From fc470d46eafa9829ae899658b95ef5f265cf85b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E6=81=92?= <2323333339@qq.com> Date: Mon, 29 Mar 2021 11:02:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typecho/write/css/joe.write.min.css | 2 +- typecho/write/css/joe.write.min.scss | 1148 +++++------ typecho/write/js/_actions.js | 541 ++--- typecho/write/js/_create.js | 10 + typecho/write/js/_tools.js | 10 + typecho/write/js/joe.parse.js | 2712 +++++++++++++------------- typecho/write/js/joe.write.chunk.js | 6 +- typecho/write/js/joe.write.js | 483 +++-- typecho/write/rollup.config.js | 12 +- 9 files changed, 2489 insertions(+), 2435 deletions(-) create mode 100644 typecho/write/js/_create.js diff --git a/typecho/write/css/joe.write.min.css b/typecho/write/css/joe.write.min.css index 4a9ddcb..1b0884c 100644 --- a/typecho/write/css/joe.write.min.css +++ b/typecho/write/css/joe.write.min.css @@ -1 +1 @@ -input[name='fields[keywords]']{width:100%}textarea[name='fields[description]'],textarea[name='fields[abstract]'],textarea[name='fields[thumb]'],textarea[name='fields[video]']{width:100%;height:80px}#text,#text ~ .resize{display:none}body.fullscreen{overflow:hidden}.cm-container{display:flex;flex-direction:column;position:relative;width:100%;height:550px;box-sizing:border-box;z-index:6666;content-visibility:auto;background:#222}.cm-container.fullscreen{position:fixed;top:0;left:0;width:100%;height:100%}.cm-container *{outline:none !important}.cm-container .cm-tools{display:flex;flex-wrap:wrap;background-color:#303133;padding:5px 0 0 5px}.cm-container .cm-tools .cm-tools-item{position:relative;cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:2px;padding:5px;margin:0 5px 5px 0;transition:background 0.25s}.cm-container .cm-tools .cm-tools-item:hover{background:#393939}.cm-container .cm-tools .cm-tools-item:hover svg{fill:#efefef}.cm-container .cm-tools .cm-tools-item.active{background:#393939}.cm-container .cm-tools .cm-tools-item.active svg{fill:#efefef}.cm-container .cm-tools .cm-tools-item.active .cm-tools__dropdown{visibility:visible;opacity:1;-webkit-transform:translateX(-50%) rotateX(0);transform:translateX(-50%) rotateX(0)}.cm-container .cm-tools .cm-tools-item svg{vertical-align:middle;fill:#bfbfbf}.cm-container .cm-tools__dropdown{position:absolute;top:42px;left:50%;z-index:1000;background:#313335;padding:5px 0;border-radius:4px;visibility:hidden;-webkit-transform-origin:top;transform-origin:top;opacity:0;-webkit-transform:translateX(-50%) rotateX(-90deg);transform:translateX(-50%) rotateX(-90deg);transition:visibility 0.25s, opacity 0.25s, -webkit-transform 0.25s;transition:visibility 0.25s, transform 0.25s, opacity 0.25s;transition:visibility 0.25s, transform 0.25s, opacity 0.25s, -webkit-transform 0.25s}.cm-container .cm-tools__dropdown-item{padding:0 20px;line-height:32px;transition:background 0.25s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;font-size:15px;color:#bfbfbf;font-weight:600}.cm-container .cm-tools__dropdown-item:hover{background:#393939}.cm-container .cm-tools__dropdown::before{content:'';position:absolute;top:-7px;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);width:0;height:0;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #313335}.cm-container .cm-mainer{flex:1;min-height:0;display:flex;width:100%}.cm-container .cm-mainer .cm-wrap{flex-shrink:0;height:100%;flex:1;min-width:0;font-size:14px}.cm-container .cm-mainer .cm-wrap .cm-scroller{line-height:1.5;font-family:Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;-ms-scroll-chaining:none;overscroll-behavior:none}.cm-container .cm-mainer .cm-wrap .cm-scroller::-webkit-scrollbar{display:none}.cm-container .cm-mainer .cm-wrap .cm-scroller ::-moz-selection{background-color:rgba(221,240,255,0.2)}.cm-container .cm-mainer .cm-wrap .cm-scroller ::selection{background-color:rgba(221,240,255,0.2)}.cm-container .cm-mainer .cm-wrap .cm-scroller .cm-content{width:100%;white-space:pre-wrap;overflow-wrap:break-word;color:#ccc;caret-color:#ccc;padding:15px 13px 15px 11px;-webkit-user-modify:read-write-plaintext-only}.cm-container .cm-mainer .cm-wrap .cm-scroller .cm-matchingBracket{color:#8f938f;border:1px solid rgba(255,255,255,0.25);margin:-1px}.cm-container .cm-mainer .cm-wrap .cm-scroller .cm-nonmatchingBracket{color:#ff5627}.cm-container .cm-mainer .cm-resize{flex-shrink:0;height:100%;position:relative;width:16px;background:#303133;cursor:col-resize}.cm-container .cm-mainer .cm-resize::before{content:'';position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);width:4px;height:40px;border-radius:2px;background:#fff}.cm-container .cm-mainer .cm-preview{position:relative;flex-shrink:0;width:0;height:100%;background:#fff;overflow:auto;box-sizing:border-box;-ms-scroll-chaining:none;overscroll-behavior:none}.cm-container .cm-mainer .cm-preview::-webkit-scrollbar-track{background:#fff}.cm-container .cm-mainer .cm-preview::-webkit-scrollbar{width:6px;height:6px}.cm-container .cm-mainer .cm-preview::-webkit-scrollbar-thumb{border-radius:3px;background:#c0c4cc}.cm-container .cm-mainer .cm-preview .cm-preview-content{padding:20px;font-size:14px;font-family:'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;white-space:pre-wrap;overflow-wrap:break-word;color:#606266;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.cm-container .cm-mainer .cm-preview .cm-preview-content h1,.cm-container .cm-mainer .cm-preview .cm-preview-content h2,.cm-container .cm-mainer .cm-preview .cm-preview-content h3,.cm-container .cm-mainer .cm-preview .cm-preview-content h4,.cm-container .cm-mainer .cm-preview .cm-preview-content h5,.cm-container .cm-mainer .cm-preview .cm-preview-content h6{color:#303133;font-size:18px;line-height:24px;margin:0;margin-bottom:15px;position:relative}.cm-container .cm-mainer .cm-preview .cm-preview-content h1{padding:0 15px}.cm-container .cm-mainer .cm-preview .cm-preview-content h1::before{content:'';position:absolute;top:8.5px;left:0;height:7px;width:7px;border-radius:50%;background:#409eff}.cm-container .cm-mainer .cm-preview .cm-preview-content h2{padding:0 15px}.cm-container .cm-mainer .cm-preview .cm-preview-content h2::before{content:'';position:absolute;top:10%;bottom:10%;left:0;width:4px;border-radius:2px;background:#409eff}.cm-container .cm-mainer .cm-preview .cm-preview-content h3{padding:0 15px 0 20px}.cm-container .cm-mainer .cm-preview .cm-preview-content h3::before{content:'#';color:#409eff;font-weight:700;position:absolute;top:0;left:0;line-height:24px}.cm-container .cm-mainer .cm-preview .cm-preview-content h4::before{content:'「';color:#409eff;font-weight:600;margin-right:5px}.cm-container .cm-mainer .cm-preview .cm-preview-content h4::after{content:'」';color:#409eff;font-weight:600;margin-left:5px}.cm-container .cm-mainer .cm-preview .cm-preview-content h5{padding:0 15px 0 28px}.cm-container .cm-mainer .cm-preview .cm-preview-content h5::before{content:'';position:absolute;top:2px;left:0;width:20px;height:20px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAC8klEQVRYR+3WP2gTURwH8O/vKnVRRHKXP52cBO3g4p/BqYNIhy4muajUQRBFKjQV1En6ZxJBcmlRCoJDRe3FDiJVwamLS3FwqbgIgss1l2ZQF5XeT3I1Z3NJ7u5dLlAwN9699/t97vfe7/EIO/yhHe5DD9jpCv3fFVTu856+Xzi62Y/35hj9CFPNrlUwWeRJAJfBGADwBcBNI0/PRZFdAdo4xlQLjCqKjBzogat7hZCRAgPghJGBgbFnxglAOvS7b/fLb+q+qnv5BHBCyEBAWTdnANy2IxOtWSC1qsY+1jOFwAVG+gIVvXyHQbcaKuZCxmf5iMQogXFQtEsBeO5JT6BcMu+Bcb1lUhcyqfExACUAB6JEtgUqi+U5JrrmmcyFHCjwSYtQO+tSUSFbAmXdnAdwJVASdyWLPAS2kbFA8xsHNS13EzCmlx8R6KJQcBcypfFpho3cKxRna3ADsgEo6+ZjAKMhgjZ1d2KWR2gTSyD0h4jnIB2gXDIXwciFCPZvSnMl0wwshYrJGDImaMUGKovlLBPVOrDjh8APzFx8zDkjNa7FzYoGZsKT9XEarQOHmei1aJA246cqOWW6/i2l8VMGzoWIPW/k6eq2Ja6UwCz8pw2JGZ8sS8pUz8fWau/jGp+SgLchcGBgZD1Py41NUuoI+ZloV8ZU93+ogZKzfBiWfXAPCgMJU8Y42avQdMzI4ZBfmSizocqrUeJaAmsvBZGGBCtTziXeRY1rCxRAViEhXckqK93AeQJ9kYTvlmVlqmcTdhNEtefc+9X3utVmuX+CkK6oyqtu4nwrWP8bF5IZdGYjJ79wDuMCz4D+XmhFWnZbt7ab5ltBB6mbkyAaBPFCJassuwMmNb4L4EZgXwBc4AoGTZrUeA6A9x1yK6tzzvnFDlxBv0D176kCP2TCpbbjBXCRV9DZk0VeAONCE1IQ1zWg3dlF1sFQHWQIXFeBNrLAw5BwHBZWjQl6E3SbbB8X+R4Mg/Ca0wN2WtFeBTut4B84mFI4VpekyAAAAABJRU5ErkJggg==");background-size:100% 100%}.cm-container .cm-mainer .cm-preview .cm-preview-content h6{padding:0 15px 0 28px}.cm-container .cm-mainer .cm-preview .cm-preview-content h6::before{content:'';position:absolute;top:2px;left:0;width:20px;height:20px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAEI0lEQVRYR+3Xb2wTZRwH8G/vL22RPy5GW8fK6rJpGeFFY9RO3TRRE1HfmEAammEyjZmOSEg1RrPZaTD6xjhU/Ndlf0CZgwmD+qcgZBRIETeqY0Vcnc7pGonhRY2l3m2t5upqjq693l2vcy+8N81zz/NcPvf75fd7rjos8ku3yH34HyjK0PqlDLPzD56vMNL0VHxmpgXAoUIZXKgI3sMSpK+cNTAbylaj/9IkprnLM3+mkg8XQi4EsJ4lSL+ZNbAfVd+JG/XLcSERg3M8IAtZauBtDEkeNdN6fX9NfRqXueQiSwm00wQRMDMGw94snBJkqYBrSYIIXs/ojftqGq6IXHZRFIpkKYC2JSw9SJE663W0nthlqcMawwrJYpVCag1M48pNy1YNvLWRffGNIYSCv6Cnog7rjCtVIbUEXoG7qeqaNMj51F58dWoKPZY62JeWyUJG+ctcIplcIizWCpgTl9EIyODJn9BtceDWq/6B57tO/H4R688fFaZ7AWzWAiiJEyMDx39Ed6UDdyy7Ni/w1ekxbP95VJi/F8CRYoGycGLksaEJdFU6cPdy0zxkR/RbtE6FhPvHATQUm2JFODHSfyyCLmsd7lth/hf53q/jcE8OC+NTAG7PTKiNoCqcGPnpF+PotDrwwNXl+OC3H9A8cVqYPgPgFnFo1QCLwomRg4cvoPMGBzZHTgq3zwKwZ+ddKVATXAZhf+gdnPvuojAUqmJdrspRAtQU93pXEM+8clgwhQHU5itruUBNcTt6TsP9sl8weQC0S/VFOUBNcW/2folt2z+XhZPTZh6kSKJ79aqVRuFszRxfUm8sNbdz9xlsfekz2bhCQBvDMMM8z+ubN92Mjrb71brS+97dM4wtnk8U4SSBBEGErVarzeVywePxoHVLA1pb6lUh3+8bwZMv+BTjpIAVACa9Xq+uqakJ7e3tqpGd/WfR3Jr+81awIJS0mY0A+sLhMGw2W3qfGmTXvhAef/6gapxUBDuqqqoejUQiBvFbKUH2DHyNx54bLAqXF0jT9HBjY6Pd6/XOi7oc5K7936Dp2QNF4/IBrTqdLuLxeIi2tracRSGF/PDgKB55er8muHzATQB2m81m+P1+1NbmPoVyIfsOnUOj+2PNcPmAO1iWbeE4TmexWODz+WQhayrL4No2oCkuJ5Bl2VGO49ZmcisXObdeVSuRaq7ZZ3G10KBTqRQl3pQPGY1GEQgE4HQ6heVDAO5S1cklNmUDXQRB9KZSqXkfESaTCW63G7FYDKFQKDEyMoJoNKqfe/bbAJ7QGpcrxa8xDLOV5/k0kGXZv2ZnZ5FMJtNjmqYvURR1IpFInAcwAeD7ud/pUuDmAY1G41g8Hl9DkmScoqggx3FHAIyJMMlSQfI9V5zKagDC93dsoRFKimQx2dIWOV/U/yn6bx0WyDj8vgLOAAAAAElFTkSuQmCC");background-size:100% 100%}.cm-container .cm-mainer .cm-preview .cm-preview-content hr{margin:0;border:none;height:1px;background-color:#e4e7ed;margin-bottom:15px}.cm-container .cm-mainer .cm-preview .cm-preview-content p{line-height:26px;margin:0;margin-bottom:15px}.cm-container .cm-mainer .cm-preview .cm-preview-content blockquote{margin:0;line-height:26px;margin-bottom:15px;background:#ecf8ff;border-left:5px solid #50bfff;color:#50bfff;padding:8px 15px;border-radius:0 4px 4px 0}.cm-container .cm-mainer .cm-preview .cm-preview-content blockquote p{margin:0}.cm-container .cm-mainer .cm-preview .cm-preview-content pre{margin:0;margin-bottom:15px}.cm-container .cm-mainer .cm-preview .cm-preview-content pre::-webkit-scrollbar-track{background:#fff}.cm-container .cm-mainer .cm-preview .cm-preview-content pre::-webkit-scrollbar{width:6px;height:6px}.cm-container .cm-mainer .cm-preview .cm-preview-content pre::-webkit-scrollbar-thumb{border-radius:3px;background:#c0c4cc}.cm-container .cm-mainer .cm-preview .cm-preview-content p code{display:inline-block;min-height:26px;line-height:26px;border-radius:4px;font-size:12px;background:#fdf6ec;padding:0 8px;color:#e6a23c;vertical-align:top}.cm-container .cm-mainer .cm-preview .cm-preview-content ol,.cm-container .cm-mainer .cm-preview .cm-preview-content ul{margin:0;margin-bottom:15px;padding-left:36px}.cm-container .cm-mainer .cm-preview .cm-preview-content ol li,.cm-container .cm-mainer .cm-preview .cm-preview-content ul li{line-height:26px}.cm-container .cm-mainer .cm-preview .cm-preview-content ol li{list-style:decimal}.cm-container .cm-mainer .cm-preview .cm-preview-content ul li{list-style:disc}.cm-container .cm-mainer .cm-preview .cm-preview-content table{width:100%;max-width:100%;table-layout:fixed;color:#909399;margin-bottom:15px;font-size:13px;border-top:1px solid #ebeef5;border-left:1px solid #ebeef5;border-collapse:collapse}.cm-container .cm-mainer .cm-preview .cm-preview-content table td,.cm-container .cm-mainer .cm-preview .cm-preview-content table th{padding:8px;border-bottom:1px solid #ebeef5;border-right:1px solid #ebeef5}.cm-container .cm-mainer .cm-preview .cm-preview-content table thead th{font-weight:500;background:#ebeef5}.cm-container .cm-mainer .cm-preview .cm-preview-content img{display:block;max-width:100%;border-radius:4px;transition:box-shadow 0.35s, -webkit-transform 0.35s;transition:transform 0.35s, box-shadow 0.35s;transition:transform 0.35s, box-shadow 0.35s, -webkit-transform 0.35s;margin:0 auto}.cm-container .cm-mainer .cm-preview .cm-preview-content a{display:inline-block;line-height:26px;color:#409eff;position:relative;text-decoration:none}.cm-container .cm-progress-left{position:absolute;top:0;right:50%;width:0;height:3px;background-color:#ff5627;transition:width 0.5s;z-index:1}.cm-container .cm-progress-right{position:absolute;top:0;left:50%;width:0;height:3px;background-color:#ff5627;transition:width 0.5s;z-index:1}.cm-modal{display:flex;align-items:center;justify-content:center;position:fixed;top:0;left:0;right:0;bottom:0;z-index:9999;background:rgba(0,0,0,0);visibility:hidden;transition:background 0.25s, visibility 0.25s;will-change:background, visibility}.cm-modal__wrapper{width:380px;background:#fff;color:#606266;border-radius:4px;opacity:0;-webkit-transform:translateY(-30%);transform:translateY(-30%);transition:opacity 0.25s, -webkit-transform 0.25s;transition:opacity 0.25s, transform 0.25s;transition:opacity 0.25s, transform 0.25s, -webkit-transform 0.25s}.cm-modal__wrapper-header{padding:10px 20px;border-bottom:1px solid #e4e7ed;display:flex;align-items:center;justify-content:space-between}.cm-modal__wrapper-header--close{font-size:20px;cursor:pointer}.cm-modal__wrapper-bodyer{padding:20px}.cm-modal__wrapper-bodyer .fitem{display:flex;align-items:center;margin-bottom:15px}.cm-modal__wrapper-bodyer .fitem:last-child{margin-bottom:0}.cm-modal__wrapper-bodyer .fitem label{margin-right:10px}.cm-modal__wrapper-bodyer .fitem input{width:auto;flex:1;-webkit-appearance:none;outline:none;border:1px solid #dcdfe6;height:34px;box-sizing:border-box;padding:0 10px;border-radius:3px;color:#606266}.cm-modal__wrapper-bodyer .tabbar{position:relative;width:100%;overflow-x:auto;display:flex;margin-bottom:20px}.cm-modal__wrapper-bodyer .tabbar::-webkit-scrollbar{display:none}.cm-modal__wrapper-bodyer .tabbar-item{white-space:nowrap;margin-right:15px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.cm-modal__wrapper-bodyer .tabbar-item:last-child{margin-right:0}.cm-modal__wrapper-bodyer .tabbar-item.active{color:#409eff}.cm-modal__wrapper-bodyer .lists{display:none;grid-template-columns:repeat(6, 1fr);font-size:18px;border-left:1px solid #e4e7ed;border-top:1px solid #e4e7ed;font-family:'Meiryo UI', 'Microsoft YaHei', 'Malgun Gothic', 'Segoe UI', 'Trebuchet MS', Helvetica, 'Monaco', monospace, Tahoma, STXihei, '华文细黑', STHeiti, 'Helvetica Neue', 'Droid Sans', 'wenquanyi micro hei', FreeSans, Arimo, Arial, SimSun, '宋体', Heiti, '黑体', sans-serif;max-height:380px;overflow-y:auto;-ms-scroll-chaining:none;overscroll-behavior:none}.cm-modal__wrapper-bodyer .lists::-webkit-scrollbar-track{background:#fff}.cm-modal__wrapper-bodyer .lists::-webkit-scrollbar{width:6px;height:6px}.cm-modal__wrapper-bodyer .lists::-webkit-scrollbar-thumb{border-radius:3px;background:#c0c4cc}.cm-modal__wrapper-bodyer .lists.active{display:grid}.cm-modal__wrapper-bodyer .lists-item{display:flex;align-items:center;justify-content:center;border-right:1px solid #e4e7ed;border-bottom:1px solid #e4e7ed;cursor:pointer;transition:background 0.25s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:#888;padding:5px 0}.cm-modal__wrapper-bodyer .lists-item:hover,.cm-modal__wrapper-bodyer .lists-item .active{background:#e4e7ed}.cm-modal__wrapper-footer{display:flex;align-items:center;justify-content:flex-end;padding:0 20px 10px}.cm-modal__wrapper-footer--cancle,.cm-modal__wrapper-footer--confirm{cursor:pointer;border:none;outline:none;margin-left:5px;background:#fff;color:#606266;-webkit-appearance:none;padding:7px 15px;border-radius:3px}.cm-modal__wrapper-footer--confirm{color:#fff;background:#409eff}.cm-modal.active{visibility:visible;background:rgba(0,0,0,0.75)}.cm-modal.active .cm-modal__wrapper{-webkit-transform:translateY(0);transform:translateY(0);opacity:1}@media (max-width: 768px){.cm-modal__wrapper{width:90%}} +input[name='fields[keywords]']{width:100%}textarea[name='fields[description]'],textarea[name='fields[abstract]'],textarea[name='fields[thumb]'],textarea[name='fields[video]']{width:100%;height:80px}#text,#text ~ .resize{display:none}body.fullscreen{overflow:hidden}.cm-container{display:flex;flex-direction:column;position:relative;width:100%;height:550px;box-sizing:border-box;z-index:6666;content-visibility:auto;background:#222}.cm-container.fullscreen{position:fixed;top:0;left:0;width:100%;height:100%}.cm-container *{outline:none !important}.cm-container .cm-tools{display:flex;flex-wrap:wrap;background-color:#303133;padding:5px 0 0 5px}.cm-container .cm-tools .cm-tools-item{position:relative;cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:2px;padding:5px;margin:0 5px 5px 0;transition:background 0.25s}.cm-container .cm-tools .cm-tools-item:hover{background:#393939}.cm-container .cm-tools .cm-tools-item:hover svg{fill:#efefef}.cm-container .cm-tools .cm-tools-item.active{background:#393939}.cm-container .cm-tools .cm-tools-item.active svg{fill:#efefef}.cm-container .cm-tools .cm-tools-item.active .cm-tools__dropdown{visibility:visible;opacity:1;-webkit-transform:translateX(-50%) rotateX(0);transform:translateX(-50%) rotateX(0)}.cm-container .cm-tools .cm-tools-item svg{vertical-align:middle;fill:#bfbfbf}.cm-container .cm-tools__dropdown{position:absolute;top:42px;left:50%;z-index:1000;background:#313335;padding:5px 0;border-radius:4px;visibility:hidden;-webkit-transform-origin:top;transform-origin:top;opacity:0;-webkit-transform:translateX(-50%) rotateX(-90deg);transform:translateX(-50%) rotateX(-90deg);transition:visibility 0.25s, opacity 0.25s, -webkit-transform 0.25s;transition:visibility 0.25s, transform 0.25s, opacity 0.25s;transition:visibility 0.25s, transform 0.25s, opacity 0.25s, -webkit-transform 0.25s}.cm-container .cm-tools__dropdown-item{padding:0 20px;line-height:32px;transition:background 0.25s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;font-size:15px;color:#bfbfbf;font-weight:600}.cm-container .cm-tools__dropdown-item:hover{background:#393939}.cm-container .cm-tools__dropdown::before{content:'';position:absolute;top:-7px;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);width:0;height:0;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #313335}.cm-container .cm-mainer{flex:1;min-height:0;display:flex;width:100%}.cm-container .cm-mainer .cm-wrap{flex-shrink:0;height:100%;flex:1;min-width:0;font-size:14px}.cm-container .cm-mainer .cm-wrap .cm-scroller{line-height:1.5;font-family:Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;-ms-scroll-chaining:none;overscroll-behavior:none}.cm-container .cm-mainer .cm-wrap .cm-scroller::-webkit-scrollbar{display:none}.cm-container .cm-mainer .cm-wrap .cm-scroller ::-moz-selection{background-color:rgba(221,240,255,0.2)}.cm-container .cm-mainer .cm-wrap .cm-scroller ::selection{background-color:rgba(221,240,255,0.2)}.cm-container .cm-mainer .cm-wrap .cm-scroller .cm-content{width:100%;white-space:pre-wrap;overflow-wrap:break-word;color:#ccc;caret-color:#ccc;padding:15px 13px 15px 11px;-webkit-user-modify:read-write-plaintext-only}.cm-container .cm-mainer .cm-wrap .cm-scroller .cm-matchingBracket{color:#8f938f;border:1px solid rgba(255,255,255,0.25);margin:-1px}.cm-container .cm-mainer .cm-wrap .cm-scroller .cm-nonmatchingBracket{color:#ff5627}.cm-container .cm-mainer .cm-resize{flex-shrink:0;height:100%;position:relative;width:16px;background:#303133;cursor:col-resize}.cm-container .cm-mainer .cm-resize::before{content:'';position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);width:4px;height:40px;border-radius:2px;background:#fff}.cm-container .cm-mainer .cm-preview{position:relative;flex-shrink:0;width:0;height:100%;background:#fff;overflow:auto;box-sizing:border-box;-ms-scroll-chaining:none;overscroll-behavior:none}.cm-container .cm-mainer .cm-preview::-webkit-scrollbar-track{background:#fff}.cm-container .cm-mainer .cm-preview::-webkit-scrollbar{width:6px;height:6px}.cm-container .cm-mainer .cm-preview::-webkit-scrollbar-thumb{border-radius:3px;background:#c0c4cc}.cm-container .cm-mainer .cm-preview .cm-preview-content{padding:20px;font-size:14px;font-family:'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;white-space:pre-wrap;overflow-wrap:break-word;color:#606266;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.cm-container .cm-mainer .cm-preview .cm-preview-content h1,.cm-container .cm-mainer .cm-preview .cm-preview-content h2,.cm-container .cm-mainer .cm-preview .cm-preview-content h3,.cm-container .cm-mainer .cm-preview .cm-preview-content h4,.cm-container .cm-mainer .cm-preview .cm-preview-content h5,.cm-container .cm-mainer .cm-preview .cm-preview-content h6{color:#303133;font-size:18px;line-height:24px;margin:0;margin-bottom:15px;position:relative}.cm-container .cm-mainer .cm-preview .cm-preview-content h1{padding:0 15px}.cm-container .cm-mainer .cm-preview .cm-preview-content h1::before{content:'';position:absolute;top:8.5px;left:0;height:7px;width:7px;border-radius:50%;background:#409eff}.cm-container .cm-mainer .cm-preview .cm-preview-content h2{padding:0 15px}.cm-container .cm-mainer .cm-preview .cm-preview-content h2::before{content:'';position:absolute;top:10%;bottom:10%;left:0;width:4px;border-radius:2px;background:#409eff}.cm-container .cm-mainer .cm-preview .cm-preview-content h3{padding:0 15px 0 20px}.cm-container .cm-mainer .cm-preview .cm-preview-content h3::before{content:'#';color:#409eff;font-weight:700;position:absolute;top:0;left:0;line-height:24px}.cm-container .cm-mainer .cm-preview .cm-preview-content h4::before{content:'「';color:#409eff;font-weight:600;margin-right:5px}.cm-container .cm-mainer .cm-preview .cm-preview-content h4::after{content:'」';color:#409eff;font-weight:600;margin-left:5px}.cm-container .cm-mainer .cm-preview .cm-preview-content h5{padding:0 15px 0 28px}.cm-container .cm-mainer .cm-preview .cm-preview-content h5::before{content:'';position:absolute;top:2px;left:0;width:20px;height:20px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAC8klEQVRYR+3WP2gTURwH8O/vKnVRRHKXP52cBO3g4p/BqYNIhy4muajUQRBFKjQV1En6ZxJBcmlRCoJDRe3FDiJVwamLS3FwqbgIgss1l2ZQF5XeT3I1Z3NJ7u5dLlAwN9699/t97vfe7/EIO/yhHe5DD9jpCv3fFVTu856+Xzi62Y/35hj9CFPNrlUwWeRJAJfBGADwBcBNI0/PRZFdAdo4xlQLjCqKjBzogat7hZCRAgPghJGBgbFnxglAOvS7b/fLb+q+qnv5BHBCyEBAWTdnANy2IxOtWSC1qsY+1jOFwAVG+gIVvXyHQbcaKuZCxmf5iMQogXFQtEsBeO5JT6BcMu+Bcb1lUhcyqfExACUAB6JEtgUqi+U5JrrmmcyFHCjwSYtQO+tSUSFbAmXdnAdwJVASdyWLPAS2kbFA8xsHNS13EzCmlx8R6KJQcBcypfFpho3cKxRna3ADsgEo6+ZjAKMhgjZ1d2KWR2gTSyD0h4jnIB2gXDIXwciFCPZvSnMl0wwshYrJGDImaMUGKovlLBPVOrDjh8APzFx8zDkjNa7FzYoGZsKT9XEarQOHmei1aJA246cqOWW6/i2l8VMGzoWIPW/k6eq2Ja6UwCz8pw2JGZ8sS8pUz8fWau/jGp+SgLchcGBgZD1Py41NUuoI+ZloV8ZU93+ogZKzfBiWfXAPCgMJU8Y42avQdMzI4ZBfmSizocqrUeJaAmsvBZGGBCtTziXeRY1rCxRAViEhXckqK93AeQJ9kYTvlmVlqmcTdhNEtefc+9X3utVmuX+CkK6oyqtu4nwrWP8bF5IZdGYjJ79wDuMCz4D+XmhFWnZbt7ab5ltBB6mbkyAaBPFCJassuwMmNb4L4EZgXwBc4AoGTZrUeA6A9x1yK6tzzvnFDlxBv0D176kCP2TCpbbjBXCRV9DZk0VeAONCE1IQ1zWg3dlF1sFQHWQIXFeBNrLAw5BwHBZWjQl6E3SbbB8X+R4Mg/Ca0wN2WtFeBTut4B84mFI4VpekyAAAAABJRU5ErkJggg==");background-size:100% 100%}.cm-container .cm-mainer .cm-preview .cm-preview-content h6{padding:0 15px 0 28px}.cm-container .cm-mainer .cm-preview .cm-preview-content h6::before{content:'';position:absolute;top:2px;left:0;width:20px;height:20px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAEI0lEQVRYR+3Xb2wTZRwH8G/vL22RPy5GW8fK6rJpGeFFY9RO3TRRE1HfmEAammEyjZmOSEg1RrPZaTD6xjhU/Ndlf0CZgwmD+qcgZBRIETeqY0Vcnc7pGonhRY2l3m2t5upqjq693l2vcy+8N81zz/NcPvf75fd7rjos8ku3yH34HyjK0PqlDLPzD56vMNL0VHxmpgXAoUIZXKgI3sMSpK+cNTAbylaj/9IkprnLM3+mkg8XQi4EsJ4lSL+ZNbAfVd+JG/XLcSERg3M8IAtZauBtDEkeNdN6fX9NfRqXueQiSwm00wQRMDMGw94snBJkqYBrSYIIXs/ojftqGq6IXHZRFIpkKYC2JSw9SJE663W0nthlqcMawwrJYpVCag1M48pNy1YNvLWRffGNIYSCv6Cnog7rjCtVIbUEXoG7qeqaNMj51F58dWoKPZY62JeWyUJG+ctcIplcIizWCpgTl9EIyODJn9BtceDWq/6B57tO/H4R688fFaZ7AWzWAiiJEyMDx39Ed6UDdyy7Ni/w1ekxbP95VJi/F8CRYoGycGLksaEJdFU6cPdy0zxkR/RbtE6FhPvHATQUm2JFODHSfyyCLmsd7lth/hf53q/jcE8OC+NTAG7PTKiNoCqcGPnpF+PotDrwwNXl+OC3H9A8cVqYPgPgFnFo1QCLwomRg4cvoPMGBzZHTgq3zwKwZ+ddKVATXAZhf+gdnPvuojAUqmJdrspRAtQU93pXEM+8clgwhQHU5itruUBNcTt6TsP9sl8weQC0S/VFOUBNcW/2folt2z+XhZPTZh6kSKJ79aqVRuFszRxfUm8sNbdz9xlsfekz2bhCQBvDMMM8z+ubN92Mjrb71brS+97dM4wtnk8U4SSBBEGErVarzeVywePxoHVLA1pb6lUh3+8bwZMv+BTjpIAVACa9Xq+uqakJ7e3tqpGd/WfR3Jr+81awIJS0mY0A+sLhMGw2W3qfGmTXvhAef/6gapxUBDuqqqoejUQiBvFbKUH2DHyNx54bLAqXF0jT9HBjY6Pd6/XOi7oc5K7936Dp2QNF4/IBrTqdLuLxeIi2tracRSGF/PDgKB55er8muHzATQB2m81m+P1+1NbmPoVyIfsOnUOj+2PNcPmAO1iWbeE4TmexWODz+WQhayrL4No2oCkuJ5Bl2VGO49ZmcisXObdeVSuRaq7ZZ3G10KBTqRQl3pQPGY1GEQgE4HQ6heVDAO5S1cklNmUDXQRB9KZSqXkfESaTCW63G7FYDKFQKDEyMoJoNKqfe/bbAJ7QGpcrxa8xDLOV5/k0kGXZv2ZnZ5FMJtNjmqYvURR1IpFInAcwAeD7ud/pUuDmAY1G41g8Hl9DkmScoqggx3FHAIyJMMlSQfI9V5zKagDC93dsoRFKimQx2dIWOV/U/yn6bx0WyDj8vgLOAAAAAElFTkSuQmCC");background-size:100% 100%}.cm-container .cm-mainer .cm-preview .cm-preview-content hr{margin:0;border:none;height:1px;background-color:#e4e7ed;margin-bottom:15px}.cm-container .cm-mainer .cm-preview .cm-preview-content p{line-height:26px;margin:0;margin-bottom:15px}.cm-container .cm-mainer .cm-preview .cm-preview-content blockquote{margin:0;line-height:26px;margin-bottom:15px;background:#ecf8ff;border-left:5px solid #50bfff;color:#50bfff;padding:8px 15px;border-radius:0 4px 4px 0}.cm-container .cm-mainer .cm-preview .cm-preview-content blockquote p{margin:0}.cm-container .cm-mainer .cm-preview .cm-preview-content pre{margin:0;margin-bottom:15px}.cm-container .cm-mainer .cm-preview .cm-preview-content pre::-webkit-scrollbar-track{background:#fff}.cm-container .cm-mainer .cm-preview .cm-preview-content pre::-webkit-scrollbar{width:6px;height:6px}.cm-container .cm-mainer .cm-preview .cm-preview-content pre::-webkit-scrollbar-thumb{border-radius:3px;background:#c0c4cc}.cm-container .cm-mainer .cm-preview .cm-preview-content p code{display:inline-block;min-height:26px;line-height:26px;border-radius:4px;font-size:12px;background:#fdf6ec;padding:0 8px;color:#e6a23c;vertical-align:top}.cm-container .cm-mainer .cm-preview .cm-preview-content ol,.cm-container .cm-mainer .cm-preview .cm-preview-content ul{margin:0;margin-bottom:15px;padding-left:36px}.cm-container .cm-mainer .cm-preview .cm-preview-content ol li,.cm-container .cm-mainer .cm-preview .cm-preview-content ul li{line-height:26px}.cm-container .cm-mainer .cm-preview .cm-preview-content ol li{list-style:decimal}.cm-container .cm-mainer .cm-preview .cm-preview-content ul li{list-style:disc}.cm-container .cm-mainer .cm-preview .cm-preview-content table{width:100%;max-width:100%;table-layout:fixed;color:#909399;margin-bottom:15px;font-size:13px;border-top:1px solid #ebeef5;border-left:1px solid #ebeef5;border-collapse:collapse}.cm-container .cm-mainer .cm-preview .cm-preview-content table td,.cm-container .cm-mainer .cm-preview .cm-preview-content table th{padding:8px;border-bottom:1px solid #ebeef5;border-right:1px solid #ebeef5}.cm-container .cm-mainer .cm-preview .cm-preview-content table thead th{font-weight:500;background:#ebeef5}.cm-container .cm-mainer .cm-preview .cm-preview-content img{display:block;max-width:100%;border-radius:4px;transition:box-shadow 0.35s, -webkit-transform 0.35s;transition:transform 0.35s, box-shadow 0.35s;transition:transform 0.35s, box-shadow 0.35s, -webkit-transform 0.35s;margin:0 auto}.cm-container .cm-mainer .cm-preview .cm-preview-content a{display:inline-block;line-height:26px;color:#409eff;position:relative;text-decoration:none}.cm-container .cm-mainer .cm-preview .cm-preview-content .task{-webkit-appearance:none;position:relative;border-radius:2px;width:15px;height:15px;border:2px solid #409eff;vertical-align:-3px;box-sizing:border-box;margin:0}.cm-container .cm-mainer .cm-preview .cm-preview-content .task:disabled{cursor:not-allowed}.cm-container .cm-mainer .cm-preview .cm-preview-content .task:checked{border:none;background:#409eff}.cm-container .cm-mainer .cm-preview .cm-preview-content .task:checked::after{content:'';width:3px;height:7px;position:absolute;top:2px;left:5px;border:2px solid #fff;border-top:0;border-left:0;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.cm-container .cm-progress-left{position:absolute;top:0;right:50%;width:0;height:3px;background-color:#ff5627;transition:width 0.5s;z-index:1}.cm-container .cm-progress-right{position:absolute;top:0;left:50%;width:0;height:3px;background-color:#ff5627;transition:width 0.5s;z-index:1}.cm-modal{display:flex;align-items:center;justify-content:center;position:fixed;top:0;left:0;right:0;bottom:0;z-index:9999;background:rgba(0,0,0,0);visibility:hidden;transition:background 0.25s, visibility 0.25s;will-change:background, visibility}.cm-modal__wrapper{width:380px;background:#fff;color:#606266;border-radius:4px;opacity:0;-webkit-transform:translateY(-30%);transform:translateY(-30%);transition:opacity 0.25s, -webkit-transform 0.25s;transition:opacity 0.25s, transform 0.25s;transition:opacity 0.25s, transform 0.25s, -webkit-transform 0.25s}.cm-modal__wrapper-header{padding:10px 20px;border-bottom:1px solid #e4e7ed;display:flex;align-items:center;justify-content:space-between}.cm-modal__wrapper-header--close{font-size:20px;cursor:pointer}.cm-modal__wrapper-bodyer{padding:20px}.cm-modal__wrapper-bodyer .fitem{display:flex;align-items:center;margin-bottom:15px}.cm-modal__wrapper-bodyer .fitem:last-child{margin-bottom:0}.cm-modal__wrapper-bodyer .fitem label{margin-right:10px}.cm-modal__wrapper-bodyer .fitem input{width:auto;flex:1;-webkit-appearance:none;outline:none;border:1px solid #dcdfe6;height:34px;box-sizing:border-box;padding:0 10px;border-radius:3px;color:#606266}.cm-modal__wrapper-bodyer .tabbar{position:relative;width:100%;overflow-x:auto;display:flex;margin-bottom:20px}.cm-modal__wrapper-bodyer .tabbar::-webkit-scrollbar{display:none}.cm-modal__wrapper-bodyer .tabbar-item{white-space:nowrap;margin-right:15px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.cm-modal__wrapper-bodyer .tabbar-item:last-child{margin-right:0}.cm-modal__wrapper-bodyer .tabbar-item.active{color:#409eff}.cm-modal__wrapper-bodyer .lists{display:none;grid-template-columns:repeat(6, 1fr);font-size:18px;border-left:1px solid #e4e7ed;border-top:1px solid #e4e7ed;font-family:'Meiryo UI', 'Microsoft YaHei', 'Malgun Gothic', 'Segoe UI', 'Trebuchet MS', Helvetica, 'Monaco', monospace, Tahoma, STXihei, '华文细黑', STHeiti, 'Helvetica Neue', 'Droid Sans', 'wenquanyi micro hei', FreeSans, Arimo, Arial, SimSun, '宋体', Heiti, '黑体', sans-serif;max-height:350px;overflow-y:auto;-ms-scroll-chaining:none;overscroll-behavior:none}.cm-modal__wrapper-bodyer .lists::-webkit-scrollbar-track{background:#fff}.cm-modal__wrapper-bodyer .lists::-webkit-scrollbar{width:6px;height:6px}.cm-modal__wrapper-bodyer .lists::-webkit-scrollbar-thumb{border-radius:3px;background:#c0c4cc}.cm-modal__wrapper-bodyer .lists.active{display:grid}.cm-modal__wrapper-bodyer .lists-item{display:flex;align-items:center;justify-content:center;border-right:1px solid #e4e7ed;border-bottom:1px solid #e4e7ed;cursor:pointer;transition:background 0.25s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:#888;padding:5px 0}.cm-modal__wrapper-bodyer .lists-item:hover,.cm-modal__wrapper-bodyer .lists-item .active{background:#e4e7ed}.cm-modal__wrapper-footer{display:flex;align-items:center;justify-content:flex-end;padding:0 20px 10px}.cm-modal__wrapper-footer--cancle,.cm-modal__wrapper-footer--confirm{cursor:pointer;border:none;outline:none;margin-left:5px;background:#fff;color:#606266;-webkit-appearance:none;padding:7px 15px;border-radius:3px}.cm-modal__wrapper-footer--confirm{color:#fff;background:#409eff}.cm-modal.active{visibility:visible;background:rgba(0,0,0,0.75)}.cm-modal.active .cm-modal__wrapper{-webkit-transform:translateY(0);transform:translateY(0);opacity:1}@media (max-width: 768px){.cm-modal__wrapper{width:90%}} diff --git a/typecho/write/css/joe.write.min.scss b/typecho/write/css/joe.write.min.scss index d870d85..9ac5f87 100644 --- a/typecho/write/css/joe.write.min.scss +++ b/typecho/write/css/joe.write.min.scss @@ -1,584 +1,614 @@ input[name='fields[keywords]'] { - width: 100%; + width: 100%; } textarea[name='fields[description]'], textarea[name='fields[abstract]'], textarea[name='fields[thumb]'], textarea[name='fields[video]'] { - width: 100%; - height: 80px; + width: 100%; + height: 80px; } #text, #text ~ .resize { - display: none; + display: none; } body.fullscreen { - overflow: hidden; + overflow: hidden; } .cm-container { - display: flex; - flex-direction: column; - position: relative; - width: 100%; - height: 550px; - box-sizing: border-box; - z-index: 6666; - content-visibility: auto; - background: #222; - &.fullscreen { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - } - * { - outline: none !important; - } - .cm-tools { - display: flex; - flex-wrap: wrap; - background-color: #303133; - padding: 5px 0 0 5px; - .cm-tools-item { - position: relative; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - border-radius: 2px; - padding: 5px; - margin: 0 5px 5px 0; - transition: background 0.25s; - &:hover { - background: #393939; - svg { - fill: #efefef; - } - } - &.active { - background: #393939; - svg { - fill: #efefef; - } - .cm-tools__dropdown { - visibility: visible; - opacity: 1; - transform: translateX(-50%) rotateX(0); - } - } - svg { - vertical-align: middle; - fill: #bfbfbf; - } - } - &__dropdown { - position: absolute; - top: 42px; - left: 50%; - z-index: 1000; - background: #313335; - padding: 5px 0; - border-radius: 4px; - visibility: hidden; - transform-origin: top; - opacity: 0; - transform: translateX(-50%) rotateX(-90deg); - transition: visibility 0.25s, transform 0.25s, opacity 0.25s; - &-item { - padding: 0 20px; - line-height: 32px; - transition: background 0.25s; - user-select: none; - font-size: 15px; - color: #bfbfbf; - font-weight: 600; - &:hover { - background: #393939; - } - } - &::before { - content: ''; - position: absolute; - top: -7px; - left: 50%; - transform: translateX(-50%); - width: 0; - height: 0; - border-left: 7px solid transparent; - border-right: 7px solid transparent; - border-bottom: 7px solid #313335; - } - } - } - .cm-mainer { - flex: 1; - min-height: 0; - display: flex; - width: 100%; - .cm-wrap { - flex-shrink: 0; - height: 100%; - flex: 1; - min-width: 0; - font-size: 14px; - .cm-scroller { - line-height: 1.5; - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; - overscroll-behavior: none; - &::-webkit-scrollbar { - display: none; - } - ::selection { - background-color: rgba(221, 240, 255, 0.2); - } - .cm-content { - width: 100%; - white-space: pre-wrap; - overflow-wrap: break-word; - color: #ccc; - caret-color: #ccc; - padding: 15px 13px 15px 11px; - -webkit-user-modify: read-write-plaintext-only; - } - .cm-matchingBracket { - color: #8f938f; - border: 1px solid rgba(255, 255, 255, 0.25); - margin: -1px; - } - .cm-nonmatchingBracket { - color: #ff5627; - } - } - } - .cm-resize { - flex-shrink: 0; - height: 100%; - position: relative; - width: 16px; - background: #303133; - cursor: col-resize; - &::before { - content: ''; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - width: 4px; - height: 40px; - border-radius: 2px; - background: #fff; - } - } - .cm-preview { - position: relative; - flex-shrink: 0; - width: 0; - height: 100%; - background: #fff; - overflow: auto; - box-sizing: border-box; - overscroll-behavior: none; - &::-webkit-scrollbar-track { - background: #fff; - } - &::-webkit-scrollbar { - width: 6px; - height: 6px; - } - &::-webkit-scrollbar-thumb { - border-radius: 3px; - background: #c0c4cc; - } - .cm-preview-content { - padding: 20px; - font-size: 14px; - font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif; - white-space: pre-wrap; - overflow-wrap: break-word; - color: #606266; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - h1, - h2, - h3, - h4, - h5, - h6 { - color: #303133; - font-size: 18px; - line-height: 24px; + display: flex; + flex-direction: column; + position: relative; + width: 100%; + height: 550px; + box-sizing: border-box; + z-index: 6666; + content-visibility: auto; + background: #222; + &.fullscreen { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + } + * { + outline: none !important; + } + .cm-tools { + display: flex; + flex-wrap: wrap; + background-color: #303133; + padding: 5px 0 0 5px; + .cm-tools-item { + position: relative; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + border-radius: 2px; + padding: 5px; + margin: 0 5px 5px 0; + transition: background 0.25s; + &:hover { + background: #393939; + svg { + fill: #efefef; + } + } + &.active { + background: #393939; + svg { + fill: #efefef; + } + .cm-tools__dropdown { + visibility: visible; + opacity: 1; + transform: translateX(-50%) rotateX(0); + } + } + svg { + vertical-align: middle; + fill: #bfbfbf; + } + } + &__dropdown { + position: absolute; + top: 42px; + left: 50%; + z-index: 1000; + background: #313335; + padding: 5px 0; + border-radius: 4px; + visibility: hidden; + transform-origin: top; + opacity: 0; + transform: translateX(-50%) rotateX(-90deg); + transition: visibility 0.25s, transform 0.25s, opacity 0.25s; + &-item { + padding: 0 20px; + line-height: 32px; + transition: background 0.25s; + user-select: none; + font-size: 15px; + color: #bfbfbf; + font-weight: 600; + &:hover { + background: #393939; + } + } + &::before { + content: ''; + position: absolute; + top: -7px; + left: 50%; + transform: translateX(-50%); + width: 0; + height: 0; + border-left: 7px solid transparent; + border-right: 7px solid transparent; + border-bottom: 7px solid #313335; + } + } + } + .cm-mainer { + flex: 1; + min-height: 0; + display: flex; + width: 100%; + .cm-wrap { + flex-shrink: 0; + height: 100%; + flex: 1; + min-width: 0; + font-size: 14px; + .cm-scroller { + line-height: 1.5; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + overscroll-behavior: none; + &::-webkit-scrollbar { + display: none; + } + ::selection { + background-color: rgba(221, 240, 255, 0.2); + } + .cm-content { + width: 100%; + white-space: pre-wrap; + overflow-wrap: break-word; + color: #ccc; + caret-color: #ccc; + padding: 15px 13px 15px 11px; + -webkit-user-modify: read-write-plaintext-only; + } + .cm-matchingBracket { + color: #8f938f; + border: 1px solid rgba(255, 255, 255, 0.25); + margin: -1px; + } + .cm-nonmatchingBracket { + color: #ff5627; + } + } + } + .cm-resize { + flex-shrink: 0; + height: 100%; + position: relative; + width: 16px; + background: #303133; + cursor: col-resize; + &::before { + content: ''; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 4px; + height: 40px; + border-radius: 2px; + background: #fff; + } + } + .cm-preview { + position: relative; + flex-shrink: 0; + width: 0; + height: 100%; + background: #fff; + overflow: auto; + box-sizing: border-box; + overscroll-behavior: none; + &::-webkit-scrollbar-track { + background: #fff; + } + &::-webkit-scrollbar { + width: 6px; + height: 6px; + } + &::-webkit-scrollbar-thumb { + border-radius: 3px; + background: #c0c4cc; + } + .cm-preview-content { + padding: 20px; + font-size: 14px; + font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif; + white-space: pre-wrap; + overflow-wrap: break-word; + color: #606266; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + h1, + h2, + h3, + h4, + h5, + h6 { + color: #303133; + font-size: 18px; + line-height: 24px; + margin: 0; + margin-bottom: 15px; + position: relative; + } + h1 { + padding: 0 15px; + &::before { + content: ''; + position: absolute; + top: 8.5px; + left: 0; + height: 7px; + width: 7px; + border-radius: 50%; + background: #409eff; + } + } + h2 { + padding: 0 15px; + &::before { + content: ''; + position: absolute; + top: 10%; + bottom: 10%; + left: 0; + width: 4px; + border-radius: 2px; + background: #409eff; + } + } + h3 { + padding: 0 15px 0 20px; + &::before { + content: '#'; + color: #409eff; + font-weight: 700; + position: absolute; + top: 0; + left: 0; + line-height: 24px; + } + } + h4 { + &::before { + content: '「'; + color: #409eff; + font-weight: 600; + margin-right: 5px; + } + &::after { + content: '」'; + color: #409eff; + font-weight: 600; + margin-left: 5px; + } + } + h5 { + padding: 0 15px 0 28px; + &::before { + content: ''; + position: absolute; + top: 2px; + left: 0; + width: 20px; + height: 20px; + background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAC8klEQVRYR+3WP2gTURwH8O/vKnVRRHKXP52cBO3g4p/BqYNIhy4muajUQRBFKjQV1En6ZxJBcmlRCoJDRe3FDiJVwamLS3FwqbgIgss1l2ZQF5XeT3I1Z3NJ7u5dLlAwN9699/t97vfe7/EIO/yhHe5DD9jpCv3fFVTu856+Xzi62Y/35hj9CFPNrlUwWeRJAJfBGADwBcBNI0/PRZFdAdo4xlQLjCqKjBzogat7hZCRAgPghJGBgbFnxglAOvS7b/fLb+q+qnv5BHBCyEBAWTdnANy2IxOtWSC1qsY+1jOFwAVG+gIVvXyHQbcaKuZCxmf5iMQogXFQtEsBeO5JT6BcMu+Bcb1lUhcyqfExACUAB6JEtgUqi+U5JrrmmcyFHCjwSYtQO+tSUSFbAmXdnAdwJVASdyWLPAS2kbFA8xsHNS13EzCmlx8R6KJQcBcypfFpho3cKxRna3ADsgEo6+ZjAKMhgjZ1d2KWR2gTSyD0h4jnIB2gXDIXwciFCPZvSnMl0wwshYrJGDImaMUGKovlLBPVOrDjh8APzFx8zDkjNa7FzYoGZsKT9XEarQOHmei1aJA246cqOWW6/i2l8VMGzoWIPW/k6eq2Ja6UwCz8pw2JGZ8sS8pUz8fWau/jGp+SgLchcGBgZD1Py41NUuoI+ZloV8ZU93+ogZKzfBiWfXAPCgMJU8Y42avQdMzI4ZBfmSizocqrUeJaAmsvBZGGBCtTziXeRY1rCxRAViEhXckqK93AeQJ9kYTvlmVlqmcTdhNEtefc+9X3utVmuX+CkK6oyqtu4nwrWP8bF5IZdGYjJ79wDuMCz4D+XmhFWnZbt7ab5ltBB6mbkyAaBPFCJassuwMmNb4L4EZgXwBc4AoGTZrUeA6A9x1yK6tzzvnFDlxBv0D176kCP2TCpbbjBXCRV9DZk0VeAONCE1IQ1zWg3dlF1sFQHWQIXFeBNrLAw5BwHBZWjQl6E3SbbB8X+R4Mg/Ca0wN2WtFeBTut4B84mFI4VpekyAAAAABJRU5ErkJggg=='); + background-size: 100% 100%; + } + } + h6 { + padding: 0 15px 0 28px; + &::before { + content: ''; + position: absolute; + top: 2px; + left: 0; + width: 20px; + height: 20px; + background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAEI0lEQVRYR+3Xb2wTZRwH8G/vL22RPy5GW8fK6rJpGeFFY9RO3TRRE1HfmEAammEyjZmOSEg1RrPZaTD6xjhU/Ndlf0CZgwmD+qcgZBRIETeqY0Vcnc7pGonhRY2l3m2t5upqjq693l2vcy+8N81zz/NcPvf75fd7rjos8ku3yH34HyjK0PqlDLPzD56vMNL0VHxmpgXAoUIZXKgI3sMSpK+cNTAbylaj/9IkprnLM3+mkg8XQi4EsJ4lSL+ZNbAfVd+JG/XLcSERg3M8IAtZauBtDEkeNdN6fX9NfRqXueQiSwm00wQRMDMGw94snBJkqYBrSYIIXs/ojftqGq6IXHZRFIpkKYC2JSw9SJE663W0nthlqcMawwrJYpVCag1M48pNy1YNvLWRffGNIYSCv6Cnog7rjCtVIbUEXoG7qeqaNMj51F58dWoKPZY62JeWyUJG+ctcIplcIizWCpgTl9EIyODJn9BtceDWq/6B57tO/H4R688fFaZ7AWzWAiiJEyMDx39Ed6UDdyy7Ni/w1ekxbP95VJi/F8CRYoGycGLksaEJdFU6cPdy0zxkR/RbtE6FhPvHATQUm2JFODHSfyyCLmsd7lth/hf53q/jcE8OC+NTAG7PTKiNoCqcGPnpF+PotDrwwNXl+OC3H9A8cVqYPgPgFnFo1QCLwomRg4cvoPMGBzZHTgq3zwKwZ+ddKVATXAZhf+gdnPvuojAUqmJdrspRAtQU93pXEM+8clgwhQHU5itruUBNcTt6TsP9sl8weQC0S/VFOUBNcW/2folt2z+XhZPTZh6kSKJ79aqVRuFszRxfUm8sNbdz9xlsfekz2bhCQBvDMMM8z+ubN92Mjrb71brS+97dM4wtnk8U4SSBBEGErVarzeVywePxoHVLA1pb6lUh3+8bwZMv+BTjpIAVACa9Xq+uqakJ7e3tqpGd/WfR3Jr+81awIJS0mY0A+sLhMGw2W3qfGmTXvhAef/6gapxUBDuqqqoejUQiBvFbKUH2DHyNx54bLAqXF0jT9HBjY6Pd6/XOi7oc5K7936Dp2QNF4/IBrTqdLuLxeIi2tracRSGF/PDgKB55er8muHzATQB2m81m+P1+1NbmPoVyIfsOnUOj+2PNcPmAO1iWbeE4TmexWODz+WQhayrL4No2oCkuJ5Bl2VGO49ZmcisXObdeVSuRaq7ZZ3G10KBTqRQl3pQPGY1GEQgE4HQ6heVDAO5S1cklNmUDXQRB9KZSqXkfESaTCW63G7FYDKFQKDEyMoJoNKqfe/bbAJ7QGpcrxa8xDLOV5/k0kGXZv2ZnZ5FMJtNjmqYvURR1IpFInAcwAeD7ud/pUuDmAY1G41g8Hl9DkmScoqggx3FHAIyJMMlSQfI9V5zKagDC93dsoRFKimQx2dIWOV/U/yn6bx0WyDj8vgLOAAAAAElFTkSuQmCC'); + background-size: 100% 100%; + } + } + hr { + margin: 0; + border: none; + height: 1px; + background-color: #e4e7ed; + margin-bottom: 15px; + } + p { + line-height: 26px; + margin: 0; + margin-bottom: 15px; + } + blockquote { + margin: 0; + line-height: 26px; + margin-bottom: 15px; + background: #ecf8ff; + border-left: 5px solid #50bfff; + color: #50bfff; + padding: 8px 15px; + border-radius: 0 4px 4px 0; + p { + margin: 0; + } + } + pre { + margin: 0; + margin-bottom: 15px; + &::-webkit-scrollbar-track { + background: #fff; + } + &::-webkit-scrollbar { + width: 6px; + height: 6px; + } + &::-webkit-scrollbar-thumb { + border-radius: 3px; + background: #c0c4cc; + } + } + p code { + display: inline-block; + min-height: 26px; + line-height: 26px; + border-radius: 4px; + font-size: 12px; + background: #fdf6ec; + padding: 0 8px; + color: #e6a23c; + vertical-align: top; + } + ol, + ul { + margin: 0; + margin-bottom: 15px; + padding-left: 36px; + li { + line-height: 26px; + } + } + ol li { + list-style: decimal; + } + ul li { + list-style: disc; + } + table { + width: 100%; + max-width: 100%; + table-layout: fixed; + color: #909399; + margin-bottom: 15px; + font-size: 13px; + border-top: 1px solid #ebeef5; + border-left: 1px solid #ebeef5; + border-collapse: collapse; + td, + th { + padding: 8px; + border-bottom: 1px solid #ebeef5; + border-right: 1px solid #ebeef5; + } + thead { + th { + font-weight: 500; + background: #ebeef5; + } + } + } + img { + display: block; + max-width: 100%; + border-radius: 4px; + transition: transform 0.35s, box-shadow 0.35s; + margin: 0 auto; + } + a { + display: inline-block; + line-height: 26px; + color: #409eff; + position: relative; + text-decoration: none; + } + .task { + -webkit-appearance: none; + position: relative; + border-radius: 2px; + width: 15px; + height: 15px; + border: 2px solid #409eff; + vertical-align: -3px; + box-sizing: border-box; margin: 0; - margin-bottom: 15px; - position: relative; - } - h1 { - padding: 0 15px; - &::before { - content: ''; - position: absolute; - top: 8.5px; - left: 0; - height: 7px; - width: 7px; - border-radius: 50%; - background: #409eff; - } - } - h2 { - padding: 0 15px; - &::before { - content: ''; - position: absolute; - top: 10%; - bottom: 10%; - left: 0; - width: 4px; - border-radius: 2px; - background: #409eff; - } - } - h3 { - padding: 0 15px 0 20px; - &::before { - content: '#'; - color: #409eff; - font-weight: 700; - position: absolute; - top: 0; - left: 0; - line-height: 24px; - } - } - h4 { - &::before { - content: '「'; - color: #409eff; - font-weight: 600; - margin-right: 5px; - } - &::after { - content: '」'; - color: #409eff; - font-weight: 600; - margin-left: 5px; - } - } - h5 { - padding: 0 15px 0 28px; - &::before { - content: ''; - position: absolute; - top: 2px; - left: 0; - width: 20px; - height: 20px; - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAC8klEQVRYR+3WP2gTURwH8O/vKnVRRHKXP52cBO3g4p/BqYNIhy4muajUQRBFKjQV1En6ZxJBcmlRCoJDRe3FDiJVwamLS3FwqbgIgss1l2ZQF5XeT3I1Z3NJ7u5dLlAwN9699/t97vfe7/EIO/yhHe5DD9jpCv3fFVTu856+Xzi62Y/35hj9CFPNrlUwWeRJAJfBGADwBcBNI0/PRZFdAdo4xlQLjCqKjBzogat7hZCRAgPghJGBgbFnxglAOvS7b/fLb+q+qnv5BHBCyEBAWTdnANy2IxOtWSC1qsY+1jOFwAVG+gIVvXyHQbcaKuZCxmf5iMQogXFQtEsBeO5JT6BcMu+Bcb1lUhcyqfExACUAB6JEtgUqi+U5JrrmmcyFHCjwSYtQO+tSUSFbAmXdnAdwJVASdyWLPAS2kbFA8xsHNS13EzCmlx8R6KJQcBcypfFpho3cKxRna3ADsgEo6+ZjAKMhgjZ1d2KWR2gTSyD0h4jnIB2gXDIXwciFCPZvSnMl0wwshYrJGDImaMUGKovlLBPVOrDjh8APzFx8zDkjNa7FzYoGZsKT9XEarQOHmei1aJA246cqOWW6/i2l8VMGzoWIPW/k6eq2Ja6UwCz8pw2JGZ8sS8pUz8fWau/jGp+SgLchcGBgZD1Py41NUuoI+ZloV8ZU93+ogZKzfBiWfXAPCgMJU8Y42avQdMzI4ZBfmSizocqrUeJaAmsvBZGGBCtTziXeRY1rCxRAViEhXckqK93AeQJ9kYTvlmVlqmcTdhNEtefc+9X3utVmuX+CkK6oyqtu4nwrWP8bF5IZdGYjJ79wDuMCz4D+XmhFWnZbt7ab5ltBB6mbkyAaBPFCJassuwMmNb4L4EZgXwBc4AoGTZrUeA6A9x1yK6tzzvnFDlxBv0D176kCP2TCpbbjBXCRV9DZk0VeAONCE1IQ1zWg3dlF1sFQHWQIXFeBNrLAw5BwHBZWjQl6E3SbbB8X+R4Mg/Ca0wN2WtFeBTut4B84mFI4VpekyAAAAABJRU5ErkJggg=='); - background-size: 100% 100%; - } - } - h6 { - padding: 0 15px 0 28px; - &::before { - content: ''; - position: absolute; - top: 2px; - left: 0; - width: 20px; - height: 20px; - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAEI0lEQVRYR+3Xb2wTZRwH8G/vL22RPy5GW8fK6rJpGeFFY9RO3TRRE1HfmEAammEyjZmOSEg1RrPZaTD6xjhU/Ndlf0CZgwmD+qcgZBRIETeqY0Vcnc7pGonhRY2l3m2t5upqjq693l2vcy+8N81zz/NcPvf75fd7rjos8ku3yH34HyjK0PqlDLPzD56vMNL0VHxmpgXAoUIZXKgI3sMSpK+cNTAbylaj/9IkprnLM3+mkg8XQi4EsJ4lSL+ZNbAfVd+JG/XLcSERg3M8IAtZauBtDEkeNdN6fX9NfRqXueQiSwm00wQRMDMGw94snBJkqYBrSYIIXs/ojftqGq6IXHZRFIpkKYC2JSw9SJE663W0nthlqcMawwrJYpVCag1M48pNy1YNvLWRffGNIYSCv6Cnog7rjCtVIbUEXoG7qeqaNMj51F58dWoKPZY62JeWyUJG+ctcIplcIizWCpgTl9EIyODJn9BtceDWq/6B57tO/H4R688fFaZ7AWzWAiiJEyMDx39Ed6UDdyy7Ni/w1ekxbP95VJi/F8CRYoGycGLksaEJdFU6cPdy0zxkR/RbtE6FhPvHATQUm2JFODHSfyyCLmsd7lth/hf53q/jcE8OC+NTAG7PTKiNoCqcGPnpF+PotDrwwNXl+OC3H9A8cVqYPgPgFnFo1QCLwomRg4cvoPMGBzZHTgq3zwKwZ+ddKVATXAZhf+gdnPvuojAUqmJdrspRAtQU93pXEM+8clgwhQHU5itruUBNcTt6TsP9sl8weQC0S/VFOUBNcW/2folt2z+XhZPTZh6kSKJ79aqVRuFszRxfUm8sNbdz9xlsfekz2bhCQBvDMMM8z+ubN92Mjrb71brS+97dM4wtnk8U4SSBBEGErVarzeVywePxoHVLA1pb6lUh3+8bwZMv+BTjpIAVACa9Xq+uqakJ7e3tqpGd/WfR3Jr+81awIJS0mY0A+sLhMGw2W3qfGmTXvhAef/6gapxUBDuqqqoejUQiBvFbKUH2DHyNx54bLAqXF0jT9HBjY6Pd6/XOi7oc5K7936Dp2QNF4/IBrTqdLuLxeIi2tracRSGF/PDgKB55er8muHzATQB2m81m+P1+1NbmPoVyIfsOnUOj+2PNcPmAO1iWbeE4TmexWODz+WQhayrL4No2oCkuJ5Bl2VGO49ZmcisXObdeVSuRaq7ZZ3G10KBTqRQl3pQPGY1GEQgE4HQ6heVDAO5S1cklNmUDXQRB9KZSqXkfESaTCW63G7FYDKFQKDEyMoJoNKqfe/bbAJ7QGpcrxa8xDLOV5/k0kGXZv2ZnZ5FMJtNjmqYvURR1IpFInAcwAeD7ud/pUuDmAY1G41g8Hl9DkmScoqggx3FHAIyJMMlSQfI9V5zKagDC93dsoRFKimQx2dIWOV/U/yn6bx0WyDj8vgLOAAAAAElFTkSuQmCC'); - background-size: 100% 100%; - } - } - hr { - margin: 0; - border: none; - height: 1px; - background-color: #e4e7ed; - margin-bottom: 15px; - } - p { - line-height: 26px; - margin: 0; - margin-bottom: 15px; - } - blockquote { - margin: 0; - line-height: 26px; - margin-bottom: 15px; - background: #ecf8ff; - border-left: 5px solid #50bfff; - color: #50bfff; - padding: 8px 15px; - border-radius: 0 4px 4px 0; - p { - margin: 0; - } - } - pre { - margin: 0; - margin-bottom: 15px; - &::-webkit-scrollbar-track { - background: #fff; - } - &::-webkit-scrollbar { - width: 6px; - height: 6px; - } - &::-webkit-scrollbar-thumb { - border-radius: 3px; - background: #c0c4cc; - } - } - p code { - display: inline-block; - min-height: 26px; - line-height: 26px; - border-radius: 4px; - font-size: 12px; - background: #fdf6ec; - padding: 0 8px; - color: #e6a23c; - vertical-align: top; - } - ol, - ul { - margin: 0; - margin-bottom: 15px; - padding-left: 36px; - li { - line-height: 26px; - } - } - ol li { - list-style: decimal; - } - ul li { - list-style: disc; - } - table { - width: 100%; - max-width: 100%; - table-layout: fixed; - color: #909399; - margin-bottom: 15px; - font-size: 13px; - border-top: 1px solid #ebeef5; - border-left: 1px solid #ebeef5; - border-collapse: collapse; - td, - th { - padding: 8px; - border-bottom: 1px solid #ebeef5; - border-right: 1px solid #ebeef5; - } - thead { - th { - font-weight: 500; - background: #ebeef5; - } - } - } - img { - display: block; - max-width: 100%; - border-radius: 4px; - transition: transform 0.35s, box-shadow 0.35s; - margin: 0 auto; - } - a { - display: inline-block; - line-height: 26px; - color: #409eff; - position: relative; - text-decoration: none; - } - } - } - } - .cm-progress-left { - position: absolute; - top: 0; - right: 50%; - width: 0; - height: 3px; - background-color: #ff5627; - transition: width 0.5s; - z-index: 1; - } - .cm-progress-right { - position: absolute; - top: 0; - left: 50%; - width: 0; - height: 3px; - background-color: #ff5627; - transition: width 0.5s; - z-index: 1; - } + &:disabled { + cursor: not-allowed; + } + &:checked { + border: none; + background: #409eff; + &::after { + content: ''; + width: 3px; + height: 7px; + position: absolute; + top: 2px; + left: 5px; + border: 2px solid #fff; + border-top: 0; + border-left: 0; + transform: rotate(45deg); + } + } + } + } + } + } + .cm-progress-left { + position: absolute; + top: 0; + right: 50%; + width: 0; + height: 3px; + background-color: #ff5627; + transition: width 0.5s; + z-index: 1; + } + .cm-progress-right { + position: absolute; + top: 0; + left: 50%; + width: 0; + height: 3px; + background-color: #ff5627; + transition: width 0.5s; + z-index: 1; + } } .cm-modal { - display: flex; - align-items: center; - justify-content: center; - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 9999; - background: rgba(0, 0, 0, 0); - visibility: hidden; - transition: background 0.25s, visibility 0.25s; - will-change: background, visibility; - &__wrapper { - width: 380px; - background: #fff; - color: #606266; - border-radius: 4px; - opacity: 0; - transform: translateY(-30%); - transition: opacity 0.25s, transform 0.25s; - &-header { - padding: 10px 20px; - border-bottom: 1px solid #e4e7ed; - display: flex; - align-items: center; - justify-content: space-between; - &--close { - font-size: 20px; - cursor: pointer; - } - } - &-bodyer { - padding: 20px; - .fitem { - display: flex; - align-items: center; - margin-bottom: 15px; - &:last-child { - margin-bottom: 0; - } - label { - margin-right: 10px; - } - input { - width: auto; - flex: 1; - -webkit-appearance: none; - outline: none; - border: 1px solid #dcdfe6; - height: 34px; - box-sizing: border-box; - padding: 0 10px; - border-radius: 3px; - color: #606266; - } - } - .tabbar { - position: relative; - width: 100%; - overflow-x: auto; - display: flex; - margin-bottom: 20px; - &::-webkit-scrollbar { - display: none; - } - &-item { - white-space: nowrap; - margin-right: 15px; - cursor: pointer; - user-select: none; - &:last-child { - margin-right: 0; - } - &.active { - color: #409eff; - } - } - } - .lists { - display: none; - grid-template-columns: repeat(6, 1fr); - font-size: 18px; - border-left: 1px solid #e4e7ed; - border-top: 1px solid #e4e7ed; - font-family: 'Meiryo UI', 'Microsoft YaHei', 'Malgun Gothic', 'Segoe UI', 'Trebuchet MS', Helvetica, 'Monaco', monospace, Tahoma, STXihei, '华文细黑', STHeiti, 'Helvetica Neue', 'Droid Sans', 'wenquanyi micro hei', FreeSans, Arimo, Arial, SimSun, '宋体', Heiti, '黑体', sans-serif; - max-height: 380px; - overflow-y: auto; - overscroll-behavior: none; - &::-webkit-scrollbar-track { - background: #fff; - } - &::-webkit-scrollbar { - width: 6px; - height: 6px; - } - &::-webkit-scrollbar-thumb { - border-radius: 3px; - background: #c0c4cc; - } - &.active { - display: grid; - } - &-item { - display: flex; - align-items: center; - justify-content: center; - border-right: 1px solid #e4e7ed; - border-bottom: 1px solid #e4e7ed; - cursor: pointer; - transition: background 0.25s; - user-select: none; - color: #888; - padding: 5px 0; - &:hover, - .active { - background: #e4e7ed; - } - } - } - } - &-footer { - display: flex; - align-items: center; - justify-content: flex-end; - padding: 0 20px 10px; - &--cancle, - &--confirm { - cursor: pointer; - border: none; - outline: none; - margin-left: 5px; - background: #fff; - color: #606266; - -webkit-appearance: none; - padding: 7px 15px; - border-radius: 3px; - } - &--confirm { - color: #fff; - background: #409eff; - } - } - } - &.active { - visibility: visible; - background: rgba(0, 0, 0, 0.75); - .cm-modal__wrapper { - transform: translateY(0); - opacity: 1; - } - } + display: flex; + align-items: center; + justify-content: center; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 9999; + background: rgba(0, 0, 0, 0); + visibility: hidden; + transition: background 0.25s, visibility 0.25s; + will-change: background, visibility; + &__wrapper { + width: 380px; + background: #fff; + color: #606266; + border-radius: 4px; + opacity: 0; + transform: translateY(-30%); + transition: opacity 0.25s, transform 0.25s; + &-header { + padding: 10px 20px; + border-bottom: 1px solid #e4e7ed; + display: flex; + align-items: center; + justify-content: space-between; + &--close { + font-size: 20px; + cursor: pointer; + } + } + &-bodyer { + padding: 20px; + .fitem { + display: flex; + align-items: center; + margin-bottom: 15px; + &:last-child { + margin-bottom: 0; + } + label { + margin-right: 10px; + } + input { + width: auto; + flex: 1; + -webkit-appearance: none; + outline: none; + border: 1px solid #dcdfe6; + height: 34px; + box-sizing: border-box; + padding: 0 10px; + border-radius: 3px; + color: #606266; + } + } + .tabbar { + position: relative; + width: 100%; + overflow-x: auto; + display: flex; + margin-bottom: 20px; + &::-webkit-scrollbar { + display: none; + } + &-item { + white-space: nowrap; + margin-right: 15px; + cursor: pointer; + user-select: none; + &:last-child { + margin-right: 0; + } + &.active { + color: #409eff; + } + } + } + .lists { + display: none; + grid-template-columns: repeat(6, 1fr); + font-size: 18px; + border-left: 1px solid #e4e7ed; + border-top: 1px solid #e4e7ed; + font-family: 'Meiryo UI', 'Microsoft YaHei', 'Malgun Gothic', 'Segoe UI', 'Trebuchet MS', Helvetica, 'Monaco', monospace, Tahoma, STXihei, '华文细黑', STHeiti, 'Helvetica Neue', 'Droid Sans', 'wenquanyi micro hei', FreeSans, Arimo, Arial, SimSun, '宋体', Heiti, '黑体', sans-serif; + max-height: 350px; + overflow-y: auto; + overscroll-behavior: none; + &::-webkit-scrollbar-track { + background: #fff; + } + &::-webkit-scrollbar { + width: 6px; + height: 6px; + } + &::-webkit-scrollbar-thumb { + border-radius: 3px; + background: #c0c4cc; + } + &.active { + display: grid; + } + &-item { + display: flex; + align-items: center; + justify-content: center; + border-right: 1px solid #e4e7ed; + border-bottom: 1px solid #e4e7ed; + cursor: pointer; + transition: background 0.25s; + user-select: none; + color: #888; + padding: 5px 0; + &:hover, + .active { + background: #e4e7ed; + } + } + } + } + &-footer { + display: flex; + align-items: center; + justify-content: flex-end; + padding: 0 20px 10px; + &--cancle, + &--confirm { + cursor: pointer; + border: none; + outline: none; + margin-left: 5px; + background: #fff; + color: #606266; + -webkit-appearance: none; + padding: 7px 15px; + border-radius: 3px; + } + &--confirm { + color: #fff; + background: #409eff; + } + } + } + &.active { + visibility: visible; + background: rgba(0, 0, 0, 0.75); + .cm-modal__wrapper { + transform: translateY(0); + opacity: 1; + } + } } @media (max-width: 768px) { - .cm-modal__wrapper { - width: 90%; - } + .cm-modal__wrapper { + width: 90%; + } } diff --git a/typecho/write/js/_actions.js b/typecho/write/js/_actions.js index 8402a33..0bb64eb 100644 --- a/typecho/write/js/_actions.js +++ b/typecho/write/js/_actions.js @@ -1,7 +1,7 @@ import { undo, redo } from '@codemirror/history'; export default class JoeAction { - constructor() { - $('body').append(` + constructor() { + $('body').append(`
@@ -16,186 +16,186 @@ export default class JoeAction {
`); - $('.cm-modal__wrapper-footer--cancle, .cm-modal__wrapper-header--close').on('click', () => $('.cm-modal').removeClass('active')); - $('.cm-modal__wrapper-footer--confirm').on('click', () => { - this.options.confirm(); - $('.cm-modal').removeClass('active'); - }); - } - _openModal(options = {}) { - const _options = { - title: '提示', - innerHtml: '内容', - hasFooter: true, - confirm: () => {}, - handler: () => {} - }; - this.options = Object.assign(_options, options); - $('.cm-modal__wrapper-header--text').html(this.options.title); - $('.cm-modal__wrapper-bodyer').html(this.options.innerHtml); - this.options.hasFooter ? $('.cm-modal__wrapper-footer').show() : $('.cm-modal__wrapper-footer').hide(); - $('.cm-modal').addClass('active'); - this.options.handler(); - } - _getLineCh(cm) { - const head = cm.state.selection.main.head; - const line = cm.state.doc.lineAt(head); - return head - line.from; - } - _replaceSelection(cm, str) { - cm.dispatch(cm.state.replaceSelection(str)); - } - _setCursor(cm, pos) { - cm.dispatch({ selection: { anchor: pos } }); - } - _getSelection(cm) { - return cm.state.sliceDoc(cm.state.selection.main.from, cm.state.selection.main.to); - } - _insetAmboText(cm, str) { - const cursor = cm.state.selection.main.head; - const selection = this._getSelection(cm); - this._replaceSelection(cm, ` ${str + selection + str} `); - if (selection === '') this._setCursor(cm, cursor + str.length + 1); - cm.focus(); - } - _createTableLists(cm, url, activeTab = '', modalTitle) { - $.ajax({ - url, - dataType: 'json', - success: res => { - let tabbarStr = ''; - let listsStr = ''; - for (let key in res) { - const arr = res[key].split(' '); - tabbarStr += `
${key}
`; - listsStr += `
${arr.map(item => `
${item}
`).join(' ')}
`; - } - this._openModal({ - title: modalTitle, - hasFooter: false, - innerHtml: `
${tabbarStr}
${listsStr}`, - handler: () => { - $('.cm-modal__wrapper-bodyer .tabbar-item').on('click', function () { - const activeTab = $(this); - const show = activeTab.attr('data-show'); - const tabbar = $('.cm-modal__wrapper-bodyer .tabbar'); - activeTab.addClass('active').siblings().removeClass('active'); - tabbar.stop().animate({ - scrollLeft: activeTab[0].offsetLeft - tabbar[0].offsetWidth / 2 + activeTab[0].offsetWidth / 2 - 15 - }); - $('.cm-modal__wrapper-bodyer .lists').removeClass('active'); - $(".cm-modal__wrapper-bodyer .lists[data-show='" + show + "']").addClass('active'); - }); - const _this = this; - $('.cm-modal__wrapper-bodyer .lists-item').on('click', function () { - const text = $(this).attr('data-text'); - _this._replaceSelection(cm, ` ${text} `); - $('.cm-modal').removeClass('active'); - cm.focus(); - }); - } - }); - } - }); - } - handleFullScreen(el) { - el.toggleClass('active'); - $('body').toggleClass('fullscreen'); - $('.cm-container').toggleClass('fullscreen'); - $('.cm-preview').width(0); - } - handlePublish() { - $('#btn-submit').click(); - } - handleUndo(cm) { - undo(cm); - cm.focus(); - } - handleRedo(cm) { - redo(cm); - cm.focus(); - } - handleIndent(cm) { - this._replaceSelection(cm, ' '); - cm.focus(); - } - handleTime(cm) { - const time = new Date(); - const _Year = time.getFullYear(); - const _Month = String(time.getMonth() + 1).padStart(2, 0); - const _Date = String(time.getDate()).padStart(2, 0); - const _Hours = String(time.getHours()).padStart(2, 0); - const _Minutes = String(time.getMinutes()).padStart(2, 0); - const _Seconds = String(time.getSeconds()).padStart(2, 0); - const _Day = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][time.getDay()]; - const _time = `${this._getLineCh(cm) ? '\n' : ''}${_Year}-${_Month}-${_Date} ${_Hours}:${_Minutes}:${_Seconds} ${_Day}\n`; - this._replaceSelection(cm, _time); - cm.focus(); - } - handleHr(cm) { - const str = `${this._getLineCh(cm) ? '\n' : ''}\n------------\n\n`; - this._replaceSelection(cm, str); - cm.focus(); - } - handleClean(cm) { - cm.dispatch({ changes: { from: 0, to: cm.state.doc.length, insert: '' } }); - cm.focus(); - } - handleOrdered(cm) { - const selection = this._getSelection(cm); - if (selection === '') { - const str = (this._getLineCh(cm) ? '\n\n' : '') + '1. '; - this._replaceSelection(cm, str); - } else { - const selectionText = selection.split('\n'); - for (let i = 0, len = selectionText.length; i < len; i++) { - selectionText[i] = selectionText[i] === '' ? '' : i + 1 + '. ' + selectionText[i]; - } - const str = (this._getLineCh(cm) ? '\n' : '') + selectionText.join('\n'); - this._replaceSelection(cm, str); - } - cm.focus(); - } - handleUnordered(cm) { - const selection = this._getSelection(cm); - if (selection === '') { - const str = (this._getLineCh(cm) ? '\n' : '') + '- '; - this._replaceSelection(cm, str); - } else { - const selectionText = selection.split('\n'); - for (let i = 0, len = selectionText.length; i < len; i++) { - selectionText[i] = selectionText[i] === '' ? '' : '- ' + selectionText[i]; - } - const str = (this._getLineCh(cm) ? '\n' : '') + selectionText.join('\n'); - this._replaceSelection(cm, str); - } - cm.focus(); - } - handleQuote(cm) { - const selection = this._getSelection(cm); - if (selection === '') { - this._replaceSelection(cm, `${this._getLineCh(cm) ? '\n' : ''}> `); - } else { - const selectionText = selection.split('\n'); - for (let i = 0, len = selectionText.length; i < len; i++) { - selectionText[i] = selectionText[i] === '' ? '' : '> ' + selectionText[i]; - } - const str = (this._getLineCh(cm) ? '\n' : '') + selectionText.join('\n'); - this._replaceSelection(cm, str); - } - cm.focus(); - } - handleDownload(cm) { - const title = $('#title').val() || '新文章'; - const aTag = document.createElement('a'); - let blob = new Blob([cm.state.doc.toString()]); - aTag.download = title + '.md'; - aTag.href = URL.createObjectURL(blob); - aTag.click(); - URL.revokeObjectURL(blob); - } - handleTitle(cm, tool) { - const item = $(` + $('.cm-modal__wrapper-footer--cancle, .cm-modal__wrapper-header--close').on('click', () => $('.cm-modal').removeClass('active')); + $('.cm-modal__wrapper-footer--confirm').on('click', () => { + this.options.confirm(); + $('.cm-modal').removeClass('active'); + }); + } + _openModal(options = {}) { + const _options = { + title: '提示', + innerHtml: '内容', + hasFooter: true, + confirm: () => {}, + handler: () => {} + }; + this.options = Object.assign(_options, options); + $('.cm-modal__wrapper-header--text').html(this.options.title); + $('.cm-modal__wrapper-bodyer').html(this.options.innerHtml); + this.options.hasFooter ? $('.cm-modal__wrapper-footer').show() : $('.cm-modal__wrapper-footer').hide(); + $('.cm-modal').addClass('active'); + this.options.handler(); + } + _getLineCh(cm) { + const head = cm.state.selection.main.head; + const line = cm.state.doc.lineAt(head); + return head - line.from; + } + _replaceSelection(cm, str) { + cm.dispatch(cm.state.replaceSelection(str)); + } + _setCursor(cm, pos) { + cm.dispatch({ selection: { anchor: pos } }); + } + _getSelection(cm) { + return cm.state.sliceDoc(cm.state.selection.main.from, cm.state.selection.main.to); + } + _insetAmboText(cm, str) { + const cursor = cm.state.selection.main.head; + const selection = this._getSelection(cm); + this._replaceSelection(cm, ` ${str + selection + str} `); + if (selection === '') this._setCursor(cm, cursor + str.length + 1); + cm.focus(); + } + _createTableLists(cm, url, activeTab = '', modalTitle) { + $.ajax({ + url, + dataType: 'json', + success: res => { + let tabbarStr = ''; + let listsStr = ''; + for (let key in res) { + const arr = res[key].split(' '); + tabbarStr += `
${key}
`; + listsStr += `
${arr.map(item => `
${item}
`).join(' ')}
`; + } + this._openModal({ + title: modalTitle, + hasFooter: false, + innerHtml: `
${tabbarStr}
${listsStr}`, + handler: () => { + $('.cm-modal__wrapper-bodyer .tabbar-item').on('click', function () { + const activeTab = $(this); + const show = activeTab.attr('data-show'); + const tabbar = $('.cm-modal__wrapper-bodyer .tabbar'); + activeTab.addClass('active').siblings().removeClass('active'); + tabbar.stop().animate({ + scrollLeft: activeTab[0].offsetLeft - tabbar[0].offsetWidth / 2 + activeTab[0].offsetWidth / 2 - 15 + }); + $('.cm-modal__wrapper-bodyer .lists').removeClass('active'); + $(".cm-modal__wrapper-bodyer .lists[data-show='" + show + "']").addClass('active'); + }); + const _this = this; + $('.cm-modal__wrapper-bodyer .lists-item').on('click', function () { + const text = $(this).attr('data-text'); + _this._replaceSelection(cm, ` ${text} `); + $('.cm-modal').removeClass('active'); + cm.focus(); + }); + } + }); + } + }); + } + handleFullScreen(el) { + el.toggleClass('active'); + $('body').toggleClass('fullscreen'); + $('.cm-container').toggleClass('fullscreen'); + $('.cm-preview').width(0); + } + handlePublish() { + $('#btn-submit').click(); + } + handleUndo(cm) { + undo(cm); + cm.focus(); + } + handleRedo(cm) { + redo(cm); + cm.focus(); + } + handleIndent(cm) { + this._replaceSelection(cm, ' '); + cm.focus(); + } + handleTime(cm) { + const time = new Date(); + const _Year = time.getFullYear(); + const _Month = String(time.getMonth() + 1).padStart(2, 0); + const _Date = String(time.getDate()).padStart(2, 0); + const _Hours = String(time.getHours()).padStart(2, 0); + const _Minutes = String(time.getMinutes()).padStart(2, 0); + const _Seconds = String(time.getSeconds()).padStart(2, 0); + const _Day = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][time.getDay()]; + const _time = `${this._getLineCh(cm) ? '\n' : ''}${_Year}-${_Month}-${_Date} ${_Hours}:${_Minutes}:${_Seconds} ${_Day}\n`; + this._replaceSelection(cm, _time); + cm.focus(); + } + handleHr(cm) { + const str = `${this._getLineCh(cm) ? '\n' : ''}\n------------\n\n`; + this._replaceSelection(cm, str); + cm.focus(); + } + handleClean(cm) { + cm.dispatch({ changes: { from: 0, to: cm.state.doc.length, insert: '' } }); + cm.focus(); + } + handleOrdered(cm) { + const selection = this._getSelection(cm); + if (selection === '') { + const str = (this._getLineCh(cm) ? '\n\n' : '') + '1. '; + this._replaceSelection(cm, str); + } else { + const selectionText = selection.split('\n'); + for (let i = 0, len = selectionText.length; i < len; i++) { + selectionText[i] = selectionText[i] === '' ? '' : i + 1 + '. ' + selectionText[i]; + } + const str = (this._getLineCh(cm) ? '\n' : '') + selectionText.join('\n'); + this._replaceSelection(cm, str); + } + cm.focus(); + } + handleUnordered(cm) { + const selection = this._getSelection(cm); + if (selection === '') { + const str = (this._getLineCh(cm) ? '\n' : '') + '- '; + this._replaceSelection(cm, str); + } else { + const selectionText = selection.split('\n'); + for (let i = 0, len = selectionText.length; i < len; i++) { + selectionText[i] = selectionText[i] === '' ? '' : '- ' + selectionText[i]; + } + const str = (this._getLineCh(cm) ? '\n' : '') + selectionText.join('\n'); + this._replaceSelection(cm, str); + } + cm.focus(); + } + handleQuote(cm) { + const selection = this._getSelection(cm); + if (selection === '') { + this._replaceSelection(cm, `${this._getLineCh(cm) ? '\n' : ''}> `); + } else { + const selectionText = selection.split('\n'); + for (let i = 0, len = selectionText.length; i < len; i++) { + selectionText[i] = selectionText[i] === '' ? '' : '> ' + selectionText[i]; + } + const str = (this._getLineCh(cm) ? '\n' : '') + selectionText.join('\n'); + this._replaceSelection(cm, str); + } + cm.focus(); + } + handleDownload(cm) { + const title = $('#title').val() || '新文章'; + const aTag = document.createElement('a'); + let blob = new Blob([cm.state.doc.toString()]); + aTag.download = title + '.md'; + aTag.href = URL.createObjectURL(blob); + aTag.click(); + URL.revokeObjectURL(blob); + } + handleTitle(cm, tool) { + const item = $(`
${tool.innerHTML}
@@ -208,26 +208,26 @@ export default class JoeAction {
`); - item.on('click', function (e) { - e.stopPropagation(); - $(this).toggleClass('active'); - }); - const _this = this; - item.on('click', '.cm-tools__dropdown-item', function (e) { - e.stopPropagation(); - const text = $(this).attr('data-text'); - if (_this._getLineCh(cm)) _this._replaceSelection(cm, '\n\n' + text); - else _this._replaceSelection(cm, text); - item.removeClass('active'); - cm.focus(); - }); - $(document).on('click', () => item.removeClass('active')); - $('.cm-tools').append(item); - } - handleLink(cm) { - this._openModal({ - title: '插入链接', - innerHtml: ` + item.on('click', function (e) { + e.stopPropagation(); + $(this).toggleClass('active'); + }); + const _this = this; + item.on('click', '.cm-tools__dropdown-item', function (e) { + e.stopPropagation(); + const text = $(this).attr('data-text'); + if (_this._getLineCh(cm)) _this._replaceSelection(cm, '\n\n' + text); + else _this._replaceSelection(cm, text); + item.removeClass('active'); + cm.focus(); + }); + $(document).on('click', () => item.removeClass('active')); + $('.cm-tools').append(item); + } + handleLink(cm) { + this._openModal({ + title: '插入链接', + innerHtml: `
@@ -237,18 +237,18 @@ export default class JoeAction {
`, - confirm: () => { - const title = $(".cm-modal input[name='title']").val() || 'Test'; - const url = $(".cm-modal input[name='url']").val() || 'http://'; - this._replaceSelection(cm, ` [${title}](${url}) `); - cm.focus(); - } - }); - } - handleImage(cm) { - this._openModal({ - title: '插入图片', - innerHtml: ` + confirm: () => { + const title = $(".cm-modal input[name='title']").val() || 'Test'; + const url = $(".cm-modal input[name='url']").val() || 'http://'; + this._replaceSelection(cm, ` [${title}](${url}) `); + cm.focus(); + } + }); + } + handleImage(cm) { + this._openModal({ + title: '插入图片', + innerHtml: `
@@ -258,18 +258,18 @@ export default class JoeAction {
`, - confirm: () => { - const title = $(".cm-modal input[name='title']").val() || 'Test'; - const url = $(".cm-modal input[name='url']").val() || 'http://'; - this._replaceSelection(cm, ` ![${title}](${url}) `); - cm.focus(); - } - }); - } - handleTable(cm) { - this._openModal({ - title: '插入表格', - innerHtml: ` + confirm: () => { + const title = $(".cm-modal input[name='title']").val() || 'Test'; + const url = $(".cm-modal input[name='url']").val() || 'http://'; + this._replaceSelection(cm, ` ![${title}](${url}) `); + cm.focus(); + } + }); + } + handleTable(cm) { + this._openModal({ + title: '插入表格', + innerHtml: `
@@ -277,33 +277,33 @@ export default class JoeAction {
`, - confirm: () => { - let row = $(".cm-modal input[name='row']").val(); - let column = $(".cm-modal input[name='column']").val(); - if (isNaN(row)) row = 3; - if (isNaN(column)) column = 3; - let rowStr = ''; - let rangeStr = ''; - let columnlStr = ''; - for (let i = 0; i < column; i++) { - rowStr += '| 表头 '; - rangeStr += '| :--: '; - } - for (let i = 0; i < row; i++) { - for (let j = 0; j < column; j++) columnlStr += '| 表格 '; - columnlStr += '|\n'; - } - const htmlStr = `${rowStr}|\n${rangeStr}|\n${columnlStr}\n`; - if (this._getLineCh(cm)) this._replaceSelection(cm, '\n\n' + htmlStr); - else this._replaceSelection(cm, htmlStr); - cm.focus(); - } - }); - } - handleCodeBlock(cm) { - this._openModal({ - title: '插入代码块', - innerHtml: ` + confirm: () => { + let row = $(".cm-modal input[name='row']").val(); + let column = $(".cm-modal input[name='column']").val(); + if (isNaN(row)) row = 3; + if (isNaN(column)) column = 3; + let rowStr = ''; + let rangeStr = ''; + let columnlStr = ''; + for (let i = 0; i < column; i++) { + rowStr += '| 表头 '; + rangeStr += '| :--: '; + } + for (let i = 0; i < row; i++) { + for (let j = 0; j < column; j++) columnlStr += '| 表格 '; + columnlStr += '|\n'; + } + const htmlStr = `${rowStr}|\n${rangeStr}|\n${columnlStr}\n`; + if (this._getLineCh(cm)) this._replaceSelection(cm, '\n\n' + htmlStr); + else this._replaceSelection(cm, htmlStr); + cm.focus(); + } + }); + } + handleCodeBlock(cm) { + this._openModal({ + title: '插入代码块', + innerHtml: `
`, - confirm: () => { - const type = $(".cm-modal select[name='type']").val() || 'html'; - const htmlStr = `\`\`\`${type}\ncode here...\n\`\`\``; - if (this._getLineCh(cm)) this._replaceSelection(cm, '\n\n' + htmlStr); - else this._replaceSelection(cm, htmlStr); - cm.focus(); - } - }); - } - handleAbout() { - this._openModal({ - title: '关于', - innerHtml: ` + confirm: () => { + const type = $(".cm-modal select[name='type']").val() || 'html'; + const htmlStr = `\`\`\`${type}\ncode here...\n\`\`\``; + if (this._getLineCh(cm)) this._replaceSelection(cm, '\n\n' + htmlStr); + else this._replaceSelection(cm, htmlStr); + cm.focus(); + } + }); + } + handleAbout() { + this._openModal({ + title: '关于', + innerHtml: ` ` - }); - } + }); + } + handleTask(cm, type) { + const str = type ? '{x}' : '{ }'; + this._replaceSelection(cm, ` ${str} `); + cm.focus(); + } } diff --git a/typecho/write/js/_create.js b/typecho/write/js/_create.js new file mode 100644 index 0000000..a9972de --- /dev/null +++ b/typecho/write/js/_create.js @@ -0,0 +1,10 @@ +const parser = new HyperDown(); +export default function createPreviewHtml(str) { + str = parser.makeHtml(str); + + str = str.replace(/{x}/g, '') + str = str.replace(/{ }/g, '') + + $('.cm-preview-content').html(str); + $('.cm-preview-content pre code').each((i, el) => Prism.highlightElement(el)); +} diff --git a/typecho/write/js/_tools.js b/typecho/write/js/_tools.js index 788e890..777db8a 100644 --- a/typecho/write/js/_tools.js +++ b/typecho/write/js/_tools.js @@ -84,6 +84,16 @@ export default [ title: '符号表情', innerHTML: '' }, + { + type: 'task-no', + title: '任务 - 未完成', + innerHTML: '' + }, + { + type: 'task-yes', + title: '任务 - 已完成', + innerHTML: '' + }, { type: 'code-block', title: '代码块', diff --git a/typecho/write/js/joe.parse.js b/typecho/write/js/joe.parse.js index d310f19..3e727f5 100644 --- a/typecho/write/js/joe.parse.js +++ b/typecho/write/js/joe.parse.js @@ -1,1359 +1,1359 @@ // Generated by CoffeeScript 1.12.7 (function () { - var Parser, - slice = [].slice; - - Parser = (function () { - var array_keys, array_values, htmlspecialchars, pL, preg_quote, str_replace, trim, ucfirst; - - ucfirst = function (str) { - return str.charAt(0).toUpperCase() + str.substring(1); - }; - - preg_quote = function (str) { - return str.replace(/[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); - }; - - pL = 'A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC'; - - str_replace = function (search, replace, str) { - var i, j, l, len, len1, val; - if (search instanceof Array) { - if (replace instanceof Array) { - for (i = j = 0, len = search.length; j < len; i = ++j) { - val = search[i]; - str = str_replace(val, replace[i], str); - } - } else { - for (l = 0, len1 = search.length; l < len1; l++) { - val = search[l]; - str = str_replace(val, replace, str); - } - } - } else { - search = preg_quote(search); - str = str.replace(new RegExp(search, 'g'), replace.replace(/\$/g, '$$$$')); - } - return str; - }; - - htmlspecialchars = function (str) { - return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); - }; - - trim = function (str, ch) { - var c, i, j, ref, search; - if (ch == null) { - ch = null; - } - if (ch != null) { - search = ''; - for (i = j = 0, ref = ch.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { - c = ch[i]; - c = preg_quote(c); - search += c; - } - search = '[' + search + ']*'; - return str.replace(new RegExp('^' + search), '').replace(new RegExp(search + '$'), ''); - } else { - return str.replace(/^\s*/, '').replace(/\s*$/, ''); - } - }; - - array_keys = function (arr) { - var _, j, k, len, result; - result = []; - if (arr instanceof Array) { - for (k = j = 0, len = arr.length; j < len; k = ++j) { - _ = arr[k]; - result.push(k); - } - } else { - for (k in arr) { - result.push(k); - } - } - return result; - }; - - array_values = function (arr) { - var _, j, len, result, v; - result = []; - if (arr instanceof Array) { - for (j = 0, len = arr.length; j < len; j++) { - v = arr[j]; - result.push(v); - } - } else { - for (_ in arr) { - v = arr[_]; - result.push(v); - } - } - return result; - }; - - function Parser() { - this.commonWhiteList = 'kbd|b|i|strong|em|sup|sub|br|code|del|a|hr|small'; - this.blockHtmlTags = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|svg|script|noscript'; - this.specialWhiteList = { - table: 'table|tbody|thead|tfoot|tr|td|th' - }; - this.hooks = {}; - this.html = false; - this.line = false; - this.blockParsers = [ - ['code', 10], - ['shtml', 20], - ['pre', 30], - ['ahtml', 40], - ['shr', 50], - ['list', 60], - ['math', 70], - ['html', 80], - ['footnote', 90], - ['definition', 100], - ['quote', 110], - ['table', 120], - ['sh', 130], - ['mh', 140], - ['dhr', 150], - ['default', 9999] - ]; - this.parsers = {}; - } - - Parser.prototype.makeHtml = function (text) { - var html, j, len, name, parser, ref; - this.footnotes = []; - this.definitions = {}; - this.holders = {}; - this.uniqid = Math.ceil(Math.random() * 10000000) + Math.ceil(Math.random() * 10000000); - this.id = 0; - this.blockParsers.sort(function (a, b) { - if (a[1] < b[1]) { - return -1; - } else { - return 1; - } - }); - ref = this.blockParsers; - for (j = 0, len = ref.length; j < len; j++) { - parser = ref[j]; - name = parser[0]; - if (parser[2] !== void 0) { - this.parsers[name] = parser[2]; - } else { - this.parsers[name] = this['parseBlock' + ucfirst(name)].bind(this); - } - } - text = this.initText(text); - html = this.parse(text); - html = this.makeFootnotes(html); - html = this.optimizeLines(html); - return this.call('makeHtml', html); - }; - - Parser.prototype.enableHtml = function (html1) { - this.html = html1 != null ? html1 : true; - }; - - Parser.prototype.enableLine = function (line1) { - this.line = line1 != null ? line1 : true; - }; - - Parser.prototype.hook = function (type, cb) { - if (this.hooks[type] == null) { - this.hooks[type] = []; - } - return this.hooks[type].push(cb); - }; - - Parser.prototype.makeHolder = function (str) { - var key; - key = '|\r' + this.uniqid + this.id + '\r|'; - this.id += 1; - this.holders[key] = str; - return key; - }; - - Parser.prototype.initText = function (text) { - return text - .replace(/\t/g, ' ') - .replace(/\r/g, '') - .replace(/(\u000A|\u000D|\u2028|\u2029)/g, '\n'); - }; - - Parser.prototype.makeFootnotes = function (html) { - var index, val; - if (this.footnotes.length > 0) { - html += '

    '; - index = 1; - while ((val = this.footnotes.shift())) { - if (typeof val === 'string') { - val += ' '; - } else { - val[val.length - 1] += ' '; - val = val.length > 1 ? this.parse(val.join('\n')) : this.parseInline(val[0]); - } - html += '
  1. ' + val + '
  2. '; - index += 1; - } - html += '
'; - } - return html; - }; - - Parser.prototype.parse = function (text, inline, offset) { - var block, blocks, end, extract, html, j, len, lines, method, result, start, type, value; - if (inline == null) { - inline = false; - } - if (offset == null) { - offset = 0; - } - lines = []; - blocks = this.parseBlock(text, lines); - html = ''; - if (inline && blocks.length === 1 && blocks[0][0] === 'normal') { - blocks[0][3] = true; - } - for (j = 0, len = blocks.length; j < len; j++) { - block = blocks[j]; - (type = block[0]), (start = block[1]), (end = block[2]), (value = block[3]); - extract = lines.slice(start, end + 1); - method = 'parse' + ucfirst(type); - extract = this.call('before' + ucfirst(method), extract, value); - result = this[method](extract, value, start + offset, end + offset); - result = this.call('after' + ucfirst(method), result, value); - html += result; - } - return html; - }; - - Parser.prototype.call = function () { - var args, callback, j, len, ref, type, value; - (type = arguments[0]), (args = 2 <= arguments.length ? slice.call(arguments, 1) : []); - value = args[0]; - if (this.hooks[type] == null) { - return value; - } - ref = this.hooks[type]; - for (j = 0, len = ref.length; j < len; j++) { - callback = ref[j]; - value = callback.apply(this, args); - args[0] = value; - } - return value; - }; - - Parser.prototype.releaseHolder = function (text, clearHolders) { - var deep; - if (clearHolders == null) { - clearHolders = true; - } - deep = 0; - while (text.indexOf('\r') >= 0 && deep < 10) { - text = str_replace(array_keys(this.holders), array_values(this.holders), text); - deep += 1; - } - if (clearHolders) { - this.holders = {}; - } - return text; - }; - - Parser.prototype.markLine = function (start, end) { - if (end == null) { - end = -1; - } - if (this.line) { - end = end < 0 ? start : end; - return ''; - } - return ''; - }; - - Parser.prototype.markLines = function (lines, start) { - var i; - i = -1; - if (this.line) { - return lines.map( - (function (_this) { - return function (line) { - i += 1; - return _this.markLine(start + i) + line; - }; - })(this) - ); - } else { - return lines; - } - }; - - Parser.prototype.optimizeLines = function (html) { - var last, regex; - last = 0; - regex = new RegExp('class="line" data\\-start="([0-9]+)" data\\-end="([0-9]+)" (data\\-id="' + this.uniqid + '")', 'g'); - if (this.line) { - return html.replace(regex, function () { - var matches, replace; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - if (last !== parseInt(matches[1])) { - replace = 'class="line" data-start="' + last + '" data-start-original="' + matches[1] + '" data-end="' + matches[2] + '" ' + matches[3]; - } else { - replace = matches[0]; - } - last = 1 + parseInt(matches[2]); - return replace; - }); - } else { - return html; - } - }; - - Parser.prototype.parseInline = function (text, whiteList, clearHolders, enableAutoLink) { - var regex; - if (whiteList == null) { - whiteList = ''; - } - if (clearHolders == null) { - clearHolders = true; - } - if (enableAutoLink == null) { - enableAutoLink = true; - } - text = this.call('beforeParseInline', text); - text = text.replace( - /(^|[^\\])(`+)(.+?)\2/gm, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return matches[1] + _this.makeHolder('' + htmlspecialchars(matches[3]) + ''); - }; - })(this) - ); - text = text.replace( - /(^|[^\\])(\$+)(.+?)\2/gm, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return matches[1] + _this.makeHolder(matches[2] + htmlspecialchars(matches[3]) + matches[2]); - }; - })(this) - ); - text = text.replace( - /\\(.)/g, - (function (_this) { - return function () { - var escaped, matches, prefix; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - prefix = matches[1].match(/^[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]$/) ? '' : '\\'; - escaped = htmlspecialchars(matches[1]); - escaped = escaped.replace(/\$/g, '$'); - return _this.makeHolder(prefix + escaped); - }; - })(this) - ); - text = text.replace( - /<(https?:\/\/.+)>/gi, - (function (_this) { - return function () { - var link, matches, url; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - url = _this.cleanUrl(matches[1]); - link = _this.call('parseLink', matches[1]); - return _this.makeHolder('' + link + ''); - }; - })(this) - ); - text = text.replace( - /<(\/?)([a-z0-9-]+)(\s+[^>]*)?>/gi, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - if (_this.html || ('|' + _this.commonWhiteList + '|' + whiteList + '|').indexOf('|' + matches[2].toLowerCase() + '|') >= 0) { - return _this.makeHolder(matches[0]); - } else { - return _this.makeHolder(htmlspecialchars(matches[0])); - } - }; - })(this) - ); - if (this.html) { - text = text.replace( - //g, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return _this.makeHolder(matches[0]); - }; - })(this) - ); - } - text = str_replace(['<', '>'], ['<', '>'], text); - text = text.replace( - /\[\^((?:[^\]]|\\\]|\\\[)+?)\]/g, - (function (_this) { - return function () { - var id, matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - id = _this.footnotes.indexOf(matches[1]); - if (id < 0) { - id = _this.footnotes.length + 1; - _this.footnotes.push(_this.parseInline(matches[1], '', false)); - } - return _this.makeHolder('' + id + ''); - }; - })(this) - ); - text = text.replace( - /!\[((?:[^\]]|\\\]|\\\[)*?)\]\(((?:[^\)]|\\\)|\\\()+?)\)/g, - (function (_this) { - return function () { - var escaped, matches, url; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - escaped = htmlspecialchars(_this.escapeBracket(matches[1])); - url = _this.escapeBracket(matches[2]); - url = _this.cleanUrl(url); - return _this.makeHolder('' + escaped + ''); - }; - })(this) - ); - text = text.replace( - /!\[((?:[^\]]|\\\]|\\\[)*?)\]\[((?:[^\]]|\\\]|\\\[)+?)\]/g, - (function (_this) { - return function () { - var escaped, matches, result; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - escaped = htmlspecialchars(_this.escapeBracket(matches[1])); - result = _this.definitions[matches[2]] != null ? '' + escaped + '' : escaped; - return _this.makeHolder(result); - }; - })(this) - ); - text = text.replace( - /\[((?:[^\]]|\\\]|\\\[)+?)\]\(((?:[^\)]|\\\)|\\\()+?)\)/g, - (function (_this) { - return function () { - var escaped, matches, url; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - escaped = _this.parseInline(_this.escapeBracket(matches[1]), '', false, false); - url = _this.escapeBracket(matches[2]); - url = _this.cleanUrl(url); - return _this.makeHolder('' + escaped + ''); - }; - })(this) - ); - text = text.replace( - /\[((?:[^\]]|\\\]|\\\[)+?)\]\[((?:[^\]]|\\\]|\\\[)+?)\]/g, - (function (_this) { - return function () { - var escaped, matches, result; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - escaped = _this.parseInline(_this.escapeBracket(matches[1]), '', false, false); - result = _this.definitions[matches[2]] != null ? '' + escaped + '' : escaped; - return _this.makeHolder(result); - }; - })(this) - ); - text = this.parseInlineCallback(text); - text = text.replace(/<([_a-z0-9-\.\+]+@[^@]+\.[a-z]{2,})>/gi, '$1'); - if (enableAutoLink) { - regex = new RegExp('(^|[^"])((https?):[' + pL + '_0-9-\\./%#!@\\?\\[\\]\\+=~\\|\\,&\\(\\)]+)($|[^"])', 'ig'); - text = text.replace( - regex, - (function (_this) { - return function () { - var link, matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - link = _this.call('parseLink', matches[2]); - return matches[1] + '' + link + '' + matches[4]; - }; - })(this) - ); - } - text = this.call('afterParseInlineBeforeRelease', text); - text = this.releaseHolder(text, clearHolders); - text = this.call('afterParseInline', text); - return text; - }; - - Parser.prototype.parseInlineCallback = function (text) { - text = text.replace( - /(\*{3})((?:.|\r)+?)\1/gm, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return '' + _this.parseInlineCallback(matches[2]) + ''; - }; - })(this) - ); - text = text.replace( - /(\*{2})((?:.|\r)+?)\1/gm, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return '' + _this.parseInlineCallback(matches[2]) + ''; - }; - })(this) - ); - text = text.replace( - /(\*)((?:.|\r)+?)\1/gm, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return '' + _this.parseInlineCallback(matches[2]) + ''; - }; - })(this) - ); - text = text.replace( - /(\s+|^)(_{3})((?:.|\r)+?)\2(\s+|$)/gm, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return matches[1] + '' + _this.parseInlineCallback(matches[3]) + '' + matches[4]; - }; - })(this) - ); - text = text.replace( - /(\s+|^)(_{2})((?:.|\r)+?)\2(\s+|$)/gm, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return matches[1] + '' + _this.parseInlineCallback(matches[3]) + '' + matches[4]; - }; - })(this) - ); - text = text.replace( - /(\s+|^)(_)((?:.|\r)+?)\2(\s+|$)/gm, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return matches[1] + '' + _this.parseInlineCallback(matches[3]) + '' + matches[4]; - }; - })(this) - ); - text = text.replace( - /(~{2})((?:.|\r)+?)\1/gm, - (function (_this) { - return function () { - var matches; - matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return '' + _this.parseInlineCallback(matches[2]) + ''; - }; - })(this) - ); - return text; - }; - - Parser.prototype.parseBlock = function (text, lines) { - var block, j, key, l, len, len1, line, name, parser, pass, ref, ref1, state; - ref = text.split('\n'); - for (j = 0, len = ref.length; j < len; j++) { - line = ref[j]; - lines.push(line); - } - this.blocks = []; - this.current = 'normal'; - this.pos = -1; - state = { - special: array_keys(this.specialWhiteList).join('|'), - empty: 0, - html: false - }; - for (key = l = 0, len1 = lines.length; l < len1; key = ++l) { - line = lines[key]; - block = this.getBlock(); - if (block != null) { - block = block.slice(0); - } - if (this.current !== 'normal') { - pass = this.parsers[this.current](block, key, line, state, lines); - if (!pass) { - continue; - } - } - ref1 = this.parsers; - for (name in ref1) { - parser = ref1[name]; - if (name !== this.current) { - pass = parser(block, key, line, state, lines); - if (!pass) { - break; - } - } - } - } - return this.optimizeBlocks(this.blocks, lines); - }; - - Parser.prototype.parseBlockList = function (block, key, line, state) { - var matches, space; - if (this.isBlock('list') && !line.match(/^\s*\[((?:[^\]]|\\\]|\\\[)+?)\]:\s*(.+)$/)) { - if (state.empty <= 1 && !!(matches = line.match(/^(\s+)/)) && matches[1].length > block[3]) { - state.empty = 0; - this.setBlock(key); - return false; - } else if (line.match(/^\s*$/) && state.empty === 0) { - state.empty += 1; - this.setBlock(key); - return false; - } - } - if (!!(matches = line.match(/^(\s*)((?:[0-9]+\.)|\-|\+|\*)\s+/i))) { - space = matches[1].length; - state.empty = 0; - if (this.isBlock('list')) { - this.setBlock(key, space); - } else { - this.startBlock('list', key, space); - } - return false; - } - return true; - }; - - Parser.prototype.parseBlockCode = function (block, key, line) { - var isAfterList, matches, space; - if (!!(matches = line.match(/^(\s*)(~{3,}|`{3,})([^`~]*)$/i))) { - if (this.isBlock('code')) { - isAfterList = block[3][2]; - if (isAfterList) { - this.combineBlock().setBlock(key); - } else { - this.setBlock(key).endBlock(); - } - } else { - isAfterList = false; - if (this.isBlock('list')) { - space = block[3]; - isAfterList = (space > 0 && matches[1].length >= space) || matches[1].length > space; - } - this.startBlock('code', key, [matches[1], matches[3], isAfterList]); - } - return false; - } else if (this.isBlock('code')) { - this.setBlock(key); - return false; - } - return true; - }; - - Parser.prototype.parseBlockShtml = function (block, key, line, state) { - var matches; - if (this.html) { - if (!!(matches = line.match(/^(\s*)!!!(\s*)$/))) { - if (this.isBlock('shtml')) { - this.setBlock(key).endBlock(); - } else { - this.startBlock('shtml', key); - } - return false; - } else if (this.isBlock('shtml')) { - this.setBlock(key); - return false; - } - } - return true; - }; - - Parser.prototype.parseBlockAhtml = function (block, key, line, state) { - var htmlTagAllRegExp, htmlTagRegExp, lastMatch, m, matches; - if (this.html) { - htmlTagRegExp = new RegExp('^\\s*<(' + this.blockHtmlTags + ')(\\s+[^>]*)?>', 'i'); - if ((matches = line.match(htmlTagRegExp))) { - if (this.isBlock('ahtml')) { - this.setBlock(key); - return false; - } else if (matches[2] === void 0 || matches[2] !== '/') { - this.startBlock('ahtml', key); - htmlTagAllRegExp = new RegExp('\\s*<(' + this.blockHtmlTags + ')(\\s+[^>]*)?>', 'ig'); - while (true) { - m = htmlTagAllRegExp.exec(line); - if (!m) { - break; - } - lastMatch = m[1]; - } - if (0 <= line.indexOf('')) { - this.endBlock(); - } else { - state.html = lastMatch; - } - return false; - } - } else if (!!state.html && 0 <= line.indexOf('')) { - this.setBlock(key).endBlock(); - state.html = false; - return false; - } else if (this.isBlock('ahtml')) { - this.setBlock(key); - return false; - } else if (!!(matches = line.match(/^\s*\s*$/))) { - this.startBlock('ahtml', key).endBlock(); - return false; - } - } - return true; - }; - - Parser.prototype.parseBlockMath = function (block, key, line) { - var matches; - if (!!(matches = line.match(/^(\s*)\$\$(\s*)$/))) { - if (this.isBlock('math')) { - this.setBlock(key).endBlock(); - } else { - this.startBlock('math', key); - } - return false; - } else if (this.isBlock('math')) { - this.setBlock(key); - return false; - } - return true; - }; - - Parser.prototype.parseBlockPre = function (block, key, line, state) { - if (!!line.match(/^ {4}/)) { - if (this.isBlock('pre')) { - this.setBlock(key); - } else { - this.startBlock('pre', key); - } - return false; - } else if (this.isBlock('pre') && line.match(/^\s*$/)) { - this.setBlock(key); - return false; - } - return true; - }; - - Parser.prototype.parseBlockHtml = function (block, key, line, state) { - var matches, tag; - if (!!(matches = line.match(new RegExp('^\\s*<(' + state.special + ')(\\s+[^>]*)?>', 'i')))) { - tag = matches[1].toLowerCase(); - if (!this.isBlock('html', tag) && !this.isBlock('pre')) { - this.startBlock('html', key, tag); - } - return false; - } else if (!!(matches = line.match(new RegExp('\\s*$', 'i')))) { - tag = matches[1].toLowerCase(); - if (this.isBlock('html', tag)) { - this.setBlock(key).endBlock(); - } - return false; - } else if (this.isBlock('html')) { - this.setBlock(key); - return false; - } - return true; - }; - - Parser.prototype.parseBlockFootnote = function (block, key, line) { - var matches, space; - if (!!(matches = line.match(/^\[\^((?:[^\]]|\\\]|\\\[)+?)\]:/))) { - space = matches[0].length - 1; - this.startBlock('footnote', key, [space, matches[1]]); - return false; - } - return true; - }; - - Parser.prototype.parseBlockDefinition = function (block, key, line) { - var matches; - if (!!(matches = line.match(/^\s*\[((?:[^\]]|\\\]|\\\[)+?)\]:\s*(.+)$/))) { - this.definitions[matches[1]] = this.cleanUrl(matches[2]); - this.startBlock('definition', key).endBlock(); - return false; - } - return true; - }; - - Parser.prototype.parseBlockQuote = function (block, key, line) { - var matches; - if (!!(matches = line.match(/^(\s*)>/))) { - if (this.isBlock('list') && matches[1].length > 0) { - this.setBlock(key); - } else if (this.isBlock('quote')) { - this.setBlock(key); - } else { - this.startBlock('quote', key); - } - return false; - } - return true; - }; - - Parser.prototype.parseBlockTable = function (block, key, line, state, lines) { - var align, aligns, head, j, len, matches, row, rows; - if (!!(matches = line.match(/^((?:(?:(?:\||\+)(?:[ :]*\-+[ :]*)(?:\||\+))|(?:(?:[ :]*\-+[ :]*)(?:\||\+)(?:[ :]*\-+[ :]*))|(?:(?:[ :]*\-+[ :]*)(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-+[ :]*)))+)$/))) { - if (this.isBlock('table')) { - block[3][0].push(block[3][2]); - block[3][2] += 1; - this.setBlock(key, block[3]); - } else { - head = 0; - if (block == null || block[0] !== 'normal' || lines[block[2]].match(/^\s*$/)) { - this.startBlock('table', key); - } else { - head = 1; - this.backBlock(1, 'table'); - } - if (matches[1][0] === '|') { - matches[1] = matches[1].substring(1); - if (matches[1][matches[1].length - 1] === '|') { - matches[1] = matches[1].substring(0, matches[1].length - 1); - } - } - rows = matches[1].split(/\+|\|/); - aligns = []; - for (j = 0, len = rows.length; j < len; j++) { - row = rows[j]; - align = 'none'; - if (!!(matches = row.match(/^\s*(:?)\-+(:?)\s*$/))) { - if (!!matches[1] && !!matches[2]) { - align = 'center'; - } else if (!!matches[1]) { - align = 'left'; - } else if (!!matches[2]) { - align = 'right'; - } - } - aligns.push(align); - } - this.setBlock(key, [[head], aligns, head + 1]); - } - return false; - } - return true; - }; - - Parser.prototype.parseBlockSh = function (block, key, line) { - var matches, num; - if (!!(matches = line.match(/^(#+)(.*)$/))) { - num = Math.min(matches[1].length, 6); - this.startBlock('sh', key, num).endBlock(); - return false; - } - return true; - }; - - Parser.prototype.parseBlockMh = function (block, key, line, state, lines) { - var matches; - if (!!(matches = line.match(/^\s*((=|-){2,})\s*$/)) && block != null && block[0] === 'normal' && !lines[block[2]].match(/^\s*$/)) { - if (this.isBlock('normal')) { - this.backBlock(1, 'mh', matches[1][0] === '=' ? 1 : 2) - .setBlock(key) - .endBlock(); - } else { - this.startBlock('normal', key); - } - return false; - } - return true; - }; - - Parser.prototype.parseBlockShr = function (block, key, line) { - if (!!line.match(/^(\* *){3,}\s*$/)) { - this.startBlock('hr', key).endBlock(); - return false; - } - return true; - }; - - Parser.prototype.parseBlockDhr = function (block, key, line) { - if (!!line.match(/^(- *){3,}\s*$/)) { - this.startBlock('hr', key).endBlock(); - return false; - } - return true; - }; - - Parser.prototype.parseBlockDefault = function (block, key, line, state) { - var matches; - if (this.isBlock('footnote')) { - matches = line.match(/^(\s*)/); - if (matches[1].length >= block[3][0]) { - this.setBlock(key); - } else { - this.startBlock('normal', key); - } - } else if (this.isBlock('table')) { - if (0 <= line.indexOf('|')) { - block[3][2] += 1; - this.setBlock(key, block[3]); - } else { - this.startBlock('normal', key); - } - } else if (this.isBlock('quote')) { - if (!line.match(/^(\s*)$/)) { - this.setBlock(key); - } else { - this.startBlock('normal', key); - } - } else { - if (block == null || block[0] !== 'normal') { - this.startBlock('normal', key); - } else { - this.setBlock(key); - } - } - return true; - }; - - Parser.prototype.optimizeBlocks = function (_blocks, _lines) { - var block, blocks, from, isEmpty, key, lines, moved, nextBlock, prevBlock, to, type, types; - blocks = _blocks.slice(0); - lines = _lines.slice(0); - blocks = this.call('beforeOptimizeBlocks', blocks, lines); - key = 0; - while (blocks[key] != null) { - moved = false; - block = blocks[key]; - prevBlock = blocks[key - 1] != null ? blocks[key - 1] : null; - nextBlock = blocks[key + 1] != null ? blocks[key + 1] : null; - (type = block[0]), (from = block[1]), (to = block[2]); - if ('pre' === type) { - isEmpty = lines.slice(block[1], block[2] + 1).reduce(function (result, line) { - return line.match(/^\s*$/) && result; - }, true); - if (isEmpty) { - block[0] = type = 'normal'; - } - } - if ('normal' === type) { - types = ['list', 'quote']; - if (from === to && lines[from].match(/^\s*$/) && prevBlock != null && nextBlock != null) { - if (prevBlock[0] === nextBlock[0] && types.indexOf(prevBlock[0]) >= 0) { - blocks[key - 1] = [prevBlock[0], prevBlock[1], nextBlock[2], null]; - blocks.splice(key, 2); - moved = true; - } - } - } - if (!moved) { - key += 1; - } - } - return this.call('afterOptimizeBlocks', blocks, lines); - }; - - Parser.prototype.parseCode = function (lines, parts, start) { - var blank, count, isEmpty, lang, rel, str; - (blank = parts[0]), (lang = parts[1]); - lang = trim(lang); - count = blank.length; - if (!lang.match(/^[_a-z0-9-\+\#\:\.]+$/i)) { - lang = null; - } else { - parts = lang.split(':'); - if (parts.length > 1) { - (lang = parts[0]), (rel = parts[1]); - lang = trim(lang); - rel = trim(rel); - } - } - isEmpty = true; - lines = lines.slice(1, -1).map(function (line) { - line = line.replace(new RegExp('/^[ ]{' + count + '}/'), ''); - if (isEmpty && !line.match(/^\s*$/)) { - isEmpty = false; - } - return htmlspecialchars(line); - }); - str = this.markLines(lines, start + 1).join('\n'); - if (isEmpty) { - return ''; - } else { - return '
' + str + '
'; - } - }; - - Parser.prototype.parsePre = function (lines, value, start) { - var str; - lines = lines.map(function (line) { - return htmlspecialchars(line.substring(4)); - }); - str = this.markLines(lines, start).join('\n'); - if (str.match(/^\s*$/)) { - return ''; - } else { - return '
' + str + '
'; - } - }; - - Parser.prototype.parseAhtml = function (lines, value, start) { - return trim(this.markLines(lines, start).join('\n')); - }; - - Parser.prototype.parseShtml = function (lines, value, start) { - return trim(this.markLines(lines.slice(1, -1), start + 1).join('\n')); - }; - - Parser.prototype.parseMath = function (lines, value, start, end) { - return '

' + this.markLine(start, end) + htmlspecialchars(lines.join('\n')) + '

'; - }; - - Parser.prototype.parseSh = function (lines, num, start, end) { - var line; - line = this.markLine(start, end) + this.parseInline(trim(lines[0], '# ')); - if (line.match(/^\s*$/)) { - return ''; - } else { - return '' + line + ''; - } - }; - - Parser.prototype.parseMh = function (lines, num, start, end) { - return this.parseSh(lines, num, start, end); - }; - - Parser.prototype.parseQuote = function (lines, value, start) { - var str; - lines = lines.map(function (line) { - return line.replace(/^\s*> ?/, ''); - }); - str = lines.join('\n'); - if (str.match(/^\s*$/)) { - return ''; - } else { - return '
' + this.parse(str, true, start) + '
'; - } - }; - - Parser.prototype.parseList = function (lines, value, start) { - var found, html, j, key, l, lastType, leftLines, leftStart, len, len1, line, matches, minSpace, row, rows, secondFound, secondMinSpace, space, text, type; - html = ''; - minSpace = 99999; - secondMinSpace = 99999; - found = false; - secondFound = false; - rows = []; - for (key = j = 0, len = lines.length; j < len; key = ++j) { - line = lines[key]; - if ((matches = line.match(/^(\s*)((?:[0-9]+\.?)|\-|\+|\*)(\s+)(.*)$/i))) { - space = matches[1].length; - type = 0 <= '+-*'.indexOf(matches[2]) ? 'ul' : 'ol'; - minSpace = Math.min(space, minSpace); - found = true; - if (space > 0) { - secondMinSpace = Math.min(space, secondMinSpace); - secondFound = true; - } - rows.push([space, type, line, matches[4]]); - } else { - rows.push(line); - if (!!(matches = line.match(/^(\s*)/))) { - space = matches[1].length; - if (space > 0) { - secondMinSpace = Math.min(space, secondMinSpace); - secondFound = true; - } - } - } - } - minSpace = found ? minSpace : 0; - secondMinSpace = secondFound ? secondMinSpace : minSpace; - lastType = ''; - leftLines = []; - leftStart = 0; - for (key = l = 0, len1 = rows.length; l < len1; key = ++l) { - row = rows[key]; - if (row instanceof Array) { - (space = row[0]), (type = row[1]), (line = row[2]), (text = row[3]); - if (space !== minSpace) { - leftLines.push(line.replace(new RegExp('^\\s{' + secondMinSpace + '}'), '')); - } else { - if (leftLines.length > 0) { - html += '
  • ' + this.parse(leftLines.join('\n'), true, start + leftStart) + '
  • '; - } - if (lastType !== type) { - if (!!lastType) { - html += ''; - } - html += '<' + type + '>'; - } - leftStart = key; - leftLines = [text]; - lastType = type; - } - } else { - leftLines.push(row.replace(new RegExp('^\\s{' + secondMinSpace + '}'), '')); - } - } - if (leftLines.length > 0) { - html += '
  • ' + this.parse(leftLines.join('\n'), true, start + leftStart) + ('
  • '); - } - return html; - }; - - Parser.prototype.parseTable = function (lines, value, start) { - var aligns, body, column, columns, head, html, ignores, j, key, l, last, len, len1, line, num, output, row, rows, tag, text; - (ignores = value[0]), (aligns = value[1]); - head = - ignores.length > 0 && - ignores.reduce(function (prev, curr) { - return curr + prev; - }) > 0; - html = ''; - body = head ? null : true; - output = false; - for (key = j = 0, len = lines.length; j < len; key = ++j) { - line = lines[key]; - if (0 <= ignores.indexOf(key)) { - if (head && output) { - head = false; - body = true; - } - continue; - } - line = trim(line); - output = true; - if (line[0] === '|') { - line = line.substring(1); - if (line[line.length - 1] === '|') { - line = line.substring(0, line.length - 1); - } - } - rows = line.split('|').map(function (row) { - if (row.match(/^\s*$/)) { - return ' '; - } else { - return trim(row); - } - }); - columns = {}; - last = -1; - for (l = 0, len1 = rows.length; l < len1; l++) { - row = rows[l]; - if (row.length > 0) { - last += 1; - columns[last] = [columns[last] != null ? columns[last][0] + 1 : 1, row]; - } else if (columns[last] != null) { - columns[last][0] += 1; - } else { - columns[0] = [1, row]; - } - } - if (head) { - html += ''; - } else if (body) { - html += ''; - } - html += ' 1) { - html += ' colspan="' + num + '"'; - } - if (aligns[key] != null && aligns[key] !== 'none') { - html += ' align="' + aligns[key] + '"'; - } - html += '>' + this.parseInline(text) + (''); - } - html += ''; - if (head) { - html += ''; - } else if (body) { - body = false; - } - } - if (body !== null) { - html += ''; - } - return (html += '
    '); - }; - - Parser.prototype.parseHr = function (lines, value, start) { - if (this.line) { - return '
    '; - } else { - return '
    '; - } - }; - - Parser.prototype.parseNormal = function (lines, inline, start) { - var key, str; - if (inline == null) { - inline = false; - } - key = 0; - lines = lines.map( - (function (_this) { - return function (line) { - line = _this.parseInline(line); - if (!line.match(/^\s*$/)) { - line = _this.markLine(start + key) + line; - } - key += 1; - return line; - }; - })(this) - ); - str = trim(lines.join('\n')); - str = str.replace(/(\n\s*){2,}/g, '

    '); - str = str.replace(/\n/g, '
    '); - if (str.match(/^\s*$/)) { - return ''; - } else { - if (inline) { - return str; - } else { - return '

    ' + str + '

    '; - } - } - }; - - Parser.prototype.parseFootnote = function (lines, value) { - var index, note, space; - (space = value[0]), (note = value[1]); - index = this.footnotes.indexOf(note); - if (index >= 0) { - lines = lines.slice(0); - lines[0] = lines[0].replace(/^\[\^((?:[^\]]|\]|\[)+?)\]:/, ''); - this.footnotes[index] = lines; - } - return ''; - }; - - Parser.prototype.parseDefinition = function () { - return ''; - }; - - Parser.prototype.parseHtml = function (lines, type, start) { - lines = lines.map( - (function (_this) { - return function (line) { - return _this.parseInline(line, _this.specialWhiteList[type] != null ? _this.specialWhiteList[type] : ''); - }; - })(this) - ); - return this.markLines(lines, start).join('\n'); - }; - - Parser.prototype.cleanUrl = function (url) { - var matches, regexUrl, regexWord; - regexUrl = new RegExp('^\\s*((http|https|ftp|mailto):[' + pL + '_a-z0-9-:\\.\\*/%#;!@\\?\\[\\]\\+=~\\|\\,&\\(\\)]+)', 'i'); - regexWord = new RegExp('^\\s*([' + pL + '_a-z0-9-:\\.\\*/%#!@\\?\\+=~\\|\\,&]+)', 'i'); - if (!!(matches = url.match(regexUrl))) { - return matches[1]; - } else if (!!(matches = url.match(regexWord))) { - return matches[1]; - } else { - return '#'; - } - }; - - Parser.prototype.escapeBracket = function (str) { - return str_replace(['\\[', '\\]', '\\(', '\\)'], ['[', ']', '(', ')'], str); - }; - - Parser.prototype.startBlock = function (type, start, value) { - if (value == null) { - value = null; - } - this.pos += 1; - this.current = type; - this.blocks.push([type, start, start, value]); - return this; - }; - - Parser.prototype.endBlock = function () { - this.current = 'normal'; - return this; - }; - - Parser.prototype.isBlock = function (type, value) { - if (value == null) { - value = null; - } - return this.current === type && (null === value ? true : this.blocks[this.pos][3] === value); - }; - - Parser.prototype.getBlock = function () { - if (this.blocks[this.pos] != null) { - return this.blocks[this.pos]; - } else { - return null; - } - }; - - Parser.prototype.setBlock = function (to, value) { - if (to == null) { - to = null; - } - if (value == null) { - value = null; - } - if (to !== null) { - this.blocks[this.pos][2] = to; - } - if (value !== null) { - this.blocks[this.pos][3] = value; - } - return this; - }; - - Parser.prototype.backBlock = function (step, type, value) { - var item, last; - if (value == null) { - value = null; - } - if (this.pos < 0) { - return this.startBlock(type, 0, value); - } - last = this.blocks[this.pos][2]; - this.blocks[this.pos][2] = last - step; - item = [type, last - step + 1, last, value]; - if (this.blocks[this.pos][1] <= this.blocks[this.pos][2]) { - this.pos += 1; - this.blocks.push(item); - } else { - this.blocks[this.pos] = item; - } - this.current = type; - return this; - }; - - Parser.prototype.combineBlock = function () { - var current, prev; - if (this.pos < 1) { - return this; - } - prev = this.blocks[this.pos - 1].slice(0); - current = this.blocks[this.pos].slice(0); - prev[2] = current[2]; - this.blocks[this.pos - 1] = prev; - this.current = prev[0]; - this.blocks = this.blocks.slice(0, -1); - this.pos -= 1; - return this; - }; - - return Parser; - })(); - - if (typeof module !== 'undefined' && module !== null) { - module.exports = Parser; - } else if (typeof window !== 'undefined' && window !== null) { - window.HyperDown = Parser; - } + var Parser, + slice = [].slice; + + Parser = (function () { + var array_keys, array_values, htmlspecialchars, pL, preg_quote, str_replace, trim, ucfirst; + + ucfirst = function (str) { + return str.charAt(0).toUpperCase() + str.substring(1); + }; + + preg_quote = function (str) { + return str.replace(/[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); + }; + + pL = 'A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC'; + + str_replace = function (search, replace, str) { + var i, j, l, len, len1, val; + if (search instanceof Array) { + if (replace instanceof Array) { + for (i = j = 0, len = search.length; j < len; i = ++j) { + val = search[i]; + str = str_replace(val, replace[i], str); + } + } else { + for (l = 0, len1 = search.length; l < len1; l++) { + val = search[l]; + str = str_replace(val, replace, str); + } + } + } else { + search = preg_quote(search); + str = str.replace(new RegExp(search, 'g'), replace.replace(/\$/g, '$$$$')); + } + return str; + }; + + htmlspecialchars = function (str) { + return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); + }; + + trim = function (str, ch) { + var c, i, j, ref, search; + if (ch == null) { + ch = null; + } + if (ch != null) { + search = ''; + for (i = j = 0, ref = ch.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { + c = ch[i]; + c = preg_quote(c); + search += c; + } + search = '[' + search + ']*'; + return str.replace(new RegExp('^' + search), '').replace(new RegExp(search + '$'), ''); + } else { + return str.replace(/^\s*/, '').replace(/\s*$/, ''); + } + }; + + array_keys = function (arr) { + var _, j, k, len, result; + result = []; + if (arr instanceof Array) { + for (k = j = 0, len = arr.length; j < len; k = ++j) { + _ = arr[k]; + result.push(k); + } + } else { + for (k in arr) { + result.push(k); + } + } + return result; + }; + + array_values = function (arr) { + var _, j, len, result, v; + result = []; + if (arr instanceof Array) { + for (j = 0, len = arr.length; j < len; j++) { + v = arr[j]; + result.push(v); + } + } else { + for (_ in arr) { + v = arr[_]; + result.push(v); + } + } + return result; + }; + + function Parser() { + this.commonWhiteList = 'kbd|b|i|strong|em|sup|sub|br|code|del|a|hr|small'; + this.blockHtmlTags = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|svg|script|noscript'; + this.specialWhiteList = { + table: 'table|tbody|thead|tfoot|tr|td|th' + }; + this.hooks = {}; + this.html = false; + this.line = false; + this.blockParsers = [ + ['code', 10], + ['shtml', 20], + ['pre', 30], + ['ahtml', 40], + ['shr', 50], + ['list', 60], + ['math', 70], + ['html', 80], + ['footnote', 90], + ['definition', 100], + ['quote', 110], + ['table', 120], + ['sh', 130], + ['mh', 140], + ['dhr', 150], + ['default', 9999] + ]; + this.parsers = {}; + } + + Parser.prototype.makeHtml = function (text) { + var html, j, len, name, parser, ref; + this.footnotes = []; + this.definitions = {}; + this.holders = {}; + this.uniqid = Math.ceil(Math.random() * 10000000) + Math.ceil(Math.random() * 10000000); + this.id = 0; + this.blockParsers.sort(function (a, b) { + if (a[1] < b[1]) { + return -1; + } else { + return 1; + } + }); + ref = this.blockParsers; + for (j = 0, len = ref.length; j < len; j++) { + parser = ref[j]; + name = parser[0]; + if (parser[2] !== void 0) { + this.parsers[name] = parser[2]; + } else { + this.parsers[name] = this['parseBlock' + ucfirst(name)].bind(this); + } + } + text = this.initText(text); + html = this.parse(text); + html = this.makeFootnotes(html); + html = this.optimizeLines(html); + return this.call('makeHtml', html); + }; + + Parser.prototype.enableHtml = function (html1) { + this.html = html1 != null ? html1 : true; + }; + + Parser.prototype.enableLine = function (line1) { + this.line = line1 != null ? line1 : true; + }; + + Parser.prototype.hook = function (type, cb) { + if (this.hooks[type] == null) { + this.hooks[type] = []; + } + return this.hooks[type].push(cb); + }; + + Parser.prototype.makeHolder = function (str) { + var key; + key = '|\r' + this.uniqid + this.id + '\r|'; + this.id += 1; + this.holders[key] = str; + return key; + }; + + Parser.prototype.initText = function (text) { + return text + .replace(/\t/g, ' ') + .replace(/\r/g, '') + .replace(/(\u000A|\u000D|\u2028|\u2029)/g, '\n'); + }; + + Parser.prototype.makeFootnotes = function (html) { + var index, val; + if (this.footnotes.length > 0) { + html += '

      '; + index = 1; + while ((val = this.footnotes.shift())) { + if (typeof val === 'string') { + val += ' '; + } else { + val[val.length - 1] += ' '; + val = val.length > 1 ? this.parse(val.join('\n')) : this.parseInline(val[0]); + } + html += '
    1. ' + val + '
    2. '; + index += 1; + } + html += '
    '; + } + return html; + }; + + Parser.prototype.parse = function (text, inline, offset) { + var block, blocks, end, extract, html, j, len, lines, method, result, start, type, value; + if (inline == null) { + inline = false; + } + if (offset == null) { + offset = 0; + } + lines = []; + blocks = this.parseBlock(text, lines); + html = ''; + if (inline && blocks.length === 1 && blocks[0][0] === 'normal') { + blocks[0][3] = true; + } + for (j = 0, len = blocks.length; j < len; j++) { + block = blocks[j]; + (type = block[0]), (start = block[1]), (end = block[2]), (value = block[3]); + extract = lines.slice(start, end + 1); + method = 'parse' + ucfirst(type); + extract = this.call('before' + ucfirst(method), extract, value); + result = this[method](extract, value, start + offset, end + offset); + result = this.call('after' + ucfirst(method), result, value); + html += result; + } + return html; + }; + + Parser.prototype.call = function () { + var args, callback, j, len, ref, type, value; + (type = arguments[0]), (args = 2 <= arguments.length ? slice.call(arguments, 1) : []); + value = args[0]; + if (this.hooks[type] == null) { + return value; + } + ref = this.hooks[type]; + for (j = 0, len = ref.length; j < len; j++) { + callback = ref[j]; + value = callback.apply(this, args); + args[0] = value; + } + return value; + }; + + Parser.prototype.releaseHolder = function (text, clearHolders) { + var deep; + if (clearHolders == null) { + clearHolders = true; + } + deep = 0; + while (text.indexOf('\r') >= 0 && deep < 10) { + text = str_replace(array_keys(this.holders), array_values(this.holders), text); + deep += 1; + } + if (clearHolders) { + this.holders = {}; + } + return text; + }; + + Parser.prototype.markLine = function (start, end) { + if (end == null) { + end = -1; + } + if (this.line) { + end = end < 0 ? start : end; + return ''; + } + return ''; + }; + + Parser.prototype.markLines = function (lines, start) { + var i; + i = -1; + if (this.line) { + return lines.map( + (function (_this) { + return function (line) { + i += 1; + return _this.markLine(start + i) + line; + }; + })(this) + ); + } else { + return lines; + } + }; + + Parser.prototype.optimizeLines = function (html) { + var last, regex; + last = 0; + regex = new RegExp('class="line" data\\-start="([0-9]+)" data\\-end="([0-9]+)" (data\\-id="' + this.uniqid + '")', 'g'); + if (this.line) { + return html.replace(regex, function () { + var matches, replace; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + if (last !== parseInt(matches[1])) { + replace = 'class="line" data-start="' + last + '" data-start-original="' + matches[1] + '" data-end="' + matches[2] + '" ' + matches[3]; + } else { + replace = matches[0]; + } + last = 1 + parseInt(matches[2]); + return replace; + }); + } else { + return html; + } + }; + + Parser.prototype.parseInline = function (text, whiteList, clearHolders, enableAutoLink) { + var regex; + if (whiteList == null) { + whiteList = ''; + } + if (clearHolders == null) { + clearHolders = true; + } + if (enableAutoLink == null) { + enableAutoLink = true; + } + text = this.call('beforeParseInline', text); + text = text.replace( + /(^|[^\\])(`+)(.+?)\2/gm, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return matches[1] + _this.makeHolder('' + htmlspecialchars(matches[3]) + ''); + }; + })(this) + ); + text = text.replace( + /(^|[^\\])(\$+)(.+?)\2/gm, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return matches[1] + _this.makeHolder(matches[2] + htmlspecialchars(matches[3]) + matches[2]); + }; + })(this) + ); + text = text.replace( + /\\(.)/g, + (function (_this) { + return function () { + var escaped, matches, prefix; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + prefix = matches[1].match(/^[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]$/) ? '' : '\\'; + escaped = htmlspecialchars(matches[1]); + escaped = escaped.replace(/\$/g, '$'); + return _this.makeHolder(prefix + escaped); + }; + })(this) + ); + text = text.replace( + /<(https?:\/\/.+)>/gi, + (function (_this) { + return function () { + var link, matches, url; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + url = _this.cleanUrl(matches[1]); + link = _this.call('parseLink', matches[1]); + return _this.makeHolder('' + link + ''); + }; + })(this) + ); + text = text.replace( + /<(\/?)([a-z0-9-]+)(\s+[^>]*)?>/gi, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + if (_this.html || ('|' + _this.commonWhiteList + '|' + whiteList + '|').indexOf('|' + matches[2].toLowerCase() + '|') >= 0) { + return _this.makeHolder(matches[0]); + } else { + return _this.makeHolder(htmlspecialchars(matches[0])); + } + }; + })(this) + ); + if (this.html) { + text = text.replace( + //g, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return _this.makeHolder(matches[0]); + }; + })(this) + ); + } + text = str_replace(['<', '>'], ['<', '>'], text); + text = text.replace( + /\[\^((?:[^\]]|\\\]|\\\[)+?)\]/g, + (function (_this) { + return function () { + var id, matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + id = _this.footnotes.indexOf(matches[1]); + if (id < 0) { + id = _this.footnotes.length + 1; + _this.footnotes.push(_this.parseInline(matches[1], '', false)); + } + return _this.makeHolder('' + id + ''); + }; + })(this) + ); + text = text.replace( + /!\[((?:[^\]]|\\\]|\\\[)*?)\]\(((?:[^\)]|\\\)|\\\()+?)\)/g, + (function (_this) { + return function () { + var escaped, matches, url; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + escaped = htmlspecialchars(_this.escapeBracket(matches[1])); + url = _this.escapeBracket(matches[2]); + url = _this.cleanUrl(url); + return _this.makeHolder('' + escaped + ''); + }; + })(this) + ); + text = text.replace( + /!\[((?:[^\]]|\\\]|\\\[)*?)\]\[((?:[^\]]|\\\]|\\\[)+?)\]/g, + (function (_this) { + return function () { + var escaped, matches, result; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + escaped = htmlspecialchars(_this.escapeBracket(matches[1])); + result = _this.definitions[matches[2]] != null ? '' + escaped + '' : escaped; + return _this.makeHolder(result); + }; + })(this) + ); + text = text.replace( + /\[((?:[^\]]|\\\]|\\\[)+?)\]\(((?:[^\)]|\\\)|\\\()+?)\)/g, + (function (_this) { + return function () { + var escaped, matches, url; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + escaped = _this.parseInline(_this.escapeBracket(matches[1]), '', false, false); + url = _this.escapeBracket(matches[2]); + url = _this.cleanUrl(url); + return _this.makeHolder('' + escaped + ''); + }; + })(this) + ); + text = text.replace( + /\[((?:[^\]]|\\\]|\\\[)+?)\]\[((?:[^\]]|\\\]|\\\[)+?)\]/g, + (function (_this) { + return function () { + var escaped, matches, result; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + escaped = _this.parseInline(_this.escapeBracket(matches[1]), '', false, false); + result = _this.definitions[matches[2]] != null ? '' + escaped + '' : escaped; + return _this.makeHolder(result); + }; + })(this) + ); + text = this.parseInlineCallback(text); + text = text.replace(/<([_a-z0-9-\.\+]+@[^@]+\.[a-z]{2,})>/gi, '$1'); + if (enableAutoLink) { + regex = new RegExp('(^|[^"])((https?):[' + pL + '_0-9-\\./%#!@\\?\\[\\]\\+=~\\|\\,&\\(\\)]+)($|[^"])', 'ig'); + text = text.replace( + regex, + (function (_this) { + return function () { + var link, matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + link = _this.call('parseLink', matches[2]); + return matches[1] + '' + link + '' + matches[4]; + }; + })(this) + ); + } + text = this.call('afterParseInlineBeforeRelease', text); + text = this.releaseHolder(text, clearHolders); + text = this.call('afterParseInline', text); + return text; + }; + + Parser.prototype.parseInlineCallback = function (text) { + text = text.replace( + /(\*{3})((?:.|\r)+?)\1/gm, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return '' + _this.parseInlineCallback(matches[2]) + ''; + }; + })(this) + ); + text = text.replace( + /(\*{2})((?:.|\r)+?)\1/gm, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return '' + _this.parseInlineCallback(matches[2]) + ''; + }; + })(this) + ); + text = text.replace( + /(\*)((?:.|\r)+?)\1/gm, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return '' + _this.parseInlineCallback(matches[2]) + ''; + }; + })(this) + ); + text = text.replace( + /(\s+|^)(_{3})((?:.|\r)+?)\2(\s+|$)/gm, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return matches[1] + '' + _this.parseInlineCallback(matches[3]) + '' + matches[4]; + }; + })(this) + ); + text = text.replace( + /(\s+|^)(_{2})((?:.|\r)+?)\2(\s+|$)/gm, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return matches[1] + '' + _this.parseInlineCallback(matches[3]) + '' + matches[4]; + }; + })(this) + ); + text = text.replace( + /(\s+|^)(_)((?:.|\r)+?)\2(\s+|$)/gm, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return matches[1] + '' + _this.parseInlineCallback(matches[3]) + '' + matches[4]; + }; + })(this) + ); + text = text.replace( + /(~{2})((?:.|\r)+?)\1/gm, + (function (_this) { + return function () { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return '' + _this.parseInlineCallback(matches[2]) + ''; + }; + })(this) + ); + return text; + }; + + Parser.prototype.parseBlock = function (text, lines) { + var block, j, key, l, len, len1, line, name, parser, pass, ref, ref1, state; + ref = text.split('\n'); + for (j = 0, len = ref.length; j < len; j++) { + line = ref[j]; + lines.push(line); + } + this.blocks = []; + this.current = 'normal'; + this.pos = -1; + state = { + special: array_keys(this.specialWhiteList).join('|'), + empty: 0, + html: false + }; + for (key = l = 0, len1 = lines.length; l < len1; key = ++l) { + line = lines[key]; + block = this.getBlock(); + if (block != null) { + block = block.slice(0); + } + if (this.current !== 'normal') { + pass = this.parsers[this.current](block, key, line, state, lines); + if (!pass) { + continue; + } + } + ref1 = this.parsers; + for (name in ref1) { + parser = ref1[name]; + if (name !== this.current) { + pass = parser(block, key, line, state, lines); + if (!pass) { + break; + } + } + } + } + return this.optimizeBlocks(this.blocks, lines); + }; + + Parser.prototype.parseBlockList = function (block, key, line, state) { + var matches, space; + if (this.isBlock('list') && !line.match(/^\s*\[((?:[^\]]|\\\]|\\\[)+?)\]:\s*(.+)$/)) { + if (state.empty <= 1 && !!(matches = line.match(/^(\s+)/)) && matches[1].length > block[3]) { + state.empty = 0; + this.setBlock(key); + return false; + } else if (line.match(/^\s*$/) && state.empty === 0) { + state.empty += 1; + this.setBlock(key); + return false; + } + } + if (!!(matches = line.match(/^(\s*)((?:[0-9]+\.)|\-|\+|\*)\s+/i))) { + space = matches[1].length; + state.empty = 0; + if (this.isBlock('list')) { + this.setBlock(key, space); + } else { + this.startBlock('list', key, space); + } + return false; + } + return true; + }; + + Parser.prototype.parseBlockCode = function (block, key, line) { + var isAfterList, matches, space; + if (!!(matches = line.match(/^(\s*)(~{3,}|`{3,})([^`~]*)$/i))) { + if (this.isBlock('code')) { + isAfterList = block[3][2]; + if (isAfterList) { + this.combineBlock().setBlock(key); + } else { + this.setBlock(key).endBlock(); + } + } else { + isAfterList = false; + if (this.isBlock('list')) { + space = block[3]; + isAfterList = (space > 0 && matches[1].length >= space) || matches[1].length > space; + } + this.startBlock('code', key, [matches[1], matches[3], isAfterList]); + } + return false; + } else if (this.isBlock('code')) { + this.setBlock(key); + return false; + } + return true; + }; + + Parser.prototype.parseBlockShtml = function (block, key, line, state) { + var matches; + if (this.html) { + if (!!(matches = line.match(/^(\s*)!!!(\s*)$/))) { + if (this.isBlock('shtml')) { + this.setBlock(key).endBlock(); + } else { + this.startBlock('shtml', key); + } + return false; + } else if (this.isBlock('shtml')) { + this.setBlock(key); + return false; + } + } + return true; + }; + + Parser.prototype.parseBlockAhtml = function (block, key, line, state) { + var htmlTagAllRegExp, htmlTagRegExp, lastMatch, m, matches; + if (this.html) { + htmlTagRegExp = new RegExp('^\\s*<(' + this.blockHtmlTags + ')(\\s+[^>]*)?>', 'i'); + if ((matches = line.match(htmlTagRegExp))) { + if (this.isBlock('ahtml')) { + this.setBlock(key); + return false; + } else if (matches[2] === void 0 || matches[2] !== '/') { + this.startBlock('ahtml', key); + htmlTagAllRegExp = new RegExp('\\s*<(' + this.blockHtmlTags + ')(\\s+[^>]*)?>', 'ig'); + while (true) { + m = htmlTagAllRegExp.exec(line); + if (!m) { + break; + } + lastMatch = m[1]; + } + if (0 <= line.indexOf('')) { + this.endBlock(); + } else { + state.html = lastMatch; + } + return false; + } + } else if (!!state.html && 0 <= line.indexOf('')) { + this.setBlock(key).endBlock(); + state.html = false; + return false; + } else if (this.isBlock('ahtml')) { + this.setBlock(key); + return false; + } else if (!!(matches = line.match(/^\s*\s*$/))) { + this.startBlock('ahtml', key).endBlock(); + return false; + } + } + return true; + }; + + Parser.prototype.parseBlockMath = function (block, key, line) { + var matches; + if (!!(matches = line.match(/^(\s*)\$\$(\s*)$/))) { + if (this.isBlock('math')) { + this.setBlock(key).endBlock(); + } else { + this.startBlock('math', key); + } + return false; + } else if (this.isBlock('math')) { + this.setBlock(key); + return false; + } + return true; + }; + + Parser.prototype.parseBlockPre = function (block, key, line, state) { + if (!!line.match(/^ {4}/)) { + if (this.isBlock('pre')) { + this.setBlock(key); + } else { + this.startBlock('pre', key); + } + return false; + } else if (this.isBlock('pre') && line.match(/^\s*$/)) { + this.setBlock(key); + return false; + } + return true; + }; + + Parser.prototype.parseBlockHtml = function (block, key, line, state) { + var matches, tag; + if (!!(matches = line.match(new RegExp('^\\s*<(' + state.special + ')(\\s+[^>]*)?>', 'i')))) { + tag = matches[1].toLowerCase(); + if (!this.isBlock('html', tag) && !this.isBlock('pre')) { + this.startBlock('html', key, tag); + } + return false; + } else if (!!(matches = line.match(new RegExp('\\s*$', 'i')))) { + tag = matches[1].toLowerCase(); + if (this.isBlock('html', tag)) { + this.setBlock(key).endBlock(); + } + return false; + } else if (this.isBlock('html')) { + this.setBlock(key); + return false; + } + return true; + }; + + Parser.prototype.parseBlockFootnote = function (block, key, line) { + var matches, space; + if (!!(matches = line.match(/^\[\^((?:[^\]]|\\\]|\\\[)+?)\]:/))) { + space = matches[0].length - 1; + this.startBlock('footnote', key, [space, matches[1]]); + return false; + } + return true; + }; + + Parser.prototype.parseBlockDefinition = function (block, key, line) { + var matches; + if (!!(matches = line.match(/^\s*\[((?:[^\]]|\\\]|\\\[)+?)\]:\s*(.+)$/))) { + this.definitions[matches[1]] = this.cleanUrl(matches[2]); + this.startBlock('definition', key).endBlock(); + return false; + } + return true; + }; + + Parser.prototype.parseBlockQuote = function (block, key, line) { + var matches; + if (!!(matches = line.match(/^(\s*)>/))) { + if (this.isBlock('list') && matches[1].length > 0) { + this.setBlock(key); + } else if (this.isBlock('quote')) { + this.setBlock(key); + } else { + this.startBlock('quote', key); + } + return false; + } + return true; + }; + + Parser.prototype.parseBlockTable = function (block, key, line, state, lines) { + var align, aligns, head, j, len, matches, row, rows; + if (!!(matches = line.match(/^((?:(?:(?:\||\+)(?:[ :]*\-+[ :]*)(?:\||\+))|(?:(?:[ :]*\-+[ :]*)(?:\||\+)(?:[ :]*\-+[ :]*))|(?:(?:[ :]*\-+[ :]*)(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-+[ :]*)))+)$/))) { + if (this.isBlock('table')) { + block[3][0].push(block[3][2]); + block[3][2] += 1; + this.setBlock(key, block[3]); + } else { + head = 0; + if (block == null || block[0] !== 'normal' || lines[block[2]].match(/^\s*$/)) { + this.startBlock('table', key); + } else { + head = 1; + this.backBlock(1, 'table'); + } + if (matches[1][0] === '|') { + matches[1] = matches[1].substring(1); + if (matches[1][matches[1].length - 1] === '|') { + matches[1] = matches[1].substring(0, matches[1].length - 1); + } + } + rows = matches[1].split(/\+|\|/); + aligns = []; + for (j = 0, len = rows.length; j < len; j++) { + row = rows[j]; + align = 'none'; + if (!!(matches = row.match(/^\s*(:?)\-+(:?)\s*$/))) { + if (!!matches[1] && !!matches[2]) { + align = 'center'; + } else if (!!matches[1]) { + align = 'left'; + } else if (!!matches[2]) { + align = 'right'; + } + } + aligns.push(align); + } + this.setBlock(key, [[head], aligns, head + 1]); + } + return false; + } + return true; + }; + + Parser.prototype.parseBlockSh = function (block, key, line) { + var matches, num; + if (!!(matches = line.match(/^(#+)(.*)$/))) { + num = Math.min(matches[1].length, 6); + this.startBlock('sh', key, num).endBlock(); + return false; + } + return true; + }; + + Parser.prototype.parseBlockMh = function (block, key, line, state, lines) { + var matches; + if (!!(matches = line.match(/^\s*((=|-){2,})\s*$/)) && block != null && block[0] === 'normal' && !lines[block[2]].match(/^\s*$/)) { + if (this.isBlock('normal')) { + this.backBlock(1, 'mh', matches[1][0] === '=' ? 1 : 2) + .setBlock(key) + .endBlock(); + } else { + this.startBlock('normal', key); + } + return false; + } + return true; + }; + + Parser.prototype.parseBlockShr = function (block, key, line) { + if (!!line.match(/^(\* *){3,}\s*$/)) { + this.startBlock('hr', key).endBlock(); + return false; + } + return true; + }; + + Parser.prototype.parseBlockDhr = function (block, key, line) { + if (!!line.match(/^(- *){3,}\s*$/)) { + this.startBlock('hr', key).endBlock(); + return false; + } + return true; + }; + + Parser.prototype.parseBlockDefault = function (block, key, line, state) { + var matches; + if (this.isBlock('footnote')) { + matches = line.match(/^(\s*)/); + if (matches[1].length >= block[3][0]) { + this.setBlock(key); + } else { + this.startBlock('normal', key); + } + } else if (this.isBlock('table')) { + if (0 <= line.indexOf('|')) { + block[3][2] += 1; + this.setBlock(key, block[3]); + } else { + this.startBlock('normal', key); + } + } else if (this.isBlock('quote')) { + if (!line.match(/^(\s*)$/)) { + this.setBlock(key); + } else { + this.startBlock('normal', key); + } + } else { + if (block == null || block[0] !== 'normal') { + this.startBlock('normal', key); + } else { + this.setBlock(key); + } + } + return true; + }; + + Parser.prototype.optimizeBlocks = function (_blocks, _lines) { + var block, blocks, from, isEmpty, key, lines, moved, nextBlock, prevBlock, to, type, types; + blocks = _blocks.slice(0); + lines = _lines.slice(0); + blocks = this.call('beforeOptimizeBlocks', blocks, lines); + key = 0; + while (blocks[key] != null) { + moved = false; + block = blocks[key]; + prevBlock = blocks[key - 1] != null ? blocks[key - 1] : null; + nextBlock = blocks[key + 1] != null ? blocks[key + 1] : null; + (type = block[0]), (from = block[1]), (to = block[2]); + if ('pre' === type) { + isEmpty = lines.slice(block[1], block[2] + 1).reduce(function (result, line) { + return line.match(/^\s*$/) && result; + }, true); + if (isEmpty) { + block[0] = type = 'normal'; + } + } + if ('normal' === type) { + types = ['list', 'quote']; + if (from === to && lines[from].match(/^\s*$/) && prevBlock != null && nextBlock != null) { + if (prevBlock[0] === nextBlock[0] && types.indexOf(prevBlock[0]) >= 0) { + blocks[key - 1] = [prevBlock[0], prevBlock[1], nextBlock[2], null]; + blocks.splice(key, 2); + moved = true; + } + } + } + if (!moved) { + key += 1; + } + } + return this.call('afterOptimizeBlocks', blocks, lines); + }; + + Parser.prototype.parseCode = function (lines, parts, start) { + var blank, count, isEmpty, lang, rel, str; + (blank = parts[0]), (lang = parts[1]); + lang = trim(lang); + count = blank.length; + if (!lang.match(/^[_a-z0-9-\+\#\:\.]+$/i)) { + lang = null; + } else { + parts = lang.split(':'); + if (parts.length > 1) { + (lang = parts[0]), (rel = parts[1]); + lang = trim(lang); + rel = trim(rel); + } + } + isEmpty = true; + lines = lines.slice(1, -1).map(function (line) { + line = line.replace(new RegExp('/^[ ]{' + count + '}/'), ''); + if (isEmpty && !line.match(/^\s*$/)) { + isEmpty = false; + } + return htmlspecialchars(line); + }); + str = this.markLines(lines, start + 1).join('\n'); + if (isEmpty) { + return ''; + } else { + return '
    ' + str + '
    '; + } + }; + + Parser.prototype.parsePre = function (lines, value, start) { + var str; + lines = lines.map(function (line) { + return htmlspecialchars(line.substring(4)); + }); + str = this.markLines(lines, start).join('\n'); + if (str.match(/^\s*$/)) { + return ''; + } else { + return '
    ' + str + '
    '; + } + }; + + Parser.prototype.parseAhtml = function (lines, value, start) { + return trim(this.markLines(lines, start).join('\n')); + }; + + Parser.prototype.parseShtml = function (lines, value, start) { + return trim(this.markLines(lines.slice(1, -1), start + 1).join('\n')); + }; + + Parser.prototype.parseMath = function (lines, value, start, end) { + return '

    ' + this.markLine(start, end) + htmlspecialchars(lines.join('\n')) + '

    '; + }; + + Parser.prototype.parseSh = function (lines, num, start, end) { + var line; + line = this.markLine(start, end) + this.parseInline(trim(lines[0], '# ')); + if (line.match(/^\s*$/)) { + return ''; + } else { + return '' + line + ''; + } + }; + + Parser.prototype.parseMh = function (lines, num, start, end) { + return this.parseSh(lines, num, start, end); + }; + + Parser.prototype.parseQuote = function (lines, value, start) { + var str; + lines = lines.map(function (line) { + return line.replace(/^\s*> ?/, ''); + }); + str = lines.join('\n'); + if (str.match(/^\s*$/)) { + return ''; + } else { + return '
    ' + this.parse(str, true, start) + '
    '; + } + }; + + Parser.prototype.parseList = function (lines, value, start) { + var found, html, j, key, l, lastType, leftLines, leftStart, len, len1, line, matches, minSpace, row, rows, secondFound, secondMinSpace, space, text, type; + html = ''; + minSpace = 99999; + secondMinSpace = 99999; + found = false; + secondFound = false; + rows = []; + for (key = j = 0, len = lines.length; j < len; key = ++j) { + line = lines[key]; + if ((matches = line.match(/^(\s*)((?:[0-9]+\.?)|\-|\+|\*)(\s+)(.*)$/i))) { + space = matches[1].length; + type = 0 <= '+-*'.indexOf(matches[2]) ? 'ul' : 'ol'; + minSpace = Math.min(space, minSpace); + found = true; + if (space > 0) { + secondMinSpace = Math.min(space, secondMinSpace); + secondFound = true; + } + rows.push([space, type, line, matches[4]]); + } else { + rows.push(line); + if (!!(matches = line.match(/^(\s*)/))) { + space = matches[1].length; + if (space > 0) { + secondMinSpace = Math.min(space, secondMinSpace); + secondFound = true; + } + } + } + } + minSpace = found ? minSpace : 0; + secondMinSpace = secondFound ? secondMinSpace : minSpace; + lastType = ''; + leftLines = []; + leftStart = 0; + for (key = l = 0, len1 = rows.length; l < len1; key = ++l) { + row = rows[key]; + if (row instanceof Array) { + (space = row[0]), (type = row[1]), (line = row[2]), (text = row[3]); + if (space !== minSpace) { + leftLines.push(line.replace(new RegExp('^\\s{' + secondMinSpace + '}'), '')); + } else { + if (leftLines.length > 0) { + html += '
  • ' + this.parse(leftLines.join('\n'), true, start + leftStart) + '
  • '; + } + if (lastType !== type) { + if (!!lastType) { + html += ''; + } + html += '<' + type + '>'; + } + leftStart = key; + leftLines = [text]; + lastType = type; + } + } else { + leftLines.push(row.replace(new RegExp('^\\s{' + secondMinSpace + '}'), '')); + } + } + if (leftLines.length > 0) { + html += '
  • ' + this.parse(leftLines.join('\n'), true, start + leftStart) + ('
  • '); + } + return html; + }; + + Parser.prototype.parseTable = function (lines, value, start) { + var aligns, body, column, columns, head, html, ignores, j, key, l, last, len, len1, line, num, output, row, rows, tag, text; + (ignores = value[0]), (aligns = value[1]); + head = + ignores.length > 0 && + ignores.reduce(function (prev, curr) { + return curr + prev; + }) > 0; + html = ''; + body = head ? null : true; + output = false; + for (key = j = 0, len = lines.length; j < len; key = ++j) { + line = lines[key]; + if (0 <= ignores.indexOf(key)) { + if (head && output) { + head = false; + body = true; + } + continue; + } + line = trim(line); + output = true; + if (line[0] === '|') { + line = line.substring(1); + if (line[line.length - 1] === '|') { + line = line.substring(0, line.length - 1); + } + } + rows = line.split('|').map(function (row) { + if (row.match(/^\s*$/)) { + return ' '; + } else { + return trim(row); + } + }); + columns = {}; + last = -1; + for (l = 0, len1 = rows.length; l < len1; l++) { + row = rows[l]; + if (row.length > 0) { + last += 1; + columns[last] = [columns[last] != null ? columns[last][0] + 1 : 1, row]; + } else if (columns[last] != null) { + columns[last][0] += 1; + } else { + columns[0] = [1, row]; + } + } + if (head) { + html += ''; + } else if (body) { + html += ''; + } + html += ' 1) { + html += ' colspan="' + num + '"'; + } + if (aligns[key] != null && aligns[key] !== 'none') { + html += ' align="' + aligns[key] + '"'; + } + html += '>' + this.parseInline(text) + (''); + } + html += ''; + if (head) { + html += ''; + } else if (body) { + body = false; + } + } + if (body !== null) { + html += ''; + } + return (html += '
    '); + }; + + Parser.prototype.parseHr = function (lines, value, start) { + if (this.line) { + return '
    '; + } else { + return '
    '; + } + }; + + Parser.prototype.parseNormal = function (lines, inline, start) { + var key, str; + if (inline == null) { + inline = false; + } + key = 0; + lines = lines.map( + (function (_this) { + return function (line) { + line = _this.parseInline(line); + if (!line.match(/^\s*$/)) { + line = _this.markLine(start + key) + line; + } + key += 1; + return line; + }; + })(this) + ); + str = trim(lines.join('\n')); + str = str.replace(/(\n\s*){2,}/g, '

    '); + str = str.replace(/\n/g, '
    '); + if (str.match(/^\s*$/)) { + return ''; + } else { + if (inline) { + return str; + } else { + return '

    ' + str + '

    '; + } + } + }; + + Parser.prototype.parseFootnote = function (lines, value) { + var index, note, space; + (space = value[0]), (note = value[1]); + index = this.footnotes.indexOf(note); + if (index >= 0) { + lines = lines.slice(0); + lines[0] = lines[0].replace(/^\[\^((?:[^\]]|\]|\[)+?)\]:/, ''); + this.footnotes[index] = lines; + } + return ''; + }; + + Parser.prototype.parseDefinition = function () { + return ''; + }; + + Parser.prototype.parseHtml = function (lines, type, start) { + lines = lines.map( + (function (_this) { + return function (line) { + return _this.parseInline(line, _this.specialWhiteList[type] != null ? _this.specialWhiteList[type] : ''); + }; + })(this) + ); + return this.markLines(lines, start).join('\n'); + }; + + Parser.prototype.cleanUrl = function (url) { + var matches, regexUrl, regexWord; + regexUrl = new RegExp('^\\s*((http|https|ftp|mailto):[' + pL + '_a-z0-9-:\\.\\*/%#;!@\\?\\[\\]\\+=~\\|\\,&\\(\\)]+)', 'i'); + regexWord = new RegExp('^\\s*([' + pL + '_a-z0-9-:\\.\\*/%#!@\\?\\+=~\\|\\,&]+)', 'i'); + if (!!(matches = url.match(regexUrl))) { + return matches[1]; + } else if (!!(matches = url.match(regexWord))) { + return matches[1]; + } else { + return '#'; + } + }; + + Parser.prototype.escapeBracket = function (str) { + return str_replace(['\\[', '\\]', '\\(', '\\)'], ['[', ']', '(', ')'], str); + }; + + Parser.prototype.startBlock = function (type, start, value) { + if (value == null) { + value = null; + } + this.pos += 1; + this.current = type; + this.blocks.push([type, start, start, value]); + return this; + }; + + Parser.prototype.endBlock = function () { + this.current = 'normal'; + return this; + }; + + Parser.prototype.isBlock = function (type, value) { + if (value == null) { + value = null; + } + return this.current === type && (null === value ? true : this.blocks[this.pos][3] === value); + }; + + Parser.prototype.getBlock = function () { + if (this.blocks[this.pos] != null) { + return this.blocks[this.pos]; + } else { + return null; + } + }; + + Parser.prototype.setBlock = function (to, value) { + if (to == null) { + to = null; + } + if (value == null) { + value = null; + } + if (to !== null) { + this.blocks[this.pos][2] = to; + } + if (value !== null) { + this.blocks[this.pos][3] = value; + } + return this; + }; + + Parser.prototype.backBlock = function (step, type, value) { + var item, last; + if (value == null) { + value = null; + } + if (this.pos < 0) { + return this.startBlock(type, 0, value); + } + last = this.blocks[this.pos][2]; + this.blocks[this.pos][2] = last - step; + item = [type, last - step + 1, last, value]; + if (this.blocks[this.pos][1] <= this.blocks[this.pos][2]) { + this.pos += 1; + this.blocks.push(item); + } else { + this.blocks[this.pos] = item; + } + this.current = type; + return this; + }; + + Parser.prototype.combineBlock = function () { + var current, prev; + if (this.pos < 1) { + return this; + } + prev = this.blocks[this.pos - 1].slice(0); + current = this.blocks[this.pos].slice(0); + prev[2] = current[2]; + this.blocks[this.pos - 1] = prev; + this.current = prev[0]; + this.blocks = this.blocks.slice(0, -1); + this.pos -= 1; + return this; + }; + + return Parser; + })(); + + if (typeof module !== 'undefined' && module !== null) { + module.exports = Parser; + } else if (typeof window !== 'undefined' && window !== null) { + window.HyperDown = Parser; + } }.call(this)); diff --git a/typecho/write/js/joe.write.chunk.js b/typecho/write/js/joe.write.chunk.js index 95aec92..f6bdcef 100644 --- a/typecho/write/js/joe.write.chunk.js +++ b/typecho/write/js/joe.write.chunk.js @@ -1,4 +1,4 @@ -!function(){"use strict";let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=1;te)return r[t-1]<=e}(e))n+=u(e),t=e;else{if(!s(e))break;{let t=0,e=n-2;for(;0<=e&&s(c(i,e));)t++,e-=2;if(t%2==0)break;n+=2}}}return n}function a(t,e){for(;0this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){var n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),m.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){var i=[];return this.decompose(t,e,i,0),m.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=new v(this),i=new v(t);for(;;){if(e.next(),i.next(),e.lineBreak!=i.lineBreak||e.done!=i.done||e.value!=i.value)return!1;if(e.done)return!0}}iter(t=1){return new v(this,t)}iterRange(t,e=this.length){return new i(this,t,e)}toString(){return this.sliceString(0)}toJSON(){var t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new g(t):m.from(g.split(t,[])):d.empty}}"undefined"!=typeof Symbol&&(d.prototype[Symbol.iterator]=function(){return this.iter()});class g extends d{constructor(t,e=function(t){let e=-1;for(var i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(e,i,n,r){for(let t=0;;t++){var s=this.text[t],o=r+s.length;if(e<=(i?n:o))return new w(r,o,n,s);r=o+1,n++}}decompose(i,t,n,r){i=i<=0&&t>=this.length?this:new g(p(this.text,i,t),Math.min(t,this.length)-Math.max(0,i));if(1&r){let t=n.pop(),e=f(i.text,t.text.slice(),0,i.length);e.length<=32?n.push(new g(e,t.length+i.length)):(r=e.length>>1,n.push(new g(e.slice(0,r)),new g(e.slice(r))))}else n.push(i)}replace(t,e,i){if(!(i instanceof g))return super.replace(t,e,i);var n=f(this.text,f(i.text,p(this.text,0,t)),e),t=this.length+i.length-(e-t);return n.length<=32?new g(n,t):m.from(g.split(n,[]),t)}sliceString(r,s=this.length,o="\n"){let a="";for(let i=0,n=0;i<=s&&nr&&n&&(a+=o),ri&&(a+=t.slice(Math.max(0,r-i),s-i)),i=e+1}return a}flatten(t){for(var e of this.text)t.push(e)}static split(t,e){let i=[],n=-1;for(var r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new g(i,n)),i=[],n=-1);return-1=n&&(h=a&((n<=r?1:0)|(s<=e?2:0)),n>=r&&e<=s&&!h?o.push(t):t.decompose(r-n,s-n,o,h)),n=e+1}}replace(r,s,o){if(o.lines=n&&s<=e){var a=t.replace(r-n,s-n,o),h=this.lines-t.lines+a.lines;if(a.lines>4&&a.lines>h>>6){let t=this.children.slice();return t[i]=a,new m(t,this.length-(s-r)+o.length)}return super.replace(n,e,a)}n=e+1}return super.replace(r,s,o)}sliceString(r,s=this.length,o="\n"){let a="";for(let i=0,n=0;ir&&i&&(a+=o),rn&&(a+=t.sliceString(r-n,s-n,o)),n=e+1}return a}flatten(t){for(var e of this.children)e.flatten(t)}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(var n of t)i+=n.lines;if(i<32){var r,s=[];for(r of t)r.flatten(s);return new g(s,e)}let o=Math.max(32,i>>5),a=o<<1,h=o>>1,l=[],c=0,u=-1,d=[];function f(){0!=c&&(l.push(1==d.length?d[0]:m.from(d,u)),u=-1,c=d.length=0)}for(var p of t)!function t(e){let i;if(e.lines>a&&e instanceof m)for(var n of e.children)t(n);else e.lines>h&&(c>h||!c)?(f(),l.push(e)):e instanceof g&&c&&(i=d[d.length-1])instanceof g&&e.lines+i.lines<=32?(c+=e.lines,u+=e.length+1,d[d.length-1]=new g(i.text.concat(e.text),i.length+1+e.length)):(c+e.lines>o&&f(),c+=e.lines,u+=e.length+1,d.push(e))}(p);return f(),1==l.length?l[0]:new m(l,e)}}function f(s,o,a=0,h=1e9){for(let i=0,n=0,r=!0;nMath.max(0,n))return this.value=0==n?t:0t.length?n-=t.length:(this.nodes.push(t),this.offsets.push(0this.limit&&(this.value=0r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(i,n=i){for(let t=0,e=0;t"number"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeDesc");return new k(t)}}class M extends k{constructor(t,e){super(t),this.inserted=e}apply(s){if(this.length!=s.length)throw new RangeError("Applying change set to a document with the wrong length");return D(this,(t,e,i,n,r)=>s=s.replace(i,i+(e-t),r),!1),s}mapDesc(t,e=!1){return O(this,t,e,!0)}invert(i){let n=this.sections.slice(),r=[];for(let t=0,e=0;t>1;r.length>1].toJSON()))}return n}static of(t,s,o){let a=[],h=[],l=0,i=null;function c(t=!1){if(t||a.length){ll&&C(a,t-l,-1),C(a,e-t,n),T(h,a,r),l=e)}}(t),c(!i),i}static empty(t){return new M(t?[t,-1]:[],[])}static fromJSON(i){if(!Array.isArray(i))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let e=0;ee&&"string"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==t.length)n.push(t[0],0);else{for(;r.length>1;if(n>1])),!(c||a==h.sections.length||h.sections[a+1]<0);)n=h.sections[a++],r=h.sections[a++];l(s,t,o,e,i),s=t,o=e}}}function O(t,e,r,i=!1){var s=[],o=i?[]:null;let a=new L(t),h=new L(e);for(let i=0,n=0;;)if(-1==a.ins)i+=a.len,a.next();else if(-1==h.ins&&nn&&!a.done&&i+a.leni&&n+h.lenh||0<=o.ins&&o.len>h)&&(t||l>1;return e>=t.length?d.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?d.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class B{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){var t=3&this.flags;return 3==t?null:t}get goalColumn(){var t=this.flags>>5;return 33554431==t?void 0:t}map(t,e=-1){var i=t.mapPos(this.from,e),e=t.mapPos(this.to,e);return i==this.from&&e==this.to?this:new B(i,e,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return E.range(t,e);e=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return E.range(this.anchor,e)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return E.range(t.anchor,t.head)}}class E{constructor(t,e=0){this.ranges=t,this.mainIndex=e}map(e,i=-1){return e.empty?this:E.create(this.ranges.map(t=>t.map(e,i)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;tt.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new E(t.ranges.map(t=>B.fromJSON(t)),t.main)}static single(t,e=t){return new E([E.range(t,e)],0)}static create(i,n=0){if(0==i.length)throw new RangeError("A selection needs at least one range");for(let t=0,e=0;et.from-e.from),i=e.indexOf(t);for(let t=1;tr.head?E.range(s,n):E.range(n,s)))}return new E(e,i)}(i.slice(),n);t=r.to}return new E(i,n)}static cursor(t,e=0,i,n){return new B(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i){i=(null!=i?i:33554431)<<5;return ee)throw new RangeError("Selection points outside of document")}let R=0;class H{constructor(t,e,i,n,r){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.extensions=r,this.id=R++,this.default=t([])}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:N),!!t.static,t.enables)}of(t){return new _([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new _(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new _(t,this,2,e)}from(e,i){return i=i||(t=>t),this.compute([e],t=>i(t.field(e)))}}function N(t,i){return t==i||t.length==i.length&&t.every((t,e)=>t===i[e])}class _{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=R++}dynamicSlot(t){var e,i;let n=this.value,r=this.facet.compareInput,s=t[this.id]>>1,o=2==this.type,a=!1,h=!1,l=[];for(i of this.dependencies)"doc"==i?a=!0:"selection"==i?h=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&l.push(t[i.id]);return(e,t)=>{if(!t||t.reconfigured)return e.values[s]=n(e),1;if(!(a&&t.docChanged||h&&(t.docChanged||t.selection)||l.some(t=>0<(1&K(e,t)))))return 0;var i=n(e),t=t.startState.values[s];return(o?function(e,i,n){if(e.length!=i.length)return!1;for(let t=0;tt===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(V).find(t=>t.field==this);return((null===e||void 0===e?void 0:e.create)||this.createF)(t)}slot(t){let o=t[this.id]>>1;return(t,e)=>{if(!e)return t.values[o]=this.create(t),1;let i,n=0;var r,s;e.reconfigured?(r=e.startState,s=this.id,s=null==(s=r.config.address[s])?null:s>>1,i=null==s?this.create(e.startState):e.startState.values[s],n=1):i=e.startState.values[o];e=this.updateF(i,e);return n||this.compareF(i,e)||(n=1),n&&(t.values[o]=e),n}}init(t){return[this,V.of({field:this,create:t})]}get extension(){return this}}const I={fallback:3,default:2,extend:1,override:0};function t(e){return t=>new F(t,e)}const W={fallback:t(I.fallback),default:t(I.default),extend:t(I.extend),override:t(I.override)};class F{constructor(t,e){this.inner=t,this.prec=e}}class q{of(t){return new j(this,t)}reconfigure(t){return q.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class j{constructor(t,e){this.compartment=t,this.inner=e}}class J{constructor(t,e,i,n,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,e,n){let i=[],r=Object.create(null);var s,o,a=new Map;for(s of function(t,a,h){let l=[[],[],[],[]],c=new Map;return function t(e,i){var n=c.get(e);if(null!=n){if(i<=n)return;var r=l[n].indexOf(e);-1t.concat(e))}(t,e,a))(s instanceof z?i:r[s.facet.id]||(r[s.facet.id]=[])).push(s);let h=Object.create(null),l=[],c=[];for(let e of i)h[e.id]=c.length<<1,c.push(t=>e.slot(t));for(o in r){let i=r[o],e=i[0].facet;if(i.every(t=>0==t.type)){h[e.id]=l.length<<1|1;let t=e.combine(i.map(t=>t.value));var u=n?n.config.address[e.id]:null;null!=u&&(u=G(n,u),e.compare(t,u)&&(t=u)),l.push(t)}else{for(let e of i)0==e.type?(h[e.id]=l.length<<1|1,l.push(e.value)):(h[e.id]=c.length<<1,c.push(t=>e.dynamicSlot(t)));h[e.id]=c.length<<1,c.push(t=>function(e,l,t){let c=t.map(t=>e[t.id]),u=t.map(t=>t.type),d=c.filter(t=>!(1&t)),f=e[l.id]>>1;return(e,t)=>{var i,n=t?t.reconfigured?t.startState.config.address[l.id]:f<<1:null;let r=null==n;for(i of d)1&K(e,i)&&(r=!0);if(!r)return 0;let s=[];for(let t=0;tt(h)),h,l)}}function K(t,e){if(1&e)return 2;var i=e>>1,e=t.status[i];if(4==e)throw new Error("Cyclic dependency between fields and/or facets");if(2&e)return e;t.status[i]=4;e=t.config.dynamicSlots[i](t,t.applying);return t.status[i]=2|e}function G(t,e){return(1&e?t.config.staticValues:t.values)[e>>1]}const U=H.define(),X=H.define({combine:t=>t.some(t=>t),static:!0}),Y=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),Q=H.define(),Z=H.define(),tt=H.define();class et{constructor(t,e){this.type=t,this.value=e}static define(){return new it}}class it{of(t){return new et(this,t)}}class nt{constructor(t){this.map=t}of(t){return new rt(this,t)}}class rt{constructor(t,e){this.type=t,this.value=e}map(t){t=this.type.map(this.value,t);return void 0===t?void 0:t==this.value?this:new rt(this.type,t)}is(t){return this.type==t}static define(t={}){return new nt(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(var n of t){n=n.map(e);n&&i.push(n)}return i}}rt.reconfigure=rt.define(),rt.appendConfig=rt.define();class st{constructor(t,e,i,n,r,s){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,i&&P(i,e.newLength),r.some(t=>t.type==st.time)||(this.annotations=r.concat(st.time.of(Date.now())))}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(var e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}}function ot(t,e,i){let n,r,s;return s=i?(n=e.changes,r=M.empty(e.changes.length),t.changes.compose(e.changes)):(n=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),t.changes.compose(n)),{changes:s,selection:e.selection?e.selection.map(r):null===(i=t.selection)||void 0===i?void 0:i.map(n),effects:rt.mapEffects(t.effects,n).concat(rt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function at(t,e,i){var n=e.selection;return{changes:e.changes instanceof M?e.changes:M.of(e.changes||[],i,t.facet(Y)),selection:n&&(n instanceof E?n:E.single(n.anchor,n.head)),effects:ct(e.effects),annotations:ct(e.annotations),scrollIntoView:!!e.scrollIntoView}}function ht(e,i,n){let r=at(e,i.length?i[0]:{},e.doc.length);i.length&&!1===i[0].filter&&(n=!1);for(let t=1;t=r[i]))t=r[i++],e=r[i++];else{if(!(n{if(!/\S/.test(e))return x.Space;if(function(i){if(dt)return dt.test(i);for(let e=0;enull),n)for(var r in t.address){var s=t.address[r],r=n.startState.config.address[r];null!=r&&0==(1&s)&&(this.values[s>>1]=G(n.startState,r))}(this.applying=n)&&(n._state=this);for(let t=0;tn.set(e,t)),e=null),n.set(r.value.compartment,r.value.extension)):r.is(rt.reconfigure)?(e=null,i=r.value):r.is(rt.appendConfig)&&(e=null,i=ct(i).concat(r.value));new pt(e||J.resolve(i,n,this),t.newDoc,t.newSelection,t)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:E.cursor(t.from+e.length)}))}changeByRange(r){var s=this.selection,t=r(s.ranges[0]);let o=this.changes(t.changes),a=[t.range],h=ct(t.effects);for(let n=1;ne.spec.fromJSON(i,t)))}return pt.create({doc:t.doc,selection:E.fromJSON(t.selection),extensions:e.extensions?r.concat([e.extensions]):r})}static create(t={}){let e=J.resolve(t.extensions||[],new Map);var i=t.doc instanceof d?t.doc:d.of((t.doc||"").split(e.staticFacet(pt.lineSeparator)||y));let n=t.selection?t.selection instanceof E?t.selection:E.single(t.selection.anchor,t.selection.head):E.single(0);return P(n,i.length),e.staticFacet(X)||(n=n.asSingle()),new pt(e,i,n)}get tabSize(){return this.facet(pt.tabSize)}get lineBreak(){return this.facet(pt.lineSeparator)||"\n"}phrase(t){for(var e of this.facet(pt.phrases))if(Object.prototype.hasOwnProperty.call(e,t))return e[t];return t}languageDataAt(t,e){let i=[];for(var n of this.facet(U))for(var r of n(this,e))Object.prototype.hasOwnProperty.call(r,t)&&i.push(r[t]);return i}charCategorizer(t){return ft(this.languageDataAt("wordChars",t).join(""))}}function gt(t,e,i={}){let n={};for(var r of t)for(var s of Object.keys(r)){var o=r[s],a=n[s];if(void 0===a)n[s]=o;else if(a!==o&&void 0!==o){if(!Object.hasOwnProperty.call(i,s))throw new Error("Config merge conflict for field "+s);n[s]=i[s](a,o)}}for(var h in e)void 0===n[h]&&(n[h]=e[h]);return n}pt.allowMultipleSelections=X,pt.tabSize=H.define({combine:t=>t.length?t[0]:4}),pt.lineSeparator=Y,pt.phrases=H.define(),pt.languageData=U,pt.changeFilter=Q,pt.transactionFilter=Z,pt.transactionExtender=tt,q.reconfigure=rt.define();const mt="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),vt="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),wt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class yt{constructor(t,e){this.rules=[];let{finish:c}=e||{};function u(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}for(var i in t)!function t(i,e,n,r){let s=[],o=/^@(\w+)\b/.exec(i[0]),a=o&&"keyframes"==o[1];if(o&&null==e)return n.push(i[0]+";");for(var h in e){var l=e[h];if(/&/.test(h))t(h.split(/,\s*/).map(e=>i.map(t=>e.replace(/&/,t))).reduce((t,e)=>t.concat(e)),l,n);else if(l&&"object"==typeof l){if(!o)throw new RangeError("The value of a property ("+h+") should be a primitive value.");t(u(h),l,s,a)}else null!=l&&s.push(h.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+l+";")}(s.length||a)&&n.push((!c||o||r?i:i.map(c)).join(", ")+" {"+s.join(" ")+"}")}(u(i),t[i],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=wt[mt]||1;return wt[mt]=t+1,"ͼ"+t.toString(36)}static mount(t,e){(t[vt]||new xt(t)).mount(Array.isArray(e)?e:[e])}}let bt=null;class xt{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(bt)return e.adoptedStyleSheets=[bt.sheet].concat(e.adoptedStyleSheets),e[vt]=bt;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),bt=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[vt]=this}mount(n){let r=this.sheet,s=0,o=0;for(let i=0;i>1,h=o[a]-i||(n<0?this.value[a].startSide:this.value[a].endSide)-r;if(a==t)return 0<=h?t:e;0<=h?e=a:t=1+a}}between(i,n,r,s){for(let t=this.findIndex(n,-1),e=this.findIndex(r,1,void 0,t);tr||n==r&&0this.chunkEnd(o.chunkIndex)||ro.to||r500<=t.maxPoint||t!=Ct.empty&&i.indexOf(t)<0&&t.maxPoint>=r),o=i.filter(t=>500<=t.maxPoint||t!=Ct.empty&&e.indexOf(t)<0&&t.maxPoint>=r),a=function(t,e){let i=new Map;for(var n of t)for(let t=0;tEt(h,t,l,e,i,n)),t.empty&&0==t.length&&Et(h,0,l,0,0,n)}static spans(t,e,i,n,r=-1){let s=new Bt(t,null,r).goto(e),o=e,a=s.openStart;for(;;){var h=Math.min(s.to,i);if(s.point?(n.point(o,h,s.point,s.activeForPoint(s.to),a),a=s.openEnd(h)+(s.to>h?1:0)):h>o&&(n.span(o,h,s.active,a),a=s.openEnd(h)),s.to>i)break;o=s.to,s.next()}return a}static of(t,e=!1){let i=new Tt;for(var n of t instanceof St?[t]:e?t.slice().sort(At):t)i.add(n.from,n.to,n.value);return i.finish()}}Ct.empty=new Ct([],[],null,-1),Ct.empty.nextLayer=Ct.empty;class Tt{constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}finishChunk(t){this.chunks.push(new Mt(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Tt)).add(t,e,i)}addInner(t,e,i){var n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);var i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Ct.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;t=new Ct(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,t}}class Dt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex=this.minPoint)break}}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.to-t.to||this.endSide-t.endSide}}class Ot{constructor(t){this.heap=t}static from(i,n=null,r=-1){let s=[];for(let e=0;e=r&&s.push(new Dt(t,n,r,e));return 1==s.length?s[0]:new Ot(s)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(var i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;0<=t;t--)Lt(this.heap,t);return this.next(),this}forward(t,e){for(var i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;0<=t;t--)Lt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Lt(this.heap,0)}}}function Lt(n,r){for(let i=n[r];;){let t=1+(r<<1);if(t>=n.length)break;let e=n[t];if(t+1e){this.to=this.activeTo[t],this.endSide=this.active[t].endSide;break}this.removeActive(t),i&&Pt(i,t)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}t=this.cursor.value;if(t.point){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.frome&&this.forward(this.to,this.endSide);break}this.addActive(i),this.cursor.next()}}if(i){let t=0;for(;tthis.pointRank);t++)(this.activeTo[t]>e||this.activeTo[t]==e&&this.active[t].endSide>this.point.endSide)&&i.push(this.active[t]);return i}openEnd(t){let e=0;for(;et;)e++;return e}}function Et(t,e,i,n,r,s){t.goto(e),i.goto(n);var o=n+r;let a=n,h=n-e;for(;;){var l=t.to+h-i.to||t.endSide-i.endSide,c=l<0?t.to+h:i.to,u=Math.min(c,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))||s.comparePoint(a,u,t.point,i.point):u>a&&!function(e,i){if(e.length!=i.length)return!1;for(let t=0;t=i;t--)e[t+1]=e[t];e[i]=t}function Ht(e,i){let n=-1,r=1e9;for(let t=0;t",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},Vt="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),zt="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),It="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),$t="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Wt="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ft=Vt&&($t||+Vt[1]<57)||It&&$t,qt=0;qt<10;qt++)Nt[48+qt]=Nt[96+qt]=String(qt);for(qt=1;qt<=24;qt++)Nt[qt+111]="F"+qt;for(var jt,qt=65;qt<=90;qt++)Nt[qt]=String.fromCharCode(qt+32),_t[qt]=String.fromCharCode(qt);for(jt in Nt)_t.hasOwnProperty(jt)||(_t[jt]=Nt[jt]);var Jt,Kt,Gt,[Ut,Xt]="undefined"!=typeof navigator?[navigator,document]:[{userAgent:"",vendor:"",platform:""},{documentElement:{style:{}}}],Yt=/Edge\/(\d+)/.exec(Ut.userAgent),Qt=/MSIE \d/.test(Ut.userAgent),Zt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ut.userAgent),te=!!(Qt||Zt||Yt),ee=!te&&/gecko\/(\d+)/i.test(Ut.userAgent),ie=!te&&/Chrome\/(\d+)/.exec(Ut.userAgent),ne="webkitFontSmoothing"in Xt.documentElement.style,re=!te&&/Apple Computer/.test(Ut.vendor),se={mac:/Mac/.test(Ut.platform),ie:te,ie_version:Qt?Xt.documentMode||6:Zt?+Zt[1]:Yt?+Yt[1]:0,gecko:ee,gecko_version:ee?+(/Firefox\/(\d+)/.exec(Ut.userAgent)||[0,0])[1]:0,chrome:!!ie,chrome_version:ie?+ie[1]:0,ios:re&&(/Mobile\/\w+/.test(Ut.userAgent)||2this.pos||t==this.pos&&(0t.width)||a),o?pe(a,o<0):a}class Le extends Ce{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i}static create(t,e,i){return new(t.customView||Le)(t,e,i)}slice(t){return Le.create(this.widget,this.length-t,this.side)}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,r){return!(i&&(!(i instanceof Le&&this.widget.compare(i.widget))||0i&&st?i[r]=Math.max(i[r],e):i.push(t,e)}We.prototype.point=!0;class je extends ke{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,r,s){if(i){if(!(i instanceof je))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Ee(this,t,e,i?i.children:Je,r,s),!0}split(t){let e=new je;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].slice(n),0),this.children[i].merge(n,this.children[i].length,null,0,0),i++);for(let t=i;t!t.length||t[0]});class si{constructor(t,e){this.field=t,this.get=e}}class oi{from(t){return new si(this,t)}static define(){return new oi}}oi.decorations=oi.define(),oi.scrollMargins=oi.define();let ai=0;const hi=H.define();class li{constructor(t,e,i){this.id=t,this.create=e,this.fields=i,this.extension=hi.of(this)}static define(t,e){let{eventHandlers:i,provide:n,decorations:r}=e||{},s=[];if(n)for(var o of Array.isArray(n)?n:[n])s.push(o);return i&&s.push(ci.from(t=>({plugin:t,handlers:i}))),r&&s.push(oi.decorations.from(r)),new li(ai++,t,s)}static fromClass(e,t){return li.define(t=>new e(t),t)}}const ci=oi.define();class ui{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}takeField(t,e){for(var{field:i,get:n}of this.spec.fields)i==t&&e.push(n(this.value))}update(e){if(this.value){if(this.mustUpdate){var i=this.mustUpdate;if(this.mustUpdate=null,!this.value.update)return this;try{this.value.update(i)}catch(t){if(ni(i.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}return ui.dummy}}}else try{this.value=this.spec.create(e)}catch(t){return ni(e.state,t,"CodeMirror plugin crashed"),ui.dummy}return this}destroy(e){var t;if(null!==(t=this.value)&&void 0!==t&&t.destroy)try{this.value.destroy()}catch(t){ni(e.state,t,"CodeMirror plugin crashed")}}}ui.dummy=new ui(li.define(()=>({})));const di=H.define({combine:t=>t.reduce((t,e)=>He(e,t),{})}),fi=H.define({combine:t=>t.reduce((t,e)=>He(e,t),{})}),pi=H.define(),gi=H.define();class mi{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new mi(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;0i.toA)){if(n.toAr.push(new mi(t,e,i,n))),this.changedRanges=r;i=t.hasFocus;i!=t.inputState.notifiedFocused&&(t.inputState.notifiedFocused=i,this.flags|=1),this.docChanged&&(this.flags|=2)}get viewportChanged(){return 0<(4&this.flags)}get heightChanged(){return 0<(2&this.flags)}get geometryChanged(){return this.docChanged||0<(18&this.flags)}get focusChanged(){return 0<(1&this.flags)}get docChanged(){return this.transactions.some(t=>t.docChanged)}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class wi extends ke{constructor(t){super(),this.view=t,this.compositionDeco=ze.none,this.decorations=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.setDOM(t.contentDOM),this.children=[new je],this.children[0].setParent(this),this.updateInner([new mi(0,0,0,t.state.doc.length)],this.updateDeco(),0)}get root(){return this.view.root}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(t){let e=t.changedRanges;0ethis.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=0),this.view.inputState.composing<0?this.compositionDeco=ze.none:t.transactions.length&&(this.compositionDeco=function(t,e){var i=oe(t.root),i=i.focusNode&&xi(i.focusNode,i.focusOffset,0);if(!i)return ze.none;let n=t.docView.nearest(i),r,s,o=i;if(n instanceof Ce){for(;n.parent instanceof Ce;)n=n.parent;r=n.posAtStart,s=r+n.length,o=n.dom}else{if(!(n instanceof je))return ze.none;{for(;o.parentNode!=n.dom;)o=o.parentNode;let t=o.previousSibling;for(;t&&!ke.get(t);)t=t.previousSibling;r=s=t?ke.get(t).posAtEnd:n.posAtStart}}let a=e.mapPos(r,1),h=Math.max(a,e.mapPos(s,-1)),l=i.nodeValue,{state:c}=t;if(h-a"pointerselection"==t.annotation(st.userEvent));return 0==this.dirty&&0==e.length&&!(12&t.flags)&&t.state.selection.main.from>=this.view.viewport.from&&t.state.selection.main.to<=this.view.viewport.to?(this.updateSelection(s,o),!1):(this.updateInner(e,a,t.startState.doc.length,s,o),!0)}updateInner(t,e,i,n=!1,r=!1){this.updateChildren(t,e,i),this.view.observer.ignore(()=>{this.dom.style.height=this.view.viewState.domHeight+"px",this.dom.style.minWidth=this.minWidth?this.minWidth+"px":"";var t=se.chrome?{node:oe(this.view.root).focusNode,written:!1}:void 0;this.sync(t),this.dirty=0,null!=t&&t.written&&(n=!0),this.updateSelection(n,r),this.dom.style.height=""})}updateChildren(e,i,t){let n=this.childCursor(t);for(let t=e.length-1;;t--){var r=0<=t?e[t]:null;if(!r)break;var{fromA:s,toA:o,fromB:a,toB:h}=r,{content:l,breakAtStart:c,openStart:u,openEnd:r}=Ge.build(this.view.state.doc,a,h,i),{i:a,off:h}=n.findPos(o,1),{i:o,off:s}=n.findPos(s,-1);this.replaceRange(o,s,a,h,l,c,u,r)}}replaceRange(e,i,n,r,s,o,a,h){let l=this.children[e],c=s.length?s[s.length-1]:null;var u=c?c.breakAfter:o;if(e!=n||o||u||!(s.length<2)||!l.merge(i,r,s.length?c:null,0==i,a,h)){let t=this.children[n];for(rn.node.insertBefore(t,n.node.childNodes[n.offset]||null)),n=r=new be(t,0),e=!0}let s=oe(this.root);!(e||!s.focusNode||se.gecko&&i.empty&&ki(s.focusNode,s.focusOffset))&&le(n.node,n.offset,s.anchorNode,s.anchorOffset)&&le(r.node,r.offset,s.focusNode,s.focusOffset)||this.view.observer.ignore(()=>{var t,e;if(i.empty)se.gecko&&(!(t=ki(n.node,n.offset))||3==t||(e=xi(n.node,n.offset,1==t?1:-1))&&(n=new be(e,1==t?0:e.nodeValue.length))),s.collapse(n.node,n.offset),null!=i.bidiLevel&&null!=s.cursorBidiLevel&&(s.cursorBidiLevel=i.bidiLevel);else if(s.extend)s.collapse(n.node,n.offset),s.extend(r.node,r.offset);else{let t=document.createRange();i.anchor>i.head&&([n,r]=[r,n]),t.setEnd(r.node,r.offset),t.setStart(n.node,n.offset),s.removeAllRanges(),s.addRange(t)}}),this.impreciseAnchor=n.precise?null:new be(s.anchorNode,s.anchorOffset),this.impreciseHead=r.precise?null:new be(s.focusNode,s.focusOffset)}}enforceCursorAssoc(){var t,e,i=this.view.state.selection.main;let n=oe(this.root);i.empty&&i.assoc&&n.modify&&((e=je.find(this,i.head))&&(t=e.posAtStart,i.head!=t&&i.head!=t+e.length&&(t=this.coordsAt(i.head,-1),e=this.coordsAt(i.head,1),!t||!e||t.bottom>e.top||(e=this.domAtPos(i.head+i.assoc),n.collapse(e.node,e.offset),n.modify("move",i.assoc<0?"forward":"backward","lineboundary")))))}mayControlSelection(){return this.view.state.facet(ri)?this.root.activeElement==this.dom:ae(this.dom,oe(this.root))}nearest(e){for(let t=e;t;){var i=ke.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e=s&&(r.push(t.dom.getBoundingClientRect().height),(h=t.dom.scrollWidth)>a&&(this.minWidth=a=h,this.minWidthFrom=i,this.minWidthTo=e)),i=e+t.breakAfter}return r}measureTextSize(){for(var t of this.children)if(t instanceof je){t=t.measureTextSize();if(t)return t}let e=document.createElement("div"),i,n;return e.className="cm-line",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);var t=he(e.firstChild)[0];i=e.getBoundingClientRect().height,n=t?t.width/27:7,e.remove()}),{lineHeight:i,charWidth:n}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new Ae(this.children,t,e)}computeBlockGapDeco(){let i=[],n=this.view.viewState;for(let t=0,e=0;;e++){var r,s=e==n.viewports.length?null:n.viewports[e],o=s?s.from-1:this.length;if(o>t&&(r=n.lineAt(o,0).bottom-n.lineAt(t,0).top,i.push(ze.replace({widget:new yi(r),block:!0,inclusive:!0}).range(t,o))),!s)break;t=s.to+1}return ze.set(i)}updateDeco(){return this.decorations=[this.computeBlockGapDeco(),this.view.viewState.lineGapDeco,this.compositionDeco,...this.view.state.facet(pi),...this.view.pluginField(oi.decorations)]}scrollPosIntoView(t,r){var s,o,a,r=this.coordsAt(t,r);if(r){let t=0,e=0,i=0,n=0;for(var h of this.view.pluginField(oi.scrollMargins))h&&({left:s,right:o,top:a,bottom:h}=h,null!=s&&(t=Math.max(t,s)),null!=o&&(e=Math.max(e,o)),null!=a&&(i=Math.max(i,a)),null!=h&&(n=Math.max(n,h)));!function(t,s){let e=t.ownerDocument,o=e.defaultView;for(let r=t.parentNode;r;)if(1==r.nodeType){let t,e=r==document.body;if(e)t={left:0,right:(h=o).innerWidth,top:0,bottom:h.innerHeight};else{if(r.scrollHeight<=r.clientHeight&&r.scrollWidth<=r.clientWidth){r=r.parentNode;continue}h=r.getBoundingClientRect();t={left:h.left,right:h.left+r.clientWidth,top:h.top,bottom:h.top+r.clientHeight}}let i=0,n=0;var a;if(s.topt.bottom&&(n=s.bottom-t.bottom+5),s.leftt.right&&(i=s.right-t.right+5),(i||n)&&(e?o.scrollBy(i,n):(n&&(a=r.scrollTop,r.scrollTop+=n,n=r.scrollTop-a),i&&(a=r.scrollLeft,r.scrollLeft+=i,i=r.scrollLeft-a),s={left:s.left-i,top:s.top-n,right:s.right-i,bottom:s.bottom-n})),e)break;r=r.parentNode}else{if(11!=r.nodeType)break;r=r.host}var h}(this.dom,{left:r.left-t,top:r.top-i,right:r.right+e,bottom:r.bottom+n})}}}class yi extends Ve{constructor(t){super(),this.height=t}toDOM(){var t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}class bi extends Ve{constructor(t,e){super(),this.top=t,this.text=e}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return Be}}function xi(t,e,i){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&0=i){if(o.level==n)return t;(s<0||(0!=r?r<0?o.fromi:e[s].level>o.level))&&(s=t)}}if(s<0)throw new RangeError("Index out of range");return s}}const Bi=[];function Ei(r,t){var s,o=r.length,a=t==Ai?1:2;if(!r||1==a&&!Oi.test(r))return Pi(o);for(let e=0,i=a,n=a;ec;){for(var d=t,f=2!=Bi[--t];t>c&&f==(2!=Bi[t-1]);)t--;i.push(new Li(t,d,f?2:1))}else i.push(new Li(c,e,0))}else for(let t=0;te.top+1}function Ni(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Vi(t,n,r){let s,o,a,h,l,c,u,d;for(let i=t.firstChild;i;i=i.nextSibling){var f=he(i);for(let e=0;em?g.left-m:Math.max(0,m-g.right)),g=(m=r,(g=t).top>m?g.top-m:Math.max(0,m-g.bottom));if(0==p&&0==g)return(3==i.nodeType?zi:Vi)(i,n,r);(!s||h>g||h==g&&a>p)&&(s=i,o=t,a=p,h=g),0==p?r>t.bottom&&(!u||u.bottomt.top)&&(c=i,d=t):u&&Hi(u,t)?u=_i(u,t.bottom):d&&Hi(d,t)&&(d=Ni(d,t.top))}}var m,g;if(u&&u.bottom>=r?(s=l,o=u):d&&d.top<=r&&(s=c,o=d),!s)return{node:t,offset:0};var e=Math.max(o.left,Math.min(o.right,n));return 3==s.nodeType?zi(s,e,r):a||"true"!=s.contentEditable?{node:t,offset:Array.prototype.indexOf.call(t.childNodes,s)+(n>=(o.left+o.right)/2?1:0)}:Vi(s,e,r)}function zi(n,r,e){var t=n.nodeValue.length;let s=-1,o=1e9,a=0;for(let i=0;ie?l.top-e:e-l.bottom)-1;if(l.left-1<=r&&l.right+1>=r&&c=(l.left+l.right)/2,e=t;if((se.chrome||se.gecko)&&ye(n,i).getBoundingClientRect().left==l.right&&(e=!t),c<=0)return{node:n,offset:i+(e?1:0)};s=i+(e?1:0),o=c}}}}return{node:n,offset:-1i||s.bottomi?-1:1,i=Math.min(s.bottom-o,Math.max(s.top+o,i)),t)return-1;t=!0}if(s.type==Jt.Text)break;i=0e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:null;t=Math.max(r.left+1,Math.min(r.right-1,t));let l=e.root,c=l.elementFromPoint(t,i),u,d=-1;return!c||!e.contentDOM.contains(c)||e.docView.nearest(c)instanceof Le||(l.caretPositionFromPoint?(a=l.caretPositionFromPoint(t,i))&&({offsetNode:u,offset:d}=a):!l.caretRangeFromPoint||(a=l.caretRangeFromPoint(t,i))&&({startContainer:u,startOffset:d}=a,se.safari&&function(e,t,i){let n;if(3!=e.nodeType||t!=(n=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=e.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return ye(e,n-1,n).getBoundingClientRect().left>i}(u,d,t)&&(u=void 0))),u&&e.docView.dom.contains(u)||(h=je.find(e.docView,h),{node:u,offset:d}=Vi(h.dom,t,i)),e.docView.posFromDOM(u,d)}function $i(r,t,s,o){let a=r.state.doc.lineAt(t.head),h=r.bidiSpans(a);for(let i=t,n=null;;){let t=function(t,e,i,n,r){let s=n.head-t.from,o=-1;if(0==s){if(!r||!t.length)return null;e[0].level!=i&&(s=e[0].side(!1,i),o=0)}else if(s==t.length){if(r)return null;let t=e[e.length-1];t.level!=i&&(s=t.side(!0,i),o=e.length-1)}o<0&&(o=Li.find(e,s,null!==(h=n.bidiLevel)&&void 0!==h?h:-1,n.assoc));let a=e[o];s==a.side(r,i)&&(a=e[o+=r?1:-1],s=a.side(!r,i));var h=r==(a.dir==i),n=S(t.text,s,h);if(Ri=t.text.slice(Math.min(s,n),Math.max(s,n)),n!=a.side(r,i))return E.cursor(n+t.from,h?-1:1,a.level);let l=o==(r?e.length-1:0)?null:e[o+(r?1:-1)];return l||a.level==i?l&&l.level>1;for(let t=s<0?o.top:o.bottom,e=0;e<50;e+=10){var u=Ii(i,{x:l,y:t+(c+e)*s},s);if(null==u)break;if(u!=r)return E.cursor(u,void 0,void 0,h)}}let{doc:d}=i.state,f=d.lineAt(r),p=i.state.tabSize,g=t.goalColumn,m=0;if(null==g){for(const x=d.iterRange(f.from,r);!x.next().done;)m=A(x.value,m,p);g=m*i.defaultCharacterWidth}else m=Math.round(g/i.defaultCharacterWidth);if(s<0&&0==f.from)return E.cursor(0);if(0=m&&!k.next().done;){var{offset:y,leftOver:b}=function(e,i,n,r){for(let t=0;t{!Ji(n,t)||this.ignoreDuringComposition(t)||"keydown"==i&&this.screenKeyEvent(n,t)||(this.mustFlushObserver(t)&&n.observer.forceFlush(),this.runCustomHandlers(i,n,t)?t.preventDefault():e(n,t))}),this.registeredEvents.push(i)}n.contentDOM.addEventListener("keydown",t=>{n.inputState.lastKeyCode=t.keyCode,n.inputState.lastKeyTime=Date.now()}),this.notifiedFocused=n.hasFocus,this.ensureHandlers(n)}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(i){var t;for(t of this.customHandlers=i.pluginField(ci))for(let e in t.handlers)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),i.contentDOM.addEventListener(e,t=>{Ji(i,t)&&this.runCustomHandlers(e,i,t)&&t.preventDefault()}))}runCustomHandlers(i,n,r){for(var s of this.customHandlers){let t=s.handlers[i],e=!1;if(t){try{e=t.call(s.plugin,r,n)}catch(t){ni(n.state,t)}if(e||r.defaultPrevented)return se.android&&"keydown"==i&&13==r.keyCode&&n.observer.flushSoon(),!0}}return!1}runScrollHandlers(e,i){for(var n of this.customHandlers){let t=n.handlers.scroll;if(t)try{t.call(n.plugin,i,e)}catch(t){ni(e.state,t)}}}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(0=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}(e,i)&&null,!1===this.dragging&&(i.preventDefault(),this.select(i))}move(t){if(0==t.buttons)return this.destroy();!1===this.dragging&&this.select(t)}up(t){null==this.dragging&&this.select(this.startEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.inputState.mouseSelection=null}select(t){let e=this.style.get(t,this.extend,this.multiple);e.eq(this.view.state.selection)&&e.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:e,annotations:st.userEvent.of("pointerselection"),scrollIntoView:!0})}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)}}function Ji(i,n){if(!n.bubbles)return 1;if(!n.defaultPrevented){for(let t=n.target,e;t!=i.contentDOM;t=t.parentNode)if(!t||11==t.nodeType||(e=ke.get(t))&&e.ignoreEvent(n))return;return 1}}const Ki=Object.create(null),Gi=se.ie&&se.ie_version<15||se.ios&&se.webkit_version<604;function Ui(t,r){let{state:s}=t,e,o=1,a=s.toText(r),h=a.lines==s.selection.ranges.length;if(sn&&s.selection.ranges.every(t=>t.empty)&&sn==a.toString()){let n=-1;e=s.changeByRange(t=>{var e=s.doc.lineAt(t.from);if(e.from==n)return{range:t};n=e.from;var i=s.toText((h?a.line(o++).text:r)+s.lineBreak);return{changes:{from:e.from,insert:i},range:E.cursor(t.from+i.length)}})}else e=h?s.changeByRange(t=>{var e=a.line(o++);return{changes:{from:t.from,to:t.to,insert:e.text},range:E.cursor(t.from+e.length)}}):s.replaceSelection(a);t.dispatch(e,{annotations:st.userEvent.of("paste"),scrollIntoView:!0})}Ki.keydown=(t,e)=>{var i,n,r;n=((i=e).ctrlKey?1:0)|(i.metaKey?8:0)|(i.altKey?2:0)|(i.shiftKey?4:0),r=i.keyCode,i=se.mac&&1==n,(8==r||i&&72==r||46==r||i&&68==r||27==r||n==(se.mac?8:1)&&(66==r||73==r||89==r||90==r))&&e.preventDefault(),t.inputState.setSelectionOrigin("keyboardselection")};let Xi=0;function Yi(i,n,r,t){if(1==t)return E.cursor(n,r);if(2==t)return function(t,e,i=1){let n=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(0==r.length)return E.cursor(e);0==s?i=1:s==r.length&&(i=-1);let o=s,a=s;i<0?o=S(r.text,s,!1):a=S(r.text,s);for(var h=n(r.text.slice(o,a));0{1==(e=e).touches.length&&e.touches[0].radiusX<=1&&e.touches[0].radiusY<=1||(Xi=Date.now()),t.inputState.setSelectionOrigin("pointerselection")},Ki.touchmove=t=>{t.inputState.setSelectionOrigin("pointerselection")},Ki.mousedown=(e,i)=>{if(e.observer.flush(),!(Xi>Date.now()-2e3)){let t=null;for(var n of e.state.facet(Ze))if(t=n(e,i),t)break;t||0!=i.button||(t=function(o,t){let a=tn(o,t),h=function(t){if(!en)return t.detail;var e=nn;return nn=t,rn=!e||e.timeStamp>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(rn+1)%3:1}(t),l=o.state.selection,c=a,u=t;return{update(t){t.changes&&(a&&(a.pos=t.changes.mapPos(a.pos)),l=l.map(t.changes))},get(t,e,i){let n;if(t.clientX==u.clientX&&t.clientY==u.clientY?n=c:(n=c=tn(o,t),u=t),!n||!a)return l;let r=Yi(o,n.pos,n.bias,h);var s;return a.pos==n.pos||e||(s=Yi(o,a.pos,a.bias,h),t=Math.min(s.from,r.from),s=Math.max(s.to,r.to),r=tve(e.contentDOM)),e.inputState.startMouseSelection(e,i,t))}};let Qi=(t,e)=>t>=e.top&&t<=e.bottom,Zi=(t,e,i)=>Qi(e,i)&&t>=i.left&&t<=i.right;function tn(t,e){var i=t.posAtCoords({x:e.clientX,y:e.clientY});return null==i?null:{pos:i,bias:function(t,e,i,n){let r=je.find(t.docView,e);return r&&0!=(t=e-r.posAtStart)&&(t==r.length||(e=r.coordsAt(t,-1))&&Zi(i,n,e)||(!(t=r.coordsAt(t,1))||!Zi(i,n,t))&&e&&Qi(n,e))?-1:1}(t,i,e.clientX,e.clientY)}}const en=se.ie&&se.ie_version<=11;let nn=null,rn=0;Ki.dragstart=(t,e)=>{var{selection:{main:i}}=t.state;let{mouseSelection:n}=t.inputState;n&&(n.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},Ki.drop=(e,i)=>{if(i.dataTransfer){var n=e.posAtCoords({x:i.clientX,y:i.clientY}),r=i.dataTransfer.getData("Text");if(null!=n&&r){i.preventDefault();var{mouseSelection:i}=e.inputState,i=i&&i.dragging&&i.dragMove?{from:i.dragging.from,to:i.dragging.to}:null,r={from:n,insert:r};let t=e.state.changes(i?[i,r]:r);e.focus(),e.dispatch({changes:t,selection:{anchor:t.mapPos(n,-1),head:t.mapPos(n,1)},annotations:st.userEvent.of("drop")})}}},Ki.paste=(t,e)=>{t.observer.flush();let i=Gi?null:e.clipboardData;var n=i&&i.getData("text/plain");n?(Ui(t,n),e.preventDefault()):function(e){let i=e.dom.parentNode;if(i){let t=i.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{e.focus(),t.remove(),Ui(e,t.value)},50)}}(t)};let sn=null;function on(t){t.docView.compositionDeco.size&&t.update([])}Ki.copy=Ki.cut=(e,i)=>{var{text:n,ranges:r,linewise:s}=function(e){let i=[],n=[],r=!1;for(var t of e.selection.ranges)t.empty||(i.push(e.sliceDoc(t.from,t.to)),n.push(t));if(!i.length){let t=-1;for(var{from:s}of e.selection.ranges){s=e.doc.lineAt(s);s.number>t&&(i.push(s.text),n.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),t=s.number}r=!0}return{text:i.join(e.lineBreak),ranges:n,linewise:r}}(e.state);if(n){sn=s?n:null;let t=Gi?null:i.clipboardData;t?(i.preventDefault(),t.clearData(),t.setData("text/plain",n)):function(e,i){let n=e.dom.parentNode;if(n){let t=n.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.value=i,t.focus(),t.selectionEnd=i.length,t.selectionStart=0,setTimeout(()=>{t.remove(),e.focus()},50)}}(e,n),"cut"==i.type&&e.dispatch({changes:r,scrollIntoView:!0,annotations:st.userEvent.of("cut")})}},Ki.focus=Ki.blur=t=>{setTimeout(()=>{t.hasFocus!=t.inputState.notifiedFocused&&t.update([])},10)},Ki.beforeprint=t=>{t.viewState.printing=!0,t.requestMeasure(),setTimeout(()=>{t.viewState.printing=!1,t.requestMeasure()},2e3)},Ki.compositionstart=Ki.compositionupdate=t=>{t.inputState.composing<0&&(t.docView.compositionDeco.size&&(t.observer.flush(),on(t)),t.inputState.composing=0)},Ki.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),setTimeout(()=>{t.inputState.composing<0&&on(t)},50)};const an=["pre-wrap","normal","pre-line"];class hn{constructor(){this.doc=d.empty,this.lineWrapping=!1,this.direction=Kt.LTR,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength)),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefresh(e,t,i){let n=!1;for(let t=0;t=e?r:c.lineAt(e,Gt.ByPosNoHeight,a,0,0);for(n+=u.to-e,e=u.to;02*r){var o=t[e-1];o.break?t.splice(--e,1,o.left,null,o.right):t.splice(--e,1,o.left,o.right),i+=1+o.break,n-=o.size}else{if(!(r>2*n))break;o=t[i];o.break?t.splice(i,1,o.left,null,o.right):t.splice(i,1,o.left,o.right),i+=2+o.break,r-=o.size}else nt&&e.push(new pn(r.from-t-1).updateHeight(n,t));i<=s&&r.more;){var o=n.doc.lineAt(i).length;e.length&&e.push(null);let t=new fn(o,r.heights[r.index++]);t.outdated=!1,e.push(t),i+=o+1}return i<=s&&e.push(null,new pn(s-i).updateHeight(n,i)),n.heightChanged=!0,un.of(e)}return(e||this.outdated)&&(this.setHeight(n,n.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class gn extends un{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){var r=i+this.left.height;return to))return h;e=e==Gt.ByPosNoHeight?Gt.ByPosNoHeight:Gt.ByPos;return a?h.join(this.right.lineAt(o,e,i,s,o)):this.left.lineAt(o,e,i,n,r).join(h)}forEachLine(t,e,i,n,r,s){var o,a=n+this.left.height,h=r+this.left.length+this.break;this.break?(t=t&&o.from<=e&&s(o),e>o.to&&this.right.forEachLine(o.to+1,e,i,a,h,s))}replace(t,e,i){var n=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let r=[];0=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){var i=this.left.length,n=i+this.break;if(n<=t)return this.right.decomposeRight(t-n,e);t2*e.size||e.size>2*t.size?un.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:r,right:s}=this,o=e+r.length+this.break,a=null;return n&&n.from<=e+r.length&&n.more?a=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=o+s.length&&n.more?a=s=s.updateHeight(t,o,i,n):s.updateHeight(t,o,i),a?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function mn(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof pn&&(n=t[e+1])instanceof pn&&t.splice(e-1,3,new pn(i.length+1+n.length))}class vn{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,i){if(-1this.pos||!this.isCovered)&&this.nodes.push(new fn(t-this.pos,-1)),(this.writtenTo=t)t&&this.nodes.push(new fn(this.pos-t,-1)),this.writtenTo=this.pos)}blankContent(t,e){let i=new pn(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();var t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof fn)return t;t=new fn(0,-1);return this.nodes.push(t),t}addBlock(t){this.enterLine(),t.type!=Jt.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=Jt.WidgetBefore&&(this.covering=t)}addLineDeco(t,e){let i=this.ensureLine();i.length+=e,i.collapsed+=e,i.widgetHeight=Math.max(i.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}finish(t){var e,i=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(-1t.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let t=0;t<=1;t++){let i=t?n.head:n.anchor;var r,s;e.some(({from:t,to:e})=>i>=t&&i<=e)||({from:r,to:s}=this.lineAt(i,0),e.push(new kn(r,s)))}this.viewports=e.sort((t,e)=>t.from-e.from),this.scaler=this.heightMap.height<=7e6?Cn:new Tn(this.heightOracle.doc,this.heightMap,this.viewports)}update(t,e=null){var i=this.state;this.state=t.state;var n,r,s,o=this.state.facet(pi),a=t.changedRanges,s=mi.extendWithRanges(a,(n=t.startState.facet(pi),r=o,s=t?t.changes:M.empty(this.state.doc.length),a=new wn,Ct.compare(n,r,s,a,0),a.changes)),a=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(o,i.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=a&&(t.flags|=2);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.headh.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e)),h.eq(this.viewport)||(this.viewport=h,t.flags|=4),this.updateForViewport(),(this.lineGaps.length||15e3t.clientHeight||t.scrollWidth>t.clientWidth)&&"visible"!=window.getComputedStyle(t).overflow&&(i=t.getBoundingClientRect(),r=Math.max(r,i.left),s=Math.min(s,i.right),o=Math.max(o,i.top),a=Math.min(a,i.bottom)),t=t.parentNode;else{if(11!=t.nodeType)break;t=t.host}return{left:r-n.left,right:s-n.left,top:o-(n.top+t),bottom:a-(n.top+t)}}(i,this.paddingTop),o=s.top-this.pixelViewport.top,a=s.bottom-this.pixelViewport.bottom;if(this.pixelViewport=s,this.inView=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left,!this.inView)return 0;var h,l=t.measureVisibleLineHeights();let c=!1,u=0,d=0,f=this.heightOracle;return e||(h=t.dom.clientWidth,(f.mustRefresh(l,n,r)||f.lineWrapping&&Math.abs(h-this.contentWidth)>f.charWidth)&&({lineHeight:s,charWidth:e}=t.measureTextSize(),c=f.refresh(n,r,s,e,h/e,l),c&&(t.minWidth=0,d|=16)),this.contentWidth!=h&&(this.contentWidth=h,d|=16),0this.viewport.to))&&((l=this.getViewport(u,this.scrollTo)).from==this.viewport.from&&l.to==this.viewport.to||(this.viewport=l,d|=4)),this.updateForViewport(),(this.lineGaps.length||15e3o.to&&({bottom:e}=i.lineAt(e.head,Gt.ByPos,n,0,0),o=new kn(i.lineAt(e-(s-r)-500,Gt.ByHeight,n,0,0).from,i.lineAt(e+500,Gt.ByHeight,n,0,0).to))),o}mapViewport(t,e){var i=e.mapPos(t.from,-1),t=e.mapPos(t.to,1);return new kn(this.heightMap.lineAt(i,Gt.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(t,Gt.ByPos,this.state.doc,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){var{top:n}=this.heightMap.lineAt(t,Gt.ByPos,this.state.doc,0,0),{bottom:r}=this.heightMap.lineAt(e,Gt.ByPos,this.state.doc,0,0),{visibleTop:s,visibleBottom:o}=this;return(0==t||n<=s-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&s-2e3{if(!(r.length<1e4)){var s=function(t,e,i){let n=[],r=t,s=0;Ct.spans(i.facet(pi),t,e,{span(){},point(t,e){t>r&&(n.push({from:r,to:t}),s+=t-r),r=e}},20),r=r.from&&(t=o.from),o.from<=r.to&&o.to>=e&&(e=o.to);let i=t-1e4,n=e+1e4;i>r.from+5e3&&h.push(Mn(a,t=>t.from==r.from&&t.to>i-5e3&&t.to<5e3+i)||new yn(r.from,i,this.gapSize(r,i,!0,s))),nt.to==r.to&&t.from>n-5e3&&t.fromt.draw(this.heightOracle.lineWrapping))),8)}computeVisibleRanges(){let t=this.state.facet(pi);this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];Ct.spans(t,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20),this.visibleRanges=i}lineAt(t,e){return e+=this.paddingTop,Dn(this.heightMap.lineAt(t,Gt.ByPos,this.state.doc,e,0),this.scaler,e)}lineAtHeight(t,e){return e+=this.paddingTop,Dn(this.heightMap.lineAt(this.scaler.fromDOM(t,e),Gt.ByHeight,this.state.doc,e,0),this.scaler,e)}blockAtHeight(t,e){return e+=this.paddingTop,Dn(this.heightMap.blockAt(this.scaler.fromDOM(t,e),this.state.doc,e,0),this.scaler,e)}forEachLine(t,e,i,n){return n+=this.paddingTop,this.heightMap.forEachLine(t,e,this.state.doc,n,0,1==this.scaler.scale?i:t=>i(Dn(t,this.scaler,n)))}get contentHeight(){return this.domHeight+this.paddingTop+this.paddingBottom}get domHeight(){return this.scaler.toDOM(this.heightMap.height,this.paddingTop)}}class kn{constructor(t,e){this.from=t,this.to=e}eq(t){return this.from==t.from&&this.to==t.to}}function Sn({total:t,ranges:e},i){if(i<=0)return e[0].from;if(1<=i)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){var{from:r,to:s}=e[t],s=s-r;if(n<=s)return r+n;n-=s}}function An(t,e){let i=0;for(var{from:n,to:r}of t.ranges){if(e<=r){i+=e-n;break}i+=r-n}return i/t.total}function Mn(t,e){for(var i of t)if(e(i))return i}const Cn={toDOM(t){return t},fromDOM(t){return t},scale:1};class Tn{constructor(r,s,t){let o=0,e=0,i=0;this.viewports=t.map(({from:t,to:e})=>{var i=s.lineAt(t,Gt.ByPos,r,0,0).top,n=s.lineAt(e,Gt.ByPos,r,0,0).bottom;return o+=n-i,{from:t,to:e,top:i,bottom:n,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(s.height-o);for(var n of this.viewports)n.domTop=i+(n.top-e)*this.scale,i=n.domBottom=n.domTop+(n.bottom-n.top),e=n.bottom}toDOM(n,r){n-=r;for(let t=0,e=0,i=0;;t++){var s=tDn(t,e,i)):t.type)}const On=H.define({combine:t=>t.join(" ")}),Ln=H.define({combine:t=>-1{if("&"==t)return e;if(!i||!i[t])throw new RangeError(`Unsupported selector: ${t}`);return i[t]}):e+" "+t}})}const Nn=Hn("."+Bn,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline_fallback:"1px dotted #212121",outline:"5px auto -webkit-focus-ring-color"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,minHeight:"100%",display:"block",whiteSpace:"pre",boxSizing:"border-box",padding:"4px 0",outline:"none"},".cm-lineWrapping":{whiteSpace:"pre-wrap",overflowWrap:"anywhere"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none",display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-placeholder":{color:"#888",display:"inline-block"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"3px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Rn),_n={childList:!0,characterData:!0,subtree:!0,characterDataOldValue:!0},Vn=se.ie&&se.ie_version<=11;class zn{constructor(i,t,e){this.view=i,this.onChange=t,this.onScrollChanged=e,this.active=!1,this.ignoreSelection=new ge,this.delayedFlush=-1,this.queue=[],this.scrollTargets=[],this.intersection=null,this.intersecting=!1,this.parentCheck=-1,this.dom=i.contentDOM,this.observer=new MutationObserver(t=>{for(var e of t)this.queue.push(e);(se.ie&&se.ie_version<=11||se.ios&&i.composing)&&t.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),Vn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.start(),this.onScroll=this.onScroll.bind(this),window.addEventListener("scroll",this.onScroll),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),0{this.delayedFlush=-1,this.flush()},20))}forceFlush(){0<=this.delayedFlush&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}flush(){if(!(0<=this.delayedFlush)){let n=this.queue;for(var t of this.observer.takeRecords())n.push(t);n.length&&(this.queue=[]);var r=oe(this.view.root),s=!this.ignoreSelection.eq(r)&&ae(this.dom,r);if(0!=n.length||s){let t=-1,e=-1,i=!1;for(var o of n){o=this.readMutation(o);o&&(o.typeOver&&(i=!0),-1==t?{from:t,to:e}=o:(t=Math.min(o.from,t),e=Math.max(o.to,e)))}r=this.view.state;(-1this.view.docView.sync()),this.view.docView.dirty=0),this.view.docView.updateSelection()),this.clearSelection()}}}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty(),"childList"!=t.type)return{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue};var i=In(e,t.previousSibling||t.target.previousSibling,-1),t=In(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:t?e.posBefore(t):e.posAtEnd,typeOver:!1}}destroy(){this.stop(),this.intersection&&this.intersection.disconnect();for(var t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),clearTimeout(this.parentCheck)}}function In(t,e,i){for(;e;){var n=ke.get(e);if(n&&n.parent==t)return n;n=e.parentNode;e=n!=t.dom?n:0Date.now()-100||se.android&&t.text.length=o?s-i:0,s-=h,a=s+(a-o),o=s):a=a?s-i:0,s-=i,o=s+(o-a),a=s)}return{from:s,toA:o,toB:a}}(n.state.sliceDoc(l,c),t.text,e-l,i);u&&(s={from:l+u.from,to:l+u.toA,insert:n.state.toText(t.text.slice(u.from,u.toB))})}else!n.hasFocus&&n.state.facet(ri)||(c=oe(n.root),{impreciseHead:l,impreciseAnchor:u}=n.docView,l=l&&l.node==c.focusNode&&l.offset==c.focusOffset?n.state.selection.main.head:n.docView.posFromDOM(c.focusNode,c.focusOffset),c=u&&u.node==c.anchorNode&&u.offset==c.anchorOffset?n.state.selection.main.anchor:function(t){let e=t.isCollapsed;return e&&se.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e}(c)?l:n.docView.posFromDOM(c.anchorNode,c.anchorOffset),l==a.head&&c==a.anchor||(o=E.single(c,l)));if(s||o)if(!s&&r&&!a.empty&&o&&o.main.empty&&(s={from:a.from,to:a.to,insert:n.state.doc.slice(a.from,a.to)}),s){let i=n.state;if(!se.android||!(s.from==a.from&&s.to==a.to&&1==s.insert.length&&2==s.insert.lines&&jn(n,"Enter",10)||s.from==a.from-1&&s.to==a.to&&0==s.insert.length&&jn(n,"Backspace",8)||s.from==a.from&&s.to==a.to+1&&0==s.insert.length&&jn(n,"Delete",46))){let e=s.insert.toString();if(!n.state.facet(ii).some(t=>t(n,s.from,s.to,e))){0<=n.inputState.composing&&n.inputState.composing++;let t;var d;t=s.from>=a.from&&s.to<=a.to&&s.to-s.from>=(a.to-a.from)/3&&(!o||o.main.empty&&o.main.from==s.from+s.insert.length)?(r=a.froms.to?i.sliceDoc(s.to,a.to):"",i.replaceSelection(n.state.toText(r+s.insert.sliceString(0,void 0,n.state.lineBreak)+d))):{changes:d=i.changes(s),selection:o&&!i.selection.main.eq(o.main)&&o.main.to<=d.newLength?i.selection.replaceRange(o.main):void 0},n.dispatch(t,{scrollIntoView:!0,annotations:st.userEvent.of("input")})}}}else if(o&&!o.main.eq(a)){let t=!1,e;n.inputState.lastSelectionTime>Date.now()-50&&("keyboardselection"==n.inputState.lastSelectionOrigin?t=!0:e=st.userEvent.of(n.inputState.lastSelectionOrigin)),n.dispatch({selection:o,scrollIntoView:t,annotations:e})}}class Wn{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineBreak=e.state.lineBreak}readRange(e,i){if(e){var n=e.parentNode;for(let t=e;;){this.findPointBefore(n,t),this.readNode(t);var r=t.nextSibling;if(r==i)break;var s=ke.get(t),o=ke.get(r);((s?s.breakAfter:Fn(t))||(o?o.breakAfter:Fn(r))&&("BR"!=t.nodeName||t.cmIgnore))&&(this.text+=this.lineBreak),t=r}this.findPointBefore(n,i)}}readNode(i){if(!i.cmIgnore){var n=ke.get(i);let t=n&&n.overrideDOMText,e;null!=t?e=t.sliceString(0,void 0,this.lineBreak):3==i.nodeType?e=i.nodeValue:"BR"==i.nodeName?e=i.nextSibling?this.lineBreak:"":1==i.nodeType&&this.readRange(i.firstChild,null),null!=e&&(this.findPointIn(i,e.length),this.text+=e,se.chrome&&13==this.view.inputState.lastKeyCode&&!i.nextSibling&&/\n\n$/.test(this.text)&&(this.text=this.text.slice(0,-1)))}}findPointBefore(t,e){for(var i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointIn(t,e){for(var i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e))}}function Fn(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class qn{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}function jn(t,e,i){e={key:e,code:e,keyCode:i,which:i,cancelable:!0},i=new KeyboardEvent("keydown",e);t.contentDOM.dispatchEvent(i);e=new KeyboardEvent("keyup",e);return t.contentDOM.dispatchEvent(e),i.defaultPrevented||e.defaultPrevented}class Jn{constructor(t={}){this.plugins=[],this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this.root=t.root||document,this.viewState=new xn(t.state||pt.create()),this.plugins=this.state.facet(hi).map(t=>new ui(t).update(this)),this.observer=new zn(this,(t,e,i)=>{$n(this,t,e,i)},t=>{this.inputState.runScrollHandlers(this,t),this.measure()}),this.inputState=new Fi(this),this.docView=new wi(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,window.addEventListener("resize",()=>{-1==Un&&(Un=setTimeout(Xn,50))}),this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return 0t.scrollIntoView)?n.selection.main:null;this.viewState.update(i,s),this.bidiCache=Qn.update(this.bidiCache,i.changes),i.empty||this.updatePlugins(i),e=this.docView.update(i),this.state.facet(gi)!=this.styleModules&&this.mountStyles(),this.updateAttrs(),this.showAnnouncements(t)}finally{this.updateState=0}if((e||scrollTo||this.viewState.mustEnforceCursorAssoc)&&this.requestMeasure(),!i.empty)for(var o of this.state.facet(ei))o(i)}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");this.updateState=2;try{for(var e of this.plugins)e.destroy(this);this.viewState=new xn(t),this.plugins=t.facet(hi).map(t=>new ui(t).update(this)),this.docView=new wi(this),this.inputState.ensureHandlers(this),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}this.requestMeasure()}updatePlugins(i){let t=i.startState.facet(hi),n=i.state.facet(hi);if(t!=n){let e=[];for(var r of n){var s=t.indexOf(r);if(s<0)e.push(new ui(r));else{let t=this.plugins[s];t.mustUpdate=i,e.push(t)}}for(var o of this.plugins)o.mustUpdate!=i&&o.destroy(this);this.plugins=e,this.inputState.ensureHandlers(this)}else for(var e of this.plugins)e.mustUpdate=i;for(let t=0;t{try{return t.read(this)}catch(t){return ni(this.state,t),Yn}});let t=new vi(this,this.state);t.flags|=r,n?n.flags|=r:n=t,this.updateState=2,t.empty||this.updatePlugins(t),this.updateAttrs(),r&&this.docView.update(t);for(let t=0;tthis.measure())),e){if(null!=e.key)for(let t=0;tfunction(t,e,i){let n=t.state.charCategorizer(e),r=n(i);return t=>{t=n(t);return r==x.Space&&(r=t),r==t}}(this,e.head,t))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){var r=t.state.doc.lineAt(e.head),s=n&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(s){n=t.dom.getBoundingClientRect(),s=t.posAtCoords({x:i==(t.textDirection==Kt.LTR)?n.right-1:n.left+1,y:(s.top+s.bottom)/2});if(null!=s)return E.cursor(s,i?-1:1)}return e=je.find(t.docView,e.head),r=e?i?e.posAtEnd:e.posAtStart:i?r.to:r.from,E.cursor(r,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Wi(this,t,e,i)}scrollPosIntoView(t){this.viewState.scrollTo=E.cursor(t),this.requestMeasure()}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t){return this.readMeasured(),Ii(this,t)}coordsAtPos(t,e=1){this.readMeasured();var i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;var n=this.state.doc.lineAt(t),r=this.bidiSpans(n);return pe(i,r[Li.find(r,t-n.from,-1,e)].dir==Kt.LTR==0Kn)return Pi(t.length);var e,i=this.textDirection;for(e of this.bidiCache)if(e.from==t.from&&e.dir==i)return e.order;var n=Ei(t.text,this.textDirection);return this.bidiCache.push(new Qn(t.from,t.to,i,n)),n}get hasFocus(){return document.hasFocus()&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ve(this.contentDOM),this.docView.updateSelection()})}destroy(){for(var t of this.plugins)t.destroy(this);this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),-1({}),{eventHandlers:t})}static theme(t,e){var i=yt.newName();let n=[On.of(i),gi.of(Hn(`.${i}`,t))];return e&&e.dark&&n.push(Ln.of(!0)),n}static baseTheme(t){return W.fallback(gi.of(Hn("."+Bn,t,Rn)))}}Jn.styleModule=gi,Jn.inputHandler=ii,Jn.exceptionSink=ti,Jn.updateListener=ei,Jn.editable=ri,Jn.mouseSelectionStyle=Ze,Jn.dragMovesSelection=Qe,Jn.clickAddsSelectionRange=Ye,Jn.decorations=pi,Jn.contentAttributes=fi,Jn.editorAttributes=di,Jn.lineWrapping=Jn.contentAttributes.of({class:"cm-lineWrapping"}),Jn.announce=rt.define();const Kn=4096;function Gn(t,e){return null==t?e.getBoundingClientRect().top:t}let Un=-1;function Xn(){Un=-1;var i=document.querySelectorAll(".cm-content");for(let e=0;e{if(t){for(var e of t.commands)if(e(i))return!0;t.preventDefault&&(a=!0)}return!1},l=t[n],c;if(l){if(h(l[o+tr(r,e,!s)]))return!0;if(s&&(e.shiftKey||e.altKey||e.metaKey)&&(c=Nt[e.keyCode])&&c!=r){if(h(l[o+tr(c,e,!0)]))return!0}else if(s&&e.shiftKey&&h(l[o+tr(r,e,!0)]))return!0}return a}(function(t){let e=t.facet(er),i=ir.get(e);i||ir.set(e,i=function(t,a=Zn){let h=Object.create(null),n=Object.create(null),l=(t,e)=>{var i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},e=(n,t,e,i)=>{let r=h[n]||(h[n]=Object.create(null)),s=t.split(/ (?!$)/).map(t=>function(t,e){var i=t.split(/-(?!$)/);let n=i[i.length-1];"Space"==n&&(n=" ");let r,s,o,a;for(let t=0;t{let e=nr={view:t,prefix:i,scope:n};return setTimeout(()=>{nr==e&&(nr=null)},rr),!0}]})}t=s.join(" ");l(t,!1);let o=r[t]||(r[t]={preventDefault:!1,commands:[]});o.commands.push(e),i&&(o.preventDefault=!0)};for(var i of t){var r=i[a]||i.key;if(r)for(var s of i.scope?i.scope.split(" "):["editor"])e(s,r,i.run,i.preventDefault),i.shift&&e(s,"Shift-"+r,i.shift,i.preventDefault)}return h}(e.reduce((t,e)=>t.concat(e),[])));return i}(e.state),t,e,"editor")}});const er=H.define({enables:te}),ir=new WeakMap;let nr=null;const rr=4e3;const sr=!se.ios,or=H.define({combine(t){return gt(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});class ar{constructor(t,e,i,n,r){this.left=t,this.top=e,this.width=i,this.height=n,this.className=r}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",0<=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}}li.fromClass(class{constructor(t){this.view=t,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=t.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=t.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),t.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(or).cursorBlinkRate+"ms"}update(t){var e=t.startState.facet(or)!=t.state.facet(or);(e||t.selectionSet||t.geometryChanged||t.viewportChanged)&&this.view.requestMeasure(this.measureReq),t.transactions.some(t=>t.scrollIntoView)&&(this.cursorLayer.style.animationName="cm-blink"==this.cursorLayer.style.animationName?"cm-blink2":"cm-blink"),e&&this.setBlinkRate()}readPos(){let{state:t}=this.view,e=t.facet(or);var i,n=t.selection.ranges.map(t=>t.empty?[]:function(m,n){if(n.to<=m.viewport.from||n.from>=m.viewport.to)return[];let t=Math.max(n.from,m.viewport.from),e=Math.min(n.to,m.viewport.to),v=m.textDirection==Kt.LTR,i=m.contentDOM,r=i.getBoundingClientRect(),s=lr(m),o=window.getComputedStyle(i.firstChild),w=r.left+parseInt(o.paddingLeft),y=r.right-parseInt(o.paddingRight),a=m.visualLineAt(t),h=m.visualLineAt(e);m.lineWrapping&&(a=cr(m,t,a),h=cr(m,e,h));{if(a.from==h.from)return c(u(n.from,n.to,a));{let t=u(n.from,null,a),e=u(null,n.to,h),i=[];return a.toc&&l.fromt&&r(Math.max(p,t),null==i&&p<=c,Math.min(g,e),null==n&&u<=g,d.dir)}if(t=f.to+1,t>=e)break}return 0==h.length&&r(c,null==i,u,null==n,m.textDirection),{top:o,bottom:a,horizontal:h}}}(this.view,t)).reduce((t,e)=>t.concat(e));let r=[];for(i of t.selection.ranges){var s=i==t.selection.main;(i.empty?s&&!sr:!e.drawRangeCursor)||(s=function(t,e,i){e=t.coordsAtPos(e.head,e.assoc||1);if(!e)return null;t=lr(t);return new ar(e.left-t.left,e.top-t.top,-1,e.bottom-e.top,i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}(this.view,i,s))&&r.push(s)}return{rangePieces:n,cursors:r}}drawSel({rangePieces:t,cursors:e}){if(t.length!=this.rangePieces.length||t.some((t,e)=>!t.eq(this.rangePieces[e]))){this.selectionLayer.textContent="";for(var i of t)this.selectionLayer.appendChild(i.draw());this.rangePieces=t}if(e.length!=this.cursors.length||e.some((t,e)=>!t.eq(this.cursors[e]))){let i=this.cursorLayer.children;if(i.length!==e.length){this.cursorLayer.textContent="";for(const n of e)this.cursorLayer.appendChild(n.draw())}else e.forEach((t,e)=>t.adjust(i[e]));this.cursors=e}}destroy(){this.selectionLayer.remove(),this.cursorLayer.remove()}});const hr={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};function lr(t){var e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Kt.LTR?e.left:e.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function cr(t,e,i){e=E.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(e,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(e,!0,!0).from)}}sr&&(hr[".cm-line"].caretColor="transparent !important"),W.override(Jn.theme(hr));const ur=null!=/x/.unicode?"gu":"g",dr=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029\ufeff-]",ur);let fr=null;H.define({combine(t){let e=gt(t,{render:null,specialChars:dr,addSpecialChars:null});return(e.replaceTabs=(null==fr&&"undefined"!=typeof document&&document.body&&(t=document.body.style,fr=null!=(t.tabSize||t.MozTabSize)),!fr))&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,ur)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,ur)),e}});const pr=ze.line({attributes:{class:"cm-activeLine"}});li.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(var n of t.state.selection.ranges)n.empty&&((n=t.visualLineAt(n.head)).from>e&&(i.push(pr.range(n.from)),e=n.from));return ze.set(i)}},{decorations:t=>t.decorations});let gr=0;const mr=new WeakMap;class vr{constructor({deserialize:t}={}){this.id=gr++,this.deserialize=t||(()=>{throw new Error("This node type doesn't define a deserialize function")})}static string(){return new vr({deserialize:t=>t})}static number(){return new vr({deserialize:Number})}static flag(){return new vr({deserialize:()=>!0})}set(t,e){return t[this.id]=e,t}add(e){return"function"!=typeof e&&(e=yr.match(e)),t=>{t=e(t);return void 0===t?null:[this,t]}}}vr.closedBy=new vr({deserialize:t=>t.split(" ")}),vr.openedBy=new vr({deserialize:t=>t.split(" ")}),vr.group=new vr({deserialize:t=>t.split(" ")});const wr=Object.create(null);class yr{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){var e=t.props&&t.props.length?Object.create(null):wr,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new yr(t.name||"",e,t.id,i);if(t.props)for(var r of t.props)Array.isArray(r)||(r=r(n)),r&&r[0].set(e,r[1]);return n}prop(t){return this.props[t.id]}get isTop(){return 0<(1&this.flags)}get isSkipped(){return 0<(2&this.flags)}get isError(){return 0<(4&this.flags)}get isAnonymous(){return 0<(8&this.flags)}is(e){if("string"!=typeof e)return this.id==e;{if(this.name==e)return!0;let t=this.prop(vr.group);return!!t&&-1{for(let t=i.prop(vr.group),e=-1;e<(t?t.length:0);e++){var n=r[e<0?i.name:t[e]];if(n)return n}}}}yr.none=new yr("",Object.create(null),0,8);class br{constructor(t,e,i,n){this.type=t,this.children=e,this.positions=i,this.length=n}toString(){var t=this.children.map(t=>t.toString()).join();return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(t,e=0){var i=null!=t&&mr.get(this)||this.topNode;let n=new Tr(i);return null!=t&&(n.moveTo(t,e),mr.set(this,n._tree)),n}fullCursor(){return new Tr(this.topNode,!0)}get topNode(){return new Sr(this,0,0,null)}resolve(t,e=0){return this.cursor(t,e).node}iterate(t){let{enter:i,leave:n,from:r=0,to:s=this.length}=t;for(let e=this.cursor();;){let t=!1;if(e.from<=s&&e.to>=r&&(e.type.isAnonymous||!1!==i(e.type,e.from,e.to))){if(e.firstChild())continue;e.type.isAnonymous||(t=!0)}for(;t&&n&&n(e.type,e.from,e.to),t=e.type.isAnonymous,!e.nextSibling();){if(!e.parent())return;t=!0}}}balance(t=1024){return this.children.length<=Lr?this:Br(this.type,yr.none,this.children,this.positions,0,this.children.length,0,t,this.length,0)}static build(t){let{buffer:e,nodeSet:m,topID:i=0,maxBufferLength:v=1024,reused:w=[],minRepeatType:y=m.types.length}=t,b=Array.isArray(e)?new Or(e,e.length):e,x=m.types,k=0;function S(i,t,e,n,r){var{id:s,start:o,end:a,size:h}=b;let l=o-i;if(h<0)return-1==h?(e.push(w[s]),n.push(l)):k=s,void b.next();let c=x[s],u,d;if(a-o<=v&&(d=function(t,e){let i=b.fork(),n=0,r=0,s=0,o=i.end-v,a={size:0,start:0,skip:0};t:for(var h=i.pos-t;i.pos>h;)if(i.id!=e){var l=i.size,c=i.pos-l;if(l<0||c=y?4:0;var u=i.start;for(i.next();i.pos>c;){if(i.size<0)break t;i.id>=y&&(t+=4),i.next()}r=u,n+=l,s+=t}else a.size=n,a.start=r,a.skip=s,s+=4,n+=4,i.next();(e<0||n==t)&&(a.size=n,a.start=r,a.skip=s);return 4t;)e=function t(e,i,n,r){var{id:s,start:o,end:a,size:h}=b;b.next();if(s==r)return n;var l=n;if(4c;)n=t(e,i,n,r);s=y?s:-1;b.pos>p;)b.id==g?b.next():S(o,p,t,e,g);t.reverse(),e.reverse(),u=-1Lr?Br(c,c,t,e,0,t.length,0,v,a-o,k):xr(new br(c,t,e,a-o),k)}e.push(u),n.push(l)}let n=[],r=[];for(;0=t:this.from>t)||(-1=t:this.from>t)||(-1!t.type.isAnonymous||t instanceof kr||Dr(t))}class Or{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Or(this.buffer,this.index)}}const Lr=8;function Br(t,i,n,r,s,o,a,h,e,l){let c=[],u=[];if(e<=h)for(let t=s;td<<1){for(let t=0;t=i)for(;s&&s.from=t.from||d<=t.to||h)&&(l=Math.max(t.from,a)-h,c=Math.min(t.to,d)-h,t=c<=l?null:new Er(l,c,t.tree,t.offset+h,(0d)break;s=rt.length&&n.push(r);return n}}const Pr=new vr;class Rr{constructor(t,e,i,n=[]){this.data=t,this.topNode=i,pt.prototype.hasOwnProperty("tree")||Object.defineProperty(pt.prototype,"tree",{get(){return Nr(this)}}),this.parser=e,this.extension=[Fr.of(this),pt.languageData.of((t,e)=>t.facet(Hr(t,e)))].concat(n)}isActiveAt(t,e){return Hr(t,e)==this.data}findRegions(t){var e=t.facet(Fr);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let n=[];return Nr(t).iterate({enter:(t,e,i)=>{if(t.isTop&&t.prop(Pr)==this.data)return n.push({from:e,to:i}),!1}}),n}get allowsNesting(){return!0}parseString(t){var e=d.of(t.split("\n"));let i=this.parser.startParse(new _r(e),0,new Vr(this.parser,pt.create({doc:e}),[],br.empty,{from:0,to:t.length},[])),n;for(;!(n=i.advance()););return n}}function Hr(t,e){var i=t.facet(Fr);if(!i)return null;if(!i.allowsNesting)return i.data;let n=Nr(t),r=n.resolve(e,-1);for(;r;){var s=r.type.prop(Pr);if(s)return s;r=r.parent}return i.data}function Nr(t){t=t.field(Rr.state,!1);return t?t.tree:br.empty}Rr.setState=rt.define();class _r{constructor(t,e=t.length){this.doc=t,this.length=e,this.cursorPos=0,this.string="",this.prevString="",this.cursor=t.iter()}syncTo(t){return t=this.length)return-1;let e=this.cursorPos-this.string.length;if(t=this.cursorPos){if(t=e-this.prevString.length)return this.prevString.charCodeAt(t-(e-this.prevString.length));e=this.syncTo(t)}return this.string.charCodeAt(t-e)}lineAfter(t){if(t>=this.length||t<0)return"";let e=this.cursorPos-this.string.length;return(t=this.cursorPos)&&(e=this.syncTo(t)),this.cursor.lineBreak?"":this.string.slice(t-e)}read(t,e){var i=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}clip(t){return new _r(this.doc,t)}}class Vr{constructor(t,e,i=[],n,r,s){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.viewport=r,this.skipped=s,this.parse=null,this.tempSkipped=[]}work(t,e){if(this.tree!=br.empty&&(null==e?this.tree.length==this.state.doc.length:this.tree.length>=e))return this.takeTree(),!0;this.parse||(this.parse=this.parser.startParse(new _r(this.state.doc),0,this));for(var i=Date.now()+t;;){var n=this.parse.advance();if(n)return this.fragments=this.withoutTempSkipped(Er.addTree(n)),this.parse=null,this.tree=n,!0;if(null!=e&&this.parse.pos>=e)return this.takeTree(),!0;if(Date.now()>i)return!1}}takeTree(){this.parse&&this.parse.pos>this.tree.length&&(this.tree=this.parse.forceFinish(),this.fragments=this.withoutTempSkipped(Er.addTree(this.tree,this.fragments,!0)))}withoutTempSkipped(t){for(var e;e=this.tempSkipped.pop();)t=zr(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let r=[];if(t.iterChangedRanges((t,e,i,n)=>r.push({fromA:t,toA:e,fromB:i,toB:n})),i=Er.applyChanges(i,r),n=br.empty,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(var a of this.skipped){var h=t.mapPos(a.from,1),a=t.mapPos(a.to,-1);he.from&&(this.fragments=zr(this.fragments,i,n),this.skipped.splice(t--,1))}return this.skipped.length=t}}function zr(t,e,i){return Er.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}Vr.skippingParser={startParse(t,e,i){return{pos:e,advance(){return i.tempSkipped.push({from:e,to:t.length}),this.pos=t.length,new br(yr.none,[],[],t.length-e)},forceFinish(){return this.advance()}}}};class Ir{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged)return this;let e=this.context.changes(t.changes,t.state);t=this.context.tree.length==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.tree.length),e.viewport.to);return e.work(25,t)||e.takeTree(),new Ir(e)}static init(t){let e=new Vr(t.facet(Fr).parser,t,[],br.empty,{from:0,to:t.doc.length},[]);return e.work(25)||e.takeTree(),new Ir(e)}}Rr.state=z.define({create:Ir.init,update(t,e){for(var i of e.effects)if(i.is(Rr.setState))return i.value;return e.startState.facet(Fr)!=e.state.facet(Fr)?Ir.init(e.state):t.apply(e)}});let $r="undefined"!=typeof window&&window.requestIdleCallback||((t,{timeout:e})=>setTimeout(t,e)),Wr="undefined"!=typeof window&&window.cancelIdleCallback||clearTimeout;Qt=li.fromClass(class{constructor(t){this.view=t,this.working=-1,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){if(e.viewportChanged){let t=this.view.state.field(Rr.state).context;t.updateViewport(e.view.viewport)&&t.reset(),this.view.viewport.to>t.tree.length&&this.scheduleWork()}e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork())}scheduleWork(){if(!(-1=t.doc.length||(this.working=$r(this.work,{timeout:500}))}}work(n){this.working=-1;var r=Date.now();if(this.chunkEnd=e+1e6||(n=Math.min(this.chunkBudget,n?Math.max(25,n.timeRemaining()):100),n=i.context.work(n,e+1e6),this.chunkBudget-=Date.now()-r,(n||this.chunkBudget<=0||i.context.movedPast(e))&&(i.context.takeTree(),this.view.dispatch({effects:Rr.setState.of(new Ir(i.context))})),!n&&0{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function Jr(t){let e=t.facet(jr);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Kr(t,e){let i="",n=t.tabSize;if(9==t.facet(jr).charCodeAt(0))for(;n<=e;)i+="\t",e-=n;for(let t=0;tfunction(t,e,i,n,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==t.pos+o,h=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;var r=null===(r=t.options)||void 0===r?void 0:r.simulateBreak,t=t.state.doc.lineAt(i.from),s=null==r||r<=t.from?t.to:Math.min(t.to,r);for(let t=i.to;;){var o=e.childAfter(t);if(!o||o==n)return null;if(!o.type.isSkipped)return o.fromJn.decorations.from(t)}),Zt];function as(t,e,i){var n=t.prop(e<0?vr.openedBy:vr.closedBy);if(n)return n;if(1==t.name.length){t=i.indexOf(t.name);if(-1=e.to){if(0==o&&-1>1==h>>1};u--}}0"},cs=rt.define({map(t,e){t=e.mapPos(t,-1,b.TrackAfter);return null==t?void 0:t}}),us=rt.define({map(t,e){return e.mapPos(t)}}),ds=new class extends kt{};ds.startSide=1,ds.endSide=-1;const fs=z.define({create(){return Ct.empty},update(t,i){var e,n;i.selection&&(e=i.state.doc.lineAt(i.selection.main.head).from,n=i.startState.doc.lineAt(i.startState.selection.main.head).from,e!=i.changes.mapPos(n,-1)&&(t=Ct.empty)),t=t.map(i.changes);for(let e of i.effects)e.is(cs)?t=t.update({add:[ds.range(e.value,e.value+1)]}):e.is(us)&&(t=t.update({filter:t=>t!=e.value}));return t}});const ps="()[]{}<>";function gs(e){for(let t=0;t>10),56320+(1023&t)));var t}function ms(t,e){return t.languageDataAt("closeBrackets",e)[0]||ls}function vs(t,e,i,n){if(t.composing)return!1;var r=t.state.selection.main;if(2{if(!t.empty)return{changes:[{insert:s,from:t.from},{insert:s,from:t.to}],effects:cs.of(t.to+s.length),range:E.range(t.anchor+s.length,t.head+s.length)};var e=t.head,i=bs(r.doc,e);if(i==s){if(xs(r,e))return{changes:{insert:s+s,from:e},effects:cs.of(e+s.length),range:E.cursor(e+s.length)};if(ys(r,e)){var n=o&&r.sliceDoc(e,e+3*s.length)==s+s+s;return{range:E.cursor(e+s.length*(n?3:1)),effects:us.of(e)}}}else{if(o&&r.sliceDoc(e-2*s.length,e)==s+s&&xs(r,e-2*s.length))return{changes:{insert:s+s+s+s,from:e},effects:cs.of(e+s.length),range:E.cursor(e+s.length)};if(r.charCategorizer(e)(i)!=x.Word){i=r.sliceDoc(e-1,e);if(i!=s&&r.charCategorizer(e)(i)!=x.Word)return{changes:{insert:s+s,from:e},effects:cs.of(e+s.length),range:E.cursor(e+s.length)}}}return{range:a=t}});return a?null:r.update(t,{scrollIntoView:!0,annotations:st.userEvent.of("input")})}(t,r,-1{if(!t.empty)return{changes:[{insert:n,from:t.from},{insert:r,from:t.to}],effects:cs.of(t.to+n.length),range:E.range(t.anchor+n.length,t.head+n.length)};var e=bs(i.doc,t.head);return!e||/\s/.test(e)||-1t.empty&&bs(e.doc,t.head)==i?E.cursor(t.head+i.length):n=t);return n?null:e.update({selection:E.create(t,e.selection.mainIndex),scrollIntoView:!0,effects:e.selection.ranges.map(({from:t})=>us.of(t))})}(t,(r,s))}return null}(t.state,n);return!!n&&(t.dispatch(n),!0)}const ws=[{key:"Backspace",run:({state:n,dispatch:t})=>{let r=ms(n,n.selection.main.head).brackets||ls.brackets,s=null,e=n.changeByRange(t=>{if(t.empty){var e,i=function(t,e){let i=t.sliceString(e-2,e);return u(c(i,0))==i.length?i:i.slice(1)}(n.doc,t.head);for(e of r)if(e==i&&bs(n.doc,t.head)==gs(c(e,0)))return{changes:{from:t.head-e.length,to:t.head+e.length},range:E.cursor(t.head-e.length),annotations:st.userEvent.of("delete")}}return{range:s=t}});return s||t(n.update(e,{scrollIntoView:!0})),!s}}];function ys(t,e){let i=!1;return t.field(fs).between(0,t.doc.length,t=>{t==e&&(i=!0)}),i}function bs(t,e){let i=t.sliceString(e,e+2);return i.slice(0,u(c(i,0)))}function xs(t,e){t=Nr(t).resolve(e+1);return t.parent&&t.from==e}function ks(t,e){return E.create(t.ranges.map(e),t.mainIndex)}function Ss(t,e){return t.update({selection:e,scrollIntoView:!0,annotations:st.userEvent.of("keyboardselection")})}function As({state:t,dispatch:e},i){let n=ks(t.selection,i);return!n.eq(t.selection)&&(e(Ss(t,n)),!0)}function Ms(t,e){return E.cursor(e?t.to:t.from)}function Cs(e,i){return As(e,t=>t.empty?e.moveByChar(t,i):Ms(t,i))}const Ts=t=>Cs(t,t.textDirection!=Kt.LTR),Ds=t=>Cs(t,t.textDirection==Kt.LTR);function Os(e,i){return As(e,t=>t.empty?e.moveByGroup(t,i):Ms(t,i))}function Ls(e,i,n){let r=Nr(e).resolve(i.head);var s,o,a,h=n?vr.closedBy:vr.openedBy;for(let t=i.head;;){var l=n?r.childAfter(t):r.childBefore(t);if(!l)break;s=e,a=h,(o=l).type.prop(a)||((a=o.to-o.from)&&(2t.empty?e.moveVertically(t,i):Ms(t,i))}const Es=t=>Bs(t,!1),Ps=t=>Bs(t,!0);function Rs(e,i){return As(e,t=>t.empty?e.moveVertically(t,i,e.dom.clientHeight):Ms(t,i))}const Hs=t=>Rs(t,!1),Ns=t=>Rs(t,!0);function _s(t,e,i){let n=t.visualLineAt(e.head),r=t.moveToLineBoundary(e,i);return r.head==e.head&&r.head!=(i?n.to:n.from)&&(r=t.moveToLineBoundary(e,i,!1)),i||r.head!=n.from||!n.length||(t=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length)&&e.head!=n.from+t&&(r=E.cursor(n.from+t)),r}const Vs=e=>As(e,t=>E.cursor(e.visualLineAt(t.head).from,1)),zs=e=>As(e,t=>E.cursor(e.visualLineAt(t.head).to,-1));function Is(t,i){let e=ks(t.state.selection,t=>{var e=i(t);return E.range(t.anchor,e.head,e.goalColumn)});return!e.eq(t.state.selection)&&(t.dispatch(Ss(t.state,e)),!0)}function $s(e,i){return Is(e,t=>e.moveByChar(t,i))}const Ws=t=>$s(t,t.textDirection!=Kt.LTR),Fs=t=>$s(t,t.textDirection==Kt.LTR);function qs(e,i){return Is(e,t=>e.moveByGroup(t,i))}function js(e,i){return Is(e,t=>e.moveVertically(t,i))}const Js=t=>js(t,!1),Ks=t=>js(t,!0);function Gs(e,i){return Is(e,t=>e.moveVertically(t,i,e.dom.clientHeight))}const Us=t=>Gs(t,!1),Xs=t=>Gs(t,!0);const Ys=e=>Is(e,t=>E.cursor(e.visualLineAt(t.head).from)),Qs=e=>Is(e,t=>E.cursor(e.visualLineAt(t.head).to)),Zs=({state:t,dispatch:e})=>(e(Ss(t,{anchor:0})),!0),to=({state:t,dispatch:e})=>(e(Ss(t,{anchor:t.doc.length})),!0),eo=({state:t,dispatch:e})=>(e(Ss(t,{anchor:t.selection.main.anchor,head:0})),!0),io=({state:t,dispatch:e})=>(e(Ss(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function no({state:t,dispatch:e},r){var i=t.changeByRange(t=>{let{from:e,to:i}=t;var n;return e==i&&(n=r(e),e=Math.min(e,n),i=Math.max(i,n)),e==i?{range:t}:{changes:{from:e,to:i},range:E.cursor(e)}});return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,annotations:st.userEvent.of("delete")})),!0)}const ro=(a,h,l)=>no(a,e=>{let{state:t}=a,i=t.doc.lineAt(e),n;if(!h&&e>i.from&&ero(t,!0,!1),oo=(t,l)=>no(t,e=>{let i=e,{state:n}=t,r=n.doc.lineAt(i),s=n.charCategorizer(i);for(let t=null;;){if(i==(l?r.to:r.from)){i==e&&r.number!=(l?n.doc.lines:1)&&(i+=l?1:-1);break}var o=S(r.text,i-r.from,l)+r.from,a=r.text.slice(Math.min(i,o)-r.from,Math.max(i,o)-r.from),h=s(a);if(null!=t&&h!=t)break;" "==a&&i==e||(t=h),i=o}return i}),ao=t=>oo(t,!1),ho=t=>oo(t,!0);function lo(t){let e=[],i=-1;for(var n of t.selection.ranges){var r=t.doc.lineAt(n.from),n=t.doc.lineAt(n.to);i==r.number?e[e.length-1].to=n.to:e.push({from:r.from,to:n.to}),i=n.number}return e}function co(t,e,i){let n=[];for(var r of lo(t)){var s;(i?r.to!=t.doc.length:0!=r.from)&&(s=t.doc.lineAt(i?r.to+1:r.from-1),i?n.push({from:r.to,to:s.to},{from:r.from,insert:s.text+t.lineBreak}):n.push({from:s.from,to:r.from},{from:r.to,insert:t.lineBreak+s.text}))}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0})),!0)}function uo(t,e,i){let n=[];for(var r of lo(t))i?n.push({from:r.from,insert:t.doc.slice(r.from,r.to)+t.lineBreak}):n.push({from:r.to,insert:t.lineBreak+t.doc.slice(r.from,r.to)});return e(t.update({changes:n,scrollIntoView:!0})),!0}function fo(r,s){let o=-1;return r.changeByRange(e=>{var i=[];for(let t=e.from;t<=e.to;){var n=r.doc.lineAt(t);n.number>o&&(e.empty||e.to>n.from)&&(s(n,i,e),o=n.number),t=n.to+1}let t=r.changes(i);return{changes:i,range:E.range(t.mapPos(e.anchor,1),t.mapPos(e.head,1))}})}const po=({state:o,dispatch:t})=>{let a=Object.create(null),h=new Ur(o,{overrideIndentation:t=>{t=a[t];return null==t?-1:t}});var e=fo(o,(t,e,i)=>{var n,r,s=Gr(h,t.from);null==s||((n=/^\s*/.exec(t.text)[0])!=(r=Kr(o,s))||i.from(t(i.update(fo(i,(t,e)=>{e.push({from:t.from,insert:i.facet(jr)})}))),!0);const mo=[{key:"Ctrl-b",run:Ts,shift:Ws},{key:"Ctrl-f",run:Ds,shift:Fs},{key:"Ctrl-p",run:Es,shift:Js},{key:"Ctrl-n",run:Ps,shift:Ks},{key:"Ctrl-a",run:Vs,shift:Ys},{key:"Ctrl-e",run:zs,shift:Qs},{key:"Ctrl-d",run:so},{key:"Ctrl-h",run:t=>ro(t,!1,!1)},{key:"Ctrl-k",run:i=>no(i,t=>{var e=i.visualLineAt(t).to;return t{var i=t.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:d.of(["",""])},range:E.cursor(t.from)}));return e(t.update(i,{scrollIntoView:!0,annotations:st.userEvent.of("input")})),!0}},{key:"Ctrl-t",run:({state:n,dispatch:t})=>{var e=n.changeByRange(t=>{if(!t.empty||0==t.from||t.from==n.doc.length)return{range:t};var e=t.from,i=n.doc.lineAt(e),t=e==i.from?e-1:S(i.text,e-i.from,!1)+i.from,i=e==i.to?e+1:S(i.text,e-i.from,!0)+i.from;return{changes:{from:t,to:i,insert:n.doc.slice(e,i).append(n.doc.slice(t,e))},range:E.cursor(i)}});return!e.changes.empty&&(t(n.update(e,{scrollIntoView:!0})),!0)}},{key:"Alt-f",run:t=>Os(t,!0),shift:t=>qs(t,!0)},{key:"Alt-b",run:t=>Os(t,!1),shift:t=>qs(t,!1)},{key:"Alt-<",run:Zs},{key:"Alt->",run:to},{key:"Ctrl-v",run:Ns},{key:"Alt-v",run:Hs}];Yt=[{key:"ArrowLeft",run:Ts,shift:Ws},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Os(t,t.textDirection!=Kt.LTR),shift:t=>qs(t,t.textDirection!=Kt.LTR)},{mac:"Cmd-ArrowLeft",run:Vs,shift:Ys},{key:"ArrowRight",run:Ds,shift:Fs},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Os(t,t.textDirection==Kt.LTR),shift:t=>qs(t,t.textDirection==Kt.LTR)},{mac:"Cmd-ArrowRight",run:zs,shift:Qs},{key:"ArrowUp",run:Es,shift:Js},{mac:"Cmd-ArrowUp",run:Zs,shift:eo},{mac:"Ctrl-ArrowUp",run:Hs,shift:Us},{key:"ArrowDown",run:Ps,shift:Ks},{mac:"Cmd-ArrowDown",run:to,shift:io},{mac:"Ctrl-ArrowDown",run:Ns,shift:Xs},{key:"PageUp",run:Hs,shift:Us},{key:"PageDown",run:Ns,shift:Xs},{key:"Home",run:e=>As(e,t=>_s(e,t,!1)),shift:e=>Is(e,t=>_s(e,t,!1))},{key:"Mod-Home",run:Zs,shift:eo},{key:"End",run:e=>As(e,t=>_s(e,t,!0)),shift:e=>Is(e,t=>_s(e,t,!0))},{key:"Mod-End",run:to,shift:io},{key:"Enter",run:({state:a,dispatch:t})=>{var e=a.changeByRange(({from:t,to:e})=>{var i=t==e&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=Nr(t).resolve(e),n=i.childBefore(e),r=i.childAfter(e),s;return n&&r&&n.to<=e&&r.from>=e&&(s=n.type.prop(vr.closedBy))&&-1s.from&&t(e(t.update({selection:{anchor:0,head:t.doc.length},annotations:st.userEvent.of("keyboardselection")})),!0)},{key:"Backspace",run:t=>ro(t,!1,!0)},{key:"Delete",run:so},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ao},{key:"Mod-Delete",mac:"Alt-Delete",run:ho}].concat(mo.map(t=>({mac:t.key,run:t.run,shift:t.shift})));const vo=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>As(e,t=>Ls(e.state,t,e.textDirection!=Kt.LTR)),shift:e=>Is(e,t=>Ls(e.state,t,e.textDirection!=Kt.LTR))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>As(e,t=>Ls(e.state,t,e.textDirection==Kt.LTR)),shift:e=>Is(e,t=>Ls(e.state,t,e.textDirection==Kt.LTR))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>co(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>uo(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>co(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>uo(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return 1{var e=lo(i).map(({from:t,to:e})=>E.range(t,Math.min(e+1,i.doc.length)));return t(i.update({selection:E.create(e),annotations:st.userEvent.of("keyboardselection")})),!0}},{key:"Mod-i",run:({state:n,dispatch:t})=>{var e=ks(n.selection,t=>{var e;let i=Nr(n).resolve(t.head,1);for(;!(i.from=t.to||i.to>t.to&&i.from<=t.from||null===(e=i.parent)||void 0===e)&&e.parent;)i=i.parent;return E.range(i.to,i.from)});return t(Ss(n,e)),!0}},{key:"Mod-[",run:({state:o,dispatch:t})=>(t(o.update(fo(o,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(s){let t=A(s,0,o.tabSize),e=0,i=Kr(o,Math.max(0,t-Jr(o)));for(;e{let{state:i}=e,t=i.changes(lo(i).map(({from:t,to:e})=>(0e.moveVertically(t,!0)).map(t);return e.dispatch({changes:t,selection:n,scrollIntoView:!0}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(i,t,n){let r=!1,e=ks(i.selection,t=>{var e=hs(i,t.head,-1)||hs(i,t.head,1)||0t.selection.ranges.some(t=>!t.empty)?go({state:t,dispatch:e}):(e(t.update(t.replaceSelection("\t"),{scrollIntoView:!0,annotations:st.userEvent.of("input")})),!0),shift:po},yo=et.define(),bo=et.define(),xo=H.define(),ko=H.define({combine(t){return gt(t,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}}),So=z.define({create(){return Ro.empty},update(e,i){var n=i.state.facet(ko),r=i.annotation(yo);if(r){var s=To.fromTransaction(i),o=r.side;let t=0==o?e.undone:e.done;return t=s?Do(t,t.length,n.minDepth,s):Eo(t,i.startState.selection),new Ro(0==o?r.rest:t,0==o?t:r.rest)}var t=i.annotation(bo);if("full"!=t&&"before"!=t||(e=e.isolate()),!1===i.annotation(st.addToHistory))return i.changes.empty?e:e.addMapping(i.changes.desc);s=To.fromTransaction(i),o=i.annotation(st.time),r=i.annotation(st.userEvent);return s?e=e.addChanges(s,o,r,n.newGroupDelay,n.minDepth):i.selection&&(e=e.addSelection(i.startState.selection,o,r,n.newGroupDelay)),e="full"==t||"after"==t?e.isolate():e},toJSON(t){return{done:t.done.map(t=>t.toJSON()),undone:t.undone.map(t=>t.toJSON())}},fromJSON(t){return new Ro(t.done.map(To.fromJSON),t.undone.map(To.fromJSON))}});function Ao(n,r){return function({state:t,dispatch:e}){let i=t.field(So,!1);if(!i)return!1;t=i.pop(n,t,r);return!!t&&(e(t),!0)}}const Mo=Ao(0,!1),Co=Ao(1,!1);ee=Ao(0,!0),ie=Ao(1,!0);class To{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(t){return new To(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(t=this.startSelection)||void 0===t?void 0:t.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new To(t.changes&&M.fromJSON(t.changes),[],t.mapped&&k.fromJSON(t.mapped),t.startSelection&&E.fromJSON(t.startSelection),t.selectionsAfter.map(E.fromJSON))}static fromTransaction(t){let e=Lo;for(var i of t.startState.facet(xo)){i=i(t);i.length&&(e=e.concat(i))}return!e.length&&t.changes.empty?null:new To(t.changes.invert(t.startState.doc),e,void 0,t.startState.selection,Lo)}static selection(t){return new To(void 0,Lo,void 0,void 0,t)}}function Do(t,e,i,n){let r=t.slice(i+20t.map(e)):Lo,i);if(!t.changes)return To.selection(n);var r=t.changes.map(e),s=e.mapDesc(t.changes,!0),i=t.mapped?t.mapped.composeDesc(s):s;return new To(r,rt.mapEffects(t.effects,e),i,t.startSelection.map(s),n)}(e[i-1],t,n);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,i);return t[i-1]=r,t}t=r.mapped,i--,n=r.selectionsAfter}return n.length?[To.selection(n)]:Lo}class Ro{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Ro(this.done,this.undone):this}addChanges(t,e,i,n,r){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&e-this.prevTimeo.push(t,e)),e.iterChangedRanges((t,e,i,n)=>{for(let t=0;tt.empty!=r.ranges[e].empty).length)?this:new Ro(Eo(this.done,t),this.undone,e,i)}addMapping(t){return new Ro(Po(this.done,t),Po(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,i,t){let n=0==e?this.done:this.undone;if(0==n.length)return null;var r=n[n.length-1];if(t&&r.selectionsAfter.length)return i.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:yo.of({side:e,rest:function(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}(n)})});if(r.changes){let t=1==n.length?Lo:n.slice(0,n.length-1);return r.mapped&&(t=Po(t,r.mapped)),i.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:yo.of({side:e,rest:t}),filter:!1})}return null}}Ro.empty=new Ro(Lo,Lo);const Ho=[{key:"Mod-z",run:Mo,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Co,preventDefault:!0},{key:"Mod-u",run:ee,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ie,preventDefault:!0}];let No=0;class _o{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=No++}static define(t){if(null!=t&&t.base)throw new Error("Can not derive from a modified tag");let e=new _o([],null,[]);if(e.set.push(e),t)for(var i of t.set)e.set.push(i);return e}static defineModifier(){let e=new zo;return t=>-1t.id-e.id))}}let Vo=0;class zo{constructor(){this.instances=[],this.id=Vo++}static get(e,i){if(!i.length)return e;var t,n=i[0].instances.find(t=>t.base==e&&function(t,i){return t.length==i.length&&t.every((t,e)=>t==i[e])}(i,t.modified));if(n)return n;let r=[],s=new _o(r,e,i);for(t of i)t.instances.push(s);var o,a=function e(i){let n=[i];for(let t=0;tt.scope)?void 0:Object.create(null);return(t,e)=>{var i,n=a&&a[t.id];if(void 0!==n)return n;let r=null;for(i of o){var s=i.match(t,e);s&&(r=r?r+" "+s:s)}return a&&(a[t.id]=r),r}}static define(t,e){return new jo(t,e||{})}static get(t,e,i){return qo(t)(e,i||yr.none)}}const Jo=W.fallback(li.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=Nr(t.state),this.decorations=this.buildDeco(t,qo(t.state))}update(t){var e=Nr(t.state),i=qo(t.state),n=i!=t.startState.facet($o);e.lengthr-1)){for(let t=r-1,e=i.length-1;0<=e;e--,t--){var s=i[e];if(s&&s!=n[t])return}return 1}}(e.context,Ko,s)){for(var l of e.tags)(l=d(l,o))&&(t&&(t+=" "),t+=l,1==e.mode?r+=(r?" ":"")+l:0==e.mode&&(i=!0));break}e=e.next}if(t!=g&&(h>p&&g&&f(p,m.from,g),p=h,g=t),!i&&m.firstChild()){do{var c=m.to;n(r,s+1,o),g!=t&&((c=Math.min(u,c))>p&&g&&f(p,c,g),p=c,g=t)}while(m.nextSibling());m.parent()}}}("",0,t.type)}(this.tree,i,r,e,(t,e,i)=>{n.add(t,e,this.markCache[i]||(this.markCache[i]=ze.mark({class:i})))});return n.finish()}},{decorations:t=>t.decorations})),Ko=[""];const Go=_o.define;Ut=Go(),re=Go(),ne=Go(re),Xt=Go(),Vt=Go(Xt),It=Go(Xt),$t=Go(),te=Go($t),Qt=Go(),Zt=Go(),Yt=Go(),ee=Go(Yt),ie=Go();const Uo={comment:Ut,lineComment:Go(Ut),blockComment:Go(Ut),docComment:Go(Ut),name:re,variableName:Go(re),typeName:ne,tagName:Go(ne),propertyName:Go(re),className:Go(re),labelName:Go(re),namespace:Go(re),macroName:Go(re),literal:Xt,string:Vt,docString:Go(Vt),character:Go(Vt),number:It,integer:Go(It),float:Go(It),bool:Go(Xt),regexp:Go(Xt),escape:Go(Xt),color:Go(Xt),url:Go(Xt),keyword:Qt,self:Go(Qt),null:Go(Qt),atom:Go(Qt),unit:Go(Qt),modifier:Go(Qt),operatorKeyword:Go(Qt),controlKeyword:Go(Qt),definitionKeyword:Go(Qt),operator:Zt,derefOperator:Go(Zt),arithmeticOperator:Go(Zt),logicOperator:Go(Zt),bitwiseOperator:Go(Zt),compareOperator:Go(Zt),updateOperator:Go(Zt),definitionOperator:Go(Zt),typeOperator:Go(Zt),controlOperator:Go(Zt),punctuation:Yt,separator:Go(Yt),bracket:ee,angleBracket:Go(ee),squareBracket:Go(ee),paren:Go(ee),brace:Go(ee),content:$t,heading:te,heading1:Go(te),heading2:Go(te),heading3:Go(te),heading4:Go(te),heading5:Go(te),heading6:Go(te),contentSeparator:Go($t),list:Go($t),quote:Go($t),emphasis:Go($t),strong:Go($t),link:Go($t),monospace:Go($t),inserted:Go(),deleted:Go(),changed:Go(),invalid:Go(),meta:ie,documentMeta:Go(ie),annotation:Go(ie),processingInstruction:Go(ie),definition:_o.defineModifier(),constant:_o.defineModifier(),function:_o.defineModifier(),standard:_o.defineModifier(),local:_o.defineModifier(),special:_o.defineModifier()};jo.define([{tag:Uo.link,textDecoration:"underline"},{tag:Uo.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Uo.emphasis,fontStyle:"italic"},{tag:Uo.strong,fontWeight:"bold"},{tag:Uo.keyword,color:"#708"},{tag:[Uo.atom,Uo.bool,Uo.url,Uo.contentSeparator,Uo.labelName],color:"#219"},{tag:[Uo.literal,Uo.inserted],color:"#164"},{tag:[Uo.string,Uo.deleted],color:"#a11"},{tag:[Uo.regexp,Uo.escape,Uo.special(Uo.string)],color:"#e40"},{tag:Uo.definition(Uo.variableName),color:"#00f"},{tag:Uo.local(Uo.variableName),color:"#30a"},{tag:[Uo.typeName,Uo.namespace],color:"#085"},{tag:Uo.className,color:"#167"},{tag:[Uo.special(Uo.variableName),Uo.macroName],color:"#256"},{tag:Uo.definition(Uo.propertyName),color:"#00c"},{tag:Uo.comment,color:"#940"},{tag:Uo.meta,color:"#7a757a"},{tag:Uo.invalid,color:"#f00"}]);const Xo=jo.define([{tag:Uo.link,class:"cmt-link"},{tag:Uo.heading,class:"cmt-heading"},{tag:Uo.emphasis,class:"cmt-emphasis"},{tag:Uo.strong,class:"cmt-strong"},{tag:Uo.keyword,class:"cmt-keyword"},{tag:Uo.atom,class:"cmt-atom"},{tag:Uo.bool,class:"cmt-bool"},{tag:Uo.url,class:"cmt-url"},{tag:Uo.labelName,class:"cmt-labelName"},{tag:Uo.inserted,class:"cmt-inserted"},{tag:Uo.deleted,class:"cmt-deleted"},{tag:Uo.literal,class:"cmt-literal"},{tag:Uo.string,class:"cmt-string"},{tag:Uo.number,class:"cmt-number"},{tag:[Uo.regexp,Uo.escape,Uo.special(Uo.string)],class:"cmt-string2"},{tag:Uo.variableName,class:"cmt-variableName"},{tag:Uo.local(Uo.variableName),class:"cmt-variableName cmt-local"},{tag:Uo.definition(Uo.variableName),class:"cmt-variableName cmt-definition"},{tag:Uo.special(Uo.variableName),class:"cmt-variableName2"},{tag:Uo.typeName,class:"cmt-typeName"},{tag:Uo.namespace,class:"cmt-namespace"},{tag:Uo.macroName,class:"cmt-macroName"},{tag:Uo.propertyName,class:"cmt-propertyName"},{tag:Uo.operator,class:"cmt-operator"},{tag:Uo.comment,class:"cmt-comment"},{tag:Uo.meta,class:"cmt-meta"},{tag:Uo.invalid,class:"cmt-invalid"},{tag:Uo.punctuation,class:"cmt-punctuation"}]);var Yo=[{type:"undo",title:"撤销",innerHTML:''},{type:"redo",title:"重做",innerHTML:''},{type:"bold",title:"加粗",innerHTML:''},{type:"italic",title:"倾斜",innerHTML:''},{type:"delete",title:"删除",innerHTML:''},{type:"code-inline",title:"行内代码",innerHTML:''},{type:"indent",title:"缩进",innerHTML:''},{type:"hr",title:"横线",innerHTML:''},{type:"quote",title:"引用",innerHTML:''},{type:"title",title:"标题",innerHTML:''},{type:"ordered-list",title:"有序列表",innerHTML:''},{type:"unordered-list",title:"无序列表",innerHTML:''},{type:"link",title:"超链接",innerHTML:''},{type:"image",title:"插入图片",innerHTML:''},{type:"character",title:"实体符号",innerHTML:''},{type:"table",title:"表格",innerHTML:''},{type:"emoji",title:"符号表情",innerHTML:''},{type:"code-block",title:"代码块",innerHTML:''},{type:"time",title:"当前时间",innerHTML:''},{type:"clean",title:"清屏",innerHTML:''},{type:"download",title:"下载",innerHTML:''},{type:"fullScreen",title:"全屏/取消全屏",innerHTML:''},{type:"publish",title:"发布文章",innerHTML:''},{type:"about",title:"关于",innerHTML:''}];class Qo extends class{constructor(){$("body").append(` +!function(){"use strict";let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=1;te)return r[t-1]<=e}(e))n+=u(e),t=e;else{if(!s(e))break;{let t=0,e=n-2;for(;0<=e&&s(c(i,e));)t++,e-=2;if(t%2==0)break;n+=2}}}return n}function a(t,e){for(;0this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){var n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),m.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){var i=[];return this.decompose(t,e,i,0),m.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=new v(this),i=new v(t);for(;;){if(e.next(),i.next(),e.lineBreak!=i.lineBreak||e.done!=i.done||e.value!=i.value)return!1;if(e.done)return!0}}iter(t=1){return new v(this,t)}iterRange(t,e=this.length){return new i(this,t,e)}toString(){return this.sliceString(0)}toJSON(){var t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new g(t):m.from(g.split(t,[])):d.empty}}"undefined"!=typeof Symbol&&(d.prototype[Symbol.iterator]=function(){return this.iter()});class g extends d{constructor(t,e=function(t){let e=-1;for(var i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(e,i,n,r){for(let t=0;;t++){var s=this.text[t],o=r+s.length;if(e<=(i?n:o))return new w(r,o,n,s);r=o+1,n++}}decompose(i,t,n,r){i=i<=0&&t>=this.length?this:new g(p(this.text,i,t),Math.min(t,this.length)-Math.max(0,i));if(1&r){let t=n.pop(),e=f(i.text,t.text.slice(),0,i.length);e.length<=32?n.push(new g(e,t.length+i.length)):(r=e.length>>1,n.push(new g(e.slice(0,r)),new g(e.slice(r))))}else n.push(i)}replace(t,e,i){if(!(i instanceof g))return super.replace(t,e,i);var n=f(this.text,f(i.text,p(this.text,0,t)),e),t=this.length+i.length-(e-t);return n.length<=32?new g(n,t):m.from(g.split(n,[]),t)}sliceString(r,s=this.length,o="\n"){let a="";for(let i=0,n=0;i<=s&&nr&&n&&(a+=o),ri&&(a+=t.slice(Math.max(0,r-i),s-i)),i=e+1}return a}flatten(t){for(var e of this.text)t.push(e)}static split(t,e){let i=[],n=-1;for(var r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new g(i,n)),i=[],n=-1);return-1=n&&(h=a&((n<=r?1:0)|(s<=e?2:0)),n>=r&&e<=s&&!h?o.push(t):t.decompose(r-n,s-n,o,h)),n=e+1}}replace(r,s,o){if(o.lines=n&&s<=e){var a=t.replace(r-n,s-n,o),h=this.lines-t.lines+a.lines;if(a.lines>4&&a.lines>h>>6){let t=this.children.slice();return t[i]=a,new m(t,this.length-(s-r)+o.length)}return super.replace(n,e,a)}n=e+1}return super.replace(r,s,o)}sliceString(r,s=this.length,o="\n"){let a="";for(let i=0,n=0;ir&&i&&(a+=o),rn&&(a+=t.sliceString(r-n,s-n,o)),n=e+1}return a}flatten(t){for(var e of this.children)e.flatten(t)}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(var n of t)i+=n.lines;if(i<32){var r,s=[];for(r of t)r.flatten(s);return new g(s,e)}let o=Math.max(32,i>>5),a=o<<1,h=o>>1,l=[],c=0,u=-1,d=[];function f(){0!=c&&(l.push(1==d.length?d[0]:m.from(d,u)),u=-1,c=d.length=0)}for(var p of t)!function t(e){let i;if(e.lines>a&&e instanceof m)for(var n of e.children)t(n);else e.lines>h&&(c>h||!c)?(f(),l.push(e)):e instanceof g&&c&&(i=d[d.length-1])instanceof g&&e.lines+i.lines<=32?(c+=e.lines,u+=e.length+1,d[d.length-1]=new g(i.text.concat(e.text),i.length+1+e.length)):(c+e.lines>o&&f(),c+=e.lines,u+=e.length+1,d.push(e))}(p);return f(),1==l.length?l[0]:new m(l,e)}}function f(s,o,a=0,h=1e9){for(let i=0,n=0,r=!0;nMath.max(0,n))return this.value=0==n?t:0t.length?n-=t.length:(this.nodes.push(t),this.offsets.push(0this.limit&&(this.value=0r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(i,n=i){for(let t=0,e=0;t"number"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeDesc");return new k(t)}}class M extends k{constructor(t,e){super(t),this.inserted=e}apply(s){if(this.length!=s.length)throw new RangeError("Applying change set to a document with the wrong length");return D(this,(t,e,i,n,r)=>s=s.replace(i,i+(e-t),r),!1),s}mapDesc(t,e=!1){return O(this,t,e,!0)}invert(i){let n=this.sections.slice(),r=[];for(let t=0,e=0;t>1;r.length>1].toJSON()))}return n}static of(t,s,o){let a=[],h=[],l=0,i=null;function c(t=!1){if(t||a.length){ll&&C(a,t-l,-1),C(a,e-t,n),T(h,a,r),l=e)}}(t),c(!i),i}static empty(t){return new M(t?[t,-1]:[],[])}static fromJSON(i){if(!Array.isArray(i))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let e=0;ee&&"string"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==t.length)n.push(t[0],0);else{for(;r.length>1;if(n>1])),!(c||a==h.sections.length||h.sections[a+1]<0);)n=h.sections[a++],r=h.sections[a++];l(s,t,o,e,i),s=t,o=e}}}function O(t,e,r,i=!1){var s=[],o=i?[]:null;let a=new L(t),h=new L(e);for(let i=0,n=0;;)if(-1==a.ins)i+=a.len,a.next();else if(-1==h.ins&&nn&&!a.done&&i+a.leni&&n+h.lenh||0<=o.ins&&o.len>h)&&(t||l>1;return e>=t.length?d.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?d.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class B{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){var t=3&this.flags;return 3==t?null:t}get goalColumn(){var t=this.flags>>5;return 33554431==t?void 0:t}map(t,e=-1){var i=t.mapPos(this.from,e),e=t.mapPos(this.to,e);return i==this.from&&e==this.to?this:new B(i,e,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return E.range(t,e);e=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return E.range(this.anchor,e)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return E.range(t.anchor,t.head)}}class E{constructor(t,e=0){this.ranges=t,this.mainIndex=e}map(e,i=-1){return e.empty?this:E.create(this.ranges.map(t=>t.map(e,i)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;tt.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new E(t.ranges.map(t=>B.fromJSON(t)),t.main)}static single(t,e=t){return new E([E.range(t,e)],0)}static create(i,n=0){if(0==i.length)throw new RangeError("A selection needs at least one range");for(let t=0,e=0;et.from-e.from),i=e.indexOf(t);for(let t=1;tr.head?E.range(s,n):E.range(n,s)))}return new E(e,i)}(i.slice(),n);t=r.to}return new E(i,n)}static cursor(t,e=0,i,n){return new B(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i){i=(null!=i?i:33554431)<<5;return ee)throw new RangeError("Selection points outside of document")}let R=0;class H{constructor(t,e,i,n,r){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.extensions=r,this.id=R++,this.default=t([])}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:N),!!t.static,t.enables)}of(t){return new _([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new _(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new _(t,this,2,e)}from(e,i){return i=i||(t=>t),this.compute([e],t=>i(t.field(e)))}}function N(t,i){return t==i||t.length==i.length&&t.every((t,e)=>t===i[e])}class _{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=R++}dynamicSlot(t){var e,i;let n=this.value,r=this.facet.compareInput,s=t[this.id]>>1,o=2==this.type,a=!1,h=!1,l=[];for(i of this.dependencies)"doc"==i?a=!0:"selection"==i?h=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&l.push(t[i.id]);return(e,t)=>{if(!t||t.reconfigured)return e.values[s]=n(e),1;if(!(a&&t.docChanged||h&&(t.docChanged||t.selection)||l.some(t=>0<(1&K(e,t)))))return 0;var i=n(e),t=t.startState.values[s];return(o?function(e,i,n){if(e.length!=i.length)return!1;for(let t=0;tt===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(V).find(t=>t.field==this);return((null===e||void 0===e?void 0:e.create)||this.createF)(t)}slot(t){let o=t[this.id]>>1;return(t,e)=>{if(!e)return t.values[o]=this.create(t),1;let i,n=0;var r,s;e.reconfigured?(r=e.startState,s=this.id,s=null==(s=r.config.address[s])?null:s>>1,i=null==s?this.create(e.startState):e.startState.values[s],n=1):i=e.startState.values[o];e=this.updateF(i,e);return n||this.compareF(i,e)||(n=1),n&&(t.values[o]=e),n}}init(t){return[this,V.of({field:this,create:t})]}get extension(){return this}}const I={fallback:3,default:2,extend:1,override:0};function t(e){return t=>new F(t,e)}const W={fallback:t(I.fallback),default:t(I.default),extend:t(I.extend),override:t(I.override)};class F{constructor(t,e){this.inner=t,this.prec=e}}class q{of(t){return new j(this,t)}reconfigure(t){return q.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class j{constructor(t,e){this.compartment=t,this.inner=e}}class J{constructor(t,e,i,n,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,e,n){let i=[],r=Object.create(null);var s,o,a=new Map;for(s of function(t,a,h){let l=[[],[],[],[]],c=new Map;return function t(e,i){var n=c.get(e);if(null!=n){if(i<=n)return;var r=l[n].indexOf(e);-1t.concat(e))}(t,e,a))(s instanceof z?i:r[s.facet.id]||(r[s.facet.id]=[])).push(s);let h=Object.create(null),l=[],c=[];for(let e of i)h[e.id]=c.length<<1,c.push(t=>e.slot(t));for(o in r){let i=r[o],e=i[0].facet;if(i.every(t=>0==t.type)){h[e.id]=l.length<<1|1;let t=e.combine(i.map(t=>t.value));var u=n?n.config.address[e.id]:null;null!=u&&(u=G(n,u),e.compare(t,u)&&(t=u)),l.push(t)}else{for(let e of i)0==e.type?(h[e.id]=l.length<<1|1,l.push(e.value)):(h[e.id]=c.length<<1,c.push(t=>e.dynamicSlot(t)));h[e.id]=c.length<<1,c.push(t=>function(e,l,t){let c=t.map(t=>e[t.id]),u=t.map(t=>t.type),d=c.filter(t=>!(1&t)),f=e[l.id]>>1;return(e,t)=>{var i,n=t?t.reconfigured?t.startState.config.address[l.id]:f<<1:null;let r=null==n;for(i of d)1&K(e,i)&&(r=!0);if(!r)return 0;let s=[];for(let t=0;tt(h)),h,l)}}function K(t,e){if(1&e)return 2;var i=e>>1,e=t.status[i];if(4==e)throw new Error("Cyclic dependency between fields and/or facets");if(2&e)return e;t.status[i]=4;e=t.config.dynamicSlots[i](t,t.applying);return t.status[i]=2|e}function G(t,e){return(1&e?t.config.staticValues:t.values)[e>>1]}const U=H.define(),X=H.define({combine:t=>t.some(t=>t),static:!0}),Y=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),Q=H.define(),Z=H.define(),tt=H.define();class et{constructor(t,e){this.type=t,this.value=e}static define(){return new it}}class it{of(t){return new et(this,t)}}class nt{constructor(t){this.map=t}of(t){return new rt(this,t)}}class rt{constructor(t,e){this.type=t,this.value=e}map(t){t=this.type.map(this.value,t);return void 0===t?void 0:t==this.value?this:new rt(this.type,t)}is(t){return this.type==t}static define(t={}){return new nt(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(var n of t){n=n.map(e);n&&i.push(n)}return i}}rt.reconfigure=rt.define(),rt.appendConfig=rt.define();class st{constructor(t,e,i,n,r,s){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,i&&P(i,e.newLength),r.some(t=>t.type==st.time)||(this.annotations=r.concat(st.time.of(Date.now())))}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(var e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}}function ot(t,e,i){let n,r,s;return s=i?(n=e.changes,r=M.empty(e.changes.length),t.changes.compose(e.changes)):(n=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),t.changes.compose(n)),{changes:s,selection:e.selection?e.selection.map(r):null===(i=t.selection)||void 0===i?void 0:i.map(n),effects:rt.mapEffects(t.effects,n).concat(rt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function at(t,e,i){var n=e.selection;return{changes:e.changes instanceof M?e.changes:M.of(e.changes||[],i,t.facet(Y)),selection:n&&(n instanceof E?n:E.single(n.anchor,n.head)),effects:ct(e.effects),annotations:ct(e.annotations),scrollIntoView:!!e.scrollIntoView}}function ht(e,i,n){let r=at(e,i.length?i[0]:{},e.doc.length);i.length&&!1===i[0].filter&&(n=!1);for(let t=1;t=r[i]))t=r[i++],e=r[i++];else{if(!(n{if(!/\S/.test(e))return x.Space;if(function(i){if(dt)return dt.test(i);for(let e=0;enull),n)for(var r in t.address){var s=t.address[r],r=n.startState.config.address[r];null!=r&&0==(1&s)&&(this.values[s>>1]=G(n.startState,r))}(this.applying=n)&&(n._state=this);for(let t=0;tn.set(e,t)),e=null),n.set(r.value.compartment,r.value.extension)):r.is(rt.reconfigure)?(e=null,i=r.value):r.is(rt.appendConfig)&&(e=null,i=ct(i).concat(r.value));new pt(e||J.resolve(i,n,this),t.newDoc,t.newSelection,t)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:E.cursor(t.from+e.length)}))}changeByRange(r){var s=this.selection,t=r(s.ranges[0]);let o=this.changes(t.changes),a=[t.range],h=ct(t.effects);for(let n=1;ne.spec.fromJSON(i,t)))}return pt.create({doc:t.doc,selection:E.fromJSON(t.selection),extensions:e.extensions?r.concat([e.extensions]):r})}static create(t={}){let e=J.resolve(t.extensions||[],new Map);var i=t.doc instanceof d?t.doc:d.of((t.doc||"").split(e.staticFacet(pt.lineSeparator)||y));let n=t.selection?t.selection instanceof E?t.selection:E.single(t.selection.anchor,t.selection.head):E.single(0);return P(n,i.length),e.staticFacet(X)||(n=n.asSingle()),new pt(e,i,n)}get tabSize(){return this.facet(pt.tabSize)}get lineBreak(){return this.facet(pt.lineSeparator)||"\n"}phrase(t){for(var e of this.facet(pt.phrases))if(Object.prototype.hasOwnProperty.call(e,t))return e[t];return t}languageDataAt(t,e){let i=[];for(var n of this.facet(U))for(var r of n(this,e))Object.prototype.hasOwnProperty.call(r,t)&&i.push(r[t]);return i}charCategorizer(t){return ft(this.languageDataAt("wordChars",t).join(""))}}function gt(t,e,i={}){let n={};for(var r of t)for(var s of Object.keys(r)){var o=r[s],a=n[s];if(void 0===a)n[s]=o;else if(a!==o&&void 0!==o){if(!Object.hasOwnProperty.call(i,s))throw new Error("Config merge conflict for field "+s);n[s]=i[s](a,o)}}for(var h in e)void 0===n[h]&&(n[h]=e[h]);return n}pt.allowMultipleSelections=X,pt.tabSize=H.define({combine:t=>t.length?t[0]:4}),pt.lineSeparator=Y,pt.phrases=H.define(),pt.languageData=U,pt.changeFilter=Q,pt.transactionFilter=Z,pt.transactionExtender=tt,q.reconfigure=rt.define();const mt="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),vt="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),wt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class yt{constructor(t,e){this.rules=[];let{finish:c}=e||{};function u(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}for(var i in t)!function t(i,e,n,r){let s=[],o=/^@(\w+)\b/.exec(i[0]),a=o&&"keyframes"==o[1];if(o&&null==e)return n.push(i[0]+";");for(var h in e){var l=e[h];if(/&/.test(h))t(h.split(/,\s*/).map(e=>i.map(t=>e.replace(/&/,t))).reduce((t,e)=>t.concat(e)),l,n);else if(l&&"object"==typeof l){if(!o)throw new RangeError("The value of a property ("+h+") should be a primitive value.");t(u(h),l,s,a)}else null!=l&&s.push(h.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+l+";")}(s.length||a)&&n.push((!c||o||r?i:i.map(c)).join(", ")+" {"+s.join(" ")+"}")}(u(i),t[i],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=wt[mt]||1;return wt[mt]=t+1,"ͼ"+t.toString(36)}static mount(t,e){(t[vt]||new xt(t)).mount(Array.isArray(e)?e:[e])}}let bt=null;class xt{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(bt)return e.adoptedStyleSheets=[bt.sheet].concat(e.adoptedStyleSheets),e[vt]=bt;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),bt=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[vt]=this}mount(n){let r=this.sheet,s=0,o=0;for(let i=0;i>1,h=o[a]-i||(n<0?this.value[a].startSide:this.value[a].endSide)-r;if(a==t)return 0<=h?t:e;0<=h?e=a:t=1+a}}between(i,n,r,s){for(let t=this.findIndex(n,-1),e=this.findIndex(r,1,void 0,t);tr||n==r&&0this.chunkEnd(o.chunkIndex)||ro.to||r500<=t.maxPoint||t!=Ct.empty&&i.indexOf(t)<0&&t.maxPoint>=r),o=i.filter(t=>500<=t.maxPoint||t!=Ct.empty&&e.indexOf(t)<0&&t.maxPoint>=r),a=function(t,e){let i=new Map;for(var n of t)for(let t=0;tEt(h,t,l,e,i,n)),t.empty&&0==t.length&&Et(h,0,l,0,0,n)}static spans(t,e,i,n,r=-1){let s=new Bt(t,null,r).goto(e),o=e,a=s.openStart;for(;;){var h=Math.min(s.to,i);if(s.point?(n.point(o,h,s.point,s.activeForPoint(s.to),a),a=s.openEnd(h)+(s.to>h?1:0)):h>o&&(n.span(o,h,s.active,a),a=s.openEnd(h)),s.to>i)break;o=s.to,s.next()}return a}static of(t,e=!1){let i=new Tt;for(var n of t instanceof St?[t]:e?t.slice().sort(At):t)i.add(n.from,n.to,n.value);return i.finish()}}Ct.empty=new Ct([],[],null,-1),Ct.empty.nextLayer=Ct.empty;class Tt{constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}finishChunk(t){this.chunks.push(new Mt(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Tt)).add(t,e,i)}addInner(t,e,i){var n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);var i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Ct.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;t=new Ct(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,t}}class Dt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex=this.minPoint)break}}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.to-t.to||this.endSide-t.endSide}}class Ot{constructor(t){this.heap=t}static from(i,n=null,r=-1){let s=[];for(let e=0;e=r&&s.push(new Dt(t,n,r,e));return 1==s.length?s[0]:new Ot(s)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(var i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;0<=t;t--)Lt(this.heap,t);return this.next(),this}forward(t,e){for(var i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;0<=t;t--)Lt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Lt(this.heap,0)}}}function Lt(n,r){for(let i=n[r];;){let t=1+(r<<1);if(t>=n.length)break;let e=n[t];if(t+1e){this.to=this.activeTo[t],this.endSide=this.active[t].endSide;break}this.removeActive(t),i&&Pt(i,t)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}t=this.cursor.value;if(t.point){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.frome&&this.forward(this.to,this.endSide);break}this.addActive(i),this.cursor.next()}}if(i){let t=0;for(;tthis.pointRank);t++)(this.activeTo[t]>e||this.activeTo[t]==e&&this.active[t].endSide>this.point.endSide)&&i.push(this.active[t]);return i}openEnd(t){let e=0;for(;et;)e++;return e}}function Et(t,e,i,n,r,s){t.goto(e),i.goto(n);var o=n+r;let a=n,h=n-e;for(;;){var l=t.to+h-i.to||t.endSide-i.endSide,c=l<0?t.to+h:i.to,u=Math.min(c,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))||s.comparePoint(a,u,t.point,i.point):u>a&&!function(e,i){if(e.length!=i.length)return!1;for(let t=0;t=i;t--)e[t+1]=e[t];e[i]=t}function Ht(e,i){let n=-1,r=1e9;for(let t=0;t",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},Vt="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),zt="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),It="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),$t="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Wt="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ft=Vt&&($t||+Vt[1]<57)||It&&$t,qt=0;qt<10;qt++)Nt[48+qt]=Nt[96+qt]=String(qt);for(qt=1;qt<=24;qt++)Nt[qt+111]="F"+qt;for(var jt,qt=65;qt<=90;qt++)Nt[qt]=String.fromCharCode(qt+32),_t[qt]=String.fromCharCode(qt);for(jt in Nt)_t.hasOwnProperty(jt)||(_t[jt]=Nt[jt]);var Jt,Kt,Gt,[Ut,Xt]="undefined"!=typeof navigator?[navigator,document]:[{userAgent:"",vendor:"",platform:""},{documentElement:{style:{}}}],Yt=/Edge\/(\d+)/.exec(Ut.userAgent),Qt=/MSIE \d/.test(Ut.userAgent),Zt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ut.userAgent),te=!!(Qt||Zt||Yt),ee=!te&&/gecko\/(\d+)/i.test(Ut.userAgent),ie=!te&&/Chrome\/(\d+)/.exec(Ut.userAgent),ne="webkitFontSmoothing"in Xt.documentElement.style,re=!te&&/Apple Computer/.test(Ut.vendor),se={mac:/Mac/.test(Ut.platform),ie:te,ie_version:Qt?Xt.documentMode||6:Zt?+Zt[1]:Yt?+Yt[1]:0,gecko:ee,gecko_version:ee?+(/Firefox\/(\d+)/.exec(Ut.userAgent)||[0,0])[1]:0,chrome:!!ie,chrome_version:ie?+ie[1]:0,ios:re&&(/Mobile\/\w+/.test(Ut.userAgent)||2this.pos||t==this.pos&&(0t.width)||a),o?pe(a,o<0):a}class Le extends Ce{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i}static create(t,e,i){return new(t.customView||Le)(t,e,i)}slice(t){return Le.create(this.widget,this.length-t,this.side)}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,r){return!(i&&(!(i instanceof Le&&this.widget.compare(i.widget))||0i&&st?i[r]=Math.max(i[r],e):i.push(t,e)}We.prototype.point=!0;class je extends ke{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,r,s){if(i){if(!(i instanceof je))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Ee(this,t,e,i?i.children:Je,r,s),!0}split(t){let e=new je;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].slice(n),0),this.children[i].merge(n,this.children[i].length,null,0,0),i++);for(let t=i;t!t.length||t[0]});class si{constructor(t,e){this.field=t,this.get=e}}class oi{from(t){return new si(this,t)}static define(){return new oi}}oi.decorations=oi.define(),oi.scrollMargins=oi.define();let ai=0;const hi=H.define();class li{constructor(t,e,i){this.id=t,this.create=e,this.fields=i,this.extension=hi.of(this)}static define(t,e){let{eventHandlers:i,provide:n,decorations:r}=e||{},s=[];if(n)for(var o of Array.isArray(n)?n:[n])s.push(o);return i&&s.push(ci.from(t=>({plugin:t,handlers:i}))),r&&s.push(oi.decorations.from(r)),new li(ai++,t,s)}static fromClass(e,t){return li.define(t=>new e(t),t)}}const ci=oi.define();class ui{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}takeField(t,e){for(var{field:i,get:n}of this.spec.fields)i==t&&e.push(n(this.value))}update(e){if(this.value){if(this.mustUpdate){var i=this.mustUpdate;if(this.mustUpdate=null,!this.value.update)return this;try{this.value.update(i)}catch(t){if(ni(i.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}return ui.dummy}}}else try{this.value=this.spec.create(e)}catch(t){return ni(e.state,t,"CodeMirror plugin crashed"),ui.dummy}return this}destroy(e){var t;if(null!==(t=this.value)&&void 0!==t&&t.destroy)try{this.value.destroy()}catch(t){ni(e.state,t,"CodeMirror plugin crashed")}}}ui.dummy=new ui(li.define(()=>({})));const di=H.define({combine:t=>t.reduce((t,e)=>He(e,t),{})}),fi=H.define({combine:t=>t.reduce((t,e)=>He(e,t),{})}),pi=H.define(),gi=H.define();class mi{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new mi(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;0i.toA)){if(n.toAr.push(new mi(t,e,i,n))),this.changedRanges=r;i=t.hasFocus;i!=t.inputState.notifiedFocused&&(t.inputState.notifiedFocused=i,this.flags|=1),this.docChanged&&(this.flags|=2)}get viewportChanged(){return 0<(4&this.flags)}get heightChanged(){return 0<(2&this.flags)}get geometryChanged(){return this.docChanged||0<(18&this.flags)}get focusChanged(){return 0<(1&this.flags)}get docChanged(){return this.transactions.some(t=>t.docChanged)}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class wi extends ke{constructor(t){super(),this.view=t,this.compositionDeco=ze.none,this.decorations=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.setDOM(t.contentDOM),this.children=[new je],this.children[0].setParent(this),this.updateInner([new mi(0,0,0,t.state.doc.length)],this.updateDeco(),0)}get root(){return this.view.root}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(t){let e=t.changedRanges;0ethis.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=0),this.view.inputState.composing<0?this.compositionDeco=ze.none:t.transactions.length&&(this.compositionDeco=function(t,e){var i=oe(t.root),i=i.focusNode&&xi(i.focusNode,i.focusOffset,0);if(!i)return ze.none;let n=t.docView.nearest(i),r,s,o=i;if(n instanceof Ce){for(;n.parent instanceof Ce;)n=n.parent;r=n.posAtStart,s=r+n.length,o=n.dom}else{if(!(n instanceof je))return ze.none;{for(;o.parentNode!=n.dom;)o=o.parentNode;let t=o.previousSibling;for(;t&&!ke.get(t);)t=t.previousSibling;r=s=t?ke.get(t).posAtEnd:n.posAtStart}}let a=e.mapPos(r,1),h=Math.max(a,e.mapPos(s,-1)),l=i.nodeValue,{state:c}=t;if(h-a"pointerselection"==t.annotation(st.userEvent));return 0==this.dirty&&0==e.length&&!(12&t.flags)&&t.state.selection.main.from>=this.view.viewport.from&&t.state.selection.main.to<=this.view.viewport.to?(this.updateSelection(s,o),!1):(this.updateInner(e,a,t.startState.doc.length,s,o),!0)}updateInner(t,e,i,n=!1,r=!1){this.updateChildren(t,e,i),this.view.observer.ignore(()=>{this.dom.style.height=this.view.viewState.domHeight+"px",this.dom.style.minWidth=this.minWidth?this.minWidth+"px":"";var t=se.chrome?{node:oe(this.view.root).focusNode,written:!1}:void 0;this.sync(t),this.dirty=0,null!=t&&t.written&&(n=!0),this.updateSelection(n,r),this.dom.style.height=""})}updateChildren(e,i,t){let n=this.childCursor(t);for(let t=e.length-1;;t--){var r=0<=t?e[t]:null;if(!r)break;var{fromA:s,toA:o,fromB:a,toB:h}=r,{content:l,breakAtStart:c,openStart:u,openEnd:r}=Ge.build(this.view.state.doc,a,h,i),{i:a,off:h}=n.findPos(o,1),{i:o,off:s}=n.findPos(s,-1);this.replaceRange(o,s,a,h,l,c,u,r)}}replaceRange(e,i,n,r,s,o,a,h){let l=this.children[e],c=s.length?s[s.length-1]:null;var u=c?c.breakAfter:o;if(e!=n||o||u||!(s.length<2)||!l.merge(i,r,s.length?c:null,0==i,a,h)){let t=this.children[n];for(rn.node.insertBefore(t,n.node.childNodes[n.offset]||null)),n=r=new be(t,0),e=!0}let s=oe(this.root);!(e||!s.focusNode||se.gecko&&i.empty&&ki(s.focusNode,s.focusOffset))&&le(n.node,n.offset,s.anchorNode,s.anchorOffset)&&le(r.node,r.offset,s.focusNode,s.focusOffset)||this.view.observer.ignore(()=>{var t,e;if(i.empty)se.gecko&&(!(t=ki(n.node,n.offset))||3==t||(e=xi(n.node,n.offset,1==t?1:-1))&&(n=new be(e,1==t?0:e.nodeValue.length))),s.collapse(n.node,n.offset),null!=i.bidiLevel&&null!=s.cursorBidiLevel&&(s.cursorBidiLevel=i.bidiLevel);else if(s.extend)s.collapse(n.node,n.offset),s.extend(r.node,r.offset);else{let t=document.createRange();i.anchor>i.head&&([n,r]=[r,n]),t.setEnd(r.node,r.offset),t.setStart(n.node,n.offset),s.removeAllRanges(),s.addRange(t)}}),this.impreciseAnchor=n.precise?null:new be(s.anchorNode,s.anchorOffset),this.impreciseHead=r.precise?null:new be(s.focusNode,s.focusOffset)}}enforceCursorAssoc(){var t,e,i=this.view.state.selection.main;let n=oe(this.root);i.empty&&i.assoc&&n.modify&&((e=je.find(this,i.head))&&(t=e.posAtStart,i.head!=t&&i.head!=t+e.length&&(t=this.coordsAt(i.head,-1),e=this.coordsAt(i.head,1),!t||!e||t.bottom>e.top||(e=this.domAtPos(i.head+i.assoc),n.collapse(e.node,e.offset),n.modify("move",i.assoc<0?"forward":"backward","lineboundary")))))}mayControlSelection(){return this.view.state.facet(ri)?this.root.activeElement==this.dom:ae(this.dom,oe(this.root))}nearest(e){for(let t=e;t;){var i=ke.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e=s&&(r.push(t.dom.getBoundingClientRect().height),(h=t.dom.scrollWidth)>a&&(this.minWidth=a=h,this.minWidthFrom=i,this.minWidthTo=e)),i=e+t.breakAfter}return r}measureTextSize(){for(var t of this.children)if(t instanceof je){t=t.measureTextSize();if(t)return t}let e=document.createElement("div"),i,n;return e.className="cm-line",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);var t=he(e.firstChild)[0];i=e.getBoundingClientRect().height,n=t?t.width/27:7,e.remove()}),{lineHeight:i,charWidth:n}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new Ae(this.children,t,e)}computeBlockGapDeco(){let i=[],n=this.view.viewState;for(let t=0,e=0;;e++){var r,s=e==n.viewports.length?null:n.viewports[e],o=s?s.from-1:this.length;if(o>t&&(r=n.lineAt(o,0).bottom-n.lineAt(t,0).top,i.push(ze.replace({widget:new yi(r),block:!0,inclusive:!0}).range(t,o))),!s)break;t=s.to+1}return ze.set(i)}updateDeco(){return this.decorations=[this.computeBlockGapDeco(),this.view.viewState.lineGapDeco,this.compositionDeco,...this.view.state.facet(pi),...this.view.pluginField(oi.decorations)]}scrollPosIntoView(t,r){var s,o,a,r=this.coordsAt(t,r);if(r){let t=0,e=0,i=0,n=0;for(var h of this.view.pluginField(oi.scrollMargins))h&&({left:s,right:o,top:a,bottom:h}=h,null!=s&&(t=Math.max(t,s)),null!=o&&(e=Math.max(e,o)),null!=a&&(i=Math.max(i,a)),null!=h&&(n=Math.max(n,h)));!function(t,s){let e=t.ownerDocument,o=e.defaultView;for(let r=t.parentNode;r;)if(1==r.nodeType){let t,e=r==document.body;if(e)t={left:0,right:(h=o).innerWidth,top:0,bottom:h.innerHeight};else{if(r.scrollHeight<=r.clientHeight&&r.scrollWidth<=r.clientWidth){r=r.parentNode;continue}h=r.getBoundingClientRect();t={left:h.left,right:h.left+r.clientWidth,top:h.top,bottom:h.top+r.clientHeight}}let i=0,n=0;var a;if(s.topt.bottom&&(n=s.bottom-t.bottom+5),s.leftt.right&&(i=s.right-t.right+5),(i||n)&&(e?o.scrollBy(i,n):(n&&(a=r.scrollTop,r.scrollTop+=n,n=r.scrollTop-a),i&&(a=r.scrollLeft,r.scrollLeft+=i,i=r.scrollLeft-a),s={left:s.left-i,top:s.top-n,right:s.right-i,bottom:s.bottom-n})),e)break;r=r.parentNode}else{if(11!=r.nodeType)break;r=r.host}var h}(this.dom,{left:r.left-t,top:r.top-i,right:r.right+e,bottom:r.bottom+n})}}}class yi extends Ve{constructor(t){super(),this.height=t}toDOM(){var t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}class bi extends Ve{constructor(t,e){super(),this.top=t,this.text=e}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return Be}}function xi(t,e,i){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&0=i){if(o.level==n)return t;(s<0||(0!=r?r<0?o.fromi:e[s].level>o.level))&&(s=t)}}if(s<0)throw new RangeError("Index out of range");return s}}const Bi=[];function Ei(r,t){var s,o=r.length,a=t==Ai?1:2;if(!r||1==a&&!Oi.test(r))return Pi(o);for(let e=0,i=a,n=a;ec;){for(var d=t,f=2!=Bi[--t];t>c&&f==(2!=Bi[t-1]);)t--;i.push(new Li(t,d,f?2:1))}else i.push(new Li(c,e,0))}else for(let t=0;te.top+1}function Ni(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Vi(t,n,r){let s,o,a,h,l,c,u,d;for(let i=t.firstChild;i;i=i.nextSibling){var f=he(i);for(let e=0;em?g.left-m:Math.max(0,m-g.right)),g=(m=r,(g=t).top>m?g.top-m:Math.max(0,m-g.bottom));if(0==p&&0==g)return(3==i.nodeType?zi:Vi)(i,n,r);(!s||h>g||h==g&&a>p)&&(s=i,o=t,a=p,h=g),0==p?r>t.bottom&&(!u||u.bottomt.top)&&(c=i,d=t):u&&Hi(u,t)?u=_i(u,t.bottom):d&&Hi(d,t)&&(d=Ni(d,t.top))}}var m,g;if(u&&u.bottom>=r?(s=l,o=u):d&&d.top<=r&&(s=c,o=d),!s)return{node:t,offset:0};var e=Math.max(o.left,Math.min(o.right,n));return 3==s.nodeType?zi(s,e,r):a||"true"!=s.contentEditable?{node:t,offset:Array.prototype.indexOf.call(t.childNodes,s)+(n>=(o.left+o.right)/2?1:0)}:Vi(s,e,r)}function zi(n,r,e){var t=n.nodeValue.length;let s=-1,o=1e9,a=0;for(let i=0;ie?l.top-e:e-l.bottom)-1;if(l.left-1<=r&&l.right+1>=r&&c=(l.left+l.right)/2,e=t;if((se.chrome||se.gecko)&&ye(n,i).getBoundingClientRect().left==l.right&&(e=!t),c<=0)return{node:n,offset:i+(e?1:0)};s=i+(e?1:0),o=c}}}}return{node:n,offset:-1i||s.bottomi?-1:1,i=Math.min(s.bottom-o,Math.max(s.top+o,i)),t)return-1;t=!0}if(s.type==Jt.Text)break;i=0e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:null;t=Math.max(r.left+1,Math.min(r.right-1,t));let l=e.root,c=l.elementFromPoint(t,i),u,d=-1;return!c||!e.contentDOM.contains(c)||e.docView.nearest(c)instanceof Le||(l.caretPositionFromPoint?(a=l.caretPositionFromPoint(t,i))&&({offsetNode:u,offset:d}=a):!l.caretRangeFromPoint||(a=l.caretRangeFromPoint(t,i))&&({startContainer:u,startOffset:d}=a,se.safari&&function(e,t,i){let n;if(3!=e.nodeType||t!=(n=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=e.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return ye(e,n-1,n).getBoundingClientRect().left>i}(u,d,t)&&(u=void 0))),u&&e.docView.dom.contains(u)||(h=je.find(e.docView,h),{node:u,offset:d}=Vi(h.dom,t,i)),e.docView.posFromDOM(u,d)}function $i(r,t,s,o){let a=r.state.doc.lineAt(t.head),h=r.bidiSpans(a);for(let i=t,n=null;;){let t=function(t,e,i,n,r){let s=n.head-t.from,o=-1;if(0==s){if(!r||!t.length)return null;e[0].level!=i&&(s=e[0].side(!1,i),o=0)}else if(s==t.length){if(r)return null;let t=e[e.length-1];t.level!=i&&(s=t.side(!0,i),o=e.length-1)}o<0&&(o=Li.find(e,s,null!==(h=n.bidiLevel)&&void 0!==h?h:-1,n.assoc));let a=e[o];s==a.side(r,i)&&(a=e[o+=r?1:-1],s=a.side(!r,i));var h=r==(a.dir==i),n=S(t.text,s,h);if(Ri=t.text.slice(Math.min(s,n),Math.max(s,n)),n!=a.side(r,i))return E.cursor(n+t.from,h?-1:1,a.level);let l=o==(r?e.length-1:0)?null:e[o+(r?1:-1)];return l||a.level==i?l&&l.level>1;for(let t=s<0?o.top:o.bottom,e=0;e<50;e+=10){var u=Ii(i,{x:l,y:t+(c+e)*s},s);if(null==u)break;if(u!=r)return E.cursor(u,void 0,void 0,h)}}let{doc:d}=i.state,f=d.lineAt(r),p=i.state.tabSize,g=t.goalColumn,m=0;if(null==g){for(const x=d.iterRange(f.from,r);!x.next().done;)m=A(x.value,m,p);g=m*i.defaultCharacterWidth}else m=Math.round(g/i.defaultCharacterWidth);if(s<0&&0==f.from)return E.cursor(0);if(0=m&&!k.next().done;){var{offset:y,leftOver:b}=function(e,i,n,r){for(let t=0;t{!Ji(n,t)||this.ignoreDuringComposition(t)||"keydown"==i&&this.screenKeyEvent(n,t)||(this.mustFlushObserver(t)&&n.observer.forceFlush(),this.runCustomHandlers(i,n,t)?t.preventDefault():e(n,t))}),this.registeredEvents.push(i)}n.contentDOM.addEventListener("keydown",t=>{n.inputState.lastKeyCode=t.keyCode,n.inputState.lastKeyTime=Date.now()}),this.notifiedFocused=n.hasFocus,this.ensureHandlers(n)}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(i){var t;for(t of this.customHandlers=i.pluginField(ci))for(let e in t.handlers)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),i.contentDOM.addEventListener(e,t=>{Ji(i,t)&&this.runCustomHandlers(e,i,t)&&t.preventDefault()}))}runCustomHandlers(i,n,r){for(var s of this.customHandlers){let t=s.handlers[i],e=!1;if(t){try{e=t.call(s.plugin,r,n)}catch(t){ni(n.state,t)}if(e||r.defaultPrevented)return se.android&&"keydown"==i&&13==r.keyCode&&n.observer.flushSoon(),!0}}return!1}runScrollHandlers(e,i){for(var n of this.customHandlers){let t=n.handlers.scroll;if(t)try{t.call(n.plugin,i,e)}catch(t){ni(e.state,t)}}}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(0=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}(e,i)&&null,!1===this.dragging&&(i.preventDefault(),this.select(i))}move(t){if(0==t.buttons)return this.destroy();!1===this.dragging&&this.select(t)}up(t){null==this.dragging&&this.select(this.startEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.inputState.mouseSelection=null}select(t){let e=this.style.get(t,this.extend,this.multiple);e.eq(this.view.state.selection)&&e.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:e,annotations:st.userEvent.of("pointerselection"),scrollIntoView:!0})}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)}}function Ji(i,n){if(!n.bubbles)return 1;if(!n.defaultPrevented){for(let t=n.target,e;t!=i.contentDOM;t=t.parentNode)if(!t||11==t.nodeType||(e=ke.get(t))&&e.ignoreEvent(n))return;return 1}}const Ki=Object.create(null),Gi=se.ie&&se.ie_version<15||se.ios&&se.webkit_version<604;function Ui(t,r){let{state:s}=t,e,o=1,a=s.toText(r),h=a.lines==s.selection.ranges.length;if(sn&&s.selection.ranges.every(t=>t.empty)&&sn==a.toString()){let n=-1;e=s.changeByRange(t=>{var e=s.doc.lineAt(t.from);if(e.from==n)return{range:t};n=e.from;var i=s.toText((h?a.line(o++).text:r)+s.lineBreak);return{changes:{from:e.from,insert:i},range:E.cursor(t.from+i.length)}})}else e=h?s.changeByRange(t=>{var e=a.line(o++);return{changes:{from:t.from,to:t.to,insert:e.text},range:E.cursor(t.from+e.length)}}):s.replaceSelection(a);t.dispatch(e,{annotations:st.userEvent.of("paste"),scrollIntoView:!0})}Ki.keydown=(t,e)=>{var i,n,r;n=((i=e).ctrlKey?1:0)|(i.metaKey?8:0)|(i.altKey?2:0)|(i.shiftKey?4:0),r=i.keyCode,i=se.mac&&1==n,(8==r||i&&72==r||46==r||i&&68==r||27==r||n==(se.mac?8:1)&&(66==r||73==r||89==r||90==r))&&e.preventDefault(),t.inputState.setSelectionOrigin("keyboardselection")};let Xi=0;function Yi(i,n,r,t){if(1==t)return E.cursor(n,r);if(2==t)return function(t,e,i=1){let n=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(0==r.length)return E.cursor(e);0==s?i=1:s==r.length&&(i=-1);let o=s,a=s;i<0?o=S(r.text,s,!1):a=S(r.text,s);for(var h=n(r.text.slice(o,a));0{1==(e=e).touches.length&&e.touches[0].radiusX<=1&&e.touches[0].radiusY<=1||(Xi=Date.now()),t.inputState.setSelectionOrigin("pointerselection")},Ki.touchmove=t=>{t.inputState.setSelectionOrigin("pointerselection")},Ki.mousedown=(e,i)=>{if(e.observer.flush(),!(Xi>Date.now()-2e3)){let t=null;for(var n of e.state.facet(Ze))if(t=n(e,i),t)break;t||0!=i.button||(t=function(o,t){let a=tn(o,t),h=function(t){if(!en)return t.detail;var e=nn;return nn=t,rn=!e||e.timeStamp>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(rn+1)%3:1}(t),l=o.state.selection,c=a,u=t;return{update(t){t.changes&&(a&&(a.pos=t.changes.mapPos(a.pos)),l=l.map(t.changes))},get(t,e,i){let n;if(t.clientX==u.clientX&&t.clientY==u.clientY?n=c:(n=c=tn(o,t),u=t),!n||!a)return l;let r=Yi(o,n.pos,n.bias,h);var s;return a.pos==n.pos||e||(s=Yi(o,a.pos,a.bias,h),t=Math.min(s.from,r.from),s=Math.max(s.to,r.to),r=tve(e.contentDOM)),e.inputState.startMouseSelection(e,i,t))}};let Qi=(t,e)=>t>=e.top&&t<=e.bottom,Zi=(t,e,i)=>Qi(e,i)&&t>=i.left&&t<=i.right;function tn(t,e){var i=t.posAtCoords({x:e.clientX,y:e.clientY});return null==i?null:{pos:i,bias:function(t,e,i,n){let r=je.find(t.docView,e);return r&&0!=(t=e-r.posAtStart)&&(t==r.length||(e=r.coordsAt(t,-1))&&Zi(i,n,e)||(!(t=r.coordsAt(t,1))||!Zi(i,n,t))&&e&&Qi(n,e))?-1:1}(t,i,e.clientX,e.clientY)}}const en=se.ie&&se.ie_version<=11;let nn=null,rn=0;Ki.dragstart=(t,e)=>{var{selection:{main:i}}=t.state;let{mouseSelection:n}=t.inputState;n&&(n.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},Ki.drop=(e,i)=>{if(i.dataTransfer){var n=e.posAtCoords({x:i.clientX,y:i.clientY}),r=i.dataTransfer.getData("Text");if(null!=n&&r){i.preventDefault();var{mouseSelection:i}=e.inputState,i=i&&i.dragging&&i.dragMove?{from:i.dragging.from,to:i.dragging.to}:null,r={from:n,insert:r};let t=e.state.changes(i?[i,r]:r);e.focus(),e.dispatch({changes:t,selection:{anchor:t.mapPos(n,-1),head:t.mapPos(n,1)},annotations:st.userEvent.of("drop")})}}},Ki.paste=(t,e)=>{t.observer.flush();let i=Gi?null:e.clipboardData;var n=i&&i.getData("text/plain");n?(Ui(t,n),e.preventDefault()):function(e){let i=e.dom.parentNode;if(i){let t=i.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{e.focus(),t.remove(),Ui(e,t.value)},50)}}(t)};let sn=null;function on(t){t.docView.compositionDeco.size&&t.update([])}Ki.copy=Ki.cut=(e,i)=>{var{text:n,ranges:r,linewise:s}=function(e){let i=[],n=[],r=!1;for(var t of e.selection.ranges)t.empty||(i.push(e.sliceDoc(t.from,t.to)),n.push(t));if(!i.length){let t=-1;for(var{from:s}of e.selection.ranges){s=e.doc.lineAt(s);s.number>t&&(i.push(s.text),n.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),t=s.number}r=!0}return{text:i.join(e.lineBreak),ranges:n,linewise:r}}(e.state);if(n){sn=s?n:null;let t=Gi?null:i.clipboardData;t?(i.preventDefault(),t.clearData(),t.setData("text/plain",n)):function(e,i){let n=e.dom.parentNode;if(n){let t=n.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.value=i,t.focus(),t.selectionEnd=i.length,t.selectionStart=0,setTimeout(()=>{t.remove(),e.focus()},50)}}(e,n),"cut"==i.type&&e.dispatch({changes:r,scrollIntoView:!0,annotations:st.userEvent.of("cut")})}},Ki.focus=Ki.blur=t=>{setTimeout(()=>{t.hasFocus!=t.inputState.notifiedFocused&&t.update([])},10)},Ki.beforeprint=t=>{t.viewState.printing=!0,t.requestMeasure(),setTimeout(()=>{t.viewState.printing=!1,t.requestMeasure()},2e3)},Ki.compositionstart=Ki.compositionupdate=t=>{t.inputState.composing<0&&(t.docView.compositionDeco.size&&(t.observer.flush(),on(t)),t.inputState.composing=0)},Ki.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),setTimeout(()=>{t.inputState.composing<0&&on(t)},50)};const an=["pre-wrap","normal","pre-line"];class hn{constructor(){this.doc=d.empty,this.lineWrapping=!1,this.direction=Kt.LTR,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength)),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefresh(e,t,i){let n=!1;for(let t=0;t=e?r:c.lineAt(e,Gt.ByPosNoHeight,a,0,0);for(n+=u.to-e,e=u.to;02*r){var o=t[e-1];o.break?t.splice(--e,1,o.left,null,o.right):t.splice(--e,1,o.left,o.right),i+=1+o.break,n-=o.size}else{if(!(r>2*n))break;o=t[i];o.break?t.splice(i,1,o.left,null,o.right):t.splice(i,1,o.left,o.right),i+=2+o.break,r-=o.size}else nt&&e.push(new pn(r.from-t-1).updateHeight(n,t));i<=s&&r.more;){var o=n.doc.lineAt(i).length;e.length&&e.push(null);let t=new fn(o,r.heights[r.index++]);t.outdated=!1,e.push(t),i+=o+1}return i<=s&&e.push(null,new pn(s-i).updateHeight(n,i)),n.heightChanged=!0,un.of(e)}return(e||this.outdated)&&(this.setHeight(n,n.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class gn extends un{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){var r=i+this.left.height;return to))return h;e=e==Gt.ByPosNoHeight?Gt.ByPosNoHeight:Gt.ByPos;return a?h.join(this.right.lineAt(o,e,i,s,o)):this.left.lineAt(o,e,i,n,r).join(h)}forEachLine(t,e,i,n,r,s){var o,a=n+this.left.height,h=r+this.left.length+this.break;this.break?(t=t&&o.from<=e&&s(o),e>o.to&&this.right.forEachLine(o.to+1,e,i,a,h,s))}replace(t,e,i){var n=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let r=[];0=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){var i=this.left.length,n=i+this.break;if(n<=t)return this.right.decomposeRight(t-n,e);t2*e.size||e.size>2*t.size?un.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:r,right:s}=this,o=e+r.length+this.break,a=null;return n&&n.from<=e+r.length&&n.more?a=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=o+s.length&&n.more?a=s=s.updateHeight(t,o,i,n):s.updateHeight(t,o,i),a?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function mn(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof pn&&(n=t[e+1])instanceof pn&&t.splice(e-1,3,new pn(i.length+1+n.length))}class vn{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,i){if(-1this.pos||!this.isCovered)&&this.nodes.push(new fn(t-this.pos,-1)),(this.writtenTo=t)t&&this.nodes.push(new fn(this.pos-t,-1)),this.writtenTo=this.pos)}blankContent(t,e){let i=new pn(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();var t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof fn)return t;t=new fn(0,-1);return this.nodes.push(t),t}addBlock(t){this.enterLine(),t.type!=Jt.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=Jt.WidgetBefore&&(this.covering=t)}addLineDeco(t,e){let i=this.ensureLine();i.length+=e,i.collapsed+=e,i.widgetHeight=Math.max(i.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}finish(t){var e,i=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(-1t.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let t=0;t<=1;t++){let i=t?n.head:n.anchor;var r,s;e.some(({from:t,to:e})=>i>=t&&i<=e)||({from:r,to:s}=this.lineAt(i,0),e.push(new kn(r,s)))}this.viewports=e.sort((t,e)=>t.from-e.from),this.scaler=this.heightMap.height<=7e6?Cn:new Tn(this.heightOracle.doc,this.heightMap,this.viewports)}update(t,e=null){var i=this.state;this.state=t.state;var n,r,s,o=this.state.facet(pi),a=t.changedRanges,s=mi.extendWithRanges(a,(n=t.startState.facet(pi),r=o,s=t?t.changes:M.empty(this.state.doc.length),a=new wn,Ct.compare(n,r,s,a,0),a.changes)),a=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(o,i.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=a&&(t.flags|=2);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.headh.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e)),h.eq(this.viewport)||(this.viewport=h,t.flags|=4),this.updateForViewport(),(this.lineGaps.length||15e3t.clientHeight||t.scrollWidth>t.clientWidth)&&"visible"!=window.getComputedStyle(t).overflow&&(i=t.getBoundingClientRect(),r=Math.max(r,i.left),s=Math.min(s,i.right),o=Math.max(o,i.top),a=Math.min(a,i.bottom)),t=t.parentNode;else{if(11!=t.nodeType)break;t=t.host}return{left:r-n.left,right:s-n.left,top:o-(n.top+t),bottom:a-(n.top+t)}}(i,this.paddingTop),o=s.top-this.pixelViewport.top,a=s.bottom-this.pixelViewport.bottom;if(this.pixelViewport=s,this.inView=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left,!this.inView)return 0;var h,l=t.measureVisibleLineHeights();let c=!1,u=0,d=0,f=this.heightOracle;return e||(h=t.dom.clientWidth,(f.mustRefresh(l,n,r)||f.lineWrapping&&Math.abs(h-this.contentWidth)>f.charWidth)&&({lineHeight:s,charWidth:e}=t.measureTextSize(),c=f.refresh(n,r,s,e,h/e,l),c&&(t.minWidth=0,d|=16)),this.contentWidth!=h&&(this.contentWidth=h,d|=16),0this.viewport.to))&&((l=this.getViewport(u,this.scrollTo)).from==this.viewport.from&&l.to==this.viewport.to||(this.viewport=l,d|=4)),this.updateForViewport(),(this.lineGaps.length||15e3o.to&&({bottom:e}=i.lineAt(e.head,Gt.ByPos,n,0,0),o=new kn(i.lineAt(e-(s-r)-500,Gt.ByHeight,n,0,0).from,i.lineAt(e+500,Gt.ByHeight,n,0,0).to))),o}mapViewport(t,e){var i=e.mapPos(t.from,-1),t=e.mapPos(t.to,1);return new kn(this.heightMap.lineAt(i,Gt.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(t,Gt.ByPos,this.state.doc,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){var{top:n}=this.heightMap.lineAt(t,Gt.ByPos,this.state.doc,0,0),{bottom:r}=this.heightMap.lineAt(e,Gt.ByPos,this.state.doc,0,0),{visibleTop:s,visibleBottom:o}=this;return(0==t||n<=s-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&s-2e3{if(!(r.length<1e4)){var s=function(t,e,i){let n=[],r=t,s=0;Ct.spans(i.facet(pi),t,e,{span(){},point(t,e){t>r&&(n.push({from:r,to:t}),s+=t-r),r=e}},20),r=r.from&&(t=o.from),o.from<=r.to&&o.to>=e&&(e=o.to);let i=t-1e4,n=e+1e4;i>r.from+5e3&&h.push(Mn(a,t=>t.from==r.from&&t.to>i-5e3&&t.to<5e3+i)||new yn(r.from,i,this.gapSize(r,i,!0,s))),nt.to==r.to&&t.from>n-5e3&&t.fromt.draw(this.heightOracle.lineWrapping))),8)}computeVisibleRanges(){let t=this.state.facet(pi);this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];Ct.spans(t,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20),this.visibleRanges=i}lineAt(t,e){return e+=this.paddingTop,Dn(this.heightMap.lineAt(t,Gt.ByPos,this.state.doc,e,0),this.scaler,e)}lineAtHeight(t,e){return e+=this.paddingTop,Dn(this.heightMap.lineAt(this.scaler.fromDOM(t,e),Gt.ByHeight,this.state.doc,e,0),this.scaler,e)}blockAtHeight(t,e){return e+=this.paddingTop,Dn(this.heightMap.blockAt(this.scaler.fromDOM(t,e),this.state.doc,e,0),this.scaler,e)}forEachLine(t,e,i,n){return n+=this.paddingTop,this.heightMap.forEachLine(t,e,this.state.doc,n,0,1==this.scaler.scale?i:t=>i(Dn(t,this.scaler,n)))}get contentHeight(){return this.domHeight+this.paddingTop+this.paddingBottom}get domHeight(){return this.scaler.toDOM(this.heightMap.height,this.paddingTop)}}class kn{constructor(t,e){this.from=t,this.to=e}eq(t){return this.from==t.from&&this.to==t.to}}function Sn({total:t,ranges:e},i){if(i<=0)return e[0].from;if(1<=i)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){var{from:r,to:s}=e[t],s=s-r;if(n<=s)return r+n;n-=s}}function An(t,e){let i=0;for(var{from:n,to:r}of t.ranges){if(e<=r){i+=e-n;break}i+=r-n}return i/t.total}function Mn(t,e){for(var i of t)if(e(i))return i}const Cn={toDOM(t){return t},fromDOM(t){return t},scale:1};class Tn{constructor(r,s,t){let o=0,e=0,i=0;this.viewports=t.map(({from:t,to:e})=>{var i=s.lineAt(t,Gt.ByPos,r,0,0).top,n=s.lineAt(e,Gt.ByPos,r,0,0).bottom;return o+=n-i,{from:t,to:e,top:i,bottom:n,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(s.height-o);for(var n of this.viewports)n.domTop=i+(n.top-e)*this.scale,i=n.domBottom=n.domTop+(n.bottom-n.top),e=n.bottom}toDOM(n,r){n-=r;for(let t=0,e=0,i=0;;t++){var s=tDn(t,e,i)):t.type)}const On=H.define({combine:t=>t.join(" ")}),Ln=H.define({combine:t=>-1{if("&"==t)return e;if(!i||!i[t])throw new RangeError(`Unsupported selector: ${t}`);return i[t]}):e+" "+t}})}const Nn=Hn("."+Bn,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline_fallback:"1px dotted #212121",outline:"5px auto -webkit-focus-ring-color"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,minHeight:"100%",display:"block",whiteSpace:"pre",boxSizing:"border-box",padding:"4px 0",outline:"none"},".cm-lineWrapping":{whiteSpace:"pre-wrap",overflowWrap:"anywhere"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none",display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-placeholder":{color:"#888",display:"inline-block"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"3px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Rn),_n={childList:!0,characterData:!0,subtree:!0,characterDataOldValue:!0},Vn=se.ie&&se.ie_version<=11;class zn{constructor(i,t,e){this.view=i,this.onChange=t,this.onScrollChanged=e,this.active=!1,this.ignoreSelection=new ge,this.delayedFlush=-1,this.queue=[],this.scrollTargets=[],this.intersection=null,this.intersecting=!1,this.parentCheck=-1,this.dom=i.contentDOM,this.observer=new MutationObserver(t=>{for(var e of t)this.queue.push(e);(se.ie&&se.ie_version<=11||se.ios&&i.composing)&&t.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),Vn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.start(),this.onScroll=this.onScroll.bind(this),window.addEventListener("scroll",this.onScroll),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),0{this.delayedFlush=-1,this.flush()},20))}forceFlush(){0<=this.delayedFlush&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}flush(){if(!(0<=this.delayedFlush)){let n=this.queue;for(var t of this.observer.takeRecords())n.push(t);n.length&&(this.queue=[]);var r=oe(this.view.root),s=!this.ignoreSelection.eq(r)&&ae(this.dom,r);if(0!=n.length||s){let t=-1,e=-1,i=!1;for(var o of n){o=this.readMutation(o);o&&(o.typeOver&&(i=!0),-1==t?{from:t,to:e}=o:(t=Math.min(o.from,t),e=Math.max(o.to,e)))}r=this.view.state;(-1this.view.docView.sync()),this.view.docView.dirty=0),this.view.docView.updateSelection()),this.clearSelection()}}}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty(),"childList"!=t.type)return{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue};var i=In(e,t.previousSibling||t.target.previousSibling,-1),t=In(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:t?e.posBefore(t):e.posAtEnd,typeOver:!1}}destroy(){this.stop(),this.intersection&&this.intersection.disconnect();for(var t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),clearTimeout(this.parentCheck)}}function In(t,e,i){for(;e;){var n=ke.get(e);if(n&&n.parent==t)return n;n=e.parentNode;e=n!=t.dom?n:0Date.now()-100||se.android&&t.text.length=o?s-i:0,s-=h,a=s+(a-o),o=s):a=a?s-i:0,s-=i,o=s+(o-a),a=s)}return{from:s,toA:o,toB:a}}(n.state.sliceDoc(l,c),t.text,e-l,i);u&&(s={from:l+u.from,to:l+u.toA,insert:n.state.toText(t.text.slice(u.from,u.toB))})}else!n.hasFocus&&n.state.facet(ri)||(c=oe(n.root),{impreciseHead:l,impreciseAnchor:u}=n.docView,l=l&&l.node==c.focusNode&&l.offset==c.focusOffset?n.state.selection.main.head:n.docView.posFromDOM(c.focusNode,c.focusOffset),c=u&&u.node==c.anchorNode&&u.offset==c.anchorOffset?n.state.selection.main.anchor:function(t){let e=t.isCollapsed;return e&&se.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e}(c)?l:n.docView.posFromDOM(c.anchorNode,c.anchorOffset),l==a.head&&c==a.anchor||(o=E.single(c,l)));if(s||o)if(!s&&r&&!a.empty&&o&&o.main.empty&&(s={from:a.from,to:a.to,insert:n.state.doc.slice(a.from,a.to)}),s){let i=n.state;if(!se.android||!(s.from==a.from&&s.to==a.to&&1==s.insert.length&&2==s.insert.lines&&jn(n,"Enter",10)||s.from==a.from-1&&s.to==a.to&&0==s.insert.length&&jn(n,"Backspace",8)||s.from==a.from&&s.to==a.to+1&&0==s.insert.length&&jn(n,"Delete",46))){let e=s.insert.toString();if(!n.state.facet(ii).some(t=>t(n,s.from,s.to,e))){0<=n.inputState.composing&&n.inputState.composing++;let t;var d;t=s.from>=a.from&&s.to<=a.to&&s.to-s.from>=(a.to-a.from)/3&&(!o||o.main.empty&&o.main.from==s.from+s.insert.length)?(r=a.froms.to?i.sliceDoc(s.to,a.to):"",i.replaceSelection(n.state.toText(r+s.insert.sliceString(0,void 0,n.state.lineBreak)+d))):{changes:d=i.changes(s),selection:o&&!i.selection.main.eq(o.main)&&o.main.to<=d.newLength?i.selection.replaceRange(o.main):void 0},n.dispatch(t,{scrollIntoView:!0,annotations:st.userEvent.of("input")})}}}else if(o&&!o.main.eq(a)){let t=!1,e;n.inputState.lastSelectionTime>Date.now()-50&&("keyboardselection"==n.inputState.lastSelectionOrigin?t=!0:e=st.userEvent.of(n.inputState.lastSelectionOrigin)),n.dispatch({selection:o,scrollIntoView:t,annotations:e})}}class Wn{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineBreak=e.state.lineBreak}readRange(e,i){if(e){var n=e.parentNode;for(let t=e;;){this.findPointBefore(n,t),this.readNode(t);var r=t.nextSibling;if(r==i)break;var s=ke.get(t),o=ke.get(r);((s?s.breakAfter:Fn(t))||(o?o.breakAfter:Fn(r))&&("BR"!=t.nodeName||t.cmIgnore))&&(this.text+=this.lineBreak),t=r}this.findPointBefore(n,i)}}readNode(i){if(!i.cmIgnore){var n=ke.get(i);let t=n&&n.overrideDOMText,e;null!=t?e=t.sliceString(0,void 0,this.lineBreak):3==i.nodeType?e=i.nodeValue:"BR"==i.nodeName?e=i.nextSibling?this.lineBreak:"":1==i.nodeType&&this.readRange(i.firstChild,null),null!=e&&(this.findPointIn(i,e.length),this.text+=e,se.chrome&&13==this.view.inputState.lastKeyCode&&!i.nextSibling&&/\n\n$/.test(this.text)&&(this.text=this.text.slice(0,-1)))}}findPointBefore(t,e){for(var i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointIn(t,e){for(var i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e))}}function Fn(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class qn{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}function jn(t,e,i){e={key:e,code:e,keyCode:i,which:i,cancelable:!0},i=new KeyboardEvent("keydown",e);t.contentDOM.dispatchEvent(i);e=new KeyboardEvent("keyup",e);return t.contentDOM.dispatchEvent(e),i.defaultPrevented||e.defaultPrevented}class Jn{constructor(t={}){this.plugins=[],this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this.root=t.root||document,this.viewState=new xn(t.state||pt.create()),this.plugins=this.state.facet(hi).map(t=>new ui(t).update(this)),this.observer=new zn(this,(t,e,i)=>{$n(this,t,e,i)},t=>{this.inputState.runScrollHandlers(this,t),this.measure()}),this.inputState=new Fi(this),this.docView=new wi(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,window.addEventListener("resize",()=>{-1==Un&&(Un=setTimeout(Xn,50))}),this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return 0t.scrollIntoView)?n.selection.main:null;this.viewState.update(i,s),this.bidiCache=Qn.update(this.bidiCache,i.changes),i.empty||this.updatePlugins(i),e=this.docView.update(i),this.state.facet(gi)!=this.styleModules&&this.mountStyles(),this.updateAttrs(),this.showAnnouncements(t)}finally{this.updateState=0}if((e||scrollTo||this.viewState.mustEnforceCursorAssoc)&&this.requestMeasure(),!i.empty)for(var o of this.state.facet(ei))o(i)}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");this.updateState=2;try{for(var e of this.plugins)e.destroy(this);this.viewState=new xn(t),this.plugins=t.facet(hi).map(t=>new ui(t).update(this)),this.docView=new wi(this),this.inputState.ensureHandlers(this),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}this.requestMeasure()}updatePlugins(i){let t=i.startState.facet(hi),n=i.state.facet(hi);if(t!=n){let e=[];for(var r of n){var s=t.indexOf(r);if(s<0)e.push(new ui(r));else{let t=this.plugins[s];t.mustUpdate=i,e.push(t)}}for(var o of this.plugins)o.mustUpdate!=i&&o.destroy(this);this.plugins=e,this.inputState.ensureHandlers(this)}else for(var e of this.plugins)e.mustUpdate=i;for(let t=0;t{try{return t.read(this)}catch(t){return ni(this.state,t),Yn}});let t=new vi(this,this.state);t.flags|=r,n?n.flags|=r:n=t,this.updateState=2,t.empty||this.updatePlugins(t),this.updateAttrs(),r&&this.docView.update(t);for(let t=0;tthis.measure())),e){if(null!=e.key)for(let t=0;tfunction(t,e,i){let n=t.state.charCategorizer(e),r=n(i);return t=>{t=n(t);return r==x.Space&&(r=t),r==t}}(this,e.head,t))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){var r=t.state.doc.lineAt(e.head),s=n&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(s){n=t.dom.getBoundingClientRect(),s=t.posAtCoords({x:i==(t.textDirection==Kt.LTR)?n.right-1:n.left+1,y:(s.top+s.bottom)/2});if(null!=s)return E.cursor(s,i?-1:1)}return e=je.find(t.docView,e.head),r=e?i?e.posAtEnd:e.posAtStart:i?r.to:r.from,E.cursor(r,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Wi(this,t,e,i)}scrollPosIntoView(t){this.viewState.scrollTo=E.cursor(t),this.requestMeasure()}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t){return this.readMeasured(),Ii(this,t)}coordsAtPos(t,e=1){this.readMeasured();var i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;var n=this.state.doc.lineAt(t),r=this.bidiSpans(n);return pe(i,r[Li.find(r,t-n.from,-1,e)].dir==Kt.LTR==0Kn)return Pi(t.length);var e,i=this.textDirection;for(e of this.bidiCache)if(e.from==t.from&&e.dir==i)return e.order;var n=Ei(t.text,this.textDirection);return this.bidiCache.push(new Qn(t.from,t.to,i,n)),n}get hasFocus(){return document.hasFocus()&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ve(this.contentDOM),this.docView.updateSelection()})}destroy(){for(var t of this.plugins)t.destroy(this);this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),-1({}),{eventHandlers:t})}static theme(t,e){var i=yt.newName();let n=[On.of(i),gi.of(Hn(`.${i}`,t))];return e&&e.dark&&n.push(Ln.of(!0)),n}static baseTheme(t){return W.fallback(gi.of(Hn("."+Bn,t,Rn)))}}Jn.styleModule=gi,Jn.inputHandler=ii,Jn.exceptionSink=ti,Jn.updateListener=ei,Jn.editable=ri,Jn.mouseSelectionStyle=Ze,Jn.dragMovesSelection=Qe,Jn.clickAddsSelectionRange=Ye,Jn.decorations=pi,Jn.contentAttributes=fi,Jn.editorAttributes=di,Jn.lineWrapping=Jn.contentAttributes.of({class:"cm-lineWrapping"}),Jn.announce=rt.define();const Kn=4096;function Gn(t,e){return null==t?e.getBoundingClientRect().top:t}let Un=-1;function Xn(){Un=-1;var i=document.querySelectorAll(".cm-content");for(let e=0;e{if(t){for(var e of t.commands)if(e(i))return!0;t.preventDefault&&(a=!0)}return!1},l=t[n],c;if(l){if(h(l[o+tr(r,e,!s)]))return!0;if(s&&(e.shiftKey||e.altKey||e.metaKey)&&(c=Nt[e.keyCode])&&c!=r){if(h(l[o+tr(c,e,!0)]))return!0}else if(s&&e.shiftKey&&h(l[o+tr(r,e,!0)]))return!0}return a}(function(t){let e=t.facet(er),i=ir.get(e);i||ir.set(e,i=function(t,a=Zn){let h=Object.create(null),n=Object.create(null),l=(t,e)=>{var i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},e=(n,t,e,i)=>{let r=h[n]||(h[n]=Object.create(null)),s=t.split(/ (?!$)/).map(t=>function(t,e){var i=t.split(/-(?!$)/);let n=i[i.length-1];"Space"==n&&(n=" ");let r,s,o,a;for(let t=0;t{let e=nr={view:t,prefix:i,scope:n};return setTimeout(()=>{nr==e&&(nr=null)},rr),!0}]})}t=s.join(" ");l(t,!1);let o=r[t]||(r[t]={preventDefault:!1,commands:[]});o.commands.push(e),i&&(o.preventDefault=!0)};for(var i of t){var r=i[a]||i.key;if(r)for(var s of i.scope?i.scope.split(" "):["editor"])e(s,r,i.run,i.preventDefault),i.shift&&e(s,"Shift-"+r,i.shift,i.preventDefault)}return h}(e.reduce((t,e)=>t.concat(e),[])));return i}(e.state),t,e,"editor")}});const er=H.define({enables:te}),ir=new WeakMap;let nr=null;const rr=4e3;const sr=!se.ios,or=H.define({combine(t){return gt(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});class ar{constructor(t,e,i,n,r){this.left=t,this.top=e,this.width=i,this.height=n,this.className=r}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",0<=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}}li.fromClass(class{constructor(t){this.view=t,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=t.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=t.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),t.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(or).cursorBlinkRate+"ms"}update(t){var e=t.startState.facet(or)!=t.state.facet(or);(e||t.selectionSet||t.geometryChanged||t.viewportChanged)&&this.view.requestMeasure(this.measureReq),t.transactions.some(t=>t.scrollIntoView)&&(this.cursorLayer.style.animationName="cm-blink"==this.cursorLayer.style.animationName?"cm-blink2":"cm-blink"),e&&this.setBlinkRate()}readPos(){let{state:t}=this.view,e=t.facet(or);var i,n=t.selection.ranges.map(t=>t.empty?[]:function(m,n){if(n.to<=m.viewport.from||n.from>=m.viewport.to)return[];let t=Math.max(n.from,m.viewport.from),e=Math.min(n.to,m.viewport.to),v=m.textDirection==Kt.LTR,i=m.contentDOM,r=i.getBoundingClientRect(),s=lr(m),o=window.getComputedStyle(i.firstChild),w=r.left+parseInt(o.paddingLeft),y=r.right-parseInt(o.paddingRight),a=m.visualLineAt(t),h=m.visualLineAt(e);m.lineWrapping&&(a=cr(m,t,a),h=cr(m,e,h));{if(a.from==h.from)return c(u(n.from,n.to,a));{let t=u(n.from,null,a),e=u(null,n.to,h),i=[];return a.toc&&l.fromt&&r(Math.max(p,t),null==i&&p<=c,Math.min(g,e),null==n&&u<=g,d.dir)}if(t=f.to+1,t>=e)break}return 0==h.length&&r(c,null==i,u,null==n,m.textDirection),{top:o,bottom:a,horizontal:h}}}(this.view,t)).reduce((t,e)=>t.concat(e));let r=[];for(i of t.selection.ranges){var s=i==t.selection.main;(i.empty?s&&!sr:!e.drawRangeCursor)||(s=function(t,e,i){e=t.coordsAtPos(e.head,e.assoc||1);if(!e)return null;t=lr(t);return new ar(e.left-t.left,e.top-t.top,-1,e.bottom-e.top,i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}(this.view,i,s))&&r.push(s)}return{rangePieces:n,cursors:r}}drawSel({rangePieces:t,cursors:e}){if(t.length!=this.rangePieces.length||t.some((t,e)=>!t.eq(this.rangePieces[e]))){this.selectionLayer.textContent="";for(var i of t)this.selectionLayer.appendChild(i.draw());this.rangePieces=t}if(e.length!=this.cursors.length||e.some((t,e)=>!t.eq(this.cursors[e]))){let i=this.cursorLayer.children;if(i.length!==e.length){this.cursorLayer.textContent="";for(const n of e)this.cursorLayer.appendChild(n.draw())}else e.forEach((t,e)=>t.adjust(i[e]));this.cursors=e}}destroy(){this.selectionLayer.remove(),this.cursorLayer.remove()}});const hr={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};function lr(t){var e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Kt.LTR?e.left:e.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function cr(t,e,i){e=E.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(e,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(e,!0,!0).from)}}sr&&(hr[".cm-line"].caretColor="transparent !important"),W.override(Jn.theme(hr));const ur=null!=/x/.unicode?"gu":"g",dr=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029\ufeff-]",ur);let fr=null;H.define({combine(t){let e=gt(t,{render:null,specialChars:dr,addSpecialChars:null});return(e.replaceTabs=(null==fr&&"undefined"!=typeof document&&document.body&&(t=document.body.style,fr=null!=(t.tabSize||t.MozTabSize)),!fr))&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,ur)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,ur)),e}});const pr=ze.line({attributes:{class:"cm-activeLine"}});li.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(var n of t.state.selection.ranges)n.empty&&((n=t.visualLineAt(n.head)).from>e&&(i.push(pr.range(n.from)),e=n.from));return ze.set(i)}},{decorations:t=>t.decorations});let gr=0;const mr=new WeakMap;class vr{constructor({deserialize:t}={}){this.id=gr++,this.deserialize=t||(()=>{throw new Error("This node type doesn't define a deserialize function")})}static string(){return new vr({deserialize:t=>t})}static number(){return new vr({deserialize:Number})}static flag(){return new vr({deserialize:()=>!0})}set(t,e){return t[this.id]=e,t}add(e){return"function"!=typeof e&&(e=yr.match(e)),t=>{t=e(t);return void 0===t?null:[this,t]}}}vr.closedBy=new vr({deserialize:t=>t.split(" ")}),vr.openedBy=new vr({deserialize:t=>t.split(" ")}),vr.group=new vr({deserialize:t=>t.split(" ")});const wr=Object.create(null);class yr{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){var e=t.props&&t.props.length?Object.create(null):wr,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new yr(t.name||"",e,t.id,i);if(t.props)for(var r of t.props)Array.isArray(r)||(r=r(n)),r&&r[0].set(e,r[1]);return n}prop(t){return this.props[t.id]}get isTop(){return 0<(1&this.flags)}get isSkipped(){return 0<(2&this.flags)}get isError(){return 0<(4&this.flags)}get isAnonymous(){return 0<(8&this.flags)}is(e){if("string"!=typeof e)return this.id==e;{if(this.name==e)return!0;let t=this.prop(vr.group);return!!t&&-1{for(let t=i.prop(vr.group),e=-1;e<(t?t.length:0);e++){var n=r[e<0?i.name:t[e]];if(n)return n}}}}yr.none=new yr("",Object.create(null),0,8);class br{constructor(t,e,i,n){this.type=t,this.children=e,this.positions=i,this.length=n}toString(){var t=this.children.map(t=>t.toString()).join();return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(t,e=0){var i=null!=t&&mr.get(this)||this.topNode;let n=new Tr(i);return null!=t&&(n.moveTo(t,e),mr.set(this,n._tree)),n}fullCursor(){return new Tr(this.topNode,!0)}get topNode(){return new Sr(this,0,0,null)}resolve(t,e=0){return this.cursor(t,e).node}iterate(t){let{enter:i,leave:n,from:r=0,to:s=this.length}=t;for(let e=this.cursor();;){let t=!1;if(e.from<=s&&e.to>=r&&(e.type.isAnonymous||!1!==i(e.type,e.from,e.to))){if(e.firstChild())continue;e.type.isAnonymous||(t=!0)}for(;t&&n&&n(e.type,e.from,e.to),t=e.type.isAnonymous,!e.nextSibling();){if(!e.parent())return;t=!0}}}balance(t=1024){return this.children.length<=Lr?this:Br(this.type,yr.none,this.children,this.positions,0,this.children.length,0,t,this.length,0)}static build(t){let{buffer:e,nodeSet:m,topID:i=0,maxBufferLength:v=1024,reused:w=[],minRepeatType:y=m.types.length}=t,b=Array.isArray(e)?new Or(e,e.length):e,x=m.types,k=0;function S(i,t,e,n,r){var{id:s,start:o,end:a,size:h}=b;let l=o-i;if(h<0)return-1==h?(e.push(w[s]),n.push(l)):k=s,void b.next();let c=x[s],u,d;if(a-o<=v&&(d=function(t,e){let i=b.fork(),n=0,r=0,s=0,o=i.end-v,a={size:0,start:0,skip:0};t:for(var h=i.pos-t;i.pos>h;)if(i.id!=e){var l=i.size,c=i.pos-l;if(l<0||c=y?4:0;var u=i.start;for(i.next();i.pos>c;){if(i.size<0)break t;i.id>=y&&(t+=4),i.next()}r=u,n+=l,s+=t}else a.size=n,a.start=r,a.skip=s,s+=4,n+=4,i.next();(e<0||n==t)&&(a.size=n,a.start=r,a.skip=s);return 4t;)e=function t(e,i,n,r){var{id:s,start:o,end:a,size:h}=b;b.next();if(s==r)return n;var l=n;if(4c;)n=t(e,i,n,r);s=y?s:-1;b.pos>p;)b.id==g?b.next():S(o,p,t,e,g);t.reverse(),e.reverse(),u=-1Lr?Br(c,c,t,e,0,t.length,0,v,a-o,k):xr(new br(c,t,e,a-o),k)}e.push(u),n.push(l)}let n=[],r=[];for(;0=t:this.from>t)||(-1=t:this.from>t)||(-1!t.type.isAnonymous||t instanceof kr||Dr(t))}class Or{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Or(this.buffer,this.index)}}const Lr=8;function Br(t,i,n,r,s,o,a,h,e,l){let c=[],u=[];if(e<=h)for(let t=s;td<<1){for(let t=0;t=i)for(;s&&s.from=t.from||d<=t.to||h)&&(l=Math.max(t.from,a)-h,c=Math.min(t.to,d)-h,t=c<=l?null:new Er(l,c,t.tree,t.offset+h,(0d)break;s=rt.length&&n.push(r);return n}}const Pr=new vr;class Rr{constructor(t,e,i,n=[]){this.data=t,this.topNode=i,pt.prototype.hasOwnProperty("tree")||Object.defineProperty(pt.prototype,"tree",{get(){return Nr(this)}}),this.parser=e,this.extension=[Fr.of(this),pt.languageData.of((t,e)=>t.facet(Hr(t,e)))].concat(n)}isActiveAt(t,e){return Hr(t,e)==this.data}findRegions(t){var e=t.facet(Fr);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let n=[];return Nr(t).iterate({enter:(t,e,i)=>{if(t.isTop&&t.prop(Pr)==this.data)return n.push({from:e,to:i}),!1}}),n}get allowsNesting(){return!0}parseString(t){var e=d.of(t.split("\n"));let i=this.parser.startParse(new _r(e),0,new Vr(this.parser,pt.create({doc:e}),[],br.empty,{from:0,to:t.length},[])),n;for(;!(n=i.advance()););return n}}function Hr(t,e){var i=t.facet(Fr);if(!i)return null;if(!i.allowsNesting)return i.data;let n=Nr(t),r=n.resolve(e,-1);for(;r;){var s=r.type.prop(Pr);if(s)return s;r=r.parent}return i.data}function Nr(t){t=t.field(Rr.state,!1);return t?t.tree:br.empty}Rr.setState=rt.define();class _r{constructor(t,e=t.length){this.doc=t,this.length=e,this.cursorPos=0,this.string="",this.prevString="",this.cursor=t.iter()}syncTo(t){return t=this.length)return-1;let e=this.cursorPos-this.string.length;if(t=this.cursorPos){if(t=e-this.prevString.length)return this.prevString.charCodeAt(t-(e-this.prevString.length));e=this.syncTo(t)}return this.string.charCodeAt(t-e)}lineAfter(t){if(t>=this.length||t<0)return"";let e=this.cursorPos-this.string.length;return(t=this.cursorPos)&&(e=this.syncTo(t)),this.cursor.lineBreak?"":this.string.slice(t-e)}read(t,e){var i=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}clip(t){return new _r(this.doc,t)}}class Vr{constructor(t,e,i=[],n,r,s){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.viewport=r,this.skipped=s,this.parse=null,this.tempSkipped=[]}work(t,e){if(this.tree!=br.empty&&(null==e?this.tree.length==this.state.doc.length:this.tree.length>=e))return this.takeTree(),!0;this.parse||(this.parse=this.parser.startParse(new _r(this.state.doc),0,this));for(var i=Date.now()+t;;){var n=this.parse.advance();if(n)return this.fragments=this.withoutTempSkipped(Er.addTree(n)),this.parse=null,this.tree=n,!0;if(null!=e&&this.parse.pos>=e)return this.takeTree(),!0;if(Date.now()>i)return!1}}takeTree(){this.parse&&this.parse.pos>this.tree.length&&(this.tree=this.parse.forceFinish(),this.fragments=this.withoutTempSkipped(Er.addTree(this.tree,this.fragments,!0)))}withoutTempSkipped(t){for(var e;e=this.tempSkipped.pop();)t=zr(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let r=[];if(t.iterChangedRanges((t,e,i,n)=>r.push({fromA:t,toA:e,fromB:i,toB:n})),i=Er.applyChanges(i,r),n=br.empty,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(var a of this.skipped){var h=t.mapPos(a.from,1),a=t.mapPos(a.to,-1);he.from&&(this.fragments=zr(this.fragments,i,n),this.skipped.splice(t--,1))}return this.skipped.length=t}}function zr(t,e,i){return Er.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}Vr.skippingParser={startParse(t,e,i){return{pos:e,advance(){return i.tempSkipped.push({from:e,to:t.length}),this.pos=t.length,new br(yr.none,[],[],t.length-e)},forceFinish(){return this.advance()}}}};class Ir{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged)return this;let e=this.context.changes(t.changes,t.state);t=this.context.tree.length==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.tree.length),e.viewport.to);return e.work(25,t)||e.takeTree(),new Ir(e)}static init(t){let e=new Vr(t.facet(Fr).parser,t,[],br.empty,{from:0,to:t.doc.length},[]);return e.work(25)||e.takeTree(),new Ir(e)}}Rr.state=z.define({create:Ir.init,update(t,e){for(var i of e.effects)if(i.is(Rr.setState))return i.value;return e.startState.facet(Fr)!=e.state.facet(Fr)?Ir.init(e.state):t.apply(e)}});let $r="undefined"!=typeof window&&window.requestIdleCallback||((t,{timeout:e})=>setTimeout(t,e)),Wr="undefined"!=typeof window&&window.cancelIdleCallback||clearTimeout;Qt=li.fromClass(class{constructor(t){this.view=t,this.working=-1,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){if(e.viewportChanged){let t=this.view.state.field(Rr.state).context;t.updateViewport(e.view.viewport)&&t.reset(),this.view.viewport.to>t.tree.length&&this.scheduleWork()}e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork())}scheduleWork(){if(!(-1=t.doc.length||(this.working=$r(this.work,{timeout:500}))}}work(n){this.working=-1;var r=Date.now();if(this.chunkEnd=e+1e6||(n=Math.min(this.chunkBudget,n?Math.max(25,n.timeRemaining()):100),n=i.context.work(n,e+1e6),this.chunkBudget-=Date.now()-r,(n||this.chunkBudget<=0||i.context.movedPast(e))&&(i.context.takeTree(),this.view.dispatch({effects:Rr.setState.of(new Ir(i.context))})),!n&&0{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function Jr(t){let e=t.facet(jr);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Kr(t,e){let i="",n=t.tabSize;if(9==t.facet(jr).charCodeAt(0))for(;n<=e;)i+="\t",e-=n;for(let t=0;tfunction(t,e,i,n,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==t.pos+o,h=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;var r=null===(r=t.options)||void 0===r?void 0:r.simulateBreak,t=t.state.doc.lineAt(i.from),s=null==r||r<=t.from?t.to:Math.min(t.to,r);for(let t=i.to;;){var o=e.childAfter(t);if(!o||o==n)return null;if(!o.type.isSkipped)return o.fromJn.decorations.from(t)}),Zt];function as(t,e,i){var n=t.prop(e<0?vr.openedBy:vr.closedBy);if(n)return n;if(1==t.name.length){t=i.indexOf(t.name);if(-1=e.to){if(0==o&&-1>1==h>>1};u--}}0"},cs=rt.define({map(t,e){t=e.mapPos(t,-1,b.TrackAfter);return null==t?void 0:t}}),us=rt.define({map(t,e){return e.mapPos(t)}}),ds=new class extends kt{};ds.startSide=1,ds.endSide=-1;const fs=z.define({create(){return Ct.empty},update(t,i){var e,n;i.selection&&(e=i.state.doc.lineAt(i.selection.main.head).from,n=i.startState.doc.lineAt(i.startState.selection.main.head).from,e!=i.changes.mapPos(n,-1)&&(t=Ct.empty)),t=t.map(i.changes);for(let e of i.effects)e.is(cs)?t=t.update({add:[ds.range(e.value,e.value+1)]}):e.is(us)&&(t=t.update({filter:t=>t!=e.value}));return t}});const ps="()[]{}<>";function gs(e){for(let t=0;t>10),56320+(1023&t)));var t}function ms(t,e){return t.languageDataAt("closeBrackets",e)[0]||ls}function vs(t,e,i,n){if(t.composing)return!1;var r=t.state.selection.main;if(2{if(!t.empty)return{changes:[{insert:s,from:t.from},{insert:s,from:t.to}],effects:cs.of(t.to+s.length),range:E.range(t.anchor+s.length,t.head+s.length)};var e=t.head,i=bs(r.doc,e);if(i==s){if(xs(r,e))return{changes:{insert:s+s,from:e},effects:cs.of(e+s.length),range:E.cursor(e+s.length)};if(ys(r,e)){var n=o&&r.sliceDoc(e,e+3*s.length)==s+s+s;return{range:E.cursor(e+s.length*(n?3:1)),effects:us.of(e)}}}else{if(o&&r.sliceDoc(e-2*s.length,e)==s+s&&xs(r,e-2*s.length))return{changes:{insert:s+s+s+s,from:e},effects:cs.of(e+s.length),range:E.cursor(e+s.length)};if(r.charCategorizer(e)(i)!=x.Word){i=r.sliceDoc(e-1,e);if(i!=s&&r.charCategorizer(e)(i)!=x.Word)return{changes:{insert:s+s,from:e},effects:cs.of(e+s.length),range:E.cursor(e+s.length)}}}return{range:a=t}});return a?null:r.update(t,{scrollIntoView:!0,annotations:st.userEvent.of("input")})}(t,r,-1{if(!t.empty)return{changes:[{insert:n,from:t.from},{insert:r,from:t.to}],effects:cs.of(t.to+n.length),range:E.range(t.anchor+n.length,t.head+n.length)};var e=bs(i.doc,t.head);return!e||/\s/.test(e)||-1t.empty&&bs(e.doc,t.head)==i?E.cursor(t.head+i.length):n=t);return n?null:e.update({selection:E.create(t,e.selection.mainIndex),scrollIntoView:!0,effects:e.selection.ranges.map(({from:t})=>us.of(t))})}(t,(r,s))}return null}(t.state,n);return!!n&&(t.dispatch(n),!0)}const ws=[{key:"Backspace",run:({state:n,dispatch:t})=>{let r=ms(n,n.selection.main.head).brackets||ls.brackets,s=null,e=n.changeByRange(t=>{if(t.empty){var e,i=function(t,e){let i=t.sliceString(e-2,e);return u(c(i,0))==i.length?i:i.slice(1)}(n.doc,t.head);for(e of r)if(e==i&&bs(n.doc,t.head)==gs(c(e,0)))return{changes:{from:t.head-e.length,to:t.head+e.length},range:E.cursor(t.head-e.length),annotations:st.userEvent.of("delete")}}return{range:s=t}});return s||t(n.update(e,{scrollIntoView:!0})),!s}}];function ys(t,e){let i=!1;return t.field(fs).between(0,t.doc.length,t=>{t==e&&(i=!0)}),i}function bs(t,e){let i=t.sliceString(e,e+2);return i.slice(0,u(c(i,0)))}function xs(t,e){t=Nr(t).resolve(e+1);return t.parent&&t.from==e}function ks(t,e){return E.create(t.ranges.map(e),t.mainIndex)}function Ss(t,e){return t.update({selection:e,scrollIntoView:!0,annotations:st.userEvent.of("keyboardselection")})}function As({state:t,dispatch:e},i){let n=ks(t.selection,i);return!n.eq(t.selection)&&(e(Ss(t,n)),!0)}function Ms(t,e){return E.cursor(e?t.to:t.from)}function Cs(e,i){return As(e,t=>t.empty?e.moveByChar(t,i):Ms(t,i))}const Ts=t=>Cs(t,t.textDirection!=Kt.LTR),Ds=t=>Cs(t,t.textDirection==Kt.LTR);function Os(e,i){return As(e,t=>t.empty?e.moveByGroup(t,i):Ms(t,i))}function Ls(e,i,n){let r=Nr(e).resolve(i.head);var s,o,a,h=n?vr.closedBy:vr.openedBy;for(let t=i.head;;){var l=n?r.childAfter(t):r.childBefore(t);if(!l)break;s=e,a=h,(o=l).type.prop(a)||((a=o.to-o.from)&&(2t.empty?e.moveVertically(t,i):Ms(t,i))}const Es=t=>Bs(t,!1),Ps=t=>Bs(t,!0);function Rs(e,i){return As(e,t=>t.empty?e.moveVertically(t,i,e.dom.clientHeight):Ms(t,i))}const Hs=t=>Rs(t,!1),Ns=t=>Rs(t,!0);function _s(t,e,i){let n=t.visualLineAt(e.head),r=t.moveToLineBoundary(e,i);return r.head==e.head&&r.head!=(i?n.to:n.from)&&(r=t.moveToLineBoundary(e,i,!1)),i||r.head!=n.from||!n.length||(t=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length)&&e.head!=n.from+t&&(r=E.cursor(n.from+t)),r}const Vs=e=>As(e,t=>E.cursor(e.visualLineAt(t.head).from,1)),zs=e=>As(e,t=>E.cursor(e.visualLineAt(t.head).to,-1));function Is(t,i){let e=ks(t.state.selection,t=>{var e=i(t);return E.range(t.anchor,e.head,e.goalColumn)});return!e.eq(t.state.selection)&&(t.dispatch(Ss(t.state,e)),!0)}function $s(e,i){return Is(e,t=>e.moveByChar(t,i))}const Ws=t=>$s(t,t.textDirection!=Kt.LTR),Fs=t=>$s(t,t.textDirection==Kt.LTR);function qs(e,i){return Is(e,t=>e.moveByGroup(t,i))}function js(e,i){return Is(e,t=>e.moveVertically(t,i))}const Js=t=>js(t,!1),Ks=t=>js(t,!0);function Gs(e,i){return Is(e,t=>e.moveVertically(t,i,e.dom.clientHeight))}const Us=t=>Gs(t,!1),Xs=t=>Gs(t,!0);const Ys=e=>Is(e,t=>E.cursor(e.visualLineAt(t.head).from)),Qs=e=>Is(e,t=>E.cursor(e.visualLineAt(t.head).to)),Zs=({state:t,dispatch:e})=>(e(Ss(t,{anchor:0})),!0),to=({state:t,dispatch:e})=>(e(Ss(t,{anchor:t.doc.length})),!0),eo=({state:t,dispatch:e})=>(e(Ss(t,{anchor:t.selection.main.anchor,head:0})),!0),io=({state:t,dispatch:e})=>(e(Ss(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function no({state:t,dispatch:e},r){var i=t.changeByRange(t=>{let{from:e,to:i}=t;var n;return e==i&&(n=r(e),e=Math.min(e,n),i=Math.max(i,n)),e==i?{range:t}:{changes:{from:e,to:i},range:E.cursor(e)}});return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,annotations:st.userEvent.of("delete")})),!0)}const ro=(a,h,l)=>no(a,e=>{let{state:t}=a,i=t.doc.lineAt(e),n;if(!h&&e>i.from&&ero(t,!0,!1),oo=(t,l)=>no(t,e=>{let i=e,{state:n}=t,r=n.doc.lineAt(i),s=n.charCategorizer(i);for(let t=null;;){if(i==(l?r.to:r.from)){i==e&&r.number!=(l?n.doc.lines:1)&&(i+=l?1:-1);break}var o=S(r.text,i-r.from,l)+r.from,a=r.text.slice(Math.min(i,o)-r.from,Math.max(i,o)-r.from),h=s(a);if(null!=t&&h!=t)break;" "==a&&i==e||(t=h),i=o}return i}),ao=t=>oo(t,!1),ho=t=>oo(t,!0);function lo(t){let e=[],i=-1;for(var n of t.selection.ranges){var r=t.doc.lineAt(n.from),n=t.doc.lineAt(n.to);i==r.number?e[e.length-1].to=n.to:e.push({from:r.from,to:n.to}),i=n.number}return e}function co(t,e,i){let n=[];for(var r of lo(t)){var s;(i?r.to!=t.doc.length:0!=r.from)&&(s=t.doc.lineAt(i?r.to+1:r.from-1),i?n.push({from:r.to,to:s.to},{from:r.from,insert:s.text+t.lineBreak}):n.push({from:s.from,to:r.from},{from:r.to,insert:t.lineBreak+s.text}))}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0})),!0)}function uo(t,e,i){let n=[];for(var r of lo(t))i?n.push({from:r.from,insert:t.doc.slice(r.from,r.to)+t.lineBreak}):n.push({from:r.to,insert:t.lineBreak+t.doc.slice(r.from,r.to)});return e(t.update({changes:n,scrollIntoView:!0})),!0}function fo(r,s){let o=-1;return r.changeByRange(e=>{var i=[];for(let t=e.from;t<=e.to;){var n=r.doc.lineAt(t);n.number>o&&(e.empty||e.to>n.from)&&(s(n,i,e),o=n.number),t=n.to+1}let t=r.changes(i);return{changes:i,range:E.range(t.mapPos(e.anchor,1),t.mapPos(e.head,1))}})}const po=({state:o,dispatch:t})=>{let a=Object.create(null),h=new Ur(o,{overrideIndentation:t=>{t=a[t];return null==t?-1:t}});var e=fo(o,(t,e,i)=>{var n,r,s=Gr(h,t.from);null==s||((n=/^\s*/.exec(t.text)[0])!=(r=Kr(o,s))||i.from(t(i.update(fo(i,(t,e)=>{e.push({from:t.from,insert:i.facet(jr)})}))),!0);const mo=[{key:"Ctrl-b",run:Ts,shift:Ws},{key:"Ctrl-f",run:Ds,shift:Fs},{key:"Ctrl-p",run:Es,shift:Js},{key:"Ctrl-n",run:Ps,shift:Ks},{key:"Ctrl-a",run:Vs,shift:Ys},{key:"Ctrl-e",run:zs,shift:Qs},{key:"Ctrl-d",run:so},{key:"Ctrl-h",run:t=>ro(t,!1,!1)},{key:"Ctrl-k",run:i=>no(i,t=>{var e=i.visualLineAt(t).to;return t{var i=t.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:d.of(["",""])},range:E.cursor(t.from)}));return e(t.update(i,{scrollIntoView:!0,annotations:st.userEvent.of("input")})),!0}},{key:"Ctrl-t",run:({state:n,dispatch:t})=>{var e=n.changeByRange(t=>{if(!t.empty||0==t.from||t.from==n.doc.length)return{range:t};var e=t.from,i=n.doc.lineAt(e),t=e==i.from?e-1:S(i.text,e-i.from,!1)+i.from,i=e==i.to?e+1:S(i.text,e-i.from,!0)+i.from;return{changes:{from:t,to:i,insert:n.doc.slice(e,i).append(n.doc.slice(t,e))},range:E.cursor(i)}});return!e.changes.empty&&(t(n.update(e,{scrollIntoView:!0})),!0)}},{key:"Alt-f",run:t=>Os(t,!0),shift:t=>qs(t,!0)},{key:"Alt-b",run:t=>Os(t,!1),shift:t=>qs(t,!1)},{key:"Alt-<",run:Zs},{key:"Alt->",run:to},{key:"Ctrl-v",run:Ns},{key:"Alt-v",run:Hs}];Yt=[{key:"ArrowLeft",run:Ts,shift:Ws},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Os(t,t.textDirection!=Kt.LTR),shift:t=>qs(t,t.textDirection!=Kt.LTR)},{mac:"Cmd-ArrowLeft",run:Vs,shift:Ys},{key:"ArrowRight",run:Ds,shift:Fs},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Os(t,t.textDirection==Kt.LTR),shift:t=>qs(t,t.textDirection==Kt.LTR)},{mac:"Cmd-ArrowRight",run:zs,shift:Qs},{key:"ArrowUp",run:Es,shift:Js},{mac:"Cmd-ArrowUp",run:Zs,shift:eo},{mac:"Ctrl-ArrowUp",run:Hs,shift:Us},{key:"ArrowDown",run:Ps,shift:Ks},{mac:"Cmd-ArrowDown",run:to,shift:io},{mac:"Ctrl-ArrowDown",run:Ns,shift:Xs},{key:"PageUp",run:Hs,shift:Us},{key:"PageDown",run:Ns,shift:Xs},{key:"Home",run:e=>As(e,t=>_s(e,t,!1)),shift:e=>Is(e,t=>_s(e,t,!1))},{key:"Mod-Home",run:Zs,shift:eo},{key:"End",run:e=>As(e,t=>_s(e,t,!0)),shift:e=>Is(e,t=>_s(e,t,!0))},{key:"Mod-End",run:to,shift:io},{key:"Enter",run:({state:a,dispatch:t})=>{var e=a.changeByRange(({from:t,to:e})=>{var i=t==e&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=Nr(t).resolve(e),n=i.childBefore(e),r=i.childAfter(e),s;return n&&r&&n.to<=e&&r.from>=e&&(s=n.type.prop(vr.closedBy))&&-1s.from&&t(e(t.update({selection:{anchor:0,head:t.doc.length},annotations:st.userEvent.of("keyboardselection")})),!0)},{key:"Backspace",run:t=>ro(t,!1,!0)},{key:"Delete",run:so},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ao},{key:"Mod-Delete",mac:"Alt-Delete",run:ho}].concat(mo.map(t=>({mac:t.key,run:t.run,shift:t.shift})));const vo=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>As(e,t=>Ls(e.state,t,e.textDirection!=Kt.LTR)),shift:e=>Is(e,t=>Ls(e.state,t,e.textDirection!=Kt.LTR))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>As(e,t=>Ls(e.state,t,e.textDirection==Kt.LTR)),shift:e=>Is(e,t=>Ls(e.state,t,e.textDirection==Kt.LTR))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>co(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>uo(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>co(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>uo(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return 1{var e=lo(i).map(({from:t,to:e})=>E.range(t,Math.min(e+1,i.doc.length)));return t(i.update({selection:E.create(e),annotations:st.userEvent.of("keyboardselection")})),!0}},{key:"Mod-i",run:({state:n,dispatch:t})=>{var e=ks(n.selection,t=>{var e;let i=Nr(n).resolve(t.head,1);for(;!(i.from=t.to||i.to>t.to&&i.from<=t.from||null===(e=i.parent)||void 0===e)&&e.parent;)i=i.parent;return E.range(i.to,i.from)});return t(Ss(n,e)),!0}},{key:"Mod-[",run:({state:o,dispatch:t})=>(t(o.update(fo(o,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(s){let t=A(s,0,o.tabSize),e=0,i=Kr(o,Math.max(0,t-Jr(o)));for(;e{let{state:i}=e,t=i.changes(lo(i).map(({from:t,to:e})=>(0e.moveVertically(t,!0)).map(t);return e.dispatch({changes:t,selection:n,scrollIntoView:!0}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(i,t,n){let r=!1,e=ks(i.selection,t=>{var e=hs(i,t.head,-1)||hs(i,t.head,1)||0t.selection.ranges.some(t=>!t.empty)?go({state:t,dispatch:e}):(e(t.update(t.replaceSelection("\t"),{scrollIntoView:!0,annotations:st.userEvent.of("input")})),!0),shift:po},yo=et.define(),bo=et.define(),xo=H.define(),ko=H.define({combine(t){return gt(t,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}}),So=z.define({create(){return Ro.empty},update(e,i){var n=i.state.facet(ko),r=i.annotation(yo);if(r){var s=To.fromTransaction(i),o=r.side;let t=0==o?e.undone:e.done;return t=s?Do(t,t.length,n.minDepth,s):Eo(t,i.startState.selection),new Ro(0==o?r.rest:t,0==o?t:r.rest)}var t=i.annotation(bo);if("full"!=t&&"before"!=t||(e=e.isolate()),!1===i.annotation(st.addToHistory))return i.changes.empty?e:e.addMapping(i.changes.desc);s=To.fromTransaction(i),o=i.annotation(st.time),r=i.annotation(st.userEvent);return s?e=e.addChanges(s,o,r,n.newGroupDelay,n.minDepth):i.selection&&(e=e.addSelection(i.startState.selection,o,r,n.newGroupDelay)),e="full"==t||"after"==t?e.isolate():e},toJSON(t){return{done:t.done.map(t=>t.toJSON()),undone:t.undone.map(t=>t.toJSON())}},fromJSON(t){return new Ro(t.done.map(To.fromJSON),t.undone.map(To.fromJSON))}});function Ao(n,r){return function({state:t,dispatch:e}){let i=t.field(So,!1);if(!i)return!1;t=i.pop(n,t,r);return!!t&&(e(t),!0)}}const Mo=Ao(0,!1),Co=Ao(1,!1);ee=Ao(0,!0),ie=Ao(1,!0);class To{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(t){return new To(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(t=this.startSelection)||void 0===t?void 0:t.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new To(t.changes&&M.fromJSON(t.changes),[],t.mapped&&k.fromJSON(t.mapped),t.startSelection&&E.fromJSON(t.startSelection),t.selectionsAfter.map(E.fromJSON))}static fromTransaction(t){let e=Lo;for(var i of t.startState.facet(xo)){i=i(t);i.length&&(e=e.concat(i))}return!e.length&&t.changes.empty?null:new To(t.changes.invert(t.startState.doc),e,void 0,t.startState.selection,Lo)}static selection(t){return new To(void 0,Lo,void 0,void 0,t)}}function Do(t,e,i,n){let r=t.slice(i+20t.map(e)):Lo,i);if(!t.changes)return To.selection(n);var r=t.changes.map(e),s=e.mapDesc(t.changes,!0),i=t.mapped?t.mapped.composeDesc(s):s;return new To(r,rt.mapEffects(t.effects,e),i,t.startSelection.map(s),n)}(e[i-1],t,n);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,i);return t[i-1]=r,t}t=r.mapped,i--,n=r.selectionsAfter}return n.length?[To.selection(n)]:Lo}class Ro{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Ro(this.done,this.undone):this}addChanges(t,e,i,n,r){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&e-this.prevTimeo.push(t,e)),e.iterChangedRanges((t,e,i,n)=>{for(let t=0;tt.empty!=r.ranges[e].empty).length)?this:new Ro(Eo(this.done,t),this.undone,e,i)}addMapping(t){return new Ro(Po(this.done,t),Po(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,i,t){let n=0==e?this.done:this.undone;if(0==n.length)return null;var r=n[n.length-1];if(t&&r.selectionsAfter.length)return i.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:yo.of({side:e,rest:function(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}(n)})});if(r.changes){let t=1==n.length?Lo:n.slice(0,n.length-1);return r.mapped&&(t=Po(t,r.mapped)),i.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:yo.of({side:e,rest:t}),filter:!1})}return null}}Ro.empty=new Ro(Lo,Lo);const Ho=[{key:"Mod-z",run:Mo,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Co,preventDefault:!0},{key:"Mod-u",run:ee,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ie,preventDefault:!0}];let No=0;class _o{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=No++}static define(t){if(null!=t&&t.base)throw new Error("Can not derive from a modified tag");let e=new _o([],null,[]);if(e.set.push(e),t)for(var i of t.set)e.set.push(i);return e}static defineModifier(){let e=new zo;return t=>-1t.id-e.id))}}let Vo=0;class zo{constructor(){this.instances=[],this.id=Vo++}static get(e,i){if(!i.length)return e;var t,n=i[0].instances.find(t=>t.base==e&&function(t,i){return t.length==i.length&&t.every((t,e)=>t==i[e])}(i,t.modified));if(n)return n;let r=[],s=new _o(r,e,i);for(t of i)t.instances.push(s);var o,a=function e(i){let n=[i];for(let t=0;tt.scope)?void 0:Object.create(null);return(t,e)=>{var i,n=a&&a[t.id];if(void 0!==n)return n;let r=null;for(i of o){var s=i.match(t,e);s&&(r=r?r+" "+s:s)}return a&&(a[t.id]=r),r}}static define(t,e){return new jo(t,e||{})}static get(t,e,i){return qo(t)(e,i||yr.none)}}const Jo=W.fallback(li.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=Nr(t.state),this.decorations=this.buildDeco(t,qo(t.state))}update(t){var e=Nr(t.state),i=qo(t.state),n=i!=t.startState.facet($o);e.lengthr-1)){for(let t=r-1,e=i.length-1;0<=e;e--,t--){var s=i[e];if(s&&s!=n[t])return}return 1}}(e.context,Ko,s)){for(var l of e.tags)(l=d(l,o))&&(t&&(t+=" "),t+=l,1==e.mode?r+=(r?" ":"")+l:0==e.mode&&(i=!0));break}e=e.next}if(t!=g&&(h>p&&g&&f(p,m.from,g),p=h,g=t),!i&&m.firstChild()){do{var c=m.to;n(r,s+1,o),g!=t&&((c=Math.min(u,c))>p&&g&&f(p,c,g),p=c,g=t)}while(m.nextSibling());m.parent()}}}("",0,t.type)}(this.tree,i,r,e,(t,e,i)=>{n.add(t,e,this.markCache[i]||(this.markCache[i]=ze.mark({class:i})))});return n.finish()}},{decorations:t=>t.decorations})),Ko=[""];const Go=_o.define;Ut=Go(),re=Go(),ne=Go(re),Xt=Go(),Vt=Go(Xt),It=Go(Xt),$t=Go(),te=Go($t),Qt=Go(),Zt=Go(),Yt=Go(),ee=Go(Yt),ie=Go();const Uo={comment:Ut,lineComment:Go(Ut),blockComment:Go(Ut),docComment:Go(Ut),name:re,variableName:Go(re),typeName:ne,tagName:Go(ne),propertyName:Go(re),className:Go(re),labelName:Go(re),namespace:Go(re),macroName:Go(re),literal:Xt,string:Vt,docString:Go(Vt),character:Go(Vt),number:It,integer:Go(It),float:Go(It),bool:Go(Xt),regexp:Go(Xt),escape:Go(Xt),color:Go(Xt),url:Go(Xt),keyword:Qt,self:Go(Qt),null:Go(Qt),atom:Go(Qt),unit:Go(Qt),modifier:Go(Qt),operatorKeyword:Go(Qt),controlKeyword:Go(Qt),definitionKeyword:Go(Qt),operator:Zt,derefOperator:Go(Zt),arithmeticOperator:Go(Zt),logicOperator:Go(Zt),bitwiseOperator:Go(Zt),compareOperator:Go(Zt),updateOperator:Go(Zt),definitionOperator:Go(Zt),typeOperator:Go(Zt),controlOperator:Go(Zt),punctuation:Yt,separator:Go(Yt),bracket:ee,angleBracket:Go(ee),squareBracket:Go(ee),paren:Go(ee),brace:Go(ee),content:$t,heading:te,heading1:Go(te),heading2:Go(te),heading3:Go(te),heading4:Go(te),heading5:Go(te),heading6:Go(te),contentSeparator:Go($t),list:Go($t),quote:Go($t),emphasis:Go($t),strong:Go($t),link:Go($t),monospace:Go($t),inserted:Go(),deleted:Go(),changed:Go(),invalid:Go(),meta:ie,documentMeta:Go(ie),annotation:Go(ie),processingInstruction:Go(ie),definition:_o.defineModifier(),constant:_o.defineModifier(),function:_o.defineModifier(),standard:_o.defineModifier(),local:_o.defineModifier(),special:_o.defineModifier()};jo.define([{tag:Uo.link,textDecoration:"underline"},{tag:Uo.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Uo.emphasis,fontStyle:"italic"},{tag:Uo.strong,fontWeight:"bold"},{tag:Uo.keyword,color:"#708"},{tag:[Uo.atom,Uo.bool,Uo.url,Uo.contentSeparator,Uo.labelName],color:"#219"},{tag:[Uo.literal,Uo.inserted],color:"#164"},{tag:[Uo.string,Uo.deleted],color:"#a11"},{tag:[Uo.regexp,Uo.escape,Uo.special(Uo.string)],color:"#e40"},{tag:Uo.definition(Uo.variableName),color:"#00f"},{tag:Uo.local(Uo.variableName),color:"#30a"},{tag:[Uo.typeName,Uo.namespace],color:"#085"},{tag:Uo.className,color:"#167"},{tag:[Uo.special(Uo.variableName),Uo.macroName],color:"#256"},{tag:Uo.definition(Uo.propertyName),color:"#00c"},{tag:Uo.comment,color:"#940"},{tag:Uo.meta,color:"#7a757a"},{tag:Uo.invalid,color:"#f00"}]);const Xo=jo.define([{tag:Uo.link,class:"cmt-link"},{tag:Uo.heading,class:"cmt-heading"},{tag:Uo.emphasis,class:"cmt-emphasis"},{tag:Uo.strong,class:"cmt-strong"},{tag:Uo.keyword,class:"cmt-keyword"},{tag:Uo.atom,class:"cmt-atom"},{tag:Uo.bool,class:"cmt-bool"},{tag:Uo.url,class:"cmt-url"},{tag:Uo.labelName,class:"cmt-labelName"},{tag:Uo.inserted,class:"cmt-inserted"},{tag:Uo.deleted,class:"cmt-deleted"},{tag:Uo.literal,class:"cmt-literal"},{tag:Uo.string,class:"cmt-string"},{tag:Uo.number,class:"cmt-number"},{tag:[Uo.regexp,Uo.escape,Uo.special(Uo.string)],class:"cmt-string2"},{tag:Uo.variableName,class:"cmt-variableName"},{tag:Uo.local(Uo.variableName),class:"cmt-variableName cmt-local"},{tag:Uo.definition(Uo.variableName),class:"cmt-variableName cmt-definition"},{tag:Uo.special(Uo.variableName),class:"cmt-variableName2"},{tag:Uo.typeName,class:"cmt-typeName"},{tag:Uo.namespace,class:"cmt-namespace"},{tag:Uo.macroName,class:"cmt-macroName"},{tag:Uo.propertyName,class:"cmt-propertyName"},{tag:Uo.operator,class:"cmt-operator"},{tag:Uo.comment,class:"cmt-comment"},{tag:Uo.meta,class:"cmt-meta"},{tag:Uo.invalid,class:"cmt-invalid"},{tag:Uo.punctuation,class:"cmt-punctuation"}]);var Yo=[{type:"undo",title:"撤销",innerHTML:''},{type:"redo",title:"重做",innerHTML:''},{type:"bold",title:"加粗",innerHTML:''},{type:"italic",title:"倾斜",innerHTML:''},{type:"delete",title:"删除",innerHTML:''},{type:"code-inline",title:"行内代码",innerHTML:''},{type:"indent",title:"缩进",innerHTML:''},{type:"hr",title:"横线",innerHTML:''},{type:"quote",title:"引用",innerHTML:''},{type:"title",title:"标题",innerHTML:''},{type:"ordered-list",title:"有序列表",innerHTML:''},{type:"unordered-list",title:"无序列表",innerHTML:''},{type:"link",title:"超链接",innerHTML:''},{type:"image",title:"插入图片",innerHTML:''},{type:"character",title:"实体符号",innerHTML:''},{type:"table",title:"表格",innerHTML:''},{type:"emoji",title:"符号表情",innerHTML:''},{type:"task-no",title:"任务 - 未完成",innerHTML:''},{type:"task-yes",title:"任务 - 已完成",innerHTML:''},{type:"code-block",title:"代码块",innerHTML:''},{type:"time",title:"当前时间",innerHTML:''},{type:"clean",title:"清屏",innerHTML:''},{type:"download",title:"下载",innerHTML:''},{type:"fullScreen",title:"全屏/取消全屏",innerHTML:''},{type:"publish",title:"发布文章",innerHTML:''},{type:"about",title:"关于",innerHTML:''}];const Qo=new HyperDown;function Zo(t){t=(t=(t=Qo.makeHtml(t)).replace(/{x}/g,'')).replace(/{ }/g,''),$(".cm-preview-content").html(t),$(".cm-preview-content pre code").each((t,e)=>Prism.highlightElement(e))}class ta extends class{constructor(){$("body").append(`
    @@ -98,7 +98,7 @@
  • 仅支持网络图片粘贴上传(截图等)
  • 本编辑器仅供Joe主题使用,未经允许不得移植至其他主题!
  • - `})}}{constructor(){var t;super(),this.plugins=[(t={},[So,ko.of(t),Jn.domEventHandlers({beforeinput(t,e){return"historyUndo"==t.inputType?Mo(e):"historyRedo"==t.inputType&&Co(e)}})]),Xo,(t={},[ns.of(t),os]),[Jn.inputHandler.of(vs),fs]],this.parser=new HyperDown,this._isPasting=!1,this.init_ViewPort(),this.init_Editor(),this.init_Preview(),this.init_Tools(),this.init_Insert()}_createPreviewHtml(t){t=this.parser.makeHtml(t),$(".cm-preview-content").html(t),$(".cm-preview-content pre code").each((t,e)=>Prism.highlightElement(e))}init_ViewPort(){0<$('meta[name="viewport"]').length?$('meta[name="viewport"]').attr("content","width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover"):$("head").append('')}init_Editor(){$("#text").before(` + `})}handleTask(t,e){this._replaceSelection(t,` ${e?"{x}":"{ }"} `),t.focus()}}{constructor(){var t;super(),this.plugins=[(t={},[So,ko.of(t),Jn.domEventHandlers({beforeinput(t,e){return"historyUndo"==t.inputType?Mo(e):"historyRedo"==t.inputType&&Co(e)}})]),Xo,(t={},[ns.of(t),os]),[Jn.inputHandler.of(vs),fs]],this._isPasting=!1,this.init_ViewPort(),this.init_Editor(),this.init_Preview(),this.init_Tools(),this.init_Insert()}init_ViewPort(){0<$('meta[name="viewport"]').length?$('meta[name="viewport"]').attr("content","width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover"):$("head").append('')}init_Editor(){$("#text").before(`
    @@ -108,4 +108,4 @@
    - `),this._createPreviewHtml($("#text").val());const s=new Jn({state:pt.create({doc:$("#text").val(),extensions:[...this.plugins,er.of([wo,...vo,...Ho,...ws]),Jn.updateListener.of(t=>{t.docChanged&&this._createPreviewHtml(t.state.doc.toString())}),Jn.domEventHandlers({paste:e=>{var n=e.clipboardData;if(n&&n.items){const r=n.items;if(r.length){let i=null;for(let t=0;t{const t=$.ajaxSettings.xhr();if(t.upload)return t.upload.addEventListener("progress",t=>{t=t.loaded/t.total*100;$(".cm-progress-left").width(t/2+"%"),$(".cm-progress-right").width(t/2+"%")},!1),t},success:t=>{$(".cm-progress-left").width(0),$(".cm-progress-right").width(0),this._isPasting=!1;t=`${super._getLineCh(s)?"\n":""}![${t[1].title}](${t[0]})\n`;super._replaceSelection(s,t),s.focus()},error:()=>{$(".cm-progress-left").width(0),$(".cm-progress-right").width(0),this._isPasting=!1}})}}}}}}})],tabSize:4})});$(".cm-mainer").prepend(s.dom),$("#text")[0].form&&$("#text")[0].form.addEventListener("submit",()=>$("#text").val(s.state.doc.toString())),this.cm=s}init_Preview(){const n=(t,e,i)=>{let n=e+(t-i);n<=0&&(n=0),n>=$(".cm-mainer").outerWidth()-16&&(n=$(".cm-mainer").outerWidth()-16),$(".cm-preview").width(n)};$(".cm-resize").on({mousedown:t=>{t.preventDefault(),t.stopPropagation();const e=$(".cm-preview").outerWidth(),i=t.clientX;return document.onmousemove=t=>{window.requestAnimationFrame?requestAnimationFrame(()=>n(i,e,t.clientX)):n(i,e,t.clientX)},!(document.onmouseup=()=>{document.onmousemove=null,document.onmouseup=null})},touchstart:t=>{t.preventDefault(),t.stopPropagation();const e=$(".cm-preview").outerWidth(),i=t.originalEvent.targetTouches[0].clientX;return document.ontouchmove=t=>{window.requestAnimationFrame?requestAnimationFrame(()=>n(i,e,t.targetTouches[0].clientX)):n(i,e,t.targetTouches[0].clientX)},!(document.ontouchend=()=>{document.ontouchmove=null,document.ontouchend=null})}})}init_Tools(){Yo.forEach(e=>{if("title"===e.type)super.handleTitle(this.cm,e);else{const i=$(`
    ${e.innerHTML}
    `);i.on("click",t=>{switch(t.preventDefault(),e.type){case"fullScreen":super.handleFullScreen(i);break;case"publish":super.handlePublish();break;case"undo":super.handleUndo(this.cm);break;case"redo":super.handleRedo(this.cm);break;case"time":super.handleTime(this.cm);break;case"bold":super._insetAmboText(this.cm,"**");break;case"italic":super._insetAmboText(this.cm,"*");break;case"delete":super._insetAmboText(this.cm,"~~");break;case"code-inline":super._insetAmboText(this.cm,"`");break;case"indent":super.handleIndent(this.cm);break;case"hr":super.handleHr(this.cm);break;case"clean":super.handleClean(this.cm);break;case"ordered-list":super.handleOrdered(this.cm);break;case"unordered-list":super.handleUnordered(this.cm);break;case"quote":super.handleQuote(this.cm);break;case"download":super.handleDownload(this.cm);break;case"link":super.handleLink(this.cm);break;case"image":super.handleImage(this.cm);break;case"table":super.handleTable(this.cm);break;case"code-block":super.handleCodeBlock(this.cm);break;case"about":super.handleAbout();break;case"character":super._createTableLists(this.cm,JoeConfig.characterAPI,"星星符号","字符大全");break;case"emoji":super._createTableLists(this.cm,JoeConfig.emojiAPI,"表情","符号表情(需数据库支持)")}}),$(".cm-tools").append(i)}})}init_Insert(){Typecho.insertFileToEditor=(t,e,i)=>{e=`${super._getLineCh(this.cm)?"\n":""}${i?"!":""}[${t}](${e})\n`;super._replaceSelection(this.cm,e),this.cm.focus()}}}document.addEventListener("DOMContentLoaded",()=>new Qo)}(); + `),Zo($("#text").val());const s=new Jn({state:pt.create({doc:$("#text").val(),extensions:[...this.plugins,er.of([wo,...vo,...Ho,...ws]),Jn.updateListener.of(t=>{t.docChanged&&Zo(t.state.doc.toString())}),Jn.domEventHandlers({paste:e=>{var n=e.clipboardData;if(n&&n.items){const r=n.items;if(r.length){let i=null;for(let t=0;t{const t=$.ajaxSettings.xhr();if(t.upload)return t.upload.addEventListener("progress",t=>{t=t.loaded/t.total*100;$(".cm-progress-left").width(t/2+"%"),$(".cm-progress-right").width(t/2+"%")},!1),t},success:t=>{$(".cm-progress-left").width(0),$(".cm-progress-right").width(0),this._isPasting=!1;t=`${super._getLineCh(s)?"\n":""}![${t[1].title}](${t[0]})\n`;super._replaceSelection(s,t),s.focus()},error:()=>{$(".cm-progress-left").width(0),$(".cm-progress-right").width(0),this._isPasting=!1}})}}}}}}})],tabSize:4})});$(".cm-mainer").prepend(s.dom),$("#text")[0].form&&$("#text")[0].form.addEventListener("submit",()=>$("#text").val(s.state.doc.toString())),this.cm=s}init_Preview(){const n=(t,e,i)=>{let n=e+(t-i);n<=0&&(n=0),n>=$(".cm-mainer").outerWidth()-16&&(n=$(".cm-mainer").outerWidth()-16),$(".cm-preview").width(n)};$(".cm-resize").on({mousedown:t=>{t.preventDefault(),t.stopPropagation();const e=$(".cm-preview").outerWidth(),i=t.clientX;return document.onmousemove=t=>{window.requestAnimationFrame?requestAnimationFrame(()=>n(i,e,t.clientX)):n(i,e,t.clientX)},!(document.onmouseup=()=>{document.onmousemove=null,document.onmouseup=null})},touchstart:t=>{t.preventDefault(),t.stopPropagation();const e=$(".cm-preview").outerWidth(),i=t.originalEvent.targetTouches[0].clientX;return document.ontouchmove=t=>{window.requestAnimationFrame?requestAnimationFrame(()=>n(i,e,t.targetTouches[0].clientX)):n(i,e,t.targetTouches[0].clientX)},!(document.ontouchend=()=>{document.ontouchmove=null,document.ontouchend=null})}})}init_Tools(){Yo.forEach(e=>{if("title"===e.type)super.handleTitle(this.cm,e);else{const i=$(`
    ${e.innerHTML}
    `);i.on("click",t=>{switch(t.preventDefault(),e.type){case"fullScreen":super.handleFullScreen(i);break;case"publish":super.handlePublish();break;case"undo":super.handleUndo(this.cm);break;case"redo":super.handleRedo(this.cm);break;case"time":super.handleTime(this.cm);break;case"bold":super._insetAmboText(this.cm,"**");break;case"italic":super._insetAmboText(this.cm,"*");break;case"delete":super._insetAmboText(this.cm,"~~");break;case"code-inline":super._insetAmboText(this.cm,"`");break;case"indent":super.handleIndent(this.cm);break;case"hr":super.handleHr(this.cm);break;case"clean":super.handleClean(this.cm);break;case"ordered-list":super.handleOrdered(this.cm);break;case"unordered-list":super.handleUnordered(this.cm);break;case"quote":super.handleQuote(this.cm);break;case"download":super.handleDownload(this.cm);break;case"link":super.handleLink(this.cm);break;case"image":super.handleImage(this.cm);break;case"table":super.handleTable(this.cm);break;case"code-block":super.handleCodeBlock(this.cm);break;case"about":super.handleAbout();break;case"character":super._createTableLists(this.cm,JoeConfig.characterAPI,"星星符号","字符大全");break;case"emoji":super._createTableLists(this.cm,JoeConfig.emojiAPI,"表情","符号表情(需数据库支持)");break;case"task-no":super.handleTask(this.cm,!1);break;case"task-yes":super.handleTask(this.cm,!0)}}),$(".cm-tools").append(i)}})}init_Insert(){Typecho.insertFileToEditor=(t,e,i)=>{e=`${super._getLineCh(this.cm)?"\n":""}${i?"!":""}[${t}](${e})\n`;super._replaceSelection(this.cm,e),this.cm.focus()}}}document.addEventListener("DOMContentLoaded",()=>new ta)}(); diff --git a/typecho/write/js/joe.write.js b/typecho/write/js/joe.write.js index b3d183f..1e2a324 100644 --- a/typecho/write/js/joe.write.js +++ b/typecho/write/js/joe.write.js @@ -7,36 +7,29 @@ import { history, historyKeymap } from '@codemirror/history'; import { classHighlightStyle } from '@codemirror/highlight'; import tools from './_tools'; import JoeAction from './_actions'; +import createPreviewHtml from './_create'; class Joe extends JoeAction { - constructor() { - super(); - this.plugins = [history(), classHighlightStyle, bracketMatching(), closeBrackets()]; - this.parser = new HyperDown(); - this._isPasting = false; + constructor() { + super(); + this.plugins = [history(), classHighlightStyle, bracketMatching(), closeBrackets()]; + this._isPasting = false; + this.init_ViewPort(); + this.init_Editor(); + this.init_Preview(); + this.init_Tools(); + this.init_Insert(); + } - this.init_ViewPort(); - this.init_Editor(); - this.init_Preview(); - this.init_Tools(); - this.init_Insert(); - } + /* 已测 √ */ + init_ViewPort() { + if ($('meta[name="viewport"]').length > 0) $('meta[name="viewport"]').attr('content', 'width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover'); + else $('head').append(''); + } - _createPreviewHtml(str) { - str = this.parser.makeHtml(str); - $('.cm-preview-content').html(str); - $('.cm-preview-content pre code').each((i, el) => Prism.highlightElement(el)); - } - - /* 已测 √ */ - init_ViewPort() { - if ($('meta[name="viewport"]').length > 0) $('meta[name="viewport"]').attr('content', 'width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover'); - else $('head').append(''); - } - - /* 已测 √ */ - init_Editor() { - $('#text').before(` + /* 已测 √ */ + init_Editor() { + $('#text').before(`
    @@ -47,225 +40,231 @@ class Joe extends JoeAction {
    `); - this._createPreviewHtml($('#text').val()); - const cm = new EditorView({ - state: EditorState.create({ - doc: $('#text').val(), - extensions: [ - ...this.plugins, - keymap.of([defaultTabBinding, ...defaultKeymap, ...historyKeymap, ...closeBracketsKeymap]), - EditorView.updateListener.of(update => { - if (!update.docChanged) return; - this._createPreviewHtml(update.state.doc.toString()); - }), - EditorView.domEventHandlers({ - paste: e => { - const clipboardData = e.clipboardData; - if (!clipboardData || !clipboardData.items) return; - const items = clipboardData.items; - if (!items.length) return; - let blob = null; - for (let i = 0; i < items.length; i++) { - if (items[i].type.indexOf('image') !== -1) { - e.preventDefault(); - blob = items[i].getAsFile(); - break; - } - } - if (!blob) return; - let api = window.JoeConfig.uploadAPI; - if (!api) return; - const cid = $('input[name="cid"]').val(); - cid && (api = api + '&cid=' + cid); - if (this._isPasting) return; - this._isPasting = true; - const fileName = Date.now().toString(36) + '.png'; - let formData = new FormData(); - formData.append('name', fileName); - formData.append('file', blob, fileName); - $.ajax({ - url: api, - method: 'post', - data: formData, - contentType: false, - processData: false, - dataType: 'json', - xhr: () => { - const xhr = $.ajaxSettings.xhr(); - if (!xhr.upload) return; - xhr.upload.addEventListener( - 'progress', - e => { - let percent = (e.loaded / e.total) * 100; - $('.cm-progress-left').width(percent / 2 + '%'); - $('.cm-progress-right').width(percent / 2 + '%'); - }, - false - ); - return xhr; - }, - success: res => { - $('.cm-progress-left').width(0); - $('.cm-progress-right').width(0); - this._isPasting = false; - const str = `${super._getLineCh(cm) ? '\n' : ''}![${res[1].title}](${res[0]})\n`; - super._replaceSelection(cm, str); - cm.focus(); - }, - error: () => { - $('.cm-progress-left').width(0); - $('.cm-progress-right').width(0); - this._isPasting = false; - } - }); - } - }) - ], - tabSize: 4 - }) - }); - $('.cm-mainer').prepend(cm.dom); - $('#text')[0].form && $('#text')[0].form.addEventListener('submit', () => $('#text').val(cm.state.doc.toString())); - this.cm = cm; - } + createPreviewHtml($('#text').val()); + const cm = new EditorView({ + state: EditorState.create({ + doc: $('#text').val(), + extensions: [ + ...this.plugins, + keymap.of([defaultTabBinding, ...defaultKeymap, ...historyKeymap, ...closeBracketsKeymap]), + EditorView.updateListener.of(update => { + if (!update.docChanged) return; + createPreviewHtml(update.state.doc.toString()); + }), + EditorView.domEventHandlers({ + paste: e => { + const clipboardData = e.clipboardData; + if (!clipboardData || !clipboardData.items) return; + const items = clipboardData.items; + if (!items.length) return; + let blob = null; + for (let i = 0; i < items.length; i++) { + if (items[i].type.indexOf('image') !== -1) { + e.preventDefault(); + blob = items[i].getAsFile(); + break; + } + } + if (!blob) return; + let api = window.JoeConfig.uploadAPI; + if (!api) return; + const cid = $('input[name="cid"]').val(); + cid && (api = api + '&cid=' + cid); + if (this._isPasting) return; + this._isPasting = true; + const fileName = Date.now().toString(36) + '.png'; + let formData = new FormData(); + formData.append('name', fileName); + formData.append('file', blob, fileName); + $.ajax({ + url: api, + method: 'post', + data: formData, + contentType: false, + processData: false, + dataType: 'json', + xhr: () => { + const xhr = $.ajaxSettings.xhr(); + if (!xhr.upload) return; + xhr.upload.addEventListener( + 'progress', + e => { + let percent = (e.loaded / e.total) * 100; + $('.cm-progress-left').width(percent / 2 + '%'); + $('.cm-progress-right').width(percent / 2 + '%'); + }, + false + ); + return xhr; + }, + success: res => { + $('.cm-progress-left').width(0); + $('.cm-progress-right').width(0); + this._isPasting = false; + const str = `${super._getLineCh(cm) ? '\n' : ''}![${res[1].title}](${res[0]})\n`; + super._replaceSelection(cm, str); + cm.focus(); + }, + error: () => { + $('.cm-progress-left').width(0); + $('.cm-progress-right').width(0); + this._isPasting = false; + } + }); + } + }) + ], + tabSize: 4 + }) + }); + $('.cm-mainer').prepend(cm.dom); + $('#text')[0].form && $('#text')[0].form.addEventListener('submit', () => $('#text').val(cm.state.doc.toString())); + this.cm = cm; + } - /* 已测 √ */ - init_Preview() { - const move = (nowClientX, nowWidth, clientX) => { - let moveX = nowClientX - clientX; - let moveWidth = nowWidth + moveX; - if (moveWidth <= 0) moveWidth = 0; - if (moveWidth >= $('.cm-mainer').outerWidth() - 16) moveWidth = $('.cm-mainer').outerWidth() - 16; - $('.cm-preview').width(moveWidth); - }; - $('.cm-resize').on({ - mousedown: e => { - e.preventDefault(); - e.stopPropagation(); - const nowWidth = $('.cm-preview').outerWidth(); - const nowClientX = e.clientX; - document.onmousemove = _e => { - if (window.requestAnimationFrame) requestAnimationFrame(() => move(nowClientX, nowWidth, _e.clientX)); - else move(nowClientX, nowWidth, _e.clientX); - }; - document.onmouseup = () => { - document.onmousemove = null; - document.onmouseup = null; - }; - return false; - }, - touchstart: e => { - e.preventDefault(); - e.stopPropagation(); - const nowWidth = $('.cm-preview').outerWidth(); - const nowClientX = e.originalEvent.targetTouches[0].clientX; - document.ontouchmove = _e => { - if (window.requestAnimationFrame) requestAnimationFrame(() => move(nowClientX, nowWidth, _e.targetTouches[0].clientX)); - else move(nowClientX, nowWidth, _e.targetTouches[0].clientX); - }; - document.ontouchend = () => { - document.ontouchmove = null; - document.ontouchend = null; - }; - return false; - } - }); - } + /* 已测 √ */ + init_Preview() { + const move = (nowClientX, nowWidth, clientX) => { + let moveX = nowClientX - clientX; + let moveWidth = nowWidth + moveX; + if (moveWidth <= 0) moveWidth = 0; + if (moveWidth >= $('.cm-mainer').outerWidth() - 16) moveWidth = $('.cm-mainer').outerWidth() - 16; + $('.cm-preview').width(moveWidth); + }; + $('.cm-resize').on({ + mousedown: e => { + e.preventDefault(); + e.stopPropagation(); + const nowWidth = $('.cm-preview').outerWidth(); + const nowClientX = e.clientX; + document.onmousemove = _e => { + if (window.requestAnimationFrame) requestAnimationFrame(() => move(nowClientX, nowWidth, _e.clientX)); + else move(nowClientX, nowWidth, _e.clientX); + }; + document.onmouseup = () => { + document.onmousemove = null; + document.onmouseup = null; + }; + return false; + }, + touchstart: e => { + e.preventDefault(); + e.stopPropagation(); + const nowWidth = $('.cm-preview').outerWidth(); + const nowClientX = e.originalEvent.targetTouches[0].clientX; + document.ontouchmove = _e => { + if (window.requestAnimationFrame) requestAnimationFrame(() => move(nowClientX, nowWidth, _e.targetTouches[0].clientX)); + else move(nowClientX, nowWidth, _e.targetTouches[0].clientX); + }; + document.ontouchend = () => { + document.ontouchmove = null; + document.ontouchend = null; + }; + return false; + } + }); + } - /* 已测 √ */ - init_Tools() { - tools.forEach(item => { - if (item.type === 'title') { - super.handleTitle(this.cm, item); - } else { - const el = $(`
    ${item.innerHTML}
    `); - el.on('click', e => { - e.preventDefault(); - switch (item.type) { - case 'fullScreen': - super.handleFullScreen(el); - break; - case 'publish': - super.handlePublish(); - break; - case 'undo': - super.handleUndo(this.cm); - break; - case 'redo': - super.handleRedo(this.cm); - break; - case 'time': - super.handleTime(this.cm); - break; - case 'bold': - super._insetAmboText(this.cm, '**'); - break; - case 'italic': - super._insetAmboText(this.cm, '*'); - break; - case 'delete': - super._insetAmboText(this.cm, '~~'); - break; - case 'code-inline': - super._insetAmboText(this.cm, '`'); - break; - case 'indent': - super.handleIndent(this.cm); - break; - case 'hr': - super.handleHr(this.cm); - break; - case 'clean': - super.handleClean(this.cm); - break; - case 'ordered-list': - super.handleOrdered(this.cm); - break; - case 'unordered-list': - super.handleUnordered(this.cm); - break; - case 'quote': - super.handleQuote(this.cm); - break; - case 'download': - super.handleDownload(this.cm); - break; - case 'link': - super.handleLink(this.cm); - break; - case 'image': - super.handleImage(this.cm); - break; - case 'table': - super.handleTable(this.cm); - break; - case 'code-block': - super.handleCodeBlock(this.cm); - break; - case 'about': - super.handleAbout(); - break; - case 'character': - super._createTableLists(this.cm, JoeConfig.characterAPI, '星星符号', '字符大全'); - break; - case 'emoji': - super._createTableLists(this.cm, JoeConfig.emojiAPI, '表情', '符号表情(需数据库支持)'); - break; - } - }); - $('.cm-tools').append(el); - } - }); - } + /* 已测 √ */ + init_Tools() { + tools.forEach(item => { + if (item.type === 'title') { + super.handleTitle(this.cm, item); + } else { + const el = $(`
    ${item.innerHTML}
    `); + el.on('click', e => { + e.preventDefault(); + switch (item.type) { + case 'fullScreen': + super.handleFullScreen(el); + break; + case 'publish': + super.handlePublish(); + break; + case 'undo': + super.handleUndo(this.cm); + break; + case 'redo': + super.handleRedo(this.cm); + break; + case 'time': + super.handleTime(this.cm); + break; + case 'bold': + super._insetAmboText(this.cm, '**'); + break; + case 'italic': + super._insetAmboText(this.cm, '*'); + break; + case 'delete': + super._insetAmboText(this.cm, '~~'); + break; + case 'code-inline': + super._insetAmboText(this.cm, '`'); + break; + case 'indent': + super.handleIndent(this.cm); + break; + case 'hr': + super.handleHr(this.cm); + break; + case 'clean': + super.handleClean(this.cm); + break; + case 'ordered-list': + super.handleOrdered(this.cm); + break; + case 'unordered-list': + super.handleUnordered(this.cm); + break; + case 'quote': + super.handleQuote(this.cm); + break; + case 'download': + super.handleDownload(this.cm); + break; + case 'link': + super.handleLink(this.cm); + break; + case 'image': + super.handleImage(this.cm); + break; + case 'table': + super.handleTable(this.cm); + break; + case 'code-block': + super.handleCodeBlock(this.cm); + break; + case 'about': + super.handleAbout(); + break; + case 'character': + super._createTableLists(this.cm, JoeConfig.characterAPI, '星星符号', '字符大全'); + break; + case 'emoji': + super._createTableLists(this.cm, JoeConfig.emojiAPI, '表情', '符号表情(需数据库支持)'); + break; + case 'task-no': + super.handleTask(this.cm, false); + break; + case 'task-yes': + super.handleTask(this.cm, true); + break; + } + }); + $('.cm-tools').append(el); + } + }); + } - /* 已测 √ */ - init_Insert() { - Typecho.insertFileToEditor = (file, url, isImage) => { - const str = `${super._getLineCh(this.cm) ? '\n' : ''}${isImage ? '!' : ''}[${file}](${url})\n`; - super._replaceSelection(this.cm, str); - this.cm.focus(); - }; - } + /* 已测 √ */ + init_Insert() { + Typecho.insertFileToEditor = (file, url, isImage) => { + const str = `${super._getLineCh(this.cm) ? '\n' : ''}${isImage ? '!' : ''}[${file}](${url})\n`; + super._replaceSelection(this.cm, str); + this.cm.focus(); + }; + } } document.addEventListener('DOMContentLoaded', () => new Joe()); diff --git a/typecho/write/rollup.config.js b/typecho/write/rollup.config.js index 7298032..f77b53f 100644 --- a/typecho/write/rollup.config.js +++ b/typecho/write/rollup.config.js @@ -1,10 +1,10 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; import { uglify } from 'rollup-plugin-uglify'; export default { - input: './js/joe.write.js', - output: { - file: './js/joe.write.chunk.js', - format: 'iife' - }, - plugins: [nodeResolve(), uglify()] + input: './js/joe.write.js', + output: { + file: './js/joe.write.chunk.js', + format: 'iife' + }, + plugins: [nodeResolve(), uglify()] };