From 1da110d6b1d03824eba1aed1cf14ca5dee763e58 Mon Sep 17 00:00:00 2001 From: sslyxhz Date: Sun, 11 Mar 2018 14:47:13 +0800 Subject: [PATCH] feat: add gitment module (#36) --- exampleSite/config.toml | 8 ++++++ layouts/partials/comments.html | 33 ++++++++++++++++++++++-- static/lib/gitment/gitment-0.0.3.min.css | 1 + static/lib/gitment/gitment-0.0.3.min.js | 1 + 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 static/lib/gitment/gitment-0.0.3.min.css create mode 100644 static/lib/gitment/gitment-0.0.3.min.js diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 984abf3..6376691 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -92,6 +92,14 @@ copyright = "" # default: author.name ↓ # 默认为下面配 slideout = '' fancyboxJs = '' fancyboxCss = '' + gitmentJS = '' + gitmentCSS = '' + + [params.gitment] # Gitment is a comment system based on GitHub issues. see https://github.com/imsun/gitment + owner = "" # Your GitHub ID + repo = "" # The repo to store comments + clientId = "" # Your client ID + clientSecret = "" # Your client secret [params.busuanzi] # count web traffic by busuanzi # 是否使用不蒜子统计站点访问量 enable = false diff --git a/layouts/partials/comments.html b/layouts/partials/comments.html index afce2a3..eb75615 100644 --- a/layouts/partials/comments.html +++ b/layouts/partials/comments.html @@ -15,7 +15,7 @@ })(); - {{- end }} + {{- end -}} {{- if and .Site.Params.changyanAppid .Site.Params.changyanAppkey -}} @@ -30,7 +30,7 @@ if (width < 960) {window.document.write(' - {{- end }} + {{- end -}} {{- if .Site.Params.livereUID -}} @@ -50,5 +50,34 @@ + {{- end -}} + + + {{- if .Site.Params.gitment.owner -}} +
+ {{ if .Site.Params.publicCDN.enable -}} + {{ .Site.Params.publicCDN.gitmentCSS | safeHTML }} + {{ .Site.Params.publicCDN.gitmentJS | safeHTML }} + {{- else -}} + + {{- end }} + + + {{- end }} + {{- end }} \ No newline at end of file diff --git a/static/lib/gitment/gitment-0.0.3.min.css b/static/lib/gitment/gitment-0.0.3.min.css new file mode 100644 index 0000000..9ec26a6 --- /dev/null +++ b/static/lib/gitment/gitment-0.0.3.min.css @@ -0,0 +1 @@ +.gitment-markdown hr::after,.gitment-markdown::after{clear:both}.gitment-container{font-family:sans-serif;font-size:14px;line-height:1.5;color:#333;word-wrap:break-word}.gitment-container *{box-sizing:border-box}.gitment-container :disabled{cursor:not-allowed}.gitment-container a,.gitment-container a:visited{cursor:pointer;text-decoration:none}.gitment-container a:hover{text-decoration:underline}.gitment-container .gitment-hidden{display:none}.gitment-container .gitment-spinner-icon{fill:#333;-webkit-animation:gitment-spin 1s steps(12) infinite;animation:gitment-spin 1s steps(12) infinite}@-webkit-keyframes gitment-spin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes gitment-spin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.gitment-header-container,.gitment-root-container{margin:19px 0}.gitment-comment-like-btn,.gitment-comment-reply-btn,.gitment-header-like-btn{cursor:pointer}.gitment-comment-like-btn,.gitment-comment-reply-btn{float:right}.gitment-comment-like-btn.liked{color:#F44336}.gitment-header-like-btn svg{vertical-align:middle;height:30px}.gitment-comment-like-btn svg,.gitment-comment-reply-btn svg{vertical-align:middle;height:20px}.gitment-comment-like-btn.liked svg,.gitment-header-like-btn.liked svg{fill:#F44336}a.gitment-header-issue-link,a.gitment-header-issue-link:visited{float:right;line-height:30px;color:#666}a.gitment-header-issue-link:hover{color:#666}.gitment-comments-empty,.gitment-comments-error,.gitment-comments-loading{text-align:center;margin:50px 0}.gitment-comments-list{list-style:none;padding-left:0;margin:0 0 38px}.gitment-comment,.gitment-editor-container{position:relative;min-height:60px;padding-left:60px;margin:19px 0}.gitment-comment-avatar,.gitment-editor-avatar{float:left;margin-left:-60px}.gitment-comment-avatar,.gitment-comment-avatar-img,.gitment-editor-avatar svg,.gitment-editor-avatar-img{width:44px;height:44px;border-radius:3px}.gitment-editor-avatar .gitment-github-icon{fill:#fff;background-color:#333}.gitment-comment-main,.gitment-editor-main{position:relative;border:1px solid #CFD8DC;border-radius:0}.gitment-comment-main::after,.gitment-comment-main::before,.gitment-editor-main::after,.gitment-editor-main::before{position:absolute;top:11px;left:-16px;display:block;width:0;height:0;pointer-events:none;content:"";border-color:transparent;border-style:solid solid outset}.gitment-comment-main::before,.gitment-editor-main::before{border-width:8px;border-right-color:#CFD8DC}.gitment-comment-main::after,.gitment-editor-main::after{margin-top:1px;margin-left:2px;border-width:7px;border-right-color:#fff}.gitment-comment-header{margin:12px 15px;color:#666;background-color:#fff;border-radius:3px}.gitment-editor-header{padding:0;margin:0;border-bottom:1px solid #CFD8DC}a.gitment-comment-name,a.gitment-comment-name:visited{font-weight:600;color:#666}.gitment-editor-tabs{margin-bottom:-1px;margin-left:-1px}.gitment-editor-tab{display:inline-block;padding:11px 12px;font-size:14px;line-height:20px;color:#666;text-decoration:none;background-color:transparent;border-width:0 1px;border-style:solid;border-color:transparent;border-radius:0;white-space:nowrap;cursor:pointer;user-select:none;outline:0}.gitment-editor-tab.gitment-selected{color:#333;background-color:#fff;border-color:#CFD8DC}.gitment-editor-login{float:right;margin-top:-30px;margin-right:15px}a.gitment-editor-login-link,a.gitment-editor-login-link:visited,a.gitment-footer-project-link,a.gitment-footer-project-link:visited{color:#2196F3}a.gitment-editor-logout-link,a.gitment-editor-logout-link:visited{color:#666}a.gitment-editor-logout-link:hover{color:#2196F3;text-decoration:none}.gitment-comment-body{position:relative;margin:12px 15px;overflow:hidden;border-radius:3px}.gitment-comment-body-folded::after,.gitment-comment-body-folded::before{display:block!important;position:absolute;left:0;pointer-events:none;width:100%}.gitment-comment-body-folded{cursor:pointer}.gitment-comment-body-folded::before{content:"";top:0;bottom:50px;background:-webkit-linear-gradient(top,rgba(255,255,255,0),rgba(255,255,255,.9));background:linear-gradient(180deg,rgba(255,255,255,0),rgba(255,255,255,.9))}.gitment-comment-body-folded::after{content:"Click to Expand"!important;text-align:center;color:#666;height:50px;line-height:50px;bottom:0;background:rgba(255,255,255,.9)}.gitment-editor-body{margin:0}.gitment-comment-body>:first-child,.gitment-editor-preview>:first-child{margin-top:0!important}.gitment-comment-body>:last-child,.gitment-editor-preview>:last-child{margin-bottom:0!important}.gitment-editor-body textarea{display:block;width:100%;min-height:150px;max-height:500px;padding:16px;resize:vertical;max-width:100%;margin:0;font-size:14px;line-height:1.6;background-color:#fff;color:#333;vertical-align:middle;border:none;border-radius:0;outline:0;box-shadow:none;overflow:visible}.gitment-editor-body textarea:focus{background-color:#fff}.gitment-editor-preview{min-height:150px;padding:16px;background-color:transparent;width:100%;font-size:14px;line-height:1.5;word-wrap:break-word}.gitment-editor-footer{padding:0;margin-top:10px}.gitment-editor-footer::after{display:table;clear:both;content:""}a.gitment-editor-footer-tip{display:inline-block;padding-top:10px;font-size:12px;color:#666}a.gitment-editor-footer-tip:hover{color:#2196F3;text-decoration:none}.gitment-comments-pagination{list-style:none;text-align:right;border-radius:0;margin:-19px 0 19px}.gitment-comments-page-item{display:inline-block;cursor:pointer;border:1px solid #CFD8DC;margin-left:-1px;padding:.25rem .5rem}.gitment-comments-page-item.gitment-selected,.gitment-comments-page-item:hover{background-color:#f5f5f5}.gitment-comments-init-btn,.gitment-editor-submit{color:#fff;background-color:#00BCD4;position:relative;display:inline-block;padding:7px 13px;font-size:14px;font-weight:600;line-height:20px;white-space:nowrap;vertical-align:middle;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-size:110% 110%;border:none;-webkit-appearance:none;-moz-appearance:none;appearance:none}.gitment-comments-init-btn:hover,.gitment-editor-submit:hover{background-color:#00ACC1}.gitment-comments-init-btn:disabled,.gitment-editor-submit:disabled{color:rgba(255,255,255,.75);background-color:#4DD0E1;box-shadow:none}.gitment-editor-submit{float:right}.gitment-footer-container{margin-top:30px;margin-bottom:20px;text-align:right;font-size:12px}.gitment-markdown{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;color:#333;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:16px;line-height:1.5;word-wrap:break-word}.gitment-markdown .pl-c{color:#969896}.gitment-markdown .pl-c1,.gitment-markdown .pl-s .pl-v{color:#0086b3}.gitment-markdown .pl-e,.gitment-markdown .pl-en{color:#795da3}.gitment-markdown .pl-s .pl-s1,.gitment-markdown .pl-smi{color:#333}.gitment-markdown .pl-ent{color:#63a35c}.gitment-markdown .pl-k{color:#a71d5d}.gitment-markdown .pl-pds,.gitment-markdown .pl-s,.gitment-markdown .pl-s .pl-pse .pl-s1,.gitment-markdown .pl-sr,.gitment-markdown .pl-sr .pl-cce,.gitment-markdown .pl-sr .pl-sra,.gitment-markdown .pl-sr .pl-sre{color:#183691}.gitment-markdown .pl-smw,.gitment-markdown .pl-v{color:#ed6a43}.gitment-markdown .pl-bu{color:#b52a1d}.gitment-markdown .pl-c2,.gitment-markdown .pl-ii{color:#f8f8f8;background-color:#b52a1d}.gitment-markdown .pl-c2::before{content:"^M"}.gitment-markdown .pl-sr .pl-cce{font-weight:700;color:#63a35c}.gitment-markdown .pl-ml{color:#693a17}.gitment-markdown .pl-mh,.gitment-markdown .pl-mh .pl-en,.gitment-markdown .pl-ms{font-weight:700;color:#1d3e81}.gitment-markdown .pl-mq{color:teal}.gitment-markdown .pl-mi{font-style:italic;color:#333}.gitment-markdown .pl-mb{font-weight:700;color:#333}.gitment-markdown .pl-md{color:#bd2c00;background-color:#ffecec}.gitment-markdown .pl-mi1{color:#55a532;background-color:#eaffea}.gitment-markdown .pl-mc{color:#ef9700;background-color:#ffe3b4}.gitment-markdown .pl-mi2{color:#d8d8d8;background-color:grey}.gitment-markdown .pl-mdr{font-weight:700;color:#795da3}.gitment-markdown .pl-mo{color:#1d3e81}.gitment-markdown .pl-ba{color:#595e62}.gitment-markdown .pl-sg{color:silver}.gitment-markdown .pl-corl{text-decoration:underline;color:#183691}.gitment-markdown .octicon{display:inline-block;fill:currentColor;vertical-align:text-bottom}.gitment-markdown hr::after,.gitment-markdown hr::before,.gitment-markdown::after,.gitment-markdown::before{display:table;content:""}.gitment-markdown a{background-color:transparent;-webkit-text-decoration-skip:objects;color:#0366d6;text-decoration:none}.gitment-markdown a:active,.gitment-markdown a:hover{outline-width:0}.gitment-markdown h1{margin:.67em 0}.gitment-markdown img{border-style:none}.gitment-markdown svg:not(:root){overflow:hidden}.gitment-markdown hr{box-sizing:content-box}.gitment-markdown input{font:inherit;margin:0;overflow:visible;font-family:inherit;font-size:inherit;line-height:inherit}.gitment-markdown [type=checkbox]{box-sizing:border-box;padding:0}.gitment-markdown *{box-sizing:border-box}.gitment-markdown a:hover{text-decoration:underline}.gitment-markdown strong{font-weight:600}.gitment-markdown td,.gitment-markdown th{padding:0}.gitment-markdown blockquote{margin:0}.gitment-markdown ol ol,.gitment-markdown ul ol{list-style-type:lower-roman}.gitment-markdown ol ol ol,.gitment-markdown ol ul ol,.gitment-markdown ul ol ol,.gitment-markdown ul ul ol{list-style-type:lower-alpha}.gitment-markdown dd{margin-left:0}.gitment-markdown code{font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace}.gitment-markdown pre{font:12px SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;word-wrap:normal}.gitment-markdown .pl-0{padding-left:0!important}.gitment-markdown .pl-1{padding-left:4px!important}.gitment-markdown .pl-2{padding-left:8px!important}.gitment-markdown .pl-3{padding-left:16px!important}.gitment-markdown .pl-4{padding-left:24px!important}.gitment-markdown .pl-5{padding-left:32px!important}.gitment-markdown .pl-6{padding-left:40px!important}.gitment-markdown>:first-child{margin-top:0!important}.gitment-markdown>:last-child{margin-bottom:0!important}.gitment-markdown a:not([href]){color:inherit;text-decoration:none}.gitment-markdown .anchor{float:left;padding-right:4px;margin-left:-20px;line-height:1}.gitment-markdown .anchor:focus{outline:0}.gitment-markdown blockquote,.gitment-markdown dl,.gitment-markdown ol,.gitment-markdown p,.gitment-markdown pre,.gitment-markdown table,.gitment-markdown ul{margin-top:0;margin-bottom:16px}.gitment-markdown hr{overflow:hidden;background:#e1e4e8;height:.25em;padding:0;margin:24px 0;border:0}.gitment-markdown blockquote{padding:0 1em;color:#6a737d;border-left:.25em solid #dfe2e5}.gitment-markdown h1,.gitment-markdown h2{padding-bottom:.3em;border-bottom:1px solid #eaecef}.gitment-markdown blockquote>:first-child{margin-top:0}.gitment-markdown blockquote>:last-child{margin-bottom:0}.gitment-markdown h1,.gitment-markdown h2,.gitment-markdown h3,.gitment-markdown h4,.gitment-markdown h5,.gitment-markdown h6{margin-top:24px;margin-bottom:16px;font-weight:600;line-height:1.25}.gitment-markdown h1 .octicon-link,.gitment-markdown h2 .octicon-link,.gitment-markdown h3 .octicon-link,.gitment-markdown h4 .octicon-link,.gitment-markdown h5 .octicon-link,.gitment-markdown h6 .octicon-link{color:#1b1f23;vertical-align:middle;visibility:hidden}.gitment-markdown h1:hover .anchor,.gitment-markdown h2:hover .anchor,.gitment-markdown h3:hover .anchor,.gitment-markdown h4:hover .anchor,.gitment-markdown h5:hover .anchor,.gitment-markdown h6:hover .anchor{text-decoration:none}.gitment-markdown h1:hover .anchor .octicon-link,.gitment-markdown h2:hover .anchor .octicon-link,.gitment-markdown h3:hover .anchor .octicon-link,.gitment-markdown h4:hover .anchor .octicon-link,.gitment-markdown h5:hover .anchor .octicon-link,.gitment-markdown h6:hover .anchor .octicon-link{visibility:visible}.gitment-markdown h1{font-size:2em}.gitment-markdown h2{font-size:1.5em}.gitment-markdown h3{font-size:1.25em}.gitment-markdown h4{font-size:1em}.gitment-markdown h5{font-size:.875em}.gitment-markdown h6{font-size:.85em;color:#6a737d}.gitment-markdown ol,.gitment-markdown ul{padding-left:2em}.gitment-markdown ol ol,.gitment-markdown ol ul,.gitment-markdown ul ol,.gitment-markdown ul ul{margin-top:0;margin-bottom:0}.gitment-markdown li>p{margin-top:16px}.gitment-markdown li+li{margin-top:.25em}.gitment-markdown dl{padding:0}.gitment-markdown dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:600}.gitment-markdown dl dd{padding:0 16px;margin-bottom:16px}.gitment-markdown table{border-spacing:0;border-collapse:collapse;display:block;width:100%;overflow:auto}.gitment-markdown table th{font-weight:600}.gitment-markdown table td,.gitment-markdown table th{padding:6px 13px;border:1px solid #dfe2e5}.gitment-markdown table tr{background-color:#fff;border-top:1px solid #c6cbd1}.gitment-markdown table tr:nth-child(2n){background-color:#f5f5f5}.gitment-markdown img{max-width:100%;box-sizing:content-box;background-color:#fff}.gitment-markdown code{padding:.2em 0;margin:0;font-size:85%;background-color:rgba(27,31,35,.05);border-radius:0}.gitment-markdown code::after,.gitment-markdown code::before{letter-spacing:-.2em;content:"\00a0"}.gitment-markdown pre>code{padding:0;margin:0;font-size:100%;word-break:normal;white-space:pre;background:0 0;border:0}.gitment-markdown .highlight{margin-bottom:16px}.gitment-markdown .highlight pre{margin-bottom:0;word-break:normal}.gitment-markdown .highlight pre,.gitment-markdown pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;background-color:#f5f5f5;border-radius:0}.gitment-markdown pre code{display:inline;max-width:auto;padding:0;margin:0;overflow:visible;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.gitment-markdown pre code::after,.gitment-markdown pre code::before{content:normal}.gitment-markdown .full-commit .btn-outline:not(:disabled):hover{color:#005cc5;border-color:#005cc5}.gitment-markdown kbd{display:inline-block;padding:3px 5px;font:11px SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;line-height:10px;color:#444d56;vertical-align:middle;background-color:#fcfcfc;border:1px solid #c6cbd1;border-bottom-color:#959da5;border-radius:0;box-shadow:inset 0 -1px 0 #959da5}.gitment-markdown :checked+.radio-label{position:relative;z-index:1;border-color:#0366d6}.gitment-markdown .task-list-item{list-style-type:none}.gitment-markdown .task-list-item+.task-list-item{margin-top:3px}.gitment-markdown .task-list-item input{margin:0 .2em .25em -1.6em;vertical-align:middle}.gitment-markdown hr{border-bottom-color:#eee} \ No newline at end of file diff --git a/static/lib/gitment/gitment-0.0.3.min.js b/static/lib/gitment/gitment-0.0.3.min.js new file mode 100644 index 0000000..9b2592d --- /dev/null +++ b/static/lib/gitment/gitment-0.0.3.min.js @@ -0,0 +1 @@ +var Gitment=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=5)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.LS_ACCESS_TOKEN_KEY="gitment-comments-token",t.LS_USER_KEY="gitment-user-info",t.NOT_INITIALIZED_ERROR=new Error("Comments Not Initialized")},function(e,t,n){"use strict";(function(n){function r(e){return function(t,n,r){return r&&"function"==typeof r.value?(r.value=V(e,r.value),r.enumerable=!1,r.configurable=!0,r):Kt(e).apply(this,arguments)}}function i(e,t,n){var r="string"==typeof e?e:e.name||"",i="function"==typeof e?e:t,o="function"==typeof e?t:n;return wt("function"==typeof i,vt("m002")),wt(0===i.length,vt("m003")),wt("string"==typeof r&&r.length>0,"actions should have valid names, got: '"+r+"'"),z(r,i,o,void 0)}function o(e){return"function"==typeof e&&!0===e.isMobxAction}function a(e,t,n){var r=function(){return z(t,n,e,arguments)};r.isMobxAction=!0,Ct(e,t,r)}function s(e,t,n){function r(){a(u)}var i,a,s;"string"==typeof e?(i=e,a=t,s=n):(i=e.name||"Autorun@"+bt(),a=e,s=t),wt("function"==typeof a,vt("m004")),wt(!1===o(a),vt("m005")),s&&(a=a.bind(s));var u=new fn(i,function(){this.track(r)});return u.schedule(),u.getDisposer()}function u(e,t,n,r){var i,o,a,u;return"string"==typeof e?(i=e,o=t,a=n,u=r):(i="When@"+bt(),o=e,a=t,u=n),s(i,function(e){if(o.call(u)){e.dispose();var t=te();a.call(u),ne(t)}})}function c(e,t,n,r){function i(){s(h)}var a,s,u,c;"string"==typeof e?(a=e,s=t,u=n,c=r):(a=e.name||"AutorunAsync@"+bt(),s=e,u=t,c=n),wt(!1===o(s),vt("m006")),void 0===u&&(u=1),c&&(s=s.bind(c));var l=!1,h=new fn(a,function(){l||(l=!0,setTimeout(function(){l=!1,h.isDisposed||h.track(i)},u))});return h.schedule(),h.getDisposer()}function l(e,t,n){function r(){if(!u.isDisposed){var n=!1;u.track(function(){var t=e(u);n=Tt(i.compareStructural,o,t),o=t}),a&&i.fireImmediately&&t(o,u),a||!0!==n||t(o,u),a&&(a=!1)}}arguments.length>3&&yt(vt("m007")),Ve(e)&&yt(vt("m008"));var i;i="object"===(void 0===n?"undefined":Ut(n))?n:{},i.name=i.name||e.name||t.name||"Reaction@"+bt(),i.fireImmediately=!0===n||!0===i.fireImmediately,i.delay=i.delay||0,i.compareStructural=i.compareStructural||i.struct||!1,t=Yt(i.name,i.context?t.bind(i.context):t),i.context&&(e=e.bind(i.context));var o,a=!0,s=!1,u=new fn(i.name,function(){a||i.delay<1?r():s||(s=!0,setTimeout(function(){s=!1,r()},i.delay))});return u.schedule(),u.getDisposer()}function h(e){return ct(function(t,n,r,i,o){wt(void 0!==o,vt("m009")),wt("function"==typeof o.get,vt("m010")),Ze(Fe(t,""),n,o.get,o.set,e,!1)},function(e){var t=this.$mobx.values[e];if(void 0!==t)return t.get()},function(e,t){this.$mobx.values[e].set(t)},!1,!1)}function d(e,t){wt("function"==typeof e&&e.length<2,"createTransformer expects a function that accepts one argument");var n={},r=pn.resetId,i=function(r){function i(t,n){var i=r.call(this,function(){return e(n)},void 0,!1,"Transformer-"+e.name+"-"+t,void 0)||this;return i.sourceIdentifier=t,i.sourceObject=n,i}return Ht(i,r),i.prototype.onBecomeUnobserved=function(){var e=this.value;r.prototype.onBecomeUnobserved.call(this),delete n[this.sourceIdentifier],t&&t(e,this.sourceObject)},i}(sn);return function(e){r!==pn.resetId&&(n={},r=pn.resetId);var t=p(e),o=n[t];return o?o.get():(o=n[t]=new i(t,e),o.get())}}function p(e){if("string"==typeof e||"number"==typeof e)return e;if(null===e||"object"!==(void 0===e?"undefined":Ut(e)))throw new Error("[mobx] transform expected some kind of object or primitive value, got: "+e);var t=e.$transformId;return void 0===t&&(t=bt(),Ct(e,"$transformId",t)),t}function f(e,t){return J()||console.warn(vt("m013")),Jt(e,{context:t}).get()}function m(e){for(var t=[],n=1;n=2,vt("m014")),wt("object"===(void 0===e?"undefined":Ut(e)),vt("m015")),wt(!Tn(e),vt("m016")),n.forEach(function(e){wt("object"===(void 0===e?"undefined":Ut(e)),vt("m017")),wt(!A(e),vt("m018"))});for(var r=Fe(e),i={},o=n.length-1;o>=0;o--){var a=n[o];for(var s in a)if(!0!==i[s]&&Lt(a,s)){if(i[s]=!0,e===a&&!jt(e,s))continue;var u=Object.getOwnPropertyDescriptor(a,s);Xe(r,s,u,t)}}return e}function b(e,t){return y(at(e,t))}function y(e){var t={name:e.name};return e.observing&&e.observing.length>0&&(t.dependencies=St(e.observing).map(y)),t}function w(e,t){return _(at(e,t))}function _(e){var t={name:e.name};return se(e)&&(t.observers=ue(e).map(_)),t}function x(e,t,n){return"function"==typeof n?O(e,t,n):S(e,t)}function S(e,t){return st(e).intercept(t)}function O(e,t,n){return st(e,t).intercept(n)}function k(e,t){if(null===e||void 0===e)return!1;if(void 0!==t){if(!1===ot(e))return!1;var n=at(e,t);return cn(n)}return cn(e)}function A(e,t){if(null===e||void 0===e)return!1;if(void 0!==t){if(qe(e)||Tn(e))throw new Error(vt("m019"));if(ot(e)){var n=e.$mobx;return n.values&&!!n.values[t]}return!1}return ot(e)||!!e.$mobx||an(e)||gn(e)||cn(e)}function E(e){if(void 0===e&&(e=void 0),"string"==typeof arguments[1])return Ft.apply(null,arguments);if(wt(arguments.length<=1,vt("m021")),wt(!Ve(e),vt("m020")),A(e))return e;var t=Be(e,void 0,void 0);return t!==e?t:nn.box(e)}function T(e){yt("Expected one or two arguments to observable."+e+". Did you accidentally try to use observable."+e+" as decorator?")}function L(e){return wt(!!e,":("),ct(function(t,n,r,i,o){Rt(t,n),wt(!o||!o.get,vt("m022")),Qe(Fe(t,void 0),n,r,e)},function(e){var t=this.$mobx.values[e];if(void 0!==t)return t.get()},function(e,t){rt(this,e,t)},!0,!1)}function C(e,t,n,r){return"function"==typeof n?j(e,t,n,r):I(e,t,n)}function I(e,t,n){return st(e).observe(t,n)}function j(e,t,n,r){return st(e,t).observe(n,r)}function R(e,t,n){function r(r){return t&&n.push([e,r]),r}if(void 0===t&&(t=!0),void 0===n&&(n=[]),A(e)){if(t&&null===n&&(n=[]),t&&null!==e&&"object"===(void 0===e?"undefined":Ut(e)))for(var i=0,o=n.length;i0,"actions should have valid names, got: '"+e+"'");var n=function(){return z(e,t,this,arguments)};return n.originalFn=t,n.isMobxAction=!0,n}function z(e,t,n,r){var i=B(e,t,n,r);try{return t.apply(n,r)}finally{$(i)}}function B(e,t,n,r){var i=Se()&&!!e,o=0;if(i){o=Date.now();var a=r&&r.length||0,s=new Array(a);if(a>0)for(var u=0;u0;pn.computationDepth>0&&t&&yt(vt("m031")+e.name),!pn.allowStateChanges&&t&&yt(vt(pn.strictMode?"m030a":"m030b")+e.name)}function X(e,t,n){re(e),e.newObserving=new Array(e.observing.length+100),e.unboundDepsCount=0,e.runId=++pn.runId;var r=pn.trackingDerivation;pn.trackingDerivation=e;var i;try{i=t.call(n)}catch(e){i=new ln(e)}return pn.trackingDerivation=r,Q(e),i}function Q(e){var t=e.observing,n=e.observing=e.newObserving,r=un.UP_TO_DATE;e.newObserving=null;for(var i=0,o=e.unboundDepsCount,a=0;ar&&(r=s.dependenciesState)}for(n.length=i,o=t.length;o--;){var s=t[o];0===s.diffValue&&le(s,e),s.diffValue=0}for(;i--;){var s=n[i];1===s.diffValue&&(s.diffValue=0,ce(s,e))}r!==un.UP_TO_DATE&&(e.dependenciesState=r,e.onBecomeStale())}function Z(e){var t=e.observing;e.observing=[];for(var n=t.length;n--;)le(t[n],e);e.dependenciesState=un.NOT_TRACKING}function ee(e){var t=te(),n=e();return ne(t),n}function te(){var e=pn.trackingDerivation;return pn.trackingDerivation=null,e}function ne(e){pn.trackingDerivation=e}function re(e){if(e.dependenciesState!==un.UP_TO_DATE){e.dependenciesState=un.UP_TO_DATE;for(var t=e.observing,n=t.length;n--;)t[n].lowestObserverState=un.UP_TO_DATE}}function ie(){var e=gt(),t=pn;if(e.__mobservableTrackingStack||e.__mobservableViewStack)throw new Error("[mobx] An incompatible version of mobservable is already loaded.");if(e.__mobxGlobal&&e.__mobxGlobal.version!==t.version)throw new Error("[mobx] An incompatible version of mobx is already loaded.");e.__mobxGlobal?pn=e.__mobxGlobal:e.__mobxGlobal=t}function oe(){return pn}function ae(){pn.resetId++;var e=new dn;for(var t in e)-1===hn.indexOf(t)&&(pn[t]=e[t]);pn.allowStateChanges=!pn.strictMode}function se(e){return e.observers&&e.observers.length>0}function ue(e){return e.observers}function ce(e,t){var n=e.observers.length;n&&(e.observersIndexes[t.__mapid]=n),e.observers[n]=t,e.lowestObserverState>t.dependenciesState&&(e.lowestObserverState=t.dependenciesState)}function le(e,t){if(1===e.observers.length)e.observers.length=0,he(e);else{var n=e.observers,r=e.observersIndexes,i=n.pop();if(i!==t){var o=r[t.__mapid]||0;o?r[i.__mapid]=o:delete r[i.__mapid],n[o]=i}delete r[t.__mapid]}}function he(e){e.isPendingUnobservation||(e.isPendingUnobservation=!0,pn.pendingUnobservations.push(e))}function de(){pn.inBatch++}function pe(){if(0==--pn.inBatch){we();for(var e=pn.pendingUnobservations,t=0;t=0&&pn.globalReactionErrorHandlers.splice(t,1)}}function we(){pn.inBatch>0||pn.isRunningReactions||vn(_e)}function _e(){pn.isRunningReactions=!0;for(var e=pn.pendingReactions,t=0;e.length>0;){++t===mn&&(console.error("Reaction doesn't converge to a stable state after "+mn+" iterations. Probably there is a cycle in the reactive function: "+e[0]),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r0}function Le(e,t){var n=e.interceptors||(e.interceptors=[]);return n.push(t),xt(function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)})}function Ce(e,t){var n=te();try{var r=e.interceptors;if(r)for(var i=0,o=r.length;i0}function je(e,t){var n=e.changeListeners||(e.changeListeners=[]);return n.push(t),xt(function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)})}function Re(e,t){var n=te(),r=e.changeListeners;if(r){r=r.slice();for(var i=0,o=r.length;i=this.length,value:tt?" (... and "+(e.length-t)+"more)":""):""}function kt(e){return null!==e&&"object"===(void 0===e?"undefined":Ut(e))}function At(e){if(null===e||"object"!==(void 0===e?"undefined":Ut(e)))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function Et(){for(var e=arguments[0],t=1,n=arguments.length;t=0;i--)if(!Mt(e[i],t[i]))return!1;return!0}if(r){if(e.size!==t.size)return!1;var o=!0;return e.forEach(function(e,n){o=o&&Mt(t.get(n),e)}),o}if("object"===(void 0===e?"undefined":Ut(e))&&"object"===(void 0===t?"undefined":Ut(t))){if(null===e||null===t)return!1;if(Vt(e)&&Vt(t))return e.size===t.size&&Mt(nn.shallowMap(e).entries(),nn.shallowMap(t).entries());if(Pt(e).length!==Pt(t).length)return!1;for(var a in e){if(!(a in t))return!1;if(!Mt(e[a],t[a]))return!1}return!0}return!1}function Dt(e,t){var n="isMobX"+e;return t.prototype[n]=!0,function(e){return kt(e)&&!0===e[n]}}function Nt(e){return Array.isArray(e)||qe(e)}function Vt(e){return zt(e)||Tn(e)}function zt(e){return void 0!==gt().Map&&e instanceof gt().Map}function Bt(){return"function"==typeof Symbol&&Symbol.toPrimitive||"@@toPrimitive"}function $t(e){return null===e?null:"object"===(void 0===e?"undefined":Ut(e))?""+e:e}var Ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ht=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.extras={allowStateChanges:K,deepEqual:Mt,getAtom:at,getDebugName:ut,getDependencyTree:b,getAdministration:st,getGlobalState:oe,getObserverTree:w,isComputingDerivation:J,isSpyEnabled:Se,onReactionError:ye,reserveArrayBuffer:We,resetGlobalState:ae,shareGlobalState:ie,spyReport:Oe,spyReportEnd:Ae,spyReportStart:ke,setReactionScheduler:xe},"object"===("undefined"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__?"undefined":Ut(__MOBX_DEVTOOLS_GLOBAL_HOOK__))&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx(e.exports),e.exports.default=e.exports;var Kt=ct(function(e,t,n,r,i){var o=r&&1===r.length?r[0]:n.name||t||"";Ct(e,t,Yt(o,n))},function(e){return this[e]},function(){wt(!1,vt("m001"))},!1,!0),Gt=ct(function(e,t,n){a(e,t,n)},function(e){return this[e]},function(){wt(!1,vt("m001"))},!1,!1),Yt=function(e,t,n,i){return 1===arguments.length&&"function"==typeof e?V(e.name||"",e):2===arguments.length&&"function"==typeof t?V(e,t):1===arguments.length&&"string"==typeof e?r(e):r(t).apply(null,arguments)};t.action=Yt,Yt.bound=function(e,t,n){if("function"==typeof e){var r=V("",e);return r.autoBind=!0,r}return Gt.apply(null,arguments)},t.runInAction=i,t.isAction=o,t.autorun=s,t.when=u,t.autorunAsync=c,t.reaction=l;var Wt=h(!1),qt=h(!0),Jt=function(e,t,n){if("string"==typeof t)return Wt.apply(null,arguments);wt("function"==typeof e,vt("m011")),wt(arguments.length<3,vt("m012"));var r="object"===(void 0===t?"undefined":Ut(t))?t:{};return r.setter="function"==typeof t?t:r.setter,new sn(e,r.context,r.compareStructural||r.struct||!1,r.name||e.name||"",r.setter)};t.computed=Jt,Jt.struct=qt,t.createTransformer=d,t.expr=f,t.extendObservable=m,t.extendShallowObservable=v,t.intercept=x,t.isComputed=k,t.isObservable=A;var Ft=L(Be),Xt=L($e),Qt=L(Ue),Zt=L(He),en=L(Ke),tn=function(){function e(){}return e.prototype.box=function(e,t){return arguments.length>2&&T("box"),new Pn(e,Be,t)},e.prototype.shallowBox=function(e,t){return arguments.length>2&&T("shallowBox"),new Pn(e,Ue,t)},e.prototype.array=function(e,t){return arguments.length>2&&T("array"),new Sn(e,Be,t)},e.prototype.shallowArray=function(e,t){return arguments.length>2&&T("shallowArray"),new Sn(e,Ue,t)},e.prototype.map=function(e,t){return arguments.length>2&&T("map"),new En(e,Be,t)},e.prototype.shallowMap=function(e,t){return arguments.length>2&&T("shallowMap"),new En(e,Ue,t)},e.prototype.object=function(e,t){arguments.length>2&&T("object");var n={};return Fe(n,t),m(n,e),n},e.prototype.shallowObject=function(e,t){arguments.length>2&&T("shallowObject");var n={};return Fe(n,t),v(n,e),n},e.prototype.ref=function(){return arguments.length<2?ze(Ue,arguments[0]):Qt.apply(null,arguments)},e.prototype.shallow=function(){return arguments.length<2?ze($e,arguments[0]):Xt.apply(null,arguments)},e.prototype.deep=function(){return arguments.length<2?ze(Be,arguments[0]):Ft.apply(null,arguments)},e.prototype.struct=function(){return arguments.length<2?ze(He,arguments[0]):Zt.apply(null,arguments)},e}();t.IObservableFactories=tn;var nn=E;t.observable=nn,Object.keys(tn.prototype).forEach(function(e){return nn[e]=tn.prototype[e]}),nn.deep.struct=nn.struct,nn.ref.struct=function(){return arguments.length<2?ze(Ke,arguments[0]):en.apply(null,arguments)},t.observe=C,t.toJS=R,t.transaction=P,t.whyRun=N,t.useStrict=U,t.isStrictModeEnabled=H;var rn=function(){function e(e){void 0===e&&(e="Atom@"+bt()),this.name=e,this.isPendingUnobservation=!0,this.observers=[],this.observersIndexes={},this.diffValue=0,this.lastAccessedBy=0,this.lowestObserverState=un.NOT_TRACKING}return e.prototype.onBecomeUnobserved=function(){},e.prototype.reportObserved=function(){fe(this)},e.prototype.reportChanged=function(){de(),me(this),pe()},e.prototype.toString=function(){return this.name},e}();t.BaseAtom=rn;var on=function(e){function t(t,n,r){void 0===t&&(t="Atom@"+bt()),void 0===n&&(n=Bn),void 0===r&&(r=Bn);var i=e.call(this,t)||this;return i.name=t,i.onBecomeObservedHandler=n,i.onBecomeUnobservedHandler=r,i.isPendingUnobservation=!1,i.isBeingTracked=!1,i}return Ht(t,e),t.prototype.reportObserved=function(){return de(),e.prototype.reportObserved.call(this),this.isBeingTracked||(this.isBeingTracked=!0,this.onBecomeObservedHandler()),pe(),!!pn.trackingDerivation},t.prototype.onBecomeUnobserved=function(){this.isBeingTracked=!1,this.onBecomeUnobservedHandler()},t}(rn);t.Atom=on;var an=Dt("Atom",rn),sn=function(){function e(e,t,n,r,i){this.derivation=e,this.scope=t,this.compareStructural=n,this.dependenciesState=un.NOT_TRACKING,this.observing=[],this.newObserving=null,this.isPendingUnobservation=!1,this.observers=[],this.observersIndexes={},this.diffValue=0,this.runId=0,this.lastAccessedBy=0,this.lowestObserverState=un.UP_TO_DATE,this.unboundDepsCount=0,this.__mapid="#"+bt(),this.value=void 0,this.isComputing=!1,this.isRunningSetter=!1,this.name=r||"ComputedValue@"+bt(),i&&(this.setter=V(r+"-setter",i))}return e.prototype.onBecomeStale=function(){ge(this)},e.prototype.onBecomeUnobserved=function(){Z(this),this.value=void 0},e.prototype.get=function(){wt(!this.isComputing,"Cycle detected in computation "+this.name,this.derivation),0===pn.inBatch?(de(),q(this)&&(this.value=this.computeValue(!1)),pe()):(fe(this),q(this)&&this.trackAndCompute()&&ve(this));var e=this.value;if(W(e))throw e.cause;return e},e.prototype.peek=function(){var e=this.computeValue(!1);if(W(e))throw e.cause;return e},e.prototype.set=function(e){if(this.setter){wt(!this.isRunningSetter,"The setter of computed value '"+this.name+"' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?"),this.isRunningSetter=!0;try{this.setter.call(this.scope,e)}finally{this.isRunningSetter=!1}}else wt(!1,"[ComputedValue '"+this.name+"'] It is not possible to assign a new value to a computed value.")},e.prototype.trackAndCompute=function(){Se()&&Oe({object:this.scope,type:"compute",fn:this.derivation});var e=this.value,t=this.value=this.computeValue(!0);return W(t)||Tt(this.compareStructural,t,e)},e.prototype.computeValue=function(e){this.isComputing=!0,pn.computationDepth++;var t;if(e)t=X(this,this.derivation,this.scope);else try{t=this.derivation.call(this.scope)}catch(e){t=new ln(e)}return pn.computationDepth--,this.isComputing=!1,t},e.prototype.observe=function(e,t){var n=this,r=!0,i=void 0;return s(function(){var o=n.get();if(!r||t){var a=te();e({type:"update",object:n,newValue:o,oldValue:i}),ne(a)}r=!1,i=o})},e.prototype.toJSON=function(){return this.get()},e.prototype.toString=function(){return this.name+"["+this.derivation.toString()+"]"},e.prototype.valueOf=function(){return $t(this.get())},e.prototype.whyRun=function(){var e=Boolean(pn.trackingDerivation),t=St(this.isComputing?this.newObserving:this.observing).map(function(e){return e.name}),n=St(ue(this).map(function(e){return e.name}));return"\nWhyRun? computation '"+this.name+"':\n * Running because: "+(e?"[active] the value of this computation is needed by a reaction":this.isComputing?"[get] The value of this computed was requested outside a reaction":"[idle] not running at the moment")+"\n"+(this.dependenciesState===un.NOT_TRACKING?vt("m032"):" * This computation will re-run if any of the following observables changes:\n "+Ot(t)+"\n "+(this.isComputing&&e?" (... or any observable accessed during the remainder of the current run)":"")+"\n\t"+vt("m038")+"\n\n * If the outcome of this computation changes, the following observers will be re-run:\n "+Ot(n)+"\n")},e}();sn.prototype[Bt()]=sn.prototype.valueOf;var un,cn=Dt("ComputedValue",sn);!function(e){e[e.NOT_TRACKING=-1]="NOT_TRACKING",e[e.UP_TO_DATE=0]="UP_TO_DATE",e[e.POSSIBLY_STALE=1]="POSSIBLY_STALE",e[e.STALE=2]="STALE"}(un||(un={})),t.IDerivationState=un;var ln=function(){function e(e){this.cause=e}return e}();t.untracked=ee;var hn=["mobxGuid","resetId","spyListeners","strictMode","runId"],dn=function(){function e(){this.version=5,this.trackingDerivation=null,this.computationDepth=0,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!0,this.strictMode=!1,this.resetId=0,this.spyListeners=[],this.globalReactionErrorHandlers=[]}return e}(),pn=new dn,fn=function(){function e(e,t){void 0===e&&(e="Reaction@"+bt()),this.name=e,this.onInvalidate=t,this.observing=[],this.newObserving=[],this.dependenciesState=un.NOT_TRACKING,this.diffValue=0,this.runId=0,this.unboundDepsCount=0,this.__mapid="#"+bt(),this.isDisposed=!1,this._isScheduled=!1,this._isTrackPending=!1,this._isRunning=!1}return e.prototype.onBecomeStale=function(){this.schedule()},e.prototype.schedule=function(){this._isScheduled||(this._isScheduled=!0,pn.pendingReactions.push(this),we())},e.prototype.isScheduled=function(){return this._isScheduled},e.prototype.runReaction=function(){this.isDisposed||(de(),this._isScheduled=!1,q(this)&&(this._isTrackPending=!0,this.onInvalidate(),this._isTrackPending&&Se()&&Oe({object:this,type:"scheduled-reaction"})),pe())},e.prototype.track=function(e){de();var t,n=Se();n&&(t=Date.now(),ke({object:this,type:"reaction",fn:e})),this._isRunning=!0;var r=X(this,e,void 0);this._isRunning=!1,this._isTrackPending=!1,this.isDisposed&&Z(this),W(r)&&this.reportExceptionInDerivation(r.cause),n&&Ae({time:Date.now()-t}),pe()},e.prototype.reportExceptionInDerivation=function(e){var t=this;if(this.errorHandler)return void this.errorHandler(e,this);var n="[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '"+this,r=vt("m037");console.error(n||r,e),Se()&&Oe({type:"error",message:n,error:e,object:this}),pn.globalReactionErrorHandlers.forEach(function(n){return n(e,t)})},e.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this._isRunning||(de(),Z(this),pe()))},e.prototype.getDisposer=function(){var e=this.dispose.bind(this);return e.$mobx=this,e.onError=be,e},e.prototype.toString=function(){return"Reaction["+this.name+"]"},e.prototype.whyRun=function(){var e=St(this._isRunning?this.newObserving:this.observing).map(function(e){return e.name});return"\nWhyRun? reaction '"+this.name+"':\n * Status: ["+(this.isDisposed?"stopped":this._isRunning?"running":this.isScheduled()?"scheduled":"idle")+"]\n * This reaction will re-run if any of the following observables changes:\n "+Ot(e)+"\n "+(this._isRunning?" (... or any observable accessed during the remainder of the current run)":"")+"\n\t"+vt("m038")+"\n"},e}();t.Reaction=fn;var mn=100,vn=function(e){return e()},gn=Dt("Reaction",fn),bn={spyReportEnd:!0};t.spy=Ee,t.asReference=Pe,t.asStructure=Me,t.asFlat=De,t.asMap=Ne,t.isModifierDescriptor=Ve;var yn=function(){var e=!1,t={};return Object.defineProperty(t,"0",{set:function(){e=!0}}),Object.create(t)[0]=1,!1===e}(),wn=0,_n=function(){function e(){}return e}();_n.prototype=[];var xn=function(){function e(e,t,n,r){this.array=n,this.owned=r,this.lastKnownLength=0,this.interceptors=null,this.changeListeners=null,this.atom=new rn(e||"ObservableArray@"+bt()),this.enhancer=function(n,r){return t(n,r,e+"[..]")}}return e.prototype.intercept=function(e){return Le(this,e)},e.prototype.observe=function(e,t){return void 0===t&&(t=!1),t&&e({object:this.array,type:"splice",index:0,added:this.values.slice(),addedCount:this.values.length,removed:[],removedCount:0}),je(this,e)},e.prototype.getArrayLength=function(){return this.atom.reportObserved(),this.values.length},e.prototype.setArrayLength=function(e){if("number"!=typeof e||e<0)throw new Error("[mobx.array] Out of range: "+e);var t=this.values.length;if(e!==t)if(e>t){for(var n=new Array(e-t),r=0;r0&&e+t+1>wn&&We(e+t+1)},e.prototype.spliceWithArray=function(e,t,n){var r=this;F(this.atom);var i=this.values.length;if(void 0===e?e=0:e>i?e=i:e<0&&(e=Math.max(0,i+e)),t=1===arguments.length?i-e:void 0===t||null===t?0:Math.max(0,Math.min(t,i-e)),void 0===n&&(n=[]),Te(this)){var o=Ce(this,{object:this.array,type:"splice",index:e,removedCount:t,added:n});if(!o)return Vn;t=o.removedCount,n=o.added}n=n.map(function(e){return r.enhancer(e,void 0)});var a=n.length-t;this.updateArrayLength(i,a);var s=this.spliceItemsIntoValues(e,t,n);return 0===t&&0===n.length||this.notifyArraySplice(e,n,s),s},e.prototype.spliceItemsIntoValues=function(e,t,n){if(n.length<1e4)return(i=this.values).splice.apply(i,[e,t].concat(n));var r=this.values.slice(e,e+t);return this.values=this.values.slice(0,e).concat(n,this.values.slice(e+t)),r;var i},e.prototype.notifyArrayChildUpdate=function(e,t,n){var r=!this.owned&&Se(),i=Ie(this),o=i||r?{object:this.array,type:"update",index:e,newValue:t,oldValue:n}:null;r&&ke(o),this.atom.reportChanged(),i&&Re(this,o),r&&Ae()},e.prototype.notifyArraySplice=function(e,t,n){var r=!this.owned&&Se(),i=Ie(this),o=i||r?{object:this.array,type:"splice",index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&ke(o),this.atom.reportChanged(),i&&Re(this,o),r&&Ae()},e}(),Sn=function(e){function t(t,n,r,i){void 0===r&&(r="ObservableArray@"+bt()),void 0===i&&(i=!1);var o=e.call(this)||this,a=new xn(r,n,o,i);return It(o,"$mobx",a),t&&t.length?(a.updateArrayLength(0,t.length),a.values=t.map(function(e){return n(e,void 0,r+"[..]")}),a.notifyArraySplice(0,a.values.slice(),Vn)):a.values=[],yn&&Object.defineProperty(a.array,"0",On),o}return Ht(t,e),t.prototype.intercept=function(e){return this.$mobx.intercept(e)},t.prototype.observe=function(e,t){return void 0===t&&(t=!1),this.$mobx.observe(e,t)},t.prototype.clear=function(){return this.splice(0)},t.prototype.concat=function(){for(var e=[],t=0;t-1&&(this.splice(t,1),!0)},t.prototype.move=function(e,t){function n(e){if(e<0)throw new Error("[mobx.array] Index out of bounds: "+e+" is negative");var t=this.$mobx.values.length;if(e>=t)throw new Error("[mobx.array] Index out of bounds: "+e+" is not smaller than "+t)}if(n.call(this,e),n.call(this,t),e!==t){var r,i=this.$mobx.values;r=e"+n.reactions.heart+" Liked":"")+"\n ",s?(a.classList.add("liked"),a.onclick=function(){return t.unlike()}):(a.classList.remove("liked"),a.onclick=function(){return t.like()}),o.appendChild(a);var u=document.createElement("span");u.innerHTML="\n "+(n.comments?" • "+n.comments+" Comments":"")+"\n ",o.appendChild(u);var l=document.createElement("a");return l.className="gitment-header-issue-link",l.href=n.html_url,l.target="_blank",l.innerText="Issue Page",o.appendChild(l),o}function i(e,t){var n=e.meta,r=e.comments,i=e.commentReactions,o=e.currentPage,a=e.user,s=e.error,u=document.createElement("div");if(u.lang="en-US",u.className="gitment-container gitment-comments-container",s){var h=document.createElement("div");if(h.className="gitment-comments-error",s===l.NOT_INITIALIZED_ERROR&&a.login&&a.login.toLowerCase()===t.owner.toLowerCase()){var d=document.createElement("div"),p=document.createElement("button");p.className="gitment-comments-init-btn",p.onclick=function(){p.setAttribute("disabled",!0),t.init().catch(function(e){p.removeAttribute("disabled"),alert(e)})},p.innerText="Initialize Comments",d.appendChild(p),h.appendChild(d)}else h.innerText=s;return u.appendChild(h),u}if(void 0===r){var f=document.createElement("div");return f.innerText="Loading comments...",f.className="gitment-comments-loading",u.appendChild(f),u}if(!r.length){var m=document.createElement("div");return m.className="gitment-comments-empty",m.innerText="No Comment Yet",u.appendChild(m),u}var v=document.createElement("ul");if(v.className="gitment-comments-list",r.forEach(function(e){var n=new Date(e.created_at),r=new Date(e.updated_at),o=document.createElement("li");o.className="gitment-comment",o.innerHTML='\n \n \n \n
\n
\n \n '+e.user.login+'\n \n commented on\n '+n.toDateString()+"\n "+(n.toString()!==r.toString()?' • edited':"")+'\n
'+c.reply+'
\n
'+c.heart+" "+(e.reactions.heart||"")+'
\n
\n
'+e.body_html+"
\n
\n ";var s=o.querySelector(".gitment-comment-like-btn");i[e.id]&&i[e.id].find(function(e){return"heart"===e.content&&e.user.login===a.login})?(s.classList.add("liked"),s.onclick=function(){return t.unlikeAComment(e.id)}):(s.classList.remove("liked"),s.onclick=function(){return t.likeAComment(e.id)}),o.querySelector(".gitment-comment-reply-btn").onclick=function(){return t.replyAComment(e.user.login)};var u=document.createElement("img"),l=o.querySelector(".gitment-comment-body");u.className="gitment-hidden",u.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",u.onload=function(){l.clientHeight>t.maxCommentHeight&&(l.classList.add("gitment-comment-body-folded"),l.style.maxHeight=t.maxCommentHeight+"px",l.title="Click to Expand",l.onclick=function(){l.classList.remove("gitment-comment-body-folded"),l.style.maxHeight="",l.title="",l.onclick=null})},o.appendChild(u),v.appendChild(o)}),u.appendChild(v),n){var g=Math.ceil(n.comments/t.perPage);if(g>1){var b=document.createElement("ul");if(b.className="gitment-comments-pagination",o>1){var y=document.createElement("li");y.className="gitment-comments-page-item",y.innerText="Previous",y.onclick=function(){return t.goto(o-1)},b.appendChild(y)}for(var w=1;w<=g;w++)!function(e){var n=document.createElement("li");n.className="gitment-comments-page-item",n.innerText=e,n.onclick=function(){return t.goto(e)},o===e&&n.classList.add("gitment-selected"),b.appendChild(n)}(w);if(o\n \n ':n.isLoggingIn?'
'+c.spinner+"
":'\n '+c.github+"\n ")+'\n \n
\n
\n \n \n
\n
\n
\n \n
\n
\n
\n
\n
\n
\n \n ",n.login&&(i.querySelector(".gitment-editor-logout-link").onclick=function(){return t.logout()});var s=i.querySelector(".gitment-editor-write-field"),l=i.querySelector(".gitment-editor-preview-field"),h=s.querySelector("textarea");h.oninput=function(){h.style.height="auto";var e=window.getComputedStyle(h,null),t=parseInt(e.height,10),n=h.clientHeight,r=h.scrollHeight;n1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"https://api.github.com",i=new XMLHttpRequest,o=localStorage.getItem(a.LS_ACCESS_TOKEN_KEY),s=""+r+t,c=null;"GET"!==e&&"DELETE"!==e||(s+=u.stringify(n));var l=new Promise(function(e,t){i.addEventListener("load",function(){var n=i.getResponseHeader("content-type"),r=i.responseText;if(!/json/.test(n))return void e(r);var o=i.responseText?JSON.parse(r):{};o.message?t(new Error(o.message)):e(o)}),i.addEventListener("error",function(e){return t(e)})});return i.open(e,s,!0),i.setRequestHeader("Accept","application/vnd.github.squirrel-girl-preview, application/vnd.github.html+json"),o&&i.setRequestHeader("Authorization","token "+o),"GET"!==e&&"DELETE"!==e&&(c=JSON.stringify(n),i.setRequestHeader("Content-Type","application/json")),i.send(c),l}}Object.defineProperty(t,"__esModule",{value:!0}),t.http=t.Query=t.isString=void 0;var o=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.getTargetContainer=r;var a=n(0),s=t.isString=function(e){return"[object String]"===toString.call(e)},u=t.Query={parse:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location.search;if(!e)return{};var t="?"===e[0]?e.substring(1):e,n={};return t.split("&").forEach(function(e){var t=e.split("="),r=o(t,2),i=r[0],a=r[1];i&&(n[i]=a)}),n},stringify:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"?",n=Object.keys(e).map(function(t){return t+"="+encodeURIComponent(e[t]||"")}).join("&");return n?t+n:""}};t.http={get:i("GET"),post:i("POST"),delete:i("DELETE"),put:i("PUT")}},function(e,t,n){"use strict";var r,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":i(window))&&(r=window)}e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){e[t]=function(n){var r=(0,u.getTargetContainer)(n),i=e.theme[t]||e.defaultTheme[t];return(0,a.autorun)(function(){var t=i(e.state,e);r.firstChild?r.replaceChild(t,r.firstChild):r.appendChild(t)}),r}}var o=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.defaultTheme=l.default,this.useTheme(l.default),Object.assign(this,{id:window.location.href,title:window.document.title,link:window.location.href,desc:"",labels:[],theme:l.default,oauth:{},perPage:20,maxCommentHeight:250},n),this.useTheme(this.theme);var i={};try{var o=localStorage.getItem(s.LS_USER_KEY);this.accessToken&&o&&Object.assign(i,JSON.parse(o),{fromCache:!0})}catch(e){localStorage.removeItem(s.LS_USER_KEY)}this.state=(0,a.observable)({user:i,error:null,meta:{},comments:void 0,reactions:[],commentReactions:{},currentPage:1});var c=u.Query.parse();if(c.code){var h=this.oauth,d=h.client_id,p=h.client_secret,f=c.code;delete c.code;var m=u.Query.stringify(c),v=""+window.location.origin+window.location.pathname+m+window.location.hash;history.replaceState({},"",v),Object.assign(this,{id:v,link:v},n),this.state.user.isLoggingIn=!0,u.http.post("https://gh-oauth.imsun.net",{code:f,client_id:d,client_secret:p},"").then(function(e){t.accessToken=e.access_token,t.update()}).catch(function(e){t.state.user.isLoggingIn=!1,alert(e)})}else this.update()}return o(e,[{key:"accessToken",get:function(){return localStorage.getItem(s.LS_ACCESS_TOKEN_KEY)},set:function(e){localStorage.setItem(s.LS_ACCESS_TOKEN_KEY,e)}},{key:"loginLink",get:function(){var e=this.oauth.redirect_uri||window.location.href,t=Object.assign({scope:"public_repo",redirect_uri:e},this.oauth);return"https://github.com/login/oauth/authorize"+u.Query.stringify(t)}}]),o(e,[{key:"init",value:function(){var e=this;return this.createIssue().then(function(){return e.loadComments()}).then(function(t){return e.state.error=null,t})}},{key:"useTheme",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.theme=t,Object.keys(this.theme).forEach(function(t){return i(e,t)})}},{key:"update",value:function(){var e=this;return Promise.all([this.loadMeta(),this.loadUserInfo()]).then(function(){return Promise.all([e.loadComments().then(function(){return e.loadCommentReactions()}),e.loadReactions()])}).catch(function(t){return e.state.error=t})}},{key:"markdown",value:function(e){return u.http.post("/markdown",{text:e,mode:"gfm"})}},{key:"createIssue",value:function(){var e=this,t=this.id,n=this.owner,r=this.repo,i=this.title,o=this.link,a=this.desc,s=this.labels;return u.http.post("/repos/"+n+"/"+r+"/issues",{title:i,labels:s.concat(["gitment",t]),body:o+"\n\n"+a}).then(function(t){return e.state.meta=t,t})}},{key:"getIssue",value:function(){return this.state.meta.id?Promise.resolve(this.state.meta):this.loadMeta()}},{key:"post",value:function(e){var t=this;return this.getIssue().then(function(t){return u.http.post(t.comments_url,{body:e},"")}).then(function(e){t.state.meta.comments++;var n=Math.ceil(t.state.meta.comments/t.perPage);return t.state.currentPage===n&&t.state.comments.push(e),e})}},{key:"loadMeta",value:function(){var e=this,t=this.id,n=this.owner,r=this.repo;return u.http.get("/repos/"+n+"/"+r+"/issues",{creator:n,labels:t}).then(function(t){return t.length?(e.state.meta=t[0],t[0]):Promise.reject(s.NOT_INITIALIZED_ERROR)})}},{key:"loadComments",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state.currentPage;return this.getIssue().then(function(n){return u.http.get(n.comments_url,{page:t,per_page:e.perPage},"")}).then(function(t){return e.state.comments=t,t})}},{key:"loadUserInfo",value:function(){var e=this;return this.accessToken?u.http.get("/user").then(function(t){return e.state.user=t,localStorage.setItem(s.LS_USER_KEY,JSON.stringify(t)),t}):(this.logout(),Promise.resolve({}))}},{key:"loadReactions",value:function(){var e=this;return this.accessToken?this.getIssue().then(function(e){return e.reactions.total_count?u.http.get(e.reactions.url,{},""):[]}).then(function(t){return e.state.reactions=t,t}):(this.state.reactions=[],Promise.resolve([]))}},{key:"loadCommentReactions",value:function(){var e=this;if(!this.accessToken)return this.state.commentReactions={},Promise.resolve([]);var t=this.state.comments,n={};return Promise.all(t.map(function(t){if(!t.reactions.total_count)return[];var n=e.owner,r=e.repo;return u.http.get("/repos/"+n+"/"+r+"/issues/comments/"+t.id+"/reactions",{})})).then(function(r){return t.forEach(function(e,t){n[e.id]=r[t]}),e.state.commentReactions=n,n})}},{key:"login",value:function(){window.location.href=this.loginLink}},{key:"logout",value:function(){localStorage.removeItem(s.LS_ACCESS_TOKEN_KEY),localStorage.removeItem(s.LS_USER_KEY),this.state.user={}}},{key:"goto",value:function(e){return this.state.currentPage=e,this.state.comments=void 0,this.loadComments(e)}},{key:"like",value:function(){var e=this;if(!this.accessToken)return alert("Login to Like"),Promise.reject();var t=this.owner,n=this.repo;return u.http.post("/repos/"+t+"/"+n+"/issues/"+this.state.meta.number+"/reactions",{content:"heart"}).then(function(t){e.state.reactions.push(t),e.state.meta.reactions.heart++})}},{key:"unlike",value:function(){var e=this;if(!this.accessToken)return Promise.reject();var t=this.state,n=t.user,r=t.reactions,i=r.findIndex(function(e){return e.user.login===n.login});return u.http.delete("/reactions/"+r[i].id).then(function(){r.splice(i,1),e.state.meta.reactions.heart--})}},{key:"likeAComment",value:function(e){var t=this;if(!this.accessToken)return alert("Login to Like"),Promise.reject();var n=this.owner,r=this.repo,i=this.state.comments.find(function(t){return t.id===e});return u.http.post("/repos/"+n+"/"+r+"/issues/comments/"+e+"/reactions",{content:"heart"}).then(function(n){t.state.commentReactions[e].push(n),i.reactions.heart++})}},{key:"unlikeAComment",value:function(e){if(!this.accessToken)return Promise.reject();var t=this.state.commentReactions[e],n=this.state.comments.find(function(t){return t.id===e}),r=this.state.user,i=t.findIndex(function(e){return e.user.login===r.login});return u.http.delete("/reactions/"+t[i].id).then(function(){t.splice(i,1),n.reactions.heart--})}},{key:"replyAComment",value:function(e){if(!this.accessToken)return Promise.reject();var t=document.getElementById("gitment-editor");t.innerText+="@"+e+" ",t.focus()}}]),e}();e.exports=h},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.close='',t.github='',t.heart='',t.spinner='',t.reply=''}]); \ No newline at end of file