From bf1b678d9c2a5914524e60323a0a2dcd1b67f64a Mon Sep 17 00:00:00 2001 From: Girish Vasmatkar Date: Thu, 24 Dec 2020 22:25:32 +0530 Subject: [PATCH 01/11] Initial commit: without checkstyle issues --- graphql/README.adoc | 108 + graphql/build.gradle | 39 + graphql/config/GraphqlUiLabels.xml | 42 + graphql/data/GraphqlDemoData.xml | 23 + graphql/data/GraphqlSecurityGroupDemoData.xml | 29 + .../GraphqlSecurityPermissionSeedData.xml | 30 + graphql/data/GraphqlTypeData.xml | 23 + graphql/entitydef/entitymodel.xml | 31 + graphql/ofbiz-component.xml | 53 + graphql/servicedef/services.xml | 67 + .../graphql/AppServletContextListener.java | 50 + .../graphql/GraphQLEndpointServletImpl.java | 164 + .../ofbiz/graphql/GraphQLErrorType.java | 26 + .../org/apache/ofbiz/graphql/Scalars.java | 93 + .../OFBizGraphQLObjectMapperConfigurer.java | 36 + .../graphql/fetcher/BaseDataFetcher.java | 46 + .../fetcher/BaseEntityDataFetcher.java | 147 + .../graphql/fetcher/EmptyDataFetcher.java | 48 + .../graphql/fetcher/EntityDataFetcher.java | 191 + .../graphql/fetcher/ServiceDataFetcher.java | 175 + .../fetcher/utils/DataFetcherUtils.java | 176 + .../graphql/filter/AuthenticationFilter.java | 147 + .../graphql/schema/DateRangeInputType.java | 53 + .../schema/GraphQLSchemaDefinition.java | 2179 ++ .../graphql/schema/GraphQLSchemaUtil.java | 551 + .../graphql/schema/OperationInputType.java | 53 + .../graphql/schema/PaginationInputType.java | 60 + .../graphql/services/GraphQLServices.java | 211 + graphql/template/playground.ftl | 546 + graphql/testdef/GraphqlTests.xml | 26 + graphql/webapp/graphql/WEB-INF/controller.xml | 62 + graphql/webapp/graphql/WEB-INF/web.xml | 109 + .../webapp/graphql/graphiql/graphiql.min.css | 10 + .../webapp/graphql/graphiql/graphiql.min.js | 14 + graphql/webapp/graphql/graphiql/index.html | 42 + .../graphql/graphiql/react-dom.development.js | 27941 ++++++++++++++++ .../graphql/graphiql/react.development.js | 3793 +++ graphql/webapp/graphql/images/OFBiz-Logo.svg | 41 + .../webapp/graphql/images/graphql-logo.svg | 1 + graphql/webapp/graphql/index.jsp | 20 + .../webapp/graphql/playground/css/index.css | 2 + .../graphql/playground/css/index.css.map | 1 + .../graphql/playground/css/middleware.css | 2 + .../graphql/playground/css/middleware.css.map | 1 + .../webapp/graphql/playground/img/favicon.png | Bin 0 -> 5057 bytes graphql/webapp/graphql/playground/index.html | 546 + graphql/webapp/graphql/playground/js/index.js | 2 + .../webapp/graphql/playground/js/index.js.map | 1 + .../graphql/playground/js/middleware.js | 2 + .../graphql/playground/js/middleware.js.map | 1 + .../GraphQLLanguageService.js.6d01bfc8.flow | 247 + .../media/autocompleteUtils.js.4ce7ba19.flow | 204 + ...etAutocompleteSuggestions.js.5f735c7b.flow | 658 + .../media/getDefinition.js.0c48668e.flow | 93 + .../media/getDiagnostics.js.84508a12.flow | 170 + .../media/getOutline.js.671d1f9b.flow | 117 + .../playground/media/index.js.641230f5.flow | 30 + .../playground/media/logo.57ee3b60.png | Bin 0 -> 32043 bytes graphql/widget/CommonScreens.xml | 67 + graphql/widget/GraphqlForms.xml | 25 + graphql/widget/GraphqlMenus.xml | 27 + graphql/widget/GraphqlScreens.xml | 76 + 62 files changed, 39728 insertions(+) create mode 100644 graphql/README.adoc create mode 100644 graphql/build.gradle create mode 100644 graphql/config/GraphqlUiLabels.xml create mode 100644 graphql/data/GraphqlDemoData.xml create mode 100644 graphql/data/GraphqlSecurityGroupDemoData.xml create mode 100644 graphql/data/GraphqlSecurityPermissionSeedData.xml create mode 100644 graphql/data/GraphqlTypeData.xml create mode 100644 graphql/entitydef/entitymodel.xml create mode 100644 graphql/ofbiz-component.xml create mode 100644 graphql/servicedef/services.xml create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/AppServletContextListener.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/GraphQLEndpointServletImpl.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/GraphQLErrorType.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/Scalars.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/config/OFBizGraphQLObjectMapperConfigurer.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/BaseDataFetcher.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/BaseEntityDataFetcher.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/EmptyDataFetcher.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/EntityDataFetcher.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/ServiceDataFetcher.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/utils/DataFetcherUtils.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/filter/AuthenticationFilter.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/schema/DateRangeInputType.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/schema/GraphQLSchemaDefinition.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/schema/GraphQLSchemaUtil.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/schema/OperationInputType.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/schema/PaginationInputType.java create mode 100644 graphql/src/main/java/org/apache/ofbiz/graphql/services/GraphQLServices.java create mode 100644 graphql/template/playground.ftl create mode 100644 graphql/testdef/GraphqlTests.xml create mode 100644 graphql/webapp/graphql/WEB-INF/controller.xml create mode 100644 graphql/webapp/graphql/WEB-INF/web.xml create mode 100644 graphql/webapp/graphql/graphiql/graphiql.min.css create mode 100644 graphql/webapp/graphql/graphiql/graphiql.min.js create mode 100644 graphql/webapp/graphql/graphiql/index.html create mode 100644 graphql/webapp/graphql/graphiql/react-dom.development.js create mode 100644 graphql/webapp/graphql/graphiql/react.development.js create mode 100755 graphql/webapp/graphql/images/OFBiz-Logo.svg create mode 100644 graphql/webapp/graphql/images/graphql-logo.svg create mode 100644 graphql/webapp/graphql/index.jsp create mode 100644 graphql/webapp/graphql/playground/css/index.css create mode 100644 graphql/webapp/graphql/playground/css/index.css.map create mode 100644 graphql/webapp/graphql/playground/css/middleware.css create mode 100644 graphql/webapp/graphql/playground/css/middleware.css.map create mode 100644 graphql/webapp/graphql/playground/img/favicon.png create mode 100644 graphql/webapp/graphql/playground/index.html create mode 100644 graphql/webapp/graphql/playground/js/index.js create mode 100644 graphql/webapp/graphql/playground/js/index.js.map create mode 100644 graphql/webapp/graphql/playground/js/middleware.js create mode 100644 graphql/webapp/graphql/playground/js/middleware.js.map create mode 100644 graphql/webapp/graphql/playground/media/GraphQLLanguageService.js.6d01bfc8.flow create mode 100644 graphql/webapp/graphql/playground/media/autocompleteUtils.js.4ce7ba19.flow create mode 100644 graphql/webapp/graphql/playground/media/getAutocompleteSuggestions.js.5f735c7b.flow create mode 100644 graphql/webapp/graphql/playground/media/getDefinition.js.0c48668e.flow create mode 100644 graphql/webapp/graphql/playground/media/getDiagnostics.js.84508a12.flow create mode 100644 graphql/webapp/graphql/playground/media/getOutline.js.671d1f9b.flow create mode 100644 graphql/webapp/graphql/playground/media/index.js.641230f5.flow create mode 100644 graphql/webapp/graphql/playground/media/logo.57ee3b60.png create mode 100644 graphql/widget/CommonScreens.xml create mode 100644 graphql/widget/GraphqlForms.xml create mode 100644 graphql/widget/GraphqlMenus.xml create mode 100644 graphql/widget/GraphqlScreens.xml diff --git a/graphql/README.adoc b/graphql/README.adoc new file mode 100644 index 000000000..28de5d9c8 --- /dev/null +++ b/graphql/README.adoc @@ -0,0 +1,108 @@ +//// +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you 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. +//// += Apache OFBiz® GraphQL plug-in + + +:imagesdir: ./webapp/graphql/images +image::OFBiz-Logo.svg[100,100][float="left"] +image::graphql-logo.svg[100,100][float="right"] + +This plug-in a GraphQL plugin that lets OFBiz to define GraphQL API. + +== What's included +* GraphiQL (https://github.com/graphql/graphiql) +* Playground (https://github.com/prisma-labs/graphql-playground) +* OFBiz GraphQL endpoint + +== OFBiz GraphQL API based on graphql-java suite of libraries +.The plug-in uses the following dependencies +* com.graphql-java:graphql-java:13.0 +* com.graphql-java-kickstart:graphql-java-servlet:9.0.1 +* com.graphql-java-kickstart:graphql-java-tools:5.7.1 +* io.github.graphql-java:graphql-java-annotations:7.2.1 + +The endpoint is configured by subclassing SimpleGraphQLHttpServlet from graphql-java-servlet dependency. +---- +public class GraphQLEndpointServletImpl extends SimpleGraphQLHttpServlet { +---- + +== Important URLs +* GraphQL endpint (https://localhost:8443/graphql/graphql) +* GraphQL schema (https://localhost:8443/graphql/graphql/schema.json) +* GraphiQL (https://localhost:8443/graphql/graphiql/index.html) +* GraphQL Playground (https://localhost:8443/graphql/playground/index.html) + +== Usage +It comes with a demo query operation outlined below. The schema part is something that needs to be refined further. Both ways of creating the schema viz. GraphQL SDL and Programmatically using Java API, are demonstrated. This part will be further enhanced to include other operations that can be defined easily. + +Queries can be executed like below: +---- +'/graphql/?query={graphQLQueryString}' or '/graphql/?query={graphQLQueryString}&&variables={graphQLVariables}&&operationName={operationName}' +---- +The bundled up schema does not define any mutation, but executing mutations is supported via POST only as per GraphQL specifications. + +=== Demo Query operation +The schema defines a single Query type operation to fetch product details with product id passed as parameter: +Input: +---- +{ + product(id : "WG-9943-B3") + { + productId + productName + isVirtual + primaryProductCategoryId + productTypeId + } +} +---- +Output: +---- +{ + "data": { + "product": { + "productId": "WG-9943-B3", + "productName": "Giant Widget B3", + "isVirtual": "N", + "primaryProductCategoryId": "202", + "productTypeId": "FINISHED_GOOD" + } + } +} +---- + + +== Authentication +The GraphQL endpoint is secured. Authentication scheme is "Bearer ". Every query/muation/subscription operation must have an Authorization header associated with it. +Example Request: + +---- +GET /graphql/graphql/?query={ + product(id : "WG-9943-B3") + { + productId + productName + isVirtual + primaryProductCategoryId + productTypeId + ddd + } +} HTTP/1.1 +Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJBcGFjaGVPRkJpeiIsImlhdCI6MTU0NzczOTM0OCwiZXhwIjoxNjc5Mjc1MzQ4LCJhdWQiOiJ3d3cuZXhhbXBsZS5jb20iLCJzdWIiOiJqcm9ja2V0QGV4YW1wbGUuY29tIiwiR2l2ZW5OYW1lIjoiSm9obm55IiwiU3VybmFtZSI6IlJvY2tldCIsIkVtYWlsIjoianJvY2tldEBleGFtcGxlLmNvbSIsInVzZXJMb2dpbklkIjoiYWRtaW4iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.fwafgrgpodBJcXxNTQdZknKeWKb3sDOsQrcR2vcRw97FznD6mkE79p10Tu7cqpUx7LiXuROUAnXEgqDice-BSg +---- diff --git a/graphql/build.gradle b/graphql/build.gradle new file mode 100644 index 000000000..81127bc41 --- /dev/null +++ b/graphql/build.gradle @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +dependencies { + //Examples of compile-time and runtime dependencies + + pluginLibsCompile 'com.graphql-java:graphql-java:13.0' + pluginLibsCompile 'com.graphql-java-kickstart:graphql-java-servlet:9.0.1' + pluginLibsCompile 'com.graphql-java-kickstart:graphql-java-tools:5.7.1' + pluginLibsCompile 'io.github.graphql-java:graphql-java-annotations:7.2.1' +} + +task install { + doLast { + // Install logic for this plugin + } +} + +task uninstall { + doLast { + // uninstall logic for this plugin + } +} diff --git a/graphql/config/GraphqlUiLabels.xml b/graphql/config/GraphqlUiLabels.xml new file mode 100644 index 000000000..91ad9afc2 --- /dev/null +++ b/graphql/config/GraphqlUiLabels.xml @@ -0,0 +1,42 @@ + + + + + + Graphql Application + Graphql应用程序 + Graphql應用程式 + + + OFBiz: Graphql + OFBiz: Graphql + + + Part of the Apache OFBiz Family of Open Source Software + Un modulo della famiglia di software open source Apache OFBiz + 开源软件OFBiz的组成部分 + 開源軟體OFBiz的組成部分 + + + You are not allowed to view this page. + 不允许你浏览这个页面。 + 不允許您檢視這個頁面. + + diff --git a/graphql/data/GraphqlDemoData.xml b/graphql/data/GraphqlDemoData.xml new file mode 100644 index 000000000..b76e67e05 --- /dev/null +++ b/graphql/data/GraphqlDemoData.xml @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/graphql/data/GraphqlSecurityGroupDemoData.xml b/graphql/data/GraphqlSecurityGroupDemoData.xml new file mode 100644 index 000000000..bd4ba7312 --- /dev/null +++ b/graphql/data/GraphqlSecurityGroupDemoData.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + diff --git a/graphql/data/GraphqlSecurityPermissionSeedData.xml b/graphql/data/GraphqlSecurityPermissionSeedData.xml new file mode 100644 index 000000000..beb5f18d4 --- /dev/null +++ b/graphql/data/GraphqlSecurityPermissionSeedData.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/graphql/data/GraphqlTypeData.xml b/graphql/data/GraphqlTypeData.xml new file mode 100644 index 000000000..b76e67e05 --- /dev/null +++ b/graphql/data/GraphqlTypeData.xml @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/graphql/entitydef/entitymodel.xml b/graphql/entitydef/entitymodel.xml new file mode 100644 index 000000000..2f662c101 --- /dev/null +++ b/graphql/entitydef/entitymodel.xml @@ -0,0 +1,31 @@ + + + + + + + + Entity of Graphql Component + None + + + + \ No newline at end of file diff --git a/graphql/ofbiz-component.xml b/graphql/ofbiz-component.xml new file mode 100644 index 000000000..89af93b45 --- /dev/null +++ b/graphql/ofbiz-component.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/graphql/servicedef/services.xml b/graphql/servicedef/services.xml new file mode 100644 index 000000000..1581e220a --- /dev/null +++ b/graphql/servicedef/services.xml @@ -0,0 +1,67 @@ + + + + + Graphql Services + + 1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Returns GraphQL Connection + + + + + diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/AppServletContextListener.java b/graphql/src/main/java/org/apache/ofbiz/graphql/AppServletContextListener.java new file mode 100644 index 000000000..58df6f718 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/AppServletContextListener.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import org.apache.ofbiz.base.util.Debug; +import org.apache.ofbiz.entity.Delegator; +import org.apache.ofbiz.service.LocalDispatcher; +import org.apache.ofbiz.webapp.WebAppUtil; + +public class AppServletContextListener implements ServletContextListener { + + public static final String MODULE = AppServletContextListener.class.getName(); + + public void contextInitialized(ServletContextEvent sce) { + ServletContext servletContext = sce.getServletContext(); + Delegator delegator = WebAppUtil.getDelegator(servletContext); + LocalDispatcher dispatcher = WebAppUtil.getDispatcher(servletContext); + Debug.logInfo("GraphQL Context initialized, delegator " + delegator + ", dispatcher", MODULE); + servletContext.setAttribute("delegator", delegator); + servletContext.setAttribute("dispatcher", dispatcher); + } + + public void contextDestroyed(ServletContextEvent sce) { + ServletContext context = sce.getServletContext(); + Debug.logInfo("GraphQL Context destroyed, removing delegator and dispatcher ", MODULE); + context.removeAttribute("delegator"); + context.removeAttribute("dispatcher"); + } + +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/GraphQLEndpointServletImpl.java b/graphql/src/main/java/org/apache/ofbiz/graphql/GraphQLEndpointServletImpl.java new file mode 100644 index 000000000..1febe630f --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/GraphQLEndpointServletImpl.java @@ -0,0 +1,164 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.ServletException; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.ofbiz.base.component.ComponentConfig; +import org.apache.ofbiz.base.component.ComponentException; +import org.apache.ofbiz.base.util.Debug; +import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.base.util.UtilXml; +import org.apache.ofbiz.entity.Delegator; +import org.apache.ofbiz.graphql.config.OFBizGraphQLObjectMapperConfigurer; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaDefinition; +import org.apache.ofbiz.service.LocalDispatcher; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + +import graphql.ExecutionResultImpl; +import graphql.GraphQLError; +import graphql.GraphqlErrorBuilder; +import graphql.kickstart.execution.GraphQLObjectMapper; +import graphql.servlet.GraphQLConfiguration; +import graphql.servlet.SimpleGraphQLHttpServlet; + +@SuppressWarnings("serial") +public class GraphQLEndpointServletImpl extends SimpleGraphQLHttpServlet { + + public static final String MODULE = GraphQLEndpointServletImpl.class.getName(); + private static final String APPLICATION_GRAPHQL = "application/graphql"; + private GraphQLConfiguration configuration; + private GraphQLObjectMapper mapper; + private Map graphQLSchemaElementMap = new HashMap<>(); + + @Override + protected GraphQLConfiguration getConfiguration() { + mapper = GraphQLObjectMapper.newBuilder().withObjectMapperConfigurer(new OFBizGraphQLObjectMapperConfigurer()) + .build(); + loadSchemaElements(); + GraphQLSchemaDefinition schemaDef = new GraphQLSchemaDefinition( + (Delegator) getServletContext().getAttribute("delegator"), + (LocalDispatcher) getServletContext().getAttribute("dispatcher"), graphQLSchemaElementMap); + configuration = GraphQLConfiguration.with(schemaDef.generateSchema()).with(false).with(mapper).build(); + return configuration; + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) { + if (isContentTypeGraphQL(request)) { + response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); + response.setContentType(MediaType.APPLICATION_JSON); + GraphQLError error = GraphqlErrorBuilder.newError() + .message("Content Type application/graphql is only allowed on POST", (Object[]) null).build(); + ExecutionResultImpl result = new ExecutionResultImpl(error); + try { + configuration.getObjectMapper().serializeResultAsJson(response.getWriter(), result); + response.flushBuffer(); + } catch (IOException e) { + response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); + } + } + super.doGet(request, response); + } + + @Override + protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + setupCORSHeaders(req, resp); + resp.flushBuffer(); + } + + private boolean isContentTypeGraphQL(HttpServletRequest request) { + String contentType = request.getHeader(HttpHeaders.CONTENT_TYPE); + return contentType != null && contentType.equals(APPLICATION_GRAPHQL); + } + + /** + * @param httpServletRequest + * @param response + * @throws IOException + */ + public void setupCORSHeaders(HttpServletRequest httpServletRequest, ServletResponse response) throws IOException { + if (response instanceof HttpServletResponse) { + HttpServletResponse httpServletResponse = (HttpServletResponse) response; + if (httpServletRequest != null && httpServletRequest.getHeader("Origin") != null) { + httpServletResponse.setHeader("Access-Control-Allow-Origin", httpServletRequest.getHeader("Origin")); + } else { + httpServletResponse.setHeader("Access-Control-Allow-Origin", "*"); + } + httpServletResponse.setHeader("Access-Control-Allow-Headers", + "Origin, X-Requested-With, Content-Type, Accept"); + httpServletResponse.setHeader("Access-Control-Allow-Credentials", "true"); + httpServletResponse.setHeader("Access-Control-Allow-Methods", "OPTIONS, POST, GET"); + } + } + + private void loadSchemaElements() { + Collection components = ComponentConfig.getAllComponents(); + components.forEach(component -> { + String cName = component.getComponentName(); + try { + String loc = ComponentConfig.getRootLocation(cName) + "/graphql/schema"; + File folder = new File(loc); + if (folder.isDirectory() && folder.exists()) { + File[] schemaFiles = folder.listFiles((dir, fileName) -> fileName.endsWith(".graphql.xml")); + for (File schemaFile : schemaFiles) { + Debug.logInfo( + "GraphQL schema file " + schemaFile.getName() + " was found in component " + cName, + MODULE); + Element element = null; + try { + element = UtilXml + .readXmlDocument(new FileInputStream(schemaFile), true, "GraphQL Schema File", true) + .getDocumentElement(); + String isEnabledStr = element.getAttribute("expose"); + if (UtilValidate.isEmpty(isEnabledStr) || Boolean.parseBoolean(isEnabledStr)) { + Debug.logInfo("Processing GraphQL schema file " + schemaFile.getName() + + " from component " + cName, MODULE); + graphQLSchemaElementMap.put(schemaFile.getName(), element); + } + } catch (SAXException | ParserConfigurationException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + + } catch (ComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }); + } + +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/GraphQLErrorType.java b/graphql/src/main/java/org/apache/ofbiz/graphql/GraphQLErrorType.java new file mode 100644 index 000000000..69e9dfa87 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/GraphQLErrorType.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ + +package org.apache.ofbiz.graphql; + +import graphql.ErrorClassification; + +public enum GraphQLErrorType implements ErrorClassification { + InvalidSyntax, ValidationError, DataFetchingException, OperationNotSupported, ExecutionAborted, AuthenticationError +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/Scalars.java b/graphql/src/main/java/org/apache/ofbiz/graphql/Scalars.java new file mode 100644 index 000000000..c58cdda1b --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/Scalars.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql; + +import java.math.BigInteger; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.TimeZone; + +import graphql.GraphQLException; +import graphql.language.IntValue; +import graphql.language.StringValue; +import graphql.schema.Coercing; +import graphql.schema.CoercingParseLiteralException; +import graphql.schema.CoercingParseValueException; +import graphql.schema.CoercingSerializeException; +import graphql.schema.GraphQLScalarType; + +public class Scalars { + private static final BigInteger LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE); + private static final BigInteger LONG_MIN = BigInteger.valueOf(Long.MIN_VALUE); + + public static GraphQLScalarType GraphQLDateTime = GraphQLScalarType.newScalar().name("DateTime") + .description("An ISO-8601 encoded UTC date time string. Example value: \"2019-07-03T20:47:55Z\".") + .coercing(new Coercing() { + + @Override + public Object serialize(Object dataFetcherResult) throws CoercingSerializeException { + if (dataFetcherResult instanceof String) { + if (dataFetcherResult == "" || dataFetcherResult == null) { + return null; + } + return Timestamp.valueOf((String) dataFetcherResult).getTime(); + } else if (dataFetcherResult instanceof Long) { + return new Timestamp((Long) dataFetcherResult).getTime(); + } else if (dataFetcherResult instanceof Timestamp) { + return formatDateTimeToUTC((Timestamp) dataFetcherResult); + } + return null; + } + + @Override + public Object parseValue(Object input) throws CoercingParseValueException { + if (input instanceof String) { + return Timestamp.valueOf((String) input); + } else if (input instanceof Long) { + return new Timestamp((Long) input); + } else if (input instanceof Timestamp) { + return input; + } + return null; + } + + @Override + public Object parseLiteral(Object input) throws CoercingParseLiteralException { + if (input instanceof StringValue) { + return Timestamp.valueOf(((StringValue) input).getValue()); + } else if (input instanceof IntValue) { + BigInteger value = ((IntValue) input).getValue(); + // Check if out of bounds. + if (value.compareTo(LONG_MIN) < 0 || value.compareTo(LONG_MAX) > 0) { + throw new GraphQLException( + "Int literal is too big or too small for a long, would cause overflow"); + } + return new Timestamp(value.longValue()); + } + return null; + } + + private String formatDateTimeToUTC(Timestamp ts) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + sdf.setTimeZone(TimeZone.getTimeZone("UTC")); + return sdf.format(ts); + } + + }).build(); +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/config/OFBizGraphQLObjectMapperConfigurer.java b/graphql/src/main/java/org/apache/ofbiz/graphql/config/OFBizGraphQLObjectMapperConfigurer.java new file mode 100644 index 000000000..d106baa87 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/config/OFBizGraphQLObjectMapperConfigurer.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql.config; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import graphql.kickstart.execution.config.ObjectMapperConfigurer; + +public class OFBizGraphQLObjectMapperConfigurer implements ObjectMapperConfigurer { + @Override + public void configure(ObjectMapper mapper) { + mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); + mapper.registerModule(new Jdk8Module()); + mapper.setDefaultPropertyInclusion(JsonInclude.Include.ALWAYS); + //mapper.setSerializationInclusion(Include.NON_NULL); messes up the schema retrieval in graphiQL + // mapper.setSerializationInclusion(Include.NON_EMPTY); + } +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/BaseDataFetcher.java b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/BaseDataFetcher.java new file mode 100644 index 000000000..e6fff9bcf --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/BaseDataFetcher.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql.fetcher; + +import org.apache.ofbiz.entity.Delegator; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaDefinition.FieldDefinition; +import graphql.schema.DataFetcher; +import graphql.schema.DataFetchingEnvironment; + +public abstract class BaseDataFetcher implements DataFetcher { + protected final FieldDefinition fieldDef; + protected final Delegator delegator; + + BaseDataFetcher(FieldDefinition fieldDef, Delegator delegator) { + this.fieldDef = fieldDef; + this.delegator = delegator; + } + + @Override + public Object get(DataFetchingEnvironment environment) { + Object result = fetch(environment); + return result; + } + + Object fetch(DataFetchingEnvironment environment) { + return null; + } + + ; +} \ No newline at end of file diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/BaseEntityDataFetcher.java b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/BaseEntityDataFetcher.java new file mode 100644 index 000000000..129028d3f --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/BaseEntityDataFetcher.java @@ -0,0 +1,147 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql.fetcher; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.base.util.UtilXml; +import org.apache.ofbiz.entity.Delegator; +import org.apache.ofbiz.entity.GenericEntityException; +import org.apache.ofbiz.entity.model.ModelEntity; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaDefinition.FieldDefinition; +import org.w3c.dom.Element; + +class BaseEntityDataFetcher extends BaseDataFetcher { + String entityName, interfaceEntityName, operation; + String requireAuthentication; + String interfaceEntityPkField; + List pkFieldNames = new ArrayList<>(1); + String fieldRawType; + Map relKeyMap = new HashMap<>(); + List localizeFields = new ArrayList<>(); + boolean useCache = false; + + BaseEntityDataFetcher(Delegator delegator, Element element, FieldDefinition fieldDef) { + super(fieldDef, delegator); + String entityName = element.getAttribute("entity-name"); + ModelEntity entity = null; + try { + entity = delegator.getModelReader().getModelEntity(entityName); + } catch (GenericEntityException e) { + throw new IllegalArgumentException("Entity [" + entityName + "] does not exist."); + } + + if (element.getAttribute("cache") != null) { + useCache = "true".equals(element.getAttribute("cache")) && !entity.getNeverCache(); + } else { + useCache = !entity.getNeverCache(); + } + + Map keyMap = new HashMap<>(); + List keyMapElements = UtilXml.childElementList(element, "key-map"); + for (Element keyMapElement : keyMapElements) { + String fieldName = keyMapElement.getAttribute("field-name"); + String relFn = keyMapElement.getAttribute("related"); + if (relFn == null) { + if (entity.isField(fieldName)) { + relFn = fieldName; + } else { + if (entity.getPkFieldNames().size() == 1) { + relFn = entity.getPkFieldNames().get(0); + } + } + } + if (relFn == null) { + throw new IllegalArgumentException("The key-map.@related of Entity " + entityName + " should be specified"); + } + + keyMap.put(fieldName, relFn); + } + + List localizeFieldElements = UtilXml.childElementList(element, "localize-field"); + + for (Element keyMapElement : localizeFieldElements) { + if (!localizeFields.contains(keyMapElement.getAttribute("name"))) { + localizeFields.add(keyMapElement.getAttribute("name")); + } + } + initializeFields(entityName, element.getAttribute("interface-entity-name"), keyMap); + } + + BaseEntityDataFetcher(Delegator delegator, FieldDefinition fieldDef, String entityName, Map relKeyMap) { + this(delegator, fieldDef, entityName, null, relKeyMap); + } + + BaseEntityDataFetcher(Delegator delegator, FieldDefinition fieldDef, String entityName, String interfaceEntityName, + Map relKeyMap) { + super(fieldDef, delegator); + ModelEntity entity = null; + try { + entity = delegator.getModelReader().getModelEntity(entityName); + } catch (GenericEntityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + useCache = !entity.getNeverCache(); + initializeFields(entityName, interfaceEntityName, relKeyMap); + } + + private void initializeFields(String entityName, String interfaceEntityName, Map relKeyMap) { + this.requireAuthentication = fieldDef.getRequireAuthentication() != null ? fieldDef.getRequireAuthentication() : "true"; + this.entityName = entityName; + this.interfaceEntityName = interfaceEntityName; + this.fieldRawType = fieldDef.getType(); + this.relKeyMap.putAll(relKeyMap); + if ("true".equals(fieldDef.getIsList())) { + this.operation = "list"; + } else { + this.operation = "one"; + } + if (UtilValidate.isNotEmpty(interfaceEntityName)) { + ModelEntity entity = null; + try { + entity = delegator.getModelReader().getModelEntity(entityName); + } catch (GenericEntityException e) { + e.printStackTrace(); + } + if (entity == null) { + throw new IllegalArgumentException("Interface entity " + interfaceEntityName + " not found"); + } + if (entity.getPkFieldNames().size() != 1) { + throw new IllegalArgumentException("Entity " + interfaceEntityName + " for interface should have one primary key"); + } + interfaceEntityPkField = entity.getFirstPkFieldName(); + } + + ModelEntity entity = null; + try { + entity = delegator.getModelReader().getModelEntity(entityName); + } catch (GenericEntityException e) { + e.printStackTrace(); + } + if (entity == null) { + throw new IllegalArgumentException("Entity " + entityName + " not found"); + } + pkFieldNames.addAll(entity.getPkFieldNames()); + } +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/EmptyDataFetcher.java b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/EmptyDataFetcher.java new file mode 100644 index 000000000..db8e11431 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/EmptyDataFetcher.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql.fetcher; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.apache.ofbiz.graphql.schema.GraphQLSchemaDefinition.FieldDefinition; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaUtil; +import org.w3c.dom.Element; +import graphql.schema.DataFetchingEnvironment; + +public class EmptyDataFetcher extends BaseDataFetcher { + public EmptyDataFetcher(Element node, FieldDefinition fieldDef) { + super(fieldDef, null); + } + + public EmptyDataFetcher(FieldDefinition fieldDef) { + super(fieldDef, null); + } + + @Override + Object fetch(DataFetchingEnvironment environment) { + if (!GraphQLSchemaUtil.graphQLScalarTypes.containsKey(fieldDef.getType())) { + if ("true".equals(fieldDef.getIsList())) { + return new ArrayList(); + } + return new HashMap(); + } + return null; + } +} \ No newline at end of file diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/EntityDataFetcher.java b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/EntityDataFetcher.java new file mode 100644 index 000000000..8db0b3e13 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/EntityDataFetcher.java @@ -0,0 +1,191 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql.fetcher; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.entity.Delegator; +import org.apache.ofbiz.entity.GenericEntityException; +import org.apache.ofbiz.entity.GenericValue; +import org.apache.ofbiz.entity.condition.EntityCondition; +import org.apache.ofbiz.entity.condition.EntityOperator; +import org.apache.ofbiz.entity.util.EntityFindOptions; +import org.apache.ofbiz.entity.util.EntityQuery; +import org.apache.ofbiz.graphql.fetcher.utils.DataFetcherUtils; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaDefinition.FieldDefinition; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaUtil; +import org.w3c.dom.Element; + +import graphql.schema.DataFetchingEnvironment; + +public class EntityDataFetcher extends BaseEntityDataFetcher { + + public EntityDataFetcher() { + super(null, null, null); + } + + public EntityDataFetcher(Delegator delegator, Element node, FieldDefinition fieldDef) { + super(delegator, node, fieldDef); + } + + EntityDataFetcher(Delegator delegator, FieldDefinition fieldDef, String entityName, Map relKeyMap) { + this(delegator, fieldDef, entityName, null, relKeyMap); + } + + EntityDataFetcher(Delegator delegator, FieldDefinition fieldDef, String entityName, String interfaceEntityName, + Map relKeyMap) { + super(delegator, fieldDef, entityName, interfaceEntityName, relKeyMap); + } + + Object fetch(DataFetchingEnvironment environment) { + Map inputFieldsMap = new HashMap<>(); + Map operationMap = new HashMap<>(); + Map resultMap = new HashMap<>(); + GraphQLSchemaUtil.transformArguments(environment.getArguments(), inputFieldsMap, operationMap); + if (operation.equals("one")) { + try { + GenericValue entity = null; + EntityQuery entityQuery = EntityQuery.use(delegator).from(entityName).where(inputFieldsMap); + for (Map.Entry entry : relKeyMap.entrySet()) { + entityQuery.where(EntityCondition + .makeCondition(entry.getValue(), EntityOperator.EQUALS, ((Map) environment.getSource()).get(entry.getKey()))); + } + entity = entityQuery.queryOne(); + if (UtilValidate.isEmpty(entity)) { + return null; + } + if (interfaceEntityName == null || interfaceEntityName.isEmpty() || entityName.equals(interfaceEntityName)) { + return entity; + } else { + GenericValue interfaceEntity = null; + entityQuery = EntityQuery.use(delegator).from(interfaceEntityName) + .where(EntityCondition.makeCondition(entity.getPrimaryKey().getAllFields())); + interfaceEntity = entityQuery.queryOne(); + Map jointOneMap = new HashMap<>(); + if (interfaceEntity != null) { + jointOneMap.putAll(interfaceEntity); + } + jointOneMap.putAll(entity); + return jointOneMap; + } + + } catch (GenericEntityException e) { + e.printStackTrace(); + return null; + } + } else if (operation.equals("list")) { + EntityFindOptions options = null; + List result = null; + Map edgesData; + List entityConditions = new ArrayList(); + if (inputFieldsMap.size() != 0) { + entityConditions.add(EntityCondition.makeCondition(inputFieldsMap)); + } else { + DataFetcherUtils.addEntityConditions(entityConditions, operationMap, GraphQLSchemaUtil.getEntityDefinition(entityName, delegator)); + } + for (Map.Entry entry : relKeyMap.entrySet()) { + entityConditions.add(EntityCondition + .makeCondition(entry.getValue(), EntityOperator.EQUALS, ((Map) environment.getSource()).get(entry.getKey()))); + } + List> edgesDataList = null; + if (GraphQLSchemaUtil.requirePagination(environment)) { + Map arguments = environment.getArguments(); + Map paginationMap = (Map) arguments.get("pagination"); + options = new EntityFindOptions(); + int pageIndex = (int) paginationMap.get("pageIndex"); + int pageSize = (int) paginationMap.get("pageSize"); + int pageRangeLow = pageIndex * pageSize + 1; + int pageRangeHigh = (pageIndex * pageSize) + pageSize; + int first = (int) paginationMap.get("first"); + String after = (String) paginationMap.get("after"); + boolean hasPreviousPage = pageIndex > 0; + String orderBy = (String) paginationMap.get("orderByField"); + options.setLimit(pageSize); + options.setMaxRows(pageSize); + options.setOffset(pageIndex); + Map pageInfo = new HashMap(); + pageInfo.put("pageIndex", pageIndex); + pageInfo.put("pageSize", pageSize); + pageInfo.put("pageRangeLow", pageRangeLow); + pageInfo.put("pageRangeHigh", pageRangeHigh); + pageInfo.put("hasPreviousPage", hasPreviousPage); + int count = 0; + try { + count = (int) delegator.findCountByCondition(entityName, EntityCondition.makeCondition(entityConditions), null, options); + result = delegator.findList(entityName, EntityCondition.makeCondition(entityConditions), null, + UtilValidate.isNotEmpty(orderBy) ? Arrays.asList(orderBy.split(",")) : null, options, false); + } catch (GenericEntityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + int pageMaxIndex = new BigDecimal(count - 1).divide(new BigDecimal(pageSize), 0, BigDecimal.ROUND_DOWN).intValue(); + pageInfo.put("pageMaxIndex", pageMaxIndex); + if (pageRangeHigh > count) { + pageRangeHigh = count; + } + boolean hasNextPage = pageMaxIndex > pageIndex; + pageInfo.put("hasNextPage", hasNextPage); + pageInfo.put("totalCount", count); + edgesDataList = new ArrayList>(result.size()); + if (UtilValidate.isNotEmpty(result)) { + String cursor = null; + if (interfaceEntityName == null || interfaceEntityName.isEmpty() || entityName.equals(interfaceEntityName)) { + pageInfo.put("startCursor", GraphQLSchemaUtil.encodeRelayCursor(result.get(0), pkFieldNames)); //TODO + pageInfo.put("endCursor", GraphQLSchemaUtil.encodeRelayCursor(result.get(result.size() - 1), pkFieldNames)); //TODO + for (GenericValue gv : result) { + edgesData = new HashMap<>(2); + cursor = GraphQLSchemaUtil.encodeRelayCursor(gv, pkFieldNames); + edgesData.put("cursor", cursor); //TODO + edgesData.put("node", gv); + edgesDataList.add(edgesData); + } + } + resultMap.put("pageInfo", pageInfo); + } + + } else { + try { + result = delegator.findList(entityName, EntityCondition.makeCondition(entityConditions), null, null, options, false); + } catch (GenericEntityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + edgesDataList = new ArrayList>(result != null ? result.size() : 0); + if (interfaceEntityName == null || interfaceEntityName.isEmpty() || entityName.equals(interfaceEntityName)) { + for (GenericValue gv : result) { + edgesData = new HashMap<>(2); + edgesData.put("cursor", "2"); //TODO + edgesData.put("node", gv); + edgesDataList.add(edgesData); + } + } + } + resultMap.put("edges", edgesDataList); + return resultMap; + } + return null; + } + +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/ServiceDataFetcher.java b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/ServiceDataFetcher.java new file mode 100644 index 000000000..013d4664d --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/ServiceDataFetcher.java @@ -0,0 +1,175 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql.fetcher; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.base.util.UtilXml; +import org.apache.ofbiz.entity.Delegator; +import org.apache.ofbiz.entity.GenericEntityException; +import org.apache.ofbiz.entity.GenericValue; +import org.apache.ofbiz.entity.util.EntityQuery; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaDefinition.FieldDefinition; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaUtil; +import org.apache.ofbiz.service.GenericServiceException; +import org.apache.ofbiz.service.LocalDispatcher; +import org.apache.ofbiz.service.ModelService; +import org.apache.ofbiz.service.ServiceUtil; +import org.w3c.dom.Element; + +import graphql.schema.DataFetchingEnvironment; +import graphql.servlet.context.DefaultGraphQLServletContext; + +public class ServiceDataFetcher extends BaseDataFetcher { + + private String serviceName; + private String requireAuthentication; + private String invoke; + private String defaultEntity; + boolean isEntityAutoService; + boolean resultPrimitive = false; + + public Map getRelKeyMap() { + return relKeyMap; + } + + public String getServiceName() { + return serviceName; + } + + public boolean isEntityAutoService() { + return isEntityAutoService; + } + + + Map relKeyMap = new HashMap<>(); + + public ServiceDataFetcher(Element node, FieldDefinition fieldDef, Delegator delegator, LocalDispatcher dispatcher) { + super(fieldDef, delegator); + this.requireAuthentication = node.getAttribute("require-authentication") != null + ? node.getAttribute("require-authentication") + : "true"; + this.serviceName = node.getAttribute("service"); + List elements = UtilXml.childElementList(node, "key-map"); + for (Element keyMapNode : elements) { + relKeyMap.put(keyMapNode.getAttribute("field-name"), + keyMapNode.getAttribute("related") != null ? keyMapNode.getAttribute("related") + : keyMapNode.getAttribute("field-name")); + } + + try { + ModelService service = dispatcher.getDispatchContext().getModelService(serviceName); + if (service == null) { + throw new IllegalArgumentException("Service ${serviceName} not found"); + } + if (service.getEngineName().equalsIgnoreCase("entity-auto")) { + isEntityAutoService = true; + } + + defaultEntity = service.getDefaultEntityName(); + invoke = service.getInvoke(); + + if (this.isEntityAutoService) { + if (!fieldDef.isMutation()) { + throw new IllegalArgumentException("Query should not use entity auto service ${serviceName}"); + } + } else { + if (service.getParam("_graphql_result_primitive") != null) { + resultPrimitive = true; + } + } + + } catch (GenericServiceException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + Object fetch(DataFetchingEnvironment environment) { + DefaultGraphQLServletContext context = environment.getContext(); + HttpServletRequest request = context.getHttpServletRequest(); + LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); + GenericValue userLogin = (GenericValue) request.getAttribute("userLogin"); + if (dispatcher == null) { + dispatcher = (LocalDispatcher) request.getServletContext().getAttribute("dispatcher"); + } + + ModelService service = null; + + try { + service = dispatcher.getDispatchContext().getModelService(serviceName); + } catch (GenericServiceException e) { + e.printStackTrace(); + } + Map inputFieldsMap = new HashMap<>(); + Map operationMap = new HashMap<>(); + inputFieldsMap.put("userLogin", userLogin); + if (fieldDef.isMutation()) { + GraphQLSchemaUtil.transformArguments(environment.getArguments(), inputFieldsMap, operationMap); + } else { + GraphQLSchemaUtil.transformQueryServiceArguments(service, environment.getArguments(), inputFieldsMap); + Map source = environment.getSource(); + GraphQLSchemaUtil.transformQueryServiceRelArguments(source, relKeyMap, inputFieldsMap); + } + + Map result = null; + + try { + if (fieldDef.isMutation()) { + result = dispatcher.runSync(serviceName, inputFieldsMap); + String verb = GraphQLSchemaUtil.getVerbFromName(serviceName, dispatcher); + if (this.isEntityAutoService || isCRUDService()) { + if (UtilValidate.isNotEmpty(verb) && verb.equals("delete")) { + result.put("error", false); + result.put("message", "Deleted Successfully"); + } else { + GenericValue entity = null; + try { + entity = EntityQuery.use(delegator).from(defaultEntity).where(result).cache().queryOne(); + result.put("_graphql_result_", entity); + } catch (GenericEntityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } else { + result = dispatcher.runSync(serviceName, inputFieldsMap); + } + } catch (GenericServiceException e) { + e.printStackTrace(); + } + + return result; + } + + private boolean isCRUDService() { + if ((invoke.startsWith("create") || invoke.startsWith("update") || invoke.startsWith("delete")) && invoke.endsWith(defaultEntity)) { + return true; + } + return false; + } +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/utils/DataFetcherUtils.java b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/utils/DataFetcherUtils.java new file mode 100644 index 000000000..901d05618 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/fetcher/utils/DataFetcherUtils.java @@ -0,0 +1,176 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql.fetcher.utils; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.entity.condition.EntityComparisonOperator; +import org.apache.ofbiz.entity.condition.EntityCondition; +import org.apache.ofbiz.entity.condition.EntityFunction; +import org.apache.ofbiz.entity.condition.EntityOperator; +import org.apache.ofbiz.entity.model.ModelEntity; +import graphql.language.Field; +import graphql.language.FragmentSpread; +import graphql.language.InlineFragment; +import graphql.language.Selection; +import graphql.language.SelectionSet; + +public class DataFetcherUtils { + static Selection getGraphQLSelection(SelectionSet selectionSet, String name) { + if (selectionSet == null) { + return null; + } + for (Selection selection : selectionSet.getSelections()) { + if (selection instanceof Field) { + if (((Field) (selection)).getName().equals(name)) { + return selection; + } + } else if (selection instanceof FragmentSpread) { + // Do nothing since FragmentSpread has no way to find selectionSet + } else if (selection instanceof InlineFragment) { + getGraphQLSelection(((InlineFragment) (selection)).getSelectionSet(), name); + } + } + return null; + } + + static SelectionSet getGraphQLSelectionSet(Selection selection) { + if (selection == null) { + return null; + } + if (selection instanceof Field) { + return (((Field) selection)).getSelectionSet(); + } + if (selection instanceof InlineFragment) { + return ((InlineFragment) (selection)).getSelectionSet(); + } + return null; + } + + static SelectionSet getConnectionNodeSelectionSet(SelectionSet selectionSet) { + SelectionSet finalSelectionSet; + + Selection edgesSS = getGraphQLSelection(selectionSet, "edges"); + finalSelectionSet = getGraphQLSelectionSet(edgesSS); + if (finalSelectionSet == null) { + return null; + } + + Selection nodeSS = getGraphQLSelection(finalSelectionSet, "node"); + finalSelectionSet = getGraphQLSelectionSet(nodeSS); + + return finalSelectionSet; + } + + static boolean matchParentByRelKeyMap(Map sourceItem, Map self, + Map relKeyMap) { + int found = -1; + for (Map.Entry entry : relKeyMap.entrySet()) { + found = (found == -1) ? (sourceItem.get(entry.getKey()) == self.get(entry.getValue()) ? 1 : 0) + : (found == 1 && sourceItem.get(entry.getKey()) == self.get(entry.getValue()) ? 1 : 0); + } + return found == 1; + } + + public static List addEntityConditions(List entityConditions, + Map inputFieldsMap, ModelEntity entity) { + if (inputFieldsMap == null || inputFieldsMap.size() == 0) { + return entityConditions; + } + + for (String fieldName : entity.getAllFieldNames()) { + if (inputFieldsMap.containsKey(fieldName) || inputFieldsMap.containsKey(fieldName + "_op")) { + String value = (String) inputFieldsMap.get(fieldName); + String op = UtilValidate.isNotEmpty(inputFieldsMap.get(fieldName + "_op")) + ? (String) inputFieldsMap.get(fieldName + "_op") + : "equals"; + boolean not = ("Y").equals(inputFieldsMap.get(fieldName + "_not")) + || "true".equals(inputFieldsMap.get(fieldName + "_not")); + boolean ic = "Y".equals(inputFieldsMap.get(fieldName + "_ic")) + || "true".equals(inputFieldsMap.get(fieldName + "_ic")); + boolean isValEmpty = UtilValidate.isEmpty(value); + switch (op) { + case "equals": + if (!isValEmpty) { + EntityComparisonOperator eq_operator = not ? EntityOperator.NOT_EQUAL + : EntityOperator.EQUALS; + if (ic) { + entityConditions.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), + eq_operator, EntityFunction.UPPER(value.trim()))); + } else { + entityConditions.add(EntityCondition.makeCondition(fieldName, eq_operator, value.trim())); + } + + } + break; + case "like": + if (!isValEmpty) { + EntityComparisonOperator eq_operator = not ? EntityOperator.NOT_LIKE + : EntityOperator.LIKE; + if (ic) { + entityConditions.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), + eq_operator, EntityFunction.UPPER(value))); + } else { + entityConditions.add(EntityCondition.makeCondition(fieldName, eq_operator, value)); + } + + } + break; + case "contains": + if (!isValEmpty) { + EntityComparisonOperator eq_operator = not ? EntityOperator.NOT_LIKE + : EntityOperator.LIKE; + if (ic) { + entityConditions.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), + eq_operator, EntityFunction.UPPER("%" + value + "%"))); + } else { + entityConditions + .add(EntityCondition.makeCondition(fieldName, eq_operator, "%" + value + "%")); + } + } + break; + case "begins": + if (!isValEmpty) { + EntityComparisonOperator eq_operator = not ? EntityOperator.NOT_LIKE + : EntityOperator.LIKE; + if (ic) { + entityConditions.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), + eq_operator, EntityFunction.UPPER(value + "%"))); + } else { + entityConditions.add(EntityCondition.makeCondition(fieldName, eq_operator, value + "%")); + } + } + break; + case "in": + if (!isValEmpty) { + List valueList = Arrays.asList(value.split(",")); + EntityComparisonOperator eq_operator = not ? EntityOperator.NOT_IN : EntityOperator.IN; + entityConditions.add(EntityCondition.makeCondition(fieldName, eq_operator, valueList)); + } + break; + } + + } + } + return entityConditions; + } +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/filter/AuthenticationFilter.java b/graphql/src/main/java/org/apache/ofbiz/graphql/filter/AuthenticationFilter.java new file mode 100644 index 000000000..44a562afa --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/filter/AuthenticationFilter.java @@ -0,0 +1,147 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql.filter; + +import java.io.IOException; +import java.util.Map; +import java.util.Optional; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; + +import org.apache.ofbiz.base.util.Debug; +import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.entity.Delegator; +import org.apache.ofbiz.entity.GenericEntityException; +import org.apache.ofbiz.entity.GenericValue; +import org.apache.ofbiz.entity.util.EntityQuery; +import org.apache.ofbiz.graphql.GraphQLErrorType; +import org.apache.ofbiz.graphql.config.OFBizGraphQLObjectMapperConfigurer; +import org.apache.ofbiz.service.ModelService; +import org.apache.ofbiz.webapp.control.JWTManager; +import graphql.ExecutionResultImpl; +import graphql.GraphQLError; +import graphql.GraphqlErrorBuilder; +import graphql.kickstart.execution.GraphQLObjectMapper; + + +public class AuthenticationFilter implements Filter { + + private static final String MODULE = AuthenticationFilter.class.getName(); + private GraphQLObjectMapper mapper; + private static final String AUTHENTICATION_SCHEME = "Bearer"; + private static final String REALM = "OFBiz-GraphQl"; + private static final String INTROSPECTION_QUERY_PATH = "/schema.json"; + + { + mapper = GraphQLObjectMapper.newBuilder().withObjectMapperConfigurer(new OFBizGraphQLObjectMapperConfigurer()).build(); + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + HttpServletRequest httpRequest = (HttpServletRequest) request; + HttpServletResponse httpResponse = (HttpServletResponse) response; + String authorizationHeader = httpRequest.getHeader(HttpHeaders.AUTHORIZATION); + if (!isTokenBasedAuthentication(authorizationHeader)) { + abortWithUnauthorized(httpResponse, false, "Authentication Required"); + return; + } + ServletContext servletContext = request.getServletContext(); + Delegator delegator = (Delegator) servletContext.getAttribute("delegator"); + String jwtToken = JWTManager.getHeaderAuthBearerToken(httpRequest); + Map claims = JWTManager.validateToken(jwtToken, JWTManager.getJWTKey(delegator)); + if (claims.containsKey(ModelService.ERROR_MESSAGE)) { + abortWithUnauthorized(httpResponse, true, (String) claims.get(ModelService.ERROR_MESSAGE)); + return; + } else { + GenericValue userLogin = extractUserLoginFromJwtClaim(delegator, claims); + if (UtilValidate.isEmpty(userLogin)) { + abortWithUnauthorized(httpResponse, true, "There was a problem with the JWT token. Could not find provided userLogin"); + return; + } + httpRequest.setAttribute("userLogin", userLogin); + httpRequest.setAttribute("delegator", delegator); + } + chain.doFilter(request, response); + } + + /** + * @param request + * @return + */ + private boolean isIntrospectionQuery(HttpServletRequest request) { + String path = Optional.ofNullable(request.getPathInfo()).orElseGet(request::getServletPath).toLowerCase(); + return path.contentEquals(INTROSPECTION_QUERY_PATH); + } + + /** + * @param requestContext + * @throws IOException + */ + private void abortWithUnauthorized(HttpServletResponse httpResponse, boolean isAuthHeaderPresent, String message) throws IOException { + httpResponse.reset(); + httpResponse.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); + if (!isAuthHeaderPresent) { + httpResponse.addHeader(HttpHeaders.WWW_AUTHENTICATE, AUTHENTICATION_SCHEME + " realm=\"" + REALM + "\""); + } + httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + GraphQLError error = GraphqlErrorBuilder.newError().message(message, (Object[]) null).errorType(GraphQLErrorType.AuthenticationError).build(); + ExecutionResultImpl result = new ExecutionResultImpl(error); + mapper.serializeResultAsJson(httpResponse.getWriter(), result); + + } + + /** + * /** + * + * @param authorizationHeader + * @return + */ + private boolean isTokenBasedAuthentication(String authorizationHeader) { + return authorizationHeader != null && authorizationHeader.toLowerCase().startsWith(AUTHENTICATION_SCHEME.toLowerCase() + " "); + } + + + private GenericValue extractUserLoginFromJwtClaim(Delegator delegator, Map claims) { + String userLoginId = (String) claims.get("userLoginId"); + if (UtilValidate.isEmpty(userLoginId)) { + Debug.logWarning("No userLoginId found in the JWT token.", MODULE); + return null; + } + GenericValue userLogin = null; + try { + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); + if (UtilValidate.isEmpty(userLogin)) { + Debug.logWarning("There was a problem with the JWT token. Could not find provided userLogin " + userLoginId, MODULE); + } + } catch (GenericEntityException e) { + Debug.logError(e, "Unable to get UserLogin information from JWT Token: " + e.getMessage(), MODULE); + } + return userLogin; + } + +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/schema/DateRangeInputType.java b/graphql/src/main/java/org/apache/ofbiz/graphql/schema/DateRangeInputType.java new file mode 100644 index 000000000..7c0ccac10 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/schema/DateRangeInputType.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.aaaab + *******************************************************************************/ +package org.apache.ofbiz.graphql.schema; + +import java.util.LinkedHashMap; +import java.util.Map; + +@SuppressWarnings("serial") +public class DateRangeInputType extends LinkedHashMap { + public String period; + public String poffset; + public String from; + public String thru; + + DateRangeInputType(String period, String poffset, String from, String thru) { + this.period = period; + this.poffset = poffset; + this.from = from; + this.thru = thru; + if (this.period != null) { + this.put("period", this.period); + } + if (this.poffset != null) { + this.put("poffset", this.poffset); + } + if (this.from != null) { + this.put("from", this.from); + } + if (this.thru != null) { + this.put("thru", this.thru); + } + } + + public DateRangeInputType(Map map) { + this((String) map.get("period"), (String) map.get("poffset"), (String) map.get("from"), (String) map.get("thru")); + } +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/schema/GraphQLSchemaDefinition.java b/graphql/src/main/java/org/apache/ofbiz/graphql/schema/GraphQLSchemaDefinition.java new file mode 100644 index 000000000..bb2029070 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/schema/GraphQLSchemaDefinition.java @@ -0,0 +1,2179 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.aaaab + *******************************************************************************/ +package org.apache.ofbiz.graphql.schema; + +import static graphql.Scalars.GraphQLBoolean; +import static graphql.Scalars.GraphQLChar; +import static graphql.Scalars.GraphQLInt; +import static graphql.Scalars.GraphQLString; +import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; +import static graphql.schema.GraphQLObjectType.newObject; +import static graphql.schema.idl.TypeRuntimeWiring.newTypeWiring; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.apache.ofbiz.base.util.FileUtil; +import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.base.util.UtilXml; +import org.apache.ofbiz.entity.Delegator; +import org.apache.ofbiz.entity.model.ModelEntity; +import org.apache.ofbiz.entity.model.ModelField; +import org.apache.ofbiz.graphql.fetcher.BaseDataFetcher; +import org.apache.ofbiz.graphql.fetcher.EmptyDataFetcher; +import org.apache.ofbiz.graphql.fetcher.EntityDataFetcher; +import org.apache.ofbiz.graphql.fetcher.ServiceDataFetcher; +import org.apache.ofbiz.service.GenericServiceException; +import org.apache.ofbiz.service.LocalDispatcher; +import org.apache.ofbiz.service.ModelParam; +import org.apache.ofbiz.service.ModelService; +import org.w3c.dom.Element; +import graphql.TypeResolutionEnvironment; +import graphql.schema.FieldCoordinates; +import graphql.schema.GraphQLArgument; +import graphql.schema.GraphQLCodeRegistry; +import graphql.schema.GraphQLFieldDefinition; +import graphql.schema.GraphQLInputObjectField; +import graphql.schema.GraphQLInputObjectType; +import graphql.schema.GraphQLInputType; +import graphql.schema.GraphQLInterfaceType; +import graphql.schema.GraphQLList; +import graphql.schema.GraphQLNonNull; +import graphql.schema.GraphQLObjectType; +import graphql.schema.GraphQLOutputType; +import graphql.schema.GraphQLScalarType; +import graphql.schema.GraphQLSchema; +import graphql.schema.GraphQLTypeReference; +import graphql.schema.StaticDataFetcher; +import graphql.schema.TypeResolver; +import graphql.schema.idl.RuntimeWiring; +import graphql.schema.idl.SchemaGenerator; +import graphql.schema.idl.SchemaParser; +import graphql.schema.idl.TypeDefinitionRegistry; + +public class GraphQLSchemaDefinition { + + private Delegator delegator; + private LocalDispatcher dispatcher; + protected final Map schemaInputTypeMap = new HashMap<>(); + protected static final Map graphQLInputTypeMap = new HashMap<>(); + protected static Map fieldDefMap = new HashMap<>(); + protected final ArrayList schemaInputTypeNameList = new ArrayList<>(); + protected final Map queryRootFieldMap = new LinkedHashMap<>(); + protected final Map mutationRootFieldMap = new LinkedHashMap<>(); + protected final String queryRootObjectTypeName = "QueryRootObjectType"; + protected final String mutationRootObjectTypeName = "MutationRootObjectType"; + protected Map allTypeDefMap = new LinkedHashMap<>(); + protected static Map argumentDefMap = new HashMap<>(); + protected Map extendObjectDefMap = new LinkedHashMap<>(); + protected Map interfaceTypeDefMap = new LinkedHashMap<>(); + protected static Map interfaceFetcherNodeMap = new HashMap<>(); + + // Type Maps + protected static final Map graphQLInterfaceTypeMap = new HashMap<>(); + protected static final Map graphQLOutputTypeMap = new HashMap<>(); + protected static final Map graphQLObjectTypeMap = new HashMap<>(); + protected static final Map graphQLFieldMap = new HashMap<>(); + protected static final Map graphQLInputObjectTypeMap = new HashMap<>(); + protected static final Map graphQLInputObjectFieldMap = new HashMap<>(); + protected static final Map graphQLArgumentMap = new HashMap<>(); + protected static final Map graphQLDirectiveArgumentMap = new LinkedHashMap<>(); + protected static final Map graphQLTypeReferenceMap = new HashMap<>(); + + protected LinkedList allTypeDefSortedList = new LinkedList<>(); + protected Map requiredTypeDefMap = new LinkedHashMap<>(); + + protected static Set interfaceResolverTypeSet = new HashSet<>(); + + protected static final String KEY_SPLITTER = "__"; + protected static final String NON_NULL_SUFFIX = "_1"; + protected static final String IS_LIST_SUFFIX = "_2"; + protected static final String LIST_ITEM_NON_NULL_SUFFIX = "_3"; + protected static final String REQUIRED_SUFFIX = "_a"; + + protected static GraphQLObjectType pageInfoType; + protected static GraphQLInputObjectType paginationInputType; + protected static GraphQLInputObjectType operationInputType; + protected static GraphQLInputObjectType dateRangeInputType; + protected static GraphQLFieldDefinition cursorField; + protected static GraphQLFieldDefinition clientMutationIdField; + protected static GraphQLArgument paginationArgument; + protected static GraphQLArgument ifArgument; + protected static GraphQLInputObjectField clientMutationIdInputField; + private static GraphQLCodeRegistry.Builder codeRegistryBuilder = GraphQLCodeRegistry.newCodeRegistry(); + + static { + createPredefinedGraphQLTypes(); + } + + private static void createPredefinedGraphQLTypes() { + // Add default GraphQLScalarType + for (Map.Entry entry : GraphQLSchemaUtil.graphQLScalarTypes.entrySet()) { + graphQLInputTypeMap.put(entry.getKey(), entry.getValue()); + graphQLOutputTypeMap.put(entry.getKey(), entry.getValue()); + } + + GraphQLFieldDefinition.Builder cursorFieldBuilder = GraphQLFieldDefinition.newFieldDefinition().name("cursor") + .type(GraphQLString); + for (Map.Entry entry : graphQLDirectiveArgumentMap.entrySet()) cursorFieldBuilder.argument(entry.getValue()); + cursorField = cursorFieldBuilder.build(); + graphQLFieldMap.put("cursor" + KEY_SPLITTER + "String", cursorField); + + + GraphQLFieldDefinition.Builder clientMutationIdFieldBuilder = GraphQLFieldDefinition.newFieldDefinition() + .name("clientMutationId").type(GraphQLString); + for (Map.Entry entry : graphQLDirectiveArgumentMap.entrySet()) { + clientMutationIdFieldBuilder.argument(entry.getValue()); + } + clientMutationIdField = clientMutationIdFieldBuilder.build(); + graphQLFieldMap.put("clientMutationId" + KEY_SPLITTER + "String", clientMutationIdField); + + ifArgument = GraphQLArgument.newArgument().name("if") + .type(GraphQLBoolean).description("Directive @if").build(); + graphQLDirectiveArgumentMap.put("if", ifArgument); + + // Predefined GraphQLObject + pageInfoType = GraphQLObjectType.newObject().name("GraphQLPageInfo") + .field(getGraphQLFieldWithNoArgs("GraphQLPageInfo", "pageIndex", GraphQLInt, "")) + .field(getGraphQLFieldWithNoArgs("GraphQLPageInfo", "pageSize", GraphQLInt, "")) + .field(getGraphQLFieldWithNoArgs("GraphQLPageInfo", "totalCount", GraphQLInt, "")) + .field(getGraphQLFieldWithNoArgs("GraphQLPageInfo", "pageMaxIndex", GraphQLInt, "")) + .field(getGraphQLFieldWithNoArgs("GraphQLPageInfo", "pageRangeLow", GraphQLInt, "")) + .field(getGraphQLFieldWithNoArgs("GraphQLPageInfo", "pageRangeHigh", GraphQLInt, "")) + .field(getGraphQLFieldWithNoArgs("GraphQLPageInfo", "hasPreviousPage", GraphQLBoolean, + "hasPreviousPage will be false if the client is not paginating with last, or if the client is paginating with last, and the server has determined that the client has reached the end of the set of edges defined by their cursors.")) + .field(getGraphQLFieldWithNoArgs("GraphQLPageInfo", "hasNextPage", GraphQLBoolean, + "hasNextPage will be false if the client is not paginating with first, or if the client is paginating with first, and the server has determined that the client has reached the end of the set of edges defined by their cursors")) + .field(getGraphQLFieldWithNoArgs("GraphQLPageInfo", "startCursor", GraphQLString, "")) + .field(getGraphQLFieldWithNoArgs("GraphQLPageInfo", "endCursor", GraphQLString, "")) + .build(); + graphQLObjectTypeMap.put("GraphQLPageInfo", pageInfoType); + graphQLOutputTypeMap.put("GraphQLPageInfo", pageInfoType); + + + // Predefined GraphQLInputObject + paginationInputType = GraphQLInputObjectType.newInputObject().name("PaginationInputType") + .field(createPredefinedInputField("pageIndex", GraphQLInt, 0, "Page index for pagination, default 0")) + .field(createPredefinedInputField("pageSize", GraphQLInt, 20, "Page size for pagination, default 20")) + .field(createPredefinedInputField("pageNoLimit", GraphQLBoolean, false, "Page no limit for pagination, default false")) + .field(createPredefinedInputField("orderByField", GraphQLString, null, "OrderBy field for pagination. \ne.g. \n" + + "productName \n" + "productName,statusId \n" + "-statusId,productName")) + .field(createPredefinedInputField("first", GraphQLInt, 20, "Forward pagination argument takes a non‐negative integer, default 20")) + .field(createPredefinedInputField("after", GraphQLString, null, "Forward pagination argument takes the cursor, default null")) + .field(createPredefinedInputField("last", GraphQLInt, 20, "Backward pagination argument takes a non‐negative integer, default 20")) + .field(createPredefinedInputField("before", GraphQLString, null, "Backward pagination argument takes the cursor, default null")) + .field(createPredefinedInputField("type", GraphQLString, null, "Pagination type either 'offset' or 'cursor'")) + .build(); + graphQLInputTypeMap.put("PaginationInputType", paginationInputType); + + operationInputType = GraphQLInputObjectType.newInputObject().name("OperationInputType") + .field(createPredefinedInputField("op", GraphQLString, null, + "Operation on field, one of [ equals | like | contains | begins | empty | in ]")) + .field(createPredefinedInputField("value", GraphQLString, null, "Argument value")) + .field(createPredefinedInputField("not", GraphQLString, null, "Not operation, one of [ Y | true ] represents true")) + .field(createPredefinedInputField("ic", GraphQLString, null, "Case insensitive, one of [ Y | true ] represents true")) + .build(); + graphQLInputTypeMap.put("OperationInputType", operationInputType); + + dateRangeInputType = GraphQLInputObjectType.newInputObject().name("DateRangeInputType") + .field(createPredefinedInputField("period", GraphQLChar, null, "")) + .field(createPredefinedInputField("poffset", GraphQLChar, null, "")) + .field(createPredefinedInputField("from", GraphQLChar, null, "")) + .field(createPredefinedInputField("thru", GraphQLChar, null, "")) + .build(); + graphQLInputTypeMap.put("DateRangeInputType", dateRangeInputType); + + paginationArgument = GraphQLArgument.newArgument().name("pagination") + .type(paginationInputType) + .description("pagination").build(); + graphQLArgumentMap.put(getArgumentKey("pagination", paginationInputType.getName()), paginationArgument); + + clientMutationIdInputField = GraphQLInputObjectField.newInputObjectField().name("clientMutationId") + .type(GraphQLString).description("A unique identifier for the client performing the mutation.").build(); + graphQLInputObjectFieldMap.put("clientMutationId", clientMutationIdInputField); + } + + private static GraphQLInputObjectField createPredefinedInputField(String name, GraphQLInputType type, Object defaultValue, String description) { + GraphQLInputObjectField.Builder fieldBuilder = + GraphQLInputObjectField.newInputObjectField().name(name).type(type).defaultValue(defaultValue).description(description); + return fieldBuilder.build(); + } + + static class TreeNode { + T data; + public final List> children = new LinkedList>(); + + public TreeNode(T data) { + this.data = data; + } + } + + static class EnumValue { + String name, value, description, depreciationReason; + + EnumValue(Element node) { + this.name = node.getAttribute("node"); + this.value = node.getAttribute("value"); + List elements = UtilXml.childElementList(node); + for (Element childNode : elements) { + switch (childNode.getNodeName()) { + case "description": + this.description = childNode.getTextContent(); + break; + case "depreciation-reason": + this.depreciationReason = childNode.getTextContent(); + break; + } + } + } + } + + static class EnumTypeDefinition extends GraphQLTypeDefinition { + List valueList = new LinkedList<>(); + + EnumTypeDefinition(Element node) { + this.name = node.getAttribute("name"); + this.type = "enum"; + List elements = UtilXml.childElementList(node); + for (Element childNode : elements) { + switch (childNode.getNodeName()) { + case "description": + this.description = childNode.getTextContent(); + break; + case "enum-value": + valueList.add(new EnumValue(childNode)); + break; + } + } + } + + @Override + List getDependentTypes() { + return new LinkedList(); + } + } + + static class ExtendObjectDefinition { + final Delegator delegator; + final LocalDispatcher dispatcher; + List extendObjectNodeList = new ArrayList(); + String name, resolverField; + + List interfaceList = new LinkedList<>(); + Map fieldDefMap = new LinkedHashMap<>(); + List excludeFields = new ArrayList<>(); + Map resolverMap = new LinkedHashMap<>(); + + boolean convertToInterface = false; + + ExtendObjectDefinition(Element node, Delegator delegator, LocalDispatcher dispatcher) { + this.delegator = delegator; + this.dispatcher = dispatcher; + this.extendObjectNodeList.add(node); + this.name = node.getAttribute("name"); + List elements = UtilXml.childElementList(node); + for (Element childNode : elements) { + switch (childNode.getNodeName()) { + case "interface": + interfaceList.add(childNode.getAttribute("name")); + break; + case "field": + System.out.println("Name: " + childNode.getAttribute("name")); + System.out.println("Parent Name: " + this.name); + fieldDefMap.put(childNode.getAttribute("name"), new FieldDefinition(this.name, delegator, dispatcher, childNode)); + System.out.println(); + break; + case "exclude-field": + excludeFields.add(childNode.getAttribute("name")); + break; + case "convert-to-interface": + convertToInterface = true; + resolverField = childNode.getAttribute("resolver-field"); + break; + } + } + } + + ExtendObjectDefinition merge(ExtendObjectDefinition other) { + extendObjectNodeList.addAll(other.extendObjectNodeList); + resolverField = resolverField != null ? resolverField : other.resolverField; + interfaceList.addAll(other.interfaceList); + fieldDefMap.putAll(other.fieldDefMap); + excludeFields.addAll(other.excludeFields); + resolverMap.putAll(other.resolverMap); + convertToInterface = convertToInterface ? convertToInterface : other.convertToInterface; + return this; + } + + } + + static class UnionTypeDefinition extends GraphQLTypeDefinition { + String typeResolver; + List typeList = new LinkedList<>(); + + UnionTypeDefinition(Element node) { + this.name = node.getAttribute("name"); + this.type = "union"; + this.typeResolver = node.getAttribute("type-resolver"); + List elements = UtilXml.childElementList(node); + for (Element childNode : elements) { + switch (childNode.getNodeName()) { + case "description": + this.description = childNode.getTextContent(); + break; + case "type": + typeList.add(childNode.getAttribute("name")); + break; + } + } + } + + @Override + List getDependentTypes() { + return typeList; + } + } + + public GraphQLSchemaDefinition(Delegator delegator, LocalDispatcher dispatcher, Map schemaMap) { + this.delegator = delegator; + this.dispatcher = dispatcher; + GraphQLSchemaUtil.createObjectTypeNodeForAllEntities(delegator, dispatcher, allTypeDefMap); + schemaMap.forEach((k, v) -> { + Element schemaElement = v; + List elements = UtilXml.childElementList(schemaElement, "interface-fetcher"); + for (Element interfaceFetcherNode : elements) { + interfaceFetcherNodeMap.put(interfaceFetcherNode.getAttribute("name"), interfaceFetcherNode); + } + }); + + schemaMap.forEach((k, v) -> { + Element schemaElement = v; + String rootFieldName = schemaElement.getAttribute("name"); + String rootQueryTypeName = schemaElement.getAttribute("query"); + String rootMutationTypeName = schemaElement.getAttribute("mutation"); + if (!rootQueryTypeName.isEmpty()) { + queryRootFieldMap.put(rootFieldName, rootQueryTypeName); + } + if (!rootMutationTypeName.isEmpty()) { + mutationRootFieldMap.put(rootFieldName, rootMutationTypeName); + } + + List elements = UtilXml.childElementList(schemaElement); + for (Element element : elements) { + String nodeName = element.getNodeName(); + switch (nodeName) { + case "input-type": + schemaInputTypeNameList.add(element.getAttribute("name")); + break; + case "interface": + InterfaceTypeDefinition interfaceTypeDef = new InterfaceTypeDefinition(element, delegator, + dispatcher); + allTypeDefMap.put(element.getAttribute("name"), interfaceTypeDef); + interfaceTypeDefMap.put(element.getAttribute("name"), interfaceTypeDef); + break; + case "object": + allTypeDefMap.put(element.getAttribute("name"), + new ObjectTypeDefinition(element, delegator, dispatcher)); + break; + case "union": + allTypeDefMap.put(element.getAttribute("name"), new UnionTypeDefinition(element)); + break; + case "enum": + allTypeDefMap.put(element.getAttribute("name"), new EnumTypeDefinition(element)); + break; + case "extend-object": + extendObjectDefMap.put(element.getAttribute("name"), mergeExtendObjectDef(extendObjectDefMap, + new ExtendObjectDefinition(element, delegator, dispatcher))); + break; + } + } + }); + createRootObjectTypeDef(queryRootObjectTypeName, queryRootFieldMap); + createRootObjectTypeDef(mutationRootObjectTypeName, mutationRootFieldMap); + updateAllTypeDefMap(); + } + + private void updateAllTypeDefMap() { + + // Extend object which convert to interface first + for (Map.Entry entry : extendObjectDefMap.entrySet()) { + ExtendObjectDefinition extendObjectDef = (ExtendObjectDefinition) entry.getValue(); + if (!extendObjectDef.convertToInterface) { + continue; + } + + String name = entry.getKey(); + ObjectTypeDefinition objectTypeDef = (ObjectTypeDefinition) allTypeDefMap.get(name); + if (objectTypeDef == null) { + throw new IllegalArgumentException("ObjectTypeDefinition [${name}] not found to extend"); + } + + if (interfaceTypeDefMap.containsKey(name)) { + throw new IllegalArgumentException("Interface [${name}] to be extended already exists"); + } + + InterfaceTypeDefinition interfaceTypeDef = new InterfaceTypeDefinition(objectTypeDef, extendObjectDef, + delegator); + allTypeDefMap.put(interfaceTypeDef.name, interfaceTypeDef); + interfaceTypeDefMap.put(interfaceTypeDef.name, interfaceTypeDef); + + objectTypeDef.extend(extendObjectDef, allTypeDefMap); + // Interface need the object to do resolve + requiredTypeDefMap.put(objectTypeDef.name, objectTypeDef); + } + + // Extend object + for (Map.Entry entry : extendObjectDefMap.entrySet()) { + ExtendObjectDefinition extendObjectDef = (ExtendObjectDefinition) entry.getValue(); + if (extendObjectDef.convertToInterface) { + continue; + } + + String name = entry.getKey(); + + ObjectTypeDefinition objectTypeDef = (ObjectTypeDefinition) allTypeDefMap.get(name); + if (objectTypeDef == null) { + throw new IllegalArgumentException("ObjectTypeDefinition [" + name + "] not found to extend"); + } + + if (name.equals("Product")) { + System.out.println("Categories field def parent: " + extendObjectDef.fieldDefMap.get("categories").parent); + System.out.println("from objectTypeDef " + objectTypeDef.fieldDefMap.get("categories")); + } + + objectTypeDef.extend(extendObjectDef, allTypeDefMap); + } + + } + + private static ExtendObjectDefinition mergeExtendObjectDef(Map extendObjectDefMap, + ExtendObjectDefinition extendObjectDef) { + ExtendObjectDefinition eoDef = extendObjectDefMap.get(extendObjectDef.name); + if (eoDef == null) { + return extendObjectDef; + } + return eoDef.merge(extendObjectDef); + } + + static FieldDefinition getCachedFieldDefinition(String name, String rawTypeName, String nonNull, String isList, + String listItemNonNull) { + return fieldDefMap.get(getFieldKey(name, rawTypeName, nonNull, isList, listItemNonNull)); + } + + protected static String getFieldKey(String name, String rawTypeName, String nonNull, String isList, + String listItemNonNull) { + String fieldKey = name + KEY_SPLITTER + rawTypeName; + if ("true".equals(nonNull)) { + fieldKey = fieldKey + NON_NULL_SUFFIX; + } + if ("true".equals(isList)) { + fieldKey = fieldKey + IS_LIST_SUFFIX; + if ("true".equals(listItemNonNull)) { + fieldKey = fieldKey + LIST_ITEM_NON_NULL_SUFFIX; + } + } + return fieldKey; + } + + private void createRootObjectTypeDef(String rootObjectTypeName, Map rootFieldMap) { + Map fieldDefMap = new LinkedHashMap<>(); + for (Map.Entry entry : rootFieldMap.entrySet()) { + String fieldName = entry.getKey(); + String fieldTypeName = entry.getValue(); + // Map fieldPropertyMap = [nonNull: "true"] + Map fieldPropertyMap = new HashMap<>(); + fieldPropertyMap.put("nonNull", "true"); + FieldDefinition fieldDef = getCachedFieldDefinition(fieldName, fieldTypeName, fieldPropertyMap.get("nonNull"), "false", "false"); + if (fieldDef == null) { + fieldDef = new FieldDefinition(rootObjectTypeName, delegator, dispatcher, fieldName, fieldTypeName, fieldPropertyMap); + fieldDef.setDataFetcher(new EmptyDataFetcher(fieldDef)); + putCachedFieldDefinition(fieldDef); + } + fieldDefMap.put(fieldName, fieldDef); + } + + if (fieldDefMap.size() == 0) { + Map fieldPropertyMap = new HashMap<>(); + fieldPropertyMap.put("nonNull", "false"); + FieldDefinition fieldDef = new FieldDefinition(rootObjectTypeName, delegator, dispatcher, "empty", "String", fieldPropertyMap); + fieldDefMap.put("empty", fieldDef); + } + ObjectTypeDefinition objectTypeDef = + new ObjectTypeDefinition(delegator, dispatcher, rootObjectTypeName, "", new ArrayList(), fieldDefMap); + allTypeDefMap.put(rootObjectTypeName, objectTypeDef); + } + + protected static void putCachedFieldDefinition(FieldDefinition fieldDef) { + String fieldKey = getFieldKey(fieldDef.name, fieldDef.type, fieldDef.nonNull, fieldDef.isList, fieldDef.listItemNonNull); + if (fieldDefMap.get(fieldKey) != null) { + throw new IllegalArgumentException("FieldDefinition [${fieldDef.name} - ${fieldDef.type}] already exists in cache"); + } + fieldDefMap.put(fieldKey, fieldDef); + } + + public GraphQLSchemaDefinition() { + + } + + static class InterfaceTypeDefinition extends GraphQLTypeDefinition { + Delegator delegator; + LocalDispatcher dispatcher; + String convertFromObjectTypeName; + String typeResolver; + Map fieldDefMap = new LinkedHashMap<>(); + String resolverField; + Map resolverMap = new LinkedHashMap<>(); + String defaultResolvedTypeName; + + InterfaceTypeDefinition(Element node, Delegator delegator, LocalDispatcher dispatcher) { + this.delegator = delegator; + this.dispatcher = dispatcher; + this.name = node.getAttribute("name"); + this.type = "interface"; + this.typeResolver = node.getAttribute("type-resolver"); + List elements = UtilXml.childElementList(node); + for (Element childNode : elements) { + switch (childNode.getNodeName()) { + case "description": + this.description = childNode.getTextContent(); + break; + case "field": + fieldDefMap.put(childNode.getAttribute("name"), new FieldDefinition(this.name, delegator, dispatcher, childNode)); + break; + } + } + } + + InterfaceTypeDefinition(ObjectTypeDefinition objectTypeDef, ExtendObjectDefinition extendObjectDef, Delegator delegator) { + this.convertFromObjectTypeName = objectTypeDef.name; + this.delegator = delegator; + this.name = objectTypeDef.name + "Interface"; + this.type = "interface"; + this.defaultResolvedTypeName = objectTypeDef.name; + this.resolverField = extendObjectDef.resolverField; + this.resolverMap.putAll(extendObjectDef.resolverMap); + + fieldDefMap.putAll(objectTypeDef.fieldDefMap); + + for (Element extendObjectNode : extendObjectDef.extendObjectNodeList) { + List elements = UtilXml.childElementList(extendObjectNode, "field"); + for (Element fieldNode : elements) { + GraphQLSchemaUtil.mergeFieldDefinition(fieldNode, fieldDefMap, delegator, dispatcher); + } + } + + for (String excludeFieldName : extendObjectDef.excludeFields) { + fieldDefMap.remove(excludeFieldName); + } + + // Make object type that interface convert from extends interface automatically. + objectTypeDef.interfaceList.add(name); + resolverMap.put(objectTypeDef.name.toUpperCase(), objectTypeDef.name); // Hack to avoid error if the resolved type is + // the one interface was extended from + } + + public void addResolver(String resolverValue, String resolverType) { + resolverMap.put(resolverValue, resolverType); + } + + public List getFieldList() { + List fieldList = new LinkedList<>(); + for (Map.Entry entry : fieldDefMap.entrySet()) { + fieldList.add(entry.getValue()); + } + + return fieldList; + } + + @Override + List getDependentTypes() { + List typeList = new LinkedList<>(); + for (Map.Entry entry : fieldDefMap.entrySet()) { + typeList.add(((FieldDefinition) entry.getValue()).type); + } + return typeList; + } + } + + static abstract class GraphQLTypeDefinition { + String name, description, type; + + abstract List getDependentTypes(); + } + + static class ObjectTypeDefinition extends GraphQLTypeDefinition { + Map fieldDefMap = new LinkedHashMap<>(); + private Delegator delegator; + private LocalDispatcher dispatcher; + List interfaceList = new LinkedList<>(); + Map interfacesMap; + + ObjectTypeDefinition(Element element, Delegator delegator, LocalDispatcher dispatcher) { + this.delegator = delegator; + this.dispatcher = dispatcher; + this.name = element.getAttribute("name"); + this.type = "object"; + List objectElements = UtilXml.childElementList(element); + for (Element childNode : objectElements) { + switch (childNode.getNodeName()) { + case "description": + this.description = childNode.getTextContent(); + break; + case "interface": + interfaceList.add(childNode.getAttribute("name")); + break; + case "field": + fieldDefMap.put(childNode.getAttribute("name"), + new FieldDefinition(this.name, delegator, dispatcher, childNode)); + break; + } + } + } + + ObjectTypeDefinition(Delegator delegator, LocalDispatcher dispatcher, String name, String description, List interfaceList, + Map fieldDefMap) { + this.name = name; + this.description = description; + this.type = "object"; + this.fieldDefMap.putAll(fieldDefMap); + this.interfaceList.addAll(interfaceList); + this.delegator = delegator; + this.dispatcher = dispatcher; + } + + List getFieldList() { + List fieldList = new LinkedList<>(); + for (Map.Entry entry : fieldDefMap.entrySet()) { + fieldList.add((FieldDefinition) entry.getValue()); + } + return fieldList; + } + + @Override + List getDependentTypes() { + List typeList = new LinkedList<>(); + for (String interfaceTypeName : interfaceList) { + typeList.add(interfaceTypeName); + } + for (Map.Entry entry : fieldDefMap.entrySet()) { + typeList.add(((FieldDefinition) entry.getValue()).type); + } + + return typeList; + } + + void extend(ExtendObjectDefinition extendObjectDef, Map allTypeDefMap) { + for (Element extendObjectNode : extendObjectDef.extendObjectNodeList) { + List objectElements = UtilXml.childElementList(extendObjectNode, "interface"); + for (Element childNode : objectElements) { + String interfaceDef = childNode.getAttribute("name"); + GraphQLTypeDefinition interfaceTypeDef = allTypeDefMap.get(interfaceDef); + if (interfaceTypeDef == null) { + throw new IllegalArgumentException( + "Extend object " + extendObjectDef.name + ", but interface definition [" + interfaceDef + "] not found"); + } + if (!(interfaceTypeDef instanceof InterfaceTypeDefinition)) { + throw new IllegalArgumentException( + "Extend object ${extendObjectDef.name}, but interface definition [${childNode.attribute('name')}] is not instance of InterfaceTypeDefinition"); + } + extendInterface((InterfaceTypeDefinition) interfaceTypeDef, childNode); + } + } + for (Element extendObjectNode : extendObjectDef.extendObjectNodeList) { + System.out.println("extendObjectNode " + extendObjectNode.getNodeName()); + List objectElements = UtilXml.childElementList(extendObjectNode, "field"); + for (Element childNode : objectElements) { + System.out.println("childNode name " + childNode.getAttribute("name")); + GraphQLSchemaUtil.mergeFieldDefinition(childNode, fieldDefMap, delegator, dispatcher); + } + } + for (String excludeFieldName : extendObjectDef.excludeFields) { + fieldDefMap.remove(excludeFieldName); + } + } + + private void extendInterface(InterfaceTypeDefinition interfaceTypeDefinition, Element interfaceNode) { + for (Map.Entry entry : interfaceTypeDefinition.fieldDefMap.entrySet()) { + // Already use interface field. + fieldDefMap.put(entry.getKey(), entry.getValue()); + } + interfaceTypeDefinition.addResolver(interfaceNode.getAttribute("resolver-value"), name); + if (!interfaceList.contains(interfaceTypeDefinition.name)) { + interfaceList.add(interfaceTypeDefinition.name); + } + } + + } + + static String getArgumentTypeName(String type, String fieldIsList) { + if (!"true".equals(fieldIsList)) { + return type; + } + if (GraphQLSchemaUtil.graphQLStringTypes.contains(type) || GraphQLSchemaUtil.graphQLNumericTypes.contains(type) || + GraphQLSchemaUtil.graphQLDateTypes.contains(type)) { + return operationInputType.getName(); + } + if (GraphQLSchemaUtil.graphQLDateTypes.contains(type)) { + return dateRangeInputType.getName(); + } + + return type; + } + + static String getArgumentKey(String name, String type) { + return getArgumentKey(name, type, null); + } + + static String getArgumentKey(String name, String type, String required) { + String argumentKey = name + KEY_SPLITTER + type; + if ("true".equals(required)) argumentKey = argumentKey + REQUIRED_SUFFIX; + return argumentKey; + } + + static void putCachedArgumentDefinition(ArgumentDefinition argDef) { + if (!(GraphQLSchemaUtil.graphQLScalarTypes.containsKey(argDef.getType()) || dateRangeInputType.getName().equals(argDef.getType()) || + operationInputType.getName().equals(argDef.getType()))) { + return; + } + + String argumentKey = getArgumentKey(argDef.name, argDef.getType(), argDef.getRequired()); + if (argumentDefMap.get(argumentKey) != null) { + throw new IllegalArgumentException("ArgumentDefinition [" + argDef.name + " - " + argDef.getType() + "] already exists in cache"); + } + argumentDefMap.put(argumentKey, argDef); + } + + public static class FieldDefinition implements Cloneable { + +// public String toString() { +// return "FieldDefinition{name=" + this.name + ", parent=" + this.parent + ", type=" + this.type + ", nonNull=" + this.nonNull +// + ", isList=" + this.isList + ", " + "listItemNonNull=" + this.listItemNonNull + ", " +// + "isMutation=" + this.isMutation + ", argumentDefMap=" + this.argumentDefMap + "}"; +// } + + String name, type, description, depreciationReason, parent; + String nonNull, isList, listItemNonNull; + BaseDataFetcher dataFetcher; + Delegator delegator; + LocalDispatcher dispatcher; + String requireAuthentication; + + public String getRequireAuthentication() { + return requireAuthentication; + } + + public String getType() { + return type; + } + + public void setDataFetcher(BaseDataFetcher dataFetcher) { + this.dataFetcher = dataFetcher; + } + + public String getNonNull() { + return nonNull; + } + + public String getIsList() { + return isList; + } + + boolean isMutation = false; + + public boolean isMutation() { + return isMutation; + } + + String preDataFetcher, postDataFetcher; + Map argumentDefMap = new LinkedHashMap<>(); + + FieldDefinition(String parent, Delegator delegator, LocalDispatcher dispatcher, String name, String type) { + this(parent, delegator, dispatcher, name, type, new HashMap<>(), null, new ArrayList<>()); + } + + FieldDefinition(String parent, Delegator delegator, LocalDispatcher dispatcher, String name, String type, + Map fieldPropertyMap) { + this(parent, delegator, dispatcher, name, type, fieldPropertyMap, null, new ArrayList<>()); + } + + // This constructor used by auto creation of master-detail field + FieldDefinition(String parent, Delegator delegator, LocalDispatcher dispatcher, String name, String type, + Map fieldPropertyMap, List excludedFields) { + this(parent, delegator, dispatcher, name, type, fieldPropertyMap, null, excludedFields); + } + + FieldDefinition(String parent, Delegator delegator, LocalDispatcher dispatcher, String name, String type, + Map fieldPropertyMap, BaseDataFetcher dataFetcher, List excludedArguments) { + this.parent = parent; + this.delegator = delegator; + this.name = name; + this.type = type; + this.dataFetcher = dataFetcher; + this.nonNull = fieldPropertyMap.get("nonNull") != null ? fieldPropertyMap.get("nonNull") : "false"; + this.isList = fieldPropertyMap.get("isList") != null ? fieldPropertyMap.get("isList") : "false"; + this.listItemNonNull = fieldPropertyMap.get("listItemNonNull") != null ? fieldPropertyMap.get("listItemNonNull") : "false"; + this.description = fieldPropertyMap.get("description"); + addEntityAutoArguments(excludedArguments, new HashMap()); + //updateArgumentDefs(); + addPeriodValidArguments(); + } + + FieldDefinition(String parent, Delegator delegator, LocalDispatcher dispatcher, Element node) { + this.parent = parent; + this.delegator = delegator; + this.dispatcher = dispatcher; + this.name = node.getAttribute("name"); + this.type = node.getAttribute("type"); + this.description = node.getAttribute("description"); + this.nonNull = node.getAttribute("non-null") != null ? node.getAttribute("non-null") : "false"; + this.isList = node.getAttribute("is-list") != null ? node.getAttribute("is-list") : "false"; + this.listItemNonNull = node.getAttribute("list-item-non-null") != null ? node.getAttribute("list-item-non-null") : "false"; + this.isMutation = "mutation".equals(node.getAttribute("for")); + + String dataFetcherType = ""; + Element dataFetcherNode = null; + List objectElements = UtilXml.childElementList(node); + for (Element childNode : objectElements) { + switch (childNode.getNodeName()) { + case "description": + this.description = childNode.getTextContent(); + break; + case "argument": + String argTypeName = getArgumentTypeName(childNode.getAttribute("type"), this.isList); + ArgumentDefinition argDef = + getCachedArgumentDefinition(childNode.getAttribute("name"), argTypeName, childNode.getAttribute("required")); + if (argDef == null) { + argDef = new ArgumentDefinition(childNode, this); + putCachedArgumentDefinition(argDef); + } + mergeArgument(argDef); + break; + case "service-fetcher": + dataFetcherType = "service"; + dataFetcherNode = childNode; + this.dataFetcher = new ServiceDataFetcher(childNode, this, delegator, dispatcher); + break; + case "entity-fetcher": + dataFetcherType = "entity"; + dataFetcherNode = childNode; + this.dataFetcher = new EntityDataFetcher(delegator, childNode, this); + break; + case "empty-fetcher": + dataFetcherType = "empty"; + dataFetcherNode = childNode; + this.dataFetcher = new EmptyDataFetcher(childNode, this); + break; + } + } + + Map keyMap = getDataFetcherKeyMap(dataFetcherNode, delegator); + switch (dataFetcherType) { + case "entity": + case "interface": + addEntityAutoArguments(new ArrayList(), keyMap); + addPeriodValidArguments(); + //updateArgumentDefs(); TODO + break; + case "service": + if (isMutation) { + addInputArgument(); + } else { + addQueryAutoArguments(dataFetcherNode, keyMap, dispatcher); + } + break; + } + + //System.out.println("this.name "+this.name+", THIS: "+this); + } + + private void addPeriodValidArguments() { + if (!"true".equals(isList)) { + return; + } + + List allArguments = new ArrayList(argumentDefMap.keySet()); + List fromDateArguments = allArguments.stream().filter((argument) -> argument.equals("fromDate") || argument.endsWith("FromDate")) + .collect(Collectors.toList()); + List pairedFromDateArguments = fromDateArguments.stream() + .filter((argument) -> (argument.equals("fromDate") && allArguments.contains("thruDate")) || + allArguments.contains(argument.replace("FromDate", "ThruDate"))).collect(Collectors.toList()); + for (String argument : pairedFromDateArguments) { + String periodValidArgName = argument == "fromDate" ? "periodValid_" : argument.replace("FromDate", "PeriodValid_"); + ArgumentDefinition argumentDef = getCachedArgumentDefinition(periodValidArgName, "Boolean", null); + if (argumentDef == null) { + argumentDef = new ArgumentDefinition(this, periodValidArgName, "Boolean", null, null, ""); + putCachedArgumentDefinition(argumentDef); + } + argumentDefMap.put(periodValidArgName, argumentDef); + } + } + + void mergeArgument(ArgumentDefinition argumentDef) { + mergeArgument(argumentDef.name, argumentDef.attributeMap); + } + + ArgumentDefinition mergeArgument(final String argumentName, Map attributeMap) { + ArgumentDefinition baseArgumentDef = argumentDefMap.get(argumentName); + if (baseArgumentDef == null) { + baseArgumentDef = getCachedArgumentDefinition(argumentName, attributeMap.get("type"), attributeMap.get("required")); + if (baseArgumentDef == null) { + baseArgumentDef = new ArgumentDefinition(this, argumentName, attributeMap); + putCachedArgumentDefinition(baseArgumentDef); + } + argumentDefMap.put(argumentName, baseArgumentDef); + } else { + baseArgumentDef.attributeMap.putAll(attributeMap); + } + return baseArgumentDef; + } + + private static Map getDataFetcherKeyMap(Element fetcherNode, Delegator delegator) { + Map keyMap = new HashMap<>(1); + if (fetcherNode == null) { + return keyMap; + } + + List elements = UtilXml.childElementList(fetcherNode, "key-map"); + if (fetcherNode.getNodeName().equals("entity-fetcher")) { + String entityName = fetcherNode.getAttribute("entity-name"); + ModelEntity entity = delegator.getModelEntity(entityName); + for (Element keyMapNode : elements) { + String fieldName = keyMapNode.getAttribute("field-name"); + String relFn = keyMapNode.getAttribute("related"); + if (relFn == null) { + if (entity.isField(fieldName)) { + relFn = fieldName; + } else { + if (entity.getPkFieldNames().size() == 1) { + relFn = entity.getPkFieldNames().get(0); + } + } + } + if (relFn == null) { + throw new IllegalArgumentException("The key-map.@related of Entity ${entityName} should be specified"); + } + keyMap.put(fieldName, relFn); + } + } else { + for (Element keyMapNode : elements) { + keyMap.put(keyMapNode.getAttribute("field-name"), + keyMapNode.getAttribute("related") != null ? keyMapNode.getAttribute("related") : keyMapNode.getAttribute("field-name")); + } + } + return keyMap; + } + + private void addQueryAutoArguments(Element serviceFetcherNode, Map keyMap, + LocalDispatcher dispatcher) { + if (isMutation) { + return; + } + String serviceName = serviceFetcherNode.getAttribute("service"); + + try { + ModelService service = dispatcher.getDispatchContext().getModelService(serviceName); + if (service == null) { + throw new IllegalArgumentException("Service [" + serviceName + "] for field [" + name + "] not found"); + } + + for (ModelParam modelParam : service.getInModelParamList()) { + + String paramName = modelParam.getName(); + String paramType = modelParam.getType(); + boolean optional = modelParam.isOptional(); + if (modelParam.isInternal()) { + continue; + } + if (keyMap.values().contains(paramName)) { + continue; + } + if (paramType.equals("graphql.schema.DataFetchingEnvironment")) { + continue; // ignored + } + // TODO: get description from parameter description node + String paramDescription = ""; + boolean argIsList = false; + String argType; + switch (paramType) { + case "org.apache.ofbiz.graphql.schema.OperationInputType": + argType = "OperationInputType"; + break; + case "org.apache.ofbiz.graphql.schema.DateRangeInputType": + argType = "DateRangeInputType"; + break; + case "org.apache.ofbiz.graphql.schema.PaginationInputType": + argType = "PaginationInputType"; + break; + case "List": + argIsList = true; + argType = GraphQLSchemaUtil.camelCaseToUpperCamel(this.name) + "_" + paramName; + break; + case "Map": + argType = GraphQLSchemaUtil.camelCaseToUpperCamel(this.name) + "_" + paramName; + break; + default: + argType = GraphQLSchemaUtil.javaTypeGraphQLMap.get(paramType); + break; + } + if (argType == null) { + throw new IllegalArgumentException( + "Parameter [" + paramName + "] and paramType [" + paramType + "] can't be mapped"); + } + + ArgumentDefinition argumentDef = getCachedArgumentDefinition(paramName, argType, + Boolean.toString(!optional)); + if (argumentDef == null) { + argumentDef = new ArgumentDefinition(this, paramName, argType, Boolean.toString(!optional), + argIsList, null, paramDescription); + putCachedArgumentDefinition(argumentDef); + } + argumentDefMap.put(paramName, argumentDef); + } + } catch (GenericServiceException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void addEntityAutoArguments(List excludedFields, Map explicitKeyMap) { + if (isMutation) return; + if (GraphQLSchemaUtil.graphQLScalarTypes.keySet().contains(type) || graphQLDirectiveArgumentMap.keySet().contains(type)) return; + + ModelEntity entity = GraphQLSchemaUtil.getEntityDefinition(type, delegator); + + if (UtilValidate.isEmpty(entity)) { + return; + } + List fieldNames = new ArrayList<>(); + if ("true".equals(isList)) { + fieldNames.addAll(entity.getAllFieldNames()); + } else { + fieldNames.addAll(entity.getPkFieldNames()); + } + + fieldNames.removeAll(explicitKeyMap.values()); + + for (String fieldName : fieldNames) { + if (excludedFields.contains(fieldName)) continue; + ModelField fi = entity.getField(fieldName); + String fieldDescription = fi.getDescription(); + // Add fields in entity as argument + String argType = getArgumentTypeName(GraphQLSchemaUtil.fieldTypeGraphQLMap.get(fi.getType()), isList); + + ArgumentDefinition argumentDef = getCachedArgumentDefinition(fi.getName(), argType, null); + if (argumentDef == null) { + argumentDef = new ArgumentDefinition(this, fi.getName(), argType, null, null, fieldDescription); + putCachedArgumentDefinition(argumentDef); + } + argumentDefMap.put(fi.getName(), argumentDef); + } + } + + List getArgumentList() { + List argumentList = new LinkedList<>(); + for (Map.Entry entry : argumentDefMap.entrySet()) { + argumentList.add(entry.getValue()); + } + return argumentList; + } + + private void addInputArgument() { + if (!isMutation) { + return; + } + + String inputTypeName = GraphQLSchemaUtil.camelCaseToUpperCamel(this.name) + "Input"; + ArgumentDefinition inputArgDef = new ArgumentDefinition(this, "input", inputTypeName, "true", null, ""); + argumentDefMap.put("input", inputArgDef); + } + } + + static ArgumentDefinition getCachedArgumentDefinition(String name, String type, String required) { + return argumentDefMap.get(getArgumentKey(name, type, required)); + } + + static class AutoArgumentsDefinition { + String entityName, include, required; + List excludes = new LinkedList<>(); + + AutoArgumentsDefinition(Element node) { + this.entityName = node.getAttribute("entity-name"); + this.include = node.getAttribute("include") != null ? node.getAttribute("include") : "all"; + this.required = node.getAttribute("required") != null ? node.getAttribute("required") : "false"; + List elements = UtilXml.childElementList(node, "exclude"); + for (Element childNode : elements) { + excludes.add(childNode.getAttribute("field-name")); + } + } + } + + static class ArgumentDefinition implements Cloneable { + String name; + boolean isList = false; + Map attributeMap = new LinkedHashMap<>(); + ; + + ArgumentDefinition(Element ele, FieldDefinition fieldDef) { + this.name = ele.getAttribute("name"); + if (ele.getAttribute("type") == "List") { + this.isList = true; + } + attributeMap.put("type", ele.getAttribute("type")); + attributeMap.put("required", ele.getAttribute("required") != null ? ele.getAttribute("required") : "false"); + attributeMap.put("defaultValue", ele.getAttribute("default-value")); + List elements = UtilXml.childElementList(ele); + for (Element childNode : elements) { + if ("description".equals(childNode.getNodeName())) { + attributeMap.put("description", childNode.getAttribute("description")); + } + } + } + + ArgumentDefinition(FieldDefinition fieldDef, String name, Map attributeMap) { + this.name = name; + this.attributeMap.putAll(attributeMap); + } + + ArgumentDefinition(FieldDefinition fieldDef, String name, String type, String required, String defaultValue, + String description) { + this(fieldDef, name, type, required, false, defaultValue, description); + } + + ArgumentDefinition(FieldDefinition fieldDef, String name, String type, String required, boolean isList, + String defaultValue, String description) { + this.name = name; + this.isList = isList; + attributeMap.put("type", type); + attributeMap.put("required", required); + attributeMap.put("defaultValue", defaultValue); + attributeMap.put("description", description); + } + + String getName() { + return name; + } + + String getType() { + return attributeMap.get("type"); + } + + String getRequired() { + return attributeMap.get("required"); + } + + String getDefaultValue() { + return attributeMap.get("defaultValue"); + } + + String getDescription() { + return attributeMap.get("description"); + } + + @Override + protected Object clone() throws CloneNotSupportedException { + // TODO Auto-generated method stub + return super.clone(); + } + + } + + static class InputObjectFieldDefinition { + String name, type, description; + boolean nonNull; + + public boolean isNonNull() { + return nonNull; + } + + public boolean isList() { + return list; + } + + public boolean isListItemNonNull() { + return listItemNonNull; + } + + boolean list; + boolean listItemNonNull; + Object defaultValue; + + InputObjectFieldDefinition(String name, String type, Object defaultValue, String description) { + this.name = name; + this.type = type; + this.defaultValue = defaultValue; + this.nonNull = false; + this.list = false; + this.listItemNonNull = false; + this.description = description; + } + + InputObjectFieldDefinition(String name, String type, Object defaultValue, String description, boolean nonNull, + boolean list, boolean listItemNonNull) { + this.name = name; + this.type = type; + this.defaultValue = defaultValue; + this.nonNull = nonNull; + this.list = list; + this.listItemNonNull = listItemNonNull; + this.description = description; + } + } + + /** + * Creates a new GraphQLSchema using SDL + * + * @return + */ + public GraphQLSchema newSDLSchema() { + SchemaParser schemaParser = new SchemaParser(); + SchemaGenerator schemaGenerator = new SchemaGenerator(); + Reader cdpSchemaReader = getSchemaReader("component://graphql/graphql-schema/schema.graphqls"); + TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry(); + typeRegistry.merge(schemaParser.parse(cdpSchemaReader)); + RuntimeWiring runtimeWiring = buildRuntimeWiring(); + GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeRegistry, runtimeWiring); + return graphQLSchema; + } + + /** + * Creates a new GraphQLSchema dynamically + * + * @return + */ + public GraphQLSchema newDynamicSchema() { + GraphQLObjectType productType = newObject().name("Product") + .field(newFieldDefinition().name("productId").type(GraphQLString)) + .field(newFieldDefinition().name("productId").type(GraphQLString)) + .field(newFieldDefinition().name("productName").type(GraphQLString)) + .field(newFieldDefinition().name("description").type(GraphQLString)) + .field(newFieldDefinition().name("productTypeId").type(GraphQLString)) + .field(newFieldDefinition().name("primaryProductCategoryId").type(GraphQLString)) + .field(newFieldDefinition().name("isVirtual").type(GraphQLString)).build(); + GraphQLObjectType queryType = newObject().name("QueryRootObjectType").field(newFieldDefinition().name("product") + .type(productType).argument(GraphQLArgument.newArgument().name("id").type(GraphQLString))).build(); + GraphQLCodeRegistry codeRegistry = GraphQLCodeRegistry.newCodeRegistry() + .dataFetcher(FieldCoordinates.coordinates("Query", "product"), + new StaticDataFetcher("Test Static Response")) + .typeResolver("PartyInterface", new TypeResolver() { + + @Override + public GraphQLObjectType getType(TypeResolutionEnvironment env) { + Object object = env.getObject(); + System.out.println("object " + object); + return null; + } + }).build(); + GraphQLSchema schema = GraphQLSchema.newSchema().query(queryType).codeRegistry(codeRegistry).build(); + return schema; + + } + + private static Reader getSchemaReader(String resourceUrl) { + File schemaFile = FileUtil.getFile(resourceUrl); + try { + return new InputStreamReader(new FileInputStream(schemaFile), StandardCharsets.UTF_8.name()); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + /** + * Builds Runtime Wiring for the schema types defined + * + * @return + */ + private RuntimeWiring buildRuntimeWiring() { + RuntimeWiring.Builder build = RuntimeWiring.newRuntimeWiring(); + build.type(newTypeWiring("Query").dataFetcher("product", new EntityDataFetcher())); + return build.build(); + } + + private void addSchemaInputTypes() { + for (Map.Entry entry : GraphQLSchemaUtil.graphQLScalarTypes.entrySet()) { + schemaInputTypeMap.put(entry.getKey(), entry.getValue()); + } + + schemaInputTypeMap.put(paginationInputType.getName(), paginationInputType); + schemaInputTypeMap.put(operationInputType.getName(), operationInputType); + schemaInputTypeMap.put(dateRangeInputType.getName(), dateRangeInputType); + + // Add explicitly defined input types from *.graphql.xml + for (String inputTypeName : schemaInputTypeNameList) { + GraphQLInputType type = graphQLInputTypeMap.get(inputTypeName); + if (type == null) { + throw new IllegalArgumentException("GraphQLInputType [" + inputTypeName + "] for schema not found"); + } + schemaInputTypeMap.put(inputTypeName, type); + } + + addSchemaInputObjectTypes(); + } + + private GraphQLTypeDefinition getTypeDef(String name) { + return allTypeDefMap.get(name); + } + + private void populateSortedTypes() { + allTypeDefSortedList.clear(); + GraphQLTypeDefinition queryTypeDef = getTypeDef(queryRootObjectTypeName); + GraphQLTypeDefinition mutationTypeDef = getTypeDef(mutationRootObjectTypeName); + + TreeNode rootNode = new TreeNode<>(null); + TreeNode interfaceNode = new TreeNode<>(null); + + for (Map.Entry entry : interfaceTypeDefMap.entrySet()) { + interfaceNode.children.add(new TreeNode((InterfaceTypeDefinition) entry.getValue())); + } + + TreeNode queryTypeNode = new TreeNode(queryTypeDef); + rootNode.children.add(queryTypeNode); + + List objectTypeNames = new ArrayList<>( + Arrays.asList(queryRootObjectTypeName, mutationRootObjectTypeName)); + createTreeNodeRecursive(interfaceNode, objectTypeNames, true); + traverseByPostOrder(interfaceNode, allTypeDefSortedList); + + createTreeNodeRecursive(queryTypeNode, objectTypeNames, false); + traverseByPostOrder(queryTypeNode, allTypeDefSortedList); + + if (mutationTypeDef != null) { + TreeNode mutationTypeNode = new TreeNode(mutationTypeDef); + rootNode.children.add(mutationTypeNode); + createTreeNodeRecursive(mutationTypeNode, objectTypeNames, false); + traverseByPostOrder(mutationTypeNode, allTypeDefSortedList); + } + + for (Map.Entry entry : requiredTypeDefMap.entrySet()) { + if (allTypeDefSortedList.contains(entry.getValue())) { + continue; + } + allTypeDefSortedList.add((GraphQLTypeDefinition) entry.getValue()); + } + } + + private void createTreeNodeRecursive(TreeNode node, List objectTypeNames, + boolean includeInterface) { + if (node.data != null) { + for (String type : node.data.getDependentTypes()) { + // If type is GraphQL Scalar types, skip. + if (GraphQLSchemaUtil.graphQLScalarTypes.containsKey(type)) { + continue; + } + // If type is GraphQLObjectType which already added in Tree, skip. + if (objectTypeNames.contains(type)) { + continue; + } + if (!includeInterface && "interface".equals(type)) { + continue; + } + + GraphQLTypeDefinition typeDef = getTypeDef(type); + if (typeDef != null) { + TreeNode typeTreeNode = new TreeNode<>(typeDef); + node.children.add(typeTreeNode); + objectTypeNames.add(type); + createTreeNodeRecursive(typeTreeNode, objectTypeNames, includeInterface); + } else { + System.err.println("No GraphQL Type " + type + " defined"); + } + } + } else { + for (TreeNode childTreeNode : node.children) { + createTreeNodeRecursive(childTreeNode, objectTypeNames, includeInterface); + } + } + } + + public GraphQLSchema generateSchema() { + addSchemaInputTypes(); + populateSortedTypes(); + + for (GraphQLTypeDefinition typeDef : allTypeDefSortedList) { + switch (typeDef.type) { + case "interface": + addGraphQLInterfaceType((InterfaceTypeDefinition) typeDef); + break; + } + } + for (GraphQLTypeDefinition typeDef : allTypeDefSortedList) { + switch (typeDef.type) { + case "object": + addGraphQLObjectType((ObjectTypeDefinition) typeDef); + break; + } + } + rebuildQueryObjectType(); + GraphQLObjectType schemaQueryType = graphQLObjectTypeMap.get(this.queryRootObjectTypeName); + GraphQLSchema.Builder schemaBuilder = GraphQLSchema.newSchema().query(schemaQueryType); + + if (mutationRootFieldMap.size() > 0) { + GraphQLObjectType schemaMutationType = graphQLObjectTypeMap.get(this.mutationRootObjectTypeName); + schemaBuilder = schemaBuilder.mutation(schemaMutationType); + } + + schemaBuilder.codeRegistry(codeRegistryBuilder.build()); + + return schemaBuilder.build(); + } + + private static void addGraphQLInterfaceType(InterfaceTypeDefinition interfaceTypeDef) { + String interfaceTypeName = interfaceTypeDef.name; + GraphQLInterfaceType interfaceType = graphQLInterfaceTypeMap.get(interfaceTypeName); + if (interfaceType != null) { + return; + } + + interfaceResolverTypeSet.addAll(interfaceTypeDef.resolverMap.values()); + + GraphQLInterfaceType.Builder interfaceTypeBuilder = + GraphQLInterfaceType.newInterface().name(interfaceTypeName).description(interfaceTypeDef.description); + + for (FieldDefinition fieldDef : interfaceTypeDef.getFieldList()) { + interfaceTypeBuilder.field(buildSchemaField(fieldDef)); + } + + // TODO: Add typeResolver for type, one way is to add a service as resolver + if (!interfaceTypeDef.convertFromObjectTypeName.isEmpty()) { + if (interfaceTypeDef.resolverField == null || interfaceTypeDef.resolverField.isEmpty()) { + throw new IllegalArgumentException("Interface definition of ${interfaceTypeName} resolverField not set"); + } + + codeRegistryBuilder.typeResolver(interfaceTypeName, (env) -> { + Object object = env.getObject(); + String resolverFieldValue = (String) ((Map) object).get(interfaceTypeDef.resolverField); + String resolvedTypeName = interfaceTypeDef.resolverMap.get(resolverFieldValue); + GraphQLObjectType resolvedType = graphQLObjectTypeMap.get(resolvedTypeName); + if (resolvedType == null) resolvedType = graphQLObjectTypeMap.get(interfaceTypeDef.defaultResolvedTypeName); + return resolvedType; + }); + } + + interfaceType = interfaceTypeBuilder.build(); + graphQLInterfaceTypeMap.put(interfaceTypeName, interfaceType); + graphQLOutputTypeMap.put(interfaceTypeName, interfaceType); + } + + private void traverseByPostOrder(TreeNode startNode, + LinkedList sortedList) { + if (startNode == null) { + return; + } + + for (TreeNode childNode : startNode.children) { + traverseByPostOrder(childNode, sortedList); + } + + if (startNode.data == null) { + return; + } + + if (!sortedList.contains(startNode.data)) { + sortedList.add(startNode.data); + } + } + + private void rebuildQueryObjectType() { + ObjectTypeDefinition queryObjectTypeDef = (ObjectTypeDefinition) allTypeDefMap.get(queryRootObjectTypeName); + + GraphQLObjectType.Builder queryObjectTypeBuilder = GraphQLObjectType.newObject().name(queryRootObjectTypeName) + .description(queryObjectTypeDef.description); + + for (FieldDefinition fieldDef : queryObjectTypeDef.getFieldList()) { + queryObjectTypeBuilder = queryObjectTypeBuilder.field(buildSchemaField(fieldDef)); + } + + // create a fake object type + GraphQLObjectType.Builder graphQLObjectTypeBuilder = GraphQLObjectType.newObject().name("TypeReferenceContainer") + .description("This is only for contain GraphQLTypeReference so GraphQLSchema includes all of GraphQLTypeReference."); + + boolean hasFakeField = false; + List fakeFieldNameList = new ArrayList<>(); + // fields for GraphQLTypeReference + for (Map.Entry entry : graphQLTypeReferenceMap.entrySet()) { + if (fakeFieldNameList.contains(entry.getKey())) { + continue; + } + + FieldDefinition fieldDef = new FieldDefinition("TypeReferenceContainer", delegator, dispatcher, entry.getKey(), entry.getKey()); + graphQLObjectTypeBuilder.field(buildSchemaField(fieldDef)); + fakeFieldNameList.add(entry.getKey()); + hasFakeField = true; + } + + // fields for resolver type of interface + for (String resolverType : interfaceResolverTypeSet) { + if (fakeFieldNameList.contains(resolverType)) { + continue; + } + + GraphQLTypeDefinition typeDef = getTypeDef(resolverType); + if (typeDef == null) { + throw new IllegalArgumentException("GraphQLTypeDefinition [" + resolverType + "] not found"); + } + addGraphQLObjectType((ObjectTypeDefinition) typeDef); + + FieldDefinition fieldDef = new FieldDefinition("TypeReferenceContainer", delegator, dispatcher, resolverType, resolverType); + graphQLObjectTypeBuilder.field(buildSchemaField(fieldDef)); + fakeFieldNameList.add(resolverType); + hasFakeField = true; + } + + if (hasFakeField) { + GraphQLObjectType fakeObjectType = graphQLObjectTypeBuilder.build(); + GraphQLFieldDefinition fakeField = + GraphQLFieldDefinition.newFieldDefinition().name("typeReferenceContainer").type(fakeObjectType).build(); + queryObjectTypeBuilder.field(fakeField); + } + + GraphQLObjectType queryObjectType = queryObjectTypeBuilder.build(); + graphQLObjectTypeMap.put(queryRootObjectTypeName, queryObjectType); + graphQLOutputTypeMap.put(queryRootObjectTypeName, queryObjectType); + } + + private static void addGraphQLObjectType(ObjectTypeDefinition objectTypeDef) { + String objectTypeName = objectTypeDef.name; + System.out.println("objectTypeName " + objectTypeName); + GraphQLObjectType objectType = graphQLObjectTypeMap.get(objectTypeName); + //System.out.println("objectType "+objectType); + if (objectType != null) { + return; + } + + GraphQLObjectType.Builder objectTypeBuilder = GraphQLObjectType.newObject().name(objectTypeName) + .description(objectTypeDef.description); + + for (String interfaceName : objectTypeDef.interfaceList) { + GraphQLInterfaceType interfaceType = graphQLInterfaceTypeMap.get(interfaceName); + if (interfaceType == null) { + throw new IllegalArgumentException( + "GraphQLInterfaceType [" + interfaceName + "] for GraphQLObjectType [" + objectTypeName + "] not found."); + } + + objectTypeBuilder = objectTypeBuilder.withInterface(interfaceType); + } + + for (FieldDefinition fieldDef : objectTypeDef.getFieldList()) { + objectTypeBuilder = objectTypeBuilder.field(buildSchemaField(fieldDef)); + } + + objectType = objectTypeBuilder.build(); + graphQLObjectTypeMap.put(objectTypeName, objectType); + graphQLOutputTypeMap.put(objectTypeName, objectType); + } + + private static GraphQLFieldDefinition buildSchemaField(FieldDefinition fieldDef) { + GraphQLFieldDefinition graphQLFieldDef; + if (fieldDef.getArgumentList().size() == 0 && GraphQLSchemaUtil.graphQLScalarTypes.containsKey(fieldDef.type)) { + return getGraphQLFieldWithNoArgs(fieldDef); + } + + GraphQLOutputType fieldType; + if ("true".equals(fieldDef.isList)) { + fieldType = getConnectionObjectType(fieldDef.type, fieldDef.nonNull, fieldDef.listItemNonNull); + } else { + fieldType = getGraphQLOutputType(fieldDef); + } + GraphQLFieldDefinition.Builder graphQLFieldDefBuilder = + GraphQLFieldDefinition.newFieldDefinition().name(fieldDef.name).type(fieldType).description(fieldDef.description); + + // build arguments for field + for (ArgumentDefinition argNode : fieldDef.getArgumentList()) { + graphQLFieldDefBuilder.argument(buildSchemaArgument(argNode)); + } + + // Add pagination argument + if ("true".equals(fieldDef.isList)) { + graphQLFieldDefBuilder.argument(paginationArgument); + } + // Add directive arguments + for (Map.Entry entry : graphQLDirectiveArgumentMap.entrySet()) { + graphQLFieldDefBuilder.argument(entry.getValue()); + } + + // TO-DO - Use of method is deprecated. Need to replace it with coderegistry + // implementation. + if (fieldDef.dataFetcher != null) { + //System.out.println("fieldDef.parent "+fieldDef.parent+", fieldDef.name "+fieldDef.name); + //System.out.println("fieldDef name "+fieldDef.name+", field "+fieldDef); + codeRegistryBuilder.dataFetcher(FieldCoordinates.coordinates(fieldDef.parent, fieldDef.name), fieldDef.dataFetcher); + } + graphQLFieldDef = graphQLFieldDefBuilder.build(); + return graphQLFieldDef; + } + + private static GraphQLOutputType getGraphQLOutputType(FieldDefinition fieldDef) { + return getGraphQLOutputType(fieldDef.type, fieldDef.nonNull, fieldDef.isList, fieldDef.listItemNonNull); + } + + private static GraphQLOutputType getGraphQLOutputType(String rawTypeName, String nonNull, String isList, String listItemNonNull) { + GraphQLOutputType rawType = graphQLOutputTypeMap.get(rawTypeName); + if (rawType == null) { + rawType = graphQLTypeReferenceMap.get(rawTypeName); + if (rawType == null) { + rawType = new GraphQLTypeReference(rawTypeName); + graphQLTypeReferenceMap.put(rawTypeName, (GraphQLTypeReference) rawType); + } + } + return getGraphQLOutputType(rawType, nonNull, isList, listItemNonNull); + } + + private static GraphQLOutputType getGraphQLOutputType(GraphQLOutputType rawType, String nonNull, String isList, + String listItemNonNull) { + String outputTypeKey = rawType.getName(); + if ("true".equals(nonNull)) { + outputTypeKey = outputTypeKey + NON_NULL_SUFFIX; + } + if ("true".equals(isList)) { + outputTypeKey = outputTypeKey + IS_LIST_SUFFIX; + if ("true".equals(listItemNonNull)) { + outputTypeKey = outputTypeKey + LIST_ITEM_NON_NULL_SUFFIX; + } + } + + GraphQLOutputType wrappedType = graphQLOutputTypeMap.get(outputTypeKey); + if (wrappedType != null) { + return wrappedType; + } + + wrappedType = rawType; + if ("true".equals(isList)) { + if ("true".equals(listItemNonNull)) { + wrappedType = new GraphQLNonNull(wrappedType); + } + wrappedType = new GraphQLList(wrappedType); + } + if ("true".equals(nonNull)) { + wrappedType = new GraphQLNonNull(wrappedType); + } + + if (!outputTypeKey.equals(rawType.getName())) { + graphQLOutputTypeMap.put(outputTypeKey, wrappedType); + } + + return wrappedType; + } + + private static GraphQLArgument buildSchemaArgument(ArgumentDefinition argumentDef) { + String argumentName = argumentDef.getName(); + GraphQLArgument.Builder argument = GraphQLArgument.newArgument().name(argumentName).description(argumentDef.getDescription()); + + if (UtilValidate.isNotEmpty(argumentDef.getDefaultValue())) { + argument.defaultValue(argumentDef.getDefaultValue()); + } + + GraphQLInputType argType = graphQLInputTypeMap.get(argumentDef.getType()); + if (argType == null) { + throw new IllegalArgumentException("GraphQLInputType [" + argumentDef.getType() + "] for argument [" + argumentName + "] not found"); + } + + if (argumentDef.isList) { + argType = new GraphQLList(argType); + } + + if (argumentDef.getRequired() != null && argumentDef.getRequired().equalsIgnoreCase("true")) { + argument = argument.type(new GraphQLNonNull(argType)); + } else { + argument = argument.type(argType); + } + return argument.build(); + } + + private static GraphQLFieldDefinition getGraphQLFieldWithNoArgs(FieldDefinition fieldDef) { + if (fieldDef.getArgumentList().size() > 0) { + throw new IllegalArgumentException( + "FieldDefinition [" + fieldDef.name + " ] with type [" + fieldDef.type + "] has arguments, which should not be cached"); + } + return getGraphQLFieldWithNoArgs(fieldDef.parent, fieldDef.name, fieldDef.type, fieldDef.nonNull, fieldDef.isList, + fieldDef.listItemNonNull, fieldDef.description, fieldDef.dataFetcher); + } + + private static GraphQLFieldDefinition getGraphQLFieldWithNoArgs(String parent, String name, GraphQLOutputType rawType, + String description) { + return getGraphQLFieldWithNoArgs(parent, name, rawType, "false", "false", "false", description, null); + } + + private static GraphQLFieldDefinition getGraphQLFieldWithNoArgs(String parent, String name, String rawTypeName, String nonNull, + String isList, String listItemNonNull, String description, + BaseDataFetcher dataFetcher) { + GraphQLOutputType rawType = graphQLOutputTypeMap.get(rawTypeName); + if (rawType == null) { + rawType = graphQLTypeReferenceMap.get(rawTypeName); + if (rawType == null) { + rawType = new GraphQLTypeReference(rawTypeName); + graphQLTypeReferenceMap.put(rawTypeName, (GraphQLTypeReference) rawType); + } + } + return getGraphQLFieldWithNoArgs(parent, name, rawType, nonNull, isList, listItemNonNull, description, dataFetcher); + } + + private static GraphQLFieldDefinition getGraphQLFieldWithNoArgs(String parent, String name, GraphQLOutputType rawType, + String nonNull, String isList, String listItemNonNull, + BaseDataFetcher dataFetcher) { + return getGraphQLFieldWithNoArgs(parent, name, rawType, nonNull, isList, listItemNonNull, "", dataFetcher); + } + + private static GraphQLFieldDefinition getGraphQLFieldWithNoArgs(String parent, String name, GraphQLOutputType rawType, + String nonNull, String isList, String listItemNonNull, String description, + BaseDataFetcher dataFetcher) { + String fieldKey = getFieldKey(name, rawType.getName(), nonNull, isList, listItemNonNull); + + GraphQLFieldDefinition field = graphQLFieldMap.get(fieldKey); + if (field != null) { + return field; + } + + GraphQLOutputType fieldType = null; + + if ("true".equals(isList)) { + fieldType = getConnectionObjectType(rawType, nonNull, listItemNonNull); + } else { + fieldType = getGraphQLOutputType(rawType, nonNull, "false", listItemNonNull); + } + + GraphQLFieldDefinition.Builder fieldBuilder = GraphQLFieldDefinition.newFieldDefinition().name(name) + .description(description); + for (Map.Entry entry : graphQLDirectiveArgumentMap.entrySet()) { + fieldBuilder.argument(entry.getValue()); + } + + fieldBuilder.type(fieldType); + + if ("true".equals(isList)) fieldBuilder.argument(paginationArgument); + for (Map.Entry entry : graphQLDirectiveArgumentMap.entrySet()) { + fieldBuilder.argument((GraphQLArgument) entry.getValue()); + } + + if (dataFetcher != null) { + codeRegistryBuilder.dataFetcher(FieldCoordinates.coordinates(parent, name), dataFetcher); + } + field = fieldBuilder.build(); + graphQLFieldMap.put(fieldKey, field); + return field; + } + + private static GraphQLOutputType getConnectionObjectType(String rawTypeName, String nonNull, String listItemNonNull) { + GraphQLOutputType rawType = graphQLOutputTypeMap.get(rawTypeName); + if (rawType == null) { + rawType = graphQLTypeReferenceMap.get(rawTypeName); + if (rawType == null) { + rawType = new GraphQLTypeReference(rawTypeName); + System.out.println("Adding graphQLTypeReferenceMap: ${rawTypeName}"); + graphQLTypeReferenceMap.put(rawTypeName, (GraphQLTypeReference) rawType); + + } + } + return getConnectionObjectType(rawType, nonNull, listItemNonNull); + } + + private static GraphQLOutputType getConnectionObjectType(GraphQLOutputType rawType, String nonNull, String listItemNonNull) { + String connectionTypeName = rawType.getName() + "Connection"; + String connectionTypeKey = rawType.getName(); + if ("true".equals(nonNull)) connectionTypeKey = connectionTypeKey + NON_NULL_SUFFIX; + connectionTypeKey = connectionTypeKey + IS_LIST_SUFFIX; + if ("true".equals(listItemNonNull)) connectionTypeKey = connectionTypeKey + LIST_ITEM_NON_NULL_SUFFIX; + + GraphQLOutputType wrappedConnectionType = graphQLOutputTypeMap.get(connectionTypeKey); + if (wrappedConnectionType != null) return wrappedConnectionType; + + GraphQLOutputType connectionType = graphQLOutputTypeMap.get(connectionTypeName); + if (connectionType == null) { + connectionType = GraphQLObjectType.newObject().name(connectionTypeName) + .field(getEdgesField(rawType, nonNull, listItemNonNull)) + .field(getGraphQLFieldWithNoArgs(connectionTypeName, "pageInfo", pageInfoType, "false", "false", "false", null)) + .build(); + graphQLOutputTypeMap.put(connectionTypeName, connectionType); + } + + wrappedConnectionType = connectionType; + if ("true".equals(nonNull)) wrappedConnectionType = new GraphQLNonNull(connectionType); + + if (!connectionTypeKey.equals(connectionTypeName)) graphQLOutputTypeMap.put(connectionTypeKey, wrappedConnectionType); + + return wrappedConnectionType; + } + + private static GraphQLFieldDefinition getEdgesField(GraphQLOutputType rawType, String nonNull, String listItemNonNull) { + String edgesFieldName = "edges"; + String edgeFieldKey = edgesFieldName + KEY_SPLITTER + rawType.getName() + "Edge"; + if ("true".equals(nonNull)) edgeFieldKey = edgeFieldKey + NON_NULL_SUFFIX; + edgeFieldKey = edgeFieldKey + IS_LIST_SUFFIX; + if ("true".equals(listItemNonNull)) edgeFieldKey = edgeFieldKey + LIST_ITEM_NON_NULL_SUFFIX; + + GraphQLFieldDefinition edgesField = graphQLFieldMap.get(edgeFieldKey); + if (edgesField != null) return edgesField; + + GraphQLFieldDefinition.Builder edgesFieldBuilder = GraphQLFieldDefinition.newFieldDefinition().name(edgesFieldName) + .type(getEdgesObjectType(rawType, nonNull, listItemNonNull)); + + for (Map.Entry entry : graphQLDirectiveArgumentMap.entrySet()) edgesFieldBuilder.argument(entry.getValue()); + + edgesField = edgesFieldBuilder.build(); + graphQLFieldMap.put(edgeFieldKey, edgesField); + + return edgesField; + } + + private static GraphQLOutputType getEdgesObjectType(GraphQLOutputType rawType, String nonNull, String listItemNonNull) { + String edgeRawTypeName = rawType.getName() + "Edge"; + String edgesTypeKey = edgeRawTypeName; + if ("true".equals(nonNull)) edgesTypeKey = edgesTypeKey + NON_NULL_SUFFIX; + edgesTypeKey = edgesTypeKey + IS_LIST_SUFFIX; + if ("true".equals(listItemNonNull)) edgesTypeKey = edgesTypeKey + LIST_ITEM_NON_NULL_SUFFIX; + + GraphQLOutputType edgesType = graphQLOutputTypeMap.get(edgesTypeKey); + if (edgesType != null) return edgesType; + + GraphQLObjectType edgeRawType = graphQLObjectTypeMap.get(edgeRawTypeName); + if (edgeRawType == null) { + GraphQLFieldDefinition nodeField = getGraphQLFieldWithNoArgs(edgeRawTypeName, "node", rawType, nonNull, "false", listItemNonNull, null); + + edgeRawType = GraphQLObjectType.newObject().name(edgeRawTypeName) + .field(cursorField) + .field(nodeField).build(); + graphQLObjectTypeMap.put(edgeRawTypeName, edgeRawType); + graphQLOutputTypeMap.put(edgeRawTypeName, edgeRawType); + } + + edgesType = edgeRawType; + ; + + if ("true".equals(listItemNonNull)) edgesType = new GraphQLNonNull(edgesType); + edgesType = new GraphQLList(edgesType); + if ("true".equals(nonNull)) edgesType = new GraphQLNonNull(edgesType); + + if (!edgesTypeKey.equals(edgeRawTypeName)) { + graphQLOutputTypeMap.put(edgesTypeKey, edgesType); + } + + return edgesType; + } + + + // Create InputObjectType (Input) for mutation fields + private void addSchemaInputObjectTypes() { + for (Map.Entry entry : allTypeDefMap.entrySet()) { + if (!(entry.getValue() instanceof ObjectTypeDefinition)) { + continue; + } + for (FieldDefinition fieldDef : ((ObjectTypeDefinition) entry.getValue()).getFieldList()) { + if (fieldDef.isMutation) { + if (fieldDef.dataFetcher == null) { + throw new IllegalArgumentException("FieldDefinition [" + fieldDef.name + "] - [" + fieldDef.type + + "] as mutation must have a data fetcher"); + } + if (fieldDef.dataFetcher instanceof EmptyDataFetcher) { + throw new IllegalArgumentException("FieldDefinition [" + fieldDef.name + "] - [" + fieldDef.type + + "] as mutation can't have empty data fetcher"); + } + } + + if (fieldDef.dataFetcher instanceof ServiceDataFetcher && fieldDef.isMutation) { + String serviceName = ((ServiceDataFetcher) fieldDef.dataFetcher).getServiceName(); + String inputTypeName = GraphQLSchemaUtil.camelCaseToUpperCamel(fieldDef.name) + "Input"; + + boolean isEntityAutoService = ((ServiceDataFetcher) fieldDef.dataFetcher).isEntityAutoService(); + + Map inputFieldMap; + if (isEntityAutoService) { + // Entity Auto Service only works for mutation which is checked in + // ServiceDataFetcher initialization. + String verb = GraphQLSchemaUtil.getVerbFromName(serviceName, dispatcher); + String entityName = GraphQLSchemaUtil.getDefaultEntityName(serviceName, dispatcher); + ModelEntity entity = GraphQLSchemaUtil.getEntityDefinition(entityName, delegator); + List allFields = verb.equals("delete") ? entity.getPkFieldNames() : entity.getAllFieldNames(); + inputFieldMap = new LinkedHashMap<>(allFields.size()); + for (int i = 0; i < allFields.size(); i++) { + ModelField fi = entity.getField(allFields.get(i)); + String inputFieldType = GraphQLSchemaUtil.fieldTypeGraphQLMap.get(fi.getType()); + Object defaultValue = null; + InputObjectFieldDefinition inputFieldDef = new InputObjectFieldDefinition(fi.getName(), inputFieldType, defaultValue, ""); + inputFieldMap.put(fi.getName(), inputFieldDef); + } + + } else { + ModelService sd = GraphQLSchemaUtil.getServiceDefinition(serviceName, dispatcher); + inputFieldMap = new LinkedHashMap<>(sd.getInParamNames().size()); + for (String parmName : sd.getInParamNames()) { + ModelParam parmNode = sd.getParam(parmName); + boolean isInternal = parmNode.getInternal(); + String entityName = parmNode.getEntityName(); + if (isInternal || + ((parmNode.getType().equals("List") || parmNode.getType().equals("Map") || parmNode.getType().equals("Set")) && + UtilValidate.isEmpty(entityName))) { + continue; + } + Object defaultValue = null; + boolean inputFieldNonNull = !parmNode.isOptional(); + boolean inputFieldIsList = GraphQLSchemaUtil.getShortJavaType(parmNode.getType()).equals("List") ? true : false; + GraphQLInputType fieldInputType = getInputTypeRecursiveInSD(parmNode, inputTypeName); + InputObjectFieldDefinition inputFieldDef = + new InputObjectFieldDefinition(parmName, fieldInputType.getName(), defaultValue, "", inputFieldNonNull, + inputFieldIsList, false); + inputFieldMap.put(parmName, inputFieldDef); + } + } + + GraphQLInputObjectType.Builder inputObjectTypeBuilder = + GraphQLInputObjectType.newInputObject().name(inputTypeName).description("Autogenerated input type of " + inputTypeName); + + for (Map.Entry inputFieldEntry : inputFieldMap.entrySet()) { + InputObjectFieldDefinition inputFieldDef = inputFieldEntry.getValue(); + if ("clientMutationId".equals(inputFieldDef.name)) { + continue; + } + + inputObjectTypeBuilder.field(buildSchemaInputField(inputFieldDef)); + } + inputObjectTypeBuilder.field(clientMutationIdInputField); + GraphQLInputObjectType inputObjectType = inputObjectTypeBuilder.build(); + graphQLInputTypeMap.put(inputTypeName, inputObjectType); + + } + + if (fieldDef.dataFetcher instanceof ServiceDataFetcher && !fieldDef.isMutation) { + String serviceName = ((ServiceDataFetcher) fieldDef.dataFetcher).getServiceName(); + String inputTypeName = GraphQLSchemaUtil.camelCaseToUpperCamel(fieldDef.name); + boolean isEntityAutoService = ((ServiceDataFetcher) fieldDef.dataFetcher).isEntityAutoService(); + if (isEntityAutoService) { + throw new IllegalArgumentException("Entity auto service is not supported for query field"); + } else { + ModelService sd = GraphQLSchemaUtil.getServiceDefinition(serviceName, dispatcher); + for (String parmName : sd.getParameterNames("IN", true, false)) { + ModelParam parmNode = sd.getParam(parmName); + getInputTypeRecursiveInSD(parmNode, inputTypeName); + } + } + } + + } + + } + + } + + private GraphQLInputType getInputTypeRecursiveInSD(ModelField field, String inputTypeNamePrefix) { + + if (field == null) { + return GraphQLString; + } + + String parmType = field.getType(); + String inputTypeName = GraphQLSchemaUtil.getGraphQLTypeNameBySQLType(parmType); + GraphQLScalarType scalarType = GraphQLSchemaUtil.graphQLScalarTypes.get(inputTypeName); + if (scalarType != null) { + graphQLInputTypeMap.put(inputTypeName, scalarType); + return scalarType; + } + return null; + } + + private GraphQLInputType getInputTypeRecursiveInSD(ModelParam node, String inputTypeNamePrefix) { + // default to String + if (node == null) { + return GraphQLString; + } + + String parmName = node.getName(); + String parmType = node.getType(); + String entityName = node.getEntityName(); + String inputTypeName = GraphQLSchemaUtil.getGraphQLTypeNameByJava(parmType); + GraphQLScalarType scalarType = GraphQLSchemaUtil.graphQLScalarTypes.get(inputTypeName); + if (scalarType != null) { + return scalarType; + } + + inputTypeName = inputTypeNamePrefix + '_' + parmName; + GraphQLInputType inputType = graphQLInputTypeMap.get(inputTypeName); + if (inputType != null) { + return inputType; + } + + switch (parmType) { + case "List": + if (entityName != null) { + GraphQLInputObjectType.Builder builder = GraphQLInputObjectType.newInputObject().name(inputTypeName); + ModelEntity entity = GraphQLSchemaUtil.getEntityDefinition(entityName, delegator); + if (entity != null) { + for (String fieldName : entity.getAllFieldNames()) { + ModelField field = entity.getField(fieldName); + GraphQLInputType mapEntryRawType = getInputTypeRecursiveInSD(field, inputTypeName); + GraphQLInputObjectField inputObjectField = GraphQLInputObjectField.newInputObjectField().name(fieldName) + .type(getGraphQLInputType(mapEntryRawType, field.getIsNotNull(), false, false)).build(); + builder.field(inputObjectField); + } + inputType = builder.build(); + } + + } + break; + case "Map": + if (entityName != null) { + GraphQLInputObjectType.Builder builder = GraphQLInputObjectType.newInputObject().name(inputTypeName); + ModelEntity entity = GraphQLSchemaUtil.getEntityDefinition(entityName, delegator); + if (entity != null) { + for (String fieldName : entity.getAllFieldNames()) { + ModelField field = entity.getField(fieldName); + GraphQLInputType mapEntryRawType = getInputTypeRecursiveInSD(field, inputTypeName); + GraphQLInputObjectField inputObjectField = GraphQLInputObjectField.newInputObjectField().name(fieldName) + .type(getGraphQLInputType(mapEntryRawType, field.getIsNotNull(), false, false)).build(); + builder.field(inputObjectField); + } + inputType = builder.build(); + } + + } + break; + case "org.apache.ofbiz.graphql.schema.PaginationInputType": + return paginationInputType; + case "org.apache.ofbiz.graphql.schema.OperationInputType": + return operationInputType; + case "org.apache.ofbiz.graphql.schema.DateRangeInputType": + return dateRangeInputType; + case "graphql.schema.DataFetchingEnvironment": + return null; + default: + throw new IllegalArgumentException( + "Type " + inputTypeName + " - " + parmType + " for input field is not supported"); + } + + graphQLInputTypeMap.put(inputTypeName, inputType); + return inputType; + } + + private static GraphQLInputType getGraphQLInputType(InputObjectFieldDefinition inputFieldDef) { + return getGraphQLInputType(inputFieldDef.type, inputFieldDef.nonNull, inputFieldDef.isList(), inputFieldDef.listItemNonNull); + } + + private static GraphQLInputType getGraphQLInputType(String rawTypeName, boolean nonNull, boolean isList, boolean listItemNonNull) { + GraphQLInputType rawType = graphQLInputTypeMap.get(rawTypeName); + if (rawType == null) { + rawType = graphQLTypeReferenceMap.get(rawTypeName); + if (rawType == null) { + rawType = new GraphQLTypeReference(rawTypeName); + graphQLTypeReferenceMap.put(rawTypeName, (GraphQLTypeReference) rawType); + } + } + return getGraphQLInputType(rawType, nonNull, isList, listItemNonNull); + } + + private static GraphQLInputType getGraphQLInputType(GraphQLInputType rawType, boolean nonNull, boolean isList, boolean listItemNonNull) { + String inputTypeKey = rawType.getName(); + if (nonNull) inputTypeKey = inputTypeKey + NON_NULL_SUFFIX; + if (isList) { + inputTypeKey = inputTypeKey + IS_LIST_SUFFIX; + if (listItemNonNull) inputTypeKey = inputTypeKey + LIST_ITEM_NON_NULL_SUFFIX; + } + + GraphQLInputType wrappedType = graphQLInputTypeMap.get(inputTypeKey); + if (wrappedType != null) return wrappedType; + + wrappedType = rawType; + if (isList) { + if (listItemNonNull) wrappedType = new GraphQLNonNull(wrappedType); + wrappedType = new GraphQLList(wrappedType); + } + if (nonNull) wrappedType = new GraphQLNonNull(wrappedType); + + if (!inputTypeKey.equals(rawType.getName())) graphQLInputTypeMap.put(inputTypeKey, wrappedType); + + return wrappedType; + } + + private static GraphQLInputObjectField buildSchemaInputField(InputObjectFieldDefinition inputFieldDef) { + String inputFieldKey = getInputFieldKey(inputFieldDef); + GraphQLInputObjectField inputObjectField = graphQLInputObjectFieldMap.get(inputFieldKey); + if (inputObjectField != null) { + return inputObjectField; + } + + GraphQLInputType rawType = graphQLInputTypeMap.get(inputFieldDef.type); + + GraphQLInputType wrapperType = rawType; + if (inputFieldDef.isList()) { + if (inputFieldDef.listItemNonNull) { + wrapperType = new GraphQLNonNull(wrapperType); + } + wrapperType = new GraphQLList(wrapperType); + } + if (inputFieldDef.nonNull) { + wrapperType = new GraphQLNonNull(wrapperType); + } + + + GraphQLInputObjectField inputField = GraphQLInputObjectField.newInputObjectField().name(inputFieldDef.name) + .type(wrapperType).defaultValue(inputFieldDef.defaultValue).description(inputFieldDef.description) + .build(); + + graphQLInputObjectFieldMap.put(inputFieldKey, inputField); + return inputField; + } + + private static int unknownInputDefaultValueNum = 0; + + private static String getInputFieldKey(InputObjectFieldDefinition inputFieldDef) { + return getInputFieldKey(inputFieldDef.name, inputFieldDef.type, inputFieldDef.defaultValue, + inputFieldDef.isNonNull(), inputFieldDef.isList(), inputFieldDef.listItemNonNull); + } + + private static String getInputFieldKey(String name, String type, Object defaultValue) { + return getInputFieldKey(name, type, defaultValue, false, false, false); + } + + private static String getInputFieldKey(String name, String type, Object defaultValue, boolean nonNull, + boolean isList, boolean listItemNonNull) { + String defaultValueKey; + if (defaultValue == null) { + defaultValueKey = "NULL"; + } else { + // TODO: generate a unique key based on defaultValue + defaultValueKey = "UNKNOWN" + Integer.toString(unknownInputDefaultValueNum); + unknownInputDefaultValueNum++; + } + + String inputFieldKey = name + KEY_SPLITTER + type + KEY_SPLITTER + defaultValueKey; + if (nonNull) { + inputFieldKey = inputFieldKey + NON_NULL_SUFFIX; + } + if (isList) { + inputFieldKey = inputFieldKey + IS_LIST_SUFFIX; + if (listItemNonNull) { + inputFieldKey = inputFieldKey + LIST_ITEM_NON_NULL_SUFFIX; + } + } + + return inputFieldKey; + } + +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/schema/GraphQLSchemaUtil.java b/graphql/src/main/java/org/apache/ofbiz/graphql/schema/GraphQLSchemaUtil.java new file mode 100644 index 000000000..2514266a7 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/schema/GraphQLSchemaUtil.java @@ -0,0 +1,551 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.aaaab + *******************************************************************************/ +package org.apache.ofbiz.graphql.schema; + +import graphql.language.Field; +import graphql.schema.DataFetchingEnvironment; +import graphql.schema.GraphQLScalarType; +import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.base.util.UtilXml; +import org.apache.ofbiz.entity.Delegator; +import org.apache.ofbiz.entity.GenericEntityException; +import org.apache.ofbiz.entity.model.ModelEntity; +import org.apache.ofbiz.entity.model.ModelField; +import org.apache.ofbiz.entity.model.ModelReader; +import org.apache.ofbiz.graphql.fetcher.EntityDataFetcher; +import org.apache.ofbiz.graphql.fetcher.ServiceDataFetcher; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaDefinition.ArgumentDefinition; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaDefinition.FieldDefinition; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaDefinition.GraphQLTypeDefinition; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaDefinition.ObjectTypeDefinition; +import org.apache.ofbiz.service.GenericServiceException; +import org.apache.ofbiz.service.LocalDispatcher; +import org.apache.ofbiz.service.ModelParam; +import org.apache.ofbiz.service.ModelService; +import org.w3c.dom.Element; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeSet; + +import static graphql.Scalars.GraphQLBigDecimal; +import static graphql.Scalars.GraphQLBigInteger; +import static graphql.Scalars.GraphQLBoolean; +import static graphql.Scalars.GraphQLByte; +import static graphql.Scalars.GraphQLChar; +import static graphql.Scalars.GraphQLFloat; +import static graphql.Scalars.GraphQLID; +import static graphql.Scalars.GraphQLInt; +import static graphql.Scalars.GraphQLLong; +import static graphql.Scalars.GraphQLShort; +import static graphql.Scalars.GraphQLString; +import static org.apache.ofbiz.graphql.Scalars.GraphQLDateTime; + +@SuppressWarnings(value = "all") +public class GraphQLSchemaUtil { + + public static final Map graphQLScalarTypes = new HashMap(); + public static final Map fieldTypeGraphQLMap = new HashMap(); + public static final Map javaTypeGraphQLMap = new HashMap(); + + public static final List graphQLStringTypes = Arrays.asList("String", "ID", "Char"); + public static final List graphQLDateTypes = Arrays.asList("Timestamp"); + public static final List graphQLNumericTypes = Arrays.asList("Int", "Long", "Float", "BigInteger", "BigDecimal", "Short"); + public static final List graphQLBoolTypes = Arrays.asList("Boolean"); + + static { + graphQLScalarTypes.put("Int", GraphQLInt); + graphQLScalarTypes.put("Float", GraphQLFloat); + graphQLScalarTypes.put("Boolean", GraphQLBoolean); + graphQLScalarTypes.put("BigInteger", GraphQLBigInteger); + graphQLScalarTypes.put("Byte", GraphQLByte); + graphQLScalarTypes.put("Char", GraphQLChar); + graphQLScalarTypes.put("String", GraphQLString); + graphQLScalarTypes.put("ID", GraphQLID); + graphQLScalarTypes.put("BigDecimal", GraphQLBigDecimal); + graphQLScalarTypes.put("Short", GraphQLShort); + graphQLScalarTypes.put("Long", GraphQLLong); + graphQLScalarTypes.put("Timestamp", GraphQLDateTime); + graphQLScalarTypes.put("DateTime", GraphQLDateTime); + + fieldTypeGraphQLMap.put("id", "ID"); + fieldTypeGraphQLMap.put("indicator", "String"); + fieldTypeGraphQLMap.put("date", "String"); + fieldTypeGraphQLMap.put("id-vlong", "String"); + fieldTypeGraphQLMap.put("description", "String"); + fieldTypeGraphQLMap.put("numeric", "Int"); // + fieldTypeGraphQLMap.put("long-varchar", "String"); + fieldTypeGraphQLMap.put("id-long", "String"); + fieldTypeGraphQLMap.put("currency-amount", "BigDecimal"); + fieldTypeGraphQLMap.put("value", "value"); + fieldTypeGraphQLMap.put("email", "String"); + fieldTypeGraphQLMap.put("currency-precise", "BigDecimal"); + fieldTypeGraphQLMap.put("very-short", "String"); + fieldTypeGraphQLMap.put("date-time", "Timestamp"); + fieldTypeGraphQLMap.put("credit-card-date", "String"); + fieldTypeGraphQLMap.put("url", "String"); + fieldTypeGraphQLMap.put("credit-card-number", "String"); + fieldTypeGraphQLMap.put("fixed-point", "BigDecimal"); + fieldTypeGraphQLMap.put("name", "String"); + fieldTypeGraphQLMap.put("short-varchar", "String"); + fieldTypeGraphQLMap.put("comment", "String"); + fieldTypeGraphQLMap.put("time", "String"); + fieldTypeGraphQLMap.put("very-long", "String"); + fieldTypeGraphQLMap.put("floating-point", "Float"); + fieldTypeGraphQLMap.put("object", "Byte"); + fieldTypeGraphQLMap.put("byte-array", "Byte"); + fieldTypeGraphQLMap.put("blob", "Byte"); + + javaTypeGraphQLMap.put("String", "String"); + javaTypeGraphQLMap.put("java.lang.String", "String"); + javaTypeGraphQLMap.put("CharSequence", "String"); + javaTypeGraphQLMap.put("java.lang.CharSequence", "String"); + javaTypeGraphQLMap.put("Date", "String"); + javaTypeGraphQLMap.put("java.sql.Date", "String"); + javaTypeGraphQLMap.put("Time", "String"); + javaTypeGraphQLMap.put("java.sql.Time", "String"); + javaTypeGraphQLMap.put("Timestamp", "Timestamp"); + javaTypeGraphQLMap.put("java.sql.Timestamp", "Timestamp"); + javaTypeGraphQLMap.put("Integer", "Int"); + javaTypeGraphQLMap.put("java.lang.Integer", "Int"); + javaTypeGraphQLMap.put("Long", "Long"); + javaTypeGraphQLMap.put("java.lang.Long", "Long"); + javaTypeGraphQLMap.put("BigInteger", "BigInteger"); + javaTypeGraphQLMap.put("java.math.BigInteger", "BigInteger"); + javaTypeGraphQLMap.put("Float", "Float"); + javaTypeGraphQLMap.put("java.lang.Float", "Float"); + javaTypeGraphQLMap.put("Double", "Float"); + javaTypeGraphQLMap.put("java.lang.Double", "Float"); + javaTypeGraphQLMap.put("BigDecimal", "BigDecimal"); + javaTypeGraphQLMap.put("java.math.BigDecimal", "BigDecimal"); + javaTypeGraphQLMap.put("Boolean", "Boolean"); + javaTypeGraphQLMap.put("java.lang.Boolean", "Boolean"); + + } + + public static String camelCaseToUpperCamel(String camelCase) { + if (camelCase == null || camelCase.length() == 0) { + return ""; + } + return Character.toString(Character.toUpperCase(camelCase.charAt(0))) + camelCase.substring(1); + } + + static void createObjectTypeNodeForAllEntities(Delegator delegator, LocalDispatcher dispatcher, + Map allTypeNodeMap) { + + List entities = getAllEntities(delegator, "org.apache.ofbiz", true); + for (ModelEntity entity : entities) { + addObjectTypeNode(delegator, dispatcher, entity, true, allTypeNodeMap); + } + } + + private static void addObjectTypeNode(Delegator delegator, LocalDispatcher dispatcher, ModelEntity ed, + boolean standalone, Map allTypeDefMap) { + String objectTypeName = ed.getEntityName(); + if (allTypeDefMap.containsKey(objectTypeName)) { + return; + } + Map fieldDefMap = new LinkedHashMap<>(); + List allFields = ed.getAllFieldNames(); + + if (!allFields.contains("id")) { + // Add a id field to all entity Object Type + GraphQLSchemaDefinition.FieldDefinition idFieldDef = GraphQLSchemaDefinition.getCachedFieldDefinition("id", + "ID", "false", "false", "false"); + if (idFieldDef == null) { + idFieldDef = new GraphQLSchemaDefinition.FieldDefinition(null, delegator, dispatcher, "id", "ID", + new HashMap()); + GraphQLSchemaDefinition.putCachedFieldDefinition(idFieldDef); + } + fieldDefMap.put("id", idFieldDef); + } + + for (String fieldName : allFields) { + ModelField field = ed.getField(fieldName); + String fieldScalarType = fieldTypeGraphQLMap.get(field.getType()); + Map fieldPropertyMap = new HashMap<>(); + if (field.getIsPk() || field.getIsNotNull()) { + fieldPropertyMap.put("nonNull", "true"); + } + fieldPropertyMap.put("description", + UtilValidate.isEmpty(field.getDescription()) ? "" : field.getDescription()); + FieldDefinition fieldDef = GraphQLSchemaDefinition.getCachedFieldDefinition(fieldName, fieldScalarType, + fieldPropertyMap.get("nonNull"), "false", "false"); + if (fieldDef == null) { + //System.out.println("fieldName "+fieldName+", fieldScalarType "+fieldScalarType); + fieldDef = new FieldDefinition(objectTypeName, delegator, dispatcher, fieldName, fieldScalarType, fieldPropertyMap); + GraphQLSchemaDefinition.putCachedFieldDefinition(fieldDef); + } + fieldDefMap.put(fieldName, fieldDef); + + } + + //System.out.println("objectTypeName "+objectTypeName); + ObjectTypeDefinition objectTypeDef = new ObjectTypeDefinition(delegator, dispatcher, objectTypeName, + ed.getDescription(), new ArrayList(), fieldDefMap); + allTypeDefMap.put(objectTypeName, objectTypeDef); + + } + + private static List getAllEntities(Delegator delegator, String groupName, + boolean excludeViewEntities) { + List entities = new ArrayList(); + ModelReader reader = delegator.getModelReader(); + TreeSet entityNames = null; + try { + entityNames = new TreeSet(reader.getEntityNames()); + } catch (GenericEntityException e) { + } + entityNames.forEach(entityName -> { + try { + final ModelEntity entity = reader.getModelEntity(entityName); + entities.add(entity); + } catch (Exception e) { + + } + }); + + return entities; + } + + public static void transformArguments(Map arguments, Map inputFieldsMap, Map operationMap) { + for (Map.Entry entry : arguments.entrySet()) { + String argName = entry.getKey(); + // Ignore if argument which is used for directive @include and @skip + if ("if".equals(argName)) { + continue; + } + Object argValue = entry.getValue(); + if (argValue == null) { + continue; + } + + if (argValue instanceof LinkedHashMap) { + Map argValueMap = (LinkedHashMap) argValue; + if ("input".equals(argName)) { + argValueMap.forEach((k, v) -> { + inputFieldsMap.put((String) k, v); + }); + continue; + } + + if (argValueMap.get("value") != null) { + operationMap.put(argName, argValueMap.get("value")); + } + if (argValueMap.get("op") != null) { + operationMap.put(argName + "_op", argValueMap.get("op")); + } + if (argValueMap.get("not") != null) { + operationMap.put(argName + "_not", argValueMap.get("not")); + } + if (argValueMap.get("ic") != null) { + operationMap.put(argName + "_ic", argValueMap.get("ic")); + } + operationMap.put("pageIndex", argValueMap.get("pageIndex") != null ? argValueMap.get("pageIndex") : 0); + operationMap.put("pageSize", argValueMap.get("pageSize") != null ? argValueMap.get("pageSize") : 20); + if (argValueMap.get("pageNoLimit") != null) { + operationMap.put("pageNoLimit", argValueMap.get("pageNoLimit")); + } + if (argValueMap.get("orderByField") != null) { + operationMap.put("orderByField", argValueMap.get("orderByField")); + } + + if (argValueMap.get("period") != null) { + operationMap.put(argName + "_period", argValueMap.get("period")); + } + if (argValueMap.get("poffset") != null) { + operationMap.put(argName + "_poffset", argValueMap.get("poffset")); + } + if (argValueMap.get("from") != null) { + operationMap.put(argName + "_from", argValueMap.get("from")); + } + if (argValueMap.get("thru") != null) { + operationMap.put(argName + "_thru", argValueMap.get("thru")); + } + + } else { + // periodValid_ type argument is handled specially + if (!(argName == "periodValid_" || argName.endsWith("PeriodValid_"))) { + inputFieldsMap.put(argName, argValue); + } + } + } + } + + public static void transformQueryServiceRelArguments(Map source, Map relKeyMap, + Map inParameterMap) { + for (Map.Entry keyMapEntry : relKeyMap.entrySet()) { + inParameterMap.put((String) keyMapEntry.getValue(), source.get(keyMapEntry.getKey())); + } + + } + + public static void transformQueryServiceArguments(ModelService sd, Map arguments, + Map inParameterMap) { + for (Map.Entry entry : arguments.entrySet()) { + String paramName = entry.getKey(); + if ("if".equals(paramName)) { + continue; + } + if (entry.getValue() == null) { + continue; + } + ModelParam paramNode = sd.getParam(paramName); + if (paramNode == null) { + throw new IllegalArgumentException("Service " + sd.getName() + " missing in parameter " + paramName); + } + if (!paramNode.isIn()) { + throw new IllegalArgumentException("The Param Was not IN"); + } + String paramType = paramNode.getType(); + Object paramJavaTypeValue; + switch (paramType) { + case "org.apache.ofbiz.graphql.schema.OperationInputType": + paramJavaTypeValue = new OperationInputType((Map) entry.getValue()); + break; + case "org.apache.ofbiz.graphql.schema.DateRangeInputType": + paramJavaTypeValue = new DateRangeInputType((Map) entry.getValue()); + break; + case "org.apache.ofbiz.graphql.schema.PaginationInputType": + paramJavaTypeValue = new PaginationInputType((Map) entry.getValue()); + break; + default: + paramJavaTypeValue = castValueToJavaType(entry.getValue(), paramType); + break; + } + inParameterMap.put(paramName, paramJavaTypeValue); + } + + } + + public static boolean requirePagination(DataFetchingEnvironment environment) { + Map arguments = (Map) environment.getArguments(); + List fields = (List) environment.getFields(); + Map paginationArg = (Map) arguments.get("pagination"); + if (paginationArg != null && (Boolean) paginationArg.get("pageNoLimit")) { + return false; + } + if (paginationArg != null) { + return true; + } + int count = (int) fields.stream().filter((field) -> field.getName().equals("pageInfo")).count(); + if (count != 0) { + return true; + } + return false; + } + + + static Object castValueToJavaType(Object value, String javaType) { + switch (javaType) { + case "String": + return value; + case "CharSequence": + return value; + case "Date": + break; //TODO + case "Time": + break; //TODO + case "Timestamp": + return (Timestamp) value; + case "Integer": + return (Integer) value; + case "Long": + return (Long) value; + case "BigInteger": + return (BigInteger) value; + case "Float": + return (Float) value; + case "Double": + return (Double) value; + case "BigDecimal": + return (BigDecimal) value; + case "Boolean": + return (Boolean) value; + case "List": + return (List) value; + case "Map": + return (Map) value; + default: + throw new IllegalArgumentException("Can't cast value [${value}] to Java type ${javaType}"); + } + return null; + } + + public static void mergeFieldDefinition(Element fieldNode, Map fieldDefMap, + Delegator delegator, LocalDispatcher dispatcher) { + FieldDefinition fieldDef = fieldDefMap.get(fieldNode.getAttribute("name")); + System.out.println("Trying to merge here: " + fieldNode.getAttribute("name") + ", fieldDef is null ? " + (fieldDef == null)); + System.out.println("fieldDef " + fieldDef); + if (fieldDef != null) { + if (UtilValidate.isNotEmpty(fieldNode.getAttribute("type"))) { + fieldDef.type = fieldNode.getAttribute("type"); + } + if (UtilValidate.isNotEmpty(fieldNode.getAttribute("non-null"))) { + fieldDef.nonNull = fieldNode.getAttribute("non-null"); + } + if (UtilValidate.isNotEmpty(fieldNode.getAttribute("is-list"))) { + fieldDef.isList = fieldNode.getAttribute("is-list"); + } + if (UtilValidate.isNotEmpty(fieldNode.getAttribute("list-item-non-null"))) { + fieldDef.listItemNonNull = fieldNode.getAttribute("list-item-non-null"); + } + if (UtilValidate.isNotEmpty(fieldNode.getAttribute("require-authentication"))) { + fieldDef.requireAuthentication = fieldNode.getAttribute("require-authentication"); + } + List elements = UtilXml.childElementList(fieldNode); + for (Element childNode : elements) { + switch (childNode.getNodeName()) { + case "description": + fieldDef.description = childNode.getTextContent(); + break; + case "depreciation-reason": + fieldDef.depreciationReason = childNode.getTextContent(); + break; + case "auto-arguments": + //fieldDef.mergeArgument(new AutoArgumentsDefinition(childNode)); + break; + case "argument": + String argTypeName = GraphQLSchemaDefinition.getArgumentTypeName(childNode.getAttribute("type"), + fieldDef.isList); + ArgumentDefinition argDef = GraphQLSchemaDefinition.getCachedArgumentDefinition( + childNode.getAttribute("name"), argTypeName, childNode.getAttribute("required")); + if (argDef == null) { + argDef = new ArgumentDefinition(childNode, fieldDef); + GraphQLSchemaDefinition.putCachedArgumentDefinition(argDef); + } + + fieldDef.mergeArgument(argDef); + break; + case "entity-fetcher": + fieldDef.setDataFetcher(new EntityDataFetcher(delegator, childNode, fieldDef)); + break; + case "service-fetcher": + fieldDef.setDataFetcher(new ServiceDataFetcher(childNode, fieldDef, delegator, dispatcher)); + } + } + } else { + Element parentEle = (Element) fieldNode.getParentNode(); + String parent = parentEle.getAttribute("name"); + System.out.println("YAYYY!! " + parent); + fieldDef = new FieldDefinition(parent, delegator, dispatcher, fieldNode); + fieldDefMap.put(fieldDef.name, fieldDef); + } + } + + public static String getDefaultEntityName(String serviceName, LocalDispatcher dispatcher) { + String defaultEntityName = null; + try { + ModelService service = dispatcher.getDispatchContext().getModelService(serviceName); + if (service == null) { + throw new IllegalArgumentException("Service " + serviceName + " not found"); + } + defaultEntityName = service.getDefaultEntityName(); + } catch (GenericServiceException e) { + e.printStackTrace(); + } + return defaultEntityName; + } + + public static ModelEntity getEntityDefinition(String entityName, Delegator delegator) { + ModelEntity entity = null; + try { + entity = delegator.getModelReader().getModelEntity(entityName); + } catch (GenericEntityException e) { + // TODO Auto-generated catch block + //e.printStackTrace(); + } +// if (entity == null) { +// throw new IllegalArgumentException("Entity Definition " + entityName + " not found"); +// } + + return entity; + } + + public static String getVerbFromName(String serviceName, LocalDispatcher dispatcher) { + String verb = null; + ModelService service = getServiceDefinition(serviceName, dispatcher); + if (service.getEngineName().equalsIgnoreCase("entity-auto")) { + verb = service.getInvoke(); + } + return verb; + } + + public static ModelService getServiceDefinition(String serviceName, LocalDispatcher dispatcher) { + ModelService service = null; + try { + service = dispatcher.getDispatchContext().getModelService(serviceName); + if (service == null) { + throw new IllegalArgumentException("Service " + serviceName + " not found"); + } + + } catch (GenericServiceException e) { + e.printStackTrace(); + } + + return service; + } + + public static String getShortJavaType(String javaType) { + if (javaType == null) { + return ""; + } + String shortJavaType = javaType; + if (javaType.contains(".")) { + shortJavaType = javaType.substring(javaType.lastIndexOf(".") + 1); + } + return shortJavaType; + } + + public static String getGraphQLTypeNameByJava(String javaType) { + if (javaType == null) return "String"; + return javaTypeGraphQLMap.get(getShortJavaType(javaType)); + } + + public static String getGraphQLTypeNameBySQLType(String sqlType) { + if (sqlType == null) return null; + return fieldTypeGraphQLMap.get(sqlType); + } + + + public static String encodeRelayCursor(Map ev, List pkFieldNames) { + return encodeRelayId(ev, pkFieldNames); + } + + public static String encodeRelayId(Map ev, List pkFieldNames) { + if (pkFieldNames.size() == 0) throw new IllegalArgumentException("Entity value must have primary keys to generate id"); + Object pkFieldValue0 = ev.get(pkFieldNames.get(0)); + if (pkFieldValue0 instanceof Timestamp) pkFieldValue0 = ((Timestamp) pkFieldValue0).getTime(); + String id = (String) pkFieldValue0; + for (int i = 1; i < pkFieldNames.size(); i++) { + Object pkFieldValue = ev.get(pkFieldNames.get(i)); + if (pkFieldValue instanceof Timestamp) pkFieldValue = ((Timestamp) pkFieldValue).getTime(); + id = id + '|' + pkFieldValue; + } + return id; + } + +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/schema/OperationInputType.java b/graphql/src/main/java/org/apache/ofbiz/graphql/schema/OperationInputType.java new file mode 100644 index 000000000..6212ee696 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/schema/OperationInputType.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.aaaab + *******************************************************************************/ +package org.apache.ofbiz.graphql.schema; + +import java.util.LinkedHashMap; +import java.util.Map; + +@SuppressWarnings("serial") +class OperationInputType extends LinkedHashMap { + public String value; + public String op; + public String not; + public String ic; + + OperationInputType(String value, String op, String not, String ic) { + this.value = value; + this.op = op; + this.not = not; + this.ic = ic; + if (value != null) { + this.put("value", value); + } + if (op != null) { + this.put("op", op); + } + if (not != null) { + this.put("not", not); + } + if (ic != null) { + this.put("ic", ic); + } + } + + public OperationInputType(Map map) { + this((String) map.get("value"), (String) map.get("op"), (String) map.get("not"), (String) map.get("ic")); + } +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/schema/PaginationInputType.java b/graphql/src/main/java/org/apache/ofbiz/graphql/schema/PaginationInputType.java new file mode 100644 index 000000000..449cca19a --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/schema/PaginationInputType.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.aaaab + *******************************************************************************/ +package org.apache.ofbiz.graphql.schema; + +import java.util.Map; + +public class PaginationInputType { + public Integer pageIndex; + public Integer pageSize; + public Boolean pageNoLimit; + public String orderByField; + public Integer first; + public String after; + public Integer last; + public String before; + public String type; // 'offset' or 'cursor-after' or 'cursor-before' + + PaginationInputType(int pageIndex, int pageSize, boolean pageNoLimit, String orderByField) { + this.pageIndex = pageIndex; + this.pageSize = pageSize; + this.pageNoLimit = pageNoLimit; + this.orderByField = orderByField; + } + + PaginationInputType(int first, String after, int last, String before) { + this.first = first; + this.after = after; + this.last = last; + this.before = before; + } + + public PaginationInputType(Map map) { + this.pageIndex = (int) map.get("pageIndex"); + this.pageSize = (int) map.get("pageSize"); + this.pageNoLimit = (Boolean) map.get("pageNoLimit"); + this.orderByField = (String) map.get("orderByField"); + this.first = (int) map.get("first"); + this.after = (String) map.get("after"); + this.last = (int) map.get("last"); + this.before = (String) map.get("before"); + this.type = (String) map.get("type") != null ? (String) map.get("type") : "offset"; + } + +} diff --git a/graphql/src/main/java/org/apache/ofbiz/graphql/services/GraphQLServices.java b/graphql/src/main/java/org/apache/ofbiz/graphql/services/GraphQLServices.java new file mode 100644 index 000000000..d66709f22 --- /dev/null +++ b/graphql/src/main/java/org/apache/ofbiz/graphql/services/GraphQLServices.java @@ -0,0 +1,211 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + *******************************************************************************/ +package org.apache.ofbiz.graphql.services; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.ofbiz.base.util.UtilValidate; +import org.apache.ofbiz.entity.GenericValue; +import org.apache.ofbiz.graphql.schema.GraphQLSchemaUtil; +import org.apache.ofbiz.service.DispatchContext; +import org.apache.ofbiz.service.GenericServiceException; +import org.apache.ofbiz.service.LocalDispatcher; +import org.apache.ofbiz.service.ModelService; +import org.apache.ofbiz.service.ServiceUtil; + +public class GraphQLServices { + + /** + * @param dctx + * @param context + * @return + */ + public Map buildPageInfo(DispatchContext dctx, Map context) { + String type = (String) context.get("type"); + int totalCount = (int) context.get("totalCount"); + int pageSize = (int) context.get("pageSize"); + int pageIndex = (int) context.get("pageIndex"); + String startCursor = (String) context.get("startCursor"); + String endCursor = (String) context.get("endCursor"); + Map pageInfo = new HashMap(); + int pageMaxIndex = new BigDecimal(totalCount - 1).divide(new BigDecimal(pageSize), 0, BigDecimal.ROUND_DOWN) + .intValue(); + int pageRangeLow = pageIndex * pageSize + 1; + int pageRangeHigh = (pageIndex * pageSize) + pageSize; + if (pageRangeHigh > totalCount) { + pageRangeHigh = totalCount; + } + boolean hasPreviousPage = pageIndex > 0; + boolean hasNextPage = pageMaxIndex > pageIndex; + switch (type) { + case "offset": + pageInfo.put("pageIndex", pageIndex); + pageInfo.put("pageSize", pageSize); + pageInfo.put("pageRangeLow", pageRangeLow); + pageInfo.put("pageRangeHigh", pageRangeHigh); + pageInfo.put("hasPreviousPage", hasPreviousPage); + pageInfo.put("pageMaxIndex", pageMaxIndex); + pageInfo.put("hasNextPage", hasNextPage); + pageInfo.put("totalCount", totalCount); + break; + case "cursor-after": + case "cursor-before": + pageInfo.put("hasNextPage", hasNextPage); + pageInfo.put("hasPreviousPage", hasNextPage); + pageInfo.put("endCursor", endCursor); + pageInfo.put("startCursor", startCursor); + break; + } + Map sucess = ServiceUtil.returnSuccess(); + sucess.put("pageInfo", pageInfo); + return sucess; + } + + @SuppressWarnings("unchecked") + public Map buildConnection(DispatchContext dctx, Map context) { + + List el = (List) context.get("el"); + int totalCount = (int) context.get("totalCount"); + int pageSize = (int) context.get("pageSize"); + int pageIndex = (int) context.get("pageIndex"); + Map pageInfo = new HashMap(); + int pageMaxIndex = new BigDecimal(totalCount - 1).divide(new BigDecimal(pageSize), 0, BigDecimal.ROUND_DOWN) + .intValue(); + int pageRangeLow = pageIndex * pageSize + 1; + int pageRangeHigh = (pageIndex * pageSize) + pageSize; + if (pageRangeHigh > totalCount) { + pageRangeHigh = totalCount; + } + boolean hasPreviousPage = pageIndex > 0; + boolean hasNextPage = pageMaxIndex > pageIndex; + Map edgesData; + Map node; + String id; + + List> edgesDataList = new ArrayList>(el.size()); + List pkFieldNames = null; + if (UtilValidate.isNotEmpty(el)) { + Map primaryKeys = el.get(0).getPrimaryKey().getAllFields(); + pkFieldNames = new ArrayList(primaryKeys.keySet()); + pageInfo.put("startCursor", GraphQLSchemaUtil.encodeRelayCursor(el.get(0), pkFieldNames)); // TODO + pageInfo.put("endCursor", GraphQLSchemaUtil.encodeRelayCursor(el.get(el.size() - 1), pkFieldNames)); // TODO + } + + for (int index = 0; index < el.size(); index++) { + GenericValue gv = el.get(index); + edgesData = new HashMap<>(2); + node = new HashMap<>(); + Map primaryKeys = gv.getPrimaryKey().getAllFields(); + if (primaryKeys.size() > 0 && !primaryKeys.values().contains(null)) { + id = GraphQLSchemaUtil.encodeRelayId(gv, new ArrayList(primaryKeys.keySet())); + } else { + id = "" + index; + } + node.put("id", id); + node.putAll(gv); + edgesData.put("cursor", id); // TODO + edgesData.put("node", node); + edgesDataList.add(edgesData); + } + + pageInfo.put("pageIndex", pageIndex); + pageInfo.put("pageSize", pageSize); + pageInfo.put("pageRangeLow", pageRangeLow); + pageInfo.put("pageRangeHigh", pageRangeHigh); + pageInfo.put("hasPreviousPage", hasPreviousPage); + pageInfo.put("pageMaxIndex", pageMaxIndex); + pageInfo.put("hasNextPage", hasNextPage); + pageInfo.put("totalCount", totalCount); + Map sucess = ServiceUtil.returnSuccess(); + sucess.put("pageInfo", pageInfo); + sucess.put("edges", edgesDataList); + return sucess; + } + + private static Object buildFieldRecursive(Object obj) { + Map result = new HashMap(); + if (obj instanceof List) { + List edges = new ArrayList<>(); + for (Object item : edges) { + Map edge = new HashMap(); + Map node = (Map) buildFieldRecursive(item); + edge.put("node", node); + edges.add(edge); + } + result.put("edges", edges); + return result; + } else if (obj instanceof Map) { + Map map = (Map) obj; + map.forEach((k, v) -> { + result.put((String) k, buildFieldRecursive(v)); + }); + return result; + } else { + return obj; + } + } + + @SuppressWarnings("unchecked") + public Map buildConnectionByList(DispatchContext dctx, Map context) { + + LocalDispatcher dispatcher = (LocalDispatcher) dctx.getDispatcher(); + Map edgesData; + Map node; + List pkFieldNames = (List) context.get("pkFieldNames"); + List el = (List) context.get("el"); + List> edgesDataList = new ArrayList>(el.size()); + + for (GenericValue gv : el) { + String id; + edgesData = new HashMap<>(); + node = new HashMap<>(); + if (pkFieldNames.size() > 0 && !pkFieldNames.contains(null)) { + id = GraphQLSchemaUtil.encodeRelayId(gv, pkFieldNames); + node.put("id", id); + } + Map map = (Map) buildFieldRecursive(gv); + node.putAll(map); + edgesData.put("node", node); + edgesDataList.add(edgesData); + } + + Map sucess = ServiceUtil.returnSuccess(); + sucess.put("edges", edgesDataList); + + Map buildPageInfoCtx = new HashMap<>(); + try { + buildPageInfoCtx = dctx.makeValidContext("createCommunicationEvent", ModelService.IN_PARAM, context); + Map buildPageInfoResult = dispatcher.runSync("buildPageInfo", buildPageInfoCtx); + if (ServiceUtil.isSuccess(buildPageInfoResult)) { + Map pageInfo = (Map) buildPageInfoResult.get("pageInfo"); + sucess.put("pageInfo", pageInfo); + } + } catch (GenericServiceException e) { + e.printStackTrace(); + } + + return sucess; + + } + +} diff --git a/graphql/template/playground.ftl b/graphql/template/playground.ftl new file mode 100644 index 000000000..783619a5f --- /dev/null +++ b/graphql/template/playground.ftl @@ -0,0 +1,546 @@ + + + + + + + + GraphQL Playground + + + + + + + + + + +
+ +
Loading + GraphQL Playground +
+
+ +
+ + + \ No newline at end of file diff --git a/graphql/testdef/GraphqlTests.xml b/graphql/testdef/GraphqlTests.xml new file mode 100644 index 000000000..a7e72bb13 --- /dev/null +++ b/graphql/testdef/GraphqlTests.xml @@ -0,0 +1,26 @@ + + + + + + + \ No newline at end of file diff --git a/graphql/webapp/graphql/WEB-INF/controller.xml b/graphql/webapp/graphql/WEB-INF/controller.xml new file mode 100644 index 000000000..df66b519f --- /dev/null +++ b/graphql/webapp/graphql/WEB-INF/controller.xml @@ -0,0 +1,62 @@ + + + + + + + + Graphql Component Site Configuration File + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/graphql/webapp/graphql/WEB-INF/web.xml b/graphql/webapp/graphql/WEB-INF/web.xml new file mode 100644 index 000000000..2aca0b908 --- /dev/null +++ b/graphql/webapp/graphql/WEB-INF/web.xml @@ -0,0 +1,109 @@ + + + + + Apache OFBiz - Graphql Component + Graphql Component of the Apache OFBiz Project + + + + A unique name used to identify/recognize the local dispatcher for the Service Engine + localDispatcherNamegraphql + + + The Name of the Entity Delegator to use, defined in entityengine.xml + entityDelegatorNamedefault + + + The location of the main-decorator screen to use for this webapp; referred to as a context variable in screen def XML files. + mainDecoratorLocation + component://graphql/widget/CommonScreens.xml + + + Remove unnecessary whitespace from HTML output. + compressHTML + false + + + + ControlFilter + ControlFilter + org.apache.ofbiz.webapp.control.ControlFilter + + allowedPaths + /api:/error:/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images + + redirectPath/control/main + + + ContextFilter + ContextFilter + org.apache.ofbiz.webapp.control.ContextFilter + + + SameSiteFilter + SameSiteFilter + org.apache.ofbiz.webapp.control.SameSiteFilter + + + AuthenticationFilter + org.apache.ofbiz.graphql.filter.AuthenticationFilter + + + AuthenticationFilter + /api/* + + ControlFilter/* + SameSiteFilter/* + + org.apache.ofbiz.webapp.control.ControlEventListener + org.apache.ofbiz.webapp.control.LoginEventListener + + + + + Main Control Servlet + ControlServlet + ControlServlet + org.apache.ofbiz.webapp.control.ControlServlet + 1 + + ControlServlet/control/* + + + Main Control Servlet + GraphQLEndpointServlet + GraphQLEndpointServlet + org.apache.ofbiz.graphql.GraphQLEndpointServletImpl + 1 + + + GraphQLEndpointServlet + /api/* + + + + 60 + + diff --git a/graphql/webapp/graphql/graphiql/graphiql.min.css b/graphql/webapp/graphql/graphiql/graphiql.min.css new file mode 100644 index 000000000..251ea4583 --- /dev/null +++ b/graphql/webapp/graphql/graphiql/graphiql.min.css @@ -0,0 +1,10 @@ +.graphiql-container,.graphiql-container button,.graphiql-container input{color:#141823;font-family:system,-apple-system,San Francisco,\.SFNSDisplay-Regular,Segoe UI,Segoe,Segoe WP,Helvetica Neue,helvetica,Lucida Grande,arial,sans-serif;font-size:14px}.graphiql-container{display:flex;flex-direction:row;height:100%;margin:0;overflow:hidden;width:100%}.graphiql-container .editorWrap{display:flex;flex-direction:column;flex:1;overflow-x:hidden}.graphiql-container .title{font-size:18px}.graphiql-container .title em{font-family:georgia;font-size:19px}.graphiql-container .topBarWrap{display:flex;flex-direction:row}.graphiql-container .topBar{align-items:center;background:linear-gradient(#f7f7f7,#e2e2e2);border-bottom:1px solid #d0d0d0;cursor:default;display:flex;flex-direction:row;flex:1;height:34px;overflow-y:visible;padding:7px 14px 6px;user-select:none}.graphiql-container .toolbar{overflow-x:visible;display:flex}.graphiql-container .docExplorerShow,.graphiql-container .historyShow{background:linear-gradient(#f7f7f7,#e2e2e2);border-radius:0;border-bottom:1px solid #d0d0d0;border-right:none;border-top:none;color:#3b5998;cursor:pointer;font-size:14px;margin:0;padding:2px 20px 0 18px}.graphiql-container .docExplorerShow{border-left:1px solid rgba(0,0,0,.2)}.graphiql-container .historyShow{border-right:1px solid rgba(0,0,0,.2);border-left:0}.graphiql-container .docExplorerShow:before{border-left:2px solid #3b5998;border-top:2px solid #3b5998;content:"";display:inline-block;height:9px;margin:0 3px -1px 0;position:relative;transform:rotate(-45deg);width:9px}.graphiql-container .editorBar{display:flex;flex-direction:row;flex:1}.graphiql-container .queryWrap,.graphiql-container .resultWrap{display:flex;flex-direction:column;flex:1}.graphiql-container .resultWrap{border-left:1px solid #e0e0e0;flex-basis:1em;position:relative}.graphiql-container .docExplorerWrap,.graphiql-container .historyPaneWrap{background:#fff;box-shadow:0 0 8px rgba(0,0,0,.15);position:relative;z-index:3}.graphiql-container .historyPaneWrap{min-width:230px;z-index:5}.graphiql-container .docExplorerResizer{cursor:col-resize;height:100%;left:-5px;position:absolute;top:0;width:10px;z-index:10}.graphiql-container .docExplorerHide{cursor:pointer;font-size:18px;margin:-7px -8px -6px 0;padding:18px 16px 15px 12px;background:0;border:0;line-height:14px}.graphiql-container div .query-editor{flex:1;position:relative}.graphiql-container .variable-editor{display:flex;flex-direction:column;height:30px;position:relative}.graphiql-container .variable-editor-title{background:#eee;border-bottom:1px solid #d6d6d6;border-top:1px solid #e0e0e0;color:#777;font-variant:small-caps;font-weight:700;letter-spacing:1px;line-height:14px;padding:6px 0 8px 43px;text-transform:lowercase;user-select:none}.graphiql-container .codemirrorWrap,.graphiql-container .result-window{flex:1;height:100%;position:relative}.graphiql-container .footer{background:#f6f7f8;border-left:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin-left:12px;position:relative}.graphiql-container .footer:before{background:#eee;bottom:0;content:" ";left:-13px;position:absolute;top:-1px;width:12px}.result-window .CodeMirror{background:#f6f7f8}.graphiql-container .result-window .CodeMirror-gutters{background-color:#eee;border-color:#e0e0e0;cursor:col-resize}.graphiql-container .result-window .CodeMirror-foldgutter,.graphiql-container .result-window .CodeMirror-foldgutter-folded:after,.graphiql-container .result-window .CodeMirror-foldgutter-open:after{padding-left:3px}.graphiql-container .toolbar-button{background:#fdfdfd;background:linear-gradient(#f9f9f9,#ececec);border:0;border-radius:3px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.2),0 1px 0 hsla(0,0%,100%,.7),inset 0 1px #fff;color:#555;cursor:pointer;display:inline-block;margin:0 5px;padding:3px 11px 5px;text-decoration:none;text-overflow:ellipsis;white-space:nowrap;max-width:150px}.graphiql-container .toolbar-button:active{background:linear-gradient(#ececec,#d5d5d5);box-shadow:0 1px 0 hsla(0,0%,100%,.7),inset 0 0 0 1px rgba(0,0,0,.1),inset 0 1px 1px 1px rgba(0,0,0,.12),inset 0 0 5px rgba(0,0,0,.1)}.graphiql-container .toolbar-button.error{background:linear-gradient(#fdf3f3,#e6d6d7);color:#b00}.graphiql-container .toolbar-button-group{margin:0 5px;white-space:nowrap}.graphiql-container .toolbar-button-group>*{margin:0}.graphiql-container .toolbar-button-group>:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}.graphiql-container .toolbar-button-group>:not(:first-child){border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}.graphiql-container .execute-button-wrap{height:34px;margin:0 14px 0 28px;position:relative}.graphiql-container .execute-button{background:linear-gradient(#fdfdfd,#d2d3d6);border-radius:17px;border:1px solid rgba(0,0,0,.25);box-shadow:0 1px 0 #fff;cursor:pointer;fill:#444;height:34px;margin:0;padding:0;width:34px}.graphiql-container .execute-button svg{pointer-events:none}.graphiql-container .execute-button:active{background:linear-gradient(#e6e6e6,#c3c3c3);box-shadow:0 1px 0 #fff,inset 0 0 2px rgba(0,0,0,.2),inset 0 0 6px rgba(0,0,0,.1)}.graphiql-container .toolbar-menu,.graphiql-container .toolbar-select{position:relative}.graphiql-container .execute-options,.graphiql-container .toolbar-menu-items,.graphiql-container .toolbar-select-options{background:#fff;box-shadow:0 0 0 1px rgba(0,0,0,.1),0 2px 4px rgba(0,0,0,.25);margin:0;padding:6px 0;position:absolute;z-index:100}.graphiql-container .execute-options{min-width:100px;top:37px;left:-1px}.graphiql-container .toolbar-menu-items{left:1px;margin-top:-1px;min-width:110%;top:100%;visibility:hidden}.graphiql-container .toolbar-menu-items.open{visibility:visible}.graphiql-container .toolbar-select-options{left:0;min-width:100%;top:-5px;visibility:hidden}.graphiql-container .toolbar-select-options.open{visibility:visible}.graphiql-container .execute-options>li,.graphiql-container .toolbar-menu-items>li,.graphiql-container .toolbar-select-options>li{cursor:pointer;display:block;margin:none;max-width:300px;overflow:hidden;padding:2px 20px 4px 11px;white-space:nowrap}.graphiql-container .execute-options>li.selected,.graphiql-container .history-contents>li:active,.graphiql-container .history-contents>li:hover,.graphiql-container .toolbar-menu-items>li.hover,.graphiql-container .toolbar-menu-items>li:active,.graphiql-container .toolbar-menu-items>li:hover,.graphiql-container .toolbar-select-options>li.hover,.graphiql-container .toolbar-select-options>li:active,.graphiql-container .toolbar-select-options>li:hover{background:#e10098;color:#fff}.graphiql-container .toolbar-select-options>li>svg{display:inline;fill:#666;margin:0 -6px 0 6px;pointer-events:none;vertical-align:middle}.graphiql-container .toolbar-select-options>li.hover>svg,.graphiql-container .toolbar-select-options>li:active>svg,.graphiql-container .toolbar-select-options>li:hover>svg{fill:#fff}.graphiql-container .CodeMirror-scroll{overflow-scrolling:touch}.graphiql-container .CodeMirror{color:#141823;font-family:Consolas,Inconsolata,Droid Sans Mono,Monaco,monospace;font-size:13px;height:100%;left:0;position:absolute;top:0;width:100%}.graphiql-container .CodeMirror-lines{padding:20px 0}.CodeMirror-hint-information .content{box-orient:vertical;color:#141823;display:flex;font-family:system,-apple-system,San Francisco,\.SFNSDisplay-Regular,Segoe UI,Segoe,Segoe WP,Helvetica Neue,helvetica,Lucida Grande,arial,sans-serif;font-size:13px;line-clamp:3;line-height:16px;max-height:48px;overflow:hidden;text-overflow:-o-ellipsis-lastline}.CodeMirror-hint-information .content p:first-child{margin-top:0}.CodeMirror-hint-information .content p:last-child{margin-bottom:0}.CodeMirror-hint-information .infoType{color:#ca9800;cursor:pointer;display:inline;margin-right:.5em}.autoInsertedLeaf.cm-property{animation-duration:6s;animation-name:insertionFade;border-bottom:2px solid hsla(0,0%,100%,0);border-radius:2px;margin:-2px -4px -1px;padding:2px 4px 1px}@keyframes insertionFade{0%,to{background:hsla(0,0%,100%,0);border-color:hsla(0,0%,100%,0)}15%,85%{background:#fbffc9;border-color:#f0f3c0}}div.CodeMirror-lint-tooltip{background-color:#fff;border-radius:2px;border:0;color:#141823;box-shadow:0 1px 3px rgba(0,0,0,.45);font-size:13px;line-height:16px;max-width:430px;opacity:0;padding:8px 10px;transition:opacity .15s;white-space:pre-wrap}div.CodeMirror-lint-tooltip>*{padding-left:23px}div.CodeMirror-lint-tooltip>*+*{margin-top:12px}.graphiql-container .CodeMirror-foldmarker{border-radius:4px;background:#08f;background:linear-gradient(#43a8ff,#0f83e8);box-shadow:0 1px 1px rgba(0,0,0,.2),inset 0 0 0 1px rgba(0,0,0,.1);color:#fff;font-family:arial;font-size:12px;line-height:0;margin:0 3px;padding:0 4px 1px;text-shadow:0 -1px rgba(0,0,0,.1)}.graphiql-container div.CodeMirror span.CodeMirror-matchingbracket{color:#555;text-decoration:underline}.graphiql-container div.CodeMirror span.CodeMirror-nonmatchingbracket{color:red}.cm-comment{color:#999}.cm-punctuation{color:#555}.cm-keyword{color:#b11a04}.cm-def{color:#d2054e}.cm-property{color:#1f61a0}.cm-qualifier{color:#1c92a9}.cm-attribute{color:#8b2bb9}.cm-number{color:#2882f9}.cm-string{color:#d64292}.cm-builtin{color:#d47509}.cm-string-2{color:#0b7fc7}.cm-variable{color:#397d13}.cm-meta{color:#b33086}.cm-atom{color:#ca9800} +.CodeMirror{color:#000;font-family:monospace;height:300px}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{color:#999;min-width:20px;padding:0 3px 0 5px;text-align:right;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror .CodeMirror-cursor{border-left:1px solid #000}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.CodeMirror.cm-fat-cursor div.CodeMirror-cursor{background:#7e7;border:0;width:auto}.CodeMirror.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{animation:blink 1.06s steps(1) infinite;border:0;width:auto}@keyframes blink{0%{background:#7e7}50%{background:none}to{background:#7e7}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-invalidchar,.cm-s-default .cm-error{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{background:#fff;overflow:hidden;position:relative}.CodeMirror-scroll{height:100%;margin-bottom:-30px;margin-right:-30px;outline:none;overflow:scroll!important;padding-bottom:30px;position:relative}.CodeMirror-sizer{border-right:30px solid transparent;position:relative}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{display:none;position:absolute;z-index:6}.CodeMirror-vscrollbar{overflow-x:hidden;overflow-y:scroll;right:0;top:0}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-x:scroll;overflow-y:hidden}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{min-height:100%;position:absolute;left:0;top:0;z-index:3}.CodeMirror-gutter{display:inline-block;height:100%;margin-bottom:-30px;vertical-align:top;white-space:normal;*zoom:1;*display:inline}.CodeMirror-gutter-wrapper{background:none!important;border:none!important;position:absolute;z-index:4}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{cursor:default;position:absolute;z-index:4}.CodeMirror-gutter-wrapper{user-select:none}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{-webkit-tap-highlight-color:transparent;background:transparent;border-radius:0;border-width:0;color:inherit;font-family:inherit;font-size:inherit;font-variant-ligatures:none;line-height:inherit;margin:0;overflow:visible;position:relative;white-space:pre;word-wrap:normal;z-index:2}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{overflow:auto;position:relative;z-index:2}.CodeMirror-code{outline:none}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{box-sizing:content-box}.CodeMirror-measure{height:0;overflow:hidden;position:absolute;visibility:hidden;width:100%}.CodeMirror-cursor{position:absolute}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{position:relative;visibility:hidden;z-index:3}.CodeMirror-focused div.CodeMirror-cursors,div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.CodeMirror span{*vertical-align:text-bottom}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:""}span.CodeMirror-selectedtext{background:none}.CodeMirror-dialog{background:inherit;color:inherit;left:0;right:0;overflow:hidden;padding:.1em .8em;position:absolute;z-index:15}.CodeMirror-dialog-top{border-bottom:1px solid #eee;top:0}.CodeMirror-dialog-bottom{border-top:1px solid #eee;bottom:0}.CodeMirror-dialog input{background:transparent;border:1px solid #d3d6db;color:inherit;font-family:monospace;outline:none;width:20em}.CodeMirror-dialog button{font-size:70%} +.CodeMirror-foldmarker{color:#00f;cursor:pointer;font-family:arial;line-height:.3;text-shadow:#b9f 1px 1px 2px,#b9f -1px -1px 2px,#b9f 1px -1px 2px,#b9f -1px 1px 2px}.CodeMirror-foldgutter{width:.7em}.CodeMirror-foldgutter-folded,.CodeMirror-foldgutter-open{cursor:pointer}.CodeMirror-foldgutter-open:after{content:"\25BE"}.CodeMirror-foldgutter-folded:after{content:"\25B8"} +.CodeMirror-info{background:#fff;border-radius:2px;box-shadow:0 1px 3px rgba(0,0,0,.45);box-sizing:border-box;color:#555;font-family:system,-apple-system,San Francisco,\.SFNSDisplay-Regular,Segoe UI,Segoe,Segoe WP,Helvetica Neue,helvetica,Lucida Grande,arial,sans-serif;font-size:13px;line-height:16px;margin:8px -8px;max-width:400px;opacity:0;overflow:hidden;padding:8px;position:fixed;transition:opacity .15s;z-index:50}.CodeMirror-info :first-child{margin-top:0}.CodeMirror-info :last-child{margin-bottom:0}.CodeMirror-info p{margin:1em 0}.CodeMirror-info .info-description{color:#777;line-height:16px;margin-top:1em;max-height:80px;overflow:hidden}.CodeMirror-info .info-deprecation{background:#fffae8;box-shadow:inset 0 1px 1px -1px #bfb063;color:#867f70;line-height:16px;margin:8px -8px -8px;max-height:80px;overflow:hidden;padding:8px}.CodeMirror-info .info-deprecation-label{color:#c79b2e;cursor:default;display:block;font-size:9px;font-weight:700;letter-spacing:1px;line-height:1;padding-bottom:5px;text-transform:uppercase;user-select:none}.CodeMirror-info .info-deprecation-label+*{margin-top:0}.CodeMirror-info a{text-decoration:none}.CodeMirror-info a:hover{text-decoration:underline}.CodeMirror-info .type-name{color:#ca9800}.CodeMirror-info .field-name{color:#1f61a0}.CodeMirror-info .enum-value{color:#0b7fc7}.CodeMirror-info .arg-name{color:#8b2bb9}.CodeMirror-info .directive-name{color:#b33086} +.CodeMirror-jump-token{text-decoration:underline;cursor:pointer} +.CodeMirror-lint-markers{width:16px}.CodeMirror-lint-tooltip{background-color:infobackground;border-radius:4px 4px 4px 4px;border:1px solid #000;color:infotext;font-family:monospace;font-size:10pt;max-width:600px;opacity:0;overflow:hidden;padding:2px 5px;position:fixed;transition:opacity .4s;white-space:pre-wrap;z-index:100}.CodeMirror-lint-mark-error,.CodeMirror-lint-mark-warning{background-position:0 100%;background-repeat:repeat-x}.CodeMirror-lint-mark-error{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==")}.CodeMirror-lint-mark-warning{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=")}.CodeMirror-lint-marker-error,.CodeMirror-lint-marker-warning{background-position:50%;background-repeat:no-repeat;cursor:pointer;display:inline-block;height:16px;position:relative;vertical-align:middle;width:16px}.CodeMirror-lint-message-error,.CodeMirror-lint-message-warning{background-position:0 0;background-repeat:no-repeat;padding-left:18px}.CodeMirror-lint-marker-error,.CodeMirror-lint-message-error{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=")}.CodeMirror-lint-marker-warning,.CodeMirror-lint-message-warning{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=")}.CodeMirror-lint-marker-multiple{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC");background-position:100% 100%;background-repeat:no-repeat;width:100%;height:100%} +.graphiql-container .spinner-container{height:36px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:36px;z-index:10}.graphiql-container .spinner{animation:rotation .6s linear infinite;border-radius:100%;border:6px solid hsla(0,0%,58.8%,.15);border-top-color:hsla(0,0%,58.8%,.8);display:inline-block;height:24px;position:absolute;vertical-align:middle;width:24px}@keyframes rotation{0%{transform:rotate(0deg)}to{transform:rotate(359deg)}} +.CodeMirror-hints{background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.45);font-family:Consolas,Inconsolata,Droid Sans Mono,Monaco,monospace;font-size:13px;list-style:none;margin:0;max-height:14.5em;overflow:hidden;overflow-y:auto;padding:0;position:absolute;z-index:10}.CodeMirror-hint{border-top:1px solid #f7f7f7;color:#141823;cursor:pointer;margin:0;max-width:300px;overflow:hidden;padding:2px 6px;white-space:pre}li.CodeMirror-hint-active{background-color:#08f;border-top-color:#fff;color:#fff}.CodeMirror-hint-information{border-top:1px solid silver;max-width:300px;padding:4px 6px;position:relative;z-index:1}.CodeMirror-hint-information:first-child{border-bottom:1px solid silver;border-top:none;margin-bottom:-1px}.CodeMirror-hint-deprecation{background:#fffae8;box-shadow:inset 0 1px 1px -1px #bfb063;color:#867f70;font-family:system,-apple-system,San Francisco,\.SFNSDisplay-Regular,Segoe UI,Segoe,Segoe WP,Helvetica Neue,helvetica,Lucida Grande,arial,sans-serif;font-size:13px;line-height:16px;margin-top:4px;max-height:80px;overflow:hidden;padding:6px}.CodeMirror-hint-deprecation .deprecation-label{color:#c79b2e;cursor:default;display:block;font-size:9px;font-weight:700;letter-spacing:1px;line-height:1;padding-bottom:5px;text-transform:uppercase;user-select:none}.CodeMirror-hint-deprecation .deprecation-label+*{margin-top:0}.CodeMirror-hint-deprecation :last-child{margin-bottom:0} +.graphiql-container .doc-explorer{background:#fff}.graphiql-container .doc-explorer-title-bar,.graphiql-container .history-title-bar{cursor:default;display:flex;height:34px;line-height:14px;padding:8px 8px 5px;position:relative;user-select:none}.graphiql-container .doc-explorer-title,.graphiql-container .history-title{flex:1;font-weight:700;overflow-x:hidden;padding:10px 0 10px 10px;text-align:center;text-overflow:ellipsis;user-select:text;white-space:nowrap}.graphiql-container .doc-explorer-back{color:#3b5998;cursor:pointer;margin:-7px 0 -6px -8px;overflow-x:hidden;padding:17px 12px 16px 16px;text-overflow:ellipsis;white-space:nowrap;background:0;border:0;line-height:14px}.doc-explorer-narrow .doc-explorer-back{width:0}.graphiql-container .doc-explorer-back:before{border-left:2px solid #3b5998;border-top:2px solid #3b5998;content:"";display:inline-block;height:9px;margin:0 3px -1px 0;position:relative;transform:rotate(-45deg);width:9px}.graphiql-container .doc-explorer-rhs{position:relative}.graphiql-container .doc-explorer-contents,.graphiql-container .history-contents{background-color:#fff;border-top:1px solid #d6d6d6;bottom:0;left:0;overflow-y:auto;padding:20px 15px;position:absolute;right:0;top:47px}.graphiql-container .doc-explorer-contents{min-width:300px}.graphiql-container .doc-type-description blockquote:first-child,.graphiql-container .doc-type-description p:first-child{margin-top:0}.graphiql-container .doc-explorer-contents a{cursor:pointer;text-decoration:none}.graphiql-container .doc-explorer-contents a:hover{text-decoration:underline}.graphiql-container .doc-value-description>:first-child{margin-top:4px}.graphiql-container .doc-value-description>:last-child{margin-bottom:4px}.graphiql-container .doc-category code,.graphiql-container .doc-category pre,.graphiql-container .doc-type-description code,.graphiql-container .doc-type-description pre{--saf-0:rgba(var(--sk_foreground_low,29,28,29),0.13);font-size:12px;line-height:1.50001;font-variant-ligatures:none;white-space:pre;white-space:pre-wrap;word-wrap:break-word;word-break:normal;-webkit-tab-size:4;-moz-tab-size:4;tab-size:4}.graphiql-container .doc-category code,.graphiql-container .doc-type-description code{padding:2px 3px 1px;border:1px solid var(--saf-0);border-radius:3px;background-color:rgba(var(--sk_foreground_min,29,28,29),.04);color:#e01e5a;background-color:#fff}.graphiql-container .doc-category{margin:20px 0}.graphiql-container .doc-category-title{border-bottom:1px solid #e0e0e0;color:#777;cursor:default;font-size:14px;font-variant:small-caps;font-weight:700;letter-spacing:1px;margin:0 -15px 10px 0;padding:10px 0;user-select:none}.graphiql-container .doc-category-item{margin:12px 0;color:#555}.graphiql-container .keyword{color:#b11a04}.graphiql-container .type-name{color:#ca9800}.graphiql-container .field-name{color:#1f61a0}.graphiql-container .field-short-description{color:#999;margin-left:5px;overflow:hidden;text-overflow:ellipsis}.graphiql-container .enum-value{color:#0b7fc7}.graphiql-container .arg-name{color:#8b2bb9}.graphiql-container .arg{display:block;margin-left:1em}.graphiql-container .arg:first-child:last-child,.graphiql-container .arg:first-child:nth-last-child(2),.graphiql-container .arg:first-child:nth-last-child(2)~.arg{display:inherit;margin:inherit}.graphiql-container .arg:first-child:nth-last-child(2):after{content:", "}.graphiql-container .arg-default-value{color:#43a047}.graphiql-container .doc-deprecation{background:#fffae8;box-shadow:inset 0 0 1px #bfb063;color:#867f70;line-height:16px;margin:8px -8px;max-height:80px;overflow:hidden;padding:8px;border-radius:3px}.graphiql-container .doc-deprecation:before{content:"Deprecated:";color:#c79b2e;cursor:default;display:block;font-size:9px;font-weight:700;letter-spacing:1px;line-height:1;padding-bottom:5px;text-transform:uppercase;user-select:none}.graphiql-container .doc-deprecation>:first-child{margin-top:0}.graphiql-container .doc-deprecation>:last-child{margin-bottom:0}.graphiql-container .show-btn{-webkit-appearance:initial;display:block;border-radius:3px;border:1px solid #ccc;text-align:center;padding:8px 12px 10px;width:100%;box-sizing:border-box;background:#fbfcfc;color:#555;cursor:pointer}.graphiql-container .search-box{border-bottom:1px solid #d3d6db;display:block;font-size:14px;margin:-15px -15px 12px 0;position:relative}.graphiql-container .search-box-icon{cursor:pointer;display:block;font-size:24px;position:absolute;top:-2px;transform:rotate(-45deg);user-select:none}.graphiql-container .search-box .search-box-clear{background-color:#d0d0d0;border-radius:12px;color:#fff;cursor:pointer;font-size:11px;padding:1px 5px 2px;position:absolute;right:3px;top:8px;user-select:none;border:0}.graphiql-container .search-box .search-box-clear:hover{background-color:#b9b9b9}.graphiql-container .search-box>input{border:none;box-sizing:border-box;font-size:14px;outline:none;padding:6px 24px 8px 20px;width:100%}.graphiql-container .error-container{font-weight:700;left:0;letter-spacing:1px;opacity:.5;position:absolute;right:0;text-align:center;text-transform:uppercase;top:50%;transform:translateY(-50%)} +.graphiql-container .history-contents{font-family:Consolas,Inconsolata,Droid Sans Mono,Monaco,monospace;margin:0;padding:0}.graphiql-container .history-contents li{align-items:center;display:flex;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0;padding:8px;border-bottom:1px solid #e0e0e0}.graphiql-container .history-contents li button:not(.history-label){display:none;margin-left:10px}.graphiql-container .history-contents li:focus-within button:not(.history-label),.graphiql-container .history-contents li:hover button:not(.history-label){display:inline-block}.graphiql-container .history-contents button,.graphiql-container .history-contents input{padding:0;background:0;border:0;font-size:inherit;font-family:inherit;line-height:14px;color:inherit}.graphiql-container .history-contents input{flex-grow:1}.graphiql-container .history-contents input::placeholder{color:inherit}.graphiql-container .history-contents button{cursor:pointer;text-align:left}.graphiql-container .history-contents .history-label{flex-grow:1;overflow:hidden;text-overflow:ellipsis} \ No newline at end of file diff --git a/graphql/webapp/graphql/graphiql/graphiql.min.js b/graphql/webapp/graphql/graphiql/graphiql.min.js new file mode 100644 index 000000000..f656a0345 --- /dev/null +++ b/graphql/webapp/graphql/graphiql/graphiql.min.js @@ -0,0 +1,14 @@ +window.GraphiQL=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=94)}([function(e,t,n){"use strict";var r=n(26),i=n(2),o=n(19),a=n(30),s=n(20),u=n(4),c=n(18),l=n(28),f=n(15);function p(e){return e}var d=n(25),h=n(24),m=n(1),v=n(93);function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function g(e){for(var t=1;t0?e:void 0}n.d(t,"S",(function(){return O})),n.d(t,"x",(function(){return E})),n.d(t,"R",(function(){return T})),n.d(t,"w",(function(){return w})),n.d(t,"N",(function(){return _})),n.d(t,"u",(function(){return k})),n.d(t,"H",(function(){return x})),n.d(t,"o",(function(){return S})),n.d(t,"T",(function(){return C})),n.d(t,"y",(function(){return N})),n.d(t,"E",(function(){return D})),n.d(t,"l",(function(){return j})),n.d(t,"F",(function(){return A})),n.d(t,"m",(function(){return L})),n.d(t,"J",(function(){return I})),n.d(t,"q",(function(){return F})),n.d(t,"L",(function(){return R})),n.d(t,"s",(function(){return M})),n.d(t,"G",(function(){return P})),n.d(t,"n",(function(){return V})),n.d(t,"O",(function(){return U})),n.d(t,"v",(function(){return B})),n.d(t,"I",(function(){return q})),n.d(t,"p",(function(){return K})),n.d(t,"D",(function(){return H})),n.d(t,"k",(function(){return z})),n.d(t,"C",(function(){return G})),n.d(t,"j",(function(){return Q})),n.d(t,"d",(function(){return W})),n.d(t,"e",(function(){return Y})),n.d(t,"U",(function(){return J})),n.d(t,"z",(function(){return $})),n.d(t,"M",(function(){return X})),n.d(t,"t",(function(){return Z})),n.d(t,"B",(function(){return ee})),n.d(t,"K",(function(){return te})),n.d(t,"r",(function(){return ne})),n.d(t,"A",(function(){return re})),n.d(t,"g",(function(){return ae})),n.d(t,"f",(function(){return se})),n.d(t,"i",(function(){return pe})),n.d(t,"P",(function(){return de})),n.d(t,"c",(function(){return he})),n.d(t,"h",(function(){return me})),n.d(t,"a",(function(){return ye})),n.d(t,"b",(function(){return ge})),n.d(t,"Q",(function(){return Oe})),W.prototype.toString=function(){return"["+String(this.ofType)+"]"},Object(h.a)(W),Object(d.a)(W),Y.prototype.toString=function(){return String(this.ofType)+"!"},Object(h.a)(Y),Object(d.a)(Y);var ae=function(){function e(e){var t=e.parseValue||p;this.name=e.name,this.description=e.description,this.serialize=e.serialize||p,this.parseValue=t,this.parseLiteral=e.parseLiteral||function(e){return t(Object(v.a)(e))},this.extensions=e.extensions&&Object(s.a)(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=oe(e.extensionASTNodes),"string"==typeof e.name||Object(u.a)(0,"Must provide name."),null==e.serialize||"function"==typeof e.serialize||Object(u.a)(0,"".concat(this.name,' must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.')),e.parseLiteral&&("function"==typeof e.parseValue&&"function"==typeof e.parseLiteral||Object(u.a)(0,"".concat(this.name,' must provide both "parseValue" and "parseLiteral" functions.')))}var t=e.prototype;return t.toConfig=function(){return{name:this.name,description:this.description,serialize:this.serialize,parseValue:this.parseValue,parseLiteral:this.parseLiteral,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes||[]}},t.toString=function(){return this.name},e}();Object(h.a)(ae),Object(d.a)(ae);var se=function(){function e(e){this.name=e.name,this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=e.extensions&&Object(s.a)(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=oe(e.extensionASTNodes),this._fields=ce.bind(void 0,e),this._interfaces=ue.bind(void 0,e),"string"==typeof e.name||Object(u.a)(0,"Must provide name."),null==e.isTypeOf||"function"==typeof e.isTypeOf||Object(u.a)(0,"".concat(this.name,' must provide "isTypeOf" as a function, ')+"but got: ".concat(Object(i.a)(e.isTypeOf),"."))}var t=e.prototype;return t.getFields=function(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields},t.getInterfaces=function(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces},t.toConfig=function(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:fe(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes||[]}},t.toString=function(){return this.name},e}();function ue(e){var t=ie(e.interfaces)||[];return Array.isArray(t)||Object(u.a)(0,"".concat(e.name," interfaces must be an Array or a function which returns an Array.")),t}function ce(e){var t=ie(e.fields)||{};return le(t)||Object(u.a)(0,"".concat(e.name," fields must be an object with field names as keys or a function which returns such an object.")),Object(a.a)(t,(function(t,n){le(t)||Object(u.a)(0,"".concat(e.name,".").concat(n," field config must be an object")),!("isDeprecated"in t)||Object(u.a)(0,"".concat(e.name,".").concat(n,' should provide "deprecationReason" instead of "isDeprecated".')),null==t.resolve||"function"==typeof t.resolve||Object(u.a)(0,"".concat(e.name,".").concat(n," field resolver must be a function if ")+"provided, but got: ".concat(Object(i.a)(t.resolve),"."));var o=t.args||{};le(o)||Object(u.a)(0,"".concat(e.name,".").concat(n," args must be an object with argument names as keys."));var a=Object(r.a)(o).map((function(e){var t=e[0],n=e[1];return{name:t,description:void 0===n.description?null:n.description,type:n.type,defaultValue:n.defaultValue,extensions:n.extensions&&Object(s.a)(n.extensions),astNode:n.astNode}}));return g({},t,{name:n,description:t.description,type:t.type,args:a,resolve:t.resolve,subscribe:t.subscribe,isDeprecated:Boolean(t.deprecationReason),deprecationReason:t.deprecationReason,extensions:t.extensions&&Object(s.a)(t.extensions),astNode:t.astNode})}))}function le(e){return Object(f.a)(e)&&!Array.isArray(e)}function fe(e){return Object(a.a)(e,(function(e){return{description:e.description,type:e.type,args:pe(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode}}))}function pe(e){return Object(c.a)(e,(function(e){return e.name}),(function(e){return{description:e.description,type:e.type,defaultValue:e.defaultValue,extensions:e.extensions,astNode:e.astNode}}))}function de(e){return R(e.type)&&void 0===e.defaultValue}Object(h.a)(se),Object(d.a)(se);var he=function(){function e(e){this.name=e.name,this.description=e.description,this.resolveType=e.resolveType,this.extensions=e.extensions&&Object(s.a)(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=oe(e.extensionASTNodes),this._fields=ce.bind(void 0,e),"string"==typeof e.name||Object(u.a)(0,"Must provide name."),null==e.resolveType||"function"==typeof e.resolveType||Object(u.a)(0,"".concat(this.name,' must provide "resolveType" as a function, ')+"but got: ".concat(Object(i.a)(e.resolveType),"."))}var t=e.prototype;return t.getFields=function(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields},t.toConfig=function(){return{name:this.name,description:this.description,fields:fe(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes||[]}},t.toString=function(){return this.name},e}();Object(h.a)(he),Object(d.a)(he);var me=function(){function e(e){this.name=e.name,this.description=e.description,this.resolveType=e.resolveType,this.extensions=e.extensions&&Object(s.a)(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=oe(e.extensionASTNodes),this._types=ve.bind(void 0,e),"string"==typeof e.name||Object(u.a)(0,"Must provide name."),null==e.resolveType||"function"==typeof e.resolveType||Object(u.a)(0,"".concat(this.name,' must provide "resolveType" as a function, ')+"but got: ".concat(Object(i.a)(e.resolveType),"."))}var t=e.prototype;return t.getTypes=function(){return"function"==typeof this._types&&(this._types=this._types()),this._types},t.toConfig=function(){return{name:this.name,description:this.description,types:this.getTypes(),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes||[]}},t.toString=function(){return this.name},e}();function ve(e){var t=ie(e.types)||[];return Array.isArray(t)||Object(u.a)(0,"Must provide Array of types or a function which returns such an array for Union ".concat(e.name,".")),t}Object(h.a)(me),Object(d.a)(me);var ye=function(){function e(e){var t,n;this.name=e.name,this.description=e.description,this.extensions=e.extensions&&Object(s.a)(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=oe(e.extensionASTNodes),this._values=(t=this.name,le(n=e.values)||Object(u.a)(0,"".concat(t," values must be an object with value names as keys.")),Object(r.a)(n).map((function(e){var n=e[0],r=e[1];return le(r)||Object(u.a)(0,"".concat(t,".").concat(n,' must refer to an object with a "value" key ')+"representing an internal value but got: ".concat(Object(i.a)(r),".")),!("isDeprecated"in r)||Object(u.a)(0,"".concat(t,".").concat(n,' should provide "deprecationReason" instead of "isDeprecated".')),{name:n,description:r.description,value:"value"in r?r.value:n,isDeprecated:Boolean(r.deprecationReason),deprecationReason:r.deprecationReason,extensions:r.extensions&&Object(s.a)(r.extensions),astNode:r.astNode}}))),this._valueLookup=new Map(this._values.map((function(e){return[e.value,e]}))),this._nameLookup=Object(o.a)(this._values,(function(e){return e.name})),"string"==typeof e.name||Object(u.a)(0,"Must provide name.")}var t=e.prototype;return t.getValues=function(){return this._values},t.getValue=function(e){return this._nameLookup[e]},t.serialize=function(e){var t=this._valueLookup.get(e);if(t)return t.name},t.parseValue=function(e){if("string"==typeof e){var t=this.getValue(e);if(t)return t.value}},t.parseLiteral=function(e,t){if(e.kind===m.Kind.ENUM){var n=this.getValue(e.value);if(n)return n.value}},t.toConfig=function(){var e=Object(c.a)(this.getValues(),(function(e){return e.name}),(function(e){return{description:e.description,value:e.value,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode}}));return{name:this.name,description:this.description,values:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes||[]}},t.toString=function(){return this.name},e}();Object(h.a)(ye),Object(d.a)(ye);var ge=function(){function e(e){this.name=e.name,this.description=e.description,this.extensions=e.extensions&&Object(s.a)(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=oe(e.extensionASTNodes),this._fields=be.bind(void 0,e),"string"==typeof e.name||Object(u.a)(0,"Must provide name.")}var t=e.prototype;return t.getFields=function(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields},t.toConfig=function(){var e=Object(a.a)(this.getFields(),(function(e){return{description:e.description,type:e.type,defaultValue:e.defaultValue,extensions:e.extensions,astNode:e.astNode}}));return{name:this.name,description:this.description,fields:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes||[]}},t.toString=function(){return this.name},e}();function be(e){var t=ie(e.fields)||{};return le(t)||Object(u.a)(0,"".concat(e.name," fields must be an object with field names as keys or a function which returns such an object.")),Object(a.a)(t,(function(t,n){return!("resolve"in t)||Object(u.a)(0,"".concat(e.name,".").concat(n," field has a resolve property, but Input Types cannot define resolvers.")),g({},t,{name:n,description:t.description,type:t.type,defaultValue:t.defaultValue,extensions:t.extensions&&Object(s.a)(t.extensions),astNode:t.astNode})}))}function Oe(e){return R(e.type)&&void 0===e.defaultValue}Object(h.a)(ge),Object(d.a)(ge)},function(e,t,n){"use strict";n.r(t),n.d(t,"Kind",(function(){return r}));var r=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"})},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(37);function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var o=10,a=2;function s(e){return u(e,[])}function u(e,t){switch(i(e)){case"string":return JSON.stringify(e);case"function":return e.name?"[function ".concat(e.name,"]"):"[function]";case"object":return null===e?"null":function(e,t){if(-1!==t.indexOf(e))return"[Circular]";var n=[].concat(t,[e]),i=function(e){var t=e[String(r.a)];if("function"==typeof t)return t;if("function"==typeof e.inspect)return e.inspect}(e);if(void 0!==i){var s=i.call(e);if(s!==e)return"string"==typeof s?s:u(s,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>a)return"[Array]";for(var n=Math.min(o,e.length),r=e.length-n,i=[],s=0;s1&&i.push("... ".concat(r," more items"));return"["+i.join(", ")+"]"}(e,n);return function(e,t){var n=Object.keys(e);if(0===n.length)return"{}";if(t.length>a)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){var n=e.constructor.name;if("string"==typeof n&&""!==n)return n}return t}(e)+"]";return"{ "+n.map((function(n){return n+": "+u(e[n],t)})).join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return s}));var r=n(15),i=n(38),o=n(61);function a(e,t,n,o,s,u,c){var l=Array.isArray(t)?0!==t.length?t:void 0:t?[t]:void 0,f=n;if(!f&&l){var p=l[0];f=p&&p.loc&&p.loc.source}var d,h=o;!h&&l&&(h=l.reduce((function(e,t){return t.loc&&e.push(t.loc.start),e}),[])),h&&0===h.length&&(h=void 0),o&&n?d=o.map((function(e){return Object(i.a)(n,e)})):l&&(d=l.reduce((function(e,t){return t.loc&&e.push(Object(i.a)(t.loc.source,t.loc.start)),e}),[]));var m=c;if(null==m&&null!=u){var v=u.extensions;Object(r.a)(v)&&(m=v)}Object.defineProperties(this,{message:{value:e,enumerable:!0,writable:!0},locations:{value:d||void 0,enumerable:Boolean(d)},path:{value:s||void 0,enumerable:Boolean(s)},nodes:{value:l||void 0},source:{value:f||void 0},positions:{value:h||void 0},originalError:{value:u},extensions:{value:m||void 0,enumerable:Boolean(m)}}),u&&u.stack?Object.defineProperty(this,"stack",{value:u.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,a):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}function s(e){var t=e.message;if(e.nodes)for(var n=0,r=e.nodes;n=15&&(p=!1,c=!0);var w=b&&(l||p&&(null==T||T<12.11)),_=n||s&&u>=9;function k(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var x,S=function(e,t){var n=e.className,r=k(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}};function C(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function N(e,t){return C(e).appendChild(t)}function D(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o=t)return a+(t-o);a+=s-o,a+=n-a%n,o=s+1}}v?R=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:s&&(R=function(e){try{e.select()}catch(e){}});var U=function(){this.id=null,this.f=null,this.time=0,this.handler=M(this.onTimeout,this)};function B(e,t){for(var n=0;n=t)return r+Math.min(a,t-i);if(i+=o-r,r=o+1,(i+=n-i%n)>=t)return r}}var W=[""];function Y(e){for(;W.length<=e;)W.push(J(W)+" ");return W[e]}function J(e){return e[e.length-1]}function $(e,t){for(var n=[],r=0;r"€"&&(e.toUpperCase()!=e.toLowerCase()||ee.test(e))}function ne(e,t){return t?!!(t.source.indexOf("\\w")>-1&&te(e))||t.test(e):te(e)}function re(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ie=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function oe(e){return e.charCodeAt(0)>=768&&ie.test(e)}function ae(e,t,n){for(;(n<0?t>0:tn?-1:1;;){if(t==n)return t;var i=(t+n)/2,o=r<0?Math.ceil(i):Math.floor(i);if(o==t)return e(o)?t:n;e(o)?n=o:t=o+r}}var ue=null;function ce(e,t,n){var r;ue=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==n?r=i:ue=i),o.from==t&&(o.from!=o.to&&"before"!=n?r=i:ue=i)}return null!=r?r:ue}var le=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",n=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,r=/[stwN]/,i=/[LRr]/,o=/[Lb1n]/,a=/[1n]/;function s(e,t,n){this.level=e,this.from=t,this.to=n}return function(u,c){var l="ltr"==c?"L":"R";if(0==u.length||"ltr"==c&&!n.test(u))return!1;for(var f,p=u.length,d=[],h=0;h-1&&(r[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function ve(e,t){var n=he(e,t);if(n.length)for(var r=Array.prototype.slice.call(arguments,2),i=0;i0}function Oe(e){e.prototype.on=function(e,t){de(this,e,t)},e.prototype.off=function(e,t){me(this,e,t)}}function Ee(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Te(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function we(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function _e(e){Ee(e),Te(e)}function ke(e){return e.target||e.srcElement}function xe(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),b&&e.ctrlKey&&1==t&&(t=3),t}var Se,Ce,Ne=function(){if(s&&u<9)return!1;var e=D("div");return"draggable"in e||"dragDrop"in e}();function De(e){if(null==Se){var t=D("span","​");N(e,D("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Se=t.offsetWidth<=1&&t.offsetHeight>2&&!(s&&u<8))}var n=Se?D("span","​"):D("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function je(e){if(null!=Ce)return Ce;var t=N(e,document.createTextNode("AخA")),n=x(t,0,1).getBoundingClientRect(),r=x(t,1,2).getBoundingClientRect();return C(e),!(!n||n.left==n.right)&&(Ce=r.right-n.right<3)}var Ae,Le=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;t<=r;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),a=o.indexOf("\r");-1!=a?(n.push(o.slice(0,a)),t+=a+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},Ie=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Fe="oncopy"in(Ae=D("div"))||(Ae.setAttribute("oncopy","return;"),"function"==typeof Ae.oncopy),Re=null,Me={},Pe={};function Ve(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Me[e]=t}function Ue(e){if("string"==typeof e&&Pe.hasOwnProperty(e))e=Pe[e];else if(e&&"string"==typeof e.name&&Pe.hasOwnProperty(e.name)){var t=Pe[e.name];"string"==typeof t&&(t={name:t}),(e=Z(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ue("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ue("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Be(e,t){t=Ue(t);var n=Me[t.name];if(!n)return Be(e,"text/plain");var r=n(e,t);if(qe.hasOwnProperty(t.name)){var i=qe[t.name];for(var o in i)i.hasOwnProperty(o)&&(r.hasOwnProperty(o)&&(r["_"+o]=r[o]),r[o]=i[o])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)r[a]=t.modeProps[a];return r}var qe={};function Ke(e,t){P(t,qe.hasOwnProperty(e)?qe[e]:qe[e]={})}function He(e,t){if(!0===t)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function ze(e,t){for(var n;e.innerMode&&(n=e.innerMode(t))&&n.mode!=e;)t=n.state,e=n.mode;return n||{mode:e,state:t}}function Ge(e,t,n){return!e.startState||e.startState(t,n)}var Qe=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};function We(e,t){if((t-=e.first)<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(t=e.first&&tn?nt(n,We(e,n).text.length):function(e,t){var n=e.ch;return null==n||n>t?nt(e.line,t):n<0?nt(e.line,0):e}(t,We(e,t.line).text.length)}function lt(e,t){for(var n=[],r=0;r=this.string.length},Qe.prototype.sol=function(){return this.pos==this.lineStart},Qe.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Qe.prototype.next=function(){if(this.post},Qe.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Qe.prototype.skipToEnd=function(){this.pos=this.string.length},Qe.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Qe.prototype.backUp=function(e){this.pos-=e},Qe.prototype.column=function(){return this.lastColumnPos0?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}var i=function(e){return n?e.toLowerCase():e};if(i(this.string.substr(this.pos,e.length))==i(e))return!1!==t&&(this.pos+=e.length),!0},Qe.prototype.current=function(){return this.string.slice(this.start,this.pos)},Qe.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Qe.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Qe.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var ft=function(e,t){this.state=e,this.lookAhead=t},pt=function(e,t,n,r){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};function dt(e,t,n,r){var i=[e.state.modeGen],o={};Tt(e,t.text,e.doc.mode,n,(function(e,t){return i.push(e,t)}),o,r);for(var a=n.state,s=function(r){n.baseTokens=i;var s=e.state.overlays[r],u=1,c=0;n.state=!0,Tt(e,t.text,s.mode,n,(function(e,t){for(var n=u;ce&&i.splice(u,1,e,i[u+1],r),u+=2,c=Math.min(e,r)}if(t)if(s.opaque)i.splice(n,u-n,e,"overlay "+t),u=n+2;else for(;ne.options.maxHighlightLength&&He(e.doc.mode,r.state),o=dt(e,t,r);i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function mt(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return new pt(r,!0,t);var o=function(e,t,n){for(var r,i,o=e.doc,a=n?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>a;--s){if(s<=o.first)return o.first;var u=We(o,s-1),c=u.stateAfter;if(c&&(!n||s+(c instanceof ft?c.lookAhead:0)<=o.modeFrontier))return s;var l=V(u.text,null,e.options.tabSize);(null==i||r>l)&&(i=s-1,r=l)}return i}(e,t,n),a=o>r.first&&We(r,o-1).stateAfter,s=a?pt.fromSaved(r,a,o):new pt(r,Ge(r.mode),o);return r.iter(o,t,(function(n){vt(e,n.text,s);var r=s.line;n.stateAfter=r==t-1||r%5==0||r>=i.viewFrom&&rt.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}pt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},pt.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},pt.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},pt.fromSaved=function(e,t,n){return t instanceof ft?new pt(e,He(e.mode,t.state),n,t.lookAhead):new pt(e,He(e.mode,t),n)},pt.prototype.save=function(e){var t=!1!==e?He(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new ft(t,this.maxLookAhead):t};var bt=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function Ot(e,t,n,r){var i,o,a=e.doc,s=a.mode,u=We(a,(t=ct(a,t)).line),c=mt(e,t.line,n),l=new Qe(u.text,e.options.tabSize,c);for(r&&(o=[]);(r||l.pose.options.maxHighlightLength?(s=!1,a&&vt(e,t,r,f.pos),f.pos=t.length,u=null):u=Et(gt(n,f,r.state,p),o),p){var d=p[0].name;d&&(u="m-"+(u?d+" "+u:d))}if(!s||l!=u){for(;c=t:o.to>t);(r||(r=[])).push(new kt(a,o.from,s?null:o.to))}}return r}(n,i,a),u=function(e,t,n){var r;if(e)for(var i=0;i=t:o.to>t)||o.from==t&&"bookmark"==a.type&&(!n||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from0&&s)for(var b=0;bt)&&(!n||It(n,o.marker)<0)&&(n=o.marker)}return n}function Vt(e,t,n,r,i){var o=We(e,t),a=_t&&o.markedSpans;if(a)for(var s=0;s=0&&f<=0||l<=0&&f>=0)&&(l<=0&&(u.marker.inclusiveRight&&i.inclusiveLeft?rt(c.to,n)>=0:rt(c.to,n)>0)||l>=0&&(u.marker.inclusiveRight&&i.inclusiveLeft?rt(c.from,r)<=0:rt(c.from,r)<0)))return!0}}}function Ut(e){for(var t;t=Rt(e);)e=t.find(-1,!0).line;return e}function Bt(e,t){var n=We(e,t),r=Ut(n);return n==r?t:Xe(r)}function qt(e,t){if(t>e.lastLine())return t;var n,r=We(e,t);if(!Kt(e,r))return t;for(;n=Mt(r);)r=n.find(1,!0).line;return Xe(r)+1}function Kt(e,t){var n=_t&&t.markedSpans;if(n)for(var r=void 0,i=0;it.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)}))}var Wt=function(e,t,n){this.text=e,jt(this,t),this.height=n?n(this):1};function Yt(e){e.parent=null,Dt(e)}Wt.prototype.lineNo=function(){return Xe(this)},Oe(Wt);var Jt={},$t={};function Xt(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?$t:Jt;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Zt(e,t){var n=j("span",null,null,c?"padding-right: .1px":null),r={pre:j("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o=i?t.rest[i-1]:t.line,a=void 0;r.pos=0,r.addToken=tn,je(e.display.measure)&&(a=fe(o,e.doc.direction))&&(r.addToken=nn(r.addToken,a)),r.map=[],on(o,r,ht(e,o,t!=e.display.externalMeasured&&Xe(o))),o.styleClasses&&(o.styleClasses.bgClass&&(r.bgClass=F(o.styleClasses.bgClass,r.bgClass||"")),o.styleClasses.textClass&&(r.textClass=F(o.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(De(e.display.measure))),0==i?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(c){var s=r.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return ve(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=F(r.pre.className,r.textClass||"")),r}function en(e){var t=D("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function tn(e,t,n,r,i,o,a){if(t){var c,l=e.splitSpaces?function(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,r="",i=0;ic&&f.from<=c);p++);if(f.to>=l)return e(n,r,i,o,a,s,u);e(n,r.slice(0,f.to-c),i,o,null,s,u),o=null,r=r.slice(f.to-c),c=f.to}}}function rn(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function on(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(r)for(var a,s,u,c,l,f,p,d=i.length,h=0,m=1,v="",y=0;;){if(y==h){u=c=l=s="",p=null,f=null,y=1/0;for(var g=[],b=void 0,O=0;Oh||T.collapsed&&E.to==h&&E.from==h)){if(null!=E.to&&E.to!=h&&y>E.to&&(y=E.to,c=""),T.className&&(u+=" "+T.className),T.css&&(s=(s?s+";":"")+T.css),T.startStyle&&E.from==h&&(l+=" "+T.startStyle),T.endStyle&&E.to==y&&(b||(b=[])).push(T.endStyle,E.to),T.title&&((p||(p={})).title=T.title),T.attributes)for(var w in T.attributes)(p||(p={}))[w]=T.attributes[w];T.collapsed&&(!f||It(f.marker,T)<0)&&(f=E)}else E.from>h&&y>E.from&&(y=E.from)}if(b)for(var _=0;_=d)break;for(var x=Math.min(d,y);;){if(v){var S=h+v.length;if(!f){var C=S>x?v.slice(0,x-h):v;t.addToken(t,C,a?a+u:u,l,h+C.length==y?c:"",s,p)}if(S>=x){v=v.slice(x-h),h=x;break}h=S,l=""}v=i.slice(o,o=n[m++]),a=Xt(n[m++],t.cm.options)}}else for(var N=1;Nn)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function An(e,t,n,r){return Fn(e,In(e,t),n,r)}function Ln(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&t2&&o.push((u.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}(e,t.view,t.rect),t.hasHeights=!0),(o=function(e,t,n,r){var i,o=Pn(t.map,n,r),a=o.node,c=o.start,l=o.end,f=o.collapse;if(3==a.nodeType){for(var p=0;p<4;p++){for(;c&&oe(t.line.text.charAt(o.coverStart+c));)--c;for(;o.coverStart+l1}(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}(e.display.measure,i))}else{var d;c>0&&(f=r="right"),i=e.options.lineWrapping&&(d=a.getClientRects()).length>1?d["right"==r?d.length-1:0]:a.getBoundingClientRect()}if(s&&u<9&&!c&&(!i||!i.left&&!i.right)){var h=a.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+ar(e.display),top:h.top,bottom:h.bottom}:Mn}for(var m=i.top-t.rect.top,v=i.bottom-t.rect.top,y=(m+v)/2,g=t.view.measure.heights,b=0;bt)&&(i=(o=u-s)-1,t>=u&&(a="right")),null!=i){if(r=e[c+2],s==u&&n==(r.insertLeft?"left":"right")&&(a=n),"left"==n&&0==i)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)r=e[2+(c-=3)],a="left";if("right"==n&&i==u-s)for(;c=0&&(n=e[i]).left==n.right;i--);return n}function Un(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t=r.text.length?(u=r.text.length,c="before"):u<=0&&(u=0,c="after"),!s)return a("before"==c?u-1:u,"before"==c);function l(e,t,n){return a(n?e-1:e,1==s[t].level!=n)}var f=ce(s,u,c),p=ue,d=l(u,f,"before"==c);return null!=p&&(d.other=l(u,p,"before"!=c)),d}function Jn(e,t){var n=0;t=ct(e.doc,t),e.options.lineWrapping||(n=ar(e.display)*t.ch);var r=We(e.doc,t.line),i=zt(r)+kn(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function $n(e,t,n,r,i){var o=nt(e,t,n);return o.xRel=i,r&&(o.outside=r),o}function Xn(e,t,n){var r=e.doc;if((n+=e.display.viewOffset)<0)return $n(r.first,0,null,-1,-1);var i=Ze(r,n),o=r.first+r.size-1;if(i>o)return $n(r.first+r.size-1,We(r,o).text.length,null,1,1);t<0&&(t=0);for(var a=We(r,i);;){var s=nr(e,a,i,t,n),u=Pt(a,s.ch+(s.xRel>0||s.outside>0?1:0));if(!u)return s;var c=u.find(1);if(c.line==i)return c;a=We(r,i=c.line)}}function Zn(e,t,n,r){r-=zn(t);var i=t.text.length,o=se((function(t){return Fn(e,n,t-1).bottom<=r}),i,0);return{begin:o,end:i=se((function(t){return Fn(e,n,t).top>r}),o,i)}}function er(e,t,n,r){return n||(n=In(e,t)),Zn(e,t,n,Gn(e,t,Fn(e,n,r),"line").top)}function tr(e,t,n,r){return!(e.bottom<=n)&&(e.top>n||(r?e.left:e.right)>t)}function nr(e,t,n,r,i){i-=zt(t);var o=In(e,t),a=zn(t),s=0,u=t.text.length,c=!0,l=fe(t,e.doc.direction);if(l){var f=(e.options.lineWrapping?ir:rr)(e,t,n,o,l,r,i);s=(c=1!=f.level)?f.from:f.to-1,u=c?f.to:f.from-1}var p,d,h=null,m=null,v=se((function(t){var n=Fn(e,o,t);return n.top+=a,n.bottom+=a,!!tr(n,r,i,!1)&&(n.top<=i&&n.left<=r&&(h=t,m=n),!0)}),s,u),y=!1;if(m){var g=r-m.left=O.bottom?1:0}return $n(n,v=ae(t.text,v,1),d,y,r-p)}function rr(e,t,n,r,i,o,a){var s=se((function(s){var u=i[s],c=1!=u.level;return tr(Yn(e,nt(n,c?u.to:u.from,c?"before":"after"),"line",t,r),o,a,!0)}),0,i.length-1),u=i[s];if(s>0){var c=1!=u.level,l=Yn(e,nt(n,c?u.from:u.to,c?"after":"before"),"line",t,r);tr(l,o,a,!0)&&l.top>a&&(u=i[s-1])}return u}function ir(e,t,n,r,i,o,a){var s=Zn(e,t,r,a),u=s.begin,c=s.end;/\s/.test(t.text.charAt(c-1))&&c--;for(var l=null,f=null,p=0;p=c||d.to<=u)){var h=Fn(e,r,1!=d.level?Math.min(c,d.to)-1:Math.max(u,d.from)).right,m=hm)&&(l=d,f=m)}}return l||(l=i[i.length-1]),l.fromc&&(l={from:l.from,to:c,level:l.level}),l}function or(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Rn){Rn=D("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Rn.appendChild(document.createTextNode("x")),Rn.appendChild(D("br"));Rn.appendChild(document.createTextNode("x"))}N(e.measure,Rn);var n=Rn.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),C(e.measure),n||1}function ar(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=D("span","xxxxxxxxxx"),n=D("pre",[t],"CodeMirror-line-like");N(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function sr(e){for(var t=e.display,n={},r={},i=t.gutters.clientLeft,o=t.gutters.firstChild,a=0;o;o=o.nextSibling,++a){var s=e.display.gutterSpecs[a].className;n[s]=o.offsetLeft+o.clientLeft+i,r[s]=o.clientWidth}return{fixedPos:ur(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function ur(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function cr(e){var t=or(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/ar(e.display)-3);return function(i){if(Kt(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;a=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var n=e.display.view,r=0;rt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)_t&&Bt(e.doc,t)i.viewFrom?mr(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)mr(e);else if(t<=i.viewFrom){var o=vr(e,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):mr(e)}else if(n>=i.viewTo){var a=vr(e,t,t,-1);a?(i.view=i.view.slice(0,a.index),i.viewTo=a.lineN):mr(e)}else{var s=vr(e,t,t,-1),u=vr(e,n,n+r,1);s&&u?(i.view=i.view.slice(0,s.index).concat(sn(e,s.lineN,u.lineN)).concat(i.view.slice(u.index)),i.viewTo+=r):mr(e)}var c=i.externalMeasured;c&&(n=i.lineN&&t=r.viewTo)){var o=r.view[pr(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==B(a,n)&&a.push(n)}}}function mr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function vr(e,t,n,r){var i,o=pr(e,t),a=e.display.view;if(!_t||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var s=e.display.viewFrom,u=0;u0){if(o==a.length-1)return null;i=s+a[o].size-t,o++}else i=s-t;t+=i,n+=i}for(;Bt(e.doc,n)!=n;){if(o==(r<0?0:a.length-1))return null;n+=r*a[o-(r<0?1:0)].size,o+=r}return{index:o,lineN:n}}function yr(e){for(var t=e.display.view,n=0,r=0;r=e.display.viewTo||s.to().linet||t==n&&a.to==t)&&(r(Math.max(a.from,t),Math.min(a.to,n),1==a.level?"rtl":"ltr",o),i=!0)}i||r(t,n,"ltr")}(m,n||0,null==r?p:r,(function(e,t,i,f){var v="ltr"==i,y=d(e,v?"left":"right"),g=d(t-1,v?"right":"left"),b=null==n&&0==e,O=null==r&&t==p,E=0==f,T=!m||f==m.length-1;if(g.top-y.top<=3){var w=(c?O:b)&&T,_=(c?b:O)&&E?s:(v?y:g).left,k=w?u:(v?g:y).right;l(_,y.top,k-_,y.bottom)}else{var x,S,C,N;v?(x=c&&b&&E?s:y.left,S=c?u:h(e,i,"before"),C=c?s:h(t,i,"after"),N=c&&O&&T?u:g.right):(x=c?h(e,i,"before"):s,S=!c&&b&&E?u:y.right,C=!c&&O&&T?s:g.left,N=c?h(t,i,"after"):u),l(x,y.top,S-x,y.bottom),y.bottom0?t.blinker=setInterval((function(){return t.cursorDiv.style.visibility=(n=!n)?"":"hidden"}),e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function _r(e){e.state.focused||(e.display.input.focus(),xr(e))}function kr(e){e.state.delayingBlurEvent=!0,setTimeout((function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Sr(e))}),100)}function xr(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(ve(e,"focus",e,t),e.state.focused=!0,I(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),c&&setTimeout((function(){return e.display.input.reset(!0)}),20)),e.display.input.receivedFocus()),wr(e))}function Sr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(ve(e,"blur",e,t),e.state.focused=!1,S(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout((function(){e.state.focused||(e.display.shift=!1)}),150))}function Cr(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r.005||p<-.005)&&($e(i.line,a),Nr(i.line),i.rest))for(var d=0;de.display.sizerWidth){var h=Math.ceil(c/ar(e.display));h>e.display.maxLineLength&&(e.display.maxLineLength=h,e.display.maxLine=i.line,e.display.maxLineChanged=!0)}}}}function Nr(e){if(e.widgets)for(var t=0;t=a&&(o=Ze(t,zt(We(t,u))-e.wrapper.clientHeight),a=u)}return{from:o,to:Math.max(a,o+1)}}function jr(e,t){var n=e.display,r=or(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:n.scroller.scrollTop,o=Dn(e),a={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s=e.doc.height+xn(n),u=t.tops-r;if(t.topi+o){var l=Math.min(t.top,(c?s:t.bottom)-o);l!=i&&(a.scrollTop=l)}var f=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft,p=Nn(e)-(e.options.fixedGutter?n.gutters.offsetWidth:0),d=t.right-t.left>p;return d&&(t.right=t.left+p),t.left<10?a.scrollLeft=0:t.leftp+f-3&&(a.scrollLeft=t.right+(d?0:10)-p),a}function Ar(e,t){null!=t&&(Fr(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Lr(e){Fr(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Ir(e,t,n){null==t&&null==n||Fr(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function Fr(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Rr(e,Jn(e,t.from),Jn(e,t.to),t.margin))}function Rr(e,t,n,r){var i=jr(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});Ir(e,i.scrollLeft,i.scrollTop)}function Mr(e,t){Math.abs(e.doc.scrollTop-t)<2||(n||li(e,{top:t}),Pr(e,t,!0),n&&li(e),oi(e,100))}function Pr(e,t,n){t=Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t),(e.display.scroller.scrollTop!=t||n)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function Vr(e,t,n,r){t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r||(e.doc.scrollLeft=t,di(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Ur(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+xn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+Cn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var Br=function(e,t,n){this.cm=n;var r=this.vert=D("div",[D("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=D("div",[D("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,e(r),e(i),de(r,"scroll",(function(){r.clientHeight&&t(r.scrollTop,"vertical")})),de(i,"scroll",(function(){i.clientWidth&&t(i.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,s&&u<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Br.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:t?r:0}},Br.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Br.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Br.prototype.zeroWidthHack=function(){var e=b&&!h?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new U,this.disableVert=new U},Br.prototype.enableZeroWidthBar=function(e,t,n){e.style.pointerEvents="auto",t.set(1e3,(function r(){var i=e.getBoundingClientRect();("vert"==n?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1))!=e?e.style.pointerEvents="none":t.set(1e3,r)}))},Br.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var qr=function(){};function Kr(e,t){t||(t=Ur(e));var n=e.display.barWidth,r=e.display.barHeight;Hr(e,t);for(var i=0;i<4&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&Cr(e),Hr(e,Ur(e)),n=e.display.barWidth,r=e.display.barHeight}function Hr(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}qr.prototype.update=function(){return{bottom:0,right:0}},qr.prototype.setScrollLeft=function(){},qr.prototype.setScrollTop=function(){},qr.prototype.clear=function(){};var zr={native:Br,null:qr};function Gr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&S(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new zr[e.options.scrollbarStyle]((function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),de(t,"mousedown",(function(){e.state.focused&&setTimeout((function(){return e.display.input.focus()}),0)})),t.setAttribute("cm-not-content","true")}),(function(t,n){"horizontal"==n?Vr(e,t):Mr(e,t)}),e),e.display.scrollbars.addClass&&I(e.display.wrapper,e.display.scrollbars.addClass)}var Qr=0;function Wr(e){var t;e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Qr},t=e.curOp,un?un.ops.push(t):t.ownsGroup=un={ops:[t],delayedCallbacks:[]}}function Yr(e){var t=e.curOp;t&&function(e,t){var n=e.ownsGroup;if(n)try{!function(e){var t=e.delayedCallbacks,n=0;do{for(;n=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new si(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function $r(e){e.updatedDisplay=e.mustUpdate&&ui(e.cm,e.update)}function Xr(e){var t=e.cm,n=t.display;e.updatedDisplay&&Cr(t),e.barMeasure=Ur(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=An(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Cn(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-Nn(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function Zr(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!m){var o=D("div","​",null,"position: absolute;\n top: "+(t.top-n.viewOffset-kn(e.display))+"px;\n height: "+(t.bottom-t.top+Cn(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}(t,function(e,t,n,r){var i;null==r&&(r=0),e.options.lineWrapping||t!=n||(n="before"==(t=t.ch?nt(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t).sticky?nt(t.line,t.ch+1,"before"):t);for(var o=0;o<5;o++){var a=!1,s=Yn(e,t),u=n&&n!=t?Yn(e,n):s,c=jr(e,i={left:Math.min(s.left,u.left),top:Math.min(s.top,u.top)-r,right:Math.max(s.left,u.left),bottom:Math.max(s.bottom,u.bottom)+r}),l=e.doc.scrollTop,f=e.doc.scrollLeft;if(null!=c.scrollTop&&(Mr(e,c.scrollTop),Math.abs(e.doc.scrollTop-l)>1&&(a=!0)),null!=c.scrollLeft&&(Vr(e,c.scrollLeft),Math.abs(e.doc.scrollLeft-f)>1&&(a=!0)),!a)break}return i}(t,ct(r,e.scrollToPos.from),ct(r,e.scrollToPos.to),e.scrollToPos.margin));var i=e.maybeHiddenMarkers,o=e.maybeUnhiddenMarkers;if(i)for(var a=0;a=e.display.viewTo)){var n=+new Date+e.options.workTime,r=mt(e,t.highlightFrontier),i=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),(function(o){if(r.line>=e.display.viewFrom){var a=o.styles,s=o.text.length>e.options.maxHighlightLength?He(t.mode,r.state):null,u=dt(e,o,r,!0);s&&(r.state=s),o.styles=u.styles;var c=o.styleClasses,l=u.classes;l?o.styleClasses=l:c&&(o.styleClasses=null);for(var f=!a||a.length!=o.styles.length||c!=l&&(!c||!l||c.bgClass!=l.bgClass||c.textClass!=l.textClass),p=0;!f&&pn)return oi(e,e.options.workDelay),!0})),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),i.length&&ti(e,(function(){for(var t=0;t=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==yr(e))return!1;hi(e)&&(mr(e),t.dims=sr(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),a=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFroma&&n.viewTo-a<20&&(a=Math.min(i,n.viewTo)),_t&&(o=Bt(e.doc,o),a=qt(e.doc,a));var s=o!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;!function(e,t,n){var r=e.display;0==r.view.length||t>=r.viewTo||n<=r.viewFrom?(r.view=sn(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=sn(e,t,r.viewFrom).concat(r.view):r.viewFromn&&(r.view=r.view.slice(0,pr(e,n)))),r.viewTo=n}(e,o,a),n.viewOffset=zt(We(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var u=yr(e);if(!s&&0==u&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var l=function(e){if(e.hasFocus())return null;var t=L();if(!t||!A(e.display.lineDiv,t))return null;var n={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&A(e.display.lineDiv,r.anchorNode)&&(n.anchorNode=r.anchorNode,n.anchorOffset=r.anchorOffset,n.focusNode=r.focusNode,n.focusOffset=r.focusOffset)}return n}(e);return u>4&&(n.lineDiv.style.display="none"),function(e,t,n){var r=e.display,i=e.options.lineNumbers,o=r.lineDiv,a=o.firstChild;function s(t){var n=t.nextSibling;return c&&b&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}for(var u=r.view,l=r.viewFrom,f=0;f-1&&(d=!1),pn(e,p,l,n)),d&&(C(p.lineNumber),p.lineNumber.appendChild(document.createTextNode(tt(e.options,l)))),a=p.node.nextSibling}else{var h=bn(e,p,l,n);o.insertBefore(h,a)}l+=p.size}for(;a;)a=s(a)}(e,n.updateLineNumbers,t.dims),u>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,function(e){if(e&&e.activeElt&&e.activeElt!=L()&&(e.activeElt.focus(),e.anchorNode&&A(document.body,e.anchorNode)&&A(document.body,e.focusNode))){var t=window.getSelection(),n=document.createRange();n.setEnd(e.anchorNode,e.anchorOffset),n.collapse(!1),t.removeAllRanges(),t.addRange(n),t.extend(e.focusNode,e.focusOffset)}}(l),C(n.cursorDiv),C(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,s&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,oi(e,400)),n.updateLineNumbers=null,!0}function ci(e,t){for(var n=t.viewport,r=!0;(r&&e.options.lineWrapping&&t.oldDisplayWidth!=Nn(e)||(n&&null!=n.top&&(n={top:Math.min(e.doc.height+xn(e.display)-Dn(e),n.top)}),t.visible=Dr(e.display,e.doc,n),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&ui(e,t);r=!1){Cr(e);var i=Ur(e);gr(e),Kr(e,i),pi(e,i),t.force=!1}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function li(e,t){var n=new si(e,t);if(ui(e,n)){Cr(e),ci(e,n);var r=Ur(e);gr(e),Kr(e,r),pi(e,r),n.finish()}}function fi(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function pi(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Cn(e)+"px"}function di(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=ur(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",a=0;as.clientWidth,l=s.scrollHeight>s.clientHeight;if(i&&u||o&&l){if(o&&b&&c)e:for(var f=t.target,d=a.view;f!=s;f=f.parentNode)for(var h=0;h=0&&rt(e,r.to())<=0)return n}return-1};var ki=function(e,t){this.anchor=e,this.head=t};function xi(e,t,n){var r=e&&e.options.selectionsMayTouch,i=t[n];t.sort((function(e,t){return rt(e.from(),t.from())})),n=B(t,i);for(var o=1;o0:u>=0){var c=st(s.from(),a.from()),l=at(s.to(),a.to()),f=s.empty()?a.from()==a.head:s.from()==s.head;o<=n&&--n,t.splice(--o,2,new ki(f?l:c,f?c:l))}}return new _i(t,n)}function Si(e,t){return new _i([new ki(e,t||e)],0)}function Ci(e){return e.text?nt(e.from.line+e.text.length-1,J(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function Ni(e,t){if(rt(e,t.from)<0)return e;if(rt(e,t.to)<=0)return Ci(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Ci(t).ch-t.to.ch),nt(n,r)}function Di(e,t){for(var n=[],r=0;r1&&e.remove(s.line+1,h-1),e.insert(s.line+1,y)}ln(e,"change",e,t)}function Ri(e,t,n){!function e(r,i,o){if(r.linked)for(var a=0;as-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=function(e,t){return t?(Bi(e.done),J(e.done)):e.done.length&&!J(e.done).ranges?J(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),J(e.done)):void 0}(i,i.lastOp==r)))a=J(o.changes),0==rt(t.from,t.to)&&0==rt(t.from,a.to)?a.to=Ci(t):o.changes.push(Ui(e,t));else{var u=J(i.done);for(u&&u.ranges||Hi(e.sel,i.done),o={changes:[Ui(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,a||ve(e,"historyAdded")}function Ki(e,t,n,r){var i=e.history,o=r&&r.origin;n==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||function(e,t,n,r){var i=t.charAt(0);return"*"==i||"+"==i&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}(e,o,J(i.done),t))?i.done[i.done.length-1]=t:Hi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&!1!==r.clearRedo&&Bi(i.undone)}function Hi(e,t){var n=J(t);n&&n.ranges&&n.equals(e)||t.push(e)}function zi(e,t,n,r){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),(function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=n.markedSpans),++o}))}function Gi(e){if(!e)return null;for(var t,n=0;n-1&&(J(s)[f]=c[f],delete c[f])}}}return r}function Yi(e,t,n,r){if(r){var i=e.anchor;if(n){var o=rt(t,i)<0;o!=rt(n,i)<0?(i=t,t=n):o!=rt(t,n)<0&&(t=n)}return new ki(i,t)}return new ki(n||t,t)}function Ji(e,t,n,r,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),to(e,new _i([Yi(e.sel.primary(),t,n,i)],0),r)}function $i(e,t,n){for(var r=[],i=e.cm&&(e.cm.display.shift||e.extend),o=0;o=t.ch:s.to>t.ch))){if(i&&(ve(u,"beforeCursorEnter"),u.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!u.atomic)continue;if(n){var f=u.find(r<0?1:-1),p=void 0;if((r<0?l:c)&&(f=uo(e,f,-r,f&&f.line==t.line?o:null)),f&&f.line==t.line&&(p=rt(f,n))&&(r<0?p<0:p>0))return ao(e,f,t,r,i)}var d=u.find(r<0?-1:1);return(r<0?c:l)&&(d=uo(e,d,r,d.line==t.line?o:null)),d?ao(e,d,t,r,i):null}}return t}function so(e,t,n,r,i){var o=r||1,a=ao(e,t,n,o,i)||!i&&ao(e,t,n,o,!0)||ao(e,t,n,-o,i)||!i&&ao(e,t,n,-o,!0);return a||(e.cantEdit=!0,nt(e.first,0))}function uo(e,t,n,r){return n<0&&0==t.ch?t.line>e.first?ct(e,nt(t.line-1)):null:n>0&&t.ch==(r||We(e,t.line)).text.length?t.line0)){var l=[u,1],f=rt(c.from,s.from),p=rt(c.to,s.to);(f<0||!a.inclusiveLeft&&!f)&&l.push({from:c.from,to:s.from}),(p>0||!a.inclusiveRight&&!p)&&l.push({from:s.to,to:c.to}),i.splice.apply(i,l),u+=l.length-3}}return i}(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)po(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text,origin:t.origin});else po(e,t)}}function po(e,t){if(1!=t.text.length||""!=t.text[0]||0!=rt(t.from,t.to)){var n=Di(e,t);qi(e,t,n,e.cm?e.cm.curOp.id:NaN),vo(e,t,n,Ct(e,t));var r=[];Ri(e,(function(e,n){n||-1!=B(r,e.history)||(Oo(e.history,t),r.push(e.history)),vo(e,t,null,Ct(e,t))}))}}function ho(e,t,n){var r=e.cm&&e.cm.state.suppressEdits;if(!r||n){for(var i,o=e.history,a=e.sel,s="undo"==t?o.done:o.undone,u="undo"==t?o.undone:o.done,c=0;c=0;--d){var h=p(d);if(h)return h.v}}}}function mo(e,t){if(0!=t&&(e.first+=t,e.sel=new _i($(e.sel.ranges,(function(e){return new ki(nt(e.anchor.line+t,e.anchor.ch),nt(e.head.line+t,e.head.ch))})),e.sel.primIndex),e.cm)){dr(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;re.lastLine())){if(t.from.lineo&&(t={from:t.from,to:nt(o,We(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Ye(e,t.from,t.to),n||(n=Di(e,t)),e.cm?function(e,t,n){var r=e.doc,i=e.display,o=t.from,a=t.to,s=!1,u=o.line;e.options.lineWrapping||(u=Xe(Ut(We(r,o.line))),r.iter(u,a.line+1,(function(e){if(e==i.maxLine)return s=!0,!0}))),r.sel.contains(t.from,t.to)>-1&&ge(e),Fi(r,t,n,cr(e)),e.options.lineWrapping||(r.iter(u,o.line+t.text.length,(function(e){var t=Gt(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)})),s&&(e.curOp.updateMaxLine=!0)),function(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontiern;r--){var i=We(e,r).stateAfter;if(i&&(!(i instanceof ft)||r+i.lookAhead1||!(this.children[0]instanceof To))){var s=[];this.collapse(s),this.children=[new To(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var a=i.lines.length%25+25,s=a;s10);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;r0||0==a&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=j("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(Vt(e,t.line,t,n,o)||t.line!=n.line&&Vt(e,n.line,t,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");_t=!0}o.addToHistory&&qi(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var s,u=t.line,c=e.cm;if(e.iter(u,n.line+1,(function(e){c&&o.collapsed&&!c.options.lineWrapping&&Ut(e)==c.display.maxLine&&(s=!0),o.collapsed&&u!=t.line&&$e(e,0),function(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}(e,new kt(o,u==t.line?t.ch:null,u==n.line?n.ch:null)),++u})),o.collapsed&&e.iter(t.line,n.line+1,(function(t){Kt(e,t)&&$e(t,0)})),o.clearOnEnter&&de(o,"beforeCursorEnter",(function(){return o.clear()})),o.readOnly&&(wt=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++xo,o.atomic=!0),c){if(s&&(c.curOp.updateMaxLine=!0),o.collapsed)dr(c,t.line,n.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var l=t.line;l<=n.line;l++)hr(c,l,"text");o.atomic&&io(c.doc),ln(c,"markerAdded",c,o)}return o}So.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&Wr(e),be(this,"clear")){var n=this.find();n&&ln(this,"clear",n.from,n.to)}for(var r=null,i=null,o=0;oe.display.maxLineLength&&(e.display.maxLine=c,e.display.maxLineLength=l,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&dr(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&io(e.doc)),e&&ln(e,"markerCleared",e,this,r,i),t&&Yr(e),this.parent&&this.parent.clear()}},So.prototype.find=function(e,t){var n,r;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i=0;u--)fo(this,r[u]);s?eo(this,s):this.cm&&Lr(this.cm)})),undo:ii((function(){ho(this,"undo")})),redo:ii((function(){ho(this,"redo")})),undoSelection:ii((function(){ho(this,"undo",!0)})),redoSelection:ii((function(){ho(this,"redo",!0)})),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=ct(this,e),t=ct(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,(function(o){var a=o.markedSpans;if(a)for(var s=0;s=u.to||null==u.from&&i!=e.line||null!=u.from&&i==t.line&&u.from>=t.ch||n&&!n(u.marker)||r.push(u.marker.parent||u.marker)}++i})),r},getAllMarks:function(){var e=[];return this.iter((function(t){var n=t.markedSpans;if(n)for(var r=0;re)return t=e,!0;e-=o,++n})),ct(this,nt(n,t))},indexFromPos:function(e){var t=(e=ct(this,e)).ch;if(e.linet&&(t=e.from),null!=e.to&&e.to-1)return t.state.draggingText(e),void setTimeout((function(){return t.display.input.focus()}),20);try{var l=e.dataTransfer.getData("Text");if(l){var f;if(t.state.draggingText&&!t.state.draggingText.copy&&(f=t.listSelections()),no(t.doc,Si(n,n)),f)for(var p=0;p=0;t--)yo(e.doc,"",r[t].from,r[t].to,"+delete");Lr(e)}))}function ea(e,t,n){var r=ae(e.text,t+n,n);return r<0||r>e.text.length?null:r}function ta(e,t,n){var r=ea(e,t.ch,n);return null==r?null:new nt(t.line,r,n<0?"after":"before")}function na(e,t,n,r,i){if(e){var o=fe(n,t.doc.direction);if(o){var a,s=i<0?J(o):o[0],u=i<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var c=In(t,n);a=i<0?n.text.length-1:0;var l=Fn(t,c,a).top;a=se((function(e){return Fn(t,c,e).top==l}),i<0==(1==s.level)?s.from:s.to-1,a),"before"==u&&(a=ea(n,a,1))}else a=i<0?s.to:s.from;return new nt(r,a,u)}}return new nt(r,i<0?n.text.length:0,i<0?"before":"after")}zo.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},zo.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},zo.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},zo.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},zo.default=b?zo.macDefault:zo.pcDefault;var ra={selectAll:co,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),H)},killLine:function(e){return Zo(e,(function(t){if(t.empty()){var n=We(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)i=new nt(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),nt(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var a=We(e.doc,i.line-1).text;a&&(i=new nt(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),nt(i.line-1,a.length-1),i,"+transpose"))}n.push(new ki(i,i))}e.setSelections(n)}))},newlineAndIndent:function(e){return ti(e,(function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var r=0;r-1&&(rt((i=a.ranges[i]).from(),t)<0||t.xRel>0)&&(rt(i.to(),t)>0||t.xRel<0)?function(e,t,n,r){var i=e.display,o=!1,a=ni(e,(function(t){c&&(i.scroller.draggable=!1),e.state.draggingText=!1,me(i.wrapper.ownerDocument,"mouseup",a),me(i.wrapper.ownerDocument,"mousemove",l),me(i.scroller,"dragstart",f),me(i.scroller,"drop",a),o||(Ee(t),r.addNew||Ji(e.doc,n,null,null,r.extend),c||s&&9==u?setTimeout((function(){i.wrapper.ownerDocument.body.focus(),i.input.focus()}),20):i.input.focus())})),l=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},f=function(){return o=!0};c&&(i.scroller.draggable=!0),e.state.draggingText=a,a.copy=!r.moveOnDrag,i.scroller.dragDrop&&i.scroller.dragDrop(),de(i.wrapper.ownerDocument,"mouseup",a),de(i.wrapper.ownerDocument,"mousemove",l),de(i.scroller,"dragstart",f),de(i.scroller,"drop",a),kr(e),setTimeout((function(){return i.input.focus()}),20)}(e,r,t,o):function(e,t,n,r){var i=e.display,o=e.doc;Ee(t);var a,s,u=o.sel,c=u.ranges;if(r.addNew&&!r.extend?(s=o.sel.contains(n),a=s>-1?c[s]:new ki(n,n)):(a=o.sel.primary(),s=o.sel.primIndex),"rectangle"==r.unit)r.addNew||(a=new ki(n,n)),n=fr(e,t,!0,!0),s=-1;else{var l=ba(e,n,r.unit);a=r.extend?Yi(a,l.anchor,l.head,r.extend):l}r.addNew?-1==s?(s=c.length,to(o,xi(e,c.concat([a]),s),{scroll:!1,origin:"*mouse"})):c.length>1&&c[s].empty()&&"char"==r.unit&&!r.extend?(to(o,xi(e,c.slice(0,s).concat(c.slice(s+1)),0),{scroll:!1,origin:"*mouse"}),u=o.sel):Xi(o,s,a,z):(s=0,to(o,new _i([a],0),z),u=o.sel);var f=n;function p(t){if(0!=rt(f,t))if(f=t,"rectangle"==r.unit){for(var i=[],c=e.options.tabSize,l=V(We(o,n.line).text,n.ch,c),p=V(We(o,t.line).text,t.ch,c),d=Math.min(l,p),h=Math.max(l,p),m=Math.min(n.line,t.line),v=Math.min(e.lastLine(),Math.max(n.line,t.line));m<=v;m++){var y=We(o,m).text,g=Q(y,d,c);d==h?i.push(new ki(nt(m,g),nt(m,g))):y.length>g&&i.push(new ki(nt(m,g),nt(m,Q(y,h,c))))}i.length||i.push(new ki(n,n)),to(o,xi(e,u.ranges.slice(0,s).concat(i),s),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b,O=a,E=ba(e,t,r.unit),T=O.anchor;rt(E.anchor,T)>0?(b=E.head,T=st(O.from(),E.anchor)):(b=E.anchor,T=at(O.to(),E.head));var w=u.ranges.slice(0);w[s]=function(e,t){var n=t.anchor,r=t.head,i=We(e.doc,n.line);if(0==rt(n,r)&&n.sticky==r.sticky)return t;var o=fe(i);if(!o)return t;var a=ce(o,n.ch,n.sticky),s=o[a];if(s.from!=n.ch&&s.to!=n.ch)return t;var u,c=a+(s.from==n.ch==(1!=s.level)?0:1);if(0==c||c==o.length)return t;if(r.line!=n.line)u=(r.line-n.line)*("ltr"==e.doc.direction?1:-1)>0;else{var l=ce(o,r.ch,r.sticky),f=l-a||(r.ch-n.ch)*(1==s.level?-1:1);u=l==c-1||l==c?f<0:f>0}var p=o[c+(u?-1:0)],d=u==(1==p.level),h=d?p.from:p.to,m=d?"after":"before";return n.ch==h&&n.sticky==m?t:new ki(new nt(n.line,h,m),r)}(e,new ki(ct(o,T),b)),to(o,xi(e,w,s),z)}}var d=i.wrapper.getBoundingClientRect(),h=0;function m(t){e.state.selectingText=!1,h=1/0,t&&(Ee(t),i.input.focus()),me(i.wrapper.ownerDocument,"mousemove",v),me(i.wrapper.ownerDocument,"mouseup",y),o.history.lastSelOrigin=null}var v=ni(e,(function(t){0!==t.buttons&&xe(t)?function t(n){var a=++h,s=fr(e,n,!0,"rectangle"==r.unit);if(s)if(0!=rt(s,f)){e.curOp.focus=L(),p(s);var u=Dr(i,o);(s.line>=u.to||s.lined.bottom?20:0;c&&setTimeout(ni(e,(function(){h==a&&(i.scroller.scrollTop+=c,t(n))})),50)}}(t):m(t)})),y=ni(e,m);e.state.selectingText=y,de(i.wrapper.ownerDocument,"mousemove",v),de(i.wrapper.ownerDocument,"mouseup",y)}(e,r,t,o)}(t,r,o,e):ke(e)==n.scroller&&Ee(e):2==i?(r&&Ji(t.doc,r),setTimeout((function(){return n.input.focus()}),20)):3==i&&(_?t.display.input.onContextMenu(e):kr(t)))}}function ba(e,t,n){if("char"==n)return new ki(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new ki(nt(t.line,0),ct(e.doc,nt(t.line+1,0)));var r=n(e,t);return new ki(r.from,r.to)}function Oa(e,t,n,r){var i,o;if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Ee(t);var a=e.display,s=a.lineDiv.getBoundingClientRect();if(o>s.bottom||!be(e,n))return we(t);o-=s.top-a.viewOffset;for(var u=0;u=i)return ve(e,n,e,Ze(e.doc,o),e.display.gutterSpecs[u].className,t),we(t)}}function Ea(e,t){return Oa(e,t,"gutterClick",!0)}function Ta(e,t){_n(e.display,t)||function(e,t){return!!be(e,"gutterContextMenu")&&Oa(e,t,"gutterContextMenu",!1)}(e,t)||ye(e,t,"contextmenu")||_||e.display.input.onContextMenu(t)}function wa(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),qn(e)}ya.prototype.compare=function(e,t,n){return this.time+400>e&&0==rt(t,this.pos)&&n==this.button};var _a={toString:function(){return"CodeMirror.Init"}},ka={},xa={};function Sa(e,t,n){if(!t!=!(n&&n!=_a)){var r=e.display.dragFunctions,i=t?de:me;i(e.display.scroller,"dragstart",r.start),i(e.display.scroller,"dragenter",r.enter),i(e.display.scroller,"dragover",r.over),i(e.display.scroller,"dragleave",r.leave),i(e.display.scroller,"drop",r.drop)}}function Ca(e){e.options.lineWrapping?(I(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(S(e.display.wrapper,"CodeMirror-wrap"),Qt(e)),lr(e),dr(e),qn(e),setTimeout((function(){return Kr(e)}),100)}function Na(e,t){var n=this;if(!(this instanceof Na))return new Na(e,t);this.options=t=t?P(t):{},P(ka,t,!1);var r=t.value;"string"==typeof r?r=new Lo(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var i=new Na.inputStyles[t.inputStyle](this),o=this.display=new gi(e,r,i,t);for(var a in o.wrapper.CodeMirror=this,wa(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Gr(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new U,keySeq:null,specialChars:null},t.autofocus&&!g&&o.input.focus(),s&&u<11&&setTimeout((function(){return n.display.input.reset(!0)}),20),function(e){var t=e.display;de(t.scroller,"mousedown",ni(e,ga)),de(t.scroller,"dblclick",s&&u<11?ni(e,(function(t){if(!ye(e,t)){var n=fr(e,t);if(n&&!Ea(e,t)&&!_n(e.display,t)){Ee(t);var r=e.findWordAt(n);Ji(e.doc,r.anchor,r.head)}}})):function(t){return ye(e,t)||Ee(t)}),de(t.scroller,"contextmenu",(function(t){return Ta(e,t)}));var n,r={end:0};function i(){t.activeTouch&&(n=setTimeout((function(){return t.activeTouch=null}),1e3),(r=t.activeTouch).end=+new Date)}function o(e,t){if(null==t.left)return!0;var n=t.left-e.left,r=t.top-e.top;return n*n+r*r>400}de(t.scroller,"touchstart",(function(i){if(!ye(e,i)&&!function(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}(i)&&!Ea(e,i)){t.input.ensurePolled(),clearTimeout(n);var o=+new Date;t.activeTouch={start:o,moved:!1,prev:o-r.end<=300?r:null},1==i.touches.length&&(t.activeTouch.left=i.touches[0].pageX,t.activeTouch.top=i.touches[0].pageY)}})),de(t.scroller,"touchmove",(function(){t.activeTouch&&(t.activeTouch.moved=!0)})),de(t.scroller,"touchend",(function(n){var r=t.activeTouch;if(r&&!_n(t,n)&&null!=r.left&&!r.moved&&new Date-r.start<300){var a,s=e.coordsChar(t.activeTouch,"page");a=!r.prev||o(r,r.prev)?new ki(s,s):!r.prev.prev||o(r,r.prev.prev)?e.findWordAt(s):new ki(nt(s.line,0),ct(e.doc,nt(s.line+1,0))),e.setSelection(a.anchor,a.head),e.focus(),Ee(n)}i()})),de(t.scroller,"touchcancel",i),de(t.scroller,"scroll",(function(){t.scroller.clientHeight&&(Mr(e,t.scroller.scrollTop),Vr(e,t.scroller.scrollLeft,!0),ve(e,"scroll",e))})),de(t.scroller,"mousewheel",(function(t){return wi(e,t)})),de(t.scroller,"DOMMouseScroll",(function(t){return wi(e,t)})),de(t.wrapper,"scroll",(function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0})),t.dragFunctions={enter:function(t){ye(e,t)||_e(t)},over:function(t){ye(e,t)||(function(e,t){var n=fr(e,t);if(n){var r=document.createDocumentFragment();Or(e,n,r),e.display.dragCursor||(e.display.dragCursor=D("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),N(e.display.dragCursor,r)}}(e,t),_e(t))},start:function(t){return function(e,t){if(s&&(!e.state.draggingText||+new Date-Io<100))_e(t);else if(!ye(e,t)&&!_n(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!d)){var n=D("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",p&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),p&&n.parentNode.removeChild(n)}}(e,t)},drop:ni(e,Fo),leave:function(t){ye(e,t)||Ro(e)}};var a=t.input.getField();de(a,"keyup",(function(t){return da.call(e,t)})),de(a,"keydown",ni(e,pa)),de(a,"keypress",ni(e,ha)),de(a,"focus",(function(t){return xr(e,t)})),de(a,"blur",(function(t){return Sr(e,t)}))}(this),Vo(),Wr(this),this.curOp.forceUpdate=!0,Mi(this,r),t.autofocus&&!g||this.hasFocus()?setTimeout(M(xr,this),20):Sr(this),xa)xa.hasOwnProperty(a)&&xa[a](n,t[a],_a);hi(this),t.finishInit&&t.finishInit(this);for(var l=0;l150)){if(!r)return;n="prev"}}else c=0,n="not";"prev"==n?c=t>o.first?V(We(o,t-1).text,null,a):0:"add"==n?c=u+e.options.indentUnit:"subtract"==n?c=u-e.options.indentUnit:"number"==typeof n&&(c=u+n),c=Math.max(0,c);var f="",p=0;if(e.options.indentWithTabs)for(var d=Math.floor(c/a);d;--d)p+=a,f+="\t";if(pa,u=Le(t),c=null;if(s&&r.ranges.length>1)if(Aa&&Aa.text.join("\n")==t){if(r.ranges.length%Aa.text.length==0){c=[];for(var l=0;l=0;p--){var d=r.ranges[p],h=d.from(),m=d.to();d.empty()&&(n&&n>0?h=nt(h.line,h.ch-n):e.state.overwrite&&!s?m=nt(m.line,Math.min(We(o,m.line).text.length,m.ch+J(u).length)):s&&Aa&&Aa.lineWise&&Aa.text.join("\n")==t&&(h=m=nt(h.line,0)));var v={from:h,to:m,text:c?c[p%c.length]:u,origin:i||(s?"paste":e.state.cutIncoming>a?"cut":"+input")};fo(e.doc,v),ln(e,"inputRead",e,v)}t&&!s&&Ra(e,t),Lr(e),e.curOp.updateInput<2&&(e.curOp.updateInput=f),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Fa(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||ti(t,(function(){return Ia(t,n,0,null,"paste")})),!0}function Ra(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(!(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)){var o=e.getModeAt(i.head),a=!1;if(o.electricChars){for(var s=0;s-1){a=ja(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(We(e.doc,i.head.line).text.slice(0,i.head.ch))&&(a=ja(e,i.head.line,"smart"));a&&ln(e,"electricInput",e,i.head.line)}}}function Ma(e){for(var t=[],n=[],r=0;r=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var o=ce(i,n.ch,n.sticky),a=i[o];if("ltr"==e.doc.direction&&a.level%2==0&&(r>0?a.to>n.ch:a.from=a.from&&p>=l.begin)){var d=f?"before":"after";return new nt(n.line,p,d)}}var h=function(e,t,r){for(var o=function(e,t){return t?new nt(n.line,u(e,1),"before"):new nt(n.line,e,"after")};e>=0&&e0==(1!=a.level),c=s?r.begin:u(r.end,-1);if(a.from<=c&&c0?l.end:u(l.begin,-1);return null==v||r>0&&v==t.text.length||!(m=h(r>0?0:i.length-1,r,c(v)))?null:m}(e.cm,s,t,n):ta(s,t,n))){if(r||(a=t.line+n)=e.first+e.size||(t=new nt(a,t.ch,t.sticky),!(s=We(e,a))))return!1;t=na(i,e.cm,s,t.line,n)}else t=o;return!0}if("char"==r)u();else if("column"==r)u(!0);else if("word"==r||"group"==r)for(var c=null,l="group"==r,f=e.cm&&e.cm.getHelper(t,"wordChars"),p=!0;!(n<0)||u(!p);p=!1){var d=s.text.charAt(t.ch)||"\n",h=ne(d,f)?"w":l&&"\n"==d?"n":!l||/\s/.test(d)?null:"p";if(!l||p||h||(h="s"),c&&c!=h){n<0&&(n=1,u(),t.sticky="after");break}if(h&&(c=h),n>0&&!u(!p))break}var m=so(e,t,o,a,!0);return it(o,m)&&(m.hitSide=!0),m}function Ba(e,t,n,r){var i,o,a=e.doc,s=t.left;if("page"==r){var u=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),c=Math.max(u-.5*or(e.display),3);i=(n>0?t.bottom:t.top)+n*c}else"line"==r&&(i=n>0?t.bottom+3:t.top-3);for(;(o=Xn(e,s,i)).outside;){if(n<0?i<=0:i>=a.height){o.hitSide=!0;break}i+=5*n}return o}var qa=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new U,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Ka(e,t){var n=Ln(e,t.line);if(!n||n.hidden)return null;var r=We(e.doc,t.line),i=jn(n,r,t.line),o=fe(r,e.doc.direction),a="left";o&&(a=ce(o,t.ch)%2?"right":"left");var s=Pn(i.map,t.ch,a);return s.offset="right"==s.collapse?s.end:s.start,s}function Ha(e,t){return t&&(e.bad=!0),e}function za(e,t,n){var r;if(t==e.display.lineDiv){if(!(r=e.display.lineDiv.childNodes[n]))return Ha(e.clipPos(nt(e.display.viewTo-1)),!0);t=null,n=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var i=0;i=t.display.viewTo||o.line=t.display.viewFrom&&Ka(t,i)||{node:u[0].measure.map[2],offset:0},l=o.liner.firstLine()&&(a=nt(a.line-1,We(r.doc,a.line-1).length)),s.ch==We(r.doc,s.line).text.length&&s.linei.viewTo-1)return!1;a.line==i.viewFrom||0==(e=pr(r,a.line))?(t=Xe(i.view[0].line),n=i.view[0].node):(t=Xe(i.view[e].line),n=i.view[e-1].node.nextSibling);var u,c,l=pr(r,s.line);if(l==i.view.length-1?(u=i.viewTo-1,c=i.lineDiv.lastChild):(u=Xe(i.view[l+1].line)-1,c=i.view[l+1].node.previousSibling),!n)return!1;for(var f=r.doc.splitLines(function(e,t,n,r,i){var o="",a=!1,s=e.doc.lineSeparator(),u=!1;function c(){a&&(o+=s,u&&(o+=s),a=u=!1)}function l(e){e&&(c(),o+=e)}function f(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)return void l(n);var o,p=t.getAttribute("cm-marker");if(p){var d=e.findMarks(nt(r,0),nt(i+1,0),(v=+p,function(e){return e.id==v}));return void(d.length&&(o=d[0].find(0))&&l(Ye(e.doc,o.from,o.to).join(s)))}if("false"==t.getAttribute("contenteditable"))return;var h=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;h&&c();for(var m=0;m1&&p.length>1;)if(J(f)==J(p))f.pop(),p.pop(),u--;else{if(f[0]!=p[0])break;f.shift(),p.shift(),t++}for(var d=0,h=0,m=f[0],v=p[0],y=Math.min(m.length,v.length);da.ch&&g.charCodeAt(g.length-h-1)==b.charCodeAt(b.length-h-1);)d--,h++;f[f.length-1]=g.slice(0,g.length-h).replace(/^\u200b+/,""),f[0]=f[0].slice(d).replace(/\u200b+$/,"");var E=nt(t,d),T=nt(u,p.length?J(p).length-h:0);return f.length>1||f[0]||rt(E,T)?(yo(r.doc,f,E,T,"+input"),!0):void 0},qa.prototype.ensurePolled=function(){this.forceCompositionEnd()},qa.prototype.reset=function(){this.forceCompositionEnd()},qa.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},qa.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout((function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}e.updateFromDOM()}),80))},qa.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||ti(this.cm,(function(){return dr(e.cm)}))},qa.prototype.setUneditable=function(e){e.contentEditable="false"},qa.prototype.onKeyPress=function(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||ni(this.cm,Ia)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},qa.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},qa.prototype.onContextMenu=function(){},qa.prototype.resetPosition=function(){},qa.prototype.needsContentAttribute=!0;var Qa=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new U,this.hasSelection=!1,this.composing=null};Qa.prototype.init=function(e){var t=this,n=this,r=this.cm;this.createField(e);var i=this.textarea;function o(e){if(!ye(r,e)){if(r.somethingSelected())La({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var t=Ma(r);La({lineWise:!0,text:t.text}),"cut"==e.type?r.setSelections(t.ranges,null,H):(n.prevInput="",i.value=t.text.join("\n"),R(i))}"cut"==e.type&&(r.state.cutIncoming=+new Date)}}e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),v&&(i.style.width="0px"),de(i,"input",(function(){s&&u>=9&&t.hasSelection&&(t.hasSelection=null),n.poll()})),de(i,"paste",(function(e){ye(r,e)||Fa(e,r)||(r.state.pasteIncoming=+new Date,n.fastPoll())})),de(i,"cut",o),de(i,"copy",o),de(e.scroller,"paste",(function(t){if(!_n(e,t)&&!ye(r,t)){if(!i.dispatchEvent)return r.state.pasteIncoming=+new Date,void n.focus();var o=new Event("paste");o.clipboardData=t.clipboardData,i.dispatchEvent(o)}})),de(e.lineSpace,"selectstart",(function(t){_n(e,t)||Ee(t)})),de(i,"compositionstart",(function(){var e=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}})),de(i,"compositionend",(function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)}))},Qa.prototype.createField=function(e){this.wrapper=Va(),this.textarea=this.wrapper.firstChild},Qa.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,r=br(e);if(e.options.moveInputWithCursor){var i=Yn(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+a.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+a.left-o.left))}return r},Qa.prototype.showSelection=function(e){var t=this.cm.display;N(t.cursorDiv,e.cursors),N(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Qa.prototype.reset=function(e){if(!this.contextMenuPending&&!this.composing){var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&R(this.textarea),s&&u>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",s&&u>=9&&(this.hasSelection=null))}},Qa.prototype.getField=function(){return this.textarea},Qa.prototype.supportsTouch=function(){return!1},Qa.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!g||L()!=this.textarea))try{this.textarea.focus()}catch(e){}},Qa.prototype.blur=function(){this.textarea.blur()},Qa.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Qa.prototype.receivedFocus=function(){this.slowPoll()},Qa.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,(function(){e.poll(),e.cm.state.focused&&e.slowPoll()}))},Qa.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0,t.polling.set(20,(function n(){t.poll()||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,n))}))},Qa.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||Ie(n)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=n.value;if(i==r&&!t.somethingSelected())return!1;if(s&&u>=9&&this.hasSelection===i||b&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||r||(r="​"),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var a=0,c=Math.min(r.length,i.length);a1e3||i.indexOf("\n")>-1?n.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))})),!0},Qa.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Qa.prototype.onKeyPress=function(){s&&u>=9&&(this.hasSelection=null),this.fastPoll()},Qa.prototype.onContextMenu=function(e){var t=this,n=t.cm,r=n.display,i=t.textarea;t.contextMenuPending&&t.contextMenuPending();var o=fr(n,e),a=r.scroller.scrollTop;if(o&&!p){n.options.resetSelectionOnContextMenu&&-1==n.doc.sel.contains(o)&&ni(n,to)(n.doc,Si(o),H);var l,f=i.style.cssText,d=t.wrapper.style.cssText,h=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",i.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(s?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",c&&(l=window.scrollY),r.input.focus(),c&&window.scrollTo(null,l),r.input.reset(),n.somethingSelected()||(i.value=t.prevInput=" "),t.contextMenuPending=v,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll),s&&u>=9&&m(),_?(_e(e),de(window,"mouseup",(function e(){me(window,"mouseup",e),setTimeout(v,20)}))):setTimeout(v,50)}function m(){if(null!=i.selectionStart){var e=n.somethingSelected(),o="​"+(e?i.value:"");i.value="⇚",i.value=o,t.prevInput=e?"":"​",i.selectionStart=1,i.selectionEnd=o.length,r.selForContextMenu=n.doc.sel}}function v(){if(t.contextMenuPending==v&&(t.contextMenuPending=!1,t.wrapper.style.cssText=d,i.style.cssText=f,s&&u<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=a),null!=i.selectionStart)){(!s||s&&u<9)&&m();var e=0;r.detectingSelectAll=setTimeout((function o(){r.selForContextMenu==n.doc.sel&&0==i.selectionStart&&i.selectionEnd>0&&"​"==t.prevInput?ni(n,co)(n):e++<10?r.detectingSelectAll=setTimeout(o,500):(r.selForContextMenu=null,r.input.reset())}),200)}}},Qa.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e},Qa.prototype.setUneditable=function(){},Qa.prototype.needsContentAttribute=!1,function(e){var t=e.optionHandlers;function n(n,r,i,o){e.defaults[n]=r,i&&(t[n]=o?function(e,t,n){n!=_a&&i(e,t,n)}:i)}e.defineOption=n,e.Init=_a,n("value","",(function(e,t){return e.setValue(t)}),!0),n("mode",null,(function(e,t){e.doc.modeOption=t,Ai(e)}),!0),n("indentUnit",2,Ai,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,(function(e){Li(e),qn(e),dr(e)}),!0),n("lineSeparator",null,(function(e,t){if(e.doc.lineSep=t,t){var n=[],r=e.doc.first;e.doc.iter((function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,n.push(nt(r,o))}r++}));for(var i=n.length-1;i>=0;i--)yo(e.doc,t,n[i],nt(n[i].line,n[i].ch+t.length))}})),n("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,(function(e,t,n){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),n!=_a&&e.refresh()})),n("specialCharPlaceholder",en,(function(e){return e.refresh()}),!0),n("electricChars",!0),n("inputStyle",g?"contenteditable":"textarea",(function(){throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),n("spellcheck",!1,(function(e,t){return e.getInputField().spellcheck=t}),!0),n("autocorrect",!1,(function(e,t){return e.getInputField().autocorrect=t}),!0),n("autocapitalize",!1,(function(e,t){return e.getInputField().autocapitalize=t}),!0),n("rtlMoveVisually",!E),n("wholeLineUpdateBefore",!0),n("theme","default",(function(e){wa(e),yi(e)}),!0),n("keyMap","default",(function(e,t,n){var r=Xo(t),i=n!=_a&&Xo(n);i&&i.detach&&i.detach(e,r),r.attach&&r.attach(e,i||null)})),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,Ca,!0),n("gutters",[],(function(e,t){e.display.gutterSpecs=mi(t,e.options.lineNumbers),yi(e)}),!0),n("fixedGutter",!0,(function(e,t){e.display.gutters.style.left=t?ur(e.display)+"px":"0",e.refresh()}),!0),n("coverGutterNextToScrollbar",!1,(function(e){return Kr(e)}),!0),n("scrollbarStyle","native",(function(e){Gr(e),Kr(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)}),!0),n("lineNumbers",!1,(function(e,t){e.display.gutterSpecs=mi(e.options.gutters,t),yi(e)}),!0),n("firstLineNumber",1,yi,!0),n("lineNumberFormatter",(function(e){return e}),yi,!0),n("showCursorWhenSelecting",!1,gr,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("selectionsMayTouch",!1),n("readOnly",!1,(function(e,t){"nocursor"==t&&(Sr(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)})),n("disableInput",!1,(function(e,t){t||e.display.input.reset()}),!0),n("dragDrop",!0,Sa),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,gr,!0),n("singleCursorHeightPerLine",!0,gr,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,Li,!0),n("addModeClass",!1,Li,!0),n("pollInterval",100),n("undoDepth",200,(function(e,t){return e.doc.history.undoDepth=t})),n("historyEventDelay",1250),n("viewportMargin",10,(function(e){return e.refresh()}),!0),n("maxHighlightLength",1e4,Li,!0),n("moveInputWithCursor",!0,(function(e,t){t||e.display.input.resetPosition()})),n("tabindex",null,(function(e,t){return e.display.input.getField().tabIndex=t||""})),n("autofocus",null),n("direction","ltr",(function(e,t){return e.doc.setDirection(t)}),!0),n("phrases",null)}(Na),function(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,n){var r=this.options,i=r[e];r[e]==n&&"mode"!=e||(r[e]=n,t.hasOwnProperty(e)&&ni(this,t[e])(this,n,i),ve(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Xo(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;nn&&(ja(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&Lr(this));else{var o=i.from(),a=i.to(),s=Math.max(n,o.line);n=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var u=s;u0&&Xi(this.doc,r,new ki(o,c[r].to()),H)}}})),getTokenAt:function(e,t){return Ot(this,e,t)},getLineTokens:function(e,t){return Ot(this,nt(e),t,!0)},getTokenTypeAt:function(e){e=ct(this.doc,e);var t,n=ht(this,We(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var a=r+i>>1;if((a?n[2*a-1]:0)>=o)i=a;else{if(!(n[2*a+1]o&&(e=o,i=!0),r=We(this.doc,e)}else r=e;return Gn(this,r,{top:0,left:0},t||"page",n||i).top+(i?this.doc.height-zt(r):0)},defaultTextHeight:function(){return or(this.display)},defaultCharWidth:function(){return ar(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var o,a,s,u=this.display,c=(e=Yn(this,ct(this.doc,e))).bottom,l=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),u.sizer.appendChild(t),"over"==r)c=e.top;else if("above"==r||"near"==r){var f=Math.max(u.wrapper.clientHeight,this.doc.height),p=Math.max(u.sizer.clientWidth,u.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>f)&&e.top>t.offsetHeight?c=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=f&&(c=e.bottom),l+t.offsetWidth>p&&(l=p-t.offsetWidth)}t.style.top=c+"px",t.style.left=t.style.right="","right"==i?(l=u.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?l=0:"middle"==i&&(l=(u.sizer.clientWidth-t.offsetWidth)/2),t.style.left=l+"px"),n&&(o=this,a={left:l,top:c,right:l+t.offsetWidth,bottom:c+t.offsetHeight},null!=(s=jr(o,a)).scrollTop&&Mr(o,s.scrollTop),null!=s.scrollLeft&&Vr(o,s.scrollLeft))},triggerOnKeyDown:ri(pa),triggerOnKeyPress:ri(ha),triggerOnKeyUp:da,triggerOnMouseDown:ri(ga),execCommand:function(e){if(ra.hasOwnProperty(e))return ra[e].call(null,this)},triggerElectric:ri((function(e){Ra(this,e)})),findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var o=ct(this.doc,e),a=0;a0&&a(t.charAt(n-1));)--n;for(;r.5)&&lr(this),ve(this,"refresh",this)})),swapDoc:ri((function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),Mi(this,e),qn(this),this.display.input.reset(),Ir(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,ln(this,"swapDoc",this,t),t})),phrase:function(e){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Oe(e),e.registerHelper=function(t,r,i){n.hasOwnProperty(t)||(n[t]=e[t]={_global:[]}),n[t][r]=i},e.registerGlobalHelper=function(t,r,i,o){e.registerHelper(t,r,o),n[t]._global.push({pred:i,val:o})}}(Na);var Wa="iter insert remove copy getEditor constructor".split(" ");for(var Ya in Lo.prototype)Lo.prototype.hasOwnProperty(Ya)&&B(Wa,Ya)<0&&(Na.prototype[Ya]=function(e){return function(){return e.apply(this.doc,arguments)}}(Lo.prototype[Ya]));return Oe(Lo),Na.inputStyles={textarea:Qa,contenteditable:qa},Na.defineMode=function(e){Na.defaults.mode||"null"==e||(Na.defaults.mode=e),Ve.apply(this,arguments)},Na.defineMIME=function(e,t){Pe[e]=t},Na.defineMode("null",(function(){return{token:function(e){return e.skipToEnd()}}})),Na.defineMIME("text/plain","null"),Na.defineExtension=function(e,t){Na.prototype[e]=t},Na.defineDocExtension=function(e,t){Lo.prototype[e]=t},Na.fromTextArea=function(e,t){if((t=t?P(t):{}).value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n=L();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}function r(){e.value=s.getValue()}var i;if(e.form&&(de(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var o=e.form;i=o.submit;try{var a=o.submit=function(){r(),o.submit=i,o.submit(),o.submit=a}}catch(e){}}t.finishInit=function(n){n.save=r,n.getTextArea=function(){return e},n.toTextArea=function(){n.toTextArea=isNaN,r(),e.parentNode.removeChild(n.getWrapperElement()),e.style.display="",e.form&&(me(e.form,"submit",r),t.leaveSubmitMethodAlone||"function"!=typeof e.form.submit||(e.form.submit=i))}},e.style.display="none";var s=Na((function(t){return e.parentNode.insertBefore(t,e.nextSibling)}),t);return s},function(e){e.off=me,e.on=de,e.wheelEventPixels=Ti,e.Doc=Lo,e.splitLines=Le,e.countColumn=V,e.findColumn=Q,e.isWordChar=te,e.Pass=K,e.signal=ve,e.Line=Wt,e.changeEnd=Ci,e.scrollbarModel=zr,e.Pos=nt,e.cmpPos=rt,e.modes=Me,e.mimeModes=Pe,e.resolveMode=Ue,e.getMode=Be,e.modeExtensions=qe,e.extendMode=Ke,e.copyState=He,e.startState=Ge,e.innerMode=ze,e.commands=ra,e.keyMap=zo,e.keyName=$o,e.isModifierKey=Yo,e.lookupKey=Wo,e.normalizeKeyMap=Qo,e.StringStream=Qe,e.SharedTextMarker=No,e.TextMarker=So,e.LineWidget=_o,e.e_preventDefault=Ee,e.e_stopPropagation=Te,e.e_stop=_e,e.addClass=I,e.contains=A,e.rmClass=S,e.keyNames=Bo}(Na),Na.version="5.49.2",Na}))},void 0===(o="function"==typeof i?i.apply(t,r):i)||(e.exports=o)},function(e,t,n){"use strict";var r=Object.values||function(e){return Object.keys(e).map((function(t){return e[t]}))};t.a=r},function(e,t,n){"use strict";n.r(t),n.d(t,"__Schema",(function(){return f})),n.d(t,"__Directive",(function(){return p})),n.d(t,"__DirectiveLocation",(function(){return d})),n.d(t,"__Type",(function(){return h})),n.d(t,"__Field",(function(){return m})),n.d(t,"__InputValue",(function(){return v})),n.d(t,"__EnumValue",(function(){return y})),n.d(t,"TypeKind",(function(){return g})),n.d(t,"__TypeKind",(function(){return b})),n.d(t,"SchemaMetaFieldDef",(function(){return O})),n.d(t,"TypeMetaFieldDef",(function(){return E})),n.d(t,"TypeNameMetaFieldDef",(function(){return T})),n.d(t,"introspectionTypes",(function(){return w})),n.d(t,"isIntrospectionType",(function(){return _}));var r=n(7),i=n(2),o=n(12),a=n(11),s=n(5),u=n(33),c=n(9),l=n(0),f=new l.f({name:"__Schema",description:"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",fields:function(){return{types:{description:"A list of all types supported by this server.",type:Object(l.e)(Object(l.d)(Object(l.e)(h))),resolve:function(e){return Object(r.a)(e.getTypeMap())}},queryType:{description:"The type that query operations will be rooted at.",type:Object(l.e)(h),resolve:function(e){return e.getQueryType()}},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:h,resolve:function(e){return e.getMutationType()}},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:h,resolve:function(e){return e.getSubscriptionType()}},directives:{description:"A list of all directives supported by this server.",type:Object(l.e)(Object(l.d)(Object(l.e)(p))),resolve:function(e){return e.getDirectives()}}}}}),p=new l.f({name:"__Directive",description:"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.",fields:function(){return{name:{type:Object(l.e)(c.e),resolve:function(e){return e.name}},description:{type:c.e,resolve:function(e){return e.description}},locations:{type:Object(l.e)(Object(l.d)(Object(l.e)(d))),resolve:function(e){return e.locations}},args:{type:Object(l.e)(Object(l.d)(Object(l.e)(v))),resolve:function(e){return e.args}}}}}),d=new l.a({name:"__DirectiveLocation",description:"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",values:{QUERY:{value:s.a.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:s.a.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:s.a.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:s.a.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:s.a.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:s.a.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:s.a.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:s.a.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:s.a.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:s.a.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:s.a.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:s.a.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:s.a.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:s.a.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:s.a.UNION,description:"Location adjacent to a union definition."},ENUM:{value:s.a.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:s.a.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:s.a.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:s.a.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),h=new l.f({name:"__Type",description:"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",fields:function(){return{kind:{type:Object(l.e)(b),resolve:function(e){return Object(l.R)(e)?g.SCALAR:Object(l.N)(e)?g.OBJECT:Object(l.H)(e)?g.INTERFACE:Object(l.T)(e)?g.UNION:Object(l.E)(e)?g.ENUM:Object(l.F)(e)?g.INPUT_OBJECT:Object(l.J)(e)?g.LIST:Object(l.L)(e)?g.NON_NULL:void Object(o.a)(!1,'Unexpected type: "'.concat(Object(i.a)(e),'".'))}},name:{type:c.e,resolve:function(e){return void 0!==e.name?e.name:void 0}},description:{type:c.e,resolve:function(e){return void 0!==e.description?e.description:void 0}},fields:{type:Object(l.d)(Object(l.e)(m)),args:{includeDeprecated:{type:c.a,defaultValue:!1}},resolve:function(e,t){var n=t.includeDeprecated;if(Object(l.N)(e)||Object(l.H)(e)){var i=Object(r.a)(e.getFields());return n||(i=i.filter((function(e){return!e.deprecationReason}))),i}return null}},interfaces:{type:Object(l.d)(Object(l.e)(h)),resolve:function(e){if(Object(l.N)(e))return e.getInterfaces()}},possibleTypes:{type:Object(l.d)(Object(l.e)(h)),resolve:function(e,t,n,r){var i=r.schema;if(Object(l.C)(e))return i.getPossibleTypes(e)}},enumValues:{type:Object(l.d)(Object(l.e)(y)),args:{includeDeprecated:{type:c.a,defaultValue:!1}},resolve:function(e,t){var n=t.includeDeprecated;if(Object(l.E)(e)){var r=e.getValues();return n||(r=r.filter((function(e){return!e.deprecationReason}))),r}}},inputFields:{type:Object(l.d)(Object(l.e)(v)),resolve:function(e){if(Object(l.F)(e))return Object(r.a)(e.getFields())}},ofType:{type:h,resolve:function(e){return void 0!==e.ofType?e.ofType:void 0}}}}}),m=new l.f({name:"__Field",description:"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",fields:function(){return{name:{type:Object(l.e)(c.e),resolve:function(e){return e.name}},description:{type:c.e,resolve:function(e){return e.description}},args:{type:Object(l.e)(Object(l.d)(Object(l.e)(v))),resolve:function(e){return e.args}},type:{type:Object(l.e)(h),resolve:function(e){return e.type}},isDeprecated:{type:Object(l.e)(c.a),resolve:function(e){return e.isDeprecated}},deprecationReason:{type:c.e,resolve:function(e){return e.deprecationReason}}}}}),v=new l.f({name:"__InputValue",description:"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",fields:function(){return{name:{type:Object(l.e)(c.e),resolve:function(e){return e.name}},description:{type:c.e,resolve:function(e){return e.description}},type:{type:Object(l.e)(h),resolve:function(e){return e.type}},defaultValue:{type:c.e,description:"A GraphQL-formatted string representing the default value for this input value.",resolve:function(e){var t=Object(u.a)(e.defaultValue,e.type);return t?Object(a.a)(t):null}}}}}),y=new l.f({name:"__EnumValue",description:"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",fields:function(){return{name:{type:Object(l.e)(c.e),resolve:function(e){return e.name}},description:{type:c.e,resolve:function(e){return e.description}},isDeprecated:{type:Object(l.e)(c.a),resolve:function(e){return e.isDeprecated}},deprecationReason:{type:c.e,resolve:function(e){return e.deprecationReason}}}}}),g=Object.freeze({SCALAR:"SCALAR",OBJECT:"OBJECT",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",INPUT_OBJECT:"INPUT_OBJECT",LIST:"LIST",NON_NULL:"NON_NULL"}),b=new l.a({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:g.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:g.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:g.INTERFACE,description:"Indicates this type is an interface. `fields` and `possibleTypes` are valid fields."},UNION:{value:g.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:g.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:g.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:g.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:g.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),O={name:"__schema",type:Object(l.e)(f),description:"Access the current type schema of this server.",args:[],resolve:function(e,t,n,r){return r.schema},deprecationReason:void 0,extensions:void 0,astNode:void 0},E={name:"__type",type:h,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:Object(l.e)(c.e),defaultValue:void 0,extensions:void 0,astNode:void 0}],resolve:function(e,t,n,r){var i=t.name;return r.schema.getType(i)},deprecationReason:void 0,extensions:void 0,astNode:void 0},T={name:"__typename",type:Object(l.e)(c.e),description:"The name of the current Object type at runtime.",args:[],resolve:function(e,t,n,r){return r.parentType.name},deprecationReason:void 0,extensions:void 0,astNode:void 0},w=Object.freeze([f,p,d,h,m,v,y,b]);function _(e){return Object(l.K)(e)&&w.some((function(t){var n=t.name;return e.name===n}))}},function(e,t,n){"use strict";var r=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},i=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},o=n(2),a=n(15),s=n(1),u=n(0);n.d(t,"d",(function(){return f})),n.d(t,"b",(function(){return p})),n.d(t,"e",(function(){return h})),n.d(t,"a",(function(){return m})),n.d(t,"c",(function(){return v})),n.d(t,"g",(function(){return y})),n.d(t,"f",(function(){return g}));var c=2147483647,l=-2147483648;var f=new u.g({name:"Int",description:"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",serialize:function(e){if("boolean"==typeof e)return e?1:0;var t=e;if("string"==typeof e&&""!==e&&(t=Number(e)),!i(t))throw new TypeError("Int cannot represent non-integer value: ".concat(Object(o.a)(e)));if(t>c||tc||e=l)return t}}});var p=new u.g({name:"Float",description:"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",serialize:function(e){if("boolean"==typeof e)return e?1:0;var t=e;if("string"==typeof e&&""!==e&&(t=Number(e)),!r(t))throw new TypeError("Float cannot represent non numeric value: ".concat(Object(o.a)(e)));return t},parseValue:function(e){if(!r(e))throw new TypeError("Float cannot represent non numeric value: ".concat(Object(o.a)(e)));return e},parseLiteral:function(e){return e.kind===s.Kind.FLOAT||e.kind===s.Kind.INT?parseFloat(e.value):void 0}});function d(e){if(Object(a.a)(e)){if("function"==typeof e.valueOf){var t=e.valueOf();if(!Object(a.a)(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}var h=new u.g({name:"String",description:"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",serialize:function(e){var t=d(e);if("string"==typeof t)return t;if("boolean"==typeof t)return t?"true":"false";if(r(t))return t.toString();throw new TypeError("String cannot represent value: ".concat(Object(o.a)(e)))},parseValue:function(e){if("string"!=typeof e)throw new TypeError("String cannot represent a non string value: ".concat(Object(o.a)(e)));return e},parseLiteral:function(e){return e.kind===s.Kind.STRING?e.value:void 0}});var m=new u.g({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize:function(e){if("boolean"==typeof e)return e;if(r(e))return 0!==e;throw new TypeError("Boolean cannot represent a non boolean value: ".concat(Object(o.a)(e)))},parseValue:function(e){if("boolean"!=typeof e)throw new TypeError("Boolean cannot represent a non boolean value: ".concat(Object(o.a)(e)));return e},parseLiteral:function(e){return e.kind===s.Kind.BOOLEAN?e.value:void 0}});var v=new u.g({name:"ID",description:'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.',serialize:function(e){var t=d(e);if("string"==typeof t)return t;if(i(t))return String(t);throw new TypeError("ID cannot represent value: ".concat(Object(o.a)(e)))},parseValue:function(e){if("string"==typeof e)return e;if(i(e))return e.toString();throw new TypeError("ID cannot represent value: ".concat(Object(o.a)(e)))},parseLiteral:function(e){return e.kind===s.Kind.STRING||e.kind===s.Kind.INT?e.value:void 0}}),y=Object.freeze([h,f,p,m,v]);function g(e){return Object(u.R)(e)&&y.some((function(t){var n=t.name;return e.name===n}))}},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}var r=Object.prototype.hasOwnProperty;function i(e,t){return r.call(e,t)}function o(e){return!(e>=55296&&e<=57343||e>=64976&&e<=65007||65535==(65535&e)||65534==(65535&e)||e>=0&&e<=8||11===e||e>=14&&e<=31||e>=127&&e<=159||e>1114111)}function a(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}var s=/\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g,u=new RegExp(s.source+"|"+/&([a-z#][a-z0-9]{1,31});/gi.source,"gi"),c=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i,l=n(63),f=/[&<>"]/,p=/[&<>"]/g,d={"&":"&","<":"<",">":">",'"':"""};function h(e){return d[e]}var m=/[.?*+^$[\]\\(){}|-]/g,v=n(43);t.lib={},t.lib.mdurl=n(64),t.lib.ucmicro=n(124),t.assign=function(t){return Array.prototype.slice.call(arguments,1).forEach((function(n){if(n){if("object"!==e(n))throw new TypeError(n+"must be object");Object.keys(n).forEach((function(e){t[e]=n[e]}))}})),t},t.isString=function(e){return"[object String]"===function(e){return Object.prototype.toString.call(e)}(e)},t.has=i,t.unescapeMd=function(e){return e.indexOf("\\")<0?e:e.replace(s,"$1")},t.unescapeAll=function(e){return e.indexOf("\\")<0&&e.indexOf("&")<0?e:e.replace(u,(function(e,t,n){return t||function(e,t){var n=0;return i(l,t)?l[t]:35===t.charCodeAt(0)&&c.test(t)&&o(n="x"===t[1].toLowerCase()?parseInt(t.slice(2),16):parseInt(t.slice(1),10))?a(n):e}(e,n)}))},t.isValidEntityCode=o,t.fromCodePoint=a,t.escapeHtml=function(e){return f.test(e)?e.replace(p,h):e},t.arrayReplaceAt=function(e,t,n){return[].concat(e.slice(0,t),n,e.slice(t+1))},t.isSpace=function(e){switch(e){case 9:case 32:return!0}return!1},t.isWhiteSpace=function(e){if(e>=8192&&e<=8202)return!0;switch(e){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1},t.isMdAsciiPunct=function(e){switch(e){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}},t.isPunctChar=function(e){return v.test(e)},t.escapeRE=function(e){return e.replace(m,"\\$&")},t.normalizeReference=function(e){return e=e.trim().replace(/\s+/g," "),"Ṿ"==="ẞ".toLowerCase()&&(e=e.replace(/ẞ/g,"ß")),e.toLowerCase().toUpperCase()}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(17),i=n(29);function o(e){return Object(r.c)(e,{leave:a})}var a={Name:function(e){return e.value},Variable:function(e){return"$"+e.name},Document:function(e){return u(e.definitions,"\n\n")+"\n"},OperationDefinition:function(e){var t=e.operation,n=e.name,r=l("(",u(e.variableDefinitions,", "),")"),i=u(e.directives," "),o=e.selectionSet;return n||i||r||"query"!==t?u([t,u([n,r]),i,o]," "):o},VariableDefinition:function(e){var t=e.variable,n=e.type,r=e.defaultValue,i=e.directives;return t+": "+n+l(" = ",r)+l(" ",u(i," "))},SelectionSet:function(e){return c(e.selections)},Field:function(e){var t=e.alias,n=e.name,r=e.arguments,i=e.directives,o=e.selectionSet;return u([l("",t,": ")+n+l("(",u(r,", "),")"),u(i," "),o]," ")},Argument:function(e){return e.name+": "+e.value},FragmentSpread:function(e){return"..."+e.name+l(" ",u(e.directives," "))},InlineFragment:function(e){var t=e.typeCondition,n=e.directives,r=e.selectionSet;return u(["...",l("on ",t),u(n," "),r]," ")},FragmentDefinition:function(e){var t=e.name,n=e.typeCondition,r=e.variableDefinitions,i=e.directives,o=e.selectionSet;return("fragment ".concat(t).concat(l("(",u(r,", "),")")," ")+"on ".concat(n," ").concat(l("",u(i," ")," "))+o)},IntValue:function(e){return e.value},FloatValue:function(e){return e.value},StringValue:function(e,t){var n=e.value;return e.block?Object(i.c)(n,"description"===t?"":" "):JSON.stringify(n)},BooleanValue:function(e){return e.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){return e.value},ListValue:function(e){return"["+u(e.values,", ")+"]"},ObjectValue:function(e){return"{"+u(e.fields,", ")+"}"},ObjectField:function(e){return e.name+": "+e.value},Directive:function(e){return"@"+e.name+l("(",u(e.arguments,", "),")")},NamedType:function(e){return e.name},ListType:function(e){return"["+e.type+"]"},NonNullType:function(e){return e.type+"!"},SchemaDefinition:function(e){var t=e.directives,n=e.operationTypes;return u(["schema",u(t," "),c(n)]," ")},OperationTypeDefinition:function(e){return e.operation+": "+e.type},ScalarTypeDefinition:s((function(e){return u(["scalar",e.name,u(e.directives," ")]," ")})),ObjectTypeDefinition:s((function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return u(["type",t,l("implements ",u(n," & ")),u(r," "),c(i)]," ")})),FieldDefinition:s((function(e){var t=e.name,n=e.arguments,r=e.type,i=e.directives;return t+(d(n)?l("(\n",f(u(n,"\n")),"\n)"):l("(",u(n,", "),")"))+": "+r+l(" ",u(i," "))})),InputValueDefinition:s((function(e){var t=e.name,n=e.type,r=e.defaultValue,i=e.directives;return u([t+": "+n,l("= ",r),u(i," ")]," ")})),InterfaceTypeDefinition:s((function(e){var t=e.name,n=e.directives,r=e.fields;return u(["interface",t,u(n," "),c(r)]," ")})),UnionTypeDefinition:s((function(e){var t=e.name,n=e.directives,r=e.types;return u(["union",t,u(n," "),r&&0!==r.length?"= "+u(r," | "):""]," ")})),EnumTypeDefinition:s((function(e){var t=e.name,n=e.directives,r=e.values;return u(["enum",t,u(n," "),c(r)]," ")})),EnumValueDefinition:s((function(e){return u([e.name,u(e.directives," ")]," ")})),InputObjectTypeDefinition:s((function(e){var t=e.name,n=e.directives,r=e.fields;return u(["input",t,u(n," "),c(r)]," ")})),DirectiveDefinition:s((function(e){var t=e.name,n=e.arguments,r=e.repeatable,i=e.locations;return"directive @"+t+(d(n)?l("(\n",f(u(n,"\n")),"\n)"):l("(",u(n,", "),")"))+(r?" repeatable":"")+" on "+u(i," | ")})),SchemaExtension:function(e){var t=e.directives,n=e.operationTypes;return u(["extend schema",u(t," "),c(n)]," ")},ScalarTypeExtension:function(e){return u(["extend scalar",e.name,u(e.directives," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return u(["extend type",t,l("implements ",u(n," & ")),u(r," "),c(i)]," ")},InterfaceTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return u(["extend interface",t,u(n," "),c(r)]," ")},UnionTypeExtension:function(e){var t=e.name,n=e.directives,r=e.types;return u(["extend union",t,u(n," "),r&&0!==r.length?"= "+u(r," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,n=e.directives,r=e.values;return u(["extend enum",t,u(n," "),c(r)]," ")},InputObjectTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return u(["extend input",t,u(n," "),c(r)]," ")}};function s(e){return function(t){return u([t.description,e(t)],"\n")}}function u(e,t){return e?e.filter((function(e){return e})).join(t||""):""}function c(e){return e&&0!==e.length?"{\n"+f(u(e,"\n"))+"\n}":""}function l(e,t,n){return t?e+t+(n||""):""}function f(e){return e&&" "+e.replace(/\n/g,"\n ")}function p(e){return-1!==e.indexOf("\n")}function d(e){return e&&e.some(p)}},function(e,t,n){"use strict";function r(e,t){if(!Boolean(e))throw new Error(t||"Unexpected invariant triggered")}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.r(t);var r=Object.freeze({major:14,minor:5,patch:8,preReleaseTag:null});function i(e){return Boolean(e&&"function"==typeof e.then)}var o=n(2),a=n(4),s=n(25),u=n(3);function c(e,t,n){return new u.a("Syntax Error: ".concat(n),void 0,e,[t])}var l=n(1),f=n(24),p=function(e,t,n){this.body=e,this.name=t||"GraphQL request",this.locationOffset=n||{line:1,column:1},this.locationOffset.line>0||Object(a.a)(0,"line in locationOffset is 1-indexed and must be positive"),this.locationOffset.column>0||Object(a.a)(0,"column in locationOffset is 1-indexed and must be positive")};Object(f.a)(p);var d=n(29),h=Object.freeze({SOF:"",EOF:"",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function m(e,t){var n=new g(h.SOF,0,0,0,0,null);return{source:e,options:t,lastToken:n,token:n,line:1,lineStart:0,advance:v,lookahead:y}}function v(){return this.lastToken=this.token,this.token=this.lookahead()}function y(){var e=this.token;if(e.kind!==h.EOF)do{e=e.next||(e.next=O(this,e))}while(e.kind===h.COMMENT);return e}function g(e,t,n,r,i,o,a){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=a,this.prev=o,this.next=null}function b(e){return isNaN(e)?h.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function O(e,t){var n=e.source,r=n.body,i=r.length,o=function(e,t,n){var r=e.length,i=t;for(;i=i)return new g(h.EOF,i,i,a,s,t);var u=r.charCodeAt(o);switch(u){case 33:return new g(h.BANG,o,o+1,a,s,t);case 35:return function(e,t,n,r,i){var o,a=e.body,s=t;do{o=a.charCodeAt(++s)}while(!isNaN(o)&&(o>31||9===o));return new g(h.COMMENT,t,s,n,r,i,a.slice(t+1,s))}(n,o,a,s,t);case 36:return new g(h.DOLLAR,o,o+1,a,s,t);case 38:return new g(h.AMP,o,o+1,a,s,t);case 40:return new g(h.PAREN_L,o,o+1,a,s,t);case 41:return new g(h.PAREN_R,o,o+1,a,s,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new g(h.SPREAD,o,o+3,a,s,t);break;case 58:return new g(h.COLON,o,o+1,a,s,t);case 61:return new g(h.EQUALS,o,o+1,a,s,t);case 64:return new g(h.AT,o,o+1,a,s,t);case 91:return new g(h.BRACKET_L,o,o+1,a,s,t);case 93:return new g(h.BRACKET_R,o,o+1,a,s,t);case 123:return new g(h.BRACE_L,o,o+1,a,s,t);case 124:return new g(h.PIPE,o,o+1,a,s,t);case 125:return new g(h.BRACE_R,o,o+1,a,s,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return function(e,t,n,r,i){var o=e.body,a=o.length,s=t+1,u=0;for(;s!==a&&!isNaN(u=o.charCodeAt(s))&&(95===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++s;return new g(h.NAME,t,s,n,r,i,o.slice(t,s))}(n,o,a,s,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return function(e,t,n,r,i,o){var a=e.body,s=n,u=t,l=!1;45===s&&(s=a.charCodeAt(++u));if(48===s){if((s=a.charCodeAt(++u))>=48&&s<=57)throw c(e,u,"Invalid number, unexpected digit after 0: ".concat(b(s),"."))}else u=E(e,u,s),s=a.charCodeAt(u);46===s&&(l=!0,s=a.charCodeAt(++u),u=E(e,u,s),s=a.charCodeAt(u));69!==s&&101!==s||(l=!0,43!==(s=a.charCodeAt(++u))&&45!==s||(s=a.charCodeAt(++u)),u=E(e,u,s),s=a.charCodeAt(u));if(46===s||69===s||101===s)throw c(e,u,"Invalid number, expected digit but got: ".concat(b(s),"."));return new g(l?h.FLOAT:h.INT,t,u,r,i,o,a.slice(t,u))}(n,o,u,a,s,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?function(e,t,n,r,i,o){var a=e.body,s=t+3,u=s,l=0,f="";for(;s=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw c(e,i,"Invalid number, expected digit but got: ".concat(b(o),"."))}function T(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}Object(s.a)(g,(function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}));var w=n(5);function _(e,t){return new S(e,t).parseDocument()}function k(e,t){var n=new S(e,t);n.expectToken(h.SOF);var r=n.parseValueLiteral(!1);return n.expectToken(h.EOF),r}function x(e,t){var n=new S(e,t);n.expectToken(h.SOF);var r=n.parseTypeReference();return n.expectToken(h.EOF),r}var S=function(){function e(e,t){var n="string"==typeof e?new p(e):e;n instanceof p||Object(a.a)(0,"Must provide Source. Received: ".concat(Object(o.a)(n))),this._lexer=m(n),this._options=t||{}}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(h.NAME);return{kind:l.Kind.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:l.Kind.DOCUMENT,definitions:this.many(h.SOF,this.parseDefinition,h.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(h.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(h.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(h.BRACE_L))return{kind:l.Kind.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,n=this.parseOperationType();return this.peek(h.NAME)&&(t=this.parseName()),{kind:l.Kind.OPERATION_DEFINITION,operation:n,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(h.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(h.PAREN_L,this.parseVariableDefinition,h.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:l.Kind.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(h.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(h.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(h.DOLLAR),{kind:l.Kind.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:l.Kind.SELECTION_SET,selections:this.many(h.BRACE_L,this.parseSelection,h.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(h.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(h.COLON)?(e=r,t=this.parseName()):t=r,{kind:l.Kind.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(h.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(h.PAREN_L,t,h.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(h.COLON),{kind:l.Kind.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:l.Kind.ARGUMENT,name:this.parseName(),value:(this.expectToken(h.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(h.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(h.NAME)?{kind:l.Kind.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:l.Kind.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e=this._lexer.token;return this.expectKeyword("fragment"),this._options.experimentalFragmentVariables?{kind:l.Kind.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:l.Kind.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case h.BRACKET_L:return this.parseList(e);case h.BRACE_L:return this.parseObject(e);case h.INT:return this._lexer.advance(),{kind:l.Kind.INT,value:t.value,loc:this.loc(t)};case h.FLOAT:return this._lexer.advance(),{kind:l.Kind.FLOAT,value:t.value,loc:this.loc(t)};case h.STRING:case h.BLOCK_STRING:return this.parseStringLiteral();case h.NAME:return"true"===t.value||"false"===t.value?(this._lexer.advance(),{kind:l.Kind.BOOLEAN,value:"true"===t.value,loc:this.loc(t)}):"null"===t.value?(this._lexer.advance(),{kind:l.Kind.NULL,loc:this.loc(t)}):(this._lexer.advance(),{kind:l.Kind.ENUM,value:t.value,loc:this.loc(t)});case h.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:l.Kind.STRING,value:e.value,block:e.kind===h.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,n=this._lexer.token;return{kind:l.Kind.LIST,values:this.any(h.BRACKET_L,(function(){return t.parseValueLiteral(e)}),h.BRACKET_R),loc:this.loc(n)}},t.parseObject=function(e){var t=this,n=this._lexer.token;return{kind:l.Kind.OBJECT,fields:this.any(h.BRACE_L,(function(){return t.parseObjectField(e)}),h.BRACE_R),loc:this.loc(n)}},t.parseObjectField=function(e){var t=this._lexer.token,n=this.parseName();return this.expectToken(h.COLON),{kind:l.Kind.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(h.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(h.AT),{kind:l.Kind.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(h.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(h.BRACKET_R),e={kind:l.Kind.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(h.BANG)?{kind:l.Kind.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:l.Kind.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===h.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(h.STRING)||this.peek(h.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token;this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.many(h.BRACE_L,this.parseOperationTypeDefinition,h.BRACE_R);return{kind:l.Kind.SCHEMA_DEFINITION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(h.COLON);var n=this.parseNamedType();return{kind:l.Kind.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var n=this.parseName(),r=this.parseDirectives(!0);return{kind:l.Kind.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:l.Kind.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e=[];if(this.expectOptionalKeyword("implements")){this.expectOptionalToken(h.AMP);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(h.AMP)||this._options.allowLegacySDLImplementsInterfaces&&this.peek(h.NAME))}return e},t.parseFieldsDefinition=function(){return this._options.allowLegacySDLEmptyFields&&this.peek(h.BRACE_L)&&this._lexer.lookahead().kind===h.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(h.BRACE_L,this.parseFieldDefinition,h.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(h.COLON);var i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:l.Kind.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(h.PAREN_L,this.parseInputValueDef,h.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(h.COLON);var r,i=this.parseTypeReference();this.expectOptionalToken(h.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:l.Kind.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();return{kind:l.Kind.INTERFACE_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:l.Kind.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){var e=[];if(this.expectOptionalToken(h.EQUALS)){this.expectOptionalToken(h.PIPE);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(h.PIPE))}return e},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:l.Kind.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(h.BRACE_L,this.parseEnumValueDefinition,h.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:l.Kind.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:l.Kind.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(h.BRACE_L,this.parseInputValueDef,h.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===h.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.optionalMany(h.BRACE_L,this.parseOperationTypeDefinition,h.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:l.Kind.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:l.Kind.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:l.Kind.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:l.Kind.INTERFACE_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:l.Kind.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:l.Kind.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:l.Kind.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(h.AT);var n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:l.Kind.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){this.expectOptionalToken(h.PIPE);var e=[];do{e.push(this.parseDirectiveLocation())}while(this.expectOptionalToken(h.PIPE));return e},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==w.a[t.value])return t;throw this.unexpected(e)},t.loc=function(e){if(!this._options.noLocation)return new C(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw c(this._lexer.source,t.start,"Expected ".concat(e,", found ").concat(N(t)))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==h.NAME||t.value!==e)throw c(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(N(t)));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===h.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=e||this._lexer.token;return c(this._lexer.source,t.start,"Unexpected ".concat(N(t)))},t.any=function(e,t,n){this.expectToken(e);for(var r=[];!this.expectOptionalToken(n);)r.push(t.call(this));return r},t.optionalMany=function(e,t,n){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}return[]},t.many=function(e,t,n){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r},e}();function C(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}function N(e){var t=e.value;return t?"".concat(e.kind,' "').concat(t,'"'):e.kind}Object(s.a)(C,(function(){return{start:this.start,end:this.end}}));var D=n(17),j=Array.prototype.find?function(e,t){return Array.prototype.find.call(e,t)}:function(e,t){for(var n=0;n1&&"_"===e[0]&&"_"===e[1]?new u.a('Name "'.concat(e,'" must not begin with "__", which is reserved by GraphQL introspection.'),t):R.test(e)?void 0:new u.a('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "'.concat(e,'" does not.'),t)}var V=n(0);function U(e,t){return e===t||(Object(V.L)(e)&&Object(V.L)(t)?U(e.ofType,t.ofType):!(!Object(V.J)(e)||!Object(V.J)(t))&&U(e.ofType,t.ofType))}function B(e,t,n){return t===n||(Object(V.L)(n)?!!Object(V.L)(t)&&B(e,t.ofType,n.ofType):Object(V.L)(t)?B(e,t.ofType,n):Object(V.J)(n)?!!Object(V.J)(t)&&B(e,t.ofType,n.ofType):!Object(V.J)(t)&&!!(Object(V.C)(n)&&Object(V.N)(t)&&e.isPossibleType(n,t)))}function q(e,t,n){return t===n||(Object(V.C)(t)?Object(V.C)(n)?e.getPossibleTypes(t).some((function(t){return e.isPossibleType(n,t)})):e.isPossibleType(t,n):!!Object(V.C)(n)&&e.isPossibleType(n,t))}var K=n(20),H=n(28),z=n(15),G=n(9);function Q(e){return Object(H.a)(e,Y)}function W(e){if(!Q(e))throw new Error("Expected ".concat(Object(o.a)(e)," to be a GraphQL directive."));return e}var Y=function(){function e(e){this.name=e.name,this.description=e.description,this.locations=e.locations,this.isRepeatable=null!=e.isRepeatable&&e.isRepeatable,this.extensions=e.extensions&&Object(K.a)(e.extensions),this.astNode=e.astNode,e.name||Object(a.a)(0,"Directive must be named."),Array.isArray(e.locations)||Object(a.a)(0,"@".concat(e.name," locations must be an Array."));var t=e.args||{};Object(z.a)(t)&&!Array.isArray(t)||Object(a.a)(0,"@".concat(e.name," args must be an object with argument names as keys.")),this.args=Object(F.a)(t).map((function(e){var t=e[0],n=e[1];return{name:t,description:void 0===n.description?null:n.description,type:n.type,defaultValue:n.defaultValue,extensions:n.extensions&&Object(K.a)(n.extensions),astNode:n.astNode}}))}var t=e.prototype;return t.toString=function(){return"@"+this.name},t.toConfig=function(){return{name:this.name,description:this.description,locations:this.locations,args:Object(V.i)(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}},e}();Object(f.a)(Y),Object(s.a)(Y);var J=new Y({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[w.a.FIELD,w.a.FRAGMENT_SPREAD,w.a.INLINE_FRAGMENT],args:{if:{type:Object(V.e)(G.a),description:"Included when true."}}}),$=new Y({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[w.a.FIELD,w.a.FRAGMENT_SPREAD,w.a.INLINE_FRAGMENT],args:{if:{type:Object(V.e)(G.a),description:"Skipped when true."}}}),X="No longer supported",Z=new Y({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[w.a.FIELD_DEFINITION,w.a.ENUM_VALUE],args:{reason:{type:G.e,description:"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax (as specified by [CommonMark](https://commonmark.org/).",defaultValue:X}}}),ee=Object.freeze([J,$,Z]);function te(e){return Q(e)&&ee.some((function(t){return t.name===e.name}))}var ne=n(8);function re(e){return Object(H.a)(e,oe)}function ie(e){if(!re(e))throw new Error("Expected ".concat(Object(o.a)(e)," to be a GraphQL schema."));return e}var oe=function(){function e(e){e&&e.assumeValid?this.__validationErrors=[]:(this.__validationErrors=void 0,Object(z.a)(e)||Object(a.a)(0,"Must provide configuration object."),!e.types||Array.isArray(e.types)||Object(a.a)(0,'"types" must be Array if provided but got: '.concat(Object(o.a)(e.types),".")),!e.directives||Array.isArray(e.directives)||Object(a.a)(0,'"directives" must be Array if provided but got: '+"".concat(Object(o.a)(e.directives),".")),!e.allowedLegacyNames||Array.isArray(e.allowedLegacyNames)||Object(a.a)(0,'"allowedLegacyNames" must be Array if provided but got: '+"".concat(Object(o.a)(e.allowedLegacyNames),"."))),this.extensions=e.extensions&&Object(K.a)(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=e.extensionASTNodes,this.__allowedLegacyNames=e.allowedLegacyNames||[],this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=e.directives||ee;var t=[this._queryType,this._mutationType,this._subscriptionType,ne.__Schema].concat(e.types),n=Object.create(null);n=t.reduce(ae,n),n=this._directives.reduce(se,n),this._typeMap=n,this._possibleTypeMap=Object.create(null),this._implementations=Object.create(null);for(var r=0,i=Object(I.a)(this._typeMap);r0)return this._typeStack[this._typeStack.length-1]},t.getParentType=function(){if(this._parentTypeStack.length>0)return this._parentTypeStack[this._parentTypeStack.length-1]},t.getInputType=function(){if(this._inputTypeStack.length>0)return this._inputTypeStack[this._inputTypeStack.length-1]},t.getParentInputType=function(){if(this._inputTypeStack.length>1)return this._inputTypeStack[this._inputTypeStack.length-2]},t.getFieldDef=function(){if(this._fieldDefStack.length>0)return this._fieldDefStack[this._fieldDefStack.length-1]},t.getDefaultValue=function(){if(this._defaultValueStack.length>0)return this._defaultValueStack[this._defaultValueStack.length-1]},t.getDirective=function(){return this._directive},t.getArgument=function(){return this._argument},t.getEnumValue=function(){return this._enumValue},t.enter=function(e){var t=this._schema;switch(e.kind){case l.Kind.SELECTION_SET:var n=Object(V.A)(this.getType());this._parentTypeStack.push(Object(V.D)(n)?n:void 0);break;case l.Kind.FIELD:var r,i,o=this.getParentType();o&&(r=this._getFieldDef(t,o,e))&&(i=r.type),this._fieldDefStack.push(r),this._typeStack.push(Object(V.O)(i)?i:void 0);break;case l.Kind.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case l.Kind.OPERATION_DEFINITION:var a;"query"===e.operation?a=t.getQueryType():"mutation"===e.operation?a=t.getMutationType():"subscription"===e.operation&&(a=t.getSubscriptionType()),this._typeStack.push(Object(V.N)(a)?a:void 0);break;case l.Kind.INLINE_FRAGMENT:case l.Kind.FRAGMENT_DEFINITION:var s=e.typeCondition,u=s?_e(t,s):Object(V.A)(this.getType());this._typeStack.push(Object(V.O)(u)?u:void 0);break;case l.Kind.VARIABLE_DEFINITION:var c=_e(t,e.type);this._inputTypeStack.push(Object(V.G)(c)?c:void 0);break;case l.Kind.ARGUMENT:var f,p,d=this.getDirective()||this.getFieldDef();d&&(f=j(d.args,(function(t){return t.name===e.name.value})))&&(p=f.type),this._argument=f,this._defaultValueStack.push(f?f.defaultValue:void 0),this._inputTypeStack.push(Object(V.G)(p)?p:void 0);break;case l.Kind.LIST:var h=Object(V.B)(this.getInputType()),m=Object(V.J)(h)?h.ofType:h;this._defaultValueStack.push(void 0),this._inputTypeStack.push(Object(V.G)(m)?m:void 0);break;case l.Kind.OBJECT_FIELD:var v,y,g=Object(V.A)(this.getInputType());Object(V.F)(g)&&(y=g.getFields()[e.name.value])&&(v=y.type),this._defaultValueStack.push(y?y.defaultValue:void 0),this._inputTypeStack.push(Object(V.G)(v)?v:void 0);break;case l.Kind.ENUM:var b,O=Object(V.A)(this.getInputType());Object(V.E)(O)&&(b=O.getValue(e.value)),this._enumValue=b}},t.leave=function(e){switch(e.kind){case l.Kind.SELECTION_SET:this._parentTypeStack.pop();break;case l.Kind.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case l.Kind.DIRECTIVE:this._directive=null;break;case l.Kind.OPERATION_DEFINITION:case l.Kind.INLINE_FRAGMENT:case l.Kind.FRAGMENT_DEFINITION:this._typeStack.pop();break;case l.Kind.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case l.Kind.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case l.Kind.LIST:case l.Kind.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case l.Kind.ENUM:this._enumValue=null}},e}();function xe(e,t,n){var r=n.name.value;return r===ne.SchemaMetaFieldDef.name&&e.getQueryType()===t?ne.SchemaMetaFieldDef:r===ne.TypeMetaFieldDef.name&&e.getQueryType()===t?ne.TypeMetaFieldDef:r===ne.TypeNameMetaFieldDef.name&&Object(V.D)(t)?ne.TypeNameMetaFieldDef:Object(V.N)(t)||Object(V.H)(t)?t.getFields()[r]:void 0}var Se=n(58);function Ce(e){var t=Object.create(null);return{OperationDefinition:function(n){var r=n.name;return r&&(t[r.value]?e.reportError(new u.a(function(e){return'There can be only one operation named "'.concat(e,'".')}(r.value),[t[r.value],r])):t[r.value]=r),!1},FragmentDefinition:function(){return!1}}}function Ne(e){var t=0;return{Document:function(e){t=e.definitions.filter((function(e){return e.kind===l.Kind.OPERATION_DEFINITION})).length},OperationDefinition:function(n){!n.name&&t>1&&e.reportError(new u.a("This anonymous operation must be the only defined operation.",n))}}}function De(e){return{OperationDefinition:function(t){var n;"subscription"===t.operation&&1!==t.selectionSet.selections.length&&e.reportError(new u.a((n=t.name&&t.name.value)?'Subscription "'.concat(n,'" must select only one top level field.'):"Anonymous Subscription must select only one top level field.",t.selectionSet.selections.slice(1)))}}}var je=5;function Ae(e,t){var n="string"==typeof e?[e,t]:[void 0,e],r=n[0],i=n[1],o=" Did you mean ";switch(r&&(o+=r+" "),i.length){case 0:return"";case 1:return o+i[0]+"?";case 2:return o+i[0]+" or "+i[1]+"?"}var a=i.slice(0,je),s=a.pop();return o+a.join(", ")+", or "+s+"?"}function Le(e,t){for(var n=Object.create(null),r=e.length/2,i=0;i1&&l>1&&r[c-1]===i[l-2]&&r[c-2]===i[l-1]&&(n[c][l]=Math.min(n[c][l],n[c-2][l-2]+f))}return n[o][a]}var Fe=n(27);function Re(e){for(var t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null),i=0,o=e.getDocument().definitions;i1)for(var l=0;l0)return[[t,e.map((function(e){return e[0]}))],e.reduce((function(e,t){var n=t[1];return e.concat(n)}),[n]),e.reduce((function(e,t){var n=t[2];return e.concat(n)}),[r])]}(function(e,t,n,r,i,o,a,s){var u=[],c=Dt(e,t,i,o),l=c[0],f=c[1],p=Dt(e,t,a,s),d=p[0],h=p[1];if(Ct(e,u,t,n,r,l,d),0!==h.length)for(var m=Object.create(null),v=0;v0&&e.reportError(new u.a("Must provide only one schema definition.",t)),++r)}}},function(e){var t=e.getSchema(),n=Object.create(null),r=t?{query:t.getQueryType(),mutation:t.getMutationType(),subscription:t.getSubscriptionType()}:{};return{SchemaDefinition:i,SchemaExtension:i};function i(t){if(t.operationTypes)for(var i=0,o=t.operationTypes||[];i2&&void 0!==arguments[2]?arguments[2]:Qt,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new ke(e),i=arguments.length>4?arguments[4]:void 0;t||Object(a.a)(0,"Must provide document"),ce(e);var o=Object.freeze({}),s=[],c=i&&i.maxErrors,l=new Xt(e,t,r,(function(e){if(null!=c&&s.length>=c)throw s.push(new u.a("Too many validation errors, error limit reached. Validation aborted.")),o;s.push(e)})),f=Object(D.d)(n.map((function(e){return e(l)})));try{Object(D.c)(t,Object(D.e)(r,f))}catch(e){if(e!==o)throw e}return s}function en(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Wt,r=[],i=new $t(e,t,(function(e){r.push(e)})),o=n.map((function(e){return e(i)}));return Object(D.c)(e,Object(D.d)(o)),r}var tn=n(23);var nn=n(40);function rn(e,t){return{prev:e,key:t}}function on(e){for(var t=[],n=e;n;)t.push(n.key),n=n.prev;return t.reverse()}function an(e,t,n){return e&&Array.isArray(e.path)?e:new u.a(e&&e.message,e&&e.nodes||t,e&&e.source,e&&e.positions,n,e)}function sn(e,t){if("query"===t.operation){var n=e.getQueryType();if(!n)throw new u.a("Schema does not define the required query root type.",t);return n}if("mutation"===t.operation){var r=e.getMutationType();if(!r)throw new u.a("Schema is not configured for mutations.",t);return r}if("subscription"===t.operation){var i=e.getSubscriptionType();if(!i)throw new u.a("Schema is not configured for subscriptions.",t);return i}throw new u.a("Can only have query, mutation and subscription operations.",t)}function un(e){return e.map((function(e){return"number"==typeof e?"["+e.toString()+"]":"."+e})).join("")}function cn(e,t,n){if(e){if(Object(V.L)(t)){if(e.kind===l.Kind.NULL)return;return cn(e,t.ofType,n)}if(e.kind===l.Kind.NULL)return null;if(e.kind===l.Kind.VARIABLE){var r=e.name.value;if(!n||Object(ct.a)(n[r]))return;var i=n[r];if(null===i&&Object(V.L)(t))return;return i}if(Object(V.J)(t)){var a=t.ofType;if(e.kind===l.Kind.LIST){for(var s=[],u=0,c=e.values;u2&&void 0!==arguments[2]?arguments[2]:pn)}function pn(e,t,n){var r="Invalid value "+Object(o.a)(t);throw e.length>0&&(r+=' at "value'.concat(un(e),'": ')),n.message=r+": "+n.message,n}function dn(e,t,n,r){var i=r&&r.maxErrors,a=[];try{var s=function(e,t,n,r){for(var i={},a=function(a){var s=t[a],c=s.variable.name.value,l=_e(e,s.type);if(!Object(V.G)(l)){var f=Object(Pe.a)(s.type);return r(new u.a('Variable "$'.concat(c,'" expected value of type "').concat(f,'" which cannot be used as an input type.'),s.type)),"continue"}if(!vn(n,c)){if(s.defaultValue)i[c]=cn(s.defaultValue,l);else if(Object(V.L)(l)){var p=Object(o.a)(l);r(new u.a('Variable "$'.concat(c,'" of required type "').concat(p,'" was not provided.'),s))}return"continue"}var d=n[c];if(null===d&&Object(V.L)(l)){var h=Object(o.a)(l);return r(new u.a('Variable "$'.concat(c,'" of non-null type "').concat(h,'" must not be null.'),s)),"continue"}i[c]=fn(d,l,(function(e,t,n){var i='Variable "$'.concat(c,'" got invalid value ')+Object(o.a)(t);e.length>0&&(i+=' at "'.concat(c).concat(un(e),'"')),r(new u.a(i+"; "+n.message,s,void 0,void 0,void 0,n.originalError))}))},s=0;s=i)throw new u.a("Too many errors processing variables, error limit reached. Execution aborted.");a.push(e)}));if(0===a.length)return{coerced:s}}catch(e){a.push(e)}return{errors:a}}function hn(e,t,n){for(var r={},i=Object(ut.a)(t.arguments||[],(function(e){return e.name.value})),a=0,s=e.args;a0)return{errors:l};try{t=_(r)}catch(e){return{errors:[e]}}var f=Zt(n,t);return f.length>0?{errors:f}:yn({schema:n,document:t,rootValue:i,contextValue:o,variableValues:a,operationName:s,fieldResolver:u,typeResolver:c})}var zn=n(38),Gn=n(61);function Qn(e,t,n){var r,i,o,a,s,u,c=Object(tn.c)(e);function l(e){return e.done?e:Wn(e.value,t).then(Yn,i)}if("function"==typeof c.return&&(r=c.return,i=function(e){var t=function(){return Promise.reject(e)};return r.call(c).then(t,t)}),n){var f=n;o=function(e){return Wn(e,f).then(Yn,i)}}return a={next:function(){return c.next().then(l,o)},return:function(){return r?r.call(c).then(l,o):Promise.resolve({value:void 0,done:!0})},throw:function(e){return"function"==typeof c.throw?c.throw(e).then(l,o):Promise.reject(e).catch(i)}},s=tn.a,u=function(){return this},s in a?Object.defineProperty(a,s,{value:u,enumerable:!0,configurable:!0,writable:!0}):a[s]=u,a}function Wn(e,t){return new Promise((function(n){return n(t(e))}))}function Yn(e){return{value:e,done:!1}}function Jn(e,t,n,r,i,o,a,s){return 1===arguments.length?Xn(e):Xn({schema:e,document:t,rootValue:n,contextValue:r,variableValues:i,operationName:o,fieldResolver:a,subscribeFieldResolver:s})}function $n(e){if(e instanceof u.a)return{errors:[e]};throw e}function Xn(e){var t=e.schema,n=e.document,r=e.rootValue,i=e.contextValue,o=e.variableValues,a=e.operationName,s=e.fieldResolver,u=e.subscribeFieldResolver,c=Zn(t,n,r,i,o,a,u),l=function(e){return yn(t,n,e,i,o,a,s)};return c.then((function(e){return Object(tn.d)(e)?Qn(e,l,$n):e}))}function Zn(e,t,n,r,i,a,s){bn(e,t,i);try{var c=On(e,t,n,r,i,a,s);if(Array.isArray(c))return Promise.resolve({errors:c});var l=sn(e,c.operation),f=Tn(c,l,c.operation.selectionSet,Object.create(null),Object.create(null)),p=Object.keys(f)[0],d=f[p],h=d[0].name.value,m=Bn(e,l,h);if(!m)throw new u.a('The subscription field "'.concat(h,'" is not defined.'),d);var v=m.subscribe||c.fieldResolver,y=rn(void 0,p),g=xn(c,m,d,l,y),b=Sn(c,m,d,v,n,g);return Promise.resolve(b).then((function(e){if(e instanceof Error)return{errors:[an(e,d,on(y))]};if(Object(tn.d)(e))return e;throw new Error("Subscription field must return Async Iterable. Received: "+Object(o.a)(e))}))}catch(e){return e instanceof u.a?Promise.resolve({errors:[e]}):Promise.reject(e)}}function er(e){e||Object(a.a)(0,"Received null or undefined error.");var t=e.message||"An unknown error occurred.",n=e.locations,r=e.path,i=e.extensions;return i?{message:t,locations:n,path:r,extensions:i}:{message:t,locations:n,path:r}}function tr(e){var t=!(e&&!1===e.descriptions);return"\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n ...FullType\n }\n directives {\n name\n ".concat(t?"description":"","\n locations\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n ").concat(t?"description":"","\n fields(includeDeprecated: true) {\n name\n ").concat(t?"description":"","\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n ").concat(t?"description":"","\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n ").concat(t?"description":"","\n type { ...TypeRef }\n defaultValue\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n ")}var nr=tr();function rr(e,t){for(var n=null,r=0,i=e.definitions;r0?function(){return n.map((function(e){return t.getNamedType(e)}))}:[],o=r&&r.length>0?function(){return lr(r,(function(e){return t.buildField(e)}))}:Object.create(null);return new V.f({name:e.name.value,description:pr(e,this._options),interfaces:i,fields:o,astNode:e})},t._makeInterfaceDef=function(e){var t=this,n=e.fields,r=n&&n.length>0?function(){return lr(n,(function(e){return t.buildField(e)}))}:Object.create(null);return new V.c({name:e.name.value,description:pr(e,this._options),fields:r,astNode:e})},t._makeEnumDef=function(e){var t=this,n=e.values||[];return new V.a({name:e.name.value,description:pr(e,this._options),values:lr(n,(function(e){return t.buildEnumValue(e)})),astNode:e})},t._makeUnionDef=function(e){var t=this,n=e.types,r=n&&n.length>0?function(){return n.map((function(e){return t.getNamedType(e)}))}:[];return new V.h({name:e.name.value,description:pr(e,this._options),types:r,astNode:e})},t._makeScalarDef=function(e){return new V.g({name:e.name.value,description:pr(e,this._options),astNode:e})},t._makeInputObjectDef=function(e){var t=this,n=e.fields;return new V.b({name:e.name.value,description:pr(e,this._options),fields:n?function(){return lr(n,(function(e){return t.buildInputField(e)}))}:Object.create(null),astNode:e})},e}();function lr(e,t){return Object(or.a)(e,(function(e){return e.name.value}),t)}function fr(e){var t=mn(Z,e);return t&&t.reason}function pr(e,t){if(e.description)return e.description.value;if(t&&t.commentDescriptions){var n=function(e){var t=e.loc;if(!t)return;var n=[],r=t.startToken.prev;for(;r&&r.kind===h.COMMENT&&r.next&&r.prev&&r.line+1===r.next.line&&r.line!==r.prev.line;){var i=String(r.value);n.push(i),r=r.prev}return n.reverse().join("\n")}(e);if(void 0!==n)return Object(d.a)("\n"+n)}}function dr(e,t){return sr(_(e,t),t)}var hr=n(30);function mr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function vr(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"";return 0===t.length?"":t.every((function(e){return!e.description}))?"("+t.map(Rr).join(", ")+")":"(\n"+t.map((function(t,r){return Pr(e,t," "+n,!r)+" "+n+Rr(t)})).join("\n")+"\n"+n+")"}function Rr(e){var t=Object(xr.a)(e.defaultValue,e.type),n=e.name+": "+String(e.type);return t&&(n+=" = ".concat(Object(Pe.a)(t))),n}function Mr(e){if(!e.isDeprecated)return"";var t=e.deprecationReason,n=Object(xr.a)(t,G.e);return n&&""!==t&&t!==X?" @deprecated(reason: "+Object(Pe.a)(n)+")":" @deprecated"}function Pr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!t.description)return"";var i,o,a,s=(i=t.description,o=120-n.length,a=i.split("\n"),L(a,(function(e){return e.length70;return(n&&!r?"\n"+n:n)+Object(d.c)(u,"",c).replace(/\n/g,"\n"+n)+"\n"}var Vr=n(93);function Ur(e,t,n,r){var i=[],a=fn(e,t,(function(e,t,a){var s="Invalid value "+Object(o.a)(t),c=[].concat(on(r),e);c.length>0&&(s+=' at "value'.concat(un(c),'"')),i.push(new u.a(s+": "+a.message,n,void 0,void 0,void 0,a.originalError))}));return i.length>0?{errors:i,value:void 0}:{errors:void 0,value:a}}function Br(e,t){var n=Ur(e,t).errors;return n?n.map((function(e){return e.message})):[]}function qr(e,t){var n=new oe({}),r={kind:l.Kind.DOCUMENT,definitions:[]},i=new ke(n,void 0,e),o=new Xt(n,r,i),a=pt(o);return Object(D.c)(t,Object(D.e)(i,a)),o.getErrors()}function Kr(e){return{kind:"Document",definitions:L(e,(function(e){return e.definitions}))}}function Hr(e){var t,n=[],r=Object.create(null),i=new Map,o=Object.create(null),a=0;Object(D.c)(e,{OperationDefinition:function(e){t=zr(e),n.push(e),i.set(e,a++)},FragmentDefinition:function(e){t=e.name.value,r[t]=e,i.set(e,a++)},FragmentSpread:function(e){var n=e.name.value;(o[t]||(o[t]=Object.create(null)))[n]=!0}});for(var s=Object.create(null),u=0;u0&&(n="\n"+n);var i=n[n.length-1];return('"'===i&&'\\"""'!==n.slice(-4)||"\\"===i)&&(n+="\n"),'"""'+n+'"""'}function Yr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Jr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var $r=Object.freeze({TYPE_REMOVED:"TYPE_REMOVED",TYPE_CHANGED_KIND:"TYPE_CHANGED_KIND",TYPE_REMOVED_FROM_UNION:"TYPE_REMOVED_FROM_UNION",VALUE_REMOVED_FROM_ENUM:"VALUE_REMOVED_FROM_ENUM",REQUIRED_INPUT_FIELD_ADDED:"REQUIRED_INPUT_FIELD_ADDED",INTERFACE_REMOVED_FROM_OBJECT:"INTERFACE_REMOVED_FROM_OBJECT",FIELD_REMOVED:"FIELD_REMOVED",FIELD_CHANGED_KIND:"FIELD_CHANGED_KIND",REQUIRED_ARG_ADDED:"REQUIRED_ARG_ADDED",ARG_REMOVED:"ARG_REMOVED",ARG_CHANGED_KIND:"ARG_CHANGED_KIND",DIRECTIVE_REMOVED:"DIRECTIVE_REMOVED",DIRECTIVE_ARG_REMOVED:"DIRECTIVE_ARG_REMOVED",REQUIRED_DIRECTIVE_ARG_ADDED:"REQUIRED_DIRECTIVE_ARG_ADDED",DIRECTIVE_LOCATION_REMOVED:"DIRECTIVE_LOCATION_REMOVED"}),Xr=Object.freeze({VALUE_ADDED_TO_ENUM:"VALUE_ADDED_TO_ENUM",TYPE_ADDED_TO_UNION:"TYPE_ADDED_TO_UNION",OPTIONAL_INPUT_FIELD_ADDED:"OPTIONAL_INPUT_FIELD_ADDED",OPTIONAL_ARG_ADDED:"OPTIONAL_ARG_ADDED",INTERFACE_ADDED_TO_OBJECT:"INTERFACE_ADDED_TO_OBJECT",ARG_DEFAULT_VALUE_CHANGE:"ARG_DEFAULT_VALUE_CHANGE"});function Zr(e,t){return ti(e,t).filter((function(e){return e.type in $r}))}function ei(e,t){return ti(e,t).filter((function(e){return e.type in Xr}))}function ti(e,t){return[].concat(function(e,t){for(var n=[],r=pi(Object(I.a)(e.getTypeMap()),Object(I.a)(t.getTypeMap())),i=0,o=r.removed;i2&&void 0!==arguments[2]?arguments[2]:i,a=void 0,u=Array.isArray(e),c=[e],f=-1,p=[],d=void 0,h=void 0,m=void 0,v=[],y=[],g=e;do{var b=++f===c.length,O=b&&0!==p.length;if(b){if(h=0===y.length?void 0:v[v.length-1],d=m,m=y.pop(),O){if(u)d=d.slice();else{for(var E={},T=0,w=Object.keys(d);T=0&&t%1==0}function s(e){return Object(e)===e&&(a(e)||function(e){return!!c(e)}(e))}function u(e){var t=c(e);if(t)return t.call(e)}function c(e){if(null!=e){var t=i&&e[i]||e["@@iterator"];if("function"==typeof t)return t}}function l(e){this._o=e,this._i=0}function f(e,t,n){if(null!=e){if("function"==typeof e.forEach)return e.forEach(t,n);var r=0,i=u(e);if(i){for(var o;!(o=i.next()).done;)if(t.call(n,o.value,r++,e),r>9999999)throw new TypeError("Near-infinite iteration.")}else if(a(e))for(;r=this._o.length?(this._o=void 0,{value:void 0,done:!0}):{value:this._o[this._i++],done:!1}};var p=r&&r.asyncIterator,d=p||"@@asyncIterator";function h(e){return!!v(e)}function m(e){var t=v(e);if(t)return t.call(e)}function v(e){if(null!=e){var t=p&&e[p]||e["@@asyncIterator"];if("function"==typeof t)return t}}function y(e){this._i=e}y.prototype[d]=function(){return this},y.prototype.next=function(){var e=this._i.next();return Promise.resolve(e.value).then((function(t){return{value:t,done:e.done}}))}},function(e,t,n){"use strict";function r(e){"function"==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return this.constructor.name}})}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(37);function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.prototype.toString;e.prototype.toJSON=t,e.prototype.inspect=t,r.a&&(e.prototype[r.a]=t)}},function(e,t,n){"use strict";var r=Object.entries||function(e){return Object.keys(e).map((function(t){return[t,e[t]]}))};t.a=r},function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return o})),n.d(t,"c",(function(){return a})),n.d(t,"i",(function(){return s})),n.d(t,"f",(function(){return u})),n.d(t,"g",(function(){return c})),n.d(t,"d",(function(){return l})),n.d(t,"h",(function(){return f})),n.d(t,"e",(function(){return p}));var r=n(1);function i(e){return o(e)||c(e)||f(e)}function o(e){return e.kind===r.Kind.OPERATION_DEFINITION||e.kind===r.Kind.FRAGMENT_DEFINITION}function a(e){return e.kind===r.Kind.FIELD||e.kind===r.Kind.FRAGMENT_SPREAD||e.kind===r.Kind.INLINE_FRAGMENT}function s(e){return e.kind===r.Kind.VARIABLE||e.kind===r.Kind.INT||e.kind===r.Kind.FLOAT||e.kind===r.Kind.STRING||e.kind===r.Kind.BOOLEAN||e.kind===r.Kind.NULL||e.kind===r.Kind.ENUM||e.kind===r.Kind.LIST||e.kind===r.Kind.OBJECT}function u(e){return e.kind===r.Kind.NAMED_TYPE||e.kind===r.Kind.LIST_TYPE||e.kind===r.Kind.NON_NULL_TYPE}function c(e){return e.kind===r.Kind.SCHEMA_DEFINITION||l(e)||e.kind===r.Kind.DIRECTIVE_DEFINITION}function l(e){return e.kind===r.Kind.SCALAR_TYPE_DEFINITION||e.kind===r.Kind.OBJECT_TYPE_DEFINITION||e.kind===r.Kind.INTERFACE_TYPE_DEFINITION||e.kind===r.Kind.UNION_TYPE_DEFINITION||e.kind===r.Kind.ENUM_TYPE_DEFINITION||e.kind===r.Kind.INPUT_OBJECT_TYPE_DEFINITION}function f(e){return e.kind===r.Kind.SCHEMA_EXTENSION||p(e)}function p(e){return e.kind===r.Kind.SCALAR_TYPE_EXTENSION||e.kind===r.Kind.OBJECT_TYPE_EXTENSION||e.kind===r.Kind.INTERFACE_TYPE_EXTENSION||e.kind===r.Kind.UNION_TYPE_EXTENSION||e.kind===r.Kind.ENUM_TYPE_EXTENSION||e.kind===r.Kind.INPUT_OBJECT_TYPE_EXTENSION}},function(e,t,n){"use strict";t.a=function(e,t){return e instanceof t}},function(e,t,n){"use strict";function r(e){var t=e.split(/\r\n|[\n\r]/g),n=i(t);if(0!==n)for(var r=1;r0&&a(t[0]);)t.shift();for(;t.length>0&&a(t[t.length-1]);)t.pop();return t.join("\n")}function i(e){for(var t=null,n=1;n1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],a=!r||o||n,s="";return!a||r&&i||(s+="\n"+t),s+=t?e.replace(/\n/g,"\n"+t):e,a&&(s+="\n"),'"""'+s.replace(/"""/g,'\\"""')+'"""'}n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return s}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(26);function i(e,t){for(var n=Object.create(null),i=0,o=Object(r.a)(e);ic);l++){var f=e.getLine(u++);a=null==a?f:a+"\n"+f}s*=2,t.lastIndex=n.ch;var p=t.exec(a);if(p){var d=a.slice(0,p.index).split("\n"),h=p[0].split("\n"),m=n.line+d.length-1,v=d[d.length-1].length;return{from:r(m,v),to:r(m+h.length-1,1==h.length?v+h[0].length:h[h.length-1].length),match:p}}}}function u(e,t){for(var n,r=0;;){t.lastIndex=r;var i=t.exec(e);if(!i)return n;if((r=(n=i).index+(n[0].length||1))==e.length)return n}}function c(e,t,n){t=i(t,"g");for(var o=n.line,a=n.ch,s=e.firstLine();o>=s;o--,a=-1){var c=e.getLine(o);a>-1&&(c=c.slice(0,a));var l=u(c,t);if(l)return{from:r(o,l.index),to:r(o,l.index+l[0].length),match:l}}}function l(e,t,n){t=i(t,"gm");for(var o,a=1,s=n.line,c=e.firstLine();s>=c;){for(var l=0;l>1,s=r(e.slice(0,a)).length;if(s==n)return a;s>n?o=a:i=a+1}}function p(e,i,o,a){if(!i.length)return null;var s=a?t:n,u=s(i).split(/\r|\n\r?/);e:for(var c=o.line,l=o.ch,p=e.lastLine()+1-u.length;c<=p;c++,l=0){var d=e.getLine(c).slice(l),h=s(d);if(1==u.length){var m=h.indexOf(u[0]);if(-1==m)continue e;return o=f(d,h,m,s)+l,{from:r(c,f(d,h,m,s)+l),to:r(c,f(d,h,m+u[0].length,s)+l)}}var v=h.length-u[0].length;if(h.slice(v)==u[0]){for(var y=1;y=p;c--,l=-1){var d=e.getLine(c);l>-1&&(d=d.slice(0,l));var h=s(d);if(1==u.length){var m=h.lastIndexOf(u[0]);if(-1==m)continue e;return{from:r(c,f(d,h,m,s)),to:r(c,f(d,h,m+u[0].length,s))}}var v=u[u.length-1];if(h.slice(0,v.length)==v){var y=1;for(o=c-u.length+1;y0);)r.push({anchor:i.from(),head:i.to()});r.length&&this.setSelections(r,0)}))}))},void 0===(o="function"==typeof r?r.apply(t,i):r)||(e.exports=o)}).call(this,n(21)(e))},function(e,t,n){(function(e){var r,i,o;i=[],r=function(){"use strict";function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(s){"object"==a(t)&&"object"==a(e)?s(n(6)):(i=[n(6)],void 0===(o="function"==typeof(r=s)?r.apply(t,i):r)||(e.exports=o))}((function(e){function t(t,n,r){var i,o=t.getWrapperElement();return(i=o.appendChild(document.createElement("div"))).className=r?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof n?i.innerHTML=n:i.appendChild(n),e.addClass(o,"dialog-opened"),i}function n(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}e.defineExtension("openDialog",(function(r,i,o){o||(o={}),n(this,null);var a=t(this,r,o.bottom),s=!1,u=this;function c(t){if("string"==typeof t)f.value=t;else{if(s)return;s=!0,e.rmClass(a.parentNode,"dialog-opened"),a.parentNode.removeChild(a),u.focus(),o.onClose&&o.onClose(a)}}var l,f=a.getElementsByTagName("input")[0];return f?(f.focus(),o.value&&(f.value=o.value,!1!==o.selectValueOnOpen&&f.select()),o.onInput&&e.on(f,"input",(function(e){o.onInput(e,f.value,c)})),o.onKeyUp&&e.on(f,"keyup",(function(e){o.onKeyUp(e,f.value,c)})),e.on(f,"keydown",(function(t){o&&o.onKeyDown&&o.onKeyDown(t,f.value,c)||((27==t.keyCode||!1!==o.closeOnEnter&&13==t.keyCode)&&(f.blur(),e.e_stop(t),c()),13==t.keyCode&&i(f.value,t))})),!1!==o.closeOnBlur&&e.on(f,"blur",c)):(l=a.getElementsByTagName("button")[0])&&(e.on(l,"click",(function(){c(),u.focus()})),!1!==o.closeOnBlur&&e.on(l,"blur",c),l.focus()),c})),e.defineExtension("openConfirm",(function(r,i,o){n(this,null);var a=t(this,r,o&&o.bottom),s=a.getElementsByTagName("button"),u=!1,c=this,l=1;function f(){u||(u=!0,e.rmClass(a.parentNode,"dialog-opened"),a.parentNode.removeChild(a),c.focus())}s[0].focus();for(var p=0;p",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function i(e){return e&&e.bracketRegex||/[(){}[\]]/}function o(e,t,o){var a=e.getLineHandle(t.line),u=t.ch-1,c=o&&o.afterCursor;null==c&&(c=/(^| )cm-fat-cursor($| )/.test(e.getWrapperElement().className));var l=i(o),f=!c&&u>=0&&l.test(a.text.charAt(u))&&r[a.text.charAt(u)]||l.test(a.text.charAt(u+1))&&r[a.text.charAt(++u)];if(!f)return null;var p=">"==f.charAt(1)?1:-1;if(o&&o.strict&&p>0!=(u==t.ch))return null;var d=e.getTokenTypeAt(n(t.line,u+1)),h=s(e,n(t.line,u+(p>0?1:0)),p,d||null,o);return null==h?null:{from:n(t.line,u),to:h&&h.pos,match:h&&h.ch==f.charAt(0),forward:p>0}}function s(e,t,o,a,s){for(var u=s&&s.maxScanLineLength||1e4,c=s&&s.maxScanLines||1e3,l=[],f=i(s),p=o>0?Math.min(t.line+c,e.lastLine()+1):Math.max(e.firstLine()-1,t.line-c),d=t.line;d!=p;d+=o){var h=e.getLine(d);if(h){var m=o>0?0:h.length-1,v=o>0?h.length:-1;if(!(h.length>u))for(d==t.line&&(m=t.ch-(o<0?1:0));m!=v;m+=o){var y=h.charAt(m);if(f.test(y)&&(void 0===a||e.getTokenTypeAt(n(d,m+1))==a)){var g=r[y];if(g&&">"==g.charAt(1)==o>0)l.push(y);else{if(!l.length)return{pos:n(d,m),ch:y};l.pop()}}}}}return d-o!=(o>0?e.lastLine():e.firstLine())&&null}function u(e,r,i){for(var a=e.state.matchBrackets.maxHighlightLineLength||1e3,s=[],u=e.listSelections(),c=0;c=0&&(n=this.attrs[t][1]),n},t.prototype.attrJoin=function(e,t){var n=this.attrIndex(e);n<0?this.attrPush([e,t]):this.attrs[n][1]=this.attrs[n][1]+" "+t},e.exports=t})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t],void 0===(o="function"==typeof(r=function(e){"use strict";var t;function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=!1;"object"===("undefined"==typeof window?"undefined":r(window))&&(i="MacIntel"===window.navigator.platform);var o=(n(t={},i?"Cmd-F":"Ctrl-F","findPersistent"),n(t,"Cmd-G","findPersistent"),n(t,"Ctrl-G","findPersistent"),n(t,"Ctrl-Left","goSubwordLeft"),n(t,"Ctrl-Right","goSubwordRight"),n(t,"Alt-Left","goGroupLeft"),n(t,"Alt-Right","goGroupRight"),t);e.default=o})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){(function(e){var r,i,o;i=[],r=function(){"use strict";function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(s){"object"==a(t)&&"object"==a(e)?s(n(6),n(75)):(i=[n(6),n(75)],void 0===(o="function"==typeof(r=s)?r.apply(t,i):r)||(e.exports=o))}((function(e){e.defineOption("foldGutter",!1,(function(t,r,i){var o;i&&i!=e.Init&&(t.clearGutter(t.state.foldGutter.options.gutter),t.state.foldGutter=null,t.off("gutterClick",u),t.off("changes",c),t.off("viewportChange",l),t.off("fold",f),t.off("unfold",f),t.off("swapDoc",c)),r&&(t.state.foldGutter=new n((!0===(o=r)&&(o={}),null==o.gutter&&(o.gutter="CodeMirror-foldgutter"),null==o.indicatorOpen&&(o.indicatorOpen="CodeMirror-foldgutter-open"),null==o.indicatorFolded&&(o.indicatorFolded="CodeMirror-foldgutter-folded"),o)),s(t),t.on("gutterClick",u),t.on("changes",c),t.on("viewportChange",l),t.on("fold",f),t.on("unfold",f),t.on("swapDoc",c))}));var t=e.Pos;function n(e){this.options=e,this.from=this.to=0}function r(e,n){for(var r=e.findMarks(t(n,0),t(n+1,0)),i=0;i=c){if(p&&a&&p.test(a.className))return;o=i(s.indicatorOpen)}}(o||a)&&e.setGutterMarker(n,s.gutter,o)}))}function a(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function s(e){var t=e.getViewport(),n=e.state.foldGutter;n&&(e.operation((function(){o(e,t.from,t.to)})),n.from=t.from,n.to=t.to)}function u(e,n,i){var o=e.state.foldGutter;if(o){var a=o.options;if(i==a.gutter){var s=r(e,n);s?s.clear():e.foldCode(t(n,0),a)}}}function c(e){var t=e.state.foldGutter;if(t){var n=t.options;t.from=t.to=0,clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout((function(){s(e)}),n.foldOnChangeTimeSpan||600)}}function l(e){var t=e.state.foldGutter;if(t){var n=t.options;clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout((function(){var n=e.getViewport();t.from==t.to||n.from-t.to>20||t.from-n.to>20?s(e):e.operation((function(){n.fromt.to&&(o(e,t.to,n.to),t.to=n.to)}))}),n.updateViewportTimeSpan||400)}}function f(e,t){var n=e.state.foldGutter;if(n){var r=t.line;r>=n.from&&rt.lastLine())return null;var r=t.getTokenAt(e.Pos(n,1));if(/\S/.test(r.string)||(r=t.getTokenAt(e.Pos(n,r.end+1))),"keyword"!=r.type||"import"!=r.string)return null;for(var i=n,o=Math.min(t.lastLine(),n+10);i<=o;++i){var a=t.getLine(i).indexOf(";");if(-1!=a)return{startCh:r.end,end:e.Pos(i,a)}}}var i,o=n.line,a=r(o);if(!a||r(o-1)||(i=r(o-2))&&i.end.line==o-1)return null;for(var s=a.end;;){var u=r(s.line+1);if(null==u)break;s=u.end}return{from:t.clipPos(e.Pos(o,a.startCh+1)),to:s}})),e.registerHelper("fold","include",(function(t,n){function r(n){if(nt.lastLine())return null;var r=t.getTokenAt(e.Pos(n,1));return/\S/.test(r.string)||(r=t.getTokenAt(e.Pos(n,r.end+1))),"meta"==r.type&&"#include"==r.string.slice(0,8)?r.start+8:void 0}var i=n.line,o=r(i);if(null==o||null!=r(i-1))return null;for(var a=i;null!=r(a+1);)++a;return{from:e.Pos(i,o+1),to:t.clipPos(e.Pos(a))}}))}))},void 0===(o="function"==typeof r?r.apply(t,i):r)||(e.exports=o)}).call(this,n(21)(e))},function(e,t,n){(function(e){var r,i,o;i=[],r=function(){"use strict";function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(s){"object"==a(t)&&"object"==a(e)?s(n(6),n(32)):(i=[n(6),n(32)],void 0===(o="function"==typeof(r=s)?r.apply(t,i):r)||(e.exports=o))}((function(e){function t(e,t){var n=Number(t);return/^[-+]/.test(t)?e.getCursor().line+n:n-1}e.commands.jumpToLine=function(e){var n=e.getCursor();!function(e,t,n,r,i){e.openDialog?e.openDialog(t,i,{value:r,selectValueOnOpen:!0}):i(prompt(n,r))}(e,function(e){return e.phrase("Jump to line:")+' '+e.phrase("(Use line:column or scroll% syntax)")+""}(e),e.phrase("Jump to line:"),n.line+1+":"+n.ch,(function(r){var i;if(r)if(i=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(r))e.setCursor(t(e,i[1]),Number(i[2]));else if(i=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(r)){var o=Math.round(e.lineCount()*Number(i[1])/100);/^[-+]/.test(i[1])&&(o=n.line+o+1),e.setCursor(o-1,n.ch)}else(i=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(r))&&e.setCursor(t(e,i[1]),n.ch)}))},e.keyMap.default["Alt-G"]="jumpToLine"}))},void 0===(o="function"==typeof r?r.apply(t,i):r)||(e.exports=o)}).call(this,n(21)(e))},function(e,t,n){(function(e){var r,i,o;i=[],r=function(){"use strict";function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(s){"object"==a(t)&&"object"==a(e)?s(n(6),n(31),n(39)):(i=[n(6),n(31),n(39)],void 0===(o="function"==typeof(r=s)?r.apply(t,i):r)||(e.exports=o))}((function(e){var t=e.commands,n=e.Pos;function r(t,r){t.extendSelectionsBy((function(i){return t.display.shift||t.doc.extend||i.empty()?function(t,r,i){if(i<0&&0==r.ch)return t.clipPos(n(r.line-1));var o=t.getLine(r.line);if(i>0&&r.ch>=o.length)return t.clipPos(n(r.line+1,0));for(var a,s="start",u=r.ch,c=i<0?0:o.length,l=0;u!=c;u+=i,l++){var f=o.charAt(i<0?u-1:u),p="_"!=f&&e.isWordChar(f)?"w":"o";if("w"==p&&f.toUpperCase()==f&&(p="W"),"start"==s)"o"!=p&&(s="in",a=p);else if("in"==s&&a!=p){if("w"==a&&"W"==p&&i<0&&u--,"W"==a&&"w"==p&&i>0){a="w";continue}break}}return n(r.line,u)}(t.doc,i.head,r):r<0?i.from():i.to()}))}function i(t,r){if(t.isReadOnly())return e.Pass;t.operation((function(){for(var e=t.listSelections().length,i=[],o=-1,a=0;a=n&&e.execCommand("goLineUp")}e.scrollTo(null,t.top-e.defaultTextHeight())},t.scrollLineDown=function(e){var t=e.getScrollInfo();if(!e.somethingSelected()){var n=e.lineAtHeight(t.top,"local")+1;e.getCursor().line<=n&&e.execCommand("goLineDown")}e.scrollTo(null,t.top+e.defaultTextHeight())},t.splitSelectionByLine=function(e){for(var t=e.listSelections(),r=[],i=0;io.line&&s==a.line&&0==a.ch||r.push({anchor:s==o.line?o:n(s,0),head:s==a.line?a:n(s)});e.setSelections(r,0)},t.singleSelectionTop=function(e){var t=e.listSelections()[0];e.setSelection(t.anchor,t.head,{scroll:!1})},t.selectLine=function(e){for(var t=e.listSelections(),r=[],i=0;i=0;s--){var c=r[i[s]];if(!(u&&e.cmpPos(c.head,u)>0)){var l=o(t,c.head);u=l.from,t.replaceRange(n(l.word),l.from,l.to)}}}))}function f(t){var n=t.getCursor("from"),r=t.getCursor("to");if(0==e.cmpPos(n,r)){var i=o(t,n);if(!i.word)return;n=i.from,r=i.to}return{from:n,to:r,query:t.getRange(n,r),word:i}}function p(e,t){var r=f(e);if(r){var i=r.query,o=e.getSearchCursor(i,t?r.to:r.from);(t?o.findNext():o.findPrevious())?e.setSelection(o.from(),o.to()):(o=e.getSearchCursor(i,t?n(e.firstLine(),0):e.clipPos(n(e.lastLine()))),(t?o.findNext():o.findPrevious())?e.setSelection(o.from(),o.to()):r.word&&e.setSelection(r.from,r.to))}}t.selectScope=function(e){u(e)||e.execCommand("selectAll")},t.selectBetweenBrackets=function(t){if(!u(t))return e.Pass},t.goToBracket=function(t){t.extendSelectionsBy((function(r){var i=t.scanForBracket(r.head,1);if(i&&0!=e.cmpPos(i.pos,r.head))return i.pos;var o=t.scanForBracket(r.head,-1);return o&&n(o.pos.line,o.pos.ch+1)||r.head}))},t.swapLineUp=function(t){if(t.isReadOnly())return e.Pass;for(var r=t.listSelections(),i=[],o=t.firstLine()-1,a=[],s=0;so?i.push(c,l):i.length&&(i[i.length-1]=l),o=l}t.operation((function(){for(var e=0;et.lastLine()?t.replaceRange("\n"+s,n(t.lastLine()),null,"+swapLine"):t.replaceRange(s+"\n",n(o,0),null,"+swapLine")}t.setSelections(a),t.scrollIntoView()}))},t.swapLineDown=function(t){if(t.isReadOnly())return e.Pass;for(var r=t.listSelections(),i=[],o=t.lastLine()+1,a=r.length-1;a>=0;a--){var s=r[a],u=s.to().line+1,c=s.from().line;0!=s.to().ch||s.empty()||u--,u=0;e-=2){var r=i[e],o=i[e+1],a=t.getLine(r);r==t.lastLine()?t.replaceRange("",n(r-1),n(r),"+swapLine"):t.replaceRange("",n(r,0),n(r+1,0),"+swapLine"),t.replaceRange(a+"\n",n(o,0),null,"+swapLine")}t.scrollIntoView()}))},t.toggleCommentIndented=function(e){e.toggleComment({indent:!0})},t.joinLines=function(e){for(var t=e.listSelections(),r=[],i=0;i=0;o--){var a=r[o].head,s=t.getRange({line:a.line,ch:0},a),u=e.countColumn(s,null,t.getOption("tabSize")),c=t.findPosH(a,-1,"char",!1);if(s&&!/\S/.test(s)&&u%i==0){var l=new n(a.line,e.findColumn(s,u-i,i));l.ch!=a.ch&&(c=l)}t.replaceRange("",c,a,"+delete")}}))},t.delLineRight=function(e){e.operation((function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange("",t[r].anchor,n(t[r].to().line),"+delete");e.scrollIntoView()}))},t.upcaseAtCursor=function(e){l(e,(function(e){return e.toUpperCase()}))},t.downcaseAtCursor=function(e){l(e,(function(e){return e.toLowerCase()}))},t.setSublimeMark=function(e){e.state.sublimeMark&&e.state.sublimeMark.clear(),e.state.sublimeMark=e.setBookmark(e.getCursor())},t.selectToSublimeMark=function(e){var t=e.state.sublimeMark&&e.state.sublimeMark.find();t&&e.setSelection(e.getCursor(),t)},t.deleteToSublimeMark=function(t){var n=t.state.sublimeMark&&t.state.sublimeMark.find();if(n){var r=t.getCursor(),i=n;if(e.cmpPos(r,i)>0){var o=i;i=r,r=o}t.state.sublimeKilled=t.getRange(r,i),t.replaceRange("",r,i)}},t.swapWithSublimeMark=function(e){var t=e.state.sublimeMark&&e.state.sublimeMark.find();t&&(e.state.sublimeMark.clear(),e.state.sublimeMark=e.setBookmark(e.getCursor()),e.setCursor(t))},t.sublimeYank=function(e){null!=e.state.sublimeKilled&&e.replaceSelection(e.state.sublimeKilled,null,"paste")},t.showInCenter=function(e){var t=e.cursorCoords(null,"local");e.scrollTo(null,(t.top+t.bottom)/2-e.getScrollInfo().clientHeight/2)},t.findUnder=function(e){p(e,!0)},t.findUnderPrevious=function(e){p(e,!1)},t.findAllUnder=function(e){var t=f(e);if(t){for(var n=e.getSearchCursor(t.query),r=[],i=-1;n.findNext();)r.push({anchor:n.from(),head:n.to()}),n.from().line<=t.from.line&&n.from().ch<=t.from.ch&&i++;e.setSelections(r,i)}};var d=e.keyMap;d.macSublime={"Cmd-Left":"goLineStartSmart","Shift-Tab":"indentLess","Shift-Ctrl-K":"deleteLine","Alt-Q":"wrapLines","Ctrl-Left":"goSubwordLeft","Ctrl-Right":"goSubwordRight","Ctrl-Alt-Up":"scrollLineUp","Ctrl-Alt-Down":"scrollLineDown","Cmd-L":"selectLine","Shift-Cmd-L":"splitSelectionByLine",Esc:"singleSelectionTop","Cmd-Enter":"insertLineAfter","Shift-Cmd-Enter":"insertLineBefore","Cmd-D":"selectNextOccurrence","Shift-Cmd-Space":"selectScope","Shift-Cmd-M":"selectBetweenBrackets","Cmd-M":"goToBracket","Cmd-Ctrl-Up":"swapLineUp","Cmd-Ctrl-Down":"swapLineDown","Cmd-/":"toggleCommentIndented","Cmd-J":"joinLines","Shift-Cmd-D":"duplicateLine",F5:"sortLines","Cmd-F5":"sortLinesInsensitive",F2:"nextBookmark","Shift-F2":"prevBookmark","Cmd-F2":"toggleBookmark","Shift-Cmd-F2":"clearBookmarks","Alt-F2":"selectBookmarks",Backspace:"smartBackspace","Cmd-K Cmd-K":"delLineRight","Cmd-K Cmd-U":"upcaseAtCursor","Cmd-K Cmd-L":"downcaseAtCursor","Cmd-K Cmd-Space":"setSublimeMark","Cmd-K Cmd-A":"selectToSublimeMark","Cmd-K Cmd-W":"deleteToSublimeMark","Cmd-K Cmd-X":"swapWithSublimeMark","Cmd-K Cmd-Y":"sublimeYank","Cmd-K Cmd-C":"showInCenter","Cmd-K Cmd-G":"clearBookmarks","Cmd-K Cmd-Backspace":"delLineLeft","Cmd-K Cmd-0":"unfoldAll","Cmd-K Cmd-J":"unfoldAll","Ctrl-Shift-Up":"addCursorToPrevLine","Ctrl-Shift-Down":"addCursorToNextLine","Cmd-F3":"findUnder","Shift-Cmd-F3":"findUnderPrevious","Alt-F3":"findAllUnder","Shift-Cmd-[":"fold","Shift-Cmd-]":"unfold","Cmd-I":"findIncremental","Shift-Cmd-I":"findIncrementalReverse","Cmd-H":"replace",F3:"findNext","Shift-F3":"findPrev",fallthrough:"macDefault"},e.normalizeKeyMap(d.macSublime),d.pcSublime={"Shift-Tab":"indentLess","Shift-Ctrl-K":"deleteLine","Alt-Q":"wrapLines","Ctrl-T":"transposeChars","Alt-Left":"goSubwordLeft","Alt-Right":"goSubwordRight","Ctrl-Up":"scrollLineUp","Ctrl-Down":"scrollLineDown","Ctrl-L":"selectLine","Shift-Ctrl-L":"splitSelectionByLine",Esc:"singleSelectionTop","Ctrl-Enter":"insertLineAfter","Shift-Ctrl-Enter":"insertLineBefore","Ctrl-D":"selectNextOccurrence","Shift-Ctrl-Space":"selectScope","Shift-Ctrl-M":"selectBetweenBrackets","Ctrl-M":"goToBracket","Shift-Ctrl-Up":"swapLineUp","Shift-Ctrl-Down":"swapLineDown","Ctrl-/":"toggleCommentIndented","Ctrl-J":"joinLines","Shift-Ctrl-D":"duplicateLine",F9:"sortLines","Ctrl-F9":"sortLinesInsensitive",F2:"nextBookmark","Shift-F2":"prevBookmark","Ctrl-F2":"toggleBookmark","Shift-Ctrl-F2":"clearBookmarks","Alt-F2":"selectBookmarks",Backspace:"smartBackspace","Ctrl-K Ctrl-K":"delLineRight","Ctrl-K Ctrl-U":"upcaseAtCursor","Ctrl-K Ctrl-L":"downcaseAtCursor","Ctrl-K Ctrl-Space":"setSublimeMark","Ctrl-K Ctrl-A":"selectToSublimeMark","Ctrl-K Ctrl-W":"deleteToSublimeMark","Ctrl-K Ctrl-X":"swapWithSublimeMark","Ctrl-K Ctrl-Y":"sublimeYank","Ctrl-K Ctrl-C":"showInCenter","Ctrl-K Ctrl-G":"clearBookmarks","Ctrl-K Ctrl-Backspace":"delLineLeft","Ctrl-K Ctrl-0":"unfoldAll","Ctrl-K Ctrl-J":"unfoldAll","Ctrl-Alt-Up":"addCursorToPrevLine","Ctrl-Alt-Down":"addCursorToNextLine","Ctrl-F3":"findUnder","Shift-Ctrl-F3":"findUnderPrevious","Alt-F3":"findAllUnder","Shift-Ctrl-[":"fold","Shift-Ctrl-]":"unfold","Ctrl-I":"findIncremental","Shift-Ctrl-I":"findIncrementalReverse","Ctrl-H":"replace",F3:"findNext","Shift-F3":"findPrev",fallthrough:"pcDefault"},e.normalizeKeyMap(d.pcSublime);var h=d.default==d.macDefault;d.sublime=h?d.macSublime:d.pcSublime}))},void 0===(o="function"==typeof r?r.apply(t,i):r)||(e.exports=o)}).call(this,n(21)(e))},function(e,t,n){var r,i,o;i=[t,n(13),n(35),n(79)],void 0===(o="function"==typeof(r=function(e,t,n,r){"use strict";function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=null,r=null,a=null,u=s(e,(function(e,s,u,c){if(c===t.line&&e.getCurrentPosition()>=t.character)return n=u,r=function(e){for(var t=1;t=e.character:i.start.line<=e.line&&i.end.line>=e.line},this.start=n,this.end=r}return r(e,[{key:"setStart",value:function(e,t){this.start=new o(e,t)}},{key:"setEnd",value:function(e,t){this.end=new o(e,t)}}]),e}();e.Range=i;var o=function(){function e(n,r){var i=this;t(this,e),this.lessThanOrEqualTo=function(e){return i.line0?l.filter((function(e){if(-1===e.message.indexOf("Unknown directive"))return!0;if(e.nodes&&e.nodes[0]){var t=e.nodes[0];return!(t.name&&"arguments"===t.name.value||"argumentDefinitions"===t.name.value)}})):[]}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t],void 0===(o="function"==typeof(r=function(e){"use strict";function t(e){var t=/^.+\.([^.]+)$/.exec(e);return t&&t.length>1?t[1]:null}function r(e,t){var n=e;return t&&(n=e.substr(0,e.length-(t.length+1))),n}function i(e){if(e)throw Error("cannot import() module with extension '".concat(e,"'"))}Object.defineProperty(e,"__esModule",{value:!0}),e.getFileExtension=t,e.getPathWithoutExtension=r,e.resolveFile=c,e.requireFile=function(e){var n=t(e),o=r(e,n);switch(n){case"js":return c(o+".js")?s(o):null;case"json":return c(o+".json")?u(o):null;default:try{if(c(e+".js"))return s(e)}catch(e){i(n)}if(c(e+".json"))return u(e);i(n)}};var o=function(e){return n(177).resolve(e+".js")},a=function(e){return n(178).resolve(e+".json")},s=function(e){return n(179)(e+".js")},u=function(e){return n(180)(e+".json")};function c(e){var n=t(e),i=r(e,n);switch(n){case"js":return o(i);case"json":return a(i);default:try{return o(e)}catch(t){return a(e)}}}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(14),n(16),n(36),n(91)],void 0===(o="function"==typeof(r=function(e,t,n,r,i){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function a(e){var n=e.arg,o=e.onClickType,a=e.showDefaultValue;return t.default.createElement("span",{className:"arg"},t.default.createElement("span",{className:"arg-name"},n.name),": ",t.default.createElement(r.default,{type:n.type,onClick:o}),!1!==a&&t.default.createElement(i.default,{field:n}))}Object.defineProperty(e,"__esModule",{value:!0}),e.default=a,t=o(t),n=o(n),r=o(r),i=o(i),a.propTypes={arg:n.default.object.isRequired,onClickType:n.default.func.isRequired,showDefaultValue:n.default.bool}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(14),n(16),n(42)],void 0===(o="function"==typeof(r=function(e,t,n,r){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){for(var n=0;n120){for(var h=Math.floor(l/80),m=l%80,v=[],y=0;y`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",n="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",r=new RegExp("^(?:"+t+"|"+n+"|\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e|<[?].*?[?]>|]*>|)"),i=new RegExp("^(?:"+t+"|"+n+")");e.exports.HTML_TAG_RE=r,e.exports.HTML_OPEN_CLOSE_TAG_RE=i})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t){var n,r,i,o,a,s=[],u=t.length;for(n=0;n=0;n--)95!==(r=t[n]).marker&&42!==r.marker||-1!==r.end&&(i=t[r.end],s=n>0&&t[n-1].end===r.end+1&&t[n-1].token===r.token-1&&t[r.end+1].token===i.token+1&&t[n-1].marker===r.marker,a=String.fromCharCode(r.marker),(o=e.tokens[r.token]).type=s?"strong_open":"em_open",o.tag=s?"strong":"em",o.nesting=1,o.markup=s?a+a:a,o.content="",(o=e.tokens[i.token]).type=s?"strong_close":"em_close",o.tag=s?"strong":"em",o.nesting=-1,o.markup=s?a+a:a,o.content="",s&&(e.tokens[t[n-1].token].content="",e.tokens[t[r.end+1].token].content="",n--))}e.exports.tokenize=function(e,t){var n,r,i=e.pos,o=e.src.charCodeAt(i);if(t)return!1;if(95!==o&&42!==o)return!1;for(r=e.scanDelims(e.pos,42===o),n=0;n'+function e(n){return n instanceof t.GraphQLNonNull?"".concat(e(n.ofType),"!"):n instanceof t.GraphQLList?"[".concat(e(n.ofType),"]"):''.concat(n.name,"")}(e.type)+"":"";if(a.innerHTML='
'+("

"===c.slice(0,3)?"

"+l+c.slice(3):l+c)+"

",e.isDeprecated){var f=e.deprecationReason?o.render(e.deprecationReason):"";s.innerHTML='Deprecated'+f,s.style.display="block"}else s.style.display="none";i&&i(a)}))};var i,o=new(i=r,r=i&&i.__esModule?i:{default:i}).default})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){(function(e){var r,i,o;i=[],r=function(){"use strict";function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(s){"object"==a(t)&&"object"==a(e)?s(n(6)):(i=[n(6)],void 0===(o="function"==typeof(r=s)?r.apply(t,i):r)||(e.exports=o))}((function(e){var t="CodeMirror-hint",n="CodeMirror-hint-active";function r(e,t){this.cm=e,this.options=t,this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor("start"),this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length;var n=this;e.on("cursorActivity",this.activityFunc=function(){n.cursorActivity()})}e.showHint=function(e,t,n){if(!t)return e.showHint(n);n&&n.async&&(t.async=!0);var r={hint:t};if(n)for(var i in n)r[i]=n[i];return e.showHint(r)},e.defineExtension("showHint",(function(t){t=function(e,t,n){var r=e.options.hintOptions,i={};for(var o in l)i[o]=l[o];if(r)for(var o in r)void 0!==r[o]&&(i[o]=r[o]);if(n)for(var o in n)void 0!==n[o]&&(i[o]=n[o]);return i.hint.resolve&&(i.hint=i.hint.resolve(e,t)),i}(this,this.getCursor("start"),t);var n=this.listSelections();if(!(n.length>1)){if(this.somethingSelected()){if(!t.hint.supportsSelection)return;for(var i=0;if.clientHeight+1,L=u.getScrollInfo();if(j>0){var I=D.bottom-D.top;if(b.top-(b.bottom-D.top)-I>0)f.style.top=(E=b.top-I-_)+"px",T=!1;else if(I>N){f.style.height=N-5+"px",f.style.top=(E=b.bottom-D.top-_)+"px";var F=u.getCursor();i.from.ch!=F.ch&&(b=u.cursorCoords(F),f.style.left=(O=b.left-w)+"px",D=f.getBoundingClientRect())}}var R,M=D.right-C;if(M>0&&(D.right-D.left>C&&(f.style.width=C-5+"px",M-=D.right-D.left-C),f.style.left=(O=b.left-M-w)+"px"),A)for(var P=f.firstChild;P;P=P.nextSibling)P.style.paddingRight=u.display.nativeBarWidth+"px";return u.addKeyMap(this.keyMap=function(e,t){var n={Up:function(){t.moveFocus(-1)},Down:function(){t.moveFocus(1)},PageUp:function(){t.moveFocus(1-t.menuSize(),!0)},PageDown:function(){t.moveFocus(t.menuSize()-1,!0)},Home:function(){t.setFocus(0)},End:function(){t.setFocus(t.length-1)},Enter:t.pick,Tab:t.pick,Esc:t.close};/Mac/.test(navigator.platform)&&(n["Ctrl-P"]=function(){t.moveFocus(-1)},n["Ctrl-N"]=function(){t.moveFocus(1)});var r=e.options.customKeys,i=r?{}:n;function o(e,r){var o;o="string"!=typeof r?function(e){return r(e,t)}:n.hasOwnProperty(r)?n[r]:r,i[e]=o}if(r)for(var a in r)r.hasOwnProperty(a)&&o(a,r[a]);var s=e.options.extraKeys;if(s)for(var a in s)s.hasOwnProperty(a)&&o(a,s[a]);return i}(r,{moveFocus:function(e,t){o.changeActive(o.selectedHint+e,t)},setFocus:function(e){o.changeActive(e)},menuSize:function(){return o.screenAmount()},length:d.length,close:function(){r.close()},pick:function(){o.pick()},data:i})),r.options.closeOnUnfocus&&(u.on("blur",this.onBlur=function(){R=setTimeout((function(){r.close()}),100)}),u.on("focus",this.onFocus=function(){clearTimeout(R)})),u.on("scroll",this.onScroll=function(){var e=u.getScrollInfo(),t=u.getWrapperElement().getBoundingClientRect(),n=E+L.top-e.top,i=n-(l.pageYOffset||(c.documentElement||c.body).scrollTop);if(T||(i+=f.offsetHeight),i<=t.top||i>=t.bottom)return r.close();f.style.top=n+"px",f.style.left=O+L.left-e.left+"px"}),e.on(f,"dblclick",(function(e){var t=s(f,e.target||e.srcElement);t&&null!=t.hintId&&(o.changeActive(t.hintId),o.pick())})),e.on(f,"click",(function(e){var t=s(f,e.target||e.srcElement);t&&null!=t.hintId&&(o.changeActive(t.hintId),r.options.completeOnSingleClick&&o.pick())})),e.on(f,"mousedown",(function(){setTimeout((function(){u.focus()}),20)})),e.signal(i,"select",d[this.selectedHint],f.childNodes[this.selectedHint]),!0}function c(e,t,n,r){if(e.async)e(t,r,n);else{var i=e(t,n);i&&i.then?i.then(r):r(i)}}r.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&e.signal(this.data,"close"),this.widget&&this.widget.close(),e.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(t,n){var r=t.list[n];r.hint?r.hint(this.cm,t,r):this.cm.replaceRange(a(r),r.from||t.from,r.to||t.to,"complete"),e.signal(t,"pick",r),this.close()},cursorActivity:function(){this.debounce&&(o(this.debounce),this.debounce=0);var e=this.cm.getCursor(),t=this.cm.getLine(e.line);if(e.line!=this.startPos.line||t.length-e.ch!=this.startLen-this.startPos.ch||e.ch=this.data.list.length?t=r?this.data.list.length-1:0:t<0&&(t=r?0:this.data.list.length-1),this.selectedHint!=t){var i=this.hints.childNodes[this.selectedHint];i&&(i.className=i.className.replace(" "+n,"")),(i=this.hints.childNodes[this.selectedHint=t]).className+=" "+n,i.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=i.offsetTop+i.offsetHeight-this.hints.clientHeight+3),e.signal(this.data,"select",this.data.list[this.selectedHint],i)}},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},e.registerHelper("hint","auto",{resolve:function(t,n){var r,i=t.getHelpers(n,"hint");if(i.length){var o=function(e,t,n){var r=function(e,t){if(!e.somethingSelected())return t;for(var n=[],r=0;r0?t(e):i(o+1)}))}(0)};return o.async=!0,o.supportsSelection=!0,o}return(r=t.getHelper(t.getCursor(),"hintWords"))?function(t){return e.hint.fromList(t,{words:r})}:e.hint.anyword?function(t,n){return e.hint.anyword(t,n)}:function(){}}}),e.registerHelper("hint","fromList",(function(t,n){var r,i=t.getCursor(),o=t.getTokenAt(i),a=e.Pos(i.line,o.start),s=i;o.start,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};e.defineOption("hintOptions",null)}))},void 0===(o="function"==typeof r?r.apply(t,i):r)||(e.exports=o)}).call(this,n(21)(e))},function(e,t,n){(function(e){var r,i,o;i=[],r=function(){"use strict";function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(s){"object"==a(t)&&"object"==a(e)?s(n(6)):(i=[n(6)],void 0===(o="function"==typeof(r=s)?r.apply(t,i):r)||(e.exports=o))}((function(e){var t={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},n=e.Pos;function r(e,n){return"pairs"==n&&"string"==typeof e?e:"object"==a(e)&&null!=e[n]?e[n]:t[n]}e.defineOption("autoCloseBrackets",!1,(function(t,n,a){a&&a!=e.Init&&(t.removeKeyMap(i),t.state.closeBrackets=null),n&&(o(r(n,"pairs")),t.state.closeBrackets=n,t.addKeyMap(i))}));var i={Backspace:function(t){var i=u(t);if(!i||t.getOption("disableInput"))return e.Pass;for(var o=r(i,"pairs"),a=t.listSelections(),s=0;s=0;s--){var f=a[s].head;t.replaceRange("",n(f.line,f.ch-1),n(f.line,f.ch+1),"+delete")}},Enter:function(t){var n=u(t),i=n&&r(n,"explode");if(!i||t.getOption("disableInput"))return e.Pass;for(var o=t.listSelections(),a=0;a1&&p.indexOf(i)>=0&&t.getRange(n(b.line,b.ch-2),b)==i+i){if(b.ch>2&&/\bstring/.test(t.getTokenTypeAt(n(b.line,b.ch-2))))return e.Pass;y="addFour"}else if(d){var E=0==b.ch?" ":t.getRange(n(b.line,b.ch-1),b);if(e.isWordChar(O)||E==i||e.isWordChar(E))return e.Pass;y="both"}else{if(!m||!(0===O.length||/\s/.test(O)||f.indexOf(O)>-1))return e.Pass;y="both"}else y=d&&l(t,b)?"both":p.indexOf(i)>=0&&t.getRange(b,n(b.line,b.ch+3))==i+i+i?"skipThree":"skip";if(c){if(c!=y)return e.Pass}else c=y}var T=s%2?a.charAt(s-1):i,w=s%2?i:a.charAt(s+1);t.operation((function(){if("skip"==c)t.execCommand("goCharRight");else if("skipThree"==c)for(var r=0;r<3;r++)t.execCommand("goCharRight");else if("surround"==c){var i=t.getSelections();for(r=0;r0,{anchor:new n(o.anchor.line,o.anchor.ch+(a?-1:1)),head:new n(o.head.line,o.head.ch+(a?1:-1))});t.setSelections(i)}else"both"==c?(t.replaceSelection(T+w,null),t.triggerElectric(T+w),t.execCommand("goCharLeft")):"addFour"==c&&(t.replaceSelection(T+T+T+T,"before"),t.execCommand("goCharRight"));var o,a}))}(i,t)}}function u(e){var t=e.state.closeBrackets;return!t||t.override?t:e.getModeAt(e.getCursor()).closeBrackets||t}function c(e,t){var r=e.getRange(n(t.line,t.ch-1),n(t.line,t.ch+1));return 2==r.length?r:null}function l(e,t){var r=e.getTokenAt(n(t.line,t.ch+1));return/\bstring/.test(r.type)&&r.start==t.ch&&(0==t.ch||!/\bstring/.test(e.getTokenTypeAt(t)))}o(t.pairs+"`")}))},void 0===(o="function"==typeof r?r.apply(t,i):r)||(e.exports=o)}).call(this,n(21)(e))},function(e,t,n){(function(e){var r,i,o;i=[],r=function(){"use strict";function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(s){"object"==a(t)&&"object"==a(e)?s(n(6)):(i=[n(6)],void 0===(o="function"==typeof(r=s)?r.apply(t,i):r)||(e.exports=o))}((function(e){function t(t,n,i,o){if(i&&i.call){var a=i;i=null}else a=r(t,i,"rangeFinder");"number"==typeof n&&(n=e.Pos(n,0));var s=r(t,i,"minFoldSize");function u(e){var r=a(t,n);if(!r||r.to.line-r.from.linet.firstLine();)n=e.Pos(n.line-1,0),c=u(!1);if(c&&!c.cleared&&"unfold"!==o){var l=function(e,t){var n=r(e,t,"widget");if("string"==typeof n){var i=document.createTextNode(n);(n=document.createElement("span")).appendChild(i),n.className="CodeMirror-foldmarker"}else n&&(n=n.cloneNode(!0));return n}(t,i);e.on(l,"mousedown",(function(t){f.clear(),e.e_preventDefault(t)}));var f=t.markText(c.from,c.to,{replacedWith:l,clearOnEnter:r(t,i,"clearOnEnter"),__isFold:!0});f.on("clear",(function(n,r){e.signal(t,"unfold",t,n,r)})),e.signal(t,"fold",t,c.from,c.to)}}e.newFoldFunction=function(e,n){return function(r,i){t(r,i,{rangeFinder:e,widget:n})}},e.defineExtension("foldCode",(function(e,n,r){t(this,e,n,r)})),e.defineExtension("isFolded",(function(e){for(var t=this.findMarksAt(e),n=0;nt.cursorCoords(n,"window").top&&((d=r).style.opacity=.4)})))};!function(e,t,n,r,i){e.openDialog(t,r,{value:n,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){f(e)},onKeyDown:i})}(t,p(t),c,h,(function(r,i){var o=e.keyName(r),a=t.getOption("extraKeys"),s=a&&a[o]||e.keyMap[t.getOption("keyMap")][o];"findNext"==s||"findPrev"==s||"findPersistentNext"==s||"findPersistentPrev"==s?(e.e_stop(r),u(t,n(t),i),t.execCommand(s)):"find"!=s&&"findPersistent"!=s||(e.e_stop(r),h(i,r))})),a&&c&&(u(t,s,c),l(t,r))}else o(t,p(t),"Search for:",c,(function(e){e&&!s.query&&t.operation((function(){u(t,s,e),s.posFrom=s.posTo=t.getCursor(),l(t,r)}))}))}function l(t,r,o){t.operation((function(){var a=n(t),s=i(t,a.query,r?a.posFrom:a.posTo);(s.find(r)||(s=i(t,a.query,r?e.Pos(t.lastLine()):e.Pos(t.firstLine(),0))).find(r))&&(t.setSelection(s.from(),s.to()),t.scrollIntoView({from:s.from(),to:s.to()},20),a.posFrom=s.from(),a.posTo=s.to(),o&&o(s.from(),s.to()))}))}function f(e){e.operation((function(){var t=n(e);t.lastQuery=t.query,t.query&&(t.query=t.queryText=null,e.removeOverlay(t.overlay),t.annotate&&(t.annotate.clear(),t.annotate=null))}))}function p(e){return''+e.phrase("Search:")+' '+e.phrase("(Use /re/ syntax for regexp search)")+""}function d(e,t,n){e.operation((function(){for(var r=i(e,t);r.findNext();)if("string"!=typeof t){var o=e.getRange(r.from(),r.to()).match(t);r.replace(n.replace(/\$(\d)/g,(function(e,t){return o[t]})))}else r.replace(n)}))}function h(e,t){if(!e.getOption("readOnly")){var r=e.getSelection()||n(e).lastQuery,u=''+(t?e.phrase("Replace all:"):e.phrase("Replace:"))+"";o(e,u+function(e){return' '+e.phrase("(Use /re/ syntax for regexp search)")+""}(e),u,r,(function(n){n&&(n=s(n),o(e,function(e){return''+e.phrase("With:")+' '}(e),e.phrase("Replace with:"),"",(function(r){if(r=a(r),t)d(e,n,r);else{f(e);var o=i(e,n,e.getCursor("from")),s=function t(){var a,s=o.from();!(a=o.findNext())&&(o=i(e,n),!(a=o.findNext())||s&&o.from().line==s.line&&o.from().ch==s.ch)||(e.setSelection(o.from(),o.to()),e.scrollIntoView({from:o.from(),to:o.to()}),function(e,t,n,r){e.openConfirm?e.openConfirm(t,r):confirm(n)&&r[0]()}(e,function(e){return''+e.phrase("Replace?")+" "}(e),e.phrase("Replace?"),[function(){u(a)},t,function(){d(e,n,r)}]))},u=function(e){o.replace("string"==typeof n?r:r.replace(/\$(\d)/g,(function(t,n){return e[n]}))),s()};s()}})))}))}}e.commands.find=function(e){f(e),c(e)},e.commands.findPersistent=function(e){f(e),c(e,!1,!0)},e.commands.findPersistentNext=function(e){c(e,!1,!0,!0)},e.commands.findPersistentPrev=function(e){c(e,!0,!0,!0)},e.commands.findNext=c,e.commands.findPrev=function(e){c(e,!0)},e.commands.clearSearch=f,e.commands.replace=h,e.commands.replaceAll=function(e){h(e,!0)}}))},void 0===(o="function"==typeof r?r.apply(t,i):r)||(e.exports=o)}).call(this,n(21)(e))},function(e,t,n){(function(e){var r,i,o;i=[],r=function(){"use strict";function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(s){"object"==a(t)&&"object"==a(e)?s(n(6)):(i=[n(6)],void 0===(o="function"==typeof(r=s)?r.apply(t,i):r)||(e.exports=o))}((function(e){var t="CodeMirror-lint-markers";function n(e){e.parentNode&&e.parentNode.removeChild(e)}function r(t,r,i){var o=function(t,n){var r=document.createElement("div");function i(t){if(!r.parentNode)return e.off(document,"mousemove",i);r.style.top=Math.max(0,t.clientY-r.offsetHeight-5)+"px",r.style.left=t.clientX+5+"px"}return r.className="CodeMirror-lint-tooltip",r.appendChild(n.cloneNode(!0)),document.body.appendChild(r),e.on(document,"mousemove",i),i(t),null!=r.style.opacity&&(r.style.opacity=1),r}(t,r);function a(){var t;e.off(i,"mouseout",a),o&&((t=o).parentNode&&(null==t.style.opacity&&n(t),t.style.opacity=0,setTimeout((function(){n(t)}),600)),o=null)}var s=setInterval((function(){if(o)for(var e=i;;e=e.parentNode){if(e&&11==e.nodeType&&(e=e.host),e==document.body)return;if(!e){a();break}}if(!o)return clearInterval(s)}),400);e.on(i,"mouseout",a)}function i(e,t,n){this.marked=[],this.options=t,this.timeout=null,this.hasGutter=n,this.onMouseOver=function(t){!function(e,t){var n=t.target||t.srcElement;if(/\bCodeMirror-lint-mark-/.test(n.className)){for(var i=n.getBoundingClientRect(),o=(i.left+i.right)/2,a=(i.top+i.bottom)/2,u=e.findMarksAt(e.coordsChar({left:o,top:a},"client")),c=[],l=0;l1,u.options.tooltips))}}c.onUpdateLinting&&c.onUpdateLinting(n,l,e)}function l(e){var t=e.state.lint;t&&(clearTimeout(t.timeout),t.timeout=setTimeout((function(){u(e)}),t.options.delay||500))}e.defineOption("lint",!1,(function(n,r,a){if(a&&a!=e.Init&&(o(n),!1!==n.state.lint.options.lintOnChange&&n.off("change",l),e.off(n.getWrapperElement(),"mouseover",n.state.lint.onMouseOver),clearTimeout(n.state.lint.timeout),delete n.state.lint),r){for(var s=n.getOption("gutters"),c=!1,f=0;f=0;i--)t(n[i])}function i(e,t){var n=e.filter(t);return 0===n.length?e:n}function o(e){return e.toLowerCase().replace(/\W/g,"")}function a(e,t){var n=function(e,t){var n,r,i=[],o=e.length,a=t.length;for(n=0;n<=o;n++)i[n]=[n];for(r=1;r<=a;r++)i[0][r]=r;for(n=1;n<=o;n++)for(r=1;r<=a;r++){var s=e[n-1]===t[r-1]?0:1;i[n][r]=Math.min(i[n-1][r]+1,i[n][r-1]+1,i[n-1][r-1]+s),n>1&&r>1&&e[n-1]===t[r-2]&&e[n-2]===t[r-1]&&(i[n][r]=Math.min(i[n][r],i[n-2][r-2]+s))}return i[o][a]}(t,e);return e.length>t.length&&(n-=e.length-t.length-1,n+=0===e.indexOf(t)?0:.5),n}Object.defineProperty(e,"__esModule",{value:!0}),e.getDefinitionState=function(e){var t;return r(e,(function(e){switch(e.kind){case"Query":case"ShortQuery":case"Mutation":case"Subscription":case"FragmentDefinition":t=e}})),t},e.getFieldDef=function(e,r,i){return i===n.SchemaMetaFieldDef.name&&e.getQueryType()===r?n.SchemaMetaFieldDef:i===n.TypeMetaFieldDef.name&&e.getQueryType()===r?n.TypeMetaFieldDef:i===n.TypeNameMetaFieldDef.name&&(0,t.isCompositeType)(r)?n.TypeNameMetaFieldDef:"getFields"in r?r.getFields()[i]:null},e.forEachState=r,e.objectValues=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n),i=0;i1)for(var n=1;n + * @license MIT + */function o(e,t){if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i=0;u--)if(l[u]!==f[u])return!1;for(u=l.length-1;u>=0;u--)if(a=l[u],!O(e[a],t[a],n,r))return!1;return!0}(e,n,r,i))}return r?e===n:e==n}function E(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function T(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function w(e,t,n,r){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(r=n,n=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&g(i,n,"Missing expected exception"+r);var o="string"==typeof r,a=!e&&i&&!n;if((!e&&s.isError(i)&&o&&T(i,n)||a)&&g(i,n,"Got unwanted exception"+r),e&&i&&n&&!T(i,n)||!e&&i)throw i}d.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=v(y((t=this).actual),128)+" "+t.operator+" "+v(y(t.expected),128),this.generatedMessage=!0);var n=e.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,n);else{var r=new Error;if(r.stack){var i=r.stack,o=m(n),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},s.inherits(d.AssertionError,Error),d.fail=g,d.ok=b,d.equal=function(e,t,n){e!=t&&g(e,t,n,"==",d.equal)},d.notEqual=function(e,t,n){e==t&&g(e,t,n,"!=",d.notEqual)},d.deepEqual=function(e,t,n){O(e,t,!1)||g(e,t,n,"deepEqual",d.deepEqual)},d.deepStrictEqual=function(e,t,n){O(e,t,!0)||g(e,t,n,"deepStrictEqual",d.deepStrictEqual)},d.notDeepEqual=function(e,t,n){O(e,t,!1)&&g(e,t,n,"notDeepEqual",d.notDeepEqual)},d.notDeepStrictEqual=function e(t,n,r){O(t,n,!0)&&g(t,n,r,"notDeepStrictEqual",e)},d.strictEqual=function(e,t,n){e!==t&&g(e,t,n,"===",d.strictEqual)},d.notStrictEqual=function(e,t,n){e===t&&g(e,t,n,"!==",d.notStrictEqual)},d.throws=function(e,t,n){w(!0,e,t,n)},d.doesNotThrow=function(e,t,n){w(!1,e,t,n)},d.ifError=function(e){if(e)throw e},d.strict=i((function e(t,n){t||g(t,!0,n,"==",e)}),d,{equal:d.strictEqual,deepEqual:d.deepStrictEqual,notEqual:d.notStrictEqual,notDeepEqual:d.notDeepStrictEqual}),d.strict.strict=d.strict;var _=Object.keys||function(e){var t=[];for(var n in e)u.call(e,n)&&t.push(n);return t}})?i.apply(t,o):i)||(e.exports=a)}).call(this,n(41))},function(e,t,n){var r,i,o;i=[t,n(84),n(13),n(35),n(34)],void 0===(o="function"==typeof(r=function(e,t,n,r,i){"use strict";var o;Object.defineProperty(e,"__esModule",{value:!0}),e.getDiagnostics=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,o=null;try{o=(0,n.parse)(e)}catch(t){var u=l(t.locations[0],e);return[{severity:a.ERROR,message:t.message,source:"GraphQL: Syntax",range:u}]}return s(o,t,r,i)},e.validateQuery=s,e.getRange=l,e.SEVERITY=void 0,t=(o=t)&&o.__esModule?o:{default:o};var a={ERROR:1,WARNING:2,INFORMATION:3,HINT:4};function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0;if(!t)return[];var s=u((0,i.validateWithCustomRules)(t,e,r,o),(function(e){return c(e,a.ERROR,"Validation")})),l=n.findDeprecatedUsages?u((0,n.findDeprecatedUsages)(t,e),(function(e){return c(e,a.WARNING,"Deprecation")})):[];return s.concat(l)}function u(e,t){return Array.prototype.concat.apply([],e.map(t))}function c(e,n,r){return e.nodes?e.nodes.map((function(o){var a="Variable"!==o.kind&&"name"in o?o.name:"variable"in o?o.variable:o;(0,t.default)(e.locations,"GraphQL validation error requires locations.");var s=e.locations[0],u=function(e){var n=e.loc;return(0,t.default)(n,"Expected ASTNode to have a location."),n}(a),c=s.column+(u.end-u.start);return{source:"GraphQL: ".concat(r),message:e.message,severity:n,range:new i.Range(new i.Position(s.line-1,s.column-1),new i.Position(s.line-1,c))}})):[]}function l(e,n){var o=(0,r.onlineParser)(),a=o.startState(),s=n.split("\n");(0,t.default)(s.length>=e.line,"Query text must have more lines than where the error happened");for(var u=null,c=0;c=0;i--)t(n[i])}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getFieldReference=function(e){return{kind:"Field",schema:e.schema,field:e.fieldDef,type:r(e.fieldDef)?null:e.parentType}},t.getDirectiveReference=function(e){return{kind:"Directive",schema:e.schema,directive:e.directiveDef}},t.getArgumentReference=function(e){return e.directiveDef?{kind:"Argument",schema:e.schema,argument:e.argDef,directive:e.directiveDef}:{kind:"Argument",schema:e.schema,argument:e.argDef,field:e.fieldDef,type:r(e.fieldDef)?null:e.parentType}},t.getEnumValueReference=function(t){return{kind:"EnumValue",value:t.enumValue,type:(0,e.getNamedType)(t.inputType)}},t.getTypeReference=function(e,t){return{kind:"Type",schema:e.schema,type:t||e.type}};var e=n(13);function r(e){return"__"===e.name.slice(0,2)}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var e,t=(e=n(6))&&e.__esModule?e:{default:e};function r(e,n){var r=e.state.info,i=n.target||n.srcElement;if("SPAN"===i.nodeName&&void 0===r.hoverTimeout){var o=i.getBoundingClientRect(),a=function(){clearTimeout(r.hoverTimeout),r.hoverTimeout=setTimeout(u,c)},s=function n(){t.default.off(document,"mousemove",a),t.default.off(e.getWrapperElement(),"mouseout",n),clearTimeout(r.hoverTimeout),r.hoverTimeout=void 0},u=function(){t.default.off(document,"mousemove",a),t.default.off(e.getWrapperElement(),"mouseout",s),r.hoverTimeout=void 0,function(e,n){var r=e.coordsChar({left:(n.left+n.right)/2,top:(n.top+n.bottom)/2}),i=e.state.info.options,o=i.render||e.getHelper(r,"info");if(o){var a=e.getTokenAt(r,!0);if(a){var s=o(a,i,e,r);s&&function(e,n,r){var i=document.createElement("div");i.className="CodeMirror-info",i.appendChild(r),document.body.appendChild(i);var o=i.getBoundingClientRect(),a=i.currentStyle||window.getComputedStyle(i),s=o.right-o.left+parseFloat(a.marginLeft)+parseFloat(a.marginRight),u=o.bottom-o.top+parseFloat(a.marginTop)+parseFloat(a.marginBottom),c=n.bottom;u>window.innerHeight-n.bottom-15&&n.top>window.innerHeight-n.bottom&&(c=n.top-u),c<0&&(c=n.bottom);var l,f=Math.max(0,window.innerWidth-s-15);f>n.left&&(f=n.left),i.style.opacity=1,i.style.top=c+"px",i.style.left=f+"px";var p=function(){clearTimeout(l)},d=function(){clearTimeout(l),l=setTimeout(h,200)},h=function(){t.default.off(i,"mouseover",p),t.default.off(i,"mouseout",d),t.default.off(e.getWrapperElement(),"mouseout",d),i.style.opacity?(i.style.opacity=0,setTimeout((function(){i.parentNode&&i.parentNode.removeChild(i)}),600)):i.parentNode&&i.parentNode.removeChild(i)};t.default.on(i,"mouseover",p),t.default.on(i,"mouseout",d),t.default.on(e.getWrapperElement(),"mouseout",d)}(e,n,s)}}}(e,o)},c=function(e){var t=e.state.info.options;return t&&t.hoverTime||500}(e);r.hoverTimeout=setTimeout(u,c),t.default.on(document,"mousemove",a),t.default.on(e.getWrapperElement(),"mouseout",s)}}t.default.defineOption("info",!1,(function(e,n,i){if(i&&i!==t.default.Init){var o=e.state.info.onMouseOver;t.default.off(e.getWrapperElement(),"mouseover",o),clearTimeout(e.state.info.hoverTimeout),delete e.state.info}if(n){var a=e.state.info=function(e){return{options:e instanceof Function?{render:e}:!0===e?{}:e}}(n);a.onMouseOver=r.bind(null,e),t.default.on(e.getWrapperElement(),"mouseover",a.onMouseOver)}}))})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(14),n(16),n(13)],void 0===(o="function"==typeof(r=function(e,t,n,r){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e){var n=e.field,i=n.type,o=n.defaultValue;return void 0!==o?t.default.createElement("span",null," = ",t.default.createElement("span",{className:"arg-default-value"},(0,r.print)((0,r.astFromValue)(o,i)))):null}Object.defineProperty(e,"__esModule",{value:!0}),e.default=o,t=i(t),n=i(n),o.propTypes={field:n.default.object.isRequired}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t],void 0===(o="function"==typeof(r=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(e,t){var n;return function(){var r=arguments,i=this;clearTimeout(n),n=setTimeout((function(){n=null,t.apply(i,r)}),e)}}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(2),i=n(12),o=n(18),a=n(22),s=n(1);function u(e,t){switch(e.kind){case s.Kind.NULL:return null;case s.Kind.INT:return parseInt(e.value,10);case s.Kind.FLOAT:return parseFloat(e.value);case s.Kind.STRING:case s.Kind.ENUM:case s.Kind.BOOLEAN:return e.value;case s.Kind.LIST:return e.values.map((function(e){return u(e,t)}));case s.Kind.OBJECT:return Object(o.a)(e.fields,(function(e){return e.name.value}),(function(e){return u(e.value,t)}));case s.Kind.VARIABLE:var n=e.name.value;return t&&!Object(a.a)(t[n])?t[n]:void 0}Object(i.a)(!1,"Unexpected value node: "+Object(r.a)(e))}},function(e,t,n){var r,i,o;i=[t,n(95),n(96),n(97),n(98),n(99),n(100),n(101),n(102),n(103),n(104),n(105),n(106)],void 0===(o="function"==typeof(r=function(e,t,n,r,i,o,a,s,u,c,l,f,p){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var d=p.GraphiQL;e.default=d})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){(function(e){var n,r,i;r=[],void 0===(i="function"==typeof(n=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=function(e){var n,r=Object.prototype,i=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,n,r){var i=t&&t.prototype instanceof v?t:v,o=Object.create(i.prototype),a=new C(r||[]);return o._invoke=function(e,t,n){var r=f;return function(i,o){if(r===d)throw new Error("Generator is already running");if(r===h){if("throw"===i)throw o;return D()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=k(a,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===f)throw r=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=d;var u=l(e,t,n);if("normal"===u.type){if(r=n.done?h:p,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=h,n.method="throw",n.arg=u.arg)}}}(e,n,a),o}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f="suspendedStart",p="suspendedYield",d="executing",h="completed",m={};function v(){}function y(){}function g(){}var b={};b[a]=function(){return this};var O=Object.getPrototypeOf,E=O&&O(O(N([])));E&&E!==r&&i.call(E,a)&&(b=E);var T=g.prototype=v.prototype=Object.create(b);function w(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function _(e){var n;this._invoke=function(r,o){function a(){return new Promise((function(n,a){!function n(r,o,a,s){var u=l(e[r],e,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"===t(f)&&i.call(f,"__await")?Promise.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):Promise.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}(r,o,n,a)}))}return n=n?n.then(a,a):a()}}function k(e,t){var r=e.iterator[t.method];if(r===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=n,k(e,t),"throw"===t.method))return m;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var i=l(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,m;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,m):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function N(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(u&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:N(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),m}},e}("object"===t(e)?e.exports:{});try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}})?n.apply(t,r):n)||(e.exports=i)}).call(this,n(21)(e))},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){(function(r){var i,o,a,s;s=function(e,t,n,i,o,a,s,u,c,l,f,p,d,h,m,v,y,g,b,O,E,T,w,_,k,x,S){"use strict";function C(e){return e&&e.__esModule?e:{default:e}}function N(e){return(N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function j(e){for(var t=1;t0){var r=this.getQueryEditor();r.operation((function(){var e=r.getCursor(),i=r.indexFromPos(e);r.setValue(n);var o=0,a=t.map((function(e){var t=e.index,n=e.string;return r.markText(r.posFromIndex(t+o),r.posFromIndex(t+(o+=n.length)),{className:"autoInsertedLeaf",clearOnEnter:!0,title:"Automatically added leaf fields"})}));setTimeout((function(){return a.forEach((function(e){return e.clear()}))}),7e3);var s=i;t.forEach((function(e){var t=e.index,n=e.string;t=i){e=a.name&&a.name.value;break}}}this.handleRunQuery(e)}}},{key:"_didClickDragBar",value:function(e){if(0!==e.button||e.ctrlKey)return!1;var t=e.target;if(0!==t.className.indexOf("CodeMirror-gutter"))return!1;for(var n=i.default.findDOMNode(this.resultComponent);t;){if(t===n)return!0;t=t.parentNode}return!1}}])&&A(l.prototype,f),p&&A(l,p),n}(t.default.Component);e.GraphiQL=P,R(P,"propTypes",{fetcher:n.default.func.isRequired,schema:n.default.instanceOf(o.GraphQLSchema),query:n.default.string,variables:n.default.string,operationName:n.default.string,response:n.default.string,storage:n.default.shape({getItem:n.default.func,setItem:n.default.func,removeItem:n.default.func}),defaultQuery:n.default.string,defaultVariableEditorOpen:n.default.bool,onCopyQuery:n.default.func,onEditQuery:n.default.func,onEditVariables:n.default.func,onEditOperationName:n.default.func,onToggleDocs:n.default.func,getDefaultFieldNames:n.default.func,editorTheme:n.default.string,onToggleHistory:n.default.func,ResultsTooltip:n.default.any,readOnly:n.default.bool,docExplorerOpen:n.default.bool}),P.Logo=function(e){return t.default.createElement("div",{className:"title"},e.children||t.default.createElement("span",null,"Graph",t.default.createElement("em",null,"i"),"QL"))},P.Toolbar=function(e){return t.default.createElement("div",{className:"toolbar",role:"toolbar","aria-label":"Editor Commands"},e.children)},P.QueryEditor=d.QueryEditor,P.VariableEditor=h.VariableEditor,P.ResultViewer=m.ResultViewer,P.Button=c.ToolbarButton,P.ToolbarButton=c.ToolbarButton,P.Group=l.ToolbarGroup,P.Menu=f.ToolbarMenu,P.MenuItem=f.ToolbarMenuItem,P.Select=p.ToolbarSelect,P.SelectOption=p.ToolbarSelectOption,P.Footer=function(e){return t.default.createElement("div",{className:"footer"},e.children)},P.formatResult=function(e){return JSON.stringify(e,null,2)};var V=function(e){return j({},e,{message:e.message,stack:e.stack})};P.formatError=function(e){var t=Array.isArray(e)?e.map(V):V(e);return JSON.stringify(t,null,2)};var U='# Welcome to GraphiQL\n#\n# GraphiQL is an in-browser tool for writing, validating, and\n# testing GraphQL queries.\n#\n# Type queries into this side of the screen, and you will see intelligent\n# typeaheads aware of the current GraphQL type schema and live syntax and\n# validation errors highlighted within the text.\n#\n# GraphQL queries typically start with a "{" character. Lines that starts\n# with a # are ignored.\n#\n# An example GraphQL query might look like:\n#\n# {\n# field(arg: "value") {\n# subField\n# }\n# }\n#\n# Keyboard shortcuts:\n#\n# Prettify Query: Shift-Ctrl-P (or press the prettify button above)\n#\n# Merge Query: Shift-Ctrl-M (or press the merge button above)\n#\n# Run Query: Ctrl-Enter (or press the play button above)\n#\n# Auto Complete: Ctrl-Space (or just start typing)\n#\n\n';function B(e){return"object"===N(e)&&"function"==typeof e.then}function q(e){return K(e)?new Promise((function(t,n){var r=e.subscribe((function(e){t(e),r.unsubscribe()}),n,(function(){n(new Error("no value resolved"))}))})):e}function K(e){return"object"===N(e)&&"function"==typeof e.subscribe}},o=[t,n(14),n(16),n(62),n(13),n(109),n(111),n(112),n(113),n(114),n(115),n(116),n(117),n(192),n(198),n(200),n(206),n(209),n(210),n(211),n(212),n(92),n(213),n(214),n(215),n(216),n(217)],void 0===(a="function"==typeof(i=s)?i.apply(t,o):i)||(e.exports=a)}).call(this,n(41))},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t=n(108);function r(){}function i(){}i.resetWarningCache=r,e.exports=function(){function e(e,n,r,i,o,a){if(a!==t){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function n(){return e}e.isRequired=e;var o={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:n,element:e,elementType:e,instanceOf:n,node:e,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:i,resetWarningCache:r};return o.PropTypes=o,o}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t=n(110),r="Copy to clipboard: #{key}, Enter";e.exports=function(e,n){var i,o,a,s,u,c,l=!1;n||(n={}),i=n.debug||!1;try{if(a=t(),s=document.createRange(),u=document.getSelection(),(c=document.createElement("span")).textContent=e,c.style.all="unset",c.style.position="fixed",c.style.top=0,c.style.clip="rect(0, 0, 0, 0)",c.style.whiteSpace="pre",c.style.webkitUserSelect="text",c.style.MozUserSelect="text",c.style.msUserSelect="text",c.style.userSelect="text",c.addEventListener("copy",(function(t){t.stopPropagation(),n.format&&(t.preventDefault(),t.clipboardData.clearData(),t.clipboardData.setData(n.format,e))})),document.body.appendChild(c),s.selectNodeContents(c),u.addRange(s),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");l=!0}catch(t){i&&console.error("unable to copy using execCommand: ",t),i&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(n.format||"text",e),l=!0}catch(t){i&&console.error("unable to copy using clipboardData: ",t),i&&console.error("falling back to prompt"),o=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in n?n.message:r),window.prompt(o,e)}}finally{u&&("function"==typeof u.removeRange?u.removeRange(s):u.removeAllRanges()),c&&document.body.removeChild(c),a()}return l}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r1,s=null;if(a&&o){var u=this.state.highlight;s=t.default.createElement("ul",{className:"execute-options"},i.map((function(e){return t.default.createElement("li",{key:e.name?e.name.value:"*",className:e===u?"selected":void 0,onMouseOver:function(){return r.setState({highlight:e})},onMouseOut:function(){return r.setState({highlight:null})},onMouseUp:function(){return r._onOptionSelected(e)}},e.name?e.name.value:"")})))}!this.props.isRunning&&a||(e=this._onClick),this.props.isRunning||!a||o||(n=this._onOptionsOpen);var c=this.props.isRunning?t.default.createElement("path",{d:"M 10 10 L 23 10 L 23 23 L 10 23 z"}):t.default.createElement("path",{d:"M 11 9 L 24 16 L 11 23 z"});return t.default.createElement("div",{className:"execute-button-wrap"},t.default.createElement("button",{type:"button",className:"execute-button",onMouseDown:n,onClick:e,title:"Execute Query (Ctrl-Enter)"},t.default.createElement("svg",{width:"34",height:"34"},c)),s)}}])&&o(r.prototype,l),f&&o(r,f),n}(t.default.Component);e.ExecuteButton=l,c(l,"propTypes",{onRun:n.default.func,onStop:n.default.func,isRunning:n.default.bool,operations:n.default.array})})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(14),n(16)],void 0===(o="function"==typeof(r=function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){for(var n=0;n=0))try{t.hostname=l.toASCII(t.hostname)}catch(e){}return c.encode(c.format(t))}function y(e){var t=c.parse(e,!0);if(t.hostname&&(!t.protocol||m.indexOf(t.protocol)>=0))try{t.hostname=l.toUnicode(t.hostname)}catch(e){}return c.decode(c.format(t))}function g(e,n){if(!(this instanceof g))return new g(e,n);n||t.isString(e)||(n=e||{},e="default"),this.inline=new s,this.block=new a,this.core=new o,this.renderer=new i,this.linkify=new u,this.validateLink=h,this.normalizeLink=v,this.normalizeLinkText=y,this.utils=t,this.helpers=t.assign({},r),this.options={},this.configure(e),n&&this.set(n)}g.prototype.set=function(e){return t.assign(this.options,e),this},g.prototype.configure=function(e){var n,r=this;if(t.isString(e)&&!(e=f[n=e]))throw new Error('Wrong `markdown-it` preset "'+n+'", check name');if(!e)throw new Error("Wrong `markdown-it` preset, can't be empty");return e.options&&r.set(e.options),e.components&&Object.keys(e.components).forEach((function(t){e.components[t].rules&&r[t].ruler.enableOnly(e.components[t].rules),e.components[t].rules2&&r[t].ruler2.enableOnly(e.components[t].rules2)})),this},g.prototype.enable=function(e,t){var n=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach((function(t){n=n.concat(this[t].ruler.enable(e,!0))}),this),n=n.concat(this.inline.ruler2.enable(e,!0));var r=e.filter((function(e){return n.indexOf(e)<0}));if(r.length&&!t)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+r);return this},g.prototype.disable=function(e,t){var n=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach((function(t){n=n.concat(this[t].ruler.disable(e,!0))}),this),n=n.concat(this.inline.ruler2.disable(e,!0));var r=e.filter((function(e){return n.indexOf(e)<0}));if(r.length&&!t)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+r);return this},g.prototype.use=function(e){var t=[this].concat(Array.prototype.slice.call(arguments,1));return e.apply(e,t),this},g.prototype.parse=function(e,t){if("string"!=typeof e)throw new Error("Input data should be a String");var n=new this.core.State(e,this,t);return this.core.process(n),n.tokens},g.prototype.render=function(e,t){return t=t||{},this.renderer.render(this.parse(e,t),this.options,t)},g.prototype.parseInline=function(e,t){var n=new this.core.State(e,this,t);return n.inlineMode=!0,this.core.process(n),n.tokens},g.prototype.renderInline=function(e,t){return t=t||{},this.renderer.render(this.parseInline(e,t),this.options,t)},e.exports=g})?r.apply(t,i):r)||(e.exports=o)},function(e){e.exports=JSON.parse('{"Aacute":"Á","aacute":"á","Abreve":"Ă","abreve":"ă","ac":"∾","acd":"∿","acE":"∾̳","Acirc":"Â","acirc":"â","acute":"´","Acy":"А","acy":"а","AElig":"Æ","aelig":"æ","af":"⁡","Afr":"𝔄","afr":"𝔞","Agrave":"À","agrave":"à","alefsym":"ℵ","aleph":"ℵ","Alpha":"Α","alpha":"α","Amacr":"Ā","amacr":"ā","amalg":"⨿","amp":"&","AMP":"&","andand":"⩕","And":"⩓","and":"∧","andd":"⩜","andslope":"⩘","andv":"⩚","ang":"∠","ange":"⦤","angle":"∠","angmsdaa":"⦨","angmsdab":"⦩","angmsdac":"⦪","angmsdad":"⦫","angmsdae":"⦬","angmsdaf":"⦭","angmsdag":"⦮","angmsdah":"⦯","angmsd":"∡","angrt":"∟","angrtvb":"⊾","angrtvbd":"⦝","angsph":"∢","angst":"Å","angzarr":"⍼","Aogon":"Ą","aogon":"ą","Aopf":"𝔸","aopf":"𝕒","apacir":"⩯","ap":"≈","apE":"⩰","ape":"≊","apid":"≋","apos":"\'","ApplyFunction":"⁡","approx":"≈","approxeq":"≊","Aring":"Å","aring":"å","Ascr":"𝒜","ascr":"𝒶","Assign":"≔","ast":"*","asymp":"≈","asympeq":"≍","Atilde":"Ã","atilde":"ã","Auml":"Ä","auml":"ä","awconint":"∳","awint":"⨑","backcong":"≌","backepsilon":"϶","backprime":"‵","backsim":"∽","backsimeq":"⋍","Backslash":"∖","Barv":"⫧","barvee":"⊽","barwed":"⌅","Barwed":"⌆","barwedge":"⌅","bbrk":"⎵","bbrktbrk":"⎶","bcong":"≌","Bcy":"Б","bcy":"б","bdquo":"„","becaus":"∵","because":"∵","Because":"∵","bemptyv":"⦰","bepsi":"϶","bernou":"ℬ","Bernoullis":"ℬ","Beta":"Β","beta":"β","beth":"ℶ","between":"≬","Bfr":"𝔅","bfr":"𝔟","bigcap":"⋂","bigcirc":"◯","bigcup":"⋃","bigodot":"⨀","bigoplus":"⨁","bigotimes":"⨂","bigsqcup":"⨆","bigstar":"★","bigtriangledown":"▽","bigtriangleup":"△","biguplus":"⨄","bigvee":"⋁","bigwedge":"⋀","bkarow":"⤍","blacklozenge":"⧫","blacksquare":"▪","blacktriangle":"▴","blacktriangledown":"▾","blacktriangleleft":"◂","blacktriangleright":"▸","blank":"␣","blk12":"▒","blk14":"░","blk34":"▓","block":"█","bne":"=⃥","bnequiv":"≡⃥","bNot":"⫭","bnot":"⌐","Bopf":"𝔹","bopf":"𝕓","bot":"⊥","bottom":"⊥","bowtie":"⋈","boxbox":"⧉","boxdl":"┐","boxdL":"╕","boxDl":"╖","boxDL":"╗","boxdr":"┌","boxdR":"╒","boxDr":"╓","boxDR":"╔","boxh":"─","boxH":"═","boxhd":"┬","boxHd":"╤","boxhD":"╥","boxHD":"╦","boxhu":"┴","boxHu":"╧","boxhU":"╨","boxHU":"╩","boxminus":"⊟","boxplus":"⊞","boxtimes":"⊠","boxul":"┘","boxuL":"╛","boxUl":"╜","boxUL":"╝","boxur":"└","boxuR":"╘","boxUr":"╙","boxUR":"╚","boxv":"│","boxV":"║","boxvh":"┼","boxvH":"╪","boxVh":"╫","boxVH":"╬","boxvl":"┤","boxvL":"╡","boxVl":"╢","boxVL":"╣","boxvr":"├","boxvR":"╞","boxVr":"╟","boxVR":"╠","bprime":"‵","breve":"˘","Breve":"˘","brvbar":"¦","bscr":"𝒷","Bscr":"ℬ","bsemi":"⁏","bsim":"∽","bsime":"⋍","bsolb":"⧅","bsol":"\\\\","bsolhsub":"⟈","bull":"•","bullet":"•","bump":"≎","bumpE":"⪮","bumpe":"≏","Bumpeq":"≎","bumpeq":"≏","Cacute":"Ć","cacute":"ć","capand":"⩄","capbrcup":"⩉","capcap":"⩋","cap":"∩","Cap":"⋒","capcup":"⩇","capdot":"⩀","CapitalDifferentialD":"ⅅ","caps":"∩︀","caret":"⁁","caron":"ˇ","Cayleys":"ℭ","ccaps":"⩍","Ccaron":"Č","ccaron":"č","Ccedil":"Ç","ccedil":"ç","Ccirc":"Ĉ","ccirc":"ĉ","Cconint":"∰","ccups":"⩌","ccupssm":"⩐","Cdot":"Ċ","cdot":"ċ","cedil":"¸","Cedilla":"¸","cemptyv":"⦲","cent":"¢","centerdot":"·","CenterDot":"·","cfr":"𝔠","Cfr":"ℭ","CHcy":"Ч","chcy":"ч","check":"✓","checkmark":"✓","Chi":"Χ","chi":"χ","circ":"ˆ","circeq":"≗","circlearrowleft":"↺","circlearrowright":"↻","circledast":"⊛","circledcirc":"⊚","circleddash":"⊝","CircleDot":"⊙","circledR":"®","circledS":"Ⓢ","CircleMinus":"⊖","CirclePlus":"⊕","CircleTimes":"⊗","cir":"○","cirE":"⧃","cire":"≗","cirfnint":"⨐","cirmid":"⫯","cirscir":"⧂","ClockwiseContourIntegral":"∲","CloseCurlyDoubleQuote":"”","CloseCurlyQuote":"’","clubs":"♣","clubsuit":"♣","colon":":","Colon":"∷","Colone":"⩴","colone":"≔","coloneq":"≔","comma":",","commat":"@","comp":"∁","compfn":"∘","complement":"∁","complexes":"ℂ","cong":"≅","congdot":"⩭","Congruent":"≡","conint":"∮","Conint":"∯","ContourIntegral":"∮","copf":"𝕔","Copf":"ℂ","coprod":"∐","Coproduct":"∐","copy":"©","COPY":"©","copysr":"℗","CounterClockwiseContourIntegral":"∳","crarr":"↵","cross":"✗","Cross":"⨯","Cscr":"𝒞","cscr":"𝒸","csub":"⫏","csube":"⫑","csup":"⫐","csupe":"⫒","ctdot":"⋯","cudarrl":"⤸","cudarrr":"⤵","cuepr":"⋞","cuesc":"⋟","cularr":"↶","cularrp":"⤽","cupbrcap":"⩈","cupcap":"⩆","CupCap":"≍","cup":"∪","Cup":"⋓","cupcup":"⩊","cupdot":"⊍","cupor":"⩅","cups":"∪︀","curarr":"↷","curarrm":"⤼","curlyeqprec":"⋞","curlyeqsucc":"⋟","curlyvee":"⋎","curlywedge":"⋏","curren":"¤","curvearrowleft":"↶","curvearrowright":"↷","cuvee":"⋎","cuwed":"⋏","cwconint":"∲","cwint":"∱","cylcty":"⌭","dagger":"†","Dagger":"‡","daleth":"ℸ","darr":"↓","Darr":"↡","dArr":"⇓","dash":"‐","Dashv":"⫤","dashv":"⊣","dbkarow":"⤏","dblac":"˝","Dcaron":"Ď","dcaron":"ď","Dcy":"Д","dcy":"д","ddagger":"‡","ddarr":"⇊","DD":"ⅅ","dd":"ⅆ","DDotrahd":"⤑","ddotseq":"⩷","deg":"°","Del":"∇","Delta":"Δ","delta":"δ","demptyv":"⦱","dfisht":"⥿","Dfr":"𝔇","dfr":"𝔡","dHar":"⥥","dharl":"⇃","dharr":"⇂","DiacriticalAcute":"´","DiacriticalDot":"˙","DiacriticalDoubleAcute":"˝","DiacriticalGrave":"`","DiacriticalTilde":"˜","diam":"⋄","diamond":"⋄","Diamond":"⋄","diamondsuit":"♦","diams":"♦","die":"¨","DifferentialD":"ⅆ","digamma":"ϝ","disin":"⋲","div":"÷","divide":"÷","divideontimes":"⋇","divonx":"⋇","DJcy":"Ђ","djcy":"ђ","dlcorn":"⌞","dlcrop":"⌍","dollar":"$","Dopf":"𝔻","dopf":"𝕕","Dot":"¨","dot":"˙","DotDot":"⃜","doteq":"≐","doteqdot":"≑","DotEqual":"≐","dotminus":"∸","dotplus":"∔","dotsquare":"⊡","doublebarwedge":"⌆","DoubleContourIntegral":"∯","DoubleDot":"¨","DoubleDownArrow":"⇓","DoubleLeftArrow":"⇐","DoubleLeftRightArrow":"⇔","DoubleLeftTee":"⫤","DoubleLongLeftArrow":"⟸","DoubleLongLeftRightArrow":"⟺","DoubleLongRightArrow":"⟹","DoubleRightArrow":"⇒","DoubleRightTee":"⊨","DoubleUpArrow":"⇑","DoubleUpDownArrow":"⇕","DoubleVerticalBar":"∥","DownArrowBar":"⤓","downarrow":"↓","DownArrow":"↓","Downarrow":"⇓","DownArrowUpArrow":"⇵","DownBreve":"̑","downdownarrows":"⇊","downharpoonleft":"⇃","downharpoonright":"⇂","DownLeftRightVector":"⥐","DownLeftTeeVector":"⥞","DownLeftVectorBar":"⥖","DownLeftVector":"↽","DownRightTeeVector":"⥟","DownRightVectorBar":"⥗","DownRightVector":"⇁","DownTeeArrow":"↧","DownTee":"⊤","drbkarow":"⤐","drcorn":"⌟","drcrop":"⌌","Dscr":"𝒟","dscr":"𝒹","DScy":"Ѕ","dscy":"ѕ","dsol":"⧶","Dstrok":"Đ","dstrok":"đ","dtdot":"⋱","dtri":"▿","dtrif":"▾","duarr":"⇵","duhar":"⥯","dwangle":"⦦","DZcy":"Џ","dzcy":"џ","dzigrarr":"⟿","Eacute":"É","eacute":"é","easter":"⩮","Ecaron":"Ě","ecaron":"ě","Ecirc":"Ê","ecirc":"ê","ecir":"≖","ecolon":"≕","Ecy":"Э","ecy":"э","eDDot":"⩷","Edot":"Ė","edot":"ė","eDot":"≑","ee":"ⅇ","efDot":"≒","Efr":"𝔈","efr":"𝔢","eg":"⪚","Egrave":"È","egrave":"è","egs":"⪖","egsdot":"⪘","el":"⪙","Element":"∈","elinters":"⏧","ell":"ℓ","els":"⪕","elsdot":"⪗","Emacr":"Ē","emacr":"ē","empty":"∅","emptyset":"∅","EmptySmallSquare":"◻","emptyv":"∅","EmptyVerySmallSquare":"▫","emsp13":" ","emsp14":" ","emsp":" ","ENG":"Ŋ","eng":"ŋ","ensp":" ","Eogon":"Ę","eogon":"ę","Eopf":"𝔼","eopf":"𝕖","epar":"⋕","eparsl":"⧣","eplus":"⩱","epsi":"ε","Epsilon":"Ε","epsilon":"ε","epsiv":"ϵ","eqcirc":"≖","eqcolon":"≕","eqsim":"≂","eqslantgtr":"⪖","eqslantless":"⪕","Equal":"⩵","equals":"=","EqualTilde":"≂","equest":"≟","Equilibrium":"⇌","equiv":"≡","equivDD":"⩸","eqvparsl":"⧥","erarr":"⥱","erDot":"≓","escr":"ℯ","Escr":"ℰ","esdot":"≐","Esim":"⩳","esim":"≂","Eta":"Η","eta":"η","ETH":"Ð","eth":"ð","Euml":"Ë","euml":"ë","euro":"€","excl":"!","exist":"∃","Exists":"∃","expectation":"ℰ","exponentiale":"ⅇ","ExponentialE":"ⅇ","fallingdotseq":"≒","Fcy":"Ф","fcy":"ф","female":"♀","ffilig":"ffi","fflig":"ff","ffllig":"ffl","Ffr":"𝔉","ffr":"𝔣","filig":"fi","FilledSmallSquare":"◼","FilledVerySmallSquare":"▪","fjlig":"fj","flat":"♭","fllig":"fl","fltns":"▱","fnof":"ƒ","Fopf":"𝔽","fopf":"𝕗","forall":"∀","ForAll":"∀","fork":"⋔","forkv":"⫙","Fouriertrf":"ℱ","fpartint":"⨍","frac12":"½","frac13":"⅓","frac14":"¼","frac15":"⅕","frac16":"⅙","frac18":"⅛","frac23":"⅔","frac25":"⅖","frac34":"¾","frac35":"⅗","frac38":"⅜","frac45":"⅘","frac56":"⅚","frac58":"⅝","frac78":"⅞","frasl":"⁄","frown":"⌢","fscr":"𝒻","Fscr":"ℱ","gacute":"ǵ","Gamma":"Γ","gamma":"γ","Gammad":"Ϝ","gammad":"ϝ","gap":"⪆","Gbreve":"Ğ","gbreve":"ğ","Gcedil":"Ģ","Gcirc":"Ĝ","gcirc":"ĝ","Gcy":"Г","gcy":"г","Gdot":"Ġ","gdot":"ġ","ge":"≥","gE":"≧","gEl":"⪌","gel":"⋛","geq":"≥","geqq":"≧","geqslant":"⩾","gescc":"⪩","ges":"⩾","gesdot":"⪀","gesdoto":"⪂","gesdotol":"⪄","gesl":"⋛︀","gesles":"⪔","Gfr":"𝔊","gfr":"𝔤","gg":"≫","Gg":"⋙","ggg":"⋙","gimel":"ℷ","GJcy":"Ѓ","gjcy":"ѓ","gla":"⪥","gl":"≷","glE":"⪒","glj":"⪤","gnap":"⪊","gnapprox":"⪊","gne":"⪈","gnE":"≩","gneq":"⪈","gneqq":"≩","gnsim":"⋧","Gopf":"𝔾","gopf":"𝕘","grave":"`","GreaterEqual":"≥","GreaterEqualLess":"⋛","GreaterFullEqual":"≧","GreaterGreater":"⪢","GreaterLess":"≷","GreaterSlantEqual":"⩾","GreaterTilde":"≳","Gscr":"𝒢","gscr":"ℊ","gsim":"≳","gsime":"⪎","gsiml":"⪐","gtcc":"⪧","gtcir":"⩺","gt":">","GT":">","Gt":"≫","gtdot":"⋗","gtlPar":"⦕","gtquest":"⩼","gtrapprox":"⪆","gtrarr":"⥸","gtrdot":"⋗","gtreqless":"⋛","gtreqqless":"⪌","gtrless":"≷","gtrsim":"≳","gvertneqq":"≩︀","gvnE":"≩︀","Hacek":"ˇ","hairsp":" ","half":"½","hamilt":"ℋ","HARDcy":"Ъ","hardcy":"ъ","harrcir":"⥈","harr":"↔","hArr":"⇔","harrw":"↭","Hat":"^","hbar":"ℏ","Hcirc":"Ĥ","hcirc":"ĥ","hearts":"♥","heartsuit":"♥","hellip":"…","hercon":"⊹","hfr":"𝔥","Hfr":"ℌ","HilbertSpace":"ℋ","hksearow":"⤥","hkswarow":"⤦","hoarr":"⇿","homtht":"∻","hookleftarrow":"↩","hookrightarrow":"↪","hopf":"𝕙","Hopf":"ℍ","horbar":"―","HorizontalLine":"─","hscr":"𝒽","Hscr":"ℋ","hslash":"ℏ","Hstrok":"Ħ","hstrok":"ħ","HumpDownHump":"≎","HumpEqual":"≏","hybull":"⁃","hyphen":"‐","Iacute":"Í","iacute":"í","ic":"⁣","Icirc":"Î","icirc":"î","Icy":"И","icy":"и","Idot":"İ","IEcy":"Е","iecy":"е","iexcl":"¡","iff":"⇔","ifr":"𝔦","Ifr":"ℑ","Igrave":"Ì","igrave":"ì","ii":"ⅈ","iiiint":"⨌","iiint":"∭","iinfin":"⧜","iiota":"℩","IJlig":"IJ","ijlig":"ij","Imacr":"Ī","imacr":"ī","image":"ℑ","ImaginaryI":"ⅈ","imagline":"ℐ","imagpart":"ℑ","imath":"ı","Im":"ℑ","imof":"⊷","imped":"Ƶ","Implies":"⇒","incare":"℅","in":"∈","infin":"∞","infintie":"⧝","inodot":"ı","intcal":"⊺","int":"∫","Int":"∬","integers":"ℤ","Integral":"∫","intercal":"⊺","Intersection":"⋂","intlarhk":"⨗","intprod":"⨼","InvisibleComma":"⁣","InvisibleTimes":"⁢","IOcy":"Ё","iocy":"ё","Iogon":"Į","iogon":"į","Iopf":"𝕀","iopf":"𝕚","Iota":"Ι","iota":"ι","iprod":"⨼","iquest":"¿","iscr":"𝒾","Iscr":"ℐ","isin":"∈","isindot":"⋵","isinE":"⋹","isins":"⋴","isinsv":"⋳","isinv":"∈","it":"⁢","Itilde":"Ĩ","itilde":"ĩ","Iukcy":"І","iukcy":"і","Iuml":"Ï","iuml":"ï","Jcirc":"Ĵ","jcirc":"ĵ","Jcy":"Й","jcy":"й","Jfr":"𝔍","jfr":"𝔧","jmath":"ȷ","Jopf":"𝕁","jopf":"𝕛","Jscr":"𝒥","jscr":"𝒿","Jsercy":"Ј","jsercy":"ј","Jukcy":"Є","jukcy":"є","Kappa":"Κ","kappa":"κ","kappav":"ϰ","Kcedil":"Ķ","kcedil":"ķ","Kcy":"К","kcy":"к","Kfr":"𝔎","kfr":"𝔨","kgreen":"ĸ","KHcy":"Х","khcy":"х","KJcy":"Ќ","kjcy":"ќ","Kopf":"𝕂","kopf":"𝕜","Kscr":"𝒦","kscr":"𝓀","lAarr":"⇚","Lacute":"Ĺ","lacute":"ĺ","laemptyv":"⦴","lagran":"ℒ","Lambda":"Λ","lambda":"λ","lang":"⟨","Lang":"⟪","langd":"⦑","langle":"⟨","lap":"⪅","Laplacetrf":"ℒ","laquo":"«","larrb":"⇤","larrbfs":"⤟","larr":"←","Larr":"↞","lArr":"⇐","larrfs":"⤝","larrhk":"↩","larrlp":"↫","larrpl":"⤹","larrsim":"⥳","larrtl":"↢","latail":"⤙","lAtail":"⤛","lat":"⪫","late":"⪭","lates":"⪭︀","lbarr":"⤌","lBarr":"⤎","lbbrk":"❲","lbrace":"{","lbrack":"[","lbrke":"⦋","lbrksld":"⦏","lbrkslu":"⦍","Lcaron":"Ľ","lcaron":"ľ","Lcedil":"Ļ","lcedil":"ļ","lceil":"⌈","lcub":"{","Lcy":"Л","lcy":"л","ldca":"⤶","ldquo":"“","ldquor":"„","ldrdhar":"⥧","ldrushar":"⥋","ldsh":"↲","le":"≤","lE":"≦","LeftAngleBracket":"⟨","LeftArrowBar":"⇤","leftarrow":"←","LeftArrow":"←","Leftarrow":"⇐","LeftArrowRightArrow":"⇆","leftarrowtail":"↢","LeftCeiling":"⌈","LeftDoubleBracket":"⟦","LeftDownTeeVector":"⥡","LeftDownVectorBar":"⥙","LeftDownVector":"⇃","LeftFloor":"⌊","leftharpoondown":"↽","leftharpoonup":"↼","leftleftarrows":"⇇","leftrightarrow":"↔","LeftRightArrow":"↔","Leftrightarrow":"⇔","leftrightarrows":"⇆","leftrightharpoons":"⇋","leftrightsquigarrow":"↭","LeftRightVector":"⥎","LeftTeeArrow":"↤","LeftTee":"⊣","LeftTeeVector":"⥚","leftthreetimes":"⋋","LeftTriangleBar":"⧏","LeftTriangle":"⊲","LeftTriangleEqual":"⊴","LeftUpDownVector":"⥑","LeftUpTeeVector":"⥠","LeftUpVectorBar":"⥘","LeftUpVector":"↿","LeftVectorBar":"⥒","LeftVector":"↼","lEg":"⪋","leg":"⋚","leq":"≤","leqq":"≦","leqslant":"⩽","lescc":"⪨","les":"⩽","lesdot":"⩿","lesdoto":"⪁","lesdotor":"⪃","lesg":"⋚︀","lesges":"⪓","lessapprox":"⪅","lessdot":"⋖","lesseqgtr":"⋚","lesseqqgtr":"⪋","LessEqualGreater":"⋚","LessFullEqual":"≦","LessGreater":"≶","lessgtr":"≶","LessLess":"⪡","lesssim":"≲","LessSlantEqual":"⩽","LessTilde":"≲","lfisht":"⥼","lfloor":"⌊","Lfr":"𝔏","lfr":"𝔩","lg":"≶","lgE":"⪑","lHar":"⥢","lhard":"↽","lharu":"↼","lharul":"⥪","lhblk":"▄","LJcy":"Љ","ljcy":"љ","llarr":"⇇","ll":"≪","Ll":"⋘","llcorner":"⌞","Lleftarrow":"⇚","llhard":"⥫","lltri":"◺","Lmidot":"Ŀ","lmidot":"ŀ","lmoustache":"⎰","lmoust":"⎰","lnap":"⪉","lnapprox":"⪉","lne":"⪇","lnE":"≨","lneq":"⪇","lneqq":"≨","lnsim":"⋦","loang":"⟬","loarr":"⇽","lobrk":"⟦","longleftarrow":"⟵","LongLeftArrow":"⟵","Longleftarrow":"⟸","longleftrightarrow":"⟷","LongLeftRightArrow":"⟷","Longleftrightarrow":"⟺","longmapsto":"⟼","longrightarrow":"⟶","LongRightArrow":"⟶","Longrightarrow":"⟹","looparrowleft":"↫","looparrowright":"↬","lopar":"⦅","Lopf":"𝕃","lopf":"𝕝","loplus":"⨭","lotimes":"⨴","lowast":"∗","lowbar":"_","LowerLeftArrow":"↙","LowerRightArrow":"↘","loz":"◊","lozenge":"◊","lozf":"⧫","lpar":"(","lparlt":"⦓","lrarr":"⇆","lrcorner":"⌟","lrhar":"⇋","lrhard":"⥭","lrm":"‎","lrtri":"⊿","lsaquo":"‹","lscr":"𝓁","Lscr":"ℒ","lsh":"↰","Lsh":"↰","lsim":"≲","lsime":"⪍","lsimg":"⪏","lsqb":"[","lsquo":"‘","lsquor":"‚","Lstrok":"Ł","lstrok":"ł","ltcc":"⪦","ltcir":"⩹","lt":"<","LT":"<","Lt":"≪","ltdot":"⋖","lthree":"⋋","ltimes":"⋉","ltlarr":"⥶","ltquest":"⩻","ltri":"◃","ltrie":"⊴","ltrif":"◂","ltrPar":"⦖","lurdshar":"⥊","luruhar":"⥦","lvertneqq":"≨︀","lvnE":"≨︀","macr":"¯","male":"♂","malt":"✠","maltese":"✠","Map":"⤅","map":"↦","mapsto":"↦","mapstodown":"↧","mapstoleft":"↤","mapstoup":"↥","marker":"▮","mcomma":"⨩","Mcy":"М","mcy":"м","mdash":"—","mDDot":"∺","measuredangle":"∡","MediumSpace":" ","Mellintrf":"ℳ","Mfr":"𝔐","mfr":"𝔪","mho":"℧","micro":"µ","midast":"*","midcir":"⫰","mid":"∣","middot":"·","minusb":"⊟","minus":"−","minusd":"∸","minusdu":"⨪","MinusPlus":"∓","mlcp":"⫛","mldr":"…","mnplus":"∓","models":"⊧","Mopf":"𝕄","mopf":"𝕞","mp":"∓","mscr":"𝓂","Mscr":"ℳ","mstpos":"∾","Mu":"Μ","mu":"μ","multimap":"⊸","mumap":"⊸","nabla":"∇","Nacute":"Ń","nacute":"ń","nang":"∠⃒","nap":"≉","napE":"⩰̸","napid":"≋̸","napos":"ʼn","napprox":"≉","natural":"♮","naturals":"ℕ","natur":"♮","nbsp":" ","nbump":"≎̸","nbumpe":"≏̸","ncap":"⩃","Ncaron":"Ň","ncaron":"ň","Ncedil":"Ņ","ncedil":"ņ","ncong":"≇","ncongdot":"⩭̸","ncup":"⩂","Ncy":"Н","ncy":"н","ndash":"–","nearhk":"⤤","nearr":"↗","neArr":"⇗","nearrow":"↗","ne":"≠","nedot":"≐̸","NegativeMediumSpace":"​","NegativeThickSpace":"​","NegativeThinSpace":"​","NegativeVeryThinSpace":"​","nequiv":"≢","nesear":"⤨","nesim":"≂̸","NestedGreaterGreater":"≫","NestedLessLess":"≪","NewLine":"\\n","nexist":"∄","nexists":"∄","Nfr":"𝔑","nfr":"𝔫","ngE":"≧̸","nge":"≱","ngeq":"≱","ngeqq":"≧̸","ngeqslant":"⩾̸","nges":"⩾̸","nGg":"⋙̸","ngsim":"≵","nGt":"≫⃒","ngt":"≯","ngtr":"≯","nGtv":"≫̸","nharr":"↮","nhArr":"⇎","nhpar":"⫲","ni":"∋","nis":"⋼","nisd":"⋺","niv":"∋","NJcy":"Њ","njcy":"њ","nlarr":"↚","nlArr":"⇍","nldr":"‥","nlE":"≦̸","nle":"≰","nleftarrow":"↚","nLeftarrow":"⇍","nleftrightarrow":"↮","nLeftrightarrow":"⇎","nleq":"≰","nleqq":"≦̸","nleqslant":"⩽̸","nles":"⩽̸","nless":"≮","nLl":"⋘̸","nlsim":"≴","nLt":"≪⃒","nlt":"≮","nltri":"⋪","nltrie":"⋬","nLtv":"≪̸","nmid":"∤","NoBreak":"⁠","NonBreakingSpace":" ","nopf":"𝕟","Nopf":"ℕ","Not":"⫬","not":"¬","NotCongruent":"≢","NotCupCap":"≭","NotDoubleVerticalBar":"∦","NotElement":"∉","NotEqual":"≠","NotEqualTilde":"≂̸","NotExists":"∄","NotGreater":"≯","NotGreaterEqual":"≱","NotGreaterFullEqual":"≧̸","NotGreaterGreater":"≫̸","NotGreaterLess":"≹","NotGreaterSlantEqual":"⩾̸","NotGreaterTilde":"≵","NotHumpDownHump":"≎̸","NotHumpEqual":"≏̸","notin":"∉","notindot":"⋵̸","notinE":"⋹̸","notinva":"∉","notinvb":"⋷","notinvc":"⋶","NotLeftTriangleBar":"⧏̸","NotLeftTriangle":"⋪","NotLeftTriangleEqual":"⋬","NotLess":"≮","NotLessEqual":"≰","NotLessGreater":"≸","NotLessLess":"≪̸","NotLessSlantEqual":"⩽̸","NotLessTilde":"≴","NotNestedGreaterGreater":"⪢̸","NotNestedLessLess":"⪡̸","notni":"∌","notniva":"∌","notnivb":"⋾","notnivc":"⋽","NotPrecedes":"⊀","NotPrecedesEqual":"⪯̸","NotPrecedesSlantEqual":"⋠","NotReverseElement":"∌","NotRightTriangleBar":"⧐̸","NotRightTriangle":"⋫","NotRightTriangleEqual":"⋭","NotSquareSubset":"⊏̸","NotSquareSubsetEqual":"⋢","NotSquareSuperset":"⊐̸","NotSquareSupersetEqual":"⋣","NotSubset":"⊂⃒","NotSubsetEqual":"⊈","NotSucceeds":"⊁","NotSucceedsEqual":"⪰̸","NotSucceedsSlantEqual":"⋡","NotSucceedsTilde":"≿̸","NotSuperset":"⊃⃒","NotSupersetEqual":"⊉","NotTilde":"≁","NotTildeEqual":"≄","NotTildeFullEqual":"≇","NotTildeTilde":"≉","NotVerticalBar":"∤","nparallel":"∦","npar":"∦","nparsl":"⫽⃥","npart":"∂̸","npolint":"⨔","npr":"⊀","nprcue":"⋠","nprec":"⊀","npreceq":"⪯̸","npre":"⪯̸","nrarrc":"⤳̸","nrarr":"↛","nrArr":"⇏","nrarrw":"↝̸","nrightarrow":"↛","nRightarrow":"⇏","nrtri":"⋫","nrtrie":"⋭","nsc":"⊁","nsccue":"⋡","nsce":"⪰̸","Nscr":"𝒩","nscr":"𝓃","nshortmid":"∤","nshortparallel":"∦","nsim":"≁","nsime":"≄","nsimeq":"≄","nsmid":"∤","nspar":"∦","nsqsube":"⋢","nsqsupe":"⋣","nsub":"⊄","nsubE":"⫅̸","nsube":"⊈","nsubset":"⊂⃒","nsubseteq":"⊈","nsubseteqq":"⫅̸","nsucc":"⊁","nsucceq":"⪰̸","nsup":"⊅","nsupE":"⫆̸","nsupe":"⊉","nsupset":"⊃⃒","nsupseteq":"⊉","nsupseteqq":"⫆̸","ntgl":"≹","Ntilde":"Ñ","ntilde":"ñ","ntlg":"≸","ntriangleleft":"⋪","ntrianglelefteq":"⋬","ntriangleright":"⋫","ntrianglerighteq":"⋭","Nu":"Ν","nu":"ν","num":"#","numero":"№","numsp":" ","nvap":"≍⃒","nvdash":"⊬","nvDash":"⊭","nVdash":"⊮","nVDash":"⊯","nvge":"≥⃒","nvgt":">⃒","nvHarr":"⤄","nvinfin":"⧞","nvlArr":"⤂","nvle":"≤⃒","nvlt":"<⃒","nvltrie":"⊴⃒","nvrArr":"⤃","nvrtrie":"⊵⃒","nvsim":"∼⃒","nwarhk":"⤣","nwarr":"↖","nwArr":"⇖","nwarrow":"↖","nwnear":"⤧","Oacute":"Ó","oacute":"ó","oast":"⊛","Ocirc":"Ô","ocirc":"ô","ocir":"⊚","Ocy":"О","ocy":"о","odash":"⊝","Odblac":"Ő","odblac":"ő","odiv":"⨸","odot":"⊙","odsold":"⦼","OElig":"Œ","oelig":"œ","ofcir":"⦿","Ofr":"𝔒","ofr":"𝔬","ogon":"˛","Ograve":"Ò","ograve":"ò","ogt":"⧁","ohbar":"⦵","ohm":"Ω","oint":"∮","olarr":"↺","olcir":"⦾","olcross":"⦻","oline":"‾","olt":"⧀","Omacr":"Ō","omacr":"ō","Omega":"Ω","omega":"ω","Omicron":"Ο","omicron":"ο","omid":"⦶","ominus":"⊖","Oopf":"𝕆","oopf":"𝕠","opar":"⦷","OpenCurlyDoubleQuote":"“","OpenCurlyQuote":"‘","operp":"⦹","oplus":"⊕","orarr":"↻","Or":"⩔","or":"∨","ord":"⩝","order":"ℴ","orderof":"ℴ","ordf":"ª","ordm":"º","origof":"⊶","oror":"⩖","orslope":"⩗","orv":"⩛","oS":"Ⓢ","Oscr":"𝒪","oscr":"ℴ","Oslash":"Ø","oslash":"ø","osol":"⊘","Otilde":"Õ","otilde":"õ","otimesas":"⨶","Otimes":"⨷","otimes":"⊗","Ouml":"Ö","ouml":"ö","ovbar":"⌽","OverBar":"‾","OverBrace":"⏞","OverBracket":"⎴","OverParenthesis":"⏜","para":"¶","parallel":"∥","par":"∥","parsim":"⫳","parsl":"⫽","part":"∂","PartialD":"∂","Pcy":"П","pcy":"п","percnt":"%","period":".","permil":"‰","perp":"⊥","pertenk":"‱","Pfr":"𝔓","pfr":"𝔭","Phi":"Φ","phi":"φ","phiv":"ϕ","phmmat":"ℳ","phone":"☎","Pi":"Π","pi":"π","pitchfork":"⋔","piv":"ϖ","planck":"ℏ","planckh":"ℎ","plankv":"ℏ","plusacir":"⨣","plusb":"⊞","pluscir":"⨢","plus":"+","plusdo":"∔","plusdu":"⨥","pluse":"⩲","PlusMinus":"±","plusmn":"±","plussim":"⨦","plustwo":"⨧","pm":"±","Poincareplane":"ℌ","pointint":"⨕","popf":"𝕡","Popf":"ℙ","pound":"£","prap":"⪷","Pr":"⪻","pr":"≺","prcue":"≼","precapprox":"⪷","prec":"≺","preccurlyeq":"≼","Precedes":"≺","PrecedesEqual":"⪯","PrecedesSlantEqual":"≼","PrecedesTilde":"≾","preceq":"⪯","precnapprox":"⪹","precneqq":"⪵","precnsim":"⋨","pre":"⪯","prE":"⪳","precsim":"≾","prime":"′","Prime":"″","primes":"ℙ","prnap":"⪹","prnE":"⪵","prnsim":"⋨","prod":"∏","Product":"∏","profalar":"⌮","profline":"⌒","profsurf":"⌓","prop":"∝","Proportional":"∝","Proportion":"∷","propto":"∝","prsim":"≾","prurel":"⊰","Pscr":"𝒫","pscr":"𝓅","Psi":"Ψ","psi":"ψ","puncsp":" ","Qfr":"𝔔","qfr":"𝔮","qint":"⨌","qopf":"𝕢","Qopf":"ℚ","qprime":"⁗","Qscr":"𝒬","qscr":"𝓆","quaternions":"ℍ","quatint":"⨖","quest":"?","questeq":"≟","quot":"\\"","QUOT":"\\"","rAarr":"⇛","race":"∽̱","Racute":"Ŕ","racute":"ŕ","radic":"√","raemptyv":"⦳","rang":"⟩","Rang":"⟫","rangd":"⦒","range":"⦥","rangle":"⟩","raquo":"»","rarrap":"⥵","rarrb":"⇥","rarrbfs":"⤠","rarrc":"⤳","rarr":"→","Rarr":"↠","rArr":"⇒","rarrfs":"⤞","rarrhk":"↪","rarrlp":"↬","rarrpl":"⥅","rarrsim":"⥴","Rarrtl":"⤖","rarrtl":"↣","rarrw":"↝","ratail":"⤚","rAtail":"⤜","ratio":"∶","rationals":"ℚ","rbarr":"⤍","rBarr":"⤏","RBarr":"⤐","rbbrk":"❳","rbrace":"}","rbrack":"]","rbrke":"⦌","rbrksld":"⦎","rbrkslu":"⦐","Rcaron":"Ř","rcaron":"ř","Rcedil":"Ŗ","rcedil":"ŗ","rceil":"⌉","rcub":"}","Rcy":"Р","rcy":"р","rdca":"⤷","rdldhar":"⥩","rdquo":"”","rdquor":"”","rdsh":"↳","real":"ℜ","realine":"ℛ","realpart":"ℜ","reals":"ℝ","Re":"ℜ","rect":"▭","reg":"®","REG":"®","ReverseElement":"∋","ReverseEquilibrium":"⇋","ReverseUpEquilibrium":"⥯","rfisht":"⥽","rfloor":"⌋","rfr":"𝔯","Rfr":"ℜ","rHar":"⥤","rhard":"⇁","rharu":"⇀","rharul":"⥬","Rho":"Ρ","rho":"ρ","rhov":"ϱ","RightAngleBracket":"⟩","RightArrowBar":"⇥","rightarrow":"→","RightArrow":"→","Rightarrow":"⇒","RightArrowLeftArrow":"⇄","rightarrowtail":"↣","RightCeiling":"⌉","RightDoubleBracket":"⟧","RightDownTeeVector":"⥝","RightDownVectorBar":"⥕","RightDownVector":"⇂","RightFloor":"⌋","rightharpoondown":"⇁","rightharpoonup":"⇀","rightleftarrows":"⇄","rightleftharpoons":"⇌","rightrightarrows":"⇉","rightsquigarrow":"↝","RightTeeArrow":"↦","RightTee":"⊢","RightTeeVector":"⥛","rightthreetimes":"⋌","RightTriangleBar":"⧐","RightTriangle":"⊳","RightTriangleEqual":"⊵","RightUpDownVector":"⥏","RightUpTeeVector":"⥜","RightUpVectorBar":"⥔","RightUpVector":"↾","RightVectorBar":"⥓","RightVector":"⇀","ring":"˚","risingdotseq":"≓","rlarr":"⇄","rlhar":"⇌","rlm":"‏","rmoustache":"⎱","rmoust":"⎱","rnmid":"⫮","roang":"⟭","roarr":"⇾","robrk":"⟧","ropar":"⦆","ropf":"𝕣","Ropf":"ℝ","roplus":"⨮","rotimes":"⨵","RoundImplies":"⥰","rpar":")","rpargt":"⦔","rppolint":"⨒","rrarr":"⇉","Rrightarrow":"⇛","rsaquo":"›","rscr":"𝓇","Rscr":"ℛ","rsh":"↱","Rsh":"↱","rsqb":"]","rsquo":"’","rsquor":"’","rthree":"⋌","rtimes":"⋊","rtri":"▹","rtrie":"⊵","rtrif":"▸","rtriltri":"⧎","RuleDelayed":"⧴","ruluhar":"⥨","rx":"℞","Sacute":"Ś","sacute":"ś","sbquo":"‚","scap":"⪸","Scaron":"Š","scaron":"š","Sc":"⪼","sc":"≻","sccue":"≽","sce":"⪰","scE":"⪴","Scedil":"Ş","scedil":"ş","Scirc":"Ŝ","scirc":"ŝ","scnap":"⪺","scnE":"⪶","scnsim":"⋩","scpolint":"⨓","scsim":"≿","Scy":"С","scy":"с","sdotb":"⊡","sdot":"⋅","sdote":"⩦","searhk":"⤥","searr":"↘","seArr":"⇘","searrow":"↘","sect":"§","semi":";","seswar":"⤩","setminus":"∖","setmn":"∖","sext":"✶","Sfr":"𝔖","sfr":"𝔰","sfrown":"⌢","sharp":"♯","SHCHcy":"Щ","shchcy":"щ","SHcy":"Ш","shcy":"ш","ShortDownArrow":"↓","ShortLeftArrow":"←","shortmid":"∣","shortparallel":"∥","ShortRightArrow":"→","ShortUpArrow":"↑","shy":"­","Sigma":"Σ","sigma":"σ","sigmaf":"ς","sigmav":"ς","sim":"∼","simdot":"⩪","sime":"≃","simeq":"≃","simg":"⪞","simgE":"⪠","siml":"⪝","simlE":"⪟","simne":"≆","simplus":"⨤","simrarr":"⥲","slarr":"←","SmallCircle":"∘","smallsetminus":"∖","smashp":"⨳","smeparsl":"⧤","smid":"∣","smile":"⌣","smt":"⪪","smte":"⪬","smtes":"⪬︀","SOFTcy":"Ь","softcy":"ь","solbar":"⌿","solb":"⧄","sol":"/","Sopf":"𝕊","sopf":"𝕤","spades":"♠","spadesuit":"♠","spar":"∥","sqcap":"⊓","sqcaps":"⊓︀","sqcup":"⊔","sqcups":"⊔︀","Sqrt":"√","sqsub":"⊏","sqsube":"⊑","sqsubset":"⊏","sqsubseteq":"⊑","sqsup":"⊐","sqsupe":"⊒","sqsupset":"⊐","sqsupseteq":"⊒","square":"□","Square":"□","SquareIntersection":"⊓","SquareSubset":"⊏","SquareSubsetEqual":"⊑","SquareSuperset":"⊐","SquareSupersetEqual":"⊒","SquareUnion":"⊔","squarf":"▪","squ":"□","squf":"▪","srarr":"→","Sscr":"𝒮","sscr":"𝓈","ssetmn":"∖","ssmile":"⌣","sstarf":"⋆","Star":"⋆","star":"☆","starf":"★","straightepsilon":"ϵ","straightphi":"ϕ","strns":"¯","sub":"⊂","Sub":"⋐","subdot":"⪽","subE":"⫅","sube":"⊆","subedot":"⫃","submult":"⫁","subnE":"⫋","subne":"⊊","subplus":"⪿","subrarr":"⥹","subset":"⊂","Subset":"⋐","subseteq":"⊆","subseteqq":"⫅","SubsetEqual":"⊆","subsetneq":"⊊","subsetneqq":"⫋","subsim":"⫇","subsub":"⫕","subsup":"⫓","succapprox":"⪸","succ":"≻","succcurlyeq":"≽","Succeeds":"≻","SucceedsEqual":"⪰","SucceedsSlantEqual":"≽","SucceedsTilde":"≿","succeq":"⪰","succnapprox":"⪺","succneqq":"⪶","succnsim":"⋩","succsim":"≿","SuchThat":"∋","sum":"∑","Sum":"∑","sung":"♪","sup1":"¹","sup2":"²","sup3":"³","sup":"⊃","Sup":"⋑","supdot":"⪾","supdsub":"⫘","supE":"⫆","supe":"⊇","supedot":"⫄","Superset":"⊃","SupersetEqual":"⊇","suphsol":"⟉","suphsub":"⫗","suplarr":"⥻","supmult":"⫂","supnE":"⫌","supne":"⊋","supplus":"⫀","supset":"⊃","Supset":"⋑","supseteq":"⊇","supseteqq":"⫆","supsetneq":"⊋","supsetneqq":"⫌","supsim":"⫈","supsub":"⫔","supsup":"⫖","swarhk":"⤦","swarr":"↙","swArr":"⇙","swarrow":"↙","swnwar":"⤪","szlig":"ß","Tab":"\\t","target":"⌖","Tau":"Τ","tau":"τ","tbrk":"⎴","Tcaron":"Ť","tcaron":"ť","Tcedil":"Ţ","tcedil":"ţ","Tcy":"Т","tcy":"т","tdot":"⃛","telrec":"⌕","Tfr":"𝔗","tfr":"𝔱","there4":"∴","therefore":"∴","Therefore":"∴","Theta":"Θ","theta":"θ","thetasym":"ϑ","thetav":"ϑ","thickapprox":"≈","thicksim":"∼","ThickSpace":"  ","ThinSpace":" ","thinsp":" ","thkap":"≈","thksim":"∼","THORN":"Þ","thorn":"þ","tilde":"˜","Tilde":"∼","TildeEqual":"≃","TildeFullEqual":"≅","TildeTilde":"≈","timesbar":"⨱","timesb":"⊠","times":"×","timesd":"⨰","tint":"∭","toea":"⤨","topbot":"⌶","topcir":"⫱","top":"⊤","Topf":"𝕋","topf":"𝕥","topfork":"⫚","tosa":"⤩","tprime":"‴","trade":"™","TRADE":"™","triangle":"▵","triangledown":"▿","triangleleft":"◃","trianglelefteq":"⊴","triangleq":"≜","triangleright":"▹","trianglerighteq":"⊵","tridot":"◬","trie":"≜","triminus":"⨺","TripleDot":"⃛","triplus":"⨹","trisb":"⧍","tritime":"⨻","trpezium":"⏢","Tscr":"𝒯","tscr":"𝓉","TScy":"Ц","tscy":"ц","TSHcy":"Ћ","tshcy":"ћ","Tstrok":"Ŧ","tstrok":"ŧ","twixt":"≬","twoheadleftarrow":"↞","twoheadrightarrow":"↠","Uacute":"Ú","uacute":"ú","uarr":"↑","Uarr":"↟","uArr":"⇑","Uarrocir":"⥉","Ubrcy":"Ў","ubrcy":"ў","Ubreve":"Ŭ","ubreve":"ŭ","Ucirc":"Û","ucirc":"û","Ucy":"У","ucy":"у","udarr":"⇅","Udblac":"Ű","udblac":"ű","udhar":"⥮","ufisht":"⥾","Ufr":"𝔘","ufr":"𝔲","Ugrave":"Ù","ugrave":"ù","uHar":"⥣","uharl":"↿","uharr":"↾","uhblk":"▀","ulcorn":"⌜","ulcorner":"⌜","ulcrop":"⌏","ultri":"◸","Umacr":"Ū","umacr":"ū","uml":"¨","UnderBar":"_","UnderBrace":"⏟","UnderBracket":"⎵","UnderParenthesis":"⏝","Union":"⋃","UnionPlus":"⊎","Uogon":"Ų","uogon":"ų","Uopf":"𝕌","uopf":"𝕦","UpArrowBar":"⤒","uparrow":"↑","UpArrow":"↑","Uparrow":"⇑","UpArrowDownArrow":"⇅","updownarrow":"↕","UpDownArrow":"↕","Updownarrow":"⇕","UpEquilibrium":"⥮","upharpoonleft":"↿","upharpoonright":"↾","uplus":"⊎","UpperLeftArrow":"↖","UpperRightArrow":"↗","upsi":"υ","Upsi":"ϒ","upsih":"ϒ","Upsilon":"Υ","upsilon":"υ","UpTeeArrow":"↥","UpTee":"⊥","upuparrows":"⇈","urcorn":"⌝","urcorner":"⌝","urcrop":"⌎","Uring":"Ů","uring":"ů","urtri":"◹","Uscr":"𝒰","uscr":"𝓊","utdot":"⋰","Utilde":"Ũ","utilde":"ũ","utri":"▵","utrif":"▴","uuarr":"⇈","Uuml":"Ü","uuml":"ü","uwangle":"⦧","vangrt":"⦜","varepsilon":"ϵ","varkappa":"ϰ","varnothing":"∅","varphi":"ϕ","varpi":"ϖ","varpropto":"∝","varr":"↕","vArr":"⇕","varrho":"ϱ","varsigma":"ς","varsubsetneq":"⊊︀","varsubsetneqq":"⫋︀","varsupsetneq":"⊋︀","varsupsetneqq":"⫌︀","vartheta":"ϑ","vartriangleleft":"⊲","vartriangleright":"⊳","vBar":"⫨","Vbar":"⫫","vBarv":"⫩","Vcy":"В","vcy":"в","vdash":"⊢","vDash":"⊨","Vdash":"⊩","VDash":"⊫","Vdashl":"⫦","veebar":"⊻","vee":"∨","Vee":"⋁","veeeq":"≚","vellip":"⋮","verbar":"|","Verbar":"‖","vert":"|","Vert":"‖","VerticalBar":"∣","VerticalLine":"|","VerticalSeparator":"❘","VerticalTilde":"≀","VeryThinSpace":" ","Vfr":"𝔙","vfr":"𝔳","vltri":"⊲","vnsub":"⊂⃒","vnsup":"⊃⃒","Vopf":"𝕍","vopf":"𝕧","vprop":"∝","vrtri":"⊳","Vscr":"𝒱","vscr":"𝓋","vsubnE":"⫋︀","vsubne":"⊊︀","vsupnE":"⫌︀","vsupne":"⊋︀","Vvdash":"⊪","vzigzag":"⦚","Wcirc":"Ŵ","wcirc":"ŵ","wedbar":"⩟","wedge":"∧","Wedge":"⋀","wedgeq":"≙","weierp":"℘","Wfr":"𝔚","wfr":"𝔴","Wopf":"𝕎","wopf":"𝕨","wp":"℘","wr":"≀","wreath":"≀","Wscr":"𝒲","wscr":"𝓌","xcap":"⋂","xcirc":"◯","xcup":"⋃","xdtri":"▽","Xfr":"𝔛","xfr":"𝔵","xharr":"⟷","xhArr":"⟺","Xi":"Ξ","xi":"ξ","xlarr":"⟵","xlArr":"⟸","xmap":"⟼","xnis":"⋻","xodot":"⨀","Xopf":"𝕏","xopf":"𝕩","xoplus":"⨁","xotime":"⨂","xrarr":"⟶","xrArr":"⟹","Xscr":"𝒳","xscr":"𝓍","xsqcup":"⨆","xuplus":"⨄","xutri":"△","xvee":"⋁","xwedge":"⋀","Yacute":"Ý","yacute":"ý","YAcy":"Я","yacy":"я","Ycirc":"Ŷ","ycirc":"ŷ","Ycy":"Ы","ycy":"ы","yen":"¥","Yfr":"𝔜","yfr":"𝔶","YIcy":"Ї","yicy":"ї","Yopf":"𝕐","yopf":"𝕪","Yscr":"𝒴","yscr":"𝓎","YUcy":"Ю","yucy":"ю","yuml":"ÿ","Yuml":"Ÿ","Zacute":"Ź","zacute":"ź","Zcaron":"Ž","zcaron":"ž","Zcy":"З","zcy":"з","Zdot":"Ż","zdot":"ż","zeetrf":"ℨ","ZeroWidthSpace":"​","Zeta":"Ζ","zeta":"ζ","zfr":"𝔷","Zfr":"ℨ","ZHcy":"Ж","zhcy":"ж","zigrarr":"⇝","zopf":"𝕫","Zopf":"ℤ","Zscr":"𝒵","zscr":"𝓏","zwj":"‍","zwnj":"‌"}')},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t={};function n(e,r,i){var o,a,s,u,c,l="";for("string"!=typeof r&&(i=r,r=n.defaultChars),void 0===i&&(i=!0),c=function(e){var n,r,i=t[e];if(i)return i;for(i=t[e]=[],n=0;n<128;n++)r=String.fromCharCode(n),/^[0-9a-z]$/i.test(r)?i.push(r):i.push("%"+("0"+n.toString(16).toUpperCase()).slice(-2));for(n=0;n=55296&&s<=57343){if(s>=55296&&s<=56319&&o+1=56320&&u<=57343){l+=encodeURIComponent(e[o]+e[o+1]),o++;continue}l+="%EF%BF%BD"}else l+=encodeURIComponent(e[o]);return l}n.defaultChars=";/?:@&=+$,-_.!~*'()#",n.componentChars="-_.!~*'()",e.exports=n})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t={};function n(e,r){var i;return"string"!=typeof r&&(r=n.defaultChars),i=function(e){var n,r,i=t[e];if(i)return i;for(i=t[e]=[],n=0;n<128;n++)r=String.fromCharCode(n),i.push(r);for(n=0;n=55296&&u<=57343?"���":String.fromCharCode(u),t+=6):240==(248&r)&&t+91114111?c+="����":(u-=65536,c+=String.fromCharCode(55296+(u>>10),56320+(1023&u))),t+=9):c+="�";return c}))}n.defaultChars=";/?:@&=+$,#",n.componentChars="",e.exports=n})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports=function(e){var t="";return t+=e.protocol||"",t+=e.slashes?"//":"",t+=e.auth?e.auth+"@":"",e.hostname&&-1!==e.hostname.indexOf(":")?t+="["+e.hostname+"]":t+=e.hostname||"",t+=e.port?":"+e.port:"",t+=e.pathname||"",t+=e.search||"",t+=e.hash||""}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";function t(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var n=/^([a-z0-9.+-]+:)/i,r=/:[0-9]*$/,i=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,o=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),a=["'"].concat(o),s=["%","/","?",";","#"].concat(a),u=["/","?","#"],c=/^[+a-z0-9A-Z_-]{0,63}$/,l=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,f={javascript:!0,"javascript:":!0},p={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};t.prototype.parse=function(e,t){var r,o,a,d,h,m=e;if(m=m.trim(),!t&&1===e.split("#").length){var v=i.exec(m);if(v)return this.pathname=v[1],v[2]&&(this.search=v[2]),this}var y=n.exec(m);if(y&&(a=(y=y[0]).toLowerCase(),this.protocol=y,m=m.substr(y.length)),(t||y||m.match(/^\/\/[^@\/]+@[^@\/]+/))&&(!(h="//"===m.substr(0,2))||y&&f[y]||(m=m.substr(2),this.slashes=!0)),!f[y]&&(h||y&&!p[y])){var g,b,O=-1;for(r=0;r127?k+="x":k+=_[x];if(!k.match(c)){var C=w.slice(0,r),N=w.slice(r+1),D=_.match(l);D&&(C.push(D[1]),N.unshift(D[2])),N.length&&(m=N.join(".")+m),this.hostname=C.join(".");break}}}}this.hostname.length>255&&(this.hostname=""),T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}var j=m.indexOf("#");-1!==j&&(this.hash=m.substr(j),m=m.slice(0,j));var A=m.indexOf("?");return-1!==A&&(this.search=m.substr(A),m=m.slice(0,A)),m&&(this.pathname=m),p[a]&&this.hostname&&!this.pathname&&(this.pathname=""),this},t.prototype.parseHost=function(e){var t=r.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)},e.exports=function(e,n){if(e&&e instanceof t)return e;var r=new t;return r.parse(e,n),r}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";t.Any=n(65),t.Cc=n(66),t.Cf=n(125),t.P=n(43),t.Z=n(67)})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";t.parseLinkLabel=n(127),t.parseLinkDestination=n(128),t.parseLinkTitle=n(129)})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports=function(e,t,n){var r,i,o,a,s=-1,u=e.posMax,c=e.pos;for(e.pos=t+1,r=1;e.pos=r)return u;if(34!==(o=e.charCodeAt(n))&&39!==o&&40!==o)return u;for(n++,40===o&&(o=41);n"+i(e[t].content)+""},o.code_block=function(e,t,n,r,o){var a=e[t];return""+i(e[t].content)+"\n"},o.fence=function(e,t,n,o,a){var s,u,c,l,f=e[t],p=f.info?r(f.info).trim():"",d="";return p&&(d=p.split(/\s+/g)[0]),0===(s=n.highlight&&n.highlight(f.content,d)||i(f.content)).indexOf(""+s+"\n"):"
"+s+"
\n"},o.image=function(e,t,n,r,i){var o=e[t];return o.attrs[o.attrIndex("alt")][1]=i.renderInlineAsText(o.children,n,r),i.renderToken(e,t,n)},o.hardbreak=function(e,t,n){return n.xhtmlOut?"
\n":"
\n"},o.softbreak=function(e,t,n){return n.breaks?n.xhtmlOut?"
\n":"
\n":"\n"},o.text=function(e,t){return i(e[t].content)},o.html_block=function(e,t){return e[t].content},o.html_inline=function(e,t){return e[t].content},a.prototype.renderAttrs=function(e){var t,n,r;if(!e.attrs)return"";for(r="",t=0,n=e.attrs.length;t\n":">")},a.prototype.renderInline=function(e,t,n){for(var r,i="",o=this.rules,a=0,s=e.length;a/i.test(e)}e.exports=function(e){var n,i,o,a,s,u,c,l,f,p,d,h,m,v,y,g,b,O,E=e.tokens;if(e.md.options.linkify)for(i=0,o=E.length;i=0;n--)if("link_close"!==(u=a[n]).type){if("html_inline"===u.type&&(O=u.content,/^\s]/i.test(O)&&m>0&&m--,r(u.content)&&m++),!(m>0)&&"text"===u.type&&e.md.linkify.test(u.content)){for(f=u.content,b=e.md.linkify.match(f),c=[],h=u.level,d=0,l=0;ld&&((s=new e.Token("text","",0)).content=f.slice(d,p),s.level=h,c.push(s)),(s=new e.Token("link_open","a",1)).attrs=[["href",y]],s.level=h++,s.markup="linkify",s.info="auto",c.push(s),(s=new e.Token("text","",0)).content=g,s.level=h,c.push(s),(s=new e.Token("link_close","a",-1)).level=--h,s.markup="linkify",s.info="auto",c.push(s),d=b[l].lastIndex);d=0;t--)"text"!==(n=e[t]).type||i||(n.content=n.content.replace(r,o)),"link_open"===n.type&&"auto"===n.info&&i--,"link_close"===n.type&&"auto"===n.info&&i++}function s(e){var n,r,i=0;for(n=e.length-1;n>=0;n--)"text"!==(r=e[n]).type||i||t.test(r.content)&&(r.content=r.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---([^-]|$)/gm,"$1—$2").replace(/(^|\s)--(\s|$)/gm,"$1–$2").replace(/(^|[^-\s])--([^-\s]|$)/gm,"$1–$2")),"link_open"===r.type&&"auto"===r.info&&i--,"link_close"===r.type&&"auto"===r.info&&i++}e.exports=function(e){var r;if(e.md.options.typographer)for(r=e.tokens.length-1;r>=0;r--)"inline"===e.tokens[r].type&&(n.test(e.tokens[r].content)&&a(e.tokens[r].children),t.test(e.tokens[r].content)&&s(e.tokens[r].children))}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t=n(10).isWhiteSpace,r=n(10).isPunctChar,i=n(10).isMdAsciiPunct,o=/['"]/,a=/['"]/g,s="’";function u(e,t,n){return e.substr(0,t)+n+e.substr(t+1)}function c(e,n){var o,c,l,f,p,d,h,m,v,y,g,b,O,E,T,w,_,k,x,S,C;for(x=[],o=0;o=0&&!(x[_].level<=h);_--);if(x.length=_+1,"text"===c.type){p=0,d=(l=c.content).length;e:for(;p=0)v=l.charCodeAt(f.index-1);else for(_=o-1;_>=0&&"softbreak"!==e[_].type&&"hardbreak"!==e[_].type;_--)if("text"===e[_].type){v=e[_].content.charCodeAt(e[_].content.length-1);break}if(y=32,p=48&&v<=57&&(w=T=!1),T&&w&&(T=!1,w=b),T||w){if(w)for(_=x.length-1;_>=0&&(m=x[_],!(x[_].level=0;t--)"inline"===e.tokens[t].type&&o.test(e.tokens[t].content)&&c(e.tokens[t].children,e)}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t=n(45);function r(e,t,n){this.src=e,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=t}r.prototype.Token=t,e.exports=r})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t=n(44),r=[["table",n(140),["paragraph","reference"]],["code",n(141)],["fence",n(142),["paragraph","reference","blockquote","list"]],["blockquote",n(143),["paragraph","reference","blockquote","list"]],["hr",n(144),["paragraph","reference","blockquote","list"]],["list",n(145),["paragraph","reference","blockquote"]],["reference",n(146)],["heading",n(147),["paragraph","reference","blockquote"]],["lheading",n(148)],["html_block",n(149),["paragraph","reference","blockquote"]],["paragraph",n(151)]];function i(){this.ruler=new t;for(var e=0;e=n))&&!(e.sCount[a]=u){e.line=n;break}for(r=0;ro)return!1;if(f=n+1,e.sCount[f]=4)return!1;if((c=e.bMarks[f]+e.tShift[f])>=e.eMarks[f])return!1;if(124!==(s=e.src.charCodeAt(c++))&&45!==s&&58!==s)return!1;for(;c=4)return!1;if((d=(p=i(u.replace(/^\||\|$/g,""))).length)>m.length)return!1;if(a)return!0;for((h=e.push("table_open","table",1)).map=y=[n,0],(h=e.push("thead_open","thead",1)).map=[n,n+1],(h=e.push("tr_open","tr",1)).map=[n,n+1],l=0;l=4);f++){for(p=i(u.replace(/^\||\|$/g,"")),h=e.push("tr_open","tr",1),l=0;l=4))break;i=++r}return e.line=i,(o=e.push("code_block","code",0)).content=e.getLines(t,i,4+e.blkIndent,!0),o.map=[t,e.line],!0}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports=function(e,t,n,r){var i,o,a,s,u,c,l,f=!1,p=e.bMarks[t]+e.tShift[t],d=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;if(p+3>d)return!1;if(126!==(i=e.src.charCodeAt(p))&&96!==i)return!1;if(u=p,(o=(p=e.skipChars(p,i))-u)<3)return!1;if(l=e.src.slice(u,p),a=e.src.slice(p,d),96===i&&a.indexOf(String.fromCharCode(i))>=0)return!1;if(r)return!0;for(s=t;!(++s>=n||(p=u=e.bMarks[s]+e.tShift[s])<(d=e.eMarks[s])&&e.sCount[s]=4||(p=e.skipChars(p,i))-u=4)return!1;if(62!==e.src.charCodeAt(x++))return!1;if(i)return!0;for(u=d=e.sCount[n]+x-(e.bMarks[n]+e.tShift[n]),32===e.src.charCodeAt(x)?(x++,u++,d++,o=!1,O=!0):9===e.src.charCodeAt(x)?(O=!0,(e.bsCount[n]+d)%4==3?(x++,u++,d++,o=!1):o=!0):O=!1,h=[e.bMarks[n]],e.bMarks[n]=x;x=S,g=[e.sCount[n]],e.sCount[n]=d-u,b=[e.tShift[n]],e.tShift[n]=x-e.bMarks[n],T=e.md.block.ruler.getRules("blockquote"),y=e.parentType,e.parentType="blockquote",_=!1,p=n+1;p=(S=e.eMarks[p])));p++)if(62!==e.src.charCodeAt(x++)||_){if(l)break;for(E=!1,s=0,c=T.length;s=S,m.push(e.bsCount[p]),e.bsCount[p]=e.sCount[p]+1+(O?1:0),g.push(e.sCount[p]),e.sCount[p]=d-u,b.push(e.tShift[p]),e.tShift[p]=x-e.bMarks[p]}for(v=e.blkIndent,e.blkIndent=0,(w=e.push("blockquote_open","blockquote",1)).markup=">",w.map=f=[n,0],e.md.block.tokenize(e,n,p),(w=e.push("blockquote_close","blockquote",-1)).markup=">",e.lineMax=k,e.parentType=y,f[1]=e.line,s=0;s=4)return!1;if(42!==(o=e.src.charCodeAt(c++))&&45!==o&&95!==o)return!1;for(a=1;c=a)return-1;if((r=e.src.charCodeAt(o++))<48||r>57)return-1;for(;;){if(o>=a)return-1;if(!((r=e.src.charCodeAt(o++))>=48&&r<=57)){if(41===r||46===r)break;return-1}if(o-i>=10)return-1}return o=4)return!1;if(e.listIndent>=0&&e.sCount[t]-e.listIndent>=4&&e.sCount[t]=e.blkIndent&&(I=!0),(C=i(e,t))>=0){if(p=!0,D=e.bMarks[t]+e.tShift[t],g=Number(e.src.substr(D,C-D-1)),I&&1!==g)return!1}else{if(!((C=r(e,t))>=0))return!1;p=!1}if(I&&e.skipSpaces(C)>=e.eMarks[t])return!1;if(y=e.src.charCodeAt(C-1),o)return!0;for(v=e.tokens.length,p?(L=e.push("ordered_list_open","ol",1),1!==g&&(L.attrs=[["start",g]])):L=e.push("bullet_list_open","ul",1),L.map=m=[t,0],L.markup=String.fromCharCode(y),O=t,N=!1,A=e.md.block.ruler.getRules("list"),w=e.parentType,e.parentType="list";O=b?1:E-f)>4&&(l=1),c=f+l,(L=e.push("list_item_open","li",1)).markup=String.fromCharCode(y),L.map=d=[t,0],x=e.tight,k=e.tShift[t],_=e.sCount[t],T=e.listIndent,e.listIndent=e.blkIndent,e.blkIndent=c,e.tight=!0,e.tShift[t]=s-e.bMarks[t],e.sCount[t]=E,s>=b&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,t,n,!0),e.tight&&!N||(F=!1),N=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=T,e.tShift[t]=k,e.sCount[t]=_,e.tight=x,(L=e.push("list_item_close","li",-1)).markup=String.fromCharCode(y),O=t=e.line,d[1]=O,s=e.bMarks[t],O>=n)break;if(e.sCount[O]=4)break;for(j=!1,u=0,h=A.length;u=4)return!1;if(91!==e.src.charCodeAt(w))return!1;for(;++w<_;)if(93===e.src.charCodeAt(w)&&92!==e.src.charCodeAt(w-1)){if(w+1===_)return!1;if(58!==e.src.charCodeAt(w+1))return!1;break}for(c=e.lineMax,O=e.md.block.ruler.getRules("reference"),m=e.parentType,e.parentType="reference";k3||e.sCount[k]<0)){for(b=!1,f=0,p=O.length;f=4)return!1;if(35!==(o=e.src.charCodeAt(c))||c>=l)return!1;for(a=1,o=e.src.charCodeAt(++c);35===o&&c6||cc&&t(e.src.charCodeAt(s-1))&&(l=s),e.line=n+1,(u=e.push("heading_open","h"+String(a),1)).markup="########".slice(0,a),u.map=[n,e.line],(u=e.push("inline","",0)).content=e.src.slice(c,l).trim(),u.map=[n,e.line],u.children=[],(u=e.push("heading_close","h"+String(a),-1)).markup="########".slice(0,a),0))}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports=function(e,t,n){var r,i,o,a,s,u,c,l,f,p,d=t+1,h=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(p=e.parentType,e.parentType="paragraph";d3)){if(e.sCount[d]>=e.blkIndent&&(u=e.bMarks[d]+e.tShift[d])<(c=e.eMarks[d])&&(45===(f=e.src.charCodeAt(u))||61===f)&&(u=e.skipChars(u,f),(u=e.skipSpaces(u))>=c)){l=61===f?1:2;break}if(!(e.sCount[d]<0)){for(i=!1,o=0,a=h.length;o|$))/i,/<\/(script|pre|style)>/i,!0],[/^/,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp("^|$))","i"),/^$/,!0],[new RegExp(r.source+"\\s*$"),/^$/,!1]];e.exports=function(e,t,n,r){var o,a,s,u,c=e.bMarks[t]+e.tShift[t],l=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;if(!e.md.options.html)return!1;if(60!==e.src.charCodeAt(c))return!1;for(u=e.src.slice(c,l),o=0;o3||e.sCount[u]<0)){for(r=!1,i=0,o=c.length;i0&&this.level++,this.tokens.push(i),i},i.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]},i.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;et;)if(!r(this.src.charCodeAt(--e)))return e+1;return e},i.prototype.skipChars=function(e,t){for(var n=this.src.length;en;)if(t!==this.src.charCodeAt(--e))return e+1;return e},i.prototype.getLines=function(e,t,n,i){var o,a,s,u,c,l,f,p=e;if(e>=t)return"";for(l=new Array(t-e),o=0;pn?new Array(a-n+1).join(" ")+this.src.slice(u,c):this.src.slice(u,c)}return l.join("")},i.prototype.Token=t,e.exports=i})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t=n(44),r=[["text",n(154)],["newline",n(155)],["escape",n(156)],["backticks",n(157)],["strikethrough",n(69).tokenize],["emphasis",n(70).tokenize],["link",n(158)],["image",n(159)],["autolink",n(160)],["html_inline",n(161)],["entity",n(162)]],i=[["balance_pairs",n(163)],["strikethrough",n(69).postProcess],["emphasis",n(70).postProcess],["text_collapse",n(164)]];function o(){var e;for(this.ruler=new t,e=0;e=o)break}else e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()},o.prototype.parse=function(e,t,n,r){var i,o,a,s=new this.State(e,t,n,r);for(this.tokenize(s),a=(o=this.ruler2.getRules("")).length,i=0;i=0&&32===e.pending.charCodeAt(r)?r>=1&&32===e.pending.charCodeAt(r-1)?(e.pending=e.pending.replace(/ +$/,""),e.push("hardbreak","br",0)):(e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0)):e.push("softbreak","br",0)),o++;o?@[]^_`{|}~-".split("").forEach((function(e){r[e.charCodeAt(0)]=1})),e.exports=function(e,n){var i,o=e.pos,a=e.posMax;if(92!==e.src.charCodeAt(o))return!1;if(++o=m)return!1;for(v=c,(l=e.md.helpers.parseLinkDestination(e.src,c,e.posMax)).ok&&(d=e.md.normalizeLink(l.str),e.md.validateLink(d)?c=l.pos:d=""),v=c;c=m||41!==e.src.charCodeAt(c))&&(y=!0),c++}if(y){if(void 0===e.env.references)return!1;if(c=0?a=e.src.slice(v,c++):c=s+1):c=s+1,a||(a=e.src.slice(u,s)),!(f=e.env.references[t(a)]))return e.pos=h,!1;d=f.href,p=f.title}return n||(e.pos=u,e.posMax=s,e.push("link_open","a",1).attrs=i=[["href",d]],p&&i.push(["title",p]),e.md.inline.tokenize(e),e.push("link_close","a",-1)),e.pos=c,e.posMax=m,!0}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t=n(10).normalizeReference,r=n(10).isSpace;e.exports=function(e,n){var i,o,a,s,u,c,l,f,p,d,h,m,v,y="",g=e.pos,b=e.posMax;if(33!==e.src.charCodeAt(e.pos))return!1;if(91!==e.src.charCodeAt(e.pos+1))return!1;if(c=e.pos+2,(u=e.md.helpers.parseLinkLabel(e,e.pos+1,!1))<0)return!1;if((l=u+1)=b)return!1;for(v=l,(p=e.md.helpers.parseLinkDestination(e.src,l,e.posMax)).ok&&(y=e.md.normalizeLink(p.str),e.md.validateLink(y)?l=p.pos:y=""),v=l;l=b||41!==e.src.charCodeAt(l))return e.pos=g,!1;l++}else{if(void 0===e.env.references)return!1;if(l=0?s=e.src.slice(v,l++):l=u+1):l=u+1,s||(s=e.src.slice(c,u)),!(f=e.env.references[t(s)]))return e.pos=g,!1;y=f.href,d=f.title}return n||(a=e.src.slice(c,u),e.md.inline.parse(a,e.md,e.env,m=[]),(h=e.push("image","img",0)).attrs=i=[["src",y],["alt",""]],h.children=m,h.content=a,d&&i.push(["title",d])),e.pos=l,e.posMax=b,!0}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t=/^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/,n=/^<([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)>/;e.exports=function(e,r){var i,o,a,s,u,c,l=e.pos;return!(60!==e.src.charCodeAt(l)||(i=e.src.slice(l)).indexOf(">")<0||(n.test(i)?(s=(o=i.match(n))[0].slice(1,-1),u=e.md.normalizeLink(s),!e.md.validateLink(u)||(r||((c=e.push("link_open","a",1)).attrs=[["href",u]],c.markup="autolink",c.info="auto",(c=e.push("text","",0)).content=e.md.normalizeLinkText(s),(c=e.push("link_close","a",-1)).markup="autolink",c.info="auto"),e.pos+=o[0].length,0)):!t.test(i)||(s=(a=i.match(t))[0].slice(1,-1),u=e.md.normalizeLink("mailto:"+s),!e.md.validateLink(u)||(r||((c=e.push("link_open","a",1)).attrs=[["href",u]],c.markup="autolink",c.info="auto",(c=e.push("text","",0)).content=e.md.normalizeLinkText(s),(c=e.push("link_close","a",-1)).markup="autolink",c.info="auto"),e.pos+=a[0].length,0))))}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t=n(68).HTML_TAG_RE;e.exports=function(e,n){var r,i,o,a=e.pos;return!(!e.md.options.html||(o=e.posMax,60!==e.src.charCodeAt(a)||a+2>=o||33!==(r=e.src.charCodeAt(a+1))&&63!==r&&47!==r&&!function(e){var t=32|e;return t>=97&&t<=122}(r)||!(i=e.src.slice(a).match(t))||(n||(e.push("html_inline","",0).content=e.src.slice(a,a+i[0].length)),e.pos+=i[0].length,0)))}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var t=n(63),r=n(10).has,i=n(10).isValidEntityCode,o=n(10).fromCodePoint,a=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,s=/^&([a-z][a-z0-9]{1,31});/i;e.exports=function(e,n){var u,c,l=e.pos,f=e.posMax;if(38!==e.src.charCodeAt(l))return!1;if(l+1a;r-=o.jump+1)if((o=t[r]).marker===i.marker&&(-1===s&&(s=r),o.open&&o.end<0&&o.level===i.level&&(u=!1,(o.close||i.open)&&(o.length+i.length)%3==0&&(o.length%3==0&&i.length%3==0||(u=!0)),!u))){c=r>0&&!t[r-1].open?t[r-1].jump+1:0,i.jump=n-r+c,i.open=!1,o.end=n,o.jump=c,o.close=!1,s=-1;break}-1!==s&&(l[i.marker][(i.length||0)%3]=s)}}e.exports=function(e){var n,r=e.tokens_meta,i=e.tokens_meta.length;for(t(0,e.delimiters),n=0;n0&&r++,"text"===i[t].type&&t+10&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],o={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(i),this.tokens_meta.push(o),i},a.prototype.scanDelims=function(e,t){var n,a,s,u,c,l,f,p,d,h=e,m=!0,v=!0,y=this.posMax,g=this.src.charCodeAt(e);for(n=e>0?this.src.charCodeAt(e-1):32;h=3&&":"===e[t-3]?0:t>=3&&"/"===e[t-3]?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){var r=e.slice(t);return n.re.mailto||(n.re.mailto=new RegExp("^"+n.re.src_email_name+"@"+n.re.src_host_strict,"i")),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},u="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",c="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function l(e){var t=e.re=n(167)(e.__opts__),a=e.__tlds__.slice();function s(e){return e.replace("%TLDS%",t.src_tlds)}e.onCompile(),e.__tlds_replaced__||a.push(u),a.push(t.src_xn),t.src_tlds=a.join("|"),t.email_fuzzy=RegExp(s(t.tpl_email_fuzzy),"i"),t.link_fuzzy=RegExp(s(t.tpl_link_fuzzy),"i"),t.link_no_ip_fuzzy=RegExp(s(t.tpl_link_no_ip_fuzzy),"i"),t.host_fuzzy_test=RegExp(s(t.tpl_host_fuzzy_test),"i");var c=[];function l(e,t){throw new Error('(LinkifyIt) Invalid schema "'+e+'": '+t)}e.__compiled__={},Object.keys(e.__schemas__).forEach((function(t){var n=e.__schemas__[t];if(null!==n){var o={validate:null,link:null};if(e.__compiled__[t]=o,"[object Object]"===r(n))return function(e){return"[object RegExp]"===r(e)}(n.validate)?o.validate=function(e){return function(t,n){var r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}(n.validate):i(n.validate)?o.validate=n.validate:l(t,n),void(i(n.normalize)?o.normalize=n.normalize:n.normalize?l(t,n):o.normalize=function(e,t){t.normalize(e)});!function(e){return"[object String]"===r(e)}(n)?l(t,n):c.push(t)}})),c.forEach((function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)})),e.__compiled__[""]={validate:null,normalize:function(e,t){t.normalize(e)}};var f=Object.keys(e.__compiled__).filter((function(t){return t.length>0&&e.__compiled__[t]})).map(o).join("|");e.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+f+")","i"),e.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+f+")","ig"),e.re.pretest=RegExp("("+e.re.schema_test.source+")|("+e.re.host_fuzzy_test.source+")|@","i"),function(e){e.__index__=-1,e.__text_cache__=""}(e)}function f(e,t){var n=e.__index__,r=e.__last_index__,i=e.__text_cache__.slice(n,r);this.schema=e.__schema__.toLowerCase(),this.index=n+t,this.lastIndex=r+t,this.raw=i,this.text=i,this.url=i}function p(e,t){var n=new f(e,t);return e.__compiled__[n.schema].normalize(n,e),n}function d(e,n){if(!(this instanceof d))return new d(e,n);var r;n||(r=e,Object.keys(r||{}).reduce((function(e,t){return e||a.hasOwnProperty(t)}),!1)&&(n=e,e={})),this.__opts__=t({},a,n),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=t({},s,e),this.__compiled__={},this.__tlds__=c,this.__tlds_replaced__=!1,this.re={},l(this)}d.prototype.add=function(e,t){return this.__schemas__[e]=t,l(this),this},d.prototype.set=function(e){return this.__opts__=t(this.__opts__,e),this},d.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,n,r,i,o,a,s,u;if(this.re.schema_test.test(e))for((s=this.re.schema_search).lastIndex=0;null!==(t=s.exec(e));)if(i=this.testSchemaAt(e,t[2],s.lastIndex)){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+i;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(u=e.search(this.re.host_fuzzy_test))>=0&&(this.__index__<0||u=0&&null!==(r=e.match(this.re.email_fuzzy))&&(o=r.index+r[1].length,a=r.index+r[0].length,(this.__index__<0||othis.__last_index__)&&(this.__schema__="mailto:",this.__index__=o,this.__last_index__=a)),this.__index__>=0},d.prototype.pretest=function(e){return this.re.pretest.test(e)},d.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},d.prototype.match=function(e){var t=0,n=[];this.__index__>=0&&this.__text_cache__===e&&(n.push(p(this,t)),t=this.__last_index__);for(var r=t?e.slice(t):e;this.test(r);)n.push(p(this,t)),r=r.slice(this.__last_index__),t+=this.__last_index__;return n.length?n:null},d.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter((function(e,t,n){return e!==n[t-1]})).reverse(),l(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,l(this),this)},d.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),"mailto:"!==e.schema||/^mailto:/i.test(e.url)||(e.url="mailto:"+e.url)},d.prototype.onCompile=function(){},e.exports=d})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports=function(e){var t={};return t.src_Any=n(65).source,t.src_Cc=n(66).source,t.src_Z=n(67).source,t.src_P=n(43).source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join("|"),t.src_ZCc=[t.src_Z,t.src_Cc].join("|"),t.src_pseudo_letter="(?:(?![><|]|"+t.src_ZPCc+")"+t.src_Any+")",t.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",t.src_auth="(?:(?:(?!"+t.src_ZCc+"|[@/\\[\\]()]).)+@)?",t.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",t.src_host_terminator="(?=$|[><|]|"+t.src_ZPCc+")(?!-|_|:\\d|\\.-|\\.(?!$|"+t.src_ZPCc+"))",t.src_path="(?:[/?#](?:(?!"+t.src_ZCc+"|[><|]|[()[\\]{}.,\"'?!\\-]).|\\[(?:(?!"+t.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+t.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+t.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+t.src_ZCc+'|["]).)+\\"|\\\'(?:(?!'+t.src_ZCc+"|[']).)+\\'|\\'(?="+t.src_pseudo_letter+"|[-]).|\\.{2,4}[a-zA-Z0-9%/]|\\.(?!"+t.src_ZCc+"|[.]).|"+(e&&e["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+"\\,(?!"+t.src_ZCc+").|\\!(?!"+t.src_ZCc+"|[!]).|\\?(?!"+t.src_ZCc+"|[?]).)+|\\/)?",t.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',t.src_xn="xn--[a-z0-9\\-]{1,59}",t.src_domain_root="(?:"+t.src_xn+"|"+t.src_pseudo_letter+"{1,63})",t.src_domain="(?:"+t.src_xn+"|(?:"+t.src_pseudo_letter+")|(?:"+t.src_pseudo_letter+"(?:-|"+t.src_pseudo_letter+"){0,61}"+t.src_pseudo_letter+"))",t.src_host="(?:(?:(?:(?:"+t.src_domain+")\\.)*"+t.src_domain+"))",t.tpl_host_fuzzy="(?:"+t.src_ip4+"|(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%)))",t.tpl_host_no_ip_fuzzy="(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%))",t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+t.src_ZPCc+"|>|$))",t.tpl_email_fuzzy='(^|[><|]|"|\\(|'+t.src_ZCc+")("+t.src_email_name+"@"+t.tpl_host_fuzzy_strict+")",t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+")",t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+")",t}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){(function(e,r){var i,o,a,s;s=function(){"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)} +/*! https://mths.be/punycode v1.4.1 by @mathias */!function(o){var s="object"==i(t)&&t&&!t.nodeType&&t,u="object"==i(e)&&e&&!e.nodeType&&e,c="object"==(void 0===r?"undefined":i(r))&&r;c.global!==c&&c.window!==c&&c.self!==c||(o=c);var l,f,p=2147483647,d=36,h=1,m=26,v=38,y=700,g=72,b=128,O="-",E=/^xn--/,T=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=d-h,x=Math.floor,S=String.fromCharCode;function C(e){throw new RangeError(_[e])}function N(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function D(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+N((e=e.replace(w,".")).split("."),t).join(".")}function j(e){for(var t,n,r=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=S((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=S(e)})).join("")}function L(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function I(e,t,n){var r=0;for(e=n?x(e/y):e>>1,e+=x(e/t);e>k*m>>1;r+=d)e=x(e/k);return x(r+(k+1)*e/(e+v))}function F(e){var t,n,r,i,o,a,s,u,c,l,f,v=[],y=e.length,E=0,T=b,w=g;for((n=e.lastIndexOf(O))<0&&(n=0),r=0;r=128&&C("not-basic"),v.push(e.charCodeAt(r));for(i=n>0?n+1:0;i=y&&C("invalid-input"),((u=(f=e.charCodeAt(i++))-48<10?f-22:f-65<26?f-65:f-97<26?f-97:d)>=d||u>x((p-E)/a))&&C("overflow"),E+=u*a,!(u<(c=s<=w?h:s>=w+m?m:s-w));s+=d)a>x(p/(l=d-c))&&C("overflow"),a*=l;w=I(E-o,t=v.length+1,0==o),x(E/t)>p-T&&C("overflow"),T+=x(E/t),E%=t,v.splice(E++,0,T)}return A(v)}function R(e){var t,n,r,i,o,a,s,u,c,l,f,v,y,E,T,w=[];for(v=(e=j(e)).length,t=b,n=0,o=g,a=0;a=t&&fx((p-n)/(y=r+1))&&C("overflow"),n+=(s-t)*y,t=s,a=0;ap&&C("overflow"),f==t){for(u=n,c=d;!(u<(l=c<=o?h:c>=o+m?m:c-o));c+=d)T=u-l,E=d-l,w.push(S(L(l+T%E,0))),u=x(T/E);w.push(S(L(u,0))),o=I(n,y,r==i),n=0,++r}++n,++t}return w.join("")}if(l={version:"1.4.1",ucs2:{decode:j,encode:A},decode:F,encode:R,toASCII:function(e){return D(e,(function(e){return T.test(e)?"xn--"+R(e):e}))},toUnicode:function(e){return D(e,(function(e){return E.test(e)?F(e.slice(4).toLowerCase()):e}))}},"object"==i(n(71))&&n(71))void 0===(a=function(){return l}.call(t,n,t,e))||(e.exports=a);else if(s&&u)if(e.exports==s)u.exports=l;else for(f in l)l.hasOwnProperty(f)&&(s[f]=l[f]);else o.punycode=l}(void 0)},o=[],void 0===(a="function"==typeof(i=s)?i.apply(t,o):i)||(e.exports=a)}).call(this,n(21)(e),n(41))},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","text_collapse"]}}}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";e.exports={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","text_collapse"]}}}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t],void 0===(o="function"==typeof(r=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.normalizeWhitespace=function(e){return e.replace(n," ")},e.invalidCharacters=void 0;var t=Array.from({length:11},(function(e,t){return String.fromCharCode(8192+t)})).concat(["\u2028","\u2029"," "," "]);e.invalidCharacters=t;var n=new RegExp("["+t.join("")+"]","g")})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){(function(e){var r,i,o;i=[],r=function(){"use strict";function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(s){"object"==a(t)&&"object"==a(e)?s(n(6)):(i=[n(6)],void 0===(o="function"==typeof(r=s)?r.apply(t,i):r)||(e.exports=o))}((function(e){var t={},n=/[^\s\u00a0]/,r=e.Pos;function i(e){var t=e.search(n);return-1==t?0:t}function o(e,t){var n=e.getMode();return!1!==n.useInnerComments&&n.innerMode?e.getModeAt(t):n}e.commands.toggleComment=function(e){e.toggleComment()},e.defineExtension("toggleComment",(function(e){e||(e=t);for(var n=1/0,i=this.listSelections(),o=null,a=i.length-1;a>=0;a--){var s=i[a].from(),u=i[a].to();s.line>=n||(u.line>=n&&(u=r(n,0)),n=s.line,null==o?this.uncomment(s,u,e)?o="un":(this.lineComment(s,u,e),o="line"):"un"==o?this.uncomment(s,u,e):this.lineComment(s,u,e))}})),e.defineExtension("lineComment",(function(e,a,s){s||(s=t);var u=this,c=o(u,e),l=u.getLine(e.line);if(null!=l&&(f=e,p=l,!/\bstring\b/.test(u.getTokenTypeAt(r(f.line,0)))||/^[\'\"\`]/.test(p))){var f,p,d=s.lineComment||c.lineComment;if(d){var h=Math.min(0!=a.ch||a.line==e.line?a.line+1:a.line,u.lastLine()+1),m=null==s.padding?" ":s.padding,v=s.commentBlankLines||e.line==a.line;u.operation((function(){if(s.indent){for(var t=null,o=e.line;oa.length)&&(t=a)}for(o=e.line;of||s.operation((function(){if(0!=a.fullLines){var t=n.test(s.getLine(f));s.replaceRange(p+l,r(f)),s.replaceRange(c+p,r(e.line,0));var o=a.blockCommentLead||u.blockCommentLead;if(null!=o)for(var d=e.line+1;d<=f;++d)(d!=f||t)&&s.replaceRange(o+p,r(d,0))}else s.replaceRange(l,i),s.replaceRange(c,e)}))}}else(a.lineComment||u.lineComment)&&0!=a.fullLines&&s.lineComment(e,i,a)})),e.defineExtension("uncomment",(function(e,i,a){a||(a=t);var s,u=this,c=o(u,e),l=Math.min(0!=i.ch||i.line==e.line?i.line:i.line-1,u.lastLine()),f=Math.min(e.line,l),p=a.lineComment||c.lineComment,d=[],h=null==a.padding?" ":a.padding;e:if(p){for(var m=f;m<=l;++m){var v=u.getLine(m),y=v.indexOf(p);if(y>-1&&!/comment/.test(u.getTokenTypeAt(r(m,y+1)))&&(y=-1),-1==y&&n.test(v))break e;if(y>-1&&n.test(v.slice(0,y)))break e;d.push(v)}if(u.operation((function(){for(var e=f;e<=l;++e){var t=d[e-f],n=t.indexOf(p),i=n+p.length;n<0||(t.slice(i,i+h.length)==h&&(i+=h.length),s=!0,u.replaceRange("",r(e,n),r(e,i)))}})),s)return!0}var g=a.blockCommentStart||c.blockCommentStart,b=a.blockCommentEnd||c.blockCommentEnd;if(!g||!b)return!1;var O=a.blockCommentLead||c.blockCommentLead,E=u.getLine(f),T=E.indexOf(g);if(-1==T)return!1;var w=l==f?E:u.getLine(l),_=w.indexOf(b,l==f?T+g.length:0),k=r(f,T+1),x=r(l,_+1);if(-1==_||!/comment/.test(u.getTokenTypeAt(k))||!/comment/.test(u.getTokenTypeAt(x))||u.getRange(k,x,"\n").indexOf(b)>-1)return!1;var S=E.lastIndexOf(g,e.ch),C=-1==S?-1:E.slice(0,e.ch).indexOf(b,S+g.length);if(-1!=S&&-1!=C&&C+b.length!=e.ch)return!1;C=w.indexOf(b,i.ch);var N=w.slice(i.ch).lastIndexOf(g,C-i.ch);return S=-1==C||-1==N?-1:i.ch+N,(-1==C||-1==S||S==i.ch)&&(u.operation((function(){u.replaceRange("",r(l,_-(h&&w.slice(_-h.length,_)==h?h.length:0)),r(l,_+b.length));var e=T+g.length;if(h&&E.slice(e,e+h.length)==h&&(e+=h.length),u.replaceRange("",r(f,T),r(f,e)),O)for(var t=f+1;t<=l;++t){var i=u.getLine(t),o=i.indexOf(O);if(-1!=o&&!n.test(i.slice(0,o))){var a=o+O.length;h&&i.slice(a,a+h.length)==h&&(a+=h.length),u.replaceRange("",r(t,o),r(t,a))}}})),!0)}))}))},void 0===(o="function"==typeof r?r.apply(t,i):r)||(e.exports=o)}).call(this,n(21)(e))},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var e,t=(e=n(6))&&e.__esModule?e:{default:e},r=n(78);t.default.registerHelper("hint","graphql",(function(e,n){var i=n.schema;if(i){var o=e.getCursor(),a=e.getTokenAt(o),s=(0,r.getAutocompleteSuggestions)(i,e.getValue(),o,a),u=null!==a.type&&/"|\w/.test(a.string[0])?a.start:a.end,c={list:s.map((function(e){return{text:e.label,type:i.getType(e.detail),description:e.documentation,isDeprecated:e.isDeprecated,deprecationReason:e.deprecationReason}})),from:{line:o.line,column:u},to:{line:o.line,column:a.end}};return c&&c.list&&c.list.length>0&&(c.from=t.default.Pos(c.from.line,c.from.column),c.to=t.default.Pos(c.to.line,c.to.column),t.default.signal(e,"hasCompletion",e,c,a)),c}}))})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t],void 0===(o="function"==typeof(r=function(e){"use strict";function t(e,t){for(var n=0;n1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=null,o=null;if("string"==typeof e){var a=new RegExp(e,r?"i":"g");o=a.test(n._sourceText.substr(n._pos,e.length)),i=e}else e instanceof RegExp&&(i=(o=n._sourceText.slice(n._pos).match(e))&&o[0]);return!(null==o||!("string"==typeof e||o instanceof Array&&n._sourceText.startsWith(o[0],n._pos)))&&(t&&(n._start=n._pos,i&&i.length&&(n._pos+=i.length)),o)},this.backUp=function(e){n._pos-=e},this.column=function(){return n._pos},this.indentation=function(){var e=n._sourceText.match(/\s*/),t=0;if(e&&0===e.length)for(var r=e[0],i=0;r.length>i;)9===r.charCodeAt(i)?t+=2:t++,i++;return t},this.current=function(){return n._sourceText.slice(n._start,n._pos)},this._start=0,this._pos=0,this._sourceText=t}var n,r,i;return n=e,(r=[{key:"_testNextCharacter",value:function(e){var t=this._sourceText.charAt(this._pos);return"string"==typeof e?t===e:e instanceof RegExp?e.test(t):e(t)}}])&&t(n.prototype,r),i&&t(n,i),e}();e.default=n})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(80)],void 0===(o="function"==typeof(r=function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){for(var n=Object.keys(t),r=0;r0&&void 0!==arguments[0]?arguments[0]:{eatWhitespace:function(e){return e.eatWhile(t.isIgnored)},lexRules:t.LexRules,parseRules:t.ParseRules,editorConfig:{}};return{startState:function(){var t={level:0,step:0,name:null,kind:null,type:null,rule:null,needsSeperator:!1,prevState:null};return a(e.parseRules,t,"Document"),t},token:function(t,n){return function(e,t,n){var r=n.lexRules,c=n.parseRules,f=n.eatWhitespace,p=n.editorConfig;if(t.rule&&0===t.rule.length?s(t):t.needsAdvance&&(t.needsAdvance=!1,u(t,!0)),e.sol()){var d=p&&p.tabSize||2;t.indentLevel=Math.floor(e.indentation()/d)}if(f(e))return"ws";var h=function(e,t){for(var n=Object.keys(e),r=0;r0&&v[v.length-1]=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),m(n)?r.showHidden=n:n&&t._extend(r,n),b(r.showHidden)&&(r.showHidden=!1),b(r.depth)&&(r.depth=2),b(r.colors)&&(r.colors=!1),b(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=c),f(r,e,r.depth)}function c(e,t){var n=u.styles[t];return n?"["+u.colors[n][0]+"m"+e+"["+u.colors[n][1]+"m":e}function l(e,t){return e}function f(e,n,r){if(e.customInspect&&n&&_(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return g(i)||(i=f(e,i,r)),i}var o=function(e,t){if(b(t))return e.stylize("undefined","undefined");if(g(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return y(t)?e.stylize(""+t,"number"):m(t)?e.stylize(""+t,"boolean"):v(t)?e.stylize("null","null"):void 0}(e,n);if(o)return o;var a=Object.keys(n),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(n)),w(n)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return p(n);if(0===a.length){if(_(n)){var u=n.name?": "+n.name:"";return e.stylize("[Function"+u+"]","special")}if(O(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(T(n))return e.stylize(Date.prototype.toString.call(n),"date");if(w(n))return p(n)}var c,l="",E=!1,k=["{","}"];return h(n)&&(E=!0,k=["[","]"]),_(n)&&(l=" [Function"+(n.name?": "+n.name:"")+"]"),O(n)&&(l=" "+RegExp.prototype.toString.call(n)),T(n)&&(l=" "+Date.prototype.toUTCString.call(n)),w(n)&&(l=" "+p(n)),0!==a.length||E&&0!=n.length?r<0?O(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),c=E?function(e,t,n,r,i){for(var o=[],a=0,s=t.length;a60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(c,l,k)):k[0]+l+k[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,n,r,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),N(r,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=v(n)?f(e,u.value,null):f(e,u.value,n-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),b(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function h(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function v(e){return null===e}function y(e){return"number"==typeof e}function g(e){return"string"==typeof e}function b(e){return void 0===e}function O(e){return E(e)&&"[object RegExp]"===k(e)}function E(t){return"object"===e(t)&&null!==t}function T(e){return E(e)&&"[object Date]"===k(e)}function w(e){return E(e)&&("[object Error]"===k(e)||e instanceof Error)}function _(e){return"function"==typeof e}function k(e){return Object.prototype.toString.call(e)}function x(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(b(a)&&(a=r.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(a)){var n=r.pid;s[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else s[e]=function(){};return s[e]},t.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=h,t.isBoolean=m,t.isNull=v,t.isNullOrUndefined=function(e){return null==e},t.isNumber=y,t.isString=g,t.isSymbol=function(t){return"symbol"===e(t)},t.isUndefined=b,t.isRegExp=O,t.isObject=E,t.isDate=T,t.isError=w,t.isFunction=_,t.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"===e(t)||void 0===t},t.isBuffer=n(183);var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function C(){var e=new Date,t=[x(e.getHours()),x(e.getMinutes()),x(e.getSeconds())].join(":");return[e.getDate(),S[e.getMonth()],t].join(" ")}function N(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",C(),t.format.apply(t,arguments))},t.inherits=n(184),t._extend=function(e,t){if(!t||!E(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};var D="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function j(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(D&&e[D]){var t;if("function"!=typeof(t=e[D]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,D,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),i=[],o=0;o3&&void 0!==arguments[3]?arguments[3]:{onClick:null},i=arguments.length>4?arguments[4]:void 0;if(n){var o,a=r.onClick;a?((o=document.createElement("a")).href="javascript:void 0",o.addEventListener("click",(function(e){a(i,e)}))):o=document.createElement("span"),o.className=n,o.appendChild(document.createTextNode(t)),e.appendChild(o)}else e.appendChild(document.createTextNode(t))}n(90),t.default.registerHelper("info","graphql",(function(e,t){if(t.schema&&e.state){var n=e.state,o=n.kind,p=n.step,d=(0,r.default)(t.schema,e.state);if("Field"===o&&0===p&&d.fieldDef||"AliasedField"===o&&2===p&&d.fieldDef){var h=document.createElement("div");return function(e,t,n){a(e,t,n),u(e,t,n,t.type)}(h,d,t),l(h,t,d.fieldDef),h}if("Directive"===o&&1===p&&d.directiveDef){var m=document.createElement("div");return s(m,d,t),l(m,t,d.directiveDef),m}if("Argument"===o&&0===p&&d.argDef){var v=document.createElement("div");return function(e,t,n){t.directiveDef?s(e,t,n):t.fieldDef&&a(e,t,n);var r=t.argDef.name;f(e,"("),f(e,r,"arg-name",n,(0,i.getArgumentReference)(t)),u(e,t,n,t.inputType),f(e,")")}(v,d,t),l(v,t,d.argDef),v}if("EnumValue"===o&&d.enumValue&&d.enumValue.description){var y=document.createElement("div");return function(e,t,n){var r=t.enumValue.name;c(e,t,n,t.inputType),f(e,"."),f(e,r,"enum-value",n,(0,i.getEnumValueReference)(t))}(y,d,t),l(y,t,d.enumValue),y}if("NamedType"===o&&d.type&&d.type.description){var g=document.createElement("div");return c(g,d,t,d.type),l(g,t,d.type),g}}}))})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var e=i(n(6)),t=i(n(87)),r=n(89);function i(e){return e&&e.__esModule?e:{default:e}}n(190),e.default.registerHelper("jump","graphql",(function(e,n){if(n.schema&&n.onClick&&e.state){var i=e.state,o=i.kind,a=i.step,s=(0,t.default)(n.schema,i);return"Field"===o&&0===a&&s.fieldDef||"AliasedField"===o&&2===a&&s.fieldDef?(0,r.getFieldReference)(s):"Directive"===o&&1===a&&s.directiveDef?(0,r.getDirectiveReference)(s):"Argument"===o&&0===a&&s.argDef?(0,r.getArgumentReference)(s):"EnumValue"===o&&s.enumValue?(0,r.getEnumValueReference)(s):"NamedType"===o&&s.type?(0,r.getTypeReference)(s):void 0}}))})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var e,t=(e=n(6))&&e.__esModule?e:{default:e};function r(e,t){var n=t.target||t.srcElement;if("SPAN"===n.nodeName){var r=n.getBoundingClientRect(),i={left:(r.left+r.right)/2,top:(r.top+r.bottom)/2};e.state.jump.cursor=i,e.state.jump.isHoldingModifier&&s(e)}}function i(e){e.state.jump.isHoldingModifier||!e.state.jump.cursor?e.state.jump.isHoldingModifier&&e.state.jump.marker&&u(e):e.state.jump.cursor=null}function o(e,n){if(!e.state.jump.isHoldingModifier&&n.key===(a?"Meta":"Control")){e.state.jump.isHoldingModifier=!0,e.state.jump.cursor&&s(e);var r=function(t){var n=e.state.jump.destination;n&&e.state.jump.options.onClick(n,t)},i=function(t,n){e.state.jump.destination&&(n.codemirrorIgnore=!0)};t.default.on(document,"keyup",(function o(a){a.code===n.code&&(e.state.jump.isHoldingModifier=!1,e.state.jump.marker&&u(e),t.default.off(document,"keyup",o),t.default.off(document,"click",r),e.off("mousedown",i))})),t.default.on(document,"click",r),e.on("mousedown",i)}}t.default.defineOption("jump",!1,(function(e,n,a){if(a&&a!==t.default.Init){var s=e.state.jump.onMouseOver;t.default.off(e.getWrapperElement(),"mouseover",s);var u=e.state.jump.onMouseOut;t.default.off(e.getWrapperElement(),"mouseout",u),t.default.off(document,"keydown",e.state.jump.onKeyDown),delete e.state.jump}if(n){var c=e.state.jump={options:n,onMouseOver:r.bind(null,e),onMouseOut:i.bind(null,e),onKeyDown:o.bind(null,e)};t.default.on(e.getWrapperElement(),"mouseover",c.onMouseOver),t.default.on(e.getWrapperElement(),"mouseout",c.onMouseOut),t.default.on(document,"keydown",c.onKeyDown)}}));var a="undefined"!=typeof navigator&&navigator&&-1!==navigator.appVersion.indexOf("Mac");function s(e){if(!e.state.jump.marker){var t=e.state.jump.cursor,n=e.coordsChar(t),r=e.getTokenAt(n,!0),i=e.state.jump.options,o=i.getDestination||e.getHelper(n,"jump");if(o){var a=o(r,i,e);if(a){var s=e.markText({line:n.line,ch:r.start},{line:n.line,ch:r.end},{className:"CodeMirror-jump-token"});e.state.jump.marker=s,e.state.jump.destination=a}}}}function u(e){var t=e.state.jump.marker;e.state.jump.marker=null,e.state.jump.destination=null,t.clear()}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var e,t=(e=n(6))&&e.__esModule?e:{default:e},r=n(35);function i(e,t){var n=e.levels;return(n&&0!==n.length?n[n.length-1]-(this.electricInput.test(t)?1:0):e.indentLevel)*this.config.indentUnit}t.default.defineMode("graphql",(function(e){var t=(0,r.onlineParser)({eatWhitespace:function(e){return e.eatWhile(r.isIgnored)},lexRules:r.LexRules,parseRules:r.ParseRules,editorConfig:{tabSize:e.tabSize}});return{config:e,startState:t.startState,token:t.token,indent:i,electricInput:/^\s*[})\]]/,fold:"brace",lineComment:"#",closeBrackets:{pairs:'()[]{}""',explode:"()[]{}"}}}))})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(14),n(16),n(72),n(46)],void 0===(o="function"==typeof(r=function(e,t,r,i,o){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t=65&&r<=90||!n.shiftKey&&r>=48&&r<=57||n.shiftKey&&189===r||n.shiftKey&&222===r)&&t.editor.execCommand("autocomplete")})),h(p(t),"_onEdit",(function(){t.ignoreChangeEvent||(t.cachedValue=t.editor.getValue(),t.props.onEdit&&t.props.onEdit(t.cachedValue))})),h(p(t),"_onHasCompletion",(function(e,n){(0,i.default)(e,n,t.props.onHintInformationRender)})),t.cachedValue=e.value||"",t}var a,u,m;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&d(e,t)}(r,e),a=r,(u=[{key:"componentDidMount",value:function(){var e=this,t=n(6);n(73),n(39),n(74),n(48),n(47),n(77),n(31),n(49),n(32),n(50),n(193),n(195),n(197),this.editor=t(this._node,{value:this.props.value||"",lineNumbers:!0,tabSize:2,mode:"graphql-variables",theme:this.props.editorTheme||"graphiql",keyMap:"sublime",autoCloseBrackets:!0,matchBrackets:!0,showCursorWhenSelecting:!0,readOnly:!!this.props.readOnly&&"nocursor",foldGutter:{minFoldSize:4},lint:{variableToType:this.props.variableToType},hintOptions:{variableToType:this.props.variableToType,closeOnUnfocus:!1,completeSingle:!1,container:this._node},gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],extraKeys:c({"Cmd-Space":function(){return e.editor.showHint({completeSingle:!1,container:e._node})},"Ctrl-Space":function(){return e.editor.showHint({completeSingle:!1,container:e._node})},"Alt-Space":function(){return e.editor.showHint({completeSingle:!1,container:e._node})},"Shift-Space":function(){return e.editor.showHint({completeSingle:!1,container:e._node})},"Cmd-Enter":function(){e.props.onRunQuery&&e.props.onRunQuery()},"Ctrl-Enter":function(){e.props.onRunQuery&&e.props.onRunQuery()},"Shift-Ctrl-P":function(){e.props.onPrettifyQuery&&e.props.onPrettifyQuery()},"Shift-Ctrl-M":function(){e.props.onMergeQuery&&e.props.onMergeQuery()}},o.default)}),this.editor.on("change",this._onEdit),this.editor.on("keyup",this._onKeyUp),this.editor.on("hasCompletion",this._onHasCompletion)}},{key:"componentDidUpdate",value:function(e){var t=n(6);if(this.ignoreChangeEvent=!0,this.props.variableToType!==e.variableToType&&(this.editor.options.lint.variableToType=this.props.variableToType,this.editor.options.hintOptions.variableToType=this.props.variableToType,t.signal(this.editor,"change",this.editor)),this.props.value!==e.value&&this.props.value!==this.cachedValue){var r=this.props.value||"";this.cachedValue=r,this.editor.setValue(r)}this.ignoreChangeEvent=!1}},{key:"componentWillUnmount",value:function(){this.editor.off("change",this._onEdit),this.editor.off("keyup",this._onKeyUp),this.editor.off("hasCompletion",this._onHasCompletion),this.editor=null}},{key:"render",value:function(){var e=this;return t.default.createElement("div",{className:"codemirrorWrap",ref:function(t){e._node=t}})}},{key:"getCodeMirror",value:function(){return this.editor}},{key:"getClientHeight",value:function(){return this._node&&this._node.clientHeight}}])&&l(a.prototype,u),m&&l(a,m),r}(t.default.Component);e.VariableEditor=m,h(m,"propTypes",{variableToType:r.default.object,value:r.default.string,onEdit:r.default.func,readOnly:r.default.bool,onHintInformationRender:r.default.func,onPrettifyQuery:r.default.func,onMergeQuery:r.default.func,onRunQuery:r.default.func,editorTheme:r.default.string})})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var e=o(n(6)),t=n(13),r=o(n(88)),i=o(n(194));function o(e){return e&&e.__esModule?e:{default:e}}function a(e,n,o){var a="Invalid"===n.state.kind?n.state.prevState:n.state,s=a.kind,u=a.step;if("Document"===s&&0===u)return(0,i.default)(e,n,[{text:"{"}]);var c=o.variableToType;if(c){var l=function(e,n){var i={type:null,fields:null};return(0,r.default)(n,(function(n){if("Variable"===n.kind)i.type=e[n.name];else if("ListValue"===n.kind){var r=(0,t.getNullableType)(i.type);i.type=r instanceof t.GraphQLList?r.ofType:null}else if("ObjectValue"===n.kind){var o=(0,t.getNamedType)(i.type);i.fields=o instanceof t.GraphQLInputObjectType?o.getFields():null}else if("ObjectField"===n.kind){var a=n.name&&i.fields?i.fields[n.name]:null;i.type=a&&a.type}})),i}(c,n.state);if("Document"===s||"Variable"===s&&0===u){var f=Object.keys(c);return(0,i.default)(e,n,f.map((function(e){return{text:'"'.concat(e,'": '),type:c[e]}})))}if(("ObjectValue"===s||"ObjectField"===s&&0===u)&&l.fields){var p=Object.keys(l.fields).map((function(e){return l.fields[e]}));return(0,i.default)(e,n,p.map((function(e){return{text:'"'.concat(e.name,'": '),type:e.type,description:e.description}})))}if("StringValue"===s||"NumberValue"===s||"BooleanValue"===s||"NullValue"===s||"ListValue"===s&&1===u||"ObjectField"===s&&2===u||"Variable"===s&&2===u){var d=(0,t.getNamedType)(l.type);if(d instanceof t.GraphQLInputObjectType)return(0,i.default)(e,n,[{text:"{"}]);if(d instanceof t.GraphQLEnumType){var h=d.getValues(),m=Object.keys(h).map((function(e){return h[e]}));return(0,i.default)(e,n,m.map((function(e){return{text:'"'.concat(e.name,'"'),type:d,description:e.description}})))}if(d===t.GraphQLBoolean)return(0,i.default)(e,n,[{text:"true",type:t.GraphQLBoolean,description:"Not false."},{text:"false",type:t.GraphQLBoolean,description:"Not true."}])}}}e.default.registerHelper("hint","graphql-variables",(function(t,n){var r=t.getCursor(),i=t.getTokenAt(r),o=a(r,i,n);return o&&o.list&&o.list.length>0&&(o.from=e.default.Pos(o.from.line,o.from.column),o.to=e.default.Pos(o.to.line,o.to.column),e.default.signal(t,"hasCompletion",t,o,i)),o}))})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";function e(e,t){var n=e.filter(t);return 0===n.length?e:n}function n(e){return e.toLowerCase().replace(/\W/g,"")}function r(e,t){var n=function(e,t){var n,r,i=[],o=e.length,a=t.length;for(n=0;n<=o;n++)i[n]=[n];for(r=1;r<=a;r++)i[0][r]=r;for(n=1;n<=o;n++)for(r=1;r<=a;r++){var s=e[n-1]===t[r-1]?0:1;i[n][r]=Math.min(i[n-1][r]+1,i[n][r-1]+1,i[n-1][r-1]+s),n>1&&r>1&&e[n-1]===t[r-2]&&e[n-2]===t[r-1]&&(i[n][r]=Math.min(i[n][r],i[n-2][r-2]+s))}return i[o][a]}(t,e);return e.length>t.length&&(n-=e.length-t.length-1,n+=0===e.indexOf(t)?0:.5),n}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t,i,o){var a=function(t,i){return i?e(e(t.map((function(e){return{proximity:r(n(e.text),i),entry:e}})),(function(e){return e.proximity<=2})),(function(e){return!e.entry.isDeprecated})).sort((function(e,t){return(e.entry.isDeprecated?1:0)-(t.entry.isDeprecated?1:0)||e.proximity-t.proximity||e.entry.text.length-t.entry.text.length})).map((function(e){return e.entry})):e(t,(function(e){return!e.isDeprecated}))}(o,n(i.string));if(a){var s=null!==i.type&&/"|\w/.test(i.string[0])?i.start:i.end;return{list:a,from:{line:t.line,column:s},to:{line:t.line,column:i.end}}}}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";function e(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var t=o(n(6)),r=n(13),i=o(n(196));function o(e){return e&&e.__esModule?e:{default:e}}function a(t,n,i){var o=[];return i.members.forEach((function(i){var a=i.key.value,c=n[a];c?function e(t,n){if(t instanceof r.GraphQLNonNull)return"Null"===n.kind?[[n,'Type "'.concat(t,'" is non-nullable and cannot be null.')]]:e(t.ofType,n);if("Null"===n.kind)return[];if(t instanceof r.GraphQLList){var i=t.ofType;return"Array"===n.kind?u(n.values,(function(t){return e(i,t)})):e(i,n)}if(t instanceof r.GraphQLInputObjectType){if("Object"!==n.kind)return[[n,'Type "'.concat(t,'" must be an Object.')]];var o=Object.create(null),a=u(n.members,(function(n){var r=n.key.value;o[r]=!0;var i=t.getFields()[r];if(!i)return[[n.key,'Type "'.concat(t,'" does not have a field "').concat(r,'".')]];var a=i?i.type:void 0;return e(a,n.value)}));return Object.keys(t.getFields()).forEach((function(e){o[e]||t.getFields()[e].type instanceof r.GraphQLNonNull&&a.push([n,'Object of type "'.concat(t,'" is missing required field "').concat(e,'".')])})),a}return"Boolean"===t.name&&"Boolean"!==n.kind||"String"===t.name&&"String"!==n.kind||"ID"===t.name&&"Number"!==n.kind&&"String"!==n.kind||"Float"===t.name&&"Number"!==n.kind||"Int"===t.name&&("Number"!==n.kind||(0|n.value)!==n.value)?[[n,'Expected value of type "'.concat(t,'".')]]:(t instanceof r.GraphQLEnumType||t instanceof r.GraphQLScalarType)&&("String"!==n.kind&&"Number"!==n.kind&&"Boolean"!==n.kind&&"Null"!==n.kind||null==(s=t.parseValue(n.value))||s!=s)?[[n,'Expected value of type "'.concat(t,'".')]]:[];var s}(c,i.value).forEach((function(n){var r=e(n,2),i=r[0],a=r[1];o.push(s(t,i,a))})):o.push(s(t,i.key,'Variable "$'.concat(a,'" does not appear in any GraphQL query.')))})),o}function s(e,t,n){return{message:n,severity:"error",type:"validation",from:e.posFromIndex(t.start),to:e.posFromIndex(t.end)}}function u(e,t){return Array.prototype.concat.apply([],e.map(t))}t.default.registerHelper("lint","graphql-variables",(function(e,t,n){if(!e)return[];var r;try{r=(0,i.default)(e)}catch(e){if(e.stack)throw e;return[s(n,e,e.message)]}var o=t.variableToType;return o?a(n,o,r):[]}))})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var e,n,r,i,o,a,s;function u(){var e=r,t=[];if(p("{"),!h("}")){do{t.push(c())}while(h(","));p("}")}return{kind:"Object",start:e,end:o,members:t}}function c(){var e=r,t="String"===s?f():null;p("String"),p(":");var n=l();return{kind:"Member",start:e,end:o,key:t,value:n}}function l(){switch(s){case"[":return function(){var e=r,t=[];if(p("["),!h("]")){do{t.push(l())}while(h(","));p("]")}return{kind:"Array",start:e,end:o,values:t}}();case"{":return u();case"String":case"Number":case"Boolean":case"Null":var e=f();return v(),e}return p("Value")}function f(){return{kind:s,start:r,end:i,value:JSON.parse(e.slice(r,i))}}function p(t){if(s!==t){var n;if("EOF"===s)n="[end of file]";else if(i-r>1)n="`"+e.slice(r,i)+"`";else{var o=e.slice(r).match(/^.+?\b/);n="`"+(o?o[0]:e[r])+"`"}throw d("Expected ".concat(t," but found ").concat(n,"."))}v()}function d(e){return{message:e,start:r,end:i}}function h(e){if(s===e)return v(),!0}function m(){i31;)if(92===a)switch(m(),a){case 34:case 47:case 92:case 98:case 102:case 110:case 114:case 116:m();break;case 117:m(),y(),y(),y(),y();break;default:throw d("Bad character escape sequence.")}else{if(i===n)throw d("Unterminated string.");m()}if(34!==a)throw d("Unterminated string.");m()}();case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return s="Number",45===a&&m(),48===a?m():g(),46===a&&(m(),g()),void(69!==a&&101!==a||(m(),43!==a&&45!==a||m(),g()));case 102:if("false"!==e.slice(r,r+5))break;return i+=4,m(),void(s="Boolean");case 110:if("null"!==e.slice(r,r+4))break;return i+=3,m(),void(s="Null");case 116:if("true"!==e.slice(r,r+4))break;return i+=3,m(),void(s="Boolean")}s=e[r],m()}else s="EOF"}function y(){if(a>=48&&a<=57||a>=65&&a<=70||a>=97&&a<=102)return m();throw d("Expected hexadecimal digit.")}function g(){if(a<48||a>57)throw d("Expected decimal digit.");do{m()}while(a>=48&&a<=57)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t){e=t,n=t.length,r=i=o=-1,m(),v();var a=u();return p("EOF"),a}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[],void 0===(o="function"==typeof(r=function(){"use strict";var e,t=(e=n(6))&&e.__esModule?e:{default:e},r=n(35);function i(e,t){var n=e.levels;return(n&&0!==n.length?n[n.length-1]-(this.electricInput.test(t)?1:0):e.indentLevel)*this.config.indentUnit}t.default.defineMode("graphql-variables",(function(e){var t=(0,r.onlineParser)({eatWhitespace:function(e){return e.eatSpace()},lexRules:o,parseRules:a,editorConfig:{tabSize:e.tabSize}});return{config:e,startState:t.startState,token:t.token,indent:i,electricInput:/^\s*[}\]]/,fold:"brace",closeBrackets:{pairs:'[]{}""',explode:"[]{}"}}}));var o={Punctuation:/^\[|]|\{|\}|:|,/,Number:/^-?(?:0|(?:[1-9][0-9]*))(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?/,String:/^"(?:[^"\\]|\\(?:"|\/|\\|b|f|n|r|t|u[0-9a-fA-F]{4}))*"?/,Keyword:/^true|false|null/},a={Document:[(0,r.p)("{"),(0,r.list)("Variable",(0,r.opt)((0,r.p)(","))),(0,r.p)("}")],Variable:[s("variable"),(0,r.p)(":"),"Value"],Value:function(e){switch(e.kind){case"Number":return"NumberValue";case"String":return"StringValue";case"Punctuation":switch(e.value){case"[":return"ListValue";case"{":return"ObjectValue"}return null;case"Keyword":switch(e.value){case"true":case"false":return"BooleanValue";case"null":return"NullValue"}return null}},NumberValue:[(0,r.t)("Number","number")],StringValue:[(0,r.t)("String","string")],BooleanValue:[(0,r.t)("Keyword","builtin")],NullValue:[(0,r.t)("Keyword","keyword")],ListValue:[(0,r.p)("["),(0,r.list)("Value",(0,r.opt)((0,r.p)(","))),(0,r.p)("]")],ObjectValue:[(0,r.p)("{"),(0,r.list)("ObjectField",(0,r.opt)((0,r.p)(","))),(0,r.p)("}")],ObjectField:[s("attribute"),(0,r.p)(":"),"Value"]};function s(e){return{style:e,match:function(e){return"String"===e.kind},update:function(e,t){e.name=t.value.slice(1,-1)}}}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(14),n(62),n(16),n(46)],void 0===(o="function"==typeof(r=function(e,t,r,i,o){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){for(var n=0;n1&&e.setState({navStack:e.state.navStack.slice(0,-1)})})),v(h(e),"handleClickTypeOrField",(function(t){e.showDoc(t)})),v(h(e),"handleSearch",(function(t){e.showSearch(t)})),e.state={navStack:[y]},e}var c,g,b;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}(n,e),c=n,(g=[{key:"shouldComponentUpdate",value:function(e,t){return this.props.schema!==e.schema||this.state.navStack!==t.navStack}},{key:"render",value:function(){var e,n=this.props.schema,c=this.state.navStack,l=c[c.length-1];e=void 0===n?t.default.createElement("div",{className:"spinner-container"},t.default.createElement("div",{className:"spinner"})):n?l.search?t.default.createElement(s.default,{searchValue:l.search,withinType:l.def,schema:n,onClickType:this.handleClickTypeOrField,onClickField:this.handleClickTypeOrField}):1===c.length?t.default.createElement(o.default,{schema:n,onClickType:this.handleClickTypeOrField}):(0,r.isType)(l.def)?t.default.createElement(u.default,{schema:n,type:l.def,onClickType:this.handleClickTypeOrField,onClickField:this.handleClickTypeOrField}):t.default.createElement(i.default,{field:l.def,onClickType:this.handleClickTypeOrField}):t.default.createElement("div",{className:"error-container"},"No Schema Available");var f,p=1===c.length||(0,r.isType)(l.def)&&l.def.getFields;return c.length>1&&(f=c[c.length-2].name),t.default.createElement("section",{className:"doc-explorer",key:l.name,"aria-label":"Documentation Explorer"},t.default.createElement("div",{className:"doc-explorer-title-bar"},f&&t.default.createElement("button",{className:"doc-explorer-back",onClick:this.handleNavBackClick,"aria-label":"Go back to ".concat(f)},f),t.default.createElement("div",{className:"doc-explorer-title"},l.title||l.name),t.default.createElement("div",{className:"doc-explorer-rhs"},this.props.children)),t.default.createElement("div",{className:"doc-explorer-contents"},p&&t.default.createElement(a.default,{value:l.search,placeholder:"Search ".concat(l.name,"..."),onSearch:this.handleSearch}),e))}},{key:"showDoc",value:function(e){var t=this.state.navStack;t[t.length-1].def!==e&&this.setState({navStack:t.concat([{name:e.name,def:e}])})}},{key:"showDocForReference",value:function(e){"Type"===e.kind?this.showDoc(e.type):"Field"===e.kind?this.showDoc(e.field):"Argument"===e.kind&&e.field?this.showDoc(e.field):"EnumValue"===e.kind&&e.type&&this.showDoc(e.type)}},{key:"showSearch",value:function(e){var t=this.state.navStack.slice(),n=t[t.length-1];t[t.length-1]=function(e){for(var t=1;t0&&(e=t.default.createElement("div",{className:"doc-category"},t.default.createElement("div",{className:"doc-category-title"},"arguments"),a.args.map((function(e){return t.default.createElement("div",{key:e.name,className:"doc-category-item"},t.default.createElement("div",null,t.default.createElement(r.default,{arg:e,onClickType:n.props.onClickType})),t.default.createElement(i.default,{className:"doc-value-description",markdown:e.description}))})))),t.default.createElement("div",null,t.default.createElement(i.default,{className:"doc-type-description",markdown:a.description||"No Description"}),a.deprecationReason&&t.default.createElement(i.default,{className:"doc-deprecation",markdown:a.deprecationReason}),t.default.createElement("div",{className:"doc-category"},t.default.createElement("div",{className:"doc-category-title"},"type"),t.default.createElement(o.default,{type:a.type,onClick:this.props.onClickType})),e)}}])&&u(a.prototype,s),p&&u(a,p),n}(t.default.Component);e.default=m,p=m,d="propTypes",h={field:n.default.object,onClickType:n.default.func},d in p?Object.defineProperty(p,d,{value:h,enumerable:!0,configurable:!0,writable:!0}):p[d]=h})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(14),n(16),n(36),n(57)],void 0===(o="function"==typeof(r=function(e,t,n,r,i){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){for(var n=0;n=100)return"break";var p=f[o];if(n!==p&&m(o,e)&&c.push(t.default.createElement("div",{className:"doc-category-item",key:o},t.default.createElement(i.default,{type:p,onClick:a}))),p.getFields){var d=p.getFields();Object.keys(d).forEach((function(c){var f,h=d[c];if(!m(c,e)){if(!h.args||!h.args.length)return;if(0===(f=h.args.filter((function(t){return m(t.name,e)}))).length)return}var v=t.default.createElement("div",{className:"doc-category-item",key:o+"."+c},n!==p&&[t.default.createElement(i.default,{key:"type",type:p,onClick:a}),"."],t.default.createElement("a",{className:"field-name",onClick:function(e){return s(h,p,e)}},h.name),f&&["(",t.default.createElement("span",{key:"args"},f.map((function(e){return t.default.createElement(r.default,{key:e.name,arg:e,onClickType:a,showDefaultValue:!1})}))),")"]);n===p?u.push(v):l.push(v)}))}},b=p[Symbol.iterator]();!(d=(y=b.next()).done)&&"break"!==g();d=!0);}catch(e){h=!0,v=e}finally{try{d||null==b.return||b.return()}finally{if(h)throw v}}return u.length+c.length+l.length===0?t.default.createElement("span",{className:"doc-alert-text"},"No results found."):n&&c.length+l.length>0?t.default.createElement("div",null,u,t.default.createElement("div",{className:"doc-category"},t.default.createElement("div",{className:"doc-category-title"},"other results"),c,l)):t.default.createElement("div",null,u,c,l)}}])&&s(o.prototype,a),f&&s(o,f),n}(t.default.Component);function m(e,t){try{var n=t.replace(/[^_0-9A-Za-z]/g,(function(e){return"\\"+e}));return-1!==e.search(new RegExp(n,"i"))}catch(n){return-1!==e.toLowerCase().indexOf(t.toLowerCase())}}e.default=h,f=h,p="propTypes",d={schema:n.default.object,withinType:n.default.object,searchValue:n.default.string,onClickType:n.default.func,onClickField:n.default.func},p in f?Object.defineProperty(f,p,{value:d,enumerable:!0,configurable:!0,writable:!0}):f[p]=d})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(14),n(16),n(13),n(56),n(57),n(36),n(91)],void 0===(o="function"==typeof(r=function(e,t,n,r,i,o,a,s){"use strict";function u(e){return e&&e.__esModule?e:{default:e}}function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function l(e,t){for(var n=0;n0&&(i=t.default.createElement("div",{className:"doc-category"},t.default.createElement("div",{className:"doc-category-title"},e),n.map((function(e){return t.default.createElement("div",{key:e.name,className:"doc-category-item"},t.default.createElement(a.default,{type:e,onClick:d}))})))),p.getFields){var m=p.getFields(),g=Object.keys(m).map((function(e){return m[e]}));s=t.default.createElement("div",{className:"doc-category"},t.default.createElement("div",{className:"doc-category-title"},"fields"),g.filter((function(e){return!e.isDeprecated})).map((function(e){return t.default.createElement(v,{key:e.name,type:p,field:e,onClickType:d,onClickField:h})})));var b=g.filter((function(e){return e.isDeprecated}));b.length>0&&(u=t.default.createElement("div",{className:"doc-category"},t.default.createElement("div",{className:"doc-category-title"},"deprecated fields"),this.state.showDeprecated?b.map((function(e){return t.default.createElement(v,{key:e.name,type:p,field:e,onClickType:d,onClickField:h})})):t.default.createElement("button",{className:"show-btn",onClick:this.handleShowDeprecated},"Show deprecated fields...")))}if(p instanceof r.GraphQLEnumType){var O=p.getValues();c=t.default.createElement("div",{className:"doc-category"},t.default.createElement("div",{className:"doc-category-title"},"values"),O.filter((function(e){return!e.isDeprecated})).map((function(e){return t.default.createElement(y,{key:e.name,value:e})})));var E=O.filter((function(e){return e.isDeprecated}));E.length>0&&(l=t.default.createElement("div",{className:"doc-category"},t.default.createElement("div",{className:"doc-category-title"},"deprecated values"),this.state.showDeprecated?E.map((function(e){return t.default.createElement(y,{key:e.name,value:e})})):t.default.createElement("button",{className:"show-btn",onClick:this.handleShowDeprecated},"Show deprecated values...")))}return t.default.createElement("div",null,t.default.createElement(o.default,{className:"doc-type-description",markdown:p.description||"No Description"}),p instanceof r.GraphQLObjectType&&i,s,u,c,l,!(p instanceof r.GraphQLObjectType)&&i)}}])&&l(i.prototype,s),u&&l(i,u),n}(t.default.Component);function v(e){var n=e.type,r=e.field,u=e.onClickType,c=e.onClickField;return t.default.createElement("div",{className:"doc-category-item"},t.default.createElement("a",{className:"field-name",onClick:function(e){return c(r,n,e)}},r.name),r.args&&r.args.length>0&&["(",t.default.createElement("span",{key:"args"},r.args.map((function(e){return t.default.createElement(i.default,{key:e.name,arg:e,onClickType:u})}))),")"],": ",t.default.createElement(a.default,{type:r.type,onClick:u}),t.default.createElement(s.default,{field:r}),r.description&&t.default.createElement(o.default,{className:"field-short-description",markdown:r.description}),r.deprecationReason&&t.default.createElement(o.default,{className:"doc-deprecation",markdown:r.deprecationReason}))}function y(e){var n=e.value;return t.default.createElement("div",{className:"doc-category-item"},t.default.createElement("div",{className:"enum-value"},n.name),t.default.createElement(o.default,{className:"doc-value-description",markdown:n.description}),n.deprecationReason&&t.default.createElement(o.default,{className:"doc-deprecation",markdown:n.deprecationReason}))}e.default=m,h(m,"propTypes",{schema:n.default.instanceOf(r.GraphQLSchema),type:n.default.object,onClickType:n.default.func,onClickField:n.default.func}),v.propTypes={type:n.default.object,field:n.default.object,onClickType:n.default.func,onClickField:n.default.func},y.propTypes={value:n.default.object}})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(13),n(14),n(16),n(207),n(208)],void 0===(o="function"==typeof(r=function(e,t,n,r,i,o){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(){return(u=Object.assign||function(e){for(var t=1;t1e5)return!1;if(!r)return!0;if(JSON.stringify(e.query)===JSON.stringify(r.query)){if(JSON.stringify(e.variables)===JSON.stringify(r.variables))return!1;if(!e.variables&&!r.variables)return!1}return!0}(e,this.props,this.historyStore.fetchRecent())){var n={query:e.query,variables:e.variables,operationName:e.operationName};this.historyStore.push(n);var r=this.historyStore.items,i=this.favoriteStore.items,o=r.concat(i);this.setState({queries:o})}}},{key:"render",value:function(){var e=this,t=this.state.queries.slice().reverse().map((function(t,r){return n.default.createElement(o.default,u({handleEditLabel:e.editLabel,handleToggleFavorite:e.toggleFavorite,key:"".concat(r,":").concat(t.label||t.query),onSelect:e.props.onSelectQuery},t))}));return n.default.createElement("section",{"aria-label":"History"},n.default.createElement("div",{className:"history-title-bar"},n.default.createElement("div",{className:"history-title"},"History"),n.default.createElement("div",{className:"doc-explorer-rhs"},this.props.children)),n.default.createElement("ul",{className:"history-contents"},t))}}])&&f(a.prototype,y),g&&f(a,g),r}(n.default.Component);e.QueryHistory=y,m(y,"propTypes",{query:r.default.string,variables:r.default.string,operationName:r.default.string,queryID:r.default.number,onSelectQuery:r.default.func,storage:r.default.object})})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t],void 0===(o="function"==typeof(r=function(e){"use strict";function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t2&&void 0!==arguments[2]?arguments[2]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.key=t,this.storage=n,this.maxSize=r,this.items=this.fetchAll()}var i,o,a;return i=e,(o=[{key:"contains",value:function(e){return this.items.some((function(t){return t.query===e.query&&t.variables===e.variables&&t.operationName===e.operationName}))}},{key:"edit",value:function(e){var t=this.items.findIndex((function(t){return t.query===e.query&&t.variables===e.variables&&t.operationName===e.operationName}));-1!==t&&(this.items.splice(t,1,e),this.save())}},{key:"delete",value:function(e){var t=this.items.findIndex((function(t){return t.query===e.query&&t.variables===e.variables&&t.operationName===e.operationName}));-1!==t&&(this.items.splice(t,1),this.save())}},{key:"fetchRecent",value:function(){return this.items[this.items.length-1]}},{key:"fetchAll",value:function(){var e=this.storage.get(this.key);return e?JSON.parse(e)[this.key]:[]}},{key:"push",value:function(e){var r=[].concat(n(this.items),[e]);this.maxSize&&r.length>this.maxSize&&r.shift();for(var i=0;i<5;i++){var o=this.storage.set(this.key,JSON.stringify(t({},this.key,r)));if(o&&o.error){if(!o.isQuotaError||!this.maxSize)return;r.shift()}else this.items=r}}},{key:"save",value:function(){this.storage.set(this.key,JSON.stringify(t({},this.key,this.items)))}},{key:"length",get:function(){return this.items.length}}])&&r(i.prototype,o),a&&r(i,a),e}();e.default=i})?r.apply(t,i):r)||(e.exports=o)},function(e,t,n){var r,i,o;i=[t,n(14),n(16)],void 0===(o="function"==typeof(r=function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n + + Simple GraphiQL Example + + + +
+ + + + + + + + \ No newline at end of file diff --git a/graphql/webapp/graphql/graphiql/react-dom.development.js b/graphql/webapp/graphql/graphiql/react-dom.development.js new file mode 100644 index 000000000..a484d1d9d --- /dev/null +++ b/graphql/webapp/graphql/graphiql/react-dom.development.js @@ -0,0 +1,27941 @@ +/** @license React v16.12.0 + * react-dom.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) : + typeof define === 'function' && define.amd ? define(['react'], factory) : + (global.ReactDOM = factory(global.React)); +}(this, (function (React) { 'use strict'; + +// Do not require this module directly! Use normal `invariant` calls with +// template literal strings. The messages will be replaced with error codes +// during build. + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +if (!React) { + { + throw Error("ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM."); + } +} + +/** + * Injectable ordering of event plugins. + */ +var eventPluginOrder = null; +/** + * Injectable mapping from names to event plugin modules. + */ + +var namesToPlugins = {}; +/** + * Recomputes the plugin list using the injected plugins and plugin ordering. + * + * @private + */ + +function recomputePluginOrdering() { + if (!eventPluginOrder) { + // Wait until an `eventPluginOrder` is injected. + return; + } + + for (var pluginName in namesToPlugins) { + var pluginModule = namesToPlugins[pluginName]; + var pluginIndex = eventPluginOrder.indexOf(pluginName); + + if (!(pluginIndex > -1)) { + { + throw Error("EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`."); + } + } + + if (plugins[pluginIndex]) { + continue; + } + + if (!pluginModule.extractEvents) { + { + throw Error("EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not."); + } + } + + plugins[pluginIndex] = pluginModule; + var publishedEvents = pluginModule.eventTypes; + + for (var eventName in publishedEvents) { + if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) { + { + throw Error("EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`."); + } + } + } + } +} +/** + * Publishes an event so that it can be dispatched by the supplied plugin. + * + * @param {object} dispatchConfig Dispatch configuration for the event. + * @param {object} PluginModule Plugin publishing the event. + * @return {boolean} True if the event was successfully published. + * @private + */ + + +function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { + if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { + { + throw Error("EventPluginHub: More than one plugin attempted to publish the same event name, `" + eventName + "`."); + } + } + + eventNameDispatchConfigs[eventName] = dispatchConfig; + var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; + + if (phasedRegistrationNames) { + for (var phaseName in phasedRegistrationNames) { + if (phasedRegistrationNames.hasOwnProperty(phaseName)) { + var phasedRegistrationName = phasedRegistrationNames[phaseName]; + publishRegistrationName(phasedRegistrationName, pluginModule, eventName); + } + } + + return true; + } else if (dispatchConfig.registrationName) { + publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); + return true; + } + + return false; +} +/** + * Publishes a registration name that is used to identify dispatched events. + * + * @param {string} registrationName Registration name to add. + * @param {object} PluginModule Plugin publishing the event. + * @private + */ + + +function publishRegistrationName(registrationName, pluginModule, eventName) { + if (!!registrationNameModules[registrationName]) { + { + throw Error("EventPluginHub: More than one plugin attempted to publish the same registration name, `" + registrationName + "`."); + } + } + + registrationNameModules[registrationName] = pluginModule; + registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; + + { + var lowerCasedName = registrationName.toLowerCase(); + possibleRegistrationNames[lowerCasedName] = registrationName; + + if (registrationName === 'onDoubleClick') { + possibleRegistrationNames.ondblclick = registrationName; + } + } +} +/** + * Registers plugins so that they can extract and dispatch events. + * + * @see {EventPluginHub} + */ + +/** + * Ordered list of injected plugins. + */ + + +var plugins = []; +/** + * Mapping from event name to dispatch config + */ + +var eventNameDispatchConfigs = {}; +/** + * Mapping from registration name to plugin module + */ + +var registrationNameModules = {}; +/** + * Mapping from registration name to event name + */ + +var registrationNameDependencies = {}; +/** + * Mapping from lowercase registration names to the properly cased version, + * used to warn in the case of missing event handlers. Available + * only in true. + * @type {Object} + */ + +var possibleRegistrationNames = {}; // Trust the developer to only use possibleRegistrationNames in true + +/** + * Injects an ordering of plugins (by plugin name). This allows the ordering + * to be decoupled from injection of the actual plugins so that ordering is + * always deterministic regardless of packaging, on-the-fly injection, etc. + * + * @param {array} InjectedEventPluginOrder + * @internal + * @see {EventPluginHub.injection.injectEventPluginOrder} + */ + +function injectEventPluginOrder(injectedEventPluginOrder) { + if (!!eventPluginOrder) { + { + throw Error("EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."); + } + } // Clone the ordering so it cannot be dynamically mutated. + + + eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); + recomputePluginOrdering(); +} +/** + * Injects plugins to be used by `EventPluginHub`. The plugin names must be + * in the ordering injected by `injectEventPluginOrder`. + * + * Plugins can be injected as part of page initialization or on-the-fly. + * + * @param {object} injectedNamesToPlugins Map from names to plugin modules. + * @internal + * @see {EventPluginHub.injection.injectEventPluginsByName} + */ + +function injectEventPluginsByName(injectedNamesToPlugins) { + var isOrderingDirty = false; + + for (var pluginName in injectedNamesToPlugins) { + if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { + continue; + } + + var pluginModule = injectedNamesToPlugins[pluginName]; + + if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) { + if (!!namesToPlugins[pluginName]) { + { + throw Error("EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + pluginName + "`."); + } + } + + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = true; + } + } + + if (isOrderingDirty) { + recomputePluginOrdering(); + } +} + +var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) { + var funcArgs = Array.prototype.slice.call(arguments, 3); + + try { + func.apply(context, funcArgs); + } catch (error) { + this.onError(error); + } +}; + +{ + // In DEV mode, we swap out invokeGuardedCallback for a special version + // that plays more nicely with the browser's DevTools. The idea is to preserve + // "Pause on exceptions" behavior. Because React wraps all user-provided + // functions in invokeGuardedCallback, and the production version of + // invokeGuardedCallback uses a try-catch, all user exceptions are treated + // like caught exceptions, and the DevTools won't pause unless the developer + // takes the extra step of enabling pause on caught exceptions. This is + // unintuitive, though, because even though React has caught the error, from + // the developer's perspective, the error is uncaught. + // + // To preserve the expected "Pause on exceptions" behavior, we don't use a + // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake + // DOM node, and call the user-provided callback from inside an event handler + // for that fake event. If the callback throws, the error is "captured" using + // a global event handler. But because the error happens in a different + // event loop context, it does not interrupt the normal program flow. + // Effectively, this gives us try-catch behavior without actually using + // try-catch. Neat! + // Check that the browser supports the APIs we need to implement our special + // DEV version of invokeGuardedCallback + if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { + var fakeNode = document.createElement('react'); + + var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) { + // If document doesn't exist we know for sure we will crash in this method + // when we call document.createEvent(). However this can cause confusing + // errors: https://github.com/facebookincubator/create-react-app/issues/3482 + // So we preemptively throw with a better message instead. + if (!(typeof document !== 'undefined')) { + { + throw Error("The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous."); + } + } + + var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We + // set this to true at the beginning, then set it to false right after + // calling the function. If the function errors, `didError` will never be + // set to false. This strategy works even if the browser is flaky and + // fails to call our global error handler, because it doesn't rely on + // the error event at all. + + var didError = true; // Keeps track of the value of window.event so that we can reset it + // during the callback to let user code access window.event in the + // browsers that support it. + + var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event + // dispatching: https://github.com/facebook/react/issues/13688 + + var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously + // dispatch our fake event using `dispatchEvent`. Inside the handler, we + // call the user-provided callback. + + var funcArgs = Array.prototype.slice.call(arguments, 3); + + function callCallback() { + // We immediately remove the callback from event listeners so that + // nested `invokeGuardedCallback` calls do not clash. Otherwise, a + // nested call would trigger the fake event handlers of any call higher + // in the stack. + fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the + // window.event assignment in both IE <= 10 as they throw an error + // "Member not found" in strict mode, and in Firefox which does not + // support window.event. + + if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) { + window.event = windowEvent; + } + + func.apply(context, funcArgs); + didError = false; + } // Create a global error event handler. We use this to capture the value + // that was thrown. It's possible that this error handler will fire more + // than once; for example, if non-React code also calls `dispatchEvent` + // and a handler for that event throws. We should be resilient to most of + // those cases. Even if our error event handler fires more than once, the + // last error event is always used. If the callback actually does error, + // we know that the last error event is the correct one, because it's not + // possible for anything else to have happened in between our callback + // erroring and the code that follows the `dispatchEvent` call below. If + // the callback doesn't error, but the error event was fired, we know to + // ignore it because `didError` will be false, as described above. + + + var error; // Use this to track whether the error event is ever called. + + var didSetError = false; + var isCrossOriginError = false; + + function handleWindowError(event) { + error = event.error; + didSetError = true; + + if (error === null && event.colno === 0 && event.lineno === 0) { + isCrossOriginError = true; + } + + if (event.defaultPrevented) { + // Some other error handler has prevented default. + // Browsers silence the error report if this happens. + // We'll remember this to later decide whether to log it or not. + if (error != null && typeof error === 'object') { + try { + error._suppressLogging = true; + } catch (inner) {// Ignore. + } + } + } + } // Create a fake event type. + + + var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers + + window.addEventListener('error', handleWindowError); + fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function + // errors, it will trigger our global error handler. + + evt.initEvent(evtType, false, false); + fakeNode.dispatchEvent(evt); + + if (windowEventDescriptor) { + Object.defineProperty(window, 'event', windowEventDescriptor); + } + + if (didError) { + if (!didSetError) { + // The callback errored, but the error event never fired. + error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.'); + } else if (isCrossOriginError) { + error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.'); + } + + this.onError(error); + } // Remove our event listeners + + + window.removeEventListener('error', handleWindowError); + }; + + invokeGuardedCallbackImpl = invokeGuardedCallbackDev; + } +} + +var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; + +var hasError = false; +var caughtError = null; // Used by event system to capture/rethrow the first error. + +var hasRethrowError = false; +var rethrowError = null; +var reporter = { + onError: function (error) { + hasError = true; + caughtError = error; + } +}; +/** + * Call a function while guarding against errors that happens within it. + * Returns an error if it throws, otherwise null. + * + * In production, this is implemented using a try-catch. The reason we don't + * use a try-catch directly is so that we can swap out a different + * implementation in DEV mode. + * + * @param {String} name of the guard to use for logging or debugging + * @param {Function} func The function to invoke + * @param {*} context The context to use when calling the function + * @param {...*} args Arguments for function + */ + +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = false; + caughtError = null; + invokeGuardedCallbackImpl$1.apply(reporter, arguments); +} +/** + * Same as invokeGuardedCallback, but instead of returning an error, it stores + * it in a global so it can be rethrown by `rethrowCaughtError` later. + * TODO: See if caughtError and rethrowError can be unified. + * + * @param {String} name of the guard to use for logging or debugging + * @param {Function} func The function to invoke + * @param {*} context The context to use when calling the function + * @param {...*} args Arguments for function + */ + +function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) { + invokeGuardedCallback.apply(this, arguments); + + if (hasError) { + var error = clearCaughtError(); + + if (!hasRethrowError) { + hasRethrowError = true; + rethrowError = error; + } + } +} +/** + * During execution of guarded functions we will capture the first error which + * we will rethrow to be handled by the top level error handler. + */ + +function rethrowCaughtError() { + if (hasRethrowError) { + var error = rethrowError; + hasRethrowError = false; + rethrowError = null; + throw error; + } +} +function hasCaughtError() { + return hasError; +} +function clearCaughtError() { + if (hasError) { + var error = caughtError; + hasError = false; + caughtError = null; + return error; + } else { + { + { + throw Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue."); + } + } + } +} + +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ +var warningWithoutStack = function () {}; + +{ + warningWithoutStack = function (condition, format) { + for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } + + if (format === undefined) { + throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument'); + } + + if (args.length > 8) { + // Check before the condition to catch violations early. + throw new Error('warningWithoutStack() currently supports at most 8 arguments.'); + } + + if (condition) { + return; + } + + if (typeof console !== 'undefined') { + var argsWithFormat = args.map(function (item) { + return '' + item; + }); + argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + + Function.prototype.apply.call(console.error, console, argsWithFormat); + } + + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + var argIndex = 0; + var message = 'Warning: ' + format.replace(/%s/g, function () { + return args[argIndex++]; + }); + throw new Error(message); + } catch (x) {} + }; +} + +var warningWithoutStack$1 = warningWithoutStack; + +var getFiberCurrentPropsFromNode = null; +var getInstanceFromNode = null; +var getNodeFromInstance = null; +function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) { + getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl; + getInstanceFromNode = getInstanceFromNodeImpl; + getNodeFromInstance = getNodeFromInstanceImpl; + + { + !(getNodeFromInstance && getInstanceFromNode) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0; + } +} +var validateEventDispatches; + +{ + validateEventDispatches = function (event) { + var dispatchListeners = event._dispatchListeners; + var dispatchInstances = event._dispatchInstances; + var listenersIsArr = Array.isArray(dispatchListeners); + var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; + var instancesIsArr = Array.isArray(dispatchInstances); + var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; + !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0; + }; +} +/** + * Dispatch the event to the listener. + * @param {SyntheticEvent} event SyntheticEvent to handle + * @param {function} listener Application-level callback + * @param {*} inst Internal component instance + */ + + +function executeDispatch(event, listener, inst) { + var type = event.type || 'unknown-event'; + event.currentTarget = getNodeFromInstance(inst); + invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); + event.currentTarget = null; +} +/** + * Standard/simple iteration through an event's collected dispatches. + */ + +function executeDispatchesInOrder(event) { + var dispatchListeners = event._dispatchListeners; + var dispatchInstances = event._dispatchInstances; + + { + validateEventDispatches(event); + } + + if (Array.isArray(dispatchListeners)) { + for (var i = 0; i < dispatchListeners.length; i++) { + if (event.isPropagationStopped()) { + break; + } // Listeners and Instances are two parallel arrays that are always in sync. + + + executeDispatch(event, dispatchListeners[i], dispatchInstances[i]); + } + } else if (dispatchListeners) { + executeDispatch(event, dispatchListeners, dispatchInstances); + } + + event._dispatchListeners = null; + event._dispatchInstances = null; +} +/** + * @see executeDispatchesInOrderStopAtTrueImpl + */ + + + +/** + * Execution of a "direct" dispatch - there must be at most one dispatch + * accumulated on the event or it is considered an error. It doesn't really make + * sense for an event with multiple dispatches (bubbled) to keep track of the + * return values at each dispatch execution, but it does tend to make sense when + * dealing with "direct" dispatches. + * + * @return {*} The return value of executing the single dispatch. + */ + + +/** + * @param {SyntheticEvent} event + * @return {boolean} True iff number of dispatches accumulated is greater than 0. + */ + +/** + * Accumulates items that must not be null or undefined into the first one. This + * is used to conserve memory by avoiding array allocations, and thus sacrifices + * API cleanness. Since `current` can be null before being passed in and not + * null after this function, make sure to assign it back to `current`: + * + * `a = accumulateInto(a, b);` + * + * This API should be sparingly used. Try `accumulate` for something cleaner. + * + * @return {*|array<*>} An accumulation of items. + */ + +function accumulateInto(current, next) { + if (!(next != null)) { + { + throw Error("accumulateInto(...): Accumulated items must not be null or undefined."); + } + } + + if (current == null) { + return next; + } // Both are not empty. Warning: Never call x.concat(y) when you are not + // certain that x is an Array (x could be a string with concat method). + + + if (Array.isArray(current)) { + if (Array.isArray(next)) { + current.push.apply(current, next); + return current; + } + + current.push(next); + return current; + } + + if (Array.isArray(next)) { + // A bit too dangerous to mutate `next`. + return [current].concat(next); + } + + return [current, next]; +} + +/** + * @param {array} arr an "accumulation" of items which is either an Array or + * a single item. Useful when paired with the `accumulate` module. This is a + * simple utility that allows us to reason about a collection of items, but + * handling the case when there is exactly one item (and we do not need to + * allocate an array). + * @param {function} cb Callback invoked with each element or a collection. + * @param {?} [scope] Scope used as `this` in a callback. + */ +function forEachAccumulated(arr, cb, scope) { + if (Array.isArray(arr)) { + arr.forEach(cb, scope); + } else if (arr) { + cb.call(scope, arr); + } +} + +/** + * Internal queue of events that have accumulated their dispatches and are + * waiting to have their dispatches executed. + */ + +var eventQueue = null; +/** + * Dispatches an event and releases it back into the pool, unless persistent. + * + * @param {?object} event Synthetic event to be dispatched. + * @private + */ + +var executeDispatchesAndRelease = function (event) { + if (event) { + executeDispatchesInOrder(event); + + if (!event.isPersistent()) { + event.constructor.release(event); + } + } +}; + +var executeDispatchesAndReleaseTopLevel = function (e) { + return executeDispatchesAndRelease(e); +}; + +function runEventsInBatch(events) { + if (events !== null) { + eventQueue = accumulateInto(eventQueue, events); + } // Set `eventQueue` to null before processing it so that we can tell if more + // events get enqueued while processing. + + + var processingEventQueue = eventQueue; + eventQueue = null; + + if (!processingEventQueue) { + return; + } + + forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); + + if (!!eventQueue) { + { + throw Error("processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."); + } + } // This would be a good time to rethrow if any of the event handlers threw. + + + rethrowCaughtError(); +} + +function isInteractive(tag) { + return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; +} + +function shouldPreventMouseEvent(name, type, props) { + switch (name) { + case 'onClick': + case 'onClickCapture': + case 'onDoubleClick': + case 'onDoubleClickCapture': + case 'onMouseDown': + case 'onMouseDownCapture': + case 'onMouseMove': + case 'onMouseMoveCapture': + case 'onMouseUp': + case 'onMouseUpCapture': + return !!(props.disabled && isInteractive(type)); + + default: + return false; + } +} +/** + * This is a unified interface for event plugins to be installed and configured. + * + * Event plugins can implement the following properties: + * + * `extractEvents` {function(string, DOMEventTarget, string, object): *} + * Required. When a top-level event is fired, this method is expected to + * extract synthetic events that will in turn be queued and dispatched. + * + * `eventTypes` {object} + * Optional, plugins that fire events must publish a mapping of registration + * names that are used to register listeners. Values of this mapping must + * be objects that contain `registrationName` or `phasedRegistrationNames`. + * + * `executeDispatch` {function(object, function, string)} + * Optional, allows plugins to override how an event gets dispatched. By + * default, the listener is simply invoked. + * + * Each plugin that is injected into `EventsPluginHub` is immediately operable. + * + * @public + */ + +/** + * Methods for injecting dependencies. + */ + + +var injection = { + /** + * @param {array} InjectedEventPluginOrder + * @public + */ + injectEventPluginOrder: injectEventPluginOrder, + + /** + * @param {object} injectedNamesToPlugins Map from names to plugin modules. + */ + injectEventPluginsByName: injectEventPluginsByName +}; +/** + * @param {object} inst The instance, which is the source of events. + * @param {string} registrationName Name of listener (e.g. `onClick`). + * @return {?function} The stored callback. + */ + +function getListener(inst, registrationName) { + var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not + // live here; needs to be moved to a better place soon + + var stateNode = inst.stateNode; + + if (!stateNode) { + // Work in progress (ex: onload events in incremental mode). + return null; + } + + var props = getFiberCurrentPropsFromNode(stateNode); + + if (!props) { + // Work in progress. + return null; + } + + listener = props[registrationName]; + + if (shouldPreventMouseEvent(registrationName, inst.type, props)) { + return null; + } + + if (!(!listener || typeof listener === 'function')) { + { + throw Error("Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type."); + } + } + + return listener; +} +/** + * Allows registered plugins an opportunity to extract events from top-level + * native browser events. + * + * @return {*} An accumulation of synthetic events. + * @internal + */ + +function extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { + var events = null; + + for (var i = 0; i < plugins.length; i++) { + // Not every plugin in the ordering may be loaded at runtime. + var possiblePlugin = plugins[i]; + + if (possiblePlugin) { + var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); + + if (extractedEvents) { + events = accumulateInto(events, extractedEvents); + } + } + } + + return events; +} + +function runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) { + var events = extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); + runEventsInBatch(events); +} + +var FunctionComponent = 0; +var ClassComponent = 1; +var IndeterminateComponent = 2; // Before we know whether it is function or class + +var HostRoot = 3; // Root of a host tree. Could be nested inside another node. + +var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. + +var HostComponent = 5; +var HostText = 6; +var Fragment = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; +var DehydratedFragment = 18; +var SuspenseListComponent = 19; +var FundamentalComponent = 20; +var ScopeComponent = 21; + +var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. +// Current owner and dispatcher used to share the same ref, +// but PR #14548 split them out to better support the react-debug-tools package. + +if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) { + ReactSharedInternals.ReactCurrentDispatcher = { + current: null + }; +} + +if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) { + ReactSharedInternals.ReactCurrentBatchConfig = { + suspense: null + }; +} + +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; +var describeComponentFrame = function (name, source, ownerName) { + var sourceInfo = ''; + + if (source) { + var path = source.fileName; + var fileName = path.replace(BEFORE_SLASH_RE, ''); + + { + // In DEV, include code for a common special case: + // prefer "folder/index.js" instead of just "index.js". + if (/^index\./.test(fileName)) { + var match = path.match(BEFORE_SLASH_RE); + + if (match) { + var pathBeforeSlash = match[1]; + + if (pathBeforeSlash) { + var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); + fileName = folderName + '/' + fileName; + } + } + } + } + + sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; + } else if (ownerName) { + sourceInfo = ' (created by ' + ownerName + ')'; + } + + return '\n in ' + (name || 'Unknown') + sourceInfo; +}; + +// The Symbol used to tag the ReactElement-like types. If there is no native Symbol +// nor polyfill, then a plain number is used for performance. +var hasSymbol = typeof Symbol === 'function' && Symbol.for; +var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; +var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; +var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; +var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; +var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; +var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; +var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary +// (unstable) APIs that have been removed. Can we remove the symbols? + + +var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; +var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; +var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; +var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; +var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; +var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; +var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; +var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; +var FAUX_ITERATOR_SYMBOL = '@@iterator'; +function getIteratorFn(maybeIterable) { + if (maybeIterable === null || typeof maybeIterable !== 'object') { + return null; + } + + var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; + + if (typeof maybeIterator === 'function') { + return maybeIterator; + } + + return null; +} + +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +var warning = warningWithoutStack$1; + +{ + warning = function (condition, format) { + if (condition) { + return; + } + + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args + + for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } + + warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack])); + }; +} + +var warning$1 = warning; + +var Uninitialized = -1; +var Pending = 0; +var Resolved = 1; +var Rejected = 2; +function refineResolvedLazyComponent(lazyComponent) { + return lazyComponent._status === Resolved ? lazyComponent._result : null; +} +function initializeLazyComponentType(lazyComponent) { + if (lazyComponent._status === Uninitialized) { + lazyComponent._status = Pending; + var ctor = lazyComponent._ctor; + var thenable = ctor(); + lazyComponent._result = thenable; + thenable.then(function (moduleObject) { + if (lazyComponent._status === Pending) { + var defaultExport = moduleObject.default; + + { + if (defaultExport === undefined) { + warning$1(false, 'lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject); + } + } + + lazyComponent._status = Resolved; + lazyComponent._result = defaultExport; + } + }, function (error) { + if (lazyComponent._status === Pending) { + lazyComponent._status = Rejected; + lazyComponent._result = error; + } + }); + } +} + +function getWrappedName(outerType, innerType, wrapperName) { + var functionName = innerType.displayName || innerType.name || ''; + return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); +} + +function getComponentName(type) { + if (type == null) { + // Host root, text node or just invalid type. + return null; + } + + { + if (typeof type.tag === 'number') { + warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); + } + } + + if (typeof type === 'function') { + return type.displayName || type.name || null; + } + + if (typeof type === 'string') { + return type; + } + + switch (type) { + case REACT_FRAGMENT_TYPE: + return 'Fragment'; + + case REACT_PORTAL_TYPE: + return 'Portal'; + + case REACT_PROFILER_TYPE: + return "Profiler"; + + case REACT_STRICT_MODE_TYPE: + return 'StrictMode'; + + case REACT_SUSPENSE_TYPE: + return 'Suspense'; + + case REACT_SUSPENSE_LIST_TYPE: + return 'SuspenseList'; + } + + if (typeof type === 'object') { + switch (type.$$typeof) { + case REACT_CONTEXT_TYPE: + return 'Context.Consumer'; + + case REACT_PROVIDER_TYPE: + return 'Context.Provider'; + + case REACT_FORWARD_REF_TYPE: + return getWrappedName(type, type.render, 'ForwardRef'); + + case REACT_MEMO_TYPE: + return getComponentName(type.type); + + case REACT_LAZY_TYPE: + { + var thenable = type; + var resolvedThenable = refineResolvedLazyComponent(thenable); + + if (resolvedThenable) { + return getComponentName(resolvedThenable); + } + + break; + } + } + } + + return null; +} + +var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + +function describeFiber(fiber) { + switch (fiber.tag) { + case HostRoot: + case HostPortal: + case HostText: + case Fragment: + case ContextProvider: + case ContextConsumer: + return ''; + + default: + var owner = fiber._debugOwner; + var source = fiber._debugSource; + var name = getComponentName(fiber.type); + var ownerName = null; + + if (owner) { + ownerName = getComponentName(owner.type); + } + + return describeComponentFrame(name, source, ownerName); + } +} + +function getStackByFiberInDevAndProd(workInProgress) { + var info = ''; + var node = workInProgress; + + do { + info += describeFiber(node); + node = node.return; + } while (node); + + return info; +} +var current = null; +var phase = null; +function getCurrentFiberOwnerNameInDevOrNull() { + { + if (current === null) { + return null; + } + + var owner = current._debugOwner; + + if (owner !== null && typeof owner !== 'undefined') { + return getComponentName(owner.type); + } + } + + return null; +} +function getCurrentFiberStackInDev() { + { + if (current === null) { + return ''; + } // Safe because if current fiber exists, we are reconciling, + // and it is guaranteed to be the work-in-progress version. + + + return getStackByFiberInDevAndProd(current); + } + + return ''; +} +function resetCurrentFiber() { + { + ReactDebugCurrentFrame.getCurrentStack = null; + current = null; + phase = null; + } +} +function setCurrentFiber(fiber) { + { + ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev; + current = fiber; + phase = null; + } +} +function setCurrentPhase(lifeCyclePhase) { + { + phase = lifeCyclePhase; + } +} + +var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); + +function endsWith(subject, search) { + var length = subject.length; + return subject.substring(length - search.length, length) === search; +} + +var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; +var _assign = ReactInternals.assign; + +var PLUGIN_EVENT_SYSTEM = 1; +var RESPONDER_EVENT_SYSTEM = 1 << 1; +var IS_PASSIVE = 1 << 2; +var IS_ACTIVE = 1 << 3; +var PASSIVE_NOT_SUPPORTED = 1 << 4; +var IS_REPLAYED = 1 << 5; + +var restoreImpl = null; +var restoreTarget = null; +var restoreQueue = null; + +function restoreStateOfTarget(target) { + // We perform this translation at the end of the event loop so that we + // always receive the correct fiber here + var internalInstance = getInstanceFromNode(target); + + if (!internalInstance) { + // Unmounted + return; + } + + if (!(typeof restoreImpl === 'function')) { + { + throw Error("setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue."); + } + } + + var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); + restoreImpl(internalInstance.stateNode, internalInstance.type, props); +} + +function setRestoreImplementation(impl) { + restoreImpl = impl; +} +function enqueueStateRestore(target) { + if (restoreTarget) { + if (restoreQueue) { + restoreQueue.push(target); + } else { + restoreQueue = [target]; + } + } else { + restoreTarget = target; + } +} +function needsStateRestore() { + return restoreTarget !== null || restoreQueue !== null; +} +function restoreStateIfNeeded() { + if (!restoreTarget) { + return; + } + + var target = restoreTarget; + var queuedTargets = restoreQueue; + restoreTarget = null; + restoreQueue = null; + restoreStateOfTarget(target); + + if (queuedTargets) { + for (var i = 0; i < queuedTargets.length; i++) { + restoreStateOfTarget(queuedTargets[i]); + } + } +} + +var enableUserTimingAPI = true; // Helps identify side effects in render-phase lifecycle hooks and setState +// reducers by double invoking them in Strict Mode. + +var debugRenderPhaseSideEffectsForStrictMode = true; // To preserve the "Pause on caught exceptions" behavior of the debugger, we +// replay the begin phase of a failed component inside invokeGuardedCallback. + +var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: + +var warnAboutDeprecatedLifecycles = true; // Gather advanced timing metrics for Profiler subtrees. + +var enableProfilerTimer = true; // Trace which interactions trigger each commit. + +var enableSchedulerTracing = true; // SSR experiments + +var enableSuspenseServerRenderer = false; +var enableSelectiveHydration = false; // Only used in www builds. + + // Only used in www builds. + + // Disable javascript: URL strings in href for XSS protection. + +var disableJavaScriptURLs = false; // React Fire: prevent the value and checked attributes from syncing +// with their related DOM properties + +var disableInputAttributeSyncing = false; // These APIs will no longer be "unstable" in the upcoming 16.7 release, +// Control this behavior with a flag to support 16.6 minor releases in the meanwhile. + +var exposeConcurrentModeAPIs = false; +var warnAboutShorthandPropertyCollision = false; // Experimental React Flare event system and event components support. + +var enableFlareAPI = false; // Experimental Host Component support. + +var enableFundamentalAPI = false; // Experimental Scope support. + +var enableScopeAPI = false; // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107 + + // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?) +// Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version + +var warnAboutUnmockedScheduler = false; // For tests, we flush suspense fallbacks in an act scope; +// *except* in some of our own tests, where we test incremental loading states. + +var flushSuspenseFallbacksInTests = true; // Add a callback property to suspense to notify which promises are currently +// in the update queue. This allows reporting and tracing of what is causing +// the user to see a loading state. +// Also allows hydration callbacks to fire when a dehydrated boundary gets +// hydrated or deleted. + +var enableSuspenseCallback = false; // Part of the simplification of React.createElement so we can eventually move +// from React.createElement to React.jsx +// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md + +var warnAboutDefaultPropsOnFunctionComponents = false; +var warnAboutStringRefs = false; +var disableLegacyContext = false; +var disableSchedulerTimeoutBasedOnReactExpirationTime = false; +var enableTrustedTypesIntegration = false; // Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance + +// the renderer. Such as when we're dispatching events or if third party +// libraries need to call batchedUpdates. Eventually, this API will go away when +// everything is batched by default. We'll then have a similar API to opt-out of +// scheduled work and instead do synchronous work. +// Defaults + +var batchedUpdatesImpl = function (fn, bookkeeping) { + return fn(bookkeeping); +}; + +var discreteUpdatesImpl = function (fn, a, b, c) { + return fn(a, b, c); +}; + +var flushDiscreteUpdatesImpl = function () {}; + +var batchedEventUpdatesImpl = batchedUpdatesImpl; +var isInsideEventHandler = false; +var isBatchingEventUpdates = false; + +function finishEventHandler() { + // Here we wait until all updates have propagated, which is important + // when using controlled components within layers: + // https://github.com/facebook/react/issues/1698 + // Then we restore state of any controlled component. + var controlledComponentsHavePendingUpdates = needsStateRestore(); + + if (controlledComponentsHavePendingUpdates) { + // If a controlled event was fired, we may need to restore the state of + // the DOM node back to the controlled value. This is necessary when React + // bails out of the update without touching the DOM. + flushDiscreteUpdatesImpl(); + restoreStateIfNeeded(); + } +} + +function batchedUpdates(fn, bookkeeping) { + if (isInsideEventHandler) { + // If we are currently inside another batch, we need to wait until it + // fully completes before restoring state. + return fn(bookkeeping); + } + + isInsideEventHandler = true; + + try { + return batchedUpdatesImpl(fn, bookkeeping); + } finally { + isInsideEventHandler = false; + finishEventHandler(); + } +} +function batchedEventUpdates(fn, a, b) { + if (isBatchingEventUpdates) { + // If we are currently inside another batch, we need to wait until it + // fully completes before restoring state. + return fn(a, b); + } + + isBatchingEventUpdates = true; + + try { + return batchedEventUpdatesImpl(fn, a, b); + } finally { + isBatchingEventUpdates = false; + finishEventHandler(); + } +} // This is for the React Flare event system + +function executeUserEventHandler(fn, value) { + var previouslyInEventHandler = isInsideEventHandler; + + try { + isInsideEventHandler = true; + var type = typeof value === 'object' && value !== null ? value.type : ''; + invokeGuardedCallbackAndCatchFirstError(type, fn, undefined, value); + } finally { + isInsideEventHandler = previouslyInEventHandler; + } +} +function discreteUpdates(fn, a, b, c) { + var prevIsInsideEventHandler = isInsideEventHandler; + isInsideEventHandler = true; + + try { + return discreteUpdatesImpl(fn, a, b, c); + } finally { + isInsideEventHandler = prevIsInsideEventHandler; + + if (!isInsideEventHandler) { + finishEventHandler(); + } + } +} +var lastFlushedEventTimeStamp = 0; +function flushDiscreteUpdatesIfNeeded(timeStamp) { + // event.timeStamp isn't overly reliable due to inconsistencies in + // how different browsers have historically provided the time stamp. + // Some browsers provide high-resolution time stamps for all events, + // some provide low-resolution time stamps for all events. FF < 52 + // even mixes both time stamps together. Some browsers even report + // negative time stamps or time stamps that are 0 (iOS9) in some cases. + // Given we are only comparing two time stamps with equality (!==), + // we are safe from the resolution differences. If the time stamp is 0 + // we bail-out of preventing the flush, which can affect semantics, + // such as if an earlier flush removes or adds event listeners that + // are fired in the subsequent flush. However, this is the same + // behaviour as we had before this change, so the risks are low. + if (!isInsideEventHandler && (!enableFlareAPI || timeStamp === 0 || lastFlushedEventTimeStamp !== timeStamp)) { + lastFlushedEventTimeStamp = timeStamp; + flushDiscreteUpdatesImpl(); + } +} +function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) { + batchedUpdatesImpl = _batchedUpdatesImpl; + discreteUpdatesImpl = _discreteUpdatesImpl; + flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; + batchedEventUpdatesImpl = _batchedEventUpdatesImpl; +} + +var DiscreteEvent = 0; +var UserBlockingEvent = 1; +var ContinuousEvent = 2; + +var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; +var _ReactInternals$Sched = ReactInternals$1.Scheduler; +var unstable_cancelCallback = _ReactInternals$Sched.unstable_cancelCallback; +var unstable_now = _ReactInternals$Sched.unstable_now; +var unstable_scheduleCallback = _ReactInternals$Sched.unstable_scheduleCallback; +var unstable_shouldYield = _ReactInternals$Sched.unstable_shouldYield; +var unstable_requestPaint = _ReactInternals$Sched.unstable_requestPaint; +var unstable_getFirstCallbackNode = _ReactInternals$Sched.unstable_getFirstCallbackNode; +var unstable_runWithPriority = _ReactInternals$Sched.unstable_runWithPriority; +var unstable_next = _ReactInternals$Sched.unstable_next; +var unstable_continueExecution = _ReactInternals$Sched.unstable_continueExecution; +var unstable_pauseExecution = _ReactInternals$Sched.unstable_pauseExecution; +var unstable_getCurrentPriorityLevel = _ReactInternals$Sched.unstable_getCurrentPriorityLevel; +var unstable_ImmediatePriority = _ReactInternals$Sched.unstable_ImmediatePriority; +var unstable_UserBlockingPriority = _ReactInternals$Sched.unstable_UserBlockingPriority; +var unstable_NormalPriority = _ReactInternals$Sched.unstable_NormalPriority; +var unstable_LowPriority = _ReactInternals$Sched.unstable_LowPriority; +var unstable_IdlePriority = _ReactInternals$Sched.unstable_IdlePriority; +var unstable_forceFrameRate = _ReactInternals$Sched.unstable_forceFrameRate; +var unstable_flushAllWithoutAsserting = _ReactInternals$Sched.unstable_flushAllWithoutAsserting; + +// CommonJS interop named imports. + +var UserBlockingPriority = unstable_UserBlockingPriority; +var runWithPriority = unstable_runWithPriority; +var listenToResponderEventTypesImpl; +function setListenToResponderEventTypes(_listenToResponderEventTypesImpl) { + listenToResponderEventTypesImpl = _listenToResponderEventTypesImpl; +} +var rootEventTypesToEventResponderInstances = new Map(); +var DoNotPropagateToNextResponder = 0; +var PropagateToNextResponder = 1; +var currentTimeStamp = 0; +var currentInstance = null; +var currentDocument = null; +var currentPropagationBehavior = DoNotPropagateToNextResponder; +var eventResponderContext = { + dispatchEvent: function (eventValue, eventListener, eventPriority) { + validateResponderContext(); + validateEventValue(eventValue); + + switch (eventPriority) { + case DiscreteEvent: + { + flushDiscreteUpdatesIfNeeded(currentTimeStamp); + discreteUpdates(function () { + return executeUserEventHandler(eventListener, eventValue); + }); + break; + } + + case UserBlockingEvent: + { + runWithPriority(UserBlockingPriority, function () { + return executeUserEventHandler(eventListener, eventValue); + }); + break; + } + + case ContinuousEvent: + { + executeUserEventHandler(eventListener, eventValue); + break; + } + } + }, + isTargetWithinResponder: function (target) { + validateResponderContext(); + + if (target != null) { + var fiber = getClosestInstanceFromNode(target); + var responderFiber = currentInstance.fiber; + + while (fiber !== null) { + if (fiber === responderFiber || fiber.alternate === responderFiber) { + return true; + } + + fiber = fiber.return; + } + } + + return false; + }, + isTargetWithinResponderScope: function (target) { + validateResponderContext(); + var componentInstance = currentInstance; + var responder = componentInstance.responder; + + if (target != null) { + var fiber = getClosestInstanceFromNode(target); + var responderFiber = currentInstance.fiber; + + while (fiber !== null) { + if (fiber === responderFiber || fiber.alternate === responderFiber) { + return true; + } + + if (doesFiberHaveResponder(fiber, responder)) { + return false; + } + + fiber = fiber.return; + } + } + + return false; + }, + isTargetWithinNode: function (childTarget, parentTarget) { + validateResponderContext(); + var childFiber = getClosestInstanceFromNode(childTarget); + var parentFiber = getClosestInstanceFromNode(parentTarget); + + if (childFiber != null && parentFiber != null) { + var parentAlternateFiber = parentFiber.alternate; + var node = childFiber; + + while (node !== null) { + if (node === parentFiber || node === parentAlternateFiber) { + return true; + } + + node = node.return; + } + + return false; + } // Fallback to DOM APIs + + + return parentTarget.contains(childTarget); + }, + addRootEventTypes: function (rootEventTypes) { + validateResponderContext(); + listenToResponderEventTypesImpl(rootEventTypes, currentDocument); + + for (var i = 0; i < rootEventTypes.length; i++) { + var rootEventType = rootEventTypes[i]; + var eventResponderInstance = currentInstance; + registerRootEventType(rootEventType, eventResponderInstance); + } + }, + removeRootEventTypes: function (rootEventTypes) { + validateResponderContext(); + + for (var i = 0; i < rootEventTypes.length; i++) { + var rootEventType = rootEventTypes[i]; + var rootEventResponders = rootEventTypesToEventResponderInstances.get(rootEventType); + var rootEventTypesSet = currentInstance.rootEventTypes; + + if (rootEventTypesSet !== null) { + rootEventTypesSet.delete(rootEventType); + } + + if (rootEventResponders !== undefined) { + rootEventResponders.delete(currentInstance); + } + } + }, + getActiveDocument: getActiveDocument, + objectAssign: _assign, + getTimeStamp: function () { + validateResponderContext(); + return currentTimeStamp; + }, + isTargetWithinHostComponent: function (target, elementType) { + validateResponderContext(); + var fiber = getClosestInstanceFromNode(target); + + while (fiber !== null) { + if (fiber.tag === HostComponent && fiber.type === elementType) { + return true; + } + + fiber = fiber.return; + } + + return false; + }, + continuePropagation: function () { + currentPropagationBehavior = PropagateToNextResponder; + }, + enqueueStateRestore: enqueueStateRestore, + getResponderNode: function () { + validateResponderContext(); + var responderFiber = currentInstance.fiber; + + if (responderFiber.tag === ScopeComponent) { + return null; + } + + return responderFiber.stateNode; + } +}; + +function validateEventValue(eventValue) { + if (typeof eventValue === 'object' && eventValue !== null) { + var target = eventValue.target, + type = eventValue.type, + timeStamp = eventValue.timeStamp; + + if (target == null || type == null || timeStamp == null) { + throw new Error('context.dispatchEvent: "target", "timeStamp", and "type" fields on event object are required.'); + } + + var showWarning = function (name) { + { + warning$1(false, '%s is not available on event objects created from event responder modules (React Flare). ' + 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.%s }`', name, name); + } + }; + + eventValue.isDefaultPrevented = function () { + { + showWarning('isDefaultPrevented()'); + } + }; + + eventValue.isPropagationStopped = function () { + { + showWarning('isPropagationStopped()'); + } + }; // $FlowFixMe: we don't need value, Flow thinks we do + + + Object.defineProperty(eventValue, 'nativeEvent', { + get: function () { + { + showWarning('nativeEvent'); + } + } + }); + } +} + +function doesFiberHaveResponder(fiber, responder) { + var tag = fiber.tag; + + if (tag === HostComponent || tag === ScopeComponent) { + var dependencies = fiber.dependencies; + + if (dependencies !== null) { + var respondersMap = dependencies.responders; + + if (respondersMap !== null && respondersMap.has(responder)) { + return true; + } + } + } + + return false; +} + +function getActiveDocument() { + return currentDocument; +} + +function createDOMResponderEvent(topLevelType, nativeEvent, nativeEventTarget, passive, passiveSupported) { + var _ref = nativeEvent, + buttons = _ref.buttons, + pointerType = _ref.pointerType; + var eventPointerType = ''; + + if (pointerType !== undefined) { + eventPointerType = pointerType; + } else if (nativeEvent.key !== undefined) { + eventPointerType = 'keyboard'; + } else if (buttons !== undefined) { + eventPointerType = 'mouse'; + } else if (nativeEvent.changedTouches !== undefined) { + eventPointerType = 'touch'; + } + + return { + nativeEvent: nativeEvent, + passive: passive, + passiveSupported: passiveSupported, + pointerType: eventPointerType, + target: nativeEventTarget, + type: topLevelType + }; +} + +function responderEventTypesContainType(eventTypes, type) { + for (var i = 0, len = eventTypes.length; i < len; i++) { + if (eventTypes[i] === type) { + return true; + } + } + + return false; +} + +function validateResponderTargetEventTypes(eventType, responder) { + var targetEventTypes = responder.targetEventTypes; // Validate the target event type exists on the responder + + if (targetEventTypes !== null) { + return responderEventTypesContainType(targetEventTypes, eventType); + } + + return false; +} + +function traverseAndHandleEventResponderInstances(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags) { + var isPassiveEvent = (eventSystemFlags & IS_PASSIVE) !== 0; + var isPassiveSupported = (eventSystemFlags & PASSIVE_NOT_SUPPORTED) === 0; + var isPassive = isPassiveEvent || !isPassiveSupported; + var eventType = isPassive ? topLevelType : topLevelType + '_active'; // Trigger event responders in this order: + // - Bubble target responder phase + // - Root responder phase + + var visitedResponders = new Set(); + var responderEvent = createDOMResponderEvent(topLevelType, nativeEvent, nativeEventTarget, isPassiveEvent, isPassiveSupported); + var node = targetFiber; + var insidePortal = false; + + while (node !== null) { + var _node = node, + dependencies = _node.dependencies, + tag = _node.tag; + + if (tag === HostPortal) { + insidePortal = true; + } else if ((tag === HostComponent || tag === ScopeComponent) && dependencies !== null) { + var respondersMap = dependencies.responders; + + if (respondersMap !== null) { + var responderInstances = Array.from(respondersMap.values()); + + for (var i = 0, length = responderInstances.length; i < length; i++) { + var responderInstance = responderInstances[i]; + var props = responderInstance.props, + responder = responderInstance.responder, + state = responderInstance.state; + + if (!visitedResponders.has(responder) && validateResponderTargetEventTypes(eventType, responder) && (!insidePortal || responder.targetPortalPropagation)) { + visitedResponders.add(responder); + var onEvent = responder.onEvent; + + if (onEvent !== null) { + currentInstance = responderInstance; + onEvent(responderEvent, eventResponderContext, props, state); + + if (currentPropagationBehavior === PropagateToNextResponder) { + visitedResponders.delete(responder); + currentPropagationBehavior = DoNotPropagateToNextResponder; + } + } + } + } + } + } + + node = node.return; + } // Root phase + + + var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(eventType); + + if (rootEventResponderInstances !== undefined) { + var _responderInstances = Array.from(rootEventResponderInstances); + + for (var _i = 0; _i < _responderInstances.length; _i++) { + var _responderInstance = _responderInstances[_i]; + var props = _responderInstance.props, + responder = _responderInstance.responder, + state = _responderInstance.state; + var onRootEvent = responder.onRootEvent; + + if (onRootEvent !== null) { + currentInstance = _responderInstance; + onRootEvent(responderEvent, eventResponderContext, props, state); + } + } + } +} + +function mountEventResponder(responder, responderInstance, props, state) { + var onMount = responder.onMount; + + if (onMount !== null) { + var previousInstance = currentInstance; + currentInstance = responderInstance; + + try { + batchedEventUpdates(function () { + onMount(eventResponderContext, props, state); + }); + } finally { + currentInstance = previousInstance; + } + } +} +function unmountEventResponder(responderInstance) { + var responder = responderInstance.responder; + var onUnmount = responder.onUnmount; + + if (onUnmount !== null) { + var props = responderInstance.props, + state = responderInstance.state; + var previousInstance = currentInstance; + currentInstance = responderInstance; + + try { + batchedEventUpdates(function () { + onUnmount(eventResponderContext, props, state); + }); + } finally { + currentInstance = previousInstance; + } + } + + var rootEventTypesSet = responderInstance.rootEventTypes; + + if (rootEventTypesSet !== null) { + var rootEventTypes = Array.from(rootEventTypesSet); + + for (var i = 0; i < rootEventTypes.length; i++) { + var topLevelEventType = rootEventTypes[i]; + var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(topLevelEventType); + + if (rootEventResponderInstances !== undefined) { + rootEventResponderInstances.delete(responderInstance); + } + } + } +} + +function validateResponderContext() { + if (!(currentInstance !== null)) { + { + throw Error("An event responder context was used outside of an event cycle."); + } + } +} + +function dispatchEventForResponderEventSystem(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags) { + if (enableFlareAPI) { + var previousInstance = currentInstance; + var previousTimeStamp = currentTimeStamp; + var previousDocument = currentDocument; + var previousPropagationBehavior = currentPropagationBehavior; + currentPropagationBehavior = DoNotPropagateToNextResponder; // nodeType 9 is DOCUMENT_NODE + + currentDocument = nativeEventTarget.nodeType === 9 ? nativeEventTarget : nativeEventTarget.ownerDocument; // We might want to control timeStamp another way here + + currentTimeStamp = nativeEvent.timeStamp; + + try { + batchedEventUpdates(function () { + traverseAndHandleEventResponderInstances(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags); + }); + } finally { + currentInstance = previousInstance; + currentTimeStamp = previousTimeStamp; + currentDocument = previousDocument; + currentPropagationBehavior = previousPropagationBehavior; + } + } +} +function addRootEventTypesForResponderInstance(responderInstance, rootEventTypes) { + for (var i = 0; i < rootEventTypes.length; i++) { + var rootEventType = rootEventTypes[i]; + registerRootEventType(rootEventType, responderInstance); + } +} + +function registerRootEventType(rootEventType, eventResponderInstance) { + var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(rootEventType); + + if (rootEventResponderInstances === undefined) { + rootEventResponderInstances = new Set(); + rootEventTypesToEventResponderInstances.set(rootEventType, rootEventResponderInstances); + } + + var rootEventTypesSet = eventResponderInstance.rootEventTypes; + + if (rootEventTypesSet === null) { + rootEventTypesSet = eventResponderInstance.rootEventTypes = new Set(); + } + + if (!!rootEventTypesSet.has(rootEventType)) { + { + throw Error("addRootEventTypes() found a duplicate root event type of \"" + rootEventType + "\". This might be because the event type exists in the event responder \"rootEventTypes\" array or because of a previous addRootEventTypes() using this root event type."); + } + } + + rootEventTypesSet.add(rootEventType); + rootEventResponderInstances.add(eventResponderInstance); +} + +// A reserved attribute. +// It is handled by React separately and shouldn't be written to the DOM. +var RESERVED = 0; // A simple string attribute. +// Attributes that aren't in the whitelist are presumed to have this type. + +var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called +// "enumerated" attributes with "true" and "false" as possible values. +// When true, it should be set to a "true" string. +// When false, it should be set to a "false" string. + +var BOOLEANISH_STRING = 2; // A real boolean attribute. +// When true, it should be present (set either to an empty string or its name). +// When false, it should be omitted. + +var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value. +// When true, it should be present (set either to an empty string or its name). +// When false, it should be omitted. +// For any other value, should be present with that value. + +var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric. +// When falsy, it should be removed. + +var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric. +// When falsy, it should be removed. + +var POSITIVE_NUMERIC = 6; + +/* eslint-disable max-len */ +var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; +/* eslint-enable max-len */ + +var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; + +var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; +var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); +var hasOwnProperty = Object.prototype.hasOwnProperty; +var illegalAttributeNameCache = {}; +var validatedAttributeNameCache = {}; +function isAttributeNameSafe(attributeName) { + if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) { + return true; + } + + if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) { + return false; + } + + if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { + validatedAttributeNameCache[attributeName] = true; + return true; + } + + illegalAttributeNameCache[attributeName] = true; + + { + warning$1(false, 'Invalid attribute name: `%s`', attributeName); + } + + return false; +} +function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) { + if (propertyInfo !== null) { + return propertyInfo.type === RESERVED; + } + + if (isCustomComponentTag) { + return false; + } + + if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { + return true; + } + + return false; +} +function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { + if (propertyInfo !== null && propertyInfo.type === RESERVED) { + return false; + } + + switch (typeof value) { + case 'function': // $FlowIssue symbol is perfectly valid here + + case 'symbol': + // eslint-disable-line + return true; + + case 'boolean': + { + if (isCustomComponentTag) { + return false; + } + + if (propertyInfo !== null) { + return !propertyInfo.acceptsBooleans; + } else { + var prefix = name.toLowerCase().slice(0, 5); + return prefix !== 'data-' && prefix !== 'aria-'; + } + } + + default: + return false; + } +} +function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { + if (value === null || typeof value === 'undefined') { + return true; + } + + if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) { + return true; + } + + if (isCustomComponentTag) { + return false; + } + + if (propertyInfo !== null) { + switch (propertyInfo.type) { + case BOOLEAN: + return !value; + + case OVERLOADED_BOOLEAN: + return value === false; + + case NUMERIC: + return isNaN(value); + + case POSITIVE_NUMERIC: + return isNaN(value) || value < 1; + } + } + + return false; +} +function getPropertyInfo(name) { + return properties.hasOwnProperty(name) ? properties[name] : null; +} + +function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) { + this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; + this.attributeName = attributeName; + this.attributeNamespace = attributeNamespace; + this.mustUseProperty = mustUseProperty; + this.propertyName = name; + this.type = type; + this.sanitizeURL = sanitizeURL; +} // When adding attributes to this list, be sure to also add them to +// the `possibleStandardNames` module to ensure casing and incorrect +// name warnings. + + +var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM. + +['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular +// elements (not just inputs). Now that ReactDOMInput assigns to the +// defaultValue property -- do we need this? +'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty + name, // attributeName + null, // attributeNamespace + false); +}); // A few React string attributes have a different name. +// This is a mapping from React prop names to the attribute names. + +[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { + var name = _ref[0], + attributeName = _ref[1]; + properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty + attributeName, // attributeName + null, // attributeNamespace + false); +}); // These are "enumerated" HTML attributes that accept "true" and "false". +// In React, we let users pass `true` and `false` even though technically +// these aren't boolean attributes (they are coerced to strings). + +['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty + name.toLowerCase(), // attributeName + null, // attributeNamespace + false); +}); // These are "enumerated" SVG attributes that accept "true" and "false". +// In React, we let users pass `true` and `false` even though technically +// these aren't boolean attributes (they are coerced to strings). +// Since these are SVG attributes, their attribute names are case-sensitive. + +['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty + name, // attributeName + null, // attributeNamespace + false); +}); // These are HTML boolean attributes. + +['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM +// on the client side because the browsers are inconsistent. Instead we call focus(). +'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata +'itemScope'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty + name.toLowerCase(), // attributeName + null, // attributeNamespace + false); +}); // These are the few React props that we set as DOM properties +// rather than attributes. These are all booleans. + +['checked', // Note: `option.selected` is not updated if `select.multiple` is +// disabled with `removeAttribute`. We have special logic for handling this. +'multiple', 'muted', 'selected'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty + name, // attributeName + null, // attributeNamespace + false); +}); // These are HTML attributes that are "overloaded booleans": they behave like +// booleans, but can also accept a string value. + +['capture', 'download'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty + name, // attributeName + null, // attributeNamespace + false); +}); // These are HTML attributes that must be positive numbers. + +['cols', 'rows', 'size', 'span'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty + name, // attributeName + null, // attributeNamespace + false); +}); // These are HTML attributes that must be numbers. + +['rowSpan', 'start'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty + name.toLowerCase(), // attributeName + null, // attributeNamespace + false); +}); +var CAMELIZE = /[\-\:]([a-z])/g; + +var capitalize = function (token) { + return token[1].toUpperCase(); +}; // This is a list of all SVG attributes that need special casing, namespacing, +// or boolean value assignment. Regular attributes that just accept strings +// and have the same names are omitted, just like in the HTML whitelist. +// Some of these attributes can be hard to find. This list was created by +// scrapping the MDN documentation. + + +['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height'].forEach(function (attributeName) { + var name = attributeName.replace(CAMELIZE, capitalize); + properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty + attributeName, null, // attributeNamespace + false); +}); // String SVG attributes with the xlink namespace. + +['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) { + var name = attributeName.replace(CAMELIZE, capitalize); + properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty + attributeName, 'http://www.w3.org/1999/xlink', false); +}); // String SVG attributes with the xml namespace. + +['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) { + var name = attributeName.replace(CAMELIZE, capitalize); + properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty + attributeName, 'http://www.w3.org/XML/1998/namespace', false); +}); // These attribute exists both in HTML and SVG. +// The attribute name is case-sensitive in SVG so we can't just use +// the React name like we do for attributes that exist only in HTML. + +['tabIndex', 'crossOrigin'].forEach(function (attributeName) { + properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty + attributeName.toLowerCase(), // attributeName + null, // attributeNamespace + false); +}); // These attributes accept URLs. These must not allow javascript: URLS. +// These will also need to accept Trusted Types object in the future. + +var xlinkHref = 'xlinkHref'; +properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty +'xlink:href', 'http://www.w3.org/1999/xlink', true); +['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { + properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty + attributeName.toLowerCase(), // attributeName + null, // attributeNamespace + true); +}); + +var ReactDebugCurrentFrame$1 = null; + +{ + ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; +} // A javascript: URL can contain leading C0 control or \u0020 SPACE, +// and any newline or tab are filtered out as if they're not part of the URL. +// https://url.spec.whatwg.org/#url-parsing +// Tab or newline are defined as \r\n\t: +// https://infra.spec.whatwg.org/#ascii-tab-or-newline +// A C0 control is a code point in the range \u0000 NULL to \u001F +// INFORMATION SEPARATOR ONE, inclusive: +// https://infra.spec.whatwg.org/#c0-control-or-space + +/* eslint-disable max-len */ + + +var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i; +var didWarn = false; + +function sanitizeURL(url) { + if (disableJavaScriptURLs) { + if (!!isJavaScriptProtocol.test(url)) { + { + throw Error("React has blocked a javascript: URL as a security precaution." + (ReactDebugCurrentFrame$1.getStackAddendum())); + } + } + } else if (true && !didWarn && isJavaScriptProtocol.test(url)) { + didWarn = true; + warning$1(false, 'A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url)); + } +} + +// Flow does not allow string concatenation of most non-string types. To work +// around this limitation, we use an opaque type that can only be obtained by +// passing the value through getToStringValue first. +function toString(value) { + return '' + value; +} +function getToStringValue(value) { + switch (typeof value) { + case 'boolean': + case 'number': + case 'object': + case 'string': + case 'undefined': + return value; + + default: + // function, symbol are assigned as empty strings + return ''; + } +} +/** Trusted value is a wrapper for "safe" values which can be assigned to DOM execution sinks. */ + +/** + * We allow passing objects with toString method as element attributes or in dangerouslySetInnerHTML + * and we do validations that the value is safe. Once we do validation we want to use the validated + * value instead of the object (because object.toString may return something else on next call). + * + * If application uses Trusted Types we don't stringify trusted values, but preserve them as objects. + */ +var toStringOrTrustedType = toString; + +if (enableTrustedTypesIntegration && typeof trustedTypes !== 'undefined') { + toStringOrTrustedType = function (value) { + if (typeof value === 'object' && (trustedTypes.isHTML(value) || trustedTypes.isScript(value) || trustedTypes.isScriptURL(value) || + /* TrustedURLs are deprecated and will be removed soon: https://github.com/WICG/trusted-types/pull/204 */ + trustedTypes.isURL && trustedTypes.isURL(value))) { + // Pass Trusted Types through. + return value; + } + + return toString(value); + }; +} + +/** + * Set attribute for a node. The attribute value can be either string or + * Trusted value (if application uses Trusted Types). + */ +function setAttribute(node, attributeName, attributeValue) { + node.setAttribute(attributeName, attributeValue); +} +/** + * Set attribute with namespace for a node. The attribute value can be either string or + * Trusted value (if application uses Trusted Types). + */ + +function setAttributeNS(node, attributeNamespace, attributeName, attributeValue) { + node.setAttributeNS(attributeNamespace, attributeName, attributeValue); +} + +/** + * Get the value for a property on a node. Only used in DEV for SSR validation. + * The "expected" argument is used as a hint of what the expected value is. + * Some properties have multiple equivalent values. + */ +function getValueForProperty(node, name, expected, propertyInfo) { + { + if (propertyInfo.mustUseProperty) { + var propertyName = propertyInfo.propertyName; + return node[propertyName]; + } else { + if (!disableJavaScriptURLs && propertyInfo.sanitizeURL) { + // If we haven't fully disabled javascript: URLs, and if + // the hydration is successful of a javascript: URL, we + // still want to warn on the client. + sanitizeURL('' + expected); + } + + var attributeName = propertyInfo.attributeName; + var stringValue = null; + + if (propertyInfo.type === OVERLOADED_BOOLEAN) { + if (node.hasAttribute(attributeName)) { + var value = node.getAttribute(attributeName); + + if (value === '') { + return true; + } + + if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { + return value; + } + + if (value === '' + expected) { + return expected; + } + + return value; + } + } else if (node.hasAttribute(attributeName)) { + if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { + // We had an attribute but shouldn't have had one, so read it + // for the error message. + return node.getAttribute(attributeName); + } + + if (propertyInfo.type === BOOLEAN) { + // If this was a boolean, it doesn't matter what the value is + // the fact that we have it is the same as the expected. + return expected; + } // Even if this property uses a namespace we use getAttribute + // because we assume its namespaced name is the same as our config. + // To use getAttributeNS we need the local name which we don't have + // in our config atm. + + + stringValue = node.getAttribute(attributeName); + } + + if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { + return stringValue === null ? expected : stringValue; + } else if (stringValue === '' + expected) { + return expected; + } else { + return stringValue; + } + } + } +} +/** + * Get the value for a attribute on a node. Only used in DEV for SSR validation. + * The third argument is used as a hint of what the expected value is. Some + * attributes have multiple equivalent values. + */ + +function getValueForAttribute(node, name, expected) { + { + if (!isAttributeNameSafe(name)) { + return; + } + + if (!node.hasAttribute(name)) { + return expected === undefined ? undefined : null; + } + + var value = node.getAttribute(name); + + if (value === '' + expected) { + return expected; + } + + return value; + } +} +/** + * Sets the value for a property on a node. + * + * @param {DOMElement} node + * @param {string} name + * @param {*} value + */ + +function setValueForProperty(node, name, value, isCustomComponentTag) { + var propertyInfo = getPropertyInfo(name); + + if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) { + return; + } + + if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { + value = null; + } // If the prop isn't in the special list, treat it as a simple attribute. + + + if (isCustomComponentTag || propertyInfo === null) { + if (isAttributeNameSafe(name)) { + var _attributeName = name; + + if (value === null) { + node.removeAttribute(_attributeName); + } else { + setAttribute(node, _attributeName, toStringOrTrustedType(value)); + } + } + + return; + } + + var mustUseProperty = propertyInfo.mustUseProperty; + + if (mustUseProperty) { + var propertyName = propertyInfo.propertyName; + + if (value === null) { + var type = propertyInfo.type; + node[propertyName] = type === BOOLEAN ? false : ''; + } else { + // Contrary to `setAttribute`, object properties are properly + // `toString`ed by IE8/9. + node[propertyName] = value; + } + + return; + } // The rest are treated as attributes with special cases. + + + var attributeName = propertyInfo.attributeName, + attributeNamespace = propertyInfo.attributeNamespace; + + if (value === null) { + node.removeAttribute(attributeName); + } else { + var _type = propertyInfo.type; + var attributeValue; + + if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) { + // If attribute type is boolean, we know for sure it won't be an execution sink + // and we won't require Trusted Type here. + attributeValue = ''; + } else { + // `setAttribute` with objects becomes only `[object]` in IE8/9, + // ('' + value) makes it output the correct toString()-value. + attributeValue = toStringOrTrustedType(value); + + if (propertyInfo.sanitizeURL) { + sanitizeURL(attributeValue.toString()); + } + } + + if (attributeNamespace) { + setAttributeNS(node, attributeNamespace, attributeName, attributeValue); + } else { + setAttribute(node, attributeName, attributeValue); + } + } +} + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + +var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; + +var ReactPropTypesSecret_1 = ReactPropTypesSecret$1; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + +var printWarning = function() {}; + +{ + var ReactPropTypesSecret = ReactPropTypesSecret_1; + var loggedTypeFailures = {}; + var has = Function.call.bind(Object.prototype.hasOwnProperty); + + printWarning = function(text) { + var message = 'Warning: ' + text; + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; +} + +/** + * Assert that the values match with the type specs. + * Error messages are memorized and will only be shown once. + * + * @param {object} typeSpecs Map of name to a ReactPropType + * @param {object} values Runtime values that need to be type-checked + * @param {string} location e.g. "prop", "context", "child context" + * @param {string} componentName Name of the component for error messages. + * @param {?Function} getStack Returns the component stack. + * @private + */ +function checkPropTypes(typeSpecs, values, location, componentName, getStack) { + { + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, typeSpecName)) { + var error; + // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== 'function') { + var err = Error( + (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + ); + err.name = 'Invariant Violation'; + throw err; + } + error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); + } catch (ex) { + error = ex; + } + if (error && !(error instanceof Error)) { + printWarning( + (componentName || 'React class') + ': type specification of ' + + location + ' `' + typeSpecName + '` is invalid; the type checker ' + + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + + 'You may have forgotten to pass an argument to the type checker ' + + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + + 'shape all require an argument).' + ); + } + if (error instanceof Error && !(error.message in loggedTypeFailures)) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error.message] = true; + + var stack = getStack ? getStack() : ''; + + printWarning( + 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') + ); + } + } + } + } +} + +/** + * Resets warning cache when testing. + * + * @private + */ +checkPropTypes.resetWarningCache = function() { + { + loggedTypeFailures = {}; + } +}; + +var checkPropTypes_1 = checkPropTypes; + +var ReactDebugCurrentFrame$2 = null; +var ReactControlledValuePropTypes = { + checkPropTypes: null +}; + +{ + ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame; + var hasReadOnlyValue = { + button: true, + checkbox: true, + image: true, + hidden: true, + radio: true, + reset: true, + submit: true + }; + var propTypes = { + value: function (props, propName, componentName) { + if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) { + return null; + } + + return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); + }, + checked: function (props, propName, componentName) { + if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) { + return null; + } + + return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); + } + }; + /** + * Provide a linked `value` attribute for controlled forms. You should not use + * this outside of the ReactDOM controlled form components. + */ + + ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) { + checkPropTypes_1(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum); + }; +} + +function isCheckable(elem) { + var type = elem.type; + var nodeName = elem.nodeName; + return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); +} + +function getTracker(node) { + return node._valueTracker; +} + +function detachTracker(node) { + node._valueTracker = null; +} + +function getValueFromNode(node) { + var value = ''; + + if (!node) { + return value; + } + + if (isCheckable(node)) { + value = node.checked ? 'true' : 'false'; + } else { + value = node.value; + } + + return value; +} + +function trackValueOnNode(node) { + var valueField = isCheckable(node) ? 'checked' : 'value'; + var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); + var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail + // and don't track value will cause over reporting of changes, + // but it's better then a hard failure + // (needed for certain tests that spyOn input values and Safari) + + if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { + return; + } + + var get = descriptor.get, + set = descriptor.set; + Object.defineProperty(node, valueField, { + configurable: true, + get: function () { + return get.call(this); + }, + set: function (value) { + currentValue = '' + value; + set.call(this, value); + } + }); // We could've passed this the first time + // but it triggers a bug in IE11 and Edge 14/15. + // Calling defineProperty() again should be equivalent. + // https://github.com/facebook/react/issues/11768 + + Object.defineProperty(node, valueField, { + enumerable: descriptor.enumerable + }); + var tracker = { + getValue: function () { + return currentValue; + }, + setValue: function (value) { + currentValue = '' + value; + }, + stopTracking: function () { + detachTracker(node); + delete node[valueField]; + } + }; + return tracker; +} + +function track(node) { + if (getTracker(node)) { + return; + } // TODO: Once it's just Fiber we can move this to node._wrapperState + + + node._valueTracker = trackValueOnNode(node); +} +function updateValueIfChanged(node) { + if (!node) { + return false; + } + + var tracker = getTracker(node); // if there is no tracker at this point it's unlikely + // that trying again will succeed + + if (!tracker) { + return true; + } + + var lastValue = tracker.getValue(); + var nextValue = getValueFromNode(node); + + if (nextValue !== lastValue) { + tracker.setValue(nextValue); + return true; + } + + return false; +} + +// TODO: direct imports like some-package/src/* are bad. Fix me. +var didWarnValueDefaultValue = false; +var didWarnCheckedDefaultChecked = false; +var didWarnControlledToUncontrolled = false; +var didWarnUncontrolledToControlled = false; + +function isControlled(props) { + var usesChecked = props.type === 'checkbox' || props.type === 'radio'; + return usesChecked ? props.checked != null : props.value != null; +} +/** + * Implements an host component that allows setting these optional + * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. + * + * If `checked` or `value` are not supplied (or null/undefined), user actions + * that affect the checked state or value will trigger updates to the element. + * + * If they are supplied (and not null/undefined), the rendered element will not + * trigger updates to the element. Instead, the props must change in order for + * the rendered element to be updated. + * + * The rendered element will be initialized as unchecked (or `defaultChecked`) + * with an empty value (or `defaultValue`). + * + * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html + */ + + +function getHostProps(element, props) { + var node = element; + var checked = props.checked; + + var hostProps = _assign({}, props, { + defaultChecked: undefined, + defaultValue: undefined, + value: undefined, + checked: checked != null ? checked : node._wrapperState.initialChecked + }); + + return hostProps; +} +function initWrapperState(element, props) { + { + ReactControlledValuePropTypes.checkPropTypes('input', props); + + if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { + warning$1(false, '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); + didWarnCheckedDefaultChecked = true; + } + + if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { + warning$1(false, '%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); + didWarnValueDefaultValue = true; + } + } + + var node = element; + var defaultValue = props.defaultValue == null ? '' : props.defaultValue; + node._wrapperState = { + initialChecked: props.checked != null ? props.checked : props.defaultChecked, + initialValue: getToStringValue(props.value != null ? props.value : defaultValue), + controlled: isControlled(props) + }; +} +function updateChecked(element, props) { + var node = element; + var checked = props.checked; + + if (checked != null) { + setValueForProperty(node, 'checked', checked, false); + } +} +function updateWrapper(element, props) { + var node = element; + + { + var controlled = isControlled(props); + + if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { + warning$1(false, 'A component is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type); + didWarnUncontrolledToControlled = true; + } + + if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { + warning$1(false, 'A component is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type); + didWarnControlledToUncontrolled = true; + } + } + + updateChecked(element, props); + var value = getToStringValue(props.value); + var type = props.type; + + if (value != null) { + if (type === 'number') { + if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible. + // eslint-disable-next-line + node.value != value) { + node.value = toString(value); + } + } else if (node.value !== toString(value)) { + node.value = toString(value); + } + } else if (type === 'submit' || type === 'reset') { + // Submit/reset inputs need the attribute removed completely to avoid + // blank-text buttons. + node.removeAttribute('value'); + return; + } + + if (disableInputAttributeSyncing) { + // When not syncing the value attribute, React only assigns a new value + // whenever the defaultValue React prop has changed. When not present, + // React does nothing + if (props.hasOwnProperty('defaultValue')) { + setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); + } + } else { + // When syncing the value attribute, the value comes from a cascade of + // properties: + // 1. The value React property + // 2. The defaultValue React property + // 3. Otherwise there should be no change + if (props.hasOwnProperty('value')) { + setDefaultValue(node, props.type, value); + } else if (props.hasOwnProperty('defaultValue')) { + setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); + } + } + + if (disableInputAttributeSyncing) { + // When not syncing the checked attribute, the attribute is directly + // controllable from the defaultValue React property. It needs to be + // updated as new props come in. + if (props.defaultChecked == null) { + node.removeAttribute('checked'); + } else { + node.defaultChecked = !!props.defaultChecked; + } + } else { + // When syncing the checked attribute, it only changes when it needs + // to be removed, such as transitioning from a checkbox into a text input + if (props.checked == null && props.defaultChecked != null) { + node.defaultChecked = !!props.defaultChecked; + } + } +} +function postMountWrapper(element, props, isHydrating) { + var node = element; // Do not assign value if it is already set. This prevents user text input + // from being lost during SSR hydration. + + if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { + var type = props.type; + var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the + // default value provided by the browser. See: #12872 + + if (isButton && (props.value === undefined || props.value === null)) { + return; + } + + var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input + // from being lost during SSR hydration. + + if (!isHydrating) { + if (disableInputAttributeSyncing) { + var value = getToStringValue(props.value); // When not syncing the value attribute, the value property points + // directly to the React prop. Only assign it if it exists. + + if (value != null) { + // Always assign on buttons so that it is possible to assign an + // empty string to clear button text. + // + // Otherwise, do not re-assign the value property if is empty. This + // potentially avoids a DOM write and prevents Firefox (~60.0.1) from + // prematurely marking required inputs as invalid. Equality is compared + // to the current value in case the browser provided value is not an + // empty string. + if (isButton || value !== node.value) { + node.value = toString(value); + } + } + } else { + // When syncing the value attribute, the value property should use + // the wrapperState._initialValue property. This uses: + // + // 1. The value React property when present + // 2. The defaultValue React property when present + // 3. An empty string + if (initialValue !== node.value) { + node.value = initialValue; + } + } + } + + if (disableInputAttributeSyncing) { + // When not syncing the value attribute, assign the value attribute + // directly from the defaultValue React property (when present) + var defaultValue = getToStringValue(props.defaultValue); + + if (defaultValue != null) { + node.defaultValue = toString(defaultValue); + } + } else { + // Otherwise, the value attribute is synchronized to the property, + // so we assign defaultValue to the same thing as the value property + // assignment step above. + node.defaultValue = initialValue; + } + } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug + // this is needed to work around a chrome bug where setting defaultChecked + // will sometimes influence the value of checked (even after detachment). + // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 + // We need to temporarily unset name to avoid disrupting radio button groups. + + + var name = node.name; + + if (name !== '') { + node.name = ''; + } + + if (disableInputAttributeSyncing) { + // When not syncing the checked attribute, the checked property + // never gets assigned. It must be manually set. We don't want + // to do this when hydrating so that existing user input isn't + // modified + if (!isHydrating) { + updateChecked(element, props); + } // Only assign the checked attribute if it is defined. This saves + // a DOM write when controlling the checked attribute isn't needed + // (text inputs, submit/reset) + + + if (props.hasOwnProperty('defaultChecked')) { + node.defaultChecked = !node.defaultChecked; + node.defaultChecked = !!props.defaultChecked; + } + } else { + // When syncing the checked attribute, both the checked property and + // attribute are assigned at the same time using defaultChecked. This uses: + // + // 1. The checked React property when present + // 2. The defaultChecked React property when present + // 3. Otherwise, false + node.defaultChecked = !node.defaultChecked; + node.defaultChecked = !!node._wrapperState.initialChecked; + } + + if (name !== '') { + node.name = name; + } +} +function restoreControlledState$1(element, props) { + var node = element; + updateWrapper(node, props); + updateNamedCousins(node, props); +} + +function updateNamedCousins(rootNode, props) { + var name = props.name; + + if (props.type === 'radio' && name != null) { + var queryRoot = rootNode; + + while (queryRoot.parentNode) { + queryRoot = queryRoot.parentNode; + } // If `rootNode.form` was non-null, then we could try `form.elements`, + // but that sometimes behaves strangely in IE8. We could also try using + // `form.getElementsByName`, but that will only return direct children + // and won't include inputs that use the HTML5 `form=` attribute. Since + // the input might not even be in a form. It might not even be in the + // document. Let's just use the local `querySelectorAll` to ensure we don't + // miss anything. + + + var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); + + for (var i = 0; i < group.length; i++) { + var otherNode = group[i]; + + if (otherNode === rootNode || otherNode.form !== rootNode.form) { + continue; + } // This will throw if radio buttons rendered by different copies of React + // and the same name are rendered into the same form (same as #1939). + // That's probably okay; we don't support it just as we don't support + // mixing React radio buttons with non-React ones. + + + var otherProps = getFiberCurrentPropsFromNode$1(otherNode); + + if (!otherProps) { + { + throw Error("ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported."); + } + } // We need update the tracked value on the named cousin since the value + // was changed but the input saw no event or value set + + + updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that + // was previously checked to update will cause it to be come re-checked + // as appropriate. + + updateWrapper(otherNode, otherProps); + } + } +} // In Chrome, assigning defaultValue to certain input types triggers input validation. +// For number inputs, the display value loses trailing decimal points. For email inputs, +// Chrome raises "The specified value is not a valid email address". +// +// Here we check to see if the defaultValue has actually changed, avoiding these problems +// when the user is inputting text +// +// https://github.com/facebook/react/issues/7253 + + +function setDefaultValue(node, type, value) { + if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js + type !== 'number' || node.ownerDocument.activeElement !== node) { + if (value == null) { + node.defaultValue = toString(node._wrapperState.initialValue); + } else if (node.defaultValue !== toString(value)) { + node.defaultValue = toString(value); + } + } +} + +var didWarnSelectedSetOnOption = false; +var didWarnInvalidChild = false; + +function flattenChildren(children) { + var content = ''; // Flatten children. We'll warn if they are invalid + // during validateProps() which runs for hydration too. + // Note that this would throw on non-element objects. + // Elements are stringified (which is normally irrelevant + // but matters for ). + + React.Children.forEach(children, function (child) { + if (child == null) { + return; + } + + content += child; // Note: we don't warn about invalid children here. + // Instead, this is done separately below so that + // it happens during the hydration codepath too. + }); + return content; +} +/** + * Implements an