diff --git a/account.go b/account.go index cbd7cde..2af9fce 100644 --- a/account.go +++ b/account.go @@ -1,1209 +1,1209 @@ /* * Copyright © 2018-2021 A Bunch Tell LLC. * * This file is part of WriteFreely. * * WriteFreely is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, included * in the LICENSE file in this source code package. */ package writefreely import ( "encoding/json" "fmt" "html/template" "net/http" "regexp" "strings" "sync" "time" "github.com/gorilla/csrf" "github.com/gorilla/mux" "github.com/gorilla/sessions" "github.com/guregu/null/zero" "github.com/writeas/impart" "github.com/writeas/web-core/auth" "github.com/writeas/web-core/data" "github.com/writeas/web-core/log" "github.com/writefreely/writefreely/author" "github.com/writefreely/writefreely/config" "github.com/writefreely/writefreely/page" ) type ( userSettings struct { Username string `schema:"username" json:"username"` Email string `schema:"email" json:"email"` NewPass string `schema:"new-pass" json:"new_pass"` OldPass string `schema:"current-pass" json:"current_pass"` IsLogOut bool `schema:"logout" json:"logout"` } UserPage struct { page.StaticPage PageTitle string Separator template.HTML IsAdmin bool CanInvite bool CollAlias string } ) func NewUserPage(app *App, r *http.Request, u *User, title string, flashes []string) *UserPage { up := &UserPage{ StaticPage: pageForReq(app, r), PageTitle: title, } up.Username = u.Username up.Flashes = flashes up.Path = r.URL.Path up.IsAdmin = u.IsAdmin() up.CanInvite = canUserInvite(app.cfg, up.IsAdmin) return up } func canUserInvite(cfg *config.Config, isAdmin bool) bool { return cfg.App.UserInvites != "" && (isAdmin || cfg.App.UserInvites != "admin") } func (up *UserPage) SetMessaging(u *User) { // up.NeedsAuth = app.db.DoesUserNeedAuth(u.ID) } const ( loginAttemptExpiration = 3 * time.Second ) var actuallyUsernameReg = regexp.MustCompile("username is actually ([a-z0-9\\-]+)\\. Please try that, instead") func apiSignup(app *App, w http.ResponseWriter, r *http.Request) error { _, err := signup(app, w, r) return err } func signup(app *App, w http.ResponseWriter, r *http.Request) (*AuthUser, error) { if app.cfg.App.DisablePasswordAuth { err := ErrDisabledPasswordAuth return nil, err } reqJSON := IsJSON(r) // Get params var ur userRegistration if reqJSON { decoder := json.NewDecoder(r.Body) err := decoder.Decode(&ur) if err != nil { log.Error("Couldn't parse signup JSON request: %v\n", err) return nil, ErrBadJSON } } else { // Check if user is already logged in u := getUserSession(app, r) if u != nil { return &AuthUser{User: u}, nil } err := r.ParseForm() if err != nil { log.Error("Couldn't parse signup form request: %v\n", err) return nil, ErrBadFormData } err = app.formDecoder.Decode(&ur, r.PostForm) if err != nil { log.Error("Couldn't decode signup form request: %v\n", err) return nil, ErrBadFormData } } return signupWithRegistration(app, ur, w, r) } func signupWithRegistration(app *App, signup userRegistration, w http.ResponseWriter, r *http.Request) (*AuthUser, error) { reqJSON := IsJSON(r) // Validate required params (alias) if signup.Alias == "" { return nil, impart.HTTPError{http.StatusBadRequest, "A username is required."} } if signup.Pass == "" { return nil, impart.HTTPError{http.StatusBadRequest, "A password is required."} } var desiredUsername string if signup.Normalize { // With this option we simply conform the username to what we expect // without complaining. Since they might've done something funny, like // enter: write.as/Way Out There, we'll use their raw input for the new // collection name and sanitize for the slug / username. desiredUsername = signup.Alias signup.Alias = getSlug(signup.Alias, "") } if !author.IsValidUsername(app.cfg, signup.Alias) { // Ensure the username is syntactically correct. return nil, impart.HTTPError{http.StatusPreconditionFailed, "Username is reserved or isn't valid. It must be at least 3 characters long, and can only include letters, numbers, and hyphens."} } // Handle empty optional params hashedPass, err := auth.HashPass([]byte(signup.Pass)) if err != nil { return nil, impart.HTTPError{http.StatusInternalServerError, "Could not create password hash."} } // Create struct to insert u := &User{ Username: signup.Alias, HashedPass: hashedPass, HasPass: true, Email: prepareUserEmail(signup.Email, app.keys.EmailKey), Created: time.Now().Truncate(time.Second).UTC(), } // Create actual user if err := app.db.CreateUser(app.cfg, u, desiredUsername); err != nil { return nil, err } // Log invite if needed if signup.InviteCode != "" { err = app.db.CreateInvitedUser(signup.InviteCode, u.ID) if err != nil { return nil, err } } // Add back unencrypted data for response if signup.Email != "" { u.Email.String = signup.Email } resUser := &AuthUser{ User: u, } title := signup.Alias if signup.Normalize { title = desiredUsername } resUser.Collections = &[]Collection{ { Alias: signup.Alias, Title: title, }, } var token string if reqJSON && !signup.Web { token, err = app.db.GetAccessToken(u.ID) if err != nil { return nil, impart.HTTPError{http.StatusInternalServerError, "Could not create access token. Try re-authenticating."} } resUser.AccessToken = token } else { session, err := app.sessionStore.Get(r, cookieName) if err != nil { // The cookie should still save, even if there's an error. // Source: https://github.com/gorilla/sessions/issues/16#issuecomment-143642144 log.Error("Session: %v; ignoring", err) } session.Values[cookieUserVal] = resUser.User.Cookie() err = session.Save(r, w) if err != nil { log.Error("Couldn't save session: %v", err) return nil, err } } if reqJSON { return resUser, impart.WriteSuccess(w, resUser, http.StatusCreated) } return resUser, nil } func viewLogout(app *App, w http.ResponseWriter, r *http.Request) error { session, err := app.sessionStore.Get(r, cookieName) if err != nil { return ErrInternalCookieSession } // Ensure user has an email or password set before they go, so they don't // lose access to their account. val := session.Values[cookieUserVal] var u = &User{} var ok bool if u, ok = val.(*User); !ok { log.Error("Error casting user object on logout. Vals: %+v Resetting cookie.", session.Values) err = session.Save(r, w) if err != nil { log.Error("Couldn't save session on logout: %v", err) return impart.HTTPError{http.StatusInternalServerError, "Unable to save cookie session."} } return impart.HTTPError{http.StatusFound, "/"} } u, err = app.db.GetUserByID(u.ID) if err != nil && err != ErrUserNotFound { return impart.HTTPError{http.StatusInternalServerError, "Unable to fetch user information."} } session.Options.MaxAge = -1 err = session.Save(r, w) if err != nil { log.Error("Couldn't save session on logout: %v", err) return impart.HTTPError{http.StatusInternalServerError, "Unable to save cookie session."} } return impart.HTTPError{http.StatusFound, "/"} } func handleAPILogout(app *App, w http.ResponseWriter, r *http.Request) error { accessToken := r.Header.Get("Authorization") if accessToken == "" { return ErrNoAccessToken } t := auth.GetToken(accessToken) if len(t) == 0 { return ErrNoAccessToken } err := app.db.DeleteToken(t) if err != nil { return err } return impart.HTTPError{Status: http.StatusNoContent} } func viewLogin(app *App, w http.ResponseWriter, r *http.Request) error { var earlyError string oneTimeToken := r.FormValue("with") if oneTimeToken != "" { log.Info("Calling login with one-time token.") err := login(app, w, r) if err != nil { log.Info("Received error: %v", err) earlyError = fmt.Sprintf("%s", err) } } session, err := app.sessionStore.Get(r, cookieName) if err != nil { // Ignore this log.Error("Unable to get session; ignoring: %v", err) } p := &struct { page.StaticPage *OAuthButtons To string Message template.HTML Flashes []template.HTML LoginUsername string }{ StaticPage: pageForReq(app, r), OAuthButtons: NewOAuthButtons(app.Config()), To: r.FormValue("to"), Message: template.HTML(""), Flashes: []template.HTML{}, LoginUsername: getTempInfo(app, "login-user", r, w), } if earlyError != "" { p.Flashes = append(p.Flashes, template.HTML(earlyError)) } // Display any error messages flashes, _ := getSessionFlashes(app, w, r, session) for _, flash := range flashes { p.Flashes = append(p.Flashes, template.HTML(flash)) } err = pages["login.tmpl"].ExecuteTemplate(w, "base", p) if err != nil { log.Error("Unable to render login: %v", err) return err } return nil } func webLogin(app *App, w http.ResponseWriter, r *http.Request) error { err := login(app, w, r) if err != nil { username := r.FormValue("alias") // Login request was unsuccessful; save the error in the session and redirect them if err, ok := err.(impart.HTTPError); ok { session, _ := app.sessionStore.Get(r, cookieName) if session != nil { session.AddFlash(err.Message) session.Save(r, w) } if m := actuallyUsernameReg.FindStringSubmatch(err.Message); len(m) > 0 { // Retain fixed username recommendation for the login form username = m[1] } } // Pass along certain information saveTempInfo(app, "login-user", username, r, w) // Retain post-login URL if one was given redirectTo := "/login" postLoginRedirect := r.FormValue("to") if postLoginRedirect != "" { redirectTo += "?to=" + postLoginRedirect } log.Error("Unable to login: %v", err) return impart.HTTPError{http.StatusTemporaryRedirect, redirectTo} } return nil } var loginAttemptUsers = sync.Map{} func login(app *App, w http.ResponseWriter, r *http.Request) error { reqJSON := IsJSON(r) oneTimeToken := r.FormValue("with") verbose := r.FormValue("all") == "true" || r.FormValue("verbose") == "1" || r.FormValue("verbose") == "true" || (reqJSON && oneTimeToken != "") redirectTo := r.FormValue("to") if redirectTo == "" { if app.cfg.App.SingleUser { redirectTo = "/me/new" } else { redirectTo = "/" } } var u *User var err error var signin userCredentials if app.cfg.App.DisablePasswordAuth { err := ErrDisabledPasswordAuth return err } // Log in with one-time token if one is given if oneTimeToken != "" { log.Info("Login: Logging user in via token.") userID := app.db.GetUserID(oneTimeToken) if userID == -1 { log.Error("Login: Got user -1 from token") err := ErrBadAccessToken err.Message = "Expired or invalid login code." return err } log.Info("Login: Found user %d.", userID) u, err = app.db.GetUserByID(userID) if err != nil { log.Error("Unable to fetch user on one-time token login: %v", err) return impart.HTTPError{http.StatusInternalServerError, "There was an error retrieving the user you want."} } log.Info("Login: Got user via token") } else { // Get params if reqJSON { decoder := json.NewDecoder(r.Body) err := decoder.Decode(&signin) if err != nil { log.Error("Couldn't parse signin JSON request: %v\n", err) return ErrBadJSON } } else { err := r.ParseForm() if err != nil { log.Error("Couldn't parse signin form request: %v\n", err) return ErrBadFormData } err = app.formDecoder.Decode(&signin, r.PostForm) if err != nil { log.Error("Couldn't decode signin form request: %v\n", err) return ErrBadFormData } } log.Info("Login: Attempting login for '%s'", signin.Alias) // Validate required params (all) if signin.Alias == "" { msg := "Parameter `alias` required." if signin.Web { msg = "A username is required." } return impart.HTTPError{http.StatusBadRequest, msg} } if !signin.EmailLogin && signin.Pass == "" { msg := "Parameter `pass` required." if signin.Web { msg = "A password is required." } return impart.HTTPError{http.StatusBadRequest, msg} } // Prevent excessive login attempts on the same account // Skip this check in dev environment if !app.cfg.Server.Dev { now := time.Now() attemptExp, att := loginAttemptUsers.LoadOrStore(signin.Alias, now.Add(loginAttemptExpiration)) if att { if attemptExpTime, ok := attemptExp.(time.Time); ok { if attemptExpTime.After(now) { // This user attempted previously, and the period hasn't expired yet return impart.HTTPError{http.StatusTooManyRequests, "You're doing that too much."} } else { // This user attempted previously, but the time expired; free up space loginAttemptUsers.Delete(signin.Alias) } } else { log.Error("Unable to cast expiration to time") } } } // Retrieve password u, err = app.db.GetUserForAuth(signin.Alias) if err != nil { log.Info("Unable to getUserForAuth on %s: %v", signin.Alias, err) if strings.IndexAny(signin.Alias, "@") > 0 { log.Info("Suggesting: %s", ErrUserNotFoundEmail.Message) return ErrUserNotFoundEmail } return err } // Authenticate if u.Email.String == "" { // User has no email set, so check if they haven't added a password, either, // so we can return a more helpful error message. if hasPass, _ := app.db.IsUserPassSet(u.ID); !hasPass { log.Info("Tried logging in to %s, but no password or email.", signin.Alias) return impart.HTTPError{http.StatusPreconditionFailed, "This user never added a password or email address. Please contact us for help."} } } if len(u.HashedPass) == 0 { return impart.HTTPError{http.StatusUnauthorized, "This user never set a password. Perhaps try logging in via OAuth?"} } if !auth.Authenticated(u.HashedPass, []byte(signin.Pass)) { return impart.HTTPError{http.StatusUnauthorized, "Incorrect password."} } } if reqJSON && !signin.Web { var token string if r.Header.Get("User-Agent") == "" { // Get last created token when User-Agent is empty token = app.db.FetchLastAccessToken(u.ID) if token == "" { token, err = app.db.GetAccessToken(u.ID) } } else { token, err = app.db.GetAccessToken(u.ID) } if err != nil { log.Error("Login: Unable to create access token: %v", err) return impart.HTTPError{http.StatusInternalServerError, "Could not create access token. Try re-authenticating."} } resUser := getVerboseAuthUser(app, token, u, verbose) return impart.WriteSuccess(w, resUser, http.StatusOK) } session, err := app.sessionStore.Get(r, cookieName) if err != nil { // The cookie should still save, even if there's an error. log.Error("Login: Session: %v; ignoring", err) } // Remove unwanted data session.Values[cookieUserVal] = u.Cookie() err = session.Save(r, w) if err != nil { log.Error("Login: Couldn't save session: %v", err) // TODO: return error } // Send success if reqJSON { return impart.WriteSuccess(w, &AuthUser{User: u}, http.StatusOK) } log.Info("Login: Redirecting to %s", redirectTo) w.Header().Set("Location", redirectTo) w.WriteHeader(http.StatusFound) return nil } func getVerboseAuthUser(app *App, token string, u *User, verbose bool) *AuthUser { resUser := &AuthUser{ AccessToken: token, User: u, } // Fetch verbose user data if requested if verbose { posts, err := app.db.GetUserPosts(u) if err != nil { log.Error("Login: Unable to get user posts: %v", err) } colls, err := app.db.GetCollections(u, app.cfg.App.Host) if err != nil { log.Error("Login: Unable to get user collections: %v", err) } passIsSet, err := app.db.IsUserPassSet(u.ID) if err != nil { // TODO: correct error meesage log.Error("Login: Unable to get user collections: %v", err) } resUser.Posts = posts resUser.Collections = colls resUser.User.HasPass = passIsSet } return resUser } func viewExportOptions(app *App, u *User, w http.ResponseWriter, r *http.Request) error { // Fetch extra user data p := NewUserPage(app, r, u, "Export", nil) showUserPage(w, "export", p) return nil } func viewExportPosts(app *App, w http.ResponseWriter, r *http.Request) ([]byte, string, error) { var filename string var u = &User{} reqJSON := IsJSON(r) if reqJSON { // Use given Authorization header accessToken := r.Header.Get("Authorization") if accessToken == "" { return nil, filename, ErrNoAccessToken } userID := app.db.GetUserID(accessToken) if userID == -1 { return nil, filename, ErrBadAccessToken } var err error u, err = app.db.GetUserByID(userID) if err != nil { return nil, filename, impart.HTTPError{http.StatusInternalServerError, "Unable to retrieve requested user."} } } else { // Use user cookie session, err := app.sessionStore.Get(r, cookieName) if err != nil { // The cookie should still save, even if there's an error. log.Error("Session: %v; ignoring", err) } val := session.Values[cookieUserVal] var ok bool if u, ok = val.(*User); !ok { return nil, filename, ErrNotLoggedIn } } filename = u.Username + "-posts-" + time.Now().Truncate(time.Second).UTC().Format("200601021504") // Fetch data we're exporting var err error var data []byte posts, err := app.db.GetUserPosts(u) if err != nil { return data, filename, err } // Export as CSV if strings.HasSuffix(r.URL.Path, ".csv") { data = exportPostsCSV(app.cfg.App.Host, u, posts) return data, filename, err } if strings.HasSuffix(r.URL.Path, ".zip") { data = exportPostsZip(u, posts) return data, filename, err } if r.FormValue("pretty") == "1" { data, err = json.MarshalIndent(posts, "", "\t") } else { data, err = json.Marshal(posts) } return data, filename, err } func viewExportFull(app *App, w http.ResponseWriter, r *http.Request) ([]byte, string, error) { var err error filename := "" u := getUserSession(app, r) if u == nil { return nil, filename, ErrNotLoggedIn } filename = u.Username + "-" + time.Now().Truncate(time.Second).UTC().Format("200601021504") exportUser := compileFullExport(app, u) var data []byte if r.FormValue("pretty") == "1" { data, err = json.MarshalIndent(exportUser, "", "\t") } else { data, err = json.Marshal(exportUser) } return data, filename, err } func viewMeAPI(app *App, w http.ResponseWriter, r *http.Request) error { reqJSON := IsJSON(r) uObj := struct { ID int64 `json:"id,omitempty"` Username string `json:"username,omitempty"` }{} var err error if reqJSON { _, uObj.Username, err = app.db.GetUserDataFromToken(r.Header.Get("Authorization")) if err != nil { return err } } else { u := getUserSession(app, r) if u == nil { return impart.WriteSuccess(w, uObj, http.StatusOK) } uObj.Username = u.Username } return impart.WriteSuccess(w, uObj, http.StatusOK) } func viewMyPostsAPI(app *App, u *User, w http.ResponseWriter, r *http.Request) error { reqJSON := IsJSON(r) if !reqJSON { return ErrBadRequestedType } var err error p := GetPostsCache(u.ID) if p == nil { userPostsCache.Lock() if userPostsCache.users[u.ID].ready == nil { userPostsCache.users[u.ID] = postsCacheItem{ready: make(chan struct{})} userPostsCache.Unlock() p, err = app.db.GetUserPosts(u) if err != nil { return err } CachePosts(u.ID, p) } else { userPostsCache.Unlock() <-userPostsCache.users[u.ID].ready p = GetPostsCache(u.ID) } } return impart.WriteSuccess(w, p, http.StatusOK) } func viewMyCollectionsAPI(app *App, u *User, w http.ResponseWriter, r *http.Request) error { reqJSON := IsJSON(r) if !reqJSON { return ErrBadRequestedType } p, err := app.db.GetCollections(u, app.cfg.App.Host) if err != nil { return err } return impart.WriteSuccess(w, p, http.StatusOK) } func viewArticles(app *App, u *User, w http.ResponseWriter, r *http.Request) error { p, err := app.db.GetAnonymousPosts(u) if err != nil { log.Error("unable to fetch anon posts: %v", err) } // nil-out AnonymousPosts slice for easy detection in the template if p != nil && len(*p) == 0 { p = nil } f, err := getSessionFlashes(app, w, r, nil) if err != nil { log.Error("unable to fetch flashes: %v", err) } c, err := app.db.GetPublishableCollections(u, app.cfg.App.Host) if err != nil { log.Error("unable to fetch collections: %v", err) } silenced, err := app.db.IsUserSilenced(u.ID) if err != nil { log.Error("view articles: %v", err) } d := struct { *UserPage AnonymousPosts *[]PublicPost Collections *[]Collection Silenced bool }{ UserPage: NewUserPage(app, r, u, u.Username+"'s Posts", f), AnonymousPosts: p, Collections: c, Silenced: silenced, } d.UserPage.SetMessaging(u) w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") w.Header().Set("Expires", "Thu, 04 Oct 1990 20:00:00 GMT") showUserPage(w, "articles", d) return nil } func viewCollections(app *App, u *User, w http.ResponseWriter, r *http.Request) error { c, err := app.db.GetCollections(u, app.cfg.App.Host) if err != nil { log.Error("unable to fetch collections: %v", err) return fmt.Errorf("No collections") } f, _ := getSessionFlashes(app, w, r, nil) uc, _ := app.db.GetUserCollectionCount(u.ID) // TODO: handle any errors silenced, err := app.db.IsUserSilenced(u.ID) if err != nil { log.Error("view collections %v", err) return fmt.Errorf("view collections: %v", err) } d := struct { *UserPage Collections *[]Collection UsedCollections, TotalCollections int NewBlogsDisabled bool Silenced bool }{ UserPage: NewUserPage(app, r, u, u.Username+"'s Blogs", f), Collections: c, UsedCollections: int(uc), NewBlogsDisabled: !app.cfg.App.CanCreateBlogs(uc), Silenced: silenced, } d.UserPage.SetMessaging(u) showUserPage(w, "collections", d) return nil } func viewEditCollection(app *App, u *User, w http.ResponseWriter, r *http.Request) error { vars := mux.Vars(r) c, err := app.db.GetCollection(vars["collection"]) if err != nil { return err } if c.OwnerID != u.ID { return ErrCollectionNotFound } // Add collection properties - c.MonetizationPointer = app.db.GetCollectionAttribute(c.ID, "monetization_pointer") + c.Monetization = app.db.GetCollectionAttribute(c.ID, "monetization_pointer") silenced, err := app.db.IsUserSilenced(u.ID) if err != nil { log.Error("view edit collection %v", err) return fmt.Errorf("view edit collection: %v", err) } flashes, _ := getSessionFlashes(app, w, r, nil) obj := struct { *UserPage *Collection Silenced bool }{ UserPage: NewUserPage(app, r, u, "Edit "+c.DisplayTitle(), flashes), Collection: c, Silenced: silenced, } obj.UserPage.CollAlias = c.Alias showUserPage(w, "collection", obj) return nil } func updateSettings(app *App, w http.ResponseWriter, r *http.Request) error { reqJSON := IsJSON(r) var s userSettings var u *User var sess *sessions.Session var err error if reqJSON { accessToken := r.Header.Get("Authorization") if accessToken == "" { return ErrNoAccessToken } u, err = app.db.GetAPIUser(accessToken) if err != nil { return ErrBadAccessToken } decoder := json.NewDecoder(r.Body) err := decoder.Decode(&s) if err != nil { log.Error("Couldn't parse settings JSON request: %v\n", err) return ErrBadJSON } // Prevent all username updates // TODO: support changing username via JSON API request s.Username = "" } else { u, sess = getUserAndSession(app, r) if u == nil { return ErrNotLoggedIn } err := r.ParseForm() if err != nil { log.Error("Couldn't parse settings form request: %v\n", err) return ErrBadFormData } err = app.formDecoder.Decode(&s, r.PostForm) if err != nil { log.Error("Couldn't decode settings form request: %v\n", err) return ErrBadFormData } } // Do update postUpdateReturn := r.FormValue("return") redirectTo := "/me/settings" if s.IsLogOut { redirectTo += "?logout=1" } else if postUpdateReturn != "" { redirectTo = postUpdateReturn } // Only do updates on values we need if s.Username != "" && s.Username == u.Username { // Username hasn't actually changed; blank it out s.Username = "" } err = app.db.ChangeSettings(app, u, &s) if err != nil { if reqJSON { return err } if err, ok := err.(impart.HTTPError); ok { addSessionFlash(app, w, r, err.Message, nil) } } else { // Successful update. if reqJSON { return impart.WriteSuccess(w, u, http.StatusOK) } if s.IsLogOut { redirectTo = "/me/logout" } else { sess.Values[cookieUserVal] = u.Cookie() addSessionFlash(app, w, r, "Account updated.", nil) } } w.Header().Set("Location", redirectTo) w.WriteHeader(http.StatusFound) return nil } func updatePassphrase(app *App, w http.ResponseWriter, r *http.Request) error { accessToken := r.Header.Get("Authorization") if accessToken == "" { return ErrNoAccessToken } curPass := r.FormValue("current") newPass := r.FormValue("new") // Ensure a new password is given (always required) if newPass == "" { return impart.HTTPError{http.StatusBadRequest, "Provide a new password."} } userID, sudo := app.db.GetUserIDPrivilege(accessToken) if userID == -1 { return ErrBadAccessToken } // Ensure a current password is given if the access token doesn't have sudo // privileges. if !sudo && curPass == "" { return impart.HTTPError{http.StatusBadRequest, "Provide current password."} } // Hash the new password hashedPass, err := auth.HashPass([]byte(newPass)) if err != nil { return impart.HTTPError{http.StatusInternalServerError, "Could not create password hash."} } // Do update err = app.db.ChangePassphrase(userID, sudo, curPass, hashedPass) if err != nil { return err } return impart.WriteSuccess(w, struct{}{}, http.StatusOK) } func viewStats(app *App, u *User, w http.ResponseWriter, r *http.Request) error { var c *Collection var err error vars := mux.Vars(r) alias := vars["collection"] if alias != "" { c, err = app.db.GetCollection(alias) if err != nil { return err } if c.OwnerID != u.ID { return ErrCollectionNotFound } } topPosts, err := app.db.GetTopPosts(u, alias) if err != nil { log.Error("Unable to get top posts: %v", err) return err } flashes, _ := getSessionFlashes(app, w, r, nil) titleStats := "" if c != nil { titleStats = c.DisplayTitle() + " " } silenced, err := app.db.IsUserSilenced(u.ID) if err != nil { log.Error("view stats: %v", err) return err } obj := struct { *UserPage VisitsBlog string Collection *Collection TopPosts *[]PublicPost APFollowers int Silenced bool }{ UserPage: NewUserPage(app, r, u, titleStats+"Stats", flashes), VisitsBlog: alias, Collection: c, TopPosts: topPosts, Silenced: silenced, } obj.UserPage.CollAlias = c.Alias if app.cfg.App.Federation { folls, err := app.db.GetAPFollowers(c) if err != nil { return err } obj.APFollowers = len(*folls) } showUserPage(w, "stats", obj) return nil } func viewSettings(app *App, u *User, w http.ResponseWriter, r *http.Request) error { fullUser, err := app.db.GetUserByID(u.ID) if err != nil { log.Error("Unable to get user for settings: %s", err) return impart.HTTPError{http.StatusInternalServerError, "Unable to retrieve user data. The humans have been alerted."} } passIsSet, err := app.db.IsUserPassSet(u.ID) if err != nil { log.Error("Unable to get isUserPassSet for settings: %s", err) return impart.HTTPError{http.StatusInternalServerError, "Unable to retrieve user data. The humans have been alerted."} } flashes, _ := getSessionFlashes(app, w, r, nil) enableOauthSlack := app.Config().SlackOauth.ClientID != "" enableOauthWriteAs := app.Config().WriteAsOauth.ClientID != "" enableOauthGitLab := app.Config().GitlabOauth.ClientID != "" enableOauthGeneric := app.Config().GenericOauth.ClientID != "" enableOauthGitea := app.Config().GiteaOauth.ClientID != "" oauthAccounts, err := app.db.GetOauthAccounts(r.Context(), u.ID) if err != nil { log.Error("Unable to get oauth accounts for settings: %s", err) return impart.HTTPError{http.StatusInternalServerError, "Unable to retrieve user data. The humans have been alerted."} } for idx, oauthAccount := range oauthAccounts { switch oauthAccount.Provider { case "slack": enableOauthSlack = false case "write.as": enableOauthWriteAs = false case "gitlab": enableOauthGitLab = false case "generic": oauthAccounts[idx].DisplayName = app.Config().GenericOauth.DisplayName oauthAccounts[idx].AllowDisconnect = app.Config().GenericOauth.AllowDisconnect enableOauthGeneric = false case "gitea": enableOauthGitea = false } } displayOauthSection := enableOauthSlack || enableOauthWriteAs || enableOauthGitLab || enableOauthGeneric || enableOauthGitea || len(oauthAccounts) > 0 obj := struct { *UserPage Email string HasPass bool IsLogOut bool Silenced bool CSRFField template.HTML OauthSection bool OauthAccounts []oauthAccountInfo OauthSlack bool OauthWriteAs bool OauthGitLab bool GitLabDisplayName string OauthGeneric bool OauthGenericDisplayName string OauthGitea bool GiteaDisplayName string }{ UserPage: NewUserPage(app, r, u, "Account Settings", flashes), Email: fullUser.EmailClear(app.keys), HasPass: passIsSet, IsLogOut: r.FormValue("logout") == "1", Silenced: fullUser.IsSilenced(), CSRFField: csrf.TemplateField(r), OauthSection: displayOauthSection, OauthAccounts: oauthAccounts, OauthSlack: enableOauthSlack, OauthWriteAs: enableOauthWriteAs, OauthGitLab: enableOauthGitLab, GitLabDisplayName: config.OrDefaultString(app.Config().GitlabOauth.DisplayName, gitlabDisplayName), OauthGeneric: enableOauthGeneric, OauthGenericDisplayName: config.OrDefaultString(app.Config().GenericOauth.DisplayName, genericOauthDisplayName), OauthGitea: enableOauthGitea, GiteaDisplayName: config.OrDefaultString(app.Config().GiteaOauth.DisplayName, giteaDisplayName), } showUserPage(w, "settings", obj) return nil } func saveTempInfo(app *App, key, val string, r *http.Request, w http.ResponseWriter) error { session, err := app.sessionStore.Get(r, "t") if err != nil { return ErrInternalCookieSession } session.Values[key] = val err = session.Save(r, w) if err != nil { log.Error("Couldn't saveTempInfo for key-val (%s:%s): %v", key, val, err) } return err } func getTempInfo(app *App, key string, r *http.Request, w http.ResponseWriter) string { session, err := app.sessionStore.Get(r, "t") if err != nil { return "" } // Get the information var s = "" var ok bool if s, ok = session.Values[key].(string); !ok { return "" } // Delete cookie session.Options.MaxAge = -1 err = session.Save(r, w) if err != nil { log.Error("Couldn't erase temp data for key %s: %v", key, err) } // Return value return s } func handleUserDelete(app *App, u *User, w http.ResponseWriter, r *http.Request) error { if !app.cfg.App.OpenDeletion { return impart.HTTPError{http.StatusForbidden, "Open account deletion is disabled on this instance."} } confirmUsername := r.PostFormValue("confirm-username") if u.Username != confirmUsername { return impart.HTTPError{http.StatusBadRequest, "Confirmation username must match your username exactly."} } // Check for account deletion safeguards in place if u.IsAdmin() { return impart.HTTPError{http.StatusForbidden, "Cannot delete admin."} } err := app.db.DeleteAccount(u.ID) if err != nil { log.Error("user delete account: %v", err) return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not delete account: %v", err)} } // FIXME: This doesn't ever appear to the user, as (I believe) the value is erased when the session cookie is reset _ = addSessionFlash(app, w, r, "Thanks for writing with us! You account was deleted successfully.", nil) return impart.HTTPError{http.StatusFound, "/me/logout"} } func removeOauth(app *App, u *User, w http.ResponseWriter, r *http.Request) error { provider := r.FormValue("provider") clientID := r.FormValue("client_id") remoteUserID := r.FormValue("remote_user_id") err := app.db.RemoveOauth(r.Context(), u.ID, provider, clientID, remoteUserID) if err != nil { return impart.HTTPError{Status: http.StatusInternalServerError, Message: err.Error()} } return impart.HTTPError{Status: http.StatusFound, Message: "/me/settings"} } func prepareUserEmail(input string, emailKey []byte) zero.String { email := zero.NewString("", input != "") if len(input) > 0 { encEmail, err := data.Encrypt(emailKey, input) if err != nil { log.Error("Unable to encrypt email: %s\n", err) } else { email.String = string(encEmail) } } return email } diff --git a/collections.go b/collections.go index 5f7b608..30795d5 100644 --- a/collections.go +++ b/collections.go @@ -1,1212 +1,1212 @@ /* * Copyright © 2018-2021 A Bunch Tell LLC. * * This file is part of WriteFreely. * * WriteFreely is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, included * in the LICENSE file in this source code package. */ package writefreely import ( "database/sql" "encoding/json" "fmt" "html/template" "math" "net/http" "net/url" "regexp" "strconv" "strings" "unicode" "github.com/gorilla/mux" "github.com/writeas/impart" "github.com/writeas/web-core/activitystreams" "github.com/writeas/web-core/auth" "github.com/writeas/web-core/bots" "github.com/writeas/web-core/log" waposts "github.com/writeas/web-core/posts" "github.com/writefreely/writefreely/author" "github.com/writefreely/writefreely/config" "github.com/writefreely/writefreely/page" "golang.org/x/net/idna" ) type ( // TODO: add Direction to db // TODO: add Language to db Collection struct { ID int64 `datastore:"id" json:"-"` Alias string `datastore:"alias" schema:"alias" json:"alias"` Title string `datastore:"title" schema:"title" json:"title"` Description string `datastore:"description" schema:"description" json:"description"` Direction string `schema:"dir" json:"dir,omitempty"` Language string `schema:"lang" json:"lang,omitempty"` StyleSheet string `datastore:"style_sheet" schema:"style_sheet" json:"style_sheet"` Script string `datastore:"script" schema:"script" json:"script,omitempty"` Signature string `datastore:"post_signature" schema:"signature" json:"-"` Public bool `datastore:"public" json:"public"` Visibility collVisibility `datastore:"private" json:"-"` Format string `datastore:"format" json:"format,omitempty"` Views int64 `json:"views"` OwnerID int64 `datastore:"owner_id" json:"-"` PublicOwner bool `datastore:"public_owner" json:"-"` URL string `json:"url,omitempty"` - MonetizationPointer string `json:"monetization_pointer,omitempty"` + Monetization string `json:"monetization_pointer,omitempty"` db *datastore hostName string } CollectionObj struct { Collection TotalPosts int `json:"total_posts"` Owner *User `json:"owner,omitempty"` Posts *[]PublicPost `json:"posts,omitempty"` Format *CollectionFormat } DisplayCollection struct { *CollectionObj Prefix string IsTopLevel bool CurrentPage int TotalPages int Silenced bool } SubmittedCollection struct { // Data used for updating a given collection ID int64 OwnerID uint64 // Form helpers PreferURL string `schema:"prefer_url" json:"prefer_url"` Privacy int `schema:"privacy" json:"privacy"` Pass string `schema:"password" json:"password"` MathJax bool `schema:"mathjax" json:"mathjax"` Handle string `schema:"handle" json:"handle"` // Actual collection values updated in the DB Alias *string `schema:"alias" json:"alias"` Title *string `schema:"title" json:"title"` Description *string `schema:"description" json:"description"` StyleSheet *sql.NullString `schema:"style_sheet" json:"style_sheet"` Script *sql.NullString `schema:"script" json:"script"` Signature *sql.NullString `schema:"signature" json:"signature"` Monetization *string `schema:"monetization_pointer" json:"monetization_pointer"` Visibility *int `schema:"visibility" json:"public"` Format *sql.NullString `schema:"format" json:"format"` } CollectionFormat struct { Format string } collectionReq struct { // Information about the collection request itself prefix, alias, domain string isCustomDomain bool // User-related fields isCollOwner bool isAuthorized bool } ) func (sc *SubmittedCollection) FediverseHandle() string { if sc.Handle == "" { return apCustomHandleDefault } return getSlug(sc.Handle, "") } // collVisibility represents the visibility level for the collection. type collVisibility int // Visibility levels. Values are bitmasks, stored in the database as // decimal numbers. If adding types, append them to this list. If removing, // replace the desired visibility with a new value. const CollUnlisted collVisibility = 0 const ( CollPublic collVisibility = 1 << iota CollPrivate CollProtected ) var collVisibilityStrings = map[string]collVisibility{ "unlisted": CollUnlisted, "public": CollPublic, "private": CollPrivate, "protected": CollProtected, } func defaultVisibility(cfg *config.Config) collVisibility { vis, ok := collVisibilityStrings[cfg.App.DefaultVisibility] if !ok { vis = CollUnlisted } return vis } func (cf *CollectionFormat) Ascending() bool { return cf.Format == "novel" } func (cf *CollectionFormat) ShowDates() bool { return cf.Format == "blog" } func (cf *CollectionFormat) PostsPerPage() int { if cf.Format == "novel" { return postsPerPage } return postsPerPage } // Valid returns whether or not a format value is valid. func (cf *CollectionFormat) Valid() bool { return cf.Format == "blog" || cf.Format == "novel" || cf.Format == "notebook" } // NewFormat creates a new CollectionFormat object from the Collection. func (c *Collection) NewFormat() *CollectionFormat { cf := &CollectionFormat{Format: c.Format} // Fill in default format if cf.Format == "" { cf.Format = "blog" } return cf } func (c *Collection) IsInstanceColl() bool { ur, _ := url.Parse(c.hostName) return c.Alias == ur.Host } func (c *Collection) IsUnlisted() bool { return c.Visibility == 0 } func (c *Collection) IsPrivate() bool { return c.Visibility&CollPrivate != 0 } func (c *Collection) IsProtected() bool { return c.Visibility&CollProtected != 0 } func (c *Collection) IsPublic() bool { return c.Visibility&CollPublic != 0 } func (c *Collection) FriendlyVisibility() string { if c.IsPrivate() { return "Private" } if c.IsPublic() { return "Public" } if c.IsProtected() { return "Password-protected" } return "Unlisted" } func (c *Collection) ShowFooterBranding() bool { // TODO: implement this setting return true } // CanonicalURL returns a fully-qualified URL to the collection. func (c *Collection) CanonicalURL() string { return c.RedirectingCanonicalURL(false) } func (c *Collection) DisplayCanonicalURL() string { us := c.CanonicalURL() u, err := url.Parse(us) if err != nil { return us } p := u.Path if p == "/" { p = "" } d := u.Hostname() d, _ = idna.ToUnicode(d) return d + p } func (c *Collection) RedirectingCanonicalURL(isRedir bool) string { if c.hostName == "" { // If this is true, the human programmers screwed up. So ask for a bug report and fail, fail, fail log.Error("[PROGRAMMER ERROR] WARNING: Collection.hostName is empty! Federation and many other things will fail! If you're seeing this in the wild, please report this bug and let us know what you were doing just before this: https://github.com/writefreely/writefreely/issues/new?template=bug_report.md") } if isSingleUser { return c.hostName + "/" } return fmt.Sprintf("%s/%s/", c.hostName, c.Alias) } // PrevPageURL provides a full URL for the previous page of collection posts, // returning a /page/N result for pages >1 func (c *Collection) PrevPageURL(prefix string, n int, tl bool) string { u := "" if n == 2 { // Previous page is 1; no need for /page/ prefix if prefix == "" { u = "/" } // Else leave off trailing slash } else { u = fmt.Sprintf("/page/%d", n-1) } if tl { return u } return "/" + prefix + c.Alias + u } // NextPageURL provides a full URL for the next page of collection posts func (c *Collection) NextPageURL(prefix string, n int, tl bool) string { if tl { return fmt.Sprintf("/page/%d", n+1) } return fmt.Sprintf("/%s%s/page/%d", prefix, c.Alias, n+1) } func (c *Collection) DisplayTitle() string { if c.Title != "" { return c.Title } return c.Alias } func (c *Collection) StyleSheetDisplay() template.CSS { return template.CSS(c.StyleSheet) } // ForPublic modifies the Collection for public consumption, such as via // the API. func (c *Collection) ForPublic() { c.URL = c.CanonicalURL() } var isAvatarChar = regexp.MustCompile("[a-z0-9]").MatchString func (c *Collection) PersonObject(ids ...int64) *activitystreams.Person { accountRoot := c.FederatedAccount() p := activitystreams.NewPerson(accountRoot) p.URL = c.CanonicalURL() uname := c.Alias p.PreferredUsername = uname p.Name = c.DisplayTitle() p.Summary = c.Description if p.Name != "" { if av := c.AvatarURL(); av != "" { p.Icon = activitystreams.Image{ Type: "Image", MediaType: "image/png", URL: av, } } } collID := c.ID if len(ids) > 0 { collID = ids[0] } pub, priv := c.db.GetAPActorKeys(collID) if pub != nil { p.AddPubKey(pub) p.SetPrivKey(priv) } return p } func (c *Collection) AvatarURL() string { fl := string(unicode.ToLower([]rune(c.DisplayTitle())[0])) if !isAvatarChar(fl) { return "" } return c.hostName + "/img/avatars/" + fl + ".png" } func (c *Collection) FederatedAPIBase() string { return c.hostName + "/" } func (c *Collection) FederatedAccount() string { accountUser := c.Alias return c.FederatedAPIBase() + "api/collections/" + accountUser } func (c *Collection) RenderMathJax() bool { return c.db.CollectionHasAttribute(c.ID, "render_mathjax") } func newCollection(app *App, w http.ResponseWriter, r *http.Request) error { reqJSON := IsJSON(r) alias := r.FormValue("alias") title := r.FormValue("title") var missingParams, accessToken string var u *User c := struct { Alias string `json:"alias" schema:"alias"` Title string `json:"title" schema:"title"` Web bool `json:"web" schema:"web"` }{} if reqJSON { // Decode JSON request decoder := json.NewDecoder(r.Body) err := decoder.Decode(&c) if err != nil { log.Error("Couldn't parse post update JSON request: %v\n", err) return ErrBadJSON } } else { // TODO: move form parsing to formDecoder c.Alias = alias c.Title = title } if c.Alias == "" { if c.Title != "" { // If only a title was given, just use it to generate the alias. c.Alias = getSlug(c.Title, "") } else { missingParams += "`alias` " } } if c.Title == "" { missingParams += "`title` " } if missingParams != "" { return impart.HTTPError{http.StatusBadRequest, fmt.Sprintf("Parameter(s) %srequired.", missingParams)} } var userID int64 var err error if reqJSON && !c.Web { accessToken = r.Header.Get("Authorization") if accessToken == "" { return ErrNoAccessToken } userID = app.db.GetUserID(accessToken) if userID == -1 { return ErrBadAccessToken } } else { u = getUserSession(app, r) if u == nil { return ErrNotLoggedIn } userID = u.ID } silenced, err := app.db.IsUserSilenced(userID) if err != nil { log.Error("new collection: %v", err) return ErrInternalGeneral } if silenced { return ErrUserSilenced } if !author.IsValidUsername(app.cfg, c.Alias) { return impart.HTTPError{http.StatusPreconditionFailed, "Collection alias isn't valid."} } coll, err := app.db.CreateCollection(app.cfg, c.Alias, c.Title, userID) if err != nil { // TODO: handle this return err } res := &CollectionObj{Collection: *coll} if reqJSON { return impart.WriteSuccess(w, res, http.StatusCreated) } redirectTo := "/me/c/" // TODO: redirect to pad when necessary return impart.HTTPError{http.StatusFound, redirectTo} } func apiCheckCollectionPermissions(app *App, r *http.Request, c *Collection) (int64, error) { accessToken := r.Header.Get("Authorization") var userID int64 = -1 if accessToken != "" { userID = app.db.GetUserID(accessToken) } isCollOwner := userID == c.OwnerID if c.IsPrivate() && !isCollOwner { // Collection is private, but user isn't authenticated return -1, ErrCollectionNotFound } if c.IsProtected() { // TODO: check access token return -1, ErrCollectionUnauthorizedRead } return userID, nil } // fetchCollection handles the API endpoint for retrieving collection data. func fetchCollection(app *App, w http.ResponseWriter, r *http.Request) error { accept := r.Header.Get("Accept") if strings.Contains(accept, "application/activity+json") { return handleFetchCollectionActivities(app, w, r) } vars := mux.Vars(r) alias := vars["alias"] // TODO: move this logic into a common getCollection function // Get base Collection data c, err := app.db.GetCollection(alias) if err != nil { return err } c.hostName = app.cfg.App.Host // Redirect users who aren't requesting JSON reqJSON := IsJSON(r) if !reqJSON { return impart.HTTPError{http.StatusFound, c.CanonicalURL()} } // Check permissions userID, err := apiCheckCollectionPermissions(app, r, c) if err != nil { return err } isCollOwner := userID == c.OwnerID // Fetch extra data about the Collection res := &CollectionObj{Collection: *c} if c.PublicOwner { u, err := app.db.GetUserByID(res.OwnerID) if err != nil { // Log the error and just continue log.Error("Error getting user for collection: %v", err) } else { res.Owner = u } } // TODO: check status for silenced app.db.GetPostsCount(res, isCollOwner) // Strip non-public information res.Collection.ForPublic() return impart.WriteSuccess(w, res, http.StatusOK) } // fetchCollectionPosts handles an API endpoint for retrieving a collection's // posts. func fetchCollectionPosts(app *App, w http.ResponseWriter, r *http.Request) error { vars := mux.Vars(r) alias := vars["alias"] c, err := app.db.GetCollection(alias) if err != nil { return err } c.hostName = app.cfg.App.Host // Check permissions userID, err := apiCheckCollectionPermissions(app, r, c) if err != nil { return err } isCollOwner := userID == c.OwnerID // Get page page := 1 if p := r.FormValue("page"); p != "" { pInt, _ := strconv.Atoi(p) if pInt > 0 { page = pInt } } posts, err := app.db.GetPosts(app.cfg, c, page, isCollOwner, false, false) if err != nil { return err } coll := &CollectionObj{Collection: *c, Posts: posts} app.db.GetPostsCount(coll, isCollOwner) // Strip non-public information coll.Collection.ForPublic() // Transform post bodies if needed if r.FormValue("body") == "html" { for _, p := range *coll.Posts { p.Content = waposts.ApplyMarkdown([]byte(p.Content)) } } return impart.WriteSuccess(w, coll, http.StatusOK) } type CollectionPage struct { page.StaticPage *DisplayCollection IsCustomDomain bool IsWelcome bool IsOwner bool IsCollLoggedIn bool CanPin bool Username string Monetization string Collections *[]Collection PinnedPosts *[]PublicPost IsAdmin bool CanInvite bool } func NewCollectionObj(c *Collection) *CollectionObj { return &CollectionObj{ Collection: *c, Format: c.NewFormat(), } } func (c *CollectionObj) ScriptDisplay() template.JS { return template.JS(c.Script) } var jsSourceCommentReg = regexp.MustCompile("(?m)^// src:(.+)$") func (c *CollectionObj) ExternalScripts() []template.URL { scripts := []template.URL{} if c.Script == "" { return scripts } matches := jsSourceCommentReg.FindAllStringSubmatch(c.Script, -1) for _, m := range matches { scripts = append(scripts, template.URL(strings.TrimSpace(m[1]))) } return scripts } func (c *CollectionObj) CanShowScript() bool { return false } func processCollectionRequest(cr *collectionReq, vars map[string]string, w http.ResponseWriter, r *http.Request) error { cr.prefix = vars["prefix"] cr.alias = vars["collection"] // Normalize the URL, redirecting user to consistent post URL if cr.alias != strings.ToLower(cr.alias) { return impart.HTTPError{http.StatusMovedPermanently, fmt.Sprintf("/%s/", strings.ToLower(cr.alias))} } return nil } // processCollectionPermissions checks the permissions for the given // collectionReq, returning a Collection if access is granted; otherwise this // renders any necessary collection pages, for example, if requesting a custom // domain that doesn't yet have a collection associated, or if a collection // requires a password. In either case, this will return nil, nil -- thus both // values should ALWAYS be checked to determine whether or not to continue. func processCollectionPermissions(app *App, cr *collectionReq, u *User, w http.ResponseWriter, r *http.Request) (*Collection, error) { // Display collection if this is a collection var c *Collection var err error if app.cfg.App.SingleUser { c, err = app.db.GetCollectionByID(1) } else { c, err = app.db.GetCollection(cr.alias) } // TODO: verify we don't reveal the existence of a private collection with redirection if err != nil { if err, ok := err.(impart.HTTPError); ok { if err.Status == http.StatusNotFound { if cr.isCustomDomain { // User is on the site from a custom domain //tErr := pages["404-domain.tmpl"].ExecuteTemplate(w, "base", pageForHost(page.StaticPage{}, r)) //if tErr != nil { //log.Error("Unable to render 404-domain page: %v", err) //} return nil, nil } if len(cr.alias) >= minIDLen && len(cr.alias) <= maxIDLen { // Alias is within post ID range, so just be sure this isn't a post if app.db.PostIDExists(cr.alias) { // TODO: use StatusFound for vanity post URLs when we implement them return nil, impart.HTTPError{http.StatusMovedPermanently, "/" + cr.alias} } } // Redirect if necessary newAlias := app.db.GetCollectionRedirect(cr.alias) if newAlias != "" { return nil, impart.HTTPError{http.StatusFound, "/" + newAlias + "/"} } } } return nil, err } c.hostName = app.cfg.App.Host // Update CollectionRequest to reflect owner status cr.isCollOwner = u != nil && u.ID == c.OwnerID // Check permissions if !cr.isCollOwner { if c.IsPrivate() { return nil, ErrCollectionNotFound } else if c.IsProtected() { uname := "" if u != nil { uname = u.Username } // TODO: move this to all permission checks? suspended, err := app.db.IsUserSilenced(c.OwnerID) if err != nil { log.Error("process protected collection permissions: %v", err) return nil, err } if suspended { return nil, ErrCollectionNotFound } // See if we've authorized this collection cr.isAuthorized = isAuthorizedForCollection(app, c.Alias, r) if !cr.isAuthorized { p := struct { page.StaticPage *CollectionObj Username string Next string Flashes []template.HTML }{ StaticPage: pageForReq(app, r), CollectionObj: &CollectionObj{Collection: *c}, Username: uname, Next: r.FormValue("g"), Flashes: []template.HTML{}, } // Get owner information p.CollectionObj.Owner, err = app.db.GetUserByID(c.OwnerID) if err != nil { // Log the error and just continue log.Error("Error getting user for collection: %v", err) } flashes, _ := getSessionFlashes(app, w, r, nil) for _, flash := range flashes { p.Flashes = append(p.Flashes, template.HTML(flash)) } err = templates["password-collection"].ExecuteTemplate(w, "password-collection", p) if err != nil { log.Error("Unable to render password-collection: %v", err) return nil, err } return nil, nil } } } return c, nil } func checkUserForCollection(app *App, cr *collectionReq, r *http.Request, isPostReq bool) (*User, error) { u := getUserSession(app, r) return u, nil } func newDisplayCollection(c *Collection, cr *collectionReq, page int) *DisplayCollection { coll := &DisplayCollection{ CollectionObj: NewCollectionObj(c), CurrentPage: page, Prefix: cr.prefix, IsTopLevel: isSingleUser, } c.db.GetPostsCount(coll.CollectionObj, cr.isCollOwner) return coll } // getCollectionPage returns the collection page as an int. If the parsed page value is not // greater than 0 then the default value of 1 is returned. func getCollectionPage(vars map[string]string) int { if p, _ := strconv.Atoi(vars["page"]); p > 0 { return p } return 1 } // handleViewCollection displays the requested Collection func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) error { vars := mux.Vars(r) cr := &collectionReq{} err := processCollectionRequest(cr, vars, w, r) if err != nil { return err } u, err := checkUserForCollection(app, cr, r, false) if err != nil { return err } page := getCollectionPage(vars) c, err := processCollectionPermissions(app, cr, u, w, r) if c == nil || err != nil { return err } c.hostName = app.cfg.App.Host silenced, err := app.db.IsUserSilenced(c.OwnerID) if err != nil { log.Error("view collection: %v", err) return ErrInternalGeneral } // Serve ActivityStreams data now, if requested if strings.Contains(r.Header.Get("Accept"), "application/activity+json") { ac := c.PersonObject() ac.Context = []interface{}{activitystreams.Namespace} setCacheControl(w, apCacheTime) return impart.RenderActivityJSON(w, ac, http.StatusOK) } // Fetch extra data about the Collection // TODO: refactor out this logic, shared in collection.go:fetchCollection() coll := newDisplayCollection(c, cr, page) coll.TotalPages = int(math.Ceil(float64(coll.TotalPosts) / float64(coll.Format.PostsPerPage()))) if coll.TotalPages > 0 && page > coll.TotalPages { redirURL := fmt.Sprintf("/page/%d", coll.TotalPages) if !app.cfg.App.SingleUser { redirURL = fmt.Sprintf("/%s%s%s", cr.prefix, coll.Alias, redirURL) } return impart.HTTPError{http.StatusFound, redirURL} } coll.Posts, _ = app.db.GetPosts(app.cfg, c, page, cr.isCollOwner, false, false) // Serve collection displayPage := CollectionPage{ DisplayCollection: coll, IsCollLoggedIn: cr.isAuthorized, StaticPage: pageForReq(app, r), IsCustomDomain: cr.isCustomDomain, IsWelcome: r.FormValue("greeting") != "", } displayPage.IsAdmin = u != nil && u.IsAdmin() displayPage.CanInvite = canUserInvite(app.cfg, displayPage.IsAdmin) var owner *User if u != nil { displayPage.Username = u.Username displayPage.IsOwner = u.ID == coll.OwnerID if displayPage.IsOwner { // Add in needed information for users viewing their own collection owner = u displayPage.CanPin = true pubColls, err := app.db.GetPublishableCollections(owner, app.cfg.App.Host) if err != nil { log.Error("unable to fetch collections: %v", err) } displayPage.Collections = pubColls } } isOwner := owner != nil if !isOwner { // Current user doesn't own collection; retrieve owner information owner, err = app.db.GetUserByID(coll.OwnerID) if err != nil { // Log the error and just continue log.Error("Error getting user for collection: %v", err) } } if !isOwner && silenced { return ErrCollectionNotFound } displayPage.Silenced = isOwner && silenced displayPage.Owner = owner coll.Owner = displayPage.Owner // Add more data // TODO: fix this mess of collections inside collections displayPage.PinnedPosts, _ = app.db.GetPinnedPosts(coll.CollectionObj, isOwner) displayPage.Monetization = app.db.GetCollectionAttribute(coll.ID, "monetization_pointer") collTmpl := "collection" if app.cfg.App.Chorus { collTmpl = "chorus-collection" } err = templates[collTmpl].ExecuteTemplate(w, "collection", displayPage) if err != nil { log.Error("Unable to render collection index: %v", err) } // Update collection view count go func() { // Don't update if owner is viewing the collection. if u != nil && u.ID == coll.OwnerID { return } // Only update for human views if r.Method == "HEAD" || bots.IsBot(r.UserAgent()) { return } _, err := app.db.Exec("UPDATE collections SET view_count = view_count + 1 WHERE id = ?", coll.ID) if err != nil { log.Error("Unable to update collections count: %v", err) } }() return err } func handleViewMention(app *App, w http.ResponseWriter, r *http.Request) error { vars := mux.Vars(r) handle := vars["handle"] remoteUser, err := app.db.GetProfilePageFromHandle(app, handle) if err != nil || remoteUser == "" { log.Error("Couldn't find user %s: %v", handle, err) return ErrRemoteUserNotFound } return impart.HTTPError{Status: http.StatusFound, Message: remoteUser} } func handleViewCollectionTag(app *App, w http.ResponseWriter, r *http.Request) error { vars := mux.Vars(r) tag := vars["tag"] cr := &collectionReq{} err := processCollectionRequest(cr, vars, w, r) if err != nil { return err } u, err := checkUserForCollection(app, cr, r, false) if err != nil { return err } page := getCollectionPage(vars) c, err := processCollectionPermissions(app, cr, u, w, r) if c == nil || err != nil { return err } coll := newDisplayCollection(c, cr, page) coll.Posts, _ = app.db.GetPostsTagged(app.cfg, c, tag, page, cr.isCollOwner) if coll.Posts != nil && len(*coll.Posts) == 0 { return ErrCollectionPageNotFound } // Serve collection displayPage := struct { CollectionPage Tag string }{ CollectionPage: CollectionPage{ DisplayCollection: coll, StaticPage: pageForReq(app, r), IsCustomDomain: cr.isCustomDomain, }, Tag: tag, } var owner *User if u != nil { displayPage.Username = u.Username displayPage.IsOwner = u.ID == coll.OwnerID if displayPage.IsOwner { // Add in needed information for users viewing their own collection owner = u displayPage.CanPin = true pubColls, err := app.db.GetPublishableCollections(owner, app.cfg.App.Host) if err != nil { log.Error("unable to fetch collections: %v", err) } displayPage.Collections = pubColls } } isOwner := owner != nil if !isOwner { // Current user doesn't own collection; retrieve owner information owner, err = app.db.GetUserByID(coll.OwnerID) if err != nil { // Log the error and just continue log.Error("Error getting user for collection: %v", err) } if owner.IsSilenced() { return ErrCollectionNotFound } } displayPage.Silenced = owner != nil && owner.IsSilenced() displayPage.Owner = owner coll.Owner = displayPage.Owner // Add more data // TODO: fix this mess of collections inside collections displayPage.PinnedPosts, _ = app.db.GetPinnedPosts(coll.CollectionObj, isOwner) displayPage.Monetization = app.db.GetCollectionAttribute(coll.ID, "monetization_pointer") err = templates["collection-tags"].ExecuteTemplate(w, "collection-tags", displayPage) if err != nil { log.Error("Unable to render collection tag page: %v", err) } return nil } func handleCollectionPostRedirect(app *App, w http.ResponseWriter, r *http.Request) error { vars := mux.Vars(r) slug := vars["slug"] cr := &collectionReq{} err := processCollectionRequest(cr, vars, w, r) if err != nil { return err } // Normalize the URL, redirecting user to consistent post URL loc := fmt.Sprintf("/%s", slug) if !app.cfg.App.SingleUser { loc = fmt.Sprintf("/%s/%s", cr.alias, slug) } return impart.HTTPError{http.StatusFound, loc} } func existingCollection(app *App, w http.ResponseWriter, r *http.Request) error { reqJSON := IsJSON(r) vars := mux.Vars(r) collAlias := vars["alias"] isWeb := r.FormValue("web") == "1" u := &User{} if reqJSON && !isWeb { // Ensure an access token was given accessToken := r.Header.Get("Authorization") u.ID = app.db.GetUserID(accessToken) if u.ID == -1 { return ErrBadAccessToken } } else { u = getUserSession(app, r) if u == nil { return ErrNotLoggedIn } } silenced, err := app.db.IsUserSilenced(u.ID) if err != nil { log.Error("existing collection: %v", err) return ErrInternalGeneral } if silenced { return ErrUserSilenced } if r.Method == "DELETE" { err := app.db.DeleteCollection(collAlias, u.ID) if err != nil { // TODO: if not HTTPError, report error to admin log.Error("Unable to delete collection: %s", err) return err } addSessionFlash(app, w, r, "Deleted your blog, "+collAlias+".", nil) return impart.HTTPError{Status: http.StatusNoContent} } c := SubmittedCollection{OwnerID: uint64(u.ID)} if reqJSON { // Decode JSON request decoder := json.NewDecoder(r.Body) err = decoder.Decode(&c) if err != nil { log.Error("Couldn't parse collection update JSON request: %v\n", err) return ErrBadJSON } } else { err = r.ParseForm() if err != nil { log.Error("Couldn't parse collection update form request: %v\n", err) return ErrBadFormData } err = app.formDecoder.Decode(&c, r.PostForm) if err != nil { log.Error("Couldn't decode collection update form request: %v\n", err) return ErrBadFormData } } err = app.db.UpdateCollection(&c, collAlias) if err != nil { if err, ok := err.(impart.HTTPError); ok { if reqJSON { return err } addSessionFlash(app, w, r, err.Message, nil) return impart.HTTPError{http.StatusFound, "/me/c/" + collAlias} } else { log.Error("Couldn't update collection: %v\n", err) return err } } if reqJSON { return impart.WriteSuccess(w, struct { }{}, http.StatusOK) } addSessionFlash(app, w, r, "Blog updated!", nil) return impart.HTTPError{http.StatusFound, "/me/c/" + collAlias} } // collectionAliasFromReq takes a request and returns the collection alias // if it can be ascertained, as well as whether or not the collection uses a // custom domain. func collectionAliasFromReq(r *http.Request) string { vars := mux.Vars(r) alias := vars["subdomain"] isSubdomain := alias != "" if !isSubdomain { // Fall back to write.as/{collection} since this isn't a custom domain alias = vars["collection"] } return alias } func handleWebCollectionUnlock(app *App, w http.ResponseWriter, r *http.Request) error { var readReq struct { Alias string `schema:"alias" json:"alias"` Pass string `schema:"password" json:"password"` Next string `schema:"to" json:"to"` } // Get params if impart.ReqJSON(r) { decoder := json.NewDecoder(r.Body) err := decoder.Decode(&readReq) if err != nil { log.Error("Couldn't parse readReq JSON request: %v\n", err) return ErrBadJSON } } else { err := r.ParseForm() if err != nil { log.Error("Couldn't parse readReq form request: %v\n", err) return ErrBadFormData } err = app.formDecoder.Decode(&readReq, r.PostForm) if err != nil { log.Error("Couldn't decode readReq form request: %v\n", err) return ErrBadFormData } } if readReq.Alias == "" { return impart.HTTPError{http.StatusBadRequest, "Need a collection `alias` to read."} } if readReq.Pass == "" { return impart.HTTPError{http.StatusBadRequest, "Please supply a password."} } var collHashedPass []byte err := app.db.QueryRow("SELECT password FROM collectionpasswords INNER JOIN collections ON id = collection_id WHERE alias = ?", readReq.Alias).Scan(&collHashedPass) if err != nil { if err == sql.ErrNoRows { log.Error("No collectionpassword found when trying to read collection %s", readReq.Alias) return impart.HTTPError{http.StatusInternalServerError, "Something went very wrong. The humans have been alerted."} } return err } if !auth.Authenticated(collHashedPass, []byte(readReq.Pass)) { return impart.HTTPError{http.StatusUnauthorized, "Incorrect password."} } // Success; set cookie session, err := app.sessionStore.Get(r, blogPassCookieName) if err == nil { session.Values[readReq.Alias] = true err = session.Save(r, w) if err != nil { log.Error("Didn't save unlocked blog '%s': %v", readReq.Alias, err) } } next := "/" + readReq.Next if !app.cfg.App.SingleUser { next = "/" + readReq.Alias + next } return impart.HTTPError{http.StatusFound, next} } func isAuthorizedForCollection(app *App, alias string, r *http.Request) bool { authd := false session, err := app.sessionStore.Get(r, blogPassCookieName) if err == nil { _, authd = session.Values[alias] } return authd } func logOutCollection(app *App, alias string, w http.ResponseWriter, r *http.Request) error { session, err := app.sessionStore.Get(r, blogPassCookieName) if err != nil { return err } // Remove this from map of blogs logged into delete(session.Values, alias) // If not auth'd with any blog, delete entire cookie if len(session.Values) == 0 { session.Options.MaxAge = -1 } return session.Save(r, w) } func handleLogOutCollection(app *App, w http.ResponseWriter, r *http.Request) error { alias := collectionAliasFromReq(r) var c *Collection var err error if app.cfg.App.SingleUser { c, err = app.db.GetCollectionByID(1) } else { c, err = app.db.GetCollection(alias) } if err != nil { return err } if !c.IsProtected() { // Invalid to log out of this collection return ErrCollectionPageNotFound } err = logOutCollection(app, c.Alias, w, r) if err != nil { addSessionFlash(app, w, r, "Logging out failed. Try clearing cookies for this site, instead.", nil) } return impart.HTTPError{http.StatusFound, c.CanonicalURL()} } diff --git a/less/prose-editor.less b/less/prose-editor.less index 389ee48..6cd1cb5 100644 --- a/less/prose-editor.less +++ b/less/prose-editor.less @@ -1,450 +1,490 @@ +@classicHorizMargin: 2rem; + body#pad.classic { header { display: flex; justify-content: space-between; align-items: center; } #editor { top: 4em; + bottom: 1em; } #title { top: 4.25rem; bottom: unset; height: auto; font-weight: bold; font-size: 2em; - padding-top: 0; - padding-bottom: 0; + padding: 0; border: 0; } #tools { #belt { float: none; } } #target { ul { a { padding: 0 0.5em !important; } } } } +#title { + margin-left: @classicHorizMargin; + margin-right: @classicHorizMargin; +} + .ProseMirror { position: relative; height: calc(~"100% - 1.6em"); overflow-y: auto; box-sizing: border-box; -moz-box-sizing: border-box; font-size: 1.2em; word-wrap: break-word; white-space: pre-wrap; -webkit-font-variant-ligatures: none; font-variant-ligatures: none; - padding: 0.5em 0; + padding: 0.5em @classicHorizMargin; line-height: 1.5; outline: none; } .ProseMirror pre { white-space: pre-wrap; } .ProseMirror li { position: relative; } .ProseMirror-hideselection *::selection { background: transparent; } .ProseMirror-hideselection *::-moz-selection { background: transparent; } .ProseMirror-hideselection { caret-color: transparent; } .ProseMirror-selectednode { outline: 2px solid #8cf; } /* Make sure li selections wrap around markers */ li.ProseMirror-selectednode { outline: none; } li.ProseMirror-selectednode:after { content: ""; position: absolute; left: -32px; right: -2px; top: -2px; bottom: -2px; border: 2px solid #8cf; pointer-events: none; } .ProseMirror-textblock-dropdown { min-width: 3em; } .ProseMirror-menu { margin: 0 -4px; line-height: 1; } .ProseMirror-tooltip .ProseMirror-menu { width: -webkit-fit-content; width: fit-content; white-space: pre; } .ProseMirror-menuitem { margin-right: 3px; display: inline-block; div { cursor: pointer; } } .ProseMirror-menuseparator { border-right: 1px solid #ddd; margin-right: 3px; } .ProseMirror-menu-dropdown, .ProseMirror-menu-dropdown-menu { font-size: 90%; white-space: nowrap; } .ProseMirror-menu-dropdown { vertical-align: 1px; cursor: pointer; position: relative; padding-right: 15px; } .ProseMirror-menu-dropdown-wrap { padding: 1px 0 1px 4px; display: inline-block; position: relative; } .ProseMirror-menu-dropdown:after { content: ""; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 4px solid currentColor; opacity: .6; position: absolute; right: 4px; top: calc(50% - 2px); } .ProseMirror-menu-dropdown-menu, .ProseMirror-menu-submenu { position: absolute; background: white; color: #666; border: 1px solid #aaa; padding: 2px; } .ProseMirror-menu-dropdown-menu { z-index: 15; min-width: 6em; } .ProseMirror-menu-dropdown-item { cursor: pointer; padding: 2px 8px 2px 4px; } .ProseMirror-menu-dropdown-item:hover { background: #f2f2f2; } .ProseMirror-menu-submenu-wrap { position: relative; margin-right: -4px; } .ProseMirror-menu-submenu-label:after { content: ""; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 4px solid currentColor; opacity: .6; position: absolute; right: 4px; top: calc(50% - 4px); } .ProseMirror-menu-submenu { display: none; min-width: 4em; left: 100%; top: -3px; } .ProseMirror-menu-active { background: #eee; border-radius: 4px; } .ProseMirror-menu-active { background: #eee; border-radius: 4px; } .ProseMirror-menu-disabled { opacity: .3; } .ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu, .ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu { display: block; } .ProseMirror-menubar { + font-family: @sansFont; position: relative; min-height: 1em; color: #666; padding: 0.5em; top: 0; left: 0; right: 0; background: rgba(255, 255, 255, 0.8); z-index: 10; -moz-box-sizing: border-box; box-sizing: border-box; overflow: visible; + margin-left: @classicHorizMargin; + margin-right: @classicHorizMargin; } .ProseMirror-icon { display: inline-block; line-height: .8; vertical-align: -2px; /* Compensate for padding */ padding: 2px 8px; cursor: pointer; } .ProseMirror-menu-disabled.ProseMirror-icon { cursor: default; } .ProseMirror-icon svg { fill: currentColor; height: 1em; } .ProseMirror-icon span { vertical-align: text-top; } .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; } .ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid black; animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; } @keyframes ProseMirror-cursor-blink { to { visibility: hidden; } } .ProseMirror-focused .ProseMirror-gapcursor { display: block; } /* Add space around the hr to make clicking it easier */ .ProseMirror-example-setup-style hr { - padding: 2px 10px; + padding: 4px 10px; border: none; margin: 1em 0; + background: initial; } .ProseMirror-example-setup-style hr:after { content: ""; display: block; height: 1px; - background-color: silver; + background-color: #ccc; line-height: 2px; } .ProseMirror ul, .ProseMirror ol { padding-left: 30px; } .ProseMirror blockquote { padding-left: 1em; - border-left: 3px solid #eee; + border-left: 4px solid #ddd; + color: #767676; margin-left: 0; margin-right: 0; } .ProseMirror-example-setup-style img { cursor: default; + max-width: 100%; } .ProseMirror-prompt { background: white; padding: 1em; border: 1px solid silver; position: fixed; border-radius: 0.25em; z-index: 11; box-shadow: -.5px 2px 5px rgba(0, 0, 0, .2); } .ProseMirror-prompt h5 { margin: 0 0 0.75em; font-family: @sansFont; font-size: 100%; color: #444; } .ProseMirror-prompt input[type="text"], .ProseMirror-prompt textarea { background: #eee; border: none; outline: none; } .ProseMirror-prompt input[type="text"] { margin: 0.25em 0; } .ProseMirror-prompt-close { position: absolute; left: 2px; top: 1px; color: #666; border: none; background: transparent; padding: 0; } .ProseMirror-prompt-close:after { content: "✕"; font-size: 12px; } .ProseMirror-invalid { background: #ffc; border: 1px solid #cc7; border-radius: 4px; padding: 5px 10px; position: absolute; min-width: 10em; } .ProseMirror-prompt-buttons { margin-top: 5px; display: none; } #editor, .editor { position: fixed; top: 0; right: 0; bottom: 0; left: 0; color: black; background-clip: padding-box; padding: 5px 0; margin: 4em auto 23px auto; } +.dark #editor { + color: white; +} + .ProseMirror p:first-child, .ProseMirror h1:first-child, .ProseMirror h2:first-child, .ProseMirror h3:first-child, .ProseMirror h4:first-child, .ProseMirror h5:first-child, .ProseMirror h6:first-child { margin-top: 10px; } .ProseMirror p { margin-bottom: 1em; } textarea { width: 100%; height: 123px; border: 1px solid silver; box-sizing: border-box; -moz-box-sizing: border-box; padding: 3px 10px; border: none; outline: none; font-family: inherit; font-size: inherit; } .ProseMirror-menubar-wrapper { height: 100%; box-sizing: border-box; } .ProseMirror-menubar-wrapper, #markdown textarea { display: block; margin-bottom: 4px; } .editorreadmore { color: @textLinkColor; text-decoration: underline; text-align: center; width: 100%; } @media all and (min-width: 50em) { - #editor { + #photo-upload label { + display: inline; + } + .ProseMirror-menubar, #title, #photo-upload { margin-left: 10%; margin-right: 10%; } + .ProseMirror { + padding-left: 10%; + padding-right: 10%; + } } @media all and (min-width: 60em) { - #editor { + .ProseMirror-menubar, #title, #photo-upload { margin-left: 15%; margin-right: 15%; } + .ProseMirror { + padding-left: 15%; + padding-right: 15%; + } } @media all and (min-width: 70em) { - #editor { + .ProseMirror-menubar, #title, #photo-upload { margin-left: 20%; margin-right: 20%; } + .ProseMirror { + padding-left: 20%; + padding-right: 20%; + } } @media all and (min-width: 85em) { - #editor { + .ProseMirror-menubar, #title, #photo-upload { margin-left: 25%; margin-right: 25%; } + .ProseMirror { + padding-left: 25%; + padding-right: 25%; + } } @media all and (min-width: 105em) { - #editor { + .ProseMirror-menubar, #title, #photo-upload { margin-left: 30%; margin-right: 30%; } + .ProseMirror { + padding-left: 30%; + padding-right: 30%; + } } diff --git a/prose/markdownParser.js b/prose/markdownParser.js index 757a47e..30669d9 100644 --- a/prose/markdownParser.js +++ b/prose/markdownParser.js @@ -1,57 +1,57 @@ import { MarkdownParser } from "prosemirror-markdown"; import markdownit from "markdown-it"; import { writeFreelySchema } from "./schema"; -export const writeAsMarkdownParser = new MarkdownParser( +export const writeFreelyMarkdownParser = new MarkdownParser( writeFreelySchema, markdownit("commonmark", { html: true }), { - // blockquote: { block: "blockquote" }, + blockquote: { block: "blockquote" }, paragraph: { block: "paragraph" }, list_item: { block: "list_item" }, bullet_list: { block: "bullet_list" }, ordered_list: { block: "ordered_list", getAttrs: (tok) => ({ order: +tok.attrGet("start") || 1 }), }, heading: { block: "heading", getAttrs: (tok) => ({ level: +tok.tag.slice(1) }), }, code_block: { block: "code_block", noCloseToken: true }, fence: { block: "code_block", getAttrs: (tok) => ({ params: tok.info || "" }), noCloseToken: true, }, - // hr: { node: "horizontal_rule" }, + hr: { node: "horizontal_rule" }, image: { node: "image", getAttrs: (tok) => ({ src: tok.attrGet("src"), title: tok.attrGet("title") || null, - alt: tok.children?.[0].content || null, + alt: (tok.children !== null && typeof tok.children[0] !== 'undefined' ? tok.children[0].content : null), }), }, hardbreak: { node: "hard_break" }, em: { mark: "em" }, strong: { mark: "strong" }, link: { mark: "link", getAttrs: (tok) => ({ href: tok.attrGet("href"), title: tok.attrGet("title") || null, }), }, code_inline: { mark: "code", noCloseToken: true }, html_block: { node: "readmore", getAttrs(token) { // TODO: Give different attributes depending on the token content return {}; }, }, } ); diff --git a/prose/markdownSerializer.js b/prose/markdownSerializer.js index ef068df..6ccf6bc 100644 --- a/prose/markdownSerializer.js +++ b/prose/markdownSerializer.js @@ -1,123 +1,128 @@ import { MarkdownSerializer } from "prosemirror-markdown"; function backticksFor(node, side) { const ticks = /`+/g; let m; let len = 0; if (node.isText) while ((m = ticks.exec(node.text))) len = Math.max(len, m[0].length); let result = len > 0 && side > 0 ? " `" : "`"; for (let i = 0; i < len; i++) result += "`"; if (len > 0 && side < 0) result += " "; return result; } function isPlainURL(link, parent, index, side) { if (link.attrs.title || !/^\w+:/.test(link.attrs.href)) return false; const content = parent.child(index + (side < 0 ? -1 : 0)); if ( !content.isText || content.text != link.attrs.href || content.marks[content.marks.length - 1] != link ) return false; if (index == (side < 0 ? 1 : parent.childCount - 1)) return true; const next = parent.child(index + (side < 0 ? -2 : 1)); return !link.isInSet(next.marks); } -export const writeAsMarkdownSerializer = new MarkdownSerializer( +export const writeFreelyMarkdownSerializer = new MarkdownSerializer( { readmore(state, node) { state.write("\n"); state.closeBlock(node); }, - // blockquote(state, node) { - // state.wrapBlock("> ", undefined, node, () => state.renderContent(node)); - // }, + blockquote(state, node) { + state.wrapBlock("> ", null, node, () => state.renderContent(node)); + }, code_block(state, node) { state.write(`\`\`\`${node.attrs.params || ""}\n`); state.text(node.textContent, false); state.ensureNewLine(); state.write("```"); state.closeBlock(node); }, heading(state, node) { state.write(`${state.repeat("#", node.attrs.level)} `); state.renderInline(node); state.closeBlock(node); }, + horizontal_rule: function horizontal_rule(state, node) { + state.write(node.attrs.markup || "---"); + state.closeBlock(node); + }, bullet_list(state, node) { + node.attrs.tight = true; state.renderList(node, " ", () => `${node.attrs.bullet || "*"} `); }, ordered_list(state, node) { const start = node.attrs.order || 1; const maxW = String(start + node.childCount - 1).length; const space = state.repeat(" ", maxW + 2); state.renderList(node, space, (i) => { const nStr = String(start + i); return `${state.repeat(" ", maxW - nStr.length) + nStr}. `; }); }, list_item(state, node) { state.renderContent(node); }, paragraph(state, node) { state.renderInline(node); state.closeBlock(node); }, image(state, node) { state.write( `![${state.esc(node.attrs.alt || "")}](${state.esc(node.attrs.src)}${ node.attrs.title ? ` ${state.quote(node.attrs.title)}` : "" })` ); }, hard_break(state, node, parent, index) { for (let i = index + 1; i < parent.childCount; i += 1) if (parent.child(i).type !== node.type) { state.write("\\\n"); return; } }, text(state, node) { state.text(node.text || ""); }, }, { em: { open: "*", close: "*", mixable: true, expelEnclosingWhitespace: true, }, strong: { open: "**", close: "**", mixable: true, expelEnclosingWhitespace: true, }, link: { open(_state, mark, parent, index) { return isPlainURL(mark, parent, index, 1) ? "<" : "["; }, close(state, mark, parent, index) { return isPlainURL(mark, parent, index, -1) ? ">" : `](${state.esc(mark.attrs.href)}${ mark.attrs.title ? ` ${state.quote(mark.attrs.title)}` : "" })`; }, }, code: { open(_state, _mark, parent, index) { return backticksFor(parent.child(index), -1); }, close(_state, _mark, parent, index) { return backticksFor(parent.child(index - 1), 1); }, escape: false, }, } ); diff --git a/prose/package.json b/prose/package.json index 6f81f5e..1584748 100644 --- a/prose/package.json +++ b/prose/package.json @@ -1,32 +1,32 @@ { "name": "prose", "version": "1.0.0", "description": "", "main": "prose.js", "dependencies": { "babel-core": "^6.26.3", "babel-preset-es2015": "^6.24.1", "markdown-it": "^12.0.4", - "prosemirror-example-setup": "^1.1.2", + "prosemirror-example-setup": "github:writefreely/prosemirror-example-setup", "prosemirror-keymap": "^1.1.4", - "prosemirror-markdown": "github:VV-EE/prosemirror-markdown", + "prosemirror-markdown": "github:writefreely/prosemirror-markdown", "prosemirror-model": "^1.9.1", "prosemirror-state": "^1.3.2", "prosemirror-view": "^1.14.2", "webpack": "^4.42.0", "webpack-cli": "^3.3.11" }, "devDependencies": { "@babel/core": "^7.8.7", "@babel/preset-env": "^7.9.0", "babel-loader": "^8.0.6", "prettier": "^2.2.1" }, "scripts": { "develop": "webpack --mode development --watch", "build": "webpack --mode production" }, "keywords": [], "author": "", "license": "ISC" } diff --git a/prose/prose.js b/prose/prose.js index 5a6b618..3096c9e 100644 --- a/prose/prose.js +++ b/prose/prose.js @@ -1,118 +1,118 @@ // class MarkdownView { // constructor(target, content) { // this.textarea = target.appendChild(document.createElement("textarea")) // this.textarea.value = content // } // get content() { return this.textarea.value } // focus() { this.textarea.focus() } // destroy() { this.textarea.remove() } // } import { EditorView } from "prosemirror-view"; import { EditorState, TextSelection } from "prosemirror-state"; import { exampleSetup } from "prosemirror-example-setup"; import { keymap } from "prosemirror-keymap"; -import { writeAsMarkdownParser } from "./markdownParser"; -import { writeAsMarkdownSerializer } from "./markdownSerializer"; +import { writeFreelyMarkdownParser } from "./markdownParser"; +import { writeFreelyMarkdownSerializer } from "./markdownSerializer"; import { writeFreelySchema } from "./schema"; import { getMenu } from "./menu"; let $title = document.querySelector("#title"); let $content = document.querySelector("#content"); // Bugs: // 1. When there's just an empty line and a hard break is inserted with shift-enter then two enters are inserted // which do not show up in the markdown ( maybe bc. they are training enters ) class ProseMirrorView { constructor(target, content) { let typingTimer; let localDraft = localStorage.getItem(window.draftKey); if (localDraft != null) { content = localDraft; } if (content.indexOf("# ") === 0) { let eol = content.indexOf("\n"); let title = content.substring("# ".length, eol); content = content.substring(eol + "\n\n".length); $title.value = title; } - const doc = writeAsMarkdownParser.parse( + const doc = writeFreelyMarkdownParser.parse( // Replace all "solo" \n's with \\\n for correct markdown parsing // Can't use lookahead or lookbehind because it's not supported on Safari content.replace(/([^]{0,1})(\n)([^]{0,1})/g, (match, p1, p2, p3) => { return p1 !== "\n" && p3 !== "\n" ? p1 + "\\\n" + p3 : match; }) ); this.view = new EditorView(target, { state: EditorState.create({ doc, plugins: [ keymap({ "Mod-Enter": () => { document.getElementById("publish").click(); return true; }, "Mod-k": () => { const linkButton = document.querySelector( ".ProseMirror-icon[title='Add or remove link']" ); linkButton.dispatchEvent(new Event("mousedown")); return true; }, }), ...exampleSetup({ schema: writeFreelySchema, menuContent: getMenu(), }), ], }), dispatchTransaction(transaction) { let newState = this.state.apply(transaction); - const newContent = writeAsMarkdownSerializer + const newContent = writeFreelyMarkdownSerializer .serialize(newState.doc) // Replace all \\\ns ( not followed by a \n ) with \n .replace(/(\\\n)(\n{0,1})/g, (match, p1, p2) => p2 !== "\n" ? "\n" + p2 : match ); $content.value = newContent; let draft = ""; if ($title.value != null && $title.value !== "") { draft = "# " + $title.value + "\n\n"; } draft += newContent; clearTimeout(typingTimer); typingTimer = setTimeout(doneTyping, doneTypingInterval); this.updateState(newState); }, }); // Editor is focused to the last position. This is a workaround for a bug: // 1. 1 type something in an existing entry // 2. reload - works fine, the draft is reloaded // 3. reload again - the draft is somehow removed from localStorage and the original content is loaded // When the editor is focused the content is re-saved to localStorage // This is also useful for editing, so it's not a bad thing even const lastPosition = this.view.state.doc.content.size; const selection = TextSelection.create(this.view.state.doc, lastPosition); this.view.dispatch(this.view.state.tr.setSelection(selection)); this.view.focus(); } get content() { - return defaultMarkdownSerializer.serialize(this.view.state.doc); + return writeFreelyMarkdownSerializer.serialize(this.view.state.doc); } focus() { this.view.focus(); } destroy() { this.view.destroy(); } } let place = document.querySelector("#editor"); let view = new ProseMirrorView(place, $content.value); diff --git a/prose/schema.js b/prose/schema.js index 67302df..eeebbd9 100644 --- a/prose/schema.js +++ b/prose/schema.js @@ -1,21 +1,19 @@ import { schema } from "prosemirror-markdown"; import { Schema } from "prosemirror-model"; export const writeFreelySchema = new Schema({ nodes: schema.spec.nodes - .remove("blockquote") - .remove("horizontal_rule") .addToEnd("readmore", { inline: false, content: "", group: "block", draggable: true, toDOM: (node) => [ "div", { class: "editorreadmore" }, "Read more...", ], parseDOM: [{ tag: "div.editorreadmore" }], }), marks: schema.spec.marks, }); diff --git a/session.go b/session.go index e379496..81d628f 100644 --- a/session.go +++ b/session.go @@ -1,138 +1,141 @@ /* * Copyright © 2018-2019 A Bunch Tell LLC. * * This file is part of WriteFreely. * * WriteFreely is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, included * in the LICENSE file in this source code package. */ package writefreely import ( "encoding/gob" "github.com/gorilla/sessions" "github.com/writeas/web-core/log" "net/http" "strings" ) const ( day = 86400 sessionLength = 180 * day cookieName = "wfu" cookieUserVal = "u" blogPassCookieName = "ub" ) // InitSession creates the cookie store. It depends on the keychain already // being loaded. func (app *App) InitSession() { // Register complex data types we'll be storing in cookies gob.Register(&User{}) // Create the cookie store store := sessions.NewCookieStore(app.keys.CookieAuthKey, app.keys.CookieKey) store.Options = &sessions.Options{ Path: "/", MaxAge: sessionLength, HttpOnly: true, Secure: strings.HasPrefix(app.cfg.App.Host, "https://"), } + if store.Options.Secure { + store.Options.SameSite = http.SameSiteNoneMode + } app.sessionStore = store } func getSessionFlashes(app *App, w http.ResponseWriter, r *http.Request, session *sessions.Session) ([]string, error) { var err error if session == nil { session, err = app.sessionStore.Get(r, cookieName) if err != nil { return nil, err } } f := []string{} if flashes := session.Flashes(); len(flashes) > 0 { for _, flash := range flashes { if str, ok := flash.(string); ok { f = append(f, str) } } } saveUserSession(app, r, w) return f, nil } func addSessionFlash(app *App, w http.ResponseWriter, r *http.Request, m string, session *sessions.Session) error { var err error if session == nil { session, err = app.sessionStore.Get(r, cookieName) } if err != nil { log.Error("Unable to add flash '%s': %v", m, err) return err } session.AddFlash(m) saveUserSession(app, r, w) return nil } func getUserAndSession(app *App, r *http.Request) (*User, *sessions.Session) { session, err := app.sessionStore.Get(r, cookieName) if err == nil { // Got the currently logged-in user val := session.Values[cookieUserVal] var u = &User{} var ok bool if u, ok = val.(*User); ok { return u, session } } return nil, nil } func getUserSession(app *App, r *http.Request) *User { u, _ := getUserAndSession(app, r) return u } func saveUserSession(app *App, r *http.Request, w http.ResponseWriter) error { session, err := app.sessionStore.Get(r, cookieName) if err != nil { return ErrInternalCookieSession } // Extend the session session.Options.MaxAge = int(sessionLength) // Remove any information that accidentally got added // FIXME: find where Plan information is getting saved to cookie. val := session.Values[cookieUserVal] var u = &User{} var ok bool if u, ok = val.(*User); ok { session.Values[cookieUserVal] = u.Cookie() } err = session.Save(r, w) if err != nil { log.Error("Couldn't saveUserSession: %v", err) } return err } func getFullUserSession(app *App, r *http.Request) *User { u := getUserSession(app, r) if u == nil { return nil } u, _ = app.db.GetUserByID(u.ID) return u } diff --git a/static/js/.gitignore b/static/js/.gitignore new file mode 100644 index 0000000..b54345e --- /dev/null +++ b/static/js/.gitignore @@ -0,0 +1 @@ +prose.bundle.js \ No newline at end of file diff --git a/static/js/prose.bundle.js b/static/js/prose.bundle.js deleted file mode 100644 index e371a63..0000000 --- a/static/js/prose.bundle.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=125)}([function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o=Object.prototype.hasOwnProperty;function i(t,e){return o.call(t,e)}function s(t){return!(t>=55296&&t<=57343)&&(!(t>=64976&&t<=65007)&&(65535!=(65535&t)&&65534!=(65535&t)&&(!(t>=0&&t<=8)&&(11!==t&&(!(t>=14&&t<=31)&&(!(t>=127&&t<=159)&&!(t>1114111)))))))}function a(t){if(t>65535){var e=55296+((t-=65536)>>10),r=56320+(1023&t);return String.fromCharCode(e,r)}return String.fromCharCode(t)}var c=/\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g,l=new RegExp(c.source+"|"+/&([a-z#][a-z0-9]{1,31});/gi.source,"gi"),u=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i,p=r(11);var h=/[&<>"]/,f=/[&<>"]/g,d={"&":"&","<":"<",">":">",'"':"""};function m(t){return d[t]}var g=/[.?*+^$[\]\\(){}|-]/g;var v=r(2);e.lib={},e.lib.mdurl=r(3),e.lib.ucmicro=r(12),e.assign=function(t){var e=Array.prototype.slice.call(arguments,1);return e.forEach((function(e){if(e){if("object"!==n(e))throw new TypeError(e+"must be object");Object.keys(e).forEach((function(r){t[r]=e[r]}))}})),t},e.isString=function(t){return"[object String]"===function(t){return Object.prototype.toString.call(t)}(t)},e.has=i,e.unescapeMd=function(t){return t.indexOf("\\")<0?t:t.replace(c,"$1")},e.unescapeAll=function(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(l,(function(t,e,r){return e||function(t,e){var r=0;return i(p,e)?p[e]:35===e.charCodeAt(0)&&u.test(e)&&s(r="x"===e[1].toLowerCase()?parseInt(e.slice(2),16):parseInt(e.slice(1),10))?a(r):t}(t,r)}))},e.isValidEntityCode=s,e.fromCodePoint=a,e.escapeHtml=function(t){return h.test(t)?t.replace(f,m):t},e.arrayReplaceAt=function(t,e,r){return[].concat(t.slice(0,e),r,t.slice(e+1))},e.isSpace=function(t){switch(t){case 9:case 32:return!0}return!1},e.isWhiteSpace=function(t){if(t>=8192&&t<=8202)return!0;switch(t){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1},e.isMdAsciiPunct=function(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}},e.isPunctChar=function(t){return v.test(t)},e.escapeRE=function(t){return t.replace(g,"\\$&")},e.normalizeReference=function(t){return t=t.trim().replace(/\s+/g," "),"Ṿ"==="ẞ".toLowerCase()&&(t=t.replace(/ẞ/g,"ß")),t.toLowerCase().toUpperCase()}},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o=Object.prototype.hasOwnProperty;function i(t,e){return o.call(t,e)}function s(t){return!(t>=55296&&t<=57343)&&(!(t>=64976&&t<=65007)&&(65535!=(65535&t)&&65534!=(65535&t)&&(!(t>=0&&t<=8)&&(11!==t&&(!(t>=14&&t<=31)&&(!(t>=127&&t<=159)&&!(t>1114111)))))))}function a(t){if(t>65535){var e=55296+((t-=65536)>>10),r=56320+(1023&t);return String.fromCharCode(e,r)}return String.fromCharCode(t)}var c=/\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g,l=new RegExp(c.source+"|"+/&([a-z#][a-z0-9]{1,31});/gi.source,"gi"),u=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i,p=r(18);var h=/[&<>"]/,f=/[&<>"]/g,d={"&":"&","<":"<",">":">",'"':"""};function m(t){return d[t]}var g=/[.?*+^$[\]\\(){}|-]/g;var v=r(2);e.lib={},e.lib.mdurl=r(3),e.lib.ucmicro=r(12),e.assign=function(t){var e=Array.prototype.slice.call(arguments,1);return e.forEach((function(e){if(e){if("object"!==n(e))throw new TypeError(e+"must be object");Object.keys(e).forEach((function(r){t[r]=e[r]}))}})),t},e.isString=function(t){return"[object String]"===function(t){return Object.prototype.toString.call(t)}(t)},e.has=i,e.unescapeMd=function(t){return t.indexOf("\\")<0?t:t.replace(c,"$1")},e.unescapeAll=function(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(l,(function(t,e,r){return e||function(t,e){var r=0;return i(p,e)?p[e]:35===e.charCodeAt(0)&&u.test(e)&&s(r="x"===e[1].toLowerCase()?parseInt(e.slice(2),16):parseInt(e.slice(1),10))?a(r):t}(t,r)}))},e.isValidEntityCode=s,e.fromCodePoint=a,e.escapeHtml=function(t){return h.test(t)?t.replace(f,m):t},e.arrayReplaceAt=function(t,e,r){return[].concat(t.slice(0,e),r,t.slice(e+1))},e.isSpace=function(t){switch(t){case 9:case 32:return!0}return!1},e.isWhiteSpace=function(t){if(t>=8192&&t<=8202)return!0;switch(t){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1},e.isMdAsciiPunct=function(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}},e.isPunctChar=function(t){return v.test(t)},e.escapeRE=function(t){return t.replace(g,"\\$&")},e.normalizeReference=function(t){return t=t.trim().replace(/\s+/g," "),"Ṿ"==="ẞ".toLowerCase()&&(t=t.replace(/ẞ/g,"ß")),t.toLowerCase().toUpperCase()}},function(t,e){t.exports=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/},function(t,e,r){"use strict";t.exports.encode=r(26),t.exports.decode=r(27),t.exports.format=r(28),t.exports.parse=r(29)},function(t,e){t.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/},function(t,e){t.exports=/[\0-\x1F\x7F-\x9F]/},function(t,e){t.exports=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/},function(t,e,r){"use strict";function n(){this.__rules__=[],this.__cache__=null}n.prototype.__find__=function(t){for(var e=0;e=0&&(r=this.attrs[e][1]),r},n.prototype.attrJoin=function(t,e){var r=this.attrIndex(t);r<0?this.attrPush([t,e]):this.attrs[r][1]=this.attrs[r][1]+" "+e},t.exports=n},function(t,e,r){"use strict";function n(){this.__rules__=[],this.__cache__=null}n.prototype.__find__=function(t){for(var e=0;e=0&&(r=this.attrs[e][1]),r},n.prototype.attrJoin=function(t,e){var r=this.attrIndex(t);r<0?this.attrPush([t,e]):this.attrs[r][1]=this.attrs[r][1]+" "+e},t.exports=n},function(t,e,r){"use strict";t.exports=r(25)},function(t,e,r){"use strict";e.Any=r(4),e.Cc=r(5),e.Cf=r(30),e.P=r(2),e.Z=r(6)},function(t,e,r){"use strict";var n="<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",o="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",i=new RegExp("^(?:"+n+"|"+o+"|\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e|<[?].*?[?]>|]*>|)"),s=new RegExp("^(?:"+n+"|"+o+")");t.exports.HTML_TAG_RE=i,t.exports.HTML_OPEN_CLOSE_TAG_RE=s},function(t,e,r){"use strict";function n(t,e){var r,n,o,i,s,a=[],c=e.length;for(r=0;r=0;r--)95!==(n=e[r]).marker&&42!==n.marker||-1!==n.end&&(o=e[n.end],a=r>0&&e[r-1].end===n.end+1&&e[r-1].token===n.token-1&&e[n.end+1].token===o.token+1&&e[r-1].marker===n.marker,s=String.fromCharCode(n.marker),(i=t.tokens[n.token]).type=a?"strong_open":"em_open",i.tag=a?"strong":"em",i.nesting=1,i.markup=a?s+s:s,i.content="",(i=t.tokens[o.token]).type=a?"strong_close":"em_close",i.tag=a?"strong":"em",i.nesting=-1,i.markup=a?s+s:s,i.content="",a&&(t.tokens[e[r-1].token].content="",t.tokens[e[n.end+1].token].content="",r--))}t.exports.tokenize=function(t,e){var r,n,o=t.pos,i=t.src.charCodeAt(o);if(e)return!1;if(95!==i&&42!==i)return!1;for(n=t.scanDelims(t.pos,42===i),r=0;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=Math.floor,y=String.fromCharCode;function b(t){throw new RangeError(g[t])}function k(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function _(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+k((t=t.replace(m,".")).split("."),e).join(".")}function w(t){for(var e,r,n=[],o=0,i=t.length;o=55296&&e<=56319&&o65535&&(e+=y((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=y(t)})).join("")}function C(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function S(t,e,r){var n=0;for(t=r?v(t/700):t>>1,t+=v(t/e);t>455;n+=36)t=v(t/35);return v(n+36*t/(t+38))}function A(t){var e,r,n,o,i,s,a,c,l,u,p,f=[],d=t.length,m=0,g=128,y=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n=128&&b("not-basic"),f.push(t.charCodeAt(n));for(o=r>0?r+1:0;o=d&&b("invalid-input"),((c=(p=t.charCodeAt(o++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:36)>=36||c>v((h-m)/s))&&b("overflow"),m+=c*s,!(c<(l=a<=y?1:a>=y+26?26:a-y));a+=36)s>v(h/(u=36-l))&&b("overflow"),s*=u;y=S(m-i,e=f.length+1,0==i),v(m/e)>h-g&&b("overflow"),g+=v(m/e),m%=e,f.splice(m++,0,g)}return x(f)}function E(t){var e,r,n,o,i,s,a,c,l,u,p,f,d,m,g,k=[];for(f=(t=w(t)).length,e=128,r=0,i=72,s=0;s=e&&pv((h-r)/(d=n+1))&&b("overflow"),r+=(a-e)*d,e=a,s=0;sh&&b("overflow"),p==e){for(c=r,l=36;!(c<(u=l<=i?1:l>=i+26?26:l-i));l+=36)g=c-u,m=36-u,k.push(y(C(u+g%m,0))),c=v(g/m);k.push(y(C(c,0))),i=S(r,d,n==o),r=0,++n}++r,++e}return k.join("")}if(u={version:"1.4.1",ucs2:{decode:w,encode:x},decode:A,encode:E,toASCII:function(t){return _(t,(function(t){return d.test(t)?"xn--"+E(t):t}))},toUnicode:function(t){return _(t,(function(t){return f.test(t)?A(t.slice(4).toLowerCase()):t}))}},"object"==i(r(17))&&r(17))void 0===(o=function(){return u}.call(e,r,e,t))||(t.exports=o);else if(a&&c)if(t.exports==a)c.exports=u;else for(p in u)u.hasOwnProperty(p)&&(a[p]=u[p]);else s.punycode=u}(this)}).call(this,r(73)(t),r(74))},function(t,e){(function(e){t.exports=e}).call(this,{})},function(t,e,r){"use strict";t.exports=r(79)},function(t,e,r){"use strict";var n="<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",o="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",i=new RegExp("^(?:"+n+"|"+o+"|\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e|<[?][\\s\\S]*?[?]>|]*>|)"),s=new RegExp("^(?:"+n+"|"+o+")");t.exports.HTML_TAG_RE=i,t.exports.HTML_OPEN_CLOSE_TAG_RE=s},function(t,e,r){"use strict";function n(t,e){var r,n,o,i,s,a=[],c=e.length;for(r=0;r=0;r--)95!==(n=e[r]).marker&&42!==n.marker||-1!==n.end&&(o=e[n.end],a=r>0&&e[r-1].end===n.end+1&&e[r-1].token===n.token-1&&e[n.end+1].token===o.token+1&&e[r-1].marker===n.marker,s=String.fromCharCode(n.marker),(i=t.tokens[n.token]).type=a?"strong_open":"em_open",i.tag=a?"strong":"em",i.nesting=1,i.markup=a?s+s:s,i.content="",(i=t.tokens[o.token]).type=a?"strong_close":"em_close",i.tag=a?"strong":"em",i.nesting=-1,i.markup=a?s+s:s,i.content="",a&&(t.tokens[e[r-1].token].content="",t.tokens[e[n.end+1].token].content="",r--))}t.exports.tokenize=function(t,e){var r,n,o=t.pos,i=t.src.charCodeAt(o);if(e)return!1;if(95!==i&&42!==i)return!1;for(n=t.scanDelims(t.pos,42===i),r=0;r=0))try{e.hostname=p.toASCII(e.hostname)}catch(t){}return u.encode(u.format(e))}function y(t){var e=u.parse(t,!0);if(e.hostname&&(!e.protocol||g.indexOf(e.protocol)>=0))try{e.hostname=p.toUnicode(e.hostname)}catch(t){}return u.decode(u.format(e))}function b(t,e){if(!(this instanceof b))return new b(t,e);e||n.isString(t)||(e=t||{},t="default"),this.inline=new c,this.block=new a,this.core=new s,this.renderer=new i,this.linkify=new l,this.validateLink=m,this.normalizeLink=v,this.normalizeLinkText=y,this.utils=n,this.helpers=n.assign({},o),this.options={},this.configure(t),e&&this.set(e)}b.prototype.set=function(t){return n.assign(this.options,t),this},b.prototype.configure=function(t){var e,r=this;if(n.isString(t)&&!(t=h[e=t]))throw new Error('Wrong `markdown-it` preset "'+e+'", check name');if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");return t.options&&r.set(t.options),t.components&&Object.keys(t.components).forEach((function(e){t.components[e].rules&&r[e].ruler.enableOnly(t.components[e].rules),t.components[e].rules2&&r[e].ruler2.enableOnly(t.components[e].rules2)})),this},b.prototype.enable=function(t,e){var r=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.enable(t,!0))}),this),r=r.concat(this.inline.ruler2.enable(t,!0));var n=t.filter((function(t){return r.indexOf(t)<0}));if(n.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+n);return this},b.prototype.disable=function(t,e){var r=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.disable(t,!0))}),this),r=r.concat(this.inline.ruler2.disable(t,!0));var n=t.filter((function(t){return r.indexOf(t)<0}));if(n.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+n);return this},b.prototype.use=function(t){var e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this},b.prototype.parse=function(t,e){if("string"!=typeof t)throw new Error("Input data should be a String");var r=new this.core.State(t,this,e);return this.core.process(r),r.tokens},b.prototype.render=function(t,e){return e=e||{},this.renderer.render(this.parse(t,e),this.options,e)},b.prototype.parseInline=function(t,e){var r=new this.core.State(t,this,e);return r.inlineMode=!0,this.core.process(r),r.tokens},b.prototype.renderInline=function(t,e){return e=e||{},this.renderer.render(this.parseInline(t,e),this.options,e)},t.exports=b},function(t){t.exports=JSON.parse('{"Aacute":"Á","aacute":"á","Abreve":"Ă","abreve":"ă","ac":"∾","acd":"∿","acE":"∾̳","Acirc":"Â","acirc":"â","acute":"´","Acy":"А","acy":"а","AElig":"Æ","aelig":"æ","af":"⁡","Afr":"𝔄","afr":"𝔞","Agrave":"À","agrave":"à","alefsym":"ℵ","aleph":"ℵ","Alpha":"Α","alpha":"α","Amacr":"Ā","amacr":"ā","amalg":"⨿","amp":"&","AMP":"&","andand":"⩕","And":"⩓","and":"∧","andd":"⩜","andslope":"⩘","andv":"⩚","ang":"∠","ange":"⦤","angle":"∠","angmsdaa":"⦨","angmsdab":"⦩","angmsdac":"⦪","angmsdad":"⦫","angmsdae":"⦬","angmsdaf":"⦭","angmsdag":"⦮","angmsdah":"⦯","angmsd":"∡","angrt":"∟","angrtvb":"⊾","angrtvbd":"⦝","angsph":"∢","angst":"Å","angzarr":"⍼","Aogon":"Ą","aogon":"ą","Aopf":"𝔸","aopf":"𝕒","apacir":"⩯","ap":"≈","apE":"⩰","ape":"≊","apid":"≋","apos":"\'","ApplyFunction":"⁡","approx":"≈","approxeq":"≊","Aring":"Å","aring":"å","Ascr":"𝒜","ascr":"𝒶","Assign":"≔","ast":"*","asymp":"≈","asympeq":"≍","Atilde":"Ã","atilde":"ã","Auml":"Ä","auml":"ä","awconint":"∳","awint":"⨑","backcong":"≌","backepsilon":"϶","backprime":"‵","backsim":"∽","backsimeq":"⋍","Backslash":"∖","Barv":"⫧","barvee":"⊽","barwed":"⌅","Barwed":"⌆","barwedge":"⌅","bbrk":"⎵","bbrktbrk":"⎶","bcong":"≌","Bcy":"Б","bcy":"б","bdquo":"„","becaus":"∵","because":"∵","Because":"∵","bemptyv":"⦰","bepsi":"϶","bernou":"ℬ","Bernoullis":"ℬ","Beta":"Β","beta":"β","beth":"ℶ","between":"≬","Bfr":"𝔅","bfr":"𝔟","bigcap":"⋂","bigcirc":"◯","bigcup":"⋃","bigodot":"⨀","bigoplus":"⨁","bigotimes":"⨂","bigsqcup":"⨆","bigstar":"★","bigtriangledown":"▽","bigtriangleup":"△","biguplus":"⨄","bigvee":"⋁","bigwedge":"⋀","bkarow":"⤍","blacklozenge":"⧫","blacksquare":"▪","blacktriangle":"▴","blacktriangledown":"▾","blacktriangleleft":"◂","blacktriangleright":"▸","blank":"␣","blk12":"▒","blk14":"░","blk34":"▓","block":"█","bne":"=⃥","bnequiv":"≡⃥","bNot":"⫭","bnot":"⌐","Bopf":"𝔹","bopf":"𝕓","bot":"⊥","bottom":"⊥","bowtie":"⋈","boxbox":"⧉","boxdl":"┐","boxdL":"╕","boxDl":"╖","boxDL":"╗","boxdr":"┌","boxdR":"╒","boxDr":"╓","boxDR":"╔","boxh":"─","boxH":"═","boxhd":"┬","boxHd":"╤","boxhD":"╥","boxHD":"╦","boxhu":"┴","boxHu":"╧","boxhU":"╨","boxHU":"╩","boxminus":"⊟","boxplus":"⊞","boxtimes":"⊠","boxul":"┘","boxuL":"╛","boxUl":"╜","boxUL":"╝","boxur":"└","boxuR":"╘","boxUr":"╙","boxUR":"╚","boxv":"│","boxV":"║","boxvh":"┼","boxvH":"╪","boxVh":"╫","boxVH":"╬","boxvl":"┤","boxvL":"╡","boxVl":"╢","boxVL":"╣","boxvr":"├","boxvR":"╞","boxVr":"╟","boxVR":"╠","bprime":"‵","breve":"˘","Breve":"˘","brvbar":"¦","bscr":"𝒷","Bscr":"ℬ","bsemi":"⁏","bsim":"∽","bsime":"⋍","bsolb":"⧅","bsol":"\\\\","bsolhsub":"⟈","bull":"•","bullet":"•","bump":"≎","bumpE":"⪮","bumpe":"≏","Bumpeq":"≎","bumpeq":"≏","Cacute":"Ć","cacute":"ć","capand":"⩄","capbrcup":"⩉","capcap":"⩋","cap":"∩","Cap":"⋒","capcup":"⩇","capdot":"⩀","CapitalDifferentialD":"ⅅ","caps":"∩︀","caret":"⁁","caron":"ˇ","Cayleys":"ℭ","ccaps":"⩍","Ccaron":"Č","ccaron":"č","Ccedil":"Ç","ccedil":"ç","Ccirc":"Ĉ","ccirc":"ĉ","Cconint":"∰","ccups":"⩌","ccupssm":"⩐","Cdot":"Ċ","cdot":"ċ","cedil":"¸","Cedilla":"¸","cemptyv":"⦲","cent":"¢","centerdot":"·","CenterDot":"·","cfr":"𝔠","Cfr":"ℭ","CHcy":"Ч","chcy":"ч","check":"✓","checkmark":"✓","Chi":"Χ","chi":"χ","circ":"ˆ","circeq":"≗","circlearrowleft":"↺","circlearrowright":"↻","circledast":"⊛","circledcirc":"⊚","circleddash":"⊝","CircleDot":"⊙","circledR":"®","circledS":"Ⓢ","CircleMinus":"⊖","CirclePlus":"⊕","CircleTimes":"⊗","cir":"○","cirE":"⧃","cire":"≗","cirfnint":"⨐","cirmid":"⫯","cirscir":"⧂","ClockwiseContourIntegral":"∲","CloseCurlyDoubleQuote":"”","CloseCurlyQuote":"’","clubs":"♣","clubsuit":"♣","colon":":","Colon":"∷","Colone":"⩴","colone":"≔","coloneq":"≔","comma":",","commat":"@","comp":"∁","compfn":"∘","complement":"∁","complexes":"ℂ","cong":"≅","congdot":"⩭","Congruent":"≡","conint":"∮","Conint":"∯","ContourIntegral":"∮","copf":"𝕔","Copf":"ℂ","coprod":"∐","Coproduct":"∐","copy":"©","COPY":"©","copysr":"℗","CounterClockwiseContourIntegral":"∳","crarr":"↵","cross":"✗","Cross":"⨯","Cscr":"𝒞","cscr":"𝒸","csub":"⫏","csube":"⫑","csup":"⫐","csupe":"⫒","ctdot":"⋯","cudarrl":"⤸","cudarrr":"⤵","cuepr":"⋞","cuesc":"⋟","cularr":"↶","cularrp":"⤽","cupbrcap":"⩈","cupcap":"⩆","CupCap":"≍","cup":"∪","Cup":"⋓","cupcup":"⩊","cupdot":"⊍","cupor":"⩅","cups":"∪︀","curarr":"↷","curarrm":"⤼","curlyeqprec":"⋞","curlyeqsucc":"⋟","curlyvee":"⋎","curlywedge":"⋏","curren":"¤","curvearrowleft":"↶","curvearrowright":"↷","cuvee":"⋎","cuwed":"⋏","cwconint":"∲","cwint":"∱","cylcty":"⌭","dagger":"†","Dagger":"‡","daleth":"ℸ","darr":"↓","Darr":"↡","dArr":"⇓","dash":"‐","Dashv":"⫤","dashv":"⊣","dbkarow":"⤏","dblac":"˝","Dcaron":"Ď","dcaron":"ď","Dcy":"Д","dcy":"д","ddagger":"‡","ddarr":"⇊","DD":"ⅅ","dd":"ⅆ","DDotrahd":"⤑","ddotseq":"⩷","deg":"°","Del":"∇","Delta":"Δ","delta":"δ","demptyv":"⦱","dfisht":"⥿","Dfr":"𝔇","dfr":"𝔡","dHar":"⥥","dharl":"⇃","dharr":"⇂","DiacriticalAcute":"´","DiacriticalDot":"˙","DiacriticalDoubleAcute":"˝","DiacriticalGrave":"`","DiacriticalTilde":"˜","diam":"⋄","diamond":"⋄","Diamond":"⋄","diamondsuit":"♦","diams":"♦","die":"¨","DifferentialD":"ⅆ","digamma":"ϝ","disin":"⋲","div":"÷","divide":"÷","divideontimes":"⋇","divonx":"⋇","DJcy":"Ђ","djcy":"ђ","dlcorn":"⌞","dlcrop":"⌍","dollar":"$","Dopf":"𝔻","dopf":"𝕕","Dot":"¨","dot":"˙","DotDot":"⃜","doteq":"≐","doteqdot":"≑","DotEqual":"≐","dotminus":"∸","dotplus":"∔","dotsquare":"⊡","doublebarwedge":"⌆","DoubleContourIntegral":"∯","DoubleDot":"¨","DoubleDownArrow":"⇓","DoubleLeftArrow":"⇐","DoubleLeftRightArrow":"⇔","DoubleLeftTee":"⫤","DoubleLongLeftArrow":"⟸","DoubleLongLeftRightArrow":"⟺","DoubleLongRightArrow":"⟹","DoubleRightArrow":"⇒","DoubleRightTee":"⊨","DoubleUpArrow":"⇑","DoubleUpDownArrow":"⇕","DoubleVerticalBar":"∥","DownArrowBar":"⤓","downarrow":"↓","DownArrow":"↓","Downarrow":"⇓","DownArrowUpArrow":"⇵","DownBreve":"̑","downdownarrows":"⇊","downharpoonleft":"⇃","downharpoonright":"⇂","DownLeftRightVector":"⥐","DownLeftTeeVector":"⥞","DownLeftVectorBar":"⥖","DownLeftVector":"↽","DownRightTeeVector":"⥟","DownRightVectorBar":"⥗","DownRightVector":"⇁","DownTeeArrow":"↧","DownTee":"⊤","drbkarow":"⤐","drcorn":"⌟","drcrop":"⌌","Dscr":"𝒟","dscr":"𝒹","DScy":"Ѕ","dscy":"ѕ","dsol":"⧶","Dstrok":"Đ","dstrok":"đ","dtdot":"⋱","dtri":"▿","dtrif":"▾","duarr":"⇵","duhar":"⥯","dwangle":"⦦","DZcy":"Џ","dzcy":"џ","dzigrarr":"⟿","Eacute":"É","eacute":"é","easter":"⩮","Ecaron":"Ě","ecaron":"ě","Ecirc":"Ê","ecirc":"ê","ecir":"≖","ecolon":"≕","Ecy":"Э","ecy":"э","eDDot":"⩷","Edot":"Ė","edot":"ė","eDot":"≑","ee":"ⅇ","efDot":"≒","Efr":"𝔈","efr":"𝔢","eg":"⪚","Egrave":"È","egrave":"è","egs":"⪖","egsdot":"⪘","el":"⪙","Element":"∈","elinters":"⏧","ell":"ℓ","els":"⪕","elsdot":"⪗","Emacr":"Ē","emacr":"ē","empty":"∅","emptyset":"∅","EmptySmallSquare":"◻","emptyv":"∅","EmptyVerySmallSquare":"▫","emsp13":" ","emsp14":" ","emsp":" ","ENG":"Ŋ","eng":"ŋ","ensp":" ","Eogon":"Ę","eogon":"ę","Eopf":"𝔼","eopf":"𝕖","epar":"⋕","eparsl":"⧣","eplus":"⩱","epsi":"ε","Epsilon":"Ε","epsilon":"ε","epsiv":"ϵ","eqcirc":"≖","eqcolon":"≕","eqsim":"≂","eqslantgtr":"⪖","eqslantless":"⪕","Equal":"⩵","equals":"=","EqualTilde":"≂","equest":"≟","Equilibrium":"⇌","equiv":"≡","equivDD":"⩸","eqvparsl":"⧥","erarr":"⥱","erDot":"≓","escr":"ℯ","Escr":"ℰ","esdot":"≐","Esim":"⩳","esim":"≂","Eta":"Η","eta":"η","ETH":"Ð","eth":"ð","Euml":"Ë","euml":"ë","euro":"€","excl":"!","exist":"∃","Exists":"∃","expectation":"ℰ","exponentiale":"ⅇ","ExponentialE":"ⅇ","fallingdotseq":"≒","Fcy":"Ф","fcy":"ф","female":"♀","ffilig":"ffi","fflig":"ff","ffllig":"ffl","Ffr":"𝔉","ffr":"𝔣","filig":"fi","FilledSmallSquare":"◼","FilledVerySmallSquare":"▪","fjlig":"fj","flat":"♭","fllig":"fl","fltns":"▱","fnof":"ƒ","Fopf":"𝔽","fopf":"𝕗","forall":"∀","ForAll":"∀","fork":"⋔","forkv":"⫙","Fouriertrf":"ℱ","fpartint":"⨍","frac12":"½","frac13":"⅓","frac14":"¼","frac15":"⅕","frac16":"⅙","frac18":"⅛","frac23":"⅔","frac25":"⅖","frac34":"¾","frac35":"⅗","frac38":"⅜","frac45":"⅘","frac56":"⅚","frac58":"⅝","frac78":"⅞","frasl":"⁄","frown":"⌢","fscr":"𝒻","Fscr":"ℱ","gacute":"ǵ","Gamma":"Γ","gamma":"γ","Gammad":"Ϝ","gammad":"ϝ","gap":"⪆","Gbreve":"Ğ","gbreve":"ğ","Gcedil":"Ģ","Gcirc":"Ĝ","gcirc":"ĝ","Gcy":"Г","gcy":"г","Gdot":"Ġ","gdot":"ġ","ge":"≥","gE":"≧","gEl":"⪌","gel":"⋛","geq":"≥","geqq":"≧","geqslant":"⩾","gescc":"⪩","ges":"⩾","gesdot":"⪀","gesdoto":"⪂","gesdotol":"⪄","gesl":"⋛︀","gesles":"⪔","Gfr":"𝔊","gfr":"𝔤","gg":"≫","Gg":"⋙","ggg":"⋙","gimel":"ℷ","GJcy":"Ѓ","gjcy":"ѓ","gla":"⪥","gl":"≷","glE":"⪒","glj":"⪤","gnap":"⪊","gnapprox":"⪊","gne":"⪈","gnE":"≩","gneq":"⪈","gneqq":"≩","gnsim":"⋧","Gopf":"𝔾","gopf":"𝕘","grave":"`","GreaterEqual":"≥","GreaterEqualLess":"⋛","GreaterFullEqual":"≧","GreaterGreater":"⪢","GreaterLess":"≷","GreaterSlantEqual":"⩾","GreaterTilde":"≳","Gscr":"𝒢","gscr":"ℊ","gsim":"≳","gsime":"⪎","gsiml":"⪐","gtcc":"⪧","gtcir":"⩺","gt":">","GT":">","Gt":"≫","gtdot":"⋗","gtlPar":"⦕","gtquest":"⩼","gtrapprox":"⪆","gtrarr":"⥸","gtrdot":"⋗","gtreqless":"⋛","gtreqqless":"⪌","gtrless":"≷","gtrsim":"≳","gvertneqq":"≩︀","gvnE":"≩︀","Hacek":"ˇ","hairsp":" ","half":"½","hamilt":"ℋ","HARDcy":"Ъ","hardcy":"ъ","harrcir":"⥈","harr":"↔","hArr":"⇔","harrw":"↭","Hat":"^","hbar":"ℏ","Hcirc":"Ĥ","hcirc":"ĥ","hearts":"♥","heartsuit":"♥","hellip":"…","hercon":"⊹","hfr":"𝔥","Hfr":"ℌ","HilbertSpace":"ℋ","hksearow":"⤥","hkswarow":"⤦","hoarr":"⇿","homtht":"∻","hookleftarrow":"↩","hookrightarrow":"↪","hopf":"𝕙","Hopf":"ℍ","horbar":"―","HorizontalLine":"─","hscr":"𝒽","Hscr":"ℋ","hslash":"ℏ","Hstrok":"Ħ","hstrok":"ħ","HumpDownHump":"≎","HumpEqual":"≏","hybull":"⁃","hyphen":"‐","Iacute":"Í","iacute":"í","ic":"⁣","Icirc":"Î","icirc":"î","Icy":"И","icy":"и","Idot":"İ","IEcy":"Е","iecy":"е","iexcl":"¡","iff":"⇔","ifr":"𝔦","Ifr":"ℑ","Igrave":"Ì","igrave":"ì","ii":"ⅈ","iiiint":"⨌","iiint":"∭","iinfin":"⧜","iiota":"℩","IJlig":"IJ","ijlig":"ij","Imacr":"Ī","imacr":"ī","image":"ℑ","ImaginaryI":"ⅈ","imagline":"ℐ","imagpart":"ℑ","imath":"ı","Im":"ℑ","imof":"⊷","imped":"Ƶ","Implies":"⇒","incare":"℅","in":"∈","infin":"∞","infintie":"⧝","inodot":"ı","intcal":"⊺","int":"∫","Int":"∬","integers":"ℤ","Integral":"∫","intercal":"⊺","Intersection":"⋂","intlarhk":"⨗","intprod":"⨼","InvisibleComma":"⁣","InvisibleTimes":"⁢","IOcy":"Ё","iocy":"ё","Iogon":"Į","iogon":"į","Iopf":"𝕀","iopf":"𝕚","Iota":"Ι","iota":"ι","iprod":"⨼","iquest":"¿","iscr":"𝒾","Iscr":"ℐ","isin":"∈","isindot":"⋵","isinE":"⋹","isins":"⋴","isinsv":"⋳","isinv":"∈","it":"⁢","Itilde":"Ĩ","itilde":"ĩ","Iukcy":"І","iukcy":"і","Iuml":"Ï","iuml":"ï","Jcirc":"Ĵ","jcirc":"ĵ","Jcy":"Й","jcy":"й","Jfr":"𝔍","jfr":"𝔧","jmath":"ȷ","Jopf":"𝕁","jopf":"𝕛","Jscr":"𝒥","jscr":"𝒿","Jsercy":"Ј","jsercy":"ј","Jukcy":"Є","jukcy":"є","Kappa":"Κ","kappa":"κ","kappav":"ϰ","Kcedil":"Ķ","kcedil":"ķ","Kcy":"К","kcy":"к","Kfr":"𝔎","kfr":"𝔨","kgreen":"ĸ","KHcy":"Х","khcy":"х","KJcy":"Ќ","kjcy":"ќ","Kopf":"𝕂","kopf":"𝕜","Kscr":"𝒦","kscr":"𝓀","lAarr":"⇚","Lacute":"Ĺ","lacute":"ĺ","laemptyv":"⦴","lagran":"ℒ","Lambda":"Λ","lambda":"λ","lang":"⟨","Lang":"⟪","langd":"⦑","langle":"⟨","lap":"⪅","Laplacetrf":"ℒ","laquo":"«","larrb":"⇤","larrbfs":"⤟","larr":"←","Larr":"↞","lArr":"⇐","larrfs":"⤝","larrhk":"↩","larrlp":"↫","larrpl":"⤹","larrsim":"⥳","larrtl":"↢","latail":"⤙","lAtail":"⤛","lat":"⪫","late":"⪭","lates":"⪭︀","lbarr":"⤌","lBarr":"⤎","lbbrk":"❲","lbrace":"{","lbrack":"[","lbrke":"⦋","lbrksld":"⦏","lbrkslu":"⦍","Lcaron":"Ľ","lcaron":"ľ","Lcedil":"Ļ","lcedil":"ļ","lceil":"⌈","lcub":"{","Lcy":"Л","lcy":"л","ldca":"⤶","ldquo":"“","ldquor":"„","ldrdhar":"⥧","ldrushar":"⥋","ldsh":"↲","le":"≤","lE":"≦","LeftAngleBracket":"⟨","LeftArrowBar":"⇤","leftarrow":"←","LeftArrow":"←","Leftarrow":"⇐","LeftArrowRightArrow":"⇆","leftarrowtail":"↢","LeftCeiling":"⌈","LeftDoubleBracket":"⟦","LeftDownTeeVector":"⥡","LeftDownVectorBar":"⥙","LeftDownVector":"⇃","LeftFloor":"⌊","leftharpoondown":"↽","leftharpoonup":"↼","leftleftarrows":"⇇","leftrightarrow":"↔","LeftRightArrow":"↔","Leftrightarrow":"⇔","leftrightarrows":"⇆","leftrightharpoons":"⇋","leftrightsquigarrow":"↭","LeftRightVector":"⥎","LeftTeeArrow":"↤","LeftTee":"⊣","LeftTeeVector":"⥚","leftthreetimes":"⋋","LeftTriangleBar":"⧏","LeftTriangle":"⊲","LeftTriangleEqual":"⊴","LeftUpDownVector":"⥑","LeftUpTeeVector":"⥠","LeftUpVectorBar":"⥘","LeftUpVector":"↿","LeftVectorBar":"⥒","LeftVector":"↼","lEg":"⪋","leg":"⋚","leq":"≤","leqq":"≦","leqslant":"⩽","lescc":"⪨","les":"⩽","lesdot":"⩿","lesdoto":"⪁","lesdotor":"⪃","lesg":"⋚︀","lesges":"⪓","lessapprox":"⪅","lessdot":"⋖","lesseqgtr":"⋚","lesseqqgtr":"⪋","LessEqualGreater":"⋚","LessFullEqual":"≦","LessGreater":"≶","lessgtr":"≶","LessLess":"⪡","lesssim":"≲","LessSlantEqual":"⩽","LessTilde":"≲","lfisht":"⥼","lfloor":"⌊","Lfr":"𝔏","lfr":"𝔩","lg":"≶","lgE":"⪑","lHar":"⥢","lhard":"↽","lharu":"↼","lharul":"⥪","lhblk":"▄","LJcy":"Љ","ljcy":"љ","llarr":"⇇","ll":"≪","Ll":"⋘","llcorner":"⌞","Lleftarrow":"⇚","llhard":"⥫","lltri":"◺","Lmidot":"Ŀ","lmidot":"ŀ","lmoustache":"⎰","lmoust":"⎰","lnap":"⪉","lnapprox":"⪉","lne":"⪇","lnE":"≨","lneq":"⪇","lneqq":"≨","lnsim":"⋦","loang":"⟬","loarr":"⇽","lobrk":"⟦","longleftarrow":"⟵","LongLeftArrow":"⟵","Longleftarrow":"⟸","longleftrightarrow":"⟷","LongLeftRightArrow":"⟷","Longleftrightarrow":"⟺","longmapsto":"⟼","longrightarrow":"⟶","LongRightArrow":"⟶","Longrightarrow":"⟹","looparrowleft":"↫","looparrowright":"↬","lopar":"⦅","Lopf":"𝕃","lopf":"𝕝","loplus":"⨭","lotimes":"⨴","lowast":"∗","lowbar":"_","LowerLeftArrow":"↙","LowerRightArrow":"↘","loz":"◊","lozenge":"◊","lozf":"⧫","lpar":"(","lparlt":"⦓","lrarr":"⇆","lrcorner":"⌟","lrhar":"⇋","lrhard":"⥭","lrm":"‎","lrtri":"⊿","lsaquo":"‹","lscr":"𝓁","Lscr":"ℒ","lsh":"↰","Lsh":"↰","lsim":"≲","lsime":"⪍","lsimg":"⪏","lsqb":"[","lsquo":"‘","lsquor":"‚","Lstrok":"Ł","lstrok":"ł","ltcc":"⪦","ltcir":"⩹","lt":"<","LT":"<","Lt":"≪","ltdot":"⋖","lthree":"⋋","ltimes":"⋉","ltlarr":"⥶","ltquest":"⩻","ltri":"◃","ltrie":"⊴","ltrif":"◂","ltrPar":"⦖","lurdshar":"⥊","luruhar":"⥦","lvertneqq":"≨︀","lvnE":"≨︀","macr":"¯","male":"♂","malt":"✠","maltese":"✠","Map":"⤅","map":"↦","mapsto":"↦","mapstodown":"↧","mapstoleft":"↤","mapstoup":"↥","marker":"▮","mcomma":"⨩","Mcy":"М","mcy":"м","mdash":"—","mDDot":"∺","measuredangle":"∡","MediumSpace":" ","Mellintrf":"ℳ","Mfr":"𝔐","mfr":"𝔪","mho":"℧","micro":"µ","midast":"*","midcir":"⫰","mid":"∣","middot":"·","minusb":"⊟","minus":"−","minusd":"∸","minusdu":"⨪","MinusPlus":"∓","mlcp":"⫛","mldr":"…","mnplus":"∓","models":"⊧","Mopf":"𝕄","mopf":"𝕞","mp":"∓","mscr":"𝓂","Mscr":"ℳ","mstpos":"∾","Mu":"Μ","mu":"μ","multimap":"⊸","mumap":"⊸","nabla":"∇","Nacute":"Ń","nacute":"ń","nang":"∠⃒","nap":"≉","napE":"⩰̸","napid":"≋̸","napos":"ʼn","napprox":"≉","natural":"♮","naturals":"ℕ","natur":"♮","nbsp":" ","nbump":"≎̸","nbumpe":"≏̸","ncap":"⩃","Ncaron":"Ň","ncaron":"ň","Ncedil":"Ņ","ncedil":"ņ","ncong":"≇","ncongdot":"⩭̸","ncup":"⩂","Ncy":"Н","ncy":"н","ndash":"–","nearhk":"⤤","nearr":"↗","neArr":"⇗","nearrow":"↗","ne":"≠","nedot":"≐̸","NegativeMediumSpace":"​","NegativeThickSpace":"​","NegativeThinSpace":"​","NegativeVeryThinSpace":"​","nequiv":"≢","nesear":"⤨","nesim":"≂̸","NestedGreaterGreater":"≫","NestedLessLess":"≪","NewLine":"\\n","nexist":"∄","nexists":"∄","Nfr":"𝔑","nfr":"𝔫","ngE":"≧̸","nge":"≱","ngeq":"≱","ngeqq":"≧̸","ngeqslant":"⩾̸","nges":"⩾̸","nGg":"⋙̸","ngsim":"≵","nGt":"≫⃒","ngt":"≯","ngtr":"≯","nGtv":"≫̸","nharr":"↮","nhArr":"⇎","nhpar":"⫲","ni":"∋","nis":"⋼","nisd":"⋺","niv":"∋","NJcy":"Њ","njcy":"њ","nlarr":"↚","nlArr":"⇍","nldr":"‥","nlE":"≦̸","nle":"≰","nleftarrow":"↚","nLeftarrow":"⇍","nleftrightarrow":"↮","nLeftrightarrow":"⇎","nleq":"≰","nleqq":"≦̸","nleqslant":"⩽̸","nles":"⩽̸","nless":"≮","nLl":"⋘̸","nlsim":"≴","nLt":"≪⃒","nlt":"≮","nltri":"⋪","nltrie":"⋬","nLtv":"≪̸","nmid":"∤","NoBreak":"⁠","NonBreakingSpace":" ","nopf":"𝕟","Nopf":"ℕ","Not":"⫬","not":"¬","NotCongruent":"≢","NotCupCap":"≭","NotDoubleVerticalBar":"∦","NotElement":"∉","NotEqual":"≠","NotEqualTilde":"≂̸","NotExists":"∄","NotGreater":"≯","NotGreaterEqual":"≱","NotGreaterFullEqual":"≧̸","NotGreaterGreater":"≫̸","NotGreaterLess":"≹","NotGreaterSlantEqual":"⩾̸","NotGreaterTilde":"≵","NotHumpDownHump":"≎̸","NotHumpEqual":"≏̸","notin":"∉","notindot":"⋵̸","notinE":"⋹̸","notinva":"∉","notinvb":"⋷","notinvc":"⋶","NotLeftTriangleBar":"⧏̸","NotLeftTriangle":"⋪","NotLeftTriangleEqual":"⋬","NotLess":"≮","NotLessEqual":"≰","NotLessGreater":"≸","NotLessLess":"≪̸","NotLessSlantEqual":"⩽̸","NotLessTilde":"≴","NotNestedGreaterGreater":"⪢̸","NotNestedLessLess":"⪡̸","notni":"∌","notniva":"∌","notnivb":"⋾","notnivc":"⋽","NotPrecedes":"⊀","NotPrecedesEqual":"⪯̸","NotPrecedesSlantEqual":"⋠","NotReverseElement":"∌","NotRightTriangleBar":"⧐̸","NotRightTriangle":"⋫","NotRightTriangleEqual":"⋭","NotSquareSubset":"⊏̸","NotSquareSubsetEqual":"⋢","NotSquareSuperset":"⊐̸","NotSquareSupersetEqual":"⋣","NotSubset":"⊂⃒","NotSubsetEqual":"⊈","NotSucceeds":"⊁","NotSucceedsEqual":"⪰̸","NotSucceedsSlantEqual":"⋡","NotSucceedsTilde":"≿̸","NotSuperset":"⊃⃒","NotSupersetEqual":"⊉","NotTilde":"≁","NotTildeEqual":"≄","NotTildeFullEqual":"≇","NotTildeTilde":"≉","NotVerticalBar":"∤","nparallel":"∦","npar":"∦","nparsl":"⫽⃥","npart":"∂̸","npolint":"⨔","npr":"⊀","nprcue":"⋠","nprec":"⊀","npreceq":"⪯̸","npre":"⪯̸","nrarrc":"⤳̸","nrarr":"↛","nrArr":"⇏","nrarrw":"↝̸","nrightarrow":"↛","nRightarrow":"⇏","nrtri":"⋫","nrtrie":"⋭","nsc":"⊁","nsccue":"⋡","nsce":"⪰̸","Nscr":"𝒩","nscr":"𝓃","nshortmid":"∤","nshortparallel":"∦","nsim":"≁","nsime":"≄","nsimeq":"≄","nsmid":"∤","nspar":"∦","nsqsube":"⋢","nsqsupe":"⋣","nsub":"⊄","nsubE":"⫅̸","nsube":"⊈","nsubset":"⊂⃒","nsubseteq":"⊈","nsubseteqq":"⫅̸","nsucc":"⊁","nsucceq":"⪰̸","nsup":"⊅","nsupE":"⫆̸","nsupe":"⊉","nsupset":"⊃⃒","nsupseteq":"⊉","nsupseteqq":"⫆̸","ntgl":"≹","Ntilde":"Ñ","ntilde":"ñ","ntlg":"≸","ntriangleleft":"⋪","ntrianglelefteq":"⋬","ntriangleright":"⋫","ntrianglerighteq":"⋭","Nu":"Ν","nu":"ν","num":"#","numero":"№","numsp":" ","nvap":"≍⃒","nvdash":"⊬","nvDash":"⊭","nVdash":"⊮","nVDash":"⊯","nvge":"≥⃒","nvgt":">⃒","nvHarr":"⤄","nvinfin":"⧞","nvlArr":"⤂","nvle":"≤⃒","nvlt":"<⃒","nvltrie":"⊴⃒","nvrArr":"⤃","nvrtrie":"⊵⃒","nvsim":"∼⃒","nwarhk":"⤣","nwarr":"↖","nwArr":"⇖","nwarrow":"↖","nwnear":"⤧","Oacute":"Ó","oacute":"ó","oast":"⊛","Ocirc":"Ô","ocirc":"ô","ocir":"⊚","Ocy":"О","ocy":"о","odash":"⊝","Odblac":"Ő","odblac":"ő","odiv":"⨸","odot":"⊙","odsold":"⦼","OElig":"Œ","oelig":"œ","ofcir":"⦿","Ofr":"𝔒","ofr":"𝔬","ogon":"˛","Ograve":"Ò","ograve":"ò","ogt":"⧁","ohbar":"⦵","ohm":"Ω","oint":"∮","olarr":"↺","olcir":"⦾","olcross":"⦻","oline":"‾","olt":"⧀","Omacr":"Ō","omacr":"ō","Omega":"Ω","omega":"ω","Omicron":"Ο","omicron":"ο","omid":"⦶","ominus":"⊖","Oopf":"𝕆","oopf":"𝕠","opar":"⦷","OpenCurlyDoubleQuote":"“","OpenCurlyQuote":"‘","operp":"⦹","oplus":"⊕","orarr":"↻","Or":"⩔","or":"∨","ord":"⩝","order":"ℴ","orderof":"ℴ","ordf":"ª","ordm":"º","origof":"⊶","oror":"⩖","orslope":"⩗","orv":"⩛","oS":"Ⓢ","Oscr":"𝒪","oscr":"ℴ","Oslash":"Ø","oslash":"ø","osol":"⊘","Otilde":"Õ","otilde":"õ","otimesas":"⨶","Otimes":"⨷","otimes":"⊗","Ouml":"Ö","ouml":"ö","ovbar":"⌽","OverBar":"‾","OverBrace":"⏞","OverBracket":"⎴","OverParenthesis":"⏜","para":"¶","parallel":"∥","par":"∥","parsim":"⫳","parsl":"⫽","part":"∂","PartialD":"∂","Pcy":"П","pcy":"п","percnt":"%","period":".","permil":"‰","perp":"⊥","pertenk":"‱","Pfr":"𝔓","pfr":"𝔭","Phi":"Φ","phi":"φ","phiv":"ϕ","phmmat":"ℳ","phone":"☎","Pi":"Π","pi":"π","pitchfork":"⋔","piv":"ϖ","planck":"ℏ","planckh":"ℎ","plankv":"ℏ","plusacir":"⨣","plusb":"⊞","pluscir":"⨢","plus":"+","plusdo":"∔","plusdu":"⨥","pluse":"⩲","PlusMinus":"±","plusmn":"±","plussim":"⨦","plustwo":"⨧","pm":"±","Poincareplane":"ℌ","pointint":"⨕","popf":"𝕡","Popf":"ℙ","pound":"£","prap":"⪷","Pr":"⪻","pr":"≺","prcue":"≼","precapprox":"⪷","prec":"≺","preccurlyeq":"≼","Precedes":"≺","PrecedesEqual":"⪯","PrecedesSlantEqual":"≼","PrecedesTilde":"≾","preceq":"⪯","precnapprox":"⪹","precneqq":"⪵","precnsim":"⋨","pre":"⪯","prE":"⪳","precsim":"≾","prime":"′","Prime":"″","primes":"ℙ","prnap":"⪹","prnE":"⪵","prnsim":"⋨","prod":"∏","Product":"∏","profalar":"⌮","profline":"⌒","profsurf":"⌓","prop":"∝","Proportional":"∝","Proportion":"∷","propto":"∝","prsim":"≾","prurel":"⊰","Pscr":"𝒫","pscr":"𝓅","Psi":"Ψ","psi":"ψ","puncsp":" ","Qfr":"𝔔","qfr":"𝔮","qint":"⨌","qopf":"𝕢","Qopf":"ℚ","qprime":"⁗","Qscr":"𝒬","qscr":"𝓆","quaternions":"ℍ","quatint":"⨖","quest":"?","questeq":"≟","quot":"\\"","QUOT":"\\"","rAarr":"⇛","race":"∽̱","Racute":"Ŕ","racute":"ŕ","radic":"√","raemptyv":"⦳","rang":"⟩","Rang":"⟫","rangd":"⦒","range":"⦥","rangle":"⟩","raquo":"»","rarrap":"⥵","rarrb":"⇥","rarrbfs":"⤠","rarrc":"⤳","rarr":"→","Rarr":"↠","rArr":"⇒","rarrfs":"⤞","rarrhk":"↪","rarrlp":"↬","rarrpl":"⥅","rarrsim":"⥴","Rarrtl":"⤖","rarrtl":"↣","rarrw":"↝","ratail":"⤚","rAtail":"⤜","ratio":"∶","rationals":"ℚ","rbarr":"⤍","rBarr":"⤏","RBarr":"⤐","rbbrk":"❳","rbrace":"}","rbrack":"]","rbrke":"⦌","rbrksld":"⦎","rbrkslu":"⦐","Rcaron":"Ř","rcaron":"ř","Rcedil":"Ŗ","rcedil":"ŗ","rceil":"⌉","rcub":"}","Rcy":"Р","rcy":"р","rdca":"⤷","rdldhar":"⥩","rdquo":"”","rdquor":"”","rdsh":"↳","real":"ℜ","realine":"ℛ","realpart":"ℜ","reals":"ℝ","Re":"ℜ","rect":"▭","reg":"®","REG":"®","ReverseElement":"∋","ReverseEquilibrium":"⇋","ReverseUpEquilibrium":"⥯","rfisht":"⥽","rfloor":"⌋","rfr":"𝔯","Rfr":"ℜ","rHar":"⥤","rhard":"⇁","rharu":"⇀","rharul":"⥬","Rho":"Ρ","rho":"ρ","rhov":"ϱ","RightAngleBracket":"⟩","RightArrowBar":"⇥","rightarrow":"→","RightArrow":"→","Rightarrow":"⇒","RightArrowLeftArrow":"⇄","rightarrowtail":"↣","RightCeiling":"⌉","RightDoubleBracket":"⟧","RightDownTeeVector":"⥝","RightDownVectorBar":"⥕","RightDownVector":"⇂","RightFloor":"⌋","rightharpoondown":"⇁","rightharpoonup":"⇀","rightleftarrows":"⇄","rightleftharpoons":"⇌","rightrightarrows":"⇉","rightsquigarrow":"↝","RightTeeArrow":"↦","RightTee":"⊢","RightTeeVector":"⥛","rightthreetimes":"⋌","RightTriangleBar":"⧐","RightTriangle":"⊳","RightTriangleEqual":"⊵","RightUpDownVector":"⥏","RightUpTeeVector":"⥜","RightUpVectorBar":"⥔","RightUpVector":"↾","RightVectorBar":"⥓","RightVector":"⇀","ring":"˚","risingdotseq":"≓","rlarr":"⇄","rlhar":"⇌","rlm":"‏","rmoustache":"⎱","rmoust":"⎱","rnmid":"⫮","roang":"⟭","roarr":"⇾","robrk":"⟧","ropar":"⦆","ropf":"𝕣","Ropf":"ℝ","roplus":"⨮","rotimes":"⨵","RoundImplies":"⥰","rpar":")","rpargt":"⦔","rppolint":"⨒","rrarr":"⇉","Rrightarrow":"⇛","rsaquo":"›","rscr":"𝓇","Rscr":"ℛ","rsh":"↱","Rsh":"↱","rsqb":"]","rsquo":"’","rsquor":"’","rthree":"⋌","rtimes":"⋊","rtri":"▹","rtrie":"⊵","rtrif":"▸","rtriltri":"⧎","RuleDelayed":"⧴","ruluhar":"⥨","rx":"℞","Sacute":"Ś","sacute":"ś","sbquo":"‚","scap":"⪸","Scaron":"Š","scaron":"š","Sc":"⪼","sc":"≻","sccue":"≽","sce":"⪰","scE":"⪴","Scedil":"Ş","scedil":"ş","Scirc":"Ŝ","scirc":"ŝ","scnap":"⪺","scnE":"⪶","scnsim":"⋩","scpolint":"⨓","scsim":"≿","Scy":"С","scy":"с","sdotb":"⊡","sdot":"⋅","sdote":"⩦","searhk":"⤥","searr":"↘","seArr":"⇘","searrow":"↘","sect":"§","semi":";","seswar":"⤩","setminus":"∖","setmn":"∖","sext":"✶","Sfr":"𝔖","sfr":"𝔰","sfrown":"⌢","sharp":"♯","SHCHcy":"Щ","shchcy":"щ","SHcy":"Ш","shcy":"ш","ShortDownArrow":"↓","ShortLeftArrow":"←","shortmid":"∣","shortparallel":"∥","ShortRightArrow":"→","ShortUpArrow":"↑","shy":"­","Sigma":"Σ","sigma":"σ","sigmaf":"ς","sigmav":"ς","sim":"∼","simdot":"⩪","sime":"≃","simeq":"≃","simg":"⪞","simgE":"⪠","siml":"⪝","simlE":"⪟","simne":"≆","simplus":"⨤","simrarr":"⥲","slarr":"←","SmallCircle":"∘","smallsetminus":"∖","smashp":"⨳","smeparsl":"⧤","smid":"∣","smile":"⌣","smt":"⪪","smte":"⪬","smtes":"⪬︀","SOFTcy":"Ь","softcy":"ь","solbar":"⌿","solb":"⧄","sol":"/","Sopf":"𝕊","sopf":"𝕤","spades":"♠","spadesuit":"♠","spar":"∥","sqcap":"⊓","sqcaps":"⊓︀","sqcup":"⊔","sqcups":"⊔︀","Sqrt":"√","sqsub":"⊏","sqsube":"⊑","sqsubset":"⊏","sqsubseteq":"⊑","sqsup":"⊐","sqsupe":"⊒","sqsupset":"⊐","sqsupseteq":"⊒","square":"□","Square":"□","SquareIntersection":"⊓","SquareSubset":"⊏","SquareSubsetEqual":"⊑","SquareSuperset":"⊐","SquareSupersetEqual":"⊒","SquareUnion":"⊔","squarf":"▪","squ":"□","squf":"▪","srarr":"→","Sscr":"𝒮","sscr":"𝓈","ssetmn":"∖","ssmile":"⌣","sstarf":"⋆","Star":"⋆","star":"☆","starf":"★","straightepsilon":"ϵ","straightphi":"ϕ","strns":"¯","sub":"⊂","Sub":"⋐","subdot":"⪽","subE":"⫅","sube":"⊆","subedot":"⫃","submult":"⫁","subnE":"⫋","subne":"⊊","subplus":"⪿","subrarr":"⥹","subset":"⊂","Subset":"⋐","subseteq":"⊆","subseteqq":"⫅","SubsetEqual":"⊆","subsetneq":"⊊","subsetneqq":"⫋","subsim":"⫇","subsub":"⫕","subsup":"⫓","succapprox":"⪸","succ":"≻","succcurlyeq":"≽","Succeeds":"≻","SucceedsEqual":"⪰","SucceedsSlantEqual":"≽","SucceedsTilde":"≿","succeq":"⪰","succnapprox":"⪺","succneqq":"⪶","succnsim":"⋩","succsim":"≿","SuchThat":"∋","sum":"∑","Sum":"∑","sung":"♪","sup1":"¹","sup2":"²","sup3":"³","sup":"⊃","Sup":"⋑","supdot":"⪾","supdsub":"⫘","supE":"⫆","supe":"⊇","supedot":"⫄","Superset":"⊃","SupersetEqual":"⊇","suphsol":"⟉","suphsub":"⫗","suplarr":"⥻","supmult":"⫂","supnE":"⫌","supne":"⊋","supplus":"⫀","supset":"⊃","Supset":"⋑","supseteq":"⊇","supseteqq":"⫆","supsetneq":"⊋","supsetneqq":"⫌","supsim":"⫈","supsub":"⫔","supsup":"⫖","swarhk":"⤦","swarr":"↙","swArr":"⇙","swarrow":"↙","swnwar":"⤪","szlig":"ß","Tab":"\\t","target":"⌖","Tau":"Τ","tau":"τ","tbrk":"⎴","Tcaron":"Ť","tcaron":"ť","Tcedil":"Ţ","tcedil":"ţ","Tcy":"Т","tcy":"т","tdot":"⃛","telrec":"⌕","Tfr":"𝔗","tfr":"𝔱","there4":"∴","therefore":"∴","Therefore":"∴","Theta":"Θ","theta":"θ","thetasym":"ϑ","thetav":"ϑ","thickapprox":"≈","thicksim":"∼","ThickSpace":"  ","ThinSpace":" ","thinsp":" ","thkap":"≈","thksim":"∼","THORN":"Þ","thorn":"þ","tilde":"˜","Tilde":"∼","TildeEqual":"≃","TildeFullEqual":"≅","TildeTilde":"≈","timesbar":"⨱","timesb":"⊠","times":"×","timesd":"⨰","tint":"∭","toea":"⤨","topbot":"⌶","topcir":"⫱","top":"⊤","Topf":"𝕋","topf":"𝕥","topfork":"⫚","tosa":"⤩","tprime":"‴","trade":"™","TRADE":"™","triangle":"▵","triangledown":"▿","triangleleft":"◃","trianglelefteq":"⊴","triangleq":"≜","triangleright":"▹","trianglerighteq":"⊵","tridot":"◬","trie":"≜","triminus":"⨺","TripleDot":"⃛","triplus":"⨹","trisb":"⧍","tritime":"⨻","trpezium":"⏢","Tscr":"𝒯","tscr":"𝓉","TScy":"Ц","tscy":"ц","TSHcy":"Ћ","tshcy":"ћ","Tstrok":"Ŧ","tstrok":"ŧ","twixt":"≬","twoheadleftarrow":"↞","twoheadrightarrow":"↠","Uacute":"Ú","uacute":"ú","uarr":"↑","Uarr":"↟","uArr":"⇑","Uarrocir":"⥉","Ubrcy":"Ў","ubrcy":"ў","Ubreve":"Ŭ","ubreve":"ŭ","Ucirc":"Û","ucirc":"û","Ucy":"У","ucy":"у","udarr":"⇅","Udblac":"Ű","udblac":"ű","udhar":"⥮","ufisht":"⥾","Ufr":"𝔘","ufr":"𝔲","Ugrave":"Ù","ugrave":"ù","uHar":"⥣","uharl":"↿","uharr":"↾","uhblk":"▀","ulcorn":"⌜","ulcorner":"⌜","ulcrop":"⌏","ultri":"◸","Umacr":"Ū","umacr":"ū","uml":"¨","UnderBar":"_","UnderBrace":"⏟","UnderBracket":"⎵","UnderParenthesis":"⏝","Union":"⋃","UnionPlus":"⊎","Uogon":"Ų","uogon":"ų","Uopf":"𝕌","uopf":"𝕦","UpArrowBar":"⤒","uparrow":"↑","UpArrow":"↑","Uparrow":"⇑","UpArrowDownArrow":"⇅","updownarrow":"↕","UpDownArrow":"↕","Updownarrow":"⇕","UpEquilibrium":"⥮","upharpoonleft":"↿","upharpoonright":"↾","uplus":"⊎","UpperLeftArrow":"↖","UpperRightArrow":"↗","upsi":"υ","Upsi":"ϒ","upsih":"ϒ","Upsilon":"Υ","upsilon":"υ","UpTeeArrow":"↥","UpTee":"⊥","upuparrows":"⇈","urcorn":"⌝","urcorner":"⌝","urcrop":"⌎","Uring":"Ů","uring":"ů","urtri":"◹","Uscr":"𝒰","uscr":"𝓊","utdot":"⋰","Utilde":"Ũ","utilde":"ũ","utri":"▵","utrif":"▴","uuarr":"⇈","Uuml":"Ü","uuml":"ü","uwangle":"⦧","vangrt":"⦜","varepsilon":"ϵ","varkappa":"ϰ","varnothing":"∅","varphi":"ϕ","varpi":"ϖ","varpropto":"∝","varr":"↕","vArr":"⇕","varrho":"ϱ","varsigma":"ς","varsubsetneq":"⊊︀","varsubsetneqq":"⫋︀","varsupsetneq":"⊋︀","varsupsetneqq":"⫌︀","vartheta":"ϑ","vartriangleleft":"⊲","vartriangleright":"⊳","vBar":"⫨","Vbar":"⫫","vBarv":"⫩","Vcy":"В","vcy":"в","vdash":"⊢","vDash":"⊨","Vdash":"⊩","VDash":"⊫","Vdashl":"⫦","veebar":"⊻","vee":"∨","Vee":"⋁","veeeq":"≚","vellip":"⋮","verbar":"|","Verbar":"‖","vert":"|","Vert":"‖","VerticalBar":"∣","VerticalLine":"|","VerticalSeparator":"❘","VerticalTilde":"≀","VeryThinSpace":" ","Vfr":"𝔙","vfr":"𝔳","vltri":"⊲","vnsub":"⊂⃒","vnsup":"⊃⃒","Vopf":"𝕍","vopf":"𝕧","vprop":"∝","vrtri":"⊳","Vscr":"𝒱","vscr":"𝓋","vsubnE":"⫋︀","vsubne":"⊊︀","vsupnE":"⫌︀","vsupne":"⊋︀","Vvdash":"⊪","vzigzag":"⦚","Wcirc":"Ŵ","wcirc":"ŵ","wedbar":"⩟","wedge":"∧","Wedge":"⋀","wedgeq":"≙","weierp":"℘","Wfr":"𝔚","wfr":"𝔴","Wopf":"𝕎","wopf":"𝕨","wp":"℘","wr":"≀","wreath":"≀","Wscr":"𝒲","wscr":"𝓌","xcap":"⋂","xcirc":"◯","xcup":"⋃","xdtri":"▽","Xfr":"𝔛","xfr":"𝔵","xharr":"⟷","xhArr":"⟺","Xi":"Ξ","xi":"ξ","xlarr":"⟵","xlArr":"⟸","xmap":"⟼","xnis":"⋻","xodot":"⨀","Xopf":"𝕏","xopf":"𝕩","xoplus":"⨁","xotime":"⨂","xrarr":"⟶","xrArr":"⟹","Xscr":"𝒳","xscr":"𝓍","xsqcup":"⨆","xuplus":"⨄","xutri":"△","xvee":"⋁","xwedge":"⋀","Yacute":"Ý","yacute":"ý","YAcy":"Я","yacy":"я","Ycirc":"Ŷ","ycirc":"ŷ","Ycy":"Ы","ycy":"ы","yen":"¥","Yfr":"𝔜","yfr":"𝔶","YIcy":"Ї","yicy":"ї","Yopf":"𝕐","yopf":"𝕪","Yscr":"𝒴","yscr":"𝓎","YUcy":"Ю","yucy":"ю","yuml":"ÿ","Yuml":"Ÿ","Zacute":"Ź","zacute":"ź","Zcaron":"Ž","zcaron":"ž","Zcy":"З","zcy":"з","Zdot":"Ż","zdot":"ż","zeetrf":"ℨ","ZeroWidthSpace":"​","Zeta":"Ζ","zeta":"ζ","zfr":"𝔷","Zfr":"ℨ","ZHcy":"Ж","zhcy":"ж","zigrarr":"⇝","zopf":"𝕫","Zopf":"ℤ","Zscr":"𝒵","zscr":"𝓏","zwj":"‍","zwnj":"‌"}')},function(t,e,r){"use strict";var n={};function o(t,e,r){var i,s,a,c,l,u="";for("string"!=typeof e&&(r=e,e=o.defaultChars),void 0===r&&(r=!0),l=function(t){var e,r,o=n[t];if(o)return o;for(o=n[t]=[],e=0;e<128;e++)r=String.fromCharCode(e),/^[0-9a-z]$/i.test(r)?o.push(r):o.push("%"+("0"+e.toString(16).toUpperCase()).slice(-2));for(e=0;e=55296&&a<=57343){if(a>=55296&&a<=56319&&i+1=56320&&c<=57343){u+=encodeURIComponent(t[i]+t[i+1]),i++;continue}u+="%EF%BF%BD"}else u+=encodeURIComponent(t[i]);return u}o.defaultChars=";/?:@&=+$,-_.!~*'()#",o.componentChars="-_.!~*'()",t.exports=o},function(t,e,r){"use strict";var n={};function o(t,e){var r;return"string"!=typeof e&&(e=o.defaultChars),r=function(t){var e,r,o=n[t];if(o)return o;for(o=n[t]=[],e=0;e<128;e++)r=String.fromCharCode(e),o.push(r);for(e=0;e=55296&&c<=57343?"���":String.fromCharCode(c),e+=6):240==(248&o)&&e+91114111?l+="����":(c-=65536,l+=String.fromCharCode(55296+(c>>10),56320+(1023&c))),e+=9):l+="�";return l}))}o.defaultChars=";/?:@&=+$,#",o.componentChars="",t.exports=o},function(t,e,r){"use strict";t.exports=function(t){var e="";return e+=t.protocol||"",e+=t.slashes?"//":"",e+=t.auth?t.auth+"@":"",t.hostname&&-1!==t.hostname.indexOf(":")?e+="["+t.hostname+"]":e+=t.hostname||"",e+=t.port?":"+t.port:"",e+=t.pathname||"",e+=t.search||"",e+=t.hash||""}},function(t,e,r){"use strict";function n(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var o=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,s=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,a=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(a),l=["%","/","?",";","#"].concat(c),u=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,h=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,f={javascript:!0,"javascript:":!0},d={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};n.prototype.parse=function(t,e){var r,n,i,a,c,m=t;if(m=m.trim(),!e&&1===t.split("#").length){var g=s.exec(m);if(g)return this.pathname=g[1],g[2]&&(this.search=g[2]),this}var v=o.exec(m);if(v&&(i=(v=v[0]).toLowerCase(),this.protocol=v,m=m.substr(v.length)),(e||v||m.match(/^\/\/[^@\/]+@[^@\/]+/))&&(!(c="//"===m.substr(0,2))||v&&f[v]||(m=m.substr(2),this.slashes=!0)),!f[v]&&(c||v&&!d[v])){var y,b,k=-1;for(r=0;r127?S+="x":S+=C[A];if(!S.match(p)){var M=x.slice(0,r),D=x.slice(r+1),T=C.match(h);T&&(M.push(T[1]),D.unshift(T[2])),D.length&&(m=D.join(".")+m),this.hostname=M.join(".");break}}}}this.hostname.length>255&&(this.hostname=""),w&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}var O=m.indexOf("#");-1!==O&&(this.hash=m.substr(O),m=m.slice(0,O));var q=m.indexOf("?");return-1!==q&&(this.search=m.substr(q),m=m.slice(0,q)),m&&(this.pathname=m),d[i]&&this.hostname&&!this.pathname&&(this.pathname=""),this},n.prototype.parseHost=function(t){var e=i.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)},t.exports=function(t,e){if(t&&t instanceof n)return t;var r=new n;return r.parse(t,e),r}},function(t,e){t.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/},function(t,e,r){"use strict";e.parseLinkLabel=r(32),e.parseLinkDestination=r(33),e.parseLinkTitle=r(34)},function(t,e,r){"use strict";t.exports=function(t,e,r){var n,o,i,s,a=-1,c=t.posMax,l=t.pos;for(t.pos=e+1,n=1;t.pos=r)return c;if(34!==(i=t.charCodeAt(e))&&39!==i&&40!==i)return c;for(e++,40===i&&(i=41);e"+i(t[e].content)+""},s.code_block=function(t,e,r,n,o){var s=t[e];return""+i(t[e].content)+"\n"},s.fence=function(t,e,r,n,s){var a,c,l,u,p=t[e],h=p.info?o(p.info).trim():"",f="";return h&&(f=h.split(/\s+/g)[0]),0===(a=r.highlight&&r.highlight(p.content,f)||i(p.content)).indexOf(""+a+"\n"):"
"+a+"
\n"},s.image=function(t,e,r,n,o){var i=t[e];return i.attrs[i.attrIndex("alt")][1]=o.renderInlineAsText(i.children,r,n),o.renderToken(t,e,r)},s.hardbreak=function(t,e,r){return r.xhtmlOut?"
\n":"
\n"},s.softbreak=function(t,e,r){return r.breaks?r.xhtmlOut?"
\n":"
\n":"\n"},s.text=function(t,e){return i(t[e].content)},s.html_block=function(t,e){return t[e].content},s.html_inline=function(t,e){return t[e].content},a.prototype.renderAttrs=function(t){var e,r,n;if(!t.attrs)return"";for(n="",e=0,r=t.attrs.length;e\n":">")},a.prototype.renderInline=function(t,e,r){for(var n,o="",i=this.rules,s=0,a=t.length;s/i.test(t)}t.exports=function(t){var e,r,i,s,a,c,l,u,p,h,f,d,m,g,v,y,b,k,_=t.tokens;if(t.md.options.linkify)for(r=0,i=_.length;r=0;e--)if("link_close"!==(c=s[e]).type){if("html_inline"===c.type&&(k=c.content,/^\s]/i.test(k)&&m>0&&m--,o(c.content)&&m++),!(m>0)&&"text"===c.type&&t.md.linkify.test(c.content)){for(p=c.content,b=t.md.linkify.match(p),l=[],d=c.level,f=0,u=0;uf&&((a=new t.Token("text","",0)).content=p.slice(f,h),a.level=d,l.push(a)),(a=new t.Token("link_open","a",1)).attrs=[["href",v]],a.level=d++,a.markup="linkify",a.info="auto",l.push(a),(a=new t.Token("text","",0)).content=y,a.level=d,l.push(a),(a=new t.Token("link_close","a",-1)).level=--d,a.markup="linkify",a.info="auto",l.push(a),f=b[u].lastIndex);f=0;e--)"text"!==(r=t[e]).type||n||(r.content=r.content.replace(i,a)),"link_open"===r.type&&"auto"===r.info&&n--,"link_close"===r.type&&"auto"===r.info&&n++}function l(t){var e,r,o=0;for(e=t.length-1;e>=0;e--)"text"!==(r=t[e]).type||o||n.test(r.content)&&(r.content=r.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---([^-]|$)/gm,"$1—$2").replace(/(^|\s)--(\s|$)/gm,"$1–$2").replace(/(^|[^-\s])--([^-\s]|$)/gm,"$1–$2")),"link_open"===r.type&&"auto"===r.info&&o--,"link_close"===r.type&&"auto"===r.info&&o++}t.exports=function(t){var e;if(t.md.options.typographer)for(e=t.tokens.length-1;e>=0;e--)"inline"===t.tokens[e].type&&(o.test(t.tokens[e].content)&&c(t.tokens[e].children),n.test(t.tokens[e].content)&&l(t.tokens[e].children))}},function(t,e,r){"use strict";var n=r(0).isWhiteSpace,o=r(0).isPunctChar,i=r(0).isMdAsciiPunct,s=/['"]/,a=/['"]/g;function c(t,e,r){return t.substr(0,e)+r+t.substr(e+1)}function l(t,e){var r,s,l,u,p,h,f,d,m,g,v,y,b,k,_,w,x,C,S,A,E;for(S=[],r=0;r=0&&!(S[x].level<=f);x--);if(S.length=x+1,"text"===s.type){p=0,h=(l=s.content).length;t:for(;p=0)m=l.charCodeAt(u.index-1);else for(x=r-1;x>=0&&("softbreak"!==t[x].type&&"hardbreak"!==t[x].type);x--)if("text"===t[x].type){m=t[x].content.charCodeAt(t[x].content.length-1);break}if(g=32,p=48&&m<=57&&(w=_=!1),_&&w&&(_=!1,w=y),_||w){if(w)for(x=S.length-1;x>=0&&(d=S[x],!(S[x].level=0;e--)"inline"===t.tokens[e].type&&s.test(t.tokens[e].content)&&l(t.tokens[e].children,t)}},function(t,e,r){"use strict";var n=r(8);function o(t,e,r){this.src=t,this.env=r,this.tokens=[],this.inlineMode=!1,this.md=e}o.prototype.Token=n,t.exports=o},function(t,e,r){"use strict";var n=r(7),o=[["table",r(45),["paragraph","reference"]],["code",r(46)],["fence",r(47),["paragraph","reference","blockquote","list"]],["blockquote",r(48),["paragraph","reference","blockquote","list"]],["hr",r(49),["paragraph","reference","blockquote","list"]],["list",r(50),["paragraph","reference","blockquote"]],["reference",r(51)],["heading",r(52),["paragraph","reference","blockquote"]],["lheading",r(53)],["html_block",r(54),["paragraph","reference","blockquote"]],["paragraph",r(56)]];function i(){this.ruler=new n;for(var t=0;t=r))&&!(t.sCount[s]=c){t.line=r;break}for(n=0;nr)return!1;if(p=e+1,t.sCount[p]=4)return!1;if((l=t.bMarks[p]+t.tShift[p])>=t.eMarks[p])return!1;if(124!==(a=t.src.charCodeAt(l++))&&45!==a&&58!==a)return!1;for(;l=4)return!1;if((f=(h=i(c.replace(/^\||\|$/g,""))).length)>m.length)return!1;if(s)return!0;for((d=t.push("table_open","table",1)).map=v=[e,0],(d=t.push("thead_open","thead",1)).map=[e,e+1],(d=t.push("tr_open","tr",1)).map=[e,e+1],u=0;u=4);p++){for(h=i(c.replace(/^\||\|$/g,"")),d=t.push("tr_open","tr",1),u=0;u=4))break;o=++n}return t.line=o,(i=t.push("code_block","code",0)).content=t.getLines(e,o,4+t.blkIndent,!0),i.map=[e,t.line],!0}},function(t,e,r){"use strict";t.exports=function(t,e,r,n){var o,i,s,a,c,l,u,p=!1,h=t.bMarks[e]+t.tShift[e],f=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(h+3>f)return!1;if(126!==(o=t.src.charCodeAt(h))&&96!==o)return!1;if(c=h,(i=(h=t.skipChars(h,o))-c)<3)return!1;if(u=t.src.slice(c,h),s=t.src.slice(h,f),96===o&&s.indexOf(String.fromCharCode(o))>=0)return!1;if(n)return!0;for(a=e;!(++a>=r)&&!((h=c=t.bMarks[a]+t.tShift[a])<(f=t.eMarks[a])&&t.sCount[a]=4||(h=t.skipChars(h,o))-c=4)return!1;if(62!==t.src.charCodeAt(A++))return!1;if(o)return!0;for(c=f=t.sCount[e]+A-(t.bMarks[e]+t.tShift[e]),32===t.src.charCodeAt(A)?(A++,c++,f++,i=!1,k=!0):9===t.src.charCodeAt(A)?(k=!0,(t.bsCount[e]+f)%4==3?(A++,c++,f++,i=!1):i=!0):k=!1,d=[t.bMarks[e]],t.bMarks[e]=A;A=E,y=[t.sCount[e]],t.sCount[e]=f-c,b=[t.tShift[e]],t.tShift[e]=A-t.bMarks[e],w=t.md.block.ruler.getRules("blockquote"),v=t.parentType,t.parentType="blockquote",C=!1,h=e+1;h=(E=t.eMarks[h])));h++)if(62!==t.src.charCodeAt(A++)||C){if(u)break;for(_=!1,a=0,l=w.length;a=E,m.push(t.bsCount[h]),t.bsCount[h]=t.sCount[h]+1+(k?1:0),y.push(t.sCount[h]),t.sCount[h]=f-c,b.push(t.tShift[h]),t.tShift[h]=A-t.bMarks[h]}for(g=t.blkIndent,t.blkIndent=0,(x=t.push("blockquote_open","blockquote",1)).markup=">",x.map=p=[e,0],t.md.block.tokenize(t,e,h),(x=t.push("blockquote_close","blockquote",-1)).markup=">",t.lineMax=S,t.parentType=v,p[1]=t.line,a=0;a=4)return!1;if(42!==(i=t.src.charCodeAt(l++))&&45!==i&&95!==i)return!1;for(s=1;l=s)return-1;if((r=t.src.charCodeAt(i++))<48||r>57)return-1;for(;;){if(i>=s)return-1;if(!((r=t.src.charCodeAt(i++))>=48&&r<=57)){if(41===r||46===r)break;return-1}if(i-o>=10)return-1}return i=4)return!1;if(t.listIndent>=0&&t.sCount[e]-t.listIndent>=4&&t.sCount[e]=t.blkIndent&&(N=!0),(M=i(t,e))>=0){if(h=!0,T=t.bMarks[e]+t.tShift[e],y=Number(t.src.substr(T,M-T-1)),N&&1!==y)return!1}else{if(!((M=o(t,e))>=0))return!1;h=!1}if(N&&t.skipSpaces(M)>=t.eMarks[e])return!1;if(v=t.src.charCodeAt(M-1),n)return!0;for(g=t.tokens.length,h?(z=t.push("ordered_list_open","ol",1),1!==y&&(z.attrs=[["start",y]])):z=t.push("bullet_list_open","ul",1),z.map=m=[e,0],z.markup=String.fromCharCode(v),k=e,D=!1,q=t.md.block.ruler.getRules("list"),x=t.parentType,t.parentType="list";k=b?1:_-p)>4&&(u=1),l=p+u,(z=t.push("list_item_open","li",1)).markup=String.fromCharCode(v),z.map=f=[e,0],A=t.tight,S=t.tShift[e],C=t.sCount[e],w=t.listIndent,t.listIndent=t.blkIndent,t.blkIndent=l,t.tight=!0,t.tShift[e]=a-t.bMarks[e],t.sCount[e]=_,a>=b&&t.isEmpty(e+1)?t.line=Math.min(t.line+2,r):t.md.block.tokenize(t,e,r,!0),t.tight&&!D||(I=!1),D=t.line-e>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=w,t.tShift[e]=S,t.sCount[e]=C,t.tight=A,(z=t.push("list_item_close","li",-1)).markup=String.fromCharCode(v),k=e=t.line,f[1]=k,a=t.bMarks[e],k>=r)break;if(t.sCount[k]=4)break;for(O=!1,c=0,d=q.length;c=4)return!1;if(91!==t.src.charCodeAt(x))return!1;for(;++x3||t.sCount[S]<0)){for(b=!1,p=0,h=k.length;p=4)return!1;if(35!==(i=t.src.charCodeAt(l))||l>=u)return!1;for(s=1,i=t.src.charCodeAt(++l);35===i&&l6||ll&&n(t.src.charCodeAt(a-1))&&(u=a),t.line=e+1,(c=t.push("heading_open","h"+String(s),1)).markup="########".slice(0,s),c.map=[e,t.line],(c=t.push("inline","",0)).content=t.src.slice(l,u).trim(),c.map=[e,t.line],c.children=[],(c=t.push("heading_close","h"+String(s),-1)).markup="########".slice(0,s)),!0)}},function(t,e,r){"use strict";t.exports=function(t,e,r){var n,o,i,s,a,c,l,u,p,h,f=e+1,d=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;for(h=t.parentType,t.parentType="paragraph";f3)){if(t.sCount[f]>=t.blkIndent&&(c=t.bMarks[f]+t.tShift[f])<(l=t.eMarks[f])&&(45===(p=t.src.charCodeAt(c))||61===p)&&(c=t.skipChars(c,p),(c=t.skipSpaces(c))>=l)){u=61===p?1:2;break}if(!(t.sCount[f]<0)){for(o=!1,i=0,s=d.length;i|$))/i,/<\/(script|pre|style)>/i,!0],[/^/,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp("^|$))","i"),/^$/,!0],[new RegExp(o.source+"\\s*$"),/^$/,!1]];t.exports=function(t,e,r,n){var o,s,a,c,l=t.bMarks[e]+t.tShift[e],u=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(!t.md.options.html)return!1;if(60!==t.src.charCodeAt(l))return!1;for(c=t.src.slice(l,u),o=0;o3||t.sCount[c]<0)){for(n=!1,o=0,i=l.length;o0&&this.level++,this.tokens.push(o),o},i.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]},i.prototype.skipEmptyLines=function(t){for(var e=this.lineMax;te;)if(!o(this.src.charCodeAt(--t)))return t+1;return t},i.prototype.skipChars=function(t,e){for(var r=this.src.length;tr;)if(e!==this.src.charCodeAt(--t))return t+1;return t},i.prototype.getLines=function(t,e,r,n){var i,s,a,c,l,u,p,h=t;if(t>=e)return"";for(u=new Array(e-t),i=0;hr?new Array(s-r+1).join(" ")+this.src.slice(c,l):this.src.slice(c,l)}return u.join("")},i.prototype.Token=n,t.exports=i},function(t,e,r){"use strict";var n=r(7),o=[["text",r(59)],["newline",r(60)],["escape",r(61)],["backticks",r(62)],["strikethrough",r(14).tokenize],["emphasis",r(15).tokenize],["link",r(63)],["image",r(64)],["autolink",r(65)],["html_inline",r(66)],["entity",r(67)]],i=[["balance_pairs",r(68)],["strikethrough",r(14).postProcess],["emphasis",r(15).postProcess],["text_collapse",r(69)]];function s(){var t;for(this.ruler=new n,t=0;t=i)break}else t.pending+=t.src[t.pos++]}t.pending&&t.pushPending()},s.prototype.parse=function(t,e,r,n){var o,i,s,a=new this.State(t,e,r,n);for(this.tokenize(a),s=(i=this.ruler2.getRules("")).length,o=0;o=0&&32===t.pending.charCodeAt(r)?r>=1&&32===t.pending.charCodeAt(r-1)?(t.pending=t.pending.replace(/ +$/,""),t.push("hardbreak","br",0)):(t.pending=t.pending.slice(0,-1),t.push("softbreak","br",0)):t.push("softbreak","br",0)),i++;i?@[]^_`{|}~-".split("").forEach((function(t){o[t.charCodeAt(0)]=1})),t.exports=function(t,e){var r,i=t.pos,s=t.posMax;if(92!==t.src.charCodeAt(i))return!1;if(++i=m)return!1;for(g=l,(u=t.md.helpers.parseLinkDestination(t.src,l,t.posMax)).ok&&(f=t.md.normalizeLink(u.str),t.md.validateLink(f)?l=u.pos:f=""),g=l;l=m||41!==t.src.charCodeAt(l))&&(v=!0),l++}if(v){if(void 0===t.env.references)return!1;if(l=0?s=t.src.slice(g,l++):l=a+1):l=a+1,s||(s=t.src.slice(c,a)),!(p=t.env.references[n(s)]))return t.pos=d,!1;f=p.href,h=p.title}return e||(t.pos=c,t.posMax=a,t.push("link_open","a",1).attrs=r=[["href",f]],h&&r.push(["title",h]),t.md.inline.tokenize(t),t.push("link_close","a",-1)),t.pos=l,t.posMax=m,!0}},function(t,e,r){"use strict";var n=r(0).normalizeReference,o=r(0).isSpace;t.exports=function(t,e){var r,i,s,a,c,l,u,p,h,f,d,m,g,v="",y=t.pos,b=t.posMax;if(33!==t.src.charCodeAt(t.pos))return!1;if(91!==t.src.charCodeAt(t.pos+1))return!1;if(l=t.pos+2,(c=t.md.helpers.parseLinkLabel(t,t.pos+1,!1))<0)return!1;if((u=c+1)=b)return!1;for(g=u,(h=t.md.helpers.parseLinkDestination(t.src,u,t.posMax)).ok&&(v=t.md.normalizeLink(h.str),t.md.validateLink(v)?u=h.pos:v=""),g=u;u=b||41!==t.src.charCodeAt(u))return t.pos=y,!1;u++}else{if(void 0===t.env.references)return!1;if(u=0?a=t.src.slice(g,u++):u=c+1):u=c+1,a||(a=t.src.slice(l,c)),!(p=t.env.references[n(a)]))return t.pos=y,!1;v=p.href,f=p.title}return e||(s=t.src.slice(l,c),t.md.inline.parse(s,t.md,t.env,m=[]),(d=t.push("image","img",0)).attrs=r=[["src",v],["alt",""]],d.children=m,d.content=s,f&&r.push(["title",f])),t.pos=u,t.posMax=b,!0}},function(t,e,r){"use strict";var n=/^<([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])?)*)>/,o=/^<([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)>/;t.exports=function(t,e){var r,i,s,a,c,l,u=t.pos;return 60===t.src.charCodeAt(u)&&(!((r=t.src.slice(u)).indexOf(">")<0)&&(o.test(r)?(a=(i=r.match(o))[0].slice(1,-1),c=t.md.normalizeLink(a),!!t.md.validateLink(c)&&(e||((l=t.push("link_open","a",1)).attrs=[["href",c]],l.markup="autolink",l.info="auto",(l=t.push("text","",0)).content=t.md.normalizeLinkText(a),(l=t.push("link_close","a",-1)).markup="autolink",l.info="auto"),t.pos+=i[0].length,!0)):!!n.test(r)&&(a=(s=r.match(n))[0].slice(1,-1),c=t.md.normalizeLink("mailto:"+a),!!t.md.validateLink(c)&&(e||((l=t.push("link_open","a",1)).attrs=[["href",c]],l.markup="autolink",l.info="auto",(l=t.push("text","",0)).content=t.md.normalizeLinkText(a),(l=t.push("link_close","a",-1)).markup="autolink",l.info="auto"),t.pos+=s[0].length,!0))))}},function(t,e,r){"use strict";var n=r(13).HTML_TAG_RE;t.exports=function(t,e){var r,o,i,s=t.pos;return!!t.md.options.html&&(i=t.posMax,!(60!==t.src.charCodeAt(s)||s+2>=i)&&(!(33!==(r=t.src.charCodeAt(s+1))&&63!==r&&47!==r&&!function(t){var e=32|t;return e>=97&&e<=122}(r))&&(!!(o=t.src.slice(s).match(n))&&(e||(t.push("html_inline","",0).content=t.src.slice(s,s+o[0].length)),t.pos+=o[0].length,!0))))}},function(t,e,r){"use strict";var n=r(11),o=r(0).has,i=r(0).isValidEntityCode,s=r(0).fromCodePoint,a=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,c=/^&([a-z][a-z0-9]{1,31});/i;t.exports=function(t,e){var r,l,u=t.pos,p=t.posMax;if(38!==t.src.charCodeAt(u))return!1;if(u+1s;n-=i.jump+1)if((i=e[n]).marker===o.marker&&(-1===a&&(a=n),i.open&&i.end<0&&i.level===o.level&&(c=!1,(i.close||o.open)&&(i.length+o.length)%3==0&&(i.length%3==0&&o.length%3==0||(c=!0)),!c))){l=n>0&&!e[n-1].open?e[n-1].jump+1:0,o.jump=r-n+l,o.open=!1,i.end=r,i.jump=l,i.close=!1,a=-1;break}-1!==a&&(u[o.marker][(o.length||0)%3]=a)}}t.exports=function(t){var e,r=t.tokens_meta,o=t.tokens_meta.length;for(n(0,t.delimiters),e=0;e0&&n++,"text"===o[e].type&&e+10&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(o),this.tokens_meta.push(i),o},a.prototype.scanDelims=function(t,e){var r,n,a,c,l,u,p,h,f,d=t,m=!0,g=!0,v=this.posMax,y=this.src.charCodeAt(t);for(r=t>0?this.src.charCodeAt(t-1):32;d=3&&":"===t[e-3]||e>=3&&"/"===t[e-3]?0:n.match(r.re.no_http)[0].length:0}},"mailto:":{validate:function(t,e,r){var n=t.slice(e);return r.re.mailto||(r.re.mailto=new RegExp("^"+r.re.src_email_name+"@"+r.re.src_host_strict,"i")),r.re.mailto.test(n)?n.match(r.re.mailto)[0].length:0}}},l="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function u(t){var e=t.re=r(72)(t.__opts__),n=t.__tlds__.slice();function a(t){return t.replace("%TLDS%",e.src_tlds)}t.onCompile(),t.__tlds_replaced__||n.push("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]"),n.push(e.src_xn),e.src_tlds=n.join("|"),e.email_fuzzy=RegExp(a(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(a(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(a(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(a(e.tpl_host_fuzzy_test),"i");var c=[];function l(t,e){throw new Error('(LinkifyIt) Invalid schema "'+t+'": '+e)}t.__compiled__={},Object.keys(t.__schemas__).forEach((function(e){var r=t.__schemas__[e];if(null!==r){var n={validate:null,link:null};if(t.__compiled__[e]=n,"[object Object]"===o(r))return!function(t){return"[object RegExp]"===o(t)}(r.validate)?i(r.validate)?n.validate=r.validate:l(e,r):n.validate=function(t){return function(e,r){var n=e.slice(r);return t.test(n)?n.match(t)[0].length:0}}(r.validate),void(i(r.normalize)?n.normalize=r.normalize:r.normalize?l(e,r):n.normalize=function(t,e){e.normalize(t)});!function(t){return"[object String]"===o(t)}(r)?l(e,r):c.push(e)}})),c.forEach((function(e){t.__compiled__[t.__schemas__[e]]&&(t.__compiled__[e].validate=t.__compiled__[t.__schemas__[e]].validate,t.__compiled__[e].normalize=t.__compiled__[t.__schemas__[e]].normalize)})),t.__compiled__[""]={validate:null,normalize:function(t,e){e.normalize(t)}};var u=Object.keys(t.__compiled__).filter((function(e){return e.length>0&&t.__compiled__[e]})).map(s).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+u+")","i"),t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+u+")","ig"),t.re.pretest=RegExp("("+t.re.schema_test.source+")|("+t.re.host_fuzzy_test.source+")|@","i"),function(t){t.__index__=-1,t.__text_cache__=""}(t)}function p(t,e){var r=t.__index__,n=t.__last_index__,o=t.__text_cache__.slice(r,n);this.schema=t.__schema__.toLowerCase(),this.index=r+e,this.lastIndex=n+e,this.raw=o,this.text=o,this.url=o}function h(t,e){var r=new p(t,e);return t.__compiled__[r.schema].normalize(r,t),r}function f(t,e){if(!(this instanceof f))return new f(t,e);var r;e||(r=t,Object.keys(r||{}).reduce((function(t,e){return t||a.hasOwnProperty(e)}),!1)&&(e=t,t={})),this.__opts__=n({},a,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=n({},c,t),this.__compiled__={},this.__tlds__=l,this.__tlds_replaced__=!1,this.re={},u(this)}f.prototype.add=function(t,e){return this.__schemas__[t]=e,u(this),this},f.prototype.set=function(t){return this.__opts__=n(this.__opts__,t),this},f.prototype.test=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return!1;var e,r,n,o,i,s,a,c;if(this.re.schema_test.test(t))for((a=this.re.schema_search).lastIndex=0;null!==(e=a.exec(t));)if(o=this.testSchemaAt(t,e[2],a.lastIndex)){this.__schema__=e[2],this.__index__=e.index+e[1].length,this.__last_index__=e.index+e[0].length+o;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(c=t.search(this.re.host_fuzzy_test))>=0&&(this.__index__<0||c=0&&null!==(n=t.match(this.re.email_fuzzy))&&(i=n.index+n[1].length,s=n.index+n[0].length,(this.__index__<0||ithis.__last_index__)&&(this.__schema__="mailto:",this.__index__=i,this.__last_index__=s)),this.__index__>=0},f.prototype.pretest=function(t){return this.re.pretest.test(t)},f.prototype.testSchemaAt=function(t,e,r){return this.__compiled__[e.toLowerCase()]?this.__compiled__[e.toLowerCase()].validate(t,r,this):0},f.prototype.match=function(t){var e=0,r=[];this.__index__>=0&&this.__text_cache__===t&&(r.push(h(this,e)),e=this.__last_index__);for(var n=e?t.slice(e):t;this.test(n);)r.push(h(this,e)),n=n.slice(this.__last_index__),e+=this.__last_index__;return r.length?r:null},f.prototype.tlds=function(t,e){return t=Array.isArray(t)?t:[t],e?(this.__tlds__=this.__tlds__.concat(t).sort().filter((function(t,e,r){return t!==r[e-1]})).reverse(),u(this),this):(this.__tlds__=t.slice(),this.__tlds_replaced__=!0,u(this),this)},f.prototype.normalize=function(t){t.schema||(t.url="http://"+t.url),"mailto:"!==t.schema||/^mailto:/i.test(t.url)||(t.url="mailto:"+t.url)},f.prototype.onCompile=function(){},t.exports=f},function(t,e,r){"use strict";t.exports=function(t){var e={};e.src_Any=r(4).source,e.src_Cc=r(5).source,e.src_Z=r(6).source,e.src_P=r(2).source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");return e.src_pseudo_letter="(?:(?![><|]|"+e.src_ZPCc+")"+e.src_Any+")",e.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]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|[><|]|"+e.src_ZPCc+")(?!-|_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|[><|]|[()[\\]{}.,\"'?!\\-]).|\\[(?:(?!"+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+'|["]).)+\\"|\\\'(?:(?!'+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-]).|\\.{2,4}[a-zA-Z0-9%/]|\\.(?!"+e.src_ZCc+"|[.]).|"+(t&&t["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+"\\,(?!"+e.src_ZCc+").|\\!(?!"+e.src_ZCc+"|[!]).|\\?(?!"+e.src_ZCc+"|[?]).)+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy='(^|[><|]|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"===("undefined"==typeof window?"undefined":r(window))&&(n=window)}t.exports=n},function(t,e,r){"use strict";t.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}}},function(t,e,r){"use strict";t.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","text_collapse"]}}}},function(t,e,r){"use strict";t.exports={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","text_collapse"]}}}},function(t,e,r){"use strict";var n=r(1),o=r(80),i=r(84),s=r(85),a=r(93),c=r(107),l=r(120),u=r(3),p=r(16),h={default:r(122),zero:r(123),commonmark:r(124)},f=/^(vbscript|javascript|file|data):/,d=/^data:image\/(gif|png|jpeg|webp);/;function m(t){var e=t.trim().toLowerCase();return!f.test(e)||!!d.test(e)}var g=["http:","https:","mailto:"];function v(t){var e=u.parse(t,!0);if(e.hostname&&(!e.protocol||g.indexOf(e.protocol)>=0))try{e.hostname=p.toASCII(e.hostname)}catch(t){}return u.encode(u.format(e))}function y(t){var e=u.parse(t,!0);if(e.hostname&&(!e.protocol||g.indexOf(e.protocol)>=0))try{e.hostname=p.toUnicode(e.hostname)}catch(t){}return u.decode(u.format(e),u.decode.defaultChars+"%")}function b(t,e){if(!(this instanceof b))return new b(t,e);e||n.isString(t)||(e=t||{},t="default"),this.inline=new c,this.block=new a,this.core=new s,this.renderer=new i,this.linkify=new l,this.validateLink=m,this.normalizeLink=v,this.normalizeLinkText=y,this.utils=n,this.helpers=n.assign({},o),this.options={},this.configure(t),e&&this.set(e)}b.prototype.set=function(t){return n.assign(this.options,t),this},b.prototype.configure=function(t){var e,r=this;if(n.isString(t)&&!(t=h[e=t]))throw new Error('Wrong `markdown-it` preset "'+e+'", check name');if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");return t.options&&r.set(t.options),t.components&&Object.keys(t.components).forEach((function(e){t.components[e].rules&&r[e].ruler.enableOnly(t.components[e].rules),t.components[e].rules2&&r[e].ruler2.enableOnly(t.components[e].rules2)})),this},b.prototype.enable=function(t,e){var r=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.enable(t,!0))}),this),r=r.concat(this.inline.ruler2.enable(t,!0));var n=t.filter((function(t){return r.indexOf(t)<0}));if(n.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+n);return this},b.prototype.disable=function(t,e){var r=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.disable(t,!0))}),this),r=r.concat(this.inline.ruler2.disable(t,!0));var n=t.filter((function(t){return r.indexOf(t)<0}));if(n.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+n);return this},b.prototype.use=function(t){var e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this},b.prototype.parse=function(t,e){if("string"!=typeof t)throw new Error("Input data should be a String");var r=new this.core.State(t,this,e);return this.core.process(r),r.tokens},b.prototype.render=function(t,e){return e=e||{},this.renderer.render(this.parse(t,e),this.options,e)},b.prototype.parseInline=function(t,e){var r=new this.core.State(t,this,e);return r.inlineMode=!0,this.core.process(r),r.tokens},b.prototype.renderInline=function(t,e){return e=e||{},this.renderer.render(this.parseInline(t,e),this.options,e)},t.exports=b},function(t){t.exports=JSON.parse('{"Aacute":"Á","aacute":"á","Abreve":"Ă","abreve":"ă","ac":"∾","acd":"∿","acE":"∾̳","Acirc":"Â","acirc":"â","acute":"´","Acy":"А","acy":"а","AElig":"Æ","aelig":"æ","af":"⁡","Afr":"𝔄","afr":"𝔞","Agrave":"À","agrave":"à","alefsym":"ℵ","aleph":"ℵ","Alpha":"Α","alpha":"α","Amacr":"Ā","amacr":"ā","amalg":"⨿","amp":"&","AMP":"&","andand":"⩕","And":"⩓","and":"∧","andd":"⩜","andslope":"⩘","andv":"⩚","ang":"∠","ange":"⦤","angle":"∠","angmsdaa":"⦨","angmsdab":"⦩","angmsdac":"⦪","angmsdad":"⦫","angmsdae":"⦬","angmsdaf":"⦭","angmsdag":"⦮","angmsdah":"⦯","angmsd":"∡","angrt":"∟","angrtvb":"⊾","angrtvbd":"⦝","angsph":"∢","angst":"Å","angzarr":"⍼","Aogon":"Ą","aogon":"ą","Aopf":"𝔸","aopf":"𝕒","apacir":"⩯","ap":"≈","apE":"⩰","ape":"≊","apid":"≋","apos":"\'","ApplyFunction":"⁡","approx":"≈","approxeq":"≊","Aring":"Å","aring":"å","Ascr":"𝒜","ascr":"𝒶","Assign":"≔","ast":"*","asymp":"≈","asympeq":"≍","Atilde":"Ã","atilde":"ã","Auml":"Ä","auml":"ä","awconint":"∳","awint":"⨑","backcong":"≌","backepsilon":"϶","backprime":"‵","backsim":"∽","backsimeq":"⋍","Backslash":"∖","Barv":"⫧","barvee":"⊽","barwed":"⌅","Barwed":"⌆","barwedge":"⌅","bbrk":"⎵","bbrktbrk":"⎶","bcong":"≌","Bcy":"Б","bcy":"б","bdquo":"„","becaus":"∵","because":"∵","Because":"∵","bemptyv":"⦰","bepsi":"϶","bernou":"ℬ","Bernoullis":"ℬ","Beta":"Β","beta":"β","beth":"ℶ","between":"≬","Bfr":"𝔅","bfr":"𝔟","bigcap":"⋂","bigcirc":"◯","bigcup":"⋃","bigodot":"⨀","bigoplus":"⨁","bigotimes":"⨂","bigsqcup":"⨆","bigstar":"★","bigtriangledown":"▽","bigtriangleup":"△","biguplus":"⨄","bigvee":"⋁","bigwedge":"⋀","bkarow":"⤍","blacklozenge":"⧫","blacksquare":"▪","blacktriangle":"▴","blacktriangledown":"▾","blacktriangleleft":"◂","blacktriangleright":"▸","blank":"␣","blk12":"▒","blk14":"░","blk34":"▓","block":"█","bne":"=⃥","bnequiv":"≡⃥","bNot":"⫭","bnot":"⌐","Bopf":"𝔹","bopf":"𝕓","bot":"⊥","bottom":"⊥","bowtie":"⋈","boxbox":"⧉","boxdl":"┐","boxdL":"╕","boxDl":"╖","boxDL":"╗","boxdr":"┌","boxdR":"╒","boxDr":"╓","boxDR":"╔","boxh":"─","boxH":"═","boxhd":"┬","boxHd":"╤","boxhD":"╥","boxHD":"╦","boxhu":"┴","boxHu":"╧","boxhU":"╨","boxHU":"╩","boxminus":"⊟","boxplus":"⊞","boxtimes":"⊠","boxul":"┘","boxuL":"╛","boxUl":"╜","boxUL":"╝","boxur":"└","boxuR":"╘","boxUr":"╙","boxUR":"╚","boxv":"│","boxV":"║","boxvh":"┼","boxvH":"╪","boxVh":"╫","boxVH":"╬","boxvl":"┤","boxvL":"╡","boxVl":"╢","boxVL":"╣","boxvr":"├","boxvR":"╞","boxVr":"╟","boxVR":"╠","bprime":"‵","breve":"˘","Breve":"˘","brvbar":"¦","bscr":"𝒷","Bscr":"ℬ","bsemi":"⁏","bsim":"∽","bsime":"⋍","bsolb":"⧅","bsol":"\\\\","bsolhsub":"⟈","bull":"•","bullet":"•","bump":"≎","bumpE":"⪮","bumpe":"≏","Bumpeq":"≎","bumpeq":"≏","Cacute":"Ć","cacute":"ć","capand":"⩄","capbrcup":"⩉","capcap":"⩋","cap":"∩","Cap":"⋒","capcup":"⩇","capdot":"⩀","CapitalDifferentialD":"ⅅ","caps":"∩︀","caret":"⁁","caron":"ˇ","Cayleys":"ℭ","ccaps":"⩍","Ccaron":"Č","ccaron":"č","Ccedil":"Ç","ccedil":"ç","Ccirc":"Ĉ","ccirc":"ĉ","Cconint":"∰","ccups":"⩌","ccupssm":"⩐","Cdot":"Ċ","cdot":"ċ","cedil":"¸","Cedilla":"¸","cemptyv":"⦲","cent":"¢","centerdot":"·","CenterDot":"·","cfr":"𝔠","Cfr":"ℭ","CHcy":"Ч","chcy":"ч","check":"✓","checkmark":"✓","Chi":"Χ","chi":"χ","circ":"ˆ","circeq":"≗","circlearrowleft":"↺","circlearrowright":"↻","circledast":"⊛","circledcirc":"⊚","circleddash":"⊝","CircleDot":"⊙","circledR":"®","circledS":"Ⓢ","CircleMinus":"⊖","CirclePlus":"⊕","CircleTimes":"⊗","cir":"○","cirE":"⧃","cire":"≗","cirfnint":"⨐","cirmid":"⫯","cirscir":"⧂","ClockwiseContourIntegral":"∲","CloseCurlyDoubleQuote":"”","CloseCurlyQuote":"’","clubs":"♣","clubsuit":"♣","colon":":","Colon":"∷","Colone":"⩴","colone":"≔","coloneq":"≔","comma":",","commat":"@","comp":"∁","compfn":"∘","complement":"∁","complexes":"ℂ","cong":"≅","congdot":"⩭","Congruent":"≡","conint":"∮","Conint":"∯","ContourIntegral":"∮","copf":"𝕔","Copf":"ℂ","coprod":"∐","Coproduct":"∐","copy":"©","COPY":"©","copysr":"℗","CounterClockwiseContourIntegral":"∳","crarr":"↵","cross":"✗","Cross":"⨯","Cscr":"𝒞","cscr":"𝒸","csub":"⫏","csube":"⫑","csup":"⫐","csupe":"⫒","ctdot":"⋯","cudarrl":"⤸","cudarrr":"⤵","cuepr":"⋞","cuesc":"⋟","cularr":"↶","cularrp":"⤽","cupbrcap":"⩈","cupcap":"⩆","CupCap":"≍","cup":"∪","Cup":"⋓","cupcup":"⩊","cupdot":"⊍","cupor":"⩅","cups":"∪︀","curarr":"↷","curarrm":"⤼","curlyeqprec":"⋞","curlyeqsucc":"⋟","curlyvee":"⋎","curlywedge":"⋏","curren":"¤","curvearrowleft":"↶","curvearrowright":"↷","cuvee":"⋎","cuwed":"⋏","cwconint":"∲","cwint":"∱","cylcty":"⌭","dagger":"†","Dagger":"‡","daleth":"ℸ","darr":"↓","Darr":"↡","dArr":"⇓","dash":"‐","Dashv":"⫤","dashv":"⊣","dbkarow":"⤏","dblac":"˝","Dcaron":"Ď","dcaron":"ď","Dcy":"Д","dcy":"д","ddagger":"‡","ddarr":"⇊","DD":"ⅅ","dd":"ⅆ","DDotrahd":"⤑","ddotseq":"⩷","deg":"°","Del":"∇","Delta":"Δ","delta":"δ","demptyv":"⦱","dfisht":"⥿","Dfr":"𝔇","dfr":"𝔡","dHar":"⥥","dharl":"⇃","dharr":"⇂","DiacriticalAcute":"´","DiacriticalDot":"˙","DiacriticalDoubleAcute":"˝","DiacriticalGrave":"`","DiacriticalTilde":"˜","diam":"⋄","diamond":"⋄","Diamond":"⋄","diamondsuit":"♦","diams":"♦","die":"¨","DifferentialD":"ⅆ","digamma":"ϝ","disin":"⋲","div":"÷","divide":"÷","divideontimes":"⋇","divonx":"⋇","DJcy":"Ђ","djcy":"ђ","dlcorn":"⌞","dlcrop":"⌍","dollar":"$","Dopf":"𝔻","dopf":"𝕕","Dot":"¨","dot":"˙","DotDot":"⃜","doteq":"≐","doteqdot":"≑","DotEqual":"≐","dotminus":"∸","dotplus":"∔","dotsquare":"⊡","doublebarwedge":"⌆","DoubleContourIntegral":"∯","DoubleDot":"¨","DoubleDownArrow":"⇓","DoubleLeftArrow":"⇐","DoubleLeftRightArrow":"⇔","DoubleLeftTee":"⫤","DoubleLongLeftArrow":"⟸","DoubleLongLeftRightArrow":"⟺","DoubleLongRightArrow":"⟹","DoubleRightArrow":"⇒","DoubleRightTee":"⊨","DoubleUpArrow":"⇑","DoubleUpDownArrow":"⇕","DoubleVerticalBar":"∥","DownArrowBar":"⤓","downarrow":"↓","DownArrow":"↓","Downarrow":"⇓","DownArrowUpArrow":"⇵","DownBreve":"̑","downdownarrows":"⇊","downharpoonleft":"⇃","downharpoonright":"⇂","DownLeftRightVector":"⥐","DownLeftTeeVector":"⥞","DownLeftVectorBar":"⥖","DownLeftVector":"↽","DownRightTeeVector":"⥟","DownRightVectorBar":"⥗","DownRightVector":"⇁","DownTeeArrow":"↧","DownTee":"⊤","drbkarow":"⤐","drcorn":"⌟","drcrop":"⌌","Dscr":"𝒟","dscr":"𝒹","DScy":"Ѕ","dscy":"ѕ","dsol":"⧶","Dstrok":"Đ","dstrok":"đ","dtdot":"⋱","dtri":"▿","dtrif":"▾","duarr":"⇵","duhar":"⥯","dwangle":"⦦","DZcy":"Џ","dzcy":"џ","dzigrarr":"⟿","Eacute":"É","eacute":"é","easter":"⩮","Ecaron":"Ě","ecaron":"ě","Ecirc":"Ê","ecirc":"ê","ecir":"≖","ecolon":"≕","Ecy":"Э","ecy":"э","eDDot":"⩷","Edot":"Ė","edot":"ė","eDot":"≑","ee":"ⅇ","efDot":"≒","Efr":"𝔈","efr":"𝔢","eg":"⪚","Egrave":"È","egrave":"è","egs":"⪖","egsdot":"⪘","el":"⪙","Element":"∈","elinters":"⏧","ell":"ℓ","els":"⪕","elsdot":"⪗","Emacr":"Ē","emacr":"ē","empty":"∅","emptyset":"∅","EmptySmallSquare":"◻","emptyv":"∅","EmptyVerySmallSquare":"▫","emsp13":" ","emsp14":" ","emsp":" ","ENG":"Ŋ","eng":"ŋ","ensp":" ","Eogon":"Ę","eogon":"ę","Eopf":"𝔼","eopf":"𝕖","epar":"⋕","eparsl":"⧣","eplus":"⩱","epsi":"ε","Epsilon":"Ε","epsilon":"ε","epsiv":"ϵ","eqcirc":"≖","eqcolon":"≕","eqsim":"≂","eqslantgtr":"⪖","eqslantless":"⪕","Equal":"⩵","equals":"=","EqualTilde":"≂","equest":"≟","Equilibrium":"⇌","equiv":"≡","equivDD":"⩸","eqvparsl":"⧥","erarr":"⥱","erDot":"≓","escr":"ℯ","Escr":"ℰ","esdot":"≐","Esim":"⩳","esim":"≂","Eta":"Η","eta":"η","ETH":"Ð","eth":"ð","Euml":"Ë","euml":"ë","euro":"€","excl":"!","exist":"∃","Exists":"∃","expectation":"ℰ","exponentiale":"ⅇ","ExponentialE":"ⅇ","fallingdotseq":"≒","Fcy":"Ф","fcy":"ф","female":"♀","ffilig":"ffi","fflig":"ff","ffllig":"ffl","Ffr":"𝔉","ffr":"𝔣","filig":"fi","FilledSmallSquare":"◼","FilledVerySmallSquare":"▪","fjlig":"fj","flat":"♭","fllig":"fl","fltns":"▱","fnof":"ƒ","Fopf":"𝔽","fopf":"𝕗","forall":"∀","ForAll":"∀","fork":"⋔","forkv":"⫙","Fouriertrf":"ℱ","fpartint":"⨍","frac12":"½","frac13":"⅓","frac14":"¼","frac15":"⅕","frac16":"⅙","frac18":"⅛","frac23":"⅔","frac25":"⅖","frac34":"¾","frac35":"⅗","frac38":"⅜","frac45":"⅘","frac56":"⅚","frac58":"⅝","frac78":"⅞","frasl":"⁄","frown":"⌢","fscr":"𝒻","Fscr":"ℱ","gacute":"ǵ","Gamma":"Γ","gamma":"γ","Gammad":"Ϝ","gammad":"ϝ","gap":"⪆","Gbreve":"Ğ","gbreve":"ğ","Gcedil":"Ģ","Gcirc":"Ĝ","gcirc":"ĝ","Gcy":"Г","gcy":"г","Gdot":"Ġ","gdot":"ġ","ge":"≥","gE":"≧","gEl":"⪌","gel":"⋛","geq":"≥","geqq":"≧","geqslant":"⩾","gescc":"⪩","ges":"⩾","gesdot":"⪀","gesdoto":"⪂","gesdotol":"⪄","gesl":"⋛︀","gesles":"⪔","Gfr":"𝔊","gfr":"𝔤","gg":"≫","Gg":"⋙","ggg":"⋙","gimel":"ℷ","GJcy":"Ѓ","gjcy":"ѓ","gla":"⪥","gl":"≷","glE":"⪒","glj":"⪤","gnap":"⪊","gnapprox":"⪊","gne":"⪈","gnE":"≩","gneq":"⪈","gneqq":"≩","gnsim":"⋧","Gopf":"𝔾","gopf":"𝕘","grave":"`","GreaterEqual":"≥","GreaterEqualLess":"⋛","GreaterFullEqual":"≧","GreaterGreater":"⪢","GreaterLess":"≷","GreaterSlantEqual":"⩾","GreaterTilde":"≳","Gscr":"𝒢","gscr":"ℊ","gsim":"≳","gsime":"⪎","gsiml":"⪐","gtcc":"⪧","gtcir":"⩺","gt":">","GT":">","Gt":"≫","gtdot":"⋗","gtlPar":"⦕","gtquest":"⩼","gtrapprox":"⪆","gtrarr":"⥸","gtrdot":"⋗","gtreqless":"⋛","gtreqqless":"⪌","gtrless":"≷","gtrsim":"≳","gvertneqq":"≩︀","gvnE":"≩︀","Hacek":"ˇ","hairsp":" ","half":"½","hamilt":"ℋ","HARDcy":"Ъ","hardcy":"ъ","harrcir":"⥈","harr":"↔","hArr":"⇔","harrw":"↭","Hat":"^","hbar":"ℏ","Hcirc":"Ĥ","hcirc":"ĥ","hearts":"♥","heartsuit":"♥","hellip":"…","hercon":"⊹","hfr":"𝔥","Hfr":"ℌ","HilbertSpace":"ℋ","hksearow":"⤥","hkswarow":"⤦","hoarr":"⇿","homtht":"∻","hookleftarrow":"↩","hookrightarrow":"↪","hopf":"𝕙","Hopf":"ℍ","horbar":"―","HorizontalLine":"─","hscr":"𝒽","Hscr":"ℋ","hslash":"ℏ","Hstrok":"Ħ","hstrok":"ħ","HumpDownHump":"≎","HumpEqual":"≏","hybull":"⁃","hyphen":"‐","Iacute":"Í","iacute":"í","ic":"⁣","Icirc":"Î","icirc":"î","Icy":"И","icy":"и","Idot":"İ","IEcy":"Е","iecy":"е","iexcl":"¡","iff":"⇔","ifr":"𝔦","Ifr":"ℑ","Igrave":"Ì","igrave":"ì","ii":"ⅈ","iiiint":"⨌","iiint":"∭","iinfin":"⧜","iiota":"℩","IJlig":"IJ","ijlig":"ij","Imacr":"Ī","imacr":"ī","image":"ℑ","ImaginaryI":"ⅈ","imagline":"ℐ","imagpart":"ℑ","imath":"ı","Im":"ℑ","imof":"⊷","imped":"Ƶ","Implies":"⇒","incare":"℅","in":"∈","infin":"∞","infintie":"⧝","inodot":"ı","intcal":"⊺","int":"∫","Int":"∬","integers":"ℤ","Integral":"∫","intercal":"⊺","Intersection":"⋂","intlarhk":"⨗","intprod":"⨼","InvisibleComma":"⁣","InvisibleTimes":"⁢","IOcy":"Ё","iocy":"ё","Iogon":"Į","iogon":"į","Iopf":"𝕀","iopf":"𝕚","Iota":"Ι","iota":"ι","iprod":"⨼","iquest":"¿","iscr":"𝒾","Iscr":"ℐ","isin":"∈","isindot":"⋵","isinE":"⋹","isins":"⋴","isinsv":"⋳","isinv":"∈","it":"⁢","Itilde":"Ĩ","itilde":"ĩ","Iukcy":"І","iukcy":"і","Iuml":"Ï","iuml":"ï","Jcirc":"Ĵ","jcirc":"ĵ","Jcy":"Й","jcy":"й","Jfr":"𝔍","jfr":"𝔧","jmath":"ȷ","Jopf":"𝕁","jopf":"𝕛","Jscr":"𝒥","jscr":"𝒿","Jsercy":"Ј","jsercy":"ј","Jukcy":"Є","jukcy":"є","Kappa":"Κ","kappa":"κ","kappav":"ϰ","Kcedil":"Ķ","kcedil":"ķ","Kcy":"К","kcy":"к","Kfr":"𝔎","kfr":"𝔨","kgreen":"ĸ","KHcy":"Х","khcy":"х","KJcy":"Ќ","kjcy":"ќ","Kopf":"𝕂","kopf":"𝕜","Kscr":"𝒦","kscr":"𝓀","lAarr":"⇚","Lacute":"Ĺ","lacute":"ĺ","laemptyv":"⦴","lagran":"ℒ","Lambda":"Λ","lambda":"λ","lang":"⟨","Lang":"⟪","langd":"⦑","langle":"⟨","lap":"⪅","Laplacetrf":"ℒ","laquo":"«","larrb":"⇤","larrbfs":"⤟","larr":"←","Larr":"↞","lArr":"⇐","larrfs":"⤝","larrhk":"↩","larrlp":"↫","larrpl":"⤹","larrsim":"⥳","larrtl":"↢","latail":"⤙","lAtail":"⤛","lat":"⪫","late":"⪭","lates":"⪭︀","lbarr":"⤌","lBarr":"⤎","lbbrk":"❲","lbrace":"{","lbrack":"[","lbrke":"⦋","lbrksld":"⦏","lbrkslu":"⦍","Lcaron":"Ľ","lcaron":"ľ","Lcedil":"Ļ","lcedil":"ļ","lceil":"⌈","lcub":"{","Lcy":"Л","lcy":"л","ldca":"⤶","ldquo":"“","ldquor":"„","ldrdhar":"⥧","ldrushar":"⥋","ldsh":"↲","le":"≤","lE":"≦","LeftAngleBracket":"⟨","LeftArrowBar":"⇤","leftarrow":"←","LeftArrow":"←","Leftarrow":"⇐","LeftArrowRightArrow":"⇆","leftarrowtail":"↢","LeftCeiling":"⌈","LeftDoubleBracket":"⟦","LeftDownTeeVector":"⥡","LeftDownVectorBar":"⥙","LeftDownVector":"⇃","LeftFloor":"⌊","leftharpoondown":"↽","leftharpoonup":"↼","leftleftarrows":"⇇","leftrightarrow":"↔","LeftRightArrow":"↔","Leftrightarrow":"⇔","leftrightarrows":"⇆","leftrightharpoons":"⇋","leftrightsquigarrow":"↭","LeftRightVector":"⥎","LeftTeeArrow":"↤","LeftTee":"⊣","LeftTeeVector":"⥚","leftthreetimes":"⋋","LeftTriangleBar":"⧏","LeftTriangle":"⊲","LeftTriangleEqual":"⊴","LeftUpDownVector":"⥑","LeftUpTeeVector":"⥠","LeftUpVectorBar":"⥘","LeftUpVector":"↿","LeftVectorBar":"⥒","LeftVector":"↼","lEg":"⪋","leg":"⋚","leq":"≤","leqq":"≦","leqslant":"⩽","lescc":"⪨","les":"⩽","lesdot":"⩿","lesdoto":"⪁","lesdotor":"⪃","lesg":"⋚︀","lesges":"⪓","lessapprox":"⪅","lessdot":"⋖","lesseqgtr":"⋚","lesseqqgtr":"⪋","LessEqualGreater":"⋚","LessFullEqual":"≦","LessGreater":"≶","lessgtr":"≶","LessLess":"⪡","lesssim":"≲","LessSlantEqual":"⩽","LessTilde":"≲","lfisht":"⥼","lfloor":"⌊","Lfr":"𝔏","lfr":"𝔩","lg":"≶","lgE":"⪑","lHar":"⥢","lhard":"↽","lharu":"↼","lharul":"⥪","lhblk":"▄","LJcy":"Љ","ljcy":"љ","llarr":"⇇","ll":"≪","Ll":"⋘","llcorner":"⌞","Lleftarrow":"⇚","llhard":"⥫","lltri":"◺","Lmidot":"Ŀ","lmidot":"ŀ","lmoustache":"⎰","lmoust":"⎰","lnap":"⪉","lnapprox":"⪉","lne":"⪇","lnE":"≨","lneq":"⪇","lneqq":"≨","lnsim":"⋦","loang":"⟬","loarr":"⇽","lobrk":"⟦","longleftarrow":"⟵","LongLeftArrow":"⟵","Longleftarrow":"⟸","longleftrightarrow":"⟷","LongLeftRightArrow":"⟷","Longleftrightarrow":"⟺","longmapsto":"⟼","longrightarrow":"⟶","LongRightArrow":"⟶","Longrightarrow":"⟹","looparrowleft":"↫","looparrowright":"↬","lopar":"⦅","Lopf":"𝕃","lopf":"𝕝","loplus":"⨭","lotimes":"⨴","lowast":"∗","lowbar":"_","LowerLeftArrow":"↙","LowerRightArrow":"↘","loz":"◊","lozenge":"◊","lozf":"⧫","lpar":"(","lparlt":"⦓","lrarr":"⇆","lrcorner":"⌟","lrhar":"⇋","lrhard":"⥭","lrm":"‎","lrtri":"⊿","lsaquo":"‹","lscr":"𝓁","Lscr":"ℒ","lsh":"↰","Lsh":"↰","lsim":"≲","lsime":"⪍","lsimg":"⪏","lsqb":"[","lsquo":"‘","lsquor":"‚","Lstrok":"Ł","lstrok":"ł","ltcc":"⪦","ltcir":"⩹","lt":"<","LT":"<","Lt":"≪","ltdot":"⋖","lthree":"⋋","ltimes":"⋉","ltlarr":"⥶","ltquest":"⩻","ltri":"◃","ltrie":"⊴","ltrif":"◂","ltrPar":"⦖","lurdshar":"⥊","luruhar":"⥦","lvertneqq":"≨︀","lvnE":"≨︀","macr":"¯","male":"♂","malt":"✠","maltese":"✠","Map":"⤅","map":"↦","mapsto":"↦","mapstodown":"↧","mapstoleft":"↤","mapstoup":"↥","marker":"▮","mcomma":"⨩","Mcy":"М","mcy":"м","mdash":"—","mDDot":"∺","measuredangle":"∡","MediumSpace":" ","Mellintrf":"ℳ","Mfr":"𝔐","mfr":"𝔪","mho":"℧","micro":"µ","midast":"*","midcir":"⫰","mid":"∣","middot":"·","minusb":"⊟","minus":"−","minusd":"∸","minusdu":"⨪","MinusPlus":"∓","mlcp":"⫛","mldr":"…","mnplus":"∓","models":"⊧","Mopf":"𝕄","mopf":"𝕞","mp":"∓","mscr":"𝓂","Mscr":"ℳ","mstpos":"∾","Mu":"Μ","mu":"μ","multimap":"⊸","mumap":"⊸","nabla":"∇","Nacute":"Ń","nacute":"ń","nang":"∠⃒","nap":"≉","napE":"⩰̸","napid":"≋̸","napos":"ʼn","napprox":"≉","natural":"♮","naturals":"ℕ","natur":"♮","nbsp":" ","nbump":"≎̸","nbumpe":"≏̸","ncap":"⩃","Ncaron":"Ň","ncaron":"ň","Ncedil":"Ņ","ncedil":"ņ","ncong":"≇","ncongdot":"⩭̸","ncup":"⩂","Ncy":"Н","ncy":"н","ndash":"–","nearhk":"⤤","nearr":"↗","neArr":"⇗","nearrow":"↗","ne":"≠","nedot":"≐̸","NegativeMediumSpace":"​","NegativeThickSpace":"​","NegativeThinSpace":"​","NegativeVeryThinSpace":"​","nequiv":"≢","nesear":"⤨","nesim":"≂̸","NestedGreaterGreater":"≫","NestedLessLess":"≪","NewLine":"\\n","nexist":"∄","nexists":"∄","Nfr":"𝔑","nfr":"𝔫","ngE":"≧̸","nge":"≱","ngeq":"≱","ngeqq":"≧̸","ngeqslant":"⩾̸","nges":"⩾̸","nGg":"⋙̸","ngsim":"≵","nGt":"≫⃒","ngt":"≯","ngtr":"≯","nGtv":"≫̸","nharr":"↮","nhArr":"⇎","nhpar":"⫲","ni":"∋","nis":"⋼","nisd":"⋺","niv":"∋","NJcy":"Њ","njcy":"њ","nlarr":"↚","nlArr":"⇍","nldr":"‥","nlE":"≦̸","nle":"≰","nleftarrow":"↚","nLeftarrow":"⇍","nleftrightarrow":"↮","nLeftrightarrow":"⇎","nleq":"≰","nleqq":"≦̸","nleqslant":"⩽̸","nles":"⩽̸","nless":"≮","nLl":"⋘̸","nlsim":"≴","nLt":"≪⃒","nlt":"≮","nltri":"⋪","nltrie":"⋬","nLtv":"≪̸","nmid":"∤","NoBreak":"⁠","NonBreakingSpace":" ","nopf":"𝕟","Nopf":"ℕ","Not":"⫬","not":"¬","NotCongruent":"≢","NotCupCap":"≭","NotDoubleVerticalBar":"∦","NotElement":"∉","NotEqual":"≠","NotEqualTilde":"≂̸","NotExists":"∄","NotGreater":"≯","NotGreaterEqual":"≱","NotGreaterFullEqual":"≧̸","NotGreaterGreater":"≫̸","NotGreaterLess":"≹","NotGreaterSlantEqual":"⩾̸","NotGreaterTilde":"≵","NotHumpDownHump":"≎̸","NotHumpEqual":"≏̸","notin":"∉","notindot":"⋵̸","notinE":"⋹̸","notinva":"∉","notinvb":"⋷","notinvc":"⋶","NotLeftTriangleBar":"⧏̸","NotLeftTriangle":"⋪","NotLeftTriangleEqual":"⋬","NotLess":"≮","NotLessEqual":"≰","NotLessGreater":"≸","NotLessLess":"≪̸","NotLessSlantEqual":"⩽̸","NotLessTilde":"≴","NotNestedGreaterGreater":"⪢̸","NotNestedLessLess":"⪡̸","notni":"∌","notniva":"∌","notnivb":"⋾","notnivc":"⋽","NotPrecedes":"⊀","NotPrecedesEqual":"⪯̸","NotPrecedesSlantEqual":"⋠","NotReverseElement":"∌","NotRightTriangleBar":"⧐̸","NotRightTriangle":"⋫","NotRightTriangleEqual":"⋭","NotSquareSubset":"⊏̸","NotSquareSubsetEqual":"⋢","NotSquareSuperset":"⊐̸","NotSquareSupersetEqual":"⋣","NotSubset":"⊂⃒","NotSubsetEqual":"⊈","NotSucceeds":"⊁","NotSucceedsEqual":"⪰̸","NotSucceedsSlantEqual":"⋡","NotSucceedsTilde":"≿̸","NotSuperset":"⊃⃒","NotSupersetEqual":"⊉","NotTilde":"≁","NotTildeEqual":"≄","NotTildeFullEqual":"≇","NotTildeTilde":"≉","NotVerticalBar":"∤","nparallel":"∦","npar":"∦","nparsl":"⫽⃥","npart":"∂̸","npolint":"⨔","npr":"⊀","nprcue":"⋠","nprec":"⊀","npreceq":"⪯̸","npre":"⪯̸","nrarrc":"⤳̸","nrarr":"↛","nrArr":"⇏","nrarrw":"↝̸","nrightarrow":"↛","nRightarrow":"⇏","nrtri":"⋫","nrtrie":"⋭","nsc":"⊁","nsccue":"⋡","nsce":"⪰̸","Nscr":"𝒩","nscr":"𝓃","nshortmid":"∤","nshortparallel":"∦","nsim":"≁","nsime":"≄","nsimeq":"≄","nsmid":"∤","nspar":"∦","nsqsube":"⋢","nsqsupe":"⋣","nsub":"⊄","nsubE":"⫅̸","nsube":"⊈","nsubset":"⊂⃒","nsubseteq":"⊈","nsubseteqq":"⫅̸","nsucc":"⊁","nsucceq":"⪰̸","nsup":"⊅","nsupE":"⫆̸","nsupe":"⊉","nsupset":"⊃⃒","nsupseteq":"⊉","nsupseteqq":"⫆̸","ntgl":"≹","Ntilde":"Ñ","ntilde":"ñ","ntlg":"≸","ntriangleleft":"⋪","ntrianglelefteq":"⋬","ntriangleright":"⋫","ntrianglerighteq":"⋭","Nu":"Ν","nu":"ν","num":"#","numero":"№","numsp":" ","nvap":"≍⃒","nvdash":"⊬","nvDash":"⊭","nVdash":"⊮","nVDash":"⊯","nvge":"≥⃒","nvgt":">⃒","nvHarr":"⤄","nvinfin":"⧞","nvlArr":"⤂","nvle":"≤⃒","nvlt":"<⃒","nvltrie":"⊴⃒","nvrArr":"⤃","nvrtrie":"⊵⃒","nvsim":"∼⃒","nwarhk":"⤣","nwarr":"↖","nwArr":"⇖","nwarrow":"↖","nwnear":"⤧","Oacute":"Ó","oacute":"ó","oast":"⊛","Ocirc":"Ô","ocirc":"ô","ocir":"⊚","Ocy":"О","ocy":"о","odash":"⊝","Odblac":"Ő","odblac":"ő","odiv":"⨸","odot":"⊙","odsold":"⦼","OElig":"Œ","oelig":"œ","ofcir":"⦿","Ofr":"𝔒","ofr":"𝔬","ogon":"˛","Ograve":"Ò","ograve":"ò","ogt":"⧁","ohbar":"⦵","ohm":"Ω","oint":"∮","olarr":"↺","olcir":"⦾","olcross":"⦻","oline":"‾","olt":"⧀","Omacr":"Ō","omacr":"ō","Omega":"Ω","omega":"ω","Omicron":"Ο","omicron":"ο","omid":"⦶","ominus":"⊖","Oopf":"𝕆","oopf":"𝕠","opar":"⦷","OpenCurlyDoubleQuote":"“","OpenCurlyQuote":"‘","operp":"⦹","oplus":"⊕","orarr":"↻","Or":"⩔","or":"∨","ord":"⩝","order":"ℴ","orderof":"ℴ","ordf":"ª","ordm":"º","origof":"⊶","oror":"⩖","orslope":"⩗","orv":"⩛","oS":"Ⓢ","Oscr":"𝒪","oscr":"ℴ","Oslash":"Ø","oslash":"ø","osol":"⊘","Otilde":"Õ","otilde":"õ","otimesas":"⨶","Otimes":"⨷","otimes":"⊗","Ouml":"Ö","ouml":"ö","ovbar":"⌽","OverBar":"‾","OverBrace":"⏞","OverBracket":"⎴","OverParenthesis":"⏜","para":"¶","parallel":"∥","par":"∥","parsim":"⫳","parsl":"⫽","part":"∂","PartialD":"∂","Pcy":"П","pcy":"п","percnt":"%","period":".","permil":"‰","perp":"⊥","pertenk":"‱","Pfr":"𝔓","pfr":"𝔭","Phi":"Φ","phi":"φ","phiv":"ϕ","phmmat":"ℳ","phone":"☎","Pi":"Π","pi":"π","pitchfork":"⋔","piv":"ϖ","planck":"ℏ","planckh":"ℎ","plankv":"ℏ","plusacir":"⨣","plusb":"⊞","pluscir":"⨢","plus":"+","plusdo":"∔","plusdu":"⨥","pluse":"⩲","PlusMinus":"±","plusmn":"±","plussim":"⨦","plustwo":"⨧","pm":"±","Poincareplane":"ℌ","pointint":"⨕","popf":"𝕡","Popf":"ℙ","pound":"£","prap":"⪷","Pr":"⪻","pr":"≺","prcue":"≼","precapprox":"⪷","prec":"≺","preccurlyeq":"≼","Precedes":"≺","PrecedesEqual":"⪯","PrecedesSlantEqual":"≼","PrecedesTilde":"≾","preceq":"⪯","precnapprox":"⪹","precneqq":"⪵","precnsim":"⋨","pre":"⪯","prE":"⪳","precsim":"≾","prime":"′","Prime":"″","primes":"ℙ","prnap":"⪹","prnE":"⪵","prnsim":"⋨","prod":"∏","Product":"∏","profalar":"⌮","profline":"⌒","profsurf":"⌓","prop":"∝","Proportional":"∝","Proportion":"∷","propto":"∝","prsim":"≾","prurel":"⊰","Pscr":"𝒫","pscr":"𝓅","Psi":"Ψ","psi":"ψ","puncsp":" ","Qfr":"𝔔","qfr":"𝔮","qint":"⨌","qopf":"𝕢","Qopf":"ℚ","qprime":"⁗","Qscr":"𝒬","qscr":"𝓆","quaternions":"ℍ","quatint":"⨖","quest":"?","questeq":"≟","quot":"\\"","QUOT":"\\"","rAarr":"⇛","race":"∽̱","Racute":"Ŕ","racute":"ŕ","radic":"√","raemptyv":"⦳","rang":"⟩","Rang":"⟫","rangd":"⦒","range":"⦥","rangle":"⟩","raquo":"»","rarrap":"⥵","rarrb":"⇥","rarrbfs":"⤠","rarrc":"⤳","rarr":"→","Rarr":"↠","rArr":"⇒","rarrfs":"⤞","rarrhk":"↪","rarrlp":"↬","rarrpl":"⥅","rarrsim":"⥴","Rarrtl":"⤖","rarrtl":"↣","rarrw":"↝","ratail":"⤚","rAtail":"⤜","ratio":"∶","rationals":"ℚ","rbarr":"⤍","rBarr":"⤏","RBarr":"⤐","rbbrk":"❳","rbrace":"}","rbrack":"]","rbrke":"⦌","rbrksld":"⦎","rbrkslu":"⦐","Rcaron":"Ř","rcaron":"ř","Rcedil":"Ŗ","rcedil":"ŗ","rceil":"⌉","rcub":"}","Rcy":"Р","rcy":"р","rdca":"⤷","rdldhar":"⥩","rdquo":"”","rdquor":"”","rdsh":"↳","real":"ℜ","realine":"ℛ","realpart":"ℜ","reals":"ℝ","Re":"ℜ","rect":"▭","reg":"®","REG":"®","ReverseElement":"∋","ReverseEquilibrium":"⇋","ReverseUpEquilibrium":"⥯","rfisht":"⥽","rfloor":"⌋","rfr":"𝔯","Rfr":"ℜ","rHar":"⥤","rhard":"⇁","rharu":"⇀","rharul":"⥬","Rho":"Ρ","rho":"ρ","rhov":"ϱ","RightAngleBracket":"⟩","RightArrowBar":"⇥","rightarrow":"→","RightArrow":"→","Rightarrow":"⇒","RightArrowLeftArrow":"⇄","rightarrowtail":"↣","RightCeiling":"⌉","RightDoubleBracket":"⟧","RightDownTeeVector":"⥝","RightDownVectorBar":"⥕","RightDownVector":"⇂","RightFloor":"⌋","rightharpoondown":"⇁","rightharpoonup":"⇀","rightleftarrows":"⇄","rightleftharpoons":"⇌","rightrightarrows":"⇉","rightsquigarrow":"↝","RightTeeArrow":"↦","RightTee":"⊢","RightTeeVector":"⥛","rightthreetimes":"⋌","RightTriangleBar":"⧐","RightTriangle":"⊳","RightTriangleEqual":"⊵","RightUpDownVector":"⥏","RightUpTeeVector":"⥜","RightUpVectorBar":"⥔","RightUpVector":"↾","RightVectorBar":"⥓","RightVector":"⇀","ring":"˚","risingdotseq":"≓","rlarr":"⇄","rlhar":"⇌","rlm":"‏","rmoustache":"⎱","rmoust":"⎱","rnmid":"⫮","roang":"⟭","roarr":"⇾","robrk":"⟧","ropar":"⦆","ropf":"𝕣","Ropf":"ℝ","roplus":"⨮","rotimes":"⨵","RoundImplies":"⥰","rpar":")","rpargt":"⦔","rppolint":"⨒","rrarr":"⇉","Rrightarrow":"⇛","rsaquo":"›","rscr":"𝓇","Rscr":"ℛ","rsh":"↱","Rsh":"↱","rsqb":"]","rsquo":"’","rsquor":"’","rthree":"⋌","rtimes":"⋊","rtri":"▹","rtrie":"⊵","rtrif":"▸","rtriltri":"⧎","RuleDelayed":"⧴","ruluhar":"⥨","rx":"℞","Sacute":"Ś","sacute":"ś","sbquo":"‚","scap":"⪸","Scaron":"Š","scaron":"š","Sc":"⪼","sc":"≻","sccue":"≽","sce":"⪰","scE":"⪴","Scedil":"Ş","scedil":"ş","Scirc":"Ŝ","scirc":"ŝ","scnap":"⪺","scnE":"⪶","scnsim":"⋩","scpolint":"⨓","scsim":"≿","Scy":"С","scy":"с","sdotb":"⊡","sdot":"⋅","sdote":"⩦","searhk":"⤥","searr":"↘","seArr":"⇘","searrow":"↘","sect":"§","semi":";","seswar":"⤩","setminus":"∖","setmn":"∖","sext":"✶","Sfr":"𝔖","sfr":"𝔰","sfrown":"⌢","sharp":"♯","SHCHcy":"Щ","shchcy":"щ","SHcy":"Ш","shcy":"ш","ShortDownArrow":"↓","ShortLeftArrow":"←","shortmid":"∣","shortparallel":"∥","ShortRightArrow":"→","ShortUpArrow":"↑","shy":"­","Sigma":"Σ","sigma":"σ","sigmaf":"ς","sigmav":"ς","sim":"∼","simdot":"⩪","sime":"≃","simeq":"≃","simg":"⪞","simgE":"⪠","siml":"⪝","simlE":"⪟","simne":"≆","simplus":"⨤","simrarr":"⥲","slarr":"←","SmallCircle":"∘","smallsetminus":"∖","smashp":"⨳","smeparsl":"⧤","smid":"∣","smile":"⌣","smt":"⪪","smte":"⪬","smtes":"⪬︀","SOFTcy":"Ь","softcy":"ь","solbar":"⌿","solb":"⧄","sol":"/","Sopf":"𝕊","sopf":"𝕤","spades":"♠","spadesuit":"♠","spar":"∥","sqcap":"⊓","sqcaps":"⊓︀","sqcup":"⊔","sqcups":"⊔︀","Sqrt":"√","sqsub":"⊏","sqsube":"⊑","sqsubset":"⊏","sqsubseteq":"⊑","sqsup":"⊐","sqsupe":"⊒","sqsupset":"⊐","sqsupseteq":"⊒","square":"□","Square":"□","SquareIntersection":"⊓","SquareSubset":"⊏","SquareSubsetEqual":"⊑","SquareSuperset":"⊐","SquareSupersetEqual":"⊒","SquareUnion":"⊔","squarf":"▪","squ":"□","squf":"▪","srarr":"→","Sscr":"𝒮","sscr":"𝓈","ssetmn":"∖","ssmile":"⌣","sstarf":"⋆","Star":"⋆","star":"☆","starf":"★","straightepsilon":"ϵ","straightphi":"ϕ","strns":"¯","sub":"⊂","Sub":"⋐","subdot":"⪽","subE":"⫅","sube":"⊆","subedot":"⫃","submult":"⫁","subnE":"⫋","subne":"⊊","subplus":"⪿","subrarr":"⥹","subset":"⊂","Subset":"⋐","subseteq":"⊆","subseteqq":"⫅","SubsetEqual":"⊆","subsetneq":"⊊","subsetneqq":"⫋","subsim":"⫇","subsub":"⫕","subsup":"⫓","succapprox":"⪸","succ":"≻","succcurlyeq":"≽","Succeeds":"≻","SucceedsEqual":"⪰","SucceedsSlantEqual":"≽","SucceedsTilde":"≿","succeq":"⪰","succnapprox":"⪺","succneqq":"⪶","succnsim":"⋩","succsim":"≿","SuchThat":"∋","sum":"∑","Sum":"∑","sung":"♪","sup1":"¹","sup2":"²","sup3":"³","sup":"⊃","Sup":"⋑","supdot":"⪾","supdsub":"⫘","supE":"⫆","supe":"⊇","supedot":"⫄","Superset":"⊃","SupersetEqual":"⊇","suphsol":"⟉","suphsub":"⫗","suplarr":"⥻","supmult":"⫂","supnE":"⫌","supne":"⊋","supplus":"⫀","supset":"⊃","Supset":"⋑","supseteq":"⊇","supseteqq":"⫆","supsetneq":"⊋","supsetneqq":"⫌","supsim":"⫈","supsub":"⫔","supsup":"⫖","swarhk":"⤦","swarr":"↙","swArr":"⇙","swarrow":"↙","swnwar":"⤪","szlig":"ß","Tab":"\\t","target":"⌖","Tau":"Τ","tau":"τ","tbrk":"⎴","Tcaron":"Ť","tcaron":"ť","Tcedil":"Ţ","tcedil":"ţ","Tcy":"Т","tcy":"т","tdot":"⃛","telrec":"⌕","Tfr":"𝔗","tfr":"𝔱","there4":"∴","therefore":"∴","Therefore":"∴","Theta":"Θ","theta":"θ","thetasym":"ϑ","thetav":"ϑ","thickapprox":"≈","thicksim":"∼","ThickSpace":"  ","ThinSpace":" ","thinsp":" ","thkap":"≈","thksim":"∼","THORN":"Þ","thorn":"þ","tilde":"˜","Tilde":"∼","TildeEqual":"≃","TildeFullEqual":"≅","TildeTilde":"≈","timesbar":"⨱","timesb":"⊠","times":"×","timesd":"⨰","tint":"∭","toea":"⤨","topbot":"⌶","topcir":"⫱","top":"⊤","Topf":"𝕋","topf":"𝕥","topfork":"⫚","tosa":"⤩","tprime":"‴","trade":"™","TRADE":"™","triangle":"▵","triangledown":"▿","triangleleft":"◃","trianglelefteq":"⊴","triangleq":"≜","triangleright":"▹","trianglerighteq":"⊵","tridot":"◬","trie":"≜","triminus":"⨺","TripleDot":"⃛","triplus":"⨹","trisb":"⧍","tritime":"⨻","trpezium":"⏢","Tscr":"𝒯","tscr":"𝓉","TScy":"Ц","tscy":"ц","TSHcy":"Ћ","tshcy":"ћ","Tstrok":"Ŧ","tstrok":"ŧ","twixt":"≬","twoheadleftarrow":"↞","twoheadrightarrow":"↠","Uacute":"Ú","uacute":"ú","uarr":"↑","Uarr":"↟","uArr":"⇑","Uarrocir":"⥉","Ubrcy":"Ў","ubrcy":"ў","Ubreve":"Ŭ","ubreve":"ŭ","Ucirc":"Û","ucirc":"û","Ucy":"У","ucy":"у","udarr":"⇅","Udblac":"Ű","udblac":"ű","udhar":"⥮","ufisht":"⥾","Ufr":"𝔘","ufr":"𝔲","Ugrave":"Ù","ugrave":"ù","uHar":"⥣","uharl":"↿","uharr":"↾","uhblk":"▀","ulcorn":"⌜","ulcorner":"⌜","ulcrop":"⌏","ultri":"◸","Umacr":"Ū","umacr":"ū","uml":"¨","UnderBar":"_","UnderBrace":"⏟","UnderBracket":"⎵","UnderParenthesis":"⏝","Union":"⋃","UnionPlus":"⊎","Uogon":"Ų","uogon":"ų","Uopf":"𝕌","uopf":"𝕦","UpArrowBar":"⤒","uparrow":"↑","UpArrow":"↑","Uparrow":"⇑","UpArrowDownArrow":"⇅","updownarrow":"↕","UpDownArrow":"↕","Updownarrow":"⇕","UpEquilibrium":"⥮","upharpoonleft":"↿","upharpoonright":"↾","uplus":"⊎","UpperLeftArrow":"↖","UpperRightArrow":"↗","upsi":"υ","Upsi":"ϒ","upsih":"ϒ","Upsilon":"Υ","upsilon":"υ","UpTeeArrow":"↥","UpTee":"⊥","upuparrows":"⇈","urcorn":"⌝","urcorner":"⌝","urcrop":"⌎","Uring":"Ů","uring":"ů","urtri":"◹","Uscr":"𝒰","uscr":"𝓊","utdot":"⋰","Utilde":"Ũ","utilde":"ũ","utri":"▵","utrif":"▴","uuarr":"⇈","Uuml":"Ü","uuml":"ü","uwangle":"⦧","vangrt":"⦜","varepsilon":"ϵ","varkappa":"ϰ","varnothing":"∅","varphi":"ϕ","varpi":"ϖ","varpropto":"∝","varr":"↕","vArr":"⇕","varrho":"ϱ","varsigma":"ς","varsubsetneq":"⊊︀","varsubsetneqq":"⫋︀","varsupsetneq":"⊋︀","varsupsetneqq":"⫌︀","vartheta":"ϑ","vartriangleleft":"⊲","vartriangleright":"⊳","vBar":"⫨","Vbar":"⫫","vBarv":"⫩","Vcy":"В","vcy":"в","vdash":"⊢","vDash":"⊨","Vdash":"⊩","VDash":"⊫","Vdashl":"⫦","veebar":"⊻","vee":"∨","Vee":"⋁","veeeq":"≚","vellip":"⋮","verbar":"|","Verbar":"‖","vert":"|","Vert":"‖","VerticalBar":"∣","VerticalLine":"|","VerticalSeparator":"❘","VerticalTilde":"≀","VeryThinSpace":" ","Vfr":"𝔙","vfr":"𝔳","vltri":"⊲","vnsub":"⊂⃒","vnsup":"⊃⃒","Vopf":"𝕍","vopf":"𝕧","vprop":"∝","vrtri":"⊳","Vscr":"𝒱","vscr":"𝓋","vsubnE":"⫋︀","vsubne":"⊊︀","vsupnE":"⫌︀","vsupne":"⊋︀","Vvdash":"⊪","vzigzag":"⦚","Wcirc":"Ŵ","wcirc":"ŵ","wedbar":"⩟","wedge":"∧","Wedge":"⋀","wedgeq":"≙","weierp":"℘","Wfr":"𝔚","wfr":"𝔴","Wopf":"𝕎","wopf":"𝕨","wp":"℘","wr":"≀","wreath":"≀","Wscr":"𝒲","wscr":"𝓌","xcap":"⋂","xcirc":"◯","xcup":"⋃","xdtri":"▽","Xfr":"𝔛","xfr":"𝔵","xharr":"⟷","xhArr":"⟺","Xi":"Ξ","xi":"ξ","xlarr":"⟵","xlArr":"⟸","xmap":"⟼","xnis":"⋻","xodot":"⨀","Xopf":"𝕏","xopf":"𝕩","xoplus":"⨁","xotime":"⨂","xrarr":"⟶","xrArr":"⟹","Xscr":"𝒳","xscr":"𝓍","xsqcup":"⨆","xuplus":"⨄","xutri":"△","xvee":"⋁","xwedge":"⋀","Yacute":"Ý","yacute":"ý","YAcy":"Я","yacy":"я","Ycirc":"Ŷ","ycirc":"ŷ","Ycy":"Ы","ycy":"ы","yen":"¥","Yfr":"𝔜","yfr":"𝔶","YIcy":"Ї","yicy":"ї","Yopf":"𝕐","yopf":"𝕪","Yscr":"𝒴","yscr":"𝓎","YUcy":"Ю","yucy":"ю","yuml":"ÿ","Yuml":"Ÿ","Zacute":"Ź","zacute":"ź","Zcaron":"Ž","zcaron":"ž","Zcy":"З","zcy":"з","Zdot":"Ż","zdot":"ż","zeetrf":"ℨ","ZeroWidthSpace":"​","Zeta":"Ζ","zeta":"ζ","zfr":"𝔷","Zfr":"ℨ","ZHcy":"Ж","zhcy":"ж","zigrarr":"⇝","zopf":"𝕫","Zopf":"ℤ","Zscr":"𝒵","zscr":"𝓏","zwj":"‍","zwnj":"‌"}')},function(t,e,r){"use strict";e.parseLinkLabel=r(81),e.parseLinkDestination=r(82),e.parseLinkTitle=r(83)},function(t,e,r){"use strict";t.exports=function(t,e,r){var n,o,i,s,a=-1,c=t.posMax,l=t.pos;for(t.pos=e+1,n=1;t.pos32)return a;if(41===o){if(0===i)break;i--}e++}return s===e||0!==i||(a.str=n(t.slice(s,e)),a.lines=0,a.pos=e,a.ok=!0),a}},function(t,e,r){"use strict";var n=r(1).unescapeAll;t.exports=function(t,e,r){var o,i,s=0,a=e,c={ok:!1,pos:0,lines:0,str:""};if(e>=r)return c;if(34!==(i=t.charCodeAt(e))&&39!==i&&40!==i)return c;for(e++,40===i&&(i=41);e"+i(t[e].content)+""},s.code_block=function(t,e,r,n,o){var s=t[e];return""+i(t[e].content)+"\n"},s.fence=function(t,e,r,n,s){var a,c,l,u,p,h=t[e],f=h.info?o(h.info).trim():"",d="",m="";return f&&(d=(l=f.split(/(\s+)/g))[0],m=l.slice(2).join("")),0===(a=r.highlight&&r.highlight(h.content,d,m)||i(h.content)).indexOf(""+a+"\n"):"
"+a+"
\n"},s.image=function(t,e,r,n,o){var i=t[e];return i.attrs[i.attrIndex("alt")][1]=o.renderInlineAsText(i.children,r,n),o.renderToken(t,e,r)},s.hardbreak=function(t,e,r){return r.xhtmlOut?"
\n":"
\n"},s.softbreak=function(t,e,r){return r.breaks?r.xhtmlOut?"
\n":"
\n":"\n"},s.text=function(t,e){return i(t[e].content)},s.html_block=function(t,e){return t[e].content},s.html_inline=function(t,e){return t[e].content},a.prototype.renderAttrs=function(t){var e,r,n;if(!t.attrs)return"";for(n="",e=0,r=t.attrs.length;e\n":">")},a.prototype.renderInline=function(t,e,r){for(var n,o="",i=this.rules,s=0,a=t.length;s/i.test(t)}t.exports=function(t){var e,r,i,s,a,c,l,u,p,h,f,d,m,g,v,y,b,k,_=t.tokens;if(t.md.options.linkify)for(r=0,i=_.length;r=0;e--)if("link_close"!==(c=s[e]).type){if("html_inline"===c.type&&(k=c.content,/^\s]/i.test(k)&&m>0&&m--,o(c.content)&&m++),!(m>0)&&"text"===c.type&&t.md.linkify.test(c.content)){for(p=c.content,b=t.md.linkify.match(p),l=[],d=c.level,f=0,u=0;uf&&((a=new t.Token("text","",0)).content=p.slice(f,h),a.level=d,l.push(a)),(a=new t.Token("link_open","a",1)).attrs=[["href",v]],a.level=d++,a.markup="linkify",a.info="auto",l.push(a),(a=new t.Token("text","",0)).content=y,a.level=d,l.push(a),(a=new t.Token("link_close","a",-1)).level=--d,a.markup="linkify",a.info="auto",l.push(a),f=b[u].lastIndex);f=0;e--)"text"!==(r=t[e]).type||n||(r.content=r.content.replace(i,a)),"link_open"===r.type&&"auto"===r.info&&n--,"link_close"===r.type&&"auto"===r.info&&n++}function l(t){var e,r,o=0;for(e=t.length-1;e>=0;e--)"text"!==(r=t[e]).type||o||n.test(r.content)&&(r.content=r.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")),"link_open"===r.type&&"auto"===r.info&&o--,"link_close"===r.type&&"auto"===r.info&&o++}t.exports=function(t){var e;if(t.md.options.typographer)for(e=t.tokens.length-1;e>=0;e--)"inline"===t.tokens[e].type&&(o.test(t.tokens[e].content)&&c(t.tokens[e].children),n.test(t.tokens[e].content)&&l(t.tokens[e].children))}},function(t,e,r){"use strict";var n=r(1).isWhiteSpace,o=r(1).isPunctChar,i=r(1).isMdAsciiPunct,s=/['"]/,a=/['"]/g;function c(t,e,r){return t.substr(0,e)+r+t.substr(e+1)}function l(t,e){var r,s,l,u,p,h,f,d,m,g,v,y,b,k,_,w,x,C,S,A,E;for(S=[],r=0;r=0&&!(S[x].level<=f);x--);if(S.length=x+1,"text"===s.type){p=0,h=(l=s.content).length;t:for(;p=0)m=l.charCodeAt(u.index-1);else for(x=r-1;x>=0&&("softbreak"!==t[x].type&&"hardbreak"!==t[x].type);x--)if(t[x].content){m=t[x].content.charCodeAt(t[x].content.length-1);break}if(g=32,p=48&&m<=57&&(w=_=!1),_&&w&&(_=v,w=y),_||w){if(w)for(x=S.length-1;x>=0&&(d=S[x],!(S[x].level=0;e--)"inline"===t.tokens[e].type&&s.test(t.tokens[e].content)&&l(t.tokens[e].children,t)}},function(t,e,r){"use strict";var n=r(10);function o(t,e,r){this.src=t,this.env=r,this.tokens=[],this.inlineMode=!1,this.md=e}o.prototype.Token=n,t.exports=o},function(t,e,r){"use strict";var n=r(9),o=[["table",r(94),["paragraph","reference"]],["code",r(95)],["fence",r(96),["paragraph","reference","blockquote","list"]],["blockquote",r(97),["paragraph","reference","blockquote","list"]],["hr",r(98),["paragraph","reference","blockquote","list"]],["list",r(99),["paragraph","reference","blockquote"]],["reference",r(100)],["heading",r(101),["paragraph","reference","blockquote"]],["lheading",r(102)],["html_block",r(103),["paragraph","reference","blockquote"]],["paragraph",r(105)]];function i(){this.ruler=new n;for(var t=0;t=r))&&!(t.sCount[s]=c){t.line=r;break}for(n=0;nr)return!1;if(h=e+1,t.sCount[h]=4)return!1;if((l=t.bMarks[h]+t.tShift[h])>=t.eMarks[h])return!1;if(124!==(a=t.src.charCodeAt(l++))&&45!==a&&58!==a)return!1;for(;l=4)return!1;if((f=i(c)).length&&""===f[0]&&f.shift(),f.length&&""===f[f.length-1]&&f.pop(),0===(d=f.length)||d!==g.length)return!1;if(s)return!0;for(k=t.parentType,t.parentType="table",w=t.md.block.ruler.getRules("blockquote"),(m=t.push("table_open","table",1)).map=y=[e,0],(m=t.push("thead_open","thead",1)).map=[e,e+1],(m=t.push("tr_open","tr",1)).map=[e,e+1],u=0;u=4)break;for((f=i(c)).length&&""===f[0]&&f.shift(),f.length&&""===f[f.length-1]&&f.pop(),h===e+2&&((m=t.push("tbody_open","tbody",1)).map=b=[e+2,0]),(m=t.push("tr_open","tr",1)).map=[h,h+1],u=0;u=4))break;o=++n}return t.line=o,(i=t.push("code_block","code",0)).content=t.getLines(e,o,4+t.blkIndent,!0),i.map=[e,t.line],!0}},function(t,e,r){"use strict";t.exports=function(t,e,r,n){var o,i,s,a,c,l,u,p=!1,h=t.bMarks[e]+t.tShift[e],f=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(h+3>f)return!1;if(126!==(o=t.src.charCodeAt(h))&&96!==o)return!1;if(c=h,(i=(h=t.skipChars(h,o))-c)<3)return!1;if(u=t.src.slice(c,h),s=t.src.slice(h,f),96===o&&s.indexOf(String.fromCharCode(o))>=0)return!1;if(n)return!0;for(a=e;!(++a>=r)&&!((h=c=t.bMarks[a]+t.tShift[a])<(f=t.eMarks[a])&&t.sCount[a]=4||(h=t.skipChars(h,o))-c=4)return!1;if(62!==t.src.charCodeAt(A++))return!1;if(o)return!0;for(c=f=t.sCount[e]+1,32===t.src.charCodeAt(A)?(A++,c++,f++,i=!1,k=!0):9===t.src.charCodeAt(A)?(k=!0,(t.bsCount[e]+f)%4==3?(A++,c++,f++,i=!1):i=!0):k=!1,d=[t.bMarks[e]],t.bMarks[e]=A;A=E,y=[t.sCount[e]],t.sCount[e]=f-c,b=[t.tShift[e]],t.tShift[e]=A-t.bMarks[e],w=t.md.block.ruler.getRules("blockquote"),v=t.parentType,t.parentType="blockquote",h=e+1;h=(E=t.eMarks[h])));h++)if(62!==t.src.charCodeAt(A++)||C){if(u)break;for(_=!1,a=0,l=w.length;a=E,m.push(t.bsCount[h]),t.bsCount[h]=t.sCount[h]+1+(k?1:0),y.push(t.sCount[h]),t.sCount[h]=f-c,b.push(t.tShift[h]),t.tShift[h]=A-t.bMarks[h]}for(g=t.blkIndent,t.blkIndent=0,(x=t.push("blockquote_open","blockquote",1)).markup=">",x.map=p=[e,0],t.md.block.tokenize(t,e,h),(x=t.push("blockquote_close","blockquote",-1)).markup=">",t.lineMax=S,t.parentType=v,p[1]=t.line,a=0;a=4)return!1;if(42!==(i=t.src.charCodeAt(l++))&&45!==i&&95!==i)return!1;for(s=1;l=s)return-1;if((r=t.src.charCodeAt(i++))<48||r>57)return-1;for(;;){if(i>=s)return-1;if(!((r=t.src.charCodeAt(i++))>=48&&r<=57)){if(41===r||46===r)break;return-1}if(i-o>=10)return-1}return i=4)return!1;if(t.listIndent>=0&&t.sCount[e]-t.listIndent>=4&&t.sCount[e]=t.blkIndent&&(N=!0),(M=i(t,e))>=0){if(h=!0,T=t.bMarks[e]+t.tShift[e],y=Number(t.src.substr(T,M-T-1)),N&&1!==y)return!1}else{if(!((M=o(t,e))>=0))return!1;h=!1}if(N&&t.skipSpaces(M)>=t.eMarks[e])return!1;if(v=t.src.charCodeAt(M-1),n)return!0;for(g=t.tokens.length,h?(z=t.push("ordered_list_open","ol",1),1!==y&&(z.attrs=[["start",y]])):z=t.push("bullet_list_open","ul",1),z.map=m=[e,0],z.markup=String.fromCharCode(v),k=e,D=!1,q=t.md.block.ruler.getRules("list"),x=t.parentType,t.parentType="list";k=b?1:_-p)>4&&(u=1),l=p+u,(z=t.push("list_item_open","li",1)).markup=String.fromCharCode(v),z.map=f=[e,0],A=t.tight,S=t.tShift[e],C=t.sCount[e],w=t.listIndent,t.listIndent=t.blkIndent,t.blkIndent=l,t.tight=!0,t.tShift[e]=a-t.bMarks[e],t.sCount[e]=_,a>=b&&t.isEmpty(e+1)?t.line=Math.min(t.line+2,r):t.md.block.tokenize(t,e,r,!0),t.tight&&!D||(I=!1),D=t.line-e>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=w,t.tShift[e]=S,t.sCount[e]=C,t.tight=A,(z=t.push("list_item_close","li",-1)).markup=String.fromCharCode(v),k=e=t.line,f[1]=k,a=t.bMarks[e],k>=r)break;if(t.sCount[k]=4)break;for(O=!1,c=0,d=q.length;c=4)return!1;if(91!==t.src.charCodeAt(x))return!1;for(;++x3||t.sCount[S]<0)){for(b=!1,p=0,h=k.length;p=4)return!1;if(35!==(i=t.src.charCodeAt(l))||l>=u)return!1;for(s=1,i=t.src.charCodeAt(++l);35===i&&l6||ll&&n(t.src.charCodeAt(a-1))&&(u=a),t.line=e+1,(c=t.push("heading_open","h"+String(s),1)).markup="########".slice(0,s),c.map=[e,t.line],(c=t.push("inline","",0)).content=t.src.slice(l,u).trim(),c.map=[e,t.line],c.children=[],(c=t.push("heading_close","h"+String(s),-1)).markup="########".slice(0,s)),!0)}},function(t,e,r){"use strict";t.exports=function(t,e,r){var n,o,i,s,a,c,l,u,p,h,f=e+1,d=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;for(h=t.parentType,t.parentType="paragraph";f3)){if(t.sCount[f]>=t.blkIndent&&(c=t.bMarks[f]+t.tShift[f])<(l=t.eMarks[f])&&(45===(p=t.src.charCodeAt(c))||61===p)&&(c=t.skipChars(c,p),(c=t.skipSpaces(c))>=l)){u=61===p?1:2;break}if(!(t.sCount[f]<0)){for(o=!1,i=0,s=d.length;i|$))/i,/<\/(script|pre|style)>/i,!0],[/^/,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp("^|$))","i"),/^$/,!0],[new RegExp(o.source+"\\s*$"),/^$/,!1]];t.exports=function(t,e,r,n){var o,s,a,c,l=t.bMarks[e]+t.tShift[e],u=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(!t.md.options.html)return!1;if(60!==t.src.charCodeAt(l))return!1;for(c=t.src.slice(l,u),o=0;o3||t.sCount[c]<0)){for(n=!1,o=0,i=l.length;o0&&this.level++,this.tokens.push(o),o},i.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]},i.prototype.skipEmptyLines=function(t){for(var e=this.lineMax;te;)if(!o(this.src.charCodeAt(--t)))return t+1;return t},i.prototype.skipChars=function(t,e){for(var r=this.src.length;tr;)if(e!==this.src.charCodeAt(--t))return t+1;return t},i.prototype.getLines=function(t,e,r,n){var i,s,a,c,l,u,p,h=t;if(t>=e)return"";for(u=new Array(e-t),i=0;hr?new Array(s-r+1).join(" ")+this.src.slice(c,l):this.src.slice(c,l)}return u.join("")},i.prototype.Token=n,t.exports=i},function(t,e,r){"use strict";var n=r(9),o=[["text",r(108)],["newline",r(109)],["escape",r(110)],["backticks",r(111)],["strikethrough",r(20).tokenize],["emphasis",r(21).tokenize],["link",r(112)],["image",r(113)],["autolink",r(114)],["html_inline",r(115)],["entity",r(116)]],i=[["balance_pairs",r(117)],["strikethrough",r(20).postProcess],["emphasis",r(21).postProcess],["text_collapse",r(118)]];function s(){var t;for(this.ruler=new n,t=0;t=i)break}else t.pending+=t.src[t.pos++]}t.pending&&t.pushPending()},s.prototype.parse=function(t,e,r,n){var o,i,s,a=new this.State(t,e,r,n);for(this.tokenize(a),s=(i=this.ruler2.getRules("")).length,o=0;o=0&&32===t.pending.charCodeAt(r)?r>=1&&32===t.pending.charCodeAt(r-1)?(t.pending=t.pending.replace(/ +$/,""),t.push("hardbreak","br",0)):(t.pending=t.pending.slice(0,-1),t.push("softbreak","br",0)):t.push("softbreak","br",0)),i++;i?@[]^_`{|}~-".split("").forEach((function(t){o[t.charCodeAt(0)]=1})),t.exports=function(t,e){var r,i=t.pos,s=t.posMax;if(92!==t.src.charCodeAt(i))return!1;if(++i=m)return!1;if(g=l,(u=t.md.helpers.parseLinkDestination(t.src,l,t.posMax)).ok){for(h=t.md.normalizeLink(u.str),t.md.validateLink(h)?l=u.pos:h="",g=l;l=m||41!==t.src.charCodeAt(l))&&(v=!0),l++}if(v){if(void 0===t.env.references)return!1;if(l=0?s=t.src.slice(g,l++):l=a+1):l=a+1,s||(s=t.src.slice(c,a)),!(p=t.env.references[n(s)]))return t.pos=d,!1;h=p.href,f=p.title}return e||(t.pos=c,t.posMax=a,t.push("link_open","a",1).attrs=r=[["href",h]],f&&r.push(["title",f]),t.md.inline.tokenize(t),t.push("link_close","a",-1)),t.pos=l,t.posMax=m,!0}},function(t,e,r){"use strict";var n=r(1).normalizeReference,o=r(1).isSpace;t.exports=function(t,e){var r,i,s,a,c,l,u,p,h,f,d,m,g,v="",y=t.pos,b=t.posMax;if(33!==t.src.charCodeAt(t.pos))return!1;if(91!==t.src.charCodeAt(t.pos+1))return!1;if(l=t.pos+2,(c=t.md.helpers.parseLinkLabel(t,t.pos+1,!1))<0)return!1;if((u=c+1)=b)return!1;for(g=u,(h=t.md.helpers.parseLinkDestination(t.src,u,t.posMax)).ok&&(v=t.md.normalizeLink(h.str),t.md.validateLink(v)?u=h.pos:v=""),g=u;u=b||41!==t.src.charCodeAt(u))return t.pos=y,!1;u++}else{if(void 0===t.env.references)return!1;if(u=0?a=t.src.slice(g,u++):u=c+1):u=c+1,a||(a=t.src.slice(l,c)),!(p=t.env.references[n(a)]))return t.pos=y,!1;v=p.href,f=p.title}return e||(s=t.src.slice(l,c),t.md.inline.parse(s,t.md,t.env,m=[]),(d=t.push("image","img",0)).attrs=r=[["src",v],["alt",""]],d.children=m,d.content=s,f&&r.push(["title",f])),t.pos=u,t.posMax=b,!0}},function(t,e,r){"use strict";var n=/^([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])?)*)$/,o=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;t.exports=function(t,e){var r,i,s,a,c,l,u=t.pos;if(60!==t.src.charCodeAt(u))return!1;for(c=t.pos,l=t.posMax;;){if(++u>=l)return!1;if(60===(a=t.src.charCodeAt(u)))return!1;if(62===a)break}return r=t.src.slice(c+1,u),o.test(r)?(i=t.md.normalizeLink(r),!!t.md.validateLink(i)&&(e||((s=t.push("link_open","a",1)).attrs=[["href",i]],s.markup="autolink",s.info="auto",(s=t.push("text","",0)).content=t.md.normalizeLinkText(r),(s=t.push("link_close","a",-1)).markup="autolink",s.info="auto"),t.pos+=r.length+2,!0)):!!n.test(r)&&(i=t.md.normalizeLink("mailto:"+r),!!t.md.validateLink(i)&&(e||((s=t.push("link_open","a",1)).attrs=[["href",i]],s.markup="autolink",s.info="auto",(s=t.push("text","",0)).content=t.md.normalizeLinkText(r),(s=t.push("link_close","a",-1)).markup="autolink",s.info="auto"),t.pos+=r.length+2,!0))}},function(t,e,r){"use strict";var n=r(19).HTML_TAG_RE;t.exports=function(t,e){var r,o,i,s=t.pos;return!!t.md.options.html&&(i=t.posMax,!(60!==t.src.charCodeAt(s)||s+2>=i)&&(!(33!==(r=t.src.charCodeAt(s+1))&&63!==r&&47!==r&&!function(t){var e=32|t;return e>=97&&e<=122}(r))&&(!!(o=t.src.slice(s).match(n))&&(e||(t.push("html_inline","",0).content=t.src.slice(s,s+o[0].length)),t.pos+=o[0].length,!0))))}},function(t,e,r){"use strict";var n=r(18),o=r(1).has,i=r(1).isValidEntityCode,s=r(1).fromCodePoint,a=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,c=/^&([a-z][a-z0-9]{1,31});/i;t.exports=function(t,e){var r,l,u=t.pos,p=t.posMax;if(38!==t.src.charCodeAt(u))return!1;if(u+1s;n-=i.jump+1)if((i=e[n]).marker===o.marker&&i.open&&i.end<0&&(c=!1,(i.close||o.open)&&(i.length+o.length)%3==0&&(i.length%3==0&&o.length%3==0||(c=!0)),!c)){l=n>0&&!e[n-1].open?e[n-1].jump+1:0,o.jump=r-n+l,o.open=!1,i.end=r,i.jump=l,i.close=!1,a=-1;break}-1!==a&&(u[o.marker][(o.length||0)%3]=a)}}t.exports=function(t){var e,r=t.tokens_meta,o=t.tokens_meta.length;for(n(0,t.delimiters),e=0;e0&&n++,"text"===o[e].type&&e+10&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(o),this.tokens_meta.push(i),o},a.prototype.scanDelims=function(t,e){var r,n,a,c,l,u,p,h,f,d=t,m=!0,g=!0,v=this.posMax,y=this.src.charCodeAt(t);for(r=t>0?this.src.charCodeAt(t-1):32;d=3&&":"===t[e-3]||e>=3&&"/"===t[e-3]?0:n.match(r.re.no_http)[0].length:0}},"mailto:":{validate:function(t,e,r){var n=t.slice(e);return r.re.mailto||(r.re.mailto=new RegExp("^"+r.re.src_email_name+"@"+r.re.src_host_strict,"i")),r.re.mailto.test(n)?n.match(r.re.mailto)[0].length:0}}},l="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function u(t){var e=t.re=r(121)(t.__opts__),n=t.__tlds__.slice();function a(t){return t.replace("%TLDS%",e.src_tlds)}t.onCompile(),t.__tlds_replaced__||n.push("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]"),n.push(e.src_xn),e.src_tlds=n.join("|"),e.email_fuzzy=RegExp(a(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(a(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(a(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(a(e.tpl_host_fuzzy_test),"i");var c=[];function l(t,e){throw new Error('(LinkifyIt) Invalid schema "'+t+'": '+e)}t.__compiled__={},Object.keys(t.__schemas__).forEach((function(e){var r=t.__schemas__[e];if(null!==r){var n={validate:null,link:null};if(t.__compiled__[e]=n,"[object Object]"===o(r))return!function(t){return"[object RegExp]"===o(t)}(r.validate)?i(r.validate)?n.validate=r.validate:l(e,r):n.validate=function(t){return function(e,r){var n=e.slice(r);return t.test(n)?n.match(t)[0].length:0}}(r.validate),void(i(r.normalize)?n.normalize=r.normalize:r.normalize?l(e,r):n.normalize=function(t,e){e.normalize(t)});!function(t){return"[object String]"===o(t)}(r)?l(e,r):c.push(e)}})),c.forEach((function(e){t.__compiled__[t.__schemas__[e]]&&(t.__compiled__[e].validate=t.__compiled__[t.__schemas__[e]].validate,t.__compiled__[e].normalize=t.__compiled__[t.__schemas__[e]].normalize)})),t.__compiled__[""]={validate:null,normalize:function(t,e){e.normalize(t)}};var u=Object.keys(t.__compiled__).filter((function(e){return e.length>0&&t.__compiled__[e]})).map(s).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+u+")","i"),t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+u+")","ig"),t.re.pretest=RegExp("("+t.re.schema_test.source+")|("+t.re.host_fuzzy_test.source+")|@","i"),function(t){t.__index__=-1,t.__text_cache__=""}(t)}function p(t,e){var r=t.__index__,n=t.__last_index__,o=t.__text_cache__.slice(r,n);this.schema=t.__schema__.toLowerCase(),this.index=r+e,this.lastIndex=n+e,this.raw=o,this.text=o,this.url=o}function h(t,e){var r=new p(t,e);return t.__compiled__[r.schema].normalize(r,t),r}function f(t,e){if(!(this instanceof f))return new f(t,e);var r;e||(r=t,Object.keys(r||{}).reduce((function(t,e){return t||a.hasOwnProperty(e)}),!1)&&(e=t,t={})),this.__opts__=n({},a,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=n({},c,t),this.__compiled__={},this.__tlds__=l,this.__tlds_replaced__=!1,this.re={},u(this)}f.prototype.add=function(t,e){return this.__schemas__[t]=e,u(this),this},f.prototype.set=function(t){return this.__opts__=n(this.__opts__,t),this},f.prototype.test=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return!1;var e,r,n,o,i,s,a,c;if(this.re.schema_test.test(t))for((a=this.re.schema_search).lastIndex=0;null!==(e=a.exec(t));)if(o=this.testSchemaAt(t,e[2],a.lastIndex)){this.__schema__=e[2],this.__index__=e.index+e[1].length,this.__last_index__=e.index+e[0].length+o;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(c=t.search(this.re.host_fuzzy_test))>=0&&(this.__index__<0||c=0&&null!==(n=t.match(this.re.email_fuzzy))&&(i=n.index+n[1].length,s=n.index+n[0].length,(this.__index__<0||ithis.__last_index__)&&(this.__schema__="mailto:",this.__index__=i,this.__last_index__=s)),this.__index__>=0},f.prototype.pretest=function(t){return this.re.pretest.test(t)},f.prototype.testSchemaAt=function(t,e,r){return this.__compiled__[e.toLowerCase()]?this.__compiled__[e.toLowerCase()].validate(t,r,this):0},f.prototype.match=function(t){var e=0,r=[];this.__index__>=0&&this.__text_cache__===t&&(r.push(h(this,e)),e=this.__last_index__);for(var n=e?t.slice(e):t;this.test(n);)r.push(h(this,e)),n=n.slice(this.__last_index__),e+=this.__last_index__;return r.length?r:null},f.prototype.tlds=function(t,e){return t=Array.isArray(t)?t:[t],e?(this.__tlds__=this.__tlds__.concat(t).sort().filter((function(t,e,r){return t!==r[e-1]})).reverse(),u(this),this):(this.__tlds__=t.slice(),this.__tlds_replaced__=!0,u(this),this)},f.prototype.normalize=function(t){t.schema||(t.url="http://"+t.url),"mailto:"!==t.schema||/^mailto:/i.test(t.url)||(t.url="mailto:"+t.url)},f.prototype.onCompile=function(){},t.exports=f},function(t,e,r){"use strict";t.exports=function(t){var e={};e.src_Any=r(4).source,e.src_Cc=r(5).source,e.src_Z=r(6).source,e.src_P=r(2).source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");return e.src_pseudo_letter="(?:(?![><|]|"+e.src_ZPCc+")"+e.src_Any+")",e.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]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|[><|]|"+e.src_ZPCc+")(?!-|_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|[><|]|[()[\\]{}.,\"'?!\\-]).|\\[(?:(?!"+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+'|["]).)+\\"|\\\'(?:(?!'+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-]).|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+e.src_ZCc+"|[.]).|"+(t&&t["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+"\\,(?!"+e.src_ZCc+").|\\!+(?!"+e.src_ZCc+"|[!]).|\\?(?!"+e.src_ZCc+"|[?]).)+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy='(^|[><|]|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}},function(t,e,r){"use strict";t.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}}},function(t,e,r){"use strict";t.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","text_collapse"]}}}},function(t,e,r){"use strict";t.exports={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","text_collapse"]}}}},function(t,e,r){"use strict";function n(t){this.content=t}r.r(e),n.prototype={constructor:n,find:function(t){for(var e=0;e>1}},n.from=function(t){if(t instanceof n)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new n(e)};var o=n;function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var s=function(t,e){if(this.content=t,this.size=e||0,null==e)for(var r=0;rt&&!1!==r(a,n+s,o,i)&&a.content.size){var l=s+1;a.nodesBetween(Math.max(0,t-l),Math.min(a.content.size,e-l),r,n+l)}s=c}},s.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},s.prototype.textBetween=function(t,e,r,n){var o="",i=!0;return this.nodesBetween(t,e,(function(s,a){s.isText?(o+=s.text.slice(Math.max(t,a)-a,e-a),i=!r):s.isLeaf&&n?(o+=n,i=!r):!i&&s.isBlock&&(o+=r,i=!0)}),0),o},s.prototype.append=function(t){if(!t.size)return this;if(!this.size)return t;var e=this.lastChild,r=t.firstChild,n=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(r)&&(n[n.length-1]=e.withText(e.text+r.text),o=1);ot)for(var o=0,i=0;it&&((ie)&&(a=a.isText?a.cut(Math.max(0,t-i),Math.min(a.text.length,e-i)):a.cut(Math.max(0,t-i-1),Math.min(a.content.size,e-i-1))),r.push(a),n+=a.nodeSize),i=c}return new s(r,n)},s.prototype.cutByIndex=function(t,e){return t==e?s.empty:0==t&&e==this.content.length?this:new s(this.content.slice(t,e))},s.prototype.replaceChild=function(t,e){var r=this.content[t];if(r==e)return this;var n=this.content.slice(),o=this.size+e.nodeSize-r.nodeSize;return n[t]=e,new s(n,o)},s.prototype.addToStart=function(t){return new s([t].concat(this.content),this.size+t.nodeSize)},s.prototype.addToEnd=function(t){return new s(this.content.concat(t),this.size+t.nodeSize)},s.prototype.eq=function(t){if(this.content.length!=t.content.length)return!1;for(var e=0;ethis.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var r=0,n=0;;r++){var o=n+this.child(r).nodeSize;if(o>=t)return o==t||e>0?l(r+1,o):l(r,n);n=o}},s.prototype.toString=function(){return"<"+this.toStringInner()+">"},s.prototype.toStringInner=function(){return this.content.join(", ")},s.prototype.toJSON=function(){return this.content.length?this.content.map((function(t){return t.toJSON()})):null},s.fromJSON=function(t,e){if(!e)return s.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new s(e.map(t.nodeFromJSON))},s.fromArray=function(t){if(!t.length)return s.empty;for(var e,r=0,n=0;nthis.type.rank&&(e||(e=t.slice(0,n)),e.push(this),r=!0),e&&e.push(o)}}return e||(e=t.slice()),r||e.push(this),e},p.prototype.removeFromSet=function(t){for(var e=0;et.depth)throw new h("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new h("Inconsistent open depths");return function t(e,r,n,o){var i=e.index(o),a=e.node(o);if(i==r.index(o)&&o=0;o--)n=e.node(o).copy(s.from(n));return{start:n.resolveNoCache(t.openStart+r),end:n.resolveNoCache(n.content.size-t.openEnd-r)}}(n,e),u=l.start,p=l.end;return k(a,function t(e,r,n,o,i){var a=e.depth>i&&v(e,r,i+1),c=o.depth>i&&v(n,o,i+1),l=[];b(null,e,i,l),a&&c&&r.index(i)==n.index(i)?(g(a,c),y(k(a,t(e,r,n,o,i+1)),l)):(a&&y(k(a,_(e,r,i+1)),l),b(r,n,i,l),c&&y(k(c,_(n,o,i+1)),l));return b(o,null,i,l),new s(l)}(e,u,p,r,o))}var h=e.parent,f=h.content;return k(h,f.cut(0,e.parentOffset).append(n.content).append(f.cut(r.parentOffset)))}return k(a,_(e,r,o))}(t,e,r,0)}function g(t,e){if(!e.type.compatibleContent(t.type))throw new h("Cannot join "+e.type.name+" onto "+t.type.name)}function v(t,e,r){var n=t.node(r);return g(n,e.node(r)),n}function y(t,e){var r=e.length-1;r>=0&&t.isText&&t.sameMarkup(e[r])?e[r]=t.withText(e[r].text+t.text):e.push(t)}function b(t,e,r,n){var o=(e||t).node(r),i=0,s=e?e.index(r):o.childCount;t&&(i=t.index(r),t.depth>r?i++:t.textOffset&&(y(t.nodeAfter,n),i++));for(var a=i;ar)&&y(k(v(t,e,r+1),_(t,e,r+1)),n);return b(e,null,r,n),new s(n)}d.size.get=function(){return this.content.size-this.openStart-this.openEnd},f.prototype.insertAt=function(t,e){var r=function t(e,r,n,o){var i=e.findIndex(r),s=i.index,a=i.offset,c=e.maybeChild(s);if(a==r||c.isText)return o&&!o.canReplace(s,s,n)?null:e.cut(0,r).append(n).append(e.cut(r));var l=t(c.content,r-a-1,n);return l&&e.replaceChild(s,c.copy(l))}(this.content,t+this.openStart,e,null);return r&&new f(r,this.openStart,this.openEnd)},f.prototype.removeBetween=function(t,e){return new f(function t(e,r,n){var o=e.findIndex(r),i=o.index,s=o.offset,a=e.maybeChild(i),c=e.findIndex(n),l=c.index,u=c.offset;if(s==r||a.isText){if(u!=n&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,r).append(e.cut(n))}if(i!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(i,a.copy(t(a.content,r-s-1,n-s-1)))}(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},f.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},f.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},f.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t},f.fromJSON=function(t,e){if(!e)return f.empty;var r=e.openStart||0,n=e.openEnd||0;if("number"!=typeof r||"number"!=typeof n)throw new RangeError("Invalid input for Slice.fromJSON");return new f(s.fromJSON(t,e.content),e.openStart||0,e.openEnd||0)},f.maxOpen=function(t,e){void 0===e&&(e=!0);for(var r=0,n=0,o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)r++;for(var i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)n++;return new f(t,r,n)},Object.defineProperties(f.prototype,d),f.empty=new f(s.empty,0,0);var w=function(t,e,r){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=r},x={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};w.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},x.parent.get=function(){return this.node(this.depth)},x.doc.get=function(){return this.node(0)},w.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},w.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},w.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},w.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},w.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},w.prototype.before=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]},w.prototype.after=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize},x.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},x.nodeAfter.get=function(){var t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;var r=this.pos-this.path[this.path.length-1],n=t.child(e);return r?t.child(e).cut(r):n},x.nodeBefore.get=function(){var t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)},w.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return p.none;if(this.textOffset)return t.child(e).marks;var r=t.maybeChild(e-1),n=t.maybeChild(e);if(!r){var o=r;r=n,n=o}for(var i=r.marks,s=0;s0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0},w.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.pos=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new E(this,t,r)},w.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},w.prototype.max=function(t){return t.pos>this.pos?t:this},w.prototype.min=function(t){return t.pos=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");for(var r=[],n=0,o=e,i=t;;){var s=i.content.findIndex(o),a=s.index,c=s.offset,l=o-c;if(r.push(i,a,n+c),!l)break;if((i=i.child(a)).isText)break;o=l-1,n+=c+1}return new w(e,r,o)},w.resolveCached=function(t,e){for(var r=0;rt&&this.nodesBetween(t,e,(function(t){return r.isInSet(t.marks)&&(n=!0),!n})),n},O.isBlock.get=function(){return this.type.isBlock},O.isTextblock.get=function(){return this.type.isTextblock},O.inlineContent.get=function(){return this.type.inlineContent},O.isInline.get=function(){return this.type.isInline},O.isText.get=function(){return this.type.isText},O.isLeaf.get=function(){return this.type.isLeaf},O.isAtom.get=function(){return this.type.isAtom},T.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),z(this.marks,t)},T.prototype.contentMatchAt=function(t){var e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e},T.prototype.canReplace=function(t,e,r,n,o){void 0===r&&(r=s.empty),void 0===n&&(n=0),void 0===o&&(o=r.childCount);var i=this.contentMatchAt(t).matchFragment(r,n,o),a=i&&i.matchFragment(this.content,e);if(!a||!a.validEnd)return!1;for(var c=n;c=0;r--)e=t[r].type.name+"("+e+")";return e}var N=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},I={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};N.parse=function(t,e){var r=new L(t,e);if(null==r.next)return N.empty;var n=F(r);r.next&&r.err("Unexpected trailing text");var o=function(t){var e=Object.create(null);return function r(n){var o=[];n.forEach((function(e){t[e].forEach((function(e){var r=e.term,n=e.to;if(r){var i=o.indexOf(r),s=i>-1&&o[i+1];U(t,n).forEach((function(t){s||o.push(r,s=[]),-1==s.indexOf(t)&&s.push(t)}))}}))}));for(var i=e[n.join(",")]=new N(n.indexOf(t.length-1)>-1),s=0;s>1},N.prototype.edge=function(t){var e=t<<1;if(e>=this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[e+1]}},N.prototype.toString=function(){var t=[];return function e(r){t.push(r);for(var n=1;n"+t.indexOf(e.next[o+1]);return n})).join("\n")},Object.defineProperties(N.prototype,I),N.empty=new N(!0);var L=function(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.unshift()},R={next:{configurable:!0}};function F(t){var e=[];do{e.push(P(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function P(t){var e=[];do{e.push(B(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function B(t){for(var e=function(t){if(t.eat("(")){var e=F(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){var r=function(t,e){var r=t.nodeTypes,n=r[e];if(n)return[n];var o=[];for(var i in r){var s=r[i];s.groups.indexOf(e)>-1&&o.push(s)}0==o.length&&t.err("No node type or group '"+e+"' found");return o}(t,t.next).map((function(e){return null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}}));return t.pos++,1==r.length?r[0]:{type:"choice",exprs:r}}t.err("Unexpected token '"+t.next+"'")}(t);;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=$(t,e)}return e}function V(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function $(t,e){var r=V(t),n=r;return t.eat(",")&&(n="}"!=t.next?V(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:e}}function j(t,e){return e-t}function U(t,e){var r=[];return function e(n){var o=t[n];if(1==o.length&&!o[0].term)return e(o[0].to);r.push(n);for(var i=0;i-1},Z.prototype.allowsMarks=function(t){if(null==this.markSet)return!0;for(var e=0;e-1};var X=function(t){for(var e in this.spec={},t)this.spec[e]=t[e];this.spec.nodes=o.from(t.nodes),this.spec.marks=o.from(t.marks),this.nodes=Z.compile(this.spec.nodes,this),this.marks=Q.compile(this.spec.marks,this);var r=Object.create(null);for(var n in this.nodes){if(n in this.marks)throw new RangeError(n+" can not be both a node and a mark");var i=this.nodes[n],s=i.spec.content||"",a=i.spec.marks;i.contentMatch=r[s]||(r[s]=N.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet="_"==a?null:a?tt(this,a.split(" ")):""!=a&&i.inlineContent?null:[]}for(var c in this.marks){var l=this.marks[c],u=l.spec.excludes;l.excluded=null==u?[l]:""==u?[]:tt(this,u.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached=Object.create(null),this.cached.wrappings=Object.create(null)};function tt(t,e){for(var r=[],n=0;n-1)&&r.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return r}X.prototype.node=function(t,e,r,n){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof Z))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,r,n)},X.prototype.text=function(t,e){var r=this.nodes.text;return new q(r,r.defaultAttrs,t,p.setFrom(e))},X.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},X.prototype.nodeFromJSON=function(t){return T.fromJSON(this,t)},X.prototype.markFromJSON=function(t){return p.fromJSON(this,t)},X.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var et=function(t,e){var r=this;this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((function(t){t.tag?r.tags.push(t):t.style&&r.styles.push(t)}))};et.prototype.parse=function(t,e){void 0===e&&(e={});var r=new at(this,e,!1);return r.addAll(t,null,e.from,e.to),r.finish()},et.prototype.parseSlice=function(t,e){void 0===e&&(e={});var r=new at(this,e,!0);return r.addAll(t,null,e.from,e.to),f.maxOpen(r.finish())},et.prototype.matchTag=function(t,e){for(var r=0;rt.length&&(61!=o.style.charCodeAt(t.length)||o.style.slice(t.length+1)!=e))){if(o.getAttrs){var i=o.getAttrs(e);if(!1===i)continue;o.attrs=i}return o}}},et.schemaRules=function(t){var e=[];function r(t){for(var r=null==t.priority?50:t.priority,n=0;n=0;n--){var o=this.nodes[n],i=o.findWrapping(t);if(i&&(!e||e.length>i.length)&&(e=i,r=o,!i.length))break;if(o.solid)break}if(!e)return!1;this.sync(r);for(var s=0;sthis.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}},at.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},at.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},ct.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;e>=0;e--){for(var r=this.nodes[e].content,n=r.length-1;n>=0;n--)t+=r[n].nodeSize;e&&t++}return t},at.prototype.findAtPoint=function(t,e){if(this.find)for(var r=0;r-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);var r=t.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),i=-(n?n.depth+1:0)+(o?0:1);return function t(s,a){for(;s>=0;s--){var c=r[s];if(""==c){if(s==r.length-1||0==s)continue;for(;a>=i;a--)if(t(s-1,a))return!0;return!1}var l=a>0||0==a&&o?e.nodes[a].type:n&&a>=i?n.node(a-i).type:null;if(!l||l.name!=c&&-1==l.groups.indexOf(c))return!1;a--}return!0}(r.length-1,this.open)},at.prototype.textblockFromContext=function(){var t=this.options.context;if(t)for(var e=t.depth;e>=0;e--){var r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(var n in this.parser.schema.nodes){var o=this.parser.schema.nodes[n];if(o.isTextblock&&o.defaultAttrs)return o}},at.prototype.addPendingMark=function(t){this.top.pendingMarks=t.addToSet(this.top.pendingMarks)},at.prototype.removePendingMark=function(t,e){for(var r=this.open;r>=0;r--){var n=this.nodes[r];if(n.pendingMarks.lastIndexOf(t)>-1?n.pendingMarks=t.removeFromSet(n.pendingMarks):n.activeMarks=t.removeFromSet(n.activeMarks),n==e)break}},Object.defineProperties(at.prototype,ct);var ht=function(t,e){this.nodes=t||{},this.marks=e||{}};function ft(t){var e={};for(var r in t){var n=t[r].spec.toDOM;n&&(e[r]=n)}return e}function dt(t){return t.document||window.document}ht.prototype.serializeFragment=function(t,e,r){var n=this;void 0===e&&(e={}),r||(r=dt(e).createDocumentFragment());var o=r,i=null;return t.forEach((function(t){if(i||t.marks.length){i||(i=[]);for(var r=0,s=0;r=0;n--){var o=this.serializeMark(t.marks[n],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r},ht.prototype.serializeMark=function(t,e,r){void 0===r&&(r={});var n=this.marks[t.type.name];return n&&ht.renderSpec(dt(r),n(t,e))},ht.renderSpec=function(t,e,r){if(void 0===r&&(r=null),"string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};var n=e[0],o=n.indexOf(" ");o>0&&(r=n.slice(0,o),n=n.slice(o+1));var s=null,a=r?t.createElementNS(r,n):t.createElement(n),c=e[1],l=1;if(c&&"object"==i(c)&&null==c.nodeType&&!Array.isArray(c))for(var u in l=2,c)if(null!=c[u]){var p=u.indexOf(" ");p>0?a.setAttributeNS(u.slice(0,p),u.slice(p+1),c[u]):a.setAttribute(u,c[u])}for(var h=l;hl)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}var d=ht.renderSpec(t,f,r),m=d.dom,g=d.contentDOM;if(a.appendChild(m),g){if(s)throw new RangeError("Multiple content holes");s=g}}return{dom:a,contentDOM:s}},ht.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new ht(this.nodesFromSchema(t),this.marksFromSchema(t)))},ht.nodesFromSchema=function(t){var e=ft(t.nodes);return e.text||(e.text=function(t){return t.text}),e},ht.marksFromSchema=function(t){return ft(t.marks)};var mt=Math.pow(2,16);function gt(t){return 65535&t}var vt=function(t,e,r){void 0===e&&(e=!1),void 0===r&&(r=null),this.pos=t,this.deleted=e,this.recover=r},yt=function(t,e){void 0===e&&(e=!1),this.ranges=t,this.inverted=e};yt.prototype.recover=function(t){var e=0,r=gt(t);if(!this.inverted)for(var n=0;nt)break;var c=this.ranges[s+o],l=this.ranges[s+i],u=a+c;if(t<=u){var p=a+n+((c?t==a?-1:t==u?1:e:e)<0?0:l);if(r)return p;var h=s/3+(t-a)*mt;return new vt(p,e<0?t!=a:t!=u,h)}n+=l-c}return r?t+n:new vt(t+n)},yt.prototype.touches=function(t,e){for(var r=0,n=gt(e),o=this.inverted?2:1,i=this.inverted?1:2,s=0;st)break;var c=this.ranges[s+o];if(t<=a+c&&s==3*n)return!0;r+=this.ranges[s+i]-c}return!1},yt.prototype.forEach=function(t){for(var e=this.inverted?2:1,r=this.inverted?1:2,n=0,o=0;n=0;e--){var n=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=n&&n>e?r-n-1:null)}},bt.prototype.invert=function(){var t=new bt;return t.appendMappingInverted(this),t},bt.prototype.map=function(t,e){if(void 0===e&&(e=1),this.mirror)return this._map(t,e,!0);for(var r=this.from;ri&&l0},_t.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(_t.prototype,wt);var Ct=Object.create(null),St=function(){};St.prototype.apply=function(t){return xt()},St.prototype.getMap=function(){return yt.empty},St.prototype.invert=function(t){return xt()},St.prototype.map=function(t){return xt()},St.prototype.merge=function(t){return null},St.prototype.toJSON=function(){return xt()},St.fromJSON=function(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");var r=Ct[e.stepType];if(!r)throw new RangeError("No step type "+e.stepType+" defined");return r.fromJSON(t,e)},St.jsonID=function(t,e){if(t in Ct)throw new RangeError("Duplicate use of step JSON ID "+t);return Ct[t]=e,e.prototype.jsonID=t,e};var At=function(t,e){this.doc=t,this.failed=e};At.ok=function(t){return new At(t,null)},At.fail=function(t){return new At(null,t)},At.fromReplace=function(t,e,r,n){try{return At.ok(t.replace(e,r,n))}catch(t){if(t instanceof h)return At.fail(t.message);throw t}};var Et=function(t){function e(e,r,n,o){t.call(this),this.from=e,this.to=r,this.slice=n,this.structure=!!o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){return this.structure&&Dt(t,this.from,this.to)?At.fail("Structure replace would overwrite content"):At.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new yt([this.from,this.to-this.from,this.slice.size])},e.prototype.invert=function(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))},e.prototype.map=function(t){var r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return r.deleted&&n.deleted?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice)},e.prototype.merge=function(t){if(!(t instanceof e)||t.structure!=this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;var r=this.slice.size+t.slice.size==0?f.empty:new f(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,r,this.structure)}var n=this.slice.size+t.slice.size==0?f.empty:new f(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,r){if("number"!=typeof r.from||"number"!=typeof r.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new e(r.from,r.to,f.fromJSON(t,r.slice),!!r.structure)},e}(St);St.jsonID("replace",Et);var Mt=function(t){function e(e,r,n,o,i,s,a){t.call(this),this.from=e,this.to=r,this.gapFrom=n,this.gapTo=o,this.slice=i,this.insert=s,this.structure=!!a}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){if(this.structure&&(Dt(t,this.from,this.gapFrom)||Dt(t,this.gapTo,this.to)))return At.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return At.fail("Gap is not a flat range");var r=this.slice.insertAt(this.insert,e.content);return r?At.fromReplace(t,this.from,this.to,r):At.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new yt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},e.prototype.invert=function(t){var r=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+r,this.from+this.insert,this.from+this.insert+r,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},e.prototype.map=function(t){var r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),o=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return r.deleted&&n.deleted||on.pos?null:new e(r.pos,n.pos,o,i,this.slice,this.insert,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,r){if("number"!=typeof r.from||"number"!=typeof r.to||"number"!=typeof r.gapFrom||"number"!=typeof r.gapTo||"number"!=typeof r.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new e(r.from,r.to,r.gapFrom,r.gapTo,f.fromJSON(t,r.slice),r.insert,!!r.structure)},e}(St);function Dt(t,e,r){for(var n=t.resolve(e),o=r-e,i=n.depth;o>0&&i>0&&n.indexAfter(i)==n.node(i).childCount;)i--,o--;if(o>0)for(var s=n.node(i).maybeChild(n.indexAfter(i));o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}return!1}function Tt(t,e,r){return(0==e||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function Ot(t){for(var e=t.parent.content.cutByIndex(t.startIndex,t.endIndex),r=t.depth;;--r){var n=t.$from.node(r),o=t.$from.index(r),i=t.$to.indexAfter(r);if(ri;a--,c--){var l=o.node(a),u=o.index(a);if(l.type.spec.isolating)return!1;var p=l.content.cutByIndex(u,l.childCount),h=n&&n[c]||l;if(h!=l&&(p=p.replaceChild(0,h.type.create(h.attrs))),!l.canReplace(u+1,l.childCount)||!h.type.validContent(p))return!1}var f=o.indexAfter(i),d=n&&n[0];return o.node(i).canReplaceWith(f,f,d?d.type:o.node(i+1).type)}function It(t,e){var r=t.resolve(e),n=r.index();return Lt(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function Lt(t,e){return t&&e&&!t.isLeaf&&t.canAppend(e)}function Rt(t,e,r){void 0===r&&(r=-1);for(var n=t.resolve(e),o=n.depth;;o--){var i=void 0,s=void 0,a=n.index(o);if(o==n.depth?(i=n.nodeBefore,s=n.nodeAfter):r>0?(i=n.node(o+1),a++,s=n.node(o).maybeChild(a)):(i=n.node(o).maybeChild(a-1),s=n.node(o+1)),i&&!i.isTextblock&&Lt(i,s)&&n.node(o).canReplace(a,a+1))return e;if(0==o)break;e=r<0?n.before(o):n.after(o)}}function Ft(t,e,r){var n=t.resolve(e);if(!r.content.size)return e;for(var o=r.content,i=0;i=0;a--){var c=a==n.depth?0:n.pos<=(n.start(a+1)+n.end(a+1))/2?-1:1,l=n.index(a)+(c>0?1:0);if(1==s?n.node(a).canReplace(l,l,o):n.node(a).contentMatchAt(l).findWrapping(o.firstChild.type))return 0==c?n.pos:c<0?n.before(a+1):n.after(a+1)}return null}function Pt(t,e,r){for(var n=[],o=0;oe;h--)d||r.index(h)>0?(d=!0,u=s.from(r.node(h).copy(u)),p++):c--;for(var m=s.empty,g=0,v=o,y=!1;v>e;v--)y||n.after(v+1)=0;n--)r=s.from(e[n].type.create(e[n].attrs,r));var o=t.start,i=t.end;return this.step(new Mt(o,i,o,i,new f(r,0,0),e.length,!0))},_t.prototype.setBlockType=function(t,e,r,n){var o=this;if(void 0===e&&(e=t),!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var i=this.steps.length;return this.doc.nodesBetween(t,e,(function(t,e){if(t.isTextblock&&!t.hasMarkup(r,n)&&function(t,e,r){var n=t.resolve(e),o=n.index();return n.parent.canReplaceWith(o,o+1,r)}(o.doc,o.mapping.slice(i).map(e),r)){o.clearIncompatible(o.mapping.slice(i).map(e,1),r);var a=o.mapping.slice(i),c=a.map(e,1),l=a.map(e+t.nodeSize,1);return o.step(new Mt(c,l,c+1,l-1,new f(s.from(r.create(n,null,t.marks)),0,0),1,!0)),!1}})),this},_t.prototype.setNodeMarkup=function(t,e,r,n){var o=this.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");e||(e=o.type);var i=e.create(r,null,n||o.marks);if(o.isLeaf)return this.replaceWith(t,t+o.nodeSize,i);if(!e.validContent(o.content))throw new RangeError("Invalid content for node type "+e.name);return this.step(new Mt(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new f(s.from(i),0,0),1,!0))},_t.prototype.split=function(t,e,r){void 0===e&&(e=1);for(var n=this.doc.resolve(t),o=s.empty,i=s.empty,a=n.depth,c=n.depth-e,l=e-1;a>c;a--,l--){o=s.from(n.node(a).copy(o));var u=r&&r[l];i=s.from(u?u.type.create(u.attrs,i):n.node(a).copy(i))}return this.step(new Et(t,t,new f(o.append(i),e,e),!0))},_t.prototype.join=function(t,e){void 0===e&&(e=1);var r=new Et(t-e,t+e,f.empty,!0);return this.step(r)};var Bt=function(t){function e(e,r,n){t.call(this),this.from=e,this.to=r,this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,r=t.slice(this.from,this.to),n=t.resolve(this.from),o=n.node(n.sharedDepth(this.to)),i=new f(Pt(r.content,(function(t,r){return r.type.allowsMarkType(e.mark.type)?t.mark(e.mark.addToSet(t.marks)):t}),o),r.openStart,r.openEnd);return At.fromReplace(t,this.from,this.to,i)},e.prototype.invert=function(){return new Vt(this.from,this.to,this.mark)},e.prototype.map=function(t){var r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new e(r.pos,n.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,r){if("number"!=typeof r.from||"number"!=typeof r.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new e(r.from,r.to,t.markFromJSON(r.mark))},e}(St);St.jsonID("addMark",Bt);var Vt=function(t){function e(e,r,n){t.call(this),this.from=e,this.to=r,this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,r=t.slice(this.from,this.to),n=new f(Pt(r.content,(function(t){return t.mark(e.mark.removeFromSet(t.marks))})),r.openStart,r.openEnd);return At.fromReplace(t,this.from,this.to,n)},e.prototype.invert=function(){return new Bt(this.from,this.to,this.mark)},e.prototype.map=function(t){var r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new e(r.pos,n.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,r){if("number"!=typeof r.from||"number"!=typeof r.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new e(r.from,r.to,t.markFromJSON(r.mark))},e}(St);function $t(t,e,r,n){if(void 0===r&&(r=e),void 0===n&&(n=f.empty),e==r&&!n.size)return null;var o=t.resolve(e),i=t.resolve(r);if(Ht(o,i,n))return new Et(e,r,n);var a=function(t,e){var r=function t(e,r,n,o){var i=s.empty,a=0,c=n[r];if(e.depth>r){var l=t(e,r+1,n,o||c);a=l.openEnd+1,i=s.from(e.node(r+1).copy(l.content))}c&&(i=i.append(c.content),a=c.openEnd);o&&(i=i.append(e.node(r).contentMatchAt(e.indexAfter(r)).fillBefore(s.empty,!0)),a=0);return{content:i,openEnd:a}}(t,0,e,!1),n=r.content,o=r.openEnd;return new f(n,t.depth,o||0)}(o,function(t,e){for(var r=new Gt(t),n=1;e.size&&n<=3;n++){var o=r.placeSlice(e.content,e.openStart,e.openEnd,n);3==n&&o!=e&&o.size&&(n=0),e=o}for(;r.open.length;)r.closeNode();return r.placed}(o,n)),c=Ut(o,i,a);if(!c)return null;if(a.size!=c.size&&function(t,e,r){if(!e.parent.isTextblock)return!1;var n,o=r.openEnd?function(t,e){for(var r=1;r1&&u==i.end(--l);)++u;var p=Ut(o,t.resolve(u),a);if(p)return new Mt(e,u,r,i.end(),p,a.size)}return c.size||e!=r?new Et(e,r,c):null}function jt(t,e,r,n,o,i,a){var c,l=t.childCount,u=l-(a>0?1:0),p=i<0?e:r.node(o);c=i<0?p.contentMatchAt(u):1==l&&a>0?p.contentMatchAt(i?r.index(o):r.indexAfter(o)):p.contentMatchAt(r.indexAfter(o)).matchFragment(t,l>0&&i?1:0,u);var h=n.node(o);if(a>0&&o0&&1==l&&(d=null),d){var m=jt(t.lastChild.content,t.lastChild,r,n,o+1,1==l?i-1:-1,a-1);if(m){var g=t.lastChild.copy(m);return d.size?t.cutByIndex(0,l-1).append(d).addToEnd(g):t.replaceChild(l-1,g)}}}a>0&&(c=c.matchType((1==l&&i>0?r.node(o+1):t.lastChild).type));var v=n.index(o);if(v==h.childCount&&!h.type.compatibleContent(e.type))return null;for(var y=c.fillBefore(h.content,!0,v),b=v;y&&b0){var k=function t(e,r,n,o,i){var a,c=e.content,l=c.childCount;a=i>=0?n.node(o).contentMatchAt(n.indexAfter(o)).matchFragment(c,i>0?1:0,l):e.contentMatchAt(l);if(r>0){var u=t(c.lastChild,r-1,n,o+1,1==l?i-1:-1);c=c.replaceChild(l-1,u)}return e.copy(c.append(a.fillBefore(s.empty,!0)))}(t.lastChild,a-1,r,o+1,1==l?i-1:-1);t=t.replaceChild(l-1,k)}return t=t.append(y),n.depth>o&&(t=t.addToEnd(function t(e,r){var n=e.node(r),o=n.contentMatchAt(0).fillBefore(n.content,!0,e.index(r));e.depth>r&&(o=o.addToEnd(t(e,r+1)));return n.copy(o)}(n,o+1))),t}function Ut(t,e,r){var n=jt(r.content,t.node(0),t,e,0,r.openStart,r.openEnd);return n?function(t,e,r){for(;e>0&&r>0&&1==t.childCount;)t=t.firstChild.content,e--,r--;return new f(t,e,r)}(n,r.openStart,e.depth):null}function Ht(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}St.jsonID("removeMark",Vt),_t.prototype.addMark=function(t,e,r){var n=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(t,e,(function(n,c,l){if(n.isInline){var u=n.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){for(var p=Math.max(c,t),h=Math.min(c+n.nodeSize,e),f=r.addToSet(u),d=0;d=0;d--)this.step(o[d]);return this},_t.prototype.replace=function(t,e,r){void 0===e&&(e=t),void 0===r&&(r=f.empty);var n=$t(this.doc,t,e,r);return n&&this.step(n),this},_t.prototype.replaceWith=function(t,e,r){return this.replace(t,e,new f(s.from(r),0,0))},_t.prototype.delete=function(t,e){return this.replace(t,e,f.empty)},_t.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var Gt=function(t){this.open=[];for(var e=0;e<=t.depth;e++){var r=t.node(e),n=r.contentMatchAt(t.indexAfter(e));this.open.push({parent:r,match:n,content:s.empty,wrapper:!1,openEnd:0,depth:e})}this.placed=[]};function Jt(t,e,r){var n=t.content;if(e>1){var o=Jt(t.firstChild,e-1,1==t.childCount?r-1:0);n=t.content.replaceChild(0,o)}var i=t.type.contentMatch.fillBefore(n,0==r);return t.copy(i.append(n))}function Zt(t,e,r,n,o){if(en){var a=o.contentMatchAt(0),c=a.fillBefore(t).append(t);t=c.append(a.matchFragment(c).fillBefore(s.empty,!0))}return t}function Wt(t,e){for(var r=[],n=Math.min(t.depth,e.depth);n>=0;n--){var o=t.start(n);if(oe.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;o==e.start(n)&&r.push(n)}return r}function Kt(t){return(Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Gt.prototype.placeSlice=function(t,e,r,n,o){if(e>0){var i=t.firstChild,a=this.placeSlice(i.content,Math.max(0,e-1),r&&1==t.childCount?r-1:0,n,i);a.content!=i.content&&(a.content.size?(t=t.replaceChild(0,i.copy(a.content)),e=a.openStart+1):(1==t.childCount&&(r=0),t=t.cutByIndex(1),e=0))}var c=this.placeContent(t,e,r,n,o);if(n>2&&c.size&&0==e){var l=c.content.firstChild,u=1==c.content.childCount;this.placeContent(l.content,0,r&&u?r-1:0,n,l),c=u?s.empty:new f(c.content.cutByIndex(1),0,r)}return c},Gt.prototype.placeContent=function(t,e,r,n,o){for(var i=0;i=0;u--){var p=this.open[u],h=void 0;if(n>1&&(h=p.match.findWrapping(a.type))&&(!o||!h.length||h[h.length-1]!=o.type)){for(;this.open.length-1>u;)this.closeNode();for(var d=0;du;)this.closeNode();a=a.mark(p.parent.type.allowedMarks(a.marks)),e&&(a=Jt(a,e,l?r:0),e=0),this.addNode(p,a,l?r:0),p.match=m,l&&(r=0),c=!0;break}if(!c)break}return this.open.length>1&&(i>0&&i==t.childCount||o&&this.open[this.open.length-1].parent.type==o.type)&&this.closeNode(),new f(t.cutByIndex(i),e,r)},Gt.prototype.addNode=function(t,e,r){var n,o;t.content=(n=t.content,o=t.openEnd,o?n.replaceChild(n.childCount-1,function t(e,r){var n=e.content;if(r>1){var o=t(e.lastChild,r-1);n=e.content.replaceChild(e.childCount-1,o)}var i=e.contentMatchAt(e.childCount).fillBefore(s.empty,!0);return e.copy(n.append(i))}(n.lastChild,o)):n).addToEnd(e),t.openEnd=r},Gt.prototype.closeNode=function(){var t=this.open.pop();0==t.content.size||(t.wrapper?this.addNode(this.open[this.open.length-1],t.parent.copy(t.content),t.openEnd+1):this.placed[t.depth]={depth:t.depth,content:t.content,openEnd:t.openEnd})},_t.prototype.replaceRange=function(t,e,r){if(!r.size)return this.deleteRange(t,e);var n=this.doc.resolve(t),o=this.doc.resolve(e);if(Ht(n,o,r))return this.step(new Et(t,e,r));var i=Wt(n,this.doc.resolve(e));0==i[i.length-1]&&i.pop();var s=-(n.depth+1);i.unshift(s);for(var a=n.depth,c=n.pos-1;a>0;a--,c--){var l=n.node(a).type.spec;if(l.defining||l.isolating)break;i.indexOf(a)>-1?s=a:n.before(a)==c&&i.splice(1,0,-a)}for(var u=i.indexOf(s),p=[],h=r.openStart,d=r.content,m=0;;m++){var g=d.firstChild;if(p.push(g),m==r.openStart)break;d=g.content}h>0&&p[h-1].type.spec.defining&&n.node(u).type!=p[h-1].type?h-=1:h>=2&&p[h-1].isTextblock&&p[h-2].type.spec.defining&&n.node(u).type!=p[h-2].type&&(h-=2);for(var v=r.openStart;v>=0;v--){var y=(v+h+1)%(r.openStart+1),b=p[y];if(b)for(var k=0;k=0&&(this.replace(t,e,r),!(this.steps.length>S));A--){var E=i[A];A<0||(t=n.before(E),e=o.after(E))}return this},_t.prototype.replaceRangeWith=function(t,e,r){if(!r.isInline&&t==e&&this.doc.resolve(t).parent.content.size){var n=function(t,e,r){var n=t.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),r))return e;if(0==n.parentOffset)for(var o=n.depth-1;o>=0;o--){var i=n.index(o);if(n.node(o).canReplaceWith(i,i,r))return n.before(o+1);if(i>0)return null}if(n.parentOffset==n.parent.content.size)for(var s=n.depth-1;s>=0;s--){var a=n.indexAfter(s);if(n.node(s).canReplaceWith(a,a,r))return n.after(s+1);if(a0&&(a||r.node(s-1).canReplace(r.index(s-1),n.indexAfter(s-1))))return this.delete(r.before(s),n.after(s))}for(var c=1;c<=r.depth&&c<=n.depth;c++)if(t-r.start(c)==r.depth-c&&e>r.end(c)&&n.end(c)-e!=n.depth-c)return this.delete(r.before(c),e);return this.delete(t,e)};var Yt=Object.create(null),Qt=function(t,e,r){this.ranges=r||[new te(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},Xt={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};Xt.anchor.get=function(){return this.$anchor.pos},Xt.head.get=function(){return this.$head.pos},Xt.from.get=function(){return this.$from.pos},Xt.to.get=function(){return this.$to.pos},Xt.$from.get=function(){return this.ranges[0].$from},Xt.$to.get=function(){return this.ranges[0].$to},Xt.empty.get=function(){for(var t=this.ranges,e=0;e=0;o--){var i=e<0?ae(t.node(0),t.node(o),t.before(o+1),t.index(o),e,r):ae(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,r);if(i)return i}},Qt.near=function(t,e){return void 0===e&&(e=1),this.findFrom(t,e)||this.findFrom(t,-e)||new ie(t.node(0))},Qt.atStart=function(t){return ae(t,t,0,0,1)||new ie(t)},Qt.atEnd=function(t){return ae(t,t,t.content.size,t.childCount,-1)||new ie(t)},Qt.fromJSON=function(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");var r=Yt[e.type];if(!r)throw new RangeError("No selection type "+e.type+" defined");return r.fromJSON(t,e)},Qt.jsonID=function(t,e){if(t in Yt)throw new RangeError("Duplicate use of selection JSON ID "+t);return Yt[t]=e,e.prototype.jsonID=t,e},Qt.prototype.getBookmark=function(){return ee.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(Qt.prototype,Xt),Qt.prototype.visible=!0;var te=function(t,e){this.$from=t,this.$to=e},ee=function(t){function e(e,r){void 0===r&&(r=e),t.call(this,e,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$cursor:{configurable:!0}};return r.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},e.prototype.map=function(r,n){var o=r.resolve(n.map(this.head));if(!o.parent.inlineContent)return t.near(o);var i=r.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:o,o)},e.prototype.replace=function(e,r){if(void 0===r&&(r=f.empty),t.prototype.replace.call(this,e,r),r==f.empty){var n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head},e.prototype.getBookmark=function(){return new re(this.anchor,this.head)},e.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},e.fromJSON=function(t,r){if("number"!=typeof r.anchor||"number"!=typeof r.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new e(t.resolve(r.anchor),t.resolve(r.head))},e.create=function(t,e,r){void 0===r&&(r=e);var n=t.resolve(e);return new this(n,r==e?n:t.resolve(r))},e.between=function(r,n,o){var i=r.pos-n.pos;if(o&&!i||(o=i>=0?1:-1),!n.parent.inlineContent){var s=t.findFrom(n,o,!0)||t.findFrom(n,-o,!0);if(!s)return t.near(n,o);n=s.$head}return r.parent.inlineContent||(0==i||(r=(t.findFrom(r,-o,!0)||t.findFrom(r,o,!0)).$anchor).pos0?0:1);o>0?s=0;s+=o){var a=e.child(s);if(a.isAtom){if(!i&&ne.isSelectable(a))return ne.create(t,r-(o<0?a.nodeSize:0))}else{var c=ae(t,a,r+o,o<0?a.childCount:0,o,i);if(c)return c}r+=a.nodeSize*o}}function ce(t,e,r){var n=t.steps.length-1;if(!(n0},e.prototype.setStoredMarks=function(t){return this.storedMarks=t,this.updated|=2,this},e.prototype.ensureMarks=function(t){return p.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this},e.prototype.addStoredMark=function(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))},e.prototype.removeStoredMark=function(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))},r.storedMarksSet.get=function(){return(2&this.updated)>0},e.prototype.addStep=function(e,r){t.prototype.addStep.call(this,e,r),this.updated=-3&this.updated,this.storedMarks=null},e.prototype.setTime=function(t){return this.time=t,this},e.prototype.replaceSelection=function(t){return this.selection.replace(this,t),this},e.prototype.replaceSelectionWith=function(t,e){var r=this.selection;return!1!==e&&(t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||p.none))),r.replaceWith(this,t),this},e.prototype.deleteSelection=function(){return this.selection.replace(this),this},e.prototype.insertText=function(t,e,r){void 0===r&&(r=e);var n=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(n.text(t),!0):this.deleteSelection();if(!t)return this.deleteRange(e,r);var o=this.storedMarks;if(!o){var i=this.doc.resolve(e);o=r==e?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(e,r,n.text(t,o)),this.selection.empty||this.setSelection(Qt.near(this.selection.$to)),this},e.prototype.setMeta=function(t,e){return this.meta["string"==typeof t?t:t.key]=e,this},e.prototype.getMeta=function(t){return this.meta["string"==typeof t?t:t.key]},r.isGeneric.get=function(){for(var t in this.meta)return!1;return!0},e.prototype.scrollIntoView=function(){return this.updated|=4,this},r.scrolledIntoView.get=function(){return(4&this.updated)>0},Object.defineProperties(e.prototype,r),e}(_t);function ue(t,e){return e&&t?t.bind(e):t}var pe=function(t,e,r){this.name=t,this.init=ue(e.init,r),this.apply=ue(e.apply,r)},he=[new pe("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new pe("selection",{init:function(t,e){return t.selection||Qt.atStart(e.doc)},apply:function(t){return t.selection}}),new pe("storedMarks",{init:function(t){return t.storedMarks||null},apply:function(t,e,r,n){return n.selection.$cursor?t.storedMarks:null}}),new pe("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],fe=function(t,e){var r=this;this.schema=t,this.fields=he.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),e&&e.forEach((function(t){if(r.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");r.plugins.push(t),r.pluginsByKey[t.key]=t,t.spec.state&&r.fields.push(new pe(t.key,t.spec.state,t))}))},de=function(t){this.config=t},me={schema:{configurable:!0},plugins:{configurable:!0},tr:{configurable:!0}};me.schema.get=function(){return this.config.schema},me.plugins.get=function(){return this.config.plugins},de.prototype.apply=function(t){return this.applyTransaction(t).state},de.prototype.filterTransaction=function(t,e){void 0===e&&(e=-1);for(var r=0;r-1&&ge.splice(e,1)},Object.defineProperties(de.prototype,me);var ge=[];var ve=function(t){this.props={},t.props&&function t(e,r,n){for(var o in e){var i=e[o];i instanceof Function?i=i.bind(r):"handleDOMEvents"==o&&(i=t(i,r,{})),n[o]=i}return n}(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:be("plugin")};ve.prototype.getState=function(t){return t[this.key]};var ye=Object.create(null);function be(t){return t in ye?t+"$"+ ++ye[t]:(ye[t]=0,t+"$")}var ke=function(t){void 0===t&&(t="key"),this.key=be(t)};ke.prototype.get=function(t){return t.config.pluginsByKey[this.key]},ke.prototype.getState=function(t){return t[this.key]};var _e={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var we=/Edge\/(\d+)/.exec(navigator.userAgent),xe=/MSIE \d/.test(navigator.userAgent),Ce=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);_e.mac=/Mac/.test(navigator.platform);var Se=_e.ie=!!(xe||Ce||we);_e.ie_version=xe?document.documentMode||6:Ce?+Ce[1]:we?+we[1]:null,_e.gecko=!Se&&/gecko\/(\d+)/i.test(navigator.userAgent),_e.gecko_version=_e.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var Ae=!Se&&/Chrome\/(\d+)/.exec(navigator.userAgent);_e.chrome=!!Ae,_e.chrome_version=Ae&&+Ae[1],_e.ios=!Se&&/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),_e.android=/Android \d/.test(navigator.userAgent),_e.webkit=!Se&&"WebkitAppearance"in document.documentElement.style,_e.safari=/Apple Computer/.test(navigator.vendor),_e.webkit_version=_e.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var Ee=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Me=function(t){var e=t.parentNode;return e&&11==e.nodeType?e.host:e},De=function(t,e,r){var n=document.createRange();return n.setEnd(t,null==r?t.nodeValue.length:r),n.setStart(t,e||0),n},Te=function(t,e,r,n){return r&&(qe(t,e,r,n,-1)||qe(t,e,r,n,1))},Oe=/^(img|br|input|textarea|hr)$/i;function qe(t,e,r,n,o){for(;;){if(t==r&&e==n)return!0;if(e==(o<0?0:ze(t))){var i=t.parentNode;if(1!=i.nodeType||Ne(t)||Oe.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Ee(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(o<0?-1:0)]).contentEditable)return!1;e=o<0?ze(t):0}}}function ze(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Ne(t){for(var e,r=t;r&&!(e=r.pmViewDesc);r=r.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var Ie=function(t){var e=t.isCollapsed;return e&&_e.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e};function Le(t,e){var r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=t,r.key=r.code=e,r}function Re(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function Fe(t,e){return"number"==typeof t?t:t[e]}function Pe(t,e,r){for(var n=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument,s=i.defaultView,a=r||t.dom;a;a=Me(a))if(1==a.nodeType){var c=a==i.body||1!=a.nodeType,l=c?Re(s):a.getBoundingClientRect(),u=0,p=0;if(e.topl.bottom-Fe(n,"bottom")&&(p=e.bottom-l.bottom+Fe(o,"bottom")),e.leftl.right-Fe(n,"right")&&(u=e.right-l.right+Fe(o,"right")),(u||p)&&(c?s.scrollBy(u,p):(p&&(a.scrollTop+=p),u&&(a.scrollLeft+=u),e={left:e.left-u,top:e.top-p,right:e.right-u,bottom:e.bottom-p})),c)break}}function Be(t){for(var e=[],r=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=r);t=Me(t));return e}function Ve(t,e){for(var r=0;r=a){s=Math.max(h.bottom,s),a=Math.min(h.top,a);var f=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}!r&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(i=l+1)}}return r&&3==r.nodeType?function(t,e){for(var r=t.nodeValue.length,n=document.createRange(),o=0;o=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}(r,n):!r||o&&1==r.nodeType?{node:t,offset:i}:je(r,n)}function Ue(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function He(t,e){var r,n,o,i,s=t.root;if(s.caretPositionFromPoint)try{var a=s.caretPositionFromPoint(e.left,e.top);a&&(o=(r=a).offsetNode,i=r.offset)}catch(t){}if(!o&&s.caretRangeFromPoint){var c=s.caretRangeFromPoint(e.left,e.top);c&&(o=(n=c).startContainer,i=n.startOffset)}var l,u=s.elementFromPoint(e.left,e.top+1);if(!u||!t.dom.contains(1!=u.nodeType?u.parentNode:u)){var p=t.dom.getBoundingClientRect();if(!Ue(e,p))return null;if(!(u=function t(e,r,n){var o=e.childNodes.length;if(o&&n.tope.top&&i++}o==t.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&e.top>o.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(l=function(t,e,r,n){for(var o=-1,i=e;i!=t.dom;){var s=t.docView.nearestDesc(i,!0);if(!s)return null;if(s.node.isBlock&&s.parent){var a=s.dom.getBoundingClientRect();if(a.left>n.left||a.top>n.top)o=s.posBefore;else{if(!(a.right-1?o:t.docView.posFromDOM(e,r)}(t,o,i,e))}null==l&&(l=function(t,e,r){var n=je(e,r),o=n.node,i=n.offset,s=-1;if(1==o.nodeType&&!o.firstChild){var a=o.getBoundingClientRect();s=a.left!=a.right&&r.left>(a.left+a.right)/2?1:-1}return t.docView.posFromDOM(o,i,s)}(t,u,e));var d=t.docView.nearestDesc(u,!0);return{pos:l,inside:d?d.posAtStart-d.border:-1}}function Ge(t,e){var r=t.getClientRects();return r.length?r[e<0?0:r.length-1]:t.getBoundingClientRect()}function Je(t,e){var r=t.docView.domFromPos(e),n=r.node,o=r.offset;if(3==n.nodeType&&(_e.chrome||_e.gecko)){var i=Ge(De(n,o,o),0);if(_e.gecko&&o&&/\s/.test(n.nodeValue[o-1])&&o0&&ol.top&&("up"==r?l.bottomi.bottom-1))return!1}}return!0}))}(t,e,r):function(t,e,r){var n=e.selection.$head;if(!n.parent.isTextblock)return!1;var o=n.parentOffset,i=!o,s=o==n.parent.content.size,a=getSelection();return Ke.test(n.parent.textContent)&&a.modify?We(t,e,(function(){var e=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset,s=a.caretBidiLevel;a.modify("move",r,"character");var c=!(n.depth?t.docView.domAfterPos(n.before()):t.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(e),null!=s&&(a.caretBidiLevel=s),c})):"left"==r||"backward"==r?i:s}(t,e,r))}var er=function(t,e,r,n){this.parent=t,this.children=e,this.dom=r,r.pmViewDesc=this,this.contentDOM=n,this.dirty=0},rr={beforePosition:{configurable:!0},size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0}};er.prototype.matchesWidget=function(){return!1},er.prototype.matchesMark=function(){return!1},er.prototype.matchesNode=function(){return!1},er.prototype.matchesHack=function(){return!1},rr.beforePosition.get=function(){return!1},er.prototype.parseRule=function(){return null},er.prototype.stopEvent=function(){return!1},rr.size.get=function(){for(var t=0,e=0;e0:a)?this.posAtEnd:this.posAtStart},er.prototype.nearestDesc=function(t,e){for(var r=!0,n=t;n;n=n.parentNode){var o=this.getDesc(n);if(o&&(!e||o.node)){if(!r||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(t):o.nodeDOM==t))return o;r=!1}}},er.prototype.getDesc=function(t){for(var e=t.pmViewDesc,r=e;r;r=r.parent)if(r==this)return e},er.prototype.posFromDOM=function(t,e,r){for(var n=t;;n=n.parentNode){var o=this.getDesc(n);if(o)return o.localPosFromDOM(t,e,r)}},er.prototype.descAt=function(t){for(var e=0,r=0;e=l&&e<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,e,l);t=i;for(var u=s;u>0;u--){var p=this.children[u-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){n=Ee(p.dom)+1;break}t-=p.size}-1==n&&(n=0)}if(n>-1&&e<=c){e=c;for(var h=s+1;ha&&ie){var d=u;u=p,p=d}f.setEnd(p.node,p.offset),f.setStart(u.node,u.offset)}h.removeAllRanges(),h.addRange(f),h.extend&&h.extend(p.node,p.offset)}},er.prototype.ignoreMutation=function(t){return!this.contentDOM&&"selection"!=t.type},rr.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},er.prototype.markDirty=function(t,e){for(var r=0,n=0;n=r:tr){var s=r+o.border,a=i-o.border;if(t>=s&&e<=a)return this.dirty=t==r||e==i?2:1,void(t!=s||e!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-s,e-s):o.dirty=3);o.dirty=3}r=i}this.dirty=2},er.prototype.markParentsDirty=function(){for(var t=this.parent;t;t=t.parent){t.dirty<2&&(t.dirty=2)}},Object.defineProperties(er.prototype,rr);var nr=[],or=function(t){function e(e,r,n,o){var i,s=r.type.toDOM;if("function"==typeof s&&(s=s(n,(function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:o}))),!r.type.spec.raw){if(1!=s.nodeType){var a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable=!1,s.classList.add("ProseMirror-widget")}t.call(this,e,nr,s,null),this.widget=r,i=this}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={beforePosition:{configurable:!0}};return r.beforePosition.get=function(){return this.widget.type.side<0},e.prototype.matchesWidget=function(t){return 0==this.dirty&&t.type.eq(this.widget.type)},e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.stopEvent=function(t){var e=this.widget.spec.stopEvent;return!!e&&e(t)},e.prototype.ignoreMutation=function(t){return"selection"!=t.type||this.widget.spec.ignoreSelection},Object.defineProperties(e.prototype,r),e}(er),ir=function(t){function e(e,r,n,o){t.call(this,e,nr,r,null),this.textDOM=n,this.text=o}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={size:{configurable:!0}};return r.size.get=function(){return this.text.length},e.prototype.localPosFromDOM=function(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e},e.prototype.domFromPos=function(t){return{node:this.textDOM,offset:t}},e.prototype.ignoreMutation=function(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue},Object.defineProperties(e.prototype,r),e}(er),sr=function(t){function e(e,r,n,o){t.call(this,e,[],n,o),this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.create=function(t,r,n,o){var i=o.nodeViews[r.type.name],s=i&&i(r,o,n);return s&&s.dom||(s=ht.renderSpec(document,r.type.spec.toDOM(r,n))),new e(t,r,s.dom,s.contentDOM||s.dom)},e.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},e.prototype.matchesMark=function(t){return 3!=this.dirty&&this.mark.eq(t)},e.prototype.markDirty=function(e,r){if(t.prototype.markDirty.call(this,e,r),0!=this.dirty){for(var n=this.parent;!n.node;)n=n.parent;n.dirty0&&(i=wr(i,0,t,n));for(var a=0;a=0&&!a&&s.syncToMarks(i==r.node.childCount?p.none:r.node.child(i).marks,n,t),s.placeWidget(e,t,o)}),(function(e,r,i,a){s.syncToMarks(e.marks,n,t),s.findNodeMatch(e,r,i,a)||s.updateNextNode(e,r,i,t,a)||s.addNode(e,r,i,t,o),o+=e.nodeSize})),s.syncToMarks(nr,n,t),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),this.renderChildren())},e.prototype.renderChildren=function(){!function t(e,r){for(var n=e.firstChild,o=0;oe+this.node.content.size)){var i=t.root.getSelection(),s=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];t=t.childNodes[e-1],e=ze(t)}else{if(!(1==t.nodeType&&e=r){var u=c.lastIndexOf(e,n-a);if(u>=0&&u+e.length+a>=r)return a+u}}}return-1}(this.node.content,a,n-e,o-e);return c<0?null:{node:s,pos:c,text:a}}}},e.prototype.protectLocalComposition=function(t,e){var r=e.node,n=e.pos,o=e.text;if(!this.getDesc(r)){for(var i=r;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=null)}var s=new ir(this,i,r,o);t.compositionNodes.push(s),this.children=wr(this.children,n,n+o.length,t,s)}},e.prototype.update=function(t,e,r,n){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,r,n),!0)},e.prototype.updateInner=function(t,e,r,n){this.updateOuterDeco(e),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(n,this.posAtStart),this.dirty=0},e.prototype.updateOuterDeco=function(t){if(!yr(t,this.outerDeco)){var e=1!=this.nodeDOM.nodeType,r=this.dom;this.dom=mr(this.dom,this.nodeDOM,dr(this.outerDeco,this.node,e),dr(t,this.node,e)),this.dom!=r&&(r.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=t}},e.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},e.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!1)},Object.defineProperties(e.prototype,r),e}(er);function cr(t,e,r,n,o){return vr(n,e,t),new ar(null,t,e,r,n,n,n,o,0)}var lr=function(t){function e(e,r,n,o,i,s,a){t.call(this,e,r,n,o,i,null,s,a)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.parseRule=function(){return{skip:this.nodeDOM.parentNode||!0}},e.prototype.update=function(t,e){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text),this.node=t,this.dirty=0,!0)},e.prototype.inParent=function(){for(var t=this.parent.contentDOM,e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1},e.prototype.domFromPos=function(t){return{node:this.nodeDOM,offset:t}},e.prototype.localPosFromDOM=function(e,r,n){return e==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):t.prototype.localPosFromDOM.call(this,e,r,n)},e.prototype.ignoreMutation=function(t){return"characterData"!=t.type&&"selection"!=t.type},e.prototype.slice=function(t,r,n){var o=this.node.cut(t,r),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i,n)},e}(ar),ur=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(){return 0==this.dirty},e}(er),pr=function(t){function e(e,r,n,o,i,s,a,c,l,u){t.call(this,e,r,n,o,i,s,a,l,u),this.spec=c}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.update=function(e,r,n,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(e,r);return i&&this.updateInner(e,r,n,o),i}return!(!this.contentDOM&&!e.isLeaf)&&t.prototype.update.call(this,e,r,n,o)},e.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():t.prototype.selectNode.call(this)},e.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():t.prototype.deselectNode.call(this)},e.prototype.setSelection=function(e,r,n,o){this.spec.setSelection?this.spec.setSelection(e,r,n):t.prototype.setSelection.call(this,e,r,n,o)},e.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),t.prototype.destroy.call(this)},e.prototype.stopEvent=function(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)},e.prototype.ignoreMutation=function(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):t.prototype.ignoreMutation.call(this,e)},e}(ar);function hr(t){t&&(this.nodeName=t)}hr.prototype=Object.create(null);var fr=[new hr];function dr(t,e,r){if(0==t.length)return fr;for(var n=r?fr[0]:new hr,o=[n],i=0;i0&&o>=0;o--){var i=e[o],s=i.node;if(s){if(s!=t.child(n-1))break;r.push(i),--n}}return{nodes:r.reverse(),offset:n}}(t.node.content,t.children);this.preMatched=r.nodes,this.preMatchOffset=r.offset};function _r(t,e){return t.type.side-e.type.side}function wr(t,e,r,n,o){for(var i=[],s=0,a=0;s=r||u<=e?i.push(c):(lr&&i.push(c.slice(r-l,c.size,n)))}return i}function xr(t,e){var r=t.selection,n=r.$anchor,o=r.$head,i=e>0?n.max(o):n.min(o),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&Qt.findFrom(s,e)}function Cr(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Sr(t,e,r){var n=t.state.selection;if(n instanceof ee){if(!n.empty||r.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){var o=xr(t.state,e);return!!(o&&o instanceof ne)&&Cr(t,o)}var i,s=n.$head,a=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!a||a.isText)return!1;var c=e<0?s.pos-a.nodeSize:s.pos;return!!(a.isAtom||(i=t.docView.descAt(c))&&!i.contentDOM)&&(ne.isSelectable(a)?Cr(t,new ne(e<0?t.state.doc.resolve(s.pos-a.nodeSize):s)):!!_e.webkit&&Cr(t,new ee(t.state.doc.resolve(e<0?c:c+a.nodeSize))))}if(n instanceof ne&&n.node.isInline)return Cr(t,new ee(e>0?n.$to:n.$from));var l=xr(t.state,e);return!!l&&Cr(t,l)}function Ar(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Er(t){var e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function Mr(t){var e=t.root.getSelection(),r=e.focusNode,n=e.focusOffset;if(r){var o,i,s=!1;for(_e.gecko&&1==r.nodeType&&n0){if(1!=r.nodeType)break;var a=r.childNodes[n-1];if(Er(a))o=r,i=--n;else{if(3!=a.nodeType)break;n=(r=a).nodeValue.length}}else{if(Tr(r))break;for(var c=r.previousSibling;c&&Er(c);)o=r.parentNode,i=Ee(c),c=c.previousSibling;if(c)n=Ar(r=c);else{if((r=r.parentNode)==t.dom)break;n=0}}s?Or(t,e,r,n):o&&Or(t,e,o,i)}}function Dr(t){var e=t.root.getSelection(),r=e.focusNode,n=e.focusOffset;if(r){for(var o,i,s=Ar(r);;)if(n-1)return!1;var o=n.$from,i=n.$to;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){var s=xr(t.state,e);if(s&&s instanceof ne)return Cr(t,s)}if(!o.parent.inlineContent){var a=Qt.findFrom(e<0?o:i,e);return!a||Cr(t,a)}return!1}function zr(t,e){if(!(t.state.selection instanceof ee))return!0;var r=t.state.selection,n=r.$head,o=r.$anchor,i=r.empty;if(!n.sameParent(o))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;var s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){var a=t.state.tr;return e<0?a.delete(n.pos-s.nodeSize,n.pos):a.delete(n.pos,n.pos+s.nodeSize),t.dispatch(a),!0}return!1}function Nr(t,e,r){t.domObserver.stop(),e.contentEditable=r,t.domObserver.start()}function Ir(t,e){var r=e.keyCode,n=function(t){var e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==r||_e.mac&&72==r&&"c"==n?zr(t,-1)||Mr(t):46==r||_e.mac&&68==r&&"c"==n?zr(t,1)||Dr(t):13==r&&!_e.ios||27==r||(37==r?Sr(t,-1,n)||Mr(t):39==r?Sr(t,1,n)||Dr(t):38==r?qr(t,-1,n)||Mr(t):40==r?function(t){if(_e.chrome&&!(t.state.selection.$head.parentOffset>0)){var e=t.root.getSelection(),r=e.focusNode,n=e.focusOffset;if(r&&1==r.nodeType&&0==n&&r.firstChild&&"false"==r.firstChild.contentEditable){var o=r.firstChild;Nr(t,o,!0),setTimeout((function(){return Nr(t,o,!1)}),20)}}}(t)||qr(t,1,n)||Dr(t):n==(_e.mac?"m":"c")&&(66==r||73==r||89==r||90==r))}function Lr(t,e){var r,n,o=t.root.getSelection(),i=t.state.doc,s=t.docView.nearestDesc(o.focusNode),a=s&&0==s.size,c=t.docView.posFromDOM(o.focusNode,o.focusOffset),l=i.resolve(c);if(Ie(o)){for(r=l;s&&!s.node;)s=s.parent;if(s&&s.node.isAtom&&ne.isSelectable(s.node)&&s.parent&&(!s.node.isInline||!function(t,e,r){for(var n=0==e,o=e==ze(t);n||o;){if(t==r)return!0;var i=Ee(t);if(!(t=t.parentNode))return!1;n=n&&0==i,o=o&&i==ze(t)}}(o.focusNode,o.focusOffset,s.dom))){var u=s.posBefore;n=new ne(c==u?l:i.resolve(u))}}else r=i.resolve(t.docView.posFromDOM(o.anchorNode,o.anchorOffset));n||(n=Ur(t,r,l,"pointer"==e||t.state.selection.head=this.preMatchOffset?this.preMatched[t-this.preMatchOffset]:null},kr.prototype.destroyBetween=function(t,e){if(t!=e){for(var r=t;r>1,i=Math.min(o,t.length);n-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{var c=sr.create(this.top,t[o],e,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}},kr.prototype.findNodeMatch=function(t,e,r,n){var o=-1,i=n<0?void 0:this.getPreMatch(n),s=this.top.children;if(i&&i.matchesNode(t,e,r))o=s.indexOf(i);else for(var a=this.index,c=Math.min(s.length,a+5);a-1&&s+this.preMatchOffset!=o)return!1;var a=i.dom;if(!(this.lock&&(a==this.lock||1==a.nodeType&&a.contains(this.lock.parentNode))&&!(t.isText&&i.node&&i.node.isText&&i.nodeDOM.nodeValue==t.text&&3!=i.dirty&&yr(e,i.outerDeco)))&&i.update(t,e,r,n))return i.dom!=a&&(this.changed=!0),this.index++,!0}return!1},kr.prototype.addNode=function(t,e,r,n,o){this.top.children.splice(this.index++,0,ar.create(this.top,t,e,r,n,o)),this.changed=!0},kr.prototype.placeWidget=function(t,e,r){if(this.indexDate.now()-50?t.lastSelectionOrigin:null,a=Lr(t,i);if(!t.state.selection.eq(a)){var c=t.state.tr.setSelection(a);"pointer"==i?c.setMeta("pointer",!0):"key"==i&&c.scrollIntoView(),t.dispatch(c)}}else{var l=t.state.doc.resolve(e),u=l.sharedDepth(r);e=l.before(u+1),r=t.state.doc.resolve(r).after(u+1);var p,h,f=t.state.selection,d=function(t,e,r){var n=t.docView.parseRange(e,r),o=n.node,i=n.fromOffset,s=n.toOffset,a=n.from,c=n.to,l=t.root.getSelection(),u=null,p=l.anchorNode;if(p&&t.dom.contains(1==p.nodeType?p:p.parentNode)&&(u=[{node:p,offset:l.anchorOffset}],Ie(l)||u.push({node:l.focusNode,offset:l.focusOffset})),_e.chrome&&8===t.lastKeyCode)for(var h=s;h>i;h--){var f=o.childNodes[h-1],d=f.pmViewDesc;if("BR"==f.nodeType&&!d){s=h;break}if(!d||d.size)break}var m=t.state.doc,g=t.someProp("domParser")||et.fromSchema(t.state.schema),v=m.resolve(a),y=null,b=g.parse(o,{topNode:v.parent,topMatch:v.parent.contentMatchAt(v.index()),topOpen:!0,from:i,to:s,preserveWhitespace:!v.parent.type.spec.code||"full",editableContent:!0,findPositions:u,ruleFromNode:Gr,context:v});if(u&&null!=u[0].pos){var k=u[0].pos,_=u[1]&&u[1].pos;null==_&&(_=k),y={anchor:k+a,head:_+a}}return{doc:b,sel:y,from:a,to:c}}(t,e,r),m=t.state.doc,g=m.slice(d.from,d.to);8===t.lastKeyCode&&Date.now()-100=a?i-n:0)+(c-a),a=i}else if(c=c?i-n:0)+(a-c),c=i}return{start:i,endA:a,endB:c}}(g.content,d.doc.content,d.from,p,h);if(!v){if(!(n&&f instanceof ee&&!f.empty&&f.$head.sameParent(f.$anchor))||t.composing||d.sel&&d.sel.anchor!=d.sel.head){if(d.sel){var y=Zr(t,t.state.doc,d.sel);y&&!y.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(y))}return}v={start:f.from,endA:f.to,endB:f.to}}t.domChangeCount++,t.state.selection.fromt.state.selection.from&&v.start<=t.state.selection.from+2?v.start=t.state.selection.from:v.endA=t.state.selection.to-2&&(v.endB+=t.state.selection.to-v.endA,v.endA=t.state.selection.to)),_e.ie&&_e.ie_version<=11&&v.endB==v.start+1&&v.endA==v.start&&v.start>d.from&&"  "==d.doc.textBetween(v.start-d.from-1,v.start-d.from+1)&&(v.start--,v.endA--,v.endB--);var b,k=d.doc.resolveNoCache(v.start-d.from),_=d.doc.resolveNoCache(v.endB-d.from);if((_e.ios&&t.lastIOSEnter>Date.now()-100&&(!k.sameParent(_)||o.some((function(t){return"DIV"==t.nodeName})))||!k.sameParent(_)&&k.posv.start&&function(t,e,r,n,o){if(!n.parent.isTextblock||r-e<=o.pos-n.pos||Wr(n,!0,!1)r||Wr(s,!0,!1)e.content.size?null:Ur(t,e.resolve(r.anchor),e.resolve(r.head))}function Wr(t,e,r){for(var n=t.depth,o=e?t.end():t.pos;n>0&&(e||t.indexAfter(n)==t.node(n).childCount);)n--,o++,e=!1;if(r)for(var i=t.node(n).maybeChild(t.indexAfter(n));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function Kr(t,e){for(var r=[],n=e.content,o=e.openStart,i=e.openEnd;o>1&&i>1&&1==n.childCount&&1==n.firstChild.childCount;){o--,i--;var s=n.firstChild;r.push(s.type.name,s.type.hasRequiredAttrs()?s.attrs:null),n=s.content}var a=t.someProp("clipboardSerializer")||ht.fromSchema(t.state.schema),c=rn(),l=c.createElement("div");l.appendChild(a.serializeFragment(n,{document:c}));for(var u,p=l.firstChild;p&&1==p.nodeType&&(u=tn[p.nodeName.toLowerCase()]);){for(var h=u.length-1;h>=0;h--){for(var f=c.createElement(u[h]);l.firstChild;)f.appendChild(l.firstChild);l.appendChild(f)}p=l.firstChild}return p&&1==p.nodeType&&p.setAttribute("data-pm-slice",o+" "+i+" "+JSON.stringify(r)),{dom:l,text:t.someProp("clipboardTextSerializer",(function(t){return t(e)}))||e.content.textBetween(0,e.content.size,"\n\n")}}function Yr(t,e,r,n,o){var i,a,c=o.parent.type.spec.code;if(!r&&!e)return null;var l=e&&(n||c||!r);if(l){if(t.someProp("transformPastedText",(function(t){e=t(e)})),c)return new f(s.from(t.state.schema.text(e)),0,0);var u=t.someProp("clipboardTextParser",(function(t){return t(e,o)}));u?a=u:(i=document.createElement("div"),e.trim().split(/(?:\r\n?|\n)+/).forEach((function(t){i.appendChild(document.createElement("p")).textContent=t})))}else t.someProp("transformPastedHTML",(function(t){r=t(r)})),i=function(t){var e=/(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var r,n=rn().createElement("div"),o=/(?:]*>)*<([a-z][^>\s]+)/i.exec(t),i=0;(r=o&&tn[o[1].toLowerCase()])&&(t=r.map((function(t){return"<"+t+">"})).join("")+t+r.map((function(t){return""})).reverse().join(""),i=r.length);n.innerHTML=t;for(var s=0;s=0;c-=2){var l=n.nodes[r[c]];if(!l||l.hasRequiredAttrs())break;o=s.from(l.create(r[c+1],o)),i++,a++}return new f(o,i,a)}(function(t,e,r){e=0;n--){var o=r(n);if(o)return o.v}return t}(a.content,o),!1),t.someProp("transformPasted",(function(t){a=t(a)})),a}function Qr(t,e,r){void 0===r&&(r=0);for(var n=e.length-1;n>=r;n--)t=e[n].create(null,s.from(t));return t}function Xr(t,e,r,n,o,i){var a=e<0?t.firstChild:t.lastChild,c=a.content;return o=r&&(c=e<0?a.contentMatchAt(0).fillBefore(c,t.childCount>1||i<=o).append(c):c.append(a.contentMatchAt(a.childCount).fillBefore(s.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(c))}var tn={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},en=null;function rn(){return en||(en=document.implementation.createHTMLDocument("title"))}var nn={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},on=_e.ie&&_e.ie_version<=11,sn=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};sn.prototype.set=function(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset},sn.prototype.eq=function(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset};var an=function(t,e){var r=this;this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=!1,this.observer=window.MutationObserver&&new window.MutationObserver((function(t){for(var e=0;et.target.nodeValue.length}))?r.flushSoon():r.flush()})),this.currentSelection=new sn,on&&(this.onCharData=function(t){r.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),r.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};an.prototype.flushSoon=function(){var t=this;this.flushingSoon||(this.flushingSoon=!0,window.setTimeout((function(){t.flushingSoon=!1,t.flush()}),20))},an.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,nn),on&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},an.prototype.stop=function(){var t=this;if(this.observer){var e=this.observer.takeRecords();if(e.length){for(var r=0;r1){var l=s.filter((function(t){return"BR"==t.nodeName}));if(2==l.length){var u=l[0],p=l[1];u.parentNode&&u.parentNode.parentNode==p.parentNode?p.remove():u.remove()}}(n>-1||r)&&(n>-1&&(this.view.docView.markDirty(n,o),function(t){if(cn)return;cn=!0,"normal"==getComputedStyle(t.dom).whiteSpace&&console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.")}(this.view)),this.handleDOMChange(n,o,i,s),this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(e)||Rr(this.view))}},an.prototype.registerMutation=function(t,e){if(e.indexOf(t.target)>-1)return null;var r=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(r==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!r||r.ignoreMutation(t))return null;if("childList"==t.type){var n=t.previousSibling,o=t.nextSibling;if(_e.ie&&_e.ie_version<=11&&t.addedNodes.length)for(var i=0;ii.depth?e(t,r,i.nodeAfter,i.before(n),o,!0):e(t,r,i.node(n),i.before(n),o,!1)})))return{v:!0}},a=i.depth+1;a>0;a--){var c=s(a);if(c)return c.v}return!1}function gn(t,e,r){t.focused||t.focus();var n=t.state.tr.setSelection(e);"pointer"==r&&n.setMeta("pointer",!0),t.dispatch(n)}function vn(t,e,r,n,o){return mn(t,"handleClickOn",e,r,n)||t.someProp("handleClick",(function(r){return r(t,e,n)}))||(o?function(t,e){if(-1==e)return!1;var r,n,o=t.state.selection;o instanceof ne&&(r=o.node);for(var i=t.state.doc.resolve(e),s=i.depth+1;s>0;s--){var a=s>i.depth?i.nodeAfter:i.node(s);if(ne.isSelectable(a)){n=r&&o.$from.depth>0&&s>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(s);break}}return null!=n&&(gn(t,ne.create(t.state.doc,n),"pointer"),!0)}(t,r):function(t,e){if(-1==e)return!1;var r=t.state.doc.resolve(e),n=r.nodeAfter;return!!(n&&n.isAtom&&ne.isSelectable(n))&&(gn(t,new ne(r),"pointer"),!0)}(t,r))}function yn(t,e,r,n){return mn(t,"handleDoubleClickOn",e,r,n)||t.someProp("handleDoubleClick",(function(r){return r(t,e,n)}))}function bn(t,e,r,n){return mn(t,"handleTripleClickOn",e,r,n)||t.someProp("handleTripleClick",(function(r){return r(t,e,n)}))||function(t,e){var r=t.state.doc;if(-1==e)return!!r.inlineContent&&(gn(t,ee.create(r,0,r.content.size),"pointer"),!0);for(var n=r.resolve(e),o=n.depth+1;o>0;o--){var i=o>n.depth?n.nodeAfter:n.node(o),s=n.before(o);if(i.inlineContent)gn(t,ee.create(r,s+1,s+1+i.content.size),"pointer");else{if(!ne.isSelectable(i))continue;gn(t,ne.create(r,s),"pointer")}return!0}}(t,r)}function kn(t){return An(t)}un.keydown=function(t,e){t.shiftKey=16==e.keyCode||e.shiftKey,xn(t,e)||(t.lastKeyCode=e.keyCode,t.lastKeyCodeTime=Date.now(),!_e.ios||13!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey?t.someProp("handleKeyDown",(function(r){return r(t,e)}))||Ir(t,e)?e.preventDefault():pn(t,"key"):t.lastIOSEnter=Date.now())},un.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},un.keypress=function(t,e){if(!(xn(t,e)||!e.charCode||e.ctrlKey&&!e.altKey||_e.mac&&e.metaKey))if(t.someProp("handleKeyPress",(function(r){return r(t,e)})))e.preventDefault();else{var r=t.state.selection;if(!(r instanceof ee&&r.$from.sameParent(r.$to))){var n=String.fromCharCode(e.charCode);t.someProp("handleTextInput",(function(e){return e(t,r.$from.pos,r.$to.pos,n)}))||t.dispatch(t.state.tr.insertText(n).scrollIntoView()),e.preventDefault()}}};var _n=_e.mac?"metaKey":"ctrlKey";ln.mousedown=function(t,e){t.shiftKey=e.shiftKey;var r=kn(t),n=Date.now(),o="singleClick";n-t.lastClick.time<500&&function(t,e){var r=e.x-t.clientX,n=e.y-t.clientY;return r*r+n*n<100}(e,t.lastClick)&&!e[_n]&&("singleClick"==t.lastClick.type?o="doubleClick":"doubleClick"==t.lastClick.type&&(o="tripleClick")),t.lastClick={time:n,x:e.clientX,y:e.clientY,type:o};var i=t.posAtCoords(dn(e));i&&("singleClick"==o?t.mouseDown=new wn(t,i,e,r):("doubleClick"==o?yn:bn)(t,i.pos,i.inside,e)?e.preventDefault():pn(t,"pointer"))};var wn=function(t,e,r,n){var o,i,s=this;if(this.view=t,this.startDoc=t.state.doc,this.pos=e,this.event=r,this.flushed=n,this.selectNode=r[_n],this.allowDefault=r.shiftKey,e.inside>-1)o=t.state.doc.nodeAt(e.inside),i=e.inside;else{var a=t.state.doc.resolve(e.pos);o=a.parent,i=a.depth?a.before():0}this.mightDrag=null;var c=n?null:r.target,l=c?t.docView.nearestDesc(c,!0):null;this.target=l?l.dom:null,(o.type.spec.draggable&&!1!==o.type.spec.selectable||t.state.selection instanceof ne&&i==t.state.selection.from)&&(this.mightDrag={node:o,pos:i,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&_e.gecko&&!this.target.hasAttribute("contentEditable")}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((function(){return s.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),pn(t,"pointer")};function xn(t,e){return!!t.composing||!!(_e.safari&&Math.abs(e.timeStamp-t.compositionEndedAt)<500)&&(t.compositionEndedAt=-2e8,!0)}wn.prototype.done=function(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!1),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.view.mouseDown=null},wn.prototype.up=function(t){if(this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)){var e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(dn(t))),this.allowDefault||!e?pn(this.view,"pointer"):vn(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():!this.flushed&&(!_e.chrome||this.view.state.selection instanceof ee||e.pos!=this.view.state.selection.from&&e.pos!=this.view.state.selection.to)?pn(this.view,"pointer"):(gn(this.view,Qt.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault())}},wn.prototype.move=function(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0),pn(this.view,"pointer")},ln.touchdown=function(t){kn(t),pn(t,"pointer")},ln.contextmenu=function(t){return kn(t)};var Cn=_e.android?5e3:-1;function Sn(t,e){clearTimeout(t.composingTimeout),e>-1&&(t.composingTimeout=setTimeout((function(){return An(t)}),e))}function An(t,e){for(t.composing=!1;t.compositionNodes.length>0;)t.compositionNodes.pop().markParentsDirty();return!(!e&&!t.docView.dirty)&&(t.updateState(t.state),!0)}un.compositionstart=un.compositionupdate=function(t){if(!t.composing){t.domObserver.flush();var e=t.state,r=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((function(t){return!1===t.type.spec.inclusive}))))t.markCursor=t.state.storedMarks||r.marks(),An(t,!0),t.markCursor=null;else if(An(t),_e.gecko&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length)for(var n=t.root.getSelection(),o=n.focusNode,i=n.focusOffset;o&&1==o.nodeType&&0!=i;){var s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(3==s.nodeType){n.collapse(s,s.nodeValue.length);break}o=s,i=-1}t.composing=!0}Sn(t,Cn)},un.compositionend=function(t,e){t.composing&&(t.composing=!1,t.compositionEndedAt=e.timeStamp,Sn(t,20))};var En=_e.ie&&_e.ie_version<15||_e.ios&&_e.webkit_version<604;function Mn(t,e,r,n){var o=Yr(t,e,r,t.shiftKey,t.state.selection.$from);if(!t.someProp("handlePaste",(function(e){return e(t,n,o||f.empty)}))&&o){var i=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(o),s=i?t.state.tr.replaceSelectionWith(i,t.shiftKey):t.state.tr.replaceSelection(o);t.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste"))}}ln.copy=un.cut=function(t,e){var r=t.state.selection,n="cut"==e.type;if(!r.empty){var o=En?null:e.clipboardData,i=Kr(t,r.content()),s=i.dom,a=i.text;o?(e.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",a)):function(t,e){var r=t.dom.ownerDocument,n=r.body.appendChild(r.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";var o=getSelection(),i=r.createRange();i.selectNodeContents(e),t.dom.blur(),o.removeAllRanges(),o.addRange(i),setTimeout((function(){r.body.removeChild(n),t.focus()}),50)}(t,s),n&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},un.paste=function(t,e){var r=En?null:e.clipboardData,n=r&&r.getData("text/html"),o=r&&r.getData("text/plain");r&&(n||o||r.files.length)?(Mn(t,o,n,e),e.preventDefault()):function(t,e){var r=t.dom.ownerDocument,n=t.shiftKey||t.state.selection.$from.parent.type.spec.code,o=r.body.appendChild(r.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus(),setTimeout((function(){t.focus(),r.body.removeChild(o),n?Mn(t,o.value,null,e):Mn(t,o.textContent,o.innerHTML,e)}),50)}(t,e)};var Dn=function(t,e){this.slice=t,this.move=e},Tn=_e.mac?"altKey":"ctrlKey";for(var On in ln.dragstart=function(t,e){var r=t.mouseDown;if(r&&r.done(),e.dataTransfer){var n=t.state.selection,o=n.empty?null:t.posAtCoords(dn(e));if(o&&o.pos>=n.from&&o.pos<=(n instanceof ne?n.to-1:n.to));else if(r&&r.mightDrag)t.dispatch(t.state.tr.setSelection(ne.create(t.state.doc,r.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){var i=t.docView.nearestDesc(e.target,!0);if(!i||!i.node.type.spec.draggable||i==t.docView)return;t.dispatch(t.state.tr.setSelection(ne.create(t.state.doc,i.posBefore)))}var s=t.state.selection.content(),a=Kr(t,s),c=a.dom,l=a.text;e.dataTransfer.clearData(),e.dataTransfer.setData(En?"Text":"text/html",c.innerHTML),En||e.dataTransfer.setData("text/plain",l),t.dragging=new Dn(s,!e[Tn])}},ln.dragend=function(t){window.setTimeout((function(){return t.dragging=null}),50)},un.dragover=un.dragenter=function(t,e){return e.preventDefault()},un.drop=function(t,e){var r=t.dragging;if(t.dragging=null,e.dataTransfer){var n=t.posAtCoords(dn(e));if(n){var o=t.state.doc.resolve(n.pos);if(o){var i=r&&r.slice||Yr(t,e.dataTransfer.getData(En?"Text":"text/plain"),En?null:e.dataTransfer.getData("text/html"),!1,o);if(i&&(e.preventDefault(),!t.someProp("handleDrop",(function(n){return n(t,e,i,r&&r.move)})))){var s=i?Ft(t.state.doc,o.pos,i):o.pos;null==s&&(s=o.pos);var a=t.state.tr;r&&r.move&&a.deleteSelection();var c=a.mapping.map(s),l=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,u=a.doc;if(l?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),!a.doc.eq(u)){var p=a.doc.resolve(c);l&&ne.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild)?a.setSelection(new ne(p)):a.setSelection(Ur(t,p,a.doc.resolve(a.mapping.map(s)))),t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}}}}}},ln.focus=function(t){t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((function(){t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.root.getSelection())&&Rr(t)}),20))},ln.blur=function(t){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),t.domObserver.currentSelection.set({}),t.focused=!1)},ln.beforeinput=function(t,e){if(_e.chrome&&_e.android&&"deleteContentBackward"==e.inputType){var r=t.domChangeCount;setTimeout((function(){if(t.domChangeCount==r&&(t.dom.blur(),t.focus(),!t.someProp("handleKeyDown",(function(e){return e(t,Le(8,"Backspace"))})))){var e=t.state.selection.$cursor;e&&e.pos>0&&t.dispatch(t.state.tr.delete(e.pos-1,e.pos).scrollIntoView())}}),50)}},un)ln[On]=un[On];function qn(t,e){if(t==e)return!0;for(var r in t)if(t[r]!==e[r])return!1;for(var n in e)if(!(n in t))return!1;return!0}var zn=function(t,e){this.spec=e||Pn,this.side=this.spec.side||0,this.toDOM=t};zn.prototype.map=function(t,e,r,n){var o=t.mapResult(e.from+n,this.side<0?-1:1),i=o.pos;return o.deleted?null:new Ln(i-r,i-r,this)},zn.prototype.valid=function(){return!0},zn.prototype.eq=function(t){return this==t||t instanceof zn&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&qn(this.spec,t.spec))};var Nn=function(t,e){this.spec=e||Pn,this.attrs=t};Nn.prototype.map=function(t,e,r,n){var o=t.map(e.from+n,this.spec.inclusiveStart?-1:1)-r,i=t.map(e.to+n,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new Ln(o,i,this)},Nn.prototype.valid=function(t,e){return e.from=t&&(!o||o(s.spec))&&r.push(s.copy(s.from+n,s.to+n))}for(var a=0;at){var c=this.children[a]+1;this.children[a+2].findInner(t-c,e-c,r,n+c,o)}},Bn.prototype.map=function(t,e,r){return this==Vn||0==t.maps.length?this:this.mapInner(t,e,0,0,r||Pn)},Bn.prototype.mapInner=function(t,e,r,n,o){for(var i,s=0;sc+i||(e>=a[s]+i?a[s+1]=-1:(l=n-r-(e-t)+(i-o))&&(a[s]+=l,a[s+1]+=l))}},l=0;l=n.content.size){u=!0;continue}var d=r.map(t[p+1]+i,-1)-o,m=n.content.findIndex(f),g=m.index,v=m.offset,y=n.maybeChild(g);if(y&&v==f&&v+y.nodeSize==d){var b=a[p+2].mapInner(r,y,h+1,a[p]+i+1,s);b!=Vn?(a[p]=f,a[p+1]=d,a[p+2]=b):(a[p+1]=-2,u=!0)}else u=!0}if(u){var k=Gn(function(t,e,r,n,o,i,s){function a(t,e){for(var i=0;is&&l.to=t){this.children[o]==t&&(r=this.children[o+2]);break}for(var i=t+1,s=i+e.content.size,a=0;ai&&c.type instanceof Nn){var l=Math.max(i,c.from)-i,u=Math.min(s,c.to)-i;lr&&s.to0;)e++;t.splice(e,0,r)}function Kn(t){var e=[];return t.someProp("decorations",(function(r){var n=r(t.state);n&&n!=Vn&&e.push(n)})),t.cursorWrapper&&e.push(Bn.create(t.state.doc,[t.cursorWrapper.deco])),$n.from(e)}$n.prototype.forChild=function(t,e){if(e.isLeaf)return Bn.empty;for(var r=[],n=0;nn.scrollToSelection?"to selection":"preserve",k=o||!this.docView.matchesNode(t.doc,y,v),_=k||!t.selection.eq(n.selection),w="preserve"==b&&_&&null==this.dom.style.overflowAnchor&&function(t){for(var e,r,n=t.dom.getBoundingClientRect(),o=Math.max(0,n.top),i=(n.left+n.right)/2,s=o+1;s=o-20){e=a,r=c.top;break}}}return{refDOM:e,refTop:r,stack:Be(t.dom)}}(this);if(_){this.domObserver.stop();var x=k&&(_e.ie||_e.chrome)&&!n.selection.empty&&!t.selection.empty&&(l=n.selection,u=t.selection,p=Math.min(l.$anchor.sharedDepth(l.head),u.$anchor.sharedDepth(u.head)),l.$anchor.node(p)!=u.$anchor.node(p));k&&(!o&&this.docView.update(t.doc,y,v,this)||(this.docView.destroy(),this.docView=cr(t.doc,y,v,this.dom,this))),x||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(s=this,a=s.docView.domFromPos(s.state.selection.anchor),c=s.root.getSelection(),Te(a.node,a.offset,c.anchorNode,c.anchorOffset)))?Rr(this,x):($r(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(n),"reset"==b)this.dom.scrollTop=0;else if("to selection"==b){var C=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(t){return t(r)}))||(t.selection instanceof ne?Pe(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),C):Pe(this,this.coordsAtPos(t.selection.head),C))}else w&&(f=(h=w).refDOM,d=h.refTop,m=h.stack,g=f?f.getBoundingClientRect().top:0,Ve(m,0==g?0:g-d))},Yn.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},Yn.prototype.updatePluginViews=function(t){if(t&&t.plugins==this.state.plugins)for(var e=0;e",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},io="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),so="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),ao="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),co="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),lo="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),uo=io&&(co||+io[1]<57)||ao&&co,po=0;po<10;po++)no[48+po]=no[96+po]=String(po);for(po=1;po<=24;po++)no[po+111]="F"+po;for(po=65;po<=90;po++)no[po]=String.fromCharCode(po+32),oo[po]=String.fromCharCode(po);for(var ho in no)oo.hasOwnProperty(ho)||(oo[ho]=no[ho]);var fo="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function mo(t){var e,r,n,o,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(var a=0;a127)&&(n=no[r.keyCode])&&n!=o){var a=e[go(n,r,!0)];if(a&&a(t.state,t.dispatch,t))return!0}else if(i&&r.shiftKey){var c=e[go(o,r,!0)];if(c&&c(t.state,t.dispatch,t))return!0}return!1}}var bo=function(){};bo.prototype.append=function(t){return t.length?(t=bo.from(t),!this.length&&t||t.length<200&&this.leafAppend(t)||this.length<200&&t.leafPrepend(this)||this.appendInner(t)):this},bo.prototype.prepend=function(t){return t.length?bo.from(t).append(this):this},bo.prototype.appendInner=function(t){return new _o(this,t)},bo.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?bo.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},bo.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},bo.prototype.forEach=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=this.length),e<=r?this.forEachInner(t,e,r,0):this.forEachInvertedInner(t,e,r,0)},bo.prototype.map=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=this.length);var n=[];return this.forEach((function(e,r){return n.push(t(e,r))}),e,r),n},bo.from=function(t){return t instanceof bo?t:t&&t.length?new ko(t):bo.empty};var ko=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,r){return 0==t&&r==this.length?this:new e(this.values.slice(t,r))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,r,n){for(var o=e;o=r;o--)if(!1===t(this.values[o],n+o))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=200)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=200)return new e(t.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(e.prototype,r),e}(bo);bo.empty=new ko([]);var _o=function(t){function e(e,r){t.call(this),this.left=e,this.right=r,this.length=e.length+r.length,this.depth=Math.max(e.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return to&&!1===this.right.forEachInner(t,Math.max(e-o,0),Math.min(this.length,r)-o,n+o))&&void 0)},e.prototype.forEachInvertedInner=function(t,e,r,n){var o=this.left.length;return!(e>o&&!1===this.right.forEachInvertedInner(t,e-o,Math.max(r,o)-o,n+o))&&(!(r=r?this.right.slice(t-r,e-r):this.left.slice(t,r).append(this.right.slice(0,e-r))},e.prototype.leafAppend=function(t){var r=this.right.leafAppend(t);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(t){var r=this.left.leafPrepend(t);if(r)return new e(r,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(bo),wo=bo,xo=function(t,e){this.items=t,this.eventCount=e};xo.prototype.popEvent=function(t,e){var r=this;if(0==this.eventCount)return null;for(var n,o,i=this.items.length;;i--){if(this.items.get(i-1).selection){--i;break}}e&&(n=this.remapping(i,this.items.length),o=n.maps.length);var s,a,c=t.tr,l=[],u=[];return this.items.forEach((function(t,e){if(!t.step)return n||(n=r.remapping(i,e+1),o=n.maps.length),o--,void u.push(t);if(n){u.push(new Co(t.map));var p,h=t.step.map(n.slice(o));h&&c.maybeStep(h).doc&&(p=c.mapping.maps[c.mapping.maps.length-1],l.push(new Co(p,null,null,l.length+u.length))),o--,p&&n.appendMap(p,o)}else c.maybeStep(t.step);return t.selection?(s=n?t.selection.map(n.slice(o)):t.selection,a=new xo(r.items.slice(0,i).append(u.reverse().concat(l)),r.eventCount-1),!1):void 0}),this.items.length,0),{remaining:a,transform:c,selection:s}},xo.prototype.addTransform=function(t,e,r,n){for(var o=[],i=this.eventCount,s=this.items,a=!n&&s.length?s.get(s.length-1):null,c=0;cAo&&(f=m,(h=s).forEach((function(t,e){if(t.selection&&0==f--)return d=e,!1})),s=h.slice(d),i-=m),new xo(s.append(o),i)},xo.prototype.remapping=function(t,e){var r=new bt;return this.items.forEach((function(e,n){var o=null!=e.mirrorOffset&&n-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:null;r.appendMap(e.map,o)}),t,e),r},xo.prototype.addMaps=function(t){return 0==this.eventCount?this:new xo(this.items.append(t.map((function(t){return new Co(t)}))),this.eventCount)},xo.prototype.rebased=function(t,e){if(!this.eventCount)return this;var r=[],n=Math.max(0,this.items.length-e),o=t.mapping,i=t.steps.length,s=this.eventCount;this.items.forEach((function(t){t.selection&&s--}),n);var a=e;this.items.forEach((function(e){var n=o.getMirror(--a);if(null!=n){i=Math.min(i,n);var c=o.maps[n];if(e.step){var l=t.steps[n].invert(t.docs[n]),u=e.selection&&e.selection.map(o.slice(a+1,n));u&&s++,r.push(new Co(c,l,u))}else r.push(new Co(c))}}),n);for(var c=[],l=e;l500&&(p=p.compress(this.items.length-r.length)),p},xo.prototype.emptyItemCount=function(){var t=0;return this.items.forEach((function(e){e.step||t++})),t},xo.prototype.compress=function(t){void 0===t&&(t=this.items.length);var e=this.remapping(0,t),r=e.maps.length,n=[],o=0;return this.items.forEach((function(i,s){if(s>=t)n.push(i),i.selection&&o++;else if(i.step){var a=i.step.map(e.slice(r)),c=a&&a.getMap();if(r--,c&&e.appendMap(c,r),a){var l=i.selection&&i.selection.map(e.slice(r));l&&o++;var u,p=new Co(c.invert(),a,l),h=n.length-1;(u=n.length&&n[h].merge(p))?n[h]=u:n.push(p)}}else i.map&&r--}),this.items.length,0),new xo(wo.from(n.reverse()),o)},xo.empty=new xo(wo.empty,0);var Co=function(t,e,r,n){this.map=t,this.step=e,this.selection=r,this.mirrorOffset=n};Co.prototype.merge=function(t){if(this.step&&t.step&&!t.selection){var e=t.step.merge(this.step);if(e)return new Co(e.getMap().invert(),e,this.selection)}};var So=function(t,e,r,n){this.done=t,this.undone=e,this.prevRanges=r,this.prevTime=n},Ao=20;function Eo(t){var e=[];return t.forEach((function(t,r,n,o){return e.push(n,o)})),e}function Mo(t,e){if(!t)return null;for(var r=[],n=0;n=e[o]&&(r=!0)})),r}(r,t.prevRanges)),c=s?Mo(t.prevRanges,r.mapping):Eo(r.mapping.maps[r.steps.length-1]);return new So(t.done.addTransform(r,a?e.selection.getBookmark():null,n,qo(e)),xo.empty,c,r.time)}(r,n,e,t)}},config:t})}function Lo(t,e){var r=zo.getState(t);return!(!r||0==r.done.eventCount)&&(e&&Do(r,t,e,!1),!0)}function Ro(t,e){var r=zo.getState(t);return!(!r||0==r.undone.eventCount)&&(e&&Do(r,t,e,!0),!0)}function Fo(t,e){return!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0)}function Po(t,e){for(;t;t="start"==e?t.firstChild:t.lastChild)if(t.isTextblock)return!0;return!1}function Bo(t){if(!t.parent.type.spec.isolating)for(var e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Vo(t){if(!t.parent.type.spec.isolating)for(var e=t.depth-1;e>=0;e--){var r=t.node(e);if(t.index(e)+1=0;u--)l=s.from(n[u].create(null,l));l=s.from(i.copy(l));var p=t.tr.step(new Mt(e.pos-1,c,e.pos,c,new f(l,1,0),n.length,!0)),h=c+2*n.length;It(p.doc,h)&&p.join(h),r(p.scrollIntoView())}return!0}var d=Qt.findFrom(e,1),m=d&&d.$from.blockRange(d.$to),g=m&&Ot(m);return null!=g&&g>=e.depth&&(r&&r(t.tr.lift(m,g).scrollIntoView()),!0)}function Ko(t,e){return function(r,n){var o=r.selection,i=o.$from,s=o.$to,a=i.blockRange(s),c=a&&qt(a,t,e);return!!c&&(n&&n(r.tr.wrap(a,c).scrollIntoView()),!0)}}function Yo(t,e){return function(r,n){var o=r.selection,i=o.from,s=o.to,a=!1;return r.doc.nodesBetween(i,s,(function(n,o){if(a)return!1;if(n.isTextblock&&!n.hasMarkup(t,e))if(n.type==t)a=!0;else{var i=r.doc.resolve(o),s=i.index();a=i.parent.canReplaceWith(s,s+1,t)}})),!!a&&(n&&n(r.tr.setBlockType(i,s,t,e).scrollIntoView()),!0)}}function Qo(t,e){return function(r,n){var o=r.selection,i=o.empty,s=o.$cursor,a=o.ranges;if(i&&!s||!function(t,e,r){for(var n=function(n){var o=e[n],i=o.$from,s=o.$to,a=0==i.depth&&t.type.allowsMarkType(r);if(t.nodesBetween(i.pos,s.pos,(function(t){if(a)return!1;a=t.inlineContent&&t.type.allowsMarkType(r)})),a)return{v:!0}},o=0;o0))return!1;var o=Bo(n);if(!o){var i=n.blockRange(),s=i&&Ot(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)}var a=o.nodeBefore;if(!a.type.spec.isolating&&Wo(t,o,e))return!0;if(0==n.parent.content.size&&(Po(a,"end")||ne.isSelectable(a))){if(e){var c=t.tr.deleteRange(n.before(),n.after());c.setSelection(Po(a,"end")?Qt.findFrom(c.doc.resolve(c.mapping.map(o.pos,-1)),-1):ne.create(c.doc,o.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}return!(!a.isAtom||o.depth!=n.depth-1)&&(e&&e(t.tr.delete(o.pos-a.nodeSize,o.pos).scrollIntoView()),!0)}),(function(t,e,r){var n=t.selection.$cursor;if(!n||(r?!r.endOfTextblock("backward",t):n.parentOffset>0))return!1;var o=Bo(n),i=o&&o.nodeBefore;return!(!i||!ne.isSelectable(i))&&(e&&e(t.tr.setSelection(ne.create(t.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)})),ei=Xo(Fo,(function(t,e,r){var n=t.selection.$cursor;if(!n||(r?!r.endOfTextblock("forward",t):n.parentOffset1&&r.after()!=r.end(-1)){var n=r.before();if(Nt(t.doc,n))return e&&e(t.tr.split(n).scrollIntoView()),!0}var o=r.blockRange(),i=o&&Ot(o);return null!=i&&(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)}),Jo),"Mod-Enter":Go,Backspace:ti,"Mod-Backspace":ti,Delete:ei,"Mod-Delete":ei,"Mod-a":function(t,e){return e&&e(t.tr.setSelection(new ie(t.doc))),!0}},ni={"Ctrl-h":ri.Backspace,"Alt-Backspace":ri["Mod-Backspace"],"Ctrl-d":ri.Delete,"Ctrl-Alt-Backspace":ri["Mod-Delete"],"Alt-Delete":ri["Mod-Delete"],"Alt-d":ri["Mod-Delete"]};for(var oi in ri)ni[oi]=ri[oi];var ii=("undefined"!=typeof navigator?/Mac/.test(navigator.platform):"undefined"!=typeof os&&"darwin"==os.platform())?ni:ri;function si(t){return void 0===t&&(t={}),new ve({view:function(e){return new ai(e,t)}})}var ai=function(t,e){var r=this;this.editorView=t,this.width=e.width||1,this.color=e.color||"black",this.class=e.class,this.cursorPos=null,this.element=null,this.timeout=null,this.handlers=["dragover","dragend","drop","dragleave"].map((function(e){var n=function(t){return r[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}}))};ai.prototype.destroy=function(){var t=this;this.handlers.forEach((function(e){var r=e.name,n=e.handler;return t.editorView.dom.removeEventListener(r,n)}))},ai.prototype.update=function(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&this.updateOverlay()},ai.prototype.setCursor=function(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())},ai.prototype.updateOverlay=function(){var t,e=this.editorView.state.doc.resolve(this.cursorPos);if(!e.parent.inlineContent){var r=e.nodeBefore,n=e.nodeAfter;if(r||n){var o=this.editorView.nodeDOM(this.cursorPos-(r?r.nodeSize:0)).getBoundingClientRect(),i=r?o.bottom:o.top;r&&n&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:o.left,right:o.right,top:i-this.width/2,bottom:i+this.width/2}}}if(!t){var s=this.editorView.coordsAtPos(this.cursorPos);t={left:s.left-this.width/2,right:s.left+this.width/2,top:s.top,bottom:s.bottom}}var a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color);var c=!a||a==document.body&&"static"==getComputedStyle(a).position?{left:-pageXOffset,top:-pageYOffset}:a.getBoundingClientRect();this.element.style.left=t.left-c.left+"px",this.element.style.top=t.top-c.top+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"},ai.prototype.scheduleRemoval=function(t){var e=this;clearTimeout(this.timeout),this.timeout=setTimeout((function(){return e.setCursor(null)}),t)},ai.prototype.dragover=function(t){if(this.editorView.editable){var e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});if(e){var r=e.pos;this.editorView.dragging&&this.editorView.dragging.slice&&null==(r=Ft(this.editorView.state.doc,r,this.editorView.dragging.slice))&&(r=e.pos),this.setCursor(r),this.scheduleRemoval(5e3)}}},ai.prototype.dragend=function(){this.scheduleRemoval(20)},ai.prototype.drop=function(){this.scheduleRemoval(20)},ai.prototype.dragleave=function(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)};var ci=function(t){function e(e){t.call(this,e,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.map=function(r,n){var o=r.resolve(n.map(this.head));return e.valid(o)?new e(o):t.near(o)},e.prototype.content=function(){return f.empty},e.prototype.eq=function(t){return t instanceof e&&t.head==this.head},e.prototype.toJSON=function(){return{type:"gapcursor",pos:this.head}},e.fromJSON=function(t,r){if("number"!=typeof r.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new e(t.resolve(r.pos))},e.prototype.getBookmark=function(){return new li(this.anchor)},e.valid=function(t){var e=t.parent;if(e.isTextblock||!function(t){for(var e=t.depth;e>=0;e--){var r=t.index(e);if(0!=r)for(var n=t.node(e).child(r-1);;n=n.lastChild){if(0==n.childCount&&!n.inlineContent||n.isAtom||n.type.spec.isolating)return!0;if(n.inlineContent)return!1}}return!0}(t)||!function(t){for(var e=t.depth;e>=0;e--){var r=t.indexAfter(e),n=t.node(e);if(r!=n.childCount)for(var o=n.child(r);;o=o.firstChild){if(0==o.childCount&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}(t))return!1;var r=e.type.spec.allowGapCursor;if(null!=r)return r;var n=e.contentMatchAt(t.index()).defaultType;return n&&n.isTextblock},e.findFrom=function(t,r,n){if(!n&&e.valid(t))return t;for(var o=t.pos,i=null,s=t.depth;;s--){var a=t.node(s);if(r>0?t.indexAfter(s)0){i=a.maybeChild(r>0?t.indexAfter(s):t.index(s)-1);break}if(0==s)return null;o+=r;var c=t.doc.resolve(o);if(e.valid(c))return c}for(;i=r>0?i.firstChild:i.lastChild;){o+=r;var l=t.doc.resolve(o);if(e.valid(l))return l}return null},e}(Qt);ci.prototype.visible=!1,Qt.jsonID("gapcursor",ci);var li=function(t){this.pos=t};li.prototype.map=function(t){return new li(t.map(this.pos))},li.prototype.resolve=function(t){var e=t.resolve(this.pos);return ci.valid(e)?new ci(e):Qt.near(e)};var ui=yo({ArrowLeft:pi("horiz",-1),ArrowRight:pi("horiz",1),ArrowUp:pi("vert",-1),ArrowDown:pi("vert",1)});function pi(t,e){var r="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,n,o){var i=t.selection,s=e>0?i.$to:i.$from,a=i.empty;if(i instanceof ee){if(!o.endOfTextblock(r)||0==s.depth)return!1;a=!1,s=t.doc.resolve(e>0?s.after():s.before())}var c=ci.findFrom(s,e,a);return!!c&&(n&&n(t.tr.setSelection(new ci(c))),!0)}}function hi(t,e,r){if(!t.editable)return!1;var n=t.state.doc.resolve(e);if(!ci.valid(n))return!1;var o=t.posAtCoords({left:r.clientX,top:r.clientY}).inside;return!(o>-1&&ne.isSelectable(t.state.doc.nodeAt(o)))&&(t.dispatch(t.state.tr.setSelection(new ci(n))),!0)}function fi(t){if(!(t.selection instanceof ci))return null;var e=document.createElement("div");return e.className="ProseMirror-gapcursor",Bn.create(t.doc,[Ln.widget(t.selection.head,e,{key:"gapcursor"})])}function di(t){return(di="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var mi=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){!function(e){var r,n="function",o=function(t,e){return di(t)===e},i=function t(e,r){null!==r&&(Array.isArray(r)?r.map((function(r){return t(e,r)})):(s.isNode(r)||(r=document.createTextNode(r)),e.appendChild(r)))};function s(t,e){var r,a,c=arguments,l=1;if(t=s.isElement(t)?t:document.createElement(t),o(e,"object")&&!s.isNode(e)&&!Array.isArray(e))for(r in l++,e)a=e[r],r=s.attrMap[r]||r,o(r,n)?r(t,a):o(a,n)?t[r]=a:t.setAttribute(r,a);for(;lthis.maxHeight&&(this.maxHeight=this.menu.offsetHeight,this.menu.style.minHeight=this.maxHeight+"px"))},Fi.prototype.updateScrollCursor=function(){var t=this.editorView.root.getSelection();if(t.focusNode){var e=t.getRangeAt(0).getClientRects(),r=e[function(t){if(t.anchorNode==t.focusNode)return t.anchorOffset>t.focusOffset;return t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}(t)?0:e.length-1];if(r){var n=this.menu.getBoundingClientRect();if(r.topn.top){var o=function(t){for(var e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}(this.wrapper);o&&(o.scrollTop-=n.bottom-r.top)}}}},Fi.prototype.updateFloat=function(t){var e=this.wrapper,r=e.getBoundingClientRect(),n=t?Math.max(0,t.getBoundingClientRect().top):0;if(this.floating)if(r.top>=n||r.bottomwindow.innerHeight?"none":"",t&&(this.menu.style.top=n+"px")}else if(r.top=this.menu.offsetHeight+10){this.floating=!0;var i=this.menu.getBoundingClientRect();this.menu.style.left=i.left+"px",this.menu.style.width=i.width+"px",t&&(this.menu.style.top=n+"px"),this.menu.style.position="fixed",this.spacer=mi("div",{class:Ri+"-spacer",style:"height: "+i.height+"px"}),e.insertBefore(this.spacer,this.menu)}},Fi.prototype.destroy=function(){this.wrapper.parentNode&&this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)};function Pi(t,e){return function(r,n){var o=r.selection,i=o.$from,a=o.$to,c=i.blockRange(a),l=!1,u=c;if(!c)return!1;if(c.depth>=2&&i.node(c.depth-1).type.compatibleContent(t)&&0==c.startIndex){if(0==i.index(c.depth-1))return!1;var p=r.doc.resolve(c.start-2);u=new E(p,p,c.depth),c.endIndex=0;a--)i=s.from(r[a].type.create(r[a].attrs,i));t.step(new Mt(e.start-(n?2:0),e.end,e.start,e.end,new f(i,0,0),r.length,!0));for(var c=0,l=0;lc;a--)i-=o.child(a).nodeSize,n.delete(i-1,i+1);var l=n.doc.resolve(r.start),u=l.nodeAfter,p=0==r.startIndex,h=r.endIndex==o.childCount,d=l.node(-1),m=l.index(-1);if(!d.canReplace(m+(p?0:1),m+1,u.content.append(h?s.empty:s.from(o))))return!1;var g=l.pos,v=g+u.nodeSize;return n.step(new Mt(g-(p?1:0),v+(h?1:0),g+1,v-1,new f((p?s.empty:s.from(o.copy(s.empty))).append(h?s.empty:s.from(o.copy(s.empty))),p?0:1,h?0:1),p?0:1)),e(n.scrollIntoView()),!0}(e,r,a)))}}var Vi=function(t,e){var r;this.match=t,this.handler="string"==typeof e?(r=e,function(t,e,n,o){var i=r;if(e[1]){var s=e[0].lastIndexOf(e[1]);i+=e[0].slice(s+e[1].length);var a=(n+=s)-o;a>0&&(i=e[0].slice(s-a,s)+i,n=o)}return t.tr.insertText(i,n,o)}):e};function $i(t,e,r,n,o,i){if(t.composing)return!1;var s=t.state,a=s.doc.resolve(e);if(a.parent.type.spec.code)return!1;for(var c=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,null,"")+n,l=0;l=0;c--)s.step(a.steps[c].invert(a.docs[c]));var l=s.doc.resolve(i.from).marks();e(s.replaceWith(i.from,i.to,t.schema.text(i.text,l)))}return!0}}return!1}var Ui=new Vi(/--$/,"—"),Hi=new Vi(/\.\.\.$/,"…"),Gi=[new Vi(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),new Vi(/"$/,"”"),new Vi(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),new Vi(/'$/,"’")];function Ji(t,e,r,n){return new Vi(t,(function(t,o,i,s){var a=r instanceof Function?r(o):r,c=t.tr.delete(i,s),l=c.doc.resolve(i).blockRange(),u=l&&qt(l,e,a);if(!u)return null;c.wrap(l,u);var p=c.doc.resolve(i-1).nodeBefore;return p&&p.type==e&&It(c.doc,i-1)&&(!n||n(o,p))&&c.join(i-1),c}))}function Zi(t,e,r){return new Vi(t,(function(t,n,o,i){var s=t.doc.resolve(o),a=r instanceof Function?r(n):r;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e)?t.tr.delete(o,i).setBlockType(o,o,e,a):null}))}function Wi(t){var e=document.body.appendChild(document.createElement("div"));e.className="ProseMirror-prompt";var r=function(t){e.contains(t.target)||n()};setTimeout((function(){return window.addEventListener("mousedown",r)}),50);var n=function(){window.removeEventListener("mousedown",r),e.parentNode&&e.parentNode.removeChild(e)},o=[];for(var i in t.fields)o.push(t.fields[i].render());var s=document.createElement("button");s.type="submit",s.className="ProseMirror-prompt-submit",s.textContent="OK";var a=document.createElement("button");a.type="button",a.className="ProseMirror-prompt-cancel",a.textContent="Cancel",a.addEventListener("click",n);var c=e.appendChild(document.createElement("form"));t.title&&(c.appendChild(document.createElement("h5")).textContent=t.title),o.forEach((function(t){c.appendChild(document.createElement("div")).appendChild(t)}));var l=c.appendChild(document.createElement("div"));l.className="ProseMirror-prompt-buttons",l.appendChild(s),l.appendChild(document.createTextNode(" ")),l.appendChild(a);var u=e.getBoundingClientRect();e.style.top=(window.innerHeight-u.height)/2+"px",e.style.left=(window.innerWidth-u.width)/2+"px";var p=function(){var e=function(t,e){var r=Object.create(null),n=0;for(var o in t){var i=t[o],s=e[n++],a=i.read(s),c=i.validate(a);if(c)return Ki(s,c),null;r[o]=i.clean(a)}return r}(t.fields,o);e&&(n(),t.callback(e))};c.addEventListener("submit",(function(t){t.preventDefault(),p()})),c.addEventListener("keydown",(function(t){27==t.keyCode?(t.preventDefault(),n()):13!=t.keyCode||t.ctrlKey||t.metaKey||t.shiftKey?9==t.keyCode&&window.setTimeout((function(){e.contains(document.activeElement)||n()}),500):(t.preventDefault(),p())}));var h=c.elements[0];h&&h.focus()}function Ki(t,e){var r=t.parentNode,n=r.appendChild(document.createElement("div"));n.style.left=t.offsetLeft+t.offsetWidth+2+"px",n.style.top=t.offsetTop-5+"px",n.className="ProseMirror-invalid",n.textContent=e,setTimeout((function(){return r.removeChild(n)}),1500)}var Yi=function(t){this.options=t};Yi.prototype.read=function(t){return t.value},Yi.prototype.validateType=function(t){},Yi.prototype.validate=function(t){return!t&&this.options.required?"Required field":this.validateType(t)||this.options.validate&&this.options.validate(t)},Yi.prototype.clean=function(t){return this.options.clean?this.options.clean(t):t};var Qi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.render=function(){var t=document.createElement("input");return t.type="text",t.placeholder=this.options.label,t.value=this.options.value||"",t.autocomplete="off",t},e}(Yi);function Xi(t,e){for(var r=t.selection.$from,n=r.depth;n>=0;n--){var o=r.index(n);if(r.node(n).canReplaceWith(o,o,e))return!0}return!1}function ts(t,e){var r={label:e.title,run:t};for(var n in e)r[n]=e[n];return e.enable&&!0!==e.enable||e.select||(r[e.enable?"enable":"select"]=function(e){return t(e)}),new ki(r)}function es(t,e){var r=t.selection,n=r.from,o=r.$from,i=r.to;return r.empty?e.isInSet(t.storedMarks||o.marks()):t.doc.rangeHasMark(n,i,e)}function rs(t,e){var r={active:function(e){return es(e,t)},enable:!0};for(var n in e)r[n]=e[n];return ts(Qo(t),r)}function ns(t,e){return ts(Pi(t,e.attrs),e)}function is(t){var e,r,n,o={};if((e=t.marks.strong)&&(o.toggleStrong=rs(e,{title:"Toggle strong style",icon:Di.strong})),(e=t.marks.em)&&(o.toggleEm=rs(e,{title:"Toggle emphasis",icon:Di.em})),(e=t.marks.code)&&(o.toggleCode=rs(e,{title:"Toggle code font",icon:Di.code})),(e=t.marks.link)&&(o.toggleLink=(r=e,new ki({title:"Add or remove link",icon:Di.link,active:function(t){return es(t,r)},enable:function(t){return!t.selection.empty},run:function(t,e,n){if(es(t,r))return Qo(r)(t,e),!0;Wi({title:"Create a link",fields:{href:new Qi({label:"Link target",required:!0}),title:new Qi({label:"Title"})},callback:function(t){Qo(r,t)(n.state,n.dispatch),n.focus()}})}}))),(e=t.nodes.image)&&(o.insertImage=(n=e,new ki({title:"Insert image",label:"Image",enable:function(t){return Xi(t,n)},run:function(t,e,r){var o=t.selection,i=o.from,s=o.to,a=null;t.selection instanceof ne&&t.selection.node.type==n&&(a=t.selection.node.attrs),Wi({title:"Insert image",fields:{src:new Qi({label:"Location",required:!0,value:a&&a.src}),title:new Qi({label:"Title",value:a&&a.title}),alt:new Qi({label:"Description",value:a?a.alt:t.doc.textBetween(i,s," ")})},callback:function(t){r.dispatch(r.state.tr.replaceSelectionWith(n.createAndFill(t))),r.focus()}})}}))),(e=t.nodes.bullet_list)&&(o.wrapBulletList=ns(e,{title:"Wrap in bullet list",icon:Di.bulletList})),(e=t.nodes.ordered_list)&&(o.wrapOrderedList=ns(e,{title:"Wrap in ordered list",icon:Di.orderedList})),(e=t.nodes.blockquote)&&(o.wrapBlockQuote=function(t,e){var r={run:function(r,n){return Ko(t,e.attrs)(r,n)},select:function(r){return Ko(t,e.attrs instanceof Function?null:e.attrs)(r)}};for(var n in e)r[n]=e[n];return new ki(r)}(e,{title:"Wrap in block quote",icon:Di.blockquote})),(e=t.nodes.paragraph)&&(o.makeParagraph=Ii(e,{title:"Change to paragraph",label:"Plain"})),(e=t.nodes.code_block)&&(o.makeCodeBlock=Ii(e,{title:"Change to code block",label:"Code"})),e=t.nodes.heading)for(var i=1;i<=10;i++)o["makeHead"+i]=Ii(e,{title:"Change to heading "+i,label:"Level "+i,attrs:{level:i}});if(e=t.nodes.horizontal_rule){var s=e;o.insertHorizontalRule=new ki({title:"Insert horizontal rule",label:"Horizontal rule",enable:function(t){return Xi(t,s)},run:function(t,e){e(t.tr.replaceSelectionWith(s.create()))}})}var a=function(t){return t.filter((function(t){return t}))};return o.insertMenu=new Si(a([o.insertImage,o.insertHorizontalRule]),{label:"Insert"}),o.typeMenu=new Si(a([o.makeParagraph,o.makeCodeBlock,o.makeHead1&&new Mi(a([o.makeHead1,o.makeHead2,o.makeHead3,o.makeHead4,o.makeHead5,o.makeHead6]),{label:"Heading"})]),{label:"Type..."}),o.inlineMenu=[a([o.toggleStrong,o.toggleEm,o.toggleCode,o.toggleLink])],o.blockMenu=[a([o.wrapBulletList,o.wrapOrderedList,o.wrapBlockQuote,Ti,Oi,qi])],o.fullMenu=o.inlineMenu.concat([[o.insertMenu,o.typeMenu]],[[zi,Ni]],o.blockMenu),o}var ss="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function as(t,e){var r,n,o={};function i(t,r){if(e){var n=e[t];if(!1===n)return;n&&(t=n)}o[t]=r}if(i("Mod-z",Lo),i("Shift-Mod-z",Ro),i("Backspace",ji),ss||i("Mod-y",Ro),i("Alt-ArrowUp",$o),i("Alt-ArrowDown",jo),i("Mod-BracketLeft",Uo),i("Escape",Zo),(r=t.marks.strong)&&(i("Mod-b",Qo(r)),i("Mod-B",Qo(r))),(r=t.marks.em)&&(i("Mod-i",Qo(r)),i("Mod-I",Qo(r))),(r=t.marks.code)&&i("Mod-`",Qo(r)),(r=t.nodes.bullet_list)&&i("Shift-Ctrl-8",Pi(r)),(r=t.nodes.ordered_list)&&i("Shift-Ctrl-9",Pi(r)),(r=t.nodes.blockquote)&&i("Ctrl->",Ko(r)),r=t.nodes.hard_break){var a=r,c=Xo(Go,(function(t,e){return e(t.tr.replaceSelectionWith(a.create()).scrollIntoView()),!0}));i("Mod-Enter",c),i("Shift-Enter",c),ss&&i("Ctrl-Enter",c)}if((r=t.nodes.list_item)&&(i("Enter",(n=r,function(t,e){var r=t.selection,o=r.$from,i=r.$to,a=r.node;if(a&&a.isBlock||o.depth<2||!o.sameParent(i))return!1;var c=o.node(-1);if(c.type!=n)return!1;if(0==o.parent.content.size){if(2==o.depth||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(e){for(var l=s.empty,u=o.index(-1)>0,p=o.depth-(u?1:2);p>=o.depth-3;p--)l=s.from(o.node(p).copy(l));l=l.append(s.from(n.createAndFill()));var h=t.tr.replace(o.before(u?null:-1),o.after(-3),new f(l,u?3:2,2));h.setSelection(t.selection.constructor.near(h.doc.resolve(o.pos+(u?3:2)))),e(h.scrollIntoView())}return!0}var d=i.pos==o.end()?c.contentMatchAt(0).defaultType:null,m=t.tr.delete(o.pos,i.pos),g=d&&[null,{type:d}];return!!Nt(m.doc,o.pos,2,g)&&(e&&e(m.split(o.pos,2,g).scrollIntoView()),!0)})),i("Mod-[",Bi(r)),i("Mod-]",function(t){return function(e,r){var n=e.selection,o=n.$from,i=n.$to,a=o.blockRange(i,(function(e){return e.childCount&&e.firstChild.type==t}));if(!a)return!1;var c=a.startIndex;if(0==c)return!1;var l=a.parent,u=l.child(c-1);if(u.type!=t)return!1;if(r){var p=u.lastChild&&u.lastChild.type==l.type,h=s.from(p?t.create():null),d=new f(s.from(t.create(null,s.from(l.type.create(null,h)))),p?3:1,0),m=a.start,g=a.end;r(e.tr.step(new Mt(m-(p?3:1),g,m,g,d,1,!0)).scrollIntoView())}return!0}}(r))),(r=t.nodes.paragraph)&&i("Shift-Ctrl-0",Yo(r)),(r=t.nodes.code_block)&&i("Shift-Ctrl-\\",Yo(r)),r=t.nodes.heading)for(var l=1;l<=6;l++)i("Shift-Ctrl-"+l,Yo(r,{level:l}));if(r=t.nodes.horizontal_rule){var u=r;i("Mod-_",(function(t,e){return e(t.tr.replaceSelectionWith(u.create()).scrollIntoView()),!0}))}return o}function cs(t){var e,r=Gi.concat(Hi,Ui);return(e=t.nodes.blockquote)&&r.push(Ji(/^\s*>\s$/,e)),(e=t.nodes.ordered_list)&&r.push(function(t){return Ji(/^(\d+)\.\s$/,t,(function(t){return{order:+t[1]}}),(function(t,e){return e.childCount+e.attrs.order==+t[1]}))}(e)),(e=t.nodes.bullet_list)&&r.push(function(t){return Ji(/^\s*([-+*])\s$/,t)}(e)),(e=t.nodes.code_block)&&r.push(function(t){return Zi(/^```$/,t)}(e)),(e=t.nodes.heading)&&r.push(function(t,e){return Zi(new RegExp("^(#{1,"+e+"})\\s$"),t,(function(t){return{level:t[1].length}}))}(e,6)),function(t){var e=t.rules,r=new ve({state:{init:function(){return null},apply:function(t,e){var r=t.getMeta(this);return r||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:function(t,n,o,i){return $i(t,n,o,i,e,r)},handleDOMEvents:{compositionend:function(t){setTimeout((function(){var n=t.state.selection.$cursor;n&&$i(t,n.pos,n.pos,"",e,r)}))}}},isInputRules:!0});return r}({rules:r})}function ls(t){var e=[cs(t.schema),vo(as(t.schema,t.mapKeys)),vo(ii),si(),new ve({props:{decorations:fi,createSelectionBetween:function(t,e,r){if(e.pos==r.pos&&ci.valid(r))return new ci(r)},handleClick:hi,handleKeyDown:ui}})];return!1!==t.menuBar&&e.push(function(t){return new ve({view:function(e){return new Fi(e,t)}})}({floating:!1!==t.floatingMenu,content:t.menuContent||is(t.schema).fullMenu})),!1!==t.history&&e.push(Io()),e.concat(new ve({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}var us=r(22),ps=r.n(us),hs=new X({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:function(){return["p",0]}},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:function(){return["blockquote",0]}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:function(){return["div",["hr"]]}},heading:{attrs:{level:{default:1}},content:"(text | image)*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM:function(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",group:"block",code:!0,defining:!0,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:function(t){return{params:t.getAttribute("data-params")||""}}}],toDOM:function(t){return["pre",t.attrs.params?{"data-params":t.attrs.params}:{},["code",0]]}},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:"ol",getAttrs:function(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1,tight:t.hasAttribute("data-tight")}}}],toDOM:function(t){return["ol",{start:1==t.attrs.order?null:t.attrs.order,"data-tight":t.attrs.tight?"true":null},0]}},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:!1}},parseDOM:[{tag:"ul",getAttrs:function(t){return{tight:t.hasAttribute("data-tight")}}}],toDOM:function(t){return["ul",{"data-tight":t.attrs.tight?"true":null},0]}},list_item:{content:"paragraph block*",defining:!0,parseDOM:[{tag:"li"}],toDOM:function(){return["li",0]}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:function(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM:function(t){return["img",t.attrs]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:function(){return["br"]}}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:function(t){return"italic"==t&&null}}],toDOM:function(){return["em"]}},strong:{parseDOM:[{tag:"b"},{tag:"strong"},{style:"font-weight",getAttrs:function(t){return/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}}],toDOM:function(){return["strong"]}},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:function(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM:function(t){return["a",t.attrs]}},code:{parseDOM:[{tag:"code"}],toDOM:function(){return["code"]}}}});var fs=function(t,e){this.schema=t,this.stack=[{type:t.topNodeType,content:[]}],this.marks=p.none,this.tokenHandlers=e};function ds(t,e,r,n){return t.getAttrs?t.getAttrs(e,r,n):t.attrs instanceof Function?t.attrs(e):t.attrs}function ms(t,e){return t.noCloseToken||"code_inline"==e||"code_block"==e||"fence"==e}function gs(t){return"\n"==t[t.length-1]?t.slice(0,t.length-1):t}function vs(){}fs.prototype.top=function(){return this.stack[this.stack.length-1]},fs.prototype.push=function(t){this.stack.length&&this.top().content.push(t)},fs.prototype.addText=function(t){if(t){var e,r=this.top().content,n=r[r.length-1],o=this.schema.text(t,this.marks);n&&(e=function(t,e){if(t.isText&&e.isText&&p.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}(n,o))?r[r.length-1]=e:r.push(o)}},fs.prototype.openMark=function(t){this.marks=t.addToSet(this.marks)},fs.prototype.closeMark=function(t){this.marks=t.removeFromSet(this.marks)},fs.prototype.parseTokens=function(t){for(var e=0;e ",null,e,(function(){return t.renderContent(e)}))},code_block:function(t,e){t.write("```"+(e.attrs.params||"")+"\n"),t.text(e.textContent,!1),t.ensureNewLine(),t.write("```"),t.closeBlock(e)},heading:function(t,e){t.write(t.repeat("#",e.attrs.level)+" "),t.renderInline(e),t.closeBlock(e)},horizontal_rule:function(t,e){t.write(e.attrs.markup||"---"),t.closeBlock(e)},bullet_list:function(t,e){t.renderList(e," ",(function(){return(e.attrs.bullet||"*")+" "}))},ordered_list:function(t,e){var r=e.attrs.order||1,n=String(r+e.childCount-1).length,o=t.repeat(" ",n+2);t.renderList(e,o,(function(e){var o=String(r+e);return t.repeat(" ",n-o.length)+o+". "}))},list_item:function(t,e){t.renderContent(e)},paragraph:function(t,e){t.renderInline(e),t.closeBlock(e)},image:function(t,e){t.write("!["+t.esc(e.attrs.alt||"")+"]("+t.esc(e.attrs.src)+(e.attrs.title?" "+t.quote(e.attrs.title):"")+")")},hard_break:function(t,e,r,n){for(var o=n+1;o":"]("+t.esc(e.attrs.href)+(e.attrs.title?" "+t.quote(e.attrs.title):"")+")"}},code:{open:function(t,e,r,n){return _s(r.child(n),-1)},close:function(t,e,r,n){return _s(r.child(n-1),1)},escape:!1}});function _s(t,e){var r,n=/`+/g,o=0;if(t.isText)for(;r=n.exec(t.text);)o=Math.max(o,r[0].length);for(var i=o>0&&e>0?" `":"`",s=0;s0&&e<0&&(i+=" "),i}function ws(t,e,r,n){if(t.attrs.title||!/^\w+:/.test(t.attrs.href))return!1;var o=e.child(r+(n<0?-1:0));if(!o.isText||o.text!=t.attrs.href||o.marks[o.marks.length-1]!=t)return!1;if(r==(n<0?1:e.childCount-1))return!0;var i=e.child(r+(n<0?-2:1));return!t.isInSet(i.marks)}var xs=function(t,e,r){this.nodes=t,this.marks=e,this.delim=this.out="",this.closed=!1,this.inTightList=!1,this.options=r||{},void 0===this.options.tightLists&&(this.options.tightLists=!1)};xs.prototype.flushClose=function(t){if(this.closed){if(this.atBlank()||(this.out+="\n"),null==t&&(t=2),t>1){var e=this.delim,r=/\s+$/.exec(e);r&&(e=e.slice(0,e.length-r[0].length));for(var n=1;ny?a=a.slice(0,y).concat(v).concat(a.slice(y,g)).concat(a.slice(g+1,m)):y>g&&(a=a.slice(0,g).concat(a.slice(g+1,y)).concat(v).concat(a.slice(y,m)));continue t}}}for(var k=0;k0&&e>0?" `":"`",s=0;s0&&e<0&&(i+=" "),i}function Ds(t,e,r,n){if(t.attrs.title||!/^\w+:/.test(t.attrs.href))return!1;var o=e.child(r+(n<0?-1:0));if(!o.isText||o.text!=t.attrs.href||o.marks[o.marks.length-1]!=t)return!1;if(r==(n<0?1:e.childCount-1))return!0;var i=e.child(r+(n<0?-2:1));return!t.isInSet(i.marks)}var Ts=new ks({readmore:function(t,e){t.write("\x3c!--more--\x3e\n"),t.closeBlock(e)},code_block:function(t,e){t.write("```".concat(e.attrs.params||"","\n")),t.text(e.textContent,!1),t.ensureNewLine(),t.write("```"),t.closeBlock(e)},heading:function(t,e){t.write("".concat(t.repeat("#",e.attrs.level)," ")),t.renderInline(e),t.closeBlock(e)},bullet_list:function(t,e){t.renderList(e," ",(function(){return"".concat(e.attrs.bullet||"*"," ")}))},ordered_list:function(t,e){var r=e.attrs.order||1,n=String(r+e.childCount-1).length,o=t.repeat(" ",n+2);t.renderList(e,o,(function(e){var o=String(r+e);return"".concat(t.repeat(" ",n-o.length)+o,". ")}))},list_item:function(t,e){t.renderContent(e)},paragraph:function(t,e){t.renderInline(e),t.closeBlock(e)},image:function(t,e){t.write("![".concat(t.esc(e.attrs.alt||""),"](").concat(t.esc(e.attrs.src)).concat(e.attrs.title?" ".concat(t.quote(e.attrs.title)):"",")"))},hard_break:function(t,e,r,n){for(var o=n+1;o":"](".concat(t.esc(e.attrs.href)).concat(e.attrs.title?" ".concat(t.quote(e.attrs.title)):"",")")}},code:{open:function(t,e,r,n){return Ms(r.child(n),-1)},close:function(t,e,r,n){return Ms(r.child(n-1),1)},escape:!1}});function Os(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e=0;o--){var i=n.index(o);if(n.node(o).canReplaceWith(i,i,e,r))return!0}return!1}(t,As.nodes.readmore)},run:function(t,e){e(t.tr.replaceSelectionWith(As.nodes.readmore.create()))}});function zs(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e {{if .Editing}}Editing {{if .Post.Title}}{{.Post.Title}}{{else}}{{.Post.Id}}{{end}}{{else}}New Post{{end}} — {{.SiteName}}
{{if not .SingleUser}}

{{if .Chorus}}{{else}}{{end}}{{.SiteName}}

{{end}}
{{if .Editing}}{{end}}
{{end}} diff --git a/templates/wysiwyg.tmpl b/templates/classic.tmpl similarity index 99% rename from templates/wysiwyg.tmpl rename to templates/classic.tmpl index 235c590..42a6bce 100644 --- a/templates/wysiwyg.tmpl +++ b/templates/classic.tmpl @@ -1,400 +1,401 @@ {{define "pad"}} {{if .Editing}}Editing {{if .Post.Title}}{{.Post.Title}}{{else}}{{.Post.Id}}{{end}}{{else}}New Post{{end}} — {{.SiteName}}
{{if not .SingleUser}}

{{end}}
{{if .Editing}}{{end}}
{{end}} diff --git a/templates/pad.tmpl b/templates/pad.tmpl index 049ac27..8da063e 100644 --- a/templates/pad.tmpl +++ b/templates/pad.tmpl @@ -1,423 +1,420 @@ {{define "pad"}} {{if .Editing}}Editing {{if .Post.Title}}{{.Post.Title}}{{else}}{{.Post.Id}}{{end}}{{else}}New Post{{end}} — {{.SiteName}}
{{if not .SingleUser}}

{{end}}
{{if .Editing}}{{end}}
{{end}}