JSON Viewer

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

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

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