diff --git a/css/filedrop.css b/css/filedrop.css index 96dca339e9736b699b9249ef44c799c0584eacd7..7c11f8a2aa9768863b9b32575ef6d73426a9acfc 100644 --- a/css/filedrop.css +++ b/css/filedrop.css @@ -64,9 +64,9 @@ padding-left: 10px; float: right; } -.redactor_box + .filedrop .dropzone, -.redactor_box + div > .filedrop .dropzone, -.redactor_box + div > .filedrop .files { +.redactor-box + .filedrop .dropzone, +.redactor-box + div > .filedrop .dropzone, +.redactor-box + div > .filedrop .files { border-top-width: 1px; border-top-left-radius: 0; border-top-right-radius: 0; diff --git a/css/redactor.css b/css/redactor.css index d11d73b9b662f337472cc9fc0331d0ac67132d44..c77113360dd0a1fc068ac0cc5d00cca4d2f92474 100644 --- a/css/redactor.css +++ b/css/redactor.css @@ -11,310 +11,145 @@ font-weight: normal; font-style: normal; } -/* =Selection ------------------------------------------------------------------------------*/ -.redactor_box ::selection { - background: #ffff9e; -} -.redactor_box ::-moz-selection { - background: #ffff9e; -} -.redactor_box img::selection { - background: transparent; -} -.redactor_box img::-moz-selection { - background: transparent; -} /* - BOX + Box */ -.redactor_box { +.redactor-box { position: relative; overflow: visible; background: #fff; } -.redactor_box iframe { +.redactor-box iframe, +.redactor-box textarea { display: block; + position: relative; margin: 0; padding: 0; + width: 100%; +} +.redactor-box iframe { border: 1px solid #eee; } -.redactor_box textarea { - position: relative; - display: block; +.redactor-box textarea { overflow: auto; - margin: 0; - padding: 0; - width: 100%; outline: none; border: none; - background-color: #222; + background-color: #111; box-shadow: none; color: #ccc; font-size: 13px; font-family: Menlo, Monaco, monospace, sans-serif; resize: none; } -.redactor_box textarea:focus { +.redactor-box textarea:focus { outline: none; } -.redactor_box, -.redactor_box textarea { +/* + Z-index setup +*/ +.redactor-editor, +.redactor-box { + background: #fff; +} +.redactor-editor, +.redactor-box, +.redactor-box textarea { z-index: auto !important; } -.redactor_box_fullscreen { +.redactor-box-fullscreen { z-index: 99 !important; } -#redactor_modal_overlay, -#redactor_modal, -.redactor_dropdown { - z-index: 100 !important; +.redactor-toolbar, +.redactor-dropdown { + z-index: 5 !important; +} +#redactor-modal-overlay, +#redactor-modal-box, +#redactor-modal { + z-index: 11 !important; } /* - AIR - + Resize */ -body .redactor_air { - position: absolute; - z-index: 502; +.redactor-resize { + background: #f4f4f4; + padding: 4px 0 3px 0; + cursor: move; + border: 1px solid #e3e3e3; + border-top: none; +} +.redactor-resize div { + width: 30px; + margin: auto; + border-top: 1px solid #bbb; + border-bottom: 1px solid #fff; } /* - FULLSCREEN + Fullscreen */ -body .redactor_box_fullscreen { +body .redactor-box-fullscreen { position: fixed; top: 0; left: 0; width: 100%; } /* - LINK TOOLTIP + Utils */ -.redactor-link-tooltip { - position: absolute; - z-index: 49999; - padding: 10px; - line-height: 1; - display: inline-block; - background-color: #000; - color: #555 !important; -} -.redactor-link-tooltip, -.redactor-link-tooltip a { - font-size: 12px; - font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; -} -.redactor-link-tooltip a { - color: #ccc; - margin: 0 5px; - text-decoration: none; -} -.redactor-link-tooltip a:hover { - color: #fff; +.body-hidden { + overflow: hidden; } /* - IMAGE BOX + Editor */ -#redactor-image-box img { - width: 100%; -} -.redactor_editor { +.redactor-editor { position: relative; overflow: auto; margin: 0 !important; - padding: 10px 10px; - padding-bottom: 5px; + padding: 10px; outline: none; - background: none; - background: #fff; - box-shadow: none !important; white-space: normal; border: 1px solid #eee; -} -.redactor_editor:focus { - outline: none; -} -.redactor_editor div, -.redactor_editor p, -.redactor_editor ul, -.redactor_editor ol, -.redactor_editor table, -.redactor_editor dl, -.redactor_editor blockquote, -.redactor_editor pre, -.redactor_editor h1, -.redactor_editor h2, -.redactor_editor h3, -.redactor_editor h4, -.redactor_editor h5, -.redactor_editor h6 { + border-top: none; font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; -} -.redactor_editor code, -.redactor_editor pre { - font-family: Menlo, Monaco, monospace, sans-serif; -} -.redactor_editor div, -.redactor_editor p, -.redactor_editor ul, -.redactor_editor ol, -.redactor_editor table, -.redactor_editor dl, -.redactor_editor blockquote, -.redactor_editor pre { font-size: 14px; line-height: 1.6em; } -.redactor_editor a { - color: #15c !important; - text-decoration: underline !important; -} -.redactor_editor .redactor_placeholder { - color: #999 !important; - display: block !important; +.redactor-editor:focus { + outline: none; } /* - TYPOGRAPHY + Placeholder */ -.redactor_editor object, -.redactor_editor embed, -.redactor_editor video, -.redactor_editor img { - max-width: 100%; - width: auto; -} -.redactor_editor video, -.redactor_editor img { - height: auto; -} -.redactor_editor p, -.redactor_editor ul, -.redactor_editor ol, -.redactor_editor table, -.redactor_editor dl, -.redactor_editor blockquote, -.redactor_editor pre { - margin: 0; - margin-bottom: 10px !important; - border: none; - background: none !important; - box-shadow: none !important; -} -.redactor_editor iframe, -.redactor_editor object, -.redactor_editor hr { - margin-bottom: 15px !important; -} -.redactor_editor blockquote { - color: #777; - padding: 10px 20px; - font-style: italic !important; - border-left: 5px solid #eeeeee; -} -[dir="rtl"] .redactor_editor blockquote { - border-left: none; - border-right: 5px solid #eeeeee; -} -.redactor_editor ul, -.redactor_editor ol { - padding-left: 2em !important; -} -.redactor_editor ul ul, -.redactor_editor ol ol, -.redactor_editor ul ol, -.redactor_editor ol ul { - margin: 2px !important; - padding: 0 !important; - padding-left: 2em !important; - border: none; -} -.redactor_editor dl dt { - font-weight: bold; -} -.redactor_editor dd { - margin-left: 1em; -} -.redactor_editor table { - border-collapse: collapse; - font-size: 1em !important; -} -.redactor_editor table td { - padding: 5px !important; - border: 1px solid #ddd; - vertical-align: top; -} -.redactor_editor table thead td { - border-bottom: 2px solid #000 !important; - font-weight: bold !important; -} -.redactor_editor code { - background-color: #d8d7d7 !important; +.redactor-placeholder { + position: relative; } -.redactor_editor pre { - overflow: auto; - padding: 1em !important; - border: 1px solid #ddd !important; - border-radius: 3px !important; - background: #f8f8f8 !important; - white-space: pre; - font-size: 90% !important; +.redactor-placeholder:after { + position: absolute; + top: 20px; + left: 20px; + content: attr(placeholder); + color: #999 !important; + font-weight: normal !important; } -.redactor_editor hr { - display: block; - height: 1px; - border: 0; - border-top: 1px solid #ccc; +.redactor-placeholder[dir=rtl]:after { + left: initial; + right: 20px; } -/* - HEADERS -*/ -.redactor_editor h1, -.redactor_editor h2, -.redactor_editor h3, -.redactor_editor h4, -.redactor_editor h5, -.redactor_editor h6 { - margin-top: 0 !important; - padding: 0 !important; - background: none; - color: #000; - font-weight: bold; + +/* Placeholder in linebreaks mode */ +.redactor-linebreaks.redactor-placeholder:after { + top: 10px; + left: 10px; } -.redactor_editor h1 { - font-size: 36px !important; - line-height: 1.111em !important; - margin-bottom: .15em !important; -} -.redactor_editor h2 { - font-size: 30px !important; - line-height: 1.111em !important; - margin-bottom: .25em !important; -} -.redactor_editor h3 { - font-size: 24px !important; - line-height: 1.333em !important; - margin-bottom: .2em !important; -} -.redactor_editor h4 { - font-size: 18px !important; - line-height: 1.5em !important; - margin-bottom: .2em !important; -} -.redactor_editor h5 { - font-size: 1em !important; - line-height: 1.6em !important; - margin-bottom: .25em !important; -} -.redactor_editor h6 { - font-size: .8em !important; - line-height: 1.6em !important; - text-transform: uppercase; - margin-bottom: .3em !important; +.redactor-linebreaks.redactor-placeholder[dir=rtl]:after { + left: initial; + right: 10px; } /* - TOOLBAR + Toolbar */ -.redactor_toolbar { +.redactor-toolbar { position: relative; top: 0; left: 0; @@ -322,31 +157,28 @@ body .redactor_box_fullscreen { padding: 0 !important; list-style: none !important; font-size: 14px !important; - font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; line-height: 1 !important; background: #fff; border: none; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); z-index: 1; } -.redactor_toolbar:after { +.redactor-toolbar:after { content: ""; display: table; /* clear: both; */ } -.redactor_toolbar.redactor-toolbar-overflow { +.redactor-toolbar.redactor-toolbar-overflow { overflow-y: auto; height: 29px; white-space: nowrap; } -.redactor_toolbar.redactor-toolbar-external { +.redactor-toolbar.redactor-toolbar-external { + z-index: 999; box-shadow: none; border: 1px solid rgba(0, 0, 0, 0.1); } -body .redactor_air .redactor_toolbar { - padding-right: 2px !important; -} -.redactor_toolbar li { +.redactor-toolbar li { vertical-align: top; display: inline-block; margin: 0 !important; @@ -357,7 +189,7 @@ body .redactor_air .redactor_toolbar { -moz-box-sizing: content-box; box-sizing: content-box; } -.redactor_toolbar li a { +.redactor-toolbar li a { display: block; color: #333; text-align: center; @@ -371,57 +203,45 @@ body .redactor_air .redactor_toolbar { -moz-box-sizing: content-box; box-sizing: content-box; } -.redactor_toolbar li a:hover { +.redactor-toolbar li a:hover { outline: none; background-color: #1f78d8; color: #fff; - text-decoration: none; } -.redactor_toolbar li a:hover i:before { +.redactor-toolbar li a:hover i:before { color: #fff; } -.redactor_toolbar li a:active, -.redactor_toolbar li a.redactor_act { +.redactor-toolbar li a:active, +.redactor-toolbar li a.redactor-act { outline: none; background-color: #ccc; color: #444; } -.redactor_toolbar li a.redactor-btn-image { +.redactor-toolbar li a.redactor-btn-image { width: 14px; height: 14px; background-position: center center; background-repeat: no-repeat; } -.redactor_button_disabled { +.redactor-toolbar li a.fa-redactor-btn { + display: inline-block; + padding: 9px 10px 8px 10px; + line-height: 1; +} +.redactor-toolbar li a.redactor-button-disabled { filter: alpha(opacity=30); -moz-opacity: 0.3; opacity: 0.3; } -.redactor_button_disabled:hover { +.redactor-toolbar li a.redactor-button-disabled:hover { + color: #333; outline: none; background-color: transparent !important; cursor: default; } -.redactor_toolbar li a.fa-redactor-btn { - display: inline-block; - padding: 9px 10px 8px 10px; - line-height: 1; -} -.redactor_toolbar.redactor-toolbar-typewriter { - box-shadow: none; - background: rgba(240, 240, 240, 0.9); -} -.redactor_toolbar.redactor-toolbar-typewriter li a:hover { - outline: none; - background-color: #1f78d8; - color: #fff; -} -.redactor_toolbar.redactor-toolbar-typewriter li a:active, -.redactor_toolbar.redactor-toolbar-typewriter li a.redactor_act { - outline: none; - background-color: #ccc; - color: #444; -} +/* + Icons +*/ .re-icon { font-family: 'RedactorFont'; speak: none; @@ -535,192 +355,192 @@ body .redactor_air .redactor_toolbar { content: "\e61f"; } /* - Toolbar classes + Toolbar tooltip */ -.redactor_format_blockquote { - padding-left: 10px; - color: #666 !important; - font-style: italic; -} -.redactor_format_pre { - font-family: monospace, sans-serif; -} -.redactor_format_h1, -.redactor_format_h2, -.redactor_format_h3, -.redactor_format_h4, -.redactor_format_h5 { - font-weight: bold; +.redactor-toolbar-tooltip { + position: absolute; + z-index: 100; + text-align: center; + top: 0; + left: 0; + background: #000; + color: #fff; + padding: 5px 8px; + line-height: 1; + font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; + font-size: 12px; + border-radius: 2px; } -.redactor_format_h1 { - font-size: 30px; - line-height: 36px; +/* + Dropdown +*/ +.redactor-dropdown { + position: absolute; + top: 28px; + left: 0; + padding: 0; + min-width: 220px; + max-height: 254px; + overflow: auto; + background-color: #fff; + box-shadow: 0 1px 7px rgba(0, 0, 0, 0.25); + font-size: 14px; + font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; + line-height: 1.6em; } -.redactor_format_h2 { - font-size: 24px; - line-height: 36px; +.redactor-dropdown a { + display: block; + padding: 10px 15px; + color: #000; + text-decoration: none; + border-bottom: 1px solid rgba(0, 0, 0, 0.07); } -.redactor_format_h3 { - font-size: 20px; - line-height: 30px; +.redactor-dropdown a:last-child { + border-bottom: none; } -.redactor_format_h4 { - font-size: 16px; - line-height: 26px; +.redactor-dropdown a:hover { + background-color: #1f78d8; + color: #fff !important; + text-decoration: none; } -.redactor_format_h5 { - font-size: 14px; - line-height: 23px; +/* + IMAGE BOX +*/ +#redactor-image-box { + position: relative; + max-width: 100%; + display: inline-block; + line-height: 0; + outline: 1px dashed rgba(0, 0, 0, 0.6); } -.redactor-toolbar-typewriter .redactor_dropdown .redactor_format_h1, -.redactor-toolbar-typewriter .redactor_dropdown .redactor_format_h2, -.redactor-toolbar-typewriter .redactor_dropdown .redactor_format_h3, -.redactor-toolbar-typewriter .redactor_dropdown .redactor_format_h4, -.redactor-toolbar-typewriter .redactor_dropdown .redactor_format_h5 { - font-size: 1em; - line-height: 1.6em; - text-transform: uppercase; +#redactor-image-editter { + position: absolute; + z-index: 5; + top: 50%; + left: 50%; + margin-top: -11px; + margin-left: -18px; + line-height: 1; + background-color: #000; + color: #fff; + font-size: 11px; + padding: 7px 10px; + cursor: pointer; } -.redactor-toolbar-typewriter .redactor_dropdown .redactor_format_h2 { - font-size: .85em; +#redactor-image-resizer { + position: absolute; + z-index: 2; + line-height: 1; + cursor: nw-resize; + bottom: -4px; + right: -5px; + border: 1px solid #fff; + background-color: #000; + width: 8px; + height: 8px; } /* - Typewriter + LINK TOOLTIP */ -.redactor_editor.redactor-editor-typewriter { - background: #f5f5f5 !important; - padding: 25px 50px !important; -} -.redactor_editor.redactor-editor-typewriter div, -.redactor_editor.redactor-editor-typewriter p, -.redactor_editor.redactor-editor-typewriter ul, -.redactor_editor.redactor-editor-typewriter ol, -.redactor_editor.redactor-editor-typewriter table, -.redactor_editor.redactor-editor-typewriter dl, -.redactor_editor.redactor-editor-typewriter blockquote, -.redactor_editor.redactor-editor-typewriter pre, -.redactor_editor.redactor-editor-typewriter h1, -.redactor_editor.redactor-editor-typewriter h2, -.redactor_editor.redactor-editor-typewriter h3, -.redactor_editor.redactor-editor-typewriter h4, -.redactor_editor.redactor-editor-typewriter h5, -.redactor_editor.redactor-editor-typewriter h6 { - font-family: 'Courier New', 'Lucida Console', Consolas, Monaco, monospace, sans-serif; - font-size: 18px !important; - line-height: 1.5em !important; - margin-bottom: 1.5em !important; -} -.redactor_editor.redactor-editor-typewriter h2 { - font-size: 14px !important; +.redactor-link-tooltip { + position: absolute; + z-index: 49999; + padding: 10px; + line-height: 1; + display: inline-block; + background-color: #000; + color: #555 !important; } -.redactor_editor.redactor-editor-typewriter h1, -.redactor_editor.redactor-editor-typewriter h2, -.redactor_editor.redactor-editor-typewriter h3, -.redactor_editor.redactor-editor-typewriter h4, -.redactor_editor.redactor-editor-typewriter h5, -.redactor_editor.redactor-editor-typewriter h6 { - text-transform: uppercase; +.redactor-link-tooltip, +.redactor-link-tooltip a { + font-size: 12px; + font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; +} +.redactor-link-tooltip a { + color: #ccc; + margin: 0 5px; + text-decoration: none; } -.redactor_editor.redactor-editor-typewriter a { - color: #000 !important; - text-decoration: underline !important; +.redactor-link-tooltip a:hover { + color: #fff; } /* - WYM + DROPAREA */ -.redactor_editor.redactor_editor_wym { - padding: 10px 7px 0 7px !important; - background: #f6f6f6 !important; -} -.redactor_editor.redactor_editor_wym div, -.redactor_editor.redactor_editor_wym p, -.redactor_editor.redactor_editor_wym ul, -.redactor_editor.redactor_editor_wym ol, -.redactor_editor.redactor_editor_wym table, -.redactor_editor.redactor_editor_wym dl, -.redactor_editor.redactor_editor_wym pre, -.redactor_editor.redactor_editor_wym h1, -.redactor_editor.redactor_editor_wym h2, -.redactor_editor.redactor_editor_wym h3, -.redactor_editor.redactor_editor_wym h4, -.redactor_editor.redactor_editor_wym h5, -.redactor_editor.redactor_editor_wym h6, -.redactor_editor.redactor_editor_wym blockquote { - margin-top: 0; - margin-bottom: 5px !important; - padding: 10px !important; - border: 1px solid #e4e4e4 !important; - background-color: #fff !important; - z-index: 0; -} -.redactor_editor.redactor_editor_wym blockquote:before { - content: ''; -} -.redactor_editor.redactor_editor_wym img { +#redactor-droparea { position: relative; - z-index: 1; -} -.redactor_editor.redactor_editor_wym div { - border: 1px dotted #aaa !important; + overflow: hidden; + padding: 140px 20px; + border: 3px dashed rgba(0, 0, 0, 0.1); } -.redactor_editor.redactor_editor_wym pre { - border: 2px dashed #e4e4e4 !important; - background-color: #f8f8f8 !important; +#redactor-droparea.drag-hover { + background: rgba(200, 222, 250, 0.75); } -.redactor_editor.redactor_editor_wym ul, -.redactor_editor.redactor_editor_wym ol { - padding-left: 2em !important; +#redactor-droparea.drag-drop { + background: rgba(250, 248, 200, 0.5); } -.redactor_editor.redactor_editor_wym ul li ul, -.redactor_editor.redactor_editor_wym ol li ul, -.redactor_editor.redactor_editor_wym ul li ol, -.redactor_editor.redactor_editor_wym ol li ol { - border: none !important; +#redactor-droparea-placeholder { + text-align: center; + font-size: 12px; + color: rgba(0, 0, 0, 0.7); } /* - DROPDOWN + PROGRESS */ -.redactor_dropdown { - position: absolute; - top: 28px; +#redactor-progress { + position: fixed; + top: 0; left: 0; - padding: 10px; - width: 200px; - background-color: #fff; - box-shadow: 0 1px 5px #bbb; - font-size: 13px; - font-family: Helvetica, Arial, Verdana, Tahoma, sans-serif; - line-height: 21px; + width: 100%; + z-index: 1000000; + height: 10px; } -.redactor-toolbar-typewriter .redactor_dropdown { - font-family: 'Courier New', 'Lucida Console', Consolas, Monaco, monospace, sans-serif; - background-color: #f5f5f5; +#redactor-progress span { + display: block; + width: 100%; + height: 100%; + background-color: #3d58a8; + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent); + background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent); + -webkit-animation: progress-bar-stripes 2s linear infinite; + -o-animation: progress-bar-stripes 2s linear infinite; + animation: progress-bar-stripes 2s linear infinite; + background-size: 40px 40px; } -.redactor_separator_drop { - padding: 0 !important; - border-top: 1px solid #ddd; - font-size: 0; - line-height: 0; +@-webkit-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } } -.redactor_dropdown a { - display: block; - padding: 3px 5px; - color: #000; - text-decoration: none; +@-o-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } } -.redactor_dropdown a:hover { - background-color: #dde4ef; - color: #444 !important; - text-decoration: none; +@keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } } /* MODAL */ -#redactor_modal_overlay { +#redactor-modal-overlay { position: fixed; top: 0; left: 0; margin: auto; + overflow: auto; width: 100%; height: 100%; background-color: #000 !important; @@ -728,140 +548,163 @@ body .redactor_air .redactor_toolbar { -moz-opacity: 0.3; opacity: 0.3; } -#redactor_modal { +#redactor-modal-box { position: fixed; - top: 50%; - left: 50%; + top: 0; + left: 0; + bottom: 0; + right: 0; + overflow-x: hidden; + overflow-y: auto; +} +#redactor-modal { + position: relative; + margin: auto; + margin-bottom: 20px; padding: 0; background: #fff; color: #000; - font-size: 12px !important; + font-size: 14px !important; font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; - box-shadow: 0 1px 10px rgba(0, 0, 0, 0.5); + box-shadow: 0 1px 70px rgba(0, 0, 0, 0.5); } -#redactor_modal header { - padding: 20px 30px 5px 30px; - font-size: 16px; +#redactor-modal header { + padding: 30px 40px 5px 40px; + font-size: 18px; + font-weight: bold; } -#redactor_modal section { - padding: 20px 30px; +#redactor-modal section { + padding: 30px 40px 50px 40px; } -#redactor_modal label { - display: block !important; +#redactor-modal label { + display: block; float: none !important; - margin: 10px 0 3px 0 !important; - padding: 0 !important; - font-size: 12px !important; -} -#redactor_modal footer:after { - content: ""; - display: table; - clear: both; -} -#redactor_modal footer div { - float: left; + margin: 15px 0 3px 0 !important; + padding: 0; } -#redactor_modal input[type="radio"], -#redactor_modal input[type="checkbox"] { +#redactor-modal input[type="radio"], +#redactor-modal input[type="checkbox"] { position: relative; top: -1px; } -#redactor_modal input[type="text"], -#redactor_modal input[type="password"], -#redactor_modal input[type="email"], -#redactor_modal textarea { +#redactor-modal select { + width: 100%; +} +#redactor-modal input[type="text"], +#redactor-modal input[type="password"], +#redactor-modal input[type="email"], +#redactor-modal input[type="url"], +#redactor-modal textarea { position: relative; z-index: 2; margin: 0; - padding: 1px 2px; - height: 23px; + padding: 5px 4px; + height: 28px; border: 1px solid #ccc; border-radius: 1px; background-color: white; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) inset; color: #333; - font-size: 13px; + width: 100%; + font-size: 14px; font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; - line-height: 1; -moz-transition: border 0.3s ease-in; transition: border 0.3s ease-in; } -#redactor_modal textarea { - display: block; - margin-top: 4px; - line-height: 1.4em; -} -#redactor_modal input:focus, -#redactor_modal textarea:focus { +#redactor-modal input[type="text"]:focus, +#redactor-modal input[type="password"]:focus, +#redactor-modal input[type="email"]:focus, +#redactor-modal input[type="url"]:focus, +#redactor-modal textarea:focus { outline: none; border-color: #5ca9e4; box-shadow: 0 0 0 2px rgba(70, 161, 231, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2) inset; } -#redactor_modal_close { - position: absolute; - top: 5px; - right: 3px; - width: 20px; - height: 20px; - color: #999; - font-size: 26px; - cursor: pointer; +#redactor-modal input[type="text"].redactor-input-error, +#redactor-modal input[type="password"].redactor-input-error, +#redactor-modal input[type="email"].redactor-input-error, +#redactor-modal input[type="url"].redactor-input-error, +#redactor-modal textarea.redactor-input-error { + border-color: #e82f2f; + box-shadow: 0 0 0 2px rgba(232, 47, 47, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2) inset; } -#redactor_modal_close:hover { - color: #000; +#redactor-modal textarea { + display: block; + margin-top: 4px; + line-height: 1.4em; } -.redactor_input { - width: 99%; - font-size: 14px; +/* + Tabs in Modal +*/ +#redactor-modal-tabber { + margin-bottom: 15px; + font-size: 12px; } -.redactor_modal_box { - overflow: auto; - margin-bottom: 10px; - height: 350px; +#redactor-modal-tabber a { + border: 1px solid #ddd; + line-height: 1; + padding: 8px 15px; + margin-right: -1px; + text-decoration: none; + color: #000; } -#redactor_image_box { - overflow: auto; - margin-bottom: 10px; - height: 270px; +#redactor-modal-tabber a:hover { + background-color: #1f78d8; + border-color: #1f78d8; + color: #fff; } -#redactor_image_box_select { - display: block; - margin-bottom: 15px !important; - width: 200px; +#redactor-modal-tabber a.active { + cursor: default; + background-color: #ddd; + border-color: #ddd; + color: rgba(0, 0, 0, 0.6); } -#redactor_image_box img { - margin-right: 10px; - margin-bottom: 10px; - max-width: 100px; - cursor: pointer; +/* + List in Modal +*/ +#redactor-modal #redactor-modal-list { + margin-left: 0; + padding-left: 0; + list-style: none; + max-height: 250px; + overflow-x: scroll; } -#redactor_tabs { - margin-bottom: 18px; +#redactor-modal #redactor-modal-list li { + border-bottom: 1px solid #ddd; } -#redactor_tabs a { - display: inline-block; - margin-right: 2px; - padding: 4px 14px; - border: 1px solid #d2d2d2; - border-radius: 3px; - background: #fff; +#redactor-modal #redactor-modal-list li:last-child { + border-bottom: none; +} +#redactor-modal #redactor-modal-list a { + padding: 10px 5px; color: #000; text-decoration: none; - line-height: 1; + font-size: 13px; + display: block; + position: relative; } -#redactor_tabs a:hover, -#redactor_tabs a.redactor_tabs_act { - border-color: #eee; - color: #999 !important; - text-decoration: none !important; +#redactor-modal #redactor-modal-list a:hover { + background-color: #eee; } -.redactor_modal_btn_hidden { - display: none; +#redactor-modal-close { + position: absolute; + top: 10px; + right: 10px; + width: 30px; + height: 30px; + text-align: right; + color: #bbb; + font-size: 30px; + font-weight: 300; + cursor: pointer; } -#redactor_modal footer button { +#redactor-modal-close:hover { + color: #000; +} +#redactor-modal footer button { position: relative; width: 100%; - padding: 10px 16px; + padding: 14px 16px; margin: 0; outline: none; border: none; @@ -875,110 +718,230 @@ body .redactor_air .redactor_toolbar { line-height: 1; cursor: pointer; } -#redactor_modal footer button:hover { +#redactor-modal footer button:hover { color: #777; background: none; background: #bbb; text-decoration: none; } -#redactor_modal footer button.redactor_modal_delete_btn { +#redactor-modal footer button.redactor-modal-delete-btn { background: none; color: #fff; background-color: #b52525; } -#redactor_modal footer button.redactor_modal_delete_btn:hover { +#redactor-modal footer button.redactor-modal-delete-btn:hover { color: rgba(255, 255, 255, 0.6); background-color: #881b1b; } -#redactor_modal footer button.redactor_modal_action_btn { +#redactor-modal footer button.redactor-modal-action-btn { background: none; color: #fff; background-color: #2461b5; } -#redactor_modal footer button.redactor_modal_action_btn:hover { +#redactor-modal footer button.redactor-modal-action-btn:hover { color: rgba(255, 255, 255, 0.6); background-color: #1a4580; } -/* Drag and Drop Area */ -.redactor_droparea { - position: relative; - margin: auto; - margin-bottom: 5px; - width: 100%; +/* + ############################################## + + DROPDOWN FORMATTING + + ############################################## +*/ +.redactor-dropdown .redactor-formatting-blockquote { + color: rgba(0, 0, 0, 0.4); + font-style: italic; } -.redactor_droparea .redactor_dropareabox { - position: relative; - z-index: 1; - padding: 60px 0; - width: 99%; - border: 1px dashed #ddd; - background: #fff; - text-align: center; +.redactor-dropdown .redactor-formatting-pre { + font-family: monospace, sans-serif; } -.redactor_droparea .redactor_dropareabox, -.redactor_dropalternative { - color: #555; - font-size: 12px; +.redactor-dropdown .redactor-formatting-h1 { + font-size: 36px; + line-height: 36px; + font-weight: bold; } -.redactor_dropalternative { - margin: 4px 0 2px 0; +.redactor-dropdown .redactor-formatting-h2 { + font-size: 24px; + line-height: 36px; + font-weight: bold; } -.redactor_dropareabox.hover { - border-color: #aaa; - background: #efe3b8; +.redactor-dropdown .redactor-formatting-h3 { + font-size: 21px; + line-height: 30px; + font-weight: bold; } -.redactor_dropareabox.error { - border-color: #dcc3c3; - background: #f7e5e5; +.redactor-dropdown .redactor-formatting-h4 { + font-size: 18px; + line-height: 26px; + font-weight: bold; } -.redactor_dropareabox.drop { - border-color: #e0e5d6; - background: #f4f4ee; +.redactor-dropdown .redactor-formatting-h5 { + font-size: 16px; + line-height: 23px; + font-weight: bold; } -/* =ProgressBar ------------------------------------------------------------------------------*/ -#redactor-progress { - position: fixed; - top: 0; - left: 0; +/* + ############################################## + + CONTENT STYLES + + ############################################## +*/ +.redactor-editor code, +.redactor-editor pre { + font-family: Menlo, Monaco, monospace, sans-serif; +} +.redactor-editor div, +.redactor-editor p, +.redactor-editor ul, +.redactor-editor ol, +.redactor-editor table, +.redactor-editor dl, +.redactor-editor blockquote, +.redactor-editor pre { + font-size: 14px; + line-height: 1.6em; +} +.redactor-editor a { + color: #15c; + text-decoration: underline; +} +.redactor-editor object, +.redactor-editor embed, +.redactor-editor video, +.redactor-editor img { + max-width: 100%; + width: auto; +} +.redactor-editor video, +.redactor-editor img { + height: auto; +} +.redactor-editor div, +.redactor-editor p, +.redactor-editor ul, +.redactor-editor ol, +.redactor-editor table, +.redactor-editor dl, +.redactor-editor figure, +.redactor-editor blockquote, +.redactor-editor pre { + margin: 0; + margin-bottom: 15px; + border: none; + background: none; + box-shadow: none; +} +.redactor-editor iframe, +.redactor-editor object, +.redactor-editor hr { + margin-bottom: 15px; +} +.redactor-editor iframe { + width: auto; +} +.redactor-editor blockquote { + margin-left: 1.6em !important; + padding-left: 0; + color: #777; + font-style: italic; +} +.redactor-editor ul, +.redactor-editor ol { + padding-left: 2em; +} +.redactor-editor ul ul, +.redactor-editor ol ol, +.redactor-editor ul ol, +.redactor-editor ol ul { + margin: 2px; + padding: 0; + padding-left: 2em; + border: none; +} +.redactor-editor dl dt { + font-weight: bold; +} +.redactor-editor dd { + margin-left: 1em; +} +.redactor-editor table { + border-collapse: collapse; + font-size: 1em; width: 100%; - z-index: 1000000; - height: 10px; } -#redactor-progress span { +.redactor-editor table td, +.redactor-editor table th { + padding: 5px; + border: 1px solid #ddd; + vertical-align: top; +} +.redactor-editor table thead td, +.redactor-editor table th { + font-weight: bold; + border-bottom-color: #888; +} +.redactor-editor code { + background-color: #d8d7d7; +} +.redactor-editor pre { + overflow: auto; + padding: 1em; + border: 1px solid #ddd; + border-radius: 3px; + background: #f8f8f8; + white-space: pre; + font-size: 90%; +} +.redactor-editor hr { display: block; - width: 100%; - height: 100%; - background-color: #3d58a8; - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent); - background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent); - -webkit-animation: progress-bar-stripes 2s linear infinite; - -o-animation: progress-bar-stripes 2s linear infinite; - animation: progress-bar-stripes 2s linear infinite; - background-size: 40px 40px; + height: 1px; + border: 0; + border-top: 1px solid #ccc; } -@-webkit-keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } +.redactor-editor h1, +.redactor-editor h2, +.redactor-editor h3, +.redactor-editor h4, +.redactor-editor h5, +.redactor-editor h6 { + font-weight: bold; + color: #000; + padding: 0; + background: none; + text-rendering: optimizeLegibility; + margin: 0 0 .5em 0; } -@-o-keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } +.redactor-editor h1, +.redactor-editor h2, +.redactor-editor h3, +.redactor-editor h4 { + line-height: 1.3; } -@keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } +.redactor-editor h1 { + font-size: 36px; +} +.redactor-editor h2 { + font-size: 24px; + margin-bottom: .7em; +} +.redactor-editor h3 { + font-size: 21px; +} +.redactor-editor h4 { + font-size: 18px; +} +.redactor-editor h5 { + font-size: 16px; +} +.redactor-editor h6 { + font-size: 12px; + text-transform: uppercase; +} +.redactor-dropdown *, +#redactor-modal * { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } diff --git a/include/ajax.draft.php b/include/ajax.draft.php index fa9d5c9b638f7ea81af2a8f78a94d1331591197c..5795b24e3f00e562059819db2c5369522416251b 100644 --- a/include/ajax.draft.php +++ b/include/ajax.draft.php @@ -61,6 +61,21 @@ class DraftAjaxAPI extends AjaxController { unset($_FILES['file']); $file = AttachmentFile::format($_FILES['image']); + # Allow for data-uri uploaded files + $fp = fopen($file[0]['tmp_name'], 'rb'); + if (fread($fp, 5) == 'data:') { + $data = 'data:'; + while ($block = fread($fp, 8192)) + $data .= $block; + $file[0] = Format::parseRfc2397($data); + list(,$ext) = explode('/', $file[0]['type'], 2); + $file[0] += array( + 'name' => Misc::randCode(8).'.'.$ext, + 'size' => strlen($file[0]['data']), + ); + } + fclose($fp); + # TODO: Detect unacceptable attachment extension # TODO: Verify content-type and check file-content to ensure image $type = $file[0]['type']; @@ -79,8 +94,14 @@ class DraftAjaxAPI extends AjaxController { )) ); + if (isset($file[0]['tmp_name'])) { + $ids = $draft->attachments->upload($file); + } + else { + $ids = $draft->attachments->save($file[0]); + } - if (!($ids = $draft->attachments->upload($file))) { + if (!$ids) { if ($file[0]['error']) { return Http::response(403, JsonDataEncoder::encode(array( @@ -92,7 +113,7 @@ class DraftAjaxAPI extends AjaxController { return Http::response(500, 'Unable to attach image'); } - $id = $ids[0]; + $id = (is_array($ids)) ? $ids[0] : $ids; } else { $type = explode('/', $_POST['contentType']); @@ -318,11 +339,23 @@ class DraftAjaxAPI extends AjaxController { if (!$thisstaff) Http::response(403, "Login required for file queries"); + if (isset($_GET['threadId']) && is_numeric($_GET['threadId']) + && ($thread = Thread::lookup($_GET['threadId'])) + && ($object = $thread->getObject()) + && ($thisstaff->canAccess($object)) + ) { + $union = ' UNION SELECT f.id, a.`type` FROM '.THREAD_TABLE.' t + JOIN '.THREAD_ENTRY_TABLE.' th ON (th.thread_id = t.id) + JOIN '.ATTACHMENT_TABLE.' a ON (a.object_id = th.id AND a.`type` = \'H\') + JOIN '.FILE_TABLE.' f ON (a.file_id = f.id) + WHERE t.id='.db_input($_GET['threadId']); + } + $sql = 'SELECT distinct f.id, COALESCE(a.type, f.ft) FROM '.FILE_TABLE .' f LEFT JOIN '.ATTACHMENT_TABLE.' a ON (a.file_id = f.id) - WHERE (a.`type` IN (\'C\', \'F\', \'T\', \'P\') OR f.ft = \'L\') - AND f.`type` LIKE \'image/%\''; - if (!($res = db_query($sql))) + WHERE (a.`type` IN (\'C\', \'F\', \'T\', \'P\') OR f.ft = \'L\')' + .' AND f.`type` LIKE \'image/%\''; + if (!($res = db_query($sql.$union))) Http::response(500, 'Unable to lookup files'); $files = array(); @@ -332,12 +365,15 @@ class DraftAjaxAPI extends AjaxController { 'T' => __('Email Templates'), 'L' => __('Logos'), 'P' => __('Pages'), + 'H' => __('This Thread'), ); while (list($id, $type) = db_fetch_row($res)) { $f = AttachmentFile::lookup($id); $url = $f->getDownloadUrl(); $files[] = array( - 'thumb'=>$url.'&s=128', + // Don't send special sizing for thread items 'cause they + // should be cached already by the client + 'thumb'=>$url.($type != 'H' ? '&s=128' : ''), 'image'=>$url, 'title'=>$f->getName(), 'folder'=>$folders[$type] diff --git a/include/class.draft.php b/include/class.draft.php index d777338d2296f39352dbe2488587a9b11f30ec1b..49503ed7c66bcc367580ab55779cc109ad4be07f 100644 --- a/include/class.draft.php +++ b/include/class.draft.php @@ -93,7 +93,9 @@ class Draft extends VerySimpleModel { function setBody($body) { // Change file.php urls back to content-id's - $body = Format::sanitize($body, false); + $body = Format::sanitize($body, false, + // Preserve annotation information, if any + 'img=data-annotations,data-orig-annotated-image-src'); $this->body = $body ?: ' '; $this->updated = SqlFunction::NOW(); diff --git a/include/class.format.php b/include/class.format.php index 9e6c8998538bdfbe908693ece1cf9428a151bee8..7c06ee1c464dd85db22afb8d2fabcf5f4a71e360 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -233,7 +233,7 @@ class Format { } } - function safe_html($html) { + function safe_html($html, $spec=false) { // Remove HEAD and STYLE sections $html = preg_replace( array(':<(head|style|script).+?</\1>:is', # <head> and <style> sections @@ -252,7 +252,7 @@ class Format { 'schemes' => 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; *:file, http, https; src: cid, http, https, data', 'hook_tag' => function($e, $a=0) { return Format::__html_cleanup($e, $a); }, 'elements' => '*+iframe', - 'spec' => 'iframe=-*,height,width,type,src(match="`^(https?:)?//(www\.)?(youtube|dailymotion|vimeo)\.com/`i"),frameborder; div=data-mid', + 'spec' => 'iframe=-*,height,width,type,src(match="`^(https?:)?//(www\.)?(youtube|dailymotion|vimeo)\.com/`i"),frameborder; div=data-mid'.($spec ? '; '.$spec : ''), ); return Format::html($html, $config); @@ -265,10 +265,10 @@ class Format { 'src="cid:$1', $text); } - function sanitize($text, $striptags=false) { + function sanitize($text, $striptags=false, $spec=false) { //balance and neutralize unsafe tags. - $text = Format::safe_html($text); + $text = Format::safe_html($text, $spec); $text = self::localizeInlineImages($text); diff --git a/include/class.staff.php b/include/class.staff.php index 94dcc68cec4e8b7565e682c33d07289f07a2d7a4..3201db170e8e1364d992e1d753ac2932dc1103eb 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -150,6 +150,13 @@ implements AuthenticatedUser { && $this->passwd_change>($cfg->getPasswdResetPeriod()*30*24*60*60)); } + function canAccess($something) { + if ($something instanceof RestrictedAccess) + return $something->checkStaffPerm($this); + + return true; + } + function isPasswdChangeDue() { return $this->isPasswdResetDue(); } @@ -835,4 +842,8 @@ implements AuthenticatedUser { return false; } } + +interface RestrictedAccess { + function checkStaffPerm($staff); +} ?> diff --git a/include/class.ticket.php b/include/class.ticket.php index 5348791c5cfe50a535a4d481a6df9e86a900210e..0b3c6574107193faf282fccb2fe34a0b32ab026b 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -216,7 +216,8 @@ class TicketCData extends VerySimpleModel { TicketCData::$meta['table'] = TABLE_PREFIX . 'ticket__cdata'; -class Ticket { +class Ticket +implements RestrictedAccess { var $id; var $number; diff --git a/include/client/header.inc.php b/include/client/header.inc.php index 1c3f00dbd0cb09990c64306267527b75a5a67181..4a6324a58e3da655bcf47face2cbd7b5020857b1 100644 --- a/include/client/header.inc.php +++ b/include/client/header.inc.php @@ -40,6 +40,7 @@ if (($lang = Internationalization::getCurrentLanguage()) <script type="text/javascript" src="<?php echo ROOT_PATH; ?>js/filedrop.field.js"></script> <script src="<?php echo ROOT_PATH; ?>scp/js/bootstrap-typeahead.js"></script> <script type="text/javascript" src="<?php echo ROOT_PATH; ?>js/redactor.min.js"></script> + <script type="text/javascript" src="<?php echo ROOT_PATH; ?>js/redactor-plugins.js"></script> <script type="text/javascript" src="<?php echo ROOT_PATH; ?>js/redactor-osticket.js"></script> <script type="text/javascript" src="<?php echo ROOT_PATH; ?>js/redactor-fonts.js"></script> <script type="text/javascript" src="<?php echo ROOT_PATH; ?>js/chosen.jquery.min.js"></script> diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php index ba294007755d41549bf35c9806bf32215f6df1e8..b640573a569f9181e98a03a6ccbc90e10d7d79e8 100644 --- a/include/staff/header.inc.php +++ b/include/staff/header.inc.php @@ -27,7 +27,7 @@ if (($lang = Internationalization::getCurrentLanguage()) <script type="text/javascript" src="./js/tips.js"></script> <script type="text/javascript" src="<?php echo ROOT_PATH; ?>js/redactor.min.js"></script> <script type="text/javascript" src="<?php echo ROOT_PATH; ?>js/redactor-osticket.js"></script> - <script type="text/javascript" src="<?php echo ROOT_PATH; ?>js/redactor-fonts.js"></script> + <script type="text/javascript" src="<?php echo ROOT_PATH; ?>js/redactor-plugins.js"></script> <script type="text/javascript" src="./js/bootstrap-typeahead.js"></script> <script type="text/javascript" src="./js/jquery.translatable.js"></script> <link rel="stylesheet" href="<?php echo ROOT_PATH ?>css/thread.css" media="all"> diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 83d249fd32dc2a789756cb621de47f9b5ac5de4d..eb34d70a3e82222da418dc6c025081487bf4490c 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -390,7 +390,7 @@ $tcount+= $ticket->getNumNotes(); ?></a></li> </ul> <div id="ticket_tabs_container"> - <div id="ticket_thread" class="tab_content"> + <div id="ticket_thread" data-thread-id="<?php echo $ticket->getThread()->getId(); ?>" class="tab_content"> <?php $threadTypes=array('M'=>'message','R'=>'response', 'N'=>'note'); /* -------- Messages & Responses & Notes (if inline)-------------*/ diff --git a/js/fabric.min.js b/js/fabric.min.js new file mode 100644 index 0000000000000000000000000000000000000000..dbcd34b8697579c8b766d39959771260dfaa7ade --- /dev/null +++ b/js/fabric.min.js @@ -0,0 +1,8 @@ +/* build: `node build.js modules=ALL exclude=gestures,cufon,json minifier=uglifyjs` *//*! Fabric.js Copyright 2008-2014, Printio (Juriy Zaytsev, Maxim Chernyak) */var fabric=fabric||{version:"1.4.13"};typeof exports!="undefined"&&(exports.fabric=fabric),typeof document!="undefined"&&typeof window!="undefined"?(fabric.document=document,fabric.window=window):(fabric.document=require("jsdom").jsdom("<!DOCTYPE html><html><head></head><body></body></html>"),fabric.document.createWindow?fabric.window=fabric.document.createWindow():fabric.window=fabric.document.parentWindow),fabric.isTouchSupported="ontouchstart"in fabric.document.documentElement,fabric.isLikelyNode=typeof Buffer!="undefined"&&typeof window=="undefined",fabric.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width"],fabric.DPI=96,fabric.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:e[-+]?\\d+)?)",function(){function e(e,t){if(!this.__eventListeners[e])return;t?fabric.util.removeFromArray(this.__eventListeners[e],t):this.__eventListeners[e].length=0}function t(e,t){this.__eventListeners||(this.__eventListeners={});if(arguments.length===1)for(var n in e)this.on(n,e[n]);else this.__eventListeners[e]||(this.__eventListeners[e]=[]),this.__eventListeners[e].push(t);return this}function n(t,n){if(!this.__eventListeners)return;if(arguments.length===0)this.__eventListeners={};else if(arguments.length===1&&typeof arguments[0]=="object")for(var r in t)e.call(this,r,t[r]);else e.call(this,t,n);return this}function r(e,t){if(!this.__eventListeners)return;var n=this.__eventListeners[e];if(!n)return;for(var r=0,i=n.length;r<i;r++)n[r].call(this,t||{});return this}fabric.Observable={observe:t,stopObserving:n,fire:r,on:t,off:n,trigger:r}}(),fabric.Collection={add:function(){this._objects.push.apply(this._objects,arguments);for(var e=0,t=arguments.length;e<t;e++)this._onObjectAdded(arguments[e]);return this.renderOnAddRemove&&this.renderAll(),this},insertAt:function(e,t,n){var r=this.getObjects();return n?r[t]=e:r.splice(t,0,e),this._onObjectAdded(e),this.renderOnAddRemove&&this.renderAll(),this},remove:function(){var e=this.getObjects(),t;for(var n=0,r=arguments.length;n<r;n++)t=e.indexOf(arguments[n]),t!==-1&&(e.splice(t,1),this._onObjectRemoved(arguments[n]));return this.renderOnAddRemove&&this.renderAll(),this},forEachObject:function(e,t){var n=this.getObjects(),r=n.length;while(r--)e.call(t,n[r],r,n);return this},getObjects:function(e){return typeof e=="undefined"?this._objects:this._objects.filter(function(t){return t.type===e})},item:function(e){return this.getObjects()[e]},isEmpty:function(){return this.getObjects().length===0},size:function(){return this.getObjects().length},contains:function(e){return this.getObjects().indexOf(e)>-1},complexity:function(){return this.getObjects().reduce(function(e,t){return e+=t.complexity?t.complexity():0,e},0)}},function(e){var t=Math.sqrt,n=Math.atan2,r=Math.PI/180;fabric.util={removeFromArray:function(e,t){var n=e.indexOf(t);return n!==-1&&e.splice(n,1),e},getRandomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e},degreesToRadians:function(e){return e*r},radiansToDegrees:function(e){return e/r},rotatePoint:function(e,t,n){var r=Math.sin(n),i=Math.cos(n);e.subtractEquals(t);var s=e.x*i-e.y*r,o=e.x*r+e.y*i;return(new fabric.Point(s,o)).addEquals(t)},transformPoint:function(e,t,n){return n?new fabric.Point(t[0]*e.x+t[1]*e.y,t[2]*e.x+t[3]*e.y):new fabric.Point(t[0]*e.x+t[1]*e.y+t[4],t[2]*e.x+t[3]*e.y+t[5])},invertTransform:function(e){var t=e.slice(),n=1/(e[0]*e[3]-e[1]*e[2]);t=[n*e[3],-n*e[1],-n*e[2],n*e[0],0,0];var r=fabric.util.transformPoint({x:e[4],y:e[5]},t);return t[4]=-r.x,t[5]=-r.y,t},toFixed:function(e,t){return parseFloat(Number(e).toFixed(t))},parseUnit:function(e,t){var n=/\D{0,2}$/.exec(e),r=parseFloat(e);t||(t=fabric.Text.DEFAULT_SVG_FONT_SIZE);switch(n[0]){case"mm":return r*fabric.DPI/25.4;case"cm":return r*fabric.DPI/2.54;case"in":return r*fabric.DPI;case"pt":return r*fabric.DPI/72;case"pc":return r*fabric.DPI/72*12;case"em":return r*t;default:return r}},falseFunction:function(){return!1},getKlass:function(e,t){return e=fabric.util.string.camelize(e.charAt(0).toUpperCase()+e.slice(1)),fabric.util.resolveNamespace(t)[e]},resolveNamespace:function(t){if(!t)return fabric;var n=t.split("."),r=n.length,i=e||fabric.window;for(var s=0;s<r;++s)i=i[n[s]];return i},loadImage:function(e,t,n,r){if(!e){t&&t.call(n,e);return}var i=fabric.util.createImage();i.onload=function(){t&&t.call(n,i),i=i.onload=i.onerror=null},i.onerror=function(){fabric.log("Error loading "+i.src),t&&t.call(n,null,!0),i=i.onload=i.onerror=null},e.indexOf("data")!==0&&typeof r!="undefined"&&(i.crossOrigin=r),i.src=e},enlivenObjects:function(e,t,n,r){function i(){++o===u&&t&&t(s)}e=e||[];var s=[],o=0,u=e.length;if(!u){t&&t(s);return}e.forEach(function(e,t){if(!e||!e.type){i();return}var o=fabric.util.getKlass(e.type,n);o.async?o.fromObject(e,function(n,o){o||(s[t]=n,r&&r(e,s[t])),i()}):(s[t]=o.fromObject(e),r&&r(e,s[t]),i())})},groupSVGElements:function(e,t,n){var r;return r=new fabric.PathGroup(e,t),typeof n!="undefined"&&r.setSourcePath(n),r},populateWithProperties:function(e,t,n){if(n&&Object.prototype.toString.call(n)==="[object Array]")for(var r=0,i=n.length;r<i;r++)n[r]in e&&(t[n[r]]=e[n[r]])},drawDashedLine:function(e,r,i,s,o,u){var a=s-r,f=o-i,l=t(a*a+f*f),c=n(f,a),h=u.length,p=0,d=!0;e.save(),e.translate(r,i),e.moveTo(0,0),e.rotate(c),r=0;while(l>r)r+=u[p++%h],r>l&&(r=l),e[d?"lineTo":"moveTo"](r,0),d=!d;e.restore()},createCanvasElement:function(e){return e||(e=fabric.document.createElement("canvas")),!e.getContext&&typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement(e),e},createImage:function(){return fabric.isLikelyNode?new(require("canvas").Image):fabric.document.createElement("img")},createAccessors:function(e){var t=e.prototype;for(var n=t.stateProperties.length;n--;){var r=t.stateProperties[n],i=r.charAt(0).toUpperCase()+r.slice(1),s="set"+i,o="get"+i;t[o]||(t[o]=function(e){return new Function('return this.get("'+e+'")')}(r)),t[s]||(t[s]=function(e){return new Function("value",'return this.set("'+e+'", value)')}(r))}},clipContext:function(e,t){t.save(),t.beginPath(),e.clipTo(t),t.clip()},multiplyTransformMatrices:function(e,t){var n=[[e[0],e[2],e[4]],[e[1],e[3],e[5]],[0,0,1]],r=[[t[0],t[2],t[4]],[t[1],t[3],t[5]],[0,0,1]],i=[];for(var s=0;s<3;s++){i[s]=[];for(var o=0;o<3;o++){var u=0;for(var a=0;a<3;a++)u+=n[s][a]*r[a][o];i[s][o]=u}}return[i[0][0],i[1][0],i[0][1],i[1][1],i[0][2],i[1][2]]},getFunctionBody:function(e){return(String(e).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]},isTransparent:function(e,t,n,r){r>0&&(t>r?t-=r:t=0,n>r?n-=r:n=0);var i=!0,s=e.getImageData(t,n,r*2||1,r*2||1);for(var o=3,u=s.data.length;o<u;o+=4){var a=s.data[o];i=a<=0;if(i===!1)break}return s=null,i}}}(typeof exports!="undefined"?exports:this),function(){function i(t,n,i,u,a,f,l){var c=r.call(arguments);if(e[c])return e[c];var h=Math.PI,p=l*h/180,d=Math.sin(p),v=Math.cos(p),m=0,g=0;i=Math.abs(i),u=Math.abs(u);var y=-v*t*.5-d*n*.5,b=-v*n*.5+d*t*.5,w=i*i,E=u*u,S=b*b,x=y*y,T=w*E-w*S-E*x,N=0;if(T<0){var C=Math.sqrt(1-T/(w*E));i*=C,u*=C}else N=(a===f?-1:1)*Math.sqrt(T/(w*S+E*x));var k=N*i*b/u,L=-N*u*y/i,A=v*k-d*L+t*.5,O=d*k+v*L+n*.5,M=o(1,0,(y-k)/i,(b-L)/u),_=o((y-k)/i,(b-L)/u,(-y-k)/i,(-b-L)/u);f===0&&_>0?_-=2*h:f===1&&_<0&&(_+=2*h);var D=Math.ceil(Math.abs(_/h*2)),P=[],H=_/D,B=8/3*Math.sin(H/4)*Math.sin(H/4)/Math.sin(H/2),j=M+H;for(var F=0;F<D;F++)P[F]=s(M,j,v,d,i,u,A,O,B,m,g),m=P[F][4],g=P[F][5],M=j,j+=H;return e[c]=P,P}function s(e,n,i,s,o,u,a,f,l,c,h){var p=r.call(arguments);if(t[p])return t[p];var d=Math.cos(e),v=Math.sin(e),m=Math.cos(n),g=Math.sin(n),y=i*o*m-s*u*g+a,b=s*o*m+i*u*g+f,w=c+l*(-i*o*v-s*u*d),E=h+l*(-s*o*v+i*u*d),S=y+l*(i*o*g+s*u*m),x=b+l*(s*o*g-i*u*m);return t[p]=[w,E,S,x,y,b],t[p]}function o(e,t,n,r){var i=Math.atan2(t,e),s=Math.atan2(r,n);return s>=i?s-i:2*Math.PI-(i-s)}function u(e,t,i,s,o,u,a,f){var l=r.call(arguments);if(n[l])return n[l];var c=Math.sqrt,h=Math.min,p=Math.max,d=Math.abs,v=[],m=[[],[]],g,y,b,w,E,S,x,T;y=6*e-12*i+6*o,g=-3*e+9*i-9*o+3*a,b=3*i-3*e;for(var N=0;N<2;++N){N>0&&(y=6*t-12*s+6*u,g=-3*t+9*s-9*u+3*f,b=3*s-3*t);if(d(g)<1e-12){if(d(y)<1e-12)continue;w=-b/y,0<w&&w<1&&v.push(w);continue}x=y*y-4*b*g;if(x<0)continue;T=c(x),E=(-y+T)/(2*g),0<E&&E<1&&v.push(E),S=(-y-T)/(2*g),0<S&&S<1&&v.push(S)}var C,k,L=v.length,A=L,O;while(L--)w=v[L],O=1-w,C=O*O*O*e+3*O*O*w*i+3*O*w*w*o+w*w*w*a,m[0][L]=C,k=O*O*O*t+3*O*O*w*s+3*O*w*w*u+w*w*w*f,m[1][L]=k;m[0][A]=e,m[1][A]=t,m[0][A+1]=a,m[1][A+1]=f;var M=[{x:h.apply(null,m[0]),y:h.apply(null,m[1])},{x:p.apply(null,m[0]),y:p.apply(null,m[1])}];return n[l]=M,M}var e={},t={},n={},r=Array.prototype.join;fabric.util.drawArc=function(e,t,n,r){var s=r[0],o=r[1],u=r[2],a=r[3],f=r[4],l=r[5],c=r[6],h=[[],[],[],[]],p=i(l-t,c-n,s,o,a,f,u);for(var d=0,v=p.length;d<v;d++)h[d][0]=p[d][0]+t,h[d][1]=p[d][1]+n,h[d][2]=p[d][2]+t,h[d][3]=p[d][3]+n,h[d][4]=p[d][4]+t,h[d][5]=p[d][5]+n,e.bezierCurveTo.apply(e,h[d])},fabric.util.getBoundsOfArc=function(e,t,n,r,s,o,a,f,l){var c=0,h=0,p=[],d=[],v=i(f-e,l-t,n,r,o,a,s);for(var m=0,g=v.length;m<g;m++)p=u(c,h,v[m][0],v[m][1],v[m][2],v[m][3],v[m][4],v[m][5]),p[0].x+=e,p[0].y+=t,p[1].x+=e,p[1].y+=t,d.push(p[0]),d.push(p[1]),c=v[m][4],h=v[m][5];return d},fabric.util.getBoundsOfCurve=u}(),function(){function t(t,n){var r=e.call(arguments,2),i=[];for(var s=0,o=t.length;s<o;s++)i[s]=r.length?t[s][n].apply(t[s],r):t[s][n].call(t[s]);return i}function n(e,t){return i(e,t,function(e,t){return e>=t})}function r(e,t){return i(e,t,function(e,t){return e<t})}function i(e,t,n){if(!e||e.length===0)return;var r=e.length-1,i=t?e[r][t]:e[r];if(t)while(r--)n(e[r][t],i)&&(i=e[r][t]);else while(r--)n(e[r],i)&&(i=e[r]);return i}var e=Array.prototype.slice;Array.prototype.indexOf||(Array.prototype.indexOf=function(e){if(this===void 0||this===null)throw new TypeError;var t=Object(this),n=t.length>>>0;if(n===0)return-1;var r=0;arguments.length>0&&(r=Number(arguments[1]),r!==r?r=0:r!==0&&r!==Number.POSITIVE_INFINITY&&r!==Number.NEGATIVE_INFINITY&&(r=(r>0||-1)*Math.floor(Math.abs(r))));if(r>=n)return-1;var i=r>=0?r:Math.max(n-Math.abs(r),0);for(;i<n;i++)if(i in t&&t[i]===e)return i;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(e,t){for(var n=0,r=this.length>>>0;n<r;n++)n in this&&e.call(t,this[n],n,this)}),Array.prototype.map||(Array.prototype.map=function(e,t){var n=[];for(var r=0,i=this.length>>>0;r<i;r++)r in this&&(n[r]=e.call(t,this[r],r,this));return n}),Array.prototype.every||(Array.prototype.every=function(e,t){for(var n=0,r=this.length>>>0;n<r;n++)if(n in this&&!e.call(t,this[n],n,this))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(e,t){for(var n=0,r=this.length>>>0;n<r;n++)if(n in this&&e.call(t,this[n],n,this))return!0;return!1}),Array.prototype.filter||(Array.prototype.filter=function(e,t){var n=[],r;for(var i=0,s=this.length>>>0;i<s;i++)i in this&&(r=this[i],e.call(t,r,i,this)&&n.push(r));return n}),Array.prototype.reduce||(Array.prototype.reduce=function(e){var t=this.length>>>0,n=0,r;if(arguments.length>1)r=arguments[1];else do{if(n in this){r=this[n++];break}if(++n>=t)throw new TypeError}while(!0);for(;n<t;n++)n in this&&(r=e.call(null,r,this[n],n,this));return r}),fabric.util.array={invoke:t,min:r,max:n}}(),function(){function e(e,t){for(var n in t)e[n]=t[n];return e}function t(t){return e({},t)}fabric.util.object={extend:e,clone:t}}(),function(){function e(e){return e.replace(/-+(.)?/g,function(e,t){return t?t.toUpperCase():""})}function t(e,t){return e.charAt(0).toUpperCase()+(t?e.slice(1):e.slice(1).toLowerCase())}function n(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}),fabric.util.string={camelize:e,capitalize:t,escapeXml:n}}(),function(){var e=Array.prototype.slice,t=Function.prototype.apply,n=function(){};Function.prototype.bind||(Function.prototype.bind=function(r){var i=this,s=e.call(arguments,1),o;return s.length?o=function(){return t.call(i,this instanceof n?this:r,s.concat(e.call(arguments)))}:o=function(){return t.call(i,this instanceof n?this:r,arguments)},n.prototype=this.prototype,o.prototype=new n,o})}(),function(){function i(){}function s(t){var n=this.constructor.superclass.prototype[t];return arguments.length>1?n.apply(this,e.call(arguments,1)):n.call(this)}function o(){function u(){this.initialize.apply(this,arguments)}var n=null,o=e.call(arguments,0);typeof o[0]=="function"&&(n=o.shift()),u.superclass=n,u.subclasses=[],n&&(i.prototype=n.prototype,u.prototype=new i,n.subclasses.push(u));for(var a=0,f=o.length;a<f;a++)r(u,o[a],n);return u.prototype.initialize||(u.prototype.initialize=t),u.prototype.constructor=u,u.prototype.callSuper=s,u}var e=Array.prototype.slice,t=function(){},n=function(){for(var e in{toString:1})if(e==="toString")return!1;return!0}(),r=function(e,t,r){for(var i in t)i in e.prototype&&typeof e.prototype[i]=="function"&&(t[i]+"").indexOf("callSuper")>-1?e.prototype[i]=function(e){return function(){var n=this.constructor.superclass;this.constructor.superclass=r;var i=t[e].apply(this,arguments);this.constructor.superclass=n;if(e!=="initialize")return i}}(i):e.prototype[i]=t[i],n&&(t.toString!==Object.prototype.toString&&(e.prototype.toString=t.toString),t.valueOf!==Object.prototype.valueOf&&(e.prototype.valueOf=t.valueOf))};fabric.util.createClass=o}(),function(){function t(e){var t=Array.prototype.slice.call(arguments,1),n,r,i=t.length;for(r=0;r<i;r++){n=typeof e[t[r]];if(!/^(?:function|object|unknown)$/.test(n))return!1}return!0}function s(e,t){return{handler:t,wrappedHandler:o(e,t)}}function o(e,t){return function(r){t.call(n(e),r||fabric.window.event)}}function u(e,t){return function(n){if(c[e]&&c[e][t]){var r=c[e][t];for(var i=0,s=r.length;i<s;i++)r[i].call(this,n||fabric.window.event)}}}function d(t,n){t||(t=fabric.window.event);var r=t.target||(typeof t.srcElement!==e?t.srcElement:null),i=fabric.util.getScrollLeftTop(r,n);return{x:v(t)+i.left,y:m(t)+i.top}}function g(e,t,n){var r=e.type==="touchend"?"changedTouches":"touches";return e[r]&&e[r][0]?e[r][0][t]-(e[r][0][t]-e[r][0][n])||e[n]:e[n]}var e="unknown",n,r,i=function(){var e=0;return function(t){return t.__uniqueID||(t.__uniqueID="uniqueID__"+e++)}}();(function(){var e={};n=function(t){return e[t]},r=function(t,n){e[t]=n}})();var a=t(fabric.document.documentElement,"addEventListener","removeEventListener")&&t(fabric.window,"addEventListener","removeEventListener"),f=t(fabric.document.documentElement,"attachEvent","detachEvent")&&t(fabric.window,"attachEvent","detachEvent"),l={},c={},h,p;a?(h=function(e,t,n){e.addEventListener(t,n,!1)},p=function(e,t,n){e.removeEventListener(t,n,!1)}):f?(h=function(e,t,n){var o=i(e);r(o,e),l[o]||(l[o]={}),l[o][t]||(l[o][t]=[]);var u=s(o,n);l[o][t].push(u),e.attachEvent("on"+t,u.wrappedHandler)},p=function(e,t,n){var r=i(e),s;if(l[r]&&l[r][t])for(var o=0,u=l[r][t].length;o<u;o++)s=l[r][t][o],s&&s.handler===n&&(e.detachEvent("on"+t,s.wrappedHandler),l[r][t][o]=null)}):(h=function(e,t,n){var r=i(e);c[r]||(c[r]={});if(!c[r][t]){c[r][t]=[];var s=e["on"+t];s&&c[r][t].push(s),e["on"+t]=u(r,t)}c[r][t].push(n)},p=function(e,t,n){var r=i(e);if(c[r]&&c[r][t]){var s=c[r][t];for(var o=0,u=s.length;o<u;o++)s[o]===n&&s.splice(o,1)}}),fabric.util.addListener=h,fabric.util.removeListener=p;var v=function(t){return typeof t.clientX!==e?t.clientX:0},m=function(t){return typeof t.clientY!==e?t.clientY:0};fabric.isTouchSupported&&(v=function(e){return g(e,"pageX","clientX")},m=function(e){return g(e,"pageY","clientY")}),fabric.util.getPointer=d,fabric.util.object.extend(fabric.util,fabric.Observable)}(),function(){function e(e,t){var n=e.style;if(!n)return e;if(typeof t=="string")return e.style.cssText+=";"+t,t.indexOf("opacity")>-1?s(e,t.match(/opacity:\s*(\d?\.?\d*)/)[1]):e;for(var r in t)if(r==="opacity")s(e,t[r]);else{var i=r==="float"||r==="cssFloat"?typeof n.styleFloat=="undefined"?"cssFloat":"styleFloat":r;n[i]=t[r]}return e}var t=fabric.document.createElement("div"),n=typeof t.style.opacity=="string",r=typeof t.style.filter=="string",i=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,s=function(e){return e};n?s=function(e,t){return e.style.opacity=t,e}:r&&(s=function(e,t){var n=e.style;return e.currentStyle&&!e.currentStyle.hasLayout&&(n.zoom=1),i.test(n.filter)?(t=t>=.9999?"":"alpha(opacity="+t*100+")",n.filter=n.filter.replace(i,t)):n.filter+=" alpha(opacity="+t*100+")",e}),fabric.util.setStyle=e}(),function(){function t(e){return typeof e=="string"?fabric.document.getElementById(e):e}function s(e,t){var n=fabric.document.createElement(e);for(var r in t)r==="class"?n.className=t[r]:r==="for"?n.htmlFor=t[r]:n.setAttribute(r,t[r]);return n}function o(e,t){e&&(" "+e.className+" ").indexOf(" "+t+" ")===-1&&(e.className+=(e.className?" ":"")+t)}function u(e,t,n){return typeof t=="string"&&(t=s(t,n)),e.parentNode&&e.parentNode.replaceChild(t,e),t.appendChild(e),t}function a(e,t){var n,r,i=0,s=0,o=fabric.document.documentElement,u=fabric.document.body||{scrollLeft:0,scrollTop:0};r=e;while(e&&e.parentNode&&!n)e=e.parentNode,e.nodeType===1&&fabric.util.getElementStyle(e,"position")==="fixed"&&(n=e),e.nodeType===1&&r!==t&&fabric.util.getElementStyle(e,"position")==="absolute"?(i=0,s=0):e===fabric.document?(i=u.scrollLeft||o.scrollLeft||0,s=u.scrollTop||o.scrollTop||0):(i+=e.scrollLeft||0,s+=e.scrollTop||0);return{left:i,top:s}}function f(e){var t,n=e&&e.ownerDocument,r={left:0,top:0},i={left:0,top:0},s,o={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!n)return{left:0,top:0};for(var u in o)i[o[u]]+=parseInt(l(e,u),10)||0;return t=n.documentElement,typeof e.getBoundingClientRect!="undefined"&&(r=e.getBoundingClientRect()),s=fabric.util.getScrollLeftTop(e,null),{left:r.left+s.left-(t.clientLeft||0)+i.left,top:r.top+s.top-(t.clientTop||0)+i.top}}var e=Array.prototype.slice,n,r=function(t){return e.call(t,0)};try{n=r(fabric.document.childNodes)instanceof Array}catch(i){}n||(r=function(e){var t=new Array(e.length),n=e.length;while(n--)t[n]=e[n];return t});var l;fabric.document.defaultView&&fabric.document.defaultView.getComputedStyle?l=function(e,t){var n=fabric.document.defaultView.getComputedStyle(e,null);return n?n[t]:undefined}:l=function(e,t){var n=e.style[t];return!n&&e.currentStyle&&(n=e.currentStyle[t]),n},function(){function n(e){return typeof e.onselectstart!="undefined"&&(e.onselectstart=fabric.util.falseFunction),t?e.style[t]="none":typeof e.unselectable=="string"&&(e.unselectable="on"),e}function r(e){return typeof e.onselectstart!="undefined"&&(e.onselectstart=null),t?e.style[t]="":typeof e.unselectable=="string"&&(e.unselectable=""),e}var e=fabric.document.documentElement.style,t="userSelect"in e?"userSelect":"MozUserSelect"in e?"MozUserSelect":"WebkitUserSelect"in e?"WebkitUserSelect":"KhtmlUserSelect"in e?"KhtmlUserSelect":"";fabric.util.makeElementUnselectable=n,fabric.util.makeElementSelectable=r}(),function(){function e(e,t){var n=fabric.document.getElementsByTagName("head")[0],r=fabric.document.createElement("script"),i=!0;r.onload=r.onreadystatechange=function(e){if(i){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")return;i=!1,t(e||fabric.window.event),r=r.onload=r.onreadystatechange=null}},r.src=e,n.appendChild(r)}fabric.util.getScript=e}(),fabric.util.getById=t,fabric.util.toArray=r,fabric.util.makeElement=s,fabric.util.addClass=o,fabric.util.wrapElement=u,fabric.util.getScrollLeftTop=a,fabric.util.getElementOffset=f,fabric.util.getElementStyle=l}(),function(){function e(e,t){return e+(/\?/.test(e)?"&":"?")+t}function n(){}function r(r,i){i||(i={});var s=i.method?i.method.toUpperCase():"GET",o=i.onComplete||function(){},u=t(),a;return u.onreadystatechange=function(){u.readyState===4&&(o(u),u.onreadystatechange=n)},s==="GET"&&(a=null,typeof i.parameters=="string"&&(r=e(r,i.parameters))),u.open(s,r,!0),(s==="POST"||s==="PUT")&&u.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),u.send(a),u}var t=function(){var e=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}];for(var t=e.length;t--;)try{var n=e[t]();if(n)return e[t]}catch(r){}}();fabric.util.request=r}(),fabric.log=function(){},fabric.warn=function(){},typeof console!="undefined"&&["log","warn"].forEach(function(e){typeof console[e]!="undefined"&&typeof console[e].apply=="function"&&(fabric[e]=function(){return console[e].apply(console,arguments)})}),function(){function e(e){n(function(t){e||(e={});var r=t||+(new Date),i=e.duration||500,s=r+i,o,u=e.onChange||function(){},a=e.abort||function(){return!1},f=e.easing||function(e,t,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+t},l="startValue"in e?e.startValue:0,c="endValue"in e?e.endValue:100,h=e.byValue||c-l;e.onStart&&e.onStart(),function p(t){o=t||+(new Date);var c=o>s?i:o-r;if(a()){e.onComplete&&e.onComplete();return}u(f(c,l,h,i));if(o>s){e.onComplete&&e.onComplete();return}n(p)}(r)})}function n(){return t.apply(fabric.window,arguments)}var t=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(e){fabric.window.setTimeout(e,1e3/60)};fabric.util.animate=e,fabric.util.requestAnimFrame=n}(),function(){function e(e,t,n,r){return e<Math.abs(t)?(e=t,r=n/4):r=n/(2*Math.PI)*Math.asin(t/e),{a:e,c:t,p:n,s:r}}function t(e,t,n){return e.a*Math.pow(2,10*(t-=1))*Math.sin((t*n-e.s)*2*Math.PI/e.p)}function n(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function r(e,t,n,r){return e/=r/2,e<1?n/2*e*e*e+t:n/2*((e-=2)*e*e+2)+t}function i(e,t,n,r){return n*(e/=r)*e*e*e+t}function s(e,t,n,r){return-n*((e=e/r-1)*e*e*e-1)+t}function o(e,t,n,r){return e/=r/2,e<1?n/2*e*e*e*e+t:-n/2*((e-=2)*e*e*e-2)+t}function u(e,t,n,r){return n*(e/=r)*e*e*e*e+t}function a(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t}function f(e,t,n,r){return e/=r/2,e<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t}function l(e,t,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+t}function c(e,t,n,r){return n*Math.sin(e/r*(Math.PI/2))+t}function h(e,t,n,r){return-n/2*(Math.cos(Math.PI*e/r)-1)+t}function p(e,t,n,r){return e===0?t:n*Math.pow(2,10*(e/r-1))+t}function d(e,t,n,r){return e===r?t+n:n*(-Math.pow(2,-10*e/r)+1)+t}function v(e,t,n,r){return e===0?t:e===r?t+n:(e/=r/2,e<1?n/2*Math.pow(2,10*(e-1))+t:n/2*(-Math.pow(2,-10*--e)+2)+t)}function m(e,t,n,r){return-n*(Math.sqrt(1-(e/=r)*e)-1)+t}function g(e,t,n,r){return n*Math.sqrt(1-(e=e/r-1)*e)+t}function y(e,t,n,r){return e/=r/2,e<1?-n/2*(Math.sqrt(1-e*e)-1)+t:n/2*(Math.sqrt(1-(e-=2)*e)+1)+t}function b(n,r,i,s){var o=1.70158,u=0,a=i;if(n===0)return r;n/=s;if(n===1)return r+i;u||(u=s*.3);var f=e(a,i,u,o);return-t(f,n,s)+r}function w(t,n,r,i){var s=1.70158,o=0,u=r;if(t===0)return n;t/=i;if(t===1)return n+r;o||(o=i*.3);var a=e(u,r,o,s);return a.a*Math.pow(2,-10*t)*Math.sin((t*i-a.s)*2*Math.PI/a.p)+a.c+n}function E(n,r,i,s){var o=1.70158,u=0,a=i;if(n===0)return r;n/=s/2;if(n===2)return r+i;u||(u=s*.3*1.5);var f=e(a,i,u,o);return n<1?-0.5*t(f,n,s)+r:f.a*Math.pow(2,-10*(n-=1))*Math.sin((n*s-f.s)*2*Math.PI/f.p)*.5+f.c+r}function S(e,t,n,r,i){return i===undefined&&(i=1.70158),n*(e/=r)*e*((i+1)*e-i)+t}function x(e,t,n,r,i){return i===undefined&&(i=1.70158),n*((e=e/r-1)*e*((i+1)*e+i)+1)+t}function T(e,t,n,r,i){return i===undefined&&(i=1.70158),e/=r/2,e<1?n/2*e*e*(((i*=1.525)+1)*e-i)+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t}function N(e,t,n,r){return n-C(r-e,0,n,r)+t}function C(e,t,n,r){return(e/=r)<1/2.75?n*7.5625*e*e+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t}function k(e,t,n,r){return e<r/2?N(e*2,0,n,r)*.5+t:C(e*2-r,0,n,r)*.5+n*.5+t}fabric.util.ease={easeInQuad:function(e,t,n,r){return n*(e/=r)*e+t},easeOutQuad:function(e,t,n,r){return-n*(e/=r)*(e-2)+t},easeInOutQuad:function(e,t,n,r){return e/=r/2,e<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},easeInCubic:function(e,t,n,r){return n*(e/=r)*e*e+t},easeOutCubic:n,easeInOutCubic:r,easeInQuart:i,easeOutQuart:s,easeInOutQuart:o,easeInQuint:u,easeOutQuint:a,easeInOutQuint:f,easeInSine:l,easeOutSine:c,easeInOutSine:h,easeInExpo:p,easeOutExpo:d,easeInOutExpo:v,easeInCirc:m,easeOutCirc:g,easeInOutCirc:y,easeInElastic:b,easeOutElastic:w,easeInOutElastic:E,easeInBack:S,easeOutBack:x,easeInOutBack:T,easeInBounce:N,easeOutBounce:C,easeInOutBounce:k}}(),function(e){"use strict";function l(e){return e in a?a[e]:e}function c(e,n,r,i){var s=Object.prototype.toString.call(n)==="[object Array]",a;return e!=="fill"&&e!=="stroke"||n!=="none"?e==="strokeDashArray"?n=n.replace(/,/g," ").split(/\s+/).map(function(e){return parseFloat(e)}):e==="transformMatrix"?r&&r.transformMatrix?n=u(r.transformMatrix,t.parseTransformAttribute(n)):n=t.parseTransformAttribute(n):e==="visible"?(n=n==="none"||n==="hidden"?!1:!0,r&&r.visible===!1&&(n=!1)):e==="originX"?n=n==="start"?"left":n==="end"?"right":"center":a=s?n.map(o):o(n,i):n="",!s&&isNaN(a)?n:a}function h(e){for(var n in f){if(!e[n]||typeof e[f[n]]=="undefined")continue;if(e[n].indexOf("url(")===0)continue;var r=new t.Color(e[n]);e[n]=r.setAlpha(s(r.getAlpha()*e[f[n]],2)).toRgba()}return e}function p(e,t){var n,r;e.replace(/;$/,"").split(";").forEach(function(e){var i=e.split(":");n=l(i[0].trim().toLowerCase()),r=c(n,i[1].trim()),t[n]=r})}function d(e,t){var n,r;for(var i in e){if(typeof e[i]=="undefined")continue;n=l(i.toLowerCase()),r=c(n,e[i]),t[n]=r}}function v(e,n){var r={};for(var i in t.cssRules[n])if(m(e,i.split(" ")))for(var s in t.cssRules[n][i])r[s]=t.cssRules[n][i][s];return r}function m(e,t){var n,r=!0;return n=y(e,t.pop()),n&&t.length&&(r=g(e,t)),n&&r&&t.length===0}function g(e,t){var n,r=!0;while(e.parentNode&&e.parentNode.nodeType===1&&t.length)r&&(n=t.pop()),e=e.parentNode,r=y(e,n);return t.length===0}function y(e,t){var n=e.nodeName,r=e.getAttribute("class"),i=e.getAttribute("id"),s;s=new RegExp("^"+n,"i"),t=t.replace(s,""),i&&t.length&&(s=new RegExp("#"+i+"(?![a-zA-Z\\-]+)","i"),t=t.replace(s,""));if(r&&t.length){r=r.split(" ");for(var o=r.length;o--;)s=new RegExp("\\."+r[o]+"(?![a-zA-Z\\-]+)","i"),t=t.replace(s,"")}return t.length===0}function b(e){var t=e.getElementsByTagName("use");while(t.length){var n=t[0],r=n.getAttribute("xlink:href").substr(1),i=n.getAttribute("x")||0,s=n.getAttribute("y")||0,o=e.getElementById(r).cloneNode(!0),u=(o.getAttribute("transform")||"")+" translate("+i+", "+s+")",a;for(var f=0,l=n.attributes,c=l.length;f<c;f++){var h=l.item(f);if(h.nodeName==="x"||h.nodeName==="y"||h.nodeName==="xlink:href")continue;h.nodeName==="transform"?u=h.nodeValue+" "+u:o.setAttribute(h.nodeName,h.nodeValue)}o.setAttribute("transform",u),o.setAttribute("instantiated_by_use","1"),o.removeAttribute("id"),a=n.parentNode,a.replaceChild(o,n)}}function w(e,n,r){var i=new RegExp("^\\s*("+t.reNum+"+)\\s*,?"+"\\s*("+t.reNum+"+)\\s*,?"+"\\s*("+t.reNum+"+)\\s*,?"+"\\s*("+t.reNum+"+)\\s*"+"$"),s=e.getAttribute("viewBox"),o=1,u=1,a=0,f=0,l,c,h,p;if(!s||!(s=s.match(i)))return;a=-parseFloat(s[1]),f=-parseFloat(s[2]),l=parseFloat(s[3]),c=parseFloat(s[4]),n&&n!==l&&(o=n/l),r&&r!==c&&(u=r/c),u=o=o>u?u:o;if(o===1&&u===1&&a===0&&f===0)return;h="matrix("+o+" 0"+" 0 "+u+" "+a*o+" "+f*u+")";if(e.tagName==="svg"){p=e.ownerDocument.createElement("g");while(e.firstChild!=null)p.appendChild(e.firstChild);e.appendChild(p)}else p=e,h+=p.getAttribute("transform");p.setAttribute("transform",h)}function S(e){var n=e.objects,i=e.options;return n=n.map(function(e){return t[r(e.type)].fromObject(e)}),{objects:n,options:i}}function x(e,t,n){t[n]&&t[n].toSVG&&e.push('<pattern x="0" y="0" id="',n,'Pattern" ','width="',t[n].source.width,'" height="',t[n].source.height,'" patternUnits="userSpaceOnUse">','<image x="0" y="0" ','width="',t[n].source.width,'" height="',t[n].source.height,'" xlink:href="',t[n].source.src,'"></image></pattern>')}var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.string.capitalize,i=t.util.object.clone,s=t.util.toFixed,o=t.util.parseUnit,u=t.util.multiplyTransformMatrices,a={cx:"left",x:"left",r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","stroke-dasharray":"strokeDashArray","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"originX"},f={stroke:"strokeOpacity",fill:"fillOpacity"};t.cssRules={},t.gradientDefs={},t.parseTransformAttribute=function(){function e(e,t){var n=t[0];e[0]=Math.cos(n),e[1]=Math.sin(n),e[2]=-Math.sin(n),e[3]=Math.cos(n)}function n(e,t){var n=t[0],r=t.length===2?t[1]:t[0];e[0]=n,e[3]=r}function r(e,n){e[2]=Math.tan(t.util.degreesToRadians(n[0]))}function i(e,n){e[1]=Math.tan(t.util.degreesToRadians(n[0]))}function s(e,t){e[4]=t[0],t.length===2&&(e[5]=t[1])}var o=[1,0,0,1,0,0],u=t.reNum,a="(?:\\s+,?\\s*|,\\s*)",f="(?:(skewX)\\s*\\(\\s*("+u+")\\s*\\))",l="(?:(skewY)\\s*\\(\\s*("+u+")\\s*\\))",c="(?:(rotate)\\s*\\(\\s*("+u+")(?:"+a+"("+u+")"+a+"("+u+"))?\\s*\\))",h="(?:(scale)\\s*\\(\\s*("+u+")(?:"+a+"("+u+"))?\\s*\\))",p="(?:(translate)\\s*\\(\\s*("+u+")(?:"+a+"("+u+"))?\\s*\\))",d="(?:(matrix)\\s*\\(\\s*("+u+")"+a+"("+u+")"+a+"("+u+")"+a+"("+u+")"+a+"("+u+")"+a+"("+u+")"+"\\s*\\))",v="(?:"+d+"|"+p+"|"+h+"|"+c+"|"+f+"|"+l+")",m="(?:"+v+"(?:"+a+v+")*"+")",g="^\\s*(?:"+m+"?)\\s*$",y=new RegExp(g),b=new RegExp(v,"g");return function(u){var a=o.concat(),f=[];if(!u||u&&!y.test(u))return a;u.replace(b,function(u){var l=(new RegExp(v)).exec(u).filter(function(e){return e!==""&&e!=null}),c=l[1],h=l.slice(2).map(parseFloat);switch(c){case"translate":s(a,h);break;case"rotate":h[0]=t.util.degreesToRadians(h[0]),e(a,h);break;case"scale":n(a,h);break;case"skewX":r(a,h);break;case"skewY":i(a,h);break;case"matrix":a=h}f.push(a.concat()),a=o.concat()});var l=f[0];while(f.length>1)f.shift(),l=t.util.multiplyTransformMatrices(l,f[0]);return l}}(),t.parseSVGDocument=function(){function r(e,t){while(e&&(e=e.parentNode))if(t.test(e.nodeName)&&!e.getAttribute("instantiated_by_use"))return!0;return!1}var e=/^(path|circle|polygon|polyline|ellipse|rect|line|image|text)$/,n=/^(symbol|image|marker|pattern|view)$/;return function(s,u,a){if(!s)return;b(s);var f=new Date,l=t.Object.__uid++,c=o(s.getAttribute("width")||"100%"),h=o(s.getAttribute("height")||"100%");w(s,c,h);var p=t.util.toArray(s.getElementsByTagName("*"));if(p.length===0&&t.isLikelyNode){p=s.selectNodes('//*[name(.)!="svg"]');var d=[];for(var v=0,m=p.length;v<m;v++)d[v]=p[v];p=d}var g=p.filter(function(t){return n.test(t.tagName)&&w(t,0,0),e.test(t.tagName)&&!r(t,/^(?:pattern|defs|symbol)$/)});if(!g||g&&!g.length){u&&u([],{});return}var y={width:c,height:h,widthAttr:c,heightAttr:h,svgUid:l};t.gradientDefs[l]=t.getGradientDefs(s),t.cssRules[l]=t.getCSSRules(s),t.parseElements(g,function(e){t.documentParsingTime=new Date-f,u&&u(e,y)},i(y),a)}}();var E={has:function(e,t){t(!1)},get:function(){},set:function(){}};n(t,{parseFontDeclaration:function(e,n){var r="(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+t.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+t.reNum+"))?\\s+(.*)",i=e.match(r);if(!i)return;var s=i[1],u=i[3],a=i[4],f=i[5],l=i[6];s&&(n.fontStyle=s),u&&(n.fontWeight=isNaN(parseFloat(u))?u:parseFloat(u)),a&&(n.fontSize=o(a)),l&&(n.fontFamily=l),f&&(n.lineHeight=f==="normal"?1:f)},getGradientDefs:function(e){var t=e.getElementsByTagName("linearGradient"),n=e.getElementsByTagName("radialGradient"),r,i,s=0,o,u,a=[],f={},l={};a.length=t.length+n.length,i=t.length;while(i--)a[s++]=t[i];i=n.length;while(i--)a[s++]=n[i];while(s--)r=a[s],u=r.getAttribute("xlink:href"),o=r.getAttribute("id"),u&&(l[o]=u.substr(1)),f[o]=r;for(o in l){var c=f[l[o]].cloneNode(!0);r=f[o];while(c.firstChild)r.appendChild(c.firstChild)}return f},parseAttributes:function(e,r,i){if(!e)return;var s,o={},u;typeof i=="undefined"&&(i=e.getAttribute("svgUid")),e.parentNode&&/^symbol|[g|a]$/i.test(e.parentNode.nodeName)&&(o=t.parseAttributes(e.parentNode,r,i)),u=o&&o.fontSize||e.getAttribute("font-size" +)||t.Text.DEFAULT_SVG_FONT_SIZE;var a=r.reduce(function(t,n){return s=e.getAttribute(n),s&&(n=l(n),s=c(n,s,o,u),t[n]=s),t},{});return a=n(a,n(v(e,i),t.parseStyleAttribute(e))),a.font&&t.parseFontDeclaration(a.font,a),h(n(o,a))},parseElements:function(e,n,r,i){(new t.ElementsParser(e,n,r,i)).parse()},parseStyleAttribute:function(e){var t={},n=e.getAttribute("style");return n?(typeof n=="string"?p(n,t):d(n,t),t):t},parsePointsAttribute:function(e){if(!e)return null;e=e.replace(/,/g," ").trim(),e=e.split(/\s+/);var t=[],n,r;n=0,r=e.length;for(;n<r;n+=2)t.push({x:parseFloat(e[n]),y:parseFloat(e[n+1])});return t},getCSSRules:function(e){var n=e.getElementsByTagName("style"),r={},i;for(var s=0,o=n.length;s<o;s++){var u=n[s].textContent;u=u.replace(/\/\*[\s\S]*?\*\//g,"");if(u.trim()==="")continue;i=u.match(/[^{]*\{[\s\S]*?\}/g),i=i.map(function(e){return e.trim()}),i.forEach(function(e){var n=e.match(/([\s\S]*?)\s*\{([^}]*)\}/),i={},s=n[2].trim(),o=s.replace(/;$/,"").split(/\s*;\s*/);for(var u=0,a=o.length;u<a;u++){var f=o[u].split(/\s*:\s*/),h=l(f[0]),p=c(h,f[1],f[0]);i[h]=p}e=n[1],e.split(",").forEach(function(e){e=e.replace(/^svg/i,"").trim();if(e==="")return;r[e]=t.util.object.clone(i)})})}return r},loadSVGFromURL:function(e,n,r){function i(i){var s=i.responseXML;s&&!s.documentElement&&t.window.ActiveXObject&&i.responseText&&(s=new ActiveXObject("Microsoft.XMLDOM"),s.async="false",s.loadXML(i.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));if(!s||!s.documentElement)return;t.parseSVGDocument(s.documentElement,function(r,i){E.set(e,{objects:t.util.array.invoke(r,"toObject"),options:i}),n(r,i)},r)}e=e.replace(/^\n\s*/,"").trim(),E.has(e,function(r){r?E.get(e,function(e){var t=S(e);n(t.objects,t.options)}):new t.util.request(e,{method:"get",onComplete:i})})},loadSVGFromString:function(e,n,r){e=e.trim();var i;if(typeof DOMParser!="undefined"){var s=new DOMParser;s&&s.parseFromString&&(i=s.parseFromString(e,"text/xml"))}else t.window.ActiveXObject&&(i=new ActiveXObject("Microsoft.XMLDOM"),i.async="false",i.loadXML(e.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));t.parseSVGDocument(i.documentElement,function(e,t){n(e,t)},r)},createSVGFontFacesMarkup:function(e){var t="";for(var n=0,r=e.length;n<r;n++){if(e[n].type!=="text"||!e[n].path)continue;t+=["@font-face {","font-family: ",e[n].fontFamily,"; ","src: url('",e[n].path,"')","}"].join("")}return t&&(t=['<style type="text/css">',"<![CDATA[",t,"]]>","</style>"].join("")),t},createSVGRefElementsMarkup:function(e){var t=[];return x(t,e,"backgroundColor"),x(t,e,"overlayColor"),t.join("")}})}(typeof exports!="undefined"?exports:this),fabric.ElementsParser=function(e,t,n,r){this.elements=e,this.callback=t,this.options=n,this.reviver=r,this.svgUid=n&&n.svgUid||0},fabric.ElementsParser.prototype.parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},fabric.ElementsParser.prototype.createObjects=function(){for(var e=0,t=this.elements.length;e<t;e++)this.elements[e].setAttribute("svgUid",this.svgUid),function(e,t){setTimeout(function(){e.createObject(e.elements[t],t)},0)}(this,e)},fabric.ElementsParser.prototype.createObject=function(e,t){var n=fabric[fabric.util.string.capitalize(e.tagName)];if(n&&n.fromElement)try{this._createObject(n,e,t)}catch(r){fabric.log(r)}else this.checkIfDone()},fabric.ElementsParser.prototype._createObject=function(e,t,n){if(e.async)e.fromElement(t,this.createCallback(n,t),this.options);else{var r=e.fromElement(t,this.options);this.resolveGradient(r,"fill"),this.resolveGradient(r,"stroke"),this.reviver&&this.reviver(t,r),this.instances[n]=r,this.checkIfDone()}},fabric.ElementsParser.prototype.createCallback=function(e,t){var n=this;return function(r){n.resolveGradient(r,"fill"),n.resolveGradient(r,"stroke"),n.reviver&&n.reviver(t,r),n.instances[e]=r,n.checkIfDone()}},fabric.ElementsParser.prototype.resolveGradient=function(e,t){var n=e.get(t);if(!/^url\(/.test(n))return;var r=n.slice(5,n.length-1);fabric.gradientDefs[this.svgUid][r]&&e.set(t,fabric.Gradient.fromElement(fabric.gradientDefs[this.svgUid][r],e))},fabric.ElementsParser.prototype.checkIfDone=function(){--this.numElements===0&&(this.instances=this.instances.filter(function(e){return e!=null}),this.callback(this.instances))},function(e){"use strict";function n(e,t){this.x=e,this.y=t}var t=e.fabric||(e.fabric={});if(t.Point){t.warn("fabric.Point is already defined");return}t.Point=n,n.prototype={constructor:n,add:function(e){return new n(this.x+e.x,this.y+e.y)},addEquals:function(e){return this.x+=e.x,this.y+=e.y,this},scalarAdd:function(e){return new n(this.x+e,this.y+e)},scalarAddEquals:function(e){return this.x+=e,this.y+=e,this},subtract:function(e){return new n(this.x-e.x,this.y-e.y)},subtractEquals:function(e){return this.x-=e.x,this.y-=e.y,this},scalarSubtract:function(e){return new n(this.x-e,this.y-e)},scalarSubtractEquals:function(e){return this.x-=e,this.y-=e,this},multiply:function(e){return new n(this.x*e,this.y*e)},multiplyEquals:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return new n(this.x/e,this.y/e)},divideEquals:function(e){return this.x/=e,this.y/=e,this},eq:function(e){return this.x===e.x&&this.y===e.y},lt:function(e){return this.x<e.x&&this.y<e.y},lte:function(e){return this.x<=e.x&&this.y<=e.y},gt:function(e){return this.x>e.x&&this.y>e.y},gte:function(e){return this.x>=e.x&&this.y>=e.y},lerp:function(e,t){return new n(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t)},distanceFrom:function(e){var t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)},midPointFrom:function(e){return new n(this.x+(e.x-this.x)/2,this.y+(e.y-this.y)/2)},min:function(e){return new n(Math.min(this.x,e.x),Math.min(this.y,e.y))},max:function(e){return new n(Math.max(this.x,e.x),Math.max(this.y,e.y))},toString:function(){return this.x+","+this.y},setXY:function(e,t){this.x=e,this.y=t},setFromPoint:function(e){this.x=e.x,this.y=e.y},swap:function(e){var t=this.x,n=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=n}}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function n(e){this.status=e,this.points=[]}var t=e.fabric||(e.fabric={});if(t.Intersection){t.warn("fabric.Intersection is already defined");return}t.Intersection=n,t.Intersection.prototype={appendPoint:function(e){this.points.push(e)},appendPoints:function(e){this.points=this.points.concat(e)}},t.Intersection.intersectLineLine=function(e,r,i,s){var o,u=(s.x-i.x)*(e.y-i.y)-(s.y-i.y)*(e.x-i.x),a=(r.x-e.x)*(e.y-i.y)-(r.y-e.y)*(e.x-i.x),f=(s.y-i.y)*(r.x-e.x)-(s.x-i.x)*(r.y-e.y);if(f!==0){var l=u/f,c=a/f;0<=l&&l<=1&&0<=c&&c<=1?(o=new n("Intersection"),o.points.push(new t.Point(e.x+l*(r.x-e.x),e.y+l*(r.y-e.y)))):o=new n}else u===0||a===0?o=new n("Coincident"):o=new n("Parallel");return o},t.Intersection.intersectLinePolygon=function(e,t,r){var i=new n,s=r.length;for(var o=0;o<s;o++){var u=r[o],a=r[(o+1)%s],f=n.intersectLineLine(e,t,u,a);i.appendPoints(f.points)}return i.points.length>0&&(i.status="Intersection"),i},t.Intersection.intersectPolygonPolygon=function(e,t){var r=new n,i=e.length;for(var s=0;s<i;s++){var o=e[s],u=e[(s+1)%i],a=n.intersectLinePolygon(o,u,t);r.appendPoints(a.points)}return r.points.length>0&&(r.status="Intersection"),r},t.Intersection.intersectPolygonRectangle=function(e,r,i){var s=r.min(i),o=r.max(i),u=new t.Point(o.x,s.y),a=new t.Point(s.x,o.y),f=n.intersectLinePolygon(s,u,e),l=n.intersectLinePolygon(u,o,e),c=n.intersectLinePolygon(o,a,e),h=n.intersectLinePolygon(a,s,e),p=new n;return p.appendPoints(f.points),p.appendPoints(l.points),p.appendPoints(c.points),p.appendPoints(h.points),p.points.length>0&&(p.status="Intersection"),p}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function n(e){e?this._tryParsingColor(e):this.setSource([0,0,0,1])}function r(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var t=e.fabric||(e.fabric={});if(t.Color){t.warn("fabric.Color is already defined.");return}t.Color=n,t.Color.prototype={_tryParsingColor:function(e){var t;e in n.colorNameMap&&(e=n.colorNameMap[e]);if(e==="transparent"){this.setSource([255,255,255,0]);return}t=n.sourceFromHex(e),t||(t=n.sourceFromRgb(e)),t||(t=n.sourceFromHsl(e)),t&&this.setSource(t)},_rgbToHsl:function(e,n,r){e/=255,n/=255,r/=255;var i,s,o,u=t.util.array.max([e,n,r]),a=t.util.array.min([e,n,r]);o=(u+a)/2;if(u===a)i=s=0;else{var f=u-a;s=o>.5?f/(2-u-a):f/(u+a);switch(u){case e:i=(n-r)/f+(n<r?6:0);break;case n:i=(r-e)/f+2;break;case r:i=(e-n)/f+4}i/=6}return[Math.round(i*360),Math.round(s*100),Math.round(o*100)]},getSource:function(){return this._source},setSource:function(e){this._source=e},toRgb:function(){var e=this.getSource();return"rgb("+e[0]+","+e[1]+","+e[2]+")"},toRgba:function(){var e=this.getSource();return"rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")"},toHsl:function(){var e=this.getSource(),t=this._rgbToHsl(e[0],e[1],e[2]);return"hsl("+t[0]+","+t[1]+"%,"+t[2]+"%)"},toHsla:function(){var e=this.getSource(),t=this._rgbToHsl(e[0],e[1],e[2]);return"hsla("+t[0]+","+t[1]+"%,"+t[2]+"%,"+e[3]+")"},toHex:function(){var e=this.getSource(),t,n,r;return t=e[0].toString(16),t=t.length===1?"0"+t:t,n=e[1].toString(16),n=n.length===1?"0"+n:n,r=e[2].toString(16),r=r.length===1?"0"+r:r,t.toUpperCase()+n.toUpperCase()+r.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(e){var t=this.getSource();return t[3]=e,this.setSource(t),this},toGrayscale:function(){var e=this.getSource(),t=parseInt((e[0]*.3+e[1]*.59+e[2]*.11).toFixed(0),10),n=e[3];return this.setSource([t,t,t,n]),this},toBlackWhite:function(e){var t=this.getSource(),n=(t[0]*.3+t[1]*.59+t[2]*.11).toFixed(0),r=t[3];return e=e||127,n=Number(n)<Number(e)?0:255,this.setSource([n,n,n,r]),this},overlayWith:function(e){e instanceof n||(e=new n(e));var t=[],r=this.getAlpha(),i=.5,s=this.getSource(),o=e.getSource();for(var u=0;u<3;u++)t.push(Math.round(s[u]*(1-i)+o[u]*i));return t[3]=r,this.setSource(t),this}},t.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/,t.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/,t.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i,t.Color.colorNameMap={aqua:"#00FFFF",black:"#000000",blue:"#0000FF",fuchsia:"#FF00FF",gray:"#808080",green:"#008000",lime:"#00FF00",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#FFA500",purple:"#800080",red:"#FF0000",silver:"#C0C0C0",teal:"#008080",white:"#FFFFFF",yellow:"#FFFF00"},t.Color.fromRgb=function(e){return n.fromSource(n.sourceFromRgb(e))},t.Color.sourceFromRgb=function(e){var t=e.match(n.reRGBa);if(t){var r=parseInt(t[1],10)/(/%$/.test(t[1])?100:1)*(/%$/.test(t[1])?255:1),i=parseInt(t[2],10)/(/%$/.test(t[2])?100:1)*(/%$/.test(t[2])?255:1),s=parseInt(t[3],10)/(/%$/.test(t[3])?100:1)*(/%$/.test(t[3])?255:1);return[parseInt(r,10),parseInt(i,10),parseInt(s,10),t[4]?parseFloat(t[4]):1]}},t.Color.fromRgba=n.fromRgb,t.Color.fromHsl=function(e){return n.fromSource(n.sourceFromHsl(e))},t.Color.sourceFromHsl=function(e){var t=e.match(n.reHSLa);if(!t)return;var i=(parseFloat(t[1])%360+360)%360/360,s=parseFloat(t[2])/(/%$/.test(t[2])?100:1),o=parseFloat(t[3])/(/%$/.test(t[3])?100:1),u,a,f;if(s===0)u=a=f=o;else{var l=o<=.5?o*(s+1):o+s-o*s,c=o*2-l;u=r(c,l,i+1/3),a=r(c,l,i),f=r(c,l,i-1/3)}return[Math.round(u*255),Math.round(a*255),Math.round(f*255),t[4]?parseFloat(t[4]):1]},t.Color.fromHsla=n.fromHsl,t.Color.fromHex=function(e){return n.fromSource(n.sourceFromHex(e))},t.Color.sourceFromHex=function(e){if(e.match(n.reHex)){var t=e.slice(e.indexOf("#")+1),r=t.length===3,i=r?t.charAt(0)+t.charAt(0):t.substring(0,2),s=r?t.charAt(1)+t.charAt(1):t.substring(2,4),o=r?t.charAt(2)+t.charAt(2):t.substring(4,6);return[parseInt(i,16),parseInt(s,16),parseInt(o,16),1]}},t.Color.fromSource=function(e){var t=new n;return t.setSource(e),t}}(typeof exports!="undefined"?exports:this),function(){function e(e){var t=e.getAttribute("style"),n=e.getAttribute("offset"),r,i,s;n=parseFloat(n)/(/%$/.test(n)?100:1),n=n<0?0:n>1?1:n;if(t){var o=t.split(/\s*;\s*/);o[o.length-1]===""&&o.pop();for(var u=o.length;u--;){var a=o[u].split(/\s*:\s*/),f=a[0].trim(),l=a[1].trim();f==="stop-color"?r=l:f==="stop-opacity"&&(s=l)}}return r||(r=e.getAttribute("stop-color")||"rgb(0,0,0)"),s||(s=e.getAttribute("stop-opacity")),r=new fabric.Color(r),i=r.getAlpha(),s=isNaN(parseFloat(s))?1:parseFloat(s),s*=i,{offset:n,color:r.toRgb(),opacity:s}}function t(e){return{x1:e.getAttribute("x1")||0,y1:e.getAttribute("y1")||0,x2:e.getAttribute("x2")||"100%",y2:e.getAttribute("y2")||0}}function n(e){return{x1:e.getAttribute("fx")||e.getAttribute("cx")||"50%",y1:e.getAttribute("fy")||e.getAttribute("cy")||"50%",r1:0,x2:e.getAttribute("cx")||"50%",y2:e.getAttribute("cy")||"50%",r2:e.getAttribute("r")||"50%"}}function r(e,t,n){var r,i=0,s=1,o="";for(var u in t){r=parseFloat(t[u],10),typeof t[u]=="string"&&/^\d+%$/.test(t[u])?s=.01:s=1;if(u==="x1"||u==="x2"||u==="r2")s*=n==="objectBoundingBox"?e.width:1,i=n==="objectBoundingBox"?e.left||0:0;else if(u==="y1"||u==="y2")s*=n==="objectBoundingBox"?e.height:1,i=n==="objectBoundingBox"?e.top||0:0;t[u]=r*s+i}if(e.type==="ellipse"&&t.r2!==null&&n==="objectBoundingBox"&&e.rx!==e.ry){var a=e.ry/e.rx;o=" scale(1, "+a+")",t.y1&&(t.y1/=a),t.y2&&(t.y2/=a)}return o}fabric.Gradient=fabric.util.createClass({offsetX:0,offsetY:0,initialize:function(e){e||(e={});var t={};this.id=fabric.Object.__uid++,this.type=e.type||"linear",t={x1:e.coords.x1||0,y1:e.coords.y1||0,x2:e.coords.x2||0,y2:e.coords.y2||0},this.type==="radial"&&(t.r1=e.coords.r1||0,t.r2=e.coords.r2||0),this.coords=t,this.colorStops=e.colorStops.slice(),e.gradientTransform&&(this.gradientTransform=e.gradientTransform),this.offsetX=e.offsetX||this.offsetX,this.offsetY=e.offsetY||this.offsetY},addColorStop:function(e){for(var t in e){var n=new fabric.Color(e[t]);this.colorStops.push({offset:t,color:n.toRgb(),opacity:n.getAlpha()})}return this},toObject:function(){return{type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY}},toSVG:function(e){var t=fabric.util.object.clone(this.coords),n,r;this.colorStops.sort(function(e,t){return e.offset-t.offset});if(!e.group||e.group.type!=="path-group")for(var i in t)if(i==="x1"||i==="x2"||i==="r2")t[i]+=this.offsetX-e.width/2;else if(i==="y1"||i==="y2")t[i]+=this.offsetY-e.height/2;r='id="SVGID_'+this.id+'" gradientUnits="userSpaceOnUse"',this.gradientTransform&&(r+=' gradientTransform="matrix('+this.gradientTransform.join(" ")+')" '),this.type==="linear"?n=["<linearGradient ",r,' x1="',t.x1,'" y1="',t.y1,'" x2="',t.x2,'" y2="',t.y2,'">\n']:this.type==="radial"&&(n=["<radialGradient ",r,' cx="',t.x2,'" cy="',t.y2,'" r="',t.r2,'" fx="',t.x1,'" fy="',t.y1,'">\n']);for(var s=0;s<this.colorStops.length;s++)n.push("<stop ",'offset="',this.colorStops[s].offset*100+"%",'" style="stop-color:',this.colorStops[s].color,this.colorStops[s].opacity!=null?";stop-opacity: "+this.colorStops[s].opacity:";",'"/>\n');return n.push(this.type==="linear"?"</linearGradient>\n":"</radialGradient>\n"),n.join("")},toLive:function(e,t){var n,r=fabric.util.object.clone(this.coords);if(!this.type)return;if(t.group&&t.group.type==="path-group")for(var i in r)if(i==="x1"||i==="x2")r[i]+=-this.offsetX+t.width/2;else if(i==="y1"||i==="y2")r[i]+=-this.offsetY+t.height/2;this.type==="linear"?n=e.createLinearGradient(r.x1,r.y1,r.x2,r.y2):this.type==="radial"&&(n=e.createRadialGradient(r.x1,r.y1,r.r1,r.x2,r.y2,r.r2));for(var s=0,o=this.colorStops.length;s<o;s++){var u=this.colorStops[s].color,a=this.colorStops[s].opacity,f=this.colorStops[s].offset;typeof a!="undefined"&&(u=(new fabric.Color(u)).setAlpha(a).toRgba()),n.addColorStop(parseFloat(f),u)}return n}}),fabric.util.object.extend(fabric.Gradient,{fromElement:function(i,s){var o=i.getElementsByTagName("stop"),u=i.nodeName==="linearGradient"?"linear":"radial",a=i.getAttribute("gradientUnits")||"objectBoundingBox",f=i.getAttribute("gradientTransform"),l=[],c={},h;u==="linear"?c=t(i):u==="radial"&&(c=n(i));for(var p=o.length;p--;)l.push(e(o[p]));h=r(s,c,a);var d=new fabric.Gradient({type:u,coords:c,colorStops:l,offsetX:-s.left,offsetY:-s.top});if(f||h!=="")d.gradientTransform=fabric.parseTransformAttribute((f||"")+h);return d},forObject:function(e,t){return t||(t={}),r(e,t.coords,"userSpaceOnUse"),new fabric.Gradient(t)}})}(),fabric.Pattern=fabric.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,initialize:function(e){e||(e={}),this.id=fabric.Object.__uid++;if(e.source)if(typeof e.source=="string")if(typeof fabric.util.getFunctionBody(e.source)!="undefined")this.source=new Function(fabric.util.getFunctionBody(e.source));else{var t=this;this.source=fabric.util.createImage(),fabric.util.loadImage(e.source,function(e){t.source=e})}else this.source=e.source;e.repeat&&(this.repeat=e.repeat),e.offsetX&&(this.offsetX=e.offsetX),e.offsetY&&(this.offsetY=e.offsetY)},toObject:function(){var e;return typeof this.source=="function"?e=String(this.source):typeof this.source.src=="string"&&(e=this.source.src),{source:e,repeat:this.repeat,offsetX:this.offsetX,offsetY:this.offsetY}},toSVG:function(e){var t=typeof this.source=="function"?this.source():this.source,n=t.width/e.getWidth(),r=t.height/e.getHeight(),i=this.offsetX/e.getWidth(),s=this.offsetY/e.getHeight(),o="";if(this.repeat==="repeat-x"||this.repeat==="no-repeat")r=1;if(this.repeat==="repeat-y"||this.repeat==="no-repeat")n=1;return t.src?o=t.src:t.toDataURL&&(o=t.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+i+'" y="'+s+'" width="'+n+'" height="'+r+'">\n'+'<image x="0" y="0"'+' width="'+t.width+'" height="'+t.height+'" xlink:href="'+o+'"></image>\n'+"</pattern>\n"},toLive:function(e){var t=typeof this.source=="function"?this.source():this.source;if(!t)return"";if(typeof t.src!="undefined"){if(!t.complete)return"";if(t.naturalWidth===0||t.naturalHeight===0)return""}return e.createPattern(t,this.repeat)}}),function(e){"use strict";var t=e.fabric||(e.fabric={});if(t.Shadow){t.warn("fabric.Shadow is already defined.");return}t.Shadow=t.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,initialize:function(e){typeof e=="string"&&(e=this._parseShadow(e));for(var n in e)this[n]=e[n];this.id=t.Object.__uid++},_parseShadow:function(e){var n=e.trim(),r=t.Shadow.reOffsetsAndBlur.exec(n)||[],i=n.replace(t.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)";return{color:i.trim(),offsetX:parseInt(r[1],10)||0,offsetY:parseInt(r[2],10)||0,blur:parseInt(r[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(e){var t="SourceAlpha",n=40,r=40;return e&&(e.fill===this.color||e.stroke===this.color)&&(t="SourceGraphic"),e.width&&e.height&&(n=Math.abs(this.offsetX/e.getWidth())*100+20,r=Math.abs(this.offsetY/e.getHeight())*100+20),'<filter id="SVGID_'+this.id+'" y="-'+r+'%" height="'+(100+2*r)+'%" '+'x="-'+n+'%" width="'+(100+2*n)+'%" '+">\n"+' <feGaussianBlur in="'+t+'" stdDeviation="'+(this.blur?this.blur/3:0)+'"></feGaussianBlur>\n'+' <feOffset dx="'+this.offsetX+'" dy="'+this.offsetY+'"></feOffset>\n'+" <feMerge>\n"+" <feMergeNode></feMergeNode>\n"+' <feMergeNode in="SourceGraphic"></feMergeNode>\n'+" </feMerge>\n"+"</filter>\n"},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY};var e={},n=t.Shadow.prototype;return this.color!==n.color&&(e.color=this.color),this.blur!==n.blur&&(e.blur=this.blur),this.offsetX!==n.offsetX&&(e.offsetX=this.offsetX),this.offsetY!==n.offsetY&&(e.offsetY=this.offsetY),e}}),t.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/}(typeof exports!="undefined"?exports:this),function(){"use strict";if(fabric.StaticCanvas){fabric.warn("fabric.StaticCanvas is already defined.");return}var e=fabric.util.object.extend,t=fabric.util.getElementOffset,n=fabric.util.removeFromArray,r=new Error("Could not initialize `canvas` element");fabric.StaticCanvas=fabric.util.createClass({initialize:function(e,t){t||(t={}),this._initStatic(e,t),fabric.StaticCanvas.activeInstance=this},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!0,renderOnAddRemove:!0,clipTo:null,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,preserveObjectStacking:!1,viewportTransform:[1,0,0,1,0,0],onBeforeScaleRotate:function(){},_initStatic:function(e,t){this._objects=[],this._createLowerCanvas(e),this._initOptions(t),this._setImageSmoothing(),t.overlayImage&&this.setOverlayImage(t.overlayImage,this.renderAll.bind(this)),t.backgroundImage&&this.setBackgroundImage(t.backgroundImage,this.renderAll.bind(this)),t.backgroundColor&&this.setBackgroundColor(t.backgroundColor,this.renderAll.bind(this)),t.overlayColor&&this.setOverlayColor(t.overlayColor,this.renderAll.bind(this)),this.calcOffset()},calcOffset:function(){return this._offset=t(this.lowerCanvasEl),this},setOverlayImage:function(e,t,n){return this.__setBgOverlayImage("overlayImage",e,t,n)},setBackgroundImage:function(e,t,n){return this.__setBgOverlayImage("backgroundImage",e,t,n)},setOverlayColor:function(e,t){return this.__setBgOverlayColor("overlayColor",e,t)},setBackgroundColor:function(e,t){return this.__setBgOverlayColor("backgroundColor",e,t)},_setImageSmoothing:function(){var e=this.getContext();e.imageSmoothingEnabled=this.imageSmoothingEnabled,e.webkitImageSmoothingEnabled=this.imageSmoothingEnabled,e.mozImageSmoothingEnabled=this.imageSmoothingEnabled,e.msImageSmoothingEnabled=this.imageSmoothingEnabled,e.oImageSmoothingEnabled=this.imageSmoothingEnabled},__setBgOverlayImage:function(e,t,n,r){return typeof t=="string"?fabric.util.loadImage(t,function(t){this[e]=new fabric.Image(t,r),n&&n()},this,r&&r.crossOrigin):(this[e]=t,n&&n()),this},__setBgOverlayColor:function(e,t,n){if(t&&t.source){var r=this;fabric.util.loadImage(t.source,function(i){r[e]=new fabric.Pattern({source:i,repeat:t.repeat,offsetX:t.offsetX,offsetY:t.offsetY}),n&&n()})}else this[e]=t,n&&n();return this},_createCanvasElement:function(){var e=fabric.document.createElement("canvas");e.style||(e.style={});if(!e)throw r;return this._initCanvasElement(e),e},_initCanvasElement:function(e){fabric.util.createCanvasElement(e);if(typeof e.getContext=="undefined")throw r},_initOptions:function(e){for(var t in e)this[t]=e[t];this.width=this.width||parseInt(this.lowerCanvasEl.width,10)||0,this.height=this.height||parseInt(this.lowerCanvasEl.height,10)||0;if(!this.lowerCanvasEl.style)return;this.lowerCanvasEl.width=this.width,this.lowerCanvasEl.height=this.height,this.lowerCanvasEl.style.width=this.width+"px",this.lowerCanvasEl.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice()},_createLowerCanvas:function(e){this.lowerCanvasEl=fabric.util.getById(e)||this._createCanvasElement(),this._initCanvasElement(this.lowerCanvasEl),fabric.util.addClass(this.lowerCanvasEl,"lower-canvas"),this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(e,t){return this.setDimensions({width:e},t)},setHeight:function(e,t){return this.setDimensions({height:e},t)},setDimensions:function(e,t){var n;t=t||{};for(var r in e)n=e[r],t.cssOnly||(this._setBackstoreDimension(r,e[r]),n+="px"),t.backstoreOnly||this._setCssDimension(r,n);return t.cssOnly||this.renderAll(),this.calcOffset(),this},_setBackstoreDimension:function(e,t){return this.lowerCanvasEl[e]=t,this.upperCanvasEl&&(this.upperCanvasEl[e]=t),this.cacheCanvasEl&&(this.cacheCanvasEl[e]=t),this[e]=t,this},_setCssDimension:function(e,t){return this.lowerCanvasEl.style[e]=t,this.upperCanvasEl&&(this.upperCanvasEl.style[e]=t),this.wrapperEl&&(this.wrapperEl.style[e]=t),this},getZoom:function(){return Math.sqrt(this.viewportTransform[0]*this.viewportTransform[3])},setViewportTransform:function(e){this.viewportTransform=e,this.renderAll();for(var t=0,n=this._objects.length;t<n;t++)this._objects[t].setCoords();return this},zoomToPoint:function(e,t){var n=e;e=fabric.util.transformPoint(e,fabric.util.invertTransform(this.viewportTransform)),this.viewportTransform[0]=t,this.viewportTransform[3]=t;var r=fabric.util.transformPoint(e,this.viewportTransform);this.viewportTransform[4]+=n.x-r.x,this.viewportTransform[5]+=n.y-r.y,this.renderAll();for(var i=0,s=this._objects.length;i<s;i++)this._objects[i].setCoords();return this},setZoom:function(e){return this.zoomToPoint(new fabric.Point(0,0),e),this},absolutePan:function(e){this.viewportTransform[4]=-e.x,this.viewportTransform[5]=-e.y,this.renderAll();for(var t=0,n=this._objects.length;t<n;t++)this._objects[t].setCoords();return this},relativePan:function(e){return this.absolutePan(new fabric.Point(-e.x-this.viewportTransform[4],-e.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},getActiveObject:function(){return null},getActiveGroup:function(){return null},_draw:function(e,t){if(!t)return;e.save();var n=this.viewportTransform;e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this._shouldRenderObject(t)&&t.render(e),e.restore(),this.controlsAboveOverlay||t._renderControls(e)},_shouldRenderObject:function(e){return e?e!==this.getActiveGroup()||!this.preserveObjectStacking:!1},_onObjectAdded:function(e){this.stateful&&e.setupState(),e.canvas=this,e.setCoords(),this.fire("object:added",{target:e}),e.fire("added")},_onObjectRemoved:function(e){this.getActiveObject()===e&&(this.fire("before:selection:cleared",{target:e}),this._discardActiveObject(),this.fire("selection:cleared")),this.fire("object:removed",{target:e}),e.fire("removed")},clearContext:function(e){return e.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this._objects.length=0,this.discardActiveGroup&&this.discardActiveGroup(),this.discardActiveObject&&this.discardActiveObject(),this.clearContext(this.contextContainer),this.contextTop&&this.clearContext(this.contextTop),this.fire("canvas:cleared"),this.renderAll(),this},renderAll:function(e){var t=this[e===!0&&this.interactive?"contextTop":"contextContainer"],n=this.getActiveGroup();return this.contextTop&&this.selection&&!this._groupSelector&&this.clearContext(this.contextTop),e||this.clearContext(t),this.fire("before:render"),this.clipTo&&fabric.util.clipContext(this,t),this._renderBackground(t),this._renderObjects(t,n),this._renderActiveGroup(t,n),this.clipTo&&t.restore(),this._renderOverlay(t),this.controlsAboveOverlay&&this.interactive&&this.drawControls(t),this.fire("after:render"),this},_renderObjects:function(e,t){var n,r;if(!t||this.preserveObjectStacking)for(n=0,r=this._objects.length;n<r;++n)this._draw(e,this._objects[n]);else for(n=0,r=this._objects.length;n<r;++n)this._objects[n]&&!t.contains(this._objects[n])&&this._draw(e,this._objects[n])},_renderActiveGroup:function(e,t){if(t){var n=[];this.forEachObject(function(e){t.contains(e)&&n.push(e)}),t._set("objects",n),this._draw(e,t)}},_renderBackground:function(e){this.backgroundColor&&(e.fillStyle=this.backgroundColor.toLive?this.backgroundColor.toLive(e):this.backgroundColor,e.fillRect(this.backgroundColor.offsetX||0,this.backgroundColor.offsetY||0,this.width,this.height)),this.backgroundImage&&this._draw(e,this.backgroundImage)},_renderOverlay:function(e){this.overlayColor&&(e.fillStyle=this.overlayColor.toLive?this.overlayColor.toLive(e):this.overlayColor,e.fillRect(this.overlayColor.offsetX||0,this.overlayColor.offsetY||0,this.width,this.height)),this.overlayImage&&this._draw(e,this.overlayImage)},renderTop:function(){var e=this.contextTop||this.contextContainer;this.clearContext(e),this.selection&&this._groupSelector&&this._drawSelection();var t=this.getActiveGroup();return t&&t.render(e),this._renderOverlay(e),this.fire("after:render"),this},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(e){return this._centerObject(e,new fabric.Point(this.getCenter().left,e.getCenterPoint().y)),this.renderAll(),this},centerObjectV:function(e){return this._centerObject(e,new fabric.Point(e.getCenterPoint().x,this.getCenter().top)),this.renderAll(),this},centerObject:function(e){var t=this.getCenter();return this._centerObject(e,new fabric.Point(t.left,t.top)),this.renderAll(),this},_centerObject:function(e,t){return e.setPositionByOrigin(t,"center","center"),this},toDatalessJSON:function(e){return this.toDatalessObject(e)},toObject:function(e){return this._toObjectMethod("toObject",e)},toDatalessObject:function(e){return this._toObjectMethod("toDatalessObject",e)},_toObjectMethod:function(t,n){var r=this.getActiveGroup();r&&this.discardActiveGroup();var i={objects:this._toObjects(t,n)};return e(i,this.__serializeBgOverlay()),fabric.util.populateWithProperties(this,i,n),r&&(this.setActiveGroup(new fabric.Group(r.getObjects(),{originX:"center",originY:"center"})),r.forEachObject(function(e){e.set("active",!0)}),this._currentTransform&&(this._currentTransform.target=this.getActiveGroup())),i},_toObjects:function(e,t){return this.getObjects().map(function(n){return this._toObject(n,e,t)},this)},_toObject:function(e,t,n){var r;this.includeDefaultValues||(r=e.includeDefaultValues,e.includeDefaultValues=!1);var i=e[t](n);return this.includeDefaultValues||(e.includeDefaultValues=r),i},__serializeBgOverlay:function(){var e={background:this.backgroundColor&&this.backgroundColor.toObject?this.backgroundColor.toObject():this.backgroundColor};return this.overlayColor&&(e.overlay=this.overlayColor.toObject?this.overlayColor.toObject():this.overlayColor),this.backgroundImage&&(e.backgroundImage=this.backgroundImage.toObject()),this.overlayImage&&(e.overlayImage=this.overlayImage.toObject()),e},svgViewportTransformation:!0,toSVG:function(e,t){e||(e={});var n=[];return this._setSVGPreamble(n,e),this._setSVGHeader(n,e),this._setSVGBgOverlayColor(n,"backgroundColor"),this._setSVGBgOverlayImage(n,"backgroundImage"),this._setSVGObjects(n,t),this._setSVGBgOverlayColor(n,"overlayColor"),this._setSVGBgOverlayImage(n,"overlayImage"),n.push("</svg>"),n.join("")},_setSVGPreamble:function(e,t){t.suppressPreamble||e.push('<?xml version="1.0" encoding="',t.encoding||"UTF-8",'" standalone="no" ?>','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')},_setSVGHeader:function(e,t){var n,r,i;t.viewBox?(n=t.viewBox.width,r=t.viewBox.height):(n=this.width,r=this.height,this.svgViewportTransformation||(i=this.viewportTransform,n/=i[0],r/=i[3])),e.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',n,'" ','height="',r,'" ',this.backgroundColor&&!this.backgroundColor.toLive?'style="background-color: '+this.backgroundColor+'" ':null,t.viewBox?'viewBox="'+t.viewBox.x+" "+t.viewBox.y+" "+t.viewBox.width+" "+t.viewBox.height+'" ':null,'xml:space="preserve">',"<desc>Created with Fabric.js ",fabric.version,"</desc>","<defs>",fabric.createSVGFontFacesMarkup(this.getObjects()),fabric.createSVGRefElementsMarkup(this),"</defs>")},_setSVGObjects:function(e,t){var n=this.getActiveGroup();n&&this.discardActiveGroup();for(var r=0,i=this.getObjects(),s=i.length;r<s;r++)e.push(i[r].toSVG(t));n&&(this.setActiveGroup(new fabric.Group(n.getObjects())),n.forEachObject(function(e){e.set("active",!0)}))},_setSVGBgOverlayImage:function(e,t){this[t]&&this[t].toSVG&&e.push(this[t].toSVG())},_setSVGBgOverlayColor:function(e,t){this[t]&&this[t].source?e.push('<rect x="',this[t].offsetX,'" y="',this[t].offsetY,'" ','width="',this[t].repeat==="repeat-y"||this[t].repeat==="no-repeat"?this[t].source.width:this.width,'" height="',this[t].repeat==="repeat-x"||this[t].repeat==="no-repeat"?this[t].source.height:this.height,'" fill="url(#'+t+'Pattern)"',"></rect>"):this[t]&&t==="overlayColor"&&e.push('<rect x="0" y="0" ','width="',this.width,'" height="',this.height,'" fill="',this[t],'"',"></rect>")},sendToBack:function(e){return n(this._objects,e),this._objects.unshift(e),this.renderAll&&this.renderAll()},bringToFront:function(e){return n(this._objects,e),this._objects.push(e),this.renderAll&&this.renderAll()},sendBackwards:function(e,t){var r=this._objects.indexOf(e);if(r!==0){var i=this._findNewLowerIndex(e,r,t);n(this._objects,e),this._objects.splice(i,0,e),this.renderAll&&this.renderAll()}return this},_findNewLowerIndex:function(e,t,n){var r;if(n){r=t;for(var i=t-1;i>=0;--i){var s=e.intersectsWithObject(this._objects[i])||e.isContainedWithinObject +(this._objects[i])||this._objects[i].isContainedWithinObject(e);if(s){r=i;break}}}else r=t-1;return r},bringForward:function(e,t){var r=this._objects.indexOf(e);if(r!==this._objects.length-1){var i=this._findNewUpperIndex(e,r,t);n(this._objects,e),this._objects.splice(i,0,e),this.renderAll&&this.renderAll()}return this},_findNewUpperIndex:function(e,t,n){var r;if(n){r=t;for(var i=t+1;i<this._objects.length;++i){var s=e.intersectsWithObject(this._objects[i])||e.isContainedWithinObject(this._objects[i])||this._objects[i].isContainedWithinObject(e);if(s){r=i;break}}}else r=t+1;return r},moveTo:function(e,t){return n(this._objects,e),this._objects.splice(t,0,e),this.renderAll&&this.renderAll()},dispose:function(){return this.clear(),this.interactive&&this.removeListeners(),this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): "+"{ objects: "+this.getObjects().length+" }>"}}),e(fabric.StaticCanvas.prototype,fabric.Observable),e(fabric.StaticCanvas.prototype,fabric.Collection),e(fabric.StaticCanvas.prototype,fabric.DataURLExporter),e(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(e){var t=fabric.util.createCanvasElement();if(!t||!t.getContext)return null;var n=t.getContext("2d");if(!n)return null;switch(e){case"getImageData":return typeof n.getImageData!="undefined";case"setLineDash":return typeof n.setLineDash!="undefined";case"toDataURL":return typeof t.toDataURL!="undefined";case"toDataURLWithQuality":try{return t.toDataURL("image/jpeg",0),!0}catch(r){}return!1;default:return null}}}),fabric.StaticCanvas.prototype.toJSON=fabric.StaticCanvas.prototype.toObject}(),fabric.BaseBrush=fabric.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",setShadow:function(e){return this.shadow=new fabric.Shadow(e),this},_setBrushStyles:function(){var e=this.canvas.contextTop;e.strokeStyle=this.color,e.lineWidth=this.width,e.lineCap=this.strokeLineCap,e.lineJoin=this.strokeLineJoin},_setShadow:function(){if(!this.shadow)return;var e=this.canvas.contextTop;e.shadowColor=this.shadow.color,e.shadowBlur=this.shadow.blur,e.shadowOffsetX=this.shadow.offsetX,e.shadowOffsetY=this.shadow.offsetY},_resetShadow:function(){var e=this.canvas.contextTop;e.shadowColor="",e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0}}),function(){fabric.PencilBrush=fabric.util.createClass(fabric.BaseBrush,{initialize:function(e){this.canvas=e,this._points=[]},onMouseDown:function(e){this._prepareForDrawing(e),this._captureDrawingPath(e),this._render()},onMouseMove:function(e){this._captureDrawingPath(e),this.canvas.clearContext(this.canvas.contextTop),this._render()},onMouseUp:function(){this._finalizeAndAddPath()},_prepareForDrawing:function(e){var t=new fabric.Point(e.x,e.y);this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)},_addPoint:function(e){this._points.push(e)},_reset:function(){this._points.length=0,this._setBrushStyles(),this._setShadow()},_captureDrawingPath:function(e){var t=new fabric.Point(e.x,e.y);this._addPoint(t)},_render:function(){var e=this.canvas.contextTop,t=this.canvas.viewportTransform,n=this._points[0],r=this._points[1];e.save(),e.transform(t[0],t[1],t[2],t[3],t[4],t[5]),e.beginPath(),this._points.length===2&&n.x===r.x&&n.y===r.y&&(n.x-=.5,r.x+=.5),e.moveTo(n.x,n.y);for(var i=1,s=this._points.length;i<s;i++){var o=n.midPointFrom(r);e.quadraticCurveTo(n.x,n.y,o.x,o.y),n=this._points[i],r=this._points[i+1]}e.lineTo(n.x,n.y),e.stroke(),e.restore()},convertPointsToSVGPath:function(e){var t=[],n=new fabric.Point(e[0].x,e[0].y),r=new fabric.Point(e[1].x,e[1].y);t.push("M ",e[0].x," ",e[0].y," ");for(var i=1,s=e.length;i<s;i++){var o=n.midPointFrom(r);t.push("Q ",n.x," ",n.y," ",o.x," ",o.y," "),n=new fabric.Point(e[i].x,e[i].y),i+1<e.length&&(r=new fabric.Point(e[i+1].x,e[i+1].y))}return t.push("L ",n.x," ",n.y," "),t},createPath:function(e){var t=new fabric.Path(e,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,originX:"center",originY:"center"});return this.shadow&&(this.shadow.affectStroke=!0,t.setShadow(this.shadow)),t},_finalizeAndAddPath:function(){var e=this.canvas.contextTop;e.closePath();var t=this.convertPointsToSVGPath(this._points).join("");if(t==="M 0 0 Q 0 0 0 0 L 0 0"){this.canvas.renderAll();return}var n=this.createPath(t);this.canvas.add(n),n.setCoords(),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderAll(),this.canvas.fire("path:created",{path:n})}})}(),fabric.CircleBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,initialize:function(e){this.canvas=e,this.points=[]},drawDot:function(e){var t=this.addPoint(e),n=this.canvas.contextTop,r=this.canvas.viewportTransform;n.save(),n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),n.fillStyle=t.fill,n.beginPath(),n.arc(t.x,t.y,t.radius,0,Math.PI*2,!1),n.closePath(),n.fill(),n.restore()},onMouseDown:function(e){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(e)},onMouseMove:function(e){this.drawDot(e)},onMouseUp:function(){var e=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;var t=[];for(var n=0,r=this.points.length;n<r;n++){var i=this.points[n],s=new fabric.Circle({radius:i.radius,left:i.x,top:i.y,originX:"center",originY:"center",fill:i.fill});this.shadow&&s.setShadow(this.shadow),t.push(s)}var o=new fabric.Group(t,{originX:"center",originY:"center"});o.canvas=this.canvas,this.canvas.add(o),this.canvas.fire("path:created",{path:o}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=e,this.canvas.renderAll()},addPoint:function(e){var t=new fabric.Point(e.x,e.y),n=fabric.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,r=(new fabric.Color(this.color)).setAlpha(fabric.util.getRandomInt(0,100)/100).toRgba();return t.radius=n,t.fill=r,this.points.push(t),t}}),fabric.SprayBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(e){this.canvas=e,this.sprayChunks=[]},onMouseDown:function(e){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(e),this.render()},onMouseMove:function(e){this.addSprayChunk(e),this.render()},onMouseUp:function(){var e=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;var t=[];for(var n=0,r=this.sprayChunks.length;n<r;n++){var i=this.sprayChunks[n];for(var s=0,o=i.length;s<o;s++){var u=new fabric.Rect({width:i[s].width,height:i[s].width,left:i[s].x+1,top:i[s].y+1,originX:"center",originY:"center",fill:this.color});this.shadow&&u.setShadow(this.shadow),t.push(u)}}this.optimizeOverlapping&&(t=this._getOptimizedRects(t));var a=new fabric.Group(t,{originX:"center",originY:"center"});a.canvas=this.canvas,this.canvas.add(a),this.canvas.fire("path:created",{path:a}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=e,this.canvas.renderAll()},_getOptimizedRects:function(e){var t={},n;for(var r=0,i=e.length;r<i;r++)n=e[r].left+""+e[r].top,t[n]||(t[n]=e[r]);var s=[];for(n in t)s.push(t[n]);return s},render:function(){var e=this.canvas.contextTop;e.fillStyle=this.color;var t=this.canvas.viewportTransform;e.save(),e.transform(t[0],t[1],t[2],t[3],t[4],t[5]);for(var n=0,r=this.sprayChunkPoints.length;n<r;n++){var i=this.sprayChunkPoints[n];typeof i.opacity!="undefined"&&(e.globalAlpha=i.opacity),e.fillRect(i.x,i.y,i.width,i.width)}e.restore()},addSprayChunk:function(e){this.sprayChunkPoints=[];var t,n,r,i=this.width/2;for(var s=0;s<this.density;s++){t=fabric.util.getRandomInt(e.x-i,e.x+i),n=fabric.util.getRandomInt(e.y-i,e.y+i),this.dotWidthVariance?r=fabric.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):r=this.dotWidth;var o=new fabric.Point(t,n);o.width=r,this.randomOpacity&&(o.opacity=fabric.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(o)}this.sprayChunks.push(this.sprayChunkPoints)}}),fabric.PatternBrush=fabric.util.createClass(fabric.PencilBrush,{getPatternSrc:function(){var e=20,t=5,n=fabric.document.createElement("canvas"),r=n.getContext("2d");return n.width=n.height=e+t,r.fillStyle=this.color,r.beginPath(),r.arc(e/2,e/2,e/2,0,Math.PI*2,!1),r.closePath(),r.fill(),n},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(){return this.canvas.contextTop.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(){this.callSuper("_setBrushStyles"),this.canvas.contextTop.strokeStyle=this.getPattern()},createPath:function(e){var t=this.callSuper("createPath",e);return t.stroke=new fabric.Pattern({source:this.source||this.getPatternSrcFunction()}),t}}),function(){var e=fabric.util.getPointer,t=fabric.util.degreesToRadians,n=fabric.util.radiansToDegrees,r=Math.atan2,i=Math.abs,s=.5;fabric.Canvas=fabric.util.createClass(fabric.StaticCanvas,{initialize:function(e,t){t||(t={}),this._initStatic(e,t),this._initInteractive(),this._createCacheCanvas(),fabric.Canvas.activeInstance=this},uniScaleTransform:!1,centeredScaling:!1,centeredRotation:!1,interactive:!0,selection:!0,selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",rotationCursor:"crosshair",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this.freeDrawingBrush=fabric.PencilBrush&&new fabric.PencilBrush(this),this.calcOffset()},_resetCurrentTransform:function(e){var t=this._currentTransform;t.target.set({scaleX:t.original.scaleX,scaleY:t.original.scaleY,left:t.original.left,top:t.original.top}),this._shouldCenterTransform(e,t.target)?t.action==="rotate"?this._setOriginToCenter(t.target):(t.originX!=="center"&&(t.originX==="right"?t.mouseXSign=-1:t.mouseXSign=1),t.originY!=="center"&&(t.originY==="bottom"?t.mouseYSign=-1:t.mouseYSign=1),t.originX="center",t.originY="center"):(t.originX=t.original.originX,t.originY=t.original.originY)},containsPoint:function(e,t){var n=this.getPointer(e,!0),r=this._normalizePointer(t,n);return t.containsPoint(r)||t._findTargetCorner(n)},_normalizePointer:function(e,t){var n=this.getActiveGroup(),r=t.x,i=t.y,s=n&&e.type!=="group"&&n.contains(e),o;return s&&(o=new fabric.Point(n.left,n.top),o=fabric.util.transformPoint(o,this.viewportTransform,!0),r-=o.x,i-=o.y),{x:r,y:i}},isTargetTransparent:function(e,t,n){var r=e.hasBorders,i=e.transparentCorners;e.hasBorders=e.transparentCorners=!1,this._draw(this.contextCache,e),e.hasBorders=r,e.transparentCorners=i;var s=fabric.util.isTransparent(this.contextCache,t,n,this.targetFindTolerance);return this.clearContext(this.contextCache),s},_shouldClearSelection:function(e,t){var n=this.getActiveGroup(),r=this.getActiveObject();return!t||t&&n&&!n.contains(t)&&n!==t&&!e.shiftKey||t&&!t.evented||t&&!t.selectable&&r&&r!==t},_shouldCenterTransform:function(e,t){if(!t)return;var n=this._currentTransform,r;return n.action==="scale"||n.action==="scaleX"||n.action==="scaleY"?r=this.centeredScaling||t.centeredScaling:n.action==="rotate"&&(r=this.centeredRotation||t.centeredRotation),r?!e.altKey:e.altKey},_getOriginFromCorner:function(e,t){var n={x:e.originX,y:e.originY};if(t==="ml"||t==="tl"||t==="bl")n.x="right";else if(t==="mr"||t==="tr"||t==="br")n.x="left";if(t==="tl"||t==="mt"||t==="tr")n.y="bottom";else if(t==="bl"||t==="mb"||t==="br")n.y="top";return n},_getActionFromCorner:function(e,t){var n="drag";return t&&(n=t==="ml"||t==="mr"?"scaleX":t==="mt"||t==="mb"?"scaleY":t==="mtr"?"rotate":"scale"),n},_setupCurrentTransform:function(e,n){if(!n)return;var r=this.getPointer(e),i=n._findTargetCorner(this.getPointer(e,!0)),s=this._getActionFromCorner(n,i),o=this._getOriginFromCorner(n,i);this._currentTransform={target:n,action:s,scaleX:n.scaleX,scaleY:n.scaleY,offsetX:r.x-n.left,offsetY:r.y-n.top,originX:o.x,originY:o.y,ex:r.x,ey:r.y,left:n.left,top:n.top,theta:t(n.angle),width:n.width*n.scaleX,mouseXSign:1,mouseYSign:1},this._currentTransform.original={left:n.left,top:n.top,scaleX:n.scaleX,scaleY:n.scaleY,originX:o.x,originY:o.y},this._resetCurrentTransform(e)},_translateObject:function(e,t){var n=this._currentTransform.target;n.get("lockMovementX")||n.set("left",e-this._currentTransform.offsetX),n.get("lockMovementY")||n.set("top",t-this._currentTransform.offsetY)},_scaleObject:function(e,t,n){var r=this._currentTransform,i=r.target,s=i.get("lockScalingX"),o=i.get("lockScalingY"),u=i.get("lockScalingFlip");if(s&&o)return;var a=i.translateToOriginPoint(i.getCenterPoint(),r.originX,r.originY),f=i.toLocalPoint(new fabric.Point(e,t),r.originX,r.originY);this._setLocalMouse(f,r),this._setObjectScale(f,r,s,o,n,u),i.setPositionByOrigin(a,r.originX,r.originY)},_setObjectScale:function(e,t,n,r,i,s){var o=t.target,u=!1,a=!1,f=o.stroke?o.strokeWidth:0;t.newScaleX=e.x/(o.width+f/2),t.newScaleY=e.y/(o.height+f/2),s&&t.newScaleX<=0&&t.newScaleX<o.scaleX&&(u=!0),s&&t.newScaleY<=0&&t.newScaleY<o.scaleY&&(a=!0),i==="equally"&&!n&&!r?u||a||this._scaleObjectEqually(e,o,t):i?i==="x"&&!o.get("lockUniScaling")?u||n||o.set("scaleX",t.newScaleX):i==="y"&&!o.get("lockUniScaling")&&(a||r||o.set("scaleY",t.newScaleY)):(u||n||o.set("scaleX",t.newScaleX),a||r||o.set("scaleY",t.newScaleY)),u||a||this._flipObject(t,i)},_scaleObjectEqually:function(e,t,n){var r=e.y+e.x,i=t.stroke?t.strokeWidth:0,s=(t.height+i/2)*n.original.scaleY+(t.width+i/2)*n.original.scaleX;n.newScaleX=n.original.scaleX*r/s,n.newScaleY=n.original.scaleY*r/s,t.set("scaleX",n.newScaleX),t.set("scaleY",n.newScaleY)},_flipObject:function(e,t){e.newScaleX<0&&t!=="y"&&(e.originX==="left"?e.originX="right":e.originX==="right"&&(e.originX="left")),e.newScaleY<0&&t!=="x"&&(e.originY==="top"?e.originY="bottom":e.originY==="bottom"&&(e.originY="top"))},_setLocalMouse:function(e,t){var n=t.target;t.originX==="right"?e.x*=-1:t.originX==="center"&&(e.x*=t.mouseXSign*2,e.x<0&&(t.mouseXSign=-t.mouseXSign)),t.originY==="bottom"?e.y*=-1:t.originY==="center"&&(e.y*=t.mouseYSign*2,e.y<0&&(t.mouseYSign=-t.mouseYSign)),i(e.x)>n.padding?e.x<0?e.x+=n.padding:e.x-=n.padding:e.x=0,i(e.y)>n.padding?e.y<0?e.y+=n.padding:e.y-=n.padding:e.y=0},_rotateObject:function(e,t){var i=this._currentTransform;if(i.target.get("lockRotation"))return;var s=r(i.ey-i.top,i.ex-i.left),o=r(t-i.top,e-i.left),u=n(o-s+i.theta);u<0&&(u=360+u),i.target.angle=u%360},setCursor:function(e){this.upperCanvasEl.style.cursor=e},_resetObjectTransform:function(e){e.scaleX=1,e.scaleY=1,e.setAngle(0)},_drawSelection:function(){var e=this.contextTop,t=this._groupSelector,n=t.left,r=t.top,o=i(n),u=i(r);e.fillStyle=this.selectionColor,e.fillRect(t.ex-(n>0?0:-n),t.ey-(r>0?0:-r),o,u),e.lineWidth=this.selectionLineWidth,e.strokeStyle=this.selectionBorderColor;if(this.selectionDashArray.length>1){var a=t.ex+s-(n>0?0:o),f=t.ey+s-(r>0?0:u);e.beginPath(),fabric.util.drawDashedLine(e,a,f,a+o,f,this.selectionDashArray),fabric.util.drawDashedLine(e,a,f+u-1,a+o,f+u-1,this.selectionDashArray),fabric.util.drawDashedLine(e,a,f,a,f+u,this.selectionDashArray),fabric.util.drawDashedLine(e,a+o-1,f,a+o-1,f+u,this.selectionDashArray),e.closePath(),e.stroke()}else e.strokeRect(t.ex+s-(n>0?0:o),t.ey+s-(r>0?0:u),o,u)},_isLastRenderedObject:function(e){return this.controlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay.visible&&this.containsPoint(e,this.lastRenderedObjectWithControlsAboveOverlay)&&this.lastRenderedObjectWithControlsAboveOverlay._findTargetCorner(this.getPointer(e,!0))},findTarget:function(e,t){if(this.skipTargetFind)return;if(this._isLastRenderedObject(e))return this.lastRenderedObjectWithControlsAboveOverlay;var n=this.getActiveGroup();if(n&&!t&&this.containsPoint(e,n))return n;var r=this._searchPossibleTargets(e);return this._fireOverOutEvents(r),r},_fireOverOutEvents:function(e){e?this._hoveredTarget!==e&&(this.fire("mouse:over",{target:e}),e.fire("mouseover"),this._hoveredTarget&&(this.fire("mouse:out",{target:this._hoveredTarget}),this._hoveredTarget.fire("mouseout")),this._hoveredTarget=e):this._hoveredTarget&&(this.fire("mouse:out",{target:this._hoveredTarget}),this._hoveredTarget.fire("mouseout"),this._hoveredTarget=null)},_checkTarget:function(e,t,n){if(t&&t.visible&&t.evented&&this.containsPoint(e,t)){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||!!t.isEditing)return!0;var r=this.isTargetTransparent(t,n.x,n.y);if(!r)return!0}},_searchPossibleTargets:function(e){var t,n=this.getPointer(e,!0),r=this._objects.length;while(r--)if(this._checkTarget(e,this._objects[r],n)){this.relatedTarget=this._objects[r],t=this._objects[r];break}return t},getPointer:function(t,n,r){r||(r=this.upperCanvasEl);var i=e(t,r),s=r.getBoundingClientRect(),o=s.width||0,u=s.height||0,a;if(!o||!u)"top"in s&&"bottom"in s&&(u=Math.abs(s.top-s.bottom)),"right"in s&&"left"in s&&(o=Math.abs(s.right-s.left));return this.calcOffset(),i.x=i.x-this._offset.left,i.y=i.y-this._offset.top,n||(i=fabric.util.transformPoint(i,fabric.util.invertTransform(this.viewportTransform))),o===0||u===0?a={width:1,height:1}:a={width:r.width/o,height:r.height/u},{x:i.x*a.width,y:i.y*a.height}},_createUpperCanvas:function(){var e=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,"");this.upperCanvasEl=this._createCanvasElement(),fabric.util.addClass(this.upperCanvasEl,"upper-canvas "+e),this.wrapperEl.appendChild(this.upperCanvasEl),this._copyCanvasStyle(this.lowerCanvasEl,this.upperCanvasEl),this._applyCanvasStyle(this.upperCanvasEl),this.contextTop=this.upperCanvasEl.getContext("2d")},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.lowerCanvasEl,"div",{"class":this.containerClass}),fabric.util.setStyle(this.wrapperEl,{width:this.getWidth()+"px",height:this.getHeight()+"px",position:"relative"}),fabric.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(e){var t=this.getWidth()||e.width,n=this.getHeight()||e.height;fabric.util.setStyle(e,{position:"absolute",width:t+"px",height:n+"px",left:0,top:0}),e.width=t,e.height=n,fabric.util.makeElementUnselectable(e)},_copyCanvasStyle:function(e,t){t.style.cssText=e.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},_setActiveObject:function(e){this._activeObject&&this._activeObject.set("active",!1),this._activeObject=e,e.set("active",!0)},setActiveObject:function(e,t){return this._setActiveObject(e),this.renderAll(),this.fire("object:selected",{target:e,e:t}),e.fire("selected",{e:t}),this},getActiveObject:function(){return this._activeObject},_discardActiveObject:function(){this._activeObject&&this._activeObject.set("active",!1),this._activeObject=null},discardActiveObject:function(e){return this._discardActiveObject(),this.renderAll(),this.fire("selection:cleared",{e:e}),this},_setActiveGroup:function(e){this._activeGroup=e,e&&e.set("active",!0)},setActiveGroup:function(e,t){return this._setActiveGroup(e),e&&(this.fire("object:selected",{target:e,e:t}),e.fire("selected",{e:t})),this},getActiveGroup:function(){return this._activeGroup},_discardActiveGroup:function(){var e=this.getActiveGroup();e&&e.destroy(),this.setActiveGroup(null)},discardActiveGroup:function(e){return this._discardActiveGroup(),this.fire("selection:cleared",{e:e}),this},deactivateAll:function(){var e=this.getObjects(),t=0,n=e.length;for(;t<n;t++)e[t].set("active",!1);return this._discardActiveGroup(),this._discardActiveObject(),this},deactivateAllWithDispatch:function(e){var t=this.getActiveGroup()||this.getActiveObject();return t&&this.fire("before:selection:cleared",{target:t,e:e}),this.deactivateAll(),t&&this.fire("selection:cleared",{e:e}),this},drawControls:function(e){var t=this.getActiveGroup();t?this._drawGroupControls(e,t):this._drawObjectsControls(e)},_drawGroupControls:function(e,t){t._renderControls(e)},_drawObjectsControls:function(e){for(var t=0,n=this._objects.length;t<n;++t){if(!this._objects[t]||!this._objects[t].active)continue;this._objects[t]._renderControls(e),this.lastRenderedObjectWithControlsAboveOverlay=this._objects[t]}}});for(var o in fabric.StaticCanvas)o!=="prototype"&&(fabric.Canvas[o]=fabric.StaticCanvas[o]);fabric.isTouchSupported&&(fabric.Canvas.prototype._setCursorFromEvent=function(){}),fabric.Element=fabric.Canvas}(),function(){var e={mt:0,tr:1,mr:2,br:3,mb:4,bl:5,ml:6,tl:7},t=fabric.util.addListener,n=fabric.util.removeListener;fabric.util.object.extend(fabric.Canvas.prototype,{cursorMap:["n-resize","ne-resize","e-resize","se-resize","s-resize","sw-resize","w-resize","nw-resize"],_initEventListeners:function(){this._bindEvents(),t(fabric.window,"resize",this._onResize),t(this.upperCanvasEl,"mousedown",this._onMouseDown),t(this.upperCanvasEl,"mousemove",this._onMouseMove),t(this.upperCanvasEl,"mousewheel",this._onMouseWheel),t(this.upperCanvasEl,"touchstart",this._onMouseDown),t(this.upperCanvasEl,"touchmove",this._onMouseMove),typeof Event!="undefined"&&"add"in Event&&(Event.add(this.upperCanvasEl,"gesture",this._onGesture),Event.add(this.upperCanvasEl,"drag",this._onDrag),Event.add(this.upperCanvasEl,"orientation",this._onOrientationChange),Event.add(this.upperCanvasEl,"shake",this._onShake),Event.add(this.upperCanvasEl,"longpress",this._onLongPress))},_bindEvents:function(){this._onMouseDown=this._onMouseDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this)},removeListeners:function(){n(fabric.window,"resize",this._onResize),n(this.upperCanvasEl,"mousedown",this._onMouseDown),n(this.upperCanvasEl,"mousemove",this._onMouseMove),n(this.upperCanvasEl,"mousewheel",this._onMouseWheel),n(this.upperCanvasEl,"touchstart",this._onMouseDown),n(this.upperCanvasEl,"touchmove",this._onMouseMove),typeof Event!="undefined"&&"remove"in Event&&(Event.remove(this.upperCanvasEl,"gesture",this._onGesture),Event.remove(this.upperCanvasEl,"drag",this._onDrag),Event.remove(this.upperCanvasEl,"orientation",this._onOrientationChange),Event.remove(this.upperCanvasEl,"shake",this._onShake),Event.remove(this.upperCanvasEl,"longpress",this._onLongPress))},_onGesture:function(e,t){this.__onTransformGesture&&this.__onTransformGesture(e,t)},_onDrag:function(e,t){this.__onDrag&&this.__onDrag(e,t)},_onMouseWheel:function(e,t){this.__onMouseWheel&&this.__onMouseWheel(e,t)},_onOrientationChange:function(e,t){this.__onOrientationChange&&this.__onOrientationChange(e,t)},_onShake:function(e,t){this.__onShake&&this.__onShake(e,t)},_onLongPress:function(e,t){this.__onLongPress&&this.__onLongPress(e,t)},_onMouseDown:function(e){this.__onMouseDown(e),t(fabric.document,"touchend",this._onMouseUp),t(fabric.document,"touchmove",this._onMouseMove),n(this.upperCanvasEl,"mousemove",this._onMouseMove),n(this.upperCanvasEl,"touchmove",this._onMouseMove),e.type==="touchstart"?n(this.upperCanvasEl,"mousedown",this._onMouseDown):(t(fabric.document,"mouseup",this._onMouseUp),t(fabric.document,"mousemove",this._onMouseMove))},_onMouseUp:function(e){this.__onMouseUp(e),n(fabric.document,"mouseup",this._onMouseUp),n(fabric.document,"touchend",this._onMouseUp),n(fabric.document,"mousemove",this._onMouseMove),n(fabric.document,"touchmove",this._onMouseMove),t(this.upperCanvasEl,"mousemove",this._onMouseMove),t(this.upperCanvasEl,"touchmove",this._onMouseMove);if(e.type==="touchend"){var r=this;setTimeout(function(){t(r.upperCanvasEl,"mousedown",r._onMouseDown)},400)}},_onMouseMove:function(e){!this.allowTouchScrolling&&e.preventDefault&&e.preventDefault(),this.__onMouseMove(e)},_onResize:function(){this.calcOffset()},_shouldRender:function(e,t){var n=this.getActiveGroup()||this.getActiveObject();return!!(e&&(e.isMoving||e!==n)||!e&&!!n||!e&&!n&&!this._groupSelector||t&&this._previousPointer&&this.selection&&(t.x!==this._previousPointer.x||t.y!==this._previousPointer.y))},__onMouseUp:function(e){var t;if(this.isDrawingMode&&this._isCurrentlyDrawing){this._onMouseUpInDrawingMode(e);return}this._currentTransform?(this._finalizeCurrentTransform(),t=this._currentTransform.target):t=this.findTarget(e,!0);var n=this._shouldRender(t,this.getPointer(e));this._maybeGroupObjects(e),t&&(t.isMoving=!1),n&&this.renderAll(),this._handleCursorAndEvent(e,t)},_handleCursorAndEvent:function(e,t){this._setCursorFromEvent(e,t);var n=this;setTimeout(function(){n._setCursorFromEvent(e,t)},50),this.fire("mouse:up",{target:t,e:e}),t&&t.fire("mouseup",{e:e})},_finalizeCurrentTransform:function(){var e=this._currentTransform,t=e.target;t._scaling&&(t._scaling=!1),t.setCoords(),this.stateful&&t.hasStateChanged()&&(this.fire("object:modified",{target:t}),t.fire("modified")),this._restoreOriginXY(t)},_restoreOriginXY:function(e){if(this._previousOriginX&&this._previousOriginY){var t=e.translateToOriginPoint(e.getCenterPoint(),this._previousOriginX,this._previousOriginY);e.originX=this._previousOriginX,e.originY=this._previousOriginY,e.left=t.x,e.top=t.y,this._previousOriginX=null,this._previousOriginY=null}},_onMouseDownInDrawingMode:function(e){this._isCurrentlyDrawing=!0,this.discardActiveObject(e).renderAll(),this.clipTo&&fabric.util.clipContext(this,this.contextTop);var t=fabric.util.invertTransform(this.viewportTransform),n=fabric.util.transformPoint(this.getPointer(e,!0),t);this.freeDrawingBrush.onMouseDown(n),this.fire("mouse:down",{e:e});var r=this.findTarget(e);typeof r!="undefined"&&r.fire("mousedown",{e:e,target:r})},_onMouseMoveInDrawingMode:function(e){if(this._isCurrentlyDrawing){var t=fabric.util.invertTransform(this.viewportTransform),n=fabric.util.transformPoint(this.getPointer(e,!0),t);this.freeDrawingBrush.onMouseMove(n)}this.setCursor(this.freeDrawingCursor),this.fire("mouse:move",{e:e});var r=this.findTarget(e);typeof r!="undefined"&&r.fire("mousemove",{e:e,target:r})},_onMouseUpInDrawingMode:function(e){this._isCurrentlyDrawing=!1,this.clipTo&&this.contextTop.restore(),this.freeDrawingBrush.onMouseUp(),this.fire("mouse:up",{e:e});var t=this.findTarget(e);typeof t!="undefined"&&t.fire("mouseup",{e:e,target:t})},__onMouseDown:function(e){var t="which"in e?e.which===1:e.button===1;if(!t&&!fabric.isTouchSupported)return;if(this.isDrawingMode){this._onMouseDownInDrawingMode(e);return}if(this._currentTransform)return;var n=this.findTarget(e),r=this.getPointer(e,!0);this._previousPointer=r;var i=this._shouldRender(n,r),s=this._shouldGroup(e,n);this._shouldClearSelection(e,n)?this._clearSelection(e,n,r):s&&(this._handleGrouping(e,n),n=this.getActiveGroup()),n&&n.selectable&&!s&&(this._beforeTransform(e,n),this._setupCurrentTransform(e,n)),i&&this.renderAll(),this.fire("mouse:down",{target:n,e:e}),n&&n.fire("mousedown",{e:e})},_beforeTransform:function(e,t){var n;this.stateful&&t.saveState(),(n=t._findTargetCorner(this.getPointer(e)))&&this.onBeforeScaleRotate(t),t!==this.getActiveGroup()&&t!==this.getActiveObject()&&(this.deactivateAll(),this.setActiveObject(t,e))},_clearSelection:function(e,t,n){this.deactivateAllWithDispatch(e),t&&t.selectable?this.setActiveObject(t,e):this.selection&&(this._groupSelector={ex:n.x,ey:n.y,top:0,left:0})},_setOriginToCenter:function(e){this._previousOriginX=this._currentTransform.target.originX,this._previousOriginY=this._currentTransform.target.originY;var t=e.getCenterPoint();e.originX="center",e.originY="center",e.left=t.x,e.top=t.y,this._currentTransform.left=e.left,this._currentTransform.top=e.top},_setCenterToOrigin:function(e){var t=e.translateToOriginPoint(e.getCenterPoint(),this._previousOriginX,this._previousOriginY);e.originX=this._previousOriginX,e.originY=this._previousOriginY,e.left=t.x,e.top=t.y,this._previousOriginX=null,this._previousOriginY=null},__onMouseMove:function(e){var t,n;if(this.isDrawingMode){this._onMouseMoveInDrawingMode(e);return}if(typeof e.touches!="undefined"&&e.touches.length>1)return;var r=this._groupSelector;r?(n=this.getPointer(e,!0),r.left=n.x-r.ex,r.top=n.y-r.ey,this.renderTop()):this._currentTransform?this._transformObject(e):(t=this.findTarget(e),!t||t&&!t.selectable?this.setCursor(this.defaultCursor):this._setCursorFromEvent(e,t)),this.fire("mouse:move",{target:t,e:e}),t&&t.fire("mousemove",{e:e})},_transformObject:function(e){var t=this.getPointer(e),n=this._currentTransform;n.reset=!1,n.target.isMoving=!0,this._beforeScaleTransform(e,n),this._performTransformAction(e,n,t),this.renderAll()},_performTransformAction:function(e,t,n){var r=n.x,i=n.y,s=t.target,o=t.action;o==="rotate"?(this._rotateObject(r,i),this._fire("rotating",s,e)):o==="scale"?(this._onScale(e,t,r,i),this._fire("scaling",s,e)):o==="scaleX"?(this._scaleObject(r,i,"x"),this._fire("scaling",s,e)):o==="scaleY"?(this._scaleObject(r,i,"y"),this._fire("scaling",s,e)):(this._translateObject(r,i),this._fire("moving",s,e),this.setCursor(this.moveCursor))},_fire:function(e,t,n){this.fire("object:"+e,{target:t,e:n}),t.fire(e,{e:n})},_beforeScaleTransform:function(e,t){if(t.action==="scale"||t.action==="scaleX"||t.action==="scaleY"){var n=this._shouldCenterTransform(e,t.target);if(n&&(t.originX!=="center"||t.originY!=="center")||!n&&t.originX==="center"&&t.originY==="center")this._resetCurrentTransform(e),t.reset=!0}},_onScale:function(e,t,n,r){(e.shiftKey||this.uniScaleTransform)&&!t.target.get("lockUniScaling")?(t.currentAction="scale",this._scaleObject(n,r)):(!t.reset&&t.currentAction==="scale"&&this._resetCurrentTransform(e,t.target),t.currentAction="scaleEqually",this._scaleObject(n,r,"equally"))},_setCursorFromEvent:function(e,t){if(!t||!t.selectable)return this.setCursor(this.defaultCursor),!1;var n=this.getActiveGroup(),r=t._findTargetCorner&&(!n||!n.contains(t))&&t._findTargetCorner(this.getPointer(e,!0));return r?this._setCornerCursor(r,t):this.setCursor(t.hoverCursor||this.hoverCursor),!0},_setCornerCursor:function(t,n){if(t in e)this.setCursor(this._getRotatedCornerCursor(t,n));else{if(t!=="mtr"||!n.hasRotatingPoint)return this.setCursor(this.defaultCursor),!1;this.setCursor(this.rotationCursor)}},_getRotatedCornerCursor:function(t,n){var r=Math.round(n.getAngle()%360/45);return r<0&&(r+=8),r+=e[t],r%=8,this.cursorMap[r]}})}(),function(){var e=Math.min,t=Math.max;fabric.util.object.extend(fabric.Canvas.prototype,{_shouldGroup:function(e,t){var n=this.getActiveObject();return e.shiftKey&&(this.getActiveGroup()||n&&n!==t)&&this.selection},_handleGrouping:function(e,t){if(t===this.getActiveGroup()){t=this.findTarget(e,!0);if(!t||t.isType("group"))return}this.getActiveGroup()?this._updateActiveGroup(t,e):this._createActiveGroup(t,e),this._activeGroup&&this._activeGroup.saveCoords()},_updateActiveGroup:function(e,t){var n=this.getActiveGroup();if(n.contains(e)){n.removeWithUpdate(e),this._resetObjectTransform(n),e.set("active",!1);if(n.size()===1){this.discardActiveGroup(t),this.setActiveObject(n.item(0));return}}else n.addWithUpdate(e),this._resetObjectTransform(n);this.fire("selection:created",{target:n,e:t}),n.set("active",!0)},_createActiveGroup:function(e,t){if(this._activeObject&&e!==this._activeObject){var n=this._createGroup(e);n.addWithUpdate(),this.setActiveGroup(n),this._activeObject=null,this.fire("selection:created",{target:n,e:t})}e.set("active",!0)},_createGroup:function(e){var t=this.getObjects(),n=t.indexOf(this._activeObject)<t.indexOf(e),r=n?[this._activeObject,e]:[e,this._activeObject];return new fabric.Group(r,{canvas:this})},_groupSelectedObjects:function(e){var t=this._collectObjects();t.length===1?this.setActiveObject(t[0],e):t.length>1&&(t=new fabric.Group(t.reverse(),{canvas:this}),t.addWithUpdate(),this.setActiveGroup(t,e),t.saveCoords(),this.fire("selection:created",{target:t}),this.renderAll())},_collectObjects:function(){var n=[],r,i=this._groupSelector.ex,s=this._groupSelector.ey,o=i+this._groupSelector.left,u=s+this._groupSelector.top,a=new fabric.Point(e(i,o),e(s,u)),f=new fabric.Point(t(i,o),t(s,u)), +l=i===o&&s===u;for(var c=this._objects.length;c--;){r=this._objects[c];if(!r||!r.selectable||!r.visible)continue;if(r.intersectsWithRect(a,f)||r.isContainedWithinRect(a,f)||r.containsPoint(a)||r.containsPoint(f)){r.set("active",!0),n.push(r);if(l)break}}return n},_maybeGroupObjects:function(e){this.selection&&this._groupSelector&&this._groupSelectedObjects(e);var t=this.getActiveGroup();t&&(t.setObjectsCoords().setCoords(),t.isMoving=!1,this.setCursor(this.defaultCursor)),this._groupSelector=null,this._currentTransform=null}})}(),fabric.util.object.extend(fabric.StaticCanvas.prototype,{toDataURL:function(e){e||(e={});var t=e.format||"png",n=e.quality||1,r=e.multiplier||1,i={left:e.left,top:e.top,width:e.width,height:e.height};return r!==1?this.__toDataURLWithMultiplier(t,n,i,r):this.__toDataURL(t,n,i)},__toDataURL:function(e,t,n){this.renderAll(!0);var r=this.upperCanvasEl||this.lowerCanvasEl,i=this.__getCroppedCanvas(r,n);e==="jpg"&&(e="jpeg");var s=fabric.StaticCanvas.supports("toDataURLWithQuality")?(i||r).toDataURL("image/"+e,t):(i||r).toDataURL("image/"+e);return this.contextTop&&this.clearContext(this.contextTop),this.renderAll(),i&&(i=null),s},__getCroppedCanvas:function(e,t){var n,r,i="left"in t||"top"in t||"width"in t||"height"in t;return i&&(n=fabric.util.createCanvasElement(),r=n.getContext("2d"),n.width=t.width||this.width,n.height=t.height||this.height,r.drawImage(e,-t.left||0,-t.top||0)),n},__toDataURLWithMultiplier:function(e,t,n,r){var i=this.getWidth(),s=this.getHeight(),o=i*r,u=s*r,a=this.getActiveObject(),f=this.getActiveGroup(),l=this.contextTop||this.contextContainer;r>1&&this.setWidth(o).setHeight(u),l.scale(r,r),n.left&&(n.left*=r),n.top&&(n.top*=r),n.width?n.width*=r:r<1&&(n.width=o),n.height?n.height*=r:r<1&&(n.height=u),f?this._tempRemoveBordersControlsFromGroup(f):a&&this.deactivateAll&&this.deactivateAll(),this.renderAll(!0);var c=this.__toDataURL(e,t,n);return this.width=i,this.height=s,l.scale(1/r,1/r),this.setWidth(i).setHeight(s),f?this._restoreBordersControlsOnGroup(f):a&&this.setActiveObject&&this.setActiveObject(a),this.contextTop&&this.clearContext(this.contextTop),this.renderAll(),c},toDataURLWithMultiplier:function(e,t,n){return this.toDataURL({format:e,multiplier:t,quality:n})},_tempRemoveBordersControlsFromGroup:function(e){e.origHasControls=e.hasControls,e.origBorderColor=e.borderColor,e.hasControls=!0,e.borderColor="rgba(0,0,0,0)",e.forEachObject(function(e){e.origBorderColor=e.borderColor,e.borderColor="rgba(0,0,0,0)"})},_restoreBordersControlsOnGroup:function(e){e.hideControls=e.origHideControls,e.borderColor=e.origBorderColor,e.forEachObject(function(e){e.borderColor=e.origBorderColor,delete e.origBorderColor})}}),fabric.util.object.extend(fabric.StaticCanvas.prototype,{loadFromDatalessJSON:function(e,t,n){return this.loadFromJSON(e,t,n)},loadFromJSON:function(e,t,n){if(!e)return;var r=typeof e=="string"?JSON.parse(e):e;this.clear();var i=this;return this._enlivenObjects(r.objects,function(){i._setBgOverlay(r,t)},n),this},_setBgOverlay:function(e,t){var n=this,r={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(!e.backgroundImage&&!e.overlayImage&&!e.background&&!e.overlay){t&&t();return}var i=function(){r.backgroundImage&&r.overlayImage&&r.backgroundColor&&r.overlayColor&&(n.renderAll(),t&&t())};this.__setBgOverlay("backgroundImage",e.backgroundImage,r,i),this.__setBgOverlay("overlayImage",e.overlayImage,r,i),this.__setBgOverlay("backgroundColor",e.background,r,i),this.__setBgOverlay("overlayColor",e.overlay,r,i),i()},__setBgOverlay:function(e,t,n,r){var i=this;if(!t){n[e]=!0;return}e==="backgroundImage"||e==="overlayImage"?fabric.Image.fromObject(t,function(t){i[e]=t,n[e]=!0,r&&r()}):this["set"+fabric.util.string.capitalize(e,!0)](t,function(){n[e]=!0,r&&r()})},_enlivenObjects:function(e,t,n){var r=this;if(!e||e.length===0){t&&t();return}var i=this.renderOnAddRemove;this.renderOnAddRemove=!1,fabric.util.enlivenObjects(e,function(e){e.forEach(function(e,t){r.insertAt(e,t,!0)}),r.renderOnAddRemove=i,t&&t()},null,n)},_toDataURL:function(e,t){this.clone(function(n){t(n.toDataURL(e))})},_toDataURLWithMultiplier:function(e,t,n){this.clone(function(r){n(r.toDataURLWithMultiplier(e,t))})},clone:function(e,t){var n=JSON.stringify(this.toJSON(t));this.cloneWithoutData(function(t){t.loadFromJSON(n,function(){e&&e(t)})})},cloneWithoutData:function(e){var t=fabric.document.createElement("canvas");t.width=this.getWidth(),t.height=this.getHeight();var n=new fabric.Canvas(t);n.clipTo=this.clipTo,this.backgroundImage?(n.setBackgroundImage(this.backgroundImage.src,function(){n.renderAll(),e&&e(n)}),n.backgroundImageOpacity=this.backgroundImageOpacity,n.backgroundImageStretch=this.backgroundImageStretch):e&&e(n)}}),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.toFixed,i=t.util.string.capitalize,s=t.util.degreesToRadians,o=t.StaticCanvas.supports("setLineDash");if(t.Object)return;t.Object=t.util.createClass({type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,cornerSize:12,transparentCorners:!0,hoverCursor:null,padding:0,borderColor:"rgba(102,153,255,0.75)",cornerColor:"rgba(102,153,255,0.5)",centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:10,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,transformMatrix:null,minScaleLimit:.01,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,hasRotatingPoint:!0,rotatingPointOffset:40,perPixelTargetFind:!1,includeDefaultValues:!0,clipTo:null,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockUniScaling:!1,lockScalingFlip:!1,stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeLineJoin strokeMiterLimit angle opacity fill fillRule globalCompositeOperation shadow clipTo visible backgroundColor".split(" "),initialize:function(e){e&&this.setOptions(e)},_initGradient:function(e){e.fill&&e.fill.colorStops&&!(e.fill instanceof t.Gradient)&&this.set("fill",new t.Gradient(e.fill))},_initPattern:function(e){e.fill&&e.fill.source&&!(e.fill instanceof t.Pattern)&&this.set("fill",new t.Pattern(e.fill)),e.stroke&&e.stroke.source&&!(e.stroke instanceof t.Pattern)&&this.set("stroke",new t.Pattern(e.stroke))},_initClipping:function(e){if(!e.clipTo||typeof e.clipTo!="string")return;var n=t.util.getFunctionBody(e.clipTo);typeof n!="undefined"&&(this.clipTo=new Function("ctx",n))},setOptions:function(e){for(var t in e)this.set(t,e[t]);this._initGradient(e),this._initPattern(e),this._initClipping(e)},transform:function(e,t){this.group&&this.group.transform(e,t);var n=t?this._getLeftTopCoords():this.getCenterPoint();e.translate(n.x,n.y),e.rotate(s(this.angle)),e.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(e){var n=t.Object.NUM_FRACTION_DIGITS,i={type:this.type,originX:this.originX,originY:this.originY,left:r(this.left,n),top:r(this.top,n),width:r(this.width,n),height:r(this.height,n),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,n),strokeDashArray:this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:r(this.strokeMiterLimit,n),scaleX:r(this.scaleX,n),scaleY:r(this.scaleY,n),angle:r(this.getAngle(),n),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,n),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,clipTo:this.clipTo&&String(this.clipTo),backgroundColor:this.backgroundColor,fillRule:this.fillRule,globalCompositeOperation:this.globalCompositeOperation};return this.includeDefaultValues||(i=this._removeDefaultValues(i)),t.util.populateWithProperties(this,i,e),i},toDatalessObject:function(e){return this.toObject(e)},_removeDefaultValues:function(e){var n=t.util.getKlass(e.type).prototype,r=n.stateProperties;return r.forEach(function(t){e[t]===n[t]&&delete e[t]}),e},toString:function(){return"#<fabric."+i(this.type)+">"},get:function(e){return this[e]},_setObject:function(e){for(var t in e)this._set(t,e[t])},set:function(e,t){return typeof e=="object"?this._setObject(e):typeof t=="function"&&e!=="clipTo"?this._set(e,t(this.get(e))):this._set(e,t),this},_set:function(e,n){var i=e==="scaleX"||e==="scaleY";return i&&(n=this._constrainScale(n)),e==="scaleX"&&n<0?(this.flipX=!this.flipX,n*=-1):e==="scaleY"&&n<0?(this.flipY=!this.flipY,n*=-1):e==="width"||e==="height"?this.minScaleLimit=r(Math.min(.1,1/Math.max(this.width,this.height)),2):e==="shadow"&&n&&!(n instanceof t.Shadow)&&(n=new t.Shadow(n)),this[e]=n,this},toggle:function(e){var t=this.get(e);return typeof t=="boolean"&&this.set(e,!t),this},setSourcePath:function(e){return this.sourcePath=e,this},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:[1,0,0,1,0,0]},render:function(e,n){if(this.width===0&&this.height===0||!this.visible)return;e.save(),this._setupCompositeOperation(e),n||this.transform(e),this._setStrokeStyles(e),this._setFillStyles(e),this.group&&this.group.type==="path-group"&&e.translate(-this.group.width/2,-this.group.height/2),this.transformMatrix&&e.transform.apply(e,this.transformMatrix),this._setOpacity(e),this._setShadow(e),this.clipTo&&t.util.clipContext(this,e),this._render(e,n),this.clipTo&&e.restore(),this._removeShadow(e),this._restoreCompositeOperation(e),e.restore()},_setOpacity:function(e){this.group&&this.group._setOpacity(e),e.globalAlpha*=this.opacity},_setStrokeStyles:function(e){this.stroke&&(e.lineWidth=this.strokeWidth,e.lineCap=this.strokeLineCap,e.lineJoin=this.strokeLineJoin,e.miterLimit=this.strokeMiterLimit,e.strokeStyle=this.stroke.toLive?this.stroke.toLive(e,this):this.stroke)},_setFillStyles:function(e){this.fill&&(e.fillStyle=this.fill.toLive?this.fill.toLive(e,this):this.fill)},_renderControls:function(e,n){var r=this.getViewportTransform();e.save();if(this.active&&!n){var i;this.group&&(i=t.util.transformPoint(this.group.getCenterPoint(),r),e.translate(i.x,i.y),e.rotate(s(this.group.angle))),i=t.util.transformPoint(this.getCenterPoint(),r,null!=this.group),this.group&&(i.x*=this.group.scaleX,i.y*=this.group.scaleY),e.translate(i.x,i.y),e.rotate(s(this.angle)),this.drawBorders(e),this.drawControls(e)}e.restore()},_setShadow:function(e){if(!this.shadow)return;var t=this.canvas&&this.canvas._currentMultiplier||1;e.shadowColor=this.shadow.color,e.shadowBlur=this.shadow.blur*t*(this.scaleX+this.scaleY)/2,e.shadowOffsetX=this.shadow.offsetX*t*this.scaleX,e.shadowOffsetY=this.shadow.offsetY*t*this.scaleY},_removeShadow:function(e){if(!this.shadow)return;e.shadowColor="",e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0},_renderFill:function(e){if(!this.fill)return;e.save();if(this.fill.gradientTransform){var t=this.fill.gradientTransform;e.transform.apply(e,t)}this.fill.toLive&&e.translate(-this.width/2+this.fill.offsetX||0,-this.height/2+this.fill.offsetY||0),this.fillRule==="evenodd"?e.fill("evenodd"):e.fill(),e.restore(),this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e)},_renderStroke:function(e){if(!this.stroke||this.strokeWidth===0)return;e.save();if(this.strokeDashArray)1&this.strokeDashArray.length&&this.strokeDashArray.push.apply(this.strokeDashArray,this.strokeDashArray),o?(e.setLineDash(this.strokeDashArray),this._stroke&&this._stroke(e)):this._renderDashedStroke&&this._renderDashedStroke(e),e.stroke();else{if(this.stroke.gradientTransform){var t=this.stroke.gradientTransform;e.transform.apply(e,t)}this._stroke?this._stroke(e):e.stroke()}this._removeShadow(e),e.restore()},clone:function(e,n){return this.constructor.fromObject?this.constructor.fromObject(this.toObject(n),e):new t.Object(this.toObject(n))},cloneAsImage:function(e){var n=this.toDataURL();return t.util.loadImage(n,function(n){e&&e(new t.Image(n))}),this},toDataURL:function(e){e||(e={});var n=t.util.createCanvasElement(),r=this.getBoundingRect();n.width=r.width,n.height=r.height,t.util.wrapElement(n,"div");var i=new t.Canvas(n);e.format==="jpg"&&(e.format="jpeg"),e.format==="jpeg"&&(i.backgroundColor="#fff");var s={active:this.get("active"),left:this.getLeft(),top:this.getTop()};this.set("active",!1),this.setPositionByOrigin(new t.Point(n.width/2,n.height/2),"center","center");var o=this.canvas;i.add(this);var u=i.toDataURL(e);return this.set(s).setCoords(),this.canvas=o,i.dispose(),i=null,u},isType:function(e){return this.type===e},complexity:function(){return 0},toJSON:function(e){return this.toObject(e)},setGradient:function(e,n){n||(n={});var r={colorStops:[]};r.type=n.type||(n.r1||n.r2?"radial":"linear"),r.coords={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2};if(n.r1||n.r2)r.coords.r1=n.r1,r.coords.r2=n.r2;for(var i in n.colorStops){var s=new t.Color(n.colorStops[i]);r.colorStops.push({offset:i,color:s.toRgb(),opacity:s.getAlpha()})}return this.set(e,t.Gradient.forObject(this,r))},setPatternFill:function(e){return this.set("fill",new t.Pattern(e))},setShadow:function(e){return this.set("shadow",e?new t.Shadow(e):null)},setColor:function(e){return this.set("fill",e),this},setAngle:function(e){var t=(this.originX!=="center"||this.originY!=="center")&&this.centeredRotation;return t&&this._setOriginToCenter(),this.set("angle",e),t&&this._resetOrigin(),this},centerH:function(){return this.canvas.centerObjectH(this),this},centerV:function(){return this.canvas.centerObjectV(this),this},center:function(){return this.canvas.centerObject(this),this},remove:function(){return this.canvas.remove(this),this},getLocalPointer:function(e,t){t=t||this.canvas.getPointer(e);var n=this.translateToOriginPoint(this.getCenterPoint(),"left","top");return{x:t.x-n.x,y:t.y-n.y}},_setupCompositeOperation:function(e){this.globalCompositeOperation&&(this._prevGlobalCompositeOperation=e.globalCompositeOperation,e.globalCompositeOperation=this.globalCompositeOperation)},_restoreCompositeOperation:function(e){this.globalCompositeOperation&&this._prevGlobalCompositeOperation&&(e.globalCompositeOperation=this._prevGlobalCompositeOperation)}}),t.util.createAccessors(t.Object),t.Object.prototype.rotate=t.Object.prototype.setAngle,n(t.Object.prototype,t.Observable),t.Object.NUM_FRACTION_DIGITS=2,t.Object.__uid=0}(typeof exports!="undefined"?exports:this),function(){var e=fabric.util.degreesToRadians;fabric.util.object.extend(fabric.Object.prototype,{translateToCenterPoint:function(t,n,r){var i=t.x,s=t.y,o=this.stroke?this.strokeWidth:0;return n==="left"?i=t.x+(this.getWidth()+o*this.scaleX)/2:n==="right"&&(i=t.x-(this.getWidth()+o*this.scaleX)/2),r==="top"?s=t.y+(this.getHeight()+o*this.scaleY)/2:r==="bottom"&&(s=t.y-(this.getHeight()+o*this.scaleY)/2),fabric.util.rotatePoint(new fabric.Point(i,s),t,e(this.angle))},translateToOriginPoint:function(t,n,r){var i=t.x,s=t.y,o=this.stroke?this.strokeWidth:0;return n==="left"?i=t.x-(this.getWidth()+o*this.scaleX)/2:n==="right"&&(i=t.x+(this.getWidth()+o*this.scaleX)/2),r==="top"?s=t.y-(this.getHeight()+o*this.scaleY)/2:r==="bottom"&&(s=t.y+(this.getHeight()+o*this.scaleY)/2),fabric.util.rotatePoint(new fabric.Point(i,s),t,e(this.angle))},getCenterPoint:function(){var e=new fabric.Point(this.left,this.top);return this.translateToCenterPoint(e,this.originX,this.originY)},getPointByOrigin:function(e,t){var n=this.getCenterPoint();return this.translateToOriginPoint(n,e,t)},toLocalPoint:function(t,n,r){var i=this.getCenterPoint(),s=this.stroke?this.strokeWidth:0,o,u;return n&&r?(n==="left"?o=i.x-(this.getWidth()+s*this.scaleX)/2:n==="right"?o=i.x+(this.getWidth()+s*this.scaleX)/2:o=i.x,r==="top"?u=i.y-(this.getHeight()+s*this.scaleY)/2:r==="bottom"?u=i.y+(this.getHeight()+s*this.scaleY)/2:u=i.y):(o=this.left,u=this.top),fabric.util.rotatePoint(new fabric.Point(t.x,t.y),i,-e(this.angle)).subtractEquals(new fabric.Point(o,u))},setPositionByOrigin:function(e,t,n){var r=this.translateToCenterPoint(e,t,n),i=this.translateToOriginPoint(r,this.originX,this.originY);this.set("left",i.x),this.set("top",i.y)},adjustPosition:function(t){var n=e(this.angle),r=this.getWidth()/2,i=Math.cos(n)*r,s=Math.sin(n)*r,o=this.getWidth(),u=Math.cos(n)*o,a=Math.sin(n)*o;this.originX==="center"&&t==="left"||this.originX==="right"&&t==="center"?(this.left-=i,this.top-=s):this.originX==="left"&&t==="center"||this.originX==="center"&&t==="right"?(this.left+=i,this.top+=s):this.originX==="left"&&t==="right"?(this.left+=u,this.top+=a):this.originX==="right"&&t==="left"&&(this.left-=u,this.top-=a),this.setCoords(),this.originX=t},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var e=this.getCenterPoint();this.originX="center",this.originY="center",this.left=e.x,this.top=e.y},_resetOrigin:function(){var e=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=e.x,this.top=e.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","center")}})}(),function(){var e=fabric.util.degreesToRadians;fabric.util.object.extend(fabric.Object.prototype,{oCoords:null,intersectsWithRect:function(e,t){var n=this.oCoords,r=new fabric.Point(n.tl.x,n.tl.y),i=new fabric.Point(n.tr.x,n.tr.y),s=new fabric.Point(n.bl.x,n.bl.y),o=new fabric.Point(n.br.x,n.br.y),u=fabric.Intersection.intersectPolygonRectangle([r,i,o,s],e,t);return u.status==="Intersection"},intersectsWithObject:function(e){function t(e){return{tl:new fabric.Point(e.tl.x,e.tl.y),tr:new fabric.Point(e.tr.x,e.tr.y),bl:new fabric.Point(e.bl.x,e.bl.y),br:new fabric.Point(e.br.x,e.br.y)}}var n=t(this.oCoords),r=t(e.oCoords),i=fabric.Intersection.intersectPolygonPolygon([n.tl,n.tr,n.br,n.bl],[r.tl,r.tr,r.br,r.bl]);return i.status==="Intersection"},isContainedWithinObject:function(e){var t=e.getBoundingRect(),n=new fabric.Point(t.left,t.top),r=new fabric.Point(t.left+t.width,t.top+t.height);return this.isContainedWithinRect(n,r)},isContainedWithinRect:function(e,t){var n=this.getBoundingRect();return n.left>=e.x&&n.left+n.width<=t.x&&n.top>=e.y&&n.top+n.height<=t.y},containsPoint:function(e){var t=this._getImageLines(this.oCoords),n=this._findCrossPoints(e,t);return n!==0&&n%2===1},_getImageLines:function(e){return{topline:{o:e.tl,d:e.tr},rightline:{o:e.tr,d:e.br},bottomline:{o:e.br,d:e.bl},leftline:{o:e.bl,d:e.tl}}},_findCrossPoints:function(e,t){var n,r,i,s,o,u,a=0,f;for(var l in t){f=t[l];if(f.o.y<e.y&&f.d.y<e.y)continue;if(f.o.y>=e.y&&f.d.y>=e.y)continue;f.o.x===f.d.x&&f.o.x>=e.x?(o=f.o.x,u=e.y):(n=0,r=(f.d.y-f.o.y)/(f.d.x-f.o.x),i=e.y-n*e.x,s=f.o.y-r*f.o.x,o=-(i-s)/(n-r),u=i+n*o),o>=e.x&&(a+=1);if(a===2)break}return a},getBoundingRectWidth:function(){return this.getBoundingRect().width},getBoundingRectHeight:function(){return this.getBoundingRect().height},getBoundingRect:function(){this.oCoords||this.setCoords();var e=[this.oCoords.tl.x,this.oCoords.tr.x,this.oCoords.br.x,this.oCoords.bl.x],t=fabric.util.array.min(e),n=fabric.util.array.max(e),r=Math.abs(t-n),i=[this.oCoords.tl.y,this.oCoords.tr.y,this.oCoords.br.y,this.oCoords.bl.y],s=fabric.util.array.min(i),o=fabric.util.array.max(i),u=Math.abs(s-o);return{left:t,top:s,width:r,height:u}},getWidth:function(){return this.width*this.scaleX},getHeight:function(){return this.height*this.scaleY},_constrainScale:function(e){return Math.abs(e)<this.minScaleLimit?e<0?-this.minScaleLimit:this.minScaleLimit:e},scale:function(e){return e=this._constrainScale(e),e<0&&(this.flipX=!this.flipX,this.flipY=!this.flipY,e*=-1),this.scaleX=e,this.scaleY=e,this.setCoords(),this},scaleToWidth:function(e){var t=this.getBoundingRectWidth()/this.getWidth();return this.scale(e/this.width/t)},scaleToHeight:function(e){var t=this.getBoundingRectHeight()/this.getHeight();return this.scale(e/this.height/t)},setCoords:function(){var t=this.strokeWidth,n=e(this.angle),r=this.getViewportTransform(),i=function(e){return fabric.util.transformPoint(e,r)},s=this.width,o,u=this.height,a,f=this.strokeLineCap==="round"||this.strokeLineCap==="square",l=this.type==="line"&&this.width===0,c=this.type==="line"&&this.height===0,h=l||c,p=f&&c||!h,d=f&&l||!h;l?s=t:c&&(u=t),p&&(s+=s>0?t:-t),d&&(u+=u>0?t:-t),o=s*this.scaleX+2*this.padding,a=u*this.scaleY+2*this.padding,o<0&&(o=Math.abs(o));var v=Math.sqrt(Math.pow(o/2,2)+Math.pow(a/2,2)),m=Math.atan(isFinite(a/o)?a/o:0),g=Math.cos(m+n)*v,y=Math.sin(m+n)*v,b=Math.sin(n),w=Math.cos(n),E=this.getCenterPoint(),S=new fabric.Point(o,a),x=new fabric.Point(E.x-g,E.y-y),T=new fabric.Point(x.x+S.x*w,x.y+S.x*b),N=new fabric.Point(x.x-S.y*b,x.y+S.y*w),C=new fabric.Point(x.x+S.x/2*w,x.y+S.x/2*b),k=i(x),L=i(T),A=i(new fabric.Point(T.x-S.y*b,T.y+S.y*w)),O=i(N),M=i(new fabric.Point(x.x-S.y/2*b,x.y+S.y/2*w)),_=i(C),D=i(new fabric.Point(T.x-S.y/2*b,T.y+S.y/2*w)),P=i(new fabric.Point(N.x+S.x/2*w,N.y+S.x/2*b)),H=i(new fabric.Point(C.x,C.y));return this.oCoords={tl:k,tr:L,br:A,bl:O,ml:M,mt:_,mr:D,mb:P,mtr:H},this._setCornerCoords&&this._setCornerCoords(),this}})}(),fabric.util.object.extend(fabric.Object.prototype,{sendToBack:function(){return this.group?fabric.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?fabric.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas.bringToFront(this),this},sendBackwards:function(e){return this.group?fabric.StaticCanvas.prototype.sendBackwards.call(this.group,this,e):this.canvas.sendBackwards(this,e),this},bringForward:function(e){return this.group?fabric.StaticCanvas.prototype.bringForward.call(this.group,this,e):this.canvas.bringForward(this,e),this},moveTo:function(e){return this.group?fabric.StaticCanvas.prototype.moveTo.call(this.group,this,e):this.canvas.moveTo(this,e),this}}),fabric.util.object.extend(fabric.Object.prototype,{getSvgStyles:function(){var e=this.fill?this.fill.toLive?"url(#SVGID_"+this.fill.id+")":this.fill:"none",t=this.fillRule,n=this.stroke?this.stroke.toLive?"url(#SVGID_"+this.stroke.id+")":this.stroke:"none",r=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):"",s=this.strokeLineCap?this.strokeLineCap:"butt",o=this.strokeLineJoin?this.strokeLineJoin:"miter",u=this.strokeMiterLimit?this.strokeMiterLimit:"4",a=typeof this.opacity!="undefined"?this.opacity:"1",f=this.visible?"":" visibility: hidden;",l=this.shadow&&this.type!=="text"?"filter: url(#SVGID_"+this.shadow.id+");":"";return["stroke: ",n,"; ","stroke-width: ",r,"; ","stroke-dasharray: ",i,"; ","stroke-linecap: ",s,"; ","stroke-linejoin: ",o,"; ","stroke-miterlimit: ",u,"; ","fill: ",e,"; ","fill-rule: ",t,"; ","opacity: ",a,";",l,f].join("")},getSvgTransform:function(){if(this.group&&this.group.type==="path-group")return"";var e=fabric.util.toFixed,t=this.getAngle(),n=!this.canvas||this.canvas.svgViewportTransformation?this.getViewportTransform():[1,0,0,1,0,0],r=fabric.util.transformPoint(this.getCenterPoint(),n),i=fabric.Object.NUM_FRACTION_DIGITS,s=this.type==="path-group"?"":"translate("+e(r.x,i)+" "+e(r.y,i)+")",o=t!==0?" rotate("+e(t,i)+")":"",u=this.scaleX===1&&this.scaleY===1&&n[0]===1&&n[3]===1?"":" scale("+e(this.scaleX*n[0],i)+" "+e(this.scaleY*n[3],i)+")",a=this.type==="path-group"?this.width*n[0]:0,f=this.flipX?" matrix(-1 0 0 1 "+a+" 0) ":"",l=this.type==="path-group"?this.height*n[3]:0,c=this.flipY?" matrix(1 0 0 -1 0 "+l+")":"";return[s,o,u,f,c].join("")},getSvgTransformMatrix:function(){return this.transformMatrix?" matrix("+this.transformMatrix.join(" ")+")":""},_createBaseSVGMarkup:function(){var e=[];return this.fill&&this.fill.toLive&&e.push(this.fill.toSVG(this,!1)),this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!1)),this.shadow&&e.push(this.shadow.toSVG(this)),e}}),fabric.util.object.extend(fabric.Object.prototype,{hasStateChanged:function(){return this.stateProperties.some(function(e){return this.get(e)!==this.originalState[e]},this)},saveState:function(e){return this.stateProperties.forEach(function(e){this.originalState[e]=this.get(e)},this),e&&e.stateProperties&&e.stateProperties.forEach(function(e){this.originalState[e]=this.get(e)},this),this},setupState:function(){return this.originalState={},this.saveState(),this}}),function(){var e=fabric.util.degreesToRadians,t=function(){return typeof G_vmlCanvasManager!="undefined"};fabric.util.object.extend(fabric.Object.prototype,{_controlsVisibility:null,_findTargetCorner:function(e){if(!this.hasControls||!this.active)return!1;var t=e.x,n=e.y,r,i;for(var s in this.oCoords){if(!this.isControlVisible(s))continue;if(s==="mtr"&&!this.hasRotatingPoint)continue;if(!(!this.get("lockUniScaling")||s!=="mt"&&s!=="mr"&&s!=="mb"&&s!=="ml"))continue;i=this._getImageLines(this.oCoords[s].corner),r=this._findCrossPoints({x:t,y:n},i);if(r!==0&&r%2===1)return this.__corner=s,s}return!1},_setCornerCoords:function(){var t=this.oCoords,n=e(this.angle),r=e(45-this.angle),i=Math.sqrt(2*Math.pow(this.cornerSize,2))/2,s=i*Math.cos(r),o=i*Math.sin(r),u=Math.sin(n),a=Math.cos(n);t.tl.corner={tl:{x:t.tl.x-o,y:t.tl.y-s},tr:{x:t.tl.x+s,y:t.tl.y-o},bl:{x:t.tl.x-s,y:t.tl.y+o},br:{x:t.tl.x+o,y:t.tl.y+s}},t.tr.corner={tl:{x:t.tr.x-o,y:t.tr.y-s},tr:{x:t.tr.x+s,y:t.tr.y-o},br:{x:t.tr.x+o,y:t.tr.y+s},bl:{x:t.tr.x-s,y:t.tr.y+o}},t.bl.corner={tl:{x:t.bl.x-o,y:t.bl.y-s},bl:{x:t.bl.x-s,y:t.bl.y+o},br:{x:t.bl.x+o,y:t.bl.y+s},tr:{x:t.bl.x+s,y:t.bl.y-o}},t.br.corner={tr:{x:t.br.x+s,y:t.br.y-o},bl:{x:t.br.x-s,y:t.br.y+o},br:{x:t.br.x+o,y:t.br.y+s},tl:{x:t.br.x-o,y:t.br.y-s}},t.ml.corner={tl:{x:t.ml.x-o,y:t.ml.y-s},tr:{x:t.ml.x+s,y:t.ml.y-o},bl:{x:t.ml.x-s,y:t.ml.y+o},br:{x:t.ml.x+o,y:t.ml.y+s}},t.mt.corner={tl:{x:t.mt.x-o,y:t.mt.y-s},tr:{x:t.mt.x+s,y:t.mt.y-o},bl:{x:t.mt.x-s,y:t.mt.y+o},br:{x:t.mt.x+o,y:t.mt.y+s}},t.mr.corner={tl:{x:t.mr.x-o,y:t.mr.y-s},tr:{x:t.mr.x+s,y:t.mr.y-o},bl:{x:t.mr.x-s,y:t.mr.y+o},br:{x:t.mr.x+o,y:t.mr.y+s}},t.mb.corner={tl:{x:t.mb.x-o,y:t.mb.y-s},tr:{x:t.mb.x+s,y:t.mb.y-o},bl:{x:t.mb.x-s,y:t.mb.y+o},br:{x:t.mb.x+o,y:t.mb.y+s}},t.mtr.corner={tl:{x:t.mtr.x-o+u*this.rotatingPointOffset,y:t.mtr.y-s-a*this.rotatingPointOffset},tr:{x:t.mtr.x+s+u*this.rotatingPointOffset,y:t.mtr.y-o-a*this.rotatingPointOffset},bl:{x:t.mtr.x-s+u*this.rotatingPointOffset,y:t.mtr.y+o-a*this.rotatingPointOffset},br:{x:t.mtr.x+o+u*this.rotatingPointOffset,y:t.mtr.y+s-a*this.rotatingPointOffset}}},drawBorders:function(e){if(!this.hasBorders)return this;var t=this.padding,n=t*2,r=this.getViewportTransform();e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,e.strokeStyle=this.borderColor;var i=1/this._constrainScale(this.scaleX),s=1/this._constrainScale(this.scaleY);e.lineWidth=1/this.borderScaleFactor;var o=this.getWidth(),u=this.getHeight(),a=this.strokeWidth,f=this.strokeLineCap==="round"||this.strokeLineCap==="square",l=this.type==="line"&&this.width===0,c=this.type==="line"&&this.height===0,h=l||c,p=f&&c||!h,d=f&&l||!h;l?o=a/i:c&&(u=a/s),p&&(o+=a/i),d&&(u+=a/s);var v=fabric.util.transformPoint(new fabric.Point(o,u),r,!0),m=v.x,g=v.y;this.group&&(m*=this.group.scaleX,g*=this.group.scaleY),e.strokeRect(~~(-(m/2)-t)-.5,~~(-(g/2)-t)-.5,~~(m+n)+1,~~(g+n)+1);if(this.hasRotatingPoint&&this.isControlVisible("mtr")&&!this.get("lockRotation")&&this.hasControls){var y=(-g-t*2)/2;e.beginPath(),e.moveTo(0,y),e.lineTo(0,y-this.rotatingPointOffset),e.closePath(),e.stroke()}return e.restore(),this},drawControls:function(e){if(!this.hasControls)return this;var t=this.cornerSize,n=t/2,r=this.getViewportTransform(),i=this.strokeWidth,s=this.width,o=this.height,u=this.strokeLineCap==="round"||this.strokeLineCap==="square",a=this.type==="line"&&this.width===0,f=this.type==="line"&&this.height===0,l=a||f,c=u&&f||!l,h=u&&a||!l;a?s=i:f&&(o=i),c&&(s+=i),h&&(o+=i),s*=this.scaleX,o*=this.scaleY;var p=fabric.util.transformPoint(new fabric.Point(s,o),r,!0),d=p.x,v=p.y,m=-(d/2),g=-(v/2),y=this.padding,b=n,w=n-t,E=this.transparentCorners?"strokeRect":"fillRect";return e.save(),e.lineWidth=1,e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,e.strokeStyle=e.fillStyle=this.cornerColor,this._drawControl("tl",e,E,m-b-y,g-b-y),this._drawControl("tr",e,E,m+d-b+y,g-b-y),this._drawControl("bl",e,E,m-b-y,g+v+w+y),this._drawControl("br",e,E,m+d+w+y,g+v+w+y),this.get("lockUniScaling")||(this._drawControl("mt",e,E,m+d/2-b,g-b-y),this._drawControl("mb",e,E,m+d/2-b,g+v+w+y),this._drawControl("mr",e,E,m+d+w+y,g+v/2-b),this._drawControl("ml",e,E,m-b-y,g+v/2-b)),this.hasRotatingPoint&&this._drawControl("mtr",e,E,m+d/2-b,g-this.rotatingPointOffset-this.cornerSize/2-y),e.restore(),this},_drawControl:function(e,n,r,i,s){var o=this.cornerSize;this.isControlVisible(e)&&(t()||this.transparentCorners||n.clearRect(i,s,o,o),n[r](i,s,o,o))},isControlVisible:function(e){return this._getControlsVisibility()[e]},setControlVisible:function(e,t){return this._getControlsVisibility()[e]=t,this},setControlsVisibility:function(e){e||(e={});for(var t in e)this.setControlVisible(t,e[t]);return this},_getControlsVisibility:function(){return this._controlsVisibility||(this._controlsVisibility={tl:!0,tr:!0,br:!0,bl:!0,ml:!0,mt:!0,mr:!0,mb:!0,mtr:!0}),this._controlsVisibility}})}(),fabric.util.object.extend(fabric.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(e,t){t=t||{};var n=function(){},r=t.onComplete||n,i=t.onChange||n,s=this;return fabric.util.animate({startValue:e.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(t){e.set("left",t),s.renderAll(),i()},onComplete:function(){e.setCoords(),r()}}),this},fxCenterObjectV:function(e,t){t=t||{};var n=function(){},r=t.onComplete||n,i=t.onChange||n,s=this;return fabric.util.animate({startValue:e.get("top"),endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(t){e.set("top",t),s.renderAll(),i()},onComplete:function(){e.setCoords(),r()}}),this},fxRemove:function(e,t){t=t||{};var n=function(){},r=t.onComplete||n,i=t.onChange||n,s=this;return fabric.util.animate({startValue:e.get("opacity"),endValue:0,duration:this.FX_DURATION,onStart:function(){e.set("active",!1)},onChange:function(t){e.set("opacity",t),s.renderAll(),i()},onComplete:function(){s.remove(e),r()}}),this}}),fabric.util.object.extend(fabric.Object.prototype,{animate:function(){if(arguments[0]&&typeof arguments[0]=="object"){var e=[],t,n;for(t in arguments[0])e.push(t);for(var r=0,i=e.length;r<i;r++)t=e[r],n=r!==i-1,this._animate(t,arguments[0][t],arguments[1],n)}else this._animate.apply(this,arguments);return this},_animate:function(e,t,n,r){var i=this,s;t=t.toString(),n?n=fabric.util.object.clone(n):n={},~e.indexOf(".")&&(s=e.split("."));var o=s?this.get(s[0])[s[1]]:this.get(e);"from"in n||(n.from=o),~t.indexOf("=")?t=o+parseFloat(t.replace("=","")):t=parseFloat(t),fabric.util.animate({startValue:n.from,endValue:t,byValue:n.by,easing:n.easing,duration:n.duration,abort:n.abort&&function(){return n.abort.call(i)},onChange:function(t){s?i[s[0]][s[1]]=t:i.set(e,t);if(r)return;n.onChange&&n.onChange()},onComplete:function(){if(r)return;i.setCoords(),n.onComplete&&n.onComplete()}})}}),function(e){"use strict";function s(e,t){var n=e.origin,r=e.axis1,i=e.axis2,s=e.dimension,o=t.nearest,u=t.center,a=t.farthest;return function(){switch(this.get(n)){case o:return Math.min(this.get(r),this.get(i));case u:return Math.min(this.get(r),this.get(i))+.5*this.get(s);case a:return Math.max(this.get(r),this.get(i))}}}var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r={x1:1,x2:1,y1:1,y2:1},i=t.StaticCanvas.supports("setLineDash");if(t.Line){t.warn("fabric.Line is already defined");return}t.Line=t.util.createClass(t.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,initialize:function(e,t){t=t||{},e||(e=[0,0,0,0]),this.callSuper("initialize",t),this.set("x1",e[0]),this.set("y1",e[1]),this.set("x2",e[2]),this.set("y2",e[3]),this._setWidthHeight(t)},_setWidthHeight:function(e){e||(e={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in e?e.left:this._getLeftToOriginX(),this.top="top"in e?e.top:this._getTopToOriginY()},_set:function(e,t){return this.callSuper("_set",e,t),typeof r[e]!="undefined"&&this._setWidthHeight(),this},_getLeftToOriginX:s({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:s({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest +:"bottom"}),_render:function(e,t){e.beginPath();if(t){var n=this.getCenterPoint();e.translate(n.x-this.strokeWidth/2,n.y-this.strokeWidth/2)}if(!this.strokeDashArray||this.strokeDashArray&&i){var r=this.calcLinePoints();e.moveTo(r.x1,r.y1),e.lineTo(r.x2,r.y2)}e.lineWidth=this.strokeWidth;var s=e.strokeStyle;e.strokeStyle=this.stroke||e.fillStyle,this.stroke&&this._renderStroke(e),e.strokeStyle=s},_renderDashedStroke:function(e){var n=this.calcLinePoints();e.beginPath(),t.util.drawDashedLine(e,n.x1,n.y1,n.x2,n.y2,this.strokeDashArray),e.closePath()},toObject:function(e){return n(this.callSuper("toObject",e),this.calcLinePoints())},calcLinePoints:function(){var e=this.x1<=this.x2?-1:1,t=this.y1<=this.y2?-1:1,n=e*this.width*.5,r=t*this.height*.5,i=e*this.width*-0.5,s=t*this.height*-0.5;return{x1:n,x2:i,y1:r,y2:s}},toSVG:function(e){var t=this._createBaseSVGMarkup(),n={x1:this.x1,x2:this.x2,y1:this.y1,y2:this.y2};if(!this.group||this.group.type!=="path-group")n=this.calcLinePoints();return t.push("<line ",'x1="',n.x1,'" y1="',n.y1,'" x2="',n.x2,'" y2="',n.y2,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n'),e?e(t.join("")):t.join("")},complexity:function(){return 1}}),t.Line.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),t.Line.fromElement=function(e,r){var i=t.parseAttributes(e,t.Line.ATTRIBUTE_NAMES),s=[i.x1||0,i.y1||0,i.x2||0,i.y2||0];return new t.Line(s,n(i,r))},t.Line.fromObject=function(e){var n=[e.x1,e.y1,e.x2,e.y2];return new t.Line(n,e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function i(e){return"radius"in e&&e.radius>0}var t=e.fabric||(e.fabric={}),n=Math.PI,r=t.util.object.extend;if(t.Circle){t.warn("fabric.Circle is already defined.");return}t.Circle=t.util.createClass(t.Object,{type:"circle",radius:0,startAngle:0,endAngle:n*2,initialize:function(e){e=e||{},this.callSuper("initialize",e),this.set("radius",e.radius||0),this.startAngle=e.startAngle||this.startAngle,this.endAngle=e.endAngle||this.endAngle},_set:function(e,t){return this.callSuper("_set",e,t),e==="radius"&&this.setRadius(t),this},toObject:function(e){return r(this.callSuper("toObject",e),{radius:this.get("radius"),startAngle:this.startAngle,endAngle:this.endAngle})},toSVG:function(e){var t=this._createBaseSVGMarkup(),r=0,i=0,s=(this.endAngle-this.startAngle)%(2*n);if(s===0)this.group&&this.group.type==="path-group"&&(r=this.left+this.radius,i=this.top+this.radius),t.push("<circle ",'cx="'+r+'" cy="'+i+'" ','r="',this.radius,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform()," ",this.getSvgTransformMatrix(),'"/>\n');else{var o=Math.cos(this.startAngle)*this.radius,u=Math.sin(this.startAngle)*this.radius,a=Math.cos(this.endAngle)*this.radius,f=Math.sin(this.endAngle)*this.radius,l=s>n?"1":"0";t.push('<path d="M '+o+" "+u," A "+this.radius+" "+this.radius," 0 ",+l+" 1"," "+a+" "+f,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform()," ",this.getSvgTransformMatrix(),'"/>\n')}return e?e(t.join("")):t.join("")},_render:function(e,t){e.beginPath(),e.arc(t?this.left+this.radius:0,t?this.top+this.radius:0,this.radius,this.startAngle,this.endAngle,!1),this._renderFill(e),this._renderStroke(e)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(e){this.radius=e,this.set("width",e*2).set("height",e*2)},complexity:function(){return 1}}),t.Circle.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),t.Circle.fromElement=function(e,n){n||(n={});var s=t.parseAttributes(e,t.Circle.ATTRIBUTE_NAMES);if(!i(s))throw new Error("value of `r` attribute is required and can not be negative");s.left=s.left||0,s.top=s.top||0;var o=new t.Circle(r(s,n));return o.left-=o.radius,o.top-=o.radius,o},t.Circle.fromObject=function(e){return new t.Circle(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={});if(t.Triangle){t.warn("fabric.Triangle is already defined");return}t.Triangle=t.util.createClass(t.Object,{type:"triangle",initialize:function(e){e=e||{},this.callSuper("initialize",e),this.set("width",e.width||100).set("height",e.height||100)},_render:function(e){var t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,n),e.lineTo(0,-n),e.lineTo(t,n),e.closePath(),this._renderFill(e),this._renderStroke(e)},_renderDashedStroke:function(e){var n=this.width/2,r=this.height/2;e.beginPath(),t.util.drawDashedLine(e,-n,r,0,-r,this.strokeDashArray),t.util.drawDashedLine(e,0,-r,n,r,this.strokeDashArray),t.util.drawDashedLine(e,n,r,-n,r,this.strokeDashArray),e.closePath()},toSVG:function(e){var t=this._createBaseSVGMarkup(),n=this.width/2,r=this.height/2,i=[-n+" "+r,"0 "+ -r,n+" "+r].join(",");return t.push("<polygon ",'points="',i,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),'"/>'),e?e(t.join("")):t.join("")},complexity:function(){return 1}}),t.Triangle.fromObject=function(e){return new t.Triangle(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=Math.PI*2,r=t.util.object.extend;if(t.Ellipse){t.warn("fabric.Ellipse is already defined.");return}t.Ellipse=t.util.createClass(t.Object,{type:"ellipse",rx:0,ry:0,initialize:function(e){e=e||{},this.callSuper("initialize",e),this.set("rx",e.rx||0),this.set("ry",e.ry||0)},_set:function(e,t){this.callSuper("_set",e,t);switch(e){case"rx":this.rx=t,this.set("width",t*2);break;case"ry":this.ry=t,this.set("height",t*2)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(e){return r(this.callSuper("toObject",e),{rx:this.get("rx"),ry:this.get("ry")})},toSVG:function(e){var t=this._createBaseSVGMarkup(),n=0,r=0;return this.group&&this.group.type==="path-group"&&(n=this.left+this.rx,r=this.top+this.ry),t.push("<ellipse ",'cx="',n,'" cy="',r,'" ','rx="',this.rx,'" ry="',this.ry,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n'),e?e(t.join("")):t.join("")},_render:function(e,t){e.beginPath(),e.save(),e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(t?this.left+this.rx:0,t?(this.top+this.ry)*this.rx/this.ry:0,this.rx,0,n,!1),e.restore(),this._renderFill(e),this._renderStroke(e)},complexity:function(){return 1}}),t.Ellipse.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),t.Ellipse.fromElement=function(e,n){n||(n={});var i=t.parseAttributes(e,t.Ellipse.ATTRIBUTE_NAMES);i.left=i.left||0,i.top=i.top||0;var s=new t.Ellipse(r(i,n));return s.top-=s.ry,s.left-=s.rx,s},t.Ellipse.fromObject=function(e){return new t.Ellipse(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend;if(t.Rect){console.warn("fabric.Rect is already defined");return}var r=t.Object.prototype.stateProperties.concat();r.push("rx","ry","x","y"),t.Rect=t.util.createClass(t.Object,{stateProperties:r,type:"rect",rx:0,ry:0,strokeDashArray:null,initialize:function(e){e=e||{},this.callSuper("initialize",e),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(e,t){if(this.width===1&&this.height===1){e.fillRect(0,0,1,1);return}var n=this.rx?Math.min(this.rx,this.width/2):0,r=this.ry?Math.min(this.ry,this.height/2):0,i=this.width,s=this.height,o=t?this.left:-this.width/2,u=t?this.top:-this.height/2,a=n!==0||r!==0,f=.4477152502;e.beginPath(),e.moveTo(o+n,u),e.lineTo(o+i-n,u),a&&e.bezierCurveTo(o+i-f*n,u,o+i,u+f*r,o+i,u+r),e.lineTo(o+i,u+s-r),a&&e.bezierCurveTo(o+i,u+s-f*r,o+i-f*n,u+s,o+i-n,u+s),e.lineTo(o+n,u+s),a&&e.bezierCurveTo(o+f*n,u+s,o,u+s-f*r,o,u+s-r),e.lineTo(o,u+r),a&&e.bezierCurveTo(o,u+f*r,o+f*n,u,o+n,u),e.closePath(),this._renderFill(e),this._renderStroke(e)},_renderDashedStroke:function(e){var n=-this.width/2,r=-this.height/2,i=this.width,s=this.height;e.beginPath(),t.util.drawDashedLine(e,n,r,n+i,r,this.strokeDashArray),t.util.drawDashedLine(e,n+i,r,n+i,r+s,this.strokeDashArray),t.util.drawDashedLine(e,n+i,r+s,n,r+s,this.strokeDashArray),t.util.drawDashedLine(e,n,r+s,n,r,this.strokeDashArray),e.closePath()},toObject:function(e){var t=n(this.callSuper("toObject",e),{rx:this.get("rx")||0,ry:this.get("ry")||0});return this.includeDefaultValues||this._removeDefaultValues(t),t},toSVG:function(e){var t=this._createBaseSVGMarkup(),n=this.left,r=this.top;if(!this.group||this.group.type!=="path-group")n=-this.width/2,r=-this.height/2;return t.push("<rect ",'x="',n,'" y="',r,'" rx="',this.get("rx"),'" ry="',this.get("ry"),'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n'),e?e(t.join("")):t.join("")},complexity:function(){return 1}}),t.Rect.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),t.Rect.fromElement=function(e,r){if(!e)return null;r=r||{};var i=t.parseAttributes(e,t.Rect.ATTRIBUTE_NAMES);return i.left=i.left||0,i.top=i.top||0,new t.Rect(n(r?t.util.object.clone(r):{},i))},t.Rect.fromObject=function(e){return new t.Rect(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={});if(t.Polyline){t.warn("fabric.Polyline is already defined");return}t.Polyline=t.util.createClass(t.Object,{type:"polyline",points:null,minX:0,minY:0,initialize:function(e,n){return t.Polygon.prototype.initialize.call(this,e,n)},_calcDimensions:function(){return t.Polygon.prototype._calcDimensions.call(this)},_applyPointOffset:function(){return t.Polygon.prototype._applyPointOffset.call(this)},toObject:function(e){return t.Polygon.prototype.toObject.call(this,e)},toSVG:function(e){return t.Polygon.prototype.toSVG.call(this,e)},_render:function(e){t.Polygon.prototype.commonRender.call(this,e),this._renderFill(e),this._renderStroke(e)},_renderDashedStroke:function(e){var n,r;e.beginPath();for(var i=0,s=this.points.length;i<s;i++)n=this.points[i],r=this.points[i+1]||n,t.util.drawDashedLine(e,n.x,n.y,r.x,r.y,this.strokeDashArray)},complexity:function(){return this.get("points").length}}),t.Polyline.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(),t.Polyline.fromElement=function(e,n){if(!e)return null;n||(n={});var r=t.parsePointsAttribute(e.getAttribute("points")),i=t.parseAttributes(e,t.Polyline.ATTRIBUTE_NAMES);return r===null?null:new t.Polyline(r,t.util.object.extend(i,n))},t.Polyline.fromObject=function(e){var n=e.points;return new t.Polyline(n,e,!0)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.array.min,i=t.util.array.max,s=t.util.toFixed;if(t.Polygon){t.warn("fabric.Polygon is already defined");return}t.Polygon=t.util.createClass(t.Object,{type:"polygon",points:null,minX:0,minY:0,initialize:function(e,t){t=t||{},this.points=e,this.callSuper("initialize",t),this._calcDimensions(),"top"in t||(this.top=this.minY),"left"in t||(this.left=this.minX)},_calcDimensions:function(){var e=this.points,t=r(e,"x"),n=r(e,"y"),s=i(e,"x"),o=i(e,"y");this.width=s-t||1,this.height=o-n||1,this.minX=t,this.minY=n},_applyPointOffset:function(){this.points.forEach(function(e){e.x-=this.minX+this.width/2,e.y-=this.minY+this.height/2},this)},toObject:function(e){return n(this.callSuper("toObject",e),{points:this.points.concat()})},toSVG:function(e){var t=[],n=this._createBaseSVGMarkup();for(var r=0,i=this.points.length;r<i;r++)t.push(s(this.points[r].x,2),",",s(this.points[r].y,2)," ");return n.push("<",this.type," ",'points="',t.join(""),'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform()," ",this.getSvgTransformMatrix(),'"/>\n'),e?e(n.join("")):n.join("")},_render:function(e){this.commonRender(e),this._renderFill(e);if(this.stroke||this.strokeDashArray)e.closePath(),this._renderStroke(e)},commonRender:function(e){var t;e.beginPath(),this._applyPointOffset&&((!this.group||this.group.type!=="path-group")&&this._applyPointOffset(),this._applyPointOffset=null),e.moveTo(this.points[0].x,this.points[0].y);for(var n=0,r=this.points.length;n<r;n++)t=this.points[n],e.lineTo(t.x,t.y)},_renderDashedStroke:function(e){t.Polyline.prototype._renderDashedStroke.call(this,e),e.closePath()},complexity:function(){return this.points.length}}),t.Polygon.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(),t.Polygon.fromElement=function(e,r){if(!e)return null;r||(r={});var i=t.parsePointsAttribute(e.getAttribute("points")),s=t.parseAttributes(e,t.Polygon.ATTRIBUTE_NAMES);return i===null?null:new t.Polygon(i,n(s,r))},t.Polygon.fromObject=function(e){return new t.Polygon(e.points,e,!0)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.array.min,r=t.util.array.max,i=t.util.object.extend,s=Object.prototype.toString,o=t.util.drawArc,u={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},a={m:"l",M:"L"};if(t.Path){t.warn("fabric.Path is already defined");return}t.Path=t.util.createClass(t.Object,{type:"path",path:null,minX:0,minY:0,initialize:function(e,t){t=t||{},this.setOptions(t);if(!e)throw new Error("`path` argument is required");var n=s.call(e)==="[object Array]";this.path=n?e:e.match&&e.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi);if(!this.path)return;n||(this.path=this._parsePath());var r=this._parseDimensions();this.minX=r.left,this.minY=r.top,this.width=r.width,this.height=r.height,r.left+=this.originX==="center"?this.width/2:this.originX==="right"?this.width:0,r.top+=this.originY==="center"?this.height/2:this.originY==="bottom"?this.height:0,this.top=this.top||r.top,this.left=this.left||r.left,this.pathOffset=this.pathOffset||{x:this.minX+this.width/2,y:this.minY+this.height/2},t.sourcePath&&this.setSourcePath(t.sourcePath)},_render:function(e){var t,n=null,r=0,i=0,s=0,u=0,a=0,f=0,l,c,h,p,d=-this.pathOffset.x,v=-this.pathOffset.y;this.group&&this.group.type==="path-group"&&(d=0,v=0),e.beginPath();for(var m=0,g=this.path.length;m<g;++m){t=this.path[m];switch(t[0]){case"l":s+=t[1],u+=t[2],e.lineTo(s+d,u+v);break;case"L":s=t[1],u=t[2],e.lineTo(s+d,u+v);break;case"h":s+=t[1],e.lineTo(s+d,u+v);break;case"H":s=t[1],e.lineTo(s+d,u+v);break;case"v":u+=t[1],e.lineTo(s+d,u+v);break;case"V":u=t[1],e.lineTo(s+d,u+v);break;case"m":s+=t[1],u+=t[2],r=s,i=u,e.moveTo(s+d,u+v);break;case"M":s=t[1],u=t[2],r=s,i=u,e.moveTo(s+d,u+v);break;case"c":l=s+t[5],c=u+t[6],a=s+t[3],f=u+t[4],e.bezierCurveTo(s+t[1]+d,u+t[2]+v,a+d,f+v,l+d,c+v),s=l,u=c;break;case"C":s=t[5],u=t[6],a=t[3],f=t[4],e.bezierCurveTo(t[1]+d,t[2]+v,a+d,f+v,s+d,u+v);break;case"s":l=s+t[3],c=u+t[4],a=a?2*s-a:s,f=f?2*u-f:u,e.bezierCurveTo(a+d,f+v,s+t[1]+d,u+t[2]+v,l+d,c+v),a=s+t[1],f=u+t[2],s=l,u=c;break;case"S":l=t[3],c=t[4],a=2*s-a,f=2*u-f,e.bezierCurveTo(a+d,f+v,t[1]+d,t[2]+v,l+d,c+v),s=l,u=c,a=t[1],f=t[2];break;case"q":l=s+t[3],c=u+t[4],a=s+t[1],f=u+t[2],e.quadraticCurveTo(a+d,f+v,l+d,c+v),s=l,u=c;break;case"Q":l=t[3],c=t[4],e.quadraticCurveTo(t[1]+d,t[2]+v,l+d,c+v),s=l,u=c,a=t[1],f=t[2];break;case"t":l=s+t[1],c=u+t[2],n[0].match(/[QqTt]/)===null?(a=s,f=u):n[0]==="t"?(a=2*s-h,f=2*u-p):n[0]==="q"&&(a=2*s-a,f=2*u-f),h=a,p=f,e.quadraticCurveTo(a+d,f+v,l+d,c+v),s=l,u=c,a=s+t[1],f=u+t[2];break;case"T":l=t[1],c=t[2],a=2*s-a,f=2*u-f,e.quadraticCurveTo(a+d,f+v,l+d,c+v),s=l,u=c;break;case"a":o(e,s+d,u+v,[t[1],t[2],t[3],t[4],t[5],t[6]+s+d,t[7]+u+v]),s+=t[6],u+=t[7];break;case"A":o(e,s+d,u+v,[t[1],t[2],t[3],t[4],t[5],t[6]+d,t[7]+v]),s=t[6],u=t[7];break;case"z":case"Z":s=r,u=i,e.closePath()}n=t}this._renderFill(e),this._renderStroke(e)},render:function(e,n){if(!this.visible)return;e.save(),this._setupCompositeOperation(e),n||this.transform(e),this._setStrokeStyles(e),this._setFillStyles(e),this.group&&this.group.type==="path-group"&&e.translate(-this.group.width/2,-this.group.height/2),this.transformMatrix&&e.transform.apply(e,this.transformMatrix),this._setOpacity(e),this._setShadow(e),this.clipTo&&t.util.clipContext(this,e),this._render(e,n),this.clipTo&&e.restore(),this._removeShadow(e),this._restoreCompositeOperation(e),e.restore()},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(e){var t=i(this.callSuper("toObject",e),{path:this.path.map(function(e){return e.slice()}),pathOffset:this.pathOffset});return this.sourcePath&&(t.sourcePath=this.sourcePath),this.transformMatrix&&(t.transformMatrix=this.transformMatrix),t},toDatalessObject:function(e){var t=this.toObject(e);return this.sourcePath&&(t.path=this.sourcePath),delete t.sourcePath,t},toSVG:function(e){var t=[],n=this._createBaseSVGMarkup(),r="";for(var i=0,s=this.path.length;i<s;i++)t.push(this.path[i].join(" "));var o=t.join(" ");if(!this.group||this.group.type!=="path-group")r="translate("+ -this.pathOffset.x+", "+ -this.pathOffset.y+")";return n.push("<path ",'d="',o,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),r,this.getSvgTransformMatrix(),'" stroke-linecap="round" ',"/>\n"),e?e(n.join("")):n.join("")},complexity:function(){return this.path.length},_parsePath:function(){var e=[],t=[],n,r,i=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/ig,s,o;for(var f=0,l,c=this.path.length;f<c;f++){n=this.path[f],o=n.slice(1).trim(),t.length=0;while(s=i.exec(o))t.push(s[0]);l=[n.charAt(0)];for(var h=0,p=t.length;h<p;h++)r=parseFloat(t[h]),isNaN(r)||l.push(r);var d=l[0],v=u[d.toLowerCase()],m=a[d]||d;if(l.length-1>v)for(var g=1,y=l.length;g<y;g+=v)e.push([d].concat(l.slice(g,g+v))),d=m;else e.push(l)}return e},_parseDimensions:function(){var e=[],i=[],s,o=null,u=0,a=0,f=0,l=0,c=0,h=0,p,d,v,m,g;for(var y=0,b=this.path.length;y<b;++y){s=this.path[y];switch(s[0]){case"l":f+=s[1],l+=s[2],g=[];break;case"L":f=s[1],l=s[2],g=[];break;case"h":f+=s[1],g=[];break;case"H":f=s[1],g=[];break;case"v":l+=s[1],g=[];break;case"V":l=s[1],g=[];break;case"m":f+=s[1],l+=s[2],u=f,a=l,g=[];break;case"M":f=s[1],l=s[2],u=f,a=l,g=[];break;case"c":p=f+s[5],d=l+s[6],c=f+s[3],h=l+s[4],g=t.util.getBoundsOfCurve(f,l,f+s[1],l+s[2],c,h,p,d),f=p,l=d;break;case"C":f=s[5],l=s[6],c=s[3],h=s[4],g=t.util.getBoundsOfCurve(f,l,s[1],s[2],c,h,f,l);break;case"s":p=f+s[3],d=l+s[4],c=c?2*f-c:f,h=h?2*l-h:l,g=t.util.getBoundsOfCurve(f,l,c,h,f+s[1],l+s[2],p,d),c=f+s[1],h=l+s[2],f=p,l=d;break;case"S":p=s[3],d=s[4],c=2*f-c,h=2*l-h,g=t.util.getBoundsOfCurve(f,l,c,h,s[1],s[2],p,d),f=p,l=d,c=s[1],h=s[2];break;case"q":p=f+s[3],d=l+s[4],c=f+s[1],h=l+s[2],g=t.util.getBoundsOfCurve(f,l,c,h,c,h,p,d),f=p,l=d;break;case"Q":c=s[1],h=s[2],g=t.util.getBoundsOfCurve(f,l,c,h,c,h,s[3],s[4]),f=s[3],l=s[4];break;case"t":p=f+s[1],d=l+s[2],o[0].match(/[QqTt]/)===null?(c=f,h=l):o[0]==="t"?(c=2*f-v,h=2*l-m):o[0]==="q"&&(c=2*f-c,h=2*l-h),v=c,m=h,g=t.util.getBoundsOfCurve(f,l,c,h,c,h,p,d),f=p,l=d,c=f+s[1],h=l+s[2];break;case"T":p=s[1],d=s[2],c=2*f-c,h=2*l-h,g=t.util.getBoundsOfCurve(f,l,c,h,c,h,p,d),f=p,l=d;break;case"a":g=t.util.getBoundsOfArc(f,l,s[1],s[2],s[3],s[4],s[5],s[6]+f,s[7]+l),f+=s[6],l+=s[7];break;case"A":g=t.util.getBoundsOfArc(f,l,s[1],s[2],s[3],s[4],s[5],s[6],s[7]),f=s[6],l=s[7];break;case"z":case"Z":f=u,l=a}o=s,g.forEach(function(t){e.push(t.x),i.push(t.y)}),e.push(f),i.push(l)}var w=n(e),E=n(i),S=r(e),x=r(i),T=S-w,N=x-E,C={left:w,top:E,width:T,height:N};return C}}),t.Path.fromObject=function(e,n){typeof e.path=="string"?t.loadSVGFromURL(e.path,function(r){var i=r[0],s=e.path;delete e.path,t.util.object.extend(i,e),i.setSourcePath(s),n(i)}):n(new t.Path(e.path,e))},t.Path.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(["d"]),t.Path.fromElement=function(e,n,r){var s=t.parseAttributes(e,t.Path.ATTRIBUTE_NAMES);n&&n(new t.Path(s.d,i(s,r)))},t.Path.async=!0}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.array.invoke,i=t.Object.prototype.toObject;if(t.PathGroup){t.warn("fabric.PathGroup is already defined");return}t.PathGroup=t.util.createClass(t.Path,{type:"path-group",fill:"",initialize:function(e,t){t=t||{},this.paths=e||[];for(var n=this.paths.length;n--;)this.paths[n].group=this;this.setOptions(t),t.widthAttr&&(this.scaleX=t.widthAttr/t.width),t.heightAttr&&(this.scaleY=t.heightAttr/t.height),this.setCoords(),t.sourcePath&&this.setSourcePath(t.sourcePath)},render:function(e){if(!this.visible)return;e.save();var n=this.transformMatrix;n&&e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this.transform(e),this._setShadow(e),this.clipTo&&t.util.clipContext(this,e);for(var r=0,i=this.paths.length;r<i;++r)this.paths[r].render(e,!0);this.clipTo&&e.restore(),this._removeShadow(e),e.restore()},_set:function(e,t){if(e==="fill"&&t&&this.isSameColor()){var n=this.paths.length;while(n--)this.paths[n]._set(e,t)}return this.callSuper("_set",e,t)},toObject:function(e){var t=n(i.call(this,e),{paths:r(this.getObjects(),"toObject",e)});return this.sourcePath&&(t.sourcePath=this.sourcePath),t},toDatalessObject:function(e){var t=this.toObject(e);return this.sourcePath&&(t.paths=this.sourcePath),t},toSVG:function(e){var t=this.getObjects(),n="translate("+this.left+" "+this.top+")",r=["<g ",'style="',this.getSvgStyles(),'" ','transform="',n,this.getSvgTransform(),'" ',">\n"];for(var i=0,s=t.length;i<s;i++)r.push(t[i].toSVG(e));return r.push("</g>\n"),e?e(r.join("")):r.join("")},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},isSameColor:function(){var e=(this.getObjects()[0].get("fill")||"").toLowerCase();return this.getObjects().every(function(t){return(t.get("fill")||"").toLowerCase()===e})},complexity:function(){return this.paths.reduce(function(e,t){return e+(t&&t.complexity?t.complexity():0)},0)},getObjects:function(){return this.paths}}),t.PathGroup.fromObject=function(e,n){typeof e.paths=="string"?t.loadSVGFromURL(e.paths,function(r){var i=e.paths;delete e.paths;var s=t.util.groupSVGElements(r,e,i);n(s)}):t.util.enlivenObjects(e.paths,function(r){delete e.paths,n(new t.PathGroup(r,e))})},t.PathGroup.async=!0}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.array.min,i=t.util.array.max,s=t.util.array.invoke;if(t.Group)return;var o={lockMovementX:!0,lockMovementY:!0,lockRotation:!0,lockScalingX:!0,lockScalingY:!0,lockUniScaling:!0};t.Group=t.util.createClass(t.Object,t.Collection,{type:"group",initialize:function(e,t){t=t||{},this._objects=e||[];for(var n=this._objects.length;n--;)this._objects[n].group=this;this.originalState={},this.callSuper("initialize"),t.originX&&(this.originX=t.originX),t.originY&&(this.originY=t.originY),this._calcBounds(),this._updateObjectsCoords(),this.callSuper("initialize",t),this.setCoords(),this.saveCoords()},_updateObjectsCoords:function(){this.forEachObject(this._updateObjectCoords,this)},_updateObjectCoords:function(e){var t=e.getLeft(),n=e.getTop(),r=this.getCenterPoint();e.set({originalLeft:t,originalTop:n,left:t-r.x,top:n-r.y}),e.setCoords(),e.__origHasControls=e.hasControls,e.hasControls=!1},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(e){return this._restoreObjectsState(),e&&(this._objects.push(e),e.group=this),this.forEachObject(this._setObjectActive,this),this._calcBounds(),this._updateObjectsCoords(),this},_setObjectActive:function(e){e.set("active",!0),e.group=this},removeWithUpdate:function(e){return this._moveFlippedObject(e),this._restoreObjectsState(),this.forEachObject(this._setObjectActive,this),this.remove(e),this._calcBounds(),this._updateObjectsCoords(),this},_onObjectAdded:function(e){e.group=this},_onObjectRemoved:function(e){delete e.group,e.set("active",!1)},delegatedProperties:{fill:!0,opacity:!0,fontFamily:!0,fontWeight:!0,fontSize:!0,fontStyle:!0,lineHeight:!0,textDecoration:!0,textAlign:!0,backgroundColor:!0},_set:function(e,t){if(e in this.delegatedProperties){var n=this._objects.length;while(n--)this._objects[n].set(e,t)}this.callSuper("_set",e,t)},toObject:function(e){return n(this.callSuper("toObject",e),{objects:s(this._objects,"toObject",e)})},render:function(e){if(!this.visible)return;e.save(),this.clipTo&&t.util.clipContext(this,e);for(var n=0,r=this._objects.length;n<r;n++)this._renderObject(this._objects[n],e);this.clipTo&&e.restore(),e.restore()},_renderControls:function(e,t){this.callSuper("_renderControls",e,t);for(var n=0,r=this._objects.length;n<r;n++)this._objects[n]._renderControls(e)},_renderObject:function(e,t){var n=e.hasRotatingPoint;if(!e.visible)return;e.hasRotatingPoint=!1,e.render(t),e.hasRotatingPoint=n},_restoreObjectsState:function(){return this._objects.forEach(this._restoreObjectState,this),this},_moveFlippedObject:function(e){var t=e.get("originX"),n=e.get("originY"),r=e.getCenterPoint();e.set({originX:"center",originY:"center",left:r.x,top:r.y}),this._toggleFlipping(e);var i=e.getPointByOrigin(t,n);return e.set({originX:t,originY:n,left:i.x,top:i.y}),this},_toggleFlipping:function(e){this.flipX&&(e.toggle("flipX"),e.set("left",-e.get("left")),e.setAngle(-e.getAngle())),this.flipY&&(e.toggle("flipY"),e.set("top",-e.get("top")),e.setAngle(-e.getAngle()))},_restoreObjectState:function(e){return this._setObjectPosition(e),e.setCoords(),e.hasControls=e.__origHasControls,delete e.__origHasControls,e.set("active",!1),e.setCoords(),delete e.group,this},_setObjectPosition:function(e){var t=this.getCenterPoint(),n=this._getRotatedLeftTop(e);e.set({angle:e.getAngle()+this.getAngle(),left:t.x+n.left,top:t.y+n.top,scaleX:e.get("scaleX")*this.get("scaleX"),scaleY:e.get("scaleY")*this.get("scaleY")})},_getRotatedLeftTop:function(e){var t=this.getAngle()*(Math.PI/180);return{left:-Math.sin(t)*e.getTop()*this.get("scaleY")+Math.cos(t)*e.getLeft()*this.get("scaleX"),top:Math.cos(t)*e.getTop()*this.get("scaleY")+Math.sin(t)*e.getLeft()*this.get("scaleX")}},destroy:function(){return this._objects.forEach(this._moveFlippedObject,this),this._restoreObjectsState()},saveCoords:function(){return this._originalLeft=this.get("left"),this._originalTop=this.get("top"),this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){return this.forEachObject(function(e){e.setCoords()}),this},_calcBounds:function(e){var t=[],n=[],r;for(var i=0,s=this._objects.length;i<s;++i){r=this._objects[i],r.setCoords();for(var o in r.oCoords)t.push(r.oCoords[o].x),n.push(r.oCoords[o].y)}this.set(this._getBounds(t,n,e))},_getBounds:function(e,n,s){var o=t.util.invertTransform(this.getViewportTransform()),u=t.util.transformPoint(new t.Point(r(e),r(n)),o),a=t.util.transformPoint(new t.Point(i(e),i(n)),o),f={width:a.x-u.x||0,height:a.y-u.y||0};return s||(f.left=u.x||0,f.top=u.y||0,this.originX==="center"&&(f.left+=f.width/2),this.originX==="right"&&(f.left+=f.width),this.originY==="center"&&(f.top+=f.height/2),this.originY==="bottom"&&(f.top+=f.height)),f},toSVG:function(e){var t=["<g ",'transform="',this.getSvgTransform(),'">\n'];for(var n=0,r=this._objects.length;n<r;n++)t.push(this._objects[n].toSVG(e));return t.push("</g>\n"),e?e(t.join("")):t.join("")},get:function(e){if(e in o){if(this[e])return this[e];for(var t=0,n=this._objects.length;t<n;t++)if(this._objects[t][e])return!0;return!1}return e in this.delegatedProperties?this._objects[0]&&this._objects[0].get(e):this[e]}}),t.Group.fromObject=function(e,n){t.util.enlivenObjects(e.objects,function(r){delete e.objects,n&&n(new t.Group(r,e))})},t.Group.async=!0}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=fabric.util.object.extend;e.fabric||(e.fabric={});if(e.fabric.Image){fabric.warn("fabric.Image is already defined.");return}fabric.Image=fabric.util.createClass(fabric.Object,{type:"image",crossOrigin:"",alignX:"none",alignY:"none",meetOrSlice:"meet",_lastScaleX:1,_lastScaleY:1,initialize:function(e,t){t||(t={}),this.filters=[],this.resizeFilters=[],this.callSuper("initialize",t),this._initElement(e,t),this._initConfig(t),t.filters&&(this.filters=t.filters,this.applyFilters())},getElement:function(){return this._element},setElement:function(e,t,n){return this._element=e,this._originalElement=e,this._initConfig(n),this.filters.length!==0?this.applyFilters(t):t&&t(),this},setCrossOrigin:function(e){return this.crossOrigin=e,this._element.crossOrigin=e,this},getOriginalSize:function(){var e=this.getElement();return{width:e.width,height:e.height}},_stroke:function(e){e.save(),this._setStrokeStyles(e),e.beginPath(),e.strokeRect(-this.width/2,-this.height/2,this.width,this.height),e.closePath(),e.restore()},_renderDashedStroke:function(e){var t=-this.width/2,n=-this.height/2,r=this.width,i=this.height;e.save(),this._setStrokeStyles(e),e.beginPath(),fabric.util.drawDashedLine(e,t,n,t+r,n,this.strokeDashArray),fabric.util.drawDashedLine(e,t+r,n,t+r,n+i,this.strokeDashArray),fabric.util.drawDashedLine(e,t+r,n+i,t,n+i,this.strokeDashArray),fabric.util.drawDashedLine(e,t,n+i,t,n,this.strokeDashArray),e.closePath(),e.restore()},toObject:function(e){return t(this.callSuper("toObject",e),{src:this._originalElement.src||this._originalElement._src,filters:this.filters.map(function(e){return e&&e.toObject()}),crossOrigin:this.crossOrigin,alignX:this.alignX,alignY:this.alignY,meetOrSlice:this.meetOrSlice})},toSVG:function(e){var t=[],n=-this.width/2,r=-this.height/2,i="none";this.group&&this.group.type==="path-group"&&(n=this.left,r=this.top),this.alignX!=="none"&&this.alignY!=="none"&&(i="x"+this.alignX+"Y"+this.alignY+" "+this.meetOrSlice),t.push('<g transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'">\n','<image xlink:href="',this.getSvgSrc(),'" x="',n,'" y="',r,'" style="',this.getSvgStyles(),'" width="',this.width,'" height="',this.height,'" preserveAspectRatio="',i,'"',"></image>\n");if(this.stroke||this.strokeDashArray){var s=this.fill;this.fill=null,t.push("<rect ",'x="',n,'" y="',r,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'"/>\n'),this.fill=s}return t.push("</g>\n"),e?e(t.join("")):t.join("")},getSrc:function(){if(this.getElement())return this.getElement().src||this.getElement()._src},setSrc:function(e,t,n){fabric.util.loadImage(e,function(e){return this.setElement(e,t,n)},this,n&&n.crossOrigin)},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(e,t){this.constructor.fromObject(this.toObject(t),e)},applyFilters:function(e,t,n,r){t=t||this.filters,n=n||this._originalElement;if(!n)return;var i=n,s=fabric.util.createCanvasElement(),o=fabric.util.createImage(),u=this;return s.width=i.width,s.height=i.height,s.getContext("2d").drawImage(i,0,0,i.width,i.height),t.length===0?(this._element=n,e&&e(),s):(t.forEach(function(e){e&&e.applyTo(s,e.scaleX||u.scaleX,e.scaleY||u.scaleY),!r&&e.type==="Resize"&&(u.width*=e.scaleX,u.height*=e.scaleY)}),o.width=s.width,o.height=s.height,fabric.isLikelyNode?(o.src=s.toBuffer(undefined,fabric.Image.pngCompression),u._element=o,!r&&(u._filteredEl=o),e&&e()):(o.onload=function(){u._element=o,!r&&(u._filteredEl=o),e&&e(),o.onload=s=i=null},o.src=s.toDataURL("image/png")),s)},_render:function(e,t){var n,r,i=this._findMargins(),s;n=t?this.left:-this.width/2,r=t?this.top:-this.height/2,this.meetOrSlice==="slice"&&(e.beginPath(),e.rect(n,r,this.width,this.height),e.clip()),this.isMoving===!1&&this.resizeFilters.length&&this._needsResize()?(this._lastScaleX=this.scaleX,this._lastScaleY=this.scaleY,s=this.applyFilters(null,this.resizeFilters,this._filteredEl||this._originalElement,!0)):s=this._element,s&&e.drawImage(s,n+i.marginX,r+i.marginY,i.width,i.height),this._renderStroke(e)},_needsResize:function(){return this.scaleX!==this._lastScaleX||this.scaleY!==this._lastScaleY},_findMargins:function(){var e=this.width,t=this.height,n,r,i=0,s=0;if(this.alignX!=="none"||this.alignY!=="none")n=[this.width/this._element.width,this.height/this._element.height],r=this.meetOrSlice==="meet"?Math.min.apply(null,n):Math.max.apply(null,n),e=this._element.width*r,t=this._element.height*r,this.alignX==="Mid"&&(i=(this.width-e)/2),this.alignX==="Max"&&(i=this.width-e),this.alignY==="Mid"&&(s=(this.height-t)/2),this.alignY==="Max"&&(s=this.height-t);return{width:e,height:t,marginX:i,marginY:s}},_resetWidthHeight:function(){var e=this.getElement();this.set("width",e.width),this.set("height",e.height)},_initElement:function(e){this.setElement(fabric.util.getById(e)),fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(e){e||(e={}),this.setOptions(e),this._setWidthHeight(e),this._element&&this.crossOrigin&&(this._element.crossOrigin=this.crossOrigin)},_initFilters:function(e,t){e.filters&&e.filters.length?fabric.util.enlivenObjects(e.filters,function(e){t&&t(e)},"fabric.Image.filters" +):t&&t()},_setWidthHeight:function(e){this.width="width"in e?e.width:this.getElement()?this.getElement().width||0:0,this.height="height"in e?e.height:this.getElement()?this.getElement().height||0:0},complexity:function(){return 1}}),fabric.Image.CSS_CANVAS="canvas-img",fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc,fabric.Image.fromObject=function(e,t){fabric.util.loadImage(e.src,function(n){fabric.Image.prototype._initFilters.call(e,e,function(r){e.filters=r||[];var i=new fabric.Image(n,e);t&&t(i)})},null,e.crossOrigin)},fabric.Image.fromURL=function(e,t,n){fabric.util.loadImage(e,function(e){t(new fabric.Image(e,n))},null,n&&n.crossOrigin)},fabric.Image.ATTRIBUTE_NAMES=fabric.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href".split(" ")),fabric.Image.fromElement=function(e,n,r){var i=fabric.parseAttributes(e,fabric.Image.ATTRIBUTE_NAMES),s="xMidYMid",o="meet",u,a,f;i.preserveAspectRatio&&(f=i.preserveAspectRatio.split(" ")),f&&f.length&&(o=f.pop(),o!=="meet"&&o!=="slice"?(s=o,o="meet"):f.length&&(s=f.pop())),u=s!=="none"?s.slice(1,4):"none",a=s!=="none"?s.slice(5,8):"none",i.alignX=u,i.alignY=a,i.meetOrSlice=o,fabric.Image.fromURL(i["xlink:href"],n,t(r?fabric.util.object.clone(r):{},i))},fabric.Image.async=!0,fabric.Image.pngCompression=1}(typeof exports!="undefined"?exports:this),fabric.util.object.extend(fabric.Object.prototype,{_getAngleValueForStraighten:function(){var e=this.getAngle()%360;return e>0?Math.round((e-1)/90)*90:Math.round(e/90)*90},straighten:function(){return this.setAngle(this._getAngleValueForStraighten()),this},fxStraighten:function(e){e=e||{};var t=function(){},n=e.onComplete||t,r=e.onChange||t,i=this;return fabric.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(e){i.setAngle(e),r()},onComplete:function(){i.setCoords(),n()},onStart:function(){i.set("active",!1)}}),this}}),fabric.util.object.extend(fabric.StaticCanvas.prototype,{straightenObject:function(e){return e.straighten(),this.renderAll(),this},fxStraightenObject:function(e){return e.fxStraighten({onChange:this.renderAll.bind(this)}),this}}),fabric.Image.filters=fabric.Image.filters||{},fabric.Image.filters.BaseFilter=fabric.util.createClass({type:"BaseFilter",initialize:function(e){e&&this.setOptions(e)},setOptions:function(e){for(var t in e)this[t]=e[t]},toObject:function(){return{type:this.type}},toJSON:function(){return this.toObject()}}),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend;t.Image.filters.Brightness=t.util.createClass(t.Image.filters.BaseFilter,{type:"Brightness",initialize:function(e){e=e||{},this.brightness=e.brightness||0},applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=this.brightness;for(var s=0,o=r.length;s<o;s+=4)r[s]+=i,r[s+1]+=i,r[s+2]+=i;t.putImageData(n,0,0)},toObject:function(){return n(this.callSuper("toObject"),{brightness:this.brightness})}}),t.Image.filters.Brightness.fromObject=function(e){return new t.Image.filters.Brightness(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend;t.Image.filters.Convolute=t.util.createClass(t.Image.filters.BaseFilter,{type:"Convolute",initialize:function(e){e=e||{},this.opaque=e.opaque,this.matrix=e.matrix||[0,0,0,0,1,0,0,0,0];var n=t.util.createCanvasElement();this.tmpCtx=n.getContext("2d")},_createImageData:function(e,t){return this.tmpCtx.createImageData(e,t)},applyTo:function(e){var t=this.matrix,n=e.getContext("2d"),r=n.getImageData(0,0,e.width,e.height),i=Math.round(Math.sqrt(t.length)),s=Math.floor(i/2),o=r.data,u=r.width,a=r.height,f=u,l=a,c=this._createImageData(f,l),h=c.data,p=this.opaque?1:0;for(var d=0;d<l;d++)for(var v=0;v<f;v++){var m=d,g=v,y=(d*f+v)*4,b=0,w=0,E=0,S=0;for(var x=0;x<i;x++)for(var T=0;T<i;T++){var N=m+x-s,C=g+T-s;if(N<0||N>a||C<0||C>u)continue;var k=(N*u+C)*4,L=t[x*i+T];b+=o[k]*L,w+=o[k+1]*L,E+=o[k+2]*L,S+=o[k+3]*L}h[y]=b,h[y+1]=w,h[y+2]=E,h[y+3]=S+p*(255-S)}n.putImageData(c,0,0)},toObject:function(){return n(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),t.Image.filters.Convolute.fromObject=function(e){return new t.Image.filters.Convolute(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend;t.Image.filters.GradientTransparency=t.util.createClass(t.Image.filters.BaseFilter,{type:"GradientTransparency",initialize:function(e){e=e||{},this.threshold=e.threshold||100},applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=this.threshold,s=r.length;for(var o=0,u=r.length;o<u;o+=4)r[o+3]=i+255*(s-o)/s;t.putImageData(n,0,0)},toObject:function(){return n(this.callSuper("toObject"),{threshold:this.threshold})}}),t.Image.filters.GradientTransparency.fromObject=function(e){return new t.Image.filters.GradientTransparency(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={});t.Image.filters.Grayscale=t.util.createClass(t.Image.filters.BaseFilter,{type:"Grayscale",applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=n.width*n.height*4,s=0,o;while(s<i)o=(r[s]+r[s+1]+r[s+2])/3,r[s]=o,r[s+1]=o,r[s+2]=o,s+=4;t.putImageData(n,0,0)}}),t.Image.filters.Grayscale.fromObject=function(){return new t.Image.filters.Grayscale}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={});t.Image.filters.Invert=t.util.createClass(t.Image.filters.BaseFilter,{type:"Invert",applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=r.length,s;for(s=0;s<i;s+=4)r[s]=255-r[s],r[s+1]=255-r[s+1],r[s+2]=255-r[s+2];t.putImageData(n,0,0)}}),t.Image.filters.Invert.fromObject=function(){return new t.Image.filters.Invert}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend;t.Image.filters.Mask=t.util.createClass(t.Image.filters.BaseFilter,{type:"Mask",initialize:function(e){e=e||{},this.mask=e.mask,this.channel=[0,1,2,3].indexOf(e.channel)>-1?e.channel:0},applyTo:function(e){if(!this.mask)return;var n=e.getContext("2d"),r=n.getImageData(0,0,e.width,e.height),i=r.data,s=this.mask.getElement(),o=t.util.createCanvasElement(),u=this.channel,a,f=r.width*r.height*4;o.width=s.width,o.height=s.height,o.getContext("2d").drawImage(s,0,0,s.width,s.height);var l=o.getContext("2d").getImageData(0,0,s.width,s.height),c=l.data;for(a=0;a<f;a+=4)i[a+3]=c[a+u];n.putImageData(r,0,0)},toObject:function(){return n(this.callSuper("toObject"),{mask:this.mask.toObject(),channel:this.channel})}}),t.Image.filters.Mask.fromObject=function(e,n){t.util.loadImage(e.mask.src,function(r){e.mask=new t.Image(r,e.mask),n&&n(new t.Image.filters.Mask(e))})},t.Image.filters.Mask.async=!0}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend;t.Image.filters.Noise=t.util.createClass(t.Image.filters.BaseFilter,{type:"Noise",initialize:function(e){e=e||{},this.noise=e.noise||0},applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=this.noise,s;for(var o=0,u=r.length;o<u;o+=4)s=(.5-Math.random())*i,r[o]+=s,r[o+1]+=s,r[o+2]+=s;t.putImageData(n,0,0)},toObject:function(){return n(this.callSuper("toObject"),{noise:this.noise})}}),t.Image.filters.Noise.fromObject=function(e){return new t.Image.filters.Noise(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend;t.Image.filters.Pixelate=t.util.createClass(t.Image.filters.BaseFilter,{type:"Pixelate",initialize:function(e){e=e||{},this.blocksize=e.blocksize||4},applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=n.height,s=n.width,o,u,a,f,l,c,h;for(u=0;u<i;u+=this.blocksize)for(a=0;a<s;a+=this.blocksize){o=u*4*s+a*4,f=r[o],l=r[o+1],c=r[o+2],h=r[o+3];for(var p=u,d=u+this.blocksize;p<d;p++)for(var v=a,m=a+this.blocksize;v<m;v++)o=p*4*s+v*4,r[o]=f,r[o+1]=l,r[o+2]=c,r[o+3]=h}t.putImageData(n,0,0)},toObject:function(){return n(this.callSuper("toObject"),{blocksize:this.blocksize})}}),t.Image.filters.Pixelate.fromObject=function(e){return new t.Image.filters.Pixelate(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend;t.Image.filters.RemoveWhite=t.util.createClass(t.Image.filters.BaseFilter,{type:"RemoveWhite",initialize:function(e){e=e||{},this.threshold=e.threshold||30,this.distance=e.distance||20},applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=this.threshold,s=this.distance,o=255-i,u=Math.abs,a,f,l;for(var c=0,h=r.length;c<h;c+=4)a=r[c],f=r[c+1],l=r[c+2],a>o&&f>o&&l>o&&u(a-f)<s&&u(a-l)<s&&u(f-l)<s&&(r[c+3]=1);t.putImageData(n,0,0)},toObject:function(){return n(this.callSuper("toObject"),{threshold:this.threshold,distance:this.distance})}}),t.Image.filters.RemoveWhite.fromObject=function(e){return new t.Image.filters.RemoveWhite(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={});t.Image.filters.Sepia=t.util.createClass(t.Image.filters.BaseFilter,{type:"Sepia",applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=r.length,s,o;for(s=0;s<i;s+=4)o=.3*r[s]+.59*r[s+1]+.11*r[s+2],r[s]=o+100,r[s+1]=o+50,r[s+2]=o+255;t.putImageData(n,0,0)}}),t.Image.filters.Sepia.fromObject=function(){return new t.Image.filters.Sepia}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={});t.Image.filters.Sepia2=t.util.createClass(t.Image.filters.BaseFilter,{type:"Sepia2",applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=r.length,s,o,u,a;for(s=0;s<i;s+=4)o=r[s],u=r[s+1],a=r[s+2],r[s]=(o*.393+u*.769+a*.189)/1.351,r[s+1]=(o*.349+u*.686+a*.168)/1.203,r[s+2]=(o*.272+u*.534+a*.131)/2.14;t.putImageData(n,0,0)}}),t.Image.filters.Sepia2.fromObject=function(){return new t.Image.filters.Sepia2}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend;t.Image.filters.Tint=t.util.createClass(t.Image.filters.BaseFilter,{type:"Tint",initialize:function(e){e=e||{},this.color=e.color||"#000000",this.opacity=typeof e.opacity!="undefined"?e.opacity:(new t.Color(this.color)).getAlpha()},applyTo:function(e){var n=e.getContext("2d"),r=n.getImageData(0,0,e.width,e.height),i=r.data,s=i.length,o,u,a,f,l,c,h,p,d;d=(new t.Color(this.color)).getSource(),u=d[0]*this.opacity,a=d[1]*this.opacity,f=d[2]*this.opacity,p=1-this.opacity;for(o=0;o<s;o+=4)l=i[o],c=i[o+1],h=i[o+2],i[o]=u+l*p,i[o+1]=a+c*p,i[o+2]=f+h*p;n.putImageData(r,0,0)},toObject:function(){return n(this.callSuper("toObject"),{color:this.color,opacity:this.opacity})}}),t.Image.filters.Tint.fromObject=function(e){return new t.Image.filters.Tint(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend;t.Image.filters.Multiply=t.util.createClass(t.Image.filters.BaseFilter,{type:"Multiply",initialize:function(e){e=e||{},this.color=e.color||"#000000"},applyTo:function(e){var n=e.getContext("2d"),r=n.getImageData(0,0,e.width,e.height),i=r.data,s=i.length,o,u;u=(new t.Color(this.color)).getSource();for(o=0;o<s;o+=4)i[o]*=u[0]/255,i[o+1]*=u[1]/255,i[o+2]*=u[2]/255;n.putImageData(r,0,0)},toObject:function(){return n(this.callSuper("toObject"),{color:this.color})}}),t.Image.filters.Multiply.fromObject=function(e){return new t.Image.filters.Multiply(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric;t.Image.filters.Blend=t.util.createClass({type:"Blend",initialize:function(e){e=e||{},this.color=e.color||"#000",this.image=e.image||!1,this.mode=e.mode||"multiply",this.alpha=e.alpha||1},applyTo:function(e){var n=e.getContext("2d"),r=n.getImageData(0,0,e.width,e.height),i=r.data,s,o,u,a,f,l,c,h=!1;if(this.image){h=!0;var p=t.util.createCanvasElement();p.width=this.image.width,p.height=this.image.height;var d=new t.StaticCanvas(p);d.add(this.image);var v=d.getContext("2d");c=v.getImageData(0,0,d.width,d.height).data}else c=(new t.Color(this.color)).getSource(),s=c[0]*this.alpha,o=c[1]*this.alpha,u=c[2]*this.alpha;for(var m=0,g=i.length;m<g;m+=4){a=i[m],f=i[m+1],l=i[m+2],h&&(s=c[m]*this.alpha,o=c[m+1]*this.alpha,u=c[m+2]*this.alpha);switch(this.mode){case"multiply":i[m]=a*s/255,i[m+1]=f*o/255,i[m+2]=l*u/255;break;case"screen":i[m]=1-(1-a)*(1-s),i[m+1]=1-(1-f)*(1-o),i[m+2]=1-(1-l)*(1-u);break;case"add":i[m]=Math.min(255,a+s),i[m+1]=Math.min(255,f+o),i[m+2]=Math.min(255,l+u);break;case"diff":case"difference":i[m]=Math.abs(a-s),i[m+1]=Math.abs(f-o),i[m+2]=Math.abs(l-u);break;case"subtract":var y=a-s,b=f-o,w=l-u;i[m]=y<0?0:y,i[m+1]=b<0?0:b,i[m+2]=w<0?0:w;break;case"darken":i[m]=Math.min(a,s),i[m+1]=Math.min(f,o),i[m+2]=Math.min(l,u);break;case"lighten":i[m]=Math.max(a,s),i[m+1]=Math.max(f,o),i[m+2]=Math.max(l,u)}}n.putImageData(r,0,0)},toObject:function(){return{color:this.color,image:this.image,mode:this.mode,alpha:this.alpha}}}),t.Image.filters.Blend.fromObject=function(e){return new t.Image.filters.Blend(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=Math.pow,r=Math.floor,i=Math.sqrt,s=Math.abs,o=Math.max,u=Math.round,a=Math.sin,f=Math.ceil;t.Image.filters.Resize=t.util.createClass(t.Image.filters.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:0,scaleY:0,lanczosLobes:3,applyTo:function(e,t,n){this.rcpScaleX=1/t,this.rcpScaleY=1/n;var r=e.width,i=e.height,s=u(r*t),o=u(i*n),a;this.resizeType==="sliceHack"&&(a=this.sliceByTwo(e,r,i,s,o)),this.resizeType==="hermite"&&(a=this.hermiteFastResize(e,r,i,s,o)),this.resizeType==="bilinear"&&(a=this.bilinearFiltering(e,r,i,s,o)),this.resizeType==="lanczos"&&(a=this.lanczosResize(e,r,i,s,o)),e.width=s,e.height=o,e.getContext("2d").putImageData(a,0,0)},sliceByTwo:function(e,n,i,s,u){var a=e.getContext("2d"),f,l=.5,c=.5,h=1,p=1,d=!1,v=!1,m=n,g=i,y=t.util.createCanvasElement(),b=y.getContext("2d");s=r(s),u=r(u),y.width=o(s,n),y.height=o(u,i),s>n&&(l=2,h=-1),u>i&&(c=2,p=-1),f=a.getImageData(0,0,n,i),e.width=o(s,n),e.height=o(u,i),a.putImageData(f,0,0);while(!d||!v)n=m,i=g,s*h<r(m*l*h)?m=r(m*l):(m=s,d=!0),u*p<r(g*c*p)?g=r(g*c):(g=u,v=!0),f=a.getImageData(0,0,n,i),b.putImageData(f,0,0),a.clearRect(0,0,m,g),a.drawImage(y,0,0,n,i,0,0,m,g);return a.getImageData(0,0,s,u)},lanczosResize:function(e,t,o,u,l){function c(e){return function(t){if(t>e)return 0;t*=Math.PI;if(s(t)<1e-16)return 1;var n=t/e;return a(t)*a(n)/t/n}}function h(e){var a,f,c,p,d,L,A,O,M,_,D;C.x=(e+.5)*b,k.x=r(C.x);for(a=0;a<l;a++){C.y=(a+.5)*w,k.y=r(C.y),d=0,L=0,A=0,O=0,M=0;for(f=k.x-x;f<=k.x+x;f++){if(f<0||f>=t)continue;_=r(1e3*s(f-C.x)),N[_]||(N[_]={});for(var P=k.y-T;P<=k.y+T;P++){if(P<0||P>=o)continue;D=r(1e3*s(P-C.y)),N[_][D]||(N[_][D]=y(i(n(_*E,2)+n(D*S,2))/1e3)),c=N[_][D],c>0&&(p=(P*t+f)*4,d+=c,L+=c*m[p],A+=c*m[p+1],O+=c*m[p+2],M+=c*m[p+3])}}p=(a*u+e)*4,g[p]=L/d,g[p+1]=A/d,g[p+2]=O/d,g[p+3]=M/d}return++e<u?h(e):v}var p=e.getContext("2d"),d=p.getImageData(0,0,t,o),v=p.getImageData(0,0,u,l),m=d.data,g=v.data,y=c(this.lanczosLobes),b=this.rcpScaleX,w=this.rcpScaleY,E=2/this.rcpScaleX,S=2/this.rcpScaleY,x=f(b*this.lanczosLobes/2),T=f(w*this.lanczosLobes/2),N={},C={},k={};return h(0)},bilinearFiltering:function(e,t,n,i,s){var o,u,a,f,l,c,h,p,d,v,m,g,y=0,b,w=this.rcpScaleX,E=this.rcpScaleY,S=e.getContext("2d"),x=4*(t-1),T=S.getImageData(0,0,t,n),N=T.data,C=S.getImageData(0,0,i,s),k=C.data;for(h=0;h<s;h++)for(p=0;p<i;p++){l=r(w*p),c=r(E*h),d=w*p-l,v=E*h-c,b=4*(c*t+l);for(m=0;m<4;m++)o=N[b+m],u=N[b+4+m],a=N[b+x+m],f=N[b+x+4+m],g=o*(1-d)*(1-v)+u*d*(1-v)+a*v*(1-d)+f*d*v,k[y++]=g}return C},hermiteFastResize:function(e,t,n,o,u){var a=this.rcpScaleX,l=this.rcpScaleY,c=f(a/2),h=f(l/2),p=e.getContext("2d"),d=p.getImageData(0,0,t,n),v=d.data,m=p.getImageData(0,0,o,u),g=m.data;for(var y=0;y<u;y++)for(var b=0;b<o;b++){var w=(b+y*o)*4,E=0,S=0,x=0,T=0,N=0,C=0,k=0,L=(y+.5)*l;for(var A=r(y*l);A<(y+1)*l;A++){var O=s(L-(A+.5))/h,M=(b+.5)*a,_=O*O;for(var D=r(b*a);D<(b+1)*a;D++){var P=s(M-(D+.5))/c,H=i(_+P*P);if(H>1&&H<-1)continue;E=2*H*H*H-3*H*H+1,E>0&&(P=4*(D+A*t),k+=E*v[P+3],x+=E,v[P+3]<255&&(E=E*v[P+3]/250),T+=E*v[P],N+=E*v[P+1],C+=E*v[P+2],S+=E)}}g[w]=T/S,g[w+1]=N/S,g[w+2]=C/S,g[w+3]=k/x}return m}}),t.Image.filters.Resize.fromObject=function(){return new t.Image.filters.Resize}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.object.clone,i=t.util.toFixed,s=t.StaticCanvas.supports("setLineDash");if(t.Text){t.warn("fabric.Text is already defined");return}var o=t.Object.prototype.stateProperties.concat();o.push("fontFamily","fontWeight","fontSize","text","textDecoration","textAlign","fontStyle","lineHeight","textBackgroundColor","useNative","path"),t.Text=t.util.createClass(t.Object,{_dimensionAffectingProps:{fontSize:!0,fontWeight:!0,fontFamily:!0,textDecoration:!0,fontStyle:!0,lineHeight:!0,stroke:!0,strokeWidth:!0,text:!0},_reNewline:/\r?\n/,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",textDecoration:"",textAlign:"left",fontStyle:"",lineHeight:1.3,textBackgroundColor:"",path:null,useNative:!0,stateProperties:o,stroke:null,shadow:null,initialize:function(e,t){t=t||{},this.text=e,this.__skipDimension=!0,this.setOptions(t),this.__skipDimension=!1,this._initDimensions()},_initDimensions:function(){if(this.__skipDimension)return;var e=t.util.createCanvasElement();this._render(e.getContext("2d"))},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_render:function(e){typeof Cufon=="undefined"||this.useNative===!0?this._renderViaNative(e):this._renderViaCufon(e)},_renderViaNative:function(e){var n=this.text.split(this._reNewline);this._setTextStyles(e),this.width=this._getTextWidth(e,n),this.height=this._getTextHeight(e,n),this.clipTo&&t.util.clipContext(this,e),this._renderTextBackground(e,n),this._translateForTextAlign(e),this._renderText(e,n),this.textAlign!=="left"&&this.textAlign!=="justify"&&e.restore(),this._renderTextDecoration(e,n),this.clipTo&&e.restore(),this._setBoundaries(e,n),this._totalLineHeight=0},_renderText:function(e,t){e.save(),this._setOpacity(e),this._setShadow(e),this._setupCompositeOperation(e),this._renderTextFill(e,t),this._renderTextStroke(e,t),this._restoreCompositeOperation(e),this._removeShadow(e),e.restore()},_translateForTextAlign:function(e){this.textAlign!=="left"&&this.textAlign!=="justify"&&(e.save(),e.translate(this.textAlign==="center"?this.width/2:this.width,0))},_setBoundaries:function(e,t){this._boundaries=[];for(var n=0,r=t.length;n<r;n++){var i=this._getLineWidth(e,t[n]),s=this._getLineLeftOffset(i);this._boundaries.push({height:this.fontSize*this.lineHeight,width:i,left:s})}},_setTextStyles:function(e){this._setFillStyles(e),this._setStrokeStyles(e),e.textBaseline="alphabetic",this.skipTextAlign||(e.textAlign=this.textAlign),e.font=this._getFontDeclaration()},_getTextHeight:function(e,t){return this.fontSize*t.length*this.lineHeight},_getTextWidth:function(e,t){var n=e.measureText(t[0]||"|").width;for(var r=1,i=t.length;r<i;r++){var s=e.measureText(t[r]).width;s>n&&(n=s)}return n},_renderChars:function(e,t,n,r,i){t[e](n,r,i)},_renderTextLine:function(e,t,n,r,i,s){i-=this.fontSize/4;if(this.textAlign!=="justify"){this._renderChars(e,t,n,r,i,s);return}var o=t.measureText(n).width,u=this.width;if(u>o){var a=n.split(/\s+/),f=t.measureText(n.replace(/\s+/g,"")).width,l=u-f,c=a.length-1,h=l/c,p=0;for(var d=0,v=a.length;d<v;d++)this._renderChars(e,t,a[d],r+p,i,s),p+=t.measureText(a[d]).width+h}else this._renderChars(e,t,n,r,i,s)},_getLeftOffset:function(){return-this.width/2},_getTopOffset:function(){return-this.height/2},_renderTextFill:function(e,t){if(!this.fill&&!this._skipFillStrokeCheck)return;this._boundaries=[];var n=0;for(var r=0,i=t.length;r<i;r++){var s=this._getHeightOfLine(e,r,t);n+=s,this._renderTextLine("fillText",e,t[r],this._getLeftOffset(),this._getTopOffset()+n,r)}this.shadow&&!this.shadow.affectStroke&&this._removeShadow(e)},_renderTextStroke:function(e,t){if((!this.stroke||this.strokeWidth===0)&&!this._skipFillStrokeCheck)return;var n=0;e.save(),this.strokeDashArray&&(1&this.strokeDashArray.length&&this.strokeDashArray.push.apply(this.strokeDashArray,this.strokeDashArray),s&&e.setLineDash(this.strokeDashArray)),e.beginPath();for(var r=0,i=t.length;r<i;r++){var o=this._getHeightOfLine(e,r,t);n+=o,this._renderTextLine("strokeText",e,t[r],this._getLeftOffset(),this._getTopOffset()+n,r)}e.closePath(),e.restore()},_getHeightOfLine:function(){return this.fontSize*this.lineHeight},_renderTextBackground:function(e,t){this._renderTextBoxBackground(e),this._renderTextLinesBackground(e,t)},_renderTextBoxBackground:function(e){if(!this.backgroundColor)return;e.save(),e.fillStyle=this.backgroundColor,e.fillRect(this._getLeftOffset(),this._getTopOffset(),this.width,this.height),e.restore()},_renderTextLinesBackground:function(e,t){if(!this.textBackgroundColor)return;e.save(),e.fillStyle=this.textBackgroundColor;for(var n=0,r=t.length;n<r;n++)if(t[n]!==""){var i=this._getLineWidth(e,t[n]),s=this._getLineLeftOffset(i);e.fillRect(this._getLeftOffset()+s,this._getTopOffset()+n*this.fontSize*this.lineHeight,i,this.fontSize*this.lineHeight)}e.restore()},_getLineLeftOffset:function(e){return this.textAlign==="center"?(this.width-e)/2:this.textAlign==="right"?this.width-e:0},_getLineWidth:function(e,t){return this.textAlign==="justify"?this.width:e.measureText(t).width},_renderTextDecoration:function(e,t){function i(i){for(var s=0,o=t.length;s<o;s++){var u=r._getLineWidth(e,t[s]),a=r._getLineLeftOffset(u);e.fillRect(r._getLeftOffset()+a,~~(i+s*r._getHeightOfLine(e,s,t)-n),u,1)}}if(!this.textDecoration)return;var n=this._getTextHeight(e,t)/2,r=this;this.textDecoration.indexOf("underline")>-1&&i(this.fontSize*this.lineHeight),this.textDecoration.indexOf("line-through")>-1&&i(this.fontSize*this.lineHeight-this.fontSize/2),this.textDecoration.indexOf("overline")>-1&&i(this.fontSize*this.lineHeight-this.fontSize)},_getFontDeclaration:function(){return[t.isLikelyNode?this.fontWeight:this.fontStyle,t.isLikelyNode?this.fontStyle:this.fontWeight,this.fontSize+"px",t.isLikelyNode?'"'+this.fontFamily+'"':this.fontFamily].join(" ")},render:function(e,t){if(!this.visible)return;e.save(),t||this.transform(e);var n=this.group&&this.group.type==="path-group";n&&e.translate(-this.group.width/2,-this.group.height/2),this.transformMatrix&&e.transform.apply(e,this.transformMatrix),n&&e.translate(this.left,this.top),this._render(e),e.restore()},toObject:function(e){var t=n(this.callSuper("toObject",e),{text:this.text,fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily,fontStyle:this.fontStyle,lineHeight:this.lineHeight,textDecoration:this.textDecoration,textAlign:this.textAlign,path:this.path,textBackgroundColor:this.textBackgroundColor,useNative:this.useNative});return this.includeDefaultValues||this._removeDefaultValues(t),t},toSVG:function(e){var t=[],n=this.text.split(this._reNewline),r=this._getSVGLeftTopOffsets(n),i=this._getSVGTextAndBg(r.lineTop,r.textLeft,n),s=this._getSVGShadows(r.lineTop,n);return r.textTop+=this._fontAscent?this._fontAscent/5*this.lineHeight:0,this._wrapSVGTextAndBg(t,i,s,r),e?e(t.join("")):t.join("")},_getSVGLeftTopOffsets:function(e){var t=this.useNative?this.fontSize*this.lineHeight:-this._fontAscent-this._fontAscent/5*this.lineHeight,n=-(this.width/2),r=this.useNative?this.fontSize*this.lineHeight-.25*this.fontSize:this.height/2-e.length*this.fontSize-this._totalLineHeight;return{textLeft:n+(this.group&&this.group.type==="path-group"?this.left:0),textTop:r+(this.group&&this.group.type==="path-group"?this.top:0),lineTop:t}},_wrapSVGTextAndBg:function(e,t,n,r){e.push('<g transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'">\n',t.textBgRects.join(""),"<text ",this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",this.textDecoration?'text-decoration="'+this.textDecoration+'" ':"",'style="',this.getSvgStyles(),'" ','transform="translate(',i(r.textLeft,2)," ",i(r.textTop,2),')">',n.join(""),t.textSpans.join(""),"</text>\n","</g>\n")},_getSVGShadows:function(e,n){var r=[],s,o,u=1;if(!this.shadow||!this._boundaries)return r;for(s=0,o=n.length;s<o;s++)if(n[s]!==""){var a=this._boundaries&&this._boundaries[s]?this._boundaries[s].left:0;r.push('<tspan x="',i(a+u+this.shadow.offsetX,2),s===0||this.useNative?'" y':'" dy','="',i(this.useNative?e*s-this.height/2+this.shadow.offsetY:e+(s===0?this.shadow.offsetY:0),2),'" ',this._getFillAttributes(this.shadow.color),">",t.util.string.escapeXml(n[s]),"</tspan>"),u=1}else u++;return r},_getSVGTextAndBg:function(e,t,n){var r=[],i=[],s=1;this._setSVGBg(i);for(var o=0,u=n.length;o<u;o++){n[o]!==""?(this._setSVGTextLineText(n[o],o,r,e,s,i),s=1):s++;if(!this.textBackgroundColor||!this._boundaries)continue;this._setSVGTextLineBg(i,o,t,e)}return{textSpans:r,textBgRects:i}},_setSVGTextLineText:function(e,n,r,s,o){var u=this._boundaries&&this._boundaries[n]?i(this._boundaries[n].left,2):0;r.push('<tspan x="',u,'" ',n===0||this.useNative?"y":"dy",'="',i(this.useNative?s*n-this.height/2:s*o,2),'" ',this._getFillAttributes(this.fill),">",t.util.string.escapeXml(e),"</tspan>")},_setSVGTextLineBg:function(e,t,n,r){e.push("<rect ",this._getFillAttributes(this.textBackgroundColor),' x="',i(n+this._boundaries[t].left,2),'" y="',i(r*t-this.height/2,2),'" width="',i(this._boundaries[t].width,2),'" height="',i(this._boundaries[t].height,2),'"></rect>\n')},_setSVGBg:function(e){this.backgroundColor&&this._boundaries&&e.push("<rect ",this._getFillAttributes(this.backgroundColor),' x="',i(-this.width/2,2),'" y="',i(-this.height/2,2),'" width="',i(this.width,2),'" height="',i(this.height,2),'"></rect>')},_getFillAttributes:function(e){var n=e&&typeof e=="string"?new t.Color(e):"";return!n||!n.getSource()||n.getAlpha()===1?'fill="'+e+'"':'opacity="'+n.getAlpha()+'" fill="'+n.setAlpha(1).toRgb()+'"'},_set:function(e,t){e==="fontFamily"&&this.path&&(this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+t+"$3")),this.callSuper("_set",e,t),e in this._dimensionAffectingProps&&(this._initDimensions(),this.setCoords())},complexity:function(){return 1}}),t.Text.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size text-decoration text-anchor".split(" ")),t.Text.DEFAULT_SVG_FONT_SIZE=16,t.Text.fromElement=function(e,n){if(!e)return null;var r=t.parseAttributes(e,t.Text.ATTRIBUTE_NAMES);n=t.util.object.extend(n?t.util.object.clone(n):{},r),n.top=n.top||0,n.left=n.left||0,"dx"in r&&(n.left+=r.dx),"dy"in r&&(n.top+=r.dy),"fontSize"in n||(n.fontSize=t.Text.DEFAULT_SVG_FONT_SIZE),n.originX||(n.originX="left"),n.top+=n.fontSize/4;var i=new t.Text(e.textContent,n),s=0;return i.originX==="left"&&(s=i.getWidth()/2),i.originX==="right"&&(s=-i.getWidth()/2),i.set({left:i.getLeft()+s,top:i.getTop()-i.getHeight()/2}),i},t.Text.fromObject=function(e){return new t.Text(e.text,r(e))},t.util.createAccessors(t.Text)}(typeof exports!="undefined"?exports:this),function(){var e=fabric.util.object.clone;fabric.IText=fabric.util.createClass(fabric.Text,fabric.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"#333",cursorDelay:1e3,cursorDuration:600,styles:null,caching:!0,_skipFillStrokeCheck:!0,_reSpace:/\s|\n/,_fontSizeFraction:4,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,_charWidthsCache:{},initialize:function(e,t){this.styles=t?t.styles||{}:{},this.callSuper("initialize",e,t),this.initBehavior(),fabric.IText.instances.push(this),this.__lineWidths={},this.__lineHeights={},this.__lineOffsets={}},isEmptyStyles:function(){if(!this.styles)return!0;var e=this.styles;for(var t in e)for(var n in e[t])for(var r in e[t][n])return!1;return!0},setSelectionStart:function(e){this.selectionStart!==e&&(this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})),this.selectionStart=e,this.hiddenTextarea&&(this.hiddenTextarea.selectionStart=e)},setSelectionEnd:function(e){this.selectionEnd!==e&&(this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})),this.selectionEnd=e,this.hiddenTextarea&&(this.hiddenTextarea.selectionEnd=e)},getSelectionStyles:function(e,t){if(arguments.length===2){var n=[];for(var r=e;r<t;r++)n.push(this.getSelectionStyles(r));return n}var i=this.get2DCursorLocation(e);return this.styles[i.lineIndex]?this.styles[i.lineIndex][i.charIndex]||{}:{}},setSelectionStyles:function(e){if(this.selectionStart===this.selectionEnd)this._extendStyles(this.selectionStart,e);else for(var t=this.selectionStart;t<this.selectionEnd;t++)this._extendStyles(t,e);return this},_extendStyles:function(e,t){var n=this.get2DCursorLocation(e);this.styles[n.lineIndex]||(this.styles[n.lineIndex]={}),this.styles[n.lineIndex][n.charIndex]||(this.styles[n.lineIndex][n.charIndex]={}),fabric.util.object.extend(this.styles[n.lineIndex][n.charIndex],t)},_render:function(e){this.callSuper("_render",e),this.ctx=e,this.isEditing&&this.renderCursorOrSelection()},renderCursorOrSelection:function(){if(!this.active)return;var e=this.text.split(""),t;this.selectionStart===this.selectionEnd?(t=this._getCursorBoundaries(e,"cursor"),this.renderCursor(t)):(t=this._getCursorBoundaries(e,"selection"),this.renderSelection(e,t))},get2DCursorLocation:function(e){typeof e=="undefined"&&(e=this.selectionStart);var t=this.text.slice(0,e),n=t.split(this._reNewline);return{lineIndex:n.length-1,charIndex:n[n.length-1].length}},getCurrentCharStyle:function(e,t){var n=this.styles[e]&&this.styles[e][t===0?0:t-1];return{fontSize:n&&n.fontSize||this.fontSize,fill:n&&n.fill||this.fill,textBackgroundColor:n&&n.textBackgroundColor||this.textBackgroundColor,textDecoration:n&&n.textDecoration||this.textDecoration,fontFamily:n&&n.fontFamily||this.fontFamily,fontWeight:n&&n.fontWeight||this.fontWeight,fontStyle:n&&n.fontStyle||this.fontStyle,stroke:n&&n.stroke||this.stroke,strokeWidth:n&&n.strokeWidth||this.strokeWidth}},getCurrentCharFontSize:function(e,t){return this.styles[e]&&this.styles[e][t===0?0:t-1]&&this.styles[e][t===0?0:t-1].fontSize||this.fontSize},getCurrentCharColor:function(e,t){return this.styles[e]&&this.styles[e][t===0?0:t-1]&&this.styles[e][t===0?0:t-1].fill||this.cursorColor},_getCursorBoundaries:function(e,t){var n=this.get2DCursorLocation(),r=this.text.split(this._reNewline),i=Math.round(this._getLeftOffset()),s=this._getTopOffset(),o=this._getCursorBoundariesOffsets(e,t,n,r);return{left:i,top:s,leftOffset:o.left+o.lineLeft,topOffset:o.top}},_getCursorBoundariesOffsets:function(e,t,n,r){var i=0,s=0,o=0,u=0,a=t==="cursor"?this._getHeightOfLine(this.ctx,0)-this.getCurrentCharFontSize(n.lineIndex,n.charIndex):0;for(var f=0;f<this.selectionStart;f++){if(e[f]==="\n"){u=0;var l=s+(t==="cursor"?1:0);a+=this._getCachedLineHeight(l),s++,o=0}else u+=this._getWidthOfChar(this.ctx,e[f],s,o),o++;i=this._getCachedLineOffset(s,r)}return this._clearCache(),{top:a,left:u,lineLeft:i}},_clearCache:function(){this.__lineWidths={},this.__lineHeights={},this.__lineOffsets={}},_getCachedLineHeight:function(e){return this.__lineHeights[e]||(this.__lineHeights[e]=this._getHeightOfLine(this.ctx,e))},_getCachedLineWidth:function(e,t){return this.__lineWidths[e]||(this.__lineWidths[e]=this._getWidthOfLine(this.ctx,e,t))},_getCachedLineOffset:function(e,t){var n=this._getCachedLineWidth(e,t);return this.__lineOffsets[e]||(this.__lineOffsets[e]=this._getLineLeftOffset(n))},renderCursor:function(e){var t=this.ctx;t.save();var n=this.get2DCursorLocation(),r=n.lineIndex,i=n.charIndex,s=this.getCurrentCharFontSize(r,i),o=r===0&&i===0?this._getCachedLineOffset(r,this.text.split(this._reNewline)):e.leftOffset;t.fillStyle=this.getCurrentCharColor(r,i),t.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,t.fillRect(e.left+o,e.top+e.topOffset,this.cursorWidth/this.scaleX,s),t.restore()},renderSelection:function(e,t){var n=this.ctx;n.save(),n.fillStyle=this.selectionColor;var r=this.get2DCursorLocation(this.selectionStart +),i=this.get2DCursorLocation(this.selectionEnd),s=r.lineIndex,o=i.lineIndex,u=this.text.split(this._reNewline);for(var a=s;a<=o;a++){var f=this._getCachedLineOffset(a,u)||0,l=this._getCachedLineHeight(a),c=0;if(a===s)for(var h=0,p=u[a].length;h<p;h++)h>=r.charIndex&&(a!==o||h<i.charIndex)&&(c+=this._getWidthOfChar(n,u[a][h],a,h)),h<r.charIndex&&(f+=this._getWidthOfChar(n,u[a][h],a,h));else if(a>s&&a<o)c+=this._getCachedLineWidth(a,u)||5;else if(a===o)for(var d=0,v=i.charIndex;d<v;d++)c+=this._getWidthOfChar(n,u[a][d],a,d);n.fillRect(t.left+f,t.top+t.topOffset,c,l),t.topOffset+=l}n.restore()},_renderChars:function(e,t,n,r,i,s){if(this.isEmptyStyles())return this._renderCharsFast(e,t,n,r,i);this.skipTextAlign=!0,r-=this.textAlign==="center"?this.width/2:this.textAlign==="right"?this.width:0;var o=this.text.split(this._reNewline),u=this._getWidthOfLine(t,s,o),a=this._getHeightOfLine(t,s,o),f=this._getLineLeftOffset(u),l=n.split(""),c,h="";r+=f||0,t.save();for(var p=0,d=l.length;p<=d;p++){c=c||this.getCurrentCharStyle(s,p);var v=this.getCurrentCharStyle(s,p+1);if(this._hasStyleChanged(c,v)||p===d)this._renderChar(e,t,s,p-1,h,r,i,a),h="",c=v;h+=l[p]}t.restore()},_renderCharsFast:function(e,t,n,r,i){this.skipTextAlign=!1,e==="fillText"&&this.fill&&this.callSuper("_renderChars",e,t,n,r,i),e==="strokeText"&&this.stroke&&this.callSuper("_renderChars",e,t,n,r,i)},_renderChar:function(e,t,n,r,i,s,o,u){var a,f,l;if(this.styles&&this.styles[n]&&(a=this.styles[n][r])){var c=a.stroke||this.stroke,h=a.fill||this.fill;t.save(),f=this._applyCharStylesGetWidth(t,i,n,r,a),l=this._getHeightOfChar(t,i,n,r),h&&t.fillText(i,s,o),c&&t.strokeText(i,s,o),this._renderCharDecoration(t,a,s,o,f,u,l),t.restore(),t.translate(f,0)}else e==="strokeText"&&this.stroke&&t[e](i,s,o),e==="fillText"&&this.fill&&t[e](i,s,o),f=this._applyCharStylesGetWidth(t,i,n,r),this._renderCharDecoration(t,null,s,o,f,u),t.translate(t.measureText(i).width,0)},_hasStyleChanged:function(e,t){return e.fill!==t.fill||e.fontSize!==t.fontSize||e.textBackgroundColor!==t.textBackgroundColor||e.textDecoration!==t.textDecoration||e.fontFamily!==t.fontFamily||e.fontWeight!==t.fontWeight||e.fontStyle!==t.fontStyle||e.stroke!==t.stroke||e.strokeWidth!==t.strokeWidth},_renderCharDecoration:function(e,t,n,r,i,s,o){var u=t?t.textDecoration||this.textDecoration:this.textDecoration,a=(t?t.fontSize:null)||this.fontSize;if(!u)return;u.indexOf("underline")>-1&&this._renderCharDecorationAtOffset(e,n,r+this.fontSize/this._fontSizeFraction,i,0,this.fontSize/20),u.indexOf("line-through")>-1&&this._renderCharDecorationAtOffset(e,n,r+this.fontSize/this._fontSizeFraction,i,o/2,a/20),u.indexOf("overline")>-1&&this._renderCharDecorationAtOffset(e,n,r,i,s-this.fontSize/this._fontSizeFraction,this.fontSize/20)},_renderCharDecorationAtOffset:function(e,t,n,r,i,s){e.fillRect(t,n-i,r,s)},_renderTextLine:function(e,t,n,r,i,s){i+=this.fontSize/4,this.callSuper("_renderTextLine",e,t,n,r,i,s)},_renderTextDecoration:function(e,t){if(this.isEmptyStyles())return this.callSuper("_renderTextDecoration",e,t)},_renderTextLinesBackground:function(e,t){if(!this.textBackgroundColor&&!this.styles)return;e.save(),this.textBackgroundColor&&(e.fillStyle=this.textBackgroundColor);var n=0,r=this.fontSize/this._fontSizeFraction;for(var i=0,s=t.length;i<s;i++){var o=this._getHeightOfLine(e,i,t);if(t[i]===""){n+=o;continue}var u=this._getWidthOfLine(e,i,t),a=this._getLineLeftOffset(u);this.textBackgroundColor&&(e.fillStyle=this.textBackgroundColor,e.fillRect(this._getLeftOffset()+a,this._getTopOffset()+n+r,u,o));if(this.styles[i])for(var f=0,l=t[i].length;f<l;f++)if(this.styles[i]&&this.styles[i][f]&&this.styles[i][f].textBackgroundColor){var c=t[i][f];e.fillStyle=this.styles[i][f].textBackgroundColor,e.fillRect(this._getLeftOffset()+a+this._getWidthOfCharsAt(e,i,f,t),this._getTopOffset()+n+r,this._getWidthOfChar(e,c,i,f,t)+1,o)}n+=o}e.restore()},_getCacheProp:function(e,t){return e+t.fontFamily+t.fontSize+t.fontWeight+t.fontStyle+t.shadow},_applyCharStylesGetWidth:function(t,n,r,i,s){var o=s||this.styles[r]&&this.styles[r][i];o?o=e(o):o={},this._applyFontStyles(o);var u=this._getCacheProp(n,o);if(this.isEmptyStyles()&&this._charWidthsCache[u]&&this.caching)return this._charWidthsCache[u];typeof o.shadow=="string"&&(o.shadow=new fabric.Shadow(o.shadow));var a=o.fill||this.fill;return t.fillStyle=a.toLive?a.toLive(t):a,o.stroke&&(t.strokeStyle=o.stroke&&o.stroke.toLive?o.stroke.toLive(t):o.stroke),t.lineWidth=o.strokeWidth||this.strokeWidth,t.font=this._getFontDeclaration.call(o),this._setShadow.call(o,t),this.caching?(this._charWidthsCache[u]||(this._charWidthsCache[u]=t.measureText(n).width),this._charWidthsCache[u]):t.measureText(n).width},_applyFontStyles:function(e){e.fontFamily||(e.fontFamily=this.fontFamily),e.fontSize||(e.fontSize=this.fontSize),e.fontWeight||(e.fontWeight=this.fontWeight),e.fontStyle||(e.fontStyle=this.fontStyle)},_getStyleDeclaration:function(t,n){return this.styles[t]&&this.styles[t][n]?e(this.styles[t][n]):{}},_getWidthOfChar:function(e,t,n,r){if(this.textAlign==="justify"&&/\s/.test(t))return this._getWidthOfSpace(e,n);var i=this._getStyleDeclaration(n,r);this._applyFontStyles(i);var s=this._getCacheProp(t,i);if(this._charWidthsCache[s]&&this.caching)return this._charWidthsCache[s];if(e){e.save();var o=this._applyCharStylesGetWidth(e,t,n,r);return e.restore(),o}},_getHeightOfChar:function(e,t,n,r){return this.styles[n]&&this.styles[n][r]?this.styles[n][r].fontSize||this.fontSize:this.fontSize},_getWidthOfCharAt:function(e,t,n,r){r=r||this.text.split(this._reNewline);var i=r[t].split("")[n];return this._getWidthOfChar(e,i,t,n)},_getHeightOfCharAt:function(e,t,n,r){r=r||this.text.split(this._reNewline);var i=r[t].split("")[n];return this._getHeightOfChar(e,i,t,n)},_getWidthOfCharsAt:function(e,t,n,r){var i=0;for(var s=0;s<n;s++)i+=this._getWidthOfCharAt(e,t,s,r);return i},_getWidthOfLine:function(e,t,n){return this._getWidthOfCharsAt(e,t,n[t].length,n)},_getWidthOfSpace:function(e,t){var n=this.text.split(this._reNewline),r=n[t],i=r.split(/\s+/),s=this._getWidthOfWords(e,r,t),o=this.width-s,u=i.length-1,a=o/u;return a},_getWidthOfWords:function(e,t,n){var r=0;for(var i=0;i<t.length;i++){var s=t[i];s.match(/\s/)||(r+=this._getWidthOfChar(e,s,n,i))}return r},_getTextWidth:function(e,t){if(this.isEmptyStyles())return this.callSuper("_getTextWidth",e,t);var n=this._getWidthOfLine(e,0,t);for(var r=1,i=t.length;r<i;r++){var s=this._getWidthOfLine(e,r,t);s>n&&(n=s)}return n},_getHeightOfLine:function(e,t,n){n=n||this.text.split(this._reNewline);var r=this._getHeightOfChar(e,n[t][0],t,0),i=n[t],s=i.split("");for(var o=1,u=s.length;o<u;o++){var a=this._getHeightOfChar(e,s[o],t,o);a>r&&(r=a)}return r*this.lineHeight},_getTextHeight:function(e,t){var n=0;for(var r=0,i=t.length;r<i;r++)n+=this._getHeightOfLine(e,r,t);return n},_getTopOffset:function(){var e=fabric.Text.prototype._getTopOffset.call(this);return e-this.fontSize/this._fontSizeFraction},_renderTextBoxBackground:function(e){if(!this.backgroundColor)return;e.save(),e.fillStyle=this.backgroundColor,e.fillRect(this._getLeftOffset(),this._getTopOffset()+this.fontSize/this._fontSizeFraction,this.width,this.height),e.restore()},toObject:function(t){return fabric.util.object.extend(this.callSuper("toObject",t),{styles:e(this.styles)})}}),fabric.IText.fromObject=function(t){return new fabric.IText(t.text,e(t))},fabric.IText.instances=[]}(),function(){var e=fabric.util.object.clone;fabric.util.object.extend(fabric.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation()},initSelectedHandler:function(){this.on("selected",function(){var e=this;setTimeout(function(){e.selected=!0},100)})},initAddedHandler:function(){this.on("added",function(){this.canvas&&!this.canvas._hasITextHandlers&&(this.canvas._hasITextHandlers=!0,this._initCanvasHandlers())})},_initCanvasHandlers:function(){this.canvas.on("selection:cleared",function(){fabric.IText.prototype.exitEditingOnOthers.call()}),this.canvas.on("mouse:up",function(){fabric.IText.instances.forEach(function(e){e.__isMousedown=!1})}),this.canvas.on("object:selected",function(e){fabric.IText.prototype.exitEditingOnOthers.call(e.target)})},_tick:function(){if(this._abortCursorAnimation)return;var e=this;this.animate("_currentCursorOpacity",1,{duration:this.cursorDuration,onComplete:function(){e._onTickComplete()},onChange:function(){e.canvas&&e.canvas.renderAll()},abort:function(){return e._abortCursorAnimation}})},_onTickComplete:function(){if(this._abortCursorAnimation)return;var e=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout(function(){e.animate("_currentCursorOpacity",0,{duration:this.cursorDuration/2,onComplete:function(){e._tick()},onChange:function(){e.canvas&&e.canvas.renderAll()},abort:function(){return e._abortCursorAnimation}})},100)},initDelayedCursor:function(e){var t=this,n=e?0:this.cursorDelay;e&&(this._abortCursorAnimation=!0,clearTimeout(this._cursorTimeout1),this._currentCursorOpacity=1,this.canvas&&this.canvas.renderAll()),this._cursorTimeout2&&clearTimeout(this._cursorTimeout2),this._cursorTimeout2=setTimeout(function(){t._abortCursorAnimation=!1,t._tick()},n)},abortCursorAnimation:function(){this._abortCursorAnimation=!0,clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,this.canvas&&this.canvas.renderAll();var e=this;setTimeout(function(){e._abortCursorAnimation=!1},10)},selectAll:function(){this.selectionStart=0,this.selectionEnd=this.text.length,this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},getSelectedText:function(){return this.text.slice(this.selectionStart,this.selectionEnd)},findWordBoundaryLeft:function(e){var t=0,n=e-1;if(this._reSpace.test(this.text.charAt(n)))while(this._reSpace.test(this.text.charAt(n)))t++,n--;while(/\S/.test(this.text.charAt(n))&&n>-1)t++,n--;return e-t},findWordBoundaryRight:function(e){var t=0,n=e;if(this._reSpace.test(this.text.charAt(n)))while(this._reSpace.test(this.text.charAt(n)))t++,n++;while(/\S/.test(this.text.charAt(n))&&n<this.text.length)t++,n++;return e+t},findLineBoundaryLeft:function(e){var t=0,n=e-1;while(!/\n/.test(this.text.charAt(n))&&n>-1)t++,n--;return e-t},findLineBoundaryRight:function(e){var t=0,n=e;while(!/\n/.test(this.text.charAt(n))&&n<this.text.length)t++,n++;return e+t},getNumNewLinesInSelectedText:function(){var e=this.getSelectedText(),t=0;for(var n=0,r=e.split(""),i=r.length;n<i;n++)r[n]==="\n"&&t++;return t},searchWordBoundary:function(e,t){var n=this._reSpace.test(this.text.charAt(e))?e-1:e,r=this.text.charAt(n),i=/[ \n\.,;!\?\-]/;while(!i.test(r)&&n>0&&n<this.text.length)n+=t,r=this.text.charAt(n);return i.test(r)&&r!=="\n"&&(n+=t===1?0:1),n},selectWord:function(e){var t=this.searchWordBoundary(e,-1),n=this.searchWordBoundary(e,1);this.setSelectionStart(t),this.setSelectionEnd(n),this.initDelayedCursor(!0)},selectLine:function(e){var t=this.findLineBoundaryLeft(e),n=this.findLineBoundaryRight(e);this.setSelectionStart(t),this.setSelectionEnd(n),this.initDelayedCursor(!0)},enterEditing:function(){if(this.isEditing||!this.editable)return;return this.exitEditingOnOthers(),this.isEditing=!0,this.initHiddenTextarea(),this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._tick(),this.canvas&&this.canvas.renderAll(),this.fire("editing:entered"),this.canvas&&this.canvas.fire("text:editing:entered",{target:this}),this},exitEditingOnOthers:function(){fabric.IText.instances.forEach(function(e){e.selected=!1,e.isEditing&&e.exitEditing()},this)},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},_updateTextarea:function(){if(!this.hiddenTextarea)return;this.hiddenTextarea.value=this.text,this.hiddenTextarea.selectionStart=this.selectionStart},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){if(!this._savedProps)return;this.hoverCursor=this._savedProps.overCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor)},exitEditing:function(){return this.selected=!1,this.isEditing=!1,this.selectable=!0,this.selectionEnd=this.selectionStart,this.hiddenTextarea&&this.canvas&&this.hiddenTextarea.parentNode.removeChild(this.hiddenTextarea),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this.fire("editing:exited"),this.canvas&&this.canvas.fire("text:editing:exited",{target:this}),this},_removeExtraneousStyles:function(){var e=this.text.split(this._reNewline);for(var t in this.styles)e[t]||delete this.styles[t]},_removeCharsFromTo:function(e,t){var n=t;while(n!==e){var r=this.get2DCursorLocation(n).charIndex;n--;var i=this.get2DCursorLocation(n).charIndex,s=i>r;s?this.removeStyleObject(s,n+1):this.removeStyleObject(this.get2DCursorLocation(n).charIndex===0,n)}this.text=this.text.slice(0,e)+this.text.slice(t)},insertChars:function(e){var t=this.text.slice(this.selectionStart,this.selectionStart+1)==="\n";this.text=this.text.slice(0,this.selectionStart)+e+this.text.slice(this.selectionEnd),this.selectionStart===this.selectionEnd&&this.insertStyleObjects(e,t,this.copiedStyles),this.selectionStart+=e.length,this.selectionEnd=this.selectionStart,this.canvas&&this.canvas.renderAll().renderAll(),this.setCoords(),this.fire("changed"),this.canvas&&this.canvas.fire("text:changed",{target:this})},insertNewlineStyleObject:function(t,n,r){this.shiftLineStyles(t,1),this.styles[t+1]||(this.styles[t+1]={});var i=this.styles[t][n-1],s={};if(r)s[0]=e(i),this.styles[t+1]=s;else{for(var o in this.styles[t])parseInt(o,10)>=n&&(s[parseInt(o,10)-n]=this.styles[t][o],delete this.styles[t][o]);this.styles[t+1]=s}},insertCharStyleObject:function(t,n,r){var i=this.styles[t],s=e(i);n===0&&!r&&(n=1);for(var o in s){var u=parseInt(o,10);u>=n&&(i[u+1]=s[u])}this.styles[t][n]=r||e(i[n-1])},insertStyleObjects:function(e,t,n){var r=this.get2DCursorLocation(),i=r.lineIndex,s=r.charIndex;this.styles[i]||(this.styles[i]={}),e==="\n"?this.insertNewlineStyleObject(i,s,t):n?this._insertStyles(n):this.insertCharStyleObject(i,s)},_insertStyles:function(e){for(var t=0,n=e.length;t<n;t++){var r=this.get2DCursorLocation(this.selectionStart+t),i=r.lineIndex,s=r.charIndex;this.insertCharStyleObject(i,s,e[t])}},shiftLineStyles:function(t,n){var r=e(this.styles);for(var i in this.styles){var s=parseInt(i,10);s>t&&(this.styles[s+n]=r[s])}},removeStyleObject:function(t,n){var r=this.get2DCursorLocation(n),i=r.lineIndex,s=r.charIndex;if(t){var o=this.text.split(this._reNewline),u=o[i-1],a=u?u.length:0;this.styles[i-1]||(this.styles[i-1]={});for(s in this.styles[i])this.styles[i-1][parseInt(s,10)+a]=this.styles[i][s];this.shiftLineStyles(i,-1)}else{var f=this.styles[i];if(f){var l=this.selectionStart===this.selectionEnd?-1:0;delete f[s+l]}var c=e(f);for(var h in c){var p=parseInt(h,10);p>=s&&p!==0&&(f[p-1]=c[p],delete f[p])}}},insertNewline:function(){this.insertChars("\n")}})}(),fabric.util.object.extend(fabric.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+(new Date),this.__lastLastClickTime=+(new Date),this.__lastPointer={},this.on("mousedown",this.onMouseDown.bind(this))},onMouseDown:function(e){this.__newClickTime=+(new Date);var t=this.canvas.getPointer(e.e);this.isTripleClick(t)?(this.fire("tripleclick",e),this._stopEvent(e.e)):this.isDoubleClick(t)&&(this.fire("dblclick",e),this._stopEvent(e.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=t,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected},isDoubleClick:function(e){return this.__newClickTime-this.__lastClickTime<500&&this.__lastPointer.x===e.x&&this.__lastPointer.y===e.y&&this.__lastIsEditing},isTripleClick:function(e){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===e.x&&this.__lastPointer.y===e.y},_stopEvent:function(e){e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation()},initCursorSelectionHandlers:function(){this.initSelectedHandler(),this.initMousedownHandler(),this.initMousemoveHandler(),this.initMouseupHandler(),this.initClicks()},initClicks:function(){this.on("dblclick",function(e){this.selectWord(this.getSelectionStartFromPointer(e.e))}),this.on("tripleclick",function(e){this.selectLine(this.getSelectionStartFromPointer(e.e))})},initMousedownHandler:function(){this.on("mousedown",function(e){var t=this.canvas.getPointer(e.e);this.__mousedownX=t.x,this.__mousedownY=t.y,this.__isMousedown=!0,this.hiddenTextarea&&this.canvas&&this.canvas.wrapperEl.appendChild(this.hiddenTextarea),this.selected&&this.setCursorByClick(e.e),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.initDelayedCursor(!0))})},initMousemoveHandler:function(){this.on("mousemove",function(e){if(!this.__isMousedown||!this.isEditing)return;var t=this.getSelectionStartFromPointer(e.e);t>=this.__selectionStartOnMouseDown?(this.setSelectionStart(this.__selectionStartOnMouseDown),this.setSelectionEnd(t)):(this.setSelectionStart(t),this.setSelectionEnd(this.__selectionStartOnMouseDown))})},_isObjectMoved:function(e){var t=this.canvas.getPointer(e);return this.__mousedownX!==t.x||this.__mousedownY!==t.y},initMouseupHandler:function(){this.on("mouseup",function(e){this.__isMousedown=!1;if(this._isObjectMoved(e.e))return;this.__lastSelected&&(this.enterEditing(),this.initDelayedCursor(!0)),this.selected=!0})},setCursorByClick:function(e){var t=this.getSelectionStartFromPointer(e);e.shiftKey?t<this.selectionStart?(this.setSelectionEnd(this.selectionStart),this.setSelectionStart(t)):this.setSelectionEnd(t):(this.setSelectionStart(t),this.setSelectionEnd(t))},_getLocalRotatedPointer:function(e){var t=this.canvas.getPointer(e),n=new fabric.Point(t.x,t.y),r=new fabric.Point(this.left,this.top),i=fabric.util.rotatePoint(n,r,fabric.util.degreesToRadians(-this.angle));return this.getLocalPointer(e,i)},getSelectionStartFromPointer:function(e){var t=this._getLocalRotatedPointer(e),n=this.text.split(this._reNewline),r=0,i=0,s=0,o=0,u;for(var a=0,f=n.length;a<f;a++){s+=this._getHeightOfLine(this.ctx,a)*this.scaleY;var l=this._getWidthOfLine(this.ctx,a,n),c=this._getLineLeftOffset(l);i=c*this.scaleX,this.flipX&&(n[a]=n[a].split("").reverse().join(""));for(var h=0,p=n[a].length;h<p;h++){var d=n[a][h];r=i,i+=this._getWidthOfChar(this.ctx,d,a,this.flipX?p-h:h)*this.scaleX;if(s<=t.y||i<=t.x){o++;continue}return this._getNewSelectionStartFromOffset(t,r,i,o+a,p)}if(t.y<s)return this._getNewSelectionStartFromOffset(t,r,i,o+a,p)}if(typeof u=="undefined")return this.text.length},_getNewSelectionStartFromOffset:function(e,t,n,r,i){var s=e.x-t,o=n-e.x,u=o>s?0:1,a=r+u;return this.flipX&&(a=i-a),a>this.text.length&&(a=this.text.length),a}}),fabric.util.object.extend(fabric.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=fabric.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.style.cssText="position: fixed; bottom: 20px; left: 0px; opacity: 0; width: 0px; height: 0px; z-index: -999;",fabric.document.body.appendChild(this.hiddenTextarea),fabric.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),fabric.util.addListener(this.hiddenTextarea,"keypress",this.onKeyPress.bind(this)),fabric.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),fabric.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(fabric.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},_keysMap:{8:"removeChars",9:"exitEditing",27:"exitEditing",13:"insertNewline",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown",46:"forwardDelete"},_ctrlKeysMap:{65:"selectAll",88:"cut"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(e){if(!this.isEditing)return;if(e.keyCode in this._keysMap)this[this._keysMap[e.keyCode]](e);else{if(!(e.keyCode in this._ctrlKeysMap&&(e.ctrlKey||e.metaKey)))return;this[this._ctrlKeysMap[e.keyCode]](e)}e.stopImmediatePropagation(),e.preventDefault(),this.canvas&&this.canvas.renderAll()},forwardDelete:function(e){this.selectionStart===this.selectionEnd&&this.moveCursorRight(e),this.removeChars(e)},copy:function(e){var t=this.getSelectedText(),n=this._getClipboardData(e);n&&n.setData("text",t),this.copiedText=t,this.copiedStyles=this.getSelectionStyles(this.selectionStart,this.selectionEnd)},paste:function(e){var t=null,n=this._getClipboardData(e);n?t=n.getData("text"):t=this.copiedText,t&&this.insertChars(t)},cut:function(e){if(this.selectionStart===this.selectionEnd)return;this.copy(),this.removeChars(e)},_getClipboardData:function(e){return e&&(e.clipboardData||fabric.window.clipboardData)},onKeyPress:function(e){if(!this.isEditing||e.metaKey||e.ctrlKey)return;e.which!==0&&this.insertChars(String.fromCharCode(e.which)),e.stopPropagation()},getDownCursorOffset:function(e,t){var n=t?this.selectionEnd:this.selectionStart,r=this.text.split(this._reNewline),i,s,o=this.text.slice(0,n),u=this.text.slice(n),a=o.slice(o.lastIndexOf("\n")+1),f=u.match(/(.*)\n?/)[1],l=(u.match(/.*\n(.*)\n?/)||{})[1]||"",c=this.get2DCursorLocation(n);if(c.lineIndex===r.length-1||e.metaKey||e.keyCode===34)return this.text.length-n;var h=this._getWidthOfLine(this.ctx,c.lineIndex,r);s=this._getLineLeftOffset(h);var p=s,d=c.lineIndex;for(var v=0,m=a.length;v<m;v++)i=a[v],p+=this._getWidthOfChar(this.ctx,i,d,v);var g=this._getIndexOnNextLine(c,l,p,r);return f.length+1+g},_getIndexOnNextLine:function(e,t,n,r){var i=e.lineIndex+1,s=this._getWidthOfLine(this.ctx,i,r),o=this._getLineLeftOffset(s),u=o,a=0,f;for(var l=0,c=t.length;l<c;l++){var h=t[l],p=this._getWidthOfChar(this.ctx,h,i,l);u+=p;if(u>n){f=!0;var d=u-p,v=u,m=Math.abs(d-n),g=Math.abs(v-n);a=g<m?l+1:l;break}}return f||(a=t.length),a},moveCursorDown:function(e){this.abortCursorAnimation(),this._currentCursorOpacity=1;var t=this.getDownCursorOffset(e,this._selectionDirection==="right");e.shiftKey?this.moveCursorDownWithShift(t):this.moveCursorDownWithoutShift(t),this.initDelayedCursor()},moveCursorDownWithoutShift:function(e){this._selectionDirection="right",this.selectionStart+=e,this.selectionStart>this.text.length&&(this.selectionStart=this.text.length),this.selectionEnd=this.selectionStart,this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},swapSelectionPoints:function(){var e=this.selectionEnd;this.selectionEnd=this.selectionStart,this.selectionStart=e},moveCursorDownWithShift:function(e){this.selectionEnd===this.selectionStart&&(this._selectionDirection="right");var t=this._selectionDirection==="right"?"selectionEnd":"selectionStart";this[t]+=e,this.selectionEnd<this.selectionStart&&this._selectionDirection==="left"&&(this.swapSelectionPoints(),this._selectionDirection="right"),this.selectionEnd>this.text.length&&(this.selectionEnd=this.text.length),this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},getUpCursorOffset:function(e,t){var n=t?this.selectionEnd:this.selectionStart,r=this.get2DCursorLocation(n);if(r.lineIndex===0||e.metaKey||e.keyCode===33)return n;var i=this.text.slice(0,n),s=i.slice(i.lastIndexOf("\n")+1),o=(i.match(/\n?(.*)\n.*$/)||{})[1]||"",u=this.text.split(this._reNewline),a,f=this._getWidthOfLine(this.ctx,r.lineIndex,u),l=this._getLineLeftOffset(f),c=l,h=r.lineIndex;for(var p=0,d=s.length;p<d;p++)a=s[p],c+=this._getWidthOfChar(this.ctx,a,h,p);var v=this._getIndexOnPrevLine(r,o,c,u);return o.length-v+s.length},_getIndexOnPrevLine:function(e,t,n,r){var i=e.lineIndex-1,s=this._getWidthOfLine(this.ctx,i,r),o=this._getLineLeftOffset(s),u=o,a=0,f;for(var l=0,c=t.length;l<c;l++){var h=t[l],p=this._getWidthOfChar(this.ctx,h,i,l);u+=p;if(u>n){f=!0;var d=u-p,v=u,m=Math.abs(d-n),g=Math.abs(v-n);a=g<m?l:l-1;break}}return f||(a=t.length-1),a},moveCursorUp:function(e){this.abortCursorAnimation(),this._currentCursorOpacity=1;var t=this.getUpCursorOffset(e,this._selectionDirection==="right");e.shiftKey?this.moveCursorUpWithShift(t):this.moveCursorUpWithoutShift(t),this.initDelayedCursor()},moveCursorUpWithShift:function(e){this.selectionEnd===this.selectionStart&&(this._selectionDirection="left");var t=this._selectionDirection==="right"?"selectionEnd":"selectionStart";this[t]-=e,this.selectionEnd<this.selectionStart&&this._selectionDirection==="right"&&(this.swapSelectionPoints(),this._selectionDirection="left"),this.selectionStart<0&&(this.selectionStart=0),this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},moveCursorUpWithoutShift:function(e){this.selectionStart===this.selectionEnd&&(this.selectionStart-=e),this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd=this.selectionStart,this._selectionDirection="left",this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},moveCursorLeft:function(e){if(this.selectionStart===0&&this.selectionEnd===0)return;this.abortCursorAnimation(),this._currentCursorOpacity=1,e.shiftKey?this.moveCursorLeftWithShift(e):this.moveCursorLeftWithoutShift(e),this.initDelayedCursor()},_move:function(e,t,n){e.altKey?this[t]=this["findWordBoundary"+n](this[t]):e.metaKey||e.keyCode===35||e.keyCode===36?this[t]=this["findLineBoundary"+n](this[t]):this[t]+=n==="Left"?-1:1},_moveLeft:function(e,t){this._move(e,t,"Left")},_moveRight:function(e,t){this._move(e,t,"Right")},moveCursorLeftWithoutShift:function(e){this._selectionDirection="left",this.selectionEnd===this.selectionStart&&this._moveLeft(e,"selectionStart"),this.selectionEnd=this.selectionStart,this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},moveCursorLeftWithShift:function(e){this._selectionDirection==="right"&&this.selectionStart!==this.selectionEnd?this._moveLeft(e,"selectionEnd"):(this._selectionDirection="left",this._moveLeft(e,"selectionStart"),this.text.charAt(this.selectionStart)==="\n"&&this.selectionStart--,this.selectionStart<0&&(this.selectionStart=0)),this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},moveCursorRight:function(e){if(this.selectionStart>=this.text.length&&this.selectionEnd>=this.text.length)return;this.abortCursorAnimation(),this._currentCursorOpacity=1,e.shiftKey?this.moveCursorRightWithShift(e):this.moveCursorRightWithoutShift(e),this.initDelayedCursor()},moveCursorRightWithShift:function(e){this._selectionDirection==="left"&&this.selectionStart!==this.selectionEnd?this._moveRight(e,"selectionStart"):(this._selectionDirection="right",this._moveRight(e,"selectionEnd"),this.text.charAt(this.selectionEnd-1)==="\n"&&this.selectionEnd++,this.selectionEnd>this.text.length&&(this.selectionEnd=this.text.length)),this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},moveCursorRightWithoutShift:function(e){this._selectionDirection="right",this.selectionStart===this.selectionEnd?(this._moveRight(e,"selectionStart"),this.selectionEnd=this.selectionStart):(this.selectionEnd+=this.getNumNewLinesInSelectedText(),this.selectionEnd>this.text.length&&(this.selectionEnd=this.text.length),this.selectionStart=this.selectionEnd),this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},removeChars:function(e){this.selectionStart===this.selectionEnd?this._removeCharsNearCursor(e):this._removeCharsFromTo(this.selectionStart,this.selectionEnd),this.selectionEnd=this.selectionStart,this._removeExtraneousStyles(),this.canvas&&this.canvas.renderAll().renderAll(),this.setCoords(),this.fire("changed"),this.canvas&&this.canvas.fire("text:changed",{target:this})},_removeCharsNearCursor:function(e){if(this.selectionStart!==0)if(e.metaKey){var t=this.findLineBoundaryLeft(this.selectionStart);this._removeCharsFromTo(t,this.selectionStart),this.selectionStart=t}else if(e.altKey){var n=this.findWordBoundaryLeft(this.selectionStart);this._removeCharsFromTo(n,this.selectionStart),this.selectionStart=n}else{var r=this.text.slice(this.selectionStart-1,this.selectionStart)==="\n";this.removeStyleObject(r),this.selectionStart--,this.text=this.text.slice(0,this.selectionStart)+this.text.slice(this.selectionStart+1)}}}),fabric.util.object.extend(fabric.IText.prototype,{_setSVGTextLineText:function(e,t,n,r,i,s){this.styles[t]?this._setSVGTextLineChars(e,t,n,r,i,s):this.callSuper("_setSVGTextLineText",e,t,n,r,i)},_setSVGTextLineChars:function(e,t,n,r,i,s){var o=t===0||this.useNative?"y":"dy",u=e.split(""),a=0,f=this._getSVGLineLeftOffset(t),l=this._getSVGLineTopOffset(t),c=this._getHeightOfLine(this.ctx,t);for(var h=0,p=u.length;h<p;h++){var d=this.styles[t][h]||{};n.push(this._createTextCharSpan(u[h],d,f,l,o,a));var v=this._getWidthOfChar(this.ctx,u[h],t,h);d.textBackgroundColor&&s.push(this._createTextCharBg(d,f,l,c,v,a)),a+=v}},_getSVGLineLeftOffset:function(e){return this._boundaries&&this._boundaries[e]?fabric.util.toFixed(this._boundaries[e].left,2):0},_getSVGLineTopOffset:function(e){var t=0;for(var n=0;n<=e;n++)t+=this._getHeightOfLine(this.ctx,n);return t-this.height/2},_createTextCharBg:function(e,t,n,r,i,s){return['<rect fill="',e.textBackgroundColor,'" transform="translate(',-this.width/2," ",-this.height+r,")",'" x="',t+s,'" y="',n+r,'" width="',i,'" height="',r,'"></rect>'].join("")},_createTextCharSpan:function(e,t,n,r,i,s){var o=this.getSvgStyles.call(fabric.util.object.extend({visible:!0,fill:this.fill,stroke:this.stroke,type:"text"},t));return['<tspan x="',n+s,'" ',i,'="',r,'" ',t.fontFamily?'font-family="'+t.fontFamily.replace(/"/g,"'")+'" ':"",t.fontSize?'font-size="'+t.fontSize+'" ':"",t.fontStyle?'font-style="'+t.fontStyle+'" ':"",t.fontWeight?'font-weight="'+t.fontWeight+'" ':"",t.textDecoration?'text-decoration="'+t.textDecoration+'" ':"",'style="',o,'">',fabric.util.string.escapeXml(e),"</tspan>"].join("")}}),function(){function request(e,t,n){var r=URL.parse(e);r.port||(r.port=r.protocol.indexOf("https:")===0?443:80);var i=r.port===443?HTTPS:HTTP,s=i.request({hostname:r.hostname,port:r.port,path:r.path,method:"GET"},function(e){var r="";t&&e.setEncoding(t),e.on("end",function(){n(r)}),e.on("data",function(t){e.statusCode===200&&(r+=t)})});s.on("error",function(e){e.errno===process.ECONNREFUSED?fabric.log("ECONNREFUSED: connection refused to "+r.hostname+":"+r.port):fabric.log(e.message)}),s.end()}function requestFs(e,t){var n=require("fs");n.readFile(e,function(e,n){if(e)throw fabric.log(e),e;t(n)})}if(typeof document!="undefined"&&typeof window!="undefined")return;var DOMParser=require("xmldom").DOMParser,URL=require("url"),HTTP=require("http"),HTTPS=require("https"),Canvas=require("canvas"),Image=require("canvas").Image;fabric.util.loadImage=function(e,t,n){function r(r){i.src=new Buffer(r,"binary"),i._src=e,t&&t.call(n,i)}var i=new Image;e&&(e instanceof Buffer||e.indexOf("data")===0)?(i.src=i._src=e,t&&t.call(n,i)):e&&e.indexOf("http")!==0?requestFs(e,r):e?request(e,"binary",r):t&&t.call(n,e)},fabric.loadSVGFromURL=function(e,t,n){e=e.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim(),e.indexOf("http")!==0?requestFs(e,function(e){fabric.loadSVGFromString(e.toString(),t,n)}):request(e,"",function(e){fabric.loadSVGFromString(e,t,n)})},fabric.loadSVGFromString=function(e,t,n){var r=(new DOMParser).parseFromString(e);fabric.parseSVGDocument(r.documentElement,function(e,n){t&&t(e,n)},n)},fabric.util.getScript=function(url,callback){request(url,"",function(body){eval(body),callback&&callback()})},fabric.Image.fromObject=function(e,t){fabric.util.loadImage(e.src,function(n){var r=new fabric.Image(n);r._initConfig(e),r._initFilters(e,function(e){r.filters=e||[],t&&t(r)})})},fabric.createCanvasForNode=function( +e,t,n,r){r=r||n;var i=fabric.document.createElement("canvas"),s=new Canvas(e||600,t||600,r);i.style={},i.width=s.width,i.height=s.height;var o=fabric.Canvas||fabric.StaticCanvas,u=new o(i,n);return u.contextContainer=s.getContext("2d"),u.nodeCanvas=s,u.Font=Canvas.Font,u},fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()},fabric.StaticCanvas.prototype.createJPEGStream=function(e){return this.nodeCanvas.createJPEGStream(e)};var origSetWidth=fabric.StaticCanvas.prototype.setWidth;fabric.StaticCanvas.prototype.setWidth=function(e,t){return origSetWidth.call(this,e,t),this.nodeCanvas.width=e,this},fabric.Canvas&&(fabric.Canvas.prototype.setWidth=fabric.StaticCanvas.prototype.setWidth);var origSetHeight=fabric.StaticCanvas.prototype.setHeight;fabric.StaticCanvas.prototype.setHeight=function(e,t){return origSetHeight.call(this,e,t),this.nodeCanvas.height=e,this},fabric.Canvas&&(fabric.Canvas.prototype.setHeight=fabric.StaticCanvas.prototype.setHeight)}(); \ No newline at end of file diff --git a/js/redactor-fonts.js b/js/redactor-fonts.js deleted file mode 100644 index 021ca561d63b28bd5e38b8c4f1c4ef8bdc6bfe57..0000000000000000000000000000000000000000 --- a/js/redactor-fonts.js +++ /dev/null @@ -1,187 +0,0 @@ -if (!RedactorPlugins) var RedactorPlugins = {}; - -RedactorPlugins.fontfamily = { - init: function () - { - var fonts = [ 'Arial', 'Helvetica', 'Georgia', 'Times New Roman', __('Monospace') ]; - var that = this; - var dropdown = {}; - - $.each(fonts, function(i, s) - { - dropdown['s' + i] = { title: '<span style="font-family:'+s+';">'+s+'</style>', callback: function() { that.setFontfamily(s); }}; - }); - - dropdown['remove'] = { title: 'Remove font', callback: function() { that.resetFontfamily(); }}; - - this.buttonAddBefore('bold', 'fontfamily', __('Change font family'), false, dropdown); - }, - setFontfamily: function (value) - { - this.inlineSetStyle('font-family', value); - }, - resetFontfamily: function() - { - this.inlineRemoveStyle('font-family'); - } -}; - -RedactorPlugins.fontcolor = { - init: function() - { - var colors = [ - '#ffffff', '#000000', '#eeece1', '#1f497d', '#4f81bd', '#c0504d', '#9bbb59', '#8064a2', '#4bacc6', '#f79646', '#ffff00', - '#f2f2f2', '#7f7f7f', '#ddd9c3', '#c6d9f0', '#dbe5f1', '#f2dcdb', '#ebf1dd', '#e5e0ec', '#dbeef3', '#fdeada', '#fff2ca', - '#d8d8d8', '#595959', '#c4bd97', '#8db3e2', '#b8cce4', '#e5b9b7', '#d7e3bc', '#ccc1d9', '#b7dde8', '#fbd5b5', '#ffe694', - '#bfbfbf', '#3f3f3f', '#938953', '#548dd4', '#95b3d7', '#d99694', '#c3d69b', '#b2a2c7', '#b7dde8', '#fac08f', '#f2c314', - '#a5a5a5', '#262626', '#494429', '#17365d', '#366092', '#953734', '#76923c', '#5f497a', '#92cddc', '#e36c09', '#c09100', - '#7f7f7f', '#0c0c0c', '#1d1b10', '#0f243e', '#244061', '#632423', '#4f6128', '#3f3151', '#31859b', '#974806', '#7f6000' - ]; - - var buttons = ['fontcolor', 'backcolor']; - - for (var i = 0; i < 2; i++) - { - var name = buttons[i]; - - var $dropdown = $('<div class="redactor_dropdown redactor_dropdown_box_' + name + '" style="display: none; width: 265px;">'); - - this.pickerBuild($dropdown, name, colors); - $(this.$toolbar).append($dropdown); - - var btn = this.buttonAddBefore('deleted', name, this.opts.curLang[name], $.proxy(function(btnName, $button, btnObject, e) - { - this.dropdownShow(e, btnName); - - }, this)); - - btn.data('dropdown', $dropdown); - } - }, - pickerBuild: function($dropdown, name, colors) - { - var rule = 'color'; - if (name === 'backcolor') rule = 'background-color'; - - var _self = this; - var onSwatch = function(e) - { - e.preventDefault(); - - var $this = $(this); - _self.pickerSet($this.data('rule'), $this.attr('rel')); - - }; - - var len = colors.length; - for (var z = 0; z < len; z++) - { - var color = colors[z]; - - var $swatch = $('<a rel="' + color + '" data-rule="' + rule +'" href="#" style="float: left; font-size: 0; border: 2px solid #fff; padding: 0; margin: 0; width: 20px; height: 20px;"></a>'); - $swatch.css('background-color', color); - $dropdown.append($swatch); - $swatch.on('click', onSwatch); - } - - var $elNone = $('<a href="#" style="display: block; clear: both; padding: 4px 0; font-size: 11px; line-height: 1;"></a>') - .html(this.opts.curLang.none) - .on('click', function(e) - { - e.preventDefault(); - _self.pickerSet(rule, false); - }); - - $dropdown.append($elNone); - }, - pickerSet: function(rule, type) - { - this.bufferSet(); - - this.$editor.focus(); - this.inlineRemoveStyle(rule); - if (type !== false) this.inlineSetStyle(rule, type); - if (this.opts.air) this.$air.fadeOut(100); - this.sync(); - } -}; - -RedactorPlugins.fontsize = { - init: function() - { - var fonts = [10, 14, 22, 32]; - var that = this; - var dropdown = {}; - - $.each(fonts, function(i, s) - { - dropdown['s' + i] = { - title: '<span style="font-size:'+s+'px">'+s+'px</span>', - callback: function() { that.setFontsize(s); } }; - }); - - dropdown['remove'] = { title: __('Remove font size'), callback: function() { that.resetFontsize(); } }; - - this.buttonAddAfter('formatting', 'fontsize', __('Change font size'), false, dropdown); - }, - setFontsize: function(size) - { - this.inlineSetStyle('font-size', size + 'px'); - }, - resetFontsize: function() - { - this.inlineRemoveStyle('font-size'); - } -}; - -RedactorPlugins.textdirection = { - init: function() - { - var that = this; - var dropdown = {}; - - dropdown.ltr = { title: __('Left to Right'), callback: this.setLtr }; - dropdown.rtl = { title: __('Right to Left'), callback: this.setRtl }; - - var button = this.buttonAdd('textdirection', __('Change Text Direction'), - false, dropdown); - - if (this.opts.direction == 'rtl') - this.setRtl(); - }, - setRtl: function() - { - var c = this.getCurrent(), s = this.getSelection(); - this.bufferSet(); - if (s.type == 'Range' && s.focusNode.nodeName != 'div') { - this.linebreakHack(s); - } - else if (!c) { - var repl = '<div dir="rtl">' + this.get() + '</div>'; - this.set(repl, false); - } - $(this.getCurrent()).attr('dir', 'rtl'); - this.sync(); - }, - setLtr: function() - { - var c = this.getCurrent(), s = this.getSelection(); - this.bufferSet(); - if (s.type == 'Range' && s.focusNode.nodeName != 'div') { - this.linebreakHack(s); - } - else if (!c) { - var repl = '<div dir="ltr">' + this.get() + '</div>'; - this.set(repl, false); - } - $(this.getCurrent()).attr('dir', 'ltr'); - this.sync(); - }, - linebreakHack: function(sel) { - var range = sel.getRangeAt(0); - var wrapper = document.createElement('div'); - wrapper.appendChild(range.extractContents()); - range.insertNode(wrapper); - this.selectionElement(wrapper); - } -}; diff --git a/js/redactor-osticket.js b/js/redactor-osticket.js index cf575f287870c377ac9fb0b1f3bd1cde3a5b85d7..ad7524af4cc389bbb56057ddc53104afd237ee9c 100644 --- a/js/redactor-osticket.js +++ b/js/redactor-osticket.js @@ -12,25 +12,27 @@ if (typeof RedactorPlugins === 'undefined') var RedactorPlugins = {}; * uploads. Furthermore, the id of the staff is considered for the drafts, * so one user will not retrieve drafts for another user. */ -RedactorPlugins.draft = { +RedactorPlugins.draft = function() { + return { init: function() { if (!this.opts.draftNamespace) return; - this.opts.changeCallback = this.hideDraftSaved; + this.opts.changeCallback = this.draft.hideDraftSaved; var autosave_url = 'ajax.php/draft/' + this.opts.draftNamespace; if (this.opts.draftObjectId) autosave_url += '.' + this.opts.draftObjectId; this.opts.autosave = this.opts.autoCreateUrl = autosave_url; this.opts.autosaveInterval = 30; - this.opts.autosaveCallback = this.afterUpdateDraft; - this.opts.autosaveErrorCallback = this.autosaveFailed; - this.opts.imageUploadErrorCallback = this.displayError; + this.opts.autosaveCallback = this.draft.afterUpdateDraft; + this.opts.autosaveErrorCallback = this.draft.autosaveFailed; + this.opts.imageUploadErrorCallback = this.draft.displayError; if (this.opts.draftId) { this.opts.autosave = 'ajax.php/draft/'+this.opts.draftId; this.opts.clipboardUploadUrl = this.opts.imageUpload = 'ajax.php/draft/'+this.opts.draftId+'/attach'; + this.autosave.enable(); } else { // Just upload the file. A draft will be created automatically @@ -49,21 +51,23 @@ RedactorPlugins.draft = { this.$toolbar.append(this.$draft_saved); // Add [Delete Draft] button to the toolbar if (this.opts.draftDelete) { - var trash = this.draftDeleteButton = - this.buttonAdd('deleteDraft', __('Delete Draft'), - this.deleteDraft); - this.buttonAwesome('deleteDraft', 'icon-trash'); + var trash = this.draft.deleteButton = + this.button.add('deleteDraft', __('Delete Draft'), + this.draft.deleteDraft); + this.button.setAwesome('deleteDraft', 'icon-trash'); trash.parent().addClass('pull-right'); trash.addClass('delete-draft'); if (!this.opts.draftId) trash.hide(); } + if (this.code.get()) + this.$box.trigger('draft:recovered'); }, - afterUpdateDraft: function(data) { + afterUpdateDraft: function(name, data) { // Slight workaround. Signal the 'keyup' event normally signaled // from typing in the <textarea> if ($.autoLock && this.opts.draftNamespace == 'ticket.response') { - if (this.get()) + if (this.code.get()) $.autoLock.handleEvent(); } @@ -80,17 +84,18 @@ RedactorPlugins.draft = { } // Only show the [Draft Saved] notice if there is content in the // field that has been touched - if (!this.firstSave) { - this.firstSave = true; + if (!this.draft.firstSave) { + this.draft.firstSave = true; // No change yet — dont't show the button return; } - if (data && this.get()) { + if (data && this.code.get()) { this.$draft_saved.show().delay(5000).fadeOut(); } // Show the button if there is a draft to delete if (this.opts.draftId && this.opts.draftDelete) - this.draftDeleteButton.show(); + this.draft.deleteButton.show(); + this.$box.trigger('draft:saved'); }, autosaveFailed: function(error) { if (error.code == 422) @@ -101,6 +106,7 @@ RedactorPlugins.draft = { // Cancel autosave clearInterval(this.autosaveInterval); this.hideDraftSaved(); + this.$box.trigger('draft:failed'); }, displayError: function(json) { @@ -121,17 +127,20 @@ RedactorPlugins.draft = { async: false, success: function() { self.draft_id = self.opts.draftId = undefined; - self.hideDraftSaved(); - self.set(self.opts.draftOriginal || '', false, false); + self.draft.hideDraftSaved(); + self.code.set(self.opts.draftOriginal || '', false, false); self.opts.autosave = self.opts.autoCreateUrl; - self.draftDeleteButton.hide(); - self.firstSave = false; + self.draft.deleteButton.hide(); + self.draft.firstSave = false; + this.$box.trigger('draft:deleted'); } }); } + }; }; -RedactorPlugins.signature = { +RedactorPlugins.signature = function() { + return { init: function() { var $el = $(this.$element.get(0)), inner = $('<div class="inner"></div>'); @@ -195,6 +204,7 @@ RedactorPlugins.signature = { inner.load(url).parent().show(); } + } }; /* Redactor richtext init */ @@ -220,24 +230,29 @@ $(function() { }); var options = $.extend({ 'air': el.hasClass('no-bar'), - 'airButtons': ['formatting', '|', 'bold', 'italic', 'underline', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'image'], - 'buttons': ['html', '|', 'formatting', '|', 'bold', + 'buttons': el.hasClass('no-bar') + ? ['formatting', '|', 'bold', 'italic', 'underline', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'image'] + : ['html', '|', 'formatting', '|', 'bold', 'italic', 'underline', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'image', 'video', 'file', 'table', 'link', '|', 'alignment', '|', 'horizontalrule'], + 'buttonSource': !el.hasClass('no-bar'), 'autoresize': !el.hasClass('no-bar'), 'minHeight': selectedSize, 'focus': false, - 'plugins': [], - 'imageGetJson': 'ajax.php/draft/images/browse', + 'plugins': el.hasClass('no-bar') + ? ['imagepaste','imagemanager','definedlinks'] + : ['signature','imagepaste','imagemanager','imageannotate','table','video','definedlinks'], + 'imageUpload': 'tbd', + 'imageManagerJson': 'ajax.php/draft/images/browse', 'syncBeforeCallback': captureImageSizes, 'linebreaks': true, 'tabFocus': false, 'toolbarFixedBox': true, 'focusCallback': function() { this.$box.addClass('no-pjax'); }, 'linkSize': 100000, - 'predefinedLinks': 'ajax.php/config/links' + 'definedLinks': 'ajax.php/config/links' }, options||{}); if (el.data('redactor')) return; var reset = $('input[type=reset]', el.closest('form')); @@ -254,7 +269,7 @@ $(function() { // where Redactor does not sync properly after adding an image. // Therefore, the ::get() call will not include text added after // the image was inserted. - el.redactor('sync'); + el.redactor('code.sync'); }); if (!$.clientPortal) { options['plugins'] = options['plugins'].concat( @@ -265,6 +280,10 @@ $(function() { options['plugins'].push('draft'); options.draftDelete = el.hasClass('draft-delete'); } + if (el.hasClass('fullscreen')) + options['plugins'].push('fullscreen'); + if ($('#ticket_thread[data-thread-id]').length) + options['imageManagerJson'] += '?threadId=' + $('#ticket_thread').data('threadId'); getConfig().then(function(c) { if (c.lang && c.lang.toLowerCase() != 'en_us' && $.Redactor.opts.langs[c.short_lang]) @@ -301,6 +320,18 @@ $(function() { $(document).ajaxStop(findRichtextBoxes); $(document).on('pjax:success', findRichtextBoxes); $(document).on('pjax:start', cleanupRedactorElements); + + // Monkey patch paste to show the loading bar + var oldImagePaste = $.Redactor.fn.paste.insertFromClipboard, + oldImageInsert = $.Redactor.fn.image.insert; + $.Redactor.fn.paste.insertFromClipboard = function() { + this.progress.show(); + return oldImagePaste.apply(this, arguments); + }; + $.Redactor.fn.image.insert = function() { + this.progress.hide(); + return oldImageInsert.apply(this, arguments); + }; }); $(document).ajaxError(function(event, request, settings) { diff --git a/js/redactor-plugins.js b/js/redactor-plugins.js new file mode 100644 index 0000000000000000000000000000000000000000..dc423663fb14f822371c89cf9503b82936f3c773 --- /dev/null +++ b/js/redactor-plugins.js @@ -0,0 +1,1597 @@ +if (!RedactorPlugins) var RedactorPlugins = {}; + +RedactorPlugins.definedlinks = function() +{ + return { + init: function() + { + if (!this.opts.definedLinks) return; + + this.modal.addCallback('link', $.proxy(this.definedlinks.load, this)); + + }, + load: function() + { + var $select = $('<select id="redactor-defined-links" />'); + $('#redactor-modal-link-insert').prepend($select); + + this.definedlinks.storage = {}; + + $.getJSON(this.opts.definedLinks, $.proxy(function(data) + { + $.each(data, $.proxy(function(key, val) + { + this.definedlinks.storage[key] = val; + $select.append($('<option>').val(key).html(val.name)); + + }, this)); + + $select.on('change', $.proxy(this.definedlinks.select, this)); + + }, this)); + + }, + select: function(e) + { + var key = $(e.target).val(); + var name = '', url = ''; + if (key !== 0) + { + name = this.definedlinks.storage[key].name; + url = this.definedlinks.storage[key].url; + } + + $('#redactor-link-url').val(url); + + var $el = $('#redactor-link-url-text'); + if ($el.val() === '') $el.val(name); + } + }; +}; + +RedactorPlugins.fontcolor = function() +{ + return { + init: function() + { + var colors = [ + '#ffffff', '#000000', '#eeece1', '#1f497d', '#4f81bd', '#c0504d', '#9bbb59', '#8064a2', '#4bacc6', '#f79646', '#ffff00', + '#f2f2f2', '#7f7f7f', '#ddd9c3', '#c6d9f0', '#dbe5f1', '#f2dcdb', '#ebf1dd', '#e5e0ec', '#dbeef3', '#fdeada', '#fff2ca', + '#d8d8d8', '#595959', '#c4bd97', '#8db3e2', '#b8cce4', '#e5b9b7', '#d7e3bc', '#ccc1d9', '#b7dde8', '#fbd5b5', '#ffe694', + '#bfbfbf', '#3f3f3f', '#938953', '#548dd4', '#95b3d7', '#d99694', '#c3d69b', '#b2a2c7', '#b7dde8', '#fac08f', '#f2c314', + '#a5a5a5', '#262626', '#494429', '#17365d', '#366092', '#953734', '#76923c', '#5f497a', '#92cddc', '#e36c09', '#c09100', + '#7f7f7f', '#0c0c0c', '#1d1b10', '#0f243e', '#244061', '#632423', '#4f6128', '#3f3151', '#31859b', '#974806', '#7f6000' + ]; + + var buttons = ['fontcolor', 'backcolor']; + + for (var i = 0; i < 2; i++) + { + var name = buttons[i]; + + var button = this.button.addBefore('deleted', name, this.lang.get(name)); + var $dropdown = this.button.addDropdown(button); + + $dropdown.width(242); + this.fontcolor.buildPicker($dropdown, name, colors); + + } + }, + buildPicker: function($dropdown, name, colors) + { + var rule = (name == 'backcolor') ? 'background-color' : 'color'; + + var len = colors.length; + var self = this; + var func = function(e) + { + e.preventDefault(); + self.fontcolor.set($(this).data('rule'), $(this).attr('rel')); + }; + + for (var z = 0; z < len; z++) + { + var color = colors[z]; + + var $swatch = $('<a rel="' + color + '" data-rule="' + rule +'" href="#" style="float: left; font-size: 0; border: 2px solid #fff; padding: 0; margin: 0; width: 22px; height: 22px;"></a>'); + $swatch.css('background-color', color); + $swatch.on('click', func); + + $dropdown.append($swatch); + } + + var $elNone = $('<a href="#" style="display: block; clear: both; padding: 5px; font-size: 12px; line-height: 1;"></a>').html(this.lang.get('none')); + $elNone.on('click', $.proxy(function(e) + { + e.preventDefault(); + this.fontcolor.remove(rule); + + }, this)); + + $dropdown.append($elNone); + }, + set: function(rule, type) + { + this.inline.format('span', 'style', rule + ': ' + type + ';'); + }, + remove: function(rule) + { + this.inline.removeStyleRule(rule); + } + }; +}; + +RedactorPlugins.fontfamily = function() +{ + return { + init: function () + { + var fonts = [ 'Arial', 'Helvetica', 'Georgia', 'Times New Roman', 'Monospace' ]; + var that = this; + var dropdown = {}; + + $.each(fonts, function(i, s) + { + dropdown['s' + i] = { title: '<span style="font-family:' + s.toLowerCase() + ';">' + + s + '</span>', func: function() { that.fontfamily.set(s); }}; + }); + + dropdown.remove = { title: __('Remove Font Family'), func: that.fontfamily.reset }; + + var button = this.button.addBefore('bold', 'fontfamily', __('Change Font Family')); + this.button.addDropdown(button, dropdown); + + }, + set: function (value) + { + this.inline.format('span', 'style', 'font-family:' + value + ';'); + }, + reset: function() + { + this.inline.removeStyleRule('font-family'); + } + }; +}; + +RedactorPlugins.fullscreen = function() +{ + return { + init: function() + { + this.fullscreen.isOpen = false; + + var button = this.button.add('fullscreen', 'Fullscreen'); + this.button.addCallback(button, this.fullscreen.toggle); + + if (this.opts.fullscreen) this.fullscreen.toggle(); + }, + enable: function() + { + this.button.changeIcon('fullscreen', 'normalscreen'); + this.button.setActive('fullscreen'); + this.fullscreen.isOpen = true; + + if (this.opts.toolbarExternal) + { + this.fullscreen.toolcss = {}; + this.fullscreen.boxcss = {}; + this.fullscreen.toolcss.width = this.$toolbar.css('width'); + this.fullscreen.toolcss.top = this.$toolbar.css('top'); + this.fullscreen.toolcss.position = this.$toolbar.css('position'); + this.fullscreen.boxcss.top = this.$box.css('top'); + } + + this.fullscreen.height = this.$editor.height(); + + if (this.opts.maxHeight) this.$editor.css('max-height', ''); + if (this.opts.minHeight) this.$editor.css('min-height', ''); + + if (!this.$fullscreenPlaceholder) this.$fullscreenPlaceholder = $('<div/>'); + this.$fullscreenPlaceholder.insertAfter(this.$box); + + this.$box.appendTo(document.body); + + this.$box.addClass('redactor-box-fullscreen'); + $('body, html').css('overflow', 'hidden'); + + this.fullscreen.resize(); + $(window).on('resize.redactor.fullscreen', $.proxy(this.fullscreen.resize, this)); + $(document).scrollTop(0, 0); + + this.$editor.focus(); + this.observe.load(); + }, + disable: function() + { + this.button.removeIcon('fullscreen', 'normalscreen'); + this.button.setInactive('fullscreen'); + this.fullscreen.isOpen = false; + + $(window).off('resize.redactor.fullscreen'); + $('body, html').css('overflow', ''); + + this.$box.insertBefore(this.$fullscreenPlaceholder); + this.$fullscreenPlaceholder.remove(); + + this.$box.removeClass('redactor-box-fullscreen').css({ width: 'auto', height: 'auto' }); + + this.code.sync(); + + if (this.opts.toolbarExternal) + { + this.$box.css('top', this.fullscreen.boxcss.top); + this.$toolbar.css({ + 'width': this.fullscreen.toolcss.width, + 'top': this.fullscreen.toolcss.top, + 'position': this.fullscreen.toolcss.position + }); + } + + if (this.opts.minHeight) this.$editor.css('minHeight', this.opts.minHeight); + if (this.opts.maxHeight) this.$editor.css('maxHeight', this.opts.maxHeight); + + this.$editor.css('height', 'auto'); + this.$editor.focus(); + this.observe.load(); + }, + toggle: function() + { + if (this.fullscreen.isOpen) + { + this.fullscreen.disable(); + } + else + { + this.fullscreen.enable(); + } + }, + resize: function() + { + if (!this.fullscreen.isOpen) return; + + var toolbarHeight = this.$toolbar.height(); + + var height = $(window).height() - toolbarHeight; + this.$box.width($(window).width() - 2).height(height + toolbarHeight); + + if (this.opts.toolbarExternal) + { + this.$toolbar.css({ + 'top': '0px', + 'position': 'absolute', + 'width': '100%' + }); + + this.$box.css('top', toolbarHeight + 'px'); + } + + this.$editor.height(height - 14); + } + }; +}; + +RedactorPlugins.imagemanager = function() +{ + return { + init: function() + { + if (!this.opts.imageManagerJson) return; + + this.modal.addCallback('image', this.imagemanager.load); + }, + load: function() + { + var $modal = this.modal.getModal(); + + this.modal.createTabber($modal); + this.modal.addTab(1, 'Upload', 'active'); + this.modal.addTab(2, 'Choose'); + + $('#redactor-modal-image-droparea').addClass('redactor-tab redactor-tab1'); + + var $box = $('<div id="redactor-image-manager-box" style="overflow: auto; height: 300px;" class="redactor-tab redactor-tab2">').hide(); + $modal.append($box); + + $.ajax({ + dataType: "json", + cache: false, + url: this.opts.imageManagerJson, + success: $.proxy(function(data) + { + $.each(data, $.proxy(function(key, val) + { + // title + var thumbtitle = ''; + if (typeof val.title !== 'undefined') thumbtitle = val.title; + + var img = $('<img src="' + val.thumb + '" rel="' + val.image + '" title="' + thumbtitle + '" style="width: 100px; height: 75px; cursor: pointer;" />'); + $('#redactor-image-manager-box').append(img); + $(img).click($.proxy(this.imagemanager.insert, this)); + + }, this)); + + + }, this) + }); + + + }, + insert: function(e) + { + this.image.insert('<img src="' + $(e.target).attr('rel') + '" alt="' + $(e.target).attr('title') + '">'); + } + }; +}; + +RedactorPlugins.table = function() +{ + return { + getTemplate: function() + { + return String() + + '<section id="redactor-modal-table-insert">' + + '<label>' + this.lang.get('rows') + '</label>' + + '<input type="text" size="5" value="2" id="redactor-table-rows" />' + + '<label>' + this.lang.get('columns') + '</label>' + + '<input type="text" size="5" value="3" id="redactor-table-columns" />' + + '</section>'; + }, + init: function() + { + + var dropdown = {}; + + dropdown.insert_table = { title: this.lang.get('insert_table'), func: this.table.show }; + dropdown.insert_row_above = { title: this.lang.get('insert_row_above'), func: this.table.addRowAbove }; + dropdown.insert_row_below = { title: this.lang.get('insert_row_below'), func: this.table.addRowBelow }; + dropdown.insert_column_left = { title: this.lang.get('insert_column_left'), func: this.table.addColumnLeft }; + dropdown.insert_column_right = { title: this.lang.get('insert_column_right'), func: this.table.addColumnRight }; + dropdown.add_head = { title: this.lang.get('add_head'), func: this.table.addHead }; + dropdown.delete_head = { title: this.lang.get('delete_head'), func: this.table.deleteHead }; + dropdown.delete_column = { title: this.lang.get('delete_column'), func: this.table.deleteColumn }; + dropdown.delete_row = { title: this.lang.get('delete_row'), func: this.table.deleteRow }; + dropdown.delete_table = { title: this.lang.get('delete_table'), func: this.table.deleteTable }; + + this.observe.addButton('td', 'table'); + this.observe.addButton('th', 'table'); + + var button = this.button.addBefore('link', 'table', this.lang.get('table')); + this.button.addDropdown(button, dropdown); + }, + show: function() + { + this.modal.addTemplate('table', this.table.getTemplate()); + + this.modal.load('table', this.lang.get('insert_table'), 300); + this.modal.createCancelButton(); + + var button = this.modal.createActionButton(this.lang.get('insert')); + button.on('click', this.table.insert); + + this.selection.save(); + this.modal.show(); + + $('#redactor-table-rows').focus(); + + }, + insert: function() + { + + var rows = $('#redactor-table-rows').val(), + columns = $('#redactor-table-columns').val(), + $tableBox = $('<div>'), + tableId = Math.floor(Math.random() * 99999), + $table = $('<table id="table' + tableId + '"><tbody></tbody></table>'), + i, $row, z, $column; + + for (i = 0; i < rows; i++) + { + $row = $('<tr>'); + + for (z = 0; z < columns; z++) + { + $column = $('<td>' + this.opts.invisibleSpace + '</td>'); + + // set the focus to the first td + if (i === 0 && z === 0) + { + $column.append(this.selection.getMarker()); + } + + $($row).append($column); + } + + $table.append($row); + } + + $tableBox.append($table); + var html = $tableBox.html(); + + + this.modal.close(); + this.selection.restore(); + + if (this.table.getTable()) return; + + this.buffer.set(); + + var current = this.selection.getBlock() || this.selection.getCurrent(); + if (current && current.tagName != 'BODY') + { + if (current.tagName == 'LI') current = $(current).closest('ul, ol'); + $(current).after(html); + } + else + { + this.insert.html(html); + } + + this.selection.restore(); + + var table = this.$editor.find('#table' + tableId); + + if (!this.opts.linebreaks && (this.utils.browser('mozilla') || this.utils.browser('msie'))) + { + var $next = table.next(); + if ($next.length === 0) + { + table.after(this.opts.emptyHtml); + } + } + + this.observe.buttons(); + + table.find('span.redactor-selection-marker').remove(); + table.removeAttr('id'); + + this.code.sync(); + this.core.setCallback('insertedTable', table); + }, + getTable: function() + { + var $table = $(this.selection.getParent()).closest('table'); + + if (!this.utils.isRedactorParent($table)) return false; + if ($table.size() === 0) return false; + + return $table; + }, + restoreAfterDelete: function($table) + { + this.selection.restore(); + $table.find('span.redactor-selection-marker').remove(); + this.code.sync(); + }, + deleteTable: function() + { + var $table = this.table.getTable(); + if (!$table) return; + + this.buffer.set(); + + + var $next = $table.next(); + if (!this.opts.linebreaks && $next.length !== 0) + { + this.caret.setStart($next); + } + else + { + this.caret.setAfter($table); + } + + + $table.remove(); + + this.code.sync(); + }, + deleteRow: function() + { + var $table = this.table.getTable(); + if (!$table) return; + + var $current = $(this.selection.getCurrent()); + + this.buffer.set(); + + var $current_tr = $current.closest('tr'); + var $focus_tr = $current_tr.prev().length ? $current_tr.prev() : $current_tr.next(); + if ($focus_tr.length) + { + var $focus_td = $focus_tr.children('td, th').first(); + if ($focus_td.length) $focus_td.prepend(this.selection.getMarker()); + } + + $current_tr.remove(); + this.table.restoreAfterDelete($table); + }, + deleteColumn: function() + { + var $table = this.table.getTable(); + if (!$table) return; + + this.buffer.set(); + + var $current = $(this.selection.getCurrent()); + var $current_td = $current.closest('td, th'); + var index = $current_td[0].cellIndex; + + $table.find('tr').each($.proxy(function(i, elem) + { + var $elem = $(elem); + var focusIndex = index - 1 < 0 ? index + 1 : index - 1; + if (i === 0) $elem.find('td, th').eq(focusIndex).prepend(this.selection.getMarker()); + + $elem.find('td, th').eq(index).remove(); + + }, this)); + + this.table.restoreAfterDelete($table); + }, + addHead: function() + { + var $table = this.table.getTable(); + if (!$table) return; + + this.buffer.set(); + + if ($table.find('thead').size() !== 0) + { + this.table.deleteHead(); + return; + } + + var tr = $table.find('tr').first().clone(); + tr.find('td').html(this.opts.invisibleSpace); + $thead = $('<thead></thead>').append(tr); + $table.prepend($thead); + + this.code.sync(); + + }, + deleteHead: function() + { + var $table = this.table.getTable(); + if (!$table) return; + + var $thead = $table.find('thead'); + if ($thead.size() === 0) return; + + this.buffer.set(); + + $thead.remove(); + this.code.sync(); + }, + addRowAbove: function() + { + this.table.addRow('before'); + }, + addRowBelow: function() + { + this.table.addRow('after'); + }, + addColumnLeft: function() + { + this.table.addColumn('before'); + }, + addColumnRight: function() + { + this.table.addColumn('after'); + }, + addRow: function(type) + { + var $table = this.table.getTable(); + if (!$table) return; + + this.buffer.set(); + + var $current = $(this.selection.getCurrent()); + var $current_tr = $current.closest('tr'); + var new_tr = $current_tr.clone(); + + new_tr.find('th').replaceWith(function() + { + var $td = $('<td>'); + $td[0].attributes = this.attributes; + + return $td.append($(this).contents()); + }); + + new_tr.find('td').html(this.opts.invisibleSpace); + + if (type == 'after') + { + $current_tr.after(new_tr); + } + else + { + $current_tr.before(new_tr); + } + + this.code.sync(); + }, + addColumn: function (type) + { + var $table = this.table.getTable(); + if (!$table) return; + + var index = 0; + var current = $(this.selection.getCurrent()); + + this.buffer.set(); + + var $current_tr = current.closest('tr'); + var $current_td = current.closest('td, th'); + + $current_tr.find('td, th').each($.proxy(function(i, elem) + { + if ($(elem)[0] === $current_td[0]) index = i; + + }, this)); + + $table.find('tr').each($.proxy(function(i, elem) + { + var $current = $(elem).find('td, th').eq(index); + + var td = $current.clone(); + td.html(this.opts.invisibleSpace); + + if (type == 'after') + { + $current.after(td); + } + else + { + $current.before(td); + } + + }, this)); + + this.code.sync(); + } + }; +}; + +RedactorPlugins.textdirection = function() { + return { + init: function() + { + var that = this; + var dropdown = {}; + + dropdown.ltr = { title: __('Left to Right'), callback: this.setLtr }; + dropdown.rtl = { title: __('Right to Left'), callback: this.setRtl }; + + var button = this.button.add('textdirection', __('Change Text Direction'), + false, dropdown); + + if (this.opts.direction == 'rtl') + this.setRtl(); + }, + setRtl: function() + { + var c = this.getCurrent(), s = this.getSelection(); + this.bufferSet(); + if (s.type == 'Range' && s.focusNode.nodeName != 'div') { + this.linebreakHack(s); + } + else if (!c) { + var repl = '<div dir="rtl">' + this.get() + '</div>'; + this.set(repl, false); + } + $(this.getCurrent()).attr('dir', 'rtl'); + this.sync(); + }, + setLtr: function() + { + var c = this.getCurrent(), s = this.getSelection(); + this.bufferSet(); + if (s.type == 'Range' && s.focusNode.nodeName != 'div') { + this.linebreakHack(s); + } + else if (!c) { + var repl = '<div dir="ltr">' + this.get() + '</div>'; + this.set(repl, false); + } + $(this.getCurrent()).attr('dir', 'ltr'); + this.sync(); + }, + linebreakHack: function(sel) { + var range = sel.getRangeAt(0); + var wrapper = document.createElement('div'); + wrapper.appendChild(range.extractContents()); + range.insertNode(wrapper); + this.selectionElement(wrapper); + } + }; +}; + +RedactorPlugins.video = function() +{ + return { + reUrlYoutube: /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig, + reUrlVimeo: /https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/, + getTemplate: function() + { + return String() + + '<section id="redactor-modal-video-insert">' + + '<label>' + this.lang.get('video_html_code') + '</label>' + + '<textarea id="redactor-insert-video-area" style="height: 160px;"></textarea>' + + '</section>'; + }, + init: function() + { + var button = this.button.addAfter('image', 'video', this.lang.get('video')); + this.button.addCallback(button, this.video.show); + }, + show: function() + { + this.modal.addTemplate('video', this.video.getTemplate()); + + this.modal.load('video', this.lang.get('video'), 700); + this.modal.createCancelButton(); + + var button = this.modal.createActionButton(this.lang.get('insert')); + button.on('click', this.video.insert); + + this.selection.save(); + this.modal.show(); + + $('#redactor-insert-video-area').focus(); + + }, + insert: function() + { + var data = $('#redactor-insert-video-area').val(); + data = this.clean.stripTags(data); + + // parse if it is link on youtube & vimeo + var iframeStart = '<iframe style="width: 500px; height: 281px;" src="', + iframeEnd = '" frameborder="0" allowfullscreen></iframe>'; + + if (data.match(this.video.reUrlYoutube)) + { + data = data.replace(this.video.reUrlYoutube, iframeStart + '//www.youtube.com/embed/$1' + iframeEnd); + } + else if (data.match(this.video.reUrlVimeo)) + { + data = data.replace(this.video.reUrlVimeo, iframeStart + '//player.vimeo.com/video/$2' + iframeEnd); + } + + this.selection.restore(); + this.modal.close(); + + var current = this.selection.getBlock() || this.selection.getCurrent(); + + if (current) $(current).after(data); + else + { + this.insert.html(data); + } + + this.code.sync(); + } + + }; +}; + +RedactorPlugins.imagepaste = function() { + return { + init: function() { + if (this.utils.browser('webkit') && navigator.userAgent.indexOf('Chrome') === -1) + { + var arr = this.utils.browser('version').split('.'); + if (arr[0] < 536) + return true; + } + + // paste except opera (not webkit) + if (this.utils.browser('opera')) + return true; + + this.$editor.on('paste.imagepaste', $.proxy(this.imagepaste.buildEventPaste, this)); + }, + buildEventPaste: function(e) + { + var event = e.originalEvent || e, + fileUpload = false, + files = [], + i, file, + cd = event.clipboardData; + + if (typeof(cd) === 'undefined') return; + + if (cd.items && cd.items.length) + { + for (i = 0, k = cd.items.length; i < k; i++) { + if (cd.kind == 'file' && cd.type.indexOf('image/') !== -1) { + file = cd.items[i].getAsFile(); + if (file !== null) + files.push(file); + } + } + } + else if (cd.files && cd.files.length) + { + files = cd.files + } + else if (cd.types.length) { + for (i = 0, k = cd.types.length; i < k; i++) { + if (cd.types[i].indexOf('image/') != -1) { + var data = cd.getData(cd.types[i]); + if (data.length) + files.push(new Blob([data], {type: cd.types[i]})); + } + } + } + if (files.length) { + // clipboard upload + this.selection.save(); + this.buffer.set(); + this.clean.singleLine = false; + for (i = 0, k = files.length; i < k; i++) + this.upload.directUpload(files[i], event); + return false; + } + } + }; +}; + +var loadedFabric = false; +RedactorPlugins.imageannotate = function() { + return { + annotateButton: false, + init: function() { + var redactor = this, + self = this.imageannotate; + if (typeof window.fabric === 'undefined' && !loadedFabric) { + $.getScript('../js/fabric.min.js'); + loadedFabric = true; + } + $(document).on('click', '.redactor-box img', function() { + var $image = $(this), + image_box = $('#redactor-image-box'); + if (!image_box.length || !redactor.image.editter) + return; + + var edit_size = redactor.image.editter.outerWidth(); + + self.annotateButton = redactor.image.editter + .on('remove.annotate', + function() { self.teardownAnnotate.call(redactor, image_box); }) + .clone() + .text(' '+__('Annotate')) + .prepend('<i class="icon-pencil"></i>') + .addClass('annotate-button') + .insertAfter(redactor.image.editter) + .data('image', this) + .on('click', + function() { self.startAnnotate.call(redactor, $image) }); + var diff = (edit_size - self.annotateButton.outerWidth()) / 2; + self.annotateButton.css('margin-left', + (diff + 5) + 'px'); + redactor.image.editter.css('margin-left', + (-edit_size + diff - 5) + 'px'); + }); + }, + startAnnotate: function(img) { + canvas = this.imageannotate.initCanvas(img); + this.imageannotate.buildToolbar(img); + this.image.editter.hide(); + this.imageannotate.annotateButton.hide(); + }, + teardownAnnotate: function(box) { + this.image.editter.off('.annotate'); + this.opts.keydownCallback = false; + this.opts.keyupCallback = false; + box.find('.annotate-toolbar').remove(); + box.find('.annotate-button').remove(); + var img = box.find('img')[0], + $img = $(img), + fcanvas = $img.data('canvas'), + state = fcanvas.toObject(); + // Capture current annotations + delete state.backgroundImage; + $img.attr('data-annotations', btoa(JSON.stringify(state))); + // Drop the canvas + fcanvas.dispose(); + box.find('canvas').parent().remove(); + $img.data('canvas', false); + // Deselect the image + this.image.hideResize(); + // Show the original image + $img.removeClass('hidden'); + }, + buildToolbar: function(img) { + var box = img.parent(), + redactor = this, + plugin = this.imageannotate, + shapes = $('<span>') + .attr('data-redactor', 'verified') + .attr('contenteditable', 'false') + .css({'display': 'inline-block', 'vertical-align': 'top'}), + swatches = shapes.clone(), + actions = shapes.clone(), + container = $('<div></div>') + .addClass('annotate-toolbar') + .attr('data-redactor', 'verified') + .attr('contenteditable', 'false') + .css({position: 'absolute', bottom: 0, 'min-height': '28px', + width: '100%', 'background-color': 'rgba(0,0,0,0.5)', + margin: 0, 'padding-top': '4px' }) + .appendTo(box) + .append(shapes) + .append(swatches) + .append(actions); + + var button = $('<a></a>') + .attr('href', '#') + .attr('data-redactor', 'verified') + .attr('contenteditable', 'false') + .css({color: 'white', padding: '0 7px 1px', margin: '1px 3px', + 'text-decoration': 'none', 'vertical-align': 'top'}); + + shapes + .append(button.clone() + .append($('<i class="icon-arrow-right icon-large"></i>') + .on('click', plugin.drawArrow.bind(redactor)) + .attr('title', __('Add Arrow'))) + ) + .append(button.clone() + .append($('<i class="icon-check-empty icon-large"></i>') + .on('click', plugin.drawBox.bind(redactor)) + .attr('title', __('Add Rectangle'))) + ) + .append(button.clone() + .append($('<i class="icon-circle-blank icon-large"></i>') + .on('click', plugin.drawEllipse.bind(redactor)) + .attr('title', __('Add Ellipse'))) + ) + .append(button.clone() + .append($('<i class="icon-text-height icon-large"></i>') + .on('click', plugin.drawText.bind(redactor)) + .attr('title', __('Add Text'))) + ); + + var colors = [ + '#ffffff', '#888888', '#000000', 'fuchsia', 'blue', 'red', + 'lime', 'blueviolet', 'cyan', '#f4a63b', 'yellow'] + len = colors.length; + + swatches.append( + $('<span><i class="icon-ellipsis-vertical icon-large"></i></span>') + .css({color: 'white', padding: '0 3px 1px', margin: '1px 3px', + height: '21px', position: 'relative', bottom: '8px'} + ) + ); + for (var z = 0; z < len; z++) { + var color = colors[z]; + + var $swatch = $('<a rel="' + color + '" href="#" style="font-size: 0; padding: 0; margin: 2px; width: 22px; height: 22px;"></a>'); + $swatch.css({'background-color': color, 'border': '1px dotted rgba(255,255,255,0.4)'}); + $swatch.attr('data-redactor', 'verified'); + $swatch.attr('contenteditable', 'false'); + $swatch.on('click', plugin.setColor.bind(redactor)); + + swatches.append($swatch); + } + + actions + .append( + $('<span><i class="icon-ellipsis-vertical icon-large"></i></span>') + .css({color: 'white', padding: '0 3px 1px', margin: '1px 3px', + height: '21px'} + ) + ) + .append(button.clone() + .css('padding-left', '1px') + .append($('<span></span>').css('position','relative') + .append($('<i class="icon-font"></i>')) + .append($('<i class="icon-minus"></i>') + .css({position: 'absolute', right: '-4px', top: '5px', + 'text-shadow': '0 0 2px black', 'font-size':'80%'}) + ) + ) + .on('click', plugin.smallerFont.bind(redactor)) + .attr('title', __('Decrease Font Size')) + ) + .append(button.clone() + .css('padding-left', '1px') + .append($('<span></span>').css('position','relative') + .append($('<i class="icon-font icon-large"></i>')) + .append($('<i class="icon-plus"></i>') + .css({position: 'absolute', right: '-8px', top: '4px', + 'text-shadow': '0 0 2px black'}) + ) + ) + .on('click', plugin.biggerFont.bind(redactor)) + .attr('title', __('Increase Font Size')) + ) + .append(button.clone() + .attr('id', 'annotate-set-stroke') + .append($('<span></span>').css({'position': 'relative', 'top': '2px'}) + .append($('<i class="icon-check-empty icon-large"></i>') + .css('font-size', '120%') + ).append($('<i class="icon-tint"></i>') + .css({position: 'absolute', left: '4.5px', top: 0}) + ) + ) + .on('click', plugin.paintStroke.bind(redactor)) + .attr('title', __('Set Stroke')) + ) + .append(button.clone() + .attr('id', 'annotate-set-fill') + .append($('<span></span>').css('position','relative') + .append($('<i class="icon-sign-blank icon-large"></i>')) + .append($('<i class="icon-tint icon-dark"></i>') + .css({position: 'absolute', left: '4px', top: '2px'}) + ) + ) + .on('click', plugin.paintFill.bind(redactor)) + .attr('title', __('Set Fill')) + ) + .append(button.clone() + .append($('<i class="icon-eye-close icon-large"></i>')) + .on('click', plugin.setOpacity.bind(redactor)) + .attr('title', __('Toggle Opacity')) + ) + .append(button.clone() + .append($('<i class="icon-double-angle-up icon-large"></i>')) + .on('click', plugin.bringForward.bind(redactor)) + .attr('title', __('Bring Forward')) + ) + .append(button.clone() + .append($('<i class="icon-trash icon-large"></i>')) + .on('click', plugin.discard.bind(redactor)) + .attr('title', __('Delete Object')) + ); + + container.append(button.clone() + .append($('<i class="icon-save icon-large"></i>')) + .on('click', plugin.commit.bind(redactor)) + .addClass('pull-right') + .attr('title', __('Commit Annotations')) + ); + plugin.paintStroke(); + }, + + setColor: function(e) { + e.preventDefault(); + var plugin = this.imageannotate, + redactor = this, + swatch = e.target, + image_box = $('#redactor-image-box'), + img = image_box.find('img')[0], + fcanvas = $(img).data('canvas'); + $.each(fcanvas.getObjects(), function() { + if (this.get('active')) { + if (plugin.paintMode == 'fill') + this.setFill($(e.target).attr('rel')); + else + this.setStroke($(e.target).attr('rel')); + } + }); + fcanvas.renderAll(); + }, + + // Shapes + drawShape: function(ondown, onmove, onup, cursor) { + // @see http://jsfiddle.net/URWru/ + var plugin = this.imageannotate, + redactor = this, + image_box = $('#redactor-image-box'), + img = image_box.find('img')[0], + fcanvas = $(img).data('canvas'), + isDown, shape, + mousedown = function(o) { + isDown = true; + plugin.setBuffer(); + var pointer = fcanvas.getPointer(o.e); + shape = ondown(pointer, o.e); + fcanvas.add(shape); + }, + mousemove = function(o) { + if (!isDown) return; + var pointer = fcanvas.getPointer(o.e); + onmove(shape, pointer, o.e); + fcanvas.renderAll(); + }, + mouseup = function(o) { + isDown = false; + if (onup) { + if (shape2 = onup(shape, fcanvas.getPointer(o.e))) { + shape.remove(); + fcanvas.add(shape2); + shape = shape2; + } + } + shape.setCoords() + .set({ + transparentCorners: false, + borderColor: 'rgba(102,153,255,0.9)', + cornerColor: 'rgba(102,153,255,0.5)', + cornerSize: 10 + }); + fcanvas.calcOffset() + .off('mouse:down', mousedown) + .off('mouse:up', mouseup) + .off('mouse:move', mousemove) + .deactivateAll() + .setActiveObject(shape) + .renderAll(); + fcanvas.selection = true; + fcanvas.defaultCursor = 'default'; + }; + + fcanvas.selection = false; + fcanvas.defaultCursor = cursor || 'crosshair'; + // Ensure double presses of same button are squelched + fcanvas.off('mouse:down'); + fcanvas.off('mouse:up'); + fcanvas.off('mouse:move'); + fcanvas.on('mouse:down', mousedown); + fcanvas.on('mouse:up', mouseup); + fcanvas.on('mouse:move', mousemove); + return false; + }, + + drawArrow: function(e) { + e.preventDefault(); + var top, left; + return this.imageannotate.drawShape( + function(pointer) { + top = pointer.y; + left = pointer.x; + return new fabric.Group([ + new fabric.Line([0, 5, 0, 5], { + strokeWidth: 5, + fill: 'red', + stroke: 'red', + originX: 'center', + originY: 'center', + selectable: false, + hasBorders: false + }), + new fabric.Polygon([ + {x: 20, y: 0}, + {x: 0, y: -5}, + {x: 0, y: 5} + ], { + strokeWidth: 0, + fill: 'red', + originX: 'center', + originY: 'center', + selectable: false, + hasBorders: false + }) + ], { + left: pointer.x, + top: pointer.y, + originX: 'center', + originY: 'center' + }); + }, + function(group, pointer) { + var dx = pointer.x - left, + dy = pointer.y - top, + angle = Math.atan(dy / dx), + d = Math.sqrt(dx * dx + dy * dy) - 10, + sign = dx < 0 ? -1 : 1, + dy2 = Math.sin(angle) * d * sign; + dx2 = Math.cos(angle) * d * sign, + group.item(0) + .set({ x2: dx2, y2: dy2 }); + group.item(1) + .set({ + angle: angle * 180 / Math.PI, + flipX: dx < 0, + flipY: dy < 0 + }) + .setPositionByOrigin(new fabric.Point(dx, dy), + 'center', 'center'); + }, + function(shape, pointer) { + var dx = pointer.x - left, + dy = pointer.y - top, + angle = Math.atan(dy / dx), + d = Math.sqrt(dx * dx + dy * dy); + // Mess with the next two lines and you *will* be sorry! + shape.forEachObject(function(e) { shape.removeWithUpdate(e); }); + return new fabric.Path( + 'M '+left+' '+top+' l '+(d-20)+' 0 0 -3 15 3 -15 3 0 -3 z', { + angle: angle * 180 / Math.PI + (dx < 0 ? 180 : 0), + strokeWidth: 5, + fill: 'red', + stroke: 'red' + }); + } + ); + }, + + drawEllipse: function(e) { + e.preventDefault(); + return this.imageannotate.drawShape( + function(pointer) { + return new fabric.Ellipse({ + top: pointer.y, + left: pointer.x, + strokeWidth: 5, + fill: 'transparent', + stroke: 'red', + originX: 'left', + originY: 'top' + }); + }, + function(circle, pointer, event) { + var x = circle.get('left'), y = circle.get('top'), + dx = pointer.x - x, dy = pointer.y - y, + sw = circle.getStrokeWidth()/2; + // Use SHIFT to draw circles + if (event.shiftKey) { + dy = dx = Math.max(dx, dy); + } + circle.set({ + rx: Math.max(0, Math.abs(dx/2) - sw), + ry: Math.max(0, Math.abs(dy/2) - sw), + originX: dx < 0 ? 'right' : 'left', + originY: dy < 0 ? 'bottom' : 'top'}); + } + ); + }, + + drawBox: function(e) { + e.preventDefault(); + return this.imageannotate.drawShape( + function(pointer) { + return new fabric.Rect({ + top: pointer.y, + left: pointer.x, + strokeWidth: 5, + fill: 'transparent', + stroke: 'red', + originX: 'left', + originY: 'top' + }); + }, + function(rect, pointer, event) { + var x = rect.get('left'), y = rect.get('top'), + dx = pointer.x - x, dy = pointer.y - y; + // Use SHIFT to draw squares + if (event.shiftKey) { + dy = dx = Math.max(dx, dy); + } + rect.set({ width: Math.abs(dx), height: Math.abs(dy), + originX: dx < 0 ? 'right' : 'left', + originY: dy < 0 ? 'bottom' : 'top'}); + } + ); + }, + + drawText: function(e) { + e.preventDefault(); + return this.imageannotate.drawShape( + function(pointer) { + return new fabric.IText(__('Text'), { + top: pointer.y, + left: pointer.x, + fill: 'red', + originX: 'left', + originY: 'top', + fontFamily: 'sans-serif', + fontSize: 30 + }); + }, + function(rect, pointer, event) { + var x = rect.get('left'), y = rect.get('top'), + dx = pointer.x - x, dy = pointer.y - y; + // Use SHIFT to draw squares + if (event.shiftKey) { + dy = dx = Math.max(dx, dy); + } + rect.set({ width: Math.abs(dx), height: Math.abs(dy), + originX: dx < 0 ? 'right' : 'left', + originY: dy < 0 ? 'bottom' : 'top'}); + }, + function(shape) { + shape.on('editing:exited', function() { + if (!shape.getText()) + shape.remove(); + }); + }, + 'text' + ); + }, + + // Action buttons + biggerFont: function(e) { + e.preventDefault(); + var image_box = $('#redactor-image-box'), + img = image_box.find('img')[0], + fcanvas = $(img).data('canvas'); + $.each(fcanvas.getObjects(), function() { + if (this.get('active') && this instanceof fabric.IText) { + if (this.getSelectedText()) { + this.setSelectionStyles({ + fontSize: (this.getSelectionStyles().fontSize || this.getFontSize()) + 5 + }); + } + else { + this.setFontSize(this.getFontSize() + 5); + } + } + }); + fcanvas.renderAll(); + return false; + }, + smallerFont: function(e) { + e.preventDefault(); + var image_box = $('#redactor-image-box'), + img = image_box.find('img')[0], + fcanvas = $(img).data('canvas'); + $.each(fcanvas.getObjects(), function() { + if (this.get('active') && this instanceof fabric.IText) { + if (this.getSelectedText()) { + this.setSelectionStyles({ + fontSize: (this.getSelectionStyles().fontSize || this.getFontSize()) - 5 + }); + } + else { + this.setFontSize(this.getFontSize() - 5); + } + } + }); + fcanvas.renderAll(); + return false; + }, + + paintStroke: function(e) { + $('#annotate-set-stroke').css({'background-color': 'rgba(255,255,255,0.3)'}); + $('#annotate-set-fill').css({'background-color': 'transparent'}); + this.imageannotate.paintMode = 'stroke'; + return false; + }, + paintFill: function(e) { + $('#annotate-set-fill').css({'background-color': 'rgba(255,255,255,0.3)'}); + $('#annotate-set-stroke').css({'background-color': 'transparent'}); + this.imageannotate.paintMode = 'fill'; + return false; + }, + + setOpacity: function(e) { + e.preventDefault(); + var image_box = $('#redactor-image-box'), + img = image_box.find('img')[0], + fcanvas = $(img).data('canvas'); + $.each(fcanvas.getObjects(), function() { + if (this.get('active')) { + if (this.getOpacity() != 1) + this.setOpacity(1); + else + this.setOpacity(0.6); + } + }); + fcanvas.renderAll(); + return false; + }, + + bringForward: function(e) { + e.preventDefault(); + var image_box = $('#redactor-image-box'), + img = image_box.find('img')[0], + fcanvas = $(img).data('canvas'); + $.each(fcanvas.getObjects(), function() { + if (this.get('active')) { + this.bringForward(); + } + }); + }, + + keydown: function(e) { + var image_box = $('#redactor-image-box'), + img = image_box.find('img')[0], + fcanvas = $(img).data('canvas'); + + if (!fcanvas) + return; + + var active = fcanvas.getActiveObject(); + + // Check if editing a text element + if (active instanceof fabric.IText && active.get('isEditing')) { + // This keystroke is not for redactor + var ss = active.get('selectionStart'), + se = active.get('selectionEnd'); + active.exitEditing(); + active.enterEditing(); + active.set({ + 'selectionStart': ss, + 'selectionEnd': se + }); + if (e.type == 'keydown') + active.onKeyDown(e); + else + active.onKeyPress(e); + return false; + } + + // Check if [delete] was pressed with selected objects + if (e.keyCode == 8 || e.keyCode == 46) + return this.imageannotate.discard(e); + else if (e.keyCode == 90 && (e.metaKey || e.ctrlKey)) { + fcanvas.loadFromJSON(atob($(img).attr('data-annotations'))); + return false; + } + }, + + discard: function(e) { + var image_box = $('#redactor-image-box', this.$editor), + img = image_box && image_box.find('img')[0], + fcanvas = img && $(img).data('canvas'); + + if (!fcanvas) + // Not annotating + return; + + e.preventDefault(); + this.imageannotate.setBuffer(); + $.each(fcanvas.getObjects(), function() { + if (this.get('active')) + this.remove(); + }); + fcanvas.renderAll(); + return false; + }, + + commit: function(e) { + e.preventDefault(); + var redactor = this, + image_box = $('#redactor-image-box'), + img = image_box.find('img')[0], + $img = $(img), + fcanvas = $(img).data('canvas'); + fcanvas.deactivateAll(); + + // Upload to server + redactor.buffer.set(); + var annotated = fcanvas.toDataURL({ + format: 'jpg', quality: 4, + multiplier: 1/fcanvas.getZoom() + }), + file = new Blob([annotated], {type: 'image/jpeg'}); + + // Fallback to the data URL — show while the image is being uploaded + var origSrc = $img.attr('src'); + $img.attr('src', annotated); + + var origCallback = redactor.opts.imageUploadCallback, + origErrorCbk = redactor.opts.imageUploadErrorCallback; + + // After successful upload, replace the old image with the new one. + // Transfer the annotation state to the new image for replay. + redactor.opts.imageUploadCallback = function(image, json) { + redactor.opts.imageUploadCallback = origCallback; + redactor.opts.imageUploadErrorCallback = origErrorCbk; + // Transfer the annotation JSON data and drop the original image. + image.attr('data-annotations', $img.attr('data-annotations')); + // Record the image that was originally annotated. If the committed + // image is annotated again, it should be the original image with + // the annotations placed live on the original image. The image + // being committed here will be discarded. + image.attr('data-orig-annotated-image-src', + $img.attr('data-orig-annotated-image-src') || origSrc + ); + $img.remove(); + // Redactor will add <br> before and after the image in linebreaks + // mode + var N = image.next(); + if (N.is('br')) N.remove(); + var P = image.prev(); + if (N.is('br')) P.remove(); + }; + + // Handle upload issues + redactor.opts.imageUploadErrorCallback = function(json) { + redactor.opts.imageUploadCallback = origCallback; + redactor.opts.imageUploadErrorCallback = origErrorCbk; + $img.show(); + }; + redactor.imageannotate.teardownAnnotate(image_box); + $img.css({opacity: 0.5}); + redactor.upload.directUpload(file, e); + return false; + }, + + // Utils + resizeShape: function(o) { + var shape = o.target; + if (shape instanceof fabric.Ellipse) { + shape.set({ + rx: shape.get('rx') * shape.get('scaleX'), + ry: shape.get('ry') * shape.get('scaleY'), + scaleX: 1, + scaleY: 1 + }); + } + else if (shape instanceof fabric.Rect) { + shape.set({ + width: shape.get('width') * shape.get('scaleX'), + height: shape.get('height') * shape.get('scaleY'), + scaleX: 1, + scaleY: 1 + }); + } + }, + setBuffer: function() { + var image_box = $('#redactor-image-box'), + img = image_box.find('img')[0], + $img = $(img), + fcanvas = $img.data('canvas'), + state = fcanvas.toObject(); + // Capture current annotations + delete state.backgroundImage; + $img.attr('data-annotations', btoa(JSON.stringify(state))); + }, + + // Startup + + initCanvas: function(img) { + var self = this, + plugin = this.imageannotate, + $img = $(img); + if ($img.data('canvas')) + return; + var box = $img.parent(), + canvas = $('<canvas>').css({ + position: 'absolute', + top: 0, bottom: 0, left: 0, right: 0, + width: '100%', height: '100%' + }).appendTo(box), + fcanvas = new fabric.Canvas(canvas[0], { + backgroundColor: 'rgba(0,0,0,0,0)', + containerClass: 'no-margin', + includeDefaultValues: false, + }), + previous = $(img).attr('data-annotations'); + + // Catch [delete] key and map to delete object + self.opts.keydownCallback = plugin.keydown.bind(self); + self.opts.keyupCallback = plugin.keydown.bind(self); + + var I = new Image(), scale; + I.src = $img.attr('src'); + // Use a maximum zoom-out of 0.7, so that very large pictures do not + // result in unusually small annotations (esp. stroke widths which are + // not adjustable). + scale = Math.max(0.7, $img.width() / I.width); + var scaleWidth = $img.width() / scale, + scaleHeight = $img.height() / scale; + console.log(I.width, scaleWidth, $img.width(), scale); + fcanvas + .setDimensions({width: $img.width(), height: $img.height()}) + .setZoom(scale) + .setBackgroundImage( + $img.attr('data-orig-annotated-image-src') || $img.attr('src'), + fcanvas.renderAll.bind(fcanvas), { + width: scaleWidth, + height: scaleHeight, + // Needed to position overlayImage at 0/0 + originX: 'left', + originY: 'top' + }) + .on('object:scaling', plugin.resizeShape.bind(self)); + if (previous) { + fcanvas.loadFromJSON(atob(previous)); + fcanvas.forEachObject(function(o) { + o.set({ + transparentCorners: false, + borderColor: 'rgba(102,153,255,0.9)', + cornerColor: 'rgba(102,153,255,0.5)', + cornerSize: 10 + }); + }); + } + $img.data('canvas', fcanvas).addClass('hidden'); + return fcanvas; + } + }; +}; diff --git a/js/redactor.min.js b/js/redactor.min.js index 32e661ee98ae716d7c3629e8cbfbf27d365edabc..dec48cf1451db171eea9b5c2c063671eb3b1dff8 100644 --- a/js/redactor.min.js +++ b/js/redactor.min.js @@ -1,6 +1,6 @@ /* - Redactor v9.2.4 - Updated: May 15, 2014 + Redactor v10.0.5 + Updated: November 18, 2014 http://imperavi.com/redactor/ @@ -8,5 +8,7 @@ License: http://imperavi.com/redactor/license/ Usage: $('#content').redactor(); -*/ -eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(B($){q 7z=0;"lI lJ";q cp=B(O){c[0]=O.lO;c[1]=O.jP;c.O=O;F c};cp.5g.iv=B(){F c[0]===c[1]};q 8s=/5C?:\\/\\/(?:[0-9A-Z-]+\\.)?(?:lN\\.be\\/|bU\\.6V\\S*[^\\w\\-\\s])([\\w\\-]{11})(?=[^\\w\\-]|$)(?![?=&+%\\w.-]*(?:[\'"][^<>]*>|<\\/a>))[?=&+%\\w.-]*/ig;q 8x=/5C?:\\/\\/(bg\\.)?bN.6V\\/(\\d+)($|\\/)/;$.fn.U=B(3Q){q 1p=[];q jW=fk.5g.k0.5B(hj,1);if(1E 3Q==="8O"){c.1u(B(){q 6H=$.1a(c,"U");if(1E 6H!=="1I"&&$.72(6H[3Q])){q aA=6H[3Q].cx(6H,jW);if(aA!==1I&&aA!==6H){1p.3a(aA)}}I{F $.3V(\'m5 lL 5w "\'+3Q+\'" 3w 3G\')}})}I{c.1u(B(){if(!$.1a(c,"U")){$.1a(c,"U",3G(c,3Q))}})}if(1p.1m===0){F c}I{if(1p.1m===1){F 1p[0]}I{F 1p}}};B 3G(el,3Q){F 2a 3G.5g.7B(el,3Q)}$.3G=3G;$.3G.lK="9.2.4";$.3G.C={4a:E,1Q:E,4j:E,1f:E,1y:"en",63:"lE",4R:E,8u:E,fI:E,kq:N,gl:N,h0:N,kj:E,do:N,kl:N,bV:N,d5:E,jU:E,5L:N,2j:E,7y:E,4K:N,7R:E,ch:E,6p:{"3k+m, 4E+m":"c.22(\'kz\', E)","3k+b, 4E+b":"c.22(\'3q\', E)","3k+i, 4E+i":"c.22(\'3r\', E)","3k+h, 4E+h":"c.22(\'fh\', E)","3k+l, 4E+l":"c.22(\'fo\', E)","3k+k, 4E+k":"c.an()","3k+8E+7":"c.22(\'8f\', E)","3k+8E+8":"c.22(\'82\', E)"},ji:{"3k+3":"c.22(\'kz\', E)"},7p:E,9N:60,e6:E,7I:"9W://",jE:E,6N:50,eQ:E,8c:"9a",7k:E,fr:N,kF:N,3Z:E,ba:"26",hX:N,7N:E,dF:"26",9l:N,cJ:E,cB:["T/le","T/kP","T/kN"],5p:E,3E:E,4F:N,5F:N,eX:N,ag:E,fv:N,3d:E,g8:["6c","3q","3r","5j","5V","6u","6W","5S"],1A:N,64:E,8w:X,a3:0,b4:E,8P:E,gq:E,gA:N,42:["o","6c","3q","3r","5j","5V","6u","6W","5S","T","3C","26","1n","1s","9Y","|","8b"],bz:[],aB:["5j","3r","3q","4W","5V","6u","dv","dx","dk","dK","1n"],eF:{b:"3q",43:"3q",i:"3r",em:"3r",56:"5j",5J:"5j",2q:"5V",ol:"6u",u:"4W",3h:"1n",1g:"1n",1n:"1n"},gB:["p","2h","2r","h1","h2","h3","h4","h5","h6"],1N:E,6a:N,aP:N,6P:N,68:E,6O:E,fD:E,8e:E,5G:E,7M:["o","aK","1s","2v","4E","3s","1o","lH"],5X:"43",5Y:"em",aJ:20,3J:[],7Y:[],6z:E,5a:"<p>&#aY;</p>",2i:"&#aY;",dJ:/^(P|H[1-6]|3f|b2|bi|b6|b8|am|ao)$/i,5r:["P","kG","l9","l0","hZ","hu","hF","hN","hK","jm","8J","6i","3L","jw","dP","b2","bi","b6","b8","am","ao"],dU:["gj","2v","aK","hr","i?2Z","1s","4E","m8","1o","3s","1n","7L","3X","cg"],dM:["li","dt","dt","h[1-6]","47","3s"],jb:["2h","12","dl","ga","2s","lj","gk","ol","p","2r","3n","1g","eN","3h","2q"],ac:["P","kG","l9","l0","hZ","hu","hF","hN","hK","jm","8J","3f","3L","jw","dP","6w","b2","bi","b6","b8","am","ao","6i"],jj:{en:{o:"kc",3C:"6C iY",T:"6C iX",1n:"bA",1s:"j3",eJ:"6C 1s",fU:"jx 1s",67:"lD",6c:"lC",jf:"lB Y",jg:"lF",2o:"iZ",hT:"8q 1",hS:"8q 2",hP:"8q 3",hG:"8q 4",hw:"8q 5",3q:"lR",3r:"lS",m3:"m2 jn",m4:"lA jn",5V:"m6 jq",6u:"m1 jq",6W:"lg",5S:"lf",6I:"ll",4u:"6C",83:"ln",ih:"8o",dS:"6C bA",dX:"8L bJ lw",ea:"8L bJ lu",ec:"8L bG iR",e3:"8L bG iW",cY:"8o bG",cX:"8o bJ",cW:"8o bA",ae:"lp",ap:"lr",dD:"8L j1",d9:"8o j1",1c:"ls",io:"nB",3o:"n6",1t:"iR",4I:"iW",6D:"iB",hW:"iX n5 j3",Y:"n4",er:"n3",n7:"hC",ht:"iY n8 iZ",26:"6C nb",8r:"iz",na:"n9",dR:"n2",iF:"n1 dR",iD:"mV 26 mU",du:"iM Y iL iK 1t",ds:"iB Y",dj:"iM Y iL iK 4I",ei:"mT Y",8b:"6C mS mW",5j:"mX",n0:"mZ",dA:"mY 1s in 2a 53",4W:"nc",9Y:"nd",dI:"nu (nt)",84:"jx"}}};3G.fn=$.3G.5g={2O:{9D:8,d3:46,ev:40,b3:13,eA:27,fF:9,nr:17,nq:91,nv:37,gd:91},7B:B(el,3Q){c.85=E;c.$2g=c.$1v=$(el);c.7z=7z++;q C=$.4H(N,{},$.3G.C);c.C=$.4H({},C,c.$2g.1a(),3Q);c.2u=N;c.nx=[];c.aF=c.$1v.1f("21");c.nA=c.$1v.1f("2l");if(c.C.4j){c.C.1Q=N}if(c.C.1N){c.C.6a=E}if(c.C.6a){c.C.1N=E}if(c.C.b4){c.C.64=N}c.X=X;c.48=48;c.5M=E;c.gL=2a 2L("^<(/?"+c.C.dU.5U("|/?")+"|"+c.C.dM.5U("|")+")[ >]");c.gI=2a 2L("^<(br|/?"+c.C.dU.5U("|/?")+"|/"+c.C.dM.5U("|/")+")[ >]");c.cF=2a 2L("^</?("+c.C.jb.5U("|")+")[ >]");c.a7=2a 2L("^("+c.C.ac.5U("|")+")$","i");if(c.C.1N===E){if(c.C.5G!==E){q dh=["43","em","56"];q j8=["b","i","5J"];if($.4L("p",c.C.5G)==="-1"){c.C.5G.3a("p")}3w(i in dh){if($.4L(dh[i],c.C.5G)!="-1"){c.C.5G.3a(j8[i])}}}if(c.C.7M!==E){q 3Y=$.4L("p",c.C.7M);if(3Y!=="-1"){c.C.7M.9r(3Y,3Y)}}}if(c.1C("3t")||c.1C("8S")){c.C.42=c.lb(c.C.42,"8b")}c.C.1F=c.C.jj[c.C.1y];$.4H(c.C.6p,c.C.ji);c.gV();c.ks()},fQ:B(1y){F{o:{1c:1y.o,1H:"cA"},6c:{1c:1y.6c,1H:"2N",1P:{p:{1c:1y.jf,1H:"5i"},2h:{1c:1y.jg,1H:"bR",2U:"ny"},2r:{1c:1y.2o,1H:"5i",2U:"np"},h1:{1c:1y.hT,1H:"5i",2U:"no"},h2:{1c:1y.hS,1H:"5i",2U:"m9"},h3:{1c:1y.hP,1H:"5i",2U:"ng"},h4:{1c:1y.hG,1H:"5i",2U:"nf"},h5:{1c:1y.hw,1H:"5i",2U:"ne"}}},3q:{1c:1y.3q,2p:"3q"},3r:{1c:1y.3r,2p:"3r"},5j:{1c:1y.5j,2p:"fC"},4W:{1c:1y.4W,2p:"4W"},5V:{1c:"∋ "+1y.5V,2p:"82"},6u:{1c:"1. "+1y.6u,2p:"8f"},6W:{1c:"< "+1y.6W,1H:"dz"},5S:{1c:"> "+1y.5S,1H:"dr"},T:{1c:1y.T,1H:"kJ"},3C:{1c:1y.3C,1H:"kC"},26:{1c:1y.26,1H:"kL"},1n:{1c:1y.1n,1H:"2N",1P:{dS:{1c:1y.dS,1H:"l4"},nj:{2n:"aj"},dX:{1c:1y.dX,1H:"lc"},ea:{1c:1y.ea,1H:"la"},ec:{1c:1y.ec,1H:"kT"},e3:{1c:1y.e3,1H:"kR"},nn:{2n:"aj"},dD:{1c:1y.dD,1H:"l8"},d9:{1c:1y.d9,1H:"d8"},nm:{2n:"aj"},cY:{1c:1y.cY,1H:"kW"},cX:{1c:1y.cX,1H:"kV"},cW:{1c:1y.cW,1H:"l6"}}},1s:{1c:1y.1s,1H:"2N",1P:{1s:{1c:1y.eJ,1H:"an"},67:{1c:1y.67,2p:"67"}}},9Y:{1c:1y.9Y,1H:"2N",1P:{dv:{1c:1y.du,1H:"dQ"},dx:{1c:1y.ds,1H:"dG"},dk:{1c:1y.dj,1H:"dT"},dK:{1c:1y.ei,1H:"dL"}}},dv:{1c:1y.du,1H:"dQ"},dx:{1c:1y.ds,1H:"dG"},dk:{1c:1y.dj,1H:"dT"},nk:{1c:1y.ei,1H:"dL"},8b:{2p:"fX",1c:1y.8b}}},1e:B(1G,6t,1a){q 1e=c.C[1G+"mQ"];if($.72(1e)){if(6t===E){F 1e.5B(c,1a)}I{F 1e.5B(c,6t,1a)}}I{F 1a}},mo:B(){gf(c.9N);$(48).3z(".U");c.$1v.3z("U-5R");c.$2g.3z(".U").mn("U");q o=c.2R();if(c.C.6z){c.$2A.2E(c.$1v);c.$2A.1w();c.$1v.1p(o).2N()}I{q $1B=c.$K;if(c.C.1Q){$1B=c.$2g}c.$2A.2E($1B);c.$2A.1w();$1B.3e("4e").3e("fP").2C("3F").o(o).2N()}if(c.C.8P){$(c.C.8P).o("")}if(c.C.3d){$("#gr"+c.7z).1w()}},mm:B(){F $.4H({},c)},ml:B(){F c.$K},mq:B(){F c.$2A},mj:B(){F(c.C.1Q)?c.$2Z:E},mc:B(){F(c.$1A)?c.$1A:E},2R:B(){F c.$1v.1p()},l1:B(){c.$K.2C("3F").2C("6m");q o=c.49(c.$2Z.1W().4k());c.$K.1i({3F:N,6m:c.C.63});F o},7x:B(o,a9,eC){o=o.3T();o=o.G(/\\$/g,"$");if(c.C.4j){c.kX(o)}I{c.kS(o,a9)}if(o==""){eC=E}if(eC!==E){c.fB()}},kS:B(o,a9){if(a9!==E){o=c.bt(o);o=c.7S(o);o=c.de(o);o=c.ax(o,N);if(c.C.1N===E){o=c.db(o)}I{o=o.G(/<p(.*?)>([\\w\\W]*?)<\\/p>/gi,"$2<br>")}}o=o.G(/&ab;#36;/g,"$");o=c.e5(o);c.$K.o(o);c.7J();c.aN();c.1j()},kX:B(o){q 3y=c.bm();c.$2Z[0].3l="me:mf";o=c.de(o);o=c.ax(o);o=c.79(o);3y.b1();3y.gw(o);3y.g5();if(c.C.4j){c.$K=c.$2Z.1W().1b("2v").1i({3F:N,6m:c.C.63})}c.7J();c.aN();c.1j()},cz:B(o){c.7A=o.1S(/^<\\!l3[^>]*>/i);if(c.7A&&c.7A.1m==1){o=o.G(/^<\\!l3[^>]*>/i,"")}o=c.bt(o,N);o=c.db(o);o=c.e5(o);c.$K.o(o);c.7J();c.aN();c.1j()},k1:B(){if(c.7A&&c.7A.1m==1){q 1v=c.7A[0]+"\\n"+c.$1v.1p();c.$1v.1p(1v)}},aN:B(){q 93=c.$K.1b("V");q 6G="4o";$.1u(93,B(){q au=c.ka;q 5Q=2a 2L("<"+c.Q,"gi");q 5A=au.G(5Q,"<"+6G);5Q=2a 2L("</"+c.Q,"gi");5A=5A.G(5Q,"</"+6G);$(c).2f(5A)})},aV:B(o){o=o.G(/<V(.*?)>/,"<4o$1>");F o.G(/<\\/V>/,"</4o>")},7J:B(){c.$K.1b(".mi").1i("3F",E)},1j:B(e){q o="";c.gy();if(c.C.4j){o=c.l1()}I{o=c.$K.o()}o=c.bF(o);o=c.cb(o);q 1v=c.79(c.$1v.1p(),E);q K=c.79(o,E);if(1v==K){F E}o=o.G(/<\\/li><(2q|ol)>([\\w\\W]*?)<\\/(2q|ol)>/gi,"<$1>$2</$1></li>");if($.28(o)==="<br>"){o=""}if(c.C.jU){q jT=["br","hr","1z","1s","2S","4E"];$.1u(jT,B(i,s){o=o.G(2a 2L("<"+s+"(.*?[^/$]?)>","gi"),"<"+s+"$1 />")})}o=c.1e("mu",E,o);c.$1v.1p(o);c.k1();c.1e("mv",E,o);if(c.2u===E){if(1E e!="1I"){mK(e.6h){9O 37:8h;9O 38:8h;9O 39:8h;9O 40:8h;mJ:c.1e("5W",E,o)}}I{c.1e("5W",E,o)}}},bF:B(o){if(!c.C.4j){o=c.7S(o)}o=$.28(o);o=c.fS(o);o=o.G(/&#aY;/gi,"");o=o.G(/&#mI;/gi,"");o=o.G(/<\\/a>&3u;/gi,"</a> ");o=o.G(/\\7m/g,"");if(o=="<p></p>"||o=="<p> </p>"||o=="<p>&3u;</p>"){o=""}if(c.C.jE){o=o.G(/<a(.*?)4h="jI"(.*?)>/gi,"<a$1$2>");o=o.G(/<a(.*?)>/gi,\'<a$1 4h="jI">\')}o=o.G("<!--?4P","<?4P");o=o.G("?-->","?>");o=o.G(/<(.*?)1x="k4"(.*?) 3F="E"(.*?)>/gi,\'<$mL="k4"$2$3>\');o=o.G(/ 1a-7Z=""/gi,"");o=o.G(/<br\\s?\\/?>\\n?<\\/(P|H[1-6]|3f|b2|bi|b6|b8|am|ao)>/gi,"</$1>");o=o.G(/<V(.*?)id="U-T-2A"(.*?)>([\\w\\W]*?)<1z(.*?)><\\/V>/gi,"$3<1z$4>");o=o.G(/<V(.*?)id="U-T-da"(.*?)>(.*?)<\\/V>/gi,"");o=o.G(/<V(.*?)id="U-T-d6"(.*?)>(.*?)<\\/V>/gi,"");o=o.G(/<(2q|ol)>\\s*\\t*\\n*<\\/(2q|ol)>/gi,"");if(c.C.bV){o=o.G(/<2F(.*?)>([\\w\\W]*?)<\\/2F>/gi,"$2")}o=o.G(/<V(.*?)>([\\w\\W]*?)<\\/V>/gi,"$2");o=o.G(/<4o>/gi,"<V>");o=o.G(/<4o /gi,"<V ");o=o.G(/<\\/4o>/gi,"</V>");o=o.G(/<V(.*?)1x="57"(.*?)>([\\w\\W]*?)<\\/V>/gi,"");o=o.G(/<1z(.*?)3F="E"(.*?)>/gi,"<1z$1$2>");o=o.G(/&/gi,"&");o=o.G(/\\mM/gi,"&mP;");o=o.G(/\\mO/gi,"&mN;");o=o.G(/\\mG/gi,"&mF;");o=o.G(/\\mz/gi,"&my;");o=o.G(/\\mx/gi,"&mw;");o=c.gM(o);F o},ks:B(){c.3I="";c.$2A=$(\'<12 1x="mE" />\');if(c.$1v[0].Q==="mD"){c.C.6z=N}if(c.C.kq===E&&c.5c()){c.k9()}I{c.k6();if(c.C.1Q){c.C.4K=E;c.5n()}I{if(c.C.6z){c.kb()}I{c.kg()}}if(!c.C.1Q){c.cK();c.cm()}}},k9:B(){if(!c.C.6z){c.$K=c.$1v;c.$K.2T();c.$1v=c.b0(c.$K);c.$1v.1p(c.3I)}c.$2A.aG(c.$1v).1h(c.$1v)},k6:B(){if(c.C.6z){c.3I=$.28(c.$1v.1p())}I{c.3I=$.28(c.$1v.o())}},kb:B(){c.$K=$("<12 />");c.$2A.aG(c.$1v).1h(c.$K).1h(c.$1v);c.kd(c.$K);c.ci()},kg:B(){c.$K=c.$1v;c.$1v=c.b0(c.$K);c.$2A.aG(c.$K).1h(c.$K).1h(c.$1v);c.ci()},b0:B($1v){F $("<5R />").1i("2n",$1v.1i("id")).1f("21",c.aF)},kd:B(el){$.1u(c.$1v.2R(0).2U.4i(/\\s+/),B(i,s){el.2y("nh"+s)})},ci:B(){c.$K.2y("4e").1i({3F:N,6m:c.C.63});c.$1v.1i("6m",c.C.63).2T();c.7x(c.3I,N,E)},cK:B(){q $1v=c.$K;if(c.C.1Q){$1v=c.$2Z}if(c.C.7y){$1v.1i("7y",c.C.7y)}if(c.C.7R){$1v.1f("fO-21",c.C.7R+"px")}I{if(c.1C("3c")&&c.C.1N){c.$K.1f("fO-21","mC")}}if(c.1C("3c")&&c.C.1N){c.$K.1f("95-i0","9a")}if(c.C.ch){c.C.4K=E;c.aF=c.C.ch}if(c.C.fI){c.$K.2y("fP")}if(c.C.8u){c.$K.2y("U-K-8u")}if(!c.C.4K){$1v.1f("21",c.aF)}},cm:B(){c.2u=E;if(c.C.1A){c.C.1A=c.fQ(c.C.1F);c.g6()}c.iu();c.gW();c.cU();if(c.C.7p){c.7p()}2W($.M(c.7D,c),4);if(c.1C("3c")){bK{c.X.22("mB",E,E);c.X.22("mA",E,E)}bI(e){}}if(c.C.2j){2W($.M(c.2j,c),3P)}if(!c.C.5L){2W($.M(B(){c.C.5L=N;c.cA(E)},c),5l)}c.1e("7B")},cU:B(){c.89=0;if(c.C.fr&&(c.C.3Z!==E||c.C.5p!==E)){c.$K.on("6y.U",$.M(c.g2,c))}c.$K.on("25.U",$.M(B(){c.5O=E},c));c.$K.on("2S.U",$.M(c.1j,c));c.$K.on("aW.U",$.M(c.gc,c));c.$K.on("5y.U",$.M(c.g9,c));c.$K.on("58.U",$.M(c.fs,c));if($.72(c.C.fi)){c.$1v.on("5y.U-5R",$.M(c.C.fi,c))}if($.72(c.C.fy)){c.$K.on("2j.U",$.M(c.C.fy,c))}q aq;$(X).8U(B(e){aq=$(e.1O)});c.$K.on("bO.U",$.M(B(e){if(!$(aq).3v("bs")&&$(aq).8y(".bs").1U()==0){c.5O=E;if($.72(c.C.mH)){c.1e("bO",e)}}},c))},g2:B(e){e=e.go||e;if(48.eP===1I||!e.8T){F N}q 1m=e.8T.7d.1m;if(1m==0){F N}e.2x();q 26=e.8T.7d[0];if(c.C.cB!==E&&c.C.cB.3W(26.1G)==-1){F N}c.1Z();c.8I();if(c.C.5p===E){c.ey(c.C.3Z,26,N,e,c.C.ba)}I{c.e2(26)}},gc:B(e){q bn=E;if(c.1C("4C")&&6k.7i.3W("mg")===-1){q 2M=c.1C("9y").4i(".");if(2M[0]<mh){bn=N}}if(bn){F N}if(c.1C("8S")){F N}if(c.C.9l&&c.gv(e)){F N}if(c.C.gl){c.85=N;c.2e();if(!c.5O){if(c.C.4K===N&&c.cl!==N){c.$K.21(c.$K.21());c.aX=c.X.2v.3g}I{c.aX=c.$K.3g()}}q 4f=c.cE();2W($.M(B(){q gE=c.cE();c.$K.1h(4f);c.1Y();q o=c.hR(gE);c.kk(o);if(c.C.4K===N&&c.cl!==N){c.$K.1f("21","4d")}},c),1)}},gv:B(e){q 6t=e.go||e;c.gm=E;if(1E(6t.eL)==="1I"){F E}if(6t.eL.gz){q 26=6t.eL.gz[0].ma();if(26!==2J){c.1Z();c.gm=N;q es=2a mb();es.jt=$.M(c.jK,c);es.md(26);F N}}F E},g9:B(e){if(c.85){F E}q 1k=e.6h;q 3k=e.aw||e.8K;q L=c.2B();q 1r=c.3S();q 1l=c.2P();q 2r=E;c.1e("5y",e);if(c.1C("3c")&&"ej"in 48.29()){if((3k)&&(e.2O===37||e.2O===39)){q 1J=c.29();q ex=(e.8K?"9v":"mk");if(e.2O===37){1J.ej("4H","1t",ex);if(!e.5d){1J.he()}}if(e.2O===39){1J.ej("4H","4I",ex);if(!e.5d){1J.mr()}}e.2x()}}c.62(E);if((L&&$(L).2R(0).Q==="6w")||(1r&&$(1r).2R(0).Q==="6w")){2r=N;if(1k===c.2O.ev){c.6Q(1l)}}if(1k===c.2O.ev){if(L&&$(L)[0].Q==="3L"){c.6Q(L)}if(1r&&$(1r)[0].Q==="3L"){c.6Q(1r)}if(L&&$(L)[0].Q==="P"&&$(L).L()[0].Q=="3L"){c.6Q(L,$(L).L()[0])}if(1r&&$(1r)[0].Q==="P"&&L&&$(L)[0].Q=="3L"){c.6Q(1r,L)}}c.6p(e,1k);if(3k&&1k===90&&!e.5d&&!e.gh){e.2x();if(c.C.3J.1m){c.jN()}I{c.X.22("mt",E,E)}F}I{if(3k&&1k===90&&e.5d&&!e.gh){e.2x();if(c.C.7Y.1m!=0){c.jO()}I{c.X.22("mp",E,E)}F}}if(1k==32){c.1Z()}if(3k&&1k===65){c.1Z();c.5O=N}I{if(1k!=c.2O.gd&&!3k){c.5O=E}}if(1k==c.2O.b3&&!e.5d&&!e.aw&&!e.8K){q O=c.3m();if(O&&O.4M===E){1q=c.29();if(1q.51){O.ay()}}if(c.1C("3t")&&(L.4v==1&&(L.Q=="6i"||L.Q=="mR"))){e.2x();c.1Z();c.3A(X.4y("br"));c.1e("6E",e);F E}if(1l&&(1l.Q=="3L"||$(1l).L()[0].Q=="3L")){if(c.cR()){if(c.89==1){q 2g;q 2X;if(1l.Q=="3L"){2X="br";2g=1l}I{2X="p";2g=$(1l).L()[0]}e.2x();c.cf(2g);c.89=0;if(2X=="p"){$(1l).L().1b("p").2X().1w()}I{q 2H=$.28($(1l).o());$(1l).o(2H.G(/<br\\s?\\/?>$/i,""))}F}I{c.89++}}I{c.89++}}if(2r===N){F c.fT(e,1r)}I{if(!c.C.1N){if(1l&&1l.Q=="3f"){q 5E=c.2P();if(5E!==E||5E.Q==="3f"){q aC=$.28($(1l).Y());q gN=$.28($(5E).Y());if(aC==""&&gN==""&&$(5E).4l("li").1U()==0&&$(5E).8y("li").1U()==0){c.1Z();q $30=$(5E).2c("ol, 2q");$(5E).1w();q J=$("<p>"+c.C.2i+"</p>");$30.2E(J);c.4b(J);c.1j();c.1e("6E",e);F E}}}if(1l&&c.C.dJ.4c(1l.Q)){c.1Z();2W($.M(B(){q 55=c.2P();if(55.Q==="8J"&&!$(55).3v("4e")){q J=$("<p>"+c.C.2i+"</p>");$(55).2f(J);c.4b(J)}},c),1)}I{if(1l===E){c.1Z();q J=$("<p>"+c.C.2i+"</p>");c.3A(J[0]);c.4b(J);c.1e("6E",e);F E}}}if(c.C.1N){if(1l&&c.C.dJ.4c(1l.Q)){c.1Z();2W($.M(B(){q 55=c.2P();if((55.Q==="8J"||55.Q==="P")&&!$(55).3v("4e")){c.ko(55)}},c),1)}I{F c.ef(e)}}if(1l.Q=="3L"||1l.Q=="dP"){F c.ef(e)}}c.1e("6E",e)}I{if(1k===c.2O.b3&&(e.aw||e.5d)){c.1Z();e.2x();c.aD()}}if((1k===c.2O.fF||e.8K&&1k===gH)&&c.C.6p){F c.fx(e,2r,1k)}if(1k===c.2O.9D){c.fW(e,1r,L)}},fT:B(e,1r){e.2x();c.1Z();q o=$(1r).L().Y();c.3A(X.8d("\\n"));if(o.4G(/\\s$/)==-1){c.3A(X.8d("\\n"))}c.1j();c.1e("6E",e);F E},fx:B(e,2r,1k){if(!c.C.fv){F N}if(c.a4(c.2R())&&c.C.ag===E){F N}e.2x();if(2r===N&&!e.5d){c.1Z();c.3A(X.8d("\\t"));c.1j();F E}I{if(c.C.ag!==E){c.1Z();c.3A(X.8d(fk(c.C.ag+1).5U("\\nz")));c.1j();F E}I{if(!e.5d){c.dr()}I{c.dz()}}}F E},fW:B(e,1r,L){if(L&&1r&&L.4Q.Q=="6i"&&L.Q=="fJ"&&1r.Q=="3f"&&$(L).4k("li").1U()==1){q Y=$(1r).Y().G(/[\\7m-\\hk\\hm]/g,"");if(Y==""){q J=L.4Q;$(L).1w();c.4b(J);c.1j();F E}}if(1E 1r.Q!=="1I"&&/^(H[1-6])$/i.4c(1r.Q)){q J;if(c.C.1N===E){J=$("<p>"+c.C.2i+"</p>")}I{J=$("<br>"+c.C.2i)}$(1r).2f(J);c.4b(J);c.1j()}if(1E 1r.aZ!=="1I"&&1r.aZ!==2J){if(1r.1w&&1r.4v===3&&1r.aZ.1S(/[^\\7m]/g)==2J){$(1r).4Z().1w();c.1j()}}},ef:B(e){c.1Z();e.2x();c.aD();c.1e("6E",e);F},fs:B(e){if(c.85){F E}q 1k=e.6h;q L=c.2B();q 1r=c.3S();if(!c.C.1N&&1r.4v==3&&(L==E||L.Q=="bp")){q J=$("<p>").1h($(1r).6f());$(1r).2f(J);q 4l=$(J).4l();if(1E(4l[0])!=="1I"&&4l[0].Q=="cP"){4l.1w()}c.7e(J)}if((c.C.6P||c.C.68||c.C.6O)&&1k===c.2O.b3){c.gS()}if(1k===c.2O.d3||1k===c.2O.9D){F c.gX(e)}c.1e("58",e);c.1j(e)},gS:B(){c.c6(c.C.7I,c.C.6P,c.C.68,c.C.6O,c.C.6N);2W($.M(B(){if(c.C.68){c.4F()}if(c.C.5F){c.5F()}},c),5)},gW:B(){if(!c.C.e6){F}$.1u(c.C.e6,$.M(B(i,s){if(df[s]){$.4H(c,df[s]);if($.72(df[s].7B)){c.7B()}}},c))},5n:B(){c.gu();if(c.C.6z){c.fg(c.$1v)}I{c.$eZ=c.$1v.2T();c.$1v=c.b0(c.$eZ);c.fg(c.$eZ)}},fg:B(el){c.$1v.1i("6m",c.C.63).2T();c.$2A.aG(el).1h(c.$2Z).1h(c.$1v)},gu:B(){c.$2Z=$(\'<1Q 1o="2l: 3P%;" c2="0" />\').8Z("iJ",$.M(B(){if(c.C.4j){c.bm();if(c.3I===""){c.3I=c.C.2i}c.$2Z.1W()[0].gw(c.3I);c.$2Z.1W()[0].g5();q gG=hc($.M(B(){if(c.$2Z.1W().1b("2v").o()){gf(gG);c.cG()}},c),0)}I{c.cG()}},c))},bM:B(){F c.$2Z[0].dp.X},bm:B(){q 3y=c.bM();if(3y.9L){3y.lM(3y.9L)}F 3y},cI:B(1f){1f=1f||c.C.1f;if(c.iE(1f)){c.$2Z.1W().1b("aK").1h(\'<1s 4h="ly" 1R="\'+1f+\'" />\')}if($.lP(1f)){$.1u(1f,$.M(B(i,1L){c.cI(1L)},c))}},cG:B(){c.$K=c.$2Z.1W().1b("2v").1i({3F:N,6m:c.C.63});if(c.$K[0]){c.X=c.$K[0].lh;c.48=c.X.lq||48}c.cI();if(c.C.4j){c.cz(c.$1v.1p())}I{c.7x(c.3I,N,E)}c.cK();c.cm()},gV:B(){if(c.C.4R!==E){c.bQ=c.C.4R;c.C.4R=N}I{if(1E c.$2g.1i("4R")=="1I"||c.$2g.1i("4R")==""){c.C.4R=E}I{c.bQ=c.$2g.1i("4R");c.C.4R=N}}},gO:B(o){if(c.C.4R===E){F E}if(c.a4(o)){c.C.2j=E;c.c3();c.c1();F c.c4()}I{c.c1()}F E},c3:B(){c.$K.on("2j.57",$.M(c.fp,c))},c1:B(){c.$K.on("bO.57",$.M(c.fM,c))},c4:B(){q ph=$(\'<V 1x="57">\').1a("U","8R").1i("3F",E).Y(c.bQ);if(c.C.1N===E){F $("<p>").1h(ph)}I{F ph}},fM:B(){q o=c.2R();if(c.a4(o)){c.c3();c.$K.o(c.c4())}},fp:B(){c.$K.1b("V.57").1w();q o="";if(c.C.1N===E){o=c.C.5a}c.$K.3z("2j.57");c.$K.o(o);if(c.C.1N===E){c.4b(c.$K.4k()[0])}I{c.2j()}c.1j()},fB:B(){c.$K.1b("V.57").1w();c.$K.3z("2j.57")},fS:B(o){F o.G(/<V 1x="57"(.*?)>(.*?)<\\/V>/i,"")},6p:B(e,1k){if(!c.C.6p){if((e.aw||e.8K)&&(1k===66||1k===73)){e.2x()}F E}$.1u(c.C.6p,$.M(B(4D,g1){q 52=4D.4i(",");3w(q i in 52){if(1E 52[i]==="8O"){c.fj(e,$.28(52[i]),$.M(B(){lQ(g1)},c))}}},c))},fj:B(e,52,hg){q gK={8:"lG",9:"53",10:"F",13:"F",16:"8E",17:"3k",18:"87",19:"m7",20:"m0",27:"lV",32:"6s",33:"lU",34:"lT",35:"3p",36:"lW",37:"1t",38:"lX",39:"4I",40:"lZ",45:"4u",46:"56",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",3P:"4",lY:"5",lx:"6",lk:"7",lm:"8",lz:"9",lv:"*",lo:"+",ms:"-",oz:".",qG:"/",qF:"f1",qH:"f2",qI:"f3",qJ:"f4",qE:"f5",qD:"f6",qy:"f7",qx:"f8",qz:"f9",qA:"qC",qB:"qK",qL:"qV",qU:"qW",qX:"gn",qY:"-",qT:";",qS:"=",qN:",",qM:"-",qO:".",qP:"/",qR:"`",gH:"[",qQ:"\\\\",qw:"]",qv:"\'"};q cr={"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"r0","=":"+",";":": ","\'":\'"\',",":"<",".":">","/":"?","\\\\":"|"};52=52.3N().4i(" ");q 8X=gK[e.2O],8C=4S.qb(e.6h).3N(),7w="",74={};$.1u(["87","3k","4E","8E"],B(2I,8V){if(e[8V+"qd"]&&8X!==8V){7w+=8V+"+"}});if(8X){74[7w+8X]=N}if(8C){74[7w+8C]=N;74[7w+cr[8C]]=N;if(7w==="8E+"){74[cr[8C]]=N}}3w(q i=0,l=52.1m;i<l;i++){if(74[52[i]]){e.2x();F hg.cx(c,hj)}}},2j:B(){if(!c.1C("8S")){c.48.2W($.M(c.9E,c,N),1)}I{c.$K.2j()}},4m:B(){if(c.1C("3t")){q 1T=c.X.9L.3g}c.$K.2j();if(c.1C("3t")){c.X.9L.3g=1T}},bX:B(){if(!c.1C("3c")){c.9E()}I{if(c.C.1N===E){q 2X=c.$K.4k().2X();c.$K.2j();c.7e(2X)}I{c.9E()}}},9E:B(5I,2g){c.$K.2j();if(1E 2g=="1I"){2g=c.$K[0]}q O=c.3m();O.9K(2g);O.5I(5I||E);q 1q=c.29();1q.4O();1q.5e(O)},cA:B(9Q){if(c.C.5L){c.h8(9Q)}I{c.hl()}},hl:B(){q o=c.$1v.2T().1p();if(1E c.6n!=="1I"){q 6n=c.6n.G(/\\n/g,"");q 7f=o.G(/\\n/g,"");7f=c.79(7f,E);c.6n=c.79(6n,E)!==7f}if(c.6n){if(c.C.4j&&o===""){c.cz(o)}I{c.7x(o);if(c.C.4j){c.cU()}}c.1e("5W",E,o)}if(c.C.1Q){c.$2Z.2N()}I{c.$K.2N()}if(c.C.4j){c.$K.1i("3F",N)}c.$1v.3z("5y.U-5R-h9");c.$K.2j();c.1Y();c.7D();c.gT();c.dW("o");c.C.5L=N},h8:B(9Q){if(9Q!==E){c.2e()}q 21=2J;if(c.C.1Q){21=c.$2Z.21();if(c.C.4j){c.$K.2C("3F")}c.$2Z.2T()}I{21=c.$K.gZ();c.$K.2T()}q o=c.$1v.1p();if(o!==""&&c.C.h0){c.$1v.1p(c.gF(o))}c.6n=o;c.$1v.21(21).2N().2j();c.$1v.on("5y.U-5R-h9",c.ha);c.hn();c.6M("o");c.C.5L=E},ha:B(e){if(e.2O===9){q $el=$(c);q 2u=$el.2R(0).4b;$el.1p($el.1p().a8(0,2u)+"\\t"+$el.1p().a8($el.2R(0).7e));$el.2R(0).4b=$el.2R(0).7e=2u+1;F E}},7p:B(){q bE=E;c.9N=hc($.M(B(){q o=c.2R();if(bE!==o){q 2n=c.$1v.1i("2n");$.j2({1L:c.C.7p,1G:"7X",1a:"2n="+2n+"&"+2n+"="+qe(qf(o)),4n:$.M(B(1a){q 1K=$.8G(1a);if(1E 1K.3V=="1I"){c.1e("7p",E,1K)}I{c.1e("qa",E,1K)}bE=o},c)})}},c),c.C.9N*q9)},g6:B(){if(c.5c()&&c.C.bz.1m>0){$.1u(c.C.bz,$.M(B(i,s){q 2I=c.C.42.3W(s);c.C.42.9r(2I,1)},c))}if(c.C.3d){c.C.42=c.C.g8}I{if(!c.C.gA){q 2I=c.C.42.3W("o");c.C.42.9r(2I,1)}}if(c.C.1A){$.1u(c.C.1A.6c.1P,$.M(B(i,s){if($.4L(i,c.C.gB)=="-1"){d2 c.C.1A.6c.1P[i]}},c))}if(c.C.42.1m===0){F E}c.gb();c.$1A=$("<2q>").2y("bs").1i("id","q4"+c.7z);if(c.C.8u){c.$1A.2y("U-1A-8u")}if(c.C.gq&&c.5c()){c.$1A.2y("U-1A-af")}if(c.C.3d){c.$3d=$(\'<12 1x="gg">\').1i("id","gr"+c.7z).2T();c.$3d.1h(c.$1A);$("2v").1h(c.$3d)}I{if(c.C.8P){c.$1A.2y("U-1A-q3");$(c.C.8P).o(c.$1A)}I{c.$2A.6v(c.$1A)}}$.1u(c.C.42,$.M(B(i,2z){if(c.C.1A[2z]){q 2d=c.C.1A[2z];if(c.C.7N===E&&2z==="26"){F N}c.$1A.1h($("<li>").1h(c.6X(2z,2d)))}},c));c.$1A.1b("a").1i("7y","-1");if(c.C.64){c.cV();$(c.C.8w).on("gn.U",$.M(c.cV,c))}if(c.C.aB){c.$K.on("9x.U 58.U",$.M(c.7K,c))}},cV:B(){q 3g=$(c.C.8w).3g();q 8v=0;q 1t=0;q 3p=0;if(c.C.8w===X){8v=c.$2A.2V().1T}I{8v=1}3p=8v+c.$2A.21()+40;if(3g>8v){q 2l="3P%";if(c.C.b4){1t=c.$2A.2V().1t;2l=c.$2A.hd();c.$1A.2y("g7")}c.64=N;if(c.C.8w===X){c.$1A.1f({3j:"9w",2l:2l,8Q:gp,1T:c.C.a3+"px",1t:1t})}I{c.$1A.1f({3j:"8B",2l:2l,8Q:gp,1T:(c.C.a3+3g)+"px",1t:0})}if(3g<3p){c.$1A.1f("gx","j7")}I{c.$1A.1f("gx","8F")}}I{c.64=E;c.$1A.1f({3j:"ia",2l:"4d",1T:0,1t:1t});if(c.C.b4){c.$1A.3e("g7")}}},gb:B(){if(!c.C.3d){F}c.$K.on("9x.U 58.U",c,$.M(B(e){q Y=c.9V();if(e.1G==="9x"&&Y!=""){c.eV(e)}if(e.1G==="58"&&e.5d&&Y!=""){q $fc=$(c.7U(c.29().q5)),2V=$fc.2V();2V.21=$fc.21();c.eV(2V,N)}},c))},eV:B(e,hb){if(!c.C.3d){F}q 1t,1T;$(".gg").2T();if(hb){1t=e.1t;1T=e.1T+e.21+14;if(c.C.1Q){1T+=c.$2A.3j().1T-$(c.X).3g();1t+=c.$2A.3j().1t}}I{q 2l=c.$3d.hd();1t=e.k5;if($(c.X).2l()<(1t+2l)){1t-=2l}1T=e.k7+14;if(c.C.1Q){1T+=c.$2A.3j().1T;1t+=c.$2A.3j().1t}I{1T+=$(c.X).3g()}}c.$3d.1f({1t:1t+"px",1T:1T+"px"}).2N();c.h7()},h7:B(){if(!c.C.3d){F}q 7r=$.M(B(3y){$(3y).on("8U.U",$.M(B(e){if($(e.1O).2c(c.$1A).1m===0){c.$3d.6J(3P);c.cn();$(3y).3z(e)}},c)).on("5y.U",$.M(B(e){if(e.6h===c.2O.eA){c.29().he()}c.$3d.6J(3P);$(3y).3z(e)},c))},c);7r(X);if(c.C.1Q){7r(c.X)}},9h:B(){if(!c.C.3d){F}q 7r=$.M(B(3y){$(3y).on("jB.U",$.M(B(e){if($(e.1O).2c(c.$1A).1m===0){c.$3d.6J(3P);$(3y).3z(e)}},c))},c);7r(X);if(c.C.1Q){7r(c.X)}},gU:B($1P,hf){$.1u(hf,$.M(B(2z,2d){if(!2d.2U){2d.2U=""}q $76;if(2d.2n==="aj"){$76=$(\'<a 1x="q6">\')}I{$76=$(\'<a 1R="#" 1x="\'+2d.2U+" q8"+2z+\'">\'+2d.1c+"</a>");$76.on("25",$.M(B(e){if(e.2x){e.2x()}if(c.1C("3t")){e.gP=E}if(2d.1e){2d.1e.5B(c,2z,$76,2d,e)}if(2d.2p){c.22(2d.2p,2z)}if(2d.1H){c[2d.1H](2z)}c.7K();if(c.C.3d){c.$3d.6J(3P)}},c))}$1P.1h($76)},c))},e8:B(e,1k){if(!c.C.5L){e.2x();F E}q $1D=c.4s(1k);q $1P=$1D.1a("1P").8D(X.2v);if($1D.3v("7u")){c.9t()}I{c.9t();c.1e("e8",{1P:$1P,1k:1k,1D:$1D});c.6M(1k);$1D.2y("7u");q 8H=$1D.2V();q dq=$1P.2l();if((8H.1t+dq)>$(X).2l()){8H.1t-=dq}q 1t=8H.1t+"px";q dc=$1D.gZ();q 3j="8B";q 1T=(dc+c.C.a3)+"px";if(c.C.64&&c.64){3j="9w"}I{1T=8H.1T+dc+"px"}$1P.1f({3j:3j,1t:1t,1T:1T}).2N();c.1e("q7",{1P:$1P,1k:1k,1D:$1D})}q 8W=$.M(B(e){c.e1(e,$1P)},c);$(X).8Z("25",8W);c.$K.8Z("25",8W);c.$K.8Z("qg",8W);e.qh();c.4m()},9t:B(){c.$1A.1b("a.7u").3e("8t").3e("7u");$(".gQ").2T();c.1e("e1")},e1:B(e,$1P){if(!$(e.1O).3v("7u")){$1P.3e("7u");c.9t()}},6X:B(2z,2d,gJ){q $1D=$(\'<a 1R="9I:;" 1c="\'+2d.1c+\'" 7y="-1" 1x="re-b5 re-\'+2z+\'"></a>\');if(1E gJ!="1I"){$1D.2y("U-2b-T")}$1D.on("25",$.M(B(e){if(e.2x){e.2x()}if(c.1C("3t")){e.gP=E}if($1D.3v("dm")){F E}if(c.7H()===E&&!2d.2p){c.4m()}if(2d.2p){c.4m();c.22(2d.2p,2z);c.9h()}I{if(2d.1H&&2d.1H!=="2N"){c[2d.1H](2z);c.9h()}I{if(2d.1e){2d.1e.5B(c,2z,$1D,2d,e);c.9h()}I{if(2d.1P){c.e8(e,2z)}}}}c.7K(E,2z)},c));if(2d.1P){q $1P=$(\'<12 1x="gQ qr\'+2z+\'" 1o="3i: 3o;">\');$1D.1a("1P",$1P);c.gU($1P,2d.1P)}F $1D},4s:B(1k){if(!c.C.1A){F E}F $(c.$1A.1b("a.re-"+1k))},qq:B(dV,Q){c.C.aB.3a(dV);c.C.eF[Q]=dV},fV:B(1k){q 2b=c.4s(1k);if(2b.3v("8t")){c.dW(1k)}I{c.6M(1k)}},6M:B(1k){q 2b=c.4s(1k);2b.2y("8t")},dW:B(1k){q 2b=c.4s(1k);2b.3e("8t")},fK:B(2z){c.$1A.1b("a.re-b5").ar(".re-"+2z).3e("8t")},gT:B(){c.$1A.1b("a.re-b5").ar("a.re-o").3e("dm")},hn:B(){c.$1A.1b("a.re-b5").ar("a.re-o").2y("dm")},qs:B(1k,b7){c.4s(1k).2y("re-"+b7)},qt:B(1k,b7){c.4s(1k).3e("re-"+b7)},qu:B(1k,2n){q 1D=c.4s(1k);1D.3e("U-2b-T");1D.2y("fa-U-2b");1D.o(\'<i 1x="fa \'+2n+\'"></i>\')},qp:B(1k,1c,1e,1P){if(!c.C.1A){F}q 2b=c.6X(1k,{1c:1c,1e:1e,1P:1P},N);c.$1A.1h($("<li>").1h(2b));F 2b},qo:B(1k,1c,1e,1P){if(!c.C.1A){F}q 2b=c.6X(1k,{1c:1c,1e:1e,1P:1P},N);c.$1A.6v($("<li>").1h(2b))},qj:B(g0,1k,1c,1e,1P){if(!c.C.1A){F}q 2b=c.6X(1k,{1c:1c,1e:1e,1P:1P},N);q $2b=c.4s(g0);if($2b.1U()!==0){$2b.L().2E($("<li>").1h(2b))}I{c.$1A.1h($("<li>").1h(2b))}F 2b},qi:B(fl,1k,1c,1e,1P){if(!c.C.1A){F}q 2b=c.6X(1k,{1c:1c,1e:1e,1P:1P},N);q $2b=c.4s(fl);if($2b.1U()!==0){$2b.L().3M($("<li>").1h(2b))}I{c.$1A.1h($("<li>").1h(2b))}F 2b},qk:B(1k){q $2b=c.4s(1k);$2b.1w()},7K:B(e,2z){q L=c.2B();c.fK(2z);if(e===E&&2z!=="o"){if($.4L(2z,c.C.aB)!=-1){c.fV(2z)}F}if(L&&L.Q==="A"){c.$1A.1b("a.fq").Y(c.C.1F.fU)}I{c.$1A.1b("a.fq").Y(c.C.1F.eJ)}$.1u(c.C.eF,$.M(B(1k,2t){if($(L).2c(1k,c.$K.2R()[0]).1m!=0){c.6M(2t)}},c));q $L=$(L).2c(c.C.5r.3T().3N(),c.$K[0]);if($L.1m){q 54=$L.1f("Y-54");if(54==""){54="1t"}c.6M("54"+54)}},bb:B(o){q 1q=c.29();if(1q.41&&1q.51){q O=c.3m();O.ay();q el=c.X.4y("12");el.3O=o;q 4f=c.X.cO(),J,5N;3x((J=el.8z)){5N=4f.7c(J)}q ql=4f.8z;O.3A(4f);if(5N){O=O.9p();O.9d(5N);O.5I(N)}1q.4O();1q.5e(O)}},2p:B(23,2K,1j){if(23==="c0"&&c.1C("3t")){2K="<"+2K+">"}if(23==="5b"&&c.1C("3t")){if(!c.8N()){c.4m();c.X.1J.5z().cd(2K)}I{c.bb(2K)}}I{c.X.22(23,E,2K)}if(1j!==E){c.1j()}c.1e("22",23,2K)},22:B(23,2K,1j){if(!c.C.5L){c.$1v.2j();F E}if(23==="3q"||23==="3r"||23==="4W"||23==="fC"){c.1Z()}if(23==="fh"||23==="fo"){q L=c.2B();if(L.Q==="qn"||L.Q==="qm"){c.9P(L)}}if(23==="5b"){c.9m(2K,1j);c.1e("22",23,2K);F}if(c.7s("6w")&&!c.C.fD){F E}if(23==="82"||23==="8f"){F c.fE(23,2K)}if(23==="67"){F c.fG(23,2K)}c.2p(23,2K,1j);if(23==="fX"){c.$K.1b("hr").2C("id")}},fG:B(23,2K){c.1Z();q 1s=c.7s("A");if(1s){$(1s).2f($(1s).Y());c.1j();c.1e("22",23,2K);F}},fE:B(23,2K){c.1Z();q L=c.2B();q $30=$(L).2c("ol, 2q");if(!c.4g($30)&&$30.1U()!=0){$30=E}q 1w=E;if($30&&$30.1m){1w=N;q 5q=$30[0].Q;if((23==="82"&&5q==="qZ")||(23==="8f"&&5q==="fJ")){1w=E}}c.2e();if(1w){q 1V=c.7b();q 4p=c.3H(1V);if(1E 1V[0]!="1I"&&1V.1m>1&&1V[0].4v==3){4p.k2(c.2P())}q 1a="",5v="";$.1u(4p,$.M(B(i,s){if(s.Q=="3f"){q $s=$(s);q 7a=$s.6f();7a.1b("2q","ol").1w();if(c.C.1N===E){1a+=c.49($("<p>").1h(7a.1W()))}I{q fR=7a.o().G(/<br\\s?\\/?>$/i,"");1a+=fR+"<br>"}if(i==0){$s.2y("U-5v").6d();5v=c.49($s)}I{$s.1w()}}},c));o=c.$K.o().G(5v,"</"+5q+">"+1a+"<"+5q+">");c.$K.o(o);c.$K.1b(5q+":6d").1w()}I{q fz=$(c.2B()).2c("1g");if(c.1C("3t")&&!c.8N()&&c.C.1N){q 3K=c.cs("12");q az=$(3K).o();q 6R=$("<2q>");if(23=="8f"){6R=$("<ol>")}q 8n=$("<li>");if($.28(az)==""){8n.1h(az+\'<V id="1J-1M-1">\'+c.C.2i+"</V>");6R.1h(8n);c.$K.1b("#1J-1M-1").2f(6R)}I{8n.1h(az);6R.1h(8n);$(3K).2f(6R)}}I{c.X.22(23)}q L=c.2B();q $30=$(L).2c("ol, 2q");if(c.C.1N===E){q aC=$.28($30.Y());if(aC==""){$30.4k("li").1b("br").1w();$30.4k("li").1h(\'<V id="1J-1M-1">\'+c.C.2i+"</V>")}}if(fz.1U()!=0){$30.gR("<1g>")}if($30.1m){q $6F=$30.L();if(c.4g($6F)&&$6F[0].Q!="3f"&&c.7n($6F[0])){$6F.2f($6F.1W())}}if(c.1C("3c")){c.$K.2j()}}c.1Y();c.$K.1b("#1J-1M-1").2C("id");c.1j();c.1e("22",23,2K);F},dr:B(){c.e4("5S")},dz:B(){c.e4("6W")},e4:B(23){c.1Z();if(23==="5S"){q 1l=c.2P();c.2e();if(1l&&1l.Q=="3f"){q L=c.2B();q $30=$(L).2c("ol, 2q");q 5q=$30[0].Q;q 4p=c.3H();$.1u(4p,B(i,s){if(s.Q=="3f"){q $4Z=$(s).4Z();if($4Z.1U()!=0&&$4Z[0].Q=="3f"){q $eb=$4Z.4k("2q, ol");if($eb.1U()==0){$4Z.1h($("<"+5q+">").1h(s))}I{$eb.1h(s)}}}})}I{if(1l===E&&c.C.1N===N){c.2p("6B","2h");q 7v=c.2P();q 1l=$(\'<12 1a-7Z="">\').o($(7v).o());$(7v).2f(1l);q 1t=c.9g($(1l).1f("2G-1t"))+c.C.aJ;$(1l).1f("2G-1t",1t+"px")}I{q 7G=c.3H();$.1u(7G,$.M(B(i,1B){q $el=E;if(1B.Q==="6i"){F}if($.4L(1B.Q,c.C.5r)!==-1){$el=$(1B)}I{$el=$(1B).2c(c.C.5r.3T().3N(),c.$K[0])}q 1t=c.9g($el.1f("2G-1t"))+c.C.aJ;$el.1f("2G-1t",1t+"px")},c))}}c.1Y()}I{c.2e();q 1l=c.2P();if(1l&&1l.Q=="3f"){q 4p=c.3H();q 2I=0;c.dH(1l,2I,4p)}I{q 7G=c.3H();$.1u(7G,$.M(B(i,1B){q $el=E;if($.4L(1B.Q,c.C.5r)!==-1){$el=$(1B)}I{$el=$(1B).2c(c.C.5r.3T().3N(),c.$K[0])}q 1t=c.9g($el.1f("2G-1t"))-c.C.aJ;if(1t<=0){if(c.C.1N===N&&1E($el.1a("7Z"))!=="1I"){$el.2f($el.o()+"<br>")}I{$el.1f("2G-1t","");c.4V($el,"1o")}}I{$el.1f("2G-1t",1t+"px")}},c))}c.1Y()}c.1j()},dH:B(li,2I,4p){if(li&&li.Q=="3f"){q $L=$(li).L().L();if($L.1U()!=0&&$L[0].Q=="3f"){$L.2E(li)}I{if(1E 4p[2I]!="1I"){li=4p[2I];2I++;c.dH(li,2I,4p)}I{c.22("82")}}}},dQ:B(){c.88("","rA")},dT:B(){c.88("4I","ry")},dG:B(){c.88("6D","rs")},dL:B(){c.88("dK","rt")},88:B(1G,23){c.1Z();if(c.cv()){c.X.22(23,E,E);F N}c.2e();q 1l=c.2P();if(!1l&&c.C.1N){c.2p("c0","12");q 7v=c.2P();q 1l=$(\'<12 1a-7Z="">\').o($(7v).o());$(7v).2f(1l);$(1l).1f("Y-54",1G);c.4V(1l,"1o");if(1G==""&&1E($(1l).1a("7Z"))!=="1I"){$(1l).2f($(1l).o())}}I{q 7G=c.3H();$.1u(7G,$.M(B(i,1B){q $el=E;if($.4L(1B.Q,c.C.5r)!==-1){$el=$(1B)}I{$el=$(1B).2c(c.C.5r.3T().3N(),c.$K[0])}if($el){$el.1f("Y-54",1G);c.4V($el,"1o")}},c))}c.1Y();c.1j()},e5:B(o){q ph=c.gO(o);if(ph!==E){F ph}if(c.C.1N===E){if(o===""){o=c.C.5a}I{if(o.4G(/^<hr\\s?\\/?>$/gi)!==-1){o="<hr>"+c.C.5a}}}F o},db:B(o){if(c.C.aP&&!c.C.ru){o=o.G(/<12(.*?)>([\\w\\W]*?)<\\/12>/gi,"<p$1>$2</p>")}if(c.C.6a){o=c.bj(o)}F o},de:B(o){if(c.C.d5){o=o.G(/\\{\\{(.*?)\\}\\}/gi,"<!-- a2 gY $1 -->");o=o.G(/\\{(.*?)\\}/gi,"<!-- a2 $1 -->")}o=o.G(/<3s(.*?)>([\\w\\W]*?)<\\/3s>/gi,\'<1c 1G="Y/9I" 1o="3i: 3o;" 1x="U-3s-1d"$1>$2</1c>\');o=o.G(/<1o(.*?)>([\\w\\W]*?)<\\/1o>/gi,\'<2m$1 1o="3i: 3o;" 4h="U-1o-1d">$2</2m>\');o=o.G(/<2s(.*?)>([\\w\\W]*?)<\\/2s>/gi,\'<2m$1 4h="U-2s-1d">$2</2m>\');if(c.C.8e){o=o.G(/<\\?4P([\\w\\W]*?)\\?>/gi,\'<2m 1o="3i: 3o;" 4h="U-4P-1d">$1</2m>\')}I{o=o.G(/<\\?4P([\\w\\W]*?)\\?>/gi,"")}F o},gM:B(o){if(c.C.d5){o=o.G(/<!-- a2 gY (.*?) -->/gi,"{{$1}}");o=o.G(/<!-- a2 (.*?) -->/gi,"{$1}")}o=o.G(/<1c 1G="Y\\/9I" 1o="3i: 3o;" 1x="U-3s-1d"(.*?)>([\\w\\W]*?)<\\/1c>/gi,\'<3s$1 1G="Y/9I">$2<\\/3s>\');o=o.G(/<2m(.*?) 1o="3i: 3o;" 4h="U-1o-1d">([\\w\\W]*?)<\\/2m>/gi,"<1o$1>$2</1o>");o=o.G(/<2m(.*?)4h="U-2s-1d"(.*?)>([\\w\\W]*?)<\\/2m>/gi,"<2s$1$2>$3</2s>");if(c.C.8e){o=o.G(/<2m 1o="3i: 3o;" 4h="U-4P-1d">([\\w\\W]*?)<\\/2m>/gi,"<?4P\\r\\n$1\\r\\n?>")}F o},79:B(o,3J){if(3J!==E){q 3J=[];q 2w=o.1S(/<(2r|1o|3s|1c)(.*?)>([\\w\\W]*?)<\\/(2r|1o|3s|1c)>/gi);if(2w===2J){2w=[]}if(c.C.8e){q 7l=o.1S(/<\\?4P([\\w\\W]*?)\\?>/gi);if(7l){2w=$.eW(2w,7l)}}if(2w){$.1u(2w,B(i,s){o=o.G(s,"hh"+i);3J.3a(s)})}}o=o.G(/\\n/g," ");o=o.G(/[\\t]*/g,"");o=o.G(/\\n\\s*\\n/g,"\\n");o=o.G(/^[\\s\\n]*/g," ");o=o.G(/[\\s\\n]*$/g," ");o=o.G(/>\\s{2,}</g,"> <");o=c.hi(o,3J);o=o.G(/\\n\\n/g,"\\n");F o},hi:B(o,3J){if(3J===E){F o}$.1u(3J,B(i,s){o=o.G("hh"+i,s)});F o},cb:B(o){o=o.G(/[\\7m-\\hk\\hm]/g,"");q di=["<b>\\\\s*</b>","<b>&3u;</b>","<em>\\\\s*</em>"];q 75=["<2r></2r>","<2h>\\\\s*</2h>","<dd></dd>","<dt></dt>","<2q></2q>","<ol></ol>","<li></li>","<1n></1n>","<3h></3h>","<V>\\\\s*<V>","<V>&3u;<V>","<p>\\\\s*</p>","<p></p>","<p>&3u;</p>","<p>\\\\s*<br>\\\\s*</p>","<12>\\\\s*</12>","<12>\\\\s*<br>\\\\s*</12>"];if(c.C.do){75=75.rq(di)}I{75=di}q 4T=75.1m;3w(q i=0;i<4T;++i){o=o.G(2a 2L(75[i],"gi"),"")}F o},bj:B(o){o=$.28(o);if(c.C.1N===N){F o}if(o===""||o==="<p></p>"){F c.C.5a}o=o+"\\n";if(c.C.do===E){F o}q eG=[];q 2w=o.1S(/<(1n|12|2r|3R)(.*?)>([\\w\\W]*?)<\\/(1n|12|2r|3R)>/gi);if(!2w){2w=[]}q ff=o.1S(/<!--([\\w\\W]*?)-->/gi);if(ff){2w=$.eW(2w,ff)}if(c.C.8e){q 7l=o.1S(/<2m(.*?)4h="U-4P-1d">([\\w\\W]*?)<\\/2m>/gi);if(7l){2w=$.eW(2w,7l)}}if(2w){$.1u(2w,B(i,s){eG[i]=s;o=o.G(s,"{G"+i+"}\\n")})}o=o.G(/<br \\/>\\s*<br \\/>/gi,"\\n\\n");o=o.G(/<br><br>/gi,"\\n\\n");B R(4D,ge,r){F o.G(2a 2L(4D,ge),r)}q 3D="(rw|o|2v|aK|1c|4E|1o|3s|1s|1Q|1n|3X|cg|rp|rr|rx|7L|3h|1g|eN|12|dl|dd|dt|2q|ol|li|2r|3n|47|2s|gk|gj|2h|c5|rz|1o|p|h[1-6]|hr|ga|rn|2m|kf|ke|r7|aI|44|r8|r9|r5|r1|r2|ro)";o=R("(<"+3D+"[^>]*>)","gi","\\n$1");o=R("(</"+3D+">)","gi","$1\\n\\n");o=R("\\r\\n","g","\\n");o=R("\\r","g","\\n");o=R("/\\n\\n+/","g","\\n\\n");q 4B=o.4i(2a 2L("\\ns*\\n","g"),-1);o="";3w(q i in 4B){if(4B.r3(i)){if(4B[i].4G("{G")==-1){4B[i]=4B[i].G(/<p>\\n\\t?<\\/p>/gi,"");4B[i]=4B[i].G(/<p><\\/p>/gi,"");if(4B[i]!=""){o+="<p>"+4B[i].G(/^\\n+|\\n+$/g,"")+"</p>"}}I{o+=4B[i]}}}o=R("<p><p>","gi","<p>");o=R("</p></p>","gi","</p>");o=R("<p>s?</p>","gi","");o=R("<p>([^<]+)</(12|c5|2s)>","gi","<p>$1</p></$2>");o=R("<p>(</?"+3D+"[^>]*>)</p>","gi","$1");o=R("<p>(<li.+?)</p>","gi","$1");o=R("<p>s?(</?"+3D+"[^>]*>)","gi","$1");o=R("(</?"+3D+"[^>]*>)s?</p>","gi","$1");o=R("(</?"+3D+"[^>]*>)s?<br />","gi","$1");o=R("<br />(s*</?(?:p|li|12|dl|dd|dt|eN|2r|1g|2q|ol)[^>]*>)","gi","$1");o=R("\\n</p>","gi","</p>");o=R("<li><p>","gi","<li>");o=R("</p></li>","gi","</li>");o=R("</li><p>","gi","</li>");o=R("<p>\\t?\\n?<p>","gi","<p>");o=R("</dt><p>","gi","</dt>");o=R("</dd><p>","gi","</dd>");o=R("<br></p></2h>","gi","</2h>");o=R("<p>\\t*</p>","gi","");$.1u(eG,B(i,s){o=o.G("{G"+i+"}",s)});F $.28(o)},ax:B(o,7x){q 5X="43";if(c.C.5X==="b"){5X="b"}q 5Y="em";if(c.C.5Y==="i"){5Y="i"}o=o.G(/<V 1o="2F-1o: 3r;">([\\w\\W]*?)<\\/V>/gi,"<"+5Y+">$1</"+5Y+">");o=o.G(/<V 1o="2F-71: 3q;">([\\w\\W]*?)<\\/V>/gi,"<"+5X+">$1</"+5X+">");if(c.C.5X==="43"){o=o.G(/<b>([\\w\\W]*?)<\\/b>/gi,"<43>$1</43>")}I{o=o.G(/<43>([\\w\\W]*?)<\\/43>/gi,"<b>$1</b>")}if(c.C.5Y==="em"){o=o.G(/<i>([\\w\\W]*?)<\\/i>/gi,"<em>$1</em>")}I{o=o.G(/<em>([\\w\\W]*?)<\\/em>/gi,"<i>$1</i>")}o=o.G(/<V 1o="Y-bP: 4W;">([\\w\\W]*?)<\\/V>/gi,"<u>$1</u>");if(7x!==N){o=o.G(/<5J>([\\w\\W]*?)<\\/5J>/gi,"<56>$1</56>")}I{o=o.G(/<56>([\\w\\W]*?)<\\/56>/gi,"<5J>$1</5J>")}F o},7S:B(o){if(o==""||1E o=="1I"){F o}q 94=E;if(c.C.5G!==E){94=N}q 2M=94===N?c.C.5G:c.C.7M;q gs=/<\\/?([a-z][a-ep-9]*)\\b[^>]*>/gi;o=o.G(gs,B($0,$1){if(94===N){F $.4L($1.3N(),2M)>"-1"?$0:""}I{F $.4L($1.3N(),2M)>"-1"?"":$0}});o=c.ax(o);F o},bt:B(o,gD){q 2r=o.1S(/<(2r|2o)(.*?)>([\\w\\W]*?)<\\/(2r|2o)>/gi);if(2r!==2J){$.1u(2r,$.M(B(i,s){q 2M=s.1S(/<(2r|2o)(.*?)>([\\w\\W]*?)<\\/(2r|2o)>/i);2M[3]=2M[3].G(/&3u;/g," ");if(gD!==E){2M[3]=c.bZ(2M[3])}2M[3]=2M[3].G(/\\$/g,"$");o=o.G(s,"<"+2M[1]+2M[2]+">"+2M[3]+"</"+2M[1]+">")},c))}F o},bZ:B(4D){4D=4S(4D).G(/&ab;/g,"&").G(/</g,"<").G(/>/g,">").G(/&gC;/g,\'"\');F 4D.G(/&/g,"&ab;").G(/</g,"<").G(/>/g,">").G(/"/g,"&gC;")},gy:B(){q $1B=c.$K.1b("li, 1z, a, b, 43, rc, rk, i, em, u, rl, 5J, 56, V, rm");$1B.g3(\'[1o*="9b-8i: g4;"][1o*="9v-21"]\').1f("9b-8i","").1f("9v-21","");$1B.g3(\'[1o*="9b-8i: g4;"]\').1f("9b-8i","");$1B.1f("9v-21","");$.1u($1B,$.M(B(i,s){c.4V(s,"1o")},c));q $bD=c.$K.1b("b, 43, i, em, u, 5J, 56");$bD.1f("2F-1U","");$.1u($bD,$.M(B(i,s){c.4V(s,"1o")},c));c.$K.1b(\'12[1o="Y-54: -4C-4d;"]\').1W().fA();c.$K.1b("2q, ol, li").2C("1o")},gF:B(2o){q i=0,9f=2o.1m,31=0,2u=2J,3p=2J,1d="",1X="",4Y="";c.86=0;3w(;i<9f;i++){31=i;if(-1==2o.4N(i).3W("<")){1X+=2o.4N(i);F c.cu(1X)}3x(31<9f&&2o.5u(31)!="<"){31++}if(i!=31){4Y=2o.4N(i,31-i);if(!4Y.1S(/^\\s{2,}$/g)){if("\\n"==1X.5u(1X.1m-1)){1X+=c.7C()}I{if("\\n"==4Y.5u(0)){1X+="\\n"+c.7C();4Y=4Y.G(/^\\s+/,"")}}1X+=4Y}if(4Y.1S(/\\n/)){1X+="\\n"+c.7C()}}2u=31;3x(31<9f&&">"!=2o.5u(31)){31++}1d=2o.4N(2u,31-2u);i=31;q t;if("!--"==1d.4N(1,3)){if(!1d.1S(/--$/)){3x("-->"!=2o.4N(31,3)){31++}31+=2;1d=2o.4N(2u,31-2u);i=31}if("\\n"!=1X.5u(1X.1m-1)){1X+="\\n"}1X+=c.7C();1X+=1d+">\\n"}I{if("!"==1d[1]){1X=c.9o(1d+">",1X)}I{if("?"==1d[1]){1X+=1d+">\\n"}I{if(t=1d.1S(/^<(3s|1o|2r)/i)){t[1]=t[1].3N();1d=c.ct(1d);1X=c.9o(1d,1X);3p=4S(2o.4N(i+1)).3N().3W("</"+t[1]);if(3p){4Y=2o.4N(i+1,3p);i+=3p;1X+=4Y}}I{1d=c.ct(1d);1X=c.9o(1d,1X)}}}}}F c.cu(1X)},7C:B(){q s="";3w(q j=0;j<c.86;j++){s+="\\t"}F s},cu:B(2o){2o=2o.G(/\\n\\s*\\n/g,"\\n");2o=2o.G(/^[\\s\\n]*/,"");2o=2o.G(/[\\s\\n]*$/,"");2o=2o.G(/<3s(.*?)>\\n<\\/3s>/gi,"<3s$1><\\/3s>");c.86=0;F 2o},ct:B(1d){q 81="";1d=1d.G(/\\n/g," ");1d=1d.G(/\\s{2,}/g," ");1d=1d.G(/^\\s+|\\s+$/g," ");q cS="";if(1d.1S(/\\/$/)){cS="/";1d=1d.G(/\\/+$/,"")}q m;3x(m=/\\s*([^= ]+)(?:=(([\'"\']).*?\\3|[^ ]+))?/.2p(1d)){if(m[2]){81+=m[1].3N()+"="+m[2]}I{if(m[1]){81+=m[1].3N()}}81+=" ";1d=1d.4N(m[0].1m)}F 81.G(/\\s*$/,"")+cS+">"},9o:B(1d,1X){q nl=1d.1S(c.cF);if(1d.1S(c.gL)||nl){1X=1X.G(/\\s*$/,"");1X+="\\n"}if(nl&&"/"==1d.5u(1)){c.86--}if("\\n"==1X.5u(1X.1m-1)){1X+=c.7C()}if(nl&&"/"!=1d.5u(1)){c.86++}1X+=1d;if(1d.1S(c.gI)||1d.1S(c.cF)){1X=1X.G(/ *$/,"");1X+="\\n"}F 1X},gX:B(e){q o=$.28(c.$K.o());if(c.C.1N){if(o==""){e.2x();c.$K.o("");c.2j()}}I{o=o.G(/<br\\s?\\/?>/i,"");q 7f=o.G(/<p>\\s?<\\/p>/gi,"");if(o===""||7f===""){e.2x();q J=$(c.C.5a).2R(0);c.$K.o(J);c.2j()}}c.1j()},5i:B(1d){if(c.1C("3c")&&c.7H()){c.$K.2j()}c.1Z();q 1V=c.3H();c.2e();$.1u(1V,$.M(B(i,J){if(J.Q!=="3f"){q L=$(J).L();if(1d==="p"){if((J.Q==="P"&&L.1U()!=0&&L[0].Q==="3L")||J.Q==="3L"){c.bR();F}I{if(c.C.1N){if(J&&J.Q.4G(/H[1-6]/)==0){$(J).2f(J.3O+"<br>")}I{F}}I{c.6B(1d,J)}}}I{c.6B(1d,J)}}},c));c.1Y();c.1j()},6B:B(1d,1l){if(1l===E){1l=c.2P()}if(1l===E&&c.C.1N===N){c.22("c0",1d);F N}q 1W="";if(1d!=="2r"){1W=$(1l).1W()}I{1W=$(1l).o();if($.28(1W)===""){1W=\'<V id="1J-1M-1"></V>\'}}if(1l.Q==="6w"){1d="p"}if(c.C.1N===N&&1d==="p"){$(1l).2f($("<12>").1h(1W).o()+"<br>")}I{q L=c.2B();q J=$("<"+1d+">").1h(1W);$(1l).2f(J);if(L&&L.Q=="6i"){$(J).gR("<1g>")}}},jH:B(fY,fZ,83){if(83!==E){c.2e()}q 8A=$("<"+fZ+"/>");$(fY).2f(B(){F 8A.1h($(c).1W())});if(83!==E){c.1Y()}F 8A},bR:B(){if(c.1C("3c")&&c.7H()){c.$K.2j()}c.1Z();if(c.C.1N===E){c.2e();q 3D=c.3H();q 2h=E;q fH=3D.1m;if(3D){q 1a="";q 5v="";q G=E;q bT=N;$.1u(3D,B(i,s){if(s.Q!=="P"){bT=E}});$.1u(3D,$.M(B(i,s){if(s.Q==="3L"){c.6B("p",s,E)}I{if(s.Q==="P"){2h=$(s).L();if(2h[0].Q=="3L"){q 7o=$(2h).4k("p").1U();if(7o==1){$(2h).2f(s)}I{if(7o==fH){G="2h";1a+=c.49(s)}I{G="o";1a+=c.49(s);if(i==0){$(s).2y("U-5v").6d();5v=c.49(s)}I{$(s).1w()}}}}I{if(bT===E||3D.1m==1){c.6B("2h",s,E)}I{G="fN";1a+=c.49(s)}}}I{if(s.Q!=="3f"){c.6B("2h",s,E)}}}},c));if(G){if(G=="fN"){$(3D[0]).2f("<2h>"+1a+"</2h>");$(3D).1w()}I{if(G=="2h"){$(2h).2f(1a)}I{if(G=="o"){q o=c.$K.o().G(5v,"</2h>"+1a+"<2h>");c.$K.o(o);c.$K.1b("2h").1u(B(){if($.28($(c).o())==""){$(c).1w()}})}}}}}c.1Y()}I{q 1l=c.2P();if(1l.Q==="3L"){c.2e();q o=$.28($(1l).o());q 1J=$.28(c.jR());o=o.G(/<V(.*?)id="1J-1M(.*?)<\\/V>/gi,"");if(o==1J){$(1l).2f($(1l).o()+"<br>")}I{c.ft("2H");q 2H=c.$K.1b("2H");2H.6d();q fu=c.$K.o().G("<2H></2H>",\'</2h><V id="1J-1M-1">\'+c.C.2i+"</V>"+1J+"<2h>");c.$K.o(fu);2H.1w();c.$K.1b("2h").1u(B(){if($.28($(c).o())==""){$(c).1w()}})}c.1Y();c.$K.1b("V#1J-1M-1").1i("id",E)}I{q 3K=c.cs("2h");q o=$(3K).o();q fw=["2q","ol","1n","3h","7L","3X","cg","dl"];$.1u(fw,B(i,s){o=o.G(2a 2L("<"+s+"(.*?)>","gi"),"");o=o.G(2a 2L("</"+s+">","gi"),"")});q 6Y=c.C.ac;$.1u(6Y,B(i,s){o=o.G(2a 2L("<"+s+"(.*?)>","gi"),"");o=o.G(2a 2L("</"+s+">","gi"),"<br>")});$(3K).o(o);c.cq(3K);q 4l=$(3K).4l();if(4l.1U()!=0&&4l[0].Q==="cP"){4l.1w()}}}c.1j()},rj:B(1i,2t){q 1V=c.3H();$(1V).2C(1i);c.1j()},ri:B(1i,2t){q 1V=c.3H();$(1V).1i(1i,2t);c.1j()},rf:B(5h){q 1V=c.3H();$(1V).1f(5h,"");c.4V(1V,"1o");c.1j()},rh:B(5h,2t){q 1V=c.3H();$(1V).1f(5h,2t);c.1j()},rg:B(2U){q 1V=c.3H();$(1V).3e(2U);c.4V(1V,"1x");c.1j()},rd:B(2U){q 1V=c.3H();$(1V).2y(2U);c.1j()},rb:B(2U){c.2e();c.ck(B(J){$(J).3e(2U);c.4V(J,"1x")});c.1Y();c.1j()},r4:B(2U){q 1r=c.3S();if(!$(1r).3v(2U)){c.as("2y",2U)}},r6:B(5h){c.2e();c.ck(B(J){$(J).1f(5h,"");c.4V(J,"1o")});c.1Y();c.1j()},ra:B(5h,2t){c.as("1f",5h,2t)},qc:B(1i){c.2e();q O=c.3m(),J=c.7U(),1V=c.7b();if(O.4M||O.5T===O.7Q&&J){1V=$(J)}$(1V).2C(1i);c.fm();c.1Y();c.1j()},q1:B(1i,2t){c.as("1i",1i,2t)},as:B(1G,1i,2t){c.1Z();c.2e();q O=c.3m();q el=c.7U();if((O.4M||O.5T===O.7Q)&&el&&!c.7n(el)){$(el)[1G](1i,2t)}I{c.X.22("8a",E,4);q aH=c.$K.1b("2F");$.1u(aH,$.M(B(i,s){c.fL(1G,s,1i,2t)},c))}c.1Y();c.1j()},fL:B(1G,s,1i,2t){q L=$(s).L(),el;q av=c.9V();q aE=$(L).Y();q aR=av==aE;if(aR&&L&&L[0].Q==="c7"&&L[0].or.1m!=0){el=L;$(s).2f($(s).o())}I{el=$("<4o>").1h($(s).1W());$(s).2f(el)}$(el)[1G](1i,2t);F el},ck:B(1e){q O=c.3m(),J=c.7U(),1V=c.7b(),4M;if(O.4M||O.5T===O.7Q&&J){1V=$(J);4M=N}$.1u(1V,$.M(B(i,J){if(!4M&&J.Q!=="c7"){q av=c.9V();q aE=$(J).L().Y();q aR=av==aE;if(aR&&J.4Q.Q==="c7"&&!$(J.4Q).3v("4e")){J=J.4Q}I{F}}1e.5B(c,J)},c))},fm:B(){q $93=c.$K.1b("4o");$.1u($93,$.M(B(i,V){q $V=$(V);if($V.1i("1x")===1I&&$V.1i("1o")===1I){$V.1W().fA()}},c))},ft:B(1d){c.2e();c.X.22("8a",E,4);q aH=c.$K.1b("2F");q 2X;$.1u(aH,B(i,s){q el=$("<"+1d+"/>").1h($(s).1W());$(s).2f(el);2X=el});c.1Y();c.1j()},oq:B(1d){c.2e();q ca=1d.op();q 1V=c.7b();q L=$(c.2B()).L();$.1u(1V,B(i,s){if(s.Q===ca){c.9P(s)}});if(L&&L[0].Q===ca){c.9P(L)}c.1Y();c.1j()},9P:B(el){$(el).2f($(el).1W())},9m:B(o,1j){q 1r=c.3S();q L=1r.4Q;c.4m();c.1Z();q $o=$("<12>").1h($.cc(o));o=$o.o();o=c.cb(o);$o=$("<12>").1h($.cc(o));q c9=c.2P();if($o.1W().1m==1){q 9R=$o.1W()[0].Q;if(9R!="P"&&9R==c9.Q||9R=="6w"){$o=$("<12>").1h(o)}}if(c.C.1N){o=o.G(/<p(.*?)>([\\w\\W]*?)<\\/p>/gi,"$2<br>")}if(!c.C.1N&&$o.1W().1m==1&&$o.1W()[0].4v==3&&(c.bk().1m>2||(!1r||1r.Q=="bp"&&!L||L.Q=="kc"))){o="<p>"+o+"</p>"}o=c.aV(o);if($o.1W().1m>1&&c9||$o.1W().is("p, :aI, 2q, ol, li, 12, 1n, 1g, 2h, 2r, c5, 2m, aI, 44, ke, kf")){if(c.1C("3t")){if(!c.8N()){c.X.1J.5z().cd(o)}I{c.bb(o)}}I{c.X.22("5b",E,o)}}I{c.ah(o,E)}if(c.5O){c.48.2W($.M(B(){if(!c.C.1N){c.7e(c.$K.1W().2X())}I{c.bX()}},c),1)}c.7D();c.7J();if(1j!==E){c.1j()}},ah:B(o,1j){o=c.aV(o);q 1q=c.29();if(1q.41&&1q.51){q O=1q.41(0);O.ay();q el=c.X.4y("12");el.3O=o;q 4f=c.X.cO(),J,5N;3x((J=el.8z)){5N=4f.7c(J)}O.3A(4f);if(5N){O=O.9p();O.9d(5N);O.5I(N);1q.4O();1q.5e(O)}}if(1j!==E){c.1j()}},os:B(o){o=c.aV(o);q J=$(o);q 6s=X.4y("V");6s.3O="\\7m";q O=c.3m();O.3A(6s);O.3A(J[0]);O.5I(E);q 1q=c.29();1q.4O();1q.5e(O);c.1j()},ot:B(o){q $o=$($.cc(o));if($o.1m){o=$o.Y()}c.4m();if(c.1C("3t")){if(!c.8N()){c.X.1J.5z().cd(o)}I{c.bb(o)}}I{c.X.22("5b",E,o)}c.1j()},3A:B(J){J=J[0]||J;if(J.Q=="kt"){q 6G="4o";q au=J.ka;q 5Q=2a 2L("<"+J.Q,"i");q 5A=au.G(5Q,"<"+6G);5Q=2a 2L("</"+J.Q,"i");5A=5A.G(5Q,"</"+6G);J=$(5A)[0]}q 1q=c.29();if(1q.41&&1q.51){O=1q.41(0);O.ay();O.3A(J);O.ov(J);O.9d(J);1q.4O();1q.5e(O)}F J},iS:B(e,J){q O;q x=e.k5,y=e.k7;if(c.X.k8){q 3Y=c.X.k8(x,y);O=c.3m();O.7W(3Y.ou,3Y.2V);O.5I(N);O.3A(J)}I{if(c.X.kh){O=c.X.kh(x,y);O.3A(J)}I{if(1E X.2v.ki!="1I"){O=c.X.2v.ki();O.kr(x,y);q ce=O.oo();ce.kr(x,y);O.om("og",ce);O.3n()}}}},6Q:B(2g,L){if(1E(L)!="1I"){2g=L}if(c.cR()){if(c.C.1N){q 1W=$("<12>").1h($.28(c.$K.o())).1W();q 2X=1W.2X()[0];if(2X.Q=="kt"&&2X.3O==""){2X=1W.4Z()[0]}if(c.49(2X)!=c.49(2g)){F E}}I{if(c.$K.1W().2X()[0]!==2g){F E}}c.cf(2g)}},cf:B(2g){c.1Z();if(c.C.1N===E){q J=$(c.C.5a);$(2g).2E(J);c.4b(J)}I{q J=$(\'<V id="1J-1M-1">\'+c.C.2i+"</V>",c.X)[0];$(2g).2E(J);$(J).2E(c.C.2i);c.1Y();c.$K.1b("V#1J-1M-1").2C("id")}},aD:B(kp){c.2e();q br="<br>";if(kp==N){br="<br><br>"}if(c.1C("3c")){q V=$("<V>").o(c.C.2i);c.$K.1b("#1J-1M-1").3M(br).3M(V).3M(c.C.2i);c.jZ(V[0]);V.1w();c.7V()}I{q L=c.2B();if(L&&L.Q==="A"){q 2V=c.cT(L);q Y=$.28($(L).Y()).G(/\\n\\r\\n/g,"");q 4T=Y.1m;if(2V==4T){c.7V();q J=$(\'<V id="1J-1M-1">\'+c.C.2i+"</V>",c.X)[0];$(L).2E(J);$(J).3M(br+(c.1C("4C")?c.C.2i:""));c.1Y();F N}}c.$K.1b("#1J-1M-1").3M(br+(c.1C("4C")?c.C.2i:""));c.1Y()}},of:B(){c.aD(N)},ko:B(2g){q J=$("<br>"+c.C.2i);$(2g).2f(J);c.4b(J)},kk:B(o){o=c.1e("oe",E,o);if(c.1C("3t")){q 2H=$.28(o);if(2H.4G(/^<a(.*?)>(.*?)<\\/a>$/i)==0){o=o.G(/^<a(.*?)>(.*?)<\\/a>$/i,"$2")}}if(c.C.kj){q 2H=c.X.4y("12");o=o.G(/<br>|<\\/H[1-6]>|<\\/p>|<\\/12>/gi,"\\n");2H.3O=o;o=2H.9X||2H.bC;o=$.28(o);o=o.G("\\n","<br>");o=c.bj(o);c.aL(o);F E}q aO=E;if(c.7s("6i")){aO=N;q 6Y=c.C.ac;6Y.3a("3h");6Y.3a("1n");$.1u(6Y,B(i,s){o=o.G(2a 2L("<"+s+"(.*?)>","gi"),"");o=o.G(2a 2L("</"+s+">","gi"),"<br>")})}if(c.7s("6w")){o=c.kn(o);c.aL(o);F N}o=o.G(/<1z(.*?)v:oh=(.*?)>/gi,"");o=o.G(/<p(.*?)1x="oi"([\\w\\W]*?)<\\/p>/gi,"<2q><li$2</li>");o=o.G(/<p(.*?)1x="ok"([\\w\\W]*?)<\\/p>/gi,"<li$2</li>");o=o.G(/<p(.*?)1x="oj"([\\w\\W]*?)<\\/p>/gi,"<li$2</li></2q>");o=o.G(/<p(.*?)1x="ow"([\\w\\W]*?)<\\/p>/gi,"<2q><li$2</li></2q>");o=o.G(/·/g,"");o=o.G(/<!--[\\s\\S]*?-->|<\\?(?:4P)?[\\s\\S]*?\\?>/gi,"");if(c.C.kl===N){o=o.G(/(&3u;){2,}/gi,"&3u;");o=o.G(/&3u;/gi," ")}o=o.G(/<b\\ox="km-1v-1M(.*?)">([\\w\\W]*?)<\\/b>/gi,"$2");o=o.G(/<b(.*?)id="oJ-km-oI(.*?)">([\\w\\W]*?)<\\/b>/gi,"$3");o=o.G(/<V[^>]*(2F-1o: 3r; 2F-71: 3q|2F-71: 3q; 2F-1o: 3r)[^>]*>/gi,\'<V 1o="2F-71: 3q;"><V 1o="2F-1o: 3r;">\');o=o.G(/<V[^>]*2F-1o: 3r[^>]*>/gi,\'<V 1o="2F-1o: 3r;">\');o=o.G(/<V[^>]*2F-71: 3q[^>]*>/gi,\'<V 1o="2F-71: 3q;">\');o=o.G(/<V[^>]*Y-bP: 4W[^>]*>/gi,\'<V 1o="Y-bP: 4W;">\');o=o.G(/<1g>\\oH*<\\/1g>/gi,"[1g]");o=o.G(/<1g>&3u;<\\/1g>/gi,"[1g]");o=o.G(/<1g><br><\\/1g>/gi,"[1g]");o=o.G(/<1g(.*?)bc="(.*?)"(.*?)>([\\w\\W]*?)<\\/1g>/gi,\'[1g bc="$2"]$4[/1g]\');o=o.G(/<1g(.*?)bh="(.*?)"(.*?)>([\\w\\W]*?)<\\/1g>/gi,\'[1g bh="$2"]$4[/1g]\');o=o.G(/<a(.*?)1R="(.*?)"(.*?)>([\\w\\W]*?)<\\/a>/gi,\'[a 1R="$2"]$4[/a]\');o=o.G(/<1Q(.*?)>([\\w\\W]*?)<\\/1Q>/gi,"[1Q$1]$2[/1Q]");o=o.G(/<3C(.*?)>([\\w\\W]*?)<\\/3C>/gi,"[3C$1]$2[/3C]");o=o.G(/<5t(.*?)>([\\w\\W]*?)<\\/5t>/gi,"[5t$1]$2[/5t]");o=o.G(/<4X(.*?)>([\\w\\W]*?)<\\/4X>/gi,"[4X$1]$2[/4X]");o=o.G(/<3R(.*?)>([\\w\\W]*?)<\\/3R>/gi,"[3R$1]$2[/3R]");o=o.G(/<2K(.*?)>/gi,"[2K$1]");o=o.G(/<1z(.*?)>/gi,"[1z$1]");o=o.G(/ 1x="(.*?)"/gi,"");o=o.G(/<(\\w+)([\\w\\W]*?)>/gi,"<$1>");if(c.C.1N){o=o.G(/<43><\\/43>/gi,"");o=o.G(/<u><\\/u>/gi,"");if(c.C.bV){o=o.G(/<2F(.*?)>([\\w\\W]*?)<\\/2F>/gi,"$2")}o=o.G(/<[^\\/>][^>]*>(\\s*|\\t*|\\n*|&3u;|<br>)<\\/[^>]+>/gi,"<br>")}I{o=o.G(/<[^\\/>][^>]*>(\\s*|\\t*|\\n*|&3u;|<br>)<\\/[^>]+>/gi,"")}o=o.G(/<12>\\s*?\\t*?\\n*?(<2q>|<ol>|<p>)/gi,"$1");o=o.G(/\\[1g bc="(.*?)"\\]([\\w\\W]*?)\\[\\/1g\\]/gi,\'<1g bc="$1">$2</1g>\');o=o.G(/\\[1g bh="(.*?)"\\]([\\w\\W]*?)\\[\\/1g\\]/gi,\'<1g bh="$1">$2</1g>\');o=o.G(/\\[1g\\]/gi,"<1g>&3u;</1g>");o=o.G(/\\[a 1R="(.*?)"\\]([\\w\\W]*?)\\[\\/a\\]/gi,\'<a 1R="$1">$2</a>\');o=o.G(/\\[1Q(.*?)\\]([\\w\\W]*?)\\[\\/1Q\\]/gi,"<1Q$1>$2</1Q>");o=o.G(/\\[3C(.*?)\\]([\\w\\W]*?)\\[\\/3C\\]/gi,"<3C$1>$2</3C>");o=o.G(/\\[5t(.*?)\\]([\\w\\W]*?)\\[\\/5t\\]/gi,"<5t$1>$2</5t>");o=o.G(/\\[4X(.*?)\\]([\\w\\W]*?)\\[\\/4X\\]/gi,"<4X$1>$2</4X>");o=o.G(/\\[3R(.*?)\\]([\\w\\W]*?)\\[\\/3R\\]/gi,"<3R$1>$2</3R>");o=o.G(/\\[2K(.*?)\\]/gi,"<2K$1>");o=o.G(/\\[1z(.*?)\\]/gi,"<1z$1>");if(c.C.aP){o=o.G(/<12(.*?)>([\\w\\W]*?)<\\/12>/gi,"<p>$2</p>");o=o.G(/<\\/12><p>/gi,"<p>");o=o.G(/<\\/p><\\/12>/gi,"</p>");o=o.G(/<p><\\/p>/gi,"<br />")}I{o=o.G(/<12><\\/12>/gi,"<br />")}o=c.7S(o);if(c.7s("3f")){o=o.G(/<p>([\\w\\W]*?)<\\/p>/gi,"$1<br>")}I{if(aO===E){o=c.bj(o)}}o=o.G(/<V(.*?)>([\\w\\W]*?)<\\/V>/gi,"$2");o=o.G(/<1z>/gi,"");o=o.G(/<[^\\/>][^>][^1z|2K|1v|1g][^<]*>(\\s*|\\t*|\\n*| |<br>)<\\/[^>]+>/gi,"");o=o.G(/\\n{3,}/gi,"\\n");o=o.G(/<p><p>/gi,"<p>");o=o.G(/<\\/p><\\/p>/gi,"</p>");o=o.G(/<li>(\\s*|\\t*|\\n*)<p>/gi,"<li>");o=o.G(/<\\/p>(\\s*|\\t*|\\n*)<\\/li>/gi,"</li>");if(c.C.1N===N){o=o.G(/<p(.*?)>([\\w\\W]*?)<\\/p>/gi,"$2<br>")}o=o.G(/<[^\\/>][^>][^1z|2K|1v|1g][^<]*>(\\s*|\\t*|\\n*| |<br>)<\\/[^>]+>/gi,"");o=o.G(/<1z 3l="4C-oK-1L\\:\\/\\/(.*?)"(.*?)>/gi,"");o=o.G(/<1g(.*?)>(\\s*|\\t*|\\n*)<p>([\\w\\W]*?)<\\/p>(\\s*|\\t*|\\n*)<\\/1g>/gi,"<1g$1>$3</1g>");if(c.C.aP){o=o.G(/<12(.*?)>([\\w\\W]*?)<\\/12>/gi,"$2");o=o.G(/<12(.*?)>([\\w\\W]*?)<\\/12>/gi,"$2")}c.bY=E;if(c.1C("3c")){if(c.C.9l){q 2w=o.1S(/<1z 3l="1a:T(.*?)"(.*?)>/gi);if(2w!==2J){c.bY=2w;3w(k in 2w){q 1z=2w[k].G("<1z",\'<1z 1a-3c-aW-T="\'+k+\'" \');o=o.G(2w[k],1z)}}}3x(/<br>$/gi.4c(o)){o=o.G(/<br>$/gi,"")}}o=o.G(/<p>•([\\w\\W]*?)<\\/p>/gi,"<li>$1</li>");if(c.1C("3t")){3x(/<2F>([\\w\\W]*?)<\\/2F>/gi.4c(o)){o=o.G(/<2F>([\\w\\W]*?)<\\/2F>/gi,"$1")}}if(aO===E){o=o.G(/<1g(.*?)>([\\w\\W]*?)<p(.*?)>([\\w\\W]*?)<\\/1g>/gi,"<1g$1>$2$4</1g>");o=o.G(/<1g(.*?)>([\\w\\W]*?)<\\/p>([\\w\\W]*?)<\\/1g>/gi,"<1g$1>$2$3</1g>");o=o.G(/<1g(.*?)>([\\w\\W]*?)<p(.*?)>([\\w\\W]*?)<\\/1g>/gi,"<1g$1>$2$4</1g>");o=o.G(/<1g(.*?)>([\\w\\W]*?)<\\/p>([\\w\\W]*?)<\\/1g>/gi,"<1g$1>$2$3</1g>")}o=o.G(/\\n/g," ");o=o.G(/<p>\\n?<li>/gi,"<li>");c.aL(o)},kn:B(s){s=s.G(/<br>|<\\/H[1-6]>|<\\/p>|<\\/12>/gi,"\\n");q 2H=c.X.4y("12");2H.3O=s;F c.bZ(2H.9X||2H.bC)},aL:B(o){o=c.1e("oL",E,o);if(c.5O){c.$K.o(o);c.cn();c.bX();c.1j()}I{c.9m(o)}c.5O=E;2W($.M(B(){c.85=E;if(c.1C("3c")){c.$K.1b("p:6d").1w()}if(c.bY!==E){c.k3()}},c),3P);if(c.C.4K&&c.cl!==N){$(c.X.2v).3g(c.aX)}I{c.$K.3g(c.aX)}},cL:B(4q){if(c.C.3E!==E&&1E c.C.3E==="3R"){$.1u(c.C.3E,$.M(B(k,v){if(v!=2J&&v.3T().3W("#")===0){v=$(v).1p()}4q[k]=v},c))}F 4q},k3:B(){q jL=c.$K.1b("1z[1a-3c-aW-T]");$.1u(jL,$.M(B(i,s){q $s=$(s);q 2M=s.3l.4i(",");q 4q={eI:2M[0].4i(";")[0].4i(":")[1],1a:2M[1]};4q=c.cL(4q);$.7X(c.C.cJ,4q,$.M(B(1a){q 1K=(1E 1a==="8O"?$.8G(1a):1a);$s.1i("3l",1K.5Z);$s.2C("1a-3c-aW-T");c.1j();c.1e("3Z",$s,1K)},c))},c))},jK:B(e){q 9n=e.1O.9n;q 2M=9n.4i(",");q 4q={eI:2M[0].4i(";")[0].4i(":")[1],1a:2M[1]};if(c.C.9l){4q=c.cL(4q);$.7X(c.C.cJ,4q,$.M(B(1a){q 1K=(1E 1a==="8O"?$.8G(1a):1a);q o=\'<1z 3l="\'+1K.5Z+\'" id="jM-T-1M" />\';c.22("5b",o,E);q T=$(c.$K.1b("1z#jM-T-1M"));if(T.1m){T.2C("id")}I{T=E}c.1j();if(T){c.1e("3Z",T,1K)}},c))}I{c.9m(\'<1z 3l="\'+9n+\'" />\')}},1Z:B(2e){if(2e!==E){c.2e()}c.C.3J.3a(c.$K.o());if(2e!==E){c.7V("3J")}},jN:B(){if(c.C.3J.1m===0){c.4m();F}c.2e();c.C.7Y.3a(c.$K.o());c.1Y(E,N);c.$K.o(c.C.3J.jJ());c.1Y();2W($.M(c.7D,c),3P)},jO:B(){if(c.C.7Y.1m===0){c.4m();F E}c.2e();c.C.3J.3a(c.$K.o());c.1Y(E,N);c.$K.o(c.C.7Y.jJ());c.1Y(N);2W($.M(c.7D,c),4)},7D:B(){c.4F();if(c.C.5F){c.5F()}},5F:B(){c.$K.1b("a").on("25",$.M(c.jD,c));c.$K.on("25.U",$.M(B(e){c.7t(e)},c));$(X).on("25.U",$.M(B(e){c.7t(e)},c))},4F:B(){if(c.C.4F===E){F E}c.$K.1b("1z").1u($.M(B(i,1B){if(c.1C("3t")){$(1B).1i("nC","on")}q L=$(1B).L();if(!L.3v("cH")&&!L.3v("cM")){c.kZ(1B)}},c));c.$K.1b(".cM, .cH").on("25",$.M(c.oM,c))},jD:B(e){q $1s=$(e.1O);q L=$(e.1O).L();if(L.3v("cH")||L.3v("cM")){F}if($1s.1U()==0||$1s[0].Q!=="A"){F}q 3Y=$1s.2V();if(c.C.1Q){q cN=c.$2Z.2V();3Y.1T=cN.1T+(3Y.1T-$(c.X).3g());3Y.1t+=cN.1t}q 4w=$(\'<V 1x="U-1s-4w"></V>\');q 1R=$1s.1i("1R");if(1R===1I){1R=""}if(1R.1m>24){1R=1R.a8(0,24)+"..."}q jF=$(\'<a 1R="\'+$1s.1i("1R")+\'" 1O="6j">\'+1R+"</a>").on("25",$.M(B(e){c.7t(E)},c));q jG=$(\'<a 1R="#">\'+c.C.1F.84+"</a>").on("25",$.M(B(e){e.2x();c.an();c.7t(E)},c));q kv=$(\'<a 1R="#">\'+c.C.1F.67+"</a>").on("25",$.M(B(e){e.2x();c.22("67");c.7t(E)},c));4w.1h(jF);4w.1h(" | ");4w.1h(jG);4w.1h(" | ");4w.1h(kv);4w.1f({1T:(3Y.1T+20)+"px",1t:3Y.1t+"px"});$(".U-1s-4w").1w();$("2v").1h(4w)},7t:B(e){if(e!==E&&e.1O.Q=="A"){F E}$(".U-1s-4w").1w()},29:B(){if(!c.C.4a){F c.X.29()}I{if(!c.C.1Q){F 4a.29()}I{F 4a.29(c.$2Z[0])}}},3m:B(){if(!c.C.4a){if(c.X.29){q 1q=c.29();if(1q.41&&1q.51){F 1q.41(0)}}F c.X.5z()}I{if(!c.C.1Q){F 4a.5z()}I{F 4a.5z(c.bM())}}},cq:B(J){c.jQ(J)},4b:B(J){c.7O(J[0]||J,0,2J,0)},7e:B(J){c.7O(J[0]||J,1,2J,1)},7O:B(4U,cD,8k,9S){if(8k==2J){8k=4U}if(9S==2J){9S=cD}q 1q=c.29();if(!1q){F}if(4U.Q=="P"&&4U.3O==""){4U.3O=c.C.2i}if(4U.Q=="cP"&&c.C.1N===E){q 6r=$(c.C.5a)[0];$(4U).2f(6r);4U=6r;8k=4U}q O=c.3m();O.7W(4U,cD);O.8g(8k,9S);bK{1q.4O()}bI(e){}1q.5e(O)},cs:B(1d){1d=1d.3N();q 1l=c.2P();if(1l){q 3K=c.jH(1l,1d);c.1j();F 3K}q 1q=c.29();q O=1q.41(0);q 3K=X.4y(1d);3K.7c(O.oG());O.3A(3K);c.cq(3K);F 3K},oF:B(){q O=c.3m();O.9K(c.$K[0]);q 1q=c.29();1q.4O();1q.5e(O)},cn:B(){c.29().4O()},cT:B(2g){q co=0;q O=c.3m();q 9z=O.9p();9z.9K(2g);9z.8g(O.7Q,O.jP);co=$.28(9z.3T()).1m;F co},hx:B(){F 2a cp(c.29().41(0))},jQ:B(el,2u,3p){if(1E 3p==="1I"){3p=2u}el=el[0]||el;q O=c.3m();O.9K(el);q 4A=c.cy(el);q 9J=E;q 77=0,78;if(4A.1m==1&&2u){O.7W(4A[0],2u);O.8g(4A[0],3p)}I{3w(q i=0,8l;8l=4A[i++];){78=77+8l.1m;if(!9J&&2u>=77&&(2u<78||(2u==78&&i<4A.1m))){O.7W(8l,2u-77);9J=N}if(9J&&3p<=78){O.8g(8l,3p-77);8h}77=78}}q 1q=c.29();1q.4O();1q.5e(O)},jZ:B(J){c.$K.2j();J=J[0]||J;q O=c.X.5z();q 2u=1;q 3p=-1;O.7W(J,2u);O.8g(J,3p+2);q 1J=c.48.29();q cw=c.X.5z();q al=c.X.8d("\\7m");$(J).2E(al);cw.9d(al);1J.4O();1J.5e(cw);$(al).1w()},cy:B(J){q 4A=[];if(J.4v==3){4A.3a(J)}I{q 4k=J.8p;3w(q i=0,4T=4k.1m;i<4T;++i){4A.3a.cx(4A,c.cy(4k[i]))}}F 4A},3S:B(){q el=E;q 1q=c.29();if(1q&&1q.51>0){el=1q.41(0).5T}F c.4g(el)},2B:B(1B){1B=1B||c.3S();if(1B){F c.4g($(1B).L()[0])}I{F E}},2P:B(J){if(1E J==="1I"){J=c.3S()}3x(J){if(c.7n(J)){if($(J).3v("4e")){F E}F J}J=J.4Q}F E},3H:B(1V){q 8m=[];if(1E 1V=="1I"){q O=c.3m();if(O&&O.4M===N){F[c.2P()]}q 1V=c.7b(O)}$.1u(1V,$.M(B(i,J){if(c.C.1Q===E&&$(J).8y("12.4e").1U()==0){F E}if(c.7n(J)){8m.3a(J)}},c));if(8m.1m===0){8m=[c.2P()]}F 8m},oA:B(J){if(J.4v!=1){F E}F!c.a7.4c(J.jY)},7n:B(J){F J.4v==1&&c.a7.4c(J.jY)},bl:B(1d){F c.a7.4c(1d)},7b:B(O,1d){if(1E O=="1I"||O==E){q O=c.3m()}if(O&&O.4M===N){if(1E 1d==="1I"&&c.bl(1d)){q 1l=c.2P();if(1l.Q==1d){F[1l]}I{F[]}}I{F[c.3S()]}}q 1V=[],4z=[];q 1q=c.X.29();if(!1q.q2){1V=c.bk(1q.41(0))}$.1u(1V,$.M(B(i,J){if(c.C.1Q===E&&$(J).8y("12.4e").1U()==0){F E}if(1E 1d==="1I"){if($.28(J.9X)!=""){4z.3a(J)}}I{if(J.Q==1d){4z.3a(J)}}},c));if(4z.1m==0){if(1E 1d==="1I"&&c.bl(1d)){q 1l=c.2P();if(1l.Q==1d){F 4z.3a(1l)}I{F[]}}I{4z.3a(c.3S())}}q 2X=4z[4z.1m-1];if(c.7n(2X)){4z=4z.k0(0,-1)}F 4z},7U:B(J){if(!J){J=c.3S()}3x(J){if(J.4v==1){if($(J).3v("4e")){F E}F J}J=J.4Q}F E},bk:B(O){O=O||c.3m();q J=O.5T;q bL=O.7Q;if(J==bL){F[J]}q a5=[];3x(J&&J!=bL){a5.3a(J=c.jX(J))}J=O.5T;3x(J&&J!=O.oy){a5.k2(J);J=J.4Q}F a5},jX:B(J){if(J.oB()){F J.8z}I{3x(J&&!J.jS){J=J.4Q}if(!J){F 2J}F J.jS}},9V:B(){F c.29().3T()},jR:B(){q o="";q 1q=c.29();if(1q.51){q bB=c.X.4y("12");q 4T=1q.51;3w(q i=0;i<4T;++i){bB.7c(1q.41(i).oC())}o=bB.3O}F c.bF(o)},2e:B(){if(!c.7H()){c.4m()}if(!c.C.4a){c.jV(c.3m())}I{c.5M=4a.oE()}},jV:B(O,1w){if(!O){F}q 5K=$(\'<V id="1J-1M-1" 1x="U-1J-1M">\'+c.C.2i+"</V>",c.X)[0];q 7P=$(\'<V id="1J-1M-2" 1x="U-1J-1M">\'+c.C.2i+"</V>",c.X)[0];if(O.4M===N){c.9e(O,5K,N)}I{c.9e(O,5K,N);c.9e(O,7P,E)}c.5M=c.$K.o();c.1Y(E,E)},9e:B(O,J,1G){q 9j=O.9p();bK{9j.5I(1G);9j.3A(J);9j.oD()}bI(e){q o=c.C.5a;if(c.C.1N){o="<br>"}c.$K.6v(o);c.2j()}},1Y:B(G,1w){if(!c.C.4a){if(G===N&&c.5M){c.$K.o(c.5M)}q 5K=c.$K.1b("V#1J-1M-1");q 7P=c.$K.1b("V#1J-1M-2");if(c.1C("3c")){c.$K.2j()}I{if(!c.7H()){c.4m()}}if(5K.1m!=0&&7P.1m!=0){c.7O(5K[0],0,7P[0],0)}I{if(5K.1m!=0){c.7O(5K[0],0,2J,0)}}if(1w!==E){c.7V();c.5M=E}}I{4a.od(c.5M)}},7V:B(1G){if(!c.C.4a){$.1u(c.$K.1b("V.U-1J-1M"),B(){q o=$.28($(c).o().G(/[^\\oc-\\nP]/g,""));if(o==""){$(c).1w()}I{$(c).2C("1x").2C("id")}})}I{4a.nO(c.5M)}},l4:B(){c.2e();c.6l(c.C.1F.1n,c.C.hy,nN,$.M(B(){$("#hq").25($.M(c.kY,c));2W(B(){$("#eh").2j()},5l)},c))},kY:B(){c.1Z(E);q ae=$("#eh").1p(),ap=$("#hs").1p(),$bq=$("<12></12>"),bu=4x.jr(4x.j5()*j4),$1n=$(\'<1n id="1n\'+bu+\'"><7L></7L></1n>\'),i,$ak,z,$b9;3w(i=0;i<ae;i++){$ak=$("<3h></3h>");3w(z=0;z<ap;z++){$b9=$("<1g>"+c.C.2i+"</1g>");if(i===0&&z===0){$b9.1h(\'<V id="1J-1M-1">\'+c.C.2i+"</V>")}$($ak).1h($b9)}$1n.1h($ak)}$bq.1h($1n);q o=$bq.o();if(c.C.1N===E&&c.1C("3c")){o+="<p>"+c.C.2i+"</p>"}c.3b();c.1Y();q 1r=c.2P()||c.3S();if(1r&&1r.Q!="bp"){if(1r.Q=="3f"){q 1r=$(1r).2c("2q, ol")}$(1r).2E(o)}I{c.ah(o,E)}c.1Y();q 1n=c.$K.1b("#1n"+bu);c.7K();1n.1b("V#1J-1M-1, 4o#1J-1M-1").1w();1n.2C("id");c.1j()},l6:B(){q $1n=$(c.2B()).2c("1n");if(!c.4g($1n)){F E}if($1n.1U()==0){F E}c.1Z();$1n.1w();c.1j()},kV:B(){q L=c.2B();q $1n=$(L).2c("1n");if(!c.4g($1n)){F E}if($1n.1U()==0){F E}c.1Z();q $4r=$(L).2c("3h");q $bx=$4r.4Z().1m?$4r.4Z():$4r.4l();if($bx.1m){q $bw=$bx.4k("1g").l7();if($bw.1m){$bw.6v(\'<V id="1J-1M-1">\'+c.C.2i+"</V>")}}$4r.1w();c.1Y();$1n.1b("V#1J-1M-1").1w();c.1j()},kW:B(){q L=c.2B();q $1n=$(L).2c("1n");if(!c.4g($1n)){F E}if($1n.1U()==0){F E}c.1Z();q $6e=$(L).2c("1g");if(!($6e.is("1g"))){$6e=$6e.2c("1g")}q 2I=$6e.2R(0).nQ;$1n.1b("3h").1u($.M(B(i,1B){q ld=2I-1<0?2I+1:2I-1;if(i===0){$(1B).1b("1g").eq(ld).6v(\'<V id="1J-1M-1">\'+c.C.2i+"</V>")}$(1B).1b("1g").eq(2I).1w()},c));c.1Y();$1n.1b("V#1J-1M-1").1w();c.1j()},l8:B(){q $1n=$(c.2B()).2c("1n");if(!c.4g($1n)){F E}if($1n.1U()==0){F E}c.1Z();if($1n.1b("3X").1U()!==0){c.d8()}I{q 3h=$1n.1b("3h").l7().6f();3h.1b("1g").o(c.C.2i);$3X=$("<3X></3X>");$3X.1h(3h);$1n.6v($3X);c.1j()}},d8:B(){q $1n=$(c.2B()).2c("1n");if(!c.4g($1n)){F E}q $3X=$1n.1b("3X");if($3X.1U()==0){F E}c.1Z();$3X.1w();c.1j()},lc:B(){c.eE("3M")},la:B(){c.eE("2E")},kT:B(){c.eK("3M")},kR:B(){c.eK("2E")},eE:B(1G){q $1n=$(c.2B()).2c("1n");if(!c.4g($1n)){F E}if($1n.1U()==0){F E}c.1Z();q $4r=$(c.2B()).2c("3h");q bf=$4r.6f();bf.1b("1g").o(c.C.2i);if(1G==="2E"){$4r.2E(bf)}I{$4r.3M(bf)}c.1j()},eK:B(1G){q L=c.2B();q $1n=$(L).2c("1n");if(!c.4g($1n)){F E}if($1n.1U()==0){F E}c.1Z();q 2I=0;q 1r=c.3S();q $4r=$(1r).2c("3h");q $6e=$(1r).2c("1g");$4r.1b("1g").1u($.M(B(i,1B){if($(1B)[0]===$6e[0]){2I=i}},c));$1n.1b("3h").1u($.M(B(i,1B){q $1r=$(1B).1b("1g").eq(2I);q 1g=$1r.6f();1g.o(c.C.2i);1G==="2E"?$1r.2E(1g):$1r.3M(1g)},c));c.1j()},kC:B(){c.2e();c.6l(c.C.1F.3C,c.C.hp,nR,$.M(B(){$("#hv").25($.M(c.kD,c));2W(B(){$("#eT").2j()},5l)},c))},kD:B(){q 1a=$("#eT").1p();1a=c.7S(1a);q 5n=\'<1Q 2l="bW" 21="kQ" 3l="\',6U=\'" c2="0" kO></1Q>\';if(1a.1S(8s)){1a=1a.G(8s,5n+"//bg.bU.6V/4X/$1"+6U)}I{if(1a.1S(8x)){1a=1a.G(8x,5n+"//kH.bN.6V/3C/$2"+6U)}}c.1Y();q 1r=c.2P()||c.3S();if(1r){$(1r).2E(1a)}I{c.ah(1a,E)}c.1j();c.3b()},an:B(){c.2e();q 1e=$.M(B(){if(c.C.eQ!==E){c.ai={};q 4J=c;$.kI(c.C.eQ,B(1a){q $3n=$("#U-hz-hB");$3n.o("");$.1u(1a,B(1k,1p){4J.ai[1k]=1p;$3n.1h($("<47>").1p(1k).o(1p.2n))});$3n.on("5W",B(){q 1k=$(c).1p();q 2n="",1L="";if(1k!=0){2n=4J.ai[1k].2n;1L=4J.ai[1k].1L}$("#8j").1p(1L);$("#aa").1p(2n)});$3n.2N()})}c.7E=E;q 1q=c.29();q 1L="",Y="",1O="";q 1B=c.2B();q 6r=$(1B).L().2R(0);if(6r&&6r.Q==="A"){1B=6r}if(1B&&1B.Q==="A"){1L=1B.1R;Y=$(1B).Y();1O=1B.1O;c.7E=1B}I{Y=1q.3T()}$("#aa").1p(Y);q kE=kB.kA.1R.G(/\\/$/i,"");1L=1L.G(kE,"");1L=1L.G(/^\\/#/,"#");1L=1L.G("er:","");if(c.C.7I===E){q re=2a 2L("^(9W|9u|5C)://"+kB.kA.nT,"i");1L=1L.G(re,"")}$("#8j").1p(1L);if(1O==="6j"){$("#70").aS("aT",N)}c.eB=E;$("#hD").on("25",$.M(c.ky,c));2W(B(){$("#8j").2j()},5l)},c);c.6l(c.C.1F.1s,c.C.hA,nS,1e)},ky:B(){if(c.eB){F}c.eB=N;q 1O="",eS="";q 1s=$("#8j").1p();q Y=$("#aa").1p();if(1s.4G("@")!=-1&&/(9W|9u|5C):\\/\\//i.4c(1s)===E){1s="er:"+1s}I{if(1s.4G("#")!=0){if($("#70").aS("aT")){1O=\' 1O="6j"\';eS="6j"}q eo="((nM--)?[a-ep-9]+(-[a-ep-9]+)*.)+[a-z]{2,}";q re=2a 2L("^(9W|9u|5C)://"+eo,"i");q kM=2a 2L("^"+eo,"i");if(1s.4G(re)==-1&&1s.4G(kM)==0&&c.C.7I){1s=c.C.7I+1s}}}Y=Y.G(/<|>/g,"");q ek="&3u;";if(c.1C("3c")){ek="&3u;"}c.kK(\'<a 1R="\'+1s+\'"\'+1O+">"+Y+"</a>"+ek,$.28(Y),1s,eS)},kK:B(a,Y,1s,1O){c.1Y();if(Y!==""){if(c.7E){c.1Z();$(c.7E).Y(Y).1i("1R",1s);if(1O!==""){$(c.7E).1i("1O",1O)}I{$(c.7E).2C("1O")}}I{q $a=$(a).2y("U-eu-1s");c.2p("5b",c.49($a),E);q 1s=c.$K.1b("a.U-eu-1s");1s.2C("1o").3e("U-eu-1s").1u(B(){if(c.2U==""){$(c).2C("1x")}})}c.1j()}2W($.M(B(){if(c.C.5F){c.5F()}},c),5);c.3b()},kL:B(){c.2e();q 1e=$.M(B(){q 1q=c.29();q Y="";if(c.cv()){Y=1q.Y}I{Y=1q.3T()}$("#dE").1p(Y);if(!c.5c()&&!c.bH()){c.et("#5s",{1L:c.C.7N,3E:c.C.3E,4n:$.M(c.ew,c),3V:$.M(B(7F,1K){c.1e("ho",1K)},c),6x:c.C.dF})}c.e7("5s",{4d:N,1L:c.C.7N,4n:$.M(c.ew,c),3V:$.M(B(7F,1K){c.1e("ho",1K)},c)})},c);c.6l(c.C.1F.26,c.C.iw,bW,1e)},ew:B(1K){c.1Y();if(1K!==E){q Y=$("#dE").1p();if(Y===""){Y=1K.dI}q 1s=\'<a 1R="\'+1K.5Z+\'" id="5Z-1M">\'+Y+"</a>";if(c.1C("4C")&&!!c.48.cC){1s=1s+"&3u;"}c.22("5b",1s,E);q 7T=$(c.$K.1b("a#5Z-1M"));if(7T.1U()!=0){7T.2C("id")}I{7T=E}c.1j();c.1e("7N",7T,1K)}c.3b()},kJ:B(){c.2e();q 1e=$.M(B(){if(c.C.7k){$.kI(c.C.7k,$.M(B(1a){q 7j={},7o=0;$.1u(1a,$.M(B(1k,1p){if(1E 1p.a0!=="1I"){7o++;7j[1p.a0]=7o}},c));q 9c=E;$.1u(1a,$.M(B(1k,1p){q f0="";if(1E 1p.1c!=="1I"){f0=1p.1c}q 9G=0;if(!$.kx(7j)&&1E 1p.a0!=="1I"){9G=7j[1p.a0];if(9c===E){9c=".7h"+9G}}q 1z=$(\'<1z 3l="\'+1p.nL+\'" 1x="7h 7h\'+9G+\'" 4h="\'+1p.T+\'" 1c="\'+f0+\'" />\');$("#dN").1h(1z);$(1z).25($.M(c.iq,c))},c));if(!$.kx(7j)){$(".7h").2T();$(9c).2N();q kw=B(e){$(".7h").2T();$(".7h"+$(e.1O).1p()).2N()};q 3n=$(\'<3n id="nF">\');$.1u(7j,B(k,v){3n.1h($(\'<47 2t="\'+v+\'">\'+k+"</47>"))});$("#dN").3M(3n);3n.5W(kw)}},c))}I{$("#U-53-6A-2").1w()}if(c.C.3Z||c.C.5p){if(!c.5c()&&!c.bH()&&c.C.5p===E){if($("#5s").1m){c.et("#5s",{1L:c.C.3Z,3E:c.C.3E,4n:$.M(c.ed,c),3V:$.M(B(7F,1K){c.1e("by",1K)},c),6x:c.C.ba})}}if(c.C.5p===E){c.e7("5s",{4d:N,1L:c.C.3Z,4n:$.M(c.ed,c),3V:$.M(B(7F,1K){c.1e("by",1K)},c)})}I{$("#5s").on("5W.U",$.M(c.j6,c))}}I{$(".5x").2T();if(!c.C.7k){$("#5m").1w();$("#il").2N()}I{$("#U-53-6A-1").1w();$("#U-53-6A-2").2y("6S");$("#im").2N()}}if(!c.C.kF&&(c.C.3Z||c.C.7k)){$("#U-53-6A-3").2T()}$("#hV").25($.M(c.it,c));if(!c.C.3Z&&!c.C.7k){2W(B(){$("#6b").2j()},5l)}},c);c.6l(c.C.1F.T,c.C.ik,nE,1e)},jC:B(T){q $el=T;q L=$el.L().L();q 1e=$.M(B(){$("#dO").1p($el.1i("87"));$("#nD").1i("1R",$el.1i("3l"));if($el.1f("3i")=="1l"&&$el.1f("5o")=="3o"){$("#aQ").1p("6D")}I{$("#aQ").1p($el.1f("5o"))}if($(L).2R(0).Q==="A"){$("#6b").1p($(L).1i("1R"));if($(L).1i("1O")=="6j"){$("#70").aS("aT",N)}}$("#ii").25($.M(B(){c.d1($el)},c));$("#ij").25($.M(B(){c.l5($el)},c))},c);c.6l(c.C.1F.84,c.C.ip,nG,1e)},d1:B(el){q 8Y=$(el).L().L();q L=$(el).L();q ad=E;if(8Y.1m&&8Y[0].Q==="A"){ad=N;$(8Y).1w()}I{if(L.1m&&L[0].Q==="A"){ad=N;$(L).1w()}I{$(el).1w()}}if(L.1m&&L[0].Q==="P"){c.4m();if(ad===E){c.4b(L)}}c.1e("nH",el);c.3b();c.1j()},l5:B(el){c.62(E);q $el=$(el);q L=$el.L();$el.1i("87",$("#dO").1p());q bd=$("#aQ").1p();q 2G="";if(bd==="1t"){2G="0 "+c.C.8c+" "+c.C.8c+" 0";$el.1f({"5o":"1t",2G:2G})}I{if(bd==="4I"){2G="0 0 "+c.C.8c+" "+c.C.8c+"";$el.1f({"5o":"4I",2G:2G})}I{if(bd==="6D"){$el.1f({"5o":"",3i:"1l",2G:"4d"})}I{$el.1f({"5o":"",3i:"",2G:""})}}}q 1s=$.28($("#6b").1p());if(1s!==""){q 1O=E;if($("#70").aS("aT")){1O=N}if(L.2R(0).Q!=="A"){q a=$(\'<a 1R="\'+1s+\'">\'+c.49(el)+"</a>");if(1O){a.1i("1O","6j")}$el.2f(a)}I{L.1i("1R",1s);if(1O){L.1i("1O","6j")}I{L.2C("1O")}}}I{if(L.2R(0).Q==="A"){L.2f(c.49(el))}}c.3b();c.4F();c.1j()},62:B(e){if(e!==E&&$(e.1O).L().1U()!=0&&$(e.1O).L()[0].id==="U-T-2A"){F E}q 2Y=c.$K.1b("#U-T-2A");if(2Y.1U()==0){F E}c.$K.1b("#U-T-d6, #U-T-da").1w();2Y.1b("1z").1f({5H:2Y[0].1o.5H,9T:2Y[0].1o.9T,5D:2Y[0].1o.5D,9U:2Y[0].1o.9U});2Y.1f("2G","");2Y.1b("1z").1f("i5","");2Y.2f(B(){F $(c).1W()});$(X).3z("25.U-T-80-2T");c.$K.3z("25.U-T-80-2T");c.$K.3z("5y.U-T-d2");c.1j()},kZ:B(T){q $T=$(T);$T.on("8U",$.M(B(){c.62(E)},c));$T.on("nK",$.M(B(){c.$K.on("6y.U-T-l2-6y",$.M(B(){2W($.M(B(){c.4F();c.$K.3z("6y.U-T-l2-6y");c.1j()},c),1)},c))},c));$T.on("25",$.M(B(e){if(c.$K.1b("#U-T-2A").1U()!=0){F E}q nJ=E,9M,9F,dy=$T.2l()/$T.21(),i9=20,nI=10;q 5k=c.ib($T);q 9B=E;if(5k!==E){5k.on("8U",B(e){9B=N;e.2x();dy=$T.2l()/$T.21();9M=4x.6q(e.dw-$T.eq(0).2V().1t);9F=4x.6q(e.dg-$T.eq(0).2V().1T)});$(c.X.2v).on("jB",$.M(B(e){if(9B){q nU=4x.6q(e.dw-$T.eq(0).2V().1t)-9M;q i6=4x.6q(e.dg-$T.eq(0).2V().1T)-9F;q i7=$T.21();q i8=9C(i7,10)+i6;q 9H=4x.6q(i8*dy);if(9H>i9){$T.2l(9H);if(9H<3P){c.69.1f({5H:"-aM",5D:"-nV",8a:"o7",95:"o6 i1"})}I{c.69.1f({5H:"-92",5D:"-i4",8a:"92",95:"aM 9a"})}}9M=4x.6q(e.dw-$T.eq(0).2V().1t);9F=4x.6q(e.dg-$T.eq(0).2V().1T);c.1j()}},c)).on("9x",B(){9B=E})}c.$K.on("5y.U-T-d2",$.M(B(e){q 1k=e.6h;if(c.2O.9D==1k||c.2O.d3==1k){c.1Z(E);c.62(E);c.d1($T)}},c));$(X).on("25.U-T-80-2T",$.M(c.62,c));c.$K.on("25.U-T-80-2T",$.M(c.62,c))},c))},ib:B($T){q 2Y=$(\'<V id="U-T-2A" 1a-U="8R">\');2Y.1f({3j:"ia",3i:"4o-1l",d7:0,o5:"i3 o8 o9(0, 0, 0, .6)","5o":$T.1f("5o")});2Y.1i("3F",E);if($T[0].1o.2G!="4d"){2Y.1f({5H:$T[0].1o.5H,9T:$T[0].1o.9T,5D:$T[0].1o.5D,9U:$T[0].1o.9U});$T.1f("2G","")}I{2Y.1f({3i:"1l",2G:"4d"})}$T.1f("i5",0.5).2E(2Y);c.69=$(\'<V id="U-T-d6" 1a-U="8R">\'+c.C.1F.84+"</V>");c.69.1f({3j:"8B",8Q:5,1T:"50%",1t:"50%",5H:"-92",5D:"-i4",d7:1,ic:"#ie",8i:"#i2",8a:"92",95:"aM 9a",eM:"ob"});c.69.1i("3F",E);c.69.on("25",$.M(B(){c.jC($T)},c));2Y.1h(c.69);if(c.C.hX){q 5k=$(\'<V id="U-T-da" 1a-U="8R"></V>\');5k.1f({3j:"8B",8Q:2,d7:1,eM:"nw-80",i0:"-oa",4I:"-i1",o4:"i3 o3 #i2",ic:"#ie",2l:"ir",21:"ir"});5k.1i("3F",E);2Y.1h(5k);2Y.1h($T);F 5k}I{2Y.1h($T);F E}},iq:B(e){q 1z=\'<1z id="T-1M" 3l="\'+$(e.1O).1i("4h")+\'" 87="\'+$(e.1O).1i("1c")+\'" />\';q L=c.2B();if(c.C.6a&&$(L).2c("li").1U()==0){1z="<p>"+1z+"</p>"}c.9k(1z,N)},it:B(){q 1p=$("#6b").1p();if(1p!==""){q 1a=\'<1z id="T-1M" 3l="\'+1p+\'" />\';if(c.C.1N===E){1a="<p>"+1a+"</p>"}c.9k(1a,N)}I{c.3b()}},ed:B(1a){c.9k(1a)},9k:B(1K,1s){c.1Y();if(1K!==E){q o="";if(1s!==N){o=\'<1z id="T-1M" 3l="\'+1K.5Z+\'" />\';q L=c.2B();if(c.C.6a&&$(L).2c("li").1U()==0){o="<p>"+o+"</p>"}}I{o=1K}c.22("5b",o,E);q T=$(c.$K.1b("1z#T-1M"));if(T.1m){T.2C("id")}I{T=E}c.1j();1s!==N&&c.1e("3Z",T,1K)}c.3b();c.4F()},dY:B(){if($("#U-eO").1U()!=0){F}c.$aU=$(\'<12 id="U-eO"><V></V></12>\');$(X.2v).1h(c.$aU)},8I:B(){c.dY();c.$aU.nY()},9Z:B(){c.dY();c.$aU.6J(nX)},iu:B(){$.4H(c.C,{iw:4S()+\'<2m id="U-6g-26-4u"><2s id="nW" 5w="7X" 7q="" a6="9q/2s-1a"><2D>\'+c.C.1F.dI+\'</2D><2S 1G="Y" id="dE" 1x="6T" /><12 1o="2G-1T: aM;"><2S 1G="26" id="5s" 2n="\'+c.C.dF+\'" /></12></2s></2m>\',ip:4S()+\'<2m id="U-6g-T-84"><2D>\'+c.C.1F.1c+\'</2D><2S 1G="Y" id="dO" 1x="6T" /><2D>\'+c.C.1F.1s+\'</2D><2S 1G="Y" id="6b" 1x="6T" /><2D><2S 1G="hE" id="70"> \'+c.C.1F.dA+"</2D><2D>"+c.C.1F.io+\'</2D><3n id="aQ"><47 2t="3o">\'+c.C.1F.3o+\'</47><47 2t="1t">\'+c.C.1F.1t+\'</47><47 2t="6D">\'+c.C.1F.6D+\'</47><47 2t="4I">\'+c.C.1F.4I+\'</47></3n></2m><44><1D id="ii" 1x="4t nZ">\'+c.C.1F.ih+\'</1D><1D 1x="4t 6L">\'+c.C.1F.6I+\'</1D><1D id="ij" 1x="4t 6K">\'+c.C.1F.83+"</1D></44>",ik:4S()+\'<2m id="U-6g-T-4u"><12 id="5m"><a 1R="#" id="U-53-6A-1" 1x="6S">\'+c.C.1F.8r+\'</a><a 1R="#" id="U-53-6A-2">\'+c.C.1F.dR+\'</a><a 1R="#" id="U-53-6A-3">\'+c.C.1F.1s+\'</a></12><2s id="o0" 5w="7X" 7q="" a6="9q/2s-1a"><12 id="o2" 1x="5x"><2S 1G="26" id="5s" 2n="\'+c.C.ba+\'" /></12><12 id="im" 1x="5x" 1o="3i: 3o;"><12 id="dN"></12></12></2s><12 id="il" 1x="5x" 1o="3i: 3o;"><2D>\'+c.C.1F.hW+\'</2D><2S 1G="Y" 2n="6b" id="6b" 1x="6T" /><br><br></12></2m><44><1D 1x="4t 6L">\'+c.C.1F.6I+\'</1D><1D 1x="4t 6K" id="hV">\'+c.C.1F.4u+"</1D></44>",hA:4S()+\'<2m id="U-6g-1s-4u"><3n id="U-hz-hB" 1o="2l: 99.5%; 3i: 3o;"></3n><2D>hC</2D><2S 1G="Y" 1x="6T" id="8j" /><2D>\'+c.C.1F.Y+\'</2D><2S 1G="Y" 1x="6T" id="aa" /><2D><2S 1G="hE" id="70"> \'+c.C.1F.dA+\'</2D></2m><44><1D 1x="4t 6L">\'+c.C.1F.6I+\'</1D><1D id="hD" 1x="4t 6K">\'+c.C.1F.4u+"</1D></44>",hy:4S()+\'<2m id="U-6g-1n-4u"><2D>\'+c.C.1F.ae+\'</2D><2S 1G="Y" 1U="5" 2t="2" id="eh" /><2D>\'+c.C.1F.ap+\'</2D><2S 1G="Y" 1U="5" 2t="3" id="hs" /></2m><44><1D 1x="4t 6L">\'+c.C.1F.6I+\'</1D><1D id="hq" 1x="4t 6K">\'+c.C.1F.4u+"</1D></44>",hp:4S()+\'<2m id="U-6g-3C-4u"><2s id="o1"><2D>\'+c.C.1F.ht+\'</2D><5R id="eT" 1o="2l: 99%; 21: oO;"></5R></2s></2m><44><1D 1x="4t 6L">\'+c.C.1F.6I+\'</1D><1D id="hv" 1x="4t 6K">\'+c.C.1F.4u+"</1D></44>"})},6l:B(1c,3I,2l,1e){c.hL();c.$a1=2l;c.$2Q=$("#fe");if(!c.$2Q.1m){c.$2Q=$(\'<12 id="fe" 1o="3i: 3o;" />\');c.$2Q.1h($(\'<12 id="eR">&oP;</12>\'));c.$2Q.1h($(\'<aI id="9i" />\'));c.$2Q.1h($(\'<12 id="at" />\'));c.$2Q.8D(X.2v)}$("#eR").on("25",$.M(c.3b,c));$(X).58($.M(c.ez,c));c.$K.58($.M(c.ez,c));c.hI(3I);c.hH(1c);c.ix();c.jh();c.hM();c.hJ();c.6Z=c.X.2v.3g;if(c.C.4K===E){c.6Z=c.$K.3g()}if(c.5c()===E){c.hU()}I{c.hO()}if(1E 1e==="B"){1e()}2W($.M(B(){c.1e("pE",c.$2Q)},c),11);$(X).3z("pD.6g");c.$2Q.1b("2S[1G=Y]").on("pC",$.M(B(e){if(e.6h===13){c.$2Q.1b(".6K").25();e.2x()}},c));F c.$2Q},hU:B(){c.$2Q.1f({3j:"9w",1T:"-d4",1t:"50%",2l:c.$a1+"px",5D:"-"+(c.$a1/2)+"px"}).2N();c.dB=$(X.2v).1f("af");$(X.2v).1f("af","8F");2W($.M(B(){q 21=c.$2Q.jk();c.$2Q.1f({1T:"50%",21:"4d",7R:"4d",5H:"-"+(21+10)/2+"px"})},c),15)},hO:B(){c.$2Q.1f({3j:"9w",2l:"3P%",21:"3P%",1T:"0",1t:"0",2G:"0",7R:"pF"}).2N()},hI:B(3I){c.6o=E;if(3I.3W("#")==0){c.6o=$(3I);$("#at").6d().1h(c.6o.o());c.6o.o("")}I{$("#at").6d().1h(3I)}},hH:B(1c){c.$2Q.1b("#9i").o(1c)},hJ:B(){q 42=c.$2Q.1b("44 1D").ar(".pG");q eD=42.1U();if(eD>0){$(42).1f("2l",(c.$a1/eD)+"px")}},hM:B(){c.$2Q.1b(".6L").on("25",$.M(c.3b,c))},hL:B(){if(c.C.eX){c.$8M=$("#eY");if(!c.$8M.1m){c.$8M=$(\'<12 id="eY" 1o="3i: 3o;"></12>\');$("2v").6v(c.$8M)}c.$8M.2N().on("25",$.M(c.3b,c))}},ix:B(){if(1E $.fn.iy!=="1I"){c.$2Q.iy({pI:"#9i"});c.$2Q.1b("#9i").1f("eM","pH")}},jh:B(){q $5m=$("#5m");if(!$5m.1m){F E}q 4J=c;$5m.1b("a").1u(B(i,s){i++;$(s).on("25",B(e){e.2x();$5m.1b("a").3e("6S");$(c).2y("6S");$(".5x").2T();$("#5x"+i).2N();$("#pB").1p(i);if(4J.5c()===E){q 21=4J.$2Q.jk();4J.$2Q.1f("2G-1T","-"+(21+10)/2+"px")}})})},ez:B(e){if(e.2O===c.2O.eA){c.3b();F E}},3b:B(){$("#eR").3z("25",c.3b);$("#fe").6J("pA",$.M(B(){q fb=$("#at");if(c.6o!==E){c.6o.o(fb.o());c.6o=E}fb.o("");if(c.C.eX){$("#eY").2T().3z("25",c.3b)}$(X).je("58",c.jd);c.$K.je("58",c.jd);c.1Y();if(c.C.4K&&c.6Z){$(c.X.2v).3g(c.6Z)}I{if(c.C.4K===E&&c.6Z){c.$K.3g(c.6Z)}}c.1e("pu")},c));if(c.5c()===E){$(X.2v).1f("af",c.dB?c.dB:"j7")}F E},pt:B(dC){$(".5x").2T();$("#5m").1b("a").3e("6S").eq(dC-1).2y("6S");$("#5x"+dC).2N()},j6:B(e){q 7d=e.1O.7d;3w(q i=0,f;f=7d[i];i++){c.e2(f)}},e2:B(26){c.ja(26,$.M(B(j9){c.jz(26,j9)},c))},ja:B(26,1e){q 2k=2a jy();q ee="?";if(c.C.5p.4G(/\\?/)!="-1"){ee="&"}2k.b1("ps",c.C.5p+ee+"2n="+26.2n+"&1G="+26.1G,N);if(2k.jl){2k.jl("Y/pv; pw=x-pz-py")}q 4J=c;2k.pJ=B(e){if(c.jv==4&&c.e9==5l){4J.8I();1e(pK(c.pW))}I{if(c.jv==4&&c.e9!=5l){}}};2k.jp()},ju:B(5w,1L){q 2k=2a jy();if("pV"in 2k){2k.b1(5w,1L,N)}I{if(1E jA!="1I"){2k=2a jA();2k.b1(5w,1L)}I{2k=2J}}F 2k},jz:B(26,1L){q 2k=c.ju("pU",1L);if(!2k){}I{2k.jt=$.M(B(){if(2k.e9==5l){c.9Z();q eg=1L.4i("?");if(!eg[0]){F E}c.1Y();q o="";o=\'<1z id="T-1M" 3l="\'+eg[0]+\'" />\';if(c.C.6a){o="<p>"+o+"</p>"}c.22("5b",o,E);q T=$(c.$K.1b("1z#T-1M"));if(T.1m){T.2C("id")}I{T=E}c.1j();c.1e("3Z",T,E);c.3b();c.4F()}I{}},c);2k.pX=B(){};2k.8r.pY=B(e){};2k.jo("q0-pZ",26.1G);2k.jo("x-pT-pS","pN-pM");2k.jp(26)}},e7:B(el,3Q){c.3B={1L:E,4n:E,3V:E,2u:E,e0:E,4d:E,2S:E};$.4H(c.3B,3Q);q $el=$("#"+el);if($el.1m&&$el[0].Q==="pL"){c.3B.2S=$el;c.el=$($el[0].2s)}I{c.el=$el}c.iC=c.el.1i("7q");if(c.3B.4d){$(c.3B.2S).5W($.M(B(e){c.el.dn(B(e){F E});c.dZ(e)},c))}I{if(c.3B.e0){$("#"+c.3B.e0).25($.M(c.dZ,c))}}},dZ:B(e){c.8I();c.iI(c.2g,c.js())},js:B(){c.id="f"+4x.jr(4x.j5()*j4);q d=c.X.4y("12");q 1Q=\'<1Q 1o="3i:3o" id="\'+c.id+\'" 2n="\'+c.id+\'"></1Q>\';d.3O=1Q;$(d).8D("2v");if(c.3B.2u){c.3B.2u()}$("#"+c.id).iJ($.M(c.iH,c));F c.id},iI:B(f,2n){if(c.3B.2S){q cZ="pO"+c.id,iN="pP"+c.id;c.2s=$(\'<2s 7q="\'+c.3B.1L+\'" 5w="eH" 1O="\'+2n+\'" 2n="\'+cZ+\'" id="\'+cZ+\'" a6="9q/2s-1a" />\');if(c.C.3E!==E&&1E c.C.3E==="3R"){$.1u(c.C.3E,$.M(B(k,v){if(v!=2J&&v.3T().3W("#")===0){v=$(v).1p()}q 8F=$("<2S/>",{1G:"8F",2n:k,2t:v});$(c.2s).1h(8F)},c))}q d0=c.3B.2S;q 8A=$(d0).6f();$(d0).1i("id",iN).3M(8A).8D(c.2s);$(c.2s).1f("3j","8B").1f("1T","-d4").1f("1t","-d4").8D("2v");c.2s.dn()}I{f.1i("1O",2n).1i("5w","eH").1i("a6","9q/2s-1a").1i("7q",c.3B.1L);c.2g.dn()}},iH:B(){q i=$("#"+c.id)[0],d;if(i.iG){d=i.iG}I{if(i.dp){d=i.dp.X}I{d=48.pR[c.id].X}}if(c.3B.4n){c.9Z();if(1E d!=="1I"){q iA=d.2v.3O;q 7g=iA.1S(/\\{(.|\\n)*\\}/)[0];7g=7g.G(/^\\[/,"");7g=7g.G(/\\]$/,"");q 1K=$.8G(7g);if(1E 1K.3V=="1I"){c.3B.4n(1K)}I{c.3B.3V(c,1K);c.3b()}}I{c.3b();pQ("iz pr!")}}c.el.1i("7q",c.iC);c.el.1i("1O","")},et:B(el,3Q){c.5P=$.4H({1L:E,4n:E,3V:E,pq:E,3E:E,Y:c.C.1F.iD,iO:c.C.1F.iF,6x:E},3Q);if(48.eP===1I){F E}c.eU=$(\'<12 1x="p2"></12>\');c.5f=$(\'<12 1x="p1">\'+c.5P.Y+"</12>");c.iP=$(\'<12 1x="p0">\'+c.5P.iO+"</12>");c.eU.1h(c.5f);$(el).3M(c.eU);$(el).3M(c.iP);c.5f.on("p3",$.M(B(){F c.iU()},c));c.5f.on("p4",$.M(B(){F c.hY()},c));c.5f.2R(0).p6=$.M(B(e){e.2x();c.5f.3e("bo").2y("6y");c.8I();c.ey(c.5P.1L,e.8T.7d[0],E,e,c.5P.6x)},c)},ey:B(1L,26,bv,e,6x){if(!bv){q 2k=$.p5.2k();if(2k.8r){2k.8r.oZ("eO",$.M(c.iV,c),E)}$.oY({2k:B(){F 2k}})}c.1e("6y",e);q fd=2a eP();if(6x!==E){fd.1h(6x,26)}I{fd.1h("26",26)}if(c.C.3E!==E&&1E c.C.3E==="3R"){$.1u(c.C.3E,$.M(B(k,v){if(v!=2J&&v.3T().3W("#")===0){v=$(v).1p()}fd.1h(k,v)},c))}$.j2({1L:1L,oS:"o",1a:fd,oR:E,eI:E,oQ:E,1G:"eH",4n:$.M(B(1a){1a=1a.G(/^\\[/,"");1a=1a.G(/\\]$/,"");q 1K=(1E 1a==="8O"?$.8G(1a):1a);c.9Z();if(bv){q $1z=$("<1z>");$1z.1i("3l",1K.5Z).1i("id","iT-T-1M");c.iS(e,$1z[0]);q T=$(c.$K.1b("1z#iT-T-1M"));if(T.1m){T.2C("id")}I{T=E}c.1j();c.4F();if(T){c.1e("3Z",T,1K)}if(1E 1K.3V!=="1I"){c.1e("by",1K)}}I{if(1E 1K.3V=="1I"){c.5P.4n(1K)}I{c.5P.3V(c,1K);c.5P.4n(E)}}},c)})},iU:B(){c.5f.2y("bo");F E},hY:B(){c.5f.3e("bo");F E},iV:B(e,Y){q j0=e.iQ?9C(e.iQ/e.oT*3P,10):e;c.5f.Y("oU "+j0+"% "+(Y||""))},5c:B(){F/(oX|oW|oV|p7)/.4c(6k.7i)},bH:B(){F/p8/.4c(6k.7i)},9g:B(4D){if(1E(4D)==="1I"){F 0}F 9C(4D.G("px",""),10)},49:B(el){F $("<12>").1h($(el).eq(0).6f()).o()},pl:B(o){q 2H=X.4y("8J");2H.3O=o;F 2H.9X||2H.bC||""},iE:B(7F){F pk.5g.3T.5B(7F)=="[3R 4S]"},a4:B(o){o=o.G(/&#aY;|<br>|<br\\/>|&3u;/gi,"");o=o.G(/\\s/g,"");o=o.G(/^<p>[^\\W\\w\\D\\d]*?<\\/p>$/i,"");F o==""},pj:B(){q rv=E;if(6k.pm=="pn pp po"){q 3U=6k.7i;q re=2a 2L("pi ([0-9]{1,}[.0-9]{0,})");if(re.2p(3U)!=2J){rv=pg(2L.$1)}}F rv},8N:B(){F!!6k.7i.1S(/pb\\/7\\./)},1C:B(1C){q 3U=6k.7i.3N();q 1S=/(jc)[\\/]([\\w.]+)/.2p(3U)||/(cC)[ \\/]([\\w.]+)/.2p(3U)||/(4C)[ \\/]([\\w.]+).*(pa)[ \\/]([\\w.]+)/.2p(3U)||/(4C)[ \\/]([\\w.]+)/.2p(3U)||/(8S)(?:.*9y|)[ \\/]([\\w.]+)/.2p(3U)||/(3t) ([\\w.]+)/.2p(3U)||3U.3W("p9")>=0&&/(rv)(?::| )([\\w.]+)/.2p(3U)||3U.3W("pc")<0&&/(3c)(?:.*? rv:([\\w.]+)|)/.2p(3U)||[];if(1C=="9y"){F 1S[2]}if(1C=="4C"){F(1S[1]=="cC"||1S[1]=="4C")}if(1S[1]=="rv"){F 1C=="3t"}if(1S[1]=="jc"){F 1C=="4C"}F 1C==1S[1]},cv:B(){if(c.1C("3t")&&9C(c.1C("9y"),10)<9){F N}F E},hR:B(hQ){q 7a=hQ.pd(N);q 12=c.X.4y("12");12.7c(7a);F 12.3O},cE:B(){q J=c.$K[0];q 4f=c.X.cO();q cQ;3x((cQ=J.8z)){4f.7c(cQ)}F 4f},4g:B(el){if(!el){F E}if(c.C.1Q){F el}if($(el).8y("12.4e").1m==0||$(el).3v("4e")){F E}I{F el}},7s:B(Q){q L=c.2B(),1r=c.3S();F L&&L.Q===Q?L:1r&&1r.Q===Q?1r:E},cR:B(){q 1r=c.2P();q 2V=c.cT(1r);q Y=$.28($(1r).Y()).G(/\\n\\r\\n/g,"");q 4T=Y.1m;if(2V==4T){F N}I{F E}},7H:B(){q el,1q=c.29();if(1q&&1q.51&&1q.51>0){el=1q.41(0).5T}if(!el){F E}if(c.C.1Q){if(c.hx().iv()){F!c.$K.is(el)}I{F N}}F $(el).2c("12.4e").1m!=0},4V:B(el,1i){if($(el).1i(1i)==""){$(el).2C(1i)}},lb:B(9s,2t){q 2I=2J;3x((2I=9s.3W(2t))!==-1){9s.9r(2I,1)}F 9s}};3G.5g.7B.5g=3G.5g;$.3G.fn.c6=B(c8,6P,68,6O,6N){q 1L=/(((5C?|pf?):\\/\\/)|bg[.][^\\s])(.+?\\..+?)([.),]?)(\\s|\\.\\s+|\\)|$)/gi,kU=/(5C?|9u):\\/\\//i,bS=/(5C?:\\/\\/.*\\.(?:le|pe|kP|kN))/gi;q 8p=(c.$K?c.$K.2R(0):c).8p,i=8p.1m;3x(i--){q n=8p[i];if(n.4v===3){q o=n.aZ;if(6O&&o){q 5n=\'<1Q 2l="bW" 21="kQ" 3l="\',6U=\'" c2="0" kO></1Q>\';if(o.1S(8s)){o=o.G(8s,5n+"//bg.bU.6V/4X/$1"+6U);$(n).2E(o).1w()}I{if(o.1S(8x)){o=o.G(8x,5n+"//kH.bN.6V/3C/$2"+6U);$(n).2E(o).1w()}}}if(68&&o&&o.1S(bS)){o=o.G(bS,\'<1z 3l="$1">\');$(n).2E(o).1w()}if(6P&&o&&o.1S(1L)){q 2w=o.1S(1L);3w(q i in 2w){q 1R=2w[i];q Y=1R;q 6s="";if(1R.1S(/\\s$/)!==2J){6s=" "}q cj=c8;if(1R.1S(kU)!==2J){cj=""}if(Y.1m>6N){Y=Y.a8(0,6N)+"..."}Y=Y.G(/&/g,"&ab;").G(/</g,"<").G(/>/g,">");q ku=Y.G("$","$$$");o=o.G(1R,\'<a 1R="\'+cj+$.28(1R)+\'">\'+$.28(ku)+"</a>"+6s)}$(n).2E(o).1w()}}I{if(n.4v===1&&!/^(a|1D|5R)$/i.4c(n.Q)){$.3G.fn.c6.5B(n,c8,6P,68,6O,6N)}}}}})(oN);',62,1711,'||||||||||||this||||||||||||html||var|||||||||||function|opts||false|return|replace||else|node|editor|parent|proxy|true|range||tagName|||image|redactor|span||document|text||||div||||||||data|find|title|tag|callback|css|td|append|attr|sync|key|block|length|table|style|val|sel|current|link|left|each|source|remove|class|lang|img|toolbar|elem|browser|button|typeof|curLang|type|func|undefined|selection|json|url|marker|linebreaks|target|dropdown|iframe|href|match|top|size|nodes|contents|out|selectionRestore|bufferSet||height|execCommand|cmd||click|file||trim|getSelection|new|btn|closest|btnObject|selectionSave|replaceWith|element|blockquote|invisibleSpace|focus|xhr|width|section|name|code|exec|ul|pre|form|value|start|body|matches|preventDefault|addClass|btnName|box|getParent|removeAttr|label|after|font|margin|tmp|index|null|param|RegExp|arr|show|keyCode|getBlock|redactorModal|get|input|hide|className|offset|setTimeout|last|imageBox|frame|list|point|||||||||push|modalClose|mozilla|air|removeClass|LI|scrollTop|tr|display|position|ctrl|src|getRange|select|none|end|bold|italic|script|msie|nbsp|hasClass|for|while|doc|off|insertNode|uploadOptions|video|blocks|uploadFields|contenteditable|Redactor|getBlocks|content|buffer|wrapper|BLOCKQUOTE|before|toLowerCase|innerHTML|100|options|object|getCurrent|toString|ua|error|indexOf|thead|pos|imageUpload||getRangeAt|buttons|strong|footer|||option|window|outerHtml|rangy|selectionStart|test|auto|redactor_editor|frag|isParentRedactor|rel|split|fullpage|children|next|focusWithSaveScroll|success|inline|elems|postData|current_tr|buttonGet|redactor_modal_btn|insert|nodeType|tooltip|Math|createElement|finalnodes|textNodes|htmls|webkit|str|meta|observeImages|search|extend|right|that|autoresize|inArray|collapsed|substr|removeAllRanges|php|parentNode|placeholder|String|len|orgn|removeEmptyAttr|underline|embed|cont|prev||rangeCount|keys|tab|align|blockElem|del|redactor_placeholder|keyup||emptyHtml|inserthtml|isMobile|shiftKey|addRange|dropareabox|prototype|rule|formatBlocks|deleted|imageResizer|200|redactor_tabs|iframeStart|float|s3|listTag|alignmentTags|redactor_file|audio|charAt|replaced|method|redactor_tab|keydown|createRange|newTag|call|https|marginLeft|listCurrent|observeLinks|allowedTags|marginTop|collapse|strike|node1|visual|savedSel|lastNode|selectall|draguploadOptions|regex|textarea|indent|startContainer|join|unorderedlist|change|boldTag|italicTag|filelink|||imageResizeHide|direction|toolbarFixed|||unlink|convertImageLinks|imageEditter|paragraphy|redactor_file_link|formatting|empty|current_td|clone|modal|which|TD|_blank|navigator|modalInit|dir|modified|modalcontent|shortcuts|round|par|space|event|orderedlist|prepend|PRE|uploadParam|drop|textareamode|control|formatBlock|Insert|center|enter|listParent|replacementTag|instance|cancel|fadeOut|redactor_modal_action_btn|redactor_btn_modal_close|buttonActive|linkSize|convertVideoLinks|convertLinks|insertAfterLastElement|tmpList|redactor_tabs_act|redactor_input|iframeEnd|com|outdent|buttonBuild|blocksElems|saveModalScroll|redactor_link_blank|weight|isFunction||possible|etags|item|charCount|endCharCount|cleanRemoveSpaces|cloned|getNodes|appendChild|files|selectionEnd|thtml|jsonString|redactorfolder|userAgent|folders|imageGetJson|phpMatches|u200B|nodeTestBlocks|count|autosave|action|hideHandler|currentOrParentIs|linkObserverTooltipClose|dropact|newblock|modif|set|tabindex|uuid|fullpageDoctype|init|cleanGetTabs|observeStart|insert_link_node|obj|elements|isFocused|linkProtocol|setNonEditable|buttonActiveObserver|tbody|deniedTags|fileUpload|selectionSet|node2|endContainer|minHeight|cleanStripTags|linkmarker|getElement|selectionRemoveMarkers|setStart|post|rebuffer|tagblock|resize|tagout|insertunorderedlist|save|edit|rtePaste|cleanlevel|alt|alignmentSet|dblEnter|fontSize|horizontalrule|imageFloatMargin|createTextNode|phpTags|insertorderedlist|setEnd|break|color|redactor_link_url|focn|textNode|newnodes|tmpLi|Delete|childNodes|Header|upload|reUrlYoutube|redactor_act|typewriter|boxTop|toolbarFixedTarget|reUrlVimeo|parents|firstChild|newElement|absolute|character|appendTo|shift|hidden|parseJSON|keyPosition|showProgressBar|DIV|metaKey|Add|redactorModalOverlay|isIe11|string|toolbarExternal|zIndex|verified|opera|dataTransfer|mousedown|specialKey|hdlHideDropDown|special|parentLink|one|||11px|spans|allowed|padding|||||10px|background|folderclass|setStartAfter|selectionSetMarker|codeLength|normalize|airBindMousemoveHide|redactor_modal_header|boundaryRange|imageInsert|clipboardUpload|insertHtml|result|placeTag|cloneRange|multipart|splice|array|dropdownHideAll|ftp|line|fixed|mouseup|version|preCaretRange||isResizing|parseInt|BACKSPACE|focusSet|start_y|folderkey|new_w|javascript|foundStart|selectNodeContents|documentElement|start_x|autosaveInterval|case|inlineRemoveFormatReplace|direct|htmlTagName|foco|marginBottom|marginRight|getSelectionText|http|textContent|alignment|hideProgressBar|folder|redactorModalWidth|template|toolbarFixedTopOffset|isEmpty|rangeNodes|enctype|rTestBlock|substring|strip|redactor_link_url_text|amp|blockLevelElements|parentEl|rows|overflow|tabSpaces|insertHtmlAdvanced|predefinedLinksStorage|separator|row|emptyElement|ASIDE|linkShow|ARTICLE|columns|clickedElement|not|inlineMethods|redactor_modal_inner|outer|selectionHtml|ctrlKey|cleanConvertInlineTags|deleteContents|wrapperHtml|methodVal|activeButtons|listText|insertLineBreak|parentHtml|sourceHeight|insertAfter|fonts|header|indentValue|head|pasteInsert|7px|setSpansVerified|tablePaste|convertDivs|redactor_form_image_align|selected|prop|checked|progressBar|setSpansVerifiedHtml|paste|saveScroll|x200b|nodeValue|buildCodearea|open|ADDRESS|ENTER|toolbarFixedBox|icon|HEADER|classname|FOOTER|column|imageUploadParam|execPasteFrag|colspan|floating||new_tr|www|rowspan|SECTION|cleanParagraphy|getRangeSelectedNodes|tagTestBlock|iframePage|oldsafari|hover|BODY|table_box||redactor_toolbar|cleanSavePreCode|tableId|directupload|focus_td|focus_tr|imageUploadError|buttonsHideOnMobile|Table|container|innerText|elem2|savedHtml|syncClean|Column|isIPad|catch|Row|try|endNode|iframeDoc|vimeo|blur|decoration|placeholderText|formatQuote|urlImage|paragraphsOnly|youtube|cleanFontTag|500|focusEnd|pasteClipboardMozilla|cleanEncodeEntities|formatblock|placeholderOnBlur|frameborder|placeholderOnFocus|placeholderGet|address|formatLinkify|INLINE|protocol|currBlock|utag|cleanRemoveEmptyTags|parseHTML|pasteHTML|endRange|insertingAfterLastElement|tfoot|maxHeight|buildEnable|addProtocol|inlineEachNodes|fullscreen|buildAfter|selectionRemove|caretOffset|Range|selectionElement|hotkeysShiftNums|selectionWrap|cleanTag|cleanFinish|oldIE|cursorRange|apply|getTextNodesIn|setFullpageOnInit|toggle|dnbImageTypes|chrome|orgo|extractContent|cleannewLevel|iframeLoad|royalSlider|iframeAddCss|clipboardUploadUrl|buildOptions|pasteClipboardAppendFields|fotorama|posFrame|createDocumentFragment|BR|child|isEndOfElement|suffix|getCaretOffset|buildBindKeyboard|toolbarObserveScroll|delete_table|delete_row|delete_column|formId|oldElement|imageRemove|delete|DELETE|2000px|templateVars|editter|lineHeight|tableDeleteHead|delete_head|resizer|cleanConverters|btnHeight||cleanConvertProtected|RedactorPlugins|pageY|arrSearch|etagsInline|align_right|alignright||redactor_button_disabled|submit|removeEmptyTags|contentWindow|dropdownWidth|indentingIndent|align_center||align_left|alignleft|pageX|aligncenter|ratio|indentingOutdent|link_new_tab|modalSaveBodyOveflow|num|add_head|redactor_filename|fileUploadParam|alignmentCenter|insideOutdent|filename|rBlockTest|justify|alignmentJustify|contOwnLine|redactor_image_box|redactor_file_alt|FIGCAPTION|alignmentLeft|choose|insert_table|alignmentRight|ownLine|buttonName|buttonInactive|insert_row_above|buildProgressBar|uploadSubmit|trigger|dropdownHide|s3uploadFile|insert_column_right|indentingStart|cleanEmpty|plugins|uploadInit|dropdownShow|status|insert_row_below|childList|insert_column_left|imageCallback|mark|buildEventKeydownInsertLineBreak|s3image|redactor_table_rows|align_justify|modify|extra||||pattern|z0||mailto|reader|draguploadInit|added|DOWN|fileCallback|lineOrWord|dragUploadAjax|modalCloseHandler|ESC|linkInsertPressed|placeholderRemove|buttonsSize|tableAddRow|activeButtonsStates|safes|POST|contentType|link_insert|tableAddColumn|clipboardData|cursor|th|progress|FormData|predefinedLinks|redactor_modal_close|targetBlank|redactor_insert_video_area|droparea|airShow|merge|modalOverlay|redactor_modal_overlay|sourceOld|thumbtitle|||||||||||redactorModalInner|focusElem||redactor_modal|commentsMatches|iframeAppend|superscript|textareaKeydownCallback|shortcutsHandler|Array|beforekey|inlineUnwrapSpan||subscript|placeholderFocus|redactor_dropdown_link|dragUpload|buildEventKeyup|inlineFormat|newhtml|tabFocus|blocksElemsRemove|buildEventKeydownTab|focusCallback|firstParent|unwrap|placeholderRemoveFromEditor|strikethrough|formattingPre|execLists|TAB|execUnlink|blocksLen|wym|UL|buttonInactiveAll|inlineSetMethods|placeholderBlur|paragraphs|min|redactor_editor_wym|toolbarInit|clonedHtml|placeholderRemoveFromCode|buildEventKeydownPre|link_edit|buttonActiveToggle|buildEventKeydownBackspace|inserthorizontalrule|fromElement|toTagName|afterkey|command|buildEventDrop|filter|transparent|close|toolbarBuild|toolbar_fixed_box|airButtons|buildEventKeydown|fieldset|airEnable|buildEventPaste|LEFT_WIN|mod|clearInterval|redactor_air|altKey||area|map|cleanup|clipboardFilePaste|scroll|originalEvent|10005|toolbarOverflow|redactor_air_|tags||iframeCreate|buildEventClipboardUpload|write|visibility|cleanUnverified|items|buttonSource|formattingTags|quot|encode|pastedFrag|cleanHtml|timer|219|cleanlineAfter|buttonImage|hotkeysSpecialKeys|cleanlineBefore|cleanReConvertProtected|listCurrentText|placeholderStart|returnValue|redactor_dropdown|wrapAll|buildEventKeyupConverters|buttonActiveVisual|dropdownBuild|placeholderInit|buildPlugins|formatEmpty|double|innerHeight|tidyHtml|||||||airBindHide|toggleCode|indenting|textareaIndenting|keyboard|setInterval|innerWidth|collapseToStart|dropdownObject|origHandler|buffer_|cleanReplacer|arguments|u200D|toggleVisual|uFEFF|buttonInactiveVisual|fileUploadError|modal_video|redactor_insert_table_btn||redactor_table_columns|video_html_code|H5|redactor_insert_video_btn|header5|getCaretOffsetRange|modal_table|predefined|modal_link|links|URL|redactor_insert_link_btn|checkbox|H6|header4|modalSetTitle|modalSetContent|modalSetButtonsWidth|DL|modalSetOverlay|modalOnCloseButton|DD|modalShowOnMobile|header3|fragment|getFragmentHtml|header2|header1|modalShowOnDesktop|redactor_upload_btn|image_web_link|imageResizable|draguploadOndragleave|H4|bottom|5px|fff|1px|18px|opacity|mouse_y|div_h|new_h|min_w|relative|imageResizeControls|backgroundColor||000|||_delete|redactor_image_delete_btn|redactorSaveBtn|modal_image|redactor_tab3|redactor_tab2||image_position|modal_image_edit|imageThumbClick|8px||imageCallbackLink|modalTemplatesInit|equals|modal_file|modalSetDraggable|draggable|Upload|rawString|Center|element_action|drop_file_here|isString|or_choose|contentDocument|uploadLoaded|uploadForm|load|the|to|Align|fileId|atext|dropalternative|loaded|Left|insertNodeToCaretPositionFromPoint|drag|draguploadOndrag|uploadProgress|Right|Image|Video|Code|percent|Head|ajax|Link|99999|random|s3handleFileSelect|visible|arrAdd|signedURL|s3executeOnSignedUrl|newLevel|opr|hdlModalClose|unbind|paragraph|quote|modalLoadTabs|shortcutsAdd|langs|outerHeight|overrideMimeType|DT|Color|setRequestHeader|send|List|floor|uploadFrame|onload|s3createCORSRequest|readyState|OUTPUT|Edit|XMLHttpRequest|s3uploadToS3|XDomainRequest|mousemove|imageEdit|linkObserver|linkNofollow|aLink|aEdit|formatChangeTag|nofollow|pop|pasteClipboardUpload|imgs|clipboard|bufferUndo|bufferRedo|endOffset|setCaret|getSelectionHtml|nextSibling|xhtmlTags|xhtml|selectionCreateMarker|args|nextNode|nodeName|setCaretAfter|slice|setFullpageDoctype|unshift|pasteClipboardUploadMozilla|noeditable|clientX|buildContent|clientY|caretPositionFromPoint|buildMobile|outerHTML|buildFromTextarea|HTML|buildAddClasses|aside|article|buildFromElement|caretRangeFromPoint|createTextRange|pastePlainText|pasteClean|cleanSpaces|internal|pastePre|replaceLineBreak|twice|mobile|moveToPoint|buildStart|SPAN|escapedBackReferences|aUnlink|onchangeFunc|isEmptyObject|linkProcess|removeFormat|location|self|videoShow|videoInsert|thref|imageTabLink|H1|player|getJSON|imageShow|linkInsert|fileShow|re2|gif|allowfullscreen|jpeg|281|tableAddColumnRight|setEditor|tableAddColumnLeft|rProtocol|tableDeleteRow|tableDeleteColumn|setCodeIframe|tableInsert|imageResize|H3|getCodeIframe|inside|doctype|tableShow|imageSave|tableDeleteTable|first|tableAddHead|H2|tableAddRowBelow|removeFromArrayByValue|tableAddRowAbove|focusIndex|png|Indent|Outdent|ownerDocument||frameset|103|Cancel|104|Save|107|Rows|defaultView|Columns|Title||Below|106|Above|102|stylesheet|105|Back|Normal|Formatting|Unlink|ltr|Quote|backspace|applet|use|strict|VERSION|such|removeChild|youtu|startOffset|isArray|eval|Bold|Italic|pagedown|pageup|esc|home|up|101|down|capslock|Ordered|Font|fontcolor|backcolor|No|Unordered|pause|noscript|redactor_format_h2|getAsFile|FileReader|getToolbar|readAsDataURL|about|blank|Chrome|536|noneditable|getIframe|word|getEditor|getObject|removeData|destroy|redo|getBox|collapseToEnd|109|undo|syncBefore|syncAfter|dash|u2010|mdash|u2014|enableInlineTableEditing|enableObjectResizing|45px|TEXTAREA|redactor_box|hellip|u2026|blurCallback|8203|default|switch|1class|u2122|copy|u00a9|trade|Callback|TH|Horizontal|Justify|here|Drop|Rule|Deleted|Open|Anchor|anchor|Or|Choose|Email|Text|Web|None|web|Embed|Download|download|File|Underline|Alignment|redactor_format_h5|redactor_format_h4|redactor_format_h3|redactor_|bull|separator_drop1|alignjustify||separator_drop3|separator_drop2|redactor_format_h1|redactor_format_pre|META|CTRL||optional|Name|LEFT||dropdowns|redactor_format_blockquote|u00a0|sourceWidth|Position|unselectable|redactor_image_edit_src|610|redactor_image_box_select|380|imageDelete|min_h|clicked|dragstart|thumb|xn|300|removeMarkers|u1C7F|cellIndex|600|460|host|mouse_x|13px|redactorUploadFileForm|1500|fadeIn|redactor_modal_delete_btn|redactorInsertImageForm|redactorInsertVideoForm|redactor_tab1|solid|border|outline|3px|9px|dashed|rgba|4px|pointer|u0000|restoreSelection|pasteBefore|insertDoubleLineBreak|EndToEnd|shapes|MsoListParagraphCxSpFirst|MsoListParagraphCxSpLast|MsoListParagraphCxSpMiddle||setEndPoint||duplicate|toUpperCase|inlineRemoveFormat|attributes|insertBeforeCursor|insertText|offsetNode|setEndAfter|MsoListParagraph|sid|commonAncestorContainer|110|isInlineNode|hasChildNodes|cloneContents|detach|saveSelection|selectionAll|extractContents|u200b|guid|docs|fake|pasteAfter|editGallery|jQuery|160px|times|processData|cache|dataType|total|Loading|BlackBerry|iPod|iPhone|ajaxSetup|addEventListener|redactor_dropalternative|redactor_dropareabox|redactor_droparea|dragover|dragleave|ajaxSettings|ondrop|Android|iPad|trident|safari|Trident|compatible|cloneNode|jpg|ftps|parseFloat||MSIE|getInternetExplorerVersion|Object|stripHtml|appName|Microsoft|Explorer|Internet|preview|failed|GET|modalSetTab|modalClosed|plain|charset||defined|user|fast|redactor_tab_selected|keypress|focusin|modalOpened|300px|redactor_modal_btn_hidden|move|handle|onreadystatechange|decodeURIComponent|INPUT|read|public|redactorUploadForm|redactorUploadFile|alert|frames|acl|amz|PUT|withCredentials|responseText|onerror|onprogress|Type|Content|inlineSetAttr|isCollapsed|external|redactor_toolbar_|focusNode|redactor_separator_drop|dropdownShown|redactor_dropdown_|1000|autosaveError|fromCharCode|inlineRemoveAttr|Key|escape|encodeURIComponent|touchstart|stopPropagation|buttonAddBefore|buttonAddAfter|buttonRemove|firstNode|SUB|SUP|buttonAddFirst|buttonAdd|buttonTagToActiveState|redactor_dropdown_box_|buttonChangeIcon|buttonRemoveIcon|buttonAwesome|222|221|119|118|120|121|122|f10|117|116|112|111|113|114|115|f11|123|189|188|190|191|220|192|187|186|144|f12|numlock|145|173|OL|_|details|menu|hasOwnProperty|inlineSetClass|figcaption|inlineRemoveStyle|hgroup|nav|figure|inlineSetStyle|inlineRemoveClass|sub|blockSetClass||blockRemoveStyle|blockRemoveClass|blockSetStyle|blockSetAttr|blockRemoveAttr|sup|small|cite|legend|summary|caption|concat|col|JustifyCenter|JustifyFull|gallery||comment|colgroup|JustifyRight|math|JustifyLeft'.split('|'),0,{})) \ No newline at end of file +*/(function(e){"use strict";function i(e,t){return new i.prototype.init(e,t)}Function.prototype.bind||(Function.prototype.bind=function(e){var t=this;return function(){return t.apply(e)}});var t=0,n=/https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.\-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig,r=/https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;e.fn.redactor=function(t){var n=[],r=Array.prototype.slice.call(arguments,1);return typeof t=="string"?this.each(function(){var i=e.data(this,"redactor"),s;t.search(/\./)!="-1"?(s=t.split("."),typeof i[s[0]]!="undefined"&&(s=i[s[0]][s[1]])):s=i[t];if(typeof i!="undefined"&&e.isFunction(s)){var o=s.apply(i,r);o!==undefined&&o!==i&&n.push(o)}else e.error('No such method "'+t+'" for Redactor')}):this.each(function(){e.data(this,"redactor",{}),e.data(this,"redactor",i(this,t))}),n.length===0?this:n.length===1?n[0]:n},e.Redactor=i,e.Redactor.VERSION="10.0.5",e.Redactor.modules=["alignment","autosave","block","buffer","build","button","caret","clean","code","core","dropdown","file","focus","image","indent","inline","insert","keydown","keyup","lang","line","link","list","modal","observe","paragraphize","paste","placeholder","progress","selection","shortcuts","tabifier","tidy","toolbar","upload","utils"],e.Redactor.opts={lang:"en",direction:"ltr",plugins:!1,focus:!1,focusEnd:!1,placeholder:!1,visual:!0,tabindex:!1,minHeight:!1,maxHeight:!1,linebreaks:!1,replaceDivs:!0,paragraphize:!0,cleanStyleOnEnter:!1,enterKey:!0,cleanOnPaste:!0,cleanSpaces:!0,pastePlainText:!1,autosave:!1,autosaveName:!1,autosaveInterval:60,autosaveOnChange:!1,linkTooltip:!0,linkProtocol:"http",linkNofollow:!1,linkSize:50,imageEditable:!0,imageLink:!0,imagePosition:!0,imageFloatMargin:"10px",imageResizable:!0,imageUpload:!1,imageUploadParam:"file",uploadImageField:!1,dragImageUpload:!0,fileUpload:!1,fileUploadParam:"file",dragFileUpload:!0,s3:!1,convertLinks:!0,convertUrlLinks:!0,convertImageLinks:!0,convertVideoLinks:!0,preSpaces:4,tabAsSpaces:!1,tabFocus:!0,scrollTarget:!1,toolbar:!0,toolbarFixed:!0,toolbarFixedTarget:document,toolbarFixedTopOffset:0,toolbarExternal:!1,toolbarOverflow:!1,buttonSource:!1,buttons:["html","formatting","bold","italic","deleted","unorderedlist","orderedlist","outdent","indent","image","file","link","alignment","horizontalrule"],buttonsHide:[],buttonsHideOnMobile:[],formatting:["p","blockquote","pre","h1","h2","h3","h4","h5","h6"],formattingAdd:!1,tabifier:!0,deniedTags:["html","head","link","body","meta","script","style","applet"],allowedTags:!1,removeComments:!1,replaceTags:[["strike","del"]],replaceStyles:[["font-weight:\\s?bold","strong"],["font-style:\\s?italic","em"],["text-decoration:\\s?underline","u"],["text-decoration:\\s?line-through","del"]],removeDataAttr:!1,removeAttr:!1,allowedAttr:!1,removeWithoutAttr:["span"],removeEmpty:["p"],activeButtons:["deleted","italic","bold","underline","unorderedlist","orderedlist","alignleft","aligncenter","alignright","justify"],activeButtonsStates:{b:"bold",strong:"bold",i:"italic",em:"italic",del:"deleted",strike:"deleted",ul:"unorderedlist",ol:"orderedlist",u:"underline"},shortcuts:{"ctrl+shift+m, meta+shift+m":{func:"inline.removeFormat"},"ctrl+b, meta+b":{func:"inline.format",params:["bold"]},"ctrl+i, meta+i":{func:"inline.format",params:["italic"]},"ctrl+h, meta+h":{func:"inline.format",params:["superscript"]},"ctrl+l, meta+l":{func:"inline.format",params:["subscript"]},"ctrl+k, meta+k":{func:"link.show"},"ctrl+shift+7":{func:"list.toggle",params:["orderedlist"]},"ctrl+shift+8":{func:"list.toggle",params:["unorderedlist"]}},shortcutsAdd:!1,buffer:[],rebuffer:[],emptyHtml:"<p>​</p>",invisibleSpace:"​",imageTypes:["image/png","image/jpeg","image/gif"],indentValue:20,verifiedTags:["a","img","b","strong","sub","sup","i","em","u","small","strike","del","cite","ul","ol","li"],inlineTags:["strong","b","u","em","i","code","del","ins","samp","kbd","sup","sub","mark","var","cite","small"],alignmentTags:["P","H1","H2","H3","H4","H5","H6","DL","DT","DD","DIV","TD","BLOCKQUOTE","OUTPUT","FIGCAPTION","ADDRESS","SECTION","HEADER","FOOTER","ASIDE","ARTICLE"],blockLevelElements:["PRE","UL","OL","LI"],langs:{en:{html:"HTML",video:"Insert Video",image:"Insert Image",table:"Table",link:"Link",link_insert:"Insert link",link_edit:"Edit link",unlink:"Unlink",formatting:"Formatting",paragraph:"Normal text",quote:"Quote",code:"Code",header1:"Header 1",header2:"Header 2",header3:"Header 3",header4:"Header 4",header5:"Header 5",bold:"Bold",italic:"Italic",fontcolor:"Font Color",backcolor:"Back Color",unorderedlist:"Unordered List",orderedlist:"Ordered List",outdent:"Outdent",indent:"Indent",cancel:"Cancel",insert:"Insert",save:"Save",_delete:"Delete",insert_table:"Insert Table",insert_row_above:"Add Row Above",insert_row_below:"Add Row Below",insert_column_left:"Add Column Left",insert_column_right:"Add Column Right",delete_column:"Delete Column",delete_row:"Delete Row",delete_table:"Delete Table",rows:"Rows",columns:"Columns",add_head:"Add Head",delete_head:"Delete Head",title:"Title",image_position:"Position",none:"None",left:"Left",right:"Right",center:"Center",image_web_link:"Image Web Link",text:"Text",mailto:"Email",web:"URL",video_html_code:"Video Embed Code or Youtube/Vimeo Link",file:"Insert File",upload:"Upload",download:"Download",choose:"Choose",or_choose:"Or choose",drop_file_here:"Drop file here",align_left:"Align text to the left",align_center:"Center text",align_right:"Align text to the right",align_justify:"Justify text",horizontalrule:"Insert Horizontal Rule",deleted:"Deleted",anchor:"Anchor",link_new_tab:"Open link in new tab",underline:"Underline",alignment:"Alignment",filename:"Name (optional)",edit:"Edit"}}},i.fn=e.Redactor.prototype={keyCode:{BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,SPACE:32,ESC:27,TAB:9,CTRL:17,META:91,SHIFT:16,ALT:18,LEFT:37,LEFT_WIN:91},init:function(n,r){this.$element=e(n),this.uuid=t++,this.rtePaste=!1,this.$pasteBox=!1,this.loadOptions(r),this.loadModules(),this.formatting={},e.merge(this.opts.blockLevelElements,this.opts.alignmentTags),this.reIsBlock=new RegExp("^("+this.opts.blockLevelElements.join("|")+")$","i"),this.tidy.setupAllowed(),this.lang.load(),e.extend(this.opts.shortcuts,this.opts.shortcutsAdd),this.core.setCallback("start"),this.start=!0,this.build.run()},loadOptions:function(t){this.opts=e.extend({},e.extend(!0,{},e.Redactor.opts),this.$element.data(),t)},getModuleMethods:function(e){return Object.getOwnPropertyNames(e).filter(function(t){return typeof e[t]=="function"})},loadModules:function(){var t=e.Redactor.modules.length;for(var n=0;n<t;n++)this.bindModuleMethods(e.Redactor.modules[n])},bindModuleMethods:function(e){if(typeof this[e]=="undefined")return;this[e]=this[e]();var t=this.getModuleMethods(this[e]),n=t.length;for(var r=0;r<n;r++)this[e][t[r]]=this[e][t[r]].bind(this)},alignment:function(){return{left:function(){this.alignment.set("")},right:function(){this.alignment.set("right")},center:function(){this.alignment.set("center")},justify:function(){this.alignment.set("justify")},set:function(e){this.utils.browser("msie")||this.$editor.focus(),this.buffer.set(),this.selection.save(),this.alignment.blocks=this.selection.getBlocks(),this.opts.linebreaks&&this.alignment.blocks[0]===!1?this.alignment.setText(e):this.alignment.setBlocks(e),this.selection.restore(),this.code.sync()},setText:function(t){var n=this.selection.wrap("div");e(n).attr("data-tagblock","redactor"),e(n).css("text-align",t)},setBlocks:function(t){e.each(this.alignment.blocks,e.proxy(function(e,n){var r=this.utils.getAlignmentElement(n);if(!r)return;t===""&&typeof r.data("tagblock")!="undefined"?r.replaceWith(r.html()):(r.css("text-align",t),this.utils.removeEmptyAttr(r,"style"))},this))}}},autosave:function(){return{enable:function(){if(!this.opts.autosave)return;this.autosave.html=!1,this.autosave.name=this.opts.autosaveName?this.opts.autosaveName:this.$textarea.attr("name"),this.opts.autosaveOnChange||(this.autosaveInterval=setInterval(e.proxy(this.autosave.load,this),this.opts.autosaveInterval*1e3))},onChange:function(){if(!this.opts.autosaveOnChange)return;this.autosave.load()},load:function(){var t=this.code.get();if(this.autosave.html===t)return;if(this.utils.isEmpty(t))return;e.ajax({url:this.opts.autosave,type:"post",data:"name="+this.autosave.name+"&"+this.autosave.name+"="+escape(encodeURIComponent(t)),success:e.proxy(function(e){this.autosave.success(e,t)},this)})},success:function(t,n){var r;try{r=e.parseJSON(t)}catch(i){r=t}var s=typeof r.error=="undefined"?"autosave":"autosaveError";this.core.setCallback(s,this.autosave.name,r),this.autosave.html=n},disable:function(){clearInterval(this.autosaveInterval)}}},block:function(){return{formatting:function(e){var t,n;typeof this.formatting[e].data!="undefined"?t="data":typeof this.formatting[e].attr!="undefined"?t="attr":typeof this.formatting[e].class!="undefined"&&(t="class"),t&&(n=this.formatting[e][t]),this.block.format(this.formatting[e].tag,t,n)},format:function(t,n,r){t=="quote"&&(t="blockquote");var i=["p","pre","blockquote","h1","h2","h3","h4","h5","h6"];if(e.inArray(t,i)==-1)return;this.block.isRemoveInline=t=="pre"||t.search(/h[1-6]/i)!=-1,this.utils.browser("msie")||this.$editor.focus(),this.block.blocks=this.selection.getBlocks(),this.block.blocksSize=this.block.blocks.length,this.block.type=n,this.block.value=r,this.buffer.set(),this.selection.save(),this.block.set(t),this.selection.restore(),this.code.sync()},set:function(e){this.selection.get(),this.block.containerTag=this.range.commonAncestorContainer.tagName,this.range.collapsed?this.block.setCollapsed(e):this.block.setMultiple(e)},setCollapsed:function(t){var n=this.block.blocks[0];if(n===!1)return;if(n.tagName=="LI"){if(t!="blockquote")return;this.block.formatListToBlockquote();return}var r=this.block.containerTag=="TD"||this.block.containerTag=="TH";if(r&&!this.opts.linebreaks)document.execCommand("formatblock",!1,"<"+t+">"),n=this.selection.getBlock(),this.block.toggle(e(n));else if(n.tagName.toLowerCase()!=t)if(this.opts.linebreaks&&t=="p")e(n).prepend("<br>").append("<br>"),this.utils.replaceWithContents(n);else{var i=this.utils.replaceToTag(n,t);this.block.toggle(i),t!="p"&&t!="blockquote"&&i.find("img").remove(),this.block.isRemoveInline&&this.utils.removeInlineTags(i),(t=="p"||this.block.headTag)&&i.find("p").contents().unwrap(),this.block.formatTableWrapping(i)}else if(t=="blockquote"&&n.tagName.toLowerCase()==t)if(this.opts.linebreaks)e(n).prepend("<br>").append("<br>"),this.utils.replaceWithContents(n);else{var s=this.utils.replaceToTag(n,"p");this.block.toggle(s)}else n.tagName.toLowerCase()==t&&this.block.toggle(e(n))},setMultiple:function(t){var n=this.block.blocks[0],r=this.block.containerTag=="TD"||this.block.containerTag=="TH";if(n!==!1&&this.block.blocksSize===1)if(n.tagName.toLowerCase()==t&&t=="blockquote")if(this.opts.linebreaks)e(n).prepend("<br>").append("<br>"),this.utils.replaceWithContents(n);else{var i=this.utils.replaceToTag(n,"p");this.block.toggle(i)}else if(n.tagName=="LI"){if(t!="blockquote")return;this.block.formatListToBlockquote()}else if(this.block.containerTag=="BLOCKQUOTE")this.block.formatBlockquote(t);else if(this.opts.linebreaks&&(r||this.range.commonAncestorContainer!=n))this.block.formatWrap(t);else if(this.opts.linebreaks&&t=="p")e(n).prepend("<br>").append("<br>"),this.utils.replaceWithContents(n);else if(n.tagName==="TD")this.block.formatWrap(t);else{var s=this.utils.replaceToTag(n,t);this.block.toggle(s),this.block.isRemoveInline&&this.utils.removeInlineTags(s),(t=="p"||this.block.headTag)&&s.find("p").contents().unwrap()}else if(this.opts.linebreaks||t!="p"){if(t=="blockquote"){var o=0;for(var u=0;u<this.block.blocksSize;u++)this.block.blocks[u].tagName=="BLOCKQUOTE"&&o++;if(o==this.block.blocksSize){e.each(this.block.blocks,e.proxy(function(t,n){this.opts.linebreaks?(e(n).prepend("<br>").append("<br>"),this.utils.replaceWithContents(n)):this.utils.replaceToTag(n,"p")},this));return}}this.block.formatWrap(t)}else{var a=0,f=!1;this.block.type=="class"&&(f="toggle",a=e(this.block.blocks).filter("."+this.block.value).size(),this.block.blocksSize==a?f="toggle":this.block.blocksSize>a?f="set":a===0&&(f="set"));var l=["ul","ol","li","td","th","dl","dt","dd"];e.each(this.block.blocks,e.proxy(function(n,r){if(e.inArray(r.tagName.toLowerCase(),l)!=-1)return;var i=this.utils.replaceToTag(r,t);f?f=="toggle"?this.block.toggle(i):f=="remove"?this.block.remove(i):f=="set"&&this.block.setForce(i):this.block.toggle(i),t!="p"&&t!="blockquote"&&i.find("img").remove(),this.block.isRemoveInline&&this.utils.removeInlineTags(i),(t=="p"||this.block.headTag)&&i.find("p").contents().unwrap()},this))}},setForce:function(e){if(this.block.type=="class"){e.addClass(this.block.value);return}if(this.block.type=="attr"||this.block.type=="data"){e.attr(this.block.value.name,this.block.value.value);return}},toggle:function(e){if(this.block.type=="class"){e.toggleClass(this.block.value);return}if(this.block.type=="attr"||this.block.type=="data"){e.attr(this.block.value.name)==this.block.value.value?e.removeAttr(this.block.value.name):e.attr(this.block.value.name,this.block.value.value);return}e.removeAttr("style class");return},remove:function(e){e.removeClass(this.block.value)},formatListToBlockquote:function(){var t=e(this.block.blocks[0]).closest("ul, ol");e(t).find("ul, ol").contents().unwrap(),e(t).find("li").append(e("<br>")).contents().unwrap();var n=this.utils.replaceToTag(t,"blockquote");this.block.toggle(n)},formatBlockquote:function(t){document.execCommand("outdent"),document.execCommand("formatblock",!1,t),this.clean.clearUnverified(),this.$editor.find("p:empty").remove();var n=this.selection.getBlock();t!="p"&&e(n).find("img").remove(),this.opts.linebreaks||this.block.toggle(e(n)),this.$editor.find("ul, ol, tr, blockquote, p").each(e.proxy(this.utils.removeEmpty,this)),this.opts.linebreaks&&t=="p"&&this.utils.replaceWithContents(n)},formatWrap:function(t){if(this.block.containerTag=="UL"||this.block.containerTag=="OL"){if(t!="blockquote")return;this.block.formatListToBlockquote()}var n=this.selection.wrap(t);if(n===!1)return;var r=e(n);this.block.formatTableWrapping(r);var i=r.find(this.opts.blockLevelElements.join(",")+", td, table, thead, tbody, tfoot, th, tr");(this.opts.linebreaks&&t=="p"||t=="pre"||t=="blockquote")&&i.append("<br />"),i.contents().unwrap(),t!="p"&&t!="blockquote"&&r.find("img").remove(),e.each(this.block.blocks,e.proxy(this.utils.removeEmpty,this)),r.append(this.selection.getMarker(2)),this.opts.linebreaks||this.block.toggle(r),this.$editor.find("ul, ol, tr, blockquote, p").each(e.proxy(this.utils.removeEmpty,this)),r.find("blockquote:empty").remove(),this.block.isRemoveInline&&this.utils.removeInlineTags(r),this.opts.linebreaks&&t=="p"&&this.utils.replaceWithContents(r)},formatTableWrapping:function(e){if(e.closest("table").size()===0)return;e.closest("tr").size()===0&&e.wrap("<tr>"),e.closest("td").size()===0&&e.closest("th").size()===0&&e.wrap("<td>")},removeData:function(t,n){var r=this.selection.getBlocks();e(r).removeAttr("data-"+t),this.code.sync()},setData:function(t,n){var r=this.selection.getBlocks();e(r).attr("data-"+t,n),this.code.sync()},toggleData:function(t,n){var r=this.selection.getBlocks();e.each(r,function(){e(this).attr("data-"+t)?e(this).removeAttr("data-"+t):e(this).attr("data-"+t,n)})},removeAttr:function(t,n){var r=this.selection.getBlocks();e(r).removeAttr(t),this.code.sync()},setAttr:function(t,n){var r=this.selection.getBlocks();e(r).attr(t,n),this.code.sync()},toggleAttr:function(t,n){var r=this.selection.getBlocks();e.each(r,function(){e(this).attr(name)?e(this).removeAttr(name):e(this).attr(name,n)})},removeClass:function(t){var n=this.selection.getBlocks();e(n).removeClass(t),this.utils.removeEmptyAttr(n,"class"),this.code.sync()},setClass:function(t){var n=this.selection.getBlocks();e(n).addClass(t),this.code.sync()},toggleClass:function(t){var n=this.selection.getBlocks();e(n).toggleClass(t),this.code.sync()}}},buffer:function(){return{set:function(e){typeof e=="undefined"||e=="undo"?this.buffer.setUndo():this.buffer.setRedo()},setUndo:function(){this.selection.save(),this.opts.buffer.push(this.$editor.html()),this.selection.restore()},setRedo:function(){this.selection.save(),this.opts.rebuffer.push(this.$editor.html()),this.selection.restore()},getUndo:function(){this.$editor.html(this.opts.buffer.pop())},getRedo:function(){this.$editor.html(this.opts.rebuffer.pop())},add:function(){this.opts.buffer.push(this.$editor.html())},undo:function(){if(this.opts.buffer.length===0)return;this.buffer.set("redo"),this.buffer.getUndo(),this.selection.restore(),setTimeout(e.proxy(this.observe.load,this),50)},redo:function(){if(this.opts.rebuffer.length===0)return;this.buffer.set("undo"),this.buffer.getRedo(),this.selection.restore(),setTimeout(e.proxy(this.observe.load,this),50)}}},build:function(){return{run:function(){this.build.createContainerBox(),this.build.loadContent(),this.build.loadEditor(),this.build.enableEditor(),this.build.setCodeAndCall()},isTextarea:function(){return this.$element[0].tagName==="TEXTAREA"},createContainerBox:function(){this.$box=e('<div class="redactor-box" />')},createTextarea:function(){this.$textarea=e("<textarea />").attr("name",this.build.getTextareaName())},getTextareaName:function(){var e=this.$element.attr("id");return typeof e=="undefined"&&(e="content-"+this.uuid),e},loadContent:function(){var t=this.build.isTextarea()?"val":"html";this.content=e.trim(this.$element[t]())},enableEditor:function(){this.$editor.attr({contenteditable:!0,dir:this.opts.direction})},loadEditor:function(){var e=this.build.isTextarea()?"fromTextarea":"fromElement";this.build[e]()},fromTextarea:function(){this.$editor=e("<div />"),this.$textarea=this.$element,this.$box.insertAfter(this.$element).append(this.$editor).append(this.$element),this.$editor.addClass("redactor-editor"),this.$element.hide()},fromElement:function(){this.$editor=this.$element,this.build.createTextarea(),this.$box.insertAfter(this.$editor).append(this.$editor).append(this.$textarea),this.$editor.addClass("redactor-editor"),this.$textarea.hide()},setCodeAndCall:function(){this.code.set(this.content),this.build.setOptions(),this.build.callEditor(),this.opts.visual||setTimeout(e.proxy(this.code.showCode,this),200)},callEditor:function(){this.build.disableMozillaEditing(),this.build.setEvents(),this.build.setHelpers(),this.opts.toolbar&&(this.opts.toolbar=this.toolbar.init(),this.toolbar.build()),this.modal.loadTemplates(),this.build.plugins(),setTimeout(e.proxy(this.observe.load,this),4),this.core.setCallback("init")},setOptions:function(){e(this.$textarea).attr("dir",this.opts.direction),this.opts.linebreaks&&this.$editor.addClass("redactor-linebreaks"),this.opts.tabindex&&this.$editor.attr("tabindex",this.opts.tabindex),this.opts.minHeight&&this.$editor.css("minHeight",this.opts.minHeight),this.opts.maxHeight&&this.$editor.css("maxHeight",this.opts.maxHeight)},setEvents:function(){this.$editor.on("drop.redactor",e.proxy(function(t){t=t.originalEvent||t;if(window.FormData===undefined||!t.dataTransfer)return!0;var n=t.dataTransfer.files.length;if(n===0)return this.code.sync(),setTimeout(e.proxy(this.clean.clearUnverified,this),1),this.core.setCallback("drop",t),!0;t.preventDefault();if(this.opts.dragImageUpload||this.opts.dragFileUpload){var r=t.dataTransfer.files;this.upload.directUpload(r[0],t)}setTimeout(e.proxy(this.clean.clearUnverified,this),1),this.core.setCallback("drop",t)},this)),this.$editor.on("click.redactor",e.proxy(function(e){var t="click";if(this.core.getEvent()=="click"||this.core.getEvent()=="arrow")t=!1;this.core.addEvent(t),this.utils.disableSelectAll(),this.core.setCallback("click",e)},this)),this.$editor.on("paste.redactor",e.proxy(this.paste.init,this)),this.$editor.on("keydown.redactor",e.proxy(this.keydown.init,this)),this.$editor.on("keyup.redactor",e.proxy(this.keyup.init,this)),e.isFunction(this.opts.codeKeydownCallback)&&this.$textarea.on("keydown.redactor-textarea",e.proxy(this.opts.codeKeydownCallback,this)),e.isFunction(this.opts.codeKeyupCallback)&&this.$textarea.on("keyup.redactor-textarea",e.proxy(this.opts.codeKeyupCallback,this)),e.isFunction(this.opts.focusCallback)&&this.$editor.on("focus.redactor",e.proxy(this.opts.focusCallback,this));var t;e(document).on("mousedown",function(n){t=e(n.target)}),this.$editor.on("blur.redactor",e.proxy(function(n){if(this.rtePaste)return;var r=e(t);!r.hasClass("redactor-toolbar, redactor-dropdown")&&!r.is("#redactor-modal")&&r.parents(".redactor-toolbar, .redactor-dropdown, #redactor-modal").size()===0&&(this.utils.disableSelectAll(),e.isFunction(this.opts.blurCallback)&&this.core.setCallback("blur",n))},this))},setHelpers:function(){this.autosave.enable(),this.placeholder.enable(),this.opts.focus&&setTimeout(e.proxy(this.focus.setStart,this),100),this.opts.focusEnd&&setTimeout(e.proxy(this.focus.setEnd,this),100)},plugins:function(){if(!this.opts.plugins)return;if(!RedactorPlugins)return;e.each(this.opts.plugins,e.proxy(function(t,n){if(typeof RedactorPlugins[n]=="undefined")return;if(e.inArray(n,e.Redactor.modules)!==-1){e.error('Plugin name "'+n+"\" matches the name of the Redactor's module.");return}if(!e.isFunction(RedactorPlugins[n]))return;this[n]=RedactorPlugins[n]();var r=this.getModuleMethods(this[n]),i=r.length;for(var s=0;s<i;s++)this[n][r[s]]=this[n][r[s]].bind(this);e.isFunction(this[n].init)&&this[n].init()},this))},disableMozillaEditing:function(){if(!this.utils.browser("mozilla"))return;try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(e){}}}},button:function(){return{build:function(t,n){var r=e('<a href="#" class="re-icon re-'+t+'" rel="'+t+'" />').attr("tabindex","-1");(n.func||n.command||n.dropdown)&&r.on("touchstart click",e.proxy(function(e){if(r.hasClass("redactor-button-disabled"))return!1;var i="func",s=n.func;n.command?(i="command",s=n.command):n.dropdown&&(i="dropdown",s=!1),this.button.onClick(e,t,i,s)},this));if(n.dropdown){var i=e('<div class="redactor-dropdown redactor-dropdown-box-'+t+'" style="display: none;">');r.data("dropdown",i),this.dropdown.build(t,i,n.dropdown)}return this.utils.isDesktop()&&this.button.createTooltip(r,t,n.title),r},createTooltip:function(t,n,r){var i=e("<span>").addClass("redactor-toolbar-tooltip redactor-toolbar-tooltip-"+n).hide().html(r);i.appendTo("body"),t.on("mouseover",function(){if(e(this).hasClass("redactor-button-disabled"))return;var n=t.offset(),r=t.innerHeight(),s=t.innerWidth();i.show(),i.css({top:n.top+r+"px",left:n.left+s/2-i.innerWidth()/2+"px"})}),t.on("mouseout",function(){i.hide()})},onClick:function(t,n,r,i){this.button.caretOffset=this.caret.getOffset(),t.preventDefault(),this.utils.browser("msie")&&(t.returnValue=!1);if(r=="command")this.inline.format(i);else if(r=="dropdown")this.dropdown.show(t,n);else{var s;e.isFunction(i)?(i.call(this,n),this.observe.buttons(t,n)):i.search(/\./)!="-1"?(s=i.split("."),typeof this[s[0]]!="undefined"&&(this[s[0]][s[1]](n),this.observe.buttons(t,n))):(this[i](n),this.observe.buttons(t,n))}},get:function(e){return this.$toolbar.find("a.re-"+e)},setActive:function(e){this.button.get(e).addClass("redactor-act")},setInactive:function(e){this.button.get(e).removeClass("redactor-act")},setInactiveAll:function(e){typeof e=="undefined"?this.$toolbar.find("a.re-icon").removeClass("redactor-act"):this.$toolbar.find("a.re-icon").not(".re-"+e).removeClass("redactor-act")},setActiveInVisual:function(){this.$toolbar.find("a.re-icon").not("a.re-html").removeClass("redactor-button-disabled")},setInactiveInCode:function(){this.$toolbar.find("a.re-icon").not("a.re-html").addClass("redactor-button-disabled")},changeIcon:function(e,t){this.button.get(e).addClass("re-"+t)},removeIcon:function(e,t){this.button.get(e).removeClass("re-"+t)},setAwesome:function(e,t){var n=this.button.get(e);n.removeClass("redactor-btn-image").addClass("fa-redactor-btn"),n.html('<i class="fa '+t+'"></i>')},addCallback:function(t,n){var r=n=="dropdown"?"dropdown":"func",i=t.attr("rel");t.on("touchstart click",e.proxy(function(e){if(t.hasClass("redactor-button-disabled"))return!1;this.button.onClick(e,i,r,n)},this))},addDropdown:function(t,n){var r=t.attr("rel");this.button.addCallback(t,"dropdown");var i=e('<div class="redactor-dropdown redactor-dropdown-box-'+r+'" style="display: none;">');return t.data("dropdown",i),n&&this.dropdown.build(r,i,n),i},add:function(t,n){if(!this.opts.toolbar)return;var r=this.button.build(t,{title:n});return r.addClass("redactor-btn-image"),this.$toolbar.append(e("<li>").append(r)),r},addFirst:function(t,n){if(!this.opts.toolbar)return;var r=this.button.build(t,{title:n});return this.$toolbar.prepend(e("<li>").append(r)),r},addAfter:function(t,n,r){if(!this.opts.toolbar)return;var i=this.button.build(n,{title:r}),s=this.button.get(t);return s.size()!==0?s.parent().after(e("<li>").append(i)):this.$toolbar.append(e("<li>").append(i)),i},addBefore:function(t,n,r){if(!this.opts.toolbar)return;var i=this.button.build(n,{title:r}),s=this.button.get(t);return s.size()!==0?s.parent().before(e("<li>").append(i)):this.$toolbar.append(e("<li>").append(i)),i},remove:function(e){this.button.get(e).remove()}}},caret:function(){return{setStart:function(t){if(!this.utils.isBlock(t)){var n=this.utils.createSpaceElement();e(t).prepend(n),this.caret.setEnd(n)}else this.caret.set(t,0,t,0)},setEnd:function(e){this.caret.set(e,1,e,1)},set:function(t,n,r,i){this.utils.browser("msie")||this.$editor.focus(),t=t[0]||t,r=r[0]||r,this.utils.isBlockTag(t.tagName)&&t.innerHTML===""&&(t.innerHTML=this.opts.invisibleSpace);if(t.tagName=="BR"&&this.opts.linebreaks===!1){var s=e(this.opts.emptyHtml)[0];e(t).replaceWith(s),t=s,r=t}this.selection.get();try{this.range.setStart(t,n),this.range.setEnd(r,i)}catch(o){}this.selection.addRange()},setAfter:function(t){try{var n=e(t)[0].tagName;if(n!="BR"&&!this.utils.isBlock(t)){var r=this.utils.createSpaceElement();e(t).after(r),this.caret.setEnd(r)}else n!="BR"&&this.utils.browser("msie")?this.caret.setStart(e(t).next()):this.caret.setAfterOrBefore(t,"after")}catch(i){var r=this.utils.createSpaceElement();e(t).after(r),this.caret.setEnd(r)}},setBefore:function(t){this.utils.isBlock(t)?this.caret.setEnd(e(t).prev()):this.caret.setAfterOrBefore(t,"before")},setAfterOrBefore:function(e,t){this.utils.browser("msie")||this.$editor.focus(),e=e[0]||e,this.selection.get();if(t=="after")try{this.range.setStartAfter(e),this.range.setEndAfter(e)}catch(n){}else try{this.range.setStartBefore(e),this.range.setEndBefore(e)}catch(n){}this.range.collapse(!1),this.selection.addRange()},getOffsetOfElement:function(t){t=t[0]||t,this.selection.get();var n=this.range.cloneRange();return n.selectNodeContents(t),n.setEnd(this.range.endContainer,this.range.endOffset),e.trim(n.toString()).length},getOffset:function(){var e=0,t=window.getSelection();if(t.rangeCount>0){var n=window.getSelection().getRangeAt(0),r=n.cloneRange();r.selectNodeContents(this.$editor[0]),r.setEnd(n.endContainer,n.endOffset),e=r.toString().length}return e},setOffset:function(e,t){typeof t=="undefined"&&(t=e),this.focus.isFocused()||this.focus.setStart();var n=document.createRange(),r=document.getSelection(),i,s=0,o=document.createTreeWalker(this.$editor[0],NodeFilter.SHOW_TEXT,null,null);while(i=o.nextNode()){s+=i.nodeValue.length,s>e&&(n.setStart(i,i.nodeValue.length+e-s),e=Infinity);if(s>=t){n.setEnd(i,i.nodeValue.length+t-s);break}}r.removeAllRanges(),r.addRange(n)},setToPoint:function(e,t){this.caret.setOffset(e,t)},getCoords:function(){return this.caret.getOffset()}}},clean:function(){return{onSet:function(t){t=this.clean.savePreCode(t),t=t.replace(/<script(.*?[^>]?)>([\w\W]*?)<\/script>/gi,'<pre class="redactor-script-tag" style="display: none;" $1>$2</pre>'),t=t.replace(/\$/g,"$"),t=t.replace(/â€/g,'"'),t=t.replace(/‘/g,"'"),t=t.replace(/’/g,"'"),this.opts.replaceDivs&&(t=this.clean.replaceDivs(t)),this.opts.linebreaks&&(t=this.clean.replaceParagraphsToBr(t)),t=this.clean.saveFormTags(t);var n=e("<div>");n.html(t);var r=n.find("font[style]");return r.length!==0&&(r.replaceWith(function(){var t=e(this),n=e("<span>").attr("style",t.attr("style"));return n.append(t.contents())}),t=n.html()),n.remove(),t=t.replace(/<font(.*?[^<])>/gi,""),t=t.replace(/<\/font>/gi,""),t=this.tidy.load(t),this.opts.paragraphize&&(t=this.paragraphize.load(t)),t=this.clean.setVerified(t),t=this.clean.convertInline(t),t},onSync:function(t){t=t.replace(/[\u200B-\u200D\uFEFF]/g,""),t=t.replace(/​/gi,""),t=t.replace(/ /gi," ");if(t.search(/^<p>(||\s|| )<\/p>$/i)!=-1)return"";t=t.replace(/<pre class="redactor-script-tag" style="display: none;"(.*?[^>]?)>([\w\W]*?)<\/pre>/gi,"<script$1>$2</script>"),t=this.clean.restoreFormTags(t);var n={"â„¢":"™","©":"©","…":"…","—":"—","â€":"‐"};return e.each(n,function(e,n){t=t.replace(new RegExp(e,"g"),n)}),t=t.replace(new RegExp("<br\\s?/?></li>","gi"),"</li>"),t=t.replace(new RegExp("</li><br\\s?/?>","gi"),"</li>"),t=t.replace(new RegExp('<div(.*?) data-tagblock="redactor"(.*?[^>])>',"gi"),"<div$1$2>"),t=t.replace(new RegExp('<(.*?) data-verified="redactor"(.*?[^>])>',"gi"),"<$1$2>"),t=t.replace(new RegExp('<span(.*?) rel="(.*?)"(.*?[^>])>',"gi"),"<span$1$3>"),t=t.replace(new RegExp('<img(.*?) rel="(.*?)"(.*?[^>])>',"gi"),"<img$1$3>"),t=t.replace(new RegExp('<img(.*?) style="" (.*?[^>])>',"gi"),"<img$1 $2>"),t=t.replace(new RegExp("<img(.*?) style (.*?[^>])>","gi"),"<img$1 $2>"),t=t.replace(new RegExp('<span class="redactor-invisible-space">(.*?)</span>',"gi"),"$1"),t=t.replace(/ data-save-url="(.*?[^>])"/gi,""),t=t.replace(/<span(.*?)id="redactor-image-box"(.*?[^>])>([\w\W]*?)<img(.*?)><\/span>/gi,"$3<img$4>"),t=t.replace(/<span(.*?)id="redactor-image-resizer"(.*?[^>])>(.*?)<\/span>/gi,""),t=t.replace(/<span(.*?)id="redactor-image-editter"(.*?[^>])>(.*?)<\/span>/gi,""),t=t.replace(/<font(.*?[^<])>/gi,""),t=t.replace(/<\/font>/gi,""),t=this.tidy.load(t),this.opts.linkNofollow&&(t=t.replace(/<a(.*?)rel="nofollow"(.*?[^>])>/gi,"<a$1$2>"),t=t.replace(/<a(.*?[^>])>/gi,'<a$1 rel="nofollow">')),t=t.replace(/<(.*?) data-redactor-tag="(.*?)"(.*?[^>])>/gi,"<$1$3>"),t=t.replace(/<(.*?) data-redactor-class="(.*?)"(.*?[^>])>/gi,"<$1$3>"),t=t.replace(/<(.*?) data-redactor-style="(.*?)"(.*?[^>])>/gi,"<$1$3>"),t=t.replace(new RegExp('<(.*?) data-verified="redactor"(.*?[^>])>',"gi"),"<$1$2>"),t=t.replace(new RegExp('<(.*?) data-verified="redactor">',"gi"),"<$1>"),t},onPaste:function(t,n){t=e.trim(t);if(!t)return t;t=t.replace(/\$/g,"$"),t=t.replace(/â€/g,'"'),t=t.replace(/“/g,'"'),t=t.replace(/‘/g,"'"),t=t.replace(/’/g,"'"),t=t.replace(/<span class="Apple-converted-space"> <\/span>/gi," "),t=t.replace(/<span class="Apple-tab-span"[^>]*>\t<\/span>/gi," "),t=t.replace(/<span[^>]*>(\s| )<\/span>/gi," ");if(this.opts.pastePlainText)return this.clean.getPlainText(t);if(!this.utils.isSelectAll()&&typeof n=="undefined"){if(this.utils.isCurrentOrParent(["FIGCAPTION","A"]))return this.clean.getPlainText(t,!1);if(this.utils.isCurrentOrParent("PRE"))return this.clean.getPreCode(t);if(this.utils.isCurrentOrParent(["BLOCKQUOTE","H1","H2","H3","H4","H5","H6"])){t=this.clean.getOnlyImages(t);if(!this.utils.browser("msie")){var r=this.selection.getBlock();r&&r.tagName=="P"&&(t=t.replace(/<img(.*?)>/gi,"<p><img$1></p>"))}return t}if(this.utils.isCurrentOrParent(["TD"]))return t=this.clean.onPasteTidy(t,"td"),this.opts.linebreaks&&(t=this.clean.replaceParagraphsToBr(t)),t=this.clean.replaceDivsToBr(t),t;if(this.utils.isCurrentOrParent(["LI"]))return this.clean.onPasteTidy(t,"li")}return t=this.clean.isSingleLine(t,n),this.clean.singleLine||(this.opts.linebreaks&&(t=this.clean.replaceParagraphsToBr(t)),this.opts.replaceDivs&&(t=this.clean.replaceDivs(t)),t=this.clean.saveFormTags(t)),t=this.clean.onPasteWord(t),t=this.clean.onPasteExtra(t),t=this.clean.onPasteTidy(t,"all"),!this.clean.singleLine&&this.opts.paragraphize&&(t=this.paragraphize.load(t)),t=this.clean.removeDirtyStyles(t),t=this.clean.onPasteRemoveSpans(t),t=this.clean.onPasteRemoveEmpty(t),t=this.clean.convertInline(t),t},onPasteWord:function(e){return e=e.replace(/<!--[\s\S]*?-->/gi,""),e=e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi,""),/(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/.test(e)&&(e=this.clean.onPasteIeFixLinks(e),e=e.replace(/<img(.*?)v:shapes=(.*?)>/gi,""),e=e.replace(/src="file\:\/\/(.*?)"/ +,'src=""'),e=e.replace(/<p(.*?)class="MsoListParagraphCxSpFirst"([\w\W]*?)<\/p>/gi,"<ul><li$2</li>"),e=e.replace(/<p(.*?)class="MsoListParagraphCxSpMiddle"([\w\W]*?)<\/p>/gi,"<li$2</li>"),e=e.replace(/<p(.*?)class="MsoListParagraphCxSpLast"([\w\W]*?)<\/p>/gi,"<li$2</li></ul>"),e=e.replace(/<p(.*?)class="MsoListParagraph"([\w\W]*?)<\/p>/gi,"<ul><li$2</li></ul>"),e=e.replace(/·/g,""),e=e.replace(/<p class="Mso(.*?)"/gi,"<p"),e=e.replace(/ class=\"(mso[^\"]*)\"/gi,""),e=e.replace(/ class=(mso\w+)/gi,""),e=e.replace(/<o:p(.*?)>([\w\W]*?)<\/o:p>/gi,"$2"),e=e.replace(/\n/g," "),e=e.replace(/<p>\n?<li>/gi,"<li>")),this.opts.cleanSpaces&&(e=e.replace(/(\s| )+/g," ")),e},onPasteExtra:function(e){return e=e.replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2"),e=e.replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3"),e=e.replace(/<span[^>]*(font-style: italic; font-weight: bold|font-weight: bold; font-style: italic)[^>]*>/gi,'<span style="font-weight: bold;"><span style="font-style: italic;">'),e=e.replace(/<span[^>]*font-style: italic[^>]*>/gi,'<span style="font-style: italic;">'),e=e.replace(/<span[^>]*font-weight: bold[^>]*>/gi,'<span style="font-weight: bold;">'),e=e.replace(/<span[^>]*text-decoration: underline[^>]*>/gi,'<span style="text-decoration: underline;">'),e=e.replace(/<img>/gi,""),e=e.replace(/\n{3,}/gi,"\n"),e=e.replace(/<font(.*?)>([\w\W]*?)<\/font>/gi,"$2"),e=e.replace(/<p><p>/gi,"<p>"),e=e.replace(/<\/p><\/p>/gi,"</p>"),e=e.replace(/<li>(\s*|\t*|\n*)<p>/gi,"<li>"),e=e.replace(/<\/p>(\s*|\t*|\n*)<\/li>/gi,"</li>"),e=e.replace(/<\/p>\s<p/gi,"</p><p"),e=e.replace(/<img src="webkit-fake-url\:\/\/(.*?)"(.*?)>/gi,""),e=e.replace(/<p>•([\w\W]*?)<\/p>/gi,"<li>$1</li>"),this.utils.browser("mozilla")&&(e=e.replace(/<br\s?\/?>$/gi,"")),e},onPasteTidy:function(e,t){var n=["span","a","pre","blockquote","small","em","strong","code","kbd","mark","address","cite","var","samp","dfn","sup","sub","b","i","u","del","ol","ul","li","dl","dt","dd","p","br","video","audio","iframe","embed","param","object","img","table","td","th","tr","tbody","tfoot","thead","h1","h2","h3","h4","h5","h6"],r=!1,i=[["a","*"],["img",["src","alt"]],["span",["class","rel","data-verified"]],["iframe","*"],["video","*"],["audio","*"],["embed","*"],["object","*"],["param","*"],["source","*"]];t=="all"?(r=["p","span","h1","h2","h3","h4","h5","h6"],i=[["table","class"],["td",["colspan","rowspan"]],["a","*"],["img",["src","alt","data-redactor-inserted-image"]],["span",["class","rel","data-verified"]],["iframe","*"],["video","*"],["audio","*"],["embed","*"],["object","*"],["param","*"],["source","*"]]):t=="td"?n=["ul","ol","li","span","a","small","em","strong","code","kbd","mark","cite","var","samp","dfn","sup","sub","b","i","u","del","ol","ul","li","dl","dt","dd","br","iframe","video","audio","embed","param","object","img","h1","h2","h3","h4","h5","h6"]:t=="li"&&(n=["ul","ol","li","span","a","small","em","strong","code","kbd","mark","cite","var","samp","dfn","sup","sub","b","i","u","del","br","iframe","video","audio","embed","param","object","img"]);var s={deniedTags:!1,allowedTags:n,removeComments:!0,removePhp:!0,removeAttr:!1,allowedAttr:i,removeEmpty:r};return this.tidy.load(e,s)},onPasteRemoveEmpty:function(e){return e=e.replace(/<(p|h[1-6])>(|\s|\n|\t|<br\s?\/?>)<\/(p|h[1-6])>/gi,""),this.opts.linebreaks||(e=e.replace(/<br>$/i,"")),e},onPasteRemoveSpans:function(e){return e=e.replace(/<span>(.*?)<\/span>/gi,"$1"),e=e.replace(/<span[^>]*>\s| <\/span>/gi," "),e},onPasteIeFixLinks:function(t){if(!this.utils.browser("msie"))return t;var n=e.trim(t);return n.search(/^<a(.*?)>(.*?)<\/a>$/i)===0&&(t=t.replace(/^<a(.*?)>(.*?)<\/a>$/i,"$2")),t},isSingleLine:function(e,t){this.clean.singleLine=!1;if(!this.utils.isSelectAll()&&typeof t=="undefined"){var n=this.opts.blockLevelElements.join("|").replace("P|","").replace("DIV|",""),r=e.match(new RegExp("</("+n+")>","gi")),i=e.match(/<\/(p|div)>/gi);if(!r&&(i===null||i&&i.length<=1)){console.log("isSingleLine",e,"?");var s=e.match(/<br\s?\/?>/gi),o=e.match(/<img(.*?[^>])>/gi);!s&&!o&&(this.clean.singleLine=!0,e=e.replace(/<\/?(p|div)(.*?)>/gi,""))}}return e},stripTags:function(e,t){t=(((t||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join("");var n=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;return e.replace(n,function(e,n){return t.indexOf("<"+n.toLowerCase()+">")>-1?e:""})},savePreCode:function(t){var n=t.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/gi);return n!==null&&e.each(n,e.proxy(function(e,n){var r=n.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/i);r[3]=r[3].replace(/<br\s?\/?>/g,"\n"),r[3]=r[3].replace(/ /g," "),this.opts.preSpaces&&(r[3]=r[3].replace(/\t/g,Array(this.opts.preSpaces+1).join(" "))),r[3]=this.clean.encodeEntities(r[3]),r[3]=r[3].replace(/\$/g,"$"),t=t.replace(n,"<"+r[1]+r[2]+">"+r[3]+"</"+r[1]+">")},this)),t},getTextFromHtml:function(t){t=t.replace(/<br\s?\/?>|<\/H[1-6]>|<\/p>|<\/div>|<\/li>|<\/td>/gi,"\n");var n=document.createElement("div");return n.innerHTML=t,t=n.textContent||n.innerText,e.trim(t)},getPlainText:function(e,t){return e=this.clean.getTextFromHtml(e),e=e.replace(/\n/g,"<br />"),this.opts.paragraphize&&typeof t=="undefined"&&(e=this.paragraphize.load(e)),e},getPreCode:function(e){return e=e.replace(/<img(.*?) style="(.*?)"(.*?[^>])>/gi,"<img$1$3>"),e=e.replace(/<img(.*?)>/gi,"<img$1>"),e=this.clean.getTextFromHtml(e),this.opts.preSpaces&&(e=e.replace(/\t/g,Array(this.opts.preSpaces+1).join(" "))),e=this.clean.encodeEntities(e),e},getOnlyImages:function(e){return e=e.replace(/<img(.*?)>/gi,"[img$1]"),e=e.replace(/<(.*?)>/gi,""),e=e.replace(/\[img(.*?)\]/gi,"<img$1>"),e},getOnlyLinksAndImages:function(e){return e=e.replace(/<a(.*?)href="(.*?)"(.*?)>([\w\W]*?)<\/a>/gi,'[a href="$2"]$4[/a]'),e=e.replace(/<img(.*?)>/gi,"[img$1]"),e=e.replace(/<(.*?)>/gi,""),e=e.replace(/\[a href="(.*?)"\]([\w\W]*?)\[\/a\]/gi,'<a href="$1">$2</a>'),e=e.replace(/\[img(.*?)\]/gi,"<img$1>"),e},encodeEntities:function(e){return e=String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"'),e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},removeDirtyStyles:function(t){if(this.utils.browser("msie"))return t;var n=document.createElement("div");return n.innerHTML=t,this.clean.clearUnverifiedRemove(e(n)),t=n.innerHTML,e(n).remove(),t},clearUnverified:function(){if(this.utils.browser("msie"))return;this.clean.clearUnverifiedRemove(this.$editor);var e=this.$editor.find("h1, h2, h3, h4, h5, h6");e.find("span").removeAttr("style"),e.find(this.opts.verifiedTags.join(", ")).removeAttr("style"),this.code.sync()},clearUnverifiedRemove:function(t){t.find(this.opts.verifiedTags.join(", ")).removeAttr("style"),t.find("span").not('[data-verified="redactor"]').removeAttr("style"),t.find('span[data-verified="redactor"], img[data-verified="redactor"]').each(function(t,n){var r=e(n);r.attr("style",r.attr("rel"))})},setVerified:function(e){if(this.utils.browser("msie"))return e;e=e.replace(new RegExp("<img(.*?[^>])>","gi"),'<img$1 data-verified="redactor">'),e=e.replace(new RegExp("<span(.*?)>","gi"),'<span$1 data-verified="redactor">');var t=e.match(new RegExp('<(span|img)(.*?)style="(.*?)"(.*?[^>])>',"gi"));if(t){var n=t.length;for(var r=0;r<n;r++)try{var i=t[r].replace(/style="(.*?)"/i,'style="$1" rel="$1"');e=e.replace(new RegExp(t[r],"gi"),i)}catch(s){}}return e},convertInline:function(t){var n=e("<div />").html(t),r=this.opts.inlineTags;return r.push("span"),n.find(r.join(",")).each(function(){var t=e(this),n=this.tagName.toLowerCase();t.attr("data-redactor-tag",n),n=="span"&&(t.attr("style")?t.attr("data-redactor-style",t.attr("style")):t.attr("class")&&t.attr("data-redactor-class",t.attr("class")))}),t=n.html(),n.remove(),t},normalizeLists:function(){this.$editor.find("li").each(function(t,n){var r=e(n).next();r.length!==0&&(r[0].tagName=="UL"||r[0].tagName=="OL")&&e(n).append(r)})},removeSpaces:function(e){return e=e.replace(/\n/g,""),e=e.replace(/[\t]*/g,""),e=e.replace(/\n\s*\n/g,"\n"),e=e.replace(/^[\s\n]*/g," "),e=e.replace(/[\s\n]*$/g," "),e=e.replace(/>\s{2,}</g,"> <"),e=e.replace(/\n\n/g,"\n"),e=e.replace(/[\u200B-\u200D\uFEFF]/g,""),e},replaceDivs:function(e){return this.opts.linebreaks?(e=e.replace(/<div><br\s?\/?><\/div>/gi,"<br />"),e=e.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"$2<br />")):e=e.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"<p$1>$2</p>"),e},replaceDivsToBr:function(e){return e=e.replace(/<div\s(.*?)>/gi,"<p>"),e=e.replace(/<div><br\s?\/?><\/div>/gi,"<br /><br />"),e=e.replace(/<div>([\w\W]*?)<\/div>/gi,"$1<br /><br />"),e},replaceParagraphsToBr:function(e){return e=e.replace(/<p\s(.*?)>/gi,"<p>"),e=e.replace(/<p><br\s?\/?><\/p>/gi,"<br />"),e=e.replace(/<p>([\w\W]*?)<\/p>/gi,"$1<br /><br />"),e=e.replace(/(<br\s?\/?>){1,}\n?<\/blockquote>/gi,"</blockquote>"),e},saveFormTags:function(e){return e.replace(/<form(.*?)>([\w\W]*?)<\/form>/gi,'<section$1 rel="redactor-form-tag">$2</section>')},restoreFormTags:function(e){return e.replace(/<section(.*?) rel="redactor-form-tag"(.*?)>([\w\W]*?)<\/section>/gi,"<form$1$2>$3</form>")}}},code:function(){return{set:function(t){t=e.trim(t.toString()),t=this.clean.onSet(t),this.$editor.html(t),this.code.sync(),setTimeout(e.proxy(this.buffer.add,this),15),this.start===!1&&this.observe.load()},get:function(){var e=this.$textarea.val();return e=this.tabifier.get(e),e},sync:function(){setTimeout(e.proxy(this.code.startSync,this),10)},startSync:function(){var e=this.$editor.html();if(this.code.syncCode&&this.code.syncCode==e)return;this.code.syncCode=e,e=this.core.setCallback("syncBefore",e),e=this.clean.onSync(e),this.$textarea.val(e),this.core.setCallback("sync",e),this.start===!1&&this.core.setCallback("change",e),this.start=!1,this.autosave.onChange()},toggle:function(){this.opts.visual?this.code.showCode():this.code.showVisual()},showCode:function(){this.code.offset=this.caret.getOffset();var t=e(window).scrollTop(),n=this.$editor.innerHeight();this.$editor.hide();var r=this.$textarea.val();this.modified=this.clean.removeSpaces(r),r=this.tabifier.get(r),this.$textarea.val(r).height(n).show().focus(),this.$textarea.on("keydown.redactor-textarea-indenting",this.code.textareaIndenting),e(window).scrollTop(t),this.$textarea[0].setSelectionRange&&this.$textarea[0].setSelectionRange(0,0),this.$textarea[0].scrollTop=0,this.opts.visual=!1,this.button.setInactiveInCode(),this.button.setActive("html"),this.core.setCallback("source",r)},showVisual:function(){if(this.opts.visual)return;var e=this.$textarea.hide().val();this.modified!==this.clean.removeSpaces(e)&&this.code.set(e),this.$editor.show(),this.utils.isEmpty(e)||this.placeholder.remove(),this.caret.setOffset(this.code.offset),this.$textarea.off("keydown.redactor-textarea-indenting"),this.button.setActiveInVisual(),this.button.setInactive("html"),this.observe.load(),this.opts.visual=!0},textareaIndenting:function(e){if(e.keyCode!==9)return!0;var t=this.$textarea,n=t.get(0).selectionStart;return t.val(t.val().substring(0,n)+" "+t.val().substring(t.get(0).selectionEnd)),t.get(0).selectionStart=t.get(0).selectionEnd=n+1,!1}}},core:function(){return{getObject:function(){return e.extend({},this)},getEditor:function(){return this.$editor},getBox:function(){return this.$box},getElement:function(){return this.$element},getTextarea:function(){return this.$textarea},getToolbar:function(){return this.$toolbar?this.$toolbar:!1},addEvent:function(e){this.core.event=e},getEvent:function(){return this.core.event},setCallback:function(t,n,r){var i=this.opts[t+"Callback"];return e.isFunction(i)?typeof r=="undefined"?i.call(this,n):i.call(this,n,r):typeof r=="undefined"?n:r},destroy:function(){this.core.setCallback("destroy"),this.$element.off(".redactor").removeData("redactor"),this.$editor.off(".redactor"),this.$editor.removeClass("redactor-editor redactor-linebreaks redactor-placeholder"),this.$editor.removeAttr("contenteditable");var t=this.code.get();this.build.isTextarea()?(this.$box.after(this.$element),this.$box.remove(),this.$element.val(t).show()):(this.$box.after(this.$editor),this.$box.remove(),this.$element.html(t).show()),this.$pasteBox&&this.$pasteBox.remove(),this.$modalBox&&this.$modalBox.remove(),this.$modalOverlay&&this.$modalOverlay.remove(),e(".redactor-toolbar-tooltip").remove(),clearInterval(this.autosaveInterval)}}},dropdown:function(){return{build:function(t,n,r){t=="formatting"&&this.opts.formattingAdd&&e.each(this.opts.formattingAdd,e.proxy(function(e,t){var n=t.tag;typeof t.class!="undefined"&&(n=n+"-"+t.class),t.type=this.utils.isBlockTag(t.tag)?"block":"inline";var i=t.type=="inline"?"inline.formatting":"block.formatting";if(this.opts.linebreaks&&t.type=="block"&&t.tag=="p")return;this.formatting[n]={tag:t.tag,style:t.style,"class":t.class,attr:t.attr,data:t.data},r[n]={func:i,title:t.title}},this)),e.each(r,e.proxy(function(r,i){var s=e('<a href="#" class="redactor-dropdown-'+r+'">'+i.title+"</a>");t=="formatting"&&s.addClass("redactor-formatting-"+r),s.on("click",e.proxy(function(e){var t="func",n=i.func;i.command?(t="command",n=i.command):i.dropdown&&(t="dropdown",n=i.dropdown),this.button.onClick(e,r,t,n)},this)),n.append(s)},this))},show:function(t,n){if(!this.opts.visual)return t.preventDefault(),!1;var r=this.button.get(n),i=r.data("dropdown").appendTo(document.body);document.activeElement.blur();if(r.hasClass("dropact"))this.dropdown.hideAll();else{this.dropdown.hideAll(),this.core.setCallback("dropdownShow",{dropdown:i,key:n,button:r}),this.button.setActive(n),r.addClass("dropact");var s=r.offset(),o=i.width();s.left+o>e(document).width()&&(s.left-=o);var u=s.left+"px";if(this.$toolbar.hasClass("toolbar-fixed-box")){var a=this.$toolbar.innerHeight()+this.opts.toolbarFixedTopOffset,f="fixed";this.opts.toolbarFixedTarget!==document&&(a=this.$toolbar.innerHeight()+this.$toolbar.offset().top+this.opts.toolbarFixedTopOffset,f="absolute"),i.css({position:f,left:u,top:a+"px"}).show()}else{var a=r.innerHeight()+s.top+"px";i.css({position:"absolute",left:u,top:a}).show()}this.core.setCallback("dropdownShown",{dropdown:i,key:n,button:r})}e(document).one("click",e.proxy(this.dropdown.hide,this)),this.$editor.one("click",e.proxy(this.dropdown.hide,this));var l=e(document.body),c=l.width();i.on("mouseover",function(){l.addClass("body-hidden"),l.css("margin-right",l.width()-c+"px")}),i.on("mouseout",function(){l.removeClass("body-hidden").css("margin-right",0)}),t.stopPropagation()},hideAll:function(){this.$toolbar.find("a.dropact").removeClass("redactor-act").removeClass("dropact"),e(document.body).removeClass("body-hidden").css("margin-right",0),e(".redactor-dropdown").hide(),this.core.setCallback("dropdownHide")},hide:function(t){var n=e(t.target);n.hasClass("dropact")||(n.removeClass("dropact"),this.dropdown.hideAll())}}},file:function(){return{show:function(){this.modal.load("file",this.lang.get("file"),700),this.upload.init("#redactor-modal-file-upload",this.opts.fileUpload,this.file.insert),this.selection.save(),this.selection.get();var t=this.sel.toString();e("#redactor-filename").val(t),this.modal.show()},insert:function(t,n,r){if(typeof t.error!="undefined"){this.modal.close(),this.selection.restore(),this.core.setCallback("fileUploadError",t);return}var i;if(typeof t=="string")i=t;else{var s=e("#redactor-filename").val();if(typeof s=="undefined"||s==="")s=t.filename;i='<a href="'+t.filelink+'" id="filelink-marker">'+s+"</a>"}if(n){this.selection.removeMarkers();var o=this.selection.getMarker();this.insert.nodeToCaretPositionFromPoint(r,o)}else this.modal.close();this.selection.restore(),this.buffer.set(),this.insert.html(i);if(typeof t=="string")return;var u=e(this.$editor.find("a#filelink-marker"));u.size()!==0?u.removeAttr("id"):u=!1,this.core.setCallback("fileUpload",u,t)}}},focus:function(){return{setStart:function(){this.$editor.focus();var e=this.$editor.children().first();if(e.size()===0)return;if(e[0].length===0||e[0].tagName=="BR"||e[0].nodeType==3)return;if(e[0].tagName=="UL"||e[0].tagName=="OL"){e=e.find("li").first();var t=e.children().first();if(!this.utils.isBlock(t)&&t.text()===""){this.caret.setStart(t);return}}if(this.opts.linebreaks&&!this.utils.isBlockTag(e[0].tagName)){this.selection.get(),this.range.setStart(this.$editor[0],0),this.range.setEnd(this.$editor[0],0),this.selection.addRange();return}this.caret.setStart(e)},setEnd:function(){if(this.utils.browser("mozilla")||this.utils.browser("msie")){var e=this.$editor.children().last();this.caret.setEnd(e)}else{this.selection.get();try{this.range.selectNodeContents(this.$editor[0]),this.range.collapse(!1),this.selection.addRange()}catch(t){}}},isFocused:function(){var t=document.getSelection().focusNode;return t===null?!1:this.opts.linebreaks&&e(t.parentNode).hasClass("redactor-linebreaks")?!0:this.utils.isRedactorParent(t.parentNode)?this.$editor.is(":focus"):!1}}},image:function(){return{show:function(){this.modal.load("image",this.lang.get("image"),700),this.upload.init("#redactor-modal-image-droparea",this.opts.imageUpload,this.image.insert),this.selection.save(),this.modal.show()},showEdit:function(t){var n=t.closest("a");this.modal.load("imageEdit",this.lang.get("edit"),705),this.modal.createCancelButton(),this.image.buttonDelete=this.modal.createDeleteButton(this.lang.get("_delete")),this.image.buttonSave=this.modal.createActionButton(this.lang.get("save")),this.image.buttonDelete.on("click",e.proxy(function(){this.image.remove(t)},this)),this.image.buttonSave.on("click",e.proxy(function(){this.image.update(t)},this)),e("#redactor-image-title").val(t.attr("alt"));if(!this.opts.imageLink)e(".redactor-image-link-option").hide();else{var r=e("#redactor-image-link");r.attr("href",t.attr("src")),n.size()!==0&&(r.val(n.attr("href")),n.attr("target")=="_blank"&&e("#redactor-image-link-blank").prop("checked",!0))}if(!this.opts.imagePosition)e(".redactor-image-position-option").hide();else{var i=t.css("display")=="block"&&t.css("float")=="none"?"center":t.css("float");e("#redactor-image-align").val(i)}this.modal.show()},setFloating:function(t){var n=e("#redactor-image-align").val(),r="",i="",s="";switch(n){case"left":r="left",s="0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin+" 0";break;case"right":r="right",s="0 0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin;break;case"center":i="block",s="auto"}t.css({"float":r,display:i,margin:s}),t.attr("rel",t.attr("style"))},update:function(t){this.image.hideResize(),this.buffer.set();var n=t.closest("a");t.attr("alt",e("#redactor-image-title").val()),this.image.setFloating(t);var r=e.trim(e("#redactor-image-link").val());if(r!==""){var i=e("#redactor-image-link-blank").prop("checked")?!0:!1;if(n.size()===0){var s=e('<a href="'+r+'">'+this.utils.getOuterHtml(t)+"</a>");i&&s.attr("target","_blank"),t.replaceWith(s)}else n.attr("href",r),i?n.attr("target","_blank"):n.removeAttr("target")}else n.size()!==0&&n.replaceWith(this.utils.getOuterHtml(t));this.modal.close(),this.observe.images(),this.code.sync()},setEditable:function(t){if(!this.opts.imageEditable)return;t.on("dragstart",e.proxy(this.image.onDrag,this)),t.on("mousedown",e.proxy(this.image.hideResize,this)),t.on("click touchstart",e.proxy(function(n){this.observe.image=t;if(this.$editor.find("#redactor-image-box").size()!==0)return!1;this.image.resizer=this.image.loadEditableControls(t),e(document).on("click.redactor-image-resize-hide",e.proxy(this.image.hideResize,this)),this.$editor.on("click.redactor-image-resize-hide",e.proxy(this.image.hideResize,this));if(!this.opts.imageResizable)return;this.image.resizer.on("mousedown.redactor touchstart.redactor",e.proxy(function(e){e.preventDefault(),this.image.resizeHandle={x:e.pageX,y:e.pageY,el:t,ratio:t.width()/t.height(),h:t.height()},e=e.originalEvent||e,e.targetTouches&&(this.image.resizeHandle.x=e.targetTouches[0].pageX,this.image.resizeHandle.y=e.targetTouches[0].pageY),this.image.startResize()},this))},this))},startResize:function(){e(document).on("mousemove.redactor-image-resize touchmove.redactor-image-resize",e.proxy(this.image.moveResize,this)),e(document).on("mouseup.redactor-image-resize touchend.redactor-image-resize",e.proxy(this.image.stopResize,this))},moveResize:function(e){e.preventDefault(),e=e.originalEvent||e;var t=this.image.resizeHandle.h;e.targetTouches?t+=e.targetTouches[0].pageY-this.image.resizeHandle.y:t+=e.pageY-this.image.resizeHandle.y;var n=Math.round(t*this.image.resizeHandle.ratio);if(t<50||n<100)return;this.image.resizeHandle.el.width(n),this.image.resizeHandle.el.height(this.image.resizeHandle.el.width()/this.image.resizeHandle.ratio),this.code.sync()},stopResize:function(){this.handle=!1,e(document).off(".redactor-image-resize"),this.image.hideResize()},onDrag:function(t){if(this.$editor.find("#redactor-image-box").size()!==0)return t.preventDefault(),!1;this.$editor.on("drop.redactor-image-inside-drop",e.proxy(function(){setTimeout(e.proxy(this.image.onDrop,this),1)},this))},onDrop:function(){this.image.fixImageSourceAfterDrop(),this.observe.images(),this.$editor.off("drop.redactor-image-inside-drop"),this.clean.clearUnverified(),this.code.sync()},fixImageSourceAfterDrop:function(){this.$editor.find("img[data-save-url]").each(function(){var t=e(this);t.attr("src",t.attr("data-save-url")),t.removeAttr("data-save-url")})},hideResize:function(t){if(t&&e(t.target).closest("#redactor-image-box").length!==0)return;if(t&&t.target.tagName=="IMG"){var n=e(t.target);n.attr("data-save-url",n.attr("src"))}var r=this.$editor.find("#redactor-image-box");if(r.size()===0)return;this.image.editter.remove(),e(this.image.resizer).remove(),r.find("img").css({marginTop:r[0].style.marginTop,marginBottom:r[0].style.marginBottom,marginLeft:r[0].style.marginLeft,marginRight:r[0].style.marginRight}),r.css("margin",""),r.find("img").css("opacity",""),r.replaceWith(function(){return e(this).contents()}),e(document).off("click.redactor-image-resize-hide"),this.$editor.off("click.redactor-image-resize-hide"),typeof this.image.resizeHandle!="undefined"&&this.image.resizeHandle.el.attr("rel",this.image.resizeHandle.el.attr("style")),this.code.sync()},loadEditableControls:function(t){var n=e('<span id="redactor-image-box" data-redactor="verified">');n.css("float",t.css("float")).attr("contenteditable",!1),t[0].style.margin!="auto"?(n.css({marginTop:t[0].style.marginTop,marginBottom:t[0].style.marginBottom,marginLeft:t[0].style.marginLeft,marginRight:t[0].style.marginRight}),t.css("margin","")):n.css({display:"block",margin:"auto"}),t.css("opacity",".5").after(n),this.image.editter=e('<span id="redactor-image-editter" data-redactor="verified">'+this.lang.get("edit")+"</span>"),this.image.editter.attr("contenteditable",!1),this.image.editter.on("click",e.proxy(function(){this.image.showEdit(t)},this)),n.append(this.image.editter);var r=this.image.editter.innerWidth();this.image.editter.css("margin-left","-"+r/2+"px");if(this.opts.imageResizable&&!this.utils.isMobile()){var i=e('<span id="redactor-image-resizer" data-redactor="verified"></span>');return this.utils.isDesktop()||i.css({width:"15px",height:"15px"}),i.attr("contenteditable",!1),n.append(i),n.append(t),i}return n.append(t),!1},remove:function(t){var n=e(t),r=n.closest("a"),i=n.closest("figure"),s=n.parent();e("#redactor-image-box").size()!==0&&(s=e("#redactor-image-box").parent());var o;i.size()!==0?(o=i.next(),i.remove()):r.size()!==0?(s=r.parent(),r.remove()):n.remove(),e("#redactor-image-box").remove(),i.size()!==0?this.caret.setStart(o):this.caret.setStart(s),this.core.setCallback("imageDelete",n[0].src,n),this.modal.close(),this.code.sync()},insert:function(t,n,r){if(typeof t.error!="undefined"){this.modal.close(),this.selection.restore(),this.core.setCallback("imageUploadError",t);return}var i;typeof t=="string"?i=e(t).attr("data-redactor-inserted-image","true"):(i=e("<img>"),i.attr("src",t.filelink).attr("data-redactor-inserted-image","true"));var s=i,o=this.utils.isCurrentOrParent("P");o&&(s=e("<blockquote />").append(i));if(n){this.selection.removeMarkers();var u=this.selection.getMarker();this.insert.nodeToCaretPositionFromPoint(r,u)}else this.modal.close();this.selection.restore(),this.buffer.set(),this.insert.html(this.utils.getOuterHtml(s),!1);var a=this.$editor.find("img[data-redactor-inserted-image=true]").removeAttr("data-redactor-inserted-image");o?a.parent().contents().unwrap().wrap("<p />"):this.opts.linebreaks&&a.before("<br>").after("<br>");if(typeof t=="string")return;this.core.setCallback("imageUpload",a,t)}}},indent:function(){return{increase:function(){this.utils.browser("msie")||this.$editor.focus(),this.buffer.set(),this.selection.save();var e=this.selection.getBlock();e&&e.tagName=="LI"?this.indent.increaseLists():e===!1&&this.opts.linebreaks?this.indent.increaseText():this.indent.increaseBlocks(),this.selection.restore(),this.code.sync()},increaseLists:function(){document.execCommand("indent"),this.indent.fixEmptyIndent(),this.clean.normalizeLists(),this.clean.clearUnverified()},increaseBlocks:function(){e.each(this.selection.getBlocks(),e.proxy(function(e,t){if(t.tagName==="TD"||t.tagName==="TH")return;var n=this.utils.getAlignmentElement(t),r=this.utils.normalize(n.css("margin-left"))+this.opts.indentValue;n.css("margin-left",r+"px")},this))},increaseText:function(){var t=this.selection.wrap("div");e(t).attr("data-tagblock","redactor"),e(t).css("margin-left",this.opts.indentValue+"px")},decrease:function(){this.buffer.set(),this.selection.save();var e=this.selection.getBlock();e&&e.tagName=="LI"?this.indent.decreaseLists():this.indent.decreaseBlocks(),this.selection.restore(),this.code.sync()},decreaseLists:function(){document.execCommand("outdent");var t=this.selection.getCurrent(),n=e(t).closest("li"),r=n.parent();n.size()!==0&&r.size()!==0&&r[0].tagName=="LI"&&r.after(n),this.indent.fixEmptyIndent(),!this.opts.linebreaks&&n.size()===0&&(document.execCommand("formatblock",!1,"p"),this.$editor.find("ul, ol, blockquote, p").each(e.proxy(this.utils.removeEmpty,this))),this.clean.clearUnverified()},decreaseBlocks:function(){e.each(this.selection.getBlocks(),e.proxy(function(e,t){var n=this.utils.getAlignmentElement(t),r=this.utils.normalize(n.css("margin-left"))-this.opts.indentValue;r<=0?this.opts.linebreaks&&typeof n.data("tagblock")!="undefined"?n.replaceWith(n.html()+"<br />"):(n.css("margin-left",""),this.utils.removeEmptyAttr(n,"style")):n.css("margin-left",r+"px")},this))},fixEmptyIndent:function(){var t=this.selection.getBlock();if(this.range.collapsed&&t&&t.tagName=="LI"&&this.utils.isEmpty(e(t).text())){var n=e(t);n.find("span").not(".redactor-selection-marker").contents().unwrap(),n.append("<br>")}}}},inline:function(){return{formatting:function(e){var t,n;typeof this.formatting[e].style!="undefined"?t="style":typeof this.formatting[e].class!="undefined"&&(t="class"),t&&(n=this.formatting[e][t]),this.inline.format(this.formatting[e].tag,t,n)},format:function(e,t,n){if(this.utils.isCurrentOrParent("PRE"))return;var r=["b","bold","i","italic","underline","strikethrough","deleted","superscript","subscript"],i=["strong","strong","em","em","u","del","del","sup","sub"];for(var s=0;s<r.length;s++)e==r[s]&&(e=i[s]);this.inline.type=t||!1,this.inline.value=n||!1,this.buffer.set(),this.$editor.focus(),this.selection.get(),this.range.collapsed?this.inline.formatCollapsed(e):this.inline.formatMultiple(e)},formatCollapsed:function(t){var n=this.selection.getCurrent(),r=e(n).closest(t+"[data-redactor-tag="+t+"]");if(r.size()!==0){this.caret.setAfter(r[0]),this.utils.isEmpty(r.text())&&r.remove(),this.code.sync();return}var i=e("<"+t+">").attr("data-verified","redactor").attr("data-redactor-tag",t);i.html(this.opts.invisibleSpace),i=this.inline.setFormat(i),this.insert.node(i),this.code.sync();return},formatMultiple:function(t){this.inline.formatConvert(t),this.selection.save(),document.execCommand("strikethrough"),this.$editor.find("strike").each(e.proxy(function(n,r){var i=e(r);this.inline.formatRemoveSameChildren(i,t);var s;this.inline.type?(s=e("<span>").attr("data-redactor-tag",t).attr("data-verified","redactor"),s=this.inline.setFormat(s)):s=e("<"+t+">").attr("data-redactor-tag",t).attr("data-verified","redactor"),i.replaceWith(s.html(i.contents()));if(t=="span"){var o=s.parent();if(o&&o[0].tagName=="SPAN"&&this.inline.type=="style"){var u=this.inline.value.split(";");for(var a=0;a<u.length;a++){if(u[a]==="")return;var f=u[a].split(":");o.css(f[0],""),this.utils.removeEmptyAttr(o,"style")&&o.replaceWith(o.contents())}}}},this)),t!="span"&&this.$editor.find(this.opts.inlineTags.join(", ")).each(e.proxy(function(t,n){var r=e(n),i=r.css("text-decoration");i=="line-through"&&(r.css("text-decoration",""),this.utils.removeEmptyAttr(r,"style"))},this));if(t!="del"){var n=this;this.$editor.find("inline").each(function(e,t){n.utils.replaceToTag(t,"del")})}this.selection.restore(),this.code.sync()},formatRemoveSameChildren:function(t,n){t.children(n).each(function(){var t=e(this);t.hasClass("redactor-selection-marker")||t.contents().unwrap()})},formatConvert:function(t){this.selection.save();var n="";this.inline.type=="class"?n="[data-redactor-class="+this.inline.value+"]":this.inline.type=="style"&&(n='[data-redactor-style="'+this.inline.value+'"]');if(t!="del"){var r=this;this.$editor.find("del").each(function(e,t){r.utils.replaceToTag(t,"inline")})}this.$editor.find('[data-redactor-tag="'+t+'"]'+n).each(function(){if(n===""&&t=="span"&&this.tagName.toLowerCase()==t)return;var r=e(this);r.replaceWith(e("<strike />").html(r.contents()))}),this.selection.restore()},setFormat:function(e){switch(this.inline.type){case"class":e.hasClass(this.inline.value)?(e.removeClass(this.inline.value),e.removeAttr("data-redactor-class")):(e.addClass(this.inline.value),e.attr("data-redactor-class",this.inline.value));break;case"style":e[0].style.cssText=this.inline.value,e.attr("data-redactor-style",this.inline.value)}return e},removeStyle:function(){this.buffer.set();var t=this.selection.getCurrent(),n=this.selection.getInlines();this.selection.save();if(t&&t.tagName==="SPAN"){var r=e(t);r.removeAttr("style"),r[0].attributes.length===0&&r.replaceWith(r.contents())}e.each(n,e.proxy(function(t,n){var r=e(n);e.inArray(n.tagName.toLowerCase(),this.opts.inlineTags)!=-1&&!r.hasClass("redactor-selection-marker")&&(r.removeAttr("style"),r[0].attributes.length===0&&r.replaceWith(r.contents()))},this)),this.selection.restore(),this.code.sync()},removeStyleRule:function(t){this.buffer.set();var n=this.selection.getParent(),r=this.selection.getInlines();this.selection.save();if(n&&n.tagName==="SPAN"){var i=e(n);i.css(t,""),this.utils.removeEmptyAttr(i,"style"),i[0].attributes.length===0&&i.replaceWith(i.contents())}e.each(r,e.proxy(function(n,r){var i=e(r);e.inArray(r.tagName.toLowerCase(),this.opts.inlineTags)!=-1&&!i.hasClass("redactor-selection-marker")&&(i.css(t,""),this.utils.removeEmptyAttr(i,"style"),i[0].attributes.length===0&&i.replaceWith(i.contents()))},this)),this.selection.restore(),this.code.sync()},removeFormat:function(){this.buffer.set();var t=this.selection.getCurrent();this.selection.save(),document.execCommand("removeFormat"),t&&t.tagName==="SPAN"&&e(t).replaceWith(e(t).contents()),e.each(this.selection.getNodes(),e.proxy(function(t,n){var r=e(n);e.inArray(n.tagName.toLowerCase(),this.opts.inlineTags)!=-1&&!r.hasClass("redactor-selection-marker")&&r.replaceWith(r.contents())},this)),this.selection.restore(),this.code.sync()},toggleClass:function(e){this.inline.format("span","class",e)},toggleStyle:function(e){this.inline.format("span","style",e)}}},insert:function(){return{set:function(t,n){this.placeholder.remove(),t=this.clean.setVerified(t),typeof n=="undefined"&&(t=this.clean.onPaste(t,!1)),this.$editor.html(t),this.selection.remove(),this.focus.setEnd(),this.clean.normalizeLists(),this.code.sync(),this.observe.load(),typeof n=="undefined"&&setTimeout(e.proxy(this.clean.clearUnverified,this),10)},text:function(t){this.placeholder.remove(),t=t.toString(),t=e.trim(t),t=this.clean.getPlainText(t,!1),this.$editor.focus();if(this.utils.browser("msie"))this.insert.htmlIe(t);else{this.selection.get(),this.range.deleteContents();var n=document.createElement("div");n.innerHTML=t;var r=document.createDocumentFragment(),i,s;while(i=n.firstChild)s=r.appendChild(i);this.range.insertNode(r);if(s){var o=this.range.cloneRange();o.setStartAfter(s),o.collapse(!0),this.sel.removeAllRanges(),this.sel.addRange(o)}}this.code.sync(),this.clean.clearUnverified()},htmlWithoutClean:function(e){this.insert.html(e,!1)},html:function(t,n){this.placeholder.remove(),typeof n=="undefined"&&(n=!0),this.$editor.focus(),t=this.clean.setVerified(t),n&&(t=this.clean.onPaste(t)),this.utils.browser +("msie")?this.insert.htmlIe(t):(console.log(this.clean.singleLine,t),this.clean.singleLine?this.insert.execHtml(t):document.execCommand("insertHTML",null,t),this.insert.htmlFixMozilla()),this.clean.normalizeLists(),this.opts.linebreaks||this.$editor.find("p").each(e.proxy(this.utils.removeEmpty,this)),this.code.sync(),this.observe.load(),n&&this.clean.clearUnverified()},htmlFixMozilla:function(){if(!this.utils.browser("mozilla"))return;var t=e(this.selection.getBlock()).next();t.length>0&&t[0].tagName=="P"&&t.html()===""&&t.remove()},htmlIe:function(t){if(this.utils.isIe11()){var n=this.utils.isCurrentOrParent("P"),r=e("<div>").append(t),i=r.contents().is("p, :header, dl, ul, ol, div, table, td, blockquote, pre, address, section, header, footer, aside, article");n&&i?this.insert.ie11FixInserting(n,t):this.insert.ie11PasteFrag(t);return}document.selection.createRange().pasteHTML(t)},execHtml:function(e){e=this.clean.setVerified(e),this.selection.get(),this.range.deleteContents();var t=document.createElement("div");t.innerHTML=e;var n=document.createDocumentFragment(),r,i;while(r=t.firstChild)i=n.appendChild(r);this.range.insertNode(n),this.range.collapse(!0),this.caret.setAfter(i)},node:function(t,n){t=t[0]||t;var r=this.utils.getOuterHtml(t);return r=this.clean.setVerified(r),t=e(r)[0],this.selection.get(),n!==!1&&this.range.deleteContents(),this.range.insertNode(t),this.range.collapse(!1),this.selection.addRange(),t},nodeToPoint:function(e,t,n){e=e[0]||e,this.selection.get();var r;if(document.caretPositionFromPoint){var i=document.caretPositionFromPoint(t,n);this.range.setStart(i.offsetNode,i.offset),this.range.collapse(!0),this.range.insertNode(e)}else if(document.caretRangeFromPoint)r=document.caretRangeFromPoint(t,n),r.insertNode(e);else if(typeof document.body.createTextRange!="undefined"){r=document.body.createTextRange(),r.moveToPoint(t,n);var s=r.duplicate();s.moveToPoint(t,n),r.setEndPoint("EndToEnd",s),r.select()}},nodeToCaretPositionFromPoint:function(e,t){t=t[0]||t;var n,r=e.clientX,i=e.clientY;if(document.caretPositionFromPoint){var s=document.caretPositionFromPoint(r,i),o=document.getSelection();n=o.getRangeAt(0),n.setStart(s.offsetNode,s.offset),n.collapse(!0),n.insertNode(t)}else if(document.caretRangeFromPoint)n=document.caretRangeFromPoint(r,i),n.insertNode(t);else if(typeof document.body.createTextRange!="undefined"){n=document.body.createTextRange(),n.moveToPoint(r,i);var u=n.duplicate();u.moveToPoint(r,i),n.setEndPoint("EndToEnd",u),n.select()}},ie11FixInserting:function(t,n){var r=document.createElement("span");r.className="redactor-ie-paste",this.insert.node(r);var i=e(t).html();i="<p>"+i.replace(/<span class="redactor-ie-paste"><\/span>/gi,"</p>"+n+"<p>")+"</p>",e(t).replaceWith(i)},ie11PasteFrag:function(e){this.selection.get(),this.range.deleteContents();var t=document.createElement("div");t.innerHTML=e;var n=document.createDocumentFragment(),r,i;while(r=t.firstChild)i=n.appendChild(r);this.range.insertNode(n)}}},keydown:function(){return{init:function(t){if(this.rtePaste)return;var n=t.which,r=n>=37&&n<=40;this.keydown.ctrl=t.ctrlKey||t.metaKey,this.keydown.current=this.selection.getCurrent(),this.keydown.parent=this.selection.getParent(),this.keydown.block=this.selection.getBlock(),this.keydown.pre=this.utils.isTag(this.keydown.current,"pre"),this.keydown.blockquote=this.utils.isTag(this.keydown.current,"blockquote"),this.keydown.figcaption=this.utils.isTag(this.keydown.current,"figcaption"),this.shortcuts.init(t,n),this.keydown.checkEvents(r,n),this.keydown.setupBuffer(t,n),this.keydown.addArrowsEvent(r),this.keydown.setupSelectAll(t,n);var i=this.core.setCallback("keydown",t);if(i===!1)return t.preventDefault(),!1;this.opts.enterKey&&n===this.keyCode.DOWN&&this.keydown.onArrowDown();if(!this.opts.enterKey&&n===this.keyCode.ENTER){t.preventDefault(),this.range.collapsed||this.range.deleteContents();return}if(n==this.keyCode.ENTER&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey){var s=this.core.setCallback("enter",t);if(s===!1)return t.preventDefault(),!1;if(this.keydown.blockquote&&this.keydown.exitFromBlockquote(t)===!0)return!1;var o,u;if(this.keydown.pre)return this.keydown.insertNewLine(t);if(this.keydown.blockquote||this.keydown.figcaption)return o=this.selection.getCurrent(),u=e(o).next(),u.size()!==0&&u[0].tagName=="BR"?this.keydown.insertBreakLine(t):this.utils.isEndOfElement()&&o&&o!="SPAN"?this.keydown.insertDblBreakLine(t):this.keydown.insertBreakLine(t);if(this.opts.linebreaks&&!this.keydown.block)return o=this.selection.getCurrent(),u=e(this.keydown.current).next(),o!==!1&&e(o).hasClass("redactor-invisible-space")?(e(o).remove(),this.keydown.insertDblBreakLine(t)):u.length===0&&o===!1&&typeof u.context!="undefined"?this.keydown.insertDblBreakLine(t):this.keydown.insertBreakLine(t);if(this.opts.linebreaks&&this.keydown.block)setTimeout(e.proxy(this.keydown.replaceDivToBreakLine,this),1);else if(!this.opts.linebreaks&&this.keydown.block&&this.keydown.block.tagName!=="LI")setTimeout(e.proxy(this.keydown.replaceDivToParagraph,this),1);else if(!this.opts.linebreaks&&!this.keydown.block)return this.keydown.insertParagraph(t)}if(n===this.keyCode.ENTER&&(t.ctrlKey||t.shiftKey))return this.keydown.onShiftEnter(t);if(n===this.keyCode.TAB||t.metaKey&&n===221||t.metaKey&&n===219)return this.keydown.onTab(t,n);if(n===this.keyCode.BACKSPACE||n===this.keyCode.DELETE){var a=this.selection.getNodes();if(a){var f=a.length,l;for(var c=0;c<f;c++){var h=e(a[c]).children("img");if(h.size()!==0){var p=this;e.each(h,function(t,n){var r=e(n);if(r.css("float")!="none")return;p.core.setCallback("imageDelete",n.src,r),l=n})}else a[c].tagName=="IMG"&&l!=a[c]&&(this.core.setCallback("imageDelete",a[c].src,e(a[c])),l=a[c])}}}n===this.keyCode.BACKSPACE&&(this.keydown.removeInvisibleSpace(),this.keydown.removeEmptyListInTable(t)),this.code.sync()},checkEvents:function(e,t){!e&&(this.core.getEvent()=="click"||this.core.getEvent()=="arrow")&&(this.core.addEvent(!1),this.keydown.checkKeyEvents(t)&&this.buffer.set())},checkKeyEvents:function(t){var n=this.keyCode,r=[n.BACKSPACE,n.DELETE,n.ENTER,n.SPACE,n.ESC,n.TAB,n.CTRL,n.META,n.ALT,n.SHIFT];return e.inArray(t,r)==-1?!0:!1},addArrowsEvent:function(e){if(!e)return;if(this.core.getEvent()=="click"||this.core.getEvent()=="arrow"){this.core.addEvent(!1);return}this.core.addEvent("arrow")},setupBuffer:function(e,t){if(this.keydown.ctrl&&t===90&&!e.shiftKey&&!e.altKey&&this.opts.buffer.length){e.preventDefault(),this.buffer.undo();return}if(this.keydown.ctrl&&t===90&&e.shiftKey&&!e.altKey&&this.opts.rebuffer.length!==0){e.preventDefault(),this.buffer.redo();return}this.keydown.ctrl||(t==this.keyCode.BACKSPACE||t==this.keyCode.DELETE||t==this.keyCode.ENTER&&!e.ctrlKey&&!e.shiftKey||t==this.keyCode.SPACE)&&this.buffer.set()},setupSelectAll:function(e,t){this.keydown.ctrl&&t===65?this.utils.enableSelectAll():t!=this.keyCode.LEFT_WIN&&!this.keydown.ctrl&&this.utils.disableSelectAll()},onArrowDown:function(){var e=[this.keydown.blockquote,this.keydown.pre,this.keydown.figcaption];for(var t=0;t<e.length;t++)if(e[t])return this.keydown.insertAfterLastElement(e[t]),!1},onShiftEnter:function(e){return this.buffer.set(),this.keydown.blockquote&&this.utils.isEndOfElement()?this.keydown.insertDblBreakLine(e):this.keydown.insertBreakLine(e)},onTab:function(e,t){if(!this.opts.tabFocus)return!0;if(this.utils.isEmpty(this.code.get())&&this.opts.tabAsSpaces===!1)return!0;e.preventDefault();var n;return this.keydown.pre&&!e.shiftKey?(n=this.opts.preSpaces?document.createTextNode(Array(this.opts.preSpaces+1).join(" ")):document.createTextNode(" "),this.insert.node(n),this.code.sync()):this.opts.tabAsSpaces!==!1?(n=document.createTextNode(Array(this.opts.tabAsSpaces+1).join(" ")),this.insert.node(n),this.code.sync()):e.metaKey&&t===219?this.indent.decrease():e.metaKey&&t===221?this.indent.increase():e.shiftKey?this.indent.decrease():this.indent.increase(),!1},replaceDivToBreakLine:function(){var t=this.selection.getBlock(),n=t.innerHTML.replace(/<br\s?\/?>/gi,"");if((t.tagName==="DIV"||t.tagName==="P")&&n===""&&!e(t).hasClass("redactor-editor")){var r=document.createElement("br");return e(t).replaceWith(r),this.caret.setBefore(r),this.code.sync(),!1}},replaceDivToParagraph:function(){var t=this.selection.getBlock(),n=t.innerHTML.replace(/<br\s?\/?>/gi,"");if(t.tagName==="DIV"&&n===""&&!e(t).hasClass("redactor-editor")){var r=document.createElement("p");return r.innerHTML=this.opts.invisibleSpace,e(t).replaceWith(r),this.caret.setStart(r),this.code.sync(),!1}this.opts.cleanStyleOnEnter&&t.tagName=="P"&&e(t).removeAttr("class").removeAttr("style")},insertParagraph:function(e){e.preventDefault(),this.selection.get();var t=document.createElement("p");return t.innerHTML=this.opts.invisibleSpace,this.range.deleteContents(),this.range.insertNode(t),this.caret.setStart(t),this.code.sync(),!1},exitFromBlockquote:function(t){if(!this.utils.isEndOfElement())return;var n=e.trim(e(this.keydown.block).html());if(n.search(/(<br\s?\/?>){2}$/i)!=-1){t.preventDefault();if(this.opts.linebreaks){var r=document.createElement("br");e(this.keydown.blockquote).after(r),this.caret.setBefore(r),e(this.keydown.block).html(n.replace(/<br\s?\/?>$/i,""))}else{var i=e(this.opts.emptyHtml);e(this.keydown.blockquote).after(i),this.caret.setStart(i)}return!0}return},insertAfterLastElement:function(t){if(!this.utils.isEndOfElement())return;this.buffer.set();if(this.opts.linebreaks){var n=e("<div>").append(e.trim(this.$editor.html())).contents(),r=n.last()[0];r.tagName=="SPAN"&&r.innerHTML===""&&(r=n.prev()[0]);if(this.utils.getOuterHtml(r)!=this.utils.getOuterHtml(t))return;var i=document.createElement("br");e(t).after(i),this.caret.setAfter(i)}else{if(this.$editor.contents().last()[0]!==t)return;var s=e(this.opts.emptyHtml);e(t).after(s),this.caret.setStart(s)}},insertNewLine:function(e){e.preventDefault();var t=document.createTextNode("\n");return this.selection.get(),this.range.deleteContents(),this.range.insertNode(t),this.caret.setAfter(t),this.code.sync(),!1},insertBreakLine:function(e){return this.keydown.insertBreakLineProcessing(e)},insertDblBreakLine:function(e){return this.keydown.insertBreakLineProcessing(e,!0)},insertBreakLineProcessing:function(e,t){e.stopPropagation(),this.selection.get();var n=document.createElement("br");this.range.deleteContents(),this.range.insertNode(n);if(t===!0){var r=document.createElement("br");this.range.insertNode(r),this.caret.setAfter(r)}else this.caret.setAfter(n);return this.code.sync(),!1},removeInvisibleSpace:function(){var t=e(this.keydown.current);t.text().search(/^\u200B$/g)===0&&t.remove()},removeEmptyListInTable:function(t){var n=e(this.keydown.current),r=e(this.keydown.parent),i=n.closest("td");if(i.size()!==0&&n.closest("li")&&r.children("li").size()===1){if(!this.utils.isEmpty(n.text()))return;t.preventDefault(),n.remove(),r.remove(),this.caret.setStart(i)}}}},keyup:function(){return{init:function(t){if(this.rtePaste)return;var n=t.which;this.keyup.current=this.selection.getCurrent(),this.keyup.parent=this.selection.getParent();var r=this.utils.isRedactorParent(e(this.keyup.parent).parent()),i=this.core.setCallback("keyup",t);if(i===!1)return t.preventDefault(),!1;!this.opts.linebreaks&&this.keyup.current.nodeType==3&&this.keyup.current.length<=1&&(this.keyup.parent===!1||this.keyup.parent.tagName=="BODY")&&this.keyup.replaceToParagraph(),!this.opts.linebreaks&&e(this.keyup.parent).hasClass("redactor-invisible-space")&&(r===!1||r[0].tagName=="BODY")&&(e(this.keyup.parent).contents().unwrap(),this.keyup.replaceToParagraph()),this.opts.convertLinks&&(this.opts.convertUrlLinks||this.opts.convertImageLinks||this.opts.convertVideoLinks)&&n===this.keyCode.ENTER&&(this.formatLinkify(this.opts.linkProtocol,this.opts.convertLinks,this.opts.convertUrlLinks,this.opts.convertImageLinks,this.opts.convertVideoLinks,this.opts.linkSize),this.observe.load(),this.code.sync());if(n===this.keyCode.DELETE||n===this.keyCode.BACKSPACE)return this.clean.clearUnverified(),this.observe.image?(t.preventDefault(),this.image.hideResize(),this.buffer.set(),this.image.remove(this.observe.image),this.observe.image=!1,!1):(this.$editor.find("p").each(e.proxy(this.utils.removeEmpty,this)),this.keyup.current&&this.keyup.current.tagName=="DIV"&&this.utils.isEmpty(this.keyup.current.innerHTML)&&this.opts.linebreaks&&(e(this.keyup.current).after(this.selection.getMarkerAsHtml()),this.selection.restore(),e(this.keyup.current).remove()),this.keyup.formatEmpty(t))},replaceToParagraph:function(){var t=e(this.keyup.current),n=e("<p>").append(t.clone());t.replaceWith(n);var r=e(n).next();typeof r[0]!="undefined"&&r[0].tagName=="BR"&&r.remove(),this.caret.setEnd(n)},formatEmpty:function(t){var n=e.trim(this.$editor.html());if(!this.utils.isEmpty(n))return;return t.preventDefault(),this.opts.linebreaks?(this.$editor.html(this.selection.getMarkerAsHtml()),this.selection.restore()):(n="<p><br /></p>",this.$editor.html(n),this.focus.setStart()),this.code.sync(),!1}}},lang:function(){return{load:function(){this.opts.curLang=this.opts.langs[this.opts.lang]},get:function(e){return typeof this.opts.curLang[e]!="undefined"?this.opts.curLang[e]:""}}},line:function(){return{insert:function(){this.buffer.set();var e=this.selection.getBlocks();if(e[0]!==!1&&this.line.isExceptLastOrFirst(e)){this.utils.browser("msie")||this.$editor.focus();return}this.utils.browser("msie")?this.line.insertInIe():this.line.insertInOthersBrowsers()},isExceptLastOrFirst:function(t){var n=["li","td","th","blockquote","figcaption","pre","dl","dt","dd"],r=t[0].tagName.toLowerCase(),i=this.selection.getLastBlock();i=typeof i=="undefined"?r:i.tagName.toLowerCase();var s=e.inArray(r,n)!=-1,o=e.inArray(i,n)!=-1;if(s&&o||s)return!0},insertInIe:function(){this.utils.saveScroll(),this.buffer.set(),this.insert.node(document.createElement("hr")),this.utils.restoreScroll(),this.code.sync()},insertInOthersBrowsers:function(){this.buffer.set();var e='<p id="redactor-insert-line"><br /></p>';this.opts.linebreaks&&(e='<br id="redactor-insert-line">'),document.execCommand("insertHTML",!1,"<hr>"+e),this.line.setFocus(),this.code.sync()},setFocus:function(){var t=this.$editor.find("#redactor-insert-line"),n=e(t).next()[0];n?(this.caret.setAfter(t),t.remove()):t.removeAttr("id")}}},link:function(){return{show:function(t){typeof t!="undefined"&&t.preventDefault&&t.preventDefault(),this.modal.load("link",this.lang.get("link_insert"),600),this.modal.createCancelButton(),this.link.buttonInsert=this.modal.createActionButton(this.lang.get("insert")),this.selection.get(),this.link.getData(),this.link.cleanUrl(),this.link.target=="_blank"&&e("#redactor-link-blank").prop("checked",!0),this.link.$inputUrl=e("#redactor-link-url"),this.link.$inputText=e("#redactor-link-url-text"),this.link.$inputText.val(this.link.text),this.link.$inputUrl.val(this.link.url),this.link.buttonInsert.on("click",e.proxy(this.link.insert,this)),e(".redactor-link-tooltip").remove(),this.selection.save(),this.modal.show(),this.link.$inputUrl.focus()},cleanUrl:function(){var e=self.location.href.replace(/\/$/i,"");this.link.url=this.link.url.replace(e,""),this.link.url=this.link.url.replace(/^\/#/,"#"),this.link.url=this.link.url.replace("mailto:","");if(!this.opts.linkProtocol){var t=new RegExp("^(http|ftp|https)://"+self.location.host,"i");this.link.url=this.link.url.replace(t,"")}},getData:function(){this.link.$node=!1;var t=e(this.selection.getCurrent()).closest("a");t.size()!==0&&t[0].tagName==="A"?(this.link.$node=t,this.link.url=t.attr("href"),this.link.text=t.text(),this.link.target=t.attr("target")):(this.link.text=this.sel.toString(),this.link.url="",this.link.target="")},insert:function(){var t="",n=this.link.$inputUrl.val(),r=this.link.$inputText.val();if(e.trim(n)===""){this.link.$inputUrl.addClass("redactor-input-error").on("keyup",function(){e(this).removeClass("redactor-input-error"),e(this).off("keyup")});return}if(n.search("@")!=-1&&/(http|ftp|https):\/\//i.test(n)===!1)n="mailto:"+n;else if(n.search("#")!==0){e("#redactor-link-blank").prop("checked")&&(t="_blank");var i="((xn--)?[a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}",s=new RegExp("^(http|ftp|https)://"+i,"i"),o=new RegExp("^"+i,"i");n.search(s)==-1&&n.search(o)===0&&this.opts.linkProtocol&&(n=this.opts.linkProtocol+"://"+n)}this.link.set(r,n,t),this.modal.close()},set:function(t,n,r){t=e.trim(t.replace(/<|>/g,"")),this.selection.restore();if(t===""&&n==="")return;t===""&&n!==""&&(t=n);if(this.link.$node)this.buffer.set(),this.link.$node.text(t).attr("href",n),r!==""?this.link.$node.attr("target",r):this.link.$node.removeAttr("target"),this.code.sync();else{if(this.utils.browser("mozilla")&&this.link.text===""){var i=e("<a />").attr("href",n).text(t);r!==""&&i.attr("target",r),this.insert.node(i),this.selection.selectElement(i)}else{var i;this.utils.browser("msie")?(i=e('<a href="'+n+'">').text(t),r!==""&&i.attr("target",r),i=e(this.insert.node(i)),this.selection.selectElement(i)):(document.execCommand("createLink",!1,n),i=e(this.selection.getCurrent()).closest("a"),r!==""&&i.attr("target",r),i.removeAttr("style"),this.link.text===""&&(i.text(t),this.selection.selectElement(i)))}this.code.sync(),this.core.setCallback("insertedLink",i)}setTimeout(e.proxy(function(){this.observe.links()},this),5)},unlink:function(t){typeof t!="undefined"&&t.preventDefault&&t.preventDefault();var n=this.selection.getNodes();if(!n)return;this.buffer.set();var r=n.length;for(var i=0;i<r;i++)if(n[i].tagName=="A"){var s=e(n[i]);s.replaceWith(s.contents())}e(".redactor-link-tooltip").remove(),this.code.sync()}}},list:function(){return{toggle:function(t){this.utils.browser("msie")||this.$editor.focus(),this.buffer.set(),this.selection.save();var n=this.selection.getParent(),r=e(n).closest("ol, ul");!this.utils.isRedactorParent(r)&&r.size()!==0&&(r=!1);var i,s,o=!1;if(r&&r.length){o=!0;var u=r[0].tagName;i=t==="orderedlist"&&u==="UL",s=t==="unorderedlist"&&u==="OL"}i?this.utils.replaceToTag(r,"ol"):s?this.utils.replaceToTag(r,"ul"):o?this.list.remove(t):this.list.insert(t),this.selection.restore(),this.code.sync()},insert:function(t){this.utils.browser("msie")&&this.opts.linebreaks?this.list.insertInIe(t):document.execCommand("insert"+t);var n=this.selection.getParent(),r=e(n).closest("ol, ul");if(this.utils.isEmpty(r.find("li").text())){var i=r.children("li");i.find("br").remove(),i.append(this.selection.getMarkerAsHtml())}if(r.length){var s=r.parent();this.utils.isRedactorParent(s)&&s[0].tagName!="LI"&&this.utils.isBlock(s[0])&&s.replaceWith(s.contents())}this.utils.browser("msie")||this.$editor.focus(),this.clean.clearUnverified()},insertInIe:function(t){var n=this.selection.wrap("div"),r=e(n).html(),i=t=="orderedlist"?e("<ol>"):e("<ul>"),s=e("<li>");if(e.trim(r)==="")s.append(this.selection.getMarkerAsHtml()),i.append(s),this.$editor.find("#selection-marker-1").replaceWith(i);else{var o=r.split(/<br\s?\/?>/gi);if(o)for(var u=0;u<o.length;u++)e.trim(o[u])!==""&&i.append(e("<li>").html(o[u]));else s.append(r),i.append(s);e(n).replaceWith(i)}},remove:function(t){document.execCommand("insert"+t);var n=e(this.selection.getCurrent());this.indent.fixEmptyIndent(),!this.opts.linebreaks&&n.closest("li, th, td").size()===0&&(document.execCommand("formatblock",!1,"p"),this.$editor.find("ul, ol, blockquote").each(e.proxy(this.utils.removeEmpty,this)));var r=e(this.selection.getCurrent()).closest("table"),i=r.prev();!this.opts.linebreaks&&r.size()!==0&&i.size()!==0&&i[0].tagName=="BR"&&i.remove(),this.clean.clearUnverified()}}},modal:function(){return{callbacks:{},loadTemplates:function(){this.opts.modal={imageEdit:String()+'<section id="redactor-modal-image-edit">'+"<label>"+this.lang.get("title")+"</label>"+'<input type="text" id="redactor-image-title" />'+'<label class="redactor-image-link-option">'+this.lang.get("link")+"</label>"+'<input type="text" id="redactor-image-link" class="redactor-image-link-option" />'+'<label class="redactor-image-link-option"><input type="checkbox" id="redactor-image-link-blank"> '+this.lang.get("link_new_tab")+"</label>"+'<label class="redactor-image-position-option">'+this.lang.get("image_position")+"</label>"+'<select class="redactor-image-position-option" id="redactor-image-align">'+'<option value="none">'+this.lang.get("none")+"</option>"+'<option value="left">'+this.lang.get("left")+"</option>"+'<option value="center">'+this.lang.get("center")+"</option>"+'<option value="right">'+this.lang.get("right")+"</option>"+"</select>"+"</section>",image:String()+'<section id="redactor-modal-image-insert">'+'<div id="redactor-modal-image-droparea"></div>'+"</section>",file:String()+'<section id="redactor-modal-file-insert">'+'<div id="redactor-modal-file-upload-box">'+"<label>"+this.lang.get("filename")+"</label>"+'<input type="text" id="redactor-filename" /><br><br>'+'<div id="redactor-modal-file-upload"></div>'+"</div>"+"</section>",link:String()+'<section id="redactor-modal-link-insert">'+"<label>URL</label>"+'<input type="url" id="redactor-link-url" />'+"<label>"+this.lang.get("text")+"</label>"+'<input type="text" id="redactor-link-url-text" />'+'<label><input type="checkbox" id="redactor-link-blank"> '+this.lang.get("link_new_tab")+"</label>"+"</section>"},e.extend(this.opts,this.opts.modal)},addCallback:function(e,t){this.modal.callbacks[e]=t},createTabber:function(t){this.modal.$tabber=e("<div>").attr("id","redactor-modal-tabber"),t.prepend(this.modal.$tabber)},addTab:function(t,n,r){var i=e('<a href="#" rel="tab'+t+'">').text(n);r&&i.addClass("active");var s=this;i.on("click",function(t){t.preventDefault(),e(".redactor-tab").hide(),e(".redactor-"+e(this).attr("rel")).show(),s.modal.$tabber.find("a").removeClass("active"),e(this).addClass("active")}),this.modal.$tabber.append(i)},addTemplate:function(e,t){this.opts.modal[e]=t},getTemplate:function(e){return this.opts.modal[e]},getModal:function(){return this.$modalBody.find("section")},load:function(e,t,n){this.modal.templateName=e,this.modal.width=n,this.modal.build(),this.modal.enableEvents(),this.modal.setTitle(t),this.modal.setDraggable(),this.modal.setContent(),typeof this.modal.callbacks[e]!="undefined"&&this.modal.callbacks[e].call(this)},show:function(){document.activeElement.blur(),e(document.body).removeClass("body-hidden"),this.modal.bodyOveflow=e(document.body).css("overflow"),e(document.body).css("overflow","hidden"),this.utils.isMobile()?this.modal.showOnMobile():this.modal.showOnDesktop(),this.$modalOverlay.show(),this.$modalBox.show(),this.modal.setButtonsWidth(),this.utils.saveScroll(),this.utils.isMobile()||(setTimeout(e.proxy(this.modal.showOnDesktop,this),0),e(window).on("resize.redactor-modal",e.proxy(this.modal.resize,this))),this.core.setCallback("modalOpened",this.modal.templateName,this.$modal),e(document).off("focusin.modal"),this.$modal.find("input[type=text]").on("keydown.redactor-modal",e.proxy(this.modal.setEnter,this))},showOnDesktop:function(){var t=this.$modal.outerHeight(),n=e(window).height(),r=e(window).width();if(this.modal.width>r){this.$modal.css({width:"96%",marginTop:n/2-t/2+"px"});return}t>n?this.$modal.css({width:this.modal.width+"px",marginTop:"20px"}):this.$modal.css({width:this.modal.width+"px",marginTop:n/2-t/2+"px"})},showOnMobile:function(){this.$modal.css({width:"96%",marginTop:"2%"})},resize:function(){this.utils.isMobile()?this.modal.showOnMobile():this.modal.showOnDesktop()},setTitle:function(e){this.$modalHeader.html(e)},setContent:function(){this.$modalBody.html(this.modal.getTemplate(this.modal.templateName))},setDraggable:function(){if(typeof e.fn.draggable=="undefined")return;this.$modal.draggable({handle:this.$modalHeader}),this.$modalHeader.css("cursor","move")},setEnter:function(e){if(e.which!=13)return;e.preventDefault(),this.$modal.find("button.redactor-modal-action-btn").click()},createCancelButton:function(){var t=e("<button>").addClass("redactor-modal-btn redactor-modal-close-btn").html(this.lang.get("cancel"));t.on("click",e.proxy(this.modal.close,this)),this.$modalFooter.append(t)},createDeleteButton:function(e){return this.modal.createButton(e,"delete")},createActionButton:function(e){return this.modal.createButton(e,"action")},createButton:function(t,n){var r=e("<button>").addClass("redactor-modal-btn").addClass("redactor-modal-"+n+"-btn").html(t);return this.$modalFooter.append(r),r},setButtonsWidth:function(){var e=this.$modalFooter.find("button"),t=e.size();if(t===0)return;e.css("width",100/t+"%")},build:function(){this.modal.buildOverlay(),this.$modalBox=e('<div id="redactor-modal-box" />').hide(),this.$modal=e('<div id="redactor-modal" />'),this.$modalHeader=e("<header />"),this.$modalClose=e('<span id="redactor-modal-close" />').html("×"),this.$modalBody=e('<div id="redactor-modal-body" />'),this.$modalFooter=e("<footer />"),this.$modal.append(this.$modalHeader),this.$modal.append(this.$modalClose),this.$modal.append(this.$modalBody),this.$modal.append(this.$modalFooter),this.$modalBox.append(this.$modal),this.$modalBox.appendTo(document.body)},buildOverlay:function(){this.$modalOverlay=e('<div id="redactor-modal-overlay">').hide(),e("body").prepend(this.$modalOverlay)},enableEvents:function(){this.$modalClose.on("click.redactor-modal",e.proxy(this.modal.close,this)),e(document).on("keyup.redactor-modal",e.proxy(this.modal.closeHandler,this)),this.$editor.on("keyup.redactor-modal",e.proxy(this.modal.closeHandler,this)),this.$modalBox.on("click.redactor-modal",e.proxy(this.modal.close,this))},disableEvents:function(){this.$modalClose.off("click.redactor-modal"),e(document).off("keyup.redactor-modal"),this.$editor.off("keyup.redactor-modal"),this.$modalBox.off("click.redactor-modal"),e(window).off("resize.redactor-modal")},closeHandler:function(e){if(e.which!=this.keyCode.ESC)return;this.modal.close(!1)},close:function(t){if(t){if(!e(t.target).hasClass("redactor-modal-close-btn")&&t.target!=this.$modalClose[0]&&t.target!=this.$modalBox[0])return;t.preventDefault()}if(!this.$modalBox)return;this.modal.disableEvents(),this.$modalOverlay.remove(),this.$modalBox.fadeOut("fast",e.proxy(function(){this.$modalBox.remove(),setTimeout(e.proxy(this.utils.restoreScroll,this),0),t!==undefined&&this.selection.restore(),e(document.body).css("overflow",this.modal.bodyOveflow),this.core.setCallback("modalClosed",this.modal.templateName)},this))}}},observe:function(){return{load:function(){this.observe.images(),this.observe.links()},buttons:function(t,n){var r=this.selection.getCurrent(),i=this.selection.getParent();this.button.setInactiveAll(n);if(t===!1&&n!=="html"){e.inArray(n,this.opts.activeButtons)!=-1&&this.button.toggleActive(n);return}e.each(this.opts.activeButtonsStates,e.proxy(function(t,n){var s=e(i).closest(t),o=e(r).closest(t);if(s.length!==0&&!this.utils.isRedactorParent(s))return;if(!this.utils.isRedactorParent(o))return;(s.length!==0||o.closest(t).length!==0)&&this.button.setActive(n)},this));var s=e(i).closest(this.opts.alignmentTags.toString().toLowerCase());if(this.utils.isRedactorParent(i)&&s.length){var o=s.css("text-align")===""?"left":s.css("text-align");this.button.setActive("align"+o)}},addButton:function(e,t){this.opts.activeButtons.push(t),this.opts.activeButtonsStates[e]=t},images:function(){this.$editor.find("img").each(e.proxy(function(t,n){var r=e(n);r.closest("a").on("click",function(e){e.preventDefault()}),this.utils.browser("msie")&&r.attr("unselectable","on"),this.image.setEditable(r)},this)),e(document).on("click.redactor-image-delete",e.proxy(function(e){this.observe.image=!1,e.target.tagName=="IMG"&&this.utils.isRedactorParent(e.target)&&(this.observe.image=this.observe.image&&this.observe.image==e.target?!1:e.target)},this))},links:function(){if(!this.opts.linkTooltip)return;this.$editor.find("a").on("touchstart click",e.proxy(this.observe.showTooltip,this)),this.$editor.on("touchstart click.redactor",e.proxy(this.observe.closeTooltip,this)),e(document).on("touchstart click.redactor",e.proxy(this.observe.closeTooltip,this))},getTooltipPosition:function(e){return e.offset()},showTooltip:function(t){var n=e(t.target),r=n.closest("a");if(r.size()!==0&&r[0].tagName==="A"&&n[0].tagName!=="A")n=r;else if(n.size()===0||n[0].tagName!=="A")return;var i=this.observe.getTooltipPosition(n),s=e('<span class="redactor-link-tooltip"></span>'),o=n.attr("href");o===undefined&&(o=""),o.length>24&&(o=o.substring(0,24)+"...");var u=e('<a href="'+n.attr("href")+'" target="_blank" />').html(o).addClass("redactor-link-tooltip-action"),a=e('<a href="#" />').html(this.lang.get("edit")).on("click",e.proxy(this.link.show,this)).addClass("redactor-link-tooltip-action"),f=e('<a href="#" />').html(this.lang.get("unlink")).on("click",e.proxy(this.link.unlink,this)).addClass("redactor-link-tooltip-action");s.append(u).append(" | ").append(a).append(" | ").append(f),s.css({top:i.top+20+"px",left:i.left+"px"}),e(".redactor-link-tooltip").remove(),e("body").append(s)},closeTooltip:function(t){t=t.originalEvent||t;var n=t.target,r=e(n).closest("a");if(r.size()!==0&&r[0].tagName==="A"&&n.tagName!=="A")return;if(n.tagName==="A"&&this.utils.isRedactorParent(n)||e(n).hasClass("redactor-link-tooltip-action"))return;e(".redactor-link-tooltip").remove()}}},paragraphize:function(){return{load:function(t){return this.opts.linebreaks?t:t===""||t==="<p></p>"?this.opts.emptyHtml:(this.paragraphize.blocks=["table","div","pre","form","ul","ol","h1","h2","h3","h4","h5","h6","dl","blockquote","figcaption","address","section","header","footer","aside","article","object","style","script","iframe","select","input","textarea","button","option","map","area","math","hr","fieldset","legend","hgroup","nav","figure","details","menu","summary","p"],t+="\n",this.paragraphize.safes=[],this.paragraphize.z=0,t=t.replace(/(<br\s?\/?>){1,}\n?<\/blockquote>/gi,"</blockquote>"),t=this.paragraphize.getSafes(t),t=this.paragraphize.getSafesComments(t),t=this.paragraphize.replaceBreaksToNewLines(t),t=this.paragraphize.replaceBreaksToParagraphs(t),t=this.paragraphize.clear(t),t=this.paragraphize.restoreSafes(t),t=t.replace(new RegExp("<br\\s?/?>\n?<("+this.paragraphize.blocks.join("|")+")(.*?[^>])>","gi"),"<p><br /></p>\n<$1$2>"),e.trim(t))},getSafes:function(t){var n=e("<div />").append(t);return n.find("blockquote p").replaceWith(function(){return e(this).append("<br />").contents()}),t=n.html(),n.find(this.paragraphize.blocks.join(", ")).each(e.proxy(function(e,n){this.paragraphize.z++,this.paragraphize.safes[this.paragraphize.z]=n.outerHTML,t=t.replace(n.outerHTML,"\n{replace"+this.paragraphize.z+"}")},this)),t},getSafesComments:function(t){var n=t.match(/<!--([\w\W]*?)-->/gi);return n?(e.each(n,e.proxy(function(e,n){this.paragraphize.z++,this.paragraphize.safes[this.paragraphize.z]=n,t=t.replace(n,"\n{replace"+this.paragraphize.z+"}")},this)),t):t},restoreSafes:function(t){return e.each(this.paragraphize.safes,function(e,n){t=t.replace("{replace"+e+"}",n)}),t},replaceBreaksToParagraphs:function(e){var t=e.split(new RegExp("\n","g"),-1);e="";if(t){var n=t.length;for(var r=0;r<n;r++){if(!t.hasOwnProperty(r))return;t[r].search("{replace")==-1?(t[r]=t[r].replace(/<p>\n\t?<\/p>/gi,""),t[r]=t[r].replace(/<p><\/p>/gi,""),t[r]!==""&&(e+="<p>"+t[r].replace(/^\n+|\n+$/g,"")+"</p>")):e+=t[r]}}return e},replaceBreaksToNewLines:function(e){return e=e.replace(/<br \/>\s*<br \/>/gi,"\n\n"),e=e.replace(/<br\s?\/?>\n?<br\s?\/?>/gi,"\n<br /><br />"),e=e.replace(new RegExp("\r\n","g"),"\n"),e=e.replace(new RegExp("\r","g"),"\n"),e=e.replace(new RegExp("/\n\n+/"),"g","\n\n"),e},clear:function(e){return e=e.replace(new RegExp("</blockquote></p>","gi"),"</blockquote>"),e=e.replace(new RegExp("<p></blockquote>","gi"),"</blockquote>"),e=e.replace(new RegExp("<p><blockquote>","gi"),"<blockquote>"),e=e.replace(new RegExp("<blockquote></p>","gi"),"<blockquote>"),e=e.replace(new RegExp("<p><p ","gi"),"<p "),e=e.replace(new RegExp("<p><p>","gi"),"<p>"),e=e.replace(new RegExp("</p></p>","gi"),"</p>"),e=e.replace(new RegExp("<p>\\s?</p>","gi"),""),e=e.replace(new RegExp("\n</p>","gi"),"</p>"),e=e.replace(new RegExp("<p> ? ?\n?<p>","gi"),"<p>"),e=e.replace(new RegExp("<p> *</p>","gi"),""),e}}},paste:function(){return{init:function(t){if(!this.opts.cleanOnPaste)return;this.rtePaste=!0,this.buffer.set(),this.selection.save(),this.utils.saveScroll(),this.paste.createPasteBox(),e(window).on("scroll.redactor-freeze",e.proxy(function(){e(window).scrollTop(this.saveBodyScroll)},this)),setTimeout(e.proxy(function(){var t=this.$pasteBox.html();this.$pasteBox.remove(),this.selection.restore(),this.utils.restoreScroll(),this.paste.insert(t),e(window).off("scroll.redactor-freeze")},this),1)},createPasteBox:function(){this.$pasteBox=e("<div>").html(" ").attr("contenteditable","true").css({position:"fixed",width:0,top:0 +,left:"-9999px"}),this.$box.parent().append(this.$pasteBox),this.$pasteBox.focus()},insert:function(t){t=this.core.setCallback("pasteBefore",t),t=this.utils.isSelectAll()?this.clean.onPaste(t,!1):this.clean.onPaste(t),t=this.core.setCallback("paste",t),this.utils.isSelectAll()?this.insert.set(t,!1):this.insert.html(t,!1),this.utils.disableSelectAll(),this.rtePaste=!1,setTimeout(e.proxy(this.clean.clearUnverified,this),10)}}},placeholder:function(){return{enable:function(){if(!this.placeholder.is())return;this.$editor.attr("placeholder",this.$element.attr("placeholder")),this.placeholder.toggle(),this.$editor.on("keyup.redactor-placeholder",e.proxy(this.placeholder.toggle,this))},toggle:function(){var e="removeClass";this.utils.isEmpty(this.$editor.html(),!1)&&(e="addClass"),this.$editor[e]("redactor-placeholder")},remove:function(){this.$editor.removeClass("redactor-placeholder")},is:function(){return this.opts.placeholder?this.$element.attr("placeholder",this.opts.placeholder):typeof this.$element.attr("placeholder")!="undefined"&&this.$element.attr("placeholder")!==""}}},progress:function(){return{show:function(){e(document.body).append(e('<div id="redactor-progress"><span></span></div>')),e("#redactor-progress").fadeIn()},hide:function(){e("#redactor-progress").fadeOut(1500,function(){e(this).remove()})}}},selection:function(){return{get:function(){this.sel=document.getSelection(),document.getSelection&&this.sel.getRangeAt&&this.sel.rangeCount?this.range=this.sel.getRangeAt(0):this.range=document.createRange()},addRange:function(){try{this.sel.removeAllRanges()}catch(e){}this.sel.addRange(this.range)},getCurrent:function(){var e=!1;return this.selection.get(),this.sel&&this.sel.rangeCount>0&&(e=this.sel.getRangeAt(0).startContainer),this.utils.isRedactorParent(e)},getParent:function(t){return t=t||this.selection.getCurrent(),t?this.utils.isRedactorParent(e(t).parent()[0]):!1},getBlock:function(t){t=t||this.selection.getCurrent();while(t){if(this.utils.isBlockTag(t.tagName))return e(t).hasClass("redactor-editor")?!1:t;t=t.parentNode}return!1},getInlines:function(t){this.selection.get();if(this.range&&this.range.collapsed)return!1;var n=[];t=typeof t=="undefined"?this.selection.getNodes():t;var r=this.opts.inlineTags;return r.push("span"),e.each(t,e.proxy(function(t,i){e.inArray(i.tagName.toLowerCase(),r)!=-1&&n.push(i)},this)),n.length===0?!1:n},getBlocks:function(t){this.selection.get();if(this.range&&this.range.collapsed)return[this.selection.getBlock()];var n=[];return t=typeof t=="undefined"?this.selection.getNodes():t,e.each(t,e.proxy(function(e,t){this.utils.isBlock(t)&&(this.selection.lastBlock=t,n.push(t))},this)),n.length===0?[this.selection.getBlock()]:n},getLastBlock:function(){return this.selection.lastBlock},getNodes:function(){this.selection.get();var t=this.selection.getNodesMarker(1),n=this.selection.getNodesMarker(2);this.selection.setNodesMarker(this.range,t,!0),this.range.collapsed===!1?this.selection.setNodesMarker(this.range,n,!1):n=t;var r=[],i=0,s=this;this.$editor.find("*").each(function(){if(this==t){var o=e(this).parent();o.length!==0&&o[0].tagName!="BODY"&&s.utils.isRedactorParent(o[0])&&r.push(o[0]),r.push(this),i=1}else i>0&&(r.push(this),i+=1);if(this==n)return!1});var o=[],u=r.length;for(var a=0;a<u;a++)r[a].id!="nodes-marker-1"&&r[a].id!="nodes-marker-2"&&o.push(r[a]);return this.selection.removeNodesMarkers(),o},getNodesMarker:function(t){return e('<span id="nodes-marker-'+t+'" class="redactor-nodes-marker" data-verified="redactor">'+this.opts.invisibleSpace+"</span>")[0]},setNodesMarker:function(e,t,n){e=e.cloneRange();try{e.collapse(n),e.insertNode(t)}catch(r){}},removeNodesMarkers:function(){e(document).find("span.redactor-nodes-marker").remove(),this.$editor.find("span.redactor-nodes-marker").remove()},fromPoint:function(e,t){this.caret.setOffset(e,t)},wrap:function(e){this.selection.get();if(this.range.collapsed)return!1;var t=document.createElement(e);return t.appendChild(this.range.extractContents()),this.range.insertNode(t),t},selectElement:function(e){this.caret.set(e,0,e,1)},selectAll:function(){this.selection.get(),this.range.selectNodeContents(this.$editor[0]),this.selection.addRange()},remove:function(){this.selection.get(),this.sel.removeAllRanges()},save:function(){this.selection.createMarkers()},createMarkers:function(){this.selection.get();var e=this.selection.getMarker(1);this.selection.setMarker(this.range,e,!0);if(this.range.collapsed===!1){var t=this.selection.getMarker(2);this.selection.setMarker(this.range,t,!1)}this.savedSel=this.$editor.html()},getMarker:function(t){return typeof t=="undefined"&&(t=1),e('<span id="selection-marker-'+t+'" class="redactor-selection-marker" data-verified="redactor">'+this.opts.invisibleSpace+"</span>")[0]},getMarkerAsHtml:function(e){return this.utils.getOuterHtml(this.selection.getMarker(e))},setMarker:function(e,t,n){e=e.cloneRange();try{e.collapse(n),e.insertNode(t)}catch(r){this.focus.setStart()}},restore:function(){var e=this.$editor.find("span#selection-marker-1"),t=this.$editor.find("span#selection-marker-2");e.length!==0&&t.length!==0?this.caret.set(e,0,t,0):e.length!==0?this.caret.set(e,0,e,0):this.$editor.focus(),this.selection.removeMarkers(),this.savedSel=!1},removeMarkers:function(){this.$editor.find("span.redactor-selection-marker").remove()},getText:function(){return this.selection.get(),this.sel.toString()},getHtml:function(){var e="";this.selection.get();if(this.sel.rangeCount){var t=document.createElement("div"),n=this.sel.rangeCount;for(var r=0;r<n;++r)t.appendChild(this.sel.getRangeAt(r).cloneContents());e=t.innerHTML}return this.clean.onSync(e)}}},shortcuts:function(){return{init:function(t,n){if(!this.opts.shortcuts)return(t.ctrlKey||t.metaKey)&&(n===66||n===73)&&t.preventDefault(),!1;e.each(this.opts.shortcuts,e.proxy(function(n,r){var i=n.split(","),s=i.length;for(var o=0;o<s;o++)typeof i[o]=="string"&&this.shortcuts.handler(t,e.trim(i[o]),e.proxy(function(){var e;r.func.search(/\./)!="-1"?(e=r.func.split("."),typeof this[e[0]]!="undefined"&&this[e[0]][e[1]].apply(this,r.params)):this[r.func].apply(this,r.params)},this))},this))},handler:function(t,n,r){var i={8:"backspace",9:"tab",10:"return",13:"return",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",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},s={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"};n=n.toLowerCase().split(" ");var o=i[t.keyCode],u=String.fromCharCode(t.which).toLowerCase(),a="",f={};e.each(["alt","ctrl","meta","shift"],function(e,n){t[n+"Key"]&&o!==n&&(a+=n+"+")}),o&&(f[a+o]=!0),u&&(f[a+u]=!0,f[a+s[u]]=!0,a==="shift+"&&(f[s[u]]=!0));for(var l=0,c=n.length;l<c;l++)if(f[n[l]])return t.preventDefault(),r.apply(this,arguments)}}},tabifier:function(){return{get:function(e){if(!this.opts.tabifier)return e;var t=["area","body","head","hr","i?frame","link","meta","noscript","style","script","table","tbody","thead","tfoot"],n=["li","dt","dt","h[1-6]","option","script"],r=["blockquote","div","dl","fieldset","form","frameset","map","ol","p","pre","select","td","th","tr","ul"];this.tabifier.lineBefore=new RegExp("^<(/?"+t.join("|/?")+"|"+n.join("|")+")[ >]"),this.tabifier.lineAfter=new RegExp("^<(br|/?"+t.join("|/?")+"|/"+n.join("|/")+")[ >]"),this.tabifier.newLevel=new RegExp("^</?("+r.join("|")+")[ >]");var i=0,s=e.length,o=0,u=null,a=null,f="",l="",c="";this.tabifier.cleanlevel=0;for(;i<s;i++){o=i;if(-1==e.substr(i).indexOf("<"))return l+=e.substr(i),this.tabifier.finish(l);while(o<s&&e.charAt(o)!="<")o++;i!=o&&(c=e.substr(i,o-i),c.match(/^\s{2,}$/g)||("\n"==l.charAt(l.length-1)?l+=this.tabifier.getTabs():"\n"==c.charAt(0)&&(l+="\n"+this.tabifier.getTabs(),c=c.replace(/^\s+/,"")),l+=c),c.match(/\n/)&&(l+="\n"+this.tabifier.getTabs())),u=o;while(o<s&&">"!=e.charAt(o))o++;f=e.substr(u,o-u),i=o;var h;if("!--"==f.substr(1,3)){if(!f.match(/--$/)){while("-->"!=e.substr(o,3))o++;o+=2,f=e.substr(u,o-u),i=o}"\n"!=l.charAt(l.length-1)&&(l+="\n"),l+=this.tabifier.getTabs(),l+=f+">\n"}else"!"==f[1]?l=this.tabifier.placeTag(f+">",l):"?"==f[1]?l+=f+">\n":(h=f.match(/^<(script|style|pre)/i))?(h[1]=h[1].toLowerCase(),f=this.tabifier.cleanTag(f),l=this.tabifier.placeTag(f,l),a=String(e.substr(i+1)).toLowerCase().indexOf("</"+h[1]),a&&(c=e.substr(i+1,a),i+=a,l+=c)):(f=this.tabifier.cleanTag(f),l=this.tabifier.placeTag(f,l))}return this.tabifier.finish(l)},getTabs:function(){var e="";for(var t=0;t<this.tabifier.cleanlevel;t++)e+=" ";return e},finish:function(e){return e=e.replace(/\n\s*\n/g,"\n"),e=e.replace(/^[\s\n]*/,""),e=e.replace(/[\s\n]*$/,""),e=e.replace(/<script(.*?)>\n<\/script>/gi,"<script$1></script>"),this.tabifier.cleanlevel=0,e},cleanTag:function(e){var t="";e=e.replace(/\n/g," "),e=e.replace(/\s{2,}/g," "),e=e.replace(/^\s+|\s+$/g," ");var n="";e.match(/\/$/)&&(n="/",e=e.replace(/\/+$/,""));var r;while(r=/\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/.exec(e))r[2]?t+=r[1].toLowerCase()+"="+r[2]:r[1]&&(t+=r[1].toLowerCase()),t+=" ",e=e.substr(r[0].length);return t.replace(/\s*$/,"")+n+">"},placeTag:function(e,t){var n=e.match(this.tabifier.newLevel);if(e.match(this.tabifier.lineBefore)||n)t=t.replace(/\s*$/,""),t+="\n";n&&"/"==e.charAt(1)&&this.tabifier.cleanlevel--,"\n"==t.charAt(t.length-1)&&(t+=this.tabifier.getTabs()),n&&"/"!=e.charAt(1)&&this.tabifier.cleanlevel++,t+=e;if(e.match(this.tabifier.lineAfter)||e.match(this.tabifier.newLevel))t=t.replace(/ *$/,""),t+="\n";return t}}},tidy:function(){return{setupAllowed:function(){this.opts.allowedTags&&(this.opts.deniedTags=!1),this.opts.allowedAttr&&(this.opts.removeAttr=!1);if(this.opts.linebreaks)return;var e=["p","section"];this.opts.allowedTags&&this.tidy.addToAllowed(e),this.opts.deniedTags&&this.tidy.removeFromDenied(e)},addToAllowed:function(t){var n=t.length;for(var r=0;r<n;r++)e.inArray(t[r],this.opts.allowedTags)==-1&&this.opts.allowedTags.push(t[r])},removeFromDenied:function(t){var n=t.length;for(var r=0;r<n;r++){var i=e.inArray(t[r],this.opts.deniedTags);i!=-1&&this.opts.deniedTags.splice(i,1)}},load:function(t,n){return this.tidy.settings={deniedTags:this.opts.deniedTags,allowedTags:this.opts.allowedTags,removeComments:this.opts.removeComments,replaceTags:this.opts.replaceTags,replaceStyles:this.opts.replaceStyles,removeDataAttr:this.opts.removeDataAttr,removeAttr:this.opts.removeAttr,allowedAttr:this.opts.allowedAttr,removeWithoutAttr:this.opts.removeWithoutAttr,removeEmpty:this.opts.removeEmpty},e.extend(this.tidy.settings,n),t=this.tidy.removeComments(t),this.tidy.$div=e("<div />").append(t),this.tidy.replaceTags(),this.tidy.replaceStyles(),this.tidy.removeTags(),this.tidy.removeAttr(),this.tidy.removeEmpty(),this.tidy.removeParagraphsInLists(),this.tidy.removeDataAttr(),this.tidy.removeWithoutAttr(),t=this.tidy.$div.html(),this.tidy.$div.remove(),t},removeComments:function(e){return this.tidy.settings.removeComments?e.replace(/<!--[\s\S]*?-->/gi,""):e},replaceTags:function(t){if(!this.tidy.settings.replaceTags)return t;var n=this.tidy.settings.replaceTags.length,r=[],i=[];for(var s=0;s<n;s++)i.push(this.tidy.settings.replaceTags[s][1]),r.push(this.tidy.settings.replaceTags[s][0]);return this.tidy.$div.find(r.join(",")).each(e.proxy(function(t,n){var r=i[t];e(n).replaceWith(function(){var t=e("<"+r+" />").append(e(this).contents());for(var n=0;n<this.attributes.length;n++)t.attr(this.attributes[n].name,this.attributes[n].value);return t})},this)),t},replaceStyles:function(){if(!this.tidy.settings.replaceStyles)return;var t=this.tidy.settings.replaceStyles.length;this.tidy.$div.find("span").each(e.proxy(function(n,r){var i=e(r),s=i.attr("style");for(var o=0;o<t;o++)if(s&&s.match(new RegExp("^"+this.tidy.settings.replaceStyles[o][0],"i"))){var u=this.tidy.settings.replaceStyles[o][1];i.replaceWith(function(){var t=document.createElement(u);return e(t).append(e(this).contents())})}},this))},removeTags:function(){!this.tidy.settings.deniedTags&&this.tidy.settings.allowedTags&&this.tidy.$div.find("*").not(this.tidy.settings.allowedTags.join(",")).each(function(t,n){n.innerHTML===""?e(n).remove():e(n).contents().unwrap()}),this.tidy.settings.deniedTags&&this.tidy.$div.find(this.tidy.settings.deniedTags.join(",")).each(function(t,n){n.innerHTML===""?e(n).remove():e(n).contents().unwrap()})},removeAttr:function(){var t;if(!this.tidy.settings.removeAttr&&this.tidy.settings.allowedAttr){var n=[],r=[];t=this.tidy.settings.allowedAttr.length;for(var i=0;i<t;i++)n.push(this.tidy.settings.allowedAttr[i][0]),r.push(this.tidy.settings.allowedAttr[i][1]);this.tidy.$div.find("*").each(e.proxy(function(t,i){var s=e(i),o=e.inArray(s[0].tagName.toLowerCase(),n),u=this.tidy.removeAttrGetRemoves(o,r,s);u&&e.each(u,function(e,t){s.removeAttr(t)})},this))}if(this.tidy.settings.removeAttr){t=this.tidy.settings.removeAttr.length;for(var i=0;i<t;i++){var s=this.tidy.settings.removeAttr[i][1];e.isArray(s)&&(s=s.join(" ")),this.tidy.$div.find(this.tidy.settings.removeAttr[i][0]).removeAttr(s)}}},removeAttrGetRemoves:function(t,n,r){var i=[];return t==-1?e.each(r[0].attributes,function(e,t){i.push(t.name)}):n[t]=="*"?i=[]:e.each(r[0].attributes,function(r,s){e.isArray(n[t])?e.inArray(s.name,n[t])==-1&&i.push(s.name):n[t]!=s.name&&i.push(s.name)}),i},removeAttrs:function(t,n){return n=new RegExp(n,"g"),t.each(function(){var t=e(this),r=this.attributes.length-1;for(var i=r;i>=0;i--){var s=this.attributes[i];s&&s.specified&&s.name.search(n)>=0&&t.removeAttr(s.name)}})},removeEmpty:function(){if(!this.tidy.settings.removeEmpty)return;this.tidy.$div.find(this.tidy.settings.removeEmpty.join(",")).each(function(){var t=e(this),n=t.text();n=n.replace(/[\u200B-\u200D\uFEFF]/g,""),n=n.replace(/ /gi,""),n=n.replace(/\s/g,""),n===""&&t.children().length===0&&t.remove()})},removeParagraphsInLists:function(){this.tidy.$div.find("li p").contents().unwrap()},removeDataAttr:function(){if(!this.tidy.settings.removeDataAttr)return;var t=this.tidy.settings.removeDataAttr;e.isArray(this.tidy.settings.removeDataAttr)&&(t=this.tidy.settings.removeDataAttr.join(",")),this.tidy.removeAttrs(this.tidy.$div.find(t),"^(data-)")},removeWithoutAttr:function(){if(!this.tidy.settings.removeWithoutAttr)return;this.tidy.$div.find(this.tidy.settings.removeWithoutAttr.join(",")).each(function(){this.attributes.length===0&&e(this).contents().unwrap()})}}},toolbar:function(){return{init:function(){return{html:{title:this.lang.get("html"),func:"code.toggle"},formatting:{title:this.lang.get("formatting"),dropdown:{p:{title:this.lang.get("paragraph"),func:"block.format"},blockquote:{title:this.lang.get("quote"),func:"block.format"},pre:{title:this.lang.get("code"),func:"block.format"},h1:{title:this.lang.get("header1"),func:"block.format"},h2:{title:this.lang.get("header2"),func:"block.format"},h3:{title:this.lang.get("header3"),func:"block.format"},h4:{title:this.lang.get("header4"),func:"block.format"},h5:{title:this.lang.get("header5"),func:"block.format"}}},bold:{title:this.lang.get("bold"),func:"inline.format"},italic:{title:this.lang.get("italic"),func:"inline.format"},deleted:{title:this.lang.get("deleted"),func:"inline.format"},underline:{title:this.lang.get("underline"),func:"inline.format"},unorderedlist:{title:"• "+this.lang.get("unorderedlist"),func:"list.toggle"},orderedlist:{title:"1. "+this.lang.get("orderedlist"),func:"list.toggle"},outdent:{title:"< "+this.lang.get("outdent"),func:"indent.decrease"},indent:{title:"> "+this.lang.get("indent"),func:"indent.increase"},image:{title:this.lang.get("image"),func:"image.show"},file:{title:this.lang.get("file"),func:"file.show"},link:{title:this.lang.get("link"),dropdown:{link:{title:this.lang.get("link_insert"),func:"link.show"},unlink:{title:this.lang.get("unlink"),func:"link.unlink"}}},alignment:{title:this.lang.get("alignment"),dropdown:{left:{title:this.lang.get("align_left"),func:"alignment.left"},center:{title:this.lang.get("align_center"),func:"alignment.center"},right:{title:this.lang.get("align_right"),func:"alignment.right"},justify:{title:this.lang.get("align_justify"),func:"alignment.justify"}}},horizontalrule:{title:this.lang.get("horizontalrule"),func:"line.insert"}}},build:function(){this.toolbar.hideButtons(),this.toolbar.hideButtonsOnMobile(),this.toolbar.isButtonSourceNeeded();if(this.opts.buttons.length===0)return;this.$toolbar=this.toolbar.createContainer(),this.toolbar.setOverflow(),this.toolbar.append(),this.toolbar.setFormattingTags(),this.toolbar.loadButtons(),this.toolbar.setFixed(),this.opts.activeButtons&&this.$editor.on("mouseup.redactor keyup.redactor focus.redactor",e.proxy(this.observe.buttons,this))},createContainer:function(){return e("<ul>").addClass("redactor-toolbar").attr("id","redactor-toolbar-"+this.uuid)},setFormattingTags:function(){e.each(this.opts.toolbar.formatting.dropdown,e.proxy(function(t,n){e.inArray(t,this.opts.formatting)==-1&&delete this.opts.toolbar.formatting.dropdown[t]},this))},loadButtons:function(){e.each(this.opts.buttons,e.proxy(function(t,n){if(!this.opts.toolbar[n])return;if(this.opts.fileUpload===!1&&n==="file")return!0;if(this.opts.imageUpload===!1&&this.opts.s3===!1&&n==="image")return!0;var r=this.opts.toolbar[n];this.$toolbar.append(e("<li>").append(this.button.build(n,r)))},this))},append:function(){this.opts.toolbarExternal?(this.$toolbar.addClass("redactor-toolbar-external"),e(this.opts.toolbarExternal).html(this.$toolbar)):this.$box.prepend(this.$toolbar)},setFixed:function(){if(this.utils.isMobile())return;if(this.opts.toolbarExternal)return;if(!this.opts.toolbarFixed)return;this.toolbar.observeScroll(),e(this.opts.toolbarFixedTarget).on("scroll.redactor",e.proxy(this.toolbar.observeScroll,this))},setOverflow:function(){this.utils.isMobile()&&this.opts.toolbarOverflow&&this.$toolbar.addClass("redactor-toolbar-overflow")},isButtonSourceNeeded:function(){if(this.opts.buttonSource)return;var e=this.opts.buttons.indexOf("html");e!==-1&&this.opts.buttons.splice(e,1)},hideButtons:function(){if(this.opts.buttonsHide.length===0)return;e.each(this.opts.buttonsHide,e.proxy(function(e,t){var n=this.opts.buttons.indexOf(t);this.opts.buttons.splice(n,1)},this))},hideButtonsOnMobile:function(){if(!this.utils.isMobile()||this.opts.buttonsHideOnMobile.length===0)return;e.each(this.opts.buttonsHideOnMobile,e.proxy(function(e,t){var n=this.opts.buttons.indexOf(t);this.opts.buttons.splice(n,1)},this))},observeScroll:function(){var t=e(this.opts.toolbarFixedTarget).scrollTop(),n=1;this.opts.toolbarFixedTarget===document&&(n=this.$box.offset().top),t>n?this.toolbar.observeScrollEnable(t,n):this.toolbar.observeScrollDisable()},observeScrollEnable:function(e,t){var n=this.opts.toolbarFixedTopOffset+e-t,r=0,i=t+this.$box.height()+30,s=this.$box.innerWidth();this.$toolbar.addClass("toolbar-fixed-box"),this.$toolbar.css({position:"absolute",width:s,top:n+"px",left:r}),this.toolbar.setDropdownsFixed(),this.$toolbar.css("visibility",e<i?"visible":"hidden")},observeScrollDisable:function(){this.$toolbar.css({position:"relative",width:"auto",top:0,left:0,visibility:"visible"}),this.toolbar.unsetDropdownsFixed(),this.$toolbar.removeClass("toolbar-fixed-box")},setDropdownsFixed:function(){var t=this.$toolbar.innerHeight()+this.opts.toolbarFixedTopOffset,n="fixed";this.opts.toolbarFixedTarget!==document&&(t=this.$toolbar.innerHeight()+this.$toolbar.offset().top+this.opts.toolbarFixedTopOffset,n="absolute"),e(".redactor-dropdown").each(function(){e(this).css({position:n,top:t+"px"})})},unsetDropdownsFixed:function(){var t=this.$toolbar.innerHeight()+this.$toolbar.offset().top;e(".redactor-dropdown").each(function(){e(this).css({position:"absolute",top:t+"px"})})}}},upload:function(){return{init:function(t,n,r){this.upload.direct=!1,this.upload.callback=r,this.upload.url=n,this.upload.$el=e(t),this.upload.$droparea=e('<div id="redactor-droparea" />'),this.upload.$placeholdler=e('<div id="redactor-droparea-placeholder" />').text("Drop file here or "),this.upload.$input=e('<input type="file" name="file" />'),this.upload.$placeholdler.append(this.upload.$input),this.upload.$droparea.append(this.upload.$placeholdler),this.upload.$el.append(this.upload.$droparea),this.upload.$droparea.off("redactor.upload"),this.upload.$input.off("redactor.upload"),this.upload.$droparea.on("dragover.redactor.upload",e.proxy(this.upload.onDrag,this)),this.upload.$droparea.on("dragleave.redactor.upload",e.proxy(this.upload.onDragLeave,this)),this.upload.$input.on("change.redactor.upload",e.proxy(function(e){e=e.originalEvent||e,this.upload.traverseFile(this.upload.$input[0].files[0],e)},this)),this.upload.$droparea.on("drop.redactor.upload",e.proxy(function(e){e.preventDefault(),this.upload.$droparea.removeClass("drag-hover").addClass("drag-drop"),this.upload.onDrop(e)},this))},directUpload:function(e,t){this.upload.direct=!0,this.upload.traverseFile(e,t)},onDrop:function(e){e=e.originalEvent||e;var t=e.dataTransfer.files;this.upload.traverseFile(t[0],e)},traverseFile:function(e,t){if(this.opts.s3){this.upload.setConfig(e),this.upload.s3uploadFile(e);return}var n=window.FormData?new FormData:null;if(window.FormData){this.upload.setConfig(e);var r=this.upload.type=="image"?this.opts.imageUploadParam:this.opts.fileUploadParam;n.append(r,e)}this.progress.show(),this.upload.sendData(n,t)},setConfig:function(e){this.upload.getType(e),this.upload.direct&&(this.upload.url=this.upload.type=="image"?this.opts.imageUpload:this.opts.fileUpload,this.upload.callback=this.upload.type=="image"?this.image.insert:this.file.insert)},getType:function(e){this.upload.type="image",this.opts.imageTypes.indexOf(e.type)==-1&&(this.upload.type="file")},getHiddenFields:function(t,n){return t===!1||typeof t!="object"?n:(e.each(t,e.proxy(function(t,r){r!==null&&r.toString().indexOf("#")===0&&(r=e(r).val()),n.append(t,r)},this)),n)},sendData:function(t,n){this.upload.type=="image"?(t=this.upload.getHiddenFields(this.opts.uploadImageFields,t),t=this.upload.getHiddenFields(this.upload.imageFields,t)):(t=this.upload.getHiddenFields(this.opts.uploadFileFields,t),t=this.upload.getHiddenFields(this.upload.fileFields,t));var r=new XMLHttpRequest;r.open("POST",this.upload.url),r.onreadystatechange=e.proxy(function(){if(r.readyState==4){var t=r.responseText;t=t.replace(/^\[/,""),t=t.replace(/\]$/,"");var i;try{i=typeof t=="string"?e.parseJSON(t):t}catch(s){i={error:!0}}this.progress.hide(),this.upload.direct||this.upload.$droparea.removeClass("drag-drop"),this.upload.callback(i,this.upload.direct,n)}},this),r.send(t)},onDrag:function(e){e.preventDefault(),this.upload.$droparea.addClass("drag-hover")},onDragLeave:function(e){e.preventDefault(),this.upload.$droparea.removeClass("drag-hover")},clearImageFields:function(){this.upload.imageFields={}},addImageFields:function(e,t){this.upload.imageFields[e]=t},removeImageFields:function(e){delete this.upload.imageFields[e]},clearFileFields:function(){this.upload.fileFields={}},addFileFields:function(e,t){this.upload.fileFields[e]=t},removeFileFields:function(e){delete this.upload.fileFields[e]},s3uploadFile:function(t){this.upload.s3executeOnSignedUrl(t,e.proxy(function(e){this.upload.s3uploadToS3(t,e)},this))},s3executeOnSignedUrl:function(e,t){var n=new XMLHttpRequest,r="?";this.opts.s3.search(/\?/)!="-1"&&(r="&"),n.open("GET",this.opts.s3+r+"name="+e.name+"&type="+e.type,!0),n.overrideMimeType&&n.overrideMimeType("text/plain; charset=x-user-defined");var i=this;n.onreadystatechange=function(e){this.readyState==4&&this.status==200?(i.progress.show(),t(decodeURIComponent(this.responseText))):this.readyState==4&&this.status!=200},n.send()},s3createCORSRequest:function(e,t){var n=new XMLHttpRequest;return"withCredentials"in n?n.open(e,t,!0):typeof XDomainRequest!="undefined"?(n=new XDomainRequest,n.open(e,t)):n=null,n},s3uploadToS3:function(t,n){var r=this.upload.s3createCORSRequest("PUT",n);!r||(r.onload=e.proxy(function(){if(r.status==200){this.progress.hide();var e=n.split("?");if(!e[0])return!1;this.upload.direct||this.upload.$droparea.removeClass("drag-drop");var t={filelink:e[0]};if(this.upload.type=="file"){var i=e[0].split("/");t.filename=i[i.length-1]}this.upload.callback(t,this.upload.direct,!1)}},this),r.onerror=function(){},r.upload.onprogress=function(e){},r.setRequestHeader("Content-Type",t.type),r.setRequestHeader("x-amz-acl","public-read"),r.send(t))}}},utils:function(){return{isMobile:function(){return/(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent)},isDesktop:function(){return!/(iPhone|iPod|iPad|BlackBerry|Android)/.test(navigator.userAgent)},isString:function(e){return Object.prototype.toString.call(e)=="[object String]"},isEmpty:function(t,n){return t=t.replace(/[\u200B-\u200D\uFEFF]/g,""),t=t.replace(/ /gi,""),t=t.replace(/<\/?br\s?\/?>/g,""),t=t.replace(/\s/g,""),t=t.replace(/^<p>[^\W\w\D\d]*?<\/p>$/i,""),n!==!1&&(t=t.replace(/<[^\/>][^>]*><\/[^>]+>/gi,""),t=t.replace(/<[^\/>][^>]*><\/[^>]+>/gi,"")),t=e.trim(t),t===""},normalize:function(e){return typeof e=="undefined"?0:parseInt(e.replace("px",""),10)},hexToRgb:function(e){if(typeof e=="undefined")return;if(e.search(/^#/)==-1)return e;var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(t,function(e,t,n,r){return t+t+n+n+r+r});var n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return"rgb("+parseInt(n[1],16)+", "+parseInt(n[2],16)+", "+parseInt(n[3],16)+")"},getOuterHtml:function(t){return e("<div>").append(e(t).eq(0).clone()).html()},getAlignmentElement:function(t){return e.inArray(t.tagName,this.opts.alignmentTags)!==-1?e(t):e(t).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0])},removeEmptyAttr:function(t,n){var r=e(t);return typeof r.attr(n)=="undefined"?!0:r.attr(n)===""?(r.removeAttr(n),!0):!1},removeEmpty:function(t,n){var r=e(n);r.find(".redactor-invisible-space").removeAttr("style").removeAttr("class");if(r.find("hr, br, img, iframe").length!==0)return;var i=e.trim(r.text());this.utils.isEmpty(i,!1)&&r.remove()},saveScroll:function(){if(this.utils.isSelectAll())return;this.saveEditorScroll=this.$editor.scrollTop(),this.saveBodyScroll=e(window).scrollTop(),this.opts.scrollTarget&&(this.saveTargetScroll=e(this.opts.scrollTarget).scrollTop())},restoreScroll:function(){if(typeof this.saveScroll=="undefined"&&typeof this.saveBodyScroll=="undefined")return;e(window).scrollTop(this.saveBodyScroll),this.$editor.scrollTop(this.saveEditorScroll),this.opts.scrollTarget&&e(this.opts.scrollTarget).scrollTop(this.saveTargetScroll)},createSpaceElement:function(){var e=document.createElement("span");return e.className="redactor-invisible-space",e.innerHTML=this.opts.invisibleSpace,e},removeInlineTags:function(t){var n=this.opts.inlineTags;n.push("span"),t.tagName=="PRE"&&n.push("a"),e(t).find(n.join(",")).not("span.redactor-selection-marker").contents().unwrap()},replaceWithContents:function(t,n){var r=this;e(t).replaceWith(function(){return n===!0&&r.utils.removeInlineTags(this),e(this).contents()})},replaceToTag:function(t,n,r){var i,s=this;return e(t).replaceWith(function(){i=e("<"+n+" />").append(e(this).contents());for(var t=0;t<this.attributes.length;t++)i.attr(this.attributes[t].name,this.attributes[t].value);return r===!0&&s.utils.removeInlineTags(i),i}),i},isStartOfElement:function(){var e=this.selection.getBlock();if(!e)return!1;var t=this.caret.getOffsetOfElement(e);return t===0?!0:!1},isEndOfElement:function(){var t=this.selection.getBlock();if(!t)return!1;var n=this.caret.getOffsetOfElement(t),r=e.trim(e(t).text()).replace(/\n\r\n/g,"");return n==r.length?!0:!1},isBlock:function(e){return e=e[0]||e,e&&this.utils.isBlockTag(e.tagName)},isBlockTag:function(e){return typeof e=="undefined"?!1:this.reIsBlock.test(e)},isTag:function(t,n){var r=e(t).closest(n);return r.size()==1?r[0]:!1},isSelectAll:function(){return this.selectAll},enableSelectAll:function(){this.selectAll=!0},disableSelectAll:function(){this.selectAll=!1},isRedactorParent:function(t){return t?e(t).parents(".redactor-editor").length===0||e(t).hasClass("redactor-editor")?!1:t:!1},isCurrentOrParent:function(t){var n=this.selection.getParent(),r=this.selection.getCurrent();if(e.isArray(t)){var i=0;return e.each(t,e.proxy(function(e,t){this.utils.isCurrentOrParentOne(r,n,t)&&i++},this)),i===0?!1:!0}return this.utils.isCurrentOrParentOne(r,n,t)},isCurrentOrParentOne:function(e,t,n){return t&&t.tagName===n?t:e&&e.tagName===n?e:!1},isOldIe:function(){return this.utils.browser("msie")&&parseInt(this.utils.browser("version"),10)<9?!0:!1},isLessIe10:function(){return this.utils.browser("msie")&&parseInt(this.utils.browser("version"),10)<10?!0:!1},isIe11:function(){return!!navigator.userAgent.match(/Trident\/7\./)},browser:function(e){var t=navigator.userAgent.toLowerCase(),n=/(opr)[\/]([\w.]+)/.exec(t)||/(chrome)[ \/]([\w.]+)/.exec(t)||/(webkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(t)||/(webkit)[ \/]([\w.]+)/.exec(t)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(t)||/(msie) ([\w.]+)/.exec(t)||t.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(t)||t.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(t)||[];return e=="version"?n[2]:e=="webkit"?n[1]=="chrome"||n[1]=="webkit":n[1]=="rv"?e=="msie":n[1]=="opr"?e=="webkit":e==n[1]}}}},i.prototype.init.prototype=i.prototype,e.Redactor.fn.formatLinkify=function(t,i,s,o,u,a){var f="((?:http[s]?:\\/\\/(?:www\\.)?|www\\.){1}(?:[0-9A-Za-z\\-%_]+\\.)+[a-zA-Z]{2,}(?::[0-9]+)?(?:(?:/[0-9A-Za-z\\-\\.%+_]*)+)?(?:\\?(?:[0-9A-Za-z\\-\\.%_]+(?:=[0-9A-Za-z\\-\\.%_\\+]*)?)?(?:&(?:[0-9A-Za-z\\-\\.%_]+(?:=[0-9A-Za-z\\-\\.%_\\+]*)?)?)*)?(?:#[0-9A-Za-z\\-\\.%_\\+=\\?&;]*)?)",l=new RegExp(f,"gi"),c=/(https?|ftp):\/\//i,h=/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/gi,p=(this.$editor?this.$editor[0]:this).childNodes,d=p.length;while(d--){var v=p[d];if(v.nodeType===3){var m=v.nodeValue;if(u&&m){var g='<iframe width="500" height="281" src="',y='" frameborder="0" allowfullscreen></iframe>';m.match(n)?(m=m.replace(n,g+"//www.youtube.com/embed/$1"+y),e(v).after(m).remove()):m.match(r)&&(m=m.replace(r,g+"//player.vimeo.com/video/$2"+y),e(v).after(m).remove())}if(o&&m&&m.match(h)){m=m.replace(h,'<img src="$1" />'),e(v).after(m).remove();return}m.search(/\$/g)!=-1&&(m=m.replace(/\$/g,"$"));var b=m.match(l);if(s&&m&&b){var w=b.length;for(var E=0;E<w;E++){b[E].match(/\.$/)!==null&&(b[E]=b[E].replace(/\.$/,""));var S=b[E],x=S,T="";S.match(/\s$/)!==null&&(T=" ");var N=t+"://";S.match(c)!==null&&(N=""),x.length>a&&(x=x.substring(0,a)+"..."),x=x.replace(/$/g,"$").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),m=m.replace(S,'<a href="'+N+e.trim(S)+'">'+e.trim(x)+"</a>"+T)}e(v).after(m).remove()}}else v.nodeType===1&&!/^(a|button|textarea)$/i.test(v.tagName)&&e.Redactor.fn.formatLinkify.call(v,t,i,s,o,u,a)}}})(jQuery); \ No newline at end of file diff --git a/scp/css/scp.css b/scp/css/scp.css index ebb60c9ba34d2b21761a3fdb59f148524e7ef8cc..37979a2c7531d71f26910ea796fbbfbaa7a54f61 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -1431,7 +1431,7 @@ time { z-index:1; } -.redactor_editor { +.redactor-editor { font-size: 11pt; } @@ -2141,3 +2141,6 @@ td.indented { #dynamic-actions > tr > td { padding: 5px; } +.no-margin { + margin: 0 !important; +}