diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dce454f --- /dev/null +++ b/.gitignore @@ -0,0 +1,129 @@ +# Created by https://www.gitignore.io + +### Java ### +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties + + +### Eclipse ### +*.pydevproject +.metadata +.gradle +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath + +# Eclipse Core +.project + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# PDT-specific +.buildpath + +# sbteclipse plugin +.target + +# TeXlipse plugin +.texlipse + + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties + + +### NetBeans ### +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +nbactions.xml +nb-configuration.xml +.nb-gradle/ + +confluence-plugin/src/main/typescript/tmp +confluence-plugin/src/main/typescript/node_modules + diff --git a/LICENCE.md b/LICENCE.md new file mode 100644 index 0000000..4057574 --- /dev/null +++ b/LICENCE.md @@ -0,0 +1,195 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### Terms and Conditions for use, reproduction, and distribution + +#### 1. Definitions + +“License” shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +“Licensor” shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +“Legal Entity” shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, “control” means **(i)** the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the +outstanding shares, or **(iii)** beneficial ownership of such entity. + +“You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +“Source” form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +“Object” form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +“Work” shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +“Derivative Works” shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +“Contribution” shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +“submitted” means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as “Not a Contribution.” + +“Contributor” shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +#### 2. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +#### 3. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +#### 4. Redistribution + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +* **(a)** You must give any other recipients of the Work or Derivative Works a copy of +this License; and +* **(b)** You must cause any modified files to carry prominent notices stating that You +changed the files; and +* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +#### 5. Submission of Contributions + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +#### 6. Trademarks + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +#### 7. Disclaimer of Warranty + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +#### 8. Limitation of Liability + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +#### 9. Accepting Warranty or Additional Liability + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +_END OF TERMS AND CONDITIONS_ + +### APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets `[]` replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same “printed page” as the copyright notice for easier identification within +third-party archives. + + Copyright (c) 2016 NetworkedAssets Sp. z o.o. (http://networkedassets.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..d56d4e9 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# ![](https://raw.githubusercontent.com/NetworkedAssets/autodoc/master/transformer/src/main/resources/images/transformer_logo.png "Transformer") + +Java application used by [NetworkedAssets's](http://www.networkedassets.com/) [Documentation from Code Plugin](http://condoc.networkedassets.com/) for Atlassian Confluence. + +## Installation + +1. Make sure you've got **JDK 8** installed on your server, your **JAVA_HOME** and **PATH** environment variables are properly set. + +```bash +# javac -version +# echo $JAVA_HOME +``` + +2. Prepare your favourite SSH and SFTP clients. +3. Copy the transformer jar and transformer helper scripts to your server via sftp. Suggested location is */opt/autodoc*. +4. Connect via **SSH** to your server. + +``` +ssh root@example +``` + +5. On your server machine run **transformer-start.sh** contained in *scripts/server*. + +```bash +# /opt/autodoc/transformer-start.sh +``` + +## Default Settings + +By default properties look like this: + +``` +jetty.port=8050 +jetty.address=http://localhost/ +jetty.port= +``` + +You can change them by creating **transformer.properties** file next to the **transformer.jar** and add properties you want to override. \ No newline at end of file diff --git a/confluence-plugin/LICENCE.md b/confluence-plugin/LICENCE.md new file mode 100644 index 0000000..4057574 --- /dev/null +++ b/confluence-plugin/LICENCE.md @@ -0,0 +1,195 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### Terms and Conditions for use, reproduction, and distribution + +#### 1. Definitions + +“License” shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +“Licensor” shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +“Legal Entity” shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, “control” means **(i)** the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the +outstanding shares, or **(iii)** beneficial ownership of such entity. + +“You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +“Source” form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +“Object” form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +“Work” shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +“Derivative Works” shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +“Contribution” shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +“submitted” means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as “Not a Contribution.” + +“Contributor” shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +#### 2. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +#### 3. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +#### 4. Redistribution + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +* **(a)** You must give any other recipients of the Work or Derivative Works a copy of +this License; and +* **(b)** You must cause any modified files to carry prominent notices stating that You +changed the files; and +* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +#### 5. Submission of Contributions + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +#### 6. Trademarks + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +#### 7. Disclaimer of Warranty + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +#### 8. Limitation of Liability + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +#### 9. Accepting Warranty or Additional Liability + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +_END OF TERMS AND CONDITIONS_ + +### APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets `[]` replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same “printed page” as the copyright notice for easier identification within +third-party archives. + + Copyright (c) 2016 NetworkedAssets Sp. z o.o. (http://networkedassets.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/confluence-plugin/README.md b/confluence-plugin/README.md new file mode 100644 index 0000000..e6604e8 --- /dev/null +++ b/confluence-plugin/README.md @@ -0,0 +1,13 @@ +# + +Plugin for Confluence - Team Collaboration Software from Atlassian created by [NetworkedAssets](http://www.networkedassets.com/). For more detailed information, please have a look onto [Documentation from Code Plugin](http://condoc.networkedassets.com/). + +## Installation + +1. Log in to Confluence as administrator. +2. Install [DoC Plugin](http://www.google.com) via Atlassian Marketplace. +3. Log in to Stash and/or Bitbucket. +4. Install [Event Listener for Stash](http://www.google.com) and/or [Event Listener for Bitbucket](http://www.google.com) via Atlassian Marketplace. +5. Download [The Transformer java project](https://github.com/networkedassets/transformer). +6. Get your Transformer up and running following [our guide](https://github.com/networkedassets/transformer/README.md). + diff --git a/confluence-plugin/pom.xml b/confluence-plugin/pom.xml new file mode 100644 index 0000000..725fcee --- /dev/null +++ b/confluence-plugin/pom.xml @@ -0,0 +1,208 @@ + + + + 4.0.0 + confluence-plugin + 0.4.5 + + com.networkedassets.autodoc + autodoc-parent + 0.4.5 + + + NetworkedAssets Sp. z o.o + http://www.networkedassets.com/en/ + + DoC + DoC macro displaying documentation in various forms on pages + atlassian-plugin + + + + junit + junit + 4.12 + + + com.atlassian.confluence + confluence + ${confluence.version} + provided + + + com.atlassian.activeobjects + activeobjects-plugin + 1.1.3 + provided + + + com.networkedassets.autodoc + functional-utils + 0.4.5 + + + com.mashape.unirest + unirest-java + 1.4.7 + + + com.fasterxml.jackson.core + jackson-databind + 2.8.1 + + + + + com.atlassian.plugins + atlassian-plugins-osgi-testrunner + ${plugin.testrunner.version} + test + + + javax.ws.rs + jsr311-api + 1.1.1 + provided + + + javax.servlet + servlet-api + 2.4 + provided + + + org.slf4j + slf4j-api + 1.6.6 + provided + + + + + com.atlassian.upm + licensing-api + 2.18.5 + provided + + + com.atlassian.upm + upm-api + 2.18.5 + provided + + + + + + + + com.atlassian.maven.plugins + maven-confluence-plugin + ${amps.version} + true + + ${confluence.version} + ${confluence.data.version} + false + + + + maven-compiler-plugin + + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19 + + + **/*IntegrationTest.java + + + + + org.apache.maven.surefire + surefire-junit47 + 2.19 + + + + + + com.github.eirslett + frontend-maven-plugin + 1.0 + + + src/main/typescript + target + + + + + install node and npm + + install-node-and-npm + + + v6.2.2 + 3.9.5 + + + + + npm install + + npm + + + + install + + + + + npm build + + npm + + compile + + + run prod + + + + + + + + + + + atlassian-public2 + https://maven.atlassian.com/content/repositories/atlassian-public + + true + never + warn + + + true + warn + + + + + + 5.8.6 + 5.8.6 + 5.0.13 + 1.2.3 + + diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/DocMacro.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/DocMacro.java new file mode 100644 index 0000000..5b908bf --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/DocMacro.java @@ -0,0 +1,60 @@ +package com.networkedassets.autodoc; + +import com.atlassian.confluence.content.render.xhtml.ConversionContext; +import com.atlassian.confluence.macro.Macro; +import com.atlassian.confluence.macro.MacroExecutionException; +import com.atlassian.confluence.renderer.radeox.macros.MacroUtils; +import com.atlassian.confluence.util.velocity.VelocityUtils; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Map; +import java.util.stream.Collectors; + +public class DocMacro implements Macro { + private Logger log = LoggerFactory.getLogger(DocMacro.class); + + @Override + public String execute(Map params, String s, ConversionContext conversionContext) throws MacroExecutionException { + String macroSection; + String resourcesPath = "download/resources/com.networkedassets.autodoc.confluence-plugin:macro-resources/macroResources/"; + + try { + macroSection = IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("/frontend/index.html")); + } catch (IOException e) { + throw new MacroExecutionException(e); + } + + macroSection = ("")[0] + "section>"; + + Map context = MacroUtils.defaultVelocityContext(); + + context.put("macroSectionHtml", macroSection); + context.put("resourcesPath", resourcesPath); + + String paramsString = params.entrySet().stream().map(e -> e.getKey() + ": " + e.getValue()).collect(Collectors.joining()); + log.warn(paramsString); + + try { + context.put("paramsJson", new ObjectMapper().writeValueAsString(params)); + } catch(JsonProcessingException e) { + e.printStackTrace(); + } + + return VelocityUtils.getRenderedTemplate("/macro.vm", context); + } + + @Override + public BodyType getBodyType() { + return BodyType.NONE; + } + + @Override + public OutputType getOutputType() { + return OutputType.BLOCK; + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/FrontendResourcesAccessorService.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/FrontendResourcesAccessorService.java new file mode 100644 index 0000000..1ff19b4 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/FrontendResourcesAccessorService.java @@ -0,0 +1,65 @@ +package com.networkedassets.autodoc; + +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.io.IOUtils; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; + +@Path("frontend") +public class FrontendResourcesAccessorService { + + @GET + @Path("{path:.*}") + public Response getResource(@Context final HttpServletRequest req) { + StreamingOutput so = new StreamingOutput() { + @Override + public void write(OutputStream output) throws IOException, WebApplicationException { + InputStream res = this.getClass().getClassLoader().getResourceAsStream(req.getPathInfo()); + IOUtils.copy(res, output); + output.flush(); + } + }; + + return Response.ok(so).header("Content-Type", inferContentType(req.getPathInfo())).build(); + } + + private String inferContentType(String path) { + try { + String type = Files.probeContentType(Paths.get(path)); + if (type == null) { + String extension = FilenameUtils.getExtension(path); + switch (extension) { + case "js": + return "application/javascript"; + case "css": + return "text/css"; + case "ico": + return "image/x-icon"; + case "json": + return "application/json"; + case "png": + return "image/png"; + case "gif": + return "image/gif"; + case "jpg": + case "jpeg": + return "image/jpeg"; + } + } + return type; + } catch (IOException e) { + return "text/plain"; + } + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/TransformerClient.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/TransformerClient.java new file mode 100644 index 0000000..097cecb --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/TransformerClient.java @@ -0,0 +1,223 @@ +package com.networkedassets.autodoc; + +import com.fasterxml.jackson.databind.JsonNode; +import com.mashape.unirest.http.ObjectMapper; +import com.mashape.unirest.http.Unirest; +import com.mashape.unirest.http.exceptions.UnirestException; +import com.networkedassets.autodoc.configuration.BundleAccessTokenService; +import com.networkedassets.autodoc.configuration.DocSettingsService; +import com.networkedassets.autodoc.configuration.TokenNotFoundException; +import com.networkedassets.autodoc.documentation.Documentation; +import com.networkedassets.autodoc.documentation.DocumentationPiece; +import com.networkedassets.autodoc.documentation.transformer2.Bundle; +import com.networkedassets.autodoc.documentation.transformer2.DocItem; +import com.networkedassets.autodoc.documentation.transformer2.DocItemSet; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.conn.ssl.AllowAllHostnameVerifier; +import org.apache.http.conn.ssl.SSLContextBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.json.JSONArray; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static com.networkedassets.autodoc.documentation.transformer2.DocItemSet.JAVADOC_TYPE; +import static com.networkedassets.autodoc.documentation.transformer2.DocItemSet.UML_TYPE; + +public class TransformerClient { + private static final String BUNDLES = "/rest/bundles"; + private static final int CONNECTION_TIMEOUT = 90000; + private static final int SOCKET_TIMEOUT = 90000; + private static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER = new com.fasterxml.jackson.databind.ObjectMapper(); + + public static final Logger log = LoggerFactory.getLogger(TransformerClient.class); + + private DocSettingsService docSettingsService; + private BundleAccessTokenService bundleAccessTokenService; + + public TransformerClient(DocSettingsService docSettingsService, BundleAccessTokenService bundleAccessTokenService) { + this.docSettingsService = docSettingsService; + this.bundleAccessTokenService = bundleAccessTokenService; + log.debug("Transformer server constructing"); + Unirest.setObjectMapper(getConfiguredObjectMapper()); + Unirest.setHttpClient(getConfiguredHttpClient()); + } + + public String getUrl() { + return docSettingsService.getTransformerUrl(); + } + + private static CloseableHttpClient getConfiguredHttpClient() { + try { + + return HttpClients.custom() + .setDefaultRequestConfig(RequestConfig.custom().setSocketTimeout(SOCKET_TIMEOUT) + .setConnectTimeout(CONNECTION_TIMEOUT).build()) + .setHostnameVerifier(new AllowAllHostnameVerifier()) + .setSslcontext(new SSLContextBuilder().loadTrustMaterial(null, (_1, _2) -> true).build()).build(); + } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) { + throw new RuntimeException(e); + } + } + + private static ObjectMapper getConfiguredObjectMapper() { + return new ObjectMapper() { + private com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper = new com.fasterxml.jackson.databind.ObjectMapper(); + + @Override + public T readValue(String value, Class valueType) { + try { + return jacksonObjectMapper.readValue(value, valueType); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public String writeValue(Object value) { + try { + return jacksonObjectMapper.writeValueAsString(value); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + }; + } + + public Optional getBundleById(String macroOwnerKey, int bundleId) throws UnirestException { + String token = null; + try { + token = bundleAccessTokenService.getForUserKey(macroOwnerKey); + } catch (TokenNotFoundException e) { + return Optional.empty(); + } + JSONArray array = Unirest + .get(getUrl() + BUNDLES) + .header("Authorization", "Bearer " + token) + .asJson() + .getBody() + .getArray(); + for (int i = 0; i < array.length(); i++) { + JSONObject jsonObject = array.getJSONObject(i); + if (jsonObject.getInt("id") == bundleId) + return Optional.of(new Bundle(jsonObject.getInt("id"), jsonObject.getString("name"))); + } + return Optional.empty(); + } + + public List getAllBundles(String macroOwnerKey) throws UnirestException { + List res = new ArrayList<>(); + String token = null; + try { + token = bundleAccessTokenService.getForUserKey(macroOwnerKey); + } catch (TokenNotFoundException e) { + throw new UnirestException(e); + } + JSONArray array = Unirest + .get(getUrl() + BUNDLES) + .header("Authorization", "Bearer " + token) + .asJson() + .getBody() + .getArray(); + for (int i = 0; i < array.length(); i++) { + JSONObject jsonObject = array.getJSONObject(i); + res.add(new Bundle(jsonObject.getInt("id"), jsonObject.getString("name"))); + } + return res; + } + + public Optional getDocumentation(String macroOwnerKey, Bundle bundle, String documentationType) throws UnirestException { + final String token; + try { + token = bundleAccessTokenService.getForUserKey(macroOwnerKey); + } catch (TokenNotFoundException e) { + return Optional.empty(); + } + List docItemSetList = getDocItemSets(token, bundle); + String type = documentationType.equals("uml") ? UML_TYPE : JAVADOC_TYPE; + return docItemSetList.stream().filter(docItemSet -> docItemSet.getType().equals(type)).findAny() + .flatMap(docItemSet -> { + try { + JSONObject docItemSetJson = Unirest + .get(getUrl() + "/rest/docitemsets/{id}") + .routeParam("id", String.valueOf(docItemSet.getId())) + .header("Authorization", "Bearer " + token) + .asJson() + .getBody() + .getObject(); + JSONArray docItems = docItemSetJson.getJSONArray("docItems"); + JSONObject docItem = docItems.getJSONObject(0); + String content = docItem.getString("content"); + JsonNode jsonNode = OBJECT_MAPPER.readTree(content); + JsonNode pieces = jsonNode.get("pieces"); + Documentation doc = new Documentation(); + doc.setDocumentationType(documentationType); + doc.setBundle(bundle.getName()); + List docPieces = new ArrayList<>(); + for (JsonNode piece: pieces) { + DocumentationPiece documentationPiece = new DocumentationPiece(); + documentationPiece.setDocumentation(doc); + documentationPiece.setPieceName(piece.get("pieceName").asText()); + documentationPiece.setPieceType(piece.get("pieceType").asText()); + documentationPiece.setContent(piece.get("content").asText()); + docPieces.add(documentationPiece); + } + doc.setDocumentationPieces(docPieces); + return Optional.of(doc); + } catch (UnirestException | IOException e) { + e.printStackTrace(); + return Optional.empty(); + } + }); + } + + private List getDocItemSets(String token, Bundle bundle) throws UnirestException { + JSONObject bundleJson = Unirest + .get(getUrl() + "/rest/bundles/{id}") + .routeParam("id", Integer.toString(bundle.getId())) + .header("Authorization", "Bearer " + token) + .asJson() + .getBody() + .getObject(); + JSONArray sourceUnits = bundleJson.getJSONArray("sourceUnits"); + List res = new ArrayList<>(); + for (int i = 0; i < sourceUnits.length(); i++) { + JSONArray docItemSets = sourceUnits.getJSONObject(i).getJSONArray("docItemSets"); + for (int j = 0; j < docItemSets.length(); j++) { + JSONObject docItemSet = docItemSets.getJSONObject(j); + List docItems = getDocItems(docItemSet); + res.add(new DocItemSet(docItemSet.getString("type"), docItems, docItemSet.getInt("id"))); + } + } + return res; + } + + private List getDocItems(JSONObject docItemSet) { + ArrayList res = new ArrayList<>(); + JSONArray docItems = docItemSet.getJSONArray("docItems"); + for (int i = 0; i < docItems.length(); i++) { + JSONObject docItem = docItems.getJSONObject(i); + res.add(new DocItem(docItem.getInt("id"))); + } + return res; + } + + public String getToken(BundleAccessTokenService.Credentials credentials) throws UnirestException { + return Unirest.put(getUrl() + "/rest/users/signIn") + .header("Content-Type", "application/json") + .body(credentials) + .asJson() + .getBody() + .getObject() + .getString("token"); + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/AdminConfigurationAction.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/AdminConfigurationAction.java new file mode 100644 index 0000000..8570663 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/AdminConfigurationAction.java @@ -0,0 +1,25 @@ +package com.networkedassets.autodoc.configuration; + +import com.atlassian.confluence.core.ConfluenceActionSupport; +import org.apache.commons.io.IOUtils; + +import java.io.IOException; + +public class AdminConfigurationAction extends ConfluenceActionSupport { + + public String load() { + return ConfluenceActionSupport.SUCCESS; + } + + public String save() { + return ConfluenceActionSupport.SUCCESS; + } + + public String getInnerHtml() throws IOException { + String html; + html = IOUtils.toString( + this.getClass().getClassLoader().getResourceAsStream("/configurationResources/configuration.html")); + html = (html.split("")[1]).split("")[0]; + return html; + } +} \ No newline at end of file diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/BundleAccessToken.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/BundleAccessToken.java new file mode 100644 index 0000000..7e29f47 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/BundleAccessToken.java @@ -0,0 +1,19 @@ +package com.networkedassets.autodoc.configuration; + +import net.java.ao.Entity; +import net.java.ao.Preload; +import net.java.ao.schema.Indexed; +import net.java.ao.schema.Unique; + +@Preload +public interface BundleAccessToken extends Entity { + @Indexed + @Unique + String getUserKey(); + @Indexed + @Unique + void setUserKey(String userKey); + + String getAccessToken(); + void setAccessToken(String token); +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/BundleAccessTokenService.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/BundleAccessTokenService.java new file mode 100644 index 0000000..d497043 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/BundleAccessTokenService.java @@ -0,0 +1,78 @@ +package com.networkedassets.autodoc.configuration; + +import com.atlassian.activeobjects.external.ActiveObjects; +import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; +import com.google.common.collect.ImmutableMap; +import com.mashape.unirest.http.exceptions.UnirestException; +import com.networkedassets.autodoc.TransformerClient; +import com.networkedassets.util.functional.Optionals; +import net.java.ao.Query; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; + +@Path("token") +@Consumes("application/json") +public class BundleAccessTokenService { + + private TransformerClient transformerClient; + private ActiveObjects ao; + + public BundleAccessTokenService(ActiveObjects ao, DocSettingsService docSettingsService) { + this.ao = ao; + this.transformerClient = new TransformerClient(docSettingsService, this); + } + + public String getForUserKey(String userKey) throws TokenNotFoundException { + BundleAccessToken accessToken = null; + + try { + accessToken = ao.executeInTransaction(() -> + ao.find(BundleAccessToken.class, Query.select().where("USER_KEY = ?", userKey))[0] + ); + } catch (ArrayIndexOutOfBoundsException e) { + throw new TokenNotFoundException(); + } + + return accessToken.getAccessToken(); + } + + public void setForUserKey(String userKey, String token) { + ao.executeInTransaction(() -> { + BundleAccessToken accessToken = + Optionals.fromArrayOfOne( + ao.find(BundleAccessToken.class, Query.select().where("USER_KEY = ?", userKey)) + ).orElse( + ao.create(BundleAccessToken.class, ImmutableMap.of("USER_KEY", userKey)) + ); + accessToken.setAccessToken(token); + accessToken.save(); + return accessToken; + }); + } + + public void setForCurrentUser(String token) { + setForUserKey(AuthenticatedUserThreadLocal.get().getKey().getStringValue(), token); + } + + @PUT + public void saveTokenForTransformerUser(Credentials credentials) throws UnirestException { + String token = transformerClient.getToken(credentials); + setForCurrentUser(token); + } + + @GET + @Path("ask") + public boolean doesCurrentUserHaveToken() { + String userKey = AuthenticatedUserThreadLocal.get().getKey().getStringValue(); + return ao.executeInTransaction(() -> + ao.find(BundleAccessToken.class, Query.select().where("USER_KEY = ?", userKey)).length == 1); + } + + public static class Credentials { + public String username; + public String password; + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/ConfigurationService.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/ConfigurationService.java new file mode 100644 index 0000000..d98af93 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/ConfigurationService.java @@ -0,0 +1,55 @@ +package com.networkedassets.autodoc.configuration; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.mashape.unirest.http.exceptions.UnirestException; +import com.networkedassets.autodoc.TransformerClient; +import com.networkedassets.autodoc.documentation.transformer2.Bundle; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; +import java.text.SimpleDateFormat; +import java.util.List; + +@Path("/configuration/") +public class ConfigurationService { + + private static final Logger log = LoggerFactory.getLogger(ConfigurationService.class); + private static ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + private final DocSettingsService docSettingsService; + private final TransformerClient transformerClient; + + public ConfigurationService(DocSettingsService docSettingsService, BundleAccessTokenService bundleAccessTokenService) { + this.docSettingsService = docSettingsService; + transformerClient = new TransformerClient(docSettingsService, bundleAccessTokenService); + + OBJECT_MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd")); + OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + @Path("transformerUrl") + @GET + public String getTransformerUrl() { + return docSettingsService.getTransformerUrl(); + } + + @Path("transformerUrl") + @POST + public void setTransformerUrl(String transformerUrl) { + docSettingsService.setTransformerUrl(transformerUrl); + } + + @Path("bundles") + @GET + public Response getAllBundles(@HeaderParam("X-Macro-Owner") String macroOwnerKey) throws JsonProcessingException, UnirestException { + List res = transformerClient.getAllBundles(macroOwnerKey); + return Response.ok(OBJECT_MAPPER.writeValueAsString(res)).build(); + } + +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/DocSettingsService.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/DocSettingsService.java new file mode 100644 index 0000000..f240b95 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/DocSettingsService.java @@ -0,0 +1,50 @@ +package com.networkedassets.autodoc.configuration; + +import com.atlassian.core.util.ClassLoaderUtils; +import com.atlassian.sal.api.pluginsettings.PluginSettings; +import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +@SuppressWarnings("WeakerAccess") +public class DocSettingsService { + public static final String TRANSFORMER_URL = "com.networkedassets.autodoc.configuration.TRANSFORMER_URL"; + private final Logger log = LoggerFactory.getLogger(DocSettingsService.class); + private final PluginSettings pluginSettings; + + public DocSettingsService(PluginSettingsFactory pluginSettingsFactory) { + pluginSettings = pluginSettingsFactory.createGlobalSettings(); + } + + public String getTransformerUrl() { + String url; + url = (String) pluginSettings.get(TRANSFORMER_URL); + if (url == null) { + url = getTransformerUrlFromConfigFile(); + pluginSettings.put(TRANSFORMER_URL, url); + } + return url; + } + + private String getTransformerUrlFromConfigFile() { + InputStream properties = ClassLoaderUtils.getResourceAsStream("autodoc_confluence.properties", getClass()); + Properties props = new Properties(); + try { + props.load(properties); + } catch (IOException e) { + log.error("Couldn't load the configuration file", e); + } + return props.getProperty("transformerUrl", "https://localhost:8080/transformer"); + } + + public void setTransformerUrl(String transformerUrl) { + if (transformerUrl.endsWith("/")) { + transformerUrl = transformerUrl.substring(0, transformerUrl.length() - 1); + } + pluginSettings.put(TRANSFORMER_URL, transformerUrl); + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/TokenNotFoundException.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/TokenNotFoundException.java new file mode 100644 index 0000000..f857cb1 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/configuration/TokenNotFoundException.java @@ -0,0 +1,4 @@ +package com.networkedassets.autodoc.configuration; + +public class TokenNotFoundException extends Exception { +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/Documentation.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/Documentation.java new file mode 100644 index 0000000..da06c9c --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/Documentation.java @@ -0,0 +1,37 @@ +package com.networkedassets.autodoc.documentation; + +import java.util.List; + +public class Documentation { + private String documentationType; + private String bundle; + private List documentationPieces; + + public String getDocumentationType() { + return documentationType; + } + + public Documentation setDocumentationType(String documentationType) { + this.documentationType = documentationType; + return this; + } + + + public List getDocumentationPieces() { + return documentationPieces; + } + + public Documentation setDocumentationPieces(List documentationPieces) { + this.documentationPieces = documentationPieces; + return this; + } + + public String getBundle() { + return bundle; + } + + public Documentation setBundle(String bundle) { + this.bundle = bundle; + return this; + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationPiece.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationPiece.java new file mode 100644 index 0000000..f2437e1 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationPiece.java @@ -0,0 +1,46 @@ +package com.networkedassets.autodoc.documentation; + +public class DocumentationPiece { + private String pieceName; + private String pieceType; + private String content; + private Documentation documentation; + + public String getPieceName() { + return pieceName; + } + + public void setPieceName(String name) { + this.pieceName = name; + } + + /** + * Type of this documentation piece. Ex. for piece of javadoc this may be "class", "package" + */ + public String getPieceType() { + return pieceType; + } + + public DocumentationPiece setPieceType(String pieceType) { + this.pieceType = pieceType; + return this; + } + + public String getContent() { + return content; + } + + public DocumentationPiece setContent(String content) { + this.content = content; + return this; + } + + public Documentation getDocumentation() { + return documentation; + } + + public DocumentationPiece setDocumentation(Documentation documentation) { + this.documentation = documentation; + return this; + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationProxyResource.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationProxyResource.java new file mode 100644 index 0000000..ca1e0c4 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationProxyResource.java @@ -0,0 +1,52 @@ +package com.networkedassets.autodoc.documentation; + +import com.mashape.unirest.http.HttpResponse; +import com.mashape.unirest.http.Unirest; +import com.mashape.unirest.http.exceptions.UnirestException; +import com.mashape.unirest.request.GetRequest; +import com.networkedassets.autodoc.configuration.BundleAccessTokenService; +import com.networkedassets.autodoc.configuration.DocSettingsService; +import com.networkedassets.autodoc.configuration.TokenNotFoundException; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/transformer/") +@Produces({MediaType.APPLICATION_JSON}) +public class DocumentationProxyResource { + + private BundleAccessTokenService bundleAccessTokenService; + + private DocSettingsService docSettingsService; + + public DocumentationProxyResource(BundleAccessTokenService bundleAccessTokenService, DocSettingsService docSettingsService) { + this.bundleAccessTokenService = bundleAccessTokenService; + this.docSettingsService = docSettingsService; + } + + @GET + @Path("{path:.*}") + public Response proxy(@HeaderParam("X-Macro-Owner") String macroOwner, @PathParam("path") String path, @Context HttpServletRequest request) { + try { + String url = docSettingsService.getTransformerUrl() + "/rest/" + path + ((request.getQueryString() != null) ? "?" + request.getQueryString() : ""); + + GetRequest unirestRequest = Unirest.get(url) + .header("Authorization", "Bearer " + bundleAccessTokenService.getForUserKey(macroOwner)); + HttpResponse response = unirestRequest + .asString(); + + return Response + .status(response.getStatus()) + .entity(response.getBody()) + .header("Content-Type", response.getHeaders().get("Content-Type")) + .build(); + } catch (UnirestException e) { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Unirest exception").build(); + } catch (TokenNotFoundException e) { + return Response.status(Response.Status.UNAUTHORIZED).build(); + } + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationRepository.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationRepository.java new file mode 100644 index 0000000..d34d701 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationRepository.java @@ -0,0 +1,65 @@ +package com.networkedassets.autodoc.documentation; + +import com.mashape.unirest.http.exceptions.UnirestException; +import com.networkedassets.autodoc.TransformerClient; +import com.networkedassets.autodoc.configuration.BundleAccessTokenService; +import com.networkedassets.autodoc.configuration.DocSettingsService; +import com.networkedassets.util.functional.Throwing; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +public class DocumentationRepository { + private TransformerClient tc; + + public DocumentationRepository( + DocSettingsService docSettingsService, + BundleAccessTokenService bundleAccessTokenService + ) { + this.tc = new TransformerClient(docSettingsService, bundleAccessTokenService); + } + + public Optional findDocumentation( + String macroOwnerKey, + int bundleId, + String documentationType + ) { + try { + return tc.getBundleById(macroOwnerKey, bundleId).flatMap(Throwing.functionRethrowAsRuntimeException( + bundle -> tc.getDocumentation(macroOwnerKey, bundle, documentationType))); + } catch (UnirestException e) { + throw new RuntimeException(e); + } + } + + public Optional findDocumentationPiece( + String macroOwnerKey, + int bundleId, + String docType, + String docPieceName + ) { + return findDocumentation(macroOwnerKey, bundleId, docType) + .flatMap(d -> findDocumentationPieceInDocumentation(d, docPieceName)); + } + + public Optional findDocumentationPieceInDocumentation(Documentation doc, String docPieceName) { + return doc.getDocumentationPieces().stream().filter(dp -> docPieceName.equals(dp.getPieceName())).findAny(); + } + + public List findDocumentationPieceWithQuery( + String macroOwnerKey, + int bundleId, + String doctype, + String query + ) { + Optional documentation = findDocumentation(macroOwnerKey, bundleId, doctype); + return documentation.map(doc -> + doc.getDocumentationPieces().parallelStream() + .filter(dp -> Pattern.compile(query).matcher(dp.getContent()).find()) + .collect(Collectors.toList()) + ).orElse(Collections.emptyList()); + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationService.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationService.java new file mode 100644 index 0000000..b88848c --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/DocumentationService.java @@ -0,0 +1,127 @@ +package com.networkedassets.autodoc.documentation; + +import com.atlassian.json.jsonorg.JSONException; +import com.atlassian.json.jsonorg.JSONObject; +import com.google.common.base.Joiner; +import com.google.common.base.Strings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +@Path("/documentation/") +@Produces({MediaType.APPLICATION_JSON}) +public class DocumentationService { + private final String ERROR_JSON = "{\"success\": false, \"message\": \"Could not find requested documentation!\"}"; + private DocumentationRepository docRepository; + @SuppressWarnings("unused") + private Logger log = LoggerFactory.getLogger(DocumentationService.class); + + public DocumentationService(DocumentationRepository docRepository) { + this.docRepository = docRepository; + } + + @Path("{bundle}/{doctype}") + @GET + public Response getDocumentationPiecesForProject( + @HeaderParam("X-Macro-Owner") String macroOwnerKey, + @PathParam("bundle") int bundle, + @PathParam("doctype") String doctype + ) throws UnsupportedEncodingException { + String doctypeDec = URLDecoder.decode(doctype, "UTF-8"); + + if ("uml".equalsIgnoreCase(doctypeDec)) + return getDocumentationPiece(macroOwnerKey, bundle, doctypeDec, "all"); + return docRepository.findDocumentation(macroOwnerKey, bundle, doctypeDec) + .map(d -> Response.ok("{\"success\": true, \"documentationPieces\": [" + + d.getDocumentationPieces().stream() + .map(dp -> "{\"type\": \"" + dp.getPieceType() + "\"," + + "\"name\": \"" + dp.getPieceName() + "\"}") + .collect(Collectors.joining(",")) + + "]}")) + .orElse(Response.status(404).entity(ERROR_JSON)).build(); + } + + @Path("{bundle}/{doctype}/{docPieceName}") + @GET + public Response getDocumentationPiece( + @HeaderParam("X-Macro-Owner") String macroOwnerKey, + @PathParam("bundle") int bundle, + @PathParam("doctype") String docType, + @PathParam("docPieceName") String docPieceName + ) throws UnsupportedEncodingException { + String doctypeDec = URLDecoder.decode(docType, "UTF-8"); + String docPieceNameDec = URLDecoder.decode(docPieceName, "UTF-8"); + + Optional documentationPiece = + docRepository.findDocumentationPiece(macroOwnerKey, bundle, doctypeDec, docPieceNameDec); + + return documentationPiece.map(this::makeDocPieceJson) + .map(n -> Response.ok(n).build()) + .orElse(Response.status(404).entity(ERROR_JSON).build()); + } + + @Path("{bundle}/{doctype}/{docPieceName}/{attribute}") + @GET + public Response getDocumentationPieceByAttribute( + @HeaderParam("X-Macro-Owner") String macroOwnerKey, + @PathParam("bundle") int bundle, + @PathParam("doctype") String docType, + @PathParam("docPieceName") String docPieceName, + @PathParam("attribute") String attribute + ) throws UnsupportedEncodingException { + String doctypeDec = URLDecoder.decode(docType, "UTF-8"); + String docPieceNameDec = URLDecoder.decode(docPieceName, "UTF-8"); + String attributeDec = URLDecoder.decode(attribute, "UTF-8"); + + Optional documentationPiece = + docRepository.findDocumentationPiece(macroOwnerKey, bundle, doctypeDec, docPieceNameDec); + + return documentationPiece.map(docPiece -> makeDocPieceJson(docPiece, attributeDec)) + .map(n -> Response.ok(n).build()) + .orElse(Response.status(404).entity(ERROR_JSON).build()); + } + + private String makeDocPieceJson(DocumentationPiece dp) { + return dp.getContent(); + } + + private String makeDocPieceJson(DocumentationPiece dp, String attribute) { + JSONObject jsonObject = new JSONObject(dp.getContent()); + try { + return String.format("{\"%s\": \"%s\"}", attribute, jsonObject.getString(attribute)); + } catch (JSONException e) { + return null; + } + } + + @Path("{bundle}/{doctype}/search") + @GET + public Response searchDocumentation( + @HeaderParam("X-Macro-Owner") String macroOwnerKey, + @PathParam("bundle") int bundle, + @PathParam("doctype") String doctype, + @QueryParam("q") String query + ) throws UnsupportedEncodingException { + + if (Strings.isNullOrEmpty(query)) return Response.ok("{\"results\": []}").build(); + String queryDec = URLDecoder.decode(query, "UTF-8"); + String doctypeDec = URLDecoder.decode(doctype, "UTF-8"); + + List searchResult = + docRepository.findDocumentationPieceWithQuery(macroOwnerKey, bundle, doctypeDec, queryDec); + + final List results = searchResult.stream() + .map(dp -> "\"" + dp.getPieceName() + "\"") + .collect(Collectors.toList()); + + return Response.ok(String.format("{\"results\": [%s]}", Joiner.on(",").join(results))).build(); + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/transformer2/Bundle.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/transformer2/Bundle.java new file mode 100644 index 0000000..fa38f73 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/transformer2/Bundle.java @@ -0,0 +1,29 @@ +package com.networkedassets.autodoc.documentation.transformer2; + +public class Bundle { + private int id; + private String name; + + public Bundle(int id, String name) { + this.id = id; + this.name = name; + } + + public int getId() { + return id; + } + + public Bundle setId(int id) { + this.id = id; + return this; + } + + public String getName() { + return name; + } + + public Bundle setName(String name) { + this.name = name; + return this; + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/transformer2/DocItem.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/transformer2/DocItem.java new file mode 100644 index 0000000..2e53d56 --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/transformer2/DocItem.java @@ -0,0 +1,18 @@ +package com.networkedassets.autodoc.documentation.transformer2; + +public class DocItem { + private int id; + + public DocItem(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public DocItem setId(int id) { + this.id = id; + return this; + } +} diff --git a/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/transformer2/DocItemSet.java b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/transformer2/DocItemSet.java new file mode 100644 index 0000000..99b089e --- /dev/null +++ b/confluence-plugin/src/main/java/com/networkedassets/autodoc/documentation/transformer2/DocItemSet.java @@ -0,0 +1,45 @@ +package com.networkedassets.autodoc.documentation.transformer2; + +import java.util.List; + +public class DocItemSet { + public static final String UML_TYPE = "CLASS_DIAGRAM"; + public static final String JAVADOC_TYPE = "JSON"; + + private String type; + private List docItems; + private int id; + + public DocItemSet(String type, List docItems, int id) { + this.type = type; + this.docItems = docItems; + this.id = id; + } + + public String getType() { + return type; + } + + public DocItemSet setType(String type) { + this.type = type; + return this; + } + + public List getDocItems() { + return docItems; + } + + public DocItemSet setDocItems(List docItems) { + this.docItems = docItems; + return this; + } + + public int getId() { + return id; + } + + public DocItemSet setId(int id) { + this.id = id; + return this; + } +} diff --git a/confluence-plugin/src/main/resources/atlassian-plugin.xml b/confluence-plugin/src/main/resources/atlassian-plugin.xml new file mode 100644 index 0000000..c19d774 --- /dev/null +++ b/confluence-plugin/src/main/resources/atlassian-plugin.xml @@ -0,0 +1,150 @@ + + + + + ${project.description} + ${project.version} + + images/pluginIcon.png + images/pluginLogo.png + images/vendorLogo.png + images/vendorIcon.png + /admin/plugins/autodoc/config.action + + false + + + + + + + + + autodoc_confluence + + + + confluence.editor.actions:editor-macro-browser + + macro-browser + + + + + + + + + + + + + + + + + com.atlassian.soy.soy-template-plugin:soy-deps + + + + + + + + + autodoc_confluence + + + + + + + + + + + + + Component to access Active Objects functionality from the + plugin + + + + + + + + + + + /configurationResources/adminConfiguration.vm + + /configurationResources/adminConfiguration.vm + + + + + /configurationResources/adminConfiguration.vm + + /admin/plugins/autodoc/config.action + + + + + + + + + DoC macro displaying documentation in various forms on pages + + + + + + + + + + + + + + Provides REST endpoints used by DoC + + + + + + + + com.networkedassets.autodoc.configuration.BundleAccessToken + + diff --git a/confluence-plugin/src/main/resources/autodoc_confluence.properties b/confluence-plugin/src/main/resources/autodoc_confluence.properties new file mode 100644 index 0000000..2a4929d --- /dev/null +++ b/confluence-plugin/src/main/resources/autodoc_confluence.properties @@ -0,0 +1,7 @@ +#put any key/value pairs here +my.plugin.name=Autodoc +autodoc-configuration-link.label=Autodoc Configuration Link +autodoc-configuration-link.name=Autodoc Configuration Link +autodoc-configuration-link.description=The Autodoc Configuration Link Plugin +autodoc-configuration-action.on-set-message=Configuration saved! +transformerUrl=http://localhost:8080/transformer diff --git a/confluence-plugin/src/main/resources/configurationResources/adminConfiguration.vm b/confluence-plugin/src/main/resources/configurationResources/adminConfiguration.vm new file mode 100644 index 0000000..85d8dca --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/adminConfiguration.vm @@ -0,0 +1,20 @@ +#set ( $d = "$") + + + Configure DoC + + + #requireResource("confluence.web.resources:ajs") + #requireResource("com.atlassian.auiplugin:aui-select2") + #requireResource("com.atlassian.auiplugin:aui-toggle") + #requireResource("com.atlassian.auiplugin:dialog2") + #requireResource("com.networkedassets.autodoc.confluence-plugin:configuration-resources") + #putMetadata('configLocation', "admin") + + + + #parse ( "/template/includes/actionmessages.vm" ) + #parse ( "/template/includes/actionerrors.vm" ) + $innerHtml + + \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/configuration.html b/confluence-plugin/src/main/resources/configurationResources/configuration.html new file mode 100644 index 0000000..e32dbd8 --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/configuration.html @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ + +
+
+ +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/css/doc_config.css b/confluence-plugin/src/main/resources/configurationResources/css/doc_config.css new file mode 100644 index 0000000..1901f99 --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/css/doc_config.css @@ -0,0 +1,142 @@ +#doc_config-loading { + height: 200px; + width: 100%; +} + +.doc_config-event div.inline-block { + display: inline-block; + vertical-align: top; +} + +#doc_config-branch div.table, #doc_config-admin div.table { + display: table; + width: 100%; +} + +#doc_config-branch div.table div.table-row, #doc_config-admin div.table-row { + display: table-row; +} + +#doc_config-branch div.table div.table-row > div, #doc_config-branch-container .table-cell, #doc_config-admin .table-cell { + display: table-cell; + vertical-align: top; + padding: 20px; +} + +#doc_config-branch-menu { + width: 200px; +} + +#doc_config-branch-menu form > div { + display: block; +} + +#doc_config-branch-container div.aui-message { + display: inline-block; +} + +#doc_config-sources form { + display: inline-block; + vertical-align: top; + margin-top: 20px; + width: 400px; +} + +.doc-aui-button-group .aui-button-primary { + font-weight: normal; +} + +#doc_config-branch-container .table-cell, #doc_config-admin .table-cell { + display: table-cell; + width: 48%; +} + +#doc_config-admin .table-cell:first-of-type { + border-right: 1px solid #ccc; +} + +.doc_config-branch-event { + border-bottom: 1px solid #eee; + padding-top: 20px; + padding-bottom: 5px; +} + +.doc_config-branch-event.even { + background: #fafafa; +} + +#doc_config-branch-container h4 { + margin-top: 1em; +} + +#doc_config .spin { + display: inline-block; + /*width: 20px; + height: 20px;*/ + padding-left: 10px; + height: 5px; +} + +#doc_config .spin.block { + display: block; + height: 100px; + width: 100%; +} + +span.doc_config-branch-menu-option span.indicator { + display: inline-block; + color: #ccc; + width: 10px; +} + +span.doc_config-branch-menu-option.listened { + font-weight: bold; +} + +span.doc_config-branch-menu-option.listened span.indicator { + color: #67ab49; + font-size: 12px; +} + +#doc_config-admin div.aui-message-warning, #doc_config-admin div.aui-message-error { + display: inline-block; +} + +#doc_config-admin div.source { + padding: 20px; +} + +#doc_config-admin div.source.even { + background: #f5f5f5; +} + +#doc_config-admin div.source.odd { + background: #fff; +} + +#doc_config-admin .table { + margin-top: 20px; +} + +#doc_config-admin div.source p.url { + color: #666; + margin: 0; +} + +#doc_config-admin div.source button.delete { + float: right; +} + +#doc_config-admin div.source h3 { + margin: 0; +} + +#doc_config-admin .addFromAppLinksCntr { + padding-top: 1em; + text-align: center; +} + +#doc_config hr { + border: none; + border-top: 1px solid #eee; +} \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/data/checkCorrect.json b/confluence-plugin/src/main/resources/configurationResources/data/checkCorrect.json new file mode 100644 index 0000000..eb5c494 --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/data/checkCorrect.json @@ -0,0 +1,12 @@ +{ + "name": "My very sophisticated source name, isn't it?", + "slug": "staszek", + "url": "http://127.0.0.1:12345/bitbucket", + "sourceType": "STASH", + "username": "admin", + "password": null, + "sourceExists" : true, + "credentialsCorrect" : true, + "verified" : false, + "slugUnique" : true +} \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/data/settings3.json b/confluence-plugin/src/main/resources/configurationResources/data/settings3.json new file mode 100644 index 0000000..2b107f0 --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/data/settings3.json @@ -0,0 +1,435 @@ +{ + "confluenceUrl": "http://46.101.240.138:8090/", + "confluenceUsername": "mrobakowski", + "confluencePassword": "admin", + "transformerSettings": { + "transformerPort": 8050, + "localhostAddress": "https://localhost:8050/event" + }, + "sources": [{ + "id": 10, + "name": "asdf", + "url": "http://atlas.networkedassets.net:7990", + "sourceType": "STASH", + "username": "kcala", + "password": null, + "sourceExists": true, + "credentialsCorrect": true, + "nameCorrect": true, + "sourceTypeCorrect": true, + "correct": true, + "projects": { + "AUT": { + "name": "Autodoc", + "key": "AUT", + "repos": { + "autodoc": { + "name": "autodoc", + "slug": "autodoc", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "APD": { + "name": "Atlas Plugin Development", + "key": "APD", + "repos": { + "javadoc-plugin": { + "name": "Javadoc Plugin", + "slug": "javadoc-plugin", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "CAT": { + "name": "Caturday", + "key": "CAT", + "repos": { + "catrepo": { + "name": "CatRepo", + "slug": "catrepo", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "TP": { + "name": "Third Project", + "key": "TP", + "repos": { + "repo3": { + "name": "repo3", + "slug": "repo3", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + }, + "lol": { + "name": "lol", + "slug": "lol", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + }, + "lubieplacki": { + "name": "lubieplacki", + "slug": "lubieplacki", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + }, + "refs/heads/dev": { + "displayId": "dev", + "id": "refs/heads/dev", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "SP": { + "name": "Second Project", + "key": "SP", + "repos": { + "repo2": { + "name": "repo2", + "slug": "repo2", + "branches": { + "refs/heads/branch2": { + "displayId": "branch2", + "id": "refs/heads/branch2", + "listenTo": "none", + "scheduledEvents": [] + }, + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + } + }, + "hookKey": "com.networkedassets.atlasian.plugins.stash-postReceive-hook-plugin:postReceiveHookListener" + }, { + "id": 4, + "name": "olkk-changed", + "url": "http://46.101.240.138:7990", + "sourceType": "STASH", + "username": "kcala", + "password": null, + "sourceExists": true, + "credentialsCorrect": true, + "nameCorrect": true, + "sourceTypeCorrect": true, + "correct": true, + "projects": { + "AUT": { + "name": "Autodoc", + "key": "AUT", + "repos": { + "autodoc": { + "name": "autodoc", + "slug": "autodoc", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "APD": { + "name": "Atlas Plugin Development", + "key": "APD", + "repos": { + "javadoc-plugin": { + "name": "Javadoc Plugin", + "slug": "javadoc-plugin", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "CAT": { + "name": "Caturday", + "key": "CAT", + "repos": { + "catrepo": { + "name": "CatRepo", + "slug": "catrepo", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "TP": { + "name": "Third Project", + "key": "TP", + "repos": { + "repo3": { + "name": "repo3", + "slug": "repo3", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + }, + "lol": { + "name": "lol", + "slug": "lol", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + }, + "lubieplacki": { + "name": "lubieplacki", + "slug": "lubieplacki", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + }, + "refs/heads/dev": { + "displayId": "dev", + "id": "refs/heads/dev", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "SP": { + "name": "Second Project", + "key": "SP", + "repos": { + "repo2": { + "name": "repo2", + "slug": "repo2", + "branches": { + "refs/heads/branch2": { + "displayId": "branch2", + "id": "refs/heads/branch2", + "listenTo": "none", + "scheduledEvents": [] + }, + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + } + }, + "hookKey": "com.networkedassets.atlasian.plugins.stash-postReceive-hook-plugin:postReceiveHookListener" + }, { + "id": 5, + "name": "olk9", + "url": "http://46.101.240.138:7990", + "sourceType": "STASH", + "username": "kcala", + "password": null, + "sourceExists": true, + "credentialsCorrect": true, + "nameCorrect": true, + "sourceTypeCorrect": true, + "correct": true, + "projects": { + "AUT": { + "name": "Autodoc", + "key": "AUT", + "repos": { + "autodoc": { + "name": "autodoc", + "slug": "autodoc", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "APD": { + "name": "Atlas Plugin Development", + "key": "APD", + "repos": { + "javadoc-plugin": { + "name": "Javadoc Plugin", + "slug": "javadoc-plugin", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "CAT": { + "name": "Caturday", + "key": "CAT", + "repos": { + "catrepo": { + "name": "CatRepo", + "slug": "catrepo", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "TP": { + "name": "Third Project", + "key": "TP", + "repos": { + "repo3": { + "name": "repo3", + "slug": "repo3", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + }, + "lol": { + "name": "lol", + "slug": "lol", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + }, + "lubieplacki": { + "name": "lubieplacki", + "slug": "lubieplacki", + "branches": { + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + }, + "refs/heads/dev": { + "displayId": "dev", + "id": "refs/heads/dev", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + }, + "SP": { + "name": "Second Project", + "key": "SP", + "repos": { + "repo2": { + "name": "repo2", + "slug": "repo2", + "branches": { + "refs/heads/branch2": { + "displayId": "branch2", + "id": "refs/heads/branch2", + "listenTo": "none", + "scheduledEvents": [] + }, + "refs/heads/master": { + "displayId": "master", + "id": "refs/heads/master", + "listenTo": "none", + "scheduledEvents": [] + } + } + } + } + } + }, + "hookKey": "com.networkedassets.atlasian.plugins.stash-postReceive-hook-plugin:postReceiveHookListener" + } + ] +} + diff --git a/confluence-plugin/src/main/resources/configurationResources/js/app.js b/confluence-plugin/src/main/resources/configurationResources/js/app.js new file mode 100644 index 0000000..bc8fe3e --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/js/app.js @@ -0,0 +1,42 @@ +var doc_confluencePath = ""; + +if (AJS && AJS.Data) { + doc_confluencePath = AJS.Data.get("base-url")+"/"; +} else { + var arr = window.location.pathname.split("/"); + arr.splice(arr.length-1,1); + doc_confluencePath = window.location.origin+arr.join("/")+"/"; +} + +angular.module("DoC_Config",['ngResource']); + +angular.module("DoC_Config").run(function($rootScope) { + if (AJS && AJS.params && AJS.params.configLocation) { + $rootScope.location = AJS.params.configLocation; + } else { + $rootScope.location = "local"; + } +}); +angular.element(document).ready(function() { + $("#doc_config-loading").spin("large"); + AJS.$("#doc_config .spin.small").spin("small"); + AJS.$("#doc_config .spin:not(.small)").spin(); +}); + +angular.module("DoC_Config").config(function($httpProvider) { + $httpProvider.interceptors.push(function() { + return { + request: function(config) { + config.headers["X-Atlassian-Token"] = "nocheck"; + if (AJS && + AJS.params && + AJS.params.macroParamsJson && + angular.fromJson(AJS.params.macroParamsJson).macroOwner + ) { + config.headers["X-Macro-Owner"] = angular.fromJson(AJS.params.macroParamsJson).macroOwner; + } + return config; + } + }; + }); +}); \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/js/ctrl/TransformerUrlController.js b/confluence-plugin/src/main/resources/configurationResources/js/ctrl/TransformerUrlController.js new file mode 100644 index 0000000..46af117 --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/js/ctrl/TransformerUrlController.js @@ -0,0 +1,17 @@ +angular.module("DoC_Config").controller("TransformerUrlController",function($http, urlService) { + var tc = this; + + tc.get = function () { + $http.get(urlService.getRestUrlWithParams("transformerUrl")).then(function (response) { + var url = response.data; + console.log(url); + tc.url = url; + }) + }; + + tc.set = function () { + $http.post(urlService.getRestUrlWithParams("transformerUrl"), tc.url) + }; + + tc.get(); +}); \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/js/dirs/auiSelect2.js b/confluence-plugin/src/main/resources/configurationResources/js/dirs/auiSelect2.js new file mode 100644 index 0000000..ebd0b2b --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/js/dirs/auiSelect2.js @@ -0,0 +1,84 @@ +angular.module("DoC_Config").directive("auiSelect2",function($compile,$parse,$timeout) { + + var processOptions = function(data,elem) { + angular.forEach(data,function(v) { + if (v.isOptGroup) { + var optGroup = $('',{ + label: v.label + }); + processOptions(v.options,optGroup); + + optGroup.appendTo(elem); + } else { + var attrs = { + val: v.value, + text: v.label, + data: v + }; + if (v.selected) { + attrs.selected = true; + } + var option = $(''); + } + if (scope.options) { + processOptions(scope.options,select) + } + + AJS.$(select).auiSelect2(select2Options); + },true); + scope.$watch(function() { + return ngModel.$viewValue; + },function(newValue,oldValue) { + if (1 || newValue !== oldValue) { + var value = newValue; + if (typeof value != "string") { + value = ""; + } + AJS.$(select).auiSelect2("val",value); + } + }); + }, + scope: { + options: "=docOptions", + model: "=ngModel", + formatResult: "=docFormatResult", + formatSelection: "=docFormatSelection" + } + } +}); \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/js/dirs/docAuiButtonGroup.js b/confluence-plugin/src/main/resources/configurationResources/js/dirs/docAuiButtonGroup.js new file mode 100644 index 0000000..b103f1d --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/js/dirs/docAuiButtonGroup.js @@ -0,0 +1,66 @@ +angular.module("DoC_Config").directive("docAuiButtonGroup",function() { + return { + require: "ngModel", + scope: { + options: "=docOptions" + }, + link: function(scope,element,attrs,ngModel) { + var type = attrs.docType; + if (type !== "checkbox" && type !== "radio") { + type = "radio"; + } + + var initModelIfNotObject = function() { + if (typeof ngModel.$viewValue !== "object") { + var obj = {}; + angular.forEach(scope.options,function(value,key) { + obj[key] = false; + }); + ngModel.$setViewValue(obj); + } + }; + + var updateView = function() { + var btn; + if (type === "radio") { + + btn = $(element).find("button[data-value='"+ngModel.$viewValue+"']"); + element.find("button").removeClass("aui-button-primary"); + btn.addClass("aui-button-primary"); + + } else { + btn = $(element).find("button"); + btn.each(function() { + $(this).toggleClass("aui-button-primary",ngModel.$viewValue[$(this).data("value")]); + }); + + } + }; + + var renderView = function(options) { + angular.forEach(options,function(value) { + var btn = $('').click(function() { + //$(this).toggleClass("aui-button-primary"); + if (type==="radio") { + ngModel.$viewValue = $(this).data("value"); + } else { + initModelIfNotObject(); + ngModel.$viewValue[$(this).data("value")] = !ngModel.$viewValue[$(this).data("value")]; + } + ngModel.$render(); + }); + btn.appendTo(element); + }); + element.addClass("aui-buttons doc-aui-button-group"); + }; + + renderView(scope.options); + + scope.$watch(function() { + return ngModel.$viewValue; + },function() { + updateView(); + },true); + } + }; +}); \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/js/dirs/docAuiDatePicker.js b/confluence-plugin/src/main/resources/configurationResources/js/dirs/docAuiDatePicker.js new file mode 100644 index 0000000..d87d099 --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/js/dirs/docAuiDatePicker.js @@ -0,0 +1,15 @@ +angular.module("DoC_Config").directive('docAuiDatePicker', [function() { + return { + require: 'ngModel', + link: function(scope, element, attrs, ngModel) { + AJS.$(element).datePicker({ + onSelect: function(value) { + scope.$apply(function() { + ngModel.$setViewValue(value); + }); + }, + overrideBrowserDefault: true + }); + } + }; +}]); \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/js/lib/angular-resource.min.js b/confluence-plugin/src/main/resources/configurationResources/js/lib/angular-resource.min.js new file mode 100644 index 0000000..7f99686 --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/js/lib/angular-resource.min.js @@ -0,0 +1,12 @@ +/* + AngularJS v1.4.2 + (c) 2010-2015 Google, Inc. http://angularjs.org + License: MIT + */ +(function(I,d,B){'use strict';function D(f,q){q=q||{};d.forEach(q,function(d,h){delete q[h]});for(var h in f)!f.hasOwnProperty(h)||"$"===h.charAt(0)&&"$"===h.charAt(1)||(q[h]=f[h]);return q}var x=d.$$minErr("$resource"),C=/^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;d.module("ngResource",["ng"]).provider("$resource",function(){var f=this;this.defaults={stripTrailingSlashes:!0,actions:{get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}}}; + this.$get=["$http","$q",function(q,h){function u(d,g){this.template=d;this.defaults=s({},f.defaults,g);this.urlParams={}}function w(y,g,l,m){function c(b,k){var c={};k=s({},g,k);r(k,function(a,k){v(a)&&(a=a());var d;if(a&&a.charAt&&"@"==a.charAt(0)){d=b;var e=a.substr(1);if(null==e||""===e||"hasOwnProperty"===e||!C.test("."+e))throw x("badmember",e);for(var e=e.split("."),n=0,g=e.length;n").append(a).html();try{return a[0].nodeType===Na?F(d):d.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/,function(a,b){return"<"+F(b)})}catch(c){return F(d)}}function wc(a){try{return decodeURIComponent(a)}catch(b){}} + function xc(a){var b={};n((a||"").split("&"),function(a){var c,e,f;a&&(e=a=a.replace(/\+/g,"%20"),c=a.indexOf("="),-1!==c&&(e=a.substring(0,c),f=a.substring(c+1)),e=wc(e),y(e)&&(f=y(f)?wc(f):!0,qa.call(b,e)?I(b[e])?b[e].push(f):b[e]=[b[e],f]:b[e]=f))});return b}function Qb(a){var b=[];n(a,function(a,c){I(a)?n(a,function(a){b.push(ja(c,!0)+(!0===a?"":"="+ja(a,!0)))}):b.push(ja(c,!0)+(!0===a?"":"="+ja(a,!0)))});return b.length?b.join("&"):""}function ob(a){return ja(a,!0).replace(/%26/gi,"&").replace(/%3D/gi, + "=").replace(/%2B/gi,"+")}function ja(a,b){return encodeURIComponent(a).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%3B/gi,";").replace(/%20/g,b?"%20":"+")}function Yd(a,b){var d,c,e=Oa.length;for(c=0;c/,">"));}b=b||[];b.unshift(["$provide",function(b){b.value("$rootElement",a)}]);d.debugInfoEnabled&&b.push(["$compileProvider",function(a){a.debugInfoEnabled(!0)}]);b.unshift("ng");c=eb(b,d.strictDi);c.invoke(["$rootScope", + "$rootElement","$compile","$injector",function(a,b,c,d){a.$apply(function(){b.data("$injector",d);c(b)(a)})}]);return c},e=/^NG_ENABLE_DEBUG_INFO!/,f=/^NG_DEFER_BOOTSTRAP!/;S&&e.test(S.name)&&(d.debugInfoEnabled=!0,S.name=S.name.replace(e,""));if(S&&!f.test(S.name))return c();S.name=S.name.replace(f,"");fa.resumeBootstrap=function(a){n(a,function(a){b.push(a)});return c()};z(fa.resumeDeferredBootstrap)&&fa.resumeDeferredBootstrap()}function $d(){S.name="NG_ENABLE_DEBUG_INFO!"+S.name;S.location.reload()} + function ae(a){a=fa.element(a).injector();if(!a)throw Aa("test");return a.get("$$testability")}function zc(a,b){b=b||"_";return a.replace(be,function(a,c){return(c?b:"")+a.toLowerCase()})}function ce(){var a;if(!Ac){var b=pb();(oa=q(b)?S.jQuery:b?S[b]:u)&&oa.fn.on?(B=oa,M(oa.fn,{scope:Pa.scope,isolateScope:Pa.isolateScope,controller:Pa.controller,injector:Pa.injector,inheritedData:Pa.inheritedData}),a=oa.cleanData,oa.cleanData=function(b){var c;if(Rb)Rb=!1;else for(var e=0,f;null!=(f=b[e]);e++)(c= + oa._data(f,"events"))&&c.$destroy&&oa(f).triggerHandler("$destroy");a(b)}):B=N;fa.element=B;Ac=!0}}function qb(a,b,d){if(!a)throw Aa("areq",b||"?",d||"required");return a}function Qa(a,b,d){d&&I(a)&&(a=a[a.length-1]);qb(z(a),b,"not a function, got "+(a&&"object"===typeof a?a.constructor.name||"Object":typeof a));return a}function Ra(a,b){if("hasOwnProperty"===a)throw Aa("badname",b);}function Bc(a,b,d){if(!b)return a;b=b.split(".");for(var c,e=a,f=b.length,g=0;g")+c[2];for(c=c[0];c--;)d=d.lastChild;f=cb(f,d.childNodes);d=e.firstChild;d.textContent=""}else f.push(b.createTextNode(a));e.textContent="";e.innerHTML="";n(f,function(a){e.appendChild(a)});return e}function N(a){if(a instanceof N)return a;var b;E(a)&&(a=U(a), + b=!0);if(!(this instanceof N)){if(b&&"<"!=a.charAt(0))throw Ub("nosel");return new N(a)}if(b){b=X;var d;a=(d=Ef.exec(a))?[b.createElement(d[1])]:(d=Lc(a,b))?d.childNodes:[]}Mc(this,a)}function Vb(a){return a.cloneNode(!0)}function ub(a,b){b||vb(a);if(a.querySelectorAll)for(var d=a.querySelectorAll("*"),c=0,e=d.length;cl&&this.remove(t.key);return b}},get:function(a){if(l").parent()[0])});var f=O(a,b,a,c,d,e);K.$$addScopeClass(a);var g=null;return function(b,c,d){qb(b,"scope");e&&e.needsNewScope&&(b=b.$parent.$new());d=d||{};var h=d.parentBoundTranscludeFn,k=d.transcludeControllers;d=d.futureParentElement;h&&h.$$boundTransclude&&(h=h.$$boundTransclude);g||(g=(d= + d&&d[0])?"foreignobject"!==ta(d)&&d.toString().match(/SVG/)?"svg":"html":"html");d="html"!==g?B(Yb(g,B("
").append(a).html())):c?Pa.clone.call(a):a;if(k)for(var l in k)d.data("$"+l+"Controller",k[l].instance);K.$$addScopeInfo(d,b);c&&c(d,b);f&&f(b,d,d,h);return d}}function O(a,b,c,d,e,f){function g(a,c,d,e){var f,k,l,m,t,w,D;if(p)for(D=Array(c.length),m=0;mq.priority)break;if(P=q.scope)q.templateUrl||(H(P)?(Ua("new/isolated scope",O||R,q,Z),O=q):Ua("new/isolated scope",O,q,Z)),R=R||q;x=q.name;!q.templateUrl&&q.controller&&(P=q.controller,T=T||$(),Ua("'"+x+"' controller",T[x],q,Z),T[x]=q);if(P=q.transclude)ga=!0,q.$$tlb||(Ua("transclusion",n,q,Z),n=q),"element"==P?(aa=!0,A=q.priority,P=Z,Z=d.$$element=B(X.createComment(" "+x+": "+d[x]+" ")),b=Z[0],Y(f,ra.call(P,0), + b),Ia=K(P,e,A,g&&g.name,{nonTlbTranscludeDirective:n})):(P=B(Vb(b)).contents(),Z.empty(),Ia=K(P,e,u,u,{needsNewScope:q.$$isolateScope||q.$$newScope}));if(q.template)if(L=!0,Ua("template",J,q,Z),J=q,P=z(q.template)?q.template(Z,d):q.template,P=ja(P),q.replace){g=q;P=Tb.test(P)?Xc(Yb(q.templateNamespace,U(P))):[];b=P[0];if(1!=P.length||1!==b.nodeType)throw ha("tplrt",x,"");Y(f,Z,b);P={$attr:{}};var Wc=V(b,[],P),W=a.splice(F+1,a.length-(F+1));(O||R)&&y(Wc,O,R);a=a.concat(Wc).concat(W);S(d,P);M=a.length}else Z.html(P); + if(q.templateUrl)L=!0,Ua("template",J,q,Z),J=q,q.replace&&(g=q),D=Of(a.splice(F,a.length-F),Z,d,f,ga&&Ia,h,l,{controllerDirectives:T,newScopeDirective:R!==q&&R,newIsolateScopeDirective:O,templateDirective:J,nonTlbTranscludeDirective:n}),M=a.length;else if(q.compile)try{G=q.compile(Z,d,Ia),z(G)?t(null,G,N,Q):G&&t(G.pre,G.post,N,Q)}catch(da){c(da,ua(Z))}q.terminal&&(D.terminal=!0,A=Math.max(A,q.priority))}D.scope=R&&!0===R.scope;D.transcludeOnThisElement=ga;D.templateOnThisElement=L;D.transclude=Ia; + m.hasElementTranscludeDirective=aa;return D}function y(a,b,c){for(var d=0,e=a.length;dm.priority)&&-1!=m.restrict.indexOf(f)&&(k&&(m=Ob(m,{$$start:k,$$end:l})),b.push(m),h=m)}catch(D){c(D)}}return h}function G(b){if(e.hasOwnProperty(b))for(var c=a.get(b+"Directive"),d=0,f=c.length;d"+b+"";return c.childNodes[0].childNodes;default:return b}}function Q(a,b){if("srcdoc"==b)return L.HTML;var c=ta(a);if("xlinkHref"==b||"form"==c&&"action"==b||"img"!=c&&("src"==b||"ngSrc"==b))return L.RESOURCE_URL}function W(a,c,d,e,f){var g=Q(a,e);f=h[e]||f;var k=b(d,!0,g,f);if(k){if("multiple"===e&&"select"===ta(a))throw ha("selmulti",ua(a));c.push({priority:100,compile:function(){return{pre:function(a,c,h){c=h.$$observers||(h.$$observers=$());if(l.test(e))throw ha("nodomevents"); + var m=h[e];m!==d&&(k=m&&b(m,!0,g,f),d=m);k&&(h[e]=k(a),(c[e]||(c[e]=[])).$$inter=!0,(h.$$observers&&h.$$observers[e].$$scope||a).$watch(k,function(a,b){"class"===e&&a!=b?h.$updateClass(a,b):h.$set(e,a)}))}}}})}}function Y(a,b,c){var d=b[0],e=b.length,f=d.parentNode,g,h;if(a)for(g=0,h=a.length;g=b)return a;for(;b--;)8===a[b].nodeType&&Pf.call(a,b,1);return a}function Xe(){var a={},b=!1;this.register=function(b,c){Ra(b,"controller");H(b)?M(a,b):a[b]=c};this.allowGlobals=function(){b=!0};this.$get=["$injector","$window",function(d,c){function e(a,b,c,d){if(!a||!H(a.$scope))throw G("$controller")("noscp", + d,b);a.$scope[b]=c}return function(f,g,h,k){var l,m,r;h=!0===h;k&&E(k)&&(r=k);if(E(f)){k=f.match(Uc);if(!k)throw Qf("ctrlfmt",f);m=k[1];r=r||k[3];f=a.hasOwnProperty(m)?a[m]:Bc(g.$scope,m,!0)||(b?Bc(c,m,!0):u);Qa(f,m,!0)}if(h)return h=(I(f)?f[f.length-1]:f).prototype,l=Object.create(h||null),r&&e(g,r,l,m||f.name),M(function(){var a=d.invoke(f,l,g,m);a!==l&&(H(a)||z(a))&&(l=a,r&&e(g,r,l,m||f.name));return l},{instance:l,identifier:r});l=d.instantiate(f,g,m);r&&e(g,r,l,m||f.name);return l}}]}function Ye(){this.$get= + ["$window",function(a){return B(a.document)}]}function Ze(){this.$get=["$log",function(a){return function(b,d){a.error.apply(a,arguments)}}]}function Zb(a){return H(a)?da(a)?a.toISOString():db(a):a}function df(){this.$get=function(){return function(a){if(!a)return"";var b=[];oc(a,function(a,c){null===a||q(a)||(I(a)?n(a,function(a,d){b.push(ja(c)+"="+ja(Zb(a)))}):b.push(ja(c)+"="+ja(Zb(a))))});return b.join("&")}}}function ef(){this.$get=function(){return function(a){function b(a,e,f){null===a||q(a)|| + (I(a)?n(a,function(a,c){b(a,e+"["+(H(a)?c:"")+"]")}):H(a)&&!da(a)?oc(a,function(a,c){b(a,e+(f?"":"[")+c+(f?"":"]"))}):d.push(ja(e)+"="+ja(Zb(a))))}if(!a)return"";var d=[];b(a,"",!0);return d.join("&")}}}function $b(a,b){if(E(a)){var d=a.replace(Rf,"").trim();if(d){var c=b("Content-Type");(c=c&&0===c.indexOf($c))||(c=(c=d.match(Sf))&&Tf[c[0]].test(d));c&&(a=uc(d))}}return a}function ad(a){var b=$(),d;E(a)?n(a.split("\n"),function(a){d=a.indexOf(":");var e=F(U(a.substr(0,d)));a=U(a.substr(d+1));e&& + (b[e]=b[e]?b[e]+", "+a:a)}):H(a)&&n(a,function(a,d){var f=F(d),g=U(a);f&&(b[f]=b[f]?b[f]+", "+g:g)});return b}function bd(a){var b;return function(d){b||(b=ad(a));return d?(d=b[F(d)],void 0===d&&(d=null),d):b}}function cd(a,b,d,c){if(z(c))return c(a,b,d);n(c,function(c){a=c(a,b,d)});return a}function cf(){var a=this.defaults={transformResponse:[$b],transformRequest:[function(a){return H(a)&&"[object File]"!==sa.call(a)&&"[object Blob]"!==sa.call(a)&&"[object FormData]"!==sa.call(a)?db(a):a}],headers:{common:{Accept:"application/json, text/plain, */*"}, + post:ia(ac),put:ia(ac),patch:ia(ac)},xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",paramSerializer:"$httpParamSerializer"},b=!1;this.useApplyAsync=function(a){return y(a)?(b=!!a,this):b};var d=!0;this.useLegacyPromiseExtensions=function(a){return y(a)?(d=!!a,this):d};var c=this.interceptors=[];this.$get=["$httpBackend","$$cookieReader","$cacheFactory","$rootScope","$q","$injector",function(e,f,g,h,k,l){function m(b){function c(a){var b=M({},a);b.data=cd(a.data,a.headers,a.status,f.transformResponse); + a=a.status;return 200<=a&&300>a?b:k.reject(b)}function e(a,b){var c,d={};n(a,function(a,e){z(a)?(c=a(b),null!=c&&(d[e]=c)):d[e]=a});return d}if(!fa.isObject(b))throw G("$http")("badreq",b);var f=M({method:"get",transformRequest:a.transformRequest,transformResponse:a.transformResponse,paramSerializer:a.paramSerializer},b);f.headers=function(b){var c=a.headers,d=M({},b.headers),f,g,h,c=M({},c.common,c[F(b.method)]);a:for(f in c){g=F(f);for(h in d)if(F(h)===g)continue a;d[f]=c[f]}return e(d,ia(b))}(b); + f.method=sb(f.method);f.paramSerializer=E(f.paramSerializer)?l.get(f.paramSerializer):f.paramSerializer;var g=[function(b){var d=b.headers,e=cd(b.data,bd(d),u,b.transformRequest);q(e)&&n(d,function(a,b){"content-type"===F(b)&&delete d[b]});q(b.withCredentials)&&!q(a.withCredentials)&&(b.withCredentials=a.withCredentials);return r(b,e).then(c,c)},u],h=k.when(f);for(n(v,function(a){(a.request||a.requestError)&&g.unshift(a.request,a.requestError);(a.response||a.responseError)&&g.push(a.response,a.responseError)});g.length;){b= + g.shift();var m=g.shift(),h=h.then(b,m)}d?(h.success=function(a){Qa(a,"fn");h.then(function(b){a(b.data,b.status,b.headers,f)});return h},h.error=function(a){Qa(a,"fn");h.then(null,function(b){a(b.data,b.status,b.headers,f)});return h}):(h.success=dd("success"),h.error=dd("error"));return h}function r(c,d){function g(a,c,d,e){function f(){l(c,a,d,e)}J&&(200<=a&&300>a?J.put(R,[a,c,ad(d),e]):J.remove(R));b?h.$applyAsync(f):(f(),h.$$phase||h.$apply())}function l(a,b,d,e){b=-1<=b?b:0;(200<=b&&300>b?n.resolve: + n.reject)({data:a,status:b,headers:bd(d),config:c,statusText:e})}function r(a){l(a.data,a.status,ia(a.headers()),a.statusText)}function v(){var a=m.pendingRequests.indexOf(c);-1!==a&&m.pendingRequests.splice(a,1)}var n=k.defer(),D=n.promise,J,K,O=c.headers,R=t(c.url,c.paramSerializer(c.params));m.pendingRequests.push(c);D.then(v,v);!c.cache&&!a.cache||!1===c.cache||"GET"!==c.method&&"JSONP"!==c.method||(J=H(c.cache)?c.cache:H(a.cache)?a.cache:A);J&&(K=J.get(R),y(K)?K&&z(K.then)?K.then(r,r):I(K)?l(K[1], + K[0],ia(K[2]),K[3]):l(K,200,{},"OK"):J.put(R,D));q(K)&&((K=ed(c.url)?f()[c.xsrfCookieName||a.xsrfCookieName]:u)&&(O[c.xsrfHeaderName||a.xsrfHeaderName]=K),e(c.method,R,d,g,O,c.timeout,c.withCredentials,c.responseType));return D}function t(a,b){0=k&&(p.resolve(v),A(C.$$intervalId),delete f[C.$$intervalId]);n||a.$apply()},h);f[C.$$intervalId]=p;return C}var f={};e.cancel=function(a){return a&&a.$$intervalId in f?(f[a.$$intervalId].reject("canceled"),b.clearInterval(a.$$intervalId),delete f[a.$$intervalId],!0):!1};return e}]}function bc(a){a=a.split("/");for(var b=a.length;b--;)a[b]=ob(a[b]);return a.join("/")}function fd(a,b){var d=wa(a);b.$$protocol=d.protocol;b.$$host=d.hostname;b.$$port=ea(d.port)||Vf[d.protocol]|| + null}function gd(a,b){var d="/"!==a.charAt(0);d&&(a="/"+a);var c=wa(a);b.$$path=decodeURIComponent(d&&"/"===c.pathname.charAt(0)?c.pathname.substring(1):c.pathname);b.$$search=xc(c.search);b.$$hash=decodeURIComponent(c.hash);b.$$path&&"/"!=b.$$path.charAt(0)&&(b.$$path="/"+b.$$path)}function pa(a,b){if(0===b.indexOf(a))return b.substr(a.length)}function Fa(a){var b=a.indexOf("#");return-1==b?a:a.substr(0,b)}function ib(a){return a.replace(/(#.+)|#$/,"$1")}function cc(a,b,d){this.$$html5=!0;d=d||""; + fd(a,this);this.$$parse=function(a){var d=pa(b,a);if(!E(d))throw Db("ipthprfx",a,b);gd(d,this);this.$$path||(this.$$path="/");this.$$compose()};this.$$compose=function(){var a=Qb(this.$$search),d=this.$$hash?"#"+ob(this.$$hash):"";this.$$url=bc(this.$$path)+(a?"?"+a:"")+d;this.$$absUrl=b+this.$$url.substr(1)};this.$$parseLinkUrl=function(c,e){if(e&&"#"===e[0])return this.hash(e.slice(1)),!0;var f,g;y(f=pa(a,c))?(g=f,g=y(f=pa(d,f))?b+(pa("/",f)||f):a+g):y(f=pa(b,c))?g=b+f:b==c+"/"&&(g=b);g&&this.$$parse(g); + return!!g}}function dc(a,b,d){fd(a,this);this.$$parse=function(c){var e=pa(a,c)||pa(b,c),f;q(e)||"#"!==e.charAt(0)?this.$$html5?f=e:(f="",q(e)&&(a=c,this.replace())):(f=pa(d,e),q(f)&&(f=e));gd(f,this);c=this.$$path;var e=a,g=/^\/[A-Z]:(\/.*)/;0===f.indexOf(e)&&(f=f.replace(e,""));g.exec(f)||(c=(f=g.exec(c))?f[1]:c);this.$$path=c;this.$$compose()};this.$$compose=function(){var b=Qb(this.$$search),e=this.$$hash?"#"+ob(this.$$hash):"";this.$$url=bc(this.$$path)+(b?"?"+b:"")+e;this.$$absUrl=a+(this.$$url? + d+this.$$url:"")};this.$$parseLinkUrl=function(b,d){return Fa(a)==Fa(b)?(this.$$parse(b),!0):!1}}function hd(a,b,d){this.$$html5=!0;dc.apply(this,arguments);this.$$parseLinkUrl=function(c,e){if(e&&"#"===e[0])return this.hash(e.slice(1)),!0;var f,g;a==Fa(c)?f=c:(g=pa(b,c))?f=a+d+g:b===c+"/"&&(f=b);f&&this.$$parse(f);return!!f};this.$$compose=function(){var b=Qb(this.$$search),e=this.$$hash?"#"+ob(this.$$hash):"";this.$$url=bc(this.$$path)+(b?"?"+b:"")+e;this.$$absUrl=a+d+this.$$url}}function Eb(a){return function(){return this[a]}} + function id(a,b){return function(d){if(q(d))return this[a];this[a]=b(d);this.$$compose();return this}}function hf(){var a="",b={enabled:!1,requireBase:!0,rewriteLinks:!0};this.hashPrefix=function(b){return y(b)?(a=b,this):a};this.html5Mode=function(a){return $a(a)?(b.enabled=a,this):H(a)?($a(a.enabled)&&(b.enabled=a.enabled),$a(a.requireBase)&&(b.requireBase=a.requireBase),$a(a.rewriteLinks)&&(b.rewriteLinks=a.rewriteLinks),this):b};this.$get=["$rootScope","$browser","$sniffer","$rootElement","$window", + function(d,c,e,f,g){function h(a,b,d){var e=l.url(),f=l.$$state;try{c.url(a,b,d),l.$$state=c.state()}catch(g){throw l.url(e),l.$$state=f,g;}}function k(a,b){d.$broadcast("$locationChangeSuccess",l.absUrl(),a,l.$$state,b)}var l,m;m=c.baseHref();var r=c.url(),t;if(b.enabled){if(!m&&b.requireBase)throw Db("nobase");t=r.substring(0,r.indexOf("/",r.indexOf("//")+2))+(m||"/");m=e.history?cc:hd}else t=Fa(r),m=dc;var A=t.substr(0,Fa(t).lastIndexOf("/")+1);l=new m(t,A,"#"+a);l.$$parseLinkUrl(r,r);l.$$state= + c.state();var v=/^\s*(javascript|mailto):/i;f.on("click",function(a){if(b.rewriteLinks&&!a.ctrlKey&&!a.metaKey&&!a.shiftKey&&2!=a.which&&2!=a.button){for(var e=B(a.target);"a"!==ta(e[0]);)if(e[0]===f[0]||!(e=e.parent())[0])return;var h=e.prop("href"),k=e.attr("href")||e.attr("xlink:href");H(h)&&"[object SVGAnimatedString]"===h.toString()&&(h=wa(h.animVal).href);v.test(h)||!h||e.attr("target")||a.isDefaultPrevented()||!l.$$parseLinkUrl(h,k)||(a.preventDefault(),l.absUrl()!=c.url()&&(d.$apply(),g.angular["ff-684208-preventDefault"]= + !0))}});ib(l.absUrl())!=ib(r)&&c.url(l.absUrl(),!0);var n=!0;c.onUrlChange(function(a,b){q(pa(A,a))?g.location.href=a:(d.$evalAsync(function(){var c=l.absUrl(),e=l.$$state,f;a=ib(a);l.$$parse(a);l.$$state=b;f=d.$broadcast("$locationChangeStart",a,c,b,e).defaultPrevented;l.absUrl()===a&&(f?(l.$$parse(c),l.$$state=e,h(c,!1,e)):(n=!1,k(c,e)))}),d.$$phase||d.$digest())});d.$watch(function(){var a=ib(c.url()),b=ib(l.absUrl()),f=c.state(),g=l.$$replace,m=a!==b||l.$$html5&&e.history&&f!==l.$$state;if(n|| + m)n=!1,d.$evalAsync(function(){var b=l.absUrl(),c=d.$broadcast("$locationChangeStart",b,a,l.$$state,f).defaultPrevented;l.absUrl()===b&&(c?(l.$$parse(a),l.$$state=f):(m&&h(b,g,f===l.$$state?null:l.$$state),k(a,f)))});l.$$replace=!1});return l}]}function jf(){var a=!0,b=this;this.debugEnabled=function(b){return y(b)?(a=b,this):a};this.$get=["$window",function(d){function c(a){a instanceof Error&&(a.stack?a=a.message&&-1===a.stack.indexOf(a.message)?"Error: "+a.message+"\n"+a.stack:a.stack:a.sourceURL&& + (a=a.message+"\n"+a.sourceURL+":"+a.line));return a}function e(a){var b=d.console||{},e=b[a]||b.log||x;a=!1;try{a=!!e.apply}catch(k){}return a?function(){var a=[];n(arguments,function(b){a.push(c(b))});return e.apply(b,a)}:function(a,b){e(a,null==b?"":b)}}return{log:e("log"),info:e("info"),warn:e("warn"),error:e("error"),debug:function(){var c=e("debug");return function(){a&&c.apply(b,arguments)}}()}}]}function Va(a,b){if("__defineGetter__"===a||"__defineSetter__"===a||"__lookupGetter__"===a||"__lookupSetter__"=== + a||"__proto__"===a)throw ba("isecfld",b);return a}function jd(a,b){a+="";if(!E(a))throw ba("iseccst",b);return a}function xa(a,b){if(a){if(a.constructor===a)throw ba("isecfn",b);if(a.window===a)throw ba("isecwindow",b);if(a.children&&(a.nodeName||a.prop&&a.attr&&a.find))throw ba("isecdom",b);if(a===Object)throw ba("isecobj",b);}return a}function kd(a,b){if(a){if(a.constructor===a)throw ba("isecfn",b);if(a===Wf||a===Xf||a===Yf)throw ba("isecff",b);}}function ld(a,b){if(a&&(a===(0).constructor||a=== + (!1).constructor||a==="".constructor||a==={}.constructor||a===[].constructor||a===Function.constructor))throw ba("isecaf",b);}function Zf(a,b){return"undefined"!==typeof a?a:b}function md(a,b){return"undefined"===typeof a?b:"undefined"===typeof b?a:a+b}function W(a,b){var d,c;switch(a.type){case s.Program:d=!0;n(a.body,function(a){W(a.expression,b);d=d&&a.expression.constant});a.constant=d;break;case s.Literal:a.constant=!0;a.toWatch=[];break;case s.UnaryExpression:W(a.argument,b);a.constant=a.argument.constant; + a.toWatch=a.argument.toWatch;break;case s.BinaryExpression:W(a.left,b);W(a.right,b);a.constant=a.left.constant&&a.right.constant;a.toWatch=a.left.toWatch.concat(a.right.toWatch);break;case s.LogicalExpression:W(a.left,b);W(a.right,b);a.constant=a.left.constant&&a.right.constant;a.toWatch=a.constant?[]:[a];break;case s.ConditionalExpression:W(a.test,b);W(a.alternate,b);W(a.consequent,b);a.constant=a.test.constant&&a.alternate.constant&&a.consequent.constant;a.toWatch=a.constant?[]:[a];break;case s.Identifier:a.constant= + !1;a.toWatch=[a];break;case s.MemberExpression:W(a.object,b);a.computed&&W(a.property,b);a.constant=a.object.constant&&(!a.computed||a.property.constant);a.toWatch=[a];break;case s.CallExpression:d=a.filter?!b(a.callee.name).$stateful:!1;c=[];n(a.arguments,function(a){W(a,b);d=d&&a.constant;a.constant||c.push.apply(c,a.toWatch)});a.constant=d;a.toWatch=a.filter&&!b(a.callee.name).$stateful?c:[a];break;case s.AssignmentExpression:W(a.left,b);W(a.right,b);a.constant=a.left.constant&&a.right.constant; + a.toWatch=[a];break;case s.ArrayExpression:d=!0;c=[];n(a.elements,function(a){W(a,b);d=d&&a.constant;a.constant||c.push.apply(c,a.toWatch)});a.constant=d;a.toWatch=c;break;case s.ObjectExpression:d=!0;c=[];n(a.properties,function(a){W(a.value,b);d=d&&a.value.constant;a.value.constant||c.push.apply(c,a.value.toWatch)});a.constant=d;a.toWatch=c;break;case s.ThisExpression:a.constant=!1,a.toWatch=[]}}function nd(a){if(1==a.length){a=a[0].expression;var b=a.toWatch;return 1!==b.length?b:b[0]!==a?b:u}} + function od(a){return a.type===s.Identifier||a.type===s.MemberExpression}function pd(a){if(1===a.body.length&&od(a.body[0].expression))return{type:s.AssignmentExpression,left:a.body[0].expression,right:{type:s.NGValueParameter},operator:"="}}function qd(a){return 0===a.body.length||1===a.body.length&&(a.body[0].expression.type===s.Literal||a.body[0].expression.type===s.ArrayExpression||a.body[0].expression.type===s.ObjectExpression)}function rd(a,b){this.astBuilder=a;this.$filter=b}function sd(a, + b){this.astBuilder=a;this.$filter=b}function Fb(a){return"constructor"==a}function ec(a){return z(a.valueOf)?a.valueOf():$f.call(a)}function kf(){var a=$(),b=$();this.$get=["$filter",function(d){function c(a,b){return null==a||null==b?a===b:"object"===typeof a&&(a=ec(a),"object"===typeof a)?!1:a===b||a!==a&&b!==b}function e(a,b,d,e,f){var g=e.inputs,h;if(1===g.length){var k=c,g=g[0];return a.$watch(function(a){var b=g(a);c(b,k)||(h=e(a,u,u,[b]),k=b&&ec(b));return h},b,d,f)}for(var l=[],m=[],r=0,n= + g.length;r=this.promise.$$state.status&&d&&d.length&&a(function(){for(var a,e,f=0,g=d.length;fa)for(b in l++,f)qa.call(e,b)||(n--,delete f[b])}else f!==e&&(f=e,l++);return l}}c.$stateful=!0;var d=this,e,f,g,k=1n&&(v=4-n,q[v]||(q[v]=[]),q[v].push({msg:z(a.exp)?"fn: "+(a.exp.name||a.exp.toString()):a.exp,newVal:f,oldVal:h}));else if(a===c){r=!1;break a}}catch(y){g(y)}if(!(l=A.$$watchersCount&&A.$$childHead||A!==this&&A.$$nextSibling))for(;A!==this&&!(l=A.$$nextSibling);)A=A.$parent}while(A=l);if((r||u.length)&&!n--)throw w.$$phase=null,d("infdig", + b,q);}while(r||u.length);for(w.$$phase=null;L.length;)try{L.shift()()}catch(x){g(x)}},$destroy:function(){if(!this.$$destroyed){var a=this.$parent;this.$broadcast("$destroy");this.$$destroyed=!0;this===w&&k.$$applicationDestroyed();A(this,-this.$$watchersCount);for(var b in this.$$listenerCount)v(this,this.$$listenerCount[b],b);a&&a.$$childHead==this&&(a.$$childHead=this.$$nextSibling);a&&a.$$childTail==this&&(a.$$childTail=this.$$prevSibling);this.$$prevSibling&&(this.$$prevSibling.$$nextSibling= + this.$$nextSibling);this.$$nextSibling&&(this.$$nextSibling.$$prevSibling=this.$$prevSibling);this.$destroy=this.$digest=this.$apply=this.$evalAsync=this.$applyAsync=x;this.$on=this.$watch=this.$watchGroup=function(){return x};this.$$listeners={};this.$$nextSibling=null;m(this)}},$eval:function(a,b){return h(a)(this,b)},$evalAsync:function(a,b){w.$$phase||u.length||k.defer(function(){u.length&&w.$digest()});u.push({scope:this,expression:a,locals:b})},$$postDigest:function(a){L.push(a)},$apply:function(a){try{t("$apply"); + try{return this.$eval(a)}finally{w.$$phase=null}}catch(b){g(b)}finally{try{w.$digest()}catch(c){throw g(c),c;}}},$applyAsync:function(a){function b(){c.$eval(a)}var c=this;a&&aa.push(b);C()},$on:function(a,b){var c=this.$$listeners[a];c||(this.$$listeners[a]=c=[]);c.push(b);var d=this;do d.$$listenerCount[a]||(d.$$listenerCount[a]=0),d.$$listenerCount[a]++;while(d=d.$parent);var e=this;return function(){var d=c.indexOf(b);-1!==d&&(c[d]=null,v(e,1,a))}},$emit:function(a,b){var c=[],d,e=this,f=!1,h= + {name:a,targetScope:e,stopPropagation:function(){f=!0},preventDefault:function(){h.defaultPrevented=!0},defaultPrevented:!1},k=cb([h],arguments,1),l,m;do{d=e.$$listeners[a]||c;h.currentScope=e;l=0;for(m=d.length;lHa)throw ya("iequirks");var c=ia(la);c.isEnabled=function(){return a};c.trustAs=d.trustAs;c.getTrusted=d.getTrusted;c.valueOf=d.valueOf;a||(c.trustAs=c.getTrusted=function(a,b){return b},c.valueOf=Ya);c.parseAs=function(a,d){var e=b(d);return e.literal&&e.constant?e:b(d,function(b){return c.getTrusted(a,b)})};var e=c.parseAs,f=c.getTrusted,g=c.trustAs;n(la,function(a, + b){var d=F(b);c[fb("parse_as_"+d)]=function(b){return e(a,b)};c[fb("get_trusted_"+d)]=function(b){return f(a,b)};c[fb("trust_as_"+d)]=function(b){return g(a,b)}});return c}]}function qf(){this.$get=["$window","$document",function(a,b){var d={},c=ea((/android (\d+)/.exec(F((a.navigator||{}).userAgent))||[])[1]),e=/Boxee/i.test((a.navigator||{}).userAgent),f=b[0]||{},g,h=/^(Moz|webkit|ms)(?=[A-Z])/,k=f.body&&f.body.style,l=!1,m=!1;if(k){for(var r in k)if(l=h.exec(r)){g=l[0];g=g.substr(0,1).toUpperCase()+ + g.substr(1);break}g||(g="WebkitOpacity"in k&&"webkit");l=!!("transition"in k||g+"Transition"in k);m=!!("animation"in k||g+"Animation"in k);!c||l&&m||(l=E(k.webkitTransition),m=E(k.webkitAnimation))}return{history:!(!a.history||!a.history.pushState||4>c||e),hasEvent:function(a){if("input"===a&&11>=Ha)return!1;if(q(d[a])){var b=f.createElement("div");d[a]="on"+a in b}return d[a]},csp:Ba(),vendorPrefix:g,transitions:l,animations:m,android:c}}]}function sf(){this.$get=["$templateCache","$http","$q","$sce", + function(a,b,d,c){function e(f,g){e.totalPendingRequests++;E(f)&&a.get(f)||(f=c.getTrustedResourceUrl(f));var h=b.defaults&&b.defaults.transformResponse;I(h)?h=h.filter(function(a){return a!==$b}):h===$b&&(h=null);return b.get(f,{cache:a,transformResponse:h})["finally"](function(){e.totalPendingRequests--}).then(function(b){a.put(f,b.data);return b.data},function(a){if(!g)throw ha("tpload",f,a.status,a.statusText);return d.reject(a)})}e.totalPendingRequests=0;return e}]}function tf(){this.$get=["$rootScope", + "$browser","$location",function(a,b,d){return{findBindings:function(a,b,d){a=a.getElementsByClassName("ng-binding");var g=[];n(a,function(a){var c=fa.element(a).data("$binding");c&&n(c,function(c){d?(new RegExp("(^|\\s)"+ud(b)+"(\\s|\\||$)")).test(c)&&g.push(a):-1!=c.indexOf(b)&&g.push(a)})});return g},findModels:function(a,b,d){for(var g=["ng-","data-ng-","ng\\:"],h=0;ha;a=Math.abs(a);var g=Infinity===a;if(!g&&!isFinite(a))return"";var h=a+"",k="",l=!1,m=[];g&&(k="\u221e");if(!g&&-1!==h.indexOf("e")){var r=h.match(/([\d\.]+)e(-?)(\d+)/);r&&"-"==r[2]&&r[3]>e+1?a=0:(k=h,l=!0)}if(g||l)0a&&(k=a.toFixed(e),a=parseFloat(k),k=k.replace(ic,c));else{g=(h.split(ic)[1]||"").length; + q(e)&&(e=Math.min(Math.max(b.minFrac,g),b.maxFrac));a=+(Math.round(+(a.toString()+"e"+e)).toString()+"e"+-e);var g=(""+a).split(ic),h=g[0],g=g[1]||"",r=0,t=b.lgSize,n=b.gSize;if(h.length>=t+n)for(r=h.length-t,l=0;la&&(c="-",a=-a);for(a=""+a;a.length-d)e+=d;0===e&&-12==d&&(e=12);return Gb(e,b,c)}}function Hb(a,b){return function(d,c){var e=d["get"+a](),f=sb(b?"SHORT"+a:a);return c[f][e]}}function Dd(a){var b=(new Date(a,0,1)).getDay();return new Date(a,0,(4>=b?5:12)-b)}function Ed(a){return function(b){var d=Dd(b.getFullYear());b=+new Date(b.getFullYear(),b.getMonth(),b.getDate()+(4-b.getDay()))- + +d;b=1+Math.round(b/6048E5);return Gb(b,a)}}function jc(a,b){return 0>=a.getFullYear()?b.ERAS[0]:b.ERAS[1]}function zd(a){function b(a){var b;if(b=a.match(d)){a=new Date(0);var f=0,g=0,h=b[8]?a.setUTCFullYear:a.setFullYear,k=b[8]?a.setUTCHours:a.setHours;b[9]&&(f=ea(b[9]+b[10]),g=ea(b[9]+b[11]));h.call(a,ea(b[1]),ea(b[2])-1,ea(b[3]));f=ea(b[4]||0)-f;g=ea(b[5]||0)-g;h=ea(b[6]||0);b=Math.round(1E3*parseFloat("0."+(b[7]||0)));k.call(a,f,g,h,b)}return a}var d=/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; + return function(c,d,f){var g="",h=[],k,l;d=d||"mediumDate";d=a.DATETIME_FORMATS[d]||d;E(c)&&(c=hg.test(c)?ea(c):b(c));Q(c)&&(c=new Date(c));if(!da(c)||!isFinite(c.getTime()))return c;for(;d;)(l=ig.exec(d))?(h=cb(h,l,1),d=h.pop()):(h.push(d),d=null);var m=c.getTimezoneOffset();f&&(m=vc(f,c.getTimezoneOffset()),c=Pb(c,f,!0));n(h,function(b){k=jg[b];g+=k?k(c,a.DATETIME_FORMATS,m):b.replace(/(^'|'$)/g,"").replace(/''/g,"'")});return g}}function cg(){return function(a,b){q(b)&&(b=2);return db(a,b)}}function dg(){return function(a, + b,d){b=Infinity===Math.abs(Number(b))?Number(b):ea(b);if(isNaN(b))return a;Q(a)&&(a=a.toString());if(!I(a)&&!E(a))return a;d=!d||isNaN(d)?0:ea(d);d=0>d?Math.max(0,a.length+d):d;return 0<=b?a.slice(d,d+b):0===d?a.slice(b,a.length):a.slice(Math.max(0,d+b),d)}}function Bd(a){function b(b,d){d=d?-1:1;return b.map(function(b){var c=1,h=Ya;if(z(b))h=b;else if(E(b)){if("+"==b.charAt(0)||"-"==b.charAt(0))c="-"==b.charAt(0)?-1:1,b=b.substring(1);if(""!==b&&(h=a(b),h.constant))var k=h(),h=function(a){return a[k]}}return{get:h, + descending:c*d}})}function d(a){switch(typeof a){case "number":case "boolean":case "string":return!0;default:return!1}}return function(a,e,f){if(!za(a))return a;I(e)||(e=[e]);0===e.length&&(e=["+"]);var g=b(e,f);g.push({get:function(){return{}},descending:f?-1:1});a=Array.prototype.map.call(a,function(a,b){return{value:a,predicateValues:g.map(function(c){var e=c.get(a);c=typeof e;if(null===e)c="string",e="null";else if("string"===c)e=e.toLowerCase();else if("object"===c)a:{if("function"===typeof e.valueOf&& + (e=e.valueOf(),d(e)))break a;if(qc(e)&&(e=e.toString(),d(e)))break a;e=b}return{value:e,type:c}})}});a.sort(function(a,b){for(var c=0,d=0,e=g.length;db||37<=b&&40>=b||m(a,this,this.value)});if(e.hasEvent("paste"))b.on("paste cut", + m)}b.on("change",k);c.$render=function(){var a=c.$isEmpty(c.$viewValue)?"":c.$viewValue;b.val()!==a&&b.val(a)}}function Kb(a,b){return function(d,c){var e,f;if(da(d))return d;if(E(d)){'"'==d.charAt(0)&&'"'==d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));if(kg.test(d))return new Date(d);a.lastIndex=0;if(e=a.exec(d))return e.shift(),f=c?{yyyy:c.getFullYear(),MM:c.getMonth()+1,dd:c.getDate(),HH:c.getHours(),mm:c.getMinutes(),ss:c.getSeconds(),sss:c.getMilliseconds()/1E3}:{yyyy:1970,MM:1,dd:1,HH:0, + mm:0,ss:0,sss:0},n(e,function(a,c){c=s};g.$observe("min",function(a){s=n(a);h.$validate()})}if(y(g.max)||g.ngMax){var p;h.$validators.max=function(a){return!r(a)||q(p)||d(a)<=p};g.$observe("max",function(a){p=n(a);h.$validate()})}}}function Hd(a,b,d,c){(c.$$hasNativeValidators=H(b[0].validity))&&c.$parsers.push(function(a){var c=b.prop("validity")||{}; + return c.badInput&&!c.typeMismatch?u:a})}function Id(a,b,d,c,e){if(y(c)){a=a(c);if(!a.constant)throw lb("constexpr",d,c);return a(b)}return e}function lc(a,b){a="ngClass"+a;return["$animate",function(d){function c(a,b){var c=[],d=0;a:for(;d(?:<\/\1>|)$/,Tb=/<|&#?\w+;/, + Cf=/<([\w:-]+)/,Df=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,ka={option:[1,'"],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ka.optgroup=ka.option;ka.tbody=ka.tfoot=ka.colgroup=ka.caption=ka.thead;ka.th=ka.td;var Kf=Node.prototype.contains||function(a){return!!(this.compareDocumentPosition(a)& + 16)},Pa=N.prototype={ready:function(a){function b(){d||(d=!0,a())}var d=!1;"complete"===X.readyState?setTimeout(b):(this.on("DOMContentLoaded",b),N(S).on("load",b))},toString:function(){var a=[];n(this,function(b){a.push(""+b)});return"["+a.join(", ")+"]"},eq:function(a){return 0<=a?B(this[a]):B(this[this.length+a])},length:0,push:mg,sort:[].sort,splice:[].splice},Cb={};n("multiple selected checked disabled readOnly required open".split(" "),function(a){Cb[F(a)]=a});var Rc={};n("input select option textarea button form details".split(" "), + function(a){Rc[a]=!0});var Zc={ngMinlength:"minlength",ngMaxlength:"maxlength",ngMin:"min",ngMax:"max",ngPattern:"pattern"};n({data:Wb,removeData:vb,hasData:function(a){for(var b in gb[a.ng339])return!0;return!1}},function(a,b){N[b]=a});n({data:Wb,inheritedData:Bb,scope:function(a){return B.data(a,"$scope")||Bb(a.parentNode||a,["$isolateScope","$scope"])},isolateScope:function(a){return B.data(a,"$isolateScope")||B.data(a,"$isolateScopeNoTemplate")},controller:Oc,injector:function(a){return Bb(a, + "$injector")},removeAttr:function(a,b){a.removeAttribute(b)},hasClass:yb,css:function(a,b,d){b=fb(b);if(y(d))a.style[b]=d;else return a.style[b]},attr:function(a,b,d){var c=a.nodeType;if(c!==Na&&2!==c&&8!==c)if(c=F(b),Cb[c])if(y(d))d?(a[b]=!0,a.setAttribute(b,c)):(a[b]=!1,a.removeAttribute(c));else return a[b]||(a.attributes.getNamedItem(b)||x).specified?c:u;else if(y(d))a.setAttribute(b,d);else if(a.getAttribute)return a=a.getAttribute(b,2),null===a?u:a},prop:function(a,b,d){if(y(d))a[b]=d;else return a[b]}, + text:function(){function a(a,d){if(q(d)){var c=a.nodeType;return 1===c||c===Na?a.textContent:""}a.textContent=d}a.$dv="";return a}(),val:function(a,b){if(q(b)){if(a.multiple&&"select"===ta(a)){var d=[];n(a.options,function(a){a.selected&&d.push(a.value||a.text)});return 0===d.length?null:d}return a.value}a.value=b},html:function(a,b){if(q(b))return a.innerHTML;ub(a,!0);a.innerHTML=b},empty:Pc},function(a,b){N.prototype[b]=function(b,c){var e,f,g=this.length;if(a!==Pc&&q(2==a.length&&a!==yb&&a!==Oc? + b:c)){if(H(b)){for(e=0;e <= >= && || ! = |".split(" "),function(a){Lb[a]=!0});var sg={n:"\n",f:"\f",r:"\r", + t:"\t",v:"\v","'":"'",'"':'"'},fc=function(a){this.options=a};fc.prototype={constructor:fc,lex:function(a){this.text=a;this.index=0;for(this.tokens=[];this.index=a&&"string"===typeof a},isWhitespace:function(a){return" "===a||"\r"===a|| + "\t"===a||"\n"===a||"\v"===a||"\u00a0"===a},isIdent:function(a){return"a"<=a&&"z">=a||"A"<=a&&"Z">=a||"_"===a||"$"===a},isExpOperator:function(a){return"-"===a||"+"===a||this.isNumber(a)},throwError:function(a,b,d){d=d||this.index;b=y(b)?"s "+b+"-"+this.index+" ["+this.text.substring(b,d)+"]":" "+d;throw ba("lexerr",a,b,this.text);},readNumber:function(){for(var a="",b=this.index;this.index","<=",">=");)a={type:s.BinaryExpression,operator:b.text,left:a,right:this.additive()};return a},additive:function(){for(var a=this.multiplicative(),b;b=this.expect("+","-");)a={type:s.BinaryExpression,operator:b.text,left:a,right:this.multiplicative()};return a},multiplicative:function(){for(var a=this.unary(),b;b=this.expect("*","/","%");)a={type:s.BinaryExpression,operator:b.text, + left:a,right:this.unary()};return a},unary:function(){var a;return(a=this.expect("+","-","!"))?{type:s.UnaryExpression,operator:a.text,prefix:!0,argument:this.unary()}:this.primary()},primary:function(){var a;this.expect("(")?(a=this.filterChain(),this.consume(")")):this.expect("[")?a=this.arrayDeclaration():this.expect("{")?a=this.object():this.constants.hasOwnProperty(this.peek().text)?a=bb(this.constants[this.consume().text]):this.peek().identifier?a=this.identifier():this.peek().constant?a=this.constant(): + this.throwError("not a primary expression",this.peek());for(var b;b=this.expect("(","[",".");)"("===b.text?(a={type:s.CallExpression,callee:a,arguments:this.parseArguments()},this.consume(")")):"["===b.text?(a={type:s.MemberExpression,object:a,property:this.expression(),computed:!0},this.consume("]")):"."===b.text?a={type:s.MemberExpression,object:a,property:this.identifier(),computed:!1}:this.throwError("IMPOSSIBLE");return a},filter:function(a){a=[a];for(var b={type:s.CallExpression,callee:this.identifier(), + arguments:a,filter:!0};this.expect(":");)a.push(this.expression());return b},parseArguments:function(){var a=[];if(")"!==this.peekToken().text){do a.push(this.expression());while(this.expect(","))}return a},identifier:function(){var a=this.consume();a.identifier||this.throwError("is not a valid identifier",a);return{type:s.Identifier,name:a.text}},constant:function(){return{type:s.Literal,value:this.consume().value}},arrayDeclaration:function(){var a=[];if("]"!==this.peekToken().text){do{if(this.peek("]"))break; + a.push(this.expression())}while(this.expect(","))}this.consume("]");return{type:s.ArrayExpression,elements:a}},object:function(){var a=[],b;if("}"!==this.peekToken().text){do{if(this.peek("}"))break;b={type:s.Property,kind:"init"};this.peek().constant?b.key=this.constant():this.peek().identifier?b.key=this.identifier():this.throwError("invalid key",this.peek());this.consume(":");b.value=this.expression();a.push(b)}while(this.expect(","))}this.consume("}");return{type:s.ObjectExpression,properties:a}}, + throwError:function(a,b){throw ba("syntax",b.text,a,b.index+1,this.text,this.text.substring(b.index));},consume:function(a){if(0===this.tokens.length)throw ba("ueoe",this.text);var b=this.expect(a);b||this.throwError("is unexpected, expecting ["+a+"]",this.peek());return b},peekToken:function(){if(0===this.tokens.length)throw ba("ueoe",this.text);return this.tokens[0]},peek:function(a,b,d,c){return this.peekAhead(0,a,b,d,c)},peekAhead:function(a,b,d,c,e){if(this.tokens.length>a){a=this.tokens[a]; + var f=a.text;if(f===b||f===d||f===c||f===e||!(b||d||c||e))return a}return!1},expect:function(a,b,d,c){return(a=this.peek(a,b,d,c))?(this.tokens.shift(),a):!1},constants:{"true":{type:s.Literal,value:!0},"false":{type:s.Literal,value:!1},"null":{type:s.Literal,value:null},undefined:{type:s.Literal,value:u},"this":{type:s.ThisExpression}}};rd.prototype={compile:function(a,b){var d=this,c=this.astBuilder.ast(a);this.state={nextId:0,filters:{},expensiveChecks:b,fn:{vars:[],body:[],own:{}},assign:{vars:[], + body:[],own:{}},inputs:[]};W(c,d.$filter);var e="",f;this.stage="assign";if(f=pd(c))this.state.computing="assign",e=this.nextId(),this.recurse(f,e),this.return_(e),e="fn.assign="+this.generateFunction("assign","s,v,l");f=nd(c.body);d.stage="inputs";n(f,function(a,b){var c="fn"+b;d.state[c]={vars:[],body:[],own:{}};d.state.computing=c;var e=d.nextId();d.recurse(a,e);d.return_(e);d.state.inputs.push(c);a.watchId=b});this.state.computing="fn";this.stage="main";this.recurse(c);e='"'+this.USE+" "+this.STRICT+ + '";\n'+this.filterPrefix()+"var fn="+this.generateFunction("fn","s,l,a,i")+e+this.watchFns()+"return fn;";e=(new Function("$filter","ensureSafeMemberName","ensureSafeObject","ensureSafeFunction","getStringValue","ensureSafeAssignContext","ifDefined","plus","text",e))(this.$filter,Va,xa,kd,jd,ld,Zf,md,a);this.state=this.stage=u;e.literal=qd(c);e.constant=c.constant;return e},USE:"use",STRICT:"strict",watchFns:function(){var a=[],b=this.state.inputs,d=this;n(b,function(b){a.push("var "+b+"="+d.generateFunction(b, + "s"))});b.length&&a.push("fn.inputs=["+b.join(",")+"];");return a.join("")},generateFunction:function(a,b){return"function("+b+"){"+this.varsPrefix(a)+this.body(a)+"};"},filterPrefix:function(){var a=[],b=this;n(this.state.filters,function(d,c){a.push(d+"=$filter("+b.escape(c)+")")});return a.length?"var "+a.join(",")+";":""},varsPrefix:function(a){return this.state[a].vars.length?"var "+this.state[a].vars.join(",")+";":""},body:function(a){return this.state[a].body.join("")},recurse:function(a,b, + d,c,e,f){var g,h,k=this,l,m;c=c||x;if(!f&&y(a.watchId))b=b||this.nextId(),this.if_("i",this.lazyAssign(b,this.computedMember("i",a.watchId)),this.lazyRecurse(a,b,d,c,e,!0));else switch(a.type){case s.Program:n(a.body,function(b,c){k.recurse(b.expression,u,u,function(a){h=a});c!==a.body.length-1?k.current().body.push(h,";"):k.return_(h)});break;case s.Literal:m=this.escape(a.value);this.assign(b,m);c(m);break;case s.UnaryExpression:this.recurse(a.argument,u,u,function(a){h=a});m=a.operator+"("+this.ifDefined(h, + 0)+")";this.assign(b,m);c(m);break;case s.BinaryExpression:this.recurse(a.left,u,u,function(a){g=a});this.recurse(a.right,u,u,function(a){h=a});m="+"===a.operator?this.plus(g,h):"-"===a.operator?this.ifDefined(g,0)+a.operator+this.ifDefined(h,0):"("+g+")"+a.operator+"("+h+")";this.assign(b,m);c(m);break;case s.LogicalExpression:b=b||this.nextId();k.recurse(a.left,b);k.if_("&&"===a.operator?b:k.not(b),k.lazyRecurse(a.right,b));c(b);break;case s.ConditionalExpression:b=b||this.nextId();k.recurse(a.test, + b);k.if_(b,k.lazyRecurse(a.alternate,b),k.lazyRecurse(a.consequent,b));c(b);break;case s.Identifier:b=b||this.nextId();d&&(d.context="inputs"===k.stage?"s":this.assign(this.nextId(),this.getHasOwnProperty("l",a.name)+"?l:s"),d.computed=!1,d.name=a.name);Va(a.name);k.if_("inputs"===k.stage||k.not(k.getHasOwnProperty("l",a.name)),function(){k.if_("inputs"===k.stage||"s",function(){e&&1!==e&&k.if_(k.not(k.nonComputedMember("s",a.name)),k.lazyAssign(k.nonComputedMember("s",a.name),"{}"));k.assign(b,k.nonComputedMember("s", + a.name))})},b&&k.lazyAssign(b,k.nonComputedMember("l",a.name)));(k.state.expensiveChecks||Fb(a.name))&&k.addEnsureSafeObject(b);c(b);break;case s.MemberExpression:g=d&&(d.context=this.nextId())||this.nextId();b=b||this.nextId();k.recurse(a.object,g,u,function(){k.if_(k.notNull(g),function(){if(a.computed)h=k.nextId(),k.recurse(a.property,h),k.getStringValue(h),k.addEnsureSafeMemberName(h),e&&1!==e&&k.if_(k.not(k.computedMember(g,h)),k.lazyAssign(k.computedMember(g,h),"{}")),m=k.ensureSafeObject(k.computedMember(g, + h)),k.assign(b,m),d&&(d.computed=!0,d.name=h);else{Va(a.property.name);e&&1!==e&&k.if_(k.not(k.nonComputedMember(g,a.property.name)),k.lazyAssign(k.nonComputedMember(g,a.property.name),"{}"));m=k.nonComputedMember(g,a.property.name);if(k.state.expensiveChecks||Fb(a.property.name))m=k.ensureSafeObject(m);k.assign(b,m);d&&(d.computed=!1,d.name=a.property.name)}},function(){k.assign(b,"undefined")});c(b)},!!e);break;case s.CallExpression:b=b||this.nextId();a.filter?(h=k.filter(a.callee.name),l=[],n(a.arguments, + function(a){var b=k.nextId();k.recurse(a,b);l.push(b)}),m=h+"("+l.join(",")+")",k.assign(b,m),c(b)):(h=k.nextId(),g={},l=[],k.recurse(a.callee,h,g,function(){k.if_(k.notNull(h),function(){k.addEnsureSafeFunction(h);n(a.arguments,function(a){k.recurse(a,k.nextId(),u,function(a){l.push(k.ensureSafeObject(a))})});g.name?(k.state.expensiveChecks||k.addEnsureSafeObject(g.context),m=k.member(g.context,g.name,g.computed)+"("+l.join(",")+")"):m=h+"("+l.join(",")+")";m=k.ensureSafeObject(m);k.assign(b,m)}, + function(){k.assign(b,"undefined")});c(b)}));break;case s.AssignmentExpression:h=this.nextId();g={};if(!od(a.left))throw ba("lval");this.recurse(a.left,u,g,function(){k.if_(k.notNull(g.context),function(){k.recurse(a.right,h);k.addEnsureSafeObject(k.member(g.context,g.name,g.computed));k.addEnsureSafeAssignContext(g.context);m=k.member(g.context,g.name,g.computed)+a.operator+h;k.assign(b,m);c(b||m)})},1);break;case s.ArrayExpression:l=[];n(a.elements,function(a){k.recurse(a,k.nextId(),u,function(a){l.push(a)})}); + m="["+l.join(",")+"]";this.assign(b,m);c(m);break;case s.ObjectExpression:l=[];n(a.properties,function(a){k.recurse(a.value,k.nextId(),u,function(b){l.push(k.escape(a.key.type===s.Identifier?a.key.name:""+a.key.value)+":"+b)})});m="{"+l.join(",")+"}";this.assign(b,m);c(m);break;case s.ThisExpression:this.assign(b,"s");c("s");break;case s.NGValueParameter:this.assign(b,"v"),c("v")}},getHasOwnProperty:function(a,b){var d=a+"."+b,c=this.current().own;c.hasOwnProperty(d)||(c[d]=this.nextId(!1,a+"&&("+ + this.escape(b)+" in "+a+")"));return c[d]},assign:function(a,b){if(a)return this.current().body.push(a,"=",b,";"),a},filter:function(a){this.state.filters.hasOwnProperty(a)||(this.state.filters[a]=this.nextId(!0));return this.state.filters[a]},ifDefined:function(a,b){return"ifDefined("+a+","+this.escape(b)+")"},plus:function(a,b){return"plus("+a+","+b+")"},return_:function(a){this.current().body.push("return ",a,";")},if_:function(a,b,d){if(!0===a)b();else{var c=this.current().body;c.push("if(",a, + "){");b();c.push("}");d&&(c.push("else{"),d(),c.push("}"))}},not:function(a){return"!("+a+")"},notNull:function(a){return a+"!=null"},nonComputedMember:function(a,b){return a+"."+b},computedMember:function(a,b){return a+"["+b+"]"},member:function(a,b,d){return d?this.computedMember(a,b):this.nonComputedMember(a,b)},addEnsureSafeObject:function(a){this.current().body.push(this.ensureSafeObject(a),";")},addEnsureSafeMemberName:function(a){this.current().body.push(this.ensureSafeMemberName(a),";")}, + addEnsureSafeFunction:function(a){this.current().body.push(this.ensureSafeFunction(a),";")},addEnsureSafeAssignContext:function(a){this.current().body.push(this.ensureSafeAssignContext(a),";")},ensureSafeObject:function(a){return"ensureSafeObject("+a+",text)"},ensureSafeMemberName:function(a){return"ensureSafeMemberName("+a+",text)"},ensureSafeFunction:function(a){return"ensureSafeFunction("+a+",text)"},getStringValue:function(a){this.assign(a,"getStringValue("+a+",text)")},ensureSafeAssignContext:function(a){return"ensureSafeAssignContext("+ + a+",text)"},lazyRecurse:function(a,b,d,c,e,f){var g=this;return function(){g.recurse(a,b,d,c,e,f)}},lazyAssign:function(a,b){var d=this;return function(){d.assign(a,b)}},stringEscapeRegex:/[^ a-zA-Z0-9]/g,stringEscapeFn:function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)},escape:function(a){if(E(a))return"'"+a.replace(this.stringEscapeRegex,this.stringEscapeFn)+"'";if(Q(a))return a.toString();if(!0===a)return"true";if(!1===a)return"false";if(null===a)return"null";if("undefined"=== + typeof a)return"undefined";throw ba("esc");},nextId:function(a,b){var d="v"+this.state.nextId++;a||this.current().vars.push(d+(b?"="+b:""));return d},current:function(){return this.state[this.state.computing]}};sd.prototype={compile:function(a,b){var d=this,c=this.astBuilder.ast(a);this.expression=a;this.expensiveChecks=b;W(c,d.$filter);var e,f;if(e=pd(c))f=this.recurse(e);e=nd(c.body);var g;e&&(g=[],n(e,function(a,b){var c=d.recurse(a);a.input=c;g.push(c);a.watchId=b}));var h=[];n(c.body,function(a){h.push(d.recurse(a.expression))}); + e=0===c.body.length?function(){}:1===c.body.length?h[0]:function(a,b){var c;n(h,function(d){c=d(a,b)});return c};f&&(e.assign=function(a,b,c){return f(a,c,b)});g&&(e.inputs=g);e.literal=qd(c);e.constant=c.constant;return e},recurse:function(a,b,d){var c,e,f=this,g;if(a.input)return this.inputs(a.input,a.watchId);switch(a.type){case s.Literal:return this.value(a.value,b);case s.UnaryExpression:return e=this.recurse(a.argument),this["unary"+a.operator](e,b);case s.BinaryExpression:return c=this.recurse(a.left), + e=this.recurse(a.right),this["binary"+a.operator](c,e,b);case s.LogicalExpression:return c=this.recurse(a.left),e=this.recurse(a.right),this["binary"+a.operator](c,e,b);case s.ConditionalExpression:return this["ternary?:"](this.recurse(a.test),this.recurse(a.alternate),this.recurse(a.consequent),b);case s.Identifier:return Va(a.name,f.expression),f.identifier(a.name,f.expensiveChecks||Fb(a.name),b,d,f.expression);case s.MemberExpression:return c=this.recurse(a.object,!1,!!d),a.computed||(Va(a.property.name, + f.expression),e=a.property.name),a.computed&&(e=this.recurse(a.property)),a.computed?this.computedMember(c,e,b,d,f.expression):this.nonComputedMember(c,e,f.expensiveChecks,b,d,f.expression);case s.CallExpression:return g=[],n(a.arguments,function(a){g.push(f.recurse(a))}),a.filter&&(e=this.$filter(a.callee.name)),a.filter||(e=this.recurse(a.callee,!0)),a.filter?function(a,c,d,f){for(var r=[],n=0;n":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)>b(c,e,f,g);return d?{value:c}:c}},"binary<=":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)<=b(c,e,f,g);return d?{value:c}:c}},"binary>=":function(a,b,d){return function(c, + e,f,g){c=a(c,e,f,g)>=b(c,e,f,g);return d?{value:c}:c}},"binary&&":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)&&b(c,e,f,g);return d?{value:c}:c}},"binary||":function(a,b,d){return function(c,e,f,g){c=a(c,e,f,g)||b(c,e,f,g);return d?{value:c}:c}},"ternary?:":function(a,b,d,c){return function(e,f,g,h){e=a(e,f,g,h)?b(e,f,g,h):d(e,f,g,h);return c?{value:e}:e}},value:function(a,b){return function(){return b?{context:u,name:u,value:a}:a}},identifier:function(a,b,d,c,e){return function(f,g,h,k){f= + g&&a in g?g:f;c&&1!==c&&f&&!f[a]&&(f[a]={});g=f?f[a]:u;b&&xa(g,e);return d?{context:f,name:a,value:g}:g}},computedMember:function(a,b,d,c,e){return function(f,g,h,k){var l=a(f,g,h,k),m,n;null!=l&&(m=b(f,g,h,k),m=jd(m),Va(m,e),c&&1!==c&&l&&!l[m]&&(l[m]={}),n=l[m],xa(n,e));return d?{context:l,name:m,value:n}:n}},nonComputedMember:function(a,b,d,c,e,f){return function(g,h,k,l){g=a(g,h,k,l);e&&1!==e&&g&&!g[b]&&(g[b]={});h=null!=g?g[b]:u;(d||Fb(b))&&xa(h,f);return c?{context:g,name:b,value:h}:h}},inputs:function(a, + b){return function(d,c,e,f){return f?f[b]:a(d,c,e)}}};var gc=function(a,b,d){this.lexer=a;this.$filter=b;this.options=d;this.ast=new s(this.lexer);this.astCompiler=d.csp?new sd(this.ast,b):new rd(this.ast,b)};gc.prototype={constructor:gc,parse:function(a){return this.astCompiler.compile(a,this.options.expensiveChecks)}};$();$();var $f=Object.prototype.valueOf,ya=G("$sce"),la={HTML:"html",CSS:"css",URL:"url",RESOURCE_URL:"resourceUrl",JS:"js"},ha=G("$compile"),Y=X.createElement("a"),wd=wa(S.location.href); + xd.$inject=["$document"];Jc.$inject=["$provide"];yd.$inject=["$locale"];Ad.$inject=["$locale"];var ic=".",jg={yyyy:ca("FullYear",4),yy:ca("FullYear",2,0,!0),y:ca("FullYear",1),MMMM:Hb("Month"),MMM:Hb("Month",!0),MM:ca("Month",2,1),M:ca("Month",1,1),dd:ca("Date",2),d:ca("Date",1),HH:ca("Hours",2),H:ca("Hours",1),hh:ca("Hours",2,-12),h:ca("Hours",1,-12),mm:ca("Minutes",2),m:ca("Minutes",1),ss:ca("Seconds",2),s:ca("Seconds",1),sss:ca("Milliseconds",3),EEEE:Hb("Day"),EEE:Hb("Day",!0),a:function(a,b){return 12> + a.getHours()?b.AMPMS[0]:b.AMPMS[1]},Z:function(a,b,d){a=-1*d;return a=(0<=a?"+":"")+(Gb(Math[0=a.getFullYear()?b.ERANAMES[0]:b.ERANAMES[1]}},ig=/((?:[^yMdHhmsaZEwG']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z|G+|w+))(.*)/,hg=/^\-?\d+$/;zd.$inject=["$locale"];var eg=na(F),fg=na(sb);Bd.$inject=["$parse"];var he=na({restrict:"E",compile:function(a,b){if(!b.href&&!b.xlinkHref)return function(a, + b){if("a"===b[0].nodeName.toLowerCase()){var e="[object SVGAnimatedString]"===sa.call(b.prop("href"))?"xlink:href":"href";b.on("click",function(a){b.attr(e)||a.preventDefault()})}}}}),tb={};n(Cb,function(a,b){function d(a,d,e){a.$watch(e[c],function(a){e.$set(b,!!a)})}if("multiple"!=a){var c=va("ng-"+b),e=d;"checked"===a&&(e=function(a,b,e){e.ngModel!==e[c]&&d(a,b,e)});tb[c]=function(){return{restrict:"A",priority:100,link:e}}}});n(Zc,function(a,b){tb[b]=function(){return{priority:100,link:function(a, + c,e){if("ngPattern"===b&&"/"==e.ngPattern.charAt(0)&&(c=e.ngPattern.match(lg))){e.$set("ngPattern",new RegExp(c[1],c[2]));return}a.$watch(e[b],function(a){e.$set(b,a)})}}}});n(["src","srcset","href"],function(a){var b=va("ng-"+a);tb[b]=function(){return{priority:99,link:function(d,c,e){var f=a,g=a;"href"===a&&"[object SVGAnimatedString]"===sa.call(c.prop("href"))&&(g="xlinkHref",e.$attr[g]="xlink:href",f=null);e.$observe(b,function(b){b?(e.$set(g,b),Ha&&f&&c.prop(f,e[g])):"href"===a&&e.$set(g,null)})}}}}); + var Ib={$addControl:x,$$renameControl:function(a,b){a.$name=b},$removeControl:x,$setValidity:x,$setDirty:x,$setPristine:x,$setSubmitted:x};Fd.$inject=["$element","$attrs","$scope","$animate","$interpolate"];var Nd=function(a){return["$timeout","$parse",function(b,d){function c(a){return""===a?d('this[""]').assign:d(a).assign||x}return{name:"form",restrict:a?"EAC":"E",require:["form","^^?form"],controller:Fd,compile:function(d,f){d.addClass(Wa).addClass(mb);var g=f.name?"name":a&&f.ngForm?"ngForm": + !1;return{pre:function(a,d,e,f){var n=f[0];if(!("action"in e)){var q=function(b){a.$apply(function(){n.$commitViewValue();n.$setSubmitted()});b.preventDefault()};d[0].addEventListener("submit",q,!1);d.on("$destroy",function(){b(function(){d[0].removeEventListener("submit",q,!1)},0,!1)})}(f[1]||n.$$parentForm).$addControl(n);var s=g?c(n.$name):x;g&&(s(a,n),e.$observe(g,function(b){n.$name!==b&&(s(a,u),n.$$parentForm.$$renameControl(n,b),s=c(n.$name),s(a,n))}));d.on("$destroy",function(){n.$$parentForm.$removeControl(n); + s(a,u);M(n,Ib)})}}}}}]},ie=Nd(),ve=Nd(!0),kg=/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/,tg=/^[A-Za-z][A-Za-z\d.+-]*:\/*(?:\w+(?::\w+)?@)?[^\s/]+(?::\d+)?(?:\/[\w#!:.?+=&%@\-/]*)?$/,ug=/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i,vg=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))([eE][+-]?\d+)?\s*$/,Od=/^(\d{4})-(\d{2})-(\d{2})$/,Pd=/^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/,mc=/^(\d{4})-W(\d\d)$/,Qd=/^(\d{4})-(\d\d)$/, + Rd=/^(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/,Sd={text:function(a,b,d,c,e,f){jb(a,b,d,c,e,f);kc(c)},date:kb("date",Od,Kb(Od,["yyyy","MM","dd"]),"yyyy-MM-dd"),"datetime-local":kb("datetimelocal",Pd,Kb(Pd,"yyyy MM dd HH mm ss sss".split(" ")),"yyyy-MM-ddTHH:mm:ss.sss"),time:kb("time",Rd,Kb(Rd,["HH","mm","ss","sss"]),"HH:mm:ss.sss"),week:kb("week",mc,function(a,b){if(da(a))return a;if(E(a)){mc.lastIndex=0;var d=mc.exec(a);if(d){var c=+d[1],e=+d[2],f=d=0,g=0,h=0,k=Dd(c),e=7*(e-1);b&&(d=b.getHours(),f= + b.getMinutes(),g=b.getSeconds(),h=b.getMilliseconds());return new Date(c,0,k.getDate()+e,d,f,g,h)}}return NaN},"yyyy-Www"),month:kb("month",Qd,Kb(Qd,["yyyy","MM"]),"yyyy-MM"),number:function(a,b,d,c,e,f){Hd(a,b,d,c);jb(a,b,d,c,e,f);c.$$parserName="number";c.$parsers.push(function(a){return c.$isEmpty(a)?null:vg.test(a)?parseFloat(a):u});c.$formatters.push(function(a){if(!c.$isEmpty(a)){if(!Q(a))throw lb("numfmt",a);a=a.toString()}return a});if(y(d.min)||d.ngMin){var g;c.$validators.min=function(a){return c.$isEmpty(a)|| + q(g)||a>=g};d.$observe("min",function(a){y(a)&&!Q(a)&&(a=parseFloat(a,10));g=Q(a)&&!isNaN(a)?a:u;c.$validate()})}if(y(d.max)||d.ngMax){var h;c.$validators.max=function(a){return c.$isEmpty(a)||q(h)||a<=h};d.$observe("max",function(a){y(a)&&!Q(a)&&(a=parseFloat(a,10));h=Q(a)&&!isNaN(a)?a:u;c.$validate()})}},url:function(a,b,d,c,e,f){jb(a,b,d,c,e,f);kc(c);c.$$parserName="url";c.$validators.url=function(a,b){var d=a||b;return c.$isEmpty(d)||tg.test(d)}},email:function(a,b,d,c,e,f){jb(a,b,d,c,e,f);kc(c); + c.$$parserName="email";c.$validators.email=function(a,b){var d=a||b;return c.$isEmpty(d)||ug.test(d)}},radio:function(a,b,d,c){q(d.name)&&b.attr("name",++nb);b.on("click",function(a){b[0].checked&&c.$setViewValue(d.value,a&&a.type)});c.$render=function(){b[0].checked=d.value==c.$viewValue};d.$observe("value",c.$render)},checkbox:function(a,b,d,c,e,f,g,h){var k=Id(h,a,"ngTrueValue",d.ngTrueValue,!0),l=Id(h,a,"ngFalseValue",d.ngFalseValue,!1);b.on("click",function(a){c.$setViewValue(b[0].checked,a&& + a.type)});c.$render=function(){b[0].checked=c.$viewValue};c.$isEmpty=function(a){return!1===a};c.$formatters.push(function(a){return ma(a,k)});c.$parsers.push(function(a){return a?k:l})},hidden:x,button:x,submit:x,reset:x,file:x},Dc=["$browser","$sniffer","$filter","$parse",function(a,b,d,c){return{restrict:"E",require:["?ngModel"],link:{pre:function(e,f,g,h){h[0]&&(Sd[F(g.type)]||Sd.text)(e,f,g,h[0],b,a,d,c)}}}}],wg=/^(true|false|\d+)$/,Ne=function(){return{restrict:"A",priority:100,compile:function(a, + b){return wg.test(b.ngValue)?function(a,b,e){e.$set("value",a.$eval(e.ngValue))}:function(a,b,e){a.$watch(e.ngValue,function(a){e.$set("value",a)})}}}},ne=["$compile",function(a){return{restrict:"AC",compile:function(b){a.$$addBindingClass(b);return function(b,c,e){a.$$addBindingInfo(c,e.ngBind);c=c[0];b.$watch(e.ngBind,function(a){c.textContent=q(a)?"":a})}}}}],pe=["$interpolate","$compile",function(a,b){return{compile:function(d){b.$$addBindingClass(d);return function(c,d,f){c=a(d.attr(f.$attr.ngBindTemplate)); + b.$$addBindingInfo(d,c.expressions);d=d[0];f.$observe("ngBindTemplate",function(a){d.textContent=q(a)?"":a})}}}}],oe=["$sce","$parse","$compile",function(a,b,d){return{restrict:"A",compile:function(c,e){var f=b(e.ngBindHtml),g=b(e.ngBindHtml,function(a){return(a||"").toString()});d.$$addBindingClass(c);return function(b,c,e){d.$$addBindingInfo(c,e.ngBindHtml);b.$watch(g,function(){c.html(a.getTrustedHtml(f(b))||"")})}}}}],Me=na({restrict:"A",require:"ngModel",link:function(a,b,d,c){c.$viewChangeListeners.push(function(){a.$eval(d.ngChange)})}}), + qe=lc("",!0),se=lc("Odd",0),re=lc("Even",1),te=La({compile:function(a,b){b.$set("ngCloak",u);a.removeClass("ng-cloak")}}),ue=[function(){return{restrict:"A",scope:!0,controller:"@",priority:500}}],Ic={},xg={blur:!0,focus:!0};n("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste".split(" "),function(a){var b=va("ng-"+a);Ic[b]=["$parse","$rootScope",function(d,c){return{restrict:"A",compile:function(e,f){var g= + d(f[b],null,!0);return function(b,d){d.on(a,function(d){var e=function(){g(b,{$event:d})};xg[a]&&c.$$phase?b.$evalAsync(e):b.$apply(e)})}}}}]});var xe=["$animate",function(a){return{multiElement:!0,transclude:"element",priority:600,terminal:!0,restrict:"A",$$tlb:!0,link:function(b,d,c,e,f){var g,h,k;b.$watch(c.ngIf,function(b){b?h||f(function(b,e){h=e;b[b.length++]=X.createComment(" end ngIf: "+c.ngIf+" ");g={clone:b};a.enter(b,d.parent(),d)}):(k&&(k.remove(),k=null),h&&(h.$destroy(),h=null),g&&(k= + rb(g.clone),a.leave(k).then(function(){k=null}),g=null))})}}}],ye=["$templateRequest","$anchorScroll","$animate",function(a,b,d){return{restrict:"ECA",priority:400,terminal:!0,transclude:"element",controller:fa.noop,compile:function(c,e){var f=e.ngInclude||e.src,g=e.onload||"",h=e.autoscroll;return function(c,e,m,n,q){var s=0,v,u,p,C=function(){u&&(u.remove(),u=null);v&&(v.$destroy(),v=null);p&&(d.leave(p).then(function(){u=null}),u=p,p=null)};c.$watch(f,function(f){var m=function(){!y(h)||h&&!c.$eval(h)|| + b()},u=++s;f?(a(f,!0).then(function(a){if(u===s){var b=c.$new();n.template=a;a=q(b,function(a){C();d.enter(a,null,e).then(m)});v=b;p=a;v.$emit("$includeContentLoaded",f);c.$eval(g)}},function(){u===s&&(C(),c.$emit("$includeContentError",f))}),c.$emit("$includeContentRequested",f)):(C(),n.template=null)})}}}}],Pe=["$compile",function(a){return{restrict:"ECA",priority:-400,require:"ngInclude",link:function(b,d,c,e){/SVG/.test(d[0].toString())?(d.empty(),a(Lc(e.template,X).childNodes)(b,function(a){d.append(a)}, + {futureParentElement:d})):(d.html(e.template),a(d.contents())(b))}}}],ze=La({priority:450,compile:function(){return{pre:function(a,b,d){a.$eval(d.ngInit)}}}}),Le=function(){return{restrict:"A",priority:100,require:"ngModel",link:function(a,b,d,c){var e=b.attr(d.$attr.ngList)||", ",f="false"!==d.ngTrim,g=f?U(e):e;c.$parsers.push(function(a){if(!q(a)){var b=[];a&&n(a.split(g),function(a){a&&b.push(f?U(a):a)});return b}});c.$formatters.push(function(a){return I(a)?a.join(e):u});c.$isEmpty=function(a){return!a|| + !a.length}}}},mb="ng-valid",Jd="ng-invalid",Wa="ng-pristine",Jb="ng-dirty",Ld="ng-pending",lb=G("ngModel"),yg=["$scope","$exceptionHandler","$attrs","$element","$parse","$animate","$timeout","$rootScope","$q","$interpolate",function(a,b,d,c,e,f,g,h,k,l){this.$modelValue=this.$viewValue=Number.NaN;this.$$rawModelValue=u;this.$validators={};this.$asyncValidators={};this.$parsers=[];this.$formatters=[];this.$viewChangeListeners=[];this.$untouched=!0;this.$touched=!1;this.$pristine=!0;this.$dirty=!1; + this.$valid=!0;this.$invalid=!1;this.$error={};this.$$success={};this.$pending=u;this.$name=l(d.name||"",!1)(a);this.$$parentForm=Ib;var m=e(d.ngModel),r=m.assign,t=m,s=r,v=null,B,p=this;this.$$setOptions=function(a){if((p.$options=a)&&a.getterSetter){var b=e(d.ngModel+"()"),f=e(d.ngModel+"($$$p)");t=function(a){var c=m(a);z(c)&&(c=b(a));return c};s=function(a,b){z(m(a))?f(a,{$$$p:p.$modelValue}):r(a,p.$modelValue)}}else if(!m.assign)throw lb("nonassign",d.ngModel,ua(c));};this.$render=x;this.$isEmpty= + function(a){return q(a)||""===a||null===a||a!==a};var C=0;Gd({ctrl:this,$element:c,set:function(a,b){a[b]=!0},unset:function(a,b){delete a[b]},$animate:f});this.$setPristine=function(){p.$dirty=!1;p.$pristine=!0;f.removeClass(c,Jb);f.addClass(c,Wa)};this.$setDirty=function(){p.$dirty=!0;p.$pristine=!1;f.removeClass(c,Wa);f.addClass(c,Jb);p.$$parentForm.$setDirty()};this.$setUntouched=function(){p.$touched=!1;p.$untouched=!0;f.setClass(c,"ng-untouched","ng-touched")};this.$setTouched=function(){p.$touched= + !0;p.$untouched=!1;f.setClass(c,"ng-touched","ng-untouched")};this.$rollbackViewValue=function(){g.cancel(v);p.$viewValue=p.$$lastCommittedViewValue;p.$render()};this.$validate=function(){if(!Q(p.$modelValue)||!isNaN(p.$modelValue)){var a=p.$$rawModelValue,b=p.$valid,c=p.$modelValue,d=p.$options&&p.$options.allowInvalid;p.$$runValidators(a,p.$$lastCommittedViewValue,function(e){d||b===e||(p.$modelValue=e?a:u,p.$modelValue!==c&&p.$$writeModelToScope())})}};this.$$runValidators=function(a,b,c){function d(){var c= + !0;n(p.$validators,function(d,e){var g=d(a,b);c=c&&g;f(e,g)});return c?!0:(n(p.$asyncValidators,function(a,b){f(b,null)}),!1)}function e(){var c=[],d=!0;n(p.$asyncValidators,function(e,g){var h=e(a,b);if(!h||!z(h.then))throw lb("$asyncValidators",h);f(g,u);c.push(h.then(function(){f(g,!0)},function(a){d=!1;f(g,!1)}))});c.length?k.all(c).then(function(){g(d)},x):g(!0)}function f(a,b){h===C&&p.$setValidity(a,b)}function g(a){h===C&&c(a)}C++;var h=C;(function(){var a=p.$$parserName||"parse";if(q(B))f(a, + null);else return B||(n(p.$validators,function(a,b){f(b,null)}),n(p.$asyncValidators,function(a,b){f(b,null)})),f(a,B),B;return!0})()?d()?e():g(!1):g(!1)};this.$commitViewValue=function(){var a=p.$viewValue;g.cancel(v);if(p.$$lastCommittedViewValue!==a||""===a&&p.$$hasNativeValidators)p.$$lastCommittedViewValue=a,p.$pristine&&this.$setDirty(),this.$$parseAndValidate()};this.$$parseAndValidate=function(){var b=p.$$lastCommittedViewValue;if(B=q(b)?u:!0)for(var c=0;ce||c.$isEmpty(b)||b.length<=e}}}}},Gc=function(){return{restrict:"A",require:"?ngModel",link:function(a,b,d,c){if(c){var e=0;d.$observe("minlength",function(a){e=ea(a)||0;c.$validate()});c.$validators.minlength=function(a,b){return c.$isEmpty(b)||b.length>=e}}}}};S.angular.bootstrap? + console.log("WARNING: Tried to load angular more than once."):(ce(),ee(fa),fa.module("ngLocale",[],["$provide",function(a){function b(a){a+="";var b=a.indexOf(".");return-1==b?0:a.length-b-1}a.value("$locale",{DATETIME_FORMATS:{AMPMS:["AM","PM"],DAY:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ERANAMES:["Before Christ","Anno Domini"],ERAS:["BC","AD"],FIRSTDAYOFWEEK:6,MONTH:"January February March April May June July August September October November December".split(" "),SHORTDAY:"Sun Mon Tue Wed Thu Fri Sat".split(" "), + SHORTMONTH:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),WEEKENDRANGE:[5,6],fullDate:"EEEE, MMMM d, y",longDate:"MMMM d, y",medium:"MMM d, y h:mm:ss a",mediumDate:"MMM d, y",mediumTime:"h:mm:ss a","short":"M/d/yy h:mm a",shortDate:"M/d/yy",shortTime:"h:mm a"},NUMBER_FORMATS:{CURRENCY_SYM:"$",DECIMAL_SEP:".",GROUP_SEP:",",PATTERNS:[{gSize:3,lgSize:3,maxFrac:3,minFrac:0,minInt:1,negPre:"-",negSuf:"",posPre:"",posSuf:""},{gSize:3,lgSize:3,maxFrac:2,minFrac:2,minInt:1,negPre:"-\u00a4", + negSuf:"",posPre:"\u00a4",posSuf:""}]},id:"en-us",pluralCat:function(a,c){var e=a|0,f=c;u===f&&(f=Math.min(b(a),3));Math.pow(10,f);return 1==e&&0==f?"one":"other"}})}]),B(X).ready(function(){Zd(X,yc)}))})(window,document);!window.angular.$$csp().noInlineStyle&&window.angular.element(document.head).prepend(''); \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/js/services/settingsService.js b/confluence-plugin/src/main/resources/configurationResources/js/services/settingsService.js new file mode 100644 index 0000000..40f0f85 --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/js/services/settingsService.js @@ -0,0 +1,3 @@ +angular.module('DoC_Config').factory('settingsService', function(){ + return {}; +}); \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/js/services/urlService.js b/confluence-plugin/src/main/resources/configurationResources/js/services/urlService.js new file mode 100644 index 0000000..aa06e87 --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/js/services/urlService.js @@ -0,0 +1,38 @@ +angular.module("DoC_Config").factory("urlService",function() { + var urlService = { + getRestUrl: function(path) { + if (!path) { + path = ""; + } + return this.getBaseUrl()+"/rest/doc/1.0/configuration"+path; + }, + getRestUrlWithParams: function() { + var params = arguments; + var paramString = "/"; + angular.forEach(params,function(param) { + paramString += urlService.encodeComponent(param)+"/"; + }); + return this.getRestUrl(paramString); + }, + getResourcesUrl: function(path) { + if (!path) { + path = ""; + } + return this.getBaseUrl()+"/download/resources/com.networkedassets.autodoc.confluence-plugin:configuration-resources/configurationResources"+path; + }, + isLocal: function() { + return AJS.params && AJS.params.baseUrl; + }, + getBaseUrl: function() { + if (this.isLocal()) { + return AJS.params.baseUrl; + } else { + return "http://atlassian-na-dev-01.networkedassets.local/confluence"; + } + }, + encodeComponent: function(string) { + return encodeURIComponent(encodeURIComponent(string)); + } + }; + return urlService; +}); \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/configurationResources/spaceToolsConfiguration.vm b/confluence-plugin/src/main/resources/configurationResources/spaceToolsConfiguration.vm new file mode 100644 index 0000000..0bb14bc --- /dev/null +++ b/confluence-plugin/src/main/resources/configurationResources/spaceToolsConfiguration.vm @@ -0,0 +1,25 @@ + + + Configure DoC + + #requireResource("confluence.web.resources:ajs") + #requireResource("com.atlassian.auiplugin:aui-select2") + #requireResource("com.atlassian.auiplugin:aui-toggle") + #requireResource("com.atlassian.auiplugin:dialog2") + #requireResource("com.networkedassets.autodoc.confluence-plugin:configuration-resources") + #putMetadata('configLocation', "space") + +#applyDecorator("root") +#decoratorParam("context" "space") +#decoratorParam("mode" "collector") +#decoratorParam("collector-key" "plugin-content-main-link") +#applyDecorator ("root") + #decoratorParam ("context" "spacetoolspanel") + #decoratorParam("helper" $action.helper) + #decoratorParam("selectedSpaceToolsWebItem" "space-tools-autodoc-config") + + $innerHtml + + #end +#end + \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/css/autodoc-style.css b/confluence-plugin/src/main/resources/css/autodoc-style.css new file mode 100644 index 0000000..17a4b8d --- /dev/null +++ b/confluence-plugin/src/main/resources/css/autodoc-style.css @@ -0,0 +1,66 @@ +.container { + border: 1px solid #B7B7B7; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + padding: 10px; + margin-top: 10px; +} + +.expand-arrow { + display: inline-block; + margin-top: 3px; +} + +.expandable-header { + cursor: pointer; + border-bottom: 1px solid #B7B7B7; +} + +.add-page-btn { + margin-left: 5px; + width: 54px; +} + +.scheduled-event { + border: 1px solid #B7B7B7; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + margin: 5px 0 5px 0; + padding-right: 5px; +} + +.scheduled-event label { + float: left; + margin-left: -145px; + padding: 5px 0 0 0; + position: relative; + text-align: right; + width: 130px; + word-wrap: break-word; +} + +.scheduled-event > div { + box-sizing: border-box; + clear: both; + padding: 4px 0 4px 120px; + position: relative; + margin: 1px 0; + width: 100%; +} + +.schedule-start { + display: inline-block; +} + +.branch { + display: inline-block; + margin-right: 5px; + vertical-align: top; + width: 460px; +} + +#save-button { + margin-top: 5px; +} \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/images/doc_logo.png b/confluence-plugin/src/main/resources/images/doc_logo.png new file mode 100644 index 0000000..af77f47 Binary files /dev/null and b/confluence-plugin/src/main/resources/images/doc_logo.png differ diff --git a/confluence-plugin/src/main/resources/images/pluginIcon.png b/confluence-plugin/src/main/resources/images/pluginIcon.png new file mode 100644 index 0000000..42ff01a Binary files /dev/null and b/confluence-plugin/src/main/resources/images/pluginIcon.png differ diff --git a/confluence-plugin/src/main/resources/images/pluginLogo.png b/confluence-plugin/src/main/resources/images/pluginLogo.png new file mode 100644 index 0000000..8157193 Binary files /dev/null and b/confluence-plugin/src/main/resources/images/pluginLogo.png differ diff --git a/confluence-plugin/src/main/resources/images/pluginMacroIcon.png b/confluence-plugin/src/main/resources/images/pluginMacroIcon.png new file mode 100644 index 0000000..a3957fb Binary files /dev/null and b/confluence-plugin/src/main/resources/images/pluginMacroIcon.png differ diff --git a/confluence-plugin/src/main/resources/images/vendorIcon.png b/confluence-plugin/src/main/resources/images/vendorIcon.png new file mode 100644 index 0000000..3c9661b Binary files /dev/null and b/confluence-plugin/src/main/resources/images/vendorIcon.png differ diff --git a/confluence-plugin/src/main/resources/images/vendorLogo.png b/confluence-plugin/src/main/resources/images/vendorLogo.png new file mode 100644 index 0000000..1556cfd Binary files /dev/null and b/confluence-plugin/src/main/resources/images/vendorLogo.png differ diff --git a/confluence-plugin/src/main/resources/js/autodocMacroParams.js b/confluence-plugin/src/main/resources/js/autodocMacroParams.js new file mode 100644 index 0000000..4b49c0e --- /dev/null +++ b/confluence-plugin/src/main/resources/js/autodocMacroParams.js @@ -0,0 +1,244 @@ +(function ($) { + var baseUrl = $("meta#confluence-base-url").attr("content"); + var bundleListUrl = baseUrl + "/rest/doc/1.0/configuration/bundles"; + var tokenCheckUrl = baseUrl + "/rest/doc/1.0/token/ask"; + var tokenGenerateUrl = baseUrl + "/rest/doc/1.0/token"; + var vm = { + chosen: { + bundle: null, + macroOwner: null + }, + macro: null + }; + var bundles = null; + var dialogInstance = null; + + var enableOrDisableSaveButton = function () { + if ($("#doc_macroDialogOptions").find("input:checkbox:checked").length > 0 && vm.chosen.bundle != null) { + $("#doc_macroDialogSaveButton").enable(); + } else { + $("#doc_macroDialogSaveButton").disable(); + } + }; + + var checkCurrentUserHasToken = function () { + return $.getJSON(tokenCheckUrl) + }; + + var save = function () { + var macroName = "docMacro"; + + var currentParams = $.extend({}, vm.chosen); + currentParams.omniDoc = $("#doc_macroDialogOmniDocCheckbox").is(":checked"); + currentParams.classDiagram = $("#doc_macroDialogClassDiagramCheckbox").is(":checked"); + currentParams.structureGraph = $("#doc_macroDialogStructureGraphCheckbox").is(":checked"); + currentParams.markup = $("#doc_macroDialogMarkupCheckbox").is(":checked"); + tinymce.confluence.macrobrowser.macroBrowserComplete({ + "name": macroName, + "bodyHtml": undefined, + "params": currentParams + }); + AJS.dialog2(getDialogInstance()).hide(); + }; + + var getDialogInstance = function () { + if (dialogInstance === null) { + // region var html = ...; + var html = + ''; + // endregion + dialogInstance = $(html).appendTo("body"); + + dialogInstance.find("#doc_macroDialogCloseButton").click(function () { + AJS.dialog2("#doc_macroDialog").hide(); + }); + + dialogInstance.find("#doc_macroDialogSaveButton").click(function () { + save(); + }); + + dialogInstance.find("#doc_macroDialogOptions input:checkbox").change(function () { + enableOrDisableSaveButton(); + }); + } + return dialogInstance; + }; + + var load = function () { + $("#doc_macroDialogLoading").fadeIn(0); + $("#doc_macroDialogContent").fadeOut(0); + $("#doc_macroDialogError").fadeOut(0); + $("#doc_macro-login-form").fadeOut(0); + + var doTheRestOfTheWork = function () { + $.ajax({ + dataType: "json", + url: bundleListUrl, + headers: {"X-Macro-Owner": vm.chosen.macroOwner} + }).then(function (data) { + console.log(data); + vm.data = data; + init(); + }, function () { + $("#doc_macroDialogError").fadeIn(0); + $("#doc_macroDialogLoading").fadeOut(0); + }); + }; + + checkCurrentUserHasToken().then(function (userHasToken) { + if (userHasToken) { + vm.chosen.macroOwner = (vm.macro.params && vm.macro.params.macroOwner) || AJS.params.remoteUserKey; + doTheRestOfTheWork() + } else { + loginAndThen(function () { + vm.chosen.macroOwner = AJS.params.remoteUserKey; + doTheRestOfTheWork(); + }); + } + }, /*else*/ function () { + loginAndThen(function () { + vm.chosen.macroOwner = AJS.params.remoteUserKey; + doTheRestOfTheWork(); + }); + }); + + }; + + var loginAndThen = function (callback) { + var loginForm = $("#doc_macro-login-form"); + loginForm.fadeIn(0); + $("#doc_macroDialogLoading").fadeOut(0); + + var emailField = loginForm.find("#doc_macro-login-email"); + var passwordField = loginForm.find("#doc_macro-login-password"); + var invalidCredentialsMessage = loginForm.find("#doc_macro-invalid-username"); + var loginButton = loginForm.find("#doc_macro-login-submit"); + + invalidCredentialsMessage.fadeOut(0); + + loginButton.click(function () { + invalidCredentialsMessage.fadeOut(0); + $.ajax({ + url: tokenGenerateUrl, + contentType: "application/json", + type: "PUT", + data: JSON.stringify({username: emailField.val(), password: passwordField.val()}), + processData: false + }).then(function () { + checkCurrentUserHasToken().then(function (userHasToken) { + if (userHasToken) { + loginForm.fadeOut(0); + callback(); + } else { + invalidCredentialsMessage.fadeIn(0); + } + }, function () { + invalidCredentialsMessage.fadeIn(0); + }) + }, function () { + invalidCredentialsMessage.fadeIn(0); + }); + }); + }; + + var init = function () { + var cntr = $("#doc_macroDialogSelectCntr").empty().append('

Bundle

'); + bundles = $('').appendTo(cntr); + + var bundleSelect = $(bundles); + bundleSelect.auiSelect2(); + + bundleSelect.change(function () { + vm.chosen.bundle = bundleSelect.val(); + }); + + bundleSelect.change(); + + setParams(); + $("#doc_macroDialogLoading").fadeOut(0); + $("#doc_macroDialogContent").fadeIn(0); + enableOrDisableSaveButton(); + }; + + var setParams = function () { + if (vm.macro.params) { + bundles.select2("val", vm.macro.params.bundle).change(); + + // TODO refactor into a single array and couple foreach loops – for easier component addition in the future + $("#doc_macroDialogOmniDocCheckbox").prop("checked", vm.macro.params.omniDoc === "true"); + $("#doc_macroDialogClassDiagramCheckbox").prop("checked", vm.macro.params.classDiagram === "true"); + $("#doc_macroDialogStructureDiagramCheckbox").prop("checked", vm.macro.params.structureGraph === "true"); + $("#doc_macroDialogMarkupCheckbox").prop("checked", vm.macro.params.markup === "true"); + } else { + $("#doc_macroDialogOptions").find("input:checkbox").prop("checked", true); + } + }; + + AJS.MacroBrowser.setMacroJsOverride("docMacro", { + "opener": function (macro) { + vm.macro = macro; + AJS.dialog2(getDialogInstance()).show(); + load(); + } + }); +})(AJS.$); \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/macro.vm b/confluence-plugin/src/main/resources/macro.vm new file mode 100644 index 0000000..9a325ec --- /dev/null +++ b/confluence-plugin/src/main/resources/macro.vm @@ -0,0 +1,6 @@ +#putMetadata('macroResourcePath', $resourcesPath) +#putMetadata('macroParamsJson', $paramsJson) +#requireResource("com.atlassian.auiplugin:aui-select2") +#requireResource("com.networkedassets.autodoc.confluence-plugin:macro-resources") + +$macroSectionHtml \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/templates/configureScreen.soy b/confluence-plugin/src/main/resources/templates/configureScreen.soy new file mode 100644 index 0000000..9c506c0 --- /dev/null +++ b/confluence-plugin/src/main/resources/templates/configureScreen.soy @@ -0,0 +1,167 @@ +{namespace com.networkedassets.autodoc.configuration} + +/** + * Renders the configure screen + * @param allProjects + * @param pages + */ +{template .configureScreen} +
+

Select events to watch for

+
+ {foreach $project in $allProjects} + {call .project data="$project"} + {param pages: $pages/} + {/call} + {/foreach} +
+ +
+{/template} + +/** + * Renders the project panel + * @param pages + * @param name + * @param key + * @param repos + */ +{template .project} +
+
+

Expand{$name}

+
+
+ {foreach $repo in $repos} + {call .repo data="$repo"} + {param pages: $pages/} + {/call} + {/foreach} +
+
+{/template} + +/** + * Renders the repo panel + * @param pages + * @param name + * @param slug + * @param branches + */ +{template .repo} +
+
+

Expand{$name}

+
+
+ {foreach $branch in $branches} + {call .branch data="$branch"} + {param pages: $pages/} + {/call} + {/foreach} +
+
+{/template} + +/** + * Renders the branch panel + * @param pages + * @param displayId + * @param id + * @param javadocPageId + * @param umlPageId + * @param isListened + * @param scheduledEvents + */ +{template .branch} +
+
+

Expand{$displayId}

+
+
+
+ {call .pageSelector} + {param selectName: 'javadoc'/} + {param labelName: 'Javadoc location'/} + {param pages: $pages/} + {param selectedPageId: $javadocPageId/} + {/call} + + {call .pageSelector} + {param selectName: 'uml'/} + {param labelName: 'UML location'/} + {param pages: $pages/} + {param selectedPageId: $umlPageId/} + {/call} + +
+ Git events +
+ + +
+
+ +
+ +
+ {foreach $scheduledEvent in $scheduledEvents} + {call .scheduledEventDetails data="$scheduledEvent"/} + {/foreach} + +
+
+ +
+
+
+{/template} + +/** + * Renders scheduled event details + * @param scheduleStartIso + * @param periodIso + */ +{template .scheduledEventDetails} +
+
+ + +
+
+ + +
+
+ +
+
+{/template} + +/** + * Renders page selector + * @param selectName + * @param labelName + * @param pages + * @param selectedPageId + */ +{template .pageSelector} +
+ + + +
+{/template} \ No newline at end of file diff --git a/confluence-plugin/src/main/resources/templates/space-admin-decorator.vm b/confluence-plugin/src/main/resources/templates/space-admin-decorator.vm new file mode 100644 index 0000000..650bb44 --- /dev/null +++ b/confluence-plugin/src/main/resources/templates/space-admin-decorator.vm @@ -0,0 +1,28 @@ +#set ( $d = "$") + + + Configure DoC + + #requireResource("confluence.web.resources:ajs") + #requireResource("com.atlassian.auiplugin:aui-select") + #requireResource("com.atlassian.auiplugin:dialog2") + $webResourceManager.requireResourcesForContext("autodoc_confluence") + $webResourceManager.requireResourcesForContext("add-pagetree") + + + #applyDecorator("root") + #decoratorParam("helper" $action.helper) + #decoratorParam("context" "space-administration") + + #applyDecorator ("root") + #decoratorParam ("context" "spaceadminpanel") + ##decoratorParam ("selection" "autodoc-serverConfig-link") + #decoratorParam ("selectedSpaceToolsWebItem" "autodoc-configuration-link") + #decoratorParam ("helper" $action.helper) + + + $soyRenderer.render($soyResource, $pageContent, $soyParams) + + #end + #end + \ No newline at end of file diff --git a/confluence-plugin/src/main/typescript/.editorconfig b/confluence-plugin/src/main/typescript/.editorconfig new file mode 100644 index 0000000..f352616 --- /dev/null +++ b/confluence-plugin/src/main/typescript/.editorconfig @@ -0,0 +1,14 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = 0 +trim_trailing_whitespace = false diff --git a/confluence-plugin/src/main/typescript/.ember-cli b/confluence-plugin/src/main/typescript/.ember-cli new file mode 100644 index 0000000..18e4118 --- /dev/null +++ b/confluence-plugin/src/main/typescript/.ember-cli @@ -0,0 +1,5 @@ +{ + "output-path": "../../../target/classes/frontend", + "port": 4201, + "live-reload-port": 49153 +} diff --git a/confluence-plugin/src/main/typescript/.gitignore b/confluence-plugin/src/main/typescript/.gitignore new file mode 100644 index 0000000..fccc4d9 --- /dev/null +++ b/confluence-plugin/src/main/typescript/.gitignore @@ -0,0 +1,33 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist +/tmp + +# dependencies +/node_modules +/bower_components + +# IDEs and editors +/.idea +.project +.classpath +*.launch +.settings/ + +# misc +/.sass-cache +/connect.lock +/coverage/* +/libpeerconnection.log +npm-debug.log +testem.log +/typings + +# e2e +/e2e/*.js +/e2e/*.map + +#System Files +.DS_Store +Thumbs.db diff --git a/confluence-plugin/src/main/typescript/README.md b/confluence-plugin/src/main/typescript/README.md new file mode 100644 index 0000000..71e2248 --- /dev/null +++ b/confluence-plugin/src/main/typescript/README.md @@ -0,0 +1,31 @@ +# Typescript + +This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.10. + +## Development server +Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. + +## Code scaffolding + +Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/route/class`. + +## Build + +Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. + +## Running unit tests + +Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Running end-to-end tests + +Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). +Before running the tests make sure you are serving the app via `ng serve`. + +## Deploying to Github Pages + +Run `ng github-pages:deploy` to deploy to Github Pages. + +## Further help + +To get more help on the `angular-cli` use `ng --help` or go check out the [Angular-CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/confluence-plugin/src/main/typescript/angular-cli-build.js b/confluence-plugin/src/main/typescript/angular-cli-build.js new file mode 100644 index 0000000..09c02e4 --- /dev/null +++ b/confluence-plugin/src/main/typescript/angular-cli-build.js @@ -0,0 +1,27 @@ +// Angular-CLI build configuration +// This file lists all the node_modules files that will be used in a build +// Also see https://github.com/angular/angular-cli/wiki/3rd-party-libs + +/* global require, module */ + +var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); + +module.exports = function(defaults) { + return new Angular2App(defaults, { + vendorNpmFiles: [ + 'systemjs/dist/system-polyfills.js', + 'systemjs/dist/system.src.js', + 'zone.js/dist/**/*.+(js|js.map)', + 'es6-shim/es6-shim.js', + 'reflect-metadata/**/*.+(ts|js|js.map)', + 'rxjs/**/*.+(js|js.map)', + '@angular/**/*.+(js|js.map)', + 'd3/*.js', + 'dagre/dist/dagre.min.js', + 'dagre-d3/dist/dagre-d3.min.js', + 'moment/moment.js', + 'ng2-bootstrap/**/*.js', + 'ng2-auto-complete/dist/**/*.+(js|js.map)' + ] + }); +}; diff --git a/confluence-plugin/src/main/typescript/angular-cli.json b/confluence-plugin/src/main/typescript/angular-cli.json new file mode 100644 index 0000000..2f0edbc --- /dev/null +++ b/confluence-plugin/src/main/typescript/angular-cli.json @@ -0,0 +1,32 @@ +{ + "project": { + "version": "1.0.0-beta.10", + "name": "typescript" + }, + "apps": [ + { + "main": "src/main.ts", + "tsconfig": "src/tsconfig.json", + "mobile": false + } + ], + "addons": [], + "packages": [], + "e2e": { + "protractor": { + "config": "config/protractor.conf.js" + } + }, + "test": { + "karma": { + "config": "config/karma.conf.js" + } + }, + "defaults": { + "prefix": "app", + "sourceDir": "src", + "styleExt": "css", + "prefixInterfaces": false, + "lazyRoutePrefix": "+" + } +} diff --git a/confluence-plugin/src/main/typescript/config/environment.dev.ts b/confluence-plugin/src/main/typescript/config/environment.dev.ts new file mode 100644 index 0000000..ffe8aed --- /dev/null +++ b/confluence-plugin/src/main/typescript/config/environment.dev.ts @@ -0,0 +1,3 @@ +export const environment = { + production: false +}; diff --git a/confluence-plugin/src/main/typescript/config/environment.js b/confluence-plugin/src/main/typescript/config/environment.js new file mode 100644 index 0000000..208d0ba --- /dev/null +++ b/confluence-plugin/src/main/typescript/config/environment.js @@ -0,0 +1,12 @@ +// Angular-CLI server configuration +// Unrelated to environment.dev|prod.ts + +/* jshint node: true */ + +module.exports = function(environment) { + return { + environment: environment, + baseURL: '/', + locationType: 'auto' + }; +}; diff --git a/confluence-plugin/src/main/typescript/config/environment.prod.ts b/confluence-plugin/src/main/typescript/config/environment.prod.ts new file mode 100644 index 0000000..3612073 --- /dev/null +++ b/confluence-plugin/src/main/typescript/config/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/confluence-plugin/src/main/typescript/config/karma-test-shim.js b/confluence-plugin/src/main/typescript/config/karma-test-shim.js new file mode 100644 index 0000000..b62ba72 --- /dev/null +++ b/confluence-plugin/src/main/typescript/config/karma-test-shim.js @@ -0,0 +1,56 @@ +// Test shim for Karma, needed to load files via SystemJS + +/*global jasmine, __karma__, window*/ +Error.stackTraceLimit = Infinity; +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; + +__karma__.loaded = function () { +}; + +var distPath = '/base/dist/'; +var appPaths = ['app']; //Add all valid source code folders here + +function isJsFile(path) { + return path.slice(-3) == '.js'; +} + +function isSpecFile(path) { + return path.slice(-8) == '.spec.js'; +} + +function isAppFile(path) { + return isJsFile(path) && appPaths.some(function(appPath) { + var fullAppPath = distPath + appPath + '/'; + return path.substr(0, fullAppPath.length) == fullAppPath; + }); +} + +var allSpecFiles = Object.keys(window.__karma__.files) + .filter(isSpecFile) + .filter(isAppFile); + +// Load our SystemJS configuration. +System.config({ + baseURL: distPath +}); + +System.import('system-config.js').then(function() { + // Load and configure the TestComponentBuilder. + return Promise.all([ + System.import('@angular/core/testing'), + System.import('@angular/platform-browser-dynamic/testing') + ]).then(function (providers) { + var testing = providers[0]; + var testingBrowser = providers[1]; + + testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); + }); +}).then(function() { + // Finally, load all spec files. + // This will run the tests directly. + return Promise.all( + allSpecFiles.map(function (moduleName) { + return System.import(moduleName); + })); +}).then(__karma__.start, __karma__.error); diff --git a/confluence-plugin/src/main/typescript/config/karma.conf.js b/confluence-plugin/src/main/typescript/config/karma.conf.js new file mode 100644 index 0000000..ef294ce --- /dev/null +++ b/confluence-plugin/src/main/typescript/config/karma.conf.js @@ -0,0 +1,46 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/0.13/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '..', + frameworks: ['jasmine'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher') + ], + customLaunchers: { + // chrome setup for travis CI using chromium + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + files: [ + { pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false }, + { pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false }, + { pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false }, + { pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false }, + { pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false }, + { pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false }, + { pattern: 'dist/vendor/zone.js/dist/fake-async-test.js', included: true, watched: false }, + + { pattern: 'config/karma-test-shim.js', included: true, watched: true }, + + // Distribution folder. + { pattern: 'dist/**/*', included: false, watched: true } + ], + exclude: [ + // Vendor packages might include spec files. We don't want to use those. + 'dist/vendor/**/*.spec.js' + ], + preprocessors: {}, + reporters: ['progress'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/confluence-plugin/src/main/typescript/config/protractor.conf.js b/confluence-plugin/src/main/typescript/config/protractor.conf.js new file mode 100644 index 0000000..3019efc --- /dev/null +++ b/confluence-plugin/src/main/typescript/config/protractor.conf.js @@ -0,0 +1,32 @@ +// Protractor configuration file, see link for more information +// https://github.com/angular/protractor/blob/master/docs/referenceConf.js + +/*global jasmine */ +var SpecReporter = require('jasmine-spec-reporter'); + +exports.config = { + allScriptsTimeout: 11000, + specs: [ + '../e2e/**/*.e2e-spec.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + useAllAngular2AppRoots: true, + beforeLaunch: function() { + require('ts-node').register({ + project: 'e2e' + }); + }, + onPrepare: function() { + jasmine.getEnv().addReporter(new SpecReporter()); + } +}; diff --git a/confluence-plugin/src/main/typescript/e2e/app.e2e-spec.ts b/confluence-plugin/src/main/typescript/e2e/app.e2e-spec.ts new file mode 100644 index 0000000..d462259 --- /dev/null +++ b/confluence-plugin/src/main/typescript/e2e/app.e2e-spec.ts @@ -0,0 +1,14 @@ +import { TypescriptPage } from './app.po'; + +describe('typescript App', function() { + let page: TypescriptPage; + + beforeEach(() => { + page = new TypescriptPage(); + }); + + it('should display message saying app works', () => { + page.navigateTo(); + expect(page.getParagraphText()).toEqual('app works!'); + }); +}); diff --git a/confluence-plugin/src/main/typescript/e2e/app.po.ts b/confluence-plugin/src/main/typescript/e2e/app.po.ts new file mode 100644 index 0000000..e9c6510 --- /dev/null +++ b/confluence-plugin/src/main/typescript/e2e/app.po.ts @@ -0,0 +1,9 @@ +export class TypescriptPage { + navigateTo() { + return browser.get('/'); + } + + getParagraphText() { + return element(by.css('app-root h1')).getText(); + } +} diff --git a/confluence-plugin/src/main/typescript/e2e/tsconfig.json b/confluence-plugin/src/main/typescript/e2e/tsconfig.json new file mode 100644 index 0000000..29de610 --- /dev/null +++ b/confluence-plugin/src/main/typescript/e2e/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "declaration": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "mapRoot": "", + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noImplicitAny": false, + "rootDir": ".", + "sourceMap": true, + "sourceRoot": "/", + "target": "es5" + } +} diff --git a/confluence-plugin/src/main/typescript/e2e/typings.d.ts b/confluence-plugin/src/main/typescript/e2e/typings.d.ts new file mode 100644 index 0000000..eebc272 --- /dev/null +++ b/confluence-plugin/src/main/typescript/e2e/typings.d.ts @@ -0,0 +1 @@ +/// diff --git a/confluence-plugin/src/main/typescript/package.json b/confluence-plugin/src/main/typescript/package.json new file mode 100644 index 0000000..48aa7ca --- /dev/null +++ b/confluence-plugin/src/main/typescript/package.json @@ -0,0 +1,50 @@ +{ + "name": "typescript", + "version": "0.0.0", + "license": "MIT", + "angular-cli": {}, + "scripts": { + "start": "ng serve", + "build": "ng build", + "prod": "ng build --prod", + "postinstall": "typings install", + "lint": "tslint \"src/**/*.ts\"", + "test": "ng test", + "pree2e": "webdriver-manager update", + "e2e": "protractor" + }, + "private": true, + "dependencies": { + "@angular/common": "2.0.0", + "@angular/compiler": "2.0.0", + "@angular/core": "2.0.0", + "@angular/forms": "2.0.0", + "@angular/http": "2.0.0", + "@angular/platform-browser": "2.0.0", + "@angular/platform-browser-dynamic": "2.0.0", + "@angular/router": "3.0.0", + "dagre-d3": "~0.4.17", + "es6-shim": "0.35.1", + "moment": "^2.14.1", + "ng2-bootstrap": "1.1.5", + "reflect-metadata": "0.1.3", + "rxjs": "5.0.0-beta.12", + "systemjs": "0.19.31", + "zone.js": "0.6.23" + }, + "devDependencies": { + "angular-cli": "1.0.0-beta.10", + "codelyzer": "0.0.20", + "ember-cli-inject-live-reload": "1.4.0", + "jasmine-core": "2.4.1", + "jasmine-spec-reporter": "2.5.0", + "karma": "0.13.22", + "karma-chrome-launcher": "0.2.3", + "karma-jasmine": "0.3.8", + "protractor": "3.3.0", + "ts-node": "0.5.5", + "tslint": "3.11.0", + "typescript": "1.8.10", + "typings": "1.3.1" + } +} diff --git a/confluence-plugin/src/main/typescript/public/.npmignore b/confluence-plugin/src/main/typescript/public/.npmignore new file mode 100644 index 0000000..e69de29 diff --git a/confluence-plugin/src/main/typescript/src/app/app.component.css b/confluence-plugin/src/main/typescript/src/app/app.component.css new file mode 100644 index 0000000..e69de29 diff --git a/confluence-plugin/src/main/typescript/src/app/app.component.html b/confluence-plugin/src/main/typescript/src/app/app.component.html new file mode 100644 index 0000000..0680b43 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/app.component.html @@ -0,0 +1 @@ + diff --git a/confluence-plugin/src/main/typescript/src/app/app.component.ts b/confluence-plugin/src/main/typescript/src/app/app.component.ts new file mode 100644 index 0000000..35abaf7 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/app.component.ts @@ -0,0 +1,11 @@ +import { Component } from '@angular/core'; + +@Component({ + moduleId: module.id, + selector: 'app-root', + templateUrl: 'app.component.html', + styleUrls: ['app.component.css'] +}) +export class AppComponent { + title = 'app works!'; +} diff --git a/confluence-plugin/src/main/typescript/src/app/app.module.ts b/confluence-plugin/src/main/typescript/src/app/app.module.ts new file mode 100644 index 0000000..6bdbfda --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/app.module.ts @@ -0,0 +1,47 @@ +import {NgModule} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {BrowserModule} from '@angular/platform-browser'; +import {AppComponent} from './app.component'; +import {appRoutingProviders, routing} from './app.routing'; +import {MainComponent} from './main/main.component'; +import {ParamsService} from './params.service'; +import {UrlService} from './url.service'; +import {HttpModule, Http} from '@angular/http'; +import {OmniDocComponent} from './documentation/omni-doc/omni-doc.component'; +import {ClassDiagramContainerComponent} from './documentation/class-diagram-container/class-diagram-container.component'; +import {MarkupComponent} from './documentation/markup/markup.component'; +import {ClassDiagramComponent} from './documentation/shared/class-diagram/class-diagram.component'; +import {CustomHttp} from './custom-http'; +import {NotifyService} from './notify.service'; +import {TreeViewComponent} from './documentation/omni-doc/tree-view/tree-view.component'; +import {TreeNodeComponent} from './documentation/omni-doc/tree-view/tree-node/tree-node.component'; +import {CapitalizePipe} from './capitalize.pipe'; +import {ReplaceCharPipe} from './replace-char.pipe'; +import {HtmlDocItemService} from './documentation/markup/shared/htmlDocItem.service'; +import {OmniDocService} from './documentation/omni-doc/shared/omnidoc.service'; +import {OmniDocEntityComponent} from './documentation/omni-doc/omni-doc-entity/omni-doc-entity.component'; +import {OmniDocTagPipe} from './documentation/omni-doc/omni-doc-tag.pipe'; +import {StructureGraphComponent} from './documentation/structure-graph/structure-graph.component'; +import {StructureGraphRendererComponent} from './documentation/structure-graph/shared/structure-graph-renderer/structure-graph-renderer.component'; +import {SearchBoxComponent} from './documentation/omni-doc/search-box/search-box.component'; +import {TypeaheadModule} from 'ng2-bootstrap/ng2-bootstrap'; +import {MarkupEntityComponent} from './documentation/markup/markup-entity/markup-entity.component'; + + +@NgModule({ + declarations: [AppComponent, MainComponent, OmniDocComponent, OmniDocEntityComponent, ClassDiagramComponent, MarkupComponent, + ClassDiagramContainerComponent, ReplaceCharPipe, TreeViewComponent, + TreeNodeComponent, CapitalizePipe, StructureGraphComponent, StructureGraphRendererComponent, OmniDocTagPipe, + SearchBoxComponent, MarkupEntityComponent], + imports: [BrowserModule, HttpModule, FormsModule, routing, TypeaheadModule], + bootstrap: [AppComponent], + providers: [appRoutingProviders, ParamsService, UrlService, HtmlDocItemService, OmniDocService, NotifyService, { + provide: CustomHttp, + useClass: CustomHttp, + deps: [Http, ParamsService] + }] + +}) +export class AppModule { + +} diff --git a/confluence-plugin/src/main/typescript/src/app/app.routing.ts b/confluence-plugin/src/main/typescript/src/app/app.routing.ts new file mode 100644 index 0000000..81fcd2f --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/app.routing.ts @@ -0,0 +1,70 @@ +import {RouterModule} from '@angular/router'; +import {ModuleWithProviders} from '@angular/core'; +import {MainComponent} from './main/main.component'; +import {OmniDocComponent} from './documentation/omni-doc/omni-doc.component'; +import {MarkupComponent} from './documentation/markup/markup.component'; +import {ClassDiagramContainerComponent} from './documentation/class-diagram-container/class-diagram-container.component'; +import {StructureGraphComponent} from './documentation/structure-graph/structure-graph.component'; +import {OmniDocEntityComponent} from './documentation/omni-doc/omni-doc-entity/omni-doc-entity.component'; +import {MarkupEntityComponent} from './documentation/markup/markup-entity/markup-entity.component'; + +const appRoutes: any = [ + { + path: ':sourceUnitId', + component: MainComponent, + children: [{ + path: 'omnidoc', + component: OmniDocComponent, + displayName: 'Omnidoc', + children: [ + { + path: '', + component: OmniDocEntityComponent + }, + { + path: ':docItem', + component: OmniDocEntityComponent + } + ], + macroParam: 'omniDoc' + }, { + path: 'class-diagram', + component: ClassDiagramContainerComponent, + displayName: 'Class Diagram', + macroParam: 'classDiagram' + }, { + path: 'markup', + component: MarkupComponent, + displayName: 'Markup', + children: [ + { + path: '', + component: MarkupEntityComponent + }, + { + path: ':docItem', + component: MarkupEntityComponent + } + ], + macroParam: 'markup' + }, { + path: 'structure-graph', + component: StructureGraphComponent, + displayName: 'Structure graph', + macroParam: 'structureGraph' + }], + containsDocTypes: true + }, + { + path: '', + component: MainComponent + }, + { + path: '**', + redirectTo: '' + } +]; + +export const appRoutingProviders: any[] = []; + +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes, {useHash: true}); diff --git a/confluence-plugin/src/main/typescript/src/app/capitalize.pipe.ts b/confluence-plugin/src/main/typescript/src/app/capitalize.pipe.ts new file mode 100644 index 0000000..bc0daa0 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/capitalize.pipe.ts @@ -0,0 +1,16 @@ +import {PipeTransform, Pipe} from '@angular/core'; + + +export function isString(txt: any): boolean { + return typeof txt === 'string'; +} + + +@Pipe({ + name: 'capitalize' +}) +export class CapitalizePipe implements PipeTransform { + transform(value: string): any { + return (isString(value)) ? value.charAt(0).toUpperCase() + value.substr(1).toLowerCase() : ''; + } +} diff --git a/confluence-plugin/src/main/typescript/src/app/custom-http.ts b/confluence-plugin/src/main/typescript/src/app/custom-http.ts new file mode 100644 index 0000000..68fec3f --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/custom-http.ts @@ -0,0 +1,83 @@ +import {Http, Response, RequestOptionsArgs, Request, Headers, RequestOptions} from '@angular/http'; +import {Observable} from 'rxjs/Rx'; +import {ParamsService} from './params.service'; + +export class CustomHttp { + constructor(private http: Http, private paramsService: ParamsService) { + } + + request(url: string | Request, options?: RequestOptionsArgs): Observable { + return this.http.request(url, options); + } + + /** + * Performs a request with `get` http method. + */ + get(url: string, options?: RequestOptionsArgs): Observable { + return this.http.get(url, this.parseOptions(options)); + } + + /** + * Performs a request with `post` http method. + */ + post(url: string, body: any, options?: RequestOptionsArgs): Observable { + return this.http.post(url, body, this.parseOptions(options)); + } + + /** + * Performs a request with `put` http method. + */ + put(url: string, body: any, options?: RequestOptionsArgs): Observable { + return this.http.put(url, body, this.parseOptions(options)); + } + + /** + * Performs a request with `delete` http method. + */ + delete(url: string, options?: RequestOptionsArgs): Observable { + return this.http.delete(url, this.parseOptions(options)); + } + + /** + * Performs a request with `patch` http method. + */ + patch(url: string, body: any, options?: RequestOptionsArgs): Observable { + return this.http.patch(url, body, this.parseOptions(options)); + } + + /** + * Performs a request with `head` http method. + */ + head(url: string, options?: RequestOptionsArgs): Observable { + return this.http.head(url, this.parseOptions(options)); + } + + /** + * Performs a request with `options` http method. + */ + options(url: string, options?: RequestOptionsArgs): Observable { + return this.http.options(url, this.parseOptions(options)); + } + + private parseOptions(options?: RequestOptionsArgs): RequestOptionsArgs { + if (!options) { + let headers = new Headers(); + options = new RequestOptions({ + headers: headers + }); + } else if (!options.headers) { + options.headers = new Headers(); + } + + if (this.paramsService.getParam("macroOwner")) { + options.headers.append("X-Macro-Owner", this.paramsService.getParam("macroOwner")); + } + + if (!this.paramsService.isInConfluence()) { + options.headers.append("Authorization", "Basic YWRtaW46YWRtaW4="); + } + + return options; + } + +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/class-diagram-container.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/class-diagram-container.component.css new file mode 100644 index 0000000..e69de29 diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/class-diagram-container.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/class-diagram-container.component.html new file mode 100644 index 0000000..0b9f8a3 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/class-diagram-container.component.html @@ -0,0 +1 @@ + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/class-diagram-container.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/class-diagram-container.component.ts new file mode 100644 index 0000000..3e855fe --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/class-diagram-container.component.ts @@ -0,0 +1,39 @@ +import {Component, OnInit} from '@angular/core'; +import {UrlService} from '../../url.service'; +import {ActivatedRoute} from '@angular/router'; +import {Subject, Observable} from 'rxjs/Rx'; +import {ParamsService} from '../../params.service'; +import {CustomHttp} from '../../custom-http'; + +@Component({ + moduleId: module.id, + selector: 'app-class-diagram-container', + templateUrl: 'class-diagram-container.component.html', + styleUrls: ['class-diagram-container.component.css'] +}) +export class ClassDiagramContainerComponent implements OnInit { + + private onInit = new Subject(); + + private data: any; + + constructor(private http: CustomHttp, private urlService: UrlService, private route: ActivatedRoute, + private paramsService: ParamsService) { + Observable.zip(this.route.parent.params, this.onInit).subscribe(() => { + this.getData(); + }); + } + + ngOnInit() { + this.onInit.next(); + } + + getData() { + this.http.get(this.urlService + .getRestUrl('documentation', 'sourceUnit', this.paramsService.getSourceUnitId(), 'documentationType', 'class_diagram', 'docItem', 'all')) + .subscribe((response) => { + this.data = response.json().content; + }); + } + +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/index.ts new file mode 100644 index 0000000..be05499 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/class-diagram-container/index.ts @@ -0,0 +1 @@ +export * from './class-diagram-container.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/htmlDocItem/htmlDocItem.ts b/confluence-plugin/src/main/typescript/src/app/documentation/markup/htmlDocItem/htmlDocItem.ts new file mode 100644 index 0000000..282ed91 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/markup/htmlDocItem/htmlDocItem.ts @@ -0,0 +1,14 @@ +export class HtmlDocItem { + + static fromObject(obj: any) { + return new HtmlDocItem(obj.id, obj.originalPath, obj.content); + } + + constructor(public id: number, public originalPath: string, public content: string) { + } + + toString() { + return `HtmlDocItem{id: ${this.id};originalPath: ${this.originalPath};content: ${this.content} }`; + } + +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/markup/index.ts new file mode 100644 index 0000000..60e9ebf --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/markup/index.ts @@ -0,0 +1 @@ +export * from './markup.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/index.ts new file mode 100644 index 0000000..5c47927 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/index.ts @@ -0,0 +1 @@ +export * from './markup-entity.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/markup-entity.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/markup-entity.component.css new file mode 100644 index 0000000..a6be3af --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/markup-entity.component.css @@ -0,0 +1,7 @@ + +.loading { + display: block; + margin: auto; + width: 20%; +} + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/markup-entity.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/markup-entity.component.html new file mode 100644 index 0000000..52ba991 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/markup-entity.component.html @@ -0,0 +1,9 @@ +
+ Loading... +
+ +
+

Click on left sidebar to display any content.

+
+ +
diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/markup-entity.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/markup-entity.component.ts new file mode 100644 index 0000000..17cfab1 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/markup-entity.component.ts @@ -0,0 +1,43 @@ +import {Component} from '@angular/core'; +import {HtmlDocItemService} from '../shared/htmlDocItem.service'; +import {Observable} from 'rxjs/Rx'; +import {ActivatedRoute} from '@angular/router'; + +@Component({ + moduleId: module.id, + selector: 'app-markup-entity', + templateUrl: 'markup-entity.component.html', + styleUrls: ['markup-entity.component.css'] +}) +export class MarkupEntityComponent { + + loading = true; + content = ''; + + constructor(private htmlDocItemService: HtmlDocItemService, private route: ActivatedRoute) { + + Observable.zip(this.htmlDocItemService.onHtmlDocItemsReady()).subscribe(() => { + this.update(this.route.snapshot.params['docItem']); + }); + + this.route.params.subscribe((params) => { + this.update(params['docItem']); + }); + } + + public update(id: number): void { + this.loading = true; + this.content = ''; + if (this.htmlDocItemService.isHtmlDocItemsReady()) { + if (id) { + setTimeout(() => { + const htmlDocItems: Array = this.htmlDocItemService.htmlDocItems.filter(item => item.id === +id); + this.content = htmlDocItems.length > 0 ? htmlDocItems[0].content : ''; + this.loading = false; + }, 50); + } else { + this.loading = false; + } + } + } +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/shared/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup-entity/shared/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup.component.css new file mode 100644 index 0000000..2035224 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup.component.css @@ -0,0 +1,12 @@ +.markup { + margin-left: 20px; + margin-right: 20px; +} + +.tree{ + width: 100%; + overflow: hidden; +} + + + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup.component.html new file mode 100644 index 0000000..e87d1b4 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup.component.html @@ -0,0 +1,24 @@ +
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+
diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup.component.ts new file mode 100644 index 0000000..a6b9139 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/markup/markup.component.ts @@ -0,0 +1,87 @@ +import {Component, OnInit} from '@angular/core'; +import {HtmlDocItem} from './htmlDocItem/htmlDocItem'; +import {ActivatedRoute, Router} from '@angular/router'; +import {HtmlDocItemService} from './shared/htmlDocItem.service'; +import {Observable, Subject} from 'rxjs/Rx'; +import {Node} from '../omni-doc/tree-view/shared/node'; +import {ParamsService} from '../../params.service'; + +@Component({ + moduleId: module.id, + selector: 'app-markup', + templateUrl: 'markup.component.html', + styleUrls: ['markup.component.css'] +}) + + +export class MarkupComponent implements OnInit { + + treeStructure: Array; + private onInit = new Subject(); + private root = 'root\\'; + + + constructor(private route: ActivatedRoute, + private htmlDocItemService: HtmlDocItemService, + private paramsService: ParamsService, + private router: Router) { + Observable.zip(this.route.parent.params, this.onInit).subscribe(() => { + this.getData(); + }); + } + + ngOnInit() { + this.onInit.next(); + } + + displayContent(node: any) { + //console.log('node', node); + if (!node.isRoot) { + this.router.navigate([this.paramsService.getBundleId(), 'markup', node.params.id]); + } + } + + + private getData() { + this.htmlDocItemService.getHtmlDocItems().subscribe(x => { + x.sort((item1: HtmlDocItem, item2: HtmlDocItem) => { + if (item1.id > item2.id) { + return 1; + } + if (item1.id < item2.id) { + return -1; + } + return 0; + }); + this.treeStructure = this.buildTreeStructure(x); + //console.log('treeStructure', this.treeStructure); + }); + } + + + private buildTreeStructure(htmlDocItems: Array): Array { + let data: Array = []; + for (let i = 0; i < htmlDocItems.length; i++) { + this.buildTree(this.root.concat(htmlDocItems[i].originalPath).split('\\'), htmlDocItems[i].id, data); + } + return data.map((node: any) => new Node(node)); + } + + private buildTree(parts: string [], partsId: number, treeNode: any[]) { + if (parts.length === 0) { + return; + } + for (let i = 0; i < treeNode.length; i++) { + if (parts[0] === treeNode[i].name) { + this.buildTree(parts.splice(1, parts.length), partsId, treeNode[i].children); + return; + } + } + let children: Array = []; + let newNode = {'name': parts[0], 'id': partsId, 'children': children}; + treeNode.push(newNode); + this.buildTree(parts.splice(1, parts.length), partsId, newNode.children); + } + + +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/markup/shared/htmlDocItem.service.ts b/confluence-plugin/src/main/typescript/src/app/documentation/markup/shared/htmlDocItem.service.ts new file mode 100644 index 0000000..7d25da3 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/markup/shared/htmlDocItem.service.ts @@ -0,0 +1,57 @@ +import {Injectable} from '@angular/core'; +import {HtmlDocItem} from '../htmlDocItem/htmlDocItem'; +import {Response} from '@angular/http'; +import {UrlService} from '../../../url.service'; +import {Observable, Subject} from 'rxjs/Rx'; +import {NotifyService} from '../../../notify.service'; +import {ParamsService} from '../../../params.service'; +import {CustomHttp} from '../../../custom-http'; + +@Injectable() +export class HtmlDocItemService { + + + htmlDocItems: Array; + private htmlDocItemsReady = false; + private htmlDocItemsSubject = new Subject(); + + + constructor(private http: CustomHttp, private urlService: UrlService, + private notifyService: NotifyService, private paramsService: ParamsService) { + } + + + getHtmlDocItems(): Observable> { + return Observable.create((observer: any) => { + this.http.get( + this.urlService.getRestUrl('documentation', 'sourceUnit', this.paramsService.getSourceUnitId(), + 'documentationType', 'html')).map(resp => resp.json().docItems.map((x: any) => HtmlDocItem.fromObject(x))) + .catch((err: Response) => { + if (err.status === 404) { + this.notifyService.info('Markup not found', 'Check if markup exists in selected source unit.'); + return Observable.throw(err); + } + this.notifyService.error('An error occurred', 'Try reloading the page.'); + return Observable.throw(err); + }).subscribe((result) => { + this.htmlDocItems = result; + observer.next(result); + observer.complete(); + this.htmlDocItemsReady = true; + this.htmlDocItemsSubject.next(); + }); + }); + + } + + + onHtmlDocItemsReady(): Observable { + return this.htmlDocItemsSubject; + }; + + isHtmlDocItemsReady(): boolean { + return this.htmlDocItemsReady; + } + + +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/index.ts new file mode 100644 index 0000000..c34d9da --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/index.ts @@ -0,0 +1 @@ +export * from './omni-doc.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/index.ts new file mode 100644 index 0000000..12d2813 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/index.ts @@ -0,0 +1 @@ +export * from './omni-doc-entity.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/omni-doc-entity.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/omni-doc-entity.component.css new file mode 100644 index 0000000..9fa9859 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/omni-doc-entity.component.css @@ -0,0 +1,308 @@ +/*:host /deep/ .loadingSpinner { + width: 100%; + height: 200px; +}*/ + +:host /deep/ h1 span.entityType, :host /deep/ h1 span.modifier { + font-size: 0.4em; +} + +:host /deep/ .supers, :host /deep/ .interfaces { + margin-left: 50px; +} + +:host /deep/ .elems > table { + width: 100%; + table-layout: auto; +} + +:host /deep/ .elems > table td { + vertical-align: top; + padding: 10px; +} + +:host /deep/ .elems > table td:first-child { + width: 200px; + text-align: right; +} + +:host /deep/ .elems table { + border: 2px solid #f5f5f5; + border-spacing: 0; +} + +:host /deep/ .elems .elem { + padding: 0.5em; + background: #fff; +} + +:host /deep/ .elems .elem.even { + background: #f5f5f5; +} + +:host /deep/ .elems .elem.selected td { + background: #ebf2f9; +} + +:host /deep/ span.modifier { + font-size: 0.9em; + line-height: 1.2em; + vertical-align: 0.1em; +} + +:host /deep/ span.generic { + margin-right: 0.3em; + font-weight: 600; +} + +:host /deep/ span.modifier, +:host /deep/ span.type, +:host /deep/ a.type { + background: #e9e9e9; + font-weight: 600; + display: inline-block; + border-radius: 1em; + margin: 0.2em 0; + vertical-align: 0; + padding: 0 0.75em; +} + +:host /deep/ span.modifier:not(:first-of-type) { + margin: 0 4px; +} + +:host /deep/ span.type, +:host /deep/ a.type { + background: #e9e9e9; + border-radius: 0.2em; + cursor: default; +} + +:host /deep/ span.modifier.public { + background: #59afe1; + color: #fff; +} + +:host /deep/ span.entityType { + border-radius: 0.2em; + color: #fff; + display: inline-block; + font-family: sans-serif !important; + text-transform: uppercase; + text-align: center; + min-width: 1em; + height: 1em; + font-size: 0.8em; + line-height: 1em; + font-weight: bold; + margin-right: 0.2em; + padding: 0.3em 0.2em 0.1em 0.2em; +} + +:host /deep/ span.entityType.entityTypePackage { + background: #666; +} + +:host /deep/ span.entityType.entityTypeClass { + background: #59afe1; +} + +:host /deep/ span.entityType.entityTypeInterface { + background: #8eb021; +} + +:host /deep/ span.entityType.entityTypeAnnotation { + background: #f6c342; + padding: 0.3em 0.2em 0.1em 0.2em; +} + +:host /deep/ span.entityType.entityTypeException { + background: #d04437; +} + +:host /deep/ span.entityType.entityTypeEnum { + background: #84bbc6; +} + +:host /deep/ span.modifier.static { + background: #f6c342; +} + +:host /deep/ span.modifier.private { + background: #d04437; + color: #fff; +} + +:host /deep/ span.modifier.abstract { + background: #f15c75; + color: #fff; +} + +:host /deep/ span.modifier.protected { + background: #654982; + color: #fff; +} + +:host /deep/ span.modifier.synchronized { + background: #815b3a; + color: #fff; +} + +:host /deep/ .elems .elem a.name, +:host /deep/ .elems .elem span.name, +:host /deep/ .methods .method > span.type, +:host /deep/ .elems .elem span.parameterName { + font-size: 1.0em; + font-weight: 600; +} + +:host /deep/ .elems .elem a.name, +:host /deep/ .elems .elem span.name { + font-size: 1.2em; +} + +:host /deep/ .elems .elem > span.parameters .parenthesis, +:host /deep/ .elems .elem > span.parameters .comma { + font-size: 1.2em; + font-weight: 600; +} + +:host /deep/ .elems .elem span.parameters span.parameter { + margin: 0 0.2em; + white-space: nowrap; +} + +:host /deep/ .elems .elem span.parameters span.parameter:last-of-type { + margin-right: 0; +} + +:host /deep/ .elems .elem span.parameters span.parameterName { + font-weight: 400; +} + +:host /deep/ .elems .elem span.parameters a.type, +:host /deep/ .elems .elem span.parameters span.type { + background: #e9e9e9; +} + +:host /deep/ .elem > span { + display: inline-block; + vertical-align: top; +} + +:host /deep/ span.modifiers { + margin-right: 5px; +} + +:host /deep/ .elem > span.modifiers { + display: block; + margin-bottom: 5px; +} + +:host /deep/ .elem.abstract span.name { + font-style: italic; +} + +:host /deep/ .elem.static span.name { + /*text-decoration: underline;*/ +} + +:host /deep/ .elem .toggle { + cursor: pointer; + float: right; +} + +:host /deep/ .elem .toggle { + border-radius: 0.2em; + padding: 0.2em; + background: #eee; +} + +:host /deep/ .elem.even .toggle { + background: white; +} + +:host /deep/ .elem .details { + border-radius: 0.2em; + padding: 0.5em; + margin-top: 0.5em; +} + +:host /deep/ .name.abstract { + font-style: italic; +} + +:host /deep/ .name.static { + /*text-decoration: underline;*/ +} + +:host /deep/ .elem .exceptions { + display: block; + margin-left: 50px; + margin-top: 5px; +} + +:host /deep/ .elem .exceptions .throws { + +} + +:host /deep/ .comment { + /*font-style: italic;*/ +} + +:host /deep/ .typeWrapper { + /*min-width: 150px;*/ + display: inline-block; +} + +:host /deep/ .annotations .annotation { + display: block; + color: #999999; +} + +:host /deep/ .annotations.inline .annotation { + display: inline-block; +} + +:host /deep/ h3.annotations { + margin-top: 0; + font-style: normal; + font-weight: normal; +} + +:host /deep/ a.type { + cursor: pointer; + color: #3572b0; +} + +:host /deep/ a.type:hover { + text-decoration: underline; +} + +:host /deep/ p { + margin: 0; +} + +:host /deep/ .monospace { + font-family: monospace; +} + +:host /deep/ h2.collapsible > span { + cursor: pointer; +} + +:host /deep/ h2.collapsible span.aui-icon { + vertical-align: 0.4em; +} + +.javadoc_container { + display: block; + margin: auto; + width: 30%; +} + +.loading { + display: block; + margin: auto; + width: 20%; +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/omni-doc-entity.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/omni-doc-entity.component.html new file mode 100644 index 0000000..4e48b7d --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/omni-doc-entity.component.html @@ -0,0 +1,131 @@ +
+ Loading... +
+
+
+ DoC - Documentation from Code +
+ +
+
+
+
+ +
    +
  1. + + +
  2. +
+ +
+ +
+ +
{{entity.beforeModifiers}}
+ + {{modifier}} + +
{{entity.afterModifiers}}
+ + + +

+ +

+ +
+
+ {{relation.displayName ? relation.displayName : relation.name}} + + + , + +
+
+ +
+
+
+ +
+

+ Expand/Collapse + {{memberCategory.name|capitalize}} +

+ + + + + +
+
+
+ + + +
+
+ + + +
+ +
+ + {{member?.data?.shortName}} + {{member?.data?.shortName}} + + (, ) + +
+
+
+ {{relation.displayName ? relation.displayName : relation.name}} + + + , + +
+
+
+ +
+
+
+
+
+
+ +
+

+ Expand/Collapse + UML Diagram +

+ +
+
diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/omni-doc-entity.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/omni-doc-entity.component.ts new file mode 100644 index 0000000..9dde5a7 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-entity/omni-doc-entity.component.ts @@ -0,0 +1,72 @@ +import {Component} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {OmniDocService} from '../shared/omnidoc.service'; +import {CustomHttp} from '../../../custom-http'; +import {UrlService} from '../../../url.service'; +import {ParamsService} from '../../../params.service'; +import {Observable} from 'rxjs/Rx'; + +@Component({ + moduleId: module.id, + selector: 'app-omni-doc-entity', + templateUrl: 'omni-doc-entity.component.html', + styleUrls: ['omni-doc-entity.component.css'] +}) +export class OmniDocEntityComponent { + + private loading: boolean = true; + + private entity: any; // TODO create type, when OmniDoc format is ready + + private classDiagram = { + enabled: false, + expanded: false, + data: null as any + }; + + constructor(private route: ActivatedRoute, + private omniDocService: OmniDocService, + private http: CustomHttp, + private urlService: UrlService, + private paramsService: ParamsService) { + + Observable.zip(this.omniDocService.onStructureReady()).subscribe(() => { + this.update(this.route.snapshot.params['docItem']); + }); + + this.route.params.subscribe((params) => { + this.update(params['docItem']); + }); + + this.classDiagram.enabled = !!this.paramsService.getParam('classDiagram'); + } + + public resolvePath(path: string): string { + return this.urlService.getResourcesUrl(path); + } + + public update(fullName: string): void { + if (this.omniDocService.isStructureReady()) { + if (fullName) { + this.loading = true; + this.omniDocService.getEntity(fullName).subscribe(entity => { + this.entity = entity; + this.loading = false; + if (this.classDiagram.enabled) { + this.http.get(this.urlService + .getRestUrl('documentation', 'sourceUnit', this.paramsService.getSourceUnitId(), 'documentationType', 'class_diagram', 'docItem', this.entity.fullName)) + .subscribe((response) => { + this.classDiagram.data = response.json().content; + }); + /* todo move to a service */ + } + + }); + } else { + this.loading = false; + this.entity = null as any; + } + } + } + +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-tag.pipe.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-tag.pipe.ts new file mode 100644 index 0000000..eae3eb9 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc-tag.pipe.ts @@ -0,0 +1,33 @@ +import {Pipe, PipeTransform} from '@angular/core'; +import {ParamsService} from '../../params.service'; +import {OmniDocService} from './shared/omnidoc.service'; + +@Pipe({ + name: 'omniDocTag' +}) +export class OmniDocTagPipe implements PipeTransform { + private globalPattern: RegExp = /([^<]+)<\/omni-doc>/g; + + public constructor(private paramsService: ParamsService, private omniDocService: OmniDocService) { + } + + transform(value: any, args?: any): any { + if (typeof value == 'string' && value) { + value = value.replace(this.globalPattern, (val: string) => { + this.globalPattern.lastIndex = 0; + let matches = this.globalPattern.exec(val); + let ref = matches[1]; + let content = matches[3]; + if (this.omniDocService.hasEntity(ref)) { + return '' + content + ''; + } else { + return '' + content + ''; + } + }); + } + + return value; + } + +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc.component.css new file mode 100644 index 0000000..482a275 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc.component.css @@ -0,0 +1,16 @@ +.tree { + width: 100%; + overflow: hidden; +} + +.javadoc_container { + display: block; + margin: auto; + width: 30%; +} + +.menu{ + width:280px !important; +} + + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc.component.html new file mode 100644 index 0000000..d7fe6ea --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc.component.html @@ -0,0 +1,26 @@ +
+
+
+
+ +
+ +
+
+
+
+
+ diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc.component.ts new file mode 100644 index 0000000..ec6b810 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/omni-doc.component.ts @@ -0,0 +1,40 @@ +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {Subject, Observable} from 'rxjs/Rx'; +import {OmniDocService} from './shared/omnidoc.service'; +import {ParamsService} from '../../params.service'; + +@Component({ + moduleId: module.id, + selector: 'app-omni-doc', + templateUrl: 'omni-doc.component.html', + styleUrls: ['omni-doc.component.css'] +}) +export class OmniDocComponent implements OnInit { + + private onInit = new Subject(); + treeStructure: Array; + + constructor(private route: ActivatedRoute, private omnidocService: OmniDocService, private router: Router, private paramsService: ParamsService) { + Observable.zip(this.route.parent.params, this.onInit).subscribe(() => { + this.route.parent.params.subscribe(() => { + this.getTreeStructure(); + }); + }); + } + + ngOnInit() { + this.onInit.next(); + } + + + displayContent(node: any) { + this.router.navigate([this.paramsService.getBundleId(), 'omnidoc', node.params.fullName]); + } + + getTreeStructure() { + this.omnidocService.getTreeStructure().subscribe(x => { + this.treeStructure = x; + }); + } +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/index.ts new file mode 100644 index 0000000..60e28ce --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/index.ts @@ -0,0 +1 @@ +export * from './search-box.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/search-box.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/search-box.component.css new file mode 100644 index 0000000..a632db6 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/search-box.component.css @@ -0,0 +1,73 @@ + +.dropdown-menu { + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + padding: 5px 0; + margin: 2px 0 0; + font-size: 14px; + text-align: left; + list-style: none; + height: 400px; + overflow: auto; + background-color: #fff; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #ccc; + border-radius: 4px; + -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175); + box-shadow: 0 6px 12px rgba(0, 0, 0, .175); +} + +.dropdown-menu > li > a { + display: block; + padding: 3px 20px; + clear: both; + font-weight: 400; + line-height: 1.42857143; + color: #333; + white-space: nowrap; +} + +.dropdown-menu > .active > a, .dropdown-menu > .active > a:focus, .dropdown-menu > .active > a:hover { + color: #fff; + text-decoration: none; + background-color: #337ab7; + outline: 0; +} + +.dropdown-menu > li > a:focus, .dropdown-menu > li > a:hover { + color: #262626; + text-decoration: none; + background-color: #f5f5f5; +} + +.crop { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + width: 240px; +} + +.search input { + width: 300px !important; +} + +.loading { + position: absolute; + left: 35%; + top: 30%; +} + +#searchIcon { + position: relative; + z-index: 1; + left: -25px; + top: 1px; + color: #7B7B7B; + width: 0; +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/search-box.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/search-box.component.html new file mode 100644 index 0000000..ed5bb22 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/search-box.component.html @@ -0,0 +1,28 @@ + + +
+

No results found.

+
+ +
+ Loading... +
+ + + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/search-box.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/search-box.component.ts new file mode 100644 index 0000000..57853e8 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/search-box.component.ts @@ -0,0 +1,47 @@ +import {Component, OnInit, ViewEncapsulation} from '@angular/core'; +import {OmniDocService} from '../shared/omnidoc.service'; +import {Router} from '@angular/router'; +import {Observable} from 'rxjs/Rx'; +import {ParamsService} from '../../../params.service'; + +@Component({ + moduleId: module.id, + selector: 'app-search-box', + templateUrl: 'search-box.component.html', + styleUrls: ['search-box.component.css'], + encapsulation: ViewEncapsulation.None +}) +export class SearchBoxComponent implements OnInit { + + autoCompleteSearchTerm: string = ''; + typeaheadLoading: boolean = false; + typeaheadNoResults: boolean = false; + dataSource: Observable; + + + constructor(private omnidocService: OmniDocService, private router: Router, private paramsService: ParamsService) { + this.dataSource = Observable.create((observer: any) => { + observer.next(this.autoCompleteSearchTerm); + }).mergeMap((token: string) => this.omnidocService.getOmidocSearch(token)); + + } + + ngOnInit() { + } + + public changeTypeaheadLoading(e: boolean): void { + this.typeaheadLoading = e; + } + + public changeTypeaheadNoResults(e: boolean): void { + this.typeaheadNoResults = e; + } + + public typeaheadOnSelect(e: any) { + if (e.item.documentationType.toLowerCase() === 'html') { + this.router.navigate(['/' + this.paramsService.getSourceUnitId() + '/' + 'markup' + '/' + e.item.id]); + } else { + this.router.navigate(['/' + this.paramsService.getSourceUnitId() + '/' + e.item.documentationType.toLowerCase() + '/' + e.item.fullName]); + } + } +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/shared/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/search-box/shared/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/shared/omnidoc.service.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/shared/omnidoc.service.ts new file mode 100644 index 0000000..e8f5c1e --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/shared/omnidoc.service.ts @@ -0,0 +1,103 @@ +import {Injectable} from '@angular/core'; +import {Response, URLSearchParams} from '@angular/http'; +import {UrlService} from '../../../url.service'; +import {Observable, Subject} from 'rxjs/Rx'; +import {NotifyService} from '../../../notify.service'; +import {ParamsService} from '../../../params.service'; +import {CustomHttp} from '../../../custom-http'; +import {Node} from '../tree-view/shared/node'; + +@Injectable() +export class OmniDocService { + + private names: Array; + + private structureReadySubject = new Subject(); + private structureReady = false; + + constructor(private http: CustomHttp, private urlService: UrlService, + private notifyService: NotifyService, private paramsService: ParamsService) { + } + + getTreeStructure(): Observable > { + return Observable.create((observer: any) => { + this.http.get( + this.urlService + .getRestUrl('documentation', 'sourceUnit', this.paramsService.getSourceUnitId(), 'documentationType', 'omnidoc', 'tree')) + .map(resp => resp.json().map((x: any) => new Node(x))) + .catch((err: Response) => { + if (err.status === 404) { + this.notifyService.info('OmniDoc not found', 'Check if OmniDoc exists in selected source unit.'); + return Observable.throw(err); + } + this.notifyService.error('An error occurred', 'Try reloading the page.'); + return Observable.throw(err); + }).subscribe((result) => { + this.names = this.getAllFullNames(result); + observer.next(result); + observer.complete(); + this.structureReady = true; + this.structureReadySubject.next(); + }); + }); + } + + getEntity(fullName: string) { + return this.http.get( + this.urlService + .getSourceUnitRestUrl('omnidoc', 'docItem', fullName) + ).map(resp => resp.json()); + } + + hasEntity(fullName: String): boolean { + return this.names.some(x => x === fullName); + } + + getOmidocSearch(params: string): Observable { + + let searchParams = new URLSearchParams(); + searchParams.set('query', params); + + return this.http.get(this.urlService + .getRestUrl('documentation', 'sourceUnit', this.paramsService.getSourceUnitId(), 'search'), {search: searchParams}) + .map(res => res.json()); + } + + getSingleRootTree(): Observable { + return this.http.get( + this.urlService + .getRestUrl('documentation', 'sourceUnit', this.paramsService.getSourceUnitId(), 'documentationType', 'omnidoc', 'singleRootTree')) + .map(resp => resp.json()) + .catch((err: Response) => { + if (err.status === 404) { + this.notifyService.info('OmniDoc not found', 'Check if OmniDoc exists in selected source unit.'); + return Observable.throw(err); + } + this.notifyService.error('An error occurred', 'Try reloading the page.'); + return Observable.throw(err); + }); + } + + onStructureReady(): Observable { + return this.structureReadySubject; + }; + + isStructureReady(): boolean { + return this.structureReady; + } + + private getAllFullNames(nodes: Array): Array { + let names: Array = []; + nodes.forEach((node: Node) => this.addFullNameToArray(node, names)); + return names; + } + + private addFullNameToArray(node: any, names: Array) { + names.push(node.params.fullName); + node.children.forEach((childNode: any) => this.addFullNameToArray(childNode, names)); + } +} + + + + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/shared/node.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/shared/node.ts new file mode 100644 index 0000000..5ab1a58 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/shared/node.ts @@ -0,0 +1,51 @@ +export class Node { + name: string; + parentNode: Node = null; + isRoot: boolean; + isHidden: boolean; + type = ''; + children: Array; + isExpanded = false; + focus = false; + params: {}; + + constructor(opts: { + name?: string, + type?: string, + children?: Array, + focus?: boolean + } = {}, parent: Node = null) { + + this.name = opts.name; + this.type = opts.type; + this.params = opts; + this.parentNode = parent; + this.type = opts.type || ''; + this.children = opts.children || []; + let _children: Array = []; + this.children.forEach((node) => _children.push(new Node(node, this))); + this.children = _children; + this.isRoot = this.children.length > 0; + } + + + expand(expand: boolean) { + this.isExpanded = expand; + this.children.forEach((node) => node.expand(expand)); + + } + + + filter(query: string) { + this.children.forEach((node) => node.filter(query)); + this.isHidden = this.hide(query); + + } + + private hide(query: string): boolean { + if (query === '' || ( this.children.some((node) => !node.isHidden && this.isExpanded ))) { + return false; + } + return this.name.indexOf(query) === -1; + } +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/shared/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/shared/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/tree-node.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/tree-node.component.css new file mode 100644 index 0000000..4f09fc0 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/tree-node.component.css @@ -0,0 +1,96 @@ +.all-item { + list-style-type: none; + cursor: pointer; +} + +.node-item { + color: black !important; + text-decoration: none; + white-space: nowrap; +} + +.item { + cursor: pointer; + color: black; + text-decoration: none; + display: inline-block; + white-space: nowrap; + padding-left: 20px; +} + +.children-items { + padding-left: 25px; + padding-top: 1px; + padding-bottom: 1px; + margin: 0; + +} + +span.entityType { + border-radius: 0.2em; + color: #fff; + display: inline-block; + font-family: sans-serif !important; + text-transform: uppercase; + text-align: center; + min-width: 1em; + height: 1em; + font-size: 0.8em; + line-height: 1em; + font-weight: bold; + margin-right: 0.2em; +} + +span.entityType.entityTypePackage { + background: #666; + padding: 0.3em 0.2em 0.1em 0.2em; +} + +span.entityType.entityTypeClass { + background: #59afe1; + padding: 0.3em 0.2em 0.1em 0.2em; +} + +span.entityType.entityTypeInterface { + background: #8eb021; + padding: 0.3em 0.2em 0.1em 0.2em; +} + +span.entityType.entityTypeAnnotation { + background: #f6c342; + padding: 0.3em 0.2em 0.1em 0.2em; +} + +span.entityType.entityTypeException { + background: #d04437; + padding: 0.3em 0.2em 0.1em 0.2em; +} + +span.entityType.entityTypeEnum { + background: #84bbc6; + padding: 0.3em 0.2em 0.1em 0.2em; +} + +.focus { + font-weight: bold; +} + +span.entityName { + border-width: 1px; + border-radius: 5px; + border-style: solid; + border-color: transparent; +} + +span.entityName:hover { + position: absolute; + background-color: white; + color: #3572b0; + overflow: visible; + border-color: #d6d6d6; + padding-left: 4px; + padding-right: 4px; +} + + + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/tree-node.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/tree-node.component.html new file mode 100644 index 0000000..fef7191 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/tree-node.component.html @@ -0,0 +1,24 @@ +
  • + + + {{node.type[0]}} + + + {{ node.name }} + + +
      + +
    +
  • +
  • + + {{node.type[0]}} + {{ node.name }} + +
  • + + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/tree-node.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/tree-node.component.ts new file mode 100644 index 0000000..87d4d15 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-node/tree-node.component.ts @@ -0,0 +1,39 @@ +import {Component, OnInit, Input, Output, EventEmitter} from '@angular/core'; +import {Node} from '../shared/node'; + + +@Component({ + moduleId: module.id, + selector: 'app-tree-node', + templateUrl: 'tree-node.component.html', + styleUrls: ['tree-node.component.css'] +}) + + +export class TreeNodeComponent implements OnInit { + + @Input() node: Node; + @Input() directoryIcon = false; + @Input() index: number; + @Output() clicked = new EventEmitter(); + + constructor() { + } + + ngOnInit() { + + } + + clickNodeExpand() { + this.node.isExpanded = !this.node.isExpanded; + } + + clickNodeName(node: Node) { + this.clicked.emit(node); + } + + propagate(node: Node) { + this.clicked.emit(node); + } + +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-view.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-view.component.css new file mode 100644 index 0000000..ae4f3cd --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-view.component.css @@ -0,0 +1,25 @@ + +aside > h2 span.expandAllCollapseAll { + vertical-align: text-bottom; + display: inline-block; + float: right; + padding-right: 10px; +} + +aside > h2 span.expandAllCollapseAll a, aside > h2 span.expandAllCollapseAll span { + cursor: pointer; + font-size: 10pt; + vertical-align: middle; +} + +aside > h2:after, aside > form:after { + content: "\a"; + white-space: pre; +} + +.loading { + display: block; + margin: auto; + width: 30%; +} + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-view.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-view.component.html new file mode 100644 index 0000000..635baf5 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-view.component.html @@ -0,0 +1,20 @@ +
    + +
    diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-view.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-view.component.ts new file mode 100644 index 0000000..49a7bc7 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/omni-doc/tree-view/tree-view.component.ts @@ -0,0 +1,63 @@ +import {Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges} from '@angular/core'; +import {Node} from './shared/node'; + + +@Component({ + moduleId: module.id, + selector: 'app-tree-view', + templateUrl: 'tree-view.component.html', + styleUrls: ['tree-view.component.css'] +}) +export class TreeViewComponent implements OnInit, OnChanges { + + @Input() treeNode: Array; + @Input() directoryIcon = false; + @Input() filter = false; + @Input() expandCollapseButton = false; + @Output() onChange = new EventEmitter(); + currentFocusNode: Node; + query = ''; + + private loading = true; + + constructor() { + + } + + ngOnInit() { + this.currentFocusNode = null; + } + + ngOnChanges(changes: SimpleChanges) { + if (changes['treeNode']) { + this.loading = !this.treeNode; + } + } + + nodeClicked(nextNode: Node) { + this.updateFocusNode(nextNode); + this.onChange.emit(nextNode); + } + + filterChange(query: string) { + this.treeNode.forEach((node: Node) => node.filter(query)); + } + + expandAll() { + this.treeNode.forEach((node: Node) => node.expand(true)); + } + + collapseAll() { + this.treeNode.forEach((node: Node) => node.expand(false)); + } + + + private updateFocusNode(next: Node) { + if (this.currentFocusNode) { + this.currentFocusNode.focus = false; + } + this.currentFocusNode = next; + this.currentFocusNode.focus = true; + } + +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/class-diagram.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/class-diagram.component.css new file mode 100644 index 0000000..ffc7e29 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/class-diagram.component.css @@ -0,0 +1,131 @@ +:host /deep/ { + width: 100%; + position: relative; + cursor: move; +} + +:host /deep/ .loadingSpinner { + width: 100%; + height: 200px; +} + +:host /deep/ .controls { + position: absolute; + bottom: 0; + right: 0; + font-family: sans-serif; +} + +:host /deep/ .controls span { + border-radius: 0.5em; + display: inline-block; + padding: 0.3em; + margin: 0.5em; + background: rgba(0, 0, 0, 0.8); + color: #fff; + cursor: pointer; +} + +:host /deep/ .link-tools .tool-remove, +:host /deep/ .link-tools .tool-options, +:host /deep/ .link .marker-arrowheads, +:host /deep/ .link .connection-wrap { + display: none; +} + +:host /deep/ svg { + width: 100%; + height: 100%; +} + +:host /deep/ .node rect, +:host /deep/ .node polygon { + color: #494948; + /*stroke: #c6d92d;*/ + stroke-width: 1px; +} + +.node { + cursor: pointer; +} + +:host /deep/ .node rect.fields { + fill: #edf1b3; +} + +:host /deep/ .node rect.outer { + fill: #e1ea9b; +} + +.edgePath path { + stroke: #333; + fill: #333; + stroke-width: 1.5px; +} + +:host /deep/ svg { + min-height: 500px; +} + +:host /deep/ rect.head { + fill: #c8da2f; + color: #f00; + stroke-width: 0; +} + +:host /deep/ text.head { + font-weight: bold; +} + +:host /deep/ .node g text tspan.scope { + font-family: FontAwesome; +} + +:host /deep/ .node g text tspan.scope.private { + fill: #d24538; +} + +:host /deep/ .node g text tspan.scope.protected { + fill: #664b84; +} + +:host /deep/ .node g text tspan.scope.public { + fill: #59aee1; +} + +:host /deep/ .abstract { + font-style: italic; +} + +:host /deep/ .static { + text-decoration: underline; +} + +:host /deep/ g.edgePath path.path { + stroke: #999; + stroke-width: 3px; +} + +:host /deep/ g.edgePath:hover path.path, :host /deep/ g.edgePath:hover marker polygon { + stroke: #06c; + stroke-width: 3px; +} + +:host /deep/ svg marker polygon { + fill: #fff; + stroke: #999; + stroke-width: 2; + stroke-dasharray: 1, 0; +} + +:host /deep/ svg .edgePath.aggregation marker polygon { + fill: #fff; +} + +:host /deep/ svg .edgePath.composition marker polygon { + fill: #999; +} + +:host /deep/ svg .edgePath.realization path.path, :host /deep/ svg .edgePath.dependency path.path { + stroke-dasharray: 10, 5; +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/class-diagram.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/class-diagram.component.html new file mode 100644 index 0000000..98f4268 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/class-diagram.component.html @@ -0,0 +1,4 @@ + + + + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/class-diagram.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/class-diagram.component.ts new file mode 100644 index 0000000..1c63bbd --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/class-diagram.component.ts @@ -0,0 +1,414 @@ +import {Component, OnInit, OnChanges, SimpleChanges, Input, ElementRef, ViewChild} from '@angular/core'; +import {Router} from '@angular/router'; +import {ParamsService} from '../../../params.service'; +import * as d3 from 'd3'; +import * as dagreD3 from 'dagre-d3'; + +@Component({ + moduleId: module.id, + selector: 'app-class-diagram', + templateUrl: 'class-diagram.component.html', + styleUrls: ['class-diagram.component.css'] +}) +export class ClassDiagramComponent implements OnInit, OnChanges { + + @Input('data') + private data: any; + + @ViewChild('svg') + private svgElem: ElementRef; + + @ViewChild('g') + private gElem: ElementRef; + + private dagreGraph: any; + private svg: any; + private inner: any; + private render: any; + + private initialized: boolean = false; + + constructor(private router: Router, private paramsService: ParamsService) { + } + + ngOnInit() { + this.init(); + } + + ngOnChanges(changes: SimpleChanges): void { + if (changes['data']) { + this.init(); + if (this.data) { + this.generate(); + } + } + } + + private init() { + this.dagreGraph = new dagreD3.graphlib.Graph(); + this.dagreGraph.setGraph({}); + this.svg = d3.select(this.svgElem.nativeElement); + this.inner = d3.select(this.gElem.nativeElement); + } + + private drawEntity(entity: any) { + this.dagreGraph.setNode(entity.fullName, { + data: { + abstract: entity.abstract, + static: entity.static, + methods: entity.methods, + name: entity.name, + fullName: entity.fullName, + fields: entity.fields, + type: entity.type + }, + label: "", + width: entity.size.width, + height: entity.size.height, + shape: "class" + }); + }; + + private generate() { + this.init(); + var data = this.data; + + for (var key in data.entities) { + if (data.entities.hasOwnProperty(key)) { + this.calculateEntityWidth(data.entities[key]); + this.drawEntity(data.entities[key]); + } + } + + data.relations.forEach((relation: any) => { + if (this.dagreGraph.nodes().indexOf(relation.source) === -1 || this.dagreGraph.nodes().indexOf(relation.target) === -1) { + // prevent errors in case of invalid relationship + return true; + } + + var type = relation.type; + this.dagreGraph.setEdge(relation.source, relation.target, { + //lineInterpolate: "step-after", + class: type, + arrowhead: type + }); + }); + + var zoom = d3.behavior.zoom().on("zoom", () => { + let event = d3.event as any; + this.inner.attr("transform", "translate(" + event.translate + ")" + + "scale(" + event.scale + ")"); + }).scaleExtent([0.1, 1]); + this.svg.call(zoom); + + this.render = new dagreD3.render(); + + this.render.arrows().aggregation = (parent: any, id: string) => { + var marker = parent.append("marker") + .attr("id", id) + .attr("viewBox", "0 0 50 50") + .attr("refX", 20) + .attr("refY", 10) + .attr("markerWidth", 20) + .attr("markerHeight", 20) + .attr("orient", "auto") + .classed("aggregation", true); + + var polygon = marker.append("polygon") + .attr("points", "0,10 10,5 20,10 10,15"); + }; + + this.render.arrows().composition = (parent: any, id: string) => { + var marker = parent.append("marker") + .attr("id", id) + .attr("viewBox", "0 0 50 50") + .attr("refX", 20) + .attr("refY", 10) + .attr("markerWidth", 20) + .attr("markerHeight", 20) + .attr("orient", "auto") + .classed("composition", true); + + var polygon = marker.append("polygon") + .attr("points", "0,10 10,5 20,10 10,15"); + }; + + this.render.arrows().association = (parent: any, id: string, edge: any, type: any) => { + }; + + this.render.arrows().dependency = (parent: any, id: string) => { + var marker = parent.append("marker") + .attr("id", id) + .attr("viewBox", "0 0 50 50") + .attr("refX", 20) + .attr("refY", 10) + .attr("markerWidth", 20) + .attr("markerHeight", 20) + .attr("orient", "auto") + .classed("composition", true); + + var polygon = marker.append("polygon") + .attr("points", "10,5 20,10 10,15 19.9999,10"); + }; + + this.render.arrows().realization = (parent: any, id: string) => { + var marker = parent.append("marker") + .attr("id", id) + .attr("viewBox", "0 0 50 50") + .attr("refX", 20) + .attr("refY", 10) + .attr("markerWidth", 20) + .attr("markerHeight", 20) + .attr("orient", "auto") + .classed("realization", true); + + var polygon = marker.append("polygon") + .attr("points", "10,5 20,10 10,15"); + }; + + this.render.arrows().generalization = (parent: any, id: string) => { + var marker = parent.append("marker") + .attr("id", id) + .attr("viewBox", "0 0 50 50") + .attr("refX", 20) + .attr("refY", 10) + .attr("markerWidth", 20) + .attr("markerHeight", 20) + .attr("orient", "auto") + .classed("composition", true); + + var polygon = marker.append("polygon") + .attr("points", "10,5 20,10 10,15"); + }; + + this.render.shapes().class = (parent: any, bbox: any, node: any) => { + var headerRows = 1; + + if (node.data.type == "interface") { + headerRows++; + } + + var rows = headerRows + node.data.methods.length + node.data.fields.length; + + + var w = bbox.width, + h = bbox.height; + + var h_row = 1 / rows * h; + var h1 = headerRows * h_row; + var h2 = (headerRows + node.data.fields.length) / rows * h; + + var g = parent.insert("g") + .attr("x", -w / 2) + .attr("y", -h / 2); + + var outerRect = g.append("rect") + .attr("x", -w / 2) + .attr("y", -h / 2) + .attr("width", w) + .attr("height", h) + .attr("rx", 5) + .attr("ry", 5) + .classed("outer", true); + + var nameRect = g.append("rect") + .attr("x", -w / 2) + .attr("y", -h / 2) + .attr("width", w) + .attr("height", h1) + .attr("rx", 5) + .attr("ry", 5) + .classed("head", true); + + var textOffset = { + x: -w / 2 + 4, + y: -h / 2 + h_row / 2 + 4 + }; + + if (node.data.entityType != "class" && node.data.entityType != "enum") { + + if (node.data.type == "interface") { + g.append("text") + .classed("head", true) + .attr("x", 0) + .attr("y", textOffset.y) + .attr("text-anchor", "middle") + .text('«Interface»'); + } + + g.append("text") + .classed("head", true) + .attr("x", 0) + .attr("y", textOffset.y) + .attr("text-anchor", "middle") + .text(node.data.name); + } else { + var headText = g.append("text") + .classed("head", true) + .attr("x", 0) + .attr("y", textOffset.y) + .attr("text-anchor", "middle") + .text(node.data.name); + if (node.data.abstract) { + headText.classed("abstract", true); + } + } + + var i: number; + + if (node.data.fields && node.data.fields.length) { + var fieldRect = g.append("rect") + .attr("x", -w / 2) + .attr("y", -h / 2 + h1) + .attr("width", w) + .attr("height", h2 - h1) + .classed("fields", true); + i = 0; + node.data.fields.forEach((elem: any) => { + var text = g.append("text"); + + if (elem.scope == "PUBLIC") { + text.append("tspan").text("\uf09c ").classed("scope public", true); + } else if (elem.scope == "PRIVATE") { + text.append("tspan").text("\uf023 ").classed("scope private", true); + } else if (elem.scope == "PROTECTED") { + text.append("tspan").text("\uf13e ").classed("scope protected", true); + } + + var tspan = text + //.classed("abstract",true) + //.classed("static",true) + .attr("x", textOffset.x) + .attr("y", textOffset.y + h_row * i + h1) + .append("tspan") + .text(elem.string); + + if (elem.abstract) { + tspan.classed("abstract", true); + } + + if (elem.static) { + tspan.classed("static", true); + } + + i++; + }); + } + + if (node.data.methods) { + i = 0; + node.data.methods.forEach((elem: any) => { + var text = g.append("text"); + + if (elem.scope == "PUBLIC") { + text.append("tspan").text("\uf09c ").classed("scope public", true); + } else if (elem.scope == "PRIVATE") { + text.append("tspan").text("\uf023 ").classed("scope private", true); + } else if (elem.scope == "PROTECTED") { + text.append("tspan").text("\uf13e ").classed("scope protected", true); + } + + var tspan = text + //.classed("abstract",true) + //.classed("static",true) + .attr("x", textOffset.x) + .attr("y", textOffset.y + h_row * i + h2) + .append("tspan") + .text(elem.string); + + if (elem.abstract) { + tspan.classed("abstract", true); + } + if (elem.static) { + tspan.classed("static", true); + } + + + i++; + + }); + + } + + node.intersect = (point: any) => { + return (dagreD3 as any).intersect.rect(node, point); + }; + + g.on("click", () => { + if (!(d3.event as any).defaultPrevented && d3.event) { + this.router.navigate(['/' + this.paramsService.getSourceUnitId() + '/omnidoc/' + node.data.fullName]); + } + }); + + return outerRect; + }; + + this.render(this.inner, this.dagreGraph); + + var initialScale = Math.min(parseInt(this.svg.style("width")) / this.dagreGraph.graph().width, parseInt(this.svg.style("height")) / this.dagreGraph.graph().height) * 0.9; + + zoom + .scale(initialScale) + .translate([parseInt(this.svg.style("width")) / 2 - this.dagreGraph.graph().width * initialScale / 2, 20]) + .event(this.svg); + }; + + private calculateEntityWidth(entity: any) { + var that = this; + var getWidth = function (text: string) { + if (text) { + var width = 0; + that.svg.select(".textSizer").text(text).each(function () { + width = this.getBBox().width; + return false; + }); + return width; + } else { + return 0; + } + + }; + + var widest = 0; + + if (entity.fields) { + entity.fields.forEach(function (elem: any) { + var width = getWidth(elem.string); + if (width > widest) { + widest = width; + } + }); + } + + if (entity.methods) { + entity.methods.forEach(function (elem: any) { + var width = getWidth(elem.string); + if (width > widest) { + widest = width; + } + }); + } + + var width = getWidth(entity.name); + if (width > widest) { + widest = width; + } + + var methods = entity.methods ? entity.methods.length : 0; + var fields = entity.fields ? entity.fields.length : 0; + + var headerRows = 1; + + if (entity.type != "class") { + headerRows++; + } + + var verticalCount = (Math.max(methods, 1) + Math.max(fields, 1) + headerRows); + + entity.size = { + width: Math.max(widest + 50, 200), + height: verticalCount * 20 + }; + } + +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/index.ts new file mode 100644 index 0000000..f04cc9d --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/shared/class-diagram/index.ts @@ -0,0 +1 @@ +export * from './class-diagram.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/index.ts new file mode 100644 index 0000000..9f2276a --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/index.ts @@ -0,0 +1 @@ +export * from './structure-graph.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/index.ts new file mode 100644 index 0000000..acaacec --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/index.ts @@ -0,0 +1 @@ +export * from './structure-graph-renderer'; diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/index.ts new file mode 100644 index 0000000..3ca7d4f --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/index.ts @@ -0,0 +1 @@ +export * from './structure-graph-renderer.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/shared/index.ts b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/shared/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/structure-graph-renderer.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/structure-graph-renderer.component.css new file mode 100644 index 0000000..9079e10 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/structure-graph-renderer.component.css @@ -0,0 +1,71 @@ +#doc_structureGraph.loading { + visibility: hidden; +} + +#doc_structureGraph .node circle { + cursor: pointer; + stroke: #3182bd; + stroke-width: 1.5px; +} + +#doc_structureGraph .node text { + /*display: none;*/ + font: 10px sans-serif; + pointer-events: none; + text-anchor: left; + left: 10px; +} + +#doc_structureGraph .node:hover text { + display: block; +} + +line.link { + fill: none; + stroke: #9ecae1; + stroke-width: 1.5px; +} + +#doc_structureGraph .node.entityTypePackage circle { + fill: #666; +} + +/*#doc_structureGraph .node.entityTypePackage.collapsed circle { + fill: #f00; +} + +#doc_structureGraph .node.entityTypePackage.expanded circle { + fill: #0f0; +}*/ + +#doc_structureGraph .node.entityTypeClass circle { + fill: #59afe1; +} + +#doc_structureGraph .node.entityTypeInterface circle { + fill: #8eb021; + font-family: serif; +} + +#doc_structureGraph .node.entityTypeAnnotation circle { + fill: #f6c342; +} + +#doc_structureGraph .node.entityTypeException circle { + fill: #d04437; +} + +#doc_structureGraph .node.entityTypeEnum circle { + fill: #84bbc6; +} + +#doc_structureGraph .node text.type { + text-anchor: middle; + fill: #fff; + font-weight: 600; +} + +#doc_structureGraphTakesLongerThanUsual { + width: 300px; + margin: 20px auto; +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/structure-graph-renderer.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/structure-graph-renderer.component.html new file mode 100644 index 0000000..6e9a16d --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/structure-graph-renderer.component.html @@ -0,0 +1,16 @@ +
    +

    + An error occurred +

    +
    +
    +
    +

    + It takes longer than usual... +

    +

    The structure diagram can be much less efficient for large projects.

    +
    +
    + + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/structure-graph-renderer.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/structure-graph-renderer.component.ts new file mode 100644 index 0000000..4794e15 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/shared/structure-graph-renderer/structure-graph-renderer.component.ts @@ -0,0 +1,230 @@ +import {Component, OnInit, OnChanges, SimpleChanges, Input, ViewEncapsulation} from '@angular/core'; +import {Router} from '@angular/router'; +import {ParamsService} from '../../../../params.service'; +import * as d3 from 'd3'; +import {CapitalizePipe} from '../../../../capitalize.pipe'; + + +@Component({ + moduleId: module.id, + selector: 'app-structure-graph-renderer', + templateUrl: 'structure-graph-renderer.component.html', + styleUrls: ['structure-graph-renderer.component.css'], + encapsulation: ViewEncapsulation.None +}) +export class StructureGraphRendererComponent implements OnInit, OnChanges { + + @Input('data') private data: any; + + isLoading = true; + isError = false; + isLoadingTakesLonger = false; + private svg: any; + private force: any; + private link: any; + private node: any; + private alphaMax = 1; + private alpha = 1; + private alphaMin = .3; + + + constructor(private router: Router, private paramsService: ParamsService) { + + } + + ngOnInit() { + this.init(); + } + + ngOnChanges(changes: SimpleChanges): void { + if (changes['data']) { + if (this.data) { + this.generate(); + } + } + } + + + private init() { + const margin: any = {top: -5, right: -5, bottom: -5, left: -5}; + const width: any = window.innerWidth - margin.left - margin.right; + const height: any = window.innerHeight - margin.top - margin.bottom; + this.svg = d3.select('#doc_structureGraph').append('svg') + .attr('width', width + margin.left + margin.right) + .attr('height', height + margin.top + margin.bottom); + const g: any = this.svg.append('g'); + const zoom: any = d3.behavior.zoom().on('zoom', () => { + let event = d3.event as any; + g.attr('transform', 'translate(' + event.translate + ')' + 'scale(' + event.scale + ')'); + }); + this.svg.call(zoom); + this.link = g.selectAll('.link'); + this.node = g.selectAll('.node').attr('cx', (d: any) => { + return d.x; + }) + .attr('cy', (d: any) => { + return d.y; + }); + this.force = d3.layout.force() + .linkDistance(50) + .charge(-1200) + .gravity(0.5) + .alpha(100) + .size([width + margin.left + margin.right, height + margin.top + margin.bottom]) + .on('tick', () => this.tick()); + } + + public tick() { + this.link + .attr('x1', (d: any) => { + return d.source.x; + }) + .attr('y1', (d: any) => { + return d.source.y; + }) + .attr('x2', (d: any) => { + return d.target.x; + }) + .attr('y2', (d: any) => { + return d.target.y; + }); + + this.node + .attr('transform', (d: any) => { + return 'translate(' + d.x + ',' + d.y + ')'; + }); + + } + + private generate() { + + const rootLevel: number = this.data.fullName.split('.').length - 1; + let nodes: any = this.flatten(this.data); + let links: any = d3.layout.tree().links(nodes); + this.force.nodes(nodes).links(links); + this.updateLinks(links); + this.updateNodes(nodes, rootLevel); + setTimeout(this.draw(), 0); + setTimeout(() => { + if (this.isLoading) { + this.isLoadingTakesLonger = true; + } + }, 5000); + } + + private updateLinks(links: any) { + this.link = this.link.data(links, (d: any) => { + return d.target.id; + }); + this.link.exit().remove(); + this.link.enter().insert('line', '.node') + .attr('class', 'link'); + } + + + private updateNodes(nodes: any, rootLevel: number) { + this.node = this.node.data(nodes, (d: any) => { + return d.id; + }); + + this.node.exit().remove(); + let nodeEnter: any = this.node.enter().append('g') + .attr('class', (d: any) => { + return this.cssClass(d); + }) + .classed('node', true) + .on('click', null) + .on('click', (d: any) => this.click(d)); + + nodeEnter.append('circle') + .attr('r', (d: any) => { + return 1 / (d.fullName.split('.').length - rootLevel) * 20 || 7; + }); + + nodeEnter.append('text') + .classed('type', true) + .attr('dy', '0.3em') + .text((d: any) => { + return d.type ? d.type.charAt(0).toUpperCase() : ''; + }); + + nodeEnter.append('text') + .attr('dy', '0.35em') + .attr('dx', (d: any) => { + return (1 / (d.fullName.split('.').length - rootLevel) * 20 * 0.1 + 0.35) + 'em'; + }) + .text((d: any) => { + return d.name; + }); + } + + private draw() { + this.force.start(); + this.force.alpha(this.alpha); + this.force.tick(); + this.alpha = this.force.alpha(); + this.force.stop(); + + if (this.alpha >= this.alphaMin) { + AJS.progressBars.update('#doc_structureGraphProgressbar', 1 - (this.alpha - this.alphaMin) / (this.alphaMax - this.alphaMin)); + setTimeout(this.draw(), 0); + } else { + setTimeout(() => { + AJS.progressBars.update('#doc_structureGraphProgressbar', 1); + this.isLoading = false; + this.isLoadingTakesLonger = false; + setTimeout(0); + }, 10); + } + } + + + private flatten(root: any) { + let flatNodes: any = []; + let i = 0; + + function recurse(node: any) { + if (!node.id) { + node.id = ++i; + } + if (node.children) { + node.children.forEach((childNode: any) => recurse(childNode)); + } + + flatNodes.push(node); + } + + recurse(root); + return flatNodes; + } + + + private cssClass(d: any) { + let cl: any = 'entityType' + new CapitalizePipe().transform(d.type); + if (d._children) { + cl += ' collapsed'; + } else if (d.children) { + cl += ' expanded'; + } + return cl; + } + + + private click(d: any) { + const evt: any = d3.event; + if (!evt.defaultPrevented) { + if (typeof d.type === 'undefined' || d.type === 'package') { + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + this.generate(); + } else { + this.router.navigate(['/' + this.paramsService.getSourceUnitId() + '/omnidoc/' + d.fullName]); + } + } + } +} diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/structure-graph.component.css b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/structure-graph.component.css new file mode 100644 index 0000000..e69de29 diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/structure-graph.component.html b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/structure-graph.component.html new file mode 100644 index 0000000..0b9c08d --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/structure-graph.component.html @@ -0,0 +1 @@ + diff --git a/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/structure-graph.component.ts b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/structure-graph.component.ts new file mode 100644 index 0000000..f051f0c --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/documentation/structure-graph/structure-graph.component.ts @@ -0,0 +1,32 @@ +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {OmniDocService} from '../omni-doc/shared/omnidoc.service'; +import {Observable, Subject} from 'rxjs/Rx'; + +@Component({ + moduleId: module.id, + selector: 'app-structure-graph', + templateUrl: 'structure-graph.component.html', + styleUrls: ['structure-graph.component.css'] +}) +export class StructureGraphComponent implements OnInit { + + private onInit = new Subject(); + nodes: Array; + + constructor(private route: ActivatedRoute, private omnidocService: OmniDocService) { + Observable.zip(this.route.parent.params, this.onInit).subscribe(() => { + this.getNodes(); + }); + } + + ngOnInit() { + this.onInit.next(); + } + + getNodes() { + this.omnidocService.getSingleRootTree().subscribe(x => { + this.nodes = x; + }); + } +} diff --git a/confluence-plugin/src/main/typescript/src/app/environment.ts b/confluence-plugin/src/main/typescript/src/app/environment.ts new file mode 100644 index 0000000..79ee96f --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/environment.ts @@ -0,0 +1,7 @@ +// The file for the current environment will overwrite this one during build +// Different environments can be found in config/environment.{dev|prod}.ts +// The build system defaults to the dev environment + +export const environment = { + production: false +}; diff --git a/confluence-plugin/src/main/typescript/src/app/index.ts b/confluence-plugin/src/main/typescript/src/app/index.ts new file mode 100644 index 0000000..30c9dfb --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/index.ts @@ -0,0 +1,2 @@ +export * from './environment'; +export * from './app.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/main/index.ts b/confluence-plugin/src/main/typescript/src/app/main/index.ts new file mode 100644 index 0000000..99eb045 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/main/index.ts @@ -0,0 +1 @@ +export * from './main.component'; diff --git a/confluence-plugin/src/main/typescript/src/app/main/main.component.css b/confluence-plugin/src/main/typescript/src/app/main/main.component.css new file mode 100644 index 0000000..1ccce31 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/main/main.component.css @@ -0,0 +1,3 @@ +.right { + float: right; +} diff --git a/confluence-plugin/src/main/typescript/src/app/main/main.component.html b/confluence-plugin/src/main/typescript/src/app/main/main.component.html new file mode 100644 index 0000000..442025f --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/main/main.component.html @@ -0,0 +1,14 @@ +
    + + +
    + + diff --git a/confluence-plugin/src/main/typescript/src/app/main/main.component.ts b/confluence-plugin/src/main/typescript/src/app/main/main.component.ts new file mode 100644 index 0000000..5f1c4cb --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/main/main.component.ts @@ -0,0 +1,94 @@ +import {Component, OnInit, ViewChild, ElementRef} from '@angular/core'; +import {ActivatedRoute, Router, NavigationEnd} from '@angular/router'; +import {Observable} from 'rxjs/Rx'; +import {UrlService} from '../url.service'; +import {ParamsService} from '../params.service'; +import {SourceUnit} from '../source-unit'; +import {CustomHttp} from '../custom-http'; + +declare var AJS: any; + +@Component({ + moduleId: module.id, + selector: 'app-main', + templateUrl: 'main.component.html', + styleUrls: ['main.component.css'] +}) +export class MainComponent implements OnInit { + + private availableSourceUnits: SourceUnit[]; + private currentSourceUnitId: number; + private docTypes: any[]; + private currentDocType: string; + + @ViewChild('sourceUnitSelect') + private sourceUnitSelect: ElementRef; + + @ViewChild('docTypeSelect') + private docTypeSelect: ElementRef; + + constructor(private route: ActivatedRoute, private router: Router, private http: CustomHttp, private urlService: UrlService, private paramsService: ParamsService) { + } + + ngOnInit() { + this.router.config.forEach((obj: any) => { + if (obj.containsDocTypes) { + this.docTypes = obj.children.map((x: any) => { + return { + name: x.displayName, + docType: x.path, + macroParam: x.macroParam + }; + }).filter((x: any) => { + let param = this.paramsService.getParam(x.macroParam); + return param !== "false" && param; + }); + } + }); + + this.router.events.subscribe((event) => { + if (event instanceof NavigationEnd) { + this.updateCurrentDocType(); + } + }); + + let request = this.http.get(this.urlService.getBundleRestUrl()); + request.subscribe((response) => { + this.availableSourceUnits = response.json() + .sourceUnits.map((x: any) => SourceUnit.fromObject(x)); + }); + this.route.params.subscribe((params: any) => { + if (params.sourceUnitId) { + this.currentSourceUnitId = +params.sourceUnitId; + this.paramsService.setSourceUnitId(+params.sourceUnitId); + } + }); + + Observable.zip(request, this.http.get(this.urlService.getBundleRestUrl()), this.route.params).subscribe(() => { + if (!this.currentSourceUnitId) { + this.router.navigate(['/' + this.availableSourceUnits[0].id + '/' + this.docTypes[0].docType]); + } else { + this.updateCurrentDocType(); + + AJS.$(this.sourceUnitSelect.nativeElement).auiSelect2({ + minimumResultsForSearch: 8 + }).change((event: any) => { + this.router.navigate(['/' + event.val + '/' + this.currentDocType]); + }); + + AJS.$(this.docTypeSelect.nativeElement).auiSelect2({ + minimumResultsForSearch: Infinity + }).change((event: any) => { + this.router.navigate(['/' + this.currentSourceUnitId + '/' + event.val]); + }); + } + }); + } + + private updateCurrentDocType() { + let matches = this.router.routerState.snapshot.url.match('/[^/]+/([^/]+)'); + if (matches) { + this.currentDocType = matches[1]; + } + } +} diff --git a/confluence-plugin/src/main/typescript/src/app/notify.service.ts b/confluence-plugin/src/main/typescript/src/app/notify.service.ts new file mode 100644 index 0000000..623b8a7 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/notify.service.ts @@ -0,0 +1,31 @@ +import {Injectable} from '@angular/core'; + + +@Injectable() +export class NotifyService { + + error(title: string, message: string) { + AJS.flag({ + type: 'error', + title: title, + body: '

    ' + message + '

    ' + }); + } + + info(title: string, message: string) { + AJS.flag({ + type: 'info', + title: title, + body: '

    ' + message + '

    ' + }); + } + + success(title: string, message: string) { + AJS.flag({ + type: 'success', + title: title, + body: '

    ' + message + '

    ' + }); + } + +} diff --git a/confluence-plugin/src/main/typescript/src/app/params.service.ts b/confluence-plugin/src/main/typescript/src/app/params.service.ts new file mode 100644 index 0000000..f922732 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/params.service.ts @@ -0,0 +1,61 @@ +import {Injectable} from '@angular/core'; +import {Subject, Observable} from 'rxjs/Rx'; + +declare var AJS: any; + +@Injectable() +export class ParamsService { + + private params: any = { + bundle: 1, + macroOwner: '2c9682714db22c7c014db22f51970002', + classDiagram: true, + structureGraph: true, + markup: true, + omniDoc: true + }; + + private paramsChanged = new Subject(); + + constructor() { + if (this.isInConfluence()) { + this.params = JSON.parse(AJS.params.macroParamsJson); + } + } + + public getParam(key: string): any { + return this.params[key]; + } + + public setParam(key: string, value: any): ParamsService { + this.params[key] = value; + this.paramsChanged.next({key: key, value: value}); + return this; + } + + public getBundleId(): number { + return +this.params['bundle']; + } + + public onParamsChange(): Observable { + return this.paramsChanged; + } + + public setSourceUnitId(id: number) { + this.setParam('sourceUnitId', id); + return this; + } + + public getSourceUnitId(): number { + return this.getParam('sourceUnitId'); + } + + public isInConfluence(): boolean { + return AJS && AJS.Data; + } +} + +export interface ParamsEvent { + key: string; + value: any; +} diff --git a/confluence-plugin/src/main/typescript/src/app/replace-char.pipe.ts b/confluence-plugin/src/main/typescript/src/app/replace-char.pipe.ts new file mode 100644 index 0000000..ee7c0f0 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/replace-char.pipe.ts @@ -0,0 +1,16 @@ +import {PipeTransform, Pipe} from '@angular/core'; + +// Check if the value is supported for the pipe +export function isString(txt: any): boolean { + return typeof txt === 'string'; +} + + +@Pipe({ + name: 'replace' +}) +export class ReplaceCharPipe implements PipeTransform { + transform(value: string, what: string, withWhat: string): any { + return value.split(what).join(withWhat); + } +} diff --git a/confluence-plugin/src/main/typescript/src/app/shared/index.ts b/confluence-plugin/src/main/typescript/src/app/shared/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/confluence-plugin/src/main/typescript/src/app/source-unit.ts b/confluence-plugin/src/main/typescript/src/app/source-unit.ts new file mode 100644 index 0000000..d873ca6 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/source-unit.ts @@ -0,0 +1,10 @@ +export class SourceUnit { + + static fromObject(obj: any): SourceUnit { + return new SourceUnit(obj.id, obj.sourceNodeIdentifier.unitIdentifier); + } + + constructor(public id: number, public name: String) { + } + +} diff --git a/confluence-plugin/src/main/typescript/src/app/url.service.ts b/confluence-plugin/src/main/typescript/src/app/url.service.ts new file mode 100644 index 0000000..d8df631 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/app/url.service.ts @@ -0,0 +1,53 @@ +import {Injectable, Inject} from '@angular/core'; +import {ParamsService} from './params.service'; + +declare var AJS: any; + +@Injectable() +export class UrlService { + + constructor(@Inject(ParamsService) private paramsService: ParamsService) { + } + + public getBundleRestUrl(...args: (string|number)[]) { + return this.getBaseUrl() + '/bundles/' + this.paramsService.getBundleId() + this.parseArgs(args); + } + + public getSourceUnitRestUrl(...args: (string|number)[]) { + return this.getBaseUrl() + '/documentation/sourceUnit/' + this.paramsService.getSourceUnitId() + '/documentationType' + this.parseArgs(args); + } + + public getRestUrl(...args: (string|number)[]): string { + return this.getBaseUrl() + this.parseArgs(args); + } + + public getBaseUrl(): string { + if (AJS && AJS.Data) { + return AJS.Data.get('base-url') + '/rest/doc/1.0/transformer'; + } else { + return 'http://localhost:8080/transformer/rest'; + } + } + + public getResourcesUrl(path: string): string { + if (!path) { + path = ''; + } + if (AJS && AJS.Data) { + return AJS.Data.get('base-url') + '/rest/doc/1.0/frontend/' + path; + } else { + return path; + } + } + + private parseArgs(args: (string|number)[]) { + return ((args && args.length) ? ('/' + args.map((arg) => { + if (arg) { + return encodeURI(arg.toString()); + } else { + return ''; + } + }).join('/')) : ''); + } + +} diff --git a/confluence-plugin/src/main/typescript/src/favicon.ico b/confluence-plugin/src/main/typescript/src/favicon.ico new file mode 100644 index 0000000..8081c7c Binary files /dev/null and b/confluence-plugin/src/main/typescript/src/favicon.ico differ diff --git a/confluence-plugin/src/main/typescript/src/images/doc_logo.png b/confluence-plugin/src/main/typescript/src/images/doc_logo.png new file mode 100644 index 0000000..af77f47 Binary files /dev/null and b/confluence-plugin/src/main/typescript/src/images/doc_logo.png differ diff --git a/confluence-plugin/src/main/typescript/src/index.html b/confluence-plugin/src/main/typescript/src/index.html new file mode 100644 index 0000000..326cf4b --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/index.html @@ -0,0 +1,49 @@ + + + + + Typescript + + + + + + + + {{#unless environment.production}} + + {{/unless}} + + + + + + +
    + Loading... + + {{#each scripts.polyfills}} + + {{/each}} + + +
    + + + diff --git a/confluence-plugin/src/main/typescript/src/lib/d3.min.js b/confluence-plugin/src/main/typescript/src/lib/d3.min.js new file mode 100644 index 0000000..bd8b134 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/lib/d3.min.js @@ -0,0 +1,5 @@ +!function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:NaN}function r(n){return null===n?NaN:+n}function u(n){return!isNaN(n)}function i(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function a(n){return n.length}function o(n){for(var t=1;n*t%1;)t*=10;return t}function l(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function c(){this._=Object.create(null)}function s(n){return(n+="")===xa||n[0]===ba?ba+n:n}function f(n){return(n+="")[0]===ba?n.slice(1):n}function h(n){return s(n)in this._}function g(n){return(n=s(n))in this._&&delete this._[n]}function p(){var n=[];for(var t in this._)n.push(f(t));return n}function v(){var n=0;for(var t in this._)++n;return n}function d(){for(var n in this._)return!1;return!0}function m(){this._=Object.create(null)}function y(n){return n}function M(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function x(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=_a.length;r>e;++e){var u=_a[e]+t;if(u in n)return u}}function b(){}function _(){}function w(n){function t(){for(var t,r=e,u=-1,i=r.length;++ue;e++)for(var u,i=n[e],a=0,o=i.length;o>a;a++)(u=i[a])&&t(u,a,e);return n}function Z(n){return Sa(n,za),n}function V(n){var t,e;return function(r,u,i){var a,o=n[i].update,l=o.length;for(i!=e&&(e=i,t=0),u>=t&&(t=u+1);!(a=o[t])&&++t0&&(n=n.slice(0,o));var c=La.get(n);return c&&(n=c,l=B),o?t?u:r:t?b:i}function $(n,t){return function(e){var r=oa.event;oa.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{oa.event=r}}}function B(n,t){var e=$(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function W(e){var r=".dragsuppress-"+ ++Ta,u="click"+r,i=oa.select(t(e)).on("touchmove"+r,S).on("dragstart"+r,S).on("selectstart"+r,S);if(null==qa&&(qa="onselectstart"in e?!1:x(e.style,"userSelect")),qa){var a=n(e).style,o=a[qa];a[qa]="none"}return function(n){if(i.on(r,null),qa&&(a[qa]=o),n){var t=function(){i.on(u,null)};i.on(u,function(){S(),t()},!0),setTimeout(t,0)}}}function J(n,e){e.changedTouches&&(e=e.changedTouches[0]);var r=n.ownerSVGElement||n;if(r.createSVGPoint){var u=r.createSVGPoint();if(0>Ra){var i=t(n);if(i.scrollX||i.scrollY){r=oa.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var a=r[0][0].getScreenCTM();Ra=!(a.f||a.e),r.remove()}}return Ra?(u.x=e.pageX,u.y=e.pageY):(u.x=e.clientX,u.y=e.clientY),u=u.matrixTransform(n.getScreenCTM().inverse()),[u.x,u.y]}var o=n.getBoundingClientRect();return[e.clientX-o.left-n.clientLeft,e.clientY-o.top-n.clientTop]}function G(){return oa.event.changedTouches[0].identifier}function K(n){return n>0?1:0>n?-1:0}function Q(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function nn(n){return n>1?0:-1>n?ja:Math.acos(n)}function tn(n){return n>1?Ha:-1>n?-Ha:Math.asin(n)}function en(n){return((n=Math.exp(n))-1/n)/2}function rn(n){return((n=Math.exp(n))+1/n)/2}function un(n){return((n=Math.exp(2*n))-1)/(n+1)}function an(n){return(n=Math.sin(n/2))*n}function on(){}function ln(n,t,e){return this instanceof ln?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof ln?new ln(n.h,n.s,n.l):_n(""+n,wn,ln):new ln(n,t,e)}function cn(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?i+(a-i)*n/60:180>n?a:240>n?i+(a-i)*(240-n)/60:i}function u(n){return Math.round(255*r(n))}var i,a;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,a=.5>=e?e*(1+t):e+t-e*t,i=2*e-a,new yn(u(n+120),u(n),u(n-120))}function sn(n,t,e){return this instanceof sn?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof sn?new sn(n.h,n.c,n.l):n instanceof hn?pn(n.l,n.a,n.b):pn((n=Sn((n=oa.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new sn(n,t,e)}function fn(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new hn(e,Math.cos(n*=Oa)*t,Math.sin(n)*t)}function hn(n,t,e){return this instanceof hn?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof hn?new hn(n.l,n.a,n.b):n instanceof sn?fn(n.h,n.c,n.l):Sn((n=yn(n)).r,n.g,n.b):new hn(n,t,e)}function gn(n,t,e){var r=(n+16)/116,u=r+t/500,i=r-e/200;return u=vn(u)*Ka,r=vn(r)*Qa,i=vn(i)*no,new yn(mn(3.2404542*u-1.5371385*r-.4985314*i),mn(-.969266*u+1.8760108*r+.041556*i),mn(.0556434*u-.2040259*r+1.0572252*i))}function pn(n,t,e){return n>0?new sn(Math.atan2(e,t)*Ia,Math.sqrt(t*t+e*e),n):new sn(NaN,NaN,n)}function vn(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function dn(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function mn(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function yn(n,t,e){return this instanceof yn?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof yn?new yn(n.r,n.g,n.b):_n(""+n,yn,cn):new yn(n,t,e)}function Mn(n){return new yn(n>>16,n>>8&255,255&n)}function xn(n){return Mn(n)+""}function bn(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function _n(n,t,e){var r,u,i,a=0,o=0,l=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(u=r[2].split(","),r[1]){case"hsl":return e(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(Nn(u[0]),Nn(u[1]),Nn(u[2]))}return(i=ro.get(n))?t(i.r,i.g,i.b):(null==n||"#"!==n.charAt(0)||isNaN(i=parseInt(n.slice(1),16))||(4===n.length?(a=(3840&i)>>4,a=a>>4|a,o=240&i,o=o>>4|o,l=15&i,l=l<<4|l):7===n.length&&(a=(16711680&i)>>16,o=(65280&i)>>8,l=255&i)),t(a,o,l))}function wn(n,t,e){var r,u,i=Math.min(n/=255,t/=255,e/=255),a=Math.max(n,t,e),o=a-i,l=(a+i)/2;return o?(u=.5>l?o/(a+i):o/(2-a-i),r=n==a?(t-e)/o+(e>t?6:0):t==a?(e-n)/o+2:(n-t)/o+4,r*=60):(r=NaN,u=l>0&&1>l?0:r),new ln(r,u,l)}function Sn(n,t,e){n=kn(n),t=kn(t),e=kn(e);var r=dn((.4124564*n+.3575761*t+.1804375*e)/Ka),u=dn((.2126729*n+.7151522*t+.072175*e)/Qa),i=dn((.0193339*n+.119192*t+.9503041*e)/no);return hn(116*u-16,500*(r-u),200*(u-i))}function kn(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function Nn(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function En(n){return"function"==typeof n?n:function(){return n}}function An(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Cn(t,e,n,r)}}function Cn(n,t,e,r){function u(){var n,t=l.status;if(!t&&Ln(l)||t>=200&&300>t||304===t){try{n=e.call(i,l)}catch(r){return void a.error.call(i,r)}a.load.call(i,n)}else a.error.call(i,l)}var i={},a=oa.dispatch("beforesend","progress","load","error"),o={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(n)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=u:l.onreadystatechange=function(){l.readyState>3&&u()},l.onprogress=function(n){var t=oa.event;oa.event=n;try{a.progress.call(i,l)}finally{oa.event=t}},i.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?o[n]:(null==t?delete o[n]:o[n]=t+"",i)},i.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",i):t},i.responseType=function(n){return arguments.length?(c=n,i):c},i.response=function(n){return e=n,i},["get","post"].forEach(function(n){i[n]=function(){return i.send.apply(i,[n].concat(ca(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),l.open(e,n,!0),null==t||"accept"in o||(o.accept=t+",*/*"),l.setRequestHeader)for(var s in o)l.setRequestHeader(s,o[s]);return null!=t&&l.overrideMimeType&&l.overrideMimeType(t),null!=c&&(l.responseType=c),null!=u&&i.on("error",u).on("load",function(n){u(null,n)}),a.beforesend.call(i,l),l.send(null==r?null:r),i},i.abort=function(){return l.abort(),i},oa.rebind(i,a,"on"),null==r?i:i.get(zn(r))}function zn(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function Ln(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function qn(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var u=e+t,i={c:n,t:u,n:null};return io?io.n=i:uo=i,io=i,ao||(oo=clearTimeout(oo),ao=1,lo(Tn)),i}function Tn(){var n=Rn(),t=Dn()-n;t>24?(isFinite(t)&&(clearTimeout(oo),oo=setTimeout(Tn,t)),ao=0):(ao=1,lo(Tn))}function Rn(){for(var n=Date.now(),t=uo;t;)n>=t.t&&t.c(n-t.t)&&(t.c=null),t=t.n;return n}function Dn(){for(var n,t=uo,e=1/0;t;)t.c?(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function Un(n){var t=n.decimal,e=n.thousands,r=n.grouping,u=n.currency,i=r&&e?function(n,t){for(var u=n.length,i=[],a=0,o=r[0],l=0;u>0&&o>0&&(l+o+1>t&&(o=Math.max(1,t-l)),i.push(n.substring(u-=o,u+o)),!((l+=o+1)>t));)o=r[a=(a+1)%r.length];return i.reverse().join(e)}:y;return function(n){var e=so.exec(n),r=e[1]||" ",a=e[2]||">",o=e[3]||"-",l=e[4]||"",c=e[5],s=+e[6],f=e[7],h=e[8],g=e[9],p=1,v="",d="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(c||"0"===r&&"="===a)&&(c=r="0",a="="),g){case"n":f=!0,g="g";break;case"%":p=100,d="%",g="f";break;case"p":p=100,d="%",g="r";break;case"b":case"o":case"x":case"X":"#"===l&&(v="0"+g.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,g="r"}"$"===l&&(v=u[0],d=u[1]),"r"!=g||h||(g="g"),null!=h&&("g"==g?h=Math.max(1,Math.min(21,h)):("e"==g||"f"==g)&&(h=Math.max(0,Math.min(20,h)))),g=fo.get(g)||Fn;var M=c&&f;return function(n){var e=d;if(m&&n%1)return"";var u=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===o?"":o;if(0>p){var l=oa.formatPrefix(n,h);n=l.scale(n),e=l.symbol+d}else n*=p;n=g(n,h);var x,b,_=n.lastIndexOf(".");if(0>_){var w=y?n.lastIndexOf("e"):-1;0>w?(x=n,b=""):(x=n.substring(0,w),b=n.substring(w))}else x=n.substring(0,_),b=t+n.substring(_+1);!c&&f&&(x=i(x,1/0));var S=v.length+x.length+b.length+(M?0:u.length),k=s>S?new Array(S=s-S+1).join(r):"";return M&&(x=i(k+x,k.length?s-b.length:1/0)),u+=v,n=x+b,("<"===a?u+n+k:">"===a?k+u+n:"^"===a?k.substring(0,S>>=1)+u+n+k.substring(S):u+(M?n:k+n))+e}}}function Fn(n){return n+""}function Hn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function On(n,t,e){function r(t){var e=n(t),r=i(e,1);return r-t>t-e?e:r}function u(e){return t(e=n(new go(e-1)),1),e}function i(n,e){return t(n=new go(+n),e),n}function a(n,r,i){var a=u(n),o=[];if(i>1)for(;r>a;)e(a)%i||o.push(new Date(+a)),t(a,1);else for(;r>a;)o.push(new Date(+a)),t(a,1);return o}function o(n,t,e){try{go=Hn;var r=new Hn;return r._=n,a(r,t,e)}finally{go=Date}}n.floor=n,n.round=r,n.ceil=u,n.offset=i,n.range=a;var l=n.utc=In(n);return l.floor=l,l.round=In(r),l.ceil=In(u),l.offset=In(i),l.range=o,n}function In(n){return function(t,e){try{go=Hn;var r=new Hn;return r._=t,n(r,e)._}finally{go=Date}}}function Yn(n){function t(n){function t(t){for(var e,u,i,a=[],o=-1,l=0;++oo;){if(r>=c)return-1;if(u=t.charCodeAt(o++),37===u){if(a=t.charAt(o++),i=C[a in vo?t.charAt(o++):a],!i||(r=i(n,e,r))<0)return-1}else if(u!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){_.lastIndex=0;var r=_.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){x.lastIndex=0;var r=x.exec(t.slice(e));return r?(n.w=b.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){N.lastIndex=0;var r=N.exec(t.slice(e));return r?(n.m=E.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,e){S.lastIndex=0;var r=S.exec(t.slice(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,r){return e(n,A.c.toString(),t,r)}function l(n,t,r){return e(n,A.x.toString(),t,r)}function c(n,t,r){return e(n,A.X.toString(),t,r)}function s(n,t,e){var r=M.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var f=n.dateTime,h=n.date,g=n.time,p=n.periods,v=n.days,d=n.shortDays,m=n.months,y=n.shortMonths;t.utc=function(n){function e(n){try{go=Hn;var t=new go;return t._=n,r(t)}finally{go=Date}}var r=t(n);return e.parse=function(n){try{go=Hn;var t=r.parse(n);return t&&t._}finally{go=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ct;var M=oa.map(),x=Vn(v),b=Xn(v),_=Vn(d),w=Xn(d),S=Vn(m),k=Xn(m),N=Vn(y),E=Xn(y);p.forEach(function(n,t){M.set(n.toLowerCase(),t)});var A={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return y[n.getMonth()]},B:function(n){return m[n.getMonth()]},c:t(f),d:function(n,t){return Zn(n.getDate(),t,2)},e:function(n,t){return Zn(n.getDate(),t,2)},H:function(n,t){return Zn(n.getHours(),t,2)},I:function(n,t){return Zn(n.getHours()%12||12,t,2)},j:function(n,t){return Zn(1+ho.dayOfYear(n),t,3)},L:function(n,t){return Zn(n.getMilliseconds(),t,3)},m:function(n,t){return Zn(n.getMonth()+1,t,2)},M:function(n,t){return Zn(n.getMinutes(),t,2)},p:function(n){return p[+(n.getHours()>=12)]},S:function(n,t){return Zn(n.getSeconds(),t,2)},U:function(n,t){return Zn(ho.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Zn(ho.mondayOfYear(n),t,2)},x:t(h),X:t(g),y:function(n,t){return Zn(n.getFullYear()%100,t,2)},Y:function(n,t){return Zn(n.getFullYear()%1e4,t,4)},Z:ot,"%":function(){return"%"}},C={a:r,A:u,b:i,B:a,c:o,d:tt,e:tt,H:rt,I:rt,j:et,L:at,m:nt,M:ut,p:s,S:it,U:Bn,w:$n,W:Wn,x:l,X:c,y:Gn,Y:Jn,Z:Kn,"%":lt};return t}function Zn(n,t,e){var r=0>n?"-":"",u=(r?-n:n)+"",i=u.length;return r+(e>i?new Array(e-i+1).join(t)+u:u)}function Vn(n){return new RegExp("^(?:"+n.map(oa.requote).join("|")+")","i")}function Xn(n){for(var t=new c,e=-1,r=n.length;++e68?1900:2e3)}function nt(n,t,e){mo.lastIndex=0;var r=mo.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function tt(n,t,e){mo.lastIndex=0;var r=mo.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function et(n,t,e){mo.lastIndex=0;var r=mo.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function rt(n,t,e){mo.lastIndex=0;var r=mo.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function ut(n,t,e){mo.lastIndex=0;var r=mo.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function it(n,t,e){mo.lastIndex=0;var r=mo.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function at(n,t,e){mo.lastIndex=0;var r=mo.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function ot(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=Ma(t)/60|0,u=Ma(t)%60;return e+Zn(r,"0",2)+Zn(u,"0",2)}function lt(n,t,e){yo.lastIndex=0;var r=yo.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ct(n){for(var t=n.length,e=-1;++e=0?1:-1,o=a*e,l=Math.cos(t),c=Math.sin(t),s=i*c,f=u*l+s*Math.cos(o),h=s*a*Math.sin(o);So.add(Math.atan2(h,f)),r=n,u=l,i=c}var t,e,r,u,i;ko.point=function(a,o){ko.point=n,r=(t=a)*Oa,u=Math.cos(o=(e=o)*Oa/2+ja/4),i=Math.sin(o)},ko.lineEnd=function(){n(t,e)}}function dt(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function mt(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function yt(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function Mt(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function xt(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function bt(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function _t(n){return[Math.atan2(n[1],n[0]),tn(n[2])]}function wt(n,t){return Ma(n[0]-t[0])o;++o)u.point((e=n[o])[0],e[1]);return void u.lineEnd()}var l=new Tt(e,n,null,!0),c=new Tt(e,null,l,!1);l.o=c,i.push(l),a.push(c),l=new Tt(r,n,null,!1),c=new Tt(r,null,l,!0),l.o=c,i.push(l),a.push(c)}}),a.sort(t),qt(i),qt(a),i.length){for(var o=0,l=e,c=a.length;c>o;++o)a[o].e=l=!l;for(var s,f,h=i[0];;){for(var g=h,p=!0;g.v;)if((g=g.n)===h)return;s=g.z,u.lineStart();do{if(g.v=g.o.v=!0,g.e){if(p)for(var o=0,c=s.length;c>o;++o)u.point((f=s[o])[0],f[1]);else r(g.x,g.n.x,1,u);g=g.n}else{if(p){s=g.p.z;for(var o=s.length-1;o>=0;--o)u.point((f=s[o])[0],f[1])}else r(g.x,g.p.x,-1,u);g=g.p}g=g.o,s=g.z,p=!p}while(!g.v);u.lineEnd()}}}function qt(n){if(t=n.length){for(var t,e,r=0,u=n[0];++r0){for(b||(i.polygonStart(),b=!0),i.lineStart();++a1&&2&t&&e.push(e.pop().concat(e.shift())),g.push(e.filter(Dt))}var g,p,v,d=t(i),m=u.invert(r[0],r[1]),y={point:a,lineStart:l,lineEnd:c,polygonStart:function(){y.point=s,y.lineStart=f,y.lineEnd=h,g=[],p=[]},polygonEnd:function(){y.point=a,y.lineStart=l,y.lineEnd=c,g=oa.merge(g);var n=Ot(m,p);g.length?(b||(i.polygonStart(),b=!0),Lt(g,jt,n,e,i)):n&&(b||(i.polygonStart(),b=!0),i.lineStart(),e(null,null,1,i),i.lineEnd()),b&&(i.polygonEnd(),b=!1),g=p=null},sphere:function(){i.polygonStart(),i.lineStart(),e(null,null,1,i),i.lineEnd(),i.polygonEnd()}},M=Pt(),x=t(M),b=!1;return y}}function Dt(n){return n.length>1}function Pt(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:b,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function jt(n,t){return((n=n.x)[0]<0?n[1]-Ha-Da:Ha-n[1])-((t=t.x)[0]<0?t[1]-Ha-Da:Ha-t[1])}function Ut(n){var t,e=NaN,r=NaN,u=NaN;return{lineStart:function(){n.lineStart(),t=1},point:function(i,a){var o=i>0?ja:-ja,l=Ma(i-e);Ma(l-ja)0?Ha:-Ha),n.point(u,r),n.lineEnd(),n.lineStart(),n.point(o,r),n.point(i,r),t=0):u!==o&&l>=ja&&(Ma(e-u)Da?Math.atan((Math.sin(t)*(i=Math.cos(r))*Math.sin(e)-Math.sin(r)*(u=Math.cos(t))*Math.sin(n))/(u*i*a)):(t+r)/2}function Ht(n,t,e,r){var u;if(null==n)u=e*Ha,r.point(-ja,u),r.point(0,u),r.point(ja,u),r.point(ja,0),r.point(ja,-u),r.point(0,-u),r.point(-ja,-u),r.point(-ja,0),r.point(-ja,u);else if(Ma(n[0]-t[0])>Da){var i=n[0]o;++o){var c=t[o],s=c.length;if(s)for(var f=c[0],h=f[0],g=f[1]/2+ja/4,p=Math.sin(g),v=Math.cos(g),d=1;;){d===s&&(d=0),n=c[d];var m=n[0],y=n[1]/2+ja/4,M=Math.sin(y),x=Math.cos(y),b=m-h,_=b>=0?1:-1,w=_*b,S=w>ja,k=p*M;if(So.add(Math.atan2(k*_*Math.sin(w),v*x+k*Math.cos(w))),i+=S?b+_*Ua:b,S^h>=e^m>=e){var N=yt(dt(f),dt(n));bt(N);var E=yt(u,N);bt(E);var A=(S^b>=0?-1:1)*tn(E[2]);(r>A||r===A&&(N[0]||N[1]))&&(a+=S^b>=0?1:-1)}if(!d++)break;h=m,p=M,v=x,f=n}}return(-Da>i||Da>i&&0>So)^1&a}function It(n){function t(n,t){return Math.cos(n)*Math.cos(t)>i}function e(n){var e,i,l,c,s;return{lineStart:function(){c=l=!1,s=1},point:function(f,h){var g,p=[f,h],v=t(f,h),d=a?v?0:u(f,h):v?u(f+(0>f?ja:-ja),h):0;if(!e&&(c=l=v)&&n.lineStart(),v!==l&&(g=r(e,p),(wt(e,g)||wt(p,g))&&(p[0]+=Da,p[1]+=Da,v=t(p[0],p[1]))),v!==l)s=0,v?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(o&&e&&a^v){var m;d&i||!(m=r(p,e,!0))||(s=0,a?(n.lineStart(),n.point(m[0][0],m[0][1]),n.point(m[1][0],m[1][1]),n.lineEnd()):(n.point(m[1][0],m[1][1]),n.lineEnd(),n.lineStart(),n.point(m[0][0],m[0][1])))}!v||e&&wt(e,p)||n.point(p[0],p[1]),e=p,l=v,i=d},lineEnd:function(){l&&n.lineEnd(),e=null},clean:function(){return s|(c&&l)<<1}}}function r(n,t,e){var r=dt(n),u=dt(t),a=[1,0,0],o=yt(r,u),l=mt(o,o),c=o[0],s=l-c*c;if(!s)return!e&&n;var f=i*l/s,h=-i*c/s,g=yt(a,o),p=xt(a,f),v=xt(o,h);Mt(p,v);var d=g,m=mt(p,d),y=mt(d,d),M=m*m-y*(mt(p,p)-1);if(!(0>M)){var x=Math.sqrt(M),b=xt(d,(-m-x)/y);if(Mt(b,p),b=_t(b),!e)return b;var _,w=n[0],S=t[0],k=n[1],N=t[1];w>S&&(_=w,w=S,S=_);var E=S-w,A=Ma(E-ja)E;if(!A&&k>N&&(_=k,k=N,N=_),C?A?k+N>0^b[1]<(Ma(b[0]-w)ja^(w<=b[0]&&b[0]<=S)){var z=xt(d,(-m+x)/y);return Mt(z,p),[b,_t(z)]}}}function u(t,e){var r=a?n:ja-n,u=0;return-r>t?u|=1:t>r&&(u|=2),-r>e?u|=4:e>r&&(u|=8),u}var i=Math.cos(n),a=i>0,o=Ma(i)>Da,l=ve(n,6*Oa);return Rt(t,e,l,a?[0,-n]:[-ja,n-ja])}function Yt(n,t,e,r){return function(u){var i,a=u.a,o=u.b,l=a.x,c=a.y,s=o.x,f=o.y,h=0,g=1,p=s-l,v=f-c;if(i=n-l,p||!(i>0)){if(i/=p,0>p){if(h>i)return;g>i&&(g=i)}else if(p>0){if(i>g)return;i>h&&(h=i)}if(i=e-l,p||!(0>i)){if(i/=p,0>p){if(i>g)return;i>h&&(h=i)}else if(p>0){if(h>i)return;g>i&&(g=i)}if(i=t-c,v||!(i>0)){if(i/=v,0>v){if(h>i)return;g>i&&(g=i)}else if(v>0){if(i>g)return;i>h&&(h=i)}if(i=r-c,v||!(0>i)){if(i/=v,0>v){if(i>g)return;i>h&&(h=i)}else if(v>0){if(h>i)return;g>i&&(g=i)}return h>0&&(u.a={x:l+h*p,y:c+h*v}),1>g&&(u.b={x:l+g*p,y:c+g*v}),u}}}}}}function Zt(n,t,e,r){function u(r,u){return Ma(r[0]-n)0?0:3:Ma(r[0]-e)0?2:1:Ma(r[1]-t)0?1:0:u>0?3:2}function i(n,t){return a(n.x,t.x)}function a(n,t){var e=u(n,1),r=u(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(o){function l(n){for(var t=0,e=d.length,r=n[1],u=0;e>u;++u)for(var i,a=1,o=d[u],l=o.length,c=o[0];l>a;++a)i=o[a],c[1]<=r?i[1]>r&&Q(c,i,n)>0&&++t:i[1]<=r&&Q(c,i,n)<0&&--t,c=i;return 0!==t}function c(i,o,l,c){var s=0,f=0;if(null==i||(s=u(i,l))!==(f=u(o,l))||a(i,o)<0^l>0){do c.point(0===s||3===s?n:e,s>1?r:t);while((s=(s+l+4)%4)!==f)}else c.point(o[0],o[1])}function s(u,i){return u>=n&&e>=u&&i>=t&&r>=i}function f(n,t){s(n,t)&&o.point(n,t)}function h(){C.point=p,d&&d.push(m=[]),S=!0,w=!1,b=_=NaN}function g(){v&&(p(y,M),x&&w&&E.rejoin(),v.push(E.buffer())),C.point=f,w&&o.lineEnd()}function p(n,t){n=Math.max(-Fo,Math.min(Fo,n)),t=Math.max(-Fo,Math.min(Fo,t));var e=s(n,t);if(d&&m.push([n,t]),S)y=n,M=t,x=e,S=!1,e&&(o.lineStart(),o.point(n,t));else if(e&&w)o.point(n,t);else{var r={a:{x:b,y:_},b:{x:n,y:t}};A(r)?(w||(o.lineStart(),o.point(r.a.x,r.a.y)),o.point(r.b.x,r.b.y),e||o.lineEnd(),k=!1):e&&(o.lineStart(),o.point(n,t),k=!1)}b=n,_=t,w=e}var v,d,m,y,M,x,b,_,w,S,k,N=o,E=Pt(),A=Yt(n,t,e,r),C={point:f,lineStart:h,lineEnd:g,polygonStart:function(){o=E,v=[],d=[],k=!0},polygonEnd:function(){o=N,v=oa.merge(v);var t=l([n,r]),e=k&&t,u=v.length;(e||u)&&(o.polygonStart(),e&&(o.lineStart(),c(null,null,1,o),o.lineEnd()),u&&Lt(v,i,t,c,o),o.polygonEnd()),v=d=m=null}};return C}}function Vt(n){var t=0,e=ja/3,r=oe(n),u=r(t,e);return u.parallels=function(n){return arguments.length?r(t=n[0]*ja/180,e=n[1]*ja/180):[t/ja*180,e/ja*180]},u}function Xt(n,t){function e(n,t){var e=Math.sqrt(i-2*u*Math.sin(t))/u;return[e*Math.sin(n*=u),a-e*Math.cos(n)]}var r=Math.sin(n),u=(r+Math.sin(t))/2,i=1+r*(2*u-r),a=Math.sqrt(i)/u;return e.invert=function(n,t){var e=a-t;return[Math.atan2(n,e)/u,tn((i-(n*n+e*e)*u*u)/(2*u))]},e}function $t(){function n(n,t){Oo+=u*n-r*t,r=n,u=t}var t,e,r,u;Xo.point=function(i,a){Xo.point=n,t=r=i,e=u=a},Xo.lineEnd=function(){n(t,e)}}function Bt(n,t){Io>n&&(Io=n),n>Zo&&(Zo=n),Yo>t&&(Yo=t),t>Vo&&(Vo=t)}function Wt(){function n(n,t){a.push("M",n,",",t,i)}function t(n,t){a.push("M",n,",",t),o.point=e}function e(n,t){a.push("L",n,",",t)}function r(){o.point=n}function u(){a.push("Z")}var i=Jt(4.5),a=[],o={point:n,lineStart:function(){o.point=t},lineEnd:r,polygonStart:function(){o.lineEnd=u},polygonEnd:function(){o.lineEnd=r,o.point=n},pointRadius:function(n){return i=Jt(n),o},result:function(){if(a.length){var n=a.join("");return a=[],n}}};return o}function Jt(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function Gt(n,t){Ao+=n,Co+=t,++zo}function Kt(){function n(n,r){var u=n-t,i=r-e,a=Math.sqrt(u*u+i*i);Lo+=a*(t+n)/2,qo+=a*(e+r)/2,To+=a,Gt(t=n,e=r)}var t,e;Bo.point=function(r,u){Bo.point=n,Gt(t=r,e=u)}}function Qt(){Bo.point=Gt}function ne(){function n(n,t){var e=n-r,i=t-u,a=Math.sqrt(e*e+i*i);Lo+=a*(r+n)/2,qo+=a*(u+t)/2,To+=a,a=u*n-r*t,Ro+=a*(r+n),Do+=a*(u+t),Po+=3*a,Gt(r=n,u=t)}var t,e,r,u;Bo.point=function(i,a){Bo.point=n,Gt(t=r=i,e=u=a)},Bo.lineEnd=function(){n(t,e)}}function te(n){function t(t,e){n.moveTo(t+a,e),n.arc(t,e,a,0,Ua)}function e(t,e){n.moveTo(t,e),o.point=r}function r(t,e){n.lineTo(t,e)}function u(){o.point=t}function i(){n.closePath()}var a=4.5,o={point:t,lineStart:function(){o.point=e},lineEnd:u,polygonStart:function(){o.lineEnd=i},polygonEnd:function(){o.lineEnd=u,o.point=t},pointRadius:function(n){return a=n,o},result:b};return o}function ee(n){function t(n){return(o?r:e)(n)}function e(t){return ie(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){M=NaN,S.point=i,t.lineStart()}function i(e,r){var i=dt([e,r]),a=n(e,r);u(M,x,y,b,_,w,M=a[0],x=a[1],y=e,b=i[0],_=i[1],w=i[2],o,t),t.point(M,x)}function a(){S.point=e,t.lineEnd()}function l(){r(),S.point=c,S.lineEnd=s}function c(n,t){ + i(f=n,h=t),g=M,p=x,v=b,d=_,m=w,S.point=i}function s(){u(M,x,y,b,_,w,g,p,f,v,d,m,o,t),S.lineEnd=a,a()}var f,h,g,p,v,d,m,y,M,x,b,_,w,S={point:e,lineStart:r,lineEnd:a,polygonStart:function(){t.polygonStart(),S.lineStart=l},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function u(t,e,r,o,l,c,s,f,h,g,p,v,d,m){var y=s-t,M=f-e,x=y*y+M*M;if(x>4*i&&d--){var b=o+g,_=l+p,w=c+v,S=Math.sqrt(b*b+_*_+w*w),k=Math.asin(w/=S),N=Ma(Ma(w)-1)i||Ma((y*z+M*L)/x-.5)>.3||a>o*g+l*p+c*v)&&(u(t,e,r,o,l,c,A,C,N,b/=S,_/=S,w,d,m),m.point(A,C),u(A,C,N,b,_,w,s,f,h,g,p,v,d,m))}}var i=.5,a=Math.cos(30*Oa),o=16;return t.precision=function(n){return arguments.length?(o=(i=n*n)>0&&16,t):Math.sqrt(i)},t}function re(n){var t=ee(function(t,e){return n([t*Ia,e*Ia])});return function(n){return le(t(n))}}function ue(n){this.stream=n}function ie(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function ae(n){return oe(function(){return n})()}function oe(n){function t(n){return n=o(n[0]*Oa,n[1]*Oa),[n[0]*h+l,c-n[1]*h]}function e(n){return n=o.invert((n[0]-l)/h,(c-n[1])/h),n&&[n[0]*Ia,n[1]*Ia]}function r(){o=Ct(a=fe(m,M,x),i);var n=i(v,d);return l=g-n[0]*h,c=p+n[1]*h,u()}function u(){return s&&(s.valid=!1,s=null),t}var i,a,o,l,c,s,f=ee(function(n,t){return n=i(n,t),[n[0]*h+l,c-n[1]*h]}),h=150,g=480,p=250,v=0,d=0,m=0,M=0,x=0,b=Uo,_=y,w=null,S=null;return t.stream=function(n){return s&&(s.valid=!1),s=le(b(a,f(_(n)))),s.valid=!0,s},t.clipAngle=function(n){return arguments.length?(b=null==n?(w=n,Uo):It((w=+n)*Oa),u()):w},t.clipExtent=function(n){return arguments.length?(S=n,_=n?Zt(n[0][0],n[0][1],n[1][0],n[1][1]):y,u()):S},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(g=+n[0],p=+n[1],r()):[g,p]},t.center=function(n){return arguments.length?(v=n[0]%360*Oa,d=n[1]%360*Oa,r()):[v*Ia,d*Ia]},t.rotate=function(n){return arguments.length?(m=n[0]%360*Oa,M=n[1]%360*Oa,x=n.length>2?n[2]%360*Oa:0,r()):[m*Ia,M*Ia,x*Ia]},oa.rebind(t,f,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function le(n){return ie(n,function(t,e){n.point(t*Oa,e*Oa)})}function ce(n,t){return[n,t]}function se(n,t){return[n>ja?n-Ua:-ja>n?n+Ua:n,t]}function fe(n,t,e){return n?t||e?Ct(ge(n),pe(t,e)):ge(n):t||e?pe(t,e):se}function he(n){return function(t,e){return t+=n,[t>ja?t-Ua:-ja>t?t+Ua:t,e]}}function ge(n){var t=he(n);return t.invert=he(-n),t}function pe(n,t){function e(n,t){var e=Math.cos(t),o=Math.cos(n)*e,l=Math.sin(n)*e,c=Math.sin(t),s=c*r+o*u;return[Math.atan2(l*i-s*a,o*r-c*u),tn(s*i+l*a)]}var r=Math.cos(n),u=Math.sin(n),i=Math.cos(t),a=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),o=Math.cos(n)*e,l=Math.sin(n)*e,c=Math.sin(t),s=c*i-l*a;return[Math.atan2(l*i+c*a,o*r+s*u),tn(s*r-o*u)]},e}function ve(n,t){var e=Math.cos(n),r=Math.sin(n);return function(u,i,a,o){var l=a*t;null!=u?(u=de(e,u),i=de(e,i),(a>0?i>u:u>i)&&(u+=a*Ua)):(u=n+a*Ua,i=n-.5*l);for(var c,s=u;a>0?s>i:i>s;s-=l)o.point((c=_t([e,-r*Math.cos(s),-r*Math.sin(s)]))[0],c[1])}}function de(n,t){var e=dt(t);e[0]-=n,bt(e);var r=nn(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Da)%(2*Math.PI)}function me(n,t,e){var r=oa.range(n,t-Da,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function ye(n,t,e){var r=oa.range(n,t-Da,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function Me(n){return n.source}function xe(n){return n.target}function be(n,t,e,r){var u=Math.cos(t),i=Math.sin(t),a=Math.cos(r),o=Math.sin(r),l=u*Math.cos(n),c=u*Math.sin(n),s=a*Math.cos(e),f=a*Math.sin(e),h=2*Math.asin(Math.sqrt(an(r-t)+u*a*an(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*l+t*s,u=e*c+t*f,a=e*i+t*o;return[Math.atan2(u,r)*Ia,Math.atan2(a,Math.sqrt(r*r+u*u))*Ia]}:function(){return[n*Ia,t*Ia]};return p.distance=h,p}function _e(){function n(n,u){var i=Math.sin(u*=Oa),a=Math.cos(u),o=Ma((n*=Oa)-t),l=Math.cos(o);Wo+=Math.atan2(Math.sqrt((o=a*Math.sin(o))*o+(o=r*i-e*a*l)*o),e*i+r*a*l),t=n,e=i,r=a}var t,e,r;Jo.point=function(u,i){t=u*Oa,e=Math.sin(i*=Oa),r=Math.cos(i),Jo.point=n},Jo.lineEnd=function(){Jo.point=Jo.lineEnd=b}}function we(n,t){function e(t,e){var r=Math.cos(t),u=Math.cos(e),i=n(r*u);return[i*u*Math.sin(t),i*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),u=t(r),i=Math.sin(u),a=Math.cos(u);return[Math.atan2(n*i,r*a),Math.asin(r&&e*i/r)]},e}function Se(n,t){function e(n,t){a>0?-Ha+Da>t&&(t=-Ha+Da):t>Ha-Da&&(t=Ha-Da);var e=a/Math.pow(u(t),i);return[e*Math.sin(i*n),a-e*Math.cos(i*n)]}var r=Math.cos(n),u=function(n){return Math.tan(ja/4+n/2)},i=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(u(t)/u(n)),a=r*Math.pow(u(n),i)/i;return i?(e.invert=function(n,t){var e=a-t,r=K(i)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/i,2*Math.atan(Math.pow(a/r,1/i))-Ha]},e):Ne}function ke(n,t){function e(n,t){var e=i-t;return[e*Math.sin(u*n),i-e*Math.cos(u*n)]}var r=Math.cos(n),u=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),i=r/u+n;return Ma(u)u;u++){for(;r>1&&Q(n[e[r-2]],n[e[r-1]],n[u])<=0;)--r;e[r++]=u}return e.slice(0,r)}function qe(n,t){return n[0]-t[0]||n[1]-t[1]}function Te(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Re(n,t,e,r){var u=n[0],i=e[0],a=t[0]-u,o=r[0]-i,l=n[1],c=e[1],s=t[1]-l,f=r[1]-c,h=(o*(l-c)-f*(u-i))/(f*a-o*s);return[u+h*a,l+h*s]}function De(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Pe(){rr(this),this.edge=this.site=this.circle=null}function je(n){var t=ll.pop()||new Pe;return t.site=n,t}function Ue(n){Be(n),il.remove(n),ll.push(n),rr(n)}function Fe(n){var t=n.circle,e=t.x,r=t.cy,u={x:e,y:r},i=n.P,a=n.N,o=[n];Ue(n);for(var l=i;l.circle&&Ma(e-l.circle.x)s;++s)c=o[s],l=o[s-1],nr(c.edge,l.site,c.site,u);l=o[0],c=o[f-1],c.edge=Ke(l.site,c.site,null,u),$e(l),$e(c)}function He(n){for(var t,e,r,u,i=n.x,a=n.y,o=il._;o;)if(r=Oe(o,a)-i,r>Da)o=o.L;else{if(u=i-Ie(o,a),!(u>Da)){r>-Da?(t=o.P,e=o):u>-Da?(t=o,e=o.N):t=e=o;break}if(!o.R){t=o;break}o=o.R}var l=je(n);if(il.insert(t,l),t||e){if(t===e)return Be(t),e=je(t.site),il.insert(l,e),l.edge=e.edge=Ke(t.site,l.site),$e(t),void $e(e);if(!e)return void(l.edge=Ke(t.site,l.site));Be(t),Be(e);var c=t.site,s=c.x,f=c.y,h=n.x-s,g=n.y-f,p=e.site,v=p.x-s,d=p.y-f,m=2*(h*d-g*v),y=h*h+g*g,M=v*v+d*d,x={x:(d*y-g*M)/m+s,y:(h*M-v*y)/m+f};nr(e.edge,c,p,x),l.edge=Ke(c,n,null,x),e.edge=Ke(n,p,null,x),$e(t),$e(e)}}function Oe(n,t){var e=n.site,r=e.x,u=e.y,i=u-t;if(!i)return r;var a=n.P;if(!a)return-(1/0);e=a.site;var o=e.x,l=e.y,c=l-t;if(!c)return o;var s=o-r,f=1/i-1/c,h=s/c;return f?(-h+Math.sqrt(h*h-2*f*(s*s/(-2*c)-l+c/2+u-i/2)))/f+r:(r+o)/2}function Ie(n,t){var e=n.N;if(e)return Oe(e,t);var r=n.site;return r.y===t?r.x:1/0}function Ye(n){this.site=n,this.edges=[]}function Ze(n){for(var t,e,r,u,i,a,o,l,c,s,f=n[0][0],h=n[1][0],g=n[0][1],p=n[1][1],v=ul,d=v.length;d--;)if(i=v[d],i&&i.prepare())for(o=i.edges,l=o.length,a=0;l>a;)s=o[a].end(),r=s.x,u=s.y,c=o[++a%l].start(),t=c.x,e=c.y,(Ma(r-t)>Da||Ma(u-e)>Da)&&(o.splice(a,0,new tr(Qe(i.site,s,Ma(r-f)Da?{x:f,y:Ma(t-f)Da?{x:Ma(e-p)Da?{x:h,y:Ma(t-h)Da?{x:Ma(e-g)=-Pa)){var g=l*l+c*c,p=s*s+f*f,v=(f*g-c*p)/h,d=(l*p-s*g)/h,f=d+o,m=cl.pop()||new Xe;m.arc=n,m.site=u,m.x=v+a,m.y=f+Math.sqrt(v*v+d*d),m.cy=f,n.circle=m;for(var y=null,M=ol._;M;)if(m.yd||d>=o)return;if(h>p){if(i){if(i.y>=c)return}else i={x:d,y:l};e={x:d,y:c}}else{if(i){if(i.yr||r>1)if(h>p){if(i){if(i.y>=c)return}else i={x:(l-u)/r,y:l};e={x:(c-u)/r,y:c}}else{if(i){if(i.yg){if(i){if(i.x>=o)return}else i={x:a,y:r*a+u};e={x:o,y:r*o+u}}else{if(i){if(i.xi||f>a||r>h||u>g)){if(p=n.point){var p,v=t-n.x,d=e-n.y,m=v*v+d*d;if(l>m){var y=Math.sqrt(l=m);r=t-y,u=e-y,i=t+y,a=e+y,o=p}}for(var M=n.nodes,x=.5*(s+h),b=.5*(f+g),_=t>=x,w=e>=b,S=w<<1|_,k=S+4;k>S;++S)if(n=M[3&S])switch(3&S){case 0:c(n,s,f,x,b);break;case 1:c(n,x,f,h,b);break;case 2:c(n,s,b,x,g);break;case 3:c(n,x,b,h,g)}}}(n,r,u,i,a),o}function vr(n,t){n=oa.rgb(n),t=oa.rgb(t);var e=n.r,r=n.g,u=n.b,i=t.r-e,a=t.g-r,o=t.b-u;return function(n){return"#"+bn(Math.round(e+i*n))+bn(Math.round(r+a*n))+bn(Math.round(u+o*n))}}function dr(n,t){var e,r={},u={};for(e in n)e in t?r[e]=Mr(n[e],t[e]):u[e]=n[e];for(e in t)e in n||(u[e]=t[e]);return function(n){for(e in r)u[e]=r[e](n);return u}}function mr(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function yr(n,t){var e,r,u,i=fl.lastIndex=hl.lastIndex=0,a=-1,o=[],l=[];for(n+="",t+="";(e=fl.exec(n))&&(r=hl.exec(t));)(u=r.index)>i&&(u=t.slice(i,u),o[a]?o[a]+=u:o[++a]=u),(e=e[0])===(r=r[0])?o[a]?o[a]+=r:o[++a]=r:(o[++a]=null,l.push({i:a,x:mr(e,r)})),i=hl.lastIndex;return ir;++r)o[(e=l[r]).i]=e.x(n);return o.join("")})}function Mr(n,t){for(var e,r=oa.interpolators.length;--r>=0&&!(e=oa.interpolators[r](n,t)););return e}function xr(n,t){var e,r=[],u=[],i=n.length,a=t.length,o=Math.min(n.length,t.length);for(e=0;o>e;++e)r.push(Mr(n[e],t[e]));for(;i>e;++e)u[e]=n[e];for(;a>e;++e)u[e]=t[e];return function(n){for(e=0;o>e;++e)u[e]=r[e](n);return u}}function br(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function _r(n){return function(t){return 1-n(1-t)}}function wr(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function Sr(n){return n*n}function kr(n){return n*n*n}function Nr(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Er(n){return function(t){return Math.pow(t,n)}}function Ar(n){return 1-Math.cos(n*Ha)}function Cr(n){return Math.pow(2,10*(n-1))}function zr(n){return 1-Math.sqrt(1-n*n)}function Lr(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/Ua*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*Ua/t)}}function qr(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function Tr(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Rr(n,t){n=oa.hcl(n),t=oa.hcl(t);var e=n.h,r=n.c,u=n.l,i=t.h-e,a=t.c-r,o=t.l-u;return isNaN(a)&&(a=0,r=isNaN(r)?t.c:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return fn(e+i*n,r+a*n,u+o*n)+""}}function Dr(n,t){n=oa.hsl(n),t=oa.hsl(t);var e=n.h,r=n.s,u=n.l,i=t.h-e,a=t.s-r,o=t.l-u;return isNaN(a)&&(a=0,r=isNaN(r)?t.s:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return cn(e+i*n,r+a*n,u+o*n)+""}}function Pr(n,t){n=oa.lab(n),t=oa.lab(t);var e=n.l,r=n.a,u=n.b,i=t.l-e,a=t.a-r,o=t.b-u;return function(n){return gn(e+i*n,r+a*n,u+o*n)+""}}function jr(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Ur(n){var t=[n.a,n.b],e=[n.c,n.d],r=Hr(t),u=Fr(t,e),i=Hr(Or(e,t,-u))||0;t[0]*e[1]180?t+=360:t-n>180&&(n+=360),r.push({i:e.push(Ir(e)+"rotate(",null,")")-2,x:mr(n,t)})):t&&e.push(Ir(e)+"rotate("+t+")")}function Vr(n,t,e,r){n!==t?r.push({i:e.push(Ir(e)+"skewX(",null,")")-2,x:mr(n,t)}):t&&e.push(Ir(e)+"skewX("+t+")")}function Xr(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var u=e.push(Ir(e)+"scale(",null,",",null,")");r.push({i:u-4,x:mr(n[0],t[0])},{i:u-2,x:mr(n[1],t[1])})}else(1!==t[0]||1!==t[1])&&e.push(Ir(e)+"scale("+t+")")}function $r(n,t){var e=[],r=[];return n=oa.transform(n),t=oa.transform(t),Yr(n.translate,t.translate,e,r),Zr(n.rotate,t.rotate,e,r),Vr(n.skew,t.skew,e,r),Xr(n.scale,t.scale,e,r),n=t=null,function(n){for(var t,u=-1,i=r.length;++u=0;)e.push(u[r])}function au(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(i=n.children)&&(u=i.length))for(var u,i,a=-1;++ae;++e)(t=n[e][1])>u&&(r=e,u=t);return r}function mu(n){return n.reduce(yu,0)}function yu(n,t){return n+t[1]}function Mu(n,t){return xu(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function xu(n,t){for(var e=-1,r=+n[0],u=(n[1]-r)/t,i=[];++e<=t;)i[e]=u*e+r;return i}function bu(n){return[oa.min(n),oa.max(n)]}function _u(n,t){return n.value-t.value}function wu(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function Su(n,t){n._pack_next=t,t._pack_prev=n}function ku(n,t){var e=t.x-n.x,r=t.y-n.y,u=n.r+t.r;return.999*u*u>e*e+r*r}function Nu(n){function t(n){s=Math.min(n.x-n.r,s),f=Math.max(n.x+n.r,f),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(c=e.length)){var e,r,u,i,a,o,l,c,s=1/0,f=-(1/0),h=1/0,g=-(1/0);if(e.forEach(Eu),r=e[0],r.x=-r.r,r.y=0,t(r),c>1&&(u=e[1],u.x=u.r,u.y=0,t(u),c>2))for(i=e[2],zu(r,u,i),t(i),wu(r,i),r._pack_prev=i,wu(i,u),u=r._pack_next,a=3;c>a;a++){zu(r,u,i=e[a]);var p=0,v=1,d=1;for(o=u._pack_next;o!==u;o=o._pack_next,v++)if(ku(o,i)){p=1;break}if(1==p)for(l=r._pack_prev;l!==o._pack_prev&&!ku(l,i);l=l._pack_prev,d++);p?(d>v||v==d&&u.ra;a++)i=e[a],i.x-=m,i.y-=y,M=Math.max(M,i.r+Math.sqrt(i.x*i.x+i.y*i.y));n.r=M,e.forEach(Au)}}function Eu(n){n._pack_next=n._pack_prev=n}function Au(n){delete n._pack_next,delete n._pack_prev}function Cu(n,t,e,r){var u=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,u)for(var i=-1,a=u.length;++i=0;)t=u[i],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Pu(n,t,e){return n.a.parent===t.parent?n.a:e}function ju(n){return 1+oa.max(n,function(n){return n.y})}function Uu(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Fu(n){var t=n.children;return t&&t.length?Fu(t[0]):n}function Hu(n){var t,e=n.children;return e&&(t=e.length)?Hu(e[t-1]):n}function Ou(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function Iu(n,t){var e=n.x+t[3],r=n.y+t[0],u=n.dx-t[1]-t[3],i=n.dy-t[0]-t[2];return 0>u&&(e+=u/2,u=0),0>i&&(r+=i/2,i=0),{x:e,y:r,dx:u,dy:i}}function Yu(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Zu(n){return n.rangeExtent?n.rangeExtent():Yu(n.range())}function Vu(n,t,e,r){var u=e(n[0],n[1]),i=r(t[0],t[1]);return function(n){return i(u(n))}}function Xu(n,t){var e,r=0,u=n.length-1,i=n[r],a=n[u];return i>a&&(e=r,r=u,u=e,e=i,i=a,a=e),n[r]=t.floor(i),n[u]=t.ceil(a),n}function $u(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:wl}function Bu(n,t,e,r){var u=[],i=[],a=0,o=Math.min(n.length,t.length)-1;for(n[o]2?Bu:Vu,l=r?Wr:Br;return a=u(n,t,l,e),o=u(t,n,l,Mr),i}function i(n){return a(n)}var a,o;return i.invert=function(n){return o(n)},i.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},i.range=function(n){return arguments.length?(t=n,u()):t},i.rangeRound=function(n){return i.range(n).interpolate(jr)},i.clamp=function(n){return arguments.length?(r=n,u()):r},i.interpolate=function(n){return arguments.length?(e=n,u()):e},i.ticks=function(t){return Qu(n,t)},i.tickFormat=function(t,e){return ni(n,t,e)},i.nice=function(t){return Gu(n,t),u()},i.copy=function(){return Wu(n,t,e,r)},u()}function Ju(n,t){return oa.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Gu(n,t){return Xu(n,$u(Ku(n,t)[2]))}function Ku(n,t){null==t&&(t=10);var e=Yu(n),r=e[1]-e[0],u=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),i=t/r*u;return.15>=i?u*=10:.35>=i?u*=5:.75>=i&&(u*=2),e[0]=Math.ceil(e[0]/u)*u,e[1]=Math.floor(e[1]/u)*u+.5*u,e[2]=u,e}function Qu(n,t){return oa.range.apply(oa,Ku(n,t))}function ni(n,t,e){var r=Ku(n,t);if(e){var u=so.exec(e);if(u.shift(),"s"===u[8]){var i=oa.formatPrefix(Math.max(Ma(r[0]),Ma(r[1])));return u[7]||(u[7]="."+ti(i.scale(r[2]))),u[8]="f",e=oa.format(u.join("")),function(n){return e(i.scale(n))+i.symbol}}u[7]||(u[7]="."+ei(u[8],r)),e=u.join("")}else e=",."+ti(r[2])+"f";return oa.format(e)}function ti(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function ei(n,t){var e=ti(t[2]);return n in Sl?Math.abs(e-ti(Math.max(Ma(t[0]),Ma(t[1]))))+ +("e"!==n):e-2*("%"===n)}function ri(n,t,e,r){function u(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function i(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function a(t){return n(u(t))}return a.invert=function(t){return i(n.invert(t))},a.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(u)),a):r},a.base=function(e){return arguments.length?(t=+e,n.domain(r.map(u)),a):t},a.nice=function(){var t=Xu(r.map(u),e?Math:Nl);return n.domain(t),r=t.map(i),a},a.ticks=function(){var n=Yu(r),a=[],o=n[0],l=n[1],c=Math.floor(u(o)),s=Math.ceil(u(l)),f=t%1?2:t;if(isFinite(s-c)){if(e){for(;s>c;c++)for(var h=1;f>h;h++)a.push(i(c)*h);a.push(i(c))}else for(a.push(i(c));c++0;h--)a.push(i(c)*h);for(c=0;a[c]l;s--);a=a.slice(c,s)}return a},a.tickFormat=function(n,t){if(!arguments.length)return kl;arguments.length<2?t=kl:"function"!=typeof t&&(t=oa.format(t));var r,o=Math.max(.1,n/a.ticks().length),l=e?(r=1e-12,Math.ceil):(r=-1e-12,Math.floor);return function(n){return n/i(l(u(n)+r))<=o?t(n):""}},a.copy=function(){return ri(n.copy(),t,e,r)},Ju(a,n)}function ui(n,t,e){function r(t){return n(u(t))}var u=ii(t),i=ii(1/t);return r.invert=function(t){return i(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(u)),r):e},r.ticks=function(n){return Qu(e,n)},r.tickFormat=function(n,t){return ni(e,n,t)},r.nice=function(n){return r.domain(Gu(e,n))},r.exponent=function(a){return arguments.length?(u=ii(t=a),i=ii(1/t),n.domain(e.map(u)),r):t},r.copy=function(){return ui(n.copy(),t,e)},Ju(r,n)}function ii(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function ai(n,t){function e(e){return i[((u.get(e)||("range"===t.t?u.set(e,n.push(e)):NaN))-1)%i.length]}function r(t,e){return oa.range(n.length).map(function(n){return t+e*n})}var u,i,a;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new c;for(var i,a=-1,o=r.length;++ae?[NaN,NaN]:[e>0?o[e-1]:n[0],et?NaN:t/i+n,[t,t+1/i]},r.copy=function(){return li(n,t,e)},u()}function ci(n,t){function e(e){return e>=e?t[oa.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return ci(n,t)},e}function si(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Qu(n,t)},t.tickFormat=function(t,e){return ni(n,t,e)},t.copy=function(){return si(n)},t}function fi(){return 0}function hi(n){return n.innerRadius}function gi(n){return n.outerRadius}function pi(n){return n.startAngle}function vi(n){return n.endAngle}function di(n){return n&&n.padAngle}function mi(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function yi(n,t,e,r,u){var i=n[0]-t[0],a=n[1]-t[1],o=(u?r:-r)/Math.sqrt(i*i+a*a),l=o*a,c=-o*i,s=n[0]+l,f=n[1]+c,h=t[0]+l,g=t[1]+c,p=(s+h)/2,v=(f+g)/2,d=h-s,m=g-f,y=d*d+m*m,M=e-r,x=s*g-h*f,b=(0>m?-1:1)*Math.sqrt(Math.max(0,M*M*y-x*x)),_=(x*m-d*b)/y,w=(-x*d-m*b)/y,S=(x*m+d*b)/y,k=(-x*d+m*b)/y,N=_-p,E=w-v,A=S-p,C=k-v;return N*N+E*E>A*A+C*C&&(_=S,w=k),[[_-l,w-c],[_*e/M,w*e/M]]}function Mi(n){function t(t){function a(){c.push("M",i(n(s),o))}for(var l,c=[],s=[],f=-1,h=t.length,g=En(e),p=En(r);++f1?n.join("L"):n+"Z"}function bi(n){return n.join("L")+"Z"}function _i(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1&&u.push("H",r[0]),u.join("")}function wi(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1){o=t[1],i=n[l],l++,r+="C"+(u[0]+a[0])+","+(u[1]+a[1])+","+(i[0]-o[0])+","+(i[1]-o[1])+","+i[0]+","+i[1];for(var c=2;c9&&(u=3*t/Math.sqrt(u),a[o]=u*e,a[o+1]=u*r));for(o=-1;++o<=l;)u=(n[Math.min(l,o+1)][0]-n[Math.max(0,o-1)][0])/(6*(1+a[o]*a[o])),i.push([u||0,a[o]*u||0]);return i}function Fi(n){return n.length<3?xi(n):n[0]+Ai(n,Ui(n))}function Hi(n){for(var t,e,r,u=-1,i=n.length;++u=t?a(n-t):void(s.c=a)}function a(e){var u=p.active,i=p[u];i&&(i.timer.c=null,i.timer.t=NaN,--p.count,delete p[u],i.event&&i.event.interrupt.call(n,n.__data__,i.index));for(var a in p)if(r>+a){var c=p[a];c.timer.c=null,c.timer.t=NaN,--p.count,delete p[a]}s.c=o,qn(function(){return s.c&&o(e||1)&&(s.c=null,s.t=NaN),1},0,l),p.active=r,v.event&&v.event.start.call(n,n.__data__,t),g=[],v.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&g.push(r)}),h=v.ease,f=v.duration}function o(u){for(var i=u/f,a=h(i),o=g.length;o>0;)g[--o].call(n,a);return i>=1?(v.event&&v.event.end.call(n,n.__data__,t),--p.count?delete p[r]:delete n[e],1):void 0}var l,s,f,h,g,p=n[e]||(n[e]={active:0,count:0}),v=p[r];v||(l=u.time,s=qn(i,0,l),v=p[r]={tween:new c,time:l,timer:s,delay:u.delay,duration:u.duration,ease:u.ease,index:t},u=null,++p.count)}function na(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function ta(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function ea(n){return n.toISOString()}function ra(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=oa.bisect(Gl,u);return i==Gl.length?[t.year,Ku(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/Gl[i-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=ua(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=ua(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Yu(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],ua(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return ra(n.copy(),t,e)},Ju(r,n)}function ua(n){return new Date(n)}function ia(n){return JSON.parse(n.responseText)}function aa(n){var t=sa.createRange();return t.selectNode(sa.body),t.createContextualFragment(n.responseText)}var oa={version:"3.5.9"},la=[].slice,ca=function(n){return la.call(n)},sa=this.document;if(sa)try{ca(sa.documentElement.childNodes)[0].nodeType}catch(fa){ca=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}if(Date.now||(Date.now=function(){return+new Date}),sa)try{sa.createElement("DIV").style.setProperty("opacity",0,"")}catch(ha){var ga=this.Element.prototype,pa=ga.setAttribute,va=ga.setAttributeNS,da=this.CSSStyleDeclaration.prototype,ma=da.setProperty;ga.setAttribute=function(n,t){pa.call(this,n,t+"")},ga.setAttributeNS=function(n,t,e){va.call(this,n,t,e+"")},da.setProperty=function(n,t,e){ma.call(this,n,t+"",e)}}oa.ascending=e,oa.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:NaN},oa.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ur&&(e=r)}else{for(;++u=r){e=r;break}for(;++ur&&(e=r)}return e},oa.max=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ue&&(e=r)}else{for(;++u=r){e=r;break}for(;++ue&&(e=r)}return e},oa.extent=function(n,t){var e,r,u,i=-1,a=n.length;if(1===arguments.length){for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}else{for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}return[e,u]},oa.sum=function(n,t){var e,r=0,i=n.length,a=-1;if(1===arguments.length)for(;++a1?l/(s-1):void 0},oa.deviation=function(){var n=oa.variance.apply(this,arguments);return n?Math.sqrt(n):n};var ya=i(e);oa.bisectLeft=ya.left,oa.bisect=oa.bisectRight=ya.right,oa.bisector=function(n){return i(1===n.length?function(t,r){return e(n(t),r)}:n)},oa.shuffle=function(n,t,e){(i=arguments.length)<3&&(e=n.length,2>i&&(t=0));for(var r,u,i=e-t;i;)u=Math.random()*i--|0,r=n[i+t],n[i+t]=n[u+t],n[u+t]=r;return n},oa.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},oa.pairs=function(n){for(var t,e=0,r=n.length-1,u=n[0],i=new Array(0>r?0:r);r>e;)i[e]=[t=u,u=n[++e]];return i},oa.zip=function(){if(!(r=arguments.length))return[];for(var n=-1,t=oa.min(arguments,a),e=new Array(t);++n=0;)for(r=n[u],t=r.length;--t>=0;)e[--a]=r[t];return e};var Ma=Math.abs;oa.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e===1/0)throw new Error("infinite range");var r,u=[],i=o(Ma(e)),a=-1;if(n*=i,t*=i,e*=i,0>e)for(;(r=n+e*++a)>t;)u.push(r/i);else for(;(r=n+e*++a)=i.length)return r?r.call(u,a):e?a.sort(e):a;for(var l,s,f,h,g=-1,p=a.length,v=i[o++],d=new c;++g=i.length)return n;var r=[],u=a[e++];return n.forEach(function(n,u){r.push({key:n,values:t(u,e)})}),u?r.sort(function(n,t){return u(n.key,t.key)}):r}var e,r,u={},i=[],a=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(oa.map,e,0),0)},u.key=function(n){return i.push(n),u},u.sortKeys=function(n){return a[i.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},oa.set=function(n){var t=new m;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},l(m,{has:h,add:function(n){return this._[s(n+="")]=!0,n},remove:g,values:p,size:v,empty:d,forEach:function(n){for(var t in this._)n.call(this,f(t))}}),oa.behavior={},oa.rebind=function(n,t){for(var e,r=1,u=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},oa.event=null,oa.requote=function(n){return n.replace(wa,"\\$&")};var wa=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Sa={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},ka=function(n,t){return t.querySelector(n)},Na=function(n,t){return t.querySelectorAll(n)},Ea=function(n,t){var e=n.matches||n[x(n,"matchesSelector")];return(Ea=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(ka=function(n,t){return Sizzle(n,t)[0]||null},Na=Sizzle,Ea=Sizzle.matchesSelector),oa.selection=function(){return oa.select(sa.documentElement)};var Aa=oa.selection.prototype=[];Aa.select=function(n){var t,e,r,u,i=[];n=A(n);for(var a=-1,o=this.length;++a=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),Ca.hasOwnProperty(e)?{space:Ca[e],local:n}:n}},Aa.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=oa.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(z(t,n[t]));return this}return this.each(z(n,t))},Aa.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=T(n)).length,u=-1;if(t=e.classList){for(;++uu){if("string"!=typeof n){2>u&&(e="");for(r in n)this.each(P(r,n[r],e));return this}if(2>u){var i=this.node();return t(i).getComputedStyle(i,null).getPropertyValue(n)}r=""}return this.each(P(n,e,r))},Aa.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(j(t,n[t]));return this}return this.each(j(n,t))},Aa.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},Aa.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},Aa.append=function(n){return n=U(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},Aa.insert=function(n,t){return n=U(n),t=A(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},Aa.remove=function(){return this.each(F)},Aa.data=function(n,t){function e(n,e){var r,u,i,a=n.length,f=e.length,h=Math.min(a,f),g=new Array(f),p=new Array(f),v=new Array(a);if(t){var d,m=new c,y=new Array(a);for(r=-1;++rr;++r)p[r]=H(e[r]);for(;a>r;++r)v[r]=n[r]}p.update=g,p.parentNode=g.parentNode=v.parentNode=n.parentNode,o.push(p),l.push(g),s.push(v)}var r,u,i=-1,a=this.length;if(!arguments.length){for(n=new Array(a=(r=this[0]).length);++ii;i++){u.push(t=[]),t.parentNode=(e=this[i]).parentNode;for(var o=0,l=e.length;l>o;o++)(r=e[o])&&n.call(r,r.__data__,o,i)&&t.push(r)}return E(u)},Aa.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[u])&&(i&&i!==e.nextSibling&&i.parentNode.insertBefore(e,i),i=e);return this},Aa.sort=function(n){n=I.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,u=e.length;u>r;r++){var i=e[r];if(i)return i}return null},Aa.size=function(){var n=0;return Y(this,function(){++n}),n};var za=[];oa.selection.enter=Z,oa.selection.enter.prototype=za,za.append=Aa.append,za.empty=Aa.empty,za.node=Aa.node,za.call=Aa.call,za.size=Aa.size,za.select=function(n){for(var t,e,r,u,i,a=[],o=-1,l=this.length;++or){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(X(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(X(n,t,e))};var La=oa.map({mouseenter:"mouseover",mouseleave:"mouseout"});sa&&La.forEach(function(n){"on"+n in sa&&La.remove(n)});var qa,Ta=0;oa.mouse=function(n){return J(n,k())};var Ra=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;oa.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=k().changedTouches),t)for(var r,u=0,i=t.length;i>u;++u)if((r=t[u]).identifier===e)return J(n,r)},oa.behavior.drag=function(){function n(){this.on("mousedown.drag",i).on("touchstart.drag",a)}function e(n,t,e,i,a){return function(){function o(){var n,e,r=t(h,v);r&&(n=r[0]-M[0],e=r[1]-M[1],p|=n|e,M=r,g({type:"drag",x:r[0]+c[0],y:r[1]+c[1],dx:n,dy:e}))}function l(){t(h,v)&&(m.on(i+d,null).on(a+d,null),y(p),g({type:"dragend"}))}var c,s=this,f=oa.event.target,h=s.parentNode,g=r.of(s,arguments),p=0,v=n(),d=".drag"+(null==v?"":"-"+v),m=oa.select(e(f)).on(i+d,o).on(a+d,l),y=W(f),M=t(h,v);u?(c=u.apply(s,arguments),c=[c.x-M[0],c.y-M[1]]):c=[0,0],g({type:"dragstart"})}}var r=N(n,"drag","dragstart","dragend"),u=null,i=e(b,oa.mouse,t,"mousemove","mouseup"),a=e(G,oa.touch,y,"touchmove","touchend");return n.origin=function(t){return arguments.length?(u=t,n):u},oa.rebind(n,r,"on")},oa.touches=function(n,t){return arguments.length<2&&(t=k().touches),t?ca(t).map(function(t){var e=J(n,t);return e.identifier=t.identifier,e}):[]};var Da=1e-6,Pa=Da*Da,ja=Math.PI,Ua=2*ja,Fa=Ua-Da,Ha=ja/2,Oa=ja/180,Ia=180/ja,Ya=Math.SQRT2,Za=2,Va=4;oa.interpolateZoom=function(n,t){var e,r,u=n[0],i=n[1],a=n[2],o=t[0],l=t[1],c=t[2],s=o-u,f=l-i,h=s*s+f*f;if(Pa>h)r=Math.log(c/a)/Ya,e=function(n){return[u+n*s,i+n*f,a*Math.exp(Ya*n*r)]};else{var g=Math.sqrt(h),p=(c*c-a*a+Va*h)/(2*a*Za*g),v=(c*c-a*a-Va*h)/(2*c*Za*g),d=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(v*v+1)-v);r=(m-d)/Ya,e=function(n){var t=n*r,e=rn(d),o=a/(Za*g)*(e*un(Ya*t+d)-en(d));return[u+o*s,i+o*f,a*e/rn(Ya*t+d)]}}return e.duration=1e3*r,e},oa.behavior.zoom=function(){function n(n){n.on(L,f).on($a+".zoom",g).on("dblclick.zoom",p).on(R,h)}function e(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function r(n){return[n[0]*k.k+k.x,n[1]*k.k+k.y]}function u(n){k.k=Math.max(A[0],Math.min(A[1],n))}function i(n,t){t=r(t),k.x+=n[0]-t[0],k.y+=n[1]-t[1]}function a(t,e,r,a){t.__chart__={x:k.x,y:k.y,k:k.k},u(Math.pow(2,a)),i(d=e,r),t=oa.select(t),C>0&&(t=t.transition().duration(C)),t.call(n.event)}function o(){b&&b.domain(x.range().map(function(n){return(n-k.x)/k.k}).map(x.invert)),w&&w.domain(_.range().map(function(n){return(n-k.y)/k.k}).map(_.invert))}function l(n){z++||n({type:"zoomstart"})}function c(n){o(),n({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function s(n){--z||(n({type:"zoomend"}),d=null)}function f(){function n(){o=1,i(oa.mouse(u),h),c(a)}function r(){f.on(q,null).on(T,null),g(o),s(a)}var u=this,a=D.of(u,arguments),o=0,f=oa.select(t(u)).on(q,n).on(T,r),h=e(oa.mouse(u)),g=W(u);Ol.call(u),l(a)}function h(){function n(){var n=oa.touches(p);return g=k.k,n.forEach(function(n){n.identifier in d&&(d[n.identifier]=e(n))}),n}function t(){var t=oa.event.target;oa.select(t).on(x,r).on(b,o),_.push(t);for(var e=oa.event.changedTouches,u=0,i=e.length;i>u;++u)d[e[u].identifier]=null;var l=n(),c=Date.now();if(1===l.length){if(500>c-M){var s=l[0];a(p,s,d[s.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),S()}M=c}else if(l.length>1){var s=l[0],f=l[1],h=s[0]-f[0],g=s[1]-f[1];m=h*h+g*g}}function r(){var n,t,e,r,a=oa.touches(p);Ol.call(p);for(var o=0,l=a.length;l>o;++o,r=null)if(e=a[o],r=d[e.identifier]){if(t)break;n=e,t=r}if(r){var s=(s=e[0]-n[0])*s+(s=e[1]-n[1])*s,f=m&&Math.sqrt(s/m);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+r[0])/2,(t[1]+r[1])/2],u(f*g)}M=null,i(n,t),c(v)}function o(){if(oa.event.touches.length){for(var t=oa.event.changedTouches,e=0,r=t.length;r>e;++e)delete d[t[e].identifier];for(var u in d)return void n()}oa.selectAll(_).on(y,null),w.on(L,f).on(R,h),N(),s(v)}var g,p=this,v=D.of(p,arguments),d={},m=0,y=".zoom-"+oa.event.changedTouches[0].identifier,x="touchmove"+y,b="touchend"+y,_=[],w=oa.select(p),N=W(p);t(),l(v),w.on(L,null).on(R,t)}function g(){var n=D.of(this,arguments);y?clearTimeout(y):(Ol.call(this),v=e(d=m||oa.mouse(this)),l(n)),y=setTimeout(function(){y=null,s(n)},50),S(),u(Math.pow(2,.002*Xa())*k.k),i(d,v),c(n)}function p(){var n=oa.mouse(this),t=Math.log(k.k)/Math.LN2;a(this,n,e(n),oa.event.shiftKey?Math.ceil(t)-1:Math.floor(t)+1)}var v,d,m,y,M,x,b,_,w,k={x:0,y:0,k:1},E=[960,500],A=Ba,C=250,z=0,L="mousedown.zoom",q="mousemove.zoom",T="mouseup.zoom",R="touchstart.zoom",D=N(n,"zoomstart","zoom","zoomend");return $a||($a="onwheel"in sa?(Xa=function(){return-oa.event.deltaY*(oa.event.deltaMode?120:1)},"wheel"):"onmousewheel"in sa?(Xa=function(){return oa.event.wheelDelta},"mousewheel"):(Xa=function(){return-oa.event.detail},"MozMousePixelScroll")),n.event=function(n){n.each(function(){var n=D.of(this,arguments),t=k;Fl?oa.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},l(n)}).tween("zoom:zoom",function(){var e=E[0],r=E[1],u=d?d[0]:e/2,i=d?d[1]:r/2,a=oa.interpolateZoom([(u-k.x)/k.k,(i-k.y)/k.k,e/k.k],[(u-t.x)/t.k,(i-t.y)/t.k,e/t.k]);return function(t){var r=a(t),o=e/r[2];this.__chart__=k={x:u-r[0]*o,y:i-r[1]*o,k:o},c(n)}}).each("interrupt.zoom",function(){s(n)}).each("end.zoom",function(){s(n)}):(this.__chart__=k,l(n),c(n),s(n))})},n.translate=function(t){return arguments.length?(k={x:+t[0],y:+t[1],k:k.k},o(),n):[k.x,k.y]},n.scale=function(t){return arguments.length?(k={x:k.x,y:k.y,k:null},u(+t),o(),n):k.k},n.scaleExtent=function(t){return arguments.length?(A=null==t?Ba:[+t[0],+t[1]],n):A},n.center=function(t){return arguments.length?(m=t&&[+t[0],+t[1]],n):m},n.size=function(t){return arguments.length?(E=t&&[+t[0],+t[1]],n):E},n.duration=function(t){return arguments.length?(C=+t,n):C},n.x=function(t){return arguments.length?(b=t,x=t.copy(),k={x:0,y:0,k:1},n):b},n.y=function(t){return arguments.length?(w=t,_=t.copy(),k={x:0,y:0,k:1},n):w},oa.rebind(n,D,"on")};var Xa,$a,Ba=[0,1/0];oa.color=on,on.prototype.toString=function(){return this.rgb()+""},oa.hsl=ln;var Wa=ln.prototype=new on;Wa.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new ln(this.h,this.s,this.l/n)},Wa.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new ln(this.h,this.s,n*this.l)},Wa.rgb=function(){return cn(this.h,this.s,this.l)},oa.hcl=sn;var Ja=sn.prototype=new on;Ja.brighter=function(n){return new sn(this.h,this.c,Math.min(100,this.l+Ga*(arguments.length?n:1)))},Ja.darker=function(n){return new sn(this.h,this.c,Math.max(0,this.l-Ga*(arguments.length?n:1)))},Ja.rgb=function(){return fn(this.h,this.c,this.l).rgb()},oa.lab=hn;var Ga=18,Ka=.95047,Qa=1,no=1.08883,to=hn.prototype=new on;to.brighter=function(n){return new hn(Math.min(100,this.l+Ga*(arguments.length?n:1)),this.a,this.b)},to.darker=function(n){return new hn(Math.max(0,this.l-Ga*(arguments.length?n:1)),this.a,this.b)},to.rgb=function(){return gn(this.l,this.a,this.b)},oa.rgb=yn;var eo=yn.prototype=new on;eo.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,u=30;return t||e||r?(t&&u>t&&(t=u),e&&u>e&&(e=u),r&&u>r&&(r=u),new yn(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new yn(u,u,u)},eo.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new yn(n*this.r,n*this.g,n*this.b)},eo.hsl=function(){return wn(this.r,this.g,this.b)},eo.toString=function(){return"#"+bn(this.r)+bn(this.g)+bn(this.b)};var ro=oa.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ro.forEach(function(n,t){ro.set(n,Mn(t))}),oa.functor=En,oa.xhr=An(y),oa.dsv=function(n,t){function e(n,e,i){arguments.length<3&&(i=e,e=null);var a=Cn(n,t,null==e?r:u(e),i);return a.row=function(n){return arguments.length?a.response(null==(e=n)?r:u(n)):e},a}function r(n){return e.parse(n.responseText)}function u(n){return function(t){return e.parse(t.responseText,n)}}function i(t){return t.map(a).join(n)}function a(n){return o.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var o=new RegExp('["'+n+"\n]"),l=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var u=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(u(n),e)}:u})},e.parseRows=function(n,t){function e(){if(s>=c)return a;if(u)return u=!1,i;var t=s;if(34===n.charCodeAt(t)){for(var e=t;e++s;){var r=n.charCodeAt(s++),o=1;if(10===r)u=!0;else if(13===r)u=!0,10===n.charCodeAt(s)&&(++s,++o);else if(r!==l)continue;return n.slice(t,s-o)}return n.slice(t)}for(var r,u,i={},a={},o=[],c=n.length,s=0,f=0;(r=e())!==a;){for(var h=[];r!==i&&r!==a;)h.push(r),r=e();t&&null==(h=t(h,f++))||o.push(h)}return o},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new m,u=[];return t.forEach(function(n){for(var t in n)r.has(t)||u.push(r.add(t))}),[u.map(a).join(n)].concat(t.map(function(t){return u.map(function(n){return a(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(i).join("\n")},e},oa.csv=oa.dsv(",","text/csv"),oa.tsv=oa.dsv(" ","text/tab-separated-values");var uo,io,ao,oo,lo=this[x(this,"requestAnimationFrame")]||function(n){setTimeout(n,17)};oa.timer=function(){qn.apply(this,arguments)},oa.timer.flush=function(){Rn(),Dn()},oa.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var co=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(jn);oa.formatPrefix=function(n,t){var e=0;return(n=+n)&&(0>n&&(n*=-1),t&&(n=oa.round(n,Pn(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),co[8+e/3]};var so=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,fo=oa.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=oa.round(n,Pn(n,t))).toFixed(Math.max(0,Math.min(20,Pn(n*(1+1e-15),t))))}}),ho=oa.time={},go=Date;Hn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){po.setUTCDate.apply(this._,arguments)},setDay:function(){po.setUTCDay.apply(this._,arguments)},setFullYear:function(){po.setUTCFullYear.apply(this._,arguments)},setHours:function(){po.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){po.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){po.setUTCMinutes.apply(this._,arguments)},setMonth:function(){po.setUTCMonth.apply(this._,arguments)},setSeconds:function(){po.setUTCSeconds.apply(this._,arguments)},setTime:function(){po.setTime.apply(this._,arguments)}};var po=Date.prototype;ho.year=On(function(n){return n=ho.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),ho.years=ho.year.range,ho.years.utc=ho.year.utc.range,ho.day=On(function(n){var t=new go(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),ho.days=ho.day.range,ho.days.utc=ho.day.utc.range,ho.dayOfYear=function(n){var t=ho.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=ho[n]=On(function(n){return(n=ho.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=ho.year(n).getDay();return Math.floor((ho.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});ho[n+"s"]=e.range,ho[n+"s"].utc=e.utc.range,ho[n+"OfYear"]=function(n){var e=ho.year(n).getDay();return Math.floor((ho.dayOfYear(n)+(e+t)%7)/7)}}),ho.week=ho.sunday,ho.weeks=ho.sunday.range,ho.weeks.utc=ho.sunday.utc.range,ho.weekOfYear=ho.sundayOfYear;var vo={"-":"",_:" ",0:"0"},mo=/^\s*\d+/,yo=/^%/;oa.locale=function(n){return{numberFormat:Un(n),timeFormat:Yn(n)}};var Mo=oa.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"], + shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});oa.format=Mo.numberFormat,oa.geo={},st.prototype={s:0,t:0,add:function(n){ft(n,this.t,xo),ft(xo.s,this.s,this),this.s?this.t+=xo.t:this.s=xo.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var xo=new st;oa.geo.stream=function(n,t){n&&bo.hasOwnProperty(n.type)?bo[n.type](n,t):ht(n,t)};var bo={Feature:function(n,t){ht(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,u=e.length;++rn?4*ja+n:n,ko.lineStart=ko.lineEnd=ko.point=b}};oa.geo.bounds=function(){function n(n,t){M.push(x=[s=n,h=n]),f>t&&(f=t),t>g&&(g=t)}function t(t,e){var r=dt([t*Oa,e*Oa]);if(m){var u=yt(m,r),i=[u[1],-u[0],0],a=yt(i,u);bt(a),a=_t(a);var l=t-p,c=l>0?1:-1,v=a[0]*Ia*c,d=Ma(l)>180;if(d^(v>c*p&&c*t>v)){var y=a[1]*Ia;y>g&&(g=y)}else if(v=(v+360)%360-180,d^(v>c*p&&c*t>v)){var y=-a[1]*Ia;f>y&&(f=y)}else f>e&&(f=e),e>g&&(g=e);d?p>t?o(s,t)>o(s,h)&&(h=t):o(t,h)>o(s,h)&&(s=t):h>=s?(s>t&&(s=t),t>h&&(h=t)):t>p?o(s,t)>o(s,h)&&(h=t):o(t,h)>o(s,h)&&(s=t)}else n(t,e);m=r,p=t}function e(){b.point=t}function r(){x[0]=s,x[1]=h,b.point=n,m=null}function u(n,e){if(m){var r=n-p;y+=Ma(r)>180?r+(r>0?360:-360):r}else v=n,d=e;ko.point(n,e),t(n,e)}function i(){ko.lineStart()}function a(){u(v,d),ko.lineEnd(),Ma(y)>Da&&(s=-(h=180)),x[0]=s,x[1]=h,m=null}function o(n,t){return(t-=n)<0?t+360:t}function l(n,t){return n[0]-t[0]}function c(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nSo?(s=-(h=180),f=-(g=90)):y>Da?g=90:-Da>y&&(f=-90),x[0]=s,x[1]=h}};return function(n){g=h=-(s=f=1/0),M=[],oa.geo.stream(n,b);var t=M.length;if(t){M.sort(l);for(var e,r=1,u=M[0],i=[u];t>r;++r)e=M[r],c(e[0],u)||c(e[1],u)?(o(u[0],e[1])>o(u[0],u[1])&&(u[1]=e[1]),o(e[0],u[1])>o(u[0],u[1])&&(u[0]=e[0])):i.push(u=e);for(var a,e,p=-(1/0),t=i.length-1,r=0,u=i[t];t>=r;u=e,++r)e=i[r],(a=o(u[1],e[0]))>p&&(p=a,s=e[0],h=u[1])}return M=x=null,s===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[s,f],[h,g]]}}(),oa.geo.centroid=function(n){No=Eo=Ao=Co=zo=Lo=qo=To=Ro=Do=Po=0,oa.geo.stream(n,jo);var t=Ro,e=Do,r=Po,u=t*t+e*e+r*r;return Pa>u&&(t=Lo,e=qo,r=To,Da>Eo&&(t=Ao,e=Co,r=zo),u=t*t+e*e+r*r,Pa>u)?[NaN,NaN]:[Math.atan2(e,t)*Ia,tn(r/Math.sqrt(u))*Ia]};var No,Eo,Ao,Co,zo,Lo,qo,To,Ro,Do,Po,jo={sphere:b,point:St,lineStart:Nt,lineEnd:Et,polygonStart:function(){jo.lineStart=At},polygonEnd:function(){jo.lineStart=Nt}},Uo=Rt(zt,Ut,Ht,[-ja,-ja/2]),Fo=1e9;oa.geo.clipExtent=function(){var n,t,e,r,u,i,a={stream:function(n){return u&&(u.valid=!1),u=i(n),u.valid=!0,u},extent:function(o){return arguments.length?(i=Zt(n=+o[0][0],t=+o[0][1],e=+o[1][0],r=+o[1][1]),u&&(u.valid=!1,u=null),a):[[n,t],[e,r]]}};return a.extent([[0,0],[960,500]])},(oa.geo.conicEqualArea=function(){return Vt(Xt)}).raw=Xt,oa.geo.albers=function(){return oa.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},oa.geo.albersUsa=function(){function n(n){var i=n[0],a=n[1];return t=null,e(i,a),t||(r(i,a),t)||u(i,a),t}var t,e,r,u,i=oa.geo.albers(),a=oa.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),o=oa.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=i.scale(),e=i.translate(),r=(n[0]-e[0])/t,u=(n[1]-e[1])/t;return(u>=.12&&.234>u&&r>=-.425&&-.214>r?a:u>=.166&&.234>u&&r>=-.214&&-.115>r?o:i).invert(n)},n.stream=function(n){var t=i.stream(n),e=a.stream(n),r=o.stream(n);return{point:function(n,u){t.point(n,u),e.point(n,u),r.point(n,u)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(i.precision(t),a.precision(t),o.precision(t),n):i.precision()},n.scale=function(t){return arguments.length?(i.scale(t),a.scale(.35*t),o.scale(t),n.translate(i.translate())):i.scale()},n.translate=function(t){if(!arguments.length)return i.translate();var c=i.scale(),s=+t[0],f=+t[1];return e=i.translate(t).clipExtent([[s-.455*c,f-.238*c],[s+.455*c,f+.238*c]]).stream(l).point,r=a.translate([s-.307*c,f+.201*c]).clipExtent([[s-.425*c+Da,f+.12*c+Da],[s-.214*c-Da,f+.234*c-Da]]).stream(l).point,u=o.translate([s-.205*c,f+.212*c]).clipExtent([[s-.214*c+Da,f+.166*c+Da],[s-.115*c-Da,f+.234*c-Da]]).stream(l).point,n},n.scale(1070)};var Ho,Oo,Io,Yo,Zo,Vo,Xo={point:b,lineStart:b,lineEnd:b,polygonStart:function(){Oo=0,Xo.lineStart=$t},polygonEnd:function(){Xo.lineStart=Xo.lineEnd=Xo.point=b,Ho+=Ma(Oo/2)}},$o={point:Bt,lineStart:b,lineEnd:b,polygonStart:b,polygonEnd:b},Bo={point:Gt,lineStart:Kt,lineEnd:Qt,polygonStart:function(){Bo.lineStart=ne},polygonEnd:function(){Bo.point=Gt,Bo.lineStart=Kt,Bo.lineEnd=Qt}};oa.geo.path=function(){function n(n){return n&&("function"==typeof o&&i.pointRadius(+o.apply(this,arguments)),a&&a.valid||(a=u(i)),oa.geo.stream(n,a)),i.result()}function t(){return a=null,n}var e,r,u,i,a,o=4.5;return n.area=function(n){return Ho=0,oa.geo.stream(n,u(Xo)),Ho},n.centroid=function(n){return Ao=Co=zo=Lo=qo=To=Ro=Do=Po=0,oa.geo.stream(n,u(Bo)),Po?[Ro/Po,Do/Po]:To?[Lo/To,qo/To]:zo?[Ao/zo,Co/zo]:[NaN,NaN]},n.bounds=function(n){return Zo=Vo=-(Io=Yo=1/0),oa.geo.stream(n,u($o)),[[Io,Yo],[Zo,Vo]]},n.projection=function(n){return arguments.length?(u=(e=n)?n.stream||re(n):y,t()):e},n.context=function(n){return arguments.length?(i=null==(r=n)?new Wt:new te(n),"function"!=typeof o&&i.pointRadius(o),t()):r},n.pointRadius=function(t){return arguments.length?(o="function"==typeof t?t:(i.pointRadius(+t),+t),n):o},n.projection(oa.geo.albersUsa()).context(null)},oa.geo.transform=function(n){return{stream:function(t){var e=new ue(t);for(var r in n)e[r]=n[r];return e}}},ue.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},oa.geo.projection=ae,oa.geo.projectionMutator=oe,(oa.geo.equirectangular=function(){return ae(ce)}).raw=ce.invert=ce,oa.geo.rotation=function(n){function t(t){return t=n(t[0]*Oa,t[1]*Oa),t[0]*=Ia,t[1]*=Ia,t}return n=fe(n[0]%360*Oa,n[1]*Oa,n.length>2?n[2]*Oa:0),t.invert=function(t){return t=n.invert(t[0]*Oa,t[1]*Oa),t[0]*=Ia,t[1]*=Ia,t},t},se.invert=ce,oa.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=fe(-n[0]*Oa,-n[1]*Oa,0).invert,u=[];return e(null,null,1,{point:function(n,e){u.push(n=t(n,e)),n[0]*=Ia,n[1]*=Ia}}),{type:"Polygon",coordinates:[u]}}var t,e,r=[0,0],u=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=ve((t=+r)*Oa,u*Oa),n):t},n.precision=function(r){return arguments.length?(e=ve(t*Oa,(u=+r)*Oa),n):u},n.angle(90)},oa.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Oa,u=n[1]*Oa,i=t[1]*Oa,a=Math.sin(r),o=Math.cos(r),l=Math.sin(u),c=Math.cos(u),s=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((e=f*a)*e+(e=c*s-l*f*o)*e),l*s+c*f*o)},oa.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return oa.range(Math.ceil(i/d)*d,u,d).map(h).concat(oa.range(Math.ceil(c/m)*m,l,m).map(g)).concat(oa.range(Math.ceil(r/p)*p,e,p).filter(function(n){return Ma(n%d)>Da}).map(s)).concat(oa.range(Math.ceil(o/v)*v,a,v).filter(function(n){return Ma(n%m)>Da}).map(f))}var e,r,u,i,a,o,l,c,s,f,h,g,p=10,v=p,d=90,m=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(g(l).slice(1),h(u).reverse().slice(1),g(c).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(i=+t[0][0],u=+t[1][0],c=+t[0][1],l=+t[1][1],i>u&&(t=i,i=u,u=t),c>l&&(t=c,c=l,l=t),n.precision(y)):[[i,c],[u,l]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),o>a&&(t=o,o=a,a=t),n.precision(y)):[[r,o],[e,a]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(d=+t[0],m=+t[1],n):[d,m]},n.minorStep=function(t){return arguments.length?(p=+t[0],v=+t[1],n):[p,v]},n.precision=function(t){return arguments.length?(y=+t,s=me(o,a,90),f=ye(r,e,y),h=me(c,l,90),g=ye(i,u,y),n):y},n.majorExtent([[-180,-90+Da],[180,90-Da]]).minorExtent([[-180,-80-Da],[180,80+Da]])},oa.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||u.apply(this,arguments)]}}var t,e,r=Me,u=xe;return n.distance=function(){return oa.geo.distance(t||r.apply(this,arguments),e||u.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(u=t,e="function"==typeof t?null:t,n):u},n.precision=function(){return arguments.length?n:0},n},oa.geo.interpolate=function(n,t){return be(n[0]*Oa,n[1]*Oa,t[0]*Oa,t[1]*Oa)},oa.geo.length=function(n){return Wo=0,oa.geo.stream(n,Jo),Wo};var Wo,Jo={sphere:b,point:b,lineStart:_e,lineEnd:b,polygonStart:b,polygonEnd:b},Go=we(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(oa.geo.azimuthalEqualArea=function(){return ae(Go)}).raw=Go;var Ko=we(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},y);(oa.geo.azimuthalEquidistant=function(){return ae(Ko)}).raw=Ko,(oa.geo.conicConformal=function(){return Vt(Se)}).raw=Se,(oa.geo.conicEquidistant=function(){return Vt(ke)}).raw=ke;var Qo=we(function(n){return 1/n},Math.atan);(oa.geo.gnomonic=function(){return ae(Qo)}).raw=Qo,Ne.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-Ha]},(oa.geo.mercator=function(){return Ee(Ne)}).raw=Ne;var nl=we(function(){return 1},Math.asin);(oa.geo.orthographic=function(){return ae(nl)}).raw=nl;var tl=we(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(oa.geo.stereographic=function(){return ae(tl)}).raw=tl,Ae.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-Ha]},(oa.geo.transverseMercator=function(){var n=Ee(Ae),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):(n=t(),[n[1],-n[0]])},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):(n=e(),[n[0],n[1],n[2]-90])},e([0,0,90])}).raw=Ae,oa.geom={},oa.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,u=En(e),i=En(r),a=n.length,o=[],l=[];for(t=0;a>t;t++)o.push([+u.call(this,n[t],t),+i.call(this,n[t],t),t]);for(o.sort(qe),t=0;a>t;t++)l.push([o[t][0],-o[t][1]]);var c=Le(o),s=Le(l),f=s[0]===c[0],h=s[s.length-1]===c[c.length-1],g=[];for(t=c.length-1;t>=0;--t)g.push(n[o[c[t]][2]]);for(t=+f;t=r&&c.x<=i&&c.y>=u&&c.y<=a?[[r,a],[i,a],[i,u],[r,u]]:[];s.point=n[o]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(i(n,t)/Da)*Da,y:Math.round(a(n,t)/Da)*Da,i:t}})}var r=Ce,u=ze,i=r,a=u,o=sl;return n?t(n):(t.links=function(n){return or(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return or(e(n)).cells.forEach(function(e,r){for(var u,i,a=e.site,o=e.edges.sort(Ve),l=-1,c=o.length,s=o[c-1].edge,f=s.l===a?s.r:s.l;++l=c,h=r>=s,g=h<<1|f;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=hr()),f?u=c:o=c,h?a=s:l=s,i(n,t,e,r,u,a,o,l)}var s,f,h,g,p,v,d,m,y,M=En(o),x=En(l);if(null!=t)v=t,d=e,m=r,y=u;else if(m=y=-(v=d=1/0),f=[],h=[],p=n.length,a)for(g=0;p>g;++g)s=n[g],s.xm&&(m=s.x),s.y>y&&(y=s.y),f.push(s.x),h.push(s.y);else for(g=0;p>g;++g){var b=+M(s=n[g],g),_=+x(s,g);v>b&&(v=b),d>_&&(d=_),b>m&&(m=b),_>y&&(y=_),f.push(b),h.push(_)}var w=m-v,S=y-d;w>S?y=d+w:m=v+S;var k=hr();if(k.add=function(n){i(k,n,+M(n,++g),+x(n,g),v,d,m,y)},k.visit=function(n){gr(n,k,v,d,m,y)},k.find=function(n){return pr(k,n[0],n[1],v,d,m,y)},g=-1,null==t){for(;++g=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=pl.get(e)||gl,r=vl.get(r)||y,br(r(e.apply(null,la.call(arguments,1))))},oa.interpolateHcl=Rr,oa.interpolateHsl=Dr,oa.interpolateLab=Pr,oa.interpolateRound=jr,oa.transform=function(n){var t=sa.createElementNS(oa.ns.prefix.svg,"g");return(oa.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new Ur(e?e.matrix:dl)})(n)},Ur.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var dl={a:1,b:0,c:0,d:1,e:0,f:0};oa.interpolateTransform=$r,oa.layout={},oa.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++eo*o/m){if(v>l){var c=t.charge/l;n.px-=i*c,n.py-=a*c}return!0}if(t.point&&l&&v>l){var c=t.pointCharge/l;n.px-=i*c,n.py-=a*c}}return!t.charge}}function t(n){n.px=oa.event.x,n.py=oa.event.y,l.resume()}var e,r,u,i,a,o,l={},c=oa.dispatch("start","tick","end"),s=[1,1],f=.9,h=ml,g=yl,p=-30,v=Ml,d=.1,m=.64,M=[],x=[];return l.tick=function(){if((u*=.99)<.005)return e=null,c.end({type:"end",alpha:u=0}),!0;var t,r,l,h,g,v,m,y,b,_=M.length,w=x.length;for(r=0;w>r;++r)l=x[r],h=l.source,g=l.target,y=g.x-h.x,b=g.y-h.y,(v=y*y+b*b)&&(v=u*a[r]*((v=Math.sqrt(v))-i[r])/v,y*=v,b*=v,g.x-=y*(m=h.weight+g.weight?h.weight/(h.weight+g.weight):.5),g.y-=b*m,h.x+=y*(m=1-m),h.y+=b*m);if((m=u*d)&&(y=s[0]/2,b=s[1]/2,r=-1,m))for(;++r<_;)l=M[r],l.x+=(y-l.x)*m,l.y+=(b-l.y)*m;if(p)for(ru(t=oa.geom.quadtree(M),u,o),r=-1;++r<_;)(l=M[r]).fixed||t.visit(n(l));for(r=-1;++r<_;)l=M[r],l.fixed?(l.x=l.px,l.y=l.py):(l.x-=(l.px-(l.px=l.x))*f,l.y-=(l.py-(l.py=l.y))*f);c.tick({type:"tick",alpha:u})},l.nodes=function(n){return arguments.length?(M=n,l):M},l.links=function(n){return arguments.length?(x=n,l):x},l.size=function(n){return arguments.length?(s=n,l):s},l.linkDistance=function(n){return arguments.length?(h="function"==typeof n?n:+n,l):h},l.distance=l.linkDistance,l.linkStrength=function(n){return arguments.length?(g="function"==typeof n?n:+n,l):g},l.friction=function(n){return arguments.length?(f=+n,l):f},l.charge=function(n){return arguments.length?(p="function"==typeof n?n:+n,l):p},l.chargeDistance=function(n){return arguments.length?(v=n*n,l):Math.sqrt(v)},l.gravity=function(n){return arguments.length?(d=+n,l):d},l.theta=function(n){return arguments.length?(m=n*n,l):Math.sqrt(m)},l.alpha=function(n){return arguments.length?(n=+n,u?n>0?u=n:(e.c=null,e.t=NaN,e=null,c.start({type:"end",alpha:u=0})):n>0&&(c.start({type:"start",alpha:u=n}),e=qn(l.tick)),l):u},l.start=function(){function n(n,r){if(!e){for(e=new Array(u),l=0;u>l;++l)e[l]=[];for(l=0;c>l;++l){var i=x[l];e[i.source.index].push(i.target),e[i.target.index].push(i.source)}}for(var a,o=e[t],l=-1,s=o.length;++lt;++t)(r=M[t]).index=t,r.weight=0;for(t=0;c>t;++t)r=x[t],"number"==typeof r.source&&(r.source=M[r.source]),"number"==typeof r.target&&(r.target=M[r.target]),++r.source.weight,++r.target.weight;for(t=0;u>t;++t)r=M[t],isNaN(r.x)&&(r.x=n("x",f)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(i=[],"function"==typeof h)for(t=0;c>t;++t)i[t]=+h.call(this,x[t],t);else for(t=0;c>t;++t)i[t]=h;if(a=[],"function"==typeof g)for(t=0;c>t;++t)a[t]=+g.call(this,x[t],t);else for(t=0;c>t;++t)a[t]=g;if(o=[],"function"==typeof p)for(t=0;u>t;++t)o[t]=+p.call(this,M[t],t);else for(t=0;u>t;++t)o[t]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return r||(r=oa.behavior.drag().origin(y).on("dragstart.force",Qr).on("drag.force",t).on("dragend.force",nu)),arguments.length?void this.on("mouseover.force",tu).on("mouseout.force",eu).call(r):r},oa.rebind(l,c,"on")};var ml=20,yl=1,Ml=1/0;oa.layout.hierarchy=function(){function n(u){var i,a=[u],o=[];for(u.depth=0;null!=(i=a.pop());)if(o.push(i),(c=e.call(n,i,i.depth))&&(l=c.length)){for(var l,c,s;--l>=0;)a.push(s=c[l]),s.parent=i,s.depth=i.depth+1;r&&(i.value=0),i.children=c}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return au(u,function(n){var e,u;t&&(e=n.children)&&e.sort(t),r&&(u=n.parent)&&(u.value+=n.value)}),o}var t=cu,e=ou,r=lu;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(iu(t,function(n){n.children&&(n.value=0)}),au(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},oa.layout.partition=function(){function n(t,e,r,u){var i=t.children;if(t.x=e,t.y=t.depth*u,t.dx=r,t.dy=u,i&&(a=i.length)){var a,o,l,c=-1;for(r=t.value?r/t.value:0;++cf?-1:1),p=oa.sum(c),v=p?(f-l*g)/p:0,d=oa.range(l),m=[];return null!=e&&d.sort(e===xl?function(n,t){return c[t]-c[n]}:function(n,t){return e(a[n],a[t])}),d.forEach(function(n){m[n]={data:a[n],value:o=c[n],startAngle:s,endAngle:s+=o*v+g,padAngle:h}}),m}var t=Number,e=xl,r=0,u=Ua,i=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(u=t,n):u},n.padAngle=function(t){return arguments.length?(i=t,n):i},n};var xl={};oa.layout.stack=function(){function n(o,l){if(!(h=o.length))return o;var c=o.map(function(e,r){return t.call(n,e,r)}),s=c.map(function(t){return t.map(function(t,e){return[i.call(n,t,e),a.call(n,t,e)]})}),f=e.call(n,s,l);c=oa.permute(c,f),s=oa.permute(s,f);var h,g,p,v,d=r.call(n,s,l),m=c[0].length;for(p=0;m>p;++p)for(u.call(n,c[0][p],v=d[p],s[0][p][1]),g=1;h>g;++g)u.call(n,c[g][p],v+=s[g-1][p][1],s[g][p][1]);return o}var t=y,e=pu,r=vu,u=gu,i=fu,a=hu;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:bl.get(t)||pu,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:_l.get(t)||vu,n):r},n.x=function(t){return arguments.length?(i=t,n):i},n.y=function(t){return arguments.length?(a=t,n):a},n.out=function(t){return arguments.length?(u=t,n):u},n};var bl=oa.map({"inside-out":function(n){var t,e,r=n.length,u=n.map(du),i=n.map(mu),a=oa.range(r).sort(function(n,t){return u[n]-u[t]}),o=0,l=0,c=[],s=[];for(t=0;r>t;++t)e=a[t],l>o?(o+=i[e],c.push(e)):(l+=i[e],s.push(e));return s.reverse().concat(c)},reverse:function(n){return oa.range(n.length).reverse()},"default":pu}),_l=oa.map({silhouette:function(n){var t,e,r,u=n.length,i=n[0].length,a=[],o=0,l=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];r>o&&(o=r),a.push(r)}for(e=0;i>e;++e)l[e]=(o-a[e])/2;return l},wiggle:function(n){var t,e,r,u,i,a,o,l,c,s=n.length,f=n[0],h=f.length,g=[];for(g[0]=l=c=0,e=1;h>e;++e){for(t=0,u=0;s>t;++t)u+=n[t][e][1];for(t=0,i=0,o=f[e][0]-f[e-1][0];s>t;++t){for(r=0,a=(n[t][e][1]-n[t][e-1][1])/(2*o);t>r;++r)a+=(n[r][e][1]-n[r][e-1][1])/o;i+=a*n[t][e][1]}g[e]=l-=u?i/u*o:0,c>l&&(c=l)}for(e=0;h>e;++e)g[e]-=c;return g},expand:function(n){var t,e,r,u=n.length,i=n[0].length,a=1/u,o=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];if(r)for(t=0;u>t;t++)n[t][e][1]/=r;else for(t=0;u>t;t++)n[t][e][1]=a}for(e=0;i>e;++e)o[e]=0;return o},zero:vu});oa.layout.histogram=function(){function n(n,i){for(var a,o,l=[],c=n.map(e,this),s=r.call(this,c,i),f=u.call(this,s,c,i),i=-1,h=c.length,g=f.length-1,p=t?1:1/h;++i0)for(i=-1;++i=s[0]&&o<=s[1]&&(a=l[oa.bisect(f,o,1,g)-1],a.y+=p,a.push(n[i]));return l}var t=!0,e=Number,r=bu,u=Mu;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=En(t),n):r},n.bins=function(t){return arguments.length?(u="number"==typeof t?function(n){return xu(n,t)}:En(t),n):u},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},oa.layout.pack=function(){function n(n,i){var a=e.call(this,n,i),o=a[0],l=u[0],c=u[1],s=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(o.x=o.y=0,au(o,function(n){n.r=+s(n.value)}),au(o,Nu),r){var f=r*(t?1:Math.max(2*o.r/l,2*o.r/c))/2;au(o,function(n){n.r+=f}),au(o,Nu),au(o,function(n){n.r-=f})}return Cu(o,l/2,c/2,t?1:1/Math.max(2*o.r/l,2*o.r/c)),a}var t,e=oa.layout.hierarchy().sort(_u),r=0,u=[1,1];return n.size=function(t){return arguments.length?(u=t,n):u},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},uu(n,e)},oa.layout.tree=function(){function n(n,u){var s=a.call(this,n,u),f=s[0],h=t(f);if(au(h,e),h.parent.m=-h.z,iu(h,r),c)iu(f,i);else{var g=f,p=f,v=f;iu(f,function(n){n.xp.x&&(p=n),n.depth>v.depth&&(v=n)});var d=o(g,p)/2-g.x,m=l[0]/(p.x+o(p,g)/2+d),y=l[1]/(v.depth||1);iu(f,function(n){n.x=(n.x+d)*m,n.y=n.depth*y})}return s}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var u,i=t.children,a=0,o=i.length;o>a;++a)r.push((i[a]=u={_:i[a],parent:t,children:(u=i[a].children)&&u.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:a}).a=u);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){Du(n);var i=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+o(n._,r._),n.m=n.z-i):n.z=i}else r&&(n.z=r.z+o(n._,r._));n.parent.A=u(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function u(n,t,e){if(t){for(var r,u=n,i=n,a=t,l=u.parent.children[0],c=u.m,s=i.m,f=a.m,h=l.m;a=Tu(a),u=qu(u),a&&u;)l=qu(l),i=Tu(i),i.a=n,r=a.z+f-u.z-c+o(a._,u._),r>0&&(Ru(Pu(a,n,e),n,r),c+=r,s+=r),f+=a.m,c+=u.m,h+=l.m,s+=i.m;a&&!Tu(i)&&(i.t=a,i.m+=f-s),u&&!qu(l)&&(l.t=u,l.m+=c-h,e=n)}return e}function i(n){n.x*=l[0],n.y=n.depth*l[1]}var a=oa.layout.hierarchy().sort(null).value(null),o=Lu,l=[1,1],c=null;return n.separation=function(t){return arguments.length?(o=t,n):o},n.size=function(t){return arguments.length?(c=null==(l=t)?i:null,n):c?null:l},n.nodeSize=function(t){return arguments.length?(c=null==(l=t)?null:i,n):c?l:null},uu(n,a)},oa.layout.cluster=function(){function n(n,i){var a,o=t.call(this,n,i),l=o[0],c=0;au(l,function(n){var t=n.children;t&&t.length?(n.x=Uu(t),n.y=ju(t)):(n.x=a?c+=e(n,a):0,n.y=0,a=n)});var s=Fu(l),f=Hu(l),h=s.x-e(s,f)/2,g=f.x+e(f,s)/2;return au(l,u?function(n){n.x=(n.x-l.x)*r[0],n.y=(l.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(l.y?n.y/l.y:1))*r[1]}),o}var t=oa.layout.hierarchy().sort(null).value(null),e=Lu,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},uu(n,t)},oa.layout.treemap=function(){function n(n,t){for(var e,r,u=-1,i=n.length;++ut?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var i=e.children;if(i&&i.length){var a,o,l,c=f(e),s=[],h=i.slice(),p=1/0,v="slice"===g?c.dx:"dice"===g?c.dy:"slice-dice"===g?1&e.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(n(h,c.dx*c.dy/e.value),s.area=0;(l=h.length)>0;)s.push(a=h[l-1]),s.area+=a.area,"squarify"!==g||(o=r(s,v))<=p?(h.pop(),p=o):(s.area-=s.pop().area,u(s,v,c,!1),v=Math.min(c.dx,c.dy),s.length=s.area=0,p=1/0);s.length&&(u(s,v,c,!0),s.length=s.area=0),i.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var i,a=f(t),o=r.slice(),l=[];for(n(o,a.dx*a.dy/t.value),l.area=0;i=o.pop();)l.push(i),l.area+=i.area,null!=i.z&&(u(l,i.z?a.dx:a.dy,a,!o.length),l.length=l.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,u=0,i=1/0,a=-1,o=n.length;++ae&&(i=e),e>u&&(u=e));return r*=r,t*=t,r?Math.max(t*u*p/r,r/(t*i*p)):1/0}function u(n,t,e,r){var u,i=-1,a=n.length,o=e.x,c=e.y,s=t?l(n.area/t):0; + if(t==e.dx){for((r||s>e.dy)&&(s=e.dy);++ie.dx)&&(s=e.dx);++ie&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=oa.random.normal.apply(oa,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=oa.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},oa.scale={};var wl={floor:y,ceil:y};oa.scale.linear=function(){return Wu([0,1],[0,1],Mr,!1)};var Sl={s:1,g:1,p:1,r:1,e:1};oa.scale.log=function(){return ri(oa.scale.linear().domain([0,1]),10,!0,[1,10])};var kl=oa.format(".0e"),Nl={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};oa.scale.pow=function(){return ui(oa.scale.linear(),1,[0,1])},oa.scale.sqrt=function(){return oa.scale.pow().exponent(.5)},oa.scale.ordinal=function(){return ai([],{t:"range",a:[[]]})},oa.scale.category10=function(){return oa.scale.ordinal().range(El)},oa.scale.category20=function(){return oa.scale.ordinal().range(Al)},oa.scale.category20b=function(){return oa.scale.ordinal().range(Cl)},oa.scale.category20c=function(){return oa.scale.ordinal().range(zl)};var El=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(xn),Al=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(xn),Cl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(xn),zl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(xn);oa.scale.quantile=function(){return oi([],[])},oa.scale.quantize=function(){return li(0,1,[0,1])},oa.scale.threshold=function(){return ci([.5],[0,1])},oa.scale.identity=function(){return si([0,1])},oa.svg={},oa.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),c=Math.max(0,+r.apply(this,arguments)),s=a.apply(this,arguments)-Ha,f=o.apply(this,arguments)-Ha,h=Math.abs(f-s),g=s>f?0:1;if(n>c&&(p=c,c=n,n=p),h>=Fa)return t(c,g)+(n?t(n,1-g):"")+"Z";var p,v,d,m,y,M,x,b,_,w,S,k,N=0,E=0,A=[];if((m=(+l.apply(this,arguments)||0)/2)&&(d=i===Ll?Math.sqrt(n*n+c*c):+i.apply(this,arguments),g||(E*=-1),c&&(E=tn(d/c*Math.sin(m))),n&&(N=tn(d/n*Math.sin(m)))),c){y=c*Math.cos(s+E),M=c*Math.sin(s+E),x=c*Math.cos(f-E),b=c*Math.sin(f-E);var C=Math.abs(f-s-2*E)<=ja?0:1;if(E&&mi(y,M,x,b)===g^C){var z=(s+f)/2;y=c*Math.cos(z),M=c*Math.sin(z),x=b=null}}else y=M=0;if(n){_=n*Math.cos(f-N),w=n*Math.sin(f-N),S=n*Math.cos(s+N),k=n*Math.sin(s+N);var L=Math.abs(s-f+2*N)<=ja?0:1;if(N&&mi(_,w,S,k)===1-g^L){var q=(s+f)/2;_=n*Math.cos(q),w=n*Math.sin(q),S=k=null}}else _=w=0;if(h>Da&&(p=Math.min(Math.abs(c-n)/2,+u.apply(this,arguments)))>.001){v=c>n^g?0:1;var T=p,R=p;if(ja>h){var D=null==S?[_,w]:null==x?[y,M]:Re([y,M],[S,k],[x,b],[_,w]),P=y-D[0],j=M-D[1],U=x-D[0],F=b-D[1],H=1/Math.sin(Math.acos((P*U+j*F)/(Math.sqrt(P*P+j*j)*Math.sqrt(U*U+F*F)))/2),O=Math.sqrt(D[0]*D[0]+D[1]*D[1]);R=Math.min(p,(n-O)/(H-1)),T=Math.min(p,(c-O)/(H+1))}if(null!=x){var I=yi(null==S?[_,w]:[S,k],[y,M],c,T,g),Y=yi([x,b],[_,w],c,T,g);p===T?A.push("M",I[0],"A",T,",",T," 0 0,",v," ",I[1],"A",c,",",c," 0 ",1-g^mi(I[1][0],I[1][1],Y[1][0],Y[1][1]),",",g," ",Y[1],"A",T,",",T," 0 0,",v," ",Y[0]):A.push("M",I[0],"A",T,",",T," 0 1,",v," ",Y[0])}else A.push("M",y,",",M);if(null!=S){var Z=yi([y,M],[S,k],n,-R,g),V=yi([_,w],null==x?[y,M]:[x,b],n,-R,g);p===R?A.push("L",V[0],"A",R,",",R," 0 0,",v," ",V[1],"A",n,",",n," 0 ",g^mi(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-g," ",Z[1],"A",R,",",R," 0 0,",v," ",Z[0]):A.push("L",V[0],"A",R,",",R," 0 0,",v," ",Z[0])}else A.push("L",_,",",w)}else A.push("M",y,",",M),null!=x&&A.push("A",c,",",c," 0 ",C,",",g," ",x,",",b),A.push("L",_,",",w),null!=S&&A.push("A",n,",",n," 0 ",L,",",1-g," ",S,",",k);return A.push("Z"),A.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=hi,r=gi,u=fi,i=Ll,a=pi,o=vi,l=di;return n.innerRadius=function(t){return arguments.length?(e=En(t),n):e},n.outerRadius=function(t){return arguments.length?(r=En(t),n):r},n.cornerRadius=function(t){return arguments.length?(u=En(t),n):u},n.padRadius=function(t){return arguments.length?(i=t==Ll?Ll:En(t),n):i},n.startAngle=function(t){return arguments.length?(a=En(t),n):a},n.endAngle=function(t){return arguments.length?(o=En(t),n):o},n.padAngle=function(t){return arguments.length?(l=En(t),n):l},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+a.apply(this,arguments)+ +o.apply(this,arguments))/2-Ha;return[Math.cos(t)*n,Math.sin(t)*n]},n};var Ll="auto";oa.svg.line=function(){return Mi(y)};var ql=oa.map({linear:xi,"linear-closed":bi,step:_i,"step-before":wi,"step-after":Si,basis:zi,"basis-open":Li,"basis-closed":qi,bundle:Ti,cardinal:Ei,"cardinal-open":ki,"cardinal-closed":Ni,monotone:Fi});ql.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Tl=[0,2/3,1/3,0],Rl=[0,1/3,2/3,0],Dl=[0,1/6,2/3,1/6];oa.svg.line.radial=function(){var n=Mi(Hi);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},wi.reverse=Si,Si.reverse=wi,oa.svg.area=function(){return Oi(y)},oa.svg.area.radial=function(){var n=Oi(Hi);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},oa.svg.chord=function(){function n(n,o){var l=t(this,i,n,o),c=t(this,a,n,o);return"M"+l.p0+r(l.r,l.p1,l.a1-l.a0)+(e(l,c)?u(l.r,l.p1,l.r,l.p0):u(l.r,l.p1,c.r,c.p0)+r(c.r,c.p1,c.a1-c.a0)+u(c.r,c.p1,l.r,l.p0))+"Z"}function t(n,t,e,r){var u=t.call(n,e,r),i=o.call(n,u,r),a=l.call(n,u,r)-Ha,s=c.call(n,u,r)-Ha;return{r:i,a0:a,a1:s,p0:[i*Math.cos(a),i*Math.sin(a)],p1:[i*Math.cos(s),i*Math.sin(s)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>ja)+",1 "+t}function u(n,t,e,r){return"Q 0,0 "+r}var i=Me,a=xe,o=Ii,l=pi,c=vi;return n.radius=function(t){return arguments.length?(o=En(t),n):o},n.source=function(t){return arguments.length?(i=En(t),n):i},n.target=function(t){return arguments.length?(a=En(t),n):a},n.startAngle=function(t){return arguments.length?(l=En(t),n):l},n.endAngle=function(t){return arguments.length?(c=En(t),n):c},n},oa.svg.diagonal=function(){function n(n,u){var i=t.call(this,n,u),a=e.call(this,n,u),o=(i.y+a.y)/2,l=[i,{x:i.x,y:o},{x:a.x,y:o},a];return l=l.map(r),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var t=Me,e=xe,r=Yi;return n.source=function(e){return arguments.length?(t=En(e),n):t},n.target=function(t){return arguments.length?(e=En(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},oa.svg.diagonal.radial=function(){var n=oa.svg.diagonal(),t=Yi,e=n.projection;return n.projection=function(n){return arguments.length?e(Zi(t=n)):t},n},oa.svg.symbol=function(){function n(n,r){return(Pl.get(t.call(this,n,r))||$i)(e.call(this,n,r))}var t=Xi,e=Vi;return n.type=function(e){return arguments.length?(t=En(e),n):t},n.size=function(t){return arguments.length?(e=En(t),n):e},n};var Pl=oa.map({circle:$i,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Ul)),e=t*Ul;return"M0,"+-t+"L"+e+",0 0,"+t+" "+-e+",0Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/jl),e=t*jl/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/jl),e=t*jl/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});oa.svg.symbolTypes=Pl.keys();var jl=Math.sqrt(3),Ul=Math.tan(30*Oa);Aa.transition=function(n){for(var t,e,r=Fl||++Yl,u=Ki(n),i=[],a=Hl||{time:Date.now(),ease:Nr,delay:0,duration:250},o=-1,l=this.length;++oi;i++){u.push(t=[]);for(var e=this[i],o=0,l=e.length;l>o;o++)(r=e[o])&&n.call(r,r.__data__,o,i)&&t.push(r)}return Wi(u,this.namespace,this.id)},Il.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):Y(this,null==t?function(t){t[r][e].tween.remove(n)}:function(u){u[r][e].tween.set(n,t)})},Il.attr=function(n,t){function e(){this.removeAttribute(o)}function r(){this.removeAttributeNS(o.space,o.local)}function u(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(o);return e!==n&&(t=a(e,n),function(n){this.setAttribute(o,t(n))})})}function i(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(o.space,o.local);return e!==n&&(t=a(e,n),function(n){this.setAttributeNS(o.space,o.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var a="transform"==n?$r:Mr,o=oa.ns.qualify(n);return Ji(this,"attr."+n,t,o.local?i:u)},Il.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(u));return r&&function(n){this.setAttribute(u,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(u.space,u.local));return r&&function(n){this.setAttributeNS(u.space,u.local,r(n))}}var u=oa.ns.qualify(n);return this.tween("attr."+n,u.local?r:e)},Il.style=function(n,e,r){function u(){this.style.removeProperty(n)}function i(e){return null==e?u:(e+="",function(){var u,i=t(this).getComputedStyle(this,null).getPropertyValue(n);return i!==e&&(u=Mr(i,e),function(t){this.style.setProperty(n,u(t),r)})})}var a=arguments.length;if(3>a){if("string"!=typeof n){2>a&&(e="");for(r in n)this.style(r,n[r],e);return this}r=""}return Ji(this,"style."+n,e,i)},Il.styleTween=function(n,e,r){function u(u,i){var a=e.call(this,u,i,t(this).getComputedStyle(this,null).getPropertyValue(n));return a&&function(t){this.style.setProperty(n,a(t),r)}}return arguments.length<3&&(r=""),this.tween("style."+n,u)},Il.text=function(n){return Ji(this,"text",n,Gi)},Il.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Il.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=oa.ease.apply(oa,arguments)),Y(this,function(r){r[e][t].ease=n}))},Il.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:Y(this,"function"==typeof n?function(r,u,i){r[e][t].delay=+n.call(r,r.__data__,u,i)}:(n=+n,function(r){r[e][t].delay=n}))},Il.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:Y(this,"function"==typeof n?function(r,u,i){r[e][t].duration=Math.max(1,n.call(r,r.__data__,u,i))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Il.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var u=Hl,i=Fl;try{Fl=e,Y(this,function(t,u,i){Hl=t[r][e],n.call(t,t.__data__,u,i)})}finally{Hl=u,Fl=i}}else Y(this,function(u){var i=u[r][e];(i.event||(i.event=oa.dispatch("start","end","interrupt"))).on(n,t)});return this},Il.transition=function(){for(var n,t,e,r,u=this.id,i=++Yl,a=this.namespace,o=[],l=0,c=this.length;c>l;l++){o.push(n=[]);for(var t=this[l],s=0,f=t.length;f>s;s++)(e=t[s])&&(r=e[a][u],Qi(e,s,a,i,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),n.push(e)}return Wi(o,a,i)},oa.svg.axis=function(){function n(n){n.each(function(){var n,c=oa.select(this),s=this.__chart__||e,f=this.__chart__=e.copy(),h=null==l?f.ticks?f.ticks.apply(f,o):f.domain():l,g=null==t?f.tickFormat?f.tickFormat.apply(f,o):y:t,p=c.selectAll(".tick").data(h,f),v=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Da),d=oa.transition(p.exit()).style("opacity",Da).remove(),m=oa.transition(p.order()).style("opacity",1),M=Math.max(u,0)+a,x=Zu(f),b=c.selectAll(".domain").data([0]),_=(b.enter().append("path").attr("class","domain"),oa.transition(b));v.append("line"),v.append("text");var w,S,k,N,E=v.select("line"),A=m.select("line"),C=p.select("text").text(g),z=v.select("text"),L=m.select("text"),q="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=na,w="x",k="y",S="x2",N="y2",C.attr("dy",0>q?"0em":".71em").style("text-anchor","middle"),_.attr("d","M"+x[0]+","+q*i+"V0H"+x[1]+"V"+q*i)):(n=ta,w="y",k="x",S="y2",N="x2",C.attr("dy",".32em").style("text-anchor",0>q?"end":"start"),_.attr("d","M"+q*i+","+x[0]+"H0V"+x[1]+"H"+q*i)),E.attr(N,q*u),z.attr(k,q*M),A.attr(S,0).attr(N,q*u),L.attr(w,0).attr(k,q*M),f.rangeBand){var T=f,R=T.rangeBand()/2;s=f=function(n){return T(n)+R}}else s.rangeBand?s=f:d.call(n,f,s);v.call(n,s,f),m.call(n,f,f)})}var t,e=oa.scale.linear(),r=Zl,u=6,i=6,a=3,o=[10],l=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Vl?t+"":Zl,n):r},n.ticks=function(){return arguments.length?(o=ca(arguments),n):o},n.tickValues=function(t){return arguments.length?(l=t,n):l},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(u=+t,i=+arguments[e-1],n):u},n.innerTickSize=function(t){return arguments.length?(u=+t,n):u},n.outerTickSize=function(t){return arguments.length?(i=+t,n):i},n.tickPadding=function(t){return arguments.length?(a=+t,n):a},n.tickSubdivide=function(){return arguments.length&&n},n};var Zl="bottom",Vl={top:1,right:1,bottom:1,left:1};oa.svg.brush=function(){function n(t){t.each(function(){var t=oa.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",i).on("touchstart.brush",i),a=t.selectAll(".background").data([0]);a.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),t.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var o=t.selectAll(".resize").data(v,y);o.exit().remove(),o.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return Xl[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),o.style("display",n.empty()?"none":null);var l,f=oa.transition(t),h=oa.transition(a);c&&(l=Zu(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(f)),s&&(l=Zu(s),h.attr("y",l[0]).attr("height",l[1]-l[0]),u(f)),e(f)})}function e(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+f[+/e$/.test(n)]+","+h[+/^s/.test(n)]+")"})}function r(n){n.select(".extent").attr("x",f[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function u(n){n.select(".extent").attr("y",h[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function i(){function i(){32==oa.event.keyCode&&(C||(M=null,L[0]-=f[1],L[1]-=h[1],C=2),S())}function v(){32==oa.event.keyCode&&2==C&&(L[0]+=f[1],L[1]+=h[1],C=0,S())}function d(){var n=oa.mouse(b),t=!1;x&&(n[0]+=x[0],n[1]+=x[1]),C||(oa.event.altKey?(M||(M=[(f[0]+f[1])/2,(h[0]+h[1])/2]),L[0]=f[+(n[0]s?(u=r,r=s):u=s),v[0]!=r||v[1]!=u?(e?o=null:a=null,v[0]=r,v[1]=u,!0):void 0}function y(){d(),k.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),oa.select("body").style("cursor",null),q.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),z(),w({type:"brushend"})}var M,x,b=this,_=oa.select(oa.event.target),w=l.of(b,arguments),k=oa.select(b),N=_.datum(),E=!/^(n|s)$/.test(N)&&c,A=!/^(e|w)$/.test(N)&&s,C=_.classed("extent"),z=W(b),L=oa.mouse(b),q=oa.select(t(b)).on("keydown.brush",i).on("keyup.brush",v);if(oa.event.changedTouches?q.on("touchmove.brush",d).on("touchend.brush",y):q.on("mousemove.brush",d).on("mouseup.brush",y),k.interrupt().selectAll("*").interrupt(),C)L[0]=f[0]-L[0],L[1]=h[0]-L[1];else if(N){var T=+/w$/.test(N),R=+/^n/.test(N);x=[f[1-T]-L[0],h[1-R]-L[1]],L[0]=f[T],L[1]=h[R]}else oa.event.altKey&&(M=L.slice());k.style("pointer-events","none").selectAll(".resize").style("display",null),oa.select("body").style("cursor",_.style("cursor")),w({type:"brushstart"}),d()}var a,o,l=N(n,"brushstart","brush","brushend"),c=null,s=null,f=[0,0],h=[0,0],g=!0,p=!0,v=$l[0];return n.event=function(n){n.each(function(){var n=l.of(this,arguments),t={x:f,y:h,i:a,j:o},e=this.__chart__||t;this.__chart__=t,Fl?oa.select(this).transition().each("start.brush",function(){a=e.i,o=e.j,f=e.x,h=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=xr(f,t.x),r=xr(h,t.y);return a=o=null,function(u){f=t.x=e(u),h=t.y=r(u),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){a=t.i,o=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,v=$l[!c<<1|!s],n):c},n.y=function(t){return arguments.length?(s=t,v=$l[!c<<1|!s],n):s},n.clamp=function(t){return arguments.length?(c&&s?(g=!!t[0],p=!!t[1]):c?g=!!t:s&&(p=!!t),n):c&&s?[g,p]:c?g:s?p:null},n.extent=function(t){var e,r,u,i,l;return arguments.length?(c&&(e=t[0],r=t[1],s&&(e=e[0],r=r[0]),a=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(l=e,e=r,r=l),(e!=f[0]||r!=f[1])&&(f=[e,r])),s&&(u=t[0],i=t[1],c&&(u=u[1],i=i[1]),o=[u,i],s.invert&&(u=s(u),i=s(i)),u>i&&(l=u,u=i,i=l),(u!=h[0]||i!=h[1])&&(h=[u,i])),n):(c&&(a?(e=a[0],r=a[1]):(e=f[0],r=f[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(l=e,e=r,r=l))),s&&(o?(u=o[0],i=o[1]):(u=h[0],i=h[1],s.invert&&(u=s.invert(u),i=s.invert(i)),u>i&&(l=u,u=i,i=l))),c&&s?[[e,u],[r,i]]:c?[e,r]:s&&[u,i])},n.clear=function(){return n.empty()||(f=[0,0],h=[0,0],a=o=null),n},n.empty=function(){return!!c&&f[0]==f[1]||!!s&&h[0]==h[1]},oa.rebind(n,l,"on")};var Xl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},$l=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Bl=ho.format=Mo.timeFormat,Wl=Bl.utc,Jl=Wl("%Y-%m-%dT%H:%M:%S.%LZ");Bl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?ea:Jl,ea.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},ea.toString=Jl.toString,ho.second=On(function(n){return new go(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),ho.seconds=ho.second.range,ho.seconds.utc=ho.second.utc.range,ho.minute=On(function(n){return new go(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),ho.minutes=ho.minute.range,ho.minutes.utc=ho.minute.utc.range,ho.hour=On(function(n){var t=n.getTimezoneOffset()/60;return new go(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),ho.hours=ho.hour.range,ho.hours.utc=ho.hour.utc.range,ho.month=On(function(n){return n=ho.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),ho.months=ho.month.range,ho.months.utc=ho.month.utc.range;var Gl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Kl=[[ho.second,1],[ho.second,5],[ho.second,15],[ho.second,30],[ho.minute,1],[ho.minute,5],[ho.minute,15],[ho.minute,30],[ho.hour,1],[ho.hour,3],[ho.hour,6],[ho.hour,12],[ho.day,1],[ho.day,2],[ho.week,1],[ho.month,1],[ho.month,3],[ho.year,1]],Ql=Bl.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",zt]]),nc={range:function(n,t,e){return oa.range(Math.ceil(n/e)*e,+t,e).map(ua)},floor:y,ceil:y};Kl.year=ho.year,ho.scale=function(){return ra(oa.scale.linear(),Kl,Ql)};var tc=Kl.map(function(n){return[n[0].utc,n[1]]}),ec=Wl.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",zt]]);tc.year=ho.year.utc,ho.scale.utc=function(){return ra(oa.scale.linear(),tc,ec)},oa.text=An(function(n){return n.responseText}),oa.json=function(n,t){return Cn(n,"application/json",ia,t)},oa.html=function(n,t){return Cn(n,"text/html",aa,t)},oa.xml=An(function(n){return n.responseXML}),"function"==typeof define&&define.amd?(this.d3=oa,define(oa)):"object"==typeof module&&module.exports?module.exports=oa:this.d3=oa}(); diff --git a/confluence-plugin/src/main/typescript/src/lib/dagre-d3.min.js b/confluence-plugin/src/main/typescript/src/lib/dagre-d3.min.js new file mode 100644 index 0000000..24873e5 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/lib/dagre-d3.min.js @@ -0,0 +1,27 @@ +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.dagreD3=t()}}(function(){var t;return function n(t,e,r){function i(a,u){if(!e[a]){if(!t[a]){var c="function"==typeof require&&require;if(!u&&c)return c(a,!0);if(o)return o(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var f=e[a]={exports:{}};t[a][0].call(f.exports,function(n){var e=t[a][1][n];return i(e?e:n)},f,f.exports,n,t,e,r)}return e[a].exports}for(var o="function"==typeof require&&require,a=0;ay?(y-v)/g:(y+v)/g,y=a*s-o*f,m=0>y?(y-v)/g:(y+v)/g,{x:_,y:m})}function i(t,n){return t*n>0}n.exports=r},{}],14:[function(t,n,e){function r(t,n){return t.intersect(n)}n.exports=r},{}],15:[function(t,n,e){function r(t,n,e){var r=t.x,o=t.y,a=[],u=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY;n.forEach(function(t){u=Math.min(u,t.x),c=Math.min(c,t.y)});for(var s=r-t.width/2-u,f=o-t.height/2-c,l=0;l1&&a.sort(function(t,n){var r=t.x-e.x,i=t.y-e.y,o=Math.sqrt(r*r+i*i),a=n.x-e.x,u=n.y-e.y,c=Math.sqrt(a*a+u*u);return c>o?-1:o===c?0:1}),a[0]):(console.log("NO INTERSECTION FOUND, RETURN NODE CENTER",t),t)}var i=t("./intersect-line");n.exports=r},{"./intersect-line":13}],16:[function(t,n,e){function r(t,n){var e,r,i=t.x,o=t.y,a=n.x-i,u=n.y-o,c=t.width/2,s=t.height/2;return Math.abs(u)*c>Math.abs(a)*s?(0>u&&(s=-s),e=0===u?0:s*a/u,r=s):(0>a&&(c=-c),e=c,r=0===a?0:c*u/a),{x:i+e,y:o+r}}n.exports=r},{}],17:[function(t,n,e){function r(t,n){var e=t.append("foreignObject").attr("width","100000"),r=e.append("xhtml:div");r.attr("xmlns","http://www.w3.org/1999/xhtml");var o=n.label;switch(typeof o){case"function":r.insert(o);break;case"object":r.insert(function(){return o});break;default:r.html(o)}i.applyStyle(r,n.labelStyle),r.style("display","inline-block"),r.style("white-space","nowrap");var a=r[0][0].getBoundingClientRect();return e.attr("width",a.width).attr("height",a.height),e}var i=t("../util");n.exports=r},{"../util":27}],18:[function(t,n,e){function r(t,n,e){var r=n.label,u=t.append("g");"svg"===n.labelType?a(u,n):"string"!=typeof r||"html"===n.labelType?o(u,n):i(u,n);var c,s=u.node().getBBox();switch(e){case"top":c=-n.height/2;break;case"bottom":c=n.height/2-s.height;break;default:c=-s.height/2}return u.attr("transform","translate("+-s.width/2+","+c+")"),u}var i=t("./add-text-label"),o=t("./add-html-label"),a=t("./add-svg-label");n.exports=r},{"./add-html-label":17,"./add-svg-label":19,"./add-text-label":20}],19:[function(t,n,e){function r(t,n){var e=t;return e.node().appendChild(n.label),i.applyStyle(e,n.labelStyle),e}var i=t("../util");n.exports=r},{"../util":27}],20:[function(t,n,e){function r(t,n){for(var e=t.append("text"),r=i(n.label).split("\n"),a=0;au;++u)i(t,"borderLeft","_bl",e,a,u),i(t,"borderRight","_br",e,a,u)}}o.each(t.children(),n)}function i(t,n,e,r,i,o){var u={width:0,height:0,rank:o,borderType:n},c=i[n][o-1],s=a.addDummyNode(t,"border",u,e);i[n][o]=s,t.setParent(s,r),c&&t.setEdge(c,s,{weight:1})}var o=t("./lodash"),a=t("./util");n.exports=r},{"./lodash":38,"./util":57}],32:[function(t,n,e){"use strict";function r(t){var n=t.graph().rankdir.toLowerCase();("lr"===n||"rl"===n)&&o(t)}function i(t){var n=t.graph().rankdir.toLowerCase();("bt"===n||"rl"===n)&&u(t),("lr"===n||"rl"===n)&&(s(t),o(t))}function o(t){l.each(t.nodes(),function(n){a(t.node(n))}),l.each(t.edges(),function(n){a(t.edge(n))})}function a(t){var n=t.width;t.width=t.height,t.height=n}function u(t){l.each(t.nodes(),function(n){c(t.node(n))}),l.each(t.edges(),function(n){var e=t.edge(n);l.each(e.points,c),l.has(e,"y")&&c(e)})}function c(t){t.y=-t.y}function s(t){l.each(t.nodes(),function(n){f(t.node(n))}),l.each(t.edges(),function(n){var e=t.edge(n);l.each(e.points,f),l.has(e,"x")&&f(e)})}function f(t){var n=t.x;t.x=t.y,t.y=n}var l=t("./lodash");n.exports={adjust:r,undo:i}},{"./lodash":38}],33:[function(t,n,e){function r(){var t={};t._next=t._prev=t,this._sentinel=t}function i(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function o(t,n){return"_next"!==t&&"_prev"!==t?n:void 0}n.exports=r,r.prototype.dequeue=function(){var t=this._sentinel,n=t._prev;return n!==t?(i(n),n):void 0},r.prototype.enqueue=function(t){var n=this._sentinel;t._prev&&t._next&&i(t),t._next=n._next,n._next._prev=t,n._next=t,t._prev=n},r.prototype.toString=function(){for(var t=[],n=this._sentinel,e=n._prev;e!==n;)t.push(JSON.stringify(e,o)),e=e._prev;return"["+t.join(", ")+"]"}},{}],34:[function(t,n,e){function r(t){var n=o.buildLayerMatrix(t),e=new a({compound:!0,multigraph:!0}).setGraph({});return i.each(t.nodes(),function(n){e.setNode(n,{label:n}),e.setParent(n,"layer"+t.node(n).rank)}),i.each(t.edges(),function(t){e.setEdge(t.v,t.w,{},t.name)}),i.each(n,function(t,n){var r="layer"+n;e.setNode(r,{rank:"same"}),i.reduce(t,function(t,n){return e.setEdge(t,n,{style:"invis"}),n})}),e}var i=t("./lodash"),o=t("./util"),a=t("./graphlib").Graph;n.exports={debugOrdering:r}},{"./graphlib":35,"./lodash":38,"./util":57}],35:[function(t,n,e){arguments[4][9][0].apply(e,arguments)},{dup:9,graphlib:59}],36:[function(t,n,e){function r(t,n){if(t.nodeCount()<=1)return[];var e=a(t,n||l),r=i(e.graph,e.buckets,e.zeroIdx);return c.flatten(c.map(r,function(n){return t.outEdges(n.v,n.w)}),!0)}function i(t,n,e){for(var r,i=[],a=n[n.length-1],u=n[0];t.nodeCount();){for(;r=u.dequeue();)o(t,n,e,r);for(;r=a.dequeue();)o(t,n,e,r);if(t.nodeCount())for(var c=n.length-2;c>0;--c)if(r=n[c].dequeue()){i=i.concat(o(t,n,e,r,!0));break}}return i}function o(t,n,e,r,i){var o=i?[]:void 0;return c.each(t.inEdges(r.v),function(r){var a=t.edge(r),c=t.node(r.v);i&&o.push({v:r.v,w:r.w}),c.out-=a,u(n,e,c)}),c.each(t.outEdges(r.v),function(r){var i=t.edge(r),o=r.w,a=t.node(o);a["in"]-=i,u(n,e,a)}),t.removeNode(r.v),o}function a(t,n){var e=new s,r=0,i=0;c.each(t.nodes(),function(t){e.setNode(t,{v:t,"in":0,out:0})}),c.each(t.edges(),function(t){var o=e.edge(t.v,t.w)||0,a=n(t),u=o+a;e.setEdge(t.v,t.w,u),i=Math.max(i,e.node(t.v).out+=a),r=Math.max(r,e.node(t.w)["in"]+=a)});var o=c.range(i+r+3).map(function(){return new f}),a=r+1;return c.each(e.nodes(),function(t){u(o,a,e.node(t))}),{graph:e,buckets:o,zeroIdx:a}}function u(t,n,e){e.out?e["in"]?t[e.out-e["in"]+n].enqueue(e):t[t.length-1].enqueue(e):t[0].enqueue(e)}var c=t("./lodash"),s=t("./graphlib").Graph,f=t("./data/list");n.exports=r;var l=c.constant(1)},{"./data/list":33,"./graphlib":35,"./lodash":38}],37:[function(t,n,e){"use strict";function r(t,n){var e=n&&n.debugTiming?O.time:O.notime;e("layout",function(){var n=e(" buildLayoutGraph",function(){return a(t)});e(" runLayout",function(){i(n,e)}),e(" updateInputGraph",function(){o(t,n)})})}function i(t,n){n(" makeSpaceForEdgeLabels",function(){u(t)}),n(" removeSelfEdges",function(){v(t)}),n(" acyclic",function(){x.run(t)}),n(" nestingGraph.run",function(){j.run(t)}),n(" rank",function(){E(O.asNonCompoundGraph(t))}),n(" injectEdgeLabelProxies",function(){c(t)}),n(" removeEmptyRanks",function(){C(t)}),n(" nestingGraph.cleanup",function(){j.cleanup(t)}),n(" normalizeRanks",function(){I(t)}),n(" assignRankMinMax",function(){s(t)}),n(" removeEdgeLabelProxies",function(){f(t)}),n(" normalize.run",function(){k.run(t)}),n(" parentDummyChains",function(){N(t)}),n(" addBorderSegments",function(){R(t)}),n(" order",function(){L(t)}),n(" insertSelfEdges",function(){y(t)}),n(" adjustCoordinateSystem",function(){T.adjust(t)}),n(" position",function(){A(t)}),n(" positionSelfEdges",function(){_(t)}),n(" removeBorderNodes",function(){g(t)}),n(" normalize.undo",function(){k.undo(t)}),n(" fixupEdgeLabelCoords",function(){d(t)}),n(" undoCoordinateSystem",function(){T.undo(t)}),n(" translateGraph",function(){l(t)}),n(" assignNodeIntersects",function(){h(t)}),n(" reversePoints",function(){p(t)}),n(" acyclic.undo",function(){x.undo(t)})}function o(t,n){b.each(t.nodes(),function(e){var r=t.node(e),i=n.node(e);r&&(r.x=i.x,r.y=i.y,n.children(e).length&&(r.width=i.width,r.height=i.height))}),b.each(t.edges(),function(e){var r=t.edge(e),i=n.edge(e);r.points=i.points,b.has(i,"x")&&(r.x=i.x,r.y=i.y)}),t.graph().width=n.graph().width,t.graph().height=n.graph().height}function a(t){var n=new S({multigraph:!0,compound:!0}),e=w(t.graph());return n.setGraph(b.merge({},B,m(e,M),b.pick(e,U))),b.each(t.nodes(),function(e){var r=w(t.node(e));n.setNode(e,b.defaults(m(r,P),F)),n.setParent(e,t.parent(e))}),b.each(t.edges(),function(e){var r=w(t.edge(e));n.setEdge(e,b.merge({},W,m(r,D),b.pick(r,z)))}),n}function u(t){var n=t.graph();n.ranksep/=2,b.each(t.edges(),function(e){var r=t.edge(e);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===n.rankdir||"BT"===n.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function c(t){b.each(t.edges(),function(n){var e=t.edge(n);if(e.width&&e.height){var r=t.node(n.v),i=t.node(n.w),o={rank:(i.rank-r.rank)/2+r.rank,e:n};O.addDummyNode(t,"edge-proxy",o,"_ep")}})}function s(t){var n=0;b.each(t.nodes(),function(e){var r=t.node(e);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,n=b.max(n,r.maxRank))}),t.graph().maxRank=n}function f(t){b.each(t.nodes(),function(n){var e=t.node(n);"edge-proxy"===e.dummy&&(t.edge(e.e).labelRank=e.rank,t.removeNode(n))})}function l(t){function n(t){var n=t.x,a=t.y,u=t.width,c=t.height;e=Math.min(e,n-u/2),r=Math.max(r,n+u/2),i=Math.min(i,a-c/2),o=Math.max(o,a+c/2)}var e=Number.POSITIVE_INFINITY,r=0,i=Number.POSITIVE_INFINITY,o=0,a=t.graph(),u=a.marginx||0,c=a.marginy||0;b.each(t.nodes(),function(e){n(t.node(e))}),b.each(t.edges(),function(e){var r=t.edge(e);b.has(r,"x")&&n(r)}),e-=u,i-=c,b.each(t.nodes(),function(n){var r=t.node(n);r.x-=e,r.y-=i}),b.each(t.edges(),function(n){var r=t.edge(n);b.each(r.points,function(t){t.x-=e,t.y-=i}),b.has(r,"x")&&(r.x-=e),b.has(r,"y")&&(r.y-=i)}),a.width=r-e+u,a.height=o-i+c}function h(t){b.each(t.edges(),function(n){var e,r,i=t.edge(n),o=t.node(n.v),a=t.node(n.w);i.points?(e=i.points[0],r=i.points[i.points.length-1]):(i.points=[],e=a,r=o),i.points.unshift(O.intersectRect(o,e)),i.points.push(O.intersectRect(a,r))})}function d(t){b.each(t.edges(),function(n){var e=t.edge(n);if(b.has(e,"x"))switch(("l"===e.labelpos||"r"===e.labelpos)&&(e.width-=e.labeloffset),e.labelpos){case"l":e.x-=e.width/2+e.labeloffset;break;case"r":e.x+=e.width/2+e.labeloffset}})}function p(t){b.each(t.edges(),function(n){var e=t.edge(n);e.reversed&&e.points.reverse()})}function g(t){b.each(t.nodes(),function(n){if(t.children(n).length){var e=t.node(n),r=t.node(e.borderTop),i=t.node(e.borderBottom),o=t.node(b.last(e.borderLeft)),a=t.node(b.last(e.borderRight));e.width=Math.abs(a.x-o.x),e.height=Math.abs(i.y-r.y),e.x=o.x+e.width/2,e.y=r.y+e.height/2}}),b.each(t.nodes(),function(n){"border"===t.node(n).dummy&&t.removeNode(n)})}function v(t){b.each(t.edges(),function(n){if(n.v===n.w){var e=t.node(n.v);e.selfEdges||(e.selfEdges=[]),e.selfEdges.push({e:n,label:t.edge(n)}),t.removeEdge(n)}})}function y(t){var n=O.buildLayerMatrix(t);b.each(n,function(n){var e=0;b.each(n,function(n,r){var i=t.node(n);i.order=r+e,b.each(i.selfEdges,function(n){O.addDummyNode(t,"selfedge",{width:n.label.width,height:n.label.height,rank:i.rank,order:r+ ++e,e:n.e,label:n.label},"_se")}),delete i.selfEdges})})}function _(t){b.each(t.nodes(),function(n){var e=t.node(n);if("selfedge"===e.dummy){var r=t.node(e.e.v),i=r.x+r.width/2,o=r.y,a=e.x-i,u=r.height/2;t.setEdge(e.e,e.label),t.removeNode(n),e.label.points=[{x:i+2*a/3,y:o-u},{x:i+5*a/6,y:o-u},{x:i+a,y:o},{x:i+5*a/6,y:o+u},{x:i+2*a/3,y:o+u}],e.label.x=e.x,e.label.y=e.y}})}function m(t,n){return b.mapValues(b.pick(t,n),Number)}function w(t){var n={};return b.each(t,function(t,e){n[e.toLowerCase()]=t}),n}var b=t("./lodash"),x=t("./acyclic"),k=t("./normalize"),E=t("./rank"),I=t("./util").normalizeRanks,N=t("./parent-dummy-chains"),C=t("./util").removeEmptyRanks,j=t("./nesting-graph"),R=t("./add-border-segments"),T=t("./coordinate-system"),L=t("./order"),A=t("./position"),O=t("./util"),S=t("./graphlib").Graph;n.exports=r;var M=["nodesep","edgesep","ranksep","marginx","marginy"],B={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},U=["acyclicer","ranker","rankdir","align"],P=["width","height"],F={width:0,height:0},D=["minlen","weight","width","height","labeloffset"],W={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"]},{"./acyclic":30,"./add-border-segments":31,"./coordinate-system":32,"./graphlib":35,"./lodash":38,"./nesting-graph":39,"./normalize":40,"./order":45,"./parent-dummy-chains":50,"./position":52,"./rank":54,"./util":57}],38:[function(t,n,e){arguments[4][21][0].apply(e,arguments)},{dup:21,lodash:79}],39:[function(t,n,e){function r(t){var n=s.addDummyNode(t,"root",{},"_root"),e=o(t),r=c.max(e)-1,u=2*r+1;t.graph().nestingRoot=n,c.each(t.edges(),function(n){t.edge(n).minlen*=u});var f=a(t)+1;c.each(t.children(),function(o){i(t,n,u,f,r,e,o)}),t.graph().nodeRankFactor=u}function i(t,n,e,r,o,a,u){var f=t.children(u);if(!f.length)return void(u!==n&&t.setEdge(n,u,{weight:0,minlen:e}));var l=s.addBorderNode(t,"_bt"),h=s.addBorderNode(t,"_bb"),d=t.node(u);t.setParent(l,u),d.borderTop=l,t.setParent(h,u),d.borderBottom=h,c.each(f,function(c){i(t,n,e,r,o,a,c);var s=t.node(c),f=s.borderTop?s.borderTop:c,d=s.borderBottom?s.borderBottom:c,p=s.borderTop?r:2*r,g=f!==d?1:o-a[u]+1;t.setEdge(l,f,{weight:p,minlen:g,nestingEdge:!0}),t.setEdge(d,h,{weight:p,minlen:g,nestingEdge:!0})}),t.parent(u)||t.setEdge(n,l,{weight:0,minlen:o+a[u]})}function o(t){function n(r,i){var o=t.children(r);o&&o.length&&c.each(o,function(t){n(t,i+1)}),e[r]=i}var e={};return c.each(t.children(),function(t){n(t,1)}),e}function a(t){return c.reduce(t.edges(),function(n,e){return n+t.edge(e).weight},0)}function u(t){var n=t.graph();t.removeNode(n.nestingRoot),delete n.nestingRoot,c.each(t.edges(),function(n){var e=t.edge(n);e.nestingEdge&&t.removeEdge(n)})}var c=t("./lodash"),s=t("./util");n.exports={run:r,cleanup:u}},{"./lodash":38,"./util":57}],40:[function(t,n,e){"use strict";function r(t){t.graph().dummyChains=[],a.each(t.edges(),function(n){i(t,n)})}function i(t,n){var e=n.v,r=t.node(e).rank,i=n.w,o=t.node(i).rank,a=n.name,c=t.edge(n),s=c.labelRank;if(o!==r+1){t.removeEdge(n);var f,l,h;for(h=0,++r;o>r;++h,++r)c.points=[],l={width:0,height:0,edgeLabel:c,edgeObj:n,rank:r},f=u.addDummyNode(t,"edge",l,"_d"),r===s&&(l.width=c.width,l.height=c.height,l.dummy="edge-label",l.labelpos=c.labelpos),t.setEdge(e,f,{weight:c.weight},a),0===h&&t.graph().dummyChains.push(f),e=f;t.setEdge(e,i,{weight:c.weight},a)}}function o(t){a.each(t.graph().dummyChains,function(n){var e,r=t.node(n),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)e=t.successors(n)[0],t.removeNode(n),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),n=e,r=t.node(n)})}var a=t("./lodash"),u=t("./util");n.exports={run:r,undo:o}},{"./lodash":38,"./util":57}],41:[function(t,n,e){function r(t,n,e){var r,o={};i.each(e,function(e){for(var i,a,u=t.parent(e);u;){if(i=t.parent(u),i?(a=o[i],o[i]=u):(a=r,r=u),a&&a!==u)return void n.setEdge(a,u);u=i}})}var i=t("../lodash");n.exports=r},{"../lodash":38}],42:[function(t,n,e){function r(t,n){return i.map(n,function(n){var e=t.inEdges(n);if(e.length){var r=i.reduce(e,function(n,e){var r=t.edge(e),i=t.node(e.v);return{sum:n.sum+r.weight*i.order,weight:n.weight+r.weight}},{sum:0,weight:0});return{v:n,barycenter:r.sum/r.weight,weight:r.weight}}return{v:n}})}var i=t("../lodash");n.exports=r},{"../lodash":38}],43:[function(t,n,e){function r(t,n,e){var r=i(t),u=new a({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(function(n){return t.node(n)});return o.each(t.nodes(),function(i){var a=t.node(i),c=t.parent(i);(a.rank===n||a.minRank<=n&&n<=a.maxRank)&&(u.setNode(i),u.setParent(i,c||r),o.each(t[e](i),function(n){var e=n.v===i?n.w:n.v,r=u.edge(e,i),a=o.isUndefined(r)?0:r.weight;u.setEdge(e,i,{weight:t.edge(n).weight+a})}),o.has(a,"minRank")&&u.setNode(i,{borderLeft:a.borderLeft[n],borderRight:a.borderRight[n]}))}),u}function i(t){for(var n;t.hasNode(n=o.uniqueId("_root")););return n}var o=t("../lodash"),a=t("../graphlib").Graph;n.exports=r},{"../graphlib":35,"../lodash":38}],44:[function(t,n,e){"use strict";function r(t,n){for(var e=0,r=1;r0;)n%2&&(e+=c[n+1]),n=n-1>>1,c[n]+=t.weight;s+=t.weight*e})),s}var o=t("../lodash");n.exports=r},{"../lodash":38}],45:[function(t,n,e){"use strict";function r(t){var n=p.maxRank(t),e=i(t,u.range(1,n+1),"inEdges"),r=i(t,u.range(n-1,-1,-1),"outEdges"),f=c(t);a(t,f);for(var l,h=Number.POSITIVE_INFINITY,d=0,g=0;4>g;++d,++g){o(d%2?e:r,d%4>=2),f=p.buildLayerMatrix(t);var v=s(t,f);h>v&&(g=0,l=u.cloneDeep(f),h=v)}a(t,l)}function i(t,n,e){return u.map(n,function(n){return l(t,n,e)})}function o(t,n){var e=new d;u.each(t,function(t){var r=t.graph().root,i=f(t,r,e,n);u.each(i.vs,function(n,e){t.node(n).order=e}),h(t,e,i.vs)})}function a(t,n){u.each(n,function(n){u.each(n,function(n,e){t.node(n).order=e})})}var u=t("../lodash"),c=t("./init-order"),s=t("./cross-count"),f=t("./sort-subgraph"),l=t("./build-layer-graph"),h=t("./add-subgraph-constraints"),d=t("../graphlib").Graph,p=t("../util");n.exports=r},{"../graphlib":35,"../lodash":38,"../util":57,"./add-subgraph-constraints":41,"./build-layer-graph":43,"./cross-count":44,"./init-order":46,"./sort-subgraph":48}],46:[function(t,n,e){"use strict"; + + function r(t){function n(r){if(!i.has(e,r)){e[r]=!0;var o=t.node(r);a[o.rank].push(r),i.each(t.successors(r),n)}}var e={},r=i.filter(t.nodes(),function(n){return!t.children(n).length}),o=i.max(i.map(r,function(n){return t.node(n).rank})),a=i.map(i.range(o+1),function(){return[]}),u=i.sortBy(r,function(n){return t.node(n).rank});return i.each(u,n),a}var i=t("../lodash");n.exports=r},{"../lodash":38}],47:[function(t,n,e){"use strict";function r(t,n){var e={};a.each(t,function(t,n){var r=e[t.v]={indegree:0,"in":[],out:[],vs:[t.v],i:n};a.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)}),a.each(n.edges(),function(t){var n=e[t.v],r=e[t.w];a.isUndefined(n)||a.isUndefined(r)||(r.indegree++,n.out.push(e[t.w]))});var r=a.filter(e,function(t){return!t.indegree});return i(r)}function i(t){function n(t){return function(n){n.merged||(a.isUndefined(n.barycenter)||a.isUndefined(t.barycenter)||n.barycenter>=t.barycenter)&&o(t,n)}}function e(n){return function(e){e["in"].push(n),0===--e.indegree&&t.push(e)}}for(var r=[];t.length;){var i=t.pop();r.push(i),a.each(i["in"].reverse(),n(i)),a.each(i.out,e(i))}return a.chain(r).filter(function(t){return!t.merged}).map(function(t){return a.pick(t,["vs","i","barycenter","weight"])}).value()}function o(t,n){var e=0,r=0;t.weight&&(e+=t.barycenter*t.weight,r+=t.weight),n.weight&&(e+=n.barycenter*n.weight,r+=n.weight),t.vs=n.vs.concat(t.vs),t.barycenter=e/r,t.weight=r,t.i=Math.min(n.i,t.i),n.merged=!0}var a=t("../lodash");n.exports=r},{"../lodash":38}],48:[function(t,n,e){function r(t,n,e,f){var l=t.children(n),h=t.node(n),d=h?h.borderLeft:void 0,p=h?h.borderRight:void 0,g={};d&&(l=a.filter(l,function(t){return t!==d&&t!==p}));var v=u(t,l);a.each(v,function(n){if(t.children(n.v).length){var i=r(t,n.v,e,f);g[n.v]=i,a.has(i,"barycenter")&&o(n,i)}});var y=c(v,e);i(y,g);var _=s(y,f);if(d&&(_.vs=a.flatten([d,_.vs,p],!0),t.predecessors(d).length)){var m=t.node(t.predecessors(d)[0]),w=t.node(t.predecessors(p)[0]);a.has(_,"barycenter")||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+m.order+w.order)/(_.weight+2),_.weight+=2}return _}function i(t,n){a.each(t,function(t){t.vs=a.flatten(t.vs.map(function(t){return n[t]?n[t].vs:t}),!0)})}function o(t,n){a.isUndefined(t.barycenter)?(t.barycenter=n.barycenter,t.weight=n.weight):(t.barycenter=(t.barycenter*t.weight+n.barycenter*n.weight)/(t.weight+n.weight),t.weight+=n.weight)}var a=t("../lodash"),u=t("./barycenter"),c=t("./resolve-conflicts"),s=t("./sort");n.exports=r},{"../lodash":38,"./barycenter":42,"./resolve-conflicts":47,"./sort":49}],49:[function(t,n,e){function r(t,n){var e=u.partition(t,function(t){return a.has(t,"barycenter")}),r=e.lhs,c=a.sortBy(e.rhs,function(t){return-t.i}),s=[],f=0,l=0,h=0;r.sort(o(!!n)),h=i(s,c,h),a.each(r,function(t){h+=t.vs.length,s.push(t.vs),f+=t.barycenter*t.weight,l+=t.weight,h=i(s,c,h)});var d={vs:a.flatten(s,!0)};return l&&(d.barycenter=f/l,d.weight=l),d}function i(t,n,e){for(var r;n.length&&(r=a.last(n)).i<=e;)n.pop(),t.push(r.vs),e++;return e}function o(t){return function(n,e){return n.barycentere.barycenter?1:t?e.i-n.i:n.i-e.i}}var a=t("../lodash"),u=t("../util");n.exports=r},{"../lodash":38,"../util":57}],50:[function(t,n,e){function r(t){var n=o(t);a.each(t.graph().dummyChains,function(e){for(var r=t.node(e),o=r.edgeObj,a=i(t,n,o.v,o.w),u=a.path,c=a.lca,s=0,f=u[s],l=!0;e!==o.w;){if(r=t.node(e),l){for(;(f=u[s])!==c&&t.node(f).maxRankc||s>n[i].lim));for(o=i,i=r;(i=t.parent(i))!==o;)u.push(i);return{path:a.concat(u.reverse()),lca:o}}function o(t){function n(i){var o=r;a.each(t.children(i),n),e[i]={low:o,lim:r++}}var e={},r=0;return a.each(t.children(),n),e}var a=t("./lodash");n.exports=r},{"./lodash":38}],51:[function(t,n,e){"use strict";function r(t,n){function e(n,e){var i=0,u=0,c=n.length,s=y.last(e);return y.each(e,function(n,f){var l=o(t,n),h=l?t.node(l).order:c;(l||n===s)&&(y.each(e.slice(u,f+1),function(n){y.each(t.predecessors(n),function(e){var o=t.node(e),u=o.order;!(i>u||u>h)||o.dummy&&t.node(n).dummy||a(r,e,n)})}),u=f+1,i=h)}),e}var r={};return y.reduce(n,e),r}function i(t,n){function e(n,e,r,o,u){var c;y.each(y.range(e,r),function(e){c=n[e],t.node(c).dummy&&y.each(t.predecessors(c),function(n){var e=t.node(n);e.dummy&&(e.orderu)&&a(i,n,c)})})}function r(n,r){var i,o=-1,a=0;return y.each(r,function(u,c){if("border"===t.node(u).dummy){var s=t.predecessors(u);s.length&&(i=t.node(s[0]).order,e(r,a,c,o,i),a=c,o=i)}e(r,a,r.length,i,n.length)}),r}var i={};return y.reduce(n,r),i}function o(t,n){return t.node(n).dummy?y.find(t.predecessors(n),function(n){return t.node(n).dummy}):void 0}function a(t,n,e){if(n>e){var r=n;n=e,e=r}var i=t[n];i||(t[n]=i={}),i[e]=!0}function u(t,n,e){if(n>e){var r=n;n=e,e=r}return y.has(t[n],e)}function c(t,n,e,r){var i={},o={},a={};return y.each(n,function(t){y.each(t,function(t,n){i[t]=t,o[t]=t,a[t]=n})}),y.each(n,function(t){var n=-1;y.each(t,function(t){var c=r(t);if(c.length){c=y.sortBy(c,function(t){return a[t]});for(var s=(c.length-1)/2,f=Math.floor(s),l=Math.ceil(s);l>=f;++f){var h=c[f];o[t]===t&&na.lim&&(u=a,c=!0);var s=g.filter(n.edges(),function(n){return c===p(t,t.node(n.v),u)&&c!==p(t,t.node(n.w),u)});return g.min(s,function(t){return y(n,t)})}function l(t,n,e,r){var o=e.v,a=e.w;t.removeEdge(o,a),t.setEdge(r.v,r.w,{}),u(t),i(t,n),h(t,n)}function h(t,n){var e=g.find(t.nodes(),function(t){return!n.node(t).parent}),r=m(t,e);r=r.slice(1),g.each(r,function(e){var r=t.node(e).parent,i=n.edge(e,r),o=!1;i||(i=n.edge(r,e),o=!0),n.node(e).rank=n.node(r).rank+(o?i.minlen:-i.minlen)})}function d(t,n,e){return t.hasEdge(n,e)}function p(t,n,e){return e.low<=n.lim&&n.lim<=e.lim}var g=t("../lodash"),v=t("./feasible-tree"),y=t("./util").slack,_=t("./util").longestPath,m=t("../graphlib").alg.preorder,w=t("../graphlib").alg.postorder,b=t("../util").simplify;n.exports=r,r.initLowLimValues=u,r.initCutValues=i,r.calcCutValue=a,r.leaveEdge=s,r.enterEdge=f,r.exchangeEdges=l},{"../graphlib":35,"../lodash":38,"../util":57,"./feasible-tree":53,"./util":56}],56:[function(t,n,e){"use strict";function r(t){function n(r){var i=t.node(r);if(o.has(e,r))return i.rank;e[r]=!0;var a=o.min(o.map(t.outEdges(r),function(e){return n(e.w)-t.edge(e).minlen}));return a===Number.POSITIVE_INFINITY&&(a=0),i.rank=a}var e={};o.each(t.sources(),n)}function i(t,n){return t.node(n.w).rank-t.node(n.v).rank-t.edge(n).minlen}var o=t("../lodash");n.exports={longestPath:r,slack:i}},{"../lodash":38}],57:[function(t,n,e){"use strict";function r(t,n,e,r){var i;do i=y.uniqueId(r);while(t.hasNode(i));return e.dummy=n,t.setNode(i,e),i}function i(t){var n=(new _).setGraph(t.graph());return y.each(t.nodes(),function(e){n.setNode(e,t.node(e))}),y.each(t.edges(),function(e){var r=n.edge(e.v,e.w)||{weight:0,minlen:1},i=t.edge(e);n.setEdge(e.v,e.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),n}function o(t){var n=new _({multigraph:t.isMultigraph()}).setGraph(t.graph());return y.each(t.nodes(),function(e){t.children(e).length||n.setNode(e,t.node(e))}),y.each(t.edges(),function(e){n.setEdge(e,t.edge(e))}),n}function a(t){var n=y.map(t.nodes(),function(n){var e={};return y.each(t.outEdges(n),function(n){e[n.w]=(e[n.w]||0)+t.edge(n).weight}),e});return y.zipObject(t.nodes(),n)}function u(t){var n=y.map(t.nodes(),function(n){var e={};return y.each(t.inEdges(n),function(n){e[n.v]=(e[n.v]||0)+t.edge(n).weight}),e});return y.zipObject(t.nodes(),n)}function c(t,n){var e=t.x,r=t.y,i=n.x-e,o=n.y-r,a=t.width/2,u=t.height/2;if(!i&&!o)throw new Error("Not possible to find intersection inside of the rectangle");var c,s;return Math.abs(o)*a>Math.abs(i)*u?(0>o&&(u=-u),c=u*i/o,s=u):(0>i&&(a=-a),c=a,s=a*o/i),{x:e+c,y:r+s}}function s(t){var n=y.map(y.range(d(t)+1),function(){return[]});return y.each(t.nodes(),function(e){var r=t.node(e),i=r.rank;y.isUndefined(i)||(n[i][r.order]=e)}),n}function f(t){var n=y.min(y.map(t.nodes(),function(n){return t.node(n).rank}));y.each(t.nodes(),function(e){var r=t.node(e);y.has(r,"rank")&&(r.rank-=n)})}function l(t){var n=y.min(y.map(t.nodes(),function(n){return t.node(n).rank})),e=[];y.each(t.nodes(),function(r){var i=t.node(r).rank-n;e[i]||(e[i]=[]),e[i].push(r)});var r=0,i=t.graph().nodeRankFactor;y.each(e,function(n,e){y.isUndefined(n)&&e%i!==0?--r:r&&y.each(n,function(n){t.node(n).rank+=r})})}function h(t,n,e,i){var o={width:0,height:0};return arguments.length>=4&&(o.rank=e,o.order=i),r(t,"border",o,n)}function d(t){return y.max(y.map(t.nodes(),function(n){var e=t.node(n).rank;return y.isUndefined(e)?void 0:e}))}function p(t,n){var e={lhs:[],rhs:[]};return y.each(t,function(t){n(t)?e.lhs.push(t):e.rhs.push(t)}),e}function g(t,n){var e=y.now();try{return n()}finally{console.log(t+" time: "+(y.now()-e)+"ms")}}function v(t,n){return n()}var y=t("./lodash"),_=t("./graphlib").Graph;n.exports={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:a,predecessorWeights:u,intersectRect:c,buildLayerMatrix:s,normalizeRanks:f,removeEmptyRanks:l,addBorderNode:h,maxRank:d,partition:p,time:g,notime:v}},{"./graphlib":35,"./lodash":38}],58:[function(t,n,e){n.exports="0.7.3"},{}],59:[function(t,n,e){var r=t("./lib");n.exports={Graph:r.Graph,json:t("./lib/json"),alg:t("./lib/alg"),version:r.version}},{"./lib":75,"./lib/alg":66,"./lib/json":76}],60:[function(t,n,e){function r(t){function n(o){i.has(r,o)||(r[o]=!0,e.push(o),i.each(t.successors(o),n),i.each(t.predecessors(o),n))}var e,r={},o=[];return i.each(t.nodes(),function(t){e=[],n(t),e.length&&o.push(e)}),o}var i=t("../lodash");n.exports=r},{"../lodash":77}],61:[function(t,n,e){function r(t,n,e){o.isArray(n)||(n=[n]);var r=[],a={};return o.each(n,function(n){if(!t.hasNode(n))throw new Error("Graph does not have node: "+n);i(t,n,"post"===e,a,r)}),r}function i(t,n,e,r,a){o.has(r,n)||(r[n]=!0,e||a.push(n),o.each(t.neighbors(n),function(n){i(t,n,e,r,a)}),e&&a.push(n))}var o=t("../lodash");n.exports=r},{"../lodash":77}],62:[function(t,n,e){function r(t,n,e){return o.transform(t.nodes(),function(r,o){r[o]=i(t,o,n,e)},{})}var i=t("./dijkstra"),o=t("../lodash");n.exports=r},{"../lodash":77,"./dijkstra":63}],63:[function(t,n,e){function r(t,n,e,r){return i(t,String(n),e||u,r||function(n){return t.outEdges(n)})}function i(t,n,e,r){var i,o,u={},c=new a,s=function(t){var n=t.v!==i?t.v:t.w,r=u[n],a=e(t),s=o.distance+a;if(0>a)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+a);s0&&(i=c.removeMin(),o=u[i],o.distance!==Number.POSITIVE_INFINITY);)r(i).forEach(s);return u}var o=t("../lodash"),a=t("../data/priority-queue");n.exports=r;var u=o.constant(1)},{"../data/priority-queue":73,"../lodash":77}],64:[function(t,n,e){function r(t){return i.filter(o(t),function(n){return n.length>1||1===n.length&&t.hasEdge(n[0],n[0])})}var i=t("../lodash"),o=t("./tarjan");n.exports=r},{"../lodash":77,"./tarjan":71}],65:[function(t,n,e){function r(t,n,e){return i(t,n||a,e||function(n){return t.outEdges(n)})}function i(t,n,e){var r={},i=t.nodes();return i.forEach(function(t){r[t]={},r[t][t]={distance:0},i.forEach(function(n){t!==n&&(r[t][n]={distance:Number.POSITIVE_INFINITY})}),e(t).forEach(function(e){var i=e.v===t?e.w:e.v,o=n(e);r[t][i]={distance:o,predecessor:t}})}),i.forEach(function(t){var n=r[t];i.forEach(function(e){var o=r[e];i.forEach(function(e){var r=o[t],i=n[e],a=o[e],u=r.distance+i.distance;uo&&(c[e]=r,s.decrease(e,o))}}var r,u=new o,c={},s=new a;if(0===t.nodeCount())return u;i.each(t.nodes(),function(t){s.add(t,Number.POSITIVE_INFINITY),u.setNode(t)}),s.decrease(t.nodes()[0],0);for(var f=!1;s.size()>0;){if(r=s.removeMin(),i.has(c,r))u.setEdge(r,c[r]);else{if(f)throw new Error("Input graph is not connected: "+t);f=!0}t.nodeEdges(r).forEach(e)}return u}var i=t("../lodash"),o=t("../graph"),a=t("../data/priority-queue");n.exports=r},{"../data/priority-queue":73,"../graph":74,"../lodash":77}],71:[function(t,n,e){function r(t){function n(u){var c=o[u]={onStack:!0,lowlink:e,index:e++};if(r.push(u),t.successors(u).forEach(function(t){i.has(o,t)?o[t].onStack&&(c.lowlink=Math.min(c.lowlink,o[t].index)):(n(t),c.lowlink=Math.min(c.lowlink,o[t].lowlink))}),c.lowlink===c.index){var s,f=[];do s=r.pop(),o[s].onStack=!1,f.push(s);while(u!==s);a.push(f)}}var e=0,r=[],o={},a=[];return t.nodes().forEach(function(t){i.has(o,t)||n(t)}),a}var i=t("../lodash");n.exports=r},{"../lodash":77}],72:[function(t,n,e){function r(t){function n(u){if(o.has(r,u))throw new i;o.has(e,u)||(r[u]=!0,e[u]=!0,o.each(t.predecessors(u),n),delete r[u],a.push(u))}var e={},r={},a=[];if(o.each(t.sinks(),n),o.size(e)!==t.nodeCount())throw new i;return a}function i(){}var o=t("../lodash");n.exports=r,r.CycleException=i},{"../lodash":77}],73:[function(t,n,e){function r(){this._arr=[],this._keyIndices={}}var i=t("../lodash");n.exports=r,r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return i.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];return void 0!==n?this._arr[n].priority:void 0},r.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var e=this._keyIndices;if(t=String(t),!i.has(e,t)){var r=this._arr,o=r.length;return e[t]=o,r.push({key:t,priority:n}),this._decrease(o),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var e=this._keyIndices[t];if(n>this._arr[e].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[e].priority+" New: "+n);this._arr[e].priority=n,this._decrease(e)},r.prototype._heapify=function(t){var n=this._arr,e=2*t,r=e+1,i=t;e>1,!(e[n].prioritye){var i=n;n=e,e=i}return n+h+e+h+(s.isUndefined(r)?f:r)}function u(t,n,e,r){if(!t&&n>e){var i=n;n=e,e=i}var o={v:n,w:e};return r&&(o.name=r),o}function c(t,n){return a(t,n.v,n.w,n.name)}var s=t("./lodash");n.exports=r;var f="\x00",l="\x00",h="";r.prototype._nodeCount=0,r.prototype._edgeCount=0,r.prototype.isDirected=function(){return this._isDirected},r.prototype.isMultigraph=function(){return this._isMultigraph},r.prototype.isCompound=function(){return this._isCompound},r.prototype.setGraph=function(t){return this._label=t,this},r.prototype.graph=function(){return this._label},r.prototype.setDefaultNodeLabel=function(t){return s.isFunction(t)||(t=s.constant(t)),this._defaultNodeLabelFn=t,this},r.prototype.nodeCount=function(){return this._nodeCount},r.prototype.nodes=function(){return s.keys(this._nodes)},r.prototype.sources=function(){return s.filter(this.nodes(),function(t){return s.isEmpty(this._in[t])},this)},r.prototype.sinks=function(){return s.filter(this.nodes(),function(t){return s.isEmpty(this._out[t])},this)},r.prototype.setNodes=function(t,n){var e=arguments;return s.each(t,function(t){e.length>1?this.setNode(t,n):this.setNode(t)},this),this},r.prototype.setNode=function(t,n){return s.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=n),this):(this._nodes[t]=arguments.length>1?n:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=l,this._children[t]={},this._children[l][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},r.prototype.node=function(t){return this._nodes[t]},r.prototype.hasNode=function(t){return s.has(this._nodes,t)},r.prototype.removeNode=function(t){var n=this;if(s.has(this._nodes,t)){var e=function(t){n.removeEdge(n._edgeObjs[t])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],s.each(this.children(t),function(t){this.setParent(t)},this),delete this._children[t]),s.each(s.keys(this._in[t]),e),delete this._in[t],delete this._preds[t],s.each(s.keys(this._out[t]),e),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},r.prototype.setParent=function(t,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(s.isUndefined(n))n=l;else{n+="";for(var e=n;!s.isUndefined(e);e=this.parent(e))if(e===t)throw new Error("Setting "+n+" as parent of "+t+" would create create a cycle");this.setNode(n)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=n,this._children[n][t]=!0,this},r.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},r.prototype.parent=function(t){if(this._isCompound){var n=this._parent[t];if(n!==l)return n}},r.prototype.children=function(t){if(s.isUndefined(t)&&(t=l),this._isCompound){var n=this._children[t];if(n)return s.keys(n)}else{if(t===l)return this.nodes();if(this.hasNode(t))return[]}},r.prototype.predecessors=function(t){var n=this._preds[t];return n?s.keys(n):void 0},r.prototype.successors=function(t){var n=this._sucs[t];return n?s.keys(n):void 0},r.prototype.neighbors=function(t){var n=this.predecessors(t);return n?s.union(n,this.successors(t)):void 0},r.prototype.setDefaultEdgeLabel=function(t){return s.isFunction(t)||(t=s.constant(t)),this._defaultEdgeLabelFn=t,this},r.prototype.edgeCount=function(){return this._edgeCount},r.prototype.edges=function(){return s.values(this._edgeObjs)},r.prototype.setPath=function(t,n){var e=this,r=arguments;return s.reduce(t,function(t,i){return r.length>1?e.setEdge(t,i,n):e.setEdge(t,i),i}),this},r.prototype.setEdge=function(){var t,n,e,r,o=!1;s.isPlainObject(arguments[0])?(t=arguments[0].v,n=arguments[0].w,e=arguments[0].name,2===arguments.length&&(r=arguments[1],o=!0)):(t=arguments[0],n=arguments[1],e=arguments[3],arguments.length>2&&(r=arguments[2],o=!0)),t=""+t,n=""+n,s.isUndefined(e)||(e=""+e);var c=a(this._isDirected,t,n,e);if(s.has(this._edgeLabels,c))return o&&(this._edgeLabels[c]=r),this;if(!s.isUndefined(e)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(n),this._edgeLabels[c]=o?r:this._defaultEdgeLabelFn(t,n,e);var f=u(this._isDirected,t,n,e);return t=f.v,n=f.w,Object.freeze(f),this._edgeObjs[c]=f,i(this._preds[n],t),i(this._sucs[t],n),this._in[n][c]=f,this._out[t][c]=f,this._edgeCount++,this},r.prototype.edge=function(t,n,e){var r=1===arguments.length?c(this._isDirected,arguments[0]):a(this._isDirected,t,n,e);return this._edgeLabels[r]},r.prototype.hasEdge=function(t,n,e){var r=1===arguments.length?c(this._isDirected,arguments[0]):a(this._isDirected,t,n,e);return s.has(this._edgeLabels,r)},r.prototype.removeEdge=function(t,n,e){var r=1===arguments.length?c(this._isDirected,arguments[0]):a(this._isDirected,t,n,e),i=this._edgeObjs[r];return i&&(t=i.v,n=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],o(this._preds[n],t),o(this._sucs[t],n),delete this._in[n][r],delete this._out[t][r],this._edgeCount--),this},r.prototype.inEdges=function(t,n){var e=this._in[t];if(e){var r=s.values(e);return n?s.filter(r,function(t){return t.v===n}):r}},r.prototype.outEdges=function(t,n){var e=this._out[t];if(e){var r=s.values(e);return n?s.filter(r,function(t){return t.w===n}):r}},r.prototype.nodeEdges=function(t,n){var e=this.inEdges(t,n);return e?e.concat(this.outEdges(t,n)):void 0}},{"./lodash":77}],75:[function(t,n,e){n.exports={Graph:t("./graph"),version:t("./version")}},{"./graph":74,"./version":78}],76:[function(t,n,e){function r(t){var n={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:i(t),edges:o(t)};return u.isUndefined(t.graph())||(n.value=u.clone(t.graph())),n}function i(t){return u.map(t.nodes(),function(n){var e=t.node(n),r=t.parent(n),i={v:n};return u.isUndefined(e)||(i.value=e),u.isUndefined(r)||(i.parent=r),i})}function o(t){return u.map(t.edges(),function(n){var e=t.edge(n),r={v:n.v,w:n.w};return u.isUndefined(n.name)||(r.name=n.name),u.isUndefined(e)||(r.value=e),r})}function a(t){var n=new c(t.options).setGraph(t.value);return u.each(t.nodes,function(t){n.setNode(t.v,t.value),t.parent&&n.setParent(t.v,t.parent)}),u.each(t.edges,function(t){n.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),n}var u=t("./lodash"),c=t("./graph");n.exports={write:r,read:a}},{"./graph":74,"./lodash":77}],77:[function(t,n,e){var r;if("function"==typeof t)try{r=t("lodash")}catch(i){}r||(r=window._),n.exports=r},{lodash:79}],78:[function(t,n,e){n.exports="1.0.5"},{}],79:[function(n,e,r){(function(n){(function(){function i(t,n){if(t!==n){var e=null===t,r=t===N,i=t===t,o=null===n,a=n===N,u=n===n;if(t>n&&!o||!i||e&&!a&&u||r&&u)return 1;if(n>t&&!e||!u||o&&!r&&i||a&&i)return-1}return 0}function o(t,n,e){for(var r=t.length,i=e?r:-1;e?i--:++i-1;);return e}function f(t,n){for(var e=t.length;e--&&n.indexOf(t.charAt(e))>-1;);return e}function l(t,n){return i(t.criteria,n.criteria)||t.index-n.index}function h(t,n,e){for(var r=-1,o=t.criteria,a=n.criteria,u=o.length,c=e.length;++r=c)return s;var f=e[r];return s*("asc"===f||f===!0?1:-1)}}return t.index-n.index}function d(t){return Vt[t]}function p(t){return Yt[t]}function g(t,n,e){return n?t=Ht[t]:e&&(t=Kt[t]),"\\"+t}function v(t){return"\\"+Kt[t]}function y(t,n,e){for(var r=t.length,i=n+(e?0:-1);e?i--:++i=t&&t>=9&&13>=t||32==t||160==t||5760==t||6158==t||t>=8192&&(8202>=t||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function w(t,n){for(var e=-1,r=t.length,i=-1,o=[];++en,i=e?t.length:0,o=Ye(0,i,this.__views__),a=o.start,u=o.end,c=u-a,s=r?u:a-1,f=this.__iteratees__,l=f.length,h=0,d=ka(c,this.__takeCount__);if(!e||W>i||i==c&&d==c)return re(r&&e?t.reverse():t,this.__actions__);var p=[];t:for(;c--&&d>h;){s+=n;for(var g=-1,v=t[s];++g=W?ge(n):null,s=n.length;c&&(o=Qt,u=!1,n=c);t:for(;++ie&&(e=-e>i?0:i+e),r=r===N||r>i?i:+r||0,0>r&&(r+=i),i=e>r?0:r>>>0,e>>>=0;i>e;)t[e++]=n;return t}function jn(t,n){var e=[];return Ba(t,function(t,r,i){n(t,r,i)&&e.push(t)}),e}function Rn(t,n,e,r){var i;return e(t,function(t,e,o){return n(t,e,o)?(i=r?e:t,!1):void 0}),i}function Tn(t,n,e,r){r||(r=[]);for(var i=-1,o=t.length;++ir;)t=t[n[r++]];return r&&r==i?t:N}}function Bn(t,n,e,r,i,o){return t===n?!0:null==t||null==n||!Si(t)&&!_(n)?t!==t&&n!==n:Un(t,n,Bn,e,r,i,o)}function Un(t,n,e,r,i,o,a){var u=Ru(t),c=Ru(n),s=$,f=$;u||(s=ra.call(t),s==Y?s=tt:s!=tt&&(u=qi(t))),c||(f=ra.call(n),f==Y?f=tt:f!=tt&&(c=qi(n)));var l=s==tt,h=f==tt,d=s==f;if(d&&!u&&!l)return Fe(t,n,s);if(!i){var p=l&&na.call(t,"__wrapped__"),g=h&&na.call(n,"__wrapped__");if(p||g)return e(p?t.value():t,g?n.value():n,r,i,o,a)}if(!d)return!1;o||(o=[]),a||(a=[]);for(var v=o.length;v--;)if(o[v]==t)return a[v]==n;o.push(t),a.push(n);var y=(u?Pe:De)(t,n,e,r,i,o,a);return o.pop(),a.pop(),y}function Pn(t,n,e){var r=n.length,i=r,o=!e;if(null==t)return!i;for(t=lr(t);r--;){var a=n[r];if(o&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++rn&&(n=-n>i?0:i+n),e=e===N||e>i?i:+e||0,0>e&&(e+=i),i=n>e?0:e-n>>>0,n>>>=0;for(var o=Wo(i);++r=W,c=u?ge():null,s=[];c?(r=Qt,o=!1):(u=!1,c=n?[]:s);t:for(;++e=i){for(;i>r;){var o=r+i>>>1,a=t[o];(e?n>=a:n>a)&&null!==a?r=o+1:i=o}return i}return oe(t,n,jo,e)}function oe(t,n,e,r){n=e(n);for(var i=0,o=t?t.length:0,a=n!==n,u=null===n,c=n===N;o>i;){var s=_a((i+o)/2),f=e(t[s]),l=f!==N,h=f===f;if(a)var d=h||r;else d=u?h&&l&&(r||null!=f):c?h&&(r||l):null==f?!1:r?n>=f:n>f;d?i=s+1:o=s}return ka(o,Ta)}function ae(t,n,e){if("function"!=typeof t)return jo;if(n===N)return t;switch(e){case 1:return function(e){return t.call(n,e)};case 3:return function(e,r,i){return t.call(n,e,r,i)};case 4:return function(e,r,i,o){return t.call(n,e,r,i,o)};case 5:return function(e,r,i,o,a){return t.call(n,e,r,i,o,a)}}return function(){return t.apply(n,arguments)}}function ue(t){var n=new aa(t.byteLength),e=new pa(n);return e.set(new pa(t)),n}function ce(t,n,e){for(var r=e.length,i=-1,o=xa(t.length-r,0),a=-1,u=n.length,c=Wo(u+o);++a2?e[i-2]:N,a=i>2?e[2]:N,u=i>1?e[i-1]:N;for("function"==typeof o?(o=ae(o,u,5),i-=2):(o="function"==typeof u?u:N,i-=o?1:0),a&&Ze(e[0],e[1],a)&&(o=3>i?N:o,i=1);++r-1?e[a]:N}return Rn(e,r,t)}}function xe(t){return function(n,e,r){return n&&n.length?(e=We(e,r,3),o(n,e,t)):-1}}function ke(t){return function(n,e,r){return e=We(e,r,3),Rn(n,e,t,!0)}}function Ee(t){return function(){for(var n,e=arguments.length,i=t?e:-1,o=0,a=Wo(e);t?i--:++i=W)return n.plant(r).value();for(var i=0,o=e?a[i].apply(this,t):r;++i_){var E=u?tn(u):N,I=xa(s-_,0),C=p?k:N,T=p?N:k,L=p?b:N,A=p?N:b;n|=p?O:S,n&=~(p?S:O),g||(n&=~(j|R));var M=[t,n,e,L,C,A,T,E,c,I],B=Ae.apply(N,M);return nr(t)&&qa(B,M),B.placeholder=x,B}}var U=h?e:this,P=d?U[t]:t;return u&&(b=cr(b,u)),l&&c=n||!wa(n))return"";var i=n-r;return e=null==e?" ":e+"",yo(e,va(i/e.length)).slice(0,i)}function Se(t,n,e,r){function i(){for(var n=-1,u=arguments.length,c=-1,s=r.length,f=Wo(s+u);++cc))return!1;for(;++u-1&&t%1==0&&n>t}function Ze(t,n,e){if(!Si(e))return!1;var r=typeof n;if("number"==r?Qe(e)&&Je(n,e.length):"string"==r&&n in e){var i=e[n];return t===t?t===i:i!==i}return!1}function tr(t,n){var e=typeof t;if("string"==e&&Nt.test(t)||"number"==e)return!0;if(Ru(t))return!1;var r=!It.test(t);return r||null!=n&&t in lr(n)}function nr(t){var e=ze(t);if(!(e in m.prototype))return!1;var r=n[e];if(t===r)return!0;var i=Wa(r);return!!i&&t===i[0]}function er(t){return"number"==typeof t&&t>-1&&t%1==0&&Aa>=t}function rr(t){return t===t&&!Si(t)}function ir(t,n){var e=t[1],r=n[1],i=e|r,o=M>i,a=r==M&&e==L||r==M&&e==B&&t[7].length<=n[8]||r==(M|B)&&e==L;if(!o&&!a)return t;r&j&&(t[2]=n[2],i|=e&j?0:T);var u=n[3];if(u){var c=t[3];t[3]=c?ce(c,u,n[4]):tn(u),t[4]=c?w(t[3],V):tn(n[4])}return u=n[5],u&&(c=t[5],t[5]=c?se(c,u,n[6]):tn(u),t[6]=c?w(t[5],V):tn(n[6])),u=n[7],u&&(t[7]=tn(u)),r&M&&(t[8]=null==t[8]?n[8]:ka(t[8],n[8])),null==t[9]&&(t[9]=n[9]),t[0]=n[0],t[1]=i,t}function or(t,n){return t===N?n:Tu(t,n,or)}function ar(t,n){t=lr(t);for(var e=-1,r=n.length,i={};++er;)a[++o]=Hn(t,r,r+=n);return a}function gr(t){for(var n=-1,e=t?t.length:0,r=-1,i=[];++nn?0:n)):[]}function yr(t,n,e){var r=t?t.length:0;return r?((e?Ze(t,n,e):null==n)&&(n=1),n=r-(+n||0),Hn(t,0,0>n?0:n)):[]}function _r(t,n,e){return t&&t.length?ee(t,We(n,e,3),!0,!0):[]}function mr(t,n,e){return t&&t.length?ee(t,We(n,e,3),!0):[]}function wr(t,n,e,r){var i=t?t.length:0;return i?(e&&"number"!=typeof e&&Ze(t,n,e)&&(e=0,r=i),Cn(t,n,e,r)):[]}function br(t){return t?t[0]:N}function xr(t,n,e){var r=t?t.length:0;return e&&Ze(t,n,e)&&(n=!1),r?Tn(t,n):[]}function kr(t){var n=t?t.length:0;return n?Tn(t,!0):[]}function Er(t,n,e){var r=t?t.length:0;if(!r)return-1;if("number"==typeof e)e=0>e?xa(r+e,0):e;else if(e){var i=ie(t,n);return r>i&&(n===n?n===t[i]:t[i]!==t[i])?i:-1}return a(t,n,e||0)}function Ir(t){return yr(t,1)}function Nr(t){var n=t?t.length:0;return n?t[n-1]:N}function Cr(t,n,e){var r=t?t.length:0;if(!r)return-1;var i=r;if("number"==typeof e)i=(0>e?xa(r+e,0):ka(e||0,r-1))+1;else if(e){i=ie(t,n,!0)-1;var o=t[i];return(n===n?n===o:o!==o)?i:-1}if(n!==n)return y(t,i,!0);for(;i--;)if(t[i]===n)return i;return-1}function jr(){var t=arguments,n=t[0];if(!n||!n.length)return n;for(var e=0,r=qe(),i=t.length;++e-1;)da.call(n,o,1);return n}function Rr(t,n,e){var r=[];if(!t||!t.length)return r;var i=-1,o=[],a=t.length;for(n=We(n,e,3);++in?0:n)):[]}function Or(t,n,e){var r=t?t.length:0;return r?((e?Ze(t,n,e):null==n)&&(n=1),n=r-(+n||0),Hn(t,0>n?0:n)):[]}function Sr(t,n,e){return t&&t.length?ee(t,We(n,e,3),!1,!0):[]}function Mr(t,n,e){return t&&t.length?ee(t,We(n,e,3)):[]}function Br(t,n,e,r){var i=t?t.length:0;if(!i)return[];null!=n&&"boolean"!=typeof n&&(r=e,e=Ze(t,n,r)?N:n,n=!1);var o=We();return(null!=e||o!==bn)&&(e=o(e,r,3)),n&&qe()==a?b(t,e):te(t,e)}function Ur(t){if(!t||!t.length)return[];var n=-1,e=0;t=cn(t,function(t){return Qe(t)?(e=xa(t.length,e),!0):void 0});for(var r=Wo(e);++ne?xa(i+e,0):e||0,"string"==typeof t||!Ru(t)&&zi(t)?i>=e&&t.indexOf(n,e)>-1:!!i&&qe(t,n,e)>-1}function ti(t,n,e){var r=Ru(t)?sn:Fn;return n=We(n,e,3),r(t,n)}function ni(t,n){return ti(t,So(n))}function ei(t,n,e){var r=Ru(t)?cn:jn;return n=We(n,e,3),r(t,function(t,e,r){return!n(t,e,r)})}function ri(t,n,e){if(e?Ze(t,n,e):null==n){t=fr(t);var r=t.length;return r>0?t[$n(0,r-1)]:N}var i=-1,o=$i(t),r=o.length,a=r-1;for(n=ka(0>n?0:+n||0,r);++i0&&(e=n.apply(this,arguments)),1>=t&&(n=N),e}}function di(t,n,e){function r(){d&&ua(d),s&&ua(s),g=0,s=d=p=N}function i(n,e){e&&ua(e),s=d=p=N,n&&(g=gu(),f=t.apply(h,c),d||s||(c=h=N))}function o(){var t=n-(gu()-l);0>=t||t>n?i(p,s):d=ha(o,t)}function a(){i(y,d)}function u(){if(c=arguments,l=gu(),h=this,p=y&&(d||!_),v===!1)var e=_&&!d;else{s||_||(g=l);var r=v-(l-g),i=0>=r||r>v;i?(s&&(s=ua(s)),g=l,f=t.apply(h,c)):s||(s=ha(a,r))}return i&&d?d=ua(d):d||n===v||(d=ha(o,n)),e&&(i=!0,f=t.apply(h,c)),!i||d||s||(c=h=N),f}var c,s,f,l,h,d,p,g=0,v=!1,y=!0;if("function"!=typeof t)throw new Ko(G);if(n=0>n?0:+n||0,e===!0){var _=!0;y=!1}else Si(e)&&(_=!!e.leading,v="maxWait"in e&&xa(+e.maxWait||0,n),y="trailing"in e?!!e.trailing:y);return u.cancel=r,u}function pi(t,n){if("function"!=typeof t||n&&"function"!=typeof n)throw new Ko(G);var e=function(){var r=arguments,i=n?n.apply(this,r):r[0],o=e.cache;if(o.has(i))return o.get(i);var a=t.apply(this,r);return e.cache=o.set(i,a),a};return e.cache=new pi.Cache,e}function gi(t){if("function"!=typeof t)throw new Ko(G);return function(){return!t.apply(this,arguments)}}function vi(t){return hi(2,t)}function yi(t,n){if("function"!=typeof t)throw new Ko(G);return n=xa(n===N?t.length-1:+n||0,0),function(){for(var e=arguments,r=-1,i=xa(e.length-n,0),o=Wo(i);++rn}function Ei(t,n){return t>=n}function Ii(t){return _(t)&&Qe(t)&&na.call(t,"callee")&&!fa.call(t,"callee")}function Ni(t){return t===!0||t===!1||_(t)&&ra.call(t)==X}function Ci(t){return _(t)&&ra.call(t)==H}function ji(t){return!!t&&1===t.nodeType&&_(t)&&!Di(t)}function Ri(t){return null==t?!0:Qe(t)&&(Ru(t)||zi(t)||Ii(t)||_(t)&&Oi(t.splice))?!t.length:!Du(t).length}function Ti(t,n,e,r){e="function"==typeof e?ae(e,r,3):N;var i=e?e(t,n):N;return i===N?Bn(t,n,e):!!i}function Li(t){return _(t)&&"string"==typeof t.message&&ra.call(t)==K}function Ai(t){return"number"==typeof t&&wa(t)}function Oi(t){return Si(t)&&ra.call(t)==Q}function Si(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}function Mi(t,n,e,r){return e="function"==typeof e?ae(e,r,3):N,Pn(t,Ge(n),e)}function Bi(t){return Fi(t)&&t!=+t}function Ui(t){return null==t?!1:Oi(t)?oa.test(ta.call(t)):_(t)&&Mt.test(t)}function Pi(t){return null===t}function Fi(t){return"number"==typeof t||_(t)&&ra.call(t)==Z}function Di(t){var n;if(!_(t)||ra.call(t)!=tt||Ii(t)||!na.call(t,"constructor")&&(n=t.constructor,"function"==typeof n&&!(n instanceof n)))return!1;var e;return Ln(t,function(t,n){e=n}),e===N||na.call(t,e)}function Wi(t){return Si(t)&&ra.call(t)==nt}function zi(t){return"string"==typeof t||_(t)&&ra.call(t)==rt}function qi(t){return _(t)&&er(t.length)&&!!qt[ra.call(t)]}function Gi(t){return t===N}function Vi(t,n){return n>t}function Yi(t,n){return n>=t}function $i(t){var n=t?za(t):0;return er(n)?n?tn(t):[]:oo(t)}function Xi(t){return wn(t,to(t))}function Hi(t,n,e){var r=Ma(t);return e&&Ze(t,n,e)&&(n=N),n?_n(r,n):r}function Ki(t){return Sn(t,to(t))}function Qi(t,n,e){var r=null==t?N:Mn(t,hr(n),n+"");return r===N?e:r}function Ji(t,n){if(null==t)return!1;var e=na.call(t,n);if(!e&&!tr(n)){if(n=hr(n),t=1==n.length?t:Mn(t,Hn(n,0,-1)),null==t)return!1;n=Nr(n),e=na.call(t,n)}return e||er(t.length)&&Je(n,t.length)&&(Ru(t)||Ii(t))}function Zi(t,n,e){e&&Ze(t,n,e)&&(n=N);for(var r=-1,i=Du(t),o=i.length,a={};++r0;++r=ka(n,e)&&te?0:+e||0,r),e-=n.length,e>=0&&t.indexOf(n,e)==e}function ho(t){return t=c(t),t&&bt.test(t)?t.replace(mt,p):t}function po(t){return t=c(t),t&&Rt.test(t)?t.replace(jt,g):t||"(?:)"}function go(t,n,e){t=c(t),n=+n;var r=t.length;if(r>=n||!wa(n))return t;var i=(n-r)/2,o=_a(i),a=va(i);return e=Oe("",a,e),e.slice(0,o)+t+e}function vo(t,n,e){return(e?Ze(t,n,e):null==n)?n=0:n&&(n=+n),t=wo(t),Ia(t,n||(St.test(t)?16:10))}function yo(t,n){var e="";if(t=c(t),n=+n,1>n||!t||!wa(n))return e;do n%2&&(e+=t),n=_a(n/2),t+=t;while(n);return e}function _o(t,n,e){return t=c(t),e=null==e?0:ka(0>e?0:+e||0,t.length),t.lastIndexOf(n,e)==e}function mo(t,e,r){var i=n.templateSettings;r&&Ze(t,e,r)&&(e=r=N),t=c(t),e=yn(_n({},r||e),i,vn);var o,a,u=yn(_n({},e.imports),i.imports,vn),s=Du(u),f=ne(u,s),l=0,h=e.interpolate||Pt,d="__p += '",p=Xo((e.escape||Pt).source+"|"+h.source+"|"+(h===Et?At:Pt).source+"|"+(e.evaluate||Pt).source+"|$","g"),g="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++zt+"]")+"\n";t.replace(p,function(n,e,r,i,u,c){return r||(r=i),d+=t.slice(l,c).replace(Ft,v),e&&(o=!0,d+="' +\n__e("+e+") +\n'"),u&&(a=!0,d+="';\n"+u+";\n__p += '"),r&&(d+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),l=c+n.length,n}),d+="';\n";var y=e.variable;y||(d="with (obj) {\n"+d+"\n}\n"),d=(a?d.replace(gt,""):d).replace(vt,"$1").replace(yt,"$1;"),d="function("+(y||"obj")+") {\n"+(y?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var _=Qu(function(){return Go(s,g+"return "+d).apply(N,f)});if(_.source=d,Li(_))throw _;return _}function wo(t,n,e){var r=t;return(t=c(t))?(e?Ze(r,n,e):null==n)?t.slice(x(t),k(t)+1):(n+="",t.slice(s(t,n),f(t,n)+1)):t}function bo(t,n,e){var r=t;return t=c(t),t?t.slice((e?Ze(r,n,e):null==n)?x(t):s(t,n+"")):t}function xo(t,n,e){var r=t;return t=c(t),t?(e?Ze(r,n,e):null==n)?t.slice(0,k(t)+1):t.slice(0,f(t,n+"")+1):t}function ko(t,n,e){e&&Ze(t,n,e)&&(n=N);var r=U,i=P;if(null!=n)if(Si(n)){var o="separator"in n?n.separator:o;r="length"in n?+n.length||0:r,i="omission"in n?c(n.omission):i}else r=+n||0;if(t=c(t),r>=t.length)return t;var a=r-i.length;if(1>a)return i;var u=t.slice(0,a);if(null==o)return u+i;if(Wi(o)){if(t.slice(a).search(o)){var s,f,l=t.slice(0,a);for(o.global||(o=Xo(o.source,(Ot.exec(o)||"")+"g")),o.lastIndex=0;s=o.exec(l);)f=s.index;u=u.slice(0,null==f?a:f)}}else if(t.indexOf(o,a)!=a){var h=u.lastIndexOf(o);h>-1&&(u=u.slice(0,h))}return u+i}function Eo(t){return t=c(t),t&&wt.test(t)?t.replace(_t,E):t}function Io(t,n,e){return e&&Ze(t,n,e)&&(n=N),t=c(t),t.match(n||Dt)||[]}function No(t,n,e){return e&&Ze(t,n,e)&&(n=N),_(t)?Ro(t):bn(t,n)}function Co(t){return function(){return t}}function jo(t){return t}function Ro(t){return Dn(xn(t,!0))}function To(t,n){return Wn(t,xn(n,!0))}function Lo(t,n,e){if(null==e){var r=Si(n),i=r?Du(n):N,o=i&&i.length?Sn(n,i):N;(o?o.length:r)||(o=!1,e=n,n=t,t=this)}o||(o=Sn(n,Du(n)));var a=!0,u=-1,c=Oi(t),s=o.length;e===!1?a=!1:Si(e)&&"chain"in e&&(a=e.chain);for(;++ut||!wa(t))return[];var r=-1,i=Wo(ka(t,Ra));for(n=ae(n,e,1);++rr?i[r]=n(r):n(r);return i}function Po(t){var n=++ea;return c(t)+n}function Fo(t,n){return(+t||0)+(+n||0)}function Do(t,n,e){ + return e&&Ze(t,n,e)&&(n=N),n=We(n,e,3),1==n.length?pn(Ru(t)?t:fr(t),n):Zn(t,n)}t=t?on.defaults(rn.Object(),t,on.pick(rn,Wt)):rn;{var Wo=t.Array,zo=t.Date,qo=t.Error,Go=t.Function,Vo=t.Math,Yo=t.Number,$o=t.Object,Xo=t.RegExp,Ho=t.String,Ko=t.TypeError,Qo=Wo.prototype,Jo=$o.prototype,Zo=Ho.prototype,ta=Go.prototype.toString,na=Jo.hasOwnProperty,ea=0,ra=Jo.toString,ia=rn._,oa=Xo("^"+ta.call(na).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),aa=t.ArrayBuffer,ua=t.clearTimeout,ca=t.parseFloat,sa=Vo.pow,fa=Jo.propertyIsEnumerable,la=Ve(t,"Set"),ha=t.setTimeout,da=Qo.splice,pa=t.Uint8Array,ga=Ve(t,"WeakMap"),va=Vo.ceil,ya=Ve($o,"create"),_a=Vo.floor,ma=Ve(Wo,"isArray"),wa=t.isFinite,ba=Ve($o,"keys"),xa=Vo.max,ka=Vo.min,Ea=Ve(zo,"now"),Ia=t.parseInt,Na=Vo.random,Ca=Yo.NEGATIVE_INFINITY,ja=Yo.POSITIVE_INFINITY,Ra=4294967295,Ta=Ra-1,La=Ra>>>1,Aa=9007199254740991,Oa=ga&&new ga,Sa={};n.support={}}n.templateSettings={escape:xt,evaluate:kt,interpolate:Et,variable:"",imports:{_:n}};var Ma=function(){function t(){}return function(n){if(Si(n)){t.prototype=n;var e=new t;t.prototype=N}return e||{}}}(),Ba=he(An),Ua=he(On,!0),Pa=de(),Fa=de(!0),Da=Oa?function(t,n){return Oa.set(t,n),t}:jo,Wa=Oa?function(t){return Oa.get(t)}:Oo,za=Gn("length"),qa=function(){var t=0,n=0;return function(e,r){var i=gu(),o=D-(i-n);if(n=i,o>0){if(++t>=F)return e}else t=0;return Da(e,r)}}(),Ga=yi(function(t,n){return _(t)&&Qe(t)?En(t,Tn(n,!1,!0)):[]}),Va=xe(),Ya=xe(!0),$a=yi(function(t){for(var n=t.length,e=n,r=Wo(l),i=qe(),o=i==a,u=[];e--;){var c=t[e]=Qe(c=t[e])?c:[];r[e]=o&&c.length>=120?ge(e&&c):null}var s=t[0],f=-1,l=s?s.length:0,h=r[0];t:for(;++f2?t[n-2]:N,r=n>1?t[n-1]:N;return n>2&&"function"==typeof e?n-=2:(e=n>1&&"function"==typeof r?(--n,r):N,r=N),t.length=n,Pr(t,e,r)}),nu=yi(function(t){return t=Tn(t),this.thru(function(n){return Zt(Ru(n)?n:[lr(n)],t)})}),eu=yi(function(t,n){return mn(t,Tn(n))}),ru=fe(function(t,n,e){na.call(t,e)?++t[e]:t[e]=1}),iu=be(Ba),ou=be(Ua,!0),au=Ie(nn,Ba),uu=Ie(en,Ua),cu=fe(function(t,n,e){na.call(t,e)?t[e].push(n):t[e]=[n]}),su=fe(function(t,n,e){t[e]=n}),fu=yi(function(t,n,e){var r=-1,i="function"==typeof n,o=tr(n),a=Qe(t)?Wo(t.length):[];return Ba(t,function(t){var u=i?n:o&&null!=t?t[n]:N;a[++r]=u?u.apply(t,e):Ke(t,n,e)}),a}),lu=fe(function(t,n,e){t[e?0:1].push(n)},function(){return[[],[]]}),hu=Le(ln,Ba),du=Le(hn,Ua),pu=yi(function(t,n){if(null==t)return[];var e=n[2];return e&&Ze(n[0],n[1],e)&&(n.length=1),Jn(t,Tn(n),[])}),gu=Ea||function(){return(new zo).getTime()},vu=yi(function(t,n,e){var r=j;if(e.length){var i=w(e,vu.placeholder);r|=O}return Ue(t,r,n,e,i)}),yu=yi(function(t,n){n=n.length?Tn(n):Ki(t);for(var e=-1,r=n.length;++e0||0>n)?new m(e):(0>t?e=e.takeRight(-t):t&&(e=e.drop(t)),n!==N&&(n=+n||0,e=0>n?e.dropRight(-n):e.take(n-t)),e)},m.prototype.takeRightWhile=function(t,n){return this.reverse().takeWhile(t,n).reverse()},m.prototype.toArray=function(){return this.take(ja)},An(m.prototype,function(t,e){var i=/^(?:filter|map|reject)|While$/.test(e),o=/^(?:first|last)$/.test(e),a=n[o?"take"+("last"==e?"Right":""):e];a&&(n.prototype[e]=function(){var n=o?[1]:arguments,e=this.__chain__,u=this.__wrapped__,c=!!this.__actions__.length,s=u instanceof m,f=n[0],l=s||Ru(u);l&&i&&"function"==typeof f&&1!=f.length&&(s=l=!1);var h=function(t){return o&&e?a(t,1)[0]:a.apply(N,fn([t],n))},d={func:qr,args:[h],thisArg:N},p=s&&!c;if(o&&!e)return p?(u=u.clone(),u.__actions__.push(d),t.call(u)):a.call(N,this.value())[0];if(!o&&l){u=p?u:new m(this);var g=t.apply(u,n);return g.__actions__.push(d),new r(g,e)}return this.thru(h)})}),nn(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(t){var e=(/^(?:replace|split)$/.test(t)?Zo:Qo)[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",i=/^(?:join|pop|replace|shift)$/.test(t);n.prototype[t]=function(){var t=arguments;return i&&!this.__chain__?e.apply(this.value(),t):this[r](function(n){return e.apply(n,t)})}}),An(m.prototype,function(t,e){var r=n[e];if(r){var i=r.name,o=Sa[i]||(Sa[i]=[]);o.push({name:e,func:r})}}),Sa[Ae(N,R).name]=[{name:"wrapper",func:N}],m.prototype.clone=J,m.prototype.reverse=et,m.prototype.value=it,n.prototype.chain=Gr,n.prototype.commit=Vr,n.prototype.concat=nu,n.prototype.plant=Yr,n.prototype.reverse=$r,n.prototype.toString=Xr,n.prototype.run=n.prototype.toJSON=n.prototype.valueOf=n.prototype.value=Hr,n.prototype.collect=n.prototype.map,n.prototype.head=n.prototype.first,n.prototype.select=n.prototype.filter,n.prototype.tail=n.prototype.rest,n}var N,C="3.10.0",j=1,R=2,T=4,L=8,A=16,O=32,S=64,M=128,B=256,U=30,P="...",F=150,D=16,W=200,z=1,q=2,G="Expected a function",V="__lodash_placeholder__",Y="[object Arguments]",$="[object Array]",X="[object Boolean]",H="[object Date]",K="[object Error]",Q="[object Function]",J="[object Map]",Z="[object Number]",tt="[object Object]",nt="[object RegExp]",et="[object Set]",rt="[object String]",it="[object WeakMap]",ot="[object ArrayBuffer]",at="[object Float32Array]",ut="[object Float64Array]",ct="[object Int8Array]",st="[object Int16Array]",ft="[object Int32Array]",lt="[object Uint8Array]",ht="[object Uint8ClampedArray]",dt="[object Uint16Array]",pt="[object Uint32Array]",gt=/\b__p \+= '';/g,vt=/\b(__p \+=) '' \+/g,yt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_t=/&(?:amp|lt|gt|quot|#39|#96);/g,mt=/[&<>"'`]/g,wt=RegExp(_t.source),bt=RegExp(mt.source),xt=/<%-([\s\S]+?)%>/g,kt=/<%([\s\S]+?)%>/g,Et=/<%=([\s\S]+?)%>/g,It=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,Nt=/^\w*$/,Ct=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,jt=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,Rt=RegExp(jt.source),Tt=/[\u0300-\u036f\ufe20-\ufe23]/g,Lt=/\\(\\)?/g,At=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ot=/\w*$/,St=/^0[xX]/,Mt=/^\[object .+?Constructor\]$/,Bt=/^\d+$/,Ut=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Pt=/($^)/,Ft=/['\n\r\u2028\u2029\\]/g,Dt=function(){var t="[A-Z\\xc0-\\xd6\\xd8-\\xde]",n="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(t+"+(?="+t+n+")|"+t+"?"+n+"|"+t+"+|[0-9]+","g")}(),Wt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap"],zt=-1,qt={};qt[at]=qt[ut]=qt[ct]=qt[st]=qt[ft]=qt[lt]=qt[ht]=qt[dt]=qt[pt]=!0,qt[Y]=qt[$]=qt[ot]=qt[X]=qt[H]=qt[K]=qt[Q]=qt[J]=qt[Z]=qt[tt]=qt[nt]=qt[et]=qt[rt]=qt[it]=!1;var Gt={};Gt[Y]=Gt[$]=Gt[ot]=Gt[X]=Gt[H]=Gt[at]=Gt[ut]=Gt[ct]=Gt[st]=Gt[ft]=Gt[Z]=Gt[tt]=Gt[nt]=Gt[rt]=Gt[lt]=Gt[ht]=Gt[dt]=Gt[pt]=!0,Gt[K]=Gt[Q]=Gt[J]=Gt[et]=Gt[it]=!1;var Vt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Yt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},$t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Xt={"function":!0,object:!0},Ht={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Kt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Qt=Xt[typeof r]&&r&&!r.nodeType&&r,Jt=Xt[typeof e]&&e&&!e.nodeType&&e,Zt=Qt&&Jt&&"object"==typeof n&&n&&n.Object&&n,tn=Xt[typeof self]&&self&&self.Object&&self,nn=Xt[typeof window]&&window&&window.Object&&window,en=Jt&&Jt.exports===Qt&&Qt,rn=Zt||nn!==(this&&this.window)&&nn||tn||this,on=I();"function"==typeof t&&"object"==typeof t.amd&&t.amd?(rn._=on,t(function(){return on})):Qt&&Jt?en?(Jt.exports=on)._=on:Qt._=on:rn._=on}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}); diff --git a/confluence-plugin/src/main/typescript/src/lib/dagre.min.js b/confluence-plugin/src/main/typescript/src/lib/dagre.min.js new file mode 100644 index 0000000..9eeb1c6 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/lib/dagre.min.js @@ -0,0 +1,6 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.dagre=e()}}(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o0;--i){entry=buckets[i].dequeue();if(entry){results=results.concat(removeNode(g,buckets,zeroIdx,entry,true));break}}}}return results}function removeNode(g,buckets,zeroIdx,entry,collectPredecessors){var results=collectPredecessors?[]:undefined;_.each(g.inEdges(entry.v),function(edge){var weight=g.edge(edge),uEntry=g.node(edge.v);if(collectPredecessors){results.push({v:edge.v,w:edge.w})}uEntry.out-=weight;assignBucket(buckets,zeroIdx,uEntry)});_.each(g.outEdges(entry.v),function(edge){var weight=g.edge(edge),w=edge.w,wEntry=g.node(w);wEntry["in"]-=weight;assignBucket(buckets,zeroIdx,wEntry)});g.removeNode(entry.v);return results}function buildState(g,weightFn){var fasGraph=new Graph,maxIn=0,maxOut=0;_.each(g.nodes(),function(v){fasGraph.setNode(v,{v:v,"in":0,out:0})});_.each(g.edges(),function(e){var prevWeight=fasGraph.edge(e.v,e.w)||0,weight=weightFn(e),edgeWeight=prevWeight+weight;fasGraph.setEdge(e.v,e.w,edgeWeight);maxOut=Math.max(maxOut,fasGraph.node(e.v).out+=weight);maxIn=Math.max(maxIn,fasGraph.node(e.w)["in"]+=weight)});var buckets=_.range(maxOut+maxIn+3).map(function(){return new List});var zeroIdx=maxIn+1;_.each(fasGraph.nodes(),function(v){assignBucket(buckets,zeroIdx,fasGraph.node(v))});return{graph:fasGraph,buckets:buckets,zeroIdx:zeroIdx}}function assignBucket(buckets,zeroIdx,entry){if(!entry.out){buckets[0].enqueue(entry)}else if(!entry["in"]){buckets[buckets.length-1].enqueue(entry)}else{buckets[entry.out-entry["in"]+zeroIdx].enqueue(entry)}}},{"./data/list":5,"./graphlib":7,"./lodash":10}],9:[function(require,module,exports){"use strict";var _=require("./lodash"),acyclic=require("./acyclic"),normalize=require("./normalize"),rank=require("./rank"),normalizeRanks=require("./util").normalizeRanks,parentDummyChains=require("./parent-dummy-chains"),removeEmptyRanks=require("./util").removeEmptyRanks,nestingGraph=require("./nesting-graph"),addBorderSegments=require("./add-border-segments"),coordinateSystem=require("./coordinate-system"),order=require("./order"),position=require("./position"),util=require("./util"),Graph=require("./graphlib").Graph;module.exports=layout;function layout(g,opts){var time=opts&&opts.debugTiming?util.time:util.notime;time("layout",function(){var layoutGraph=time(" buildLayoutGraph",function(){return buildLayoutGraph(g)});time(" runLayout",function(){runLayout(layoutGraph,time)});time(" updateInputGraph",function(){updateInputGraph(g,layoutGraph)})})}function runLayout(g,time){time(" makeSpaceForEdgeLabels",function(){makeSpaceForEdgeLabels(g)});time(" removeSelfEdges",function(){removeSelfEdges(g)});time(" acyclic",function(){acyclic.run(g)});time(" nestingGraph.run",function(){nestingGraph.run(g)});time(" rank",function(){rank(util.asNonCompoundGraph(g))});time(" injectEdgeLabelProxies",function(){injectEdgeLabelProxies(g)});time(" removeEmptyRanks",function(){removeEmptyRanks(g)});time(" nestingGraph.cleanup",function(){nestingGraph.cleanup(g)});time(" normalizeRanks",function(){normalizeRanks(g)});time(" assignRankMinMax",function(){assignRankMinMax(g)});time(" removeEdgeLabelProxies",function(){removeEdgeLabelProxies(g)});time(" normalize.run",function(){normalize.run(g)});time(" parentDummyChains",function(){parentDummyChains(g)});time(" addBorderSegments",function(){addBorderSegments(g)});time(" order",function(){order(g)});time(" insertSelfEdges",function(){insertSelfEdges(g)});time(" adjustCoordinateSystem",function(){coordinateSystem.adjust(g)});time(" position",function(){position(g)});time(" positionSelfEdges",function(){positionSelfEdges(g)});time(" removeBorderNodes",function(){removeBorderNodes(g)});time(" normalize.undo",function(){normalize.undo(g)});time(" fixupEdgeLabelCoords",function(){fixupEdgeLabelCoords(g)});time(" undoCoordinateSystem",function(){coordinateSystem.undo(g)});time(" translateGraph",function(){translateGraph(g)});time(" assignNodeIntersects",function(){assignNodeIntersects(g)});time(" reversePoints",function(){reversePointsForReversedEdges(g)});time(" acyclic.undo",function(){acyclic.undo(g)})}function updateInputGraph(inputGraph,layoutGraph){_.each(inputGraph.nodes(),function(v){var inputLabel=inputGraph.node(v),layoutLabel=layoutGraph.node(v);if(inputLabel){inputLabel.x=layoutLabel.x;inputLabel.y=layoutLabel.y;if(layoutGraph.children(v).length){inputLabel.width=layoutLabel.width;inputLabel.height=layoutLabel.height}}});_.each(inputGraph.edges(),function(e){var inputLabel=inputGraph.edge(e),layoutLabel=layoutGraph.edge(e);inputLabel.points=layoutLabel.points;if(_.has(layoutLabel,"x")){inputLabel.x=layoutLabel.x;inputLabel.y=layoutLabel.y}});inputGraph.graph().width=layoutGraph.graph().width;inputGraph.graph().height=layoutGraph.graph().height}var graphNumAttrs=["nodesep","edgesep","ranksep","marginx","marginy"],graphDefaults={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},graphAttrs=["acyclicer","ranker","rankdir","align"],nodeNumAttrs=["width","height"],nodeDefaults={width:0,height:0},edgeNumAttrs=["minlen","weight","width","height","labeloffset"],edgeDefaults={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},edgeAttrs=["labelpos"];function buildLayoutGraph(inputGraph){var g=new Graph({multigraph:true,compound:true}),graph=canonicalize(inputGraph.graph());g.setGraph(_.merge({},graphDefaults,selectNumberAttrs(graph,graphNumAttrs),_.pick(graph,graphAttrs)));_.each(inputGraph.nodes(),function(v){var node=canonicalize(inputGraph.node(v));g.setNode(v,_.defaults(selectNumberAttrs(node,nodeNumAttrs),nodeDefaults));g.setParent(v,inputGraph.parent(v))});_.each(inputGraph.edges(),function(e){var edge=canonicalize(inputGraph.edge(e));g.setEdge(e,_.merge({},edgeDefaults,selectNumberAttrs(edge,edgeNumAttrs),_.pick(edge,edgeAttrs)))});return g}function makeSpaceForEdgeLabels(g){var graph=g.graph();graph.ranksep/=2;_.each(g.edges(),function(e){var edge=g.edge(e);edge.minlen*=2;if(edge.labelpos.toLowerCase()!=="c"){if(graph.rankdir==="TB"||graph.rankdir==="BT"){edge.width+=edge.labeloffset}else{edge.height+=edge.labeloffset}}})}function injectEdgeLabelProxies(g){_.each(g.edges(),function(e){var edge=g.edge(e);if(edge.width&&edge.height){var v=g.node(e.v),w=g.node(e.w),label={rank:(w.rank-v.rank)/2+v.rank,e:e};util.addDummyNode(g,"edge-proxy",label,"_ep")}})}function assignRankMinMax(g){var maxRank=0;_.each(g.nodes(),function(v){var node=g.node(v);if(node.borderTop){node.minRank=g.node(node.borderTop).rank;node.maxRank=g.node(node.borderBottom).rank;maxRank=_.max(maxRank,node.maxRank)}});g.graph().maxRank=maxRank}function removeEdgeLabelProxies(g){_.each(g.nodes(),function(v){var node=g.node(v);if(node.dummy==="edge-proxy"){g.edge(node.e).labelRank=node.rank;g.removeNode(v)}})}function translateGraph(g){var minX=Number.POSITIVE_INFINITY,maxX=0,minY=Number.POSITIVE_INFINITY,maxY=0,graphLabel=g.graph(),marginX=graphLabel.marginx||0,marginY=graphLabel.marginy||0;function getExtremes(attrs){var x=attrs.x,y=attrs.y,w=attrs.width,h=attrs.height;minX=Math.min(minX,x-w/2);maxX=Math.max(maxX,x+w/2);minY=Math.min(minY,y-h/2);maxY=Math.max(maxY,y+h/2)}_.each(g.nodes(),function(v){getExtremes(g.node(v))});_.each(g.edges(),function(e){var edge=g.edge(e);if(_.has(edge,"x")){getExtremes(edge)}});minX-=marginX;minY-=marginY;_.each(g.nodes(),function(v){var node=g.node(v);node.x-=minX;node.y-=minY});_.each(g.edges(),function(e){var edge=g.edge(e);_.each(edge.points,function(p){p.x-=minX;p.y-=minY});if(_.has(edge,"x")){edge.x-=minX}if(_.has(edge,"y")){edge.y-=minY}});graphLabel.width=maxX-minX+marginX;graphLabel.height=maxY-minY+marginY}function assignNodeIntersects(g){_.each(g.edges(),function(e){var edge=g.edge(e),nodeV=g.node(e.v),nodeW=g.node(e.w),p1,p2;if(!edge.points){edge.points=[];p1=nodeW;p2=nodeV}else{p1=edge.points[0];p2=edge.points[edge.points.length-1]}edge.points.unshift(util.intersectRect(nodeV,p1));edge.points.push(util.intersectRect(nodeW,p2))})}function fixupEdgeLabelCoords(g){_.each(g.edges(),function(e){var edge=g.edge(e);if(_.has(edge,"x")){if(edge.labelpos==="l"||edge.labelpos==="r"){edge.width-=edge.labeloffset}switch(edge.labelpos){case"l":edge.x-=edge.width/2+edge.labeloffset;break;case"r":edge.x+=edge.width/2+edge.labeloffset;break}}})}function reversePointsForReversedEdges(g){_.each(g.edges(),function(e){var edge=g.edge(e);if(edge.reversed){edge.points.reverse()}})}function removeBorderNodes(g){_.each(g.nodes(),function(v){if(g.children(v).length){var node=g.node(v),t=g.node(node.borderTop),b=g.node(node.borderBottom),l=g.node(_.last(node.borderLeft)),r=g.node(_.last(node.borderRight));node.width=Math.abs(r.x-l.x);node.height=Math.abs(b.y-t.y);node.x=l.x+node.width/2;node.y=t.y+node.height/2}});_.each(g.nodes(),function(v){if(g.node(v).dummy==="border"){g.removeNode(v)}})}function removeSelfEdges(g){_.each(g.edges(),function(e){if(e.v===e.w){var node=g.node(e.v);if(!node.selfEdges){node.selfEdges=[]}node.selfEdges.push({e:e,label:g.edge(e)});g.removeEdge(e)}})}function insertSelfEdges(g){var layers=util.buildLayerMatrix(g);_.each(layers,function(layer){var orderShift=0;_.each(layer,function(v,i){var node=g.node(v);node.order=i+orderShift;_.each(node.selfEdges,function(selfEdge){util.addDummyNode(g,"selfedge",{width:selfEdge.label.width,height:selfEdge.label.height,rank:node.rank,order:i+ ++orderShift,e:selfEdge.e,label:selfEdge.label},"_se")});delete node.selfEdges})})}function positionSelfEdges(g){_.each(g.nodes(),function(v){var node=g.node(v);if(node.dummy==="selfedge"){var selfNode=g.node(node.e.v),x=selfNode.x+selfNode.width/2,y=selfNode.y,dx=node.x-x,dy=selfNode.height/2;g.setEdge(node.e,node.label);g.removeNode(v);node.label.points=[{x:x+2*dx/3,y:y-dy},{x:x+5*dx/6,y:y-dy},{x:x+dx,y:y},{x:x+5*dx/6,y:y+dy},{x:x+2*dx/3,y:y+dy}];node.label.x=node.x;node.label.y=node.y}})}function selectNumberAttrs(obj,attrs){return _.mapValues(_.pick(obj,attrs),Number)}function canonicalize(attrs){var newAttrs={};_.each(attrs,function(v,k){newAttrs[k.toLowerCase()]=v});return newAttrs}},{"./acyclic":2,"./add-border-segments":3,"./coordinate-system":4,"./graphlib":7,"./lodash":10,"./nesting-graph":11,"./normalize":12,"./order":17,"./parent-dummy-chains":22,"./position":24,"./rank":26,"./util":29}],10:[function(require,module,exports){var lodash;if(typeof require==="function"){try{lodash=require("lodash")}catch(e){}}if(!lodash){lodash=window._}module.exports=lodash},{lodash:51}],11:[function(require,module,exports){var _=require("./lodash"),util=require("./util");module.exports={run:run,cleanup:cleanup};function run(g){var root=util.addDummyNode(g,"root",{},"_root"),depths=treeDepths(g),height=_.max(depths)-1,nodeSep=2*height+1;g.graph().nestingRoot=root;_.each(g.edges(),function(e){g.edge(e).minlen*=nodeSep});var weight=sumWeights(g)+1;_.each(g.children(),function(child){dfs(g,root,nodeSep,weight,height,depths,child)});g.graph().nodeRankFactor=nodeSep}function dfs(g,root,nodeSep,weight,height,depths,v){var children=g.children(v);if(!children.length){if(v!==root){g.setEdge(root,v,{weight:0,minlen:nodeSep})}return}var top=util.addBorderNode(g,"_bt"),bottom=util.addBorderNode(g,"_bb"),label=g.node(v);g.setParent(top,v);label.borderTop=top;g.setParent(bottom,v);label.borderBottom=bottom;_.each(children,function(child){dfs(g,root,nodeSep,weight,height,depths,child);var childNode=g.node(child),childTop=childNode.borderTop?childNode.borderTop:child,childBottom=childNode.borderBottom?childNode.borderBottom:child,thisWeight=childNode.borderTop?weight:2*weight,minlen=childTop!==childBottom?1:height-depths[v]+1;g.setEdge(top,childTop,{weight:thisWeight,minlen:minlen,nestingEdge:true});g.setEdge(childBottom,bottom,{weight:thisWeight,minlen:minlen,nestingEdge:true})});if(!g.parent(v)){g.setEdge(root,top,{weight:0,minlen:height+depths[v]})}}function treeDepths(g){var depths={};function dfs(v,depth){var children=g.children(v);if(children&&children.length){_.each(children,function(child){dfs(child,depth+1)})}depths[v]=depth}_.each(g.children(),function(v){dfs(v,1)});return depths}function sumWeights(g){return _.reduce(g.edges(),function(acc,e){return acc+g.edge(e).weight},0)}function cleanup(g){var graphLabel=g.graph();g.removeNode(graphLabel.nestingRoot);delete graphLabel.nestingRoot;_.each(g.edges(),function(e){var edge=g.edge(e);if(edge.nestingEdge){g.removeEdge(e)}})}},{"./lodash":10,"./util":29}],12:[function(require,module,exports){"use strict";var _=require("./lodash"),util=require("./util");module.exports={run:run,undo:undo};function run(g){g.graph().dummyChains=[];_.each(g.edges(),function(edge){normalizeEdge(g,edge)})}function normalizeEdge(g,e){var v=e.v,vRank=g.node(v).rank,w=e.w,wRank=g.node(w).rank,name=e.name,edgeLabel=g.edge(e),labelRank=edgeLabel.labelRank;if(wRank===vRank+1)return;g.removeEdge(e);var dummy,attrs,i;for(i=0,++vRank;vRank0){if(index%2){weightSum+=tree[index+1]}index=index-1>>1;tree[index]+=entry.weight}cc+=entry.weight*weightSum}));return cc}},{"../lodash":10}],17:[function(require,module,exports){"use strict";var _=require("../lodash"),initOrder=require("./init-order"),crossCount=require("./cross-count"),sortSubgraph=require("./sort-subgraph"),buildLayerGraph=require("./build-layer-graph"),addSubgraphConstraints=require("./add-subgraph-constraints"),Graph=require("../graphlib").Graph,util=require("../util");module.exports=order;function order(g){var maxRank=util.maxRank(g),downLayerGraphs=buildLayerGraphs(g,_.range(1,maxRank+1),"inEdges"),upLayerGraphs=buildLayerGraphs(g,_.range(maxRank-1,-1,-1),"outEdges");var layering=initOrder(g);assignOrder(g,layering);var bestCC=Number.POSITIVE_INFINITY,best;for(var i=0,lastBest=0;lastBest<4;++i,++lastBest){sweepLayerGraphs(i%2?downLayerGraphs:upLayerGraphs,i%4>=2);layering=util.buildLayerMatrix(g);var cc=crossCount(g,layering);if(cc=vEntry.barycenter){mergeEntries(vEntry,uEntry)}}}function handleOut(vEntry){return function(wEntry){wEntry["in"].push(vEntry);if(--wEntry.indegree===0){sourceSet.push(wEntry)}}}while(sourceSet.length){var entry=sourceSet.pop();entries.push(entry);_.each(entry["in"].reverse(),handleIn(entry));_.each(entry.out,handleOut(entry))}return _.chain(entries).filter(function(entry){return!entry.merged}).map(function(entry){return _.pick(entry,["vs","i","barycenter","weight"])}).value()}function mergeEntries(target,source){var sum=0,weight=0;if(target.weight){sum+=target.barycenter*target.weight;weight+=target.weight}if(source.weight){sum+=source.barycenter*source.weight;weight+=source.weight}target.vs=source.vs.concat(target.vs);target.barycenter=sum/weight;target.weight=weight;target.i=Math.min(source.i,target.i);source.merged=true}},{"../lodash":10}],20:[function(require,module,exports){var _=require("../lodash"),barycenter=require("./barycenter"),resolveConflicts=require("./resolve-conflicts"),sort=require("./sort");module.exports=sortSubgraph;function sortSubgraph(g,v,cg,biasRight){var movable=g.children(v),node=g.node(v),bl=node?node.borderLeft:undefined,br=node?node.borderRight:undefined,subgraphs={};if(bl){movable=_.filter(movable,function(w){return w!==bl&&w!==br})}var barycenters=barycenter(g,movable);_.each(barycenters,function(entry){if(g.children(entry.v).length){var subgraphResult=sortSubgraph(g,entry.v,cg,biasRight);subgraphs[entry.v]=subgraphResult;if(_.has(subgraphResult,"barycenter")){mergeBarycenters(entry,subgraphResult)}}});var entries=resolveConflicts(barycenters,cg);expandSubgraphs(entries,subgraphs);var result=sort(entries,biasRight);if(bl){result.vs=_.flatten([bl,result.vs,br],true);if(g.predecessors(bl).length){var blPred=g.node(g.predecessors(bl)[0]),brPred=g.node(g.predecessors(br)[0]);if(!_.has(result,"barycenter")){result.barycenter=0;result.weight=0}result.barycenter=(result.barycenter*result.weight+blPred.order+brPred.order)/(result.weight+2);result.weight+=2}}return result}function expandSubgraphs(entries,subgraphs){_.each(entries,function(entry){entry.vs=_.flatten(entry.vs.map(function(v){if(subgraphs[v]){return subgraphs[v].vs}return v}),true)})}function mergeBarycenters(target,other){if(!_.isUndefined(target.barycenter)){target.barycenter=(target.barycenter*target.weight+other.barycenter*other.weight)/(target.weight+other.weight);target.weight+=other.weight}else{target.barycenter=other.barycenter;target.weight=other.weight}}},{"../lodash":10,"./barycenter":14,"./resolve-conflicts":19,"./sort":21}],21:[function(require,module,exports){var _=require("../lodash"),util=require("../util");module.exports=sort;function sort(entries,biasRight){var parts=util.partition(entries,function(entry){return _.has(entry,"barycenter")});var sortable=parts.lhs,unsortable=_.sortBy(parts.rhs,function(entry){return-entry.i}),vs=[],sum=0,weight=0,vsIndex=0;sortable.sort(compareWithBias(!!biasRight));vsIndex=consumeUnsortable(vs,unsortable,vsIndex);_.each(sortable,function(entry){vsIndex+=entry.vs.length;vs.push(entry.vs);sum+=entry.barycenter*entry.weight;weight+=entry.weight;vsIndex=consumeUnsortable(vs,unsortable,vsIndex)});var result={vs:_.flatten(vs,true)};if(weight){result.barycenter=sum/weight;result.weight=weight}return result}function consumeUnsortable(vs,unsortable,index){var last;while(unsortable.length&&(last=_.last(unsortable)).i<=index){unsortable.pop();vs.push(last.vs);index++}return index}function compareWithBias(bias){return function(entryV,entryW){if(entryV.barycenterentryW.barycenter){return 1}return!bias?entryV.i-entryW.i:entryW.i-entryV.i}}},{"../lodash":10,"../util":29}],22:[function(require,module,exports){var _=require("./lodash");module.exports=parentDummyChains;function parentDummyChains(g){var postorderNums=postorder(g);_.each(g.graph().dummyChains,function(v){var node=g.node(v),edgeObj=node.edgeObj,pathData=findPath(g,postorderNums,edgeObj.v,edgeObj.w),path=pathData.path,lca=pathData.lca,pathIdx=0,pathV=path[pathIdx],ascending=true;while(v!==edgeObj.w){node=g.node(v);if(ascending){while((pathV=path[pathIdx])!==lca&&g.node(pathV).maxRanklow||lim>postorderNums[parent].lim));lca=parent;parent=w;while((parent=g.parent(parent))!==lca){wPath.push(parent)}return{path:vPath.concat(wPath.reverse()),lca:lca}}function postorder(g){var result={},lim=0;function dfs(v){var low=lim;_.each(g.children(v),dfs);result[v]={low:low,lim:lim++}}_.each(g.children(),dfs);return result}},{"./lodash":10}],23:[function(require,module,exports){"use strict";var _=require("../lodash"),Graph=require("../graphlib").Graph,util=require("../util");module.exports={positionX:positionX,findType1Conflicts:findType1Conflicts,findType2Conflicts:findType2Conflicts,addConflict:addConflict,hasConflict:hasConflict,verticalAlignment:verticalAlignment,horizontalCompaction:horizontalCompaction,alignCoordinates:alignCoordinates,findSmallestWidthAlignment:findSmallestWidthAlignment,balance:balance};function findType1Conflicts(g,layering){var conflicts={};function visitLayer(prevLayer,layer){var k0=0,scanPos=0,prevLayerLength=prevLayer.length,lastNode=_.last(layer);_.each(layer,function(v,i){var w=findOtherInnerSegmentNode(g,v),k1=w?g.node(w).order:prevLayerLength;if(w||v===lastNode){_.each(layer.slice(scanPos,i+1),function(scanNode){_.each(g.predecessors(scanNode),function(u){var uLabel=g.node(u),uPos=uLabel.order; + if((uPosnextNorthBorder)){addConflict(conflicts,u,v)}})}})}function visitLayer(north,south){var prevNorthPos=-1,nextNorthPos,southPos=0;_.each(south,function(v,southLookahead){if(g.node(v).dummy==="border"){var predecessors=g.predecessors(v);if(predecessors.length){nextNorthPos=g.node(predecessors[0]).order;scan(south,southPos,southLookahead,prevNorthPos,nextNorthPos);southPos=southLookahead;prevNorthPos=nextNorthPos}}scan(south,southPos,south.length,nextNorthPos,north.length)});return south}_.reduce(layering,visitLayer);return conflicts}function findOtherInnerSegmentNode(g,v){if(g.node(v).dummy){return _.find(g.predecessors(v),function(u){return g.node(u).dummy})}}function addConflict(conflicts,v,w){if(v>w){var tmp=v;v=w;w=tmp}var conflictsV=conflicts[v];if(!conflictsV){conflicts[v]=conflictsV={}}conflictsV[w]=true}function hasConflict(conflicts,v,w){if(v>w){var tmp=v;v=w;w=tmp}return _.has(conflicts[v],w)}function verticalAlignment(g,layering,conflicts,neighborFn){var root={},align={},pos={};_.each(layering,function(layer){_.each(layer,function(v,order){root[v]=v;align[v]=v;pos[v]=order})});_.each(layering,function(layer){var prevIdx=-1;_.each(layer,function(v){var ws=neighborFn(v);if(ws.length){ws=_.sortBy(ws,function(w){return pos[w]});var mp=(ws.length-1)/2;for(var i=Math.floor(mp),il=Math.ceil(mp);i<=il;++i){var w=ws[i];if(align[v]===v&&prevIdxwLabel.lim){tailLabel=wLabel;flip=true}var candidates=_.filter(g.edges(),function(edge){return flip===isDescendant(t,t.node(edge.v),tailLabel)&&flip!==isDescendant(t,t.node(edge.w),tailLabel)});return _.min(candidates,function(edge){return slack(g,edge)})}function exchangeEdges(t,g,e,f){var v=e.v,w=e.w;t.removeEdge(v,w);t.setEdge(f.v,f.w,{});initLowLimValues(t);initCutValues(t,g);updateRanks(t,g)}function updateRanks(t,g){var root=_.find(t.nodes(),function(v){return!g.node(v).parent}),vs=preorder(t,root);vs=vs.slice(1);_.each(vs,function(v){var parent=t.node(v).parent,edge=g.edge(v,parent),flipped=false;if(!edge){edge=g.edge(parent,v);flipped=true}g.node(v).rank=g.node(parent).rank+(flipped?edge.minlen:-edge.minlen)})}function isTreeEdge(tree,u,v){return tree.hasEdge(u,v)}function isDescendant(tree,vLabel,rootLabel){return rootLabel.low<=vLabel.lim&&vLabel.lim<=rootLabel.lim}},{"../graphlib":7,"../lodash":10,"../util":29,"./feasible-tree":25,"./util":28}],28:[function(require,module,exports){"use strict";var _=require("../lodash");module.exports={longestPath:longestPath,slack:slack};function longestPath(g){var visited={};function dfs(v){var label=g.node(v);if(_.has(visited,v)){return label.rank}visited[v]=true;var rank=_.min(_.map(g.outEdges(v),function(e){return dfs(e.w)-g.edge(e).minlen}));if(rank===Number.POSITIVE_INFINITY){rank=0}return label.rank=rank}_.each(g.sources(),dfs)}function slack(g,e){return g.node(e.w).rank-g.node(e.v).rank-g.edge(e).minlen}},{"../lodash":10}],29:[function(require,module,exports){"use strict";var _=require("./lodash"),Graph=require("./graphlib").Graph;module.exports={addDummyNode:addDummyNode,simplify:simplify,asNonCompoundGraph:asNonCompoundGraph,successorWeights:successorWeights,predecessorWeights:predecessorWeights,intersectRect:intersectRect,buildLayerMatrix:buildLayerMatrix,normalizeRanks:normalizeRanks,removeEmptyRanks:removeEmptyRanks,addBorderNode:addBorderNode,maxRank:maxRank,partition:partition,time:time,notime:notime};function addDummyNode(g,type,attrs,name){var v;do{v=_.uniqueId(name)}while(g.hasNode(v));attrs.dummy=type;g.setNode(v,attrs);return v}function simplify(g){var simplified=(new Graph).setGraph(g.graph());_.each(g.nodes(),function(v){simplified.setNode(v,g.node(v))});_.each(g.edges(),function(e){var simpleLabel=simplified.edge(e.v,e.w)||{weight:0,minlen:1},label=g.edge(e);simplified.setEdge(e.v,e.w,{weight:simpleLabel.weight+label.weight,minlen:Math.max(simpleLabel.minlen,label.minlen)})});return simplified}function asNonCompoundGraph(g){var simplified=new Graph({multigraph:g.isMultigraph()}).setGraph(g.graph());_.each(g.nodes(),function(v){if(!g.children(v).length){simplified.setNode(v,g.node(v))}});_.each(g.edges(),function(e){simplified.setEdge(e,g.edge(e))});return simplified}function successorWeights(g){var weightMap=_.map(g.nodes(),function(v){var sucs={};_.each(g.outEdges(v),function(e){sucs[e.w]=(sucs[e.w]||0)+g.edge(e).weight});return sucs});return _.zipObject(g.nodes(),weightMap)}function predecessorWeights(g){var weightMap=_.map(g.nodes(),function(v){var preds={};_.each(g.inEdges(v),function(e){preds[e.v]=(preds[e.v]||0)+g.edge(e).weight});return preds});return _.zipObject(g.nodes(),weightMap)}function intersectRect(rect,point){var x=rect.x;var y=rect.y;var dx=point.x-x;var dy=point.y-y;var w=rect.width/2;var h=rect.height/2;if(!dx&&!dy){throw new Error("Not possible to find intersection inside of the rectangle")}var sx,sy;if(Math.abs(dy)*w>Math.abs(dx)*h){if(dy<0){h=-h}sx=h*dx/dy;sy=h}else{if(dx<0){w=-w}sx=w;sy=w*dy/dx}return{x:x+sx,y:y+sy}}function buildLayerMatrix(g){var layering=_.map(_.range(maxRank(g)+1),function(){return[]});_.each(g.nodes(),function(v){var node=g.node(v),rank=node.rank;if(!_.isUndefined(rank)){layering[rank][node.order]=v}});return layering}function normalizeRanks(g){var min=_.min(_.map(g.nodes(),function(v){return g.node(v).rank}));_.each(g.nodes(),function(v){var node=g.node(v);if(_.has(node,"rank")){node.rank-=min}})}function removeEmptyRanks(g){var offset=_.min(_.map(g.nodes(),function(v){return g.node(v).rank}));var layers=[];_.each(g.nodes(),function(v){var rank=g.node(v).rank-offset;if(!layers[rank]){layers[rank]=[]}layers[rank].push(v)});var delta=0,nodeRankFactor=g.graph().nodeRankFactor;_.each(layers,function(vs,i){if(_.isUndefined(vs)&&i%nodeRankFactor!==0){--delta}else if(delta){_.each(vs,function(v){g.node(v).rank+=delta})}})}function addBorderNode(g,prefix,rank,order){var node={width:0,height:0};if(arguments.length>=4){node.rank=rank;node.order=order}return addDummyNode(g,"border",node,prefix)}function maxRank(g){return _.max(_.map(g.nodes(),function(v){var rank=g.node(v).rank;if(!_.isUndefined(rank)){return rank}}))}function partition(collection,fn){var result={lhs:[],rhs:[]};_.each(collection,function(value){if(fn(value)){result.lhs.push(value)}else{result.rhs.push(value)}});return result}function time(name,fn){var start=_.now();try{return fn()}finally{console.log(name+" time: "+(_.now()-start)+"ms")}}function notime(name,fn){return fn()}},{"./graphlib":7,"./lodash":10}],30:[function(require,module,exports){module.exports="0.7.4"},{}],31:[function(require,module,exports){var lib=require("./lib");module.exports={Graph:lib.Graph,json:require("./lib/json"),alg:require("./lib/alg"),version:lib.version}},{"./lib":47,"./lib/alg":38,"./lib/json":48}],32:[function(require,module,exports){var _=require("../lodash");module.exports=components;function components(g){var visited={},cmpts=[],cmpt;function dfs(v){if(_.has(visited,v))return;visited[v]=true;cmpt.push(v);_.each(g.successors(v),dfs);_.each(g.predecessors(v),dfs)}_.each(g.nodes(),function(v){cmpt=[];dfs(v);if(cmpt.length){cmpts.push(cmpt)}});return cmpts}},{"../lodash":49}],33:[function(require,module,exports){var _=require("../lodash");module.exports=dfs;function dfs(g,vs,order){if(!_.isArray(vs)){vs=[vs]}var acc=[],visited={};_.each(vs,function(v){if(!g.hasNode(v)){throw new Error("Graph does not have node: "+v)}doDfs(g,v,order==="post",visited,acc)});return acc}function doDfs(g,v,postorder,visited,acc){if(!_.has(visited,v)){visited[v]=true;if(!postorder){acc.push(v)}_.each(g.neighbors(v),function(w){doDfs(g,w,postorder,visited,acc)});if(postorder){acc.push(v)}}}},{"../lodash":49}],34:[function(require,module,exports){var dijkstra=require("./dijkstra"),_=require("../lodash");module.exports=dijkstraAll;function dijkstraAll(g,weightFunc,edgeFunc){return _.transform(g.nodes(),function(acc,v){acc[v]=dijkstra(g,v,weightFunc,edgeFunc)},{})}},{"../lodash":49,"./dijkstra":35}],35:[function(require,module,exports){var _=require("../lodash"),PriorityQueue=require("../data/priority-queue");module.exports=dijkstra;var DEFAULT_WEIGHT_FUNC=_.constant(1);function dijkstra(g,source,weightFn,edgeFn){return runDijkstra(g,String(source),weightFn||DEFAULT_WEIGHT_FUNC,edgeFn||function(v){return g.outEdges(v)})}function runDijkstra(g,source,weightFn,edgeFn){var results={},pq=new PriorityQueue,v,vEntry;var updateNeighbors=function(edge){var w=edge.v!==v?edge.v:edge.w,wEntry=results[w],weight=weightFn(edge),distance=vEntry.distance+weight;if(weight<0){throw new Error("dijkstra does not allow negative edge weights. "+"Bad edge: "+edge+" Weight: "+weight)}if(distance0){v=pq.removeMin();vEntry=results[v];if(vEntry.distance===Number.POSITIVE_INFINITY){break}edgeFn(v).forEach(updateNeighbors)}return results}},{"../data/priority-queue":45,"../lodash":49}],36:[function(require,module,exports){var _=require("../lodash"),tarjan=require("./tarjan");module.exports=findCycles;function findCycles(g){return _.filter(tarjan(g),function(cmpt){return cmpt.length>1||cmpt.length===1&&g.hasEdge(cmpt[0],cmpt[0])})}},{"../lodash":49,"./tarjan":43}],37:[function(require,module,exports){var _=require("../lodash");module.exports=floydWarshall;var DEFAULT_WEIGHT_FUNC=_.constant(1);function floydWarshall(g,weightFn,edgeFn){return runFloydWarshall(g,weightFn||DEFAULT_WEIGHT_FUNC,edgeFn||function(v){return g.outEdges(v)})}function runFloydWarshall(g,weightFn,edgeFn){var results={},nodes=g.nodes();nodes.forEach(function(v){results[v]={};results[v][v]={distance:0};nodes.forEach(function(w){if(v!==w){results[v][w]={distance:Number.POSITIVE_INFINITY}}});edgeFn(v).forEach(function(edge){var w=edge.v===v?edge.w:edge.v,d=weightFn(edge);results[v][w]={distance:d,predecessor:v}})});nodes.forEach(function(k){var rowK=results[k];nodes.forEach(function(i){var rowI=results[i];nodes.forEach(function(j){var ik=rowI[k];var kj=rowK[j];var ij=rowI[j];var altDistance=ik.distance+kj.distance;if(altDistance0){v=pq.removeMin();if(_.has(parents,v)){result.setEdge(v,parents[v])}else if(init){throw new Error("Input graph is not connected: "+g)}else{init=true}g.nodeEdges(v).forEach(updateNeighbors)}return result}},{"../data/priority-queue":45,"../graph":46,"../lodash":49}],43:[function(require,module,exports){var _=require("../lodash");module.exports=tarjan;function tarjan(g){var index=0,stack=[],visited={},results=[];function dfs(v){var entry=visited[v]={onStack:true,lowlink:index,index:index++};stack.push(v);g.successors(v).forEach(function(w){if(!_.has(visited,w)){dfs(w);entry.lowlink=Math.min(entry.lowlink,visited[w].lowlink)}else if(visited[w].onStack){entry.lowlink=Math.min(entry.lowlink,visited[w].index)}});if(entry.lowlink===entry.index){var cmpt=[],w;do{w=stack.pop();visited[w].onStack=false;cmpt.push(w)}while(v!==w);results.push(cmpt)}}g.nodes().forEach(function(v){if(!_.has(visited,v)){dfs(v)}});return results}},{"../lodash":49}],44:[function(require,module,exports){var _=require("../lodash");module.exports=topsort;topsort.CycleException=CycleException;function topsort(g){var visited={},stack={},results=[];function visit(node){if(_.has(stack,node)){throw new CycleException}if(!_.has(visited,node)){stack[node]=true;visited[node]=true;_.each(g.predecessors(node),visit);delete stack[node];results.push(node)}}_.each(g.sinks(),visit);if(_.size(visited)!==g.nodeCount()){throw new CycleException}return results}function CycleException(){}},{"../lodash":49}],45:[function(require,module,exports){var _=require("../lodash");module.exports=PriorityQueue;function PriorityQueue(){this._arr=[];this._keyIndices={}}PriorityQueue.prototype.size=function(){return this._arr.length};PriorityQueue.prototype.keys=function(){return this._arr.map(function(x){return x.key})};PriorityQueue.prototype.has=function(key){return _.has(this._keyIndices,key)};PriorityQueue.prototype.priority=function(key){var index=this._keyIndices[key];if(index!==undefined){return this._arr[index].priority}};PriorityQueue.prototype.min=function(){if(this.size()===0){throw new Error("Queue underflow")}return this._arr[0].key};PriorityQueue.prototype.add=function(key,priority){var keyIndices=this._keyIndices;key=String(key);if(!_.has(keyIndices,key)){var arr=this._arr;var index=arr.length;keyIndices[key]=index;arr.push({key:key,priority:priority});this._decrease(index);return true}return false};PriorityQueue.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var min=this._arr.pop();delete this._keyIndices[min.key];this._heapify(0);return min.key};PriorityQueue.prototype.decrease=function(key,priority){var index=this._keyIndices[key];if(priority>this._arr[index].priority){throw new Error("New priority is greater than current priority. "+"Key: "+key+" Old: "+this._arr[index].priority+" New: "+priority)}this._arr[index].priority=priority;this._decrease(index)};PriorityQueue.prototype._heapify=function(i){var arr=this._arr;var l=2*i,r=l+1,largest=i;if(l>1;if(arr[parent].priority1){this.setNode(v,value)}else{this.setNode(v)}},this);return this};Graph.prototype.setNode=function(v,value){if(_.has(this._nodes,v)){if(arguments.length>1){this._nodes[v]=value}return this}this._nodes[v]=arguments.length>1?value:this._defaultNodeLabelFn(v);if(this._isCompound){this._parent[v]=GRAPH_NODE;this._children[v]={};this._children[GRAPH_NODE][v]=true}this._in[v]={};this._preds[v]={};this._out[v]={};this._sucs[v]={};++this._nodeCount;return this};Graph.prototype.node=function(v){return this._nodes[v]};Graph.prototype.hasNode=function(v){return _.has(this._nodes,v)};Graph.prototype.removeNode=function(v){var self=this;if(_.has(this._nodes,v)){var removeEdge=function(e){self.removeEdge(self._edgeObjs[e])};delete this._nodes[v];if(this._isCompound){this._removeFromParentsChildList(v);delete this._parent[v];_.each(this.children(v),function(child){this.setParent(child)},this);delete this._children[v]}_.each(_.keys(this._in[v]),removeEdge);delete this._in[v];delete this._preds[v];_.each(_.keys(this._out[v]),removeEdge);delete this._out[v];delete this._sucs[v];--this._nodeCount}return this};Graph.prototype.setParent=function(v,parent){if(!this._isCompound){throw new Error("Cannot set parent in a non-compound graph")}if(_.isUndefined(parent)){parent=GRAPH_NODE}else{parent+="";for(var ancestor=parent;!_.isUndefined(ancestor);ancestor=this.parent(ancestor)){if(ancestor===v){throw new Error("Setting "+parent+" as parent of "+v+" would create create a cycle")}}this.setNode(parent)}this.setNode(v);this._removeFromParentsChildList(v);this._parent[v]=parent;this._children[parent][v]=true;return this};Graph.prototype._removeFromParentsChildList=function(v){delete this._children[this._parent[v]][v]};Graph.prototype.parent=function(v){if(this._isCompound){var parent=this._parent[v];if(parent!==GRAPH_NODE){return parent}}};Graph.prototype.children=function(v){if(_.isUndefined(v)){v=GRAPH_NODE}if(this._isCompound){var children=this._children[v];if(children){return _.keys(children)}}else if(v===GRAPH_NODE){return this.nodes()}else if(this.hasNode(v)){return[]}};Graph.prototype.predecessors=function(v){var predsV=this._preds[v];if(predsV){return _.keys(predsV)}};Graph.prototype.successors=function(v){var sucsV=this._sucs[v];if(sucsV){return _.keys(sucsV)}};Graph.prototype.neighbors=function(v){var preds=this.predecessors(v);if(preds){return _.union(preds,this.successors(v))}};Graph.prototype.setDefaultEdgeLabel=function(newDefault){if(!_.isFunction(newDefault)){newDefault=_.constant(newDefault)}this._defaultEdgeLabelFn=newDefault;return this};Graph.prototype.edgeCount=function(){return this._edgeCount};Graph.prototype.edges=function(){return _.values(this._edgeObjs)};Graph.prototype.setPath=function(vs,value){var self=this,args=arguments;_.reduce(vs,function(v,w){if(args.length>1){self.setEdge(v,w,value)}else{self.setEdge(v,w)}return w});return this};Graph.prototype.setEdge=function(){var v,w,name,value,valueSpecified=false;if(_.isPlainObject(arguments[0])){v=arguments[0].v;w=arguments[0].w;name=arguments[0].name;if(arguments.length===2){value=arguments[1];valueSpecified=true}}else{v=arguments[0];w=arguments[1];name=arguments[3];if(arguments.length>2){value=arguments[2];valueSpecified=true}}v=""+v;w=""+w;if(!_.isUndefined(name)){name=""+name}var e=edgeArgsToId(this._isDirected,v,w,name);if(_.has(this._edgeLabels,e)){if(valueSpecified){this._edgeLabels[e]=value}return this}if(!_.isUndefined(name)&&!this._isMultigraph){throw new Error("Cannot set a named edge when isMultigraph = false")}this.setNode(v);this.setNode(w);this._edgeLabels[e]=valueSpecified?value:this._defaultEdgeLabelFn(v,w,name);var edgeObj=edgeArgsToObj(this._isDirected,v,w,name);v=edgeObj.v;w=edgeObj.w;Object.freeze(edgeObj);this._edgeObjs[e]=edgeObj;incrementOrInitEntry(this._preds[w],v);incrementOrInitEntry(this._sucs[v],w);this._in[w][e]=edgeObj;this._out[v][e]=edgeObj;this._edgeCount++;return this};Graph.prototype.edge=function(v,w,name){var e=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,v,w,name);return this._edgeLabels[e]};Graph.prototype.hasEdge=function(v,w,name){var e=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,v,w,name);return _.has(this._edgeLabels,e)};Graph.prototype.removeEdge=function(v,w,name){var e=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,v,w,name),edge=this._edgeObjs[e];if(edge){v=edge.v;w=edge.w;delete this._edgeLabels[e];delete this._edgeObjs[e];decrementOrRemoveEntry(this._preds[w],v);decrementOrRemoveEntry(this._sucs[v],w);delete this._in[w][e];delete this._out[v][e];this._edgeCount--}return this};Graph.prototype.inEdges=function(v,u){var inV=this._in[v];if(inV){var edges=_.values(inV);if(!u){return edges}return _.filter(edges,function(edge){return edge.v===u})}};Graph.prototype.outEdges=function(v,w){var outV=this._out[v];if(outV){var edges=_.values(outV);if(!w){return edges}return _.filter(edges,function(edge){return edge.w===w})}};Graph.prototype.nodeEdges=function(v,w){var inEdges=this.inEdges(v,w);if(inEdges){return inEdges.concat(this.outEdges(v,w))}};function incrementOrInitEntry(map,k){if(_.has(map,k)){map[k]++}else{map[k]=1}}function decrementOrRemoveEntry(map,k){if(!--map[k]){delete map[k]}}function edgeArgsToId(isDirected,v,w,name){if(!isDirected&&v>w){var tmp=v;v=w;w=tmp}return v+EDGE_KEY_DELIM+w+EDGE_KEY_DELIM+(_.isUndefined(name)?DEFAULT_EDGE_NAME:name)}function edgeArgsToObj(isDirected,v,w,name){if(!isDirected&&v>w){var tmp=v;v=w;w=tmp}var edgeObj={v:v,w:w};if(name){edgeObj.name=name}return edgeObj}function edgeObjToId(isDirected,edgeObj){return edgeArgsToId(isDirected,edgeObj.v,edgeObj.w,edgeObj.name)}},{"./lodash":49}],47:[function(require,module,exports){module.exports={Graph:require("./graph"),version:require("./version")}},{"./graph":46,"./version":50}],48:[function(require,module,exports){var _=require("./lodash"),Graph=require("./graph");module.exports={write:write,read:read};function write(g){var json={options:{directed:g.isDirected(),multigraph:g.isMultigraph(),compound:g.isCompound()},nodes:writeNodes(g),edges:writeEdges(g)}; + if(!_.isUndefined(g.graph())){json.value=_.clone(g.graph())}return json}function writeNodes(g){return _.map(g.nodes(),function(v){var nodeValue=g.node(v),parent=g.parent(v),node={v:v};if(!_.isUndefined(nodeValue)){node.value=nodeValue}if(!_.isUndefined(parent)){node.parent=parent}return node})}function writeEdges(g){return _.map(g.edges(),function(e){var edgeValue=g.edge(e),edge={v:e.v,w:e.w};if(!_.isUndefined(e.name)){edge.name=e.name}if(!_.isUndefined(edgeValue)){edge.value=edgeValue}return edge})}function read(json){var g=new Graph(json.options).setGraph(json.value);_.each(json.nodes,function(entry){g.setNode(entry.v,entry.value);if(entry.parent){g.setParent(entry.v,entry.parent)}});_.each(json.edges,function(entry){g.setEdge({v:entry.v,w:entry.w,name:entry.name},entry.value)});return g}},{"./graph":46,"./lodash":49}],49:[function(require,module,exports){module.exports=require(10)},{"/Users/cpettitt/projects/dagre/lib/lodash.js":10,lodash:51}],50:[function(require,module,exports){module.exports="1.0.5"},{}],51:[function(require,module,exports){(function(global){(function(){var undefined;var VERSION="3.10.0";var BIND_FLAG=1,BIND_KEY_FLAG=2,CURRY_BOUND_FLAG=4,CURRY_FLAG=8,CURRY_RIGHT_FLAG=16,PARTIAL_FLAG=32,PARTIAL_RIGHT_FLAG=64,ARY_FLAG=128,REARG_FLAG=256;var DEFAULT_TRUNC_LENGTH=30,DEFAULT_TRUNC_OMISSION="...";var HOT_COUNT=150,HOT_SPAN=16;var LARGE_ARRAY_SIZE=200;var LAZY_FILTER_FLAG=1,LAZY_MAP_FLAG=2;var FUNC_ERROR_TEXT="Expected a function";var PLACEHOLDER="__lodash_placeholder__";var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]";var arrayBufferTag="[object ArrayBuffer]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";var reEmptyStringLeading=/\b__p \+= '';/g,reEmptyStringMiddle=/\b(__p \+=) '' \+/g,reEmptyStringTrailing=/(__e\(.*?\)|\b__t\)) \+\n'';/g;var reEscapedHtml=/&(?:amp|lt|gt|quot|#39|#96);/g,reUnescapedHtml=/[&<>"'`]/g,reHasEscapedHtml=RegExp(reEscapedHtml.source),reHasUnescapedHtml=RegExp(reUnescapedHtml.source);var reEscape=/<%-([\s\S]+?)%>/g,reEvaluate=/<%([\s\S]+?)%>/g,reInterpolate=/<%=([\s\S]+?)%>/g;var reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;var reRegExpChars=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,reHasRegExpChars=RegExp(reRegExpChars.source);var reComboMark=/[\u0300-\u036f\ufe20-\ufe23]/g;var reEscapeChar=/\\(\\)?/g;var reEsTemplate=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;var reFlags=/\w*$/;var reHasHexPrefix=/^0[xX]/;var reIsHostCtor=/^\[object .+?Constructor\]$/;var reIsUint=/^\d+$/;var reLatin1=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;var reNoMatch=/($^)/;var reUnescapedString=/['\n\r\u2028\u2029\\]/g;var reWords=function(){var upper="[A-Z\\xc0-\\xd6\\xd8-\\xde]",lower="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(upper+"+(?="+upper+lower+")|"+upper+"?"+lower+"|"+upper+"+|[0-9]+","g")}();var contextProps=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap"];var templateCounter=-1;var typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=true;typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=false;var cloneableTags={};cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[stringTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=true;cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[mapTag]=cloneableTags[setTag]=cloneableTags[weakMapTag]=false;var deburredLetters={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"};var htmlEscapes={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};var htmlUnescapes={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"};var objectTypes={"function":true,object:true};var regexpEscapes={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"};var stringEscapes={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};var freeExports=objectTypes[typeof exports]&&exports&&!exports.nodeType&&exports;var freeModule=objectTypes[typeof module]&&module&&!module.nodeType&&module;var freeGlobal=freeExports&&freeModule&&typeof global=="object"&&global&&global.Object&&global;var freeSelf=objectTypes[typeof self]&&self&&self.Object&&self;var freeWindow=objectTypes[typeof window]&&window&&window.Object&&window;var moduleExports=freeModule&&freeModule.exports===freeExports&&freeExports;var root=freeGlobal||freeWindow!==(this&&this.window)&&freeWindow||freeSelf||this;function baseCompareAscending(value,other){if(value!==other){var valIsNull=value===null,valIsUndef=value===undefined,valIsReflexive=value===value;var othIsNull=other===null,othIsUndef=other===undefined,othIsReflexive=other===other;if(value>other&&!othIsNull||!valIsReflexive||valIsNull&&!othIsUndef&&othIsReflexive||valIsUndef&&othIsReflexive){return 1}if(value-1){}return index}function charsRightIndex(string,chars){var index=string.length;while(index--&&chars.indexOf(string.charAt(index))>-1){}return index}function compareAscending(object,other){return baseCompareAscending(object.criteria,other.criteria)||object.index-other.index}function compareMultiple(object,other,orders){var index=-1,objCriteria=object.criteria,othCriteria=other.criteria,length=objCriteria.length,ordersLength=orders.length;while(++index=ordersLength){return result}var order=orders[index];return result*(order==="asc"||order===true?1:-1)}}return object.index-other.index}function deburrLetter(letter){return deburredLetters[letter]}function escapeHtmlChar(chr){return htmlEscapes[chr]}function escapeRegExpChar(chr,leadingChar,whitespaceChar){if(leadingChar){chr=regexpEscapes[chr]}else if(whitespaceChar){chr=stringEscapes[chr]}return"\\"+chr}function escapeStringChar(chr){return"\\"+stringEscapes[chr]}function indexOfNaN(array,fromIndex,fromRight){var length=array.length,index=fromIndex+(fromRight?0:-1);while(fromRight?index--:++index=9&&charCode<=13)||charCode==32||charCode==160||charCode==5760||charCode==6158||charCode>=8192&&(charCode<=8202||charCode==8232||charCode==8233||charCode==8239||charCode==8287||charCode==12288||charCode==65279)}function replaceHolders(array,placeholder){var index=-1,length=array.length,resIndex=-1,result=[];while(++index>>1;var MAX_SAFE_INTEGER=9007199254740991;var metaMap=WeakMap&&new WeakMap;var realNames={};function lodash(value){if(isObjectLike(value)&&!isArray(value)&&!(value instanceof LazyWrapper)){if(value instanceof LodashWrapper){return value}if(hasOwnProperty.call(value,"__chain__")&&hasOwnProperty.call(value,"__wrapped__")){return wrapperClone(value)}}return new LodashWrapper(value)}function baseLodash(){}function LodashWrapper(value,chainAll,actions){this.__wrapped__=value;this.__actions__=actions||[];this.__chain__=!!chainAll}var support=lodash.support={};lodash.templateSettings={escape:reEscape,evaluate:reEvaluate,interpolate:reInterpolate,variable:"",imports:{_:lodash}};function LazyWrapper(value){this.__wrapped__=value;this.__actions__=[];this.__dir__=1;this.__filtered__=false;this.__iteratees__=[];this.__takeCount__=POSITIVE_INFINITY;this.__views__=[]}function lazyClone(){var result=new LazyWrapper(this.__wrapped__);result.__actions__=arrayCopy(this.__actions__);result.__dir__=this.__dir__;result.__filtered__=this.__filtered__;result.__iteratees__=arrayCopy(this.__iteratees__);result.__takeCount__=this.__takeCount__;result.__views__=arrayCopy(this.__views__);return result}function lazyReverse(){if(this.__filtered__){var result=new LazyWrapper(this);result.__dir__=-1;result.__filtered__=true}else{result=this.clone();result.__dir__*=-1}return result}function lazyValue(){var array=this.__wrapped__.value(),dir=this.__dir__,isArr=isArray(array),isRight=dir<0,arrLength=isArr?array.length:0,view=getView(0,arrLength,this.__views__),start=view.start,end=view.end,length=end-start,index=isRight?end:start-1,iteratees=this.__iteratees__,iterLength=iteratees.length,resIndex=0,takeCount=nativeMin(length,this.__takeCount__);if(!isArr||arrLength=LARGE_ARRAY_SIZE?createCache(values):null,valuesLength=values.length;if(cache){indexOf=cacheIndexOf;isCommon=false;values=cache}outer:while(++indexlength?0:length+start}end=end===undefined||end>length?length:+end||0;if(end<0){end+=length}length=start>end?0:end>>>0;start>>>=0;while(startlength?0:length+start}end=end===undefined||end>length?length:+end||0;if(end<0){end+=length}length=start>end?0:end-start>>>0;start>>>=0;var result=Array(length);while(++index=LARGE_ARRAY_SIZE,seen=isLarge?createCache():null,result=[];if(seen){indexOf=cacheIndexOf;isCommon=false}else{isLarge=false;seen=iteratee?[]:result}outer:while(++index>>1,computed=array[mid];if((retHighest?computed<=value:computed2?sources[length-2]:undefined,guard=length>2?sources[2]:undefined,thisArg=length>1?sources[length-1]:undefined;if(typeof customizer=="function"){customizer=bindCallback(customizer,thisArg,5);length-=2}else{customizer=typeof thisArg=="function"?thisArg:undefined;length-=customizer?1:0}if(guard&&isIterateeCall(sources[0],sources[1],guard)){customizer=length<3?undefined:customizer;length=1}while(++index-1?collection[index]:undefined}return baseFind(collection,predicate,eachFunc)}}function createFindIndex(fromRight){return function(array,predicate,thisArg){if(!(array&&array.length)){return-1}predicate=getCallback(predicate,thisArg,3);return baseFindIndex(array,predicate,fromRight)}}function createFindKey(objectFunc){return function(object,predicate,thisArg){predicate=getCallback(predicate,thisArg,3);return baseFind(object,predicate,objectFunc,true)}}function createFlow(fromRight){return function(){var wrapper,length=arguments.length,index=fromRight?length:-1,leftIndex=0,funcs=Array(length);while(fromRight?index--:++index=LARGE_ARRAY_SIZE){return wrapper.plant(value).value()}var index=0,result=length?funcs[index].apply(this,args):value;while(++index=length||!nativeIsFinite(length)){return""}var padLength=length-strLength;chars=chars==null?" ":chars+"";return repeat(chars,nativeCeil(padLength/chars.length)).slice(0,padLength)}function createPartialWrapper(func,bitmask,thisArg,partials){var isBind=bitmask&BIND_FLAG,Ctor=createCtorWrapper(func);function wrapper(){var argsIndex=-1,argsLength=arguments.length,leftIndex=-1,leftLength=partials.length,args=Array(leftLength+argsLength);while(++leftIndexarrLength)){return false}while(++index-1&&value%1==0&&value-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isStrictComparable(value){return value===value&&!isObject(value)}function mergeData(data,source){var bitmask=data[1],srcBitmask=source[1],newBitmask=bitmask|srcBitmask,isCommon=newBitmask0){if(++count>=HOT_COUNT){return key}}else{count=0}return baseSetData(key,value)}}();function shimKeys(object){var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length;var allowIndexes=!!length&&isLength(length)&&(isArray(object)||isArguments(object));var index=-1,result=[];while(++index=120?createCache(othIndex&&value):null}var array=arrays[0],index=-1,length=array?array.length:0,seen=caches[0];outer:while(++index-1){splice.call(array,fromIndex,1)}}return array}var pullAt=restParam(function(array,indexes){indexes=baseFlatten(indexes);var result=baseAt(array,indexes);basePullAt(array,indexes.sort(baseCompareAscending));return result});function remove(array,predicate,thisArg){var result=[];if(!(array&&array.length)){return result}var index=-1,indexes=[],length=array.length;predicate=getCallback(predicate,thisArg,3);while(++index2?arrays[length-2]:undefined,thisArg=length>1?arrays[length-1]:undefined;if(length>2&&typeof iteratee=="function"){length-=2}else{iteratee=length>1&&typeof thisArg=="function"?(--length,thisArg):undefined;thisArg=undefined}arrays.length=length;return unzipWith(arrays,iteratee,thisArg)});function chain(value){var result=lodash(value);result.__chain__=true;return result}function tap(value,interceptor,thisArg){interceptor.call(thisArg,value);return value}function thru(value,interceptor,thisArg){return interceptor.call(thisArg,value)}function wrapperChain(){return chain(this)}function wrapperCommit(){return new LodashWrapper(this.value(),this.__chain__)}var wrapperConcat=restParam(function(values){values=baseFlatten(values);return this.thru(function(array){return arrayConcat(isArray(array)?array:[toObject(array)],values)})});function wrapperPlant(value){var result,parent=this;while(parent instanceof baseLodash){var clone=wrapperClone(parent);if(result){previous.__wrapped__=clone}else{result=clone}var previous=clone;parent=parent.__wrapped__}previous.__wrapped__=value;return result}function wrapperReverse(){var value=this.__wrapped__;var interceptor=function(value){return wrapped&&wrapped.__dir__<0?value:value.reverse()};if(value instanceof LazyWrapper){var wrapped=value;if(this.__actions__.length){wrapped=new LazyWrapper(this)}wrapped=wrapped.reverse();wrapped.__actions__.push({func:thru,args:[interceptor],thisArg:undefined});return new LodashWrapper(wrapped,this.__chain__)}return this.thru(interceptor)}function wrapperToString(){return this.value()+""}function wrapperValue(){return baseWrapperValue(this.__wrapped__,this.__actions__)}var at=restParam(function(collection,props){return baseAt(collection,baseFlatten(props))});var countBy=createAggregator(function(result,value,key){hasOwnProperty.call(result,key)?++result[key]:result[key]=1});function every(collection,predicate,thisArg){var func=isArray(collection)?arrayEvery:baseEvery;if(thisArg&&isIterateeCall(collection,predicate,thisArg)){predicate=undefined}if(typeof predicate!="function"||thisArg!==undefined){predicate=getCallback(predicate,thisArg,3) +}return func(collection,predicate)}function filter(collection,predicate,thisArg){var func=isArray(collection)?arrayFilter:baseFilter;predicate=getCallback(predicate,thisArg,3);return func(collection,predicate)}var find=createFind(baseEach);var findLast=createFind(baseEachRight,true);function findWhere(collection,source){return find(collection,baseMatches(source))}var forEach=createForEach(arrayEach,baseEach);var forEachRight=createForEach(arrayEachRight,baseEachRight);var groupBy=createAggregator(function(result,value,key){if(hasOwnProperty.call(result,key)){result[key].push(value)}else{result[key]=[value]}});function includes(collection,target,fromIndex,guard){var length=collection?getLength(collection):0;if(!isLength(length)){collection=values(collection);length=collection.length}if(typeof fromIndex!="number"||guard&&isIterateeCall(target,fromIndex,guard)){fromIndex=0}else{fromIndex=fromIndex<0?nativeMax(length+fromIndex,0):fromIndex||0}return typeof collection=="string"||!isArray(collection)&&isString(collection)?fromIndex<=length&&collection.indexOf(target,fromIndex)>-1:!!length&&getIndexOf(collection,target,fromIndex)>-1}var indexBy=createAggregator(function(result,value,key){result[key]=value});var invoke=restParam(function(collection,path,args){var index=-1,isFunc=typeof path=="function",isProp=isKey(path),result=isArrayLike(collection)?Array(collection.length):[];baseEach(collection,function(value){var func=isFunc?path:isProp&&value!=null?value[path]:undefined;result[++index]=func?func.apply(value,args):invokePath(value,path,args)});return result});function map(collection,iteratee,thisArg){var func=isArray(collection)?arrayMap:baseMap;iteratee=getCallback(iteratee,thisArg,3);return func(collection,iteratee)}var partition=createAggregator(function(result,value,key){result[key?0:1].push(value)},function(){return[[],[]]});function pluck(collection,path){return map(collection,property(path))}var reduce=createReduce(arrayReduce,baseEach);var reduceRight=createReduce(arrayReduceRight,baseEachRight);function reject(collection,predicate,thisArg){var func=isArray(collection)?arrayFilter:baseFilter;predicate=getCallback(predicate,thisArg,3);return func(collection,function(value,index,collection){return!predicate(value,index,collection)})}function sample(collection,n,guard){if(guard?isIterateeCall(collection,n,guard):n==null){collection=toIterable(collection);var length=collection.length;return length>0?collection[baseRandom(0,length-1)]:undefined}var index=-1,result=toArray(collection),length=result.length,lastIndex=length-1;n=nativeMin(n<0?0:+n||0,length);while(++index0){result=func.apply(this,arguments)}if(n<=1){func=undefined}return result}}var bind=restParam(function(func,thisArg,partials){var bitmask=BIND_FLAG;if(partials.length){var holders=replaceHolders(partials,bind.placeholder);bitmask|=PARTIAL_FLAG}return createWrapper(func,bitmask,thisArg,partials,holders)});var bindAll=restParam(function(object,methodNames){methodNames=methodNames.length?baseFlatten(methodNames):functions(object);var index=-1,length=methodNames.length;while(++indexwait){complete(trailingCall,maxTimeoutId)}else{timeoutId=setTimeout(delayed,remaining)}}function maxDelayed(){complete(trailing,timeoutId)}function debounced(){args=arguments;stamp=now();thisArg=this;trailingCall=trailing&&(timeoutId||!leading);if(maxWait===false){var leadingCall=leading&&!timeoutId}else{if(!maxTimeoutId&&!leading){lastCalled=stamp}var remaining=maxWait-(stamp-lastCalled),isCalled=remaining<=0||remaining>maxWait;if(isCalled){if(maxTimeoutId){maxTimeoutId=clearTimeout(maxTimeoutId)}lastCalled=stamp;result=func.apply(thisArg,args)}else if(!maxTimeoutId){maxTimeoutId=setTimeout(maxDelayed,remaining)}}if(isCalled&&timeoutId){timeoutId=clearTimeout(timeoutId)}else if(!timeoutId&&wait!==maxWait){timeoutId=setTimeout(delayed,wait)}if(leadingCall){isCalled=true;result=func.apply(thisArg,args)}if(isCalled&&!timeoutId&&!maxTimeoutId){args=thisArg=undefined}return result}debounced.cancel=cancel;return debounced}var defer=restParam(function(func,args){return baseDelay(func,1,args)});var delay=restParam(function(func,wait,args){return baseDelay(func,wait,args)});var flow=createFlow();var flowRight=createFlow(true);function memoize(func,resolver){if(typeof func!="function"||resolver&&typeof resolver!="function"){throw new TypeError(FUNC_ERROR_TEXT)}var memoized=function(){var args=arguments,key=resolver?resolver.apply(this,args):args[0],cache=memoized.cache;if(cache.has(key)){return cache.get(key)}var result=func.apply(this,args);memoized.cache=cache.set(key,result);return result};memoized.cache=new memoize.Cache;return memoized}var modArgs=restParam(function(func,transforms){transforms=baseFlatten(transforms);if(typeof func!="function"||!arrayEvery(transforms,baseIsFunction)){throw new TypeError(FUNC_ERROR_TEXT)}var length=transforms.length;return restParam(function(args){var index=nativeMin(args.length,length);while(index--){args[index]=transforms[index](args[index])}return func.apply(this,args)})});function negate(predicate){if(typeof predicate!="function"){throw new TypeError(FUNC_ERROR_TEXT)}return function(){return!predicate.apply(this,arguments)}}function once(func){return before(2,func)}var partial=createPartial(PARTIAL_FLAG);var partialRight=createPartial(PARTIAL_RIGHT_FLAG);var rearg=restParam(function(func,indexes){return createWrapper(func,REARG_FLAG,undefined,undefined,undefined,baseFlatten(indexes))});function restParam(func,start){if(typeof func!="function"){throw new TypeError(FUNC_ERROR_TEXT)}start=nativeMax(start===undefined?func.length-1:+start||0,0);return function(){var args=arguments,index=-1,length=nativeMax(args.length-start,0),rest=Array(length);while(++indexother}function gte(value,other){return value>=other}function isArguments(value){return isObjectLike(value)&&isArrayLike(value)&&hasOwnProperty.call(value,"callee")&&!propertyIsEnumerable.call(value,"callee")}var isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag};function isBoolean(value){return value===true||value===false||isObjectLike(value)&&objToString.call(value)==boolTag}function isDate(value){return isObjectLike(value)&&objToString.call(value)==dateTag}function isElement(value){return!!value&&value.nodeType===1&&isObjectLike(value)&&!isPlainObject(value)}function isEmpty(value){if(value==null){return true}if(isArrayLike(value)&&(isArray(value)||isString(value)||isArguments(value)||isObjectLike(value)&&isFunction(value.splice))){return!value.length}return!keys(value).length}function isEqual(value,other,customizer,thisArg){customizer=typeof customizer=="function"?bindCallback(customizer,thisArg,3):undefined;var result=customizer?customizer(value,other):undefined;return result===undefined?baseIsEqual(value,other,customizer):!!result}function isError(value){return isObjectLike(value)&&typeof value.message=="string"&&objToString.call(value)==errorTag}function isFinite(value){return typeof value=="number"&&nativeIsFinite(value)}function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isMatch(object,source,customizer,thisArg){customizer=typeof customizer=="function"?bindCallback(customizer,thisArg,3):undefined;return baseIsMatch(object,getMatchData(source),customizer)}function isNaN(value){return isNumber(value)&&value!=+value}function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&reIsHostCtor.test(value)}function isNull(value){return value===null}function isNumber(value){return typeof value=="number"||isObjectLike(value)&&objToString.call(value)==numberTag}function isPlainObject(value){var Ctor;if(!(isObjectLike(value)&&objToString.call(value)==objectTag&&!isArguments(value))||!hasOwnProperty.call(value,"constructor")&&(Ctor=value.constructor,typeof Ctor=="function"&&!(Ctor instanceof Ctor))){return false}var result;baseForIn(value,function(subValue,key){result=key});return result===undefined||hasOwnProperty.call(value,result)}function isRegExp(value){return isObject(value)&&objToString.call(value)==regexpTag}function isString(value){return typeof value=="string"||isObjectLike(value)&&objToString.call(value)==stringTag}function isTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[objToString.call(value)]}function isUndefined(value){return value===undefined}function lt(value,other){return value0;while(++index=nativeMin(start,end)&&value=0&&string.indexOf(target,position)==position}function escape(string){string=baseToString(string);return string&&reHasUnescapedHtml.test(string)?string.replace(reUnescapedHtml,escapeHtmlChar):string}function escapeRegExp(string){string=baseToString(string);return string&&reHasRegExpChars.test(string)?string.replace(reRegExpChars,escapeRegExpChar):string||"(?:)"}var kebabCase=createCompounder(function(result,word,index){return result+(index?"-":"")+word.toLowerCase()});function pad(string,length,chars){string=baseToString(string);length=+length;var strLength=string.length;if(strLength>=length||!nativeIsFinite(length)){return string}var mid=(length-strLength)/2,leftLength=nativeFloor(mid),rightLength=nativeCeil(mid);chars=createPadding("",rightLength,chars);return chars.slice(0,leftLength)+string+chars}var padLeft=createPadDir();var padRight=createPadDir(true);function parseInt(string,radix,guard){if(guard?isIterateeCall(string,radix,guard):radix==null){radix=0}else if(radix){radix=+radix}string=trim(string);return nativeParseInt(string,radix||(reHasHexPrefix.test(string)?16:10))}function repeat(string,n){var result="";string=baseToString(string);n=+n;if(n<1||!string||!nativeIsFinite(n)){return result}do{if(n%2){result+=string}n=nativeFloor(n/2);string+=string}while(n);return result}var snakeCase=createCompounder(function(result,word,index){return result+(index?"_":"")+word.toLowerCase()});var startCase=createCompounder(function(result,word,index){return result+(index?" ":"")+(word.charAt(0).toUpperCase()+word.slice(1))});function startsWith(string,target,position){string=baseToString(string);position=position==null?0:nativeMin(position<0?0:+position||0,string.length);return string.lastIndexOf(target,position)==position}function template(string,options,otherOptions){var settings=lodash.templateSettings;if(otherOptions&&isIterateeCall(string,options,otherOptions)){options=otherOptions=undefined}string=baseToString(string);options=assignWith(baseAssign({},otherOptions||options),settings,assignOwnDefaults);var imports=assignWith(baseAssign({},options.imports),settings.imports,assignOwnDefaults),importsKeys=keys(imports),importsValues=baseValues(imports,importsKeys);var isEscaping,isEvaluating,index=0,interpolate=options.interpolate||reNoMatch,source="__p += '";var reDelimiters=RegExp((options.escape||reNoMatch).source+"|"+interpolate.source+"|"+(interpolate===reInterpolate?reEsTemplate:reNoMatch).source+"|"+(options.evaluate||reNoMatch).source+"|$","g");var sourceURL="//# sourceURL="+("sourceURL"in options?options.sourceURL:"lodash.templateSources["+ ++templateCounter+"]")+"\n";string.replace(reDelimiters,function(match,escapeValue,interpolateValue,esTemplateValue,evaluateValue,offset){interpolateValue||(interpolateValue=esTemplateValue);source+=string.slice(index,offset).replace(reUnescapedString,escapeStringChar);if(escapeValue){isEscaping=true;source+="' +\n__e("+escapeValue+") +\n'"}if(evaluateValue){isEvaluating=true;source+="';\n"+evaluateValue+";\n__p += '"}if(interpolateValue){source+="' +\n((__t = ("+interpolateValue+")) == null ? '' : __t) +\n'"}index=offset+match.length;return match});source+="';\n";var variable=options.variable;if(!variable){source="with (obj) {\n"+source+"\n}\n"}source=(isEvaluating?source.replace(reEmptyStringLeading,""):source).replace(reEmptyStringMiddle,"$1").replace(reEmptyStringTrailing,"$1;");source="function("+(variable||"obj")+") {\n"+(variable?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(isEscaping?", __e = _.escape":"")+(isEvaluating?", __j = Array.prototype.join;\n"+"function print() { __p += __j.call(arguments, '') }\n":";\n")+source+"return __p\n}";var result=attempt(function(){return Function(importsKeys,sourceURL+"return "+source).apply(undefined,importsValues)});result.source=source;if(isError(result)){throw result}return result}function trim(string,chars,guard){var value=string;string=baseToString(string);if(!string){return string}if(guard?isIterateeCall(value,chars,guard):chars==null){return string.slice(trimmedLeftIndex(string),trimmedRightIndex(string)+1)}chars=chars+"";return string.slice(charsLeftIndex(string,chars),charsRightIndex(string,chars)+1)}function trimLeft(string,chars,guard){var value=string;string=baseToString(string);if(!string){return string}if(guard?isIterateeCall(value,chars,guard):chars==null){return string.slice(trimmedLeftIndex(string))}return string.slice(charsLeftIndex(string,chars+""))}function trimRight(string,chars,guard){var value=string;string=baseToString(string);if(!string){return string}if(guard?isIterateeCall(value,chars,guard):chars==null){return string.slice(0,trimmedRightIndex(string)+1)}return string.slice(0,charsRightIndex(string,chars+"")+1)}function trunc(string,options,guard){if(guard&&isIterateeCall(string,options,guard)){options=undefined}var length=DEFAULT_TRUNC_LENGTH,omission=DEFAULT_TRUNC_OMISSION;if(options!=null){if(isObject(options)){var separator="separator"in options?options.separator:separator;length="length"in options?+options.length||0:length;omission="omission"in options?baseToString(options.omission):omission}else{length=+options||0}}string=baseToString(string);if(length>=string.length){return string}var end=length-omission.length;if(end<1){return omission}var result=string.slice(0,end);if(separator==null){return result+omission}if(isRegExp(separator)){if(string.slice(end).search(separator)){var match,newEnd,substring=string.slice(0,end);if(!separator.global){separator=RegExp(separator.source,(reFlags.exec(separator)||"")+"g")}separator.lastIndex=0;while(match=separator.exec(substring)){newEnd=match.index}result=result.slice(0,newEnd==null?end:newEnd)}}else if(string.indexOf(separator,end)!=end){var index=result.lastIndexOf(separator);if(index>-1){result=result.slice(0,index)}}return result+omission}function unescape(string){string=baseToString(string);return string&&reHasEscapedHtml.test(string)?string.replace(reEscapedHtml,unescapeHtmlChar):string}function words(string,pattern,guard){if(guard&&isIterateeCall(string,pattern,guard)){pattern=undefined}string=baseToString(string);return string.match(pattern||reWords)||[]}var attempt=restParam(function(func,args){try{return func.apply(undefined,args)}catch(e){return isError(e)?e:new Error(e)}});function callback(func,thisArg,guard){if(guard&&isIterateeCall(func,thisArg,guard)){thisArg=undefined}return isObjectLike(func)?matches(func):baseCallback(func,thisArg)}function constant(value){return function(){return value}}function identity(value){return value}function matches(source){return baseMatches(baseClone(source,true))}function matchesProperty(path,srcValue){return baseMatchesProperty(path,baseClone(srcValue,true))}var method=restParam(function(path,args){return function(object){return invokePath(object,path,args)}});var methodOf=restParam(function(object,args){return function(path){return invokePath(object,path,args)}});function mixin(object,source,options){if(options==null){var isObj=isObject(source),props=isObj?keys(source):undefined,methodNames=props&&props.length?baseFunctions(source,props):undefined;if(!(methodNames?methodNames.length:isObj)){methodNames=false;options=source;source=object;object=this}}if(!methodNames){methodNames=baseFunctions(source,keys(source))}var chain=true,index=-1,isFunc=isFunction(object),length=methodNames.length;if(options===false){chain=false}else if(isObject(options)&&"chain"in options){chain=options.chain}while(++index0||end<0)){return new LazyWrapper(result)}if(start<0){result=result.takeRight(-start)}else if(start){result=result.drop(start)}if(end!==undefined){end=+end||0;result=end<0?result.dropRight(-end):result.take(end-start)}return result};LazyWrapper.prototype.takeRightWhile=function(predicate,thisArg){return this.reverse().takeWhile(predicate,thisArg).reverse()};LazyWrapper.prototype.toArray=function(){return this.take(POSITIVE_INFINITY)};baseForOwn(LazyWrapper.prototype,function(func,methodName){var checkIteratee=/^(?:filter|map|reject)|While$/.test(methodName),retUnwrapped=/^(?:first|last)$/.test(methodName),lodashFunc=lodash[retUnwrapped?"take"+(methodName=="last"?"Right":""):methodName];if(!lodashFunc){return}lodash.prototype[methodName]=function(){var args=retUnwrapped?[1]:arguments,chainAll=this.__chain__,value=this.__wrapped__,isHybrid=!!this.__actions__.length,isLazy=value instanceof LazyWrapper,iteratee=args[0],useLazy=isLazy||isArray(value);if(useLazy&&checkIteratee&&typeof iteratee=="function"&&iteratee.length!=1){isLazy=useLazy=false}var interceptor=function(value){return retUnwrapped&&chainAll?lodashFunc(value,1)[0]:lodashFunc.apply(undefined,arrayPush([value],args))};var action={func:thru,args:[interceptor],thisArg:undefined},onlyLazy=isLazy&&!isHybrid;if(retUnwrapped&&!chainAll){if(onlyLazy){value=value.clone();value.__actions__.push(action);return func.call(value)}return lodashFunc.call(undefined,this.value())[0]}if(!retUnwrapped&&useLazy){value=onlyLazy?value:new LazyWrapper(this);var result=func.apply(value,args);result.__actions__.push(action);return new LodashWrapper(result,chainAll)}return this.thru(interceptor)}});arrayEach(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(methodName){var func=(/^(?:replace|split)$/.test(methodName)?stringProto:arrayProto)[methodName],chainName=/^(?:push|sort|unshift)$/.test(methodName)?"tap":"thru",retUnwrapped=/^(?:join|pop|replace|shift)$/.test(methodName);lodash.prototype[methodName]=function(){var args=arguments;if(retUnwrapped&&!this.__chain__){return func.apply(this.value(),args)}return this[chainName](function(value){return func.apply(value,args)})}});baseForOwn(LazyWrapper.prototype,function(func,methodName){var lodashFunc=lodash[methodName];if(lodashFunc){var key=lodashFunc.name,names=realNames[key]||(realNames[key]=[]);names.push({name:methodName,func:lodashFunc})}});realNames[createHybridWrapper(undefined,BIND_KEY_FLAG).name]=[{name:"wrapper",func:undefined}];LazyWrapper.prototype.clone=lazyClone;LazyWrapper.prototype.reverse=lazyReverse;LazyWrapper.prototype.value=lazyValue;lodash.prototype.chain=wrapperChain;lodash.prototype.commit=wrapperCommit;lodash.prototype.concat=wrapperConcat;lodash.prototype.plant=wrapperPlant;lodash.prototype.reverse=wrapperReverse;lodash.prototype.toString=wrapperToString;lodash.prototype.run=lodash.prototype.toJSON=lodash.prototype.valueOf=lodash.prototype.value=wrapperValue;lodash.prototype.collect=lodash.prototype.map;lodash.prototype.head=lodash.prototype.first;lodash.prototype.select=lodash.prototype.filter;lodash.prototype.tail=lodash.prototype.rest;return lodash}var _=runInContext();if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){root._=_;define(function(){return _})}else if(freeExports&&freeModule){if(moduleExports){(freeModule.exports=_)._=_}else{freeExports._=_}}else{root._=_}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[1])(1)}); diff --git a/confluence-plugin/src/main/typescript/src/main.ts b/confluence-plugin/src/main/typescript/src/main.ts new file mode 100644 index 0000000..4bc0048 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/main.ts @@ -0,0 +1,14 @@ +import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; +import {enableProdMode} from '@angular/core'; +import {environment} from './app/'; +import {AppModule} from './app/app.module'; + +if (environment.production) { + enableProdMode(); +} + +if (typeof AJS !== 'undefined' && AJS.Data) { + AJS.$("#editPageLink").off('click'); +} + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/confluence-plugin/src/main/typescript/src/system-config.ts b/confluence-plugin/src/main/typescript/src/system-config.ts new file mode 100644 index 0000000..ac875ba --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/system-config.ts @@ -0,0 +1,113 @@ +'use strict'; + +// SystemJS configuration file, see links for more information +// https://github.com/systemjs/systemjs +// https://github.com/systemjs/systemjs/blob/master/docs/config-api.md + +/*********************************************************************************************** + * User Configuration. + **********************************************************************************************/ +/** Map relative paths to URLs. */ +const map: any = { + 'd3': 'vendor/d3/d3.min.js', + 'dagre-d3': 'vendor/dagre-d3/dist/dagre-d3.min.js', + 'dagre': 'vendor/dagre-d3/dist/dagre.min.js', + 'class-transformer': 'vendor/ClassTransformer.js', + 'ng2-bootstrap': 'vendor/ng2-bootstrap', + 'ng2-auto-complete': 'vendor/ng2-auto-complete', + 'moment': 'vendor/moment/moment.js', +}; + +/** User packages configuration. */ +const packages: any = { + + // without this error traceur is not found + '@angular/core': {main: 'bundles/core.umd.js'}, + '@angular/common': {main: 'bundles/common.umd.js'}, + '@angular/compiler': {main: 'bundles/compiler.umd.js'}, + '@angular/forms': {main: 'bundles/forms.umd.js'}, + '@angular/http': {main: 'bundles/http.umd.js'}, + '@angular/platform-browser': {main: 'bundles/platform-browser.umd.js'}, + '@angular/platform-browser-dynamic': {main: 'bundles/platform-browser-dynamic.umd.js'}, + '@angular/router': {main: 'bundles/router.umd.js'}, + 'vendor/ng2-bootstrap': {defaultExtension: 'js'}, + 'ng2-auto-complete': {main: 'ng2-auto-complete.umd.js', defaultExtension: 'js'}, + + + 'd3': { + format: 'global' + }, + 'dagre-d3': { + format: 'cjs' + }, + 'dagre': { + format: 'cjs' + } +}; + +//////////////////////////////////////////////////////////////////////////////////////////////// +/*********************************************************************************************** + * Everything underneath this line is managed by the CLI. + **********************************************************************************************/ +const barrels: string[] = [ + // Angular specific barrels. + '@angular/core', + '@angular/common', + '@angular/compiler', + '@angular/forms', + '@angular/http', + '@angular/router', + '@angular/platform-browser', + '@angular/platform-browser-dynamic', + + // Thirdparty barrels. + 'rxjs', + + // App specific barrels. + 'app', + 'app/shared', + 'app/main-component', + 'app/main', + 'app/documentation/omni-doc', + 'app/documentation/markup', + 'app/documentation/class-diagram', + 'app/documentation/omni-doc/tree-view', + 'app/documentation/omni-doc/tree-view/tree-node', + 'app/documentation/class-diagram-container', + 'app/class-diagram', + 'app/documentation/structure-graph', + 'app/documentation/structure-graph/shared/structure-graph-renderer', + 'app/documentation/omni-doc/search-box', + 'app/documentation/omni-doc/omni-doc-entity', + 'app/documentation/markup/markup-entity', + /** @cli-barrel */ +]; + +const cliSystemConfigPackages: any = {}; +barrels.forEach((barrelName: string) => { + cliSystemConfigPackages[barrelName] = {main: 'index'}; +}); + +/** Type declaration for ambient System. */ +declare var System: any; +declare var AJS: any; + +// Change SystemJS's base-url when running on Confluence +if (typeof AJS !== 'undefined' && AJS.Data) { + System.config({ + baseURL: AJS.Data.get('base-url') + '/rest/doc/1.0/frontend' + }); +} + +// Apply the CLI SystemJS configuration. +System.config({ + map: { + '@angular': 'vendor/@angular', + 'rxjs': 'vendor/rxjs', + 'main': 'main.js', + }, + packages: cliSystemConfigPackages +}); + +// Apply the user's configuration. +System.config({map, packages}); diff --git a/confluence-plugin/src/main/typescript/src/tsconfig.json b/confluence-plugin/src/main/typescript/src/tsconfig.json new file mode 100644 index 0000000..9dc11d4 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "declaration": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "mapRoot": "/", + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noImplicitAny": true, + "outDir": "../../../../target/classes/frontend", + "rootDir": ".", + "sourceMap": true, + "target": "es5", + "inlineSources": true + }, + + "files": [ + "main.ts", + "typings.d.ts" + ] +} diff --git a/confluence-plugin/src/main/typescript/src/typings.d.ts b/confluence-plugin/src/main/typescript/src/typings.d.ts new file mode 100644 index 0000000..d310a61 --- /dev/null +++ b/confluence-plugin/src/main/typescript/src/typings.d.ts @@ -0,0 +1,7 @@ +// Typings reference file, see links for more information +// https://github.com/typings/typings +// https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html + +/// +declare var module: { id: string }; +declare var AJS: any; diff --git a/confluence-plugin/src/main/typescript/tslint.json b/confluence-plugin/src/main/typescript/tslint.json new file mode 100644 index 0000000..7b13bd1 --- /dev/null +++ b/confluence-plugin/src/main/typescript/tslint.json @@ -0,0 +1,110 @@ +{ + "rulesDirectory": [ + "node_modules/codelyzer" + ], + "rules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": true, + "forin": true, + "indent": [ + true, + "spaces" + ], + "label-position": true, + "label-undefined": true, + "max-line-length": [ + true, + 140 + ], + "member-access": false, + "member-ordering": [ + true, + "static-before-instance", + "variables-before-functions" + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-inferrable-types": true, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-unreachable": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": [ + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + + "directive-selector-name": [true, "camelCase"], + "component-selector-name": [true, "kebab-case"], + "directive-selector-type": [true, "attribute"], + "component-selector-type": [true, "element"], + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true + } +} diff --git a/confluence-plugin/src/main/typescript/typings.json b/confluence-plugin/src/main/typescript/typings.json new file mode 100644 index 0000000..4ed0453 --- /dev/null +++ b/confluence-plugin/src/main/typescript/typings.json @@ -0,0 +1,13 @@ +{ + "globalDevDependencies": { + "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459", + "jasmine": "registry:dt/jasmine#2.2.0+20160621224255", + "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654" + }, + "globalDependencies": { + "d3": "registry:dt/d3#0.0.0+20160907005744", + "dagre": "registry:dt/dagre#0.7.0+20160505164908", + "dagre-d3": "registry:dt/dagre-d3#0.0.0+20160620231311", + "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504" + } +} diff --git a/functional-utils/pom.xml b/functional-utils/pom.xml new file mode 100644 index 0000000..2d094dd --- /dev/null +++ b/functional-utils/pom.xml @@ -0,0 +1,15 @@ + + + + autodoc-parent + com.networkedassets.autodoc + 0.4.5 + + 4.0.0 + + functional-utils + + + \ No newline at end of file diff --git a/functional-utils/src/main/java/com/networkedassets/util/functional/Optionals.java b/functional-utils/src/main/java/com/networkedassets/util/functional/Optionals.java new file mode 100644 index 0000000..2afa874 --- /dev/null +++ b/functional-utils/src/main/java/com/networkedassets/util/functional/Optionals.java @@ -0,0 +1,69 @@ +package com.networkedassets.util.functional; + +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Supplier; + +/** + * Utility class for dealing with Optionals + */ +public class Optionals { + /** + * Converts a throwing supplier to a optional with it's result value or none if it threw + * @param supplier action that creates a value, but might throw an exception + * @param result type of the supplier + * @return optional of a throwing supplier + */ + public static Optional ofThrowing(Throwing.Supplier supplier) { + try { + return Optional.of(supplier.get()); + } catch (Throwable t) { + return Optional.empty(); + } + } + + /** + * Throwing version of {@link Optional#orElseGet(Supplier)} + * + * @param opt option that is going to be or'ed + * @param supplier this gives the default value when opt is not present; + * unlike in the {@link Optional#orElseGet(Supplier)}, this may throw checked exceptions + * @param type of return value + * @param type of exception that might be thrown + * @return like {@link Optional#orElseGet(Supplier)} + * @throws E + */ + public static T orElseGetThrowing(Optional opt, Throwing.Specific.Supplier supplier) throws E { + if (opt.isPresent()) return opt.get(); + else return supplier.get(); + } + + /** Throwing version of {@link Optional#map(Function)} */ + public static Optional mapThrowing(Optional opt, Throwing.Specific.Function function) throws E { + if (opt.isPresent()) { + return Optional.ofNullable(function.apply(opt.get())); + } else { + return Optional.empty(); + } + } + + /** Throwing version of {@link Optional#flatMap(Function)} */ + public static Optional flatMapThrowing(Optional opt, Throwing.Specific.Function, E> function) throws E { + if (opt.isPresent()) { + return function.apply(opt.get()); + } else { + return Optional.empty(); + } + } + + /** Returns optional with the only value of the array */ + public static Optional fromArrayOfOne(T[] arr) { + if (arr.length == 0) { + return Optional.empty(); + } else if (arr.length > 1) { + return Optional.empty(); + } else { + return Optional.of(arr[0]); + } + } +} diff --git a/functional-utils/src/main/java/com/networkedassets/util/functional/Throwing.java b/functional-utils/src/main/java/com/networkedassets/util/functional/Throwing.java new file mode 100644 index 0000000..c24d127 --- /dev/null +++ b/functional-utils/src/main/java/com/networkedassets/util/functional/Throwing.java @@ -0,0 +1,115 @@ +package com.networkedassets.util.functional; + +/** + * Taken from com.diffplug.durian + */ +public interface Throwing { + /** Variations on the standard functional interfaces which throw a specific subclass of Throwable. */ + interface Specific { + @FunctionalInterface + interface Runnable { + void run() throws E; + } + + @FunctionalInterface + interface Supplier { + T get() throws E; + } + + @FunctionalInterface + interface Consumer { + void accept(T t) throws E; + } + + @FunctionalInterface + interface Function { + R apply(T t) throws E; + } + + @FunctionalInterface + interface Predicate { + boolean test(T t) throws E; + } + + @FunctionalInterface + interface BiConsumer { + void accept(T t, U u) throws E; + } + + @FunctionalInterface + interface BiFunction { + R apply(T t, U u) throws E; + } + + @FunctionalInterface + interface BiPredicate { + boolean accept(T t, U u) throws E; + } + } + + @FunctionalInterface + interface Runnable extends Specific.Runnable {} + + @FunctionalInterface + interface Supplier extends Specific.Supplier {} + + @FunctionalInterface + interface Consumer extends Specific.Consumer {} + + @FunctionalInterface + interface Function extends Specific.Function {} + + @FunctionalInterface + interface Predicate extends Specific.Predicate {} + + @FunctionalInterface + interface BiConsumer extends Specific.BiConsumer {} + + @FunctionalInterface + interface BiFunction extends Specific.BiFunction {} + + @FunctionalInterface + interface BiPredicate extends Specific.BiPredicate {} + + static java.util.function.Function functionRethrowAsRuntimeException(Specific.Function throwingFunction) { + return t -> { + try { + return throwingFunction.apply(t); + } catch (Throwable e) { + if (e instanceof RuntimeException) { + throw (RuntimeException) e; + } else { + throw new RuntimeException(e); + } + } + }; + } + + static java.util.function.Consumer consumerRethrowAsRuntimeException(Specific.Consumer cons) { + return t -> { + try { + cons.accept(t); + } catch (Throwable e) { + if (e instanceof RuntimeException) throw (RuntimeException) e; + throw new RuntimeException(e); + } + }; + } + + + + + /** + * Converts a throwing runnable to a optional with it's result value or none if it threw + * @param runnable action that might throw an exception + * @return weather the runnable threw anything + */ + static boolean didThrow(Throwing.Runnable runnable) { + try { + runnable.run(); + return false; + } catch (Throwable t) { + return true; + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..dc8205a --- /dev/null +++ b/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + + com.networkedassets.autodoc + autodoc-parent + pom + 0.4.5 + Autodoc Parent + + + confluence-plugin + functional-utils + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + \ No newline at end of file