fae-railsz 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (328) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +5 -0
  3. data/Rakefile +37 -0
  4. data/app/assets/fonts/fae/icons.eot +0 -0
  5. data/app/assets/fonts/fae/icons.svg +56 -0
  6. data/app/assets/fonts/fae/icons.ttf +0 -0
  7. data/app/assets/fonts/fae/icons.woff +0 -0
  8. data/app/assets/fonts/fae/lato-bold-webfont.eot +0 -0
  9. data/app/assets/fonts/fae/lato-bold-webfont.svg +4551 -0
  10. data/app/assets/fonts/fae/lato-bold-webfont.ttf +0 -0
  11. data/app/assets/fonts/fae/lato-bold-webfont.woff +0 -0
  12. data/app/assets/fonts/fae/lato-light-webfont.eot +0 -0
  13. data/app/assets/fonts/fae/lato-light-webfont.svg +4241 -0
  14. data/app/assets/fonts/fae/lato-light-webfont.ttf +0 -0
  15. data/app/assets/fonts/fae/lato-light-webfont.woff +0 -0
  16. data/app/assets/fonts/fae/lato-regular-webfont.eot +0 -0
  17. data/app/assets/fonts/fae/lato-regular-webfont.svg +4241 -0
  18. data/app/assets/fonts/fae/lato-regular-webfont.ttf +0 -0
  19. data/app/assets/fonts/fae/lato-regular-webfont.woff +0 -0
  20. data/app/assets/fonts/fae/selection.json +1334 -0
  21. data/app/assets/images/fae/error_bg.jpg +0 -0
  22. data/app/assets/images/fae/error_sad_face.png +0 -0
  23. data/app/assets/images/fae/icons/alert.svg +9 -0
  24. data/app/assets/images/fae/icons/arrow_down.svg +8 -0
  25. data/app/assets/images/fae/icons/arrow_left.svg +9 -0
  26. data/app/assets/images/fae/icons/arrow_right.svg +9 -0
  27. data/app/assets/images/fae/icons/arrow_stacked.svg +8 -0
  28. data/app/assets/images/fae/icons/arrow_up.svg +8 -0
  29. data/app/assets/images/fae/icons/calendar.svg +17 -0
  30. data/app/assets/images/fae/icons/check.svg +7 -0
  31. data/app/assets/images/fae/icons/checkmark.svg +8 -0
  32. data/app/assets/images/fae/icons/chevron_down.svg +7 -0
  33. data/app/assets/images/fae/icons/chevron_left.svg +10 -0
  34. data/app/assets/images/fae/icons/chevron_right.svg +10 -0
  35. data/app/assets/images/fae/icons/chevron_up.svg +7 -0
  36. data/app/assets/images/fae/icons/delete.svg +8 -0
  37. data/app/assets/images/fae/icons/delete_x.svg +8 -0
  38. data/app/assets/images/fae/icons/edit.svg +11 -0
  39. data/app/assets/images/fae/icons/handle.svg +13 -0
  40. data/app/assets/images/fae/icons/home.svg +10 -0
  41. data/app/assets/images/fae/icons/logout.svg +12 -0
  42. data/app/assets/images/fae/icons/magnifying_glass.svg +10 -0
  43. data/app/assets/images/fae/icons/menu.svg +11 -0
  44. data/app/assets/images/fae/icons/offlink.svg +25 -0
  45. data/app/assets/images/fae/icons/plus.svg +8 -0
  46. data/app/assets/images/fae/icons/pulldown.svg +11 -0
  47. data/app/assets/images/fae/icons/search.svg +11 -0
  48. data/app/assets/images/fae/icons/settings.svg +12 -0
  49. data/app/assets/images/fae/icons/sort.svg +11 -0
  50. data/app/assets/images/fae/icons/support.svg +15 -0
  51. data/app/assets/images/fae/icons/trash.svg +10 -0
  52. data/app/assets/images/fae/icons/trumbowyg.svg +1 -0
  53. data/app/assets/images/fae/icons/user.svg +13 -0
  54. data/app/assets/images/fae/icons/users.svg +19 -0
  55. data/app/assets/images/fae/icons/zoom.svg +12 -0
  56. data/app/assets/images/fae/tutorial_model_location.png +0 -0
  57. data/app/assets/images/fae/youtube_helper.jpg +0 -0
  58. data/app/assets/javascripts/fae/_modals.js +60 -0
  59. data/app/assets/javascripts/fae/_tables.js +403 -0
  60. data/app/assets/javascripts/fae/admin.js.erb +11 -0
  61. data/app/assets/javascripts/fae/application.js +63 -0
  62. data/app/assets/javascripts/fae/fae_init.js +8 -0
  63. data/app/assets/javascripts/fae/form/_ajax.js +380 -0
  64. data/app/assets/javascripts/fae/form/_cancel.js +38 -0
  65. data/app/assets/javascripts/fae/form/_filtering.js +276 -0
  66. data/app/assets/javascripts/fae/form/_form.js +60 -0
  67. data/app/assets/javascripts/fae/form/_slugger.js.erb +100 -0
  68. data/app/assets/javascripts/fae/form/_validator.js +459 -0
  69. data/app/assets/javascripts/fae/form/fae_chosen.js +44 -0
  70. data/app/assets/javascripts/fae/form/fileinputer.js +178 -0
  71. data/app/assets/javascripts/fae/form/hinter.js +111 -0
  72. data/app/assets/javascripts/fae/form/inputs/_checkbox.js +27 -0
  73. data/app/assets/javascripts/fae/form/inputs/_color.js +42 -0
  74. data/app/assets/javascripts/fae/form/inputs/_dates.js +78 -0
  75. data/app/assets/javascripts/fae/form/inputs/_select.js +162 -0
  76. data/app/assets/javascripts/fae/form/inputs/_text.js +118 -0
  77. data/app/assets/javascripts/fae/navigation/_global_search.js +184 -0
  78. data/app/assets/javascripts/fae/navigation/_language.js +89 -0
  79. data/app/assets/javascripts/fae/navigation/_navigation.js +206 -0
  80. data/app/assets/javascripts/fae/navigation/_subnav_highlighter.js +81 -0
  81. data/app/assets/javascripts/fae/navigation/sticky.js +186 -0
  82. data/app/assets/javascripts/fae/vendor/chosen.jquery.min.js +2 -0
  83. data/app/assets/javascripts/fae/vendor/frob_core_helpers.js +587 -0
  84. data/app/assets/javascripts/fae/vendor/fryr.js +437 -0
  85. data/app/assets/javascripts/fae/vendor/jqColorPicker.min.js +4 -0
  86. data/app/assets/javascripts/fae/vendor/jquery.daterangepicker.js +1292 -0
  87. data/app/assets/javascripts/fae/vendor/jquery.multi-select.js +534 -0
  88. data/app/assets/javascripts/fae/vendor/jquery.simplemodal.1.4.4.js +719 -0
  89. data/app/assets/javascripts/fae/vendor/jquery.tablesorter.js +1901 -0
  90. data/app/assets/javascripts/fae/vendor/js.cookie.js +139 -0
  91. data/app/assets/javascripts/fae/vendor/moment.min.js +7 -0
  92. data/app/assets/javascripts/fae/vendor/simplemde.min.js +13 -0
  93. data/app/assets/javascripts/fae/vendor/touch_punch.js +11 -0
  94. data/app/assets/javascripts/fae/vendor/trumbowyg.js.erb +4 -0
  95. data/app/assets/javascripts/fae/vendor/trumbowyg/plugins/upload/trumbowyg.upload.js +223 -0
  96. data/app/assets/javascripts/fae/vendor/trumbowyg/trumbowyg.js +1603 -0
  97. data/app/assets/stylesheets/fae/application.css +8 -0
  98. data/app/assets/stylesheets/fae/base.scss +82 -0
  99. data/app/assets/stylesheets/fae/globals/_fonts.scss +43 -0
  100. data/app/assets/stylesheets/fae/globals/_icons.scss +15 -0
  101. data/app/assets/stylesheets/fae/globals/_plugins.scss +51 -0
  102. data/app/assets/stylesheets/fae/globals/_tags.scss +68 -0
  103. data/app/assets/stylesheets/fae/globals/imports/_extends.scss +53 -0
  104. data/app/assets/stylesheets/fae/globals/imports/_mixins.scss +58 -0
  105. data/app/assets/stylesheets/fae/globals/imports/_variables.scss +165 -0
  106. data/app/assets/stylesheets/fae/globals/imports/finescss/_fine.scss +7 -0
  107. data/app/assets/stylesheets/fae/globals/imports/finescss/_fine_functions.scss +88 -0
  108. data/app/assets/stylesheets/fae/globals/imports/finescss/_fine_mixins.scss +280 -0
  109. data/app/assets/stylesheets/fae/globals/imports/finescss/_fine_variables.scss +30 -0
  110. data/app/assets/stylesheets/fae/globals/layout/_base.scss +48 -0
  111. data/app/assets/stylesheets/fae/globals/layout/_breadcrumbs.scss +45 -0
  112. data/app/assets/stylesheets/fae/globals/layout/_content-header.scss +99 -0
  113. data/app/assets/stylesheets/fae/globals/legacy/_pre-1.3.scss +659 -0
  114. data/app/assets/stylesheets/fae/globals/navigation/_base.scss +22 -0
  115. data/app/assets/stylesheets/fae/globals/navigation/_footer.scss +50 -0
  116. data/app/assets/stylesheets/fae/globals/navigation/_header.scss +149 -0
  117. data/app/assets/stylesheets/fae/globals/navigation/_mobilenav.scss +149 -0
  118. data/app/assets/stylesheets/fae/globals/navigation/_search.scss +76 -0
  119. data/app/assets/stylesheets/fae/globals/navigation/_sidenav.scss +142 -0
  120. data/app/assets/stylesheets/fae/globals/navigation/_utility.scss +95 -0
  121. data/app/assets/stylesheets/fae/modules/_alerts.scss +50 -0
  122. data/app/assets/stylesheets/fae/modules/_buttons.scss +62 -0
  123. data/app/assets/stylesheets/fae/modules/_modal.scss +78 -0
  124. data/app/assets/stylesheets/fae/modules/_toggles.scss +48 -0
  125. data/app/assets/stylesheets/fae/modules/forms/_asset-actions.scss +83 -0
  126. data/app/assets/stylesheets/fae/modules/forms/_base.scss +100 -0
  127. data/app/assets/stylesheets/fae/modules/forms/_checkbox.scss +87 -0
  128. data/app/assets/stylesheets/fae/modules/forms/_colorpicker.scss +57 -0
  129. data/app/assets/stylesheets/fae/modules/forms/_date.scss +335 -0
  130. data/app/assets/stylesheets/fae/modules/forms/_hints.scss +40 -0
  131. data/app/assets/stylesheets/fae/modules/forms/_label.scss +57 -0
  132. data/app/assets/stylesheets/fae/modules/forms/_radio.scss +69 -0
  133. data/app/assets/stylesheets/fae/modules/forms/_select.scss +317 -0
  134. data/app/assets/stylesheets/fae/modules/forms/_simple-mde.scss +29 -0
  135. data/app/assets/stylesheets/fae/modules/forms/_text.scss +62 -0
  136. data/app/assets/stylesheets/fae/modules/forms/_textarea.scss +16 -0
  137. data/app/assets/stylesheets/fae/modules/forms/_validation.scss +63 -0
  138. data/app/assets/stylesheets/fae/modules/tables/_actions.scss +41 -0
  139. data/app/assets/stylesheets/fae/modules/tables/_base.scss +63 -0
  140. data/app/assets/stylesheets/fae/modules/tables/_collapsible.scss +76 -0
  141. data/app/assets/stylesheets/fae/modules/tables/_filters.scss +61 -0
  142. data/app/assets/stylesheets/fae/modules/tables/_image.scss +21 -0
  143. data/app/assets/stylesheets/fae/modules/tables/_pagination.scss +34 -0
  144. data/app/assets/stylesheets/fae/modules/tables/_sorting.scss +58 -0
  145. data/app/assets/stylesheets/fae/modules/tables/_sticky.scss +9 -0
  146. data/app/assets/stylesheets/fae/modules/tables/_tooltips.scss +24 -0
  147. data/app/assets/stylesheets/fae/pages/_error.scss +35 -0
  148. data/app/assets/stylesheets/fae/pages/_help.scss +28 -0
  149. data/app/assets/stylesheets/fae/pages/_home.scss +18 -0
  150. data/app/assets/stylesheets/fae/pages/_login.scss +137 -0
  151. data/app/assets/stylesheets/fae/vendor/chosen.css +377 -0
  152. data/app/assets/stylesheets/fae/vendor/daterangepicker.css +227 -0
  153. data/app/assets/stylesheets/fae/vendor/reset.css +48 -0
  154. data/app/assets/stylesheets/fae/vendor/simplemde.min.css +7 -0
  155. data/app/assets/stylesheets/fae/vendor/trumbowyg.css +584 -0
  156. data/app/controllers/concerns/fae/application_controller_concern.rb +1 -0
  157. data/app/controllers/concerns/fae/asset_cloner.rb +46 -0
  158. data/app/controllers/concerns/fae/cloneable.rb +136 -0
  159. data/app/controllers/fae/application_controller.rb +123 -0
  160. data/app/controllers/fae/base_controller.rb +117 -0
  161. data/app/controllers/fae/files_controller.rb +26 -0
  162. data/app/controllers/fae/images_controller.rb +37 -0
  163. data/app/controllers/fae/nested_base_controller.rb +100 -0
  164. data/app/controllers/fae/options_controller.rb +29 -0
  165. data/app/controllers/fae/pages_controller.rb +44 -0
  166. data/app/controllers/fae/setup_controller.rb +54 -0
  167. data/app/controllers/fae/static_pages_controller.rb +54 -0
  168. data/app/controllers/fae/users_controller.rb +71 -0
  169. data/app/controllers/fae/utilities_controller.rb +61 -0
  170. data/app/helpers/fae/application_helper.rb +114 -0
  171. data/app/helpers/fae/fae_helper.rb +6 -0
  172. data/app/helpers/fae/form_helper.rb +240 -0
  173. data/app/helpers/fae/nested_form_helper.rb +39 -0
  174. data/app/helpers/fae/view_helper.rb +175 -0
  175. data/app/inputs/date_range_input.rb +17 -0
  176. data/app/inputs/radio_collection_input.rb +17 -0
  177. data/app/inputs/symbol_input.rb +5 -0
  178. data/app/models/concerns/fae/assets_validatable.rb +12 -0
  179. data/app/models/concerns/fae/authorization_concern.rb +12 -0
  180. data/app/models/concerns/fae/base_model_concern.rb +105 -0
  181. data/app/models/concerns/fae/change_concern.rb +1 -0
  182. data/app/models/concerns/fae/file_concern.rb +1 -0
  183. data/app/models/concerns/fae/image_concern.rb +1 -0
  184. data/app/models/concerns/fae/navigation_concern.rb +10 -0
  185. data/app/models/concerns/fae/option_concern.rb +1 -0
  186. data/app/models/concerns/fae/page_validatable.rb +26 -0
  187. data/app/models/concerns/fae/paper_trailer.rb +8 -0
  188. data/app/models/concerns/fae/role_concern.rb +1 -0
  189. data/app/models/concerns/fae/sortable.rb +51 -0
  190. data/app/models/concerns/fae/static_page_concern.rb +1 -0
  191. data/app/models/concerns/fae/text_area_concern.rb +1 -0
  192. data/app/models/concerns/fae/text_field_concern.rb +1 -0
  193. data/app/models/concerns/fae/trackable.rb +124 -0
  194. data/app/models/concerns/fae/user_concern.rb +7 -0
  195. data/app/models/fae/authorization.rb +8 -0
  196. data/app/models/fae/change.rb +53 -0
  197. data/app/models/fae/file.rb +24 -0
  198. data/app/models/fae/image.rb +33 -0
  199. data/app/models/fae/navigation.rb +132 -0
  200. data/app/models/fae/option.rb +38 -0
  201. data/app/models/fae/role.rb +18 -0
  202. data/app/models/fae/static_page.rb +109 -0
  203. data/app/models/fae/text_area.rb +14 -0
  204. data/app/models/fae/text_field.rb +14 -0
  205. data/app/models/fae/user.rb +67 -0
  206. data/app/uploaders/fae/file_uploader.rb +26 -0
  207. data/app/uploaders/fae/image_uploader.rb +28 -0
  208. data/app/validators/fae/cross_model_uniqueness_validator.rb +14 -0
  209. data/app/views/devise/confirmations/new.html.slim +13 -0
  210. data/app/views/devise/mailer/confirmation_instructions.html.slim +3 -0
  211. data/app/views/devise/mailer/reset_password_instructions.html.slim +5 -0
  212. data/app/views/devise/mailer/unlock_instructions.html.slim +4 -0
  213. data/app/views/devise/passwords/edit.html.slim +10 -0
  214. data/app/views/devise/passwords/new.html.slim +10 -0
  215. data/app/views/devise/registrations/edit.html.slim +22 -0
  216. data/app/views/devise/registrations/new.html.slim +15 -0
  217. data/app/views/devise/sessions/new.html.slim +7 -0
  218. data/app/views/devise/shared/_links.slim +25 -0
  219. data/app/views/devise/unlocks/new.html.slim +13 -0
  220. data/app/views/fae/application/_breadcrumb.html.slim +19 -0
  221. data/app/views/fae/application/_content_form.html.slim +55 -0
  222. data/app/views/fae/application/_credit.slim +6 -0
  223. data/app/views/fae/application/_file_uploader.html.slim +36 -0
  224. data/app/views/fae/application/_flash_messages.slim +2 -0
  225. data/app/views/fae/application/_global_search_results.html.slim +37 -0
  226. data/app/views/fae/application/_header.slim +50 -0
  227. data/app/views/fae/application/_markdown_helper.slim +41 -0
  228. data/app/views/fae/application/_mobilenav.slim +66 -0
  229. data/app/views/fae/application/_sidenav.slim +23 -0
  230. data/app/views/fae/application/_user_log.html.slim +36 -0
  231. data/app/views/fae/images/_image_uploader.html.slim +66 -0
  232. data/app/views/fae/options/_form.html.slim +16 -0
  233. data/app/views/fae/options/edit.html.slim +1 -0
  234. data/app/views/fae/pages/activity_log.html.slim +32 -0
  235. data/app/views/fae/pages/disabled_environment.html.slim +4 -0
  236. data/app/views/fae/pages/error404.html.slim +7 -0
  237. data/app/views/fae/pages/help.html.slim +35 -0
  238. data/app/views/fae/pages/home.html.slim +36 -0
  239. data/app/views/fae/setup/first_user.html.slim +11 -0
  240. data/app/views/fae/shared/_errors.slim +4 -0
  241. data/app/views/fae/shared/_form_header.html.slim +40 -0
  242. data/app/views/fae/shared/_index_header.html.slim +26 -0
  243. data/app/views/fae/shared/_nested_table.html.slim +49 -0
  244. data/app/views/fae/shared/_recent_changes.html.slim +22 -0
  245. data/app/views/fae/shared/_shared_nested_table.html.slim +46 -0
  246. data/app/views/fae/static_pages/index.html.slim +13 -0
  247. data/app/views/fae/users/_form.html.slim +19 -0
  248. data/app/views/fae/users/edit.html.slim +1 -0
  249. data/app/views/fae/users/index.html.slim +23 -0
  250. data/app/views/fae/users/new.html.slim +1 -0
  251. data/app/views/fae/users/settings.html.slim +1 -0
  252. data/app/views/kaminari/fae/_gap.html.slim +8 -0
  253. data/app/views/kaminari/fae/_next_page.html.slim +9 -0
  254. data/app/views/kaminari/fae/_page.html.slim +15 -0
  255. data/app/views/kaminari/fae/_paginator.html.slim +15 -0
  256. data/app/views/kaminari/fae/_prev_page.html.slim +9 -0
  257. data/app/views/layouts/devise.html.slim +29 -0
  258. data/app/views/layouts/fae/application.html.slim +23 -0
  259. data/app/views/layouts/fae/error.html.slim +11 -0
  260. data/config/deploy.rb +73 -0
  261. data/config/deploy/dev.rb +19 -0
  262. data/config/deploy/prod.rb +19 -0
  263. data/config/deploy/stage.rb +19 -0
  264. data/config/initializers/assets.rb +1 -0
  265. data/config/initializers/carrierwave.rb +3 -0
  266. data/config/initializers/devise.rb +258 -0
  267. data/config/initializers/devise_monkeypatch.rb +11 -0
  268. data/config/initializers/fae_judge.rb +3 -0
  269. data/config/initializers/inflections.rb +16 -0
  270. data/config/initializers/kaminari_config.rb +10 -0
  271. data/config/initializers/simple_form.rb +147 -0
  272. data/config/initializers/time_formats.rb +3 -0
  273. data/config/locales/devise.en.yml +59 -0
  274. data/config/locales/devise.zh-CN.yml +59 -0
  275. data/config/locales/fae.en.yml +10 -0
  276. data/config/locales/fae.zh-CN.yml +10 -0
  277. data/config/locales/simple_form.en.yml +26 -0
  278. data/config/locales/simple_form.zh-CN.yml +26 -0
  279. data/config/routes.rb +46 -0
  280. data/db/migrate/20140809222030_add_user_table.rb +49 -0
  281. data/db/migrate/20140822224029_create_fae_roles.rb +10 -0
  282. data/db/migrate/20141008180718_create_fae_images_table.rb +19 -0
  283. data/db/migrate/20141017194616_create_fae_options.rb +16 -0
  284. data/db/migrate/20141021181327_create_fae_files.rb +17 -0
  285. data/db/migrate/20141021183047_create_fae_text_areas.rb +16 -0
  286. data/db/migrate/20141021184311_create_fae_pages.rb +13 -0
  287. data/db/migrate/20141105214814_create_fae_text_fields.rb +15 -0
  288. data/db/migrate/20150930224821_create_fae_changes.rb +17 -0
  289. data/lib/fae-rails.rb +6 -0
  290. data/lib/fae/concerns/models/base.rb +8 -0
  291. data/lib/fae/engine.rb +37 -0
  292. data/lib/fae/options.rb +35 -0
  293. data/lib/fae/validation_helper_collection.rb +76 -0
  294. data/lib/fae/version.rb +3 -0
  295. data/lib/file_size_validator.rb +71 -0
  296. data/lib/generators/fae/base_generator.rb +156 -0
  297. data/lib/generators/fae/controller_generator.rb +13 -0
  298. data/lib/generators/fae/install_generator.rb +61 -0
  299. data/lib/generators/fae/model_generator.rb +11 -0
  300. data/lib/generators/fae/nested_index_scaffold_generator.rb +36 -0
  301. data/lib/generators/fae/nested_scaffold_generator.rb +51 -0
  302. data/lib/generators/fae/page_generator.rb +65 -0
  303. data/lib/generators/fae/scaffold_generator.rb +15 -0
  304. data/lib/generators/fae/templates/assets/fae.js +6 -0
  305. data/lib/generators/fae/templates/assets/fae.scss +2 -0
  306. data/lib/generators/fae/templates/controllers/nested_index_scaffold_controller.rb +81 -0
  307. data/lib/generators/fae/templates/controllers/nested_scaffold_controller.rb +13 -0
  308. data/lib/generators/fae/templates/controllers/scaffold_controller.rb +13 -0
  309. data/lib/generators/fae/templates/controllers/static_pages_controller.rb +10 -0
  310. data/lib/generators/fae/templates/initializers/fae.rb +63 -0
  311. data/lib/generators/fae/templates/initializers/fae_fine.rb +51 -0
  312. data/lib/generators/fae/templates/initializers/judge.rb +6 -0
  313. data/lib/generators/fae/templates/models/concerns/authorization_concern.rb +27 -0
  314. data/lib/generators/fae/templates/models/concerns/navigation_concern.rb +33 -0
  315. data/lib/generators/fae/templates/models/pages_model.rb +14 -0
  316. data/lib/generators/fae/templates/tasks/fae_tasks.rake +19 -0
  317. data/lib/generators/fae/templates/views/_form.html.slim +18 -0
  318. data/lib/generators/fae/templates/views/_form_index_nested.html.slim +13 -0
  319. data/lib/generators/fae/templates/views/_form_nested.html.slim +17 -0
  320. data/lib/generators/fae/templates/views/edit.html.slim +1 -0
  321. data/lib/generators/fae/templates/views/edit_nested.html.slim +3 -0
  322. data/lib/generators/fae/templates/views/index.html.slim +35 -0
  323. data/lib/generators/fae/templates/views/index_nested.html.slim +8 -0
  324. data/lib/generators/fae/templates/views/new.html.slim +1 -0
  325. data/lib/generators/fae/templates/views/new_nested.html.slim +3 -0
  326. data/lib/generators/fae/templates/views/static_page_form.html.slim +15 -0
  327. data/lib/generators/fae/templates/views/table_nested.html.slim +4 -0
  328. metadata +692 -0
@@ -0,0 +1,139 @@
1
+ /*!
2
+ * JavaScript Cookie v2.0.3
3
+ * https://github.com/js-cookie/js-cookie
4
+ *
5
+ * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
6
+ * Released under the MIT license
7
+ */
8
+ (function (factory) {
9
+ if (typeof define === 'function' && define.amd) {
10
+ define(factory);
11
+ } else if (typeof exports === 'object') {
12
+ module.exports = factory();
13
+ } else {
14
+ var _OldCookies = window.Cookies;
15
+ var api = window.Cookies = factory();
16
+ api.noConflict = function () {
17
+ window.Cookies = _OldCookies;
18
+ return api;
19
+ };
20
+ }
21
+ }(function () {
22
+ function extend () {
23
+ var i = 0;
24
+ var result = {};
25
+ for (; i < arguments.length; i++) {
26
+ var attributes = arguments[ i ];
27
+ for (var key in attributes) {
28
+ result[key] = attributes[key];
29
+ }
30
+ }
31
+ return result;
32
+ }
33
+
34
+ function init (converter) {
35
+ function api (key, value, attributes) {
36
+ var result;
37
+
38
+ // Write
39
+
40
+ if (arguments.length > 1) {
41
+ attributes = extend({
42
+ path: '/'
43
+ }, api.defaults, attributes);
44
+
45
+ if (typeof attributes.expires === 'number') {
46
+ var expires = new Date();
47
+ expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
48
+ attributes.expires = expires;
49
+ }
50
+
51
+ try {
52
+ result = JSON.stringify(value);
53
+ if (/^[\{\[]/.test(result)) {
54
+ value = result;
55
+ }
56
+ } catch (e) {}
57
+
58
+ value = encodeURIComponent(String(value));
59
+ value = value.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
60
+
61
+ key = encodeURIComponent(String(key));
62
+ key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
63
+ key = key.replace(/[\(\)]/g, escape);
64
+
65
+ return (document.cookie = [
66
+ key, '=', value,
67
+ attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE
68
+ attributes.path && '; path=' + attributes.path,
69
+ attributes.domain && '; domain=' + attributes.domain,
70
+ attributes.secure ? '; secure' : ''
71
+ ].join(''));
72
+ }
73
+
74
+ // Read
75
+
76
+ if (!key) {
77
+ result = {};
78
+ }
79
+
80
+ // To prevent the for loop in the first place assign an empty array
81
+ // in case there are no cookies at all. Also prevents odd result when
82
+ // calling "get()"
83
+ var cookies = document.cookie ? document.cookie.split('; ') : [];
84
+ var rdecode = /(%[0-9A-Z]{2})+/g;
85
+ var i = 0;
86
+
87
+ for (; i < cookies.length; i++) {
88
+ var parts = cookies[i].split('=');
89
+ var name = parts[0].replace(rdecode, decodeURIComponent);
90
+ var cookie = parts.slice(1).join('=');
91
+
92
+ if (cookie.charAt(0) === '"') {
93
+ cookie = cookie.slice(1, -1);
94
+ }
95
+
96
+ try {
97
+ cookie = converter && converter(cookie, name) || cookie.replace(rdecode, decodeURIComponent);
98
+
99
+ if (this.json) {
100
+ try {
101
+ cookie = JSON.parse(cookie);
102
+ } catch (e) {}
103
+ }
104
+
105
+ if (key === name) {
106
+ result = cookie;
107
+ break;
108
+ }
109
+
110
+ if (!key) {
111
+ result[name] = cookie;
112
+ }
113
+ } catch (e) {}
114
+ }
115
+
116
+ return result;
117
+ }
118
+
119
+ api.get = api.set = api;
120
+ api.getJSON = function () {
121
+ return api.apply({
122
+ json: true
123
+ }, [].slice.call(arguments));
124
+ };
125
+ api.defaults = {};
126
+
127
+ api.remove = function (key, attributes) {
128
+ api(key, '', extend(attributes, {
129
+ expires: -1
130
+ }));
131
+ };
132
+
133
+ api.withConverter = init;
134
+
135
+ return api;
136
+ }
137
+
138
+ return init();
139
+ }));
@@ -0,0 +1,7 @@
1
+ //! moment.js
2
+ //! version : 2.8.3
3
+ //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
4
+ //! license : MIT
5
+ //! momentjs.com
6
+ (function(a){function b(a,b,c){switch(arguments.length){case 2:return null!=a?a:b;case 3:return null!=a?a:null!=b?b:c;default:throw new Error("Implement me")}}function c(a,b){return zb.call(a,b)}function d(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function e(a){tb.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+a)}function f(a,b){var c=!0;return m(function(){return c&&(e(a),c=!1),b.apply(this,arguments)},b)}function g(a,b){qc[a]||(e(b),qc[a]=!0)}function h(a,b){return function(c){return p(a.call(this,c),b)}}function i(a,b){return function(c){return this.localeData().ordinal(a.call(this,c),b)}}function j(){}function k(a,b){b!==!1&&F(a),n(this,a),this._d=new Date(+a._d)}function l(a){var b=y(a),c=b.year||0,d=b.quarter||0,e=b.month||0,f=b.week||0,g=b.day||0,h=b.hour||0,i=b.minute||0,j=b.second||0,k=b.millisecond||0;this._milliseconds=+k+1e3*j+6e4*i+36e5*h,this._days=+g+7*f,this._months=+e+3*d+12*c,this._data={},this._locale=tb.localeData(),this._bubble()}function m(a,b){for(var d in b)c(b,d)&&(a[d]=b[d]);return c(b,"toString")&&(a.toString=b.toString),c(b,"valueOf")&&(a.valueOf=b.valueOf),a}function n(a,b){var c,d,e;if("undefined"!=typeof b._isAMomentObject&&(a._isAMomentObject=b._isAMomentObject),"undefined"!=typeof b._i&&(a._i=b._i),"undefined"!=typeof b._f&&(a._f=b._f),"undefined"!=typeof b._l&&(a._l=b._l),"undefined"!=typeof b._strict&&(a._strict=b._strict),"undefined"!=typeof b._tzm&&(a._tzm=b._tzm),"undefined"!=typeof b._isUTC&&(a._isUTC=b._isUTC),"undefined"!=typeof b._offset&&(a._offset=b._offset),"undefined"!=typeof b._pf&&(a._pf=b._pf),"undefined"!=typeof b._locale&&(a._locale=b._locale),Ib.length>0)for(c in Ib)d=Ib[c],e=b[d],"undefined"!=typeof e&&(a[d]=e);return a}function o(a){return 0>a?Math.ceil(a):Math.floor(a)}function p(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.length<b;)d="0"+d;return(e?c?"+":"":"-")+d}function q(a,b){var c={milliseconds:0,months:0};return c.months=b.month()-a.month()+12*(b.year()-a.year()),a.clone().add(c.months,"M").isAfter(b)&&--c.months,c.milliseconds=+b-+a.clone().add(c.months,"M"),c}function r(a,b){var c;return b=K(b,a),a.isBefore(b)?c=q(a,b):(c=q(b,a),c.milliseconds=-c.milliseconds,c.months=-c.months),c}function s(a,b){return function(c,d){var e,f;return null===d||isNaN(+d)||(g(b,"moment()."+b+"(period, number) is deprecated. Please use moment()."+b+"(number, period)."),f=c,c=d,d=f),c="string"==typeof c?+c:c,e=tb.duration(c,d),t(this,e,a),this}}function t(a,b,c,d){var e=b._milliseconds,f=b._days,g=b._months;d=null==d?!0:d,e&&a._d.setTime(+a._d+e*c),f&&nb(a,"Date",mb(a,"Date")+f*c),g&&lb(a,mb(a,"Month")+g*c),d&&tb.updateOffset(a,f||g)}function u(a){return"[object Array]"===Object.prototype.toString.call(a)}function v(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function w(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&A(a[d])!==A(b[d]))&&g++;return g+f}function x(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=jc[a]||kc[b]||b}return a}function y(a){var b,d,e={};for(d in a)c(a,d)&&(b=x(d),b&&(e[b]=a[d]));return e}function z(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}tb[b]=function(e,f){var g,h,i=tb._locale[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=tb().utc().set(d,a);return i.call(tb._locale,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function A(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function B(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function C(a,b,c){return hb(tb([a,11,31+b-c]),b,c).week}function D(a){return E(a)?366:365}function E(a){return a%4===0&&a%100!==0||a%400===0}function F(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[Bb]<0||a._a[Bb]>11?Bb:a._a[Cb]<1||a._a[Cb]>B(a._a[Ab],a._a[Bb])?Cb:a._a[Db]<0||a._a[Db]>23?Db:a._a[Eb]<0||a._a[Eb]>59?Eb:a._a[Fb]<0||a._a[Fb]>59?Fb:a._a[Gb]<0||a._a[Gb]>999?Gb:-1,a._pf._overflowDayOfYear&&(Ab>b||b>Cb)&&(b=Cb),a._pf.overflow=b)}function G(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!a._pf.empty&&!a._pf.invalidMonth&&!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length)),a._isValid}function H(a){return a?a.toLowerCase().replace("_","-"):a}function I(a){for(var b,c,d,e,f=0;f<a.length;){for(e=H(a[f]).split("-"),b=e.length,c=H(a[f+1]),c=c?c.split("-"):null;b>0;){if(d=J(e.slice(0,b).join("-")))return d;if(c&&c.length>=b&&w(e,c,!0)>=b-1)break;b--}f++}return null}function J(a){var b=null;if(!Hb[a]&&Jb)try{b=tb.locale(),require("./locale/"+a),tb.locale(b)}catch(c){}return Hb[a]}function K(a,b){return b._isUTC?tb(a).zone(b._offset||0):tb(a).local()}function L(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function M(a){var b,c,d=a.match(Nb);for(b=0,c=d.length;c>b;b++)d[b]=pc[d[b]]?pc[d[b]]:L(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function N(a,b){return a.isValid()?(b=O(b,a.localeData()),lc[b]||(lc[b]=M(b)),lc[b](a)):a.localeData().invalidDate()}function O(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(Ob.lastIndex=0;d>=0&&Ob.test(a);)a=a.replace(Ob,c),Ob.lastIndex=0,d-=1;return a}function P(a,b){var c,d=b._strict;switch(a){case"Q":return Zb;case"DDDD":return _b;case"YYYY":case"GGGG":case"gggg":return d?ac:Rb;case"Y":case"G":case"g":return cc;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return d?bc:Sb;case"S":if(d)return Zb;case"SS":if(d)return $b;case"SSS":if(d)return _b;case"DDD":return Qb;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Ub;case"a":case"A":return b._locale._meridiemParse;case"X":return Xb;case"Z":case"ZZ":return Vb;case"T":return Wb;case"SSSS":return Tb;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return d?$b:Pb;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Pb;case"Do":return Yb;default:return c=new RegExp(Y(X(a.replace("\\","")),"i"))}}function Q(a){a=a||"";var b=a.match(Vb)||[],c=b[b.length-1]||[],d=(c+"").match(hc)||["-",0,0],e=+(60*d[1])+A(d[2]);return"+"===d[0]?-e:e}function R(a,b,c){var d,e=c._a;switch(a){case"Q":null!=b&&(e[Bb]=3*(A(b)-1));break;case"M":case"MM":null!=b&&(e[Bb]=A(b)-1);break;case"MMM":case"MMMM":d=c._locale.monthsParse(b),null!=d?e[Bb]=d:c._pf.invalidMonth=b;break;case"D":case"DD":null!=b&&(e[Cb]=A(b));break;case"Do":null!=b&&(e[Cb]=A(parseInt(b,10)));break;case"DDD":case"DDDD":null!=b&&(c._dayOfYear=A(b));break;case"YY":e[Ab]=tb.parseTwoDigitYear(b);break;case"YYYY":case"YYYYY":case"YYYYYY":e[Ab]=A(b);break;case"a":case"A":c._isPm=c._locale.isPM(b);break;case"H":case"HH":case"h":case"hh":e[Db]=A(b);break;case"m":case"mm":e[Eb]=A(b);break;case"s":case"ss":e[Fb]=A(b);break;case"S":case"SS":case"SSS":case"SSSS":e[Gb]=A(1e3*("0."+b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,c._tzm=Q(b);break;case"dd":case"ddd":case"dddd":d=c._locale.weekdaysParse(b),null!=d?(c._w=c._w||{},c._w.d=d):c._pf.invalidWeekday=b;break;case"w":case"ww":case"W":case"WW":case"d":case"e":case"E":a=a.substr(0,1);case"gggg":case"GGGG":case"GGGGG":a=a.substr(0,2),b&&(c._w=c._w||{},c._w[a]=A(b));break;case"gg":case"GG":c._w=c._w||{},c._w[a]=tb.parseTwoDigitYear(b)}}function S(a){var c,d,e,f,g,h,i;c=a._w,null!=c.GG||null!=c.W||null!=c.E?(g=1,h=4,d=b(c.GG,a._a[Ab],hb(tb(),1,4).year),e=b(c.W,1),f=b(c.E,1)):(g=a._locale._week.dow,h=a._locale._week.doy,d=b(c.gg,a._a[Ab],hb(tb(),g,h).year),e=b(c.w,1),null!=c.d?(f=c.d,g>f&&++e):f=null!=c.e?c.e+g:g),i=ib(d,e,f,h,g),a._a[Ab]=i.year,a._dayOfYear=i.dayOfYear}function T(a){var c,d,e,f,g=[];if(!a._d){for(e=V(a),a._w&&null==a._a[Cb]&&null==a._a[Bb]&&S(a),a._dayOfYear&&(f=b(a._a[Ab],e[Ab]),a._dayOfYear>D(f)&&(a._pf._overflowDayOfYear=!0),d=db(f,0,a._dayOfYear),a._a[Bb]=d.getUTCMonth(),a._a[Cb]=d.getUTCDate()),c=0;3>c&&null==a._a[c];++c)a._a[c]=g[c]=e[c];for(;7>c;c++)a._a[c]=g[c]=null==a._a[c]?2===c?1:0:a._a[c];a._d=(a._useUTC?db:cb).apply(null,g),null!=a._tzm&&a._d.setUTCMinutes(a._d.getUTCMinutes()+a._tzm)}}function U(a){var b;a._d||(b=y(a._i),a._a=[b.year,b.month,b.day,b.hour,b.minute,b.second,b.millisecond],T(a))}function V(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function W(a){if(a._f===tb.ISO_8601)return void $(a);a._a=[],a._pf.empty=!0;var b,c,d,e,f,g=""+a._i,h=g.length,i=0;for(d=O(a._f,a._locale).match(Nb)||[],b=0;b<d.length;b++)e=d[b],c=(g.match(P(e,a))||[])[0],c&&(f=g.substr(0,g.indexOf(c)),f.length>0&&a._pf.unusedInput.push(f),g=g.slice(g.indexOf(c)+c.length),i+=c.length),pc[e]?(c?a._pf.empty=!1:a._pf.unusedTokens.push(e),R(e,c,a)):a._strict&&!c&&a._pf.unusedTokens.push(e);a._pf.charsLeftOver=h-i,g.length>0&&a._pf.unusedInput.push(g),a._isPm&&a._a[Db]<12&&(a._a[Db]+=12),a._isPm===!1&&12===a._a[Db]&&(a._a[Db]=0),T(a),F(a)}function X(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e})}function Y(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Z(a){var b,c,e,f,g;if(0===a._f.length)return a._pf.invalidFormat=!0,void(a._d=new Date(0/0));for(f=0;f<a._f.length;f++)g=0,b=n({},a),null!=a._useUTC&&(b._useUTC=a._useUTC),b._pf=d(),b._f=a._f[f],W(b),G(b)&&(g+=b._pf.charsLeftOver,g+=10*b._pf.unusedTokens.length,b._pf.score=g,(null==e||e>g)&&(e=g,c=b));m(a,c||b)}function $(a){var b,c,d=a._i,e=dc.exec(d);if(e){for(a._pf.iso=!0,b=0,c=fc.length;c>b;b++)if(fc[b][1].exec(d)){a._f=fc[b][0]+(e[6]||" ");break}for(b=0,c=gc.length;c>b;b++)if(gc[b][1].exec(d)){a._f+=gc[b][0];break}d.match(Vb)&&(a._f+="Z"),W(a)}else a._isValid=!1}function _(a){$(a),a._isValid===!1&&(delete a._isValid,tb.createFromInputFallback(a))}function ab(a,b){var c,d=[];for(c=0;c<a.length;++c)d.push(b(a[c],c));return d}function bb(b){var c,d=b._i;d===a?b._d=new Date:v(d)?b._d=new Date(+d):null!==(c=Kb.exec(d))?b._d=new Date(+c[1]):"string"==typeof d?_(b):u(d)?(b._a=ab(d.slice(0),function(a){return parseInt(a,10)}),T(b)):"object"==typeof d?U(b):"number"==typeof d?b._d=new Date(d):tb.createFromInputFallback(b)}function cb(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function db(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function eb(a,b){if("string"==typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!=typeof a)return null}else a=parseInt(a,10);return a}function fb(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function gb(a,b,c){var d=tb.duration(a).abs(),e=yb(d.as("s")),f=yb(d.as("m")),g=yb(d.as("h")),h=yb(d.as("d")),i=yb(d.as("M")),j=yb(d.as("y")),k=e<mc.s&&["s",e]||1===f&&["m"]||f<mc.m&&["mm",f]||1===g&&["h"]||g<mc.h&&["hh",g]||1===h&&["d"]||h<mc.d&&["dd",h]||1===i&&["M"]||i<mc.M&&["MM",i]||1===j&&["y"]||["yy",j];return k[2]=b,k[3]=+a>0,k[4]=c,fb.apply({},k)}function hb(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=tb(a).add(f,"d"),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function ib(a,b,c,d,e){var f,g,h=db(a,0,1).getUTCDay();return h=0===h?7:h,c=null!=c?c:e,f=e-h+(h>d?7:0)-(e>h?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:D(a-1)+g}}function jb(b){var c=b._i,d=b._f;return b._locale=b._locale||tb.localeData(b._l),null===c||d===a&&""===c?tb.invalid({nullInput:!0}):("string"==typeof c&&(b._i=c=b._locale.preparse(c)),tb.isMoment(c)?new k(c,!0):(d?u(d)?Z(b):W(b):bb(b),new k(b)))}function kb(a,b){var c,d;if(1===b.length&&u(b[0])&&(b=b[0]),!b.length)return tb();for(c=b[0],d=1;d<b.length;++d)b[d][a](c)&&(c=b[d]);return c}function lb(a,b){var c;return"string"==typeof b&&(b=a.localeData().monthsParse(b),"number"!=typeof b)?a:(c=Math.min(a.date(),B(a.year(),b)),a._d["set"+(a._isUTC?"UTC":"")+"Month"](b,c),a)}function mb(a,b){return a._d["get"+(a._isUTC?"UTC":"")+b]()}function nb(a,b,c){return"Month"===b?lb(a,c):a._d["set"+(a._isUTC?"UTC":"")+b](c)}function ob(a,b){return function(c){return null!=c?(nb(this,a,c),tb.updateOffset(this,b),this):mb(this,a)}}function pb(a){return 400*a/146097}function qb(a){return 146097*a/400}function rb(a){tb.duration.fn[a]=function(){return this._data[a]}}function sb(a){"undefined"==typeof ender&&(ub=xb.moment,xb.moment=a?f("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.",tb):tb)}for(var tb,ub,vb,wb="2.8.3",xb="undefined"!=typeof global?global:this,yb=Math.round,zb=Object.prototype.hasOwnProperty,Ab=0,Bb=1,Cb=2,Db=3,Eb=4,Fb=5,Gb=6,Hb={},Ib=[],Jb="undefined"!=typeof module&&module.exports,Kb=/^\/?Date\((\-?\d+)/i,Lb=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,Mb=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,Nb=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,Ob=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,Pb=/\d\d?/,Qb=/\d{1,3}/,Rb=/\d{1,4}/,Sb=/[+\-]?\d{1,6}/,Tb=/\d+/,Ub=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Vb=/Z|[\+\-]\d\d:?\d\d/gi,Wb=/T/i,Xb=/[\+\-]?\d+(\.\d{1,3})?/,Yb=/\d{1,2}/,Zb=/\d/,$b=/\d\d/,_b=/\d{3}/,ac=/\d{4}/,bc=/[+-]?\d{6}/,cc=/[+-]?\d+/,dc=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,ec="YYYY-MM-DDTHH:mm:ssZ",fc=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],gc=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],hc=/([\+\-]|\d\d)/gi,ic=("Date|Hours|Minutes|Seconds|Milliseconds".split("|"),{Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6}),jc={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",Q:"quarter",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},kc={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},lc={},mc={s:45,m:45,h:22,d:26,M:11},nc="DDD w W M D d".split(" "),oc="M D H h m s w W".split(" "),pc={M:function(){return this.month()+1},MMM:function(a){return this.localeData().monthsShort(this,a)},MMMM:function(a){return this.localeData().months(this,a)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(a){return this.localeData().weekdaysMin(this,a)},ddd:function(a){return this.localeData().weekdaysShort(this,a)},dddd:function(a){return this.localeData().weekdays(this,a)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return p(this.year()%100,2)},YYYY:function(){return p(this.year(),4)},YYYYY:function(){return p(this.year(),5)},YYYYYY:function(){var a=this.year(),b=a>=0?"+":"-";return b+p(Math.abs(a),6)},gg:function(){return p(this.weekYear()%100,2)},gggg:function(){return p(this.weekYear(),4)},ggggg:function(){return p(this.weekYear(),5)},GG:function(){return p(this.isoWeekYear()%100,2)},GGGG:function(){return p(this.isoWeekYear(),4)},GGGGG:function(){return p(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return A(this.milliseconds()/100)},SS:function(){return p(A(this.milliseconds()/10),2)},SSS:function(){return p(this.milliseconds(),3)},SSSS:function(){return p(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+p(A(a/60),2)+":"+p(A(a)%60,2)},ZZ:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+p(A(a/60),2)+p(A(a)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},qc={},rc=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];nc.length;)vb=nc.pop(),pc[vb+"o"]=i(pc[vb],vb);for(;oc.length;)vb=oc.pop(),pc[vb+vb]=h(pc[vb],2);pc.DDDD=h(pc.DDD,3),m(j.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(a){return this._months[a.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a){var b,c,d;for(this._monthsParse||(this._monthsParse=[]),b=0;12>b;b++)if(this._monthsParse[b]||(c=tb.utc([2e3,b]),d="^"+this.months(c,"")+"|^"+this.monthsShort(c,""),this._monthsParse[b]=new RegExp(d.replace(".",""),"i")),this._monthsParse[b].test(a))return b},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c,d;for(this._weekdaysParse||(this._weekdaysParse=[]),b=0;7>b;b++)if(this._weekdaysParse[b]||(c=tb([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(a,b){var c=this._calendar[a];return"function"==typeof c?c.apply(b):c},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",preparse:function(a){return a},postformat:function(a){return a},week:function(a){return hb(a,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),tb=function(b,c,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._i=b,g._f=c,g._l=e,g._strict=f,g._isUTC=!1,g._pf=d(),jb(g)},tb.suppressDeprecationWarnings=!1,tb.createFromInputFallback=f("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(a){a._d=new Date(a._i)}),tb.min=function(){var a=[].slice.call(arguments,0);return kb("isBefore",a)},tb.max=function(){var a=[].slice.call(arguments,0);return kb("isAfter",a)},tb.utc=function(b,c,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._useUTC=!0,g._isUTC=!0,g._l=e,g._i=b,g._f=c,g._strict=f,g._pf=d(),jb(g).utc()},tb.unix=function(a){return tb(1e3*a)},tb.duration=function(a,b){var d,e,f,g,h=a,i=null;return tb.isDuration(a)?h={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(h={},b?h[b]=a:h.milliseconds=a):(i=Lb.exec(a))?(d="-"===i[1]?-1:1,h={y:0,d:A(i[Cb])*d,h:A(i[Db])*d,m:A(i[Eb])*d,s:A(i[Fb])*d,ms:A(i[Gb])*d}):(i=Mb.exec(a))?(d="-"===i[1]?-1:1,f=function(a){var b=a&&parseFloat(a.replace(",","."));return(isNaN(b)?0:b)*d},h={y:f(i[2]),M:f(i[3]),d:f(i[4]),h:f(i[5]),m:f(i[6]),s:f(i[7]),w:f(i[8])}):"object"==typeof h&&("from"in h||"to"in h)&&(g=r(tb(h.from),tb(h.to)),h={},h.ms=g.milliseconds,h.M=g.months),e=new l(h),tb.isDuration(a)&&c(a,"_locale")&&(e._locale=a._locale),e},tb.version=wb,tb.defaultFormat=ec,tb.ISO_8601=function(){},tb.momentProperties=Ib,tb.updateOffset=function(){},tb.relativeTimeThreshold=function(b,c){return mc[b]===a?!1:c===a?mc[b]:(mc[b]=c,!0)},tb.lang=f("moment.lang is deprecated. Use moment.locale instead.",function(a,b){return tb.locale(a,b)}),tb.locale=function(a,b){var c;return a&&(c="undefined"!=typeof b?tb.defineLocale(a,b):tb.localeData(a),c&&(tb.duration._locale=tb._locale=c)),tb._locale._abbr},tb.defineLocale=function(a,b){return null!==b?(b.abbr=a,Hb[a]||(Hb[a]=new j),Hb[a].set(b),tb.locale(a),Hb[a]):(delete Hb[a],null)},tb.langData=f("moment.langData is deprecated. Use moment.localeData instead.",function(a){return tb.localeData(a)}),tb.localeData=function(a){var b;if(a&&a._locale&&a._locale._abbr&&(a=a._locale._abbr),!a)return tb._locale;if(!u(a)){if(b=J(a))return b;a=[a]}return I(a)},tb.isMoment=function(a){return a instanceof k||null!=a&&c(a,"_isAMomentObject")},tb.isDuration=function(a){return a instanceof l};for(vb=rc.length-1;vb>=0;--vb)z(rc[vb]);tb.normalizeUnits=function(a){return x(a)},tb.invalid=function(a){var b=tb.utc(0/0);return null!=a?m(b._pf,a):b._pf.userInvalidated=!0,b},tb.parseZone=function(){return tb.apply(null,arguments).parseZone()},tb.parseTwoDigitYear=function(a){return A(a)+(A(a)>68?1900:2e3)},m(tb.fn=k.prototype,{clone:function(){return tb(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var a=tb(this).utc();return 0<a.year()&&a.year()<=9999?N(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):N(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds()]},isValid:function(){return G(this)},isDSTShifted:function(){return this._a?this.isValid()&&w(this._a,(this._isUTC?tb.utc(this._a):tb(this._a)).toArray())>0:!1},parsingFlags:function(){return m({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(a){return this.zone(0,a)},local:function(a){return this._isUTC&&(this.zone(0,a),this._isUTC=!1,a&&this.add(this._dateTzOffset(),"m")),this},format:function(a){var b=N(this,a||tb.defaultFormat);return this.localeData().postformat(b)},add:s(1,"add"),subtract:s(-1,"subtract"),diff:function(a,b,c){var d,e,f,g=K(a,this),h=6e4*(this.zone()-g.zone());return b=x(b),"year"===b||"month"===b?(d=432e5*(this.daysInMonth()+g.daysInMonth()),e=12*(this.year()-g.year())+(this.month()-g.month()),f=this-tb(this).startOf("month")-(g-tb(g).startOf("month")),f-=6e4*(this.zone()-tb(this).startOf("month").zone()-(g.zone()-tb(g).startOf("month").zone())),e+=f/d,"year"===b&&(e/=12)):(d=this-g,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-h)/864e5:"week"===b?(d-h)/6048e5:d),c?e:o(e)},from:function(a,b){return tb.duration({to:this,from:a}).locale(this.locale()).humanize(!b)},fromNow:function(a){return this.from(tb(),a)},calendar:function(a){var b=a||tb(),c=K(b,this).startOf("day"),d=this.diff(c,"days",!0),e=-6>d?"sameElse":-1>d?"lastWeek":0>d?"lastDay":1>d?"sameDay":2>d?"nextDay":7>d?"nextWeek":"sameElse";return this.format(this.localeData().calendar(e,this))},isLeapYear:function(){return E(this.year())},isDST:function(){return this.zone()<this.clone().month(0).zone()||this.zone()<this.clone().month(5).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=eb(a,this.localeData()),this.add(a-b,"d")):b},month:ob("Month",!0),startOf:function(a){switch(a=x(a)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===a?this.weekday(0):"isoWeek"===a&&this.isoWeekday(1),"quarter"===a&&this.month(3*Math.floor(this.month()/3)),this},endOf:function(a){return a=x(a),this.startOf(a).add(1,"isoWeek"===a?"week":a).subtract(1,"ms")},isAfter:function(a,b){return b=x("undefined"!=typeof b?b:"millisecond"),"millisecond"===b?(a=tb.isMoment(a)?a:tb(a),+this>+a):+this.clone().startOf(b)>+tb(a).startOf(b)},isBefore:function(a,b){return b=x("undefined"!=typeof b?b:"millisecond"),"millisecond"===b?(a=tb.isMoment(a)?a:tb(a),+a>+this):+this.clone().startOf(b)<+tb(a).startOf(b)},isSame:function(a,b){return b=x(b||"millisecond"),"millisecond"===b?(a=tb.isMoment(a)?a:tb(a),+this===+a):+this.clone().startOf(b)===+K(a,this).startOf(b)},min:f("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(a){return a=tb.apply(null,arguments),this>a?this:a}),max:f("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(a){return a=tb.apply(null,arguments),a>this?this:a}),zone:function(a,b){var c,d=this._offset||0;return null==a?this._isUTC?d:this._dateTzOffset():("string"==typeof a&&(a=Q(a)),Math.abs(a)<16&&(a=60*a),!this._isUTC&&b&&(c=this._dateTzOffset()),this._offset=a,this._isUTC=!0,null!=c&&this.subtract(c,"m"),d!==a&&(!b||this._changeInProgress?t(this,tb.duration(d-a,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,tb.updateOffset(this,!0),this._changeInProgress=null)),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(a){return a=a?tb(a).zone():0,(this.zone()-a)%60===0},daysInMonth:function(){return B(this.year(),this.month())},dayOfYear:function(a){var b=yb((tb(this).startOf("day")-tb(this).startOf("year"))/864e5)+1;return null==a?b:this.add(a-b,"d")},quarter:function(a){return null==a?Math.ceil((this.month()+1)/3):this.month(3*(a-1)+this.month()%3)},weekYear:function(a){var b=hb(this,this.localeData()._week.dow,this.localeData()._week.doy).year;return null==a?b:this.add(a-b,"y")},isoWeekYear:function(a){var b=hb(this,1,4).year;return null==a?b:this.add(a-b,"y")},week:function(a){var b=this.localeData().week(this);return null==a?b:this.add(7*(a-b),"d")},isoWeek:function(a){var b=hb(this,1,4).week;return null==a?b:this.add(7*(a-b),"d")},weekday:function(a){var b=(this.day()+7-this.localeData()._week.dow)%7;return null==a?b:this.add(a-b,"d")},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},isoWeeksInYear:function(){return C(this.year(),1,4)},weeksInYear:function(){var a=this.localeData()._week;return C(this.year(),a.dow,a.doy)},get:function(a){return a=x(a),this[a]()},set:function(a,b){return a=x(a),"function"==typeof this[a]&&this[a](b),this},locale:function(b){var c;return b===a?this._locale._abbr:(c=tb.localeData(b),null!=c&&(this._locale=c),this)},lang:f("moment().lang() is deprecated. Use moment().localeData() instead.",function(b){return b===a?this.localeData():this.locale(b)}),localeData:function(){return this._locale},_dateTzOffset:function(){return 15*Math.round(this._d.getTimezoneOffset()/15)}}),tb.fn.millisecond=tb.fn.milliseconds=ob("Milliseconds",!1),tb.fn.second=tb.fn.seconds=ob("Seconds",!1),tb.fn.minute=tb.fn.minutes=ob("Minutes",!1),tb.fn.hour=tb.fn.hours=ob("Hours",!0),tb.fn.date=ob("Date",!0),tb.fn.dates=f("dates accessor is deprecated. Use date instead.",ob("Date",!0)),tb.fn.year=ob("FullYear",!0),tb.fn.years=f("years accessor is deprecated. Use year instead.",ob("FullYear",!0)),tb.fn.days=tb.fn.day,tb.fn.months=tb.fn.month,tb.fn.weeks=tb.fn.week,tb.fn.isoWeeks=tb.fn.isoWeek,tb.fn.quarters=tb.fn.quarter,tb.fn.toJSON=tb.fn.toISOString,m(tb.duration.fn=l.prototype,{_bubble:function(){var a,b,c,d=this._milliseconds,e=this._days,f=this._months,g=this._data,h=0;g.milliseconds=d%1e3,a=o(d/1e3),g.seconds=a%60,b=o(a/60),g.minutes=b%60,c=o(b/60),g.hours=c%24,e+=o(c/24),h=o(pb(e)),e-=o(qb(h)),f+=o(e/30),e%=30,h+=o(f/12),f%=12,g.days=e,g.months=f,g.years=h},abs:function(){return this._milliseconds=Math.abs(this._milliseconds),this._days=Math.abs(this._days),this._months=Math.abs(this._months),this._data.milliseconds=Math.abs(this._data.milliseconds),this._data.seconds=Math.abs(this._data.seconds),this._data.minutes=Math.abs(this._data.minutes),this._data.hours=Math.abs(this._data.hours),this._data.months=Math.abs(this._data.months),this._data.years=Math.abs(this._data.years),this},weeks:function(){return o(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*A(this._months/12)},humanize:function(a){var b=gb(this,!a,this.localeData());return a&&(b=this.localeData().pastFuture(+this,b)),this.localeData().postformat(b)},add:function(a,b){var c=tb.duration(a,b);return this._milliseconds+=c._milliseconds,this._days+=c._days,this._months+=c._months,this._bubble(),this},subtract:function(a,b){var c=tb.duration(a,b);return this._milliseconds-=c._milliseconds,this._days-=c._days,this._months-=c._months,this._bubble(),this},get:function(a){return a=x(a),this[a.toLowerCase()+"s"]()},as:function(a){var b,c;if(a=x(a),"month"===a||"year"===a)return b=this._days+this._milliseconds/864e5,c=this._months+12*pb(b),"month"===a?c:c/12;switch(b=this._days+qb(this._months/12),a){case"week":return b/7+this._milliseconds/6048e5;case"day":return b+this._milliseconds/864e5;case"hour":return 24*b+this._milliseconds/36e5;case"minute":return 24*b*60+this._milliseconds/6e4;case"second":return 24*b*60*60+this._milliseconds/1e3;case"millisecond":return Math.floor(24*b*60*60*1e3)+this._milliseconds;default:throw new Error("Unknown unit "+a)}},lang:tb.fn.lang,locale:tb.fn.locale,toIsoString:f("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",function(){return this.toISOString()}),toISOString:function(){var a=Math.abs(this.years()),b=Math.abs(this.months()),c=Math.abs(this.days()),d=Math.abs(this.hours()),e=Math.abs(this.minutes()),f=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||f?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(f?f+"S":""):"P0D"},localeData:function(){return this._locale}}),tb.duration.fn.toString=tb.duration.fn.toISOString;for(vb in ic)c(ic,vb)&&rb(vb.toLowerCase());tb.duration.fn.asMilliseconds=function(){return this.as("ms")},tb.duration.fn.asSeconds=function(){return this.as("s")},tb.duration.fn.asMinutes=function(){return this.as("m")},tb.duration.fn.asHours=function(){return this.as("h")},tb.duration.fn.asDays=function(){return this.as("d")},tb.duration.fn.asWeeks=function(){return this.as("weeks")},tb.duration.fn.asMonths=function(){return this.as("M")},tb.duration.fn.asYears=function(){return this.as("y")},tb.locale("en",{ordinal:function(a){var b=a%10,c=1===A(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";
7
+ return a+c}}),Jb?module.exports=tb:"function"==typeof define&&define.amd?(define("moment",function(a,b,c){return c.config&&c.config()&&c.config().noGlobal===!0&&(xb.moment=ub),tb}),sb(!0)):sb()}).call(this);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * simplemde v1.7.4
3
+ * Copyright Next Step Webs, Inc.
4
+ * @link https://github.com/NextStepWebs/simplemde-markdown-editor
5
+ * @license MIT
6
+ */
7
+ function fixShortcut(e){return e=isMac?e.replace("Ctrl","Cmd"):e.replace("Cmd","Ctrl")}function createIcon(e,t){e=e||{};var n=document.createElement("a");return t=void 0==t?!0:t,e.title&&t&&(n.title=e.title,isMac&&(n.title=n.title.replace("Ctrl","⌘"),n.title=n.title.replace("Alt","⌥"))),n.className=e.className,n}function createSep(){return el=document.createElement("i"),el.className="separator",el.innerHTML="|",el}function getState(e,t){t=t||e.getCursor("start");var n=e.getTokenAt(t);if(!n.type)return{};for(var r,i,o=n.type.split(" "),l={},a=0;a<o.length;a++)r=o[a],"strong"===r?l.bold=!0:"variable-2"===r?(i=e.getLine(t.line),/^\s*\d+\.\s/.test(i)?l["ordered-list"]=!0:l["unordered-list"]=!0):"atom"===r?l.quote=!0:"em"===r?l.italic=!0:"quote"===r?l.quote=!0:"strikethrough"===r?l.strikethrough=!0:"comment"===r&&(l.code=!0);return l}function toggleFullScreen(e){var t=e.codemirror;t.setOption("fullScreen",!t.getOption("fullScreen")),t.getOption("fullScreen")?(saved_overflow=document.body.style.overflow,document.body.style.overflow="hidden"):document.body.style.overflow=saved_overflow;var n=t.getWrapperElement();/fullscreen/.test(n.previousSibling.className)?n.previousSibling.className=n.previousSibling.className.replace(/\s*fullscreen\b/,""):n.previousSibling.className+=" fullscreen";var r=e.toolbarElements.fullscreen;/active/.test(r.className)?r.className=r.className.replace(/\s*active\s*/g,""):r.className+=" active";var i=t.getWrapperElement().nextSibling;/editor-preview-active-side/.test(i.className)&&toggleSideBySide(e)}function toggleBold(e){_toggleBlock(e,"bold","**")}function toggleItalic(e){_toggleBlock(e,"italic","*")}function toggleStrikethrough(e){_toggleBlock(e,"strikethrough","~~")}function toggleCodeBlock(e){_toggleBlock(e,"code","```\r\n","\r\n```")}function toggleBlockquote(e){var t=e.codemirror;_toggleLine(t,"quote")}function toggleHeadingSmaller(e){var t=e.codemirror;_toggleHeading(t,"smaller")}function toggleHeadingBigger(e){var t=e.codemirror;_toggleHeading(t,"bigger")}function toggleHeading1(e){var t=e.codemirror;_toggleHeading(t,void 0,1)}function toggleHeading2(e){var t=e.codemirror;_toggleHeading(t,void 0,2)}function toggleHeading3(e){var t=e.codemirror;_toggleHeading(t,void 0,3)}function toggleUnorderedList(e){var t=e.codemirror;_toggleLine(t,"unordered-list")}function toggleOrderedList(e){var t=e.codemirror;_toggleLine(t,"ordered-list")}function drawLink(e){var t=e.codemirror,n=getState(t);_replaceSelection(t,n.link,"[","](http://)")}function drawImage(e){var t=e.codemirror,n=getState(t);_replaceSelection(t,n.image,"![](http://",")")}function drawHorizontalRule(e){var t=e.codemirror,n=getState(t);_replaceSelection(t,n.image,"","\n\n-----\n\n")}function undo(e){var t=e.codemirror;t.undo(),t.focus()}function redo(e){var t=e.codemirror;t.redo(),t.focus()}function toggleSideBySide(e){var t=e.codemirror,n=t.getWrapperElement(),r=(n.firstChild,n.nextSibling),i=e.toolbarElements["side-by-side"];/editor-preview-active-side/.test(r.className)?(r.className=r.className.replace(/\s*editor-preview-active-side\s*/g,""),i.className=i.className.replace(/\s*active\s*/g,""),n.className=n.className.replace(/\s*CodeMirror-sided\s*/g," ")):(setTimeout(function(){t.getOption("fullScreen")||toggleFullScreen(e),r.className+=" editor-preview-active-side"},1),i.className+=" active",n.className+=" CodeMirror-sided");var o=n.lastChild;if(/editor-preview-active/.test(o.className)){o.className=o.className.replace(/\s*editor-preview-active\s*/g,"");var l=e.toolbarElements.preview,a=n.previousSibling;l.className=l.className.replace(/\s*active\s*/g,""),a.className=a.className.replace(/\s*disabled-for-preview*/g,"")}r.innerHTML=e.options.previewRender(e.value(),r),t.on("update",function(){r.innerHTML=e.options.previewRender(e.value(),r)})}function togglePreview(e){var t=e.codemirror,n=t.getWrapperElement(),r=n.previousSibling,i=e.toolbarElements.preview,o=n.lastChild;o&&/editor-preview/.test(o.className)||(o=document.createElement("div"),o.className="editor-preview",n.appendChild(o)),/editor-preview-active/.test(o.className)?(o.className=o.className.replace(/\s*editor-preview-active\s*/g,""),i.className=i.className.replace(/\s*active\s*/g,""),r.className=r.className.replace(/\s*disabled-for-preview*/g,"")):(setTimeout(function(){o.className+=" editor-preview-active"},1),i.className+=" active",r.className+=" disabled-for-preview"),o.innerHTML=e.options.previewRender(e.value(),o);var l=t.getWrapperElement().nextSibling;/editor-preview-active-side/.test(l.className)&&toggleSideBySide(e)}function _replaceSelection(e,t,n,r){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){var i,o=e.getCursor("start"),l=e.getCursor("end");t?(i=e.getLine(o.line),n=i.slice(0,o.ch),r=i.slice(o.ch),e.replaceRange(n+r,{line:o.line,ch:0})):(i=e.getSelection(),e.replaceSelection(n+i+r),o.ch+=n.length,o!==l&&(l.ch+=n.length)),e.setSelection(o,l),e.focus()}}function _toggleHeading(e,t,n){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var r=e.getCursor("start"),i=e.getCursor("end"),o=r.line;o<=i.line;o++)!function(r){var i=e.getLine(r),o=i.search(/[^#]/);i=void 0!==t?0>=o?"bigger"==t?"###### "+i:"# "+i:6==o&&"smaller"==t?i.substr(7):1==o&&"bigger"==t?i.substr(2):"bigger"==t?i.substr(1):"#"+i:1==n?0>=o?"# "+i:o==n?i.substr(o+1):"# "+i.substr(o+1):2==n?0>=o?"## "+i:o==n?i.substr(o+1):"## "+i.substr(o+1):0>=o?"### "+i:o==n?i.substr(o+1):"### "+i.substr(o+1),e.replaceRange(i,{line:r,ch:0},{line:r,ch:99999999999999})}(o);e.focus()}}function _toggleLine(e,t){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var n=getState(e),r=e.getCursor("start"),i=e.getCursor("end"),o={quote:/^(\s*)\>\s+/,"unordered-list":/^(\s*)(\*|\-|\+)\s+/,"ordered-list":/^(\s*)\d+\.\s+/},l={quote:"> ","unordered-list":"* ","ordered-list":"1. "},a=r.line;a<=i.line;a++)!function(r){var i=e.getLine(r);i=n[t]?i.replace(o[t],"$1"):l[t]+i,e.replaceRange(i,{line:r,ch:0},{line:r,ch:99999999999999})}(a);e.focus()}}function _toggleBlock(e,t,n,r){if(!/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)){r="undefined"==typeof r?n:r;var i,o=e.codemirror,l=getState(o),a=n,s=r,u=o.getCursor("start"),c=o.getCursor("end");l[t]?(i=o.getLine(u.line),a=i.slice(0,u.ch),s=i.slice(u.ch),"bold"==t?(a=a.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),s=s.replace(/(\*\*|__)/,"")):"italic"==t?(a=a.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),s=s.replace(/(\*|_)/,"")):"strikethrough"==t&&(a=a.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/,""),s=s.replace(/(\*\*|~~)/,"")),o.replaceRange(a+s,{line:u.line,ch:0},{line:u.line,ch:99999999999999}),"bold"==t||"strikethrough"==t?(u.ch-=2,u!==c&&(c.ch-=2)):"italic"==t&&(u.ch-=1,u!==c&&(c.ch-=1))):(i=o.getSelection(),"bold"==t?(i=i.split("**").join(""),i=i.split("__").join("")):"italic"==t?(i=i.split("*").join(""),i=i.split("_").join("")):"strikethrough"==t&&(i=i.split("~~").join("")),o.replaceSelection(a+i+s),u.ch+=n.length,c.ch=u.ch+i.length),o.setSelection(u,c),o.focus()}}function wordCount(e){var t=/[a-zA-Z0-9_\u0392-\u03c9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g,n=e.match(t),r=0;if(null===n)return r;for(var i=0;i<n.length;i++)r+=n[i].charCodeAt(0)>=19968?n[i].length:1;return r}function SimpleMDE(e){e=e||{},e.parent=this;var t=!0;if(e.autoDownloadFontAwesome===!1&&(t=!1),e.autoDownloadFontAwesome!==!0)for(var n=document.styleSheets,r=0;r<n.length;r++)n[r].href&&n[r].href.indexOf("//maxcdn.bootstrapcdn.com/font-awesome/")>-1&&(t=!1);if(t){var i=document.createElement("link");i.rel="stylesheet",i.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(i)}if(e.element)this.element=e.element;else if(null===e.element)return void console.log("SimpleMDE: Error. No element was found.");e.toolbar!==!1&&(e.toolbar=e.toolbar||SimpleMDE.toolbar),e.hasOwnProperty("status")||(e.status=["autosave","lines","words","cursor"]),e.previewRender||(e.previewRender=function(e){return this.parent.markdown(e)}),e.parsingConfig=e.parsingConfig||{},this.options=e,this.render(),e.initialValue&&this.value(e.initialValue)}!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use strict";function e(n,r){if(!(this instanceof e))return new e(n,r);this.options=r=r?Fi(r):{},Fi(Yo,r,!1),f(r);var i=r.value;"string"==typeof i&&(i=new xl(i,r.mode,null,r.lineSeparator)),this.doc=i;var o=new e.inputStyles[r.inputStyle](this),l=this.display=new t(n,i,o);l.wrapper.CodeMirror=this,u(this),a(this),r.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),r.autofocus&&!Mo&&l.input.focus(),v(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Ai,keySeq:null,specialChars:null};var s=this;mo&&11>vo&&setTimeout(function(){s.display.input.reset(!0)},20),Rt(this),Ki(),bt(this),this.curOp.forceUpdate=!0,Xr(this,i),r.autofocus&&!Mo||s.hasFocus()?setTimeout(Pi(mn,this),20):vn(this);for(var c in Zo)Zo.hasOwnProperty(c)&&Zo[c](this,r[c],Qo);C(this),r.finishInit&&r.finishInit(this);for(var h=0;h<nl.length;++h)nl[h](this);wt(this),yo&&r.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,n){var r=this;this.input=n,r.scrollbarFiller=Ri("div",null,"CodeMirror-scrollbar-filler"),r.scrollbarFiller.setAttribute("cm-not-content","true"),r.gutterFiller=Ri("div",null,"CodeMirror-gutter-filler"),r.gutterFiller.setAttribute("cm-not-content","true"),r.lineDiv=Ri("div",null,"CodeMirror-code"),r.selectionDiv=Ri("div",null,null,"position: relative; z-index: 1"),r.cursorDiv=Ri("div",null,"CodeMirror-cursors"),r.measure=Ri("div",null,"CodeMirror-measure"),r.lineMeasure=Ri("div",null,"CodeMirror-measure"),r.lineSpace=Ri("div",[r.measure,r.lineMeasure,r.selectionDiv,r.cursorDiv,r.lineDiv],null,"position: relative; outline: none"),r.mover=Ri("div",[Ri("div",[r.lineSpace],"CodeMirror-lines")],null,"position: relative"),r.sizer=Ri("div",[r.mover],"CodeMirror-sizer"),r.sizerWidth=null,r.heightForcer=Ri("div",null,null,"position: absolute; height: "+Hl+"px; width: 1px;"),r.gutters=Ri("div",null,"CodeMirror-gutters"),r.lineGutter=null,r.scroller=Ri("div",[r.sizer,r.heightForcer,r.gutters],"CodeMirror-scroll"),r.scroller.setAttribute("tabIndex","-1"),r.wrapper=Ri("div",[r.scrollbarFiller,r.gutterFiller,r.scroller],"CodeMirror"),mo&&8>vo&&(r.gutters.style.zIndex=-1,r.scroller.style.paddingRight=0),yo||fo&&Mo||(r.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(r.wrapper):e(r.wrapper)),r.viewFrom=r.viewTo=t.first,r.reportedViewFrom=r.reportedViewTo=t.first,r.view=[],r.renderedView=null,r.externalMeasured=null,r.viewOffset=0,r.lastWrapHeight=r.lastWrapWidth=0,r.updateLineNumbers=null,r.nativeBarWidth=r.barHeight=r.barWidth=0,r.scrollbarsClipped=!1,r.lineNumWidth=r.lineNumInnerWidth=r.lineNumChars=null,r.alignWidgets=!1,r.cachedCharWidth=r.cachedTextHeight=r.cachedPaddingH=null,r.maxLine=null,r.maxLineLength=0,r.maxLineChanged=!1,r.wheelDX=r.wheelDY=r.wheelStartX=r.wheelStartY=null,r.shift=!1,r.selForContextMenu=null,r.activeTouch=null,n.init(r)}function n(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),r(t)}function r(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Be(e,100),e.state.modeGen++,e.curOp&&Wt(e)}function i(e){e.options.lineWrapping?(Kl(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Vl(e.display.wrapper,"CodeMirror-wrap"),d(e)),l(e),Wt(e),lt(e),setTimeout(function(){y(e)},100)}function o(e){var t=vt(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/yt(e.display)-3);return function(i){if(wr(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return n?o+(Math.ceil(i.text.length/r)||1)*t:o+t}}function l(e){var t=e.doc,n=o(e);t.iter(function(e){var t=n(e);t!=e.height&&Jr(e,t)})}function a(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),lt(e)}function s(e){u(e),Wt(e),setTimeout(function(){w(e)},20)}function u(e){var t=e.display.gutters,n=e.options.gutters;qi(t);for(var r=0;r<n.length;++r){var i=n[r],o=t.appendChild(Ri("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=r?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function h(e){if(0==e.height)return 0;for(var t,n=e.text.length,r=e;t=pr(r);){var i=t.find(0,!0);r=i.from.line,n+=i.from.ch-i.to.ch}for(r=e;t=gr(r);){var i=t.find(0,!0);n-=r.text.length-i.from.ch,r=i.to.line,n+=r.text.length-i.to.ch}return n}function d(e){var t=e.display,n=e.doc;t.maxLine=Yr(n,n.first),t.maxLineLength=h(t.maxLine),t.maxLineChanged=!0,n.iter(function(e){var n=h(e);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function f(e){var t=Oi(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+Ue(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+je(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function g(e,t,n){this.cm=n;var r=this.vert=Ri("div",[Ri("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=Ri("div",[Ri("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(r),e(i),Ml(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Ml(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedOverlay=!1,mo&&8>vo&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function m(){}function v(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Vl(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),Ml(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,n){"horizontal"==n?rn(t,e):nn(t,e)},t),t.display.scrollbars.addClass&&Kl(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var n=e.display.barWidth,r=e.display.barHeight;b(e,t);for(var i=0;4>i&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&H(e),b(e,p(e)),n=e.display.barWidth,r=e.display.barHeight}function b(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}function x(e,t,n){var r=n&&null!=n.top?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-qe(e));var i=n&&null!=n.bottom?n.bottom:r+e.wrapper.clientHeight,o=ti(t,r),l=ti(t,i);if(n&&n.ensure){var a=n.ensure.from.line,s=n.ensure.to.line;o>a?(o=a,l=ti(t,ni(Yr(t,a))+e.wrapper.clientHeight)):Math.min(s,t.lastLine())>=l&&(o=ti(t,ni(Yr(t,s))-e.wrapper.clientHeight),l=s)}return{from:o,to:Math.max(l,o+1)}}function w(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=k(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",l=0;l<n.length;l++)if(!n[l].hidden){e.options.fixedGutter&&n[l].gutter&&(n[l].gutter.style.left=o);var a=n[l].alignable;if(a)for(var s=0;s<a.length;s++)a[s].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=r+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=S(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var i=r.measure.appendChild(Ri("div",[Ri("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(o,r.lineGutter.offsetWidth-l)+1,r.lineNumWidth=r.lineNumInnerWidth+l,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function k(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function L(e,t,n){var r=e.display;this.viewport=t,this.visible=x(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=$e(e),this.force=n,this.dims=E(e),this.events=[]}function M(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=je(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=je(e)+"px",t.scrollbarsClipped=!0)}function T(e,t){var n=e.display,r=e.doc;if(t.editorIsHidden)return Ft(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==_t(e))return!1;C(e)&&(Ft(e),t.dims=E(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFrom<o&&o-n.viewFrom<20&&(o=Math.max(r.first,n.viewFrom)),n.viewTo>l&&n.viewTo-l<20&&(l=Math.min(i,n.viewTo)),Eo&&(o=br(e.doc,o),l=xr(e.doc,l));var a=o!=n.viewFrom||l!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;zt(e,o,l),n.viewOffset=ni(Yr(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var s=_t(e);if(!a&&0==s&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var u=Gi();return s>4&&(n.lineDiv.style.display="none"),W(e,n.updateLineNumbers,t.dims),s>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,u&&Gi()!=u&&u.offsetHeight&&u.focus(),qi(n.cursorDiv),qi(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,a&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,Be(e,400)),n.updateLineNumbers=null,!0}function N(e,t){for(var n=t.viewport,r=!0;(r&&e.options.lineWrapping&&t.oldDisplayWidth!=$e(e)||(n&&null!=n.top&&(n={top:Math.min(e.doc.height+Ue(e.display)-Ve(e),n.top)}),t.visible=x(e.display,e.doc,n),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&T(e,t);r=!1){H(e);var i=p(e);Ee(e),D(e,i),y(e,i)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var n=new L(e,t);if(T(e,n)){H(e),N(e,n);var r=p(e);Ee(e),D(e,r),y(e,r),n.finish()}}function D(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var n=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=n+"px",e.display.gutters.style.height=Math.max(n+je(e),t.clientHeight)+"px"}function H(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var i,o=t.view[r];if(!o.hidden){if(mo&&8>vo){var l=o.node.offsetTop+o.node.offsetHeight;i=l-n,n=l}else{var a=o.node.getBoundingClientRect();i=a.bottom-a.top}var s=o.line.height-i;if(2>i&&(i=vt(t)),(s>.001||-.001>s)&&(Jr(o.line,i),O(o.line),o.rest))for(var u=0;u<o.rest.length;u++)O(o.rest[u])}}}function O(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function E(e){for(var t=e.display,n={},r={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)n[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,r[e.options.gutters[l]]=o.clientWidth;return{fixedPos:k(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function W(e,t,n){function r(t){var n=t.nextSibling;return yo&&To&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,a=l.firstChild,s=i.view,u=i.viewFrom,c=0;c<s.length;c++){var h=s[c];if(h.hidden);else if(h.node&&h.node.parentNode==l){for(;a!=h.node;)a=r(a);var d=o&&null!=t&&u>=t&&h.lineNumber;h.changes&&(Oi(h.changes,"gutter")>-1&&(d=!1),I(e,h,u,n)),d&&(qi(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(S(e.options,u)))),a=h.node.nextSibling}else{var f=U(e,h,u,n);l.insertBefore(f,a)}u+=h.size}for(;a;)a=r(a)}function I(e,t,n,r){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?z(e,t):"gutter"==o?R(e,t,n,r):"class"==o?_(t):"widget"==o&&q(e,t,r)}t.changes=null}function F(e){return e.node==e.text&&(e.node=Ri("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),mo&&8>vo&&(e.node.style.zIndex=2)),e.node}function P(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var n=F(e);e.background=n.insertBefore(Ri("div",null,t),n.firstChild)}}function B(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Pr(e,t)}function z(e,t){var n=t.text.className,r=B(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,_(t)):n&&(t.text.className=n)}function _(e){P(e),e.line.wrapClass?F(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function R(e,t,n,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=F(t);t.gutterBackground=Ri("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var i=F(t),l=t.gutter=Ri("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(l),i.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(Ri("div",S(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var a=0;a<e.options.gutters.length;++a){var s=e.options.gutters[a],u=o.hasOwnProperty(s)&&o[s];u&&l.appendChild(Ri("div",[u],"CodeMirror-gutter-elt","left: "+r.gutterLeft[s]+"px; width: "+r.gutterWidth[s]+"px"))}}}function q(e,t,n){t.alignable&&(t.alignable=null);for(var r,i=t.node.firstChild;i;i=r){var r=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}G(e,t,n)}function U(e,t,n,r){var i=B(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),_(t),R(e,t,n,r),G(e,t,r),t.node}function G(e,t,n){if(j(e,t.line,t,n,!0),t.rest)for(var r=0;r<t.rest.length;r++)j(e,t.rest[r],t,n,!1)}function j(e,t,n,r,i){if(t.widgets)for(var o=F(n),l=0,a=t.widgets;l<a.length;++l){var s=a[l],u=Ri("div",[s.node],"CodeMirror-linewidget");s.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),$(s,u,n,r),e.display.input.setUneditable(u),i&&s.above?o.insertBefore(u,n.gutter||n.text):o.appendChild(u),Si(s,"redraw")}}function $(e,t,n,r){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var i=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(i-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function V(e){return Wo(e.line,e.ch)}function K(e,t){return Io(e,t)<0?t:e}function X(e,t){return Io(e,t)<0?e:t}function Y(e){e.state.focused||(e.display.input.focus(),mn(e))}function Z(e){return e.options.readOnly||e.doc.cantEdit}function Q(e,t,n,r,i){var o=e.doc;e.display.shift=!1,r||(r=o.sel);var l=e.state.pasteIncoming||"paste"==i,a=o.splitLines(t),s=null;if(l&&r.ranges.length>1)if(Fo&&Fo.join("\n")==t){if(r.ranges.length%Fo.length==0){s=[];for(var u=0;u<Fo.length;u++)s.push(o.splitLines(Fo[u]))}}else a.length==r.ranges.length&&(s=Ei(a,function(e){return[e]}));for(var u=r.ranges.length-1;u>=0;u--){var c=r.ranges[u],h=c.from(),d=c.to();c.empty()&&(n&&n>0?h=Wo(h.line,h.ch-n):e.state.overwrite&&!l&&(d=Wo(d.line,Math.min(Yr(o,d.line).text.length,d.ch+Hi(a).length))));var f=e.curOp.updateInput,p={from:h,to:d,text:s?s[u%s.length]:a,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};Ln(e.doc,p),Si(e,"inputRead",e,p)}t&&!l&&ee(e,t),Pn(e),e.curOp.updateInput=f,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e,t){var n=e.clipboardData&&e.clipboardData.getData("text/plain");return n?(e.preventDefault(),Z(t)||t.options.disableInput||Nt(t,function(){Q(t,n,0,null,"paste")}),!0):void 0}function ee(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(!(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)){var o=e.getModeAt(i.head),l=!1;if(o.electricChars){for(var a=0;a<o.electricChars.length;a++)if(t.indexOf(o.electricChars.charAt(a))>-1){l=zn(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Yr(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=zn(e,i.head.line,"smart"));l&&Si(e,"electricInput",e,i.head.line)}}}function te(e){for(var t=[],n=[],r=0;r<e.doc.sel.ranges.length;r++){var i=e.doc.sel.ranges[r].head.line,o={anchor:Wo(i,0),head:Wo(i+1,0)};n.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:n}}function ne(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function re(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Ai,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null}function ie(){var e=Ri("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=Ri("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return yo?e.style.width="1000px":e.setAttribute("wrap","off"),Lo&&(e.style.border="1px solid black"),ne(e),t}function oe(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Ai,this.gracePeriod=!1}function le(e,t){var n=Qe(e,t.line);if(!n||n.hidden)return null;var r=Yr(e.doc,t.line),i=Xe(n,r,t.line),o=ri(r),l="left";if(o){var a=so(o,t.ch);l=a%2?"right":"left"}var s=tt(i.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function ae(e,t){return t&&(e.bad=!0),e}function se(e,t,n){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[n],!r)return ae(e.clipPos(Wo(e.display.viewTo-1)),!0);t=null,n=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==r)return ue(o,t,n)}}function ue(e,t,n){function r(t,n,r){for(var i=-1;i<(c?c.length:0);i++)for(var o=0>i?u.map:c[i],l=0;l<o.length;l+=3){var a=o[l+2];if(a==t||a==n){var s=ei(0>i?e.line:e.rest[i]),h=o[l]+r;return(0>r||a!=t)&&(h=o[l+(r?1:0)]),Wo(s,h)}}}var i=e.text.firstChild,o=!1;if(!t||!Gl(i,t))return ae(Wo(ei(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[n],n=0,!t)){var l=e.rest?Hi(e.rest):e.line;return ae(Wo(ei(l),l.text.length),o)}var a=3==t.nodeType?t:null,s=t;for(a||1!=t.childNodes.length||3!=t.firstChild.nodeType||(a=t.firstChild,n&&(n=a.nodeValue.length));s.parentNode!=i;)s=s.parentNode;var u=e.measure,c=u.maps,h=r(a,s,n);if(h)return ae(h,o);for(var d=s.nextSibling,f=a?a.nodeValue.length-n:0;d;d=d.nextSibling){if(h=r(d,d.firstChild,0))return ae(Wo(h.line,h.ch-f),o);f+=d.textContent.length}for(var p=s.previousSibling,f=n;p;p=p.previousSibling){if(h=r(p,p.firstChild,-1))return ae(Wo(h.line,h.ch+f),o);f+=d.textContent.length}}function ce(e,t,n,r,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(null!=n)return""==n&&(n=t.textContent.replace(/\u200b/g,"")),void(a+=n);var c,h=t.getAttribute("cm-marker");if(h){var d=e.findMarks(Wo(r,0),Wo(i+1,0),o(+h));return void(d.length&&(c=d[0].find())&&(a+=Zr(e.doc,c.from,c.to).join(u)))}if("false"==t.getAttribute("contenteditable"))return;for(var f=0;f<t.childNodes.length;f++)l(t.childNodes[f]);/^(pre|div|p)$/i.test(t.nodeName)&&(s=!0)}else if(3==t.nodeType){var p=t.nodeValue;if(!p)return;s&&(a+=u,s=!1),a+=p}}for(var a="",s=!1,u=e.doc.lineSeparator();l(t),t!=n;)t=t.nextSibling;return a}function he(e,t){this.ranges=e,this.primIndex=t}function de(e,t){this.anchor=e,this.head=t}function fe(e,t){var n=e[t];e.sort(function(e,t){return Io(e.from(),t.from())}),t=Oi(e,n);for(var r=1;r<e.length;r++){var i=e[r],o=e[r-1];if(Io(o.to(),i.from())>=0){var l=X(o.from(),i.from()),a=K(o.to(),i.to()),s=o.empty()?i.from()==i.head:o.from()==o.head;t>=r&&--t,e.splice(--r,2,new de(s?a:l,s?l:a))}}return new he(e,t)}function pe(e,t){return new he([new de(e,t||e)],0)}function ge(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function me(e,t){if(t.line<e.first)return Wo(e.first,0);var n=e.first+e.size-1;return t.line>n?Wo(n,Yr(e,n).text.length):ve(t,Yr(e,t.line).text.length)}function ve(e,t){var n=e.ch;return null==n||n>t?Wo(e.line,t):0>n?Wo(e.line,0):e}function ye(e,t){return t>=e.first&&t<e.first+e.size}function be(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=me(e,t[r]);return n}function xe(e,t,n,r){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(r){var o=Io(n,i)<0;o!=Io(r,i)<0?(i=n,n=r):o!=Io(n,r)<0&&(n=r)}return new de(i,n)}return new de(r||n,n)}function we(e,t,n,r){Te(e,new he([xe(e,e.sel.primary(),t,n)],0),r)}function Ce(e,t,n){for(var r=[],i=0;i<e.sel.ranges.length;i++)r[i]=xe(e,e.sel.ranges[i],t[i],null);var o=fe(r,e.sel.primIndex);Te(e,o,n)}function Se(e,t,n,r){var i=e.sel.ranges.slice(0);i[t]=n,Te(e,fe(i,e.sel.primIndex),r)}function ke(e,t,n,r){Te(e,pe(t,n),r)}function Le(e,t){var n={ranges:t.ranges,update:function(t){this.ranges=[];for(var n=0;n<t.length;n++)this.ranges[n]=new de(me(e,t[n].anchor),me(e,t[n].head))}};return Al(e,"beforeSelectionChange",e,n),e.cm&&Al(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?fe(n.ranges,n.ranges.length-1):t}function Me(e,t,n){var r=e.history.done,i=Hi(r);i&&i.ranges?(r[r.length-1]=t,Ne(e,t,n)):Te(e,t,n)}function Te(e,t,n){Ne(e,t,n),ci(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function Ne(e,t,n){(Ti(e,"beforeSelectionChange")||e.cm&&Ti(e.cm,"beforeSelectionChange"))&&(t=Le(e,t));var r=n&&n.bias||(Io(t.primary().head,e.sel.primary().head)<0?-1:1);
8
+ Ae(e,He(e,t,r,!0)),n&&n.scroll===!1||!e.cm||Pn(e.cm)}function Ae(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Mi(e.cm)),Si(e,"cursorActivity",e))}function De(e){Ae(e,He(e,e.sel,null,!1),El)}function He(e,t,n,r){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],a=Oe(e,l.anchor,n,r),s=Oe(e,l.head,n,r);(i||a!=l.anchor||s!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new de(a,s))}return i?fe(i,t.primIndex):t}function Oe(e,t,n,r){var i=!1,o=t,l=n||1;e.cantEdit=!1;e:for(;;){var a=Yr(e,o.line);if(a.markedSpans)for(var s=0;s<a.markedSpans.length;++s){var u=a.markedSpans[s],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(r&&(Al(c,"beforeCursorEnter"),c.explicitlyCleared)){if(a.markedSpans){--s;continue}break}if(!c.atomic)continue;var h=c.find(0>l?-1:1);if(0==Io(h,o)&&(h.ch+=l,h.ch<0?h=h.line>e.first?me(e,Wo(h.line-1)):null:h.ch>a.text.length&&(h=h.line<e.first+e.size-1?Wo(h.line+1,0):null),!h)){if(i)return r?(e.cantEdit=!0,Wo(e.first,0)):Oe(e,t,n,!0);i=!0,h=t,l=-l}o=h;continue e}}return o}}function Ee(e){e.display.input.showSelection(e.display.input.prepareSelection())}function We(e,t){for(var n=e.doc,r={},i=r.cursors=document.createDocumentFragment(),o=r.selection=document.createDocumentFragment(),l=0;l<n.sel.ranges.length;l++)if(t!==!1||l!=n.sel.primIndex){var a=n.sel.ranges[l],s=a.empty();(s||e.options.showCursorWhenSelecting)&&Ie(e,a.head,i),s||Fe(e,a,o)}return r}function Ie(e,t,n){var r=dt(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),i=n.appendChild(Ri("div"," ","CodeMirror-cursor"));if(i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var o=n.appendChild(Ri("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=r.other.left+"px",o.style.top=r.other.top+"px",o.style.height=.85*(r.other.bottom-r.other.top)+"px"}}function Fe(e,t,n){function r(e,t,n,r){0>t&&(t=0),t=Math.round(t),r=Math.round(r),a.appendChild(Ri("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==n?c-e:n)+"px; height: "+(r-t)+"px"))}function i(t,n,i){function o(n,r){return ht(e,Wo(t,n),"div",h,r)}var a,s,h=Yr(l,t),d=h.text.length;return Ji(ri(h),n||0,null==i?d:i,function(e,t,l){var h,f,p,g=o(e,"left");if(e==t)h=g,f=p=g.left;else{if(h=o(t-1,"right"),"rtl"==l){var m=g;g=h,h=m}f=g.left,p=h.right}null==n&&0==e&&(f=u),h.top-g.top>3&&(r(f,g.top,null,g.bottom),f=u,g.bottom<h.top&&r(f,g.bottom,null,h.top)),null==i&&t==d&&(p=c),(!a||g.top<a.top||g.top==a.top&&g.left<a.left)&&(a=g),(!s||h.bottom>s.bottom||h.bottom==s.bottom&&h.right>s.right)&&(s=h),u+1>f&&(f=u),r(f,h.top,p-f,h.bottom)}),{start:a,end:s}}var o=e.display,l=e.doc,a=document.createDocumentFragment(),s=Ge(e.display),u=s.left,c=Math.max(o.sizerWidth,$e(e)-o.sizer.offsetLeft)-s.right,h=t.from(),d=t.to();if(h.line==d.line)i(h.line,h.ch,d.ch);else{var f=Yr(l,h.line),p=Yr(l,d.line),g=vr(f)==vr(p),m=i(h.line,h.ch,g?f.text.length+1:null).end,v=i(d.line,g?0:null,d.ch).start;g&&(m.top<v.top-2?(r(m.right,m.top,null,m.bottom),r(u,v.top,v.left,v.bottom)):r(m.right,m.top,v.left-m.right,m.bottom)),m.bottom<v.top&&r(u,m.bottom,null,v.top)}n.appendChild(a)}function Pe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Be(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Pi(ze,e))}function ze(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var n=+new Date+e.options.workTime,r=il(t.mode,Re(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,a=o.text.length>e.options.maxHighlightLength,s=Er(e,o,a?il(t.mode,r):r,!0);o.styles=s.styles;var u=o.styleClasses,c=s.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),d=0;!h&&d<l.length;++d)h=l[d]!=o.styles[d];h&&i.push(t.frontier),o.stateAfter=a?r:il(t.mode,r)}else o.text.length<=e.options.maxHighlightLength&&Ir(e,o.text,r),o.stateAfter=t.frontier%5==0?il(t.mode,r):null;return++t.frontier,+new Date>n?(Be(e,e.options.workDelay),!0):void 0}),i.length&&Nt(e,function(){for(var t=0;t<i.length;t++)It(e,i[t],"text")})}}function _e(e,t,n){for(var r,i,o=e.doc,l=n?-1:t-(e.doc.mode.innerMode?1e3:100),a=t;a>l;--a){if(a<=o.first)return o.first;var s=Yr(o,a-1);if(s.stateAfter&&(!n||a<=o.frontier))return a;var u=Fl(s.text,null,e.options.tabSize);(null==i||r>u)&&(i=a-1,r=u)}return i}function Re(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return!0;var o=_e(e,t,n),l=o>r.first&&Yr(r,o-1).stateAfter;return l=l?il(r.mode,l):ol(r.mode),r.iter(o,t,function(n){Ir(e,n.text,l);var a=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;n.stateAfter=a?il(r.mode,l):null,++o}),n&&(r.frontier=o),l}function qe(e){return e.lineSpace.offsetTop}function Ue(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Ge(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Ui(e.measure,Ri("pre","x")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return isNaN(r.left)||isNaN(r.right)||(e.cachedPaddingH=r),r}function je(e){return Hl-e.display.nativeBarWidth}function $e(e){return e.display.scroller.clientWidth-je(e)-e.display.barWidth}function Ve(e){return e.display.scroller.clientHeight-je(e)-e.display.barHeight}function Ke(e,t,n){var r=e.options.lineWrapping,i=r&&$e(e);if(!t.measure.heights||r&&t.measure.width!=i){var o=t.measure.heights=[];if(r){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),a=0;a<l.length-1;a++){var s=l[a],u=l[a+1];Math.abs(s.bottom-u.bottom)>2&&o.push((s.bottom+u.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Xe(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var r=0;r<e.rest.length;r++)if(ei(e.rest[r])>n)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function Ye(e,t){t=vr(t);var n=ei(t),r=e.display.externalMeasured=new Ot(e.doc,t,n);r.lineN=n;var i=r.built=Pr(e,r);return r.text=i.pre,Ui(e.display.lineMeasure,i.pre),r}function Ze(e,t,n,r){return et(e,Je(e,t),n,r)}function Qe(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Pt(e,t)];var n=e.display.externalMeasured;return n&&t>=n.lineN&&t<n.lineN+n.size?n:void 0}function Je(e,t){var n=ei(t),r=Qe(e,n);r&&!r.text?r=null:r&&r.changes&&(I(e,r,n,E(e)),e.curOp.forceUpdate=!0),r||(r=Ye(e,t));var i=Xe(r,t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function et(e,t,n,r,i){t.before&&(n=-1);var o,l=n+(r||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Ke(e,t.view,t.rect),t.hasHeights=!0),o=nt(e,t,n,r),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function tt(e,t,n){for(var r,i,o,l,a=0;a<e.length;a+=3){var s=e[a],u=e[a+1];if(s>t?(i=0,o=1,l="left"):u>t?(i=t-s,o=i+1):(a==e.length-3||t==u&&e[a+3]>t)&&(o=u-s,i=o-1,t>=u&&(l="right")),null!=i){if(r=e[a+2],s==u&&n==(r.insertLeft?"left":"right")&&(l=n),"left"==n&&0==i)for(;a&&e[a-2]==e[a-3]&&e[a-1].insertLeft;)r=e[(a-=3)+2],l="left";if("right"==n&&i==u-s)for(;a<e.length-3&&e[a+3]==e[a+4]&&!e[a+5].insertLeft;)r=e[(a+=3)+2],l="right";break}}return{node:r,start:i,end:o,collapse:l,coverStart:s,coverEnd:u}}function nt(e,t,n,r){var i,o=tt(t.map,n,r),l=o.node,a=o.start,s=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;4>c;c++){for(;a&&_i(t.line.text.charAt(o.coverStart+a));)--a;for(;o.coverStart+s<o.coverEnd&&_i(t.line.text.charAt(o.coverStart+s));)++s;if(mo&&9>vo&&0==a&&s==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(mo&&e.options.lineWrapping){var h=_l(l,a,s).getClientRects();i=h.length?h["right"==r?h.length-1:0]:_o}else i=_l(l,a,s).getBoundingClientRect()||_o;if(i.left||i.right||0==a)break;s=a,a-=1,u="right"}mo&&11>vo&&(i=rt(e.display.measure,i))}else{a>0&&(u=r="right");var h;i=e.options.lineWrapping&&(h=l.getClientRects()).length>1?h["right"==r?h.length-1:0]:l.getBoundingClientRect()}if(mo&&9>vo&&!a&&(!i||!i.left&&!i.right)){var d=l.parentNode.getClientRects()[0];i=d?{left:d.left,right:d.left+yt(e.display),top:d.top,bottom:d.bottom}:_o}for(var f=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(f+p)/2,m=t.view.measure.heights,c=0;c<m.length-1&&!(g<m[c]);c++);var v=c?m[c-1]:0,y=m[c],b={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:v,bottom:y};return i.left||i.right||(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=f,b.rbottom=p),b}function rt(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Qi(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}function it(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ot(e){e.display.externalMeasure=null,qi(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)it(e.display.view[t])}function lt(e){ot(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function at(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function st(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function ut(e,t,n,r){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=kr(t.widgets[i]);n.top+=o,n.bottom+=o}if("line"==r)return n;r||(r="local");var l=ni(t);if("local"==r?l+=qe(e.display):l-=e.display.viewOffset,"page"==r||"window"==r){var a=e.display.lineSpace.getBoundingClientRect();l+=a.top+("window"==r?0:st());var s=a.left+("window"==r?0:at());n.left+=s,n.right+=s}return n.top+=l,n.bottom+=l,n}function ct(e,t,n){if("div"==n)return t;var r=t.left,i=t.top;if("page"==n)r-=at(),i-=st();else if("local"==n||!n){var o=e.display.sizer.getBoundingClientRect();r+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:r-l.left,top:i-l.top}}function ht(e,t,n,r,i){return r||(r=Yr(e.doc,t.line)),ut(e,r,Ze(e,r,t.ch,i),n)}function dt(e,t,n,r,i,o){function l(t,l){var a=et(e,i,t,l?"right":"left",o);return l?a.left=a.right:a.right=a.left,ut(e,r,a,n)}function a(e,t){var n=s[t],r=n.level%2;return e==eo(n)&&t&&n.level<s[t-1].level?(n=s[--t],e=to(n)-(n.level%2?0:1),r=!0):e==to(n)&&t<s.length-1&&n.level<s[t+1].level&&(n=s[++t],e=eo(n)-n.level%2,r=!1),r&&e==n.to&&e>n.from?l(e-1):l(e,r)}r=r||Yr(e.doc,t.line),i||(i=Je(e,r));var s=ri(r),u=t.ch;if(!s)return l(u);var c=so(s,u),h=a(u,c);return null!=na&&(h.other=a(u,na)),h}function ft(e,t){var n=0,t=me(e.doc,t);e.options.lineWrapping||(n=yt(e.display)*t.ch);var r=Yr(e.doc,t.line),i=ni(r)+qe(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function pt(e,t,n,r){var i=Wo(e,t);return i.xRel=r,n&&(i.outside=!0),i}function gt(e,t,n){var r=e.doc;if(n+=e.display.viewOffset,0>n)return pt(r.first,0,!0,-1);var i=ti(r,n),o=r.first+r.size-1;if(i>o)return pt(r.first+r.size-1,Yr(r,o).text.length,!0,1);0>t&&(t=0);for(var l=Yr(r,i);;){var a=mt(e,l,i,t,n),s=gr(l),u=s&&s.find(0,!0);if(!s||!(a.ch>u.from.ch||a.ch==u.from.ch&&a.xRel>0))return a;i=ei(l=u.to.line)}}function mt(e,t,n,r,i){function o(r){var i=dt(e,Wo(n,r),"line",t,u);return a=!0,l>i.bottom?i.left-s:l<i.top?i.left+s:(a=!1,i.left)}var l=i-ni(t),a=!1,s=2*e.display.wrapper.clientWidth,u=Je(e,t),c=ri(t),h=t.text.length,d=no(t),f=ro(t),p=o(d),g=a,m=o(f),v=a;if(r>m)return pt(n,f,v,1);for(;;){if(c?f==d||f==co(t,d,1):1>=f-d){for(var y=p>r||m-r>=r-p?d:f,b=r-(y==d?p:m);_i(t.text.charAt(y));)++y;var x=pt(n,y,y==d?g:v,-1>b?-1:b>1?1:0);return x}var w=Math.ceil(h/2),C=d+w;if(c){C=d;for(var S=0;w>S;++S)C=co(t,C,1)}var k=o(C);k>r?(f=C,m=k,(v=a)&&(m+=1e3),h=w):(d=C,p=k,g=a,h-=w)}}function vt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Po){Po=Ri("pre");for(var t=0;49>t;++t)Po.appendChild(document.createTextNode("x")),Po.appendChild(Ri("br"));Po.appendChild(document.createTextNode("x"))}Ui(e.measure,Po);var n=Po.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),qi(e.measure),n||1}function yt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=Ri("span","xxxxxxxxxx"),n=Ri("pre",[t]);Ui(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function bt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++qo},Ro?Ro.ops.push(e.curOp):e.curOp.ownsGroup=Ro={ops:[e.curOp],delayedCallbacks:[]}}function xt(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n].call(null);for(var r=0;r<e.ops.length;r++){var i=e.ops[r];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(n<t.length)}function wt(e){var t=e.curOp,n=t.ownsGroup;if(n)try{xt(n)}finally{Ro=null;for(var r=0;r<n.ops.length;r++)n.ops[r].cm.curOp=null;Ct(n)}}function Ct(e){for(var t=e.ops,n=0;n<t.length;n++)St(t[n]);for(var n=0;n<t.length;n++)kt(t[n]);for(var n=0;n<t.length;n++)Lt(t[n]);for(var n=0;n<t.length;n++)Mt(t[n]);for(var n=0;n<t.length;n++)Tt(t[n])}function St(e){var t=e.cm,n=t.display;M(t),e.updateMaxLine&&d(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new L(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function kt(e){e.updatedDisplay=e.mustUpdate&&T(e.cm,e.update)}function Lt(e){var t=e.cm,n=t.display;e.updatedDisplay&&H(t),e.barMeasure=p(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Ze(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+je(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-$e(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function Mt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&rn(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.preparedSelection&&t.display.input.showSelection(e.preparedSelection),e.updatedDisplay&&D(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&y(t,e.barMeasure),e.selectionChanged&&Pe(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),e.focus&&e.focus==Gi()&&Y(e.cm)}function Tt(e){var t=e.cm,n=t.display,r=t.doc;if(e.updatedDisplay&&N(t,e.update),null==n.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(n.wheelStartX=n.wheelStartY=null),null==e.scrollTop||n.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(r.scrollTop=Math.max(0,Math.min(n.scroller.scrollHeight-n.scroller.clientHeight,e.scrollTop)),n.scrollbars.setScrollTop(r.scrollTop),n.scroller.scrollTop=r.scrollTop),null==e.scrollLeft||n.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(r.scrollLeft=Math.max(0,Math.min(n.scroller.scrollWidth-$e(t),e.scrollLeft)),n.scrollbars.setScrollLeft(r.scrollLeft),n.scroller.scrollLeft=r.scrollLeft,w(t)),e.scrollToPos){var i=En(t,me(r,e.scrollToPos.from),me(r,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&On(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var a=0;a<o.length;++a)o[a].lines.length||Al(o[a],"hide");if(l)for(var a=0;a<l.length;++a)l[a].lines.length&&Al(l[a],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Al(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Nt(e,t){if(e.curOp)return t();bt(e);try{return t()}finally{wt(e)}}function At(e,t){return function(){if(e.curOp)return t.apply(e,arguments);bt(e);try{return t.apply(e,arguments)}finally{wt(e)}}}function Dt(e){return function(){if(this.curOp)return e.apply(this,arguments);bt(this);try{return e.apply(this,arguments)}finally{wt(this)}}}function Ht(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);bt(t);try{return e.apply(this,arguments)}finally{wt(t)}}}function Ot(e,t,n){this.line=t,this.rest=yr(t),this.size=this.rest?ei(Hi(this.rest))-n+1:1,this.node=this.text=null,this.hidden=wr(e,t)}function Et(e,t,n){for(var r,i=[],o=t;n>o;o=r){var l=new Ot(e.doc,Yr(e.doc,o),o);r=o+l.size,i.push(l)}return i}function Wt(e,t,n,r){null==t&&(t=e.doc.first),null==n&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;if(r&&n<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Eo&&br(e.doc,t)<i.viewTo&&Ft(e);else if(n<=i.viewFrom)Eo&&xr(e.doc,n+r)>i.viewFrom?Ft(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)Ft(e);else if(t<=i.viewFrom){var o=Bt(e,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):Ft(e)}else if(n>=i.viewTo){var o=Bt(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):Ft(e)}else{var l=Bt(e,t,t,-1),a=Bt(e,n,n+r,1);l&&a?(i.view=i.view.slice(0,l.index).concat(Et(e,l.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=r):Ft(e)}var s=i.externalMeasured;s&&(n<s.lineN?s.lineN+=r:t<s.lineN+s.size&&(i.externalMeasured=null))}function It(e,t,n){e.curOp.viewChanged=!0;var r=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(r.externalMeasured=null),!(t<r.viewFrom||t>=r.viewTo)){var o=r.view[Pt(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==Oi(l,n)&&l.push(n)}}}function Ft(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Pt(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var n=e.display.view,r=0;r<n.length;r++)if(t-=n[r].size,0>t)return r}function Bt(e,t,n,r){var i,o=Pt(e,t),l=e.display.view;if(!Eo||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var a=0,s=e.display.viewFrom;o>a;a++)s+=l[a].size;if(s!=t){if(r>0){if(o==l.length-1)return null;i=s+l[o].size-t,o++}else i=s-t;t+=i,n+=i}for(;br(e.doc,n)!=n;){if(o==(0>r?0:l.length-1))return null;n+=r*l[o-(0>r?1:0)].size,o+=r}return{index:o,lineN:n}}function zt(e,t,n){var r=e.display,i=r.view;0==i.length||t>=r.viewTo||n<=r.viewFrom?(r.view=Et(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=Et(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Pt(e,t))),r.viewFrom=t,r.viewTo<n?r.view=r.view.concat(Et(e,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,Pt(e,n)))),r.viewTo=n}function _t(e){for(var t=e.display.view,n=0,r=0;r<t.length;r++){var i=t[r];i.hidden||i.node&&!i.changes||++n}return n}function Rt(e){function t(){i.activeTouch&&(o=setTimeout(function(){i.activeTouch=null},1e3),l=i.activeTouch,l.end=+new Date)}function n(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function r(e,t){if(null==t.left)return!0;var n=t.left-e.left,r=t.top-e.top;return n*n+r*r>400}var i=e.display;Ml(i.scroller,"mousedown",At(e,$t)),mo&&11>vo?Ml(i.scroller,"dblclick",At(e,function(t){if(!Li(e,t)){var n=jt(e,t);if(n&&!Zt(e,t)&&!Gt(e.display,t)){Sl(t);var r=e.findWordAt(n);we(e.doc,r.anchor,r.head)}}})):Ml(i.scroller,"dblclick",function(t){Li(e,t)||Sl(t)}),Ho||Ml(i.scroller,"contextmenu",function(t){yn(e,t)});var o,l={end:0};Ml(i.scroller,"touchstart",function(e){if(!n(e)){clearTimeout(o);var t=+new Date;i.activeTouch={start:t,moved:!1,prev:t-l.end<=300?l:null},1==e.touches.length&&(i.activeTouch.left=e.touches[0].pageX,i.activeTouch.top=e.touches[0].pageY)}}),Ml(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Ml(i.scroller,"touchend",function(n){var o=i.activeTouch;if(o&&!Gt(i,n)&&null!=o.left&&!o.moved&&new Date-o.start<300){var l,a=e.coordsChar(i.activeTouch,"page");l=!o.prev||r(o,o.prev)?new de(a,a):!o.prev.prev||r(o,o.prev.prev)?e.findWordAt(a):new de(Wo(a.line,0),me(e.doc,Wo(a.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),Sl(n)}t()}),Ml(i.scroller,"touchcancel",t),Ml(i.scroller,"scroll",function(){i.scroller.clientHeight&&(nn(e,i.scroller.scrollTop),rn(e,i.scroller.scrollLeft,!0),Al(e,"scroll",e))}),Ml(i.scroller,"mousewheel",function(t){on(e,t)}),Ml(i.scroller,"DOMMouseScroll",function(t){on(e,t)}),Ml(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){Li(e,t)||Ll(t)},over:function(t){Li(e,t)||(en(e,t),Ll(t))},start:function(t){Jt(e,t)},drop:At(e,Qt),leave:function(){tn(e)}};var a=i.input.getField();Ml(a,"keyup",function(t){fn.call(e,t)}),Ml(a,"keydown",At(e,hn)),Ml(a,"keypress",At(e,pn)),Ml(a,"focus",Pi(mn,e)),Ml(a,"blur",Pi(vn,e))}function qt(t,n,r){var i=r&&r!=e.Init;if(!n!=!i){var o=t.display.dragFunctions,l=n?Ml:Nl;l(t.display.scroller,"dragstart",o.start),l(t.display.scroller,"dragenter",o.enter),l(t.display.scroller,"dragover",o.over),l(t.display.scroller,"dragleave",o.leave),l(t.display.scroller,"drop",o.drop)}}function Ut(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Gt(e,t){for(var n=xi(t);n!=e.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==e.sizer&&n!=e.mover)return!0}function jt(e,t,n,r){var i=e.display;if(!n&&"true"==xi(t).getAttribute("cm-not-content"))return null;var o,l,a=i.lineSpace.getBoundingClientRect();try{o=t.clientX-a.left,l=t.clientY-a.top}catch(t){return null}var s,u=gt(e,o,l);if(r&&1==u.xRel&&(s=Yr(e.doc,u.line).text).length==u.ch){var c=Fl(s,s.length,e.options.tabSize)-s.length;u=Wo(u.line,Math.max(0,Math.round((o-Ge(e.display).left)/yt(e.display))-c))}return u}function $t(e){var t=this,n=t.display;if(!(n.activeTouch&&n.input.supportsTouch()||Li(t,e))){if(n.shift=e.shiftKey,Gt(n,e))return void(yo||(n.scroller.draggable=!1,setTimeout(function(){n.scroller.draggable=!0},100)));if(!Zt(t,e)){var r=jt(t,e);switch(window.focus(),wi(e)){case 1:t.state.selectingText?t.state.selectingText(e):r?Vt(t,e,r):xi(e)==n.scroller&&Sl(e);break;case 2:yo&&(t.state.lastMiddleDown=+new Date),r&&we(t.doc,r),setTimeout(function(){n.input.focus()},20),Sl(e);break;case 3:Ho?yn(t,e):gn(t)}}}}function Vt(e,t,n){mo?setTimeout(Pi(Y,e),0):e.curOp.focus=Gi();var r,i=+new Date;zo&&zo.time>i-400&&0==Io(zo.pos,n)?r="triple":Bo&&Bo.time>i-400&&0==Io(Bo.pos,n)?(r="double",zo={time:i,pos:n}):(r="single",Bo={time:i,pos:n});var o,l=e.doc.sel,a=To?t.metaKey:t.ctrlKey;e.options.dragDrop&&Yl&&!Z(e)&&"single"==r&&(o=l.contains(n))>-1&&(Io((o=l.ranges[o]).from(),n)<0||n.xRel>0)&&(Io(o.to(),n)>0||n.xRel<0)?Kt(e,t,n,a):Xt(e,t,n,r,a)}function Kt(e,t,n,r){var i=e.display,o=+new Date,l=At(e,function(a){yo&&(i.scroller.draggable=!1),e.state.draggingText=!1,Nl(document,"mouseup",l),Nl(i.scroller,"drop",l),Math.abs(t.clientX-a.clientX)+Math.abs(t.clientY-a.clientY)<10&&(Sl(a),!r&&+new Date-200<o&&we(e.doc,n),yo||mo&&9==vo?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())});yo&&(i.scroller.draggable=!0),e.state.draggingText=l,i.scroller.dragDrop&&i.scroller.dragDrop(),Ml(document,"mouseup",l),Ml(i.scroller,"drop",l)}function Xt(e,t,n,r,i){function o(t){if(0!=Io(m,t))if(m=t,"rect"==r){for(var i=[],o=e.options.tabSize,l=Fl(Yr(u,n.line).text,n.ch,o),a=Fl(Yr(u,t.line).text,t.ch,o),s=Math.min(l,a),f=Math.max(l,a),p=Math.min(n.line,t.line),g=Math.min(e.lastLine(),Math.max(n.line,t.line));g>=p;p++){var v=Yr(u,p).text,y=Pl(v,s,o);s==f?i.push(new de(Wo(p,y),Wo(p,y))):v.length>y&&i.push(new de(Wo(p,y),Wo(p,Pl(v,f,o))))}i.length||i.push(new de(n,n)),Te(u,fe(d.ranges.slice(0,h).concat(i),h),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,x=b.anchor,w=t;if("single"!=r){if("double"==r)var C=e.findWordAt(t);else var C=new de(Wo(t.line,0),me(u,Wo(t.line+1,0)));Io(C.anchor,x)>0?(w=C.head,x=X(b.from(),C.anchor)):(w=C.anchor,x=K(b.to(),C.head))}var i=d.ranges.slice(0);i[h]=new de(me(u,x),w),Te(u,fe(i,h),Wl)}}function l(t){var n=++y,i=jt(e,t,!0,"rect"==r);if(i)if(0!=Io(i,m)){e.curOp.focus=Gi(),o(i);var a=x(s,u);(i.line>=a.to||i.line<a.from)&&setTimeout(At(e,function(){y==n&&l(t)}),150)}else{var c=t.clientY<v.top?-20:t.clientY>v.bottom?20:0;c&&setTimeout(At(e,function(){y==n&&(s.scroller.scrollTop+=c,l(t))}),50)}}function a(t){e.state.selectingText=!1,y=1/0,Sl(t),s.input.focus(),Nl(document,"mousemove",b),Nl(document,"mouseup",w),u.history.lastSelOrigin=null}var s=e.display,u=e.doc;Sl(t);var c,h,d=u.sel,f=d.ranges;if(i&&!t.shiftKey?(h=u.sel.contains(n),c=h>-1?f[h]:new de(n,n)):(c=u.sel.primary(),h=u.sel.primIndex),t.altKey)r="rect",i||(c=new de(n,n)),n=jt(e,t,!0,!0),h=-1;else if("double"==r){var p=e.findWordAt(n);c=e.display.shift||u.extend?xe(u,c,p.anchor,p.head):p}else if("triple"==r){var g=new de(Wo(n.line,0),me(u,Wo(n.line+1,0)));c=e.display.shift||u.extend?xe(u,c,g.anchor,g.head):g}else c=xe(u,c,n);i?-1==h?(h=f.length,Te(u,fe(f.concat([c]),h),{scroll:!1,origin:"*mouse"})):f.length>1&&f[h].empty()&&"single"==r&&!t.shiftKey?(Te(u,fe(f.slice(0,h).concat(f.slice(h+1)),0),{scroll:!1,origin:"*mouse"}),d=u.sel):Se(u,h,c,Wl):(h=0,Te(u,new he([c],0),Wl),d=u.sel);var m=n,v=s.wrapper.getBoundingClientRect(),y=0,b=At(e,function(e){wi(e)?l(e):a(e)}),w=At(e,a);e.state.selectingText=w,Ml(document,"mousemove",b),Ml(document,"mouseup",w)}function Yt(e,t,n,r,i){try{var o=t.clientX,l=t.clientY}catch(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Sl(t);var a=e.display,s=a.lineDiv.getBoundingClientRect();if(l>s.bottom||!Ti(e,n))return bi(t);l-=s.top-a.viewOffset;for(var u=0;u<e.options.gutters.length;++u){var c=a.gutters.childNodes[u];if(c&&c.getBoundingClientRect().right>=o){var h=ti(e.doc,l),d=e.options.gutters[u];return i(e,n,e,h,d,t),bi(t)}}}function Zt(e,t){return Yt(e,t,"gutterClick",!0,Si)}function Qt(e){var t=this;if(tn(t),!Li(t,e)&&!Gt(t.display,e)){Sl(e),mo&&(Uo=+new Date);var n=jt(t,e,!0),r=e.dataTransfer.files;if(n&&!Z(t))if(r&&r.length&&window.FileReader&&window.File)for(var i=r.length,o=Array(i),l=0,a=function(e,r){var a=new FileReader;a.onload=At(t,function(){if(o[r]=a.result,++l==i){n=me(t.doc,n);var e={from:n,to:n,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};Ln(t.doc,e),Me(t.doc,pe(n,Xo(e)))}}),a.readAsText(e)},s=0;i>s;++s)a(r[s],s);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(To?e.altKey:e.ctrlKey))var u=t.listSelections();if(Ne(t.doc,pe(n,n)),u)for(var s=0;s<u.length;++s)Hn(t.doc,"",u[s].anchor,u[s].head,"drag");t.replaceSelection(o,"around","paste"),t.display.input.focus()}}catch(e){}}}}function Jt(e,t){if(mo&&(!e.state.draggingText||+new Date-Uo<100))return void Ll(t);if(!Li(e,t)&&!Gt(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!Co)){var n=Ri("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",wo&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),wo&&n.parentNode.removeChild(n)}}function en(e,t){var n=jt(e,t);if(n){var r=document.createDocumentFragment();Ie(e,n,r),e.display.dragCursor||(e.display.dragCursor=Ri("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),Ui(e.display.dragCursor,r)}}function tn(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function nn(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,fo||A(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),fo&&A(e),Be(e,100))}function rn(e,t,n){(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,w(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function on(e,t){var n=$o(t),r=n.x,i=n.y,o=e.display,l=o.scroller;if(r&&l.scrollWidth>l.clientWidth||i&&l.scrollHeight>l.clientHeight){if(i&&To&&yo)e:for(var a=t.target,s=o.view;a!=l;a=a.parentNode)for(var u=0;u<s.length;u++)if(s[u].node==a){e.display.currentWheelTarget=a;break e}if(r&&!fo&&!wo&&null!=jo)return i&&nn(e,Math.max(0,Math.min(l.scrollTop+i*jo,l.scrollHeight-l.clientHeight))),rn(e,Math.max(0,Math.min(l.scrollLeft+r*jo,l.scrollWidth-l.clientWidth))),Sl(t),void(o.wheelStartX=null);if(i&&null!=jo){var c=i*jo,h=e.doc.scrollTop,d=h+o.wrapper.clientHeight;0>c?h=Math.max(0,h+c-50):d=Math.min(e.doc.height,d+c+50),A(e,{top:h,bottom:d})}20>Go&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=r,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,n&&(jo=(jo*Go+n)/(Go+1),++Go)}},200)):(o.wheelDX+=r,o.wheelDY+=i))}}function ln(e,t,n){if("string"==typeof t&&(t=ll[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,i=!1;try{Z(e)&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=Ol}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function an(e,t,n){for(var r=0;r<e.state.keyMaps.length;r++){var i=sl(t,e.state.keyMaps[r],n,e);if(i)return i}return e.options.extraKeys&&sl(t,e.options.extraKeys,n,e)||sl(t,e.options.keyMap,n,e)}function sn(e,t,n,r){var i=e.state.keySeq;if(i){if(ul(t))return"handled";Vo.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=an(e,t,r);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&Si(e,"keyHandled",e,t,n),("handled"==o||"multi"==o)&&(Sl(n),Pe(e)),i&&!o&&/\'$/.test(t)?(Sl(n),!0):!!o}function un(e,t){var n=cl(t,!0);return n?t.shiftKey&&!e.state.keySeq?sn(e,"Shift-"+n,t,function(t){return ln(e,t,!0)})||sn(e,n,t,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?ln(e,t):void 0}):sn(e,n,t,function(t){return ln(e,t)}):!1}function cn(e,t,n){return sn(e,"'"+n+"'",t,function(t){return ln(e,t,!0)})}function hn(e){var t=this;if(t.curOp.focus=Gi(),!Li(t,e)){mo&&11>vo&&27==e.keyCode&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=16==n||e.shiftKey;var r=un(t,e);wo&&(Ko=r?n:null,!r&&88==n&&!Jl&&(To?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=n||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||dn(t)}}function dn(e){function t(e){18!=e.keyCode&&e.altKey||(Vl(n,"CodeMirror-crosshair"),Nl(document,"keyup",t),Nl(document,"mouseover",t))}var n=e.display.lineDiv;Kl(n,"CodeMirror-crosshair"),Ml(document,"keyup",t),Ml(document,"mouseover",t)}function fn(e){16==e.keyCode&&(this.doc.sel.shift=!1),Li(this,e)}function pn(e){var t=this;if(!(Gt(t.display,e)||Li(t,e)||e.ctrlKey&&!e.altKey||To&&e.metaKey)){var n=e.keyCode,r=e.charCode;if(wo&&n==Ko)return Ko=null,
9
+ void Sl(e);if(!wo||e.which&&!(e.which<10)||!un(t,e)){var i=String.fromCharCode(null==r?n:r);cn(t,e,i)||t.display.input.onKeyPress(e)}}}function gn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,vn(e))},100)}function mn(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Al(e,"focus",e),e.state.focused=!0,Kl(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),yo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Pe(e))}function vn(e){e.state.delayingBlurEvent||(e.state.focused&&(Al(e,"blur",e),e.state.focused=!1,Vl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function yn(e,t){Gt(e.display,t)||bn(e,t)||e.display.input.onContextMenu(t)}function bn(e,t){return Ti(e,"gutterContextMenu")?Yt(e,t,"gutterContextMenu",!1,Al):!1}function xn(e,t){if(Io(e,t.from)<0)return e;if(Io(e,t.to)<=0)return Xo(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Xo(t).ch-t.to.ch),Wo(n,r)}function wn(e,t){for(var n=[],r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new de(xn(i.anchor,t),xn(i.head,t)))}return fe(n,e.sel.primIndex)}function Cn(e,t,n){return e.line==t.line?Wo(n.line,e.ch-t.ch+n.ch):Wo(n.line+(e.line-t.line),e.ch)}function Sn(e,t,n){for(var r=[],i=Wo(e.first,0),o=i,l=0;l<t.length;l++){var a=t[l],s=Cn(a.from,i,o),u=Cn(Xo(a),i,o);if(i=a.to,o=u,"around"==n){var c=e.sel.ranges[l],h=Io(c.head,c.anchor)<0;r[l]=new de(h?u:s,h?s:u)}else r[l]=new de(s,s)}return new he(r,e.sel.primIndex)}function kn(e,t,n){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return n&&(r.update=function(t,n,r,i){t&&(this.from=me(e,t)),n&&(this.to=me(e,n)),r&&(this.text=r),void 0!==i&&(this.origin=i)}),Al(e,"beforeChange",e,r),e.cm&&Al(e.cm,"beforeChange",e.cm,r),r.canceled?null:{from:r.from,to:r.to,text:r.text,origin:r.origin}}function Ln(e,t,n){if(e.cm){if(!e.cm.curOp)return At(e.cm,Ln)(e,t,n);if(e.cm.state.suppressEdits)return}if(!(Ti(e,"beforeChange")||e.cm&&Ti(e.cm,"beforeChange"))||(t=kn(e,t,!0))){var r=Oo&&!n&&ar(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)Mn(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text});else Mn(e,t)}}function Mn(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Io(t.from,t.to)){var n=wn(e,t);si(e,t,n,e.cm?e.cm.curOp.id:NaN),An(e,t,n,ir(e,t));var r=[];Kr(e,function(e,n){n||-1!=Oi(r,e.history)||(yi(e.history,t),r.push(e.history)),An(e,t,null,ir(e,t))})}}function Tn(e,t,n){if(!e.cm||!e.cm.state.suppressEdits){for(var r,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,a="undo"==t?i.undone:i.done,s=0;s<l.length&&(r=l[s],n?!r.ranges||r.equals(e.sel):r.ranges);s++);if(s!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;r=l.pop(),r.ranges;){if(hi(r,a),n&&!r.equals(e.sel))return void Te(e,r,{clearRedo:!1});o=r}var u=[];hi(o,a),a.push({changes:u,generation:i.generation}),i.generation=r.generation||++i.maxGeneration;for(var c=Ti(e,"beforeChange")||e.cm&&Ti(e.cm,"beforeChange"),s=r.changes.length-1;s>=0;--s){var h=r.changes[s];if(h.origin=t,c&&!kn(e,h,!1))return void(l.length=0);u.push(oi(e,h));var d=s?wn(e,h):Hi(l);An(e,h,d,lr(e,h)),!s&&e.cm&&e.cm.scrollIntoView({from:h.from,to:Xo(h)});var f=[];Kr(e,function(e,t){t||-1!=Oi(f,e.history)||(yi(e.history,h),f.push(e.history)),An(e,h,null,lr(e,h))})}}}}function Nn(e,t){if(0!=t&&(e.first+=t,e.sel=new he(Ei(e.sel.ranges,function(e){return new de(Wo(e.anchor.line+t,e.anchor.ch),Wo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Wt(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)It(e.cm,r,"gutter")}}function An(e,t,n,r){if(e.cm&&!e.cm.curOp)return At(e.cm,An)(e,t,n,r);if(t.to.line<e.first)return void Nn(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Nn(e,i),t={from:Wo(e.first,0),to:Wo(t.to.line+i,t.to.ch),text:[Hi(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:Wo(o,Yr(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Zr(e,t.from,t.to),n||(n=wn(e,t)),e.cm?Dn(e.cm,t,r):jr(e,t,r),Ne(e,n,El)}}function Dn(e,t,n){var r=e.doc,i=e.display,l=t.from,a=t.to,s=!1,u=l.line;e.options.lineWrapping||(u=ei(vr(Yr(r,l.line))),r.iter(u,a.line+1,function(e){return e==i.maxLine?(s=!0,!0):void 0})),r.sel.contains(t.from,t.to)>-1&&Mi(e),jr(r,t,n,o(e)),e.options.lineWrapping||(r.iter(u,l.line+t.text.length,function(e){var t=h(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),r.frontier=Math.min(r.frontier,l.line),Be(e,400);var c=t.text.length-(a.line-l.line)-1;t.full?Wt(e):l.line!=a.line||1!=t.text.length||Gr(e.doc,t)?Wt(e,l.line,a.line+1,c):It(e,l.line,"text");var d=Ti(e,"changes"),f=Ti(e,"change");if(f||d){var p={from:l,to:a,text:t.text,removed:t.removed,origin:t.origin};f&&Si(e,"change",e,p),d&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Hn(e,t,n,r,i){if(r||(r=n),Io(r,n)<0){var o=r;r=n,n=o}"string"==typeof t&&(t=e.splitLines(t)),Ln(e,{from:n,to:r,text:t,origin:i})}function On(e,t){if(!Li(e,"scrollCursorIntoView")){var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;if(t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!ko){var o=Ri("div","​",null,"position: absolute; top: "+(t.top-n.viewOffset-qe(e.display))+"px; height: "+(t.bottom-t.top+je(e)+n.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function En(e,t,n,r){null==r&&(r=0);for(var i=0;5>i;i++){var o=!1,l=dt(e,t),a=n&&n!=t?dt(e,n):l,s=In(e,Math.min(l.left,a.left),Math.min(l.top,a.top)-r,Math.max(l.left,a.left),Math.max(l.bottom,a.bottom)+r),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=s.scrollTop&&(nn(e,s.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=s.scrollLeft&&(rn(e,s.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Wn(e,t,n,r,i){var o=In(e,t,n,r,i);null!=o.scrollTop&&nn(e,o.scrollTop),null!=o.scrollLeft&&rn(e,o.scrollLeft)}function In(e,t,n,r,i){var o=e.display,l=vt(e.display);0>n&&(n=0);var a=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,s=Ve(e),u={};i-n>s&&(i=n+s);var c=e.doc.height+Ue(o),h=l>n,d=i>c-l;if(a>n)u.scrollTop=h?0:n;else if(i>a+s){var f=Math.min(n,(d?c:i)-s);f!=a&&(u.scrollTop=f)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=$e(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),m=r-t>g;return m&&(r=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(m?0:10)):r>g+p-3&&(u.scrollLeft=r+(m?0:10)-g),u}function Fn(e,t,n){(null!=t||null!=n)&&Bn(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=n&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+n)}function Pn(e){Bn(e);var t=e.getCursor(),n=t,r=t;e.options.lineWrapping||(n=t.ch?Wo(t.line,t.ch-1):t,r=Wo(t.line,t.ch+1)),e.curOp.scrollToPos={from:n,to:r,margin:e.options.cursorScrollMargin,isCursor:!0}}function Bn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=ft(e,t.from),r=ft(e,t.to),i=In(e,Math.min(n.left,r.left),Math.min(n.top,r.top)-t.margin,Math.max(n.right,r.right),Math.max(n.bottom,r.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function zn(e,t,n,r){var i,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=Re(e,t):n="prev");var l=e.options.tabSize,a=Yr(o,t),s=Fl(a.text,null,l);a.stateAfter&&(a.stateAfter=null);var u,c=a.text.match(/^\s*/)[0];if(r||/\S/.test(a.text)){if("smart"==n&&(u=o.mode.indent(i,a.text.slice(c.length),a.text),u==Ol||u>150)){if(!r)return;n="prev"}}else u=0,n="not";"prev"==n?u=t>o.first?Fl(Yr(o,t-1).text,null,l):0:"add"==n?u=s+e.options.indentUnit:"subtract"==n?u=s-e.options.indentUnit:"number"==typeof n&&(u=s+n),u=Math.max(0,u);var h="",d=0;if(e.options.indentWithTabs)for(var f=Math.floor(u/l);f;--f)d+=l,h+=" ";if(u>d&&(h+=Di(u-d)),h!=c)return Hn(o,h,Wo(t,0),Wo(t,c.length),"+input"),a.stateAfter=null,!0;for(var f=0;f<o.sel.ranges.length;f++){var p=o.sel.ranges[f];if(p.head.line==t&&p.head.ch<c.length){var d=Wo(t,c.length);Se(o,f,new de(d,d));break}}}function _n(e,t,n,r){var i=t,o=t;return"number"==typeof t?o=Yr(e,ge(e,t)):i=ei(t),null==i?null:(r(o,i)&&e.cm&&It(e.cm,i,n),o)}function Rn(e,t){for(var n=e.doc.sel.ranges,r=[],i=0;i<n.length;i++){for(var o=t(n[i]);r.length&&Io(o.from,Hi(r).to)<=0;){var l=r.pop();if(Io(l.from,o.from)<0){o.from=l.from;break}}r.push(o)}Nt(e,function(){for(var t=r.length-1;t>=0;t--)Hn(e.doc,"",r[t].from,r[t].to,"+delete");Pn(e)})}function qn(e,t,n,r,i){function o(){var t=a+n;return t<e.first||t>=e.first+e.size?h=!1:(a=t,c=Yr(e,t))}function l(e){var t=(i?co:ho)(c,s,n,!0);if(null==t){if(e||!o())return h=!1;s=i?(0>n?ro:no)(c):0>n?c.text.length:0}else s=t;return!0}var a=t.line,s=t.ch,u=n,c=Yr(e,a),h=!0;if("char"==r)l();else if("column"==r)l(!0);else if("word"==r||"group"==r)for(var d=null,f="group"==r,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(0>n)||l(!g);g=!1){var m=c.text.charAt(s)||"\n",v=Bi(m,p)?"w":f&&"\n"==m?"n":!f||/\s/.test(m)?null:"p";if(!f||g||v||(v="s"),d&&d!=v){0>n&&(n=1,l());break}if(v&&(d=v),n>0&&!l(!g))break}var y=Oe(e,Wo(a,s),u,!0);return h||(y.hitSide=!0),y}function Un(e,t,n,r){var i,o=e.doc,l=t.left;if("page"==r){var a=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+n*(a-(0>n?1.5:.5)*vt(e.display))}else"line"==r&&(i=n>0?t.bottom+3:t.top-3);for(;;){var s=gt(e,l,i);if(!s.outside)break;if(0>n?0>=i:i>=o.height){s.hitSide=!0;break}i+=5*n}return s}function Gn(t,n,r,i){e.defaults[t]=n,r&&(Zo[t]=i?function(e,t,n){n!=Qo&&r(e,t,n)}:r)}function jn(e){for(var t,n,r,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l<o.length-1;l++){var a=o[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))t=!0;else if(/^(c|ctrl|control)$/i.test(a))n=!0;else{if(!/^s(hift)$/i.test(a))throw new Error("Unrecognized modifier name: "+a);r=!0}}return t&&(e="Alt-"+e),n&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),r&&(e="Shift-"+e),e}function $n(e){return"string"==typeof e?al[e]:e}function Vn(e,t,n,r,i){if(r&&r.shared)return Kn(e,t,n,r,i);if(e.cm&&!e.cm.curOp)return At(e.cm,Vn)(e,t,n,r,i);var o=new fl(e,i),l=Io(t,n);if(r&&Fi(r,o,!1),l>0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=Ri("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(mr(e,t.line,t,n,o)||t.line!=n.line&&mr(e,n.line,t,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Eo=!0}o.addToHistory&&si(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var a,s=t.line,u=e.cm;if(e.iter(s,n.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&vr(e)==u.display.maxLine&&(a=!0),o.collapsed&&s!=t.line&&Jr(e,0),tr(e,new Qn(o,s==t.line?t.ch:null,s==n.line?n.ch:null)),++s}),o.collapsed&&e.iter(t.line,n.line+1,function(t){wr(e,t)&&Jr(t,0)}),o.clearOnEnter&&Ml(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(Oo=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++dl,o.atomic=!0),u){if(a&&(u.curOp.updateMaxLine=!0),o.collapsed)Wt(u,t.line,n.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=n.line;c++)It(u,c,"text");o.atomic&&De(u.doc),Si(u,"markerAdded",u,o)}return o}function Kn(e,t,n,r,i){r=Fi(r),r.shared=!1;var o=[Vn(e,t,n,r,i)],l=o[0],a=r.widgetNode;return Kr(e,function(e){a&&(r.widgetNode=a.cloneNode(!0)),o.push(Vn(e,me(e,t),me(e,n),r,i));for(var s=0;s<e.linked.length;++s)if(e.linked[s].isParent)return;l=Hi(o)}),new pl(o,l)}function Xn(e){return e.findMarks(Wo(e.first,0),e.clipPos(Wo(e.lastLine())),function(e){return e.parent})}function Yn(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.find(),o=e.clipPos(i.from),l=e.clipPos(i.to);if(Io(o,l)){var a=Vn(e,o,l,r.primary,r.primary.type);r.markers.push(a),a.parent=r}}}function Zn(e){for(var t=0;t<e.length;t++){var n=e[t],r=[n.primary.doc];Kr(n.primary.doc,function(e){r.push(e)});for(var i=0;i<n.markers.length;i++){var o=n.markers[i];-1==Oi(r,o.doc)&&(o.parent=null,n.markers.splice(i--,1))}}}function Qn(e,t,n){this.marker=e,this.from=t,this.to=n}function Jn(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function er(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n||(n=[])).push(e[r]);return n}function tr(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function nr(e,t,n){if(e)for(var r,i=0;i<e.length;++i){var o=e[i],l=o.marker,a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);if(a||o.from==t&&"bookmark"==l.type&&(!n||!o.marker.insertLeft)){var s=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(r||(r=[])).push(new Qn(l,o.from,s?null:o.to))}}return r}function rr(e,t,n){if(e)for(var r,i=0;i<e.length;++i){var o=e[i],l=o.marker,a=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);if(a||o.from==t&&"bookmark"==l.type&&(!n||o.marker.insertLeft)){var s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(r||(r=[])).push(new Qn(l,s?null:o.from-t,null==o.to?null:o.to-t))}}return r}function ir(e,t){if(t.full)return null;var n=ye(e,t.from.line)&&Yr(e,t.from.line).markedSpans,r=ye(e,t.to.line)&&Yr(e,t.to.line).markedSpans;if(!n&&!r)return null;var i=t.from.ch,o=t.to.ch,l=0==Io(t.from,t.to),a=nr(n,i,l),s=rr(r,o,l),u=1==t.text.length,c=Hi(t.text).length+(u?i:0);if(a)for(var h=0;h<a.length;++h){var d=a[h];if(null==d.to){var f=Jn(s,d.marker);f?u&&(d.to=null==f.to?null:f.to+c):d.to=i}}if(s)for(var h=0;h<s.length;++h){var d=s[h];if(null!=d.to&&(d.to+=c),null==d.from){var f=Jn(a,d.marker);f||(d.from=c,u&&(a||(a=[])).push(d))}else d.from+=c,u&&(a||(a=[])).push(d)}a&&(a=or(a)),s&&s!=a&&(s=or(s));var p=[a];if(!u){var g,m=t.text.length-2;if(m>0&&a)for(var h=0;h<a.length;++h)null==a[h].to&&(g||(g=[])).push(new Qn(a[h].marker,null,null));for(var h=0;m>h;++h)p.push(g);p.push(s)}return p}function or(e){for(var t=0;t<e.length;++t){var n=e[t];null!=n.from&&n.from==n.to&&n.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function lr(e,t){var n=pi(e,t),r=ir(e,t);if(!n)return r;if(!r)return n;for(var i=0;i<n.length;++i){var o=n[i],l=r[i];if(o&&l)e:for(var a=0;a<l.length;++a){for(var s=l[a],u=0;u<o.length;++u)if(o[u].marker==s.marker)continue e;o.push(s)}else l&&(n[i]=l)}return n}function ar(e,t,n){var r=null;if(e.iter(t.line,n.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var n=e.markedSpans[t].marker;!n.readOnly||r&&-1!=Oi(r,n)||(r||(r=[])).push(n)}}),!r)return null;for(var i=[{from:t,to:n}],o=0;o<r.length;++o)for(var l=r[o],a=l.find(0),s=0;s<i.length;++s){var u=i[s];if(!(Io(u.to,a.from)<0||Io(u.from,a.to)>0)){var c=[s,1],h=Io(u.from,a.from),d=Io(u.to,a.to);(0>h||!l.inclusiveLeft&&!h)&&c.push({from:u.from,to:a.from}),(d>0||!l.inclusiveRight&&!d)&&c.push({from:a.to,to:u.to}),i.splice.apply(i,c),s+=c.length-1}}return i}function sr(e){var t=e.markedSpans;if(t){for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}}function ur(e,t){if(t){for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}}function cr(e){return e.inclusiveLeft?-1:0}function hr(e){return e.inclusiveRight?1:0}function dr(e,t){var n=e.lines.length-t.lines.length;if(0!=n)return n;var r=e.find(),i=t.find(),o=Io(r.from,i.from)||cr(e)-cr(t);if(o)return-o;var l=Io(r.to,i.to)||hr(e)-hr(t);return l?l:t.id-e.id}function fr(e,t){var n,r=Eo&&e.markedSpans;if(r)for(var i,o=0;o<r.length;++o)i=r[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!n||dr(n,i.marker)<0)&&(n=i.marker);return n}function pr(e){return fr(e,!0)}function gr(e){return fr(e,!1)}function mr(e,t,n,r,i){var o=Yr(e,t),l=Eo&&o.markedSpans;if(l)for(var a=0;a<l.length;++a){var s=l[a];if(s.marker.collapsed){var u=s.marker.find(0),c=Io(u.from,n)||cr(s.marker)-cr(i),h=Io(u.to,r)||hr(s.marker)-hr(i);if(!(c>=0&&0>=h||0>=c&&h>=0)&&(0>=c&&(Io(u.to,n)>0||s.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&&(Io(u.from,r)<0||s.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function vr(e){for(var t;t=pr(e);)e=t.find(-1,!0).line;return e}function yr(e){for(var t,n;t=gr(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function br(e,t){var n=Yr(e,t),r=vr(n);return n==r?t:ei(r)}function xr(e,t){if(t>e.lastLine())return t;var n,r=Yr(e,t);if(!wr(e,r))return t;for(;n=gr(r);)r=n.find(1,!0).line;return ei(r)+1}function wr(e,t){var n=Eo&&t.markedSpans;if(n)for(var r,i=0;i<n.length;++i)if(r=n[i],r.marker.collapsed){if(null==r.from)return!0;if(!r.marker.widgetNode&&0==r.from&&r.marker.inclusiveLeft&&Cr(e,t,r))return!0}}function Cr(e,t,n){if(null==n.to){var r=n.marker.find(1,!0);return Cr(e,r.line,Jn(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(null==i.to||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&Cr(e,t,i))return!0}function Sr(e,t,n){ni(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Fn(e,null,n)}function kr(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!Gl(document.body,e.node)){var n="position: relative;";e.coverGutter&&(n+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(n+="width: "+t.display.wrapper.clientWidth+"px;"),Ui(t.display.measure,Ri("div",[e.node],null,n))}return e.height=e.node.offsetHeight}function Lr(e,t,n,r){var i=new gl(e,n,r),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),_n(e,t,"widget",function(t){var n=t.widgets||(t.widgets=[]);if(null==i.insertAt?n.push(i):n.splice(Math.min(n.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,o&&!wr(e,t)){var r=ni(t)<e.scrollTop;Jr(t,t.height+kr(i)),r&&Fn(o,null,i.height),o.curOp.forceUpdate=!0}return!0}),i}function Mr(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),sr(e),ur(e,n);var i=r?r(e):1;i!=e.height&&Jr(e,i)}function Tr(e){e.parent=null,sr(e)}function Nr(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";null==t[r]?t[r]=n[2]:new RegExp("(?:^|s)"+n[2]+"(?:$|s)").test(t[r])||(t[r]+=" "+n[2])}return e}function Ar(t,n){if(t.blankLine)return t.blankLine(n);if(t.innerMode){var r=e.innerMode(t,n);return r.mode.blankLine?r.mode.blankLine(r.state):void 0}}function Dr(t,n,r,i){for(var o=0;10>o;o++){i&&(i[0]=e.innerMode(t,r).mode);var l=t.token(n,r);if(n.pos>n.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function Hr(e,t,n,r){function i(e){return{start:h.start,end:h.pos,string:h.current(),type:o||null,state:e?il(l.mode,c):c}}var o,l=e.doc,a=l.mode;t=me(l,t);var s,u=Yr(l,t.line),c=Re(e,t.line,n),h=new hl(u.text,e.options.tabSize);for(r&&(s=[]);(r||h.pos<t.ch)&&!h.eol();)h.start=h.pos,o=Dr(a,h,c),r&&s.push(i(!0));return r?s:i()}function Or(e,t,n,r,i,o,l){var a=n.flattenSpans;null==a&&(a=e.options.flattenSpans);var s,u=0,c=null,h=new hl(t,e.options.tabSize),d=e.options.addModeClass&&[null];for(""==t&&Nr(Ar(n,r),o);!h.eol();){if(h.pos>e.options.maxHighlightLength?(a=!1,l&&Ir(e,t,r,h.pos),h.pos=t.length,s=null):s=Nr(Dr(n,h,r,d),o),d){var f=d[0].name;f&&(s="m-"+(s?f+" "+s:f))}if(!a||c!=s){for(;u<h.start;)u=Math.min(h.start,u+5e4),i(u,c);c=s}h.start=h.pos}for(;u<h.pos;){var p=Math.min(h.pos,u+5e4);i(p,c),u=p}}function Er(e,t,n,r){var i=[e.state.modeGen],o={};Or(e,t.text,e.doc.mode,n,function(e,t){i.push(e,t)},o,r);for(var l=0;l<e.state.overlays.length;++l){var a=e.state.overlays[l],s=1,u=0;Or(e,t.text,a.mode,!0,function(e,t){for(var n=s;e>u;){var r=i[s];r>e&&i.splice(s,1,e,i[s+1],r),s+=2,u=Math.min(e,r)}if(t)if(a.opaque)i.splice(n,s-n,e,"cm-overlay "+t),s=n+2;else for(;s>n;n+=2){var o=i[n+1];i[n+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Wr(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Re(e,ei(t)),i=Er(e,t,t.text.length>e.options.maxHighlightLength?il(e.doc.mode,r):r);t.stateAfter=r,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.frontier&&e.doc.frontier++}return t.styles}function Ir(e,t,n,r){var i=e.doc.mode,o=new hl(t,e.options.tabSize);for(o.start=o.pos=r||0,""==t&&Ar(i,n);!o.eol();)Dr(i,o,n),o.start=o.pos}function Fr(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?yl:vl;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Pr(e,t){var n=Ri("span",null,null,yo?"padding-right: .1px":null),r={pre:Ri("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,splitSpaces:(mo||yo)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;r.pos=0,r.addToken=zr,Zi(e.display.measure)&&(o=ri(l))&&(r.addToken=Rr(r.addToken,o)),r.map=[];var a=t!=e.display.externalMeasured&&ei(l);Ur(l,r,Wr(e,l,a)),l.styleClasses&&(l.styleClasses.bgClass&&(r.bgClass=$i(l.styleClasses.bgClass,r.bgClass||"")),l.styleClasses.textClass&&(r.textClass=$i(l.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(Yi(e.display.measure))),0==i?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return yo&&/\bcm-tab\b/.test(r.content.lastChild.className)&&(r.content.className="cm-tab-wrap-hack"),Al(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=$i(r.pre.className,r.textClass||"")),r}function Br(e){var t=Ri("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function zr(e,t,n,r,i,o,l){if(t){var a=e.splitSpaces?t.replace(/ {3,}/g,_r):t,s=e.cm.state.specialChars,u=!1;if(s.test(t))for(var c=document.createDocumentFragment(),h=0;;){s.lastIndex=h;var d=s.exec(t),f=d?d.index-h:t.length-h;if(f){var p=document.createTextNode(a.slice(h,h+f));mo&&9>vo?c.appendChild(Ri("span",[p])):c.appendChild(p),e.map.push(e.pos,e.pos+f,p),e.col+=f,e.pos+=f}if(!d)break;if(h+=f+1," "==d[0]){var g=e.cm.options.tabSize,m=g-e.col%g,p=c.appendChild(Ri("span",Di(m),"cm-tab"));p.setAttribute("role","presentation"),p.setAttribute("cm-text"," "),e.col+=m}else if("\r"==d[0]||"\n"==d[0]){var p=c.appendChild(Ri("span","\r"==d[0]?"␍":"␤","cm-invalidchar"));p.setAttribute("cm-text",d[0]),e.col+=1}else{var p=e.cm.options.specialCharPlaceholder(d[0]);p.setAttribute("cm-text",d[0]),mo&&9>vo?c.appendChild(Ri("span",[p])):c.appendChild(p),e.col+=1}e.map.push(e.pos,e.pos+1,p),e.pos++}else{e.col+=t.length;var c=document.createTextNode(a);e.map.push(e.pos,e.pos+t.length,c),mo&&9>vo&&(u=!0),e.pos+=t.length}if(n||r||i||u||l){var v=n||"";r&&(v+=r),i&&(v+=i);var y=Ri("span",[c],v,l);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(c)}}function _r(e){for(var t=" ",n=0;n<e.length-2;++n)t+=n%2?" ":" ";return t+=" "}function Rr(e,t){return function(n,r,i,o,l,a,s){i=i?i+" cm-force-border":"cm-force-border";for(var u=n.pos,c=u+r.length;;){for(var h=0;h<t.length;h++){var d=t[h];if(d.to>u&&d.from<=u)break}if(d.to>=c)return e(n,r,i,o,l,a,s);e(n,r.slice(0,d.to-u),i,o,null,a,s),o=null,r=r.slice(d.to-u),u=d.to}}}function qr(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function Ur(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(r)for(var l,a,s,u,c,h,d,f=i.length,p=0,g=1,m="",v=0;;){if(v==p){s=u=c=h=a="",d=null,v=1/0;for(var y=[],b=0;b<r.length;++b){var x=r[b],w=x.marker;"bookmark"==w.type&&x.from==p&&w.widgetNode?y.push(w):x.from<=p&&(null==x.to||x.to>p||w.collapsed&&x.to==p&&x.from==p)?(null!=x.to&&x.to!=p&&v>x.to&&(v=x.to,u=""),w.className&&(s+=" "+w.className),w.css&&(a=w.css),w.startStyle&&x.from==p&&(c+=" "+w.startStyle),w.endStyle&&x.to==v&&(u+=" "+w.endStyle),w.title&&!h&&(h=w.title),w.collapsed&&(!d||dr(d.marker,w)<0)&&(d=x)):x.from>p&&v>x.from&&(v=x.from)}if(d&&(d.from||0)==p){if(qr(t,(null==d.to?f+1:d.to)-p,d.marker,null==d.from),null==d.to)return;d.to==p&&(d=!1)}if(!d&&y.length)for(var b=0;b<y.length;++b)qr(t,0,y[b])}if(p>=f)break;for(var C=Math.min(f,v);;){if(m){var S=p+m.length;if(!d){var k=S>C?m.slice(0,C-p):m;t.addToken(t,k,l?l+s:s,c,p+k.length==v?u:"",h,a)}if(S>=C){m=m.slice(C-p),p=C;break}p=S,c=""}m=i.slice(o,o=n[g++]),l=Fr(n[g++],t.cm.options)}}else for(var g=1;g<n.length;g+=2)t.addToken(t,i.slice(o,o=n[g]),Fr(n[g+1],t.cm.options))}function Gr(e,t){return 0==t.from.ch&&0==t.to.ch&&""==Hi(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function jr(e,t,n,r){function i(e){return n?n[e]:null}function o(e,n,i){Mr(e,n,i,r),Si(e,"change",e,t)}function l(e,t){for(var n=e,o=[];t>n;++n)o.push(new ml(u[n],i(n),r));return o}var a=t.from,s=t.to,u=t.text,c=Yr(e,a.line),h=Yr(e,s.line),d=Hi(u),f=i(u.length-1),p=s.line-a.line;if(t.full)e.insert(0,l(0,u.length)),e.remove(u.length,e.size-u.length);else if(Gr(e,t)){var g=l(0,u.length-1);o(h,h.text,f),p&&e.remove(a.line,p),g.length&&e.insert(a.line,g)}else if(c==h)if(1==u.length)o(c,c.text.slice(0,a.ch)+d+c.text.slice(s.ch),f);else{var g=l(1,u.length-1);g.push(new ml(d+c.text.slice(s.ch),f,r)),o(c,c.text.slice(0,a.ch)+u[0],i(0)),e.insert(a.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,a.ch)+u[0]+h.text.slice(s.ch),i(0)),e.remove(a.line+1,p);else{o(c,c.text.slice(0,a.ch)+u[0],i(0)),o(h,d+h.text.slice(s.ch),f);var g=l(1,u.length-1);p>1&&e.remove(a.line+1,p-1),e.insert(a.line+1,g)}Si(e,"change",e,t)}function $r(e){this.lines=e,this.parent=null;for(var t=0,n=0;t<e.length;++t)e[t].parent=this,n+=e[t].height;this.height=n}function Vr(e){this.children=e;for(var t=0,n=0,r=0;r<e.length;++r){var i=e[r];t+=i.chunkSize(),n+=i.height,i.parent=this}this.size=t,this.height=n,this.parent=null}function Kr(e,t,n){function r(e,i,o){if(e.linked)for(var l=0;l<e.linked.length;++l){var a=e.linked[l];if(a.doc!=i){var s=o&&a.sharedHist;(!n||s)&&(t(a.doc,s),r(a.doc,e,s))}}}r(e,null,!0)}function Xr(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,l(e),n(e),e.options.lineWrapping||d(e),e.options.mode=t.modeOption,Wt(e)}function Yr(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(o>t){n=i;break}t-=o}return n.lines[t]}function Zr(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(e){var o=e.text;i==n.line&&(o=o.slice(0,n.ch)),i==t.line&&(o=o.slice(t.ch)),r.push(o),++i}),r}function Qr(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function Jr(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function ei(e){if(null==e.parent)return null;for(var t=e.parent,n=Oi(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var i=0;r.children[i]!=t;++i)n+=r.children[i].chunkSize();return n+t.first}function ti(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var i=e.children[r],o=i.height;if(o>t){e=i;continue e}t-=o,n+=i.chunkSize()}return n}while(!e.lines);for(var r=0;r<e.lines.length;++r){var l=e.lines[r],a=l.height;if(a>t)break;t-=a}return n+r}function ni(e){e=vr(e);for(var t=0,n=e.parent,r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var o=n.parent;o;n=o,o=n.parent)for(var r=0;r<o.children.length;++r){var l=o.children[r];if(l==n)break;t+=l.height}return t}function ri(e){var t=e.order;return null==t&&(t=e.order=ra(e.text)),t}function ii(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function oi(e,t){var n={from:V(t.from),to:Xo(t),text:Zr(e,t.from,t.to)};return di(e,n,t.from.line,t.to.line+1),Kr(e,function(e){di(e,n,t.from.line,t.to.line+1)},!0),n}function li(e){for(;e.length;){var t=Hi(e);if(!t.ranges)break;e.pop()}}function ai(e,t){return t?(li(e.done),Hi(e.done)):e.done.length&&!Hi(e.done).ranges?Hi(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Hi(e.done)):void 0}function si(e,t,n,r){var i=e.history;i.undone.length=0;var o,l=+new Date;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=ai(i,i.lastOp==r))){var a=Hi(o.changes);0==Io(t.from,t.to)&&0==Io(t.from,a.to)?a.to=Xo(t):o.changes.push(oi(e,t))}else{var s=Hi(i.done);for(s&&s.ranges||hi(e.sel,i.done),o={changes:[oi(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,a||Al(e,"historyAdded")}function ui(e,t,n,r){var i=t.charAt(0);return"*"==i||"+"==i&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function ci(e,t,n,r){var i=e.history,o=r&&r.origin;n==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||ui(e,o,Hi(i.done),t))?i.done[i.done.length-1]=t:hi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&r.clearRedo!==!1&&li(i.undone)}function hi(e,t){var n=Hi(t);n&&n.ranges&&n.equals(e)||t.push(e)}function di(e,t,n,r){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=n.markedSpans),++o})}function fi(e){if(!e)return null;for(var t,n=0;n<e.length;++n)e[n].marker.explicitlyCleared?t||(t=e.slice(0,n)):t&&t.push(e[n]);return t?t.length?t:null:e}function pi(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=0,i=[];r<t.text.length;++r)i.push(fi(n[r]));return i}function gi(e,t,n){for(var r=0,i=[];r<e.length;++r){var o=e[r];if(o.ranges)i.push(n?he.prototype.deepCopy.call(o):o);else{var l=o.changes,a=[];i.push({changes:a});for(var s=0;s<l.length;++s){var u,c=l[s];if(a.push({from:c.from,to:c.to,text:c.text}),t)for(var h in c)(u=h.match(/^spans_(\d+)$/))&&Oi(t,Number(u[1]))>-1&&(Hi(a)[h]=c[h],delete c[h])}}}return i}function mi(e,t,n,r){n<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function vi(e,t,n,r){for(var i=0;i<e.length;++i){var o=e[i],l=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var a=0;a<o.ranges.length;a++)mi(o.ranges[a].anchor,t,n,r),mi(o.ranges[a].head,t,n,r)}else{for(var a=0;a<o.changes.length;++a){var s=o.changes[a];if(n<s.from.line)s.from=Wo(s.from.line+r,s.from.ch),s.to=Wo(s.to.line+r,s.to.ch);else if(t<=s.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function yi(e,t){var n=t.from.line,r=t.to.line,i=t.text.length-(r-n)-1;vi(e.done,n,r,i),vi(e.undone,n,r,i)}function bi(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function xi(e){return e.target||e.srcElement}function wi(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),To&&e.ctrlKey&&1==t&&(t=3),t}function Ci(e,t,n){var r=e._handlers&&e._handlers[t];return n?r&&r.length>0?r.slice():Tl:r||Tl}function Si(e,t){function n(e){return function(){e.apply(null,o)}}var r=Ci(e,t,!1);if(r.length){var i,o=Array.prototype.slice.call(arguments,2);Ro?i=Ro.delayedCallbacks:Dl?i=Dl:(i=Dl=[],setTimeout(ki,0));for(var l=0;l<r.length;++l)i.push(n(r[l]))}}function ki(){var e=Dl;Dl=null;for(var t=0;t<e.length;++t)e[t]()}function Li(e,t,n){return"string"==typeof t&&(t={type:t,preventDefault:function(){
10
+ this.defaultPrevented=!0}}),Al(e,n||t.type,e,t),bi(t)||t.codemirrorIgnore}function Mi(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)-1==Oi(n,t[r])&&n.push(t[r])}function Ti(e,t){return Ci(e,t).length>0}function Ni(e){e.prototype.on=function(e,t){Ml(this,e,t)},e.prototype.off=function(e,t){Nl(this,e,t)}}function Ai(){this.id=null}function Di(e){for(;Bl.length<=e;)Bl.push(Hi(Bl)+" ");return Bl[e]}function Hi(e){return e[e.length-1]}function Oi(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}function Ei(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Wi(){}function Ii(e,t){var n;return Object.create?n=Object.create(e):(Wi.prototype=e,n=new Wi),t&&Fi(t,n),n}function Fi(e,t,n){t||(t={});for(var r in e)!e.hasOwnProperty(r)||n===!1&&t.hasOwnProperty(r)||(t[r]=e[r]);return t}function Pi(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function Bi(e,t){return t?t.source.indexOf("\\w")>-1&&ql(e)?!0:t.test(e):ql(e)}function zi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function _i(e){return e.charCodeAt(0)>=768&&Ul.test(e)}function Ri(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function qi(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function Ui(e,t){return qi(e).appendChild(t)}function Gi(){for(var e=document.activeElement;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e}function ji(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function $i(e,t){for(var n=e.split(" "),r=0;r<n.length;r++)n[r]&&!ji(n[r]).test(t)&&(t+=" "+n[r]);return t}function Vi(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),n=0;n<t.length;n++){var r=t[n].CodeMirror;r&&e(r)}}function Ki(){Xl||(Xi(),Xl=!0)}function Xi(){var e;Ml(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,Vi(Ut)},100))}),Ml(window,"blur",function(){Vi(vn)})}function Yi(e){if(null==jl){var t=Ri("span","​");Ui(e,Ri("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(jl=t.offsetWidth<=1&&t.offsetHeight>2&&!(mo&&8>vo))}var n=jl?Ri("span","​"):Ri("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function Zi(e){if(null!=$l)return $l;var t=Ui(e,document.createTextNode("AخA")),n=_l(t,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var r=_l(t,1,2).getBoundingClientRect();return $l=r.right-n.right<3}function Qi(e){if(null!=ea)return ea;var t=Ui(e,Ri("span","x")),n=t.getBoundingClientRect(),r=_l(t,0,1).getBoundingClientRect();return ea=Math.abs(n.left-r.left)>1}function Ji(e,t,n,r){if(!e)return r(t,n,"ltr");for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<n&&l.to>t||t==n&&l.to==t)&&(r(Math.max(l.from,t),Math.min(l.to,n),1==l.level?"rtl":"ltr"),i=!0)}i||r(t,n,"ltr")}function eo(e){return e.level%2?e.to:e.from}function to(e){return e.level%2?e.from:e.to}function no(e){var t=ri(e);return t?eo(t[0]):0}function ro(e){var t=ri(e);return t?to(Hi(t)):e.text.length}function io(e,t){var n=Yr(e.doc,t),r=vr(n);r!=n&&(t=ei(r));var i=ri(r),o=i?i[0].level%2?ro(r):no(r):0;return Wo(t,o)}function oo(e,t){for(var n,r=Yr(e.doc,t);n=gr(r);)r=n.find(1,!0).line,t=null;var i=ri(r),o=i?i[0].level%2?no(r):ro(r):r.text.length;return Wo(null==t?ei(r):t,o)}function lo(e,t){var n=io(e,t.line),r=Yr(e.doc,n.line),i=ri(r);if(!i||0==i[0].level){var o=Math.max(0,r.text.search(/\S/)),l=t.line==n.line&&t.ch<=o&&t.ch;return Wo(n.line,l?0:o)}return n}function ao(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:n>t}function so(e,t){na=null;for(var n,r=0;r<e.length;++r){var i=e[r];if(i.from<t&&i.to>t)return r;if(i.from==t||i.to==t){if(null!=n)return ao(e,i.level,e[n].level)?(i.from!=i.to&&(na=n),r):(i.from!=i.to&&(na=r),n);n=r}}return n}function uo(e,t,n,r){if(!r)return t+n;do t+=n;while(t>0&&_i(e.text.charAt(t)));return t}function co(e,t,n,r){var i=ri(e);if(!i)return ho(e,t,n,r);for(var o=so(i,t),l=i[o],a=uo(e,t,l.level%2?-n:n,r);;){if(a>l.from&&a<l.to)return a;if(a==l.from||a==l.to)return so(i,a)==o?a:(l=i[o+=n],n>0==l.level%2?l.to:l.from);if(l=i[o+=n],!l)return null;a=n>0==l.level%2?uo(e,l.to,-1,r):uo(e,l.from,1,r)}}function ho(e,t,n,r){var i=t+n;if(r)for(;i>0&&_i(e.text.charAt(i));)i+=n;return 0>i||i>e.text.length?null:i}var fo=/gecko\/\d/i.test(navigator.userAgent),po=/MSIE \d/.test(navigator.userAgent),go=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),mo=po||go,vo=mo&&(po?document.documentMode||6:go[1]),yo=/WebKit\//.test(navigator.userAgent),bo=yo&&/Qt\/\d+\.\d+/.test(navigator.userAgent),xo=/Chrome\//.test(navigator.userAgent),wo=/Opera\//.test(navigator.userAgent),Co=/Apple Computer/.test(navigator.vendor),So=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),ko=/PhantomJS/.test(navigator.userAgent),Lo=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),Mo=Lo||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),To=Lo||/Mac/.test(navigator.platform),No=/win/i.test(navigator.platform),Ao=wo&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Ao&&(Ao=Number(Ao[1])),Ao&&Ao>=15&&(wo=!1,yo=!0);var Do=To&&(bo||wo&&(null==Ao||12.11>Ao)),Ho=fo||mo&&vo>=9,Oo=!1,Eo=!1;g.prototype=Fi({update:function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedOverlay&&e.clientHeight>0&&(0==r&&this.overlayHack(),this.checkedOverlay=!0),{right:n?r:0,bottom:t?r:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e)},overlayHack:function(){var e=To&&!So?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=e;var t=this,n=function(e){xi(e)!=t.vert&&xi(e)!=t.horiz&&At(t.cm,$t)(e)};Ml(this.vert,"mousedown",n),Ml(this.horiz,"mousedown",n)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},g.prototype),m.prototype=Fi({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},m.prototype),e.scrollbarModel={"native":g,"null":m},L.prototype.signal=function(e,t){Ti(e,t)&&this.events.push(arguments)},L.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Al.apply(null,this.events[e])};var Wo=e.Pos=function(e,t){return this instanceof Wo?(this.line=e,void(this.ch=t)):new Wo(e,t)},Io=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch},Fo=null;re.prototype=Fi({init:function(e){function t(e){if(r.somethingSelected())Fo=r.getSelections(),n.inaccurateSelection&&(n.prevInput="",n.inaccurateSelection=!1,o.value=Fo.join("\n"),zl(o));else{if(!r.options.lineWiseCopyCut)return;var t=te(r);Fo=t.text,"cut"==e.type?r.setSelections(t.ranges,null,El):(n.prevInput="",o.value=t.text.join("\n"),zl(o))}"cut"==e.type&&(r.state.cutIncoming=!0)}var n=this,r=this.cm,i=this.wrapper=ie(),o=this.textarea=i.firstChild;e.wrapper.insertBefore(i,e.wrapper.firstChild),Lo&&(o.style.width="0px"),Ml(o,"input",function(){mo&&vo>=9&&n.hasSelection&&(n.hasSelection=null),n.poll()}),Ml(o,"paste",function(e){return J(e,r)?!0:(r.state.pasteIncoming=!0,void n.fastPoll())}),Ml(o,"cut",t),Ml(o,"copy",t),Ml(e.scroller,"paste",function(t){Gt(e,t)||(r.state.pasteIncoming=!0,n.focus())}),Ml(e.lineSpace,"selectstart",function(t){Gt(e,t)||Sl(t)}),Ml(o,"compositionstart",function(){var e=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Ml(o,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},prepareSelection:function(){var e=this.cm,t=e.display,n=e.doc,r=We(e);if(e.options.moveInputWithCursor){var i=dt(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return r},showSelection:function(e){var t=this.cm,n=t.display;Ui(n.cursorDiv,e.cursors),Ui(n.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,n,r=this.cm,i=r.doc;if(r.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=Jl&&(o.to().line-o.from().line>100||(n=r.getSelection()).length>1e3);var l=t?"-":n||r.getSelection();this.textarea.value=l,r.state.focused&&zl(this.textarea),mo&&vo>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",mo&&vo>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Mo||Gi()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var r=n.poll();r||t?(n.pollingFast=!1,n.slowPoll()):(t=!0,n.polling.set(60,e))}var t=!1,n=this;n.pollingFast=!0,n.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,n=this.prevInput;if(this.contextMenuPending||!e.state.focused||Ql(t)&&!n&&!this.composing||Z(e)||e.options.disableInput||e.state.keySeq)return!1;var r=t.value;if(r==n&&!e.somethingSelected())return!1;if(mo&&vo>=9&&this.hasSelection===r||To&&/[\uf700-\uf7ff]/.test(r))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var i=r.charCodeAt(0);if(8203!=i||n||(n="​"),8666==i)return this.reset(),this.cm.execCommand("undo")}for(var o=0,l=Math.min(n.length,r.length);l>o&&n.charCodeAt(o)==r.charCodeAt(o);)++o;var a=this;return Nt(e,function(){Q(e,r.slice(o),n.length-o,null,a.composing?"*compose":null),r.length>1e3||r.indexOf("\n")>-1?t.value=a.prevInput="":a.prevInput=r,a.composing&&(a.composing.range.clear(),a.composing.range=e.markText(a.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){mo&&vo>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t="​"+(e?l.value:"");l.value="⇚",l.value=t,r.prevInput=e?"":"​",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function n(){if(r.contextMenuPending=!1,r.wrapper.style.position="relative",l.style.cssText=c,mo&&9>vo&&o.scrollbars.setScrollTop(o.scroller.scrollTop=s),null!=l.selectionStart){(!mo||mo&&9>vo)&&t();var e=0,n=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart&&l.selectionEnd>0&&"​"==r.prevInput?At(i,ll.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(n,500):o.input.reset()};o.detectingSelectAll=setTimeout(n,200)}}var r=this,i=r.cm,o=i.display,l=r.textarea,a=jt(i,e),s=o.scroller.scrollTop;if(a&&!wo){var u=i.options.resetSelectionOnContextMenu;u&&-1==i.doc.sel.contains(a)&&At(i,Te)(i.doc,pe(a),El);var c=l.style.cssText;if(r.wrapper.style.position="absolute",l.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(mo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",yo)var h=window.scrollY;if(o.input.focus(),yo&&window.scrollTo(null,h),o.input.reset(),i.somethingSelected()||(l.value=r.prevInput=" "),r.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),mo&&vo>=9&&t(),Ho){Ll(e);var d=function(){Nl(window,"mouseup",d),setTimeout(n,20)};Ml(window,"mouseup",d)}else setTimeout(n,50)}},readOnlyChanged:function(e){e||this.reset()},setUneditable:Wi,needsContentAttribute:!1},re.prototype),oe.prototype=Fi({init:function(e){function t(e){if(r.somethingSelected())Fo=r.getSelections(),"cut"==e.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var t=te(r);Fo=t.text,"cut"==e.type&&r.operation(function(){r.setSelections(t.ranges,0,El),r.replaceSelection("",null,"cut")})}if(e.clipboardData&&!Lo)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Fo.join("\n"));else{var n=ie(),i=n.firstChild;r.display.lineSpace.insertBefore(n,r.display.lineSpace.firstChild),i.value=Fo.join("\n");var o=document.activeElement;zl(i),setTimeout(function(){r.display.lineSpace.removeChild(n),o.focus()},50)}}var n=this,r=n.cm,i=n.div=e.lineDiv;ne(i),Ml(i,"paste",function(e){J(e,r)}),Ml(i,"compositionstart",function(e){var t=e.data;if(n.composing={sel:r.doc.sel,data:t,startData:t},t){var i=r.doc.sel.primary(),o=r.getLine(i.head.line),l=o.indexOf(t,Math.max(0,i.head.ch-t.length));l>-1&&l<=i.head.ch&&(n.composing.sel=pe(Wo(i.head.line,l),Wo(i.head.line,l+t.length)))}}),Ml(i,"compositionupdate",function(e){n.composing.data=e.data}),Ml(i,"compositionend",function(e){var t=n.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||n.applyComposition(t),n.composing==t&&(n.composing=null)},50))}),Ml(i,"touchstart",function(){n.forceCompositionEnd()}),Ml(i,"input",function(){n.composing||(Z(r)||!n.pollContent())&&Nt(n.cm,function(){Wt(r)})}),Ml(i,"copy",t),Ml(i,"cut",t)},prepareSelection:function(){var e=We(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e){e&&this.cm.display.view.length&&(e.focus&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),n=se(this.cm,e.anchorNode,e.anchorOffset),r=se(this.cm,e.focusNode,e.focusOffset);if(!n||n.bad||!r||r.bad||0!=Io(X(n,r),t.from())||0!=Io(K(n,r),t.to())){var i=le(this.cm,t.from()),o=le(this.cm,t.to());if(i||o){var l=this.cm.display.view,a=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var s=l[l.length-1].measure,u=s.maps?s.maps[s.maps.length-1]:s.map;o={node:u[u.length-1],offset:u[u.length-2]-u[u.length-3]}}}else i={node:l[0].measure.map[2],offset:0};try{var c=_l(i.node,i.offset,o.offset,o.node)}catch(h){}c&&(e.removeAllRanges(),e.addRange(c),a&&null==e.anchorNode?e.addRange(a):fo&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){e.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(e){Ui(this.cm.display.cursorDiv,e.cursors),Ui(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return Gl(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():Nt(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},selectionChanged:function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var n=se(t,e.anchorNode,e.anchorOffset),r=se(t,e.focusNode,e.focusOffset);n&&r&&Nt(t,function(){Te(t.doc,pe(n,r),El),(n.bad||r.bad)&&(t.curOp.selectionChanged=!0)})}},pollContent:function(){var e=this.cm,t=e.display,n=e.doc.sel.primary(),r=n.from(),i=n.to();if(r.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o;if(r.line==t.viewFrom||0==(o=Pt(e,r.line)))var l=ei(t.view[0].line),a=t.view[0].node;else var l=ei(t.view[o].line),a=t.view[o-1].node.nextSibling;var s=Pt(e,i.line);if(s==t.view.length-1)var u=t.viewTo-1,c=t.lineDiv.lastChild;else var u=ei(t.view[s+1].line)-1,c=t.view[s+1].node.previousSibling;for(var h=e.doc.splitLines(ce(e,a,c,l,u)),d=Zr(e.doc,Wo(l,0),Wo(u,Yr(e.doc,u).text.length));h.length>1&&d.length>1;)if(Hi(h)==Hi(d))h.pop(),d.pop(),u--;else{if(h[0]!=d[0])break;h.shift(),d.shift(),l++}for(var f=0,p=0,g=h[0],m=d[0],v=Math.min(g.length,m.length);v>f&&g.charCodeAt(f)==m.charCodeAt(f);)++f;for(var y=Hi(h),b=Hi(d),x=Math.min(y.length-(1==h.length?f:0),b.length-(1==d.length?f:0));x>p&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;h[h.length-1]=y.slice(0,y.length-p),h[0]=h[0].slice(f);var w=Wo(l,f),C=Wo(u,d.length?Hi(d).length-p:0);return h.length>1||h[0]||Io(w,C)?(Hn(e.doc,h,w,C,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){Z(this.cm)?At(this.cm,Wt)(this.cm):e.data&&e.data!=e.startData&&At(this.cm,Q)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.contentEditable="false"},onKeyPress:function(e){e.preventDefault(),Z(this.cm)||At(this.cm,Q)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},readOnlyChanged:function(e){this.div.contentEditable=String("nocursor"!=e)},onContextMenu:Wi,resetPosition:Wi,needsContentAttribute:!0},oe.prototype),e.inputStyles={textarea:re,contenteditable:oe},he.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var n=this.ranges[t],r=e.ranges[t];if(0!=Io(n.anchor,r.anchor)||0!=Io(n.head,r.head))return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new de(V(this.ranges[t].anchor),V(this.ranges[t].head));return new he(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(Io(t,r.from())>=0&&Io(e,r.to())<=0)return n}return-1}},de.prototype={from:function(){return X(this.anchor,this.head)},to:function(){return K(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Po,Bo,zo,_o={left:0,right:0,top:0,bottom:0},Ro=null,qo=0,Uo=0,Go=0,jo=null;mo?jo=-.53:fo?jo=15:xo?jo=-.7:Co&&(jo=-1/3);var $o=function(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==n&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:null==n&&(n=e.wheelDelta),{x:t,y:n}};e.wheelEventPixels=function(e){var t=$o(e);return t.x*=jo,t.y*=jo,t};var Vo=new Ai,Ko=null,Xo=e.changeEnd=function(e){return e.text?Wo(e.from.line+e.text.length-1,Hi(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var n=this.options,r=n[e];(n[e]!=t||"mode"==e)&&(n[e]=t,Zo.hasOwnProperty(e)&&At(this,Zo[e])(this,t,r))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"]($n(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;n<t.length;++n)if(t[n]==e||t[n].name==e)return t.splice(n,1),!0},addOverlay:Dt(function(t,n){var r=t.token?t:e.getMode(this.options,t);if(r.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:r,modeSpec:t,opaque:n&&n.opaque}),this.state.modeGen++,Wt(this)}),removeOverlay:Dt(function(e){for(var t=this.state.overlays,n=0;n<t.length;++n){var r=t[n].modeSpec;if(r==e||"string"==typeof e&&r.name==e)return t.splice(n,1),this.state.modeGen++,void Wt(this)}}),indentLine:Dt(function(e,t,n){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),ye(this.doc,e)&&zn(this,e,t,n)}),indentSelection:Dt(function(e){for(var t=this.doc.sel.ranges,n=-1,r=0;r<t.length;r++){var i=t[r];if(i.empty())i.head.line>n&&(zn(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&Pn(this));else{var o=i.from(),l=i.to(),a=Math.max(n,o.line);n=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var s=a;n>s;++s)zn(this,s,e);var u=this.doc.sel.ranges;0==o.ch&&t.length==u.length&&u[r].from().ch>0&&Se(this.doc,r,new de(o,u[r].to()),El)}}}),getTokenAt:function(e,t){return Hr(this,e,t)},getLineTokens:function(e,t){return Hr(this,Wo(e),t,!0)},getTokenTypeAt:function(e){e=me(this.doc,e);var t,n=Wr(this,Yr(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var l=r+i>>1;if((l?n[2*l-1]:0)>=o)i=l;else{if(!(n[2*l+1]<o)){t=n[2*l+2];break}r=l+1}}var a=t?t.indexOf("cm-overlay "):-1;return 0>a?t:0==a?null:t.slice(0,a-1)},getModeAt:function(t){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(t).state).mode:n},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var n=[];if(!rl.hasOwnProperty(t))return n;var r=rl[t],i=this.getModeAt(e);if("string"==typeof i[t])r[i[t]]&&n.push(r[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var l=r[i[t][o]];l&&n.push(l)}else i.helperType&&r[i.helperType]?n.push(r[i.helperType]):r[i.name]&&n.push(r[i.name]);for(var o=0;o<r._global.length;o++){var a=r._global[o];a.pred(i,this)&&-1==Oi(n,a.val)&&n.push(a.val)}return n},getStateAfter:function(e,t){var n=this.doc;return e=ge(n,null==e?n.first+n.size-1:e),Re(this,e+1,t)},cursorCoords:function(e,t){var n,r=this.doc.sel.primary();return n=null==e?r.head:"object"==typeof e?me(this.doc,e):e?r.from():r.to(),dt(this,n,t||"page")},charCoords:function(e,t){return ht(this,me(this.doc,e),t||"page")},coordsChar:function(e,t){return e=ct(this,e,t||"page"),gt(this,e.left,e.top)},lineAtHeight:function(e,t){return e=ct(this,{top:e,left:0},t||"page").top,ti(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var n,r=!1;if("number"==typeof e){var i=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>i&&(e=i,r=!0),n=Yr(this.doc,e)}else n=e;return ut(this,n,{top:0,left:0},t||"page").top+(r?this.doc.height-ni(n):0)},defaultTextHeight:function(){return vt(this.display)},defaultCharWidth:function(){return yt(this.display)},setGutterMarker:Dt(function(e,t,n){return _n(this.doc,e,"gutter",function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&zi(r)&&(e.gutterMarkers=null),!0})}),clearGutter:Dt(function(e){var t=this,n=t.doc,r=n.first;n.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&(n.gutterMarkers[e]=null,It(t,r,"gutter"),zi(n.gutterMarkers)&&(n.gutterMarkers=null)),++r})}),lineInfo:function(e){if("number"==typeof e){if(!ye(this.doc,e))return null;var t=e;if(e=Yr(this.doc,e),!e)return null}else{var t=ei(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var o=this.display;e=dt(this,me(this.doc,e));var l=e.bottom,a=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==r)l=e.top;else if("above"==r||"near"==r){var s=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>s)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=s&&(l=e.bottom),a+t.offsetWidth>u&&(a=u-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==i?(a=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?a=0:"middle"==i&&(a=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=a+"px"),n&&Wn(this,a,l,a+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:Dt(hn),triggerOnKeyPress:Dt(pn),triggerOnKeyUp:fn,execCommand:function(e){return ll.hasOwnProperty(e)?ll[e].call(null,this):void 0},triggerElectric:Dt(function(e){ee(this,e)}),findPosH:function(e,t,n,r){var i=1;0>t&&(i=-1,t=-t);for(var o=0,l=me(this.doc,e);t>o&&(l=qn(this.doc,l,i,n,r),!l.hitSide);++o);return l},moveH:Dt(function(e,t){var n=this;n.extendSelectionsBy(function(r){return n.display.shift||n.doc.extend||r.empty()?qn(n.doc,r.head,e,t,n.options.rtlMoveVisually):0>e?r.from():r.to()},Il)}),deleteH:Dt(function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):Rn(this,function(n){var i=qn(r,n.head,e,t,!1);return 0>e?{from:i,to:n.head}:{from:n.head,to:i}})}),findPosV:function(e,t,n,r){var i=1,o=r;0>t&&(i=-1,t=-t);for(var l=0,a=me(this.doc,e);t>l;++l){var s=dt(this,a,"div");if(null==o?o=s.left:s.left=o,a=Un(this,s,i,n),a.hitSide)break}return a},moveV:Dt(function(e,t){var n=this,r=this.doc,i=[],o=!n.display.shift&&!r.extend&&r.sel.somethingSelected();if(r.extendSelectionsBy(function(l){if(o)return 0>e?l.from():l.to();var a=dt(n,l.head,"div");null!=l.goalColumn&&(a.left=l.goalColumn),i.push(a.left);var s=Un(n,a,e,t);return"page"==t&&l==r.sel.primary()&&Fn(n,null,ht(n,s,"div").top-a.top),s},Il),i.length)for(var l=0;l<r.sel.ranges.length;l++)r.sel.ranges[l].goalColumn=i[l]}),findWordAt:function(e){var t=this.doc,n=Yr(t,e.line).text,r=e.ch,i=e.ch;if(n){var o=this.getHelper(e,"wordChars");(e.xRel<0||i==n.length)&&r?--r:++i;for(var l=n.charAt(r),a=Bi(l,o)?function(e){return Bi(e,o)}:/\s/.test(l)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!Bi(e)};r>0&&a(n.charAt(r-1));)--r;for(;i<n.length&&a(n.charAt(i));)++i}return new de(Wo(e.line,r),Wo(e.line,i))},toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?Kl(this.display.cursorDiv,"CodeMirror-overwrite"):Vl(this.display.cursorDiv,"CodeMirror-overwrite"),Al(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==Gi()},scrollTo:Dt(function(e,t){(null!=e||null!=t)&&Bn(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-je(this)-this.display.barHeight,width:e.scrollWidth-je(this)-this.display.barWidth,clientHeight:Ve(this),clientWidth:$e(this)}},scrollIntoView:Dt(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:Wo(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)Bn(this),this.curOp.scrollToPos=e;else{var n=In(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(n.scrollLeft,n.scrollTop)}}),setSize:Dt(function(e,t){function n(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}var r=this;null!=e&&(r.display.wrapper.style.width=n(e)),null!=t&&(r.display.wrapper.style.height=n(t)),r.options.lineWrapping&&ot(this);var i=r.display.viewFrom;r.doc.iter(i,r.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){It(r,i,"widget");break}++i}),r.curOp.forceUpdate=!0,Al(r,"refresh",this)}),operation:function(e){return Nt(this,e)},refresh:Dt(function(){var e=this.display.cachedTextHeight;Wt(this),this.curOp.forceUpdate=!0,lt(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),c(this),(null==e||Math.abs(e-vt(this.display))>.5)&&l(this),Al(this,"refresh",this)}),swapDoc:Dt(function(e){var t=this.doc;return t.cm=null,Xr(this,e),lt(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Si(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Ni(e);var Yo=e.defaults={},Zo=e.optionHandlers={},Qo=e.Init={toString:function(){return"CodeMirror.Init"}};Gn("value","",function(e,t){e.setValue(t)},!0),Gn("mode",null,function(e,t){e.doc.modeOption=t,n(e)},!0),Gn("indentUnit",2,n,!0),Gn("indentWithTabs",!1),Gn("smartIndent",!0),Gn("tabSize",4,function(e){r(e),lt(e),Wt(e)},!0),Gn("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var n=[],r=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,n.push(Wo(r,o))}r++});for(var i=n.length-1;i>=0;i--)Hn(e.doc,t,n[i],Wo(n[i].line,n[i].ch+t.length))}}),Gn("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,n,r){t.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),r!=e.Init&&t.refresh()}),Gn("specialCharPlaceholder",Br,function(e){e.refresh()},!0),Gn("electricChars",!0),Gn("inputStyle",Mo?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Gn("rtlMoveVisually",!No),Gn("wholeLineUpdateBefore",!0),Gn("theme","default",function(e){a(e),s(e)},!0),Gn("keyMap","default",function(t,n,r){var i=$n(n),o=r!=e.Init&&$n(r);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Gn("extraKeys",null),Gn("lineWrapping",!1,i,!0),Gn("gutters",[],function(e){f(e.options),s(e)},!0),Gn("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?k(e.display)+"px":"0",e.refresh()},!0),Gn("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Gn("scrollbarStyle","native",function(e){v(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Gn("lineNumbers",!1,function(e){f(e.options),s(e)},!0),Gn("firstLineNumber",1,s,!0),Gn("lineNumberFormatter",function(e){return e},s,!0),Gn("showCursorWhenSelecting",!1,Ee,!0),Gn("resetSelectionOnContextMenu",!0),Gn("lineWiseCopyCut",!0),Gn("readOnly",!1,function(e,t){"nocursor"==t?(vn(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),Gn("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Gn("dragDrop",!0,qt),Gn("cursorBlinkRate",530),Gn("cursorScrollMargin",0),Gn("cursorHeight",1,Ee,!0),Gn("singleCursorHeightPerLine",!0,Ee,!0),Gn("workTime",100),Gn("workDelay",100),Gn("flattenSpans",!0,r,!0),Gn("addModeClass",!1,r,!0),Gn("pollInterval",100),Gn("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Gn("historyEventDelay",1250),Gn("viewportMargin",10,function(e){e.refresh()},!0),
11
+ Gn("maxHighlightLength",1e4,r,!0),Gn("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Gn("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Gn("autofocus",null);var Jo=e.modes={},el=e.mimeModes={};e.defineMode=function(t,n){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(n.dependencies=Array.prototype.slice.call(arguments,2)),Jo[t]=n},e.defineMIME=function(e,t){el[e]=t},e.resolveMode=function(t){if("string"==typeof t&&el.hasOwnProperty(t))t=el[t];else if(t&&"string"==typeof t.name&&el.hasOwnProperty(t.name)){var n=el[t.name];"string"==typeof n&&(n={name:n}),t=Ii(n,t),t.name=n.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,n){var n=e.resolveMode(n),r=Jo[n.name];if(!r)return e.getMode(t,"text/plain");var i=r(t,n);if(tl.hasOwnProperty(n.name)){var o=tl[n.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=n.name,n.helperType&&(i.helperType=n.helperType),n.modeProps)for(var l in n.modeProps)i[l]=n.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var tl=e.modeExtensions={};e.extendMode=function(e,t){var n=tl.hasOwnProperty(e)?tl[e]:tl[e]={};Fi(t,n)},e.defineExtension=function(t,n){e.prototype[t]=n},e.defineDocExtension=function(e,t){xl.prototype[e]=t},e.defineOption=Gn;var nl=[];e.defineInitHook=function(e){nl.push(e)};var rl=e.helpers={};e.registerHelper=function(t,n,r){rl.hasOwnProperty(t)||(rl[t]=e[t]={_global:[]}),rl[t][n]=r},e.registerGlobalHelper=function(t,n,r,i){e.registerHelper(t,n,i),rl[t]._global.push({pred:r,val:i})};var il=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n},ol=e.startState=function(e,t,n){return e.startState?e.startState(t,n):!0};e.innerMode=function(e,t){for(;e.innerMode;){var n=e.innerMode(t);if(!n||n.mode==e)break;t=n.state,e=n.mode}return n||{mode:e,state:t}};var ll=e.commands={selectAll:function(e){e.setSelection(Wo(e.firstLine(),0),Wo(e.lastLine()),El)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),El)},killLine:function(e){Rn(e,function(t){if(t.empty()){var n=Yr(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:Wo(t.head.line+1,0)}:{from:t.head,to:Wo(t.head.line,n)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){Rn(e,function(t){return{from:Wo(t.from().line,0),to:me(e.doc,Wo(t.to().line+1,0))}})},delLineLeft:function(e){Rn(e,function(e){return{from:Wo(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){Rn(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){Rn(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div");return{from:t.from(),to:r}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(Wo(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(Wo(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return io(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return lo(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return oo(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")},Il)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")},Il)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return r.ch<e.getLine(r.line).search(/\S/)?lo(e,t.head):r},Il)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],n=e.listSelections(),r=e.options.tabSize,i=0;i<n.length;i++){var o=n[i].from(),l=Fl(e.getLine(o.line),o.ch,r);t.push(new Array(r-l%r+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Nt(e,function(){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++){var i=t[r].head,o=Yr(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new Wo(i.line,i.ch-1)),i.ch>0)i=new Wo(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Wo(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Yr(e.doc,i.line-1).text;l&&e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),Wo(i.line-1,l.length-1),Wo(i.line,1),"+transpose")}n.push(new de(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){Nt(e,function(){for(var t=e.listSelections().length,n=0;t>n;n++){var r=e.listSelections()[n];e.replaceRange(e.doc.lineSeparator(),r.anchor,r.head,"+input"),e.indentLine(r.from().line+1,null,!0),Pn(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},al=e.keyMap={};al.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},al.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},al.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},al.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},al["default"]=To?al.macDefault:al.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if("..."==r){delete e[n];continue}for(var i=Ei(n.split(" "),jn),o=0;o<i.length;o++){var l,a;o==i.length-1?(a=i.join(" "),l=r):(a=i.slice(0,o+1).join(" "),l="...");var s=t[a];if(s){if(s!=l)throw new Error("Inconsistent bindings for "+a)}else t[a]=l}delete e[n]}for(var u in t)e[u]=t[u];return e};var sl=e.lookupKey=function(e,t,n,r){t=$n(t);var i=t.call?t.call(e,r):t[e];if(i===!1)return"nothing";if("..."===i)return"multi";if(null!=i&&n(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return sl(e,t.fallthrough,n,r);for(var o=0;o<t.fallthrough.length;o++){var l=sl(e,t.fallthrough[o],n,r);if(l)return l}}},ul=e.isModifierKey=function(e){var t="string"==typeof e?e:ta[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t},cl=e.keyName=function(e,t){if(wo&&34==e.keyCode&&e["char"])return!1;var n=ta[e.keyCode],r=n;return null==r||e.altGraphKey?!1:(e.altKey&&"Alt"!=n&&(r="Alt-"+r),(Do?e.metaKey:e.ctrlKey)&&"Ctrl"!=n&&(r="Ctrl-"+r),(Do?e.ctrlKey:e.metaKey)&&"Cmd"!=n&&(r="Cmd-"+r),!t&&e.shiftKey&&"Shift"!=n&&(r="Shift-"+r),r)};e.fromTextArea=function(t,n){function r(){t.value=u.getValue()}if(n=n?Fi(n):{},n.value=t.value,!n.tabindex&&t.tabIndex&&(n.tabindex=t.tabIndex),!n.placeholder&&t.placeholder&&(n.placeholder=t.placeholder),null==n.autofocus){var i=Gi();n.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body}if(t.form&&(Ml(t.form,"submit",r),!n.leaveSubmitMethodAlone)){var o=t.form,l=o.submit;try{var a=o.submit=function(){r(),o.submit=l,o.submit(),o.submit=a}}catch(s){}}n.finishInit=function(e){e.save=r,e.getTextArea=function(){return t},e.toTextArea=function(){e.toTextArea=isNaN,r(),t.parentNode.removeChild(e.getWrapperElement()),t.style.display="",t.form&&(Nl(t.form,"submit",r),"function"==typeof t.form.submit&&(t.form.submit=l))}},t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},n);return u};var hl=e.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};hl.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var n=t==e;else var n=t&&(e.test?e.test(t):e(t));return n?(++this.pos,t):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Fl(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Fl(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Fl(this.string,null,this.tabSize)-(this.lineStart?Fl(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,n){if("string"!=typeof e){var r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}var i=function(e){return n?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var dl=0,fl=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++dl};Ni(fl),fl.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&bt(e),Ti(this,"clear")){var n=this.find();n&&Si(this,"clear",n.from,n.to)}for(var r=null,i=null,o=0;o<this.lines.length;++o){var l=this.lines[o],a=Jn(l.markedSpans,this);e&&!this.collapsed?It(e,ei(l),"text"):e&&(null!=a.to&&(i=ei(l)),null!=a.from&&(r=ei(l))),l.markedSpans=er(l.markedSpans,a),null==a.from&&this.collapsed&&!wr(this.doc,l)&&e&&Jr(l,vt(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var o=0;o<this.lines.length;++o){var s=vr(this.lines[o]),u=h(s);u>e.display.maxLineLength&&(e.display.maxLine=s,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&Wt(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&De(e.doc)),e&&Si(e,"markerCleared",e,this),t&&wt(e),this.parent&&this.parent.clear()}},fl.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var n,r,i=0;i<this.lines.length;++i){var o=this.lines[i],l=Jn(o.markedSpans,this);if(null!=l.from&&(n=Wo(t?o:ei(o),l.from),-1==e))return n;if(null!=l.to&&(r=Wo(t?o:ei(o),l.to),1==e))return r}return n&&{from:n,to:r}},fl.prototype.changed=function(){var e=this.find(-1,!0),t=this,n=this.doc.cm;e&&n&&Nt(n,function(){var r=e.line,i=ei(e.line),o=Qe(n,i);if(o&&(it(o),n.curOp.selectionChanged=n.curOp.forceUpdate=!0),n.curOp.updateMaxLine=!0,!wr(t.doc,r)&&null!=t.height){var l=t.height;t.height=null;var a=kr(t)-l;a&&Jr(r,r.height+a)}})},fl.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=Oi(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},fl.prototype.detachLine=function(e){if(this.lines.splice(Oi(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var dl=0,pl=e.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};Ni(pl),pl.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();Si(this,"clear")}},pl.prototype.find=function(e,t){return this.primary.find(e,t)};var gl=e.LineWidget=function(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.doc=e,this.node=t};Ni(gl),gl.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,n=this.line,r=ei(n);if(null!=r&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(n.widgets=null);var o=kr(this);Jr(n,Math.max(0,n.height-o)),e&&Nt(e,function(){Sr(e,n,-o),It(e,r,"widget")})}},gl.prototype.changed=function(){var e=this.height,t=this.doc.cm,n=this.line;this.height=null;var r=kr(this)-e;r&&(Jr(n,n.height+r),t&&Nt(t,function(){t.curOp.forceUpdate=!0,Sr(t,n,r)}))};var ml=e.Line=function(e,t,n){this.text=e,ur(this,t),this.height=n?n(this):1};Ni(ml),ml.prototype.lineNo=function(){return ei(this)};var vl={},yl={};$r.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=e,r=e+t;r>n;++n){var i=this.lines[n];this.height-=i.height,Tr(i),Si(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,n){for(var r=e+t;r>e;++e)if(n(this.lines[e]))return!0}},Vr.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;n<this.children.length;++n){var r=this.children[n],i=r.chunkSize();if(i>e){var o=Math.min(t,i-e),l=r.height;if(r.removeInner(e,o),this.height-=l-r.height,i==o&&(this.children.splice(n--,1),r.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof $r))){var a=[];this.collapse(a),this.children=[new $r(a)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0;r<this.children.length;++r){var i=this.children[r],o=i.chunkSize();if(o>=e){if(i.insertInner(e,t,n),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var l=i.lines.splice(i.lines.length-25,25),a=new $r(l);i.height-=a.height,this.children.splice(r+1,0,a),a.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),n=new Vr(t);if(e.parent){e.size-=n.size,e.height-=n.height;var r=Oi(e.parent.children,e);e.parent.children.splice(r+1,0,n)}else{var i=new Vr(e.children);i.parent=e,e.children=[i,n],e=i}n.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;r<this.children.length;++r){var i=this.children[r],o=i.chunkSize();if(o>e){var l=Math.min(t,o-e);if(i.iterN(e,l,n))return!0;if(0==(t-=l))break;e=0}else e-=o}}};var bl=0,xl=e.Doc=function(e,t,n,r){if(!(this instanceof xl))return new xl(e,t,n,r);null==n&&(n=0),Vr.call(this,[new $r([new ml("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=n;var i=Wo(n,0);this.sel=pe(i),this.history=new ii(null),this.id=++bl,this.modeOption=t,this.lineSep=r,"string"==typeof e&&(e=this.splitLines(e)),jr(this,{from:i,to:i,text:e}),Te(this,pe(i),El)};xl.prototype=Ii(Vr.prototype,{constructor:xl,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var n=0,r=0;r<t.length;++r)n+=t[r].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Qr(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:Ht(function(e){var t=Wo(this.first,0),n=this.first+this.size-1;Ln(this,{from:t,to:Wo(n,Yr(this,n).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),Te(this,pe(t))}),replaceRange:function(e,t,n,r){t=me(this,t),n=n?me(this,n):t,Hn(this,e,t,n,r)},getRange:function(e,t,n){var r=Zr(this,me(this,e),me(this,t));return n===!1?r:r.join(n||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){return ye(this,e)?Yr(this,e):void 0},getLineNumber:function(e){return ei(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=Yr(this,e)),vr(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return me(this,e)},getCursor:function(e){var t,n=this.sel.primary();return t=null==e||"head"==e?n.head:"anchor"==e?n.anchor:"end"==e||"to"==e||e===!1?n.to():n.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:Ht(function(e,t,n){ke(this,me(this,"number"==typeof e?Wo(e,t||0):e),null,n)}),setSelection:Ht(function(e,t,n){ke(this,me(this,e),me(this,t||e),n)}),extendSelection:Ht(function(e,t,n){we(this,me(this,e),t&&me(this,t),n)}),extendSelections:Ht(function(e,t){Ce(this,be(this,e,t))}),extendSelectionsBy:Ht(function(e,t){Ce(this,Ei(this.sel.ranges,e),t)}),setSelections:Ht(function(e,t,n){if(e.length){for(var r=0,i=[];r<e.length;r++)i[r]=new de(me(this,e[r].anchor),me(this,e[r].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),Te(this,fe(i,t),n)}}),addSelection:Ht(function(e,t,n){var r=this.sel.ranges.slice(0);r.push(new de(me(this,e),me(this,t||e))),Te(this,fe(r,r.length-1),n)}),getSelection:function(e){for(var t,n=this.sel.ranges,r=0;r<n.length;r++){var i=Zr(this,n[r].from(),n[r].to());t=t?t.concat(i):i}return e===!1?t:t.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],n=this.sel.ranges,r=0;r<n.length;r++){var i=Zr(this,n[r].from(),n[r].to());e!==!1&&(i=i.join(e||this.lineSeparator())),t[r]=i}return t},replaceSelection:function(e,t,n){for(var r=[],i=0;i<this.sel.ranges.length;i++)r[i]=e;this.replaceSelections(r,t,n||"+input")},replaceSelections:Ht(function(e,t,n){for(var r=[],i=this.sel,o=0;o<i.ranges.length;o++){var l=i.ranges[o];r[o]={from:l.from(),to:l.to(),text:this.splitLines(e[o]),origin:n}}for(var a=t&&"end"!=t&&Sn(this,r,t),o=r.length-1;o>=0;o--)Ln(this,r[o]);a?Me(this,a):this.cm&&Pn(this.cm)}),undo:Ht(function(){Tn(this,"undo")}),redo:Ht(function(){Tn(this,"redo")}),undoSelection:Ht(function(){Tn(this,"undo",!0)}),redoSelection:Ht(function(){Tn(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var r=0;r<e.undone.length;r++)e.undone[r].ranges||++n;return{undo:t,redo:n}},clearHistory:function(){this.history=new ii(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:gi(this.history.done),undone:gi(this.history.undone)}},setHistory:function(e){var t=this.history=new ii(this.history.maxGeneration);t.done=gi(e.done.slice(0),null,!0),t.undone=gi(e.undone.slice(0),null,!0)},addLineClass:Ht(function(e,t,n){return _n(this,e,"gutter"==t?"gutter":"class",function(e){var r="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[r]){if(ji(n).test(e[r]))return!1;e[r]+=" "+n}else e[r]=n;return!0})}),removeLineClass:Ht(function(e,t,n){return _n(this,e,"gutter"==t?"gutter":"class",function(e){var r="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",i=e[r];if(!i)return!1;if(null==n)e[r]=null;else{var o=i.match(ji(n));if(!o)return!1;var l=o.index+o[0].length;e[r]=i.slice(0,o.index)+(o.index&&l!=i.length?" ":"")+i.slice(l)||null}return!0})}),addLineWidget:Ht(function(e,t,n){return Lr(this,e,t,n)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,n){return Vn(this,me(this,e),me(this,t),n,"range")},setBookmark:function(e,t){var n={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=me(this,e),Vn(this,e,e,n,"bookmark")},findMarksAt:function(e){e=me(this,e);var t=[],n=Yr(this,e.line).markedSpans;if(n)for(var r=0;r<n.length;++r){var i=n[r];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=me(this,e),t=me(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var a=0;a<l.length;a++){var s=l[a];i==e.line&&e.ch>s.to||null==s.from&&i!=e.line||i==t.line&&s.from>t.ch||n&&!n(s.marker)||r.push(s.marker.parent||s.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;r<n.length;++r)null!=n[r].from&&e.push(n[r].marker)}),e},posFromIndex:function(e){var t,n=this.first;return this.iter(function(r){var i=r.text.length+1;return i>e?(t=e,!0):(e-=i,void++n)}),me(this,Wo(n,t))},indexFromPos:function(e){e=me(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new xl(Qr(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,n=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<n&&(n=e.to);var r=new xl(Qr(this,t,n),e.mode||this.modeOption,t,this.lineSep);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Yn(r,Xn(this)),r},unlinkDoc:function(t){if(t instanceof e&&(t=t.doc),this.linked)for(var n=0;n<this.linked.length;++n){var r=this.linked[n];if(r.doc==t){this.linked.splice(n,1),t.unlinkDoc(this),Zn(Xn(this));break}}if(t.history==this.history){var i=[t.id];Kr(t,function(e){i.push(e.id)},!0),t.history=new ii(null),t.history.done=gi(this.history.done,i),t.history.undone=gi(this.history.undone,i)}},iterLinkedDocs:function(e){Kr(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Zl(e)},lineSeparator:function(){return this.lineSep||"\n"}}),xl.prototype.eachLine=xl.prototype.iter;var wl="iter insert remove copy getEditor constructor".split(" ");for(var Cl in xl.prototype)xl.prototype.hasOwnProperty(Cl)&&Oi(wl,Cl)<0&&(e.prototype[Cl]=function(e){return function(){return e.apply(this.doc,arguments)}}(xl.prototype[Cl]));Ni(xl);var Sl=e.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},kl=e.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},Ll=e.e_stop=function(e){Sl(e),kl(e)},Ml=e.on=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var r=e._handlers||(e._handlers={}),i=r[t]||(r[t]=[]);i.push(n)}},Tl=[],Nl=e.off=function(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else for(var r=Ci(e,t,!1),i=0;i<r.length;++i)if(r[i]==n){r.splice(i,1);break}},Al=e.signal=function(e,t){var n=Ci(e,t,!0);if(n.length)for(var r=Array.prototype.slice.call(arguments,2),i=0;i<n.length;++i)n[i].apply(null,r)},Dl=null,Hl=30,Ol=e.Pass={toString:function(){return"CodeMirror.Pass"}},El={scroll:!1},Wl={origin:"*mouse"},Il={origin:"+move"};Ai.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Fl=e.countColumn=function(e,t,n,r,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=r||0,l=i||0;;){var a=e.indexOf(" ",o);if(0>a||a>=t)return l+(t-o);l+=a-o,l+=n-l%n,o=a+1}},Pl=e.findColumn=function(e,t,n){for(var r=0,i=0;;){var o=e.indexOf(" ",r);-1==o&&(o=e.length);var l=o-r;if(o==e.length||i+l>=t)return r+Math.min(l,t-i);if(i+=o-r,i+=n-i%n,r=o+1,i>=t)return r}},Bl=[""],zl=function(e){e.select()};Lo?zl=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:mo&&(zl=function(e){try{e.select()}catch(t){}});var _l,Rl=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,ql=e.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Rl.test(e))},Ul=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;_l=document.createRange?function(e,t,n,r){var i=document.createRange();return i.setEnd(r||e,n),i.setStart(e,t),i}:function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(i){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r};var Gl=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};mo&&11>vo&&(Gi=function(){try{return document.activeElement}catch(e){return document.body}});var jl,$l,Vl=e.rmClass=function(e,t){var n=e.className,r=ji(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}},Kl=e.addClass=function(e,t){var n=e.className;ji(t).test(n)||(e.className+=(n?" ":"")+t)},Xl=!1,Yl=function(){if(mo&&9>vo)return!1;var e=Ri("div");return"draggable"in e||"dragDrop"in e}(),Zl=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;r>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");-1!=l?(n.push(o.slice(0,l)),t+=l+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},Ql=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},Jl=function(){var e=Ri("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),ea=null,ta=e.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var e=0;10>e;e++)ta[e+48]=ta[e+96]=String(e);for(var e=65;90>=e;e++)ta[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)ta[e+111]=ta[e+63235]="F"+e}();var na,ra=function(){function e(e){return 247>=e?n.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?r.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,n){this.level=e,this.from=t,this.to=n}var n="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",r="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,a=/[Lb1n]/,s=/[1n]/,u="L";
12
+ return function(n){if(!i.test(n))return!1;for(var r,c=n.length,h=[],d=0;c>d;++d)h.push(r=e(n.charCodeAt(d)));for(var d=0,f=u;c>d;++d){var r=h[d];"m"==r?h[d]=f:f=r}for(var d=0,p=u;c>d;++d){var r=h[d];"1"==r&&"r"==p?h[d]="n":l.test(r)&&(p=r,"r"==r&&(h[d]="R"))}for(var d=1,f=h[0];c-1>d;++d){var r=h[d];"+"==r&&"1"==f&&"1"==h[d+1]?h[d]="1":","!=r||f!=h[d+1]||"1"!=f&&"n"!=f||(h[d]=f),f=r}for(var d=0;c>d;++d){var r=h[d];if(","==r)h[d]="N";else if("%"==r){for(var g=d+1;c>g&&"%"==h[g];++g);for(var m=d&&"!"==h[d-1]||c>g&&"1"==h[g]?"1":"N",v=d;g>v;++v)h[v]=m;d=g-1}}for(var d=0,p=u;c>d;++d){var r=h[d];"L"==p&&"1"==r?h[d]="L":l.test(r)&&(p=r)}for(var d=0;c>d;++d)if(o.test(h[d])){for(var g=d+1;c>g&&o.test(h[g]);++g);for(var y="L"==(d?h[d-1]:u),b="L"==(c>g?h[g]:u),m=y||b?"L":"R",v=d;g>v;++v)h[v]=m;d=g-1}for(var x,w=[],d=0;c>d;)if(a.test(h[d])){var C=d;for(++d;c>d&&a.test(h[d]);++d);w.push(new t(0,C,d))}else{var S=d,k=w.length;for(++d;c>d&&"L"!=h[d];++d);for(var v=S;d>v;)if(s.test(h[v])){v>S&&w.splice(k,0,new t(1,S,v));var L=v;for(++v;d>v&&s.test(h[v]);++v);w.splice(k,0,new t(2,L,v)),S=v}else++v;d>S&&w.splice(k,0,new t(1,S,d))}return 1==w[0].level&&(x=n.match(/^\s+/))&&(w[0].from=x[0].length,w.unshift(new t(0,0,x[0].length))),1==Hi(w).level&&(x=n.match(/\s+$/))&&(Hi(w).to-=x[0].length,w.push(new t(0,c-x[0].length,c))),2==w[0].level&&w.unshift(new t(1,w[0].to,w[0].to)),w[0].level!=Hi(w).level&&w.push(new t(w[0].level,c,c)),w}}();return e.version="5.7.1",e}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var t=/^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,n=/^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,r=/[*+-]\s/;e.commands.newlineAndIndentContinueMarkdownList=function(i){if(i.getOption("disableInput"))return e.Pass;for(var o=i.listSelections(),l=[],a=0;a<o.length;a++){var s=o[a].head,u=i.getStateAfter(s.line),c=u.list!==!1,h=0!==u.quote,d=i.getLine(s.line),f=t.exec(d);if(!o[a].empty()||!c&&!h||!f)return void i.execCommand("newlineAndIndent");if(n.test(d))i.replaceRange("",{line:s.line,ch:0},{line:s.line,ch:s.ch+1}),l[a]="\n";else{var p=f[1],g=f[5],m=r.test(f[2])||f[2].indexOf(">")>=0?f[2]:parseInt(f[3],10)+1+f[4];l[a]="\n"+p+m+g}}i.replaceSelections(l)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.commands.tabAndIndentMarkdownList=function(e){var t=e.listSelections(),n=t[0].head,r=e.getStateAfter(n.line),i=r.list!==!1;if(i)return void e.execCommand("indentMore");if(e.options.indentWithTabs)e.execCommand("insertTab");else{var o=Array(e.options.tabSize+1).join(" ");e.replaceSelection(o)}},e.commands.shiftTabAndUnindentMarkdownList=function(e){var t=e.listSelections(),n=t[0].head,r=e.getStateAfter(n.line),i=r.list!==!1;if(i)return void e.execCommand("indentLess");if(e.options.indentWithTabs)e.execCommand("insertTab");else{var o=Array(e.options.tabSize+1).join(" ");e.replaceSelection(o)}}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){var t=e.getWrapperElement();e.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:t.style.width,height:t.style.height},t.style.width="",t.style.height="auto",t.className+=" CodeMirror-fullscreen",document.documentElement.style.overflow="hidden",e.refresh()}function n(e){var t=e.getWrapperElement();t.className=t.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="";var n=e.state.fullScreenRestore;t.style.width=n.width,t.style.height=n.height,window.scrollTo(n.scrollLeft,n.scrollTop),e.refresh()}e.defineOption("fullScreen",!1,function(r,i,o){o==e.Init&&(o=!1),!o!=!i&&(i?t(r):n(r))})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../xml/xml"),require("../meta")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../meta"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("markdown",function(t,n){function r(n){if(e.findModeByName){var r=e.findModeByName(n);r&&(n=r.mime||r.mimes[0])}var i=e.getMode(t,n);return"null"==i.name?null:i}function i(e,t,n){return t.f=t.inline=n,n(e,t)}function o(e,t,n){return t.f=t.block=n,n(e,t)}function l(e){return!e||!/\S/.test(e.string)}function a(e){return e.linkTitle=!1,e.em=!1,e.strong=!1,e.strikethrough=!1,e.quote=0,e.indentedCode=!1,C||e.f!=u||(e.f=p,e.block=s),e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.prevLine=e.thisLine,e.thisLine=null,null}function s(e,t){var o=e.sol(),a=t.list!==!1,s=t.indentedCode;t.indentedCode=!1,a&&(t.indentationDiff>=0?(t.indentationDiff<4&&(t.indentation-=t.indentationDiff),t.list=null):t.indentation>0?(t.list=null,t.listDepth=Math.floor(t.indentation/4)):(t.list=!1,t.listDepth=0));var u=null;if(t.indentationDiff>=4)return e.skipToEnd(),s||l(t.prevLine)?(t.indentation-=4,t.indentedCode=!0,M):null;if(e.eatSpace())return null;if((u=e.match(j))&&u[1].length<=6)return t.header=u[1].length,n.highlightFormatting&&(t.formatting="header"),t.f=t.inline,d(t);if(!(l(t.prevLine)||t.quote||a||s)&&(u=e.match($)))return t.header="="==u[0].charAt(0)?1:2,n.highlightFormatting&&(t.formatting="header"),t.f=t.inline,d(t);if(e.eat(">"))return t.quote=o?1:t.quote+1,n.highlightFormatting&&(t.formatting="quote"),e.eatSpace(),d(t);if("["===e.peek())return i(e,t,y);if(e.match(R,!0))return t.hr=!0,H;if((l(t.prevLine)||a)&&(e.match(q,!1)||e.match(U,!1))){var h=null;return e.match(q,!0)?h="ul":(e.match(U,!0),h="ol"),t.indentation=e.column()+e.current().length,t.list=!0,t.listDepth++,n.taskLists&&e.match(G,!1)&&(t.taskList=!0),t.f=t.inline,n.highlightFormatting&&(t.formatting=["list","list-"+h]),d(t)}return n.fencedCodeBlocks&&(u=e.match(K,!0))?(t.fencedChars=u[1],t.localMode=r(u[2]),t.localMode&&(t.localState=t.localMode.startState()),t.f=t.block=c,n.highlightFormatting&&(t.formatting="code-block"),t.code=!0,d(t)):i(e,t,t.inline)}function u(e,t){var n=S.token(e,t.htmlState);return(C&&null===t.htmlState.tagStart&&!t.htmlState.context&&t.htmlState.tokenize.isInText||t.md_inside&&e.current().indexOf(">")>-1)&&(t.f=p,t.block=s,t.htmlState=null),n}function c(e,t){return e.sol()&&t.fencedChars&&e.match(t.fencedChars,!1)?(t.localMode=t.localState=null,t.f=t.block=h,null):t.localMode?t.localMode.token(e,t.localState):(e.skipToEnd(),M)}function h(e,t){e.match(t.fencedChars),t.block=s,t.f=p,t.fencedChars=null,n.highlightFormatting&&(t.formatting="code-block"),t.code=!0;var r=d(t);return t.code=!1,r}function d(e){var t=[];if(e.formatting){t.push(E),"string"==typeof e.formatting&&(e.formatting=[e.formatting]);for(var r=0;r<e.formatting.length;r++)t.push(E+"-"+e.formatting[r]),"header"===e.formatting[r]&&t.push(E+"-"+e.formatting[r]+"-"+e.header),"quote"===e.formatting[r]&&(!n.maxBlockquoteDepth||n.maxBlockquoteDepth>=e.quote?t.push(E+"-"+e.formatting[r]+"-"+e.quote):t.push("error"))}if(e.taskOpen)return t.push("meta"),t.length?t.join(" "):null;if(e.taskClosed)return t.push("property"),t.length?t.join(" "):null;if(e.linkHref?t.push(P,"url"):(e.strong&&t.push(z),e.em&&t.push(B),e.strikethrough&&t.push(_),e.linkText&&t.push(F),e.code&&t.push(M)),e.header&&(t.push(L),t.push(L+"-"+e.header)),e.quote&&(t.push(T),!n.maxBlockquoteDepth||n.maxBlockquoteDepth>=e.quote?t.push(T+"-"+e.quote):t.push(T+"-"+n.maxBlockquoteDepth)),e.list!==!1){var i=(e.listDepth-1)%3;i?1===i?t.push(A):t.push(D):t.push(N)}return e.trailingSpaceNewLine?t.push("trailing-space-new-line"):e.trailingSpace&&t.push("trailing-space-"+(e.trailingSpace%2?"a":"b")),t.length?t.join(" "):null}function f(e,t){return e.match(V,!0)?d(t):void 0}function p(t,r){var i=r.text(t,r);if("undefined"!=typeof i)return i;if(r.list)return r.list=null,d(r);if(r.taskList){var l="x"!==t.match(G,!0)[1];return l?r.taskOpen=!0:r.taskClosed=!0,n.highlightFormatting&&(r.formatting="task"),r.taskList=!1,d(r)}if(r.taskOpen=!1,r.taskClosed=!1,r.header&&t.match(/^#+$/,!0))return n.highlightFormatting&&(r.formatting="header"),d(r);var a=t.sol(),s=t.next();if("\\"===s&&(t.next(),n.highlightFormatting)){var c=d(r);return c?c+" formatting-escape":"formatting-escape"}if(r.linkTitle){r.linkTitle=!1;var h=s;"("===s&&(h=")"),h=(h+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var f="^\\s*(?:[^"+h+"\\\\]+|\\\\\\\\|\\\\.)"+h;if(t.match(new RegExp(f),!0))return P}if("`"===s){var p=r.formatting;n.highlightFormatting&&(r.formatting="code");var v=d(r),y=t.pos;t.eatWhile("`");var b=1+t.pos-y;return r.code?b===k?(r.code=!1,v):(r.formatting=p,d(r)):(k=b,r.code=!0,d(r))}if(r.code)return d(r);if("!"===s&&t.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return t.match(/\[[^\]]*\]/),r.inline=r.f=m,O;if("["===s&&t.match(/.*\](\(.*\)| ?\[.*\])/,!1))return r.linkText=!0,n.highlightFormatting&&(r.formatting="link"),d(r);if("]"===s&&r.linkText&&t.match(/\(.*\)| ?\[.*\]/,!1)){n.highlightFormatting&&(r.formatting="link");var c=d(r);return r.linkText=!1,r.inline=r.f=m,c}if("<"===s&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=g,n.highlightFormatting&&(r.formatting="link");var c=d(r);return c?c+=" ":c="",c+W}if("<"===s&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=g,n.highlightFormatting&&(r.formatting="link");var c=d(r);return c?c+=" ":c="",c+I}if("<"===s&&t.match(/^(!--|\w)/,!1)){var x=t.string.indexOf(">",t.pos);if(-1!=x){var w=t.string.substring(t.start,x);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(w)&&(r.md_inside=!0)}return t.backUp(1),r.htmlState=e.startState(S),o(t,r,u)}if("<"===s&&t.match(/^\/\w*?>/))return r.md_inside=!1,"tag";var C=!1;if(!n.underscoresBreakWords&&"_"===s&&"_"!==t.peek()&&t.match(/(\w)/,!1)){var L=t.pos-2;if(L>=0){var M=t.string.charAt(L);"_"!==M&&M.match(/(\w)/,!1)&&(C=!0)}}if("*"===s||"_"===s&&!C)if(a&&" "===t.peek());else{if(r.strong===s&&t.eat(s)){n.highlightFormatting&&(r.formatting="strong");var v=d(r);return r.strong=!1,v}if(!r.strong&&t.eat(s))return r.strong=s,n.highlightFormatting&&(r.formatting="strong"),d(r);if(r.em===s){n.highlightFormatting&&(r.formatting="em");var v=d(r);return r.em=!1,v}if(!r.em)return r.em=s,n.highlightFormatting&&(r.formatting="em"),d(r)}else if(" "===s&&(t.eat("*")||t.eat("_"))){if(" "===t.peek())return d(r);t.backUp(1)}if(n.strikethrough)if("~"===s&&t.eatWhile(s)){if(r.strikethrough){n.highlightFormatting&&(r.formatting="strikethrough");var v=d(r);return r.strikethrough=!1,v}if(t.match(/^[^\s]/,!1))return r.strikethrough=!0,n.highlightFormatting&&(r.formatting="strikethrough"),d(r)}else if(" "===s&&t.match(/^~~/,!0)){if(" "===t.peek())return d(r);t.backUp(2)}return" "===s&&(t.match(/ +$/,!1)?r.trailingSpace++:r.trailingSpace&&(r.trailingSpaceNewLine=!0)),d(r)}function g(e,t){var r=e.next();if(">"===r){t.f=t.inline=p,n.highlightFormatting&&(t.formatting="link");var i=d(t);return i?i+=" ":i="",i+W}return e.match(/^[^>]+/,!0),W}function m(e,t){if(e.eatSpace())return null;var r=e.next();return"("===r||"["===r?(t.f=t.inline=v("("===r?")":"]"),n.highlightFormatting&&(t.formatting="link-string"),t.linkHref=!0,d(t)):"error"}function v(e){return function(t,r){var i=t.next();if(i===e){r.f=r.inline=p,n.highlightFormatting&&(r.formatting="link-string");var o=d(r);return r.linkHref=!1,o}return t.match(w(e),!0)&&t.backUp(1),r.linkHref=!0,d(r)}}function y(e,t){return e.match(/^[^\]]*\]:/,!1)?(t.f=b,e.next(),n.highlightFormatting&&(t.formatting="link"),t.linkText=!0,d(t)):i(e,t,p)}function b(e,t){if(e.match(/^\]:/,!0)){t.f=t.inline=x,n.highlightFormatting&&(t.formatting="link");var r=d(t);return t.linkText=!1,r}return e.match(/^[^\]]+/,!0),F}function x(e,t){return e.eatSpace()?null:(e.match(/^[^\s]+/,!0),void 0===e.peek()?t.linkTitle=!0:e.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),t.f=t.inline=p,P+" url")}function w(e){return X[e]||(e=(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),X[e]=new RegExp("^(?:[^\\\\]|\\\\.)*?("+e+")")),X[e]}var C=e.modes.hasOwnProperty("xml"),S=e.getMode(t,C?{name:"xml",htmlMode:!0}:"text/plain");void 0===n.highlightFormatting&&(n.highlightFormatting=!1),void 0===n.maxBlockquoteDepth&&(n.maxBlockquoteDepth=0),void 0===n.underscoresBreakWords&&(n.underscoresBreakWords=!0),void 0===n.taskLists&&(n.taskLists=!1),void 0===n.strikethrough&&(n.strikethrough=!1);var k=0,L="header",M="comment",T="quote",N="variable-2",A="variable-3",D="keyword",H="hr",O="tag",E="formatting",W="link",I="link",F="link",P="string",B="em",z="strong",_="strikethrough",R=/^([*\-_])(?:\s*\1){2,}\s*$/,q=/^[*\-+]\s+/,U=/^[0-9]+([.)])\s+/,G=/^\[(x| )\](?=\s)/,j=n.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,$=/^ *(?:\={1,}|-{1,})\s*$/,V=/^[^#!\[\]*_\\<>` "'(~]+/,K=new RegExp("^("+(n.fencedCodeBlocks===!0?"~~~+|```+":n.fencedCodeBlocks)+")[ \\t]*([\\w+#]*)"),X=[],Y={startState:function(){return{f:s,prevLine:null,thisLine:null,block:s,htmlState:null,indentation:0,inline:p,text:f,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,em:!1,strong:!1,header:0,hr:!1,taskList:!1,list:!1,listDepth:0,quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,fencedChars:null}},copyState:function(t){return{f:t.f,prevLine:t.prevLine,thisLine:t["this"],block:t.block,htmlState:t.htmlState&&e.copyState(S,t.htmlState),indentation:t.indentation,localMode:t.localMode,localState:t.localMode?e.copyState(t.localMode,t.localState):null,inline:t.inline,text:t.text,formatting:!1,linkTitle:t.linkTitle,code:t.code,em:t.em,strong:t.strong,strikethrough:t.strikethrough,header:t.header,hr:t.hr,taskList:t.taskList,list:t.list,listDepth:t.listDepth,quote:t.quote,indentedCode:t.indentedCode,trailingSpace:t.trailingSpace,trailingSpaceNewLine:t.trailingSpaceNewLine,md_inside:t.md_inside,fencedChars:t.fencedChars}},token:function(e,t){if(t.formatting=!1,e!=t.thisLine){var n=t.header||t.hr;if(t.header=0,t.hr=!1,e.match(/^\s*$/,!0)||n){if(a(t),!n)return null;t.prevLine=null}t.prevLine=t.thisLine,t.thisLine=e,t.taskList=!1,t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.f=t.block;var r=e.match(/^\s*/,!0)[0].replace(/\t/g," ").length,i=4*Math.floor((r-t.indentation)/4);i>4&&(i=4);var o=t.indentation+i;if(t.indentationDiff=o-t.indentation,t.indentation=o,r>0)return null}return t.f(e,t)},innerMode:function(e){return e.block==u?{state:e.htmlState,mode:S}:e.localState?{state:e.localState,mode:e.localMode}:{state:e,mode:Y}},blankLine:a,getType:d,fold:"markdown"};return Y},"xml"),e.defineMIME("text/x-markdown","markdown")}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.overlayMode=function(t,n,r){return{startState:function(){return{base:e.startState(t),overlay:e.startState(n),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(r){return{base:e.copyState(t,r.base),overlay:e.copyState(n,r.overlay),basePos:r.basePos,baseCur:null,overlayPos:r.overlayPos,overlayCur:null}},token:function(e,i){return(e!=i.streamSeen||Math.min(i.basePos,i.overlayPos)<e.start)&&(i.streamSeen=e,i.basePos=i.overlayPos=e.start),e.start==i.basePos&&(i.baseCur=t.token(e,i.base),i.basePos=e.pos),e.start==i.overlayPos&&(e.pos=e.start,i.overlayCur=n.token(e,i.overlay),i.overlayPos=e.pos),e.pos=Math.min(i.basePos,i.overlayPos),null==i.overlayCur?i.baseCur:null!=i.baseCur&&i.overlay.combineTokens||r&&null==i.overlay.combineTokens?i.baseCur+" "+i.overlayCur:i.overlayCur},indent:t.indent&&function(e,n){return t.indent(e.base,n)},electricChars:t.electricChars,innerMode:function(e){return{state:e.base,mode:t}},blankLine:function(e){t.blankLine&&t.blankLine(e.base),n.blankLine&&n.blankLine(e.overlay)}}}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../markdown/markdown"),require("../../addon/mode/overlay")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../markdown/markdown","../../addon/mode/overlay"],e):e(CodeMirror)}(function(e){"use strict";var t=/^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i;e.defineMode("gfm",function(n,r){function i(e){return e.code=!1,null}var o=0,l={startState:function(){return{code:!1,codeBlock:!1,ateSpace:!1}},copyState:function(e){return{code:e.code,codeBlock:e.codeBlock,ateSpace:e.ateSpace}},token:function(e,n){if(n.combineTokens=null,n.codeBlock)return e.match(/^```+/)?(n.codeBlock=!1,null):(e.skipToEnd(),null);if(e.sol()&&(n.code=!1),e.sol()&&e.match(/^```+/))return e.skipToEnd(),n.codeBlock=!0,null;if("`"===e.peek()){e.next();var i=e.pos;e.eatWhile("`");var l=1+e.pos-i;return n.code?l===o&&(n.code=!1):(o=l,n.code=!0),null}if(n.code)return e.next(),null;if(e.eatSpace())return n.ateSpace=!0,null;if((e.sol()||n.ateSpace)&&(n.ateSpace=!1,r.gitHubSpice!==!1)){if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/))return n.combineTokens=!0,"link";if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/))return n.combineTokens=!0,"link"}return e.match(t)&&"]("!=e.string.slice(e.start-2,e.start)&&(0==e.start||/\W/.test(e.string.charAt(e.start-1)))?(n.combineTokens=!0,"link"):(e.next(),null)},blankLine:i},a={underscoresBreakWords:!1,taskLists:!0,fencedCodeBlocks:"```",strikethrough:!0};for(var s in r)a[s]=r[s];return a.name="markdown",e.overlayMode(e.getMode(n,a),l)},"markdown"),e.defineMIME("text/x-gfm","gfm")}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("xml",function(t,n){function r(e,t){function n(n){return t.tokenize=n,n(e,t)}var r=e.next();if("<"==r)return e.eat("!")?e.eat("[")?e.match("CDATA[")?n(l("atom","]]>")):null:e.match("--")?n(l("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(a(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=l("meta","?>"),"meta"):(S=e.eat("/")?"closeTag":"openTag",t.tokenize=i,"tag bracket");if("&"==r){var o;return o=e.eat("#")?e.eat("x")?e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):e.eatWhile(/[\d]/)&&e.eat(";"):e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),o?"atom":"error"}return e.eatWhile(/[^&<]/),null}function i(e,t){var n=e.next();if(">"==n||"/"==n&&e.eat(">"))return t.tokenize=r,S=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return S="equals",null;if("<"==n){t.tokenize=r,t.state=h,t.tagName=t.tagStart=null;var i=t.tokenize(e,t);return i?i+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=o(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function o(e){var t=function(t,n){for(;!t.eol();)if(t.next()==e){n.tokenize=i;break}return"string"};return t.isInAttribute=!0,t}function l(e,t){return function(n,i){for(;!n.eol();){if(n.match(t)){i.tokenize=r;break}n.next()}return e}}function a(e){return function(t,n){for(var i;null!=(i=t.next());){if("<"==i)return n.tokenize=a(e+1),n.tokenize(t,n);if(">"==i){if(1==e){n.tokenize=r;break}return n.tokenize=a(e-1),n.tokenize(t,n)}}return"meta"}}function s(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n,(L.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)&&(this.noIndent=!0)}function u(e){e.context&&(e.context=e.context.prev)}function c(e,t){for(var n;;){if(!e.context)return;if(n=e.context.tagName,!L.contextGrabbers.hasOwnProperty(n)||!L.contextGrabbers[n].hasOwnProperty(t))return;u(e)}}function h(e,t,n){return"openTag"==e?(n.tagStart=t.column(),d):"closeTag"==e?f:h}function d(e,t,n){return"word"==e?(n.tagName=t.current(),k="tag",m):(k="error",d)}function f(e,t,n){if("word"==e){var r=t.current();return n.context&&n.context.tagName!=r&&L.implicitlyClosed.hasOwnProperty(n.context.tagName)&&u(n),n.context&&n.context.tagName==r?(k="tag",p):(k="tag error",g)}return k="error",g}function p(e,t,n){return"endTag"!=e?(k="error",p):(u(n),h)}function g(e,t,n){return k="error",p(e,t,n)}function m(e,t,n){if("word"==e)return k="attribute",v;if("endTag"==e||"selfcloseTag"==e){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==e||L.autoSelfClosers.hasOwnProperty(r)?c(n,r):(c(n,r),n.context=new s(n,r,i==n.indented)),h}return k="error",m}function v(e,t,n){return"equals"==e?y:(L.allowMissing||(k="error"),m(e,t,n))}function y(e,t,n){return"string"==e?b:"word"==e&&L.allowUnquoted?(k="string",m):(k="error",m(e,t,n))}function b(e,t,n){return"string"==e?b:m(e,t,n)}var x=t.indentUnit,w=n.multilineTagIndentFactor||1,C=n.multilineTagIndentPastTag;null==C&&(C=!0);var S,k,L=n.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},M=n.alignCDATA;return r.isInText=!0,{startState:function(){return{tokenize:r,state:h,indented:0,tagName:null,tagStart:null,context:null}},token:function(e,t){if(!t.tagName&&e.sol()&&(t.indented=e.indentation()),e.eatSpace())return null;S=null;var n=t.tokenize(e,t);return(n||S)&&"comment"!=n&&(k=null,t.state=t.state(S||n,e,t),k&&(n="error"==k?n+" error":k)),n},indent:function(t,n,o){var l=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+x;if(l&&l.noIndent)return e.Pass;if(t.tokenize!=i&&t.tokenize!=r)return o?o.match(/^(\s*)/)[0].length:0;if(t.tagName)return C?t.tagStart+t.tagName.length+2:t.tagStart+x*w;if(M&&/<!\[CDATA\[/.test(n))return 0;var a=n&&/^<(\/)?([\w_:\.-]*)/.exec(n);if(a&&a[1])for(;l;){if(l.tagName==a[2]){l=l.prev;break}if(!L.implicitlyClosed.hasOwnProperty(l.tagName))break;l=l.prev}else if(a)for(;l;){var s=L.contextGrabbers[l.tagName];if(!s||!s.hasOwnProperty(a[2]))break;l=l.prev}for(;l&&!l.startOfLine;)l=l.prev;return l?l.indent+x:0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:n.htmlMode?"html":"xml",helperType:n.htmlMode?"html":"xml"}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})});var Typo=function(e,t,n,r){if(r=r||{},this.platform=r.platform||"chrome",this.dictionary=null,this.rules={},this.dictionaryTable={},this.compoundRules=[],this.compoundRuleCodes={},this.replacementTable=[],this.flags=r.flags||{},e){if(this.dictionary=e,"chrome"==this.platform)t||(t=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+e+"/"+e+".aff"))),n||(n=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+e+"/"+e+".dic")));else{var i=r.dictionaryPath||"";t||(t=this._readFile(i+"/"+e+"/"+e+".aff")),n||(n=this._readFile(i+"/"+e+"/"+e+".dic"))}this.rules=this._parseAFF(t),this.compoundRuleCodes={};for(var o=0,l=this.compoundRules.length;l>o;o++)for(var a=this.compoundRules[o],s=0,u=a.length;u>s;s++)this.compoundRuleCodes[a[s]]=[];"ONLYINCOMPOUND"in this.flags&&(this.compoundRuleCodes[this.flags.ONLYINCOMPOUND]=[]),this.dictionaryTable=this._parseDIC(n);for(var o in this.compoundRuleCodes)0==this.compoundRuleCodes[o].length&&delete this.compoundRuleCodes[o];for(var o=0,l=this.compoundRules.length;l>o;o++){for(var c=this.compoundRules[o],h="",s=0,u=c.length;u>s;s++){var d=c[s];h+=d in this.compoundRuleCodes?"("+this.compoundRuleCodes[d].join("|")+")":d}this.compoundRules[o]=new RegExp(h,"i")}}return this};Typo.prototype={load:function(e){for(var t in e)this[t]=e[t];return this},_readFile:function(e,t){t||(t="ISO8859-1");var n=new XMLHttpRequest;return n.open("GET",e,!1),n.overrideMimeType&&n.overrideMimeType("text/plain; charset="+t),n.send(null),n.responseText},_parseAFF:function(e){var t={};e=this._removeAffixComments(e);for(var n=e.split("\n"),r=0,i=n.length;i>r;r++){var o=n[r],l=o.split(/\s+/),a=l[0];if("PFX"==a||"SFX"==a){for(var s=l[1],u=l[2],c=parseInt(l[3],10),h=[],d=r+1,f=r+1+c;f>d;d++){var o=n[d],p=o.split(/\s+/),g=p[2],m=p[3].split("/"),v=m[0];"0"===v&&(v="");var y=this.parseRuleCodes(m[1]),b=p[4],x={};x.add=v,y.length>0&&(x.continuationClasses=y),"."!==b&&("SFX"===a?x.match=new RegExp(b+"$"):x.match=new RegExp("^"+b)),"0"!=g&&("SFX"===a?x.remove=new RegExp(g+"$"):x.remove=g),h.push(x)}t[s]={type:a,combineable:"Y"==u,entries:h},r+=c}else if("COMPOUNDRULE"===a){for(var c=parseInt(l[1],10),d=r+1,f=r+1+c;f>d;d++){var o=n[d],p=o.split(/\s+/);this.compoundRules.push(p[1])}r+=c}else if("REP"===a){var p=o.split(/\s+/);3===p.length&&this.replacementTable.push([p[1],p[2]])}else this.flags[a]=l[1]}return t},_removeAffixComments:function(e){return e=e.replace(/#.*$/gm,""),e=e.replace(/^\s\s*/m,"").replace(/\s\s*$/m,""),e=e.replace(/\n{2,}/g,"\n"),e=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},_parseDIC:function(e){function t(e,t){e in r&&"object"==typeof r[e]||(r[e]=[]),r[e].push(t)}e=this._removeDicComments(e);for(var n=e.split("\n"),r={},i=1,o=n.length;o>i;i++){var l=n[i],a=l.split("/",2),s=a[0];if(a.length>1){var u=this.parseRuleCodes(a[1]);"NEEDAFFIX"in this.flags&&-1!=u.indexOf(this.flags.NEEDAFFIX)||t(s,u);for(var c=0,h=u.length;h>c;c++){var d=u[c],f=this.rules[d];if(f)for(var p=this._applyRule(s,f),g=0,m=p.length;m>g;g++){var v=p[g];if(t(v,[]),f.combineable)for(var y=c+1;h>y;y++){var b=u[y],x=this.rules[b];if(x&&x.combineable&&f.type!=x.type)for(var w=this._applyRule(v,x),C=0,S=w.length;S>C;C++){var k=w[C];t(k,[])}}}d in this.compoundRuleCodes&&this.compoundRuleCodes[d].push(s)}}else t(s.trim(),[])}return r},_removeDicComments:function(e){return e=e.replace(/^\t.*$/gm,"")},parseRuleCodes:function(e){if(!e)return[];if(!("FLAG"in this.flags))return e.split("");if("long"===this.flags.FLAG){for(var t=[],n=0,r=e.length;r>n;n+=2)t.push(e.substr(n,2));return t}return"num"===this.flags.FLAG?textCode.split(","):void 0},_applyRule:function(e,t){for(var n=t.entries,r=[],i=0,o=n.length;o>i;i++){var l=n[i];if(!l.match||e.match(l.match)){var a=e;if(l.remove&&(a=a.replace(l.remove,"")),"SFX"===t.type?a+=l.add:a=l.add+a,r.push(a),"continuationClasses"in l)for(var s=0,u=l.continuationClasses.length;u>s;s++){var c=this.rules[l.continuationClasses[s]];c&&(r=r.concat(this._applyRule(a,c)))}}}return r},check:function(e){var t=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(this.checkExact(t))return!0;if(t.toUpperCase()===t){var n=t[0]+t.substring(1).toLowerCase();if(this.hasFlag(n,"KEEPCASE"))return!1;if(this.checkExact(n))return!0}var r=t.toLowerCase();if(r!==t){if(this.hasFlag(r,"KEEPCASE"))return!1;if(this.checkExact(r))return!0}return!1},checkExact:function(e){var t=this.dictionaryTable[e];if("undefined"==typeof t){if("COMPOUNDMIN"in this.flags&&e.length>=this.flags.COMPOUNDMIN)for(var n=0,r=this.compoundRules.length;r>n;n++)if(e.match(this.compoundRules[n]))return!0;return!1}for(var n=0,r=t.length;r>n;n++)if(!this.hasFlag(e,"ONLYINCOMPOUND",t[n]))return!0;return!1},hasFlag:function(e,t,n){if(t in this.flags){if("undefined"==typeof n)var n=Array.prototype.concat.apply([],this.dictionaryTable[e]);if(n&&-1!==n.indexOf(this.flags[t]))return!0}return!1},alphabet:"",suggest:function(e,t){function n(e){for(var t=[],n=0,r=e.length;r>n;n++){for(var i=e[n],o=[],l=0,a=i.length+1;a>l;l++)o.push([i.substring(0,l),i.substring(l,i.length)]);for(var s=[],l=0,a=o.length;a>l;l++){var c=o[l];c[1]&&s.push(c[0]+c[1].substring(1))}for(var h=[],l=0,a=o.length;a>l;l++){var c=o[l];c[1].length>1&&h.push(c[0]+c[1][1]+c[1][0]+c[1].substring(2))}for(var d=[],l=0,a=o.length;a>l;l++){var c=o[l];if(c[1])for(var f=0,p=u.alphabet.length;p>f;f++)d.push(c[0]+u.alphabet[f]+c[1].substring(1))}for(var g=[],l=0,a=o.length;a>l;l++){var c=o[l];if(c[1])for(var f=0,p=u.alphabet.length;p>f;f++)d.push(c[0]+u.alphabet[f]+c[1])}t=t.concat(s),t=t.concat(h),t=t.concat(d),t=t.concat(g)}return t}function r(e){for(var t=[],n=0;n<e.length;n++)u.check(e[n])&&t.push(e[n]);return t}function i(e){function i(e,t){return e[1]<t[1]?-1:1}for(var o=n([e]),l=n(o),a=r(o).concat(r(l)),s={},c=0,h=a.length;h>c;c++)a[c]in s?s[a[c]]+=1:s[a[c]]=1;var d=[];for(var c in s)d.push([c,s[c]]);d.sort(i).reverse();for(var f=[],c=0,h=Math.min(t,d.length);h>c;c++)u.hasFlag(d[c][0],"NOSUGGEST")||f.push(d[c][0]);return f}if(t||(t=5),this.check(e))return[];for(var o=0,l=this.replacementTable.length;l>o;o++){var a=this.replacementTable[o];if(-1!==e.indexOf(a[0])){var s=e.replace(a[0],a[1]);if(this.check(s))return[s]}}var u=this;return u.alphabet="abcdefghijklmnopqrstuvwxyz",i(e)}};var num_loaded=0,aff_loading=!1,dic_loading=!1,aff_data="",dic_data="",typo;CodeMirror.defineMode("spell-checker",function(e,t){if(!aff_loading){aff_loading=!0;var n=new XMLHttpRequest;n.open("GET","https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff",!0),n.onload=function(e){4===n.readyState&&200===n.status&&(aff_data=n.responseText,num_loaded++,2==num_loaded&&(typo=new Typo("en_US",aff_data,dic_data,{platform:"any"})))},n.send(null)}if(!dic_loading){dic_loading=!0;var r=new XMLHttpRequest;r.open("GET","https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic",!0),r.onload=function(e){4===r.readyState&&200===r.status&&(dic_data=r.responseText,num_loaded++,2==num_loaded&&(typo=new Typo("en_US",aff_data,dic_data,{platform:"any"})))},r.send(null)}var i='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ',o={token:function(e,t){var n=e.peek(),r="";if(i.includes(n))return e.next(),null;for(;null!=(n=e.peek())&&!i.includes(n);)r+=n,e.next();return typo&&!typo.check(r)?"spell-error":null}},l=CodeMirror.getMode(e,e.backdrop||"text/plain");return CodeMirror.overlayMode(l,o,!0)}),String.prototype.includes||(String.prototype.includes=function(){"use strict";return-1!==String.prototype.indexOf.apply(this,arguments)}),function(){function e(e){this.tokens=[],this.tokens.links={},this.options=e||u.defaults,this.rules=c.normal,this.options.gfm&&(this.options.tables?this.rules=c.tables:this.rules=c.gfm)}function t(e,t){if(this.options=t||u.defaults,this.links=e,this.rules=h.normal,this.renderer=this.options.renderer||new n,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");
13
+ this.options.gfm?this.options.breaks?this.rules=h.breaks:this.rules=h.gfm:this.options.pedantic&&(this.rules=h.pedantic)}function n(e){this.options=e||{}}function r(e){this.tokens=[],this.token=null,this.options=e||u.defaults,this.options.renderer=this.options.renderer||new n,this.renderer=this.options.renderer,this.renderer.options=this.options}function i(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function o(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function l(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function a(){}function s(e){for(var t,n,r=1;r<arguments.length;r++){t=arguments[r];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}function u(t,n,o){if(o||"function"==typeof n){o||(o=n,n=null),n=s({},u.defaults,n||{});var l,a,c=n.highlight,h=0;try{l=e.lex(t,n)}catch(d){return o(d)}a=l.length;var f=function(e){if(e)return n.highlight=c,o(e);var t;try{t=r.parse(l,n)}catch(i){e=i}return n.highlight=c,e?o(e):o(null,t)};if(!c||c.length<3)return f();if(delete n.highlight,!a)return f();for(;h<l.length;h++)!function(e){return"code"!==e.type?--a||f():c(e.text,e.lang,function(t,n){return t?f(t):null==n||n===e.text?--a||f():(e.text=n,e.escaped=!0,void(--a||f()))})}(l[h])}else try{return n&&(n=s({},u.defaults,n)),r.parse(e.lex(t,n),n)}catch(d){if(d.message+="\nPlease report this to https://github.com/chjj/marked.",(n||u.defaults).silent)return"<p>An error occured:</p><pre>"+i(d.message+"",!0)+"</pre>";throw d}}var c={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:a,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:a,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:a,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};c.bullet=/(?:[*+-]|\d+\.)/,c.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,c.item=l(c.item,"gm")(/bull/g,c.bullet)(),c.list=l(c.list)(/bull/g,c.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+c.def.source+")")(),c.blockquote=l(c.blockquote)("def",c.def)(),c._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",c.html=l(c.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,c._tag)(),c.paragraph=l(c.paragraph)("hr",c.hr)("heading",c.heading)("lheading",c.lheading)("blockquote",c.blockquote)("tag","<"+c._tag)("def",c.def)(),c.normal=s({},c),c.gfm=s({},c.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),c.gfm.paragraph=l(c.paragraph)("(?!","(?!"+c.gfm.fences.source.replace("\\1","\\2")+"|"+c.list.source.replace("\\1","\\3")+"|")(),c.tables=s({},c.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=c,e.lex=function(t,n){var r=new e(n);return r.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,n){for(var r,i,o,l,a,s,u,h,d,e=e.replace(/^ +$/gm,"");e;)if((o=this.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&this.tokens.push({type:"space"})),o=this.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=this.rules.fences.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"code",lang:o[2],text:o[3]||""});else if(o=this.rules.heading.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=this.rules.nptable.exec(e))){for(e=e.substring(o[0].length),s={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/\n$/,"").split("\n")},h=0;h<s.align.length;h++)/^ *-+: *$/.test(s.align[h])?s.align[h]="right":/^ *:-+: *$/.test(s.align[h])?s.align[h]="center":/^ *:-+ *$/.test(s.align[h])?s.align[h]="left":s.align[h]=null;for(h=0;h<s.cells.length;h++)s.cells[h]=s.cells[h].split(/ *\| */);this.tokens.push(s)}else if(o=this.rules.lheading.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"heading",depth:"="===o[2]?1:2,text:o[1]});else if(o=this.rules.hr.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"hr"});else if(o=this.rules.blockquote.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"blockquote_start"}),o=o[0].replace(/^ *> ?/gm,""),this.token(o,t,!0),this.tokens.push({type:"blockquote_end"});else if(o=this.rules.list.exec(e)){for(e=e.substring(o[0].length),l=o[2],this.tokens.push({type:"list_start",ordered:l.length>1}),o=o[0].match(this.rules.item),r=!1,d=o.length,h=0;d>h;h++)s=o[h],u=s.length,s=s.replace(/^ *([*+-]|\d+\.) +/,""),~s.indexOf("\n ")&&(u-=s.length,s=this.options.pedantic?s.replace(/^ {1,4}/gm,""):s.replace(new RegExp("^ {1,"+u+"}","gm"),"")),this.options.smartLists&&h!==d-1&&(a=c.bullet.exec(o[h+1])[0],l===a||l.length>1&&a.length>1||(e=o.slice(h+1).join("\n")+e,h=d-1)),i=r||/\n\n(?!\s*$)/.test(s),h!==d-1&&(r="\n"===s.charAt(s.length-1),i||(i=r)),this.tokens.push({type:i?"loose_item_start":"list_item_start"}),this.token(s,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(o=this.rules.html.exec(e))e=e.substring(o[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===o[1]||"script"===o[1]||"style"===o[1]),text:o[0]});else if(!n&&t&&(o=this.rules.def.exec(e)))e=e.substring(o[0].length),this.tokens.links[o[1].toLowerCase()]={href:o[2],title:o[3]};else if(t&&(o=this.rules.table.exec(e))){for(e=e.substring(o[0].length),s={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/(?: *\| *)?\n$/,"").split("\n")},h=0;h<s.align.length;h++)/^ *-+: *$/.test(s.align[h])?s.align[h]="right":/^ *:-+: *$/.test(s.align[h])?s.align[h]="center":/^ *:-+ *$/.test(s.align[h])?s.align[h]="left":s.align[h]=null;for(h=0;h<s.cells.length;h++)s.cells[h]=s.cells[h].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(s)}else if(t&&(o=this.rules.paragraph.exec(e)))e=e.substring(o[0].length),this.tokens.push({type:"paragraph",text:"\n"===o[1].charAt(o[1].length-1)?o[1].slice(0,-1):o[1]});else if(o=this.rules.text.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"text",text:o[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var h={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:a,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:a,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};h._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/,h._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,h.link=l(h.link)("inside",h._inside)("href",h._href)(),h.reflink=l(h.reflink)("inside",h._inside)(),h.normal=s({},h),h.pedantic=s({},h.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),h.gfm=s({},h.normal,{escape:l(h.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:l(h.text)("]|","~]|")("|","|https?://|")()}),h.breaks=s({},h.gfm,{br:l(h.br)("{2,}","*")(),text:l(h.gfm.text)("{2,}","*")()}),t.rules=h,t.output=function(e,n,r){var i=new t(n,r);return i.output(e)},t.prototype.output=function(e){for(var t,n,r,o,l="";e;)if(o=this.rules.escape.exec(e))e=e.substring(o[0].length),l+=o[1];else if(o=this.rules.autolink.exec(e))e=e.substring(o[0].length),"@"===o[2]?(n=":"===o[1].charAt(6)?this.mangle(o[1].substring(7)):this.mangle(o[1]),r=this.mangle("mailto:")+n):(n=i(o[1]),r=n),l+=this.renderer.link(r,null,n);else if(this.inLink||!(o=this.rules.url.exec(e))){if(o=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(o[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(o[0])&&(this.inLink=!1),e=e.substring(o[0].length),l+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(o[0]):i(o[0]):o[0];else if(o=this.rules.link.exec(e))e=e.substring(o[0].length),this.inLink=!0,l+=this.outputLink(o,{href:o[2],title:o[3]}),this.inLink=!1;else if((o=this.rules.reflink.exec(e))||(o=this.rules.nolink.exec(e))){if(e=e.substring(o[0].length),t=(o[2]||o[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){l+=o[0].charAt(0),e=o[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(o,t),this.inLink=!1}else if(o=this.rules.strong.exec(e))e=e.substring(o[0].length),l+=this.renderer.strong(this.output(o[2]||o[1]));else if(o=this.rules.em.exec(e))e=e.substring(o[0].length),l+=this.renderer.em(this.output(o[2]||o[1]));else if(o=this.rules.code.exec(e))e=e.substring(o[0].length),l+=this.renderer.codespan(i(o[2],!0));else if(o=this.rules.br.exec(e))e=e.substring(o[0].length),l+=this.renderer.br();else if(o=this.rules.del.exec(e))e=e.substring(o[0].length),l+=this.renderer.del(this.output(o[1]));else if(o=this.rules.text.exec(e))e=e.substring(o[0].length),l+=this.renderer.text(i(this.smartypants(o[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(o[0].length),n=i(o[1]),r=n,l+=this.renderer.link(r,null,n);return l},t.prototype.outputLink=function(e,t){var n=i(t.href),r=t.title?i(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,i(e[1]))},t.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},t.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;r>i;i++)t=e.charCodeAt(i),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},n.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'<pre><code class="'+this.options.langPrefix+i(t,!0)+'">'+(n?e:i(e,!0))+"\n</code></pre>\n":"<pre><code>"+(n?e:i(e,!0))+"\n</code></pre>"},n.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},n.prototype.html=function(e){return e},n.prototype.heading=function(e,t,n){return"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n"},n.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},n.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"</"+n+">\n"},n.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},n.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},n.prototype.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n<tbody>\n"+t+"</tbody>\n</table>\n"},n.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},n.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"</"+n+">\n"},n.prototype.strong=function(e){return"<strong>"+e+"</strong>"},n.prototype.em=function(e){return"<em>"+e+"</em>"},n.prototype.codespan=function(e){return"<code>"+e+"</code>"},n.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},n.prototype.del=function(e){return"<del>"+e+"</del>"},n.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(o(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(i){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var l='<a href="'+e+'"';return t&&(l+=' title="'+t+'"'),l+=">"+n+"</a>"},n.prototype.image=function(e,t,n){var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},n.prototype.text=function(e){return e},r.parse=function(e,t,n){var i=new r(t,n);return i.parse(e)},r.prototype.parse=function(e){this.inline=new t(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=this.tok();return n},r.prototype.next=function(){return this.token=this.tokens.pop()},r.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},r.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},r.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,i,o="",l="";for(n="",e=0;e<this.token.header.length;e++)r={header:!0,align:this.token.align[e]},n+=this.renderer.tablecell(this.inline.output(this.token.header[e]),{header:!0,align:this.token.align[e]});for(o+=this.renderer.tablerow(n),e=0;e<this.token.cells.length;e++){for(t=this.token.cells[e],n="",i=0;i<t.length;i++)n+=this.renderer.tablecell(this.inline.output(t[i]),{header:!1,align:this.token.align[i]});l+=this.renderer.tablerow(n)}return this.renderer.table(o,l);case"blockquote_start":for(var l="";"blockquote_end"!==this.next().type;)l+=this.tok();return this.renderer.blockquote(l);case"list_start":for(var l="",a=this.token.ordered;"list_end"!==this.next().type;)l+=this.tok();return this.renderer.list(l,a);case"list_item_start":for(var l="";"list_item_end"!==this.next().type;)l+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(l);case"loose_item_start":for(var l="";"list_item_end"!==this.next().type;)l+=this.tok();return this.renderer.listitem(l);case"html":var s=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);return this.renderer.html(s);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}},a.exec=a,u.options=u.setOptions=function(e){return s(u.defaults,e),u},u.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,sanitizer:null,mangle:!0,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new n,xhtml:!1},u.Parser=r,u.parser=r.parse,u.Renderer=n,u.Lexer=e,u.lexer=e.lex,u.InlineLexer=t,u.inlineLexer=t.output,u.parse=u,"undefined"!=typeof module&&"object"==typeof exports?module.exports=u:"function"==typeof define&&define.amd?define(function(){return u}):this.marked=u}.call(function(){return this||("undefined"!=typeof window?window:global)}());var isMac=/Mac/.test(navigator.platform),shortcuts={"Cmd-B":toggleBold,"Cmd-I":toggleItalic,"Cmd-K":drawLink,"Cmd-H":toggleHeadingSmaller,"Shift-Cmd-H":toggleHeadingBigger,"Cmd-Alt-I":drawImage,"Cmd-'":toggleBlockquote,"Cmd-Alt-L":toggleOrderedList,"Cmd-L":toggleUnorderedList,"Cmd-Alt-C":toggleCodeBlock,"Cmd-P":togglePreview},saved_overflow="",toolbarBuiltInButtons={bold:{name:"bold",action:toggleBold,className:"fa fa-bold",title:"Bold (Ctrl+B)"},italic:{name:"italic",action:toggleItalic,className:"fa fa-italic",title:"Italic (Ctrl+I)"},strikethrough:{name:"strikethrough",action:toggleStrikethrough,className:"fa fa-strikethrough",title:"Strikethrough"},heading:{name:"heading",action:toggleHeadingSmaller,className:"fa fa-header",title:"Heading (Ctrl+H)"},"heading-smaller":{name:"heading-smaller",action:toggleHeadingSmaller,className:"fa fa-header fa-header-x fa-header-smaller",title:"Smaller Heading (Ctrl+H)"},"heading-bigger":{name:"heading-bigger",action:toggleHeadingBigger,className:"fa fa-header fa-header-x fa-header-bigger",title:"Bigger Heading (Shift+Ctrl+H)"},"heading-1":{name:"heading-1",action:toggleHeading1,className:"fa fa-header fa-header-x fa-header-1",title:"Big Heading"},"heading-2":{name:"heading-2",action:toggleHeading2,className:"fa fa-header fa-header-x fa-header-2",title:"Medium Heading"},"heading-3":{name:"heading-3",action:toggleHeading3,className:"fa fa-header fa-header-x fa-header-3",title:"Small Heading"},code:{name:"code",action:toggleCodeBlock,className:"fa fa-code",title:"Code (Ctrl+Alt+C)"},quote:{name:"quote",action:toggleBlockquote,className:"fa fa-quote-left",title:"Quote (Ctrl+')"},"unordered-list":{name:"unordered-list",action:toggleUnorderedList,className:"fa fa-list-ul",title:"Generic List (Ctrl+L)"},"ordered-list":{name:"ordered-list",action:toggleOrderedList,className:"fa fa-list-ol",title:"Numbered List (Ctrl+Alt+L)"},link:{name:"link",action:drawLink,className:"fa fa-link",title:"Create Link (Ctrl+K)"},image:{name:"image",action:drawImage,className:"fa fa-picture-o",title:"Insert Image (Ctrl+Alt+I)"},"horizontal-rule":{name:"horizontal-rule",action:drawHorizontalRule,className:"fa fa-minus",title:"Insert Horizontal Line"},preview:{name:"preview",action:togglePreview,className:"fa fa-eye no-disable",title:"Toggle Preview (Ctrl+P)"},"side-by-side":{name:"side-by-side",action:toggleSideBySide,className:"fa fa-columns no-disable no-mobile",title:"Toggle Side by Side (F9)"},fullscreen:{name:"fullscreen",action:toggleFullScreen,className:"fa fa-arrows-alt no-disable no-mobile",title:"Toggle Fullscreen (F11)"},guide:{name:"guide",action:"http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide",className:"fa fa-question-circle",title:"Markdown Guide"}},toolbar=["bold","italic","heading","|","quote","unordered-list","ordered-list","|","link","image","|","preview","side-by-side","fullscreen","guide"];SimpleMDE.toolbar=toolbar,SimpleMDE.prototype.markdown=function(e){if(window.marked){var t={};return this.options&&this.options.renderingConfig&&this.options.renderingConfig.singleLineBreaks!==!1&&(t.breaks=!0),this.options&&this.options.renderingConfig&&this.options.renderingConfig.codeSyntaxHighlighting===!0&&window.hljs&&(t.highlight=function(e){return hljs.highlightAuto(e).value}),marked.setOptions(t),marked(e)}},SimpleMDE.prototype.render=function(e){if(e||(e=this.element||document.getElementsByTagName("textarea")[0]),!this._rendered||this._rendered!==e){this.element=e;var t=this.options,n=this,r={};for(var i in shortcuts)!function(e){r[fixShortcut(e)]=function(t){shortcuts[e](n)}}(i);r.Enter="newlineAndIndentContinueMarkdownList",r.Tab="tabAndIndentMarkdownList",r["Shift-Tab"]="shiftTabAndUnindentMarkdownList",r.F11=function(e){toggleFullScreen(n)},r.F9=function(e){toggleSideBySide(n)},r.Esc=function(e){e.getOption("fullScreen")&&toggleFullScreen(n)};var o,l;t.spellChecker!==!1?(o="spell-checker",l=t.parsingConfig,l.name="gfm",l.gitHubSpice=!1):(o=t.parsingConfig,o.name="gfm",o.gitHubSpice=!1),this.codemirror=CodeMirror.fromTextArea(e,{mode:o,backdrop:l,theme:"paper",tabSize:void 0!=t.tabSize?t.tabSize:2,indentUnit:void 0!=t.tabSize?t.tabSize:2,indentWithTabs:t.indentWithTabs===!1?!1:!0,lineNumbers:!1,autofocus:t.autofocus===!0?!0:!1,extraKeys:r,lineWrapping:t.lineWrapping===!1?!1:!0,allowDroppedFileTypes:["text/plain"]}),t.toolbar!==!1&&this.createToolbar(),t.status!==!1&&this.createStatusbar(),void 0!=t.autosave&&t.autosave.enabled===!0&&this.autosave(),this.createSideBySide(),this._rendered=this.element}},SimpleMDE.prototype.autosave=function(){var e=this.value(),t=this;if(void 0==this.options.autosave.unique_id||""==this.options.autosave.unique_id)return void console.log("SimpleMDE: You must set a unique_id to use the autosave feature");null!=t.element.form&&void 0!=t.element.form&&t.element.form.addEventListener("submit",function(){localStorage.setItem(t.options.autosave.unique_id,"")}),this.options.autosave.loaded!==!0&&(null!=localStorage.getItem(this.options.autosave.unique_id)&&this.codemirror.setValue(localStorage.getItem(this.options.autosave.unique_id)),this.options.autosave.loaded=!0),localStorage&&localStorage.setItem(this.options.autosave.unique_id,e);var n=document.getElementById("autosaved");if(null!=n&&void 0!=n&&""!=n){var r=new Date,i=r.getHours(),o=r.getMinutes(),l="am",a=i;a>=12&&(a=i-12,l="pm"),0==a&&(a=12),o=10>o?"0"+o:o,n.innerHTML="Autosaved: "+a+":"+o+" "+l}setTimeout(function(){t.autosave()},this.options.autosave.delay||1e4)},SimpleMDE.prototype.createSideBySide=function(){var e=this.codemirror,t=e.getWrapperElement(),n=t.nextSibling;n&&/editor-preview-side/.test(n.className)||(n=document.createElement("div"),n.className="editor-preview-side",t.parentNode.insertBefore(n,t.nextSibling));var r=!1,i=!1;return e.on("scroll",function(e){return r?void(r=!1):(i=!0,height=e.getScrollInfo().height-e.getScrollInfo().clientHeight,ratio=parseFloat(e.getScrollInfo().top)/height,move=(n.scrollHeight-n.clientHeight)*ratio,void(n.scrollTop=move))}),n.onscroll=function(t){return i?void(i=!1):(r=!0,height=n.scrollHeight-n.clientHeight,ratio=parseFloat(n.scrollTop)/height,move=(e.getScrollInfo().height-e.getScrollInfo().clientHeight)*ratio,void e.scrollTo(0,move))},!0},SimpleMDE.prototype.createToolbar=function(e){if(e=e||this.options.toolbar,e&&0!==e.length){for(var t=0;t<e.length;t++)void 0!=toolbarBuiltInButtons[e[t]]&&(e[t]=toolbarBuiltInButtons[e[t]]);var n=document.createElement("div");n.className="editor-toolbar";var r=this,i={};r.toolbar=e;for(var t=0;t<e.length;t++)("guide"!=e[t].name||r.options.toolbarGuideIcon!==!1)&&(r.options.hideIcons&&-1!=r.options.hideIcons.indexOf(e[t].name)||!function(e){var t;t="|"===e?createSep():createIcon(e,r.options.toolbarTips),e.action&&("function"==typeof e.action?t.onclick=function(t){e.action(r)}:"string"==typeof e.action&&(t.href=e.action,t.target="_blank")),i[e.name||e]=t,n.appendChild(t)}(e[t]));r.toolbarElements=i;var o=this.codemirror;o.on("cursorActivity",function(){var e=getState(o);for(var t in i)!function(t){var n=i[t];e[t]?n.className+=" active":"fullscreen"!=t&&"side-by-side"!=t&&(n.className=n.className.replace(/\s*active\s*/g,""))}(t)});var l=o.getWrapperElement();return l.parentNode.insertBefore(n,l),n}},SimpleMDE.prototype.createStatusbar=function(e){if(e=e||this.options.status,options=this.options,e&&0!==e.length){var t=document.createElement("div");t.className="editor-statusbar";for(var n,r=this.codemirror,i=0;i<e.length;i++)!function(e){var i=document.createElement("span");i.className=e,"words"===e?(i.innerHTML="0",r.on("update",function(){i.innerHTML=wordCount(r.getValue())})):"lines"===e?(i.innerHTML="0",r.on("update",function(){i.innerHTML=r.lineCount()})):"cursor"===e?(i.innerHTML="0:0",r.on("cursorActivity",function(){n=r.getCursor(),i.innerHTML=n.line+":"+n.ch})):"autosave"===e&&void 0!=options.autosave&&options.autosave.enabled===!0&&i.setAttribute("id","autosaved"),t.appendChild(i)}(e[i]);var o=this.codemirror.getWrapperElement();return o.parentNode.insertBefore(t,o.nextSibling),t}},SimpleMDE.prototype.value=function(e){return void 0===e?this.codemirror.getValue():(this.codemirror.getDoc().setValue(e),this)},SimpleMDE.toggleBold=toggleBold,SimpleMDE.toggleItalic=toggleItalic,SimpleMDE.toggleStrikethrough=toggleStrikethrough,SimpleMDE.toggleBlockquote=toggleBlockquote,SimpleMDE.toggleHeadingSmaller=toggleHeadingSmaller,SimpleMDE.toggleHeadingBigger=toggleHeadingBigger,SimpleMDE.toggleHeading1=toggleHeading1,SimpleMDE.toggleHeading2=toggleHeading2,SimpleMDE.toggleHeading3=toggleHeading3,SimpleMDE.toggleCodeBlock=toggleCodeBlock,SimpleMDE.toggleUnorderedList=toggleUnorderedList,SimpleMDE.toggleOrderedList=toggleOrderedList,SimpleMDE.drawLink=drawLink,SimpleMDE.drawImage=drawImage,SimpleMDE.drawHorizontalRule=drawHorizontalRule,SimpleMDE.undo=undo,SimpleMDE.redo=redo,SimpleMDE.togglePreview=togglePreview,SimpleMDE.toggleSideBySide=toggleSideBySide,SimpleMDE.toggleFullScreen=toggleFullScreen,SimpleMDE.prototype.toggleBold=function(){toggleBold(this)},SimpleMDE.prototype.toggleItalic=function(){toggleItalic(this)},SimpleMDE.prototype.toggleStrikethrough=function(){toggleStrikethrough(this)},SimpleMDE.prototype.toggleBlockquote=function(){toggleBlockquote(this)},SimpleMDE.prototype.toggleHeadingSmaller=function(){toggleHeadingSmaller(this)},SimpleMDE.prototype.toggleHeadingBigger=function(){toggleHeadingBigger(this)},SimpleMDE.prototype.toggleHeading1=function(){toggleHeading1(this)},SimpleMDE.prototype.toggleHeading2=function(){toggleHeading2(this)},SimpleMDE.prototype.toggleHeading3=function(){toggleHeading3(this)},SimpleMDE.prototype.toggleCodeBlock=function(){toggleCodeBlock(this)},SimpleMDE.prototype.toggleUnorderedList=function(){toggleUnorderedList(this)},SimpleMDE.prototype.toggleOrderedList=function(){toggleOrderedList(this)},SimpleMDE.prototype.drawLink=function(){drawLink(this)},SimpleMDE.prototype.drawImage=function(){drawImage(this)},SimpleMDE.prototype.drawHorizontalRule=function(){drawHorizontalRule(this)},SimpleMDE.prototype.undo=function(){undo(this)},SimpleMDE.prototype.redo=function(){redo(this)},SimpleMDE.prototype.togglePreview=function(){togglePreview(this)},SimpleMDE.prototype.toggleSideBySide=function(){toggleSideBySide(this)},SimpleMDE.prototype.toggleFullScreen=function(){toggleFullScreen(this)};
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * jQuery UI Touch Punch 0.2.3
3
+ *
4
+ * Copyright 2011–2014, Dave Furfero
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ *
7
+ * Depends:
8
+ * jquery.ui.widget.js
9
+ * jquery.ui.mouse.js
10
+ */
11
+ !function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);
@@ -0,0 +1,4 @@
1
+ //= require fae/vendor/trumbowyg/trumbowyg
2
+ //= require fae/vendor/trumbowyg/plugins/upload/trumbowyg.upload
3
+
4
+ jQuery.trumbowyg.svgPath = "<%= image_path('fae/icons/trumbowyg.svg') %>"
@@ -0,0 +1,223 @@
1
+ /* ===========================================================
2
+ * trumbowyg.upload.js v1.2
3
+ * Upload plugin for Trumbowyg
4
+ * http://alex-d.github.com/Trumbowyg
5
+ * ===========================================================
6
+ * Author : Alexandre Demode (Alex-D)
7
+ * Twitter : @AlexandreDemode
8
+ * Website : alex-d.fr
9
+ * Mod by : Aleksandr-ru
10
+ * Twitter : @Aleksandr_ru
11
+ * Website : aleksandr.ru
12
+ */
13
+
14
+ (function ($) {
15
+ 'use strict';
16
+
17
+ var defaultOptions = {
18
+ serverPath: './src/plugins/upload/trumbowyg.upload.php',
19
+ fileFieldName: 'fileToUpload',
20
+ data: [], // Additional data for ajax [{name: 'key', value: 'value'}]
21
+ headers: {}, // Additional headers
22
+ xhrFields: {}, // Additional fields
23
+ urlPropertyName: 'file', // How to get url from the json response (for instance 'url' for {url: ....})
24
+ statusPropertyName: 'success', // How to get status from the json response
25
+ success: undefined, // Success callback: function (data, trumbowyg, $modal, values) {}
26
+ error: undefined // Error callback: function () {}
27
+ };
28
+
29
+ function getDeep(object, propertyParts) {
30
+ var mainProperty = propertyParts.shift(),
31
+ otherProperties = propertyParts;
32
+
33
+ if (object !== null) {
34
+ if (otherProperties.length === 0) {
35
+ return object[mainProperty];
36
+ }
37
+
38
+ if (typeof object === 'object') {
39
+ return getDeep(object[mainProperty], otherProperties);
40
+ }
41
+ }
42
+ return object;
43
+ }
44
+
45
+ addXhrProgressEvent();
46
+
47
+ $.extend(true, $.trumbowyg, {
48
+ langs: {
49
+ // jshint camelcase:false
50
+ en: {
51
+ upload: 'Upload',
52
+ file: 'File',
53
+ uploadError: 'Error'
54
+ },
55
+ sk: {
56
+ upload: 'Nahrať',
57
+ file: 'Súbor',
58
+ uploadError: 'Chyba'
59
+ },
60
+ fr: {
61
+ upload: 'Envoi',
62
+ file: 'Fichier',
63
+ uploadError: 'Erreur'
64
+ },
65
+ cs: {
66
+ upload: 'Nahrát obrázek',
67
+ file: 'Soubor',
68
+ uploadError: 'Chyba'
69
+ },
70
+ zh_cn: {
71
+ upload: '上传',
72
+ file: '文件',
73
+ uploadError: '错误'
74
+ },
75
+ ru: {
76
+ upload: 'Загрузка',
77
+ file: 'Файл',
78
+ uploadError: 'Ошибка'
79
+ }
80
+ },
81
+ // jshint camelcase:true
82
+
83
+ plugins: {
84
+ upload: {
85
+ init: function (trumbowyg) {
86
+ trumbowyg.o.plugins.upload = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.upload || {});
87
+ var btnDef = {
88
+ fn: function () {
89
+ trumbowyg.saveRange();
90
+
91
+ var file,
92
+ prefix = trumbowyg.o.prefix;
93
+
94
+ var $modal = trumbowyg.openModalInsert(
95
+ // Title
96
+ trumbowyg.lang.upload,
97
+
98
+ // Fields
99
+ {
100
+ file: {
101
+ type: 'file',
102
+ required: true,
103
+ attributes: {
104
+ accept: 'image/*'
105
+ }
106
+ },
107
+ alt: {
108
+ label: 'description',
109
+ value: trumbowyg.getRangeText()
110
+ }
111
+ },
112
+
113
+ // Callback
114
+ function (values) {
115
+ var data = new FormData();
116
+ data.append(trumbowyg.o.plugins.upload.fileFieldName, file);
117
+
118
+ trumbowyg.o.plugins.upload.data.map(function (cur) {
119
+ data.append(cur.name, cur.value);
120
+ });
121
+
122
+ if ($('.' + prefix + 'progress', $modal).length === 0) {
123
+ $('.' + prefix + 'modal-title', $modal)
124
+ .after(
125
+ $('<div/>', {
126
+ 'class': prefix + 'progress'
127
+ }).append(
128
+ $('<div/>', {
129
+ 'class': prefix + 'progress-bar'
130
+ })
131
+ )
132
+ );
133
+ }
134
+
135
+ $.ajax({
136
+ url: trumbowyg.o.plugins.upload.serverPath,
137
+ headers: trumbowyg.o.plugins.upload.headers,
138
+ xhrFields: trumbowyg.o.plugins.upload.xhrFields,
139
+ type: 'POST',
140
+ data: data,
141
+ cache: false,
142
+ dataType: 'json',
143
+ processData: false,
144
+ contentType: false,
145
+
146
+ progressUpload: function (e) {
147
+ $('.' + prefix + 'progress-bar').stop().animate({
148
+ width: Math.round(e.loaded * 100 / e.total) + '%'
149
+ }, 200);
150
+ },
151
+
152
+ success: function (data) {
153
+ if (trumbowyg.o.plugins.upload.success) {
154
+ trumbowyg.o.plugins.upload.success(data, trumbowyg, $modal, values);
155
+ } else {
156
+ if (!!getDeep(data, trumbowyg.o.plugins.upload.statusPropertyName.split('.'))) {
157
+ var url = getDeep(data, trumbowyg.o.plugins.upload.urlPropertyName.split('.'));
158
+ trumbowyg.execCmd('insertImage', url);
159
+ $('img[src="' + url + '"]:not([alt])', trumbowyg.$box).attr('alt', values.alt);
160
+ setTimeout(function () {
161
+ trumbowyg.closeModal();
162
+ }, 250);
163
+ trumbowyg.$c.trigger('tbwuploadsuccess', [trumbowyg, data, url]);
164
+ } else {
165
+ trumbowyg.addErrorOnModalField(
166
+ $('input[type=file]', $modal),
167
+ trumbowyg.lang[data.message]
168
+ );
169
+ trumbowyg.$c.trigger('tbwuploaderror', [trumbowyg, data]);
170
+ }
171
+ }
172
+ },
173
+
174
+ error: trumbowyg.o.plugins.upload.error || function () {
175
+ trumbowyg.addErrorOnModalField(
176
+ $('input[type=file]', $modal),
177
+ trumbowyg.lang.uploadError
178
+ );
179
+ trumbowyg.$c.trigger('tbwuploaderror', [trumbowyg]);
180
+ }
181
+ });
182
+ }
183
+ );
184
+
185
+ $('input[type=file]').on('change', function (e) {
186
+ try {
187
+ // If multiple files allowed, we just get the first.
188
+ file = e.target.files[0];
189
+ } catch (err) {
190
+ // In IE8, multiple files not allowed
191
+ file = e.target.value;
192
+ }
193
+ });
194
+ }
195
+ };
196
+
197
+ trumbowyg.addBtnDef('upload', btnDef);
198
+ }
199
+ }
200
+ }
201
+ });
202
+
203
+
204
+ function addXhrProgressEvent() {
205
+ if (!$.trumbowyg && !$.trumbowyg.addedXhrProgressEvent) { // Avoid adding progress event multiple times
206
+ var originalXhr = $.ajaxSettings.xhr;
207
+ $.ajaxSetup({
208
+ xhr: function () {
209
+ var req = originalXhr(),
210
+ that = this;
211
+ if (req && typeof req.upload === 'object' && that.progressUpload !== undefined) {
212
+ req.upload.addEventListener('progress', function (e) {
213
+ that.progressUpload(e);
214
+ }, false);
215
+ }
216
+
217
+ return req;
218
+ }
219
+ });
220
+ $.trumbowyg.addedXhrProgressEvent = true;
221
+ }
222
+ }
223
+ })(jQuery);
@@ -0,0 +1,1603 @@
1
+ /**
2
+ * Trumbowyg v2.5.1 - A lightweight WYSIWYG editor
3
+ * Trumbowyg core file
4
+ * ------------------------
5
+ * @link http://alex-d.github.io/Trumbowyg
6
+ * @license MIT
7
+ * @author Alexandre Demode (Alex-D)
8
+ * Twitter : @AlexandreDemode
9
+ * Website : alex-d.fr
10
+ */
11
+
12
+ jQuery.trumbowyg = {
13
+ langs: {
14
+ en: {
15
+ viewHTML: 'View HTML',
16
+
17
+ undo: 'Undo',
18
+ redo: 'Redo',
19
+
20
+ formatting: 'Formatting',
21
+ p: 'Paragraph',
22
+ blockquote: 'Quote',
23
+ code: 'Code',
24
+ header: 'Header',
25
+
26
+ bold: 'Bold',
27
+ italic: 'Italic',
28
+ strikethrough: 'Stroke',
29
+ underline: 'Underline',
30
+
31
+ strong: 'Strong',
32
+ em: 'Emphasis',
33
+ del: 'Deleted',
34
+
35
+ superscript: 'Superscript',
36
+ subscript: 'Subscript',
37
+
38
+ unorderedList: 'Unordered list',
39
+ orderedList: 'Ordered list',
40
+
41
+ insertImage: 'Insert Image',
42
+ link: 'Link',
43
+ createLink: 'Insert link',
44
+ unlink: 'Remove link',
45
+
46
+ justifyLeft: 'Align Left',
47
+ justifyCenter: 'Align Center',
48
+ justifyRight: 'Align Right',
49
+ justifyFull: 'Align Justify',
50
+
51
+ horizontalRule: 'Insert horizontal rule',
52
+ removeformat: 'Remove format',
53
+
54
+ fullscreen: 'Fullscreen',
55
+
56
+ close: 'Close',
57
+
58
+ submit: 'Confirm',
59
+ reset: 'Cancel',
60
+
61
+ required: 'Required',
62
+ description: 'Description',
63
+ title: 'Title',
64
+ text: 'Text',
65
+ target: 'Target'
66
+ }
67
+ },
68
+
69
+ // Plugins
70
+ plugins: {},
71
+
72
+ // SVG Path globally
73
+ svgPath: null,
74
+
75
+ hideButtonTexts: null
76
+ };
77
+
78
+
79
+ (function (navigator, window, document, $) {
80
+ 'use strict';
81
+
82
+ $.fn.trumbowyg = function (options, params) {
83
+ var trumbowygDataName = 'trumbowyg';
84
+ if (options === Object(options) || !options) {
85
+ return this.each(function () {
86
+ if (!$(this).data(trumbowygDataName)) {
87
+ $(this).data(trumbowygDataName, new Trumbowyg(this, options));
88
+ }
89
+ });
90
+ }
91
+ if (this.length === 1) {
92
+ try {
93
+ var t = $(this).data(trumbowygDataName);
94
+ switch (options) {
95
+ // Exec command
96
+ case 'execCmd':
97
+ return t.execCmd(params.cmd, params.param, params.forceCss);
98
+
99
+ // Modal box
100
+ case 'openModal':
101
+ return t.openModal(params.title, params.content);
102
+ case 'closeModal':
103
+ return t.closeModal();
104
+ case 'openModalInsert':
105
+ return t.openModalInsert(params.title, params.fields, params.callback);
106
+
107
+ // Range
108
+ case 'saveRange':
109
+ return t.saveRange();
110
+ case 'getRange':
111
+ return t.range;
112
+ case 'getRangeText':
113
+ return t.getRangeText();
114
+ case 'restoreRange':
115
+ return t.restoreRange();
116
+
117
+ // Enable/disable
118
+ case 'enable':
119
+ return t.toggleDisable(false);
120
+ case 'disable':
121
+ return t.toggleDisable(true);
122
+
123
+ // Destroy
124
+ case 'destroy':
125
+ return t.destroy();
126
+
127
+ // Empty
128
+ case 'empty':
129
+ return t.empty();
130
+
131
+ // HTML
132
+ case 'html':
133
+ return t.html(params);
134
+ }
135
+ } catch (c) {
136
+ }
137
+ }
138
+
139
+ return false;
140
+ };
141
+
142
+ // @param: editorElem is the DOM element
143
+ var Trumbowyg = function (editorElem, options) {
144
+ var t = this,
145
+ trumbowygIconsId = 'trumbowyg-icons';
146
+
147
+ // Get the document of the element. It use to makes the plugin
148
+ // compatible on iframes.
149
+ t.doc = editorElem.ownerDocument || document;
150
+
151
+ // jQuery object of the editor
152
+ t.$ta = $(editorElem); // $ta : Textarea
153
+ t.$c = $(editorElem); // $c : creator
154
+
155
+ options = options || {};
156
+
157
+ // Localization management
158
+ if (options.lang != null || $.trumbowyg.langs[options.lang] != null) {
159
+ t.lang = $.extend(true, {}, $.trumbowyg.langs.en, $.trumbowyg.langs[options.lang]);
160
+ } else {
161
+ t.lang = $.trumbowyg.langs.en;
162
+ }
163
+
164
+ t.hideButtonTexts = $.trumbowyg.hideButtonTexts != null ? $.trumbowyg.hideButtonTexts : options.hideButtonTexts;
165
+
166
+ // SVG path
167
+ var svgPathOption = $.trumbowyg.svgPath != null ? $.trumbowyg.svgPath : options.svgPath;
168
+ t.hasSvg = svgPathOption !== false;
169
+ t.svgPath = !!t.doc.querySelector('base') ? window.location.href.split('#')[0] : '';
170
+ if ($('#' + trumbowygIconsId, t.doc).length === 0 && svgPathOption !== false) {
171
+ if (svgPathOption == null) {
172
+ try {
173
+ throw new Error();
174
+ } catch (e) {
175
+ var stackLines = e.stack.split('\n');
176
+
177
+ for (var i in stackLines) {
178
+ if (!stackLines[i].match(/http[s]?:\/\//)) {
179
+ continue;
180
+ }
181
+ svgPathOption = stackLines[Number(i)].match(/((http[s]?:\/\/.+\/)([^\/]+\.js))(\?.*)?:/)[1].split('/');
182
+ svgPathOption.pop();
183
+ svgPathOption = svgPathOption.join('/') + '/ui/icons.svg';
184
+ break;
185
+ }
186
+ }
187
+ }
188
+
189
+ var div = t.doc.createElement('div');
190
+ div.id = trumbowygIconsId;
191
+ t.doc.body.insertBefore(div, t.doc.body.childNodes[0]);
192
+ $.ajax({
193
+ async: true,
194
+ type: 'GET',
195
+ contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
196
+ dataType: 'xml',
197
+ url: svgPathOption,
198
+ data: null,
199
+ beforeSend: null,
200
+ complete: null,
201
+ success: function (data) {
202
+ div.innerHTML = new XMLSerializer().serializeToString(data.documentElement);
203
+ }
204
+ });
205
+ }
206
+
207
+
208
+ /**
209
+ * When the button is associated to a empty object
210
+ * fn and title attributs are defined from the button key value
211
+ *
212
+ * For example
213
+ * foo: {}
214
+ * is equivalent to :
215
+ * foo: {
216
+ * fn: 'foo',
217
+ * title: this.lang.foo
218
+ * }
219
+ */
220
+ var h = t.lang.header, // Header translation
221
+ isBlinkFunction = function () {
222
+ return (window.chrome || (window.Intl && Intl.v8BreakIterator)) && 'CSS' in window;
223
+ };
224
+ t.btnsDef = {
225
+ viewHTML: {
226
+ fn: 'toggle'
227
+ },
228
+
229
+ undo: {
230
+ isSupported: isBlinkFunction,
231
+ key: 'Z'
232
+ },
233
+ redo: {
234
+ isSupported: isBlinkFunction,
235
+ key: 'Y'
236
+ },
237
+
238
+ p: {
239
+ fn: 'formatBlock'
240
+ },
241
+ blockquote: {
242
+ fn: 'formatBlock'
243
+ },
244
+ h1: {
245
+ fn: 'formatBlock',
246
+ title: h + ' 1'
247
+ },
248
+ h2: {
249
+ fn: 'formatBlock',
250
+ title: h + ' 2'
251
+ },
252
+ h3: {
253
+ fn: 'formatBlock',
254
+ title: h + ' 3'
255
+ },
256
+ h4: {
257
+ fn: 'formatBlock',
258
+ title: h + ' 4'
259
+ },
260
+ subscript: {
261
+ tag: 'sub'
262
+ },
263
+ superscript: {
264
+ tag: 'sup'
265
+ },
266
+
267
+ bold: {
268
+ key: 'B',
269
+ tag: 'b'
270
+ },
271
+ italic: {
272
+ key: 'I',
273
+ tag: 'i'
274
+ },
275
+ underline: {
276
+ tag: 'u'
277
+ },
278
+ strikethrough: {
279
+ tag: 'strike'
280
+ },
281
+
282
+ strong: {
283
+ fn: 'bold',
284
+ key: 'B'
285
+ },
286
+ em: {
287
+ fn: 'italic',
288
+ key: 'I'
289
+ },
290
+ del: {
291
+ fn: 'strikethrough'
292
+ },
293
+
294
+ createLink: {
295
+ key: 'K',
296
+ tag: 'a'
297
+ },
298
+ unlink: {},
299
+
300
+ insertImage: {},
301
+
302
+ justifyLeft: {
303
+ tag: 'left',
304
+ forceCss: true
305
+ },
306
+ justifyCenter: {
307
+ tag: 'center',
308
+ forceCss: true
309
+ },
310
+ justifyRight: {
311
+ tag: 'right',
312
+ forceCss: true
313
+ },
314
+ justifyFull: {
315
+ tag: 'justify',
316
+ forceCss: true
317
+ },
318
+
319
+ unorderedList: {
320
+ fn: 'insertUnorderedList',
321
+ tag: 'ul'
322
+ },
323
+ orderedList: {
324
+ fn: 'insertOrderedList',
325
+ tag: 'ol'
326
+ },
327
+
328
+ horizontalRule: {
329
+ fn: 'insertHorizontalRule'
330
+ },
331
+
332
+ removeformat: {},
333
+
334
+ fullscreen: {
335
+ class: 'trumbowyg-not-disable'
336
+ },
337
+ close: {
338
+ fn: 'destroy',
339
+ class: 'trumbowyg-not-disable'
340
+ },
341
+
342
+ // Dropdowns
343
+ formatting: {
344
+ dropdown: ['p', 'blockquote', 'h1', 'h2', 'h3', 'h4'],
345
+ ico: 'p'
346
+ },
347
+ link: {
348
+ dropdown: ['createLink', 'unlink']
349
+ }
350
+ };
351
+
352
+ // Defaults Options
353
+ t.o = $.extend(true, {}, {
354
+ lang: 'en',
355
+
356
+ fixedBtnPane: false,
357
+ fixedFullWidth: false,
358
+ autogrow: false,
359
+
360
+ prefix: 'trumbowyg-',
361
+
362
+ semantic: true,
363
+ resetCss: false,
364
+ removeformatPasted: false,
365
+ tagsToRemove: [],
366
+
367
+ btnsGrps: {
368
+ design: ['bold', 'italic', 'underline', 'strikethrough'],
369
+ semantic: ['strong', 'em', 'del'],
370
+ justify: ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
371
+ lists: ['unorderedList', 'orderedList']
372
+ },
373
+ btns: [
374
+ ['viewHTML'],
375
+ ['undo', 'redo'],
376
+ ['formatting'],
377
+ 'btnGrp-semantic',
378
+ ['superscript', 'subscript'],
379
+ ['link'],
380
+ ['insertImage'],
381
+ 'btnGrp-justify',
382
+ 'btnGrp-lists',
383
+ ['horizontalRule'],
384
+ ['removeformat'],
385
+ ['fullscreen']
386
+ ],
387
+ // For custom button definitions
388
+ btnsDef: {},
389
+
390
+ inlineElementsSelector: 'a,abbr,acronym,b,caption,cite,code,col,dfn,dir,dt,dd,em,font,hr,i,kbd,li,q,span,strikeout,strong,sub,sup,u',
391
+
392
+ pasteHandlers: [],
393
+
394
+ imgDblClickHandler: function () {
395
+ var $img = $(this),
396
+ src = $img.attr('src'),
397
+ base64 = '(Base64)';
398
+
399
+ if (src.indexOf('data:image') === 0) {
400
+ src = base64;
401
+ }
402
+
403
+ t.openModalInsert(t.lang.insertImage, {
404
+ url: {
405
+ label: 'URL',
406
+ value: src,
407
+ required: true
408
+ },
409
+ alt: {
410
+ label: t.lang.description,
411
+ value: $img.attr('alt')
412
+ }
413
+ }, function (v) {
414
+ if (v.src !== base64) {
415
+ $img.attr({
416
+ src: v.src
417
+ });
418
+ }
419
+ $img.attr({
420
+ alt: v.alt
421
+ });
422
+ return true;
423
+ });
424
+ return false;
425
+ },
426
+
427
+ plugins: {}
428
+ }, options);
429
+
430
+ t.disabled = t.o.disabled || (editorElem.nodeName === 'TEXTAREA' && editorElem.disabled);
431
+
432
+ if (options.btns) {
433
+ t.o.btns = options.btns;
434
+ } else if (!t.o.semantic) {
435
+ t.o.btns[4] = 'btnGrp-design';
436
+ }
437
+
438
+ $.each(t.o.btnsDef, function (btnName, btnDef) {
439
+ t.addBtnDef(btnName, btnDef);
440
+ });
441
+
442
+ // put this here in the event it would be merged in with options
443
+ t.eventNamespace = 'trumbowyg-event';
444
+
445
+ // Keyboard shortcuts are load in this array
446
+ t.keys = [];
447
+
448
+ // Tag to button dynamically hydrated
449
+ t.tagToButton = {};
450
+ t.tagHandlers = [];
451
+
452
+ // Admit multiple paste handlers
453
+ t.pasteHandlers = [].concat(t.o.pasteHandlers);
454
+
455
+ // Check if browser is IE
456
+ t.isIE = (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') !== -1);
457
+
458
+ t.init();
459
+ };
460
+
461
+ Trumbowyg.prototype = {
462
+ init: function () {
463
+ var t = this;
464
+ t.height = t.$ta.height();
465
+
466
+ t.initPlugins();
467
+
468
+ try {
469
+ // Disable image resize, try-catch for old IE
470
+ t.doc.execCommand('enableObjectResizing', false, false);
471
+ t.doc.execCommand('defaultParagraphSeparator', false, 'p');
472
+ } catch (e) {
473
+ }
474
+
475
+ t.buildEditor();
476
+ t.buildBtnPane();
477
+
478
+ t.fixedBtnPaneEvents();
479
+
480
+ t.buildOverlay();
481
+
482
+ setTimeout(function () {
483
+ if (t.disabled) {
484
+ t.toggleDisable(true);
485
+ }
486
+ t.$c.trigger('tbwinit');
487
+ });
488
+ },
489
+
490
+ addBtnDef: function (btnName, btnDef) {
491
+ this.btnsDef[btnName] = btnDef;
492
+ },
493
+
494
+ buildEditor: function () {
495
+ var t = this,
496
+ prefix = t.o.prefix,
497
+ html = '';
498
+
499
+ t.$box = $('<div/>', {
500
+ class: prefix + 'box ' + prefix + 'editor-visible ' + prefix + t.o.lang + ' trumbowyg'
501
+ });
502
+
503
+ // $ta = Textarea
504
+ // $ed = Editor
505
+ t.isTextarea = t.$ta.is('textarea');
506
+ if (t.isTextarea) {
507
+ html = t.$ta.val();
508
+ t.$ed = $('<div/>');
509
+ t.$box
510
+ .insertAfter(t.$ta)
511
+ .append(t.$ed, t.$ta);
512
+ } else {
513
+ t.$ed = t.$ta;
514
+ html = t.$ed.html();
515
+
516
+ t.$ta = $('<textarea/>', {
517
+ name: t.$ta.attr('id'),
518
+ height: t.height
519
+ }).val(html);
520
+
521
+ t.$box
522
+ .insertAfter(t.$ed)
523
+ .append(t.$ta, t.$ed);
524
+ t.syncCode();
525
+ }
526
+
527
+ t.$ta
528
+ .addClass(prefix + 'textarea')
529
+ .attr('tabindex', -1)
530
+ ;
531
+
532
+ t.$ed
533
+ .addClass(prefix + 'editor')
534
+ .attr({
535
+ contenteditable: true,
536
+ dir: t.lang._dir || 'ltr'
537
+ })
538
+ .html(html)
539
+ ;
540
+
541
+ if (t.o.tabindex) {
542
+ t.$ed.attr('tabindex', t.o.tabindex);
543
+ }
544
+
545
+ if (t.$c.is('[placeholder]')) {
546
+ t.$ed.attr('placeholder', t.$c.attr('placeholder'));
547
+ }
548
+
549
+ if (t.o.resetCss) {
550
+ t.$ed.addClass(prefix + 'reset-css');
551
+ }
552
+
553
+ if (!t.o.autogrow) {
554
+ t.$ta.add(t.$ed).css({
555
+ height: t.height
556
+ });
557
+ }
558
+
559
+ t.semanticCode();
560
+
561
+
562
+ var ctrl = false,
563
+ composition = false,
564
+ debounceButtonPaneStatus,
565
+ updateEventName = t.isIE ? 'keyup' : 'input';
566
+
567
+ t.$ed
568
+ .on('dblclick', 'img', t.o.imgDblClickHandler)
569
+ .on('keydown', function (e) {
570
+ if (e.ctrlKey) {
571
+ ctrl = true;
572
+ var key = t.keys[String.fromCharCode(e.which).toUpperCase()];
573
+
574
+ try {
575
+ t.execCmd(key.fn, key.param);
576
+ return false;
577
+ } catch (c) {
578
+ }
579
+ }
580
+ })
581
+ .on('compositionstart compositionupdate', function () {
582
+ composition = true;
583
+ })
584
+ .on(updateEventName + ' compositionend', function (e) {
585
+ if (e.type === 'compositionend') {
586
+ composition = false;
587
+ } else if(composition) {
588
+ return;
589
+ }
590
+
591
+ var keyCode = e.which;
592
+
593
+ if (keyCode >= 37 && keyCode <= 40) {
594
+ return;
595
+ }
596
+
597
+ if (e.ctrlKey && (keyCode === 89 || keyCode === 90)) {
598
+ t.$c.trigger('tbwchange');
599
+ } else if (!ctrl && keyCode !== 17) {
600
+ t.semanticCode(false, keyCode === 13);
601
+ t.$c.trigger('tbwchange');
602
+ } else if (typeof e.which === 'undefined') {
603
+ t.semanticCode(false, false, true);
604
+ }
605
+
606
+ setTimeout(function () {
607
+ ctrl = false;
608
+ }, 200);
609
+ })
610
+ .on('mouseup keydown keyup', function () {
611
+ clearTimeout(debounceButtonPaneStatus);
612
+ debounceButtonPaneStatus = setTimeout(function () {
613
+ t.updateButtonPaneStatus();
614
+ }, 50);
615
+ })
616
+ .on('focus blur', function (e) {
617
+ t.$c.trigger('tbw' + e.type);
618
+ if (e.type === 'blur') {
619
+ $('.' + prefix + 'active-button', t.$btnPane).removeClass(prefix + 'active-button ' + prefix + 'active');
620
+ }
621
+ })
622
+ .on('cut', function () {
623
+ setTimeout(function () {
624
+ t.semanticCode(false, true);
625
+ t.$c.trigger('tbwchange');
626
+ }, 0);
627
+ })
628
+ .on('paste', function (e) {
629
+ if (t.o.removeformatPasted) {
630
+ e.preventDefault();
631
+
632
+ try {
633
+ // IE
634
+ var text = window.clipboardData.getData('Text');
635
+
636
+ try {
637
+ // <= IE10
638
+ t.doc.selection.createRange().pasteHTML(text);
639
+ } catch (c) {
640
+ // IE 11
641
+ t.doc.getSelection().getRangeAt(0).insertNode(t.doc.createTextNode(text));
642
+ }
643
+ } catch (d) {
644
+ // Not IE
645
+ t.execCmd('insertText', (e.originalEvent || e).clipboardData.getData('text/plain'));
646
+ }
647
+ }
648
+
649
+ // Call pasteHandlers
650
+ $.each(t.pasteHandlers, function (i, pasteHandler) {
651
+ pasteHandler(e);
652
+ });
653
+
654
+ setTimeout(function () {
655
+ t.semanticCode(false, true);
656
+ t.$c.trigger('tbwpaste', e);
657
+ }, 0);
658
+ });
659
+ t.$ta.on('keyup paste', function () {
660
+ t.$c.trigger('tbwchange');
661
+ });
662
+
663
+ t.$box.on('keydown', function (e) {
664
+ if (e.which === 27 && $('.' + prefix + 'modal-box', t.$box).length === 1) {
665
+ t.closeModal();
666
+ return false;
667
+ }
668
+ });
669
+ },
670
+
671
+
672
+ // Build button pane, use o.btns option
673
+ buildBtnPane: function () {
674
+ var t = this,
675
+ prefix = t.o.prefix;
676
+
677
+ var $btnPane = t.$btnPane = $('<div/>', {
678
+ class: prefix + 'button-pane'
679
+ });
680
+
681
+ $.each(t.o.btns, function (i, btnGrps) {
682
+ // Managment of group of buttons
683
+ try {
684
+ var b = btnGrps.split('btnGrp-');
685
+ if (b[1] != null) {
686
+ btnGrps = t.o.btnsGrps[b[1]];
687
+ }
688
+ } catch (c) {
689
+ }
690
+
691
+ if (!$.isArray(btnGrps)) {
692
+ btnGrps = [btnGrps];
693
+ }
694
+
695
+ var $btnGroup = $('<div/>', {
696
+ class: prefix + 'button-group ' + ((btnGrps.indexOf('fullscreen') >= 0) ? prefix + 'right' : '')
697
+ });
698
+ $.each(btnGrps, function (i, btn) {
699
+ try { // Prevent buildBtn error
700
+ var $item;
701
+
702
+ if (t.isSupportedBtn(btn)) { // It's a supported button
703
+ $item = t.buildBtn(btn);
704
+ }
705
+
706
+ $btnGroup.append($item);
707
+ } catch (c) {
708
+ }
709
+ });
710
+ $btnPane.append($btnGroup);
711
+ });
712
+
713
+ t.$box.prepend($btnPane);
714
+ },
715
+
716
+
717
+ // Build a button and his action
718
+ buildBtn: function (btnName) { // btnName is name of the button
719
+ var t = this,
720
+ prefix = t.o.prefix,
721
+ btn = t.btnsDef[btnName],
722
+ isDropdown = btn.dropdown,
723
+ hasIcon = btn.hasIcon != null ? btn.hasIcon : true,
724
+ textDef = t.lang[btnName] || btnName,
725
+
726
+ $btn = $('<button/>', {
727
+ type: 'button',
728
+ class: prefix + btnName + '-button ' + (btn.class || '') + (!hasIcon ? ' ' + prefix + 'textual-button' : ''),
729
+ html: t.hasSvg && hasIcon ?
730
+ '<svg><use xlink:href="' + t.svgPath + '#' + prefix + (btn.ico || btnName).replace(/([A-Z]+)/g, '-$1').toLowerCase() + '"/></svg>' :
731
+ t.hideButtonTexts ? '' : (btn.text || btn.title || t.lang[btnName] || btnName),
732
+ title: (btn.title || btn.text || textDef) + ((btn.key) ? ' (Ctrl + ' + btn.key + ')' : ''),
733
+ tabindex: -1,
734
+ mousedown: function () {
735
+ if (!isDropdown || $('.' + btnName + '-' + prefix + 'dropdown', t.$box).is(':hidden')) {
736
+ $('body', t.doc).trigger('mousedown');
737
+ }
738
+
739
+ if (t.$btnPane.hasClass(prefix + 'disable') && !$(this).hasClass(prefix + 'active') && !$(this).hasClass(prefix + 'not-disable')) {
740
+ return false;
741
+ }
742
+
743
+ t.execCmd((isDropdown ? 'dropdown' : false) || btn.fn || btnName, btn.param || btnName, btn.forceCss || false);
744
+
745
+ return false;
746
+ }
747
+ });
748
+
749
+ if (isDropdown) {
750
+ $btn.addClass(prefix + 'open-dropdown');
751
+ var dropdownPrefix = prefix + 'dropdown',
752
+ $dropdown = $('<div/>', { // the dropdown
753
+ class: dropdownPrefix + '-' + btnName + ' ' + dropdownPrefix + ' ' + prefix + 'fixed-top',
754
+ 'data-dropdown': btnName
755
+ });
756
+ $.each(isDropdown, function (i, def) {
757
+ if (t.btnsDef[def] && t.isSupportedBtn(def)) {
758
+ $dropdown.append(t.buildSubBtn(def));
759
+ }
760
+ });
761
+ t.$box.append($dropdown.hide());
762
+ } else if (btn.key) {
763
+ t.keys[btn.key] = {
764
+ fn: btn.fn || btnName,
765
+ param: btn.param || btnName
766
+ };
767
+ }
768
+
769
+ if (!isDropdown) {
770
+ t.tagToButton[(btn.tag || btnName).toLowerCase()] = btnName;
771
+ }
772
+
773
+ return $btn;
774
+ },
775
+ // Build a button for dropdown menu
776
+ // @param n : name of the subbutton
777
+ buildSubBtn: function (btnName) {
778
+ var t = this,
779
+ prefix = t.o.prefix,
780
+ btn = t.btnsDef[btnName],
781
+ hasIcon = btn.hasIcon != null ? btn.hasIcon : true;
782
+
783
+ if (btn.key) {
784
+ t.keys[btn.key] = {
785
+ fn: btn.fn || btnName,
786
+ param: btn.param || btnName
787
+ };
788
+ }
789
+
790
+ t.tagToButton[(btn.tag || btnName).toLowerCase()] = btnName;
791
+
792
+ return $('<button/>', {
793
+ type: 'button',
794
+ class: prefix + btnName + '-dropdown-button' + (btn.ico ? ' ' + prefix + btn.ico + '-button' : ''),
795
+ html: t.hasSvg && hasIcon ? '<svg><use xlink:href="' + t.svgPath + '#' + prefix + (btn.ico || btnName).replace(/([A-Z]+)/g, '-$1').toLowerCase() + '"/></svg>' + (btn.text || btn.title || t.lang[btnName] || btnName) : (btn.text || btn.title || t.lang[btnName] || btnName),
796
+ title: ((btn.key) ? ' (Ctrl + ' + btn.key + ')' : null),
797
+ style: btn.style || null,
798
+ mousedown: function () {
799
+ $('body', t.doc).trigger('mousedown');
800
+
801
+ t.execCmd(btn.fn || btnName, btn.param || btnName, btn.forceCss || false);
802
+
803
+ return false;
804
+ }
805
+ });
806
+ },
807
+ // Check if button is supported
808
+ isSupportedBtn: function (b) {
809
+ try {
810
+ return this.btnsDef[b].isSupported();
811
+ } catch (c) {
812
+ }
813
+ return true;
814
+ },
815
+
816
+ // Build overlay for modal box
817
+ buildOverlay: function () {
818
+ var t = this;
819
+ t.$overlay = $('<div/>', {
820
+ class: t.o.prefix + 'overlay'
821
+ }).css({
822
+ top: t.$btnPane.outerHeight(),
823
+ height: (t.$ed.outerHeight() + 1) + 'px'
824
+ }).appendTo(t.$box);
825
+ return t.$overlay;
826
+ },
827
+ showOverlay: function () {
828
+ var t = this;
829
+ $(window).trigger('scroll');
830
+ t.$overlay.fadeIn(200);
831
+ t.$box.addClass(t.o.prefix + 'box-blur');
832
+ },
833
+ hideOverlay: function () {
834
+ var t = this;
835
+ t.$overlay.fadeOut(50);
836
+ t.$box.removeClass(t.o.prefix + 'box-blur');
837
+ },
838
+
839
+ // Management of fixed button pane
840
+ fixedBtnPaneEvents: function () {
841
+ var t = this,
842
+ fixedFullWidth = t.o.fixedFullWidth,
843
+ $box = t.$box;
844
+
845
+ if (!t.o.fixedBtnPane) {
846
+ return;
847
+ }
848
+
849
+ t.isFixed = false;
850
+
851
+ $(window)
852
+ .on('scroll.'+t.eventNamespace+' resize.'+t.eventNamespace, function () {
853
+ if (!$box) {
854
+ return;
855
+ }
856
+
857
+ t.syncCode();
858
+
859
+ var scrollTop = $(window).scrollTop(),
860
+ offset = $box.offset().top + 1,
861
+ bp = t.$btnPane,
862
+ oh = bp.outerHeight() - 2;
863
+
864
+ if ((scrollTop - offset > 0) && ((scrollTop - offset - t.height) < 0)) {
865
+ if (!t.isFixed) {
866
+ t.isFixed = true;
867
+ bp.css({
868
+ position: 'fixed',
869
+ top: 0,
870
+ left: fixedFullWidth ? '0' : 'auto',
871
+ zIndex: 7
872
+ });
873
+ $([t.$ta, t.$ed]).css({marginTop: bp.height()});
874
+ }
875
+ bp.css({
876
+ width: fixedFullWidth ? '100%' : (($box.width() - 1) + 'px')
877
+ });
878
+
879
+ $('.' + t.o.prefix + 'fixed-top', $box).css({
880
+ position: fixedFullWidth ? 'fixed' : 'absolute',
881
+ top: fixedFullWidth ? oh : oh + (scrollTop - offset) + 'px',
882
+ zIndex: 15
883
+ });
884
+ } else if (t.isFixed) {
885
+ t.isFixed = false;
886
+ bp.removeAttr('style');
887
+ $([t.$ta, t.$ed]).css({marginTop: 0});
888
+ $('.' + t.o.prefix + 'fixed-top', $box).css({
889
+ position: 'absolute',
890
+ top: oh
891
+ });
892
+ }
893
+ });
894
+ },
895
+
896
+ // Disable editor
897
+ toggleDisable: function (disable) {
898
+ var t = this,
899
+ prefix = t.o.prefix;
900
+
901
+ t.disabled = disable;
902
+
903
+ if (disable) {
904
+ t.$ta.attr('disabled', true);
905
+ } else {
906
+ t.$ta.removeAttr('disabled');
907
+ }
908
+ t.$box.toggleClass(prefix + 'disabled', disable);
909
+ t.$ed.attr('contenteditable', !disable);
910
+ },
911
+
912
+ // Destroy the editor
913
+ destroy: function () {
914
+ var t = this,
915
+ prefix = t.o.prefix,
916
+ height = t.height;
917
+
918
+ if (t.isTextarea) {
919
+ t.$box.after(
920
+ t.$ta
921
+ .css({height: height})
922
+ .val(t.html())
923
+ .removeClass(prefix + 'textarea')
924
+ .show()
925
+ );
926
+ } else {
927
+ t.$box.after(
928
+ t.$ed
929
+ .css({height: height})
930
+ .removeClass(prefix + 'editor')
931
+ .removeAttr('contenteditable')
932
+ .html(t.html())
933
+ .show()
934
+ );
935
+ }
936
+
937
+ t.$ed.off('dblclick', 'img');
938
+
939
+ t.destroyPlugins();
940
+
941
+ t.$box.remove();
942
+ t.$c.removeData('trumbowyg');
943
+ $('body').removeClass(prefix + 'body-fullscreen');
944
+ t.$c.trigger('tbwclose');
945
+ $(window).off('scroll.'+t.eventNamespace+' resize.'+t.eventNamespace);
946
+ },
947
+
948
+
949
+ // Empty the editor
950
+ empty: function () {
951
+ this.$ta.val('');
952
+ this.syncCode(true);
953
+ },
954
+
955
+
956
+ // Function call when click on viewHTML button
957
+ toggle: function () {
958
+ var t = this,
959
+ prefix = t.o.prefix;
960
+ t.semanticCode(false, true);
961
+ setTimeout(function () {
962
+ t.doc.activeElement.blur();
963
+ t.$box.toggleClass(prefix + 'editor-hidden ' + prefix + 'editor-visible');
964
+ t.$btnPane.toggleClass(prefix + 'disable');
965
+ $('.' + prefix + 'viewHTML-button', t.$btnPane).toggleClass(prefix + 'active');
966
+ if (t.$box.hasClass(prefix + 'editor-visible')) {
967
+ t.$ta.attr('tabindex', -1);
968
+ } else {
969
+ t.$ta.removeAttr('tabindex');
970
+ }
971
+ }, 0);
972
+ },
973
+
974
+ // Open dropdown when click on a button which open that
975
+ dropdown: function (name) {
976
+ var t = this,
977
+ d = t.doc,
978
+ prefix = t.o.prefix,
979
+ $dropdown = $('[data-dropdown=' + name + ']', t.$box),
980
+ $btn = $('.' + prefix + name + '-button', t.$btnPane),
981
+ show = $dropdown.is(':hidden');
982
+
983
+ $('body', d).trigger('mousedown');
984
+
985
+ if (show) {
986
+ var o = $btn.offset().left;
987
+ $btn.addClass(prefix + 'active');
988
+
989
+ $dropdown.css({
990
+ position: 'absolute',
991
+ top: $btn.offset().top - t.$btnPane.offset().top + $btn.outerHeight(),
992
+ left: (t.o.fixedFullWidth && t.isFixed) ? o + 'px' : (o - t.$btnPane.offset().left) + 'px'
993
+ }).show();
994
+
995
+ $(window).trigger('scroll');
996
+
997
+ $('body', d).on('mousedown.'+t.eventNamespace, function (e) {
998
+ if (!$dropdown.is(e.target)) {
999
+ $('.' + prefix + 'dropdown', d).hide();
1000
+ $('.' + prefix + 'active', d).removeClass(prefix + 'active');
1001
+ $('body', d).off('mousedown.'+t.eventNamespace);
1002
+ }
1003
+ });
1004
+ }
1005
+ },
1006
+
1007
+
1008
+ // HTML Code management
1009
+ html: function (html) {
1010
+ var t = this;
1011
+ if (html != null) {
1012
+ t.$ta.val(html);
1013
+ t.syncCode(true);
1014
+ return t;
1015
+ }
1016
+ return t.$ta.val();
1017
+ },
1018
+ syncTextarea: function () {
1019
+ var t = this;
1020
+ t.$ta.val(t.$ed.text().trim().length > 0 || t.$ed.find('hr,img,embed,iframe,input').length > 0 ? t.$ed.html() : '');
1021
+ },
1022
+ syncCode: function (force) {
1023
+ var t = this;
1024
+ if (!force && t.$ed.is(':visible')) {
1025
+ t.syncTextarea();
1026
+ } else {
1027
+ t.$ed.html(t.$ta.val());
1028
+ }
1029
+
1030
+ if (t.o.autogrow) {
1031
+ t.height = t.$ed.height();
1032
+ if (t.height !== t.$ta.css('height')) {
1033
+ t.$ta.css({height: t.height});
1034
+ t.$c.trigger('tbwresize');
1035
+ }
1036
+ }
1037
+ },
1038
+
1039
+ // Analyse and update to semantic code
1040
+ // @param force : force to sync code from textarea
1041
+ // @param full : wrap text nodes in <p>
1042
+ // @param keepRange : leave selection range as it is
1043
+ semanticCode: function (force, full, keepRange) {
1044
+ var t = this;
1045
+ t.saveRange();
1046
+ t.syncCode(force);
1047
+
1048
+ $(t.o.tagsToRemove.join(','), t.$ed).remove();
1049
+
1050
+ if (t.o.semantic) {
1051
+ t.semanticTag('b', 'strong');
1052
+ t.semanticTag('i', 'em');
1053
+
1054
+ if (full) {
1055
+ var inlineElementsSelector = t.o.inlineElementsSelector,
1056
+ blockElementsSelector = ':not(' + inlineElementsSelector + ')';
1057
+
1058
+ // Wrap text nodes in span for easier processing
1059
+ t.$ed.contents().filter(function () {
1060
+ return this.nodeType === 3 && this.nodeValue.trim().length > 0;
1061
+ }).wrap('<span data-tbw/>');
1062
+
1063
+ // Wrap groups of inline elements in paragraphs (recursive)
1064
+ var wrapInlinesInParagraphsFrom = function ($from) {
1065
+ if ($from.length !== 0) {
1066
+ var $finalParagraph = $from.nextUntil(blockElementsSelector).addBack().wrapAll('<p/>').parent(),
1067
+ $nextElement = $finalParagraph.nextAll(inlineElementsSelector).first();
1068
+ $finalParagraph.next('br').remove();
1069
+ wrapInlinesInParagraphsFrom($nextElement);
1070
+ }
1071
+ };
1072
+ wrapInlinesInParagraphsFrom(t.$ed.children(inlineElementsSelector).first());
1073
+
1074
+ t.semanticTag('div', 'p', true);
1075
+
1076
+ // Unwrap paragraphs content, containing nothing usefull
1077
+ t.$ed.find('p').filter(function () {
1078
+ // Don't remove currently being edited element
1079
+ if (t.range && this === t.range.startContainer) {
1080
+ return false;
1081
+ }
1082
+ return $(this).text().trim().length === 0 && $(this).children().not('br,span').length === 0;
1083
+ }).contents().unwrap();
1084
+
1085
+ // Get rid of temporial span's
1086
+ $('[data-tbw]', t.$ed).contents().unwrap();
1087
+
1088
+ // Remove empty <p>
1089
+ t.$ed.find('p:empty').remove();
1090
+ }
1091
+
1092
+ if (!keepRange) {
1093
+ t.restoreRange();
1094
+ }
1095
+
1096
+ t.syncTextarea();
1097
+ }
1098
+ },
1099
+
1100
+ semanticTag: function (oldTag, newTag, copyAttributes) {
1101
+ $(oldTag, this.$ed).each(function () {
1102
+ var $oldTag = $(this);
1103
+ $oldTag.wrap('<' + newTag + '/>');
1104
+ if (copyAttributes) {
1105
+ $.each($oldTag.prop('attributes'), function () {
1106
+ $oldTag.parent().attr(this.name, this.value);
1107
+ });
1108
+ }
1109
+ $oldTag.contents().unwrap();
1110
+ });
1111
+ },
1112
+
1113
+ // Function call when user click on "Insert Link"
1114
+ createLink: function () {
1115
+ var t = this,
1116
+ documentSelection = t.doc.getSelection(),
1117
+ node = documentSelection.focusNode,
1118
+ url,
1119
+ title,
1120
+ target;
1121
+
1122
+ while (['A', 'DIV'].indexOf(node.nodeName) < 0) {
1123
+ node = node.parentNode;
1124
+ }
1125
+
1126
+ if (node && node.nodeName === 'A') {
1127
+ var $a = $(node);
1128
+ url = $a.attr('href');
1129
+ title = $a.attr('title');
1130
+ target = $a.attr('target');
1131
+ var range = t.doc.createRange();
1132
+ range.selectNode(node);
1133
+ documentSelection.addRange(range);
1134
+ }
1135
+
1136
+ t.saveRange();
1137
+
1138
+ t.openModalInsert(t.lang.createLink, {
1139
+ url: {
1140
+ label: 'URL',
1141
+ required: true,
1142
+ value: url
1143
+ },
1144
+ title: {
1145
+ label: t.lang.title,
1146
+ value: title
1147
+ },
1148
+ text: {
1149
+ label: t.lang.text,
1150
+ value: t.getRangeText()
1151
+ },
1152
+ target: {
1153
+ label: t.lang.target,
1154
+ value: target
1155
+ }
1156
+ }, function (v) { // v is value
1157
+ var link = $(['<a href="', v.url, '">', v.text, '</a>'].join(''));
1158
+ if (v.title.length > 0) {
1159
+ link.attr('title', v.title);
1160
+ }
1161
+ if (v.target.length > 0) {
1162
+ link.attr('target', v.target);
1163
+ }
1164
+ t.range.deleteContents();
1165
+ t.range.insertNode(link[0]);
1166
+ return true;
1167
+ });
1168
+ },
1169
+ unlink: function () {
1170
+ var t = this,
1171
+ documentSelection = t.doc.getSelection(),
1172
+ node = documentSelection.focusNode;
1173
+
1174
+ if (documentSelection.isCollapsed) {
1175
+ while (['A', 'DIV'].indexOf(node.nodeName) < 0) {
1176
+ node = node.parentNode;
1177
+ }
1178
+
1179
+ if (node && node.nodeName === 'A') {
1180
+ var range = t.doc.createRange();
1181
+ range.selectNode(node);
1182
+ documentSelection.addRange(range);
1183
+ }
1184
+ }
1185
+ t.execCmd('unlink', undefined, undefined, true);
1186
+ },
1187
+ insertImage: function () {
1188
+ var t = this;
1189
+ t.saveRange();
1190
+ t.openModalInsert(t.lang.insertImage, {
1191
+ url: {
1192
+ label: 'URL',
1193
+ required: true
1194
+ },
1195
+ alt: {
1196
+ label: t.lang.description,
1197
+ value: t.getRangeText()
1198
+ }
1199
+ }, function (v) { // v are values
1200
+ t.execCmd('insertImage', v.url);
1201
+ $('img[src="' + v.url + '"]:not([alt])', t.$box).attr('alt', v.alt);
1202
+ return true;
1203
+ });
1204
+ },
1205
+ fullscreen: function () {
1206
+ var t = this,
1207
+ prefix = t.o.prefix,
1208
+ fullscreenCssClass = prefix + 'fullscreen',
1209
+ isFullscreen;
1210
+
1211
+ t.$box.toggleClass(fullscreenCssClass);
1212
+ isFullscreen = t.$box.hasClass(fullscreenCssClass);
1213
+ $('body').toggleClass(prefix + 'body-fullscreen', isFullscreen);
1214
+ $(window).trigger('scroll');
1215
+ t.$c.trigger('tbw' + (isFullscreen ? 'open' : 'close') + 'fullscreen');
1216
+ },
1217
+
1218
+
1219
+ /*
1220
+ * Call method of trumbowyg if exist
1221
+ * else try to call anonymous function
1222
+ * and finaly native execCommand
1223
+ */
1224
+ execCmd: function (cmd, param, forceCss, skipTrumbowyg) {
1225
+ var t = this;
1226
+ skipTrumbowyg = !!skipTrumbowyg || '';
1227
+
1228
+ if (cmd !== 'dropdown') {
1229
+ t.$ed.focus();
1230
+ }
1231
+
1232
+ try {
1233
+ t.doc.execCommand('styleWithCSS', false, forceCss || false);
1234
+ } catch (c) {
1235
+ }
1236
+
1237
+ try {
1238
+ t[cmd + skipTrumbowyg](param);
1239
+ } catch (c) {
1240
+ try {
1241
+ cmd(param);
1242
+ } catch (e2) {
1243
+ if (cmd === 'insertHorizontalRule') {
1244
+ param = undefined;
1245
+ } else if (cmd === 'formatBlock' && t.isIE) {
1246
+ param = '<' + param + '>';
1247
+ }
1248
+
1249
+ t.doc.execCommand(cmd, false, param);
1250
+
1251
+ t.syncCode();
1252
+ t.semanticCode(false, true);
1253
+ }
1254
+
1255
+ if (cmd !== 'dropdown') {
1256
+ t.updateButtonPaneStatus();
1257
+ t.$c.trigger('tbwchange');
1258
+ }
1259
+ }
1260
+ },
1261
+
1262
+
1263
+ // Open a modal box
1264
+ openModal: function (title, content) {
1265
+ var t = this,
1266
+ prefix = t.o.prefix;
1267
+
1268
+ // No open a modal box when exist other modal box
1269
+ if ($('.' + prefix + 'modal-box', t.$box).length > 0) {
1270
+ return false;
1271
+ }
1272
+
1273
+ t.saveRange();
1274
+ t.showOverlay();
1275
+
1276
+ // Disable all btnPane btns
1277
+ t.$btnPane.addClass(prefix + 'disable');
1278
+
1279
+ // Build out of ModalBox, it's the mask for animations
1280
+ var $modal = $('<div/>', {
1281
+ class: prefix + 'modal ' + prefix + 'fixed-top'
1282
+ }).css({
1283
+ top: t.$btnPane.height()
1284
+ }).appendTo(t.$box);
1285
+
1286
+ // Click on overlay close modal by cancelling them
1287
+ t.$overlay.one('click', function () {
1288
+ $modal.trigger('tbwcancel');
1289
+ return false;
1290
+ });
1291
+
1292
+ // Build the form
1293
+ var $form = $('<form/>', {
1294
+ action: '',
1295
+ html: content
1296
+ })
1297
+ .on('submit', function () {
1298
+ $modal.trigger('tbwconfirm');
1299
+ return false;
1300
+ })
1301
+ .on('reset', function () {
1302
+ $modal.trigger('tbwcancel');
1303
+ return false;
1304
+ });
1305
+
1306
+
1307
+ // Build ModalBox and animate to show them
1308
+ var $box = $('<div/>', {
1309
+ class: prefix + 'modal-box',
1310
+ html: $form
1311
+ })
1312
+ .css({
1313
+ top: '-' + t.$btnPane.outerHeight() + 'px',
1314
+ opacity: 0
1315
+ })
1316
+ .appendTo($modal)
1317
+ .animate({
1318
+ top: 0,
1319
+ opacity: 1
1320
+ }, 100);
1321
+
1322
+
1323
+ // Append title
1324
+ $('<span/>', {
1325
+ text: title,
1326
+ class: prefix + 'modal-title'
1327
+ }).prependTo($box);
1328
+
1329
+ $modal.height($box.outerHeight() + 10);
1330
+
1331
+
1332
+ // Focus in modal box
1333
+ $('input:first', $box).focus();
1334
+
1335
+
1336
+ // Append Confirm and Cancel buttons
1337
+ t.buildModalBtn('submit', $box);
1338
+ t.buildModalBtn('reset', $box);
1339
+
1340
+
1341
+ $(window).trigger('scroll');
1342
+
1343
+ return $modal;
1344
+ },
1345
+ // @param n is name of modal
1346
+ buildModalBtn: function (n, $modal) {
1347
+ var t = this,
1348
+ prefix = t.o.prefix;
1349
+
1350
+ return $('<button/>', {
1351
+ class: prefix + 'modal-button ' + prefix + 'modal-' + n,
1352
+ type: n,
1353
+ text: t.lang[n] || n
1354
+ }).appendTo($('form', $modal));
1355
+ },
1356
+ // close current modal box
1357
+ closeModal: function () {
1358
+ var t = this,
1359
+ prefix = t.o.prefix;
1360
+
1361
+ t.$btnPane.removeClass(prefix + 'disable');
1362
+ t.$overlay.off();
1363
+
1364
+ // Find the modal box
1365
+ var $modalBox = $('.' + prefix + 'modal-box', t.$box);
1366
+
1367
+ $modalBox.animate({
1368
+ top: '-' + $modalBox.height()
1369
+ }, 100, function () {
1370
+ $modalBox.parent().remove();
1371
+ t.hideOverlay();
1372
+ });
1373
+
1374
+ t.restoreRange();
1375
+ },
1376
+ // Preformated build and management modal
1377
+ openModalInsert: function (title, fields, cmd) {
1378
+ var t = this,
1379
+ prefix = t.o.prefix,
1380
+ lg = t.lang,
1381
+ html = '',
1382
+ CONFIRM_EVENT = 'tbwconfirm';
1383
+
1384
+ $.each(fields, function (fieldName, field) {
1385
+ var l = field.label,
1386
+ n = field.name || fieldName,
1387
+ a = field.attributes || {};
1388
+
1389
+ var attr = Object.keys(a).map(function (prop) {
1390
+ return prop + '="' + a[prop] + '"';
1391
+ }).join(' ');
1392
+
1393
+ html += '<label><input type="' + (field.type || 'text') + '" name="' + n + '" value="' + (field.value || '').replace(/"/g, '&quot;') + '"' + attr + '><span class="' + prefix + 'input-infos"><span>' +
1394
+ ((!l) ? (lg[fieldName] ? lg[fieldName] : fieldName) : (lg[l] ? lg[l] : l)) +
1395
+ '</span></span></label>';
1396
+ });
1397
+
1398
+ return t.openModal(title, html)
1399
+ .on(CONFIRM_EVENT, function () {
1400
+ var $form = $('form', $(this)),
1401
+ valid = true,
1402
+ values = {};
1403
+
1404
+ $.each(fields, function (fieldName, field) {
1405
+ var $field = $('input[name="' + fieldName + '"]', $form),
1406
+ inputType = $field.attr('type');
1407
+
1408
+ if (inputType.toLowerCase() === 'checkbox') {
1409
+ values[fieldName] = $field.is(':checked');
1410
+ } else {
1411
+ values[fieldName] = $.trim($field.val());
1412
+ }
1413
+ // Validate value
1414
+ if (field.required && values[fieldName] === '') {
1415
+ valid = false;
1416
+ t.addErrorOnModalField($field, t.lang.required);
1417
+ } else if (field.pattern && !field.pattern.test(values[fieldName])) {
1418
+ valid = false;
1419
+ t.addErrorOnModalField($field, field.patternError);
1420
+ }
1421
+ });
1422
+
1423
+ if (valid) {
1424
+ t.restoreRange();
1425
+
1426
+ if (cmd(values, fields)) {
1427
+ t.syncCode();
1428
+ t.$c.trigger('tbwchange');
1429
+ t.closeModal();
1430
+ $(this).off(CONFIRM_EVENT);
1431
+ }
1432
+ }
1433
+ })
1434
+ .one('tbwcancel', function () {
1435
+ $(this).off(CONFIRM_EVENT);
1436
+ t.closeModal();
1437
+ });
1438
+ },
1439
+ addErrorOnModalField: function ($field, err) {
1440
+ var prefix = this.o.prefix,
1441
+ $label = $field.parent();
1442
+
1443
+ $field
1444
+ .on('change keyup', function () {
1445
+ $label.removeClass(prefix + 'input-error');
1446
+ });
1447
+
1448
+ $label
1449
+ .addClass(prefix + 'input-error')
1450
+ .find('input+span')
1451
+ .append(
1452
+ $('<span/>', {
1453
+ class: prefix + 'msg-error',
1454
+ text: err
1455
+ })
1456
+ );
1457
+ },
1458
+
1459
+
1460
+ // Range management
1461
+ saveRange: function () {
1462
+ var t = this,
1463
+ documentSelection = t.doc.getSelection();
1464
+
1465
+ t.range = null;
1466
+
1467
+ if (documentSelection.rangeCount) {
1468
+ var savedRange = t.range = documentSelection.getRangeAt(0),
1469
+ range = t.doc.createRange(),
1470
+ rangeStart;
1471
+ range.selectNodeContents(t.$ed[0]);
1472
+ range.setEnd(savedRange.startContainer, savedRange.startOffset);
1473
+ rangeStart = (range + '').length;
1474
+ t.metaRange = {
1475
+ start: rangeStart,
1476
+ end: rangeStart + (savedRange + '').length
1477
+ };
1478
+ }
1479
+ },
1480
+ restoreRange: function () {
1481
+ var t = this,
1482
+ metaRange = t.metaRange,
1483
+ savedRange = t.range,
1484
+ documentSelection = t.doc.getSelection(),
1485
+ range;
1486
+
1487
+ if (!savedRange) {
1488
+ return;
1489
+ }
1490
+
1491
+ if (metaRange && metaRange.start !== metaRange.end) { // Algorithm from http://jsfiddle.net/WeWy7/3/
1492
+ var charIndex = 0,
1493
+ nodeStack = [t.$ed[0]],
1494
+ node,
1495
+ foundStart = false,
1496
+ stop = false;
1497
+
1498
+ range = t.doc.createRange();
1499
+
1500
+ while (!stop && (node = nodeStack.pop())) {
1501
+ if (node.nodeType === 3) {
1502
+ var nextCharIndex = charIndex + node.length;
1503
+ if (!foundStart && metaRange.start >= charIndex && metaRange.start <= nextCharIndex) {
1504
+ range.setStart(node, metaRange.start - charIndex);
1505
+ foundStart = true;
1506
+ }
1507
+ if (foundStart && metaRange.end >= charIndex && metaRange.end <= nextCharIndex) {
1508
+ range.setEnd(node, metaRange.end - charIndex);
1509
+ stop = true;
1510
+ }
1511
+ charIndex = nextCharIndex;
1512
+ } else {
1513
+ var cn = node.childNodes,
1514
+ i = cn.length;
1515
+
1516
+ while (i > 0) {
1517
+ i -= 1;
1518
+ nodeStack.push(cn[i]);
1519
+ }
1520
+ }
1521
+ }
1522
+ }
1523
+
1524
+ documentSelection.removeAllRanges();
1525
+ documentSelection.addRange(range || savedRange);
1526
+ },
1527
+ getRangeText: function () {
1528
+ return this.range + '';
1529
+ },
1530
+
1531
+ updateButtonPaneStatus: function () {
1532
+ var t = this,
1533
+ prefix = t.o.prefix,
1534
+ tags = t.getTagsRecursive(t.doc.getSelection().focusNode),
1535
+ activeClasses = prefix + 'active-button ' + prefix + 'active';
1536
+
1537
+ $('.' + prefix + 'active-button', t.$btnPane).removeClass(activeClasses);
1538
+ $.each(tags, function (i, tag) {
1539
+ var btnName = t.tagToButton[tag.toLowerCase()],
1540
+ $btn = $('.' + prefix + btnName + '-button', t.$btnPane);
1541
+
1542
+ if ($btn.length > 0) {
1543
+ $btn.addClass(activeClasses);
1544
+ } else {
1545
+ try {
1546
+ $btn = $('.' + prefix + 'dropdown .' + prefix + btnName + '-dropdown-button', t.$box);
1547
+ var dropdownBtnName = $btn.parent().data('dropdown');
1548
+ $('.' + prefix + dropdownBtnName + '-button', t.$box).addClass(activeClasses);
1549
+ } catch (e) {
1550
+ }
1551
+ }
1552
+ });
1553
+ },
1554
+ getTagsRecursive: function (element, tags) {
1555
+ var t = this;
1556
+ tags = tags || (element && element.tagName ? [element.tagName] : []);
1557
+
1558
+ if (element && element.parentNode) {
1559
+ element = element.parentNode;
1560
+ } else {
1561
+ return tags;
1562
+ }
1563
+
1564
+ var tag = element.tagName;
1565
+ if (tag === 'DIV') {
1566
+ return tags;
1567
+ }
1568
+ if (tag === 'P' && element.style.textAlign !== '') {
1569
+ tags.push(element.style.textAlign);
1570
+ }
1571
+
1572
+ $.each(t.tagHandlers, function (i, tagHandler) {
1573
+ tags = tags.concat(tagHandler(element, t));
1574
+ });
1575
+
1576
+ tags.push(tag);
1577
+
1578
+ return t.getTagsRecursive(element, tags);
1579
+ },
1580
+
1581
+ // Plugins
1582
+ initPlugins: function () {
1583
+ var t = this;
1584
+ t.loadedPlugins = [];
1585
+ $.each($.trumbowyg.plugins, function (name, plugin) {
1586
+ if (!plugin.shouldInit || plugin.shouldInit(t)) {
1587
+ plugin.init(t);
1588
+ if (plugin.tagHandler) {
1589
+ t.tagHandlers.push(plugin.tagHandler);
1590
+ }
1591
+ t.loadedPlugins.push(plugin);
1592
+ }
1593
+ });
1594
+ },
1595
+ destroyPlugins: function () {
1596
+ $.each(this.loadedPlugins, function (i, plugin) {
1597
+ if (plugin.destroy) {
1598
+ plugin.destroy();
1599
+ }
1600
+ });
1601
+ }
1602
+ };
1603
+ })(navigator, window, document, jQuery);