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.6
  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:hover{background-color:transparent}.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:14px;background-repeat:no-repeat;background-position:7px center;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAipJREFUWEftljuIE1EUhv8zpJB0FqugItiIdmKnnQ+wjPhq3EILRYt1JTDnDvhgUJG55zY+ELO7hRZupYWCCIK6nXYiNoqlrIUKaxes5siFBGKYSSbJTnaLTDMwl/Ofj8Pc/z+ENX5ojftjfQFYay8AuEFEU2VMRlV/A7hujGm09f+bgIj8APCtjOYdmjuZeWsewCMAZwBcYub7qwkiIjMA7gF4zMxnMwHiOK5Wq9UXAA6r6kljzLPVgLDWniCipwDeNJvNWhzHzUwA/zFJku1BEHiIPUS0PwzDD6NAOOf2qep7AJ/SNK1FUfS9Uy/zFojIXgAeYhsRbQ7D8NcwEM65Tar6E8AygBozf+zWyb2GSZIcCYLgORH9DcNw45AAf1R1Q5qmR6Moep2l0dMHrLWniegJgK/MvHsQCBH5AmCXqk4bYxbzavsakYjMArgD4B0zHyoCISJvARwEcJmZ7/aq6Qvgi0XkJoCrqrpgjDnfS9BaO09E5wDcYuZr/YALAbQgHgLwTpnrER13vcHMF/s19+eFAVoQS/7NzAeyxJ1zS6qaez7wT9hdICITgMkEJhOYTMCq6jEimmXmV90+UboRtdzQ7wZ+aW1UKpUr9Xp9pQ0yFoCuXFhW1agdt2MD8BDOOb83zgPYAWAxCILbqvqg1CzIChMRmQPgI3qFiD773Z+ZTxVJwoHTME9URI4TUV1VtwCYYeaXYwUo2mzkOB6l0dA7YRlNOzX/ATTlNjBwsoHnAAAAAElFTkSuQmCC)}.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/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAANZJREFUOE+t0zFKg0EQhuEndbpgIVZ26eIJFK1SeQcPYKuWmlJIb6lHkJRpFFKnE2zTpBAknaUgA/+Q5SfBwGaaZWfne3dmdraj0job9Ae4wwAn+MUcn3jCotS0Aad4RW9LYj+4xkuel4ArPO9Y0RlmEZuAY3ygi/cGct6Clf4V+vhOwCNuG0EEXuAB941v1OzfkOAxbhIwwWVxYwoCEhZrCQzfFMMELHHUSjkhCchsMuwLh3sDVJfwXxOj/ihpaxOrnzEaUzVI2dmqUU5I1Wfa8Susw/4A1fw8ES1B6icAAAAASUVORK5CYII=)}.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-key{cursor:pointer}.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}.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-Dr2d-6z6.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-Dr2d-6z6.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. debounce: function(func, delay = 300) {
  1970. let timer;
  1971. return function() {
  1972. if (timer) {
  1973. clearTimeout(timer);
  1974. }
  1975. timer = setTimeout(() => {
  1976. func.apply(this, arguments);
  1977. }, delay);
  1978. };
  1979. }
  1980. });
  1981. const URL$1 = exports("e", {
  1982. JSON_CRACK_WIDGET: "https://jsoncrack.feny.ink/widget",
  1983. EXAMPLE_JSON: "https://fetch-api.feny.ink/example.json",
  1984. ONLINE_REQUEST: "https://fetch-api.feny.ink/httpRequest",
  1985. LAYUI_JS: "https://unpkg.com/layui@2.7.6/dist/layui.js",
  1986. LAYUI_CSS: "https://unpkg.com/layui@2.7.6/dist/css/layui.css"
  1987. });
  1988. const layout = `
  1989. <div class="json-viewer-layout">
  1990. <div class="panel">
  1991. <div class="tabs">
  1992. <div class="tabs-item btn active" id="viewFormater">JSON 格式化</div>
  1993. <div class="tabs-item btn" id="viewMind">JSON 脑图</div>
  1994. <div class="tabs-item btn" id="viewRawText">原始数据</div>
  1995. </div>
  1996. <div class="toolbar">
  1997. <div class="toolbar-item btn" id="saveJson">保存</div>
  1998. <div class="toolbar-item btn" id="copyJson">复制</div>
  1999. <div class="toolbar-item btn" id="collapseAll">全部折叠</div>
  2000. <div class="toolbar-item btn" id="expandAll">全部展开</div>
  2001. <div class="toolbar-item btn" id="jsoncrack" style="display: none;">JSON Crack</div>
  2002. <div class="toolbar-item btn" id="beautify" style="display: none;">美化输出</div>
  2003. <div class="searchbox">
  2004. <input type="text" placeholder="过滤 JSON "/>
  2005. <button class="clear" hidden></button>
  2006. </div>
  2007. </div>
  2008. <div class="rightbox">
  2009. <div class="style">
  2010. <span>风格</span>
  2011. <template data-type="style">
  2012. <ul>
  2013. <li data-type="style" data-value="default">默认</li>
  2014. <li data-type="style" data-value="table">表格</li>
  2015. </ul>
  2016. </template>
  2017. </div>
  2018. <div class="theme">
  2019. <span>主题</span>
  2020. <template data-type="theme">
  2021. <ul>
  2022. <li data-type="theme" data-value="default">默认</li>
  2023. <li data-type="theme" data-value="light">浅色</li>
  2024. <li data-type="theme" data-value="dark">暗黑</li>
  2025. <li data-type="theme" data-value="dark-plus">暗黑+</li>
  2026. </ul>
  2027. </template>
  2028. </div>
  2029. <div class="tools">
  2030. <span>工具</span>
  2031. <template data-type="tools">
  2032. <ul>
  2033. <li data-type="tools" data-value="inputJson">JSON 输入</li>
  2034. <li data-type="tools" data-value="fetchApi">HTTP 请求</li>
  2035. </ul>
  2036. </template>
  2037. </div>
  2038. </div>
  2039. </div>
  2040. <div class="container">
  2041. <div class="active" id="formatBox"></div>
  2042. <div id="mindBox"></div>
  2043. <div id="rawTextBox">
  2044. <pre></pre>
  2045. </div>
  2046. </div>
  2047. </div>`;
  2048. var _GM_addStyle = /* @__PURE__ */ (() => typeof GM_addStyle != "undefined" ? GM_addStyle : void 0)();
  2049. var _GM_getValue = exports("a", /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)());
  2050. var _GM_openInTab = /* @__PURE__ */ (() => typeof GM_openInTab != "undefined" ? GM_openInTab : void 0)();
  2051. var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
  2052. var _GM_setClipboard = exports("c", /* @__PURE__ */ (() => typeof GM_setClipboard != "undefined" ? GM_setClipboard : void 0)());
  2053. var _GM_setValue = exports("_", /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)());
  2054. var _unsafeWindow = exports("b", /* @__PURE__ */ (() => typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)());
  2055. const { EXAMPLE_JSON, LAYUI_CSS, LAYUI_JS } = URL$1;
  2056. (function() {
  2057. const openInTab = () => _GM_openInTab(EXAMPLE_JSON);
  2058. _GM_registerMenuCommand("测试JSON( Alt + j )", openInTab);
  2059. window.addEventListener("keydown", function(event) {
  2060. const { key, altKey } = event;
  2061. if (altKey && (key === "J" || key === "j")) {
  2062. openInTab();
  2063. }
  2064. });
  2065. const innerText = document.body.innerText;
  2066. const { rawText, jsonpFun } = Utils.jsonpMatch(innerText);
  2067. _unsafeWindow.RAW_TEXT = rawText;
  2068. _unsafeWindow.GLOBAL_JSONP_FUN = jsonpFun;
  2069. if (!Utils.isJSON(_unsafeWindow.RAW_TEXT)) {
  2070. __vitePreload(() => module.import('./index-mjXXc9V1-CzTRTL8e.js'), void 0 );
  2071. return;
  2072. }
  2073. document.querySelector("pre").style.display = "none";
  2074. document.querySelector("html").classList.add("monkey-jsonviewer");
  2075. window.postMessage({ addStyle: true });
  2076. const meta = document.createElement("meta");
  2077. meta.setAttribute("name", "viewport");
  2078. meta.setAttribute("content", "width=device-width, initial-scale=1.0");
  2079. document.head.appendChild(meta);
  2080. const link = document.createElement("link");
  2081. link.setAttribute("href", LAYUI_CSS);
  2082. link.setAttribute("rel", "stylesheet");
  2083. document.head.appendChild(link);
  2084. const script = document.createElement("script");
  2085. script.setAttribute("src", LAYUI_JS);
  2086. script.setAttribute("type", "text/javascript");
  2087. document.head.appendChild(script);
  2088. _GM_addStyle(`
  2089. jmnode.root::before{background-color: ${Utils.randomColor(0.5)}}
  2090. jmnode:not(.root)::before{background-color: ${Utils.randomColor(0.5)}}
  2091. `);
  2092. setTimeout(() => {
  2093. _unsafeWindow.GLOBAL_JSON = JSONbig({ useNativeBigInt: true }).parse(
  2094. _unsafeWindow.RAW_TEXT
  2095. );
  2096. document.body.insertAdjacentHTML("afterbegin", layout);
  2097. __vitePreload(() => module.import('./index-CwQ-SJst-CZMBC2H3.js'), void 0 ).then((format) => format.default.init()).then(() => __vitePreload(() => module.import('./index-B0rAase1-CncgL00v.js'), void 0 )).then(() => __vitePreload(() => module.import('./index-CZOUlSU2-CskZy1NC.js'), void 0 ));
  2098. });
  2099. })();
  2100.  
  2101. })
  2102. };
  2103. }));
  2104.  
  2105. System.register("./index-mjXXc9V1-CzTRTL8e.js", ['highlight.js', 'beautifier'], (function (exports, module) {
  2106. 'use strict';
  2107. var hljs, css_beautify, js_beautify;
  2108. return {
  2109. setters: [module => {
  2110. hljs = module.default;
  2111. }, module => {
  2112. css_beautify = module.css_beautify;
  2113. js_beautify = module.js_beautify;
  2114. }],
  2115. execute: (function () {
  2116.  
  2117. const layout = `
  2118. <div class="beautify_checkbox">
  2119. <input type="checkbox" id="beautify"/>
  2120. <label for="beautify">美化输出</label>
  2121. </div>`;
  2122. (function() {
  2123. const docType = [
  2124. "application/x-javascript",
  2125. "application/javascript",
  2126. "text/javascript",
  2127. "text/css"
  2128. ];
  2129. const contentType = document.contentType;
  2130. if (!docType.includes(contentType)) {
  2131. return;
  2132. }
  2133. const preElement = document.querySelector("pre");
  2134. if (!preElement) {
  2135. return;
  2136. }
  2137. window.postMessage({ addStyle: true });
  2138. document.querySelector("html").classList.add("monkey-js-css-beautify");
  2139. setTimeout(() => {
  2140. const rawText = preElement.innerText;
  2141. document.body.insertAdjacentHTML("afterbegin", layout);
  2142. const checkbox = document.querySelector(".beautify_checkbox input");
  2143. checkbox.addEventListener("click", function() {
  2144. if (this.checked) {
  2145. beautifyCode(contentType, preElement, rawText);
  2146. } else {
  2147. preElement.innerText = rawText;
  2148. }
  2149. });
  2150. });
  2151. })();
  2152. function beautifyCode(contentType, element, rawText) {
  2153. const language = contentType.substring(contentType.indexOf("/") + 1);
  2154. if (!["css", "javascript", "x-javascript"].includes(language)) {
  2155. return;
  2156. }
  2157. let beautifyCode2;
  2158. if ("css" === language) {
  2159. const cssBeautify = css_beautify ? css_beautify : window.css_beautify;
  2160. beautifyCode2 = cssBeautify(rawText);
  2161. beautifyCode2 = hljs.highlight(beautifyCode2, {
  2162. language
  2163. }).value;
  2164. } else {
  2165. const jsBeautify = js_beautify ? js_beautify : window.js_beautify;
  2166. beautifyCode2 = jsBeautify(rawText);
  2167. beautifyCode2 = hljs.highlight(beautifyCode2, {
  2168. language: "javascript"
  2169. }).value;
  2170. }
  2171. element.innerHTML = `<code>${beautifyCode2}</code>`;
  2172. }
  2173.  
  2174. })
  2175. };
  2176. }));
  2177.  
  2178. System.register("./index-CwQ-SJst-CZMBC2H3.js", ['jquery', './tippy.esm-Ot9MORvr-DNGa7Opj.js', './__monkey.entry-Dr2d-6z6.js'], (function (exports, module) {
  2179. 'use strict';
  2180. var $, tippy, _GM_setValue, _GM_getValue, _unsafeWindow, Utils, _GM_setClipboard;
  2181. return {
  2182. setters: [module => {
  2183. $ = module.default;
  2184. }, module => {
  2185. tippy = module.t;
  2186. }, module => {
  2187. _GM_setValue = module._;
  2188. _GM_getValue = module.a;
  2189. _unsafeWindow = module.b;
  2190. Utils = module.U;
  2191. _GM_setClipboard = module.c;
  2192. }],
  2193. execute: (function () {
  2194.  
  2195. class JsonViewer {
  2196. constructor(options) {
  2197. const defaults = {
  2198. json: null,
  2199. theme: "default",
  2200. container: null,
  2201. onExpand: null,
  2202. expander: null,
  2203. collapser: null,
  2204. onCollapse: null
  2205. };
  2206. this.options = Object.assign(defaults, options);
  2207. if (!options.container) {
  2208. throw new Error("Container: dom element is required");
  2209. }
  2210. if (!options.json) {
  2211. throw new Error("json: json is required");
  2212. }
  2213. this.render();
  2214. this.bind();
  2215. this.setTheme(this.options.theme);
  2216. }
  2217. setTheme(theme) {
  2218. const classList = document.body.classList;
  2219. classList.forEach((clas) => {
  2220. if (clas.includes("theme")) {
  2221. classList.remove(clas);
  2222. }
  2223. });
  2224. classList.add(`${theme}-theme`);
  2225. }
  2226. render() {
  2227. const { json, container } = this.options;
  2228. this.$container = container instanceof HTMLElement ? container : document.querySelector(container);
  2229. this.$box = this.createElement("div");
  2230. this.$box.setAttribute("class", `json-view-formater`);
  2231. this.createNode(this.$box, json, "Root", "Root");
  2232. this.$container.appendChild(this.$box);
  2233. }
  2234. createNode(box, json, pChain, pid) {
  2235. const type2 = this.getType(json);
  2236. switch (type2) {
  2237. case "array":
  2238. case "object":
  2239. let length = Object.keys(json).length;
  2240. if (length > 0) {
  2241. this.createObjectNode(box, type2, json, pChain, pid);
  2242. } else {
  2243. const emptyNode = this.createEmptyNode(type2);
  2244. box.appendChild(emptyNode);
  2245. }
  2246. break;
  2247. default:
  2248. const valueNode = this.creatValueNode(type2, json);
  2249. box.appendChild(valueNode);
  2250. break;
  2251. }
  2252. }
  2253. createObjectNode(box, type2, json, pChain, pid) {
  2254. const startBracket = this.createStartBracket(type2);
  2255. box.appendChild(startBracket);
  2256. if (pChain !== "Root" && this.canIterate(json)) {
  2257. const span = this.createElement("span", {
  2258. class: "json-formater-placeholder"
  2259. });
  2260. span.addEventListener("click", () => {
  2261. this.show(box);
  2262. });
  2263. box.appendChild(span);
  2264. }
  2265. let length = Object.keys(json).length;
  2266. for (var key in json) {
  2267. if (Object.prototype.hasOwnProperty.call(json, key)) {
  2268. const value = json[key];
  2269. const id = this.random();
  2270. const canComma = --length > 0;
  2271. const jsonPath = pChain + "." + key;
  2272. const node = this.createElement("div", {
  2273. "data-node-id": id,
  2274. "data-node-pid": pid,
  2275. "json-path": jsonPath,
  2276. style: `padding-left: 20px`,
  2277. "data-type": this.getType(value),
  2278. class: this.isIterate(value) ? "json-formater-opened" : null
  2279. });
  2280. this.createKeyNode(node, key, value);
  2281. this.createNode(node, value, jsonPath, id);
  2282. if (canComma) {
  2283. const comma = this.createElement("span", {
  2284. class: "json-comma"
  2285. });
  2286. comma.textContent = ",";
  2287. node.appendChild(comma);
  2288. }
  2289. box.appendChild(node);
  2290. }
  2291. }
  2292. const endBracket = this.createEndBracket(type2);
  2293. box.appendChild(endBracket);
  2294. }
  2295. createStartBracket(type2) {
  2296. const span = this.createElement("span", {
  2297. class: `json-${type2}-bracket`
  2298. });
  2299. span.textContent = type2 === "array" ? "[" : "{";
  2300. return span;
  2301. }
  2302. createEndBracket(type2) {
  2303. const span = this.createElement("span", {
  2304. class: `json-${type2}-bracket`
  2305. });
  2306. span.textContent = type2 === "array" ? "]" : "}";
  2307. return span;
  2308. }
  2309. createBracket() {
  2310. const span = this.createElement("span", {
  2311. class: `json-${type}-bracket`
  2312. });
  2313. span.textContent = type === "array" ? "[]" : "{}";
  2314. return span;
  2315. }
  2316. createKeyNode(node, key, value) {
  2317. if (this.canIterate(value)) {
  2318. const arrow = this.createElement("span", {
  2319. class: "json-formater-arrow"
  2320. });
  2321. node.appendChild(arrow);
  2322. }
  2323. if (!/^\d+$/.test(key)) {
  2324. const span = this.createElement("span", {
  2325. class: "json-key"
  2326. });
  2327. span.textContent = `"${key}"`;
  2328. node.appendChild(span);
  2329. const colon = this.createElement("span", {
  2330. class: "json-colon"
  2331. });
  2332. colon.textContent = ":";
  2333. node.appendChild(colon);
  2334. }
  2335. }
  2336. creatValueNode(type2, value) {
  2337. const node = this.createElement("span", {
  2338. class: `json-${type2}`
  2339. });
  2340. node.textContent = `${value}`;
  2341. if (type2 === "string") {
  2342. value = this.escape(value);
  2343. node.textContent = `"${value}"`;
  2344. }
  2345. if (this.isUrl(value)) {
  2346. node.textContent = "";
  2347. const a = this.createElement("a", {
  2348. target: "_blank",
  2349. href: value
  2350. });
  2351. a.textContent = `"${value}"`;
  2352. node.appendChild(a);
  2353. }
  2354. if (this.isColor(value)) {
  2355. const span = this.createElement("span", {
  2356. class: "json-color",
  2357. style: `background-color: ${value}`
  2358. });
  2359. node.prepend(span);
  2360. }
  2361. return node;
  2362. }
  2363. createEmptyNode(type2) {
  2364. const node = this.createElement("span", {
  2365. class: `json-${type2}-bracket`
  2366. });
  2367. node.textContent = type2 === "array" ? "[]" : "{}";
  2368. return node;
  2369. }
  2370. bind() {
  2371. this.addEvent(this.options.expander, `click`, () => {
  2372. this.expandAll();
  2373. });
  2374. this.addEvent(this.options.collapser, `click`, () => {
  2375. this.collapseAll();
  2376. });
  2377. const { onExpand, onCollapse } = this.options;
  2378. this.addEvent(".json-formater-arrow", "click", (e) => {
  2379. const node = e.currentTarget.parentElement;
  2380. if (this.hasClass(node, "json-formater-opened")) {
  2381. this.hide(node);
  2382. if (onCollapse) onCollapse(node, this);
  2383. } else {
  2384. this.show(node);
  2385. if (onExpand) onExpand(node, this);
  2386. }
  2387. });
  2388. }
  2389. expandAll() {
  2390. this.nodes().forEach((node) => {
  2391. this.show(node.parentElement);
  2392. });
  2393. }
  2394. collapseAll() {
  2395. this.nodes().forEach((node) => {
  2396. this.hide(node.parentElement);
  2397. });
  2398. }
  2399. show(node) {
  2400. this.removeClass(node, "json-formater-closed");
  2401. this.addClass(node, "json-formater-opened");
  2402. this.showDescs(node);
  2403. this.onShow(node);
  2404. }
  2405. onShow(node) {
  2406. const nodeId = node.dataset.nodeId;
  2407. this.findChildren(node).length;
  2408. const placeholder = node.querySelector(
  2409. `*[data-node-id*=${nodeId}] > .json-formater-placeholder`
  2410. );
  2411. if (!placeholder) {
  2412. return;
  2413. }
  2414. placeholder.textContent = "";
  2415. }
  2416. showDescs(node) {
  2417. let children = this.findChildren(node);
  2418. children.forEach((child) => {
  2419. child.style.display = null;
  2420. });
  2421. }
  2422. hide(node) {
  2423. this.removeClass(node, "json-formater-opened");
  2424. this.addClass(node, "json-formater-closed");
  2425. this.hideDescs(node);
  2426. this.onHide(node);
  2427. }
  2428. onHide(node) {
  2429. const type2 = node.dataset.type;
  2430. const nodeId = node.dataset.nodeId;
  2431. const length = this.findChildren(node).length;
  2432. const placeholder = node.querySelector(
  2433. `*[data-node-id*=${nodeId}] > .json-formater-placeholder`
  2434. );
  2435. if (!placeholder) {
  2436. return;
  2437. }
  2438. placeholder.textContent = `${length}${length > 1 ? " items " : " item "}`;
  2439. if (type2 === "object") {
  2440. placeholder.textContent = `${length}${length > 1 ? " keys " : " key "}`;
  2441. }
  2442. }
  2443. hideDescs(node) {
  2444. const children = this.findChildren(node);
  2445. children.forEach((child) => {
  2446. child.style.display = "none";
  2447. });
  2448. }
  2449. findChildren(node) {
  2450. const pid = node.dataset.nodeId;
  2451. return this.$container.querySelectorAll(
  2452. `*[data-node-pid="${pid}"]:not(.hidden)`
  2453. );
  2454. }
  2455. findByID(id) {
  2456. return this.$container.querySelector(`*[data-node-id="${id}"]`);
  2457. }
  2458. openByID(id) {
  2459. this.show(this.findByID(id));
  2460. }
  2461. closeByID(id) {
  2462. this.hide(this.findByID(id));
  2463. }
  2464. addEvent(selector, event, fn) {
  2465. document.body.querySelectorAll(selector).forEach((el) => {
  2466. el.addEventListener(event, fn);
  2467. });
  2468. }
  2469. closest(element, selector) {
  2470. while (element) {
  2471. if (element.matches(selector)) {
  2472. return element;
  2473. }
  2474. element = element.parentElement;
  2475. }
  2476. return null;
  2477. }
  2478. hasClass(element, clas) {
  2479. return element.classList.contains(clas);
  2480. }
  2481. removeClass(element, clas) {
  2482. element.classList.remove(clas);
  2483. return this;
  2484. }
  2485. addClass(element, clas) {
  2486. element.classList.add(clas);
  2487. return this;
  2488. }
  2489. nodes() {
  2490. return this.$container.querySelectorAll(".json-formater-arrow");
  2491. }
  2492. /**
  2493. * 创建元素
  2494. * @param {String} name 元素名称
  2495. * @param {Object} attributes 属性
  2496. */
  2497. createElement(name, attributes) {
  2498. const element = document.createElement(name);
  2499. this.setAttributes(element, attributes);
  2500. return element;
  2501. }
  2502. /**
  2503. * 设置属性
  2504. * @param {HTMLElement} element 元素
  2505. * @param {Object} attributes 属性
  2506. */
  2507. setAttributes(element, attributes) {
  2508. if (!attributes) {
  2509. return;
  2510. }
  2511. for (const name in attributes) {
  2512. const value = attributes[name];
  2513. if (value) element.setAttribute(name, attributes[name]);
  2514. }
  2515. }
  2516. /**
  2517. * 获取数据的类型
  2518. * @param {Object} value
  2519. * @return 返回类型 number、object、array、string、null等
  2520. */
  2521. getType(value) {
  2522. return Object.prototype.toString.call(value).match(/\s(.+)]/)[1].toLowerCase();
  2523. }
  2524. isIterate(value) {
  2525. const type2 = this.getType(value);
  2526. return ["array", "object"].includes(type2);
  2527. }
  2528. /**
  2529. * 是否可迭代
  2530. * @param {*} value
  2531. * @returns
  2532. */
  2533. canIterate(value) {
  2534. if (!this.isIterate(value)) {
  2535. return false;
  2536. }
  2537. let len = Object.keys(value).length;
  2538. return len > 0;
  2539. }
  2540. /**
  2541. * 是否为Url
  2542. * @param {*} str
  2543. * @returns
  2544. */
  2545. isUrl(str) {
  2546. const regexp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
  2547. return regexp.test(str);
  2548. }
  2549. /**
  2550. * 转义
  2551. * @param {*} str
  2552. * @returns
  2553. */
  2554. escape(str) {
  2555. return str.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  2556. }
  2557. isColor(colorString) {
  2558. const hexCodeRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
  2559. const rgbRegex = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/;
  2560. const rgbaRegex = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0\.\d+)\s*\)$/;
  2561. return hexCodeRegex.test(colorString) || rgbRegex.test(colorString) || rgbaRegex.test(colorString);
  2562. }
  2563. random() {
  2564. let randomString = "";
  2565. const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  2566. for (let i = 0; i < 10; i++) {
  2567. const randomIndex = Math.floor(Math.random() * characters.length);
  2568. randomString += characters.charAt(randomIndex);
  2569. }
  2570. return randomString;
  2571. }
  2572. }
  2573. const cssText = `
  2574. .json-tree-table {
  2575. border-collapse: collapse;
  2576. width: -webkit-fill-available;
  2577. }
  2578.  
  2579. .json-tree-table b {
  2580. font-weight: normal;
  2581. }
  2582.  
  2583. .json-tree-table tr.selected,
  2584. .json-tree-table tr.selected td,
  2585. .json-tree-table tr.selected td b,
  2586. .json-tree-table tr.selected td a {
  2587. color: #fff !important;
  2588. background-color: #3875d7;
  2589. }
  2590.  
  2591. .json-tree-table tr:hover {
  2592. background-color: #f0f9fe;
  2593. }
  2594.  
  2595. .json-tree-table tr td:first-child {
  2596. width: 120px;
  2597. }
  2598.  
  2599. .dark-theme .json-tree-table tr:hover,
  2600. .dark-plus-theme .json-tree-table tr:hover {
  2601. background-color: #353b48;
  2602. }
  2603. `;
  2604. const DEFAULTS = {
  2605. json: null,
  2606. theme: "default",
  2607. container: null,
  2608. onExpand: null,
  2609. expander: null,
  2610. collapser: null,
  2611. onCollapse: null
  2612. };
  2613. class JsonToTable {
  2614. constructor(options) {
  2615. this.options = Object.assign(DEFAULTS, options);
  2616. if (!options.container) {
  2617. throw new Error("Container: dom element is required");
  2618. }
  2619. if (!options.json) {
  2620. throw new Error("json: json is required");
  2621. }
  2622. if (typeof options.json !== "object") {
  2623. throw new Error("json: Need to use JSON.parse conversion");
  2624. }
  2625. this.render();
  2626. this.bindEvent();
  2627. this.setTheme(this.options.theme);
  2628. }
  2629. setTheme(theme) {
  2630. const classList = document.body.classList;
  2631. classList.forEach((clas) => {
  2632. if (clas.includes("theme")) {
  2633. classList.remove(clas);
  2634. }
  2635. });
  2636. classList.add(`${theme}-theme`);
  2637. }
  2638. render() {
  2639. const { json, container } = this.options;
  2640. this.$container = container instanceof HTMLElement ? container : document.querySelector(container);
  2641. const style = this.createElement("style");
  2642. style.textContent = cssText;
  2643. document.head.appendChild(style);
  2644. this.$table = this.createElement("table");
  2645. this.$table.setAttribute("class", `json-tree-table`);
  2646. this.createNode(json, 1, "Root", "Root");
  2647. this.$container.appendChild(this.$table);
  2648. }
  2649. /**
  2650. * 创建节点
  2651. * @param {Object} json
  2652. * @param {Boolean} isRoot 是否根节点
  2653. * @param {Number} depth 递归层级
  2654. * @param {String} pChain 上级json-path
  2655. */
  2656. createNode(json, depth, pChain, parentId) {
  2657. for (const key in json) {
  2658. let value = json[key];
  2659. const type2 = this.getType(value);
  2660. const jsonPath = `${pChain}.${key}`;
  2661. const item = this.createItem(key, value, type2, depth, jsonPath, parentId);
  2662. this.$table.appendChild(item);
  2663. if (this.canIterate(value)) {
  2664. const nodeId = item.dataset.nodeId;
  2665. this.createNode(value, depth + 1, jsonPath, nodeId);
  2666. }
  2667. }
  2668. }
  2669. createItem(key, value, type2, depth, jsonPath, parentId) {
  2670. const id = key + "_" + Math.random();
  2671. const isIterate = this.isIterate(value);
  2672. const canIterate = this.canIterate(value);
  2673. const node = this.createElement("tr", {
  2674. "data-type": type2,
  2675. "data-node-id": id,
  2676. "data-node-pid": parentId,
  2677. class: "json-formater-opened"
  2678. });
  2679. const leftNode = this.createLeftNode(key, value, depth, jsonPath);
  2680. node.appendChild(leftNode);
  2681. if (!isIterate) {
  2682. const rightNode = this.createRightNode(type2, value);
  2683. node.appendChild(rightNode);
  2684. }
  2685. if (isIterate && !canIterate) {
  2686. const rightNode = this.createEmptyRightNode(type2);
  2687. node.appendChild(rightNode);
  2688. }
  2689. return node;
  2690. }
  2691. createLeftNode(key, value, depth, jsonPath) {
  2692. const node = this.createElement("td", {
  2693. "json-path": jsonPath,
  2694. colspan: this.canIterate(value) ? 2 : 0,
  2695. style: `padding-left: ${depth * 20}px`
  2696. });
  2697. const b = this.createElement("b", {
  2698. class: "json-key"
  2699. });
  2700. b.textContent = `${key}`;
  2701. node.appendChild(b);
  2702. const colon = this.createElement("span", {
  2703. class: "json-colon"
  2704. });
  2705. colon.textContent = ":";
  2706. node.appendChild(colon);
  2707. if (this.canIterate(value)) {
  2708. const icon = this.createElement("span", {
  2709. class: "json-formater-arrow"
  2710. });
  2711. node.prepend(icon);
  2712. const span = this.createElement("span", {
  2713. class: "json-formater-placeholder"
  2714. });
  2715. node.appendChild(span);
  2716. }
  2717. return node;
  2718. }
  2719. createRightNode(type2, value) {
  2720. const node = this.createElement("td", {
  2721. class: `json-${type2}`
  2722. });
  2723. node.textContent = `${value}`;
  2724. if (type2 === "string") {
  2725. value = this.escape(value);
  2726. node.textContent = `"${value}"`;
  2727. }
  2728. if (this.isUrl(value)) {
  2729. node.textContent = "";
  2730. const a = this.createElement("a", {
  2731. target: "_blank",
  2732. href: value
  2733. });
  2734. a.textContent = `"${value}"`;
  2735. node.appendChild(a);
  2736. }
  2737. if (this.isColor(value)) {
  2738. const span = this.createElement("span", {
  2739. class: "json-color",
  2740. style: `background-color: ${value}`
  2741. });
  2742. node.prepend(span);
  2743. }
  2744. return node;
  2745. }
  2746. createEmptyRightNode(type2) {
  2747. const node = this.createElement("td", {
  2748. class: `json-${type2}-bracket`
  2749. });
  2750. node.textContent = type2 === "array" ? "[]" : "{}";
  2751. return node;
  2752. }
  2753. bindEvent() {
  2754. this.addEvent(`click`, this.options.expander, () => {
  2755. this.expandAll();
  2756. });
  2757. this.addEvent(`click`, this.options.collapser, () => {
  2758. this.collapseAll();
  2759. });
  2760. this.addEvent("click", ".json-formater-arrow", (e) => {
  2761. const node = this.closest(e.currentTarget, "tr");
  2762. if (this.hasClass(node, "json-formater-opened")) {
  2763. this.hide(node);
  2764. } else {
  2765. this.show(node);
  2766. }
  2767. });
  2768. this.addEvent("click", ".json-formater-placeholder", (e) => {
  2769. const node = this.closest(e.currentTarget, "tr");
  2770. this.show(node);
  2771. });
  2772. this.addEvent("mousedown", "table tr", function(event) {
  2773. const { tagName } = event.target;
  2774. if (tagName === "A" || tagName === "SPAN" || event.ctrlKey) {
  2775. return;
  2776. }
  2777. Array.from(document.querySelectorAll(".selected")).filter((ele) => ele !== this).forEach((ele) => ele.classList.remove("selected"));
  2778. this.classList.toggle("selected");
  2779. });
  2780. }
  2781. expandAll() {
  2782. this.nodes().forEach((node) => {
  2783. this.show(node);
  2784. });
  2785. }
  2786. collapseAll() {
  2787. this.nodes().forEach((node) => {
  2788. this.hide(node);
  2789. });
  2790. }
  2791. show(node) {
  2792. this.removeClass(node, "json-formater-closed");
  2793. this.addClass(node, "json-formater-opened");
  2794. this.showDescs(node);
  2795. this.onShow(node);
  2796. }
  2797. onShow(node) {
  2798. const placeholder = node.querySelector(".json-formater-placeholder");
  2799. if (!placeholder) {
  2800. return;
  2801. }
  2802. placeholder.innerHTML = null;
  2803. const { onExpand } = this.options;
  2804. if (onExpand) onExpand(node, this);
  2805. }
  2806. showDescs(node) {
  2807. let children = this.findChildren(node);
  2808. children.forEach((child) => {
  2809. child.style.display = null;
  2810. if (this.hasClass(child, "json-formater-opened")) {
  2811. this.showDescs(child);
  2812. }
  2813. });
  2814. }
  2815. hide(node) {
  2816. this.removeClass(node, "json-formater-opened");
  2817. this.addClass(node, "json-formater-closed");
  2818. this.hideDescs(node);
  2819. this.onHide(node);
  2820. }
  2821. onHide(node) {
  2822. const type2 = node.dataset.type;
  2823. const placeholder = node.querySelector(".json-formater-placeholder");
  2824. if (!placeholder) {
  2825. return;
  2826. }
  2827. const length = this.findChildren(node).length;
  2828. let content = `[ <span>${length}${length > 1 ? " items" : " item"}</span> ]`;
  2829. if (type2 === "object") {
  2830. content = `{ <span>${length}${length > 1 ? " keys" : " key"}</span> }`;
  2831. }
  2832. placeholder.innerHTML = content;
  2833. const { onCollapse } = this.options;
  2834. if (onCollapse) onCollapse(node, this);
  2835. }
  2836. hideDescs(node) {
  2837. const children = this.findChildren(node);
  2838. children.forEach((child) => {
  2839. child.style.display = "none";
  2840. this.hideDescs(child);
  2841. });
  2842. }
  2843. findChildren(node) {
  2844. const pid = node.dataset.nodeId;
  2845. return this.$container.querySelectorAll(
  2846. `tr[data-node-pid="${pid}"]:not(.hidden)`
  2847. );
  2848. }
  2849. findByID(id) {
  2850. return this.$container.querySelector(`tr[data-node-id="${id}"]`);
  2851. }
  2852. openByID(id) {
  2853. this.show(this.findByID(id));
  2854. }
  2855. closeByID(id) {
  2856. this.hide(this.findByID(id));
  2857. }
  2858. addEvent(event, selector, fn) {
  2859. document.body.querySelectorAll(selector).forEach((el) => {
  2860. el.addEventListener(event, fn);
  2861. });
  2862. }
  2863. closest(element, selector) {
  2864. while (element) {
  2865. if (element.matches(selector)) {
  2866. return element;
  2867. }
  2868. element = element.parentElement;
  2869. }
  2870. return null;
  2871. }
  2872. hasClass(element, clas) {
  2873. return element.classList.contains(clas);
  2874. }
  2875. removeClass(element, clas) {
  2876. element.classList.remove(clas);
  2877. return this;
  2878. }
  2879. addClass(element, clas) {
  2880. element.classList.add(clas);
  2881. return this;
  2882. }
  2883. nodes() {
  2884. return this.$container.querySelectorAll("tr[data-node-id]");
  2885. }
  2886. /**
  2887. * 创建元素
  2888. * @param {String} name 元素名称
  2889. * @param {Object} attributes 属性
  2890. */
  2891. createElement(name, attributes) {
  2892. const element = document.createElement(name);
  2893. this.setAttributes(element, attributes);
  2894. return element;
  2895. }
  2896. /**
  2897. * 设置属性
  2898. * @param {HTMLElement} element 元素
  2899. * @param {Object} attributes 属性
  2900. */
  2901. setAttributes(element, attributes) {
  2902. if (!attributes) {
  2903. return;
  2904. }
  2905. for (const name in attributes) {
  2906. const value = attributes[name];
  2907. if (value) element.setAttribute(name, value);
  2908. }
  2909. }
  2910. /**
  2911. * 获取数据的类型
  2912. * @param {Object} value
  2913. * @return 返回类型 number、object、array、string、null等
  2914. */
  2915. getType(value) {
  2916. return Object.prototype.toString.call(value).match(/\s(.+)]/)[1].toLowerCase();
  2917. }
  2918. isIterate(value) {
  2919. const type2 = this.getType(value);
  2920. return ["array", "object"].includes(type2);
  2921. }
  2922. /**
  2923. * 是否可迭代
  2924. * @param {*} value
  2925. * @returns
  2926. */
  2927. canIterate(value) {
  2928. if (!this.isIterate(value)) {
  2929. return false;
  2930. }
  2931. let len = Object.keys(value).length;
  2932. return len > 0;
  2933. }
  2934. /**
  2935. * 是否为Url
  2936. * @param {*} str
  2937. * @returns
  2938. */
  2939. isUrl(str) {
  2940. const regexp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
  2941. return regexp.test(str);
  2942. }
  2943. /**
  2944. * 转义
  2945. * @param {*} str
  2946. * @returns
  2947. */
  2948. escape(str) {
  2949. return str.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  2950. }
  2951. isColor(colorString) {
  2952. const hexCodeRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
  2953. const rgbRegex = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/;
  2954. const rgbaRegex = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0\.\d+)\s*\)$/;
  2955. return hexCodeRegex.test(colorString) || rgbRegex.test(colorString) || rgbaRegex.test(colorString);
  2956. }
  2957. }
  2958. const evnet = {
  2959. /**
  2960. * a标签鼠标移入,看是否是图片,是图片生成预览图
  2961. * @returns this
  2962. */
  2963. urlHover: function() {
  2964. $(document.body).on("mouseenter", "a[href]", function() {
  2965. const href = $(this).attr("href");
  2966. if (Utils.isImg(href)) {
  2967. tippy(this, {
  2968. duration: 800,
  2969. content: `<img style="max-width: 500px;" src="${href}" />`,
  2970. allowHTML: true,
  2971. theme: "imagebox"
  2972. }).show();
  2973. }
  2974. });
  2975. return this;
  2976. },
  2977. /**
  2978. * 鼠标移入key提示JSONPath
  2979. * @returns this
  2980. */
  2981. tipsJsonPath: function() {
  2982. const that = this;
  2983. $(document.body).on("mouseenter", ".json-key", function() {
  2984. const jsonPath = that.getJsonPath(this);
  2985. const content = `<b>ctrl + 点击复制</b><br/>${jsonPath}`;
  2986. tippy(this, {
  2987. content,
  2988. duration: 800,
  2989. allowHTML: true,
  2990. theme: "layer"
  2991. }).show();
  2992. });
  2993. return that;
  2994. },
  2995. /**
  2996. * 复制key的JSONPath
  2997. * @returns
  2998. */
  2999. copyJsonPath: function() {
  3000. const that = this;
  3001. $(document.body).on("click", ".json-key", function(event) {
  3002. if (event.ctrlKey) {
  3003. const jsonPath = that.getJsonPath(this);
  3004. _GM_setClipboard(jsonPath);
  3005. layer.msg("复制成功", { time: 1500 });
  3006. }
  3007. });
  3008. return that;
  3009. },
  3010. /**
  3011. * 给定HtmlElement获取JSONPath
  3012. * @param {*} element
  3013. * @returns
  3014. */
  3015. getJsonPath: function(element) {
  3016. const jsonPath = $(element).parent().attr("json-path");
  3017. const split = jsonPath.split(".");
  3018. const splice = (prev, next) => {
  3019. return /^\d+$/.test(next) ? prev + `[${next}]` : prev + "." + next;
  3020. };
  3021. return split.reduce(splice);
  3022. },
  3023. init: function() {
  3024. this.urlHover().tipsJsonPath().copyJsonPath();
  3025. }
  3026. };
  3027. const format_style = exports("default", {
  3028. /**
  3029. * 切换JSON 格式化风格
  3030. * @param {*} style 格式化风格,default/table
  3031. * @returns
  3032. */
  3033. changeStyle: function(style) {
  3034. _GM_setValue("style", style);
  3035. this.setStyle();
  3036. return this;
  3037. },
  3038. /**
  3039. * 设置JSON 格式化风格
  3040. * @returns
  3041. */
  3042. setStyle: function() {
  3043. const style = _GM_getValue("style") || "default";
  3044. const theme = _GM_getValue("theme") || "default";
  3045. const formatBox = document.querySelector("#formatBox");
  3046. formatBox.innerHTML = "";
  3047. document.querySelector(".searchbox input").value = "";
  3048. const clear = document.querySelector(".searchbox .clear");
  3049. clear.setAttribute("hidden", true);
  3050. if (style === "default") {
  3051. _unsafeWindow.JSON_VIEWER = new JsonViewer({
  3052. theme,
  3053. json: _unsafeWindow.GLOBAL_JSON,
  3054. container: formatBox
  3055. });
  3056. } else {
  3057. _unsafeWindow.JSON_TO_TABLE = new JsonToTable({
  3058. theme,
  3059. json: _unsafeWindow.GLOBAL_JSON,
  3060. container: formatBox
  3061. });
  3062. }
  3063. if (_unsafeWindow.GLOBAL_JSONP_FUN) {
  3064. const start = document.createElement("div");
  3065. start.setAttribute("class", "jsonp");
  3066. start.textContent = `${_unsafeWindow.GLOBAL_JSONP_FUN}(`;
  3067. formatBox.prepend(start);
  3068. const end = start.cloneNode(true);
  3069. end.textContent = ")";
  3070. formatBox.append(end);
  3071. }
  3072. return this;
  3073. },
  3074. init: function() {
  3075. const that = this;
  3076. that.setStyle();
  3077. evnet.init();
  3078. window.addEventListener("message", function(event) {
  3079. const { data } = event;
  3080. if (!data) {
  3081. return;
  3082. }
  3083. if (data.reload) {
  3084. that.setStyle();
  3085. return;
  3086. }
  3087. const { type: type2, value } = data;
  3088. if (type2 === "style") {
  3089. that.changeStyle(value);
  3090. return;
  3091. }
  3092. });
  3093. }
  3094. });
  3095.  
  3096. })
  3097. };
  3098. }));
  3099.  
  3100. System.register("./index-B0rAase1-CncgL00v.js", ['jquery', './__monkey.entry-Dr2d-6z6.js', './tippy.esm-Ot9MORvr-DNGa7Opj.js', 'jsmind'], (function (exports, module) {
  3101. 'use strict';
  3102. var $, commonjsGlobal, _unsafeWindow, Utils, _GM_setClipboard, JSONbig, _GM_getValue, URL$1, _GM_setValue, tippy, require$$0;
  3103. return {
  3104. setters: [module => {
  3105. $ = module.default;
  3106. }, module => {
  3107. commonjsGlobal = module.d;
  3108. _unsafeWindow = module.b;
  3109. Utils = module.U;
  3110. _GM_setClipboard = module.c;
  3111. JSONbig = module.J;
  3112. _GM_getValue = module.a;
  3113. URL$1 = module.e;
  3114. _GM_setValue = module._;
  3115. }, module => {
  3116. tippy = module.t;
  3117. }, module => {
  3118. require$$0 = module.default;
  3119. }],
  3120. execute: (function () {
  3121.  
  3122. var domToImage = { exports: {} };
  3123. var hasRequiredDomToImage;
  3124. function requireDomToImage() {
  3125. if (hasRequiredDomToImage) return domToImage.exports;
  3126. hasRequiredDomToImage = 1;
  3127. (function(module) {
  3128. (function(global) {
  3129. var util = newUtil();
  3130. var inliner = newInliner();
  3131. var fontFaces = newFontFaces();
  3132. var images = newImages();
  3133. var defaultOptions = {
  3134. // Default is to fail on error, no placeholder
  3135. imagePlaceholder: void 0,
  3136. // Default cache bust is false, it will use the cache
  3137. cacheBust: false
  3138. };
  3139. var domtoimage = {
  3140. toSvg,
  3141. toPng,
  3142. toJpeg,
  3143. toBlob,
  3144. toPixelData,
  3145. impl: {
  3146. fontFaces,
  3147. images,
  3148. util,
  3149. inliner,
  3150. options: {}
  3151. }
  3152. };
  3153. module.exports = domtoimage;
  3154. function toSvg(node, options) {
  3155. options = options || {};
  3156. copyOptions(options);
  3157. return Promise.resolve(node).then(function(node2) {
  3158. return cloneNode(node2, options.filter, true);
  3159. }).then(embedFonts).then(inlineImages).then(applyOptions).then(function(clone) {
  3160. return makeSvgDataUri(
  3161. clone,
  3162. options.width || util.width(node),
  3163. options.height || util.height(node)
  3164. );
  3165. });
  3166. function applyOptions(clone) {
  3167. if (options.bgcolor) clone.style.backgroundColor = options.bgcolor;
  3168. if (options.width) clone.style.width = options.width + "px";
  3169. if (options.height) clone.style.height = options.height + "px";
  3170. if (options.style)
  3171. Object.keys(options.style).forEach(function(property) {
  3172. clone.style[property] = options.style[property];
  3173. });
  3174. return clone;
  3175. }
  3176. }
  3177. function toPixelData(node, options) {
  3178. return draw(node, options || {}).then(function(canvas) {
  3179. return canvas.getContext("2d").getImageData(
  3180. 0,
  3181. 0,
  3182. util.width(node),
  3183. util.height(node)
  3184. ).data;
  3185. });
  3186. }
  3187. function toPng(node, options) {
  3188. return draw(node, options || {}).then(function(canvas) {
  3189. return canvas.toDataURL();
  3190. });
  3191. }
  3192. function toJpeg(node, options) {
  3193. options = options || {};
  3194. return draw(node, options).then(function(canvas) {
  3195. return canvas.toDataURL("image/jpeg", options.quality || 1);
  3196. });
  3197. }
  3198. function toBlob(node, options) {
  3199. return draw(node, options || {}).then(util.canvasToBlob);
  3200. }
  3201. function copyOptions(options) {
  3202. if (typeof options.imagePlaceholder === "undefined") {
  3203. domtoimage.impl.options.imagePlaceholder = defaultOptions.imagePlaceholder;
  3204. } else {
  3205. domtoimage.impl.options.imagePlaceholder = options.imagePlaceholder;
  3206. }
  3207. if (typeof options.cacheBust === "undefined") {
  3208. domtoimage.impl.options.cacheBust = defaultOptions.cacheBust;
  3209. } else {
  3210. domtoimage.impl.options.cacheBust = options.cacheBust;
  3211. }
  3212. }
  3213. function draw(domNode, options) {
  3214. return toSvg(domNode, options).then(util.makeImage).then(util.delay(100)).then(function(image) {
  3215. var canvas = newCanvas(domNode);
  3216. canvas.getContext("2d").drawImage(image, 0, 0);
  3217. return canvas;
  3218. });
  3219. function newCanvas(domNode2) {
  3220. var canvas = document.createElement("canvas");
  3221. canvas.width = options.width || util.width(domNode2);
  3222. canvas.height = options.height || util.height(domNode2);
  3223. if (options.bgcolor) {
  3224. var ctx = canvas.getContext("2d");
  3225. ctx.fillStyle = options.bgcolor;
  3226. ctx.fillRect(0, 0, canvas.width, canvas.height);
  3227. }
  3228. return canvas;
  3229. }
  3230. }
  3231. function cloneNode(node, filter2, root) {
  3232. if (!root && filter2 && !filter2(node)) return Promise.resolve();
  3233. return Promise.resolve(node).then(makeNodeCopy).then(function(clone) {
  3234. return cloneChildren(node, clone, filter2);
  3235. }).then(function(clone) {
  3236. return processClone(node, clone);
  3237. });
  3238. function makeNodeCopy(node2) {
  3239. if (node2 instanceof HTMLCanvasElement) return util.makeImage(node2.toDataURL());
  3240. return node2.cloneNode(false);
  3241. }
  3242. function cloneChildren(original, clone, filter3) {
  3243. var children = original.childNodes;
  3244. if (children.length === 0) return Promise.resolve(clone);
  3245. return cloneChildrenInOrder(clone, util.asArray(children), filter3).then(function() {
  3246. return clone;
  3247. });
  3248. function cloneChildrenInOrder(parent, children2, filter4) {
  3249. var done = Promise.resolve();
  3250. children2.forEach(function(child) {
  3251. done = done.then(function() {
  3252. return cloneNode(child, filter4);
  3253. }).then(function(childClone) {
  3254. if (childClone) parent.appendChild(childClone);
  3255. });
  3256. });
  3257. return done;
  3258. }
  3259. }
  3260. function processClone(original, clone) {
  3261. if (!(clone instanceof Element)) return clone;
  3262. return Promise.resolve().then(cloneStyle).then(clonePseudoElements).then(copyUserInput).then(fixSvg).then(function() {
  3263. return clone;
  3264. });
  3265. function cloneStyle() {
  3266. copyStyle(window.getComputedStyle(original), clone.style);
  3267. function copyStyle(source, target) {
  3268. if (source.cssText) target.cssText = source.cssText;
  3269. else copyProperties(source, target);
  3270. function copyProperties(source2, target2) {
  3271. util.asArray(source2).forEach(function(name) {
  3272. target2.setProperty(
  3273. name,
  3274. source2.getPropertyValue(name),
  3275. source2.getPropertyPriority(name)
  3276. );
  3277. });
  3278. }
  3279. }
  3280. }
  3281. function clonePseudoElements() {
  3282. [":before", ":after"].forEach(function(element) {
  3283. clonePseudoElement(element);
  3284. });
  3285. function clonePseudoElement(element) {
  3286. var style = window.getComputedStyle(original, element);
  3287. var content = style.getPropertyValue("content");
  3288. if (content === "" || content === "none") return;
  3289. var className = util.uid();
  3290. clone.className = clone.className + " " + className;
  3291. var styleElement = document.createElement("style");
  3292. styleElement.appendChild(formatPseudoElementStyle(className, element, style));
  3293. clone.appendChild(styleElement);
  3294. function formatPseudoElementStyle(className2, element2, style2) {
  3295. var selector = "." + className2 + ":" + element2;
  3296. var cssText = style2.cssText ? formatCssText(style2) : formatCssProperties(style2);
  3297. return document.createTextNode(selector + "{" + cssText + "}");
  3298. function formatCssText(style3) {
  3299. var content2 = style3.getPropertyValue("content");
  3300. return style3.cssText + " content: " + content2 + ";";
  3301. }
  3302. function formatCssProperties(style3) {
  3303. return util.asArray(style3).map(formatProperty).join("; ") + ";";
  3304. function formatProperty(name) {
  3305. return name + ": " + style3.getPropertyValue(name) + (style3.getPropertyPriority(name) ? " !important" : "");
  3306. }
  3307. }
  3308. }
  3309. }
  3310. }
  3311. function copyUserInput() {
  3312. if (original instanceof HTMLTextAreaElement) clone.innerHTML = original.value;
  3313. if (original instanceof HTMLInputElement) clone.setAttribute("value", original.value);
  3314. }
  3315. function fixSvg() {
  3316. if (!(clone instanceof SVGElement)) return;
  3317. clone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
  3318. if (!(clone instanceof SVGRectElement)) return;
  3319. ["width", "height"].forEach(function(attribute) {
  3320. var value = clone.getAttribute(attribute);
  3321. if (!value) return;
  3322. clone.style.setProperty(attribute, value);
  3323. });
  3324. }
  3325. }
  3326. }
  3327. function embedFonts(node) {
  3328. return fontFaces.resolveAll().then(function(cssText) {
  3329. var styleNode = document.createElement("style");
  3330. node.appendChild(styleNode);
  3331. styleNode.appendChild(document.createTextNode(cssText));
  3332. return node;
  3333. });
  3334. }
  3335. function inlineImages(node) {
  3336. return images.inlineAll(node).then(function() {
  3337. return node;
  3338. });
  3339. }
  3340. function makeSvgDataUri(node, width, height) {
  3341. return Promise.resolve(node).then(function(node2) {
  3342. node2.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
  3343. return new XMLSerializer().serializeToString(node2);
  3344. }).then(util.escapeXhtml).then(function(xhtml) {
  3345. return '<foreignObject x="0" y="0" width="100%" height="100%">' + xhtml + "</foreignObject>";
  3346. }).then(function(foreignObject) {
  3347. return '<svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height + '">' + foreignObject + "</svg>";
  3348. }).then(function(svg) {
  3349. return "data:image/svg+xml;charset=utf-8," + svg;
  3350. });
  3351. }
  3352. function newUtil() {
  3353. return {
  3354. escape,
  3355. parseExtension,
  3356. mimeType,
  3357. dataAsUrl,
  3358. isDataUrl,
  3359. canvasToBlob,
  3360. resolveUrl,
  3361. getAndEncode,
  3362. uid: uid(),
  3363. delay,
  3364. asArray,
  3365. escapeXhtml,
  3366. makeImage,
  3367. width,
  3368. height
  3369. };
  3370. function mimes() {
  3371. var WOFF = "application/font-woff";
  3372. var JPEG = "image/jpeg";
  3373. return {
  3374. "woff": WOFF,
  3375. "woff2": WOFF,
  3376. "ttf": "application/font-truetype",
  3377. "eot": "application/vnd.ms-fontobject",
  3378. "png": "image/png",
  3379. "jpg": JPEG,
  3380. "jpeg": JPEG,
  3381. "gif": "image/gif",
  3382. "tiff": "image/tiff",
  3383. "svg": "image/svg+xml"
  3384. };
  3385. }
  3386. function parseExtension(url) {
  3387. var match = /\.([^\.\/]*?)$/g.exec(url);
  3388. if (match) return match[1];
  3389. else return "";
  3390. }
  3391. function mimeType(url) {
  3392. var extension = parseExtension(url).toLowerCase();
  3393. return mimes()[extension] || "";
  3394. }
  3395. function isDataUrl(url) {
  3396. return url.search(/^(data:)/) !== -1;
  3397. }
  3398. function toBlob2(canvas) {
  3399. return new Promise(function(resolve) {
  3400. var binaryString = window.atob(canvas.toDataURL().split(",")[1]);
  3401. var length = binaryString.length;
  3402. var binaryArray = new Uint8Array(length);
  3403. for (var i = 0; i < length; i++)
  3404. binaryArray[i] = binaryString.charCodeAt(i);
  3405. resolve(new Blob([binaryArray], {
  3406. type: "image/png"
  3407. }));
  3408. });
  3409. }
  3410. function canvasToBlob(canvas) {
  3411. if (canvas.toBlob)
  3412. return new Promise(function(resolve) {
  3413. canvas.toBlob(resolve);
  3414. });
  3415. return toBlob2(canvas);
  3416. }
  3417. function resolveUrl(url, baseUrl) {
  3418. var doc = document.implementation.createHTMLDocument();
  3419. var base = doc.createElement("base");
  3420. doc.head.appendChild(base);
  3421. var a = doc.createElement("a");
  3422. doc.body.appendChild(a);
  3423. base.href = baseUrl;
  3424. a.href = url;
  3425. return a.href;
  3426. }
  3427. function uid() {
  3428. var index = 0;
  3429. return function() {
  3430. return "u" + fourRandomChars() + index++;
  3431. function fourRandomChars() {
  3432. return ("0000" + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4);
  3433. }
  3434. };
  3435. }
  3436. function makeImage(uri) {
  3437. return new Promise(function(resolve, reject) {
  3438. var image = new Image();
  3439. image.onload = function() {
  3440. resolve(image);
  3441. };
  3442. image.onerror = reject;
  3443. image.src = uri;
  3444. });
  3445. }
  3446. function getAndEncode(url) {
  3447. var TIMEOUT = 3e4;
  3448. if (domtoimage.impl.options.cacheBust) {
  3449. url += (/\?/.test(url) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime();
  3450. }
  3451. return new Promise(function(resolve) {
  3452. var request = new XMLHttpRequest();
  3453. request.onreadystatechange = done;
  3454. request.ontimeout = timeout;
  3455. request.responseType = "blob";
  3456. request.timeout = TIMEOUT;
  3457. request.open("GET", url, true);
  3458. request.send();
  3459. var placeholder;
  3460. if (domtoimage.impl.options.imagePlaceholder) {
  3461. var split = domtoimage.impl.options.imagePlaceholder.split(/,/);
  3462. if (split && split[1]) {
  3463. placeholder = split[1];
  3464. }
  3465. }
  3466. function done() {
  3467. if (request.readyState !== 4) return;
  3468. if (request.status !== 200) {
  3469. if (placeholder) {
  3470. resolve(placeholder);
  3471. } else {
  3472. fail("cannot fetch resource: " + url + ", status: " + request.status);
  3473. }
  3474. return;
  3475. }
  3476. var encoder = new FileReader();
  3477. encoder.onloadend = function() {
  3478. var content = encoder.result.split(/,/)[1];
  3479. resolve(content);
  3480. };
  3481. encoder.readAsDataURL(request.response);
  3482. }
  3483. function timeout() {
  3484. if (placeholder) {
  3485. resolve(placeholder);
  3486. } else {
  3487. fail("timeout of " + TIMEOUT + "ms occured while fetching resource: " + url);
  3488. }
  3489. }
  3490. function fail(message) {
  3491. console.error(message);
  3492. resolve("");
  3493. }
  3494. });
  3495. }
  3496. function dataAsUrl(content, type) {
  3497. return "data:" + type + ";base64," + content;
  3498. }
  3499. function escape(string) {
  3500. return string.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
  3501. }
  3502. function delay(ms) {
  3503. return function(arg) {
  3504. return new Promise(function(resolve) {
  3505. setTimeout(function() {
  3506. resolve(arg);
  3507. }, ms);
  3508. });
  3509. };
  3510. }
  3511. function asArray(arrayLike) {
  3512. var array = [];
  3513. var length = arrayLike.length;
  3514. for (var i = 0; i < length; i++) array.push(arrayLike[i]);
  3515. return array;
  3516. }
  3517. function escapeXhtml(string) {
  3518. return string.replace(/#/g, "%23").replace(/\n/g, "%0A");
  3519. }
  3520. function width(node) {
  3521. var leftBorder = px(node, "border-left-width");
  3522. var rightBorder = px(node, "border-right-width");
  3523. return node.scrollWidth + leftBorder + rightBorder;
  3524. }
  3525. function height(node) {
  3526. var topBorder = px(node, "border-top-width");
  3527. var bottomBorder = px(node, "border-bottom-width");
  3528. return node.scrollHeight + topBorder + bottomBorder;
  3529. }
  3530. function px(node, styleProperty) {
  3531. var value = window.getComputedStyle(node).getPropertyValue(styleProperty);
  3532. return parseFloat(value.replace("px", ""));
  3533. }
  3534. }
  3535. function newInliner() {
  3536. var URL_REGEX = /url\(['"]?([^'"]+?)['"]?\)/g;
  3537. return {
  3538. inlineAll,
  3539. shouldProcess,
  3540. impl: {
  3541. readUrls,
  3542. inline
  3543. }
  3544. };
  3545. function shouldProcess(string) {
  3546. return string.search(URL_REGEX) !== -1;
  3547. }
  3548. function readUrls(string) {
  3549. var result = [];
  3550. var match;
  3551. while ((match = URL_REGEX.exec(string)) !== null) {
  3552. result.push(match[1]);
  3553. }
  3554. return result.filter(function(url) {
  3555. return !util.isDataUrl(url);
  3556. });
  3557. }
  3558. function inline(string, url, baseUrl, get) {
  3559. return Promise.resolve(url).then(function(url2) {
  3560. return baseUrl ? util.resolveUrl(url2, baseUrl) : url2;
  3561. }).then(get || util.getAndEncode).then(function(data) {
  3562. return util.dataAsUrl(data, util.mimeType(url));
  3563. }).then(function(dataUrl) {
  3564. return string.replace(urlAsRegex(url), "$1" + dataUrl + "$3");
  3565. });
  3566. function urlAsRegex(url2) {
  3567. return new RegExp(`(url\\(['"]?)(` + util.escape(url2) + `)(['"]?\\))`, "g");
  3568. }
  3569. }
  3570. function inlineAll(string, baseUrl, get) {
  3571. if (nothingToInline()) return Promise.resolve(string);
  3572. return Promise.resolve(string).then(readUrls).then(function(urls) {
  3573. var done = Promise.resolve(string);
  3574. urls.forEach(function(url) {
  3575. done = done.then(function(string2) {
  3576. return inline(string2, url, baseUrl, get);
  3577. });
  3578. });
  3579. return done;
  3580. });
  3581. function nothingToInline() {
  3582. return !shouldProcess(string);
  3583. }
  3584. }
  3585. }
  3586. function newFontFaces() {
  3587. return {
  3588. resolveAll,
  3589. impl: {
  3590. readAll
  3591. }
  3592. };
  3593. function resolveAll() {
  3594. return readAll().then(function(webFonts) {
  3595. return Promise.all(
  3596. webFonts.map(function(webFont) {
  3597. return webFont.resolve();
  3598. })
  3599. );
  3600. }).then(function(cssStrings) {
  3601. return cssStrings.join("\n");
  3602. });
  3603. }
  3604. function readAll() {
  3605. return Promise.resolve(util.asArray(document.styleSheets)).then(getCssRules).then(selectWebFontRules).then(function(rules) {
  3606. return rules.map(newWebFont);
  3607. });
  3608. function selectWebFontRules(cssRules) {
  3609. return cssRules.filter(function(rule) {
  3610. return rule.type === CSSRule.FONT_FACE_RULE;
  3611. }).filter(function(rule) {
  3612. return inliner.shouldProcess(rule.style.getPropertyValue("src"));
  3613. });
  3614. }
  3615. function getCssRules(styleSheets) {
  3616. var cssRules = [];
  3617. styleSheets.forEach(function(sheet) {
  3618. try {
  3619. util.asArray(sheet.cssRules || []).forEach(cssRules.push.bind(cssRules));
  3620. } catch (e) {
  3621. console.log("Error while reading CSS rules from " + sheet.href, e.toString());
  3622. }
  3623. });
  3624. return cssRules;
  3625. }
  3626. function newWebFont(webFontRule) {
  3627. return {
  3628. resolve: function resolve() {
  3629. var baseUrl = (webFontRule.parentStyleSheet || {}).href;
  3630. return inliner.inlineAll(webFontRule.cssText, baseUrl);
  3631. },
  3632. src: function() {
  3633. return webFontRule.style.getPropertyValue("src");
  3634. }
  3635. };
  3636. }
  3637. }
  3638. }
  3639. function newImages() {
  3640. return {
  3641. inlineAll,
  3642. impl: {
  3643. newImage
  3644. }
  3645. };
  3646. function newImage(element) {
  3647. return {
  3648. inline
  3649. };
  3650. function inline(get) {
  3651. if (util.isDataUrl(element.src)) return Promise.resolve();
  3652. return Promise.resolve(element.src).then(get || util.getAndEncode).then(function(data) {
  3653. return util.dataAsUrl(data, util.mimeType(element.src));
  3654. }).then(function(dataUrl) {
  3655. return new Promise(function(resolve, reject) {
  3656. element.onload = resolve;
  3657. element.onerror = reject;
  3658. element.src = dataUrl;
  3659. });
  3660. });
  3661. }
  3662. }
  3663. function inlineAll(node) {
  3664. if (!(node instanceof Element)) return Promise.resolve(node);
  3665. return inlineBackground(node).then(function() {
  3666. if (node instanceof HTMLImageElement)
  3667. return newImage(node).inline();
  3668. else
  3669. return Promise.all(
  3670. util.asArray(node.childNodes).map(function(child) {
  3671. return inlineAll(child);
  3672. })
  3673. );
  3674. });
  3675. function inlineBackground(node2) {
  3676. var background = node2.style.getPropertyValue("background");
  3677. if (!background) return Promise.resolve(node2);
  3678. return inliner.inlineAll(background).then(function(inlined) {
  3679. node2.style.setProperty(
  3680. "background",
  3681. inlined,
  3682. node2.style.getPropertyPriority("background")
  3683. );
  3684. }).then(function() {
  3685. return node2;
  3686. });
  3687. }
  3688. }
  3689. }
  3690. })();
  3691. })(domToImage);
  3692. return domToImage.exports;
  3693. }
  3694. /**
  3695. * @license BSD-3-Clause
  3696. * @copyright 2014-2023 hizzgdev@163.com
  3697. *
  3698. * Project Home:
  3699. * https://github.com/hizzgdev/jsmind/
  3700. */
  3701. (function(module, exports) {
  3702. !function(e, t) {
  3703. t(require$$0, requireDomToImage());
  3704. }(commonjsGlobal, function(e, t) {
  3705. function i(e2) {
  3706. return e2 && "object" == typeof e2 && "default" in e2 ? e2 : { default: e2 };
  3707. }
  3708. var n = i(e), o = i(t);
  3709. if (!n.default) throw new Error("jsMind is not defined");
  3710. if (!o.default) throw new Error("dom-to-image is required");
  3711. const r = n.default.$, s = { filename: null, watermark: { left: r.w.location, right: "https://github.com/hizzgdev/jsmind" }, background: "transparent" };
  3712. class a {
  3713. constructor(e2, t2) {
  3714. var i2 = {};
  3715. 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;
  3716. }
  3717. shoot() {
  3718. let e2 = this.create_canvas(), t2 = e2.getContext("2d");
  3719. 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));
  3720. }
  3721. create_canvas() {
  3722. let e2 = r.c("canvas");
  3723. const t2 = this.jm.view.size.w, i2 = this.jm.view.size.h;
  3724. 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;
  3725. }
  3726. clear(e2) {
  3727. e2.parentNode.removeChild(e2);
  3728. }
  3729. draw_background(e2) {
  3730. return new Promise((function(t2, i2) {
  3731. const n2 = this.options.background;
  3732. n2 && "transparent" !== n2 && (e2.fillStyle = this.options.background, e2.fillRect(0, 0, this.jm.view.size.w, this.jm.view.size.h)), t2(e2);
  3733. }).bind(this));
  3734. }
  3735. draw_lines(e2) {
  3736. return new Promise((function(t2, i2) {
  3737. this.jm.view.graph.copy_to(e2, function() {
  3738. t2(e2);
  3739. });
  3740. }).bind(this));
  3741. }
  3742. draw_nodes(e2) {
  3743. return o.default.toSvg(this.jm.view.e_nodes, { style: { zoom: 1 } }).then(this.load_image).then(function(t2) {
  3744. return e2.drawImage(t2, 0, 0), e2;
  3745. });
  3746. }
  3747. draw_watermark(e2, t2) {
  3748. 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;
  3749. }
  3750. load_image(e2) {
  3751. return new Promise(function(t2, i2) {
  3752. let n2 = new Image();
  3753. n2.onload = function() {
  3754. t2(n2);
  3755. }, n2.onerror = i2, n2.src = e2;
  3756. });
  3757. }
  3758. download(e2) {
  3759. var t2 = (this.options.filename || this.jm.mind.name) + ".png";
  3760. if (navigator.msSaveBlob && e2.msToBlob) {
  3761. var i2 = e2.msToBlob();
  3762. navigator.msSaveBlob(i2, t2);
  3763. } else {
  3764. var n2 = e2.toDataURL(), o2 = r.c("a");
  3765. if ("download" in o2) {
  3766. o2.style.visibility = "hidden", o2.href = n2, o2.download = t2, r.d.body.appendChild(o2);
  3767. var s2 = r.d.createEvent("MouseEvents");
  3768. s2.initEvent("click", true, true), o2.dispatchEvent(s2), r.d.body.removeChild(o2);
  3769. } else location.href = n2;
  3770. }
  3771. }
  3772. }
  3773. let d = new n.default.plugin("screenshot", function(e2, t2) {
  3774. var i2 = new a(e2, t2);
  3775. e2.screenshot = i2, e2.shoot = function() {
  3776. i2.shoot();
  3777. };
  3778. });
  3779. n.default.register_plugin(d);
  3780. });
  3781. })();
  3782. const jsonMind = {
  3783. isFirst: true,
  3784. /**
  3785. * JSON数据转换为jsMind所需要的数据结构
  3786. * @param {*} json JSON 数据
  3787. * @returns
  3788. */
  3789. convert: function(json) {
  3790. const children = [];
  3791. if (typeof json === "object") {
  3792. for (const key in json) {
  3793. let val = json[key], isArray = Array.isArray(val);
  3794. const type = Utils.getPrototype(val);
  3795. if (isArray && val.length > 0) {
  3796. val = Utils.findMaxKeysObject(val);
  3797. }
  3798. children.push({
  3799. isArray,
  3800. chain: key,
  3801. id: key + "_" + Math.random(),
  3802. topic: `${key}<span class="datatype">${type}</span>`,
  3803. children: this.convert(val)
  3804. });
  3805. }
  3806. }
  3807. return children;
  3808. },
  3809. /**
  3810. * 脑图节点调用链
  3811. * @param {*} node 脑图节点对象
  3812. * @returns
  3813. */
  3814. mindChain: function(node) {
  3815. let chain = node.data.chain;
  3816. if (!node.parent) {
  3817. return chain;
  3818. }
  3819. const parent = node.parent;
  3820. const parentChain = this.mindChain(parent);
  3821. chain = parent.data.isArray ? `${parentChain}[i].${chain}` : `${parentChain}.${chain}`;
  3822. return chain;
  3823. },
  3824. /**
  3825. * 显示脑图
  3826. * @param {*} json JSON 数据
  3827. * @returns
  3828. */
  3829. show: function(json) {
  3830. let isArr = Array.isArray(json);
  3831. if (isArr) {
  3832. if (typeof json[0] !== "object") {
  3833. layer.msg("数据结构无法生成脑图", { time: 1e3 });
  3834. return this;
  3835. }
  3836. json = Utils.findMaxKeysObject(json);
  3837. }
  3838. if (!this.isFirst) {
  3839. return this;
  3840. }
  3841. _unsafeWindow.GLOBAL_JSMIND.show({
  3842. meta: {
  3843. version: "1.0",
  3844. name: "JSON脑图",
  3845. author: "1220301855@qq.com"
  3846. },
  3847. format: "node_tree",
  3848. /* 数据内容 */
  3849. data: {
  3850. id: "root",
  3851. topic: "Root",
  3852. direction: "left",
  3853. children: this.convert(json),
  3854. chain: isArr ? "Root[i]" : "Root"
  3855. }
  3856. });
  3857. this.isFirst = false;
  3858. return this;
  3859. },
  3860. /**
  3861. * 脑图节点事件
  3862. * @returns
  3863. */
  3864. event: function() {
  3865. const jsonMind2 = this;
  3866. $(document.body).on("dblclick mouseover", "jmnode", function(event) {
  3867. const nodeid = $(this).attr("nodeid");
  3868. const node = _unsafeWindow.GLOBAL_JSMIND.get_node(nodeid);
  3869. if (!node.parent) {
  3870. return;
  3871. }
  3872. if (event.type === "dblclick") {
  3873. _GM_setClipboard(jsonMind2.mindChain(node));
  3874. layer.msg("节点路径复制成功", { time: 1500 });
  3875. } else {
  3876. const chain = jsonMind2.mindChain(node);
  3877. const content = `<b>节点路径(双击复制)</b><br/>${chain}`;
  3878. tippy(this, {
  3879. content,
  3880. duration: 800,
  3881. allowHTML: true,
  3882. theme: "layer"
  3883. }).show();
  3884. }
  3885. });
  3886. return this;
  3887. },
  3888. init: function(json) {
  3889. if (!_unsafeWindow.GLOBAL_JSMIND) {
  3890. _unsafeWindow.GLOBAL_JSMIND = new require$$0({
  3891. mode: "side",
  3892. editable: false,
  3893. container: "mindBox",
  3894. view: {
  3895. hmargin: 50,
  3896. // 思维导图距容器外框的最小水平距离
  3897. vmargin: 50,
  3898. // 思维导图距容器外框的最小垂直距离
  3899. engine: "svg",
  3900. // 思维导图各节点之间线条的绘制引擎
  3901. draggable: true,
  3902. // 当容器不能完全容纳思维导图时,是否允许拖动画布代替鼠标滚动
  3903. support_html: false,
  3904. line_color: "#C4C9D0"
  3905. },
  3906. zoom: {
  3907. // 配置缩放
  3908. min: 0.1,
  3909. // 最小的缩放比例
  3910. max: 2.1,
  3911. // 最大的缩放比例
  3912. step: 0.1
  3913. // 缩放比例间隔
  3914. },
  3915. layout: {
  3916. vspace: 7,
  3917. // 节点之间的垂直间距
  3918. hspace: 150
  3919. // 节点之间的水平空间
  3920. }
  3921. });
  3922. }
  3923. this.show(json).event();
  3924. }
  3925. };
  3926. const $mindBox = $("#mindBox");
  3927. const $formatBox = $("#formatBox");
  3928. const $rawTextBox = $("#rawTextBox");
  3929. const tabsEvent = {
  3930. firstFormat: true,
  3931. isBeautify: false,
  3932. $rawTextPre: $rawTextBox.find("pre"),
  3933. /**
  3934. * 原始数据
  3935. */
  3936. _setRawText: function() {
  3937. let rawText = _unsafeWindow.RAW_TEXT;
  3938. if (_unsafeWindow.GLOBAL_JSONP_FUN) {
  3939. rawText = `${_unsafeWindow.GLOBAL_JSONP_FUN}(${rawText})`;
  3940. }
  3941. this.$rawTextPre.text(rawText);
  3942. },
  3943. /**
  3944. * 保存为文件
  3945. * 如果是JSON 格式化可见,保存JSON数据为.json文件
  3946. * 如果是JSON 脑图可见,保存脑图为图片
  3947. */
  3948. saveJson: function() {
  3949. if ($mindBox.is(":visible")) {
  3950. _unsafeWindow.GLOBAL_JSMIND.shoot();
  3951. return;
  3952. }
  3953. const content = this.$rawTextPre.text() || _unsafeWindow.RAW_TEXT;
  3954. const filename = (/* @__PURE__ */ new Date()).getTime() + ".json";
  3955. Utils.downloadText(content, filename);
  3956. },
  3957. /**
  3958. * 复制JSON文本内容
  3959. */
  3960. copyJson: function() {
  3961. const content = this.$rawTextPre.text() || _unsafeWindow.RAW_TEXT;
  3962. _GM_setClipboard(content);
  3963. layer.msg("复制成功", { time: 1500 });
  3964. },
  3965. /**
  3966. * 点击了`全部折叠`
  3967. * 如果是JSON 格式化可见,折叠JSON
  3968. * 如果是JSON 脑图可见,折叠脑图节点
  3969. */
  3970. collapseAll: function() {
  3971. var _a, _b, _c, _d;
  3972. if ($formatBox.is(":visible")) {
  3973. (_b = (_a = _unsafeWindow) == null ? void 0 : _a.JSON_VIEWER) == null ? void 0 : _b.collapseAll();
  3974. (_d = (_c = _unsafeWindow) == null ? void 0 : _c.JSON_TO_TABLE) == null ? void 0 : _d.collapseAll();
  3975. return;
  3976. }
  3977. _unsafeWindow.GLOBAL_JSMIND.collapse_all();
  3978. },
  3979. /**
  3980. * 点击了`全部展开`
  3981. * 如果是JSON 格式化可见,展开JSON
  3982. * 如果是JSON 脑图可见,展开脑图节点
  3983. */
  3984. expandAll: function() {
  3985. var _a, _b, _c, _d;
  3986. if ($formatBox.is(":visible")) {
  3987. (_b = (_a = _unsafeWindow) == null ? void 0 : _a.JSON_VIEWER) == null ? void 0 : _b.expandAll();
  3988. (_d = (_c = _unsafeWindow) == null ? void 0 : _c.JSON_TO_TABLE) == null ? void 0 : _d.expandAll();
  3989. return;
  3990. }
  3991. _unsafeWindow.GLOBAL_JSMIND.expand_all();
  3992. _unsafeWindow.GLOBAL_JSMIND.scroll_node_to_center(
  3993. _unsafeWindow.GLOBAL_JSMIND.get_root()
  3994. );
  3995. },
  3996. viewFormater: function() {
  3997. },
  3998. /**
  3999. * tabs点击了`JSON 脑图`
  4000. */
  4001. viewMind: function() {
  4002. jsonMind.init(_unsafeWindow.GLOBAL_JSON);
  4003. _unsafeWindow.GLOBAL_JSMIND.scroll_node_to_center(
  4004. _unsafeWindow.GLOBAL_JSMIND.get_root()
  4005. );
  4006. },
  4007. /**
  4008. * tabs点击了`原始数据`
  4009. */
  4010. viewRawText: function() {
  4011. if (!this.firstFormat) {
  4012. return;
  4013. }
  4014. this.firstFormat = false;
  4015. this._setRawText();
  4016. },
  4017. /**
  4018. * 点击了`美化输出`
  4019. */
  4020. beautify: function() {
  4021. this.isBeautify = !this.isBeautify;
  4022. if (this.isBeautify) {
  4023. let str = JSONbig.stringify(_unsafeWindow.GLOBAL_JSON, null, 2);
  4024. if (_unsafeWindow.GLOBAL_JSONP_FUN) {
  4025. str = `${_unsafeWindow.GLOBAL_JSONP_FUN}(${str})`;
  4026. }
  4027. this.$rawTextPre.text(str);
  4028. return;
  4029. }
  4030. this._setRawText();
  4031. },
  4032. /**
  4033. * 点击了`JSON Crack`
  4034. */
  4035. jsoncrack: function() {
  4036. let theme2 = _GM_getValue("theme") || "light";
  4037. theme2 = theme2.replace(/_.*/, "");
  4038. layer.closeAll();
  4039. layer.open({
  4040. type: 1,
  4041. title: false,
  4042. area: ["100vw", "100vh"],
  4043. content: `<iframe id="jsoncrackEmbed" src="${URL$1.JSON_CRACK_WIDGET}"></iframe>`,
  4044. success: function(layero) {
  4045. const jsonCrackEmbed = layero.find("#jsoncrackEmbed")[0];
  4046. window == null ? void 0 : window.addEventListener("message", () => {
  4047. var _a;
  4048. (_a = jsonCrackEmbed == null ? void 0 : jsonCrackEmbed.contentWindow) == null ? void 0 : _a.postMessage(
  4049. {
  4050. options: { theme: theme2 },
  4051. json: _unsafeWindow.RAW_TEXT
  4052. },
  4053. "*"
  4054. );
  4055. });
  4056. }
  4057. });
  4058. },
  4059. init: function() {
  4060. $(document.body).on("click", ".btn", (e) => {
  4061. const target = e.target;
  4062. const id = target.id;
  4063. if (target.classList.contains("tabs-item")) {
  4064. const clas = "active";
  4065. const index = $(target).index();
  4066. $(target).addClass(clas).siblings().removeClass(clas);
  4067. $(".container > div").removeClass(clas).eq(index).addClass(clas);
  4068. const beautifyEl = $("#beautify");
  4069. const searchEl = $(".searchbox");
  4070. const copyEl = $("#copyJson");
  4071. const jsoncrackEl = $("#jsoncrack");
  4072. const aEl = $("#collapseAll, #expandAll");
  4073. id === "viewFormater" ? searchEl.show() : searchEl.hide();
  4074. id === "viewMind" ? copyEl.hide() && jsoncrackEl.show() : copyEl.show() && jsoncrackEl.hide();
  4075. id === "viewRawText" ? beautifyEl.show() && aEl.hide() : beautifyEl.hide() && aEl.show();
  4076. }
  4077. this[id](target);
  4078. });
  4079. return this;
  4080. }
  4081. };
  4082. window.addEventListener("message", function(event) {
  4083. const { data } = event;
  4084. if (!(data == null ? void 0 : data.reload)) {
  4085. return;
  4086. }
  4087. $mindBox.empty();
  4088. jsonMind.isFirst = true;
  4089. tabsEvent.isBeautify = false;
  4090. tabsEvent.firstFormat = true;
  4091. _unsafeWindow.GLOBAL_JSMIND = void 0;
  4092. if ($rawTextBox.is(":visible")) {
  4093. tabsEvent.viewRawText();
  4094. }
  4095. if ($mindBox.is(":visible")) {
  4096. jsonMind.init(_unsafeWindow.GLOBAL_JSON);
  4097. }
  4098. });
  4099. const filter = {
  4100. /**
  4101. * 根据`filter`过滤 JSON
  4102. * @param {*} filter 过滤值
  4103. * @returns
  4104. */
  4105. match: function(filter2) {
  4106. const style = _GM_getValue("style") || "default";
  4107. const allPath = $(`#formatBox *[json-path]`);
  4108. if (!filter2) {
  4109. style == "default" ? allPath.removeClass("hidden") : allPath.parent().removeClass("hidden");
  4110. return;
  4111. }
  4112. const chainSet = /* @__PURE__ */ new Set();
  4113. document.querySelectorAll("#formatBox *[json-path]").forEach((el) => {
  4114. let chain = $(el).attr("json-path");
  4115. if (!chain) {
  4116. return;
  4117. }
  4118. const newChain = chain.substring(chain.lastIndexOf("."));
  4119. if (!newChain.toLowerCase().includes(filter2.toLowerCase())) {
  4120. return;
  4121. }
  4122. chainSet.add(chain);
  4123. while (chain = chain.substring(0, chain.lastIndexOf("."))) {
  4124. chainSet.add(chain);
  4125. }
  4126. });
  4127. const selector = [
  4128. "json-key",
  4129. "json-comma",
  4130. "json-colon",
  4131. "json-viewer",
  4132. "json-formater-placeholder"
  4133. ].reduce(
  4134. (prev, next) => prev + ':not([class*="' + next + '"])',
  4135. "#formatBox *[class*='json-']"
  4136. );
  4137. document.querySelectorAll(selector).forEach((el) => {
  4138. const target = $(el);
  4139. let chain = target.siblings().attr("json-path");
  4140. if (style == "default") {
  4141. chain = target.parent().attr("json-path");
  4142. }
  4143. if (!chain) {
  4144. return;
  4145. }
  4146. const text = target.text();
  4147. if (!text.toLowerCase().includes(filter2.toLowerCase())) {
  4148. return;
  4149. }
  4150. chainSet.add(chain);
  4151. while (chain = chain.substring(0, chain.lastIndexOf("."))) {
  4152. chainSet.add(chain);
  4153. }
  4154. });
  4155. style == "default" ? allPath.addClass("hidden") : allPath.parent().addClass("hidden");
  4156. chainSet.forEach((chain) => {
  4157. const path = $(`#formatBox *[json-path="${chain}"]`);
  4158. style == "default" ? path.removeClass("hidden") : path.parent().removeClass("hidden");
  4159. });
  4160. },
  4161. /**
  4162. * JSON 过滤输入框事件监听
  4163. * @returns
  4164. */
  4165. input: function() {
  4166. const that = this;
  4167. const debounceInput = Utils.debounce(function() {
  4168. that.match(this.value);
  4169. $(".clear").attr("hidden", !this.value);
  4170. }, 500);
  4171. $(document.body).on("input", ".searchbox input", debounceInput);
  4172. return that;
  4173. },
  4174. /**
  4175. * 清空输入框内容
  4176. * @returns
  4177. */
  4178. clear: function() {
  4179. const that = this;
  4180. $(document.body).on("click", ".searchbox .clear", function() {
  4181. that.match();
  4182. $(this).attr("hidden", true);
  4183. $(".searchbox input").val("");
  4184. });
  4185. return this;
  4186. },
  4187. init: function() {
  4188. this.input().clear();
  4189. }
  4190. };
  4191. const theme = {
  4192. /**
  4193. * 切换主题色
  4194. * @param {*} theme 主题色:default、light、dark、dark_plus
  4195. * @returns
  4196. */
  4197. changeTheme: function(theme2) {
  4198. _GM_setValue("theme", theme2);
  4199. this.setTheme();
  4200. return this;
  4201. },
  4202. /**
  4203. * 设置主题
  4204. * @returns
  4205. */
  4206. setTheme: function() {
  4207. var _a, _b, _c, _d;
  4208. const theme2 = _GM_getValue("theme") || "default";
  4209. (_b = (_a = _unsafeWindow) == null ? void 0 : _a.JSON_VIEWER) == null ? void 0 : _b.setTheme(theme2);
  4210. (_d = (_c = _unsafeWindow) == null ? void 0 : _c.JSON_TO_TABLE) == null ? void 0 : _d.setTheme(theme2);
  4211. return this;
  4212. },
  4213. init: function() {
  4214. const that = this;
  4215. that.setTheme();
  4216. window.addEventListener("message", function(event) {
  4217. const { data } = event;
  4218. if (!data) {
  4219. return;
  4220. }
  4221. const { type, value } = data;
  4222. if (type === "theme") {
  4223. that.changeTheme(value);
  4224. }
  4225. });
  4226. }
  4227. };
  4228. const http_form = `
  4229. <form class="httpRequest">
  4230. <div class="requestbox">
  4231. <select name="method">
  4232. <option value="POST">POST</option>
  4233. <option value="GET">GET</option>
  4234. <option value="PUT">PUT</option>
  4235. <option value="DELETE">DELETE</option>
  4236. </select>
  4237. <input name="url" placeholder="请求地址" />
  4238. <select name="contentType">
  4239. <option value="application/x-www-form-urlencoded;charset=UTF-8">urlencoded</option>
  4240. <option value="application/json;charset=UTF-8">application/json</option>
  4241. </select>
  4242. <button type="submit">发送</button>
  4243. </div>
  4244. <div class="textarea">
  4245. <input name="headers" placeholder='请求头 {"token": "test"}' />
  4246. <input name="params" placeholder='请求参数 {"id": "test", ""name": "test"}' />
  4247. </div>
  4248. </form>`;
  4249. const tools = {
  4250. inputJson: function() {
  4251. const that = this;
  4252. layer.prompt(
  4253. {
  4254. title: "JSON 输入",
  4255. formType: 2,
  4256. btn: ["确认"],
  4257. shadeClose: true,
  4258. maxlength: 1e6,
  4259. area: ["400px", "300px"]
  4260. },
  4261. function(text) {
  4262. if (!text) {
  4263. layer.msg("内容不能为空", { time: 1500 });
  4264. return;
  4265. }
  4266. const { rawText, jsonpFun } = Utils.jsonpMatch(text);
  4267. try {
  4268. const json = JSONbig({ useNativeBigInt: true }).parse(rawText);
  4269. that.reload(json, rawText, jsonpFun);
  4270. } catch (e) {
  4271. layer.msg("JSON格式不正确", { time: 1500 });
  4272. console.log("格式化异常: ", e);
  4273. }
  4274. }
  4275. );
  4276. return this;
  4277. },
  4278. fetchApi: function() {
  4279. const that = this;
  4280. layer.open({
  4281. type: 1,
  4282. closeBtn: 0,
  4283. shadeClose: true,
  4284. title: "HTTP 请求",
  4285. content: http_form
  4286. });
  4287. $("form").on("submit", function(event) {
  4288. event.preventDefault();
  4289. const serialize = $(this).serializeArray();
  4290. const form = {};
  4291. for (const key in serialize) {
  4292. const it = serialize[key];
  4293. form[it.name] = it.value;
  4294. }
  4295. if (form.url === "") {
  4296. layer.msg("请求URL不能为空");
  4297. return;
  4298. }
  4299. let headers = form.headers;
  4300. let params = form.params;
  4301. try {
  4302. if (headers) {
  4303. headers = JSON.parse(headers);
  4304. }
  4305. } catch (e) {
  4306. layer.msg("请求头格式不合法");
  4307. return;
  4308. }
  4309. try {
  4310. if (params) {
  4311. params = JSON.parse(params);
  4312. }
  4313. } catch (e) {
  4314. layer.msg("请求参数格式不合法");
  4315. return;
  4316. }
  4317. layer.load(0, { shade: false });
  4318. fetch(URL$1.ONLINE_REQUEST, {
  4319. method: "POST",
  4320. headers: {
  4321. "Content-Type": "application/json"
  4322. },
  4323. body: JSON.stringify(form)
  4324. }).then(async (response) => {
  4325. const result = await response.json();
  4326. if (typeof result === "string") {
  4327. try {
  4328. const { rawText, jsonpFun } = Utils.jsonpMatch(result);
  4329. const json = JSONbig({ useNativeBigInt: true }).parse(rawText);
  4330. that.reload(json, rawText, jsonpFun);
  4331. } catch (e) {
  4332. layer.closeAll();
  4333. console.log("HTTP 请求异常:", e);
  4334. }
  4335. } else {
  4336. that.reload(result, JSONbig.stringify(result), null);
  4337. }
  4338. }).catch((e) => {
  4339. layer.closeAll();
  4340. console.log("HTTP 请求异常:", e);
  4341. });
  4342. });
  4343. return this;
  4344. },
  4345. reload: function(json, rawText, jsonpFun) {
  4346. _unsafeWindow.GLOBAL_JSON = json;
  4347. _unsafeWindow.RAW_TEXT = rawText;
  4348. _unsafeWindow.GLOBAL_JSONP_FUN = jsonpFun;
  4349. window.postMessage({ reload: true });
  4350. layer.closeAll();
  4351. },
  4352. init: function() {
  4353. window.addEventListener("message", (event) => {
  4354. const { data } = event;
  4355. if (!data) {
  4356. return;
  4357. }
  4358. const { type, value } = data;
  4359. if (type === "tools") {
  4360. this[value]();
  4361. }
  4362. });
  4363. }
  4364. };
  4365. const handleBar = {
  4366. instance: null,
  4367. /**
  4368. * 对右侧操作栏的点击事件初始化
  4369. * @returns
  4370. */
  4371. handle: function() {
  4372. const that = this;
  4373. const tagName = "span";
  4374. [".style", ".theme", ".tools"].forEach((selector) => {
  4375. tippy(selector, {
  4376. duration: 500,
  4377. allowHTML: true,
  4378. interactive: true,
  4379. trigger: "click",
  4380. appendTo: document.querySelector(selector).parentNode,
  4381. onTrigger: function(instance) {
  4382. const tools2 = $(instance.reference);
  4383. tools2.siblings().find(tagName).removeClass();
  4384. tools2.find(tagName).addClass("active");
  4385. const template = tools2.find("template");
  4386. const type = template.data("type");
  4387. const value = _GM_getValue(type) || "default";
  4388. const ul = template.contents();
  4389. ul.find("li").removeClass();
  4390. ul.find(`li[data-value=${value}]`).addClass("active");
  4391. instance.setContent(template.html());
  4392. that.instance = instance;
  4393. },
  4394. onHide: function(instance) {
  4395. const tools2 = $(instance.reference);
  4396. tools2.find(tagName).removeClass();
  4397. }
  4398. });
  4399. });
  4400. return this;
  4401. },
  4402. /**
  4403. * 点击了对应选项
  4404. * 如点击了`主题`-`暗黑`,通过window.postMessage进行主题色更新
  4405. * @returns
  4406. */
  4407. checked: function() {
  4408. const that = this;
  4409. $(document.body).on("click", ".rightbox li", function() {
  4410. const el = $(this);
  4411. const hasClass = el.hasClass("active");
  4412. if (hasClass) {
  4413. return;
  4414. }
  4415. const type = el.data("type");
  4416. const value = el.data("value");
  4417. if (type !== "tools") {
  4418. el.addClass("active").siblings().removeClass();
  4419. } else {
  4420. that.instance.hide();
  4421. }
  4422. window.postMessage({ type, value });
  4423. });
  4424. return this;
  4425. },
  4426. init: function() {
  4427. this.handle().checked();
  4428. }
  4429. };
  4430. tabsEvent.init();
  4431. theme.init();
  4432. tools.init();
  4433. filter.init();
  4434. handleBar.init();
  4435.  
  4436. })
  4437. };
  4438. }));
  4439.  
  4440. System.register("./tippy.esm-Ot9MORvr-DNGa7Opj.js", [], (function (exports, module) {
  4441. 'use strict';
  4442. return {
  4443. execute: (function () {
  4444.  
  4445. exports("t", tippy);
  4446.  
  4447. var top = "top";
  4448. var bottom = "bottom";
  4449. var right = "right";
  4450. var left = "left";
  4451. var auto = "auto";
  4452. var basePlacements = [top, bottom, right, left];
  4453. var start = "start";
  4454. var end = "end";
  4455. var clippingParents = "clippingParents";
  4456. var viewport = "viewport";
  4457. var popper = "popper";
  4458. var reference = "reference";
  4459. var variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) {
  4460. return acc.concat([placement + "-" + start, placement + "-" + end]);
  4461. }, []);
  4462. var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
  4463. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  4464. }, []);
  4465. var beforeRead = "beforeRead";
  4466. var read = "read";
  4467. var afterRead = "afterRead";
  4468. var beforeMain = "beforeMain";
  4469. var main = "main";
  4470. var afterMain = "afterMain";
  4471. var beforeWrite = "beforeWrite";
  4472. var write = "write";
  4473. var afterWrite = "afterWrite";
  4474. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  4475. function getNodeName(element) {
  4476. return element ? (element.nodeName || "").toLowerCase() : null;
  4477. }
  4478. function getWindow(node) {
  4479. if (node == null) {
  4480. return window;
  4481. }
  4482. if (node.toString() !== "[object Window]") {
  4483. var ownerDocument = node.ownerDocument;
  4484. return ownerDocument ? ownerDocument.defaultView || window : window;
  4485. }
  4486. return node;
  4487. }
  4488. function isElement$1(node) {
  4489. var OwnElement = getWindow(node).Element;
  4490. return node instanceof OwnElement || node instanceof Element;
  4491. }
  4492. function isHTMLElement(node) {
  4493. var OwnElement = getWindow(node).HTMLElement;
  4494. return node instanceof OwnElement || node instanceof HTMLElement;
  4495. }
  4496. function isShadowRoot(node) {
  4497. if (typeof ShadowRoot === "undefined") {
  4498. return false;
  4499. }
  4500. var OwnElement = getWindow(node).ShadowRoot;
  4501. return node instanceof OwnElement || node instanceof ShadowRoot;
  4502. }
  4503. function applyStyles(_ref) {
  4504. var state = _ref.state;
  4505. Object.keys(state.elements).forEach(function(name) {
  4506. var style = state.styles[name] || {};
  4507. var attributes = state.attributes[name] || {};
  4508. var element = state.elements[name];
  4509. if (!isHTMLElement(element) || !getNodeName(element)) {
  4510. return;
  4511. }
  4512. Object.assign(element.style, style);
  4513. Object.keys(attributes).forEach(function(name2) {
  4514. var value = attributes[name2];
  4515. if (value === false) {
  4516. element.removeAttribute(name2);
  4517. } else {
  4518. element.setAttribute(name2, value === true ? "" : value);
  4519. }
  4520. });
  4521. });
  4522. }
  4523. function effect$2(_ref2) {
  4524. var state = _ref2.state;
  4525. var initialStyles = {
  4526. popper: {
  4527. position: state.options.strategy,
  4528. left: "0",
  4529. top: "0",
  4530. margin: "0"
  4531. },
  4532. arrow: {
  4533. position: "absolute"
  4534. },
  4535. reference: {}
  4536. };
  4537. Object.assign(state.elements.popper.style, initialStyles.popper);
  4538. state.styles = initialStyles;
  4539. if (state.elements.arrow) {
  4540. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  4541. }
  4542. return function() {
  4543. Object.keys(state.elements).forEach(function(name) {
  4544. var element = state.elements[name];
  4545. var attributes = state.attributes[name] || {};
  4546. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
  4547. var style = styleProperties.reduce(function(style2, property) {
  4548. style2[property] = "";
  4549. return style2;
  4550. }, {});
  4551. if (!isHTMLElement(element) || !getNodeName(element)) {
  4552. return;
  4553. }
  4554. Object.assign(element.style, style);
  4555. Object.keys(attributes).forEach(function(attribute) {
  4556. element.removeAttribute(attribute);
  4557. });
  4558. });
  4559. };
  4560. }
  4561. const applyStyles$1 = {
  4562. name: "applyStyles",
  4563. enabled: true,
  4564. phase: "write",
  4565. fn: applyStyles,
  4566. effect: effect$2,
  4567. requires: ["computeStyles"]
  4568. };
  4569. function getBasePlacement$1(placement) {
  4570. return placement.split("-")[0];
  4571. }
  4572. var max = Math.max;
  4573. var min = Math.min;
  4574. var round = Math.round;
  4575. function getUAString() {
  4576. var uaData = navigator.userAgentData;
  4577. if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
  4578. return uaData.brands.map(function(item) {
  4579. return item.brand + "/" + item.version;
  4580. }).join(" ");
  4581. }
  4582. return navigator.userAgent;
  4583. }
  4584. function isLayoutViewport() {
  4585. return !/^((?!chrome|android).)*safari/i.test(getUAString());
  4586. }
  4587. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  4588. if (includeScale === void 0) {
  4589. includeScale = false;
  4590. }
  4591. if (isFixedStrategy === void 0) {
  4592. isFixedStrategy = false;
  4593. }
  4594. var clientRect = element.getBoundingClientRect();
  4595. var scaleX = 1;
  4596. var scaleY = 1;
  4597. if (includeScale && isHTMLElement(element)) {
  4598. scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
  4599. scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
  4600. }
  4601. var _ref = isElement$1(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
  4602. var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
  4603. var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
  4604. var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
  4605. var width = clientRect.width / scaleX;
  4606. var height = clientRect.height / scaleY;
  4607. return {
  4608. width,
  4609. height,
  4610. top: y,
  4611. right: x + width,
  4612. bottom: y + height,
  4613. left: x,
  4614. x,
  4615. y
  4616. };
  4617. }
  4618. function getLayoutRect(element) {
  4619. var clientRect = getBoundingClientRect(element);
  4620. var width = element.offsetWidth;
  4621. var height = element.offsetHeight;
  4622. if (Math.abs(clientRect.width - width) <= 1) {
  4623. width = clientRect.width;
  4624. }
  4625. if (Math.abs(clientRect.height - height) <= 1) {
  4626. height = clientRect.height;
  4627. }
  4628. return {
  4629. x: element.offsetLeft,
  4630. y: element.offsetTop,
  4631. width,
  4632. height
  4633. };
  4634. }
  4635. function contains(parent, child) {
  4636. var rootNode = child.getRootNode && child.getRootNode();
  4637. if (parent.contains(child)) {
  4638. return true;
  4639. } else if (rootNode && isShadowRoot(rootNode)) {
  4640. var next = child;
  4641. do {
  4642. if (next && parent.isSameNode(next)) {
  4643. return true;
  4644. }
  4645. next = next.parentNode || next.host;
  4646. } while (next);
  4647. }
  4648. return false;
  4649. }
  4650. function getComputedStyle(element) {
  4651. return getWindow(element).getComputedStyle(element);
  4652. }
  4653. function isTableElement(element) {
  4654. return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
  4655. }
  4656. function getDocumentElement(element) {
  4657. return ((isElement$1(element) ? element.ownerDocument : (
  4658. // $FlowFixMe[prop-missing]
  4659. element.document
  4660. )) || window.document).documentElement;
  4661. }
  4662. function getParentNode(element) {
  4663. if (getNodeName(element) === "html") {
  4664. return element;
  4665. }
  4666. return (
  4667. // this is a quicker (but less type safe) way to save quite some bytes from the bundle
  4668. // $FlowFixMe[incompatible-return]
  4669. // $FlowFixMe[prop-missing]
  4670. element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
  4671. element.parentNode || // DOM Element detected
  4672. (isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
  4673. // $FlowFixMe[incompatible-call]: HTMLElement is a Node
  4674. getDocumentElement(element)
  4675. );
  4676. }
  4677. function getTrueOffsetParent(element) {
  4678. if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
  4679. getComputedStyle(element).position === "fixed") {
  4680. return null;
  4681. }
  4682. return element.offsetParent;
  4683. }
  4684. function getContainingBlock(element) {
  4685. var isFirefox = /firefox/i.test(getUAString());
  4686. var isIE = /Trident/i.test(getUAString());
  4687. if (isIE && isHTMLElement(element)) {
  4688. var elementCss = getComputedStyle(element);
  4689. if (elementCss.position === "fixed") {
  4690. return null;
  4691. }
  4692. }
  4693. var currentNode = getParentNode(element);
  4694. if (isShadowRoot(currentNode)) {
  4695. currentNode = currentNode.host;
  4696. }
  4697. while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
  4698. var css = getComputedStyle(currentNode);
  4699. 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") {
  4700. return currentNode;
  4701. } else {
  4702. currentNode = currentNode.parentNode;
  4703. }
  4704. }
  4705. return null;
  4706. }
  4707. function getOffsetParent(element) {
  4708. var window2 = getWindow(element);
  4709. var offsetParent = getTrueOffsetParent(element);
  4710. while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
  4711. offsetParent = getTrueOffsetParent(offsetParent);
  4712. }
  4713. if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static")) {
  4714. return window2;
  4715. }
  4716. return offsetParent || getContainingBlock(element) || window2;
  4717. }
  4718. function getMainAxisFromPlacement(placement) {
  4719. return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
  4720. }
  4721. function within(min$1, value, max$1) {
  4722. return max(min$1, min(value, max$1));
  4723. }
  4724. function withinMaxClamp(min2, value, max2) {
  4725. var v = within(min2, value, max2);
  4726. return v > max2 ? max2 : v;
  4727. }
  4728. function getFreshSideObject() {
  4729. return {
  4730. top: 0,
  4731. right: 0,
  4732. bottom: 0,
  4733. left: 0
  4734. };
  4735. }
  4736. function mergePaddingObject(paddingObject) {
  4737. return Object.assign({}, getFreshSideObject(), paddingObject);
  4738. }
  4739. function expandToHashMap(value, keys) {
  4740. return keys.reduce(function(hashMap, key) {
  4741. hashMap[key] = value;
  4742. return hashMap;
  4743. }, {});
  4744. }
  4745. var toPaddingObject = function toPaddingObject2(padding, state) {
  4746. padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
  4747. placement: state.placement
  4748. })) : padding;
  4749. return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
  4750. };
  4751. function arrow(_ref) {
  4752. var _state$modifiersData$;
  4753. var state = _ref.state, name = _ref.name, options = _ref.options;
  4754. var arrowElement = state.elements.arrow;
  4755. var popperOffsets2 = state.modifiersData.popperOffsets;
  4756. var basePlacement = getBasePlacement$1(state.placement);
  4757. var axis = getMainAxisFromPlacement(basePlacement);
  4758. var isVertical = [left, right].indexOf(basePlacement) >= 0;
  4759. var len = isVertical ? "height" : "width";
  4760. if (!arrowElement || !popperOffsets2) {
  4761. return;
  4762. }
  4763. var paddingObject = toPaddingObject(options.padding, state);
  4764. var arrowRect = getLayoutRect(arrowElement);
  4765. var minProp = axis === "y" ? top : left;
  4766. var maxProp = axis === "y" ? bottom : right;
  4767. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
  4768. var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
  4769. var arrowOffsetParent = getOffsetParent(arrowElement);
  4770. var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  4771. var centerToReference = endDiff / 2 - startDiff / 2;
  4772. var min2 = paddingObject[minProp];
  4773. var max2 = clientSize - arrowRect[len] - paddingObject[maxProp];
  4774. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  4775. var offset2 = within(min2, center, max2);
  4776. var axisProp = axis;
  4777. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset2, _state$modifiersData$.centerOffset = offset2 - center, _state$modifiersData$);
  4778. }
  4779. function effect$1(_ref2) {
  4780. var state = _ref2.state, options = _ref2.options;
  4781. var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
  4782. if (arrowElement == null) {
  4783. return;
  4784. }
  4785. if (typeof arrowElement === "string") {
  4786. arrowElement = state.elements.popper.querySelector(arrowElement);
  4787. if (!arrowElement) {
  4788. return;
  4789. }
  4790. }
  4791. if (!contains(state.elements.popper, arrowElement)) {
  4792. return;
  4793. }
  4794. state.elements.arrow = arrowElement;
  4795. }
  4796. const arrow$1 = {
  4797. name: "arrow",
  4798. enabled: true,
  4799. phase: "main",
  4800. fn: arrow,
  4801. effect: effect$1,
  4802. requires: ["popperOffsets"],
  4803. requiresIfExists: ["preventOverflow"]
  4804. };
  4805. function getVariation(placement) {
  4806. return placement.split("-")[1];
  4807. }
  4808. var unsetSides = {
  4809. top: "auto",
  4810. right: "auto",
  4811. bottom: "auto",
  4812. left: "auto"
  4813. };
  4814. function roundOffsetsByDPR(_ref, win) {
  4815. var x = _ref.x, y = _ref.y;
  4816. var dpr = win.devicePixelRatio || 1;
  4817. return {
  4818. x: round(x * dpr) / dpr || 0,
  4819. y: round(y * dpr) / dpr || 0
  4820. };
  4821. }
  4822. function mapToStyles(_ref2) {
  4823. var _Object$assign2;
  4824. 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;
  4825. 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;
  4826. var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
  4827. x,
  4828. y
  4829. }) : {
  4830. x,
  4831. y
  4832. };
  4833. x = _ref3.x;
  4834. y = _ref3.y;
  4835. var hasX = offsets.hasOwnProperty("x");
  4836. var hasY = offsets.hasOwnProperty("y");
  4837. var sideX = left;
  4838. var sideY = top;
  4839. var win = window;
  4840. if (adaptive) {
  4841. var offsetParent = getOffsetParent(popper2);
  4842. var heightProp = "clientHeight";
  4843. var widthProp = "clientWidth";
  4844. if (offsetParent === getWindow(popper2)) {
  4845. offsetParent = getDocumentElement(popper2);
  4846. if (getComputedStyle(offsetParent).position !== "static" && position === "absolute") {
  4847. heightProp = "scrollHeight";
  4848. widthProp = "scrollWidth";
  4849. }
  4850. }
  4851. offsetParent = offsetParent;
  4852. if (placement === top || (placement === left || placement === right) && variation === end) {
  4853. sideY = bottom;
  4854. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : (
  4855. // $FlowFixMe[prop-missing]
  4856. offsetParent[heightProp]
  4857. );
  4858. y -= offsetY - popperRect.height;
  4859. y *= gpuAcceleration ? 1 : -1;
  4860. }
  4861. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  4862. sideX = right;
  4863. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : (
  4864. // $FlowFixMe[prop-missing]
  4865. offsetParent[widthProp]
  4866. );
  4867. x -= offsetX - popperRect.width;
  4868. x *= gpuAcceleration ? 1 : -1;
  4869. }
  4870. }
  4871. var commonStyles = Object.assign({
  4872. position
  4873. }, adaptive && unsetSides);
  4874. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  4875. x,
  4876. y
  4877. }, getWindow(popper2)) : {
  4878. x,
  4879. y
  4880. };
  4881. x = _ref4.x;
  4882. y = _ref4.y;
  4883. if (gpuAcceleration) {
  4884. var _Object$assign;
  4885. 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));
  4886. }
  4887. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
  4888. }
  4889. function computeStyles(_ref5) {
  4890. var state = _ref5.state, options = _ref5.options;
  4891. 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;
  4892. var commonStyles = {
  4893. placement: getBasePlacement$1(state.placement),
  4894. variation: getVariation(state.placement),
  4895. popper: state.elements.popper,
  4896. popperRect: state.rects.popper,
  4897. gpuAcceleration,
  4898. isFixed: state.options.strategy === "fixed"
  4899. };
  4900. if (state.modifiersData.popperOffsets != null) {
  4901. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  4902. offsets: state.modifiersData.popperOffsets,
  4903. position: state.options.strategy,
  4904. adaptive,
  4905. roundOffsets
  4906. })));
  4907. }
  4908. if (state.modifiersData.arrow != null) {
  4909. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  4910. offsets: state.modifiersData.arrow,
  4911. position: "absolute",
  4912. adaptive: false,
  4913. roundOffsets
  4914. })));
  4915. }
  4916. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  4917. "data-popper-placement": state.placement
  4918. });
  4919. }
  4920. const computeStyles$1 = {
  4921. name: "computeStyles",
  4922. enabled: true,
  4923. phase: "beforeWrite",
  4924. fn: computeStyles,
  4925. data: {}
  4926. };
  4927. var passive = {
  4928. passive: true
  4929. };
  4930. function effect(_ref) {
  4931. var state = _ref.state, instance = _ref.instance, options = _ref.options;
  4932. 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;
  4933. var window2 = getWindow(state.elements.popper);
  4934. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  4935. if (scroll) {
  4936. scrollParents.forEach(function(scrollParent) {
  4937. scrollParent.addEventListener("scroll", instance.update, passive);
  4938. });
  4939. }
  4940. if (resize) {
  4941. window2.addEventListener("resize", instance.update, passive);
  4942. }
  4943. return function() {
  4944. if (scroll) {
  4945. scrollParents.forEach(function(scrollParent) {
  4946. scrollParent.removeEventListener("scroll", instance.update, passive);
  4947. });
  4948. }
  4949. if (resize) {
  4950. window2.removeEventListener("resize", instance.update, passive);
  4951. }
  4952. };
  4953. }
  4954. const eventListeners = {
  4955. name: "eventListeners",
  4956. enabled: true,
  4957. phase: "write",
  4958. fn: function fn() {
  4959. },
  4960. effect,
  4961. data: {}
  4962. };
  4963. var hash$1 = {
  4964. left: "right",
  4965. right: "left",
  4966. bottom: "top",
  4967. top: "bottom"
  4968. };
  4969. function getOppositePlacement(placement) {
  4970. return placement.replace(/left|right|bottom|top/g, function(matched) {
  4971. return hash$1[matched];
  4972. });
  4973. }
  4974. var hash = {
  4975. start: "end",
  4976. end: "start"
  4977. };
  4978. function getOppositeVariationPlacement(placement) {
  4979. return placement.replace(/start|end/g, function(matched) {
  4980. return hash[matched];
  4981. });
  4982. }
  4983. function getWindowScroll(node) {
  4984. var win = getWindow(node);
  4985. var scrollLeft = win.pageXOffset;
  4986. var scrollTop = win.pageYOffset;
  4987. return {
  4988. scrollLeft,
  4989. scrollTop
  4990. };
  4991. }
  4992. function getWindowScrollBarX(element) {
  4993. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  4994. }
  4995. function getViewportRect(element, strategy) {
  4996. var win = getWindow(element);
  4997. var html = getDocumentElement(element);
  4998. var visualViewport = win.visualViewport;
  4999. var width = html.clientWidth;
  5000. var height = html.clientHeight;
  5001. var x = 0;
  5002. var y = 0;
  5003. if (visualViewport) {
  5004. width = visualViewport.width;
  5005. height = visualViewport.height;
  5006. var layoutViewport = isLayoutViewport();
  5007. if (layoutViewport || !layoutViewport && strategy === "fixed") {
  5008. x = visualViewport.offsetLeft;
  5009. y = visualViewport.offsetTop;
  5010. }
  5011. }
  5012. return {
  5013. width,
  5014. height,
  5015. x: x + getWindowScrollBarX(element),
  5016. y
  5017. };
  5018. }
  5019. function getDocumentRect(element) {
  5020. var _element$ownerDocumen;
  5021. var html = getDocumentElement(element);
  5022. var winScroll = getWindowScroll(element);
  5023. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  5024. var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  5025. var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  5026. var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
  5027. var y = -winScroll.scrollTop;
  5028. if (getComputedStyle(body || html).direction === "rtl") {
  5029. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  5030. }
  5031. return {
  5032. width,
  5033. height,
  5034. x,
  5035. y
  5036. };
  5037. }
  5038. function isScrollParent(element) {
  5039. var _getComputedStyle = getComputedStyle(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
  5040. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  5041. }
  5042. function getScrollParent(node) {
  5043. if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
  5044. return node.ownerDocument.body;
  5045. }
  5046. if (isHTMLElement(node) && isScrollParent(node)) {
  5047. return node;
  5048. }
  5049. return getScrollParent(getParentNode(node));
  5050. }
  5051. function listScrollParents(element, list) {
  5052. var _element$ownerDocumen;
  5053. if (list === void 0) {
  5054. list = [];
  5055. }
  5056. var scrollParent = getScrollParent(element);
  5057. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  5058. var win = getWindow(scrollParent);
  5059. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  5060. var updatedList = list.concat(target);
  5061. return isBody ? updatedList : (
  5062. // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
  5063. updatedList.concat(listScrollParents(getParentNode(target)))
  5064. );
  5065. }
  5066. function rectToClientRect(rect) {
  5067. return Object.assign({}, rect, {
  5068. left: rect.x,
  5069. top: rect.y,
  5070. right: rect.x + rect.width,
  5071. bottom: rect.y + rect.height
  5072. });
  5073. }
  5074. function getInnerBoundingClientRect(element, strategy) {
  5075. var rect = getBoundingClientRect(element, false, strategy === "fixed");
  5076. rect.top = rect.top + element.clientTop;
  5077. rect.left = rect.left + element.clientLeft;
  5078. rect.bottom = rect.top + element.clientHeight;
  5079. rect.right = rect.left + element.clientWidth;
  5080. rect.width = element.clientWidth;
  5081. rect.height = element.clientHeight;
  5082. rect.x = rect.left;
  5083. rect.y = rect.top;
  5084. return rect;
  5085. }
  5086. function getClientRectFromMixedType(element, clippingParent, strategy) {
  5087. return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
  5088. }
  5089. function getClippingParents(element) {
  5090. var clippingParents2 = listScrollParents(getParentNode(element));
  5091. var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle(element).position) >= 0;
  5092. var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
  5093. if (!isElement$1(clipperElement)) {
  5094. return [];
  5095. }
  5096. return clippingParents2.filter(function(clippingParent) {
  5097. return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
  5098. });
  5099. }
  5100. function getClippingRect(element, boundary, rootBoundary, strategy) {
  5101. var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
  5102. var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
  5103. var firstClippingParent = clippingParents2[0];
  5104. var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
  5105. var rect = getClientRectFromMixedType(element, clippingParent, strategy);
  5106. accRect.top = max(rect.top, accRect.top);
  5107. accRect.right = min(rect.right, accRect.right);
  5108. accRect.bottom = min(rect.bottom, accRect.bottom);
  5109. accRect.left = max(rect.left, accRect.left);
  5110. return accRect;
  5111. }, getClientRectFromMixedType(element, firstClippingParent, strategy));
  5112. clippingRect.width = clippingRect.right - clippingRect.left;
  5113. clippingRect.height = clippingRect.bottom - clippingRect.top;
  5114. clippingRect.x = clippingRect.left;
  5115. clippingRect.y = clippingRect.top;
  5116. return clippingRect;
  5117. }
  5118. function computeOffsets(_ref) {
  5119. var reference2 = _ref.reference, element = _ref.element, placement = _ref.placement;
  5120. var basePlacement = placement ? getBasePlacement$1(placement) : null;
  5121. var variation = placement ? getVariation(placement) : null;
  5122. var commonX = reference2.x + reference2.width / 2 - element.width / 2;
  5123. var commonY = reference2.y + reference2.height / 2 - element.height / 2;
  5124. var offsets;
  5125. switch (basePlacement) {
  5126. case top:
  5127. offsets = {
  5128. x: commonX,
  5129. y: reference2.y - element.height
  5130. };
  5131. break;
  5132. case bottom:
  5133. offsets = {
  5134. x: commonX,
  5135. y: reference2.y + reference2.height
  5136. };
  5137. break;
  5138. case right:
  5139. offsets = {
  5140. x: reference2.x + reference2.width,
  5141. y: commonY
  5142. };
  5143. break;
  5144. case left:
  5145. offsets = {
  5146. x: reference2.x - element.width,
  5147. y: commonY
  5148. };
  5149. break;
  5150. default:
  5151. offsets = {
  5152. x: reference2.x,
  5153. y: reference2.y
  5154. };
  5155. }
  5156. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  5157. if (mainAxis != null) {
  5158. var len = mainAxis === "y" ? "height" : "width";
  5159. switch (variation) {
  5160. case start:
  5161. offsets[mainAxis] = offsets[mainAxis] - (reference2[len] / 2 - element[len] / 2);
  5162. break;
  5163. case end:
  5164. offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element[len] / 2);
  5165. break;
  5166. }
  5167. }
  5168. return offsets;
  5169. }
  5170. function detectOverflow(state, options) {
  5171. if (options === void 0) {
  5172. options = {};
  5173. }
  5174. 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;
  5175. var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
  5176. var altContext = elementContext === popper ? reference : popper;
  5177. var popperRect = state.rects.popper;
  5178. var element = state.elements[altBoundary ? altContext : elementContext];
  5179. var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
  5180. var referenceClientRect = getBoundingClientRect(state.elements.reference);
  5181. var popperOffsets2 = computeOffsets({
  5182. reference: referenceClientRect,
  5183. element: popperRect,
  5184. strategy: "absolute",
  5185. placement
  5186. });
  5187. var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
  5188. var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
  5189. var overflowOffsets = {
  5190. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  5191. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  5192. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  5193. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  5194. };
  5195. var offsetData = state.modifiersData.offset;
  5196. if (elementContext === popper && offsetData) {
  5197. var offset2 = offsetData[placement];
  5198. Object.keys(overflowOffsets).forEach(function(key) {
  5199. var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
  5200. var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
  5201. overflowOffsets[key] += offset2[axis] * multiply;
  5202. });
  5203. }
  5204. return overflowOffsets;
  5205. }
  5206. function computeAutoPlacement(state, options) {
  5207. if (options === void 0) {
  5208. options = {};
  5209. }
  5210. 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;
  5211. var variation = getVariation(placement);
  5212. var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement2) {
  5213. return getVariation(placement2) === variation;
  5214. }) : basePlacements;
  5215. var allowedPlacements = placements$1.filter(function(placement2) {
  5216. return allowedAutoPlacements.indexOf(placement2) >= 0;
  5217. });
  5218. if (allowedPlacements.length === 0) {
  5219. allowedPlacements = placements$1;
  5220. }
  5221. var overflows = allowedPlacements.reduce(function(acc, placement2) {
  5222. acc[placement2] = detectOverflow(state, {
  5223. placement: placement2,
  5224. boundary,
  5225. rootBoundary,
  5226. padding
  5227. })[getBasePlacement$1(placement2)];
  5228. return acc;
  5229. }, {});
  5230. return Object.keys(overflows).sort(function(a, b) {
  5231. return overflows[a] - overflows[b];
  5232. });
  5233. }
  5234. function getExpandedFallbackPlacements(placement) {
  5235. if (getBasePlacement$1(placement) === auto) {
  5236. return [];
  5237. }
  5238. var oppositePlacement = getOppositePlacement(placement);
  5239. return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
  5240. }
  5241. function flip(_ref) {
  5242. var state = _ref.state, options = _ref.options, name = _ref.name;
  5243. if (state.modifiersData[name]._skip) {
  5244. return;
  5245. }
  5246. 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;
  5247. var preferredPlacement = state.options.placement;
  5248. var basePlacement = getBasePlacement$1(preferredPlacement);
  5249. var isBasePlacement = basePlacement === preferredPlacement;
  5250. var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
  5251. var placements2 = [preferredPlacement].concat(fallbackPlacements).reduce(function(acc, placement2) {
  5252. return acc.concat(getBasePlacement$1(placement2) === auto ? computeAutoPlacement(state, {
  5253. placement: placement2,
  5254. boundary,
  5255. rootBoundary,
  5256. padding,
  5257. flipVariations,
  5258. allowedAutoPlacements
  5259. }) : placement2);
  5260. }, []);
  5261. var referenceRect = state.rects.reference;
  5262. var popperRect = state.rects.popper;
  5263. var checksMap = /* @__PURE__ */ new Map();
  5264. var makeFallbackChecks = true;
  5265. var firstFittingPlacement = placements2[0];
  5266. for (var i = 0; i < placements2.length; i++) {
  5267. var placement = placements2[i];
  5268. var _basePlacement = getBasePlacement$1(placement);
  5269. var isStartVariation = getVariation(placement) === start;
  5270. var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
  5271. var len = isVertical ? "width" : "height";
  5272. var overflow = detectOverflow(state, {
  5273. placement,
  5274. boundary,
  5275. rootBoundary,
  5276. altBoundary,
  5277. padding
  5278. });
  5279. var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
  5280. if (referenceRect[len] > popperRect[len]) {
  5281. mainVariationSide = getOppositePlacement(mainVariationSide);
  5282. }
  5283. var altVariationSide = getOppositePlacement(mainVariationSide);
  5284. var checks = [];
  5285. if (checkMainAxis) {
  5286. checks.push(overflow[_basePlacement] <= 0);
  5287. }
  5288. if (checkAltAxis) {
  5289. checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
  5290. }
  5291. if (checks.every(function(check) {
  5292. return check;
  5293. })) {
  5294. firstFittingPlacement = placement;
  5295. makeFallbackChecks = false;
  5296. break;
  5297. }
  5298. checksMap.set(placement, checks);
  5299. }
  5300. if (makeFallbackChecks) {
  5301. var numberOfChecks = flipVariations ? 3 : 1;
  5302. var _loop = function _loop2(_i2) {
  5303. var fittingPlacement = placements2.find(function(placement2) {
  5304. var checks2 = checksMap.get(placement2);
  5305. if (checks2) {
  5306. return checks2.slice(0, _i2).every(function(check) {
  5307. return check;
  5308. });
  5309. }
  5310. });
  5311. if (fittingPlacement) {
  5312. firstFittingPlacement = fittingPlacement;
  5313. return "break";
  5314. }
  5315. };
  5316. for (var _i = numberOfChecks; _i > 0; _i--) {
  5317. var _ret = _loop(_i);
  5318. if (_ret === "break") break;
  5319. }
  5320. }
  5321. if (state.placement !== firstFittingPlacement) {
  5322. state.modifiersData[name]._skip = true;
  5323. state.placement = firstFittingPlacement;
  5324. state.reset = true;
  5325. }
  5326. }
  5327. const flip$1 = {
  5328. name: "flip",
  5329. enabled: true,
  5330. phase: "main",
  5331. fn: flip,
  5332. requiresIfExists: ["offset"],
  5333. data: {
  5334. _skip: false
  5335. }
  5336. };
  5337. function getSideOffsets(overflow, rect, preventedOffsets) {
  5338. if (preventedOffsets === void 0) {
  5339. preventedOffsets = {
  5340. x: 0,
  5341. y: 0
  5342. };
  5343. }
  5344. return {
  5345. top: overflow.top - rect.height - preventedOffsets.y,
  5346. right: overflow.right - rect.width + preventedOffsets.x,
  5347. bottom: overflow.bottom - rect.height + preventedOffsets.y,
  5348. left: overflow.left - rect.width - preventedOffsets.x
  5349. };
  5350. }
  5351. function isAnySideFullyClipped(overflow) {
  5352. return [top, right, bottom, left].some(function(side) {
  5353. return overflow[side] >= 0;
  5354. });
  5355. }
  5356. function hide(_ref) {
  5357. var state = _ref.state, name = _ref.name;
  5358. var referenceRect = state.rects.reference;
  5359. var popperRect = state.rects.popper;
  5360. var preventedOffsets = state.modifiersData.preventOverflow;
  5361. var referenceOverflow = detectOverflow(state, {
  5362. elementContext: "reference"
  5363. });
  5364. var popperAltOverflow = detectOverflow(state, {
  5365. altBoundary: true
  5366. });
  5367. var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
  5368. var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
  5369. var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
  5370. var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
  5371. state.modifiersData[name] = {
  5372. referenceClippingOffsets,
  5373. popperEscapeOffsets,
  5374. isReferenceHidden,
  5375. hasPopperEscaped
  5376. };
  5377. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  5378. "data-popper-reference-hidden": isReferenceHidden,
  5379. "data-popper-escaped": hasPopperEscaped
  5380. });
  5381. }
  5382. const hide$1 = {
  5383. name: "hide",
  5384. enabled: true,
  5385. phase: "main",
  5386. requiresIfExists: ["preventOverflow"],
  5387. fn: hide
  5388. };
  5389. function distanceAndSkiddingToXY(placement, rects, offset2) {
  5390. var basePlacement = getBasePlacement$1(placement);
  5391. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  5392. var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
  5393. placement
  5394. })) : offset2, skidding = _ref[0], distance = _ref[1];
  5395. skidding = skidding || 0;
  5396. distance = (distance || 0) * invertDistance;
  5397. return [left, right].indexOf(basePlacement) >= 0 ? {
  5398. x: distance,
  5399. y: skidding
  5400. } : {
  5401. x: skidding,
  5402. y: distance
  5403. };
  5404. }
  5405. function offset(_ref2) {
  5406. var state = _ref2.state, options = _ref2.options, name = _ref2.name;
  5407. var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
  5408. var data = placements.reduce(function(acc, placement) {
  5409. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
  5410. return acc;
  5411. }, {});
  5412. var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
  5413. if (state.modifiersData.popperOffsets != null) {
  5414. state.modifiersData.popperOffsets.x += x;
  5415. state.modifiersData.popperOffsets.y += y;
  5416. }
  5417. state.modifiersData[name] = data;
  5418. }
  5419. const offset$1 = {
  5420. name: "offset",
  5421. enabled: true,
  5422. phase: "main",
  5423. requires: ["popperOffsets"],
  5424. fn: offset
  5425. };
  5426. function popperOffsets(_ref) {
  5427. var state = _ref.state, name = _ref.name;
  5428. state.modifiersData[name] = computeOffsets({
  5429. reference: state.rects.reference,
  5430. element: state.rects.popper,
  5431. strategy: "absolute",
  5432. placement: state.placement
  5433. });
  5434. }
  5435. const popperOffsets$1 = {
  5436. name: "popperOffsets",
  5437. enabled: true,
  5438. phase: "read",
  5439. fn: popperOffsets,
  5440. data: {}
  5441. };
  5442. function getAltAxis(axis) {
  5443. return axis === "x" ? "y" : "x";
  5444. }
  5445. function preventOverflow(_ref) {
  5446. var state = _ref.state, options = _ref.options, name = _ref.name;
  5447. 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;
  5448. var overflow = detectOverflow(state, {
  5449. boundary,
  5450. rootBoundary,
  5451. padding,
  5452. altBoundary
  5453. });
  5454. var basePlacement = getBasePlacement$1(state.placement);
  5455. var variation = getVariation(state.placement);
  5456. var isBasePlacement = !variation;
  5457. var mainAxis = getMainAxisFromPlacement(basePlacement);
  5458. var altAxis = getAltAxis(mainAxis);
  5459. var popperOffsets2 = state.modifiersData.popperOffsets;
  5460. var referenceRect = state.rects.reference;
  5461. var popperRect = state.rects.popper;
  5462. var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
  5463. placement: state.placement
  5464. })) : tetherOffset;
  5465. var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
  5466. mainAxis: tetherOffsetValue,
  5467. altAxis: tetherOffsetValue
  5468. } : Object.assign({
  5469. mainAxis: 0,
  5470. altAxis: 0
  5471. }, tetherOffsetValue);
  5472. var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
  5473. var data = {
  5474. x: 0,
  5475. y: 0
  5476. };
  5477. if (!popperOffsets2) {
  5478. return;
  5479. }
  5480. if (checkMainAxis) {
  5481. var _offsetModifierState$;
  5482. var mainSide = mainAxis === "y" ? top : left;
  5483. var altSide = mainAxis === "y" ? bottom : right;
  5484. var len = mainAxis === "y" ? "height" : "width";
  5485. var offset2 = popperOffsets2[mainAxis];
  5486. var min$1 = offset2 + overflow[mainSide];
  5487. var max$1 = offset2 - overflow[altSide];
  5488. var additive = tether ? -popperRect[len] / 2 : 0;
  5489. var minLen = variation === start ? referenceRect[len] : popperRect[len];
  5490. var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
  5491. var arrowElement = state.elements.arrow;
  5492. var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
  5493. width: 0,
  5494. height: 0
  5495. };
  5496. var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
  5497. var arrowPaddingMin = arrowPaddingObject[mainSide];
  5498. var arrowPaddingMax = arrowPaddingObject[altSide];
  5499. var arrowLen = within(0, referenceRect[len], arrowRect[len]);
  5500. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
  5501. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
  5502. var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
  5503. var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  5504. var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
  5505. var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
  5506. var tetherMax = offset2 + maxOffset - offsetModifierValue;
  5507. var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset2, tether ? max(max$1, tetherMax) : max$1);
  5508. popperOffsets2[mainAxis] = preventedOffset;
  5509. data[mainAxis] = preventedOffset - offset2;
  5510. }
  5511. if (checkAltAxis) {
  5512. var _offsetModifierState$2;
  5513. var _mainSide = mainAxis === "x" ? top : left;
  5514. var _altSide = mainAxis === "x" ? bottom : right;
  5515. var _offset = popperOffsets2[altAxis];
  5516. var _len = altAxis === "y" ? "height" : "width";
  5517. var _min = _offset + overflow[_mainSide];
  5518. var _max = _offset - overflow[_altSide];
  5519. var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
  5520. var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
  5521. var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
  5522. var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
  5523. var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
  5524. popperOffsets2[altAxis] = _preventedOffset;
  5525. data[altAxis] = _preventedOffset - _offset;
  5526. }
  5527. state.modifiersData[name] = data;
  5528. }
  5529. const preventOverflow$1 = {
  5530. name: "preventOverflow",
  5531. enabled: true,
  5532. phase: "main",
  5533. fn: preventOverflow,
  5534. requiresIfExists: ["offset"]
  5535. };
  5536. function getHTMLElementScroll(element) {
  5537. return {
  5538. scrollLeft: element.scrollLeft,
  5539. scrollTop: element.scrollTop
  5540. };
  5541. }
  5542. function getNodeScroll(node) {
  5543. if (node === getWindow(node) || !isHTMLElement(node)) {
  5544. return getWindowScroll(node);
  5545. } else {
  5546. return getHTMLElementScroll(node);
  5547. }
  5548. }
  5549. function isElementScaled(element) {
  5550. var rect = element.getBoundingClientRect();
  5551. var scaleX = round(rect.width) / element.offsetWidth || 1;
  5552. var scaleY = round(rect.height) / element.offsetHeight || 1;
  5553. return scaleX !== 1 || scaleY !== 1;
  5554. }
  5555. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  5556. if (isFixed === void 0) {
  5557. isFixed = false;
  5558. }
  5559. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  5560. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  5561. var documentElement = getDocumentElement(offsetParent);
  5562. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
  5563. var scroll = {
  5564. scrollLeft: 0,
  5565. scrollTop: 0
  5566. };
  5567. var offsets = {
  5568. x: 0,
  5569. y: 0
  5570. };
  5571. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  5572. if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
  5573. isScrollParent(documentElement)) {
  5574. scroll = getNodeScroll(offsetParent);
  5575. }
  5576. if (isHTMLElement(offsetParent)) {
  5577. offsets = getBoundingClientRect(offsetParent, true);
  5578. offsets.x += offsetParent.clientLeft;
  5579. offsets.y += offsetParent.clientTop;
  5580. } else if (documentElement) {
  5581. offsets.x = getWindowScrollBarX(documentElement);
  5582. }
  5583. }
  5584. return {
  5585. x: rect.left + scroll.scrollLeft - offsets.x,
  5586. y: rect.top + scroll.scrollTop - offsets.y,
  5587. width: rect.width,
  5588. height: rect.height
  5589. };
  5590. }
  5591. function order(modifiers) {
  5592. var map = /* @__PURE__ */ new Map();
  5593. var visited = /* @__PURE__ */ new Set();
  5594. var result = [];
  5595. modifiers.forEach(function(modifier) {
  5596. map.set(modifier.name, modifier);
  5597. });
  5598. function sort(modifier) {
  5599. visited.add(modifier.name);
  5600. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  5601. requires.forEach(function(dep) {
  5602. if (!visited.has(dep)) {
  5603. var depModifier = map.get(dep);
  5604. if (depModifier) {
  5605. sort(depModifier);
  5606. }
  5607. }
  5608. });
  5609. result.push(modifier);
  5610. }
  5611. modifiers.forEach(function(modifier) {
  5612. if (!visited.has(modifier.name)) {
  5613. sort(modifier);
  5614. }
  5615. });
  5616. return result;
  5617. }
  5618. function orderModifiers(modifiers) {
  5619. var orderedModifiers = order(modifiers);
  5620. return modifierPhases.reduce(function(acc, phase) {
  5621. return acc.concat(orderedModifiers.filter(function(modifier) {
  5622. return modifier.phase === phase;
  5623. }));
  5624. }, []);
  5625. }
  5626. function debounce$1(fn2) {
  5627. var pending;
  5628. return function() {
  5629. if (!pending) {
  5630. pending = new Promise(function(resolve) {
  5631. Promise.resolve().then(function() {
  5632. pending = void 0;
  5633. resolve(fn2());
  5634. });
  5635. });
  5636. }
  5637. return pending;
  5638. };
  5639. }
  5640. function mergeByName(modifiers) {
  5641. var merged = modifiers.reduce(function(merged2, current) {
  5642. var existing = merged2[current.name];
  5643. merged2[current.name] = existing ? Object.assign({}, existing, current, {
  5644. options: Object.assign({}, existing.options, current.options),
  5645. data: Object.assign({}, existing.data, current.data)
  5646. }) : current;
  5647. return merged2;
  5648. }, {});
  5649. return Object.keys(merged).map(function(key) {
  5650. return merged[key];
  5651. });
  5652. }
  5653. var DEFAULT_OPTIONS = {
  5654. placement: "bottom",
  5655. modifiers: [],
  5656. strategy: "absolute"
  5657. };
  5658. function areValidElements() {
  5659. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5660. args[_key] = arguments[_key];
  5661. }
  5662. return !args.some(function(element) {
  5663. return !(element && typeof element.getBoundingClientRect === "function");
  5664. });
  5665. }
  5666. function popperGenerator(generatorOptions) {
  5667. if (generatorOptions === void 0) {
  5668. generatorOptions = {};
  5669. }
  5670. 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;
  5671. return function createPopper2(reference2, popper2, options) {
  5672. if (options === void 0) {
  5673. options = defaultOptions;
  5674. }
  5675. var state = {
  5676. placement: "bottom",
  5677. orderedModifiers: [],
  5678. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  5679. modifiersData: {},
  5680. elements: {
  5681. reference: reference2,
  5682. popper: popper2
  5683. },
  5684. attributes: {},
  5685. styles: {}
  5686. };
  5687. var effectCleanupFns = [];
  5688. var isDestroyed = false;
  5689. var instance = {
  5690. state,
  5691. setOptions: function setOptions(setOptionsAction) {
  5692. var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
  5693. cleanupModifierEffects();
  5694. state.options = Object.assign({}, defaultOptions, state.options, options2);
  5695. state.scrollParents = {
  5696. reference: isElement$1(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
  5697. popper: listScrollParents(popper2)
  5698. };
  5699. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
  5700. state.orderedModifiers = orderedModifiers.filter(function(m) {
  5701. return m.enabled;
  5702. });
  5703. runModifierEffects();
  5704. return instance.update();
  5705. },
  5706. // Sync update – it will always be executed, even if not necessary. This
  5707. // is useful for low frequency updates where sync behavior simplifies the
  5708. // logic.
  5709. // For high frequency updates (e.g. `resize` and `scroll` events), always
  5710. // prefer the async Popper#update method
  5711. forceUpdate: function forceUpdate() {
  5712. if (isDestroyed) {
  5713. return;
  5714. }
  5715. var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper;
  5716. if (!areValidElements(reference3, popper3)) {
  5717. return;
  5718. }
  5719. state.rects = {
  5720. reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
  5721. popper: getLayoutRect(popper3)
  5722. };
  5723. state.reset = false;
  5724. state.placement = state.options.placement;
  5725. state.orderedModifiers.forEach(function(modifier) {
  5726. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  5727. });
  5728. for (var index = 0; index < state.orderedModifiers.length; index++) {
  5729. if (state.reset === true) {
  5730. state.reset = false;
  5731. index = -1;
  5732. continue;
  5733. }
  5734. 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;
  5735. if (typeof fn2 === "function") {
  5736. state = fn2({
  5737. state,
  5738. options: _options,
  5739. name,
  5740. instance
  5741. }) || state;
  5742. }
  5743. }
  5744. },
  5745. // Async and optimistically optimized update – it will not be executed if
  5746. // not necessary (debounced to run at most once-per-tick)
  5747. update: debounce$1(function() {
  5748. return new Promise(function(resolve) {
  5749. instance.forceUpdate();
  5750. resolve(state);
  5751. });
  5752. }),
  5753. destroy: function destroy() {
  5754. cleanupModifierEffects();
  5755. isDestroyed = true;
  5756. }
  5757. };
  5758. if (!areValidElements(reference2, popper2)) {
  5759. return instance;
  5760. }
  5761. instance.setOptions(options).then(function(state2) {
  5762. if (!isDestroyed && options.onFirstUpdate) {
  5763. options.onFirstUpdate(state2);
  5764. }
  5765. });
  5766. function runModifierEffects() {
  5767. state.orderedModifiers.forEach(function(_ref) {
  5768. var name = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect3 = _ref.effect;
  5769. if (typeof effect3 === "function") {
  5770. var cleanupFn = effect3({
  5771. state,
  5772. name,
  5773. instance,
  5774. options: options2
  5775. });
  5776. var noopFn = function noopFn2() {
  5777. };
  5778. effectCleanupFns.push(cleanupFn || noopFn);
  5779. }
  5780. });
  5781. }
  5782. function cleanupModifierEffects() {
  5783. effectCleanupFns.forEach(function(fn2) {
  5784. return fn2();
  5785. });
  5786. effectCleanupFns = [];
  5787. }
  5788. return instance;
  5789. };
  5790. }
  5791. var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
  5792. var createPopper = /* @__PURE__ */ popperGenerator({
  5793. defaultModifiers
  5794. });
  5795. var BOX_CLASS = "tippy-box";
  5796. var CONTENT_CLASS = "tippy-content";
  5797. var BACKDROP_CLASS = "tippy-backdrop";
  5798. var ARROW_CLASS = "tippy-arrow";
  5799. var SVG_ARROW_CLASS = "tippy-svg-arrow";
  5800. var TOUCH_OPTIONS = {
  5801. passive: true,
  5802. capture: true
  5803. };
  5804. var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO2() {
  5805. return document.body;
  5806. };
  5807. function getValueAtIndexOrReturn(value, index, defaultValue) {
  5808. if (Array.isArray(value)) {
  5809. var v = value[index];
  5810. return v == null ? Array.isArray(defaultValue) ? defaultValue[index] : defaultValue : v;
  5811. }
  5812. return value;
  5813. }
  5814. function isType(value, type) {
  5815. var str = {}.toString.call(value);
  5816. return str.indexOf("[object") === 0 && str.indexOf(type + "]") > -1;
  5817. }
  5818. function invokeWithArgsOrReturn(value, args) {
  5819. return typeof value === "function" ? value.apply(void 0, args) : value;
  5820. }
  5821. function debounce(fn5, ms) {
  5822. if (ms === 0) {
  5823. return fn5;
  5824. }
  5825. var timeout;
  5826. return function(arg) {
  5827. clearTimeout(timeout);
  5828. timeout = setTimeout(function() {
  5829. fn5(arg);
  5830. }, ms);
  5831. };
  5832. }
  5833. function splitBySpaces(value) {
  5834. return value.split(/\s+/).filter(Boolean);
  5835. }
  5836. function normalizeToArray(value) {
  5837. return [].concat(value);
  5838. }
  5839. function pushIfUnique(arr, value) {
  5840. if (arr.indexOf(value) === -1) {
  5841. arr.push(value);
  5842. }
  5843. }
  5844. function unique(arr) {
  5845. return arr.filter(function(item, index) {
  5846. return arr.indexOf(item) === index;
  5847. });
  5848. }
  5849. function getBasePlacement(placement) {
  5850. return placement.split("-")[0];
  5851. }
  5852. function arrayFrom(value) {
  5853. return [].slice.call(value);
  5854. }
  5855. function removeUndefinedProps(obj) {
  5856. return Object.keys(obj).reduce(function(acc, key) {
  5857. if (obj[key] !== void 0) {
  5858. acc[key] = obj[key];
  5859. }
  5860. return acc;
  5861. }, {});
  5862. }
  5863. function div() {
  5864. return document.createElement("div");
  5865. }
  5866. function isElement(value) {
  5867. return ["Element", "Fragment"].some(function(type) {
  5868. return isType(value, type);
  5869. });
  5870. }
  5871. function isNodeList(value) {
  5872. return isType(value, "NodeList");
  5873. }
  5874. function isMouseEvent(value) {
  5875. return isType(value, "MouseEvent");
  5876. }
  5877. function isReferenceElement(value) {
  5878. return !!(value && value._tippy && value._tippy.reference === value);
  5879. }
  5880. function getArrayOfElements(value) {
  5881. if (isElement(value)) {
  5882. return [value];
  5883. }
  5884. if (isNodeList(value)) {
  5885. return arrayFrom(value);
  5886. }
  5887. if (Array.isArray(value)) {
  5888. return value;
  5889. }
  5890. return arrayFrom(document.querySelectorAll(value));
  5891. }
  5892. function setTransitionDuration(els, value) {
  5893. els.forEach(function(el) {
  5894. if (el) {
  5895. el.style.transitionDuration = value + "ms";
  5896. }
  5897. });
  5898. }
  5899. function setVisibilityState(els, state) {
  5900. els.forEach(function(el) {
  5901. if (el) {
  5902. el.setAttribute("data-state", state);
  5903. }
  5904. });
  5905. }
  5906. function getOwnerDocument(elementOrElements) {
  5907. var _element$ownerDocumen;
  5908. var _normalizeToArray = normalizeToArray(elementOrElements), element = _normalizeToArray[0];
  5909. return element != null && (_element$ownerDocumen = element.ownerDocument) != null && _element$ownerDocumen.body ? element.ownerDocument : document;
  5910. }
  5911. function isCursorOutsideInteractiveBorder(popperTreeData, event) {
  5912. var clientX = event.clientX, clientY = event.clientY;
  5913. return popperTreeData.every(function(_ref) {
  5914. var popperRect = _ref.popperRect, popperState = _ref.popperState, props = _ref.props;
  5915. var interactiveBorder = props.interactiveBorder;
  5916. var basePlacement = getBasePlacement(popperState.placement);
  5917. var offsetData = popperState.modifiersData.offset;
  5918. if (!offsetData) {
  5919. return true;
  5920. }
  5921. var topDistance = basePlacement === "bottom" ? offsetData.top.y : 0;
  5922. var bottomDistance = basePlacement === "top" ? offsetData.bottom.y : 0;
  5923. var leftDistance = basePlacement === "right" ? offsetData.left.x : 0;
  5924. var rightDistance = basePlacement === "left" ? offsetData.right.x : 0;
  5925. var exceedsTop = popperRect.top - clientY + topDistance > interactiveBorder;
  5926. var exceedsBottom = clientY - popperRect.bottom - bottomDistance > interactiveBorder;
  5927. var exceedsLeft = popperRect.left - clientX + leftDistance > interactiveBorder;
  5928. var exceedsRight = clientX - popperRect.right - rightDistance > interactiveBorder;
  5929. return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight;
  5930. });
  5931. }
  5932. function updateTransitionEndListener(box, action, listener) {
  5933. var method = action + "EventListener";
  5934. ["transitionend", "webkitTransitionEnd"].forEach(function(event) {
  5935. box[method](event, listener);
  5936. });
  5937. }
  5938. function actualContains(parent, child) {
  5939. var target = child;
  5940. while (target) {
  5941. var _target$getRootNode;
  5942. if (parent.contains(target)) {
  5943. return true;
  5944. }
  5945. target = target.getRootNode == null ? void 0 : (_target$getRootNode = target.getRootNode()) == null ? void 0 : _target$getRootNode.host;
  5946. }
  5947. return false;
  5948. }
  5949. var currentInput = {
  5950. isTouch: false
  5951. };
  5952. var lastMouseMoveTime = 0;
  5953. function onDocumentTouchStart() {
  5954. if (currentInput.isTouch) {
  5955. return;
  5956. }
  5957. currentInput.isTouch = true;
  5958. if (window.performance) {
  5959. document.addEventListener("mousemove", onDocumentMouseMove);
  5960. }
  5961. }
  5962. function onDocumentMouseMove() {
  5963. var now = performance.now();
  5964. if (now - lastMouseMoveTime < 20) {
  5965. currentInput.isTouch = false;
  5966. document.removeEventListener("mousemove", onDocumentMouseMove);
  5967. }
  5968. lastMouseMoveTime = now;
  5969. }
  5970. function onWindowBlur() {
  5971. var activeElement = document.activeElement;
  5972. if (isReferenceElement(activeElement)) {
  5973. var instance = activeElement._tippy;
  5974. if (activeElement.blur && !instance.state.isVisible) {
  5975. activeElement.blur();
  5976. }
  5977. }
  5978. }
  5979. function bindGlobalEventListeners() {
  5980. document.addEventListener("touchstart", onDocumentTouchStart, TOUCH_OPTIONS);
  5981. window.addEventListener("blur", onWindowBlur);
  5982. }
  5983. var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
  5984. var isIE11 = isBrowser ? (
  5985. // @ts-ignore
  5986. !!window.msCrypto
  5987. ) : false;
  5988. var pluginProps = {
  5989. animateFill: false,
  5990. followCursor: false,
  5991. inlinePositioning: false,
  5992. sticky: false
  5993. };
  5994. var renderProps = {
  5995. allowHTML: false,
  5996. animation: "fade",
  5997. arrow: true,
  5998. content: "",
  5999. inertia: false,
  6000. maxWidth: 350,
  6001. role: "tooltip",
  6002. theme: "",
  6003. zIndex: 9999
  6004. };
  6005. var defaultProps = Object.assign({
  6006. appendTo: TIPPY_DEFAULT_APPEND_TO,
  6007. aria: {
  6008. content: "auto",
  6009. expanded: "auto"
  6010. },
  6011. delay: 0,
  6012. duration: [300, 250],
  6013. getReferenceClientRect: null,
  6014. hideOnClick: true,
  6015. ignoreAttributes: false,
  6016. interactive: false,
  6017. interactiveBorder: 2,
  6018. interactiveDebounce: 0,
  6019. moveTransition: "",
  6020. offset: [0, 10],
  6021. onAfterUpdate: function onAfterUpdate() {
  6022. },
  6023. onBeforeUpdate: function onBeforeUpdate() {
  6024. },
  6025. onCreate: function onCreate() {
  6026. },
  6027. onDestroy: function onDestroy() {
  6028. },
  6029. onHidden: function onHidden() {
  6030. },
  6031. onHide: function onHide() {
  6032. },
  6033. onMount: function onMount() {
  6034. },
  6035. onShow: function onShow() {
  6036. },
  6037. onShown: function onShown() {
  6038. },
  6039. onTrigger: function onTrigger() {
  6040. },
  6041. onUntrigger: function onUntrigger() {
  6042. },
  6043. onClickOutside: function onClickOutside() {
  6044. },
  6045. placement: "top",
  6046. plugins: [],
  6047. popperOptions: {},
  6048. render: null,
  6049. showOnCreate: false,
  6050. touch: true,
  6051. trigger: "mouseenter focus",
  6052. triggerTarget: null
  6053. }, pluginProps, renderProps);
  6054. var defaultKeys = Object.keys(defaultProps);
  6055. var setDefaultProps = function setDefaultProps2(partialProps) {
  6056. var keys = Object.keys(partialProps);
  6057. keys.forEach(function(key) {
  6058. defaultProps[key] = partialProps[key];
  6059. });
  6060. };
  6061. function getExtendedPassedProps(passedProps) {
  6062. var plugins = passedProps.plugins || [];
  6063. var pluginProps2 = plugins.reduce(function(acc, plugin) {
  6064. var name = plugin.name, defaultValue = plugin.defaultValue;
  6065. if (name) {
  6066. var _name;
  6067. acc[name] = passedProps[name] !== void 0 ? passedProps[name] : (_name = defaultProps[name]) != null ? _name : defaultValue;
  6068. }
  6069. return acc;
  6070. }, {});
  6071. return Object.assign({}, passedProps, pluginProps2);
  6072. }
  6073. function getDataAttributeProps(reference2, plugins) {
  6074. var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
  6075. plugins
  6076. }))) : defaultKeys;
  6077. var props = propKeys.reduce(function(acc, key) {
  6078. var valueAsString = (reference2.getAttribute("data-tippy-" + key) || "").trim();
  6079. if (!valueAsString) {
  6080. return acc;
  6081. }
  6082. if (key === "content") {
  6083. acc[key] = valueAsString;
  6084. } else {
  6085. try {
  6086. acc[key] = JSON.parse(valueAsString);
  6087. } catch (e) {
  6088. acc[key] = valueAsString;
  6089. }
  6090. }
  6091. return acc;
  6092. }, {});
  6093. return props;
  6094. }
  6095. function evaluateProps(reference2, props) {
  6096. var out = Object.assign({}, props, {
  6097. content: invokeWithArgsOrReturn(props.content, [reference2])
  6098. }, props.ignoreAttributes ? {} : getDataAttributeProps(reference2, props.plugins));
  6099. out.aria = Object.assign({}, defaultProps.aria, out.aria);
  6100. out.aria = {
  6101. expanded: out.aria.expanded === "auto" ? props.interactive : out.aria.expanded,
  6102. content: out.aria.content === "auto" ? props.interactive ? null : "describedby" : out.aria.content
  6103. };
  6104. return out;
  6105. }
  6106. var innerHTML = function innerHTML2() {
  6107. return "innerHTML";
  6108. };
  6109. function dangerouslySetInnerHTML(element, html) {
  6110. element[innerHTML()] = html;
  6111. }
  6112. function createArrowElement(value) {
  6113. var arrow2 = div();
  6114. if (value === true) {
  6115. arrow2.className = ARROW_CLASS;
  6116. } else {
  6117. arrow2.className = SVG_ARROW_CLASS;
  6118. if (isElement(value)) {
  6119. arrow2.appendChild(value);
  6120. } else {
  6121. dangerouslySetInnerHTML(arrow2, value);
  6122. }
  6123. }
  6124. return arrow2;
  6125. }
  6126. function setContent(content, props) {
  6127. if (isElement(props.content)) {
  6128. dangerouslySetInnerHTML(content, "");
  6129. content.appendChild(props.content);
  6130. } else if (typeof props.content !== "function") {
  6131. if (props.allowHTML) {
  6132. dangerouslySetInnerHTML(content, props.content);
  6133. } else {
  6134. content.textContent = props.content;
  6135. }
  6136. }
  6137. }
  6138. function getChildren(popper2) {
  6139. var box = popper2.firstElementChild;
  6140. var boxChildren = arrayFrom(box.children);
  6141. return {
  6142. box,
  6143. content: boxChildren.find(function(node) {
  6144. return node.classList.contains(CONTENT_CLASS);
  6145. }),
  6146. arrow: boxChildren.find(function(node) {
  6147. return node.classList.contains(ARROW_CLASS) || node.classList.contains(SVG_ARROW_CLASS);
  6148. }),
  6149. backdrop: boxChildren.find(function(node) {
  6150. return node.classList.contains(BACKDROP_CLASS);
  6151. })
  6152. };
  6153. }
  6154. function render(instance) {
  6155. var popper2 = div();
  6156. var box = div();
  6157. box.className = BOX_CLASS;
  6158. box.setAttribute("data-state", "hidden");
  6159. box.setAttribute("tabindex", "-1");
  6160. var content = div();
  6161. content.className = CONTENT_CLASS;
  6162. content.setAttribute("data-state", "hidden");
  6163. setContent(content, instance.props);
  6164. popper2.appendChild(box);
  6165. box.appendChild(content);
  6166. onUpdate(instance.props, instance.props);
  6167. function onUpdate(prevProps, nextProps) {
  6168. var _getChildren = getChildren(popper2), box2 = _getChildren.box, content2 = _getChildren.content, arrow2 = _getChildren.arrow;
  6169. if (nextProps.theme) {
  6170. box2.setAttribute("data-theme", nextProps.theme);
  6171. } else {
  6172. box2.removeAttribute("data-theme");
  6173. }
  6174. if (typeof nextProps.animation === "string") {
  6175. box2.setAttribute("data-animation", nextProps.animation);
  6176. } else {
  6177. box2.removeAttribute("data-animation");
  6178. }
  6179. if (nextProps.inertia) {
  6180. box2.setAttribute("data-inertia", "");
  6181. } else {
  6182. box2.removeAttribute("data-inertia");
  6183. }
  6184. box2.style.maxWidth = typeof nextProps.maxWidth === "number" ? nextProps.maxWidth + "px" : nextProps.maxWidth;
  6185. if (nextProps.role) {
  6186. box2.setAttribute("role", nextProps.role);
  6187. } else {
  6188. box2.removeAttribute("role");
  6189. }
  6190. if (prevProps.content !== nextProps.content || prevProps.allowHTML !== nextProps.allowHTML) {
  6191. setContent(content2, instance.props);
  6192. }
  6193. if (nextProps.arrow) {
  6194. if (!arrow2) {
  6195. box2.appendChild(createArrowElement(nextProps.arrow));
  6196. } else if (prevProps.arrow !== nextProps.arrow) {
  6197. box2.removeChild(arrow2);
  6198. box2.appendChild(createArrowElement(nextProps.arrow));
  6199. }
  6200. } else if (arrow2) {
  6201. box2.removeChild(arrow2);
  6202. }
  6203. }
  6204. return {
  6205. popper: popper2,
  6206. onUpdate
  6207. };
  6208. }
  6209. render.$$tippy = true;
  6210. var idCounter = 1;
  6211. var mouseMoveListeners = [];
  6212. var mountedInstances = [];
  6213. function createTippy(reference2, passedProps) {
  6214. var props = evaluateProps(reference2, Object.assign({}, defaultProps, getExtendedPassedProps(removeUndefinedProps(passedProps))));
  6215. var showTimeout;
  6216. var hideTimeout;
  6217. var scheduleHideAnimationFrame;
  6218. var isVisibleFromClick = false;
  6219. var didHideDueToDocumentMouseDown = false;
  6220. var didTouchMove = false;
  6221. var ignoreOnFirstUpdate = false;
  6222. var lastTriggerEvent;
  6223. var currentTransitionEndListener;
  6224. var onFirstUpdate;
  6225. var listeners = [];
  6226. var debouncedOnMouseMove = debounce(onMouseMove, props.interactiveDebounce);
  6227. var currentTarget;
  6228. var id = idCounter++;
  6229. var popperInstance = null;
  6230. var plugins = unique(props.plugins);
  6231. var state = {
  6232. // Is the instance currently enabled?
  6233. isEnabled: true,
  6234. // Is the tippy currently showing and not transitioning out?
  6235. isVisible: false,
  6236. // Has the instance been destroyed?
  6237. isDestroyed: false,
  6238. // Is the tippy currently mounted to the DOM?
  6239. isMounted: false,
  6240. // Has the tippy finished transitioning in?
  6241. isShown: false
  6242. };
  6243. var instance = {
  6244. // properties
  6245. id,
  6246. reference: reference2,
  6247. popper: div(),
  6248. popperInstance,
  6249. props,
  6250. state,
  6251. plugins,
  6252. // methods
  6253. clearDelayTimeouts,
  6254. setProps,
  6255. setContent: setContent2,
  6256. show,
  6257. hide: hide2,
  6258. hideWithInteractivity,
  6259. enable,
  6260. disable,
  6261. unmount,
  6262. destroy
  6263. };
  6264. if (!props.render) {
  6265. return instance;
  6266. }
  6267. var _props$render = props.render(instance), popper2 = _props$render.popper, onUpdate = _props$render.onUpdate;
  6268. popper2.setAttribute("data-tippy-root", "");
  6269. popper2.id = "tippy-" + instance.id;
  6270. instance.popper = popper2;
  6271. reference2._tippy = instance;
  6272. popper2._tippy = instance;
  6273. var pluginsHooks = plugins.map(function(plugin) {
  6274. return plugin.fn(instance);
  6275. });
  6276. var hasAriaExpanded = reference2.hasAttribute("aria-expanded");
  6277. addListeners();
  6278. handleAriaExpandedAttribute();
  6279. handleStyles();
  6280. invokeHook("onCreate", [instance]);
  6281. if (props.showOnCreate) {
  6282. scheduleShow();
  6283. }
  6284. popper2.addEventListener("mouseenter", function() {
  6285. if (instance.props.interactive && instance.state.isVisible) {
  6286. instance.clearDelayTimeouts();
  6287. }
  6288. });
  6289. popper2.addEventListener("mouseleave", function() {
  6290. if (instance.props.interactive && instance.props.trigger.indexOf("mouseenter") >= 0) {
  6291. getDocument().addEventListener("mousemove", debouncedOnMouseMove);
  6292. }
  6293. });
  6294. return instance;
  6295. function getNormalizedTouchSettings() {
  6296. var touch = instance.props.touch;
  6297. return Array.isArray(touch) ? touch : [touch, 0];
  6298. }
  6299. function getIsCustomTouchBehavior() {
  6300. return getNormalizedTouchSettings()[0] === "hold";
  6301. }
  6302. function getIsDefaultRenderFn() {
  6303. var _instance$props$rende;
  6304. return !!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy);
  6305. }
  6306. function getCurrentTarget() {
  6307. return currentTarget || reference2;
  6308. }
  6309. function getDocument() {
  6310. var parent = getCurrentTarget().parentNode;
  6311. return parent ? getOwnerDocument(parent) : document;
  6312. }
  6313. function getDefaultTemplateChildren() {
  6314. return getChildren(popper2);
  6315. }
  6316. function getDelay(isShow) {
  6317. if (instance.state.isMounted && !instance.state.isVisible || currentInput.isTouch || lastTriggerEvent && lastTriggerEvent.type === "focus") {
  6318. return 0;
  6319. }
  6320. return getValueAtIndexOrReturn(instance.props.delay, isShow ? 0 : 1, defaultProps.delay);
  6321. }
  6322. function handleStyles(fromHide) {
  6323. if (fromHide === void 0) {
  6324. fromHide = false;
  6325. }
  6326. popper2.style.pointerEvents = instance.props.interactive && !fromHide ? "" : "none";
  6327. popper2.style.zIndex = "" + instance.props.zIndex;
  6328. }
  6329. function invokeHook(hook, args, shouldInvokePropsHook) {
  6330. if (shouldInvokePropsHook === void 0) {
  6331. shouldInvokePropsHook = true;
  6332. }
  6333. pluginsHooks.forEach(function(pluginHooks) {
  6334. if (pluginHooks[hook]) {
  6335. pluginHooks[hook].apply(pluginHooks, args);
  6336. }
  6337. });
  6338. if (shouldInvokePropsHook) {
  6339. var _instance$props;
  6340. (_instance$props = instance.props)[hook].apply(_instance$props, args);
  6341. }
  6342. }
  6343. function handleAriaContentAttribute() {
  6344. var aria = instance.props.aria;
  6345. if (!aria.content) {
  6346. return;
  6347. }
  6348. var attr = "aria-" + aria.content;
  6349. var id2 = popper2.id;
  6350. var nodes = normalizeToArray(instance.props.triggerTarget || reference2);
  6351. nodes.forEach(function(node) {
  6352. var currentValue = node.getAttribute(attr);
  6353. if (instance.state.isVisible) {
  6354. node.setAttribute(attr, currentValue ? currentValue + " " + id2 : id2);
  6355. } else {
  6356. var nextValue = currentValue && currentValue.replace(id2, "").trim();
  6357. if (nextValue) {
  6358. node.setAttribute(attr, nextValue);
  6359. } else {
  6360. node.removeAttribute(attr);
  6361. }
  6362. }
  6363. });
  6364. }
  6365. function handleAriaExpandedAttribute() {
  6366. if (hasAriaExpanded || !instance.props.aria.expanded) {
  6367. return;
  6368. }
  6369. var nodes = normalizeToArray(instance.props.triggerTarget || reference2);
  6370. nodes.forEach(function(node) {
  6371. if (instance.props.interactive) {
  6372. node.setAttribute("aria-expanded", instance.state.isVisible && node === getCurrentTarget() ? "true" : "false");
  6373. } else {
  6374. node.removeAttribute("aria-expanded");
  6375. }
  6376. });
  6377. }
  6378. function cleanupInteractiveMouseListeners() {
  6379. getDocument().removeEventListener("mousemove", debouncedOnMouseMove);
  6380. mouseMoveListeners = mouseMoveListeners.filter(function(listener) {
  6381. return listener !== debouncedOnMouseMove;
  6382. });
  6383. }
  6384. function onDocumentPress(event) {
  6385. if (currentInput.isTouch) {
  6386. if (didTouchMove || event.type === "mousedown") {
  6387. return;
  6388. }
  6389. }
  6390. var actualTarget = event.composedPath && event.composedPath()[0] || event.target;
  6391. if (instance.props.interactive && actualContains(popper2, actualTarget)) {
  6392. return;
  6393. }
  6394. if (normalizeToArray(instance.props.triggerTarget || reference2).some(function(el) {
  6395. return actualContains(el, actualTarget);
  6396. })) {
  6397. if (currentInput.isTouch) {
  6398. return;
  6399. }
  6400. if (instance.state.isVisible && instance.props.trigger.indexOf("click") >= 0) {
  6401. return;
  6402. }
  6403. } else {
  6404. invokeHook("onClickOutside", [instance, event]);
  6405. }
  6406. if (instance.props.hideOnClick === true) {
  6407. instance.clearDelayTimeouts();
  6408. instance.hide();
  6409. didHideDueToDocumentMouseDown = true;
  6410. setTimeout(function() {
  6411. didHideDueToDocumentMouseDown = false;
  6412. });
  6413. if (!instance.state.isMounted) {
  6414. removeDocumentPress();
  6415. }
  6416. }
  6417. }
  6418. function onTouchMove() {
  6419. didTouchMove = true;
  6420. }
  6421. function onTouchStart() {
  6422. didTouchMove = false;
  6423. }
  6424. function addDocumentPress() {
  6425. var doc = getDocument();
  6426. doc.addEventListener("mousedown", onDocumentPress, true);
  6427. doc.addEventListener("touchend", onDocumentPress, TOUCH_OPTIONS);
  6428. doc.addEventListener("touchstart", onTouchStart, TOUCH_OPTIONS);
  6429. doc.addEventListener("touchmove", onTouchMove, TOUCH_OPTIONS);
  6430. }
  6431. function removeDocumentPress() {
  6432. var doc = getDocument();
  6433. doc.removeEventListener("mousedown", onDocumentPress, true);
  6434. doc.removeEventListener("touchend", onDocumentPress, TOUCH_OPTIONS);
  6435. doc.removeEventListener("touchstart", onTouchStart, TOUCH_OPTIONS);
  6436. doc.removeEventListener("touchmove", onTouchMove, TOUCH_OPTIONS);
  6437. }
  6438. function onTransitionedOut(duration, callback) {
  6439. onTransitionEnd(duration, function() {
  6440. if (!instance.state.isVisible && popper2.parentNode && popper2.parentNode.contains(popper2)) {
  6441. callback();
  6442. }
  6443. });
  6444. }
  6445. function onTransitionedIn(duration, callback) {
  6446. onTransitionEnd(duration, callback);
  6447. }
  6448. function onTransitionEnd(duration, callback) {
  6449. var box = getDefaultTemplateChildren().box;
  6450. function listener(event) {
  6451. if (event.target === box) {
  6452. updateTransitionEndListener(box, "remove", listener);
  6453. callback();
  6454. }
  6455. }
  6456. if (duration === 0) {
  6457. return callback();
  6458. }
  6459. updateTransitionEndListener(box, "remove", currentTransitionEndListener);
  6460. updateTransitionEndListener(box, "add", listener);
  6461. currentTransitionEndListener = listener;
  6462. }
  6463. function on(eventType, handler, options) {
  6464. if (options === void 0) {
  6465. options = false;
  6466. }
  6467. var nodes = normalizeToArray(instance.props.triggerTarget || reference2);
  6468. nodes.forEach(function(node) {
  6469. node.addEventListener(eventType, handler, options);
  6470. listeners.push({
  6471. node,
  6472. eventType,
  6473. handler,
  6474. options
  6475. });
  6476. });
  6477. }
  6478. function addListeners() {
  6479. if (getIsCustomTouchBehavior()) {
  6480. on("touchstart", onTrigger2, {
  6481. passive: true
  6482. });
  6483. on("touchend", onMouseLeave, {
  6484. passive: true
  6485. });
  6486. }
  6487. splitBySpaces(instance.props.trigger).forEach(function(eventType) {
  6488. if (eventType === "manual") {
  6489. return;
  6490. }
  6491. on(eventType, onTrigger2);
  6492. switch (eventType) {
  6493. case "mouseenter":
  6494. on("mouseleave", onMouseLeave);
  6495. break;
  6496. case "focus":
  6497. on(isIE11 ? "focusout" : "blur", onBlurOrFocusOut);
  6498. break;
  6499. case "focusin":
  6500. on("focusout", onBlurOrFocusOut);
  6501. break;
  6502. }
  6503. });
  6504. }
  6505. function removeListeners() {
  6506. listeners.forEach(function(_ref) {
  6507. var node = _ref.node, eventType = _ref.eventType, handler = _ref.handler, options = _ref.options;
  6508. node.removeEventListener(eventType, handler, options);
  6509. });
  6510. listeners = [];
  6511. }
  6512. function onTrigger2(event) {
  6513. var _lastTriggerEvent;
  6514. var shouldScheduleClickHide = false;
  6515. if (!instance.state.isEnabled || isEventListenerStopped(event) || didHideDueToDocumentMouseDown) {
  6516. return;
  6517. }
  6518. var wasFocused = ((_lastTriggerEvent = lastTriggerEvent) == null ? void 0 : _lastTriggerEvent.type) === "focus";
  6519. lastTriggerEvent = event;
  6520. currentTarget = event.currentTarget;
  6521. handleAriaExpandedAttribute();
  6522. if (!instance.state.isVisible && isMouseEvent(event)) {
  6523. mouseMoveListeners.forEach(function(listener) {
  6524. return listener(event);
  6525. });
  6526. }
  6527. if (event.type === "click" && (instance.props.trigger.indexOf("mouseenter") < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) {
  6528. shouldScheduleClickHide = true;
  6529. } else {
  6530. scheduleShow(event);
  6531. }
  6532. if (event.type === "click") {
  6533. isVisibleFromClick = !shouldScheduleClickHide;
  6534. }
  6535. if (shouldScheduleClickHide && !wasFocused) {
  6536. scheduleHide(event);
  6537. }
  6538. }
  6539. function onMouseMove(event) {
  6540. var target = event.target;
  6541. var isCursorOverReferenceOrPopper = getCurrentTarget().contains(target) || popper2.contains(target);
  6542. if (event.type === "mousemove" && isCursorOverReferenceOrPopper) {
  6543. return;
  6544. }
  6545. var popperTreeData = getNestedPopperTree().concat(popper2).map(function(popper22) {
  6546. var _instance$popperInsta;
  6547. var instance2 = popper22._tippy;
  6548. var state2 = (_instance$popperInsta = instance2.popperInstance) == null ? void 0 : _instance$popperInsta.state;
  6549. if (state2) {
  6550. return {
  6551. popperRect: popper22.getBoundingClientRect(),
  6552. popperState: state2,
  6553. props
  6554. };
  6555. }
  6556. return null;
  6557. }).filter(Boolean);
  6558. if (isCursorOutsideInteractiveBorder(popperTreeData, event)) {
  6559. cleanupInteractiveMouseListeners();
  6560. scheduleHide(event);
  6561. }
  6562. }
  6563. function onMouseLeave(event) {
  6564. var shouldBail = isEventListenerStopped(event) || instance.props.trigger.indexOf("click") >= 0 && isVisibleFromClick;
  6565. if (shouldBail) {
  6566. return;
  6567. }
  6568. if (instance.props.interactive) {
  6569. instance.hideWithInteractivity(event);
  6570. return;
  6571. }
  6572. scheduleHide(event);
  6573. }
  6574. function onBlurOrFocusOut(event) {
  6575. if (instance.props.trigger.indexOf("focusin") < 0 && event.target !== getCurrentTarget()) {
  6576. return;
  6577. }
  6578. if (instance.props.interactive && event.relatedTarget && popper2.contains(event.relatedTarget)) {
  6579. return;
  6580. }
  6581. scheduleHide(event);
  6582. }
  6583. function isEventListenerStopped(event) {
  6584. return currentInput.isTouch ? getIsCustomTouchBehavior() !== event.type.indexOf("touch") >= 0 : false;
  6585. }
  6586. function createPopperInstance() {
  6587. destroyPopperInstance();
  6588. 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;
  6589. var arrow2 = getIsDefaultRenderFn() ? getChildren(popper2).arrow : null;
  6590. var computedReference = getReferenceClientRect ? {
  6591. getBoundingClientRect: getReferenceClientRect,
  6592. contextElement: getReferenceClientRect.contextElement || getCurrentTarget()
  6593. } : reference2;
  6594. var tippyModifier = {
  6595. name: "$$tippy",
  6596. enabled: true,
  6597. phase: "beforeWrite",
  6598. requires: ["computeStyles"],
  6599. fn: function fn5(_ref2) {
  6600. var state2 = _ref2.state;
  6601. if (getIsDefaultRenderFn()) {
  6602. var _getDefaultTemplateCh = getDefaultTemplateChildren(), box = _getDefaultTemplateCh.box;
  6603. ["placement", "reference-hidden", "escaped"].forEach(function(attr) {
  6604. if (attr === "placement") {
  6605. box.setAttribute("data-placement", state2.placement);
  6606. } else {
  6607. if (state2.attributes.popper["data-popper-" + attr]) {
  6608. box.setAttribute("data-" + attr, "");
  6609. } else {
  6610. box.removeAttribute("data-" + attr);
  6611. }
  6612. }
  6613. });
  6614. state2.attributes.popper = {};
  6615. }
  6616. }
  6617. };
  6618. var modifiers = [{
  6619. name: "offset",
  6620. options: {
  6621. offset: offset2
  6622. }
  6623. }, {
  6624. name: "preventOverflow",
  6625. options: {
  6626. padding: {
  6627. top: 2,
  6628. bottom: 2,
  6629. left: 5,
  6630. right: 5
  6631. }
  6632. }
  6633. }, {
  6634. name: "flip",
  6635. options: {
  6636. padding: 5
  6637. }
  6638. }, {
  6639. name: "computeStyles",
  6640. options: {
  6641. adaptive: !moveTransition
  6642. }
  6643. }, tippyModifier];
  6644. if (getIsDefaultRenderFn() && arrow2) {
  6645. modifiers.push({
  6646. name: "arrow",
  6647. options: {
  6648. element: arrow2,
  6649. padding: 3
  6650. }
  6651. });
  6652. }
  6653. modifiers.push.apply(modifiers, (popperOptions == null ? void 0 : popperOptions.modifiers) || []);
  6654. instance.popperInstance = createPopper(computedReference, popper2, Object.assign({}, popperOptions, {
  6655. placement,
  6656. onFirstUpdate,
  6657. modifiers
  6658. }));
  6659. }
  6660. function destroyPopperInstance() {
  6661. if (instance.popperInstance) {
  6662. instance.popperInstance.destroy();
  6663. instance.popperInstance = null;
  6664. }
  6665. }
  6666. function mount() {
  6667. var appendTo = instance.props.appendTo;
  6668. var parentNode;
  6669. var node = getCurrentTarget();
  6670. if (instance.props.interactive && appendTo === TIPPY_DEFAULT_APPEND_TO || appendTo === "parent") {
  6671. parentNode = node.parentNode;
  6672. } else {
  6673. parentNode = invokeWithArgsOrReturn(appendTo, [node]);
  6674. }
  6675. if (!parentNode.contains(popper2)) {
  6676. parentNode.appendChild(popper2);
  6677. }
  6678. instance.state.isMounted = true;
  6679. createPopperInstance();
  6680. }
  6681. function getNestedPopperTree() {
  6682. return arrayFrom(popper2.querySelectorAll("[data-tippy-root]"));
  6683. }
  6684. function scheduleShow(event) {
  6685. instance.clearDelayTimeouts();
  6686. if (event) {
  6687. invokeHook("onTrigger", [instance, event]);
  6688. }
  6689. addDocumentPress();
  6690. var delay = getDelay(true);
  6691. var _getNormalizedTouchSe = getNormalizedTouchSettings(), touchValue = _getNormalizedTouchSe[0], touchDelay = _getNormalizedTouchSe[1];
  6692. if (currentInput.isTouch && touchValue === "hold" && touchDelay) {
  6693. delay = touchDelay;
  6694. }
  6695. if (delay) {
  6696. showTimeout = setTimeout(function() {
  6697. instance.show();
  6698. }, delay);
  6699. } else {
  6700. instance.show();
  6701. }
  6702. }
  6703. function scheduleHide(event) {
  6704. instance.clearDelayTimeouts();
  6705. invokeHook("onUntrigger", [instance, event]);
  6706. if (!instance.state.isVisible) {
  6707. removeDocumentPress();
  6708. return;
  6709. }
  6710. if (instance.props.trigger.indexOf("mouseenter") >= 0 && instance.props.trigger.indexOf("click") >= 0 && ["mouseleave", "mousemove"].indexOf(event.type) >= 0 && isVisibleFromClick) {
  6711. return;
  6712. }
  6713. var delay = getDelay(false);
  6714. if (delay) {
  6715. hideTimeout = setTimeout(function() {
  6716. if (instance.state.isVisible) {
  6717. instance.hide();
  6718. }
  6719. }, delay);
  6720. } else {
  6721. scheduleHideAnimationFrame = requestAnimationFrame(function() {
  6722. instance.hide();
  6723. });
  6724. }
  6725. }
  6726. function enable() {
  6727. instance.state.isEnabled = true;
  6728. }
  6729. function disable() {
  6730. instance.hide();
  6731. instance.state.isEnabled = false;
  6732. }
  6733. function clearDelayTimeouts() {
  6734. clearTimeout(showTimeout);
  6735. clearTimeout(hideTimeout);
  6736. cancelAnimationFrame(scheduleHideAnimationFrame);
  6737. }
  6738. function setProps(partialProps) {
  6739. if (instance.state.isDestroyed) {
  6740. return;
  6741. }
  6742. invokeHook("onBeforeUpdate", [instance, partialProps]);
  6743. removeListeners();
  6744. var prevProps = instance.props;
  6745. var nextProps = evaluateProps(reference2, Object.assign({}, prevProps, removeUndefinedProps(partialProps), {
  6746. ignoreAttributes: true
  6747. }));
  6748. instance.props = nextProps;
  6749. addListeners();
  6750. if (prevProps.interactiveDebounce !== nextProps.interactiveDebounce) {
  6751. cleanupInteractiveMouseListeners();
  6752. debouncedOnMouseMove = debounce(onMouseMove, nextProps.interactiveDebounce);
  6753. }
  6754. if (prevProps.triggerTarget && !nextProps.triggerTarget) {
  6755. normalizeToArray(prevProps.triggerTarget).forEach(function(node) {
  6756. node.removeAttribute("aria-expanded");
  6757. });
  6758. } else if (nextProps.triggerTarget) {
  6759. reference2.removeAttribute("aria-expanded");
  6760. }
  6761. handleAriaExpandedAttribute();
  6762. handleStyles();
  6763. if (onUpdate) {
  6764. onUpdate(prevProps, nextProps);
  6765. }
  6766. if (instance.popperInstance) {
  6767. createPopperInstance();
  6768. getNestedPopperTree().forEach(function(nestedPopper) {
  6769. requestAnimationFrame(nestedPopper._tippy.popperInstance.forceUpdate);
  6770. });
  6771. }
  6772. invokeHook("onAfterUpdate", [instance, partialProps]);
  6773. }
  6774. function setContent2(content) {
  6775. instance.setProps({
  6776. content
  6777. });
  6778. }
  6779. function show() {
  6780. var isAlreadyVisible = instance.state.isVisible;
  6781. var isDestroyed = instance.state.isDestroyed;
  6782. var isDisabled = !instance.state.isEnabled;
  6783. var isTouchAndTouchDisabled = currentInput.isTouch && !instance.props.touch;
  6784. var duration = getValueAtIndexOrReturn(instance.props.duration, 0, defaultProps.duration);
  6785. if (isAlreadyVisible || isDestroyed || isDisabled || isTouchAndTouchDisabled) {
  6786. return;
  6787. }
  6788. if (getCurrentTarget().hasAttribute("disabled")) {
  6789. return;
  6790. }
  6791. invokeHook("onShow", [instance], false);
  6792. if (instance.props.onShow(instance) === false) {
  6793. return;
  6794. }
  6795. instance.state.isVisible = true;
  6796. if (getIsDefaultRenderFn()) {
  6797. popper2.style.visibility = "visible";
  6798. }
  6799. handleStyles();
  6800. addDocumentPress();
  6801. if (!instance.state.isMounted) {
  6802. popper2.style.transition = "none";
  6803. }
  6804. if (getIsDefaultRenderFn()) {
  6805. var _getDefaultTemplateCh2 = getDefaultTemplateChildren(), box = _getDefaultTemplateCh2.box, content = _getDefaultTemplateCh2.content;
  6806. setTransitionDuration([box, content], 0);
  6807. }
  6808. onFirstUpdate = function onFirstUpdate2() {
  6809. var _instance$popperInsta2;
  6810. if (!instance.state.isVisible || ignoreOnFirstUpdate) {
  6811. return;
  6812. }
  6813. ignoreOnFirstUpdate = true;
  6814. void popper2.offsetHeight;
  6815. popper2.style.transition = instance.props.moveTransition;
  6816. if (getIsDefaultRenderFn() && instance.props.animation) {
  6817. var _getDefaultTemplateCh3 = getDefaultTemplateChildren(), _box = _getDefaultTemplateCh3.box, _content = _getDefaultTemplateCh3.content;
  6818. setTransitionDuration([_box, _content], duration);
  6819. setVisibilityState([_box, _content], "visible");
  6820. }
  6821. handleAriaContentAttribute();
  6822. handleAriaExpandedAttribute();
  6823. pushIfUnique(mountedInstances, instance);
  6824. (_instance$popperInsta2 = instance.popperInstance) == null ? void 0 : _instance$popperInsta2.forceUpdate();
  6825. invokeHook("onMount", [instance]);
  6826. if (instance.props.animation && getIsDefaultRenderFn()) {
  6827. onTransitionedIn(duration, function() {
  6828. instance.state.isShown = true;
  6829. invokeHook("onShown", [instance]);
  6830. });
  6831. }
  6832. };
  6833. mount();
  6834. }
  6835. function hide2() {
  6836. var isAlreadyHidden = !instance.state.isVisible;
  6837. var isDestroyed = instance.state.isDestroyed;
  6838. var isDisabled = !instance.state.isEnabled;
  6839. var duration = getValueAtIndexOrReturn(instance.props.duration, 1, defaultProps.duration);
  6840. if (isAlreadyHidden || isDestroyed || isDisabled) {
  6841. return;
  6842. }
  6843. invokeHook("onHide", [instance], false);
  6844. if (instance.props.onHide(instance) === false) {
  6845. return;
  6846. }
  6847. instance.state.isVisible = false;
  6848. instance.state.isShown = false;
  6849. ignoreOnFirstUpdate = false;
  6850. isVisibleFromClick = false;
  6851. if (getIsDefaultRenderFn()) {
  6852. popper2.style.visibility = "hidden";
  6853. }
  6854. cleanupInteractiveMouseListeners();
  6855. removeDocumentPress();
  6856. handleStyles(true);
  6857. if (getIsDefaultRenderFn()) {
  6858. var _getDefaultTemplateCh4 = getDefaultTemplateChildren(), box = _getDefaultTemplateCh4.box, content = _getDefaultTemplateCh4.content;
  6859. if (instance.props.animation) {
  6860. setTransitionDuration([box, content], duration);
  6861. setVisibilityState([box, content], "hidden");
  6862. }
  6863. }
  6864. handleAriaContentAttribute();
  6865. handleAriaExpandedAttribute();
  6866. if (instance.props.animation) {
  6867. if (getIsDefaultRenderFn()) {
  6868. onTransitionedOut(duration, instance.unmount);
  6869. }
  6870. } else {
  6871. instance.unmount();
  6872. }
  6873. }
  6874. function hideWithInteractivity(event) {
  6875. getDocument().addEventListener("mousemove", debouncedOnMouseMove);
  6876. pushIfUnique(mouseMoveListeners, debouncedOnMouseMove);
  6877. debouncedOnMouseMove(event);
  6878. }
  6879. function unmount() {
  6880. if (instance.state.isVisible) {
  6881. instance.hide();
  6882. }
  6883. if (!instance.state.isMounted) {
  6884. return;
  6885. }
  6886. destroyPopperInstance();
  6887. getNestedPopperTree().forEach(function(nestedPopper) {
  6888. nestedPopper._tippy.unmount();
  6889. });
  6890. if (popper2.parentNode) {
  6891. popper2.parentNode.removeChild(popper2);
  6892. }
  6893. mountedInstances = mountedInstances.filter(function(i) {
  6894. return i !== instance;
  6895. });
  6896. instance.state.isMounted = false;
  6897. invokeHook("onHidden", [instance]);
  6898. }
  6899. function destroy() {
  6900. if (instance.state.isDestroyed) {
  6901. return;
  6902. }
  6903. instance.clearDelayTimeouts();
  6904. instance.unmount();
  6905. removeListeners();
  6906. delete reference2._tippy;
  6907. instance.state.isDestroyed = true;
  6908. invokeHook("onDestroy", [instance]);
  6909. }
  6910. }
  6911. function tippy(targets, optionalProps) {
  6912. if (optionalProps === void 0) {
  6913. optionalProps = {};
  6914. }
  6915. var plugins = defaultProps.plugins.concat(optionalProps.plugins || []);
  6916. bindGlobalEventListeners();
  6917. var passedProps = Object.assign({}, optionalProps, {
  6918. plugins
  6919. });
  6920. var elements = getArrayOfElements(targets);
  6921. var instances = elements.reduce(function(acc, reference2) {
  6922. var instance = reference2 && createTippy(reference2, passedProps);
  6923. if (instance) {
  6924. acc.push(instance);
  6925. }
  6926. return acc;
  6927. }, []);
  6928. return isElement(targets) ? instances[0] : instances;
  6929. }
  6930. tippy.defaultProps = defaultProps;
  6931. tippy.setDefaultProps = setDefaultProps;
  6932. tippy.currentInput = currentInput;
  6933. Object.assign({}, applyStyles$1, {
  6934. effect: function effect2(_ref) {
  6935. var state = _ref.state;
  6936. var initialStyles = {
  6937. popper: {
  6938. position: state.options.strategy,
  6939. left: "0",
  6940. top: "0",
  6941. margin: "0"
  6942. },
  6943. arrow: {
  6944. position: "absolute"
  6945. },
  6946. reference: {}
  6947. };
  6948. Object.assign(state.elements.popper.style, initialStyles.popper);
  6949. state.styles = initialStyles;
  6950. if (state.elements.arrow) {
  6951. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  6952. }
  6953. }
  6954. });
  6955. tippy.setDefaultProps({
  6956. render
  6957. });
  6958.  
  6959. })
  6960. };
  6961. }));
  6962.  
  6963. System.register("./index-CZOUlSU2-CskZy1NC.js", [], (function (exports, module) {
  6964. 'use strict';
  6965. return {
  6966. execute: (function () {
  6967.  
  6968. const scroll = document.createElement("div");
  6969. scroll.setAttribute("class", "scroll-top");
  6970. document.body.appendChild(scroll);
  6971. const style = scroll.style;
  6972. const $container = document.querySelector(".container");
  6973. $container.addEventListener("scroll", function() {
  6974. this.scrollTop > 500 ? style.display = "block" : style.display = "none";
  6975. });
  6976. scroll.addEventListener("click", function() {
  6977. $container.scrollTop = 0;
  6978. });
  6979.  
  6980. })
  6981. };
  6982. }));
  6983.  
  6984. System.import("./__entry.js", "./");