@monkey2582/thinconsole 1.3.6 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/en.thinConsole.min.js +1 -1
- package/package.json +1 -1
- package/thinConsole.d.ts +308 -389
- package/thinConsole.min.js +1 -1
package/thinConsole.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):t.thinConsole=e()}("undefined"!=typeof self?self:this,function(){let t={"angle-down":"0 0 384 512|M169.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 306.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z","angle-right":"0 0 256 512|M247.1 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L179.2 256 41.9 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z","arrow-left":"0 0 512 512|M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 288H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H109.3l105.4-105.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z",ban:"0 0 512 512|M367.2 412.5 99.5 144.8C77.1 176.2 64 214.6 64 256c0 106 86 192 192 192 41.5 0 79.9-13.1 111.2-35.5m45.3-45.3C434.9 335.8 448 297.4 448 256c0-106-86-192-192-192-41.5 0-79.9 13.1-111.2 35.5zM0 256a256 256 0 1 1 512 0 256 256 0 1 1-512 0",check:"0 0 448 512|M434.8 70.1c14.3 10.4 17.5 30.4 7.1 44.7l-256 352c-5.5 7.6-14 12.3-23.4 13.1s-18.5-2.7-25.1-9.3l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l101.5 101.5 234-321.7c10.4-14.3 30.4-17.5 44.7-7.1z","check-circle":"0 0 512 512|M256 512a256 256 0 1 1 0-512 256 256 0 1 1 0 512m118-366.3c-10.7-7.8-25.7-5.4-33.5 5.3L221.1 315.2 169 263.1c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l72 72c5 5 11.8 7.5 18.8 7s13.4-4.1 17.5-9.8l135.9-187c7.8-10.7 5.4-25.7-5.3-33.5","chevron-down":"0 0 448 512|M201.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 338.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z","chevron-up":"0 0 448 512|M201.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L224 173.3 54.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z",code:"0 0 576 512|M360.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6m64.6 136.1c-12.5 12.5-12.5 32.8 0 45.3l73.4 73.4-73.4 73.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l96-96c12.5-12.5 12.5-32.8 0-45.3l-96-96c-12.5-12.5-32.8-12.5-45.3 0zm-274.7 0c-12.5-12.5-32.8-12.5-45.3 0l-96 96c-12.5 12.5-12.5 32.8 0 45.3l96 96c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l73.3-73.4c12.5-12.5 12.5-32.8 0-45.3z",copy:"0 0 448 512|M192 0c-35.3 0-64 28.7-64 64v256c0 35.3 28.7 64 64 64h192c35.3 0 64-28.7 64-64V119.4c0-17.4-7.1-34.1-19.7-46.2l-57.7-55.4A64.1 64.1 0 0 0 326.3 0zM64 128c-35.3 0-64 28.7-64 64v256c0 35.3 28.7 64 64 64h192c35.3 0 64-28.7 64-64v-16h-64v16H64V192h16v-64z",database:"0 0 448 512|M448 205.8c-14.8 9.8-31.8 17.7-49.5 24-47 16.8-108.7 26.2-174.5 26.2s-127.6-9.5-174.5-26.2c-17.6-6.3-34.7-14.2-49.5-24V288c0 44.2 100.3 80 224 80s224-35.8 224-80zm0-77.8V80c0-44.2-100.3-80-224-80S0 35.8 0 80v48c0 44.2 100.3 80 224 80s224-35.8 224-80m-49.5 261.8C351.6 406.5 289.9 416 224 416s-127.6-9.5-174.5-26.2c-17.6-6.3-34.7-14.2-49.5-24V432c0 44.2 100.3 80 224 80s224-35.8 224-80v-66.2c-14.8 9.8-31.8 17.7-49.5 24",download:"0 0 448 512|M256 32c0-17.7-14.3-32-32-32s-32 14.3-32 32v210.7l-41.4-41.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l96 96c12.5 12.5 32.8 12.5 45.3 0l96-96c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 242.7zM64 320c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64h320c35.3 0 64-28.7 64-64v-32c0-35.3-28.7-64-64-64h-46.9l-56.6 56.6c-31.2 31.2-81.9 31.2-113.1 0L110.9 320zm304 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48",edit:"0 0 512 512|M471.6 21.7c-21.9-21.9-57.3-21.9-79.2 0L368 46.1l97.9 97.9 24.4-24.4c21.9-21.9 21.9-57.3 0-79.2zm-299.2 220c-6.1 6.1-10.8 13.6-13.5 21.9l-29.6 88.8c-2.9 8.6-.6 18.1 5.8 24.6s15.9 8.7 24.6 5.8l88.8-29.6c8.2-2.7 15.7-7.4 21.9-13.5L432 177.9 334.1 80zM96 64c-53 0-96 43-96 96v256c0 53 43 96 96 96h256c53 0 96-43 96-96v-96c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32z",exclamation:"0 0 128 512|M64 432c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40M64 0c26.5 0 48 21.5 48 48v1.7l-16 304c-.9 17-15 30.3-32 30.3s-31-13.3-32-30.3l-16-304V48C16 21.5 37.5 0 64 0","exclamation-triangle":"0 0 512 512|M256 0c14.7 0 28.2 8.1 35.2 21l216 400c6.7 12.4 6.4 27.4-.8 39.5S486.1 480 472 480H40c-14.1 0-27.2-7.4-34.4-19.5s-7.5-27.1-.8-39.5l216-400c7-12.9 20.5-21 35.2-21m0 352a32 32 0 1 0 0 64 32 32 0 1 0 0-64m0-192c-18.2 0-32.7 15.5-31.4 33.7l7.4 104c.9 12.5 11.4 22.3 23.9 22.3 12.6 0 23-9.7 23.9-22.3l7.4-104c1.3-18.2-13.1-33.7-31.4-33.7z",eye:"0 0 576 512|M288 32c-80.8 0-145.5 36.8-192.6 80.6-46.8 43.5-78.1 95.4-93 131.1-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1C142.5 443.1 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C433.5 68.9 368.8 32 288 32M144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0m144-64c0 35.3-28.7 64-64 64-11.5 0-22.3-3-31.7-8.4-1 10.9-.1 22.1 2.9 33.2 13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-12.2-45.7-55.5-74.8-101.1-70.8 5.3 9.3 8.4 20.1 8.4 31.7",info:"0 0 192 512|M48 48a48 48 0 1 1 96 0 48 48 0 1 1-96 0M0 192c0-17.7 14.3-32 32-32h64c17.7 0 32 14.3 32 32v256h32c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32h32V224H32c-17.7 0-32-14.3-32-32","info-circle":"0 0 512 512|M256 512a256 256 0 1 0 0-512 256 256 0 1 0 0 512m-32-352a32 32 0 1 1 64 0 32 32 0 1 1-64 0m-8 64h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24h-80c-13.3 0-24-10.7-24-24s10.7-24 24-24h24v-64h-24c-13.3 0-24-10.7-24-24s10.7-24 24-24",list:"0 0 512 512|M40 48c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24V72c0-13.3-10.7-24-24-24zm152 16c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zM16 232v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24v-48c0-13.3-10.7-24-24-24H40c-13.3 0-24 10.7-24 24m24 136c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24v-48c0-13.3-10.7-24-24-24z","mouse-pointer":"0 0 448 512|M77.3 2.5c8.1-4.1 17.9-3.2 25.1 2.3l320 239.9c8.3 6.2 11.6 17 8.4 26.8s-12.4 16.4-22.8 16.4H255.7l88.9 177.7c7.9 15.8 1.5 35-14.3 42.9s-35 1.5-42.9-14.3l-88.9-177.7-91.3 121.8c-6.2 8.3-17 11.6-26.8 8.4S64 434.3 64 424V24c0-9.1 5.1-17.4 13.3-21.5","paper-plane":"0 0 576 512|M536.4-26.3c9.8-3.5 20.6-1 28 6.3s9.8 18.2 6.3 28l-178 496.9c-5 13.9-18.1 23.1-32.8 23.1-14.2 0-27-8.6-32.3-21.7l-64.2-158c-4.5-11-2.5-23.6 5.2-32.6l94.5-112.4c5.1-6.1 4.7-15-.9-20.6s-14.6-6-20.6-.9l-112.4 94.3c-9.1 7.6-21.6 9.6-32.6 5.2L38.1 216.8c-13.1-5.3-21.7-18.1-21.7-32.3 0-14.7 9.2-27.8 23.1-32.8z",pen:"0 0 512 512|M352.9 21.2 308 66.1 445.9 204l44.9-44.9c13.6-13.5 21.2-31.9 21.2-51.1s-7.6-37.6-21.2-51.1l-35.7-35.7C441.6 7.6 423.2 0 404 0s-37.6 7.6-51.1 21.2M274.1 100 58.9 315.1c-10.7 10.7-18.5 24.1-22.6 38.7L.9 481.6c-2.3 8.3 0 17.3 6.2 23.4s15.1 8.5 23.4 6.2l127.8-35.5c14.6-4.1 27.9-11.8 38.7-22.6l215-215.2z",plug:"0 0 448 512|M128-32c17.7 0 32 14.3 32 32v96h128V0c0-17.7 14.3-32 32-32s32 14.3 32 32v96h64c17.7 0 32 14.3 32 32s-14.3 32-32 32v64c0 95.1-69.2 174.1-160 189.3V480c0 17.7-14.3 32-32 32s-32-14.3-32-32v-66.7C101.2 398.1 32 319.1 32 224v-64c-17.7 0-32-14.3-32-32s14.3-32 32-32h64V0c0-17.7 14.3-32 32-32",plus:"0 0 448 512|M256 64c0-17.7-14.3-32-32-32s-32 14.3-32 32v160H32c-17.7 0-32 14.3-32 32s14.3 32 32 32h160v160c0 17.7 14.3 32 32 32s32-14.3 32-32V288h160c17.7 0 32-14.3 32-32s-14.3-32-32-32H256z",redo:"0 0 512 512|M488 192H344c-9.7 0-18.5-5.8-22.2-14.8s-1.7-19.3 5.2-26.2l46.7-46.7C298.4 45.7 189.4 51 120.2 120.2c-75 75-75 196.5 0 271.5s196.5 75 271.5 0q12.3-12.3 21.9-26.1c10.1-14.5 30.1-18 44.6-7.9s18 30.1 7.9 44.6c-8.5 12.2-18.2 23.8-29.1 34.7-100 100-262.1 100-362 0S-25 175 75 75c94.3-94.3 243.7-99.6 344.3-16.2L471 7c6.9-6.9 17.2-8.9 26.2-5.2S512 14.3 512 24v144c0 13.3-10.7 24-24 24",search:"0 0 512 512|M416 208c0 45.9-14.9 88.3-40 122.7l126.6 126.7c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.1-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0s208 93.1 208 208M208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288",table:"0 0 448 512|M384 32c35.3 0 64 28.7 64 64v320c0 35.3-28.7 64-64 64H64l-6.5-.3C25.2 476.4 0 449.1 0 416V96c0-35.3 28.7-64 64-64zM64 320v96h128v-96zm192 0v96h128v-96zM64 256h128v-96H64zm192 0h128v-96H256z",terminal:"0 0 512 512|M9.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L146.7 256zM224 384h256c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32",times:"0 0 384 512|M55.1 73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L147.2 256 9.9 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l137.3-137.4 137.4 137.3c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.8 256l137.3-137.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192.5 210.7z","times-circle":"0 0 512 512|M256 512a256 256 0 1 0 0-512 256 256 0 1 0 0 512m-89-345c9.4-9.4 24.6-9.4 33.9 0l55 55 55-55c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-55 55 55 55c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-55-55-55 55c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l55-55-55-55c-9.4-9.4-9.4-24.6 0-33.9",tool:"0 0 576 512|M70.8-6.7c5.4-5.4 13.8-6.2 20.2-2l118.9 79.2c8.9 5.9 14.2 15.9 14.2 26.6v49.6l90.8 90.8c33.3-15 73.9-8.9 101.2 18.5l126.1 126.1c18.7 18.7 18.7 49.1 0 67.9l-60.1 60.1c-18.7 18.7-49.1 18.7-67.9 0L288.1 384c-27.4-27.4-33.5-67.9-18.5-101.2L178.8 192h-49.6c-10.7 0-20.7-5.3-26.6-14.2L23.4 58.9c-4.2-6.3-3.4-14.8 2-20.2zm145 303.5c-6.3 36.9 2.3 75.9 26.2 107.2l-94.9 95c-28.1 28.1-73.7 28.1-101.8 0s-28.1-73.7 0-101.8l135.4-135.5 35.2 35.1zM384.1 0c20.1 0 39.4 3.7 57.1 10.5 10 3.8 11.8 16.5 4.3 24.1l-56.7 56.7c-3 3-4.7 7.1-4.7 11.3V144c0 8.8 7.2 16 16 16h41.4c4.2 0 8.3-1.7 11.3-4.7l56.7-56.7c7.6-7.5 20.3-5.7 24.1 4.3 6.8 17.7 10.5 37 10.5 57.1 0 43.2-17.2 82.3-45 111.1L450 222c-33.1-33-78.5-45.7-121.1-38.4l-56.8-56.8V97.1l-.2-5c-.8-12.4-4.4-24.3-10.5-34.9C290.8 22.2 334.8 0 384.1-.1z",trash:"0 0 448 512|M136.7 5.9 128 32H32C14.3 32 0 46.3 0 64s14.3 32 32 32h384c17.7 0 32-14.3 32-32s-14.3-32-32-32h-96l-8.7-26.1C306.9-7.2 294.7-16 280.9-16H167.1c-13.8 0-26 8.8-30.4 21.9M416 144H32l21.1 323.1C54.7 492.4 75.7 512 101 512h246c25.3 0 46.3-19.6 47.9-44.9z","trash-alt":"0 0 448 512|M166.2-16c-13.3 0-25.3 8.3-30 20.8L120 48H24C10.7 48 0 58.7 0 72s10.7 24 24 24h400c13.3 0 24-10.7 24-24s-10.7-24-24-24h-96L311.8 4.8c-4.7-12.5-16.6-20.8-30-20.8zM32 144v304c0 35.3 28.7 64 64 64h256c35.3 0 64-28.7 64-64V144h-48v304c0 8.8-7.2 16-16 16H96c-8.8 0-16-7.2-16-16V144zm160 72c0-13.3-10.7-24-24-24s-24 10.7-24 24v176c0 13.3 10.7 24 24 24s24-10.7 24-24zm112 0c0-13.3-10.7-24-24-24s-24 10.7-24 24v176c0 13.3 10.7 24 24 24s24-10.7 24-24z",upload:"0 0 448 512|M256 109.3V320c0 17.7-14.3 32-32 32s-32-14.3-32-32V109.3l-41.4 41.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l96-96c12.5-12.5 32.8-12.5 45.3 0l96 96c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0zM224 400c44.2 0 80-35.8 80-80h80c35.3 0 64 28.7 64 64v32c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64v-32c0-35.3 28.7-64 64-64h80c0 44.2 35.8 80 80 80m144 24a24 24 0 1 0 0-48 24 24 0 1 0 0 48",wifi:"0 0 576 512|M288 96c-90.9 0-173.2 36-233.7 94.6-12.7 12.3-33 12-45.2-.7s-12-33 .7-45.2C81.7 74.9 179.9 32 288 32s206.3 42.9 278.3 112.7c12.7 12.3 13 32.6.7 45.2s-32.6 13-45.2.7C461.2 132 378.9 96 288 96m-48 336a48 48 0 1 1 96 0 48 48 0 1 1-96 0m-72-105.8c-11.7 13.3-31.9 14.5-45.2 2.8s-14.5-31.9-2.8-45.2c41-46.4 101.1-75.8 168-75.8s127 29.4 168 75.8c11.7 13.3 10.4 33.5-2.8 45.2s-33.5 10.4-45.2-2.8c-29.4-33.3-72.2-54.2-120-54.2s-90.6 20.9-120 54.2","window-restore":"0 0 576 512|M512 96H160c0-35.3 28.7-64 64-64h288c35.3 0 64 28.7 64 64v192c0 35.3-28.7 64-64 64h-48v-64h48zM0 224c0-35.3 28.7-64 64-64h288c35.3 0 64 28.7 64 64v192c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64zm64 40c0 13.3 10.7 24 24 24h240c13.3 0 24-10.7 24-24s-10.7-24-24-24H88c-13.3 0-24 10.7-24 24","cookie-bite":"0 0 512 512|M257.5 27.6c-.8-5.4-4.9-9.8-10.3-10.6-22.1-3.1-44.6.9-64.4 11.4l-74 39.5c-19.7 10.5-35.6 27-45.4 47.1l-36.7 75.6c-9.8 20.1-13 42.9-9.1 64.9l14.5 82.8c3.9 22.1 14.6 42.3 30.7 57.9l60.3 58.4c16.1 15.6 36.6 25.6 58.7 28.7l83 11.7c22.1 3.1 44.6-.9 64.4-11.4l74-39.5c19.7-10.5 35.6-27 45.4-47.2l36.7-75.5c9.8-20.1 13-42.9 9.1-64.9-.9-5.3-5.3-9.3-10.6-10.1-51.5-8.2-92.8-47.1-104.5-97.4-1.8-7.6-8-13.4-15.7-14.6-54.6-8.7-97.7-52-106.2-106.8zM208 144a32 32 0 1 1 0 64 32 32 0 1 1 0-64m-64 192a32 32 0 1 1 64 0 32 32 0 1 1-64 0m224-64a32 32 0 1 1 0 64 32 32 0 1 1 0-64"};class e{constructor(t={}){if(e.tC)return console.warn("[thinConsole] thinConsole实例已存在"),e.tC;switch(t=this.sanitizeOptions(t),e.tC=this,this.version="1.3.6",this.options=t,this.options.theme){case"light":this.currentTheme="light";break;case"dark":this.currentTheme="dark";break;default:let t=()=>window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";this.currentTheme=t(),this.mediaQuery=window.matchMedia("(prefers-color-scheme:dark)"),this.themeChangeHandler=t=>{this.currentTheme=t.matches?"dark":"light",this.overlay&&this.overlay.classList.contains("active")&&(this.overlay.className="overlay active theme-"+this.currentTheme)},this.mediaQuery.addEventListener("change",this.themeChangeHandler)}this.currentTab="console",this.searchExpanded=!1,this.activeLSFilter="local",this.selectedElement=null,this.selectedShadowHostId=null,this.expandedElements=new WeakSet,this.mutedLogs=!1,this.mutedFilters={},this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!1,mode:"ls",key:"",oldKey:"",value:""},void 0===t.pos?.x&&void 0===t.pos?.y&&(this.options.pos=this.getSavedBtnPos()||{x:30,y:30}),this.pluginEnabled=this.options.plugins,this.disabledPlugins=this.options.disabledPlugins,this.plugins={},this.pluginTabs={},this.pluginViewContainers={},this.logs=[],this.lastLog=null,this.maxLog=this.options.maxLog,this.maxNetwork=this.options.maxNetwork,this.selectedLogId=null,this.customTabCount=0,this.jsonPageSize=200,this.jsonPageCache=new Map,this.jsonPageIndex=new Map,this.treeNodeRegistry=new Map,this.treeNodeRegId=0,this.expandedTreePaths=new Set,this.timerMap=new Map,this.countMap=new Map,this.networkRequests=[],this._netReqId=0,this.activeNetFilter="all",this.netDisabled=!1,this.netDisabledTypes=new Set,this.netDetailId=null,this.originalXHR=null,this.originalFetch=null,this.closedShadowRoots=new WeakMap,this.interceptShadowRoot(),this.initShadow(),this.createStyles(),this.createButton(),this.captureConsoleLogs(),this.createNotificationElement(),this.createOverlayElement(),this.setupGlobalEventHandlers(),this.setupSelfProtection(),this.renderContent()}interceptShadowRoot(){if(window.__tcShadowIntercepted)return;window.__tcShadowIntercepted=!0;let t=this,e=Element.prototype.attachShadow;Element.prototype.attachShadow=function(s){let i=e.call(this,s);return t.closedShadowRoots.set(this,{root:i,mode:s.mode||"open"}),i}}initShadow(){this.host&&this.host.remove(),this.host=document.createElement("div"),this.host.id="tc-host",this.host.setAttribute("tc-lock",""),this.host.style.cssText="position:absolute;top:0;left:0;width:0;height:0;z-index:2147483647",this.shadowRoot=this.host.attachShadow({mode:"open"}),document.documentElement.appendChild(this.host)}getShadowRoot(t){return t.shadowRoot?{root:t.shadowRoot,mode:"open"}:this.closedShadowRoots.get(t)||null}getSavedBtnPos(){let t=localStorage.getItem("tC-Button-pos");if(!t)return this.saveBtnPos({x:30,y:30}),null;let e=t.match(/^x:(.+?)\,y:(.+)$/);if(!e)return this.saveBtnPos({x:30,y:30}),null;let s=Number(e[1]),i=Number(e[2]);return isNaN(s)||isNaN(i)?(this.saveBtnPos({x:30,y:30}),null):{x:s,y:i}}saveBtnPos({x:t,y:e}){t=isNaN(Number(t))?30:Number(t),e=isNaN(Number(e))?30:Number(e),localStorage.setItem("tC-Button-pos",`x:${t},y:${e}`)}sanitizeOptions(t){let e={text:"thinConsole",color:"#007aff",width:"auto",height:"auto",theme:"auto",plugins:!0,disabledPlugins:[],jsExecute:!0,pos:null,maxLog:1e5,maxNetwork:1e3,pluginOption:{},filters:null};if(!t||"object"!=typeof t)return{...e};let s={...e},i=(t,e=200)=>"string"==typeof t&&t.length<=e&&!/[<>"&]/.test(t)?t:void 0;for(let n of Object.keys(t)){if(!(n in e))continue;let o=t[n];switch(n){case"text":case"color":case"width":case"height":case"theme":{let t=i(o);void 0!==t&&(s[n]=t);break}case"plugins":case"jsExecute":"boolean"==typeof o&&(s[n]=o);break;case"disabledPlugins":Array.isArray(o)&&o.every(t=>"string"==typeof t)&&(s[n]=o.slice(0,100));break;case"pos":o&&"object"==typeof o&&"number"==typeof o.x&&"number"==typeof o.y&&(s.pos={x:o.x,y:o.y});break;case"maxLog":{let e=Number(t[n]);!isNaN(e)&&e>0&&(s[n]=Math.floor(e));break}case"maxNetwork":{let e=Number(t[n]);!isNaN(e)&&e>0&&(s[n]=Math.floor(e));break}case"pluginOption":o&&"object"==typeof o&&(s[n]=o);break;case"filters":Array.isArray(o)&&o.every(t=>t&&"string"==typeof t.id&&"string"==typeof t.name)&&(s[n]=o)}}return s}createButton(){this.btn=document.createElement("button"),this.btn.id="thinConsole-btn",this.btn.className="floating-console-btn",this.btn.textContent=this.options.text.slice(0,11),this.btn.style.background=this.options.color,this.btn.style.width=this.options.width,this.btn.style.height=this.options.height,this.btn.style.bottom=(Number(this.options.pos.y)||30)+"px",this.btn.style.right=(Number(this.options.pos.x)||30)+"px",this.btn.title=this.options.text.slice(0,11),this.shadowRoot.append(this.btn),this.btn.style.transition="none",requestAnimationFrame(()=>requestAnimationFrame(()=>{this.btn.style.transition=""}));let t=!1,e=0,s=0,i=0,n=0,o=0,r=0,l=null,a=null,c=0,d=0,h=()=>{l&&(clearTimeout(l),l=null)},p=()=>{if(!t)return;let e=c-i,s=d-n;this.btn.style.transition="none",this.btn.style.transform=`translate3d(${e}px,${s}px,0)`,a=requestAnimationFrame(p)},u=l=>{if(!t)return;let a=l.touches?l.touches[0]:l,h=a.clientX-e,p=a.clientY-s;c=Math.max(o/2,Math.min(innerWidth-o/2,i+h)),d=Math.max(r/2,Math.min(innerHeight-r/2,n+p)),l.preventDefault()},g=()=>{if(h(),!t)return;t=!1,cancelAnimationFrame(a);let e=this.btn.getBoundingClientRect(),s=Math.round(innerWidth-e.right),i=Math.round(innerHeight-e.bottom);this.btn.style.right=Math.max(0,s)+"px",this.btn.style.bottom=Math.max(0,i)+"px",this.saveBtnPos({x:Math.max(0,s),y:Math.max(0,i)}),this.btn.style.transition="all 0.3s ease",this.btn.style.transform="",this.btn.dataset.right=Math.max(0,s),this.btn.dataset.bottom=Math.max(0,i),this.btn.removeEventListener("touchmove",u,{passive:!1}),this.btn.removeEventListener("touchend",g),this.btn.removeEventListener("mousemove",u),this.btn.removeEventListener("mouseup",g)},f=a=>{let h=a.touches?a.touches[0]:a;e=h.clientX,s=h.clientY;let f=this.btn.getBoundingClientRect();o=f.width,r=f.height,i=f.left+o/2,n=f.top+r/2,l=setTimeout(()=>{t=!0,c=i,d=n,p(),this.btn.addEventListener("touchmove",u,{passive:!1}),this.btn.addEventListener("touchend",g),this.btn.addEventListener("mousemove",u),this.btn.addEventListener("mouseup",g)},500)};this.btn.addEventListener("touchstart",f,{passive:!1}),this.btn.addEventListener("mousedown",f),this.btn.addEventListener("touchend",h),this.btn.addEventListener("mouseup",h),this.btn.addEventListener("mouseleave",h),this.btn.addEventListener("click",()=>{this.triggerGlobalHook("beforeOpen"),this.overlay.className="overlay active theme-"+this.currentTheme,this.renderContent(),this.triggerGlobalHook("afterOpen")})}createOverlayElement(){this.overlay=document.createElement("div"),this.overlay.id="consoleOverlay",this.overlay.className="overlay no-anim";let t=`<div class="splitter" id="splitter"></div><div class="console-container"><div class="console-header" id="consoleHeader"><div class="console-title" id="consoleTitle">${this.icon("terminal")}${this.options.text.slice(0,11)}</div><div class="header-actions"><button class="header-icon-btn el-header-btn" id="elementPickBtn" title="选择元素" style="display:none">${this.icon("mouse-pointer")}</button><button class="header-icon-btn el-header-btn" id="elCopyBtn" title="复制元素" style="display:none">${this.icon("copy")}</button><button class="header-icon-btn el-header-btn el-delete-btn" id="elDeleteBtn" title="删除元素" style="display:none">${this.icon("trash")}</button><button class="header-icon-btn" id="logCopyBtn" title="复制选中日志" style="display:none">${this.icon("copy")}</button><button class="header-icon-btn ls-add-btn" id="lsAddBtn" title="新建" style="display:none">${this.icon("plus")}</button><button class="header-icon-btn" id="netNewBtn" title="新建请求" style="display:none">${this.icon("plus")}</button><button class="header-icon-btn" id="searchToggleBtn" title="搜索">${this.icon("search")}</button><button class="clear-all-btn" title="清除" id="clearLogsBtn">${this.icon("trash")}</button><button class="close-btn" title="关闭" id="closeConsoleBtn">${this.icon("times")}</button></div></div><div class="search-bar" id="searchBar" style="display:none"><div class="search-input-wrap">${this.icon("search","search-bar-icon")}<input type="text" id="searchInput" placeholder="搜索..."></div></div><div class="tabs" id="tabsContainer"></div><div class="console-content" id="contentArea"><div class="controls" id="consoleControls"><div class="filters" id="filtersContainer"></div><div class="filters ls-filters" id="lsFiltersContainer" style="display:none"><button class="filter-btn active" title="本地存储" data-ls-type="local" data-orig="本地存储" data-icon="database">${this.icon("database")}本地存储</button><button class="filter-btn" title="会话存储" data-ls-type="session" data-orig="会话存储" data-icon="window-restore">${this.icon("window-restore")}会话存储</button><button class="filter-btn" title="Cookies" data-ls-type="cookie" data-orig="Cookies" data-icon="cookie-bite">${this.icon("cookie-bite")}Cookies</button></div><button class="mute-btn" id="muteBtn" title="屏蔽后续日志">${this.icon("ban")}</button></div><div class="console-output" id="consoleOutput"></div><div class="localstorage-view" id="localstorageView" style="display:none"><div class="ls-items" id="lsItems"></div></div><div class="elements-view" id="elementsView" style="display:none"><div class="elements-tree" id="elementsTree"></div></div><div class="network-view" id="networkView" style="display:none"><div class="network-controls"><div class="network-filters" id="netFilters"></div><button class="net-disable-btn" id="netDisableBtn" title="禁用">${this.icon("ban")}</button></div><div class="network-items" id="networkItems"></div><div class="net-detail-overlay" id="netDetailOverlay"><div class="net-detail-header"><button class="net-back-btn" id="netBackBtn" title="返回">${this.icon("arrow-left")}</button><div class="net-detail-header-actions"><button class="net-resend-icon-btn" id="netResendIconBtn" title="重发">${this.icon("redo")}</button></div></div><div class="net-detail-body" id="netDetailBody"></div></div><div class="net-new-overlay" id="netNewOverlay"><div class="net-new-header"><button class="net-back-btn" id="netNewBackBtn">${this.icon("arrow-left")}</button><div class="net-new-title">新建请求</div></div><div class="net-new-body"><div class="net-form-group"><label class="net-form-label">网址</label><input type="text" class="net-form-input" id="netNewUrl" placeholder="https://..." spellcheck="false"></div><div class="net-form-group"><label class="net-form-label">类型</label><select class="net-form-select" id="netNewMethod"><option value="GET">GET</option><option value="POST">POST</option><option value="PUT">PUT</option><option value="PATCH">PATCH</option><option value="DELETE">DELETE</option><option value="HEAD">HEAD</option><option value="OPTIONS">OPTIONS</option></select></div><div class="net-form-group"><label class="net-form-label">请求内容 (可选)</label><textarea class="net-form-textarea" id="netNewBody" placeholder='{"key":"value"}' spellcheck="false"></textarea></div><div class="net-form-group"><label class="net-form-label">请求头 (可选, 每行一个)</label><textarea class="net-form-textarea" id="netNewHeaders" placeholder="Content-Type: application/json" spellcheck="false"></textarea></div><button class="net-send-btn" id="netSendBtn">${this.icon("paper-plane")} 发送请求</button></div></div></div><div class="ls-editor-overlay" id="lsEditorOverlay" style="display:none"><div class="ls-editor-header"><div class="ls-editor-header-row"><input type="text" class="ls-editor-key-input" id="lsEditorKeyInput" placeholder="键名..." spellcheck="false"><span class="ls-editor-title" id="lsEditorTitle"></span></div></div><div class="ls-editor-body"><textarea id="lsEditorInput" placeholder="输入值..." spellcheck="false"></textarea></div><div class="ls-editor-footer"><button class="ls-editor-btn cancel" id="lsEditorCancel">取消</button><button class="ls-editor-btn save" id="lsEditorSave">保存</button></div></div></div></div>`;this.overlay.innerHTML=t,this.shadowRoot.appendChild(this.overlay),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.overlay.classList.remove("no-anim")})});let $=this.overlay.querySelector.bind(this.overlay);this.tabButtonsContainer=$("#tabsContainer"),this.createBuiltinTabs(),this.closeConsoleBtn=$("#closeConsoleBtn"),this.consoleOutput=$("#consoleOutput"),this.title=$("#consoleTitle"),this.localstorageView=$("#localstorageView"),this.lsItems=$("#lsItems"),this.contentArea=$("#contentArea"),this.consoleContainer=$(".console-container"),this.renderFilters(),this.filterButtons=this.overlay.querySelectorAll("#filtersContainer .filter-btn"),this.searchInput=$("#searchInput"),this.clearLogsBtn=$("#clearLogsBtn"),this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.consoleControls=$("#consoleControls"),this.searchToggleBtn=$("#searchToggleBtn"),this.searchBar=$("#searchBar"),this.consoleHeader=$("#consoleHeader"),this.lsEditorOverlay=$("#lsEditorOverlay"),this.lsEditorTitle=$("#lsEditorTitle"),this.lsEditorKeyInput=$("#lsEditorKeyInput"),this.lsEditorInput=$("#lsEditorInput"),this.lsEditorCancel=$("#lsEditorCancel"),this.lsEditorSave=$("#lsEditorSave"),this.muteBtn=$("#muteBtn"),this.lsFiltersContainer=$("#lsFiltersContainer"),this.lsAddBtn=$("#lsAddBtn"),this.logCopyBtn=$("#logCopyBtn"),this.elementsView=$("#elementsView"),this.elementsTree=$("#elementsTree"),this.networkView=$("#networkView"),this.networkItems=$("#networkItems"),this.netFiltersEl=$("#netFilters"),this.netDisableBtn=$("#netDisableBtn"),this.netDetailOverlay=$("#netDetailOverlay"),this.netDetailBody=$("#netDetailBody"),this.netNewOverlay=$("#netNewOverlay"),this.netNewUrl=$("#netNewUrl"),this.netNewMethod=$("#netNewMethod"),this.netNewBody=$("#netNewBody"),this.netNewHeaders=$("#netNewHeaders"),this.netSendBtn=$("#netSendBtn"),this.netBackBtn=$("#netBackBtn"),this.netNewBackBtn=$("#netNewBackBtn"),this.netNewBtn=$("#netNewBtn"),this.elementPickBtn=$("#elementPickBtn"),this.splitter=$("#splitter"),this.splitter&&this.setupSplitter(),this.elementPickBtn.addEventListener("click",()=>this.startElementPicker()),this.elCopyBtn=$("#elCopyBtn"),this.elCopyBtn.addEventListener("click",()=>{this.selectedElement?this.copyElementHTML(this.selectedElement):this.showNotification("请先选择一个元素","warning")}),this.elDeleteBtn=$("#elDeleteBtn"),this.elDeleteBtn.addEventListener("click",()=>{this.selectedElement?this.deleteElement(this.selectedElement):this.showNotification("请先选择一个元素","warning")}),this.netDisableBtn&&this.netDisableBtn.addEventListener("click",()=>this.toggleNetDisable()),this.netBackBtn&&this.netBackBtn.addEventListener("click",()=>{this.netDetailOverlay.style.display="none",this.netDetailId=null}),this.netNewBackBtn&&this.netNewBackBtn.addEventListener("click",()=>{this.netNewVisible=!1,this.netNewOverlay.style.display="none"}),this.netNewBtn&&this.netNewBtn.addEventListener("click",()=>{if(this.editorState.visible){let t=this.editorState.mode;if("code"===t)return void this.showNotification("正在运行代码,无法发送请求","warning");if("ls"===t)return void this.showNotification("正在保存键值,无法发送请求","warning")}this.netNewVisible=!0,this.netNewOverlay.style.display="flex"}),this.netSendBtn&&this.netSendBtn.addEventListener("click",()=>this.sendNewRequest()),this.networkItems&&this.networkItems.addEventListener("click",t=>{let e=t.target.closest(".net-item");if(!e)return;let s=parseInt(e.dataset.reqId);if(t.target.closest("[data-action=copy]")){t.stopPropagation(),t.preventDefault();let e=this.networkRequests.find(t=>t.id===s);if(e){let t={method:e.method,url:e.url,headers:e.reqHeaders,body:e.reqBody};navigator.clipboard.writeText(JSON.stringify(t,null,2)).then(()=>this.showNotification("已复制请求JSON")).catch(()=>{})}return}return t.target.closest("[data-action=detail]")?(t.stopPropagation(),t.preventDefault(),void this.showNetDetail(s)):void 0}),this.captureNetworkRequests(),this.closeConsoleBtn.addEventListener("click",()=>{this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose")}),[this.consoleOutput,this.lsItems,this.networkItems].forEach(t=>this.vsInit(t)),this.lsItems.addEventListener("click",t=>{let e=t.target.closest(".ls-action-btn");if(!e)return;let s=e.dataset.action,i=e.dataset.key;switch(s){case"edit":this.openLSEditor(i);break;case"copy":this.copyLog(i,"",!0);break;case"remove":this.removeLSItem(i)}}),this.title.title="运行代码功能已被禁用",this.title.style.cursor="not-allowed",this.options.jsExecute&&(this.title.title="点击标题以输入代码执行",this.title.style.cursor="pointer",this.title.addEventListener("click",()=>this.onTitleClick())),this.overlay.addEventListener("click",t=>{let e=t.target.closest(".json-page-btn");e&&this.changeJsonPage(parseInt(e.dataset.id),parseInt(e.dataset.page,10));let s=t.target.closest(".tree-load-more");s&&this.loadMoreTreeChildren(s);let i=t.target.closest(".elements-tree .tree-label");if(i){let t=i.closest(".tree-node[data-el-id]"),e=t?parseInt(t.dataset.elId):null,s=null!==e&&this.elRefMap?this.elRefMap.get(e):null;s&&(this.selectedElement=s,this.selectedShadowHostId=t.dataset.shadowHost?parseInt(t.dataset.shadowHost):null,this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),this.elementsTree.querySelectorAll(".el-highlight").forEach(t=>t.classList.remove("el-highlight")),t.classList.add("el-selected"),t.classList.add("el-highlight"),setTimeout(()=>t.classList.remove("el-highlight"),3e3))}else"elements"!==this.currentTab||t.target.closest(".tree-label")||t.target.closest(".tree-toggle")||t.target.closest(".el-header-btn")||t.target.closest(".close-btn")||t.target.closest(".header-icon-btn")||t.target.closest(".console-header")||t.target.closest(".tabs")||t.target.closest(".controls")||t.target.closest(".search-bar")||(this.selectedElement=null,this.selectedShadowHostId=null,this.elementsTree&&(this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),this.elementsTree.querySelectorAll(".el-highlight").forEach(t=>t.classList.remove("el-highlight"))));let n=t.target.closest(".tree-toggle");if(n){let t=n.closest(".tree-node");if(t){let e=t.dataset.elId,s=e&&this.elRefMap?this.elRefMap.get(parseInt(e)):null;if(t.classList.contains("collapsed")){t.classList.remove("collapsed"),t.classList.add("expanded");let e=t.dataset.treePath;e&&this.expandedTreePaths.add(e),s&&this.expandedElements.add(s);let i=t.querySelector(":scope > .tree-children");if(i&&i.dataset.lazyId){let t=parseInt(i.dataset.lazyId),e=this.treeNodeRegistry.get(t);if(e){let s="";if("html"===e.type)s=this.renderDomChildrenLazy(e.children,(t,s,i)=>this.renderHTMLTree(t,"",e.path+"."+s,i),e.depth||0,"html",{path:e.path}),e.shadow&&(s+=this.buildShadowLazy(e.shadow,"html",e.path,e.depth||0));else if("html-shadow"===e.type)s=this.renderDomChildrenLazy(e.children,(t,s,i)=>this.renderHTMLTree(t,"",e.path+".shadow."+s,i),e.depth||0,"html-shadow",{});else if("element"===e.type)s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element",{}),e.shadow&&(s+=this.buildShadowLazy(e.shadow,"element",null,e.depth||0,e.elId));else if("element-shadow"===e.type)s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element-shadow",{});else if(e.isJsonValue)s=this.renderJSONValueChildren(e.children);else{let t=new WeakSet;e.chain.forEach(e=>t.add(e)),t.add(e.obj);let i=e.children;if(i.length>200){let n=this.treeNodeRegId++;this.treeNodeRegistry.set(n,{children:i,chain:e.chain.concat([e.obj]),noProto:e.noProto}),s=this.renderTreeChildrenBatch(i,t,0,200,e.chain.concat([e.obj]),e.path||"",1,e.noProto)+'<div class="tree-load-more" data-reg-id="'+n+'" data-offset="200">'+this.icon("angle-down")+" 展开更多 (剩余 "+(i.length-200)+" 项)</div>"}else s=this.renderTreeChildrenBatch(i,t,0,i.length,e.chain.concat([e.obj]),e.path||"",1,e.noProto)}i.innerHTML=s,delete i.dataset.lazyId,this.treeNodeRegistry.delete(t)}}}else{t.classList.remove("expanded"),t.classList.add("collapsed");let e=t.dataset.treePath;e&&this.expandedTreePaths.delete(e),s&&this.expandedElements.delete(s)}let i=n.closest(".console-output, .ls-items");i&&this.vsRender(i)}}t.target===this.overlay&&(this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose"))}),this.filterButtons.forEach(t=>{t.addEventListener("click",()=>{this.filterButtons.forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.activeFilter=t.dataset.type,this.updateFilterCounts(),this.renderContent(),this.scrollFilterIntoView(this.filtersContainerEl,t)})}),this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>{t.addEventListener("click",()=>{this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.activeLSFilter=t.dataset.lsType,this.renderContent(),this.scrollFilterIntoView(this.lsFiltersContainer,t)})}),this.lsAddBtn&&this.lsAddBtn.addEventListener("click",()=>this.onAddLSClick()),this.logCopyBtn&&this.logCopyBtn.addEventListener("click",()=>{null!==this.selectedLogId?this.copyLog(this.selectedLogId,!1):this.showNotification("请先选中一条日志","warning")}),this.consoleOutput&&this.consoleOutput.addEventListener("click",t=>{let e=t.target.closest(".log-item");if(!e)return this.selectedLogId=null,this.consoleOutput.querySelectorAll(".log-item.selected").forEach(t=>t.classList.remove("selected")),void(this.logCopyBtn&&(this.logCopyBtn.style.display="none"));let s=parseInt(e.id.replace("log-item-",""));this.selectedLogId=s,this.consoleOutput.querySelectorAll(".log-item.selected").forEach(t=>t.classList.remove("selected")),e.classList.add("selected"),this.logCopyBtn&&(this.logCopyBtn.style.display="flex")}),this.searchInput.addEventListener("input",(t=>e=>{clearTimeout(t),t=setTimeout(()=>{if(this.searchQuery=e.target.value,"network"===this.currentTab)return this.renderNetworkList().trim(),this.renderContent()},300)})(0)),this.clearLogsBtn.addEventListener("click",()=>this.clearAllLogs()),this.searchToggleBtn.addEventListener("click",()=>this.toggleSearch()),this.lsEditorCancel.addEventListener("click",()=>this.closeLSEditor()),this.lsEditorSave.addEventListener("click",()=>this.onEditorSave()),this.muteBtn.addEventListener("click",()=>this.toggleMute()),this.lsEditorInput.addEventListener("input",()=>{this.editorState.value=this.lsEditorInput.value}),this.lsEditorKeyInput&&this.lsEditorKeyInput.addEventListener("input",()=>{this.editorState.key=this.lsEditorKeyInput.value.trim()}),this.setupFilterShadow(this.filtersContainerEl),this.setupFilterShadow(this.lsFiltersContainer),this.setupFilterShadow(this.netFiltersEl),this.setupGestures(),this.tabButtons.forEach(t=>{t.addEventListener("click",()=>{this.tabButtons.forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.currentTab=t.dataset.tab,this.renderContent()})})}renderFilters(){let t=this.overlay.querySelector("#filtersContainer");if(!t)return;this.filtersContainerEl=t;let e=this.options.filters;e&&e.length||(e=[{id:"all",name:"全部",icon:"list"},{id:"log",name:"日志",icon:"info"},{id:"info",name:"信息",icon:"info-circle"},{id:"warn",name:"警告",icon:"exclamation-triangle"},{id:"error",name:"错误",icon:"times-circle"}]),t.innerHTML=e.map((t,e)=>`<button class="filter-btn${0===e?" active":""}" title="${this.escapeHtml(t.name)}" data-type="${this.escapeHtml(t.id)}" data-icon="${this.escapeHtml(t.icon||"")}">${t.icon?this.icon(t.icon):""}${this.escapeHtml(t.name)}</button>`).join(""),t.querySelectorAll(".filter-btn").forEach(e=>{e.addEventListener("click",()=>{t.querySelectorAll(".filter-btn").forEach(t=>t.classList.remove("active")),e.classList.add("active"),this.activeFilter=e.dataset.type,this.updateFilterCounts(),this.renderContent()})})}createBuiltinTabs(){[{id:"console",name:"控制台",icon:"terminal"},{id:"network",name:"网络",icon:"wifi"},{id:"localstorage",name:"存储",icon:"database"},{id:"elements",name:"元素",icon:"code"}].forEach(t=>{let e=document.createElement("button");e.className="tab-btn",e.dataset.tab=t.id,e.title=t.name,e.innerHTML=this.icon(t.icon)+t.name,t.id===this.currentTab&&e.classList.add("active"),e.addEventListener("click",()=>{this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.tabButtons.forEach(t=>t.classList.remove("active")),e.classList.add("active"),this.currentTab=t.id,this.renderContent()}),this.tabButtonsContainer.appendChild(e)})}createPluginTab(t){let e=document.createElement("button");e.className="tab-btn",e.dataset.tab=t.id?t.id:"newTab",t.title=t.name?t.name:"新的插件",e.innerHTML=this.icon(t.icon||"plug")+(t.name||"新的插件"),this.tabButtonsContainer.appendChild(e),e.addEventListener("click",()=>{this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.tabButtons.forEach(t=>t.classList.remove("active")),e.classList.add("active"),this.currentTab=t.id,this.renderContent()});let s=document.createElement("div");s.id=`${t.id}View`,s.innerHTML="无插件视图",s.className="plug-view",s.style.display="none",this.contentArea.appendChild(s),this.pluginViewContainers[t.id]=s}createNotificationElement(){this.notification=document.createElement("div"),this.notification.id="notification",this.notification.className="notification",this.notification.style.display="none",this.shadowRoot.appendChild(this.notification)}createStyles(){let t=document.createElement("style");t.innerHTML=":host{all:initial}*{margin:0;padding:0;box-sizing:border-box}.floating-console-btn{position:fixed;z-index:99997;touch-action:none;will-change:transform;padding:15px 25px;backdrop-filter:blur(5px);border-radius:5px;border:none;background:#007aff;color:#fff;font-size:1rem;cursor:move;display:flex;align-items:center;gap:10px;font-weight:500;box-shadow:0 8px 20px rgba(0,0,0,.4);transition:all .3s ease;user-select:none}.floating-console-btn:active{transform:scale(.98)}.floating-console-btn .ico{font-size:1.2rem}.overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.85);display:flex;align-items:center;justify-content:center;z-index:99998;opacity:0;visibility:hidden;transition:all .4s ease;backdrop-filter:blur(5px)}.overlay.active{opacity:1;visibility:visible}.theme-dark{--selected-bg:rgba(74,74,230,.15);--console-bg:#1e1e1e;--header-bg:#252526;--text-color:#d4d4d4;--controls-bg:#2d2d2d;--border-color:rgba(255,255,255,0.05);--log-bg:#191919;--log-border-light:3px solid;--filter-active:#4a4ae6;--search-bg:#3e3e42;--json-bg:rgba(40,40,40,0.7);--json-key:#6aaeff;--json-tag:#5dade2;--json-string:#98c379;--json-number:#d19a66;--json-boolean:#56b6c2;--json-null:#be5046;--json-cmt:#707070;--action-bg:rgba(106,174,255,0.3);--action-hover:rgba(106,174,255,0.5);--log-icon-info:#4a4ae6;--log-bg-warn:rgba(255,193,7,0.1);--log-icon-warn:#d9a40d;--log-icon-error:#ff3b30;--clear-btn-color:#ff6b6b;--clear-btn-hover:#ff5252;--tab-bg:#333;--tab-active:#444;--tab-color:#ddd}.theme-light{--selected-bg:rgba(30,107,184,.08);--console-bg:#ffffff;--header-bg:#f0f0f0;--text-color:#333;--controls-bg:#e0e0e0;--border-color:rgba(0,0,0,0.1);--log-bg:#f3f3f3;--log-border-light:3px solid;--filter-active:#4a4ae6;--search-bg:#f0f0f0;--json-bg:rgba(240,240,240,0.9);--json-key:#1e6bb8;--json-tag:#2980b9;--json-string:#22863a;--json-number:#d73a49;--json-boolean:#005cc5;--json-null:#6f42c1;--json-cmt:#707070;--action-bg:rgba(30,107,184,0.1);--action-hover:rgba(30,107,184,0.2);--log-bg-warn:rgba(255,243,205,0.75);--log-icon-info:#1e6bb8;--log-icon-warn:#e36209;--log-icon-error:#d73a49;--clear-btn-color:#ff5252;--clear-btn-hover:#ff3b30;--tab-bg:#e5e5e5;--tab-active:#ddd;--tab-color:#333}.console-container{background:var(--console-bg);display:flex;flex-direction:column;box-shadow:0 15px 35px rgba(0,0,0,.3);position:fixed;z-index:99999;left:0;bottom:0;width:100%;height:90vh;transform:translateY(100%);transition:transform .4s cubic-bezier(.25,.8,.25,1)}.overlay.active .console-container{transform:translateY(0)}.overlay.no-anim .console-container{transition:none!important}.network-view{display:none;flex:1;overflow:hidden;flex-direction:column;position:relative}.net-disable-btn{display:inline-flex;align-items:center;justify-content:center;border:none;background:0 0;color:var(--text-color);cursor:pointer;font-size:14px;padding:5px 10px;border-radius:5px;white-space:nowrap;transition:all .2s;opacity:.55;flex-shrink:0;margin-left:auto}.net-disable-btn:hover{opacity:1}.net-disable-btn.disabled{opacity:1;color:var(--text-color);filter:none}.network-items{flex:1;overflow-y:auto;padding:8px 12px}.net-item{padding:12px 14px;margin-bottom:8px;background:var(--log-bg);border-left:3px solid var(--json-boolean);border-radius:6px;cursor:default;transition:background .2s}.net-item:hover{background:var(--selected-bg)}.net-item.net-failed{border-left-color:#ff5252}.net-item.net-success{border-left-color:#98c379}.net-item-header{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.net-row1{display:flex;align-items:center;gap:8px;margin-bottom:4px}.net-row2{display:flex;align-items:center;gap:8px;margin-bottom:6px}.net-row3{display:flex;gap:8px;align-items:center}.net-copy-btn,.net-detail-btn{display:inline-flex;align-items:center;gap:4px;padding:4px 10px;border:none;border-radius:4px;font-size:11px;cursor:pointer;transition:all .2s}.net-copy-btn{background:var(--action-bg);color:var(--json-key)}.net-copy-btn:hover,.net-detail-btn:hover{background:var(--action-hover)}.net-detail-btn{background:var(--action-bg);color:var(--json-key)}.net-method{font-size:10px;font-weight:700;padding:2px 6px;border-radius:3px;text-transform:uppercase}.net-method-GET{background:rgba(106,174,255,.2);color:var(--json-key)}.net-method-POST{background:rgba(152,195,121,.2);color:var(--json-string)}.net-method-PUT{background:rgba(255,193,7,.2);color:#ffc107}.net-method-DELETE{background:rgba(255,82,82,.2);color:#ff5252}.net-method-PATCH{background:rgba(255,152,0,.2);color:#ff9800}.net-method-HEAD{background:rgba(190,80,70,.2);color:var(--json-null)}.net-method-OPTIONS{background:rgba(112,112,112,.2);color:var(--json-cmt)}.net-url{flex:1;font-size:12px;color:var(--text-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:100px}.net-status{font-size:11px;font-weight:700;padding:2px 6px;border-radius:3px}.net-status-2xx{background:rgba(152,195,121,.2);color:#98c379}.net-status-3xx{background:rgba(106,174,255,.2);color:var(--json-key)}.net-status-4xx{background:rgba(255,152,0,.2);color:#ff9800}.net-status-5xx{background:rgba(255,82,82,.2);color:#ff5252}.net-status-pending{background:rgba(112,112,112,.2);color:var(--json-cmt)}.net-time{font-size:11px;color:var(--json-cmt);white-space:nowrap}.net-item-actions{display:flex;gap:4px;align-items:center}.net-action-btn{background:0 0;border:none;color:var(--json-cmt);cursor:pointer;font-size:13px;padding:2px 6px;border-radius:3px;transition:all .2s}.net-action-btn:hover{background:var(--action-bg);color:var(--json-key)}.net-detail-overlay,.net-detail-header,.net-back-btn{background:0 0;border:none;color:var(--text-color);cursor:pointer;font-size:16px;padding:4px 8px;border-radius:4px}.net-back-btn:hover{background:var(--action-bg)}.net-detail-overlay,.net-new-overlay{position:absolute;top:0;left:0;right:0;bottom:0;background:var(--console-bg);z-index:100;display:none;flex-direction:column}.net-detail-header,.net-new-header{display:flex;align-items:center;gap:8px;padding:3px 12px;background:var(--header-bg);border-bottom:1px solid var(--border-color)}.net-detail-title{flex:1;font-size:13px;color:var(--text-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.net-detail-body{flex:1;overflow-y:auto;padding:12px}.net-detail-section{margin-bottom:16px}.net-detail-label{font-size:11px;color:var(--json-cmt);text-transform:uppercase;margin-bottom:4px}.net-detail-value{font-size:13px;color:var(--text-color);word-break:break-all;background:var(--log-bg);padding:8px 10px;border-radius:4px}.net-detail-value textarea{width:100%;min-height:80px;background:var(--log-bg);border:1px solid var(--border-color);color:var(--text-color);border-radius:4px;padding:8px;font-size:12px;font-family:monospace;resize:vertical}.net-resend-btn{padding:6px 14px;border:none;background:var(--filter-active);color:#fff;cursor:pointer;border-radius:4px;font-size:12px;transition:all .2s}.net-resend-btn:hover{opacity:.85}.net-new-title{flex:1;font-size:14px;color:var(--text-color)}.net-new-body{flex:1;overflow-y:auto;padding:16px}.net-form-group{margin-bottom:14px}.net-form-label{font-size:12px;color:var(--json-cmt);margin-bottom:4px;display:block}.net-form-input,.net-form-select,.net-form-textarea{width:100%;background:var(--log-bg);border:1px solid var(--border-color);color:var(--text-color);border-radius:4px;padding:8px 10px;font-size:13px;font-family:monospace;outline:0;transition:border-color .2s}.net-form-input:focus,.net-form-select:focus,.net-form-textarea:focus{border-color:var(--filter-active)}.net-form-textarea{min-height:100px;resize:none}.net-form-select{cursor:pointer}.net-send-btn{padding:8px 20px;border:none;background:var(--filter-active);color:#fff;cursor:pointer;border-radius:4px;font-size:13px;transition:all .2s;margin-left:auto;display:block}.net-send-btn:hover{opacity:.85}.nolog{text-align:center;font-size:18px;color:var(--json-cmt);padding:40px 0;display:flex;align-items:center;justify-content:center;gap:5px}.nolog>.ico{font-size:1em;flex-shrink:0}.net-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--json-cmt);font-size:18px;gap:5px}.net-detail-section-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:4px}.net-detail-copy-section{background:0 0;border:none;color:var(--json-cmt);cursor:pointer;font-size:13px;padding:2px 6px;border-radius:3px;transition:all .2s}.net-detail-copy-section:hover{background:var(--action-bg);color:var(--json-key)}.net-detail-empty{color:var(--json-cmt);opacity:.5;font-style:italic}.net-detail-value.net-detail-code{font-family:monospace;white-space:pre-wrap;word-break:break-all;overflow-x:auto;max-height:400px}.net-detail-url-row{display:flex;align-items:center;gap:6px}.net-detail-url-copy{background:0 0;border:none;color:var(--json-cmt);cursor:pointer;font-size:13px;padding:2px 6px;border-radius:3px;transition:all .2s;flex-shrink:0}.net-detail-url-copy:hover{background:var(--action-bg);color:var(--json-key)}.net-detail-header-actions{display:flex;align-items:center;gap:4px;margin-left:auto}.net-resend-icon-btn{background:0 0;border:none;color:var(--text-color);cursor:pointer;font-size:16px;padding:4px 8px;border-radius:4px;transition:all .2s}.net-resend-icon-btn:hover{background:var(--action-bg);color:var(--json-key)}.net-new-btn-right{margin-left:auto;flex-shrink:0}.filters,.network-filters,.plug-view .filters{display:flex;flex-wrap:nowrap;gap:2px;margin-left:0;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin;position:relative;padding-bottom:2px;min-width:0;flex:0 1 auto;-webkit-overflow-scrolling:touch}.network-filters{flex:1 1 auto}.filter-btn,.net-filter-btn{position:relative;padding:5px 10px;border:none;background:0 0;color:var(--text-color);cursor:pointer;font-size:12px;display:flex;width:auto;white-space:nowrap;border-radius:4px;opacity:.55;transition:opacity .2s,background .2s;flex-shrink:0}.filter-btn>.ico,.net-filter-btn>.ico{margin-right:5px;margin-top:2px}.filter-btn:hover,.net-filter-btn:hover{opacity:1;background:rgba(127,127,127,.14)}.filter-btn.active,.net-filter-btn.active{opacity:1;font-weight:600;background:transparent}.filter-btn.active::after,.net-filter-btn.active::after{content:'';position:absolute;width:80%;left:10%;right:auto;top:auto;height:2px;bottom:0;border-radius:3px;background:var(--filter-active)}@media(min-width:769px){.overlay{flex-direction:row;align-items:stretch;justify-content:flex-end;background:transparent;backdrop-filter:none;opacity:1}.console-container{position:relative;left:auto;bottom:auto;width:50%;height:100%;transform:translateX(100%);flex-shrink:0}.overlay.active .console-container{transform:translateX(0)}.overlay::before{content:'';flex:1;cursor:pointer}.splitter{display:block;width:4px;background:var(--border-color);cursor:col-resize;flex-shrink:0;z-index:100001;position:relative;transform:translateX(100%);transition:transform .4s cubic-bezier(.25,.8,.25,1)}.overlay.active .splitter{transform:translateX(0)}.overlay.no-anim .splitter{transition:none!important}.splitter:hover,.splitter.dragging{background:var(--filter-active)}.console-header{padding:6px 15px}.console-title{font-size:16px}.header-icon-btn,.close-btn,.clear-all-btn{width:34px;height:34px;font-size:17px}.tabs{padding:2px 10px 0}.tab-btn{padding:8px 14px;font-size:14px}.controls{padding:4px 12px;flex-wrap:nowrap}.network-controls{padding:4px 12px;flex-wrap:nowrap}}@media(max-width:768px){.splitter{display:none}}@media(max-width:768px){.overlay{flex-direction:column;align-items:center;justify-content:center}.console-container{transform:translateY(100%)!important}.overlay.active .console-container{transform:translateY(0)!important}}.console-header{display:flex;justify-content:space-between;align-items:center;padding:8px 25px;background:var(--header-bg);border-bottom:1px solid var(--border-color);position:relative}.console-title{color:var(--text-color);gap:10px;display:flex;align-items:center;font-size:18px}.header-actions{display:flex;align-items:center;gap:2px}.header-icon-btn{background:0 0;border:none;color:var(--text-color);font-size:18px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.header-icon-btn:hover{background:rgba(106,174,255,0.2);color:var(--json-key)}.push-btn{border:none;background:var(--filter-active);color:#fff;padding:10px;border-radius:5px;font-size:10px}.close-btn{background:0 0;border:none;color:var(--text-color);font-size:20px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.close-btn:hover{background:rgba(255,100,100,.2);color:#ff6464;transform:scale(1.1)}.clear-all-btn{background:0 0;border:none;color:var(--text-color);font-size:20px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.clear-all-btn:hover,.clear-all-btn:active{background:rgba(255,100,100,.2);color:var(--clear-btn-hover)}.tabs{display:block;white-space:nowrap;overflow-x:auto;background:var(--tab-bg);padding:5px 10px 0;border-bottom:1px solid var(--border-color)}.tab-btn{padding:12px 20px;background:0 0;border-radius:5px 5px 0 0;border:none;color:var(--tab-color);cursor:pointer;position:relative;display:inline-flex;align-items:center;gap:8px}.tab-btn.active{color:var(--text-color);font-weight:600}.tab-btn.active::after{content:'';position:absolute;bottom:0;left:0;width:100%;height:2px;border-radius:3px;background:var(--filter-active)}.tab-btn:hover:not(.active){background:rgba(255,255,255,.05)}.controls{display:flex;padding:6px 15px;background:var(--controls-bg);gap:10px;flex-wrap:nowrap;border-bottom:1px solid var(--border-color);align-items:center;overflow-x:auto}.network-controls{display:flex;align-items:center;gap:8px;padding:6px 15px;background:var(--controls-bg);border-bottom:1px solid var(--border-color);flex-wrap:nowrap}.controls-float-toggle{display:none}.search-bar{display:flex;align-items:center;gap:8px;padding:10px 20px;background:var(--controls-bg);border-bottom:1px solid var(--border-color)}.search-input-wrap{display:flex;align-items:center;flex:1;position:relative}.search-bar-icon{position:absolute;left:10px;color:var(--text-color);opacity:.6;font-size:14px;pointer-events:none}.search-bar input{flex:1;padding:8px 10px 8px 35px;border-radius:5px;border:none;background:var(--search-bg);color:var(--text-color);transition:all .3s ease;font-size:14px;border:1px solid var(--border-color)}.search-bar input:focus{outline:0;border-color:#4a4ae6}.search-bar-close{background:0 0;border:none;color:var(--text-color);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:5px;opacity:.6;transition:all .3s}.search-bar-close:hover{opacity:1;background:rgba(255,255,255,.1)}.console-content{flex:1;overflow:auto;display:flex;flex-direction:column;position:relative}.console-output{flex:1;overflow-y:auto;padding:20px;font-family:monospace;font-size:.95rem}.localstorage-view{flex:1;padding:20px;font-family:monospace;font-size:.95rem;position:relative;overflow:hidden}.ls-items{position:absolute;inset:0;overflow-y:auto;padding:20px}.log-item{padding:8px 12px;margin-bottom:6px;display:flex;flex-direction:column;border-left:3px solid #4a4ae6;background:var(--log-bg);border-radius:5px;cursor:pointer;transition:background .2s;color:var(--text-color);user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}.log-item .log-icon .ico{color:inherit}.log-item.selected{border-left-color:var(--json-key);background:var(--selected-bg)}.log-item.log{border-left-color:#4a4ae6}.log-item.info{border-left-color:var(--log-icon-info)}.log-item.warn{border-left-color:var(--log-icon-warn);background:var(--log-bg-warn)}.log-item.error{border-left-color:var(--log-icon-error);background:rgba(255,59,48,.15)}.log-item.warn.selected,.log-item.error.selected{border-left-color:var(--json-key);background:var(--selected-bg)}.log-count{background:#4a4ae6;color:#fff;border-radius:4px;min-width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;font-size:11px;margin-right:4px;padding:0 5px;flex-shrink:0}.log-icon{flex-shrink:0;display:flex;align-items:center;font-size:13px;margin-right:2px}.log-header{display:flex;align-items:center;gap:0;margin-bottom:2px}.log-content{width:100%;font-size:13px;max-height:300px;overflow-y:auto;margin-top:4px;word-break:break-word;line-height:1.5;user-select:text;-webkit-user-select:text}.timestamp{color:var(--json-cmt);font-size:11px;margin-left:4px;white-space:nowrap}.json-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);border-radius:5px;white-space:pre!important;max-height:400px;overflow:auto}.json-tree-container{font-family:monospace;padding:2px 0;margin-top:2px;background:0 0;border-radius:0;max-height:300px;overflow:auto;font-size:12px;line-height:1.6}.tree-node{position:relative}.tree-node.collapsed>.tree-children{display:none}.tree-toggle{display:inline-block;width:9px;cursor:pointer;color:var(--json-cmt);text-align:center}.ico{display:inline-block;width:1em;height:1em;fill:currentColor;vertical-align:middle;flex-shrink:0}.tree-toggle>.ico{width:9px;height:9px}.tree-node.collapsed>.tree-toggle .ico-angle-down{display:none}.tree-node.expanded>.tree-toggle .ico-angle-right{display:none}.tree-spacer{display:inline-block;width:9px}.tree-leaf{white-space:pre}.tree-leaf-text{white-space:pre-wrap;word-break:break-all;max-height:8em;overflow-y:auto}.tree-label{color:var(--json-cmt)}.tree-children{margin-left:16px;padding-left:4px}.tree-brace{color:var(--json-cmt)}.tree-ellipsis{color:var(--json-cmt)}.tree-load-more{color:var(--json-cmt);cursor:pointer;padding:4px 0;user-select:none;font-size:11px}.tree-node.collapsed>.tree-open{display:none}.tree-node.collapsed>.tree-close{display:none}.tree-node.expanded>.tree-close{display:block;padding-left:16px}.tree-node.expanded>.tree-collapsed{display:none}.tree-node.collapsed>.tree-ellipsis{display:inline}.tree-node.expanded>.tree-ellipsis{display:none}.tree-node.collapsed>.tree-close-tag{display:inline}.tree-node.expanded>.tree-close-tag{display:inline}.json-page-btn,.ls-json-page-btn{border:none}.json-number{color:var(--json-number)}.json-boolean{color:var(--json-boolean)}.json-key{color:var(--json-key)}.json-tag{color:var(--json-tag)}.json-null{color:var(--json-null)}.json-string{color:var(--json-string)}.json-cmt{color:var(--json-cmt)}.log-actions{margin-top:8px;display:flex;gap:10px;font-size:10px}.log-action{color:var(--json-key);cursor:pointer;padding:5px 10px;background:var(--action-bg);transition:all .2s;display:inline-flex;align-items:center;gap:5px;border-radius:5px}.log-action:hover{background:var(--action-hover)}.log-action.copy-btn{background:var(--action-bg)}.log-action.copy-btn:hover{background:var(--action-hover)}.error-stack{font-family:monospace;padding:10px;margin-top:10px;background:rgba(255,59,48,.2);border-radius:5px;white-space:nowrap;font-size:.85rem;overflow:auto;max-height:400px}.object-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);color:var(--json-number);border-radius:5px;white-space:pre;max-height:600px;overflow:auto}.function-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);color:var(--json-boolean);border-radius:5px;white-space:pre;word-break:break-all;overflow-x:auto}.ls-header{padding:15px 0;display:flex;justify-content:flex-end}.ls-item{background:var(--log-bg);padding:15px;margin-bottom:15px;border-radius:8px}.ls-key-row{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;border-bottom:1px solid var(--border-color);padding-bottom:10px}.ls-key{color:var(--json-key);font-size:16px;max-width:60%;overflow-x:auto;white-space:nowrap}.ls-actions{display:flex;gap:8px}.ls-action-btn{background:var(--action-bg);border:none;color:var(--text-color);padding:5px 10px;border-radius:5px;cursor:pointer;transition:all .2s;display:flex;align-items:center;gap:5px}.ls-action-btn:hover{background:var(--action-hover)}.ls-value{white-space:normal;word-break:break-all;padding:10px;background:var(--json-bg);border-radius:5px;font-family:monospace;max-height:200px;overflow-y:auto;color:var(--text-color);font-size:13px}.ls-edit{display:flex;flex-direction:column;gap:10px;margin-top:10px;display:none}.ls-edit textarea{width:100%;min-height:100px;padding:10px;background:var(--search-bg);border:1px solid var(--border-color);border-radius:5px;color:var(--text-color);font-family:monospace;resize:vertical;outline:0;transition:all .3s ease;font-size:10px}.ls-edit textarea:focus{border-color:#4a4ae6}.ls-key-edit{display:none;width:60%;padding:6px 10px;border:1px solid var(--border-color);border-radius:5px;background:var(--search-bg);font-size:16px;outline:0;transition:border .2s;color:var(--json-key);font-family:monospace}.ls-key-edit:focus{border-color:#4a4ae6}.ls-item.editing .ls-key{display:none}.ls-item.editing .ls-key-edit{display:block}.ls-edit-actions{display:flex;gap:10px;justify-content:flex-end}.ls-value-type{font-size:8px;opacity:.7;margin-top:5px;color:var(--text-color)}.vs-spacer{width:100%;flex-shrink:0}.ls-editor-overlay{position:absolute;inset:0;z-index:100;display:flex;flex-direction:column;background:var(--console-bg)}.ls-editor-header{padding:12px 20px;background:var(--header-bg);border-bottom:1px solid var(--border-color)}.ls-editor-header-row{display:flex;align-items:center;gap:10px}.ls-editor-key-input{flex:1;padding:8px 12px;border:1px solid var(--border-color);border-radius:6px;background:var(--search-bg);color:var(--json-key);font-size:14px;font-family:monospace;outline:0;transition:border .2s}.ls-editor-key-input:focus{border-color:var(--filter-active)}.ls-editor-title{color:var(--text-color);font-size:15px;font-weight:600;white-space:nowrap}.ls-editor-body{flex:1;padding:15px 20px;overflow:hidden;display:flex}.ls-editor-body textarea{flex:1;width:100%;padding:12px;background:var(--search-bg);border:1px solid var(--border-color);border-radius:8px;color:var(--text-color);font-family:monospace;font-size:14px;resize:none;outline:0;transition:border .2s;line-height:1.5}.ls-editor-body textarea:focus{border-color:var(--filter-active)}.ls-editor-footer{display:flex;gap:10px;justify-content:flex-end;padding:12px 20px;background:var(--header-bg);border-top:1px solid var(--border-color)}.ls-editor-btn{padding:8px 24px;border:none;border-radius:6px;font-size:14px;cursor:pointer;transition:all .2s;font-weight:500}.ls-editor-btn.cancel{background:var(--controls-bg);color:var(--text-color)}.ls-editor-btn.cancel:hover{background:var(--action-hover)}.ls-editor-btn.save{background:var(--filter-active);color:#fff}.ls-editor-btn.save:hover{opacity:.85}.ls-editor-btn.run{background:var(--filter-active);color:#fff}.ls-editor-btn.run:hover{opacity:.85}.console-table-wrap{overflow-x:auto;margin-top:5px;-webkit-overflow-scrolling:touch;border-radius:8px;border:1px solid rgba(128,128,128,0.25)}.console-table{border-collapse:separate;border-spacing:0;width:100%;font-size:12px;font-family:monospace;overflow:hidden}.console-table th{background:var(--controls-bg);color:var(--json-key);padding:6px 10px;text-align:left;border-bottom:1px solid rgba(128,128,128,0.25);border-right:1px solid rgba(128,128,128,0.25);white-space:nowrap;position:sticky;top:0}.console-table td{padding:5px 10px;border-bottom:1px solid rgba(128,128,128,0.25);border-right:1px solid rgba(128,128,128,0.25);color:var(--text-color);white-space:nowrap;max-width:200px;overflow:hidden;text-overflow:ellipsis}.console-table tbody tr:nth-child(even){background:var(--log-bg)}.console-table tbody tr:hover{background:var(--action-bg)}.console-table th:last-child,.console-table td:last-child{border-right:none}.console-table tbody tr:last-child td{border-bottom:none}.ls-add-btn{font-size:18px!important;opacity:1!important;width:40px!important;height:40px!important;padding:0!important;margin-left:0!important}.mute-btn{background:0 0;border:none;color:var(--text-color);font-size:14px;cursor:pointer;padding:5px 8px;border-radius:5px;opacity:.6;transition:opacity .2s;margin-left:auto;flex-shrink:0}.mute-btn:hover{opacity:1}.mute-btn.muted{opacity:1;filter:saturate(2)}.elements-view{flex:1;overflow-y:auto;padding:10px;font-family:monospace;font-size:12px;line-height:1.6}.elements-tree .tree-node{white-space:normal;word-break:break-all}.el-header-btn{width:40px!important;height:40px!important;font-size:18px!important}.el-header-btn.el-delete-btn:hover{color:var(--clear-btn-color);background:rgba(255,100,100,.15)}.tree-node.el-highlight>.tree-label{display:inline-block!important;background:var(--action-hover)!important;border-radius:3px;padding:1px 4px}.tree-node.el-selected>.tree-label{display:inline-block!important;background:rgba(106,174,255,0.4);border-radius:3px;padding:1px 4px}.el-toolbar-actions{margin-left:auto;display:flex;gap:4px}.el-toolbar-btn{background:0 0;border:none;color:var(--text-color);cursor:pointer;padding:6px 10px;border-radius:5px;font-size:14px;opacity:.7;transition:all .2s}.el-toolbar-btn:hover{opacity:1;background:var(--action-bg)}.el-toolbar-btn.el-delete-btn:hover{color:var(--clear-btn-color);background:rgba(255,100,100,.15)}.element-picker-overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:100000;cursor:crosshair;background:transparent;pointer-events:none}@media(max-width:768px){.controls{flex-direction:row;align-items:center;padding:5px 10px;overflow-x:auto;flex-wrap:nowrap}.log-item{flex-wrap:nowrap}.log-actions{flex-wrap:wrap}.floating-console-btn{padding:12px 20px;font-size:.9rem;right:20px;bottom:20px}.tab-btn{padding:8px 12px;font-size:14px}.notification{position:fixed;top:20px;right:20px;padding:12px 20px;background:rgba(76,175,80,.6);backdrop-filter:blur(12px);color:#fff;border-radius:5px;box-shadow:0 2px 10px rgba(0,0,0,.2);z-index:99999;display:none;transform:translateX(150%);max-height:48px;max-width:calc(100vw - 40px);transition:transform .3s ease;font-size:15px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.notification.show{transform:translateX(0)}.notification.warning{background:rgba(255,152,0,.6);backdrop-filter:blur(12px)}.elements-tree .tree-leaf-text{max-height:12em}.nolog{text-align:center;font-size:20px;color:var(--json-cmt);padding:40px 0;display:flex;align-items:center;justify-content:center;gap:5px}}.network-controls{padding:5px 10px}}.overflow-scroll.overflow-start:not(.overflow-end){-webkit-mask-image:linear-gradient(to right,transparent,#000 40px);mask-image:linear-gradient(to right,transparent,#000 40px)}.overflow-scroll.overflow-end:not(.overflow-start){-webkit-mask-image:linear-gradient(to left,transparent,#000 40px);mask-image:linear-gradient(to left,transparent,#000 40px)}.overflow-scroll.overflow-start.overflow-end{-webkit-mask-image:linear-gradient(to right,transparent,#000 40px,#000 calc(100% - 40px),transparent);mask-image:linear-gradient(to right,transparent,#000 40px,#000 calc(100% - 40px),transparent)}.tree-toggle>.ico{font-size:10px;color:var(--json-cmt);transition:transform .2s;cursor:pointer;width:9px;height:9px;text-align:center;display:inline-block}.network-view{display:none;flex:1;overflow:hidden;flex-direction:column;position:relative}",t.setAttribute("tcstyle",""),t.setAttribute("tc-lock",""),this.shadowRoot.append(t)}setupSplitter(){let t=!1,e=0,s=0,i=()=>{t=!1,this.splitter.classList.remove("dragging"),document.body.style.cursor="",document.body.style.userSelect=""};this.splitter.addEventListener("mousedown",i=>{i.preventDefault(),t=!0,e=i.clientX,s=this.consoleContainer.offsetWidth||.5*window.innerWidth,this.splitter.classList.add("dragging"),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}),document.addEventListener("mousemove",i=>{if(!t)return;let n=i.clientX,o=window.innerWidth-(s+(e-n));o=Math.max(200,Math.min(window.innerWidth-50,o)),this.consoleContainer&&(this.consoleContainer.style.width=o+"px",this.consoleContainer.style.flex="none")}),document.addEventListener("mouseup",i),this.splitter.addEventListener("touchstart",e=>{e.preventDefault(),t=!0,s=this.consoleContainer.offsetWidth||.5*window.innerWidth,e.touches[0],this.splitter.classList.add("dragging")}),document.addEventListener("touchmove",e=>{if(!t)return;let s=e.touches[0],i=window.innerWidth-s.clientX;i=Math.max(200,Math.min(window.innerWidth-50,i)),this.consoleContainer&&(this.consoleContainer.style.width=i+"px",this.consoleContainer.style.flex="none")}),document.addEventListener("touchend",i)}showNotification(t,e=""){this.notification.innerHTML='<span style="display:inline-block;vertical-align:middle;margin-right:8px">'+this.icon("warning"==e?"exclamation":"check")+"</span>"+t.replace(/</,"<").replace(/>/,">"),this.notification.className="notification","warning"===e&&this.notification.classList.add("warning"),this.notification.style.display="block",this.notification.offsetHeight,this.notification.classList.add("show"),clearTimeout(this._notifTimer),this._notifTimer=setTimeout(()=>{this.notification.classList.remove("show"),setTimeout(()=>{this.notification.style.display="none"},300)},3e3)}captureConsoleLogs(){this.originalConsole={log:console.log,info:console.info,warn:console.warn,error:console.error,debug:console.debug,time:console.time,timeEnd:console.timeEnd,count:console.count,countReset:console.countReset,assert:console.assert,trace:console.trace,group:console.group,groupEnd:console.groupEnd,clear:console.clear,table:console.table},console.log=(...t)=>(this.captureConsole("log",...t),console),console.info=(...t)=>(this.captureConsole("info",...t),console),console.warn=(...t)=>(this.captureConsole("warn",...t),console),console.error=(...t)=>(this.captureConsole("error",...t),console),console.debug=(...t)=>(this.captureConsole("log",...t),console),console.table=(t,e)=>(this._captureSubType="table",this._captureExtra={columns:e},this.captureConsole("log",t),this._captureSubType=null,this._captureExtra=null,console),console.time=(t="time")=>{t=String(t);let e=performance.now();this.timerMap.has(t)&&clearTimeout(this.timerMap.get(t).timeoutId);let s=setTimeout(()=>{if(!this.timerMap.has(t))return;let{start:e}=this.timerMap.get(t);this.timerMap.delete(t),console.info(`[time] "${t}"用时: ${(performance.now()-e).toFixed(1)}ms(已超时)`)},3e5);this.timerMap.set(t,{start:e,timeoutId:s}),console},console.timeEnd=(t="time")=>{t=String(t);let e=this.timerMap.get(t);if(!e)return void console.error(`[timeEnd] 标签"${t}"不存在`);e.timeoutId&&clearTimeout(e.timeoutId);let s=performance.now()-e.start;this.timerMap.delete(t),console.info(`[time] "${t}"用时: ${s.toFixed(1)}ms`),console},console.count=(t="count")=>{t=String(t);let e=(this.countMap.get(t)||0)+1;this.countMap.set(t,e),console.info(`[count] 标签"${t}"被调用了${e}次`),console},console.countReset=(t="count")=>{t=String(t),this.countMap.has(t)?this.countMap.delete(t):console.error(`[countReset] 标签"${t}"不存在`),console},console.assert=(t,...e)=>{t||console.error("[assertion failed] ",...e),console},console.trace=(...t)=>{let e=(new Error).stack.split("\n").slice(2).join("\n");console.warn("[trace] ",...t,"\n"+e),console},console.group=t=>(this.captureConsole("log",`[Group ${t}]`),console),console.groupEnd=()=>(this.captureConsole("log","[GroupEnd]"),console),console.clear=()=>(this.clearAllLogs(!0),console)}isClass(t){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t&&!1===Object.getOwnPropertyDescriptor(t,"prototype").writable}renderFunctionInline(t){let e=t.name||"anonymous",s=this.getParams(t);return'<span class="json-boolean">ƒ '+this.escapeHtml(e)+'</span><span class="json-cmt">('+this.escapeHtml(s)+")</span>"}renderFunctionCollapsed(t){let e=t.name||"anonymous",s=this.getParams(t);return'<span class="json-boolean">ƒ '+this.escapeHtml(e)+'</span><span class="json-cmt">('+this.escapeHtml(s)+")</span>"}safeStringify(t,s=2,i=!0){let n=new WeakSet,o=(t,e=new WeakSet)=>null===t||"object"!=typeof t?"bigint"==typeof t?""+t.toString()+"n":t:e.has(t)?"[循环引用]":(e.add(t),t instanceof RegExp?""+t.toString():t instanceof Date?""+t.toISOString():"function"==typeof t?this.isClass(t)?"[Class "+(t.name||"anonymous")+"]":"ƒ "+(t.name||"anonymous")+"("+this.getParams(t)+")":t instanceof Error?"[Error: "+t.message+"]":t instanceof ArrayBuffer?"[ArrayBuffer "+t.byteLength+" bytes]":t instanceof WeakMap?"[WeakMap]":t instanceof WeakSet?"[WeakSet]":t instanceof Map?"[Map "+t.size+"]":t instanceof Set?"[Set "+t.size+"]":Array.isArray(t)?t.map(t=>o(t,e)):(()=>{let s={};try{Reflect.ownKeys(t).forEach(i=>{let n=Object.getOwnPropertyDescriptor(t,i);if(n){let r="symbol"==typeof i?"["+i.toString()+"]":String(i);if("value"in n)s[r]=o(n.value,e);else if(n.get)try{s[r]=o(n.get.call(t),e)}catch{s[r]="[getter]"}}})}catch{}let n=Object.getPrototypeOf(t);return i&&n&&null!==n&&(s["[[Prototype]]"]=o(n,e)),s})());return t=o(t),JSON.stringify(t,function(t,s){if(void 0===s)return"undefined";if("number"==typeof s){if(Number.isNaN(s))return"NaN";if(!isFinite(s))return""+(s>0?"Infinity":"-Infinity")}if("object"==typeof s&&null!==s){if(n.has(s))return"[循环引用]";if(n.add(s),!Array.isArray(s)&&s.constructor===Object)return Object.keys(s).sort((t,e)=>{let s="[[Prototype]]"===t,i="[[Prototype]]"===e,n=t.endsWith("[[Prototype]]")&&"[[Prototype]]"!==t,o=e.endsWith("[[Prototype]]")&&"[[Prototype]]"!==e;if(s&&!i)return 1;if(!s&&i)return-1;if(n&&!o)return 1;if(!n&&o)return-1;let r=t.match(/^(_*)/)[0].length,l=e.match(/^(_*)/)[0].length;return r!==l?r-l:t.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"})}).reduce((t,e)=>(t[e]=s[e],t),{});if(s instanceof Error)return{"名称":s.name,"信息":s.message,"堆栈":s.stack};if(s instanceof Date)return s.toISOString();if(s instanceof HTMLElement)return`<${s.tagName.toLowerCase()}>${s.tagName.toLowerCase()}元素</${s.tagName.toLowerCase()}>`}return"string"==typeof s?s.startsWith("")?s:""+s:"function"==typeof s?""+(e.tC.isClass(s)?`[Class ${s.name||"anonymous"}]`:`ƒ ${s.name||"anonymous"}(${e.tC.getParams(s)})`):s},s)}formatArgsForPlainText(t){return Array.from(t).map(t=>{if("function"==typeof t)return this.isClass(t)?`[Class ${t.name||"anonymous"}]`:`ƒ ${t.name||"anonymous"}(${this.getParams(t)})`;if("object"==typeof t&&null!==t)try{return this.safeStringify(t)}catch{return"无法序列化]"}return String(t)}).join(" ")}captureConsole(t,...e){if(this._capturing)this.originalConsole[t].apply(console,e);else{this._capturing=!0;try{this.triggerGlobalHook("beforeLog",t,...e);let s=!1;if(this.mutedFilters.console&&(this.mutedFilters.console.all||this.mutedFilters.console[t])&&(s=!0),this.mutedLogs||s)return void this.originalConsole[t].apply(console,e);let i=new Date,n=e.map(t=>{if("object"==typeof t&&null!==t)try{if(t instanceof HTMLElement)return`el:<${t.tagName.toLowerCase()}>`;if(t instanceof Date)return`d:${t.getTime()}`;if(t instanceof RegExp)return`re:${t.toString()}`;if(t instanceof Error)return`e:${t.message}`;let e=Object.entries(t).reduce((t,[e,s])=>{if("then"===e&&"function"==typeof s)return t;if("object"==typeof s&&null!==s)try{t[e]=JSON.stringify(s)}catch{t[e]="NestedObject"}else t[e]=s;return t},{});return`o:${JSON.stringify(e)}`}catch{return`u:${Math.random().toString(36).substring(2,10)}`}return`${typeof t}:${String(t)}`}).join("|");if(this.lastLog&&this.lastLog.type===t&&this.lastLog.contentSign===n&&(this.lastLog.subType||null)===(this._captureSubType||null)&&!e.some(t=>"object"==typeof t&&null!==t)){if(this.lastLog.args=[...e],this.lastLog.timestamp=new Date,this.lastLog.count++,e.some(t=>"object"==typeof t&&null!==t)){let t=this.safeStringify(e[0]);this.jsonPageIndex.has(t)||(this.jsonPageIndex.set(t,0),this.getPagedJson(e[0],0))}let s=this.shadowRoot.getElementById(`log-item-${this.lastLog.id}`);if(s){let t=s.querySelector(".log-count");if(t)t.textContent=this.lastLog.count;else{let t=s.querySelector(".log-header");if(t){let e=document.createElement("div");e.className="log-count",e.textContent=this.lastLog.count;let s=t.querySelector(".log-icon");s?t.insertBefore(e,s):t.appendChild(e)}}}return this.originalConsole[t].apply(console,e),void this.updateFilterCounts()}{let s={id:this.logs.length,type:t,args:[...e],content:this.formatArgsForPlainText(e),timestamp:i,count:1,expandedJson:!1,contentSign:n,hasObject:e.some(t=>"function"==typeof t),isError:"error"===t||e.some(t=>t instanceof Error),subType:this._captureSubType||null,subTypeData:this._captureExtra||null};this.logs.push(s),this.lastLog=s,this.triggerGlobalHook("afterLog",s)}this.originalConsole[t].apply(console,e),this.overlay?.classList.contains("active")&&"console"===this.currentTab&&(this.updateFilterCounts(),this.renderLogList(this.logs,!1)),this.logs.length>this.maxLog&&this.logs.splice(0,this.logs.length-this.maxLog)}finally{this._capturing=!1}}}formatArgs(t,e){let s=e||"x",i=Array.from(t),n=i.map((t,e)=>"function"==typeof t?`<div class="function-preview">${this.escapeHtml(t.toString())}</div>`:t instanceof Error?`<div class="error-stack"><strong>${t.name}:</strong>${t.message}<div>${t.stack||"无堆栈信息"}</div></div>`:t instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(t,"",s+":html")+"</div>":t instanceof Date?`<div class="json-preview"><span class="json-string">${t.toISOString()}</span></div>`:t instanceof RegExp?`<div class="json-preview"><span class="json-number">${t.toString()}</span></div>`:t instanceof Map?`<div class="json-preview"><span class="json-boolean">[Map ${t.size}]</span></div>`:t instanceof Set?`<div class="json-preview"><span class="json-boolean">[Set ${t.size}]</span></div>`:t instanceof WeakMap?'<div class="json-preview"><span class="json-boolean">[WeakMap]</span></div>':t instanceof WeakSet?'<div class="json-preview"><span class="json-boolean">[WeakSet]</span></div>':t instanceof ArrayBuffer?`<div class="json-preview"><span class="json-boolean">[ArrayBuffer ${t.byteLength} bytes]</span></div>`:"bigint"==typeof t?`<span class="json-number">${t.toString()}n</span>`:"object"==typeof t&&null!==t?'<div class="json-tree-container">'+this.renderJSONTree(t,"",null,null,s+":",0)+"</div>":"number"==typeof t?Number.isNaN(t)?'<span class="json-cmt">NaN</span>':isFinite(t)?`<span class="json-number">${t}</span>`:`<span class="json-cmt">${t>0?"Infinity":"-Infinity"}</span>`:"boolean"==typeof t?`<span class="json-boolean">${t}</span>`:String(t).replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>"));return i.splice(0,1),n.join(" ")}highlightHTML(t){let e=t.outerHTML.replace(/</g,"<").replace(/>/g,">").replace(/<br>/g,"<br>"),s="",i=0;for(;i<e.length;)if(e.startsWith("<",i)){let t=e[i+4];if(t&&("/"===t||/[a-zA-Z]/.test(t))){let t=e.indexOf(">",i);if(-1!==t){let n=e.slice(i,t+4);n=n.replace(/([\w-]+)(=)("[^"]*")/g,'<span class="json-tag">$1</span><span class="json-boolean">$2</span><span class="json-string">$3</span>'),n=n.replace(/^(<\/?)([\w-]+)/,'<span class="json-tag">$1</span><span class="json-tag">$2</span>'),n=n.replace(/(>)$/,'<span class="json-tag">$1</span>'),s+=n,i=t+4;continue}}let n=e.indexOf("<",i+4);-1===n&&(n=e.length);let o=e.slice(i,n);s+=o.trim()?`<span class="json-cmt">${o}</span>`:o,i=n}else if(e.startsWith("<br>",i))s+="<br>",i+=4;else{let t=e.indexOf("<",i);-1===t&&(t=e.length);let n=e.slice(i,t);s+=n.trim()?`<span class="json-cmt">${n}</span>`:n,i=t}return s}highlightJson=t=>t&&t.replace(/("(?:\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(?:\s*:)?|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b|[\{\}\[\],.:])/g,t=>{let e="json-cmt";if("true"===t||"false"===t)e="json-boolean";else if("null"===t)e="json-null";else if(/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(t))e="json-number";else if(t.endsWith(":"))e="json-key";else if(t.startsWith('"')){let s=t.slice(1,-1);if(/^\\u0002/.test(s))return`<span class="json-string">"${s.slice(6)}"</span>`;if(/^\\u0003/.test(s)){let t=s.slice(6);if(/^-?\d+n$/.test(t))return`<span class="json-number">${t}</span>`;if(/^\u0192\s/.test(t)){let e=t.match(/^(\u0192\s+\S+)(\(.*\))$/);return e?`<span class="json-boolean">${e[1]}</span><span class="json-cmt">${e[2]}</span>`:`<span class="json-boolean">${t}</span>`}return/^\[(?:Class|ArrayBuffer|Map|Set|WeakMap|WeakSet|Error)/.test(t)?`<span class="json-boolean">${t}</span>`:/^\/.*\/[gimsuy]*$/.test(t)?`<span class="json-number">${t}</span>`:/^\d{4}-\d{2}-\d{2}T/.test(t)?`<span class="json-string">${t}</span>`:/^(?:undefined|NaN|Infinity|-Infinity)$/.test(t)?`<span class="json-null">${t}</span>`:`<span class="json-string">${t}</span>`}e="json-string"}return`<span class="${e}">${t}</span>`})||"";getJsonKeys(t){return Array.isArray(t)?t.map((t,e)=>e):"object"==typeof t&&null!==t?Object.keys(t):[]}renderJSONValue(t,e){if(null===t)return'<span class="json-null">null</span>';if(void 0===t)return'<span class="json-null">undefined</span>';if("string"==typeof t)return'<span class="json-string">"'+this.escapeHtml(t)+'"</span>';if("number"==typeof t)return'<span class="json-number">'+t+"</span>";if("boolean"==typeof t)return'<span class="json-boolean">'+t+"</span>";if("function"==typeof t){if(this.isClass(t)){let e=t.name||"anonymous";return'<span class="json-boolean">[Class '+this.escapeHtml(e)+"]</span>"}return this.renderFunctionInline(t)}if(t instanceof HTMLElement){let e=t.tagName.toLowerCase();return'<span class="json-tag"><'+e+">...</"+e+"></span>"}let s=Array.isArray(t),i=s?"Array("+t.length+")":"Object",n=s?t.map((t,e)=>({name:String(e),value:t})):Object.keys(t).map(e=>({name:e,value:t[e]}));if(0===n.length)return'<span class="json-cmt">'+(e?this.escapeHtml(e)+": ":"")+(s?"[]":"{}")+"</span>";let o='<div class="tree-node collapsed">';o+=this.treeToggleHtml(),e&&(o+='<span class="json-key">'+this.escapeHtml(e)+":</span> "),o+='<span class="tree-label">'+this.escapeHtml(i)+"</span>",o+='<span class="tree-brace tree-open">{</span><span class="tree-brace tree-collapsed">{...}</span>';let r=++this.treeNodeRegId;return this.treeNodeRegistry.set(r,{obj:t,children:n,isJsonValue:!0}),o+='<div class="tree-children" data-lazy-id="'+r+'"></div>',o+='<span class="tree-brace tree-close">}</span>',o+="</div>",o}renderJSONValueChildren(t,e){let s="";for(let e of t){let t=e.value;s+=null===t||"object"!=typeof t?'<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(e.name)+":</span> "+this.renderJSONValue(t,"")+"</div>":"<div>"+this.renderJSONValue(t,e.name)+"</div>"}return s}getPagedJson(t,e){let s=this.safeStringify(t);if(!this.jsonPageCache.has(s)){let e=this.getJsonKeys(t),i=[];for(let t=0;t<e.length;t+=this.jsonPageSize)i.push(e.slice(t,t+this.jsonPageSize));this.jsonPageCache.set(s,i)}let i=this.jsonPageCache.get(s)[e]||[];if(Array.isArray(t))return i.map(e=>t[e]);{let e={};return i.forEach(s=>e[s]=t[s]),e}}changeJsonPage(t,e){let s=`log-${t}`;this.jsonPageIndex.set(s,e);let i=this.logs.find(e=>e.id===t);if(i){let e=this.consoleOutput;e&&e._vs?(e._vs.heights=new Map,e._vs.lastStart=-1,e._vs.lastEnd=-1,this.vsRender(e)):this.updateLogItem(t,!1)}}toggleExpandJson(t){let e=this.logs.find(e=>e.id===t);e&&(e.expandedJson=!e.expandedJson,this.updateLogItem(t,!1))}updateLogItem(t,e=!1){let s=this.logs.find(e=>e.id===t);if(!s)return;let i=this.shadowRoot.getElementById(`log-item-${t}`);if(!i)return;let n={info:"info-circle",warn:"exclamation-triangle",error:"times-circle",log:"info"}[s.type]||"info",o=s.timestamp.toLocaleTimeString(),r=s.expandedJson?this.formatArgs(s.args,s.id):this.renderLogContent(s);i.innerHTML=`<div class="log-header">${s.count>1?`<div class="log-count">${s.count}</div>`:""}<div class="log-icon">${this.icon(n)}</div><div class="timestamp">${o}</div></div><div class="log-content">${r}</div>${s.hasObject?`<div class="log-actions"><div class="log-action expand-btn" title="${s.expandedJson?"收起":"展开"}" onclick="thinConsole.tC.toggleExpandJson(${s.id})">${this.icon(s.expandedJson?"chevron-up":"chevron-down")}${s.expandedJson?"收起":"展开"}</div></div>`:""}</div>`}updateControlsVisibility(){let c=this.currentTab,e="console"===c,s="localstorage"===c,i="network"===c,l="elements"===c,_=(t,v)=>{t&&(t.style.display=v)};_(this.consoleControls,e||s?"flex":"none"),_(this.filtersContainerEl,e?"flex":"none"),_(this.lsFiltersContainer,s?"flex":"none"),_(this.muteBtn,e?"flex":"none"),_(this.logCopyBtn,e&&null!==this.selectedLogId?"flex":"none"),_(this.lsAddBtn,s?"flex":"none"),_(this.netNewBtn,i?"flex":"none"),_(this.elementPickBtn,l?"flex":"none"),_(this.elCopyBtn,l?"flex":"none"),_(this.elDeleteBtn,l?"flex":"none"),_(this.searchBar,l?"none":this.searchExpanded?"flex":"none"),_(this.searchToggleBtn,l?"none":"flex"),this.updateEditorVisibility()}updateEditorVisibility(){if(!this.lsEditorOverlay)return;let t=this.editorState.visible;if(t&&"ls"===this.editorState.mode&&"localstorage"!==this.currentTab&&(t=!1),this.lsEditorOverlay.style.display=t?"flex":"none",t){let t="code"===this.editorState.mode;this.lsEditorKeyInput&&(this.lsEditorKeyInput.style.display=t?"none":"block"),this.lsEditorTitle.textContent=t?"运行代码":"",this.lsEditorInput.placeholder=t?"输入要执行的代码...":"输入值...",this.lsEditorSave.textContent=t?"运行":"保存",this.lsEditorSave.className="ls-editor-btn "+(t?"run":"save"),this.lsEditorInput.value!==this.editorState.value&&(this.lsEditorInput.value=this.editorState.value),!t&&this.lsEditorKeyInput&&this.lsEditorKeyInput.value!==this.editorState.key&&(this.lsEditorKeyInput.value=this.editorState.key)}}vsInit(t){if(!t)return;t._vs={items:[],renderItem:null,afterRender:null,avgHeight:70,estHeight:70,heights:new Map,lastStart:-1,lastEnd:-1,rafId:null,isAtBottom:!0,contentEl:null,topSpacer:null,bottomSpacer:null,fakeEl:null,hasStructure:!1,topSpaceHeight:0,lastScrollTop:0,lastTimestamp:0,speedToleranceFactor:100,maxSpeedTolerance:2e3,minSpeedTolerance:100};let e=document.createElement("div");e.className="vs-spacer",e.style.cssText="width:100%;flex-shrink:0;height:0";let s=document.createElement("div");s.className="vs-content",s.style.cssText="width:100%";let i=document.createElement("div");i.className="vs-spacer",i.style.cssText="width:100%;flex-shrink:0;height:0";let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:0;top:0;width:100%;pointer-events:none",t.innerHTML="",t.appendChild(e),t.appendChild(s),t.appendChild(i),t.appendChild(n),t._vs.topSpacer=e,t._vs.contentEl=s,t._vs.bottomSpacer=i,t._vs.fakeEl=n,t._vs.hasStructure=!0,t._vs.scrollHandler=()=>{let e=t._vs;if(!e)return;let s=t.scrollHeight,i=t.clientHeight,n=t.scrollTop;e.isAtBottom=Math.abs(s-i-n)<2;let o,r,l=Date.now(),a=l-e.lastTimestamp,c=n-e.lastScrollTop,d=Math.abs(c/(a||1))*e.speedToleranceFactor;a>1e3&&(d=1e3),d>e.maxSpeedTolerance&&(d=e.maxSpeedTolerance),d<e.minSpeedTolerance&&(d=e.minSpeedTolerance),e.lastScrollTop=n,e.lastTimestamp=l,e.lastScrollTop<n?(o=e.minSpeedTolerance,r=d):(o=d,r=e.minSpeedTolerance),e.topSpaceHeight<n-o&&e.topSpaceHeight+e.contentEl.offsetHeight>n+i+r||e.rafId||(e.rafId=requestAnimationFrame(()=>{e.rafId=null,this.vsRender(t)}))},t.addEventListener("scroll",t._vs.scrollHandler,{passive:!0})}vsRender(t){let e=t._vs;if(!e||!e.contentEl)return;if(!e.items||!e.items.length)return;let ch=e.contentEl.children;if(ch.length>0){let ct=0;for(let ci=0;ci<ch.length;ci++){let ch2=ch[ci].offsetHeight+10;e.heights.set(e.lastStart+ci,ch2),ct+=ch2}let ca=ct/ch.length;ca>20&&ca<2e3&&(e.avgHeight=Math.round(.5*e.avgHeight+.5*ca))}let s=t.clientHeight||400,i=t.scrollTop,n=e.avgHeight||70;n<10&&(n=70);let o=600,r=i-o,l=i+s+o,a=0,c=0,d=0,h=e.items.length,p=!1;for(let t=0;t<e.items.length;t++){let s=e.heights.get(t)||n;if(!p&&a+s>=r&&(d=t,p=!0),a>=l){h=t;break}a+=s}if(p){if(h===e.items.length){h=e.items.length;let t=h;for(;t>d&&c<s+o;)t--,c+=e.heights.get(t)||n;d=Math.max(0,Math.min(d,t))}}else d=0;let u=!1;for(let t=d;t<h;t++)if(!e.heights.has(t)){u=!0;break}if(u&&e.fakeEl){let s=e.fakeEl,i=t.clientWidth;i>0&&(s.style.width=i+"px");for(let t=d;t<h;t++)if(!e.heights.has(t)){s.innerHTML=e.renderItem(e.items[t],t);let i=0;s.firstChild&&(i=s.firstChild.offsetHeight+10),i<10&&(i=n),e.heights.set(t,i)}s.innerHTML=""}a=0,c=0,d=0,h=e.items.length,p=!1;for(let t=0;t<e.items.length;t++){let s=e.heights.get(t)||n;if(!p&&a+s>=r&&(d=t,p=!0),a>=l){h=t;break}a+=s}if(p){if(h===e.items.length){h=e.items.length;let t=h;for(;t>d&&c<s+o;)t--,c+=e.heights.get(t)||n;d=Math.max(0,Math.min(d,t))}}else d=0;if(d===e.lastStart&&h===e.lastEnd){let th=0;for(let ti=0;ti<d;ti++)th+=e.heights.get(ti)||n;let bh=0;for(let bi=h;bi<e.items.length;bi++)bh+=e.heights.get(bi)||n;e.topSpacer.style.height=th+"px",e.bottomSpacer.style.height=bh+"px",e.topSpaceHeight=th,0===bh&&e.isAtBottom&&(t.scrollTop=1e7);return}e.lastStart=d,e.lastEnd=h;let g=0;for(let t=0;t<d;t++)g+=e.heights.get(t)||n;let f=0;for(let t=h;t<e.items.length;t++)f+=e.heights.get(t)||n;let m=t.scrollTop;e.topSpacer.style.height=g+"px",e.bottomSpacer.style.height=f+"px",e.topSpaceHeight=g;let b=document.createDocumentFragment();for(let t=d;t<h;t++){let s=document.createElement("div");for(s.innerHTML=e.renderItem(e.items[t],t);s.firstChild;)b.appendChild(s.firstChild)}e.contentEl.replaceChildren?e.contentEl.replaceChildren(b):(e.contentEl.innerHTML="",e.contentEl.appendChild(b));let y=e.contentEl.children;if(y.length>=1){let t=0;for(let s=0;s<y.length;s++){let i=y[s].offsetHeight+10;t+=i,Math.abs(i-(e.heights.get(d+s)||n))>5&&e.heights.set(d+s,i)}let s=Math.round(t/y.length);s>20&&s<2e3&&(e.avgHeight=Math.round(.5*e.avgHeight+.5*s))}if(0===f&&y.length>0){let t=0;for(let e=0;e<y.length;e++)t+=y[e].offsetHeight+10;if(t<s&&d>0){let i=Math.ceil((s-t)/n)+2,o=Math.max(0,d-i);if(o<d){d=o,e.lastStart=d;let t=0;for(let s=0;s<d;s++)t+=e.heights.get(s)||n;e.topSpacer.style.height=t+"px",e.topSpaceHeight=t;let s=document.createDocumentFragment();for(let t=d;t<h;t++){let i=document.createElement("div");for(i.innerHTML=e.renderItem(e.items[t],t);i.firstChild;)s.appendChild(i.firstChild)}e.contentEl.replaceChildren?e.contentEl.replaceChildren(s):(e.contentEl.innerHTML="",e.contentEl.appendChild(s));let i=e.contentEl.children;if(i.length>=1){let t=0;for(let s=0;s<i.length;s++){let o=i[s].offsetHeight+10;t+=o,Math.abs(o-(e.heights.get(d+s)||n))>5&&e.heights.set(d+s,o)}let s=Math.round(t/i.length);s>20&&s<2e3&&(e.avgHeight=Math.round(.5*e.avgHeight+.5*s))}}}}let v=0;for(let t=0;t<d;t++)v+=e.heights.get(t)||n;let x=0;for(let t=h;t<e.items.length;t++)x+=e.heights.get(t)||n;e.topSpacer.style.height=v+"px",e.bottomSpacer.style.height=x+"px",e.topSpaceHeight=v,e.isAtBottom||m===t.scrollTop||(t.scrollTop=m),e.afterRender&&e.afterRender()}vsUpdate(t,e,s,i,n){let o=t._vs;if(!o)return;if(o.rafId)cancelAnimationFrame(o.rafId),o.rafId=null;let g=n&&n.trackBy?(o.trackBy=n.trackBy):o.trackBy||(t=>t.id);if(!e||!e.length){o.items=[],o.heights=new Map,o.lastStart=-1,o.lastEnd=-1;if(o.contentEl){o.topSpacer.style.height="0",o.bottomSpacer.style.height="0",o.topSpaceHeight=0,o.contentEl.innerHTML=n&&n.emptyHTML||"",!(n&&n.preserveScroll)&&(t.scrollTop=0),o.isAtBottom=!0}else t.innerHTML=n&&n.emptyHTML||"";return}let r=n&&(n.force||n.preserveScroll)?!1:(o.isAtBottom=Math.abs(t.scrollHeight-t.clientHeight-t.scrollTop)<2),l=o.items?o.items.length:0,a=l>0&&o.items[0]&&e[0]&&g(o.items[0])!==g(e[0]);o.items=e,o.renderItem=s,n&&n.force?(o.avgHeight=i||70,o.isAtBottom=!1):o.avgHeight<10&&(o.avgHeight=i||100),o.afterRender=null;if(r)o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,this.vsRender(t),o.isAtBottom&&(t.scrollTop=t.scrollHeight);else if(!(n&&n.force)&&l>0&&e.length>=l&&!a&&o.lastEnd>=0){let h=0;for(let m=o.lastEnd;m<e.length;m++)h+=o.heights.get(m)||o.avgHeight;o.bottomSpacer.style.height=h+"px"}else{o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,n&&n.force&&!(n&&n.preserveScroll)&&(t.scrollTop=0),this.vsRender(t)}}renderSubTypeContent(t){let e=t.args&&t.args.length>0?t.args[0]:void 0;return"table"===t.subType?this.renderTableHTML(e,t.subTypeData?.columns):""}_treeNodeOpen(t,e,s,i){let n="tree-node "+(t?"expanded":"collapsed"),o=e+'="'+this.escapeHtml(s)+'"';return i&&(o+=" "+i),'<div class="'+n+'" '+o+">"}_treeNodeChildrenLazy(t,e){return this.treeNodeRegistry.set(t,e),'<div class="tree-children" data-lazy-id="'+t+'"></div>'}_treeShadowNode(t,e,s,i,n,o){let r="tree-node "+(t?"expanded":"collapsed"),l=e+'="'+this.escapeHtml(String(s))+'"';return o&&(l+=" "+o),'<div class="'+r+'" '+l+">"+this.treeToggleHtml()+'<span class="tree-label json-null">#shadow('+i+')</span><span class="tree-ellipsis">...</span><div class="tree-children">'+n+"</div></div>"}renderJSONTree(t,e,s,i,n,o,r){if(s||(s=new WeakSet),i||(i=[]),o=o||0,null===t)return'<span class="json-null">null</span>';if(void 0===t)return'<span class="json-null">undefined</span>';if("string"==typeof t)return'<span class="json-string">"'+this.escapeHtml(t)+'"</span>';if("number"==typeof t)return'<span class="json-number">'+t+"</span>";if("boolean"==typeof t)return'<span class="json-boolean">'+t+"</span>";if("bigint"==typeof t)return'<span class="json-number">'+t.toString()+"n</span>";if("symbol"==typeof t){let e=Object.create(Object.getPrototypeOf(Object(t)));Object.defineProperty(e,"value",{value:t.toString(),enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(e,"description",{value:t.description,enumerable:!0,writable:!0,configurable:!0}),t=e}if("function"==typeof t){if(this.isClass(t)){let e=t.name||"anonymous";return'<span class="json-boolean">[Class '+this.escapeHtml(e)+"]</span>"}return this.renderFunctionInline(t)}if(t instanceof Date)return'<span class="json-string">'+t.toISOString()+"</span>";if(t instanceof RegExp)return'<span class="json-number">'+t.toString()+"</span>";if(t instanceof Map)return'<span class="json-boolean">[Map '+t.size+"]</span>";if(t instanceof Set)return'<span class="json-boolean">[Set '+t.size+"]</span>";if(t instanceof WeakMap)return'<span class="json-boolean">[WeakMap]</span>';if(t instanceof WeakSet)return'<span class="json-boolean">[WeakSet]</span>';if(t instanceof ArrayBuffer)return'<span class="json-boolean">[ArrayBuffer '+t.byteLength+" bytes]</span>";if(t instanceof Error)return'<span class="json-boolean">[Error: '+this.escapeHtml(t.message)+"]</span>";if(t instanceof HTMLElement){let e=t.tagName.toLowerCase();return'<span class="json-tag"><'+e+">...</"+e+"></span>"}if(s.has(t))return'<span class="json-cmt">[循环引用]</span>';s.add(t);let l=i.concat([t]),a=Array.isArray(t),c=a?"Array("+t.length+")":t.constructor&&t.constructor.name?t.constructor.name:"Object",d=[];try{Reflect.ownKeys(t).forEach(e=>{let s=Object.getOwnPropertyDescriptor(t,e);s&&d.push({name:String(e),desc:s})})}catch(e){try{Object.keys(t).forEach(e=>{let s=Object.getOwnPropertyDescriptor(t,e);s&&d.push({name:String(e),desc:s})})}catch(e){return s.delete(t),'<span class="json-boolean">['+this.escapeHtml(c)+"]</span>"}}let h=Object.getPrototypeOf(t);if(!r&&h&&null!==h&&d.push({name:"[[Prototype]]",desc:{value:h,enumerable:!0,writable:!0,configurable:!0}}),0===d.length)return s.delete(t),a?'<span class="json-cmt">'+(e?this.escapeHtml(e)+": ":"")+"[]</span>":'<span class="json-cmt">'+(e?this.escapeHtml(e)+": ":"")+"{}</span>";a||d.sort((t,e)=>{if("[[Prototype]]"===t.name)return 1;if("[[Prototype]]"===e.name)return-1;let s=!(!t.desc.get&&!t.desc.set),i=!(!e.desc.get&&!e.desc.set);if(s&&!i)return 1;if(!s&&i)return-1;let n=(t.name.match(/^(_*)/)||[""])[0].length,o=(e.name.match(/^(_*)/)||[""])[0].length;if(n!==o)return n-o;let r=/^[A-Z]/.test(t.name),l=/^[A-Z]/.test(e.name);return r&&!l?1:!r&&l?-1:t.name.localeCompare(e.name,void 0,{numeric:!0,sensitivity:"base"})});let p=n||"",u=this.expandedTreePaths.has(p),g=this._treeNodeOpen(u,"data-tree-path",p);if(g+=this.treeToggleHtml(),e&&(g+='<span class="json-key">'+this.escapeHtml(e)+":</span> "),g+='<span class="tree-label">'+this.escapeHtml(c)+"</span>",g+='<span class="tree-brace tree-open">{</span><span class="tree-brace tree-collapsed">{...}</span>',u){g+='<div class="tree-children">';let t=200;if(d.length>t){let e=this.treeNodeRegId++;this.treeNodeRegistry.set(e,{children:d,chain:l,noProto:r}),g+=this.renderTreeChildrenBatch(d,s,0,t,l,p,o+1,r),g+='<div class="tree-load-more" data-reg-id="'+e+'" data-offset="'+t+'">'+this.icon("angle-down")+" 展开更多 (剩余 "+(d.length-t)+" 项)</div>"}else g+=this.renderTreeChildrenBatch(d,s,0,d.length,l,p,o+1,r);g+="</div>"}else{let e=this.treeNodeRegId++;g+=this._treeNodeChildrenLazy(e,{obj:t,children:d,chain:i,path:p,noProto:r})}return g+='<span class="tree-brace tree-close">}</span>',g+="</div>",s.delete(t),g}renderTreeChildrenBatch(t,e,s,i,n,o,r,l){r=r||0;let a="";for(let c=s;c<i&&c<t.length;c++){let s=t[c];if(s.desc.get||s.desc.set)s.desc.get&&(a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">get '+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(s.desc.get,"",e,n,o+"."+s.name,r+1,l)+"</div>"),s.desc.set&&(a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">set '+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(s.desc.set,"",e,n,o+"."+s.name,r+1,l)+"</div>");else{let t=s.desc.value;null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp||t instanceof Map||t instanceof Set||t instanceof WeakMap||t instanceof WeakSet||t instanceof ArrayBuffer||t instanceof Error||t instanceof HTMLElement||"function"==typeof t?a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(t,"",e,n,o+"."+s.name,r+1,l)+"</div>":e.has(t)?a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(s.name)+':</span> <span class="json-cmt">[循环引用]</span></div>':a+="<div>"+this.renderJSONTree(t,s.name,e,n,o+"."+s.name,r+1,l)+"</div>"}}return a}renderDomChild(t,e,s,i){return 1===t.nodeType?"<div>"+e(t,s,i)+"</div>":3===t.nodeType?'<div class="tree-leaf tree-leaf-text"><span class="tree-spacer"></span><span class="json-cmt">'+this.escapeHtml(t.textContent.trim())+"</span></div>":""}renderDomChildrenLazy(t,e,s,i,n){let o="";if(t.length>200){let r=this.treeNodeRegId++;this.treeNodeRegistry.set(r,Object.assign({type:i,children:t,depth:s},n));for(let i=0;i<200;i++)o+=this.renderDomChild(t[i],e,i,s+1);o+='<div class="tree-load-more" data-reg-id="'+r+'" data-offset="200">'+this.icon("angle-down")+" 展开更多 ("+(t.length-200)+")</div>"}else{let i=0;for(let n of t)o+=this.renderDomChild(n,e,i,s+1),1===n.nodeType&&i++}return o}buildShadowLazy(t,e,s,i,n){let o='<div class="tree-node collapsed" ';if("element"===e){let e=++this.elRefId;this.elRefMap.set(e,t.root),o+='data-el-id="'+e+'" data-shadow-host="'+n+'"'}else o+='data-tree-path="'+this.escapeHtml(s+".shadow")+'" data-shadow-root="1"';o+=">"+this.treeToggleHtml()+'<span class="tree-label json-null">#shadow('+t.mode+")</span>";let r=Array.from(t.root.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim());if(r.length>0){let n=this.treeNodeRegId++;this.treeNodeRegistry.set(n,{type:e+"-shadow",shadowInfo:t,path:s,depth:i,children:r}),o+='<span class="tree-ellipsis">...</span><div class="tree-children" data-lazy-id="'+n+'"></div>'}return o+"</div>"}loadMoreTreeChildren(t){let e=parseInt(t.dataset.regId),s=parseInt(t.dataset.offset),i=this.treeNodeRegistry.get(e);if(!i)return;let n=t.closest(".console-output, .ls-items, .elements-tree");if("html"===i.type){let e=Math.min(s+200,i.children.length),n="";for(let t=s;t<e;t++)n+=this.renderDomChild(i.children[t],(t,e)=>this.renderHTMLTree(t,"",i.path+"."+e,(i.depth||0)+1),t,0);t.insertAdjacentHTML("beforebegin",n)}else if("element"===i.type){let e=Math.min(s+200,i.children.length),n="";for(let t=s;t<e;t++)n+=this.renderDomChild(i.children[t],t=>this.renderElementTree(t,(i.depth||0)+1),t,0);t.insertAdjacentHTML("beforebegin",n)}else{let e=new WeakSet;i.chain.forEach(t=>e.add(t)),t.insertAdjacentHTML("beforebegin",this.renderTreeChildrenBatch(i.children,e,s,Math.min(s+200,i.children.length),i.chain,i.path||"",1,i.noProto))}let o=s+200;o<i.children.length?(t.dataset.offset=o,t.innerHTML=this.icon("angle-down")+" 展开更多 ("+(i.children.length-o)+")"):(t.remove(),this.treeNodeRegistry.delete(e)),n&&this.vsRender(n)}renderHTMLTree(t,e,s,i){if((i=i||0)>30)return'<span class="json-cmt">[depth limit]</span>';s=s||"";let n=t.tagName.toLowerCase(),o="";for(let e of t.attributes)o+=e.value?' <span class="json-tag">'+this.escapeHtml(e.name)+'</span><span class="json-boolean">=</span><span class="json-string">"'+this.escapeHtml(e.value)+'"</span>':' <span class="json-tag">'+this.escapeHtml(e.name)+"</span>";let r=Array.from(t.childNodes),l=this.getShadowRoot(t),a=l&&Array.from(l.root.childNodes).some(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),c=l&&(a||l.mode&&"closed"===l.mode),d=r.some(t=>1===t.nodeType)||r.filter(t=>3===t.nodeType&&t.textContent.trim()).length>0||!!c,h=this.expandedTreePaths.has(s),p=this._treeNodeOpen(h,"data-tree-path",s);if(p+=d?this.treeToggleHtml():'<span class="tree-spacer"></span>',e&&(p+='<span class="json-key">'+this.escapeHtml(e)+":</span> "),p+='<span class="tree-label json-boolean"><'+n+o+"></span>",d){if(p+='<span class="tree-ellipsis">...</span>',h){p+='<div class="tree-children">';let t=r.filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim());if(p+=this.renderDomChildrenLazy(t,(t,e,i)=>this.renderHTMLTree(t,"",s+"."+e,i),i,"html",{path:s}),c)if(this.expandedTreePaths.has(s+".shadow")){let t=Array.from(l.root.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim());p+=this._treeShadowNode(!0,"data-tree-path",s+".shadow",l.mode,this.renderDomChildrenLazy(t,(t,e,i)=>this.renderHTMLTree(t,"",s+".shadow."+e,i),i,"html-shadow",{shadowInfo:l,path:s}),'data-shadow-root="1"')}else p+=this.buildShadowLazy(l,"html",s,i);p+="</div>"}else{let t=r.filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),e=this.treeNodeRegId++;p+=this._treeNodeChildrenLazy(e,{type:"html",children:t,path:s,depth:i,shadow:c?l:null})}p+='<span class="tree-label json-boolean tree-close-tag"></'+n+"></span>"}else p+='<span class="tree-label json-boolean tree-close-tag"></'+n+"></span>";return p+="</div>",p}renderElementsView(){if(!this.elementsTree)return;let t=document.documentElement;this.elRefMap=new Map,this.elRefId=0;let e=this.renderElementTree(t,0);this.elementsTree.innerHTML=e,this.pendingHighlight?this.expandToElement(this.pendingHighlight):this.selectedElement&&this.restoreElementSelection()}restoreElementSelection(){if(!this.selectedElement||!this.elementsTree)return;let t=null;for(let[e,s]of this.elRefMap)if(s===this.selectedElement){t=e;break}if(null===t)return;let e=this.elementsTree.querySelector('.tree-node[data-el-id="'+t+'"]');if(!e)return;let s=e;for(;s&&s!==this.elementsTree;)s.classList.contains("tree-node")&&(s.classList.remove("collapsed"),s.classList.add("expanded"),s.dataset.elId&&this.elRefMap&&this.elRefMap.get(parseInt(s.dataset.elId))&&this.expandedElements.add(this.elRefMap.get(parseInt(s.dataset.elId)))),s=s.parentElement;this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),e.classList.add("el-selected"),e.classList.add("el-highlight"),requestAnimationFrame(()=>{e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>e.classList.remove("el-highlight"),3e3)})}renderElementTree(t,e){if(t===this.overlay||t===this.notification||t===this.btn)return"";if(t.nodeType&&3===t.nodeType){let e=t.textContent.trim();return e?'<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-cmt">'+this.escapeHtml(e)+"</span></div>":""}if(1!==t.nodeType)return"";let s=t.tagName.toLowerCase(),i="";for(let e of t.attributes)i+=e.value?' <span class="json-tag">'+this.escapeHtml(e.name)+'</span><span class="json-boolean">=</span><span class="json-string">"'+this.escapeHtml(e.value)+'"</span>':' <span class="json-tag">'+this.escapeHtml(e.name)+"</span>";let n=Array.from(t.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),o=this.getShadowRoot(t),r=o&&Array.from(o.root.childNodes).some(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),l=o&&(r||o.mode&&"closed"===o.mode),a=n.length>0||!!l,c=0===e||this.expandedElements.has(t),d=++this.elRefId;this.elRefMap.set(d,t);let h=this._treeNodeOpen(c,"data-el-id",d);if(h+=a?this.treeToggleHtml():'<span class="tree-spacer"></span>',h+='<span class="tree-label json-boolean"><'+s+i+"></span>",a){if(h+='<span class="tree-ellipsis">...</span>',c){if(h+='<div class="tree-children">',h+=this.renderDomChildrenLazy(n,(t,e,s)=>this.renderElementTree(t,s),e,"element",{}),l)if(this.expandedElements.has(o.root)||0===e){let t=Array.from(o.root.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),s=++this.elRefId;this.elRefMap.set(s,o.root),h+=this._treeShadowNode(!0,"data-el-id",s,o.mode,this.renderDomChildrenLazy(t,(t,e,s)=>this.renderElementTree(t,s),e,"element-shadow",{}),'data-shadow-host="'+d+'"')}else h+=this.buildShadowLazy(o,"element",null,e,d);h+="</div>"}else{let t=this.treeNodeRegId++;h+=this._treeNodeChildrenLazy(t,{type:"element",children:n,depth:e,shadow:l?o:null,elId:d})}h+='<span class="tree-label json-boolean tree-close-tag"></'+s+"></span>"}else h+='<span class="tree-label json-boolean tree-close-tag"></'+s+"></span>";return h+="</div>",h}startElementPicker(){this.elementPickBtn&&this.elementPickBtn.classList.add("active"),this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose");let t=document.createElement("div");t.className="element-picker-overlay",t.style.pointerEvents="none";let e=!1,s=n=>{if(e)return;e=!0,n.preventDefault(),n.stopPropagation();let o=n.target;t.remove(),document.removeEventListener("click",s,!0),document.removeEventListener("keydown",i,!0),this.pendingHighlight=o,this.switchTab("elements"),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this.elementPickBtn&&this.elementPickBtn.classList.remove("active")},i=n=>{"Escape"!==n.key||e||(e=!0,t.remove(),document.removeEventListener("click",s,!0),document.removeEventListener("keydown",i,!0),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this.elementPickBtn&&this.elementPickBtn.classList.remove("active"))};document.body.appendChild(t),setTimeout(()=>{document.addEventListener("click",s,!0),document.addEventListener("keydown",i,!0)},200)}expandToElement(t){if(!t||!this.elementsTree)return;this.pendingHighlight=null,this.selectedElement=t;let e=[],s=t;for(;s&&s!==document.documentElement&&s!==document;)e.unshift(s),s=s.parentNode;for(let t of e){let e=null;for(let[s,i]of this.elRefMap)if(i===t){e=s;break}if(null===e)continue;let s=this.elementsTree.querySelector('.tree-node[data-el-id="'+e+'"]');if(!s||!s.classList.contains("collapsed"))continue;s.classList.remove("collapsed"),s.classList.add("expanded");let i=this.elRefMap.get(parseInt(s.dataset.elId));i&&this.expandedElements.add(i);let n=s.querySelector(":scope > .tree-children[data-lazy-id]");if(n){let t=parseInt(n.dataset.lazyId),e=this.treeNodeRegistry.get(t);if(e){let s="";"element"===e.type?(s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element",{}),e.shadow&&(s+=this.buildShadowLazy(e.shadow,"element",null,e.depth||0,e.elId))):"element-shadow"===e.type&&(s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element-shadow",{})),n.innerHTML=s,delete n.dataset.lazyId,this.treeNodeRegistry.delete(t)}}}let i=null;for(let[e,s]of this.elRefMap)if(s===t){i=e;break}if(null===i)return;let n=this.elementsTree.querySelector('.tree-node[data-el-id="'+i+'"]');n&&(this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),n.classList.add("el-selected"),n.classList.add("el-highlight"),requestAnimationFrame(()=>{n.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>n.classList.remove("el-highlight"),3e3)}))}serializeNodeWithShadow(t){if(t instanceof ShadowRoot||t instanceof DocumentFragment)return Array.from(t.childNodes).map(t=>this.serializeNodeWithShadow(t)).join("");if(1===t.nodeType){let e=t.tagName.toLowerCase(),s="";for(let e of t.attributes)s+=null!=e.value&&void 0!==e.value?" "+e.name+'="'+this.escapeHtml(e.value)+'"':" "+e.name;let i=this.getShadowRoot(t),n="";return i&&(n+="\x3c!-- #shadow("+i.mode+") --\x3e",n+=Array.from(i.root.childNodes).map(t=>this.serializeNodeWithShadow(t)).join("")),n+=Array.from(t.childNodes).map(t=>this.serializeNodeWithShadow(t)).join(""),["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(e)?"<"+e+s+">":"<"+e+s+">"+n+"</"+e+">"}return 3===t.nodeType?t.textContent:8===t.nodeType?"\x3c!--"+t.textContent+"--\x3e":""}copyElementHTML(t){let e=this.serializeNodeWithShadow(t);navigator.clipboard?navigator.clipboard.writeText(e).then(()=>this.showNotification("已复制元素")).catch(()=>this.fallbackCopy(e)):this.fallbackCopy(e)}fallbackCopy(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();try{document.execCommand("copy"),this.showNotification("已复制元素")}catch(e){this.showNotification("复制失败","warning")}e.remove()}deleteElement(t){if(t)if(null!==this.selectedShadowHostId){let t=this.elRefMap.get(this.selectedShadowHostId);if(t){let e=this.getShadowRoot(t);if(e){if("closed"===e.mode)return void this.showNotification("无法删除closed模式的ShadowDOM","warning");try{for(t.shadowRoot&&(t.shadowRoot.innerHTML="");e.root.firstChild;)e.root.removeChild(e.root.lastChild)}catch{}this.selectedElement=null,this.selectedShadowHostId=null,this.showNotification("ShadowDOM已删除"),this.renderElementsView()}else this.showNotification("ShadowDOM已不存在","warning")}else this.showNotification("无法删除此元素","warning")}else t.parentNode?(t.parentNode.removeChild(t),this.showNotification("元素已删除"),this.selectedElement===t&&(this.selectedElement=null),this.renderElementsView()):t.parentElement?(t.parentElement.removeChild(t),this.showNotification("元素已删除"),this.selectedElement===t&&(this.selectedElement=null),this.renderElementsView()):this.showNotification("无法删除此元素","warning")}renderTableHTML(t,e){if(!t||"object"!=typeof t)return`<div class="console-table-wrap"><span class="json-cmt">非表格数据: ${this.escapeHtml(String(t))}</span></div>`;let s,i;s=Array.isArray(t)?t.map((t,e)=>{let s={"(idx)":e};return t&&"object"==typeof t?Object.assign(s,t):s.value=t,s}):Object.entries(t).map(([t,e])=>{let s={"(idx)":t};return e&&"object"==typeof e?Object.assign(s,e):s.value=e,s});let n=new Set;s.forEach(t=>Object.keys(t).forEach(t=>n.add(t))),i=["(idx)",...Array.from(n).filter(t=>"(idx)"!==t)],e&&Array.isArray(e)&&e.length&&(i=["(idx)",...e.filter(t=>"(idx)"!==t)]);let o=t=>{if(void 0===t)return"";if(null===t)return'<span class="json-null">null</span>';if("string"==typeof t)return`<span class="json-string">"${this.escapeHtml(t.substring(0,100))}"</span>`;if("number"==typeof t)return`<span class="json-number">${t}</span>`;if("boolean"==typeof t)return`<span class="json-boolean">${t}</span>`;if("function"==typeof t)return this.isClass(t)?`<span class="json-boolean">[Class ${t.name||"anonymous"}]</span>`:`<span class="json-boolean">ƒ ${t.name||"anonymous"}</span>`;if("object"==typeof t)try{let e=this.safeStringify(t);return`<span class="json-cmt">${this.escapeHtml(e.length>50?e.substring(0,50)+"…":e)}</span>`}catch{return'<span class="json-cmt">{Object}</span>'}return this.escapeHtml(String(t))},r='<div class="console-table-wrap"><table class="console-table"><thead><tr>';return i.forEach(t=>r+=`<th>${this.escapeHtml(String(t))}</th>`),r+="</tr></thead><tbody>",s.forEach(t=>{r+="<tr>",i.forEach(e=>r+=`<td>${o(t[e])}</td>`),r+="</tr>"}),r+="</tbody></table></div>",r}renderLogItemHTML(t,e){if(t.subType){let e="table",s=t.timestamp.toLocaleTimeString(),i=this.renderSubTypeContent(t);return`<div class="log-item ${t.type}${this.selectedLogId===t.id?" selected":""}" id="log-item-${t.id}"><div class="log-header">${t.count>1?`<div class="log-count">${t.count}</div>`:""}<div class="log-icon">${this.icon(e)}</div><div class="timestamp">${s}</div></div><div class="log-content">${i}</div></div>`}let s;switch(t.type){case"info":s="info-circle";break;case"warn":s="exclamation-triangle";break;case"error":s="times-circle";break;default:s="info"}let i=t.timestamp.toLocaleTimeString(),n=t.expandedJson?this.formatArgs(t.args,t.id):this.renderLogContent(t);return`<div class="log-item ${t.type}${this.selectedLogId===t.id?" selected":""}" id="log-item-${t.id}"><div class="log-header">${t.count>1?`<div class="log-count">${t.count}</div>`:""}<div class="log-icon">${this.icon(s)}</div><div class="timestamp">${i}</div></div><div class="log-content">${n}</div>${t.hasObject?`<div class="log-actions"><div class="log-action expand-btn" title="${t.expandedJson?"收起":"展开"}" onclick="thinConsole.tC.toggleExpandJson(${t.id})">${this.icon(t.expandedJson?"chevron-up":"chevron-down")}${t.expandedJson?"收起":"展开"}</div></div>`:""}</div>`}renderLSItemHTML(t,e){let s=this.escapeHtml(t),{displayValue:i,valueType:n,isJSON:o}=this.parseAndTypeCheck(e),r=o?this.highlightJson(i):this.escapeHtml(i),l="";if(o){let t=JSON.parse(e);l=`<div class="ls-value json-tree-container">${this.renderJSONValue(t,"")}</div>`}else l=`<div class="ls-value" title="${this.escapeHtml(i)}"><span class="json-${n}">${"string"===n?'"':""}${r}${"string"===n?'"':""}</span></div>`;return`<div class="ls-item" data-key="${s}"><div class="ls-key-row"><div class="ls-key" title="${s}">${s}</div><div class="ls-actions"><button class="ls-action-btn" data-action="edit" data-key="${s}" title="编辑">${this.icon("edit")}</button><button class="ls-action-btn" data-action="copy" data-key="${s}" title="复制">${this.icon("copy")}</button><button class="ls-action-btn" data-action="remove" data-key="${s}" title="删除">${this.icon("trash")}</button></div></div>${l}<div class="ls-value-type" title="${n}">类型:${n}</div></div>`}toggleSearch(t){let e=void 0!==t?t:!this.searchExpanded;this.searchExpanded=e,this.searchBar&&(this.searchBar.style.display=e?"flex":"none"),e&&this.searchInput?this.searchInput.focus():e||(this.searchQuery="",this.searchInput&&(this.searchInput.value=""),this.renderContent())}onAddLSClick(){this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!0,mode:"ls",key:"",oldKey:"",value:""},this.updateEditorVisibility(),this.lsEditorKeyInput&&(this.lsEditorKeyInput.value="",this.lsEditorKeyInput.focus())}openLSEditor(t){if(this.netSending||this.netNewVisible)return void this.showNotification("正在发送请求,无法保存键值","warning");let e=this.activeLSFilter||"local",s=this.storage[e].get(t)||"";this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!0,mode:"ls",key:t,oldKey:t,value:s},this.updateEditorVisibility(),this.lsEditorInput&&this.lsEditorInput.focus()}closeLSEditor(){this.editorState.visible=!1,this.editorState.value="",this.updateEditorVisibility()}onEditorSave(){"code"===this.editorState.mode?this.runCode():this.saveLSFromEditor()}saveLSFromEditor(){if(this.netSending||this.netNewVisible)return void this.showNotification("正在发送请求,无法保存键值","warning");let t,e=this.lsEditorKeyInput?this.lsEditorKeyInput.value.trim():this.editorState.key,s=this.editorState.oldKey,i=this.lsEditorInput?this.lsEditorInput.value:this.editorState.value;if(!e)return void this.showNotification("键名不能为空","warning");try{t=JSON.stringify(JSON.parse(this.fixKeysOnly(i)))}catch{t=i}let n=this.activeLSFilter||"local",o=this.storage[n];if("cookie"===n)return o.set(e,t),this.closeLSEditor(),this.renderLocalStorage(),void this.showNotification('已保存Cookie"'+e+'"');if(s&&s!==e){if(null!==o.get(e))return void this.showNotification('键名"'+e+'"已存在!',"warning");o.remove(s)}else if(!s&&null!==o.get(e))return void this.showNotification('键名"'+e+'"已存在!',"warning");o.set(e,t),this.closeLSEditor(),this.renderLocalStorage(),this.showNotification('已保存键"'+e+'"')}onTitleClick(){this.netSending||this.netNewVisible?this.showNotification("正在发送请求,无法运行代码","warning"):this.editorState.visible&&"ls"===this.editorState.mode?this.showNotification("正在保存键值,无法运行代码","warning"):(this.editorState.visible=!0,this.editorState.mode="code",this.updateEditorVisibility(),this.lsEditorInput&&this.lsEditorInput.focus())}toggleMute(){let t="console",e=this.activeFilter||"all";this.mutedFilters[t]||(this.mutedFilters[t]={}),this.mutedFilters[t][e]=!this.mutedFilters[t][e];let s=this.mutedFilters[t][e],i="all"===e?"所有日志":e+"类型日志";this.showNotification(s?i+"已屏蔽":i+"已恢复",s?"warning":""),this.updateMuteBtnState()}updateMuteBtnState(){if(!this.muteBtn)return;let t="console",e=this.activeFilter||"all";this.mutedFilters[t]&&this.mutedFilters[t][e]?(this.muteBtn.classList.add("muted"),this.muteBtn.title="恢复日志"):(this.muteBtn.classList.remove("muted"),this.muteBtn.title="屏蔽"+("all"===e?"后续日志":e+"类型日志"))}runCode(){let t=this.lsEditorInput?this.lsEditorInput.value:"";if(t.trim())try{let e=window.eval(t);console.log(t+"\n> ",e),this.showNotification("代码已执行"),this.closeLSEditor()}catch(e){console.error(t+"\n> 执行失败:"+e),this.showNotification("代码执行失败","warning"),this.closeLSEditor()}}setupGestures(){if(!this.contentArea||!this.consoleHeader)return;let t=this.contentArea,e=this.consoleHeader,s=null,i=0,n=0,o=0,r=0,l=!1,a=null,c=0,d=0,h=0,p=!1,u=()=>{let t=this.overlay.querySelectorAll(".tab-btn");return Array.from(t).map(t=>t.dataset.tab)},g=()=>{if("console"===this.currentTab)return["all","log","info","warn","error"];if("network"===this.currentTab)return["all","get","post","put","success","failed"];if("localstorage"===this.currentTab)return["local","session","cookie"];let t=this.pluginViewContainers[this.currentTab];return t&&t.querySelectorAll(".filter-btn").length>1?Array.from(t.querySelectorAll(".filter-btn")).map(t=>t.dataset.type||t.dataset.filter||t.textContent.trim()):null},f=t=>{let e=u(),s=e.indexOf(this.currentTab),i=g();if(i)if("localstorage"===this.currentTab){let e=i.indexOf(this.activeLSFilter||"local")+t;if(e>=0&&e<i.length){this.activeLSFilter=i[e],this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>t.classList.toggle("active",t.dataset.lsType===this.activeLSFilter)),this.renderContent();let t=this.lsFiltersContainer&&this.lsFiltersContainer.querySelector('.filter-btn[data-ls-type="'+this.activeLSFilter+'"]');return void this.scrollFilterIntoView(this.lsFiltersContainer,t)}}else if("console"===this.currentTab){let e=i.indexOf(this.activeFilter||"all")+t;if(e>=0&&e<i.length)return this.activeFilter=i[e],this.filterButtons.forEach(t=>t.classList.toggle("active",t.dataset.type===this.activeFilter)),this.updateFilterCounts(),this.renderContent(),void this.scrollFilterIntoView(this.filtersContainerEl,this.filterButtons[e])}else{if("network"!==this.currentTab){let e=this.pluginViewContainers[this.currentTab];if(e){this.enhanceFilterContainers(e);let s=e.querySelectorAll(".filter-btn");if(s.length>1){let e=-1;s.forEach((t,s)=>{t.classList.contains("active")&&(e=s)});let i=e+t;i>=0&&i<s.length&&(s.forEach(t=>t.classList.remove("active")),s[i].classList.add("active"),s[i].click(),this.scrollFilterIntoView(s[i].parentElement,s[i]))}}return}{let e=i.indexOf(this.activeNetFilter||"all")+t;if(e>=0&&e<i.length){this.activeNetFilter=i[e],this.netFiltersEl&&this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(t=>t.classList.toggle("active",t.dataset.netFilter===this.activeNetFilter)),this.renderNetworkList(),this.updateNetDisableBtn(),this.updateNetFilterCounts();let t=this.netFiltersEl&&this.netFiltersEl.querySelector('.net-filter-btn[data-net-filter="'+this.activeNetFilter+'"]');return void this.scrollFilterIntoView(this.netFiltersEl,t)}}}let n=s+t;if(n>=0&&n<e.length){let t=e[n];"console"===t?(this.activeFilter="all",this.filterButtons&&this.filterButtons.forEach(t=>t.classList.toggle("active","all"===t.dataset.type))):"localstorage"===t&&(this.activeLSFilter="local",this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>t.classList.toggle("active","local"===t.dataset.lsType)));let s=this.overlay.querySelector(`.tab-btn[data-tab="${t}"]`);s&&s.click()}};t.addEventListener("touchstart",t=>{if(1!==t.touches.length)return;if(this.editorState.visible)return;let e=t.target.closest(".json-tree-container,.json-preview,.log-content,.console-table-wrap,.system-log-content,.ls-value,.object-preview,.error-stack,.function-preview,.elements-tree,.filters,.network-filters");e&&(e.matches(".filters,.network-filters")||e.scrollWidth>e.clientWidth)?s=null:(s=t.touches[0],i=s.clientX,n=s.clientY,o=0,r=0,l=!1)},{passive:!0}),t.addEventListener("touchmove",t=>{if(!s||1!==t.touches.length)return;let e=t.touches[0];o=e.clientX-i,r=e.clientY-n,!l&&Math.abs(o)>15&&Math.abs(o)>1.5*Math.abs(r)&&(l=!0),l&&t.preventDefault()},{passive:!1}),t.addEventListener("touchend",()=>{if(s){if(l){let t=60;o<-t?f(1):o>t&&f(-1)}s=null,l=!1}}),e.addEventListener("touchstart",t=>{window.innerWidth>768||1===t.touches.length&&(a=t.touches[0],c=a.clientX,d=a.clientY,h=0,p=!1)},{passive:!0}),e.addEventListener("touchmove",t=>{if(window.innerWidth>768)return;if(!a||1!==t.touches.length)return;let e=t.touches[0];if(h=e.clientY-d,!p&&h>15&&h>1.5*Math.abs(e.clientX-c)&&(p=!0),p){t.preventDefault();let e=this.overlay.querySelector(".console-container");e&&(e.style.transition="none",e.style.transform=`translateY(${h}px)`)}},{passive:!1}),e.addEventListener("touchend",()=>{if(!(window.innerWidth>768)&&a){if(p){let t=this.overlay.querySelector(".console-container");h>80?(t&&(t.style.transition="transform .3s ease",t.style.transform="translateY(100%)"),setTimeout(()=>{this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),t&&(t.style.transition="",t.style.transform=""),this.triggerGlobalHook("afterClose")},300)):t&&(t.style.transition="transform .25s ease",t.style.transform="")}a=null,p=!1}})}updateFilterShadow(t){if(!t)return;let e=t.scrollWidth-t.clientWidth>1;t.classList.toggle("overflow-start",e&&t.scrollLeft>1),t.classList.toggle("overflow-end",e&&t.scrollLeft+t.clientWidth<t.scrollWidth-1)}setupFilterShadow(t){if(!t||t._tcFilterShadow)return;t._tcFilterShadow=!0;t.classList.add("overflow-scroll");let e=()=>this.updateFilterShadow(t);if(t.addEventListener("scroll",e,{passive:!0}),window.ResizeObserver){let s=new ResizeObserver(e);s.observe(t),t._tcFilterRO=s,t.setAttribute("data-filter-ro","1")}if(window.MutationObserver){let s=new MutationObserver(e);s.observe(t,{childList:!0,subtree:!0}),t._tcFilterMO=s}e()}scrollFilterIntoView(t,e){if(!t||!e)return;if(t.scrollWidth<=t.clientWidth)return void this.updateFilterShadow(t);let s=e.offsetLeft-(t.clientWidth-e.offsetWidth)/2;s=Math.max(0,Math.min(s,t.scrollWidth-t.clientWidth));try{t.scrollTo({left:s,behavior:"smooth"})}catch(t){}t.scrollLeft!==s&&(t.scrollLeft=s),this.updateFilterShadow(t),setTimeout(()=>this.updateFilterShadow(t),300)}enhanceFilterContainers(t){if(!t)return;let e=new Map;t.querySelectorAll(".filter-btn").forEach(t=>{let s=t.parentElement;s&&!s.dataset.tcFilterEnhanced&&(e.has(s)||e.set(s,[]),e.get(s).push(t))}),e.forEach((t,e)=>{if(t.length>1){e.classList.contains("filters")||e.classList.contains("network-filters")||e.classList.add("filters"),e.dataset.tcFilterEnhanced="1",this.setupFilterShadow(e);let s=e;t.forEach(t=>{t.dataset.orig||(t.dataset.orig=t.textContent.trim()),t.addEventListener("click",()=>this.scrollFilterIntoView(s,t))})}})}_fmtCount(n,p){if(n<1e3)return{filterCount:n,exactCount:n};let k=n/1e3;if(n>=1e5)return{filterCount:Math.floor(k)+"K+",exactCount:n};let s=Math.round(k*10)/10;return{filterCount:(Number.isInteger(s)?s:s.toFixed(1))+"K"+(p?"+":""),exactCount:n}}_updateFilterBtns(t,e,s,i){t&&t.querySelectorAll(".filter-btn, .net-filter-btn").forEach(t=>{let n=t.dataset[s],o=e[n]||0,r=t.classList.contains("active");t.innerHTML=i(t,o,r)})}updateFilterCounts(){if(!this.filterButtons)return;this._updateFilterRaf||(this._updateFilterRaf=requestAnimationFrame(()=>{this._updateFilterRaf=null;let t=[];"console"===this.currentTab&&(t=this.logs);let e=(t,e)=>t.reduce((t,s)=>s.type===e?t+(s.count||1):t,0),s={all:t.reduce((t,e)=>t+(e.count||1),0),log:e(t,"log"),info:e(t,"info"),warn:e(t,"warn"),error:e(t,"error")};this._updateFilterCounts(this.filterButtons,s,!1)}))}_updateFilterCounts(e,t,s){if(!e)return;(s?e.querySelectorAll(".filter-btn[data-orig]"):e).forEach(i=>{let n=s?i.dataset.orig:i.dataset.type,o=t[i.dataset.type||i.dataset.filter||n]||0,r=i.classList.contains("active"),a;"object"==typeof o&&null!==o?a=o:a=this._fmtCount(o,!1);if(s)i.innerHTML=(i.dataset.icon?this.icon(i.dataset.icon)+" ":"")+n+(r?" ("+a.filterCount+")":"");else{if(i.dataset.originalHtml||(i.dataset.originalHtml=i.innerHTML),r)i.innerHTML=`${i.dataset.originalHtml} (${a.filterCount})`;else i.innerHTML=i.dataset.originalHtml}i.title=r&&void 0!==a.exactCount?""+a.exactCount:""})}renderContent(){if(this.triggerGlobalHook("beforeRender",this.currentTab),this.updateControlsVisibility(),this.updateMuteBtnState(),this.consoleOutput.style.display="none",this.localstorageView.style.display="none",this.elementsView.style.display="none",this.networkView&&(this.networkView.style.display="none"),this.netDetailOverlay&&(this.netDetailOverlay.style.display="none"),this.netNewOverlay&&(this.netNewOverlay.style.display=this.netNewVisible?"flex":"none"),this.clearLogsBtn.style.display="none",Object.values(this.pluginViewContainers).forEach(t=>{t.style.display="none"}),["console","network","localstorage","elements"].includes(this.currentTab))switch(this.clearLogsBtn.style.display="block",this.currentTab){case"console":this.consoleOutput.style.display="block",this.renderLogList(this.logs,!1),this.updateFilterCounts();break;case"network":this.clearLogsBtn.style.display="block",this.networkView&&(this.networkView.style.display="flex"),this.renderNetworkPanel();break;case"localstorage":this.localstorageView.style.display="block",this.renderLocalStorage();break;case"elements":this.clearLogsBtn.style.display="none",this.elementsView.style.display="block",this.renderElementsView()}else if(this.pluginViewContainers[this.currentTab]){this.consoleControls.style.display="none";let t=this.pluginViewContainers[this.currentTab];t.style.display="block";let e=Object.keys(this.pluginTabs).find(t=>this.pluginTabs[t].id===this.currentTab);if(e){let s=this.plugins[e];s&&"function"==typeof s.onShow&&s.onShow(),s&&"function"==typeof s.render&&s.render(t),this.enhanceFilterContainers(t)}else{let t=this.pluginTabs[this.currentTab];t&&"function"==typeof t.onShow&&t.onShow()}}this.triggerGlobalHook("afterRender",this.currentTab)}renderLogList(t,e){let s=this.consoleOutput,i="日志记录";if(!s)return;if(0===t.length)return void this.vsUpdate(s,[],null,0,{emptyHTML:`<div class="nolog">${this.icon("info-circle")}无${i}</div>`});let n=[...t];if(this.activeFilter&&"all"!==this.activeFilter&&(n=n.filter(t=>t.type===this.activeFilter)),this.searchQuery){let t,e=this.searchQuery.trim(),s=!1;if(e.startsWith("/")&&e.endsWith("/"))try{let i=e.slice(1,-1),n=i.lastIndexOf("/"),o="";n>0?(o=i.slice(n+1),t=new RegExp(i.slice(0,n),o)):t=new RegExp(i),s=!0}catch{this.showNotification("无效的正则表达式:"+e),s=!1}let i=s?e:e.toLowerCase();n=n.filter(e=>e.args.some(e=>{let n;return n=e instanceof Error?"[error]":null==e?"null":void 0===e?"undefined":"object"==typeof e?'<span class="json-cmt">{Object}</span>':String(e),s&&t?t.test(n):n.toLowerCase().includes(i.toLowerCase())}))}if(0===n.length)return void this.vsUpdate(s,[],null,0,{emptyHTML:`<div class="nolog">${this.icon("search")}无匹配的${i}</div>`});this.vsUpdate(s,n,t=>this.renderLogItemHTML(t,e),80)}getParams(t){let e=t.toString(),s=t=>{let e=t.indexOf("(");if(-1===e)return"";let s=1,i=e+1;for(;i<t.length;i++)if("("===t[i])s++;else if(")"===t[i]&&0===--s)break;return t.slice(e+1,i).replace(/\s+/g,"")};if(/^\s*(?:class|function|async\s+function)/.test(e))return s(e);let i=e.indexOf("=>"),n=e.indexOf("{");if(i>0&&(-1===n||i<n)){let t=e.slice(0,i).trim().replace(/^async\s+/,"");if(t.startsWith("(")){let e=1,s=1;for(;s<t.length&&e>0;s++)"("===t[s]?e++:")"===t[s]&&e--;return t.slice(1,s-1).replace(/\s+/g,"")}return t.replace(/\s+/g,"")}return e.indexOf("(")>0?s(e):""}renderLogContent(t){let e=[...t.args],s=t.id;if(!e.length)return"";let i=[],n=[],o=0,r=(t=>null===t?'<span class="json-null">null</span>':void 0===t?'<span class="json-null">undefined</span>':t instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(t,"",s+":html")+"</div>":t instanceof Date?t.toISOString():t instanceof Error?`<strong>${t.name}:</strong>${t.message}`:t instanceof RegExp?`<span class="json-number">${t.toString()}</span>`:"function"==typeof t?this.isClass(t)?`<span class='json-boolean'>[Class ${t.name||"anonymous"}]</span>`:this.renderFunctionCollapsed(t):t instanceof Map?`<span class="json-boolean">[Map ${t.size}]</span>`:t instanceof Set?`<span class="json-boolean">[Set ${t.size}]</span>`:t instanceof WeakMap?'<span class="json-boolean">[WeakMap]</span>':t instanceof WeakSet?'<span class="json-boolean">[WeakSet]</span>':t instanceof ArrayBuffer?`<span class="json-boolean">[ArrayBuffer ${t.byteLength} bytes]</span>`:"bigint"==typeof t?`<span class="json-number">${t.toString()}n</span>`:"object"==typeof t&&null!==t?'<div class="json-tree-container">'+this.renderJSONTree(t,"",null,null,s+":",0)+"</div>":"number"==typeof t?Number.isNaN(t)?'<span class="json-cmt">NaN</span>':isFinite(t)?`<span class="json-number">${t}</span>`:`<span class="json-cmt">${t>0?"Infinity":"-Infinity"}</span>`:"boolean"==typeof t?`<span class="json-boolean">${t}</span>`:String(t).replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>"))(e.length>0?e[0]:"").replace(/%%/g,"").replace(/%([dfsioO%])/g,(t,s)=>{if("%"===s)return"%";if("o"===s||"O"===s)return"";let n=e[++o];if(null==n)return t;let r="d"===s||"i"===s?parseInt(n,10)||0:"f"===s?parseFloat(n)||0:String(n);return i.push(r),`{{v${i.length-1}}}`}).replace(/%c/g,()=>(n.push(String(e[++o]||"")),`{{c${n.length-1}}}`)).replace(/\x01/g,"%");i.forEach((t,e)=>r=r.replace(`{{v${e}}}`,t));let l=r.split(/{{c\d+}}/);r=l.map((t,e)=>{if(!e)return t;let s=n[e-1].replace(/"/g,"").split(/\s*;\s*/).filter(t=>t.trim()&&!/\b(position|fixed|absolute|sticky|relative|static|z-index|transform|top|left|right|bottom)\s*:/i.test(t)).join("; ");return s?`<span style="${s}">${t}</span>`:t}).join("");let a=e.slice(o+1);return r+=(r?" ":"")+a.map(t=>null===t?'<span class="json-null">null</span>':void 0===t?'<span class="json-null">undefined</span>':"function"==typeof t?this.isClass(t)?`<span class='json-boolean'>[Class ${t.name||"anonymous"}]</span>`:this.renderFunctionCollapsed(t):t instanceof Error?`<strong>${t.name}:</strong>${t.message}`:t instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(t,"",s+":r:html")+"</div>":t instanceof Date?`<span class="json-string">${t.toISOString()}</span>`:t instanceof RegExp?`<span class="json-number">${t.toString()}</span>`:t instanceof Map?`<span class="json-boolean">[Map ${t.size}]</span>`:t instanceof Set?`<span class="json-boolean">[Set ${t.size}]</span>`:t instanceof WeakMap?'<span class="json-boolean">[WeakMap]</span>':t instanceof WeakSet?'<span class="json-boolean">[WeakSet]</span>':t instanceof ArrayBuffer?`<span class="json-boolean">[ArrayBuffer ${t.byteLength} bytes]</span>`:"bigint"==typeof t?`<span class="json-number">${t.toString()}n</span>`:t&&"object"==typeof t?'<div class="json-tree-container">'+this.renderJSONTree(t,"",null,null,s+":r:",0)+"</div>":"number"==typeof t?Number.isNaN(t)?'<span class="json-cmt">NaN</span>':isFinite(t)?`<span class="json-number">${t}</span>`:`<span class="json-cmt">${t>0?"Infinity":"-Infinity"}</span>`:"boolean"==typeof t?`<span class="json-boolean">${t}</span>`:String(t).replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>")).join("")}copyLog(t,e=!1,s=!1){if(s){let e=this.activeLSFilter||"local",s=this.storage[e].get(t);if(s)return navigator.clipboard.writeText(s).then(()=>this.showNotification(`已复制"${t}"的值`)).catch(t=>console.error("复制失败:",t))}let i=this.logs.find(e=>e.id===t);if(!i)return;let n="";i.count>1&&(n+=`[重复${i.count}次] `),i.args.forEach((t,e)=>{e>0&&(n+=" ");try{t instanceof HTMLElement?n+=t.outerHTML.replace(/>/g,">\n"):n+=null!==t&&"object"==typeof t?this.safeStringify(t).replace(/\\u000[23]/g,""):"function"==typeof t?this.isClass(t)?`[Class ${t.name||"anonymous"}]`:`ƒ ${t.name||"anonymous"}(${this.getParams(t)})`:null===t?"null":void 0===t?"undefined":String(t)}catch{n+="{object}"}}),navigator.clipboard.writeText(n).then(()=>this.showNotification("已复制到剪贴板")).catch(t=>console.error("复制失败:",t))}clearAllLogs(t=!1){if(this.triggerGlobalHook("beforeClear"),"network"!==this.currentTab){if(t)return this.logs=[],this.lastLog=null,this.renderContent(),void this.updateFilterCounts();if("localstorage"==this.currentTab){let t=this.activeLSFilter||"local";return void(confirm("确定要清除所有"+("local"===t?"本地存储":"session"===t?"会话存储":"Cookie")+"吗?此操作不可撤销。")&&(this.storage[t].clear(),this.renderLocalStorage()))}confirm("确定要清除所有日志吗?此操作不可撤销。")&&(this.logs=[],this.lastLog=null,this.renderContent(),this.updateFilterCounts(),this.showNotification("所有日志已清除","warning"),this.triggerGlobalHook("afterClear"))}else this.clearNetworkRequests()}updateLSFilterCounts(){if(!this.lsFiltersContainer)return;let t={local:this.storage.local.length(),session:this.storage.session.length(),cookie:this.storage.cookie.length()};this._updateFilterBtns(this.lsFiltersContainer,t,"lsType",(t,e,s)=>{let i=t.dataset.orig,n=t.dataset.icon||"",f=this._fmtCount(e,!0);return t.title=s?""+f.exactCount:"",this.icon(n)+i+(s?" ("+f.filterCount+")":"")})}renderLocalStorage(){this.updateLSFilterCounts();let t=this.activeLSFilter||"local",e=[],s="local"===t?"无本地存储":"session"===t?"无会话存储":"无Cookies",i=this.storage[t],n="local"===t?"database":"session"===t?"window-restore":"cookie-bite";if(i.length()){for(let t=0;t<i.length();t++){let s=i.key(t);null!==s&&e.push({key:s,value:i.get(s)||""})}if(e.sort((t,e)=>t.key.localeCompare(e.key,void 0,{numeric:!0,sensitivity:"base"})),this.searchQuery){let t=this.searchQuery.toLowerCase();e=e.filter(e=>e.key.toLowerCase().includes(t)||(e.value||"").toLowerCase().includes(t))}this.vsUpdate(this.lsItems,e,t=>this.renderLSItemHTML(t.key,t.value),130,{force:!0,emptyHTML:'<div class="nolog">'+this.icon("search")+"无匹配的本地存储数据</div>"})}else this.vsUpdate(this.lsItems,[],null,0,{emptyHTML:'<div class="nolog">'+this.icon(n)+s+"</div>"})}addLSItemToDOM(t,e){this.renderLocalStorage()}parseAndTypeCheck(t){try{let e=JSON.parse(t);return"object"==typeof e&&null!==e?{displayValue:this.safeStringify(e,2).replace(/</g,"<").replace(/>/g,">"),valueType:Array.isArray(e)?"array":"object",isJSON:!0}:null==e?{displayValue:null,valueType:null,isJSON:!1}:{displayValue:t,valueType:typeof e,isJSON:!1}}catch{return{displayValue:t,valueType:"string",isJSON:!1}}}isLSEmpty(){let t=this.activeLSFilter||"local";return 0===this.storage[t].length()}escapeHtml(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}addLSItem(){this.onAddLSClick()}editLSItem(t){this.openLSEditor(t)}saveLSItem(){this.onEditorSave()}fixKeysOnly(t){try{return JSON.parse(t),t}catch{return t.replace(/([{,])\s*([a-zA-Z_]\w*)\s*:/g,'$1"$2":').replace(/(":)\s*(?!true|false|null|\d+(\.\d+)?)([^\s,"{[}\]]+?)\s*(?=,|})/gs,'$1"$3"')}}cancelEditLSItem(){this.closeLSEditor()}removeLSItem(t){let e=this.activeLSFilter||"local";confirm("是否删除"+("local"===e?"本地存储":"session"===e?"会话存储":"Cookie")+'键名 "'+t+'"?')&&(this.storage[e].remove(t),this.renderLocalStorage(),this.showNotification('已删除"'+t+'"'))}findLSItem(t){return this.overlay.querySelector(`.ls-item[data-key="${t}"]`)}updateLSItemView(t){let e=this.findLSItem(t);if(!e)return;let s=this.activeLSFilter||"local",i=this.storage[s].get(t);if(null===i)return void e.remove();let{displayValue:n,valueType:o,isJSON:r}=this.parseAndTypeCheck(i),l=r?this.highlightJson(n):this.escapeHtml(n),a="";if(r){let t=JSON.parse(i);a=`<div class="ls-value json-tree-container">${this.renderJSONValue(t,"")}</div>`}else a=`<div class="ls-value" title="${this.escapeHtml(n)}"><span class="json-${o}">${"string"===o?'"':""}${l}${"string"===o?'"':""}</span></div>`;let c=this.escapeHtml(t);e.innerHTML=`<div class="ls-key-row"><div class="ls-key" title="${c}">${c}</div><div class="ls-actions"><button class="ls-action-btn" data-action="edit" data-key="${c}" title="编辑">${this.icon("edit")}</button><button class="ls-action-btn" data-action="copy" data-key="${c}" title="复制">${this.icon("copy")}</button><button class="ls-action-btn" data-action="remove" data-key="${c}" title="删除">${this.icon("trash")}</button></div></div>${a}<div class="ls-value-type" title="${o}">类型:${o}</div>`}setupGlobalEventHandlers(){this.activeFilter="all",this.searchQuery="",this.tCError=t=>{""!==t.filename||0!==t.lineno||0!==t.colno?(console.error(t.error.toString(),{"错误信息":t.message||"无信息","文件名":t.filename||"未知","位置":`${t.lineno}:${t.colno}`||"0:0","是否可信":t.isTrusted||!0,"类型":t.type||"error"}),t.preventDefault()):console.error("脚本错误")},this.tCUR=t=>{console.error("未处理的Promise异常",t.reason),t.preventDefault()},this.RSError=t=>{let e=new Set(["IMG","SCRIPT","LINK","VIDEO","AUDIO","SOURCE","TRACK"]),s=t.target;if(!e.has(s.tagName))return;let i=s.src||s.href||s.currentSrc||"[未知路径]";console.error(`[资源错误] <${s.tagName.toLowerCase()}>加载失败:${i}`)},document.addEventListener("error",this.RSError,!0),window.addEventListener("error",this.tCError),window.addEventListener("unhandledrejection",this.tCUR),window.addEventListener("resize",()=>{if(window.innerWidth<=768&&this.consoleContainer&&(this.consoleContainer.style.width="",this.consoleContainer.style.flex="",this.consoleContainer.style.transform="",this.consoleContainer.style.transition=""),window.innerWidth>768&&!window.matchMedia("(pointer:fine)").matches&&"network"===this.currentTab){let t=this.overlay.querySelector('.tab-btn[data-tab="console"]');t&&t.click()}})}setupSelfProtection(){if(this.protectInterval)return;let t=this;this.protectInterval=setInterval(()=>{window.thinConsole&&window.thinConsole.tC!==t&&(window.thinConsole.tC=t);(!this.host||!document.documentElement.contains(this.host)||!this.host.shadowRoot)&&(this.host=null,this.initShadow(),t.createButton(),t.createOverlayElement(),t.tabButtons=t.overlay.querySelectorAll(".tab-btn"),t.renderContent(),t.createStyles(),t.createNotificationElement());let e=this.shadowRoot.getElementById("thinConsole-btn");e&&e.isConnected?"flex"!==e.style.display&&(e.style.display="flex"):(t.btn=null,t.createButton());let s=this.shadowRoot.getElementById("consoleOverlay");s&&s.isConnected?"flex"!==s.style.display&&(s.style.display="flex"):(t.overlay=null,t.createOverlayElement(),t.createStyles());let i=this.shadowRoot.querySelector("style[tcstyle]");(!i||!i.innerHTML||i.innerHTML.length<100)&&t.createStyles();let n=this.shadowRoot.getElementById("notification");n&&n.isConnected?"block"!==n.style.display&&(n.style.display="block"):(t.notification=null,t.createNotificationElement());let o=t=>{if(!t||1!==t.nodeType)return;let e=t=>{"false"!==t.contentEditable&&(t.contentEditable="false",t.setAttribute("tc-lock",""),r.observe(t,{attributes:!0,attributeFilter:["contenteditable"]}))};e(t),t.querySelectorAll("*").forEach(e)},r=new MutationObserver(t=>{t.forEach(t=>{"attributes"===t.type&&"contentEditable"===t.attributeName&&"true"===t.target.contentEditable&&t.target.hasAttribute("tc-lock")&&(t.target.contentEditable="false")})});setTimeout(()=>{o(t.btn),o(t.overlay),o(t.notification),o(t.host)},0)},5e3)}disablePlugin(t){return this.disabledPlugins.includes(t)||this.disabledPlugins.push(t),this.destroyPlugin(t),this}enablePlugin(t){return this.disabledPlugins=this.disabledPlugins.filter(e=>e!==t),this.loadSinglePlugin(t),this}applyIcon(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("applyIcon参数必须是对象");for(let s in e){if(!e.hasOwnProperty(s))continue;if("string"!=typeof e[s]||-1===e[s].indexOf("|"))throw new Error("图标"+s+"格式错误,必须是viewBox|path.d格式");t[s]=e[s]}}setFilterIcon(e,s){let i=this.overlay.querySelector("[data-type=\""+e+"\"],[data-ls-type=\""+e+"\"],[data-orig=\""+e+"\"],[data-net-filter=\""+e+"\"]");if(!i)return!1;if(!t[s])throw new Error("图标"+s+"不存在");i.dataset.icon=s;let n=i.dataset.orig||i.dataset.type||i.dataset.lsType||i.dataset.netFilter||"",o=i.classList.contains("active");i.innerHTML=this.icon(s)+" "+n+(o?" (0)":"");return!0}createSandbox(t){let e=this;return new Proxy(t,{get(s,i){if("options"===i||"pluginOption"===i)return void 0;if("__isSandbox"===i)return!0;if("string"==typeof i&&i in s){let t=s[i];return"function"==typeof t?t.bind(e):t}return s[i]},set(t,s,i){return"options"===s||"pluginOption"===s||console.warn(`[thinConsole] 插件沙箱阻止了修改属性: ${String(s)}`),!0},deleteProperty(t,s){return"options"===s||"pluginOption"===s?!1:(delete t[s],!0)}})}loadSinglePlugin(t){if(!this.disabledPlugins.includes(t)&&e.plugins[t]&&!this.plugins[t]){try{let s=e.plugins[t],o=this.createSandbox(this),i=new s(o);i.pluginOption="object"==typeof this.options.pluginOption[t]&&!Array.isArray(this.options.pluginOption[t])&&null!==this.options.pluginOption[t]?this.options.pluginOption[t]:{};if(i.init(),this.plugins[t]=i,i.addTab){let e=i.addTab();this.createPluginTab(e),this.pluginTabs[t]={id:e.id,name:e.name,icon:e.icon||"plug",plugin:i}}this.triggerGlobalHook("pluginMount",t,i)}catch(e){console.error(`插件"${t}"加载失败:`,e)}return this}}applyCSS(e){let t=document.createElement("style");return t.textContent=e,this.shadowRoot.appendChild(t),t}createVirtualList(t,e){this.vsInit(t);let s=e.initialData||[],i=e.itemHeight,n=e.renderItem,o=e=>"string"==typeof e?e:e.outerHTML,r=t=>o(n(t)),h=e.emptyHTML||"",k=e.trackBy;this.vsUpdate(t,s,r,i,{force:!0,emptyHTML:h,trackBy:k});return{update:(e,s)=>{this.vsUpdate(t,e||[],s?t=>o(s(t)):r,i,{emptyHTML:h,trackBy:k})},render:()=>this.vsRender(t),destroy:()=>{if(t._vs){t.removeEventListener("scroll",t._vs.scrollHandler),delete t._vs}}}}initPlugins(){return Object.keys(e.plugins).forEach(t=>{this.disabledPlugins.includes(t)||this.loadSinglePlugin(t)}),this}destroyPlugin(t){let e=this.plugins[t];if(!e)return;"function"==typeof e.destroy&&e.destroy();let s=this.pluginTabs[t]?.id;if(s){let t=this.overlay.querySelector(`.tab-btn[data-tab="${s}"]`);t?.remove();let e=this.pluginViewContainers[s];e?.remove(),delete this.pluginViewContainers[s]}return delete this.plugins[t],delete this.pluginTabs[t],this.triggerGlobalHook("pluginUnmount",t),this}triggerGlobalHook(t,...s){return e.hooks[t]&&e.hooks[t].forEach(e=>{try{e.call(this,...s)}catch(e){console.error(`钩子"${t}"执行错误:`,e)}}),this}destroy(){e.tC===this&&(Object.assign(console,this.originalConsole),Object.keys(this.plugins).forEach(t=>this.destroyPlugin(t)),clearInterval(this.protectInterval),this.mediaQuery&&this.themeChangeHandler&&this.mediaQuery.removeEventListener("change",this.themeChangeHandler),this.timerMap&&this.timerMap.forEach(t=>clearTimeout(t.timeoutId)),this.timerMap&&this.timerMap.clear(),this._updateFilterRaf&&cancelAnimationFrame(this._updateFilterRaf),this.overlay&&this.overlay.querySelectorAll("[data-filter-ro]").forEach(t=>{t._tcFilterRO&&t._tcFilterRO.disconnect(),t._tcFilterMO&&t._tcFilterMO.disconnect()}),this.btn?.remove(),this.shadowRoot?.querySelector("style[tcstyle]")?.remove(),this.host?.remove(),this.overlay?.remove(),this.notification?.remove(),document.removeEventListener("error",this.RSError,!0),window.removeEventListener("error",this.tCError),window.removeEventListener("unhandledrejection",this.tCUR),this.originalXHR&&(window.XMLHttpRequest=this.originalXHR),this.originalFetch&&(window.fetch=this.originalFetch),e.tC=null)}createNetRequest(t,e){return this._netReqId=this._netReqId||1,{id:++this._netReqId,url:e||"",method:(t||"GET").toUpperCase(),status:0,statusText:"",reqHeaders:{},reqBody:null,resHeaders:{},resBody:null,startTime:Date.now(),endTime:0,duration:0,error:null}}finalizeNetRequest(t,e,s,i,n,o){t.status=e,t.statusText=s||"",t.endTime=Date.now(),t.duration=t.endTime-t.startTime,i&&(t.resHeaders=i),null!=n&&(t.resBody=n),o&&(t.error=o),"network"===this.currentTab&&this.renderNetworkList()}pushNetRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxNetwork&&this.networkRequests.splice(0,this.networkRequests.length-this.maxNetwork),"network"===this.currentTab&&this.renderNetworkList()}_isNetDisabled(t){if(0===this.netDisabledTypes.size)return!1;let e=t.toLowerCase();return this.netDisabledTypes.has("all")||this.netDisabledTypes.has(e)}captureNetworkRequests(){this.originalXHR=this.originalXHR||window.XMLHttpRequest;let t=this,e=this.originalXHR;window.XMLHttpRequest=function(){let s=new e,i=t.createNetRequest("GET",""),n=s.open;s.open=function(t,e){return i.method=t.toUpperCase(),i.url=e,n.apply(s,arguments)};let o=s.send;s.send=function(e){if(t._isNetDisabled(i.method))return;i.reqBody=e,i.startTime=Date.now();let n={...i};return t.pushNetRequest(n),s.addEventListener("loadend",function(){let e={},i=null;try{s.getAllResponseHeaders().trim().split("\n").forEach(t=>{let s=t.indexOf(":");s>0&&(e[t.slice(0,s).trim()]=t.slice(s+1).trim())})}catch(t){}try{i=s.responseText}catch(t){}t.finalizeNetRequest(n,s.status,s.statusText,e,i,null)}),s.addEventListener("error",function(){t.finalizeNetRequest(n,0,"",null,null,"Network Error")}),s.addEventListener("abort",function(){t.finalizeNetRequest(n,0,"",null,null,"Aborted")}),o.apply(s,arguments)};let r=s.setRequestHeader;return s.setRequestHeader=function(t,e){return i.reqHeaders[t]=e,r.apply(s,arguments)},s},this.originalFetch=this.originalFetch||window.fetch;let s=this.originalFetch;window.fetch=function(e,i){let n="string"==typeof e?e:e.url,o=(i&&i.method||"GET").toUpperCase();if(t._isNetDisabled(o))return Promise.reject(new Error("Request disabled by thinConsole"));let r=t.createNetRequest(o,n);return i&&i.headers&&(i.headers instanceof Headers?i.headers.forEach((t,e)=>r.reqHeaders[e]=t):"object"==typeof i.headers&&Object.assign(r.reqHeaders,i.headers)),i&&i.body&&(r.reqBody=i.body),t.pushNetRequest(r),s.apply(window,arguments).then(e=>{let s={};return e.headers.forEach((t,e)=>s[e]=t),e.clone().text().then(i=>{t.finalizeNetRequest(r,e.status,e.statusText,s,i,null)}).catch(()=>{t.finalizeNetRequest(r,e.status,e.statusText,s,null,null)}).then(()=>e)}).catch(e=>{throw"AbortError"===e.name?t.finalizeNetRequest(r,0,"",null,null,"Aborted"):t.finalizeNetRequest(r,0,"",null,null,e.message),e})}}renderNetFilters(){this.netFiltersEl&&(this.netFiltersEl.innerHTML=[{id:"all",name:"全部",icon:"list"},{id:"get",name:"获取",icon:"download"},{id:"post",name:"提交",icon:"upload"},{id:"put",name:"更新",icon:"pen"},{id:"success",name:"成功",icon:"check-circle"},{id:"failed",name:"失败",icon:"times-circle"}].map(t=>`<button class="net-filter-btn ${this.activeNetFilter===t.id?"active":""}" data-net-filter="${t.id}" data-orig="${t.name}" data-icon="${t.icon}">${this.icon(t.icon)} ${t.name}</button>`).join(""),this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(t=>{t.addEventListener("click",()=>{this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.activeNetFilter=t.dataset.netFilter,this.renderNetworkList(),this.updateNetDisableBtn(),this.scrollFilterIntoView(this.netFiltersEl,t)})}),this.updateNetFilterCounts())}updateNetFilterCounts(){if(!this.netFiltersEl)return;let t=this.networkRequests,e={all:t.length,get:t.filter(t=>"get"===t.method.toLowerCase()).length,post:t.filter(t=>"post"===t.method.toLowerCase()).length,put:t.filter(t=>"put"===t.method.toLowerCase()).length,success:t.filter(t=>t.status>=200&&t.status<400).length,failed:t.filter(t=>0===t.status||t.status>=400||t.error).length};this._updateFilterBtns(this.netFiltersEl,e,"netFilter",(t,e,s)=>{let i=t.dataset.orig,n=t.dataset.icon||"",f=this._fmtCount(e,!0);return t.title=s?""+f.exactCount:"",this.icon(n)+" "+i+(s?" ("+f.filterCount+")":"")})}updateNetDisableBtn(){if(!this.netDisableBtn)return;let t=this.activeNetFilter,e="";"all"===t?e="全部":"get"===t?e="获取":"post"===t?e="提交":"put"===t?e="更新":"success"===t?e="成功(全部)":"failed"===t&&(e="失败(全部)");let s=this.netDisabledTypes.has(t);this.netDisableBtn.innerHTML=this.icon("ban"),this.netDisableBtn.title=s?`已禁用${e}请求`:`禁用${e}请求`,this.netDisableBtn.classList.toggle("disabled",s)}toggleNetDisable(){let t=this.activeNetFilter,e="";if("all"===t?e="全部":"get"===t?e="获取":"post"===t?e="提交":"put"===t?e="更新":"success"===t?e="成功(全部)":"failed"===t&&(e="失败(全部)"),this.netDisabledTypes.has(t)){this.netDisabledTypes.delete(t);var s=!1}else this.netDisabledTypes.add(t),s=!0;this.updateNetDisableBtn(),this.showNotification(s?`已禁用${e}请求`:`已恢复${e}请求`,s?"warning":"")}getFilteredNetRequests(){let t=this.networkRequests;if(!this.activeNetFilter||"all"===this.activeNetFilter)return t;let e=this.activeNetFilter;return"get"===e||"post"===e||"put"===e?t.filter(t=>t.method.toLowerCase()===e):"success"===e?t.filter(t=>t.status>=200&&t.status<400):"failed"===e?t.filter(t=>0===t.status||t.status>=400||t.error):t}renderNetworkList(){if("network"!==this.currentTab)return;if(!this.networkItems)return;let t=this.getFilteredNetRequests();if(this.searchQuery){let e=this.searchQuery.toLowerCase();t=t.filter(t=>{if(t.url.toLowerCase().includes(e))return!0;if(t.method.toLowerCase().includes(e))return!0;try{if(this.safeStringify(t.reqHeaders).toLowerCase().includes(e))return!0}catch(t){}try{if(("string"==typeof t.reqBody?t.reqBody:this.safeStringify(t.reqBody)).toLowerCase().includes(e))return!0}catch(t){}try{if(this.safeStringify(t.resHeaders).toLowerCase().includes(e))return!0}catch(t){}return!!(t.resBody||"").toLowerCase().includes(e)})}if(this.updateNetFilterCounts(),0===t.length)return void this.vsUpdate(this.networkItems,[],null,0,{emptyHTML:'<div class="nolog">'+this.icon("wifi")+"暂无网络请求</div>"});this.vsUpdate(this.networkItems,t,t=>this.renderNetworkItem(t),100)}renderNetworkItem(t){let e=t.status>0?Math.floor(t.status/100)+"xx":"pending",s=t.error||t.status>=400?"net-failed":t.status>=200&&t.status<400?"net-success":"",i=t.status>0?String(t.status):t.error?"ERR":"...",n=t.duration>0?t.duration+"ms":"",o=n?i+" "+n:i,r="",u=this.escapeHtml(t.url);try{r=new Date(t.startTime).toLocaleTimeString()}catch(t){r=""}return`<div class="net-item ${s}" data-req-id="${t.id}"><div class="net-row1"><span class="net-method net-method-${t.method}">${t.method}</span><span class="net-time">${this.escapeHtml(r)}</span></div><div class="net-row2"><span class="net-url" title="${u}">${u}</span><span class="net-status net-status-${e}">${this.escapeHtml(o)}</span></div><div class="net-row3"><button class="net-copy-btn" data-action="copy" title="复制请求JSON">${this.icon("copy")} 复制</button><button class="net-detail-btn" data-action="detail" title="查看详情">${this.icon("eye")} 详情</button></div></div>`}renderNetJsonTree(t,e){try{let s=JSON.parse(t);return null==s?this.highlightJson(this.escapeHtml(t)):'<div class="json-tree-container">'+this.renderJSONTree(s,"",null,null,e,0,!0)+"</div>"}catch(e){return this.highlightJson(this.escapeHtml(t))}}showNetDetail(t){let e=this.networkRequests.find(e=>e.id===t);if(!e)return;this.netDetailId=t;let s=e.status>0?Math.floor(e.status/100)+"xx":"pending",i=e.status>0?e.status+" "+(e.statusText||""):e.error||"等待中...",n=e.duration>0?e.duration+"ms":"",o=n?i+" ("+n+")":i,r="";try{r=this.safeStringify(e.reqHeaders,2,!1)}catch(t){r=String(e.reqHeaders||"")}let l=!r||"{}"===r||"null"===r,a=l?'<span class="net-detail-empty">无请求头</span>':this.renderNetJsonTree(r,"net-"+t+"-reqHeaders"),c="";if(e.reqBody)try{c="string"==typeof e.reqBody?e.reqBody:this.safeStringify(e.reqBody,2,!1)}catch(t){c=String(e.reqBody)}let d=!c||"null"===c||"undefined"===c,h=d?'<span class="net-detail-empty">无请求内容</span>':this.renderNetJsonTree(c,"net-"+t+"-reqBody"),p="";try{p=this.safeStringify(e.resHeaders,2,!1)}catch(t){p=String(e.resHeaders||"")}let u=!p||"{}"===p||"null"===p,g=u?'<span class="net-detail-empty">无响应头</span>':this.renderNetJsonTree(p,"net-"+t+"-resHeaders"),f=e.resBody||"",m="";if(f)try{m=JSON.stringify(JSON.parse(f),null,2)}catch(t){m=f}let b=!m||"null"===m||"undefined"===m,y=b?'<span class="net-detail-empty">无响应内容</span>':this.renderNetJsonTree(m,"net-"+t+"-resBody"),v=(t,e,s,i)=>`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">${t}</div>${i?"":`<button class="net-detail-copy-section" data-copy-text="${this.escapeHtml(s)}" title="复制">${this.icon("copy")}</button>`}</div><div class="${i||e.indexOf("json-tree-container")>=0?"net-detail-value":"net-detail-value net-detail-code"}">${e}</div></div>`,x=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">网址</div><button class="net-detail-copy-section" data-copy-text="${this.escapeHtml(e.url)}" title="复制网址">${this.icon("copy")}</button></div><div class="net-detail-value net-detail-code">${this.escapeHtml(e.url)}</div></div>`,w=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">类型</div></div><span class="net-method net-method-${e.method}">${e.method}</span></div>`,k=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">状态</div></div><span class="net-status net-status-${s}">${this.escapeHtml(o)}</span></div>`,S=v("请求头",a,r,l),E=v("请求内容",h,c,d),C=v("响应头",g,p,u),L=v("响应内容",y,m,b);this.netDetailBody.innerHTML=x+w+k+S+E+C+L,this.netDetailBody.querySelectorAll(".net-detail-copy-section").forEach(t=>{t.addEventListener("click",()=>{let e=t.getAttribute("data-copy-text")||"";navigator.clipboard.writeText(e).then(()=>this.showNotification("已复制")).catch(()=>{})})});let T=this.overlay.querySelector("#netResendIconBtn");T&&T.addEventListener("click",()=>this.resendRequest(e)),this.netDetailOverlay.style.display="flex"}resendRequest(t){this.netDetailOverlay.style.display="none",this.netNewOverlay.style.display="flex",this.netNewUrl.value=t.url,this.netNewMethod.value=t.method;let e="";if(t.reqBody)try{e="string"==typeof t.reqBody?t.reqBody:JSON.stringify(t.reqBody,null,2)}catch(t){e=""}this.netNewBody.value=e||"";let s="";try{t.reqHeaders&&"object"==typeof t.reqHeaders&&(s=(Array.isArray(t.reqHeaders)?t.reqHeaders:Object.entries(t.reqHeaders)).map(t=>Array.isArray(t)?t[0]+": "+t[1]:t).join("\n"))}catch(t){}this.netNewHeaders.value=s||""}sendNewRequest(){if(this.editorState.visible){let t=this.editorState.mode;if("code"===t)return void this.showNotification("正在运行代码,无法发送请求","warning");if("ls"===t)return void this.showNotification("正在保存键值,无法发送请求","warning")}let t=this.netNewUrl.value.trim();if(!t)return void this.showNotification("请输入网址","warning");let e=this.netNewMethod.value,s=this.netNewBody.value.trim(),i=this.netNewHeaders.value.trim(),n={};i&&i.split("\n").forEach(t=>{let e=t.indexOf(":");e>0&&(n[t.slice(0,e).trim()]=t.slice(e+1).trim())});let o={method:e,headers:n};if(s&&"GET"!==e&&"HEAD"!==e)try{o.body=JSON.stringify(JSON.parse(s)),n["Content-Type"]||(n["Content-Type"]="application/json")}catch(t){o.body=s}this.netSending=!0,this.netNewVisible=!1,this.netNewOverlay.style.display="none",this.showNotification("正在发送请求...");let r={id:++this._netReqId,url:t,method:e,status:0,statusText:"",reqHeaders:n,reqBody:o.body||null,resHeaders:{},resBody:null,startTime:Date.now(),endTime:0,duration:0,error:null};this.networkRequests.push(r),(this.originalFetch||window.fetch).call(window,t,o).then(t=>{this.netSending=!1,r.status=t.status,r.statusText=t.statusText,r.endTime=Date.now(),r.duration=r.endTime-r.startTime,t.clone().text().then(t=>{r.resBody=t}).catch(()=>{}),t.headers.forEach((t,e)=>r.resHeaders[e]=t),this.showNotification("请求完成: "+t.status,t.status>=400?"warning":""),"network"===this.currentTab&&this.renderNetworkList()}).catch(t=>{this.netSending=!1,r.error=t.message,r.status=0,r.endTime=Date.now(),r.duration=r.endTime-r.startTime,this.showNotification("请求失败: "+t.message,"warning"),"network"===this.currentTab&&this.renderNetworkList()})}renderNetworkPanel(){this.renderNetFilters(),this.updateNetDisableBtn(),this.renderNetworkList()}clearNetworkRequests(){let t=this.activeNetFilter||"all",e="";"all"===t?e="全部":"get"===t?e="获取":"post"===t?e="提交":"put"===t?e="更新":"success"===t?e="成功":"failed"===t&&(e="失败");let s=this.getFilteredNetRequests();if(confirm("确定要清除所有"+e+"请求吗?\n共 "+s.length+" 条请求将被删除,此操作不可撤销。")){if("all"===t)this.networkRequests=[];else{let e="get"===t||"post"===t||"put"===t?e=>e.method.toLowerCase()!==t:"success"===t?t=>!(t.status>=200&&t.status<400):t=>!(0===t.status||t.status>=400||t.error);this.networkRequests=this.networkRequests.filter(e)}this.renderNetworkList(),this.showNotification("已清空"+e+"请求")}}switchTab(t){let e=Array.from(this.tabButtons).find(e=>e.dataset.tab===t);e&&e.click()}show(t="console"){return this.overlay||this.createOverlayElement(),this.switchTab(t),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this}hide(){return this.overlay&&(this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose")),this}get storage(){let t=t=>{document.cookie=encodeURIComponent(t)+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/",document.cookie=encodeURIComponent(t)+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT"},e=(t,e,s,i,n,o)=>({get:t,set:e,remove:s,clear:i,length:n,key:o});return{local:e(t=>localStorage.getItem(t),(t,e)=>localStorage.setItem(t,e),t=>localStorage.removeItem(t),()=>localStorage.clear(),()=>localStorage.length,t=>localStorage.key(t)),session:e(t=>sessionStorage.getItem(t),(t,e)=>sessionStorage.setItem(t,e),t=>sessionStorage.removeItem(t),()=>sessionStorage.clear(),()=>sessionStorage.length,t=>sessionStorage.key(t)),cookie:e(t=>{let e=encodeURIComponent(t),s=document.cookie.match(new RegExp("(?:^|;\\s)"+e.replace(/([.*+?^${}()|[\]\\])/g,"\\$1")+"=([^;]*)"));return s?decodeURIComponent(s[1]):null},(t,e,s)=>{let i=new Date;i.setTime(i.getTime()+864e5*(s||365)),document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(e)+";expires="+i.toUTCString()+";path=/"},t,()=>{document.cookie.split(";").forEach(e=>{let s=e.split("=")[0].trim();s&&t(s)})},()=>document.cookie?document.cookie.split(";").filter(t=>t.trim()).length:0,t=>{let e=document.cookie?document.cookie.split(";").filter(t=>t.trim()):[];return e[t]?decodeURIComponent(e[t].split("=")[0]):null})}}icon(e,s){let i=String(e||"").trim();if(!i)return"";let n=t[i];if(!n)return"";let o=n.indexOf("|");return'<svg class="ico ico-'+i+(s?" "+s:"")+'" viewBox="'+n.slice(0,o)+'" aria-hidden="true"><path fill="currentColor" d="'+n.slice(o+1)+'"/></svg>'}treeToggleHtml(){return'<span class="tree-toggle">'+this.icon("angle-right")+this.icon("angle-down")+"</span>"}}e.plugins={},window.thinConsole=e,e.tC=null,e.hooks={beforeRender:[],afterRender:[],beforeLog:[],afterLog:[],beforeOpen:[],afterOpen:[],beforeClose:[],afterClose:[],beforeClear:[],afterClear:[],pluginMount:[],pluginUnmount:[]},e.show=t=>(e.tC?.show(t),e),e.hide=()=>(e.tC?.hide(),e),e.destroy=()=>e.tC?.destroy(),e.log=(...t)=>(console.log(...t),e),e.info=(...t)=>(console.info(...t),e),e.warn=(...t)=>(console.warn(...t),e),e.error=(...t)=>(console.error(...t),e),e.addPlugin=function(t,i){if(e.tC){if(i.prototype instanceof s){if(e.plugins[t]=i,e.tC.disabledPlugins.includes(t))return;if(e.tC.pluginEnabled&&!e.tC.plugins[t])try{let o=e.tC.createSandbox(e.tC);let s=new i(o);s.pluginOption="object"==typeof e.tC.options.pluginOption[t]&&!Array.isArray(e.tC.options.pluginOption[t])&&null!==e.tC.options.pluginOption[t]?e.tC.options.pluginOption[t]:{};if(s.init(),e.tC.plugins[t]=s,s.addTab){let i=s.addTab();e.tC.pluginTabs[t]={id:i.id,name:i.name,icon:i.icon||"tool",plugin:s},e.tC.createPluginTab(i)}e.tC.triggerGlobalHook("pluginMount",t,s)}catch(i){console.error(`插件"${t}"动态加载失败:`,i)}}else{if("function"!=typeof i)throw new Error(`插件"${t}"必须是类或函数类型`);if(!e.tC.options.plugins||e.tC.disabledPlugins.includes(t))return;try{i.call(null,e.tC.createSandbox(e.tC)),e.tC.triggerGlobalHook("pluginMount",t,null)}catch(i){console.error(`函数插件"${t}"执行失败:`,i)}}return e}},e.addTabs=function(t){if(!e.tC)return e;Array.isArray(t)||(t=[t]);for(let s of t){if(e.tC.customTabCount>=5){console.warn("自定义Tab数量已达上限(5个)");break}if(!s.id||!s.name){console.warn("Tab必须包含id和name属性");continue}if(e.tC.pluginViewContainers[s.id]){console.warn("Tab ID '"+s.id+"'已存在");continue}e.tC.createPluginTab({id:s.id,name:s.name,icon:s.icon||"plug"});let t=e.tC.pluginViewContainers[s.id];t&&(t.innerHTML="","function"==typeof s.render?s.render(t):s.html&&(t.innerHTML=s.html),s.onShow&&(e.tC.pluginTabs[s.id]={id:s.id,name:s.name,icon:s.icon||"plug",onShow:s.onShow})),e.tC.customTabCount++}return e},e.addHook=function(t,s){return e.hooks[t]&&!e.hooks[t].includes(s)?e.hooks[t].push(s):console.warn(`未知钩子:${t}`),e},e.removeHook=function(t,s){return e.hooks[t]&&(e.hooks[t]=e.hooks[t].filter(t=>t!==s)),e},e.setFilterCounts=function(t){return e.tC&&e.tC._updateFilterCounts(e.tC.pluginViewContainers[e.tC.currentTab],"object"==typeof t?t:null,!0),e};class s{constructor(t){if(!(t instanceof e))throw new Error("插件必须绑定到thinConsole实例");this.tC=t,this.pluginOption={},this.id=this.constructor.name.toLowerCase()}init(){}iszh(){return!0}isen(){return!1}isMobile(){return/iPad|Android(?!.*Mobile)|Mobi|Android|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}render(t){}onShow(){}onHide(){}destroy(){}}return e.tCPlugin=s,"undefined"!=typeof window&&(window.tCPlugin=s),e});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):t.thinConsole=e()}("undefined"!=typeof self?self:this,function(){let t={"angle-down":"0 0 384 512|M169.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 306.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z","angle-right":"0 0 256 512|M247.1 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L179.2 256 41.9 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z","arrow-left":"0 0 512 512|M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 288H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H109.3l105.4-105.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z",ban:"0 0 512 512|M367.2 412.5 99.5 144.8C77.1 176.2 64 214.6 64 256c0 106 86 192 192 192 41.5 0 79.9-13.1 111.2-35.5m45.3-45.3C434.9 335.8 448 297.4 448 256c0-106-86-192-192-192-41.5 0-79.9 13.1-111.2 35.5zM0 256a256 256 0 1 1 512 0 256 256 0 1 1-512 0",check:"0 0 448 512|M434.8 70.1c14.3 10.4 17.5 30.4 7.1 44.7l-256 352c-5.5 7.6-14 12.3-23.4 13.1s-18.5-2.7-25.1-9.3l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l101.5 101.5 234-321.7c10.4-14.3 30.4-17.5 44.7-7.1z","check-circle":"0 0 512 512|M256 512a256 256 0 1 1 0-512 256 256 0 1 1 0 512m118-366.3c-10.7-7.8-25.7-5.4-33.5 5.3L221.1 315.2 169 263.1c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l72 72c5 5 11.8 7.5 18.8 7s13.4-4.1 17.5-9.8l135.9-187c7.8-10.7 5.4-25.7-5.3-33.5","chevron-down":"0 0 448 512|M201.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 338.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z","chevron-up":"0 0 448 512|M201.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L224 173.3 54.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z",code:"0 0 576 512|M360.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6m64.6 136.1c-12.5 12.5-12.5 32.8 0 45.3l73.4 73.4-73.4 73.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l96-96c12.5-12.5 12.5-32.8 0-45.3l-96-96c-12.5-12.5-32.8-12.5-45.3 0zm-274.7 0c-12.5-12.5-32.8-12.5-45.3 0l-96 96c-12.5 12.5-12.5 32.8 0 45.3l96 96c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l73.3-73.4c12.5-12.5 12.5-32.8 0-45.3z",copy:"0 0 448 512|M192 0c-35.3 0-64 28.7-64 64v256c0 35.3 28.7 64 64 64h192c35.3 0 64-28.7 64-64V119.4c0-17.4-7.1-34.1-19.7-46.2l-57.7-55.4A64.1 64.1 0 0 0 326.3 0zM64 128c-35.3 0-64 28.7-64 64v256c0 35.3 28.7 64 64 64h192c35.3 0 64-28.7 64-64v-16h-64v16H64V192h16v-64z",database:"0 0 448 512|M448 205.8c-14.8 9.8-31.8 17.7-49.5 24-47 16.8-108.7 26.2-174.5 26.2s-127.6-9.5-174.5-26.2c-17.6-6.3-34.7-14.2-49.5-24V288c0 44.2 100.3 80 224 80s224-35.8 224-80zm0-77.8V80c0-44.2-100.3-80-224-80S0 35.8 0 80v48c0 44.2 100.3 80 224 80s224-35.8 224-80m-49.5 261.8C351.6 406.5 289.9 416 224 416s-127.6-9.5-174.5-26.2c-17.6-6.3-34.7-14.2-49.5-24V432c0 44.2 100.3 80 224 80s224-35.8 224-80v-66.2c-14.8 9.8-31.8 17.7-49.5 24",download:"0 0 448 512|M256 32c0-17.7-14.3-32-32-32s-32 14.3-32 32v210.7l-41.4-41.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l96 96c12.5 12.5 32.8 12.5 45.3 0l96-96c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 242.7zM64 320c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64h320c35.3 0 64-28.7 64-64v-32c0-35.3-28.7-64-64-64h-46.9l-56.6 56.6c-31.2 31.2-81.9 31.2-113.1 0L110.9 320zm304 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48",edit:"0 0 512 512|M471.6 21.7c-21.9-21.9-57.3-21.9-79.2 0L368 46.1l97.9 97.9 24.4-24.4c21.9-21.9 21.9-57.3 0-79.2zm-299.2 220c-6.1 6.1-10.8 13.6-13.5 21.9l-29.6 88.8c-2.9 8.6-.6 18.1 5.8 24.6s15.9 8.7 24.6 5.8l88.8-29.6c8.2-2.7 15.7-7.4 21.9-13.5L432 177.9 334.1 80zM96 64c-53 0-96 43-96 96v256c0 53 43 96 96 96h256c53 0 96-43 96-96v-96c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32z",exclamation:"0 0 128 512|M64 432c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40M64 0c26.5 0 48 21.5 48 48v1.7l-16 304c-.9 17-15 30.3-32 30.3s-31-13.3-32-30.3l-16-304V48C16 21.5 37.5 0 64 0","exclamation-triangle":"0 0 512 512|M256 0c14.7 0 28.2 8.1 35.2 21l216 400c6.7 12.4 6.4 27.4-.8 39.5S486.1 480 472 480H40c-14.1 0-27.2-7.4-34.4-19.5s-7.5-27.1-.8-39.5l216-400c7-12.9 20.5-21 35.2-21m0 352a32 32 0 1 0 0 64 32 32 0 1 0 0-64m0-192c-18.2 0-32.7 15.5-31.4 33.7l7.4 104c.9 12.5 11.4 22.3 23.9 22.3 12.6 0 23-9.7 23.9-22.3l7.4-104c1.3-18.2-13.1-33.7-31.4-33.7z",eye:"0 0 576 512|M288 32c-80.8 0-145.5 36.8-192.6 80.6-46.8 43.5-78.1 95.4-93 131.1-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1C142.5 443.1 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C433.5 68.9 368.8 32 288 32M144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0m144-64c0 35.3-28.7 64-64 64-11.5 0-22.3-3-31.7-8.4-1 10.9-.1 22.1 2.9 33.2 13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-12.2-45.7-55.5-74.8-101.1-70.8 5.3 9.3 8.4 20.1 8.4 31.7",info:"0 0 192 512|M48 48a48 48 0 1 1 96 0 48 48 0 1 1-96 0M0 192c0-17.7 14.3-32 32-32h64c17.7 0 32 14.3 32 32v256h32c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32h32V224H32c-17.7 0-32-14.3-32-32","info-circle":"0 0 512 512|M256 512a256 256 0 1 0 0-512 256 256 0 1 0 0 512m-32-352a32 32 0 1 1 64 0 32 32 0 1 1-64 0m-8 64h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24h-80c-13.3 0-24-10.7-24-24s10.7-24 24-24h24v-64h-24c-13.3 0-24-10.7-24-24s10.7-24 24-24",list:"0 0 512 512|M40 48c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24V72c0-13.3-10.7-24-24-24zm152 16c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zM16 232v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24v-48c0-13.3-10.7-24-24-24H40c-13.3 0-24 10.7-24 24m24 136c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24v-48c0-13.3-10.7-24-24-24z","mouse-pointer":"0 0 448 512|M77.3 2.5c8.1-4.1 17.9-3.2 25.1 2.3l320 239.9c8.3 6.2 11.6 17 8.4 26.8s-12.4 16.4-22.8 16.4H255.7l88.9 177.7c7.9 15.8 1.5 35-14.3 42.9s-35 1.5-42.9-14.3l-88.9-177.7-91.3 121.8c-6.2 8.3-17 11.6-26.8 8.4S64 434.3 64 424V24c0-9.1 5.1-17.4 13.3-21.5","paper-plane":"0 0 576 512|M536.4-26.3c9.8-3.5 20.6-1 28 6.3s9.8 18.2 6.3 28l-178 496.9c-5 13.9-18.1 23.1-32.8 23.1-14.2 0-27-8.6-32.3-21.7l-64.2-158c-4.5-11-2.5-23.6 5.2-32.6l94.5-112.4c5.1-6.1 4.7-15-.9-20.6s-14.6-6-20.6-.9l-112.4 94.3c-9.1 7.6-21.6 9.6-32.6 5.2L38.1 216.8c-13.1-5.3-21.7-18.1-21.7-32.3 0-14.7 9.2-27.8 23.1-32.8z",pen:"0 0 512 512|M352.9 21.2 308 66.1 445.9 204l44.9-44.9c13.6-13.5 21.2-31.9 21.2-51.1s-7.6-37.6-21.2-51.1l-35.7-35.7C441.6 7.6 423.2 0 404 0s-37.6 7.6-51.1 21.2M274.1 100 58.9 315.1c-10.7 10.7-18.5 24.1-22.6 38.7L.9 481.6c-2.3 8.3 0 17.3 6.2 23.4s15.1 8.5 23.4 6.2l127.8-35.5c14.6-4.1 27.9-11.8 38.7-22.6l215-215.2z",plug:"0 0 448 512|M128-32c17.7 0 32 14.3 32 32v96h128V0c0-17.7 14.3-32 32-32s32 14.3 32 32v96h64c17.7 0 32 14.3 32 32s-14.3 32-32 32v64c0 95.1-69.2 174.1-160 189.3V480c0 17.7-14.3 32-32 32s-32-14.3-32-32v-66.7C101.2 398.1 32 319.1 32 224v-64c-17.7 0-32-14.3-32-32s14.3-32 32-32h64V0c0-17.7 14.3-32 32-32",plus:"0 0 448 512|M256 64c0-17.7-14.3-32-32-32s-32 14.3-32 32v160H32c-17.7 0-32 14.3-32 32s14.3 32 32 32h160v160c0 17.7 14.3 32 32 32s32-14.3 32-32V288h160c17.7 0 32-14.3 32-32s-14.3-32-32-32H256z",redo:"0 0 512 512|M488 192H344c-9.7 0-18.5-5.8-22.2-14.8s-1.7-19.3 5.2-26.2l46.7-46.7C298.4 45.7 189.4 51 120.2 120.2c-75 75-75 196.5 0 271.5s196.5 75 271.5 0q12.3-12.3 21.9-26.1c10.1-14.5 30.1-18 44.6-7.9s18 30.1 7.9 44.6c-8.5 12.2-18.2 23.8-29.1 34.7-100 100-262.1 100-362 0S-25 175 75 75c94.3-94.3 243.7-99.6 344.3-16.2L471 7c6.9-6.9 17.2-8.9 26.2-5.2S512 14.3 512 24v144c0 13.3-10.7 24-24 24",search:"0 0 512 512|M416 208c0 45.9-14.9 88.3-40 122.7l126.6 126.7c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.1-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0s208 93.1 208 208M208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288",table:"0 0 448 512|M384 32c35.3 0 64 28.7 64 64v320c0 35.3-28.7 64-64 64H64l-6.5-.3C25.2 476.4 0 449.1 0 416V96c0-35.3 28.7-64 64-64zM64 320v96h128v-96zm192 0v96h128v-96zM64 256h128v-96H64zm192 0h128v-96H256z",terminal:"0 0 512 512|M9.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L146.7 256zM224 384h256c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32",times:"0 0 384 512|M55.1 73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L147.2 256 9.9 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l137.3-137.4 137.4 137.3c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.8 256l137.3-137.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192.5 210.7z","times-circle":"0 0 512 512|M256 512a256 256 0 1 0 0-512 256 256 0 1 0 0 512m-89-345c9.4-9.4 24.6-9.4 33.9 0l55 55 55-55c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-55 55 55 55c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-55-55-55 55c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l55-55-55-55c-9.4-9.4-9.4-24.6 0-33.9",tool:"0 0 576 512|M70.8-6.7c5.4-5.4 13.8-6.2 20.2-2l118.9 79.2c8.9 5.9 14.2 15.9 14.2 26.6v49.6l90.8 90.8c33.3-15 73.9-8.9 101.2 18.5l126.1 126.1c18.7 18.7 18.7 49.1 0 67.9l-60.1 60.1c-18.7 18.7-49.1 18.7-67.9 0L288.1 384c-27.4-27.4-33.5-67.9-18.5-101.2L178.8 192h-49.6c-10.7 0-20.7-5.3-26.6-14.2L23.4 58.9c-4.2-6.3-3.4-14.8 2-20.2zm145 303.5c-6.3 36.9 2.3 75.9 26.2 107.2l-94.9 95c-28.1 28.1-73.7 28.1-101.8 0s-28.1-73.7 0-101.8l135.4-135.5 35.2 35.1zM384.1 0c20.1 0 39.4 3.7 57.1 10.5 10 3.8 11.8 16.5 4.3 24.1l-56.7 56.7c-3 3-4.7 7.1-4.7 11.3V144c0 8.8 7.2 16 16 16h41.4c4.2 0 8.3-1.7 11.3-4.7l56.7-56.7c7.6-7.5 20.3-5.7 24.1 4.3 6.8 17.7 10.5 37 10.5 57.1 0 43.2-17.2 82.3-45 111.1L450 222c-33.1-33-78.5-45.7-121.1-38.4l-56.8-56.8V97.1l-.2-5c-.8-12.4-4.4-24.3-10.5-34.9C290.8 22.2 334.8 0 384.1-.1z",trash:"0 0 448 512|M136.7 5.9 128 32H32C14.3 32 0 46.3 0 64s14.3 32 32 32h384c17.7 0 32-14.3 32-32s-14.3-32-32-32h-96l-8.7-26.1C306.9-7.2 294.7-16 280.9-16H167.1c-13.8 0-26 8.8-30.4 21.9M416 144H32l21.1 323.1C54.7 492.4 75.7 512 101 512h246c25.3 0 46.3-19.6 47.9-44.9z","trash-alt":"0 0 448 512|M166.2-16c-13.3 0-25.3 8.3-30 20.8L120 48H24C10.7 48 0 58.7 0 72s10.7 24 24 24h400c13.3 0 24-10.7 24-24s-10.7-24-24-24h-96L311.8 4.8c-4.7-12.5-16.6-20.8-30-20.8zM32 144v304c0 35.3 28.7 64 64 64h256c35.3 0 64-28.7 64-64V144h-48v304c0 8.8-7.2 16-16 16H96c-8.8 0-16-7.2-16-16V144zm160 72c0-13.3-10.7-24-24-24s-24 10.7-24 24v176c0 13.3 10.7 24 24 24s24-10.7 24-24zm112 0c0-13.3-10.7-24-24-24s-24 10.7-24 24v176c0 13.3 10.7 24 24 24s24-10.7 24-24z",upload:"0 0 448 512|M256 109.3V320c0 17.7-14.3 32-32 32s-32-14.3-32-32V109.3l-41.4 41.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l96-96c12.5-12.5 32.8-12.5 45.3 0l96 96c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0zM224 400c44.2 0 80-35.8 80-80h80c35.3 0 64 28.7 64 64v32c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64v-32c0-35.3 28.7-64 64-64h80c0 44.2 35.8 80 80 80m144 24a24 24 0 1 0 0-48 24 24 0 1 0 0 48",wifi:"0 0 576 512|M288 96c-90.9 0-173.2 36-233.7 94.6-12.7 12.3-33 12-45.2-.7s-12-33 .7-45.2C81.7 74.9 179.9 32 288 32s206.3 42.9 278.3 112.7c12.7 12.3 13 32.6.7 45.2s-32.6 13-45.2.7C461.2 132 378.9 96 288 96m-48 336a48 48 0 1 1 96 0 48 48 0 1 1-96 0m-72-105.8c-11.7 13.3-31.9 14.5-45.2 2.8s-14.5-31.9-2.8-45.2c41-46.4 101.1-75.8 168-75.8s127 29.4 168 75.8c11.7 13.3 10.4 33.5-2.8 45.2s-33.5 10.4-45.2-2.8c-29.4-33.3-72.2-54.2-120-54.2s-90.6 20.9-120 54.2","window-restore":"0 0 576 512|M512 96H160c0-35.3 28.7-64 64-64h288c35.3 0 64 28.7 64 64v192c0 35.3-28.7 64-64 64h-48v-64h48zM0 224c0-35.3 28.7-64 64-64h288c35.3 0 64 28.7 64 64v192c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64zm64 40c0 13.3 10.7 24 24 24h240c13.3 0 24-10.7 24-24s-10.7-24-24-24H88c-13.3 0-24 10.7-24 24","cookie-bite":"0 0 512 512|M257.5 27.6c-.8-5.4-4.9-9.8-10.3-10.6-22.1-3.1-44.6.9-64.4 11.4l-74 39.5c-19.7 10.5-35.6 27-45.4 47.1l-36.7 75.6c-9.8 20.1-13 42.9-9.1 64.9l14.5 82.8c3.9 22.1 14.6 42.3 30.7 57.9l60.3 58.4c16.1 15.6 36.6 25.6 58.7 28.7l83 11.7c22.1 3.1 44.6-.9 64.4-11.4l74-39.5c19.7-10.5 35.6-27 45.4-47.2l36.7-75.5c9.8-20.1 13-42.9 9.1-64.9-.9-5.3-5.3-9.3-10.6-10.1-51.5-8.2-92.8-47.1-104.5-97.4-1.8-7.6-8-13.4-15.7-14.6-54.6-8.7-97.7-52-106.2-106.8zM208 144a32 32 0 1 1 0 64 32 32 0 1 1 0-64m-64 192a32 32 0 1 1 64 0 32 32 0 1 1-64 0m224-64a32 32 0 1 1 0 64 32 32 0 1 1 0-64"};class e{constructor(t={}){if(e.tC)return console.warn("[thinConsole] thinConsole实例已存在"),e.tC;switch(t=this.sanitizeOptions(t),e.tC=this,this.version="1.3.7",this.options=t,this.options.theme){case"light":this.currentTheme="light";break;case"dark":this.currentTheme="dark";break;default:if(e.themes[this.options.theme])this.currentTheme=this.options.theme;else{let t=()=>window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";this.currentTheme=t(),this.mediaQuery=window.matchMedia("(prefers-color-scheme:dark)"),this.themeChangeHandler=t=>{this.currentTheme=t.matches?"dark":"light",this.overlay&&this.overlay.classList.contains("active")&&(this.overlay.className="overlay active theme-"+this.currentTheme)},this.mediaQuery.addEventListener("change",this.themeChangeHandler)}}this.currentTab="console",this.searchExpanded=!1,this.activeLSFilter="local",this.selectedElement=null,this.selectedShadowHostId=null,this.expandedElements=new WeakSet,this.mutedLogs=!1,this.mutedFilters={},this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!1,mode:"ls",key:"",oldKey:"",value:""},void 0===t.pos?.x&&void 0===t.pos?.y&&(this.options.pos=this.getSavedBtnPos()||{x:30,y:30}),this.pluginEnabled=this.options.plugins,this.disabledPlugins=this.options.disabledPlugins,this.plugins={},this.pluginTabs={},this.pluginViewContainers={},this.logs=[],this.lastLog=null,this.maxLog=this.options.maxLog,this.maxNetwork=this.options.maxNetwork,this.selectedLogId=null,this.customTabCount=0,this.treeNodeRegistry=new Map,this.treeNodeRegId=0,this.expandedTreePaths=new Set,this.timerMap=new Map,this.countMap=new Map,this.networkRequests=[],this._netReqId=0,this.activeNetFilter="all",this.netDisabled=!1,this.netDisabledTypes=new Set,this.netDetailId=null,this.originalXHR=null,this.originalFetch=null,this.closedShadowRoots=new WeakMap,this.interceptShadowRoot(),this.initShadow(),this.createStyles(),this.createButton(),this.captureConsoleLogs(),this.createNotificationElement(),this.createOverlayElement(),this._applyCustomThemeCSS(),this._injectHeaderButtons(),e.themes[this.currentTheme]&&this.applyIcon(e.themes[this.currentTheme].icons),this.setupGlobalEventHandlers(),this.setupSelfProtection(),this.renderContent()}interceptShadowRoot(){if(window.__tcShadowIntercepted)return;window.__tcShadowIntercepted=!0;let t=this,e=Element.prototype.attachShadow;Element.prototype.attachShadow=function(s){let i=e.call(this,s);return t.closedShadowRoots.set(this,{root:i,mode:s.mode||"open"}),i}}initShadow(){this.host&&this.host.remove(),this.host=document.createElement("div"),this.host.id="_thinConsole",this.host.setAttribute("tc-lock",""),this.host.style.cssText="position:absolute;top:0;left:0;width:0;height:0;z-index:2147483647",this.shadowRoot=this.host.attachShadow({mode:"open"}),document.documentElement.appendChild(this.host)}getShadowRoot(t){return t.shadowRoot?{root:t.shadowRoot,mode:"open"}:this.closedShadowRoots.get(t)||null}getSavedBtnPos(){let t=localStorage.getItem("tC-Button-pos");if(!t)return this.saveBtnPos({x:30,y:30}),null;let e=t.match(/^x:(.+?)\,y:(.+)$/);if(!e)return this.saveBtnPos({x:30,y:30}),null;let s=Number(e[1]),i=Number(e[2]);return isNaN(s)||isNaN(i)?(this.saveBtnPos({x:30,y:30}),null):{x:s,y:i}}saveBtnPos({x:t,y:e}){t=isNaN(Number(t))?30:Number(t),e=isNaN(Number(e))?30:Number(e),localStorage.setItem("tC-Button-pos",`x:${t},y:${e}`)}sanitizeOptions(t){let e={text:"thinConsole",color:"#007aff",width:"auto",height:"auto",theme:"auto",plugins:!0,disabledPlugins:[],jsExecute:!0,pos:null,maxLog:1e5,maxNetwork:1e3,pluginOption:{},filters:null};if(!t||"object"!=typeof t)return{...e};let s={...e},i=(t,e=200)=>"string"==typeof t&&t.length<=e&&!/[<>"&]/.test(t)?t:void 0;for(let n of Object.keys(t)){if(!(n in e))continue;let o=t[n];switch(n){case"text":case"color":case"width":case"height":case"theme":{let t=i(o);void 0!==t&&(s[n]=t);break}case"plugins":case"jsExecute":"boolean"==typeof o&&(s[n]=o);break;case"disabledPlugins":Array.isArray(o)&&o.every(t=>"string"==typeof t)&&(s[n]=o.slice(0,100));break;case"pos":o&&"object"==typeof o&&"number"==typeof o.x&&"number"==typeof o.y&&(s.pos={x:o.x,y:o.y});break;case"maxLog":{let e=Number(t[n]);!isNaN(e)&&e>0&&(s[n]=Math.floor(e));break}case"maxNetwork":{let e=Number(t[n]);!isNaN(e)&&e>0&&(s[n]=Math.floor(e));break}case"pluginOption":o&&"object"==typeof o&&(s[n]=o);break;case"filters":Array.isArray(o)&&o.every(t=>t&&"string"==typeof t.id&&"string"==typeof t.name)&&(s[n]=o)}}return s}createButton(){this.btn=document.createElement("button"),this.btn.id="thinConsole-btn",this.btn.className="floating-console-btn",this.btn.textContent=this.options.text.slice(0,11),this.btn.style.background=this.options.color,this.btn.style.width=this.options.width,this.btn.style.height=this.options.height,this.btn.style.bottom=(Number(this.options.pos.y)||30)+"px",this.btn.style.right=(Number(this.options.pos.x)||30)+"px",this.btn.title=this.options.text.slice(0,11),this.shadowRoot.append(this.btn),this.btn.style.transition="none",requestAnimationFrame(()=>requestAnimationFrame(()=>{this.btn.style.transition=""}));let t=!1,e=0,s=0,i=0,n=0,o=0,r=0,l=null,a=null,c=0,d=0,h=()=>{l&&(clearTimeout(l),l=null)},p=()=>{if(!t)return;let e=c-i,s=d-n;this.btn.style.transition="none",this.btn.style.transform=`translate3d(${e}px,${s}px,0)`,a=requestAnimationFrame(p)},u=l=>{if(!t)return;let a=l.touches?l.touches[0]:l,h=a.clientX-e,p=a.clientY-s;c=Math.max(o/2,Math.min(innerWidth-o/2,i+h)),d=Math.max(r/2,Math.min(innerHeight-r/2,n+p)),l.preventDefault()},g=()=>{if(h(),!t)return;t=!1,cancelAnimationFrame(a);let e=this.btn.getBoundingClientRect(),s=Math.round(innerWidth-e.right),i=Math.round(innerHeight-e.bottom);this.btn.style.right=Math.max(0,s)+"px",this.btn.style.bottom=Math.max(0,i)+"px",this.saveBtnPos({x:Math.max(0,s),y:Math.max(0,i)}),this.btn.style.transition="all 0.3s ease",this.btn.style.transform="",this.btn.dataset.right=Math.max(0,s),this.btn.dataset.bottom=Math.max(0,i),this.btn.removeEventListener("touchmove",u,{passive:!1}),this.btn.removeEventListener("touchend",g),this.btn.removeEventListener("mousemove",u),this.btn.removeEventListener("mouseup",g)},f=a=>{let h=a.touches?a.touches[0]:a;e=h.clientX,s=h.clientY;let f=this.btn.getBoundingClientRect();o=f.width,r=f.height,i=f.left+o/2,n=f.top+r/2,l=setTimeout(()=>{t=!0,c=i,d=n,p(),this.btn.addEventListener("touchmove",u,{passive:!1}),this.btn.addEventListener("touchend",g),this.btn.addEventListener("mousemove",u),this.btn.addEventListener("mouseup",g)},500)};this.btn.addEventListener("touchstart",f,{passive:!1}),this.btn.addEventListener("mousedown",f),this.btn.addEventListener("touchend",h),this.btn.addEventListener("mouseup",h),this.btn.addEventListener("mouseleave",h),this.btn.addEventListener("click",()=>{this.triggerGlobalHook("beforeOpen"),this.overlay.className="overlay active theme-"+this.currentTheme,this.renderContent(),this.triggerGlobalHook("afterOpen")})}createOverlayElement(){this.overlay=document.createElement("div"),this.overlay.id="consoleOverlay",this.overlay.className="overlay no-anim";let t=`<div class="splitter" id="splitter"></div><div class="console-container"><div class="console-header" id="consoleHeader"><div class="console-title" id="consoleTitle">${this.icon("terminal")}${this.options.text.slice(0,11)}</div><div class="header-actions"><button class="header-icon-btn el-header-btn" id="elementPickBtn" title="选择元素" style="display:none">${this.icon("mouse-pointer")}</button><button class="header-icon-btn el-header-btn" id="elCopyBtn" title="复制元素" style="display:none">${this.icon("copy")}</button><button class="header-icon-btn el-header-btn el-delete-btn" id="elDeleteBtn" title="删除元素" style="display:none">${this.icon("trash")}</button><button class="header-icon-btn" id="logCopyBtn" title="复制选中日志" style="display:none">${this.icon("copy")}</button><button class="header-icon-btn ls-add-btn" id="lsAddBtn" title="新建" style="display:none">${this.icon("plus")}</button><button class="header-icon-btn" id="netNewBtn" title="新建请求" style="display:none">${this.icon("plus")}</button><button class="header-icon-btn" id="searchToggleBtn" title="搜索">${this.icon("search")}</button><button class="clear-all-btn" title="清除" id="clearLogsBtn">${this.icon("trash")}</button><button class="close-btn" title="关闭" id="closeConsoleBtn">${this.icon("times")}</button></div></div><div class="search-bar" id="searchBar" style="display:none"><div class="search-input-wrap">${this.icon("search","search-bar-icon")}<input type="text" id="searchInput" placeholder="搜索..."></div></div><div class="tabs" id="tabsContainer"></div><div class="console-content" id="contentArea"><div class="controls" id="consoleControls"><div class="filters" id="filtersContainer"></div><div class="filters ls-filters" id="lsFiltersContainer" style="display:none"><button class="filter-btn active" title="本地存储" data-ls-type="local" data-orig="本地存储" data-icon="database">${this.icon("database")}本地存储</button><button class="filter-btn" title="会话存储" data-ls-type="session" data-orig="会话存储" data-icon="window-restore">${this.icon("window-restore")}会话存储</button><button class="filter-btn" title="Cookies" data-ls-type="cookie" data-orig="Cookies" data-icon="cookie-bite">${this.icon("cookie-bite")}Cookies</button></div><button class="mute-btn" id="muteBtn" title="屏蔽后续日志">${this.icon("ban")}</button></div><div class="console-output" id="consoleOutput"></div><div class="localstorage-view" id="localstorageView" style="display:none"><div class="ls-items" id="lsItems"></div></div><div class="elements-view" id="elementsView" style="display:none"><div class="elements-tree" id="elementsTree"></div></div><div class="network-view" id="networkView" style="display:none"><div class="network-controls"><div class="network-filters" id="netFilters"></div><button class="net-disable-btn" id="netDisableBtn" title="禁用">${this.icon("ban")}</button></div><div class="network-items" id="networkItems"></div><div class="net-detail-overlay" id="netDetailOverlay"><div class="net-detail-header"><button class="net-back-btn" id="netBackBtn" title="返回">${this.icon("arrow-left")}</button><div class="net-detail-header-actions"><button class="net-resend-icon-btn" id="netResendIconBtn" title="重发">${this.icon("redo")}</button></div></div><div class="net-detail-body" id="netDetailBody"></div></div><div class="net-new-overlay" id="netNewOverlay"><div class="net-new-header"><button class="net-back-btn" id="netNewBackBtn">${this.icon("arrow-left")}</button><div class="net-new-title">新建请求</div></div><div class="net-new-body"><div class="net-form-group"><label class="net-form-label">网址</label><input type="text" class="net-form-input" id="netNewUrl" placeholder="https://..." spellcheck="false"></div><div class="net-form-group"><label class="net-form-label">类型</label><select class="net-form-select" id="netNewMethod"><option value="GET">GET</option><option value="POST">POST</option><option value="PUT">PUT</option><option value="PATCH">PATCH</option><option value="DELETE">DELETE</option><option value="HEAD">HEAD</option><option value="OPTIONS">OPTIONS</option></select></div><div class="net-form-group"><label class="net-form-label">请求内容 (可选)</label><textarea class="net-form-textarea" id="netNewBody" placeholder='{"key":"value"}' spellcheck="false"></textarea></div><div class="net-form-group"><label class="net-form-label">请求头 (可选, 每行一个)</label><textarea class="net-form-textarea" id="netNewHeaders" placeholder="Content-Type: application/json" spellcheck="false"></textarea></div><button class="net-send-btn" id="netSendBtn">${this.icon("paper-plane")} 发送请求</button></div></div></div><div class="ls-editor-overlay" id="lsEditorOverlay" style="display:none"><div class="ls-editor-header"><div class="ls-editor-header-row"><input type="text" class="ls-editor-key-input" id="lsEditorKeyInput" placeholder="键名..." spellcheck="false"><span class="ls-editor-title" id="lsEditorTitle"></span></div></div><div class="ls-editor-body"><textarea id="lsEditorInput" placeholder="输入值..." spellcheck="false"></textarea></div><div class="ls-editor-footer"><button class="ls-editor-btn cancel" id="lsEditorCancel">取消</button><button class="ls-editor-btn save" id="lsEditorSave">保存</button></div></div></div></div>`;this.overlay.innerHTML=t,this.shadowRoot.appendChild(this.overlay),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.overlay.classList.remove("no-anim")})});let $=this.overlay.querySelector.bind(this.overlay);this.tabButtonsContainer=$("#tabsContainer"),this.createBuiltinTabs(),this.closeConsoleBtn=$("#closeConsoleBtn"),this.consoleOutput=$("#consoleOutput"),this.title=$("#consoleTitle"),this.localstorageView=$("#localstorageView"),this.lsItems=$("#lsItems"),this.contentArea=$("#contentArea"),this.consoleContainer=$(".console-container"),this.renderFilters(),this.filterButtons=this.overlay.querySelectorAll("#filtersContainer .filter-btn"),this.searchInput=$("#searchInput"),this.clearLogsBtn=$("#clearLogsBtn"),this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.consoleControls=$("#consoleControls"),this.searchToggleBtn=$("#searchToggleBtn"),this.searchBar=$("#searchBar"),this.consoleHeader=$("#consoleHeader"),this.lsEditorOverlay=$("#lsEditorOverlay"),this.lsEditorTitle=$("#lsEditorTitle"),this.lsEditorKeyInput=$("#lsEditorKeyInput"),this.lsEditorInput=$("#lsEditorInput"),this.lsEditorCancel=$("#lsEditorCancel"),this.lsEditorSave=$("#lsEditorSave"),this.muteBtn=$("#muteBtn"),this.lsFiltersContainer=$("#lsFiltersContainer"),this.lsAddBtn=$("#lsAddBtn"),this.logCopyBtn=$("#logCopyBtn"),this.elementsView=$("#elementsView"),this.elementsTree=$("#elementsTree"),this.networkView=$("#networkView"),this.networkItems=$("#networkItems"),this.netFiltersEl=$("#netFilters"),this.netDisableBtn=$("#netDisableBtn"),this.netDetailOverlay=$("#netDetailOverlay"),this.netDetailBody=$("#netDetailBody"),this.netNewOverlay=$("#netNewOverlay"),this.netNewUrl=$("#netNewUrl"),this.netNewMethod=$("#netNewMethod"),this.netNewBody=$("#netNewBody"),this.netNewHeaders=$("#netNewHeaders"),this.netSendBtn=$("#netSendBtn"),this.netBackBtn=$("#netBackBtn"),this.netNewBackBtn=$("#netNewBackBtn"),this.netNewBtn=$("#netNewBtn"),this.elementPickBtn=$("#elementPickBtn"),this.splitter=$("#splitter"),this.splitter&&this.setupSplitter(),this.elementPickBtn.addEventListener("click",()=>this.startElementPicker()),this.elCopyBtn=$("#elCopyBtn"),this.elCopyBtn.addEventListener("click",()=>{this.selectedElement?this.copyElementHTML(this.selectedElement):this.showNotification("请先选择一个元素","warning")}),this.elDeleteBtn=$("#elDeleteBtn"),this.elDeleteBtn.addEventListener("click",()=>{this.selectedElement?this.deleteElement(this.selectedElement):this.showNotification("请先选择一个元素","warning")}),this.netDisableBtn&&this.netDisableBtn.addEventListener("click",()=>this.toggleNetDisable()),this.netBackBtn&&this.netBackBtn.addEventListener("click",()=>{this.netDetailOverlay.style.display="none",this.netDetailId=null}),this.netNewBackBtn&&this.netNewBackBtn.addEventListener("click",()=>{this.netNewVisible=!1,this.netNewOverlay.style.display="none"}),this.netNewBtn&&this.netNewBtn.addEventListener("click",()=>{if(this.editorState.visible){let t=this.editorState.mode;if("code"===t)return void this.showNotification("正在运行代码,无法发送请求","warning");if("ls"===t)return void this.showNotification("正在保存键值,无法发送请求","warning")}this.netNewVisible=!0,this.netNewOverlay.style.display="flex"}),this.netSendBtn&&this.netSendBtn.addEventListener("click",()=>this.sendNewRequest()),this.networkItems&&this.networkItems.addEventListener("click",t=>{let e=t.target.closest(".net-item");if(!e)return;let s=parseInt(e.dataset.reqId);if(t.target.closest("[data-action=copy]")){t.stopPropagation(),t.preventDefault();let e=this.networkRequests.find(t=>t.id===s);if(e){let t={method:e.method,url:e.url,headers:e.reqHeaders,body:e.reqBody};navigator.clipboard.writeText(JSON.stringify(t,null,2)).then(()=>this.showNotification("已复制请求JSON")).catch(()=>{})}return}return t.target.closest("[data-action=detail]")?(t.stopPropagation(),t.preventDefault(),void this.showNetDetail(s)):void 0}),this.captureNetworkRequests(),this.closeConsoleBtn.addEventListener("click",()=>{this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose")}),[this.consoleOutput,this.lsItems,this.networkItems].forEach(t=>this.vsInit(t)),this.lsItems.addEventListener("click",t=>{let e=t.target.closest(".ls-action-btn");if(!e)return;let s=e.dataset.action,i=e.dataset.key;switch(s){case"edit":this.openLSEditor(i);break;case"copy":this.copyLog(i,"",!0);break;case"remove":this.removeLSItem(i)}}),this.title.title="运行代码功能已被禁用",this.title.style.cursor="not-allowed",this.options.jsExecute&&(this.title.title="点击标题以输入代码执行",this.title.style.cursor="pointer",this.title.addEventListener("click",()=>this.onTitleClick())),this.overlay.addEventListener("click",t=>{let s=t.target.closest(".tree-load-more");s&&this.loadMoreTreeChildren(s);let i=t.target.closest(".elements-tree .tree-label");if(i){let t=i.closest(".tree-node[data-el-id]"),e=t?parseInt(t.dataset.elId):null,s=null!==e&&this.elRefMap?this.elRefMap.get(e):null;s&&(this.selectedElement=s,this.selectedShadowHostId=t.dataset.shadowHost?parseInt(t.dataset.shadowHost):null,this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),this.elementsTree.querySelectorAll(".el-highlight").forEach(t=>t.classList.remove("el-highlight")),t.classList.add("el-selected"),t.classList.add("el-highlight"),setTimeout(()=>t.classList.remove("el-highlight"),3e3),this.updateControlsVisibility())}else"elements"!==this.currentTab||t.target.closest(".tree-label")||t.target.closest(".tree-toggle")||t.target.closest(".el-header-btn")||t.target.closest(".close-btn")||t.target.closest(".header-icon-btn")||t.target.closest(".console-header")||t.target.closest(".tabs")||t.target.closest(".controls")||t.target.closest(".search-bar")||(this.selectedElement=null,this.selectedShadowHostId=null,this.elementsTree&&(this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),this.elementsTree.querySelectorAll(".el-highlight").forEach(t=>t.classList.remove("el-highlight"))),this.updateControlsVisibility());let n=t.target.closest(".tree-toggle")||("elements"===this.currentTab||t.target.closest(".tree-close")?null:t.target.closest(".tree-node"));if(n){let t=n.closest(".tree-node");if(t){let e=t.dataset.elId,s=e&&this.elRefMap?this.elRefMap.get(parseInt(e)):null;if(t.classList.contains("collapsed")){t.classList.remove("collapsed"),t.classList.add("expanded");let e=t.dataset.treePath;e&&this.expandedTreePaths.add(e),s&&this.expandedElements.add(s);let i=t.querySelector(":scope > .tree-children");if(i&&i.dataset.lazyId){let t=parseInt(i.dataset.lazyId),e=this.treeNodeRegistry.get(t);if(e){let s="";if("html"===e.type)s=this.renderDomChildrenLazy(e.children,(t,s,i)=>this.renderHTMLTree(t,"",e.path+"."+s,i),e.depth||0,"html",{path:e.path}),e.shadow&&(s+=this.buildShadowLazy(e.shadow,"html",e.path,e.depth||0));else if("html-shadow"===e.type)s=this.renderDomChildrenLazy(e.children,(t,s,i)=>this.renderHTMLTree(t,"",e.path+".shadow."+s,i),e.depth||0,"html-shadow",{});else if("element"===e.type)s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element",{}),e.shadow&&(s+=this.buildShadowLazy(e.shadow,"element",null,e.depth||0,e.elId));else if("element-shadow"===e.type)s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element-shadow",{});else if(e.isJsonValue)s=this.renderJSONValueChildren(e.children);else{let t=new WeakSet;e.chain.forEach(e=>t.add(e)),t.add(e.obj);let i=e.children;if(i.length>200){let n=this.treeNodeRegId++;this.treeNodeRegistry.set(n,{children:i,chain:e.chain.concat([e.obj]),noProto:e.noProto}),s=this.renderTreeChildrenBatch(i,t,0,200,e.chain.concat([e.obj]),e.path||"",1,e.noProto)+'<div class="tree-load-more" data-reg-id="'+n+'" data-offset="200">'+this.icon("angle-down")+" 展开更多 (剩余 "+(i.length-200)+" 项)</div>"}else s=this.renderTreeChildrenBatch(i,t,0,i.length,e.chain.concat([e.obj]),e.path||"",1,e.noProto)}i.innerHTML=s,delete i.dataset.lazyId,this.treeNodeRegistry.delete(t)}}}else{t.classList.remove("expanded"),t.classList.add("collapsed");let e=t.dataset.treePath;e&&this.expandedTreePaths.delete(e),s&&this.expandedElements.delete(s)}let i=n.closest(".console-output, .ls-items");i&&this.vsRender(i)}}t.target===this.overlay&&(this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose"))}),this.filterButtons.forEach(t=>{t.addEventListener("click",()=>{this.filterButtons.forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.activeFilter=t.dataset.type,this.updateFilterCounts(),this.renderContent(),this.scrollFilterIntoView(this.filtersContainerEl,t)})}),this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>{t.addEventListener("click",()=>{this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.activeLSFilter=t.dataset.lsType,this.renderContent(),this.scrollFilterIntoView(this.lsFiltersContainer,t)})}),this.lsAddBtn&&this.lsAddBtn.addEventListener("click",()=>this.onAddLSClick()),this.logCopyBtn&&this.logCopyBtn.addEventListener("click",()=>{null!==this.selectedLogId?this.copyLog(this.selectedLogId,!1):this.showNotification("请先选中一条日志","warning")}),this.consoleOutput&&this.consoleOutput.addEventListener("click",t=>{let e=t.target.closest(".log-item");if(!e)return this.selectedLogId=null,this.consoleOutput.querySelectorAll(".log-item.selected").forEach(t=>t.classList.remove("selected")),void(this.logCopyBtn&&(this.logCopyBtn.style.display="none"));let s=parseInt(e.id.replace("log-item-",""));this.selectedLogId=s,this.consoleOutput.querySelectorAll(".log-item.selected").forEach(t=>t.classList.remove("selected")),e.classList.add("selected"),this.logCopyBtn&&(this.logCopyBtn.style.display="flex")}),this.searchInput.addEventListener("input",(t=>e=>{clearTimeout(t),t=setTimeout(()=>{if(this.searchQuery=e.target.value,"network"===this.currentTab)return this.renderNetworkList().trim(),this.renderContent()},300)})(0)),this.clearLogsBtn.addEventListener("click",()=>this.clearAllLogs()),this.searchToggleBtn.addEventListener("click",()=>this.toggleSearch()),this.lsEditorCancel.addEventListener("click",()=>this.closeLSEditor()),this.lsEditorSave.addEventListener("click",()=>this.onEditorSave()),this.muteBtn.addEventListener("click",()=>this.toggleMute()),this.lsEditorInput.addEventListener("input",()=>{this.editorState.value=this.lsEditorInput.value}),this.lsEditorKeyInput&&this.lsEditorKeyInput.addEventListener("input",()=>{this.editorState.key=this.lsEditorKeyInput.value.trim()}),this.setupFilterShadow(this.filtersContainerEl),this.setupFilterShadow(this.lsFiltersContainer),this.setupFilterShadow(this.netFiltersEl),this.setupGestures(),this.tabButtons.forEach(t=>{t.addEventListener("click",()=>{this.tabButtons.forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.currentTab=t.dataset.tab,this.renderContent()})})}renderFilters(){let t=this.overlay.querySelector("#filtersContainer");if(!t)return;this.filtersContainerEl=t;let e=this.options.filters;e&&e.length||(e=[{id:"all",name:"全部",icon:"list"},{id:"log",name:"日志",icon:"info"},{id:"info",name:"信息",icon:"info-circle"},{id:"warn",name:"警告",icon:"exclamation-triangle"},{id:"error",name:"错误",icon:"times-circle"}]),t.innerHTML=e.map((t,e)=>`<button class="filter-btn${0===e?" active":""}" title="${this.escapeHtml(t.name)}" data-type="${this.escapeHtml(t.id)}" data-icon="${this.escapeHtml(t.icon||"")}">${t.icon?this.icon(t.icon):""}${this.escapeHtml(t.name)}</button>`).join(""),t.querySelectorAll(".filter-btn").forEach(e=>{e.addEventListener("click",()=>{t.querySelectorAll(".filter-btn").forEach(t=>t.classList.remove("active")),e.classList.add("active"),this.activeFilter=e.dataset.type,this.updateFilterCounts(),this.renderContent()})})}createBuiltinTabs(){[{id:"console",name:"控制台",icon:"terminal"},{id:"network",name:"网络",icon:"wifi"},{id:"localstorage",name:"存储",icon:"database"},{id:"elements",name:"元素",icon:"code"}].forEach(t=>{let e=document.createElement("button");e.className="tab-btn",e.dataset.tab=t.id,e.title=t.name,e.innerHTML=this.icon(t.icon)+t.name,t.id===this.currentTab&&e.classList.add("active"),e.addEventListener("click",()=>{this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.tabButtons.forEach(t=>t.classList.remove("active")),e.classList.add("active"),this.currentTab=t.id,this.renderContent()}),this.tabButtonsContainer.appendChild(e)})}createPluginTab(t){let e=document.createElement("button");e.className="tab-btn",e.dataset.tab=t.id?t.id:"newTab",t.title=t.name?t.name:"新的插件",e.innerHTML=this.icon(t.icon||"plug")+(t.name||"新的插件"),this.tabButtonsContainer.appendChild(e),e.addEventListener("click",()=>{this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.tabButtons.forEach(t=>t.classList.remove("active")),e.classList.add("active"),this.currentTab=t.id,this.renderContent()});let s=document.createElement("div");s.id=`${t.id}View`,s.innerHTML="无插件视图",s.className="plug-view",s.style.display="none",this.contentArea.appendChild(s),this.pluginViewContainers[t.id]=s}createNotificationElement(){this.notification=document.createElement("div"),this.notification.id="notification",this.notification.className="notification",this.notification.style.display="none",this.shadowRoot.appendChild(this.notification)}createStyles(){let t=document.createElement("style");t.innerHTML=":host{all:initial}*{margin:0;padding:0;box-sizing:border-box}.floating-console-btn{position:fixed;z-index:99997;touch-action:none;will-change:transform;padding:15px 25px;backdrop-filter:blur(5px);border-radius:5px;border:none;background:#007aff;color:#fff;font-size:1rem;cursor:move;display:flex;align-items:center;gap:10px;font-weight:500;box-shadow:0 8px 20px rgba(0,0,0,.4);transition:all .3s ease;user-select:none}.floating-console-btn:active{transform:scale(.98)}.floating-console-btn .ico{font-size:1.2rem}.overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.85);display:flex;align-items:center;justify-content:center;z-index:99998;opacity:0;visibility:hidden;transition:all .4s ease;backdrop-filter:blur(5px)}.overlay.active{opacity:1;visibility:visible}.theme-dark{--selected-bg:rgba(74,74,230,.15);--console-bg:#1e1e1e;--header-bg:#252526;--text-color:#d4d4d4;--controls-bg:#2d2d2d;--border-color:rgba(255,255,255,0.05);--log-bg:#191919;--log-border-light:3px solid;--filter-active:#4a4ae6;--search-bg:#3e3e42;--json-bg:rgba(40,40,40,0.7);--json-key:#6aaeff;--json-tag:#5dade2;--json-string:#98c379;--json-number:#d19a66;--json-boolean:#56b6c2;--json-null:#be5046;--json-cmt:#707070;--action-bg:rgba(106,174,255,0.3);--action-hover:rgba(106,174,255,0.5);--log-icon-info:#4a4ae6;--log-bg-warn:rgba(255,193,7,0.1);--log-icon-warn:#d9a40d;--log-icon-error:#ff3b30;--clear-btn-color:#ff6b6b;--clear-btn-hover:#ff5252;--tab-bg:#333;--tab-active:#444;--tab-color:#ddd}.theme-light{--selected-bg:rgba(30,107,184,.08);--console-bg:#ffffff;--header-bg:#f0f0f0;--text-color:#333;--controls-bg:#e0e0e0;--border-color:rgba(0,0,0,0.1);--log-bg:#f3f3f3;--log-border-light:3px solid;--filter-active:#4a4ae6;--search-bg:#f0f0f0;--json-bg:rgba(240,240,240,0.9);--json-key:#1e6bb8;--json-tag:#2980b9;--json-string:#22863a;--json-number:#d73a49;--json-boolean:#005cc5;--json-null:#6f42c1;--json-cmt:#707070;--action-bg:rgba(30,107,184,0.1);--action-hover:rgba(30,107,184,0.2);--log-bg-warn:rgba(255,243,205,0.75);--log-icon-info:#1e6bb8;--log-icon-warn:#e36209;--log-icon-error:#d73a49;--clear-btn-color:#ff5252;--clear-btn-hover:#ff3b30;--tab-bg:#e5e5e5;--tab-active:#ddd;--tab-color:#333}.console-container *{outline:0;-webkit-tap-highlight-color:transparent}.console-container{background:var(--console-bg);display:flex;flex-direction:column;box-shadow:0 15px 35px rgba(0,0,0,.3);position:fixed;z-index:99999;left:0;bottom:0;width:100%;height:90vh;transform:translateY(100%);transition:transform .4s cubic-bezier(.25,.8,.25,1)}.overlay.active .console-container{transform:translateY(0)}.overlay.no-anim .console-container{transition:none!important}.network-view{display:none;flex:1;overflow:hidden;flex-direction:column;position:relative}.net-disable-btn{display:inline-flex;align-items:center;justify-content:center;border:none;background:0 0;color:var(--text-color);cursor:pointer;font-size:14px;padding:5px 10px;border-radius:5px;white-space:nowrap;transition:all .2s;opacity:.55;flex-shrink:0;margin-left:auto}.net-disable-btn:hover{opacity:1}.net-disable-btn.disabled{opacity:1;color:var(--text-color);filter:none}.network-items{flex:1;overflow-y:auto;padding:8px 12px}.net-item{padding:12px 14px;margin-bottom:8px;background:var(--log-bg);border-left:3px solid var(--json-boolean);border-radius:6px;cursor:default;transition:background .2s}.net-item:hover{background:var(--selected-bg)}.net-item.net-failed{border-left-color:#ff5252}.net-item.net-success{border-left-color:#98c379}.net-row1{display:flex;align-items:center;gap:8px;margin-bottom:4px}.net-row2{display:flex;align-items:center;gap:8px;margin-bottom:6px}.net-row3{display:flex;gap:8px;align-items:center}.net-copy-btn,.net-detail-btn{display:inline-flex;align-items:center;gap:4px;padding:4px 10px;border:none;border-radius:4px;font-size:11px;cursor:pointer;transition:all .2s}.net-copy-btn{background:var(--action-bg);color:var(--json-key)}.net-copy-btn:hover,.net-detail-btn:hover{background:var(--action-hover)}.net-detail-btn{background:var(--action-bg);color:var(--json-key)}.net-method{font-size:10px;font-weight:700;padding:2px 6px;border-radius:3px;text-transform:uppercase}.net-method-GET{background:rgba(106,174,255,.2);color:var(--json-key)}.net-method-POST{background:rgba(152,195,121,.2);color:var(--json-string)}.net-method-PUT{background:rgba(255,193,7,.2);color:#ffc107}.net-method-DELETE{background:rgba(255,82,82,.2);color:#ff5252}.net-method-PATCH{background:rgba(255,152,0,.2);color:#ff9800}.net-method-HEAD{background:rgba(190,80,70,.2);color:var(--json-null)}.net-method-OPTIONS{background:rgba(112,112,112,.2);color:var(--json-cmt)}.net-url{flex:1;font-size:12px;color:var(--text-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:100px}.net-status{font-size:11px;font-weight:700;padding:2px 6px;border-radius:3px}.net-status-2xx{background:rgba(152,195,121,.2);color:#98c379}.net-status-3xx{background:rgba(106,174,255,.2);color:var(--json-key)}.net-status-4xx{background:rgba(255,152,0,.2);color:#ff9800}.net-status-5xx{background:rgba(255,82,82,.2);color:#ff5252}.net-status-pending{background:rgba(112,112,112,.2);color:var(--json-cmt)}.net-time{font-size:11px;color:var(--json-cmt);white-space:nowrap}.net-detail-overlay,.net-detail-header,.net-back-btn{background:0 0;border:none;color:var(--text-color);cursor:pointer;font-size:16px;padding:4px 8px;border-radius:4px}.net-back-btn:hover{background:var(--action-bg)}.net-detail-overlay,.net-new-overlay{position:absolute;top:0;left:0;right:0;bottom:0;background:var(--console-bg);z-index:100;display:none;flex-direction:column}.net-detail-header,.net-new-header{display:flex;align-items:center;gap:8px;padding:3px 12px;background:var(--header-bg);border-bottom:1px solid var(--border-color)}.net-detail-body{flex:1;overflow-y:auto;padding:12px}.net-detail-section{margin-bottom:16px}.net-detail-label{font-size:11px;color:var(--json-cmt);text-transform:uppercase;margin-bottom:4px}.net-detail-value{font-size:13px;color:var(--text-color);word-break:break-all;background:var(--log-bg);padding:8px 10px;border-radius:4px}.net-detail-value textarea{width:100%;min-height:80px;background:var(--log-bg);border:1px solid var(--border-color);color:var(--text-color);border-radius:4px;padding:8px;font-size:12px;font-family:monospace;resize:vertical}.net-new-title{flex:1;font-size:14px;color:var(--text-color)}.net-new-body{flex:1;overflow-y:auto;padding:16px}.net-form-group{margin-bottom:14px}.net-form-label{font-size:12px;color:var(--json-cmt);margin-bottom:4px;display:block}.net-form-input,.net-form-select,.net-form-textarea{width:100%;background:var(--log-bg);border:1px solid var(--border-color);color:var(--text-color);border-radius:4px;padding:8px 10px;font-size:13px;font-family:monospace;outline:0;transition:border-color .2s}.net-form-input:focus,.net-form-select:focus,.net-form-textarea:focus{border-color:var(--filter-active)}.net-form-textarea{min-height:100px;resize:none}.net-form-select{cursor:pointer}.net-send-btn{padding:8px 20px;border:none;background:var(--filter-active);color:#fff;cursor:pointer;border-radius:4px;font-size:13px;transition:all .2s;margin-left:auto;display:block}.net-send-btn:hover{opacity:.85}.nolog{text-align:center;font-size:18px;color:var(--json-cmt);padding:40px 0;display:flex;align-items:center;justify-content:center;gap:5px}.nolog>.ico{font-size:1em;flex-shrink:0}.net-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--json-cmt);font-size:18px;gap:5px}.net-detail-section-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:4px}.net-detail-copy-section{background:0 0;border:none;color:var(--json-cmt);cursor:pointer;font-size:13px;padding:2px 6px;border-radius:3px;transition:all .2s}.net-detail-copy-section:hover{background:var(--action-bg);color:var(--json-key)}.net-detail-empty{color:var(--json-cmt);opacity:.5;font-style:italic}.net-detail-value.net-detail-code{font-family:monospace;white-space:pre-wrap;word-break:break-all;overflow-x:auto;max-height:400px}.net-detail-header-actions{display:flex;align-items:center;gap:4px;margin-left:auto}.net-resend-icon-btn{background:0 0;border:none;color:var(--text-color);cursor:pointer;font-size:16px;padding:4px 8px;border-radius:4px;transition:all .2s}.net-resend-icon-btn:hover{background:var(--action-bg);color:var(--json-key)}.filters,.network-filters,.plug-view .filters{display:flex;flex-wrap:nowrap;gap:2px;margin-left:0;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin;position:relative;padding-bottom:2px;min-width:0;flex:0 1 auto;-webkit-overflow-scrolling:touch}.network-filters{flex:1 1 auto}.filter-btn,.net-filter-btn{position:relative;padding:5px 10px;border:none;background:0 0;color:var(--text-color);cursor:pointer;font-size:12px;display:flex;width:auto;white-space:nowrap;border-radius:4px;opacity:.55;transition:opacity .2s,background .2s;flex-shrink:0}.filter-btn>.ico,.net-filter-btn>.ico{margin-right:5px;margin-top:2px}.filter-btn:hover,.net-filter-btn:hover{opacity:1;background:rgba(127,127,127,.14)}.filter-btn.active,.net-filter-btn.active{opacity:1;font-weight:600;background:transparent}.filter-btn.active::after,.net-filter-btn.active::after{content:'';position:absolute;width:80%;left:10%;right:auto;top:auto;height:2px;bottom:0;border-radius:3px;background:var(--filter-active)}@media(min-width:769px){.overlay{flex-direction:row;align-items:stretch;justify-content:flex-end;background:transparent;backdrop-filter:none;opacity:1}.console-container{position:relative;left:auto;bottom:auto;width:50%;height:100%;transform:translateX(100%);flex-shrink:0}.overlay.active .console-container{transform:translateX(0)}.overlay::before{content:'';flex:1;cursor:pointer}.splitter{display:block;width:4px;background:var(--border-color);cursor:col-resize;flex-shrink:0;z-index:100001;position:relative;transform:translateX(100%);transition:transform .4s cubic-bezier(.25,.8,.25,1)}.overlay.active .splitter{transform:translateX(0)}.overlay.no-anim .splitter{transition:none!important}.splitter:hover,.splitter.dragging{background:var(--filter-active)}.console-header{padding:6px 15px}.console-title{font-size:16px}.header-icon-btn,.close-btn,.clear-all-btn{width:34px;height:34px;font-size:17px}.tabs{padding:2px 10px 0}.tab-btn{padding:8px 14px;font-size:14px}.controls{padding:4px 12px;flex-wrap:nowrap}.network-controls{padding:4px 12px;flex-wrap:nowrap}}@media(max-width:768px){.splitter{display:none}}@media(max-width:768px){.overlay{flex-direction:column;align-items:center;justify-content:center}.console-container{transform:translateY(100%)!important}.overlay.active .console-container{transform:translateY(0)!important}}.console-header{display:flex;justify-content:space-between;align-items:center;padding:8px 25px;background:var(--header-bg);border-bottom:1px solid var(--border-color);position:relative}.console-title{color:var(--text-color);gap:10px;display:flex;align-items:center;font-size:18px}.header-actions{display:flex;align-items:center;gap:2px}.header-icon-btn{background:0 0;border:none;color:var(--text-color);font-size:18px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.header-icon-btn:hover{background:rgba(106,174,255,0.2);color:var(--json-key)}.close-btn{background:0 0;border:none;color:var(--text-color);font-size:20px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.close-btn:hover{background:rgba(255,100,100,.2);color:#ff6464;transform:scale(1.1)}.clear-all-btn{background:0 0;border:none;color:var(--text-color);font-size:20px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.clear-all-btn:hover,.clear-all-btn:active{background:rgba(255,100,100,.2);color:var(--clear-btn-hover)}.tabs{display:block;white-space:nowrap;overflow-x:auto;background:var(--tab-bg);padding:5px 10px 0;border-bottom:1px solid var(--border-color)}.tab-btn{padding:12px 20px;background:0 0;border-radius:5px 5px 0 0;border:none;color:var(--tab-color);cursor:pointer;position:relative;display:inline-flex;align-items:center;gap:8px}.tab-btn.active{color:var(--text-color);font-weight:600}.tab-btn.active::after{content:'';position:absolute;bottom:0;left:0;width:100%;height:2px;border-radius:3px;background:var(--filter-active)}.tab-btn:hover:not(.active){background:rgba(255,255,255,.05)}.controls{display:flex;padding:6px 15px;background:var(--controls-bg);gap:10px;flex-wrap:nowrap;border-bottom:1px solid var(--border-color);align-items:center;overflow-x:auto}.network-controls{display:flex;align-items:center;gap:8px;padding:6px 15px;background:var(--controls-bg);border-bottom:1px solid var(--border-color);flex-wrap:nowrap}.search-bar{display:flex;align-items:center;gap:8px;padding:10px 20px;background:var(--controls-bg);border-bottom:1px solid var(--border-color)}.search-input-wrap{display:flex;align-items:center;flex:1;position:relative}.search-bar-icon{position:absolute;left:10px;color:var(--text-color);opacity:.6;font-size:14px;pointer-events:none}.search-bar input{flex:1;padding:8px 10px 8px 35px;border-radius:5px;border:none;background:var(--search-bg);color:var(--text-color);transition:all .3s ease;font-size:14px;border:1px solid var(--border-color)}.search-bar input:focus{outline:0;border-color:#4a4ae6}.search-bar-close{background:0 0;border:none;color:var(--text-color);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:5px;opacity:.6;transition:all .3s}.search-bar-close:hover{opacity:1;background:rgba(255,255,255,.1)}.console-content{flex:1;overflow:auto;display:flex;flex-direction:column;position:relative}.console-output{flex:1;overflow-y:auto;padding:20px;font-family:monospace;font-size:.95rem}.localstorage-view{flex:1;padding:20px;font-family:monospace;font-size:.95rem;position:relative;overflow:hidden}.ls-items{position:absolute;inset:0;overflow-y:auto;padding:20px}.log-item{padding:8px 12px;margin-bottom:6px;display:flex;flex-direction:column;border-left:3px solid #4a4ae6;background:var(--log-bg);border-radius:5px;cursor:pointer;transition:background .2s;color:var(--text-color);user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}.log-item .log-icon .ico{color:inherit}.log-item.selected{border-left-color:var(--json-key);background:var(--selected-bg)}.log-item.log{border-left-color:#4a4ae6}.log-item.info{border-left-color:var(--log-icon-info)}.log-item.warn{border-left-color:var(--log-icon-warn);background:var(--log-bg-warn)}.log-item.error{border-left-color:var(--log-icon-error);background:rgba(255,59,48,.15)}.log-item.warn.selected,.log-item.error.selected{border-left-color:var(--json-key);background:var(--selected-bg)}.log-count{background:#4a4ae6;color:#fff;border-radius:4px;min-width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;font-size:11px;margin-right:4px;padding:0 5px;flex-shrink:0}.log-icon{flex-shrink:0;display:flex;align-items:center;font-size:13px;margin-right:2px}.log-header{display:flex;align-items:center;gap:0;margin-bottom:2px}.log-content{width:100%;font-size:13px;max-height:300px;overflow-y:auto;margin-top:4px;word-break:break-word;line-height:1.5;user-select:text;-webkit-user-select:text}.timestamp{color:var(--json-cmt);font-size:11px;margin-left:4px;white-space:nowrap}.json-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);border-radius:5px;white-space:pre!important;max-height:400px;overflow:auto}.json-tree-container{font-family:monospace;padding:2px 0;margin-top:2px;background:0 0;border-radius:0;max-height:300px;overflow:auto;font-size:12px;line-height:1.6}.tree-node{position:relative;cursor:pointer;-webkit-tap-highlight-color:transparent}.tree-node.collapsed>.tree-children{display:none}.tree-toggle{display:inline-block;width:9px;color:var(--json-cmt);text-align:center}.ico{display:inline-block;width:1em;height:1em;fill:currentColor;vertical-align:middle;flex-shrink:0}.tree-toggle>.ico{width:9px;height:9px}.tree-node.collapsed>.tree-toggle .ico-angle-down{display:none}.tree-node.expanded>.tree-toggle .ico-angle-right{display:none}.tree-spacer{display:inline-block;width:9px}.tree-leaf{white-space:pre}.tree-leaf-text{white-space:pre-wrap;word-break:break-all;max-height:8em;overflow-y:auto}.tree-label{color:var(--json-cmt)}.tree-children{margin-left:16px;padding-left:4px}.tree-brace{color:var(--json-cmt)}.tree-ellipsis{color:var(--json-cmt)}.tree-load-more{color:var(--json-cmt);cursor:pointer;padding:4px 0;user-select:none;font-size:11px}.tree-node.collapsed>.tree-open{display:none}.tree-node.collapsed>.tree-close{display:none}.tree-node.expanded>.tree-close{display:block;padding-left:16px}.tree-node.expanded>.tree-collapsed{display:none}.tree-node.collapsed>.tree-ellipsis{display:inline}.tree-node.expanded>.tree-ellipsis{display:none}.tree-node.collapsed>.tree-close-tag{display:inline}.tree-node.expanded>.tree-close-tag{display:inline}.json-number{color:var(--json-number)}.json-boolean{color:var(--json-boolean)}.json-key{color:var(--json-key)}.json-tag{color:var(--json-tag)}.json-null{color:var(--json-null)}.json-string{color:var(--json-string)}.json-cmt{color:var(--json-cmt)}.log-actions{margin-top:8px;display:flex;gap:10px;font-size:10px}.log-action{color:var(--json-key);cursor:pointer;padding:5px 10px;background:var(--action-bg);transition:all .2s;display:inline-flex;align-items:center;gap:5px;border-radius:5px}.log-action:hover{background:var(--action-hover)}.error-stack{font-family:monospace;padding:10px;margin-top:10px;background:rgba(255,59,48,.2);border-radius:5px;white-space:nowrap;font-size:.85rem;overflow:auto;max-height:400px}.object-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);color:var(--json-number);border-radius:5px;white-space:pre;max-height:600px;overflow:auto}.function-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);color:var(--json-boolean);border-radius:5px;white-space:pre;word-break:break-all;overflow-x:auto}.ls-item{background:var(--log-bg);padding:15px;margin-bottom:15px;border-radius:8px}.ls-key-row{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;border-bottom:1px solid var(--border-color);padding-bottom:10px}.ls-key{color:var(--json-key);font-size:16px;max-width:60%;overflow-x:auto;white-space:nowrap}.ls-actions{display:flex;gap:8px}.ls-action-btn{background:var(--action-bg);border:none;color:var(--text-color);padding:5px 10px;border-radius:5px;cursor:pointer;transition:all .2s;display:flex;align-items:center;gap:5px}.ls-action-btn:hover{background:var(--action-hover)}.ls-value{white-space:normal;word-break:break-all;padding:10px;background:var(--json-bg);border-radius:5px;font-family:monospace;max-height:200px;overflow-y:auto;color:var(--text-color);font-size:13px}.ls-value-type{font-size:8px;opacity:.7;margin-top:5px;color:var(--text-color)}.vs-spacer{width:100%;flex-shrink:0}.ls-editor-overlay{position:absolute;inset:0;z-index:100;display:flex;flex-direction:column;background:var(--console-bg)}.ls-editor-header{padding:12px 20px;background:var(--header-bg);border-bottom:1px solid var(--border-color)}.ls-editor-header-row{display:flex;align-items:center;gap:10px}.ls-editor-key-input{flex:1;padding:8px 12px;border:1px solid var(--border-color);border-radius:6px;background:var(--search-bg);color:var(--json-key);font-size:14px;font-family:monospace;outline:0;transition:border .2s}.ls-editor-key-input:focus{border-color:var(--filter-active)}.ls-editor-title{color:var(--text-color);font-size:15px;font-weight:600;white-space:nowrap}.ls-editor-body{flex:1;padding:15px 20px;overflow:hidden;display:flex}.ls-editor-body textarea{flex:1;width:100%;padding:12px;background:var(--search-bg);border:1px solid var(--border-color);border-radius:8px;color:var(--text-color);font-family:monospace;font-size:14px;resize:none;outline:0;transition:border .2s;line-height:1.5}.ls-editor-body textarea:focus{border-color:var(--filter-active)}.ls-editor-footer{display:flex;gap:10px;justify-content:flex-end;padding:12px 20px;background:var(--header-bg);border-top:1px solid var(--border-color)}.ls-editor-btn{padding:8px 24px;border:none;border-radius:6px;font-size:14px;cursor:pointer;transition:all .2s;font-weight:500}.ls-editor-btn.cancel{background:var(--controls-bg);color:var(--text-color)}.ls-editor-btn.cancel:hover{background:var(--action-hover)}.ls-editor-btn.save{background:var(--filter-active);color:#fff}.ls-editor-btn.save:hover{opacity:.85}.ls-editor-btn.run{background:var(--filter-active);color:#fff}.ls-editor-btn.run:hover{opacity:.85}.console-table-wrap{overflow-x:auto;margin-top:5px;-webkit-overflow-scrolling:touch;border-radius:8px;border:1px solid rgba(128,128,128,0.25)}.console-table{border-collapse:separate;border-spacing:0;width:100%;font-size:12px;font-family:monospace;overflow:hidden}.console-table th{background:var(--controls-bg);color:var(--json-key);padding:6px 10px;text-align:left;border-bottom:1px solid rgba(128,128,128,0.25);border-right:1px solid rgba(128,128,128,0.25);white-space:nowrap;position:sticky;top:0}.console-table td{padding:5px 10px;border-bottom:1px solid rgba(128,128,128,0.25);border-right:1px solid rgba(128,128,128,0.25);color:var(--text-color);white-space:nowrap;max-width:200px;overflow:hidden;text-overflow:ellipsis}.console-table tbody tr:nth-child(even){background:var(--log-bg)}.console-table tbody tr:hover{background:var(--action-bg)}.console-table th:last-child,.console-table td:last-child{border-right:none}.console-table tbody tr:last-child td{border-bottom:none}.ls-add-btn{font-size:18px!important;opacity:1!important;width:40px!important;height:40px!important;padding:0!important;margin-left:0!important}.mute-btn{background:0 0;border:none;color:var(--text-color);font-size:14px;cursor:pointer;padding:5px 8px;border-radius:5px;opacity:.6;transition:opacity .2s;margin-left:auto;flex-shrink:0}.mute-btn:hover{opacity:1}.mute-btn.muted{opacity:1;filter:saturate(2)}.elements-view{flex:1;overflow-y:auto;padding:10px;font-family:monospace;font-size:12px;line-height:1.6}.elements-tree .tree-node{white-space:normal;word-break:break-all}.el-header-btn{width:40px!important;height:40px!important;font-size:18px!important}.el-header-btn.el-delete-btn:hover{color:var(--clear-btn-color);background:rgba(255,100,100,.15)}.tree-node.el-highlight>.tree-label{display:inline-block!important;background:var(--action-hover)!important;border-radius:3px;padding:1px 4px}.tree-node.el-selected>.tree-label{display:inline-block!important;background:rgba(106,174,255,0.4);border-radius:3px;padding:1px 4px}.element-picker-overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:100000;cursor:crosshair;background:transparent;pointer-events:none}@media(max-width:768px){.controls{flex-direction:row;align-items:center;padding:5px 10px;overflow-x:auto;flex-wrap:nowrap}.log-item{flex-wrap:nowrap}.log-actions{flex-wrap:wrap}.floating-console-btn{padding:12px 20px;font-size:.9rem;right:20px;bottom:20px}.tab-btn{padding:8px 12px;font-size:14px}.notification{position:fixed;top:20px;right:20px;padding:12px 20px;background:rgba(76,175,80,.6);backdrop-filter:blur(12px);color:#fff;border-radius:5px;box-shadow:0 2px 10px rgba(0,0,0,.2);z-index:99999;display:none;transform:translateX(150%);max-height:48px;max-width:calc(100vw - 40px);transition:transform .3s ease;font-size:15px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.notification.show{transform:translateX(0)}.notification.warning{background:rgba(255,152,0,.6);backdrop-filter:blur(12px)}.elements-tree .tree-leaf-text{max-height:12em}.nolog{text-align:center;font-size:20px;color:var(--json-cmt);padding:40px 0;display:flex;align-items:center;justify-content:center;gap:5px}}.network-controls{padding:5px 10px}}.overflow-scroll.overflow-start:not(.overflow-end){-webkit-mask-image:linear-gradient(to right,transparent,#000 40px);mask-image:linear-gradient(to right,transparent,#000 40px)}.overflow-scroll.overflow-end:not(.overflow-start){-webkit-mask-image:linear-gradient(to left,transparent,#000 40px);mask-image:linear-gradient(to left,transparent,#000 40px)}.overflow-scroll.overflow-start.overflow-end{-webkit-mask-image:linear-gradient(to right,transparent,#000 40px,#000 calc(100% - 40px),transparent);mask-image:linear-gradient(to right,transparent,#000 40px,#000 calc(100% - 40px),transparent)}.tree-toggle>.ico{font-size:10px;color:var(--json-cmt);transition:transform .2s;cursor:pointer;width:9px;height:9px;text-align:center;display:inline-block}.network-view{display:none;flex:1;overflow:hidden;flex-direction:column;position:relative}",t.setAttribute("tcstyle",""),t.setAttribute("tc-lock",""),this.shadowRoot.append(t)}setupSplitter(){let t=!1,e=0,s=0,i=()=>{t=!1,this.splitter.classList.remove("dragging"),document.body.style.cursor="",document.body.style.userSelect=""};this.splitter.addEventListener("mousedown",i=>{i.preventDefault(),t=!0,e=i.clientX,s=this.consoleContainer.offsetWidth||.5*window.innerWidth,this.splitter.classList.add("dragging"),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}),document.addEventListener("mousemove",i=>{if(!t)return;let n=i.clientX,o=window.innerWidth-(s+(e-n));o=Math.max(200,Math.min(window.innerWidth-50,o)),this.consoleContainer&&(this.consoleContainer.style.width=o+"px",this.consoleContainer.style.flex="none")}),document.addEventListener("mouseup",i),this.splitter.addEventListener("touchstart",e=>{e.preventDefault(),t=!0,s=this.consoleContainer.offsetWidth||.5*window.innerWidth,e.touches[0],this.splitter.classList.add("dragging")}),document.addEventListener("touchmove",e=>{if(!t)return;let s=e.touches[0],i=window.innerWidth-s.clientX;i=Math.max(200,Math.min(window.innerWidth-50,i)),this.consoleContainer&&(this.consoleContainer.style.width=i+"px",this.consoleContainer.style.flex="none")}),document.addEventListener("touchend",i)}showNotification(t,e=""){this.notification.innerHTML='<span style="display:inline-block;vertical-align:middle;margin-right:8px">'+this.icon("warning"==e?"exclamation":"check")+"</span>"+t.replace(/</,"<").replace(/>/,">"),this.notification.className="notification","warning"===e&&this.notification.classList.add("warning"),this.notification.style.display="block",this.notification.offsetHeight,this.notification.classList.add("show"),clearTimeout(this._notifTimer),this._notifTimer=setTimeout(()=>{this.notification.classList.remove("show"),setTimeout(()=>{this.notification.style.display="none"},300)},3e3)}captureConsoleLogs(){this.originalConsole={log:console.log,info:console.info,warn:console.warn,error:console.error,debug:console.debug,time:console.time,timeEnd:console.timeEnd,count:console.count,countReset:console.countReset,assert:console.assert,trace:console.trace,group:console.group,groupEnd:console.groupEnd,clear:console.clear,table:console.table},console.log=(...t)=>(this.captureConsole("log",...t),console),console.info=(...t)=>(this.captureConsole("info",...t),console),console.warn=(...t)=>(this.captureConsole("warn",...t),console),console.error=(...t)=>(this.captureConsole("error",...t),console),console.debug=(...t)=>(this.captureConsole("log",...t),console),console.table=(t,e)=>(this._captureSubType="table",this._captureExtra={columns:e},this.captureConsole("log",t),this._captureSubType=null,this._captureExtra=null,console),console.time=(t="time")=>{t=String(t);let e=performance.now();this.timerMap.has(t)&&clearTimeout(this.timerMap.get(t).timeoutId);let s=setTimeout(()=>{if(!this.timerMap.has(t))return;let{start:e}=this.timerMap.get(t);this.timerMap.delete(t),console.info(`[time] "${t}"用时: ${(performance.now()-e).toFixed(1)}ms(已超时)`)},3e5);this.timerMap.set(t,{start:e,timeoutId:s}),console},console.timeEnd=(t="time")=>{t=String(t);let e=this.timerMap.get(t);if(!e)return void console.error(`[timeEnd] 标签"${t}"不存在`);e.timeoutId&&clearTimeout(e.timeoutId);let s=performance.now()-e.start;this.timerMap.delete(t),console.info(`[time] "${t}"用时: ${s.toFixed(1)}ms`),console},console.count=(t="count")=>{t=String(t);let e=(this.countMap.get(t)||0)+1;this.countMap.set(t,e),console.info(`[count] 标签"${t}"被调用了${e}次`),console},console.countReset=(t="count")=>{t=String(t),this.countMap.has(t)?this.countMap.delete(t):console.error(`[countReset] 标签"${t}"不存在`),console},console.assert=(t,...e)=>{t||console.error("[assertion failed] ",...e),console},console.trace=(...t)=>{let e=(new Error).stack.split("\n").slice(2).join("\n");console.warn("[trace] ",...t,"\n"+e),console},console.group=t=>(this.captureConsole("log",`[Group ${t}]`),console),console.groupEnd=()=>(this.captureConsole("log","[GroupEnd]"),console),console.clear=()=>(this.clearAllLogs(!0),console)}isClass(t){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t&&!1===Object.getOwnPropertyDescriptor(t,"prototype").writable}renderFunctionInline(t){let e=t.name||"anonymous",s=this.getParams(t);return'<span class="json-boolean">ƒ '+this.escapeHtml(e)+'</span><span class="json-cmt">('+this.escapeHtml(s)+")</span>"}renderFunctionCollapsed(t){let e=t.name||"anonymous",s=this.getParams(t);return'<span class="json-boolean">ƒ '+this.escapeHtml(e)+'</span><span class="json-cmt">('+this.escapeHtml(s)+")</span>"}safeStringify(t,s=2,i=!0){let n=new WeakSet,o=(t,e=new WeakSet)=>null===t||"object"!=typeof t?"bigint"==typeof t?""+t.toString()+"n":t:e.has(t)?"[循环引用]":(e.add(t),t instanceof RegExp?""+t.toString():t instanceof Date?""+t.toISOString():"function"==typeof t?this.isClass(t)?"[Class "+(t.name||"anonymous")+"]":"ƒ "+(t.name||"anonymous")+"("+this.getParams(t)+")":t instanceof Error?"[Error: "+t.message+"]":t instanceof ArrayBuffer?"[ArrayBuffer "+t.byteLength+" bytes]":t instanceof WeakMap?"[WeakMap]":t instanceof WeakSet?"[WeakSet]":t instanceof Map?"[Map "+t.size+"]":t instanceof Set?"[Set "+t.size+"]":Array.isArray(t)?t.map(t=>o(t,e)):(()=>{let s={};try{Reflect.ownKeys(t).forEach(i=>{let n=Object.getOwnPropertyDescriptor(t,i);if(n){let r="symbol"==typeof i?"["+i.toString()+"]":String(i);if("value"in n)s[r]=o(n.value,e);else if(n.get)try{s[r]=o(n.get.call(t),e)}catch{s[r]="[getter]"}}})}catch{}let n=Object.getPrototypeOf(t);return i&&n&&null!==n&&(s["[[Prototype]]"]=o(n,e)),s})());return t=o(t),JSON.stringify(t,function(t,s){if(void 0===s)return"undefined";if("number"==typeof s){if(Number.isNaN(s))return"NaN";if(!isFinite(s))return""+(s>0?"Infinity":"-Infinity")}if("object"==typeof s&&null!==s){if(n.has(s))return"[循环引用]";if(n.add(s),!Array.isArray(s)&&s.constructor===Object)return Object.keys(s).sort((t,e)=>{let s="[[Prototype]]"===t,i="[[Prototype]]"===e,n=t.endsWith("[[Prototype]]")&&"[[Prototype]]"!==t,o=e.endsWith("[[Prototype]]")&&"[[Prototype]]"!==e;if(s&&!i)return 1;if(!s&&i)return-1;if(n&&!o)return 1;if(!n&&o)return-1;let r=t.match(/^(_*)/)[0].length,l=e.match(/^(_*)/)[0].length;return r!==l?r-l:t.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"})}).reduce((t,e)=>(t[e]=s[e],t),{});if(s instanceof Error)return{"名称":s.name,"信息":s.message,"堆栈":s.stack};if(s instanceof Date)return s.toISOString();if(s instanceof HTMLElement)return`<${s.tagName.toLowerCase()}>${s.tagName.toLowerCase()}元素</${s.tagName.toLowerCase()}>`}return"string"==typeof s?s.startsWith("")?s:""+s:"function"==typeof s?""+(e.tC.isClass(s)?`[Class ${s.name||"anonymous"}]`:`ƒ ${s.name||"anonymous"}(${e.tC.getParams(s)})`):s},s)}formatArgsForPlainText(t){return Array.from(t).map(t=>{if("function"==typeof t)return this.isClass(t)?`[Class ${t.name||"anonymous"}]`:`ƒ ${t.name||"anonymous"}(${this.getParams(t)})`;if("object"==typeof t&&null!==t)try{return this.safeStringify(t)}catch{return"无法序列化]"}return String(t)}).join(" ")}captureConsole(t,...e){if(this._capturing)this.originalConsole[t].apply(console,e);else{this._capturing=!0;try{this.triggerGlobalHook("beforeLog",t,...e);let s=!1;if(this.mutedFilters.console&&(this.mutedFilters.console.all||this.mutedFilters.console[t])&&(s=!0),this.mutedLogs||s)return void this.originalConsole[t].apply(console,e);let i=new Date,n=e.map(t=>{if("object"==typeof t&&null!==t)try{if(t instanceof HTMLElement)return`el:<${t.tagName.toLowerCase()}>`;if(t instanceof Date)return`d:${t.getTime()}`;if(t instanceof RegExp)return`re:${t.toString()}`;if(t instanceof Error)return`e:${t.message}`;let e=Object.entries(t).reduce((t,[e,s])=>{if("then"===e&&"function"==typeof s)return t;if("object"==typeof s&&null!==s)try{t[e]=JSON.stringify(s)}catch{t[e]="NestedObject"}else t[e]=s;return t},{});return`o:${JSON.stringify(e)}`}catch{return`u:${Math.random().toString(36).substring(2,10)}`}return`${typeof t}:${String(t)}`}).join("|");if(this.lastLog&&this.lastLog.type===t&&this.lastLog.contentSign===n&&(this.lastLog.subType||null)===(this._captureSubType||null)&&!e.some(t=>"object"==typeof t&&null!==t)){this.lastLog.args=[...e],this.lastLog.timestamp=new Date,this.lastLog.count++;let s=this.shadowRoot.getElementById(`log-item-${this.lastLog.id}`);if(s){let t=s.querySelector(".log-count");if(t)t.textContent=this.lastLog.count;else{let t=s.querySelector(".log-header");if(t){let e=document.createElement("div");e.className="log-count",e.textContent=this.lastLog.count;let s=t.querySelector(".log-icon");s?t.insertBefore(e,s):t.appendChild(e)}}}return this.originalConsole[t].apply(console,e),void this.updateFilterCounts()}{let s={id:this.logs.length,type:t,args:[...e],content:this.formatArgsForPlainText(e),timestamp:i,count:1,expandedJson:!1,contentSign:n,hasObject:e.some(t=>"function"==typeof t),isError:"error"===t||e.some(t=>t instanceof Error),subType:this._captureSubType||null,subTypeData:this._captureExtra||null};this.logs.push(s),this.lastLog=s,this.triggerGlobalHook("afterLog",s)}this.originalConsole[t].apply(console,e),this.overlay?.classList.contains("active")&&"console"===this.currentTab&&(this.updateFilterCounts(),this.renderLogList(this.logs,!1)),this.logs.length>this.maxLog&&this.logs.splice(0,this.logs.length-this.maxLog)}finally{this._capturing=!1}}}formatArgs(t,e){let s=e||"x",i=Array.from(t),n=i.map(t=>"function"==typeof t?`<div class="function-preview">${this.escapeHtml(t.toString())}</div>`:t instanceof Error?`<div class="error-stack"><strong>${t.name}:</strong>${t.message}<div>${t.stack||"无堆栈信息"}</div></div>`:t instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(t,"",s+":html")+"</div>":t instanceof Date?`<div class="json-preview"><span class="json-string">${t.toISOString()}</span></div>`:t instanceof RegExp?`<div class="json-preview"><span class="json-number">${t.toString()}</span></div>`:t instanceof Map?`<div class="json-preview"><span class="json-boolean">[Map ${t.size}]</span></div>`:t instanceof Set?`<div class="json-preview"><span class="json-boolean">[Set ${t.size}]</span></div>`:t instanceof WeakMap?'<div class="json-preview"><span class="json-boolean">[WeakMap]</span></div>':t instanceof WeakSet?'<div class="json-preview"><span class="json-boolean">[WeakSet]</span></div>':t instanceof ArrayBuffer?`<div class="json-preview"><span class="json-boolean">[ArrayBuffer ${t.byteLength} bytes]</span></div>`:this.fmtVal(t,s,0));return i.splice(0,1),n.join(" ")}fmtVal(t,s,i){return"bigint"==typeof t?`<span class="json-number">${t.toString()}n</span>`:t&&"object"==typeof t?'<div class="json-tree-container">'+this.renderJSONTree(t,"",null,null,s+(i?":r:":":"),0)+"</div>":"number"==typeof t?Number.isNaN(t)?'<span class="json-cmt">NaN</span>':isFinite(t)?`<span class="json-number">${t}</span>`:`<span class="json-cmt">${t>0?"Infinity":"-Infinity"}</span>`:"boolean"==typeof t?`<span class="json-boolean">${t}</span>`:String(t).replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>")}highlightHTML(t){let e=t.outerHTML.replace(/</g,"<").replace(/>/g,">").replace(/<br>/g,"<br>"),s="",i=0;for(;i<e.length;)if(e.startsWith("<",i)){let t=e[i+4];if(t&&("/"===t||/[a-zA-Z]/.test(t))){let t=e.indexOf(">",i);if(-1!==t){let n=e.slice(i,t+4);n=n.replace(/([\w-]+)(=)("[^"]*")/g,'<span class="json-tag">$1</span><span class="json-boolean">$2</span><span class="json-string">$3</span>'),n=n.replace(/^(<\/?)([\w-]+)/,'<span class="json-tag">$1</span><span class="json-tag">$2</span>'),n=n.replace(/(>)$/,'<span class="json-tag">$1</span>'),s+=n,i=t+4;continue}}let n=e.indexOf("<",i+4);-1===n&&(n=e.length);let o=e.slice(i,n);s+=o.trim()?`<span class="json-cmt">${o}</span>`:o,i=n}else if(e.startsWith("<br>",i))s+="<br>",i+=4;else{let t=e.indexOf("<",i);-1===t&&(t=e.length);let n=e.slice(i,t);s+=n.trim()?`<span class="json-cmt">${n}</span>`:n,i=t}return s}highlightJson=t=>t&&t.replace(/("(?:\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(?:\s*:)?|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b|[\{\}\[\],.:])/g,t=>{let e="json-cmt";if("true"===t||"false"===t)e="json-boolean";else if("null"===t)e="json-null";else if(/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(t))e="json-number";else if(t.endsWith(":"))e="json-key";else if(t.startsWith('"')){let s=t.slice(1,-1);if(/^\\u0002/.test(s))return`<span class="json-string">"${s.slice(6)}"</span>`;if(/^\\u0003/.test(s)){let t=s.slice(6);if(/^-?\d+n$/.test(t))return`<span class="json-number">${t}</span>`;if(/^\u0192\s/.test(t)){let e=t.match(/^(\u0192\s+\S+)(\(.*\))$/);return e?`<span class="json-boolean">${e[1]}</span><span class="json-cmt">${e[2]}</span>`:`<span class="json-boolean">${t}</span>`}return/^\[(?:Class|ArrayBuffer|Map|Set|WeakMap|WeakSet|Error)/.test(t)?`<span class="json-boolean">${t}</span>`:/^\/.*\/[gimsuy]*$/.test(t)?`<span class="json-number">${t}</span>`:/^\d{4}-\d{2}-\d{2}T/.test(t)?`<span class="json-string">${t}</span>`:/^(?:undefined|NaN|Infinity|-Infinity)$/.test(t)?`<span class="json-null">${t}</span>`:`<span class="json-string">${t}</span>`}e="json-string"}return`<span class="${e}">${t}</span>`})||"";renderJSONValue(t,e){if(null===t)return'<span class="json-null">null</span>';if(void 0===t)return'<span class="json-null">undefined</span>';if("string"==typeof t)return'<span class="json-string">"'+this.escapeHtml(t)+'"</span>';if("number"==typeof t)return'<span class="json-number">'+t+"</span>";if("boolean"==typeof t)return'<span class="json-boolean">'+t+"</span>";if("function"==typeof t){if(this.isClass(t)){let e=t.name||"anonymous";return'<span class="json-boolean">[Class '+this.escapeHtml(e)+"]</span>"}return this.renderFunctionInline(t)}if(t instanceof HTMLElement){let e=t.tagName.toLowerCase();return'<span class="json-tag"><'+e+">...</"+e+"></span>"}let s=Array.isArray(t),i=s?"Array("+t.length+")":"Object",n=s?t.map((t,e)=>({name:String(e),value:t})):Object.keys(t).map(e=>({name:e,value:t[e]}));if(0===n.length)return'<span class="json-cmt">'+(e?this.escapeHtml(e)+": ":"")+(s?"[]":"{}")+"</span>";let o='<div class="tree-node collapsed">';o+=this.treeToggleHtml(),e&&(o+='<span class="json-key">'+this.escapeHtml(e)+":</span> "),o+='<span class="tree-label">'+this.escapeHtml(i)+"</span>",o+='<span class="tree-brace tree-open">{</span><span class="tree-brace tree-collapsed">{...}</span>';let r=++this.treeNodeRegId;return this.treeNodeRegistry.set(r,{obj:t,children:n,isJsonValue:!0}),o+='<div class="tree-children" data-lazy-id="'+r+'"></div>',o+='<span class="tree-brace tree-close">}</span>',o+="</div>",o}renderJSONValueChildren(t,e){let s="";for(let e of t){let t=e.value;s+=null===t||"object"!=typeof t?'<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(e.name)+":</span> "+this.renderJSONValue(t,"")+"</div>":"<div>"+this.renderJSONValue(t,e.name)+"</div>"}return s}toggleExpandJson(t){let e=this.logs.find(e=>e.id===t);e&&(e.expandedJson=!e.expandedJson,this.updateLogItem(t,!1))}updateLogItem(t,e=!1){let s=this.logs.find(e=>e.id===t);if(!s)return;let i=this.shadowRoot.getElementById(`log-item-${t}`);if(!i)return;let n={info:"info-circle",warn:"exclamation-triangle",error:"times-circle",log:"info"}[s.type]||"info",o=s.timestamp.toLocaleTimeString(),r=s.expandedJson?this.formatArgs(s.args,s.id):this.renderLogContent(s);i.innerHTML=`<div class="log-header">${s.count>1?`<div class="log-count">${s.count}</div>`:""}<div class="log-icon">${this.icon(n)}</div><div class="timestamp">${o}</div></div><div class="log-content">${r}</div>${s.hasObject?`<div class="log-actions"><div class="log-action expand-btn" title="${s.expandedJson?"收起":"展开"}" onclick="thinConsole.tC.toggleExpandJson(${s.id})">${this.icon(s.expandedJson?"chevron-up":"chevron-down")}${s.expandedJson?"收起":"展开"}</div></div>`:""}</div>`}updateControlsVisibility(){let c=this.currentTab,e="console"===c,s="localstorage"===c,i="network"===c,l="elements"===c,_=(t,v)=>{t&&(t.style.display=v)};_(this.consoleControls,e||s?"flex":"none"),_(this.filtersContainerEl,e?"flex":"none"),_(this.lsFiltersContainer,s?"flex":"none"),_(this.muteBtn,e?"flex":"none"),_(this.logCopyBtn,e&&null!==this.selectedLogId?"flex":"none"),_(this.lsAddBtn,s?"flex":"none"),_(this.netNewBtn,i?"flex":"none"),_(this.elementPickBtn,l?"flex":"none"),_(this.elCopyBtn,l&&this.selectedElement?"flex":"none"),_(this.elDeleteBtn,l&&this.selectedElement?"flex":"none"),_(this.searchBar,l?"none":this.searchExpanded?"flex":"none"),_(this.searchToggleBtn,l?"none":"flex"),this.updateEditorVisibility()}updateEditorVisibility(){if(!this.lsEditorOverlay)return;let t=this.editorState.visible;if(t&&"ls"===this.editorState.mode&&"localstorage"!==this.currentTab&&(t=!1),this.lsEditorOverlay.style.display=t?"flex":"none",t){let t="code"===this.editorState.mode;this.lsEditorKeyInput&&(this.lsEditorKeyInput.style.display=t?"none":"block"),this.lsEditorTitle.textContent=t?"运行代码":"",this.lsEditorInput.placeholder=t?"输入要执行的代码...":"输入值...",this.lsEditorSave.textContent=t?"运行":"保存",this.lsEditorSave.className="ls-editor-btn "+(t?"run":"save"),this.lsEditorInput.value!==this.editorState.value&&(this.lsEditorInput.value=this.editorState.value),!t&&this.lsEditorKeyInput&&this.lsEditorKeyInput.value!==this.editorState.key&&(this.lsEditorKeyInput.value=this.editorState.key)}}vsInit(t){if(!t)return;t._vs={items:[],renderItem:null,afterRender:null,avgHeight:70,estHeight:70,heights:new Map,lastStart:-1,lastEnd:-1,rafId:null,isAtBottom:!0,contentEl:null,topSpacer:null,bottomSpacer:null,fakeEl:null,hasStructure:!1,topSpaceHeight:0,lastScrollTop:0,lastTimestamp:0,speedToleranceFactor:100,maxSpeedTolerance:2e3,minSpeedTolerance:100};let e=document.createElement("div");e.className="vs-spacer",e.style.cssText="width:100%;flex-shrink:0;height:0";let s=document.createElement("div");s.className="vs-content",s.style.cssText="width:100%";let i=document.createElement("div");i.className="vs-spacer",i.style.cssText="width:100%;flex-shrink:0;height:0";let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:0;top:0;width:100%;pointer-events:none",t.innerHTML="",t.appendChild(e),t.appendChild(s),t.appendChild(i),t.appendChild(n),t._vs.topSpacer=e,t._vs.contentEl=s,t._vs.bottomSpacer=i,t._vs.fakeEl=n,t._vs.hasStructure=!0,t._vs.scrollHandler=()=>{let e=t._vs;if(!e)return;let s=t.scrollHeight,i=t.clientHeight,n=t.scrollTop;e.isAtBottom=Math.abs(s-i-n)<2;let o,r,l=Date.now(),a=l-e.lastTimestamp,c=n-e.lastScrollTop,d=Math.abs(c/(a||1))*e.speedToleranceFactor;a>1e3&&(d=1e3),d>e.maxSpeedTolerance&&(d=e.maxSpeedTolerance),d<e.minSpeedTolerance&&(d=e.minSpeedTolerance),e.lastScrollTop=n,e.lastTimestamp=l,e.lastScrollTop<n?(o=e.minSpeedTolerance,r=d):(o=d,r=e.minSpeedTolerance),e.topSpaceHeight<n-o&&e.topSpaceHeight+e.contentEl.offsetHeight>n+i+r||e.rafId||(e.rafId=requestAnimationFrame(()=>{e.rafId=null,this.vsRender(t)}))},t.addEventListener("scroll",t._vs.scrollHandler,{passive:!0})}vsRender(t){let e=t._vs;if(!e||!e.contentEl)return;if(!e.items||!e.items.length)return;let ch=e.contentEl.children;if(ch.length>0){let ct=0;for(let ci=0;ci<ch.length;ci++){let ch2=ch[ci].offsetHeight+10;e.heights.set(e.lastStart+ci,ch2),ct+=ch2}let ca=ct/ch.length;ca>20&&ca<2e3&&(e.avgHeight=Math.round(.5*e.avgHeight+.5*ca))}let s=t.clientHeight||400,i=t.scrollTop,n=e.avgHeight||70;n<10&&(n=70);let o=600,r=i-o,l=i+s+o,a=0,c=0,d=0,h=e.items.length,p=!1;for(let t=0;t<e.items.length;t++){let s=e.heights.get(t)||n;if(!p&&a+s>=r&&(d=t,p=!0),a>=l){h=t;break}a+=s}if(p){if(h===e.items.length){h=e.items.length;let t=h;for(;t>d&&c<s+o;)t--,c+=e.heights.get(t)||n;d=Math.max(0,Math.min(d,t))}}else d=0;let u=!1;for(let t=d;t<h;t++)if(!e.heights.has(t)){u=!0;break}if(u&&e.fakeEl){let s=e.fakeEl,i=t.clientWidth;i>0&&(s.style.width=i+"px");for(let t=d;t<h;t++)if(!e.heights.has(t)){s.innerHTML=e.renderItem(e.items[t],t);let i=0;s.firstChild&&(i=s.firstChild.offsetHeight+10),i<10&&(i=n),e.heights.set(t,i)}s.innerHTML=""}a=0,c=0,d=0,h=e.items.length,p=!1;for(let t=0;t<e.items.length;t++){let s=e.heights.get(t)||n;if(!p&&a+s>=r&&(d=t,p=!0),a>=l){h=t;break}a+=s}if(p){if(h===e.items.length){h=e.items.length;let t=h;for(;t>d&&c<s+o;)t--,c+=e.heights.get(t)||n;d=Math.max(0,Math.min(d,t))}}else d=0;if(d===e.lastStart&&h===e.lastEnd){let th=0;for(let ti=0;ti<d;ti++)th+=e.heights.get(ti)||n;let bh=0;for(let bi=h;bi<e.items.length;bi++)bh+=e.heights.get(bi)||n;return e.topSpacer.style.height=th+"px",e.bottomSpacer.style.height=bh+"px",e.topSpaceHeight=th,void(0===bh&&e.isAtBottom&&(t.scrollTop=1e7))}e.lastStart=d,e.lastEnd=h;let g=0;for(let t=0;t<d;t++)g+=e.heights.get(t)||n;let f=0;for(let t=h;t<e.items.length;t++)f+=e.heights.get(t)||n;let m=t.scrollTop;e.topSpacer.style.height=g+"px",e.bottomSpacer.style.height=f+"px",e.topSpaceHeight=g;let b=document.createDocumentFragment();for(let t=d;t<h;t++){let s=document.createElement("div");for(s.innerHTML=e.renderItem(e.items[t],t);s.firstChild;)b.appendChild(s.firstChild)}e.contentEl.replaceChildren?e.contentEl.replaceChildren(b):(e.contentEl.innerHTML="",e.contentEl.appendChild(b));let y=e.contentEl.children;if(y.length>=1){let t=0;for(let s=0;s<y.length;s++){let i=y[s].offsetHeight+10;t+=i,Math.abs(i-(e.heights.get(d+s)||n))>5&&e.heights.set(d+s,i)}let s=Math.round(t/y.length);s>20&&s<2e3&&(e.avgHeight=Math.round(.5*e.avgHeight+.5*s))}if(0===f&&y.length>0){let t=0;for(let e=0;e<y.length;e++)t+=y[e].offsetHeight+10;if(t<s&&d>0){let i=Math.ceil((s-t)/n)+2,o=Math.max(0,d-i);if(o<d){d=o,e.lastStart=d;let t=0;for(let s=0;s<d;s++)t+=e.heights.get(s)||n;e.topSpacer.style.height=t+"px",e.topSpaceHeight=t;let s=document.createDocumentFragment();for(let t=d;t<h;t++){let i=document.createElement("div");for(i.innerHTML=e.renderItem(e.items[t],t);i.firstChild;)s.appendChild(i.firstChild)}e.contentEl.replaceChildren?e.contentEl.replaceChildren(s):(e.contentEl.innerHTML="",e.contentEl.appendChild(s));let i=e.contentEl.children;if(i.length>=1){let t=0;for(let s=0;s<i.length;s++){let o=i[s].offsetHeight+10;t+=o,Math.abs(o-(e.heights.get(d+s)||n))>5&&e.heights.set(d+s,o)}let s=Math.round(t/i.length);s>20&&s<2e3&&(e.avgHeight=Math.round(.5*e.avgHeight+.5*s))}}}}let v=0;for(let t=0;t<d;t++)v+=e.heights.get(t)||n;let x=0;for(let t=h;t<e.items.length;t++)x+=e.heights.get(t)||n;e.topSpacer.style.height=v+"px",e.bottomSpacer.style.height=x+"px",e.topSpaceHeight=v,e.isAtBottom||m===t.scrollTop||(t.scrollTop=m),e.afterRender&&e.afterRender()}vsUpdate(t,e,s,i,n){let o=t._vs;if(!o)return;o.rafId&&(cancelAnimationFrame(o.rafId),o.rafId=null);let g=n&&n.trackBy?o.trackBy=n.trackBy:o.trackBy||(t=>t.id);if(!e||!e.length)return o.items=[],o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,void(o.contentEl?(o.topSpacer.style.height="0",o.bottomSpacer.style.height="0",o.topSpaceHeight=0,o.contentEl.innerHTML=n&&n.emptyHTML||"",!(n&&n.preserveScroll)&&(t.scrollTop=0),o.isAtBottom=!0):t.innerHTML=n&&n.emptyHTML||"");let r=(!n||!n.force&&!n.preserveScroll)&&(o.isAtBottom=Math.abs(t.scrollHeight-t.clientHeight-t.scrollTop)<2),l=o.items?o.items.length:0,a=l>0&&o.items[0]&&e[0]&&g(o.items[0])!==g(e[0]);if(o.items=e,o.renderItem=s,n&&n.force?(o.avgHeight=i||70,o.isAtBottom=!1):o.avgHeight<10&&(o.avgHeight=i||100),o.afterRender=null,r)o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,this.vsRender(t),o.isAtBottom&&(t.scrollTop=t.scrollHeight);else if((!n||!n.force)&&l>0&&e.length>=l&&!a&&o.lastEnd>=0){let h=0;for(let m=o.lastEnd;m<e.length;m++)h+=o.heights.get(m)||o.avgHeight;o.bottomSpacer.style.height=h+"px"}else o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,n&&n.force&&!(n&&n.preserveScroll)&&(t.scrollTop=0),this.vsRender(t)}renderSubTypeContent(t){let e=t.args&&t.args.length>0?t.args[0]:void 0;return"table"===t.subType?this.renderTableHTML(e,t.subTypeData?.columns):""}_treeNodeOpen(t,e,s,i){let n="tree-node "+(t?"expanded":"collapsed"),o=e+'="'+this.escapeHtml(s)+'"';return i&&(o+=" "+i),'<div class="'+n+'" '+o+">"}_treeNodeChildrenLazy(t,e){return this.treeNodeRegistry.set(t,e),'<div class="tree-children" data-lazy-id="'+t+'"></div>'}_treeShadowNode(t,e,s,i,n,o){let r="tree-node "+(t?"expanded":"collapsed"),l=e+'="'+this.escapeHtml(String(s))+'"';return o&&(l+=" "+o),'<div class="'+r+'" '+l+">"+this.treeToggleHtml()+'<span class="tree-label json-null">#shadow('+i+')</span><span class="tree-ellipsis">...</span><div class="tree-children">'+n+"</div></div>"}renderJSONTree(t,e,s,i,n,o,r){if(s||(s=new WeakSet),i||(i=[]),o=o||0,null===t)return'<span class="json-null">null</span>';if(void 0===t)return'<span class="json-null">undefined</span>';if("string"==typeof t)return'<span class="json-string">"'+this.escapeHtml(t)+'"</span>';if("number"==typeof t)return'<span class="json-number">'+t+"</span>";if("boolean"==typeof t)return'<span class="json-boolean">'+t+"</span>";if("bigint"==typeof t)return'<span class="json-number">'+t.toString()+"n</span>";if("symbol"==typeof t){let e=Object.create(Object.getPrototypeOf(Object(t)));Object.defineProperty(e,"value",{value:t.toString(),enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(e,"description",{value:t.description,enumerable:!0,writable:!0,configurable:!0}),t=e}if("function"==typeof t){if(this.isClass(t)){let e=t.name||"anonymous";return'<span class="json-boolean">[Class '+this.escapeHtml(e)+"]</span>"}return this.renderFunctionInline(t)}if(t instanceof Date)return'<span class="json-string">'+t.toISOString()+"</span>";if(t instanceof RegExp)return'<span class="json-number">'+t.toString()+"</span>";if(t instanceof Map)return'<span class="json-boolean">[Map '+t.size+"]</span>";if(t instanceof Set)return'<span class="json-boolean">[Set '+t.size+"]</span>";if(t instanceof WeakMap)return'<span class="json-boolean">[WeakMap]</span>';if(t instanceof WeakSet)return'<span class="json-boolean">[WeakSet]</span>';if(t instanceof ArrayBuffer)return'<span class="json-boolean">[ArrayBuffer '+t.byteLength+" bytes]</span>";if(t instanceof Error)return'<span class="json-boolean">[Error: '+this.escapeHtml(t.message)+"]</span>";if(t instanceof HTMLElement){let e=t.tagName.toLowerCase();return'<span class="json-tag"><'+e+">...</"+e+"></span>"}if(s.has(t))return'<span class="json-cmt">[循环引用]</span>';s.add(t);let l=i.concat([t]),a=Array.isArray(t),c=a?"Array("+t.length+")":t.constructor&&t.constructor.name?t.constructor.name:"Object",d=[];try{Reflect.ownKeys(t).forEach(e=>{let s=Object.getOwnPropertyDescriptor(t,e);s&&d.push({name:String(e),desc:s})})}catch(e){try{Object.keys(t).forEach(e=>{let s=Object.getOwnPropertyDescriptor(t,e);s&&d.push({name:String(e),desc:s})})}catch(e){return s.delete(t),'<span class="json-boolean">['+this.escapeHtml(c)+"]</span>"}}let h=Object.getPrototypeOf(t);if(!r&&h&&null!==h&&d.push({name:"[[Prototype]]",desc:{value:h,enumerable:!0,writable:!0,configurable:!0}}),0===d.length)return s.delete(t),a?'<span class="json-cmt">'+(e?this.escapeHtml(e)+": ":"")+"[]</span>":'<span class="json-cmt">'+(e?this.escapeHtml(e)+": ":"")+"{}</span>";a||d.sort((t,e)=>{if("[[Prototype]]"===t.name)return 1;if("[[Prototype]]"===e.name)return-1;let s=!(!t.desc.get&&!t.desc.set),i=!(!e.desc.get&&!e.desc.set);if(s&&!i)return 1;if(!s&&i)return-1;let n=(t.name.match(/^(_*)/)||[""])[0].length,o=(e.name.match(/^(_*)/)||[""])[0].length;if(n!==o)return n-o;let r=/^[A-Z]/.test(t.name),l=/^[A-Z]/.test(e.name);return r&&!l?1:!r&&l?-1:t.name.localeCompare(e.name,void 0,{numeric:!0,sensitivity:"base"})});let p=n||"",u=this.expandedTreePaths.has(p),g=this._treeNodeOpen(u,"data-tree-path",p);if(g+=this.treeToggleHtml(),e&&(g+='<span class="json-key">'+this.escapeHtml(e)+":</span> "),g+='<span class="tree-label">'+this.escapeHtml(c)+"</span>",g+='<span class="tree-brace tree-open">{</span><span class="tree-brace tree-collapsed">{...}</span>',u){g+='<div class="tree-children">';let t=200;if(d.length>t){let e=this.treeNodeRegId++;this.treeNodeRegistry.set(e,{children:d,chain:l,noProto:r}),g+=this.renderTreeChildrenBatch(d,s,0,t,l,p,o+1,r),g+='<div class="tree-load-more" data-reg-id="'+e+'" data-offset="'+t+'">'+this.icon("angle-down")+" 展开更多 (剩余 "+(d.length-t)+" 项)</div>"}else g+=this.renderTreeChildrenBatch(d,s,0,d.length,l,p,o+1,r);g+="</div>"}else{let e=this.treeNodeRegId++;g+=this._treeNodeChildrenLazy(e,{obj:t,children:d,chain:i,path:p,noProto:r})}return g+='<span class="tree-brace tree-close">}</span>',g+="</div>",s.delete(t),g}renderTreeChildrenBatch(t,e,s,i,n,o,r,l){r=r||0;let a="";for(let c=s;c<i&&c<t.length;c++){let s=t[c];if(s.desc.get||s.desc.set)s.desc.get&&(a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">get '+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(s.desc.get,"",e,n,o+"."+s.name,r+1,l)+"</div>"),s.desc.set&&(a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">set '+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(s.desc.set,"",e,n,o+"."+s.name,r+1,l)+"</div>");else{let t=s.desc.value;null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp||t instanceof Map||t instanceof Set||t instanceof WeakMap||t instanceof WeakSet||t instanceof ArrayBuffer||t instanceof Error||t instanceof HTMLElement||"function"==typeof t?a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(t,"",e,n,o+"."+s.name,r+1,l)+"</div>":e.has(t)?a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(s.name)+':</span> <span class="json-cmt">[循环引用]</span></div>':a+="<div>"+this.renderJSONTree(t,s.name,e,n,o+"."+s.name,r+1,l)+"</div>"}}return a}renderDomChild(t,e,s,i){return 1===t.nodeType?"<div>"+e(t,s,i)+"</div>":3===t.nodeType?'<div class="tree-leaf tree-leaf-text"><span class="tree-spacer"></span><span class="json-cmt">'+this.escapeHtml(t.textContent.trim())+"</span></div>":""}renderDomChildrenLazy(t,e,s,i,n){let o="";if(t.length>200){let r=this.treeNodeRegId++;this.treeNodeRegistry.set(r,Object.assign({type:i,children:t,depth:s},n));for(let i=0;i<200;i++)o+=this.renderDomChild(t[i],e,i,s+1);o+='<div class="tree-load-more" data-reg-id="'+r+'" data-offset="200">'+this.icon("angle-down")+" 展开更多 ("+(t.length-200)+")</div>"}else{let i=0;for(let n of t)o+=this.renderDomChild(n,e,i,s+1),1===n.nodeType&&i++}return o}buildShadowLazy(t,e,s,i,n){let o='<div class="tree-node collapsed" ';if("element"===e){let e=++this.elRefId;this.elRefMap.set(e,t.root),o+='data-el-id="'+e+'" data-shadow-host="'+n+'"'}else o+='data-tree-path="'+this.escapeHtml(s+".shadow")+'" data-shadow-root="1"';o+=">"+this.treeToggleHtml()+'<span class="tree-label json-null">#shadow('+t.mode+")</span>";let r=Array.from(t.root.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim());if(r.length>0){let n=this.treeNodeRegId++;this.treeNodeRegistry.set(n,{type:e+"-shadow",shadowInfo:t,path:s,depth:i,children:r}),o+='<span class="tree-ellipsis">...</span><div class="tree-children" data-lazy-id="'+n+'"></div>'}return o+"</div>"}loadMoreTreeChildren(t){let e=parseInt(t.dataset.regId),s=parseInt(t.dataset.offset),i=this.treeNodeRegistry.get(e);if(!i)return;let n=t.closest(".console-output, .ls-items, .elements-tree");if("html"===i.type){let e=Math.min(s+200,i.children.length),n="";for(let t=s;t<e;t++)n+=this.renderDomChild(i.children[t],(t,e)=>this.renderHTMLTree(t,"",i.path+"."+e,(i.depth||0)+1),t,0);t.insertAdjacentHTML("beforebegin",n)}else if("element"===i.type){let e=Math.min(s+200,i.children.length),n="";for(let t=s;t<e;t++)n+=this.renderDomChild(i.children[t],t=>this.renderElementTree(t,(i.depth||0)+1),t,0);t.insertAdjacentHTML("beforebegin",n)}else{let e=new WeakSet;i.chain.forEach(t=>e.add(t)),t.insertAdjacentHTML("beforebegin",this.renderTreeChildrenBatch(i.children,e,s,Math.min(s+200,i.children.length),i.chain,i.path||"",1,i.noProto))}let o=s+200;o<i.children.length?(t.dataset.offset=o,t.innerHTML=this.icon("angle-down")+" 展开更多 ("+(i.children.length-o)+")"):(t.remove(),this.treeNodeRegistry.delete(e)),n&&this.vsRender(n)}fmtAttrs(t){let s="";for(let e of t.attributes)s+=e.value?' <span class="json-tag">'+this.escapeHtml(e.name)+'</span><span class="json-boolean">=</span><span class="json-string">"'+this.escapeHtml(e.value)+'"</span>':' <span class="json-tag">'+this.escapeHtml(e.name)+"</span>";return s}renderHTMLTree(t,e,s,i){if((i=i||0)>30)return'<span class="json-cmt">[depth limit]</span>';s=s||"";let n=t.tagName.toLowerCase(),o="";o=this.fmtAttrs(t);let r=Array.from(t.childNodes),l=this.getShadowRoot(t),a=l&&Array.from(l.root.childNodes).some(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),c=l&&(a||l.mode&&"closed"===l.mode),d=r.some(t=>1===t.nodeType)||r.filter(t=>3===t.nodeType&&t.textContent.trim()).length>0||!!c,h=this.expandedTreePaths.has(s),p=this._treeNodeOpen(h,"data-tree-path",s);if(p+=d?this.treeToggleHtml():'<span class="tree-spacer"></span>',e&&(p+='<span class="json-key">'+this.escapeHtml(e)+":</span> "),p+='<span class="tree-label json-boolean"><'+n+o+"></span>",d){if(p+='<span class="tree-ellipsis">...</span>',h){p+='<div class="tree-children">';let t=r.filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim());if(p+=this.renderDomChildrenLazy(t,(t,e,i)=>this.renderHTMLTree(t,"",s+"."+e,i),i,"html",{path:s}),c)if(this.expandedTreePaths.has(s+".shadow")){let t=Array.from(l.root.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim());p+=this._treeShadowNode(!0,"data-tree-path",s+".shadow",l.mode,this.renderDomChildrenLazy(t,(t,e,i)=>this.renderHTMLTree(t,"",s+".shadow."+e,i),i,"html-shadow",{shadowInfo:l,path:s}),'data-shadow-root="1"')}else p+=this.buildShadowLazy(l,"html",s,i);p+="</div>"}else{let t=r.filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),e=this.treeNodeRegId++;p+=this._treeNodeChildrenLazy(e,{type:"html",children:t,path:s,depth:i,shadow:c?l:null})}p+='<span class="tree-label json-boolean tree-close-tag"></'+n+"></span>"}else p+='<span class="tree-label json-boolean tree-close-tag"></'+n+"></span>";return p+="</div>",p}renderElementsView(){if(!this.elementsTree)return;let t=document.documentElement;this.elRefMap=new Map,this.elRefId=0;let e=this.renderElementTree(t,0);this.elementsTree.innerHTML=e,this.pendingHighlight?this.expandToElement(this.pendingHighlight):this.selectedElement&&this.restoreElementSelection()}restoreElementSelection(){if(!this.selectedElement||!this.elementsTree)return;let t=null;for(let[e,s]of this.elRefMap)if(s===this.selectedElement){t=e;break}if(null===t)return;let e=this.elementsTree.querySelector('.tree-node[data-el-id="'+t+'"]');if(!e)return;let s=e;for(;s&&s!==this.elementsTree;)s.classList.contains("tree-node")&&(s.classList.remove("collapsed"),s.classList.add("expanded"),s.dataset.elId&&this.elRefMap&&this.elRefMap.get(parseInt(s.dataset.elId))&&this.expandedElements.add(this.elRefMap.get(parseInt(s.dataset.elId)))),s=s.parentElement;this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),e.classList.add("el-selected"),e.classList.add("el-highlight"),requestAnimationFrame(()=>{e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>e.classList.remove("el-highlight"),3e3)})}renderElementTree(t,e){if(t.nodeType&&3===t.nodeType){let e=t.textContent.trim();return e?'<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-cmt">'+this.escapeHtml(e)+"</span></div>":""}if(1!==t.nodeType)return"";let s=t.tagName.toLowerCase(),i="";i=this.fmtAttrs(t);let n=Array.from(t.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),o=this.getShadowRoot(t),r=o&&Array.from(o.root.childNodes).some(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),l=o&&(r||o.mode&&"closed"===o.mode),a=n.length>0||!!l,c=0===e||this.expandedElements.has(t),d=++this.elRefId;this.elRefMap.set(d,t);let h=this._treeNodeOpen(c,"data-el-id",d);if(h+=a?this.treeToggleHtml():'<span class="tree-spacer"></span>',h+='<span class="tree-label json-boolean"><'+s+i+"></span>",a){if(h+='<span class="tree-ellipsis">...</span>',c){if(h+='<div class="tree-children">',h+=this.renderDomChildrenLazy(n,(t,e,s)=>this.renderElementTree(t,s),e,"element",{}),l)if(this.expandedElements.has(o.root)||0===e){let t=Array.from(o.root.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),s=++this.elRefId;this.elRefMap.set(s,o.root),h+=this._treeShadowNode(!0,"data-el-id",s,o.mode,this.renderDomChildrenLazy(t,(t,e,s)=>this.renderElementTree(t,s),e,"element-shadow",{}),'data-shadow-host="'+d+'"')}else h+=this.buildShadowLazy(o,"element",null,e,d);h+="</div>"}else{let t=this.treeNodeRegId++;h+=this._treeNodeChildrenLazy(t,{type:"element",children:n,depth:e,shadow:l?o:null,elId:d})}h+='<span class="tree-label json-boolean tree-close-tag"></'+s+"></span>"}else h+='<span class="tree-label json-boolean tree-close-tag"></'+s+"></span>";return h+="</div>",h}startElementPicker(){this.elementPickBtn&&this.elementPickBtn.classList.add("active"),this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose");let t=document.createElement("div");t.className="element-picker-overlay",t.style.pointerEvents="none";let e=!1,s=n=>{if(e)return;e=!0,n.preventDefault(),n.stopPropagation();let o=n.target;t.remove(),document.removeEventListener("click",s,!0),document.removeEventListener("keydown",i,!0),this.pendingHighlight=o,this.switchTab("elements"),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this.elementPickBtn&&this.elementPickBtn.classList.remove("active")},i=n=>{"Escape"!==n.key||e||(e=!0,t.remove(),document.removeEventListener("click",s,!0),document.removeEventListener("keydown",i,!0),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this.elementPickBtn&&this.elementPickBtn.classList.remove("active"))};document.body.appendChild(t),setTimeout(()=>{document.addEventListener("click",s,!0),document.addEventListener("keydown",i,!0)},200)}expandToElement(t){if(!t||!this.elementsTree)return;this.pendingHighlight=null,this.selectedElement=t;let e=[],s=t;for(;s&&s!==document.documentElement&&s!==document;)e.unshift(s),s=s.parentNode;for(let t of e){let e=null;for(let[s,i]of this.elRefMap)if(i===t){e=s;break}if(null===e)continue;let s=this.elementsTree.querySelector('.tree-node[data-el-id="'+e+'"]');if(!s||!s.classList.contains("collapsed"))continue;s.classList.remove("collapsed"),s.classList.add("expanded");let i=this.elRefMap.get(parseInt(s.dataset.elId));i&&this.expandedElements.add(i);let n=s.querySelector(":scope > .tree-children[data-lazy-id]");if(n){let t=parseInt(n.dataset.lazyId),e=this.treeNodeRegistry.get(t);if(e){let s="";"element"===e.type?(s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element",{}),e.shadow&&(s+=this.buildShadowLazy(e.shadow,"element",null,e.depth||0,e.elId))):"element-shadow"===e.type&&(s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element-shadow",{})),n.innerHTML=s,delete n.dataset.lazyId,this.treeNodeRegistry.delete(t)}}}let i=null;for(let[e,s]of this.elRefMap)if(s===t){i=e;break}if(null===i)return;let n=this.elementsTree.querySelector('.tree-node[data-el-id="'+i+'"]');n&&(this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),n.classList.add("el-selected"),n.classList.add("el-highlight"),requestAnimationFrame(()=>{n.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>n.classList.remove("el-highlight"),3e3)}))}serializeNodeWithShadow(t){if(t instanceof ShadowRoot||t instanceof DocumentFragment)return Array.from(t.childNodes).map(t=>this.serializeNodeWithShadow(t)).join("");if(1===t.nodeType){let e=t.tagName.toLowerCase(),s="";for(let e of t.attributes)s+=null!=e.value&&void 0!==e.value?" "+e.name+'="'+this.escapeHtml(e.value)+'"':" "+e.name;let i=this.getShadowRoot(t),n="";return i&&(n+="\x3c!-- #shadow("+i.mode+") --\x3e",n+=Array.from(i.root.childNodes).map(t=>this.serializeNodeWithShadow(t)).join("")),n+=Array.from(t.childNodes).map(t=>this.serializeNodeWithShadow(t)).join(""),["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(e)?"<"+e+s+">":"<"+e+s+">"+n+"</"+e+">"}return 3===t.nodeType?t.textContent:8===t.nodeType?"\x3c!--"+t.textContent+"--\x3e":""}copyElementHTML(t){let e=this.serializeNodeWithShadow(t);navigator.clipboard?navigator.clipboard.writeText(e).then(()=>this.showNotification("已复制元素")).catch(()=>this.fallbackCopy(e)):this.fallbackCopy(e)}fallbackCopy(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();try{document.execCommand("copy"),this.showNotification("已复制元素")}catch(e){this.showNotification("复制失败","warning")}e.remove()}deleteElement(t){if(t)if(null!==this.selectedShadowHostId){let t=this.elRefMap.get(this.selectedShadowHostId);if(t){let e=this.getShadowRoot(t);if(e){if("closed"===e.mode)return void this.showNotification("无法删除closed模式的ShadowDOM","warning");try{for(t.shadowRoot&&(t.shadowRoot.innerHTML="");e.root.firstChild;)e.root.removeChild(e.root.lastChild)}catch{}this.selectedElement=null,this.selectedShadowHostId=null,this.showNotification("ShadowDOM已删除"),this.renderElementsView()}else this.showNotification("ShadowDOM已不存在","warning")}else this.showNotification("无法删除此元素","warning")}else t.parentNode?(t.parentNode.removeChild(t),this.showNotification("元素已删除"),this.selectedElement===t&&(this.selectedElement=null),this.renderElementsView()):t.parentElement?(t.parentElement.removeChild(t),this.showNotification("元素已删除"),this.selectedElement===t&&(this.selectedElement=null),this.renderElementsView()):this.showNotification("无法删除此元素","warning")}renderTableHTML(t,e){if(!t||"object"!=typeof t)return`<div class="console-table-wrap"><span class="json-cmt">非表格数据: ${this.escapeHtml(String(t))}</span></div>`;let s,i;s=Array.isArray(t)?t.map((t,e)=>{let s={"(idx)":e};return t&&"object"==typeof t?Object.assign(s,t):s.value=t,s}):Object.entries(t).map(([t,e])=>{let s={"(idx)":t};return e&&"object"==typeof e?Object.assign(s,e):s.value=e,s});let n=new Set;s.forEach(t=>Object.keys(t).forEach(t=>n.add(t))),i=["(idx)",...Array.from(n).filter(t=>"(idx)"!==t)],e&&Array.isArray(e)&&e.length&&(i=["(idx)",...e.filter(t=>"(idx)"!==t)]);let o=t=>{if(void 0===t)return"";if(null===t)return'<span class="json-null">null</span>';if("string"==typeof t)return`<span class="json-string">"${this.escapeHtml(t.substring(0,100))}"</span>`;if("number"==typeof t)return`<span class="json-number">${t}</span>`;if("boolean"==typeof t)return`<span class="json-boolean">${t}</span>`;if("function"==typeof t)return this.isClass(t)?`<span class="json-boolean">[Class ${t.name||"anonymous"}]</span>`:`<span class="json-boolean">ƒ ${t.name||"anonymous"}</span>`;if("object"==typeof t)try{let e=this.safeStringify(t);return`<span class="json-cmt">${this.escapeHtml(e.length>50?e.substring(0,50)+"…":e)}</span>`}catch{return'<span class="json-cmt">{Object}</span>'}return this.escapeHtml(String(t))},r='<div class="console-table-wrap"><table class="console-table"><thead><tr>';return i.forEach(t=>r+=`<th>${this.escapeHtml(String(t))}</th>`),r+="</tr></thead><tbody>",s.forEach(t=>{r+="<tr>",i.forEach(e=>r+=`<td>${o(t[e])}</td>`),r+="</tr>"}),r+="</tbody></table></div>",r}renderLogItemHTML(t,e){if(t.subType){let e="table",s=t.timestamp.toLocaleTimeString(),i=this.renderSubTypeContent(t);return`<div class="log-item ${t.type}${this.selectedLogId===t.id?" selected":""}" id="log-item-${t.id}"><div class="log-header">${t.count>1?`<div class="log-count">${t.count}</div>`:""}<div class="log-icon">${this.icon(e)}</div><div class="timestamp">${s}</div></div><div class="log-content">${i}</div></div>`}let s;switch(t.type){case"info":s="info-circle";break;case"warn":s="exclamation-triangle";break;case"error":s="times-circle";break;default:s="info"}let i=t.timestamp.toLocaleTimeString(),n=t.expandedJson?this.formatArgs(t.args,t.id):this.renderLogContent(t);return`<div class="log-item ${t.type}${this.selectedLogId===t.id?" selected":""}" id="log-item-${t.id}"><div class="log-header">${t.count>1?`<div class="log-count">${t.count}</div>`:""}<div class="log-icon">${this.icon(s)}</div><div class="timestamp">${i}</div></div><div class="log-content">${n}</div>${t.hasObject?`<div class="log-actions"><div class="log-action expand-btn" title="${t.expandedJson?"收起":"展开"}" onclick="thinConsole.tC.toggleExpandJson(${t.id})">${this.icon(t.expandedJson?"chevron-up":"chevron-down")}${t.expandedJson?"收起":"展开"}</div></div>`:""}</div>`}renderLSItemHTML(t,e){let s=this.escapeHtml(t),{displayValue:i,valueType:n,isJSON:o}=this.parseAndTypeCheck(e),r=o?this.highlightJson(i):this.escapeHtml(i),l="";if(o){let t=JSON.parse(e);l=`<div class="ls-value json-tree-container">${this.renderJSONValue(t,"")}</div>`}else l=`<div class="ls-value" title="${this.escapeHtml(i)}"><span class="json-${n}">${"string"===n?'"':""}${r}${"string"===n?'"':""}</span></div>`;return`<div class="ls-item" data-key="${s}"><div class="ls-key-row"><div class="ls-key" title="${s}">${s}</div><div class="ls-actions"><button class="ls-action-btn" data-action="edit" data-key="${s}" title="编辑">${this.icon("edit")}</button><button class="ls-action-btn" data-action="copy" data-key="${s}" title="复制">${this.icon("copy")}</button><button class="ls-action-btn" data-action="remove" data-key="${s}" title="删除">${this.icon("trash")}</button></div></div>${l}<div class="ls-value-type" title="${n}">类型:${n}</div></div>`}toggleSearch(t){let e=void 0!==t?t:!this.searchExpanded;this.searchExpanded=e,this.searchBar&&(this.searchBar.style.display=e?"flex":"none"),e&&this.searchInput?this.searchInput.focus():e||(this.searchQuery="",this.searchInput&&(this.searchInput.value=""),this.renderContent())}onAddLSClick(){this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!0,mode:"ls",key:"",oldKey:"",value:""},this.updateEditorVisibility(),this.lsEditorKeyInput&&(this.lsEditorKeyInput.value="",this.lsEditorKeyInput.focus())}openLSEditor(t){if(this.netSending||this.netNewVisible)return void this.showNotification("正在发送请求,无法保存键值","warning");let e=this.activeLSFilter||"local",s=this.storage[e].get(t)||"";this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!0,mode:"ls",key:t,oldKey:t,value:s},this.updateEditorVisibility(),this.lsEditorInput&&this.lsEditorInput.focus()}closeLSEditor(){this.editorState.visible=!1,this.editorState.value="",this.updateEditorVisibility()}onEditorSave(){"code"===this.editorState.mode?this.runCode():this.saveLSFromEditor()}saveLSFromEditor(){if(this.netSending||this.netNewVisible)return void this.showNotification("正在发送请求,无法保存键值","warning");let t,e=this.lsEditorKeyInput?this.lsEditorKeyInput.value.trim():this.editorState.key,s=this.editorState.oldKey,i=this.lsEditorInput?this.lsEditorInput.value:this.editorState.value;if(!e)return void this.showNotification("键名不能为空","warning");try{t=JSON.stringify(JSON.parse(this.fixKeysOnly(i)))}catch{t=i}let n=this.activeLSFilter||"local",o=this.storage[n];if("cookie"===n)return o.set(e,t),this.closeLSEditor(),this.renderLocalStorage(),void this.showNotification('已保存Cookie"'+e+'"');if(s&&s!==e){if(null!==o.get(e))return void this.showNotification('键名"'+e+'"已存在!',"warning");o.remove(s)}else if(!s&&null!==o.get(e))return void this.showNotification('键名"'+e+'"已存在!',"warning");o.set(e,t),this.closeLSEditor(),this.renderLocalStorage(),this.showNotification('已保存键"'+e+'"')}onTitleClick(){this.netSending||this.netNewVisible?this.showNotification("正在发送请求,无法运行代码","warning"):this.editorState.visible&&"ls"===this.editorState.mode?this.showNotification("正在保存键值,无法运行代码","warning"):(this.editorState.visible=!0,this.editorState.mode="code",this.updateEditorVisibility(),this.lsEditorInput&&this.lsEditorInput.focus())}toggleMute(){let t="console",e=this.activeFilter||"all";this.mutedFilters[t]||(this.mutedFilters[t]={}),this.mutedFilters[t][e]=!this.mutedFilters[t][e];let s=this.mutedFilters[t][e],i="all"===e?"所有日志":e+"类型日志";this.showNotification(s?i+"已屏蔽":i+"已恢复",s?"warning":""),this.updateMuteBtnState()}updateMuteBtnState(){if(!this.muteBtn)return;let t="console",e=this.activeFilter||"all";this.mutedFilters[t]&&this.mutedFilters[t][e]?(this.muteBtn.classList.add("muted"),this.muteBtn.title="恢复日志"):(this.muteBtn.classList.remove("muted"),this.muteBtn.title="屏蔽"+("all"===e?"后续日志":e+"类型日志"))}runCode(){let t=this.lsEditorInput?this.lsEditorInput.value:"";if(t.trim())try{let e=window.eval(t);console.log(t+"\n> ",e),this.showNotification("代码已执行"),this.closeLSEditor()}catch(e){console.error(t+"\n> 执行失败:"+e),this.showNotification("代码执行失败","warning"),this.closeLSEditor()}}setupGestures(){if(!this.contentArea||!this.consoleHeader)return;let t=this.contentArea,e=this.consoleHeader,s=null,i=0,n=0,o=0,r=0,l=!1,a=null,c=0,d=0,h=0,p=!1,u=()=>{let t=this.overlay.querySelectorAll(".tab-btn");return Array.from(t).map(t=>t.dataset.tab)},g=()=>{if("console"===this.currentTab)return["all","log","info","warn","error"];if("network"===this.currentTab)return["all","get","post","put","success","failed"];if("localstorage"===this.currentTab)return["local","session","cookie"];let t=this.pluginViewContainers[this.currentTab];return t&&t.querySelectorAll(".filter-btn").length>1?Array.from(t.querySelectorAll(".filter-btn")).map(t=>t.dataset.type||t.dataset.filter||t.textContent.trim()):null},f=t=>{let e=u(),s=e.indexOf(this.currentTab),i=g();if(i)if("localstorage"===this.currentTab){let e=i.indexOf(this.activeLSFilter||"local")+t;if(e>=0&&e<i.length){this.activeLSFilter=i[e],this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>t.classList.toggle("active",t.dataset.lsType===this.activeLSFilter)),this.renderContent();let t=this.lsFiltersContainer&&this.lsFiltersContainer.querySelector('.filter-btn[data-ls-type="'+this.activeLSFilter+'"]');return void this.scrollFilterIntoView(this.lsFiltersContainer,t)}}else if("console"===this.currentTab){let e=i.indexOf(this.activeFilter||"all")+t;if(e>=0&&e<i.length)return this.activeFilter=i[e],this.filterButtons.forEach(t=>t.classList.toggle("active",t.dataset.type===this.activeFilter)),this.updateFilterCounts(),this.renderContent(),void this.scrollFilterIntoView(this.filtersContainerEl,this.filterButtons[e])}else{if("network"!==this.currentTab){let e=this.pluginViewContainers[this.currentTab];if(e){this.enhanceFilterContainers(e);let s=e.querySelectorAll(".filter-btn");if(s.length>1){let e=-1;s.forEach((t,s)=>{t.classList.contains("active")&&(e=s)});let i=e+t;i>=0&&i<s.length&&(s.forEach(t=>t.classList.remove("active")),s[i].classList.add("active"),s[i].click(),this.scrollFilterIntoView(s[i].parentElement,s[i]))}}return}{let e=i.indexOf(this.activeNetFilter||"all")+t;if(e>=0&&e<i.length){this.activeNetFilter=i[e],this.netFiltersEl&&this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(t=>t.classList.toggle("active",t.dataset.netFilter===this.activeNetFilter)),this.renderNetworkList(),this.updateNetDisableBtn(),this.updateNetFilterCounts();let t=this.netFiltersEl&&this.netFiltersEl.querySelector('.net-filter-btn[data-net-filter="'+this.activeNetFilter+'"]');return void this.scrollFilterIntoView(this.netFiltersEl,t)}}}let n=s+t;if(n>=0&&n<e.length){let t=e[n];"console"===t?(this.activeFilter="all",this.filterButtons&&this.filterButtons.forEach(t=>t.classList.toggle("active","all"===t.dataset.type))):"localstorage"===t&&(this.activeLSFilter="local",this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>t.classList.toggle("active","local"===t.dataset.lsType)));let s=this.overlay.querySelector(`.tab-btn[data-tab="${t}"]`);s&&s.click()}};t.addEventListener("touchstart",t=>{if(1!==t.touches.length)return;if(this.editorState.visible)return;let e=t.target.closest(".json-tree-container,.json-preview,.log-content,.console-table-wrap,.system-log-content,.ls-value,.object-preview,.error-stack,.function-preview,.elements-tree,.filters,.network-filters");e&&(e.matches(".filters,.network-filters")||e.scrollWidth>e.clientWidth)?s=null:(s=t.touches[0],i=s.clientX,n=s.clientY,o=0,r=0,l=!1)},{passive:!0}),t.addEventListener("touchmove",t=>{if(!s||1!==t.touches.length)return;let e=t.touches[0];o=e.clientX-i,r=e.clientY-n,!l&&Math.abs(o)>15&&Math.abs(o)>1.5*Math.abs(r)&&(l=!0),l&&t.preventDefault()},{passive:!1}),t.addEventListener("touchend",()=>{if(s){if(l){let t=60;o<-t?f(1):o>t&&f(-1)}s=null,l=!1}}),e.addEventListener("touchstart",t=>{window.innerWidth>768||1===t.touches.length&&(a=t.touches[0],c=a.clientX,d=a.clientY,h=0,p=!1)},{passive:!0}),e.addEventListener("touchmove",t=>{if(window.innerWidth>768)return;if(!a||1!==t.touches.length)return;let e=t.touches[0];if(h=e.clientY-d,!p&&h>15&&h>1.5*Math.abs(e.clientX-c)&&(p=!0),p){t.preventDefault();let e=this.overlay.querySelector(".console-container");e&&(e.style.transition="none",e.style.transform=`translateY(${h}px)`)}},{passive:!1}),e.addEventListener("touchend",()=>{if(!(window.innerWidth>768)&&a){if(p){let t=this.overlay.querySelector(".console-container");h>80?(t&&(t.style.transition="transform .3s ease",t.style.transform="translateY(100%)"),setTimeout(()=>{this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),t&&(t.style.transition="",t.style.transform=""),this.triggerGlobalHook("afterClose")},300)):t&&(t.style.transition="transform .25s ease",t.style.transform="")}a=null,p=!1}})}updateFilterShadow(t){if(!t)return;let e=t.scrollWidth-t.clientWidth>1;t.classList.toggle("overflow-start",e&&t.scrollLeft>1),t.classList.toggle("overflow-end",e&&t.scrollLeft+t.clientWidth<t.scrollWidth-1)}setupFilterShadow(t){if(!t||t._tcFilterShadow)return;t._tcFilterShadow=!0,t.classList.add("overflow-scroll");let e=()=>this.updateFilterShadow(t);if(t.addEventListener("scroll",e,{passive:!0}),window.ResizeObserver){let s=new ResizeObserver(e);s.observe(t),t._tcFilterRO=s,t.setAttribute("data-filter-ro","1")}if(window.MutationObserver){let s=new MutationObserver(e);s.observe(t,{childList:!0,subtree:!0}),t._tcFilterMO=s}e()}scrollFilterIntoView(t,e){if(!t||!e)return;if(t.scrollWidth<=t.clientWidth)return void this.updateFilterShadow(t);let s=e.offsetLeft-(t.clientWidth-e.offsetWidth)/2;s=Math.max(0,Math.min(s,t.scrollWidth-t.clientWidth));try{t.scrollTo({left:s,behavior:"smooth"})}catch(t){}t.scrollLeft!==s&&(t.scrollLeft=s),this.updateFilterShadow(t),setTimeout(()=>this.updateFilterShadow(t),300)}enhanceFilterContainers(t){if(!t)return;let e=new Map;t.querySelectorAll(".filter-btn").forEach(t=>{let s=t.parentElement;s&&!s.dataset.tcFilterEnhanced&&(e.has(s)||e.set(s,[]),e.get(s).push(t))}),e.forEach((t,e)=>{if(t.length>1){e.classList.contains("filters")||e.classList.contains("network-filters")||e.classList.add("filters"),e.dataset.tcFilterEnhanced="1",this.setupFilterShadow(e);let s=e;t.forEach(t=>{t.dataset.orig||(t.dataset.orig=t.textContent.trim()),t.addEventListener("click",()=>this.scrollFilterIntoView(s,t))})}})}_fmtCount(n,p){if(n<1e3)return{filterCount:n,exactCount:n};let k=n/1e3;if(n>=1e5)return{filterCount:Math.floor(k)+"K+",exactCount:n};let s=Math.round(10*k)/10;return{filterCount:(Number.isInteger(s)?s:s.toFixed(1))+"K"+(p?"+":""),exactCount:n}}_updateFilterBtns(t,e,s,i){t&&t.querySelectorAll(".filter-btn, .net-filter-btn").forEach(t=>{let n=t.dataset[s],o=e[n]||0,r=t.classList.contains("active");t.innerHTML=i(t,o,r)})}updateFilterCounts(){this.filterButtons&&(this._updateFilterRaf||(this._updateFilterRaf=requestAnimationFrame(()=>{this._updateFilterRaf=null;let t=[];"console"===this.currentTab&&(t=this.logs);let e=(t,e)=>t.reduce((t,s)=>s.type===e?t+(s.count||1):t,0),s={all:t.reduce((t,e)=>t+(e.count||1),0),log:e(t,"log"),info:e(t,"info"),warn:e(t,"warn"),error:e(t,"error")};this._updateFilterCounts(this.filterButtons,s,!1)})))}_updateFilterCounts(e,t,s){e&&(s?e.querySelectorAll(".filter-btn[data-orig]"):e).forEach(i=>{let a,n=s?i.dataset.orig:i.dataset.type,o=t[i.dataset.type||i.dataset.filter||n]||0,r=i.classList.contains("active");a="object"==typeof o&&null!==o?o:this._fmtCount(o,!1),s?i.innerHTML=(i.dataset.icon?this.icon(i.dataset.icon)+" ":"")+n+(r?" ("+a.filterCount+")":""):(i.dataset.originalHtml||(i.dataset.originalHtml=i.innerHTML),i.innerHTML=r?`${i.dataset.originalHtml} (${a.filterCount})`:i.dataset.originalHtml),i.title=r&&void 0!==a.exactCount?""+a.exactCount:""})}renderContent(){if(this.triggerGlobalHook("beforeRender",this.currentTab),this.updateControlsVisibility(),this.updateMuteBtnState(),this.consoleOutput.style.display="none",this.localstorageView.style.display="none",this.elementsView.style.display="none",this.networkView&&(this.networkView.style.display="none"),this.netDetailOverlay&&(this.netDetailOverlay.style.display="none"),this.netNewOverlay&&(this.netNewOverlay.style.display=this.netNewVisible?"flex":"none"),this.clearLogsBtn.style.display="none",this._elementObserver&&this.stopElementObserver&&this.stopElementObserver(),Object.values(this.pluginViewContainers).forEach(t=>{t.style.display="none"}),["console","network","localstorage","elements"].includes(this.currentTab))switch(this.clearLogsBtn.style.display="block",this.currentTab){case"console":this.consoleOutput.style.display="block",this.renderLogList(this.logs,!1),this.updateFilterCounts();break;case"network":this.clearLogsBtn.style.display="block",this.networkView&&(this.networkView.style.display="flex"),this.renderNetworkPanel();break;case"localstorage":this.localstorageView.style.display="block",this.renderLocalStorage();break;case"elements":this.clearLogsBtn.style.display="none",this.elementsView.style.display="block",this.renderElementsView(),this.startElementObserver()}else if(this.pluginViewContainers[this.currentTab]){this.consoleControls.style.display="none";let t=this.pluginViewContainers[this.currentTab];t.style.display="block";let e=Object.keys(this.pluginTabs).find(t=>this.pluginTabs[t].id===this.currentTab);if(e){let s=this.plugins[e];s&&"function"==typeof s.onShow&&s.onShow(),s&&"function"==typeof s.render&&s.render(t),this.enhanceFilterContainers(t)}else{let t=this.pluginTabs[this.currentTab];t&&"function"==typeof t.onShow&&t.onShow()}}this.triggerGlobalHook("afterRender",this.currentTab)}renderLogList(t,e){let s=this.consoleOutput,i="日志记录";if(!s)return;if(0===t.length)return void this.vsUpdate(s,[],null,0,{emptyHTML:`<div class="nolog">${this.icon("info-circle")}无${i}</div>`});let n=[...t];if(this.activeFilter&&"all"!==this.activeFilter&&(n=n.filter(t=>t.type===this.activeFilter)),this.searchQuery){let t,e=this.searchQuery.trim(),s=!1;if(e.startsWith("/")&&e.endsWith("/"))try{let i=e.slice(1,-1),n=i.lastIndexOf("/"),o="";n>0?(o=i.slice(n+1),t=new RegExp(i.slice(0,n),o)):t=new RegExp(i),s=!0}catch{this.showNotification("无效的正则表达式:"+e),s=!1}let i=s?e:e.toLowerCase();n=n.filter(e=>e.args.some(e=>{let n;return n=e instanceof Error?"[error]":null==e?"null":void 0===e?"undefined":"object"==typeof e?'<span class="json-cmt">{Object}</span>':String(e),s&&t?t.test(n):n.toLowerCase().includes(i.toLowerCase())}))}0!==n.length?this.vsUpdate(s,n,t=>this.renderLogItemHTML(t,e),80):this.vsUpdate(s,[],null,0,{emptyHTML:`<div class="nolog">${this.icon("search")}无匹配的${i}</div>`})}getParams(t){let e=t.toString(),s=t=>{let e=t.indexOf("(");if(-1===e)return"";let s=1,i=e+1;for(;i<t.length;i++)if("("===t[i])s++;else if(")"===t[i]&&0===--s)break;return t.slice(e+1,i).replace(/\s+/g,"")};if(/^\s*(?:class|function|async\s+function)/.test(e))return s(e);let i=e.indexOf("=>"),n=e.indexOf("{");if(i>0&&(-1===n||i<n)){let t=e.slice(0,i).trim().replace(/^async\s+/,"");if(t.startsWith("(")){let e=1,s=1;for(;s<t.length&&e>0;s++)"("===t[s]?e++:")"===t[s]&&e--;return t.slice(1,s-1).replace(/\s+/g,"")}return t.replace(/\s+/g,"")}return e.indexOf("(")>0?s(e):""}renderLogContent(t){let e=[...t.args],s=t.id;if(!e.length)return"";let i=[],n=[],o=0,r=(t=>null===t?'<span class="json-null">null</span>':void 0===t?'<span class="json-null">undefined</span>':t instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(t,"",s+":html")+"</div>":t instanceof Date?t.toISOString():t instanceof Error?`<strong>${t.name}:</strong>${t.message}`:t instanceof RegExp?`<span class="json-number">${t.toString()}</span>`:"function"==typeof t?this.isClass(t)?`<span class='json-boolean'>[Class ${t.name||"anonymous"}]</span>`:this.renderFunctionCollapsed(t):t instanceof Map?`<span class="json-boolean">[Map ${t.size}]</span>`:t instanceof Set?`<span class="json-boolean">[Set ${t.size}]</span>`:t instanceof WeakMap?'<span class="json-boolean">[WeakMap]</span>':t instanceof WeakSet?'<span class="json-boolean">[WeakSet]</span>':t instanceof ArrayBuffer?`<span class="json-boolean">[ArrayBuffer ${t.byteLength} bytes]</span>`:this.fmtVal(t,s,0))(e.length>0?e[0]:"").replace(/%%/g,"").replace(/%([dfsioO%])/g,(t,s)=>{if("%"===s)return"%";if("o"===s||"O"===s)return"";let n=e[++o];if(null==n)return t;let r="d"===s||"i"===s?parseInt(n,10)||0:"f"===s?parseFloat(n)||0:String(n);return i.push(r),`{{v${i.length-1}}}`}).replace(/%c/g,()=>(n.push(String(e[++o]||"")),`{{c${n.length-1}}}`)).replace(/\x01/g,"%");i.forEach((t,e)=>r=r.replace(`{{v${e}}}`,t));let l=r.split(/{{c\d+}}/);r=l.map((t,e)=>{if(!e)return t;let s=n[e-1].replace(/"/g,"").split(/\s*;\s*/).filter(t=>t.trim()&&!/\b(position|fixed|absolute|sticky|relative|static|z-index|transform|top|left|right|bottom)\s*:/i.test(t)).join("; ");return s?`<span style="${s}">${t}</span>`:t}).join("");let a=e.slice(o+1);return r+=(r?" ":"")+a.map(t=>null===t?'<span class="json-null">null</span>':void 0===t?'<span class="json-null">undefined</span>':"function"==typeof t?this.isClass(t)?`<span class='json-boolean'>[Class ${t.name||"anonymous"}]</span>`:this.renderFunctionCollapsed(t):t instanceof Error?`<strong>${t.name}:</strong>${t.message}`:t instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(t,"",s+":r:html")+"</div>":t instanceof Date?`<span class="json-string">${t.toISOString()}</span>`:t instanceof RegExp?`<span class="json-number">${t.toString()}</span>`:t instanceof Map?`<span class="json-boolean">[Map ${t.size}]</span>`:t instanceof Set?`<span class="json-boolean">[Set ${t.size}]</span>`:t instanceof WeakMap?'<span class="json-boolean">[WeakMap]</span>':t instanceof WeakSet?'<span class="json-boolean">[WeakSet]</span>':t instanceof ArrayBuffer?`<span class="json-boolean">[ArrayBuffer ${t.byteLength} bytes]</span>`:this.fmtVal(t,s,1)).join("")}copyLog(t,e=!1,s=!1){if(s){let e=this.activeLSFilter||"local",s=this.storage[e].get(t);if(s)return navigator.clipboard.writeText(s).then(()=>this.showNotification(`已复制"${t}"的值`)).catch(t=>console.error("复制失败:",t))}let i=this.logs.find(e=>e.id===t);if(!i)return;let n="";i.count>1&&(n+=`[重复${i.count}次] `),i.args.forEach((t,e)=>{e>0&&(n+=" ");try{t instanceof HTMLElement?n+=t.outerHTML.replace(/>/g,">\n"):n+=null!==t&&"object"==typeof t?this.safeStringify(t).replace(/\\u000[23]/g,""):"function"==typeof t?this.isClass(t)?`[Class ${t.name||"anonymous"}]`:`ƒ ${t.name||"anonymous"}(${this.getParams(t)})`:null===t?"null":void 0===t?"undefined":String(t)}catch{n+="{object}"}}),navigator.clipboard.writeText(n).then(()=>this.showNotification("已复制到剪贴板")).catch(t=>console.error("复制失败:",t))}clearAllLogs(t=!1){if(this.triggerGlobalHook("beforeClear"),"network"!==this.currentTab){if(t)return this.logs=[],this.lastLog=null,this.renderContent(),void this.updateFilterCounts();if("localstorage"==this.currentTab){let t=this.activeLSFilter||"local";return void(confirm("确定要清除所有"+("local"===t?"本地存储":"session"===t?"会话存储":"Cookie")+"吗?此操作不可撤销。")&&(this.storage[t].clear(),this.renderLocalStorage()))}confirm("确定要清除所有日志吗?此操作不可撤销。")&&(this.logs=[],this.lastLog=null,this.renderContent(),this.updateFilterCounts(),this.showNotification("所有日志已清除","warning"),this.triggerGlobalHook("afterClear"))}else this.clearNetworkRequests()}updateLSFilterCounts(){if(!this.lsFiltersContainer)return;let t={local:this.storage.local.length(),session:this.storage.session.length(),cookie:this.storage.cookie.length()};this._updateFilterBtns(this.lsFiltersContainer,t,"lsType",(t,e,s)=>{let i=t.dataset.orig,n=t.dataset.icon||"",f=this._fmtCount(e,!0);return t.title=s?""+f.exactCount:"",this.icon(n)+i+(s?" ("+f.filterCount+")":"")})}renderLocalStorage(){this.updateLSFilterCounts();let t=this.activeLSFilter||"local",e=[],s="local"===t?"无本地存储":"session"===t?"无会话存储":"无Cookies",i=this.storage[t],n="local"===t?"database":"session"===t?"window-restore":"cookie-bite";if(i.length()){for(let t=0;t<i.length();t++){let s=i.key(t);null!==s&&e.push({key:s,value:i.get(s)||""})}if(e.sort((t,e)=>t.key.localeCompare(e.key,void 0,{numeric:!0,sensitivity:"base"})),this.searchQuery){let t=this.searchQuery.toLowerCase();e=e.filter(e=>e.key.toLowerCase().includes(t)||(e.value||"").toLowerCase().includes(t))}this.vsUpdate(this.lsItems,e,t=>this.renderLSItemHTML(t.key,t.value),130,{force:!0,emptyHTML:'<div class="nolog">'+this.icon("search")+"无匹配的本地存储数据</div>"})}else this.vsUpdate(this.lsItems,[],null,0,{emptyHTML:'<div class="nolog">'+this.icon(n)+s+"</div>"})}addLSItemToDOM(t,e){this.renderLocalStorage()}parseAndTypeCheck(t){try{let e=JSON.parse(t);return"object"==typeof e&&null!==e?{displayValue:this.safeStringify(e,2).replace(/</g,"<").replace(/>/g,">"),valueType:Array.isArray(e)?"array":"object",isJSON:!0}:null==e?{displayValue:null,valueType:null,isJSON:!1}:{displayValue:t,valueType:typeof e,isJSON:!1}}catch{return{displayValue:t,valueType:"string",isJSON:!1}}}isLSEmpty(){let t=this.activeLSFilter||"local";return 0===this.storage[t].length()}escapeHtml(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}addLSItem(){this.onAddLSClick()}editLSItem(t){this.openLSEditor(t)}saveLSItem(){this.onEditorSave()}fixKeysOnly(t){try{return JSON.parse(t),t}catch{return t.replace(/([{,])\s*([a-zA-Z_]\w*)\s*:/g,'$1"$2":').replace(/(":)\s*(?!true|false|null|\d+(\.\d+)?)([^\s,"{[}\]]+?)\s*(?=,|})/gs,'$1"$3"')}}cancelEditLSItem(){this.closeLSEditor()}removeLSItem(t){let e=this.activeLSFilter||"local";confirm("是否删除"+("local"===e?"本地存储":"session"===e?"会话存储":"Cookie")+'键名 "'+t+'"?')&&(this.storage[e].remove(t),this.renderLocalStorage(),this.showNotification('已删除"'+t+'"'))}findLSItem(t){return this.overlay.querySelector(`.ls-item[data-key="${t}"]`)}updateLSItemView(t){let e=this.findLSItem(t);if(!e)return;let s=this.activeLSFilter||"local",i=this.storage[s].get(t);if(null===i)return void e.remove();let{displayValue:n,valueType:o,isJSON:r}=this.parseAndTypeCheck(i),l=r?this.highlightJson(n):this.escapeHtml(n),a="";if(r){let t=JSON.parse(i);a=`<div class="ls-value json-tree-container">${this.renderJSONValue(t,"")}</div>`}else a=`<div class="ls-value" title="${this.escapeHtml(n)}"><span class="json-${o}">${"string"===o?'"':""}${l}${"string"===o?'"':""}</span></div>`;let c=this.escapeHtml(t);e.innerHTML=`<div class="ls-key-row"><div class="ls-key" title="${c}">${c}</div><div class="ls-actions"><button class="ls-action-btn" data-action="edit" data-key="${c}" title="编辑">${this.icon("edit")}</button><button class="ls-action-btn" data-action="copy" data-key="${c}" title="复制">${this.icon("copy")}</button><button class="ls-action-btn" data-action="remove" data-key="${c}" title="删除">${this.icon("trash")}</button></div></div>${a}<div class="ls-value-type" title="${o}">类型:${o}</div>`}setupGlobalEventHandlers(){this.activeFilter="all",this.searchQuery="",this.tCError=t=>{""!==t.filename||0!==t.lineno||0!==t.colno?(console.error(t.error.toString(),{"错误信息":t.message||"无信息","文件名":t.filename||"未知","位置":`${t.lineno}:${t.colno}`||"0:0","是否可信":t.isTrusted||!0,"类型":t.type||"error"}),t.preventDefault()):console.error("脚本错误")},this.tCUR=t=>{console.error("未处理的Promise异常",t.reason),t.preventDefault()},this.RSError=t=>{let e=new Set(["IMG","SCRIPT","LINK","VIDEO","AUDIO","SOURCE","TRACK"]),s=t.target;if(!e.has(s.tagName))return;let i=s.src||s.href||s.currentSrc||"[未知路径]";console.error(`[资源错误] <${s.tagName.toLowerCase()}>加载失败:${i}`)},document.addEventListener("error",this.RSError,!0),window.addEventListener("error",this.tCError),window.addEventListener("unhandledrejection",this.tCUR),window.addEventListener("resize",()=>{if(window.innerWidth<=768&&this.consoleContainer&&(this.consoleContainer.style.width="",this.consoleContainer.style.flex="",this.consoleContainer.style.transform="",this.consoleContainer.style.transition=""),window.innerWidth>768&&!window.matchMedia("(pointer:fine)").matches&&"network"===this.currentTab){let t=this.overlay.querySelector('.tab-btn[data-tab="console"]');t&&t.click()}})}setupSelfProtection(){if(this.protectInterval)return;let t=this;this.protectInterval=setInterval(()=>{window.thinConsole&&window.thinConsole.tC!==t&&(window.thinConsole.tC=t),(!this.host||!document.documentElement.contains(this.host)||!this.host.shadowRoot)&&(this.host=null,this.initShadow(),t.createButton(),t.createOverlayElement(),t.tabButtons=t.overlay.querySelectorAll(".tab-btn"),t.renderContent(),t.createStyles(),t.createNotificationElement());let e=this.shadowRoot.getElementById("thinConsole-btn");e&&e.isConnected?"flex"!==e.style.display&&(e.style.display="flex"):(t.btn=null,t.createButton());let s=this.shadowRoot.getElementById("consoleOverlay");s&&s.isConnected?"flex"!==s.style.display&&(s.style.display="flex"):(t.overlay=null,t.createOverlayElement(),t.createStyles());let i=this.shadowRoot.querySelector("style[tcstyle]");(!i||!i.innerHTML||i.innerHTML.length<100)&&t.createStyles();let n=this.shadowRoot.getElementById("notification");n&&n.isConnected?"block"!==n.style.display&&(n.style.display="block"):(t.notification=null,t.createNotificationElement());let o=t=>{if(!t||1!==t.nodeType)return;let e=t=>{"false"!==t.contentEditable&&(t.contentEditable="false",t.setAttribute("tc-lock",""),r.observe(t,{attributes:!0,attributeFilter:["contenteditable"]}))};e(t),t.querySelectorAll("*").forEach(e)},r=new MutationObserver(t=>{t.forEach(t=>{"attributes"===t.type&&"contentEditable"===t.attributeName&&"true"===t.target.contentEditable&&t.target.hasAttribute("tc-lock")&&(t.target.contentEditable="false")})});setTimeout(()=>{o(t.btn),o(t.overlay),o(t.notification),o(t.host)},0)},5e3)}disablePlugin(t){return this.disabledPlugins.includes(t)||this.disabledPlugins.push(t),this.destroyPlugin(t),this}enablePlugin(t){return this.disabledPlugins=this.disabledPlugins.filter(e=>e!==t),this.loadSinglePlugin(t),this}applyIcon(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("applyIcon: object required");for(let s in e)if(e.hasOwnProperty(s)){if("string"!=typeof e[s]||-1===e[s].indexOf("|"))throw new Error("图标"+s+"格式错误,必须是viewBox|path.d格式");t[s]=e[s]}}setFilterIcon(e,s){let i=this.overlay.querySelector('[data-type="'+e+'"],[data-ls-type="'+e+'"],[data-orig="'+e+'"],[data-net-filter="'+e+'"]');if(!i)return!1;if(!t[s])throw new Error("图标"+s+"不存在");i.dataset.icon=s;let n=i.dataset.orig||i.dataset.type||i.dataset.lsType||i.dataset.netFilter||"",o=i.classList.contains("active");return i.innerHTML=this.icon(s)+" "+n+(o?" (0)":""),!0}createSandbox(t){let e=this;return new Proxy(t,{get(s,i){if("options"!==i&&"pluginOption"!==i){if("__isSandbox"===i)return!0;if("string"==typeof i&&i in s){let t=s[i];return"function"==typeof t?t.bind(e):t}return s[i]}},set:(t,s)=>("options"===s||"pluginOption"===s||console.warn(`[thinConsole] 插件沙箱阻止了修改属性: ${String(s)}`),!0),deleteProperty:(t,s)=>"options"!==s&&"pluginOption"!==s&&(delete t[s],!0)})}loadSinglePlugin(t){if(!this.disabledPlugins.includes(t)&&e.plugins[t]&&!this.plugins[t]){try{let i=new(0,e.plugins[t])(this.createSandbox(this));if(i.pluginOption="object"!=typeof this.options.pluginOption[t]||Array.isArray(this.options.pluginOption[t])||null===this.options.pluginOption[t]?{}:this.options.pluginOption[t],i.init(),this.plugins[t]=i,i.addTab){let e=i.addTab();this.createPluginTab(e),this.pluginTabs[t]={id:e.id,name:e.name,icon:e.icon||"plug",plugin:i}}this.triggerGlobalHook("pluginMount",t,i)}catch(e){console.error(`插件"${t}"加载失败:`,e)}return this}}applyCSS(e){let t=document.createElement("style");return t.textContent=e,this.shadowRoot.appendChild(t),t}createVirtualList(t,e){this.vsInit(t);let s=e.initialData||[],i=e.itemHeight,n=e.renderItem,o=e=>"string"==typeof e?e:e.outerHTML,r=t=>o(n(t)),h=e.emptyHTML||"",k=e.trackBy;return this.vsUpdate(t,s,r,i,{force:!0,emptyHTML:h,trackBy:k}),{update:(e,s)=>{this.vsUpdate(t,e||[],s?t=>o(s(t)):r,i,{emptyHTML:h,trackBy:k})},render:()=>this.vsRender(t),destroy:()=>{t._vs&&(t.removeEventListener("scroll",t._vs.scrollHandler),delete t._vs)}}}initPlugins(){return Object.keys(e.plugins).forEach(t=>{this.disabledPlugins.includes(t)||this.loadSinglePlugin(t)}),this}destroyPlugin(t){let e=this.plugins[t];if(!e)return;"function"==typeof e.destroy&&e.destroy();let s=this.pluginTabs[t]?.id;if(s){let t=this.overlay.querySelector(`.tab-btn[data-tab="${s}"]`);t?.remove();let e=this.pluginViewContainers[s];e?.remove(),delete this.pluginViewContainers[s]}return delete this.plugins[t],delete this.pluginTabs[t],this.triggerGlobalHook("pluginUnmount",t),this}triggerGlobalHook(t,...s){return e.hooks[t]&&e.hooks[t].forEach(e=>{try{e.call(this,...s)}catch(e){console.error(`钩子"${t}"执行错误:`,e)}}),this}destroy(){e.tC===this&&(Object.assign(console,this.originalConsole),Object.keys(this.plugins).forEach(t=>this.destroyPlugin(t)),clearInterval(this.protectInterval),this.mediaQuery&&this.themeChangeHandler&&this.mediaQuery.removeEventListener("change",this.themeChangeHandler),this.timerMap&&this.timerMap.forEach(t=>clearTimeout(t.timeoutId)),this.timerMap&&this.timerMap.clear(),this._elementObserver&&this.stopElementObserver(),this._updateFilterRaf&&cancelAnimationFrame(this._updateFilterRaf),this.overlay&&this.overlay.querySelectorAll("[data-filter-ro]").forEach(t=>{t._tcFilterRO&&t._tcFilterRO.disconnect(),t._tcFilterMO&&t._tcFilterMO.disconnect()}),this.btn?.remove(),this.shadowRoot?.querySelector("style[tcstyle]")?.remove(),this.host?.remove(),this.overlay?.remove(),this.notification?.remove(),document.removeEventListener("error",this.RSError,!0),window.removeEventListener("error",this.tCError),window.removeEventListener("unhandledrejection",this.tCUR),this.originalXHR&&(window.XMLHttpRequest=this.originalXHR),this.originalFetch&&(window.fetch=this.originalFetch),e.tC=null)}setOption(t){return this.destroy(),new e(t)}startElementObserver(){this._elementObserver||(this._elementObserver=new MutationObserver(e=>this._onElementMutation(e)),this._observeAllRoots())}stopElementObserver(){this._elementObserver&&(this._elementObserver.disconnect(),this._elementObserver=null),clearTimeout(this._elementRefreshTimer)}_observeAllRoots(){if(!this._elementObserver)return;let o={childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,characterData:!0};this._elementObserver.observe(document.documentElement,o),this.closedShadowRoots.forEach(e=>{try{this._elementObserver.observe(e.root,o)}catch{}})}_onElementMutation(t){let e=new Set;for(let s of t){let t=s.target;if(this.shadowRoot&&t.getRootNode()===this.shadowRoot)continue;let i=t;for(;i;){if(this.expandedElements.has(i)){e.add(i);break}i=i.parentNode||i.host||null}}e.size>0&&(clearTimeout(this._elementRefreshTimer),this._elementRefreshTimer=setTimeout(()=>{if("elements"!==this.currentTab)return;this._observeAllRoots();let t=this.elementsTree?this.elementsTree.scrollTop:0;this._refreshMutatedNodes(e),this.elementsTree&&(this.elementsTree.scrollTop=t)},300))}_refreshMutatedNodes(e){let t=!1;for(let s of e){let i=-1;if(this.elRefMap)for(let[r,l]of this.elRefMap)if(l===s){i=r;break}if(i<0){t=!0;continue}let n=this.elementsTree?.querySelector('.tree-node[data-el-id="'+i+'"]');if(n?.classList.contains("expanded")){let r=n.querySelector(":scope > .tree-children");r&&(r.innerHTML=this.renderDomChildrenLazy(Array.from(s.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()),(t,e,s)=>this.renderElementTree(t,s),parseInt(n.dataset.depth||0)+1,"element",{}))}else t=!0}t&&this.renderElementsView()}_applyCustomThemeCSS(){let t=this.shadowRoot?.querySelector("style[data-custom-theme]");t?.remove();let s=e.themes[this.currentTheme];if(!s)return;let i=this._getThemeVars("light"),n=Object.assign({},i,s.vars),o=".theme-"+this.currentTheme+"{";for(let t in n)o+=t+":"+n[t]+";";o+="}";let r=document.createElement("style");r.setAttribute("data-custom-theme",""),r.textContent=o,this.shadowRoot?.appendChild(r)}_getThemeVars(t){let s=this.shadowRoot?.querySelector("style[tcstyle]");if(!s)return{};let i=s.textContent,n=".theme-"+t+"{",o=i.indexOf(n);if(o<0)return{};o+=n.length;let r=i.indexOf("}",o),a=i.slice(o,r),l={};return a.split(";").forEach(e=>{let t=e.indexOf(":");t>0&&(l[e.slice(0,t).trim()]=e.slice(t+1).trim())}),l}_injectHeaderButtons(){if(!e.headerButtons.length)return;let t=this.overlay.querySelector(".header-actions");if(t)for(let s of e.headerButtons){let i=document.createElement("button");i.className="header-icon-btn tc-header-btn",i.innerHTML=this.icon(s.icon),i.title=s.icon,s.fn&&i.addEventListener("click",s.fn),t.insertBefore(i,this.searchToggleBtn)}}createNetRequest(t,e){return this._netReqId=this._netReqId||1,{id:++this._netReqId,url:e||"",method:(t||"GET").toUpperCase(),status:0,statusText:"",reqHeaders:{},reqBody:null,resHeaders:{},resBody:null,startTime:Date.now(),endTime:0,duration:0,error:null}}finalizeNetRequest(t,e,s,i,n,o){t.status=e,t.statusText=s||"",t.endTime=Date.now(),t.duration=t.endTime-t.startTime,i&&(t.resHeaders=i),null!=n&&(t.resBody=n),o&&(t.error=o),"network"===this.currentTab&&this.renderNetworkList()}pushNetRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxNetwork&&this.networkRequests.splice(0,this.networkRequests.length-this.maxNetwork),"network"===this.currentTab&&this.renderNetworkList()}_isNetDisabled(t){if(0===this.netDisabledTypes.size)return!1;let e=t.toLowerCase();return this.netDisabledTypes.has("all")||this.netDisabledTypes.has(e)}captureNetworkRequests(){this.originalXHR=this.originalXHR||window.XMLHttpRequest;let t=this,e=this.originalXHR;window.XMLHttpRequest=function(){let s=new e,i=t.createNetRequest("GET",""),n=s.open;s.open=function(t,e){return i.method=t.toUpperCase(),i.url=e,n.apply(s,arguments)};let o=s.send;s.send=function(e){if(t._isNetDisabled(i.method))return;i.reqBody=e,i.startTime=Date.now();let n={...i};return t.pushNetRequest(n),s.addEventListener("loadend",function(){let e={},i=null;try{s.getAllResponseHeaders().trim().split("\n").forEach(t=>{let s=t.indexOf(":");s>0&&(e[t.slice(0,s).trim()]=t.slice(s+1).trim())})}catch(t){}try{i=s.responseText}catch(t){}t.finalizeNetRequest(n,s.status,s.statusText,e,i,null)}),s.addEventListener("error",function(){t.finalizeNetRequest(n,0,"",null,null,"Network Error")}),s.addEventListener("abort",function(){t.finalizeNetRequest(n,0,"",null,null,"Aborted")}),o.apply(s,arguments)};let r=s.setRequestHeader;return s.setRequestHeader=function(t,e){return i.reqHeaders[t]=e,r.apply(s,arguments)},s},this.originalFetch=this.originalFetch||window.fetch;let s=this.originalFetch;window.fetch=function(e,i){let n="string"==typeof e?e:e.url,o=(i&&i.method||"GET").toUpperCase();if(t._isNetDisabled(o))return Promise.reject(new Error("Request disabled by thinConsole"));let r=t.createNetRequest(o,n);return i&&i.headers&&(i.headers instanceof Headers?i.headers.forEach((t,e)=>r.reqHeaders[e]=t):"object"==typeof i.headers&&Object.assign(r.reqHeaders,i.headers)),i&&i.body&&(r.reqBody=i.body),t.pushNetRequest(r),s.apply(window,arguments).then(e=>{let s={};return e.headers.forEach((t,e)=>s[e]=t),e.clone().text().then(i=>{t.finalizeNetRequest(r,e.status,e.statusText,s,i,null)}).catch(()=>{t.finalizeNetRequest(r,e.status,e.statusText,s,null,null)}).then(()=>e)}).catch(e=>{throw"AbortError"===e.name?t.finalizeNetRequest(r,0,"",null,null,"Aborted"):t.finalizeNetRequest(r,0,"",null,null,e.message),e})}}renderNetFilters(){this.netFiltersEl&&(this.netFiltersEl.innerHTML=[{id:"all",name:"全部",icon:"list"},{id:"get",name:"获取",icon:"download"},{id:"post",name:"提交",icon:"upload"},{id:"put",name:"更新",icon:"pen"},{id:"success",name:"成功",icon:"check-circle"},{id:"failed",name:"失败",icon:"times-circle"}].map(t=>`<button class="net-filter-btn ${this.activeNetFilter===t.id?"active":""}" data-net-filter="${t.id}" data-orig="${t.name}" data-icon="${t.icon}">${this.icon(t.icon)} ${t.name}</button>`).join(""),this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(t=>{t.addEventListener("click",()=>{this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.activeNetFilter=t.dataset.netFilter,this.renderNetworkList(),this.updateNetDisableBtn(),this.scrollFilterIntoView(this.netFiltersEl,t)})}),this.updateNetFilterCounts())}updateNetFilterCounts(){if(!this.netFiltersEl)return;let t=this.networkRequests,e={all:t.length,get:t.filter(t=>"get"===t.method.toLowerCase()).length,post:t.filter(t=>"post"===t.method.toLowerCase()).length,put:t.filter(t=>"put"===t.method.toLowerCase()).length,success:t.filter(t=>t.status>=200&&t.status<400).length,failed:t.filter(t=>0===t.status||t.status>=400||t.error).length};this._updateFilterBtns(this.netFiltersEl,e,"netFilter",(t,e,s)=>{let i=t.dataset.orig,n=t.dataset.icon||"",f=this._fmtCount(e,!0);return t.title=s?""+f.exactCount:"",this.icon(n)+" "+i+(s?" ("+f.filterCount+")":"")})}updateNetDisableBtn(){if(!this.netDisableBtn)return;let t=this.activeNetFilter,e="";"all"===t?e="全部":"get"===t?e="获取":"post"===t?e="提交":"put"===t?e="更新":"success"===t?e="成功(全部)":"failed"===t&&(e="失败(全部)");let s=this.netDisabledTypes.has(t);this.netDisableBtn.innerHTML=this.icon("ban"),this.netDisableBtn.title=s?`已禁用${e}请求`:`禁用${e}请求`,this.netDisableBtn.classList.toggle("disabled",s)}toggleNetDisable(){let t=this.activeNetFilter,e="";if("all"===t?e="全部":"get"===t?e="获取":"post"===t?e="提交":"put"===t?e="更新":"success"===t?e="成功(全部)":"failed"===t&&(e="失败(全部)"),this.netDisabledTypes.has(t)){this.netDisabledTypes.delete(t);var s=!1}else this.netDisabledTypes.add(t),s=!0;this.updateNetDisableBtn(),this.showNotification(s?`已禁用${e}请求`:`已恢复${e}请求`,s?"warning":"")}getFilteredNetRequests(){let t=this.networkRequests;if(!this.activeNetFilter||"all"===this.activeNetFilter)return t;let e=this.activeNetFilter;return"get"===e||"post"===e||"put"===e?t.filter(t=>t.method.toLowerCase()===e):"success"===e?t.filter(t=>t.status>=200&&t.status<400):"failed"===e?t.filter(t=>0===t.status||t.status>=400||t.error):t}renderNetworkList(){if("network"!==this.currentTab)return;if(!this.networkItems)return;let t=this.getFilteredNetRequests();if(this.searchQuery){let e=this.searchQuery.toLowerCase();t=t.filter(t=>{if(t.url.toLowerCase().includes(e))return!0;if(t.method.toLowerCase().includes(e))return!0;try{if(this.safeStringify(t.reqHeaders).toLowerCase().includes(e))return!0}catch(t){}try{if(("string"==typeof t.reqBody?t.reqBody:this.safeStringify(t.reqBody)).toLowerCase().includes(e))return!0}catch(t){}try{if(this.safeStringify(t.resHeaders).toLowerCase().includes(e))return!0}catch(t){}return!!(t.resBody||"").toLowerCase().includes(e)})}this.updateNetFilterCounts(),0!==t.length?this.vsUpdate(this.networkItems,t,t=>this.renderNetworkItem(t),100):this.vsUpdate(this.networkItems,[],null,0,{emptyHTML:'<div class="nolog">'+this.icon("wifi")+"暂无网络请求</div>"})}renderNetworkItem(t){let e=t.status>0?Math.floor(t.status/100)+"xx":"pending",s=t.error||t.status>=400?"net-failed":t.status>=200&&t.status<400?"net-success":"",i=t.status>0?String(t.status):t.error?"ERR":"...",n=t.duration>0?t.duration+"ms":"",o=n?i+" "+n:i,r="",u=this.escapeHtml(t.url);try{r=new Date(t.startTime).toLocaleTimeString()}catch(t){r=""}return`<div class="net-item ${s}" data-req-id="${t.id}"><div class="net-row1"><span class="net-method net-method-${t.method}">${t.method}</span><span class="net-time">${this.escapeHtml(r)}</span></div><div class="net-row2"><span class="net-url" title="${u}">${u}</span><span class="net-status net-status-${e}">${this.escapeHtml(o)}</span></div><div class="net-row3"><button class="net-copy-btn" data-action="copy" title="复制请求JSON">${this.icon("copy")} 复制</button><button class="net-detail-btn" data-action="detail" title="查看详情">${this.icon("eye")} 详情</button></div></div>`}renderNetJsonTree(t,e){try{let s=JSON.parse(t);return null==s?this.highlightJson(this.escapeHtml(t)):'<div class="json-tree-container">'+this.renderJSONTree(s,"",null,null,e,0,!0)+"</div>"}catch(e){return this.highlightJson(this.escapeHtml(t))}}showNetDetail(t){let e=this.networkRequests.find(e=>e.id===t);if(!e)return;this.netDetailId=t;let s=e.status>0?Math.floor(e.status/100)+"xx":"pending",i=e.status>0?e.status+" "+(e.statusText||""):e.error||"等待中...",n=e.duration>0?e.duration+"ms":"",o=n?i+" ("+n+")":i,r="";try{r=this.safeStringify(e.reqHeaders,2,!1)}catch(t){r=String(e.reqHeaders||"")}let l=!r||"{}"===r||"null"===r,a=l?'<span class="net-detail-empty">无请求头</span>':this.renderNetJsonTree(r,"net-"+t+"-reqHeaders"),c="";if(e.reqBody)try{c="string"==typeof e.reqBody?e.reqBody:this.safeStringify(e.reqBody,2,!1)}catch(t){c=String(e.reqBody)}let d=!c||"null"===c||"undefined"===c,h=d?'<span class="net-detail-empty">无请求内容</span>':this.renderNetJsonTree(c,"net-"+t+"-reqBody"),p="";try{p=this.safeStringify(e.resHeaders,2,!1)}catch(t){p=String(e.resHeaders||"")}let u=!p||"{}"===p||"null"===p,g=u?'<span class="net-detail-empty">无响应头</span>':this.renderNetJsonTree(p,"net-"+t+"-resHeaders"),f=e.resBody||"",m="";if(f)try{m=JSON.stringify(JSON.parse(f),null,2)}catch(t){m=f}let b=!m||"null"===m||"undefined"===m,y=b?'<span class="net-detail-empty">无响应内容</span>':this.renderNetJsonTree(m,"net-"+t+"-resBody"),v=(t,e,s,i)=>`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">${t}</div>${i?"":`<button class="net-detail-copy-section" data-copy-text="${this.escapeHtml(s)}" title="复制">${this.icon("copy")}</button>`}</div><div class="${i||e.indexOf("json-tree-container")>=0?"net-detail-value":"net-detail-value net-detail-code"}">${e}</div></div>`,x=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">网址</div><button class="net-detail-copy-section" data-copy-text="${this.escapeHtml(e.url)}" title="复制网址">${this.icon("copy")}</button></div><div class="net-detail-value net-detail-code">${this.escapeHtml(e.url)}</div></div>`,w=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">类型</div></div><span class="net-method net-method-${e.method}">${e.method}</span></div>`,k=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">状态</div></div><span class="net-status net-status-${s}">${this.escapeHtml(o)}</span></div>`,S=v("请求头",a,r,l),E=v("请求内容",h,c,d),C=v("响应头",g,p,u),L=v("响应内容",y,m,b);this.netDetailBody.innerHTML=x+w+k+S+E+C+L,this.netDetailBody.querySelectorAll(".net-detail-copy-section").forEach(t=>{t.addEventListener("click",()=>{let e=t.getAttribute("data-copy-text")||"";navigator.clipboard.writeText(e).then(()=>this.showNotification("已复制")).catch(()=>{})})});let T=this.overlay.querySelector("#netResendIconBtn");T&&T.addEventListener("click",()=>this.resendRequest(e)),this.netDetailOverlay.style.display="flex"}resendRequest(t){this.netDetailOverlay.style.display="none",this.netNewOverlay.style.display="flex",this.netNewUrl.value=t.url,this.netNewMethod.value=t.method;let e="";if(t.reqBody)try{e="string"==typeof t.reqBody?t.reqBody:JSON.stringify(t.reqBody,null,2)}catch(t){e=""}this.netNewBody.value=e||"";let s="";try{t.reqHeaders&&"object"==typeof t.reqHeaders&&(s=(Array.isArray(t.reqHeaders)?t.reqHeaders:Object.entries(t.reqHeaders)).map(t=>Array.isArray(t)?t[0]+": "+t[1]:t).join("\n"))}catch(t){}this.netNewHeaders.value=s||""}sendNewRequest(){if(this.editorState.visible){let t=this.editorState.mode;if("code"===t)return void this.showNotification("正在运行代码,无法发送请求","warning");if("ls"===t)return void this.showNotification("正在保存键值,无法发送请求","warning")}let t=this.netNewUrl.value.trim();if(!t)return void this.showNotification("请输入网址","warning");let e=this.netNewMethod.value,s=this.netNewBody.value.trim(),i=this.netNewHeaders.value.trim(),n={};i&&i.split("\n").forEach(t=>{let e=t.indexOf(":");e>0&&(n[t.slice(0,e).trim()]=t.slice(e+1).trim())});let o={method:e,headers:n};if(s&&"GET"!==e&&"HEAD"!==e)try{o.body=JSON.stringify(JSON.parse(s)),n["Content-Type"]||(n["Content-Type"]="application/json")}catch(t){o.body=s}this.netSending=!0,this.netNewVisible=!1,this.netNewOverlay.style.display="none",this.showNotification("正在发送请求...");let r={id:++this._netReqId,url:t,method:e,status:0,statusText:"",reqHeaders:n,reqBody:o.body||null,resHeaders:{},resBody:null,startTime:Date.now(),endTime:0,duration:0,error:null};this.networkRequests.push(r),(this.originalFetch||window.fetch).call(window,t,o).then(t=>{this.netSending=!1,r.status=t.status,r.statusText=t.statusText,r.endTime=Date.now(),r.duration=r.endTime-r.startTime,t.clone().text().then(t=>{r.resBody=t}).catch(()=>{}),t.headers.forEach((t,e)=>r.resHeaders[e]=t),this.showNotification("请求完成: "+t.status,t.status>=400?"warning":""),"network"===this.currentTab&&this.renderNetworkList()}).catch(t=>{this.netSending=!1,r.error=t.message,r.status=0,r.endTime=Date.now(),r.duration=r.endTime-r.startTime,this.showNotification("请求失败: "+t.message,"warning"),"network"===this.currentTab&&this.renderNetworkList()})}renderNetworkPanel(){this.renderNetFilters(),this.updateNetDisableBtn(),this.renderNetworkList()}clearNetworkRequests(){let t=this.activeNetFilter||"all",e="";"all"===t?e="全部":"get"===t?e="获取":"post"===t?e="提交":"put"===t?e="更新":"success"===t?e="成功":"failed"===t&&(e="失败");let s=this.getFilteredNetRequests();if(confirm("确定要清除所有"+e+"请求吗?\n共 "+s.length+" 条请求将被删除,此操作不可撤销。")){if("all"===t)this.networkRequests=[];else{let e="get"===t||"post"===t||"put"===t?e=>e.method.toLowerCase()!==t:"success"===t?t=>!(t.status>=200&&t.status<400):t=>!(0===t.status||t.status>=400||t.error);this.networkRequests=this.networkRequests.filter(e)}this.renderNetworkList(),this.showNotification("已清空"+e+"请求")}}switchTab(t){let e=Array.from(this.tabButtons).find(e=>e.dataset.tab===t);e&&e.click()}show(t="console"){return this.overlay||this.createOverlayElement(),this.switchTab(t),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this}hide(){return this.overlay&&(this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose")),this}get storage(){let t=t=>{document.cookie=encodeURIComponent(t)+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/",document.cookie=encodeURIComponent(t)+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT"},e=(t,e,s,i,n,o)=>({get:t,set:e,remove:s,clear:i,length:n,key:o});return{local:e(t=>localStorage.getItem(t),(t,e)=>localStorage.setItem(t,e),t=>localStorage.removeItem(t),()=>localStorage.clear(),()=>localStorage.length,t=>localStorage.key(t)),session:e(t=>sessionStorage.getItem(t),(t,e)=>sessionStorage.setItem(t,e),t=>sessionStorage.removeItem(t),()=>sessionStorage.clear(),()=>sessionStorage.length,t=>sessionStorage.key(t)),cookie:e(t=>{let e=encodeURIComponent(t),s=document.cookie.match(new RegExp("(?:^|;\\s)"+e.replace(/([.*+?^${}()|[\]\\])/g,"\\$1")+"=([^;]*)"));return s?decodeURIComponent(s[1]):null},(t,e,s)=>{let i=new Date;i.setTime(i.getTime()+864e5*(s||365)),document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(e)+";expires="+i.toUTCString()+";path=/"},t,()=>{document.cookie.split(";").forEach(e=>{let s=e.split("=")[0].trim();s&&t(s)})},()=>document.cookie?document.cookie.split(";").filter(t=>t.trim()).length:0,t=>{let e=document.cookie?document.cookie.split(";").filter(t=>t.trim()):[];return e[t]?decodeURIComponent(e[t].split("=")[0]):null})}}icon(e,s){let i=String(e||"").trim();if(!i)return"";let n=t[i];if(!n)return"";let o=n.indexOf("|");return'<svg class="ico ico-'+i+(s?" "+s:"")+'" viewBox="'+n.slice(0,o)+'" aria-hidden="true"><path fill="currentColor" d="'+n.slice(o+1)+'"/></svg>'}treeToggleHtml(){return'<span class="tree-toggle">'+this.icon("angle-right")+this.icon("angle-down")+"</span>"}}e.plugins={},e.themes={},e.headerButtons=[],window.thinConsole=e,e.tC=null,e.hooks={beforeRender:[],afterRender:[],beforeLog:[],afterLog:[],beforeOpen:[],afterOpen:[],beforeClose:[],afterClose:[],beforeClear:[],afterClear:[],pluginMount:[],pluginUnmount:[]},e.addTheme=function(t,s,i){if("string"!=typeof t||!t)throw new Error("name must be string");if("string"!=typeof s)throw new Error("styles must be string");let n={};return s.split(";").forEach(e=>{let t=e.indexOf(":");t>0&&(t=e.slice(0,t).trim(),n[t]=e.slice(t+1).trim())}),e.themes[t]={vars:n,icons:i&&"object"==typeof i?i:{}},e.tC&&e.tC.overlay&&(e.tC._applyCustomThemeCSS(),e.tC.currentTheme===t&&e.tC._themeIconsApplied!==t&&(e.tC.applyIcon(e.themes[t].icons),e.tC._themeIconsApplied=t)),e},e.addHeader=function(t,s){if(e.headerButtons.length>=5)return e;if(e.headerButtons.push({icon:t,fn:s}),e.tC&&e.tC.overlay&&e.tC.searchToggleBtn){let i=e.tC.overlay.querySelector(".header-actions");if(i){let n=document.createElement("button");n.className="header-icon-btn tc-header-btn",n.innerHTML=e.tC.icon(t),n.title=t,s&&n.addEventListener("click",s),i.insertBefore(n,e.tC.searchToggleBtn)}}return e},e.setOption=function(t){return e.tC?e.tC.setOption(t):new e(t)},e.show=t=>(e.tC?.show(t),e),e.hide=()=>(e.tC?.hide(),e),e.destroy=()=>e.tC?.destroy(),e.log=(...t)=>(console.log(...t),e),e.info=(...t)=>(console.info(...t),e),e.warn=(...t)=>(console.warn(...t),e),e.error=(...t)=>(console.error(...t),e),e.addPlugin=function(t,i){if(e.tC){if(i.prototype instanceof s){if(e.plugins[t]=i,e.tC.disabledPlugins.includes(t))return;if(e.tC.pluginEnabled&&!e.tC.plugins[t])try{let s=new i(e.tC.createSandbox(e.tC));if(s.pluginOption="object"!=typeof e.tC.options.pluginOption[t]||Array.isArray(e.tC.options.pluginOption[t])||null===e.tC.options.pluginOption[t]?{}:e.tC.options.pluginOption[t],s.init(),e.tC.plugins[t]=s,s.addTab){let i=s.addTab();e.tC.pluginTabs[t]={id:i.id,name:i.name,icon:i.icon||"tool",plugin:s},e.tC.createPluginTab(i)}e.tC.triggerGlobalHook("pluginMount",t,s)}catch(i){console.error(`插件"${t}"动态加载失败:`,i)}}else{if("function"!=typeof i)throw new Error(`插件"${t}"必须是类或函数类型`);if(!e.tC.options.plugins||e.tC.disabledPlugins.includes(t))return;try{i.call(null,e.tC.createSandbox(e.tC)),e.tC.triggerGlobalHook("pluginMount",t,null)}catch(i){console.error(`函数插件"${t}"执行失败:`,i)}}return e}},e.addTabs=function(t){if(!e.tC)return e;Array.isArray(t)||(t=[t]);for(let s of t){if(e.tC.customTabCount>=5){console.warn("自定义Tab数量已达上限(5个)");break}if(!s.id||!s.name){console.warn("Tab必须包含id和name属性");continue}if(e.tC.pluginViewContainers[s.id]){console.warn("Tab ID '"+s.id+"'已存在");continue}e.tC.createPluginTab({id:s.id,name:s.name,icon:s.icon||"plug"});let t=e.tC.pluginViewContainers[s.id];t&&(t.innerHTML="","function"==typeof s.render?s.render(t):s.html&&(t.innerHTML=s.html),s.onShow&&(e.tC.pluginTabs[s.id]={id:s.id,name:s.name,icon:s.icon||"plug",onShow:s.onShow})),e.tC.customTabCount++}return e},e.addHook=function(t,s){return e.hooks[t]&&!e.hooks[t].includes(s)?e.hooks[t].push(s):console.warn(`未知钩子:${t}`),e},e.removeHook=function(t,s){return e.hooks[t]&&(e.hooks[t]=e.hooks[t].filter(t=>t!==s)),e},e.setFilterCounts=function(t){return e.tC&&e.tC._updateFilterCounts(e.tC.pluginViewContainers[e.tC.currentTab],"object"==typeof t?t:null,!0),e};class s{constructor(t){if(!(t instanceof e))throw new Error("plugin needs tC");this.tC=t,this.pluginOption={},this.id=this.constructor.name.toLowerCase()}init(){}iszh(){return!0}isen(){return!1}isMobile(){return/iPad|Android(?!.*Mobile)|Mobi|Android|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}render(t){}onShow(){}onHide(){}destroy(){}}return e.tCPlugin=s,"undefined"!=typeof window&&(window.tCPlugin=s),e});
|