JSON Viewer

格式化显示 JSON 使数据看起来更加漂亮。支持 JSON 主题色切换。支持 JSON 脑图,清晰明了的查看 JSON 层级。支持通过 JSON Crack 查看 JSON。支持手动输入 JSON,HTTP 请求获取 JSON

当前为 2024-11-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name JSON Viewer
  3. // @namespace http://tampermonkey.net/
  4. // @version v0.9.5
  5. // @author Feny
  6. // @description 格式化显示 JSON 使数据看起来更加漂亮。支持 JSON 主题色切换。支持 JSON 脑图,清晰明了的查看 JSON 层级。支持通过 JSON Crack 查看 JSON。支持手动输入 JSON,HTTP 请求获取 JSON
  7. // @license MIT
  8. // @icon data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAeAB4AAD/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAEAAAAAAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAAgACADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD9wvjF8bLX4ZrHZx+XNqlwnmKjH5YUyRvb6kEAd8H058d1b47XV5Ir3eoN++bagaXYrN6KOBn2FfPPx5/aEutX8a+KNWhIubhruZLSNj8u1WMcIOP4QoXOOwNS/wDBM79lDTfjh8YNe+IXj63TxRdeHfKjsE1KMTxtdSbmMmxvlAiVV2IBsUybgAyKR9ZTy6lhsM69Xovm2+iPmKmOqYjEKjT6v5WXU9e8beKrjxZpp/s/xFrfhjWIwWs9X0q42z2kmPlZo2zDcxjqYZ0eNv7obDDf/YL/AG8L745eJNc+G3xCttP0n4qeEWZZ2sVZNP8AENsu0rd2ysS0ZKPG7RMSQsisCcukWd+3x4RtfhpqGk+JNPjS0g1mV7a8iT5UM4XesgHYsofdjglQepJPxwPE1x4V/au8LePtNkeK40ma0lmdDgyorvHMhPo9uxjP+y1bUcHRxmGbS1adn1TXT0/4fcipiqmExCi3pfVdGn19f+GLni/w7ceGf2wPFXga+Vo5rW/vDbI3WWI/v4HA/wBqBg3tk+lfWX7AXia1+F/iDV9B1CRbWHXjFLayyHannpuUxk+rqy4zxlMdWAPQft7fsL33x91nQfiD4DutP0r4oeDXVrT7cWWx1y3UsTZ3LKCyAh5FEigkLLIpHzBk5vwj4JuvE2kLJfeHdY8N6lGAl5pepwBZrOT+JRIuYp0ByBNCzxPg4bIICqYyljMKot62Sa6prr6P/gBDC1MLiHJLS90+jT6ev/Dnmn/BVP8Aaw0nxv4/8P8Aw18KXK69qmk3MlxqEdiRMwuivlpbrtPLopkMnZNy5IIYLyPwa/Z8vvEmv+HtHu4/Ovr+5iS6KDcqAtukwe6om7nuEJxX0XoH7PK/bJG0vRoY5rr/AFslvbLGZf8AfcAf+PGvafgv8CbX4byNqFyI5tWmXYCoytsh6qvqx7t+A4yWiWYUsLhlRpbr72318kVHA1MTiHVqbP7kl0P/2Q==
  9. // @homepage https://github.com/xFeny/monkey-jsonviewer
  10. // @match *://*/*
  11. // @require https://unpkg.com/dom-to-image@2
  12. // @require https://unpkg.com/jquery@3.7.1/dist/jquery.slim.min.js
  13. // @require data:application/javascript,%3Bwindow.jquery%3DjQuery%3B
  14. // @require https://unpkg.com/jsmind@0.8.5/es6/jsmind.js
  15. // @require data:application/javascript,%3Bwindow.jsmind%3DjsMind%3B
  16. // @require https://unpkg.com/beautifier@0.1.7
  17. // @require data:application/javascript,%3Bwindow.beautifier%3Djs_beautify%3Bwindow.js_beautify%3Djs_beautify%3Bwindow.css_beautify%3Dcss_beautify%3B
  18. // @require https://unpkg.com/@highlightjs/cdn-assets@11.10.0/highlight.min.js
  19. // @require data:application/javascript,%3Bwindow.hljs%3Dhljs%3B
  20. // @require https://unpkg.com/systemjs@6.15.1/dist/system.min.js
  21. // @require https://unpkg.com/systemjs@6.15.1/dist/extras/named-register.min.js
  22. // @require data:application/javascript,%3B(typeof%20System!%3D'undefined')%26%26(System%3Dnew%20System.constructor())%3B
  23. // @grant GM_addStyle
  24. // @grant GM_getValue
  25. // @grant GM_openInTab
  26. // @grant GM_registerMenuCommand
  27. // @grant GM_setClipboard
  28. // @grant GM_setValue
  29. // @grant unsafeWindow
  30. // ==/UserScript==
  31.  
  32. (e=>{window.addEventListener("message",r=>{const{data:n}=r;if(!n?.addStyle)return;if(typeof GM_addStyle=="function"){GM_addStyle(e);return}const o=document.createElement("style");o.textContent=e,document.head.append(o)})})(` @charset "UTF-8";.monkey-jsonviewer body li::marker{content:""}.monkey-jsonviewer body input:focus,.monkey-jsonviewer body select:focus,.monkey-jsonviewer body textarea:focus{outline:0}.monkey-jsonviewer body a:hover{text-decoration:underline}.monkey-jsonviewer .hidden{display:none!important}.monkey-jsonviewer .jsonp{color:#93983a}.monkey-jsonviewer .layui-layer-tips{width:auto!important}.monkey-jsonviewer #jsoncrackEmbed{width:100%;height:100%;border:0}.monkey-jsonviewer .tippy-box[data-theme~=layer]{color:#fff;padding:5px;font-size:12px;line-height:20px;background-color:#2e59a7}.monkey-jsonviewer .tippy-box[data-theme~=layer] .tippy-arrow{color:#2e59a7}.monkey-jsonviewer .tippy-box[data-theme~=imagebox]{background-color:#d9d9d9}.monkey-jsonviewer .tippy-box[data-theme~=imagebox] .tippy-arrow{color:#d9d9d9}@media screen and (max-width: 640px){.monkey-jsonviewer .rightbox{right:0!important}.monkey-jsonviewer .rightbox .tools{display:none!important}}@media screen and (max-width: 400px){.monkey-jsonviewer .searchbox{display:none!important}}.monkey-jsonviewer .json-viewer-layout{top:0;left:0;z-index:10;width:100vw;height:100vh;display:flex;position:fixed;flex-direction:column}.monkey-jsonviewer .json-viewer-layout .panel{display:flex;line-height:28px;flex-direction:column;background-color:#ececec}.monkey-jsonviewer .json-viewer-layout .tabs,.monkey-jsonviewer .json-viewer-layout .toolbar{display:flex;border-bottom:1px solid #ccc}.monkey-jsonviewer .json-viewer-layout .tabs>div,.monkey-jsonviewer .json-viewer-layout .toolbar>div{cursor:pointer;padding:0 10px;font-size:12px;transition:background-color .2s ease}.monkey-jsonviewer .json-viewer-layout .tabs>div:hover,.monkey-jsonviewer .json-viewer-layout .toolbar>div:hover{background-color:#d4d4d4}.monkey-jsonviewer .json-viewer-layout .tabs-item{border-top:3px solid #ececec}.monkey-jsonviewer .json-viewer-layout .tabs-item:hover{border-top-color:#c3c3c6}.monkey-jsonviewer .json-viewer-layout .tabs-item.active{color:#0060df;border-top-color:#0060df;background-color:#f1f1f1}.monkey-jsonviewer .json-viewer-layout .toolbar{line-height:23px}.monkey-jsonviewer .json-viewer-layout .toolbar .searchbox{padding:0;display:flex;flex-grow:1}.monkey-jsonviewer .json-viewer-layout .toolbar .searchbox input{flex-grow:1;border:none;outline:none;font-size:12px;padding-left:23px;border-left:1.5px solid #ccc;background-size:12px;background-repeat:no-repeat;background-position:7px center;background-image:url(data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIGZpbGw9InJnYmEoMTM1LCAxMzUsIDEzNywgMC45KSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMTIgMTIiPgogIDxwYXRoIGZpbGw9ImNvbnRleHQtZmlsbCIgb3BhY2l0eT0iLjQiIGQ9Ik01IDkuMmwyIDEuNlY2LjFMOC41NSA0aC01LjFMNSA2LjF2My4xeiIvPgogIDxwYXRoIGZpbGw9ImNvbnRleHQtZmlsbCIgZD0iTTEuMTggMi42QTEgMSAwIDAgMSAyIDFIMTBhMSAxIDAgMCAxIC44IDEuNkw4IDYuNHY0LjgyYzAgLjYzLS43Mi45OC0xLjIyLjZsLTIuNS0xLjk5QS43NS43NSAwIDAgMSA0IDkuMjVWNi40MUwxLjE4IDIuNnpNMiAyTDUgNi4wOXYzLjA0bDIgMS41OVY2LjA5TDEwLjAxIDJIMnoiLz4KPC9zdmc+Cg==)}.monkey-jsonviewer .json-viewer-layout .toolbar .searchbox .clear{flex:0 0 auto;align-self:center;margin:0 4px;padding:0;border:0;width:16px;height:16px;background-color:transparent;background-image:url(data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIGZpbGw9ImNvbnRleHQtZmlsbCIgZmlsbC1vcGFjaXR5PSJjb250ZXh0LWZpbGwtb3BhY2l0eSI+CiAgPHBhdGggZD0iTTYuNTg2IDhsLTIuMjkzIDIuMjkzYTEgMSAwIDAgMCAxLjQxNCAxLjQxNEw4IDkuNDE0bDIuMjkzIDIuMjkzYTEgMSAwIDAgMCAxLjQxNC0xLjQxNEw5LjQxNCA4bDIuMjkzLTIuMjkzYTEgMSAwIDEgMC0xLjQxNC0xLjQxNEw4IDYuNTg2IDUuNzA3IDQuMjkzYTEgMSAwIDAgMC0xLjQxNCAxLjQxNEw2LjU4NiA4ek04IDBhOCA4IDAgMSAxIDAgMTZBOCA4IDAgMCAxIDggMHoiLz4KPC9zdmc+Cg==)}.monkey-jsonviewer .json-viewer-layout .rightbox{right:200px;display:flex;font-size:12px;position:absolute}.monkey-jsonviewer .json-viewer-layout .rightbox>div{padding:0 5px;margin-top:2px}.monkey-jsonviewer .json-viewer-layout .rightbox>div span{cursor:pointer;display:inline;padding:5px 10px;border-radius:3px;transition:background-color .2s ease}.monkey-jsonviewer .json-viewer-layout .rightbox>div span:hover{background-color:#ccc}.monkey-jsonviewer .json-viewer-layout .rightbox>div span:after{content:"";width:0;height:0;right:-5px;position:relative;border-style:solid;display:inline-block;vertical-align:middle;border-width:7px 5px 0 5px;border-color:#999 transparent transparent transparent;transform:rotate(0);transition:transform .3s ease}.monkey-jsonviewer .json-viewer-layout .rightbox>div span.active:after{transform:rotate(180deg)}.monkey-jsonviewer .json-viewer-layout .rightbox>div ul{color:#333;cursor:pointer;text-align:center;border-radius:3px}.monkey-jsonviewer .json-viewer-layout .rightbox>div ul li{font-size:12px;padding:5px 20px;background-color:#dfdfdf;transition:background-color .2s ease}.monkey-jsonviewer .json-viewer-layout .rightbox>div ul li:hover{border-radius:3px;background-color:#ccc}.monkey-jsonviewer .json-viewer-layout .rightbox>div ul li.active:before{left:15px;content:"\u221A";display:inline;position:absolute}.monkey-jsonviewer .json-viewer-layout .rightbox>div .tippy-box{background-color:#dfdfdf!important}.monkey-jsonviewer .json-viewer-layout .rightbox>div .tippy-box .tippy-content{padding:5px}.monkey-jsonviewer .json-viewer-layout .rightbox>div .tippy-box .tippy-arrow{color:#dfdfdf!important}.monkey-jsonviewer .json-viewer-layout .container{flex-grow:1;overflow:auto;line-height:1.4;font-size:13.5px;font-family:monospace}.monkey-jsonviewer .json-viewer-layout .container>div{display:none}.monkey-jsonviewer .json-viewer-layout .container>div.active{display:block}.monkey-jsonviewer .json-viewer-layout .container #formatBox{padding:5px 8px}.monkey-jsonviewer .json-viewer-layout .container #rawTextBox{font-size:13px;padding:5px 8px}.monkey-jsonviewer .json-viewer-layout .container #rawTextBox pre{display:block!important;overflow-wrap:break-word;white-space:pre-wrap}.monkey-jsonviewer .json-viewer-layout #mindBox{width:100vw;height:calc(100vh - 57px)}.monkey-jsonviewer .json-viewer-layout #mindBox jmnode{display:flex;align-items:center;padding:0 7px 0 22px;color:#475872!important;box-shadow:none!important;background-color:transparent!important}.monkey-jsonviewer .json-viewer-layout #mindBox jmnode.root{padding:0;color:transparent!important}.monkey-jsonviewer .json-viewer-layout #mindBox jmnode:before{content:"";top:50%!important;margin-top:1px;position:absolute;border-radius:50%;transform:translateY(-50%);background-color:#8149bf80}.monkey-jsonviewer .json-viewer-layout #mindBox jmnode.root:before{left:50%;width:18px;height:18px;transform:translate(-18px,-50%)}.monkey-jsonviewer .json-viewer-layout #mindBox jmnode:hover{text-shadow:0px 0px 1px currentColor}.monkey-jsonviewer .json-viewer-layout #mindBox jmnode:not(.root):before{left:0;width:15px;height:15px}.monkey-jsonviewer .json-viewer-layout #mindBox jmexpander{margin-top:1px;line-height:9px}.monkey-jsonviewer .json-viewer-layout #mindBox .datatype{opacity:.6;font-size:12px;margin-top:2px;padding-left:5px}.monkey-jsonviewer .httpRequest{padding:30px 20px;width:700px}.monkey-jsonviewer .httpRequest>div{display:flex;height:35px;margin-bottom:20px}.monkey-jsonviewer .httpRequest input,.monkey-jsonviewer .httpRequest select{border-radius:0;padding-left:10px;border:1px solid #ccc}.monkey-jsonviewer .httpRequest input{flex-grow:1}.monkey-jsonviewer .httpRequest input[name=url],.monkey-jsonviewer .httpRequest input:first-child,.monkey-jsonviewer .httpRequest select{border-right:none}.monkey-jsonviewer .httpRequest button{cursor:pointer;padding:0 15px;border:1px solid #ccc}.monkey-jsonviewer .httpRequest button:active{background-color:#cfcfcf}.monkey-jsonviewer .dark-theme .json-viewer-layout li,.monkey-jsonviewer .dark-theme .json-viewer-layout pre,.monkey-jsonviewer .dark-theme .json-viewer-layout td:first-child,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout li,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout pre,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout td:first-child{color:#ccc}.monkey-jsonviewer .dark-theme .json-viewer-layout .panel,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .panel{color:#c4c4c4;background-color:#333}.monkey-jsonviewer .dark-theme .json-viewer-layout .panel>div,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .panel>div{border-bottom-color:#464646}.monkey-jsonviewer .dark-theme .json-viewer-layout .panel .tabs-item:hover,.monkey-jsonviewer .dark-theme .json-viewer-layout .panel .toolbar-item:hover,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .panel .tabs-item:hover,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .panel .toolbar-item:hover{background-color:#464646}.monkey-jsonviewer .dark-theme .json-viewer-layout .panel .tabs-item,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .panel .tabs-item{border-top-color:#333}.monkey-jsonviewer .dark-theme .json-viewer-layout .panel .tabs-item:hover,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .panel .tabs-item:hover{border-top-color:#c3c3c6}.monkey-jsonviewer .dark-theme .json-viewer-layout .panel .tabs-item.active,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .panel .tabs-item.active{color:#c4c4c4;border-top-color:#64b7ff;background-color:#464646}.monkey-jsonviewer .dark-theme .json-viewer-layout .searchbox input,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .searchbox input{color:#ccc;background-color:#464646;border-left-color:#333}.monkey-jsonviewer .dark-theme .json-viewer-layout .searchbox .clear,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .searchbox .clear{filter:invert(.8)}.monkey-jsonviewer .dark-theme .json-viewer-layout .rightbox>div span:hover,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .rightbox>div span:hover{background-color:#464646}.monkey-jsonviewer .dark-theme .json-viewer-layout .rightbox .tippy-box,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .rightbox .tippy-box{background-color:#4e4e4e!important}.monkey-jsonviewer .dark-theme .json-viewer-layout .rightbox .tippy-box .tippy-arrow,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .rightbox .tippy-box .tippy-arrow{color:#4e4e4e!important}.monkey-jsonviewer .dark-theme .json-viewer-layout .rightbox .tippy-box li,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .rightbox .tippy-box li{background-color:#4e4e4e!important}.monkey-jsonviewer .dark-theme .json-viewer-layout .rightbox .tippy-box li:hover,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .rightbox .tippy-box li:hover{background-color:#464646!important}.monkey-jsonviewer .dark-theme .json-viewer-layout .jsonp,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout .jsonp{color:#f1d700}.monkey-jsonviewer .dark-theme .json-viewer-layout jmnode,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout jmnode{filter:brightness(2)}.monkey-jsonviewer .dark-theme .json-viewer-layout jmexpander,.monkey-jsonviewer .dark-plus-theme .json-viewer-layout jmexpander{background-color:#dfdfdf}.tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{position:relative;background-color:#333;color:#fff;border-radius:4px;font-size:14px;line-height:1.4;white-space:normal;outline:0;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{bottom:-7px;left:0;border-width:8px 8px 0;border-top-color:initial;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{top:-7px;left:0;border-width:0 8px 8px;border-bottom-color:initial;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-width:8px 0 8px 8px;border-left-color:initial;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{left:-7px;border-width:8px 8px 8px 0;border-right-color:initial;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{width:16px;height:16px;color:#333}.tippy-arrow:before{content:"";position:absolute;border-color:transparent;border-style:solid}.tippy-content{position:relative;padding:5px 9px;z-index:1}.monkey-js-css-beautify body{padding-top:20px;padding-left:5px}.monkey-js-css-beautify body .beautify_checkbox{top:0;left:0;z-index:999;width:100vw;display:flex;position:fixed;padding:5px 10px;align-items:center;background-color:#f3f3f3;border-bottom:1px solid #ccc}.monkey-js-css-beautify body .beautify_checkbox label{font-size:13px}.monkey-js-css-beautify body .beautify_checkbox input[type=checkbox]{top:1.5px;width:14px;height:14px;margin-right:5px;position:relative}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#fff;color:#000}.xml .hljs-meta{color:silver}.hljs-comment,.hljs-quote{color:#007400}.hljs-attribute,.hljs-keyword,.hljs-literal,.hljs-name,.hljs-selector-tag,.hljs-tag{color:#aa0d91}.hljs-template-variable,.hljs-variable{color:#3f6e74}.hljs-code,.hljs-meta .hljs-string,.hljs-string{color:#c41a16}.hljs-link,.hljs-regexp{color:#0e0eff}.hljs-bullet,.hljs-number,.hljs-symbol,.hljs-title{color:#1c00cf}.hljs-meta,.hljs-section{color:#643820}.hljs-built_in,.hljs-class .hljs-title,.hljs-params,.hljs-title.class_,.hljs-type{color:#5c2699}.hljs-attr{color:#836c28}.hljs-subst{color:#000}.hljs-formula{background-color:#eee;font-style:italic}.hljs-addition{background-color:#baeeba}.hljs-deletion{background-color:#ffc8bd}.hljs-selector-class,.hljs-selector-id{color:#9b703f}.hljs-doctag,.hljs-strong{font-weight:700}.hljs-emphasis{font-style:italic}.json-formater-arrow{width:0;opacity:.2;display:inline-block}.json-formater-arrow:hover{opacity:.35}.json-formater-arrow:before{width:0;height:0;left:-13px;content:"";cursor:pointer;position:relative;border-style:solid;display:inline-block;vertical-align:middle;transform:rotate(90deg);border-width:5px 0 5px 8px;transition:transform .3s ease;border-color:transparent transparent transparent currentColor}.json-formater-closed .json-formater-arrow:before{transform:rotate(0)}.json-formater-placeholder{color:#ccc;cursor:pointer;font-size:12px;margin-left:.5em}.json-formater-placeholder span:hover{text-decoration:underline}.json-color{width:.75em;height:.75em;margin-right:.3em;display:inline-block;vertical-align:middle;border:1px solid #ccc}.json-comma{font-family:Courier New,monospace}.json-colon,.json-comma{margin:0 .25em 0 .1em}.json-object-bracket{color:#6d9331;font-weight:700}.json-array-bracket{color:#8e9331;font-weight:700}.default-theme .json-key{color:#910f93;cursor:pointer}.default-theme .json-string,.default-theme .json-string a{color:#2e7c16}.default-theme .json-bigint,.default-theme .json-number{color:#164ff1}.default-theme .json-boolean{color:#c41a16}.default-theme .json-null{color:#228fec}.light-theme .json-key{color:#0040cf}.light-theme .json-string,.light-theme .json-string a{color:#a31515}.light-theme .json-bigint,.light-theme .json-number{color:#0b7500}.light-theme .json-boolean{color:#00f}.light-theme .json-null{color:#05f}.dark-theme .json-colon,.dark-theme .json-comma,.dark-plus-theme .json-colon,.dark-plus-theme .json-comma{color:#ccc}.dark-theme .json-formater-arrow,.dark-plus-theme .json-formater-arrow{color:#fff;opacity:.35}.dark-theme .json-formater-arrow:hover,.dark-plus-theme .json-formater-arrow:hover{opacity:.5}.dark-theme{background-color:#252526}.dark-theme .json-object-bracket{color:#ce70d6}.dark-theme .json-array-bracket{color:#f1d700}.dark-theme .json-key{color:#9cdcfe}.dark-theme .json-string,.dark-theme .json-string a{color:#ce9178}.dark-theme .json-bigint,.dark-theme .json-number{color:#b5cea8}.dark-theme .json-boolean{color:#358cd6}.dark-theme .json-null{color:#569cd6}.dark-plus-theme{background-color:#1e1f22}.dark-plus-theme .json-object-bracket{color:#bb9667}.dark-plus-theme .json-array-bracket{color:#bbbda3}.dark-plus-theme .json-key{color:#c77dbb}.dark-plus-theme .json-string,.dark-plus-theme .json-string a{color:#6aab73}.dark-plus-theme .json-bigint,.dark-plus-theme .json-number{color:#28aab4}.dark-plus-theme .json-boolean{color:#ce8951}.dark-plus-theme .json-null{color:#c78d61}/**
  33. * @license BSD
  34. * @copyright 2014-2023 hizzgdev@163.com
  35. *
  36. * Project Home:
  37. * https://github.com/hizzgdev/jsmind/
  38. */.jsmind-inner{position:relative;overflow:auto;width:100%;height:100%;outline:none}.jsmind-inner{moz-user-select:-moz-none;-moz-user-select:none;-o-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.jsmind-inner canvas{position:absolute}svg.jsmind{position:absolute;z-index:1}canvas.jsmind{position:absolute;z-index:1}jmnodes{position:absolute;z-index:2;background-color:#0000}jmnode{position:absolute;cursor:default;max-width:400px}jmexpander{position:absolute;width:11px;height:11px;display:block;overflow:hidden;line-height:12px;font-size:10px;text-align:center;border-radius:6px;border-width:1px;border-style:solid;cursor:pointer}.jmnode-overflow-wrap jmnodes{min-width:420px}.jmnode-overflow-hidden jmnode{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}jmnode{padding:10px;background-color:#fff;color:#333;border-radius:5px;box-shadow:1px 1px 1px #666;font:16px/1.125 Verdana,Arial,Helvetica,sans-serif}jmnode:hover{box-shadow:2px 2px 8px #000;background-color:#ebebeb;color:#333}jmnode.selected{background-color:#11f;color:#fff;box-shadow:2px 2px 8px #000}jmnode.root{font-size:24px}jmexpander{border-color:gray}jmexpander:hover{border-color:#000}@media screen and (max-device-width: 1024px){jmnode{padding:5px;border-radius:3px;font-size:14px}jmnode.root{font-size:21px}}jmnodes.theme-primary jmnode{background-color:#428bca;color:#fff;border-color:#357ebd}jmnodes.theme-primary jmnode:hover{background-color:#3276b1;border-color:#285e8e}jmnodes.theme-primary jmnode.selected{background-color:#f1c40f;color:#fff}jmnodes.theme-warning jmnode{background-color:#f0ad4e;border-color:#eea236;color:#fff}jmnodes.theme-warning jmnode:hover{background-color:#ed9c28;border-color:#d58512}jmnodes.theme-warning jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-danger jmnode{background-color:#d9534f;border-color:#d43f3a;color:#fff}jmnodes.theme-danger jmnode:hover{background-color:#d2322d;border-color:#ac2925}jmnodes.theme-danger jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-success jmnode{background-color:#5cb85c;border-color:#4cae4c;color:#fff}jmnodes.theme-success jmnode:hover{background-color:#47a447;border-color:#398439}jmnodes.theme-success jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-info jmnode{background-color:#5dc0de;border-color:#46b8da;color:#fff}jmnodes.theme-info jmnode:hover{background-color:#39b3d7;border-color:#269abc}jmnodes.theme-info jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-greensea jmnode{background-color:#1abc9c;color:#fff}jmnodes.theme-greensea jmnode:hover{background-color:#16a085}jmnodes.theme-greensea jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-nephrite jmnode{background-color:#2ecc71;color:#fff}jmnodes.theme-nephrite jmnode:hover{background-color:#27ae60}jmnodes.theme-nephrite jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-belizehole jmnode{background-color:#3498db;color:#fff}jmnodes.theme-belizehole jmnode:hover{background-color:#2980b9}jmnodes.theme-belizehole jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-wisteria jmnode{background-color:#9b59b6;color:#fff}jmnodes.theme-wisteria jmnode:hover{background-color:#8e44ad}jmnodes.theme-wisteria jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-asphalt jmnode{background-color:#34495e;color:#fff}jmnodes.theme-asphalt jmnode:hover{background-color:#2c3e50}jmnodes.theme-asphalt jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-orange jmnode{background-color:#f1c40f;color:#fff}jmnodes.theme-orange jmnode:hover{background-color:#f39c12}jmnodes.theme-orange jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-pumpkin jmnode{background-color:#e67e22;color:#fff}jmnodes.theme-pumpkin jmnode:hover{background-color:#d35400}jmnodes.theme-pumpkin jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-pomegranate jmnode{background-color:#e74c3c;color:#fff}jmnodes.theme-pomegranate jmnode:hover{background-color:#c0392b}jmnodes.theme-pomegranate jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-clouds jmnode{background-color:#ecf0f1;color:#333}jmnodes.theme-clouds jmnode:hover{background-color:#bdc3c7}jmnodes.theme-clouds jmnode.selected{background-color:#11f;color:#fff}jmnodes.theme-asbestos jmnode{background-color:#95a5a6;color:#fff}jmnodes.theme-asbestos jmnode:hover{background-color:#7f8c8d}jmnodes.theme-asbestos jmnode.selected{background-color:#11f;color:#fff}.scroll-top{width:48px;height:48px;z-index:999;position:fixed;right:30px;bottom:30px;display:none;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA39JREFUaEPtmV2ITVEUx39rJjT5KPKC5DPKK6UGZZ7Eq0whNUiKFPfcKW9mnmjm7ssLaSLygEx5xItMESnKC4V8FV4IJUkyS+fMHZ07zjl3733PvT6a+3S6Z629/r+99sfa+wgpPw1YDtxLe9/k/1eI4X5STMkSokXWNlloYjgpMZSmIxPgbxBfS8M4QK0eavT78Qw0uodrtd+wDGjAMqBcEVAQw6NaYnzeNwRAi2xBOQlMrYj6jLJTygz6iMzyyR1Ai+xCGUgMqnTmDZErgBYoIJjMXhY2S4mLeWUiNwAt0INwyEqY0iNleq1saxjlAqAB64BrToKEHVLijJNPgnHdALqPaUziOsoKRzGfaKFD+nng6FdlXj+Ay9AZq1Q5L2W2/jEA3c8sWqOSe3aCiK/A3cr/K4G2FKEbxXDZF6KuDKROXKWXFvqlxJdQmBaZzDDdKZP8thhW/RmAgKfA4qrgSq+U6UkSlAostEuJOz4Q3hnQgPXAld+CCh1pB5DogKTcSBAalhpHmw1wGtgxJuhbMczJEqIBbxLmzFUxbGg2gCYE9AVADF6jwctJDzKd73xI7DG/IQQTmCFH+OiaBT+AAyykhWcpBZv7JA4bGmaRHOV5cwBqX7mc5Qe9coyX0TK6n/m0RnVSV4bA1KuTLCi/DBTYhHCpRm+Fe8Bo/b8JmJxp71lqOwNowB7guGuqLe33iuGEpW1k5gTgVDK7qIjbZmyESU1aA1TOuA99dTn5CQulxAsbH3uAeqpOGyXVNrvEcMrGzR4gIGnjsonhYzMkhg4bx3EAm17ysGlIBh4DSzzE+LgMiGG3jaPLEApv2Q7YNFq3jcOmZg9gt/u6aH8PzEx0aGWu9PHapjFrgKimCaIDTHiQqf4pNxHW2AT8ZaMEiZdgSreUKdm25QRQgRi7nIZzI7xZcPmeNkAL5xjmVpVQx1049HUGiCAKFBH6K8GjFUP3MIW2CGJpjd4bFEPnmM54grA761tYWpteAJXgy1A6w6p09Opcu1nED7ZlAcQP/BqwGZjORAblMO9sh03czhsgLZgW6EL4JoYL0b0RTArPBfFnH6G5ZyAVYKTkGBlWQVR2bxDDgvjzvwQQXqGsDQ/sGkTXKdHzOECsB3LtjdjKMjqE/qMMjJwn5olh+98+hM6gvAqXy0aN+4Yuo/HG/weAPmC1GNrzHDbxtn4Coc0pQNdM3UAAAAAASUVORK5CYII=)} `);
  39.  
  40. System.addImportMap({ imports: {"highlight.js":"user:highlight.js","beautifier":"user:beautifier","jquery":"user:jquery","jsmind":"user:jsmind"} });
  41. System.set("user:highlight.js", (()=>{const _=hljs;('default' in _)||(_.default=_);return _})());
  42. System.set("user:beautifier", (()=>{const _=beautifier;('default' in _)||(_.default=_);return _})());
  43. System.set("user:jquery", (()=>{const _=jquery;('default' in _)||(_.default=_);return _})());
  44. System.set("user:jsmind", (()=>{const _=jsmind;('default' in _)||(_.default=_);return _})());
  45.  
  46. System.register("./__entry.js", ['./__monkey.entry-DSLwfYjn.js'], (function (exports, module) {
  47. 'use strict';
  48. return {
  49. setters: [null],
  50. execute: (function () {
  51.  
  52.  
  53.  
  54. })
  55. };
  56. }));
  57.  
  58. System.register("./__monkey.entry-DSLwfYjn.js", [], (function (exports, module) {
  59. 'use strict';
  60. return {
  61. execute: (function () {
  62.  
  63. const scriptRel = function detectScriptRel() {
  64. const relList = typeof document !== "undefined" && document.createElement("link").relList;
  65. return relList && relList.supports && relList.supports("modulepreload") ? "modulepreload" : "preload";
  66. }();
  67. const assetsURL = function(dep) {
  68. return "/" + dep;
  69. };
  70. const seen = {};
  71. const __vitePreload = function preload(baseModule, deps, importerUrl) {
  72. let promise = Promise.resolve();
  73. if (deps && deps.length > 0) {
  74. document.getElementsByTagName("link");
  75. const cspNonceMeta = document.querySelector(
  76. "meta[property=csp-nonce]"
  77. );
  78. const cspNonce = (cspNonceMeta == null ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta == null ? void 0 : cspNonceMeta.getAttribute("nonce"));
  79. promise = Promise.allSettled(
  80. deps.map((dep) => {
  81. dep = assetsURL(dep);
  82. if (dep in seen) return;
  83. seen[dep] = true;
  84. const isCss = dep.endsWith(".css");
  85. const cssSelector = isCss ? '[rel="stylesheet"]' : "";
  86. if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) {
  87. return;
  88. }
  89. const link = document.createElement("link");
  90. link.rel = isCss ? "stylesheet" : scriptRel;
  91. if (!isCss) {
  92. link.as = "script";
  93. }
  94. link.crossOrigin = "";
  95. link.href = dep;
  96. if (cspNonce) {
  97. link.setAttribute("nonce", cspNonce);
  98. }
  99. document.head.appendChild(link);
  100. if (isCss) {
  101. return new Promise((res, rej) => {
  102. link.addEventListener("load", res);
  103. link.addEventListener(
  104. "error",
  105. () => rej(new Error(`Unable to preload CSS for ${dep}`))
  106. );
  107. });
  108. }
  109. })
  110. );
  111. }
  112. function handlePreloadError(err) {
  113. const e = new Event("vite:preloadError", {
  114. cancelable: true
  115. });
  116. e.payload = err;
  117. window.dispatchEvent(e);
  118. if (!e.defaultPrevented) {
  119. throw err;
  120. }
  121. }
  122. return promise.then((res) => {
  123. for (const item of res || []) {
  124. if (item.status !== "rejected") continue;
  125. handlePreloadError(item.reason);
  126. }
  127. return baseModule().catch(handlePreloadError);
  128. });
  129. };
  130. var commonjsGlobal = exports("d", typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {});
  131. function getDefaultExportFromCjs(x) {
  132. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
  133. }
  134. var jsonBigint = { exports: {} };
  135. var stringify = { exports: {} };
  136. var bignumber = { exports: {} };
  137. (function(module) {
  138. (function(globalObject) {
  139. var BigNumber2, isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, mathceil = Math.ceil, mathfloor = Math.floor, bignumberError = "[BigNumber Error] ", tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ", BASE = 1e14, LOG_BASE = 14, MAX_SAFE_INTEGER = 9007199254740991, POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], SQRT_BASE = 1e7, MAX = 1e9;
  140. function clone(configObject) {
  141. var div, convertBase, parseNumeric, P = BigNumber3.prototype = { constructor: BigNumber3, toString: null, valueOf: null }, ONE = new BigNumber3(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
  142. prefix: "",
  143. groupSize: 3,
  144. secondaryGroupSize: 0,
  145. groupSeparator: ",",
  146. decimalSeparator: ".",
  147. fractionGroupSize: 0,
  148. fractionGroupSeparator: " ",
  149. // non-breaking space
  150. suffix: ""
  151. }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
  152. function BigNumber3(v, b) {
  153. var alphabet, c, caseChanged, e, i, isNum, len, str, x = this;
  154. if (!(x instanceof BigNumber3)) return new BigNumber3(v, b);
  155. if (b == null) {
  156. if (v && v._isBigNumber === true) {
  157. x.s = v.s;
  158. if (!v.c || v.e > MAX_EXP) {
  159. x.c = x.e = null;
  160. } else if (v.e < MIN_EXP) {
  161. x.c = [x.e = 0];
  162. } else {
  163. x.e = v.e;
  164. x.c = v.c.slice();
  165. }
  166. return;
  167. }
  168. if ((isNum = typeof v == "number") && v * 0 == 0) {
  169. x.s = 1 / v < 0 ? (v = -v, -1) : 1;
  170. if (v === ~~v) {
  171. for (e = 0, i = v; i >= 10; i /= 10, e++) ;
  172. if (e > MAX_EXP) {
  173. x.c = x.e = null;
  174. } else {
  175. x.e = e;
  176. x.c = [v];
  177. }
  178. return;
  179. }
  180. str = String(v);
  181. } else {
  182. if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
  183. x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
  184. }
  185. if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
  186. if ((i = str.search(/e/i)) > 0) {
  187. if (e < 0) e = i;
  188. e += +str.slice(i + 1);
  189. str = str.substring(0, i);
  190. } else if (e < 0) {
  191. e = str.length;
  192. }
  193. } else {
  194. intCheck(b, 2, ALPHABET.length, "Base");
  195. if (b == 10 && alphabetHasNormalDecimalDigits) {
  196. x = new BigNumber3(v);
  197. return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
  198. }
  199. str = String(v);
  200. if (isNum = typeof v == "number") {
  201. if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
  202. x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
  203. if (BigNumber3.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
  204. throw Error(tooManyDigits + v);
  205. }
  206. } else {
  207. x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
  208. }
  209. alphabet = ALPHABET.slice(0, b);
  210. e = i = 0;
  211. for (len = str.length; i < len; i++) {
  212. if (alphabet.indexOf(c = str.charAt(i)) < 0) {
  213. if (c == ".") {
  214. if (i > e) {
  215. e = len;
  216. continue;
  217. }
  218. } else if (!caseChanged) {
  219. if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
  220. caseChanged = true;
  221. i = -1;
  222. e = 0;
  223. continue;
  224. }
  225. }
  226. return parseNumeric(x, String(v), isNum, b);
  227. }
  228. }
  229. isNum = false;
  230. str = convertBase(str, b, 10, x.s);
  231. if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
  232. else e = str.length;
  233. }
  234. for (i = 0; str.charCodeAt(i) === 48; i++) ;
  235. for (len = str.length; str.charCodeAt(--len) === 48; ) ;
  236. if (str = str.slice(i, ++len)) {
  237. len -= i;
  238. if (isNum && BigNumber3.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
  239. throw Error(tooManyDigits + x.s * v);
  240. }
  241. if ((e = e - i - 1) > MAX_EXP) {
  242. x.c = x.e = null;
  243. } else if (e < MIN_EXP) {
  244. x.c = [x.e = 0];
  245. } else {
  246. x.e = e;
  247. x.c = [];
  248. i = (e + 1) % LOG_BASE;
  249. if (e < 0) i += LOG_BASE;
  250. if (i < len) {
  251. if (i) x.c.push(+str.slice(0, i));
  252. for (len -= LOG_BASE; i < len; ) {
  253. x.c.push(+str.slice(i, i += LOG_BASE));
  254. }
  255. i = LOG_BASE - (str = str.slice(i)).length;
  256. } else {
  257. i -= len;
  258. }
  259. for (; i--; str += "0") ;
  260. x.c.push(+str);
  261. }
  262. } else {
  263. x.c = [x.e = 0];
  264. }
  265. }
  266. BigNumber3.clone = clone;
  267. BigNumber3.ROUND_UP = 0;
  268. BigNumber3.ROUND_DOWN = 1;
  269. BigNumber3.ROUND_CEIL = 2;
  270. BigNumber3.ROUND_FLOOR = 3;
  271. BigNumber3.ROUND_HALF_UP = 4;
  272. BigNumber3.ROUND_HALF_DOWN = 5;
  273. BigNumber3.ROUND_HALF_EVEN = 6;
  274. BigNumber3.ROUND_HALF_CEIL = 7;
  275. BigNumber3.ROUND_HALF_FLOOR = 8;
  276. BigNumber3.EUCLID = 9;
  277. BigNumber3.config = BigNumber3.set = function(obj) {
  278. var p, v;
  279. if (obj != null) {
  280. if (typeof obj == "object") {
  281. if (obj.hasOwnProperty(p = "DECIMAL_PLACES")) {
  282. v = obj[p];
  283. intCheck(v, 0, MAX, p);
  284. DECIMAL_PLACES = v;
  285. }
  286. if (obj.hasOwnProperty(p = "ROUNDING_MODE")) {
  287. v = obj[p];
  288. intCheck(v, 0, 8, p);
  289. ROUNDING_MODE = v;
  290. }
  291. if (obj.hasOwnProperty(p = "EXPONENTIAL_AT")) {
  292. v = obj[p];
  293. if (v && v.pop) {
  294. intCheck(v[0], -MAX, 0, p);
  295. intCheck(v[1], 0, MAX, p);
  296. TO_EXP_NEG = v[0];
  297. TO_EXP_POS = v[1];
  298. } else {
  299. intCheck(v, -MAX, MAX, p);
  300. TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
  301. }
  302. }
  303. if (obj.hasOwnProperty(p = "RANGE")) {
  304. v = obj[p];
  305. if (v && v.pop) {
  306. intCheck(v[0], -MAX, -1, p);
  307. intCheck(v[1], 1, MAX, p);
  308. MIN_EXP = v[0];
  309. MAX_EXP = v[1];
  310. } else {
  311. intCheck(v, -MAX, MAX, p);
  312. if (v) {
  313. MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
  314. } else {
  315. throw Error(bignumberError + p + " cannot be zero: " + v);
  316. }
  317. }
  318. }
  319. if (obj.hasOwnProperty(p = "CRYPTO")) {
  320. v = obj[p];
  321. if (v === !!v) {
  322. if (v) {
  323. if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
  324. CRYPTO = v;
  325. } else {
  326. CRYPTO = !v;
  327. throw Error(bignumberError + "crypto unavailable");
  328. }
  329. } else {
  330. CRYPTO = v;
  331. }
  332. } else {
  333. throw Error(bignumberError + p + " not true or false: " + v);
  334. }
  335. }
  336. if (obj.hasOwnProperty(p = "MODULO_MODE")) {
  337. v = obj[p];
  338. intCheck(v, 0, 9, p);
  339. MODULO_MODE = v;
  340. }
  341. if (obj.hasOwnProperty(p = "POW_PRECISION")) {
  342. v = obj[p];
  343. intCheck(v, 0, MAX, p);
  344. POW_PRECISION = v;
  345. }
  346. if (obj.hasOwnProperty(p = "FORMAT")) {
  347. v = obj[p];
  348. if (typeof v == "object") FORMAT = v;
  349. else throw Error(bignumberError + p + " not an object: " + v);
  350. }
  351. if (obj.hasOwnProperty(p = "ALPHABET")) {
  352. v = obj[p];
  353. if (typeof v == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
  354. alphabetHasNormalDecimalDigits = v.slice(0, 10) == "0123456789";
  355. ALPHABET = v;
  356. } else {
  357. throw Error(bignumberError + p + " invalid: " + v);
  358. }
  359. }
  360. } else {
  361. throw Error(bignumberError + "Object expected: " + obj);
  362. }
  363. }
  364. return {
  365. DECIMAL_PLACES,
  366. ROUNDING_MODE,
  367. EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
  368. RANGE: [MIN_EXP, MAX_EXP],
  369. CRYPTO,
  370. MODULO_MODE,
  371. POW_PRECISION,
  372. FORMAT,
  373. ALPHABET
  374. };
  375. };
  376. BigNumber3.isBigNumber = function(v) {
  377. if (!v || v._isBigNumber !== true) return false;
  378. if (!BigNumber3.DEBUG) return true;
  379. var i, n, c = v.c, e = v.e, s = v.s;
  380. out: if ({}.toString.call(c) == "[object Array]") {
  381. if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
  382. if (c[0] === 0) {
  383. if (e === 0 && c.length === 1) return true;
  384. break out;
  385. }
  386. i = (e + 1) % LOG_BASE;
  387. if (i < 1) i += LOG_BASE;
  388. if (String(c[0]).length == i) {
  389. for (i = 0; i < c.length; i++) {
  390. n = c[i];
  391. if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
  392. }
  393. if (n !== 0) return true;
  394. }
  395. }
  396. } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
  397. return true;
  398. }
  399. throw Error(bignumberError + "Invalid BigNumber: " + v);
  400. };
  401. BigNumber3.maximum = BigNumber3.max = function() {
  402. return maxOrMin(arguments, -1);
  403. };
  404. BigNumber3.minimum = BigNumber3.min = function() {
  405. return maxOrMin(arguments, 1);
  406. };
  407. BigNumber3.random = function() {
  408. var pow2_53 = 9007199254740992;
  409. var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
  410. return mathfloor(Math.random() * pow2_53);
  411. } : function() {
  412. return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
  413. };
  414. return function(dp) {
  415. var a, b, e, k, v, i = 0, c = [], rand = new BigNumber3(ONE);
  416. if (dp == null) dp = DECIMAL_PLACES;
  417. else intCheck(dp, 0, MAX);
  418. k = mathceil(dp / LOG_BASE);
  419. if (CRYPTO) {
  420. if (crypto.getRandomValues) {
  421. a = crypto.getRandomValues(new Uint32Array(k *= 2));
  422. for (; i < k; ) {
  423. v = a[i] * 131072 + (a[i + 1] >>> 11);
  424. if (v >= 9e15) {
  425. b = crypto.getRandomValues(new Uint32Array(2));
  426. a[i] = b[0];
  427. a[i + 1] = b[1];
  428. } else {
  429. c.push(v % 1e14);
  430. i += 2;
  431. }
  432. }
  433. i = k / 2;
  434. } else if (crypto.randomBytes) {
  435. a = crypto.randomBytes(k *= 7);
  436. for (; i < k; ) {
  437. v = (a[i] & 31) * 281474976710656 + a[i + 1] * 1099511627776 + a[i + 2] * 4294967296 + a[i + 3] * 16777216 + (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
  438. if (v >= 9e15) {
  439. crypto.randomBytes(7).copy(a, i);
  440. } else {
  441. c.push(v % 1e14);
  442. i += 7;
  443. }
  444. }
  445. i = k / 7;
  446. } else {
  447. CRYPTO = false;
  448. throw Error(bignumberError + "crypto unavailable");
  449. }
  450. }
  451. if (!CRYPTO) {
  452. for (; i < k; ) {
  453. v = random53bitInt();
  454. if (v < 9e15) c[i++] = v % 1e14;
  455. }
  456. }
  457. k = c[--i];
  458. dp %= LOG_BASE;
  459. if (k && dp) {
  460. v = POWS_TEN[LOG_BASE - dp];
  461. c[i] = mathfloor(k / v) * v;
  462. }
  463. for (; c[i] === 0; c.pop(), i--) ;
  464. if (i < 0) {
  465. c = [e = 0];
  466. } else {
  467. for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE) ;
  468. for (i = 1, v = c[0]; v >= 10; v /= 10, i++) ;
  469. if (i < LOG_BASE) e -= LOG_BASE - i;
  470. }
  471. rand.e = e;
  472. rand.c = c;
  473. return rand;
  474. };
  475. }();
  476. BigNumber3.sum = function() {
  477. var i = 1, args = arguments, sum = new BigNumber3(args[0]);
  478. for (; i < args.length; ) sum = sum.plus(args[i++]);
  479. return sum;
  480. };
  481. convertBase = /* @__PURE__ */ function() {
  482. var decimal = "0123456789";
  483. function toBaseOut(str, baseIn, baseOut, alphabet) {
  484. var j, arr = [0], arrL, i = 0, len = str.length;
  485. for (; i < len; ) {
  486. for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) ;
  487. arr[0] += alphabet.indexOf(str.charAt(i++));
  488. for (j = 0; j < arr.length; j++) {
  489. if (arr[j] > baseOut - 1) {
  490. if (arr[j + 1] == null) arr[j + 1] = 0;
  491. arr[j + 1] += arr[j] / baseOut | 0;
  492. arr[j] %= baseOut;
  493. }
  494. }
  495. }
  496. return arr.reverse();
  497. }
  498. return function(str, baseIn, baseOut, sign, callerIsToString) {
  499. var alphabet, d, e, k, r, x, xc, y, i = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
  500. if (i >= 0) {
  501. k = POW_PRECISION;
  502. POW_PRECISION = 0;
  503. str = str.replace(".", "");
  504. y = new BigNumber3(baseIn);
  505. x = y.pow(str.length - i);
  506. POW_PRECISION = k;
  507. y.c = toBaseOut(
  508. toFixedPoint(coeffToString(x.c), x.e, "0"),
  509. 10,
  510. baseOut,
  511. decimal
  512. );
  513. y.e = y.c.length;
  514. }
  515. xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
  516. e = k = xc.length;
  517. for (; xc[--k] == 0; xc.pop()) ;
  518. if (!xc[0]) return alphabet.charAt(0);
  519. if (i < 0) {
  520. --e;
  521. } else {
  522. x.c = xc;
  523. x.e = e;
  524. x.s = sign;
  525. x = div(x, y, dp, rm, baseOut);
  526. xc = x.c;
  527. r = x.r;
  528. e = x.e;
  529. }
  530. d = e + dp + 1;
  531. i = xc[d];
  532. k = baseOut / 2;
  533. r = r || d < 0 || xc[d + 1] != null;
  534. r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : i > k || i == k && (rm == 4 || r || rm == 6 && xc[d - 1] & 1 || rm == (x.s < 0 ? 8 : 7));
  535. if (d < 1 || !xc[0]) {
  536. str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
  537. } else {
  538. xc.length = d;
  539. if (r) {
  540. for (--baseOut; ++xc[--d] > baseOut; ) {
  541. xc[d] = 0;
  542. if (!d) {
  543. ++e;
  544. xc = [1].concat(xc);
  545. }
  546. }
  547. }
  548. for (k = xc.length; !xc[--k]; ) ;
  549. for (i = 0, str = ""; i <= k; str += alphabet.charAt(xc[i++])) ;
  550. str = toFixedPoint(str, e, alphabet.charAt(0));
  551. }
  552. return str;
  553. };
  554. }();
  555. div = /* @__PURE__ */ function() {
  556. function multiply(x, k, base) {
  557. var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
  558. for (x = x.slice(); i--; ) {
  559. xlo = x[i] % SQRT_BASE;
  560. xhi = x[i] / SQRT_BASE | 0;
  561. m = khi * xlo + xhi * klo;
  562. temp = klo * xlo + m % SQRT_BASE * SQRT_BASE + carry;
  563. carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
  564. x[i] = temp % base;
  565. }
  566. if (carry) x = [carry].concat(x);
  567. return x;
  568. }
  569. function compare2(a, b, aL, bL) {
  570. var i, cmp;
  571. if (aL != bL) {
  572. cmp = aL > bL ? 1 : -1;
  573. } else {
  574. for (i = cmp = 0; i < aL; i++) {
  575. if (a[i] != b[i]) {
  576. cmp = a[i] > b[i] ? 1 : -1;
  577. break;
  578. }
  579. }
  580. }
  581. return cmp;
  582. }
  583. function subtract(a, b, aL, base) {
  584. var i = 0;
  585. for (; aL--; ) {
  586. a[aL] -= i;
  587. i = a[aL] < b[aL] ? 1 : 0;
  588. a[aL] = i * base + a[aL] - b[aL];
  589. }
  590. for (; !a[0] && a.length > 1; a.splice(0, 1)) ;
  591. }
  592. return function(x, y, dp, rm, base) {
  593. var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, yL, yz, s = x.s == y.s ? 1 : -1, xc = x.c, yc = y.c;
  594. if (!xc || !xc[0] || !yc || !yc[0]) {
  595. return new BigNumber3(
  596. // Return NaN if either NaN, or both Infinity or 0.
  597. !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
  598. // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
  599. xc && xc[0] == 0 || !yc ? s * 0 : s / 0
  600. )
  601. );
  602. }
  603. q = new BigNumber3(s);
  604. qc = q.c = [];
  605. e = x.e - y.e;
  606. s = dp + e + 1;
  607. if (!base) {
  608. base = BASE;
  609. e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
  610. s = s / LOG_BASE | 0;
  611. }
  612. for (i = 0; yc[i] == (xc[i] || 0); i++) ;
  613. if (yc[i] > (xc[i] || 0)) e--;
  614. if (s < 0) {
  615. qc.push(1);
  616. more = true;
  617. } else {
  618. xL = xc.length;
  619. yL = yc.length;
  620. i = 0;
  621. s += 2;
  622. n = mathfloor(base / (yc[0] + 1));
  623. if (n > 1) {
  624. yc = multiply(yc, n, base);
  625. xc = multiply(xc, n, base);
  626. yL = yc.length;
  627. xL = xc.length;
  628. }
  629. xi = yL;
  630. rem = xc.slice(0, yL);
  631. remL = rem.length;
  632. for (; remL < yL; rem[remL++] = 0) ;
  633. yz = yc.slice();
  634. yz = [0].concat(yz);
  635. yc0 = yc[0];
  636. if (yc[1] >= base / 2) yc0++;
  637. do {
  638. n = 0;
  639. cmp = compare2(yc, rem, yL, remL);
  640. if (cmp < 0) {
  641. rem0 = rem[0];
  642. if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
  643. n = mathfloor(rem0 / yc0);
  644. if (n > 1) {
  645. if (n >= base) n = base - 1;
  646. prod = multiply(yc, n, base);
  647. prodL = prod.length;
  648. remL = rem.length;
  649. while (compare2(prod, rem, prodL, remL) == 1) {
  650. n--;
  651. subtract(prod, yL < prodL ? yz : yc, prodL, base);
  652. prodL = prod.length;
  653. cmp = 1;
  654. }
  655. } else {
  656. if (n == 0) {
  657. cmp = n = 1;
  658. }
  659. prod = yc.slice();
  660. prodL = prod.length;
  661. }
  662. if (prodL < remL) prod = [0].concat(prod);
  663. subtract(rem, prod, remL, base);
  664. remL = rem.length;
  665. if (cmp == -1) {
  666. while (compare2(yc, rem, yL, remL) < 1) {
  667. n++;
  668. subtract(rem, yL < remL ? yz : yc, remL, base);
  669. remL = rem.length;
  670. }
  671. }
  672. } else if (cmp === 0) {
  673. n++;
  674. rem = [0];
  675. }
  676. qc[i++] = n;
  677. if (rem[0]) {
  678. rem[remL++] = xc[xi] || 0;
  679. } else {
  680. rem = [xc[xi]];
  681. remL = 1;
  682. }
  683. } while ((xi++ < xL || rem[0] != null) && s--);
  684. more = rem[0] != null;
  685. if (!qc[0]) qc.splice(0, 1);
  686. }
  687. if (base == BASE) {
  688. for (i = 1, s = qc[0]; s >= 10; s /= 10, i++) ;
  689. round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
  690. } else {
  691. q.e = e;
  692. q.r = +more;
  693. }
  694. return q;
  695. };
  696. }();
  697. function format(n, i, rm, id) {
  698. var c0, e, ne, len, str;
  699. if (rm == null) rm = ROUNDING_MODE;
  700. else intCheck(rm, 0, 8);
  701. if (!n.c) return n.toString();
  702. c0 = n.c[0];
  703. ne = n.e;
  704. if (i == null) {
  705. str = coeffToString(n.c);
  706. str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) ? toExponential(str, ne) : toFixedPoint(str, ne, "0");
  707. } else {
  708. n = round(new BigNumber3(n), i, rm);
  709. e = n.e;
  710. str = coeffToString(n.c);
  711. len = str.length;
  712. if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
  713. for (; len < i; str += "0", len++) ;
  714. str = toExponential(str, e);
  715. } else {
  716. i -= ne;
  717. str = toFixedPoint(str, e, "0");
  718. if (e + 1 > len) {
  719. if (--i > 0) for (str += "."; i--; str += "0") ;
  720. } else {
  721. i += e - len;
  722. if (i > 0) {
  723. if (e + 1 == len) str += ".";
  724. for (; i--; str += "0") ;
  725. }
  726. }
  727. }
  728. }
  729. return n.s < 0 && c0 ? "-" + str : str;
  730. }
  731. function maxOrMin(args, n) {
  732. var k, y, i = 1, x = new BigNumber3(args[0]);
  733. for (; i < args.length; i++) {
  734. y = new BigNumber3(args[i]);
  735. if (!y.s || (k = compare(x, y)) === n || k === 0 && x.s === n) {
  736. x = y;
  737. }
  738. }
  739. return x;
  740. }
  741. function normalise(n, c, e) {
  742. var i = 1, j = c.length;
  743. for (; !c[--j]; c.pop()) ;
  744. for (j = c[0]; j >= 10; j /= 10, i++) ;
  745. if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
  746. n.c = n.e = null;
  747. } else if (e < MIN_EXP) {
  748. n.c = [n.e = 0];
  749. } else {
  750. n.e = e;
  751. n.c = c;
  752. }
  753. return n;
  754. }
  755. parseNumeric = /* @__PURE__ */ function() {
  756. var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
  757. return function(x, str, isNum, b) {
  758. var base, s = isNum ? str : str.replace(whitespaceOrPlus, "");
  759. if (isInfinityOrNaN.test(s)) {
  760. x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
  761. } else {
  762. if (!isNum) {
  763. s = s.replace(basePrefix, function(m, p1, p2) {
  764. base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
  765. return !b || b == base ? p1 : m;
  766. });
  767. if (b) {
  768. base = b;
  769. s = s.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
  770. }
  771. if (str != s) return new BigNumber3(s, base);
  772. }
  773. if (BigNumber3.DEBUG) {
  774. throw Error(bignumberError + "Not a" + (b ? " base " + b : "") + " number: " + str);
  775. }
  776. x.s = null;
  777. }
  778. x.c = x.e = null;
  779. };
  780. }();
  781. function round(x, sd, rm, r) {
  782. var d, i, j, k, n, ni, rd, xc = x.c, pows10 = POWS_TEN;
  783. if (xc) {
  784. out: {
  785. for (d = 1, k = xc[0]; k >= 10; k /= 10, d++) ;
  786. i = sd - d;
  787. if (i < 0) {
  788. i += LOG_BASE;
  789. j = sd;
  790. n = xc[ni = 0];
  791. rd = mathfloor(n / pows10[d - j - 1] % 10);
  792. } else {
  793. ni = mathceil((i + 1) / LOG_BASE);
  794. if (ni >= xc.length) {
  795. if (r) {
  796. for (; xc.length <= ni; xc.push(0)) ;
  797. n = rd = 0;
  798. d = 1;
  799. i %= LOG_BASE;
  800. j = i - LOG_BASE + 1;
  801. } else {
  802. break out;
  803. }
  804. } else {
  805. n = k = xc[ni];
  806. for (d = 1; k >= 10; k /= 10, d++) ;
  807. i %= LOG_BASE;
  808. j = i - LOG_BASE + d;
  809. rd = j < 0 ? 0 : mathfloor(n / pows10[d - j - 1] % 10);
  810. }
  811. }
  812. r = r || sd < 0 || // Are there any non-zero digits after the rounding digit?
  813. // The expression n % pows10[d - j - 1] returns all digits of n to the right
  814. // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
  815. xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
  816. r = rm < 4 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
  817. (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
  818. if (sd < 1 || !xc[0]) {
  819. xc.length = 0;
  820. if (r) {
  821. sd -= x.e + 1;
  822. xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
  823. x.e = -sd || 0;
  824. } else {
  825. xc[0] = x.e = 0;
  826. }
  827. return x;
  828. }
  829. if (i == 0) {
  830. xc.length = ni;
  831. k = 1;
  832. ni--;
  833. } else {
  834. xc.length = ni + 1;
  835. k = pows10[LOG_BASE - i];
  836. xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
  837. }
  838. if (r) {
  839. for (; ; ) {
  840. if (ni == 0) {
  841. for (i = 1, j = xc[0]; j >= 10; j /= 10, i++) ;
  842. j = xc[0] += k;
  843. for (k = 1; j >= 10; j /= 10, k++) ;
  844. if (i != k) {
  845. x.e++;
  846. if (xc[0] == BASE) xc[0] = 1;
  847. }
  848. break;
  849. } else {
  850. xc[ni] += k;
  851. if (xc[ni] != BASE) break;
  852. xc[ni--] = 0;
  853. k = 1;
  854. }
  855. }
  856. }
  857. for (i = xc.length; xc[--i] === 0; xc.pop()) ;
  858. }
  859. if (x.e > MAX_EXP) {
  860. x.c = x.e = null;
  861. } else if (x.e < MIN_EXP) {
  862. x.c = [x.e = 0];
  863. }
  864. }
  865. return x;
  866. }
  867. function valueOf(n) {
  868. var str, e = n.e;
  869. if (e === null) return n.toString();
  870. str = coeffToString(n.c);
  871. str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(str, e) : toFixedPoint(str, e, "0");
  872. return n.s < 0 ? "-" + str : str;
  873. }
  874. P.absoluteValue = P.abs = function() {
  875. var x = new BigNumber3(this);
  876. if (x.s < 0) x.s = 1;
  877. return x;
  878. };
  879. P.comparedTo = function(y, b) {
  880. return compare(this, new BigNumber3(y, b));
  881. };
  882. P.decimalPlaces = P.dp = function(dp, rm) {
  883. var c, n, v, x = this;
  884. if (dp != null) {
  885. intCheck(dp, 0, MAX);
  886. if (rm == null) rm = ROUNDING_MODE;
  887. else intCheck(rm, 0, 8);
  888. return round(new BigNumber3(x), dp + x.e + 1, rm);
  889. }
  890. if (!(c = x.c)) return null;
  891. n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
  892. if (v = c[v]) for (; v % 10 == 0; v /= 10, n--) ;
  893. if (n < 0) n = 0;
  894. return n;
  895. };
  896. P.dividedBy = P.div = function(y, b) {
  897. return div(this, new BigNumber3(y, b), DECIMAL_PLACES, ROUNDING_MODE);
  898. };
  899. P.dividedToIntegerBy = P.idiv = function(y, b) {
  900. return div(this, new BigNumber3(y, b), 0, 1);
  901. };
  902. P.exponentiatedBy = P.pow = function(n, m) {
  903. var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, x = this;
  904. n = new BigNumber3(n);
  905. if (n.c && !n.isInteger()) {
  906. throw Error(bignumberError + "Exponent not an integer: " + valueOf(n));
  907. }
  908. if (m != null) m = new BigNumber3(m);
  909. nIsBig = n.e > 14;
  910. if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
  911. y = new BigNumber3(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
  912. return m ? y.mod(m) : y;
  913. }
  914. nIsNeg = n.s < 0;
  915. if (m) {
  916. if (m.c ? !m.c[0] : !m.s) return new BigNumber3(NaN);
  917. isModExp = !nIsNeg && x.isInteger() && m.isInteger();
  918. if (isModExp) x = x.mod(m);
  919. } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
  920. k = x.s < 0 && isOdd(n) ? -0 : 0;
  921. if (x.e > -1) k = 1 / k;
  922. return new BigNumber3(nIsNeg ? 1 / k : k);
  923. } else if (POW_PRECISION) {
  924. k = mathceil(POW_PRECISION / LOG_BASE + 2);
  925. }
  926. if (nIsBig) {
  927. half = new BigNumber3(0.5);
  928. if (nIsNeg) n.s = 1;
  929. nIsOdd = isOdd(n);
  930. } else {
  931. i = Math.abs(+valueOf(n));
  932. nIsOdd = i % 2;
  933. }
  934. y = new BigNumber3(ONE);
  935. for (; ; ) {
  936. if (nIsOdd) {
  937. y = y.times(x);
  938. if (!y.c) break;
  939. if (k) {
  940. if (y.c.length > k) y.c.length = k;
  941. } else if (isModExp) {
  942. y = y.mod(m);
  943. }
  944. }
  945. if (i) {
  946. i = mathfloor(i / 2);
  947. if (i === 0) break;
  948. nIsOdd = i % 2;
  949. } else {
  950. n = n.times(half);
  951. round(n, n.e + 1, 1);
  952. if (n.e > 14) {
  953. nIsOdd = isOdd(n);
  954. } else {
  955. i = +valueOf(n);
  956. if (i === 0) break;
  957. nIsOdd = i % 2;
  958. }
  959. }
  960. x = x.times(x);
  961. if (k) {
  962. if (x.c && x.c.length > k) x.c.length = k;
  963. } else if (isModExp) {
  964. x = x.mod(m);
  965. }
  966. }
  967. if (isModExp) return y;
  968. if (nIsNeg) y = ONE.div(y);
  969. return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
  970. };
  971. P.integerValue = function(rm) {
  972. var n = new BigNumber3(this);
  973. if (rm == null) rm = ROUNDING_MODE;
  974. else intCheck(rm, 0, 8);
  975. return round(n, n.e + 1, rm);
  976. };
  977. P.isEqualTo = P.eq = function(y, b) {
  978. return compare(this, new BigNumber3(y, b)) === 0;
  979. };
  980. P.isFinite = function() {
  981. return !!this.c;
  982. };
  983. P.isGreaterThan = P.gt = function(y, b) {
  984. return compare(this, new BigNumber3(y, b)) > 0;
  985. };
  986. P.isGreaterThanOrEqualTo = P.gte = function(y, b) {
  987. return (b = compare(this, new BigNumber3(y, b))) === 1 || b === 0;
  988. };
  989. P.isInteger = function() {
  990. return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
  991. };
  992. P.isLessThan = P.lt = function(y, b) {
  993. return compare(this, new BigNumber3(y, b)) < 0;
  994. };
  995. P.isLessThanOrEqualTo = P.lte = function(y, b) {
  996. return (b = compare(this, new BigNumber3(y, b))) === -1 || b === 0;
  997. };
  998. P.isNaN = function() {
  999. return !this.s;
  1000. };
  1001. P.isNegative = function() {
  1002. return this.s < 0;
  1003. };
  1004. P.isPositive = function() {
  1005. return this.s > 0;
  1006. };
  1007. P.isZero = function() {
  1008. return !!this.c && this.c[0] == 0;
  1009. };
  1010. P.minus = function(y, b) {
  1011. var i, j, t, xLTy, x = this, a = x.s;
  1012. y = new BigNumber3(y, b);
  1013. b = y.s;
  1014. if (!a || !b) return new BigNumber3(NaN);
  1015. if (a != b) {
  1016. y.s = -b;
  1017. return x.plus(y);
  1018. }
  1019. var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
  1020. if (!xe || !ye) {
  1021. if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber3(yc ? x : NaN);
  1022. if (!xc[0] || !yc[0]) {
  1023. return yc[0] ? (y.s = -b, y) : new BigNumber3(xc[0] ? x : (
  1024. // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
  1025. ROUNDING_MODE == 3 ? -0 : 0
  1026. ));
  1027. }
  1028. }
  1029. xe = bitFloor(xe);
  1030. ye = bitFloor(ye);
  1031. xc = xc.slice();
  1032. if (a = xe - ye) {
  1033. if (xLTy = a < 0) {
  1034. a = -a;
  1035. t = xc;
  1036. } else {
  1037. ye = xe;
  1038. t = yc;
  1039. }
  1040. t.reverse();
  1041. for (b = a; b--; t.push(0)) ;
  1042. t.reverse();
  1043. } else {
  1044. j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
  1045. for (a = b = 0; b < j; b++) {
  1046. if (xc[b] != yc[b]) {
  1047. xLTy = xc[b] < yc[b];
  1048. break;
  1049. }
  1050. }
  1051. }
  1052. if (xLTy) {
  1053. t = xc;
  1054. xc = yc;
  1055. yc = t;
  1056. y.s = -y.s;
  1057. }
  1058. b = (j = yc.length) - (i = xc.length);
  1059. if (b > 0) for (; b--; xc[i++] = 0) ;
  1060. b = BASE - 1;
  1061. for (; j > a; ) {
  1062. if (xc[--j] < yc[j]) {
  1063. for (i = j; i && !xc[--i]; xc[i] = b) ;
  1064. --xc[i];
  1065. xc[j] += BASE;
  1066. }
  1067. xc[j] -= yc[j];
  1068. }
  1069. for (; xc[0] == 0; xc.splice(0, 1), --ye) ;
  1070. if (!xc[0]) {
  1071. y.s = ROUNDING_MODE == 3 ? -1 : 1;
  1072. y.c = [y.e = 0];
  1073. return y;
  1074. }
  1075. return normalise(y, xc, ye);
  1076. };
  1077. P.modulo = P.mod = function(y, b) {
  1078. var q, s, x = this;
  1079. y = new BigNumber3(y, b);
  1080. if (!x.c || !y.s || y.c && !y.c[0]) {
  1081. return new BigNumber3(NaN);
  1082. } else if (!y.c || x.c && !x.c[0]) {
  1083. return new BigNumber3(x);
  1084. }
  1085. if (MODULO_MODE == 9) {
  1086. s = y.s;
  1087. y.s = 1;
  1088. q = div(x, y, 0, 3);
  1089. y.s = s;
  1090. q.s *= s;
  1091. } else {
  1092. q = div(x, y, 0, MODULO_MODE);
  1093. }
  1094. y = x.minus(q.times(y));
  1095. if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
  1096. return y;
  1097. };
  1098. P.multipliedBy = P.times = function(y, b) {
  1099. var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, base, sqrtBase, x = this, xc = x.c, yc = (y = new BigNumber3(y, b)).c;
  1100. if (!xc || !yc || !xc[0] || !yc[0]) {
  1101. if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
  1102. y.c = y.e = y.s = null;
  1103. } else {
  1104. y.s *= x.s;
  1105. if (!xc || !yc) {
  1106. y.c = y.e = null;
  1107. } else {
  1108. y.c = [0];
  1109. y.e = 0;
  1110. }
  1111. }
  1112. return y;
  1113. }
  1114. e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
  1115. y.s *= x.s;
  1116. xcL = xc.length;
  1117. ycL = yc.length;
  1118. if (xcL < ycL) {
  1119. zc = xc;
  1120. xc = yc;
  1121. yc = zc;
  1122. i = xcL;
  1123. xcL = ycL;
  1124. ycL = i;
  1125. }
  1126. for (i = xcL + ycL, zc = []; i--; zc.push(0)) ;
  1127. base = BASE;
  1128. sqrtBase = SQRT_BASE;
  1129. for (i = ycL; --i >= 0; ) {
  1130. c = 0;
  1131. ylo = yc[i] % sqrtBase;
  1132. yhi = yc[i] / sqrtBase | 0;
  1133. for (k = xcL, j = i + k; j > i; ) {
  1134. xlo = xc[--k] % sqrtBase;
  1135. xhi = xc[k] / sqrtBase | 0;
  1136. m = yhi * xlo + xhi * ylo;
  1137. xlo = ylo * xlo + m % sqrtBase * sqrtBase + zc[j] + c;
  1138. c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
  1139. zc[j--] = xlo % base;
  1140. }
  1141. zc[j] = c;
  1142. }
  1143. if (c) {
  1144. ++e;
  1145. } else {
  1146. zc.splice(0, 1);
  1147. }
  1148. return normalise(y, zc, e);
  1149. };
  1150. P.negated = function() {
  1151. var x = new BigNumber3(this);
  1152. x.s = -x.s || null;
  1153. return x;
  1154. };
  1155. P.plus = function(y, b) {
  1156. var t, x = this, a = x.s;
  1157. y = new BigNumber3(y, b);
  1158. b = y.s;
  1159. if (!a || !b) return new BigNumber3(NaN);
  1160. if (a != b) {
  1161. y.s = -b;
  1162. return x.minus(y);
  1163. }
  1164. var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
  1165. if (!xe || !ye) {
  1166. if (!xc || !yc) return new BigNumber3(a / 0);
  1167. if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber3(xc[0] ? x : a * 0);
  1168. }
  1169. xe = bitFloor(xe);
  1170. ye = bitFloor(ye);
  1171. xc = xc.slice();
  1172. if (a = xe - ye) {
  1173. if (a > 0) {
  1174. ye = xe;
  1175. t = yc;
  1176. } else {
  1177. a = -a;
  1178. t = xc;
  1179. }
  1180. t.reverse();
  1181. for (; a--; t.push(0)) ;
  1182. t.reverse();
  1183. }
  1184. a = xc.length;
  1185. b = yc.length;
  1186. if (a - b < 0) {
  1187. t = yc;
  1188. yc = xc;
  1189. xc = t;
  1190. b = a;
  1191. }
  1192. for (a = 0; b; ) {
  1193. a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
  1194. xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
  1195. }
  1196. if (a) {
  1197. xc = [a].concat(xc);
  1198. ++ye;
  1199. }
  1200. return normalise(y, xc, ye);
  1201. };
  1202. P.precision = P.sd = function(sd, rm) {
  1203. var c, n, v, x = this;
  1204. if (sd != null && sd !== !!sd) {
  1205. intCheck(sd, 1, MAX);
  1206. if (rm == null) rm = ROUNDING_MODE;
  1207. else intCheck(rm, 0, 8);
  1208. return round(new BigNumber3(x), sd, rm);
  1209. }
  1210. if (!(c = x.c)) return null;
  1211. v = c.length - 1;
  1212. n = v * LOG_BASE + 1;
  1213. if (v = c[v]) {
  1214. for (; v % 10 == 0; v /= 10, n--) ;
  1215. for (v = c[0]; v >= 10; v /= 10, n++) ;
  1216. }
  1217. if (sd && x.e + 1 > n) n = x.e + 1;
  1218. return n;
  1219. };
  1220. P.shiftedBy = function(k) {
  1221. intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
  1222. return this.times("1e" + k);
  1223. };
  1224. P.squareRoot = P.sqrt = function() {
  1225. var m, n, r, rep, t, x = this, c = x.c, s = x.s, e = x.e, dp = DECIMAL_PLACES + 4, half = new BigNumber3("0.5");
  1226. if (s !== 1 || !c || !c[0]) {
  1227. return new BigNumber3(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
  1228. }
  1229. s = Math.sqrt(+valueOf(x));
  1230. if (s == 0 || s == 1 / 0) {
  1231. n = coeffToString(c);
  1232. if ((n.length + e) % 2 == 0) n += "0";
  1233. s = Math.sqrt(+n);
  1234. e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
  1235. if (s == 1 / 0) {
  1236. n = "5e" + e;
  1237. } else {
  1238. n = s.toExponential();
  1239. n = n.slice(0, n.indexOf("e") + 1) + e;
  1240. }
  1241. r = new BigNumber3(n);
  1242. } else {
  1243. r = new BigNumber3(s + "");
  1244. }
  1245. if (r.c[0]) {
  1246. e = r.e;
  1247. s = e + dp;
  1248. if (s < 3) s = 0;
  1249. for (; ; ) {
  1250. t = r;
  1251. r = half.times(t.plus(div(x, t, dp, 1)));
  1252. if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
  1253. if (r.e < e) --s;
  1254. n = n.slice(s - 3, s + 1);
  1255. if (n == "9999" || !rep && n == "4999") {
  1256. if (!rep) {
  1257. round(t, t.e + DECIMAL_PLACES + 2, 0);
  1258. if (t.times(t).eq(x)) {
  1259. r = t;
  1260. break;
  1261. }
  1262. }
  1263. dp += 4;
  1264. s += 4;
  1265. rep = 1;
  1266. } else {
  1267. if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
  1268. round(r, r.e + DECIMAL_PLACES + 2, 1);
  1269. m = !r.times(r).eq(x);
  1270. }
  1271. break;
  1272. }
  1273. }
  1274. }
  1275. }
  1276. return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
  1277. };
  1278. P.toExponential = function(dp, rm) {
  1279. if (dp != null) {
  1280. intCheck(dp, 0, MAX);
  1281. dp++;
  1282. }
  1283. return format(this, dp, rm, 1);
  1284. };
  1285. P.toFixed = function(dp, rm) {
  1286. if (dp != null) {
  1287. intCheck(dp, 0, MAX);
  1288. dp = dp + this.e + 1;
  1289. }
  1290. return format(this, dp, rm);
  1291. };
  1292. P.toFormat = function(dp, rm, format2) {
  1293. var str, x = this;
  1294. if (format2 == null) {
  1295. if (dp != null && rm && typeof rm == "object") {
  1296. format2 = rm;
  1297. rm = null;
  1298. } else if (dp && typeof dp == "object") {
  1299. format2 = dp;
  1300. dp = rm = null;
  1301. } else {
  1302. format2 = FORMAT;
  1303. }
  1304. } else if (typeof format2 != "object") {
  1305. throw Error(bignumberError + "Argument not an object: " + format2);
  1306. }
  1307. str = x.toFixed(dp, rm);
  1308. if (x.c) {
  1309. var i, arr = str.split("."), g1 = +format2.groupSize, g2 = +format2.secondaryGroupSize, groupSeparator = format2.groupSeparator || "", intPart = arr[0], fractionPart = arr[1], isNeg = x.s < 0, intDigits = isNeg ? intPart.slice(1) : intPart, len = intDigits.length;
  1310. if (g2) {
  1311. i = g1;
  1312. g1 = g2;
  1313. g2 = i;
  1314. len -= i;
  1315. }
  1316. if (g1 > 0 && len > 0) {
  1317. i = len % g1 || g1;
  1318. intPart = intDigits.substr(0, i);
  1319. for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
  1320. if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
  1321. if (isNeg) intPart = "-" + intPart;
  1322. }
  1323. str = fractionPart ? intPart + (format2.decimalSeparator || "") + ((g2 = +format2.fractionGroupSize) ? fractionPart.replace(
  1324. new RegExp("\\d{" + g2 + "}\\B", "g"),
  1325. "$&" + (format2.fractionGroupSeparator || "")
  1326. ) : fractionPart) : intPart;
  1327. }
  1328. return (format2.prefix || "") + str + (format2.suffix || "");
  1329. };
  1330. P.toFraction = function(md) {
  1331. var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, x = this, xc = x.c;
  1332. if (md != null) {
  1333. n = new BigNumber3(md);
  1334. if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
  1335. throw Error(bignumberError + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n));
  1336. }
  1337. }
  1338. if (!xc) return new BigNumber3(x);
  1339. d = new BigNumber3(ONE);
  1340. n1 = d0 = new BigNumber3(ONE);
  1341. d1 = n0 = new BigNumber3(ONE);
  1342. s = coeffToString(xc);
  1343. e = d.e = s.length - x.e - 1;
  1344. d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
  1345. md = !md || n.comparedTo(d) > 0 ? e > 0 ? d : n1 : n;
  1346. exp = MAX_EXP;
  1347. MAX_EXP = 1 / 0;
  1348. n = new BigNumber3(s);
  1349. n0.c[0] = 0;
  1350. for (; ; ) {
  1351. q = div(n, d, 0, 1);
  1352. d2 = d0.plus(q.times(d1));
  1353. if (d2.comparedTo(md) == 1) break;
  1354. d0 = d1;
  1355. d1 = d2;
  1356. n1 = n0.plus(q.times(d2 = n1));
  1357. n0 = d2;
  1358. d = n.minus(q.times(d2 = d));
  1359. n = d2;
  1360. }
  1361. d2 = div(md.minus(d0), d1, 0, 1);
  1362. n0 = n0.plus(d2.times(n1));
  1363. d0 = d0.plus(d2.times(d1));
  1364. n0.s = n1.s = x.s;
  1365. e = e * 2;
  1366. r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
  1367. div(n0, d0, e, ROUNDING_MODE).minus(x).abs()
  1368. ) < 1 ? [n1, d1] : [n0, d0];
  1369. MAX_EXP = exp;
  1370. return r;
  1371. };
  1372. P.toNumber = function() {
  1373. return +valueOf(this);
  1374. };
  1375. P.toPrecision = function(sd, rm) {
  1376. if (sd != null) intCheck(sd, 1, MAX);
  1377. return format(this, sd, rm, 2);
  1378. };
  1379. P.toString = function(b) {
  1380. var str, n = this, s = n.s, e = n.e;
  1381. if (e === null) {
  1382. if (s) {
  1383. str = "Infinity";
  1384. if (s < 0) str = "-" + str;
  1385. } else {
  1386. str = "NaN";
  1387. }
  1388. } else {
  1389. if (b == null) {
  1390. str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, "0");
  1391. } else if (b === 10 && alphabetHasNormalDecimalDigits) {
  1392. n = round(new BigNumber3(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
  1393. str = toFixedPoint(coeffToString(n.c), n.e, "0");
  1394. } else {
  1395. intCheck(b, 2, ALPHABET.length, "Base");
  1396. str = convertBase(toFixedPoint(coeffToString(n.c), e, "0"), 10, b, s, true);
  1397. }
  1398. if (s < 0 && n.c[0]) str = "-" + str;
  1399. }
  1400. return str;
  1401. };
  1402. P.valueOf = P.toJSON = function() {
  1403. return valueOf(this);
  1404. };
  1405. P._isBigNumber = true;
  1406. if (configObject != null) BigNumber3.set(configObject);
  1407. return BigNumber3;
  1408. }
  1409. function bitFloor(n) {
  1410. var i = n | 0;
  1411. return n > 0 || n === i ? i : i - 1;
  1412. }
  1413. function coeffToString(a) {
  1414. var s, z, i = 1, j = a.length, r = a[0] + "";
  1415. for (; i < j; ) {
  1416. s = a[i++] + "";
  1417. z = LOG_BASE - s.length;
  1418. for (; z--; s = "0" + s) ;
  1419. r += s;
  1420. }
  1421. for (j = r.length; r.charCodeAt(--j) === 48; ) ;
  1422. return r.slice(0, j + 1 || 1);
  1423. }
  1424. function compare(x, y) {
  1425. var a, b, xc = x.c, yc = y.c, i = x.s, j = y.s, k = x.e, l = y.e;
  1426. if (!i || !j) return null;
  1427. a = xc && !xc[0];
  1428. b = yc && !yc[0];
  1429. if (a || b) return a ? b ? 0 : -j : i;
  1430. if (i != j) return i;
  1431. a = i < 0;
  1432. b = k == l;
  1433. if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
  1434. if (!b) return k > l ^ a ? 1 : -1;
  1435. j = (k = xc.length) < (l = yc.length) ? k : l;
  1436. for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
  1437. return k == l ? 0 : k > l ^ a ? 1 : -1;
  1438. }
  1439. function intCheck(n, min, max, name) {
  1440. if (n < min || n > max || n !== mathfloor(n)) {
  1441. throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min || n > max ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
  1442. }
  1443. }
  1444. function isOdd(n) {
  1445. var k = n.c.length - 1;
  1446. return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
  1447. }
  1448. function toExponential(str, e) {
  1449. return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e < 0 ? "e" : "e+") + e;
  1450. }
  1451. function toFixedPoint(str, e, z) {
  1452. var len, zs;
  1453. if (e < 0) {
  1454. for (zs = z + "."; ++e; zs += z) ;
  1455. str = zs + str;
  1456. } else {
  1457. len = str.length;
  1458. if (++e > len) {
  1459. for (zs = z, e -= len; --e; zs += z) ;
  1460. str += zs;
  1461. } else if (e < len) {
  1462. str = str.slice(0, e) + "." + str.slice(e);
  1463. }
  1464. }
  1465. return str;
  1466. }
  1467. BigNumber2 = clone();
  1468. BigNumber2["default"] = BigNumber2.BigNumber = BigNumber2;
  1469. if (module.exports) {
  1470. module.exports = BigNumber2;
  1471. } else {
  1472. if (!globalObject) {
  1473. globalObject = typeof self != "undefined" && self ? self : window;
  1474. }
  1475. globalObject.BigNumber = BigNumber2;
  1476. }
  1477. })(commonjsGlobal);
  1478. })(bignumber);
  1479. var bignumberExports = bignumber.exports;
  1480. (function(module) {
  1481. var BigNumber2 = bignumberExports;
  1482. var JSON2 = module.exports;
  1483. (function() {
  1484. var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = {
  1485. // table of character substitutions
  1486. "\b": "\\b",
  1487. " ": "\\t",
  1488. "\n": "\\n",
  1489. "\f": "\\f",
  1490. "\r": "\\r",
  1491. '"': '\\"',
  1492. "\\": "\\\\"
  1493. }, rep;
  1494. function quote(string) {
  1495. escapable.lastIndex = 0;
  1496. return escapable.test(string) ? '"' + string.replace(escapable, function(a) {
  1497. var c = meta[a];
  1498. return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
  1499. }) + '"' : '"' + string + '"';
  1500. }
  1501. function str(key, holder) {
  1502. var i, k, v, length, mind = gap, partial, value = holder[key], isBigNumber = value != null && (value instanceof BigNumber2 || BigNumber2.isBigNumber(value));
  1503. if (value && typeof value === "object" && typeof value.toJSON === "function") {
  1504. value = value.toJSON(key);
  1505. }
  1506. if (typeof rep === "function") {
  1507. value = rep.call(holder, key, value);
  1508. }
  1509. switch (typeof value) {
  1510. case "string":
  1511. if (isBigNumber) {
  1512. return value;
  1513. } else {
  1514. return quote(value);
  1515. }
  1516. case "number":
  1517. return isFinite(value) ? String(value) : "null";
  1518. case "boolean":
  1519. case "null":
  1520. case "bigint":
  1521. return String(value);
  1522. case "object":
  1523. if (!value) {
  1524. return "null";
  1525. }
  1526. gap += indent;
  1527. partial = [];
  1528. if (Object.prototype.toString.apply(value) === "[object Array]") {
  1529. length = value.length;
  1530. for (i = 0; i < length; i += 1) {
  1531. partial[i] = str(i, value) || "null";
  1532. }
  1533. v = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]";
  1534. gap = mind;
  1535. return v;
  1536. }
  1537. if (rep && typeof rep === "object") {
  1538. length = rep.length;
  1539. for (i = 0; i < length; i += 1) {
  1540. if (typeof rep[i] === "string") {
  1541. k = rep[i];
  1542. v = str(k, value);
  1543. if (v) {
  1544. partial.push(quote(k) + (gap ? ": " : ":") + v);
  1545. }
  1546. }
  1547. }
  1548. } else {
  1549. Object.keys(value).forEach(function(k2) {
  1550. var v2 = str(k2, value);
  1551. if (v2) {
  1552. partial.push(quote(k2) + (gap ? ": " : ":") + v2);
  1553. }
  1554. });
  1555. }
  1556. v = partial.length === 0 ? "{}" : gap ? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" : "{" + partial.join(",") + "}";
  1557. gap = mind;
  1558. return v;
  1559. }
  1560. }
  1561. if (typeof JSON2.stringify !== "function") {
  1562. JSON2.stringify = function(value, replacer, space) {
  1563. var i;
  1564. gap = "";
  1565. indent = "";
  1566. if (typeof space === "number") {
  1567. for (i = 0; i < space; i += 1) {
  1568. indent += " ";
  1569. }
  1570. } else if (typeof space === "string") {
  1571. indent = space;
  1572. }
  1573. rep = replacer;
  1574. if (replacer && typeof replacer !== "function" && (typeof replacer !== "object" || typeof replacer.length !== "number")) {
  1575. throw new Error("JSON.stringify");
  1576. }
  1577. return str("", { "": value });
  1578. };
  1579. }
  1580. })();
  1581. })(stringify);
  1582. var stringifyExports = stringify.exports;
  1583. var BigNumber = null;
  1584. const suspectProtoRx = /(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/;
  1585. const suspectConstructorRx = /(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;
  1586. var json_parse$1 = function(options) {
  1587. var _options = {
  1588. strict: false,
  1589. // not being strict means do not generate syntax errors for "duplicate key"
  1590. storeAsString: false,
  1591. // toggles whether the values should be stored as BigNumber (default) or a string
  1592. alwaysParseAsBig: false,
  1593. // toggles whether all numbers should be Big
  1594. useNativeBigInt: false,
  1595. // toggles whether to use native BigInt instead of bignumber.js
  1596. protoAction: "error",
  1597. constructorAction: "error"
  1598. };
  1599. if (options !== void 0 && options !== null) {
  1600. if (options.strict === true) {
  1601. _options.strict = true;
  1602. }
  1603. if (options.storeAsString === true) {
  1604. _options.storeAsString = true;
  1605. }
  1606. _options.alwaysParseAsBig = options.alwaysParseAsBig === true ? options.alwaysParseAsBig : false;
  1607. _options.useNativeBigInt = options.useNativeBigInt === true ? options.useNativeBigInt : false;
  1608. if (typeof options.constructorAction !== "undefined") {
  1609. if (options.constructorAction === "error" || options.constructorAction === "ignore" || options.constructorAction === "preserve") {
  1610. _options.constructorAction = options.constructorAction;
  1611. } else {
  1612. throw new Error(
  1613. `Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${options.constructorAction}`
  1614. );
  1615. }
  1616. }
  1617. if (typeof options.protoAction !== "undefined") {
  1618. if (options.protoAction === "error" || options.protoAction === "ignore" || options.protoAction === "preserve") {
  1619. _options.protoAction = options.protoAction;
  1620. } else {
  1621. throw new Error(
  1622. `Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${options.protoAction}`
  1623. );
  1624. }
  1625. }
  1626. }
  1627. var at, ch, escapee = {
  1628. '"': '"',
  1629. "\\": "\\",
  1630. "/": "/",
  1631. b: "\b",
  1632. f: "\f",
  1633. n: "\n",
  1634. r: "\r",
  1635. t: " "
  1636. }, text, error = function(m) {
  1637. throw {
  1638. name: "SyntaxError",
  1639. message: m,
  1640. at,
  1641. text
  1642. };
  1643. }, next = function(c) {
  1644. if (c && c !== ch) {
  1645. error("Expected '" + c + "' instead of '" + ch + "'");
  1646. }
  1647. ch = text.charAt(at);
  1648. at += 1;
  1649. return ch;
  1650. }, number = function() {
  1651. var number2, string2 = "";
  1652. if (ch === "-") {
  1653. string2 = "-";
  1654. next("-");
  1655. }
  1656. while (ch >= "0" && ch <= "9") {
  1657. string2 += ch;
  1658. next();
  1659. }
  1660. if (ch === ".") {
  1661. string2 += ".";
  1662. while (next() && ch >= "0" && ch <= "9") {
  1663. string2 += ch;
  1664. }
  1665. }
  1666. if (ch === "e" || ch === "E") {
  1667. string2 += ch;
  1668. next();
  1669. if (ch === "-" || ch === "+") {
  1670. string2 += ch;
  1671. next();
  1672. }
  1673. while (ch >= "0" && ch <= "9") {
  1674. string2 += ch;
  1675. next();
  1676. }
  1677. }
  1678. number2 = +string2;
  1679. if (!isFinite(number2)) {
  1680. error("Bad number");
  1681. } else {
  1682. if (BigNumber == null) BigNumber = bignumberExports;
  1683. if (string2.length > 15)
  1684. return _options.storeAsString ? string2 : _options.useNativeBigInt ? BigInt(string2) : new BigNumber(string2);
  1685. else
  1686. return !_options.alwaysParseAsBig ? number2 : _options.useNativeBigInt ? BigInt(number2) : new BigNumber(number2);
  1687. }
  1688. }, string = function() {
  1689. var hex, i, string2 = "", uffff;
  1690. if (ch === '"') {
  1691. var startAt = at;
  1692. while (next()) {
  1693. if (ch === '"') {
  1694. if (at - 1 > startAt) string2 += text.substring(startAt, at - 1);
  1695. next();
  1696. return string2;
  1697. }
  1698. if (ch === "\\") {
  1699. if (at - 1 > startAt) string2 += text.substring(startAt, at - 1);
  1700. next();
  1701. if (ch === "u") {
  1702. uffff = 0;
  1703. for (i = 0; i < 4; i += 1) {
  1704. hex = parseInt(next(), 16);
  1705. if (!isFinite(hex)) {
  1706. break;
  1707. }
  1708. uffff = uffff * 16 + hex;
  1709. }
  1710. string2 += String.fromCharCode(uffff);
  1711. } else if (typeof escapee[ch] === "string") {
  1712. string2 += escapee[ch];
  1713. } else {
  1714. break;
  1715. }
  1716. startAt = at;
  1717. }
  1718. }
  1719. }
  1720. error("Bad string");
  1721. }, white = function() {
  1722. while (ch && ch <= " ") {
  1723. next();
  1724. }
  1725. }, word = function() {
  1726. switch (ch) {
  1727. case "t":
  1728. next("t");
  1729. next("r");
  1730. next("u");
  1731. next("e");
  1732. return true;
  1733. case "f":
  1734. next("f");
  1735. next("a");
  1736. next("l");
  1737. next("s");
  1738. next("e");
  1739. return false;
  1740. case "n":
  1741. next("n");
  1742. next("u");
  1743. next("l");
  1744. next("l");
  1745. return null;
  1746. }
  1747. error("Unexpected '" + ch + "'");
  1748. }, value, array = function() {
  1749. var array2 = [];
  1750. if (ch === "[") {
  1751. next("[");
  1752. white();
  1753. if (ch === "]") {
  1754. next("]");
  1755. return array2;
  1756. }
  1757. while (ch) {
  1758. array2.push(value());
  1759. white();
  1760. if (ch === "]") {
  1761. next("]");
  1762. return array2;
  1763. }
  1764. next(",");
  1765. white();
  1766. }
  1767. }
  1768. error("Bad array");
  1769. }, object = function() {
  1770. var key, object2 = /* @__PURE__ */ Object.create(null);
  1771. if (ch === "{") {
  1772. next("{");
  1773. white();
  1774. if (ch === "}") {
  1775. next("}");
  1776. return object2;
  1777. }
  1778. while (ch) {
  1779. key = string();
  1780. white();
  1781. next(":");
  1782. if (_options.strict === true && Object.hasOwnProperty.call(object2, key)) {
  1783. error('Duplicate key "' + key + '"');
  1784. }
  1785. if (suspectProtoRx.test(key) === true) {
  1786. if (_options.protoAction === "error") {
  1787. error("Object contains forbidden prototype property");
  1788. } else if (_options.protoAction === "ignore") {
  1789. value();
  1790. } else {
  1791. object2[key] = value();
  1792. }
  1793. } else if (suspectConstructorRx.test(key) === true) {
  1794. if (_options.constructorAction === "error") {
  1795. error("Object contains forbidden constructor property");
  1796. } else if (_options.constructorAction === "ignore") {
  1797. value();
  1798. } else {
  1799. object2[key] = value();
  1800. }
  1801. } else {
  1802. object2[key] = value();
  1803. }
  1804. white();
  1805. if (ch === "}") {
  1806. next("}");
  1807. return object2;
  1808. }
  1809. next(",");
  1810. white();
  1811. }
  1812. }
  1813. error("Bad object");
  1814. };
  1815. value = function() {
  1816. white();
  1817. switch (ch) {
  1818. case "{":
  1819. return object();
  1820. case "[":
  1821. return array();
  1822. case '"':
  1823. return string();
  1824. case "-":
  1825. return number();
  1826. default:
  1827. return ch >= "0" && ch <= "9" ? number() : word();
  1828. }
  1829. };
  1830. return function(source, reviver) {
  1831. var result;
  1832. text = source + "";
  1833. at = 0;
  1834. ch = " ";
  1835. result = value();
  1836. white();
  1837. if (ch) {
  1838. error("Syntax error");
  1839. }
  1840. return typeof reviver === "function" ? function walk(holder, key) {
  1841. var v, value2 = holder[key];
  1842. if (value2 && typeof value2 === "object") {
  1843. Object.keys(value2).forEach(function(k) {
  1844. v = walk(value2, k);
  1845. if (v !== void 0) {
  1846. value2[k] = v;
  1847. } else {
  1848. delete value2[k];
  1849. }
  1850. });
  1851. }
  1852. return reviver.call(holder, key, value2);
  1853. }({ "": result }, "") : result;
  1854. };
  1855. };
  1856. var parse = json_parse$1;
  1857. var json_stringify = stringifyExports.stringify;
  1858. var json_parse = parse;
  1859. jsonBigint.exports = function(options) {
  1860. return {
  1861. parse: json_parse(options),
  1862. stringify: json_stringify
  1863. };
  1864. };
  1865. jsonBigint.exports.parse = json_parse();
  1866. jsonBigint.exports.stringify = json_stringify;
  1867. var jsonBigintExports = jsonBigint.exports;
  1868. const JSONbig = exports("J", /* @__PURE__ */ getDefaultExportFromCjs(jsonBigintExports));
  1869. const Utils = exports("U", {
  1870. /**
  1871. * 检查是否为图片链接
  1872. * @param {*} str 字符串
  1873. * @returns
  1874. */
  1875. isImg: function(str) {
  1876. const regexp = /\.(ico|bmp|gif|jpg|jpeg|png|svg|webp|GIF|JPG|PNG|WEBP|SVG)([\w#!:.?+=&%@!\-\/])?/i;
  1877. return regexp.test(str);
  1878. },
  1879. /**
  1880. * 是否为json格式的内容
  1881. * @param {*} str 字符串
  1882. * @returns
  1883. */
  1884. isJSON: function(str) {
  1885. try {
  1886. JSON.parse(str);
  1887. return true;
  1888. } catch (e) {
  1889. console.log("is not json");
  1890. return false;
  1891. }
  1892. },
  1893. /**
  1894. * 获取数据类型,全小写
  1895. * @param {*} v
  1896. * @returns
  1897. */
  1898. getType: function(v) {
  1899. return Object.prototype.toString.call(v).match(/\s(.+)]/)[1].toLowerCase();
  1900. },
  1901. /**
  1902. * 获取数据类型
  1903. * @param {*} val
  1904. * @returns
  1905. */
  1906. getPrototype: function(val) {
  1907. return Object.prototype.toString.call(val).match(/\s(.+)]/)[1];
  1908. },
  1909. /**
  1910. * 获取数组中对象key最多的对象
  1911. * @param {*} arr 对象数组
  1912. * @returns
  1913. */
  1914. findMaxKeysObject: function(arr) {
  1915. let maxKeysCount = 0;
  1916. let maxKeysObject;
  1917. for (const obj of arr) {
  1918. const keysCount = Object.keys(obj).length;
  1919. if (keysCount > maxKeysCount) {
  1920. maxKeysCount = keysCount;
  1921. maxKeysObject = obj;
  1922. }
  1923. }
  1924. return maxKeysObject;
  1925. },
  1926. /**
  1927. * 随机rgb颜色
  1928. * @param {*} opacity 透明度
  1929. * @returns
  1930. */
  1931. randomColor: (opacity) => {
  1932. const red = Math.floor(Math.random() * 256);
  1933. const green = Math.floor(Math.random() * 256);
  1934. const blue = Math.floor(Math.random() * 256);
  1935. return `rgba(${red}, ${green}, ${blue}, ${opacity})`;
  1936. },
  1937. /**
  1938. * 下载文本内容
  1939. * @param {*} content 文本内容
  1940. * @param {*} filename 文件名
  1941. */
  1942. downloadText: function(content, filename) {
  1943. const blob = new Blob([content], { type: "text/plain;charset=utf-8" });
  1944. const url = URL.createObjectURL(blob);
  1945. const link = document.createElement("a");
  1946. link.href = url;
  1947. link.download = filename;
  1948. link.click();
  1949. URL.revokeObjectURL(url);
  1950. },
  1951. /**
  1952. * JSONP 数据处理
  1953. * @param {*} rawText 字符串
  1954. * @returns
  1955. */
  1956. jsonpMatch: function(rawText) {
  1957. const tokens = rawText.match(/^([^\s(]*)\s*\(([\s\S]*)\)\s*;?$/);
  1958. if (tokens && tokens[1] && tokens[2]) {
  1959. return {
  1960. rawText: tokens[2],
  1961. jsonpFun: tokens[1]
  1962. };
  1963. }
  1964. return {
  1965. rawText,
  1966. jsonpFun: null
  1967. };
  1968. }
  1969. });
  1970. const URL$1 = exports("e", {
  1971. JSON_CRACK_WIDGET: "https://jsoncrack.feny.ink/widget",
  1972. EXAMPLE_JSON: "https://fetch-api.feny.ink/example.json",
  1973. ONLINE_REQUEST: "https://fetch-api.feny.ink/httpRequest",
  1974. LAYUI_JS: "https://unpkg.com/layui@2.7.6/dist/layui.js",
  1975. LAYUI_CSS: "https://unpkg.com/layui@2.7.6/dist/css/layui.css"
  1976. });
  1977. const layout = `
  1978. <div class="json-viewer-layout">
  1979. <div class="panel">
  1980. <div class="tabs">
  1981. <div class="tabs-item btn active" id="viewFormater">JSON 格式化</div>
  1982. <div class="tabs-item btn" id="viewMind">JSON 脑图</div>
  1983. <div class="tabs-item btn" id="viewRawText">原始数据</div>
  1984. </div>
  1985. <div class="toolbar">
  1986. <div class="toolbar-item btn" id="saveJson">保存</div>
  1987. <div class="toolbar-item btn" id="copyJson">复制</div>
  1988. <div class="toolbar-item btn" id="collapseAll">全部折叠</div>
  1989. <div class="toolbar-item btn" id="expandAll">全部展开</div>
  1990. <div class="toolbar-item btn" id="jsoncrack" style="display: none;">JSON Crack</div>
  1991. <div class="toolbar-item btn" id="beautify" style="display: none;">美化输出</div>
  1992. <div class="searchbox">
  1993. <input type="text" placeholder="过滤 JSON "/>
  1994. <button class="clear" hidden></button>
  1995. </div>
  1996. </div>
  1997. <div class="rightbox">
  1998. <div class="style">
  1999. <span>风格</span>
  2000. <template data-type="style">
  2001. <ul>
  2002. <li data-type="style" data-value="default">默认</li>
  2003. <li data-type="style" data-value="table">表格</li>
  2004. </ul>
  2005. </template>
  2006. </div>
  2007. <div class="theme">
  2008. <span>主题</span>
  2009. <template data-type="theme">
  2010. <ul>
  2011. <li data-type="theme" data-value="default">默认</li>
  2012. <li data-type="theme" data-value="light">浅色</li>
  2013. <li data-type="theme" data-value="dark">暗黑</li>
  2014. <li data-type="theme" data-value="dark-plus">暗黑+</li>
  2015. </ul>
  2016. </template>
  2017. </div>
  2018. <div class="tools">
  2019. <span>工具</span>
  2020. <template data-type="tools">
  2021. <ul>
  2022. <li data-type="tools" data-value="inputJson">JSON 输入</li>
  2023. <li data-type="tools" data-value="fetchApi">HTTP 请求</li>
  2024. </ul>
  2025. </template>
  2026. </div>
  2027. </div>
  2028. </div>
  2029. <div class="container">
  2030. <div class="active" id="formatBox"></div>
  2031. <div id="mindBox"></div>
  2032. <div id="rawTextBox">
  2033. <pre></pre>
  2034. </div>
  2035. </div>
  2036. </div>`;
  2037. var _GM_addStyle = /* @__PURE__ */ (() => typeof GM_addStyle != "undefined" ? GM_addStyle : void 0)();
  2038. var _GM_getValue = exports("a", /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)());
  2039. var _GM_openInTab = /* @__PURE__ */ (() => typeof GM_openInTab != "undefined" ? GM_openInTab : void 0)();
  2040. var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
  2041. var _GM_setClipboard = exports("c", /* @__PURE__ */ (() => typeof GM_setClipboard != "undefined" ? GM_setClipboard : void 0)());
  2042. var _GM_setValue = exports("_", /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)());
  2043. var _unsafeWindow = exports("b", /* @__PURE__ */ (() => typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)());
  2044. const { EXAMPLE_JSON, LAYUI_CSS, LAYUI_JS } = URL$1;
  2045. (function() {
  2046. const openInTab = () => _GM_openInTab(EXAMPLE_JSON);
  2047. _GM_registerMenuCommand("测试JSON( Alt + j )", openInTab);
  2048. window.addEventListener("keydown", function(event) {
  2049. const { key, altKey } = event;
  2050. if (altKey && (key === "J" || key === "j")) {
  2051. openInTab();
  2052. }
  2053. });
  2054. const innerText = document.body.innerText;
  2055. const { rawText, jsonpFun } = Utils.jsonpMatch(innerText);
  2056. _unsafeWindow.RAW_TEXT = rawText;
  2057. _unsafeWindow.GLOBAL_JSONP_FUN = jsonpFun;
  2058. if (!Utils.isJSON(_unsafeWindow.RAW_TEXT)) {
  2059. __vitePreload(() => module.import('./index-mjXXc9V1-CzTRTL8e.js'), void 0 );
  2060. return;
  2061. }
  2062. document.querySelector("pre").style.display = "none";
  2063. document.querySelector("html").classList.add("monkey-jsonviewer");
  2064. window.postMessage({ addStyle: true });
  2065. const meta = document.createElement("meta");
  2066. meta.setAttribute("name", "viewport");
  2067. meta.setAttribute("content", "width=device-width, initial-scale=1.0");
  2068. document.head.appendChild(meta);
  2069. const link = document.createElement("link");
  2070. link.setAttribute("href", LAYUI_CSS);
  2071. link.setAttribute("rel", "stylesheet");
  2072. document.head.appendChild(link);
  2073. const script = document.createElement("script");
  2074. script.setAttribute("src", LAYUI_JS);
  2075. script.setAttribute("type", "text/javascript");
  2076. document.head.appendChild(script);
  2077. _GM_addStyle(`
  2078. jmnode.root::before{background-color: ${Utils.randomColor(0.5)}}
  2079. jmnode:not(.root)::before{background-color: ${Utils.randomColor(0.5)}}
  2080. `);
  2081. setTimeout(() => {
  2082. _unsafeWindow.GLOBAL_JSON = JSONbig({ useNativeBigInt: true }).parse(
  2083. _unsafeWindow.RAW_TEXT
  2084. );
  2085. document.body.insertAdjacentHTML("afterbegin", layout);
  2086. __vitePreload(() => module.import('./index-BTqD3v_p--4LUzVez.js'), void 0 ).then((format) => format.default.init()).then(() => __vitePreload(() => module.import('./index-DgFsy9mH-BKxVgg-a.js'), void 0 )).then(() => __vitePreload(() => module.import('./index-CZOUlSU2-CskZy1NC.js'), void 0 ));
  2087. });
  2088. })();
  2089.  
  2090. })
  2091. };
  2092. }));
  2093.  
  2094. System.register("./index-mjXXc9V1-CzTRTL8e.js", ['highlight.js', 'beautifier'], (function (exports, module) {
  2095. 'use strict';
  2096. var hljs, css_beautify, js_beautify;
  2097. return {
  2098. setters: [module => {
  2099. hljs = module.default;
  2100. }, module => {
  2101. css_beautify = module.css_beautify;
  2102. js_beautify = module.js_beautify;
  2103. }],
  2104. execute: (function () {
  2105.  
  2106. const layout = `
  2107. <div class="beautify_checkbox">
  2108. <input type="checkbox" id="beautify"/>
  2109. <label for="beautify">美化输出</label>
  2110. </div>`;
  2111. (function() {
  2112. const docType = [
  2113. "application/x-javascript",
  2114. "application/javascript",
  2115. "text/javascript",
  2116. "text/css"
  2117. ];
  2118. const contentType = document.contentType;
  2119. if (!docType.includes(contentType)) {
  2120. return;
  2121. }
  2122. const preElement = document.querySelector("pre");
  2123. if (!preElement) {
  2124. return;
  2125. }
  2126. window.postMessage({ addStyle: true });
  2127. document.querySelector("html").classList.add("monkey-js-css-beautify");
  2128. setTimeout(() => {
  2129. const rawText = preElement.innerText;
  2130. document.body.insertAdjacentHTML("afterbegin", layout);
  2131. const checkbox = document.querySelector(".beautify_checkbox input");
  2132. checkbox.addEventListener("click", function() {
  2133. if (this.checked) {
  2134. beautifyCode(contentType, preElement, rawText);
  2135. } else {
  2136. preElement.innerText = rawText;
  2137. }
  2138. });
  2139. });
  2140. })();
  2141. function beautifyCode(contentType, element, rawText) {
  2142. const language = contentType.substring(contentType.indexOf("/") + 1);
  2143. if (!["css", "javascript", "x-javascript"].includes(language)) {
  2144. return;
  2145. }
  2146. let beautifyCode2;
  2147. if ("css" === language) {
  2148. const cssBeautify = css_beautify ? css_beautify : window.css_beautify;
  2149. beautifyCode2 = cssBeautify(rawText);
  2150. beautifyCode2 = hljs.highlight(beautifyCode2, {
  2151. language
  2152. }).value;
  2153. } else {
  2154. const jsBeautify = js_beautify ? js_beautify : window.js_beautify;
  2155. beautifyCode2 = jsBeautify(rawText);
  2156. beautifyCode2 = hljs.highlight(beautifyCode2, {
  2157. language: "javascript"
  2158. }).value;
  2159. }
  2160. element.innerHTML = `<code>${beautifyCode2}</code>`;
  2161. }
  2162.  
  2163. })
  2164. };
  2165. }));
  2166.  
  2167. System.register("./index-BTqD3v_p--4LUzVez.js", ['jquery', './tippy.esm-Ot9MORvr-DNGa7Opj.js', './__monkey.entry-DSLwfYjn.js'], (function (exports, module) {
  2168. 'use strict';
  2169. var $, tippy, _GM_setValue, _GM_getValue, _unsafeWindow, Utils, _GM_setClipboard;
  2170. return {
  2171. setters: [module => {
  2172. $ = module.default;
  2173. }, module => {
  2174. tippy = module.t;
  2175. }, module => {
  2176. _GM_setValue = module._;
  2177. _GM_getValue = module.a;
  2178. _unsafeWindow = module.b;
  2179. Utils = module.U;
  2180. _GM_setClipboard = module.c;
  2181. }],
  2182. execute: (function () {
  2183.  
  2184. class JsonViewer {
  2185. constructor(options) {
  2186. const defaults = {
  2187. json: null,
  2188. theme: "default",
  2189. container: null,
  2190. onExpand: null,
  2191. expander: null,
  2192. collapser: null,
  2193. onCollapse: null
  2194. };
  2195. this.options = Object.assign(defaults, options);
  2196. if (!options.container) {
  2197. throw new Error("Container: dom element is required");
  2198. }
  2199. if (!options.json) {
  2200. throw new Error("json: json is required");
  2201. }
  2202. this.render();
  2203. this.bind();
  2204. this.setTheme(this.options.theme);
  2205. }
  2206. setTheme(theme) {
  2207. const classList = document.body.classList;
  2208. classList.forEach((clas) => {
  2209. if (clas.includes("theme")) {
  2210. classList.remove(clas);
  2211. }
  2212. });
  2213. classList.add(`${theme}-theme`);
  2214. }
  2215. render() {
  2216. const { json, container } = this.options;
  2217. this.$container = container instanceof HTMLElement ? container : document.querySelector(container);
  2218. this.$box = this.createElement("div");
  2219. this.$box.setAttribute("class", `json-view-formater`);
  2220. this.createNode(this.$box, json, "Root", "Root");
  2221. this.$container.appendChild(this.$box);
  2222. }
  2223. createNode(box, json, pChain, pid) {
  2224. const type2 = this.getType(json);
  2225. switch (type2) {
  2226. case "array":
  2227. case "object":
  2228. let length = Object.keys(json).length;
  2229. if (length > 0) {
  2230. this.createObjectNode(box, type2, json, pChain, pid);
  2231. } else {
  2232. const emptyNode = this.createEmptyNode(type2);
  2233. box.appendChild(emptyNode);
  2234. }
  2235. break;
  2236. default:
  2237. const valueNode = this.creatValueNode(type2, json);
  2238. box.appendChild(valueNode);
  2239. break;
  2240. }
  2241. }
  2242. createObjectNode(box, type2, json, pChain, pid) {
  2243. const startBracket = this.createStartBracket(type2);
  2244. box.appendChild(startBracket);
  2245. if (pChain !== "Root" && this.canIterate(json)) {
  2246. const span = this.createElement("span", {
  2247. class: "json-formater-placeholder"
  2248. });
  2249. span.addEventListener("click", () => {
  2250. this.show(box);
  2251. });
  2252. box.appendChild(span);
  2253. }
  2254. let length = Object.keys(json).length;
  2255. for (var key in json) {
  2256. if (Object.prototype.hasOwnProperty.call(json, key)) {
  2257. const value = json[key];
  2258. const id = this.random();
  2259. const canComma = --length > 0;
  2260. const jsonPath = pChain + "." + key;
  2261. const node = this.createElement("div", {
  2262. "data-node-id": id,
  2263. "data-node-pid": pid,
  2264. "json-path": jsonPath,
  2265. style: `padding-left: 20px`,
  2266. "data-type": this.getType(value),
  2267. class: this.isIterate(value) ? "json-formater-opened" : null
  2268. });
  2269. this.createKeyNode(node, key, value);
  2270. this.createNode(node, value, jsonPath, id);
  2271. if (canComma) {
  2272. const comma = this.createElement("span", {
  2273. class: "json-comma"
  2274. });
  2275. comma.textContent = ",";
  2276. node.appendChild(comma);
  2277. }
  2278. box.appendChild(node);
  2279. }
  2280. }
  2281. const endBracket = this.createEndBracket(type2);
  2282. box.appendChild(endBracket);
  2283. }
  2284. createStartBracket(type2) {
  2285. const span = this.createElement("span", {
  2286. class: `json-${type2}-bracket`
  2287. });
  2288. span.textContent = type2 === "array" ? "[" : "{";
  2289. return span;
  2290. }
  2291. createEndBracket(type2) {
  2292. const span = this.createElement("span", {
  2293. class: `json-${type2}-bracket`
  2294. });
  2295. span.textContent = type2 === "array" ? "]" : "}";
  2296. return span;
  2297. }
  2298. createBracket() {
  2299. const span = this.createElement("span", {
  2300. class: `json-${type}-bracket`
  2301. });
  2302. span.textContent = type === "array" ? "[]" : "{}";
  2303. return span;
  2304. }
  2305. createKeyNode(node, key, value) {
  2306. if (this.canIterate(value)) {
  2307. const arrow = this.createElement("span", {
  2308. class: "json-formater-arrow"
  2309. });
  2310. node.appendChild(arrow);
  2311. }
  2312. if (!/^\d+$/.test(key)) {
  2313. const span = this.createElement("span", {
  2314. class: "json-key"
  2315. });
  2316. span.textContent = `"${key}"`;
  2317. node.appendChild(span);
  2318. const colon = this.createElement("span", {
  2319. class: "json-colon"
  2320. });
  2321. colon.textContent = ":";
  2322. node.appendChild(colon);
  2323. }
  2324. }
  2325. creatValueNode(type2, value) {
  2326. const node = this.createElement("span", {
  2327. class: `json-${type2}`
  2328. });
  2329. node.textContent = `${value}`;
  2330. if (type2 === "string") {
  2331. value = this.escape(value);
  2332. node.textContent = `"${value}"`;
  2333. }
  2334. if (this.isUrl(value)) {
  2335. node.textContent = "";
  2336. const a = this.createElement("a", {
  2337. target: "_blank",
  2338. href: value
  2339. });
  2340. a.textContent = `"${value}"`;
  2341. node.appendChild(a);
  2342. }
  2343. if (this.isColor(value)) {
  2344. const span = this.createElement("span", {
  2345. class: "json-color",
  2346. style: `background-color: ${value}`
  2347. });
  2348. node.prepend(span);
  2349. }
  2350. return node;
  2351. }
  2352. createEmptyNode(type2) {
  2353. const node = this.createElement("span", {
  2354. class: `json-${type2}-bracket`
  2355. });
  2356. node.textContent = type2 === "array" ? "[]" : "{}";
  2357. return node;
  2358. }
  2359. bind() {
  2360. this.addEvent(this.options.expander, `click`, () => {
  2361. this.expandAll();
  2362. });
  2363. this.addEvent(this.options.collapser, `click`, () => {
  2364. this.collapseAll();
  2365. });
  2366. const { onExpand, onCollapse } = this.options;
  2367. this.addEvent(".json-formater-arrow", "click", (e) => {
  2368. const node = e.currentTarget.parentElement;
  2369. if (this.hasClass(node, "json-formater-opened")) {
  2370. this.hide(node);
  2371. if (onCollapse) onCollapse(node, this);
  2372. } else {
  2373. this.show(node);
  2374. if (onExpand) onExpand(node, this);
  2375. }
  2376. });
  2377. }
  2378. expandAll() {
  2379. this.nodes().forEach((node) => {
  2380. this.show(node.parentElement);
  2381. });
  2382. }
  2383. collapseAll() {
  2384. this.nodes().forEach((node) => {
  2385. this.hide(node.parentElement);
  2386. });
  2387. }
  2388. show(node) {
  2389. this.removeClass(node, "json-formater-closed");
  2390. this.addClass(node, "json-formater-opened");
  2391. this.showDescs(node);
  2392. this.onShow(node);
  2393. }
  2394. onShow(node) {
  2395. const nodeId = node.dataset.nodeId;
  2396. this.findChildren(node).length;
  2397. const placeholder = node.querySelector(
  2398. `*[data-node-id*=${nodeId}] > .json-formater-placeholder`
  2399. );
  2400. if (!placeholder) {
  2401. return;
  2402. }
  2403. placeholder.textContent = "";
  2404. }
  2405. showDescs(node) {
  2406. let children = this.findChildren(node);
  2407. children.forEach((child) => {
  2408. child.style.display = null;
  2409. });
  2410. }
  2411. hide(node) {
  2412. this.removeClass(node, "json-formater-opened");
  2413. this.addClass(node, "json-formater-closed");
  2414. this.hideDescs(node);
  2415. this.onHide(node);
  2416. }
  2417. onHide(node) {
  2418. const type2 = node.dataset.type;
  2419. const nodeId = node.dataset.nodeId;
  2420. const length = this.findChildren(node).length;
  2421. const placeholder = node.querySelector(
  2422. `*[data-node-id*=${nodeId}] > .json-formater-placeholder`
  2423. );
  2424. if (!placeholder) {
  2425. return;
  2426. }
  2427. placeholder.textContent = `${length}${length > 1 ? " items " : " item "}`;
  2428. if (type2 === "object") {
  2429. placeholder.textContent = `${length}${length > 1 ? " keys " : " key "}`;
  2430. }
  2431. }
  2432. hideDescs(node) {
  2433. const children = this.findChildren(node);
  2434. children.forEach((child) => {
  2435. child.style.display = "none";
  2436. });
  2437. }
  2438. findChildren(node) {
  2439. const pid = node.dataset.nodeId;
  2440. return this.$container.querySelectorAll(
  2441. `*[data-node-pid="${pid}"]:not(.hidden)`
  2442. );
  2443. }
  2444. findByID(id) {
  2445. return this.$container.querySelector(`*[data-node-id="${id}"]`);
  2446. }
  2447. openByID(id) {
  2448. this.show(this.findByID(id));
  2449. }
  2450. closeByID(id) {
  2451. this.hide(this.findByID(id));
  2452. }
  2453. addEvent(selector, event, fn) {
  2454. document.body.querySelectorAll(selector).forEach((el) => {
  2455. el.addEventListener(event, fn);
  2456. });
  2457. }
  2458. closest(element, selector) {
  2459. while (element) {
  2460. if (element.matches(selector)) {
  2461. return element;
  2462. }
  2463. element = element.parentElement;
  2464. }
  2465. return null;
  2466. }
  2467. hasClass(element, clas) {
  2468. return element.classList.contains(clas);
  2469. }
  2470. removeClass(element, clas) {
  2471. element.classList.remove(clas);
  2472. return this;
  2473. }
  2474. addClass(element, clas) {
  2475. element.classList.add(clas);
  2476. return this;
  2477. }
  2478. nodes() {
  2479. return this.$container.querySelectorAll(".json-formater-arrow");
  2480. }
  2481. /**
  2482. * 创建元素
  2483. * @param {String} name 元素名称
  2484. * @param {Object} attributes 属性
  2485. */
  2486. createElement(name, attributes) {
  2487. const element = document.createElement(name);
  2488. this.setAttributes(element, attributes);
  2489. return element;
  2490. }
  2491. /**
  2492. * 设置属性
  2493. * @param {HTMLElement} element 元素
  2494. * @param {Object} attributes 属性
  2495. */
  2496. setAttributes(element, attributes) {
  2497. if (!attributes) {
  2498. return;
  2499. }
  2500. for (const name in attributes) {
  2501. const value = attributes[name];
  2502. if (value) element.setAttribute(name, attributes[name]);
  2503. }
  2504. }
  2505. /**
  2506. * 获取数据的类型
  2507. * @param {Object} value
  2508. * @return 返回类型 number、object、array、string、null等
  2509. */
  2510. getType(value) {
  2511. return Object.prototype.toString.call(value).match(/\s(.+)]/)[1].toLowerCase();
  2512. }
  2513. isIterate(value) {
  2514. const type2 = this.getType(value);
  2515. return ["array", "object"].includes(type2);
  2516. }
  2517. /**
  2518. * 是否可迭代
  2519. * @param {*} value
  2520. * @returns
  2521. */
  2522. canIterate(value) {
  2523. if (!this.isIterate(value)) {
  2524. return false;
  2525. }
  2526. let len = Object.keys(value).length;
  2527. return len > 0;
  2528. }
  2529. /**
  2530. * 是否为Url
  2531. * @param {*} str
  2532. * @returns
  2533. */
  2534. isUrl(str) {
  2535. const regexp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
  2536. return regexp.test(str);
  2537. }
  2538. /**
  2539. * 转义
  2540. * @param {*} str
  2541. * @returns
  2542. */
  2543. escape(str) {
  2544. return str.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  2545. }
  2546. isColor(colorString) {
  2547. const hexCodeRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
  2548. const rgbRegex = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/;
  2549. const rgbaRegex = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0\.\d+)\s*\)$/;
  2550. return hexCodeRegex.test(colorString) || rgbRegex.test(colorString) || rgbaRegex.test(colorString);
  2551. }
  2552. random() {
  2553. let randomString = "";
  2554. const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  2555. for (let i = 0; i < 10; i++) {
  2556. const randomIndex = Math.floor(Math.random() * characters.length);
  2557. randomString += characters.charAt(randomIndex);
  2558. }
  2559. return randomString;
  2560. }
  2561. }
  2562. const cssText = `
  2563. .json-tree-table {
  2564. border-collapse: collapse;
  2565. width: -webkit-fill-available;
  2566. }
  2567.  
  2568. .json-tree-table b {
  2569. font-weight: normal;
  2570. }
  2571.  
  2572. .json-tree-table tr.selected,
  2573. .json-tree-table tr.selected td,
  2574. .json-tree-table tr.selected td b,
  2575. .json-tree-table tr.selected td a {
  2576. color: #fff !important;
  2577. background-color: #3875d7;
  2578. }
  2579.  
  2580. .json-tree-table tr:hover {
  2581. background-color: #f0f9fe;
  2582. }
  2583.  
  2584. .json-tree-table tr td:first-child {
  2585. width: 120px;
  2586. }
  2587.  
  2588. .dark-theme .json-tree-table tr:hover,
  2589. .dark-plus-theme .json-tree-table tr:hover {
  2590. background-color: #353b48;
  2591. }
  2592. `;
  2593. const DEFAULTS = {
  2594. json: null,
  2595. theme: "default",
  2596. container: null,
  2597. onExpand: null,
  2598. expander: null,
  2599. collapser: null,
  2600. onCollapse: null
  2601. };
  2602. class JsonToTable {
  2603. constructor(options) {
  2604. this.options = Object.assign(DEFAULTS, options);
  2605. if (!options.container) {
  2606. throw new Error("Container: dom element is required");
  2607. }
  2608. if (!options.json) {
  2609. throw new Error("json: json is required");
  2610. }
  2611. if (typeof options.json !== "object") {
  2612. throw new Error("json: Need to use JSON.parse conversion");
  2613. }
  2614. this.render();
  2615. this.bindEvent();
  2616. this.setTheme(this.options.theme);
  2617. }
  2618. setTheme(theme) {
  2619. const classList = document.body.classList;
  2620. classList.forEach((clas) => {
  2621. if (clas.includes("theme")) {
  2622. classList.remove(clas);
  2623. }
  2624. });
  2625. classList.add(`${theme}-theme`);
  2626. }
  2627. render() {
  2628. const { json, container } = this.options;
  2629. this.$container = container instanceof HTMLElement ? container : document.querySelector(container);
  2630. const style = this.createElement("style");
  2631. style.textContent = cssText;
  2632. document.head.appendChild(style);
  2633. this.$table = this.createElement("table");
  2634. this.$table.setAttribute("class", `json-tree-table`);
  2635. this.createNode(json, 1, "Root", "Root");
  2636. this.$container.appendChild(this.$table);
  2637. }
  2638. /**
  2639. * 创建节点
  2640. * @param {Object} json
  2641. * @param {Boolean} isRoot 是否根节点
  2642. * @param {Number} depth 递归层级
  2643. * @param {String} pChain 上级json-path
  2644. */
  2645. createNode(json, depth, pChain, parentId) {
  2646. for (const key in json) {
  2647. let value = json[key];
  2648. const type2 = this.getType(value);
  2649. const jsonPath = `${pChain}.${key}`;
  2650. const item = this.createItem(key, value, type2, depth, jsonPath, parentId);
  2651. this.$table.appendChild(item);
  2652. if (this.canIterate(value)) {
  2653. const nodeId = item.dataset.nodeId;
  2654. this.createNode(value, depth + 1, jsonPath, nodeId);
  2655. }
  2656. }
  2657. }
  2658. createItem(key, value, type2, depth, jsonPath, parentId) {
  2659. const id = key + "_" + Math.random();
  2660. const isIterate = this.isIterate(value);
  2661. const canIterate = this.canIterate(value);
  2662. const node = this.createElement("tr", {
  2663. "data-type": type2,
  2664. "data-node-id": id,
  2665. "data-node-pid": parentId,
  2666. class: "json-formater-opened"
  2667. });
  2668. const leftNode = this.createLeftNode(key, value, depth, jsonPath);
  2669. node.appendChild(leftNode);
  2670. if (!isIterate) {
  2671. const rightNode = this.createRightNode(type2, value);
  2672. node.appendChild(rightNode);
  2673. }
  2674. if (isIterate && !canIterate) {
  2675. const rightNode = this.createEmptyRightNode(type2);
  2676. node.appendChild(rightNode);
  2677. }
  2678. return node;
  2679. }
  2680. createLeftNode(key, value, depth, jsonPath) {
  2681. const node = this.createElement("td", {
  2682. "json-path": jsonPath,
  2683. colspan: this.canIterate(value) ? 2 : 0,
  2684. style: `padding-left: ${depth * 20}px`
  2685. });
  2686. const b = this.createElement("b", {
  2687. class: "json-key"
  2688. });
  2689. b.textContent = `${key}`;
  2690. node.appendChild(b);
  2691. const colon = this.createElement("span", {
  2692. class: "json-colon"
  2693. });
  2694. colon.textContent = ":";
  2695. node.appendChild(colon);
  2696. if (this.canIterate(value)) {
  2697. const icon = this.createElement("span", {
  2698. class: "json-formater-arrow"
  2699. });
  2700. node.prepend(icon);
  2701. const span = this.createElement("span", {
  2702. class: "json-formater-placeholder"
  2703. });
  2704. node.appendChild(span);
  2705. }
  2706. return node;
  2707. }
  2708. createRightNode(type2, value) {
  2709. const node = this.createElement("td", {
  2710. class: `json-${type2}`
  2711. });
  2712. node.textContent = `${value}`;
  2713. if (type2 === "string") {
  2714. value = this.escape(value);
  2715. node.textContent = `"${value}"`;
  2716. }
  2717. if (this.isUrl(value)) {
  2718. node.textContent = "";
  2719. const a = this.createElement("a", {
  2720. target: "_blank",
  2721. href: value
  2722. });
  2723. a.textContent = `"${value}"`;
  2724. node.appendChild(a);
  2725. }
  2726. if (this.isColor(value)) {
  2727. const span = this.createElement("span", {
  2728. class: "json-color",
  2729. style: `background-color: ${value}`
  2730. });
  2731. node.prepend(span);
  2732. }
  2733. return node;
  2734. }
  2735. createEmptyRightNode(type2) {
  2736. const node = this.createElement("td", {
  2737. class: `json-${type2}-bracket`
  2738. });
  2739. node.textContent = type2 === "array" ? "[]" : "{}";
  2740. return node;
  2741. }
  2742. bindEvent() {
  2743. this.addEvent(`click`, this.options.expander, () => {
  2744. this.expandAll();
  2745. });
  2746. this.addEvent(`click`, this.options.collapser, () => {
  2747. this.collapseAll();
  2748. });
  2749. this.addEvent("click", ".json-formater-arrow", (e) => {
  2750. const node = this.closest(e.currentTarget, "tr");
  2751. if (this.hasClass(node, "json-formater-opened")) {
  2752. this.hide(node);
  2753. } else {
  2754. this.show(node);
  2755. }
  2756. });
  2757. this.addEvent("click", ".json-formater-placeholder", (e) => {
  2758. const node = this.closest(e.currentTarget, "tr");
  2759. this.show(node);
  2760. });
  2761. this.addEvent("mousedown", "table tr", function(event) {
  2762. const { tagName } = event.target;
  2763. if (tagName === "A" || tagName === "SPAN" || event.ctrlKey) {
  2764. return;
  2765. }
  2766. Array.from(document.querySelectorAll(".selected")).filter((ele) => ele !== this).forEach((ele) => ele.classList.remove("selected"));
  2767. this.classList.toggle("selected");
  2768. });
  2769. }
  2770. expandAll() {
  2771. this.nodes().forEach((node) => {
  2772. this.show(node);
  2773. });
  2774. }
  2775. collapseAll() {
  2776. this.nodes().forEach((node) => {
  2777. this.hide(node);
  2778. });
  2779. }
  2780. show(node) {
  2781. this.removeClass(node, "json-formater-closed");
  2782. this.addClass(node, "json-formater-opened");
  2783. this.showDescs(node);
  2784. this.onShow(node);
  2785. }
  2786. onShow(node) {
  2787. const placeholder = node.querySelector(".json-formater-placeholder");
  2788. if (!placeholder) {
  2789. return;
  2790. }
  2791. placeholder.innerHTML = null;
  2792. const { onExpand } = this.options;
  2793. if (onExpand) onExpand(node, this);
  2794. }
  2795. showDescs(node) {
  2796. let children = this.findChildren(node);
  2797. children.forEach((child) => {
  2798. child.style.display = null;
  2799. if (this.hasClass(child, "json-formater-opened")) {
  2800. this.showDescs(child);
  2801. }
  2802. });
  2803. }
  2804. hide(node) {
  2805. this.removeClass(node, "json-formater-opened");
  2806. this.addClass(node, "json-formater-closed");
  2807. this.hideDescs(node);
  2808. this.onHide(node);
  2809. }
  2810. onHide(node) {
  2811. const type2 = node.dataset.type;
  2812. const placeholder = node.querySelector(".json-formater-placeholder");
  2813. if (!placeholder) {
  2814. return;
  2815. }
  2816. const length = this.findChildren(node).length;
  2817. let content = `[ <span>${length}${length > 1 ? " items" : " item"}</span> ]`;
  2818. if (type2 === "object") {
  2819. content = `{ <span>${length}${length > 1 ? " keys" : " key"}</span> }`;
  2820. }
  2821. placeholder.innerHTML = content;
  2822. const { onCollapse } = this.options;
  2823. if (onCollapse) onCollapse(node, this);
  2824. }
  2825. hideDescs(node) {
  2826. const children = this.findChildren(node);
  2827. children.forEach((child) => {
  2828. child.style.display = "none";
  2829. this.hideDescs(child);
  2830. });
  2831. }
  2832. findChildren(node) {
  2833. const pid = node.dataset.nodeId;
  2834. return this.$container.querySelectorAll(
  2835. `tr[data-node-pid="${pid}"]:not(.hidden)`
  2836. );
  2837. }
  2838. findByID(id) {
  2839. return this.$container.querySelector(`tr[data-node-id="${id}"]`);
  2840. }
  2841. openByID(id) {
  2842. this.show(this.findByID(id));
  2843. }
  2844. closeByID(id) {
  2845. this.hide(this.findByID(id));
  2846. }
  2847. addEvent(event, selector, fn) {
  2848. document.body.querySelectorAll(selector).forEach((el) => {
  2849. el.addEventListener(event, fn);
  2850. });
  2851. }
  2852. closest(element, selector) {
  2853. while (element) {
  2854. if (element.matches(selector)) {
  2855. return element;
  2856. }
  2857. element = element.parentElement;
  2858. }
  2859. return null;
  2860. }
  2861. hasClass(element, clas) {
  2862. return element.classList.contains(clas);
  2863. }
  2864. removeClass(element, clas) {
  2865. element.classList.remove(clas);
  2866. return this;
  2867. }
  2868. addClass(element, clas) {
  2869. element.classList.add(clas);
  2870. return this;
  2871. }
  2872. nodes() {
  2873. return this.$container.querySelectorAll("tr[data-node-id]");
  2874. }
  2875. /**
  2876. * 创建元素
  2877. * @param {String} name 元素名称
  2878. * @param {Object} attributes 属性
  2879. */
  2880. createElement(name, attributes) {
  2881. const element = document.createElement(name);
  2882. this.setAttributes(element, attributes);
  2883. return element;
  2884. }
  2885. /**
  2886. * 设置属性
  2887. * @param {HTMLElement} element 元素
  2888. * @param {Object} attributes 属性
  2889. */
  2890. setAttributes(element, attributes) {
  2891. if (!attributes) {
  2892. return;
  2893. }
  2894. for (const name in attributes) {
  2895. const value = attributes[name];
  2896. if (value) element.setAttribute(name, value);
  2897. }
  2898. }
  2899. /**
  2900. * 获取数据的类型
  2901. * @param {Object} value
  2902. * @return 返回类型 number、object、array、string、null等
  2903. */
  2904. getType(value) {
  2905. return Object.prototype.toString.call(value).match(/\s(.+)]/)[1].toLowerCase();
  2906. }
  2907. isIterate(value) {
  2908. const type2 = this.getType(value);
  2909. return ["array", "object"].includes(type2);
  2910. }
  2911. /**
  2912. * 是否可迭代
  2913. * @param {*} value
  2914. * @returns
  2915. */
  2916. canIterate(value) {
  2917. if (!this.isIterate(value)) {
  2918. return false;
  2919. }
  2920. let len = Object.keys(value).length;
  2921. return len > 0;
  2922. }
  2923. /**
  2924. * 是否为Url
  2925. * @param {*} str
  2926. * @returns
  2927. */
  2928. isUrl(str) {
  2929. const regexp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
  2930. return regexp.test(str);
  2931. }
  2932. /**
  2933. * 转义
  2934. * @param {*} str
  2935. * @returns
  2936. */
  2937. escape(str) {
  2938. return str.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  2939. }
  2940. isColor(colorString) {
  2941. const hexCodeRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
  2942. const rgbRegex = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/;
  2943. const rgbaRegex = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0\.\d+)\s*\)$/;
  2944. return hexCodeRegex.test(colorString) || rgbRegex.test(colorString) || rgbaRegex.test(colorString);
  2945. }
  2946. }
  2947. const evnet = {
  2948. /**
  2949. * a标签鼠标移入,看是否是图片,是图片生成预览图
  2950. * @returns this
  2951. */
  2952. urlHover: function() {
  2953. $(document.body).on("mouseenter", "a[href]", function() {
  2954. const href = $(this).attr("href");
  2955. if (Utils.isImg(href)) {
  2956. tippy(this, {
  2957. duration: 800,
  2958. content: `<img style="max-width: 500px;" src="${href}" />`,
  2959. allowHTML: true,
  2960. theme: "imagebox"
  2961. }).show();
  2962. }
  2963. });
  2964. return this;
  2965. },
  2966. /**
  2967. * 鼠标移入key提示JSONPath
  2968. * @returns this
  2969. */
  2970. tipsJsonPath: function() {
  2971. const that = this;
  2972. $(document.body).on("mouseenter", ".json-key", function() {
  2973. const jsonPath = that.getJsonPath(this);
  2974. const content = `<b>ctrl + 点击复制</b><br/>${jsonPath}`;
  2975. tippy(this, {
  2976. content,
  2977. duration: 800,
  2978. allowHTML: true,
  2979. theme: "layer"
  2980. }).show();
  2981. });
  2982. return that;
  2983. },
  2984. /**
  2985. * 复制key的JSONPath
  2986. * @returns
  2987. */
  2988. copyJsonPath: function() {
  2989. const that = this;
  2990. $(document.body).on("click", ".json-key", function(event) {
  2991. if (event.ctrlKey) {
  2992. const jsonPath = that.getJsonPath(this);
  2993. _GM_setClipboard(jsonPath);
  2994. layer.msg("复制成功", { time: 1500 });
  2995. }
  2996. });
  2997. return that;
  2998. },
  2999. /**
  3000. * 给定HtmlElement获取JSONPath
  3001. * @param {*} element
  3002. * @returns
  3003. */
  3004. getJsonPath: function(element) {
  3005. const jsonPath = $(element).parent().attr("json-path");
  3006. const split = jsonPath.split(".");
  3007. const splice = (prev, next) => {
  3008. return /^\d+$/.test(next) ? prev + `[${next}]` : prev + "." + next;
  3009. };
  3010. return split.reduce(splice);
  3011. },
  3012. init: function() {
  3013. this.urlHover().tipsJsonPath().copyJsonPath();
  3014. }
  3015. };
  3016. const format_style = exports("default", {
  3017. /**
  3018. * 切换JSON 格式化风格
  3019. * @param {*} style 格式化风格,default/table
  3020. * @returns
  3021. */
  3022. changeStyle: function(style) {
  3023. _GM_setValue("style", style);
  3024. this.setStyle();
  3025. return this;
  3026. },
  3027. /**
  3028. * 设置JSON 格式化风格
  3029. * @returns
  3030. */
  3031. setStyle: function() {
  3032. const style = _GM_getValue("style") || "default";
  3033. const theme = _GM_getValue("theme") || "default";
  3034. const formatBox = document.querySelector("#formatBox");
  3035. formatBox.innerHTML = "";
  3036. document.querySelector(".searchbox input").value = "";
  3037. if (style === "default") {
  3038. _unsafeWindow.JSON_VIEWER = new JsonViewer({
  3039. theme,
  3040. json: _unsafeWindow.GLOBAL_JSON,
  3041. container: formatBox
  3042. });
  3043. } else {
  3044. _unsafeWindow.JSON_TO_TABLE = new JsonToTable({
  3045. theme,
  3046. json: _unsafeWindow.GLOBAL_JSON,
  3047. container: formatBox
  3048. });
  3049. }
  3050. if (_unsafeWindow.GLOBAL_JSONP_FUN) {
  3051. const start = document.createElement("div");
  3052. start.setAttribute("class", "jsonp");
  3053. start.textContent = `${_unsafeWindow.GLOBAL_JSONP_FUN}(`;
  3054. formatBox.prepend(start);
  3055. const end = start.cloneNode(true);
  3056. end.textContent = ")";
  3057. formatBox.append(end);
  3058. }
  3059. return this;
  3060. },
  3061. init: function() {
  3062. const that = this;
  3063. that.setStyle();
  3064. evnet.init();
  3065. window.addEventListener("message", function(event) {
  3066. const { data } = event;
  3067. if (!data) {
  3068. return;
  3069. }
  3070. if (data.reload) {
  3071. that.setStyle();
  3072. return;
  3073. }
  3074. const { type: type2, value } = data;
  3075. if (type2 === "style") {
  3076. that.changeStyle(value);
  3077. return;
  3078. }
  3079. });
  3080. }
  3081. });
  3082.  
  3083. })
  3084. };
  3085. }));
  3086.  
  3087. System.register("./index-DgFsy9mH-BKxVgg-a.js", ['jquery', './__monkey.entry-DSLwfYjn.js', './tippy.esm-Ot9MORvr-DNGa7Opj.js', 'jsmind'], (function (exports, module) {
  3088. 'use strict';
  3089. var $, commonjsGlobal, _unsafeWindow, Utils, _GM_setClipboard, JSONbig, _GM_getValue, URL$1, _GM_setValue, tippy, require$$0;
  3090. return {
  3091. setters: [module => {
  3092. $ = module.default;
  3093. }, module => {
  3094. commonjsGlobal = module.d;
  3095. _unsafeWindow = module.b;
  3096. Utils = module.U;
  3097. _GM_setClipboard = module.c;
  3098. JSONbig = module.J;
  3099. _GM_getValue = module.a;
  3100. URL$1 = module.e;
  3101. _GM_setValue = module._;
  3102. }, module => {
  3103. tippy = module.t;
  3104. }, module => {
  3105. require$$0 = module.default;
  3106. }],
  3107. execute: (function () {
  3108.  
  3109. var domToImage = { exports: {} };
  3110. var hasRequiredDomToImage;
  3111. function requireDomToImage() {
  3112. if (hasRequiredDomToImage) return domToImage.exports;
  3113. hasRequiredDomToImage = 1;
  3114. (function(module) {
  3115. (function(global) {
  3116. var util = newUtil();
  3117. var inliner = newInliner();
  3118. var fontFaces = newFontFaces();
  3119. var images = newImages();
  3120. var defaultOptions = {
  3121. // Default is to fail on error, no placeholder
  3122. imagePlaceholder: void 0,
  3123. // Default cache bust is false, it will use the cache
  3124. cacheBust: false
  3125. };
  3126. var domtoimage = {
  3127. toSvg,
  3128. toPng,
  3129. toJpeg,
  3130. toBlob,
  3131. toPixelData,
  3132. impl: {
  3133. fontFaces,
  3134. images,
  3135. util,
  3136. inliner,
  3137. options: {}
  3138. }
  3139. };
  3140. module.exports = domtoimage;
  3141. function toSvg(node, options) {
  3142. options = options || {};
  3143. copyOptions(options);
  3144. return Promise.resolve(node).then(function(node2) {
  3145. return cloneNode(node2, options.filter, true);
  3146. }).then(embedFonts).then(inlineImages).then(applyOptions).then(function(clone) {
  3147. return makeSvgDataUri(
  3148. clone,
  3149. options.width || util.width(node),
  3150. options.height || util.height(node)
  3151. );
  3152. });
  3153. function applyOptions(clone) {
  3154. if (options.bgcolor) clone.style.backgroundColor = options.bgcolor;
  3155. if (options.width) clone.style.width = options.width + "px";
  3156. if (options.height) clone.style.height = options.height + "px";
  3157. if (options.style)
  3158. Object.keys(options.style).forEach(function(property) {
  3159. clone.style[property] = options.style[property];
  3160. });
  3161. return clone;
  3162. }
  3163. }
  3164. function toPixelData(node, options) {
  3165. return draw(node, options || {}).then(function(canvas) {
  3166. return canvas.getContext("2d").getImageData(
  3167. 0,
  3168. 0,
  3169. util.width(node),
  3170. util.height(node)
  3171. ).data;
  3172. });
  3173. }
  3174. function toPng(node, options) {
  3175. return draw(node, options || {}).then(function(canvas) {
  3176. return canvas.toDataURL();
  3177. });
  3178. }
  3179. function toJpeg(node, options) {
  3180. options = options || {};
  3181. return draw(node, options).then(function(canvas) {
  3182. return canvas.toDataURL("image/jpeg", options.quality || 1);
  3183. });
  3184. }
  3185. function toBlob(node, options) {
  3186. return draw(node, options || {}).then(util.canvasToBlob);
  3187. }
  3188. function copyOptions(options) {
  3189. if (typeof options.imagePlaceholder === "undefined") {
  3190. domtoimage.impl.options.imagePlaceholder = defaultOptions.imagePlaceholder;
  3191. } else {
  3192. domtoimage.impl.options.imagePlaceholder = options.imagePlaceholder;
  3193. }
  3194. if (typeof options.cacheBust === "undefined") {
  3195. domtoimage.impl.options.cacheBust = defaultOptions.cacheBust;
  3196. } else {
  3197. domtoimage.impl.options.cacheBust = options.cacheBust;
  3198. }
  3199. }
  3200. function draw(domNode, options) {
  3201. return toSvg(domNode, options).then(util.makeImage).then(util.delay(100)).then(function(image) {
  3202. var canvas = newCanvas(domNode);
  3203. canvas.getContext("2d").drawImage(image, 0, 0);
  3204. return canvas;
  3205. });
  3206. function newCanvas(domNode2) {
  3207. var canvas = document.createElement("canvas");
  3208. canvas.width = options.width || util.width(domNode2);
  3209. canvas.height = options.height || util.height(domNode2);
  3210. if (options.bgcolor) {
  3211. var ctx = canvas.getContext("2d");
  3212. ctx.fillStyle = options.bgcolor;
  3213. ctx.fillRect(0, 0, canvas.width, canvas.height);
  3214. }
  3215. return canvas;
  3216. }
  3217. }
  3218. function cloneNode(node, filter2, root) {
  3219. if (!root && filter2 && !filter2(node)) return Promise.resolve();
  3220. return Promise.resolve(node).then(makeNodeCopy).then(function(clone) {
  3221. return cloneChildren(node, clone, filter2);
  3222. }).then(function(clone) {
  3223. return processClone(node, clone);
  3224. });
  3225. function makeNodeCopy(node2) {
  3226. if (node2 instanceof HTMLCanvasElement) return util.makeImage(node2.toDataURL());
  3227. return node2.cloneNode(false);
  3228. }
  3229. function cloneChildren(original, clone, filter3) {
  3230. var children = original.childNodes;
  3231. if (children.length === 0) return Promise.resolve(clone);
  3232. return cloneChildrenInOrder(clone, util.asArray(children), filter3).then(function() {
  3233. return clone;
  3234. });
  3235. function cloneChildrenInOrder(parent, children2, filter4) {
  3236. var done = Promise.resolve();
  3237. children2.forEach(function(child) {
  3238. done = done.then(function() {
  3239. return cloneNode(child, filter4);
  3240. }).then(function(childClone) {
  3241. if (childClone) parent.appendChild(childClone);
  3242. });
  3243. });
  3244. return done;
  3245. }
  3246. }
  3247. function processClone(original, clone) {
  3248. if (!(clone instanceof Element)) return clone;
  3249. return Promise.resolve().then(cloneStyle).then(clonePseudoElements).then(copyUserInput).then(fixSvg).then(function() {
  3250. return clone;
  3251. });
  3252. function cloneStyle() {
  3253. copyStyle(window.getComputedStyle(original), clone.style);
  3254. function copyStyle(source, target) {
  3255. if (source.cssText) target.cssText = source.cssText;
  3256. else copyProperties(source, target);
  3257. function copyProperties(source2, target2) {
  3258. util.asArray(source2).forEach(function(name) {
  3259. target2.setProperty(
  3260. name,
  3261. source2.getPropertyValue(name),
  3262. source2.getPropertyPriority(name)
  3263. );
  3264. });
  3265. }
  3266. }
  3267. }
  3268. function clonePseudoElements() {
  3269. [":before", ":after"].forEach(function(element) {
  3270. clonePseudoElement(element);
  3271. });
  3272. function clonePseudoElement(element) {
  3273. var style = window.getComputedStyle(original, element);
  3274. var content = style.getPropertyValue("content");
  3275. if (content === "" || content === "none") return;
  3276. var className = util.uid();
  3277. clone.className = clone.className + " " + className;
  3278. var styleElement = document.createElement("style");
  3279. styleElement.appendChild(formatPseudoElementStyle(className, element, style));
  3280. clone.appendChild(styleElement);
  3281. function formatPseudoElementStyle(className2, element2, style2) {
  3282. var selector = "." + className2 + ":" + element2;
  3283. var cssText = style2.cssText ? formatCssText(style2) : formatCssProperties(style2);
  3284. return document.createTextNode(selector + "{" + cssText + "}");
  3285. function formatCssText(style3) {
  3286. var content2 = style3.getPropertyValue("content");
  3287. return style3.cssText + " content: " + content2 + ";";
  3288. }
  3289. function formatCssProperties(style3) {
  3290. return util.asArray(style3).map(formatProperty).join("; ") + ";";
  3291. function formatProperty(name) {
  3292. return name + ": " + style3.getPropertyValue(name) + (style3.getPropertyPriority(name) ? " !important" : "");
  3293. }
  3294. }
  3295. }
  3296. }
  3297. }
  3298. function copyUserInput() {
  3299. if (original instanceof HTMLTextAreaElement) clone.innerHTML = original.value;
  3300. if (original instanceof HTMLInputElement) clone.setAttribute("value", original.value);
  3301. }
  3302. function fixSvg() {
  3303. if (!(clone instanceof SVGElement)) return;
  3304. clone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
  3305. if (!(clone instanceof SVGRectElement)) return;
  3306. ["width", "height"].forEach(function(attribute) {
  3307. var value = clone.getAttribute(attribute);
  3308. if (!value) return;
  3309. clone.style.setProperty(attribute, value);
  3310. });
  3311. }
  3312. }
  3313. }
  3314. function embedFonts(node) {
  3315. return fontFaces.resolveAll().then(function(cssText) {
  3316. var styleNode = document.createElement("style");
  3317. node.appendChild(styleNode);
  3318. styleNode.appendChild(document.createTextNode(cssText));
  3319. return node;
  3320. });
  3321. }
  3322. function inlineImages(node) {
  3323. return images.inlineAll(node).then(function() {
  3324. return node;
  3325. });
  3326. }
  3327. function makeSvgDataUri(node, width, height) {
  3328. return Promise.resolve(node).then(function(node2) {
  3329. node2.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
  3330. return new XMLSerializer().serializeToString(node2);
  3331. }).then(util.escapeXhtml).then(function(xhtml) {
  3332. return '<foreignObject x="0" y="0" width="100%" height="100%">' + xhtml + "</foreignObject>";
  3333. }).then(function(foreignObject) {
  3334. return '<svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height + '">' + foreignObject + "</svg>";
  3335. }).then(function(svg) {
  3336. return "data:image/svg+xml;charset=utf-8," + svg;
  3337. });
  3338. }
  3339. function newUtil() {
  3340. return {
  3341. escape,
  3342. parseExtension,
  3343. mimeType,
  3344. dataAsUrl,
  3345. isDataUrl,
  3346. canvasToBlob,
  3347. resolveUrl,
  3348. getAndEncode,
  3349. uid: uid(),
  3350. delay,
  3351. asArray,
  3352. escapeXhtml,
  3353. makeImage,
  3354. width,
  3355. height
  3356. };
  3357. function mimes() {
  3358. var WOFF = "application/font-woff";
  3359. var JPEG = "image/jpeg";
  3360. return {
  3361. "woff": WOFF,
  3362. "woff2": WOFF,
  3363. "ttf": "application/font-truetype",
  3364. "eot": "application/vnd.ms-fontobject",
  3365. "png": "image/png",
  3366. "jpg": JPEG,
  3367. "jpeg": JPEG,
  3368. "gif": "image/gif",
  3369. "tiff": "image/tiff",
  3370. "svg": "image/svg+xml"
  3371. };
  3372. }
  3373. function parseExtension(url) {
  3374. var match = /\.([^\.\/]*?)$/g.exec(url);
  3375. if (match) return match[1];
  3376. else return "";
  3377. }
  3378. function mimeType(url) {
  3379. var extension = parseExtension(url).toLowerCase();
  3380. return mimes()[extension] || "";
  3381. }
  3382. function isDataUrl(url) {
  3383. return url.search(/^(data:)/) !== -1;
  3384. }
  3385. function toBlob2(canvas) {
  3386. return new Promise(function(resolve) {
  3387. var binaryString = window.atob(canvas.toDataURL().split(",")[1]);
  3388. var length = binaryString.length;
  3389. var binaryArray = new Uint8Array(length);
  3390. for (var i = 0; i < length; i++)
  3391. binaryArray[i] = binaryString.charCodeAt(i);
  3392. resolve(new Blob([binaryArray], {
  3393. type: "image/png"
  3394. }));
  3395. });
  3396. }
  3397. function canvasToBlob(canvas) {
  3398. if (canvas.toBlob)
  3399. return new Promise(function(resolve) {
  3400. canvas.toBlob(resolve);
  3401. });
  3402. return toBlob2(canvas);
  3403. }
  3404. function resolveUrl(url, baseUrl) {
  3405. var doc = document.implementation.createHTMLDocument();
  3406. var base = doc.createElement("base");
  3407. doc.head.appendChild(base);
  3408. var a = doc.createElement("a");
  3409. doc.body.appendChild(a);
  3410. base.href = baseUrl;
  3411. a.href = url;
  3412. return a.href;
  3413. }
  3414. function uid() {
  3415. var index = 0;
  3416. return function() {
  3417. return "u" + fourRandomChars() + index++;
  3418. function fourRandomChars() {
  3419. return ("0000" + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4);
  3420. }
  3421. };
  3422. }
  3423. function makeImage(uri) {
  3424. return new Promise(function(resolve, reject) {
  3425. var image = new Image();
  3426. image.onload = function() {
  3427. resolve(image);
  3428. };
  3429. image.onerror = reject;
  3430. image.src = uri;
  3431. });
  3432. }
  3433. function getAndEncode(url) {
  3434. var TIMEOUT = 3e4;
  3435. if (domtoimage.impl.options.cacheBust) {
  3436. url += (/\?/.test(url) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime();
  3437. }
  3438. return new Promise(function(resolve) {
  3439. var request = new XMLHttpRequest();
  3440. request.onreadystatechange = done;
  3441. request.ontimeout = timeout;
  3442. request.responseType = "blob";
  3443. request.timeout = TIMEOUT;
  3444. request.open("GET", url, true);
  3445. request.send();
  3446. var placeholder;
  3447. if (domtoimage.impl.options.imagePlaceholder) {
  3448. var split = domtoimage.impl.options.imagePlaceholder.split(/,/);
  3449. if (split && split[1]) {
  3450. placeholder = split[1];
  3451. }
  3452. }
  3453. function done() {
  3454. if (request.readyState !== 4) return;
  3455. if (request.status !== 200) {
  3456. if (placeholder) {
  3457. resolve(placeholder);
  3458. } else {
  3459. fail("cannot fetch resource: " + url + ", status: " + request.status);
  3460. }
  3461. return;
  3462. }
  3463. var encoder = new FileReader();
  3464. encoder.onloadend = function() {
  3465. var content = encoder.result.split(/,/)[1];
  3466. resolve(content);
  3467. };
  3468. encoder.readAsDataURL(request.response);
  3469. }
  3470. function timeout() {
  3471. if (placeholder) {
  3472. resolve(placeholder);
  3473. } else {
  3474. fail("timeout of " + TIMEOUT + "ms occured while fetching resource: " + url);
  3475. }
  3476. }
  3477. function fail(message) {
  3478. console.error(message);
  3479. resolve("");
  3480. }
  3481. });
  3482. }
  3483. function dataAsUrl(content, type) {
  3484. return "data:" + type + ";base64," + content;
  3485. }
  3486. function escape(string) {
  3487. return string.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
  3488. }
  3489. function delay(ms) {
  3490. return function(arg) {
  3491. return new Promise(function(resolve) {
  3492. setTimeout(function() {
  3493. resolve(arg);
  3494. }, ms);
  3495. });
  3496. };
  3497. }
  3498. function asArray(arrayLike) {
  3499. var array = [];
  3500. var length = arrayLike.length;
  3501. for (var i = 0; i < length; i++) array.push(arrayLike[i]);
  3502. return array;
  3503. }
  3504. function escapeXhtml(string) {
  3505. return string.replace(/#/g, "%23").replace(/\n/g, "%0A");
  3506. }
  3507. function width(node) {
  3508. var leftBorder = px(node, "border-left-width");
  3509. var rightBorder = px(node, "border-right-width");
  3510. return node.scrollWidth + leftBorder + rightBorder;
  3511. }
  3512. function height(node) {
  3513. var topBorder = px(node, "border-top-width");
  3514. var bottomBorder = px(node, "border-bottom-width");
  3515. return node.scrollHeight + topBorder + bottomBorder;
  3516. }
  3517. function px(node, styleProperty) {
  3518. var value = window.getComputedStyle(node).getPropertyValue(styleProperty);
  3519. return parseFloat(value.replace("px", ""));
  3520. }
  3521. }
  3522. function newInliner() {
  3523. var URL_REGEX = /url\(['"]?([^'"]+?)['"]?\)/g;
  3524. return {
  3525. inlineAll,
  3526. shouldProcess,
  3527. impl: {
  3528. readUrls,
  3529. inline
  3530. }
  3531. };
  3532. function shouldProcess(string) {
  3533. return string.search(URL_REGEX) !== -1;
  3534. }
  3535. function readUrls(string) {
  3536. var result = [];
  3537. var match;
  3538. while ((match = URL_REGEX.exec(string)) !== null) {
  3539. result.push(match[1]);
  3540. }
  3541. return result.filter(function(url) {
  3542. return !util.isDataUrl(url);
  3543. });
  3544. }
  3545. function inline(string, url, baseUrl, get) {
  3546. return Promise.resolve(url).then(function(url2) {
  3547. return baseUrl ? util.resolveUrl(url2, baseUrl) : url2;
  3548. }).then(get || util.getAndEncode).then(function(data) {
  3549. return util.dataAsUrl(data, util.mimeType(url));
  3550. }).then(function(dataUrl) {
  3551. return string.replace(urlAsRegex(url), "$1" + dataUrl + "$3");
  3552. });
  3553. function urlAsRegex(url2) {
  3554. return new RegExp(`(url\\(['"]?)(` + util.escape(url2) + `)(['"]?\\))`, "g");
  3555. }
  3556. }
  3557. function inlineAll(string, baseUrl, get) {
  3558. if (nothingToInline()) return Promise.resolve(string);
  3559. return Promise.resolve(string).then(readUrls).then(function(urls) {
  3560. var done = Promise.resolve(string);
  3561. urls.forEach(function(url) {
  3562. done = done.then(function(string2) {
  3563. return inline(string2, url, baseUrl, get);
  3564. });
  3565. });
  3566. return done;
  3567. });
  3568. function nothingToInline() {
  3569. return !shouldProcess(string);
  3570. }
  3571. }
  3572. }
  3573. function newFontFaces() {
  3574. return {
  3575. resolveAll,
  3576. impl: {
  3577. readAll
  3578. }
  3579. };
  3580. function resolveAll() {
  3581. return readAll().then(function(webFonts) {
  3582. return Promise.all(
  3583. webFonts.map(function(webFont) {
  3584. return webFont.resolve();
  3585. })
  3586. );
  3587. }).then(function(cssStrings) {
  3588. return cssStrings.join("\n");
  3589. });
  3590. }
  3591. function readAll() {
  3592. return Promise.resolve(util.asArray(document.styleSheets)).then(getCssRules).then(selectWebFontRules).then(function(rules) {
  3593. return rules.map(newWebFont);
  3594. });
  3595. function selectWebFontRules(cssRules) {
  3596. return cssRules.filter(function(rule) {
  3597. return rule.type === CSSRule.FONT_FACE_RULE;
  3598. }).filter(function(rule) {
  3599. return inliner.shouldProcess(rule.style.getPropertyValue("src"));
  3600. });
  3601. }
  3602. function getCssRules(styleSheets) {
  3603. var cssRules = [];
  3604. styleSheets.forEach(function(sheet) {
  3605. try {
  3606. util.asArray(sheet.cssRules || []).forEach(cssRules.push.bind(cssRules));
  3607. } catch (e) {
  3608. console.log("Error while reading CSS rules from " + sheet.href, e.toString());
  3609. }
  3610. });
  3611. return cssRules;
  3612. }
  3613. function newWebFont(webFontRule) {
  3614. return {
  3615. resolve: function resolve() {
  3616. var baseUrl = (webFontRule.parentStyleSheet || {}).href;
  3617. return inliner.inlineAll(webFontRule.cssText, baseUrl);
  3618. },
  3619. src: function() {
  3620. return webFontRule.style.getPropertyValue("src");
  3621. }
  3622. };
  3623. }
  3624. }
  3625. }
  3626. function newImages() {
  3627. return {
  3628. inlineAll,
  3629. impl: {
  3630. newImage
  3631. }
  3632. };
  3633. function newImage(element) {
  3634. return {
  3635. inline
  3636. };
  3637. function inline(get) {
  3638. if (util.isDataUrl(element.src)) return Promise.resolve();
  3639. return Promise.resolve(element.src).then(get || util.getAndEncode).then(function(data) {
  3640. return util.dataAsUrl(data, util.mimeType(element.src));
  3641. }).then(function(dataUrl) {
  3642. return new Promise(function(resolve, reject) {
  3643. element.onload = resolve;
  3644. element.onerror = reject;
  3645. element.src = dataUrl;
  3646. });
  3647. });
  3648. }
  3649. }
  3650. function inlineAll(node) {
  3651. if (!(node instanceof Element)) return Promise.resolve(node);
  3652. return inlineBackground(node).then(function() {
  3653. if (node instanceof HTMLImageElement)
  3654. return newImage(node).inline();
  3655. else
  3656. return Promise.all(
  3657. util.asArray(node.childNodes).map(function(child) {
  3658. return inlineAll(child);
  3659. })
  3660. );
  3661. });
  3662. function inlineBackground(node2) {
  3663. var background = node2.style.getPropertyValue("background");
  3664. if (!background) return Promise.resolve(node2);
  3665. return inliner.inlineAll(background).then(function(inlined) {
  3666. node2.style.setProperty(
  3667. "background",
  3668. inlined,
  3669. node2.style.getPropertyPriority("background")
  3670. );
  3671. }).then(function() {
  3672. return node2;
  3673. });
  3674. }
  3675. }
  3676. }
  3677. })();
  3678. })(domToImage);
  3679. return domToImage.exports;
  3680. }
  3681. /**
  3682. * @license BSD-3-Clause
  3683. * @copyright 2014-2023 hizzgdev@163.com
  3684. *
  3685. * Project Home:
  3686. * https://github.com/hizzgdev/jsmind/
  3687. */
  3688. (function(module, exports) {
  3689. !function(e, t) {
  3690. t(require$$0, requireDomToImage());
  3691. }(commonjsGlobal, function(e, t) {
  3692. function i(e2) {
  3693. return e2 && "object" == typeof e2 && "default" in e2 ? e2 : { default: e2 };
  3694. }
  3695. var n = i(e), o = i(t);
  3696. if (!n.default) throw new Error("jsMind is not defined");
  3697. if (!o.default) throw new Error("dom-to-image is required");
  3698. const r = n.default.$, s = { filename: null, watermark: { left: r.w.location, right: "https://github.com/hizzgdev/jsmind" }, background: "transparent" };
  3699. class a {
  3700. constructor(e2, t2) {
  3701. var i2 = {};
  3702. n.default.util.json.merge(i2, s), n.default.util.json.merge(i2, t2), this.version = "0.2.0", this.jm = e2, this.options = i2, this.dpr = e2.view.device_pixel_ratio;
  3703. }
  3704. shoot() {
  3705. let e2 = this.create_canvas(), t2 = e2.getContext("2d");
  3706. t2.scale(this.dpr, this.dpr), Promise.resolve(t2).then(() => this.draw_background(t2)).then(() => this.draw_lines(t2)).then(() => this.draw_nodes(t2)).then(() => this.draw_watermark(e2, t2)).then(() => this.download(e2)).then(() => this.clear(e2));
  3707. }
  3708. create_canvas() {
  3709. let e2 = r.c("canvas");
  3710. const t2 = this.jm.view.size.w, i2 = this.jm.view.size.h;
  3711. return e2.width = t2 * this.dpr, e2.height = i2 * this.dpr, e2.style.width = t2 + "px", e2.style.height = i2 + "px", e2.style.visibility = "hidden", this.jm.view.e_panel.appendChild(e2), e2;
  3712. }
  3713. clear(e2) {
  3714. e2.parentNode.removeChild(e2);
  3715. }
  3716. draw_background(e2) {
  3717. return new Promise((function(t2, i2) {
  3718. const n2 = this.options.background;
  3719. n2 && "transparent" !== n2 && (e2.fillStyle = this.options.background, e2.fillRect(0, 0, this.jm.view.size.w, this.jm.view.size.h)), t2(e2);
  3720. }).bind(this));
  3721. }
  3722. draw_lines(e2) {
  3723. return new Promise((function(t2, i2) {
  3724. this.jm.view.graph.copy_to(e2, function() {
  3725. t2(e2);
  3726. });
  3727. }).bind(this));
  3728. }
  3729. draw_nodes(e2) {
  3730. return o.default.toSvg(this.jm.view.e_nodes, { style: { zoom: 1 } }).then(this.load_image).then(function(t2) {
  3731. return e2.drawImage(t2, 0, 0), e2;
  3732. });
  3733. }
  3734. draw_watermark(e2, t2) {
  3735. return t2.textBaseline = "bottom", t2.fillStyle = "#000", t2.font = "11px Verdana,Arial,Helvetica,sans-serif", this.options.watermark.left && (t2.textAlign = "left", t2.fillText(this.options.watermark.left, 5.5, e2.height - 2.5)), this.options.watermark.right && (t2.textAlign = "right", t2.fillText(this.options.watermark.right, e2.width - 5.5, e2.height - 2.5)), t2;
  3736. }
  3737. load_image(e2) {
  3738. return new Promise(function(t2, i2) {
  3739. let n2 = new Image();
  3740. n2.onload = function() {
  3741. t2(n2);
  3742. }, n2.onerror = i2, n2.src = e2;
  3743. });
  3744. }
  3745. download(e2) {
  3746. var t2 = (this.options.filename || this.jm.mind.name) + ".png";
  3747. if (navigator.msSaveBlob && e2.msToBlob) {
  3748. var i2 = e2.msToBlob();
  3749. navigator.msSaveBlob(i2, t2);
  3750. } else {
  3751. var n2 = e2.toDataURL(), o2 = r.c("a");
  3752. if ("download" in o2) {
  3753. o2.style.visibility = "hidden", o2.href = n2, o2.download = t2, r.d.body.appendChild(o2);
  3754. var s2 = r.d.createEvent("MouseEvents");
  3755. s2.initEvent("click", true, true), o2.dispatchEvent(s2), r.d.body.removeChild(o2);
  3756. } else location.href = n2;
  3757. }
  3758. }
  3759. }
  3760. let d = new n.default.plugin("screenshot", function(e2, t2) {
  3761. var i2 = new a(e2, t2);
  3762. e2.screenshot = i2, e2.shoot = function() {
  3763. i2.shoot();
  3764. };
  3765. });
  3766. n.default.register_plugin(d);
  3767. });
  3768. })();
  3769. const jsonMind = {
  3770. isFirst: true,
  3771. /**
  3772. * JSON数据转换为jsMind所需要的数据结构
  3773. * @param {*} json JSON 数据
  3774. * @returns
  3775. */
  3776. convert: function(json) {
  3777. const children = [];
  3778. if (typeof json === "object") {
  3779. for (const key in json) {
  3780. let val = json[key], isArray = Array.isArray(val);
  3781. const type = Utils.getPrototype(val);
  3782. if (isArray && val.length > 0) {
  3783. val = Utils.findMaxKeysObject(val);
  3784. }
  3785. children.push({
  3786. isArray,
  3787. chain: key,
  3788. id: key + "_" + Math.random(),
  3789. topic: `${key}<span class="datatype">${type}</span>`,
  3790. children: this.convert(val)
  3791. });
  3792. }
  3793. }
  3794. return children;
  3795. },
  3796. /**
  3797. * 脑图节点调用链
  3798. * @param {*} node 脑图节点对象
  3799. * @returns
  3800. */
  3801. mindChain: function(node) {
  3802. let chain = node.data.chain;
  3803. if (!node.parent) {
  3804. return chain;
  3805. }
  3806. const parent = node.parent;
  3807. const parentChain = this.mindChain(parent);
  3808. chain = parent.data.isArray ? `${parentChain}[i].${chain}` : `${parentChain}.${chain}`;
  3809. return chain;
  3810. },
  3811. /**
  3812. * 显示脑图
  3813. * @param {*} json JSON 数据
  3814. * @returns
  3815. */
  3816. show: function(json) {
  3817. let isArr = Array.isArray(json);
  3818. if (isArr) {
  3819. if (typeof json[0] !== "object") {
  3820. layer.msg("数据结构无法生成脑图", { time: 1e3 });
  3821. return this;
  3822. }
  3823. json = Utils.findMaxKeysObject(json);
  3824. }
  3825. if (!this.isFirst) {
  3826. return this;
  3827. }
  3828. _unsafeWindow.GLOBAL_JSMIND.show({
  3829. meta: {
  3830. version: "1.0",
  3831. name: "JSON脑图",
  3832. author: "1220301855@qq.com"
  3833. },
  3834. format: "node_tree",
  3835. /* 数据内容 */
  3836. data: {
  3837. id: "root",
  3838. topic: "Root",
  3839. direction: "left",
  3840. children: this.convert(json),
  3841. chain: isArr ? "Root[i]" : "Root"
  3842. }
  3843. });
  3844. this.isFirst = false;
  3845. return this;
  3846. },
  3847. /**
  3848. * 脑图节点事件
  3849. * @returns
  3850. */
  3851. event: function() {
  3852. const jsonMind2 = this;
  3853. $(document.body).on("dblclick mouseover", "jmnode", function(event) {
  3854. const nodeid = $(this).attr("nodeid");
  3855. const node = _unsafeWindow.GLOBAL_JSMIND.get_node(nodeid);
  3856. if (!node.parent) {
  3857. return;
  3858. }
  3859. if (event.type === "dblclick") {
  3860. _GM_setClipboard(jsonMind2.mindChain(node));
  3861. layer.msg("节点路径复制成功", { time: 1500 });
  3862. } else {
  3863. const chain = jsonMind2.mindChain(node);
  3864. const content = `<b>节点路径(双击复制)</b><br/>${chain}`;
  3865. tippy(this, {
  3866. content,
  3867. duration: 800,
  3868. allowHTML: true,
  3869. theme: "layer"
  3870. }).show();
  3871. }
  3872. });
  3873. return this;
  3874. },
  3875. init: function(json) {
  3876. if (!_unsafeWindow.GLOBAL_JSMIND) {
  3877. _unsafeWindow.GLOBAL_JSMIND = new require$$0({
  3878. mode: "side",
  3879. editable: false,
  3880. container: "mindBox",
  3881. view: {
  3882. hmargin: 50,
  3883. // 思维导图距容器外框的最小水平距离
  3884. vmargin: 50,
  3885. // 思维导图距容器外框的最小垂直距离
  3886. engine: "svg",
  3887. // 思维导图各节点之间线条的绘制引擎
  3888. draggable: true,
  3889. // 当容器不能完全容纳思维导图时,是否允许拖动画布代替鼠标滚动
  3890. support_html: false,
  3891. line_color: "#C4C9D0"
  3892. },
  3893. zoom: {
  3894. // 配置缩放
  3895. min: 0.1,
  3896. // 最小的缩放比例
  3897. max: 2.1,
  3898. // 最大的缩放比例
  3899. step: 0.1
  3900. // 缩放比例间隔
  3901. },
  3902. layout: {
  3903. vspace: 7,
  3904. // 节点之间的垂直间距
  3905. hspace: 150
  3906. // 节点之间的水平空间
  3907. }
  3908. });
  3909. }
  3910. this.show(json).event();
  3911. }
  3912. };
  3913. const $mindBox = $("#mindBox");
  3914. const $formatBox = $("#formatBox");
  3915. const $rawTextBox = $("#rawTextBox");
  3916. const tabsEvent = {
  3917. firstFormat: true,
  3918. isBeautify: false,
  3919. $rawTextPre: $rawTextBox.find("pre"),
  3920. /**
  3921. * 原始数据
  3922. */
  3923. _setRawText: function() {
  3924. let rawText = _unsafeWindow.RAW_TEXT;
  3925. if (_unsafeWindow.GLOBAL_JSONP_FUN) {
  3926. rawText = `${_unsafeWindow.GLOBAL_JSONP_FUN}(${rawText})`;
  3927. }
  3928. this.$rawTextPre.text(rawText);
  3929. },
  3930. /**
  3931. * 保存为文件
  3932. * 如果是JSON 格式化可见,保存JSON数据为.json文件
  3933. * 如果是JSON 脑图可见,保存脑图为图片
  3934. */
  3935. saveJson: function() {
  3936. if ($mindBox.is(":visible")) {
  3937. _unsafeWindow.GLOBAL_JSMIND.shoot();
  3938. return;
  3939. }
  3940. const content = this.$rawTextPre.text() || _unsafeWindow.RAW_TEXT;
  3941. const filename = (/* @__PURE__ */ new Date()).getTime() + ".json";
  3942. Utils.downloadText(content, filename);
  3943. },
  3944. /**
  3945. * 复制JSON文本内容
  3946. */
  3947. copyJson: function() {
  3948. const content = this.$rawTextPre.text() || _unsafeWindow.RAW_TEXT;
  3949. _GM_setClipboard(content);
  3950. layer.msg("复制成功", { time: 1500 });
  3951. },
  3952. /**
  3953. * 点击了`全部折叠`
  3954. * 如果是JSON 格式化可见,折叠JSON
  3955. * 如果是JSON 脑图可见,折叠脑图节点
  3956. */
  3957. collapseAll: function() {
  3958. var _a, _b, _c, _d;
  3959. if ($formatBox.is(":visible")) {
  3960. (_b = (_a = _unsafeWindow) == null ? void 0 : _a.JSON_VIEWER) == null ? void 0 : _b.collapseAll();
  3961. (_d = (_c = _unsafeWindow) == null ? void 0 : _c.JSON_TO_TABLE) == null ? void 0 : _d.collapseAll();
  3962. return;
  3963. }
  3964. _unsafeWindow.GLOBAL_JSMIND.collapse_all();
  3965. },
  3966. /**
  3967. * 点击了`全部展开`
  3968. * 如果是JSON 格式化可见,展开JSON
  3969. * 如果是JSON 脑图可见,展开脑图节点
  3970. */
  3971. expandAll: function() {
  3972. var _a, _b, _c, _d;
  3973. if ($formatBox.is(":visible")) {
  3974. (_b = (_a = _unsafeWindow) == null ? void 0 : _a.JSON_VIEWER) == null ? void 0 : _b.expandAll();
  3975. (_d = (_c = _unsafeWindow) == null ? void 0 : _c.JSON_TO_TABLE) == null ? void 0 : _d.expandAll();
  3976. return;
  3977. }
  3978. _unsafeWindow.GLOBAL_JSMIND.expand_all();
  3979. _unsafeWindow.GLOBAL_JSMIND.scroll_node_to_center(
  3980. _unsafeWindow.GLOBAL_JSMIND.get_root()
  3981. );
  3982. },
  3983. viewFormater: function() {
  3984. },
  3985. /**
  3986. * tabs点击了`JSON 脑图`
  3987. */
  3988. viewMind: function() {
  3989. jsonMind.init(_unsafeWindow.GLOBAL_JSON);
  3990. _unsafeWindow.GLOBAL_JSMIND.scroll_node_to_center(
  3991. _unsafeWindow.GLOBAL_JSMIND.get_root()
  3992. );
  3993. },
  3994. /**
  3995. * tabs点击了`原始数据`
  3996. */
  3997. viewRawText: function() {
  3998. if (!this.firstFormat) {
  3999. return;
  4000. }
  4001. this.firstFormat = false;
  4002. this._setRawText();
  4003. },
  4004. /**
  4005. * 点击了`美化输出`
  4006. */
  4007. beautify: function() {
  4008. this.isBeautify = !this.isBeautify;
  4009. if (this.isBeautify) {
  4010. let str = JSONbig.stringify(_unsafeWindow.GLOBAL_JSON, null, 2);
  4011. if (_unsafeWindow.GLOBAL_JSONP_FUN) {
  4012. str = `${_unsafeWindow.GLOBAL_JSONP_FUN}(${str})`;
  4013. }
  4014. this.$rawTextPre.text(str);
  4015. return;
  4016. }
  4017. this._setRawText();
  4018. },
  4019. /**
  4020. * 点击了`JSON Crack`
  4021. */
  4022. jsoncrack: function() {
  4023. let theme2 = _GM_getValue("theme") || "light";
  4024. theme2 = theme2.replace(/_.*/, "");
  4025. layer.closeAll();
  4026. layer.open({
  4027. type: 1,
  4028. title: false,
  4029. area: ["100vw", "100vh"],
  4030. content: `<iframe id="jsoncrackEmbed" src="${URL$1.JSON_CRACK_WIDGET}"></iframe>`,
  4031. success: function(layero) {
  4032. const jsonCrackEmbed = layero.find("#jsoncrackEmbed")[0];
  4033. window == null ? void 0 : window.addEventListener("message", () => {
  4034. var _a;
  4035. (_a = jsonCrackEmbed == null ? void 0 : jsonCrackEmbed.contentWindow) == null ? void 0 : _a.postMessage(
  4036. {
  4037. options: { theme: theme2 },
  4038. json: _unsafeWindow.RAW_TEXT
  4039. },
  4040. "*"
  4041. );
  4042. });
  4043. }
  4044. });
  4045. },
  4046. init: function() {
  4047. $(document.body).on("click", ".btn", (e) => {
  4048. const target = e.target;
  4049. const id = target.id;
  4050. if (target.classList.contains("tabs-item")) {
  4051. const clas = "active";
  4052. const index = $(target).index();
  4053. $(target).addClass(clas).siblings().removeClass(clas);
  4054. $(".container > div").removeClass(clas).eq(index).addClass(clas);
  4055. const beautifyEl = $("#beautify");
  4056. const searchEl = $(".searchbox");
  4057. const copyEl = $("#copyJson");
  4058. const jsoncrackEl = $("#jsoncrack");
  4059. const aEl = $("#collapseAll, #expandAll");
  4060. id === "viewFormater" ? searchEl.show() : searchEl.hide();
  4061. id === "viewMind" ? copyEl.hide() && jsoncrackEl.show() : copyEl.show() && jsoncrackEl.hide();
  4062. id === "viewRawText" ? beautifyEl.show() && aEl.hide() : beautifyEl.hide() && aEl.show();
  4063. }
  4064. this[id](target);
  4065. });
  4066. return this;
  4067. }
  4068. };
  4069. window.addEventListener("message", function(event) {
  4070. const { data } = event;
  4071. if (!(data == null ? void 0 : data.reload)) {
  4072. return;
  4073. }
  4074. $mindBox.empty();
  4075. jsonMind.isFirst = true;
  4076. tabsEvent.isBeautify = false;
  4077. tabsEvent.firstFormat = true;
  4078. _unsafeWindow.GLOBAL_JSMIND = void 0;
  4079. if ($rawTextBox.is(":visible")) {
  4080. tabsEvent.viewRawText();
  4081. }
  4082. if ($mindBox.is(":visible")) {
  4083. jsonMind.init(_unsafeWindow.GLOBAL_JSON);
  4084. }
  4085. });
  4086. const filter = {
  4087. /**
  4088. * 根据`filter`过滤 JSON
  4089. * @param {*} filter 过滤值
  4090. * @returns
  4091. */
  4092. filterJSON: function(filter2) {
  4093. const style = _GM_getValue("style") || "default";
  4094. const allPath = $(`#formatBox *[json-path]`);
  4095. if (!filter2) {
  4096. style == "default" ? allPath.removeClass("hidden") : allPath.parent().removeClass("hidden");
  4097. return;
  4098. }
  4099. const chainSet = /* @__PURE__ */ new Set();
  4100. document.querySelectorAll("#formatBox *[json-path]").forEach((el) => {
  4101. let chain = $(el).attr("json-path");
  4102. if (!chain) {
  4103. return;
  4104. }
  4105. const newChain = chain.substring(chain.lastIndexOf("."));
  4106. if (!newChain.toLowerCase().includes(filter2.toLowerCase())) {
  4107. return;
  4108. }
  4109. chainSet.add(chain);
  4110. while (chain = chain.substring(0, chain.lastIndexOf("."))) {
  4111. chainSet.add(chain);
  4112. }
  4113. });
  4114. const selector = [
  4115. "json-key",
  4116. "json-comma",
  4117. "json-colon",
  4118. "json-viewer",
  4119. "json-formater-placeholder"
  4120. ].reduce(
  4121. (prev, next) => prev + ':not([class*="' + next + '"])',
  4122. "#formatBox *[class*='json-']"
  4123. );
  4124. document.querySelectorAll(selector).forEach((el) => {
  4125. const target = $(el);
  4126. let chain = target.siblings().attr("json-path");
  4127. if (style == "default") {
  4128. chain = target.parent().attr("json-path");
  4129. }
  4130. if (!chain) {
  4131. return;
  4132. }
  4133. const text = target.text();
  4134. if (!text.toLowerCase().includes(filter2.toLowerCase())) {
  4135. return;
  4136. }
  4137. chainSet.add(chain);
  4138. while (chain = chain.substring(0, chain.lastIndexOf("."))) {
  4139. chainSet.add(chain);
  4140. }
  4141. });
  4142. style == "default" ? allPath.addClass("hidden") : allPath.parent().addClass("hidden");
  4143. chainSet.forEach((chain) => {
  4144. const path = $(`#formatBox *[json-path="${chain}"]`);
  4145. style == "default" ? path.removeClass("hidden") : path.parent().removeClass("hidden");
  4146. });
  4147. },
  4148. /**
  4149. * JSON 过滤输入框事件监听
  4150. * @returns
  4151. */
  4152. input: function() {
  4153. const that = this;
  4154. $(document.body).on("input", ".searchbox input", function() {
  4155. const val = $(this).val();
  4156. $(".clear").attr("hidden", !val);
  4157. that.filterJSON(val);
  4158. });
  4159. return that;
  4160. },
  4161. /**
  4162. * 清空输入框内容
  4163. * @returns
  4164. */
  4165. clear: function() {
  4166. const that = this;
  4167. $(document.body).on("click", ".searchbox .clear", function() {
  4168. that.filterJSON();
  4169. $("input").val("");
  4170. $(this).attr("hidden", true);
  4171. });
  4172. return this;
  4173. },
  4174. init: function() {
  4175. this.input().clear();
  4176. }
  4177. };
  4178. const theme = {
  4179. /**
  4180. * 切换主题色
  4181. * @param {*} theme 主题色:default、light、dark、dark_plus
  4182. * @returns
  4183. */
  4184. changeTheme: function(theme2) {
  4185. _GM_setValue("theme", theme2);
  4186. this.setTheme();
  4187. return this;
  4188. },
  4189. /**
  4190. * 设置主题
  4191. * @returns
  4192. */
  4193. setTheme: function() {
  4194. var _a, _b, _c, _d;
  4195. const theme2 = _GM_getValue("theme") || "default";
  4196. (_b = (_a = _unsafeWindow) == null ? void 0 : _a.JSON_VIEWER) == null ? void 0 : _b.setTheme(theme2);
  4197. (_d = (_c = _unsafeWindow) == null ? void 0 : _c.JSON_TO_TABLE) == null ? void 0 : _d.setTheme(theme2);
  4198. return this;
  4199. },
  4200. init: function() {
  4201. const that = this;
  4202. that.setTheme();
  4203. window.addEventListener("message", function(event) {
  4204. const { data } = event;
  4205. if (!data) {
  4206. return;
  4207. }
  4208. const { type, value } = data;
  4209. if (type === "theme") {
  4210. that.changeTheme(value);
  4211. }
  4212. });
  4213. }
  4214. };
  4215. const http_form = `
  4216. <form class="httpRequest">
  4217. <div class="requestbox">
  4218. <select name="method">
  4219. <option value="POST">POST</option>
  4220. <option value="GET">GET</option>
  4221. <option value="PUT">PUT</option>
  4222. <option value="DELETE">DELETE</option>
  4223. </select>
  4224. <input name="url" placeholder="请求地址" />
  4225. <select name="contentType">
  4226. <option value="application/x-www-form-urlencoded;charset=UTF-8">urlencoded</option>
  4227. <option value="application/json;charset=UTF-8">application/json</option>
  4228. </select>
  4229. <button type="submit">发送</button>
  4230. </div>
  4231. <div class="textarea">
  4232. <input name="headers" placeholder='请求头 {"token": "test"}' />
  4233. <input name="params" placeholder='请求参数 {"id": "test", ""name": "test"}' />
  4234. </div>
  4235. </form>`;
  4236. const tools = {
  4237. inputJson: function() {
  4238. const that = this;
  4239. layer.prompt(
  4240. {
  4241. title: "JSON 输入",
  4242. formType: 2,
  4243. btn: ["确认"],
  4244. shadeClose: true,
  4245. maxlength: 1e6,
  4246. area: ["400px", "300px"]
  4247. },
  4248. function(text) {
  4249. if (!text) {
  4250. layer.msg("内容不能为空", { time: 1500 });
  4251. return;
  4252. }
  4253. const { rawText, jsonpFun } = Utils.jsonpMatch(text);
  4254. try {
  4255. const json = JSONbig({ useNativeBigInt: true }).parse(rawText);
  4256. that.reload(json, rawText, jsonpFun);
  4257. } catch (e) {
  4258. layer.msg("JSON格式不正确", { time: 1500 });
  4259. console.log("格式化异常: ", e);
  4260. }
  4261. }
  4262. );
  4263. return this;
  4264. },
  4265. fetchApi: function() {
  4266. const that = this;
  4267. layer.open({
  4268. type: 1,
  4269. closeBtn: 0,
  4270. shadeClose: true,
  4271. title: "HTTP 请求",
  4272. content: http_form
  4273. });
  4274. $("form").on("submit", function(event) {
  4275. event.preventDefault();
  4276. const serialize = $(this).serializeArray();
  4277. const form = {};
  4278. for (const key in serialize) {
  4279. const it = serialize[key];
  4280. form[it.name] = it.value;
  4281. }
  4282. if (form.url === "") {
  4283. layer.msg("请求URL不能为空");
  4284. return;
  4285. }
  4286. let headers = form.headers;
  4287. let params = form.params;
  4288. try {
  4289. if (headers) {
  4290. headers = JSON.parse(headers);
  4291. }
  4292. } catch (e) {
  4293. layer.msg("请求头格式不合法");
  4294. return;
  4295. }
  4296. try {
  4297. if (params) {
  4298. params = JSON.parse(params);
  4299. }
  4300. } catch (e) {
  4301. layer.msg("请求参数格式不合法");
  4302. return;
  4303. }
  4304. layer.load(0, { shade: false });
  4305. fetch(URL$1.ONLINE_REQUEST, {
  4306. method: "POST",
  4307. headers: {
  4308. "Content-Type": "application/json"
  4309. },
  4310. body: JSON.stringify(form)
  4311. }).then(async (response) => {
  4312. const result = await response.json();
  4313. if (typeof result === "string") {
  4314. try {
  4315. const { rawText, jsonpFun } = Utils.jsonpMatch(result);
  4316. const json = JSONbig({ useNativeBigInt: true }).parse(rawText);
  4317. that.reload(json, rawText, jsonpFun);
  4318. } catch (e) {
  4319. layer.closeAll();
  4320. console.log("HTTP 请求异常:", e);
  4321. }
  4322. } else {
  4323. that.reload(result, JSONbig.stringify(result), null);
  4324. }
  4325. }).catch((e) => {
  4326. layer.closeAll();
  4327. console.log("HTTP 请求异常:", e);
  4328. });
  4329. });
  4330. return this;
  4331. },
  4332. reload: function(json, rawText, jsonpFun) {
  4333. _unsafeWindow.GLOBAL_JSON = json;
  4334. _unsafeWindow.RAW_TEXT = rawText;
  4335. _unsafeWindow.GLOBAL_JSONP_FUN = jsonpFun;
  4336. window.postMessage({ reload: true });
  4337. layer.closeAll();
  4338. },
  4339. init: function() {
  4340. window.addEventListener("message", (event) => {
  4341. const { data } = event;
  4342. if (!data) {
  4343. return;
  4344. }
  4345. const { type, value } = data;
  4346. if (type === "tools") {
  4347. this[value]();
  4348. }
  4349. });
  4350. }
  4351. };
  4352. const handleBar = {
  4353. instance: null,
  4354. /**
  4355. * 对右侧操作栏的点击事件初始化
  4356. * @returns
  4357. */
  4358. handle: function() {
  4359. const that = this;
  4360. const tagName = "span";
  4361. [".style", ".theme", ".tools"].forEach((selector) => {
  4362. tippy(selector, {
  4363. duration: 500,
  4364. allowHTML: true,
  4365. interactive: true,
  4366. trigger: "click",
  4367. appendTo: document.querySelector(selector).parentNode,
  4368. onTrigger: function(instance) {
  4369. const tools2 = $(instance.reference);
  4370. tools2.siblings().find(tagName).removeClass();
  4371. tools2.find(tagName).addClass("active");
  4372. const template = tools2.find("template");
  4373. const type = template.data("type");
  4374. const value = _GM_getValue(type) || "default";
  4375. const ul = template.contents();
  4376. ul.find("li").removeClass();
  4377. ul.find(`li[data-value=${value}]`).addClass("active");
  4378. instance.setContent(template.html());
  4379. that.instance = instance;
  4380. },
  4381. onHide: function(instance) {
  4382. const tools2 = $(instance.reference);
  4383. tools2.find(tagName).removeClass();
  4384. }
  4385. });
  4386. });
  4387. return this;
  4388. },
  4389. /**
  4390. * 点击了对应选项
  4391. * 如点击了`主题`-`暗黑`,通过window.postMessage进行主题色更新
  4392. * @returns
  4393. */
  4394. checked: function() {
  4395. const that = this;
  4396. $(document.body).on("click", ".rightbox li", function() {
  4397. const el = $(this);
  4398. const hasClass = el.hasClass("active");
  4399. if (hasClass) {
  4400. return;
  4401. }
  4402. const type = el.data("type");
  4403. const value = el.data("value");
  4404. if (type !== "tools") {
  4405. el.addClass("active").siblings().removeClass();
  4406. } else {
  4407. that.instance.hide();
  4408. }
  4409. window.postMessage({ type, value });
  4410. });
  4411. return this;
  4412. },
  4413. init: function() {
  4414. this.handle().checked();
  4415. }
  4416. };
  4417. tabsEvent.init();
  4418. theme.init();
  4419. tools.init();
  4420. filter.init();
  4421. handleBar.init();
  4422.  
  4423. })
  4424. };
  4425. }));
  4426.  
  4427. System.register("./tippy.esm-Ot9MORvr-DNGa7Opj.js", [], (function (exports, module) {
  4428. 'use strict';
  4429. return {
  4430. execute: (function () {
  4431.  
  4432. exports("t", tippy);
  4433.  
  4434. var top = "top";
  4435. var bottom = "bottom";
  4436. var right = "right";
  4437. var left = "left";
  4438. var auto = "auto";
  4439. var basePlacements = [top, bottom, right, left];
  4440. var start = "start";
  4441. var end = "end";
  4442. var clippingParents = "clippingParents";
  4443. var viewport = "viewport";
  4444. var popper = "popper";
  4445. var reference = "reference";
  4446. var variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) {
  4447. return acc.concat([placement + "-" + start, placement + "-" + end]);
  4448. }, []);
  4449. var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
  4450. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  4451. }, []);
  4452. var beforeRead = "beforeRead";
  4453. var read = "read";
  4454. var afterRead = "afterRead";
  4455. var beforeMain = "beforeMain";
  4456. var main = "main";
  4457. var afterMain = "afterMain";
  4458. var beforeWrite = "beforeWrite";
  4459. var write = "write";
  4460. var afterWrite = "afterWrite";
  4461. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  4462. function getNodeName(element) {
  4463. return element ? (element.nodeName || "").toLowerCase() : null;
  4464. }
  4465. function getWindow(node) {
  4466. if (node == null) {
  4467. return window;
  4468. }
  4469. if (node.toString() !== "[object Window]") {
  4470. var ownerDocument = node.ownerDocument;
  4471. return ownerDocument ? ownerDocument.defaultView || window : window;
  4472. }
  4473. return node;
  4474. }
  4475. function isElement$1(node) {
  4476. var OwnElement = getWindow(node).Element;
  4477. return node instanceof OwnElement || node instanceof Element;
  4478. }
  4479. function isHTMLElement(node) {
  4480. var OwnElement = getWindow(node).HTMLElement;
  4481. return node instanceof OwnElement || node instanceof HTMLElement;
  4482. }
  4483. function isShadowRoot(node) {
  4484. if (typeof ShadowRoot === "undefined") {
  4485. return false;
  4486. }
  4487. var OwnElement = getWindow(node).ShadowRoot;
  4488. return node instanceof OwnElement || node instanceof ShadowRoot;
  4489. }
  4490. function applyStyles(_ref) {
  4491. var state = _ref.state;
  4492. Object.keys(state.elements).forEach(function(name) {
  4493. var style = state.styles[name] || {};
  4494. var attributes = state.attributes[name] || {};
  4495. var element = state.elements[name];
  4496. if (!isHTMLElement(element) || !getNodeName(element)) {
  4497. return;
  4498. }
  4499. Object.assign(element.style, style);
  4500. Object.keys(attributes).forEach(function(name2) {
  4501. var value = attributes[name2];
  4502. if (value === false) {
  4503. element.removeAttribute(name2);
  4504. } else {
  4505. element.setAttribute(name2, value === true ? "" : value);
  4506. }
  4507. });
  4508. });
  4509. }
  4510. function effect$2(_ref2) {
  4511. var state = _ref2.state;
  4512. var initialStyles = {
  4513. popper: {
  4514. position: state.options.strategy,
  4515. left: "0",
  4516. top: "0",
  4517. margin: "0"
  4518. },
  4519. arrow: {
  4520. position: "absolute"
  4521. },
  4522. reference: {}
  4523. };
  4524. Object.assign(state.elements.popper.style, initialStyles.popper);
  4525. state.styles = initialStyles;
  4526. if (state.elements.arrow) {
  4527. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  4528. }
  4529. return function() {
  4530. Object.keys(state.elements).forEach(function(name) {
  4531. var element = state.elements[name];
  4532. var attributes = state.attributes[name] || {};
  4533. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
  4534. var style = styleProperties.reduce(function(style2, property) {
  4535. style2[property] = "";
  4536. return style2;
  4537. }, {});
  4538. if (!isHTMLElement(element) || !getNodeName(element)) {
  4539. return;
  4540. }
  4541. Object.assign(element.style, style);
  4542. Object.keys(attributes).forEach(function(attribute) {
  4543. element.removeAttribute(attribute);
  4544. });
  4545. });
  4546. };
  4547. }
  4548. const applyStyles$1 = {
  4549. name: "applyStyles",
  4550. enabled: true,
  4551. phase: "write",
  4552. fn: applyStyles,
  4553. effect: effect$2,
  4554. requires: ["computeStyles"]
  4555. };
  4556. function getBasePlacement$1(placement) {
  4557. return placement.split("-")[0];
  4558. }
  4559. var max = Math.max;
  4560. var min = Math.min;
  4561. var round = Math.round;
  4562. function getUAString() {
  4563. var uaData = navigator.userAgentData;
  4564. if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
  4565. return uaData.brands.map(function(item) {
  4566. return item.brand + "/" + item.version;
  4567. }).join(" ");
  4568. }
  4569. return navigator.userAgent;
  4570. }
  4571. function isLayoutViewport() {
  4572. return !/^((?!chrome|android).)*safari/i.test(getUAString());
  4573. }
  4574. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  4575. if (includeScale === void 0) {
  4576. includeScale = false;
  4577. }
  4578. if (isFixedStrategy === void 0) {
  4579. isFixedStrategy = false;
  4580. }
  4581. var clientRect = element.getBoundingClientRect();
  4582. var scaleX = 1;
  4583. var scaleY = 1;
  4584. if (includeScale && isHTMLElement(element)) {
  4585. scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
  4586. scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
  4587. }
  4588. var _ref = isElement$1(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
  4589. var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
  4590. var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
  4591. var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
  4592. var width = clientRect.width / scaleX;
  4593. var height = clientRect.height / scaleY;
  4594. return {
  4595. width,
  4596. height,
  4597. top: y,
  4598. right: x + width,
  4599. bottom: y + height,
  4600. left: x,
  4601. x,
  4602. y
  4603. };
  4604. }
  4605. function getLayoutRect(element) {
  4606. var clientRect = getBoundingClientRect(element);
  4607. var width = element.offsetWidth;
  4608. var height = element.offsetHeight;
  4609. if (Math.abs(clientRect.width - width) <= 1) {
  4610. width = clientRect.width;
  4611. }
  4612. if (Math.abs(clientRect.height - height) <= 1) {
  4613. height = clientRect.height;
  4614. }
  4615. return {
  4616. x: element.offsetLeft,
  4617. y: element.offsetTop,
  4618. width,
  4619. height
  4620. };
  4621. }
  4622. function contains(parent, child) {
  4623. var rootNode = child.getRootNode && child.getRootNode();
  4624. if (parent.contains(child)) {
  4625. return true;
  4626. } else if (rootNode && isShadowRoot(rootNode)) {
  4627. var next = child;
  4628. do {
  4629. if (next && parent.isSameNode(next)) {
  4630. return true;
  4631. }
  4632. next = next.parentNode || next.host;
  4633. } while (next);
  4634. }
  4635. return false;
  4636. }
  4637. function getComputedStyle(element) {
  4638. return getWindow(element).getComputedStyle(element);
  4639. }
  4640. function isTableElement(element) {
  4641. return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
  4642. }
  4643. function getDocumentElement(element) {
  4644. return ((isElement$1(element) ? element.ownerDocument : (
  4645. // $FlowFixMe[prop-missing]
  4646. element.document
  4647. )) || window.document).documentElement;
  4648. }
  4649. function getParentNode(element) {
  4650. if (getNodeName(element) === "html") {
  4651. return element;
  4652. }
  4653. return (
  4654. // this is a quicker (but less type safe) way to save quite some bytes from the bundle
  4655. // $FlowFixMe[incompatible-return]
  4656. // $FlowFixMe[prop-missing]
  4657. element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
  4658. element.parentNode || // DOM Element detected
  4659. (isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
  4660. // $FlowFixMe[incompatible-call]: HTMLElement is a Node
  4661. getDocumentElement(element)
  4662. );
  4663. }
  4664. function getTrueOffsetParent(element) {
  4665. if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
  4666. getComputedStyle(element).position === "fixed") {
  4667. return null;
  4668. }
  4669. return element.offsetParent;
  4670. }
  4671. function getContainingBlock(element) {
  4672. var isFirefox = /firefox/i.test(getUAString());
  4673. var isIE = /Trident/i.test(getUAString());
  4674. if (isIE && isHTMLElement(element)) {
  4675. var elementCss = getComputedStyle(element);
  4676. if (elementCss.position === "fixed") {
  4677. return null;
  4678. }
  4679. }
  4680. var currentNode = getParentNode(element);
  4681. if (isShadowRoot(currentNode)) {
  4682. currentNode = currentNode.host;
  4683. }
  4684. while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
  4685. var css = getComputedStyle(currentNode);
  4686. if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
  4687. return currentNode;
  4688. } else {
  4689. currentNode = currentNode.parentNode;
  4690. }
  4691. }
  4692. return null;
  4693. }
  4694. function getOffsetParent(element) {
  4695. var window2 = getWindow(element);
  4696. var offsetParent = getTrueOffsetParent(element);
  4697. while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
  4698. offsetParent = getTrueOffsetParent(offsetParent);
  4699. }
  4700. if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static")) {
  4701. return window2;
  4702. }
  4703. return offsetParent || getContainingBlock(element) || window2;
  4704. }
  4705. function getMainAxisFromPlacement(placement) {
  4706. return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
  4707. }
  4708. function within(min$1, value, max$1) {
  4709. return max(min$1, min(value, max$1));
  4710. }
  4711. function withinMaxClamp(min2, value, max2) {
  4712. var v = within(min2, value, max2);
  4713. return v > max2 ? max2 : v;
  4714. }
  4715. function getFreshSideObject() {
  4716. return {
  4717. top: 0,
  4718. right: 0,
  4719. bottom: 0,
  4720. left: 0
  4721. };
  4722. }
  4723. function mergePaddingObject(paddingObject) {
  4724. return Object.assign({}, getFreshSideObject(), paddingObject);
  4725. }
  4726. function expandToHashMap(value, keys) {
  4727. return keys.reduce(function(hashMap, key) {
  4728. hashMap[key] = value;
  4729. return hashMap;
  4730. }, {});
  4731. }
  4732. var toPaddingObject = function toPaddingObject2(padding, state) {
  4733. padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
  4734. placement: state.placement
  4735. })) : padding;
  4736. return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
  4737. };
  4738. function arrow(_ref) {
  4739. var _state$modifiersData$;
  4740. var state = _ref.state, name = _ref.name, options = _ref.options;
  4741. var arrowElement = state.elements.arrow;
  4742. var popperOffsets2 = state.modifiersData.popperOffsets;
  4743. var basePlacement = getBasePlacement$1(state.placement);
  4744. var axis = getMainAxisFromPlacement(basePlacement);
  4745. var isVertical = [left, right].indexOf(basePlacement) >= 0;
  4746. var len = isVertical ? "height" : "width";
  4747. if (!arrowElement || !popperOffsets2) {
  4748. return;
  4749. }
  4750. var paddingObject = toPaddingObject(options.padding, state);
  4751. var arrowRect = getLayoutRect(arrowElement);
  4752. var minProp = axis === "y" ? top : left;
  4753. var maxProp = axis === "y" ? bottom : right;
  4754. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
  4755. var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
  4756. var arrowOffsetParent = getOffsetParent(arrowElement);
  4757. var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  4758. var centerToReference = endDiff / 2 - startDiff / 2;
  4759. var min2 = paddingObject[minProp];
  4760. var max2 = clientSize - arrowRect[len] - paddingObject[maxProp];
  4761. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  4762. var offset2 = within(min2, center, max2);
  4763. var axisProp = axis;
  4764. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset2, _state$modifiersData$.centerOffset = offset2 - center, _state$modifiersData$);
  4765. }
  4766. function effect$1(_ref2) {
  4767. var state = _ref2.state, options = _ref2.options;
  4768. var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
  4769. if (arrowElement == null) {
  4770. return;
  4771. }
  4772. if (typeof arrowElement === "string") {
  4773. arrowElement = state.elements.popper.querySelector(arrowElement);
  4774. if (!arrowElement) {
  4775. return;
  4776. }
  4777. }
  4778. if (!contains(state.elements.popper, arrowElement)) {
  4779. return;
  4780. }
  4781. state.elements.arrow = arrowElement;
  4782. }
  4783. const arrow$1 = {
  4784. name: "arrow",
  4785. enabled: true,
  4786. phase: "main",
  4787. fn: arrow,
  4788. effect: effect$1,
  4789. requires: ["popperOffsets"],
  4790. requiresIfExists: ["preventOverflow"]
  4791. };
  4792. function getVariation(placement) {
  4793. return placement.split("-")[1];
  4794. }
  4795. var unsetSides = {
  4796. top: "auto",
  4797. right: "auto",
  4798. bottom: "auto",
  4799. left: "auto"
  4800. };
  4801. function roundOffsetsByDPR(_ref, win) {
  4802. var x = _ref.x, y = _ref.y;
  4803. var dpr = win.devicePixelRatio || 1;
  4804. return {
  4805. x: round(x * dpr) / dpr || 0,
  4806. y: round(y * dpr) / dpr || 0
  4807. };
  4808. }
  4809. function mapToStyles(_ref2) {
  4810. var _Object$assign2;
  4811. var popper2 = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
  4812. var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
  4813. var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
  4814. x,
  4815. y
  4816. }) : {
  4817. x,
  4818. y
  4819. };
  4820. x = _ref3.x;
  4821. y = _ref3.y;
  4822. var hasX = offsets.hasOwnProperty("x");
  4823. var hasY = offsets.hasOwnProperty("y");
  4824. var sideX = left;
  4825. var sideY = top;
  4826. var win = window;
  4827. if (adaptive) {
  4828. var offsetParent = getOffsetParent(popper2);
  4829. var heightProp = "clientHeight";
  4830. var widthProp = "clientWidth";
  4831. if (offsetParent === getWindow(popper2)) {
  4832. offsetParent = getDocumentElement(popper2);
  4833. if (getComputedStyle(offsetParent).position !== "static" && position === "absolute") {
  4834. heightProp = "scrollHeight";
  4835. widthProp = "scrollWidth";
  4836. }
  4837. }
  4838. offsetParent = offsetParent;
  4839. if (placement === top || (placement === left || placement === right) && variation === end) {
  4840. sideY = bottom;
  4841. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : (
  4842. // $FlowFixMe[prop-missing]
  4843. offsetParent[heightProp]
  4844. );
  4845. y -= offsetY - popperRect.height;
  4846. y *= gpuAcceleration ? 1 : -1;
  4847. }
  4848. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  4849. sideX = right;
  4850. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : (
  4851. // $FlowFixMe[prop-missing]
  4852. offsetParent[widthProp]
  4853. );
  4854. x -= offsetX - popperRect.width;
  4855. x *= gpuAcceleration ? 1 : -1;
  4856. }
  4857. }
  4858. var commonStyles = Object.assign({
  4859. position
  4860. }, adaptive && unsetSides);
  4861. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  4862. x,
  4863. y
  4864. }, getWindow(popper2)) : {
  4865. x,
  4866. y
  4867. };
  4868. x = _ref4.x;
  4869. y = _ref4.y;
  4870. if (gpuAcceleration) {
  4871. var _Object$assign;
  4872. return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
  4873. }
  4874. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
  4875. }
  4876. function computeStyles(_ref5) {
  4877. var state = _ref5.state, options = _ref5.options;
  4878. var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  4879. var commonStyles = {
  4880. placement: getBasePlacement$1(state.placement),
  4881. variation: getVariation(state.placement),
  4882. popper: state.elements.popper,
  4883. popperRect: state.rects.popper,
  4884. gpuAcceleration,
  4885. isFixed: state.options.strategy === "fixed"
  4886. };
  4887. if (state.modifiersData.popperOffsets != null) {
  4888. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  4889. offsets: state.modifiersData.popperOffsets,
  4890. position: state.options.strategy,
  4891. adaptive,
  4892. roundOffsets
  4893. })));
  4894. }
  4895. if (state.modifiersData.arrow != null) {
  4896. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  4897. offsets: state.modifiersData.arrow,
  4898. position: "absolute",
  4899. adaptive: false,
  4900. roundOffsets
  4901. })));
  4902. }
  4903. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  4904. "data-popper-placement": state.placement
  4905. });
  4906. }
  4907. const computeStyles$1 = {
  4908. name: "computeStyles",
  4909. enabled: true,
  4910. phase: "beforeWrite",
  4911. fn: computeStyles,
  4912. data: {}
  4913. };
  4914. var passive = {
  4915. passive: true
  4916. };
  4917. function effect(_ref) {
  4918. var state = _ref.state, instance = _ref.instance, options = _ref.options;
  4919. var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
  4920. var window2 = getWindow(state.elements.popper);
  4921. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  4922. if (scroll) {
  4923. scrollParents.forEach(function(scrollParent) {
  4924. scrollParent.addEventListener("scroll", instance.update, passive);
  4925. });
  4926. }
  4927. if (resize) {
  4928. window2.addEventListener("resize", instance.update, passive);
  4929. }
  4930. return function() {
  4931. if (scroll) {
  4932. scrollParents.forEach(function(scrollParent) {
  4933. scrollParent.removeEventListener("scroll", instance.update, passive);
  4934. });
  4935. }
  4936. if (resize) {
  4937. window2.removeEventListener("resize", instance.update, passive);
  4938. }
  4939. };
  4940. }
  4941. const eventListeners = {
  4942. name: "eventListeners",
  4943. enabled: true,
  4944. phase: "write",
  4945. fn: function fn() {
  4946. },
  4947. effect,
  4948. data: {}
  4949. };
  4950. var hash$1 = {
  4951. left: "right",
  4952. right: "left",
  4953. bottom: "top",
  4954. top: "bottom"
  4955. };
  4956. function getOppositePlacement(placement) {
  4957. return placement.replace(/left|right|bottom|top/g, function(matched) {
  4958. return hash$1[matched];
  4959. });
  4960. }
  4961. var hash = {
  4962. start: "end",
  4963. end: "start"
  4964. };
  4965. function getOppositeVariationPlacement(placement) {
  4966. return placement.replace(/start|end/g, function(matched) {
  4967. return hash[matched];
  4968. });
  4969. }
  4970. function getWindowScroll(node) {
  4971. var win = getWindow(node);
  4972. var scrollLeft = win.pageXOffset;
  4973. var scrollTop = win.pageYOffset;
  4974. return {
  4975. scrollLeft,
  4976. scrollTop
  4977. };
  4978. }
  4979. function getWindowScrollBarX(element) {
  4980. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  4981. }
  4982. function getViewportRect(element, strategy) {
  4983. var win = getWindow(element);
  4984. var html = getDocumentElement(element);
  4985. var visualViewport = win.visualViewport;
  4986. var width = html.clientWidth;
  4987. var height = html.clientHeight;
  4988. var x = 0;
  4989. var y = 0;
  4990. if (visualViewport) {
  4991. width = visualViewport.width;
  4992. height = visualViewport.height;
  4993. var layoutViewport = isLayoutViewport();
  4994. if (layoutViewport || !layoutViewport && strategy === "fixed") {
  4995. x = visualViewport.offsetLeft;
  4996. y = visualViewport.offsetTop;
  4997. }
  4998. }
  4999. return {
  5000. width,
  5001. height,
  5002. x: x + getWindowScrollBarX(element),
  5003. y
  5004. };
  5005. }
  5006. function getDocumentRect(element) {
  5007. var _element$ownerDocumen;
  5008. var html = getDocumentElement(element);
  5009. var winScroll = getWindowScroll(element);
  5010. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  5011. var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  5012. var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  5013. var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
  5014. var y = -winScroll.scrollTop;
  5015. if (getComputedStyle(body || html).direction === "rtl") {
  5016. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  5017. }
  5018. return {
  5019. width,
  5020. height,
  5021. x,
  5022. y
  5023. };
  5024. }
  5025. function isScrollParent(element) {
  5026. var _getComputedStyle = getComputedStyle(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
  5027. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  5028. }
  5029. function getScrollParent(node) {
  5030. if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
  5031. return node.ownerDocument.body;
  5032. }
  5033. if (isHTMLElement(node) && isScrollParent(node)) {
  5034. return node;
  5035. }
  5036. return getScrollParent(getParentNode(node));
  5037. }
  5038. function listScrollParents(element, list) {
  5039. var _element$ownerDocumen;
  5040. if (list === void 0) {
  5041. list = [];
  5042. }
  5043. var scrollParent = getScrollParent(element);
  5044. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  5045. var win = getWindow(scrollParent);
  5046. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  5047. var updatedList = list.concat(target);
  5048. return isBody ? updatedList : (
  5049. // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
  5050. updatedList.concat(listScrollParents(getParentNode(target)))
  5051. );
  5052. }
  5053. function rectToClientRect(rect) {
  5054. return Object.assign({}, rect, {
  5055. left: rect.x,
  5056. top: rect.y,
  5057. right: rect.x + rect.width,
  5058. bottom: rect.y + rect.height
  5059. });
  5060. }
  5061. function getInnerBoundingClientRect(element, strategy) {
  5062. var rect = getBoundingClientRect(element, false, strategy === "fixed");
  5063. rect.top = rect.top + element.clientTop;
  5064. rect.left = rect.left + element.clientLeft;
  5065. rect.bottom = rect.top + element.clientHeight;
  5066. rect.right = rect.left + element.clientWidth;
  5067. rect.width = element.clientWidth;
  5068. rect.height = element.clientHeight;
  5069. rect.x = rect.left;
  5070. rect.y = rect.top;
  5071. return rect;
  5072. }
  5073. function getClientRectFromMixedType(element, clippingParent, strategy) {
  5074. return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
  5075. }
  5076. function getClippingParents(element) {
  5077. var clippingParents2 = listScrollParents(getParentNode(element));
  5078. var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle(element).position) >= 0;
  5079. var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
  5080. if (!isElement$1(clipperElement)) {
  5081. return [];
  5082. }
  5083. return clippingParents2.filter(function(clippingParent) {
  5084. return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
  5085. });
  5086. }
  5087. function getClippingRect(element, boundary, rootBoundary, strategy) {
  5088. var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
  5089. var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
  5090. var firstClippingParent = clippingParents2[0];
  5091. var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
  5092. var rect = getClientRectFromMixedType(element, clippingParent, strategy);
  5093. accRect.top = max(rect.top, accRect.top);
  5094. accRect.right = min(rect.right, accRect.right);
  5095. accRect.bottom = min(rect.bottom, accRect.bottom);
  5096. accRect.left = max(rect.left, accRect.left);
  5097. return accRect;
  5098. }, getClientRectFromMixedType(element, firstClippingParent, strategy));
  5099. clippingRect.width = clippingRect.right - clippingRect.left;
  5100. clippingRect.height = clippingRect.bottom - clippingRect.top;
  5101. clippingRect.x = clippingRect.left;
  5102. clippingRect.y = clippingRect.top;
  5103. return clippingRect;
  5104. }
  5105. function computeOffsets(_ref) {
  5106. var reference2 = _ref.reference, element = _ref.element, placement = _ref.placement;
  5107. var basePlacement = placement ? getBasePlacement$1(placement) : null;
  5108. var variation = placement ? getVariation(placement) : null;
  5109. var commonX = reference2.x + reference2.width / 2 - element.width / 2;
  5110. var commonY = reference2.y + reference2.height / 2 - element.height / 2;
  5111. var offsets;
  5112. switch (basePlacement) {
  5113. case top:
  5114. offsets = {
  5115. x: commonX,
  5116. y: reference2.y - element.height
  5117. };
  5118. break;
  5119. case bottom:
  5120. offsets = {
  5121. x: commonX,
  5122. y: reference2.y + reference2.height
  5123. };
  5124. break;
  5125. case right:
  5126. offsets = {
  5127. x: reference2.x + reference2.width,
  5128. y: commonY
  5129. };
  5130. break;
  5131. case left:
  5132. offsets = {
  5133. x: reference2.x - element.width,
  5134. y: commonY
  5135. };
  5136. break;
  5137. default:
  5138. offsets = {
  5139. x: reference2.x,
  5140. y: reference2.y
  5141. };
  5142. }
  5143. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  5144. if (mainAxis != null) {
  5145. var len = mainAxis === "y" ? "height" : "width";
  5146. switch (variation) {
  5147. case start:
  5148. offsets[mainAxis] = offsets[mainAxis] - (reference2[len] / 2 - element[len] / 2);
  5149. break;
  5150. case end:
  5151. offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element[len] / 2);
  5152. break;
  5153. }
  5154. }
  5155. return offsets;
  5156. }
  5157. function detectOverflow(state, options) {
  5158. if (options === void 0) {
  5159. options = {};
  5160. }
  5161. var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$strategy = _options.strategy, strategy = _options$strategy === void 0 ? state.strategy : _options$strategy, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
  5162. var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
  5163. var altContext = elementContext === popper ? reference : popper;
  5164. var popperRect = state.rects.popper;
  5165. var element = state.elements[altBoundary ? altContext : elementContext];
  5166. var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
  5167. var referenceClientRect = getBoundingClientRect(state.elements.reference);
  5168. var popperOffsets2 = computeOffsets({
  5169. reference: referenceClientRect,
  5170. element: popperRect,
  5171. strategy: "absolute",
  5172. placement
  5173. });
  5174. var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
  5175. var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
  5176. var overflowOffsets = {
  5177. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  5178. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  5179. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  5180. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  5181. };
  5182. var offsetData = state.modifiersData.offset;
  5183. if (elementContext === popper && offsetData) {
  5184. var offset2 = offsetData[placement];
  5185. Object.keys(overflowOffsets).forEach(function(key) {
  5186. var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
  5187. var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
  5188. overflowOffsets[key] += offset2[axis] * multiply;
  5189. });
  5190. }
  5191. return overflowOffsets;
  5192. }
  5193. function computeAutoPlacement(state, options) {
  5194. if (options === void 0) {
  5195. options = {};
  5196. }
  5197. var _options = options, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
  5198. var variation = getVariation(placement);
  5199. var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement2) {
  5200. return getVariation(placement2) === variation;
  5201. }) : basePlacements;
  5202. var allowedPlacements = placements$1.filter(function(placement2) {
  5203. return allowedAutoPlacements.indexOf(placement2) >= 0;
  5204. });
  5205. if (allowedPlacements.length === 0) {
  5206. allowedPlacements = placements$1;
  5207. }
  5208. var overflows = allowedPlacements.reduce(function(acc, placement2) {
  5209. acc[placement2] = detectOverflow(state, {
  5210. placement: placement2,
  5211. boundary,
  5212. rootBoundary,
  5213. padding
  5214. })[getBasePlacement$1(placement2)];
  5215. return acc;
  5216. }, {});
  5217. return Object.keys(overflows).sort(function(a, b) {
  5218. return overflows[a] - overflows[b];
  5219. });
  5220. }
  5221. function getExpandedFallbackPlacements(placement) {
  5222. if (getBasePlacement$1(placement) === auto) {
  5223. return [];
  5224. }
  5225. var oppositePlacement = getOppositePlacement(placement);
  5226. return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
  5227. }
  5228. function flip(_ref) {
  5229. var state = _ref.state, options = _ref.options, name = _ref.name;
  5230. if (state.modifiersData[name]._skip) {
  5231. return;
  5232. }
  5233. var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options.fallbackPlacements, padding = options.padding, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, _options$flipVariatio = options.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options.allowedAutoPlacements;
  5234. var preferredPlacement = state.options.placement;
  5235. var basePlacement = getBasePlacement$1(preferredPlacement);
  5236. var isBasePlacement = basePlacement === preferredPlacement;
  5237. var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
  5238. var placements2 = [preferredPlacement].concat(fallbackPlacements).reduce(function(acc, placement2) {
  5239. return acc.concat(getBasePlacement$1(placement2) === auto ? computeAutoPlacement(state, {
  5240. placement: placement2,
  5241. boundary,
  5242. rootBoundary,
  5243. padding,
  5244. flipVariations,
  5245. allowedAutoPlacements
  5246. }) : placement2);
  5247. }, []);
  5248. var referenceRect = state.rects.reference;
  5249. var popperRect = state.rects.popper;
  5250. var checksMap = /* @__PURE__ */ new Map();
  5251. var makeFallbackChecks = true;
  5252. var firstFittingPlacement = placements2[0];
  5253. for (var i = 0; i < placements2.length; i++) {
  5254. var placement = placements2[i];
  5255. var _basePlacement = getBasePlacement$1(placement);
  5256. var isStartVariation = getVariation(placement) === start;
  5257. var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
  5258. var len = isVertical ? "width" : "height";
  5259. var overflow = detectOverflow(state, {
  5260. placement,
  5261. boundary,
  5262. rootBoundary,
  5263. altBoundary,
  5264. padding
  5265. });
  5266. var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
  5267. if (referenceRect[len] > popperRect[len]) {
  5268. mainVariationSide = getOppositePlacement(mainVariationSide);
  5269. }
  5270. var altVariationSide = getOppositePlacement(mainVariationSide);
  5271. var checks = [];
  5272. if (checkMainAxis) {
  5273. checks.push(overflow[_basePlacement] <= 0);
  5274. }
  5275. if (checkAltAxis) {
  5276. checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
  5277. }
  5278. if (checks.every(function(check) {
  5279. return check;
  5280. })) {
  5281. firstFittingPlacement = placement;
  5282. makeFallbackChecks = false;
  5283. break;
  5284. }
  5285. checksMap.set(placement, checks);
  5286. }
  5287. if (makeFallbackChecks) {
  5288. var numberOfChecks = flipVariations ? 3 : 1;
  5289. var _loop = function _loop2(_i2) {
  5290. var fittingPlacement = placements2.find(function(placement2) {
  5291. var checks2 = checksMap.get(placement2);
  5292. if (checks2) {
  5293. return checks2.slice(0, _i2).every(function(check) {
  5294. return check;
  5295. });
  5296. }
  5297. });
  5298. if (fittingPlacement) {
  5299. firstFittingPlacement = fittingPlacement;
  5300. return "break";
  5301. }
  5302. };
  5303. for (var _i = numberOfChecks; _i > 0; _i--) {
  5304. var _ret = _loop(_i);
  5305. if (_ret === "break") break;
  5306. }
  5307. }
  5308. if (state.placement !== firstFittingPlacement) {
  5309. state.modifiersData[name]._skip = true;
  5310. state.placement = firstFittingPlacement;
  5311. state.reset = true;
  5312. }
  5313. }
  5314. const flip$1 = {
  5315. name: "flip",
  5316. enabled: true,
  5317. phase: "main",
  5318. fn: flip,
  5319. requiresIfExists: ["offset"],
  5320. data: {
  5321. _skip: false
  5322. }
  5323. };
  5324. function getSideOffsets(overflow, rect, preventedOffsets) {
  5325. if (preventedOffsets === void 0) {
  5326. preventedOffsets = {
  5327. x: 0,
  5328. y: 0
  5329. };
  5330. }
  5331. return {
  5332. top: overflow.top - rect.height - preventedOffsets.y,
  5333. right: overflow.right - rect.width + preventedOffsets.x,
  5334. bottom: overflow.bottom - rect.height + preventedOffsets.y,
  5335. left: overflow.left - rect.width - preventedOffsets.x
  5336. };
  5337. }
  5338. function isAnySideFullyClipped(overflow) {
  5339. return [top, right, bottom, left].some(function(side) {
  5340. return overflow[side] >= 0;
  5341. });
  5342. }
  5343. function hide(_ref) {
  5344. var state = _ref.state, name = _ref.name;
  5345. var referenceRect = state.rects.reference;
  5346. var popperRect = state.rects.popper;
  5347. var preventedOffsets = state.modifiersData.preventOverflow;
  5348. var referenceOverflow = detectOverflow(state, {
  5349. elementContext: "reference"
  5350. });
  5351. var popperAltOverflow = detectOverflow(state, {
  5352. altBoundary: true
  5353. });
  5354. var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
  5355. var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
  5356. var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
  5357. var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
  5358. state.modifiersData[name] = {
  5359. referenceClippingOffsets,
  5360. popperEscapeOffsets,
  5361. isReferenceHidden,
  5362. hasPopperEscaped
  5363. };
  5364. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  5365. "data-popper-reference-hidden": isReferenceHidden,
  5366. "data-popper-escaped": hasPopperEscaped
  5367. });
  5368. }
  5369. const hide$1 = {
  5370. name: "hide",
  5371. enabled: true,
  5372. phase: "main",
  5373. requiresIfExists: ["preventOverflow"],
  5374. fn: hide
  5375. };
  5376. function distanceAndSkiddingToXY(placement, rects, offset2) {
  5377. var basePlacement = getBasePlacement$1(placement);
  5378. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  5379. var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
  5380. placement
  5381. })) : offset2, skidding = _ref[0], distance = _ref[1];
  5382. skidding = skidding || 0;
  5383. distance = (distance || 0) * invertDistance;
  5384. return [left, right].indexOf(basePlacement) >= 0 ? {
  5385. x: distance,
  5386. y: skidding
  5387. } : {
  5388. x: skidding,
  5389. y: distance
  5390. };
  5391. }
  5392. function offset(_ref2) {
  5393. var state = _ref2.state, options = _ref2.options, name = _ref2.name;
  5394. var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
  5395. var data = placements.reduce(function(acc, placement) {
  5396. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
  5397. return acc;
  5398. }, {});
  5399. var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
  5400. if (state.modifiersData.popperOffsets != null) {
  5401. state.modifiersData.popperOffsets.x += x;
  5402. state.modifiersData.popperOffsets.y += y;
  5403. }
  5404. state.modifiersData[name] = data;
  5405. }
  5406. const offset$1 = {
  5407. name: "offset",
  5408. enabled: true,
  5409. phase: "main",
  5410. requires: ["popperOffsets"],
  5411. fn: offset
  5412. };
  5413. function popperOffsets(_ref) {
  5414. var state = _ref.state, name = _ref.name;
  5415. state.modifiersData[name] = computeOffsets({
  5416. reference: state.rects.reference,
  5417. element: state.rects.popper,
  5418. strategy: "absolute",
  5419. placement: state.placement
  5420. });
  5421. }
  5422. const popperOffsets$1 = {
  5423. name: "popperOffsets",
  5424. enabled: true,
  5425. phase: "read",
  5426. fn: popperOffsets,
  5427. data: {}
  5428. };
  5429. function getAltAxis(axis) {
  5430. return axis === "x" ? "y" : "x";
  5431. }
  5432. function preventOverflow(_ref) {
  5433. var state = _ref.state, options = _ref.options, name = _ref.name;
  5434. var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
  5435. var overflow = detectOverflow(state, {
  5436. boundary,
  5437. rootBoundary,
  5438. padding,
  5439. altBoundary
  5440. });
  5441. var basePlacement = getBasePlacement$1(state.placement);
  5442. var variation = getVariation(state.placement);
  5443. var isBasePlacement = !variation;
  5444. var mainAxis = getMainAxisFromPlacement(basePlacement);
  5445. var altAxis = getAltAxis(mainAxis);
  5446. var popperOffsets2 = state.modifiersData.popperOffsets;
  5447. var referenceRect = state.rects.reference;
  5448. var popperRect = state.rects.popper;
  5449. var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
  5450. placement: state.placement
  5451. })) : tetherOffset;
  5452. var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
  5453. mainAxis: tetherOffsetValue,
  5454. altAxis: tetherOffsetValue
  5455. } : Object.assign({
  5456. mainAxis: 0,
  5457. altAxis: 0
  5458. }, tetherOffsetValue);
  5459. var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
  5460. var data = {
  5461. x: 0,
  5462. y: 0
  5463. };
  5464. if (!popperOffsets2) {
  5465. return;
  5466. }
  5467. if (checkMainAxis) {
  5468. var _offsetModifierState$;
  5469. var mainSide = mainAxis === "y" ? top : left;
  5470. var altSide = mainAxis === "y" ? bottom : right;
  5471. var len = mainAxis === "y" ? "height" : "width";
  5472. var offset2 = popperOffsets2[mainAxis];
  5473. var min$1 = offset2 + overflow[mainSide];
  5474. var max$1 = offset2 - overflow[altSide];
  5475. var additive = tether ? -popperRect[len] / 2 : 0;
  5476. var minLen = variation === start ? referenceRect[len] : popperRect[len];
  5477. var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
  5478. var arrowElement = state.elements.arrow;
  5479. var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
  5480. width: 0,
  5481. height: 0
  5482. };
  5483. var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
  5484. var arrowPaddingMin = arrowPaddingObject[mainSide];
  5485. var arrowPaddingMax = arrowPaddingObject[altSide];
  5486. var arrowLen = within(0, referenceRect[len], arrowRect[len]);
  5487. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
  5488. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
  5489. var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
  5490. var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  5491. var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
  5492. var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
  5493. var tetherMax = offset2 + maxOffset - offsetModifierValue;
  5494. var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset2, tether ? max(max$1, tetherMax) : max$1);
  5495. popperOffsets2[mainAxis] = preventedOffset;
  5496. data[mainAxis] = preventedOffset - offset2;
  5497. }
  5498. if (checkAltAxis) {
  5499. var _offsetModifierState$2;
  5500. var _mainSide = mainAxis === "x" ? top : left;
  5501. var _altSide = mainAxis === "x" ? bottom : right;
  5502. var _offset = popperOffsets2[altAxis];
  5503. var _len = altAxis === "y" ? "height" : "width";
  5504. var _min = _offset + overflow[_mainSide];
  5505. var _max = _offset - overflow[_altSide];
  5506. var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
  5507. var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
  5508. var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
  5509. var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
  5510. var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
  5511. popperOffsets2[altAxis] = _preventedOffset;
  5512. data[altAxis] = _preventedOffset - _offset;
  5513. }
  5514. state.modifiersData[name] = data;
  5515. }
  5516. const preventOverflow$1 = {
  5517. name: "preventOverflow",
  5518. enabled: true,
  5519. phase: "main",
  5520. fn: preventOverflow,
  5521. requiresIfExists: ["offset"]
  5522. };
  5523. function getHTMLElementScroll(element) {
  5524. return {
  5525. scrollLeft: element.scrollLeft,
  5526. scrollTop: element.scrollTop
  5527. };
  5528. }
  5529. function getNodeScroll(node) {
  5530. if (node === getWindow(node) || !isHTMLElement(node)) {
  5531. return getWindowScroll(node);
  5532. } else {
  5533. return getHTMLElementScroll(node);
  5534. }
  5535. }
  5536. function isElementScaled(element) {
  5537. var rect = element.getBoundingClientRect();
  5538. var scaleX = round(rect.width) / element.offsetWidth || 1;
  5539. var scaleY = round(rect.height) / element.offsetHeight || 1;
  5540. return scaleX !== 1 || scaleY !== 1;
  5541. }
  5542. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  5543. if (isFixed === void 0) {
  5544. isFixed = false;
  5545. }
  5546. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  5547. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  5548. var documentElement = getDocumentElement(offsetParent);
  5549. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
  5550. var scroll = {
  5551. scrollLeft: 0,
  5552. scrollTop: 0
  5553. };
  5554. var offsets = {
  5555. x: 0,
  5556. y: 0
  5557. };
  5558. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  5559. if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
  5560. isScrollParent(documentElement)) {
  5561. scroll = getNodeScroll(offsetParent);
  5562. }
  5563. if (isHTMLElement(offsetParent)) {
  5564. offsets = getBoundingClientRect(offsetParent, true);
  5565. offsets.x += offsetParent.clientLeft;
  5566. offsets.y += offsetParent.clientTop;
  5567. } else if (documentElement) {
  5568. offsets.x = getWindowScrollBarX(documentElement);
  5569. }
  5570. }
  5571. return {
  5572. x: rect.left + scroll.scrollLeft - offsets.x,
  5573. y: rect.top + scroll.scrollTop - offsets.y,
  5574. width: rect.width,
  5575. height: rect.height
  5576. };
  5577. }
  5578. function order(modifiers) {
  5579. var map = /* @__PURE__ */ new Map();
  5580. var visited = /* @__PURE__ */ new Set();
  5581. var result = [];
  5582. modifiers.forEach(function(modifier) {
  5583. map.set(modifier.name, modifier);
  5584. });
  5585. function sort(modifier) {
  5586. visited.add(modifier.name);
  5587. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  5588. requires.forEach(function(dep) {
  5589. if (!visited.has(dep)) {
  5590. var depModifier = map.get(dep);
  5591. if (depModifier) {
  5592. sort(depModifier);
  5593. }
  5594. }
  5595. });
  5596. result.push(modifier);
  5597. }
  5598. modifiers.forEach(function(modifier) {
  5599. if (!visited.has(modifier.name)) {
  5600. sort(modifier);
  5601. }
  5602. });
  5603. return result;
  5604. }
  5605. function orderModifiers(modifiers) {
  5606. var orderedModifiers = order(modifiers);
  5607. return modifierPhases.reduce(function(acc, phase) {
  5608. return acc.concat(orderedModifiers.filter(function(modifier) {
  5609. return modifier.phase === phase;
  5610. }));
  5611. }, []);
  5612. }
  5613. function debounce$1(fn2) {
  5614. var pending;
  5615. return function() {
  5616. if (!pending) {
  5617. pending = new Promise(function(resolve) {
  5618. Promise.resolve().then(function() {
  5619. pending = void 0;
  5620. resolve(fn2());
  5621. });
  5622. });
  5623. }
  5624. return pending;
  5625. };
  5626. }
  5627. function mergeByName(modifiers) {
  5628. var merged = modifiers.reduce(function(merged2, current) {
  5629. var existing = merged2[current.name];
  5630. merged2[current.name] = existing ? Object.assign({}, existing, current, {
  5631. options: Object.assign({}, existing.options, current.options),
  5632. data: Object.assign({}, existing.data, current.data)
  5633. }) : current;
  5634. return merged2;
  5635. }, {});
  5636. return Object.keys(merged).map(function(key) {
  5637. return merged[key];
  5638. });
  5639. }
  5640. var DEFAULT_OPTIONS = {
  5641. placement: "bottom",
  5642. modifiers: [],
  5643. strategy: "absolute"
  5644. };
  5645. function areValidElements() {
  5646. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5647. args[_key] = arguments[_key];
  5648. }
  5649. return !args.some(function(element) {
  5650. return !(element && typeof element.getBoundingClientRect === "function");
  5651. });
  5652. }
  5653. function popperGenerator(generatorOptions) {
  5654. if (generatorOptions === void 0) {
  5655. generatorOptions = {};
  5656. }
  5657. var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers2 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  5658. return function createPopper2(reference2, popper2, options) {
  5659. if (options === void 0) {
  5660. options = defaultOptions;
  5661. }
  5662. var state = {
  5663. placement: "bottom",
  5664. orderedModifiers: [],
  5665. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  5666. modifiersData: {},
  5667. elements: {
  5668. reference: reference2,
  5669. popper: popper2
  5670. },
  5671. attributes: {},
  5672. styles: {}
  5673. };
  5674. var effectCleanupFns = [];
  5675. var isDestroyed = false;
  5676. var instance = {
  5677. state,
  5678. setOptions: function setOptions(setOptionsAction) {
  5679. var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
  5680. cleanupModifierEffects();
  5681. state.options = Object.assign({}, defaultOptions, state.options, options2);
  5682. state.scrollParents = {
  5683. reference: isElement$1(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
  5684. popper: listScrollParents(popper2)
  5685. };
  5686. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
  5687. state.orderedModifiers = orderedModifiers.filter(function(m) {
  5688. return m.enabled;
  5689. });
  5690. runModifierEffects();
  5691. return instance.update();
  5692. },
  5693. // Sync update – it will always be executed, even if not necessary. This
  5694. // is useful for low frequency updates where sync behavior simplifies the
  5695. // logic.
  5696. // For high frequency updates (e.g. `resize` and `scroll` events), always
  5697. // prefer the async Popper#update method
  5698. forceUpdate: function forceUpdate() {
  5699. if (isDestroyed) {
  5700. return;
  5701. }
  5702. var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper;
  5703. if (!areValidElements(reference3, popper3)) {
  5704. return;
  5705. }
  5706. state.rects = {
  5707. reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
  5708. popper: getLayoutRect(popper3)
  5709. };
  5710. state.reset = false;
  5711. state.placement = state.options.placement;
  5712. state.orderedModifiers.forEach(function(modifier) {
  5713. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  5714. });
  5715. for (var index = 0; index < state.orderedModifiers.length; index++) {
  5716. if (state.reset === true) {
  5717. state.reset = false;
  5718. index = -1;
  5719. continue;
  5720. }
  5721. var _state$orderedModifie = state.orderedModifiers[index], fn2 = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name;
  5722. if (typeof fn2 === "function") {
  5723. state = fn2({
  5724. state,
  5725. options: _options,
  5726. name,
  5727. instance
  5728. }) || state;
  5729. }
  5730. }
  5731. },
  5732. // Async and optimistically optimized update – it will not be executed if
  5733. // not necessary (debounced to run at most once-per-tick)
  5734. update: debounce$1(function() {
  5735. return new Promise(function(resolve) {
  5736. instance.forceUpdate();
  5737. resolve(state);
  5738. });
  5739. }),
  5740. destroy: function destroy() {
  5741. cleanupModifierEffects();
  5742. isDestroyed = true;
  5743. }
  5744. };
  5745. if (!areValidElements(reference2, popper2)) {
  5746. return instance;
  5747. }
  5748. instance.setOptions(options).then(function(state2) {
  5749. if (!isDestroyed && options.onFirstUpdate) {
  5750. options.onFirstUpdate(state2);
  5751. }
  5752. });
  5753. function runModifierEffects() {
  5754. state.orderedModifiers.forEach(function(_ref) {
  5755. var name = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect3 = _ref.effect;
  5756. if (typeof effect3 === "function") {
  5757. var cleanupFn = effect3({
  5758. state,
  5759. name,
  5760. instance,
  5761. options: options2
  5762. });
  5763. var noopFn = function noopFn2() {
  5764. };
  5765. effectCleanupFns.push(cleanupFn || noopFn);
  5766. }
  5767. });
  5768. }
  5769. function cleanupModifierEffects() {
  5770. effectCleanupFns.forEach(function(fn2) {
  5771. return fn2();
  5772. });
  5773. effectCleanupFns = [];
  5774. }
  5775. return instance;
  5776. };
  5777. }
  5778. var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
  5779. var createPopper = /* @__PURE__ */ popperGenerator({
  5780. defaultModifiers
  5781. });
  5782. var BOX_CLASS = "tippy-box";
  5783. var CONTENT_CLASS = "tippy-content";
  5784. var BACKDROP_CLASS = "tippy-backdrop";
  5785. var ARROW_CLASS = "tippy-arrow";
  5786. var SVG_ARROW_CLASS = "tippy-svg-arrow";
  5787. var TOUCH_OPTIONS = {
  5788. passive: true,
  5789. capture: true
  5790. };
  5791. var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO2() {
  5792. return document.body;
  5793. };
  5794. function getValueAtIndexOrReturn(value, index, defaultValue) {
  5795. if (Array.isArray(value)) {
  5796. var v = value[index];
  5797. return v == null ? Array.isArray(defaultValue) ? defaultValue[index] : defaultValue : v;
  5798. }
  5799. return value;
  5800. }
  5801. function isType(value, type) {
  5802. var str = {}.toString.call(value);
  5803. return str.indexOf("[object") === 0 && str.indexOf(type + "]") > -1;
  5804. }
  5805. function invokeWithArgsOrReturn(value, args) {
  5806. return typeof value === "function" ? value.apply(void 0, args) : value;
  5807. }
  5808. function debounce(fn5, ms) {
  5809. if (ms === 0) {
  5810. return fn5;
  5811. }
  5812. var timeout;
  5813. return function(arg) {
  5814. clearTimeout(timeout);
  5815. timeout = setTimeout(function() {
  5816. fn5(arg);
  5817. }, ms);
  5818. };
  5819. }
  5820. function splitBySpaces(value) {
  5821. return value.split(/\s+/).filter(Boolean);
  5822. }
  5823. function normalizeToArray(value) {
  5824. return [].concat(value);
  5825. }
  5826. function pushIfUnique(arr, value) {
  5827. if (arr.indexOf(value) === -1) {
  5828. arr.push(value);
  5829. }
  5830. }
  5831. function unique(arr) {
  5832. return arr.filter(function(item, index) {
  5833. return arr.indexOf(item) === index;
  5834. });
  5835. }
  5836. function getBasePlacement(placement) {
  5837. return placement.split("-")[0];
  5838. }
  5839. function arrayFrom(value) {
  5840. return [].slice.call(value);
  5841. }
  5842. function removeUndefinedProps(obj) {
  5843. return Object.keys(obj).reduce(function(acc, key) {
  5844. if (obj[key] !== void 0) {
  5845. acc[key] = obj[key];
  5846. }
  5847. return acc;
  5848. }, {});
  5849. }
  5850. function div() {
  5851. return document.createElement("div");
  5852. }
  5853. function isElement(value) {
  5854. return ["Element", "Fragment"].some(function(type) {
  5855. return isType(value, type);
  5856. });
  5857. }
  5858. function isNodeList(value) {
  5859. return isType(value, "NodeList");
  5860. }
  5861. function isMouseEvent(value) {
  5862. return isType(value, "MouseEvent");
  5863. }
  5864. function isReferenceElement(value) {
  5865. return !!(value && value._tippy && value._tippy.reference === value);
  5866. }
  5867. function getArrayOfElements(value) {
  5868. if (isElement(value)) {
  5869. return [value];
  5870. }
  5871. if (isNodeList(value)) {
  5872. return arrayFrom(value);
  5873. }
  5874. if (Array.isArray(value)) {
  5875. return value;
  5876. }
  5877. return arrayFrom(document.querySelectorAll(value));
  5878. }
  5879. function setTransitionDuration(els, value) {
  5880. els.forEach(function(el) {
  5881. if (el) {
  5882. el.style.transitionDuration = value + "ms";
  5883. }
  5884. });
  5885. }
  5886. function setVisibilityState(els, state) {
  5887. els.forEach(function(el) {
  5888. if (el) {
  5889. el.setAttribute("data-state", state);
  5890. }
  5891. });
  5892. }
  5893. function getOwnerDocument(elementOrElements) {
  5894. var _element$ownerDocumen;
  5895. var _normalizeToArray = normalizeToArray(elementOrElements), element = _normalizeToArray[0];
  5896. return element != null && (_element$ownerDocumen = element.ownerDocument) != null && _element$ownerDocumen.body ? element.ownerDocument : document;
  5897. }
  5898. function isCursorOutsideInteractiveBorder(popperTreeData, event) {
  5899. var clientX = event.clientX, clientY = event.clientY;
  5900. return popperTreeData.every(function(_ref) {
  5901. var popperRect = _ref.popperRect, popperState = _ref.popperState, props = _ref.props;
  5902. var interactiveBorder = props.interactiveBorder;
  5903. var basePlacement = getBasePlacement(popperState.placement);
  5904. var offsetData = popperState.modifiersData.offset;
  5905. if (!offsetData) {
  5906. return true;
  5907. }
  5908. var topDistance = basePlacement === "bottom" ? offsetData.top.y : 0;
  5909. var bottomDistance = basePlacement === "top" ? offsetData.bottom.y : 0;
  5910. var leftDistance = basePlacement === "right" ? offsetData.left.x : 0;
  5911. var rightDistance = basePlacement === "left" ? offsetData.right.x : 0;
  5912. var exceedsTop = popperRect.top - clientY + topDistance > interactiveBorder;
  5913. var exceedsBottom = clientY - popperRect.bottom - bottomDistance > interactiveBorder;
  5914. var exceedsLeft = popperRect.left - clientX + leftDistance > interactiveBorder;
  5915. var exceedsRight = clientX - popperRect.right - rightDistance > interactiveBorder;
  5916. return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight;
  5917. });
  5918. }
  5919. function updateTransitionEndListener(box, action, listener) {
  5920. var method = action + "EventListener";
  5921. ["transitionend", "webkitTransitionEnd"].forEach(function(event) {
  5922. box[method](event, listener);
  5923. });
  5924. }
  5925. function actualContains(parent, child) {
  5926. var target = child;
  5927. while (target) {
  5928. var _target$getRootNode;
  5929. if (parent.contains(target)) {
  5930. return true;
  5931. }
  5932. target = target.getRootNode == null ? void 0 : (_target$getRootNode = target.getRootNode()) == null ? void 0 : _target$getRootNode.host;
  5933. }
  5934. return false;
  5935. }
  5936. var currentInput = {
  5937. isTouch: false
  5938. };
  5939. var lastMouseMoveTime = 0;
  5940. function onDocumentTouchStart() {
  5941. if (currentInput.isTouch) {
  5942. return;
  5943. }
  5944. currentInput.isTouch = true;
  5945. if (window.performance) {
  5946. document.addEventListener("mousemove", onDocumentMouseMove);
  5947. }
  5948. }
  5949. function onDocumentMouseMove() {
  5950. var now = performance.now();
  5951. if (now - lastMouseMoveTime < 20) {
  5952. currentInput.isTouch = false;
  5953. document.removeEventListener("mousemove", onDocumentMouseMove);
  5954. }
  5955. lastMouseMoveTime = now;
  5956. }
  5957. function onWindowBlur() {
  5958. var activeElement = document.activeElement;
  5959. if (isReferenceElement(activeElement)) {
  5960. var instance = activeElement._tippy;
  5961. if (activeElement.blur && !instance.state.isVisible) {
  5962. activeElement.blur();
  5963. }
  5964. }
  5965. }
  5966. function bindGlobalEventListeners() {
  5967. document.addEventListener("touchstart", onDocumentTouchStart, TOUCH_OPTIONS);
  5968. window.addEventListener("blur", onWindowBlur);
  5969. }
  5970. var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
  5971. var isIE11 = isBrowser ? (
  5972. // @ts-ignore
  5973. !!window.msCrypto
  5974. ) : false;
  5975. var pluginProps = {
  5976. animateFill: false,
  5977. followCursor: false,
  5978. inlinePositioning: false,
  5979. sticky: false
  5980. };
  5981. var renderProps = {
  5982. allowHTML: false,
  5983. animation: "fade",
  5984. arrow: true,
  5985. content: "",
  5986. inertia: false,
  5987. maxWidth: 350,
  5988. role: "tooltip",
  5989. theme: "",
  5990. zIndex: 9999
  5991. };
  5992. var defaultProps = Object.assign({
  5993. appendTo: TIPPY_DEFAULT_APPEND_TO,
  5994. aria: {
  5995. content: "auto",
  5996. expanded: "auto"
  5997. },
  5998. delay: 0,
  5999. duration: [300, 250],
  6000. getReferenceClientRect: null,
  6001. hideOnClick: true,
  6002. ignoreAttributes: false,
  6003. interactive: false,
  6004. interactiveBorder: 2,
  6005. interactiveDebounce: 0,
  6006. moveTransition: "",
  6007. offset: [0, 10],
  6008. onAfterUpdate: function onAfterUpdate() {
  6009. },
  6010. onBeforeUpdate: function onBeforeUpdate() {
  6011. },
  6012. onCreate: function onCreate() {
  6013. },
  6014. onDestroy: function onDestroy() {
  6015. },
  6016. onHidden: function onHidden() {
  6017. },
  6018. onHide: function onHide() {
  6019. },
  6020. onMount: function onMount() {
  6021. },
  6022. onShow: function onShow() {
  6023. },
  6024. onShown: function onShown() {
  6025. },
  6026. onTrigger: function onTrigger() {
  6027. },
  6028. onUntrigger: function onUntrigger() {
  6029. },
  6030. onClickOutside: function onClickOutside() {
  6031. },
  6032. placement: "top",
  6033. plugins: [],
  6034. popperOptions: {},
  6035. render: null,
  6036. showOnCreate: false,
  6037. touch: true,
  6038. trigger: "mouseenter focus",
  6039. triggerTarget: null
  6040. }, pluginProps, renderProps);
  6041. var defaultKeys = Object.keys(defaultProps);
  6042. var setDefaultProps = function setDefaultProps2(partialProps) {
  6043. var keys = Object.keys(partialProps);
  6044. keys.forEach(function(key) {
  6045. defaultProps[key] = partialProps[key];
  6046. });
  6047. };
  6048. function getExtendedPassedProps(passedProps) {
  6049. var plugins = passedProps.plugins || [];
  6050. var pluginProps2 = plugins.reduce(function(acc, plugin) {
  6051. var name = plugin.name, defaultValue = plugin.defaultValue;
  6052. if (name) {
  6053. var _name;
  6054. acc[name] = passedProps[name] !== void 0 ? passedProps[name] : (_name = defaultProps[name]) != null ? _name : defaultValue;
  6055. }
  6056. return acc;
  6057. }, {});
  6058. return Object.assign({}, passedProps, pluginProps2);
  6059. }
  6060. function getDataAttributeProps(reference2, plugins) {
  6061. var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
  6062. plugins
  6063. }))) : defaultKeys;
  6064. var props = propKeys.reduce(function(acc, key) {
  6065. var valueAsString = (reference2.getAttribute("data-tippy-" + key) || "").trim();
  6066. if (!valueAsString) {
  6067. return acc;
  6068. }
  6069. if (key === "content") {
  6070. acc[key] = valueAsString;
  6071. } else {
  6072. try {
  6073. acc[key] = JSON.parse(valueAsString);
  6074. } catch (e) {
  6075. acc[key] = valueAsString;
  6076. }
  6077. }
  6078. return acc;
  6079. }, {});
  6080. return props;
  6081. }
  6082. function evaluateProps(reference2, props) {
  6083. var out = Object.assign({}, props, {
  6084. content: invokeWithArgsOrReturn(props.content, [reference2])
  6085. }, props.ignoreAttributes ? {} : getDataAttributeProps(reference2, props.plugins));
  6086. out.aria = Object.assign({}, defaultProps.aria, out.aria);
  6087. out.aria = {
  6088. expanded: out.aria.expanded === "auto" ? props.interactive : out.aria.expanded,
  6089. content: out.aria.content === "auto" ? props.interactive ? null : "describedby" : out.aria.content
  6090. };
  6091. return out;
  6092. }
  6093. var innerHTML = function innerHTML2() {
  6094. return "innerHTML";
  6095. };
  6096. function dangerouslySetInnerHTML(element, html) {
  6097. element[innerHTML()] = html;
  6098. }
  6099. function createArrowElement(value) {
  6100. var arrow2 = div();
  6101. if (value === true) {
  6102. arrow2.className = ARROW_CLASS;
  6103. } else {
  6104. arrow2.className = SVG_ARROW_CLASS;
  6105. if (isElement(value)) {
  6106. arrow2.appendChild(value);
  6107. } else {
  6108. dangerouslySetInnerHTML(arrow2, value);
  6109. }
  6110. }
  6111. return arrow2;
  6112. }
  6113. function setContent(content, props) {
  6114. if (isElement(props.content)) {
  6115. dangerouslySetInnerHTML(content, "");
  6116. content.appendChild(props.content);
  6117. } else if (typeof props.content !== "function") {
  6118. if (props.allowHTML) {
  6119. dangerouslySetInnerHTML(content, props.content);
  6120. } else {
  6121. content.textContent = props.content;
  6122. }
  6123. }
  6124. }
  6125. function getChildren(popper2) {
  6126. var box = popper2.firstElementChild;
  6127. var boxChildren = arrayFrom(box.children);
  6128. return {
  6129. box,
  6130. content: boxChildren.find(function(node) {
  6131. return node.classList.contains(CONTENT_CLASS);
  6132. }),
  6133. arrow: boxChildren.find(function(node) {
  6134. return node.classList.contains(ARROW_CLASS) || node.classList.contains(SVG_ARROW_CLASS);
  6135. }),
  6136. backdrop: boxChildren.find(function(node) {
  6137. return node.classList.contains(BACKDROP_CLASS);
  6138. })
  6139. };
  6140. }
  6141. function render(instance) {
  6142. var popper2 = div();
  6143. var box = div();
  6144. box.className = BOX_CLASS;
  6145. box.setAttribute("data-state", "hidden");
  6146. box.setAttribute("tabindex", "-1");
  6147. var content = div();
  6148. content.className = CONTENT_CLASS;
  6149. content.setAttribute("data-state", "hidden");
  6150. setContent(content, instance.props);
  6151. popper2.appendChild(box);
  6152. box.appendChild(content);
  6153. onUpdate(instance.props, instance.props);
  6154. function onUpdate(prevProps, nextProps) {
  6155. var _getChildren = getChildren(popper2), box2 = _getChildren.box, content2 = _getChildren.content, arrow2 = _getChildren.arrow;
  6156. if (nextProps.theme) {
  6157. box2.setAttribute("data-theme", nextProps.theme);
  6158. } else {
  6159. box2.removeAttribute("data-theme");
  6160. }
  6161. if (typeof nextProps.animation === "string") {
  6162. box2.setAttribute("data-animation", nextProps.animation);
  6163. } else {
  6164. box2.removeAttribute("data-animation");
  6165. }
  6166. if (nextProps.inertia) {
  6167. box2.setAttribute("data-inertia", "");
  6168. } else {
  6169. box2.removeAttribute("data-inertia");
  6170. }
  6171. box2.style.maxWidth = typeof nextProps.maxWidth === "number" ? nextProps.maxWidth + "px" : nextProps.maxWidth;
  6172. if (nextProps.role) {
  6173. box2.setAttribute("role", nextProps.role);
  6174. } else {
  6175. box2.removeAttribute("role");
  6176. }
  6177. if (prevProps.content !== nextProps.content || prevProps.allowHTML !== nextProps.allowHTML) {
  6178. setContent(content2, instance.props);
  6179. }
  6180. if (nextProps.arrow) {
  6181. if (!arrow2) {
  6182. box2.appendChild(createArrowElement(nextProps.arrow));
  6183. } else if (prevProps.arrow !== nextProps.arrow) {
  6184. box2.removeChild(arrow2);
  6185. box2.appendChild(createArrowElement(nextProps.arrow));
  6186. }
  6187. } else if (arrow2) {
  6188. box2.removeChild(arrow2);
  6189. }
  6190. }
  6191. return {
  6192. popper: popper2,
  6193. onUpdate
  6194. };
  6195. }
  6196. render.$$tippy = true;
  6197. var idCounter = 1;
  6198. var mouseMoveListeners = [];
  6199. var mountedInstances = [];
  6200. function createTippy(reference2, passedProps) {
  6201. var props = evaluateProps(reference2, Object.assign({}, defaultProps, getExtendedPassedProps(removeUndefinedProps(passedProps))));
  6202. var showTimeout;
  6203. var hideTimeout;
  6204. var scheduleHideAnimationFrame;
  6205. var isVisibleFromClick = false;
  6206. var didHideDueToDocumentMouseDown = false;
  6207. var didTouchMove = false;
  6208. var ignoreOnFirstUpdate = false;
  6209. var lastTriggerEvent;
  6210. var currentTransitionEndListener;
  6211. var onFirstUpdate;
  6212. var listeners = [];
  6213. var debouncedOnMouseMove = debounce(onMouseMove, props.interactiveDebounce);
  6214. var currentTarget;
  6215. var id = idCounter++;
  6216. var popperInstance = null;
  6217. var plugins = unique(props.plugins);
  6218. var state = {
  6219. // Is the instance currently enabled?
  6220. isEnabled: true,
  6221. // Is the tippy currently showing and not transitioning out?
  6222. isVisible: false,
  6223. // Has the instance been destroyed?
  6224. isDestroyed: false,
  6225. // Is the tippy currently mounted to the DOM?
  6226. isMounted: false,
  6227. // Has the tippy finished transitioning in?
  6228. isShown: false
  6229. };
  6230. var instance = {
  6231. // properties
  6232. id,
  6233. reference: reference2,
  6234. popper: div(),
  6235. popperInstance,
  6236. props,
  6237. state,
  6238. plugins,
  6239. // methods
  6240. clearDelayTimeouts,
  6241. setProps,
  6242. setContent: setContent2,
  6243. show,
  6244. hide: hide2,
  6245. hideWithInteractivity,
  6246. enable,
  6247. disable,
  6248. unmount,
  6249. destroy
  6250. };
  6251. if (!props.render) {
  6252. return instance;
  6253. }
  6254. var _props$render = props.render(instance), popper2 = _props$render.popper, onUpdate = _props$render.onUpdate;
  6255. popper2.setAttribute("data-tippy-root", "");
  6256. popper2.id = "tippy-" + instance.id;
  6257. instance.popper = popper2;
  6258. reference2._tippy = instance;
  6259. popper2._tippy = instance;
  6260. var pluginsHooks = plugins.map(function(plugin) {
  6261. return plugin.fn(instance);
  6262. });
  6263. var hasAriaExpanded = reference2.hasAttribute("aria-expanded");
  6264. addListeners();
  6265. handleAriaExpandedAttribute();
  6266. handleStyles();
  6267. invokeHook("onCreate", [instance]);
  6268. if (props.showOnCreate) {
  6269. scheduleShow();
  6270. }
  6271. popper2.addEventListener("mouseenter", function() {
  6272. if (instance.props.interactive && instance.state.isVisible) {
  6273. instance.clearDelayTimeouts();
  6274. }
  6275. });
  6276. popper2.addEventListener("mouseleave", function() {
  6277. if (instance.props.interactive && instance.props.trigger.indexOf("mouseenter") >= 0) {
  6278. getDocument().addEventListener("mousemove", debouncedOnMouseMove);
  6279. }
  6280. });
  6281. return instance;
  6282. function getNormalizedTouchSettings() {
  6283. var touch = instance.props.touch;
  6284. return Array.isArray(touch) ? touch : [touch, 0];
  6285. }
  6286. function getIsCustomTouchBehavior() {
  6287. return getNormalizedTouchSettings()[0] === "hold";
  6288. }
  6289. function getIsDefaultRenderFn() {
  6290. var _instance$props$rende;
  6291. return !!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy);
  6292. }
  6293. function getCurrentTarget() {
  6294. return currentTarget || reference2;
  6295. }
  6296. function getDocument() {
  6297. var parent = getCurrentTarget().parentNode;
  6298. return parent ? getOwnerDocument(parent) : document;
  6299. }
  6300. function getDefaultTemplateChildren() {
  6301. return getChildren(popper2);
  6302. }
  6303. function getDelay(isShow) {
  6304. if (instance.state.isMounted && !instance.state.isVisible || currentInput.isTouch || lastTriggerEvent && lastTriggerEvent.type === "focus") {
  6305. return 0;
  6306. }
  6307. return getValueAtIndexOrReturn(instance.props.delay, isShow ? 0 : 1, defaultProps.delay);
  6308. }
  6309. function handleStyles(fromHide) {
  6310. if (fromHide === void 0) {
  6311. fromHide = false;
  6312. }
  6313. popper2.style.pointerEvents = instance.props.interactive && !fromHide ? "" : "none";
  6314. popper2.style.zIndex = "" + instance.props.zIndex;
  6315. }
  6316. function invokeHook(hook, args, shouldInvokePropsHook) {
  6317. if (shouldInvokePropsHook === void 0) {
  6318. shouldInvokePropsHook = true;
  6319. }
  6320. pluginsHooks.forEach(function(pluginHooks) {
  6321. if (pluginHooks[hook]) {
  6322. pluginHooks[hook].apply(pluginHooks, args);
  6323. }
  6324. });
  6325. if (shouldInvokePropsHook) {
  6326. var _instance$props;
  6327. (_instance$props = instance.props)[hook].apply(_instance$props, args);
  6328. }
  6329. }
  6330. function handleAriaContentAttribute() {
  6331. var aria = instance.props.aria;
  6332. if (!aria.content) {
  6333. return;
  6334. }
  6335. var attr = "aria-" + aria.content;
  6336. var id2 = popper2.id;
  6337. var nodes = normalizeToArray(instance.props.triggerTarget || reference2);
  6338. nodes.forEach(function(node) {
  6339. var currentValue = node.getAttribute(attr);
  6340. if (instance.state.isVisible) {
  6341. node.setAttribute(attr, currentValue ? currentValue + " " + id2 : id2);
  6342. } else {
  6343. var nextValue = currentValue && currentValue.replace(id2, "").trim();
  6344. if (nextValue) {
  6345. node.setAttribute(attr, nextValue);
  6346. } else {
  6347. node.removeAttribute(attr);
  6348. }
  6349. }
  6350. });
  6351. }
  6352. function handleAriaExpandedAttribute() {
  6353. if (hasAriaExpanded || !instance.props.aria.expanded) {
  6354. return;
  6355. }
  6356. var nodes = normalizeToArray(instance.props.triggerTarget || reference2);
  6357. nodes.forEach(function(node) {
  6358. if (instance.props.interactive) {
  6359. node.setAttribute("aria-expanded", instance.state.isVisible && node === getCurrentTarget() ? "true" : "false");
  6360. } else {
  6361. node.removeAttribute("aria-expanded");
  6362. }
  6363. });
  6364. }
  6365. function cleanupInteractiveMouseListeners() {
  6366. getDocument().removeEventListener("mousemove", debouncedOnMouseMove);
  6367. mouseMoveListeners = mouseMoveListeners.filter(function(listener) {
  6368. return listener !== debouncedOnMouseMove;
  6369. });
  6370. }
  6371. function onDocumentPress(event) {
  6372. if (currentInput.isTouch) {
  6373. if (didTouchMove || event.type === "mousedown") {
  6374. return;
  6375. }
  6376. }
  6377. var actualTarget = event.composedPath && event.composedPath()[0] || event.target;
  6378. if (instance.props.interactive && actualContains(popper2, actualTarget)) {
  6379. return;
  6380. }
  6381. if (normalizeToArray(instance.props.triggerTarget || reference2).some(function(el) {
  6382. return actualContains(el, actualTarget);
  6383. })) {
  6384. if (currentInput.isTouch) {
  6385. return;
  6386. }
  6387. if (instance.state.isVisible && instance.props.trigger.indexOf("click") >= 0) {
  6388. return;
  6389. }
  6390. } else {
  6391. invokeHook("onClickOutside", [instance, event]);
  6392. }
  6393. if (instance.props.hideOnClick === true) {
  6394. instance.clearDelayTimeouts();
  6395. instance.hide();
  6396. didHideDueToDocumentMouseDown = true;
  6397. setTimeout(function() {
  6398. didHideDueToDocumentMouseDown = false;
  6399. });
  6400. if (!instance.state.isMounted) {
  6401. removeDocumentPress();
  6402. }
  6403. }
  6404. }
  6405. function onTouchMove() {
  6406. didTouchMove = true;
  6407. }
  6408. function onTouchStart() {
  6409. didTouchMove = false;
  6410. }
  6411. function addDocumentPress() {
  6412. var doc = getDocument();
  6413. doc.addEventListener("mousedown", onDocumentPress, true);
  6414. doc.addEventListener("touchend", onDocumentPress, TOUCH_OPTIONS);
  6415. doc.addEventListener("touchstart", onTouchStart, TOUCH_OPTIONS);
  6416. doc.addEventListener("touchmove", onTouchMove, TOUCH_OPTIONS);
  6417. }
  6418. function removeDocumentPress() {
  6419. var doc = getDocument();
  6420. doc.removeEventListener("mousedown", onDocumentPress, true);
  6421. doc.removeEventListener("touchend", onDocumentPress, TOUCH_OPTIONS);
  6422. doc.removeEventListener("touchstart", onTouchStart, TOUCH_OPTIONS);
  6423. doc.removeEventListener("touchmove", onTouchMove, TOUCH_OPTIONS);
  6424. }
  6425. function onTransitionedOut(duration, callback) {
  6426. onTransitionEnd(duration, function() {
  6427. if (!instance.state.isVisible && popper2.parentNode && popper2.parentNode.contains(popper2)) {
  6428. callback();
  6429. }
  6430. });
  6431. }
  6432. function onTransitionedIn(duration, callback) {
  6433. onTransitionEnd(duration, callback);
  6434. }
  6435. function onTransitionEnd(duration, callback) {
  6436. var box = getDefaultTemplateChildren().box;
  6437. function listener(event) {
  6438. if (event.target === box) {
  6439. updateTransitionEndListener(box, "remove", listener);
  6440. callback();
  6441. }
  6442. }
  6443. if (duration === 0) {
  6444. return callback();
  6445. }
  6446. updateTransitionEndListener(box, "remove", currentTransitionEndListener);
  6447. updateTransitionEndListener(box, "add", listener);
  6448. currentTransitionEndListener = listener;
  6449. }
  6450. function on(eventType, handler, options) {
  6451. if (options === void 0) {
  6452. options = false;
  6453. }
  6454. var nodes = normalizeToArray(instance.props.triggerTarget || reference2);
  6455. nodes.forEach(function(node) {
  6456. node.addEventListener(eventType, handler, options);
  6457. listeners.push({
  6458. node,
  6459. eventType,
  6460. handler,
  6461. options
  6462. });
  6463. });
  6464. }
  6465. function addListeners() {
  6466. if (getIsCustomTouchBehavior()) {
  6467. on("touchstart", onTrigger2, {
  6468. passive: true
  6469. });
  6470. on("touchend", onMouseLeave, {
  6471. passive: true
  6472. });
  6473. }
  6474. splitBySpaces(instance.props.trigger).forEach(function(eventType) {
  6475. if (eventType === "manual") {
  6476. return;
  6477. }
  6478. on(eventType, onTrigger2);
  6479. switch (eventType) {
  6480. case "mouseenter":
  6481. on("mouseleave", onMouseLeave);
  6482. break;
  6483. case "focus":
  6484. on(isIE11 ? "focusout" : "blur", onBlurOrFocusOut);
  6485. break;
  6486. case "focusin":
  6487. on("focusout", onBlurOrFocusOut);
  6488. break;
  6489. }
  6490. });
  6491. }
  6492. function removeListeners() {
  6493. listeners.forEach(function(_ref) {
  6494. var node = _ref.node, eventType = _ref.eventType, handler = _ref.handler, options = _ref.options;
  6495. node.removeEventListener(eventType, handler, options);
  6496. });
  6497. listeners = [];
  6498. }
  6499. function onTrigger2(event) {
  6500. var _lastTriggerEvent;
  6501. var shouldScheduleClickHide = false;
  6502. if (!instance.state.isEnabled || isEventListenerStopped(event) || didHideDueToDocumentMouseDown) {
  6503. return;
  6504. }
  6505. var wasFocused = ((_lastTriggerEvent = lastTriggerEvent) == null ? void 0 : _lastTriggerEvent.type) === "focus";
  6506. lastTriggerEvent = event;
  6507. currentTarget = event.currentTarget;
  6508. handleAriaExpandedAttribute();
  6509. if (!instance.state.isVisible && isMouseEvent(event)) {
  6510. mouseMoveListeners.forEach(function(listener) {
  6511. return listener(event);
  6512. });
  6513. }
  6514. if (event.type === "click" && (instance.props.trigger.indexOf("mouseenter") < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) {
  6515. shouldScheduleClickHide = true;
  6516. } else {
  6517. scheduleShow(event);
  6518. }
  6519. if (event.type === "click") {
  6520. isVisibleFromClick = !shouldScheduleClickHide;
  6521. }
  6522. if (shouldScheduleClickHide && !wasFocused) {
  6523. scheduleHide(event);
  6524. }
  6525. }
  6526. function onMouseMove(event) {
  6527. var target = event.target;
  6528. var isCursorOverReferenceOrPopper = getCurrentTarget().contains(target) || popper2.contains(target);
  6529. if (event.type === "mousemove" && isCursorOverReferenceOrPopper) {
  6530. return;
  6531. }
  6532. var popperTreeData = getNestedPopperTree().concat(popper2).map(function(popper22) {
  6533. var _instance$popperInsta;
  6534. var instance2 = popper22._tippy;
  6535. var state2 = (_instance$popperInsta = instance2.popperInstance) == null ? void 0 : _instance$popperInsta.state;
  6536. if (state2) {
  6537. return {
  6538. popperRect: popper22.getBoundingClientRect(),
  6539. popperState: state2,
  6540. props
  6541. };
  6542. }
  6543. return null;
  6544. }).filter(Boolean);
  6545. if (isCursorOutsideInteractiveBorder(popperTreeData, event)) {
  6546. cleanupInteractiveMouseListeners();
  6547. scheduleHide(event);
  6548. }
  6549. }
  6550. function onMouseLeave(event) {
  6551. var shouldBail = isEventListenerStopped(event) || instance.props.trigger.indexOf("click") >= 0 && isVisibleFromClick;
  6552. if (shouldBail) {
  6553. return;
  6554. }
  6555. if (instance.props.interactive) {
  6556. instance.hideWithInteractivity(event);
  6557. return;
  6558. }
  6559. scheduleHide(event);
  6560. }
  6561. function onBlurOrFocusOut(event) {
  6562. if (instance.props.trigger.indexOf("focusin") < 0 && event.target !== getCurrentTarget()) {
  6563. return;
  6564. }
  6565. if (instance.props.interactive && event.relatedTarget && popper2.contains(event.relatedTarget)) {
  6566. return;
  6567. }
  6568. scheduleHide(event);
  6569. }
  6570. function isEventListenerStopped(event) {
  6571. return currentInput.isTouch ? getIsCustomTouchBehavior() !== event.type.indexOf("touch") >= 0 : false;
  6572. }
  6573. function createPopperInstance() {
  6574. destroyPopperInstance();
  6575. var _instance$props2 = instance.props, popperOptions = _instance$props2.popperOptions, placement = _instance$props2.placement, offset2 = _instance$props2.offset, getReferenceClientRect = _instance$props2.getReferenceClientRect, moveTransition = _instance$props2.moveTransition;
  6576. var arrow2 = getIsDefaultRenderFn() ? getChildren(popper2).arrow : null;
  6577. var computedReference = getReferenceClientRect ? {
  6578. getBoundingClientRect: getReferenceClientRect,
  6579. contextElement: getReferenceClientRect.contextElement || getCurrentTarget()
  6580. } : reference2;
  6581. var tippyModifier = {
  6582. name: "$$tippy",
  6583. enabled: true,
  6584. phase: "beforeWrite",
  6585. requires: ["computeStyles"],
  6586. fn: function fn5(_ref2) {
  6587. var state2 = _ref2.state;
  6588. if (getIsDefaultRenderFn()) {
  6589. var _getDefaultTemplateCh = getDefaultTemplateChildren(), box = _getDefaultTemplateCh.box;
  6590. ["placement", "reference-hidden", "escaped"].forEach(function(attr) {
  6591. if (attr === "placement") {
  6592. box.setAttribute("data-placement", state2.placement);
  6593. } else {
  6594. if (state2.attributes.popper["data-popper-" + attr]) {
  6595. box.setAttribute("data-" + attr, "");
  6596. } else {
  6597. box.removeAttribute("data-" + attr);
  6598. }
  6599. }
  6600. });
  6601. state2.attributes.popper = {};
  6602. }
  6603. }
  6604. };
  6605. var modifiers = [{
  6606. name: "offset",
  6607. options: {
  6608. offset: offset2
  6609. }
  6610. }, {
  6611. name: "preventOverflow",
  6612. options: {
  6613. padding: {
  6614. top: 2,
  6615. bottom: 2,
  6616. left: 5,
  6617. right: 5
  6618. }
  6619. }
  6620. }, {
  6621. name: "flip",
  6622. options: {
  6623. padding: 5
  6624. }
  6625. }, {
  6626. name: "computeStyles",
  6627. options: {
  6628. adaptive: !moveTransition
  6629. }
  6630. }, tippyModifier];
  6631. if (getIsDefaultRenderFn() && arrow2) {
  6632. modifiers.push({
  6633. name: "arrow",
  6634. options: {
  6635. element: arrow2,
  6636. padding: 3
  6637. }
  6638. });
  6639. }
  6640. modifiers.push.apply(modifiers, (popperOptions == null ? void 0 : popperOptions.modifiers) || []);
  6641. instance.popperInstance = createPopper(computedReference, popper2, Object.assign({}, popperOptions, {
  6642. placement,
  6643. onFirstUpdate,
  6644. modifiers
  6645. }));
  6646. }
  6647. function destroyPopperInstance() {
  6648. if (instance.popperInstance) {
  6649. instance.popperInstance.destroy();
  6650. instance.popperInstance = null;
  6651. }
  6652. }
  6653. function mount() {
  6654. var appendTo = instance.props.appendTo;
  6655. var parentNode;
  6656. var node = getCurrentTarget();
  6657. if (instance.props.interactive && appendTo === TIPPY_DEFAULT_APPEND_TO || appendTo === "parent") {
  6658. parentNode = node.parentNode;
  6659. } else {
  6660. parentNode = invokeWithArgsOrReturn(appendTo, [node]);
  6661. }
  6662. if (!parentNode.contains(popper2)) {
  6663. parentNode.appendChild(popper2);
  6664. }
  6665. instance.state.isMounted = true;
  6666. createPopperInstance();
  6667. }
  6668. function getNestedPopperTree() {
  6669. return arrayFrom(popper2.querySelectorAll("[data-tippy-root]"));
  6670. }
  6671. function scheduleShow(event) {
  6672. instance.clearDelayTimeouts();
  6673. if (event) {
  6674. invokeHook("onTrigger", [instance, event]);
  6675. }
  6676. addDocumentPress();
  6677. var delay = getDelay(true);
  6678. var _getNormalizedTouchSe = getNormalizedTouchSettings(), touchValue = _getNormalizedTouchSe[0], touchDelay = _getNormalizedTouchSe[1];
  6679. if (currentInput.isTouch && touchValue === "hold" && touchDelay) {
  6680. delay = touchDelay;
  6681. }
  6682. if (delay) {
  6683. showTimeout = setTimeout(function() {
  6684. instance.show();
  6685. }, delay);
  6686. } else {
  6687. instance.show();
  6688. }
  6689. }
  6690. function scheduleHide(event) {
  6691. instance.clearDelayTimeouts();
  6692. invokeHook("onUntrigger", [instance, event]);
  6693. if (!instance.state.isVisible) {
  6694. removeDocumentPress();
  6695. return;
  6696. }
  6697. if (instance.props.trigger.indexOf("mouseenter") >= 0 && instance.props.trigger.indexOf("click") >= 0 && ["mouseleave", "mousemove"].indexOf(event.type) >= 0 && isVisibleFromClick) {
  6698. return;
  6699. }
  6700. var delay = getDelay(false);
  6701. if (delay) {
  6702. hideTimeout = setTimeout(function() {
  6703. if (instance.state.isVisible) {
  6704. instance.hide();
  6705. }
  6706. }, delay);
  6707. } else {
  6708. scheduleHideAnimationFrame = requestAnimationFrame(function() {
  6709. instance.hide();
  6710. });
  6711. }
  6712. }
  6713. function enable() {
  6714. instance.state.isEnabled = true;
  6715. }
  6716. function disable() {
  6717. instance.hide();
  6718. instance.state.isEnabled = false;
  6719. }
  6720. function clearDelayTimeouts() {
  6721. clearTimeout(showTimeout);
  6722. clearTimeout(hideTimeout);
  6723. cancelAnimationFrame(scheduleHideAnimationFrame);
  6724. }
  6725. function setProps(partialProps) {
  6726. if (instance.state.isDestroyed) {
  6727. return;
  6728. }
  6729. invokeHook("onBeforeUpdate", [instance, partialProps]);
  6730. removeListeners();
  6731. var prevProps = instance.props;
  6732. var nextProps = evaluateProps(reference2, Object.assign({}, prevProps, removeUndefinedProps(partialProps), {
  6733. ignoreAttributes: true
  6734. }));
  6735. instance.props = nextProps;
  6736. addListeners();
  6737. if (prevProps.interactiveDebounce !== nextProps.interactiveDebounce) {
  6738. cleanupInteractiveMouseListeners();
  6739. debouncedOnMouseMove = debounce(onMouseMove, nextProps.interactiveDebounce);
  6740. }
  6741. if (prevProps.triggerTarget && !nextProps.triggerTarget) {
  6742. normalizeToArray(prevProps.triggerTarget).forEach(function(node) {
  6743. node.removeAttribute("aria-expanded");
  6744. });
  6745. } else if (nextProps.triggerTarget) {
  6746. reference2.removeAttribute("aria-expanded");
  6747. }
  6748. handleAriaExpandedAttribute();
  6749. handleStyles();
  6750. if (onUpdate) {
  6751. onUpdate(prevProps, nextProps);
  6752. }
  6753. if (instance.popperInstance) {
  6754. createPopperInstance();
  6755. getNestedPopperTree().forEach(function(nestedPopper) {
  6756. requestAnimationFrame(nestedPopper._tippy.popperInstance.forceUpdate);
  6757. });
  6758. }
  6759. invokeHook("onAfterUpdate", [instance, partialProps]);
  6760. }
  6761. function setContent2(content) {
  6762. instance.setProps({
  6763. content
  6764. });
  6765. }
  6766. function show() {
  6767. var isAlreadyVisible = instance.state.isVisible;
  6768. var isDestroyed = instance.state.isDestroyed;
  6769. var isDisabled = !instance.state.isEnabled;
  6770. var isTouchAndTouchDisabled = currentInput.isTouch && !instance.props.touch;
  6771. var duration = getValueAtIndexOrReturn(instance.props.duration, 0, defaultProps.duration);
  6772. if (isAlreadyVisible || isDestroyed || isDisabled || isTouchAndTouchDisabled) {
  6773. return;
  6774. }
  6775. if (getCurrentTarget().hasAttribute("disabled")) {
  6776. return;
  6777. }
  6778. invokeHook("onShow", [instance], false);
  6779. if (instance.props.onShow(instance) === false) {
  6780. return;
  6781. }
  6782. instance.state.isVisible = true;
  6783. if (getIsDefaultRenderFn()) {
  6784. popper2.style.visibility = "visible";
  6785. }
  6786. handleStyles();
  6787. addDocumentPress();
  6788. if (!instance.state.isMounted) {
  6789. popper2.style.transition = "none";
  6790. }
  6791. if (getIsDefaultRenderFn()) {
  6792. var _getDefaultTemplateCh2 = getDefaultTemplateChildren(), box = _getDefaultTemplateCh2.box, content = _getDefaultTemplateCh2.content;
  6793. setTransitionDuration([box, content], 0);
  6794. }
  6795. onFirstUpdate = function onFirstUpdate2() {
  6796. var _instance$popperInsta2;
  6797. if (!instance.state.isVisible || ignoreOnFirstUpdate) {
  6798. return;
  6799. }
  6800. ignoreOnFirstUpdate = true;
  6801. void popper2.offsetHeight;
  6802. popper2.style.transition = instance.props.moveTransition;
  6803. if (getIsDefaultRenderFn() && instance.props.animation) {
  6804. var _getDefaultTemplateCh3 = getDefaultTemplateChildren(), _box = _getDefaultTemplateCh3.box, _content = _getDefaultTemplateCh3.content;
  6805. setTransitionDuration([_box, _content], duration);
  6806. setVisibilityState([_box, _content], "visible");
  6807. }
  6808. handleAriaContentAttribute();
  6809. handleAriaExpandedAttribute();
  6810. pushIfUnique(mountedInstances, instance);
  6811. (_instance$popperInsta2 = instance.popperInstance) == null ? void 0 : _instance$popperInsta2.forceUpdate();
  6812. invokeHook("onMount", [instance]);
  6813. if (instance.props.animation && getIsDefaultRenderFn()) {
  6814. onTransitionedIn(duration, function() {
  6815. instance.state.isShown = true;
  6816. invokeHook("onShown", [instance]);
  6817. });
  6818. }
  6819. };
  6820. mount();
  6821. }
  6822. function hide2() {
  6823. var isAlreadyHidden = !instance.state.isVisible;
  6824. var isDestroyed = instance.state.isDestroyed;
  6825. var isDisabled = !instance.state.isEnabled;
  6826. var duration = getValueAtIndexOrReturn(instance.props.duration, 1, defaultProps.duration);
  6827. if (isAlreadyHidden || isDestroyed || isDisabled) {
  6828. return;
  6829. }
  6830. invokeHook("onHide", [instance], false);
  6831. if (instance.props.onHide(instance) === false) {
  6832. return;
  6833. }
  6834. instance.state.isVisible = false;
  6835. instance.state.isShown = false;
  6836. ignoreOnFirstUpdate = false;
  6837. isVisibleFromClick = false;
  6838. if (getIsDefaultRenderFn()) {
  6839. popper2.style.visibility = "hidden";
  6840. }
  6841. cleanupInteractiveMouseListeners();
  6842. removeDocumentPress();
  6843. handleStyles(true);
  6844. if (getIsDefaultRenderFn()) {
  6845. var _getDefaultTemplateCh4 = getDefaultTemplateChildren(), box = _getDefaultTemplateCh4.box, content = _getDefaultTemplateCh4.content;
  6846. if (instance.props.animation) {
  6847. setTransitionDuration([box, content], duration);
  6848. setVisibilityState([box, content], "hidden");
  6849. }
  6850. }
  6851. handleAriaContentAttribute();
  6852. handleAriaExpandedAttribute();
  6853. if (instance.props.animation) {
  6854. if (getIsDefaultRenderFn()) {
  6855. onTransitionedOut(duration, instance.unmount);
  6856. }
  6857. } else {
  6858. instance.unmount();
  6859. }
  6860. }
  6861. function hideWithInteractivity(event) {
  6862. getDocument().addEventListener("mousemove", debouncedOnMouseMove);
  6863. pushIfUnique(mouseMoveListeners, debouncedOnMouseMove);
  6864. debouncedOnMouseMove(event);
  6865. }
  6866. function unmount() {
  6867. if (instance.state.isVisible) {
  6868. instance.hide();
  6869. }
  6870. if (!instance.state.isMounted) {
  6871. return;
  6872. }
  6873. destroyPopperInstance();
  6874. getNestedPopperTree().forEach(function(nestedPopper) {
  6875. nestedPopper._tippy.unmount();
  6876. });
  6877. if (popper2.parentNode) {
  6878. popper2.parentNode.removeChild(popper2);
  6879. }
  6880. mountedInstances = mountedInstances.filter(function(i) {
  6881. return i !== instance;
  6882. });
  6883. instance.state.isMounted = false;
  6884. invokeHook("onHidden", [instance]);
  6885. }
  6886. function destroy() {
  6887. if (instance.state.isDestroyed) {
  6888. return;
  6889. }
  6890. instance.clearDelayTimeouts();
  6891. instance.unmount();
  6892. removeListeners();
  6893. delete reference2._tippy;
  6894. instance.state.isDestroyed = true;
  6895. invokeHook("onDestroy", [instance]);
  6896. }
  6897. }
  6898. function tippy(targets, optionalProps) {
  6899. if (optionalProps === void 0) {
  6900. optionalProps = {};
  6901. }
  6902. var plugins = defaultProps.plugins.concat(optionalProps.plugins || []);
  6903. bindGlobalEventListeners();
  6904. var passedProps = Object.assign({}, optionalProps, {
  6905. plugins
  6906. });
  6907. var elements = getArrayOfElements(targets);
  6908. var instances = elements.reduce(function(acc, reference2) {
  6909. var instance = reference2 && createTippy(reference2, passedProps);
  6910. if (instance) {
  6911. acc.push(instance);
  6912. }
  6913. return acc;
  6914. }, []);
  6915. return isElement(targets) ? instances[0] : instances;
  6916. }
  6917. tippy.defaultProps = defaultProps;
  6918. tippy.setDefaultProps = setDefaultProps;
  6919. tippy.currentInput = currentInput;
  6920. Object.assign({}, applyStyles$1, {
  6921. effect: function effect2(_ref) {
  6922. var state = _ref.state;
  6923. var initialStyles = {
  6924. popper: {
  6925. position: state.options.strategy,
  6926. left: "0",
  6927. top: "0",
  6928. margin: "0"
  6929. },
  6930. arrow: {
  6931. position: "absolute"
  6932. },
  6933. reference: {}
  6934. };
  6935. Object.assign(state.elements.popper.style, initialStyles.popper);
  6936. state.styles = initialStyles;
  6937. if (state.elements.arrow) {
  6938. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  6939. }
  6940. }
  6941. });
  6942. tippy.setDefaultProps({
  6943. render
  6944. });
  6945.  
  6946. })
  6947. };
  6948. }));
  6949.  
  6950. System.register("./index-CZOUlSU2-CskZy1NC.js", [], (function (exports, module) {
  6951. 'use strict';
  6952. return {
  6953. execute: (function () {
  6954.  
  6955. const scroll = document.createElement("div");
  6956. scroll.setAttribute("class", "scroll-top");
  6957. document.body.appendChild(scroll);
  6958. const style = scroll.style;
  6959. const $container = document.querySelector(".container");
  6960. $container.addEventListener("scroll", function() {
  6961. this.scrollTop > 500 ? style.display = "block" : style.display = "none";
  6962. });
  6963. scroll.addEventListener("click", function() {
  6964. $container.scrollTop = 0;
  6965. });
  6966.  
  6967. })
  6968. };
  6969. }));
  6970.  
  6971. System.import("./__entry.js", "./");