diff --git a/.gitattributes b/.gitattributes
index 8c559a7ffba835b080e0add34fcc1c8f2231f3cf..9a78d34c446aa57c5376ccb10a3941dd956f0154 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,11 @@
# Exclude tests data file from programming stats on Github
tests/data/** linguist-vendored
+src/interface/desktop/assets/icons/favicon-128x128.ico filter=lfs diff=lfs merge=lfs -text
+src/interface/desktop/assets/icons/favicon.ico filter=lfs diff=lfs merge=lfs -text
+src/interface/web/public/assets/icons/khoj_lantern.ico filter=lfs diff=lfs merge=lfs -text
+src/interface/web/public/assets/samples/desktop-browse-draw-sample.png filter=lfs diff=lfs merge=lfs -text
+src/interface/web/public/assets/samples/desktop-plain-chat-sample.png filter=lfs diff=lfs merge=lfs -text
+src/interface/web/public/assets/samples/desktop-remember-plan-sample.png filter=lfs diff=lfs merge=lfs -text
+src/interface/web/public/assets/samples/phone-browse-draw-sample.png filter=lfs diff=lfs merge=lfs -text
+src/interface/web/public/assets/samples/phone-remember-plan-sample.png filter=lfs diff=lfs merge=lfs -text
+src/khoj/interface/web/home/khoj_app_hero_image.avif filter=lfs diff=lfs merge=lfs -text
diff --git a/src/interface/android/app/build.gradle b/src/interface/android/app/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..bfa069117c6bc4423af500899d948deede2199d8
--- /dev/null
+++ b/src/interface/android/app/build.gradle
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2019 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import groovy.xml.MarkupBuilder
+
+plugins {
+ id 'com.android.application'
+}
+
+def twaManifest = [
+ applicationId: 'dev.khoj.app',
+ hostName: 'app.khoj.dev', // The domain being opened in the TWA.
+ launchUrl: '/', // The start path for the TWA. Must be relative to the domain.
+ name: 'Khoj AI', // The application name.
+ launcherName: 'Khoj', // The name shown on the Android Launcher.
+ themeColor: '#FFFFFF', // The color used for the status bar.
+ themeColorDark: '#000000', // The color used for the dark status bar.
+ navigationColor: '#000000', // The color used for the navigation bar.
+ navigationColorDark: '#000000', // The color used for the dark navbar.
+ navigationDividerColor: '#000000', // The navbar divider color.
+ navigationDividerColorDark: '#000000', // The dark navbar divider color.
+ backgroundColor: '#FFFFFF', // The color used for the splash screen background.
+ enableNotifications: true, // Set to true to enable notification delegation.
+ // Every shortcut must include the following fields:
+ // - name: String that will show up in the shortcut.
+ // - short_name: Shorter string used if |name| is too long.
+ // - url: Absolute path of the URL to launch the app with (e.g '/create').
+ // - icon: Name of the resource in the drawable folder to use as an icon.
+ shortcuts: [],
+ // The duration of fade out animation in milliseconds to be played when removing splash screen.
+ splashScreenFadeOutDuration: 300,
+ generatorApp: 'bubblewrap-cli', // Application that generated the Android Project
+ // The fallback strategy for when Trusted Web Activity is not available. Possible values are
+ // 'customtabs' and 'webview'.
+ fallbackType: 'customtabs',
+ enableSiteSettingsShortcut: 'true',
+ orientation: 'natural',
+]
+
+android {
+ compileSdkVersion 35
+ namespace "dev.khoj.app"
+ defaultConfig {
+ applicationId "dev.khoj.app"
+ minSdkVersion 19
+ targetSdkVersion 35
+ versionCode 4
+ versionName "4"
+
+ // The name for the application
+ resValue "string", "appName", twaManifest.name
+
+ // The name for the application on the Android Launcher
+ resValue "string", "launcherName", twaManifest.launcherName
+
+ // The URL that will be used when launching the TWA from the Android Launcher
+ def launchUrl = "https://" + twaManifest.hostName + twaManifest.launchUrl
+ resValue "string", "launchUrl", launchUrl
+
+
+ // The URL the Web Manifest for the Progressive Web App that the TWA points to. This
+ // is used by Chrome OS and Meta Quest to open the Web version of the PWA instead of
+ // the TWA, as it will probably give a better user experience for non-mobile devices.
+ resValue "string", "webManifestUrl", 'https://app.khoj.dev/static/khoj.webmanifest'
+
+
+
+ // This is used by Meta Quest.
+ resValue "string", "fullScopeUrl", 'https://app.khoj.dev/'
+
+
+
+
+ // The hostname is used when building the intent-filter, so the TWA is able to
+ // handle Intents to open host url of the application.
+ resValue "string", "hostName", twaManifest.hostName
+
+ // This attribute sets the status bar color for the TWA. It can be either set here or in
+ // `res/values/colors.xml`. Setting in both places is an error and the app will not
+ // compile. If not set, the status bar color defaults to #FFFFFF - white.
+ resValue "color", "colorPrimary", twaManifest.themeColor
+
+ // This attribute sets the dark status bar color for the TWA. It can be either set here or in
+ // `res/values/colors.xml`. Setting in both places is an error and the app will not
+ // compile. If not set, the status bar color defaults to #000000 - white.
+ resValue "color", "colorPrimaryDark", twaManifest.themeColorDark
+
+ // This attribute sets the navigation bar color for the TWA. It can be either set here or
+ // in `res/values/colors.xml`. Setting in both places is an error and the app will not
+ // compile. If not set, the navigation bar color defaults to #FFFFFF - white.
+ resValue "color", "navigationColor", twaManifest.navigationColor
+
+ // This attribute sets the dark navigation bar color for the TWA. It can be either set here
+ // or in `res/values/colors.xml`. Setting in both places is an error and the app will not
+ // compile. If not set, the navigation bar color defaults to #000000 - black.
+ resValue "color", "navigationColorDark", twaManifest.navigationColorDark
+
+ // This attribute sets the navbar divider color for the TWA. It can be either
+ // set here or in `res/values/colors.xml`. Setting in both places is an error and the app
+ // will not compile. If not set, the divider color defaults to #00000000 - transparent.
+ resValue "color", "navigationDividerColor", twaManifest.navigationDividerColor
+
+ // This attribute sets the dark navbar divider color for the TWA. It can be either
+ // set here or in `res/values/colors.xml`. Setting in both places is an error and the
+ //app will not compile. If not set, the divider color defaults to #000000 - black.
+ resValue "color", "navigationDividerColorDark", twaManifest.navigationDividerColorDark
+
+ // Sets the color for the background used for the splash screen when launching the
+ // Trusted Web Activity.
+ resValue "color", "backgroundColor", twaManifest.backgroundColor
+
+ // Defines a provider authority for the Splash Screen
+ resValue "string", "providerAuthority", twaManifest.applicationId + '.fileprovider'
+
+ // The enableNotification resource is used to enable or disable the
+ // TrustedWebActivityService, by changing the android:enabled and android:exported
+ // attributes
+ resValue "bool", "enableNotification", twaManifest.enableNotifications.toString()
+
+ twaManifest.shortcuts.eachWithIndex { shortcut, index ->
+ resValue "string", "shortcut_name_$index", "$shortcut.name"
+ resValue "string", "shortcut_short_name_$index", "$shortcut.short_name"
+ }
+
+ // The splashScreenFadeOutDuration resource is used to set the duration of fade out animation in milliseconds
+ // to be played when removing splash screen. The default is 0 (no animation).
+ resValue "integer", "splashScreenFadeOutDuration", twaManifest.splashScreenFadeOutDuration.toString()
+
+ resValue "string", "generatorApp", twaManifest.generatorApp
+
+ resValue "string", "fallbackType", twaManifest.fallbackType
+
+ resValue "bool", "enableSiteSettingsShortcut", twaManifest.enableSiteSettingsShortcut
+ resValue "string", "orientation", twaManifest.orientation
+ }
+ buildTypes {
+ release {
+ minifyEnabled true
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ lintOptions {
+ checkReleaseBuilds false
+ }
+}
+
+task generateShorcutsFile {
+ assert twaManifest.shortcuts.size() < 5, "You can have at most 4 shortcuts."
+ twaManifest.shortcuts.eachWithIndex { s, i ->
+ assert s.name != null, 'Missing `name` in shortcut #' + i
+ assert s.short_name != null, 'Missing `short_name` in shortcut #' + i
+ assert s.url != null, 'Missing `icon` in shortcut #' + i
+ assert s.icon != null, 'Missing `url` in shortcut #' + i
+ }
+
+ def shortcutsFile = new File("$projectDir/src/main/res/xml", "shortcuts.xml")
+
+ def xmlWriter = new StringWriter()
+ def xmlMarkup = new MarkupBuilder(new IndentPrinter(xmlWriter, " ", true))
+
+ xmlMarkup
+ .'shortcuts'('xmlns:android': 'http://schemas.android.com/apk/res/android') {
+ twaManifest.shortcuts.eachWithIndex { s, i ->
+ 'shortcut'(
+ 'android:shortcutId': 'shortcut' + i,
+ 'android:enabled': 'true',
+ 'android:icon': '@drawable/' + s.icon,
+ 'android:shortcutShortLabel': '@string/shortcut_short_name_' + i,
+ 'android:shortcutLongLabel': '@string/shortcut_name_' + i) {
+ 'intent'(
+ 'android:action': 'android.intent.action.MAIN',
+ 'android:targetPackage': twaManifest.applicationId,
+ 'android:targetClass': twaManifest.applicationId + '.LauncherActivity',
+ 'android:data': s.url)
+ 'categories'('android:name': 'android.intent.category.LAUNCHER')
+ }
+ }
+ }
+ shortcutsFile.text = xmlWriter.toString() + '\n'
+}
+
+preBuild.dependsOn(generateShorcutsFile)
+
+repositories {
+
+}
+
+dependencies {
+ implementation fileTree(include: ['*.jar'], dir: 'libs')
+
+ implementation 'com.google.androidbrowserhelper:locationdelegation:1.1.1'
+
+ implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.5.0'
+
+}
diff --git a/src/interface/android/app/src/main/AndroidManifest.xml b/src/interface/android/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000000000000000000000000000000000..39fee27d9ce12ef13197d8fe67a6f9f69894fe23
--- /dev/null
+++ b/src/interface/android/app/src/main/AndroidManifest.xml
@@ -0,0 +1,188 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/interface/android/app/src/main/java/dev/khoj/app/Application.java b/src/interface/android/app/src/main/java/dev/khoj/app/Application.java
new file mode 100644
index 0000000000000000000000000000000000000000..a1d3040f35056288e2a3ee8da4b8f70193b78daf
--- /dev/null
+++ b/src/interface/android/app/src/main/java/dev/khoj/app/Application.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package dev.khoj.app;
+
+
+
+public class Application extends android.app.Application {
+
+
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ }
+}
diff --git a/src/interface/android/app/src/main/java/dev/khoj/app/DelegationService.java b/src/interface/android/app/src/main/java/dev/khoj/app/DelegationService.java
new file mode 100644
index 0000000000000000000000000000000000000000..d8d6bd10399ed3e97c2c47fba600f9d5218ec42f
--- /dev/null
+++ b/src/interface/android/app/src/main/java/dev/khoj/app/DelegationService.java
@@ -0,0 +1,17 @@
+package dev.khoj.app;
+
+
+import com.google.androidbrowserhelper.locationdelegation.LocationDelegationExtraCommandHandler;
+
+
+public class DelegationService extends
+ com.google.androidbrowserhelper.trusted.DelegationService {
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+
+ registerExtraCommandHandler(new LocationDelegationExtraCommandHandler());
+
+ }
+}
diff --git a/src/interface/android/app/src/main/java/dev/khoj/app/LauncherActivity.java b/src/interface/android/app/src/main/java/dev/khoj/app/LauncherActivity.java
new file mode 100644
index 0000000000000000000000000000000000000000..0347d3ab5ad1415cf866ed9545caf03fcce5a4f6
--- /dev/null
+++ b/src/interface/android/app/src/main/java/dev/khoj/app/LauncherActivity.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package dev.khoj.app;
+
+import android.content.pm.ActivityInfo;
+import android.net.Uri;
+import android.os.Bundle;
+
+
+
+public class LauncherActivity
+ extends com.google.androidbrowserhelper.trusted.LauncherActivity {
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // Setting an orientation crashes the app due to the transparent background on Android 8.0
+ // Oreo and below. We only set the orientation on Oreo and above. This only affects the
+ // splash screen and Chrome will still respect the orientation.
+ // See https://github.com/GoogleChromeLabs/bubblewrap/issues/496 for details.
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+ }
+
+ @Override
+ protected Uri getLaunchingUrl() {
+ // Get the original launch Url.
+ Uri uri = super.getLaunchingUrl();
+
+
+
+ return uri;
+ }
+}
diff --git a/src/interface/android/app/src/main/res/drawable-anydpi/shortcut_legacy_background.xml b/src/interface/android/app/src/main/res/drawable-anydpi/shortcut_legacy_background.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d53c148aceba588ad0eccfc5c1b80fbf81b2a306
--- /dev/null
+++ b/src/interface/android/app/src/main/res/drawable-anydpi/shortcut_legacy_background.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/interface/android/app/src/main/res/drawable-hdpi/ic_notification_icon.png b/src/interface/android/app/src/main/res/drawable-hdpi/ic_notification_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..db196a126f756120a8ea6af87b726152f4ec04be
Binary files /dev/null and b/src/interface/android/app/src/main/res/drawable-hdpi/ic_notification_icon.png differ
diff --git a/src/interface/android/app/src/main/res/drawable-hdpi/splash.png b/src/interface/android/app/src/main/res/drawable-hdpi/splash.png
new file mode 100644
index 0000000000000000000000000000000000000000..9d2384e208728ba050d685852328f0eec60fcfc8
Binary files /dev/null and b/src/interface/android/app/src/main/res/drawable-hdpi/splash.png differ
diff --git a/src/interface/android/app/src/main/res/drawable-mdpi/ic_notification_icon.png b/src/interface/android/app/src/main/res/drawable-mdpi/ic_notification_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..1d97f7c1851a7eef4d9514c2b6458afe821c025a
Binary files /dev/null and b/src/interface/android/app/src/main/res/drawable-mdpi/ic_notification_icon.png differ
diff --git a/src/interface/android/app/src/main/res/drawable-mdpi/splash.png b/src/interface/android/app/src/main/res/drawable-mdpi/splash.png
new file mode 100644
index 0000000000000000000000000000000000000000..770884255348b24b617ea2fb31de3de6be636fb6
Binary files /dev/null and b/src/interface/android/app/src/main/res/drawable-mdpi/splash.png differ
diff --git a/src/interface/android/app/src/main/res/drawable-xhdpi/ic_notification_icon.png b/src/interface/android/app/src/main/res/drawable-xhdpi/ic_notification_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..9625ad9122bc3deaf8f18e26c2bd20b69562cb62
Binary files /dev/null and b/src/interface/android/app/src/main/res/drawable-xhdpi/ic_notification_icon.png differ
diff --git a/src/interface/android/app/src/main/res/drawable-xhdpi/splash.png b/src/interface/android/app/src/main/res/drawable-xhdpi/splash.png
new file mode 100644
index 0000000000000000000000000000000000000000..1d4f64fe1e1f5779b765fc1c33ffdd1662837dcf
Binary files /dev/null and b/src/interface/android/app/src/main/res/drawable-xhdpi/splash.png differ
diff --git a/src/interface/android/app/src/main/res/drawable-xxhdpi/ic_notification_icon.png b/src/interface/android/app/src/main/res/drawable-xxhdpi/ic_notification_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..355b758615790562b35c1df17e0fc1cf7cd92545
Binary files /dev/null and b/src/interface/android/app/src/main/res/drawable-xxhdpi/ic_notification_icon.png differ
diff --git a/src/interface/android/app/src/main/res/drawable-xxhdpi/splash.png b/src/interface/android/app/src/main/res/drawable-xxhdpi/splash.png
new file mode 100644
index 0000000000000000000000000000000000000000..43423514a3a59e7eab0568a7fc7388a6abbb6d52
Binary files /dev/null and b/src/interface/android/app/src/main/res/drawable-xxhdpi/splash.png differ
diff --git a/src/interface/android/app/src/main/res/drawable-xxxhdpi/ic_notification_icon.png b/src/interface/android/app/src/main/res/drawable-xxxhdpi/ic_notification_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..9ed4d5e614596aad288488140f657cf5a855236f
Binary files /dev/null and b/src/interface/android/app/src/main/res/drawable-xxxhdpi/ic_notification_icon.png differ
diff --git a/src/interface/android/app/src/main/res/drawable-xxxhdpi/splash.png b/src/interface/android/app/src/main/res/drawable-xxxhdpi/splash.png
new file mode 100644
index 0000000000000000000000000000000000000000..cec7e27dec6e4e7e4cd2017880050d47cf769a32
Binary files /dev/null and b/src/interface/android/app/src/main/res/drawable-xxxhdpi/splash.png differ
diff --git a/src/interface/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/src/interface/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000000000000000000000000000000000000..b97b2df5dbae9fcea7e7027b0f75b2df215e0631
Binary files /dev/null and b/src/interface/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/src/interface/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/src/interface/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000000000000000000000000000000000000..0a454eb19e8e593837b31a76c4c09b11f3615bd6
Binary files /dev/null and b/src/interface/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/src/interface/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/src/interface/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000000000000000000000000000000000000..47c45373edc6a6dfc959005c0dd6f97322fc345f
Binary files /dev/null and b/src/interface/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/src/interface/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/src/interface/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000000000000000000000000000000000000..643b56f7a6fa67334db8c9177c327a5ddec141e4
Binary files /dev/null and b/src/interface/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/src/interface/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/src/interface/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000000000000000000000000000000000000..3a456d9fdcd6ca3b781cced6c3abddf347e25897
Binary files /dev/null and b/src/interface/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/src/interface/android/app/src/main/res/raw/web_app_manifest.json b/src/interface/android/app/src/main/res/raw/web_app_manifest.json
new file mode 100644
index 0000000000000000000000000000000000000000..cff9d4ef84d86d825932843b07a50652cfde1df7
--- /dev/null
+++ b/src/interface/android/app/src/main/res/raw/web_app_manifest.json
@@ -0,0 +1 @@
+{"name":"Khoj","short_name":"Khoj","display":"standalone","start_url":"/","description":"The open, personal AI for your digital brain. You can ask Khoj to draft a message, paint your imagination, find information on the internet and even answer questions from your documents.","theme_color":"#ffffff","background_color":"#ffffff","icons":[{"src":"/static/assets/icons/khoj_lantern_128x128.png","sizes":"128x128","type":"image/png"},{"src":"/static/assets/icons/khoj_lantern_256x256.png","sizes":"256x256","type":"image/png"}],"screenshots":[{"src":"/static/assets/samples/phone-remember-plan-sample.png","sizes":"419x900","type":"image/png","form_factor":"narrow","label":"Remember and Plan"},{"src":"/static/assets/samples/phone-browse-draw-sample.png","sizes":"419x900","type":"image/png","form_factor":"narrow","label":"Browse and Draw"},{"src":"/static/assets/samples/desktop-remember-plan-sample.png","sizes":"1260x742","type":"image/png","form_factor":"wide","label":"Remember and Plan"},{"src":"/static/assets/samples/desktop-browse-draw-sample.png","sizes":"1260x742","type":"image/png","form_factor":"wide","label":"Browse and Draw"}]}
diff --git a/src/interface/android/app/src/main/res/values/colors.xml b/src/interface/android/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e66222d0025439110617820b4a8f5245295b9606
--- /dev/null
+++ b/src/interface/android/app/src/main/res/values/colors.xml
@@ -0,0 +1,18 @@
+
+
+ #F5F5F5
+
diff --git a/src/interface/android/app/src/main/res/values/strings.xml b/src/interface/android/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d5d34f8b611a571522ba7408e120f7f1f125f524
--- /dev/null
+++ b/src/interface/android/app/src/main/res/values/strings.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ [{
+ \"relation\": [\"delegate_permission/common.handle_all_urls\"],
+ \"target\": {
+ \"namespace\": \"web\",
+ \"site\": \"https://app.khoj.dev\"
+ }
+ }]
+
+
+
diff --git a/src/interface/android/app/src/main/res/xml/filepaths.xml b/src/interface/android/app/src/main/res/xml/filepaths.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a54348527192adbd46cc968132365959cd2b804d
--- /dev/null
+++ b/src/interface/android/app/src/main/res/xml/filepaths.xml
@@ -0,0 +1,18 @@
+
+
+
+
diff --git a/src/interface/android/app/src/main/res/xml/shortcuts.xml b/src/interface/android/app/src/main/res/xml/shortcuts.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5effdb1d119b941529666039f4dfa8ecf7ff36cf
--- /dev/null
+++ b/src/interface/android/app/src/main/res/xml/shortcuts.xml
@@ -0,0 +1 @@
+
diff --git a/src/interface/android/build.gradle b/src/interface/android/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..fe8944ba279807e805f1c4a1ae089954e1e152f7
--- /dev/null
+++ b/src/interface/android/build.gradle
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2019 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+
+ repositories {
+ google()
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:8.7.2'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+tasks.register('clean', Delete) {
+ delete rootProject.buildDir
+}
diff --git a/src/interface/android/gradle.properties b/src/interface/android/gradle.properties
new file mode 100644
index 0000000000000000000000000000000000000000..784a1d43f91ab356d5f3ab94f4175b056e1c1751
--- /dev/null
+++ b/src/interface/android/gradle.properties
@@ -0,0 +1,14 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+android.useAndroidX=true
diff --git a/src/interface/android/gradle/wrapper/gradle-wrapper.jar b/src/interface/android/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000000000000000000000000000000000..5c2d1cf016b3885f6930543d57b744ea8c220a1a
Binary files /dev/null and b/src/interface/android/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/src/interface/android/gradle/wrapper/gradle-wrapper.properties b/src/interface/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000000000000000000000000000000000..b30c99143acb9c01a5fc1576a48fd7eb0bd2bbd2
--- /dev/null
+++ b/src/interface/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
diff --git a/src/interface/android/gradlew b/src/interface/android/gradlew
new file mode 100644
index 0000000000000000000000000000000000000000..b740cf13397ab16efc23cba3d6234ff8433403b1
--- /dev/null
+++ b/src/interface/android/gradlew
@@ -0,0 +1,249 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://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.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/src/interface/android/gradlew.bat b/src/interface/android/gradlew.bat
new file mode 100644
index 0000000000000000000000000000000000000000..7101f8e4676fcad8adc961e929ea3bcb37b5262f
--- /dev/null
+++ b/src/interface/android/gradlew.bat
@@ -0,0 +1,92 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/src/interface/android/manifest-checksum.txt b/src/interface/android/manifest-checksum.txt
new file mode 100644
index 0000000000000000000000000000000000000000..d3280ee8f542b9c7a5c7cc0e3c5a8d5af8d9be5c
--- /dev/null
+++ b/src/interface/android/manifest-checksum.txt
@@ -0,0 +1 @@
+6ee1711cf4f745dafc80c1cc13c3025342a0f5da
diff --git a/src/interface/android/settings.gradle b/src/interface/android/settings.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..e7b4def49cb53d9aa04228dd3edb14c9e635e003
--- /dev/null
+++ b/src/interface/android/settings.gradle
@@ -0,0 +1 @@
+include ':app'
diff --git a/src/interface/android/store_icon.png b/src/interface/android/store_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..93b5729d71bf92e49b5949b890e9151f87de0c37
Binary files /dev/null and b/src/interface/android/store_icon.png differ
diff --git a/src/interface/android/twa-manifest.json b/src/interface/android/twa-manifest.json
new file mode 100644
index 0000000000000000000000000000000000000000..9b4628343bd31ce312fe2c9e0ac5000f3b0682ad
--- /dev/null
+++ b/src/interface/android/twa-manifest.json
@@ -0,0 +1,55 @@
+{
+ "packageId": "dev.khoj.app",
+ "host": "app.khoj.dev",
+ "name": "Khoj AI",
+ "launcherName": "Khoj",
+ "display": "standalone",
+ "themeColor": "#FFFFFF",
+ "themeColorDark": "#000000",
+ "navigationColor": "#000000",
+ "navigationColorDark": "#000000",
+ "navigationDividerColor": "#000000",
+ "navigationDividerColorDark": "#000000",
+ "backgroundColor": "#FFFFFF",
+ "enableNotifications": true,
+ "startUrl": "/",
+ "iconUrl": "https://assets.khoj.dev/khoj_lantern_1200x1200.png",
+ "splashScreenFadeOutDuration": 300,
+ "signingKey": {
+ "path": "android.keystore",
+ "alias": "android"
+ },
+ "appVersionName": "4",
+ "appVersionCode": 4,
+ "shortcuts": [],
+ "generatorApp": "bubblewrap-cli",
+ "webManifestUrl": "https://app.khoj.dev/static/khoj.webmanifest",
+ "fallbackType": "customtabs",
+ "features": {
+ "locationDelegation": {
+ "enabled": true
+ }
+ },
+ "alphaDependencies": {
+ "enabled": false
+ },
+ "enableSiteSettingsShortcut": true,
+ "isChromeOSOnly": false,
+ "isMetaQuest": false,
+ "fullScopeUrl": "https://app.khoj.dev/",
+ "minSdkVersion": 19,
+ "orientation": "natural",
+ "fingerprints": [
+ {
+ "name": "signing",
+ "value": "CC:98:4A:0A:F1:CC:84:26:AC:02:86:49:AA:69:64:B9:5E:63:A3:EF:18:56:EA:CA:13:C1:3A:15:CA:49:77:46"
+ },
+ {
+ "name": "upload",
+ "value": "D4:5A:6F:6C:18:28:D2:1C:78:27:92:C6:AC:DB:4C:12:C4:52:A1:88:9B:A1:F5:67:D1:22:FE:A0:0F:B1:AE:92"
+ }
+ ],
+ "additionalTrustedOrigins": [],
+ "retainedBundles": [],
+ "appVersion": "4"
+}
diff --git a/src/interface/desktop/README.md b/src/interface/desktop/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..c2f1be0dbe5024bdc07b972f33af1c12c6d50ce0
--- /dev/null
+++ b/src/interface/desktop/README.md
@@ -0,0 +1,37 @@
+# Run it locally
+
+## Prerequisites
+
+Install the runtime dependencies. This command should install all dev dependencies.
+
+```bash
+yarn install
+```
+
+Run the application
+
+```bash
+yarn start
+```
+
+# Deploying the Electron App
+
+## Prerequisites
+
+Install the ToDesktop CLI. Full documentation can be found here: https://www.npmjs.com/package/@todesktop/cli
+
+```bash
+yarn global add @todesktop/cli
+```
+
+Configure the `todesktop.json` file. Fill in the `id` based on the application ID.
+
+## Build
+
+This will prompt you to login. It triggers builds for all platforms.
+
+```bash
+todesktop build
+```
+
+If you get an error saying the command is not found, make sure that your `yarn` global bin directory is in your `PATH` environment variable. You can find the location of the global bin directory by running `yarn global bin`. Add this line to your `.bashrc` or `.zshrc` file: `export PATH="$PATH:$(yarn global bin)"`.
diff --git a/src/interface/desktop/about.html b/src/interface/desktop/about.html
new file mode 100644
index 0000000000000000000000000000000000000000..c3d4c67aee02344f2971c914ba401c3977fd7269
--- /dev/null
+++ b/src/interface/desktop/about.html
@@ -0,0 +1,89 @@
+
+
+ 03B8;;;;N;GREEK SMALL LETTER SCRIPT THETA;;0398;;0398
+ // 03F4;GREEK CAPITAL THETA SYMBOL;Lu;0;L; 0398;;;;N;;;;03B8;
+
+ // Case-insensitive comparison should treat all of them as equivalent.
+
+ // But .toLowerCase() doesn't change ϑ (it's already lowercase),
+ // and .toUpperCase() doesn't change ϴ (already uppercase).
+
+ // Applying first lower then upper case normalizes any character:
+ // '\u0398\u03f4\u03b8\u03d1'.toLowerCase().toUpperCase() === '\u0398\u0398\u0398\u0398'
+
+ // Note: this is equivalent to unicode case folding; unicode normalization
+ // is a different step that is not required here.
+
+ // Final result should be uppercased, because it's later stored in an object
+ // (this avoid a conflict with Object.prototype members,
+ // most notably, `__proto__`)
+
+ return str.toLowerCase().toUpperCase();
+ }
+ ////////////////////////////////////////////////////////////////////////////////
+ // Re-export libraries commonly used in both markdown-it and its plugins,
+ // so plugins won't have to depend on them explicitly, which reduces their
+ // bundled size (e.g. a browser build).
+
+ exports.lib = {};
+ exports.lib.mdurl = mdurl;
+ exports.lib.ucmicro = uc_micro;
+ exports.assign = assign;
+ exports.isString = isString;
+ exports.has = has;
+ exports.unescapeMd = unescapeMd;
+ exports.unescapeAll = unescapeAll;
+ exports.isValidEntityCode = isValidEntityCode;
+ exports.fromCodePoint = fromCodePoint;
+ // exports.replaceEntities = replaceEntities;
+ exports.escapeHtml = escapeHtml;
+ exports.arrayReplaceAt = arrayReplaceAt;
+ exports.isSpace = isSpace;
+ exports.isWhiteSpace = isWhiteSpace;
+ exports.isMdAsciiPunct = isMdAsciiPunct;
+ exports.isPunctChar = isPunctChar;
+ exports.escapeRE = escapeRE;
+ exports.normalizeReference = normalizeReference;
+ }));
+ // Parse link label
+ var parse_link_label = function parseLinkLabel(state, start, disableNested) {
+ var level, found, marker, prevPos, labelEnd = -1, max = state.posMax, oldPos = state.pos;
+ state.pos = start + 1;
+ level = 1;
+ while (state.pos < max) {
+ marker = state.src.charCodeAt(state.pos);
+ if (marker === 93 /* ] */) {
+ level--;
+ if (level === 0) {
+ found = true;
+ break;
+ }
+ }
+ prevPos = state.pos;
+ state.md.inline.skipToken(state);
+ if (marker === 91 /* [ */) {
+ if (prevPos === state.pos - 1) {
+ // increase level if we find text `[`, which is not a part of any token
+ level++;
+ } else if (disableNested) {
+ state.pos = oldPos;
+ return -1;
+ }
+ }
+ }
+ if (found) {
+ labelEnd = state.pos;
+ }
+ // restore old state
+ state.pos = oldPos;
+ return labelEnd;
+ };
+ var unescapeAll$2 = utils.unescapeAll;
+ var parse_link_destination = function parseLinkDestination(str, pos, max) {
+ var code, level, lines = 0, start = pos, result = {
+ ok: false,
+ pos: 0,
+ lines: 0,
+ str: ""
+ };
+ if (str.charCodeAt(pos) === 60 /* < */) {
+ pos++;
+ while (pos < max) {
+ code = str.charCodeAt(pos);
+ if (code === 10 /* \n */) {
+ return result;
+ }
+ if (code === 60 /* < */) {
+ return result;
+ }
+ if (code === 62 /* > */) {
+ result.pos = pos + 1;
+ result.str = unescapeAll$2(str.slice(start + 1, pos));
+ result.ok = true;
+ return result;
+ }
+ if (code === 92 /* \ */ && pos + 1 < max) {
+ pos += 2;
+ continue;
+ }
+ pos++;
+ }
+ // no closing '>'
+ return result;
+ }
+ // this should be ... } else { ... branch
+ level = 0;
+ while (pos < max) {
+ code = str.charCodeAt(pos);
+ if (code === 32) {
+ break;
+ }
+ // ascii control characters
+ if (code < 32 || code === 127) {
+ break;
+ }
+ if (code === 92 /* \ */ && pos + 1 < max) {
+ if (str.charCodeAt(pos + 1) === 32) {
+ break;
+ }
+ pos += 2;
+ continue;
+ }
+ if (code === 40 /* ( */) {
+ level++;
+ if (level > 32) {
+ return result;
+ }
+ }
+ if (code === 41 /* ) */) {
+ if (level === 0) {
+ break;
+ }
+ level--;
+ }
+ pos++;
+ }
+ if (start === pos) {
+ return result;
+ }
+ if (level !== 0) {
+ return result;
+ }
+ result.str = unescapeAll$2(str.slice(start, pos));
+ result.lines = lines;
+ result.pos = pos;
+ result.ok = true;
+ return result;
+ };
+ var unescapeAll$1 = utils.unescapeAll;
+ var parse_link_title = function parseLinkTitle(str, pos, max) {
+ var code, marker, lines = 0, start = pos, result = {
+ ok: false,
+ pos: 0,
+ lines: 0,
+ str: ""
+ };
+ if (pos >= max) {
+ return result;
+ }
+ marker = str.charCodeAt(pos);
+ if (marker !== 34 /* " */ && marker !== 39 /* ' */ && marker !== 40 /* ( */) {
+ return result;
+ }
+ pos++;
+ // if opening marker is "(", switch it to closing marker ")"
+ if (marker === 40) {
+ marker = 41;
+ }
+ while (pos < max) {
+ code = str.charCodeAt(pos);
+ if (code === marker) {
+ result.pos = pos + 1;
+ result.lines = lines;
+ result.str = unescapeAll$1(str.slice(start + 1, pos));
+ result.ok = true;
+ return result;
+ } else if (code === 40 /* ( */ && marker === 41 /* ) */) {
+ return result;
+ } else if (code === 10) {
+ lines++;
+ } else if (code === 92 /* \ */ && pos + 1 < max) {
+ pos++;
+ if (str.charCodeAt(pos) === 10) {
+ lines++;
+ }
+ }
+ pos++;
+ }
+ return result;
+ };
+ var parseLinkLabel = parse_link_label;
+ var parseLinkDestination = parse_link_destination;
+ var parseLinkTitle = parse_link_title;
+ var helpers = {
+ parseLinkLabel: parseLinkLabel,
+ parseLinkDestination: parseLinkDestination,
+ parseLinkTitle: parseLinkTitle
+ };
+ var assign$1 = utils.assign;
+ var unescapeAll = utils.unescapeAll;
+ var escapeHtml = utils.escapeHtml;
+ ////////////////////////////////////////////////////////////////////////////////
+ var default_rules = {};
+ default_rules.code_inline = function(tokens, idx, options, env, slf) {
+ var token = tokens[idx];
+ return "" + escapeHtml(tokens[idx].content) + "";
+ };
+ default_rules.code_block = function(tokens, idx, options, env, slf) {
+ var token = tokens[idx];
+ return "" + escapeHtml(tokens[idx].content) + "
\n";
+ };
+ default_rules.fence = function(tokens, idx, options, env, slf) {
+ var token = tokens[idx], info = token.info ? unescapeAll(token.info).trim() : "", langName = "", langAttrs = "", highlighted, i, arr, tmpAttrs, tmpToken;
+ if (info) {
+ arr = info.split(/(\s+)/g);
+ langName = arr[0];
+ langAttrs = arr.slice(2).join("");
+ }
+ if (options.highlight) {
+ highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content);
+ } else {
+ highlighted = escapeHtml(token.content);
+ }
+ if (highlighted.indexOf("" + highlighted + "
\n";
+ }
+ return "" + highlighted + "
\n";
+ };
+ default_rules.image = function(tokens, idx, options, env, slf) {
+ var token = tokens[idx];
+ // "alt" attr MUST be set, even if empty. Because it's mandatory and
+ // should be placed on proper position for tests.
+
+ // Replace content with actual value
+ token.attrs[token.attrIndex("alt")][1] = slf.renderInlineAsText(token.children, options, env);
+ return slf.renderToken(tokens, idx, options);
+ };
+ default_rules.hardbreak = function(tokens, idx, options /*, env */) {
+ return options.xhtmlOut ? "
\n" : "
\n";
+ };
+ default_rules.softbreak = function(tokens, idx, options /*, env */) {
+ return options.breaks ? options.xhtmlOut ? "
\n" : "
\n" : "\n";
+ };
+ default_rules.text = function(tokens, idx /*, options, env */) {
+ return escapeHtml(tokens[idx].content);
+ };
+ default_rules.html_block = function(tokens, idx /*, options, env */) {
+ return tokens[idx].content;
+ };
+ default_rules.html_inline = function(tokens, idx /*, options, env */) {
+ return tokens[idx].content;
+ };
+ /**
+ * new Renderer()
+ *
+ * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.
+ **/ function Renderer() {
+ /**
+ * Renderer#rules -> Object
+ *
+ * Contains render rules for tokens. Can be updated and extended.
+ *
+ * ##### Example
+ *
+ * ```javascript
+ * var md = require('markdown-it')();
+ *
+ * md.renderer.rules.strong_open = function () { return ''; };
+ * md.renderer.rules.strong_close = function () { return ''; };
+ *
+ * var result = md.renderInline(...);
+ * ```
+ *
+ * Each rule is called as independent static function with fixed signature:
+ *
+ * ```javascript
+ * function my_token_render(tokens, idx, options, env, renderer) {
+ * // ...
+ * return renderedHTML;
+ * }
+ * ```
+ *
+ * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)
+ * for more details and examples.
+ **/
+ this.rules = assign$1({}, default_rules);
+ }
+ /**
+ * Renderer.renderAttrs(token) -> String
+ *
+ * Render token attributes to string.
+ **/ Renderer.prototype.renderAttrs = function renderAttrs(token) {
+ var i, l, result;
+ if (!token.attrs) {
+ return "";
+ }
+ result = "";
+ for (i = 0, l = token.attrs.length; i < l; i++) {
+ result += " " + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
+ }
+ return result;
+ };
+ /**
+ * Renderer.renderToken(tokens, idx, options) -> String
+ * - tokens (Array): list of tokens
+ * - idx (Numbed): token index to render
+ * - options (Object): params of parser instance
+ *
+ * Default token renderer. Can be overriden by custom function
+ * in [[Renderer#rules]].
+ **/ Renderer.prototype.renderToken = function renderToken(tokens, idx, options) {
+ var nextToken, result = "", needLf = false, token = tokens[idx];
+ // Tight list paragraphs
+ if (token.hidden) {
+ return "";
+ }
+ // Insert a newline between hidden paragraph and subsequent opening
+ // block-level tag.
+
+ // For example, here we should insert a newline before blockquote:
+ // - a
+ // >
+
+ if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) {
+ result += "\n";
+ }
+ // Add token name, e.g. `
`.
+ needLf = false;
+ }
+ }
+ }
+ }
+ result += needLf ? ">\n" : ">";
+ return result;
+ };
+ /**
+ * Renderer.renderInline(tokens, options, env) -> String
+ * - tokens (Array): list on block tokens to render
+ * - options (Object): params of parser instance
+ * - env (Object): additional data from parsed input (references, for example)
+ *
+ * The same as [[Renderer.render]], but for single token of `inline` type.
+ **/ Renderer.prototype.renderInline = function(tokens, options, env) {
+ var type, result = "", rules = this.rules;
+ for (var i = 0, len = tokens.length; i < len; i++) {
+ type = tokens[i].type;
+ if (typeof rules[type] !== "undefined") {
+ result += rules[type](tokens, i, options, env, this);
+ } else {
+ result += this.renderToken(tokens, i, options);
+ }
+ }
+ return result;
+ };
+ /** internal
+ * Renderer.renderInlineAsText(tokens, options, env) -> String
+ * - tokens (Array): list on block tokens to render
+ * - options (Object): params of parser instance
+ * - env (Object): additional data from parsed input (references, for example)
+ *
+ * Special kludge for image `alt` attributes to conform CommonMark spec.
+ * Don't try to use it! Spec requires to show `alt` content with stripped markup,
+ * instead of simple escaping.
+ **/ Renderer.prototype.renderInlineAsText = function(tokens, options, env) {
+ var result = "";
+ for (var i = 0, len = tokens.length; i < len; i++) {
+ if (tokens[i].type === "text") {
+ result += tokens[i].content;
+ } else if (tokens[i].type === "image") {
+ result += this.renderInlineAsText(tokens[i].children, options, env);
+ } else if (tokens[i].type === "softbreak") {
+ result += "\n";
+ }
+ }
+ return result;
+ };
+ /**
+ * Renderer.render(tokens, options, env) -> String
+ * - tokens (Array): list on block tokens to render
+ * - options (Object): params of parser instance
+ * - env (Object): additional data from parsed input (references, for example)
+ *
+ * Takes token stream and generates HTML. Probably, you will never need to call
+ * this method directly.
+ **/ Renderer.prototype.render = function(tokens, options, env) {
+ var i, len, type, result = "", rules = this.rules;
+ for (i = 0, len = tokens.length; i < len; i++) {
+ type = tokens[i].type;
+ if (type === "inline") {
+ result += this.renderInline(tokens[i].children, options, env);
+ } else if (typeof rules[type] !== "undefined") {
+ result += rules[tokens[i].type](tokens, i, options, env, this);
+ } else {
+ result += this.renderToken(tokens, i, options, env);
+ }
+ }
+ return result;
+ };
+ var renderer = Renderer;
+ /**
+ * class Ruler
+ *
+ * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
+ * [[MarkdownIt#inline]] to manage sequences of functions (rules):
+ *
+ * - keep rules in defined order
+ * - assign the name to each rule
+ * - enable/disable rules
+ * - add/replace rules
+ * - allow assign rules to additional named chains (in the same)
+ * - cacheing lists of active rules
+ *
+ * You will not need use this class directly until write plugins. For simple
+ * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
+ * [[MarkdownIt.use]].
+ **/
+ /**
+ * new Ruler()
+ **/ function Ruler() {
+ // List of added rules. Each element is:
+ // {
+ // name: XXX,
+ // enabled: Boolean,
+ // fn: Function(),
+ // alt: [ name2, name3 ]
+ // }
+ this.__rules__ = [];
+ // Cached rule chains.
+
+ // First level - chain name, '' for default.
+ // Second level - diginal anchor for fast filtering by charcodes.
+
+ this.__cache__ = null;
+ }
+ ////////////////////////////////////////////////////////////////////////////////
+ // Helper methods, should not be used directly
+ // Find rule index by name
+
+ Ruler.prototype.__find__ = function(name) {
+ for (var i = 0; i < this.__rules__.length; i++) {
+ if (this.__rules__[i].name === name) {
+ return i;
+ }
+ }
+ return -1;
+ };
+ // Build rules lookup cache
+
+ Ruler.prototype.__compile__ = function() {
+ var self = this;
+ var chains = [ "" ];
+ // collect unique names
+ self.__rules__.forEach((function(rule) {
+ if (!rule.enabled) {
+ return;
+ }
+ rule.alt.forEach((function(altName) {
+ if (chains.indexOf(altName) < 0) {
+ chains.push(altName);
+ }
+ }));
+ }));
+ self.__cache__ = {};
+ chains.forEach((function(chain) {
+ self.__cache__[chain] = [];
+ self.__rules__.forEach((function(rule) {
+ if (!rule.enabled) {
+ return;
+ }
+ if (chain && rule.alt.indexOf(chain) < 0) {
+ return;
+ }
+ self.__cache__[chain].push(rule.fn);
+ }));
+ }));
+ };
+ /**
+ * Ruler.at(name, fn [, options])
+ * - name (String): rule name to replace.
+ * - fn (Function): new rule function.
+ * - options (Object): new rule options (not mandatory).
+ *
+ * Replace rule by name with new function & options. Throws error if name not
+ * found.
+ *
+ * ##### Options:
+ *
+ * - __alt__ - array with names of "alternate" chains.
+ *
+ * ##### Example
+ *
+ * Replace existing typographer replacement rule with new one:
+ *
+ * ```javascript
+ * var md = require('markdown-it')();
+ *
+ * md.core.ruler.at('replacements', function replace(state) {
+ * //...
+ * });
+ * ```
+ **/ Ruler.prototype.at = function(name, fn, options) {
+ var index = this.__find__(name);
+ var opt = options || {};
+ if (index === -1) {
+ throw new Error("Parser rule not found: " + name);
+ }
+ this.__rules__[index].fn = fn;
+ this.__rules__[index].alt = opt.alt || [];
+ this.__cache__ = null;
+ };
+ /**
+ * Ruler.before(beforeName, ruleName, fn [, options])
+ * - beforeName (String): new rule will be added before this one.
+ * - ruleName (String): name of added rule.
+ * - fn (Function): rule function.
+ * - options (Object): rule options (not mandatory).
+ *
+ * Add new rule to chain before one with given name. See also
+ * [[Ruler.after]], [[Ruler.push]].
+ *
+ * ##### Options:
+ *
+ * - __alt__ - array with names of "alternate" chains.
+ *
+ * ##### Example
+ *
+ * ```javascript
+ * var md = require('markdown-it')();
+ *
+ * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
+ * //...
+ * });
+ * ```
+ **/ Ruler.prototype.before = function(beforeName, ruleName, fn, options) {
+ var index = this.__find__(beforeName);
+ var opt = options || {};
+ if (index === -1) {
+ throw new Error("Parser rule not found: " + beforeName);
+ }
+ this.__rules__.splice(index, 0, {
+ name: ruleName,
+ enabled: true,
+ fn: fn,
+ alt: opt.alt || []
+ });
+ this.__cache__ = null;
+ };
+ /**
+ * Ruler.after(afterName, ruleName, fn [, options])
+ * - afterName (String): new rule will be added after this one.
+ * - ruleName (String): name of added rule.
+ * - fn (Function): rule function.
+ * - options (Object): rule options (not mandatory).
+ *
+ * Add new rule to chain after one with given name. See also
+ * [[Ruler.before]], [[Ruler.push]].
+ *
+ * ##### Options:
+ *
+ * - __alt__ - array with names of "alternate" chains.
+ *
+ * ##### Example
+ *
+ * ```javascript
+ * var md = require('markdown-it')();
+ *
+ * md.inline.ruler.after('text', 'my_rule', function replace(state) {
+ * //...
+ * });
+ * ```
+ **/ Ruler.prototype.after = function(afterName, ruleName, fn, options) {
+ var index = this.__find__(afterName);
+ var opt = options || {};
+ if (index === -1) {
+ throw new Error("Parser rule not found: " + afterName);
+ }
+ this.__rules__.splice(index + 1, 0, {
+ name: ruleName,
+ enabled: true,
+ fn: fn,
+ alt: opt.alt || []
+ });
+ this.__cache__ = null;
+ };
+ /**
+ * Ruler.push(ruleName, fn [, options])
+ * - ruleName (String): name of added rule.
+ * - fn (Function): rule function.
+ * - options (Object): rule options (not mandatory).
+ *
+ * Push new rule to the end of chain. See also
+ * [[Ruler.before]], [[Ruler.after]].
+ *
+ * ##### Options:
+ *
+ * - __alt__ - array with names of "alternate" chains.
+ *
+ * ##### Example
+ *
+ * ```javascript
+ * var md = require('markdown-it')();
+ *
+ * md.core.ruler.push('my_rule', function replace(state) {
+ * //...
+ * });
+ * ```
+ **/ Ruler.prototype.push = function(ruleName, fn, options) {
+ var opt = options || {};
+ this.__rules__.push({
+ name: ruleName,
+ enabled: true,
+ fn: fn,
+ alt: opt.alt || []
+ });
+ this.__cache__ = null;
+ };
+ /**
+ * Ruler.enable(list [, ignoreInvalid]) -> Array
+ * - list (String|Array): list of rule names to enable.
+ * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
+ *
+ * Enable rules with given names. If any rule name not found - throw Error.
+ * Errors can be disabled by second param.
+ *
+ * Returns list of found rule names (if no exception happened).
+ *
+ * See also [[Ruler.disable]], [[Ruler.enableOnly]].
+ **/ Ruler.prototype.enable = function(list, ignoreInvalid) {
+ if (!Array.isArray(list)) {
+ list = [ list ];
+ }
+ var result = [];
+ // Search by name and enable
+ list.forEach((function(name) {
+ var idx = this.__find__(name);
+ if (idx < 0) {
+ if (ignoreInvalid) {
+ return;
+ }
+ throw new Error("Rules manager: invalid rule name " + name);
+ }
+ this.__rules__[idx].enabled = true;
+ result.push(name);
+ }), this);
+ this.__cache__ = null;
+ return result;
+ };
+ /**
+ * Ruler.enableOnly(list [, ignoreInvalid])
+ * - list (String|Array): list of rule names to enable (whitelist).
+ * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
+ *
+ * Enable rules with given names, and disable everything else. If any rule name
+ * not found - throw Error. Errors can be disabled by second param.
+ *
+ * See also [[Ruler.disable]], [[Ruler.enable]].
+ **/ Ruler.prototype.enableOnly = function(list, ignoreInvalid) {
+ if (!Array.isArray(list)) {
+ list = [ list ];
+ }
+ this.__rules__.forEach((function(rule) {
+ rule.enabled = false;
+ }));
+ this.enable(list, ignoreInvalid);
+ };
+ /**
+ * Ruler.disable(list [, ignoreInvalid]) -> Array
+ * - list (String|Array): list of rule names to disable.
+ * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
+ *
+ * Disable rules with given names. If any rule name not found - throw Error.
+ * Errors can be disabled by second param.
+ *
+ * Returns list of found rule names (if no exception happened).
+ *
+ * See also [[Ruler.enable]], [[Ruler.enableOnly]].
+ **/ Ruler.prototype.disable = function(list, ignoreInvalid) {
+ if (!Array.isArray(list)) {
+ list = [ list ];
+ }
+ var result = [];
+ // Search by name and disable
+ list.forEach((function(name) {
+ var idx = this.__find__(name);
+ if (idx < 0) {
+ if (ignoreInvalid) {
+ return;
+ }
+ throw new Error("Rules manager: invalid rule name " + name);
+ }
+ this.__rules__[idx].enabled = false;
+ result.push(name);
+ }), this);
+ this.__cache__ = null;
+ return result;
+ };
+ /**
+ * Ruler.getRules(chainName) -> Array
+ *
+ * Return array of active functions (rules) for given chain name. It analyzes
+ * rules configuration, compiles caches if not exists and returns result.
+ *
+ * Default chain name is `''` (empty string). It can't be skipped. That's
+ * done intentionally, to keep signature monomorphic for high speed.
+ **/ Ruler.prototype.getRules = function(chainName) {
+ if (this.__cache__ === null) {
+ this.__compile__();
+ }
+ // Chain can be empty, if rules disabled. But we still have to return Array.
+ return this.__cache__[chainName] || [];
+ };
+ var ruler = Ruler;
+ // Normalize input string
+ // https://spec.commonmark.org/0.29/#line-ending
+ var NEWLINES_RE = /\r\n?|\n/g;
+ var NULL_RE = /\0/g;
+ var normalize = function normalize(state) {
+ var str;
+ // Normalize newlines
+ str = state.src.replace(NEWLINES_RE, "\n");
+ // Replace NULL characters
+ str = str.replace(NULL_RE, "\ufffd");
+ state.src = str;
+ };
+ var block = function block(state) {
+ var token;
+ if (state.inlineMode) {
+ token = new state.Token("inline", "", 0);
+ token.content = state.src;
+ token.map = [ 0, 1 ];
+ token.children = [];
+ state.tokens.push(token);
+ } else {
+ state.md.block.parse(state.src, state.md, state.env, state.tokens);
+ }
+ };
+ var inline = function inline(state) {
+ var tokens = state.tokens, tok, i, l;
+ // Parse inlines
+ for (i = 0, l = tokens.length; i < l; i++) {
+ tok = tokens[i];
+ if (tok.type === "inline") {
+ state.md.inline.parse(tok.content, state.md, state.env, tok.children);
+ }
+ }
+ };
+ var arrayReplaceAt = utils.arrayReplaceAt;
+ function isLinkOpen$1(str) {
+ return /^\s]/i.test(str);
+ }
+ function isLinkClose$1(str) {
+ return /^<\/a\s*>/i.test(str);
+ }
+ var linkify$1 = function linkify(state) {
+ var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos, level, htmlLinkLevel, url, fullUrl, urlText, blockTokens = state.tokens, links;
+ if (!state.md.options.linkify) {
+ return;
+ }
+ for (j = 0, l = blockTokens.length; j < l; j++) {
+ if (blockTokens[j].type !== "inline" || !state.md.linkify.pretest(blockTokens[j].content)) {
+ continue;
+ }
+ tokens = blockTokens[j].children;
+ htmlLinkLevel = 0;
+ // We scan from the end, to keep position when new tags added.
+ // Use reversed logic in links start/end match
+ for (i = tokens.length - 1; i >= 0; i--) {
+ currentToken = tokens[i];
+ // Skip content of markdown links
+ if (currentToken.type === "link_close") {
+ i--;
+ while (tokens[i].level !== currentToken.level && tokens[i].type !== "link_open") {
+ i--;
+ }
+ continue;
+ }
+ // Skip content of html tag links
+ if (currentToken.type === "html_inline") {
+ if (isLinkOpen$1(currentToken.content) && htmlLinkLevel > 0) {
+ htmlLinkLevel--;
+ }
+ if (isLinkClose$1(currentToken.content)) {
+ htmlLinkLevel++;
+ }
+ }
+ if (htmlLinkLevel > 0) {
+ continue;
+ }
+ if (currentToken.type === "text" && state.md.linkify.test(currentToken.content)) {
+ text = currentToken.content;
+ links = state.md.linkify.match(text);
+ // Now split string to nodes
+ nodes = [];
+ level = currentToken.level;
+ lastPos = 0;
+ // forbid escape sequence at the start of the string,
+ // this avoids http\://example.com/ from being linkified as
+ // http://example.com/
+ if (links.length > 0 && links[0].index === 0 && i > 0 && tokens[i - 1].type === "text_special") {
+ links = links.slice(1);
+ }
+ for (ln = 0; ln < links.length; ln++) {
+ url = links[ln].url;
+ fullUrl = state.md.normalizeLink(url);
+ if (!state.md.validateLink(fullUrl)) {
+ continue;
+ }
+ urlText = links[ln].text;
+ // Linkifier might send raw hostnames like "example.com", where url
+ // starts with domain name. So we prepend http:// in those cases,
+ // and remove it afterwards.
+
+ if (!links[ln].schema) {
+ urlText = state.md.normalizeLinkText("http://" + urlText).replace(/^http:\/\//, "");
+ } else if (links[ln].schema === "mailto:" && !/^mailto:/i.test(urlText)) {
+ urlText = state.md.normalizeLinkText("mailto:" + urlText).replace(/^mailto:/, "");
+ } else {
+ urlText = state.md.normalizeLinkText(urlText);
+ }
+ pos = links[ln].index;
+ if (pos > lastPos) {
+ token = new state.Token("text", "", 0);
+ token.content = text.slice(lastPos, pos);
+ token.level = level;
+ nodes.push(token);
+ }
+ token = new state.Token("link_open", "a", 1);
+ token.attrs = [ [ "href", fullUrl ] ];
+ token.level = level++;
+ token.markup = "linkify";
+ token.info = "auto";
+ nodes.push(token);
+ token = new state.Token("text", "", 0);
+ token.content = urlText;
+ token.level = level;
+ nodes.push(token);
+ token = new state.Token("link_close", "a", -1);
+ token.level = --level;
+ token.markup = "linkify";
+ token.info = "auto";
+ nodes.push(token);
+ lastPos = links[ln].lastIndex;
+ }
+ if (lastPos < text.length) {
+ token = new state.Token("text", "", 0);
+ token.content = text.slice(lastPos);
+ token.level = level;
+ nodes.push(token);
+ }
+ // replace current node
+ blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
+ }
+ }
+ }
+ };
+ // Simple typographic replacements
+ // TODO:
+ // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
+ // - multiplications 2 x 4 -> 2 × 4
+ var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
+ // Workaround for phantomjs - need regex without /g flag,
+ // or root check will fail every second time
+ var SCOPED_ABBR_TEST_RE = /\((c|tm|r)\)/i;
+ var SCOPED_ABBR_RE = /\((c|tm|r)\)/gi;
+ var SCOPED_ABBR = {
+ c: "\xa9",
+ r: "\xae",
+ tm: "\u2122"
+ };
+ function replaceFn(match, name) {
+ return SCOPED_ABBR[name.toLowerCase()];
+ }
+ function replace_scoped(inlineTokens) {
+ var i, token, inside_autolink = 0;
+ for (i = inlineTokens.length - 1; i >= 0; i--) {
+ token = inlineTokens[i];
+ if (token.type === "text" && !inside_autolink) {
+ token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);
+ }
+ if (token.type === "link_open" && token.info === "auto") {
+ inside_autolink--;
+ }
+ if (token.type === "link_close" && token.info === "auto") {
+ inside_autolink++;
+ }
+ }
+ }
+ function replace_rare(inlineTokens) {
+ var i, token, inside_autolink = 0;
+ for (i = inlineTokens.length - 1; i >= 0; i--) {
+ token = inlineTokens[i];
+ if (token.type === "text" && !inside_autolink) {
+ if (RARE_RE.test(token.content)) {
+ token.content = token.content.replace(/\+-/g, "\xb1").replace(/\.{2,}/g, "\u2026").replace(/([?!])\u2026/g, "$1..").replace(/([?!]){4,}/g, "$1$1$1").replace(/,{2,}/g, ",").replace(/(^|[^-])---(?=[^-]|$)/gm, "$1\u2014").replace(/(^|\s)--(?=\s|$)/gm, "$1\u2013").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm, "$1\u2013");
+ }
+ }
+ if (token.type === "link_open" && token.info === "auto") {
+ inside_autolink--;
+ }
+ if (token.type === "link_close" && token.info === "auto") {
+ inside_autolink++;
+ }
+ }
+ }
+ var replacements = function replace(state) {
+ var blkIdx;
+ if (!state.md.options.typographer) {
+ return;
+ }
+ for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
+ if (state.tokens[blkIdx].type !== "inline") {
+ continue;
+ }
+ if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
+ replace_scoped(state.tokens[blkIdx].children);
+ }
+ if (RARE_RE.test(state.tokens[blkIdx].content)) {
+ replace_rare(state.tokens[blkIdx].children);
+ }
+ }
+ };
+ var isWhiteSpace$1 = utils.isWhiteSpace;
+ var isPunctChar$1 = utils.isPunctChar;
+ var isMdAsciiPunct$1 = utils.isMdAsciiPunct;
+ var QUOTE_TEST_RE = /['"]/;
+ var QUOTE_RE = /['"]/g;
+ var APOSTROPHE = "\u2019";
+ /* ’ */ function replaceAt(str, index, ch) {
+ return str.slice(0, index) + ch + str.slice(index + 1);
+ }
+ function process_inlines(tokens, state) {
+ var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar, isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace, canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;
+ stack = [];
+ for (i = 0; i < tokens.length; i++) {
+ token = tokens[i];
+ thisLevel = tokens[i].level;
+ for (j = stack.length - 1; j >= 0; j--) {
+ if (stack[j].level <= thisLevel) {
+ break;
+ }
+ }
+ stack.length = j + 1;
+ if (token.type !== "text") {
+ continue;
+ }
+ text = token.content;
+ pos = 0;
+ max = text.length;
+ /*eslint no-labels:0,block-scoped-var:0*/ OUTER: while (pos < max) {
+ QUOTE_RE.lastIndex = pos;
+ t = QUOTE_RE.exec(text);
+ if (!t) {
+ break;
+ }
+ canOpen = canClose = true;
+ pos = t.index + 1;
+ isSingle = t[0] === "'";
+ // Find previous character,
+ // default to space if it's the beginning of the line
+
+ lastChar = 32;
+ if (t.index - 1 >= 0) {
+ lastChar = text.charCodeAt(t.index - 1);
+ } else {
+ for (j = i - 1; j >= 0; j--) {
+ if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break;
+ // lastChar defaults to 0x20
+ if (!tokens[j].content) continue;
+ // should skip all tokens except 'text', 'html_inline' or 'code_inline'
+ lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
+ break;
+ }
+ }
+ // Find next character,
+ // default to space if it's the end of the line
+
+ nextChar = 32;
+ if (pos < max) {
+ nextChar = text.charCodeAt(pos);
+ } else {
+ for (j = i + 1; j < tokens.length; j++) {
+ if (tokens[j].type === "softbreak" || tokens[j].type === "hardbreak") break;
+ // nextChar defaults to 0x20
+ if (!tokens[j].content) continue;
+ // should skip all tokens except 'text', 'html_inline' or 'code_inline'
+ nextChar = tokens[j].content.charCodeAt(0);
+ break;
+ }
+ }
+ isLastPunctChar = isMdAsciiPunct$1(lastChar) || isPunctChar$1(String.fromCharCode(lastChar));
+ isNextPunctChar = isMdAsciiPunct$1(nextChar) || isPunctChar$1(String.fromCharCode(nextChar));
+ isLastWhiteSpace = isWhiteSpace$1(lastChar);
+ isNextWhiteSpace = isWhiteSpace$1(nextChar);
+ if (isNextWhiteSpace) {
+ canOpen = false;
+ } else if (isNextPunctChar) {
+ if (!(isLastWhiteSpace || isLastPunctChar)) {
+ canOpen = false;
+ }
+ }
+ if (isLastWhiteSpace) {
+ canClose = false;
+ } else if (isLastPunctChar) {
+ if (!(isNextWhiteSpace || isNextPunctChar)) {
+ canClose = false;
+ }
+ }
+ if (nextChar === 34 /* " */ && t[0] === '"') {
+ if (lastChar >= 48 /* 0 */ && lastChar <= 57 /* 9 */) {
+ // special case: 1"" - count first quote as an inch
+ canClose = canOpen = false;
+ }
+ }
+ if (canOpen && canClose) {
+ // Replace quotes in the middle of punctuation sequence, but not
+ // in the middle of the words, i.e.:
+ // 1. foo " bar " baz - not replaced
+ // 2. foo-"-bar-"-baz - replaced
+ // 3. foo"bar"baz - not replaced
+ canOpen = isLastPunctChar;
+ canClose = isNextPunctChar;
+ }
+ if (!canOpen && !canClose) {
+ // middle of word
+ if (isSingle) {
+ token.content = replaceAt(token.content, t.index, APOSTROPHE);
+ }
+ continue;
+ }
+ if (canClose) {
+ // this could be a closing quote, rewind the stack to get a match
+ for (j = stack.length - 1; j >= 0; j--) {
+ item = stack[j];
+ if (stack[j].level < thisLevel) {
+ break;
+ }
+ if (item.single === isSingle && stack[j].level === thisLevel) {
+ item = stack[j];
+ if (isSingle) {
+ openQuote = state.md.options.quotes[2];
+ closeQuote = state.md.options.quotes[3];
+ } else {
+ openQuote = state.md.options.quotes[0];
+ closeQuote = state.md.options.quotes[1];
+ }
+ // replace token.content *before* tokens[item.token].content,
+ // because, if they are pointing at the same token, replaceAt
+ // could mess up indices when quote length != 1
+ token.content = replaceAt(token.content, t.index, closeQuote);
+ tokens[item.token].content = replaceAt(tokens[item.token].content, item.pos, openQuote);
+ pos += closeQuote.length - 1;
+ if (item.token === i) {
+ pos += openQuote.length - 1;
+ }
+ text = token.content;
+ max = text.length;
+ stack.length = j;
+ continue OUTER;
+ }
+ }
+ }
+ if (canOpen) {
+ stack.push({
+ token: i,
+ pos: t.index,
+ single: isSingle,
+ level: thisLevel
+ });
+ } else if (canClose && isSingle) {
+ token.content = replaceAt(token.content, t.index, APOSTROPHE);
+ }
+ }
+ }
+ }
+ var smartquotes = function smartquotes(state) {
+ /*eslint max-depth:0*/
+ var blkIdx;
+ if (!state.md.options.typographer) {
+ return;
+ }
+ for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
+ if (state.tokens[blkIdx].type !== "inline" || !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {
+ continue;
+ }
+ process_inlines(state.tokens[blkIdx].children, state);
+ }
+ };
+ // Join raw text tokens with the rest of the text
+ var text_join = function text_join(state) {
+ var j, l, tokens, curr, max, last, blockTokens = state.tokens;
+ for (j = 0, l = blockTokens.length; j < l; j++) {
+ if (blockTokens[j].type !== "inline") continue;
+ tokens = blockTokens[j].children;
+ max = tokens.length;
+ for (curr = 0; curr < max; curr++) {
+ if (tokens[curr].type === "text_special") {
+ tokens[curr].type = "text";
+ }
+ }
+ for (curr = last = 0; curr < max; curr++) {
+ if (tokens[curr].type === "text" && curr + 1 < max && tokens[curr + 1].type === "text") {
+ // collapse two adjacent text nodes
+ tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
+ } else {
+ if (curr !== last) {
+ tokens[last] = tokens[curr];
+ }
+ last++;
+ }
+ }
+ if (curr !== last) {
+ tokens.length = last;
+ }
+ }
+ };
+ // Token class
+ /**
+ * class Token
+ **/
+ /**
+ * new Token(type, tag, nesting)
+ *
+ * Create new token and fill passed properties.
+ **/ function Token(type, tag, nesting) {
+ /**
+ * Token#type -> String
+ *
+ * Type of the token (string, e.g. "paragraph_open")
+ **/
+ this.type = type;
+ /**
+ * Token#tag -> String
+ *
+ * html tag name, e.g. "p"
+ **/ this.tag = tag;
+ /**
+ * Token#attrs -> Array
+ *
+ * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
+ **/ this.attrs = null;
+ /**
+ * Token#map -> Array
+ *
+ * Source map info. Format: `[ line_begin, line_end ]`
+ **/ this.map = null;
+ /**
+ * Token#nesting -> Number
+ *
+ * Level change (number in {-1, 0, 1} set), where:
+ *
+ * - `1` means the tag is opening
+ * - `0` means the tag is self-closing
+ * - `-1` means the tag is closing
+ **/ this.nesting = nesting;
+ /**
+ * Token#level -> Number
+ *
+ * nesting level, the same as `state.level`
+ **/ this.level = 0;
+ /**
+ * Token#children -> Array
+ *
+ * An array of child nodes (inline and img tokens)
+ **/ this.children = null;
+ /**
+ * Token#content -> String
+ *
+ * In a case of self-closing tag (code, html, fence, etc.),
+ * it has contents of this tag.
+ **/ this.content = "";
+ /**
+ * Token#markup -> String
+ *
+ * '*' or '_' for emphasis, fence string for fence, etc.
+ **/ this.markup = "";
+ /**
+ * Token#info -> String
+ *
+ * Additional information:
+ *
+ * - Info string for "fence" tokens
+ * - The value "auto" for autolink "link_open" and "link_close" tokens
+ * - The string value of the item marker for ordered-list "list_item_open" tokens
+ **/ this.info = "";
+ /**
+ * Token#meta -> Object
+ *
+ * A place for plugins to store an arbitrary data
+ **/ this.meta = null;
+ /**
+ * Token#block -> Boolean
+ *
+ * True for block-level tokens, false for inline tokens.
+ * Used in renderer to calculate line breaks
+ **/ this.block = false;
+ /**
+ * Token#hidden -> Boolean
+ *
+ * If it's true, ignore this element when rendering. Used for tight lists
+ * to hide paragraphs.
+ **/ this.hidden = false;
+ }
+ /**
+ * Token.attrIndex(name) -> Number
+ *
+ * Search attribute index by name.
+ **/ Token.prototype.attrIndex = function attrIndex(name) {
+ var attrs, i, len;
+ if (!this.attrs) {
+ return -1;
+ }
+ attrs = this.attrs;
+ for (i = 0, len = attrs.length; i < len; i++) {
+ if (attrs[i][0] === name) {
+ return i;
+ }
+ }
+ return -1;
+ };
+ /**
+ * Token.attrPush(attrData)
+ *
+ * Add `[ name, value ]` attribute to list. Init attrs if necessary
+ **/ Token.prototype.attrPush = function attrPush(attrData) {
+ if (this.attrs) {
+ this.attrs.push(attrData);
+ } else {
+ this.attrs = [ attrData ];
+ }
+ };
+ /**
+ * Token.attrSet(name, value)
+ *
+ * Set `name` attribute to `value`. Override old value if exists.
+ **/ Token.prototype.attrSet = function attrSet(name, value) {
+ var idx = this.attrIndex(name), attrData = [ name, value ];
+ if (idx < 0) {
+ this.attrPush(attrData);
+ } else {
+ this.attrs[idx] = attrData;
+ }
+ };
+ /**
+ * Token.attrGet(name)
+ *
+ * Get the value of attribute `name`, or null if it does not exist.
+ **/ Token.prototype.attrGet = function attrGet(name) {
+ var idx = this.attrIndex(name), value = null;
+ if (idx >= 0) {
+ value = this.attrs[idx][1];
+ }
+ return value;
+ };
+ /**
+ * Token.attrJoin(name, value)
+ *
+ * Join value to existing attribute via space. Or create new attribute if not
+ * exists. Useful to operate with token classes.
+ **/ Token.prototype.attrJoin = function attrJoin(name, value) {
+ var idx = this.attrIndex(name);
+ if (idx < 0) {
+ this.attrPush([ name, value ]);
+ } else {
+ this.attrs[idx][1] = this.attrs[idx][1] + " " + value;
+ }
+ };
+ var token = Token;
+ function StateCore(src, md, env) {
+ this.src = src;
+ this.env = env;
+ this.tokens = [];
+ this.inlineMode = false;
+ this.md = md;
+ // link to parser instance
+ }
+ // re-export Token class to use in core rules
+ StateCore.prototype.Token = token;
+ var state_core = StateCore;
+ var _rules$2 = [ [ "normalize", normalize ], [ "block", block ], [ "inline", inline ], [ "linkify", linkify$1 ], [ "replacements", replacements ], [ "smartquotes", smartquotes ],
+ // `text_join` finds `text_special` tokens (for escape sequences)
+ // and joins them with the rest of the text
+ [ "text_join", text_join ] ];
+ /**
+ * new Core()
+ **/ function Core() {
+ /**
+ * Core#ruler -> Ruler
+ *
+ * [[Ruler]] instance. Keep configuration of core rules.
+ **/
+ this.ruler = new ruler;
+ for (var i = 0; i < _rules$2.length; i++) {
+ this.ruler.push(_rules$2[i][0], _rules$2[i][1]);
+ }
+ }
+ /**
+ * Core.process(state)
+ *
+ * Executes core chain rules.
+ **/ Core.prototype.process = function(state) {
+ var i, l, rules;
+ rules = this.ruler.getRules("");
+ for (i = 0, l = rules.length; i < l; i++) {
+ rules[i](state);
+ }
+ };
+ Core.prototype.State = state_core;
+ var parser_core = Core;
+ var isSpace$a = utils.isSpace;
+ function getLine(state, line) {
+ var pos = state.bMarks[line] + state.tShift[line], max = state.eMarks[line];
+ return state.src.slice(pos, max);
+ }
+ function escapedSplit(str) {
+ var result = [], pos = 0, max = str.length, ch, isEscaped = false, lastPos = 0, current = "";
+ ch = str.charCodeAt(pos);
+ while (pos < max) {
+ if (ch === 124 /* | */) {
+ if (!isEscaped) {
+ // pipe separating cells, '|'
+ result.push(current + str.substring(lastPos, pos));
+ current = "";
+ lastPos = pos + 1;
+ } else {
+ // escaped pipe, '\|'
+ current += str.substring(lastPos, pos - 1);
+ lastPos = pos;
+ }
+ }
+ isEscaped = ch === 92 /* \ */;
+ pos++;
+ ch = str.charCodeAt(pos);
+ }
+ result.push(current + str.substring(lastPos));
+ return result;
+ }
+ var table = function table(state, startLine, endLine, silent) {
+ var ch, lineText, pos, i, l, nextLine, columns, columnCount, token, aligns, t, tableLines, tbodyLines, oldParentType, terminate, terminatorRules, firstCh, secondCh;
+ // should have at least two lines
+ if (startLine + 2 > endLine) {
+ return false;
+ }
+ nextLine = startLine + 1;
+ if (state.sCount[nextLine] < state.blkIndent) {
+ return false;
+ }
+ // if it's indented more than 3 spaces, it should be a code block
+ if (state.sCount[nextLine] - state.blkIndent >= 4) {
+ return false;
+ }
+ // first character of the second line should be '|', '-', ':',
+ // and no other characters are allowed but spaces;
+ // basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
+ pos = state.bMarks[nextLine] + state.tShift[nextLine];
+ if (pos >= state.eMarks[nextLine]) {
+ return false;
+ }
+ firstCh = state.src.charCodeAt(pos++);
+ if (firstCh !== 124 /* | */ && firstCh !== 45 /* - */ && firstCh !== 58 /* : */) {
+ return false;
+ }
+ if (pos >= state.eMarks[nextLine]) {
+ return false;
+ }
+ secondCh = state.src.charCodeAt(pos++);
+ if (secondCh !== 124 /* | */ && secondCh !== 45 /* - */ && secondCh !== 58 /* : */ && !isSpace$a(secondCh)) {
+ return false;
+ }
+ // if first character is '-', then second character must not be a space
+ // (due to parsing ambiguity with list)
+ if (firstCh === 45 /* - */ && isSpace$a(secondCh)) {
+ return false;
+ }
+ while (pos < state.eMarks[nextLine]) {
+ ch = state.src.charCodeAt(pos);
+ if (ch !== 124 /* | */ && ch !== 45 /* - */ && ch !== 58 /* : */ && !isSpace$a(ch)) {
+ return false;
+ }
+ pos++;
+ }
+ lineText = getLine(state, startLine + 1);
+ columns = lineText.split("|");
+ aligns = [];
+ for (i = 0; i < columns.length; i++) {
+ t = columns[i].trim();
+ if (!t) {
+ // allow empty columns before and after table, but not in between columns;
+ // e.g. allow ` |---| `, disallow ` ---||--- `
+ if (i === 0 || i === columns.length - 1) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ if (!/^:?-+:?$/.test(t)) {
+ return false;
+ }
+ if (t.charCodeAt(t.length - 1) === 58 /* : */) {
+ aligns.push(t.charCodeAt(0) === 58 /* : */ ? "center" : "right");
+ } else if (t.charCodeAt(0) === 58 /* : */) {
+ aligns.push("left");
+ } else {
+ aligns.push("");
+ }
+ }
+ lineText = getLine(state, startLine).trim();
+ if (lineText.indexOf("|") === -1) {
+ return false;
+ }
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
+ return false;
+ }
+ columns = escapedSplit(lineText);
+ if (columns.length && columns[0] === "") columns.shift();
+ if (columns.length && columns[columns.length - 1] === "") columns.pop();
+ // header row will define an amount of columns in the entire table,
+ // and align row should be exactly the same (the rest of the rows can differ)
+ columnCount = columns.length;
+ if (columnCount === 0 || columnCount !== aligns.length) {
+ return false;
+ }
+ if (silent) {
+ return true;
+ }
+ oldParentType = state.parentType;
+ state.parentType = "table";
+ // use 'blockquote' lists for termination because it's
+ // the most similar to tables
+ terminatorRules = state.md.block.ruler.getRules("blockquote");
+ token = state.push("table_open", "table", 1);
+ token.map = tableLines = [ startLine, 0 ];
+ token = state.push("thead_open", "thead", 1);
+ token.map = [ startLine, startLine + 1 ];
+ token = state.push("tr_open", "tr", 1);
+ token.map = [ startLine, startLine + 1 ];
+ for (i = 0; i < columns.length; i++) {
+ token = state.push("th_open", "th", 1);
+ if (aligns[i]) {
+ token.attrs = [ [ "style", "text-align:" + aligns[i] ] ];
+ }
+ token = state.push("inline", "", 0);
+ token.content = columns[i].trim();
+ token.children = [];
+ token = state.push("th_close", "th", -1);
+ }
+ token = state.push("tr_close", "tr", -1);
+ token = state.push("thead_close", "thead", -1);
+ for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
+ if (state.sCount[nextLine] < state.blkIndent) {
+ break;
+ }
+ terminate = false;
+ for (i = 0, l = terminatorRules.length; i < l; i++) {
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
+ terminate = true;
+ break;
+ }
+ }
+ if (terminate) {
+ break;
+ }
+ lineText = getLine(state, nextLine).trim();
+ if (!lineText) {
+ break;
+ }
+ if (state.sCount[nextLine] - state.blkIndent >= 4) {
+ break;
+ }
+ columns = escapedSplit(lineText);
+ if (columns.length && columns[0] === "") columns.shift();
+ if (columns.length && columns[columns.length - 1] === "") columns.pop();
+ if (nextLine === startLine + 2) {
+ token = state.push("tbody_open", "tbody", 1);
+ token.map = tbodyLines = [ startLine + 2, 0 ];
+ }
+ token = state.push("tr_open", "tr", 1);
+ token.map = [ nextLine, nextLine + 1 ];
+ for (i = 0; i < columnCount; i++) {
+ token = state.push("td_open", "td", 1);
+ if (aligns[i]) {
+ token.attrs = [ [ "style", "text-align:" + aligns[i] ] ];
+ }
+ token = state.push("inline", "", 0);
+ token.content = columns[i] ? columns[i].trim() : "";
+ token.children = [];
+ token = state.push("td_close", "td", -1);
+ }
+ token = state.push("tr_close", "tr", -1);
+ }
+ if (tbodyLines) {
+ token = state.push("tbody_close", "tbody", -1);
+ tbodyLines[1] = nextLine;
+ }
+ token = state.push("table_close", "table", -1);
+ tableLines[1] = nextLine;
+ state.parentType = oldParentType;
+ state.line = nextLine;
+ return true;
+ };
+ // Code block (4 spaces padded)
+ var code = function code(state, startLine, endLine /*, silent*/) {
+ var nextLine, last, token;
+ if (state.sCount[startLine] - state.blkIndent < 4) {
+ return false;
+ }
+ last = nextLine = startLine + 1;
+ while (nextLine < endLine) {
+ if (state.isEmpty(nextLine)) {
+ nextLine++;
+ continue;
+ }
+ if (state.sCount[nextLine] - state.blkIndent >= 4) {
+ nextLine++;
+ last = nextLine;
+ continue;
+ }
+ break;
+ }
+ state.line = last;
+ token = state.push("code_block", "code", 0);
+ token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + "\n";
+ token.map = [ startLine, state.line ];
+ return true;
+ };
+ // fences (``` lang, ~~~ lang)
+ var fence = function fence(state, startLine, endLine, silent) {
+ var marker, len, params, nextLine, mem, token, markup, haveEndMarker = false, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
+ // if it's indented more than 3 spaces, it should be a code block
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
+ return false;
+ }
+ if (pos + 3 > max) {
+ return false;
+ }
+ marker = state.src.charCodeAt(pos);
+ if (marker !== 126 /* ~ */ && marker !== 96 /* ` */) {
+ return false;
+ }
+ // scan marker length
+ mem = pos;
+ pos = state.skipChars(pos, marker);
+ len = pos - mem;
+ if (len < 3) {
+ return false;
+ }
+ markup = state.src.slice(mem, pos);
+ params = state.src.slice(pos, max);
+ if (marker === 96 /* ` */) {
+ if (params.indexOf(String.fromCharCode(marker)) >= 0) {
+ return false;
+ }
+ }
+ // Since start is found, we can report success here in validation mode
+ if (silent) {
+ return true;
+ }
+ // search end of block
+ nextLine = startLine;
+ for (;;) {
+ nextLine++;
+ if (nextLine >= endLine) {
+ // unclosed block should be autoclosed by end of document.
+ // also block seems to be autoclosed by end of parent
+ break;
+ }
+ pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
+ max = state.eMarks[nextLine];
+ if (pos < max && state.sCount[nextLine] < state.blkIndent) {
+ // non-empty line with negative indent should stop the list:
+ // - ```
+ // test
+ break;
+ }
+ if (state.src.charCodeAt(pos) !== marker) {
+ continue;
+ }
+ if (state.sCount[nextLine] - state.blkIndent >= 4) {
+ // closing fence should be indented less than 4 spaces
+ continue;
+ }
+ pos = state.skipChars(pos, marker);
+ // closing code fence must be at least as long as the opening one
+ if (pos - mem < len) {
+ continue;
+ }
+ // make sure tail has spaces only
+ pos = state.skipSpaces(pos);
+ if (pos < max) {
+ continue;
+ }
+ haveEndMarker = true;
+ // found!
+ break;
+ }
+ // If a fence has heading spaces, they should be removed from its inner block
+ len = state.sCount[startLine];
+ state.line = nextLine + (haveEndMarker ? 1 : 0);
+ token = state.push("fence", "code", 0);
+ token.info = params;
+ token.content = state.getLines(startLine + 1, nextLine, len, true);
+ token.markup = markup;
+ token.map = [ startLine, state.line ];
+ return true;
+ };
+ var isSpace$9 = utils.isSpace;
+ var blockquote = function blockquote(state, startLine, endLine, silent) {
+ var adjustTab, ch, i, initial, l, lastLineEmpty, lines, nextLine, offset, oldBMarks, oldBSCount, oldIndent, oldParentType, oldSCount, oldTShift, spaceAfterMarker, terminate, terminatorRules, token, isOutdented, oldLineMax = state.lineMax, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
+ // if it's indented more than 3 spaces, it should be a code block
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
+ return false;
+ }
+ // check the block quote marker
+ if (state.src.charCodeAt(pos++) !== 62 /* > */) {
+ return false;
+ }
+ // we know that it's going to be a valid blockquote,
+ // so no point trying to find the end of it in silent mode
+ if (silent) {
+ return true;
+ }
+ // set offset past spaces and ">"
+ initial = offset = state.sCount[startLine] + 1;
+ // skip one optional space after '>'
+ if (state.src.charCodeAt(pos) === 32 /* space */) {
+ // ' > test '
+ // ^ -- position start of line here:
+ pos++;
+ initial++;
+ offset++;
+ adjustTab = false;
+ spaceAfterMarker = true;
+ } else if (state.src.charCodeAt(pos) === 9 /* tab */) {
+ spaceAfterMarker = true;
+ if ((state.bsCount[startLine] + offset) % 4 === 3) {
+ // ' >\t test '
+ // ^ -- position start of line here (tab has width===1)
+ pos++;
+ initial++;
+ offset++;
+ adjustTab = false;
+ } else {
+ // ' >\t test '
+ // ^ -- position start of line here + shift bsCount slightly
+ // to make extra space appear
+ adjustTab = true;
+ }
+ } else {
+ spaceAfterMarker = false;
+ }
+ oldBMarks = [ state.bMarks[startLine] ];
+ state.bMarks[startLine] = pos;
+ while (pos < max) {
+ ch = state.src.charCodeAt(pos);
+ if (isSpace$9(ch)) {
+ if (ch === 9) {
+ offset += 4 - (offset + state.bsCount[startLine] + (adjustTab ? 1 : 0)) % 4;
+ } else {
+ offset++;
+ }
+ } else {
+ break;
+ }
+ pos++;
+ }
+ oldBSCount = [ state.bsCount[startLine] ];
+ state.bsCount[startLine] = state.sCount[startLine] + 1 + (spaceAfterMarker ? 1 : 0);
+ lastLineEmpty = pos >= max;
+ oldSCount = [ state.sCount[startLine] ];
+ state.sCount[startLine] = offset - initial;
+ oldTShift = [ state.tShift[startLine] ];
+ state.tShift[startLine] = pos - state.bMarks[startLine];
+ terminatorRules = state.md.block.ruler.getRules("blockquote");
+ oldParentType = state.parentType;
+ state.parentType = "blockquote";
+ // Search the end of the block
+
+ // Block ends with either:
+ // 1. an empty line outside:
+ // ```
+ // > test
+
+ // ```
+ // 2. an empty line inside:
+ // ```
+ // >
+ // test
+ // ```
+ // 3. another tag:
+ // ```
+ // > test
+ // - - -
+ // ```
+ for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
+ // check if it's outdented, i.e. it's inside list item and indented
+ // less than said list item:
+ // ```
+ // 1. anything
+ // > current blockquote
+ // 2. checking this line
+ // ```
+ isOutdented = state.sCount[nextLine] < state.blkIndent;
+ pos = state.bMarks[nextLine] + state.tShift[nextLine];
+ max = state.eMarks[nextLine];
+ if (pos >= max) {
+ // Case 1: line is not inside the blockquote, and this line is empty.
+ break;
+ }
+ if (state.src.charCodeAt(pos++) === 62 /* > */ && !isOutdented) {
+ // This line is inside the blockquote.
+ // set offset past spaces and ">"
+ initial = offset = state.sCount[nextLine] + 1;
+ // skip one optional space after '>'
+ if (state.src.charCodeAt(pos) === 32 /* space */) {
+ // ' > test '
+ // ^ -- position start of line here:
+ pos++;
+ initial++;
+ offset++;
+ adjustTab = false;
+ spaceAfterMarker = true;
+ } else if (state.src.charCodeAt(pos) === 9 /* tab */) {
+ spaceAfterMarker = true;
+ if ((state.bsCount[nextLine] + offset) % 4 === 3) {
+ // ' >\t test '
+ // ^ -- position start of line here (tab has width===1)
+ pos++;
+ initial++;
+ offset++;
+ adjustTab = false;
+ } else {
+ // ' >\t test '
+ // ^ -- position start of line here + shift bsCount slightly
+ // to make extra space appear
+ adjustTab = true;
+ }
+ } else {
+ spaceAfterMarker = false;
+ }
+ oldBMarks.push(state.bMarks[nextLine]);
+ state.bMarks[nextLine] = pos;
+ while (pos < max) {
+ ch = state.src.charCodeAt(pos);
+ if (isSpace$9(ch)) {
+ if (ch === 9) {
+ offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4;
+ } else {
+ offset++;
+ }
+ } else {
+ break;
+ }
+ pos++;
+ }
+ lastLineEmpty = pos >= max;
+ oldBSCount.push(state.bsCount[nextLine]);
+ state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0);
+ oldSCount.push(state.sCount[nextLine]);
+ state.sCount[nextLine] = offset - initial;
+ oldTShift.push(state.tShift[nextLine]);
+ state.tShift[nextLine] = pos - state.bMarks[nextLine];
+ continue;
+ }
+ // Case 2: line is not inside the blockquote, and the last line was empty.
+ if (lastLineEmpty) {
+ break;
+ }
+ // Case 3: another tag found.
+ terminate = false;
+ for (i = 0, l = terminatorRules.length; i < l; i++) {
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
+ terminate = true;
+ break;
+ }
+ }
+ if (terminate) {
+ // Quirk to enforce "hard termination mode" for paragraphs;
+ // normally if you call `tokenize(state, startLine, nextLine)`,
+ // paragraphs will look below nextLine for paragraph continuation,
+ // but if blockquote is terminated by another tag, they shouldn't
+ state.lineMax = nextLine;
+ if (state.blkIndent !== 0) {
+ // state.blkIndent was non-zero, we now set it to zero,
+ // so we need to re-calculate all offsets to appear as
+ // if indent wasn't changed
+ oldBMarks.push(state.bMarks[nextLine]);
+ oldBSCount.push(state.bsCount[nextLine]);
+ oldTShift.push(state.tShift[nextLine]);
+ oldSCount.push(state.sCount[nextLine]);
+ state.sCount[nextLine] -= state.blkIndent;
+ }
+ break;
+ }
+ oldBMarks.push(state.bMarks[nextLine]);
+ oldBSCount.push(state.bsCount[nextLine]);
+ oldTShift.push(state.tShift[nextLine]);
+ oldSCount.push(state.sCount[nextLine]);
+ // A negative indentation means that this is a paragraph continuation
+
+ state.sCount[nextLine] = -1;
+ }
+ oldIndent = state.blkIndent;
+ state.blkIndent = 0;
+ token = state.push("blockquote_open", "blockquote", 1);
+ token.markup = ">";
+ token.map = lines = [ startLine, 0 ];
+ state.md.block.tokenize(state, startLine, nextLine);
+ token = state.push("blockquote_close", "blockquote", -1);
+ token.markup = ">";
+ state.lineMax = oldLineMax;
+ state.parentType = oldParentType;
+ lines[1] = state.line;
+ // Restore original tShift; this might not be necessary since the parser
+ // has already been here, but just to make sure we can do that.
+ for (i = 0; i < oldTShift.length; i++) {
+ state.bMarks[i + startLine] = oldBMarks[i];
+ state.tShift[i + startLine] = oldTShift[i];
+ state.sCount[i + startLine] = oldSCount[i];
+ state.bsCount[i + startLine] = oldBSCount[i];
+ }
+ state.blkIndent = oldIndent;
+ return true;
+ };
+ var isSpace$8 = utils.isSpace;
+ var hr = function hr(state, startLine, endLine, silent) {
+ var marker, cnt, ch, token, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
+ // if it's indented more than 3 spaces, it should be a code block
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
+ return false;
+ }
+ marker = state.src.charCodeAt(pos++);
+ // Check hr marker
+ if (marker !== 42 /* * */ && marker !== 45 /* - */ && marker !== 95 /* _ */) {
+ return false;
+ }
+ // markers can be mixed with spaces, but there should be at least 3 of them
+ cnt = 1;
+ while (pos < max) {
+ ch = state.src.charCodeAt(pos++);
+ if (ch !== marker && !isSpace$8(ch)) {
+ return false;
+ }
+ if (ch === marker) {
+ cnt++;
+ }
+ }
+ if (cnt < 3) {
+ return false;
+ }
+ if (silent) {
+ return true;
+ }
+ state.line = startLine + 1;
+ token = state.push("hr", "hr", 0);
+ token.map = [ startLine, state.line ];
+ token.markup = Array(cnt + 1).join(String.fromCharCode(marker));
+ return true;
+ };
+ var isSpace$7 = utils.isSpace;
+ // Search `[-+*][\n ]`, returns next pos after marker on success
+ // or -1 on fail.
+ function skipBulletListMarker(state, startLine) {
+ var marker, pos, max, ch;
+ pos = state.bMarks[startLine] + state.tShift[startLine];
+ max = state.eMarks[startLine];
+ marker = state.src.charCodeAt(pos++);
+ // Check bullet
+ if (marker !== 42 /* * */ && marker !== 45 /* - */ && marker !== 43 /* + */) {
+ return -1;
+ }
+ if (pos < max) {
+ ch = state.src.charCodeAt(pos);
+ if (!isSpace$7(ch)) {
+ // " -test " - is not a list item
+ return -1;
+ }
+ }
+ return pos;
+ }
+ // Search `\d+[.)][\n ]`, returns next pos after marker on success
+ // or -1 on fail.
+ function skipOrderedListMarker(state, startLine) {
+ var ch, start = state.bMarks[startLine] + state.tShift[startLine], pos = start, max = state.eMarks[startLine];
+ // List marker should have at least 2 chars (digit + dot)
+ if (pos + 1 >= max) {
+ return -1;
+ }
+ ch = state.src.charCodeAt(pos++);
+ if (ch < 48 /* 0 */ || ch > 57 /* 9 */) {
+ return -1;
+ }
+ for (;;) {
+ // EOL -> fail
+ if (pos >= max) {
+ return -1;
+ }
+ ch = state.src.charCodeAt(pos++);
+ if (ch >= 48 /* 0 */ && ch <= 57 /* 9 */) {
+ // List marker should have no more than 9 digits
+ // (prevents integer overflow in browsers)
+ if (pos - start >= 10) {
+ return -1;
+ }
+ continue;
+ }
+ // found valid marker
+ if (ch === 41 /* ) */ || ch === 46 /* . */) {
+ break;
+ }
+ return -1;
+ }
+ if (pos < max) {
+ ch = state.src.charCodeAt(pos);
+ if (!isSpace$7(ch)) {
+ // " 1.test " - is not a list item
+ return -1;
+ }
+ }
+ return pos;
+ }
+ function markTightParagraphs(state, idx) {
+ var i, l, level = state.level + 2;
+ for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
+ if (state.tokens[i].level === level && state.tokens[i].type === "paragraph_open") {
+ state.tokens[i + 2].hidden = true;
+ state.tokens[i].hidden = true;
+ i += 2;
+ }
+ }
+ }
+ var list = function list(state, startLine, endLine, silent) {
+ var ch, contentStart, i, indent, indentAfterMarker, initial, isOrdered, itemLines, l, listLines, listTokIdx, markerCharCode, markerValue, max, nextLine, offset, oldListIndent, oldParentType, oldSCount, oldTShift, oldTight, pos, posAfterMarker, prevEmptyEnd, start, terminate, terminatorRules, token, isTerminatingParagraph = false, tight = true;
+ // if it's indented more than 3 spaces, it should be a code block
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
+ return false;
+ }
+ // Special case:
+ // - item 1
+ // - item 2
+ // - item 3
+ // - item 4
+ // - this one is a paragraph continuation
+ if (state.listIndent >= 0 && state.sCount[startLine] - state.listIndent >= 4 && state.sCount[startLine] < state.blkIndent) {
+ return false;
+ }
+ // limit conditions when list can interrupt
+ // a paragraph (validation mode only)
+ if (silent && state.parentType === "paragraph") {
+ // Next list item should still terminate previous list item;
+ // This code can fail if plugins use blkIndent as well as lists,
+ // but I hope the spec gets fixed long before that happens.
+ if (state.sCount[startLine] >= state.blkIndent) {
+ isTerminatingParagraph = true;
+ }
+ }
+ // Detect list type and position after marker
+ if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
+ isOrdered = true;
+ start = state.bMarks[startLine] + state.tShift[startLine];
+ markerValue = Number(state.src.slice(start, posAfterMarker - 1));
+ // If we're starting a new ordered list right after
+ // a paragraph, it should start with 1.
+ if (isTerminatingParagraph && markerValue !== 1) return false;
+ } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
+ isOrdered = false;
+ } else {
+ return false;
+ }
+ // If we're starting a new unordered list right after
+ // a paragraph, first line should not be empty.
+ if (isTerminatingParagraph) {
+ if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false;
+ }
+ // We should terminate list on style change. Remember first one to compare.
+ markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
+ // For validation mode we can terminate immediately
+ if (silent) {
+ return true;
+ }
+ // Start list
+ listTokIdx = state.tokens.length;
+ if (isOrdered) {
+ token = state.push("ordered_list_open", "ol", 1);
+ if (markerValue !== 1) {
+ token.attrs = [ [ "start", markerValue ] ];
+ }
+ } else {
+ token = state.push("bullet_list_open", "ul", 1);
+ }
+ token.map = listLines = [ startLine, 0 ];
+ token.markup = String.fromCharCode(markerCharCode);
+
+ // Iterate list items
+
+ nextLine = startLine;
+ prevEmptyEnd = false;
+ terminatorRules = state.md.block.ruler.getRules("list");
+ oldParentType = state.parentType;
+ state.parentType = "list";
+ while (nextLine < endLine) {
+ pos = posAfterMarker;
+ max = state.eMarks[nextLine];
+ initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[startLine] + state.tShift[startLine]);
+ while (pos < max) {
+ ch = state.src.charCodeAt(pos);
+ if (ch === 9) {
+ offset += 4 - (offset + state.bsCount[nextLine]) % 4;
+ } else if (ch === 32) {
+ offset++;
+ } else {
+ break;
+ }
+ pos++;
+ }
+ contentStart = pos;
+ if (contentStart >= max) {
+ // trimming space in "- \n 3" case, indent is 1 here
+ indentAfterMarker = 1;
+ } else {
+ indentAfterMarker = offset - initial;
+ }
+ // If we have more than 4 spaces, the indent is 1
+ // (the rest is just indented code block)
+ if (indentAfterMarker > 4) {
+ indentAfterMarker = 1;
+ }
+ // " - test"
+ // ^^^^^ - calculating total length of this thing
+ indent = initial + indentAfterMarker;
+ // Run subparser & write tokens
+ token = state.push("list_item_open", "li", 1);
+ token.markup = String.fromCharCode(markerCharCode);
+ token.map = itemLines = [ startLine, 0 ];
+ if (isOrdered) {
+ token.info = state.src.slice(start, posAfterMarker - 1);
+ }
+ // change current state, then restore it after parser subcall
+ oldTight = state.tight;
+ oldTShift = state.tShift[startLine];
+ oldSCount = state.sCount[startLine];
+ // - example list
+ // ^ listIndent position will be here
+ // ^ blkIndent position will be here
+
+ oldListIndent = state.listIndent;
+ state.listIndent = state.blkIndent;
+ state.blkIndent = indent;
+ state.tight = true;
+ state.tShift[startLine] = contentStart - state.bMarks[startLine];
+ state.sCount[startLine] = offset;
+ if (contentStart >= max && state.isEmpty(startLine + 1)) {
+ // workaround for this case
+ // (list item is empty, list terminates before "foo"):
+ // ~~~~~~~~
+ // -
+ // foo
+ // ~~~~~~~~
+ state.line = Math.min(state.line + 2, endLine);
+ } else {
+ state.md.block.tokenize(state, startLine, endLine, true);
+ }
+ // If any of list item is tight, mark list as tight
+ if (!state.tight || prevEmptyEnd) {
+ tight = false;
+ }
+ // Item become loose if finish with empty line,
+ // but we should filter last element, because it means list finish
+ prevEmptyEnd = state.line - startLine > 1 && state.isEmpty(state.line - 1);
+ state.blkIndent = state.listIndent;
+ state.listIndent = oldListIndent;
+ state.tShift[startLine] = oldTShift;
+ state.sCount[startLine] = oldSCount;
+ state.tight = oldTight;
+ token = state.push("list_item_close", "li", -1);
+ token.markup = String.fromCharCode(markerCharCode);
+ nextLine = startLine = state.line;
+ itemLines[1] = nextLine;
+ contentStart = state.bMarks[startLine];
+ if (nextLine >= endLine) {
+ break;
+ }
+
+ // Try to check if list is terminated or continued.
+
+ if (state.sCount[nextLine] < state.blkIndent) {
+ break;
+ }
+ // if it's indented more than 3 spaces, it should be a code block
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
+ break;
+ }
+ // fail if terminating block found
+ terminate = false;
+ for (i = 0, l = terminatorRules.length; i < l; i++) {
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
+ terminate = true;
+ break;
+ }
+ }
+ if (terminate) {
+ break;
+ }
+ // fail if list has another type
+ if (isOrdered) {
+ posAfterMarker = skipOrderedListMarker(state, nextLine);
+ if (posAfterMarker < 0) {
+ break;
+ }
+ start = state.bMarks[nextLine] + state.tShift[nextLine];
+ } else {
+ posAfterMarker = skipBulletListMarker(state, nextLine);
+ if (posAfterMarker < 0) {
+ break;
+ }
+ }
+ if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) {
+ break;
+ }
+ }
+ // Finalize list
+ if (isOrdered) {
+ token = state.push("ordered_list_close", "ol", -1);
+ } else {
+ token = state.push("bullet_list_close", "ul", -1);
+ }
+ token.markup = String.fromCharCode(markerCharCode);
+ listLines[1] = nextLine;
+ state.line = nextLine;
+ state.parentType = oldParentType;
+ // mark paragraphs tight if needed
+ if (tight) {
+ markTightParagraphs(state, listTokIdx);
+ }
+ return true;
+ };
+ var normalizeReference$2 = utils.normalizeReference;
+ var isSpace$6 = utils.isSpace;
+ var reference = function reference(state, startLine, _endLine, silent) {
+ var ch, destEndPos, destEndLineNo, endLine, href, i, l, label, labelEnd, oldParentType, res, start, str, terminate, terminatorRules, title, lines = 0, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine], nextLine = startLine + 1;
+ // if it's indented more than 3 spaces, it should be a code block
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
+ return false;
+ }
+ if (state.src.charCodeAt(pos) !== 91 /* [ */) {
+ return false;
+ }
+ // Simple check to quickly interrupt scan on [link](url) at the start of line.
+ // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54
+ while (++pos < max) {
+ if (state.src.charCodeAt(pos) === 93 /* ] */ && state.src.charCodeAt(pos - 1) !== 92 /* \ */) {
+ if (pos + 1 === max) {
+ return false;
+ }
+ if (state.src.charCodeAt(pos + 1) !== 58 /* : */) {
+ return false;
+ }
+ break;
+ }
+ }
+ endLine = state.lineMax;
+ // jump line-by-line until empty one or EOF
+ terminatorRules = state.md.block.ruler.getRules("reference");
+ oldParentType = state.parentType;
+ state.parentType = "reference";
+ for (;nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
+ // this would be a code block normally, but after paragraph
+ // it's considered a lazy continuation regardless of what's there
+ if (state.sCount[nextLine] - state.blkIndent > 3) {
+ continue;
+ }
+ // quirk for blockquotes, this line should already be checked by that rule
+ if (state.sCount[nextLine] < 0) {
+ continue;
+ }
+ // Some tags can terminate paragraph without empty line.
+ terminate = false;
+ for (i = 0, l = terminatorRules.length; i < l; i++) {
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
+ terminate = true;
+ break;
+ }
+ }
+ if (terminate) {
+ break;
+ }
+ }
+ str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
+ max = str.length;
+ for (pos = 1; pos < max; pos++) {
+ ch = str.charCodeAt(pos);
+ if (ch === 91 /* [ */) {
+ return false;
+ } else if (ch === 93 /* ] */) {
+ labelEnd = pos;
+ break;
+ } else if (ch === 10 /* \n */) {
+ lines++;
+ } else if (ch === 92 /* \ */) {
+ pos++;
+ if (pos < max && str.charCodeAt(pos) === 10) {
+ lines++;
+ }
+ }
+ }
+ if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 58 /* : */) {
+ return false;
+ }
+ // [label]: destination 'title'
+ // ^^^ skip optional whitespace here
+ for (pos = labelEnd + 2; pos < max; pos++) {
+ ch = str.charCodeAt(pos);
+ if (ch === 10) {
+ lines++;
+ } else if (isSpace$6(ch)) ; else {
+ break;
+ }
+ }
+ // [label]: destination 'title'
+ // ^^^^^^^^^^^ parse this
+ res = state.md.helpers.parseLinkDestination(str, pos, max);
+ if (!res.ok) {
+ return false;
+ }
+ href = state.md.normalizeLink(res.str);
+ if (!state.md.validateLink(href)) {
+ return false;
+ }
+ pos = res.pos;
+ lines += res.lines;
+ // save cursor state, we could require to rollback later
+ destEndPos = pos;
+ destEndLineNo = lines;
+ // [label]: destination 'title'
+ // ^^^ skipping those spaces
+ start = pos;
+ for (;pos < max; pos++) {
+ ch = str.charCodeAt(pos);
+ if (ch === 10) {
+ lines++;
+ } else if (isSpace$6(ch)) ; else {
+ break;
+ }
+ }
+ // [label]: destination 'title'
+ // ^^^^^^^ parse this
+ res = state.md.helpers.parseLinkTitle(str, pos, max);
+ if (pos < max && start !== pos && res.ok) {
+ title = res.str;
+ pos = res.pos;
+ lines += res.lines;
+ } else {
+ title = "";
+ pos = destEndPos;
+ lines = destEndLineNo;
+ }
+ // skip trailing spaces until the rest of the line
+ while (pos < max) {
+ ch = str.charCodeAt(pos);
+ if (!isSpace$6(ch)) {
+ break;
+ }
+ pos++;
+ }
+ if (pos < max && str.charCodeAt(pos) !== 10) {
+ if (title) {
+ // garbage at the end of the line after title,
+ // but it could still be a valid reference if we roll back
+ title = "";
+ pos = destEndPos;
+ lines = destEndLineNo;
+ while (pos < max) {
+ ch = str.charCodeAt(pos);
+ if (!isSpace$6(ch)) {
+ break;
+ }
+ pos++;
+ }
+ }
+ }
+ if (pos < max && str.charCodeAt(pos) !== 10) {
+ // garbage at the end of the line
+ return false;
+ }
+ label = normalizeReference$2(str.slice(1, labelEnd));
+ if (!label) {
+ // CommonMark 0.20 disallows empty labels
+ return false;
+ }
+ // Reference can not terminate anything. This check is for safety only.
+ /*istanbul ignore if*/ if (silent) {
+ return true;
+ }
+ if (typeof state.env.references === "undefined") {
+ state.env.references = {};
+ }
+ if (typeof state.env.references[label] === "undefined") {
+ state.env.references[label] = {
+ title: title,
+ href: href
+ };
+ }
+ state.parentType = oldParentType;
+ state.line = startLine + lines + 1;
+ return true;
+ };
+ // List of valid html blocks names, accorting to commonmark spec
+ var html_blocks = [ "address", "article", "aside", "base", "basefont", "blockquote", "body", "caption", "center", "col", "colgroup", "dd", "details", "dialog", "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hr", "html", "iframe", "legend", "li", "link", "main", "menu", "menuitem", "nav", "noframes", "ol", "optgroup", "option", "p", "param", "section", "source", "summary", "table", "tbody", "td", "tfoot", "th", "thead", "title", "tr", "track", "ul" ];
+ // Regexps to match html elements
+ var attr_name = "[a-zA-Z_:][a-zA-Z0-9:._-]*";
+ var unquoted = "[^\"'=<>`\\x00-\\x20]+";
+ var single_quoted = "'[^']*'";
+ var double_quoted = '"[^"]*"';
+ var attr_value = "(?:" + unquoted + "|" + single_quoted + "|" + double_quoted + ")";
+ var attribute = "(?:\\s+" + attr_name + "(?:\\s*=\\s*" + attr_value + ")?)";
+ var open_tag = "<[A-Za-z][A-Za-z0-9\\-]*" + attribute + "*\\s*\\/?>";
+ var close_tag = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";
+ var comment = "\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e";
+ var processing = "<[?][\\s\\S]*?[?]>";
+ var declaration = "]*>";
+ var cdata = "";
+ var HTML_TAG_RE$1 = new RegExp("^(?:" + open_tag + "|" + close_tag + "|" + comment + "|" + processing + "|" + declaration + "|" + cdata + ")");
+ var HTML_OPEN_CLOSE_TAG_RE$1 = new RegExp("^(?:" + open_tag + "|" + close_tag + ")");
+ var HTML_TAG_RE_1 = HTML_TAG_RE$1;
+ var HTML_OPEN_CLOSE_TAG_RE_1 = HTML_OPEN_CLOSE_TAG_RE$1;
+ var html_re = {
+ HTML_TAG_RE: HTML_TAG_RE_1,
+ HTML_OPEN_CLOSE_TAG_RE: HTML_OPEN_CLOSE_TAG_RE_1
+ };
+ var HTML_OPEN_CLOSE_TAG_RE = html_re.HTML_OPEN_CLOSE_TAG_RE;
+ // An array of opening and corresponding closing sequences for html tags,
+ // last argument defines whether it can terminate a paragraph or not
+
+ var HTML_SEQUENCES = [ [ /^<(script|pre|style|textarea)(?=(\s|>|$))/i, /<\/(script|pre|style|textarea)>/i, true ], [ /^/, true ], [ /^<\?/, /\?>/, true ], [ /^/, true ], [ /^/, true ], [ new RegExp("^?(" + html_blocks.join("|") + ")(?=(\\s|/?>|$))", "i"), /^$/, true ], [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + "\\s*$"), /^$/, false ] ];
+ var html_block = function html_block(state, startLine, endLine, silent) {
+ var i, nextLine, token, lineText, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
+ // if it's indented more than 3 spaces, it should be a code block
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
+ return false;
+ }
+ if (!state.md.options.html) {
+ return false;
+ }
+ if (state.src.charCodeAt(pos) !== 60 /* < */) {
+ return false;
+ }
+ lineText = state.src.slice(pos, max);
+ for (i = 0; i < HTML_SEQUENCES.length; i++) {
+ if (HTML_SEQUENCES[i][0].test(lineText)) {
+ break;
+ }
+ }
+ if (i === HTML_SEQUENCES.length) {
+ return false;
+ }
+ if (silent) {
+ // true if this sequence can be a terminator, false otherwise
+ return HTML_SEQUENCES[i][2];
+ }
+ nextLine = startLine + 1;
+ // If we are here - we detected HTML block.
+ // Let's roll down till block end.
+ if (!HTML_SEQUENCES[i][1].test(lineText)) {
+ for (;nextLine < endLine; nextLine++) {
+ if (state.sCount[nextLine] < state.blkIndent) {
+ break;
+ }
+ pos = state.bMarks[nextLine] + state.tShift[nextLine];
+ max = state.eMarks[nextLine];
+ lineText = state.src.slice(pos, max);
+ if (HTML_SEQUENCES[i][1].test(lineText)) {
+ if (lineText.length !== 0) {
+ nextLine++;
+ }
+ break;
+ }
+ }
+ }
+ state.line = nextLine;
+ token = state.push("html_block", "", 0);
+ token.map = [ startLine, nextLine ];
+ token.content = state.getLines(startLine, nextLine, state.blkIndent, true);
+ return true;
+ };
+ var isSpace$5 = utils.isSpace;
+ var heading = function heading(state, startLine, endLine, silent) {
+ var ch, level, tmp, token, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
+ // if it's indented more than 3 spaces, it should be a code block
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
+ return false;
+ }
+ ch = state.src.charCodeAt(pos);
+ if (ch !== 35 /* # */ || pos >= max) {
+ return false;
+ }
+ // count heading level
+ level = 1;
+ ch = state.src.charCodeAt(++pos);
+ while (ch === 35 /* # */ && pos < max && level <= 6) {
+ level++;
+ ch = state.src.charCodeAt(++pos);
+ }
+ if (level > 6 || pos < max && !isSpace$5(ch)) {
+ return false;
+ }
+ if (silent) {
+ return true;
+ }
+ // Let's cut tails like ' ### ' from the end of string
+ max = state.skipSpacesBack(max, pos);
+ tmp = state.skipCharsBack(max, 35, pos);
+ // #
+ if (tmp > pos && isSpace$5(state.src.charCodeAt(tmp - 1))) {
+ max = tmp;
+ }
+ state.line = startLine + 1;
+ token = state.push("heading_open", "h" + String(level), 1);
+ token.markup = "########".slice(0, level);
+ token.map = [ startLine, state.line ];
+ token = state.push("inline", "", 0);
+ token.content = state.src.slice(pos, max).trim();
+ token.map = [ startLine, state.line ];
+ token.children = [];
+ token = state.push("heading_close", "h" + String(level), -1);
+ token.markup = "########".slice(0, level);
+ return true;
+ };
+ // lheading (---, ===)
+ var lheading = function lheading(state, startLine, endLine /*, silent*/) {
+ var content, terminate, i, l, token, pos, max, level, marker, nextLine = startLine + 1, oldParentType, terminatorRules = state.md.block.ruler.getRules("paragraph");
+ // if it's indented more than 3 spaces, it should be a code block
+ if (state.sCount[startLine] - state.blkIndent >= 4) {
+ return false;
+ }
+ oldParentType = state.parentType;
+ state.parentType = "paragraph";
+ // use paragraph to match terminatorRules
+ // jump line-by-line until empty one or EOF
+ for (;nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
+ // this would be a code block normally, but after paragraph
+ // it's considered a lazy continuation regardless of what's there
+ if (state.sCount[nextLine] - state.blkIndent > 3) {
+ continue;
+ }
+
+ // Check for underline in setext header
+
+ if (state.sCount[nextLine] >= state.blkIndent) {
+ pos = state.bMarks[nextLine] + state.tShift[nextLine];
+ max = state.eMarks[nextLine];
+ if (pos < max) {
+ marker = state.src.charCodeAt(pos);
+ if (marker === 45 /* - */ || marker === 61 /* = */) {
+ pos = state.skipChars(pos, marker);
+ pos = state.skipSpaces(pos);
+ if (pos >= max) {
+ level = marker === 61 /* = */ ? 1 : 2;
+ break;
+ }
+ }
+ }
+ }
+ // quirk for blockquotes, this line should already be checked by that rule
+ if (state.sCount[nextLine] < 0) {
+ continue;
+ }
+ // Some tags can terminate paragraph without empty line.
+ terminate = false;
+ for (i = 0, l = terminatorRules.length; i < l; i++) {
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
+ terminate = true;
+ break;
+ }
+ }
+ if (terminate) {
+ break;
+ }
+ }
+ if (!level) {
+ // Didn't find valid underline
+ return false;
+ }
+ content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
+ state.line = nextLine + 1;
+ token = state.push("heading_open", "h" + String(level), 1);
+ token.markup = String.fromCharCode(marker);
+ token.map = [ startLine, state.line ];
+ token = state.push("inline", "", 0);
+ token.content = content;
+ token.map = [ startLine, state.line - 1 ];
+ token.children = [];
+ token = state.push("heading_close", "h" + String(level), -1);
+ token.markup = String.fromCharCode(marker);
+ state.parentType = oldParentType;
+ return true;
+ };
+ // Paragraph
+ var paragraph = function paragraph(state, startLine /*, endLine*/) {
+ var content, terminate, i, l, token, oldParentType, nextLine = startLine + 1, terminatorRules = state.md.block.ruler.getRules("paragraph"), endLine = state.lineMax;
+ oldParentType = state.parentType;
+ state.parentType = "paragraph";
+ // jump line-by-line until empty one or EOF
+ for (;nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
+ // this would be a code block normally, but after paragraph
+ // it's considered a lazy continuation regardless of what's there
+ if (state.sCount[nextLine] - state.blkIndent > 3) {
+ continue;
+ }
+ // quirk for blockquotes, this line should already be checked by that rule
+ if (state.sCount[nextLine] < 0) {
+ continue;
+ }
+ // Some tags can terminate paragraph without empty line.
+ terminate = false;
+ for (i = 0, l = terminatorRules.length; i < l; i++) {
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
+ terminate = true;
+ break;
+ }
+ }
+ if (terminate) {
+ break;
+ }
+ }
+ content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
+ state.line = nextLine;
+ token = state.push("paragraph_open", "p", 1);
+ token.map = [ startLine, state.line ];
+ token = state.push("inline", "", 0);
+ token.content = content;
+ token.map = [ startLine, state.line ];
+ token.children = [];
+ token = state.push("paragraph_close", "p", -1);
+ state.parentType = oldParentType;
+ return true;
+ };
+ var isSpace$4 = utils.isSpace;
+ function StateBlock(src, md, env, tokens) {
+ var ch, s, start, pos, len, indent, offset, indent_found;
+ this.src = src;
+ // link to parser instance
+ this.md = md;
+ this.env = env;
+
+ // Internal state vartiables
+
+ this.tokens = tokens;
+ this.bMarks = [];
+ // line begin offsets for fast jumps
+ this.eMarks = [];
+ // line end offsets for fast jumps
+ this.tShift = [];
+ // offsets of the first non-space characters (tabs not expanded)
+ this.sCount = [];
+ // indents for each line (tabs expanded)
+ // An amount of virtual spaces (tabs expanded) between beginning
+ // of each line (bMarks) and real beginning of that line.
+
+ // It exists only as a hack because blockquotes override bMarks
+ // losing information in the process.
+
+ // It's used only when expanding tabs, you can think about it as
+ // an initial tab length, e.g. bsCount=21 applied to string `\t123`
+ // means first tab should be expanded to 4-21%4 === 3 spaces.
+
+ this.bsCount = [];
+ // block parser variables
+ this.blkIndent = 0;
+ // required block content indent (for example, if we are
+ // inside a list, it would be positioned after list marker)
+ this.line = 0;
+ // line index in src
+ this.lineMax = 0;
+ // lines count
+ this.tight = false;
+ // loose/tight mode for lists
+ this.ddIndent = -1;
+ // indent of the current dd block (-1 if there isn't any)
+ this.listIndent = -1;
+ // indent of the current list block (-1 if there isn't any)
+ // can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
+ // used in lists to determine if they interrupt a paragraph
+ this.parentType = "root";
+ this.level = 0;
+ // renderer
+ this.result = "";
+ // Create caches
+ // Generate markers.
+ s = this.src;
+ indent_found = false;
+ for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) {
+ ch = s.charCodeAt(pos);
+ if (!indent_found) {
+ if (isSpace$4(ch)) {
+ indent++;
+ if (ch === 9) {
+ offset += 4 - offset % 4;
+ } else {
+ offset++;
+ }
+ continue;
+ } else {
+ indent_found = true;
+ }
+ }
+ if (ch === 10 || pos === len - 1) {
+ if (ch !== 10) {
+ pos++;
+ }
+ this.bMarks.push(start);
+ this.eMarks.push(pos);
+ this.tShift.push(indent);
+ this.sCount.push(offset);
+ this.bsCount.push(0);
+ indent_found = false;
+ indent = 0;
+ offset = 0;
+ start = pos + 1;
+ }
+ }
+ // Push fake entry to simplify cache bounds checks
+ this.bMarks.push(s.length);
+ this.eMarks.push(s.length);
+ this.tShift.push(0);
+ this.sCount.push(0);
+ this.bsCount.push(0);
+ this.lineMax = this.bMarks.length - 1;
+ // don't count last fake line
+ }
+ // Push new token to "stream".
+
+ StateBlock.prototype.push = function(type, tag, nesting) {
+ var token$1 = new token(type, tag, nesting);
+ token$1.block = true;
+ if (nesting < 0) this.level--;
+ // closing tag
+ token$1.level = this.level;
+ if (nesting > 0) this.level++;
+ // opening tag
+ this.tokens.push(token$1);
+ return token$1;
+ };
+ StateBlock.prototype.isEmpty = function isEmpty(line) {
+ return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
+ };
+ StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
+ for (var max = this.lineMax; from < max; from++) {
+ if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {
+ break;
+ }
+ }
+ return from;
+ };
+ // Skip spaces from given position.
+ StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
+ var ch;
+ for (var max = this.src.length; pos < max; pos++) {
+ ch = this.src.charCodeAt(pos);
+ if (!isSpace$4(ch)) {
+ break;
+ }
+ }
+ return pos;
+ };
+ // Skip spaces from given position in reverse.
+ StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {
+ if (pos <= min) {
+ return pos;
+ }
+ while (pos > min) {
+ if (!isSpace$4(this.src.charCodeAt(--pos))) {
+ return pos + 1;
+ }
+ }
+ return pos;
+ };
+ // Skip char codes from given position
+ StateBlock.prototype.skipChars = function skipChars(pos, code) {
+ for (var max = this.src.length; pos < max; pos++) {
+ if (this.src.charCodeAt(pos) !== code) {
+ break;
+ }
+ }
+ return pos;
+ };
+ // Skip char codes reverse from given position - 1
+ StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
+ if (pos <= min) {
+ return pos;
+ }
+ while (pos > min) {
+ if (code !== this.src.charCodeAt(--pos)) {
+ return pos + 1;
+ }
+ }
+ return pos;
+ };
+ // cut lines range from source.
+ StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
+ var i, lineIndent, ch, first, last, queue, lineStart, line = begin;
+ if (begin >= end) {
+ return "";
+ }
+ queue = new Array(end - begin);
+ for (i = 0; line < end; line++, i++) {
+ lineIndent = 0;
+ lineStart = first = this.bMarks[line];
+ if (line + 1 < end || keepLastLF) {
+ // No need for bounds check because we have fake entry on tail.
+ last = this.eMarks[line] + 1;
+ } else {
+ last = this.eMarks[line];
+ }
+ while (first < last && lineIndent < indent) {
+ ch = this.src.charCodeAt(first);
+ if (isSpace$4(ch)) {
+ if (ch === 9) {
+ lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;
+ } else {
+ lineIndent++;
+ }
+ } else if (first - lineStart < this.tShift[line]) {
+ // patched tShift masked characters to look like spaces (blockquotes, list markers)
+ lineIndent++;
+ } else {
+ break;
+ }
+ first++;
+ }
+ if (lineIndent > indent) {
+ // partially expanding tabs in code blocks, e.g '\t\tfoobar'
+ // with indent=2 becomes ' \tfoobar'
+ queue[i] = new Array(lineIndent - indent + 1).join(" ") + this.src.slice(first, last);
+ } else {
+ queue[i] = this.src.slice(first, last);
+ }
+ }
+ return queue.join("");
+ };
+ // re-export Token class to use in block rules
+ StateBlock.prototype.Token = token;
+ var state_block = StateBlock;
+ var _rules$1 = [
+ // First 2 params - rule name & source. Secondary array - list of rules,
+ // which can be terminated by this one.
+ [ "table", table, [ "paragraph", "reference" ] ], [ "code", code ], [ "fence", fence, [ "paragraph", "reference", "blockquote", "list" ] ], [ "blockquote", blockquote, [ "paragraph", "reference", "blockquote", "list" ] ], [ "hr", hr, [ "paragraph", "reference", "blockquote", "list" ] ], [ "list", list, [ "paragraph", "reference", "blockquote" ] ], [ "reference", reference ], [ "html_block", html_block, [ "paragraph", "reference", "blockquote" ] ], [ "heading", heading, [ "paragraph", "reference", "blockquote" ] ], [ "lheading", lheading ], [ "paragraph", paragraph ] ];
+ /**
+ * new ParserBlock()
+ **/ function ParserBlock() {
+ /**
+ * ParserBlock#ruler -> Ruler
+ *
+ * [[Ruler]] instance. Keep configuration of block rules.
+ **/
+ this.ruler = new ruler;
+ for (var i = 0; i < _rules$1.length; i++) {
+ this.ruler.push(_rules$1[i][0], _rules$1[i][1], {
+ alt: (_rules$1[i][2] || []).slice()
+ });
+ }
+ }
+ // Generate tokens for input range
+
+ ParserBlock.prototype.tokenize = function(state, startLine, endLine) {
+ var ok, i, rules = this.ruler.getRules(""), len = rules.length, line = startLine, hasEmptyLines = false, maxNesting = state.md.options.maxNesting;
+ while (line < endLine) {
+ state.line = line = state.skipEmptyLines(line);
+ if (line >= endLine) {
+ break;
+ }
+ // Termination condition for nested calls.
+ // Nested calls currently used for blockquotes & lists
+ if (state.sCount[line] < state.blkIndent) {
+ break;
+ }
+ // If nesting level exceeded - skip tail to the end. That's not ordinary
+ // situation and we should not care about content.
+ if (state.level >= maxNesting) {
+ state.line = endLine;
+ break;
+ }
+ // Try all possible rules.
+ // On success, rule should:
+
+ // - update `state.line`
+ // - update `state.tokens`
+ // - return true
+ for (i = 0; i < len; i++) {
+ ok = rules[i](state, line, endLine, false);
+ if (ok) {
+ break;
+ }
+ }
+ // set state.tight if we had an empty line before current tag
+ // i.e. latest empty line should not count
+ state.tight = !hasEmptyLines;
+ // paragraph might "eat" one newline after it in nested lists
+ if (state.isEmpty(state.line - 1)) {
+ hasEmptyLines = true;
+ }
+ line = state.line;
+ if (line < endLine && state.isEmpty(line)) {
+ hasEmptyLines = true;
+ line++;
+ state.line = line;
+ }
+ }
+ };
+ /**
+ * ParserBlock.parse(str, md, env, outTokens)
+ *
+ * Process input string and push block tokens into `outTokens`
+ **/ ParserBlock.prototype.parse = function(src, md, env, outTokens) {
+ var state;
+ if (!src) {
+ return;
+ }
+ state = new this.State(src, md, env, outTokens);
+ this.tokenize(state, state.line, state.lineMax);
+ };
+ ParserBlock.prototype.State = state_block;
+ var parser_block = ParserBlock;
+ // Skip text characters for text token, place those to pending buffer
+ // Rule to skip pure text
+ // '{}$%@~+=:' reserved for extentions
+ // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
+ // !!!! Don't confuse with "Markdown ASCII Punctuation" chars
+ // http://spec.commonmark.org/0.15/#ascii-punctuation-character
+ function isTerminatorChar(ch) {
+ switch (ch) {
+ case 10 /* \n */ :
+ case 33 /* ! */ :
+ case 35 /* # */ :
+ case 36 /* $ */ :
+ case 37 /* % */ :
+ case 38 /* & */ :
+ case 42 /* * */ :
+ case 43 /* + */ :
+ case 45 /* - */ :
+ case 58 /* : */ :
+ case 60 /* < */ :
+ case 61 /* = */ :
+ case 62 /* > */ :
+ case 64 /* @ */ :
+ case 91 /* [ */ :
+ case 92 /* \ */ :
+ case 93 /* ] */ :
+ case 94 /* ^ */ :
+ case 95 /* _ */ :
+ case 96 /* ` */ :
+ case 123 /* { */ :
+ case 125 /* } */ :
+ case 126 /* ~ */ :
+ return true;
+
+ default:
+ return false;
+ }
+ }
+ var text = function text(state, silent) {
+ var pos = state.pos;
+ while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {
+ pos++;
+ }
+ if (pos === state.pos) {
+ return false;
+ }
+ if (!silent) {
+ state.pending += state.src.slice(state.pos, pos);
+ }
+ state.pos = pos;
+ return true;
+ };
+ // Process links like https://example.org/
+ // RFC3986: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
+ var SCHEME_RE = /(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;
+ var linkify = function linkify(state, silent) {
+ var pos, max, match, proto, link, url, fullUrl, token;
+ if (!state.md.options.linkify) return false;
+ if (state.linkLevel > 0) return false;
+ pos = state.pos;
+ max = state.posMax;
+ if (pos + 3 > max) return false;
+ if (state.src.charCodeAt(pos) !== 58 /* : */) return false;
+ if (state.src.charCodeAt(pos + 1) !== 47 /* / */) return false;
+ if (state.src.charCodeAt(pos + 2) !== 47 /* / */) return false;
+ match = state.pending.match(SCHEME_RE);
+ if (!match) return false;
+ proto = match[1];
+ link = state.md.linkify.matchAtStart(state.src.slice(pos - proto.length));
+ if (!link) return false;
+ url = link.url;
+ // disallow '*' at the end of the link (conflicts with emphasis)
+ url = url.replace(/\*+$/, "");
+ fullUrl = state.md.normalizeLink(url);
+ if (!state.md.validateLink(fullUrl)) return false;
+ if (!silent) {
+ state.pending = state.pending.slice(0, -proto.length);
+ token = state.push("link_open", "a", 1);
+ token.attrs = [ [ "href", fullUrl ] ];
+ token.markup = "linkify";
+ token.info = "auto";
+ token = state.push("text", "", 0);
+ token.content = state.md.normalizeLinkText(url);
+ token = state.push("link_close", "a", -1);
+ token.markup = "linkify";
+ token.info = "auto";
+ }
+ state.pos += url.length - proto.length;
+ return true;
+ };
+ var isSpace$3 = utils.isSpace;
+ var newline = function newline(state, silent) {
+ var pmax, max, ws, pos = state.pos;
+ if (state.src.charCodeAt(pos) !== 10 /* \n */) {
+ return false;
+ }
+ pmax = state.pending.length - 1;
+ max = state.posMax;
+ // ' \n' -> hardbreak
+ // Lookup in pending chars is bad practice! Don't copy to other rules!
+ // Pending string is stored in concat mode, indexed lookups will cause
+ // convertion to flat mode.
+ if (!silent) {
+ if (pmax >= 0 && state.pending.charCodeAt(pmax) === 32) {
+ if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 32) {
+ // Find whitespaces tail of pending chars.
+ ws = pmax - 1;
+ while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 32) ws--;
+ state.pending = state.pending.slice(0, ws);
+ state.push("hardbreak", "br", 0);
+ } else {
+ state.pending = state.pending.slice(0, -1);
+ state.push("softbreak", "br", 0);
+ }
+ } else {
+ state.push("softbreak", "br", 0);
+ }
+ }
+ pos++;
+ // skip heading spaces for next line
+ while (pos < max && isSpace$3(state.src.charCodeAt(pos))) {
+ pos++;
+ }
+ state.pos = pos;
+ return true;
+ };
+ var isSpace$2 = utils.isSpace;
+ var ESCAPED = [];
+ for (var i = 0; i < 256; i++) {
+ ESCAPED.push(0);
+ }
+ "\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(ch) {
+ ESCAPED[ch.charCodeAt(0)] = 1;
+ }));
+ var _escape = function escape(state, silent) {
+ var ch1, ch2, origStr, escapedStr, token, pos = state.pos, max = state.posMax;
+ if (state.src.charCodeAt(pos) !== 92 /* \ */) return false;
+ pos++;
+ // '\' at the end of the inline block
+ if (pos >= max) return false;
+ ch1 = state.src.charCodeAt(pos);
+ if (ch1 === 10) {
+ if (!silent) {
+ state.push("hardbreak", "br", 0);
+ }
+ pos++;
+ // skip leading whitespaces from next line
+ while (pos < max) {
+ ch1 = state.src.charCodeAt(pos);
+ if (!isSpace$2(ch1)) break;
+ pos++;
+ }
+ state.pos = pos;
+ return true;
+ }
+ escapedStr = state.src[pos];
+ if (ch1 >= 55296 && ch1 <= 56319 && pos + 1 < max) {
+ ch2 = state.src.charCodeAt(pos + 1);
+ if (ch2 >= 56320 && ch2 <= 57343) {
+ escapedStr += state.src[pos + 1];
+ pos++;
+ }
+ }
+ origStr = "\\" + escapedStr;
+ if (!silent) {
+ token = state.push("text_special", "", 0);
+ if (ch1 < 256 && ESCAPED[ch1] !== 0) {
+ token.content = escapedStr;
+ } else {
+ token.content = origStr;
+ }
+ token.markup = origStr;
+ token.info = "escape";
+ }
+ state.pos = pos + 1;
+ return true;
+ };
+ // Parse backticks
+ var backticks = function backtick(state, silent) {
+ var start, max, marker, token, matchStart, matchEnd, openerLength, closerLength, pos = state.pos, ch = state.src.charCodeAt(pos);
+ if (ch !== 96 /* ` */) {
+ return false;
+ }
+ start = pos;
+ pos++;
+ max = state.posMax;
+ // scan marker length
+ while (pos < max && state.src.charCodeAt(pos) === 96 /* ` */) {
+ pos++;
+ }
+ marker = state.src.slice(start, pos);
+ openerLength = marker.length;
+ if (state.backticksScanned && (state.backticks[openerLength] || 0) <= start) {
+ if (!silent) state.pending += marker;
+ state.pos += openerLength;
+ return true;
+ }
+ matchStart = matchEnd = pos;
+ // Nothing found in the cache, scan until the end of the line (or until marker is found)
+ while ((matchStart = state.src.indexOf("`", matchEnd)) !== -1) {
+ matchEnd = matchStart + 1;
+ // scan marker length
+ while (matchEnd < max && state.src.charCodeAt(matchEnd) === 96 /* ` */) {
+ matchEnd++;
+ }
+ closerLength = matchEnd - matchStart;
+ if (closerLength === openerLength) {
+ // Found matching closer length.
+ if (!silent) {
+ token = state.push("code_inline", "code", 0);
+ token.markup = marker;
+ token.content = state.src.slice(pos, matchStart).replace(/\n/g, " ").replace(/^ (.+) $/, "$1");
+ }
+ state.pos = matchEnd;
+ return true;
+ }
+ // Some different length found, put it in cache as upper limit of where closer can be found
+ state.backticks[closerLength] = matchStart;
+ }
+ // Scanned through the end, didn't find anything
+ state.backticksScanned = true;
+ if (!silent) state.pending += marker;
+ state.pos += openerLength;
+ return true;
+ };
+ // ~~strike through~~
+ // Insert each marker as a separate text token, and add it to delimiter list
+
+ var tokenize$1 = function strikethrough(state, silent) {
+ var i, scanned, token, len, ch, start = state.pos, marker = state.src.charCodeAt(start);
+ if (silent) {
+ return false;
+ }
+ if (marker !== 126 /* ~ */) {
+ return false;
+ }
+ scanned = state.scanDelims(state.pos, true);
+ len = scanned.length;
+ ch = String.fromCharCode(marker);
+ if (len < 2) {
+ return false;
+ }
+ if (len % 2) {
+ token = state.push("text", "", 0);
+ token.content = ch;
+ len--;
+ }
+ for (i = 0; i < len; i += 2) {
+ token = state.push("text", "", 0);
+ token.content = ch + ch;
+ state.delimiters.push({
+ marker: marker,
+ length: 0,
+ // disable "rule of 3" length checks meant for emphasis
+ token: state.tokens.length - 1,
+ end: -1,
+ open: scanned.can_open,
+ close: scanned.can_close
+ });
+ }
+ state.pos += scanned.length;
+ return true;
+ };
+ function postProcess$1(state, delimiters) {
+ var i, j, startDelim, endDelim, token, loneMarkers = [], max = delimiters.length;
+ for (i = 0; i < max; i++) {
+ startDelim = delimiters[i];
+ if (startDelim.marker !== 126 /* ~ */) {
+ continue;
+ }
+ if (startDelim.end === -1) {
+ continue;
+ }
+ endDelim = delimiters[startDelim.end];
+ token = state.tokens[startDelim.token];
+ token.type = "s_open";
+ token.tag = "s";
+ token.nesting = 1;
+ token.markup = "~~";
+ token.content = "";
+ token = state.tokens[endDelim.token];
+ token.type = "s_close";
+ token.tag = "s";
+ token.nesting = -1;
+ token.markup = "~~";
+ token.content = "";
+ if (state.tokens[endDelim.token - 1].type === "text" && state.tokens[endDelim.token - 1].content === "~") {
+ loneMarkers.push(endDelim.token - 1);
+ }
+ }
+ // If a marker sequence has an odd number of characters, it's splitted
+ // like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the
+ // start of the sequence.
+
+ // So, we have to move all those markers after subsequent s_close tags.
+
+ while (loneMarkers.length) {
+ i = loneMarkers.pop();
+ j = i + 1;
+ while (j < state.tokens.length && state.tokens[j].type === "s_close") {
+ j++;
+ }
+ j--;
+ if (i !== j) {
+ token = state.tokens[j];
+ state.tokens[j] = state.tokens[i];
+ state.tokens[i] = token;
+ }
+ }
+ }
+ // Walk through delimiter list and replace text tokens with tags
+
+ var postProcess_1$1 = function strikethrough(state) {
+ var curr, tokens_meta = state.tokens_meta, max = state.tokens_meta.length;
+ postProcess$1(state, state.delimiters);
+ for (curr = 0; curr < max; curr++) {
+ if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
+ postProcess$1(state, tokens_meta[curr].delimiters);
+ }
+ }
+ };
+ var strikethrough = {
+ tokenize: tokenize$1,
+ postProcess: postProcess_1$1
+ };
+ // Process *this* and _that_
+ // Insert each marker as a separate text token, and add it to delimiter list
+
+ var tokenize = function emphasis(state, silent) {
+ var i, scanned, token, start = state.pos, marker = state.src.charCodeAt(start);
+ if (silent) {
+ return false;
+ }
+ if (marker !== 95 /* _ */ && marker !== 42 /* * */) {
+ return false;
+ }
+ scanned = state.scanDelims(state.pos, marker === 42);
+ for (i = 0; i < scanned.length; i++) {
+ token = state.push("text", "", 0);
+ token.content = String.fromCharCode(marker);
+ state.delimiters.push({
+ // Char code of the starting marker (number).
+ marker: marker,
+ // Total length of these series of delimiters.
+ length: scanned.length,
+ // A position of the token this delimiter corresponds to.
+ token: state.tokens.length - 1,
+ // If this delimiter is matched as a valid opener, `end` will be
+ // equal to its position, otherwise it's `-1`.
+ end: -1,
+ // Boolean flags that determine if this delimiter could open or close
+ // an emphasis.
+ open: scanned.can_open,
+ close: scanned.can_close
+ });
+ }
+ state.pos += scanned.length;
+ return true;
+ };
+ function postProcess(state, delimiters) {
+ var i, startDelim, endDelim, token, ch, isStrong, max = delimiters.length;
+ for (i = max - 1; i >= 0; i--) {
+ startDelim = delimiters[i];
+ if (startDelim.marker !== 95 /* _ */ && startDelim.marker !== 42 /* * */) {
+ continue;
+ }
+ // Process only opening markers
+ if (startDelim.end === -1) {
+ continue;
+ }
+ endDelim = delimiters[startDelim.end];
+ // If the previous delimiter has the same marker and is adjacent to this one,
+ // merge those into one strong delimiter.
+
+ // `whatever` -> `whatever`
+
+ isStrong = i > 0 && delimiters[i - 1].end === startDelim.end + 1 &&
+ // check that first two markers match and adjacent
+ delimiters[i - 1].marker === startDelim.marker && delimiters[i - 1].token === startDelim.token - 1 &&
+ // check that last two markers are adjacent (we can safely assume they match)
+ delimiters[startDelim.end + 1].token === endDelim.token + 1;
+ ch = String.fromCharCode(startDelim.marker);
+ token = state.tokens[startDelim.token];
+ token.type = isStrong ? "strong_open" : "em_open";
+ token.tag = isStrong ? "strong" : "em";
+ token.nesting = 1;
+ token.markup = isStrong ? ch + ch : ch;
+ token.content = "";
+ token = state.tokens[endDelim.token];
+ token.type = isStrong ? "strong_close" : "em_close";
+ token.tag = isStrong ? "strong" : "em";
+ token.nesting = -1;
+ token.markup = isStrong ? ch + ch : ch;
+ token.content = "";
+ if (isStrong) {
+ state.tokens[delimiters[i - 1].token].content = "";
+ state.tokens[delimiters[startDelim.end + 1].token].content = "";
+ i--;
+ }
+ }
+ }
+ // Walk through delimiter list and replace text tokens with tags
+
+ var postProcess_1 = function emphasis(state) {
+ var curr, tokens_meta = state.tokens_meta, max = state.tokens_meta.length;
+ postProcess(state, state.delimiters);
+ for (curr = 0; curr < max; curr++) {
+ if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
+ postProcess(state, tokens_meta[curr].delimiters);
+ }
+ }
+ };
+ var emphasis = {
+ tokenize: tokenize,
+ postProcess: postProcess_1
+ };
+ var normalizeReference$1 = utils.normalizeReference;
+ var isSpace$1 = utils.isSpace;
+ var link = function link(state, silent) {
+ var attrs, code, label, labelEnd, labelStart, pos, res, ref, token, href = "", title = "", oldPos = state.pos, max = state.posMax, start = state.pos, parseReference = true;
+ if (state.src.charCodeAt(state.pos) !== 91 /* [ */) {
+ return false;
+ }
+ labelStart = state.pos + 1;
+ labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true);
+ // parser failed to find ']', so it's not a valid link
+ if (labelEnd < 0) {
+ return false;
+ }
+ pos = labelEnd + 1;
+ if (pos < max && state.src.charCodeAt(pos) === 40 /* ( */) {
+ // Inline link
+ // might have found a valid shortcut link, disable reference parsing
+ parseReference = false;
+ // [link]( "title" )
+ // ^^ skipping these spaces
+ pos++;
+ for (;pos < max; pos++) {
+ code = state.src.charCodeAt(pos);
+ if (!isSpace$1(code) && code !== 10) {
+ break;
+ }
+ }
+ if (pos >= max) {
+ return false;
+ }
+ // [link]( "title" )
+ // ^^^^^^ parsing link destination
+ start = pos;
+ res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
+ if (res.ok) {
+ href = state.md.normalizeLink(res.str);
+ if (state.md.validateLink(href)) {
+ pos = res.pos;
+ } else {
+ href = "";
+ }
+ // [link]( "title" )
+ // ^^ skipping these spaces
+ start = pos;
+ for (;pos < max; pos++) {
+ code = state.src.charCodeAt(pos);
+ if (!isSpace$1(code) && code !== 10) {
+ break;
+ }
+ }
+ // [link]( "title" )
+ // ^^^^^^^ parsing link title
+ res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
+ if (pos < max && start !== pos && res.ok) {
+ title = res.str;
+ pos = res.pos;
+ // [link]( "title" )
+ // ^^ skipping these spaces
+ for (;pos < max; pos++) {
+ code = state.src.charCodeAt(pos);
+ if (!isSpace$1(code) && code !== 10) {
+ break;
+ }
+ }
+ }
+ }
+ if (pos >= max || state.src.charCodeAt(pos) !== 41 /* ) */) {
+ // parsing a valid shortcut link failed, fallback to reference
+ parseReference = true;
+ }
+ pos++;
+ }
+ if (parseReference) {
+ // Link reference
+ if (typeof state.env.references === "undefined") {
+ return false;
+ }
+ if (pos < max && state.src.charCodeAt(pos) === 91 /* [ */) {
+ start = pos + 1;
+ pos = state.md.helpers.parseLinkLabel(state, pos);
+ if (pos >= 0) {
+ label = state.src.slice(start, pos++);
+ } else {
+ pos = labelEnd + 1;
+ }
+ } else {
+ pos = labelEnd + 1;
+ }
+ // covers label === '' and label === undefined
+ // (collapsed reference link and shortcut reference link respectively)
+ if (!label) {
+ label = state.src.slice(labelStart, labelEnd);
+ }
+ ref = state.env.references[normalizeReference$1(label)];
+ if (!ref) {
+ state.pos = oldPos;
+ return false;
+ }
+ href = ref.href;
+ title = ref.title;
+ }
+
+ // We found the end of the link, and know for a fact it's a valid link;
+ // so all that's left to do is to call tokenizer.
+
+ if (!silent) {
+ state.pos = labelStart;
+ state.posMax = labelEnd;
+ token = state.push("link_open", "a", 1);
+ token.attrs = attrs = [ [ "href", href ] ];
+ if (title) {
+ attrs.push([ "title", title ]);
+ }
+ state.linkLevel++;
+ state.md.inline.tokenize(state);
+ state.linkLevel--;
+ token = state.push("link_close", "a", -1);
+ }
+ state.pos = pos;
+ state.posMax = max;
+ return true;
+ };
+ var normalizeReference = utils.normalizeReference;
+ var isSpace = utils.isSpace;
+ var image = function image(state, silent) {
+ var attrs, code, content, label, labelEnd, labelStart, pos, ref, res, title, token, tokens, start, href = "", oldPos = state.pos, max = state.posMax;
+ if (state.src.charCodeAt(state.pos) !== 33 /* ! */) {
+ return false;
+ }
+ if (state.src.charCodeAt(state.pos + 1) !== 91 /* [ */) {
+ return false;
+ }
+ labelStart = state.pos + 2;
+ labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false);
+ // parser failed to find ']', so it's not a valid link
+ if (labelEnd < 0) {
+ return false;
+ }
+ pos = labelEnd + 1;
+ if (pos < max && state.src.charCodeAt(pos) === 40 /* ( */) {
+ // Inline link
+ // [link]( "title" )
+ // ^^ skipping these spaces
+ pos++;
+ for (;pos < max; pos++) {
+ code = state.src.charCodeAt(pos);
+ if (!isSpace(code) && code !== 10) {
+ break;
+ }
+ }
+ if (pos >= max) {
+ return false;
+ }
+ // [link]( "title" )
+ // ^^^^^^ parsing link destination
+ start = pos;
+ res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
+ if (res.ok) {
+ href = state.md.normalizeLink(res.str);
+ if (state.md.validateLink(href)) {
+ pos = res.pos;
+ } else {
+ href = "";
+ }
+ }
+ // [link]( "title" )
+ // ^^ skipping these spaces
+ start = pos;
+ for (;pos < max; pos++) {
+ code = state.src.charCodeAt(pos);
+ if (!isSpace(code) && code !== 10) {
+ break;
+ }
+ }
+ // [link]( "title" )
+ // ^^^^^^^ parsing link title
+ res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
+ if (pos < max && start !== pos && res.ok) {
+ title = res.str;
+ pos = res.pos;
+ // [link]( "title" )
+ // ^^ skipping these spaces
+ for (;pos < max; pos++) {
+ code = state.src.charCodeAt(pos);
+ if (!isSpace(code) && code !== 10) {
+ break;
+ }
+ }
+ } else {
+ title = "";
+ }
+ if (pos >= max || state.src.charCodeAt(pos) !== 41 /* ) */) {
+ state.pos = oldPos;
+ return false;
+ }
+ pos++;
+ } else {
+ // Link reference
+ if (typeof state.env.references === "undefined") {
+ return false;
+ }
+ if (pos < max && state.src.charCodeAt(pos) === 91 /* [ */) {
+ start = pos + 1;
+ pos = state.md.helpers.parseLinkLabel(state, pos);
+ if (pos >= 0) {
+ label = state.src.slice(start, pos++);
+ } else {
+ pos = labelEnd + 1;
+ }
+ } else {
+ pos = labelEnd + 1;
+ }
+ // covers label === '' and label === undefined
+ // (collapsed reference link and shortcut reference link respectively)
+ if (!label) {
+ label = state.src.slice(labelStart, labelEnd);
+ }
+ ref = state.env.references[normalizeReference(label)];
+ if (!ref) {
+ state.pos = oldPos;
+ return false;
+ }
+ href = ref.href;
+ title = ref.title;
+ }
+
+ // We found the end of the link, and know for a fact it's a valid link;
+ // so all that's left to do is to call tokenizer.
+
+ if (!silent) {
+ content = state.src.slice(labelStart, labelEnd);
+ state.md.inline.parse(content, state.md, state.env, tokens = []);
+ token = state.push("image", "img", 0);
+ token.attrs = attrs = [ [ "src", href ], [ "alt", "" ] ];
+ token.children = tokens;
+ token.content = content;
+ if (title) {
+ attrs.push([ "title", title ]);
+ }
+ }
+ state.pos = pos;
+ state.posMax = max;
+ return true;
+ };
+ // Process autolinks ''
+ /*eslint max-len:0*/ var EMAIL_RE = /^([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])?)*)$/;
+ var AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;
+ var autolink = function autolink(state, silent) {
+ var url, fullUrl, token, ch, start, max, pos = state.pos;
+ if (state.src.charCodeAt(pos) !== 60 /* < */) {
+ return false;
+ }
+ start = state.pos;
+ max = state.posMax;
+ for (;;) {
+ if (++pos >= max) return false;
+ ch = state.src.charCodeAt(pos);
+ if (ch === 60 /* < */) return false;
+ if (ch === 62 /* > */) break;
+ }
+ url = state.src.slice(start + 1, pos);
+ if (AUTOLINK_RE.test(url)) {
+ fullUrl = state.md.normalizeLink(url);
+ if (!state.md.validateLink(fullUrl)) {
+ return false;
+ }
+ if (!silent) {
+ token = state.push("link_open", "a", 1);
+ token.attrs = [ [ "href", fullUrl ] ];
+ token.markup = "autolink";
+ token.info = "auto";
+ token = state.push("text", "", 0);
+ token.content = state.md.normalizeLinkText(url);
+ token = state.push("link_close", "a", -1);
+ token.markup = "autolink";
+ token.info = "auto";
+ }
+ state.pos += url.length + 2;
+ return true;
+ }
+ if (EMAIL_RE.test(url)) {
+ fullUrl = state.md.normalizeLink("mailto:" + url);
+ if (!state.md.validateLink(fullUrl)) {
+ return false;
+ }
+ if (!silent) {
+ token = state.push("link_open", "a", 1);
+ token.attrs = [ [ "href", fullUrl ] ];
+ token.markup = "autolink";
+ token.info = "auto";
+ token = state.push("text", "", 0);
+ token.content = state.md.normalizeLinkText(url);
+ token = state.push("link_close", "a", -1);
+ token.markup = "autolink";
+ token.info = "auto";
+ }
+ state.pos += url.length + 2;
+ return true;
+ }
+ return false;
+ };
+ var HTML_TAG_RE = html_re.HTML_TAG_RE;
+ function isLinkOpen(str) {
+ return /^\s]/i.test(str);
+ }
+ function isLinkClose(str) {
+ return /^<\/a\s*>/i.test(str);
+ }
+ function isLetter(ch) {
+ /*eslint no-bitwise:0*/
+ var lc = ch | 32;
+ // to lower case
+ return lc >= 97 /* a */ && lc <= 122 /* z */;
+ }
+ var html_inline = function html_inline(state, silent) {
+ var ch, match, max, token, pos = state.pos;
+ if (!state.md.options.html) {
+ return false;
+ }
+ // Check start
+ max = state.posMax;
+ if (state.src.charCodeAt(pos) !== 60 /* < */ || pos + 2 >= max) {
+ return false;
+ }
+ // Quick fail on second char
+ ch = state.src.charCodeAt(pos + 1);
+ if (ch !== 33 /* ! */ && ch !== 63 /* ? */ && ch !== 47 /* / */ && !isLetter(ch)) {
+ return false;
+ }
+ match = state.src.slice(pos).match(HTML_TAG_RE);
+ if (!match) {
+ return false;
+ }
+ if (!silent) {
+ token = state.push("html_inline", "", 0);
+ token.content = state.src.slice(pos, pos + match[0].length);
+ if (isLinkOpen(token.content)) state.linkLevel++;
+ if (isLinkClose(token.content)) state.linkLevel--;
+ }
+ state.pos += match[0].length;
+ return true;
+ };
+ var has = utils.has;
+ var isValidEntityCode = utils.isValidEntityCode;
+ var fromCodePoint = utils.fromCodePoint;
+ var DIGITAL_RE = /^((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;
+ var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
+ var entity = function entity(state, silent) {
+ var ch, code, match, token, pos = state.pos, max = state.posMax;
+ if (state.src.charCodeAt(pos) !== 38 /* & */) return false;
+ if (pos + 1 >= max) return false;
+ ch = state.src.charCodeAt(pos + 1);
+ if (ch === 35 /* # */) {
+ match = state.src.slice(pos).match(DIGITAL_RE);
+ if (match) {
+ if (!silent) {
+ code = match[1][0].toLowerCase() === "x" ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);
+ token = state.push("text_special", "", 0);
+ token.content = isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(65533);
+ token.markup = match[0];
+ token.info = "entity";
+ }
+ state.pos += match[0].length;
+ return true;
+ }
+ } else {
+ match = state.src.slice(pos).match(NAMED_RE);
+ if (match) {
+ if (has(entities, match[1])) {
+ if (!silent) {
+ token = state.push("text_special", "", 0);
+ token.content = entities[match[1]];
+ token.markup = match[0];
+ token.info = "entity";
+ }
+ state.pos += match[0].length;
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+ // For each opening emphasis-like marker find a matching closing one
+ function processDelimiters(state, delimiters) {
+ var closerIdx, openerIdx, closer, opener, minOpenerIdx, newMinOpenerIdx, isOddMatch, lastJump, openersBottom = {}, max = delimiters.length;
+ if (!max) return;
+ // headerIdx is the first delimiter of the current (where closer is) delimiter run
+ var headerIdx = 0;
+ var lastTokenIdx = -2;
+ // needs any value lower than -1
+ var jumps = [];
+ for (closerIdx = 0; closerIdx < max; closerIdx++) {
+ closer = delimiters[closerIdx];
+ jumps.push(0);
+ // markers belong to same delimiter run if:
+ // - they have adjacent tokens
+ // - AND markers are the same
+
+ if (delimiters[headerIdx].marker !== closer.marker || lastTokenIdx !== closer.token - 1) {
+ headerIdx = closerIdx;
+ }
+ lastTokenIdx = closer.token;
+ // Length is only used for emphasis-specific "rule of 3",
+ // if it's not defined (in strikethrough or 3rd party plugins),
+ // we can default it to 0 to disable those checks.
+
+ closer.length = closer.length || 0;
+ if (!closer.close) continue;
+ // Previously calculated lower bounds (previous fails)
+ // for each marker, each delimiter length modulo 3,
+ // and for whether this closer can be an opener;
+ // https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460
+ if (!openersBottom.hasOwnProperty(closer.marker)) {
+ openersBottom[closer.marker] = [ -1, -1, -1, -1, -1, -1 ];
+ }
+ minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + closer.length % 3];
+ openerIdx = headerIdx - jumps[headerIdx] - 1;
+ newMinOpenerIdx = openerIdx;
+ for (;openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) {
+ opener = delimiters[openerIdx];
+ if (opener.marker !== closer.marker) continue;
+ if (opener.open && opener.end < 0) {
+ isOddMatch = false;
+ // from spec:
+
+ // If one of the delimiters can both open and close emphasis, then the
+ // sum of the lengths of the delimiter runs containing the opening and
+ // closing delimiters must not be a multiple of 3 unless both lengths
+ // are multiples of 3.
+
+ if (opener.close || closer.open) {
+ if ((opener.length + closer.length) % 3 === 0) {
+ if (opener.length % 3 !== 0 || closer.length % 3 !== 0) {
+ isOddMatch = true;
+ }
+ }
+ }
+ if (!isOddMatch) {
+ // If previous delimiter cannot be an opener, we can safely skip
+ // the entire sequence in future checks. This is required to make
+ // sure algorithm has linear complexity (see *_*_*_*_*_... case).
+ lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ? jumps[openerIdx - 1] + 1 : 0;
+ jumps[closerIdx] = closerIdx - openerIdx + lastJump;
+ jumps[openerIdx] = lastJump;
+ closer.open = false;
+ opener.end = closerIdx;
+ opener.close = false;
+ newMinOpenerIdx = -1;
+ // treat next token as start of run,
+ // it optimizes skips in **<...>**a**<...>** pathological case
+ lastTokenIdx = -2;
+ break;
+ }
+ }
+ }
+ if (newMinOpenerIdx !== -1) {
+ // If match for this delimiter run failed, we want to set lower bound for
+ // future lookups. This is required to make sure algorithm has linear
+ // complexity.
+ // See details here:
+ // https://github.com/commonmark/cmark/issues/178#issuecomment-270417442
+ openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length || 0) % 3] = newMinOpenerIdx;
+ }
+ }
+ }
+ var balance_pairs = function link_pairs(state) {
+ var curr, tokens_meta = state.tokens_meta, max = state.tokens_meta.length;
+ processDelimiters(state, state.delimiters);
+ for (curr = 0; curr < max; curr++) {
+ if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
+ processDelimiters(state, tokens_meta[curr].delimiters);
+ }
+ }
+ };
+ // Clean up tokens after emphasis and strikethrough postprocessing:
+ var fragments_join = function fragments_join(state) {
+ var curr, last, level = 0, tokens = state.tokens, max = state.tokens.length;
+ for (curr = last = 0; curr < max; curr++) {
+ // re-calculate levels after emphasis/strikethrough turns some text nodes
+ // into opening/closing tags
+ if (tokens[curr].nesting < 0) level--;
+ // closing tag
+ tokens[curr].level = level;
+ if (tokens[curr].nesting > 0) level++;
+ // opening tag
+ if (tokens[curr].type === "text" && curr + 1 < max && tokens[curr + 1].type === "text") {
+ // collapse two adjacent text nodes
+ tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
+ } else {
+ if (curr !== last) {
+ tokens[last] = tokens[curr];
+ }
+ last++;
+ }
+ }
+ if (curr !== last) {
+ tokens.length = last;
+ }
+ };
+ var isWhiteSpace = utils.isWhiteSpace;
+ var isPunctChar = utils.isPunctChar;
+ var isMdAsciiPunct = utils.isMdAsciiPunct;
+ function StateInline(src, md, env, outTokens) {
+ this.src = src;
+ this.env = env;
+ this.md = md;
+ this.tokens = outTokens;
+ this.tokens_meta = Array(outTokens.length);
+ this.pos = 0;
+ this.posMax = this.src.length;
+ this.level = 0;
+ this.pending = "";
+ this.pendingLevel = 0;
+ // Stores { start: end } pairs. Useful for backtrack
+ // optimization of pairs parse (emphasis, strikes).
+ this.cache = {};
+ // List of emphasis-like delimiters for current tag
+ this.delimiters = [];
+ // Stack of delimiter lists for upper level tags
+ this._prev_delimiters = [];
+ // backtick length => last seen position
+ this.backticks = {};
+ this.backticksScanned = false;
+ // Counter used to disable inline linkify-it execution
+ // inside and markdown links
+ this.linkLevel = 0;
+ }
+ // Flush pending text
+
+ StateInline.prototype.pushPending = function() {
+ var token$1 = new token("text", "", 0);
+ token$1.content = this.pending;
+ token$1.level = this.pendingLevel;
+ this.tokens.push(token$1);
+ this.pending = "";
+ return token$1;
+ };
+ // Push new token to "stream".
+ // If pending text exists - flush it as text token
+
+ StateInline.prototype.push = function(type, tag, nesting) {
+ if (this.pending) {
+ this.pushPending();
+ }
+ var token$1 = new token(type, tag, nesting);
+ var token_meta = null;
+ if (nesting < 0) {
+ // closing tag
+ this.level--;
+ this.delimiters = this._prev_delimiters.pop();
+ }
+ token$1.level = this.level;
+ if (nesting > 0) {
+ // opening tag
+ this.level++;
+ this._prev_delimiters.push(this.delimiters);
+ this.delimiters = [];
+ token_meta = {
+ delimiters: this.delimiters
+ };
+ }
+ this.pendingLevel = this.level;
+ this.tokens.push(token$1);
+ this.tokens_meta.push(token_meta);
+ return token$1;
+ };
+ // Scan a sequence of emphasis-like markers, and determine whether
+ // it can start an emphasis sequence or end an emphasis sequence.
+
+ // - start - position to scan from (it should point at a valid marker);
+ // - canSplitWord - determine if these markers can be found inside a word
+
+ StateInline.prototype.scanDelims = function(start, canSplitWord) {
+ var pos = start, lastChar, nextChar, count, can_open, can_close, isLastWhiteSpace, isLastPunctChar, isNextWhiteSpace, isNextPunctChar, left_flanking = true, right_flanking = true, max = this.posMax, marker = this.src.charCodeAt(start);
+ // treat beginning of the line as a whitespace
+ lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 32;
+ while (pos < max && this.src.charCodeAt(pos) === marker) {
+ pos++;
+ }
+ count = pos - start;
+ // treat end of the line as a whitespace
+ nextChar = pos < max ? this.src.charCodeAt(pos) : 32;
+ isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
+ isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
+ isLastWhiteSpace = isWhiteSpace(lastChar);
+ isNextWhiteSpace = isWhiteSpace(nextChar);
+ if (isNextWhiteSpace) {
+ left_flanking = false;
+ } else if (isNextPunctChar) {
+ if (!(isLastWhiteSpace || isLastPunctChar)) {
+ left_flanking = false;
+ }
+ }
+ if (isLastWhiteSpace) {
+ right_flanking = false;
+ } else if (isLastPunctChar) {
+ if (!(isNextWhiteSpace || isNextPunctChar)) {
+ right_flanking = false;
+ }
+ }
+ if (!canSplitWord) {
+ can_open = left_flanking && (!right_flanking || isLastPunctChar);
+ can_close = right_flanking && (!left_flanking || isNextPunctChar);
+ } else {
+ can_open = left_flanking;
+ can_close = right_flanking;
+ }
+ return {
+ can_open: can_open,
+ can_close: can_close,
+ length: count
+ };
+ };
+ // re-export Token class to use in block rules
+ StateInline.prototype.Token = token;
+ var state_inline = StateInline;
+ ////////////////////////////////////////////////////////////////////////////////
+ // Parser rules
+ var _rules = [ [ "text", text ], [ "linkify", linkify ], [ "newline", newline ], [ "escape", _escape ], [ "backticks", backticks ], [ "strikethrough", strikethrough.tokenize ], [ "emphasis", emphasis.tokenize ], [ "link", link ], [ "image", image ], [ "autolink", autolink ], [ "html_inline", html_inline ], [ "entity", entity ] ];
+ // `rule2` ruleset was created specifically for emphasis/strikethrough
+ // post-processing and may be changed in the future.
+
+ // Don't use this for anything except pairs (plugins working with `balance_pairs`).
+
+ var _rules2 = [ [ "balance_pairs", balance_pairs ], [ "strikethrough", strikethrough.postProcess ], [ "emphasis", emphasis.postProcess ],
+ // rules for pairs separate '**' into its own text tokens, which may be left unused,
+ // rule below merges unused segments back with the rest of the text
+ [ "fragments_join", fragments_join ] ];
+ /**
+ * new ParserInline()
+ **/ function ParserInline() {
+ var i;
+ /**
+ * ParserInline#ruler -> Ruler
+ *
+ * [[Ruler]] instance. Keep configuration of inline rules.
+ **/ this.ruler = new ruler;
+ for (i = 0; i < _rules.length; i++) {
+ this.ruler.push(_rules[i][0], _rules[i][1]);
+ }
+ /**
+ * ParserInline#ruler2 -> Ruler
+ *
+ * [[Ruler]] instance. Second ruler used for post-processing
+ * (e.g. in emphasis-like rules).
+ **/ this.ruler2 = new ruler;
+ for (i = 0; i < _rules2.length; i++) {
+ this.ruler2.push(_rules2[i][0], _rules2[i][1]);
+ }
+ }
+ // Skip single token by running all rules in validation mode;
+ // returns `true` if any rule reported success
+
+ ParserInline.prototype.skipToken = function(state) {
+ var ok, i, pos = state.pos, rules = this.ruler.getRules(""), len = rules.length, maxNesting = state.md.options.maxNesting, cache = state.cache;
+ if (typeof cache[pos] !== "undefined") {
+ state.pos = cache[pos];
+ return;
+ }
+ if (state.level < maxNesting) {
+ for (i = 0; i < len; i++) {
+ // Increment state.level and decrement it later to limit recursion.
+ // It's harmless to do here, because no tokens are created. But ideally,
+ // we'd need a separate private state variable for this purpose.
+ state.level++;
+ ok = rules[i](state, true);
+ state.level--;
+ if (ok) {
+ break;
+ }
+ }
+ } else {
+ // Too much nesting, just skip until the end of the paragraph.
+ // NOTE: this will cause links to behave incorrectly in the following case,
+ // when an amount of `[` is exactly equal to `maxNesting + 1`:
+ // [[[[[[[[[[[[[[[[[[[[[foo]()
+ // TODO: remove this workaround when CM standard will allow nested links
+ // (we can replace it by preventing links from being parsed in
+ // validation mode)
+ state.pos = state.posMax;
+ }
+ if (!ok) {
+ state.pos++;
+ }
+ cache[pos] = state.pos;
+ };
+ // Generate tokens for input range
+
+ ParserInline.prototype.tokenize = function(state) {
+ var ok, i, rules = this.ruler.getRules(""), len = rules.length, end = state.posMax, maxNesting = state.md.options.maxNesting;
+ while (state.pos < end) {
+ // Try all possible rules.
+ // On success, rule should:
+ // - update `state.pos`
+ // - update `state.tokens`
+ // - return true
+ if (state.level < maxNesting) {
+ for (i = 0; i < len; i++) {
+ ok = rules[i](state, false);
+ if (ok) {
+ break;
+ }
+ }
+ }
+ if (ok) {
+ if (state.pos >= end) {
+ break;
+ }
+ continue;
+ }
+ state.pending += state.src[state.pos++];
+ }
+ if (state.pending) {
+ state.pushPending();
+ }
+ };
+ /**
+ * ParserInline.parse(str, md, env, outTokens)
+ *
+ * Process input string and push inline tokens into `outTokens`
+ **/ ParserInline.prototype.parse = function(str, md, env, outTokens) {
+ var i, rules, len;
+ var state = new this.State(str, md, env, outTokens);
+ this.tokenize(state);
+ rules = this.ruler2.getRules("");
+ len = rules.length;
+ for (i = 0; i < len; i++) {
+ rules[i](state);
+ }
+ };
+ ParserInline.prototype.State = state_inline;
+ var parser_inline = ParserInline;
+ var re = function(opts) {
+ var re = {};
+ opts = opts || {};
+ // Use direct extract instead of `regenerate` to reduse browserified size
+ re.src_Any = regex$3.source;
+ re.src_Cc = regex$2.source;
+ re.src_Z = regex.source;
+ re.src_P = regex$4.source;
+ // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
+ re.src_ZPCc = [ re.src_Z, re.src_P, re.src_Cc ].join("|");
+ // \p{\Z\Cc} (white spaces + control)
+ re.src_ZCc = [ re.src_Z, re.src_Cc ].join("|");
+ // Experimental. List of chars, completely prohibited in links
+ // because can separate it from other part of text
+ var text_separators = "[><\uff5c]";
+ // All possible word characters (everything without punctuation, spaces & controls)
+ // Defined via punctuation & spaces to save space
+ // Should be something like \p{\L\N\S\M} (\w but without `_`)
+ re.src_pseudo_letter = "(?:(?!" + text_separators + "|" + re.src_ZPCc + ")" + re.src_Any + ")";
+ // The same as abothe but without [0-9]
+ // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
+ ////////////////////////////////////////////////////////////////////////////////
+ re.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]?)";
+ // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
+ re.src_auth = "(?:(?:(?!" + re.src_ZCc + "|[@/\\[\\]()]).)+@)?";
+ re.src_port = "(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?";
+ re.src_host_terminator = "(?=$|" + text_separators + "|" + re.src_ZPCc + ")" + "(?!" + (opts["---"] ? "-(?!--)|" : "-|") + "_|:\\d|\\.-|\\.(?!$|" + re.src_ZPCc + "))";
+ re.src_path = "(?:" + "[/?#]" + "(?:" + "(?!" + re.src_ZCc + "|" + text_separators + "|[()[\\]{}.,\"'?!\\-;]).|" + "\\[(?:(?!" + re.src_ZCc + "|\\]).)*\\]|" + "\\((?:(?!" + re.src_ZCc + "|[)]).)*\\)|" + "\\{(?:(?!" + re.src_ZCc + "|[}]).)*\\}|" + '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' + "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" + "\\'(?=" + re.src_pseudo_letter + "|[-])|" + // allow `I'm_king` if no pair found
+ "\\.{2,}[a-zA-Z0-9%/&]|" + // google has many dots in "google search" links (#66, #81).
+ // github has ... in commit range links,
+ // Restrict to
+ // - english
+ // - percent-encoded
+ // - parts of file path
+ // - params separator
+ // until more examples found.
+ "\\.(?!" + re.src_ZCc + "|[.]|$)|" + (opts["---"] ? "\\-(?!--(?:[^-]|$))(?:-*)|" : "\\-+|") + ",(?!" + re.src_ZCc + "|$)|" + // allow `,,,` in paths
+ ";(?!" + re.src_ZCc + "|$)|" + // allow `;` if not followed by space-like char
+ "\\!+(?!" + re.src_ZCc + "|[!]|$)|" + // allow `!!!` in paths, but not at the end
+ "\\?(?!" + re.src_ZCc + "|[?]|$)" + ")+" + "|\\/" + ")?";
+ // Allow anything in markdown spec, forbid quote (") at the first position
+ // because emails enclosed in quotes are far more common
+ re.src_email_name = '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';
+ re.src_xn = "xn--[a-z0-9\\-]{1,59}";
+ // More to read about domain names
+ // http://serverfault.com/questions/638260/
+ re.src_domain_root =
+ // Allow letters & digits (http://test1)
+ "(?:" + re.src_xn + "|" + re.src_pseudo_letter + "{1,63}" + ")";
+ re.src_domain = "(?:" + re.src_xn + "|" + "(?:" + re.src_pseudo_letter + ")" + "|" + "(?:" + re.src_pseudo_letter + "(?:-|" + re.src_pseudo_letter + "){0,61}" + re.src_pseudo_letter + ")" + ")";
+ re.src_host = "(?:" +
+ // Don't need IP check, because digits are already allowed in normal domain names
+ // src_ip4 +
+ // '|' +
+ "(?:(?:(?:" + re.src_domain + ")\\.)*" + re.src_domain /*_root*/ + ")" + ")";
+ re.tpl_host_fuzzy = "(?:" + re.src_ip4 + "|" + "(?:(?:(?:" + re.src_domain + ")\\.)+(?:%TLDS%))" + ")";
+ re.tpl_host_no_ip_fuzzy = "(?:(?:(?:" + re.src_domain + ")\\.)+(?:%TLDS%))";
+ re.src_host_strict = re.src_host + re.src_host_terminator;
+ re.tpl_host_fuzzy_strict = re.tpl_host_fuzzy + re.src_host_terminator;
+ re.src_host_port_strict = re.src_host + re.src_port + re.src_host_terminator;
+ re.tpl_host_port_fuzzy_strict = re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
+ re.tpl_host_port_no_ip_fuzzy_strict = re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
+ ////////////////////////////////////////////////////////////////////////////////
+ // Main rules
+ // Rude test fuzzy links by host, for quick deny
+ re.tpl_host_fuzzy_test = "localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:" + re.src_ZPCc + "|>|$))";
+ re.tpl_email_fuzzy = "(^|" + text_separators + '|"|\\(|' + re.src_ZCc + ")" + "(" + re.src_email_name + "@" + re.tpl_host_fuzzy_strict + ")";
+ re.tpl_link_fuzzy =
+ // Fuzzy link can't be prepended with .:/\- and non punctuation.
+ // but can start with > (markdown blockquote)
+ "(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|" + re.src_ZPCc + "))" + "((?![$+<=>^`|\uff5c])" + re.tpl_host_port_fuzzy_strict + re.src_path + ")";
+ re.tpl_link_no_ip_fuzzy =
+ // Fuzzy link can't be prepended with .:/\- and non punctuation.
+ // but can start with > (markdown blockquote)
+ "(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|" + re.src_ZPCc + "))" + "((?![$+<=>^`|\uff5c])" + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ")";
+ return re;
+ };
+ ////////////////////////////////////////////////////////////////////////////////
+ // Helpers
+ // Merge objects
+
+ function assign(obj /*from1, from2, from3, ...*/) {
+ var sources = Array.prototype.slice.call(arguments, 1);
+ sources.forEach((function(source) {
+ if (!source) {
+ return;
+ }
+ Object.keys(source).forEach((function(key) {
+ obj[key] = source[key];
+ }));
+ }));
+ return obj;
+ }
+ function _class(obj) {
+ return Object.prototype.toString.call(obj);
+ }
+ function isString(obj) {
+ return _class(obj) === "[object String]";
+ }
+ function isObject(obj) {
+ return _class(obj) === "[object Object]";
+ }
+ function isRegExp(obj) {
+ return _class(obj) === "[object RegExp]";
+ }
+ function isFunction(obj) {
+ return _class(obj) === "[object Function]";
+ }
+ function escapeRE(str) {
+ return str.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
+ }
+ ////////////////////////////////////////////////////////////////////////////////
+ var defaultOptions = {
+ fuzzyLink: true,
+ fuzzyEmail: true,
+ fuzzyIP: false
+ };
+ function isOptionsObj(obj) {
+ return Object.keys(obj || {}).reduce((function(acc, k) {
+ return acc || defaultOptions.hasOwnProperty(k);
+ }), false);
+ }
+ var defaultSchemas = {
+ "http:": {
+ validate: function(text, pos, self) {
+ var tail = text.slice(pos);
+ if (!self.re.http) {
+ // compile lazily, because "host"-containing variables can change on tlds update.
+ self.re.http = new RegExp("^\\/\\/" + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, "i");
+ }
+ if (self.re.http.test(tail)) {
+ return tail.match(self.re.http)[0].length;
+ }
+ return 0;
+ }
+ },
+ "https:": "http:",
+ "ftp:": "http:",
+ "//": {
+ validate: function(text, pos, self) {
+ var tail = text.slice(pos);
+ if (!self.re.no_http) {
+ // compile lazily, because "host"-containing variables can change on tlds update.
+ self.re.no_http = new RegExp("^" + self.re.src_auth +
+ // Don't allow single-level domains, because of false positives like '//test'
+ // with code comments
+ "(?:localhost|(?:(?:" + self.re.src_domain + ")\\.)+" + self.re.src_domain_root + ")" + self.re.src_port + self.re.src_host_terminator + self.re.src_path, "i");
+ }
+ if (self.re.no_http.test(tail)) {
+ // should not be `://` & `///`, that protects from errors in protocol name
+ if (pos >= 3 && text[pos - 3] === ":") {
+ return 0;
+ }
+ if (pos >= 3 && text[pos - 3] === "/") {
+ return 0;
+ }
+ return tail.match(self.re.no_http)[0].length;
+ }
+ return 0;
+ }
+ },
+ "mailto:": {
+ validate: function(text, pos, self) {
+ var tail = text.slice(pos);
+ if (!self.re.mailto) {
+ self.re.mailto = new RegExp("^" + self.re.src_email_name + "@" + self.re.src_host_strict, "i");
+ }
+ if (self.re.mailto.test(tail)) {
+ return tail.match(self.re.mailto)[0].length;
+ }
+ return 0;
+ }
+ }
+ };
+ /*eslint-disable max-len*/
+ // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
+ var tlds_2ch_src_re = "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]";
+ // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
+ var tlds_default = "biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");
+ /*eslint-enable max-len*/
+ ////////////////////////////////////////////////////////////////////////////////
+ function resetScanCache(self) {
+ self.__index__ = -1;
+ self.__text_cache__ = "";
+ }
+ function createValidator(re) {
+ return function(text, pos) {
+ var tail = text.slice(pos);
+ if (re.test(tail)) {
+ return tail.match(re)[0].length;
+ }
+ return 0;
+ };
+ }
+ function createNormalizer() {
+ return function(match, self) {
+ self.normalize(match);
+ };
+ }
+ // Schemas compiler. Build regexps.
+
+ function compile(self) {
+ // Load & clone RE patterns.
+ var re$1 = self.re = re(self.__opts__);
+ // Define dynamic patterns
+ var tlds = self.__tlds__.slice();
+ self.onCompile();
+ if (!self.__tlds_replaced__) {
+ tlds.push(tlds_2ch_src_re);
+ }
+ tlds.push(re$1.src_xn);
+ re$1.src_tlds = tlds.join("|");
+ function untpl(tpl) {
+ return tpl.replace("%TLDS%", re$1.src_tlds);
+ }
+ re$1.email_fuzzy = RegExp(untpl(re$1.tpl_email_fuzzy), "i");
+ re$1.link_fuzzy = RegExp(untpl(re$1.tpl_link_fuzzy), "i");
+ re$1.link_no_ip_fuzzy = RegExp(untpl(re$1.tpl_link_no_ip_fuzzy), "i");
+ re$1.host_fuzzy_test = RegExp(untpl(re$1.tpl_host_fuzzy_test), "i");
+
+ // Compile each schema
+
+ var aliases = [];
+ self.__compiled__ = {};
+ // Reset compiled data
+ function schemaError(name, val) {
+ throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val);
+ }
+ Object.keys(self.__schemas__).forEach((function(name) {
+ var val = self.__schemas__[name];
+ // skip disabled methods
+ if (val === null) {
+ return;
+ }
+ var compiled = {
+ validate: null,
+ link: null
+ };
+ self.__compiled__[name] = compiled;
+ if (isObject(val)) {
+ if (isRegExp(val.validate)) {
+ compiled.validate = createValidator(val.validate);
+ } else if (isFunction(val.validate)) {
+ compiled.validate = val.validate;
+ } else {
+ schemaError(name, val);
+ }
+ if (isFunction(val.normalize)) {
+ compiled.normalize = val.normalize;
+ } else if (!val.normalize) {
+ compiled.normalize = createNormalizer();
+ } else {
+ schemaError(name, val);
+ }
+ return;
+ }
+ if (isString(val)) {
+ aliases.push(name);
+ return;
+ }
+ schemaError(name, val);
+ }));
+
+ // Compile postponed aliases
+
+ aliases.forEach((function(alias) {
+ if (!self.__compiled__[self.__schemas__[alias]]) {
+ // Silently fail on missed schemas to avoid errons on disable.
+ // schemaError(alias, self.__schemas__[alias]);
+ return;
+ }
+ self.__compiled__[alias].validate = self.__compiled__[self.__schemas__[alias]].validate;
+ self.__compiled__[alias].normalize = self.__compiled__[self.__schemas__[alias]].normalize;
+ }));
+
+ // Fake record for guessed links
+
+ self.__compiled__[""] = {
+ validate: null,
+ normalize: createNormalizer()
+ };
+
+ // Build schema condition
+
+ var slist = Object.keys(self.__compiled__).filter((function(name) {
+ // Filter disabled & fake schemas
+ return name.length > 0 && self.__compiled__[name];
+ })).map(escapeRE).join("|");
+ // (?!_) cause 1.5x slowdown
+ self.re.schema_test = RegExp("(^|(?!_)(?:[><\uff5c]|" + re$1.src_ZPCc + "))(" + slist + ")", "i");
+ self.re.schema_search = RegExp("(^|(?!_)(?:[><\uff5c]|" + re$1.src_ZPCc + "))(" + slist + ")", "ig");
+ self.re.schema_at_start = RegExp("^" + self.re.schema_search.source, "i");
+ self.re.pretest = RegExp("(" + self.re.schema_test.source + ")|(" + self.re.host_fuzzy_test.source + ")|@", "i");
+
+ // Cleanup
+
+ resetScanCache(self);
+ }
+ /**
+ * class Match
+ *
+ * Match result. Single element of array, returned by [[LinkifyIt#match]]
+ **/ function Match(self, shift) {
+ var start = self.__index__, end = self.__last_index__, text = self.__text_cache__.slice(start, end);
+ /**
+ * Match#schema -> String
+ *
+ * Prefix (protocol) for matched string.
+ **/ this.schema = self.__schema__.toLowerCase();
+ /**
+ * Match#index -> Number
+ *
+ * First position of matched string.
+ **/ this.index = start + shift;
+ /**
+ * Match#lastIndex -> Number
+ *
+ * Next position after matched string.
+ **/ this.lastIndex = end + shift;
+ /**
+ * Match#raw -> String
+ *
+ * Matched string.
+ **/ this.raw = text;
+ /**
+ * Match#text -> String
+ *
+ * Notmalized text of matched string.
+ **/ this.text = text;
+ /**
+ * Match#url -> String
+ *
+ * Normalized url of matched string.
+ **/ this.url = text;
+ }
+ function createMatch(self, shift) {
+ var match = new Match(self, shift);
+ self.__compiled__[match.schema].normalize(match, self);
+ return match;
+ }
+ /**
+ * class LinkifyIt
+ **/
+ /**
+ * new LinkifyIt(schemas, options)
+ * - schemas (Object): Optional. Additional schemas to validate (prefix/validator)
+ * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
+ *
+ * Creates new linkifier instance with optional additional schemas.
+ * Can be called without `new` keyword for convenience.
+ *
+ * By default understands:
+ *
+ * - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links
+ * - "fuzzy" links and emails (example.com, foo@bar.com).
+ *
+ * `schemas` is an object, where each key/value describes protocol/rule:
+ *
+ * - __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`
+ * for example). `linkify-it` makes shure that prefix is not preceeded with
+ * alphanumeric char and symbols. Only whitespaces and punctuation allowed.
+ * - __value__ - rule to check tail after link prefix
+ * - _String_ - just alias to existing rule
+ * - _Object_
+ * - _validate_ - validator function (should return matched length on success),
+ * or `RegExp`.
+ * - _normalize_ - optional function to normalize text & url of matched result
+ * (for example, for @twitter mentions).
+ *
+ * `options`:
+ *
+ * - __fuzzyLink__ - recognige URL-s without `http(s):` prefix. Default `true`.
+ * - __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts
+ * like version numbers. Default `false`.
+ * - __fuzzyEmail__ - recognize emails without `mailto:` prefix.
+ *
+ **/ function LinkifyIt(schemas, options) {
+ if (!(this instanceof LinkifyIt)) {
+ return new LinkifyIt(schemas, options);
+ }
+ if (!options) {
+ if (isOptionsObj(schemas)) {
+ options = schemas;
+ schemas = {};
+ }
+ }
+ this.__opts__ = assign({}, defaultOptions, options);
+ // Cache last tested result. Used to skip repeating steps on next `match` call.
+ this.__index__ = -1;
+ this.__last_index__ = -1;
+ // Next scan position
+ this.__schema__ = "";
+ this.__text_cache__ = "";
+ this.__schemas__ = assign({}, defaultSchemas, schemas);
+ this.__compiled__ = {};
+ this.__tlds__ = tlds_default;
+ this.__tlds_replaced__ = false;
+ this.re = {};
+ compile(this);
+ }
+ /** chainable
+ * LinkifyIt#add(schema, definition)
+ * - schema (String): rule name (fixed pattern prefix)
+ * - definition (String|RegExp|Object): schema definition
+ *
+ * Add new rule definition. See constructor description for details.
+ **/ LinkifyIt.prototype.add = function add(schema, definition) {
+ this.__schemas__[schema] = definition;
+ compile(this);
+ return this;
+ };
+ /** chainable
+ * LinkifyIt#set(options)
+ * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
+ *
+ * Set recognition options for links without schema.
+ **/ LinkifyIt.prototype.set = function set(options) {
+ this.__opts__ = assign(this.__opts__, options);
+ return this;
+ };
+ /**
+ * LinkifyIt#test(text) -> Boolean
+ *
+ * Searches linkifiable pattern and returns `true` on success or `false` on fail.
+ **/ LinkifyIt.prototype.test = function test(text) {
+ // Reset scan cache
+ this.__text_cache__ = text;
+ this.__index__ = -1;
+ if (!text.length) {
+ return false;
+ }
+ var m, ml, me, len, shift, next, re, tld_pos, at_pos;
+ // try to scan for link with schema - that's the most simple rule
+ if (this.re.schema_test.test(text)) {
+ re = this.re.schema_search;
+ re.lastIndex = 0;
+ while ((m = re.exec(text)) !== null) {
+ len = this.testSchemaAt(text, m[2], re.lastIndex);
+ if (len) {
+ this.__schema__ = m[2];
+ this.__index__ = m.index + m[1].length;
+ this.__last_index__ = m.index + m[0].length + len;
+ break;
+ }
+ }
+ }
+ if (this.__opts__.fuzzyLink && this.__compiled__["http:"]) {
+ // guess schemaless links
+ tld_pos = text.search(this.re.host_fuzzy_test);
+ if (tld_pos >= 0) {
+ // if tld is located after found link - no need to check fuzzy pattern
+ if (this.__index__ < 0 || tld_pos < this.__index__) {
+ if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
+ shift = ml.index + ml[1].length;
+ if (this.__index__ < 0 || shift < this.__index__) {
+ this.__schema__ = "";
+ this.__index__ = shift;
+ this.__last_index__ = ml.index + ml[0].length;
+ }
+ }
+ }
+ }
+ }
+ if (this.__opts__.fuzzyEmail && this.__compiled__["mailto:"]) {
+ // guess schemaless emails
+ at_pos = text.indexOf("@");
+ if (at_pos >= 0) {
+ // We can't skip this check, because this cases are possible:
+ // 192.168.1.1@gmail.com, my.in@example.com
+ if ((me = text.match(this.re.email_fuzzy)) !== null) {
+ shift = me.index + me[1].length;
+ next = me.index + me[0].length;
+ if (this.__index__ < 0 || shift < this.__index__ || shift === this.__index__ && next > this.__last_index__) {
+ this.__schema__ = "mailto:";
+ this.__index__ = shift;
+ this.__last_index__ = next;
+ }
+ }
+ }
+ }
+ return this.__index__ >= 0;
+ };
+ /**
+ * LinkifyIt#pretest(text) -> Boolean
+ *
+ * Very quick check, that can give false positives. Returns true if link MAY BE
+ * can exists. Can be used for speed optimization, when you need to check that
+ * link NOT exists.
+ **/ LinkifyIt.prototype.pretest = function pretest(text) {
+ return this.re.pretest.test(text);
+ };
+ /**
+ * LinkifyIt#testSchemaAt(text, name, position) -> Number
+ * - text (String): text to scan
+ * - name (String): rule (schema) name
+ * - position (Number): text offset to check from
+ *
+ * Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly
+ * at given position. Returns length of found pattern (0 on fail).
+ **/ LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
+ // If not supported schema check requested - terminate
+ if (!this.__compiled__[schema.toLowerCase()]) {
+ return 0;
+ }
+ return this.__compiled__[schema.toLowerCase()].validate(text, pos, this);
+ };
+ /**
+ * LinkifyIt#match(text) -> Array|null
+ *
+ * Returns array of found link descriptions or `null` on fail. We strongly
+ * recommend to use [[LinkifyIt#test]] first, for best speed.
+ *
+ * ##### Result match description
+ *
+ * - __schema__ - link schema, can be empty for fuzzy links, or `//` for
+ * protocol-neutral links.
+ * - __index__ - offset of matched text
+ * - __lastIndex__ - index of next char after mathch end
+ * - __raw__ - matched text
+ * - __text__ - normalized text
+ * - __url__ - link, generated from matched text
+ **/ LinkifyIt.prototype.match = function match(text) {
+ var shift = 0, result = [];
+ // Try to take previous element from cache, if .test() called before
+ if (this.__index__ >= 0 && this.__text_cache__ === text) {
+ result.push(createMatch(this, shift));
+ shift = this.__last_index__;
+ }
+ // Cut head if cache was used
+ var tail = shift ? text.slice(shift) : text;
+ // Scan string until end reached
+ while (this.test(tail)) {
+ result.push(createMatch(this, shift));
+ tail = tail.slice(this.__last_index__);
+ shift += this.__last_index__;
+ }
+ if (result.length) {
+ return result;
+ }
+ return null;
+ };
+ /**
+ * LinkifyIt#matchAtStart(text) -> Match|null
+ *
+ * Returns fully-formed (not fuzzy) link if it starts at the beginning
+ * of the string, and null otherwise.
+ **/ LinkifyIt.prototype.matchAtStart = function matchAtStart(text) {
+ // Reset scan cache
+ this.__text_cache__ = text;
+ this.__index__ = -1;
+ if (!text.length) return null;
+ var m = this.re.schema_at_start.exec(text);
+ if (!m) return null;
+ var len = this.testSchemaAt(text, m[2], m[0].length);
+ if (!len) return null;
+ this.__schema__ = m[2];
+ this.__index__ = m.index + m[1].length;
+ this.__last_index__ = m.index + m[0].length + len;
+ return createMatch(this, 0);
+ };
+ /** chainable
+ * LinkifyIt#tlds(list [, keepOld]) -> this
+ * - list (Array): list of tlds
+ * - keepOld (Boolean): merge with current list if `true` (`false` by default)
+ *
+ * Load (or merge) new tlds list. Those are user for fuzzy links (without prefix)
+ * to avoid false positives. By default this algorythm used:
+ *
+ * - hostname with any 2-letter root zones are ok.
+ * - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф
+ * are ok.
+ * - encoded (`xn--...`) root zones are ok.
+ *
+ * If list is replaced, then exact match for 2-chars root zones will be checked.
+ **/ LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
+ list = Array.isArray(list) ? list : [ list ];
+ if (!keepOld) {
+ this.__tlds__ = list.slice();
+ this.__tlds_replaced__ = true;
+ compile(this);
+ return this;
+ }
+ this.__tlds__ = this.__tlds__.concat(list).sort().filter((function(el, idx, arr) {
+ return el !== arr[idx - 1];
+ })).reverse();
+ compile(this);
+ return this;
+ };
+ /**
+ * LinkifyIt#normalize(match)
+ *
+ * Default normalizer (if schema does not define it's own).
+ **/ LinkifyIt.prototype.normalize = function normalize(match) {
+ // Do minimal possible changes by default. Need to collect feedback prior
+ // to move forward https://github.com/markdown-it/linkify-it/issues/1
+ if (!match.schema) {
+ match.url = "http://" + match.url;
+ }
+ if (match.schema === "mailto:" && !/^mailto:/i.test(match.url)) {
+ match.url = "mailto:" + match.url;
+ }
+ };
+ /**
+ * LinkifyIt#onCompile()
+ *
+ * Override to modify basic RegExp-s.
+ **/ LinkifyIt.prototype.onCompile = function onCompile() {};
+ var linkifyIt = LinkifyIt;
+ /*! https://mths.be/punycode v1.4.1 by @mathias */
+ /** Highest positive signed 32-bit float value */ var maxInt = 2147483647;
+ // aka. 0x7FFFFFFF or 2^31-1
+ /** Bootstring parameters */ var base = 36;
+ var tMin = 1;
+ var tMax = 26;
+ var skew = 38;
+ var damp = 700;
+ var initialBias = 72;
+ var initialN = 128;
+ // 0x80
+ var delimiter = "-";
+ // '\x2D'
+ /** Regular expressions */ var regexPunycode = /^xn--/;
+ var regexNonASCII = /[^\x20-\x7E]/;
+ // unprintable ASCII chars + non-ASCII chars
+ var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
+ // RFC 3490 separators
+ /** Error messages */ var errors = {
+ overflow: "Overflow: input needs wider integers to process",
+ "not-basic": "Illegal input >= 0x80 (not a basic code point)",
+ "invalid-input": "Invalid input"
+ };
+ /** Convenience shortcuts */ var baseMinusTMin = base - tMin;
+ var floor = Math.floor;
+ var stringFromCharCode = String.fromCharCode;
+ /*--------------------------------------------------------------------------*/
+ /**
+ * A generic error utility function.
+ * @private
+ * @param {String} type The error type.
+ * @returns {Error} Throws a `RangeError` with the applicable error message.
+ */ function error(type) {
+ throw new RangeError(errors[type]);
+ }
+ /**
+ * A generic `Array#map` utility function.
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} callback The function that gets called for every array
+ * item.
+ * @returns {Array} A new array of values returned by the callback function.
+ */ function map(array, fn) {
+ var length = array.length;
+ var result = [];
+ while (length--) {
+ result[length] = fn(array[length]);
+ }
+ return result;
+ }
+ /**
+ * A simple `Array#map`-like wrapper to work with domain name strings or email
+ * addresses.
+ * @private
+ * @param {String} domain The domain name or email address.
+ * @param {Function} callback The function that gets called for every
+ * character.
+ * @returns {Array} A new string of characters returned by the callback
+ * function.
+ */ function mapDomain(string, fn) {
+ var parts = string.split("@");
+ var result = "";
+ if (parts.length > 1) {
+ // In email addresses, only the domain name should be punycoded. Leave
+ // the local part (i.e. everything up to `@`) intact.
+ result = parts[0] + "@";
+ string = parts[1];
+ }
+ // Avoid `split(regex)` for IE8 compatibility. See #17.
+ string = string.replace(regexSeparators, ".");
+ var labels = string.split(".");
+ var encoded = map(labels, fn).join(".");
+ return result + encoded;
+ }
+ /**
+ * Creates an array containing the numeric code points of each Unicode
+ * character in the string. While JavaScript uses UCS-2 internally,
+ * this function will convert a pair of surrogate halves (each of which
+ * UCS-2 exposes as separate characters) into a single code point,
+ * matching UTF-16.
+ * @see `punycode.ucs2.encode`
+ * @see
+ * @memberOf punycode.ucs2
+ * @name decode
+ * @param {String} string The Unicode input string (UCS-2).
+ * @returns {Array} The new array of code points.
+ */ function ucs2decode(string) {
+ var output = [], counter = 0, length = string.length, value, extra;
+ while (counter < length) {
+ value = string.charCodeAt(counter++);
+ if (value >= 55296 && value <= 56319 && counter < length) {
+ // high surrogate, and there is a next character
+ extra = string.charCodeAt(counter++);
+ if ((extra & 64512) == 56320) {
+ // low surrogate
+ output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
+ } else {
+ // unmatched surrogate; only append this code unit, in case the next
+ // code unit is the high surrogate of a surrogate pair
+ output.push(value);
+ counter--;
+ }
+ } else {
+ output.push(value);
+ }
+ }
+ return output;
+ }
+ /**
+ * Creates a string based on an array of numeric code points.
+ * @see `punycode.ucs2.decode`
+ * @memberOf punycode.ucs2
+ * @name encode
+ * @param {Array} codePoints The array of numeric code points.
+ * @returns {String} The new Unicode string (UCS-2).
+ */ function ucs2encode(array) {
+ return map(array, (function(value) {
+ var output = "";
+ if (value > 65535) {
+ value -= 65536;
+ output += stringFromCharCode(value >>> 10 & 1023 | 55296);
+ value = 56320 | value & 1023;
+ }
+ output += stringFromCharCode(value);
+ return output;
+ })).join("");
+ }
+ /**
+ * Converts a basic code point into a digit/integer.
+ * @see `digitToBasic()`
+ * @private
+ * @param {Number} codePoint The basic numeric code point value.
+ * @returns {Number} The numeric value of a basic code point (for use in
+ * representing integers) in the range `0` to `base - 1`, or `base` if
+ * the code point does not represent a value.
+ */ function basicToDigit(codePoint) {
+ if (codePoint - 48 < 10) {
+ return codePoint - 22;
+ }
+ if (codePoint - 65 < 26) {
+ return codePoint - 65;
+ }
+ if (codePoint - 97 < 26) {
+ return codePoint - 97;
+ }
+ return base;
+ }
+ /**
+ * Converts a digit/integer into a basic code point.
+ * @see `basicToDigit()`
+ * @private
+ * @param {Number} digit The numeric value of a basic code point.
+ * @returns {Number} The basic code point whose value (when used for
+ * representing integers) is `digit`, which needs to be in the range
+ * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
+ * used; else, the lowercase form is used. The behavior is undefined
+ * if `flag` is non-zero and `digit` has no uppercase form.
+ */ function digitToBasic(digit, flag) {
+ // 0..25 map to ASCII a..z or A..Z
+ // 26..35 map to ASCII 0..9
+ return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
+ }
+ /**
+ * Bias adaptation function as per section 3.4 of RFC 3492.
+ * https://tools.ietf.org/html/rfc3492#section-3.4
+ * @private
+ */ function adapt(delta, numPoints, firstTime) {
+ var k = 0;
+ delta = firstTime ? floor(delta / damp) : delta >> 1;
+ delta += floor(delta / numPoints);
+ for (;delta > baseMinusTMin * tMax >> 1; k += base) {
+ delta = floor(delta / baseMinusTMin);
+ }
+ return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
+ }
+ /**
+ * Converts a Punycode string of ASCII-only symbols to a string of Unicode
+ * symbols.
+ * @memberOf punycode
+ * @param {String} input The Punycode string of ASCII-only symbols.
+ * @returns {String} The resulting string of Unicode symbols.
+ */ function decode(input) {
+ // Don't use UCS-2
+ var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t,
+ /** Cached calculation results */
+ baseMinusT;
+ // Handle the basic code points: let `basic` be the number of input code
+ // points before the last delimiter, or `0` if there is none, then copy
+ // the first basic code points to the output.
+ basic = input.lastIndexOf(delimiter);
+ if (basic < 0) {
+ basic = 0;
+ }
+ for (j = 0; j < basic; ++j) {
+ // if it's not a basic code point
+ if (input.charCodeAt(j) >= 128) {
+ error("not-basic");
+ }
+ output.push(input.charCodeAt(j));
+ }
+ // Main decoding loop: start just after the last delimiter if any basic code
+ // points were copied; start at the beginning otherwise.
+ for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
+ // `index` is the index of the next character to be consumed.
+ // Decode a generalized variable-length integer into `delta`,
+ // which gets added to `i`. The overflow checking is easier
+ // if we increase `i` as we go, then subtract off its starting
+ // value at the end to obtain `delta`.
+ for (oldi = i, w = 1, k = base; ;k += base) {
+ if (index >= inputLength) {
+ error("invalid-input");
+ }
+ digit = basicToDigit(input.charCodeAt(index++));
+ if (digit >= base || digit > floor((maxInt - i) / w)) {
+ error("overflow");
+ }
+ i += digit * w;
+ t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
+ if (digit < t) {
+ break;
+ }
+ baseMinusT = base - t;
+ if (w > floor(maxInt / baseMinusT)) {
+ error("overflow");
+ }
+ w *= baseMinusT;
+ }
+ out = output.length + 1;
+ bias = adapt(i - oldi, out, oldi == 0);
+ // `i` was supposed to wrap around from `out` to `0`,
+ // incrementing `n` each time, so we'll fix that now:
+ if (floor(i / out) > maxInt - n) {
+ error("overflow");
+ }
+ n += floor(i / out);
+ i %= out;
+ // Insert `n` at position `i` of the output
+ output.splice(i++, 0, n);
+ }
+ return ucs2encode(output);
+ }
+ /**
+ * Converts a string of Unicode symbols (e.g. a domain name label) to a
+ * Punycode string of ASCII-only symbols.
+ * @memberOf punycode
+ * @param {String} input The string of Unicode symbols.
+ * @returns {String} The resulting Punycode string of ASCII-only symbols.
+ */ function encode(input) {
+ var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [],
+ /** `inputLength` will hold the number of code points in `input`. */
+ inputLength,
+ /** Cached calculation results */
+ handledCPCountPlusOne, baseMinusT, qMinusT;
+ // Convert the input in UCS-2 to Unicode
+ input = ucs2decode(input);
+ // Cache the length
+ inputLength = input.length;
+ // Initialize the state
+ n = initialN;
+ delta = 0;
+ bias = initialBias;
+ // Handle the basic code points
+ for (j = 0; j < inputLength; ++j) {
+ currentValue = input[j];
+ if (currentValue < 128) {
+ output.push(stringFromCharCode(currentValue));
+ }
+ }
+ handledCPCount = basicLength = output.length;
+ // `handledCPCount` is the number of code points that have been handled;
+ // `basicLength` is the number of basic code points.
+ // Finish the basic string - if it is not empty - with a delimiter
+ if (basicLength) {
+ output.push(delimiter);
+ }
+ // Main encoding loop:
+ while (handledCPCount < inputLength) {
+ // All non-basic code points < n have been handled already. Find the next
+ // larger one:
+ for (m = maxInt, j = 0; j < inputLength; ++j) {
+ currentValue = input[j];
+ if (currentValue >= n && currentValue < m) {
+ m = currentValue;
+ }
+ }
+ // Increase `delta` enough to advance the decoder's state to ,
+ // but guard against overflow
+ handledCPCountPlusOne = handledCPCount + 1;
+ if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
+ error("overflow");
+ }
+ delta += (m - n) * handledCPCountPlusOne;
+ n = m;
+ for (j = 0; j < inputLength; ++j) {
+ currentValue = input[j];
+ if (currentValue < n && ++delta > maxInt) {
+ error("overflow");
+ }
+ if (currentValue == n) {
+ // Represent delta as a generalized variable-length integer
+ for (q = delta, k = base; ;k += base) {
+ t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
+ if (q < t) {
+ break;
+ }
+ qMinusT = q - t;
+ baseMinusT = base - t;
+ output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
+ q = floor(qMinusT / baseMinusT);
+ }
+ output.push(stringFromCharCode(digitToBasic(q, 0)));
+ bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
+ delta = 0;
+ ++handledCPCount;
+ }
+ }
+ ++delta;
+ ++n;
+ }
+ return output.join("");
+ }
+ /**
+ * Converts a Punycode string representing a domain name or an email address
+ * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
+ * it doesn't matter if you call it on a string that has already been
+ * converted to Unicode.
+ * @memberOf punycode
+ * @param {String} input The Punycoded domain name or email address to
+ * convert to Unicode.
+ * @returns {String} The Unicode representation of the given Punycode
+ * string.
+ */ function toUnicode(input) {
+ return mapDomain(input, (function(string) {
+ return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
+ }));
+ }
+ /**
+ * Converts a Unicode string representing a domain name or an email address to
+ * Punycode. Only the non-ASCII parts of the domain name will be converted,
+ * i.e. it doesn't matter if you call it with a domain that's already in
+ * ASCII.
+ * @memberOf punycode
+ * @param {String} input The domain name or email address to convert, as a
+ * Unicode string.
+ * @returns {String} The Punycode representation of the given domain name or
+ * email address.
+ */ function toASCII(input) {
+ return mapDomain(input, (function(string) {
+ return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
+ }));
+ }
+ var version = "1.4.1";
+ /**
+ * An object of methods to convert from JavaScript's internal character
+ * representation (UCS-2) to Unicode code points, and back.
+ * @see
+ * @memberOf punycode
+ * @type Object
+ */ var ucs2 = {
+ decode: ucs2decode,
+ encode: ucs2encode
+ };
+ var punycode$1 = {
+ version: version,
+ ucs2: ucs2,
+ toASCII: toASCII,
+ toUnicode: toUnicode,
+ encode: encode,
+ decode: decode
+ };
+ var punycode$2 = Object.freeze({
+ __proto__: null,
+ decode: decode,
+ encode: encode,
+ toUnicode: toUnicode,
+ toASCII: toASCII,
+ version: version,
+ ucs2: ucs2,
+ default: punycode$1
+ });
+ // markdown-it default options
+ var _default = {
+ options: {
+ html: false,
+ // Enable HTML tags in source
+ xhtmlOut: false,
+ // Use '/' to close single tags (
)
+ breaks: false,
+ // Convert '\n' in paragraphs into
+ langPrefix: "language-",
+ // CSS language prefix for fenced blocks
+ linkify: false,
+ // autoconvert URL-like texts to links
+ // Enable some language-neutral replacements + quotes beautification
+ typographer: false,
+ // Double + single quotes replacement pairs, when typographer enabled,
+ // and smartquotes on. Could be either a String or an Array.
+ // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
+ // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
+ quotes: "\u201c\u201d\u2018\u2019",
+ /* “”‘’ */
+ // Highlighter function. Should return escaped HTML,
+ // or '' if the source string is not changed and should be escaped externaly.
+ // If result starts with )
+ breaks: false,
+ // Convert '\n' in paragraphs into
+ langPrefix: "language-",
+ // CSS language prefix for fenced blocks
+ linkify: false,
+ // autoconvert URL-like texts to links
+ // Enable some language-neutral replacements + quotes beautification
+ typographer: false,
+ // Double + single quotes replacement pairs, when typographer enabled,
+ // and smartquotes on. Could be either a String or an Array.
+ // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
+ // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
+ quotes: "\u201c\u201d\u2018\u2019",
+ /* “”‘’ */
+ // Highlighter function. Should return escaped HTML,
+ // or '' if the source string is not changed and should be escaped externaly.
+ // If result starts with )
+ breaks: false,
+ // Convert '\n' in paragraphs into
+ langPrefix: "language-",
+ // CSS language prefix for fenced blocks
+ linkify: false,
+ // autoconvert URL-like texts to links
+ // Enable some language-neutral replacements + quotes beautification
+ typographer: false,
+ // Double + single quotes replacement pairs, when typographer enabled,
+ // and smartquotes on. Could be either a String or an Array.
+ // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
+ // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
+ quotes: "\u201c\u201d\u2018\u2019",
+ /* “”‘’ */
+ // Highlighter function. Should return escaped HTML,
+ // or '' if the source string is not changed and should be escaped externaly.
+ // If result starts with = 0) {
+ try {
+ parsed.hostname = punycode.toASCII(parsed.hostname);
+ } catch (er) {}
+ }
+ }
+ return mdurl.encode(mdurl.format(parsed));
+ }
+ function normalizeLinkText(url) {
+ var parsed = mdurl.parse(url, true);
+ if (parsed.hostname) {
+ // Encode hostnames in urls like:
+ // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
+ // We don't encode unknown schemas, because it's likely that we encode
+ // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
+ if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
+ try {
+ parsed.hostname = punycode.toUnicode(parsed.hostname);
+ } catch (er) {}
+ }
+ }
+ // add '%' to exclude list because of https://github.com/markdown-it/markdown-it/issues/720
+ return mdurl.decode(mdurl.format(parsed), mdurl.decode.defaultChars + "%");
+ }
+ /**
+ * class MarkdownIt
+ *
+ * Main parser/renderer class.
+ *
+ * ##### Usage
+ *
+ * ```javascript
+ * // node.js, "classic" way:
+ * var MarkdownIt = require('markdown-it'),
+ * md = new MarkdownIt();
+ * var result = md.render('# markdown-it rulezz!');
+ *
+ * // node.js, the same, but with sugar:
+ * var md = require('markdown-it')();
+ * var result = md.render('# markdown-it rulezz!');
+ *
+ * // browser without AMD, added to "window" on script load
+ * // Note, there are no dash.
+ * var md = window.markdownit();
+ * var result = md.render('# markdown-it rulezz!');
+ * ```
+ *
+ * Single line rendering, without paragraph wrap:
+ *
+ * ```javascript
+ * var md = require('markdown-it')();
+ * var result = md.renderInline('__markdown-it__ rulezz!');
+ * ```
+ **/
+ /**
+ * new MarkdownIt([presetName, options])
+ * - presetName (String): optional, `commonmark` / `zero`
+ * - options (Object)
+ *
+ * Creates parser instanse with given config. Can be called without `new`.
+ *
+ * ##### presetName
+ *
+ * MarkdownIt provides named presets as a convenience to quickly
+ * enable/disable active syntax rules and options for common use cases.
+ *
+ * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -
+ * configures parser to strict [CommonMark](http://commonmark.org/) mode.
+ * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -
+ * similar to GFM, used when no preset name given. Enables all available rules,
+ * but still without html, typographer & autolinker.
+ * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -
+ * all rules disabled. Useful to quickly setup your config via `.enable()`.
+ * For example, when you need only `bold` and `italic` markup and nothing else.
+ *
+ * ##### options:
+ *
+ * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful!
+ * That's not safe! You may need external sanitizer to protect output from XSS.
+ * It's better to extend features via plugins, instead of enabling HTML.
+ * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags
+ * (`
`). This is needed only for full CommonMark compatibility. In real
+ * world you will need HTML output.
+ * - __breaks__ - `false`. Set `true` to convert `\n` in paragraphs into `
`.
+ * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks.
+ * Can be useful for external highlighters.
+ * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.
+ * - __typographer__ - `false`. Set `true` to enable [some language-neutral
+ * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
+ * quotes beautification (smartquotes).
+ * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement
+ * pairs, when typographer enabled and smartquotes on. For example, you can
+ * use `'«»„“'` for Russian, `'„“‚‘'` for German, and
+ * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
+ * - __highlight__ - `null`. Highlighter function for fenced code blocks.
+ * Highlighter `function (str, lang)` should return escaped HTML. It can also
+ * return empty string if the source was not changed and should be escaped
+ * externaly. If result starts with `):
+ *
+ * ```javascript
+ * var hljs = require('highlight.js') // https://highlightjs.org/
+ *
+ * // Actual default values
+ * var md = require('markdown-it')({
+ * highlight: function (str, lang) {
+ * if (lang && hljs.getLanguage(lang)) {
+ * try {
+ * return '' +
+ * hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
+ * '
';
+ * } catch (__) {}
+ * }
+ *
+ * return '' + md.utils.escapeHtml(str) + '
';
+ * }
+ * });
+ * ```
+ *
+ **/ function MarkdownIt(presetName, options) {
+ if (!(this instanceof MarkdownIt)) {
+ return new MarkdownIt(presetName, options);
+ }
+ if (!options) {
+ if (!utils.isString(presetName)) {
+ options = presetName || {};
+ presetName = "default";
+ }
+ }
+ /**
+ * MarkdownIt#inline -> ParserInline
+ *
+ * Instance of [[ParserInline]]. You may need it to add new rules when
+ * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
+ * [[MarkdownIt.enable]].
+ **/ this.inline = new parser_inline;
+ /**
+ * MarkdownIt#block -> ParserBlock
+ *
+ * Instance of [[ParserBlock]]. You may need it to add new rules when
+ * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
+ * [[MarkdownIt.enable]].
+ **/ this.block = new parser_block;
+ /**
+ * MarkdownIt#core -> Core
+ *
+ * Instance of [[Core]] chain executor. You may need it to add new rules when
+ * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
+ * [[MarkdownIt.enable]].
+ **/ this.core = new parser_core;
+ /**
+ * MarkdownIt#renderer -> Renderer
+ *
+ * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering
+ * rules for new token types, generated by plugins.
+ *
+ * ##### Example
+ *
+ * ```javascript
+ * var md = require('markdown-it')();
+ *
+ * function myToken(tokens, idx, options, env, self) {
+ * //...
+ * return result;
+ * };
+ *
+ * md.renderer.rules['my_token'] = myToken
+ * ```
+ *
+ * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).
+ **/ this.renderer = new renderer;
+ /**
+ * MarkdownIt#linkify -> LinkifyIt
+ *
+ * [linkify-it](https://github.com/markdown-it/linkify-it) instance.
+ * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)
+ * rule.
+ **/ this.linkify = new linkifyIt;
+ /**
+ * MarkdownIt#validateLink(url) -> Boolean
+ *
+ * Link validation function. CommonMark allows too much in links. By default
+ * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
+ * except some embedded image types.
+ *
+ * You can change this behaviour:
+ *
+ * ```javascript
+ * var md = require('markdown-it')();
+ * // enable everything
+ * md.validateLink = function () { return true; }
+ * ```
+ **/ this.validateLink = validateLink;
+ /**
+ * MarkdownIt#normalizeLink(url) -> String
+ *
+ * Function used to encode link url to a machine-readable format,
+ * which includes url-encoding, punycode, etc.
+ **/ this.normalizeLink = normalizeLink;
+ /**
+ * MarkdownIt#normalizeLinkText(url) -> String
+ *
+ * Function used to decode link url to a human-readable format`
+ **/ this.normalizeLinkText = normalizeLinkText;
+ // Expose utils & helpers for easy acces from plugins
+ /**
+ * MarkdownIt#utils -> utils
+ *
+ * Assorted utility functions, useful to write plugins. See details
+ * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js).
+ **/ this.utils = utils;
+ /**
+ * MarkdownIt#helpers -> helpers
+ *
+ * Link components parser functions, useful to write plugins. See details
+ * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers).
+ **/ this.helpers = utils.assign({}, helpers);
+ this.options = {};
+ this.configure(presetName);
+ if (options) {
+ this.set(options);
+ }
+ }
+ /** chainable
+ * MarkdownIt.set(options)
+ *
+ * Set parser options (in the same format as in constructor). Probably, you
+ * will never need it, but you can change options after constructor call.
+ *
+ * ##### Example
+ *
+ * ```javascript
+ * var md = require('markdown-it')()
+ * .set({ html: true, breaks: true })
+ * .set({ typographer, true });
+ * ```
+ *
+ * __Note:__ To achieve the best possible performance, don't modify a
+ * `markdown-it` instance options on the fly. If you need multiple configurations
+ * it's best to create multiple instances and initialize each with separate
+ * config.
+ **/ MarkdownIt.prototype.set = function(options) {
+ utils.assign(this.options, options);
+ return this;
+ };
+ /** chainable, internal
+ * MarkdownIt.configure(presets)
+ *
+ * Batch load of all options and compenent settings. This is internal method,
+ * and you probably will not need it. But if you will - see available presets
+ * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)
+ *
+ * We strongly recommend to use presets instead of direct config loads. That
+ * will give better compatibility with next versions.
+ **/ MarkdownIt.prototype.configure = function(presets) {
+ var self = this, presetName;
+ if (utils.isString(presets)) {
+ presetName = presets;
+ presets = config[presetName];
+ if (!presets) {
+ throw new Error('Wrong `markdown-it` preset "' + presetName + '", check name');
+ }
+ }
+ if (!presets) {
+ throw new Error("Wrong `markdown-it` preset, can't be empty");
+ }
+ if (presets.options) {
+ self.set(presets.options);
+ }
+ if (presets.components) {
+ Object.keys(presets.components).forEach((function(name) {
+ if (presets.components[name].rules) {
+ self[name].ruler.enableOnly(presets.components[name].rules);
+ }
+ if (presets.components[name].rules2) {
+ self[name].ruler2.enableOnly(presets.components[name].rules2);
+ }
+ }));
+ }
+ return this;
+ };
+ /** chainable
+ * MarkdownIt.enable(list, ignoreInvalid)
+ * - list (String|Array): rule name or list of rule names to enable
+ * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
+ *
+ * Enable list or rules. It will automatically find appropriate components,
+ * containing rules with given names. If rule not found, and `ignoreInvalid`
+ * not set - throws exception.
+ *
+ * ##### Example
+ *
+ * ```javascript
+ * var md = require('markdown-it')()
+ * .enable(['sub', 'sup'])
+ * .disable('smartquotes');
+ * ```
+ **/ MarkdownIt.prototype.enable = function(list, ignoreInvalid) {
+ var result = [];
+ if (!Array.isArray(list)) {
+ list = [ list ];
+ }
+ [ "core", "block", "inline" ].forEach((function(chain) {
+ result = result.concat(this[chain].ruler.enable(list, true));
+ }), this);
+ result = result.concat(this.inline.ruler2.enable(list, true));
+ var missed = list.filter((function(name) {
+ return result.indexOf(name) < 0;
+ }));
+ if (missed.length && !ignoreInvalid) {
+ throw new Error("MarkdownIt. Failed to enable unknown rule(s): " + missed);
+ }
+ return this;
+ };
+ /** chainable
+ * MarkdownIt.disable(list, ignoreInvalid)
+ * - list (String|Array): rule name or list of rule names to disable.
+ * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
+ *
+ * The same as [[MarkdownIt.enable]], but turn specified rules off.
+ **/ MarkdownIt.prototype.disable = function(list, ignoreInvalid) {
+ var result = [];
+ if (!Array.isArray(list)) {
+ list = [ list ];
+ }
+ [ "core", "block", "inline" ].forEach((function(chain) {
+ result = result.concat(this[chain].ruler.disable(list, true));
+ }), this);
+ result = result.concat(this.inline.ruler2.disable(list, true));
+ var missed = list.filter((function(name) {
+ return result.indexOf(name) < 0;
+ }));
+ if (missed.length && !ignoreInvalid) {
+ throw new Error("MarkdownIt. Failed to disable unknown rule(s): " + missed);
+ }
+ return this;
+ };
+ /** chainable
+ * MarkdownIt.use(plugin, params)
+ *
+ * Load specified plugin with given params into current parser instance.
+ * It's just a sugar to call `plugin(md, params)` with curring.
+ *
+ * ##### Example
+ *
+ * ```javascript
+ * var iterator = require('markdown-it-for-inline');
+ * var md = require('markdown-it')()
+ * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {
+ * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
+ * });
+ * ```
+ **/ MarkdownIt.prototype.use = function(plugin /*, params, ... */) {
+ var args = [ this ].concat(Array.prototype.slice.call(arguments, 1));
+ plugin.apply(plugin, args);
+ return this;
+ };
+ /** internal
+ * MarkdownIt.parse(src, env) -> Array
+ * - src (String): source string
+ * - env (Object): environment sandbox
+ *
+ * Parse input string and return list of block tokens (special token type
+ * "inline" will contain list of inline tokens). You should not call this
+ * method directly, until you write custom renderer (for example, to produce
+ * AST).
+ *
+ * `env` is used to pass data between "distributed" rules and return additional
+ * metadata like reference info, needed for the renderer. It also can be used to
+ * inject data in specific cases. Usually, you will be ok to pass `{}`,
+ * and then pass updated object to renderer.
+ **/ MarkdownIt.prototype.parse = function(src, env) {
+ if (typeof src !== "string") {
+ throw new Error("Input data should be a String");
+ }
+ var state = new this.core.State(src, this, env);
+ this.core.process(state);
+ return state.tokens;
+ };
+ /**
+ * MarkdownIt.render(src [, env]) -> String
+ * - src (String): source string
+ * - env (Object): environment sandbox
+ *
+ * Render markdown string into html. It does all magic for you :).
+ *
+ * `env` can be used to inject additional metadata (`{}` by default).
+ * But you will not need it with high probability. See also comment
+ * in [[MarkdownIt.parse]].
+ **/ MarkdownIt.prototype.render = function(src, env) {
+ env = env || {};
+ return this.renderer.render(this.parse(src, env), this.options, env);
+ };
+ /** internal
+ * MarkdownIt.parseInline(src, env) -> Array
+ * - src (String): source string
+ * - env (Object): environment sandbox
+ *
+ * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the
+ * block tokens list with the single `inline` element, containing parsed inline
+ * tokens in `children` property. Also updates `env` object.
+ **/ MarkdownIt.prototype.parseInline = function(src, env) {
+ var state = new this.core.State(src, this, env);
+ state.inlineMode = true;
+ this.core.process(state);
+ return state.tokens;
+ };
+ /**
+ * MarkdownIt.renderInline(src [, env]) -> String
+ * - src (String): source string
+ * - env (Object): environment sandbox
+ *
+ * Similar to [[MarkdownIt.render]] but for single paragraph content. Result
+ * will NOT be wrapped into `` tags.
+ **/ MarkdownIt.prototype.renderInline = function(src, env) {
+ env = env || {};
+ return this.renderer.render(this.parseInline(src, env), this.options, env);
+ };
+ var lib = MarkdownIt;
+ var markdownIt = lib;
+ return markdownIt;
+}));
diff --git a/src/interface/desktop/assets/org.min.js b/src/interface/desktop/assets/org.min.js
new file mode 100644
index 0000000000000000000000000000000000000000..a919b280b5fbd048f86dbe44f3ff581dbef97f3b
--- /dev/null
+++ b/src/interface/desktop/assets/org.min.js
@@ -0,0 +1,1823 @@
+// Generated by export.rb at Sat Feb 21 07:44:29 UTC 2015
+/*
+ Copyright (c) 2014 Masafumi Oyamada
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+var Org = (function () {
+ var exports = {};
+
+ // ------------------------------------------------------------
+ // Syntax
+ // ------------------------------------------------------------
+
+ var Syntax = {
+ rules: {},
+
+ define: function (name, syntax) {
+ this.rules[name] = syntax;
+ var methodName = "is" + name.substring(0, 1).toUpperCase() + name.substring(1);
+ this[methodName] = function (line) {
+ return this.rules[name].exec(line);
+ };
+ }
+ };
+
+ Syntax.define("header", /^(\*+)\s+(.*)$/); // m[1] => level, m[2] => content
+ Syntax.define("preformatted", /^(\s*):(?: (.*)$|$)/); // m[1] => indentation, m[2] => content
+ Syntax.define("unorderedListElement", /^(\s*)(?:-|\+|\s+\*)\s+(.*)$/); // m[1] => indentation, m[2] => content
+ Syntax.define("orderedListElement", /^(\s*)(\d+)(?:\.|\))\s+(.*)$/); // m[1] => indentation, m[2] => number, m[3] => content
+ Syntax.define("tableSeparator", /^(\s*)\|((?:\+|-)*?)\|?$/); // m[1] => indentation, m[2] => content
+ Syntax.define("tableRow", /^(\s*)\|(.*?)\|?$/); // m[1] => indentation, m[2] => content
+ Syntax.define("blank", /^$/);
+ Syntax.define("horizontalRule", /^(\s*)-{5,}$/); //
+ Syntax.define("directive", /^(\s*)#\+(?:(begin|end)_)?(.*)$/i); // m[1] => indentation, m[2] => type, m[3] => content
+ Syntax.define("comment", /^(\s*)#(.*)$/);
+ Syntax.define("line", /^(\s*)(.*)$/);
+
+ const propertyDrawer = /:PROPERTIES:(.*):END:/g;
+
+ // ------------------------------------------------------------
+ // Token
+ // ------------------------------------------------------------
+
+ function Token() {
+ }
+
+ Token.prototype = {
+ isListElement: function () {
+ return this.type === Lexer.tokens.orderedListElement ||
+ this.type === Lexer.tokens.unorderedListElement;
+ },
+
+ isTableElement: function () {
+ return this.type === Lexer.tokens.tableSeparator ||
+ this.type === Lexer.tokens.tableRow;
+ }
+ };
+
+ // ------------------------------------------------------------
+ // Lexer
+ // ------------------------------------------------------------
+
+ function Lexer(stream) {
+ this.stream = stream;
+ this.tokenStack = [];
+ }
+
+ Lexer.prototype = {
+ tokenize: function (line) {
+ var token = new Token();
+ token.fromLineNumber = this.stream.lineNumber;
+
+ if (Syntax.isHeader(line)) {
+ token.type = Lexer.tokens.header;
+ token.indentation = 0;
+ token.content = RegExp.$2;
+ // specific
+ token.level = 2;
+ } else if (Syntax.isPreformatted(line)) {
+ token.type = Lexer.tokens.preformatted;
+ token.indentation = RegExp.$1.length;
+ token.content = RegExp.$2;
+ } else if (Syntax.isUnorderedListElement(line)) {
+ token.type = Lexer.tokens.unorderedListElement;
+ token.indentation = RegExp.$1.length;
+ token.content = RegExp.$2;
+ } else if (Syntax.isOrderedListElement(line)) {
+ token.type = Lexer.tokens.orderedListElement;
+ token.indentation = RegExp.$1.length;
+ token.content = RegExp.$3;
+ // specific
+ token.number = RegExp.$2;
+ } else if (Syntax.isTableSeparator(line)) {
+ token.type = Lexer.tokens.tableSeparator;
+ token.indentation = RegExp.$1.length;
+ token.content = RegExp.$2;
+ } else if (Syntax.isTableRow(line)) {
+ token.type = Lexer.tokens.tableRow;
+ token.indentation = RegExp.$1.length;
+ token.content = RegExp.$2;
+ } else if (Syntax.isBlank(line)) {
+ token.type = Lexer.tokens.blank;
+ token.indentation = 0;
+ token.content = null;
+ } else if (Syntax.isHorizontalRule(line)) {
+ token.type = Lexer.tokens.horizontalRule;
+ token.indentation = RegExp.$1.length;
+ token.content = null;
+ } else if (Syntax.isDirective(line)) {
+ token.type = Lexer.tokens.directive;
+ token.indentation = RegExp.$1.length;
+ token.content = RegExp.$3;
+ // decide directive type (begin, end or oneshot)
+ var directiveTypeString = RegExp.$2;
+ if (/^begin/i.test(directiveTypeString))
+ token.beginDirective = true;
+ else if (/^end/i.test(directiveTypeString))
+ token.endDirective = true;
+ else
+ token.oneshotDirective = true;
+ } else if (Syntax.isComment(line)) {
+ token.type = Lexer.tokens.comment;
+ token.indentation = RegExp.$1.length;
+ token.content = RegExp.$2;
+ } else if (Syntax.isLine(line)) {
+ token.type = Lexer.tokens.line;
+ token.indentation = RegExp.$1.length;
+ token.content = RegExp.$2;
+ } else {
+ throw new Error("SyntaxError: Unknown line: " + line);
+ }
+
+ return token;
+ },
+
+ pushToken: function (token) {
+ this.tokenStack.push(token);
+ },
+
+ pushDummyTokenByType: function (type) {
+ var token = new Token();
+ token.type = type;
+ this.tokenStack.push(token);
+ },
+
+ peekStackedToken: function () {
+ return this.tokenStack.length > 0 ?
+ this.tokenStack[this.tokenStack.length - 1] : null;
+ },
+
+ getStackedToken: function () {
+ return this.tokenStack.length > 0 ?
+ this.tokenStack.pop() : null;
+ },
+
+ peekNextToken: function () {
+ return this.peekStackedToken() ||
+ this.tokenize(this.stream.peekNextLine());
+ },
+
+ getNextToken: function () {
+ return this.getStackedToken() ||
+ this.tokenize(this.stream.getNextLine());
+ },
+
+ hasNext: function () {
+ return this.stream.hasNext();
+ },
+
+ getLineNumber: function () {
+ return this.stream.lineNumber;
+ }
+ };
+
+ Lexer.tokens = {};
+ [
+ "header",
+ "orderedListElement",
+ "unorderedListElement",
+ "tableRow",
+ "tableSeparator",
+ "preformatted",
+ "line",
+ "horizontalRule",
+ "blank",
+ "directive",
+ "comment"
+ ].forEach(function (tokenName, i) {
+ Lexer.tokens[tokenName] = i;
+ });
+
+ // ------------------------------------------------------------
+ // Exports
+ // ------------------------------------------------------------
+
+ if (typeof exports !== "undefined")
+ exports.Lexer = Lexer;
+
+ function PrototypeNode(type, children) {
+ this.type = type;
+ this.children = [];
+
+ if (children) {
+ for (var i = 0, len = children.length; i < len; ++i) {
+ this.appendChild(children[i]);
+ }
+ }
+ }
+ PrototypeNode.prototype = {
+ previousSibling: null,
+ parent: null,
+ get firstChild() {
+ return this.children.length < 1 ?
+ null : this.children[0];
+ },
+ get lastChild() {
+ return this.children.length < 1 ?
+ null : this.children[this.children.length - 1];
+ },
+ appendChild: function (newChild) {
+ var previousSibling = this.children.length < 1 ?
+ null : this.lastChild;
+ this.children.push(newChild);
+ newChild.previousSibling = previousSibling;
+ newChild.parent = this;
+ },
+ toString: function () {
+ var string = "<" + this.type + ">";
+
+ if (typeof this.value !== "undefined") {
+ string += " " + this.value;
+ } else if (this.children) {
+ string += "\n" + this.children.map(function (child, idx) {
+ return "#" + idx + " " + child.toString();
+ }).join("\n").split("\n").map(function (line) {
+ return " " + line;
+ }).join("\n");
+ }
+
+ return string;
+ }
+ };
+
+ var Node = {
+ types: {},
+
+ define: function (name, postProcess) {
+ this.types[name] = name;
+
+ var methodName = "create" + name.substring(0, 1).toUpperCase() + name.substring(1);
+ var postProcessGiven = typeof postProcess === "function";
+
+ this[methodName] = function (children, options) {
+ var node = new PrototypeNode(name, children);
+
+ if (postProcessGiven)
+ postProcess(node, options || {});
+
+ return node;
+ };
+ }
+ };
+
+ Node.define("text", function (node, options) {
+ node.value = options.value;
+ });
+ Node.define("header", function (node, options) {
+ node.level = options.level;
+ });
+ Node.define("orderedList");
+ Node.define("unorderedList");
+ Node.define("definitionList");
+ Node.define("listElement");
+ Node.define("paragraph");
+ Node.define("preformatted");
+ Node.define("table");
+ Node.define("tableRow");
+ Node.define("tableCell");
+ Node.define("horizontalRule");
+ Node.define("directive");
+
+ // Inline
+ Node.define("inlineContainer");
+
+ Node.define("bold");
+ Node.define("italic");
+ Node.define("underline");
+ Node.define("code");
+ Node.define("verbatim");
+ Node.define("dashed");
+ Node.define("link", function (node, options) {
+ node.src = options.src;
+ });
+
+ if (typeof exports !== "undefined")
+ exports.Node = Node;
+
+ function Stream(sequence) {
+ this.sequences = sequence.split(/\r?\n/);
+ this.totalLines = this.sequences.length;
+ this.lineNumber = 0;
+ }
+
+ Stream.prototype.peekNextLine = function () {
+ return this.hasNext() ? this.sequences[this.lineNumber] : null;
+ };
+
+ Stream.prototype.getNextLine = function () {
+ return this.hasNext() ? this.sequences[this.lineNumber++] : null;
+ };
+
+ Stream.prototype.hasNext = function () {
+ return this.lineNumber < this.totalLines;
+ };
+
+ if (typeof exports !== "undefined") {
+ exports.Stream = Stream;
+ }
+
+ // var Stream = require("./stream.js").Stream;
+ // var Lexer = require("./lexer.js").Lexer;
+ // var Node = require("./node.js").Node;
+
+ function Parser() {
+ this.inlineParser = new InlineParser();
+ }
+
+ Parser.parseStream = function (stream, options) {
+ var parser = new Parser();
+ parser.initStatus(stream, options);
+ parser.parseNodes();
+ return parser.nodes;
+ };
+
+ Parser.prototype = {
+ initStatus: function (stream, options) {
+ if (typeof stream === "string")
+ stream = new Stream(stream);
+ this.lexer = new Lexer(stream);
+ this.nodes = [];
+ this.options = {
+ toc: true,
+ num: true,
+ "^": "{}",
+ multilineCell: false
+ };
+ // Override option values
+ if (options && typeof options === "object") {
+ for (var key in options) {
+ this.options[key] = options[key];
+ }
+ }
+ this.document = {
+ options: this.options,
+ directiveValues: {},
+ convert: function (ConverterClass, exportOptions) {
+ var converter = new ConverterClass(this, exportOptions);
+ return converter.result;
+ }
+ };
+ },
+
+ parse: function (stream, options) {
+ this.initStatus(stream, options);
+ this.parseDocument();
+ this.document.nodes = this.nodes;
+ return this.document;
+ },
+
+ createErrorReport: function (message) {
+ return new Error(message + " at line " + this.lexer.getLineNumber());
+ },
+
+ skipBlank: function () {
+ var blankToken = null;
+ while (this.lexer.peekNextToken().type === Lexer.tokens.blank)
+ blankToken = this.lexer.getNextToken();
+ return blankToken;
+ },
+
+ setNodeOriginFromToken: function (node, token) {
+ node.fromLineNumber = token.fromLineNumber;
+ return node;
+ },
+
+ appendNode: function (newNode) {
+ var previousSibling = this.nodes.length > 0 ? this.nodes[this.nodes.length - 1] : null;
+ this.nodes.push(newNode);
+ newNode.previousSibling = previousSibling;
+ },
+
+ // ------------------------------------------------------------
+ // ::= *
+ // ------------------------------------------------------------
+
+ parseDocument: function () {
+ this.parseTitle();
+ this.parseNodes();
+ },
+
+ parseNodes: function () {
+ while (this.lexer.hasNext()) {
+ var element = this.parseElement();
+ if (element) this.appendNode(element);
+ }
+ },
+
+ parseTitle: function () {
+ this.skipBlank();
+
+ if (this.lexer.hasNext() &&
+ this.lexer.peekNextToken().type === Lexer.tokens.line)
+ this.document.title = this.createTextNode(this.lexer.getNextToken().content);
+ else
+ this.document.title = null;
+
+ this.lexer.pushDummyTokenByType(Lexer.tokens.blank);
+ },
+
+ // ------------------------------------------------------------
+ // ::= ( |
+ // | |
+ // | )*
+ // ------------------------------------------------------------
+
+ parseElement: function () {
+ var element = null;
+
+ switch (this.lexer.peekNextToken().type) {
+ case Lexer.tokens.header:
+ element = this.parseHeader();
+ break;
+ case Lexer.tokens.preformatted:
+ element = this.parsePreformatted();
+ break;
+ case Lexer.tokens.orderedListElement:
+ case Lexer.tokens.unorderedListElement:
+ element = this.parseList();
+ break;
+ case Lexer.tokens.line:
+ element = this.parseText();
+ break;
+ case Lexer.tokens.tableRow:
+ case Lexer.tokens.tableSeparator:
+ element = this.parseTable();
+ break;
+ case Lexer.tokens.blank:
+ this.skipBlank();
+ if (this.lexer.hasNext()) {
+ if (this.lexer.peekNextToken().type === Lexer.tokens.line)
+ element = this.parseParagraph();
+ else
+ element = this.parseElement();
+ }
+ break;
+ case Lexer.tokens.horizontalRule:
+ this.lexer.getNextToken();
+ element = Node.createHorizontalRule();
+ break;
+ case Lexer.tokens.directive:
+ element = this.parseDirective();
+ break;
+ case Lexer.tokens.comment:
+ // Skip
+ this.lexer.getNextToken();
+ break;
+ default:
+ throw this.createErrorReport("Unhandled token: " + this.lexer.peekNextToken().type);
+ }
+
+ return element;
+ },
+
+ parseElementBesidesDirectiveEnd: function () {
+ try {
+ // Temporary, override the definition of `parseElement`
+ this.parseElement = this.parseElementBesidesDirectiveEndBody;
+ return this.parseElement();
+ } finally {
+ this.parseElement = this.originalParseElement;
+ }
+ },
+
+ parseElementBesidesDirectiveEndBody: function () {
+ if (this.lexer.peekNextToken().type === Lexer.tokens.directive &&
+ this.lexer.peekNextToken().endDirective) {
+ return null;
+ }
+
+ return this.originalParseElement();
+ },
+
+ // ------------------------------------------------------------
+ //
+ //
+ // : preformatted
+ // : block
+ // ------------------------------------------------------------
+
+ parseHeader: function () {
+ var headerToken = this.lexer.getNextToken();
+ var header = Node.createHeader([
+ this.createTextNode(headerToken.content) // TODO: Parse inline markups
+ ], { level: headerToken.level });
+ this.setNodeOriginFromToken(header, headerToken);
+
+ return header;
+ },
+
+ // ------------------------------------------------------------
+ //
+ //
+ // : preformatted
+ // : block
+ // ------------------------------------------------------------
+
+ parsePreformatted: function () {
+ var preformattedFirstToken = this.lexer.peekNextToken();
+ var preformatted = Node.createPreformatted([]);
+ this.setNodeOriginFromToken(preformatted, preformattedFirstToken);
+
+ var textContents = [];
+
+ while (this.lexer.hasNext()) {
+ var token = this.lexer.peekNextToken();
+ if (token.type !== Lexer.tokens.preformatted ||
+ token.indentation < preformattedFirstToken.indentation)
+ break;
+ this.lexer.getNextToken();
+ textContents.push(token.content);
+ }
+
+ preformatted.appendChild(this.createTextNode(textContents.join("\n"), true /* no emphasis */));
+
+ return preformatted;
+ },
+
+ // ------------------------------------------------------------
+ //
+ //
+ // - foo
+ // 1. bar
+ // 2. baz
+ // ------------------------------------------------------------
+
+ // XXX: not consider codes (e.g., =Foo::Bar=)
+ definitionPattern: /^(.*?) :: *(.*)$/,
+
+ parseList: function () {
+ var rootToken = this.lexer.peekNextToken();
+ var list;
+ var isDefinitionList = false;
+
+ if (this.definitionPattern.test(rootToken.content)) {
+ list = Node.createDefinitionList([]);
+ isDefinitionList = true;
+ } else {
+ list = rootToken.type === Lexer.tokens.unorderedListElement ?
+ Node.createUnorderedList([]) : Node.createOrderedList([]);
+ }
+ this.setNodeOriginFromToken(list, rootToken);
+
+ while (this.lexer.hasNext()) {
+ var nextToken = this.lexer.peekNextToken();
+ if (!nextToken.isListElement() || nextToken.indentation !== rootToken.indentation)
+ break;
+ list.appendChild(this.parseListElement(rootToken.indentation, isDefinitionList));
+ }
+
+ return list;
+ },
+
+ unknownDefinitionTerm: "???",
+
+ parseListElement: function (rootIndentation, isDefinitionList) {
+ var listElementToken = this.lexer.getNextToken();
+ var listElement = Node.createListElement([]);
+ this.setNodeOriginFromToken(listElement, listElementToken);
+
+ listElement.isDefinitionList = isDefinitionList;
+
+ if (isDefinitionList) {
+ var match = this.definitionPattern.exec(listElementToken.content);
+ listElement.term = [
+ this.createTextNode(match && match[1] ? match[1] : this.unknownDefinitionTerm)
+ ];
+ listElement.appendChild(this.createTextNode(match ? match[2] : listElementToken.content));
+ } else {
+ listElement.appendChild(this.createTextNode(listElementToken.content));
+ }
+
+ while (this.lexer.hasNext()) {
+ var blankToken = this.skipBlank();
+ if (!this.lexer.hasNext())
+ break;
+
+ var notBlankNextToken = this.lexer.peekNextToken();
+ if (blankToken && !notBlankNextToken.isListElement())
+ this.lexer.pushToken(blankToken); // Recover blank token only when next line is not listElement.
+ // End of the list if hit less indented line or end of directive
+ if (notBlankNextToken.indentation <= rootIndentation ||
+ (notBlankNextToken.type === Lexer.tokens.directive && notBlankNextToken.endDirective))
+ break;
+
+ var element = this.parseElement(); // recursive
+ if (element)
+ listElement.appendChild(element);
+ }
+
+ return listElement;
+ },
+
+ // ------------------------------------------------------------
+ // ::= +
+ // ------------------------------------------------------------
+
+ parseTable: function () {
+ var nextToken = this.lexer.peekNextToken();
+ var table = Node.createTable([]);
+ this.setNodeOriginFromToken(table, nextToken);
+ var sawSeparator = false;
+
+ var allowMultilineCell = nextToken.type === Lexer.tokens.tableSeparator && this.options.multilineCell;
+
+ while (this.lexer.hasNext() &&
+ (nextToken = this.lexer.peekNextToken()).isTableElement()) {
+ if (nextToken.type === Lexer.tokens.tableRow) {
+ var tableRow = this.parseTableRow(allowMultilineCell);
+ table.appendChild(tableRow);
+ } else {
+ // Lexer.tokens.tableSeparator
+ sawSeparator = true;
+ this.lexer.getNextToken();
+ }
+ }
+
+ if (sawSeparator && table.children.length) {
+ table.children[0].children.forEach(function (cell) {
+ cell.isHeader = true;
+ });
+ }
+
+ return table;
+ },
+
+ // ------------------------------------------------------------
+ // ::= +
+ // ------------------------------------------------------------
+
+ parseTableRow: function (allowMultilineCell) {
+ var tableRowTokens = [];
+
+ while (this.lexer.peekNextToken().type === Lexer.tokens.tableRow) {
+ tableRowTokens.push(this.lexer.getNextToken());
+ if (!allowMultilineCell) {
+ break;
+ }
+ }
+
+ if (!tableRowTokens.length) {
+ throw this.createErrorReport("Expected table row");
+ }
+
+ var firstTableRowToken = tableRowTokens.shift();
+ var tableCellTexts = firstTableRowToken.content.split("|");
+
+ tableRowTokens.forEach(function (rowToken) {
+ rowToken.content.split("|").forEach(function (cellText, cellIdx) {
+ tableCellTexts[cellIdx] = (tableCellTexts[cellIdx] || "") + "\n" + cellText;
+ });
+ });
+
+ // TODO: Prepare two pathes: (1)
+ var tableCells = tableCellTexts.map(
+ // TODO: consider '|' escape?
+ function (text) {
+ return Node.createTableCell(Parser.parseStream(text));
+ }, this);
+
+ return this.setNodeOriginFromToken(Node.createTableRow(tableCells), firstTableRowToken);
+ },
+
+ // ------------------------------------------------------------
+ // ::= "#+.*"
+ // ------------------------------------------------------------
+
+ parseDirective: function () {
+ var directiveToken = this.lexer.getNextToken();
+ var directiveNode = this.createDirectiveNodeFromToken(directiveToken);
+
+ if (directiveToken.endDirective)
+ throw this.createErrorReport("Unmatched 'end' directive for " + directiveNode.directiveName);
+
+ if (directiveToken.oneshotDirective) {
+ this.interpretDirective(directiveNode);
+ return directiveNode;
+ }
+
+ if (!directiveToken.beginDirective)
+ throw this.createErrorReport("Invalid directive " + directiveNode.directiveName);
+
+ // Parse begin ~ end
+ directiveNode.children = [];
+ if (this.isVerbatimDirective(directiveNode))
+ return this.parseDirectiveBlockVerbatim(directiveNode);
+ else
+ return this.parseDirectiveBlock(directiveNode);
+ },
+
+ createDirectiveNodeFromToken: function (directiveToken) {
+ var matched = /^[ ]*([^ ]*)[ ]*(.*)[ ]*$/.exec(directiveToken.content);
+
+ var directiveNode = Node.createDirective(null);
+ this.setNodeOriginFromToken(directiveNode, directiveToken);
+ directiveNode.directiveName = matched[1].toLowerCase();
+ directiveNode.directiveArguments = this.parseDirectiveArguments(matched[2]);
+ directiveNode.directiveOptions = this.parseDirectiveOptions(matched[2]);
+ directiveNode.directiveRawValue = matched[2];
+
+ return directiveNode;
+ },
+
+ isVerbatimDirective: function (directiveNode) {
+ var directiveName = directiveNode.directiveName;
+ return directiveName === "src" || directiveName === "example" || directiveName === "html";
+ },
+
+ parseDirectiveBlock: function (directiveNode, verbatim) {
+ this.lexer.pushDummyTokenByType(Lexer.tokens.blank);
+
+ while (this.lexer.hasNext()) {
+ var nextToken = this.lexer.peekNextToken();
+ if (nextToken.type === Lexer.tokens.directive &&
+ nextToken.endDirective &&
+ this.createDirectiveNodeFromToken(nextToken).directiveName === directiveNode.directiveName) {
+ // Close directive
+ this.lexer.getNextToken();
+ return directiveNode;
+ }
+ var element = this.parseElementBesidesDirectiveEnd();
+ if (element)
+ directiveNode.appendChild(element);
+ }
+
+ throw this.createErrorReport("Unclosed directive " + directiveNode.directiveName);
+ },
+
+ parseDirectiveBlockVerbatim: function (directiveNode) {
+ var textContent = [];
+
+ while (this.lexer.hasNext()) {
+ var nextToken = this.lexer.peekNextToken();
+ if (nextToken.type === Lexer.tokens.directive &&
+ nextToken.endDirective &&
+ this.createDirectiveNodeFromToken(nextToken).directiveName === directiveNode.directiveName) {
+ this.lexer.getNextToken();
+ directiveNode.appendChild(this.createTextNode(textContent.join("\n"), true));
+ return directiveNode;
+ }
+ textContent.push(this.lexer.stream.getNextLine());
+ }
+
+ throw this.createErrorReport("Unclosed directive " + directiveNode.directiveName);
+ },
+
+ parseDirectiveArguments: function (parameters) {
+ return parameters.split(/[ ]+/).filter(function (param) {
+ return param.length && param[0] !== "-";
+ });
+ },
+
+ parseDirectiveOptions: function (parameters) {
+ return parameters.split(/[ ]+/).filter(function (param) {
+ return param.length && param[0] === "-";
+ });
+ },
+
+ interpretDirective: function (directiveNode) {
+ // http://orgmode.org/manual/Export-options.html
+ switch (directiveNode.directiveName) {
+ case "options:":
+ this.interpretOptionDirective(directiveNode);
+ break;
+ case "title:":
+ this.document.title = directiveNode.directiveRawValue;
+ break;
+ case "author:":
+ this.document.author = directiveNode.directiveRawValue;
+ break;
+ case "email:":
+ this.document.email = directiveNode.directiveRawValue;
+ break;
+ default:
+ this.document.directiveValues[directiveNode.directiveName] = directiveNode.directiveRawValue;
+ break;
+ }
+ },
+
+ interpretOptionDirective: function (optionDirectiveNode) {
+ optionDirectiveNode.directiveArguments.forEach(function (pairString) {
+ var pair = pairString.split(":");
+ this.options[pair[0]] = this.convertLispyValue(pair[1]);
+ }, this);
+ },
+
+ convertLispyValue: function (lispyValue) {
+ switch (lispyValue) {
+ case "t":
+ return true;
+ case "nil":
+ return false;
+ default:
+ if (/^[0-9]+$/.test(lispyValue))
+ return parseInt(lispyValue);
+ return lispyValue;
+ }
+ },
+
+ // ------------------------------------------------------------
+ // ::= *
+ // ------------------------------------------------------------
+
+ parseParagraph: function () {
+ var paragraphFisrtToken = this.lexer.peekNextToken();
+ var paragraph = Node.createParagraph([]);
+ this.setNodeOriginFromToken(paragraph, paragraphFisrtToken);
+
+ var textContents = [];
+
+ while (this.lexer.hasNext()) {
+ var nextToken = this.lexer.peekNextToken();
+ if (nextToken.type !== Lexer.tokens.line
+ || nextToken.indentation < paragraphFisrtToken.indentation)
+ break;
+ this.lexer.getNextToken();
+ textContents.push(nextToken.content);
+ }
+
+ paragraph.appendChild(this.createTextNode(textContents.join("\n")));
+
+ return paragraph;
+ },
+
+ parseText: function (noEmphasis) {
+ var lineToken = this.lexer.getNextToken();
+ return this.createTextNode(lineToken.content, noEmphasis);
+ },
+
+ // ------------------------------------------------------------
+ // (DOM Like)
+ // ------------------------------------------------------------
+
+ createTextNode: function (text, noEmphasis) {
+ return noEmphasis ? Node.createText(null, { value: text })
+ : this.inlineParser.parseEmphasis(text);
+ }
+ };
+ Parser.prototype.originalParseElement = Parser.prototype.parseElement;
+
+ // ------------------------------------------------------------
+ // Parser for Inline Elements
+ //
+ // @refs org-emphasis-regexp-components
+ // ------------------------------------------------------------
+
+ function InlineParser() {
+ this.preEmphasis = " \t\\('\"";
+ this.postEmphasis = "- \t.,:!?;'\"\\)";
+ this.borderForbidden = " \t\r\n,\"'";
+ this.bodyRegexp = "[\\s\\S]*?";
+ this.markers = "*/_=~+";
+
+ this.emphasisPattern = this.buildEmphasisPattern();
+ this.linkPattern = /\[\[([^\]]*)\](?:\[([^\]]*)\])?\]/g; // \1 => link, \2 => text
+ }
+
+ InlineParser.prototype = {
+ parseEmphasis: function (text) {
+ var emphasisPattern = this.emphasisPattern;
+ emphasisPattern.lastIndex = 0;
+
+ var result = [],
+ match,
+ previousLast = 0,
+ savedLastIndex;
+
+ while ((match = emphasisPattern.exec(text))) {
+ var whole = match[0];
+ var pre = match[1];
+ var marker = match[2];
+ var body = match[3];
+ var post = match[4];
+
+ {
+ // parse links
+ var matchBegin = emphasisPattern.lastIndex - whole.length;
+ var beforeContent = text.substring(previousLast, matchBegin + pre.length);
+ savedLastIndex = emphasisPattern.lastIndex;
+ result.push(this.parseLink(beforeContent));
+ emphasisPattern.lastIndex = savedLastIndex;
+ }
+
+ var bodyNode = [Node.createText(null, { value: body })];
+ var bodyContainer = this.emphasizeElementByMarker(bodyNode, marker);
+ result.push(bodyContainer);
+
+ previousLast = emphasisPattern.lastIndex - post.length;
+ }
+
+ if (emphasisPattern.lastIndex === 0 ||
+ emphasisPattern.lastIndex !== text.length - 1)
+ result.push(this.parseLink(text.substring(previousLast)));
+
+ if (result.length === 1) {
+ // Avoid duplicated inline container wrapping
+ return result[0];
+ } else {
+ return Node.createInlineContainer(result);
+ }
+ },
+
+ depth: 0,
+ parseLink: function (text) {
+ var linkPattern = this.linkPattern;
+ linkPattern.lastIndex = 0;
+
+ var match,
+ result = [],
+ previousLast = 0,
+ savedLastIndex;
+
+ while ((match = linkPattern.exec(text))) {
+ var whole = match[0];
+ var src = match[1];
+ var title = match[2];
+
+ // parse before content
+ var matchBegin = linkPattern.lastIndex - whole.length;
+ var beforeContent = text.substring(previousLast, matchBegin);
+ result.push(Node.createText(null, { value: beforeContent }));
+
+ // parse link
+ var link = Node.createLink([]);
+ link.src = src;
+ if (title) {
+ savedLastIndex = linkPattern.lastIndex;
+ link.appendChild(this.parseEmphasis(title));
+ linkPattern.lastIndex = savedLastIndex;
+ } else {
+ link.appendChild(Node.createText(null, { value: src }));
+ }
+ result.push(link);
+
+ previousLast = linkPattern.lastIndex;
+ }
+
+ if (linkPattern.lastIndex === 0 ||
+ linkPattern.lastIndex !== text.length - 1)
+ result.push(Node.createText(null, { value: text.substring(previousLast) }));
+
+ return Node.createInlineContainer(result);
+ },
+
+ emphasizeElementByMarker: function (element, marker) {
+ switch (marker) {
+ case "*":
+ return Node.createBold(element);
+ case "/":
+ return Node.createItalic(element);
+ case "_":
+ return Node.createUnderline(element);
+ case "=":
+ case "~":
+ return Node.createCode(element);
+ case "+":
+ return Node.createDashed(element);
+ }
+ },
+
+ buildEmphasisPattern: function () {
+ return new RegExp(
+ "([" + this.preEmphasis + "]|^|\r?\n)" + // \1 => pre
+ "([" + this.markers + "])" + // \2 => marker
+ "([^" + this.borderForbidden + "]|" + // \3 => body
+ "[^" + this.borderForbidden + "]" +
+ this.bodyRegexp +
+ "[^" + this.borderForbidden + "])" +
+ "\\2" +
+ "([" + this.postEmphasis +"]|$|\r?\n)", // \4 => post
+ // flags
+ "g"
+ );
+ }
+ };
+
+ if (typeof exports !== "undefined") {
+ exports.Parser = Parser;
+ exports.InlineParser = InlineParser;
+ }
+
+ // var Node = require("../node.js").Node;
+
+ function Converter() {
+ }
+
+ Converter.prototype = {
+ exportOptions: {
+ headerOffset: 1,
+ exportFromLineNumber: false,
+ suppressSubScriptHandling: false,
+ suppressAutoLink: false,
+ // HTML
+ translateSymbolArrow: false,
+ suppressCheckboxHandling: false,
+ // { "directive:": function (node, childText, auxData) {} }
+ customDirectiveHandler: null,
+ // e.g., "org-js-"
+ htmlClassPrefix: null,
+ htmlIdPrefix: null
+ },
+
+ untitled: "Untitled",
+ result: null,
+
+ // TODO: Manage TODO lists
+
+ initialize: function (orgDocument, exportOptions) {
+ this.orgDocument = orgDocument;
+ this.documentOptions = orgDocument.options || {};
+ this.exportOptions = exportOptions || {};
+
+ this.headers = [];
+ this.headerOffset =
+ typeof this.exportOptions.headerOffset === "number" ? this.exportOptions.headerOffset : 1;
+ this.sectionNumbers = [0];
+ },
+
+ createTocItem: function (headerNode, parentTocs) {
+ var childTocs = [];
+ childTocs.parent = parentTocs;
+ var tocItem = { headerNode: headerNode, childTocs: childTocs };
+ return tocItem;
+ },
+
+ computeToc: function (exportTocLevel) {
+ if (typeof exportTocLevel !== "number")
+ exportTocLevel = Infinity;
+
+ var toc = [];
+ toc.parent = null;
+
+ var previousLevel = 1;
+ var currentTocs = toc; // first
+
+ for (var i = 0; i < this.headers.length; ++i) {
+ var headerNode = this.headers[i];
+
+ if (headerNode.level > exportTocLevel)
+ continue;
+
+ var levelDiff = headerNode.level - previousLevel;
+ if (levelDiff > 0) {
+ for (var j = 0; j < levelDiff; ++j) {
+ if (currentTocs.length === 0) {
+ // Create a dummy tocItem
+ var dummyHeader = Node.createHeader([], {
+ level: previousLevel + j
+ });
+ dummyHeader.sectionNumberText = "";
+ currentTocs.push(this.createTocItem(dummyHeader, currentTocs));
+ }
+ currentTocs = currentTocs[currentTocs.length - 1].childTocs;
+ }
+ } else if (levelDiff < 0) {
+ levelDiff = -levelDiff;
+ for (var k = 0; k < levelDiff; ++k) {
+ currentTocs = currentTocs.parent;
+ }
+ }
+
+ currentTocs.push(this.createTocItem(headerNode, currentTocs));
+
+ previousLevel = headerNode.level;
+ }
+
+ return toc;
+ },
+
+ convertNode: function (node, recordHeader, insideCodeElement) {
+ if (!insideCodeElement) {
+ if (node.type === Node.types.directive) {
+ if (node.directiveName === "example" ||
+ node.directiveName === "src") {
+ insideCodeElement = true;
+ }
+ } else if (node.type === Node.types.preformatted) {
+ insideCodeElement = true;
+ }
+ }
+
+ if (typeof node === "string") {
+ node = Node.createText(null, { value: node });
+ }
+
+ var childText = node.children ? this.convertNodesInternal(node.children, recordHeader, insideCodeElement) : "";
+ var text;
+
+ var auxData = this.computeAuxDataForNode(node);
+
+ switch (node.type) {
+ case Node.types.header:
+ // Compute section number
+ var sectionNumberText = null;
+ if (recordHeader) {
+ var thisHeaderLevel = node.level;
+ var previousHeaderLevel = this.sectionNumbers.length;
+ if (thisHeaderLevel > previousHeaderLevel) {
+ // Fill missing section number
+ var levelDiff = thisHeaderLevel - previousHeaderLevel;
+ for (var j = 0; j < levelDiff; ++j) {
+ this.sectionNumbers[thisHeaderLevel - 1 - j] = 0; // Extend
+ }
+ } else if (thisHeaderLevel < previousHeaderLevel) {
+ this.sectionNumbers.length = thisHeaderLevel; // Collapse
+ }
+ this.sectionNumbers[thisHeaderLevel - 1]++;
+ sectionNumberText = this.sectionNumbers.join(".");
+ node.sectionNumberText = sectionNumberText; // Can be used in ToC
+ }
+
+ text = this.convertHeader(node, childText, auxData, sectionNumberText);
+
+ if (recordHeader)
+ this.headers.push(node);
+ break;
+ case Node.types.orderedList:
+ text = this.convertOrderedList(node, childText, auxData);
+ break;
+ case Node.types.unorderedList:
+ text = this.convertUnorderedList(node, childText, auxData);
+ break;
+ case Node.types.definitionList:
+ text = this.convertDefinitionList(node, childText, auxData);
+ break;
+ case Node.types.listElement:
+ if (node.isDefinitionList) {
+ var termText = this.convertNodesInternal(node.term, recordHeader, insideCodeElement);
+ text = this.convertDefinitionItem(node, childText, auxData,
+ termText, childText);
+ } else {
+ text = this.convertListItem(node, childText, auxData);
+ }
+ break;
+ case Node.types.paragraph:
+ text = this.convertParagraph(node, childText, auxData);
+ break;
+ case Node.types.preformatted:
+ text = this.convertPreformatted(node, childText, auxData);
+ break;
+ case Node.types.table:
+ text = this.convertTable(node, childText, auxData);
+ break;
+ case Node.types.tableRow:
+ text = this.convertTableRow(node, childText, auxData);
+ break;
+ case Node.types.tableCell:
+ if (node.isHeader)
+ text = this.convertTableHeader(node, childText, auxData);
+ else
+ text = this.convertTableCell(node, childText, auxData);
+ break;
+ case Node.types.horizontalRule:
+ text = this.convertHorizontalRule(node, childText, auxData);
+ break;
+ // ============================================================ //
+ // Inline
+ // ============================================================ //
+ case Node.types.inlineContainer:
+ text = this.convertInlineContainer(node, childText, auxData);
+ break;
+ case Node.types.bold:
+ text = this.convertBold(node, childText, auxData);
+ break;
+ case Node.types.italic:
+ text = this.convertItalic(node, childText, auxData);
+ break;
+ case Node.types.underline:
+ text = this.convertUnderline(node, childText, auxData);
+ break;
+ case Node.types.code:
+ text = this.convertCode(node, childText, auxData);
+ break;
+ case Node.types.dashed:
+ text = this.convertDashed(node, childText, auxData);
+ break;
+ case Node.types.link:
+ text = this.convertLink(node, childText, auxData);
+ break;
+ case Node.types.directive:
+ switch (node.directiveName) {
+ case "quote":
+ text = this.convertQuote(node, childText, auxData);
+ break;
+ case "example":
+ text = this.convertExample(node, childText, auxData);
+ break;
+ case "src":
+ text = this.convertSrc(node, childText, auxData);
+ break;
+ case "html":
+ case "html:":
+ text = this.convertHTML(node, childText, auxData);
+ break;
+ default:
+ if (this.exportOptions.customDirectiveHandler &&
+ this.exportOptions.customDirectiveHandler[node.directiveName]) {
+ text = this.exportOptions.customDirectiveHandler[node.directiveName](
+ node, childText, auxData
+ );
+ } else {
+ text = childText;
+ }
+ }
+ break;
+ case Node.types.text:
+ text = this.convertText(node.value, insideCodeElement);
+ break;
+ default:
+ throw Error("Unknown node type: " + node.type);
+ }
+
+ if (typeof this.postProcess === "function") {
+ text = this.postProcess(node, text, insideCodeElement);
+ }
+
+ return text;
+ },
+
+ convertText: function (text, insideCodeElement) {
+ var escapedText = this.escapeSpecialChars(text, insideCodeElement);
+
+ if (!this.exportOptions.suppressSubScriptHandling && !insideCodeElement) {
+ escapedText = this.makeSubscripts(escapedText, insideCodeElement);
+ }
+ if (!this.exportOptions.suppressAutoLink) {
+ escapedText = this.linkURL(escapedText);
+ }
+
+ return escapedText;
+ },
+
+ // By default, ignore html
+ convertHTML: function (node, childText, auxData) {
+ return childText;
+ },
+
+ convertNodesInternal: function (nodes, recordHeader, insideCodeElement) {
+ var nodesTexts = [];
+ for (var i = 0; i < nodes.length; ++i) {
+ var node = nodes[i];
+ var nodeText = this.convertNode(node, recordHeader, insideCodeElement);
+ nodesTexts.push(nodeText);
+ }
+
+ // Return entries without their property drawers
+ return this.combineNodesTexts(nodesTexts).replace(propertyDrawer, '');
+ },
+
+ convertHeaderBlock: function (headerBlock, recordHeader) {
+ throw Error("convertHeaderBlock is not implemented");
+ },
+
+ convertHeaderTree: function (headerTree, recordHeader) {
+ return this.convertHeaderBlock(headerTree, recordHeader);
+ },
+
+ convertNodesToHeaderTree: function (nodes, nextBlockBegin, blockHeader) {
+ var childBlocks = [];
+ var childNodes = [];
+
+ if (typeof nextBlockBegin === "undefined") {
+ nextBlockBegin = 0;
+ }
+ if (typeof blockHeader === "undefined") {
+ blockHeader = null;
+ }
+
+ for (var i = nextBlockBegin; i < nodes.length;) {
+ var node = nodes[i];
+
+ var isHeader = node.type === Node.types.header;
+
+ if (!isHeader) {
+ childNodes.push(node);
+ i = i + 1;
+ continue;
+ }
+
+ // Header
+ if (blockHeader && node.level <= blockHeader.level) {
+ // Finish Block
+ break;
+ } else {
+ // blockHeader.level < node.level
+ // Begin child block
+ var childBlock = this.convertNodesToHeaderTree(nodes, i + 1, node);
+ childBlocks.push(childBlock);
+ i = childBlock.nextIndex;
+ }
+ }
+
+ // Finish block
+ return {
+ header: blockHeader,
+ childNodes: childNodes,
+ nextIndex: i,
+ childBlocks: childBlocks
+ };
+ },
+
+ convertNodes: function (nodes, recordHeader, insideCodeElement) {
+ return this.convertNodesInternal(nodes, recordHeader, insideCodeElement);
+ },
+
+ combineNodesTexts: function (nodesTexts) {
+ return nodesTexts.join("");
+ },
+
+ getNodeTextContent: function (node) {
+ if (node.type === Node.types.text)
+ return this.escapeSpecialChars(node.value);
+ else
+ return node.children ? node.children.map(this.getNodeTextContent, this).join("") : "";
+ },
+
+ // @Override
+ escapeSpecialChars: function (text) {
+ throw Error("Implement escapeSpecialChars");
+ },
+
+ // http://daringfireball.net/2010/07/improved_regex_for_matching_urls
+ urlPattern: /\b(?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])/ig,
+
+ // @Override
+ linkURL: function (text) {
+ var self = this;
+ return text.replace(this.urlPattern, function (matched) {
+ if (matched.indexOf("://") < 0)
+ matched = "http://" + matched;
+ return self.makeLink(matched);
+ });
+ },
+
+ makeLink: function (url) {
+ throw Error("Implement makeLink");
+ },
+
+ makeSubscripts: function (text) {
+ if (this.documentOptions["^"] === "{}")
+ return text.replace(/\b([^_ \t]*)_{([^}]*)}/g,
+ this.makeSubscript);
+ else if (this.documentOptions["^"])
+ return text.replace(/\b([^_ \t]*)_([^_]*)\b/g,
+ this.makeSubscript);
+ else
+ return text;
+ },
+
+ makeSubscript: function (match, body, subscript) {
+ throw Error("Implement makeSubscript");
+ },
+
+ stripParametersFromURL: function (url) {
+ return url.replace(/\?.*$/, "");
+ },
+
+ imageExtensionPattern: new RegExp("(" + [
+ "bmp", "png", "jpeg", "jpg", "gif", "tiff",
+ "tif", "xbm", "xpm", "pbm", "pgm", "ppm", "svg"
+ ].join("|") + ")$", "i")
+ };
+
+ if (typeof exports !== "undefined")
+ exports.Converter = Converter;
+
+ // var Converter = require("./converter.js").Converter;
+ // var Node = require("../node.js").Node;
+
+ function ConverterHTML(orgDocument, exportOptions) {
+ this.initialize(orgDocument, exportOptions);
+ this.result = this.convert();
+ }
+
+ ConverterHTML.prototype = {
+ __proto__: Converter.prototype,
+
+ convert: function () {
+ var contentHTML = this.convertNodes(this.orgDocument.nodes, false /* record headers */);
+
+ return {
+ contentHTML: contentHTML,
+ toString: function () {
+ return contentHTML;
+ }
+ };
+ },
+
+ tocToHTML: function (toc) {
+ function tocToHTMLFunction(tocList) {
+ var html = "";
+ for (var i = 0; i < tocList.length; ++i) {
+ var tocItem = tocList[i];
+ var sectionNumberText = tocItem.headerNode.sectionNumberText;
+ var sectionNumber = this.documentOptions.num ?
+ this.inlineTag("span", sectionNumberText, {
+ "class": "section-number"
+ }) : "";
+ var header = this.getNodeTextContent(tocItem.headerNode);
+ var headerLink = this.inlineTag("a", sectionNumber + header, {
+ href: "#header-" + sectionNumberText.replace(/\./g, "-")
+ });
+ var subList = tocItem.childTocs.length ? tocToHTMLFunction.call(this, tocItem.childTocs) : "";
+ html += this.tag("li", headerLink + subList);
+ }
+ return this.tag("ul", html);
+ }
+
+ return tocToHTMLFunction.call(this, toc);
+ },
+
+ computeAuxDataForNode: function (node) {
+ while (node.parent &&
+ node.parent.type === Node.types.inlineContainer) {
+ node = node.parent;
+ }
+ var attributesNode = node.previousSibling;
+ var attributesText = "";
+ while (attributesNode &&
+ attributesNode.type === Node.types.directive &&
+ attributesNode.directiveName === "attr_html:") {
+ attributesText += attributesNode.directiveRawValue + " ";
+ attributesNode = attributesNode.previousSibling;
+ }
+ return attributesText;
+ },
+
+ // Method to construct org-js generated class
+ orgClassName: function (className) {
+ return this.exportOptions.htmlClassPrefix ?
+ this.exportOptions.htmlClassPrefix + className
+ : className;
+ },
+
+ // Method to construct org-js generated id
+ orgId: function (id) {
+ return this.exportOptions.htmlIdPrefix ?
+ this.exportOptions.htmlIdPrefix + id
+ : id;
+ },
+
+ // ----------------------------------------------------
+ // Node conversion
+ // ----------------------------------------------------
+
+ convertHeader: function (node, childText, auxData, sectionNumberText) {
+ var headerAttributes = {};
+
+ // Parse task status
+ taskStatusRegex = /^\s*([A-Z]+) /
+ taskStatusMatch = childText.match(taskStatusRegex);
+ taskStatus = taskStatusMatch && taskStatusMatch[1];
+ childText = childText.replace(taskStatusRegex, "");
+
+ if (taskStatus) {
+ childText = this.inlineTag("span", taskStatus, {
+ "class": "task-status " + taskStatus
+ }) + childText;
+ }
+
+ // Parse task tags
+ taskTagsRegex = /:([\w:]+):/g
+ taskTagsMatch = childText.match(taskTagsRegex);
+ taskTags = taskTagsMatch && taskTagsMatch[0].split(":").slice(1,-1);
+ childText = childText.replace(taskTagsRegex, "");
+
+ if (taskTags) {
+ taskTags.forEach(tag => {
+ childText += this.inlineTag("span", tag, { "class": "task-tag" })
+ });
+ }
+
+ if (sectionNumberText) {
+ childText = this.inlineTag("span", sectionNumberText, {
+ "class": "section-number"
+ }) + childText;
+ headerAttributes["id"] = "header-" + sectionNumberText.replace(/\./g, "-");
+ }
+
+ if (taskStatus)
+ headerAttributes["class"] = "task-status " + taskStatus;
+
+ return this.tag("h" + (this.headerOffset + node.level),
+ childText, headerAttributes, auxData);
+ },
+
+ convertOrderedList: function (node, childText, auxData) {
+ return this.tag("ol", childText, null, auxData);
+ },
+
+ convertUnorderedList: function (node, childText, auxData) {
+ return this.tag("ul", childText, null, auxData);
+ },
+
+ convertDefinitionList: function (node, childText, auxData) {
+ return this.tag("dl", childText, null, auxData);
+ },
+
+ convertDefinitionItem: function (node, childText, auxData,
+ term, definition) {
+ return this.tag("dt", term) + this.tag("dd", definition);
+ },
+
+ convertListItem: function (node, childText, auxData) {
+ if (this.exportOptions.suppressCheckboxHandling) {
+ return this.tag("li", childText, null, auxData);
+ } else {
+ var listItemAttributes = {};
+ var listItemText = childText;
+ // Embed checkbox
+ if (/^\s*\[(X| |-)\]([\s\S]*)/.exec(listItemText)) {
+ listItemText = RegExp.$2 ;
+ var checkboxIndicator = RegExp.$1;
+
+ var checkboxAttributes = { type: "checkbox" };
+ switch (checkboxIndicator) {
+ case "X":
+ checkboxAttributes["checked"] = "true";
+ listItemAttributes["data-checkbox-status"] = "done";
+ break;
+ case "-":
+ listItemAttributes["data-checkbox-status"] = "intermediate";
+ break;
+ default:
+ listItemAttributes["data-checkbox-status"] = "undone";
+ break;
+ }
+
+ listItemText = this.inlineTag("input", null, checkboxAttributes) + listItemText;
+ }
+
+ return this.tag("li", listItemText, listItemAttributes, auxData);
+ }
+ },
+
+ convertParagraph: function (node, childText, auxData) {
+ return this.tag("p", childText, null, auxData);
+ },
+
+ convertPreformatted: function (node, childText, auxData) {
+ return this.tag("pre", childText, null, auxData);
+ },
+
+ convertTable: function (node, childText, auxData) {
+ return this.tag("table", this.tag("tbody", childText), null, auxData);
+ },
+
+ convertTableRow: function (node, childText, auxData) {
+ return this.tag("tr", childText);
+ },
+
+ convertTableHeader: function (node, childText, auxData) {
+ return this.tag("th", childText);
+ },
+
+ convertTableCell: function (node, childText, auxData) {
+ return this.tag("td", childText);
+ },
+
+ convertHorizontalRule: function (node, childText, auxData) {
+ return this.tag("hr", null, null, auxData);
+ },
+
+ convertInlineContainer: function (node, childText, auxData) {
+ return childText;
+ },
+
+ convertBold: function (node, childText, auxData) {
+ return this.inlineTag("b", childText);
+ },
+
+ convertItalic: function (node, childText, auxData) {
+ return this.inlineTag("i", childText);
+ },
+
+ convertUnderline: function (node, childText, auxData) {
+ return this.inlineTag("span", childText, {
+ style: "text-decoration:underline;"
+ });
+ },
+
+ convertCode: function (node, childText, auxData) {
+ return this.inlineTag("code", childText);
+ },
+
+ convertDashed: function (node, childText, auxData) {
+ return this.inlineTag("del", childText);
+ },
+
+ convertLink: function (node, childText, auxData) {
+ var srcParameterStripped = this.stripParametersFromURL(node.src);
+ if (this.imageExtensionPattern.exec(srcParameterStripped)) {
+ var imgText = this.getNodeTextContent(node);
+ return this.inlineTag("img", null, {
+ src: node.src,
+ alt: imgText,
+ title: imgText
+ }, auxData);
+ } else {
+ return this.inlineTag("a", childText, { href: node.src });
+ }
+ },
+
+ convertQuote: function (node, childText, auxData) {
+ return this.tag("blockquote", childText, null, auxData);
+ },
+
+ convertExample: function (node, childText, auxData) {
+ return this.tag("pre", childText, null, auxData);
+ },
+
+ convertSrc: function (node, childText, auxData) {
+ var codeLanguage = node.directiveArguments.length
+ ? node.directiveArguments[0]
+ : "unknown";
+ childText = this.tag("code", childText, {
+ "class": "language-" + codeLanguage
+ }, auxData);
+ return this.tag("pre", childText, {
+ "class": "prettyprint"
+ });
+ },
+
+ // @override
+ convertHTML: function (node, childText, auxData) {
+ if (node.directiveName === "html:") {
+ return node.directiveRawValue;
+ } else if (node.directiveName === "html") {
+ return node.children.map(function (textNode) {
+ return textNode.value;
+ }).join("\n");
+ } else {
+ return childText;
+ }
+ },
+
+ // @implement
+ convertHeaderBlock: function (headerBlock, level, index) {
+ level = level || 0;
+ index = index || 0;
+
+ var contents = [];
+
+ var headerNode = headerBlock.header;
+ if (headerNode) {
+ contents.push(this.convertNode(headerNode));
+ }
+
+ var blockContent = this.convertNodes(headerBlock.childNodes);
+ contents.push(blockContent);
+
+ var childBlockContent = headerBlock.childBlocks
+ .map(function (block, idx) {
+ return this.convertHeaderBlock(block, level + 1, idx);
+ }, this)
+ .join("\n");
+ contents.push(childBlockContent);
+
+ var contentsText = contents.join("\n");
+
+ if (headerNode) {
+ return this.tag("section", "\n" + contents.join("\n"), {
+ "class": "block block-level-" + level
+ });
+ } else {
+ return contentsText;
+ }
+ },
+
+ // ----------------------------------------------------
+ // Supplemental methods
+ // ----------------------------------------------------
+
+ replaceMap: {
+ // [replacing pattern, predicate]
+ "&": ["&", null],
+ "<": ["<", null],
+ ">": [">", null],
+ '"': [""", null],
+ "'": ["'", null],
+ "->": ["➔", function (text, insideCodeElement) {
+ return this.exportOptions.translateSymbolArrow && !insideCodeElement;
+ }]
+ },
+
+ replaceRegexp: null,
+
+ // @implement @override
+ escapeSpecialChars: function (text, insideCodeElement) {
+ if (!this.replaceRegexp) {
+ this.replaceRegexp = new RegExp(Object.keys(this.replaceMap).join("|"), "g");
+ }
+
+ var replaceMap = this.replaceMap;
+ var self = this;
+ return text.replace(this.replaceRegexp, function (matched) {
+ if (!replaceMap[matched]) {
+ throw Error("escapeSpecialChars: Invalid match");
+ }
+
+ var predicate = replaceMap[matched][1];
+ if (typeof predicate === "function" &&
+ !predicate.call(self, text, insideCodeElement)) {
+ // Not fullfill the predicate
+ return matched;
+ }
+
+ return replaceMap[matched][0];
+ });
+ },
+
+ // @implement
+ postProcess: function (node, currentText, insideCodeElement) {
+ if (this.exportOptions.exportFromLineNumber &&
+ typeof node.fromLineNumber === "number") {
+ // Wrap with line number information
+ currentText = this.inlineTag("div", currentText, {
+ "data-line-number": node.fromLineNumber
+ });
+ }
+ return currentText;
+ },
+
+ // @implement
+ makeLink: function (url) {
+ return "" + decodeURIComponent(url) + "";
+ },
+
+ // @implement
+ makeSubscript: function (match, body, subscript) {
+ return "" +
+ body +
+ "" +
+ subscript +
+ "";
+ },
+
+ // ----------------------------------------------------
+ // Specific methods
+ // ----------------------------------------------------
+
+ attributesObjectToString: function (attributesObject) {
+ var attributesString = "";
+ for (var attributeName in attributesObject) {
+ if (attributesObject.hasOwnProperty(attributeName)) {
+ var attributeValue = attributesObject[attributeName];
+ // To avoid id/class name conflicts with other frameworks,
+ // users can add arbitrary prefix to org-js generated
+ // ids/classes via exportOptions.
+ if (attributeName === "class") {
+ attributeValue = this.orgClassName(attributeValue);
+ } else if (attributeName === "id") {
+ attributeValue = this.orgId(attributeValue);
+ }
+ attributesString += " " + attributeName + "=\"" + attributeValue + "\"";
+ }
+ }
+ return attributesString;
+ },
+
+ inlineTag: function (name, innerText, attributesObject, auxAttributesText) {
+ attributesObject = attributesObject || {};
+
+ var htmlString = "<" + name;
+ // TODO: check duplicated attributes
+ if (auxAttributesText)
+ htmlString += " " + auxAttributesText;
+ htmlString += this.attributesObjectToString(attributesObject);
+
+ if (innerText === null)
+ return htmlString + "/>";
+
+ htmlString += ">" + innerText + "" + name + ">";
+
+ return htmlString;
+ },
+
+ tag: function (name, innerText, attributesObject, auxAttributesText) {
+ return this.inlineTag(name, innerText, attributesObject, auxAttributesText) + "\n";
+ }
+ };
+
+ if (typeof exports !== "undefined")
+ exports.ConverterHTML = ConverterHTML;
+
+ return exports;
+})();
diff --git a/src/interface/desktop/assets/pico.min.css b/src/interface/desktop/assets/pico.min.css
new file mode 100644
index 0000000000000000000000000000000000000000..1fe468ce15a43a5d8c4e3d3a5203503bbb4594a4
--- /dev/null
+++ b/src/interface/desktop/assets/pico.min.css
@@ -0,0 +1,5 @@
+@charset "UTF-8";/*!
+ * Pico CSS v1.5.10 (https://picocss.com)
+ * Copyright 2019-2023 - Licensed under MIT
+ */:root{--line-height:1.5;--font-weight:400;--font-size:16px;--border-radius:0.25rem;--border-width:1px;--outline-width:3px;--spacing:1rem;--typography-spacing-vertical:1.5rem;--block-spacing-vertical:calc(var(--spacing) * 2);--block-spacing-horizontal:var(--spacing);--grid-spacing-vertical:0;--grid-spacing-horizontal:var(--spacing);--form-element-spacing-vertical:0.75rem;--form-element-spacing-horizontal:1rem;--nav-element-spacing-vertical:1rem;--nav-element-spacing-horizontal:0.5rem;--nav-link-spacing-vertical:0.5rem;--nav-link-spacing-horizontal:0.5rem;--form-label-font-weight:var(--font-weight);--transition:0.2s ease-in-out;--modal-overlay-backdrop-filter:blur(0.25rem)}@media (min-width:576px){:root{--font-size:17px}}@media (min-width:768px){:root{--font-size:18px}}@media (min-width:992px){:root{--font-size:19px}}@media (min-width:1200px){:root{--font-size:20px}}@media (min-width:576px){body>footer,body>header,body>main,section{--block-spacing-vertical:calc(var(--spacing) * 2.5)}}@media (min-width:768px){body>footer,body>header,body>main,section{--block-spacing-vertical:calc(var(--spacing) * 3)}}@media (min-width:992px){body>footer,body>header,body>main,section{--block-spacing-vertical:calc(var(--spacing) * 3.5)}}@media (min-width:1200px){body>footer,body>header,body>main,section{--block-spacing-vertical:calc(var(--spacing) * 4)}}@media (min-width:576px){article{--block-spacing-horizontal:calc(var(--spacing) * 1.25)}}@media (min-width:768px){article{--block-spacing-horizontal:calc(var(--spacing) * 1.5)}}@media (min-width:992px){article{--block-spacing-horizontal:calc(var(--spacing) * 1.75)}}@media (min-width:1200px){article{--block-spacing-horizontal:calc(var(--spacing) * 2)}}dialog>article{--block-spacing-vertical:calc(var(--spacing) * 2);--block-spacing-horizontal:var(--spacing)}@media (min-width:576px){dialog>article{--block-spacing-vertical:calc(var(--spacing) * 2.5);--block-spacing-horizontal:calc(var(--spacing) * 1.25)}}@media (min-width:768px){dialog>article{--block-spacing-vertical:calc(var(--spacing) * 3);--block-spacing-horizontal:calc(var(--spacing) * 1.5)}}a{--text-decoration:none}a.contrast,a.secondary{--text-decoration:underline}small{--font-size:0.875em}h1,h2,h3,h4,h5,h6{--font-weight:700}h1{--font-size:2rem;--typography-spacing-vertical:3rem}h2{--font-size:1.75rem;--typography-spacing-vertical:2.625rem}h3{--font-size:1.5rem;--typography-spacing-vertical:2.25rem}h4{--font-size:1.25rem;--typography-spacing-vertical:1.874rem}h5{--font-size:1.125rem;--typography-spacing-vertical:1.6875rem}[type=checkbox],[type=radio]{--border-width:2px}[type=checkbox][role=switch]{--border-width:3px}tfoot td,tfoot th,thead td,thead th{--border-width:3px}:not(thead,tfoot)>*>td{--font-size:0.875em}code,kbd,pre,samp{--font-family:"Menlo","Consolas","Roboto Mono","Ubuntu Monospace","Noto Mono","Oxygen Mono","Liberation Mono",monospace,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"}kbd{--font-weight:bolder}:root:not([data-theme=dark]),[data-theme=light]{--background-color:#fff;--color:hsl(205, 20%, 32%);--h1-color:hsl(205, 30%, 15%);--h2-color:#24333e;--h3-color:hsl(205, 25%, 23%);--h4-color:#374956;--h5-color:hsl(205, 20%, 32%);--h6-color:#4d606d;--muted-color:hsl(205, 10%, 50%);--muted-border-color:hsl(205, 20%, 94%);--primary:hsl(195, 85%, 41%);--primary-hover:hsl(195, 90%, 32%);--primary-focus:rgba(16, 149, 193, 0.125);--primary-inverse:#fff;--secondary:hsl(205, 15%, 41%);--secondary-hover:hsl(205, 20%, 32%);--secondary-focus:rgba(89, 107, 120, 0.125);--secondary-inverse:#fff;--contrast:hsl(205, 30%, 15%);--contrast-hover:#000;--contrast-focus:rgba(89, 107, 120, 0.125);--contrast-inverse:#fff;--mark-background-color:#fff2ca;--mark-color:#543a26;--ins-color:#388e3c;--del-color:#c62828;--blockquote-border-color:var(--muted-border-color);--blockquote-footer-color:var(--muted-color);--button-box-shadow:0 0 0 rgba(0, 0, 0, 0);--button-hover-box-shadow:0 0 0 rgba(0, 0, 0, 0);--form-element-background-color:transparent;--form-element-border-color:hsl(205, 14%, 68%);--form-element-color:var(--color);--form-element-placeholder-color:var(--muted-color);--form-element-active-background-color:transparent;--form-element-active-border-color:var(--primary);--form-element-focus-color:var(--primary-focus);--form-element-disabled-background-color:hsl(205, 18%, 86%);--form-element-disabled-border-color:hsl(205, 14%, 68%);--form-element-disabled-opacity:0.5;--form-element-invalid-border-color:#c62828;--form-element-invalid-active-border-color:#d32f2f;--form-element-invalid-focus-color:rgba(211, 47, 47, 0.125);--form-element-valid-border-color:#388e3c;--form-element-valid-active-border-color:#43a047;--form-element-valid-focus-color:rgba(67, 160, 71, 0.125);--switch-background-color:hsl(205, 16%, 77%);--switch-color:var(--primary-inverse);--switch-checked-background-color:var(--primary);--range-border-color:hsl(205, 18%, 86%);--range-active-border-color:hsl(205, 16%, 77%);--range-thumb-border-color:var(--background-color);--range-thumb-color:var(--secondary);--range-thumb-hover-color:var(--secondary-hover);--range-thumb-active-color:var(--primary);--table-border-color:var(--muted-border-color);--table-row-stripped-background-color:#f6f8f9;--code-background-color:hsl(205, 20%, 94%);--code-color:var(--muted-color);--code-kbd-background-color:var(--contrast);--code-kbd-color:var(--contrast-inverse);--code-tag-color:hsl(330, 40%, 50%);--code-property-color:hsl(185, 40%, 40%);--code-value-color:hsl(40, 20%, 50%);--code-comment-color:hsl(205, 14%, 68%);--accordion-border-color:var(--muted-border-color);--accordion-close-summary-color:var(--color);--accordion-open-summary-color:var(--muted-color);--card-background-color:var(--background-color);--card-border-color:var(--muted-border-color);--card-box-shadow:0.0145rem 0.029rem 0.174rem rgba(27, 40, 50, 0.01698),0.0335rem 0.067rem 0.402rem rgba(27, 40, 50, 0.024),0.0625rem 0.125rem 0.75rem rgba(27, 40, 50, 0.03),0.1125rem 0.225rem 1.35rem rgba(27, 40, 50, 0.036),0.2085rem 0.417rem 2.502rem rgba(27, 40, 50, 0.04302),0.5rem 1rem 6rem rgba(27, 40, 50, 0.06),0 0 0 0.0625rem rgba(27, 40, 50, 0.015);--card-sectionning-background-color:#fbfbfc;--dropdown-background-color:#fbfbfc;--dropdown-border-color:#e1e6eb;--dropdown-box-shadow:var(--card-box-shadow);--dropdown-color:var(--color);--dropdown-hover-background-color:hsl(205, 20%, 94%);--modal-overlay-background-color:rgba(213, 220, 226, 0.7);--progress-background-color:hsl(205, 18%, 86%);--progress-color:var(--primary);--loading-spinner-opacity:0.5;--tooltip-background-color:var(--contrast);--tooltip-color:var(--contrast-inverse);--icon-checkbox:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(255, 255, 255)' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(65, 84, 98)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron-button:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(255, 255, 255)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron-button-inverse:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(255, 255, 255)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-close:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(115, 130, 140)' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E");--icon-date:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(65, 84, 98)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");--icon-invalid:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(198, 40, 40)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E");--icon-minus:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(255, 255, 255)' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'%3E%3C/line%3E%3C/svg%3E");--icon-search:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(65, 84, 98)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");--icon-time:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(65, 84, 98)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E");--icon-valid:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(56, 142, 60)' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");color-scheme:light}@media only screen and (prefers-color-scheme:dark){:root:not([data-theme]){--background-color:#11191f;--color:hsl(205, 16%, 77%);--h1-color:hsl(205, 20%, 94%);--h2-color:#e1e6eb;--h3-color:hsl(205, 18%, 86%);--h4-color:#c8d1d8;--h5-color:hsl(205, 16%, 77%);--h6-color:#afbbc4;--muted-color:hsl(205, 10%, 50%);--muted-border-color:#1f2d38;--primary:hsl(195, 85%, 41%);--primary-hover:hsl(195, 80%, 50%);--primary-focus:rgba(16, 149, 193, 0.25);--primary-inverse:#fff;--secondary:hsl(205, 15%, 41%);--secondary-hover:hsl(205, 10%, 50%);--secondary-focus:rgba(115, 130, 140, 0.25);--secondary-inverse:#fff;--contrast:hsl(205, 20%, 94%);--contrast-hover:#fff;--contrast-focus:rgba(115, 130, 140, 0.25);--contrast-inverse:#000;--mark-background-color:#d1c284;--mark-color:#11191f;--ins-color:#388e3c;--del-color:#c62828;--blockquote-border-color:var(--muted-border-color);--blockquote-footer-color:var(--muted-color);--button-box-shadow:0 0 0 rgba(0, 0, 0, 0);--button-hover-box-shadow:0 0 0 rgba(0, 0, 0, 0);--form-element-background-color:#11191f;--form-element-border-color:#374956;--form-element-color:var(--color);--form-element-placeholder-color:var(--muted-color);--form-element-active-background-color:var(--form-element-background-color);--form-element-active-border-color:var(--primary);--form-element-focus-color:var(--primary-focus);--form-element-disabled-background-color:hsl(205, 25%, 23%);--form-element-disabled-border-color:hsl(205, 20%, 32%);--form-element-disabled-opacity:0.5;--form-element-invalid-border-color:#b71c1c;--form-element-invalid-active-border-color:#c62828;--form-element-invalid-focus-color:rgba(198, 40, 40, 0.25);--form-element-valid-border-color:#2e7d32;--form-element-valid-active-border-color:#388e3c;--form-element-valid-focus-color:rgba(56, 142, 60, 0.25);--switch-background-color:#374956;--switch-color:var(--primary-inverse);--switch-checked-background-color:var(--primary);--range-border-color:#24333e;--range-active-border-color:hsl(205, 25%, 23%);--range-thumb-border-color:var(--background-color);--range-thumb-color:var(--secondary);--range-thumb-hover-color:var(--secondary-hover);--range-thumb-active-color:var(--primary);--table-border-color:var(--muted-border-color);--table-row-stripped-background-color:rgba(115, 130, 140, 0.05);--code-background-color:#18232c;--code-color:var(--muted-color);--code-kbd-background-color:var(--contrast);--code-kbd-color:var(--contrast-inverse);--code-tag-color:hsl(330, 30%, 50%);--code-property-color:hsl(185, 30%, 50%);--code-value-color:hsl(40, 10%, 50%);--code-comment-color:#4d606d;--accordion-border-color:var(--muted-border-color);--accordion-active-summary-color:var(--primary);--accordion-close-summary-color:var(--color);--accordion-open-summary-color:var(--muted-color);--card-background-color:#141e26;--card-border-color:var(--card-background-color);--card-box-shadow:0.0145rem 0.029rem 0.174rem rgba(0, 0, 0, 0.01698),0.0335rem 0.067rem 0.402rem rgba(0, 0, 0, 0.024),0.0625rem 0.125rem 0.75rem rgba(0, 0, 0, 0.03),0.1125rem 0.225rem 1.35rem rgba(0, 0, 0, 0.036),0.2085rem 0.417rem 2.502rem rgba(0, 0, 0, 0.04302),0.5rem 1rem 6rem rgba(0, 0, 0, 0.06),0 0 0 0.0625rem rgba(0, 0, 0, 0.015);--card-sectionning-background-color:#18232c;--dropdown-background-color:hsl(205, 30%, 15%);--dropdown-border-color:#24333e;--dropdown-box-shadow:var(--card-box-shadow);--dropdown-color:var(--color);--dropdown-hover-background-color:rgba(36, 51, 62, 0.75);--modal-overlay-background-color:rgba(36, 51, 62, 0.8);--progress-background-color:#24333e;--progress-color:var(--primary);--loading-spinner-opacity:0.5;--tooltip-background-color:var(--contrast);--tooltip-color:var(--contrast-inverse);--icon-checkbox:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(255, 255, 255)' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(162, 175, 185)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron-button:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(255, 255, 255)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron-button-inverse:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(0, 0, 0)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-close:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(115, 130, 140)' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E");--icon-date:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(162, 175, 185)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");--icon-invalid:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(183, 28, 28)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E");--icon-minus:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(255, 255, 255)' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'%3E%3C/line%3E%3C/svg%3E");--icon-search:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(162, 175, 185)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");--icon-time:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(162, 175, 185)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E");--icon-valid:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(46, 125, 50)' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");color-scheme:dark}}[data-theme=dark]{--background-color:#11191f;--color:hsl(205, 16%, 77%);--h1-color:hsl(205, 20%, 94%);--h2-color:#e1e6eb;--h3-color:hsl(205, 18%, 86%);--h4-color:#c8d1d8;--h5-color:hsl(205, 16%, 77%);--h6-color:#afbbc4;--muted-color:hsl(205, 10%, 50%);--muted-border-color:#1f2d38;--primary:hsl(195, 85%, 41%);--primary-hover:hsl(195, 80%, 50%);--primary-focus:rgba(16, 149, 193, 0.25);--primary-inverse:#fff;--secondary:hsl(205, 15%, 41%);--secondary-hover:hsl(205, 10%, 50%);--secondary-focus:rgba(115, 130, 140, 0.25);--secondary-inverse:#fff;--contrast:hsl(205, 20%, 94%);--contrast-hover:#fff;--contrast-focus:rgba(115, 130, 140, 0.25);--contrast-inverse:#000;--mark-background-color:#d1c284;--mark-color:#11191f;--ins-color:#388e3c;--del-color:#c62828;--blockquote-border-color:var(--muted-border-color);--blockquote-footer-color:var(--muted-color);--button-box-shadow:0 0 0 rgba(0, 0, 0, 0);--button-hover-box-shadow:0 0 0 rgba(0, 0, 0, 0);--form-element-background-color:#11191f;--form-element-border-color:#374956;--form-element-color:var(--color);--form-element-placeholder-color:var(--muted-color);--form-element-active-background-color:var(--form-element-background-color);--form-element-active-border-color:var(--primary);--form-element-focus-color:var(--primary-focus);--form-element-disabled-background-color:hsl(205, 25%, 23%);--form-element-disabled-border-color:hsl(205, 20%, 32%);--form-element-disabled-opacity:0.5;--form-element-invalid-border-color:#b71c1c;--form-element-invalid-active-border-color:#c62828;--form-element-invalid-focus-color:rgba(198, 40, 40, 0.25);--form-element-valid-border-color:#2e7d32;--form-element-valid-active-border-color:#388e3c;--form-element-valid-focus-color:rgba(56, 142, 60, 0.25);--switch-background-color:#374956;--switch-color:var(--primary-inverse);--switch-checked-background-color:var(--primary);--range-border-color:#24333e;--range-active-border-color:hsl(205, 25%, 23%);--range-thumb-border-color:var(--background-color);--range-thumb-color:var(--secondary);--range-thumb-hover-color:var(--secondary-hover);--range-thumb-active-color:var(--primary);--table-border-color:var(--muted-border-color);--table-row-stripped-background-color:rgba(115, 130, 140, 0.05);--code-background-color:#18232c;--code-color:var(--muted-color);--code-kbd-background-color:var(--contrast);--code-kbd-color:var(--contrast-inverse);--code-tag-color:hsl(330, 30%, 50%);--code-property-color:hsl(185, 30%, 50%);--code-value-color:hsl(40, 10%, 50%);--code-comment-color:#4d606d;--accordion-border-color:var(--muted-border-color);--accordion-active-summary-color:var(--primary);--accordion-close-summary-color:var(--color);--accordion-open-summary-color:var(--muted-color);--card-background-color:#141e26;--card-border-color:var(--card-background-color);--card-box-shadow:0.0145rem 0.029rem 0.174rem rgba(0, 0, 0, 0.01698),0.0335rem 0.067rem 0.402rem rgba(0, 0, 0, 0.024),0.0625rem 0.125rem 0.75rem rgba(0, 0, 0, 0.03),0.1125rem 0.225rem 1.35rem rgba(0, 0, 0, 0.036),0.2085rem 0.417rem 2.502rem rgba(0, 0, 0, 0.04302),0.5rem 1rem 6rem rgba(0, 0, 0, 0.06),0 0 0 0.0625rem rgba(0, 0, 0, 0.015);--card-sectionning-background-color:#18232c;--dropdown-background-color:hsl(205, 30%, 15%);--dropdown-border-color:#24333e;--dropdown-box-shadow:var(--card-box-shadow);--dropdown-color:var(--color);--dropdown-hover-background-color:rgba(36, 51, 62, 0.75);--modal-overlay-background-color:rgba(36, 51, 62, 0.8);--progress-background-color:#24333e;--progress-color:var(--primary);--loading-spinner-opacity:0.5;--tooltip-background-color:var(--contrast);--tooltip-color:var(--contrast-inverse);--icon-checkbox:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(255, 255, 255)' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(162, 175, 185)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron-button:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(255, 255, 255)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron-button-inverse:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(0, 0, 0)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-close:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(115, 130, 140)' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E");--icon-date:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(162, 175, 185)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");--icon-invalid:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(183, 28, 28)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E");--icon-minus:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(255, 255, 255)' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'%3E%3C/line%3E%3C/svg%3E");--icon-search:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(162, 175, 185)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");--icon-time:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(162, 175, 185)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E");--icon-valid:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(46, 125, 50)' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");color-scheme:dark}[type=checkbox],[type=radio],[type=range],progress{accent-color:var(--primary)}*,::after,::before{box-sizing:border-box;background-repeat:no-repeat}::after,::before{text-decoration:inherit;vertical-align:inherit}:where(:root){-webkit-tap-highlight-color:transparent;-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;text-size-adjust:100%;background-color:var(--background-color);color:var(--color);font-weight:var(--font-weight);font-size:var(--font-size);line-height:var(--line-height);font-family:var(--font-family);text-rendering:optimizeLegibility;overflow-wrap:break-word;cursor:default;-moz-tab-size:4;-o-tab-size:4;tab-size:4}main{display:block}body{width:100%;margin:0}body>footer,body>header,body>main{width:100%;margin-right:auto;margin-left:auto;padding:var(--block-spacing-vertical) 0}.container,.container-fluid{width:100%;margin-right:auto;margin-left:auto;padding-right:var(--spacing);padding-left:var(--spacing)}@media (min-width:576px){.container{max-width:510px;padding-right:0;padding-left:0}}@media (min-width:768px){.container{max-width:700px}}@media (min-width:992px){.container{max-width:920px}}@media (min-width:1200px){.container{max-width:1130px}}section{margin-bottom:var(--block-spacing-vertical)}.grid{grid-column-gap:var(--grid-spacing-horizontal);grid-row-gap:var(--grid-spacing-vertical);display:grid;grid-template-columns:1fr;margin:0}@media (min-width:992px){.grid{grid-template-columns:repeat(auto-fit,minmax(0%,1fr))}}.grid>*{min-width:0}figure{display:block;margin:0;padding:0;overflow-x:auto}figure figcaption{padding:calc(var(--spacing) * .5) 0;color:var(--muted-color)}b,strong{font-weight:bolder}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}address,blockquote,dl,figure,form,ol,p,pre,table,ul{margin-top:0;margin-bottom:var(--typography-spacing-vertical);color:var(--color);font-style:normal;font-weight:var(--font-weight);font-size:var(--font-size)}[role=link],a{--color:var(--primary);--background-color:transparent;outline:0;background-color:var(--background-color);color:var(--color);-webkit-text-decoration:var(--text-decoration);text-decoration:var(--text-decoration);transition:background-color var(--transition),color var(--transition),box-shadow var(--transition),-webkit-text-decoration var(--transition);transition:background-color var(--transition),color var(--transition),text-decoration var(--transition),box-shadow var(--transition);transition:background-color var(--transition),color var(--transition),text-decoration var(--transition),box-shadow var(--transition),-webkit-text-decoration var(--transition)}[role=link]:is([aria-current],:hover,:active,:focus),a:is([aria-current],:hover,:active,:focus){--color:var(--primary-hover);--text-decoration:underline}[role=link]:focus,a:focus{--background-color:var(--primary-focus)}[role=link].secondary,a.secondary{--color:var(--secondary)}[role=link].secondary:is([aria-current],:hover,:active,:focus),a.secondary:is([aria-current],:hover,:active,:focus){--color:var(--secondary-hover)}[role=link].secondary:focus,a.secondary:focus{--background-color:var(--secondary-focus)}[role=link].contrast,a.contrast{--color:var(--contrast)}[role=link].contrast:is([aria-current],:hover,:active,:focus),a.contrast:is([aria-current],:hover,:active,:focus){--color:var(--contrast-hover)}[role=link].contrast:focus,a.contrast:focus{--background-color:var(--contrast-focus)}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:var(--typography-spacing-vertical);color:var(--color);font-weight:var(--font-weight);font-size:var(--font-size);font-family:var(--font-family)}h1{--color:var(--h1-color)}h2{--color:var(--h2-color)}h3{--color:var(--h3-color)}h4{--color:var(--h4-color)}h5{--color:var(--h5-color)}h6{--color:var(--h6-color)}:where(address,blockquote,dl,figure,form,ol,p,pre,table,ul)~:is(h1,h2,h3,h4,h5,h6){margin-top:var(--typography-spacing-vertical)}.headings,hgroup{margin-bottom:var(--typography-spacing-vertical)}.headings>*,hgroup>*{margin-bottom:0}.headings>:last-child,hgroup>:last-child{--color:var(--muted-color);--font-weight:unset;font-size:1rem;font-family:unset}p{margin-bottom:var(--typography-spacing-vertical)}small{font-size:var(--font-size)}:where(dl,ol,ul){padding-right:0;padding-left:var(--spacing);-webkit-padding-start:var(--spacing);padding-inline-start:var(--spacing);-webkit-padding-end:0;padding-inline-end:0}:where(dl,ol,ul) li{margin-bottom:calc(var(--typography-spacing-vertical) * .25)}:where(dl,ol,ul) :is(dl,ol,ul){margin:0;margin-top:calc(var(--typography-spacing-vertical) * .25)}ul li{list-style:square}mark{padding:.125rem .25rem;background-color:var(--mark-background-color);color:var(--mark-color);vertical-align:baseline}blockquote{display:block;margin:var(--typography-spacing-vertical) 0;padding:var(--spacing);border-right:none;border-left:.25rem solid var(--blockquote-border-color);-webkit-border-start:0.25rem solid var(--blockquote-border-color);border-inline-start:0.25rem solid var(--blockquote-border-color);-webkit-border-end:none;border-inline-end:none}blockquote footer{margin-top:calc(var(--typography-spacing-vertical) * .5);color:var(--blockquote-footer-color)}abbr[title]{border-bottom:1px dotted;text-decoration:none;cursor:help}ins{color:var(--ins-color);text-decoration:none}del{color:var(--del-color)}::-moz-selection{background-color:var(--primary-focus)}::selection{background-color:var(--primary-focus)}:where(audio,canvas,iframe,img,svg,video){vertical-align:middle}audio,video{display:inline-block}audio:not([controls]){display:none;height:0}:where(iframe){border-style:none}img{max-width:100%;height:auto;border-style:none}:where(svg:not([fill])){fill:currentColor}svg:not(:root){overflow:hidden}button{margin:0;overflow:visible;font-family:inherit;text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}button{display:block;width:100%;margin-bottom:var(--spacing)}[role=button]{display:inline-block;text-decoration:none}[role=button],button,input[type=button],input[type=reset],input[type=submit]{--background-color:var(--primary);--border-color:var(--primary);--color:var(--primary-inverse);--box-shadow:var(--button-box-shadow, 0 0 0 rgba(0, 0, 0, 0));padding:var(--form-element-spacing-vertical) var(--form-element-spacing-horizontal);border:var(--border-width) solid var(--border-color);border-radius:var(--border-radius);outline:0;background-color:var(--background-color);box-shadow:var(--box-shadow);color:var(--color);font-weight:var(--font-weight);font-size:1rem;line-height:var(--line-height);text-align:center;cursor:pointer;transition:background-color var(--transition),border-color var(--transition),color var(--transition),box-shadow var(--transition)}[role=button]:is([aria-current],:hover,:active,:focus),button:is([aria-current],:hover,:active,:focus),input[type=button]:is([aria-current],:hover,:active,:focus),input[type=reset]:is([aria-current],:hover,:active,:focus),input[type=submit]:is([aria-current],:hover,:active,:focus){--background-color:var(--primary-hover);--border-color:var(--primary-hover);--box-shadow:var(--button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0));--color:var(--primary-inverse)}[role=button]:focus,button:focus,input[type=button]:focus,input[type=reset]:focus,input[type=submit]:focus{--box-shadow:var(--button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)),0 0 0 var(--outline-width) var(--primary-focus)}:is(button,input[type=submit],input[type=button],[role=button]).secondary,input[type=reset]{--background-color:var(--secondary);--border-color:var(--secondary);--color:var(--secondary-inverse);cursor:pointer}:is(button,input[type=submit],input[type=button],[role=button]).secondary:is([aria-current],:hover,:active,:focus),input[type=reset]:is([aria-current],:hover,:active,:focus){--background-color:var(--secondary-hover);--border-color:var(--secondary-hover);--color:var(--secondary-inverse)}:is(button,input[type=submit],input[type=button],[role=button]).secondary:focus,input[type=reset]:focus{--box-shadow:var(--button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)),0 0 0 var(--outline-width) var(--secondary-focus)}:is(button,input[type=submit],input[type=button],[role=button]).contrast{--background-color:var(--contrast);--border-color:var(--contrast);--color:var(--contrast-inverse)}:is(button,input[type=submit],input[type=button],[role=button]).contrast:is([aria-current],:hover,:active,:focus){--background-color:var(--contrast-hover);--border-color:var(--contrast-hover);--color:var(--contrast-inverse)}:is(button,input[type=submit],input[type=button],[role=button]).contrast:focus{--box-shadow:var(--button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)),0 0 0 var(--outline-width) var(--contrast-focus)}:is(button,input[type=submit],input[type=button],[role=button]).outline,input[type=reset].outline{--background-color:transparent;--color:var(--primary)}:is(button,input[type=submit],input[type=button],[role=button]).outline:is([aria-current],:hover,:active,:focus),input[type=reset].outline:is([aria-current],:hover,:active,:focus){--background-color:transparent;--color:var(--primary-hover)}:is(button,input[type=submit],input[type=button],[role=button]).outline.secondary,input[type=reset].outline{--color:var(--secondary)}:is(button,input[type=submit],input[type=button],[role=button]).outline.secondary:is([aria-current],:hover,:active,:focus),input[type=reset].outline:is([aria-current],:hover,:active,:focus){--color:var(--secondary-hover)}:is(button,input[type=submit],input[type=button],[role=button]).outline.contrast{--color:var(--contrast)}:is(button,input[type=submit],input[type=button],[role=button]).outline.contrast:is([aria-current],:hover,:active,:focus){--color:var(--contrast-hover)}:where(button,[type=submit],[type=button],[type=reset],[role=button])[disabled],:where(fieldset[disabled]) :is(button,[type=submit],[type=button],[type=reset],[role=button]),a[role=button]:not([href]){opacity:.5;pointer-events:none}input,optgroup,select,textarea{margin:0;font-size:1rem;line-height:var(--line-height);font-family:inherit;letter-spacing:inherit}input{overflow:visible}select{text-transform:none}legend{max-width:100%;padding:0;color:inherit;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio]{padding:0}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}::-moz-focus-inner{padding:0;border-style:none}:-moz-focusring{outline:0}:-moz-ui-invalid{box-shadow:none}::-ms-expand{display:none}[type=file],[type=range]{padding:0;border-width:0}input:not([type=checkbox],[type=radio],[type=range]){height:calc(1rem * var(--line-height) + var(--form-element-spacing-vertical) * 2 + var(--border-width) * 2)}fieldset{margin:0;margin-bottom:var(--spacing);padding:0;border:0}fieldset legend,label{display:block;margin-bottom:calc(var(--spacing) * .25);font-weight:var(--form-label-font-weight,var(--font-weight))}input:not([type=checkbox],[type=radio]),select,textarea{width:100%}input:not([type=checkbox],[type=radio],[type=range],[type=file]),select,textarea{-webkit-appearance:none;-moz-appearance:none;appearance:none;padding:var(--form-element-spacing-vertical) var(--form-element-spacing-horizontal)}input,select,textarea{--background-color:var(--form-element-background-color);--border-color:var(--form-element-border-color);--color:var(--form-element-color);--box-shadow:none;border:var(--border-width) solid var(--border-color);border-radius:var(--border-radius);outline:0;background-color:var(--background-color);box-shadow:var(--box-shadow);color:var(--color);font-weight:var(--font-weight);transition:background-color var(--transition),border-color var(--transition),color var(--transition),box-shadow var(--transition)}:where(select,textarea):is(:active,:focus),input:not([type=submit],[type=button],[type=reset],[type=checkbox],[type=radio],[readonly]):is(:active,:focus){--background-color:var(--form-element-active-background-color)}:where(select,textarea):is(:active,:focus),input:not([type=submit],[type=button],[type=reset],[role=switch],[readonly]):is(:active,:focus){--border-color:var(--form-element-active-border-color)}input:not([type=submit],[type=button],[type=reset],[type=range],[type=file],[readonly]):focus,select:focus,textarea:focus{--box-shadow:0 0 0 var(--outline-width) var(--form-element-focus-color)}:where(fieldset[disabled]) :is(input:not([type=submit],[type=button],[type=reset]),select,textarea),input:not([type=submit],[type=button],[type=reset])[disabled],select[disabled],textarea[disabled]{--background-color:var(--form-element-disabled-background-color);--border-color:var(--form-element-disabled-border-color);opacity:var(--form-element-disabled-opacity);pointer-events:none}:where(input,select,textarea):not([type=checkbox],[type=radio],[type=date],[type=datetime-local],[type=month],[type=time],[type=week])[aria-invalid]{padding-right:calc(var(--form-element-spacing-horizontal) + 1.5rem)!important;padding-left:var(--form-element-spacing-horizontal);-webkit-padding-start:var(--form-element-spacing-horizontal)!important;padding-inline-start:var(--form-element-spacing-horizontal)!important;-webkit-padding-end:calc(var(--form-element-spacing-horizontal) + 1.5rem)!important;padding-inline-end:calc(var(--form-element-spacing-horizontal) + 1.5rem)!important;background-position:center right .75rem;background-size:1rem auto;background-repeat:no-repeat}:where(input,select,textarea):not([type=checkbox],[type=radio],[type=date],[type=datetime-local],[type=month],[type=time],[type=week])[aria-invalid=false]{background-image:var(--icon-valid)}:where(input,select,textarea):not([type=checkbox],[type=radio],[type=date],[type=datetime-local],[type=month],[type=time],[type=week])[aria-invalid=true]{background-image:var(--icon-invalid)}:where(input,select,textarea)[aria-invalid=false]{--border-color:var(--form-element-valid-border-color)}:where(input,select,textarea)[aria-invalid=false]:is(:active,:focus){--border-color:var(--form-element-valid-active-border-color)!important;--box-shadow:0 0 0 var(--outline-width) var(--form-element-valid-focus-color)!important}:where(input,select,textarea)[aria-invalid=true]{--border-color:var(--form-element-invalid-border-color)}:where(input,select,textarea)[aria-invalid=true]:is(:active,:focus){--border-color:var(--form-element-invalid-active-border-color)!important;--box-shadow:0 0 0 var(--outline-width) var(--form-element-invalid-focus-color)!important}[dir=rtl] :where(input,select,textarea):not([type=checkbox],[type=radio]):is([aria-invalid],[aria-invalid=true],[aria-invalid=false]){background-position:center left .75rem}input::-webkit-input-placeholder,input::placeholder,select:invalid,textarea::-webkit-input-placeholder,textarea::placeholder{color:var(--form-element-placeholder-color);opacity:1}input:not([type=checkbox],[type=radio]),select,textarea{margin-bottom:var(--spacing)}select::-ms-expand{border:0;background-color:transparent}select:not([multiple],[size]){padding-right:calc(var(--form-element-spacing-horizontal) + 1.5rem);padding-left:var(--form-element-spacing-horizontal);-webkit-padding-start:var(--form-element-spacing-horizontal);padding-inline-start:var(--form-element-spacing-horizontal);-webkit-padding-end:calc(var(--form-element-spacing-horizontal) + 1.5rem);padding-inline-end:calc(var(--form-element-spacing-horizontal) + 1.5rem);background-image:var(--icon-chevron);background-position:center right .75rem;background-size:1rem auto;background-repeat:no-repeat}[dir=rtl] select:not([multiple],[size]){background-position:center left .75rem}:where(input,select,textarea,.grid)+small{display:block;width:100%;margin-top:calc(var(--spacing) * -.75);margin-bottom:var(--spacing);color:var(--muted-color)}label>:where(input,select,textarea){margin-top:calc(var(--spacing) * .25)}[type=checkbox],[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:1.25em;height:1.25em;margin-top:-.125em;margin-right:.375em;margin-left:0;-webkit-margin-start:0;margin-inline-start:0;-webkit-margin-end:.375em;margin-inline-end:.375em;border-width:var(--border-width);font-size:inherit;vertical-align:middle;cursor:pointer}[type=checkbox]::-ms-check,[type=radio]::-ms-check{display:none}[type=checkbox]:checked,[type=checkbox]:checked:active,[type=checkbox]:checked:focus,[type=radio]:checked,[type=radio]:checked:active,[type=radio]:checked:focus{--background-color:var(--primary);--border-color:var(--primary);background-image:var(--icon-checkbox);background-position:center;background-size:.75em auto;background-repeat:no-repeat}[type=checkbox]~label,[type=radio]~label{display:inline-block;margin-right:.375em;margin-bottom:0;cursor:pointer}[type=checkbox]:indeterminate{--background-color:var(--primary);--border-color:var(--primary);background-image:var(--icon-minus);background-position:center;background-size:.75em auto;background-repeat:no-repeat}[type=radio]{border-radius:50%}[type=radio]:checked,[type=radio]:checked:active,[type=radio]:checked:focus{--background-color:var(--primary-inverse);border-width:.35em;background-image:none}[type=checkbox][role=switch]{--background-color:var(--switch-background-color);--border-color:var(--switch-background-color);--color:var(--switch-color);width:2.25em;height:1.25em;border:var(--border-width) solid var(--border-color);border-radius:1.25em;background-color:var(--background-color);line-height:1.25em}[type=checkbox][role=switch]:focus{--background-color:var(--switch-background-color);--border-color:var(--switch-background-color)}[type=checkbox][role=switch]:checked{--background-color:var(--switch-checked-background-color);--border-color:var(--switch-checked-background-color)}[type=checkbox][role=switch]:before{display:block;width:calc(1.25em - (var(--border-width) * 2));height:100%;border-radius:50%;background-color:var(--color);content:"";transition:margin .1s ease-in-out}[type=checkbox][role=switch]:checked{background-image:none}[type=checkbox][role=switch]:checked::before{margin-left:calc(1.125em - var(--border-width));-webkit-margin-start:calc(1.125em - var(--border-width));margin-inline-start:calc(1.125em - var(--border-width))}[type=checkbox]:checked[aria-invalid=false],[type=checkbox][aria-invalid=false],[type=checkbox][role=switch]:checked[aria-invalid=false],[type=checkbox][role=switch][aria-invalid=false],[type=radio]:checked[aria-invalid=false],[type=radio][aria-invalid=false]{--border-color:var(--form-element-valid-border-color)}[type=checkbox]:checked[aria-invalid=true],[type=checkbox][aria-invalid=true],[type=checkbox][role=switch]:checked[aria-invalid=true],[type=checkbox][role=switch][aria-invalid=true],[type=radio]:checked[aria-invalid=true],[type=radio][aria-invalid=true]{--border-color:var(--form-element-invalid-border-color)}[type=color]::-webkit-color-swatch-wrapper{padding:0}[type=color]::-moz-focus-inner{padding:0}[type=color]::-webkit-color-swatch{border:0;border-radius:calc(var(--border-radius) * .5)}[type=color]::-moz-color-swatch{border:0;border-radius:calc(var(--border-radius) * .5)}input:not([type=checkbox],[type=radio],[type=range],[type=file]):is([type=date],[type=datetime-local],[type=month],[type=time],[type=week]){--icon-position:0.75rem;--icon-width:1rem;padding-right:calc(var(--icon-width) + var(--icon-position));background-image:var(--icon-date);background-position:center right var(--icon-position);background-size:var(--icon-width) auto;background-repeat:no-repeat}input:not([type=checkbox],[type=radio],[type=range],[type=file])[type=time]{background-image:var(--icon-time)}[type=date]::-webkit-calendar-picker-indicator,[type=datetime-local]::-webkit-calendar-picker-indicator,[type=month]::-webkit-calendar-picker-indicator,[type=time]::-webkit-calendar-picker-indicator,[type=week]::-webkit-calendar-picker-indicator{width:var(--icon-width);margin-right:calc(var(--icon-width) * -1);margin-left:var(--icon-position);opacity:0}[dir=rtl] :is([type=date],[type=datetime-local],[type=month],[type=time],[type=week]){text-align:right}@-moz-document url-prefix(){[type=date],[type=datetime-local],[type=month],[type=time],[type=week]{padding-right:var(--form-element-spacing-horizontal)!important;background-image:none!important}}[type=file]{--color:var(--muted-color);padding:calc(var(--form-element-spacing-vertical) * .5) 0;border:0;border-radius:0;background:0 0}[type=file]::file-selector-button{--background-color:var(--secondary);--border-color:var(--secondary);--color:var(--secondary-inverse);margin-right:calc(var(--spacing)/ 2);margin-left:0;-webkit-margin-start:0;margin-inline-start:0;-webkit-margin-end:calc(var(--spacing)/ 2);margin-inline-end:calc(var(--spacing)/ 2);padding:calc(var(--form-element-spacing-vertical) * .5) calc(var(--form-element-spacing-horizontal) * .5);border:var(--border-width) solid var(--border-color);border-radius:var(--border-radius);outline:0;background-color:var(--background-color);box-shadow:var(--box-shadow);color:var(--color);font-weight:var(--font-weight);font-size:1rem;line-height:var(--line-height);text-align:center;cursor:pointer;transition:background-color var(--transition),border-color var(--transition),color var(--transition),box-shadow var(--transition)}[type=file]::file-selector-button:is(:hover,:active,:focus){--background-color:var(--secondary-hover);--border-color:var(--secondary-hover)}[type=file]::-webkit-file-upload-button{--background-color:var(--secondary);--border-color:var(--secondary);--color:var(--secondary-inverse);margin-right:calc(var(--spacing)/ 2);margin-left:0;-webkit-margin-start:0;margin-inline-start:0;-webkit-margin-end:calc(var(--spacing)/ 2);margin-inline-end:calc(var(--spacing)/ 2);padding:calc(var(--form-element-spacing-vertical) * .5) calc(var(--form-element-spacing-horizontal) * .5);border:var(--border-width) solid var(--border-color);border-radius:var(--border-radius);outline:0;background-color:var(--background-color);box-shadow:var(--box-shadow);color:var(--color);font-weight:var(--font-weight);font-size:1rem;line-height:var(--line-height);text-align:center;cursor:pointer;-webkit-transition:background-color var(--transition),border-color var(--transition),color var(--transition),box-shadow var(--transition);transition:background-color var(--transition),border-color var(--transition),color var(--transition),box-shadow var(--transition)}[type=file]::-webkit-file-upload-button:is(:hover,:active,:focus){--background-color:var(--secondary-hover);--border-color:var(--secondary-hover)}[type=file]::-ms-browse{--background-color:var(--secondary);--border-color:var(--secondary);--color:var(--secondary-inverse);margin-right:calc(var(--spacing)/ 2);margin-left:0;margin-inline-start:0;margin-inline-end:calc(var(--spacing)/ 2);padding:calc(var(--form-element-spacing-vertical) * .5) calc(var(--form-element-spacing-horizontal) * .5);border:var(--border-width) solid var(--border-color);border-radius:var(--border-radius);outline:0;background-color:var(--background-color);box-shadow:var(--box-shadow);color:var(--color);font-weight:var(--font-weight);font-size:1rem;line-height:var(--line-height);text-align:center;cursor:pointer;-ms-transition:background-color var(--transition),border-color var(--transition),color var(--transition),box-shadow var(--transition);transition:background-color var(--transition),border-color var(--transition),color var(--transition),box-shadow var(--transition)}[type=file]::-ms-browse:is(:hover,:active,:focus){--background-color:var(--secondary-hover);--border-color:var(--secondary-hover)}[type=range]{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100%;height:1.25rem;background:0 0}[type=range]::-webkit-slider-runnable-track{width:100%;height:.25rem;border-radius:var(--border-radius);background-color:var(--range-border-color);-webkit-transition:background-color var(--transition),box-shadow var(--transition);transition:background-color var(--transition),box-shadow var(--transition)}[type=range]::-moz-range-track{width:100%;height:.25rem;border-radius:var(--border-radius);background-color:var(--range-border-color);-moz-transition:background-color var(--transition),box-shadow var(--transition);transition:background-color var(--transition),box-shadow var(--transition)}[type=range]::-ms-track{width:100%;height:.25rem;border-radius:var(--border-radius);background-color:var(--range-border-color);-ms-transition:background-color var(--transition),box-shadow var(--transition);transition:background-color var(--transition),box-shadow var(--transition)}[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:1.25rem;height:1.25rem;margin-top:-.5rem;border:2px solid var(--range-thumb-border-color);border-radius:50%;background-color:var(--range-thumb-color);cursor:pointer;-webkit-transition:background-color var(--transition),transform var(--transition);transition:background-color var(--transition),transform var(--transition)}[type=range]::-moz-range-thumb{-webkit-appearance:none;width:1.25rem;height:1.25rem;margin-top:-.5rem;border:2px solid var(--range-thumb-border-color);border-radius:50%;background-color:var(--range-thumb-color);cursor:pointer;-moz-transition:background-color var(--transition),transform var(--transition);transition:background-color var(--transition),transform var(--transition)}[type=range]::-ms-thumb{-webkit-appearance:none;width:1.25rem;height:1.25rem;margin-top:-.5rem;border:2px solid var(--range-thumb-border-color);border-radius:50%;background-color:var(--range-thumb-color);cursor:pointer;-ms-transition:background-color var(--transition),transform var(--transition);transition:background-color var(--transition),transform var(--transition)}[type=range]:focus,[type=range]:hover{--range-border-color:var(--range-active-border-color);--range-thumb-color:var(--range-thumb-hover-color)}[type=range]:active{--range-thumb-color:var(--range-thumb-active-color)}[type=range]:active::-webkit-slider-thumb{transform:scale(1.25)}[type=range]:active::-moz-range-thumb{transform:scale(1.25)}[type=range]:active::-ms-thumb{transform:scale(1.25)}input:not([type=checkbox],[type=radio],[type=range],[type=file])[type=search]{-webkit-padding-start:calc(var(--form-element-spacing-horizontal) + 1.75rem);padding-inline-start:calc(var(--form-element-spacing-horizontal) + 1.75rem);border-radius:5rem;background-image:var(--icon-search);background-position:center left 1.125rem;background-size:1rem auto;background-repeat:no-repeat}input:not([type=checkbox],[type=radio],[type=range],[type=file])[type=search][aria-invalid]{-webkit-padding-start:calc(var(--form-element-spacing-horizontal) + 1.75rem)!important;padding-inline-start:calc(var(--form-element-spacing-horizontal) + 1.75rem)!important;background-position:center left 1.125rem,center right .75rem}input:not([type=checkbox],[type=radio],[type=range],[type=file])[type=search][aria-invalid=false]{background-image:var(--icon-search),var(--icon-valid)}input:not([type=checkbox],[type=radio],[type=range],[type=file])[type=search][aria-invalid=true]{background-image:var(--icon-search),var(--icon-invalid)}[type=search]::-webkit-search-cancel-button{-webkit-appearance:none;display:none}[dir=rtl] :where(input):not([type=checkbox],[type=radio],[type=range],[type=file])[type=search]{background-position:center right 1.125rem}[dir=rtl] :where(input):not([type=checkbox],[type=radio],[type=range],[type=file])[type=search][aria-invalid]{background-position:center right 1.125rem,center left .75rem}:where(table){width:100%;border-collapse:collapse;border-spacing:0;text-indent:0}td,th{padding:calc(var(--spacing)/ 2) var(--spacing);border-bottom:var(--border-width) solid var(--table-border-color);color:var(--color);font-weight:var(--font-weight);font-size:var(--font-size);text-align:left;text-align:start}tfoot td,tfoot th{border-top:var(--border-width) solid var(--table-border-color);border-bottom:0}table[role=grid] tbody tr:nth-child(odd){background-color:var(--table-row-stripped-background-color)}code,kbd,pre,samp{font-size:.875em;font-family:var(--font-family)}pre{-ms-overflow-style:scrollbar;overflow:auto}code,kbd,pre{border-radius:var(--border-radius);background:var(--code-background-color);color:var(--code-color);font-weight:var(--font-weight);line-height:initial}code,kbd{display:inline-block;padding:.375rem .5rem}pre{display:block;margin-bottom:var(--spacing);overflow-x:auto}pre>code{display:block;padding:var(--spacing);background:0 0;font-size:14px;line-height:var(--line-height)}code b{color:var(--code-tag-color);font-weight:var(--font-weight)}code i{color:var(--code-property-color);font-style:normal}code u{color:var(--code-value-color);text-decoration:none}code em{color:var(--code-comment-color);font-style:normal}kbd{background-color:var(--code-kbd-background-color);color:var(--code-kbd-color);vertical-align:baseline}hr{height:0;border:0;border-top:1px solid var(--muted-border-color);color:inherit}[hidden],template{display:none!important}canvas{display:inline-block}details{display:block;margin-bottom:var(--spacing);padding-bottom:var(--spacing);border-bottom:var(--border-width) solid var(--accordion-border-color)}details summary{line-height:1rem;list-style-type:none;cursor:pointer;transition:color var(--transition)}details summary:not([role]){color:var(--accordion-close-summary-color)}details summary::-webkit-details-marker{display:none}details summary::marker{display:none}details summary::-moz-list-bullet{list-style-type:none}details summary::after{display:block;width:1rem;height:1rem;-webkit-margin-start:calc(var(--spacing,1rem) * 0.5);margin-inline-start:calc(var(--spacing,1rem) * .5);float:right;transform:rotate(-90deg);background-image:var(--icon-chevron);background-position:right center;background-size:1rem auto;background-repeat:no-repeat;content:"";transition:transform var(--transition)}details summary:focus{outline:0}details summary:focus:not([role=button]){color:var(--accordion-active-summary-color)}details summary[role=button]{width:100%;text-align:left}details summary[role=button]::after{height:calc(1rem * var(--line-height,1.5));background-image:var(--icon-chevron-button)}details summary[role=button]:not(.outline).contrast::after{background-image:var(--icon-chevron-button-inverse)}details[open]>summary{margin-bottom:calc(var(--spacing))}details[open]>summary:not([role]):not(:focus){color:var(--accordion-open-summary-color)}details[open]>summary::after{transform:rotate(0)}[dir=rtl] details summary{text-align:right}[dir=rtl] details summary::after{float:left;background-position:left center}article{margin:var(--block-spacing-vertical) 0;padding:var(--block-spacing-vertical) var(--block-spacing-horizontal);border-radius:var(--border-radius);background:var(--card-background-color);box-shadow:var(--card-box-shadow)}article>footer,article>header{margin-right:calc(var(--block-spacing-horizontal) * -1);margin-left:calc(var(--block-spacing-horizontal) * -1);padding:calc(var(--block-spacing-vertical) * .66) var(--block-spacing-horizontal);background-color:var(--card-sectionning-background-color)}article>header{margin-top:calc(var(--block-spacing-vertical) * -1);margin-bottom:var(--block-spacing-vertical);border-bottom:var(--border-width) solid var(--card-border-color);border-top-right-radius:var(--border-radius);border-top-left-radius:var(--border-radius)}article>footer{margin-top:var(--block-spacing-vertical);margin-bottom:calc(var(--block-spacing-vertical) * -1);border-top:var(--border-width) solid var(--card-border-color);border-bottom-right-radius:var(--border-radius);border-bottom-left-radius:var(--border-radius)}:root{--scrollbar-width:0px}dialog{display:flex;z-index:999;position:fixed;top:0;right:0;bottom:0;left:0;align-items:center;justify-content:center;width:inherit;min-width:100%;height:inherit;min-height:100%;padding:var(--spacing);border:0;-webkit-backdrop-filter:var(--modal-overlay-backdrop-filter);backdrop-filter:var(--modal-overlay-backdrop-filter);background-color:var(--modal-overlay-background-color);color:var(--color)}dialog article{max-height:calc(100vh - var(--spacing) * 2);overflow:auto}@media (min-width:576px){dialog article{max-width:510px}}@media (min-width:768px){dialog article{max-width:700px}}dialog article>footer,dialog article>header{padding:calc(var(--block-spacing-vertical) * .5) var(--block-spacing-horizontal)}dialog article>header .close{margin:0;margin-left:var(--spacing);float:right}dialog article>footer{text-align:right}dialog article>footer [role=button]{margin-bottom:0}dialog article>footer [role=button]:not(:first-of-type){margin-left:calc(var(--spacing) * .5)}dialog article p:last-of-type{margin:0}dialog article .close{display:block;width:1rem;height:1rem;margin-top:calc(var(--block-spacing-vertical) * -.5);margin-bottom:var(--typography-spacing-vertical);margin-left:auto;background-image:var(--icon-close);background-position:center;background-size:auto 1rem;background-repeat:no-repeat;opacity:.5;transition:opacity var(--transition)}dialog article .close:is([aria-current],:hover,:active,:focus){opacity:1}dialog:not([open]),dialog[open=false]{display:none}.modal-is-open{padding-right:var(--scrollbar-width,0);overflow:hidden;pointer-events:none;touch-action:none}.modal-is-open dialog{pointer-events:auto}:where(.modal-is-opening,.modal-is-closing) dialog,:where(.modal-is-opening,.modal-is-closing) dialog>article{animation-duration:.2s;animation-timing-function:ease-in-out;animation-fill-mode:both}:where(.modal-is-opening,.modal-is-closing) dialog{animation-duration:.8s;animation-name:modal-overlay}:where(.modal-is-opening,.modal-is-closing) dialog>article{animation-delay:.2s;animation-name:modal}.modal-is-closing dialog,.modal-is-closing dialog>article{animation-delay:0s;animation-direction:reverse}@keyframes modal-overlay{from{-webkit-backdrop-filter:none;backdrop-filter:none;background-color:transparent}}@keyframes modal{from{transform:translateY(-100%);opacity:0}}:where(nav li)::before{float:left;content:""}nav,nav ul{display:flex}nav{justify-content:space-between}nav ol,nav ul{align-items:center;margin-bottom:0;padding:0;list-style:none}nav ol:first-of-type,nav ul:first-of-type{margin-left:calc(var(--nav-element-spacing-horizontal) * -1)}nav ol:last-of-type,nav ul:last-of-type{margin-right:calc(var(--nav-element-spacing-horizontal) * -1)}nav li{display:inline-block;margin:0;padding:var(--nav-element-spacing-vertical) var(--nav-element-spacing-horizontal)}nav li>*{--spacing:0}nav :where(a,[role=link]){display:inline-block;margin:calc(var(--nav-link-spacing-vertical) * -1) calc(var(--nav-link-spacing-horizontal) * -1);padding:var(--nav-link-spacing-vertical) var(--nav-link-spacing-horizontal);border-radius:var(--border-radius);text-decoration:none}nav :where(a,[role=link]):is([aria-current],:hover,:active,:focus){text-decoration:none}nav[aria-label=breadcrumb]{align-items:center;justify-content:start}nav[aria-label=breadcrumb] ul li:not(:first-child){-webkit-margin-start:var(--nav-link-spacing-horizontal);margin-inline-start:var(--nav-link-spacing-horizontal)}nav[aria-label=breadcrumb] ul li:not(:last-child) ::after{position:absolute;width:calc(var(--nav-link-spacing-horizontal) * 2);-webkit-margin-start:calc(var(--nav-link-spacing-horizontal)/ 2);margin-inline-start:calc(var(--nav-link-spacing-horizontal)/ 2);content:"/";color:var(--muted-color);text-align:center}nav[aria-label=breadcrumb] a[aria-current]{background-color:transparent;color:inherit;text-decoration:none;pointer-events:none}nav [role=button]{margin-right:inherit;margin-left:inherit;padding:var(--nav-link-spacing-vertical) var(--nav-link-spacing-horizontal)}aside li,aside nav,aside ol,aside ul{display:block}aside li{padding:calc(var(--nav-element-spacing-vertical) * .5) var(--nav-element-spacing-horizontal)}aside li a{display:block}aside li [role=button]{margin:inherit}[dir=rtl] nav[aria-label=breadcrumb] ul li:not(:last-child) ::after{content:"\\"}progress{display:inline-block;vertical-align:baseline}progress{-webkit-appearance:none;-moz-appearance:none;display:inline-block;appearance:none;width:100%;height:.5rem;margin-bottom:calc(var(--spacing) * .5);overflow:hidden;border:0;border-radius:var(--border-radius);background-color:var(--progress-background-color);color:var(--progress-color)}progress::-webkit-progress-bar{border-radius:var(--border-radius);background:0 0}progress[value]::-webkit-progress-value{background-color:var(--progress-color)}progress::-moz-progress-bar{background-color:var(--progress-color)}@media (prefers-reduced-motion:no-preference){progress:indeterminate{background:var(--progress-background-color) linear-gradient(to right,var(--progress-color) 30%,var(--progress-background-color) 30%) top left/150% 150% no-repeat;animation:progress-indeterminate 1s linear infinite}progress:indeterminate[value]::-webkit-progress-value{background-color:transparent}progress:indeterminate::-moz-progress-bar{background-color:transparent}}@media (prefers-reduced-motion:no-preference){[dir=rtl] progress:indeterminate{animation-direction:reverse}}@keyframes progress-indeterminate{0%{background-position:200% 0}100%{background-position:-200% 0}}details[role=list],li[role=list]{position:relative}details[role=list] summary+ul,li[role=list]>ul{display:flex;z-index:99;position:absolute;top:auto;right:0;left:0;flex-direction:column;margin:0;padding:0;border:var(--border-width) solid var(--dropdown-border-color);border-radius:var(--border-radius);border-top-right-radius:0;border-top-left-radius:0;background-color:var(--dropdown-background-color);box-shadow:var(--card-box-shadow);color:var(--dropdown-color);white-space:nowrap}details[role=list] summary+ul li,li[role=list]>ul li{width:100%;margin-bottom:0;padding:calc(var(--form-element-spacing-vertical) * .5) var(--form-element-spacing-horizontal);list-style:none}details[role=list] summary+ul li:first-of-type,li[role=list]>ul li:first-of-type{margin-top:calc(var(--form-element-spacing-vertical) * .5)}details[role=list] summary+ul li:last-of-type,li[role=list]>ul li:last-of-type{margin-bottom:calc(var(--form-element-spacing-vertical) * .5)}details[role=list] summary+ul li a,li[role=list]>ul li a{display:block;margin:calc(var(--form-element-spacing-vertical) * -.5) calc(var(--form-element-spacing-horizontal) * -1);padding:calc(var(--form-element-spacing-vertical) * .5) var(--form-element-spacing-horizontal);overflow:hidden;color:var(--dropdown-color);text-decoration:none;text-overflow:ellipsis}details[role=list] summary+ul li a:hover,li[role=list]>ul li a:hover{background-color:var(--dropdown-hover-background-color)}details[role=list] summary::after,li[role=list]>a::after{display:block;width:1rem;height:calc(1rem * var(--line-height,1.5));-webkit-margin-start:0.5rem;margin-inline-start:.5rem;float:right;transform:rotate(0);background-position:right center;background-size:1rem auto;background-repeat:no-repeat;content:""}details[role=list]{padding:0;border-bottom:none}details[role=list] summary{margin-bottom:0}details[role=list] summary:not([role]){height:calc(1rem * var(--line-height) + var(--form-element-spacing-vertical) * 2 + var(--border-width) * 2);padding:var(--form-element-spacing-vertical) var(--form-element-spacing-horizontal);border:var(--border-width) solid var(--form-element-border-color);border-radius:var(--border-radius);background-color:var(--form-element-background-color);color:var(--form-element-placeholder-color);line-height:inherit;cursor:pointer;transition:background-color var(--transition),border-color var(--transition),color var(--transition),box-shadow var(--transition)}details[role=list] summary:not([role]):active,details[role=list] summary:not([role]):focus{border-color:var(--form-element-active-border-color);background-color:var(--form-element-active-background-color)}details[role=list] summary:not([role]):focus{box-shadow:0 0 0 var(--outline-width) var(--form-element-focus-color)}details[role=list][open] summary{border-bottom-right-radius:0;border-bottom-left-radius:0}details[role=list][open] summary::before{display:block;z-index:1;position:fixed;top:0;right:0;bottom:0;left:0;background:0 0;content:"";cursor:default}nav details[role=list] summary,nav li[role=list] a{display:flex;direction:ltr}nav details[role=list] summary+ul,nav li[role=list]>ul{min-width:-moz-fit-content;min-width:fit-content;border-radius:var(--border-radius)}nav details[role=list] summary+ul li a,nav li[role=list]>ul li a{border-radius:0}nav details[role=list] summary,nav details[role=list] summary:not([role]){height:auto;padding:var(--nav-link-spacing-vertical) var(--nav-link-spacing-horizontal)}nav details[role=list][open] summary{border-radius:var(--border-radius)}nav details[role=list] summary+ul{margin-top:var(--outline-width);-webkit-margin-start:0;margin-inline-start:0}nav details[role=list] summary[role=link]{margin-bottom:calc(var(--nav-link-spacing-vertical) * -1);line-height:var(--line-height)}nav details[role=list] summary[role=link]+ul{margin-top:calc(var(--nav-link-spacing-vertical) + var(--outline-width));-webkit-margin-start:calc(var(--nav-link-spacing-horizontal) * -1);margin-inline-start:calc(var(--nav-link-spacing-horizontal) * -1)}li[role=list] a:active~ul,li[role=list] a:focus~ul,li[role=list]:hover>ul{display:flex}li[role=list]>ul{display:none;margin-top:calc(var(--nav-link-spacing-vertical) + var(--outline-width));-webkit-margin-start:calc(var(--nav-element-spacing-horizontal) - var(--nav-link-spacing-horizontal));margin-inline-start:calc(var(--nav-element-spacing-horizontal) - var(--nav-link-spacing-horizontal))}li[role=list]>a::after{background-image:var(--icon-chevron)}label>details[role=list]{margin-top:calc(var(--spacing) * .25);margin-bottom:var(--spacing)}[aria-busy=true]{cursor:progress}[aria-busy=true]:not(input,select,textarea,html)::before{display:inline-block;width:1em;height:1em;border:.1875em solid currentColor;border-radius:1em;border-right-color:transparent;content:"";vertical-align:text-bottom;vertical-align:-.125em;animation:spinner .75s linear infinite;opacity:var(--loading-spinner-opacity)}[aria-busy=true]:not(input,select,textarea,html):not(:empty)::before{margin-right:calc(var(--spacing) * .5);margin-left:0;-webkit-margin-start:0;margin-inline-start:0;-webkit-margin-end:calc(var(--spacing) * .5);margin-inline-end:calc(var(--spacing) * .5)}[aria-busy=true]:not(input,select,textarea,html):empty{text-align:center}a[aria-busy=true],button[aria-busy=true],input[type=button][aria-busy=true],input[type=reset][aria-busy=true],input[type=submit][aria-busy=true]{pointer-events:none}@keyframes spinner{to{transform:rotate(360deg)}}[data-tooltip]{position:relative}[data-tooltip]:not(a,button,input){border-bottom:1px dotted;text-decoration:none;cursor:help}[data-tooltip]::after,[data-tooltip]::before,[data-tooltip][data-placement=top]::after,[data-tooltip][data-placement=top]::before{display:block;z-index:99;position:absolute;bottom:100%;left:50%;padding:.25rem .5rem;overflow:hidden;transform:translate(-50%,-.25rem);border-radius:var(--border-radius);background:var(--tooltip-background-color);content:attr(data-tooltip);color:var(--tooltip-color);font-style:normal;font-weight:var(--font-weight);font-size:.875rem;text-decoration:none;text-overflow:ellipsis;white-space:nowrap;opacity:0;pointer-events:none}[data-tooltip]::after,[data-tooltip][data-placement=top]::after{padding:0;transform:translate(-50%,0);border-top:.3rem solid;border-right:.3rem solid transparent;border-left:.3rem solid transparent;border-radius:0;background-color:transparent;content:"";color:var(--tooltip-background-color)}[data-tooltip][data-placement=bottom]::after,[data-tooltip][data-placement=bottom]::before{top:100%;bottom:auto;transform:translate(-50%,.25rem)}[data-tooltip][data-placement=bottom]:after{transform:translate(-50%,-.3rem);border:.3rem solid transparent;border-bottom:.3rem solid}[data-tooltip][data-placement=left]::after,[data-tooltip][data-placement=left]::before{top:50%;right:100%;bottom:auto;left:auto;transform:translate(-.25rem,-50%)}[data-tooltip][data-placement=left]:after{transform:translate(.3rem,-50%);border:.3rem solid transparent;border-left:.3rem solid}[data-tooltip][data-placement=right]::after,[data-tooltip][data-placement=right]::before{top:50%;right:auto;bottom:auto;left:100%;transform:translate(.25rem,-50%)}[data-tooltip][data-placement=right]:after{transform:translate(-.3rem,-50%);border:.3rem solid transparent;border-right:.3rem solid}[data-tooltip]:focus::after,[data-tooltip]:focus::before,[data-tooltip]:hover::after,[data-tooltip]:hover::before{opacity:1}@media (hover:hover) and (pointer:fine){[data-tooltip]:hover::after,[data-tooltip]:hover::before,[data-tooltip][data-placement=bottom]:focus::after,[data-tooltip][data-placement=bottom]:focus::before,[data-tooltip][data-placement=bottom]:hover [data-tooltip]:focus::after,[data-tooltip][data-placement=bottom]:hover [data-tooltip]:focus::before{animation-duration:.2s;animation-name:tooltip-slide-top}[data-tooltip]:hover::after,[data-tooltip][data-placement=bottom]:focus::after,[data-tooltip][data-placement=bottom]:hover [data-tooltip]:focus::after{animation-name:tooltip-caret-slide-top}[data-tooltip][data-placement=bottom]:focus::after,[data-tooltip][data-placement=bottom]:focus::before,[data-tooltip][data-placement=bottom]:hover::after,[data-tooltip][data-placement=bottom]:hover::before{animation-duration:.2s;animation-name:tooltip-slide-bottom}[data-tooltip][data-placement=bottom]:focus::after,[data-tooltip][data-placement=bottom]:hover::after{animation-name:tooltip-caret-slide-bottom}[data-tooltip][data-placement=left]:focus::after,[data-tooltip][data-placement=left]:focus::before,[data-tooltip][data-placement=left]:hover::after,[data-tooltip][data-placement=left]:hover::before{animation-duration:.2s;animation-name:tooltip-slide-left}[data-tooltip][data-placement=left]:focus::after,[data-tooltip][data-placement=left]:hover::after{animation-name:tooltip-caret-slide-left}[data-tooltip][data-placement=right]:focus::after,[data-tooltip][data-placement=right]:focus::before,[data-tooltip][data-placement=right]:hover::after,[data-tooltip][data-placement=right]:hover::before{animation-duration:.2s;animation-name:tooltip-slide-right}[data-tooltip][data-placement=right]:focus::after,[data-tooltip][data-placement=right]:hover::after{animation-name:tooltip-caret-slide-right}}@keyframes tooltip-slide-top{from{transform:translate(-50%,.75rem);opacity:0}to{transform:translate(-50%,-.25rem);opacity:1}}@keyframes tooltip-caret-slide-top{from{opacity:0}50%{transform:translate(-50%,-.25rem);opacity:0}to{transform:translate(-50%,0);opacity:1}}@keyframes tooltip-slide-bottom{from{transform:translate(-50%,-.75rem);opacity:0}to{transform:translate(-50%,.25rem);opacity:1}}@keyframes tooltip-caret-slide-bottom{from{opacity:0}50%{transform:translate(-50%,-.5rem);opacity:0}to{transform:translate(-50%,-.3rem);opacity:1}}@keyframes tooltip-slide-left{from{transform:translate(.75rem,-50%);opacity:0}to{transform:translate(-.25rem,-50%);opacity:1}}@keyframes tooltip-caret-slide-left{from{opacity:0}50%{transform:translate(.05rem,-50%);opacity:0}to{transform:translate(.3rem,-50%);opacity:1}}@keyframes tooltip-slide-right{from{transform:translate(-.75rem,-50%);opacity:0}to{transform:translate(.25rem,-50%);opacity:1}}@keyframes tooltip-caret-slide-right{from{opacity:0}50%{transform:translate(-.05rem,-50%);opacity:0}to{transform:translate(-.3rem,-50%);opacity:1}}[aria-controls]{cursor:pointer}[aria-disabled=true],[disabled]{cursor:not-allowed}[aria-hidden=false][hidden]{display:initial}[aria-hidden=false][hidden]:not(:focus){clip:rect(0,0,0,0);position:absolute}[tabindex],a,area,button,input,label,select,summary,textarea{-ms-touch-action:manipulation}[dir=rtl]{direction:rtl}@media (prefers-reduced-motion:reduce){:not([aria-busy=true]),:not([aria-busy=true])::after,:not([aria-busy=true])::before{background-attachment:initial!important;animation-duration:1ms!important;animation-delay:-1ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-delay:0s!important;transition-duration:0s!important}}
+/*# sourceMappingURL=pico.min.css.map */
diff --git a/src/interface/desktop/assets/purify.min.js b/src/interface/desktop/assets/purify.min.js
new file mode 100644
index 0000000000000000000000000000000000000000..40e13ee956aa31ac11db552c443577cb65cda3fc
--- /dev/null
+++ b/src/interface/desktop/assets/purify.min.js
@@ -0,0 +1,3 @@
+/*! @license DOMPurify 3.1.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.2/LICENSE */
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,(function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:o,getOwnPropertyDescriptor:r}=Object;let{freeze:i,seal:a,create:l}=Object,{apply:c,construct:s}="undefined"!=typeof Reflect&&Reflect;i||(i=function(e){return e}),a||(a=function(e){return e}),c||(c=function(e,t,n){return e.apply(t,n)}),s||(s=function(e,t){return new e(...t)});const u=b(Array.prototype.forEach),m=b(Array.prototype.pop),p=b(Array.prototype.push),f=b(String.prototype.toLowerCase),d=b(String.prototype.toString),h=b(String.prototype.match),g=b(String.prototype.replace),T=b(String.prototype.indexOf),_=b(String.prototype.trim),y=b(Object.prototype.hasOwnProperty),E=b(RegExp.prototype.test),A=(N=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n1?n-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:f;t&&t(e,null);let i=o.length;for(;i--;){let t=o[i];if("string"==typeof t){const e=r(t);e!==t&&(n(o)||(o[i]=e),t=e)}e[t]=!0}return e}function R(e){for(let t=0;t/gm),B=a(/\${[\w\W]*}/gm),W=a(/^data-[\-\w.\u00B7-\uFFFF]/),G=a(/^aria-[\-\w]+$/),Y=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),j=a(/^(?:\w+script|data):/i),X=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),q=a(/^html$/i),$=a(/^[a-z][.\w]*(-[.\w]+)+$/i);var K=Object.freeze({__proto__:null,MUSTACHE_EXPR:H,ERB_EXPR:z,TMPLIT_EXPR:B,DATA_ATTR:W,ARIA_ATTR:G,IS_ALLOWED_URI:Y,IS_SCRIPT_OR_DATA:j,ATTR_WHITESPACE:X,DOCTYPE_NAME:q,CUSTOM_ELEMENT:$});const V=function(){return"undefined"==typeof window?null:window},Z=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}};var J=function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:V();const o=e=>t(e);if(o.version="3.1.2",o.removed=[],!n||!n.document||9!==n.document.nodeType)return o.isSupported=!1,o;let{document:r}=n;const a=r,c=a.currentScript,{DocumentFragment:s,HTMLTemplateElement:N,Node:b,Element:R,NodeFilter:H,NamedNodeMap:z=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:B,DOMParser:W,trustedTypes:G}=n,j=R.prototype,X=C(j,"cloneNode"),$=C(j,"nextSibling"),J=C(j,"childNodes"),Q=C(j,"parentNode");if("function"==typeof N){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let ee,te="";const{implementation:ne,createNodeIterator:oe,createDocumentFragment:re,getElementsByTagName:ie}=r,{importNode:ae}=a;let le={};o.isSupported="function"==typeof e&&"function"==typeof Q&&ne&&void 0!==ne.createHTMLDocument;const{MUSTACHE_EXPR:ce,ERB_EXPR:se,TMPLIT_EXPR:ue,DATA_ATTR:me,ARIA_ATTR:pe,IS_SCRIPT_OR_DATA:fe,ATTR_WHITESPACE:de,CUSTOM_ELEMENT:he}=K;let{IS_ALLOWED_URI:ge}=K,Te=null;const _e=S({},[...v,...L,...D,...x,...M]);let ye=null;const Ee=S({},[...I,...U,...P,...F]);let Ae=Object.seal(l(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ne=null,be=null,Se=!0,Re=!0,we=!1,Ce=!0,ve=!1,Le=!0,De=!1,Oe=!1,xe=!1,ke=!1,Me=!1,Ie=!1,Ue=!0,Pe=!1;const Fe="user-content-";let He=!0,ze=!1,Be={},We=null;const Ge=S({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ye=null;const je=S({},["audio","video","img","source","image","track"]);let Xe=null;const qe=S({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),$e="http://www.w3.org/1998/Math/MathML",Ke="http://www.w3.org/2000/svg",Ve="http://www.w3.org/1999/xhtml";let Ze=Ve,Je=!1,Qe=null;const et=S({},[$e,Ke,Ve],d);let tt=null;const nt=["application/xhtml+xml","text/html"],ot="text/html";let rt=null,it=null;const at=255,lt=r.createElement("form"),ct=function(e){return e instanceof RegExp||e instanceof Function},st=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!it||it!==e){if(e&&"object"==typeof e||(e={}),e=w(e),tt=-1===nt.indexOf(e.PARSER_MEDIA_TYPE)?ot:e.PARSER_MEDIA_TYPE,rt="application/xhtml+xml"===tt?d:f,Te=y(e,"ALLOWED_TAGS")?S({},e.ALLOWED_TAGS,rt):_e,ye=y(e,"ALLOWED_ATTR")?S({},e.ALLOWED_ATTR,rt):Ee,Qe=y(e,"ALLOWED_NAMESPACES")?S({},e.ALLOWED_NAMESPACES,d):et,Xe=y(e,"ADD_URI_SAFE_ATTR")?S(w(qe),e.ADD_URI_SAFE_ATTR,rt):qe,Ye=y(e,"ADD_DATA_URI_TAGS")?S(w(je),e.ADD_DATA_URI_TAGS,rt):je,We=y(e,"FORBID_CONTENTS")?S({},e.FORBID_CONTENTS,rt):Ge,Ne=y(e,"FORBID_TAGS")?S({},e.FORBID_TAGS,rt):{},be=y(e,"FORBID_ATTR")?S({},e.FORBID_ATTR,rt):{},Be=!!y(e,"USE_PROFILES")&&e.USE_PROFILES,Se=!1!==e.ALLOW_ARIA_ATTR,Re=!1!==e.ALLOW_DATA_ATTR,we=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ce=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,ve=e.SAFE_FOR_TEMPLATES||!1,Le=!1!==e.SAFE_FOR_XML,De=e.WHOLE_DOCUMENT||!1,ke=e.RETURN_DOM||!1,Me=e.RETURN_DOM_FRAGMENT||!1,Ie=e.RETURN_TRUSTED_TYPE||!1,xe=e.FORCE_BODY||!1,Ue=!1!==e.SANITIZE_DOM,Pe=e.SANITIZE_NAMED_PROPS||!1,He=!1!==e.KEEP_CONTENT,ze=e.IN_PLACE||!1,ge=e.ALLOWED_URI_REGEXP||Y,Ze=e.NAMESPACE||Ve,Ae=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ct(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ae.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ct(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ae.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ae.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ve&&(Re=!1),Me&&(ke=!0),Be&&(Te=S({},M),ye=[],!0===Be.html&&(S(Te,v),S(ye,I)),!0===Be.svg&&(S(Te,L),S(ye,U),S(ye,F)),!0===Be.svgFilters&&(S(Te,D),S(ye,U),S(ye,F)),!0===Be.mathMl&&(S(Te,x),S(ye,P),S(ye,F))),e.ADD_TAGS&&(Te===_e&&(Te=w(Te)),S(Te,e.ADD_TAGS,rt)),e.ADD_ATTR&&(ye===Ee&&(ye=w(ye)),S(ye,e.ADD_ATTR,rt)),e.ADD_URI_SAFE_ATTR&&S(Xe,e.ADD_URI_SAFE_ATTR,rt),e.FORBID_CONTENTS&&(We===Ge&&(We=w(We)),S(We,e.FORBID_CONTENTS,rt)),He&&(Te["#text"]=!0),De&&S(Te,["html","head","body"]),Te.table&&(S(Te,["tbody"]),delete Ne.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw A('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw A('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ee=e.TRUSTED_TYPES_POLICY,te=ee.createHTML("")}else void 0===ee&&(ee=Z(G,c)),null!==ee&&"string"==typeof te&&(te=ee.createHTML(""));i&&i(e),it=e}},ut=S({},["mi","mo","mn","ms","mtext"]),mt=S({},["foreignobject","annotation-xml"]),pt=S({},["title","style","font","a","script"]),ft=S({},[...L,...D,...O]),dt=S({},[...x,...k]),ht=function(e){let t=Q(e);t&&t.tagName||(t={namespaceURI:Ze,tagName:"template"});const n=f(e.tagName),o=f(t.tagName);return!!Qe[e.namespaceURI]&&(e.namespaceURI===Ke?t.namespaceURI===Ve?"svg"===n:t.namespaceURI===$e?"svg"===n&&("annotation-xml"===o||ut[o]):Boolean(ft[n]):e.namespaceURI===$e?t.namespaceURI===Ve?"math"===n:t.namespaceURI===Ke?"math"===n&&mt[o]:Boolean(dt[n]):e.namespaceURI===Ve?!(t.namespaceURI===Ke&&!mt[o])&&(!(t.namespaceURI===$e&&!ut[o])&&(!dt[n]&&(pt[n]||!ft[n]))):!("application/xhtml+xml"!==tt||!Qe[e.namespaceURI]))},gt=function(e){p(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},Tt=function(e,t){try{p(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){p(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!ye[e])if(ke||Me)try{gt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},_t=function(e){let t=null,n=null;if(xe)e=""+e;else{const t=h(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===tt&&Ze===Ve&&(e=''+e+"");const o=ee?ee.createHTML(e):e;if(Ze===Ve)try{t=(new W).parseFromString(o,tt)}catch(e){}if(!t||!t.documentElement){t=ne.createDocument(Ze,"template",null);try{t.documentElement.innerHTML=Je?te:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),Ze===Ve?ie.call(t,De?"html":"body")[0]:De?t.documentElement:i},yt=function(e){return oe.call(e.ownerDocument||e,e,H.SHOW_ELEMENT|H.SHOW_COMMENT|H.SHOW_TEXT|H.SHOW_PROCESSING_INSTRUCTION|H.SHOW_CDATA_SECTION,null)},Et=function(e){return e instanceof B&&(void 0!==e.__depth&&"number"!=typeof e.__depth||void 0!==e.__removalCount&&"number"!=typeof e.__removalCount||"string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof z)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},At=function(e){return"function"==typeof b&&e instanceof b},Nt=function(e,t,n){le[e]&&u(le[e],(e=>{e.call(o,t,n,it)}))},bt=function(e){let t=null;if(Nt("beforeSanitizeElements",e,null),Et(e))return gt(e),!0;const n=rt(e.nodeName);if(Nt("uponSanitizeElement",e,{tagName:n,allowedTags:Te}),e.hasChildNodes()&&!At(e.firstElementChild)&&E(/<[/\w]/g,e.innerHTML)&&E(/<[/\w]/g,e.textContent))return gt(e),!0;if(7===e.nodeType)return gt(e),!0;if(Le&&8===e.nodeType&&E(/<[/\w]/g,e.data))return gt(e),!0;if(!Te[n]||Ne[n]){if(!Ne[n]&&Rt(n)){if(Ae.tagNameCheck instanceof RegExp&&E(Ae.tagNameCheck,n))return!1;if(Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(n))return!1}if(He&&!We[n]){const t=Q(e)||e.parentNode,n=J(e)||e.childNodes;if(n&&t){for(let o=n.length-1;o>=0;--o){const r=X(n[o],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,$(e))}}}return gt(e),!0}return e instanceof R&&!ht(e)?(gt(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!E(/<\/no(script|embed|frames)/i,e.innerHTML)?(ve&&3===e.nodeType&&(t=e.textContent,u([ce,se,ue],(e=>{t=g(t,e," ")})),e.textContent!==t&&(p(o.removed,{element:e.cloneNode()}),e.textContent=t)),Nt("afterSanitizeElements",e,null),!1):(gt(e),!0)},St=function(e,t,n){if(Ue&&("id"===t||"name"===t)&&(n in r||n in lt))return!1;if(Re&&!be[t]&&E(me,t));else if(Se&&E(pe,t));else if(!ye[t]||be[t]){if(!(Rt(e)&&(Ae.tagNameCheck instanceof RegExp&&E(Ae.tagNameCheck,e)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(e))&&(Ae.attributeNameCheck instanceof RegExp&&E(Ae.attributeNameCheck,t)||Ae.attributeNameCheck instanceof Function&&Ae.attributeNameCheck(t))||"is"===t&&Ae.allowCustomizedBuiltInElements&&(Ae.tagNameCheck instanceof RegExp&&E(Ae.tagNameCheck,n)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(n))))return!1}else if(Xe[t]);else if(E(ge,g(n,de,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==T(n,"data:")||!Ye[e]){if(we&&!E(fe,g(n,de,"")));else if(n)return!1}else;return!0},Rt=function(e){return"annotation-xml"!==e&&h(e,he)},wt=function(e){Nt("beforeSanitizeAttributes",e,null);const{attributes:t}=e;if(!t)return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ye};let r=t.length;for(;r--;){const i=t[r],{name:a,namespaceURI:l,value:c}=i,s=rt(a);let p="value"===a?c:_(c);if(n.attrName=s,n.attrValue=p,n.keepAttr=!0,n.forceKeepAttr=void 0,Nt("uponSanitizeAttribute",e,n),p=n.attrValue,n.forceKeepAttr)continue;if(Tt(a,e),!n.keepAttr)continue;if(!Ce&&E(/\/>/i,p)){Tt(a,e);continue}ve&&u([ce,se,ue],(e=>{p=g(p,e," ")}));const f=rt(e.nodeName);if(St(f,s,p)){if(!Pe||"id"!==s&&"name"!==s||(Tt(a,e),p=Fe+p),ee&&"object"==typeof G&&"function"==typeof G.getAttributeType)if(l);else switch(G.getAttributeType(f,s)){case"TrustedHTML":p=ee.createHTML(p);break;case"TrustedScriptURL":p=ee.createScriptURL(p)}try{l?e.setAttributeNS(l,a,p):e.setAttribute(a,p),m(o.removed)}catch(e){}}}Nt("afterSanitizeAttributes",e,null)},Ct=function e(t){let n=null;const o=yt(t);for(Nt("beforeSanitizeShadowDOM",t,null);n=o.nextNode();){if(Nt("uponSanitizeShadowNode",n,null),bt(n))continue;const t=Q(n);1===n.nodeType&&(t&&t.__depth?n.__depth=(n.__removalCount||0)+t.__depth+1:n.__depth=1),n.__depth>=at&>(n),n.content instanceof s&&(n.content.__depth=n.__depth,e(n.content)),wt(n)}Nt("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,i=null,l=null;if(Je=!e,Je&&(e="\x3c!--\x3e"),"string"!=typeof e&&!At(e)){if("function"!=typeof e.toString)throw A("toString is not a function");if("string"!=typeof(e=e.toString()))throw A("dirty is not a string, aborting")}if(!o.isSupported)return e;if(Oe||st(t),o.removed=[],"string"==typeof e&&(ze=!1),ze){if(e.nodeName){const t=rt(e.nodeName);if(!Te[t]||Ne[t])throw A("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof b)n=_t("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r);else{if(!ke&&!ve&&!De&&-1===e.indexOf("<"))return ee&&Ie?ee.createHTML(e):e;if(n=_t(e),!n)return ke?null:Ie?te:""}n&&xe&>(n.firstChild);const c=yt(ze?e:n);for(;i=c.nextNode();){if(bt(i))continue;const e=Q(i);1===i.nodeType&&(e&&e.__depth?i.__depth=(i.__removalCount||0)+e.__depth+1:i.__depth=1),i.__depth>=at&>(i),i.content instanceof s&&(i.content.__depth=i.__depth,Ct(i.content)),wt(i)}if(ze)return e;if(ke){if(Me)for(l=re.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(ye.shadowroot||ye.shadowrootmode)&&(l=ae.call(a,l,!0)),l}let m=De?n.outerHTML:n.innerHTML;return De&&Te["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&E(q,n.ownerDocument.doctype.name)&&(m="\n"+m),ve&&u([ce,se,ue],(e=>{m=g(m,e," ")})),ee&&Ie?ee.createHTML(m):m},o.setConfig=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};st(e),Oe=!0},o.clearConfig=function(){it=null,Oe=!1},o.isValidAttribute=function(e,t,n){it||st({});const o=rt(e),r=rt(t);return St(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&(le[e]=le[e]||[],p(le[e],t))},o.removeHook=function(e){if(le[e])return m(le[e])},o.removeHooks=function(e){le[e]&&(le[e]=[])},o.removeAllHooks=function(){le={}},o}();return J}));
+//# sourceMappingURL=purify.min.js.map
diff --git a/src/interface/desktop/assets/three.min.js b/src/interface/desktop/assets/three.min.js
new file mode 100644
index 0000000000000000000000000000000000000000..57018496b09058337581891a31a18b02f4b8aa22
--- /dev/null
+++ b/src/interface/desktop/assets/three.min.js
@@ -0,0 +1,991 @@
+// threejs.org/license
+'use strict';var THREE={REVISION:"77"};"function"===typeof define&&define.amd?define("three",THREE):"undefined"!==typeof exports&&"undefined"!==typeof module&&(module.exports=THREE);void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52));void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b,c,d){b=THREE.Math.euclideanModulo(b,1);c=THREE.Math.clamp(c,0,1);d=THREE.Math.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=
+/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){var d=
+parseFloat(c[1])/360,e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^\#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-d)/k+(cf&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=
+.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3);b=c.dot(d)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;return this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){this._x*=
+-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},
+multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,k=b._z,l=b._w;this._x=c*l+f*g+d*k-e*h;this._y=d*l+f*h+e*g-c*k;this._z=e*l+f*k+c*h-d*g;this._w=f*l-c*g-d*h-e*k;this.onChangeCallback();
+return this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=Math.sqrt(1-g*g);if(.001>Math.abs(h))return this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this;var k=Math.atan2(h,g),g=Math.sin((1-b)*k)/h,h=Math.sin(b*
+k)/h;this._w=f*g+this._w*h;this._x=c*g+this._x*h;this._y=d*g+this._y*h;this._z=e*g+this._z*h;this.onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=
+a;return this},onChangeCallback:function(){}};
+Object.assign(THREE.Quaternion,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],l=c[d+2];c=c[d+3];d=e[f+0];var n=e[f+1],p=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==n||l!==p){f=1-g;var m=h*d+k*n+l*p+c*e,q=0<=m?1:-1,r=1-m*m;r>Number.EPSILON&&(r=Math.sqrt(r),m=Math.atan2(r,m*q),f=Math.sin(f*m)/r,g=Math.sin(g*m)/r);q*=g;h=h*f+d*q;k=k*f+n*q;l=l*f+p*q;c=c*f+e*q;f===1-g&&(g=1/Math.sqrt(h*h+k*k+l*l+c*c),h*=g,k*=g,l*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=l;
+a[b+3]=c}});THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
+THREE.Vector2.prototype={constructor:THREE.Vector2,get width(){return this.x},set width(a){this.x=a},get height(){return this.y},set height(a){this.y=a},set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;
+case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},
+addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,
+this.y*=a):this.y=this.x=0;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a,b;return function(c,d){void 0===
+a&&(a=new THREE.Vector2,b=new THREE.Vector2);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);
+this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},
+distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},
+toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];return this},rotateAround:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=this.x-a.x,f=this.y-a.y;this.x=e*c-f*d+a.x;this.y=e*d+f*c+a.y;return this}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
+THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;
+case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,
+b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},
+multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a;return function(b){!1===b instanceof THREE.Euler&&
+console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");void 0===a&&(a=new THREE.Quaternion);return this.applyQuaternion(a.setFromEuler(b))}}(),applyAxisAngle:function(){var a;return function(b,c){void 0===a&&(a=new THREE.Quaternion);return this.applyQuaternion(a.setFromAxisAngle(b,c))}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},
+applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this},applyProjection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=
+a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,l=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-l*-f;this.y=k*a+b*-f+l*-e-h*-g;this.z=l*a+b*-g+h*-f-k*-e;return this},project:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld));return this.applyProjection(a)}}(),unproject:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix));return this.applyProjection(a)}}(),
+transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=
+Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3,b=new THREE.Vector3);a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y=
+Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=
+-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=
+(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b);var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;this.y=e*f-c*h;
+this.z=c*g-d*f;return this},projectOnVector:function(){var a,b;return function(c){void 0===a&&(a=new THREE.Vector3);a.copy(c).normalize();b=this.dot(a);return this.copy(a).multiplyScalar(b)}}(),projectOnPlane:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/
+Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(THREE.Math.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},setFromSpherical:function(a){var b=Math.sin(a.phi)*a.radius;this.x=b*Math.sin(a.theta);this.y=Math.cos(a.phi)*a.radius;this.z=b*Math.cos(a.theta);return this},setFromMatrixPosition:function(a){return this.setFromMatrixColumn(a,3)},setFromMatrixScale:function(a){var b=
+this.setFromMatrixColumn(a,0).length(),c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){if("number"===typeof a){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index ).");var c=a;a=b;b=c}return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+
+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];return this}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
+THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+
+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);
+this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=
+a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a,this.w*=a):this.w=this.z=this.y=this.x=0;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=
+a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2];b=a[6];var l=a[10];if(.01>Math.abs(d-g)&&.01>Math.abs(f-c)&&.01>
+Math.abs(k-b)){if(.1>Math.abs(d+g)&&.1>Math.abs(f+c)&&.1>Math.abs(k+b)&&.1>Math.abs(e+h+l-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;l=(l+1)/2;d=(d+g)/4;f=(f+c)/4;k=(k+b)/4;e>h&&e>l?.01>e?(b=0,d=c=.707106781):(b=Math.sqrt(e),c=d/b,d=f/b):h>l?.01>h?(b=.707106781,c=0,d=.707106781):(c=Math.sqrt(h),b=d/c,d=k/c):.01>l?(c=b=.707106781,d=0):(d=Math.sqrt(l),b=f/d,c=k/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d));.001>Math.abs(a)&&(a=1);this.x=(b-k)/
+a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+l-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));
+this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector4,b=new THREE.Vector4);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=
+Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*
+a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-
+this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+
+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];this.w=a.array[b+3];return this}};THREE.Euler=function(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||THREE.Euler.DefaultOrder};THREE.Euler.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");THREE.Euler.DefaultOrder="XYZ";
+THREE.Euler.prototype={constructor:THREE.Euler,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order},set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,
+this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=THREE.Math.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],k=e[5],l=e[9],n=e[2],p=e[6],e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-l,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(p,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(l,-1,1)),.99999>Math.abs(l)?
+(this._y=Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-n,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(p,-1,1)),.99999>Math.abs(p)?(this._y=Math.atan2(-n,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(n,-1,1)),.99999>Math.abs(n)?(this._x=Math.atan2(p,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-l,k),this._y=Math.atan2(-n,a)):(this._x=
+0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(p,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-l,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeRotationFromQuaternion(b);return this.setFromRotationMatrix(a,c,d)}}(),setFromVector3:function(a,
+b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new THREE.Quaternion;return function(b){a.setFromEuler(this);return this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;
+a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new THREE.Vector3(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};THREE.Line3=function(a,b){this.start=void 0!==a?a:new THREE.Vector3;this.end=void 0!==b?b:new THREE.Vector3};
+THREE.Line3.prototype={constructor:THREE.Line3,set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},center:function(a){return(a||new THREE.Vector3).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){return(a||new THREE.Vector3).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},
+at:function(a,b){var c=b||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);var e=b.dot(b),e=b.dot(a)/e;d&&(e=THREE.Math.clamp(e,0,1));return e}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);c=c||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a);
+this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}};THREE.Box2=function(a,b){this.min=void 0!==a?a:new THREE.Vector2(Infinity,Infinity);this.max=void 0!==b?b:new THREE.Vector2(-Infinity,-Infinity)};
+THREE.Box2.prototype={constructor:THREE.Box2,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y?!0:!1},getParameter:function(a,b){return(b||new THREE.Vector2).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.y
+this.max.y?!1:!0},clampPoint:function(a,b){return(b||new THREE.Vector2).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new THREE.Vector2;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&
+a.max.equals(this.max)}};THREE.Box3=function(a,b){this.min=void 0!==a?a:new THREE.Vector3(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};
+THREE.Box3.prototype={constructor:THREE.Box3,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromArray:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.length;he&&(e=l);n>f&&(f=n);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g)},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y||a.z<
+this.min.z||a.z>this.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z?!0:!1},getParameter:function(a,b){return(b||new THREE.Vector3).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y||a.max.z<
+this.min.z||a.min.z>this.max.z?!1:!0},intersectsSphere:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);this.clampPoint(b.center,a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){var b,c;0=a.constant},clampPoint:function(a,b){return(b||new THREE.Vector3).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new THREE.Vector3;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new THREE.Vector3;return function(b){b=b||new THREE.Sphere;b.center=this.center();b.radius=.5*this.size(a).length();return b}}(),
+intersect:function(a){this.min.max(a.min);this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];return function(b){if(this.isEmpty())return this;a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);
+a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&
+a.max.equals(this.max)}};THREE.Matrix3=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]);0this.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.elements.set(this.elements);c=1/g;var f=1/h,l=1/k;b.elements[0]*=c;b.elements[1]*=c;
+b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=l;b.elements[9]*=l;b.elements[10]*=l;d.setFromRotationMatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makeFrustum:function(a,b,c,d,e,f){var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a,b,c,d){a=c*Math.tan(THREE.Math.DEG2RAD*a*.5);var e=
+-a;return this.makeFrustum(e*b,a*b,e,a,c,d)},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),k=1/(c-d),l=1/(f-e);g[0]=2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((c+d)*k);g[2]=0;g[6]=0;g[10]=-2*l;g[14]=-((f+e)*l);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a){this.elements.set(a);return this},toArray:function(a,b){void 0===a&&(a=[]);
+void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}};THREE.Ray=function(a,b){this.origin=void 0!==a?a:new THREE.Vector3;this.direction=void 0!==b?b:new THREE.Vector3};
+THREE.Ray.prototype={constructor:THREE.Ray,set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,b){return(b||new THREE.Vector3).copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize();return this},recast:function(){var a=new THREE.Vector3;return function(b){this.origin.copy(this.at(b,
+a));return this}}(),closestPointToPoint:function(a,b){var c=b||new THREE.Vector3;c.subVectors(a,this.origin);var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new THREE.Vector3;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);
+return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),k=-this.direction.dot(b),l=c.dot(this.direction),n=-c.dot(b),p=c.lengthSq(),m=Math.abs(1-k*k),q;0=-q?e<=q?(h=1/m,d*=h,e*=h,k=d*(d+k*e+2*l)+e*(k*d+e+2*n)+p):(e=h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*
+n)+p):(e=-h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*n)+p):e<=-q?(d=Math.max(0,-(-k*h+l)),e=0f)return null;f=Math.sqrt(f-e);e=d-f;d+=f;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<=a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){var c=
+this.distanceToPlane(a);return null===c?null:this.at(c,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z;var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*=a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e;if(fg||e>d)return null;if(e>c||c!==c)c=e;if(gd?null:this.at(0<=c?c:d,b)},intersectsBox:function(){var a=new THREE.Vector3;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3,d=new THREE.Vector3;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);
+if(0f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a);this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}};
+THREE.Sphere=function(a,b){this.center=void 0!==a?a:new THREE.Vector3;this.radius=void 0!==b?b:0};
+THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new THREE.Box3;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).center(d);for(var e=0,f=0,g=b.length;f=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(this.center.dot(a.normal)-a.constant)<=this.radius},clampPoint:function(a,b){var c=
+this.center.distanceToSquared(a),d=b||new THREE.Vector3;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a=a||new THREE.Box3;a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&
+a.radius===this.radius}};THREE.Frustum=function(a,b,c,d,e,f){this.planes=[void 0!==a?a:new THREE.Plane,void 0!==b?b:new THREE.Plane,void 0!==c?c:new THREE.Plane,void 0!==d?d:new THREE.Plane,void 0!==e?e:new THREE.Plane,void 0!==f?f:new THREE.Plane]};
+THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],l=c[7],n=c[8],p=c[9],m=c[10],q=c[11],r=c[12],s=c[13],u=c[14],
+c=c[15];b[0].setComponents(f-a,l-g,q-n,c-r).normalize();b[1].setComponents(f+a,l+g,q+n,c+r).normalize();b[2].setComponents(f+d,l+h,q+p,c+s).normalize();b[3].setComponents(f-d,l-h,q-p,c-s).normalize();b[4].setComponents(f-e,l-k,q-m,c-u).normalize();b[5].setComponents(f+e,l+k,q+m,c+u).normalize();return this},intersectsObject:function(){var a=new THREE.Sphere;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),
+intersectsSprite:function(){var a=new THREE.Sphere;return function(b){a.center.set(0,0,0);a.radius=.7071067811865476;a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)e;e++){var f=d[e];a.x=0g&&0>f)return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}};THREE.Plane=function(a,b){this.normal=void 0!==a?a:new THREE.Vector3(1,0,0);this.constant=void 0!==b?b:0};
+THREE.Plane.prototype={constructor:THREE.Plane,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,
+c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,
+b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a,b){var c=this.distanceToPoint(a);return(b||new THREE.Vector3).copy(this.normal).multiplyScalar(c)},intersectLine:function(){var a=new THREE.Vector3;return function(b,c){var d=c||new THREE.Vector3,e=b.delta(a),f=this.normal.dot(e);if(0===f){if(0===this.distanceToPoint(b.start))return d.copy(b.start)}else return f=-(b.start.dot(this.normal)+this.constant)/f,0>f||1b&&0a&&0e;e++)8===e||13===e||18===e||23===e?b[e]="-":14===e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19===e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,
+d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead.");return Math.random()},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*
+(.5-Math.random())},degToRad:function(a){return a*THREE.Math.DEG2RAD},radToDeg:function(a){return a*THREE.Math.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nearestPowerOfTwo:function(a){return Math.pow(2,Math.round(Math.log(a)/Math.LN2))},nextPowerOfTwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++;return a}};
+THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,k,l,n,p,m;this.initFromArray=function(a){this.points=[];for(var b=0;bthis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:f+
+2;l=this.points[c[0]];n=this.points[c[1]];p=this.points[c[2]];m=this.points[c[3]];h=g*g;k=g*h;d.x=b(l.x,n.x,p.x,m.x,g,h,k);d.y=b(l.y,n.y,p.y,m.y,g,h,k);d.z=b(l.z,n.z,p.z,m.z,g,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a=b.x+b.y}}();
+THREE.Triangle.prototype={constructor:THREE.Triangle,set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},area:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,
+this.b);return.5*a.cross(b).length()}}(),midpoint:function(a){return(a||new THREE.Vector3).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return THREE.Triangle.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new THREE.Plane).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return THREE.Triangle.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return THREE.Triangle.containsPoint(a,this.a,this.b,this.c)},
+closestPointToPoint:function(){var a,b,c,d;return function(e,f){void 0===a&&(a=new THREE.Plane,b=[new THREE.Line3,new THREE.Line3,new THREE.Line3],c=new THREE.Vector3,d=new THREE.Vector3);var g=f||new THREE.Vector3,h=Infinity;a.setFromCoplanarPoints(this.a,this.b,this.c);a.projectPoint(e,c);if(!0===this.containsPoint(c))g.copy(c);else{b[0].set(this.a,this.b);b[1].set(this.b,this.c);b[2].set(this.c,this.a);for(var k=0;k=e)break a;else{f=b[1];a=e)break b}d=
+c;c=0}}for(;c>>1,ad;d++)if(e[d]===e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,
+1),c=0,g=this.faceVertexUvs.length;cb||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0c.parameterPositions[1]&&(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){var b=this.timeScale,c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0],b=b*d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.pause=!0:
+this.timeScale=b)}}return this._effectiveTimeScale=b},_updateTime:function(a){var b=this.time+a;if(0===a)return b;var c=this._clip.duration,d=this.loop,e=this._loopCount;if(d===THREE.LoopOnce)a:{if(-1===e&&(this.loopCount=0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else break a;this.clampWhenFinished?this.pause=!0:this.enabled=!1;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1})}else{d=d===THREE.LoopPingPong;-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,
+d)):this._setEndings(0===this.repetitions,!0,d));if(b>=c||0>b){var f=Math.floor(b/c),b=b-c*f,e=e+Math.abs(f),g=this.repetitions-e;0>g?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,b=0a,this._setEndings(a,!a,d)):this._setEndings(!1,!1,d),this._loopCount=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:f}))}if(d&&1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,
+b,c){var d=this._interpolantSettings;c?(d.endingStart=THREE.ZeroSlopeEnding,d.endingEnd=THREE.ZeroSlopeEnding):(d.endingStart=a?this.zeroSlopeAtStart?THREE.ZeroSlopeEnding:THREE.ZeroCurvatureEnding:THREE.WrapAroundEnding,d.endingEnd=b?this.zeroSlopeAtEnd?THREE.ZeroSlopeEnding:THREE.ZeroCurvatureEnding:THREE.WrapAroundEnding)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;
+f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}};THREE.AnimationClip=function(a,b,c){this.name=a;this.tracks=c;this.duration=void 0!==b?b:-1;this.uuid=THREE.Math.generateUUID();0>this.duration&&this.resetDuration();this.trim();this.optimize()};
+THREE.AnimationClip.prototype={constructor:THREE.AnimationClip,resetDuration:function(){for(var a=0,b=0,c=this.tracks.length;b!==c;++b)var d=this.tracks[b],a=Math.max(a,d.times[d.times.length-1]);this.duration=a},trim:function(){for(var a=0;a=c){var p=c++,m=b[p];d[m.uuid]=
+n;b[n]=m;d[l]=p;b[p]=k;k=0;for(l=f;k!==l;++k){var m=e[k],q=m[n];m[n]=m[p];m[p]=q}}}this.nCachedObjects_=c},uncache:function(a){for(var b=this._objects,c=b.length,d=this.nCachedObjects_,e=this._indicesByUUID,f=this._bindings,g=f.length,h=0,k=arguments.length;h!==k;++h){var l=arguments[h].uuid,n=e[l];if(void 0!==n)if(delete e[l],nb;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),d=this.getValueSize(),this.times=THREE.AnimationUtils.arraySlice(c,e,f),this.values=THREE.AnimationUtils.arraySlice(this.values,e*d,f*d);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("invalid value size in track",
+this),a=!1);var c=this.times,b=this.values,d=c.length;0===d&&(console.error("track is empty",this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("time is not a valid number",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("out of order keys",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&THREE.AnimationUtils.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("value is not a valid number",this,f,d);a=!1;break}return a},optimize:function(){for(var a=
+this.times,b=this.values,c=this.getValueSize(),d=1,e=1,f=a.length-1;e<=f;++e){var g=!1,h=a[e];if(h!==a[e+1]&&(1!==e||h!==h[0]))for(var k=e*c,l=k-c,n=k+c,h=0;h!==c;++h){var p=b[k+h];if(p!==b[l+h]||p!==b[n+h]){g=!0;break}}if(g){if(e!==d)for(a[d]=a[e],g=e*c,k=d*c,h=0;h!==c;++h)b[k+h]=b[g+h];++d}}d!==a.length&&(this.times=THREE.AnimationUtils.arraySlice(a,0,d),this.values=THREE.AnimationUtils.arraySlice(b,0,d*c));return this}};
+Object.assign(THREE.KeyframeTrack,{parse:function(a){if(void 0===a.type)throw Error("track type undefined, can not parse");var b=THREE.KeyframeTrack._getTrackTypeForValueTypeName(a.type);if(void 0===a.times){var c=[],d=[];THREE.AnimationUtils.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,a.times,a.values,a.interpolation)},toJSON:function(a){var b=a.constructor;if(void 0!==b.toJSON)b=b.toJSON(a);else{var b={name:a.name,times:THREE.AnimationUtils.convertArray(a.times,
+Array),values:THREE.AnimationUtils.convertArray(a.values,Array)},c=a.getInterpolation();c!==a.DefaultInterpolation&&(b.interpolation=c)}b.type=a.ValueTypeName;return b},_getTrackTypeForValueTypeName:function(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return THREE.NumberKeyframeTrack;case "vector":case "vector2":case "vector3":case "vector4":return THREE.VectorKeyframeTrack;case "color":return THREE.ColorKeyframeTrack;case "quaternion":return THREE.QuaternionKeyframeTrack;
+case "bool":case "boolean":return THREE.BooleanKeyframeTrack;case "string":return THREE.StringKeyframeTrack}throw Error("Unsupported typeName: "+a);}});THREE.PropertyBinding=function(a,b,c){this.path=b;this.parsedPath=c||THREE.PropertyBinding.parseTrackName(b);this.node=THREE.PropertyBinding.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a};
+THREE.PropertyBinding.prototype={constructor:THREE.PropertyBinding,getValue:function(a,b){this.bind();this.getValue(a,b)},setValue:function(a,b){this.bind();this.setValue(a,b)},bind:function(){var a=this.node,b=this.parsedPath,c=b.objectName,d=b.propertyName,e=b.propertyIndex;a||(this.node=a=THREE.PropertyBinding.findNode(this.rootNode,b.nodeName)||this.rootNode);this.getValue=this._getValue_unavailable;this.setValue=this._setValue_unavailable;if(a){if(c){var f=b.objectIndex;switch(c){case "materials":if(!a.material){console.error(" can not bind to material as node does not have a material",
+this);return}if(!a.material.materials){console.error(" can not bind to material.materials as node.material does not have a materials array",this);return}a=a.material.materials;break;case "bones":if(!a.skeleton){console.error(" can not bind to bones as node does not have a skeleton",this);return}a=a.skeleton.bones;for(c=0;cd&&this._mixBufferRegion(c,a,3*b,1-d,b);for(var d=b,f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);
+break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d,e){THREE.Quaternion.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}};
+THREE.BooleanKeyframeTrack=function(a,b,c){THREE.KeyframeTrack.call(this,a,b,c)};THREE.BooleanKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.BooleanKeyframeTrack,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:THREE.InterpolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});THREE.ColorKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
+THREE.ColorKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.ColorKeyframeTrack,ValueTypeName:"color"});THREE.NumberKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};THREE.NumberKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.NumberKeyframeTrack,ValueTypeName:"number"});THREE.QuaternionKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
+THREE.QuaternionKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.QuaternionKeyframeTrack,ValueTypeName:"quaternion",DefaultInterpolation:THREE.InterpolateLinear,InterpolantFactoryMethodLinear:function(a){return new THREE.QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:void 0});THREE.StringKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
+THREE.StringKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.StringKeyframeTrack,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:THREE.InterpolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});THREE.VectorKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
+THREE.VectorKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.VectorKeyframeTrack,ValueTypeName:"vector"});
+THREE.Audio=function(a){THREE.Object3D.call(this);this.type="Audio";this.context=a.context;this.source=this.context.createBufferSource();this.source.onended=this.onEnded.bind(this);this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]};
+THREE.Audio.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.Audio,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl=!1;this.sourceType="audioNode";this.source=a;this.connect();return this},setBuffer:function(a){this.source.buffer=a;this.sourceType="buffer";this.autoplay&&this.play();return this},play:function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");
+else{var a=this.context.createBufferSource();a.buffer=this.source.buffer;a.loop=this.source.loop;a.onended=this.source.onended;a.start(0,this.startTime);a.playbackRate.value=this.playbackRate;this.isPlaying=!0;this.source=a;return this.connect()}},pause:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.source.stop(),this.startTime=this.context.currentTime,this},stop:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");
+else return this.source.stop(),this.startTime=0,this},connect:function(){if(0k.opacity&&(k.transparent=!0);c.setTextures(h);return c.parse(k)}}()};
+THREE.Loader.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=this.handlers,c=0,d=b.length;cg;g++)m=v[k++],x=u[2*m],m=u[2*m+1],x=new THREE.Vector2(x,m),2!==g&&c.faceVertexUvs[d][h].push(x),0!==g&&c.faceVertexUvs[d][h+1].push(x);p&&(p=3*v[k++],q.normal.set(C[p++],C[p++],C[p]),s.normal.copy(q.normal));if(r)for(d=0;4>d;d++)p=3*v[k++],r=new THREE.Vector3(C[p++],C[p++],C[p]),2!==d&&q.vertexNormals.push(r),0!==d&&s.vertexNormals.push(r);
+n&&(n=v[k++],n=w[n],q.color.setHex(n),s.color.setHex(n));if(b)for(d=0;4>d;d++)n=v[k++],n=w[n],2!==d&&q.vertexColors.push(new THREE.Color(n)),0!==d&&s.vertexColors.push(new THREE.Color(n));c.faces.push(q);c.faces.push(s)}else{q=new THREE.Face3;q.a=v[k++];q.b=v[k++];q.c=v[k++];h&&(h=v[k++],q.materialIndex=h);h=c.faces.length;if(d)for(d=0;dg;g++)m=v[k++],x=u[2*m],m=u[2*m+1],x=new THREE.Vector2(x,m),c.faceVertexUvs[d][h].push(x);p&&(p=3*v[k++],q.normal.set(C[p++],
+C[p++],C[p]));if(r)for(d=0;3>d;d++)p=3*v[k++],r=new THREE.Vector3(C[p++],C[p++],C[p]),q.vertexNormals.push(r);n&&(n=v[k++],q.color.setHex(w[n]));if(b)for(d=0;3>d;d++)n=v[k++],q.vertexColors.push(new THREE.Color(w[n]));c.faces.push(q)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;dthis.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);0a.x||1a.x?0:1;break;case THREE.MirroredRepeatWrapping:1===Math.abs(Math.floor(a.x)%2)?a.x=Math.ceil(a.x)-a.x:a.x-=Math.floor(a.x)}if(0>a.y||1a.y?0:1;break;case THREE.MirroredRepeatWrapping:1===
+Math.abs(Math.floor(a.y)%2)?a.y=Math.ceil(a.y)-a.y:a.y-=Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}};Object.assign(THREE.Texture.prototype,THREE.EventDispatcher.prototype);THREE.TextureIdCount=0;
+THREE.DepthTexture=function(a,b,c,d,e,f,g,h,k){THREE.Texture.call(this,null,d,e,f,g,h,THREE.DepthFormat,c,k);this.image={width:a,height:b};this.type=void 0!==c?c:THREE.UnsignedShortType;this.magFilter=void 0!==g?g:THREE.NearestFilter;this.minFilter=void 0!==h?h:THREE.NearestFilter;this.generateMipmaps=this.flipY=!1};THREE.DepthTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DepthTexture.prototype.constructor=THREE.DepthTexture;
+THREE.CanvasTexture=function(a,b,c,d,e,f,g,h,k){THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.needsUpdate=!0};THREE.CanvasTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CanvasTexture.prototype.constructor=THREE.CanvasTexture;THREE.CubeTexture=function(a,b,c,d,e,f,g,h,k,l){a=void 0!==a?a:[];b=void 0!==b?b:THREE.CubeReflectionMapping;THREE.Texture.call(this,a,b,c,d,e,f,g,h,k,l);this.flipY=!1};THREE.CubeTexture.prototype=Object.create(THREE.Texture.prototype);
+THREE.CubeTexture.prototype.constructor=THREE.CubeTexture;Object.defineProperty(THREE.CubeTexture.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});THREE.CompressedTexture=function(a,b,c,d,e,f,g,h,k,l,n,p){THREE.Texture.call(this,null,f,g,h,k,l,d,e,n,p);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1};THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CompressedTexture.prototype.constructor=THREE.CompressedTexture;
+THREE.DataTexture=function(a,b,c,d,e,f,g,h,k,l,n,p){THREE.Texture.call(this,null,f,g,h,k,l,d,e,n,p);this.image={data:a,width:b,height:c};this.magFilter=void 0!==k?k:THREE.NearestFilter;this.minFilter=void 0!==l?l:THREE.NearestFilter;this.generateMipmaps=this.flipY=!1};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.constructor=THREE.DataTexture;
+THREE.VideoTexture=function(a,b,c,d,e,f,g,h,k){function l(){requestAnimationFrame(l);a.readyState>=a.HAVE_CURRENT_DATA&&(n.needsUpdate=!0)}THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.generateMipmaps=!1;var n=this;l()};THREE.VideoTexture.prototype=Object.create(THREE.Texture.prototype);THREE.VideoTexture.prototype.constructor=THREE.VideoTexture;THREE.Group=function(){THREE.Object3D.call(this);this.type="Group"};THREE.Group.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.Group});
+THREE.Points=function(a,b){THREE.Object3D.call(this);this.type="Points";this.geometry=void 0!==a?a:new THREE.BufferGeometry;this.material=void 0!==b?b:new THREE.PointsMaterial({color:16777215*Math.random()})};
+THREE.Points.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.Points,raycast:function(){var a=new THREE.Matrix4,b=new THREE.Ray,c=new THREE.Sphere;return function(d,e){function f(a,c){var f=b.distanceSqToPoint(a);if(fd.far||e.push({distance:m,distanceToRay:Math.sqrt(f),point:h.clone(),index:c,face:null,object:g})}}var g=this,h=this.geometry,k=this.matrixWorld,l=d.params.Points.threshold;
+null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);var l=l/((this.scale.x+this.scale.y+this.scale.z)/3),n=l*l,l=new THREE.Vector3;if(h instanceof THREE.BufferGeometry){var p=h.index,h=h.attributes.position.array;if(null!==p)for(var m=p.array,p=0,q=m.length;pf||(n.applyMatrix4(this.matrixWorld),s=d.ray.origin.distanceTo(n),sd.far||e.push({distance:s,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else for(g=0,r=
+q.length/3-1;gf||(n.applyMatrix4(this.matrixWorld),s=d.ray.origin.distanceTo(n),sd.far||e.push({distance:s,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(g instanceof THREE.Geometry)for(k=g.vertices,l=k.length,g=0;gf||(n.applyMatrix4(this.matrixWorld),s=d.ray.origin.distanceTo(n),sd.far||
+e.push({distance:s,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});THREE.LineSegments=function(a,b){THREE.Line.call(this,a,b);this.type="LineSegments"};THREE.LineSegments.prototype=Object.assign(Object.create(THREE.Line.prototype),{constructor:THREE.LineSegments});
+THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new THREE.BufferGeometry;this.material=void 0!==b?b:new THREE.MeshBasicMaterial({color:16777215*Math.random()});this.drawMode=THREE.TrianglesDrawMode;this.updateMorphTargets()};
+THREE.Mesh.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.Mesh,setDrawMode:function(a){this.drawMode=a},updateMorphTargets:function(){if(void 0!==this.geometry.morphTargets&&0b.far?null:{distance:c,point:x.clone(),object:a}}function c(c,d,e,f,l,p,n,s){g.fromArray(f,3*p);h.fromArray(f,3*n);k.fromArray(f,3*s);if(c=b(c,d,e,g,h,k,u))l&&(m.fromArray(l,2*p),q.fromArray(l,2*n),r.fromArray(l,2*s),c.uv=a(u,g,h,k,m,q,r)),c.face=new THREE.Face3(p,n,s,THREE.Triangle.normal(g,h,k)),c.faceIndex=p;return c}var d=new THREE.Matrix4,e=new THREE.Ray,f=new THREE.Sphere,
+g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,n=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector2,q=new THREE.Vector2,r=new THREE.Vector2,s=new THREE.Vector3,u=new THREE.Vector3,x=new THREE.Vector3;return function(s,x){var w=this.geometry,D=this.material,A=this.matrixWorld;if(void 0!==D&&(null===w.boundingSphere&&w.computeBoundingSphere(),f.copy(w.boundingSphere),f.applyMatrix4(A),!1!==s.ray.intersectsSphere(f)&&(d.getInverse(A),e.copy(s.ray).applyMatrix4(d),
+null===w.boundingBox||!1!==e.intersectsBox(w.boundingBox)))){var y,B;if(w instanceof THREE.BufferGeometry){var G,z,D=w.index,A=w.attributes,w=A.position.array;void 0!==A.uv&&(y=A.uv.array);if(null!==D)for(var A=D.array,H=0,M=A.length;H=
+d[e].distance)d[e-1].object.visible=!1,d[e].object.visible=!0;else break;for(;ethis.scale.x*this.scale.y/4||c.push({distance:Math.sqrt(d),point:this.position,face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)}});
+THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)};
+THREE.LensFlare.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.LensFlare,copy:function(a){THREE.Object3D.prototype.copy.call(this,a);this.positionScreen.copy(a.positionScreen);this.customUpdateCallback=a.customUpdateCallback;for(var b=0,c=a.lensFlares.length;b 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
+THREE.ShaderChunk.bumpmap_pars_fragment="#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n";
+THREE.ShaderChunk.clipping_planes_fragment="#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n#endif\n";THREE.ShaderChunk.clipping_planes_pars_fragment="#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n";
+THREE.ShaderChunk.clipping_planes_pars_vertex="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n";THREE.ShaderChunk.clipping_planes_vertex="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n";THREE.ShaderChunk.color_fragment="#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif";THREE.ShaderChunk.color_pars_fragment="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n";
+THREE.ShaderChunk.color_pars_vertex="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif";THREE.ShaderChunk.color_vertex="#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif";THREE.ShaderChunk.common="#define PI 3.14159265359\n#define PI2 6.28318530718\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\n";
+THREE.ShaderChunk.cube_uv_reflection_fragment="#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n";
+THREE.ShaderChunk.defaultnormal_vertex="#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n";THREE.ShaderChunk.displacementmap_vertex="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n";THREE.ShaderChunk.displacementmap_pars_vertex="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n";
+THREE.ShaderChunk.emissivemap_fragment="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n";THREE.ShaderChunk.emissivemap_pars_fragment="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n";THREE.ShaderChunk.encodings_pars_fragment="\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = min( floor( D ) / 255.0, 1.0 );\n return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n return vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n return vec4( max(vRGB, 0.0), 1.0 );\n}\n";
+THREE.ShaderChunk.encodings_fragment=" gl_FragColor = linearToOutputTexel( gl_FragColor );\n";THREE.ShaderChunk.envmap_fragment="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#else\n\t\tfloat flipNormal = 1.0;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n";
+THREE.ShaderChunk.envmap_pars_fragment="#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n";
+THREE.ShaderChunk.envmap_pars_vertex="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n";THREE.ShaderChunk.envmap_vertex="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n";
+THREE.ShaderChunk.fog_fragment="#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n";
+THREE.ShaderChunk.fog_pars_fragment="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif";THREE.ShaderChunk.lightmap_fragment="#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n";THREE.ShaderChunk.lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
+THREE.ShaderChunk.lights_lambert_vertex="vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
+THREE.ShaderChunk.lights_pars="uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tif ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tfloat flipNormal = 1.0;\n\t\t#endif\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tfloat flipNormal = 1.0;\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
+THREE.ShaderChunk.lights_phong_fragment="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n";THREE.ShaderChunk.lights_phong_pars_fragment="varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n";
+THREE.ShaderChunk.lights_physical_fragment="PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.16 * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#endif\n";THREE.ShaderChunk.lights_physical_pars_fragment="struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t#endif\n};\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectSpecular += radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n";
+THREE.ShaderChunk.lights_template="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t \tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\tRE_IndirectSpecular( radiance, geometry, material, reflectedLight );\n#endif\n";
+THREE.ShaderChunk.logdepthbuf_fragment="#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif";THREE.ShaderChunk.logdepthbuf_pars_fragment="#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n";THREE.ShaderChunk.logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif";
+THREE.ShaderChunk.logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n";THREE.ShaderChunk.map_fragment="#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n";
+THREE.ShaderChunk.map_pars_fragment="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n";THREE.ShaderChunk.map_particle_fragment="#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n";THREE.ShaderChunk.map_particle_pars_fragment="#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n";THREE.ShaderChunk.metalnessmap_fragment="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.r;\n#endif\n";
+THREE.ShaderChunk.metalnessmap_pars_fragment="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";THREE.ShaderChunk.morphnormal_vertex="#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n";
+THREE.ShaderChunk.morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif";THREE.ShaderChunk.morphtarget_vertex="#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n";
+THREE.ShaderChunk.normal_fragment="#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n\t#endif\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n";
+THREE.ShaderChunk.normalmap_pars_fragment="#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n";
+THREE.ShaderChunk.packing="vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthoDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat OrthoDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n";
+THREE.ShaderChunk.premultiplied_alpha_fragment="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n";THREE.ShaderChunk.project_vertex="#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n";THREE.ShaderChunk.roughnessmap_fragment="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\n#endif\n";
+THREE.ShaderChunk.roughnessmap_pars_fragment="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";THREE.ShaderChunk.shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n";
+THREE.ShaderChunk.shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n";
+THREE.ShaderChunk.shadowmap_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n";
+THREE.ShaderChunk.shadowmask_pars_fragment="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n";
+THREE.ShaderChunk.skinbase_vertex="#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";THREE.ShaderChunk.skinning_pars_vertex="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n";
+THREE.ShaderChunk.skinning_vertex="#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n#endif\n";THREE.ShaderChunk.skinnormal_vertex="#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n";
+THREE.ShaderChunk.specularmap_fragment="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif";THREE.ShaderChunk.specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif";THREE.ShaderChunk.tonemapping_fragment="#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n";
+THREE.ShaderChunk.tonemapping_pars_fragment="#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n";
+THREE.ShaderChunk.uv2_pars_fragment="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif";THREE.ShaderChunk.uv2_pars_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif";THREE.ShaderChunk.uv2_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif";THREE.ShaderChunk.uv_pars_fragment="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif";
+THREE.ShaderChunk.uv_pars_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n";THREE.ShaderChunk.uv_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif";
+THREE.ShaderChunk.worldpos_vertex="#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n";
+THREE.UniformsUtils={merge:function(a){for(var b={},c=0;c\n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\t#include \n}\n";
+THREE.ShaderChunk.cube_vert="varying vec3 vWorldPosition;\n#include \n#include \n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";THREE.ShaderChunk.depth_frag="#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n";
+THREE.ShaderChunk.depth_vert="#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
+THREE.ShaderChunk.distanceRGBA_frag="uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include \n#include \n#include \nvoid main () {\n\t#include \n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n";THREE.ShaderChunk.distanceRGBA_vert="varying vec4 vWorldPosition;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition;\n}\n";
+THREE.ShaderChunk.equirect_frag="uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n}\n";
+THREE.ShaderChunk.equirect_vert="varying vec3 vWorldPosition;\n#include \n#include \n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";THREE.ShaderChunk.linedashed_frag="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
+THREE.ShaderChunk.linedashed_vert="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n}\n";
+THREE.ShaderChunk.meshbasic_frag="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight;\n\treflectedLight.directDiffuse = vec3( 0.0 );\n\treflectedLight.directSpecular = vec3( 0.0 );\n\treflectedLight.indirectDiffuse = diffuseColor.rgb;\n\treflectedLight.indirectSpecular = vec3( 0.0 );\n\t#include \n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
+THREE.ShaderChunk.meshbasic_vert="#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n";
+THREE.ShaderChunk.meshlambert_frag="uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include