From 375941efc4a298087bccc9b1bcc6cb4218e0082a Mon Sep 17 00:00:00 2001 From: "Silas J. Matson" Date: Tue, 4 Jul 2017 17:38:39 -0700 Subject: [PATCH 1/3] Refactor ApiController to return JSON so thesis can redirect to the proper page. * Change index on thesis_pages.slug to be unique --- apps/example/mix.lock | 4 +- ...70704234140_add_a_unique_index_on_slug.exs | 20 ++++++++++ .../test/controllers/page_controller_test.exs | 39 ++++++++++++++++--- apps/example/test/ecto_store_test.exs | 31 +++++++-------- apps/example/web/static/js/app.js | 2 +- lib/mix/tasks/thesis.install.ex | 3 +- lib/thesis/api_controller.ex | 12 ++++-- lib/thesis/models/page.ex | 13 ++++++- lib/thesis/stores/ecto_store.ex | 13 ++++--- lib/thesis/stores/store.ex | 6 +-- lib/thesis/utilities.ex | 26 ++++++++++--- lib/thesis/views/api_view.ex | 38 ++++++++++++++++++ mix.exs | 3 +- priv/static/thesis.js | 2 +- .../add_a_unique_index_on_slug.exs | 20 ++++++++++ .../thesis.install/add_indexes_to_tables.exs | 2 +- web/static/js/components/thesis-editor.js | 6 +-- web/static/js/external.js | 8 ++-- 18 files changed, 192 insertions(+), 56 deletions(-) create mode 100644 apps/example/priv/repo/migrations/20170704234140_add_a_unique_index_on_slug.exs create mode 100644 lib/thesis/views/api_view.ex create mode 100644 priv/templates/thesis.install/add_a_unique_index_on_slug.exs diff --git a/apps/example/mix.lock b/apps/example/mix.lock index 93be668..6363be0 100644 --- a/apps/example/mix.lock +++ b/apps/example/mix.lock @@ -8,13 +8,13 @@ "fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], [], "hexpm"}, "gettext": {:hex, :gettext, "0.12.1", "c0624f52763469ef7a3674919ae28b8286d88195b90fa1516180f31bbbd26d14", [:mix], [], "hexpm"}, "hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "4.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, - "html_sanitize_ex": {:hex, :html_sanitize_ex, "1.0.1", "2572e7122c78ab7e57b613e7c7f5e42bf9b3c25e430e32f23f1413d86db8a0af", [:mix], [{:mochiweb, "~> 2.12.2", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm"}, + "html_sanitize_ex": {:hex, :html_sanitize_ex, "1.3.0", "f005ad692b717691203f940c686208aa3d8ffd9dd4bb3699240096a51fa9564e", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm"}, "httpoison": {:hex, :httpoison, "0.11.1", "d06c571274c0e77b6cc50e548db3fd7779f611fbed6681fd60a331f66c143a0b", [:mix], [{:hackney, "~> 1.7.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], [], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [:mix], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, - "mochiweb": {:hex, :mochiweb, "2.12.2", "80804ad342afa3d7f3524040d4eed66ce74b17a555de454ac85b07c479928e46", [:make, :rebar], [], "hexpm"}, + "mochiweb": {:hex, :mochiweb, "2.15.0", "e1daac474df07651e5d17cc1e642c4069c7850dc4508d3db7263a0651330aacc", [:rebar3], [], "hexpm"}, "phoenix": {:hex, :phoenix, "1.2.1", "6dc592249ab73c67575769765b66ad164ad25d83defa3492dc6ae269bd2a68ab", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.1", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_ecto": {:hex, :phoenix_ecto, "3.0.1", "42eb486ef732cf209d0a353e791806721f33ff40beab0a86f02070a5649ed00a", [:mix], [{:ecto, "~> 2.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.6", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_html": {:hex, :phoenix_html, "2.7.0", "19e12e2044340c2e43df206a06d059677c59ea1868bd1c35165438d592cd420b", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, diff --git a/apps/example/priv/repo/migrations/20170704234140_add_a_unique_index_on_slug.exs b/apps/example/priv/repo/migrations/20170704234140_add_a_unique_index_on_slug.exs new file mode 100644 index 0000000..c3c2a3d --- /dev/null +++ b/apps/example/priv/repo/migrations/20170704234140_add_a_unique_index_on_slug.exs @@ -0,0 +1,20 @@ +defmodule Example.Repo.Migrations.AddAUniqueIndexOnSlug do + @moduledoc false + use Ecto.Migration + + def up do + # Rreate old non-unique index + drop index(:thesis_pages, [:slug]) + + # Create a Unique Index + create unique_index(:thesis_pages, [:slug]) + end + + def down do + # Remove unique index + drop unique_index(:thesis_pages, :slug) + + # Create old non-unique index + create index(:thesis_pages, [:slug]) + end +end diff --git a/apps/example/test/controllers/page_controller_test.exs b/apps/example/test/controllers/page_controller_test.exs index ed6762a..22fed17 100644 --- a/apps/example/test/controllers/page_controller_test.exs +++ b/apps/example/test/controllers/page_controller_test.exs @@ -12,10 +12,23 @@ defmodule Example.PageControllerTest do assert html_response(conn, 200) =~ "

Help

" payload = %{ - "page" => %{"slug" => "/", "title" => "", "description" => "","redirect_url" => nil,"template" => nil}, - "contents" => [%{"name" => "Help","content_type" => "html","content" => "

Updated content area

", "meta" => "{\"global\":null,\"classes\":\"\"}","global" => nil}] + "page" => %{"slug" => "/", "title" => "", "description" => "", + "redirect_url" => nil,"template" => nil}, + "contents" => [%{"name" => "Help","content_type" => "html", + "content" => "

Updated content area

", + "meta" => "{\"global\":null,\"classes\":\"\"}", + "global" => nil}] } - conn = put conn, "/thesis/update", payload + response = conn + |> put("/thesis/update", payload) + |> json_response(200) + assert response["id"] != nil + assert response["slug"] == "/" + assert response["title"] == nil + assert response["description"] == nil + assert response["template"] == nil + assert response["redirect_url"] == nil + assert response["page_contents"] == [] conn = get conn, "/" refute html_response(conn, 200) =~ "

Help

" @@ -29,10 +42,24 @@ defmodule Example.PageControllerTest do # Updated content payload = %{ - "page" => %{"slug" => "/about", "title" => "", "description" => "","redirect_url" => nil,"template" => nil}, - "contents" => [%{"name" => "Resources","content_type" => "html","content" => "

Updated content area

", "meta" => "{\"global\":null,\"classes\":\"\"}","global" => nil}] + "page" => %{"slug" => "/about", "title" => "", "description" => "", + "redirect_url" => nil,"template" => nil}, + "contents" => [%{"name" => "Resources","content_type" => "html", + "content" => "

Updated content area

", + "meta" => "{\"global\":null,\"classes\":\"\"}", + "global" => nil}] } - conn = put conn, "/thesis/update", payload + response = conn + |> put("/thesis/update", payload) + |> json_response(200) + assert response["id"] != nil + assert response["slug"] == "/about" + assert response["title"] == nil + assert response["description"] == nil + assert response["template"] == nil + assert response["redirect_url"] == nil + assert response["page_contents"] == [] + # Verify content was updated and default is gone conn = get conn, "/about" diff --git a/apps/example/test/ecto_store_test.exs b/apps/example/test/ecto_store_test.exs index 0b325ae..b1e2777 100644 --- a/apps/example/test/ecto_store_test.exs +++ b/apps/example/test/ecto_store_test.exs @@ -16,25 +16,25 @@ defmodule EctoStoreTest do slug = random_slug last_pc_id = last_updated(PageContent) && last_updated(PageContent) || 0 - :ok = @store.update(valid_static_page(slug), [valid_text_page_content]) + {:ok, page} = @store.update(valid_static_page(slug), [valid_text_page_content]) - assert last_updated(Page).slug == "/" <> slug + assert page.slug == "/" <> slug assert last_updated(PageContent).id > last_pc_id end test "Save global content to a page not edited before" do slug = random_slug - :ok = @store.update(valid_static_page(slug), [valid_global_content]) + {:ok, page} = @store.update(valid_static_page(slug), [valid_global_content]) - assert last_updated(Page).slug == "/" <> slug + assert page.slug == "/" <> slug assert last_updated(PageContent).page_id == nil end test "Save more than one areas at the same time" do - :ok = @store.update(valid_static_page, [valid_text_page_content, valid_html_page_content, valid_global_content]) + {:ok, page} = @store.update(valid_static_page, [valid_text_page_content, valid_html_page_content, valid_global_content]) - assert last_updated(Page).slug == valid_static_page["slug"] + assert page.slug == valid_static_page["slug"] last_3 = last_updated(PageContent, 3) assert Enum.at(last_3, 0).content_type == "text" assert Enum.at(last_3, 1).content_type == "html" @@ -42,7 +42,7 @@ defmodule EctoStoreTest do end test "Save global area on one page; retrieve on a different page that's not yet in database" do - :ok = @store.update(valid_static_page, [valid_global_content]) + {:ok, _page} = @store.update(valid_static_page, [valid_global_content]) records = @store.page_contents("/" <> random_slug) @@ -52,8 +52,8 @@ defmodule EctoStoreTest do test "Retrieves page content as well as well as global content saved on a different page" do slug = random_slug - :ok = @store.update(valid_static_page(random_slug), [valid_global_content]) - :ok = @store.update(valid_static_page(slug), [valid_html_page_content]) + {:ok, _page} = @store.update(valid_static_page(slug), [valid_global_content]) + {:ok, _page} = @store.update(valid_static_page(slug), [valid_html_page_content]) records = @store.page_contents("/" <> slug) @@ -62,12 +62,11 @@ defmodule EctoStoreTest do test "First adds page, then deletes page found by slug" do slug = random_slug - :ok = @store.update(valid_static_page(slug), [valid_html_page_content]) + {:ok, page} = @store.update(valid_static_page(slug), [valid_html_page_content]) - assert @store.page("/" <> slug).slug == "/" <> slug - assert last_updated(Page).slug == "/" <> slug + assert page.slug == "/" <> slug - :ok = @store.delete(valid_static_page(slug)) + {:ok, _} = @store.delete(valid_static_page(slug)) refute @store.page("/" <> slug) end @@ -79,19 +78,17 @@ defmodule EctoStoreTest do pc2 = %{"name" => "B", "content_type" => "text", "content" => "Yo"} pc3 = %{"name" => "C", "content_type" => "raw_html", "content" => "Wat", "global" => "true"} - :ok = store.update(%{"slug" => "/test"}, [pc1, pc2, pc3]) + {:ok, page1} = store.update(%{"slug" => "/test"}, [pc1, pc2, pc3]) pc4 = %{"name" => "D", "content_type" => "text", "content" => "Other page"} pc5 = %{"name" => "E", "content_type" => "html", "content" => "

Other global

", "global" => "true"} - :ok = store.update(%{"slug" => "/asdf"}, [pc4, pc5]) + {:ok, page2} = store.update(%{"slug" => "/asdf"}, [pc4, pc5]) - page1 = store.page("/test") assert is_integer(page1.id) assert page1.id > 0 assert page1.slug == "/test" - page2 = store.page("/asdf") assert is_integer(page2.id) assert page2.id > 0 assert page2.slug == "/asdf" diff --git a/apps/example/web/static/js/app.js b/apps/example/web/static/js/app.js index e7549b9..44dc104 100644 --- a/apps/example/web/static/js/app.js +++ b/apps/example/web/static/js/app.js @@ -11,7 +11,7 @@ // // If you no longer want to use a dependency, remember // to also remove its path from "config.paths.watched". -import "phoenix_html" +// import "phoenix_html" // Import local files // diff --git a/lib/mix/tasks/thesis.install.ex b/lib/mix/tasks/thesis.install.ex index 1acd56e..57a8ded 100644 --- a/lib/mix/tasks/thesis.install.ex +++ b/lib/mix/tasks/thesis.install.ex @@ -8,7 +8,8 @@ defmodule Mix.Tasks.Thesis.Install do "add_indexes_to_tables", "add_template_and_redirect_url_to_thesis_pages", "change_content_default_for_page_content", - "create_thesis_files_table" + "create_thesis_files_table", + "add_a_unique_index_on_slug" ] @template_files [ {"priv/templates/thesis.install/thesis_auth.exs", "lib/thesis_auth.ex"} diff --git a/lib/thesis/api_controller.ex b/lib/thesis/api_controller.ex index a962bee..6e7c1c2 100644 --- a/lib/thesis/api_controller.ex +++ b/lib/thesis/api_controller.ex @@ -10,13 +10,17 @@ defmodule Thesis.ApiController do def assets(conn, _params), do: conn def update(conn, %{"contents" => contents, "page" => page}) do - :ok = store.update(page, contents) - json conn, %{} + {:ok, page} = store.update(page, contents) + conn + |> assign(:thesis_page, page) + |> render "page.json" end def delete(conn, %{"path" => path}) do - :ok = store.delete(%{"slug" => path}) - json conn, %{} + {:ok, page} = store.delete(%{"slug" => path}) + conn + |> assign(:thesis_page, page) + |> render "page.json" end def import_file(conn, %{"image_url" => ""}), do: json conn, %{path: ""} diff --git a/lib/thesis/models/page.ex b/lib/thesis/models/page.ex index ead86e8..44097b5 100644 --- a/lib/thesis/models/page.ex +++ b/lib/thesis/models/page.ex @@ -4,7 +4,8 @@ defmodule Thesis.Page do title, description, and redirect if necessary. """ use Ecto.Schema - import Ecto.Changeset, only: [cast: 3, validate_required: 2] + import Ecto.Changeset, only: [cast: 3, validate_required: 2, fetch_field: 2, put_change: 3, unique_constraint: 2] + import Thesis.Utilities, only: [slugify: 1] @type t :: %Thesis.Page{ id: any, @@ -52,7 +53,17 @@ defmodule Thesis.Page do def changeset(page, params \\ %{}) do page |> cast(params, @valid_attributes) + |> unique_constraint(:slug) |> validate_required(@required_attributes) + |> parameterize_slug + end + + defp parameterize_slug(changeset) do + if {:data, slug} = fetch_field(changeset, :slug) do + put_change(changeset, :slug, slugify(slug)) + else + changeset + end end end diff --git a/lib/thesis/stores/ecto_store.ex b/lib/thesis/stores/ecto_store.ex index 4534849..6e27510 100644 --- a/lib/thesis/stores/ecto_store.ex +++ b/lib/thesis/stores/ecto_store.ex @@ -84,8 +84,11 @@ defmodule Thesis.EctoStore do """ def update(page_params, contents_params) do page = save_page(page_params) - save_page_contents(page, contents_params) - :ok + + case save_page_contents(page, contents_params) do + :ok -> {:ok, page} + :error -> {:error, page} + end end @doc """ @@ -94,7 +97,7 @@ defmodule Thesis.EctoStore do def delete(%{"slug" => slug}) do page = page(slug) repo.delete!(page) - :ok + {:ok, page} end defp save_page(%{"slug" => slug} = page_params) do @@ -108,8 +111,8 @@ defmodule Thesis.EctoStore do preloaded_contents = page_contents(page) contents_params - |> Enum.map(fn(x) -> content_changeset(x, page, preloaded_contents) end) - |> Enum.each(fn(x) -> repo.insert_or_update!(x) end) + |> Enum.map(&(content_changeset(&1, page, preloaded_contents))) + |> Enum.each(&(repo.insert_or_update!(&1))) :ok end diff --git a/lib/thesis/stores/store.ex b/lib/thesis/stores/store.ex index feea3d5..af8c402 100644 --- a/lib/thesis/stores/store.ex +++ b/lib/thesis/stores/store.ex @@ -20,14 +20,14 @@ defmodule Thesis.Store do @doc """ Updates the given page (identified by its slug) with the given map of - string keys and Thesis.PageContent structs. Returns `:ok`. + string keys and Thesis.PageContent structs. Returns tuple `{:ok, page}`. update(%{"slug" => "/"}, %{"Heading" => "My Heading Content"}) """ - @callback update(%{String.t => String.t}, map) :: atom + @callback update(%{String.t => String.t}, map) :: {atom, Thesis.Page.t} @doc """ - Deletes the given page (identified by its slug). Returns `:ok`. + Deletes the given page (identified by its slug). Returns tuple `{:ok, page}`. delete(%{"slug" => "/asdf"}) """ diff --git a/lib/thesis/utilities.ex b/lib/thesis/utilities.ex index acea290..151ea56 100644 --- a/lib/thesis/utilities.ex +++ b/lib/thesis/utilities.ex @@ -5,22 +5,36 @@ defmodule Thesis.Utilities do @doc """ - Removes special characters, keeps dashes and underscores, and replaces spaces - with dashes. Also downcases the entire string. + Slugifies the url and then removes slashes iex> import Thesis.Utilities iex> parameterize("Jamon is so cool!") "jamon-is-so-cool" - iex> parameterize("%#d50SDF dfsJ FDS lkdsf f dfka a") + iex> parameterize("%#d50SDF dfsJ FDS / lkdsf f dfka a") "d50sdf-dfsj-fds--lkdsf-f-dfka---a" """ def parameterize(str) do - str = Regex.replace(~r/[^a-z0-9\-\s\.]/i, str, "") - Regex.split(~r/\%20|\s/, str) - |> Enum.join("-") + str + |> slugify + |> String.replace(~r/\//i, "") |> String.downcase end + @doc """ + Removes special characters, keeps dashes and underscores, and replaces spaces + with dashes. + + iex> import Thesis.Utilities + iex> slugify("Jamon is so cool!") + "Jamon-is-so-cool" + iex> slugify("%#d50SDF dfsJ FDS/lkdsf f dfka a") + "d50SDF-dfsJ-FDS/lkdsf-f-dfka---a" + """ + def slugify(str) do + str = Regex.replace(~r/[^A-z0-9\-\s\.\/]/i, str, "") + Regex.split(~r/\%20|\s/, str) + |> Enum.join("-") + end @doc """ Generates a random string of letters of a given length. diff --git a/lib/thesis/views/api_view.ex b/lib/thesis/views/api_view.ex new file mode 100644 index 0000000..838a0e0 --- /dev/null +++ b/lib/thesis/views/api_view.ex @@ -0,0 +1,38 @@ +defmodule Thesis.ApiView do + use Thesis.View, :view + + + def render("page.json", %{thesis_page: page} = assigns) do + %{ + id: page.id, + slug: page.slug, + title: page.title, + redirect_url: page.redirect_url, + page_contents: render("page_contents.json", assigns[:page_contents]), + inserted_at: page.inserted_at, + updated_at: page.updated_at + } + end + def render("page.json", nil), do: %{} + + def render("page_contents.json", page_contents) + when is_nil(page_contents), do: [] + def render("page_contents.json", page_contents) when is_list(page_contents) do + Enum.map(page_contents, fn(page_content) -> + render("page_content.json", page_content) + end) + end + + def render("page_content.json", page_content) do + %{ + id: page_content.id, + page_id: page_content.page_id, + name: page_content.name, + content: page_content.content, + content_type: page_content.content_type, + meta: page_content.meta, + inserted_at: page_content.inserted_at, + updated_at: page_content.updated_at + } + end +end \ No newline at end of file diff --git a/mix.exs b/mix.exs index 31764c7..495cd65 100644 --- a/mix.exs +++ b/mix.exs @@ -17,7 +17,8 @@ defmodule Thesis.Mixfile do end def application do - [applications: [:logger, :phoenix, :phoenix_html, :plug, :httpoison]] + [applications: [:logger, :phoenix, :phoenix_html, :plug, + :httpoison, :html_sanitize_ex]] end defp deps do diff --git a/priv/static/thesis.js b/priv/static/thesis.js index 60206e6..b115b2e 100644 --- a/priv/static/thesis.js +++ b/priv/static/thesis.js @@ -17,7 +17,7 @@ var o=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.pr * @internal * @license Modernizr 3.0.0pre (Custom Build) | MIT */ -function r(e,t){if(!i.canUseDOM||t&&!("addEventListener"in document))return!1;var n="on"+e,r=n in document;if(!r){var a=document.createElement("div");a.setAttribute(n,"return;"),r="function"==typeof a[n]}return!r&&o&&"wheel"===e&&(r=document.implementation.hasFeature("Events.wheel","3.0")),r}var o,i=n(6);i.canUseDOM&&(o=document.implementation&&document.implementation.hasFeature&&!0!==document.implementation.hasFeature("","")),e.exports=r},function(e,t,n){"use strict";function r(e,t){var n=null===e||!1===e,r=null===t||!1===t;if(n||r)return n===r;var o=typeof e,i=typeof t;return"string"===o||"number"===o?"string"===i||"number"===i:"object"===i&&e.type===t.type&&e.key===t.key}e.exports=r},function(e,t,n){"use strict";var r=(n(3),n(7)),o=(n(1),r);e.exports=o},function(e,t,n){"use strict";function r(e,t,n){this.props=e,this.context=t,this.refs=a,this.updater=n||i}var o=n(19),i=n(49),a=(n(78),n(13));n(0),n(1);r.prototype.isReactComponent={},r.prototype.setState=function(e,t){"object"!=typeof e&&"function"!=typeof e&&null!=e&&o("85"),this.updater.enqueueSetState(this,e),t&&this.updater.enqueueCallback(this,t,"setState")},r.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this),e&&this.updater.enqueueCallback(this,e,"forceUpdate")};e.exports=r},function(e,t,n){"use strict";var r=(n(1),{isMounted:function(e){return!1},enqueueCallback:function(e,t){},enqueueForceUpdate:function(e){},enqueueReplaceState:function(e,t){},enqueueSetState:function(e,t){}});e.exports=r},function(e,t,n){"use strict";e.exports=n(135)},function(e,t,n){"use strict";var r=n(7),o={listen:function(e,t,n){return e.addEventListener?(e.addEventListener(t,n,!1),{remove:function(){e.removeEventListener(t,n,!1)}}):e.attachEvent?(e.attachEvent("on"+t,n),{remove:function(){e.detachEvent("on"+t,n)}}):void 0},capture:function(e,t,n){return e.addEventListener?(e.addEventListener(t,n,!0),{remove:function(){e.removeEventListener(t,n,!0)}}):{remove:r}},registerDefault:function(){}};e.exports=o},function(e,t,n){"use strict";function r(e){try{e.focus()}catch(e){}}e.exports=r},function(e,t,n){"use strict";function r(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}e.exports=r},function(e,t,n){"use strict";var r=n(118);e.exports=function(e){return r(e,!1)}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";function r(e,t){return e+t.charAt(0).toUpperCase()+t.substring(1)}var o={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},i=["Webkit","ms","Moz","O"];Object.keys(o).forEach(function(e){i.forEach(function(t){o[r(t,e)]=o[e]})});var a={background:{backgroundAttachment:!0,backgroundColor:!0,backgroundImage:!0,backgroundPositionX:!0,backgroundPositionY:!0,backgroundRepeat:!0},backgroundPosition:{backgroundPositionX:!0,backgroundPositionY:!0},border:{borderWidth:!0,borderStyle:!0,borderColor:!0},borderBottom:{borderBottomWidth:!0,borderBottomStyle:!0,borderBottomColor:!0},borderLeft:{borderLeftWidth:!0,borderLeftStyle:!0,borderLeftColor:!0},borderRight:{borderRightWidth:!0,borderRightStyle:!0,borderRightColor:!0},borderTop:{borderTopWidth:!0,borderTopStyle:!0,borderTopColor:!0},font:{fontStyle:!0,fontVariant:!0,fontWeight:!0,fontSize:!0,lineHeight:!0,fontFamily:!0},outline:{outlineWidth:!0,outlineStyle:!0,outlineColor:!0}},s={isUnitlessNumber:o,shorthandPropertyExpansions:a};e.exports=s},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=n(2),i=n(12),a=(n(0),function(){function e(t){r(this,e),this._callbacks=null,this._contexts=null,this._arg=t}return e.prototype.enqueue=function(e,t){this._callbacks=this._callbacks||[],this._callbacks.push(e),this._contexts=this._contexts||[],this._contexts.push(t)},e.prototype.notifyAll=function(){var e=this._callbacks,t=this._contexts,n=this._arg;if(e&&t){e.length!==t.length&&o("24"),this._callbacks=null,this._contexts=null;for(var r=0;r.":"function"==typeof t?" Instead of passing a class like Foo, pass React.createElement(Foo) or .":null!=t&&void 0!==t.props?" This may be caused by unintentionally loading two independent copies of React.":"");var a,s=g.createElement(U,{child:t});if(e){var l=w.get(e);a=l._processChildContext(l._context)}else a=P;var c=p(n);if(c){var d=c._currentElement,f=d.props.child;if(A(f,t)){var m=c._renderedComponent.getPublicInstance(),v=r&&function(){r.call(m)};return B._updateRootComponent(c,s,a,n,v),m}B.unmountComponentAtNode(n)}var y=o(n),b=y&&!!i(y),C=u(n),E=b&&!c&&!C,x=B._renderNewRootComponent(s,n,E,a)._renderedComponent.getPublicInstance();return r&&r.call(x),x},render:function(e,t,n){return B._renderSubtreeIntoContainer(null,e,t,n)},unmountComponentAtNode:function(e){c(e)||h("40");var t=p(e);if(!t){u(e),1===e.nodeType&&e.hasAttribute(D);return!1}return delete L[t._instance.rootID],k.batchedUpdates(l,t,e,!1),!0},_mountImageIntoNode:function(e,t,n,i,a){if(c(t)||h("41"),i){var s=o(t);if(x.canReuseMarkup(e,s))return void y.precacheNode(n,s);var l=s.getAttribute(x.CHECKSUM_ATTR_NAME);s.removeAttribute(x.CHECKSUM_ATTR_NAME);var u=s.outerHTML;s.setAttribute(x.CHECKSUM_ATTR_NAME,l);var d=e,p=r(d,u),m=" (client) "+d.substring(p-20,p+20)+"\n (server) "+u.substring(p-20,p+20);t.nodeType===I&&h("42",m)}if(t.nodeType===I&&h("43"),a.useCreateElement){for(;t.lastChild;)t.removeChild(t.lastChild);f.insertTreeBefore(t,e,null)}else N(t,e),y.precacheNode(n,t.firstChild)}};e.exports=B},function(e,t,n){"use strict";var r=n(2),o=n(17),i=(n(0),{HOST:0,COMPOSITE:1,EMPTY:2,getType:function(e){return null===e||!1===e?i.EMPTY:o.isValidElement(e)?"function"==typeof e.type?i.COMPOSITE:i.HOST:void r("26",e)}});e.exports=i},function(e,t,n){"use strict";var r={currentScrollLeft:0,currentScrollTop:0,refreshScrollValues:function(e){r.currentScrollLeft=e.x,r.currentScrollTop=e.y}};e.exports=r},function(e,t,n){"use strict";function r(e,t){return null==t&&o("30"),null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}var o=n(2);n(0);e.exports=r},function(e,t,n){"use strict";function r(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}e.exports=r},function(e,t,n){"use strict";function r(e){for(var t;(t=e._renderedNodeType)===o.COMPOSITE;)e=e._renderedComponent;return t===o.HOST?e._renderedComponent:t===o.EMPTY?null:void 0}var o=n(66);e.exports=r},function(e,t,n){"use strict";function r(){return!i&&o.canUseDOM&&(i="textContent"in document.documentElement?"textContent":"innerText"),i}var o=n(6),i=null;e.exports=r},function(e,t,n){"use strict";function r(e){if(e){var t=e.getName();if(t)return" Check the render method of `"+t+"`."}return""}function o(e){return"function"==typeof e&&void 0!==e.prototype&&"function"==typeof e.prototype.mountComponent&&"function"==typeof e.prototype.receiveComponent}function i(e,t){var n;if(null===e||!1===e)n=u.create(i);else if("object"==typeof e){var s=e,l=s.type;if("function"!=typeof l&&"string"!=typeof l){var p="";p+=r(s._owner),a("130",null==l?l:typeof l,p)}"string"==typeof s.type?n=c.createInternalComponent(s):o(s.type)?(n=new s.type(s),n.getHostNode||(n.getHostNode=n.getNativeNode)):n=new d(s)}else"string"==typeof e||"number"==typeof e?n=c.createInstanceForText(e):a("131",typeof e);return n._mountIndex=0,n._mountImage=null,n}var a=n(2),s=n(3),l=n(134),u=n(61),c=n(63),d=(n(195),n(0),n(1),function(e){this.construct(e)});s(d.prototype,l,{_instantiateReactComponent:i}),e.exports=i},function(e,t,n){"use strict";function r(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!o[e.type]:"textarea"===t}var o={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};e.exports=r},function(e,t,n){"use strict";var r=n(6),o=n(27),i=n(28),a=function(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t};r.canUseDOM&&("textContent"in document.documentElement||(a=function(e,t){if(3===e.nodeType)return void(e.nodeValue=t);i(e,o(t))})),e.exports=a},function(e,t,n){"use strict";function r(e,t){return e&&"object"==typeof e&&null!=e.key?u.escape(e.key):t.toString(36)}function o(e,t,n,i){var p=typeof e;if("undefined"!==p&&"boolean"!==p||(e=null),null===e||"string"===p||"number"===p||"object"===p&&e.$$typeof===s)return n(i,e,""===t?c+r(e,0):t),1;var h,f,m=0,g=""===t?c:t+d;if(Array.isArray(e))for(var v=0;v=e.state.importContentQueueCount?(clearTimeout(window.importContentCounterTimeout),{importContentQueueCount:0,importContentCompletedCount:0,importProgress:null,trayOpen:!1}):{importContentCompletedCount:r}})}},{key:"updateImportProgress",value:function(e){this.setState({importProgress:e})}},{key:"componentDidUpdate",value:function(){var e=document.querySelector("body");e.classList.add("thesis-body");var t=this.allContentEditors();if(this.state.editing?(e.classList.add("thesis-editing"),this.addContentEditors()):(e.classList.remove("thesis-editing"),this.removeContentEditors()),this.state.pageModified)e.classList.add("thesis-page-modified");else{e.classList.remove("thesis-page-modified");for(var n=0;n0}},{key:"renderEditorClass",value:function(){var e="";return e+=this.state.editing?" active ":"",e+=this.state.pageToolsHidden?" thesis-page-tools-hidden ":"",e+="thesis-page-tools-count-"+this.editorClassButtonCount()}},{key:"editorClassButtonCount",value:function(){var e=5;return this.canCreatePages()&&e++,this.state.template&&e++,e}},{key:"renderEditButtonText",value:function(){return this.state.editing?"Editing Page":"Edit Page"}},{key:"renderFaderClass",value:function(){return this.renderEditorClass()}},{key:"renderTrayClass",value:function(){return this.state.trayType}},{key:"renderTray",value:function(){return"page-settings"===this.state.trayType?u.default.createElement(k.default,{hasErrors:!1,new:!1,path:this.state.path,title:this.state.title,description:this.state.description,template:this.state.template,templates:this.state.templates,isDynamicPage:this.state.isDynamicPage,redirectURL:this.state.redirectURL,onCancel:this.trayCanceled,onSubmit:this.settingsTraySubmitted}):"add-page"===this.state.trayType?u.default.createElement(k.default,{hasErrors:!1,new:!0,path:this.state.path.replace(/\/+$/,"")+"/newpage",title:"",description:"",template:"",templates:this.state.templates,isDynamicPage:this.state.isDynamicPage,redirectURL:"",onCancel:this.trayCanceled,onSubmit:this.settingsTraySubmitted}):"image-url"===this.state.trayType?this.imageEditor.tray(this.state.trayData):"raw-html"===this.state.trayType?this.rawHtmlEditor.tray(this.state.trayData):"import-export"===this.state.trayType?u.default.createElement(S.default,{pageContents:this.contentEditorContents(),pageSettings:this.pageSettings(),importProgress:this.state.importProgress,updateImportProgress:this.updateImportProgress,onCancel:this.trayCanceled,importData:this.importData}):void 0}},{key:"render",value:function(){return this.state.deleted?u.default.createElement("div",{id:"thesis"}):u.default.createElement("div",{id:"thesis"},u.default.createElement("div",{id:"thesis-editor",className:this.renderEditorClass()},u.default.createElement(g.default,{onPress:this.pageSettingsPressed}),u.default.createElement(y.default,{onPress:this.importExportPressed}),u.default.createElement(w.default,{onPress:this.savePressed}),u.default.createElement(C.default,{onPress:this.cancelPressed}),this.state.isDynamicPage?u.default.createElement(f.default,{onPress:this.deletePagePressed}):null,this.canCreatePages()?u.default.createElement(p.default,{onPress:this.addPagePressed}):null,u.default.createElement(_.default,{onPress:this.editPressed,text:this.renderEditButtonText()})),u.default.createElement("div",{id:"thesis-fader",className:this.renderFaderClass()}),u.default.createElement("div",{id:"thesis-tray",className:this.renderTrayClass()},this.renderTray(),u.default.createElement(A.default,null)))}}]),t}(u.default.Component);t.default=B},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(29),o=function(e){return e&&e.__esModule?e:{default:e}}(r),i=function(e){var t=document.querySelectorAll("meta[name=description]")[0];return{customHTMLEditor:window[e.getAttribute("data-html-editor")],fileUploader:e.getAttribute("data-file-uploader"),ospryPublicKey:e.getAttribute("data-ospry-public-key"),pageRedirectURL:e.getAttribute("data-redirect-url"),template:e.getAttribute("data-template"),templates:e.getAttribute("data-templates").split(",").filter(function(e){return""!==e}),isDynamicPage:e.getAttribute("data-dynamic-page"),path:window.location.pathname,getTitle:function(){return document.title},setTitle:function(e){return document.title=e},getDescription:function(){return t&&t.content},setDescription:function(e){return t&&(t.content=e)},getRedirectURL:function(){return e.getAttribute("data-redirect-url")},setRedirectURL:function(t){return e.setAttribute("data-redirect-url",t)},save:function(e,t,n){o.default.put("/thesis/update",{page:e,contents:t}).then(function(t){e.slug!==window.location.pathname?window.location=e.slug:n()}).catch(function(e){window.alert("Something went wrong! Details: "+e)})},delete:function(e,t){o.default.delete("/thesis/delete",{path:e}).then(function(e){window.alert("Page has been deleted."),t()}).catch(function(e){window.alert("Something went wrong! Details: "+e)})}}};t.default=i},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n0&&(this.editor=new a.default(this.editors,this.mediumEditorOptions()),this.editor.subscribe("editableInput",this.changedHtmlEditor)),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.editor&&this.editor.destroy(),this.editor=null,this.enabled=!1)}},{key:"content",value:function(e){return e.innerHTML}},{key:"set",value:function(e,t){var n=document.querySelector("[data-thesis-content-id='"+e+"']");n&&(n.innerHTML=t.content,n.classList.add("modified"))}},{key:"changedHtmlEditor",value:function(e,t){t.classList.add("modified"),this.onChange()}},{key:"mediumEditorOptions",value:function(){return{autoLink:!0,toolbar:{buttons:["bold","italic","underline","anchor","h1","h2","h3","h4","h5","h6","quote","orderedlist","unorderedlist","removeFormat","justifyLeft","justifyCenter","justifyRight"],static:!0,align:"center",sticky:!0,updateOnEmptySelection:!0},paste:{forcePlainText:!1,cleanPastedHTML:!0,cleanAttrs:["class","style","dir"],cleanTags:["meta","pre"]}}}}]),e}();t.default=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n0&&r.set(e.name,{url:t.path},e.meta)}).catch(function(t){n(),window.alert(e.name+" could not be saved.")})}},{key:"set",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=document.querySelector('[data-thesis-content-id="'+e+'"');if(r.classList.add("modified"),!n){var o=JSON.parse(r.getAttribute("data-thesis-content-meta")),i=Object.assign({},o,{alt:t.alt});n=JSON.stringify(i)}r.setAttribute("data-thesis-content-meta",n);var a=r.getAttribute("data-thesis-content-type");if("image"===a){var s=r.querySelector("img");s.src=t.url,s.alt=JSON.parse(n).alt}else"background_image"===a&&(r.style.backgroundImage='url("'+t.url+'")')}},{key:"determineImageUrl",value:function(e,t){return""===e.trim()?null:this.isImageAbsoluteUrl(e)?e.trim():this.isImageUrlWithoutProtocol(e)?"http:"+e.trim():t+e.trim()}},{key:"isImageAbsoluteUrl",value:function(e){var t=e.trim().indexOf("//");return t>4&&t<7}},{key:"isImageUrlWithoutProtocol",value:function(e){return 0===e.trim().indexOf("//")}},{key:"getUrlFromStyle",value:function(e){return e.replace(/\'/g,"").replace(/"/g,"").replace("url(","").replace(")","")}}]),e}();t.default=p},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n0&&t.setState({url:e.path})}).catch(function(e){window.alert(e)})}},{key:"uploadFileToOspry",value:function(e){this.setState({fileName:e.target.files[0].name});var t=new f(this.props.ospryPublicKey);e.preventDefault();var n=e.target;t.up({form:n,imageReady:this.onOspryUpload})}},{key:"previewImageStyle",value:function(){return{backgroundImage:"url("+this.state.url+")"}}},{key:"renderForm",value:function(){return this.props.ospryPublicKey?this.renderOspryForm():this.props.fileUploader?this.renderUploaderForm():void 0}},{key:"renderUploaderForm",value:function(){return u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Upload Image"),u.default.createElement("form",{onChange:this.uploadFile,className:"tray-file-upload"},u.default.createElement("span",null,this.state.fileName),u.default.createElement("input",{type:"file",accept:".svg,image/*",name:"file"}))))}},{key:"renderOspryForm",value:function(){if(this.props.ospryPublicKey)return u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Upload Image"),u.default.createElement("form",{onChange:this.uploadFileToOspry,className:"tray-file-upload"},u.default.createElement("span",null,this.state.fileName),u.default.createElement("input",{type:"file",accept:".jpg,.jpeg,.png,.gif,image/png,image/gif,image/jpeg,image/jpg"}))))}},{key:"render",value:function(){return u.default.createElement("div",{className:"tray-container"},u.default.createElement("div",{className:"tray-wrap"},u.default.createElement("div",{className:"tray-title"},"Image URL"),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("div",{className:"tray-image-preview",style:this.previewImageStyle()})),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Image URL"),u.default.createElement("input",{type:"text",placeholder:"http://placekitten.com/200/300",value:this.state.url,onChange:this.urlChange}))),this.renderForm(),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Alt Text"),u.default.createElement("input",{type:"text",placeholder:"Describe the image",value:this.state.alt,onChange:this.altChange}))),u.default.createElement("div",{className:"thesis-field-row errors",hidden:this.state.isValid}),u.default.createElement("div",{className:"thesis-field-row cta"},u.default.createElement("button",{className:"thesis-tray-cancel",onClick:this.onCancel},"Cancel"),u.default.createElement("button",{className:"thesis-tray-save",onClick:this.onSave},"Apply"))))}}]),t}(u.default.Component);t.default=m},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nAny HTML you like",value:this.state.content,onChange:this.contentChange}))),l.default.createElement("div",{className:"thesis-field-row errors",hidden:this.state.isValid}),l.default.createElement("div",{className:"thesis-field-row cta"},l.default.createElement("button",{className:"thesis-tray-cancel",onClick:this.props.onCancel},"Cancel"),l.default.createElement("button",{className:"thesis-tray-save",onClick:this.onSave},"Apply"))))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n.":"function"==typeof t?" Instead of passing a class like Foo, pass React.createElement(Foo) or .":null!=t&&void 0!==t.props?" This may be caused by unintentionally loading two independent copies of React.":"");var a,s=g.createElement(U,{child:t});if(e){var l=w.get(e);a=l._processChildContext(l._context)}else a=P;var c=p(n);if(c){var d=c._currentElement,f=d.props.child;if(A(f,t)){var m=c._renderedComponent.getPublicInstance(),v=r&&function(){r.call(m)};return B._updateRootComponent(c,s,a,n,v),m}B.unmountComponentAtNode(n)}var y=o(n),b=y&&!!i(y),C=u(n),E=b&&!c&&!C,x=B._renderNewRootComponent(s,n,E,a)._renderedComponent.getPublicInstance();return r&&r.call(x),x},render:function(e,t,n){return B._renderSubtreeIntoContainer(null,e,t,n)},unmountComponentAtNode:function(e){c(e)||h("40");var t=p(e);if(!t){u(e),1===e.nodeType&&e.hasAttribute(D);return!1}return delete L[t._instance.rootID],k.batchedUpdates(l,t,e,!1),!0},_mountImageIntoNode:function(e,t,n,i,a){if(c(t)||h("41"),i){var s=o(t);if(x.canReuseMarkup(e,s))return void y.precacheNode(n,s);var l=s.getAttribute(x.CHECKSUM_ATTR_NAME);s.removeAttribute(x.CHECKSUM_ATTR_NAME);var u=s.outerHTML;s.setAttribute(x.CHECKSUM_ATTR_NAME,l);var d=e,p=r(d,u),m=" (client) "+d.substring(p-20,p+20)+"\n (server) "+u.substring(p-20,p+20);t.nodeType===I&&h("42",m)}if(t.nodeType===I&&h("43"),a.useCreateElement){for(;t.lastChild;)t.removeChild(t.lastChild);f.insertTreeBefore(t,e,null)}else N(t,e),y.precacheNode(n,t.firstChild)}};e.exports=B},function(e,t,n){"use strict";var r=n(2),o=n(17),i=(n(0),{HOST:0,COMPOSITE:1,EMPTY:2,getType:function(e){return null===e||!1===e?i.EMPTY:o.isValidElement(e)?"function"==typeof e.type?i.COMPOSITE:i.HOST:void r("26",e)}});e.exports=i},function(e,t,n){"use strict";var r={currentScrollLeft:0,currentScrollTop:0,refreshScrollValues:function(e){r.currentScrollLeft=e.x,r.currentScrollTop=e.y}};e.exports=r},function(e,t,n){"use strict";function r(e,t){return null==t&&o("30"),null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}var o=n(2);n(0);e.exports=r},function(e,t,n){"use strict";function r(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}e.exports=r},function(e,t,n){"use strict";function r(e){for(var t;(t=e._renderedNodeType)===o.COMPOSITE;)e=e._renderedComponent;return t===o.HOST?e._renderedComponent:t===o.EMPTY?null:void 0}var o=n(66);e.exports=r},function(e,t,n){"use strict";function r(){return!i&&o.canUseDOM&&(i="textContent"in document.documentElement?"textContent":"innerText"),i}var o=n(6),i=null;e.exports=r},function(e,t,n){"use strict";function r(e){if(e){var t=e.getName();if(t)return" Check the render method of `"+t+"`."}return""}function o(e){return"function"==typeof e&&void 0!==e.prototype&&"function"==typeof e.prototype.mountComponent&&"function"==typeof e.prototype.receiveComponent}function i(e,t){var n;if(null===e||!1===e)n=u.create(i);else if("object"==typeof e){var s=e,l=s.type;if("function"!=typeof l&&"string"!=typeof l){var p="";p+=r(s._owner),a("130",null==l?l:typeof l,p)}"string"==typeof s.type?n=c.createInternalComponent(s):o(s.type)?(n=new s.type(s),n.getHostNode||(n.getHostNode=n.getNativeNode)):n=new d(s)}else"string"==typeof e||"number"==typeof e?n=c.createInstanceForText(e):a("131",typeof e);return n._mountIndex=0,n._mountImage=null,n}var a=n(2),s=n(3),l=n(134),u=n(61),c=n(63),d=(n(195),n(0),n(1),function(e){this.construct(e)});s(d.prototype,l,{_instantiateReactComponent:i}),e.exports=i},function(e,t,n){"use strict";function r(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!o[e.type]:"textarea"===t}var o={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};e.exports=r},function(e,t,n){"use strict";var r=n(6),o=n(27),i=n(28),a=function(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t};r.canUseDOM&&("textContent"in document.documentElement||(a=function(e,t){if(3===e.nodeType)return void(e.nodeValue=t);i(e,o(t))})),e.exports=a},function(e,t,n){"use strict";function r(e,t){return e&&"object"==typeof e&&null!=e.key?u.escape(e.key):t.toString(36)}function o(e,t,n,i){var p=typeof e;if("undefined"!==p&&"boolean"!==p||(e=null),null===e||"string"===p||"number"===p||"object"===p&&e.$$typeof===s)return n(i,e,""===t?c+r(e,0):t),1;var h,f,m=0,g=""===t?c:t+d;if(Array.isArray(e))for(var v=0;v=e.state.importContentQueueCount?(clearTimeout(window.importContentCounterTimeout),{importContentQueueCount:0,importContentCompletedCount:0,importProgress:null,trayOpen:!1}):{importContentCompletedCount:r}})}},{key:"updateImportProgress",value:function(e){this.setState({importProgress:e})}},{key:"componentDidUpdate",value:function(){var e=document.querySelector("body");e.classList.add("thesis-body");var t=this.allContentEditors();if(this.state.editing?(e.classList.add("thesis-editing"),this.addContentEditors()):(e.classList.remove("thesis-editing"),this.removeContentEditors()),this.state.pageModified)e.classList.add("thesis-page-modified");else{e.classList.remove("thesis-page-modified");for(var n=0;n0}},{key:"renderEditorClass",value:function(){var e="";return e+=this.state.editing?" active ":"",e+=this.state.pageToolsHidden?" thesis-page-tools-hidden ":"",e+="thesis-page-tools-count-"+this.editorClassButtonCount()}},{key:"editorClassButtonCount",value:function(){var e=5;return this.canCreatePages()&&e++,this.state.template&&e++,e}},{key:"renderEditButtonText",value:function(){return this.state.editing?"Editing Page":"Edit Page"}},{key:"renderFaderClass",value:function(){return this.renderEditorClass()}},{key:"renderTrayClass",value:function(){return this.state.trayType}},{key:"renderTray",value:function(){return"page-settings"===this.state.trayType?u.default.createElement(k.default,{hasErrors:!1,new:!1,path:this.state.path,title:this.state.title,description:this.state.description,template:this.state.template,templates:this.state.templates,isDynamicPage:this.state.isDynamicPage,redirectURL:this.state.redirectURL,onCancel:this.trayCanceled,onSubmit:this.settingsTraySubmitted}):"add-page"===this.state.trayType?u.default.createElement(k.default,{hasErrors:!1,new:!0,path:this.state.path.replace(/\/+$/,"")+"/newpage",title:"",description:"",template:"",templates:this.state.templates,isDynamicPage:this.state.isDynamicPage,redirectURL:"",onCancel:this.trayCanceled,onSubmit:this.settingsTraySubmitted}):"image-url"===this.state.trayType?this.imageEditor.tray(this.state.trayData):"raw-html"===this.state.trayType?this.rawHtmlEditor.tray(this.state.trayData):"import-export"===this.state.trayType?u.default.createElement(S.default,{pageContents:this.contentEditorContents(),pageSettings:this.pageSettings(),importProgress:this.state.importProgress,updateImportProgress:this.updateImportProgress,onCancel:this.trayCanceled,importData:this.importData}):void 0}},{key:"render",value:function(){return this.state.deleted?u.default.createElement("div",{id:"thesis"}):u.default.createElement("div",{id:"thesis"},u.default.createElement("div",{id:"thesis-editor",className:this.renderEditorClass()},u.default.createElement(g.default,{onPress:this.pageSettingsPressed}),u.default.createElement(y.default,{onPress:this.importExportPressed}),u.default.createElement(w.default,{onPress:this.savePressed}),u.default.createElement(C.default,{onPress:this.cancelPressed}),this.state.isDynamicPage?u.default.createElement(f.default,{onPress:this.deletePagePressed}):null,this.canCreatePages()?u.default.createElement(p.default,{onPress:this.addPagePressed}):null,u.default.createElement(_.default,{onPress:this.editPressed,text:this.renderEditButtonText()})),u.default.createElement("div",{id:"thesis-fader",className:this.renderFaderClass()}),u.default.createElement("div",{id:"thesis-tray",className:this.renderTrayClass()},this.renderTray(),u.default.createElement(A.default,null)))}}]),t}(u.default.Component);t.default=B},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(29),o=function(e){return e&&e.__esModule?e:{default:e}}(r),i=function(e){var t=document.querySelectorAll("meta[name=description]")[0];return{customHTMLEditor:window[e.getAttribute("data-html-editor")],fileUploader:e.getAttribute("data-file-uploader"),ospryPublicKey:e.getAttribute("data-ospry-public-key"),pageRedirectURL:e.getAttribute("data-redirect-url"),template:e.getAttribute("data-template"),templates:e.getAttribute("data-templates").split(",").filter(function(e){return""!==e}),isDynamicPage:e.getAttribute("data-dynamic-page"),path:window.location.pathname,getTitle:function(){return document.title},setTitle:function(e){return document.title=e},getDescription:function(){return t&&t.content},setDescription:function(e){return t&&(t.content=e)},getRedirectURL:function(){return e.getAttribute("data-redirect-url")},setRedirectURL:function(t){return e.setAttribute("data-redirect-url",t)},save:function(e,t,n){o.default.put("/thesis/update",{page:e,contents:t}).then(function(e){e.slug!==window.location.pathname?window.location=e.slug:n(e)}).catch(function(e){window.alert("Something went wrong! Details: "+e)})},delete:function(e,t){o.default.delete("/thesis/delete",{path:e}).then(function(e){window.alert("Page has been deleted."),t(e)}).catch(function(e){window.alert("Something went wrong! Details: "+e)})}}};t.default=i},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n0&&(this.editor=new a.default(this.editors,this.mediumEditorOptions()),this.editor.subscribe("editableInput",this.changedHtmlEditor)),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.editor&&this.editor.destroy(),this.editor=null,this.enabled=!1)}},{key:"content",value:function(e){return e.innerHTML}},{key:"set",value:function(e,t){var n=document.querySelector("[data-thesis-content-id='"+e+"']");n&&(n.innerHTML=t.content,n.classList.add("modified"))}},{key:"changedHtmlEditor",value:function(e,t){t.classList.add("modified"),this.onChange()}},{key:"mediumEditorOptions",value:function(){return{autoLink:!0,toolbar:{buttons:["bold","italic","underline","anchor","h1","h2","h3","h4","h5","h6","quote","orderedlist","unorderedlist","removeFormat","justifyLeft","justifyCenter","justifyRight"],static:!0,align:"center",sticky:!0,updateOnEmptySelection:!0},paste:{forcePlainText:!1,cleanPastedHTML:!0,cleanAttrs:["class","style","dir"],cleanTags:["meta","pre"]}}}}]),e}();t.default=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n0&&r.set(e.name,{url:t.path},e.meta)}).catch(function(t){n(),window.alert(e.name+" could not be saved.")})}},{key:"set",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=document.querySelector('[data-thesis-content-id="'+e+'"');if(r.classList.add("modified"),!n){var o=JSON.parse(r.getAttribute("data-thesis-content-meta")),i=Object.assign({},o,{alt:t.alt});n=JSON.stringify(i)}r.setAttribute("data-thesis-content-meta",n);var a=r.getAttribute("data-thesis-content-type");if("image"===a){var s=r.querySelector("img");s.src=t.url,s.alt=JSON.parse(n).alt}else"background_image"===a&&(r.style.backgroundImage='url("'+t.url+'")')}},{key:"determineImageUrl",value:function(e,t){return""===e.trim()?null:this.isImageAbsoluteUrl(e)?e.trim():this.isImageUrlWithoutProtocol(e)?"http:"+e.trim():t+e.trim()}},{key:"isImageAbsoluteUrl",value:function(e){var t=e.trim().indexOf("//");return t>4&&t<7}},{key:"isImageUrlWithoutProtocol",value:function(e){return 0===e.trim().indexOf("//")}},{key:"getUrlFromStyle",value:function(e){return e.replace(/\'/g,"").replace(/"/g,"").replace("url(","").replace(")","")}}]),e}();t.default=p},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n0&&t.setState({url:e.path})}).catch(function(e){window.alert(e)})}},{key:"uploadFileToOspry",value:function(e){this.setState({fileName:e.target.files[0].name});var t=new f(this.props.ospryPublicKey);e.preventDefault();var n=e.target;t.up({form:n,imageReady:this.onOspryUpload})}},{key:"previewImageStyle",value:function(){return{backgroundImage:"url("+this.state.url+")"}}},{key:"renderForm",value:function(){return this.props.ospryPublicKey?this.renderOspryForm():this.props.fileUploader?this.renderUploaderForm():void 0}},{key:"renderUploaderForm",value:function(){return u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Upload Image"),u.default.createElement("form",{onChange:this.uploadFile,className:"tray-file-upload"},u.default.createElement("span",null,this.state.fileName),u.default.createElement("input",{type:"file",accept:".svg,image/*",name:"file"}))))}},{key:"renderOspryForm",value:function(){if(this.props.ospryPublicKey)return u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Upload Image"),u.default.createElement("form",{onChange:this.uploadFileToOspry,className:"tray-file-upload"},u.default.createElement("span",null,this.state.fileName),u.default.createElement("input",{type:"file",accept:".jpg,.jpeg,.png,.gif,image/png,image/gif,image/jpeg,image/jpg"}))))}},{key:"render",value:function(){return u.default.createElement("div",{className:"tray-container"},u.default.createElement("div",{className:"tray-wrap"},u.default.createElement("div",{className:"tray-title"},"Image URL"),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("div",{className:"tray-image-preview",style:this.previewImageStyle()})),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Image URL"),u.default.createElement("input",{type:"text",placeholder:"http://placekitten.com/200/300",value:this.state.url,onChange:this.urlChange}))),this.renderForm(),u.default.createElement("div",{className:"thesis-field-row"},u.default.createElement("label",null,u.default.createElement("span",null,"Alt Text"),u.default.createElement("input",{type:"text",placeholder:"Describe the image",value:this.state.alt,onChange:this.altChange}))),u.default.createElement("div",{className:"thesis-field-row errors",hidden:this.state.isValid}),u.default.createElement("div",{className:"thesis-field-row cta"},u.default.createElement("button",{className:"thesis-tray-cancel",onClick:this.onCancel},"Cancel"),u.default.createElement("button",{className:"thesis-tray-save",onClick:this.onSave},"Apply"))))}}]),t}(u.default.Component);t.default=m},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nAny HTML you like",value:this.state.content,onChange:this.contentChange}))),l.default.createElement("div",{className:"thesis-field-row errors",hidden:this.state.isValid}),l.default.createElement("div",{className:"thesis-field-row cta"},l.default.createElement("button",{className:"thesis-tray-cancel",onClick:this.props.onCancel},"Cancel"),l.default.createElement("button",{className:"thesis-tray-save",onClick:this.onSave},"Apply"))))}}]),t}(l.default.Component);t.default=u},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;nn;n++)t+=p[Math.floor(Math.random()*p.length)];return t},f=function(e){if(!a(e))throw"ospry: required public key is not a string";if(""===e)throw"ospry: required public key is missing";this._key=e,this._serverURL="https://api.ospry.io/v1"};f.formats=["jpeg","png","gif"],f.prototype.up=function(e){if(!o(e))throw"ospry: required options argument is not an object";if(e=l(e,{files:null,form:null,isPrivate:!1,imageReady:s,done:s}),n){if(null===e.files){if(null===e.form)throw"ospry: both form and files are missing from options (one of them should be set)";var t=u(e.form);if(null===t)throw"ospry: file input is missing from form";e.files=t.files}this._upXHR(e.files,e)}else{if(null===e.form)throw"ospry: form property is missing from options (older browsers only support form-based uploads)";this._upIFrame(e)}},f.prototype._upXHR=function(e,t){for(var n=0,r=function(r,o,i){t.imageReady(r,o,i),++n===e.length&&t.done()},o=0;o0?n.set("maxHeight",t.maxHeight):n.remove("maxHeight")}if(null!==t.maxWidth){if(!i(t.maxWidth))throw"ospry: maxWidth should be a number";t.maxWidth>0?n.set("maxWidth",t.maxWidth):n.remove("maxWidth")}return n.toString()};var m=function(){this.scheme=null,this.host=null,this.path=null,this.query={}};return m.parse=function(e){var t=new m,n=e.indexOf(":");if(-1===n)return null;t.scheme=e.slice(0,n),n+="://".length;var r=e.indexOf("/",n);if(-1===r)return null;t.host=e.slice(n,r);var o=e.indexOf("?",r);if(-1===o&&(o=e.length),t.path=e.slice(r,o),o!==e.length)for(var i=e.slice(o+1).split("&"),a=0;a":"<"+e+">",s[e]=!a.firstChild),s[e]?p[e]:null}var o=n(6),i=n(0),a=o.canUseDOM?document.createElement("div"):null,s={},l=[1,'"],u=[1,"","
"],c=[3,"","
"],d=[1,'',""],p={"*":[1,"?
","
"],area:[1,"",""],col:[2,"","
"],legend:[1,"
","
"],param:[1,"",""],tr:[2,"","
"],optgroup:l,option:l,caption:u,colgroup:u,tbody:u,tfoot:u,thead:u,td:c,th:c};["circle","clipPath","defs","ellipse","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","text","tspan"].forEach(function(e){p[e]=d,s[e]=!0}),e.exports=r},function(e,t,n){"use strict";function r(e){return e.Window&&e instanceof e.Window?{x:e.pageXOffset||e.document.documentElement.scrollLeft,y:e.pageYOffset||e.document.documentElement.scrollTop}:{x:e.scrollLeft,y:e.scrollTop}}e.exports=r},function(e,t,n){"use strict";function r(e){return e.replace(o,"-$1").toLowerCase()}var o=/([A-Z])/g;e.exports=r},function(e,t,n){"use strict";function r(e){return o(e).replace(i,"-ms-")}var o=n(110),i=/^ms-/;e.exports=r},function(e,t,n){"use strict";function r(e){var t=e?e.ownerDocument||e:document,n=t.defaultView||window;return!(!e||!("function"==typeof n.Node?e instanceof n.Node:"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName))}e.exports=r},function(e,t,n){"use strict";function r(e){return o(e)&&3==e.nodeType}var o=n(112);e.exports=r},function(e,t,n){"use strict";function r(e){var t={};return function(n){return t.hasOwnProperty(n)||(t[n]=e.call(this,n)),t[n]}}e.exports=r},function(e,t,n){(function(r){var o;/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */ "classList"in document.createElement("_")||function(e){"use strict";if("Element"in e){var t=e.Element.prototype,n=Object,r=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},o=Array.prototype.indexOf||function(e){for(var t=0,n=this.length;t1?t:this.data.length),n,this.encoding)},i.toString=function(){return"[object Blob]"},i.close=function(){this.size=0,delete this.data},n}(e);e.Blob=function(e,n){var r=n?n.type||"":"",o=new t;if(e)for(var i=0,a=e.length;i-1,isMac:t.navigator.platform.toUpperCase().indexOf("MAC")>=0,keyCode:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,DELETE:46,K:75,M:77,V:86},isMetaCtrlKey:function(e){return!!(a.isMac&&e.metaKey||!a.isMac&&e.ctrlKey)},isKey:function(e,t){var n=a.getKeyCode(e);return!1===Array.isArray(t)?n===t:-1!==t.indexOf(n)},getKeyCode:function(e){var t=e.which;return null===t&&(t=null!==e.charCode?e.charCode:e.keyCode),t},blockContainerElementNames:["p","h1","h2","h3","h4","h5","h6","blockquote","pre","ul","li","ol","address","article","aside","audio","canvas","dd","dl","dt","fieldset","figcaption","figure","footer","form","header","hgroup","main","nav","noscript","output","section","video","table","thead","tbody","tfoot","tr","th","td"],emptyElementNames:["br","col","colgroup","hr","img","input","source","wbr"],extend:function(){var e=[!0].concat(Array.prototype.slice.call(arguments));return n.apply(this,e)},defaults:function(){var e=[!1].concat(Array.prototype.slice.call(arguments));return n.apply(this,e)},createLink:function(e,t,n,r){var o=e.createElement("a");return a.moveTextRangeIntoElement(t[0],t[t.length-1],o),o.setAttribute("href",n),r&&o.setAttribute("target",r),o},findOrCreateMatchingTextNodes:function(e,t,n){for(var r=e.createTreeWalker(t,NodeFilter.SHOW_ALL,null,!1),o=[],i=0,s=!1,l=null,u=null;null!==(l=r.nextNode());)if(!(l.nodeType>3))if(3===l.nodeType){if(!s&&n.startn.end+1)throw new Error("PerformLinking overshot the target!");s&&o.push(u||l),i+=l.nodeValue.length,null!==u&&(i+=u.nodeValue.length,r.nextNode()),u=null}else"img"===l.tagName.toLowerCase()&&(!s&&n.start<=i&&(s=!0),s&&o.push(l));return o},splitStartNodeIfNeeded:function(e,t,n){return t!==n?e.splitText(t-n):null},splitEndNodeIfNeeded:function(e,t,n,r){var o,i;o=r+e.nodeValue.length+(t?t.nodeValue.length:0)-1,i=n-r-(t?e.nodeValue.length:0),o>=n&&r!==o&&0!==i&&(t||e).splitText(i)},splitByBlockElements:function(t){if(3!==t.nodeType&&1!==t.nodeType)return[];var n=[],r=e.util.blockContainerElementNames.join(",");if(3===t.nodeType||0===t.querySelectorAll(r).length)return[t];for(var o=0;o0)break;r=i.nextNode()}return r},findPreviousSibling:function(e){if(!e||a.isMediumEditorElement(e))return!1;for(var t=e.previousSibling;!t&&!a.isMediumEditorElement(e.parentNode);)e=e.parentNode,t=e.previousSibling;return t},isDescendant:function(e,t,n){if(!e||!t)return!1;if(e===t)return!!n;if(1!==e.nodeType)return!1;if(r||3!==t.nodeType)return e.contains(t);for(var o=t.parentNode;null!==o;){if(o===e)return!0;o=o.parentNode}return!1},isElement:function(e){return!(!e||1!==e.nodeType)},throttle:function(e,t){var n,r,o,i=null,a=0,s=function(){a=Date.now(),i=null,o=e.apply(n,r),i||(n=r=null)};return t||0===t||(t=50),function(){var l=Date.now(),u=t-(l-a);return n=this,r=arguments,u<=0||u>t?(i&&(clearTimeout(i),i=null),a=l,o=e.apply(n,r),i||(n=r=null)):i||(i=setTimeout(s,u)),o}},traverseUp:function(e,t){if(!e)return!1;do{if(1===e.nodeType){if(t(e))return e;if(a.isMediumEditorElement(e))return!1}e=e.parentNode}while(e);return!1},htmlEntities:function(e){return String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")},insertHTMLCommand:function(t,n){var r,o,i,s,l,u,c,d=!1,p=["insertHTML",!1,n];if(!e.util.isEdge&&t.queryCommandSupported("insertHTML"))try{return t.execCommand.apply(t,p)}catch(e){}if(r=t.getSelection(),r.rangeCount){if(o=r.getRangeAt(0),c=o.commonAncestorContainer,a.isMediumEditorElement(c)&&!c.firstChild)o.selectNode(c.appendChild(t.createTextNode("")));else if(3===c.nodeType&&0===o.startOffset&&o.endOffset===c.nodeValue.length||3!==c.nodeType&&c.innerHTML===o.toString()){for(;!a.isMediumEditorElement(c)&&c.parentNode&&1===c.parentNode.childNodes.length&&!a.isMediumEditorElement(c.parentNode);)c=c.parentNode;o.selectNode(c)}for(o.deleteContents(),i=t.createElement("div"),i.innerHTML=n,s=t.createDocumentFragment();i.firstChild;)l=i.firstChild,u=s.appendChild(l);o.insertNode(s),u&&(o=o.cloneRange(),o.setStartAfter(u),o.collapse(!0),e.selection.selectRange(t,o)),d=!0}return t.execCommand.callListeners&&t.execCommand.callListeners(p,d),d},execFormatBlock:function(t,n){var r,o=a.getTopBlockContainer(e.selection.getSelectionStart(t));if("blockquote"===n){if(o&&(r=Array.prototype.slice.call(o.childNodes),r.some(function(e){return a.isBlockContainer(e)})))return t.execCommand("outdent",!1,null);if(a.isIE)return t.execCommand("indent",!1,n)}if(o&&n===o.nodeName.toLowerCase()&&(n="p"),a.isIE&&(n="<"+n+">"),o&&"blockquote"===o.nodeName.toLowerCase()){if(a.isIE&&"

"===n)return t.execCommand("outdent",!1,n);if((a.isFF||a.isEdge)&&"p"===n)return r=Array.prototype.slice.call(o.childNodes),r.some(function(e){return!a.isBlockContainer(e)})&&t.execCommand("formatBlock",!1,n),t.execCommand("outdent",!1,n)}return t.execCommand("formatBlock",!1,n)},setTargetBlank:function(e,t){var n,r=t||!1;if("a"===e.nodeName.toLowerCase())e.target="_blank";else for(e=e.getElementsByTagName("a"),n=0;nr?(o=o.parentNode,n-=1):(i=i.parentNode,r-=1);for(;o!==i;)o=o.parentNode,i=i.parentNode;return o},isElementAtBeginningOfBlock:function(e){for(var t,n;!a.isBlockContainer(e)&&!a.isMediumEditorElement(e);){for(n=e;n=n.previousSibling;)if(t=3===n.nodeType?n.nodeValue:n.textContent,t.length>0)return!1;e=e.parentNode}return!0},isMediumEditorElement:function(e){return e&&e.getAttribute&&!!e.getAttribute("data-medium-editor-element")},getContainerEditorElement:function(e){return a.traverseUp(e,function(e){return a.isMediumEditorElement(e)})},isBlockContainer:function(e){return e&&3!==e.nodeType&&-1!==a.blockContainerElementNames.indexOf(e.nodeName.toLowerCase())},getClosestBlockContainer:function(e){return a.traverseUp(e,function(e){return a.isBlockContainer(e)||a.isMediumEditorElement(e)})},getTopBlockContainer:function(e){var t=!!a.isBlockContainer(e)&&e;return a.traverseUp(e,function(e){return a.isBlockContainer(e)&&(t=e),!(t||!a.isMediumEditorElement(e))&&(t=e,!0)}),t},getFirstSelectableLeafNode:function(e){for(;e&&e.firstChild;)e=e.firstChild;if(e=a.traverseUp(e,function(e){return-1===a.emptyElementNames.indexOf(e.nodeName.toLowerCase())}),"table"===e.nodeName.toLowerCase()){var t=e.querySelector("th, td");t&&(e=t)}return e},getFirstTextNode:function(e){return a.warn("getFirstTextNode is deprecated and will be removed in version 6.0.0"),a._getFirstTextNode(e)},_getFirstTextNode:function(e){if(3===e.nodeType)return e;for(var t=0;t0){var o,i=r.getRangeAt(0),a=i.cloneRange();a.selectNodeContents(e),a.setEnd(i.startContainer,i.startOffset),o=a.toString().length,n={start:o,end:o+i.toString().length},this.doesRangeStartWithImages(i,t)&&(n.startsWithImage=!0);var s=this.getTrailingImageCount(e,n,i.endContainer,i.endOffset);if(s&&(n.trailingImageCount=s),0!==o){var l=this.getIndexRelativeToAdjacentEmptyBlocks(t,e,i.startContainer,i.startOffset);-1!==l&&(n.emptyBlocksIndex=l)}}return n},importSelection:function(e,t,n,r){if(e&&t){var o=n.createRange();o.setStart(t,0),o.collapse(!0);var i,a=t,s=[],l=0,u=!1,c=!1,d=0,p=!1,h=!1,f=null;for((r||e.startsWithImage||void 0!==e.emptyBlocksIndex)&&(h=!0);!p&&a;)if(a.nodeType>3)a=s.pop();else{if(3!==a.nodeType||c){if(e.trailingImageCount&&c&&("img"===a.nodeName.toLowerCase()&&d++,d===e.trailingImageCount)){for(var m=0;a.parentNode.childNodes[m]!==a;)m++;o.setEnd(a.parentNode,m+1),p=!0}if(!p&&1===a.nodeType)for(var g=a.childNodes.length-1;g>=0;)s.push(a.childNodes[g]),g-=1}else i=l+a.length,!u&&e.start>=l&&e.start<=i&&(h||e.start=l&&e.end<=i&&(e.trailingImageCount?c=!0:(o.setEnd(a,e.end-l),p=!0)),l=i;p||(a=s.pop())}!u&&f&&(o.setStart(f,f.length),o.setEnd(f,f.length)),void 0!==e.emptyBlocksIndex&&(o=this.importSelectionMoveCursorPastBlocks(n,t,e.emptyBlocksIndex,o)),r&&(o=this.importSelectionMoveCursorPastAnchor(e,o)),this.selectRange(n,o)}},importSelectionMoveCursorPastAnchor:function(t,n){var r=function(e){return"a"===e.nodeName.toLowerCase()};if(t.start===t.end&&3===n.startContainer.nodeType&&n.startOffset===n.startContainer.nodeValue.length&&e.util.traverseUp(n.startContainer,r)){for(var o=n.startContainer,i=n.startContainer.parentNode;null!==i&&"a"!==i.nodeName.toLowerCase();)i.childNodes[i.childNodes.length-1]!==o?i=null:(o=i,i=i.parentNode);if(null!==i&&"a"===i.nodeName.toLowerCase()){for(var a=null,s=0;null===a&&s0)break}else a===l.currentNode&&(s=l.currentNode);return s||(s=a),i.setStart(e.util.getFirstSelectableLeafNode(s),0),i},getIndexRelativeToAdjacentEmptyBlocks:function(n,r,o,i){if(o.textContent.length>0&&i>0)return-1;var a=o;if(3!==a.nodeType&&(a=o.childNodes[i]),a){if(!e.util.isElementAtBeginningOfBlock(a))return-1;var s=e.util.findPreviousSibling(a);if(!s)return-1;if(s.nodeValue)return-1}for(var l=e.util.getClosestBlockContainer(o),u=n.createTreeWalker(r,NodeFilter.SHOW_ELEMENT,t,!1),c=0;u.nextNode();){var d=""===u.currentNode.textContent;if((d||c>0)&&(c+=1),u.currentNode===l)return c;d||(c=0)}return c},doesRangeStartWithImages:function(e,t){if(0!==e.startOffset||1!==e.startContainer.nodeType)return!1;if("img"===e.startContainer.nodeName.toLowerCase())return!0;var n=e.startContainer.querySelector("img");if(!n)return!1;for(var r=t.createTreeWalker(e.startContainer,NodeFilter.SHOW_ALL,null,!1);r.nextNode();){var o=r.currentNode;if(o===n)break;if(o.nodeValue)return!1}return!0},getTrailingImageCount:function(e,t,n,r){if(0===r||1!==n.nodeType)return 0;if("img"!==n.nodeName.toLowerCase()&&!n.querySelector("img"))return 0;for(var o=n.childNodes[r-1];o.hasChildNodes();)o=o.lastChild;for(var i,a=e,s=[],l=0,u=!1,c=!1,d=!1,p=0;!d&&a;)if(a.nodeType>3)a=s.pop();else{if(3!==a.nodeType||c){if("img"===a.nodeName.toLowerCase()&&p++,a===o)d=!0;else if(1===a.nodeType)for(var h=a.childNodes.length-1;h>=0;)s.push(a.childNodes[h]),h-=1}else p=0,i=l+a.length,!u&&t.start>=l&&t.start<=i&&(u=!0),u&&t.end>=l&&t.end<=i&&(c=!0),l=i;d||(a=s.pop())}return p},selectionContainsContent:function(e){var t=e.getSelection();if(!t||t.isCollapsed||!t.rangeCount)return!1;if(""!==t.toString().trim())return!0;var n=this.getSelectedParentElement(t.getRangeAt(0));return!(!n||!("img"===n.nodeName.toLowerCase()||1===n.nodeType&&n.querySelector("img")))},selectionInContentEditableFalse:function(e){var t,n=this.findMatchingSelectionParent(function(e){var n=e&&e.getAttribute("contenteditable");return"true"===n&&(t=!0),"#text"!==e.nodeName&&"false"===n},e);return!t&&n},getSelectionHtml:function(e){var t,n,r,o="",i=e.getSelection();if(i.rangeCount){for(r=e.createElement("div"),t=0,n=i.rangeCount;t-1?[t]:t,Array.prototype.forEach.call(t,function(e){e.addEventListener(n,r,o),this.events.push([e,n,r,o])}.bind(this))},detachDOMEvent:function(t,n,r,o){var i,a,s=this.base.options.contentWindow,l=this.base.options.ownerDocument;null!==t&&(t=e.util.isElement(t)||[s,l].indexOf(t)>-1?[t]:t,Array.prototype.forEach.call(t,function(e){-1!==(i=this.indexOfListener(e,n,r,o))&&(a=this.events.splice(i,1)[0],a[0].removeEventListener(a[1],a[2],a[3]))}.bind(this)))},indexOfListener:function(e,t,n,r){var o,i,a;for(o=0,i=this.events.length;o0&&(r=-1!==o.indexOf(e.nodeName.toLowerCase())),!r&&this.style&&(t=this.style.value.split("|"),n=this.window.getComputedStyle(e,null).getPropertyValue(this.style.prop),t.forEach(function(e){this.knownState||((r=-1!==n.indexOf(e))||"text-decoration"!==this.style.prop)&&(this.knownState=r)},this)),r)}});t.isBuiltInButton=function(t){return"string"==typeof t&&e.extensions.button.prototype.defaults.hasOwnProperty(t)},e.extensions.button=t}(),function(){e.extensions.button.prototype.defaults={bold:{name:"bold",action:"bold",aria:"bold",tagNames:["b","strong"],style:{prop:"font-weight",value:"700|bold"},useQueryState:!0,contentDefault:"B",contentFA:''},italic:{name:"italic",action:"italic",aria:"italic",tagNames:["i","em"],style:{prop:"font-style",value:"italic"},useQueryState:!0,contentDefault:"I",contentFA:''},underline:{name:"underline",action:"underline",aria:"underline",tagNames:["u"],style:{prop:"text-decoration",value:"underline"},useQueryState:!0,contentDefault:"U",contentFA:''},strikethrough:{name:"strikethrough",action:"strikethrough",aria:"strike through",tagNames:["strike"],style:{prop:"text-decoration",value:"line-through"},useQueryState:!0,contentDefault:"A",contentFA:''},superscript:{name:"superscript",action:"superscript",aria:"superscript",tagNames:["sup"],contentDefault:"x1",contentFA:''},subscript:{name:"subscript",action:"subscript",aria:"subscript",tagNames:["sub"],contentDefault:"x1",contentFA:''},image:{name:"image",action:"image",aria:"image",tagNames:["img"],contentDefault:"image",contentFA:''},html:{name:"html",action:"html",aria:"evaluate html",tagNames:["iframe","object"],contentDefault:"html",contentFA:''},orderedlist:{name:"orderedlist",action:"insertorderedlist",aria:"ordered list",tagNames:["ol"],useQueryState:!0,contentDefault:"1.",contentFA:''},unorderedlist:{name:"unorderedlist",action:"insertunorderedlist",aria:"unordered list",tagNames:["ul"],useQueryState:!0,contentDefault:"",contentFA:''},indent:{name:"indent",action:"indent",aria:"indent",tagNames:[],contentDefault:"",contentFA:''},outdent:{name:"outdent",action:"outdent",aria:"outdent",tagNames:[],contentDefault:"",contentFA:''},justifyCenter:{name:"justifyCenter",action:"justifyCenter",aria:"center justify",tagNames:[],style:{prop:"text-align",value:"center"},contentDefault:"C",contentFA:''},justifyFull:{name:"justifyFull",action:"justifyFull",aria:"full justify",tagNames:[],style:{prop:"text-align",value:"justify"},contentDefault:"J",contentFA:''},justifyLeft:{name:"justifyLeft",action:"justifyLeft",aria:"left justify",tagNames:[],style:{prop:"text-align",value:"left"},contentDefault:"L",contentFA:''},justifyRight:{name:"justifyRight",action:"justifyRight",aria:"right justify",tagNames:[],style:{prop:"text-align",value:"right"},contentDefault:"R",contentFA:''},removeFormat:{name:"removeFormat",aria:"remove formatting",action:"removeFormat",contentDefault:"X",contentFA:''},quote:{name:"quote",action:"append-blockquote",aria:"blockquote",tagNames:["blockquote"],contentDefault:"",contentFA:''},pre:{name:"pre",action:"append-pre",aria:"preformatted text",tagNames:["pre"],contentDefault:"0101",contentFA:''},h1:{name:"h1",action:"append-h1",aria:"header type one",tagNames:["h1"],contentDefault:"H1",contentFA:'1'},h2:{name:"h2",action:"append-h2",aria:"header type two",tagNames:["h2"],contentDefault:"H2",contentFA:'2'},h3:{name:"h3",action:"append-h3",aria:"header type three",tagNames:["h3"],contentDefault:"H3",contentFA:'3'},h4:{name:"h4",action:"append-h4",aria:"header type four",tagNames:["h4"],contentDefault:"H4",contentFA:'4'},h5:{name:"h5",action:"append-h5",aria:"header type five",tagNames:["h5"],contentDefault:"H5",contentFA:'5'},h6:{name:"h6",action:"append-h6",aria:"header type six",tagNames:["h6"],contentDefault:"H6",contentFA:'6'}}}(),function(){var t=e.extensions.button.extend({init:function(){e.extensions.button.prototype.init.apply(this,arguments)},formSaveLabel:"✓",formCloseLabel:"×",activeClass:"medium-editor-toolbar-form-active",hasForm:!0,getForm:function(){},isDisplayed:function(){return!!this.hasForm&&this.getForm().classList.contains(this.activeClass)},showForm:function(){this.hasForm&&this.getForm().classList.add(this.activeClass)},hideForm:function(){this.hasForm&&this.getForm().classList.remove(this.activeClass)},showToolbarDefaultActions:function(){var e=this.base.getExtensionByName("toolbar");e&&e.showToolbarDefaultActions()},hideToolbarDefaultActions:function(){var e=this.base.getExtensionByName("toolbar");e&&e.hideToolbarDefaultActions()},setToolbarPosition:function(){var e=this.base.getExtensionByName("toolbar");e&&e.setToolbarPosition()}});e.extensions.form=t}(),function(){var t=e.extensions.form.extend({customClassOption:null,customClassOptionText:"Button",linkValidation:!1,placeholderText:"Paste or type a link",targetCheckbox:!1,targetCheckboxText:"Open in new window",name:"anchor",action:"createLink",aria:"link",tagNames:["a"],contentDefault:"#",contentFA:'',init:function(){e.extensions.form.prototype.init.apply(this,arguments),this.subscribe("editableKeydown",this.handleKeydown.bind(this))},handleClick:function(t){t.preventDefault(),t.stopPropagation();var n=e.selection.getSelectionRange(this.document);return"a"===n.startContainer.nodeName.toLowerCase()||"a"===n.endContainer.nodeName.toLowerCase()||e.util.getClosestTag(e.selection.getSelectedParentElement(n),"a")?this.execAction("unlink"):(this.isDisplayed()||this.showForm(),!1)},handleKeydown:function(t){e.util.isKey(t,e.util.keyCode.K)&&e.util.isMetaCtrlKey(t)&&!t.shiftKey&&this.handleClick(t)},getForm:function(){return this.form||(this.form=this.createForm()),this.form},getTemplate:function(){var e=[''];return e.push('',"fontawesome"===this.getEditorOption("buttonLabels")?'':this.formSaveLabel,""),e.push('',"fontawesome"===this.getEditorOption("buttonLabels")?'':this.formCloseLabel,""),this.targetCheckbox&&e.push('

','',"","
"),this.customClassOption&&e.push('
','',"","
"),e.join("")},isDisplayed:function(){return e.extensions.form.prototype.isDisplayed.apply(this)},hideForm:function(){e.extensions.form.prototype.hideForm.apply(this),this.getInput().value=""},showForm:function(t){var n=this.getInput(),r=this.getAnchorTargetCheckbox(),o=this.getAnchorButtonCheckbox();if(t=t||{value:""},"string"==typeof t&&(t={value:t}),this.base.saveSelection(),this.hideToolbarDefaultActions(),e.extensions.form.prototype.showForm.apply(this),this.setToolbarPosition(),n.value=t.value,n.focus(),r&&(r.checked="_blank"===t.target),o){var i=t.buttonClass?t.buttonClass.split(" "):[];o.checked=-1!==i.indexOf(this.customClassOption)}},destroy:function(){if(!this.form)return!1;this.form.parentNode&&this.form.parentNode.removeChild(this.form),delete this.form},getFormOpts:function(){var e=this.getAnchorTargetCheckbox(),t=this.getAnchorButtonCheckbox(),n={value:this.getInput().value.trim()};return this.linkValidation&&(n.value=this.checkLinkFormat(n.value)),n.target="_self",e&&e.checked&&(n.target="_blank"),t&&t.checked&&(n.buttonClass=this.customClassOption),n},doFormSave:function(){var e=this.getFormOpts();this.completeFormSave(e)},completeFormSave:function(e){this.base.restoreSelection(),this.execAction(this.action,e),this.base.checkSelection()},ensureEncodedUri:function(e){return e===decodeURI(e)?encodeURI(e):e},ensureEncodedUriComponent:function(e){return e===decodeURIComponent(e)?encodeURIComponent(e):e},ensureEncodedParam:function(e){var t=e.split("="),n=t[0],r=t[1];return n+(void 0===r?"":"="+this.ensureEncodedUriComponent(r))},ensureEncodedQuery:function(e){return e.split("&").map(this.ensureEncodedParam.bind(this)).join("&")},checkLinkFormat:function(e){var t=/^([a-z]+:)?\/\/|^(mailto|tel|maps):|^\#/i,n=t.test(e),r="",o=/^\+?\s?\(?(?:\d\s?\-?\)?){3,20}$/,i=e.match(/^(.*?)(?:\?(.*?))?(?:#(.*))?$/),a=i[1],s=i[2],l=i[3];if(o.test(e))return"tel:"+e;if(!n){var u=a.split("/")[0];(u.match(/.+(\.|:).+/)||"localhost"===u)&&(r="http://")}return r+this.ensureEncodedUri(a)+(void 0===s?"":"?"+this.ensureEncodedQuery(s))+(void 0===l?"":"#"+l)},doFormCancel:function(){this.base.restoreSelection(),this.base.checkSelection()},attachFormEvents:function(e){var t=e.querySelector(".medium-editor-toolbar-close"),n=e.querySelector(".medium-editor-toolbar-save"),r=e.querySelector(".medium-editor-toolbar-input");this.on(e,"click",this.handleFormClick.bind(this)),this.on(r,"keyup",this.handleTextboxKeyup.bind(this)),this.on(t,"click",this.handleCloseClick.bind(this)),this.on(n,"click",this.handleSaveClick.bind(this),!0)},createForm:function(){var e=this.document,t=e.createElement("div");return t.className="medium-editor-toolbar-form",t.id="medium-editor-toolbar-form-anchor-"+this.getEditorId(),t.innerHTML=this.getTemplate(),this.attachFormEvents(t),t},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},getAnchorTargetCheckbox:function(){return this.getForm().querySelector(".medium-editor-toolbar-anchor-target")},getAnchorButtonCheckbox:function(){return this.getForm().querySelector(".medium-editor-toolbar-anchor-button")},handleTextboxKeyup:function(t){if(t.keyCode===e.util.keyCode.ENTER)return t.preventDefault(),void this.doFormSave();t.keyCode===e.util.keyCode.ESCAPE&&(t.preventDefault(),this.doFormCancel())},handleFormClick:function(e){e.stopPropagation()},handleSaveClick:function(e){e.preventDefault(),this.doFormSave()},handleCloseClick:function(e){e.preventDefault(),this.doFormCancel()}});e.extensions.anchor=t}(),function(){var t=e.Extension.extend({name:"anchor-preview",hideDelay:500,previewValueSelector:"a",showWhenToolbarIsVisible:!1,showOnEmptyLinks:!0,init:function(){this.anchorPreview=this.createPreview(),this.getEditorOption("elementsContainer").appendChild(this.anchorPreview),this.attachToEditables()},getInteractionElements:function(){return this.getPreviewElement()},getPreviewElement:function(){return this.anchorPreview},createPreview:function(){var e=this.document.createElement("div");return e.id="medium-editor-anchor-preview-"+this.getEditorId(),e.className="medium-editor-anchor-preview",e.innerHTML=this.getTemplate(),this.on(e,"click",this.handleClick.bind(this)),e},getTemplate:function(){return'
'},destroy:function(){this.anchorPreview&&(this.anchorPreview.parentNode&&this.anchorPreview.parentNode.removeChild(this.anchorPreview),delete this.anchorPreview)},hidePreview:function(){this.anchorPreview&&this.anchorPreview.classList.remove("medium-editor-anchor-preview-active"),this.activeAnchor=null},showPreview:function(e){return!(!this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")&&!e.getAttribute("data-disable-preview"))||(this.previewValueSelector&&(this.anchorPreview.querySelector(this.previewValueSelector).textContent=e.attributes.href.value,this.anchorPreview.querySelector(this.previewValueSelector).href=e.attributes.href.value),this.anchorPreview.classList.add("medium-toolbar-arrow-over"),this.anchorPreview.classList.remove("medium-toolbar-arrow-under"),this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||this.anchorPreview.classList.add("medium-editor-anchor-preview-active"),this.activeAnchor=e,this.positionPreview(),this.attachPreviewHandlers(),this)},positionPreview:function(e){e=e||this.activeAnchor;var t,n,r,o,i,a=this.window.innerWidth,s=this.anchorPreview.offsetHeight,l=e.getBoundingClientRect(),u=this.diffLeft,c=this.diffTop,d=this.getEditorOption("elementsContainer"),p=["absolute","fixed"].indexOf(window.getComputedStyle(d).getPropertyValue("position"))>-1,h={};t=this.anchorPreview.offsetWidth/2;var f=this.base.getExtensionByName("toolbar");f&&(u=f.diffLeft,c=f.diffTop),n=u-t,p?(o=d.getBoundingClientRect(),["top","left"].forEach(function(e){h[e]=l[e]-o[e]}),h.width=l.width,h.height=l.height,l=h,a=o.width,i=d.scrollTop):i=this.window.pageYOffset,r=l.left+l.width/2,i+=s+l.top+l.height-c-this.anchorPreview.offsetHeight,this.anchorPreview.style.top=Math.round(i)+"px",this.anchorPreview.style.right="initial",rthis.hideDelay&&this.detachPreviewHandlers()},detachPreviewHandlers:function(){clearInterval(this.intervalTimer),this.instanceHandlePreviewMouseover&&(this.off(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.off(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.activeAnchor&&(this.off(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.off(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout))),this.hidePreview(),this.hovering=this.instanceHandlePreviewMouseover=this.instanceHandlePreviewMouseout=null},attachPreviewHandlers:function(){this.lastOver=(new Date).getTime(),this.hovering=!0,this.instanceHandlePreviewMouseover=this.handlePreviewMouseover.bind(this),this.instanceHandlePreviewMouseout=this.handlePreviewMouseout.bind(this),this.intervalTimer=setInterval(this.updatePreview.bind(this),200),this.on(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.on(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.on(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.on(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout)}});e.extensions.anchorPreview=t}(),function(){function t(t){return!e.util.getClosestTag(t,"a")}var n,r,o,i,a;n=[" ","\t","\n","\r"," "," "," "," "," ","\u2028","\u2029"],r="com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw",o="(((?:(https?://|ftps?://|nntp://)|www\\d{0,3}[.]|[a-z0-9.\\-]+[.]("+r+")\\/)\\S+(?:[^\\s`!\\[\\]{};:'\".,?«»“”‘’])))|(([a-z0-9\\-]+\\.)?[a-z0-9\\-]+\\.("+r+"))",i=new RegExp("^("+r+")$","i"),a=new RegExp(o,"gi");var s=e.Extension.extend({init:function(){e.Extension.prototype.init.apply(this,arguments),this.disableEventHandling=!1,this.subscribe("editableKeypress",this.onKeypress.bind(this)),this.subscribe("editableBlur",this.onBlur.bind(this)),this.document.execCommand("AutoUrlDetect",!1,!1)},isLastInstance:function(){for(var e=0,t=0;t0&&null!==a;)o=n.currentNode,i=o.nodeValue,i.length>t?(a=o.splitText(i.length-t),t=0):(a=n.previousNode(),t-=i.length);return a},performLinkingWithinElement:function(t){for(var n=this.findLinkableText(t),r=0;r1;)o.appendChild(r.childNodes[1])}});e.extensions.autoLink=s}(),function(){function t(t){var r=e.util.getContainerEditorElement(t);Array.prototype.slice.call(r.parentElement.querySelectorAll("."+n)).forEach(function(e){e.classList.remove(n)})}var n="medium-editor-dragover",r=e.Extension.extend({name:"fileDragging",allowedTypes:["image"],init:function(){e.Extension.prototype.init.apply(this,arguments),this.subscribe("editableDrag",this.handleDrag.bind(this)),this.subscribe("editableDrop",this.handleDrop.bind(this))},handleDrag:function(e){e.preventDefault(),e.dataTransfer.dropEffect="copy";var r=e.target.classList?e.target:e.target.parentElement;t(r),"dragover"===e.type&&r.classList.add(n)},handleDrop:function(e){e.preventDefault(),e.stopPropagation(),this.base.selectElement(e.target);var n=this.base.exportSelection();n.start=n.end,this.base.importSelection(n),e.dataTransfer.files&&Array.prototype.slice.call(e.dataTransfer.files).forEach(function(e){this.isAllowedFile(e)&&e.type.match("image")&&this.insertImageFile(e)},this),t(e.target)},isAllowedFile:function(e){return this.allowedTypes.some(function(t){return!!e.type.match(t)})},insertImageFile:function(t){if("function"==typeof FileReader){var n=new FileReader;n.readAsDataURL(t),n.addEventListener("load",function(t){var n=this.document.createElement("img");n.src=t.target.result,e.util.insertHTMLCommand(this.document,n.outerHTML)}.bind(this))}}});e.extensions.fileDragging=r}(),function(){var t=e.Extension.extend({name:"keyboard-commands",commands:[{command:"bold",key:"B",meta:!0,shift:!1,alt:!1},{command:"italic",key:"I",meta:!0,shift:!1,alt:!1},{command:"underline",key:"U",meta:!0,shift:!1,alt:!1}],init:function(){e.Extension.prototype.init.apply(this,arguments),this.subscribe("editableKeydown",this.handleKeydown.bind(this)),this.keys={},this.commands.forEach(function(e){var t=e.key.charCodeAt(0);this.keys[t]||(this.keys[t]=[]),this.keys[t].push(e)},this)},handleKeydown:function(t){var n=e.util.getKeyCode(t);if(this.keys[n]){var r=e.util.isMetaCtrlKey(t),o=!!t.shiftKey,i=!!t.altKey;this.keys[n].forEach(function(e){e.meta!==r||e.shift!==o||e.alt!==i&&void 0!==e.alt||(t.preventDefault(),t.stopPropagation(),"function"==typeof e.command?e.command.apply(this):!1!==e.command&&this.execAction(e.command))},this)}}});e.extensions.keyboardCommands=t}(),function(){var t=e.extensions.form.extend({name:"fontname",action:"fontName",aria:"change font name",contentDefault:"±",contentFA:'',fonts:["","Arial","Verdana","Times New Roman"],init:function(){e.extensions.form.prototype.init.apply(this,arguments)},handleClick:function(e){if(e.preventDefault(),e.stopPropagation(),!this.isDisplayed()){var t=this.document.queryCommandValue("fontName")+"";this.showForm(t)}return!1},getForm:function(){return this.form||(this.form=this.createForm()),this.form},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getSelect().value=""},showForm:function(e){var t=this.getSelect();this.base.saveSelection(),this.hideToolbarDefaultActions(),this.getForm().style.display="block",this.setToolbarPosition(),t.value=e||"",t.focus()},destroy:function(){if(!this.form)return!1;this.form.parentNode&&this.form.parentNode.removeChild(this.form),delete this.form},doFormSave:function(){this.base.restoreSelection(),this.base.checkSelection()},doFormCancel:function(){this.base.restoreSelection(),this.clearFontName(),this.base.checkSelection()},createForm:function(){var e,t=this.document,n=t.createElement("div"),r=t.createElement("select"),o=t.createElement("a"),i=t.createElement("a");n.className="medium-editor-toolbar-form",n.id="medium-editor-toolbar-form-fontname-"+this.getEditorId(),this.on(n,"click",this.handleFormClick.bind(this));for(var a=0;a
':"✓",n.appendChild(i),this.on(i,"click",this.handleSaveClick.bind(this),!0),o.setAttribute("href","#"),o.className="medium-editor-toobar-close",o.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'':"×",n.appendChild(o),this.on(o,"click",this.handleCloseClick.bind(this)),n},getSelect:function(){return this.getForm().querySelector("select.medium-editor-toolbar-select")},clearFontName:function(){e.selection.getSelectedElements(this.document).forEach(function(e){"font"===e.nodeName.toLowerCase()&&e.hasAttribute("face")&&e.removeAttribute("face")})},handleFontChange:function(){var e=this.getSelect().value;""===e?this.clearFontName():this.execAction("fontName",{value:e})},handleFormClick:function(e){e.stopPropagation()},handleSaveClick:function(e){e.preventDefault(),this.doFormSave()},handleCloseClick:function(e){e.preventDefault(),this.doFormCancel()}});e.extensions.fontName=t}(),function(){var t=e.extensions.form.extend({name:"fontsize",action:"fontSize",aria:"increase/decrease font size",contentDefault:"±",contentFA:'',init:function(){e.extensions.form.prototype.init.apply(this,arguments)},handleClick:function(e){if(e.preventDefault(),e.stopPropagation(),!this.isDisplayed()){var t=this.document.queryCommandValue("fontSize")+"";this.showForm(t)}return!1},getForm:function(){return this.form||(this.form=this.createForm()),this.form},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(e){var t=this.getInput();this.base.saveSelection(),this.hideToolbarDefaultActions(),this.getForm().style.display="block",this.setToolbarPosition(),t.value=e||"",t.focus()},destroy:function(){if(!this.form)return!1;this.form.parentNode&&this.form.parentNode.removeChild(this.form),delete this.form},doFormSave:function(){this.base.restoreSelection(),this.base.checkSelection()},doFormCancel:function(){this.base.restoreSelection(),this.clearFontSize(),this.base.checkSelection()},createForm:function(){var e=this.document,t=e.createElement("div"),n=e.createElement("input"),r=e.createElement("a"),o=e.createElement("a");return t.className="medium-editor-toolbar-form",t.id="medium-editor-toolbar-form-fontsize-"+this.getEditorId(),this.on(t,"click",this.handleFormClick.bind(this)),n.setAttribute("type","range"),n.setAttribute("min","1"),n.setAttribute("max","7"),n.className="medium-editor-toolbar-input",t.appendChild(n),this.on(n,"change",this.handleSliderChange.bind(this)),o.setAttribute("href","#"),o.className="medium-editor-toobar-save",o.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'':"✓",t.appendChild(o),this.on(o,"click",this.handleSaveClick.bind(this),!0),r.setAttribute("href","#"),r.className="medium-editor-toobar-close",r.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'':"×",t.appendChild(r),this.on(r,"click",this.handleCloseClick.bind(this)),t},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},clearFontSize:function(){e.selection.getSelectedElements(this.document).forEach(function(e){"font"===e.nodeName.toLowerCase()&&e.hasAttribute("size")&&e.removeAttribute("size")})},handleSliderChange:function(){var e=this.getInput().value;"4"===e?this.clearFontSize():this.execAction("fontSize",{value:e})},handleFormClick:function(e){e.stopPropagation()},handleSaveClick:function(e){e.preventDefault(),this.doFormSave()},handleCloseClick:function(e){e.preventDefault(),this.doFormCancel()}});e.extensions.fontSize=t}(),function(){function t(){return[[new RegExp(/^[\s\S]*]*>\s*|\s*<\/body[^>]*>[\s\S]*$/g),""],[new RegExp(/|/g),""],[new RegExp(/
$/i),""],[new RegExp(/<[^>]*docs-internal-guid[^>]*>/gi),""],[new RegExp(/<\/b>(]*>)?$/gi),""],[new RegExp(/\s+<\/span>/g)," "],[new RegExp(/
/g),"
"],[new RegExp(/]*(font-style:italic;font-weight:(bold|700)|font-weight:(bold|700);font-style:italic)[^>]*>/gi),''],[new RegExp(/]*font-style:italic[^>]*>/gi),''],[new RegExp(/]*font-weight:(bold|700)[^>]*>/gi),''],[new RegExp(/<(\/?)(i|b|a)>/gi),"<$1$2>"],[new RegExp(/<a(?:(?!href).)+href=(?:"|”|“|"|“|”)(((?!"|”|“|"|“|”).)*)(?:"|”|“|"|“|”)(?:(?!>).)*>/gi),''],[new RegExp(/<\/p>\n+/gi),"

"],[new RegExp(/\n+

/gi),""],[new RegExp(/(((?!/gi),"$1"]]}function n(e,t,n){var r=e.clipboardData||t.clipboardData||n.dataTransfer,o={};if(!r)return o;if(r.getData){var i=r.getData("Text");i&&i.length>0&&(o["text/plain"]=i)}if(r.types)for(var a=0;a1)for(i=0;i"+e.util.htmlEntities(o[i])+"

");else a=e.util.htmlEntities(o[0]);e.util.insertHTMLCommand(this.document,a)},handlePasteBinPaste:function(e){if(e.defaultPrevented)return void this.removePasteBin();var t=n(e,this.window,this.document),r=t["text/html"],i=t["text/plain"],a=o;if(!this.cleanPastedHTML||r)return e.preventDefault(),this.removePasteBin(),this.doPaste(r,i,a),void this.trigger("editablePaste",{currentTarget:a,target:a},a);setTimeout(function(){this.cleanPastedHTML&&(r=this.getPasteBinHtml()),this.removePasteBin(),this.doPaste(r,i,a),this.trigger("editablePaste",{currentTarget:a,target:a},a)}.bind(this),0)},handleKeydown:function(t,n){e.util.isKey(t,e.util.keyCode.V)&&e.util.isMetaCtrlKey(t)&&(t.stopImmediatePropagation(),this.removePasteBin(),this.createPasteBin(n))},createPasteBin:function(t){var n,a=e.selection.getSelectionRange(this.document),s=this.window.pageYOffset;o=t,a&&(n=a.getClientRects(),n.length?s+=n[0].top:s+=a.startContainer.getBoundingClientRect().top),r=a;var l=this.document.createElement("div");l.id=this.pasteBinId="medium-editor-pastebin-"+ +Date.now(),l.setAttribute("style","border: 1px red solid; position: absolute; top: "+s+"px; width: 10px; height: 10px; overflow: hidden; opacity: 0"),l.setAttribute("contentEditable",!0),l.innerHTML="%ME_PASTEBIN%",this.document.body.appendChild(l),this.on(l,"focus",i),this.on(l,"focusin",i),this.on(l,"focusout",i),l.focus(),e.selection.selectNode(l,this.document),this.boundHandlePaste||(this.boundHandlePaste=this.handlePasteBinPaste.bind(this)),this.on(l,"paste",this.boundHandlePaste)},removePasteBin:function(){null!==r&&(e.selection.selectRange(this.document,r),r=null),null!==o&&(o=null);var t=this.getPasteBin();t&&t&&(this.off(t,"focus",i),this.off(t,"focusin",i),this.off(t,"focusout",i),this.off(t,"paste",this.boundHandlePaste),t.parentElement.removeChild(t))},getPasteBin:function(){return this.document.getElementById(this.pasteBinId)},getPasteBinHtml:function(){var e=this.getPasteBin();if(!e)return!1;if(e.firstChild&&"mcepastebin"===e.firstChild.id)return!1;var t=e.innerHTML;return!(!t||"%ME_PASTEBIN%"===t)&&t},cleanPaste:function(e){var n,r,o,i,a=/"+e.split("

").join("

")+"

",r=o.querySelectorAll("a,p,div,br"),n=0;n"+r.innerHTML+"
":o.innerHTML=r.innerHTML,r.parentNode.replaceChild(o,r);for(i=t.querySelectorAll("span"),n=0;n0&&(r[0].classList.add(this.firstButtonClass),r[r.length-1].classList.add(this.lastButtonClass)),s},destroy:function(){this.toolbar&&(this.toolbar.parentNode&&this.toolbar.parentNode.removeChild(this.toolbar),delete this.toolbar)},getInteractionElements:function(){return this.getToolbarElement()},getToolbarElement:function(){return this.toolbar||(this.toolbar=this.createToolbar()),this.toolbar},getToolbarActionsElement:function(){return this.getToolbarElement().querySelector(".medium-editor-toolbar-actions")},initThrottledMethods:function(){this.throttledPositionToolbar=e.util.throttle(function(){this.base.isActive&&this.positionToolbarIfShown()}.bind(this))},attachEventHandlers:function(){this.subscribe("blur",this.handleBlur.bind(this)),this.subscribe("focus",this.handleFocus.bind(this)),this.subscribe("editableClick",this.handleEditableClick.bind(this)),this.subscribe("editableKeyup",this.handleEditableKeyup.bind(this)),this.on(this.document.documentElement,"mouseup",this.handleDocumentMouseup.bind(this)),this.static&&this.sticky&&this.on(this.window,"scroll",this.handleWindowScroll.bind(this),!0),this.on(this.window,"resize",this.handleWindowResize.bind(this))},handleWindowScroll:function(){this.positionToolbarIfShown()},handleWindowResize:function(){this.throttledPositionToolbar()},handleDocumentMouseup:function(t){if(t&&t.target&&e.util.isDescendant(this.getToolbarElement(),t.target))return!1;this.checkState()},handleEditableClick:function(){setTimeout(function(){this.checkState()}.bind(this),0)},handleEditableKeyup:function(){this.checkState()},handleBlur:function(){clearTimeout(this.hideTimeout),clearTimeout(this.delayShowTimeout),this.hideTimeout=setTimeout(function(){this.hideToolbar()}.bind(this),1)},handleFocus:function(){this.checkState()},isDisplayed:function(){return this.getToolbarElement().classList.contains("medium-editor-toolbar-active")},showToolbar:function(){clearTimeout(this.hideTimeout),this.isDisplayed()||(this.getToolbarElement().classList.add("medium-editor-toolbar-active"),this.trigger("showToolbar",{},this.base.getFocusedElement()))},hideToolbar:function(){this.isDisplayed()&&(this.getToolbarElement().classList.remove("medium-editor-toolbar-active"),this.trigger("hideToolbar",{},this.base.getFocusedElement()))},isToolbarDefaultActionsDisplayed:function(){return"block"===this.getToolbarActionsElement().style.display},hideToolbarDefaultActions:function(){this.isToolbarDefaultActionsDisplayed()&&(this.getToolbarActionsElement().style.display="none")},showToolbarDefaultActions:function(){this.hideExtensionForms(),this.isToolbarDefaultActionsDisplayed()||(this.getToolbarActionsElement().style.display="block"),this.delayShowTimeout=this.base.delay(function(){this.showToolbar()}.bind(this))},hideExtensionForms:function(){this.forEachExtension(function(e){e.hasForm&&e.isDisplayed()&&e.hideForm()})},multipleBlockElementsSelected:function(){var t=/<[^\/>][^>]*><\/[^>]+>/gim,n=new RegExp("<("+e.util.blockContainerElementNames.join("|")+")[^>]*>","g"),r=e.selection.getSelectionHtml(this.document).replace(t,""),o=r.match(n);return!!o&&o.length>1},modifySelection:function(){var t=this.window.getSelection(),n=t.getRangeAt(0);if(this.standardizeSelectionStart&&n.startContainer.nodeValue&&n.startOffset===n.startContainer.nodeValue.length){var r=e.util.findAdjacentTextNodeWithContent(e.selection.getSelectionElement(this.window),n.startContainer,this.document);if(r){for(var o=0;0===r.nodeValue.substr(o,1).trim().length;)o+=1;n=e.selection.select(this.document,r,o,n.endContainer,n.endOffset)}}},checkState:function(){if(!this.base.preventSelectionUpdates){if(!this.base.getFocusedElement()||e.selection.selectionInContentEditableFalse(this.window))return this.hideToolbar();var t=e.selection.getSelectionElement(this.window);return!t||-1===this.getEditorElements().indexOf(t)||t.getAttribute("data-disable-toolbar")?this.hideToolbar():this.updateOnEmptySelection&&this.static?this.showAndUpdateToolbar():!e.selection.selectionContainsContent(this.document)||!1===this.allowMultiParagraphSelection&&this.multipleBlockElementsSelected()?this.hideToolbar():void this.showAndUpdateToolbar()}},showAndUpdateToolbar:function(){this.modifySelection(),this.setToolbarButtonStates(),this.trigger("positionToolbar",{},this.base.getFocusedElement()),this.showToolbarDefaultActions(),this.setToolbarPosition()},setToolbarButtonStates:function(){this.forEachExtension(function(e){"function"==typeof e.isActive&&"function"==typeof e.setInactive&&e.setInactive()}),this.checkActiveButtons()},checkActiveButtons:function(){var t,n=[],r=null,o=e.selection.getSelectionRange(this.document),i=function(e){"function"==typeof e.checkState?e.checkState(t):"function"==typeof e.isActive&&"function"==typeof e.isAlreadyApplied&&"function"==typeof e.setActive&&!e.isActive()&&e.isAlreadyApplied(t)&&e.setActive()};if(o&&(this.forEachExtension(function(e){if("function"==typeof e.queryCommandState&&null!==(r=e.queryCommandState()))return void(r&&"function"==typeof e.setActive&&e.setActive());n.push(e)}),t=e.selection.getSelectedParentElement(o),this.getEditorElements().some(function(n){return e.util.isDescendant(n,t,!0)})))for(;t&&(n.forEach(i),!e.util.isMediumEditorElement(t));)t=t.parentNode},positionToolbarIfShown:function(){this.isDisplayed()&&this.setToolbarPosition()},setToolbarPosition:function(){var e=this.base.getFocusedElement(),t=this.window.getSelection();if(!e)return this;!this.static&&t.isCollapsed||(this.showToolbar(),this.relativeContainer||(this.static?this.positionStaticToolbar(e):this.positionToolbar(t)),this.trigger("positionedToolbar",{},this.base.getFocusedElement()))},positionStaticToolbar:function(e){this.getToolbarElement().style.left="0";var t,n=this.document.documentElement&&this.document.documentElement.scrollTop||this.document.body.scrollTop,r=this.window.innerWidth,o=this.getToolbarElement(),i=e.getBoundingClientRect(),a=i.top+n,s=i.left+i.width/2,l=o.offsetHeight,u=o.offsetWidth,c=u/2;switch(this.sticky?n>a+e.offsetHeight-l-this.stickyTopOffset?(o.style.top=a+e.offsetHeight-l+"px",o.classList.remove("medium-editor-sticky-toolbar")):n>a-l-this.stickyTopOffset?(o.classList.add("medium-editor-sticky-toolbar"),o.style.top=this.stickyTopOffset+"px"):(o.classList.remove("medium-editor-sticky-toolbar"),o.style.top=a-l+"px"):o.style.top=a-l+"px",this.align){case"left":t=i.left;break;case"right":t=i.right-u;break;case"center":t=s-c}t<0?t=0:t+u>r&&(t=r-Math.ceil(u)-1),o.style.left=t+"px"},positionToolbar:function(e){this.getToolbarElement().style.left="0",this.getToolbarElement().style.right="initial";var t=e.getRangeAt(0),n=t.getBoundingClientRect();(!n||0===n.height&&0===n.width&&t.startContainer===t.endContainer)&&(n=1===t.startContainer.nodeType&&t.startContainer.querySelector("img")?t.startContainer.querySelector("img").getBoundingClientRect():t.startContainer.getBoundingClientRect());var r,o,i=this.window.innerWidth,a=this.getToolbarElement(),s=a.offsetHeight,l=a.offsetWidth,u=l/2,c=this.diffLeft-u,d=this.getEditorOption("elementsContainer"),p=["absolute","fixed"].indexOf(window.getComputedStyle(d).getPropertyValue("position"))>-1,h={},f={};p?(o=d.getBoundingClientRect(),["top","left"].forEach(function(e){f[e]=n[e]-o[e]}),f.width=n.width,f.height=n.height,n=f,i=o.width,h.top=d.scrollTop):h.top=this.window.pageYOffset,r=n.left+n.width/2,h.top+=n.top-s,n.top<50?(a.classList.add("medium-toolbar-arrow-over"),a.classList.remove("medium-toolbar-arrow-under"),h.top+=50+n.height-this.diffTop):(a.classList.add("medium-toolbar-arrow-under"),a.classList.remove("medium-toolbar-arrow-over"),h.top+=this.diffTop),r'),n.onload=function(){var e=this.document.getElementById(r);e&&(e.removeAttribute("id"),e.removeAttribute("class"),e.src=n.result)}.bind(this)}}.bind(this))),t.target.classList.remove("medium-editor-dragover")}});e.extensions.imageDragging=t}(),function(){function t(t){var n=e.selection.getSelectionStart(this.options.ownerDocument),r=n.textContent,o=e.selection.getCaretOffsets(n);(void 0===r[o.left-1]||""===r[o.left-1].trim()||void 0!==r[o.left]&&""===r[o.left].trim())&&t.preventDefault()}function n(t,n){if(this.options.disableReturn||n.getAttribute("data-disable-return"))t.preventDefault();else if(this.options.disableDoubleReturn||n.getAttribute("data-disable-double-return")){var r=e.selection.getSelectionStart(this.options.ownerDocument);(r&&""===r.textContent.trim()&&"li"!==r.nodeName.toLowerCase()||r.previousElementSibling&&"br"!==r.previousElementSibling.nodeName.toLowerCase()&&""===r.previousElementSibling.textContent.trim())&&t.preventDefault()}}function r(t){var n=e.selection.getSelectionStart(this.options.ownerDocument);"pre"===(n&&n.nodeName.toLowerCase())&&(t.preventDefault(),e.util.insertHTMLCommand(this.options.ownerDocument," ")),e.util.isListItem(n)&&(t.preventDefault(),t.shiftKey?this.options.ownerDocument.execCommand("outdent",!1,null):this.options.ownerDocument.execCommand("indent",!1,null))}function o(t){var n,r=e.selection.getSelectionStart(this.options.ownerDocument),o=r.nodeName.toLowerCase(),i=/^(\s+|)?$/i,a=/h\d/i;e.util.isKey(t,[e.util.keyCode.BACKSPACE,e.util.keyCode.ENTER])&&r.previousElementSibling&&a.test(o)&&0===e.selection.getCaretOffsets(r).left?e.util.isKey(t,e.util.keyCode.BACKSPACE)&&i.test(r.previousElementSibling.innerHTML)?(r.previousElementSibling.parentNode.removeChild(r.previousElementSibling),t.preventDefault()):!this.options.disableDoubleReturn&&e.util.isKey(t,e.util.keyCode.ENTER)&&(n=this.options.ownerDocument.createElement("p"),n.innerHTML="
",r.previousElementSibling.parentNode.insertBefore(n,r),t.preventDefault()):e.util.isKey(t,e.util.keyCode.DELETE)&&r.nextElementSibling&&r.previousElementSibling&&!a.test(o)&&i.test(r.innerHTML)&&a.test(r.nextElementSibling.nodeName.toLowerCase())?(e.selection.moveCursor(this.options.ownerDocument,r.nextElementSibling),r.previousElementSibling.parentNode.removeChild(r),t.preventDefault()):e.util.isKey(t,e.util.keyCode.BACKSPACE)&&"li"===o&&i.test(r.innerHTML)&&!r.previousElementSibling&&!r.parentElement.previousElementSibling&&r.nextElementSibling&&"li"===r.nextElementSibling.nodeName.toLowerCase()?(n=this.options.ownerDocument.createElement("p"),n.innerHTML="
",r.parentElement.parentElement.insertBefore(n,r.parentElement),e.selection.moveCursor(this.options.ownerDocument,n),r.parentElement.removeChild(r),t.preventDefault()):e.util.isKey(t,e.util.keyCode.BACKSPACE)&&!1!==e.util.getClosestTag(r,"blockquote")&&0===e.selection.getCaretOffsets(r).left?(t.preventDefault(),e.util.execFormatBlock(this.options.ownerDocument,"p")):e.util.isKey(t,e.util.keyCode.ENTER)&&!1!==e.util.getClosestTag(r,"blockquote")&&0===e.selection.getCaretOffsets(r).right?(n=this.options.ownerDocument.createElement("p"),n.innerHTML="
",r.parentElement.insertBefore(n,r.nextSibling),e.selection.moveCursor(this.options.ownerDocument,n),t.preventDefault()):e.util.isKey(t,e.util.keyCode.BACKSPACE)&&e.util.isMediumEditorElement(r.parentElement)&&!r.previousElementSibling&&r.nextElementSibling&&i.test(r.innerHTML)&&(t.preventDefault(),e.selection.moveCursor(this.options.ownerDocument,r.nextSibling),r.parentElement.removeChild(r))}function i(t){var n,r=e.selection.getSelectionStart(this.options.ownerDocument);r&&(e.util.isMediumEditorElement(r)&&0===r.children.length&&!e.util.isBlockContainer(r)&&this.options.ownerDocument.execCommand("formatBlock",!1,"p"),!e.util.isKey(t,e.util.keyCode.ENTER)||e.util.isListItem(r)||e.util.isBlockContainer(r)||(n=r.nodeName.toLowerCase(),"a"===n?this.options.ownerDocument.execCommand("unlink",!1,null):t.shiftKey||t.ctrlKey||this.options.ownerDocument.execCommand("formatBlock",!1,"p")))}function a(e,t){var n=t.parentNode.querySelector('textarea[medium-editor-textarea-id="'+t.getAttribute("medium-editor-textarea-id")+'"]');n&&(n.value=t.innerHTML.trim())}function s(e){e._mediumEditors||(e._mediumEditors=[null]),this.id||(this.id=e._mediumEditors.length),e._mediumEditors[this.id]=this}function l(e){e._mediumEditors&&e._mediumEditors[this.id]&&(e._mediumEditors[this.id]=null)}function u(t,n,r){var o=[];if(t||(t=[]),"string"==typeof t&&(t=n.querySelectorAll(t)),e.util.isElement(t)&&(t=[t]),r)for(var i=0;i=0&&(r=e.selection.exportSelection(t,this.options.ownerDocument)),null!==r&&0!==n&&(r.editableElementIndex=n),r},saveSelection:function(){this.selectionState=this.exportSelection()},importSelection:function(t,n){if(t){var r=this.elements[t.editableElementIndex||0];e.selection.importSelection(t,r,this.options.ownerDocument,n)}},restoreSelection:function(){this.importSelection(this.selectionState)},createLink:function(t){var n,r=e.selection.getSelectionElement(this.options.contentWindow),o={};if(-1!==this.elements.indexOf(r)){try{if(this.events.disableCustomEvent("editableInput"),t.url&&e.util.deprecated(".url option for createLink",".value","6.0.0"),(n=t.url||t.value)&&n.trim().length>0){var i=this.options.contentWindow.getSelection();if(i){var a,s,l,u,c=i.getRangeAt(0),d=c.commonAncestorContainer;if(3===c.endContainer.nodeType&&3!==c.startContainer.nodeType&&0===c.startOffset&&c.startContainer.firstChild===c.endContainer&&(d=c.endContainer),s=e.util.getClosestBlockContainer(c.startContainer),l=e.util.getClosestBlockContainer(c.endContainer),3!==d.nodeType&&0!==d.textContent.length&&s===l){var p=s||r,h=this.options.ownerDocument.createDocumentFragment();this.execAction("unlink"),a=this.exportSelection(),h.appendChild(p.cloneNode(!0)),r===p?e.selection.select(this.options.ownerDocument,p.firstChild,0,p.lastChild,3===p.lastChild.nodeType?p.lastChild.nodeValue.length:p.lastChild.childNodes.length):e.selection.select(this.options.ownerDocument,p,0,p,p.childNodes.length);var f=this.exportSelection();u=e.util.findOrCreateMatchingTextNodes(this.options.ownerDocument,h,{start:a.start-f.start,end:a.end-f.start,editableElementIndex:a.editableElementIndex}),0===u.length&&(h=this.options.ownerDocument.createDocumentFragment(),h.appendChild(d.cloneNode(!0)),u=[h.firstChild.firstChild,h.firstChild.lastChild]),e.util.createLink(this.options.ownerDocument,u,n.trim());var m=(h.firstChild.innerHTML.match(/^\s+/)||[""])[0].length;e.util.insertHTMLCommand(this.options.ownerDocument,h.firstChild.innerHTML.replace(/^\s+/,"")),a.start-=m,a.end-=m,this.importSelection(a)}else this.options.ownerDocument.execCommand("createLink",!1,n);this.options.targetBlank||"_blank"===t.target?e.util.setTargetBlank(e.selection.getSelectionStart(this.options.ownerDocument),n):e.util.removeTargetBlank(e.selection.getSelectionStart(this.options.ownerDocument),n),t.buttonClass&&e.util.addClassToAnchors(e.selection.getSelectionStart(this.options.ownerDocument),t.buttonClass)}}if(this.options.targetBlank||"_blank"===t.target||t.buttonClass){o=this.options.ownerDocument.createEvent("HTMLEvents"),o.initEvent("input",!0,!0,this.options.contentWindow);for(var g=0,v=this.elements.length;g1?t[1]:"";return{major:parseInt(n[0],10),minor:parseInt(n[1],10),revision:parseInt(n[2],10),preRelease:r,toString:function(){return[n[0],n[1],n[2]].join(".")+(r?"-"+r:"")}}},e.version=e.parseVersionString.call(this,{version:"5.23.0"}.version),e}())}).call(t,n(31))},function(e,t,n){"use strict";function r(e,t,n,r,o){}e.exports=r},function(e,t,n){"use strict";var r=n(7),o=n(0),i=n(55);e.exports=function(){function e(e,t,n,r,a,s){s!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t,n){"use strict";var r=n(7),o=n(0),i=n(1),a=n(55),s=n(116);e.exports=function(e,t){function n(e){var t=e&&(_&&e[_]||e[T]);if("function"==typeof t)return t}function l(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function u(e){this.message=e,this.stack=""}function c(e){function n(n,r,i,s,l,c,d){if(s=s||k,c=c||i,d!==a)if(t)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else;return null==r[i]?n?new u(null===r[i]?"The "+l+" `"+c+"` is marked as required in `"+s+"`, but its value is `null`.":"The "+l+" `"+c+"` is marked as required in `"+s+"`, but its value is `undefined`."):null:e(r,i,s,l,c)}var r=n.bind(null,!1);return r.isRequired=n.bind(null,!0),r}function d(e){function t(t,n,r,o,i,a){var s=t[n];if(C(s)!==e)return new u("Invalid "+o+" `"+i+"` of type `"+E(s)+"` supplied to `"+r+"`, expected `"+e+"`.");return null}return c(t)}function p(e){function t(t,n,r,o,i){if("function"!=typeof e)return new u("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var s=t[n];if(!Array.isArray(s)){return new u("Invalid "+o+" `"+i+"` of type `"+C(s)+"` supplied to `"+r+"`, expected an array.")}for(var l=0;l=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}Object.defineProperty(t,"__esModule",{value:!0}),t.CopyToClipboard=void 0;var i=Object.assign||function(e){for(var t=1;t8&&C<=11),x=32,_=String.fromCharCode(x),T={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["topCompositionEnd","topKeyPress","topTextInput","topPaste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:["topBlur","topCompositionEnd","topKeyDown","topKeyPress","topKeyUp","topMouseDown"]},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:["topBlur","topCompositionStart","topKeyDown","topKeyPress","topKeyUp","topMouseDown"]},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:["topBlur","topCompositionUpdate","topKeyDown","topKeyPress","topKeyUp","topMouseDown"]}},k=!1,P=null,S={eventTypes:T,extractEvents:function(e,t,n,r){return[l(e,t,n,r),d(e,t,n,r)]}};e.exports=S},function(e,t,n){"use strict";var r=n(56),o=n(6),i=(n(8),n(104),n(176)),a=n(111),s=n(114),l=(n(1),s(function(e){return a(e)})),u=!1,c="cssFloat";if(o.canUseDOM){var d=document.createElement("div").style;try{d.font=""}catch(e){u=!0}void 0===document.documentElement.style.cssFloat&&(c="styleFloat")}var p={createMarkupForStyles:function(e,t){var n="";for(var r in e)if(e.hasOwnProperty(r)){var o=e[r];null!=o&&(n+=l(r)+":",n+=i(r,o,t)+";")}return n||null},setValueForStyles:function(e,t,n){var o=e.style;for(var a in t)if(t.hasOwnProperty(a)){var s=i(a,t[a],n);if("float"!==a&&"cssFloat"!==a||(a=c),s)o[a]=s;else{var l=u&&r.shorthandPropertyExpansions[a];if(l)for(var d in l)o[d]="";else o[a]=""}}}};e.exports=p},function(e,t,n){"use strict";function r(e){var t=e.nodeName&&e.nodeName.toLowerCase();return"select"===t||"input"===t&&"file"===e.type}function o(e){var t=_.getPooled(S.change,A,e,T(e));C.accumulateTwoPhaseDispatches(t),x.batchedUpdates(i,t)}function i(e){b.enqueueEvents(e),b.processEventQueue(!1)}function a(e,t){N=e,A=t,N.attachEvent("onchange",o)}function s(){N&&(N.detachEvent("onchange",o),N=null,A=null)}function l(e,t){if("topChange"===e)return t}function u(e,t,n){"topFocus"===e?(s(),a(t,n)):"topBlur"===e&&s()}function c(e,t){N=e,A=t,O=e.value,D=Object.getOwnPropertyDescriptor(e.constructor.prototype,"value"),Object.defineProperty(N,"value",R),N.attachEvent?N.attachEvent("onpropertychange",p):N.addEventListener("propertychange",p,!1)}function d(){N&&(delete N.value,N.detachEvent?N.detachEvent("onpropertychange",p):N.removeEventListener("propertychange",p,!1),N=null,A=null,O=null,D=null)}function p(e){if("value"===e.propertyName){var t=e.srcElement.value;t!==O&&(O=t,o(e))}}function h(e,t){if("topInput"===e)return t}function f(e,t,n){"topFocus"===e?(d(),c(t,n)):"topBlur"===e&&d()}function m(e,t){if(("topSelectionChange"===e||"topKeyUp"===e||"topKeyDown"===e)&&N&&N.value!==O)return O=N.value,A}function g(e){return e.nodeName&&"input"===e.nodeName.toLowerCase()&&("checkbox"===e.type||"radio"===e.type)}function v(e,t){if("topClick"===e)return t}function y(e,t){if(null!=e){var n=e._wrapperState||t._wrapperState;if(n&&n.controlled&&"number"===t.type){var r=""+t.value;t.getAttribute("value")!==r&&t.setAttribute("value",r)}}}var b=n(20),C=n(21),E=n(6),w=n(4),x=n(9),_=n(10),T=n(44),k=n(45),P=n(73),S={change:{phasedRegistrationNames:{bubbled:"onChange",captured:"onChangeCapture"},dependencies:["topBlur","topChange","topClick","topFocus","topInput","topKeyDown","topKeyUp","topSelectionChange"]}},N=null,A=null,O=null,D=null,M=!1;E.canUseDOM&&(M=k("change")&&(!document.documentMode||document.documentMode>8));var I=!1;E.canUseDOM&&(I=k("input")&&(!document.documentMode||document.documentMode>11));var R={get:function(){return D.get.call(this)},set:function(e){O=""+e,D.set.call(this,e)}},L={eventTypes:S,extractEvents:function(e,t,n,o){var i,a,s=t?w.getNodeFromInstance(t):window;if(r(s)?M?i=l:a=u:P(s)?I?i=h:(i=m,a=f):g(s)&&(i=v),i){var c=i(e,t);if(c){var d=_.getPooled(S.change,c,n,o);return d.type="change",C.accumulateTwoPhaseDispatches(d),d}}a&&a(e,s,t),"topBlur"===e&&y(t,s)}};e.exports=L},function(e,t,n){"use strict";var r=n(2),o=n(14),i=n(6),a=n(107),s=n(7),l=(n(0),{dangerouslyReplaceNodeWithMarkup:function(e,t){if(i.canUseDOM||r("56"),t||r("57"),"HTML"===e.nodeName&&r("58"),"string"==typeof t){var n=a(t,s)[0];e.parentNode.replaceChild(n,e)}else o.replaceChildWithTree(e,t)}});e.exports=l},function(e,t,n){"use strict";var r=["ResponderEventPlugin","SimpleEventPlugin","TapEventPlugin","EnterLeaveEventPlugin","ChangeEventPlugin","SelectEventPlugin","BeforeInputEventPlugin"];e.exports=r},function(e,t,n){"use strict";var r=n(21),o=n(4),i=n(25),a={mouseEnter:{registrationName:"onMouseEnter",dependencies:["topMouseOut","topMouseOver"]},mouseLeave:{registrationName:"onMouseLeave",dependencies:["topMouseOut","topMouseOver"]}},s={eventTypes:a,extractEvents:function(e,t,n,s){if("topMouseOver"===e&&(n.relatedTarget||n.fromElement))return null;if("topMouseOut"!==e&&"topMouseOver"!==e)return null;var l;if(s.window===s)l=s;else{var u=s.ownerDocument;l=u?u.defaultView||u.parentWindow:window}var c,d;if("topMouseOut"===e){c=t;var p=n.relatedTarget||n.toElement;d=p?o.getClosestInstanceFromNode(p):null}else c=null,d=t;if(c===d)return null;var h=null==c?l:o.getNodeFromInstance(c),f=null==d?l:o.getNodeFromInstance(d),m=i.getPooled(a.mouseLeave,c,n,s);m.type="mouseleave",m.target=h,m.relatedTarget=f;var g=i.getPooled(a.mouseEnter,d,n,s);return g.type="mouseenter",g.target=f,g.relatedTarget=h,r.accumulateEnterLeaveDispatches(m,g,c,d),[m,g]}};e.exports=s},function(e,t,n){"use strict";function r(e){this._root=e,this._startText=this.getText(),this._fallbackText=null}var o=n(3),i=n(12),a=n(71);o(r.prototype,{destructor:function(){this._root=null,this._startText=null,this._fallbackText=null},getText:function(){return"value"in this._root?this._root.value:this._root[a()]},getData:function(){if(this._fallbackText)return this._fallbackText;var e,t,n=this._startText,r=n.length,o=this.getText(),i=o.length;for(e=0;e1?1-t:void 0;return this._fallbackText=o.slice(e,s),this._fallbackText}}),i.addPoolingTo(r),e.exports=r},function(e,t,n){"use strict";var r=n(15),o=r.injection.MUST_USE_PROPERTY,i=r.injection.HAS_BOOLEAN_VALUE,a=r.injection.HAS_NUMERIC_VALUE,s=r.injection.HAS_POSITIVE_NUMERIC_VALUE,l=r.injection.HAS_OVERLOADED_BOOLEAN_VALUE,u={isCustomAttribute:RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+r.ATTRIBUTE_NAME_CHAR+"]*$")),Properties:{accept:0,acceptCharset:0,accessKey:0,action:0,allowFullScreen:i,allowTransparency:0,alt:0,as:0,async:i,autoComplete:0,autoPlay:i,capture:i,cellPadding:0,cellSpacing:0,charSet:0,challenge:0,checked:o|i,cite:0,classID:0,className:0,cols:s,colSpan:0,content:0,contentEditable:0,contextMenu:0,controls:i,coords:0,crossOrigin:0,data:0,dateTime:0,default:i,defer:i,dir:0,disabled:i,download:l,draggable:0,encType:0,form:0,formAction:0,formEncType:0,formMethod:0,formNoValidate:i,formTarget:0,frameBorder:0,headers:0,height:0,hidden:i,high:0,href:0,hrefLang:0,htmlFor:0,httpEquiv:0,icon:0,id:0,inputMode:0,integrity:0,is:0,keyParams:0,keyType:0,kind:0,label:0,lang:0,list:0,loop:i,low:0,manifest:0,marginHeight:0,marginWidth:0,max:0,maxLength:0,media:0,mediaGroup:0,method:0,min:0,minLength:0,multiple:o|i,muted:o|i,name:0,nonce:0,noValidate:i,open:i,optimum:0,pattern:0,placeholder:0,playsInline:i,poster:0,preload:0,profile:0,radioGroup:0,readOnly:i,referrerPolicy:0,rel:0,required:i,reversed:i,role:0,rows:s,rowSpan:a,sandbox:0,scope:0,scoped:i,scrolling:0,seamless:i,selected:o|i,shape:0,size:s,sizes:0,span:s,spellCheck:0,src:0,srcDoc:0,srcLang:0,srcSet:0,start:a,step:0,style:0,summary:0,tabIndex:0,target:0,title:0,type:0,useMap:0,value:0,width:0,wmode:0,wrap:0,about:0,datatype:0,inlist:0,prefix:0,property:0,resource:0,typeof:0,vocab:0,autoCapitalize:0,autoCorrect:0,autoSave:0,color:0,itemProp:0,itemScope:i,itemType:0,itemID:0,itemRef:0,results:0,security:0,unselectable:0},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"},DOMPropertyNames:{},DOMMutationMethods:{value:function(e,t){if(null==t)return e.removeAttribute("value");"number"!==e.type||!1===e.hasAttribute("value")?e.setAttribute("value",""+t):e.validity&&!e.validity.badInput&&e.ownerDocument.activeElement!==e&&e.setAttribute("value",""+t)}}};e.exports=u},function(e,t,n){"use strict";(function(t){function r(e,t,n,r){var o=void 0===e[n];null!=t&&o&&(e[n]=i(t,!0))}var o=n(16),i=n(72),a=(n(36),n(46)),s=n(75);n(1);void 0!==t&&t.env;var l={instantiateChildren:function(e,t,n,o){if(null==e)return null;var i={};return s(e,r,i),i},updateChildren:function(e,t,n,r,s,l,u,c,d){if(t||e){var p,h;for(p in t)if(t.hasOwnProperty(p)){h=e&&e[p];var f=h&&h._currentElement,m=t[p];if(null!=h&&a(f,m))o.receiveComponent(h,m,s,c),t[p]=h;else{h&&(r[p]=o.getHostNode(h),o.unmountComponent(h,!1));var g=i(m,!0);t[p]=g;var v=o.mountComponent(g,s,l,u,c,d);n.push(v)}}for(p in e)!e.hasOwnProperty(p)||t&&t.hasOwnProperty(p)||(h=e[p],r[p]=o.getHostNode(h),o.unmountComponent(h,!1))}},unmountChildren:function(e,t){for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];o.unmountComponent(r,t)}}};e.exports=l}).call(t,n(31))},function(e,t,n){"use strict";var r=n(32),o=n(140),i={processChildrenUpdates:o.dangerouslyProcessChildrenUpdates,replaceNodeWithMarkup:r.dangerouslyReplaceNodeWithMarkup};e.exports=i},function(e,t,n){"use strict";function r(e){}function o(e){return!(!e.prototype||!e.prototype.isReactComponent)}function i(e){return!(!e.prototype||!e.prototype.isPureReactComponent)}var a=n(2),s=n(3),l=n(17),u=n(38),c=n(11),d=n(39),p=n(22),h=(n(8),n(66)),f=n(16),m=n(13),g=(n(0),n(30)),v=n(46),y=(n(1),{ImpureClass:0,PureClass:1,StatelessFunctional:2});r.prototype.render=function(){var e=p.get(this)._currentElement.type,t=e(this.props,this.context,this.updater);return t};var b=1,C={construct:function(e){this._currentElement=e,this._rootNodeID=0,this._compositeType=null,this._instance=null,this._hostParent=null,this._hostContainerInfo=null,this._updateBatchNumber=null,this._pendingElement=null,this._pendingStateQueue=null,this._pendingReplaceState=!1,this._pendingForceUpdate=!1,this._renderedNodeType=null,this._renderedComponent=null,this._context=null,this._mountOrder=0,this._topLevelWrapper=null,this._pendingCallbacks=null,this._calledComponentWillUnmount=!1},mountComponent:function(e,t,n,s){this._context=s,this._mountOrder=b++,this._hostParent=t,this._hostContainerInfo=n;var u,c=this._currentElement.props,d=this._processContext(s),h=this._currentElement.type,f=e.getUpdateQueue(),g=o(h),v=this._constructComponent(g,c,d,f);g||null!=v&&null!=v.render?i(h)?this._compositeType=y.PureClass:this._compositeType=y.ImpureClass:(u=v,null===v||!1===v||l.isValidElement(v)||a("105",h.displayName||h.name||"Component"),v=new r(h),this._compositeType=y.StatelessFunctional);v.props=c,v.context=d,v.refs=m,v.updater=f,this._instance=v,p.set(v,this);var C=v.state;void 0===C&&(v.state=C=null),("object"!=typeof C||Array.isArray(C))&&a("106",this.getName()||"ReactCompositeComponent"),this._pendingStateQueue=null,this._pendingReplaceState=!1,this._pendingForceUpdate=!1;var E;return E=v.unstable_handleError?this.performInitialMountWithErrorHandling(u,t,n,e,s):this.performInitialMount(u,t,n,e,s),v.componentDidMount&&e.getReactMountReady().enqueue(v.componentDidMount,v),E},_constructComponent:function(e,t,n,r){return this._constructComponentWithoutOwner(e,t,n,r)},_constructComponentWithoutOwner:function(e,t,n,r){var o=this._currentElement.type;return e?new o(t,n,r):o(t,n,r)},performInitialMountWithErrorHandling:function(e,t,n,r,o){var i,a=r.checkpoint();try{i=this.performInitialMount(e,t,n,r,o)}catch(s){r.rollback(a),this._instance.unstable_handleError(s),this._pendingStateQueue&&(this._instance.state=this._processPendingState(this._instance.props,this._instance.context)),a=r.checkpoint(),this._renderedComponent.unmountComponent(!0),r.rollback(a),i=this.performInitialMount(e,t,n,r,o)}return i},performInitialMount:function(e,t,n,r,o){var i=this._instance,a=0;i.componentWillMount&&(i.componentWillMount(),this._pendingStateQueue&&(i.state=this._processPendingState(i.props,i.context))),void 0===e&&(e=this._renderValidatedComponent());var s=h.getType(e);this._renderedNodeType=s;var l=this._instantiateReactComponent(e,s!==h.EMPTY);this._renderedComponent=l;var u=f.mountComponent(l,r,t,n,this._processChildContext(o),a);return u},getHostNode:function(){return f.getHostNode(this._renderedComponent)},unmountComponent:function(e){if(this._renderedComponent){var t=this._instance;if(t.componentWillUnmount&&!t._calledComponentWillUnmount)if(t._calledComponentWillUnmount=!0,e){var n=this.getName()+".componentWillUnmount()";d.invokeGuardedCallback(n,t.componentWillUnmount.bind(t))}else t.componentWillUnmount();this._renderedComponent&&(f.unmountComponent(this._renderedComponent,e),this._renderedNodeType=null,this._renderedComponent=null,this._instance=null),this._pendingStateQueue=null,this._pendingReplaceState=!1,this._pendingForceUpdate=!1,this._pendingCallbacks=null,this._pendingElement=null,this._context=null,this._rootNodeID=0,this._topLevelWrapper=null,p.remove(t)}},_maskContext:function(e){var t=this._currentElement.type,n=t.contextTypes;if(!n)return m;var r={};for(var o in n)r[o]=e[o];return r},_processContext:function(e){var t=this._maskContext(e);return t},_processChildContext:function(e){var t,n=this._currentElement.type,r=this._instance;if(r.getChildContext&&(t=r.getChildContext()),t){"object"!=typeof n.childContextTypes&&a("107",this.getName()||"ReactCompositeComponent");for(var o in t)o in n.childContextTypes||a("108",this.getName()||"ReactCompositeComponent",o);return s({},e,t)}return e},_checkContextTypes:function(e,t,n){},receiveComponent:function(e,t,n){var r=this._currentElement,o=this._context;this._pendingElement=null,this.updateComponent(t,r,e,o,n)},performUpdateIfNecessary:function(e){null!=this._pendingElement?f.receiveComponent(this,this._pendingElement,e,this._context):null!==this._pendingStateQueue||this._pendingForceUpdate?this.updateComponent(e,this._currentElement,this._currentElement,this._context,this._context):this._updateBatchNumber=null},updateComponent:function(e,t,n,r,o){var i=this._instance;null==i&&a("136",this.getName()||"ReactCompositeComponent");var s,l=!1;this._context===o?s=i.context:(s=this._processContext(o),l=!0);var u=t.props,c=n.props;t!==n&&(l=!0),l&&i.componentWillReceiveProps&&i.componentWillReceiveProps(c,s);var d=this._processPendingState(c,s),p=!0;this._pendingForceUpdate||(i.shouldComponentUpdate?p=i.shouldComponentUpdate(c,d,s):this._compositeType===y.PureClass&&(p=!g(u,c)||!g(i.state,d))),this._updateBatchNumber=null,p?(this._pendingForceUpdate=!1,this._performComponentUpdate(n,c,d,s,e,o)):(this._currentElement=n,this._context=o,i.props=c,i.state=d,i.context=s)},_processPendingState:function(e,t){var n=this._instance,r=this._pendingStateQueue,o=this._pendingReplaceState;if(this._pendingReplaceState=!1,this._pendingStateQueue=null,!r)return n.state;if(o&&1===r.length)return r[0];for(var i=s({},o?r[0]:n.state),a=o?1:0;a=0||null!=t.is}function f(e){var t=e.type;p(t),this._currentElement=e,this._tag=t.toLowerCase(),this._namespaceURI=null,this._renderedChildren=null,this._previousStyle=null,this._previousStyleCopy=null,this._hostNode=null,this._hostParent=null,this._rootNodeID=0,this._domID=0,this._hostContainerInfo=null,this._wrapperState=null,this._topLevelWrapper=null,this._flags=0}var m=n(2),g=n(3),v=n(123),y=n(125),b=n(14),C=n(33),E=n(15),w=n(58),x=n(20),_=n(34),T=n(24),k=n(59),P=n(4),S=n(141),N=n(142),A=n(60),O=n(145),D=(n(8),n(154)),M=n(159),I=(n(7),n(27)),R=(n(0),n(45),n(30),n(47),n(1),k),L=x.deleteListener,F=P.getNodeFromInstance,U=T.listenTo,B=_.registrationNameModules,j={string:!0,number:!0},H="__html",q={children:null,dangerouslySetInnerHTML:null,suppressContentEditableWarning:null},W=11,V={topAbort:"abort",topCanPlay:"canplay",topCanPlayThrough:"canplaythrough",topDurationChange:"durationchange",topEmptied:"emptied",topEncrypted:"encrypted",topEnded:"ended",topError:"error",topLoadedData:"loadeddata",topLoadedMetadata:"loadedmetadata",topLoadStart:"loadstart",topPause:"pause",topPlay:"play",topPlaying:"playing",topProgress:"progress",topRateChange:"ratechange",topSeeked:"seeked",topSeeking:"seeking",topStalled:"stalled",topSuspend:"suspend",topTimeUpdate:"timeupdate",topVolumeChange:"volumechange",topWaiting:"waiting"},K={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},z={listing:!0,pre:!0,textarea:!0},Y=g({menuitem:!0},K),X=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,$={},G={}.hasOwnProperty,Q=1;f.displayName="ReactDOMComponent",f.Mixin={mountComponent:function(e,t,n,r){this._rootNodeID=Q++,this._domID=n._idCounter++,this._hostParent=t,this._hostContainerInfo=n;var i=this._currentElement.props;switch(this._tag){case"audio":case"form":case"iframe":case"img":case"link":case"object":case"source":case"video":this._wrapperState={listeners:null},e.getReactMountReady().enqueue(c,this);break;case"input":S.mountWrapper(this,i,t),i=S.getHostProps(this,i),e.getReactMountReady().enqueue(c,this);break;case"option":N.mountWrapper(this,i,t),i=N.getHostProps(this,i);break;case"select":A.mountWrapper(this,i,t),i=A.getHostProps(this,i),e.getReactMountReady().enqueue(c,this);break;case"textarea":O.mountWrapper(this,i,t),i=O.getHostProps(this,i),e.getReactMountReady().enqueue(c,this)}o(this,i);var a,d;null!=t?(a=t._namespaceURI,d=t._tag):n._tag&&(a=n._namespaceURI,d=n._tag),(null==a||a===C.svg&&"foreignobject"===d)&&(a=C.html),a===C.html&&("svg"===this._tag?a=C.svg:"math"===this._tag&&(a=C.mathml)),this._namespaceURI=a;var p;if(e.useCreateElement){var h,f=n._ownerDocument;if(a===C.html)if("script"===this._tag){var m=f.createElement("div"),g=this._currentElement.type;m.innerHTML="<"+g+">",h=m.removeChild(m.firstChild)}else h=i.is?f.createElement(this._currentElement.type,i.is):f.createElement(this._currentElement.type);else h=f.createElementNS(a,this._currentElement.type);P.precacheNode(this,h),this._flags|=R.hasCachedChildNodes,this._hostParent||w.setAttributeForRoot(h),this._updateDOMProperties(null,i,e);var y=b(h);this._createInitialChildren(e,i,r,y),p=y}else{var E=this._createOpenTagMarkupAndPutListeners(e,i),x=this._createContentMarkup(e,i,r);p=!x&&K[this._tag]?E+"/>":E+">"+x+""}switch(this._tag){case"input":e.getReactMountReady().enqueue(s,this),i.autoFocus&&e.getReactMountReady().enqueue(v.focusDOMComponent,this);break;case"textarea":e.getReactMountReady().enqueue(l,this),i.autoFocus&&e.getReactMountReady().enqueue(v.focusDOMComponent,this);break;case"select":case"button":i.autoFocus&&e.getReactMountReady().enqueue(v.focusDOMComponent,this);break;case"option":e.getReactMountReady().enqueue(u,this)}return p},_createOpenTagMarkupAndPutListeners:function(e,t){var n="<"+this._currentElement.type;for(var r in t)if(t.hasOwnProperty(r)){var o=t[r];if(null!=o)if(B.hasOwnProperty(r))o&&i(this,r,o,e);else{"style"===r&&(o&&(o=this._previousStyleCopy=g({},t.style)),o=y.createMarkupForStyles(o,this));var a=null;null!=this._tag&&h(this._tag,t)?q.hasOwnProperty(r)||(a=w.createMarkupForCustomAttribute(r,o)):a=w.createMarkupForProperty(r,o),a&&(n+=" "+a)}}return e.renderToStaticMarkup?n:(this._hostParent||(n+=" "+w.createMarkupForRoot()),n+=" "+w.createMarkupForID(this._domID))},_createContentMarkup:function(e,t,n){var r="",o=t.dangerouslySetInnerHTML;if(null!=o)null!=o.__html&&(r=o.__html);else{var i=j[typeof t.children]?t.children:null,a=null!=i?null:t.children;if(null!=i)r=I(i);else if(null!=a){var s=this.mountChildren(a,e,n);r=s.join("")}}return z[this._tag]&&"\n"===r.charAt(0)?"\n"+r:r},_createInitialChildren:function(e,t,n,r){var o=t.dangerouslySetInnerHTML;if(null!=o)null!=o.__html&&b.queueHTML(r,o.__html);else{var i=j[typeof t.children]?t.children:null,a=null!=i?null:t.children;if(null!=i)""!==i&&b.queueText(r,i);else if(null!=a)for(var s=this.mountChildren(a,e,n),l=0;lt.end?(n=t.end,r=t.start):(n=t.start,r=t.end),o.moveToElementText(e),o.moveStart("character",n),o.setEndPoint("EndToStart",o),o.moveEnd("character",r-n),o.select()}function s(e,t){if(window.getSelection){var n=window.getSelection(),r=e[c()].length,o=Math.min(t.start,r),i=void 0===t.end?o:Math.min(t.end,r);if(!n.extend&&o>i){var a=i;i=o,o=a}var s=u(e,o),l=u(e,i);if(s&&l){var d=document.createRange();d.setStart(s.node,s.offset),n.removeAllRanges(),o>i?(n.addRange(d),n.extend(l.node,l.offset)):(d.setEnd(l.node,l.offset),n.addRange(d))}}}var l=n(6),u=n(181),c=n(71),d=l.canUseDOM&&"selection"in document&&!("getSelection"in window),p={getOffsets:d?o:i,setOffsets:d?a:s};e.exports=p},function(e,t,n){"use strict";var r=n(2),o=n(3),i=n(32),a=n(14),s=n(4),l=n(27),u=(n(0),n(47),function(e){this._currentElement=e,this._stringText=""+e,this._hostNode=null,this._hostParent=null,this._domID=0,this._mountIndex=0,this._closingComment=null,this._commentNodes=null});o(u.prototype,{mountComponent:function(e,t,n,r){var o=n._idCounter++,i=" react-text: "+o+" ";if(this._domID=o,this._hostParent=t,e.useCreateElement){var u=n._ownerDocument,c=u.createComment(i),d=u.createComment(" /react-text "),p=a(u.createDocumentFragment());return a.queueChild(p,a(c)),this._stringText&&a.queueChild(p,a(u.createTextNode(this._stringText))),a.queueChild(p,a(d)),s.precacheNode(this,c),this._closingComment=d,p}var h=l(this._stringText);return e.renderToStaticMarkup?h:"\x3c!--"+i+"--\x3e"+h+"\x3c!-- /react-text --\x3e"},receiveComponent:function(e,t){if(e!==this._currentElement){this._currentElement=e;var n=""+e;if(n!==this._stringText){this._stringText=n;var r=this.getHostNode();i.replaceDelimitedText(r[0],r[1],n)}}},getHostNode:function(){var e=this._commentNodes;if(e)return e;if(!this._closingComment)for(var t=s.getNodeFromInstance(this),n=t.nextSibling;;){if(null==n&&r("67",this._domID),8===n.nodeType&&" /react-text "===n.nodeValue){this._closingComment=n;break}n=n.nextSibling}return e=[this._hostNode,this._closingComment],this._commentNodes=e,e},unmountComponent:function(){this._closingComment=null,this._commentNodes=null,s.uncacheNode(this)}}),e.exports=u},function(e,t,n){"use strict";function r(){this._rootNodeID&&c.updateWrapper(this)}function o(e){var t=this._currentElement.props,n=s.executeOnChange(t,e);return u.asap(r,this),n}var i=n(2),a=n(3),s=n(37),l=n(4),u=n(9),c=(n(0),n(1),{getHostProps:function(e,t){return null!=t.dangerouslySetInnerHTML&&i("91"),a({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue,onChange:e._wrapperState.onChange})},mountWrapper:function(e,t){var n=s.getValue(t),r=n;if(null==n){var a=t.defaultValue,l=t.children;null!=l&&(null!=a&&i("92"),Array.isArray(l)&&(l.length<=1||i("93"),l=l[0]),a=""+l),null==a&&(a=""),r=a}e._wrapperState={initialValue:""+r,listeners:null,onChange:o.bind(e)}},updateWrapper:function(e){var t=e._currentElement.props,n=l.getNodeFromInstance(e),r=s.getValue(t);if(null!=r){var o=""+r;o!==n.value&&(n.value=o),null==t.defaultValue&&(n.defaultValue=o)}null!=t.defaultValue&&(n.defaultValue=t.defaultValue)},postMountWrapper:function(e){var t=l.getNodeFromInstance(e),n=t.textContent;n===e._wrapperState.initialValue&&(t.value=n)}});e.exports=c},function(e,t,n){"use strict";function r(e,t){"_hostNode"in e||l("33"),"_hostNode"in t||l("33");for(var n=0,r=e;r;r=r._hostParent)n++;for(var o=0,i=t;i;i=i._hostParent)o++;for(;n-o>0;)e=e._hostParent,n--;for(;o-n>0;)t=t._hostParent,o--;for(var a=n;a--;){if(e===t)return e;e=e._hostParent,t=t._hostParent}return null}function o(e,t){"_hostNode"in e||l("35"),"_hostNode"in t||l("35");for(;t;){if(t===e)return!0;t=t._hostParent}return!1}function i(e){return"_hostNode"in e||l("36"),e._hostParent}function a(e,t,n){for(var r=[];e;)r.push(e),e=e._hostParent;var o;for(o=r.length;o-- >0;)t(r[o],"captured",n);for(o=0;o0;)n(l[u],"captured",i)}var l=n(2);n(0);e.exports={isAncestor:o,getLowestCommonAncestor:r,getParentInstance:i,traverseTwoPhase:a,traverseEnterLeave:s}},function(e,t,n){"use strict";function r(){this.reinitializeTransaction()}var o=n(3),i=n(9),a=n(26),s=n(7),l={initialize:s,close:function(){p.isBatchingUpdates=!1}},u={initialize:s,close:i.flushBatchedUpdates.bind(i)},c=[u,l];o(r.prototype,a,{getTransactionWrappers:function(){return c}});var d=new r,p={isBatchingUpdates:!1,batchedUpdates:function(e,t,n,r,o,i){var a=p.isBatchingUpdates;return p.isBatchingUpdates=!0,a?e(t,n,r,o,i):d.perform(e,null,t,n,r,o,i)}};e.exports=p},function(e,t,n){"use strict";function r(){x||(x=!0,y.EventEmitter.injectReactEventListener(v),y.EventPluginHub.injectEventPluginOrder(s),y.EventPluginUtils.injectComponentTree(p),y.EventPluginUtils.injectTreeTraversal(f),y.EventPluginHub.injectEventPluginsByName({SimpleEventPlugin:w,EnterLeaveEventPlugin:l,ChangeEventPlugin:a,SelectEventPlugin:E,BeforeInputEventPlugin:i}),y.HostComponent.injectGenericComponentClass(d),y.HostComponent.injectTextComponentClass(m),y.DOMProperty.injectDOMPropertyConfig(o),y.DOMProperty.injectDOMPropertyConfig(u),y.DOMProperty.injectDOMPropertyConfig(C),y.EmptyComponent.injectEmptyComponentFactory(function(e){return new h(e)}),y.Updates.injectReconcileTransaction(b),y.Updates.injectBatchingStrategy(g),y.Component.injectEnvironment(c))}var o=n(122),i=n(124),a=n(126),s=n(128),l=n(129),u=n(131),c=n(133),d=n(136),p=n(4),h=n(138),f=n(146),m=n(144),g=n(147),v=n(151),y=n(152),b=n(157),C=n(162),E=n(163),w=n(164),x=!1;e.exports={inject:r}},function(e,t,n){"use strict";var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103;e.exports=r},function(e,t,n){"use strict";function r(e){o.enqueueEvents(e),o.processEventQueue(!1)}var o=n(20),i={handleTopLevel:function(e,t,n,i){r(o.extractEvents(e,t,n,i))}};e.exports=i},function(e,t,n){"use strict";function r(e){for(;e._hostParent;)e=e._hostParent;var t=d.getNodeFromInstance(e),n=t.parentNode;return d.getClosestInstanceFromNode(n)}function o(e,t){this.topLevelType=e,this.nativeEvent=t,this.ancestors=[]}function i(e){var t=h(e.nativeEvent),n=d.getClosestInstanceFromNode(t),o=n;do{e.ancestors.push(o),o=o&&r(o)}while(o);for(var i=0;i/,i=/^<\!\-\-/,a={CHECKSUM_ATTR_NAME:"data-react-checksum",addChecksumToMarkup:function(e){var t=r(e);return i.test(e)?e:e.replace(o," "+a.CHECKSUM_ATTR_NAME+'="'+t+'"$&')},canReuseMarkup:function(e,t){var n=t.getAttribute(a.CHECKSUM_ATTR_NAME);return n=n&&parseInt(n,10),r(e)===n}};e.exports=a},function(e,t,n){"use strict";function r(e,t,n){return{type:"INSERT_MARKUP",content:e,fromIndex:null,fromNode:null,toIndex:n,afterNode:t}}function o(e,t,n){return{type:"MOVE_EXISTING",content:null,fromIndex:e._mountIndex,fromNode:p.getHostNode(e),toIndex:n,afterNode:t}}function i(e,t){return{type:"REMOVE_NODE",content:null,fromIndex:e._mountIndex,fromNode:t,toIndex:null,afterNode:null}}function a(e){return{type:"SET_MARKUP",content:e,fromIndex:null,fromNode:null,toIndex:null,afterNode:null}}function s(e){return{type:"TEXT_CONTENT",content:e,fromIndex:null,fromNode:null,toIndex:null,afterNode:null}}function l(e,t){return t&&(e=e||[],e.push(t)),e}function u(e,t){d.processChildrenUpdates(e,t)}var c=n(2),d=n(38),p=(n(22),n(8),n(11),n(16)),h=n(132),f=(n(7),n(178)),m=(n(0),{Mixin:{_reconcilerInstantiateChildren:function(e,t,n){return h.instantiateChildren(e,t,n)},_reconcilerUpdateChildren:function(e,t,n,r,o,i){var a,s=0;return a=f(t,s),h.updateChildren(e,a,n,r,o,this,this._hostContainerInfo,i,s),a},mountChildren:function(e,t,n){var r=this._reconcilerInstantiateChildren(e,t,n);this._renderedChildren=r;var o=[],i=0;for(var a in r)if(r.hasOwnProperty(a)){var s=r[a],l=0,u=p.mountComponent(s,t,this,this._hostContainerInfo,n,l);s._mountIndex=i++,o.push(u)}return o},updateTextContent:function(e){var t=this._renderedChildren;h.unmountChildren(t,!1);for(var n in t)t.hasOwnProperty(n)&&c("118");u(this,[s(e)])},updateMarkup:function(e){var t=this._renderedChildren;h.unmountChildren(t,!1);for(var n in t)t.hasOwnProperty(n)&&c("118");u(this,[a(e)])},updateChildren:function(e,t,n){this._updateChildren(e,t,n)},_updateChildren:function(e,t,n){var r=this._renderedChildren,o={},i=[],a=this._reconcilerUpdateChildren(r,e,i,o,t,n);if(a||r){var s,c=null,d=0,h=0,f=0,m=null;for(s in a)if(a.hasOwnProperty(s)){var g=r&&r[s],v=a[s];g===v?(c=l(c,this.moveChild(g,m,d,h)),h=Math.max(g._mountIndex,h),g._mountIndex=d):(g&&(h=Math.max(g._mountIndex,h)),c=l(c,this._mountChildAtIndex(v,i[f],m,d,t,n)),f++),d++,m=p.getHostNode(v)}for(s in o)o.hasOwnProperty(s)&&(c=l(c,this._unmountChild(r[s],o[s])));c&&u(this,c),this._renderedChildren=a}},unmountChildren:function(e){var t=this._renderedChildren;h.unmountChildren(t,e),this._renderedChildren=null},moveChild:function(e,t,n,r){if(e._mountIndex=t)return{node:n,offset:t-i};i=a}n=r(o(n))}}e.exports=i},function(e,t,n){"use strict";function r(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n["ms"+e]="MS"+t,n["O"+e]="o"+t.toLowerCase(),n}function o(e){if(s[e])return s[e];if(!a[e])return e;var t=a[e];for(var n in t)if(t.hasOwnProperty(n)&&n in l)return s[e]=t[n];return""}var i=n(6),a={animationend:r("Animation","AnimationEnd"),animationiteration:r("Animation","AnimationIteration"),animationstart:r("Animation","AnimationStart"),transitionend:r("Transition","TransitionEnd")},s={},l={};i.canUseDOM&&(l=document.createElement("div").style,"AnimationEvent"in window||(delete a.animationend.animation,delete a.animationiteration.animation,delete a.animationstart.animation),"TransitionEvent"in window||delete a.transitionend.transition),e.exports=o},function(e,t,n){"use strict";function r(e){return'"'+o(e)+'"'}var o=n(27);e.exports=r},function(e,t,n){"use strict";var r=n(65);e.exports=r.renderSubtreeIntoContainer},function(e,t,n){"use strict";function r(e){var t={"=":"=0",":":"=2"};return"$"+(""+e).replace(/[=:]/g,function(e){return t[e]})}function o(e){var t=/(=0|=2)/g,n={"=0":"=","=2":":"};return(""+("."===e[0]&&"$"===e[1]?e.substring(2):e.substring(1))).replace(t,function(e){return n[e]})}var i={escape:r,unescape:o};e.exports=i},function(e,t,n){"use strict";var r=n(19),o=(n(0),function(e){var t=this;if(t.instancePool.length){var n=t.instancePool.pop();return t.call(n,e),n}return new t(e)}),i=function(e,t){var n=this;if(n.instancePool.length){var r=n.instancePool.pop();return n.call(r,e,t),r}return new n(e,t)},a=function(e,t,n){var r=this;if(r.instancePool.length){var o=r.instancePool.pop();return r.call(o,e,t,n),o}return new r(e,t,n)},s=function(e,t,n,r){var o=this;if(o.instancePool.length){var i=o.instancePool.pop();return o.call(i,e,t,n,r),i}return new o(e,t,n,r)},l=function(e){var t=this;e instanceof t||r("25"),e.destructor(),t.instancePool.length-1?t:e}function h(e,t){t=t||{};var n=t.body;if("string"==typeof e)this.url=e;else{if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new o(e.headers)),this.method=e.method,this.mode=e.mode,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}if(this.credentials=t.credentials||this.credentials||"omit",!t.headers&&this.headers||(this.headers=new o(t.headers)),this.method=p(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function f(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(o))}}),t}function m(e){var t=new o;return e.split("\r\n").forEach(function(e){var n=e.split(":"),r=n.shift().trim();if(r){var o=n.join(":").trim();t.append(r,o)}}),t}function g(e,t){t||(t={}),this.type="default",this.status="status"in t?t.status:200,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new o(t.headers),this.url=t.url||"",this._initBody(e)}if(!e.fetch){var v={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(v.arrayBuffer)var y=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],b=function(e){return e&&DataView.prototype.isPrototypeOf(e)},C=ArrayBuffer.isView||function(e){return e&&y.indexOf(Object.prototype.toString.call(e))>-1};o.prototype.append=function(e,r){e=t(e),r=n(r);var o=this.map[e];o||(o=[],this.map[e]=o),o.push(r)},o.prototype.delete=function(e){delete this.map[t(e)]},o.prototype.get=function(e){var n=this.map[t(e)];return n?n[0]:null},o.prototype.getAll=function(e){return this.map[t(e)]||[]},o.prototype.has=function(e){return this.map.hasOwnProperty(t(e))},o.prototype.set=function(e,r){this.map[t(e)]=[n(r)]},o.prototype.forEach=function(e,t){Object.getOwnPropertyNames(this.map).forEach(function(n){this.map[n].forEach(function(r){e.call(t,r,n,this)},this)},this)},o.prototype.keys=function(){var e=[];return this.forEach(function(t,n){e.push(n)}),r(e)},o.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),r(e)},o.prototype.entries=function(){var e=[];return this.forEach(function(t,n){e.push([n,t])}),r(e)},v.iterable&&(o.prototype[Symbol.iterator]=o.prototype.entries);var E=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];h.prototype.clone=function(){return new h(this,{body:this._bodyInit})},d.call(h.prototype),d.call(g.prototype),g.prototype.clone=function(){return new g(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new o(this.headers),url:this.url})},g.error=function(){var e=new g(null,{status:0,statusText:""});return e.type="error",e};var w=[301,302,303,307,308];g.redirect=function(e,t){if(-1===w.indexOf(t))throw new RangeError("Invalid status code");return new g(null,{status:t,headers:{location:e}})},e.Headers=o,e.Request=h,e.Response=g,e.fetch=function(e,t){return new Promise(function(n,r){var o=new h(e,t),i=new XMLHttpRequest;i.onload=function(){var e={status:i.status,statusText:i.statusText,headers:m(i.getAllResponseHeaders()||"")};e.url="responseURL"in i?i.responseURL:e.headers.get("X-Request-URL");var t="response"in i?i.response:i.responseText;n(new g(t,e))},i.onerror=function(){r(new TypeError("Network request failed"))},i.ontimeout=function(){r(new TypeError("Network request failed"))},i.open(o.method,o.url,!0),"include"===o.credentials&&(i.withCredentials=!0),"responseType"in i&&v.blob&&(i.responseType="blob"),o.headers.forEach(function(e,t){i.setRequestHeader(t,e)}),i.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)}]); \ No newline at end of file diff --git a/priv/templates/thesis.install/add_a_unique_index_on_slug.exs b/priv/templates/thesis.install/add_a_unique_index_on_slug.exs new file mode 100644 index 0000000..da59ee3 --- /dev/null +++ b/priv/templates/thesis.install/add_a_unique_index_on_slug.exs @@ -0,0 +1,20 @@ +defmodule <%= base %>.Repo.Migrations.AddAUniqueIndexOnSlug do + @moduledoc false + use Ecto.Migration + + def up do + # Rreate old non-unique index + drop index(:thesis_pages, [:slug]) + + # Create a Unique Index + create unique_index(:thesis_pages, [:slug]) + end + + def down do + # Remove unique index + drop unique_index(:thesis_pages, :slug) + + # Create old non-unique index + create index(:thesis_pages, [:slug]) + end +end diff --git a/priv/templates/thesis.install/add_indexes_to_tables.exs b/priv/templates/thesis.install/add_indexes_to_tables.exs index 4fbd5c9..28f48aa 100644 --- a/priv/templates/thesis.install/add_indexes_to_tables.exs +++ b/priv/templates/thesis.install/add_indexes_to_tables.exs @@ -23,6 +23,6 @@ defmodule <%= base %>.Repo.Migrations.AddIndexToTables do modify :description, :string end - remove index(:thesis_pages, [:slug]) + drop index(:thesis_pages, [:slug]) end end diff --git a/web/static/js/components/thesis-editor.js b/web/static/js/components/thesis-editor.js index 4617f98..2b7a302 100644 --- a/web/static/js/components/thesis-editor.js +++ b/web/static/js/components/thesis-editor.js @@ -172,14 +172,14 @@ class ThesisEditor extends React.Component { } save (page, contents) { - this.props.external.save(page, contents, () => { - this.setState({editing: false, pageModified: false, trayOpen: false}) + this.props.external.save(page, contents, (resp) => { + this.setState({editing: false, pageModified: false, path: resp.slug, trayOpen: false}) this.setState({pageToolsHidden: true}) }) } deletePage (path) { - this.props.external.delete(path, () => { + this.props.external.delete(path, (resp) => { this.setState({deleted: true, editing: false}) }) } diff --git a/web/static/js/external.js b/web/static/js/external.js index e8d3bf0..49cc3cf 100644 --- a/web/static/js/external.js +++ b/web/static/js/external.js @@ -21,10 +21,10 @@ const external = (container) => { setRedirectURL: (url) => container.setAttribute('data-redirect-url', url), save: (page, contents, callback) => { Net.put('/thesis/update', {page, contents}).then((resp) => { - if (page.slug !== window.location.pathname) { - window.location = page.slug + if (resp.slug !== window.location.pathname) { + window.location = resp.slug } else { - callback() + callback(resp) } }).catch((err) => { window.alert(`Something went wrong! Details: ${err}`) @@ -33,7 +33,7 @@ const external = (container) => { delete: (path, callback) => { Net.delete('/thesis/delete', {path}).then((resp) => { window.alert('Page has been deleted.') - callback() + callback(resp) }).catch((err) => { window.alert(`Something went wrong! Details: ${err}`) }) From d52683effc5203e423c0ad575d1a52905fbcc4ae Mon Sep 17 00:00:00 2001 From: "Silas J. Matson" Date: Wed, 5 Jul 2017 10:19:00 -0700 Subject: [PATCH 2/3] Fixes per @yulolimum's review --- .../test/controllers/page_controller_test.exs | 14 ++++++++------ lib/thesis/views/api_view.ex | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/apps/example/test/controllers/page_controller_test.exs b/apps/example/test/controllers/page_controller_test.exs index 22fed17..69478b7 100644 --- a/apps/example/test/controllers/page_controller_test.exs +++ b/apps/example/test/controllers/page_controller_test.exs @@ -12,7 +12,8 @@ defmodule Example.PageControllerTest do assert html_response(conn, 200) =~ "

Help

" payload = %{ - "page" => %{"slug" => "/", "title" => "", "description" => "", + "page" => %{"slug" => "/", "title" => "Home Page", + "description" => "Home Page Description", "redirect_url" => nil,"template" => nil}, "contents" => [%{"name" => "Help","content_type" => "html", "content" => "

Updated content area

", @@ -24,8 +25,8 @@ defmodule Example.PageControllerTest do |> json_response(200) assert response["id"] != nil assert response["slug"] == "/" - assert response["title"] == nil - assert response["description"] == nil + assert response["title"] == "Home Page" + assert response["description"] == "Home Page Description" assert response["template"] == nil assert response["redirect_url"] == nil assert response["page_contents"] == [] @@ -42,7 +43,8 @@ defmodule Example.PageControllerTest do # Updated content payload = %{ - "page" => %{"slug" => "/about", "title" => "", "description" => "", + "page" => %{"slug" => "/about", "title" => "About Page", + "description" => "About Page Description", "redirect_url" => nil,"template" => nil}, "contents" => [%{"name" => "Resources","content_type" => "html", "content" => "

Updated content area

", @@ -54,8 +56,8 @@ defmodule Example.PageControllerTest do |> json_response(200) assert response["id"] != nil assert response["slug"] == "/about" - assert response["title"] == nil - assert response["description"] == nil + assert response["title"] == "About Page" + assert response["description"] == "About Page Description" assert response["template"] == nil assert response["redirect_url"] == nil assert response["page_contents"] == [] diff --git a/lib/thesis/views/api_view.ex b/lib/thesis/views/api_view.ex index 838a0e0..0571f2e 100644 --- a/lib/thesis/views/api_view.ex +++ b/lib/thesis/views/api_view.ex @@ -7,6 +7,7 @@ defmodule Thesis.ApiView do id: page.id, slug: page.slug, title: page.title, + description: page.description, redirect_url: page.redirect_url, page_contents: render("page_contents.json", assigns[:page_contents]), inserted_at: page.inserted_at, @@ -19,8 +20,8 @@ defmodule Thesis.ApiView do when is_nil(page_contents), do: [] def render("page_contents.json", page_contents) when is_list(page_contents) do Enum.map(page_contents, fn(page_content) -> - render("page_content.json", page_content) - end) + render("page_content.json", page_content) + end) end def render("page_content.json", page_content) do From 8b4fd6d5f9be87aa01a0cea5329293a505a201c7 Mon Sep 17 00:00:00 2001 From: "Silas J. Matson" Date: Wed, 5 Jul 2017 10:33:20 -0700 Subject: [PATCH 3/3] No need to check for nil if we match on nil --- lib/thesis/views/api_view.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/thesis/views/api_view.ex b/lib/thesis/views/api_view.ex index 0571f2e..54befc9 100644 --- a/lib/thesis/views/api_view.ex +++ b/lib/thesis/views/api_view.ex @@ -16,8 +16,7 @@ defmodule Thesis.ApiView do end def render("page.json", nil), do: %{} - def render("page_contents.json", page_contents) - when is_nil(page_contents), do: [] + def render("page_contents.json", nil), do: [] def render("page_contents.json", page_contents) when is_list(page_contents) do Enum.map(page_contents, fn(page_content) -> render("page_content.json", page_content)