planche 0.7.19 → 0.8.0

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.
Files changed (124) hide show
  1. package/THIRD-PARTY-NOTICES.md +269 -1
  2. package/app/assets/AboutDialog-CC7jb8_P.js +1 -0
  3. package/app/assets/AiSettingsDialog-1t0_9610.js +1 -0
  4. package/app/assets/BigInteger-BlV0QR66.js +1 -0
  5. package/app/assets/ConnectDialog-C8novVo3.js +1 -0
  6. package/app/assets/CopyDatabaseDialog-BZaC4BRf.js +1 -0
  7. package/app/assets/CopyTableDialog-mjYPJxx8.js +1 -0
  8. package/app/assets/CreateDatabaseDialog-K9LU6SFa.js +1 -0
  9. package/app/assets/CreateSchemaDialog-IMU6kUwh.js +1 -0
  10. package/app/assets/DataDiffDialog-DcPx4VLE.js +1 -0
  11. package/app/assets/{DownloadToCSVDialog-BC6Sq8Ce.js → DownloadToCSVDialog-cWxA73M8.js} +2 -2
  12. package/app/assets/EditSchemaDialog-UuUlGY4B.js +2 -0
  13. package/app/assets/FindReplaceDialog-BphY4fYD.js +1 -0
  14. package/app/assets/{FlushDialog-BX0F3dJQ.js → FlushDialog-C1ahiGEa.js} +1 -1
  15. package/app/assets/GeneralSettingsDialog-CSoV6bfv.js +1 -0
  16. package/app/assets/GroupByDialog-CO8in38J.js +1 -0
  17. package/app/assets/LicenseDialog-d17TldUe.js +1 -0
  18. package/app/assets/LinkColumnDialog-Dtz38QJy.js +1 -0
  19. package/app/assets/LocalHistoryDialog-B8WdxxF7.js +1 -0
  20. package/app/assets/ProcessListDialog-D0hVqOEu.js +1 -0
  21. package/app/assets/QuerySettingsDialog-C-chLD8U.js +1 -0
  22. package/app/assets/QuickCommandPalette-BhTxG9s-.js +1 -0
  23. package/app/assets/RowFormDialog-MZivb9nJ.js +2 -0
  24. package/app/assets/SafetySettingsDialog-D4p0vAK7.js +1 -0
  25. package/app/assets/SchemaDiffDialog-BIxIvBGm.js +7 -0
  26. package/app/assets/{SchemaToHTMLDialog-DjZQwEbM.js → SchemaToHTMLDialog-CalQNcBO.js} +2 -2
  27. package/app/assets/StatusDialog-C49Nlkmj.js +1 -0
  28. package/app/assets/SyncDialog-DgjppEJu.js +1 -0
  29. package/app/assets/{TermsDialog-B53To0oi.js → TermsDialog-CMGa972R.js} +1 -1
  30. package/app/assets/UserAddDialog-D_Ntb9Oc.js +1 -0
  31. package/app/assets/UserManagerDialog-BTOhBvd9.js +1 -0
  32. package/app/assets/VariablesDialog-BTVi_JEh.js +1 -0
  33. package/app/assets/app-storage-C_1RLCyI.js +1 -0
  34. package/app/assets/button-B2EsmMJs.js +1 -0
  35. package/app/assets/chevron-up-CBnVjNE1.js +1 -0
  36. package/app/assets/connection-store-BnO3WqEO.js +1 -0
  37. package/app/assets/contract-W8-jEnEI.js +1 -0
  38. package/app/assets/database-BvWJHB7q.js +1 -0
  39. package/app/assets/de-DPmJYeTi.js +2 -0
  40. package/app/assets/dialog-FBpgH0QJ.js +1 -0
  41. package/app/assets/dist-BUXw8brT.js +1 -0
  42. package/app/assets/dist-BYhFWvmC.js +41 -0
  43. package/app/assets/dist-BrzYmjQV.js +1 -0
  44. package/app/assets/dist-C2vlTGNz.js +1 -0
  45. package/app/assets/editor-registry-ukUyoekH.js +1 -0
  46. package/app/assets/{engine-CpwlM_Ww.js → engine-s5WfEr4n.js} +1 -1
  47. package/app/assets/error-hints-AQZemZKj.js +8 -0
  48. package/app/assets/fr-BLVbrMir.js +2 -0
  49. package/app/assets/hmr-singleton-Bit0Kfog.js +1 -0
  50. package/app/assets/i18n-D0mAAGED.js +2 -0
  51. package/app/assets/ja-BKUEaPbL.js +2 -0
  52. package/app/assets/ko-XOd5LtL3.js +2 -0
  53. package/app/assets/license-store-D_XwbbCs.js +1 -0
  54. package/app/assets/{main-BLydvBDF.js → main-C-Gt0g0g.js} +214 -196
  55. package/app/assets/main-C3ej0FPT.css +2 -0
  56. package/app/assets/mariadb-BT1adDMU.js +17 -0
  57. package/app/assets/mysql-BEg8tI_S.js +17 -0
  58. package/app/assets/postgresql-erqhE-5Q.js +19 -0
  59. package/app/assets/pro-gate-DZATEYdR.js +1 -0
  60. package/app/assets/pro-upsell-akqEMS8_.js +1 -0
  61. package/app/assets/pro-usage-C661VD02.js +1 -0
  62. package/app/assets/query-execution-CZvQYEUq.js +2 -0
  63. package/app/assets/query-store-dYiA8oM5.js +1 -0
  64. package/app/assets/rolldown-runtime-hePW80VL.js +1 -0
  65. package/app/assets/select-DwgCtoqv.js +1 -0
  66. package/app/assets/settings-controls-DrW8_eiX.js +1 -0
  67. package/app/assets/settings-store-BBVuUVjA.js +1 -0
  68. package/app/assets/table-copy-LtbDgIEc.js +1 -0
  69. package/app/assets/transactsql-BVCsopZt.js +16 -0
  70. package/app/assets/tunneling-BPoIRxJA.js +1 -0
  71. package/app/assets/ui-store-5IssrgmG.js +1 -0
  72. package/app/assets/{user-store-l9ZslFwK.js → user-store-DOy2VMsT.js} +1 -1
  73. package/app/assets/zh-DNy8t_lA.js +2 -0
  74. package/app/index.html +29 -20
  75. package/app/landing.css +96 -0
  76. package/app/third-party-notices.txt +269 -1
  77. package/dist/index.js +866 -54
  78. package/package.json +3 -1
  79. package/app/assets/AboutDialog-BaQAZjtT.js +0 -1
  80. package/app/assets/ConnectDialog-BmJvDi1P.js +0 -1
  81. package/app/assets/CopyDatabaseDialog-BEM-56Og.js +0 -1
  82. package/app/assets/CopyTableDialog-C2r7l2Ck.js +0 -1
  83. package/app/assets/CreateDatabaseDialog-CZhIpgiO.js +0 -1
  84. package/app/assets/CreateSchemaDialog-CNq4nZum.js +0 -1
  85. package/app/assets/DataDiffDialog-mUg2rIWn.js +0 -1
  86. package/app/assets/EditSchemaDialog-B0dCI4Lb.js +0 -2
  87. package/app/assets/FindReplaceDialog-DXJp2TN6.js +0 -1
  88. package/app/assets/GroupByDialog-BQPTetJF.js +0 -1
  89. package/app/assets/LinkColumnDialog-BEuhj8o8.js +0 -1
  90. package/app/assets/LocalHistoryDialog-BGF91HKS.js +0 -1
  91. package/app/assets/ProcessListDialog-VezdyrHo.js +0 -1
  92. package/app/assets/QuickCommandPalette-BseiwcpU.js +0 -1
  93. package/app/assets/RowFormDialog-XRuG3rMt.js +0 -2
  94. package/app/assets/SafetySettingsDialog-Zh_a4nml.js +0 -1
  95. package/app/assets/SchemaDiffDialog-BrnruiVP.js +0 -7
  96. package/app/assets/StatusDialog-a7NhoFvt.js +0 -1
  97. package/app/assets/UserAddDialog-BBYoKeBv.js +0 -1
  98. package/app/assets/UserManagerDialog-BPC_IoO6.js +0 -1
  99. package/app/assets/VariablesDialog-CzHDGRpy.js +0 -1
  100. package/app/assets/button--s6nUzD8.js +0 -1
  101. package/app/assets/chevron-up-QmvRX9Fw.js +0 -1
  102. package/app/assets/connection-store-N-ZwIkVg.js +0 -1
  103. package/app/assets/database-CpQt6YGv.js +0 -1
  104. package/app/assets/de-Ci_btQN-.js +0 -2
  105. package/app/assets/dialog-CJoWJzRo.js +0 -1
  106. package/app/assets/dist-BAFbxkKh.js +0 -1
  107. package/app/assets/dist-CBYDYlja.js +0 -41
  108. package/app/assets/dist-DgJHEXPr.js +0 -1
  109. package/app/assets/dist-pKt0y9E-.js +0 -1
  110. package/app/assets/editor-registry-DhF4Rf_I.js +0 -1
  111. package/app/assets/fr-rLx93rAO.js +0 -2
  112. package/app/assets/hmr-singleton-DWC1xbJ4.js +0 -1
  113. package/app/assets/i18n-57fo5jb0.js +0 -2
  114. package/app/assets/ja-DkiQpTGb.js +0 -2
  115. package/app/assets/ko-DHI7mstP.js +0 -2
  116. package/app/assets/main-DX7Tr5cg.css +0 -2
  117. package/app/assets/pro-usage-VxPxjJqt.js +0 -1
  118. package/app/assets/query-execution-4-JHu9gp.js +0 -7
  119. package/app/assets/select-ibmUj7AE.js +0 -1
  120. package/app/assets/settings-store-WUA0-UcP.js +0 -1
  121. package/app/assets/table-copy-C1ivtmj8.js +0 -1
  122. package/app/assets/ui-store-DfspmPOn.js +0 -1
  123. package/app/assets/use-engine-B9GBHTL_.js +0 -1
  124. package/app/assets/zh-mgKu2Zwj.js +0 -2
@@ -5,7 +5,7 @@ own license, reproduced here in full. Nothing in the Planche License Agreement
5
5
  limits the rights those licenses grant you.
6
6
 
7
7
  Generated from the production dependencies of the web application.
8
- 105 packages.
8
+ 108 packages.
9
9
 
10
10
  ---
11
11
 
@@ -2058,6 +2058,34 @@ SOFTWARE.
2058
2058
 
2059
2059
  ---
2060
2060
 
2061
+ ## @types/pegjs 0.10.6
2062
+ License: MIT
2063
+ Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pegjs
2064
+
2065
+ MIT License
2066
+
2067
+ Copyright (c) Microsoft Corporation.
2068
+
2069
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2070
+ of this software and associated documentation files (the "Software"), to deal
2071
+ in the Software without restriction, including without limitation the rights
2072
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2073
+ copies of the Software, and to permit persons to whom the Software is
2074
+ furnished to do so, subject to the following conditions:
2075
+
2076
+ The above copyright notice and this permission notice shall be included in all
2077
+ copies or substantial portions of the Software.
2078
+
2079
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2080
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2081
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2082
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2083
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2084
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2085
+ SOFTWARE
2086
+
2087
+ ---
2088
+
2061
2089
  ## aria-hidden 1.2.6
2062
2090
  License: MIT
2063
2091
  Homepage: https://github.com/theKashey/aria-hidden#readme
@@ -2087,6 +2115,37 @@ SOFTWARE.
2087
2115
 
2088
2116
  ---
2089
2117
 
2118
+ ## big-integer 1.6.52
2119
+ License: Unlicense
2120
+ Author: Peter Olson <peter.e.c.olson+npm@gmail.com>
2121
+
2122
+ This is free and unencumbered software released into the public domain.
2123
+
2124
+ Anyone is free to copy, modify, publish, use, compile, sell, or
2125
+ distribute this software, either in source code form or as a compiled
2126
+ binary, for any purpose, commercial or non-commercial, and by any
2127
+ means.
2128
+
2129
+ In jurisdictions that recognize copyright laws, the author or authors
2130
+ of this software dedicate any and all copyright interest in the
2131
+ software to the public domain. We make this dedication for the benefit
2132
+ of the public at large and to the detriment of our heirs and
2133
+ successors. We intend this dedication to be an overt act of
2134
+ relinquishment in perpetuity of all present and future rights to this
2135
+ software under copyright law.
2136
+
2137
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2138
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2139
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2140
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
2141
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2142
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2143
+ OTHER DEALINGS IN THE SOFTWARE.
2144
+
2145
+ For more information, please refer to <http://unlicense.org>
2146
+
2147
+ ---
2148
+
2090
2149
  ## class-variance-authority 0.7.1
2091
2150
  License: Apache-2.0
2092
2151
  Homepage: https://github.com/joe-bell/cva#readme
@@ -3205,6 +3264,215 @@ SOFTWARE.
3205
3264
 
3206
3265
  ---
3207
3266
 
3267
+ ## node-sql-parser 5.4.0
3268
+ License: Apache-2.0
3269
+ Homepage: https://github.com/taozhi8833998/node-sql-parser#readme
3270
+ Author: taozhi8833998 <taozhi8833998@163.com>
3271
+
3272
+ Apache License
3273
+ Version 2.0, January 2004
3274
+ http://www.apache.org/licenses/
3275
+
3276
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
3277
+
3278
+ 1. Definitions.
3279
+
3280
+ "License" shall mean the terms and conditions for use, reproduction,
3281
+ and distribution as defined by Sections 1 through 9 of this document.
3282
+
3283
+ "Licensor" shall mean the copyright owner or entity authorized by
3284
+ the copyright owner that is granting the License.
3285
+
3286
+ "Legal Entity" shall mean the union of the acting entity and all
3287
+ other entities that control, are controlled by, or are under common
3288
+ control with that entity. For the purposes of this definition,
3289
+ "control" means (i) the power, direct or indirect, to cause the
3290
+ direction or management of such entity, whether by contract or
3291
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
3292
+ outstanding shares, or (iii) beneficial ownership of such entity.
3293
+
3294
+ "You" (or "Your") shall mean an individual or Legal Entity
3295
+ exercising permissions granted by this License.
3296
+
3297
+ "Source" form shall mean the preferred form for making modifications,
3298
+ including but not limited to software source code, documentation
3299
+ source, and configuration files.
3300
+
3301
+ "Object" form shall mean any form resulting from mechanical
3302
+ transformation or translation of a Source form, including but
3303
+ not limited to compiled object code, generated documentation,
3304
+ and conversions to other media types.
3305
+
3306
+ "Work" shall mean the work of authorship, whether in Source or
3307
+ Object form, made available under the License, as indicated by a
3308
+ copyright notice that is included in or attached to the work
3309
+ (an example is provided in the Appendix below).
3310
+
3311
+ "Derivative Works" shall mean any work, whether in Source or Object
3312
+ form, that is based on (or derived from) the Work and for which the
3313
+ editorial revisions, annotations, elaborations, or other modifications
3314
+ represent, as a whole, an original work of authorship. For the purposes
3315
+ of this License, Derivative Works shall not include works that remain
3316
+ separable from, or merely link (or bind by name) to the interfaces of,
3317
+ the Work and Derivative Works thereof.
3318
+
3319
+ "Contribution" shall mean any work of authorship, including
3320
+ the original version of the Work and any modifications or additions
3321
+ to that Work or Derivative Works thereof, that is intentionally
3322
+ submitted to Licensor for inclusion in the Work by the copyright owner
3323
+ or by an individual or Legal Entity authorized to submit on behalf of
3324
+ the copyright owner. For the purposes of this definition, "submitted"
3325
+ means any form of electronic, verbal, or written communication sent
3326
+ to the Licensor or its representatives, including but not limited to
3327
+ communication on electronic mailing lists, source code control systems,
3328
+ and issue tracking systems that are managed by, or on behalf of, the
3329
+ Licensor for the purpose of discussing and improving the Work, but
3330
+ excluding communication that is conspicuously marked or otherwise
3331
+ designated in writing by the copyright owner as "Not a Contribution."
3332
+
3333
+ "Contributor" shall mean Licensor and any individual or Legal Entity
3334
+ on behalf of whom a Contribution has been received by Licensor and
3335
+ subsequently incorporated within the Work.
3336
+
3337
+ 2. Grant of Copyright License. Subject to the terms and conditions of
3338
+ this License, each Contributor hereby grants to You a perpetual,
3339
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
3340
+ copyright license to reproduce, prepare Derivative Works of,
3341
+ publicly display, publicly perform, sublicense, and distribute the
3342
+ Work and such Derivative Works in Source or Object form.
3343
+
3344
+ 3. Grant of Patent License. Subject to the terms and conditions of
3345
+ this License, each Contributor hereby grants to You a perpetual,
3346
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
3347
+ (except as stated in this section) patent license to make, have made,
3348
+ use, offer to sell, sell, import, and otherwise transfer the Work,
3349
+ where such license applies only to those patent claims licensable
3350
+ by such Contributor that are necessarily infringed by their
3351
+ Contribution(s) alone or by combination of their Contribution(s)
3352
+ with the Work to which such Contribution(s) was submitted. If You
3353
+ institute patent litigation against any entity (including a
3354
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
3355
+ or a Contribution incorporated within the Work constitutes direct
3356
+ or contributory patent infringement, then any patent licenses
3357
+ granted to You under this License for that Work shall terminate
3358
+ as of the date such litigation is filed.
3359
+
3360
+ 4. Redistribution. You may reproduce and distribute copies of the
3361
+ Work or Derivative Works thereof in any medium, with or without
3362
+ modifications, and in Source or Object form, provided that You
3363
+ meet the following conditions:
3364
+
3365
+ (a) You must give any other recipients of the Work or
3366
+ Derivative Works a copy of this License; and
3367
+
3368
+ (b) You must cause any modified files to carry prominent notices
3369
+ stating that You changed the files; and
3370
+
3371
+ (c) You must retain, in the Source form of any Derivative Works
3372
+ that You distribute, all copyright, patent, trademark, and
3373
+ attribution notices from the Source form of the Work,
3374
+ excluding those notices that do not pertain to any part of
3375
+ the Derivative Works; and
3376
+
3377
+ (d) If the Work includes a "NOTICE" text file as part of its
3378
+ distribution, then any Derivative Works that You distribute must
3379
+ include a readable copy of the attribution notices contained
3380
+ within such NOTICE file, excluding those notices that do not
3381
+ pertain to any part of the Derivative Works, in at least one
3382
+ of the following places: within a NOTICE text file distributed
3383
+ as part of the Derivative Works; within the Source form or
3384
+ documentation, if provided along with the Derivative Works; or,
3385
+ within a display generated by the Derivative Works, if and
3386
+ wherever such third-party notices normally appear. The contents
3387
+ of the NOTICE file are for informational purposes only and
3388
+ do not modify the License. You may add Your own attribution
3389
+ notices within Derivative Works that You distribute, alongside
3390
+ or as an addendum to the NOTICE text from the Work, provided
3391
+ that such additional attribution notices cannot be construed
3392
+ as modifying the License.
3393
+
3394
+ You may add Your own copyright statement to Your modifications and
3395
+ may provide additional or different license terms and conditions
3396
+ for use, reproduction, or distribution of Your modifications, or
3397
+ for any such Derivative Works as a whole, provided Your use,
3398
+ reproduction, and distribution of the Work otherwise complies with
3399
+ the conditions stated in this License.
3400
+
3401
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
3402
+ any Contribution intentionally submitted for inclusion in the Work
3403
+ by You to the Licensor shall be under the terms and conditions of
3404
+ this License, without any additional terms or conditions.
3405
+ Notwithstanding the above, nothing herein shall supersede or modify
3406
+ the terms of any separate license agreement you may have executed
3407
+ with Licensor regarding such Contributions.
3408
+
3409
+ 6. Trademarks. This License does not grant permission to use the trade
3410
+ names, trademarks, service marks, or product names of the Licensor,
3411
+ except as required for reasonable and customary use in describing the
3412
+ origin of the Work and reproducing the content of the NOTICE file.
3413
+
3414
+ 7. Disclaimer of Warranty. Unless required by applicable law or
3415
+ agreed to in writing, Licensor provides the Work (and each
3416
+ Contributor provides its Contributions) on an "AS IS" BASIS,
3417
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
3418
+ implied, including, without limitation, any warranties or conditions
3419
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
3420
+ PARTICULAR PURPOSE. You are solely responsible for determining the
3421
+ appropriateness of using or redistributing the Work and assume any
3422
+ risks associated with Your exercise of permissions under this License.
3423
+
3424
+ 8. Limitation of Liability. In no event and under no legal theory,
3425
+ whether in tort (including negligence), contract, or otherwise,
3426
+ unless required by applicable law (such as deliberate and grossly
3427
+ negligent acts) or agreed to in writing, shall any Contributor be
3428
+ liable to You for damages, including any direct, indirect, special,
3429
+ incidental, or consequential damages of any character arising as a
3430
+ result of this License or out of the use or inability to use the
3431
+ Work (including but not limited to damages for loss of goodwill,
3432
+ work stoppage, computer failure or malfunction, or any and all
3433
+ other commercial damages or losses), even if such Contributor
3434
+ has been advised of the possibility of such damages.
3435
+
3436
+ 9. Accepting Warranty or Additional Liability. While redistributing
3437
+ the Work or Derivative Works thereof, You may choose to offer,
3438
+ and charge a fee for, acceptance of support, warranty, indemnity,
3439
+ or other liability obligations and/or rights consistent with this
3440
+ License. However, in accepting such obligations, You may act only
3441
+ on Your own behalf and on Your sole responsibility, not on behalf
3442
+ of any other Contributor, and only if You agree to indemnify,
3443
+ defend, and hold each Contributor harmless for any liability
3444
+ incurred by, or claims asserted against, such Contributor by reason
3445
+ of your accepting any such warranty or additional liability.
3446
+
3447
+ END OF TERMS AND CONDITIONS
3448
+
3449
+ APPENDIX: How to apply the Apache License to your work.
3450
+
3451
+ To apply the Apache License to your work, attach the following
3452
+ boilerplate notice, with the fields enclosed by brackets "{}"
3453
+ replaced with your own identifying information. (Don't include
3454
+ the brackets!) The text should be enclosed in the appropriate
3455
+ comment syntax for the file format. We also recommend that a
3456
+ file or class name and description of purpose be included on the
3457
+ same "printed page" as the copyright notice for easier
3458
+ identification within third-party archives.
3459
+
3460
+ Copyright {yyyy} {name of copyright owner}
3461
+
3462
+ Licensed under the Apache License, Version 2.0 (the "License");
3463
+ you may not use this file except in compliance with the License.
3464
+ You may obtain a copy of the License at
3465
+
3466
+ http://www.apache.org/licenses/LICENSE-2.0
3467
+
3468
+ Unless required by applicable law or agreed to in writing, software
3469
+ distributed under the License is distributed on an "AS IS" BASIS,
3470
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3471
+ See the License for the specific language governing permissions and
3472
+ limitations under the License.
3473
+
3474
+ ---
3475
+
3208
3476
  ## radix-ui 1.6.7
3209
3477
  License: MIT
3210
3478
  Homepage: https://radix-ui.com/primitives
@@ -0,0 +1 @@
1
+ import{t as e}from"./main-C-Gt0g0g.js";import{n as t}from"./ui-store-5IssrgmG.js";import{l as n,m as r,t as i}from"./button-B2EsmMJs.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./dialog-FBpgH0QJ.js";var d=n(),f=`https://planche.dev`,p=`/third-party-notices.txt`;function m(){let n=t(e=>e.activeDialog),m=t(e=>e.closeDialog),{t:h}=r();return(0,d.jsx)(u,{open:n===`about`,onOpenChange:e=>{e||m()},children:(0,d.jsxs)(s,{className:`sm:max-w-[440px]`,children:[(0,d.jsx)(a,{children:(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(e,{size:44,className:`shrink-0`}),(0,d.jsxs)(`div`,{className:`grid gap-1`,children:[(0,d.jsx)(c,{children:h(`about.title`)}),(0,d.jsx)(l,{children:h(`about.tagline`)})]})]})}),(0,d.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,d.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1`,children:[(0,d.jsx)(`dt`,{className:`text-muted-foreground`,children:h(`about.version`)}),(0,d.jsx)(`dd`,{children:`0.1.1`}),(0,d.jsx)(`dt`,{className:`text-muted-foreground`,children:h(`about.website`)}),(0,d.jsx)(`dd`,{children:(0,d.jsx)(`a`,{href:f,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:f})}),(0,d.jsx)(`dt`,{className:`text-muted-foreground`,children:h(`about.licenses`)}),(0,d.jsx)(`dd`,{children:(0,d.jsx)(`a`,{href:p,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:h(`about.licensesLink`)})})]}),(0,d.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`© 2026 Juwon Jeong. `,h(`about.rights`)]}),(0,d.jsx)(`p`,{className:`rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground`,children:h(`about.disclaimer`)}),(0,d.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs text-muted-foreground`,children:[(0,d.jsx)(`p`,{className:`mb-1 font-medium text-amber-600 dark:text-amber-400`,children:h(`pro.noticeTitle`)}),(0,d.jsx)(`p`,{children:h(`pro.notice`)})]})]}),(0,d.jsx)(o,{children:(0,d.jsx)(i,{onClick:m,children:h(`settings.done`)})})]})})}export{m as AboutDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n,w as r}from"./main-C-Gt0g0g.js";import{h as i,n as a}from"./ui-store-5IssrgmG.js";import{l as o,m as s,t as c}from"./button-B2EsmMJs.js";import{a as l,i as u,n as d,r as f,t as p}from"./select-DwgCtoqv.js";import{_ as m,c as h,d as g}from"./tunneling-BPoIRxJA.js";import{i as _,n as v}from"./settings-store-BBVuUVjA.js";import{a as y,i as b,n as x,o as S,r as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(i(),1),E=o();function D(){let{t:e}=s(),[i,a]=(0,T.useState)(null),[o,y]=(0,T.useState)(!1),[b,x]=(0,T.useState)(`anthropic`),[S,C]=(0,T.useState)(``),[w,D]=(0,T.useState)(``),[O,k]=(0,T.useState)(``),[A,j]=(0,T.useState)(!1),[M,N]=(0,T.useState)(!1),[P,F]=(0,T.useState)(null),I=v(e=>e.setAiPreferences),L=(0,T.useCallback)(()=>{g().then(e=>{a(e);let t=v.getState().aiPreferences,n=e.storage!==`none`;x(n?e.provider:t.provider),C(n?e.model:t.model),D((n?e.baseUrl:t.baseUrl)??``),j(n?e.storage===`file`:t.remember)}).catch(()=>y(!0))},[]);(0,T.useEffect)(L,[L]);let R=(0,T.useCallback)(e=>{x(e),C(t=>_(t,e))},[]),z=(0,T.useCallback)(()=>{N(!0),F(null),m({provider:b,model:S.trim()||void 0,baseUrl:w.trim()||void 0,key:O,remember:A}).then(t=>{a(t),k(``),I({provider:b,model:S.trim()||t.model,baseUrl:w.trim(),remember:A}),F(e(`settings.ai.saved`)),r()}).catch(e=>F(e instanceof Error?e.message:String(e))).finally(()=>N(!1))},[b,S,w,O,A,I,e]),B=(0,T.useCallback)(()=>{N(!0),F(null),h().then(e=>{a(e),k(``),r()}).catch(e=>F(e instanceof Error?e.message:String(e))).finally(()=>N(!1))},[]);if(o)return(0,E.jsx)(`p`,{className:`rounded-md border p-3 text-xs text-muted-foreground`,children:e(`settings.ai.unreachable`)});if(!i)return null;let V=i.fromEnvironment;return(0,E.jsxs)(`div`,{className:`grid gap-3 rounded-md border p-3`,children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.intro`)}),(0,E.jsx)(`p`,{className:`text-xs`,children:i.storage===`environment`?e(`settings.ai.configuredEnv`):i.storage===`file`?e(`settings.ai.configuredFile`,{path:i.path}):i.storage===`session`?e(`settings.ai.configuredSession`):e(`settings.ai.none`)}),!V&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(t,{htmlFor:`ai-provider`,className:`text-sm font-medium`,children:e(`settings.ai.provider`)}),(0,E.jsxs)(p,{value:b,onValueChange:e=>R(e),children:[(0,E.jsx)(u,{id:`ai-provider`,children:(0,E.jsx)(l,{})}),(0,E.jsxs)(d,{children:[(0,E.jsx)(f,{value:`anthropic`,children:`Anthropic`}),(0,E.jsx)(f,{value:`openai`,children:e(`settings.ai.openaiCompatible`)}),(0,E.jsx)(f,{value:`gemini`,children:`Google Gemini`})]})]})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(t,{htmlFor:`ai-model`,className:`text-sm font-medium`,children:e(`settings.ai.model`)}),(0,E.jsx)(n,{id:`ai-model`,value:S,onChange:e=>C(e.target.value),spellCheck:!1})]}),b===`openai`&&(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,E.jsx)(t,{htmlFor:`ai-base-url`,className:`text-sm font-medium`,children:e(`settings.ai.baseUrl`)}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.baseUrlHint`)})]}),(0,E.jsx)(n,{id:`ai-base-url`,value:w,onChange:e=>D(e.target.value),placeholder:`https://api.openai.com/v1`,spellCheck:!1})]}),(0,E.jsxs)(`div`,{className:`grid gap-1`,children:[(0,E.jsx)(t,{htmlFor:`ai-key`,className:`text-sm font-medium`,children:e(`settings.ai.key`)}),(0,E.jsx)(n,{id:`ai-key`,type:`password`,value:O,onChange:e=>k(e.target.value),autoComplete:`off`,spellCheck:!1,placeholder:i.configured?`••••••••`:``}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.keyHint`)})]}),(0,E.jsxs)(`label`,{htmlFor:`ai-remember`,className:`flex cursor-pointer items-start gap-3 rounded-md border p-3 hover:bg-accent/40`,children:[(0,E.jsx)(`input`,{id:`ai-remember`,type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`mt-0.5 size-4 accent-primary`}),(0,E.jsxs)(`span`,{className:`grid flex-1 gap-0.5`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings.ai.remember`)}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.rememberHint`,{path:i.path})})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(c,{size:`sm`,onClick:z,disabled:M||!O.trim(),children:e(`settings.ai.save`)}),i.configured&&(0,E.jsx)(c,{size:`sm`,variant:`ghost`,onClick:B,disabled:M,children:e(`settings.ai.forget`)}),P&&(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:P})]})]})]})}function O(){let e=a(e=>e.activeDialog),t=a(e=>e.closeDialog),{t:n}=s();return(0,E.jsx)(w,{open:e===`ai-settings`,onOpenChange:e=>{e||t()},children:(0,E.jsxs)(x,{className:`sm:max-w-[560px]`,children:[(0,E.jsxs)(y,{children:[(0,E.jsx)(S,{children:n(`settings.ai.title`)}),(0,E.jsx)(C,{children:n(`settings.ai.description`)})]}),(0,E.jsx)(D,{}),(0,E.jsx)(b,{children:(0,E.jsx)(c,{onClick:t,children:n(`settings.done`)})})]})})}export{O as AiSettingsDialog};
@@ -0,0 +1 @@
1
+ import{t as e}from"./rolldown-runtime-hePW80VL.js";var t=e(((e,t)=>{var n=(function(e){var t=1e7,r=9007199254740992,i=f(r),a=`0123456789abcdefghijklmnopqrstuvwxyz`,o=typeof BigInt==`function`;function s(e,t,n,r){return e===void 0?s[0]:t===void 0||+t==10&&!n?Q(e):re(e,t,n,r)}function c(e,t){this.value=e,this.sign=t,this.isSmall=!1}c.prototype=Object.create(s.prototype);function l(e){this.value=e,this.sign=e<0,this.isSmall=!0}l.prototype=Object.create(s.prototype);function u(e){this.value=e}u.prototype=Object.create(s.prototype);function d(e){return-r<e&&e<r}function f(e){return e<1e7?[e]:e<0x5af3107a4000?[e%1e7,Math.floor(e/1e7)]:[e%1e7,Math.floor(e/1e7)%1e7,Math.floor(e/0x5af3107a4000)]}function p(e){m(e);var n=e.length;if(n<4&&M(e,i)<0)switch(n){case 0:return 0;case 1:return e[0];case 2:return e[0]+e[1]*t;default:return e[0]+(e[1]+e[2]*t)*t}return e}function m(e){for(var t=e.length;e[--t]===0;);e.length=t+1}function h(e){for(var t=Array(e),n=-1;++n<e;)t[n]=0;return t}function g(e){return e>0?Math.floor(e):Math.ceil(e)}function _(e,n){var r=e.length,i=n.length,a=Array(r),o=0,s=t,c,l;for(l=0;l<i;l++)c=e[l]+n[l]+o,o=+(c>=s),a[l]=c-o*s;for(;l<r;)c=e[l]+o,o=+(c===s),a[l++]=c-o*s;return o>0&&a.push(o),a}function v(e,t){return e.length>=t.length?_(e,t):_(t,e)}function y(e,n){var r=e.length,i=Array(r),a=t,o,s;for(s=0;s<r;s++)o=e[s]-a+n,n=Math.floor(o/a),i[s]=o-n*a,n+=1;for(;n>0;)i[s++]=n%a,n=Math.floor(n/a);return i}c.prototype.add=function(e){var t=Q(e);if(this.sign!==t.sign)return this.subtract(t.negate());var n=this.value,r=t.value;return t.isSmall?new c(y(n,Math.abs(r)),this.sign):new c(v(n,r),this.sign)},c.prototype.plus=c.prototype.add,l.prototype.add=function(e){var t=Q(e),n=this.value;if(n<0!==t.sign)return this.subtract(t.negate());var r=t.value;if(t.isSmall){if(d(n+r))return new l(n+r);r=f(Math.abs(r))}return new c(y(r,Math.abs(n)),n<0)},l.prototype.plus=l.prototype.add,u.prototype.add=function(e){return new u(this.value+Q(e).value)},u.prototype.plus=u.prototype.add;function b(e,n){var r=e.length,i=n.length,a=Array(r),o=0,s=t,c,l;for(c=0;c<i;c++)l=e[c]-o-n[c],l<0?(l+=s,o=1):o=0,a[c]=l;for(c=i;c<r;c++){if(l=e[c]-o,l<0)l+=s;else{a[c++]=l;break}a[c]=l}for(;c<r;c++)a[c]=e[c];return m(a),a}function x(e,t,n){var r;return M(e,t)>=0?r=b(e,t):(r=b(t,e),n=!n),r=p(r),typeof r==`number`?(n&&(r=-r),new l(r)):new c(r,n)}function S(e,n,r){var i=e.length,a=Array(i),o=-n,s=t,u,d;for(u=0;u<i;u++)d=e[u]+o,o=Math.floor(d/s),d%=s,a[u]=d<0?d+s:d;return a=p(a),typeof a==`number`?(r&&(a=-a),new l(a)):new c(a,r)}c.prototype.subtract=function(e){var t=Q(e);if(this.sign!==t.sign)return this.add(t.negate());var n=this.value,r=t.value;return t.isSmall?S(n,Math.abs(r),this.sign):x(n,r,this.sign)},c.prototype.minus=c.prototype.subtract,l.prototype.subtract=function(e){var t=Q(e),n=this.value;if(n<0!==t.sign)return this.add(t.negate());var r=t.value;return t.isSmall?new l(n-r):S(r,Math.abs(n),n>=0)},l.prototype.minus=l.prototype.subtract,u.prototype.subtract=function(e){return new u(this.value-Q(e).value)},u.prototype.minus=u.prototype.subtract,c.prototype.negate=function(){return new c(this.value,!this.sign)},l.prototype.negate=function(){var e=this.sign,t=new l(-this.value);return t.sign=!e,t},u.prototype.negate=function(){return new u(-this.value)},c.prototype.abs=function(){return new c(this.value,!1)},l.prototype.abs=function(){return new l(Math.abs(this.value))},u.prototype.abs=function(){return new u(this.value>=0?this.value:-this.value)};function C(e,n){var r=e.length,i=n.length,a=h(r+i),o=t,s,c,l,u,d;for(l=0;l<r;++l){u=e[l];for(var f=0;f<i;++f)d=n[f],s=u*d+a[l+f],c=Math.floor(s/o),a[l+f]=s-c*o,a[l+f+1]+=c}return m(a),a}function w(e,n){var r=e.length,i=Array(r),a=t,o=0,s,c;for(c=0;c<r;c++)s=e[c]*n+o,o=Math.floor(s/a),i[c]=s-o*a;for(;o>0;)i[c++]=o%a,o=Math.floor(o/a);return i}function T(e,t){for(var n=[];t-->0;)n.push(0);return n.concat(e)}function E(e,t){var n=Math.max(e.length,t.length);if(n<=30)return C(e,t);n=Math.ceil(n/2);var r=e.slice(n),i=e.slice(0,n),a=t.slice(n),o=t.slice(0,n),s=E(i,o),c=E(r,a),l=v(v(s,T(b(b(E(v(i,r),v(o,a)),s),c),n)),T(c,2*n));return m(l),l}function D(e,t){return-.012*e-.012*t+15e-6*e*t>0}c.prototype.multiply=function(e){var n=Q(e),r=this.value,i=n.value,a=this.sign!==n.sign,o;if(n.isSmall){if(i===0)return s[0];if(i===1)return this;if(i===-1)return this.negate();if(o=Math.abs(i),o<t)return new c(w(r,o),a);i=f(o)}return D(r.length,i.length)?new c(E(r,i),a):new c(C(r,i),a)},c.prototype.times=c.prototype.multiply;function O(e,n,r){return e<t?new c(w(n,e),r):new c(C(n,f(e)),r)}l.prototype._multiplyBySmall=function(e){return d(e.value*this.value)?new l(e.value*this.value):O(Math.abs(e.value),f(Math.abs(this.value)),this.sign!==e.sign)},c.prototype._multiplyBySmall=function(e){return e.value===0?s[0]:e.value===1?this:e.value===-1?this.negate():O(Math.abs(e.value),this.value,this.sign!==e.sign)},l.prototype.multiply=function(e){return Q(e)._multiplyBySmall(this)},l.prototype.times=l.prototype.multiply,u.prototype.multiply=function(e){return new u(this.value*Q(e).value)},u.prototype.times=u.prototype.multiply;function k(e){var n=e.length,r=h(n+n),i=t,a,o,s,c,l;for(s=0;s<n;s++){c=e[s],o=0-c*c;for(var u=s;u<n;u++)l=e[u],a=c*l*2+r[s+u]+o,o=Math.floor(a/i),r[s+u]=a-o*i;r[s+n]=o}return m(r),r}c.prototype.square=function(){return new c(k(this.value),!1)},l.prototype.square=function(){var e=this.value*this.value;return d(e)?new l(e):new c(k(f(Math.abs(this.value))),!1)},u.prototype.square=function(e){return new u(this.value*this.value)};function ee(e,n){var r=e.length,i=n.length,a=t,o=h(n.length),s=n[i-1],c=Math.ceil(a/(2*s)),l=w(e,c),u=w(n,c),d,f,m,g,_,v,y;for(l.length<=r&&l.push(0),u.push(0),s=u[i-1],f=r-i;f>=0;f--){for(d=a-1,l[f+i]!==s&&(d=Math.floor((l[f+i]*a+l[f+i-1])/s)),m=0,g=0,v=u.length,_=0;_<v;_++)m+=d*u[_],y=Math.floor(m/a),g+=l[f+_]-(m-y*a),m=y,g<0?(l[f+_]=g+a,g=-1):(l[f+_]=g,g=0);for(;g!==0;){for(--d,m=0,_=0;_<v;_++)m+=l[f+_]-a+u[_],m<0?(l[f+_]=m+a,m=0):(l[f+_]=m,m=1);g+=m}o[f]=d}return l=A(l,c)[0],[p(o),p(l)]}function te(e,n){for(var r=e.length,i=n.length,a=[],o=[],s=t,c,l,u,d,f;r;){if(o.unshift(e[--r]),m(o),M(o,n)<0){a.push(0);continue}l=o.length,u=o[l-1]*s+o[l-2],d=n[i-1]*s+n[i-2],l>i&&(u=(u+1)*s),c=Math.ceil(u/d);do{if(f=w(n,c),M(f,o)<=0)break;c--}while(c);a.push(c),o=b(o,f)}return a.reverse(),[p(a),p(o)]}function A(e,n){var r=e.length,i=h(r),a=t,o,s,c=0,l;for(o=r-1;o>=0;--o)l=c*a+e[o],s=g(l/n),c=l-s*n,i[o]=s|0;return[i,c|0]}function j(e,n){var r,i=Q(n);if(o)return[new u(e.value/i.value),new u(e.value%i.value)];var a=e.value,d=i.value,m;if(d===0)throw Error(`Cannot divide by zero`);if(e.isSmall)return i.isSmall?[new l(g(a/d)),new l(a%d)]:[s[0],e];if(i.isSmall){if(d===1)return[e,s[0]];if(d==-1)return[e.negate(),s[0]];var h=Math.abs(d);if(h<t){r=A(a,h),m=p(r[0]);var _=r[1];return e.sign&&(_=-_),typeof m==`number`?(e.sign!==i.sign&&(m=-m),[new l(m),new l(_)]):[new c(m,e.sign!==i.sign),new l(_)]}d=f(h)}var v=M(a,d);if(v===-1)return[s[0],e];if(v===0)return[s[e.sign===i.sign?1:-1],s[0]];r=a.length+d.length<=200?ee(a,d):te(a,d),m=r[0];var y=e.sign!==i.sign,b=r[1],x=e.sign;return typeof m==`number`?(y&&(m=-m),m=new l(m)):m=new c(m,y),typeof b==`number`?(x&&(b=-b),b=new l(b)):b=new c(b,x),[m,b]}c.prototype.divmod=function(e){var t=j(this,e);return{quotient:t[0],remainder:t[1]}},u.prototype.divmod=l.prototype.divmod=c.prototype.divmod,c.prototype.divide=function(e){return j(this,e)[0]},u.prototype.over=u.prototype.divide=function(e){return new u(this.value/Q(e).value)},l.prototype.over=l.prototype.divide=c.prototype.over=c.prototype.divide,c.prototype.mod=function(e){return j(this,e)[1]},u.prototype.mod=u.prototype.remainder=function(e){return new u(this.value%Q(e).value)},l.prototype.remainder=l.prototype.mod=c.prototype.remainder=c.prototype.mod,c.prototype.pow=function(e){var t=Q(e),n=this.value,r=t.value,i,a,o;if(r===0)return s[1];if(n===0)return s[0];if(n===1)return s[1];if(n===-1)return t.isEven()?s[1]:s[-1];if(t.sign)return s[0];if(!t.isSmall)throw Error(`The exponent `+t.toString()+` is too large.`);if(this.isSmall&&d(i=n**+r))return new l(g(i));for(a=this,o=s[1];r&!0&&(o=o.times(a),--r),r!==0;)r/=2,a=a.square();return o},l.prototype.pow=c.prototype.pow,u.prototype.pow=function(e){var t=Q(e),n=this.value,r=t.value,i=BigInt(0),a=BigInt(1),o=BigInt(2);if(r===i)return s[1];if(n===i)return s[0];if(n===a)return s[1];if(n===BigInt(-1))return t.isEven()?s[1]:s[-1];if(t.isNegative())return new u(i);for(var c=this,l=s[1];(r&a)===a&&(l=l.times(c),--r),r!==i;)r/=o,c=c.square();return l},c.prototype.modPow=function(e,t){if(e=Q(e),t=Q(t),t.isZero())throw Error(`Cannot take modPow with modulus 0`);var n=s[1],r=this.mod(t);for(e.isNegative()&&(e=e.multiply(s[-1]),r=r.modInv(t));e.isPositive();){if(r.isZero())return s[0];e.isOdd()&&(n=n.multiply(r).mod(t)),e=e.divide(2),r=r.square().mod(t)}return n},u.prototype.modPow=l.prototype.modPow=c.prototype.modPow;function M(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}c.prototype.compareAbs=function(e){var t=Q(e),n=this.value,r=t.value;return t.isSmall?1:M(n,r)},l.prototype.compareAbs=function(e){var t=Q(e),n=Math.abs(this.value),r=t.value;return t.isSmall?(r=Math.abs(r),n===r?0:n>r?1:-1):-1},u.prototype.compareAbs=function(e){var t=this.value,n=Q(e).value;return t=t>=0?t:-t,n=n>=0?n:-n,t===n?0:t>n?1:-1},c.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=Q(e),n=this.value,r=t.value;return this.sign===t.sign?t.isSmall?this.sign?-1:1:M(n,r)*(this.sign?-1:1):t.sign?1:-1},c.prototype.compareTo=c.prototype.compare,l.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=Q(e),n=this.value,r=t.value;return t.isSmall?n==r?0:n>r?1:-1:n<0===t.sign?n<0?1:-1:n<0?-1:1},l.prototype.compareTo=l.prototype.compare,u.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=this.value,n=Q(e).value;return t===n?0:t>n?1:-1},u.prototype.compareTo=u.prototype.compare,c.prototype.equals=function(e){return this.compare(e)===0},u.prototype.eq=u.prototype.equals=l.prototype.eq=l.prototype.equals=c.prototype.eq=c.prototype.equals,c.prototype.notEquals=function(e){return this.compare(e)!==0},u.prototype.neq=u.prototype.notEquals=l.prototype.neq=l.prototype.notEquals=c.prototype.neq=c.prototype.notEquals,c.prototype.greater=function(e){return this.compare(e)>0},u.prototype.gt=u.prototype.greater=l.prototype.gt=l.prototype.greater=c.prototype.gt=c.prototype.greater,c.prototype.lesser=function(e){return this.compare(e)<0},u.prototype.lt=u.prototype.lesser=l.prototype.lt=l.prototype.lesser=c.prototype.lt=c.prototype.lesser,c.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},u.prototype.geq=u.prototype.greaterOrEquals=l.prototype.geq=l.prototype.greaterOrEquals=c.prototype.geq=c.prototype.greaterOrEquals,c.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},u.prototype.leq=u.prototype.lesserOrEquals=l.prototype.leq=l.prototype.lesserOrEquals=c.prototype.leq=c.prototype.lesserOrEquals,c.prototype.isEven=function(){return!(this.value[0]&1)},l.prototype.isEven=function(){return!(this.value&1)},u.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},c.prototype.isOdd=function(){return(this.value[0]&1)==1},l.prototype.isOdd=function(){return(this.value&1)==1},u.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},c.prototype.isPositive=function(){return!this.sign},l.prototype.isPositive=function(){return this.value>0},u.prototype.isPositive=l.prototype.isPositive,c.prototype.isNegative=function(){return this.sign},l.prototype.isNegative=function(){return this.value<0},u.prototype.isNegative=l.prototype.isNegative,c.prototype.isUnit=function(){return!1},l.prototype.isUnit=function(){return Math.abs(this.value)===1},u.prototype.isUnit=function(){return this.abs().value===BigInt(1)},c.prototype.isZero=function(){return!1},l.prototype.isZero=function(){return this.value===0},u.prototype.isZero=function(){return this.value===BigInt(0)},c.prototype.isDivisibleBy=function(e){var t=Q(e);return t.isZero()?!1:t.isUnit()?!0:t.compareAbs(2)===0?this.isEven():this.mod(t).isZero()},u.prototype.isDivisibleBy=l.prototype.isDivisibleBy=c.prototype.isDivisibleBy;function N(e){var t=e.abs();if(t.isUnit())return!1;if(t.equals(2)||t.equals(3)||t.equals(5))return!0;if(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))return!1;if(t.lesser(49))return!0}function P(e,t){for(var r=e.prev(),i=r,a=0,o,s,c;i.isEven();)i=i.divide(2),a++;next:for(s=0;s<t.length;s++)if(!e.lesser(t[s])&&(c=n(t[s]).modPow(i,e),!(c.isUnit()||c.equals(r)))){for(o=a-1;o!=0;o--){if(c=c.square().mod(e),c.isUnit())return!1;if(c.equals(r))continue next}return!1}return!0}c.prototype.isPrime=function(t){var r=N(this);if(r!==e)return r;var i=this.abs(),a=i.bitLength();if(a<=64)return P(i,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var o=Math.log(2)*a.toJSNumber(),s=Math.ceil(t===!0?2*o**2:o),c=[],l=0;l<s;l++)c.push(n(l+2));return P(i,c)},u.prototype.isPrime=l.prototype.isPrime=c.prototype.isPrime,c.prototype.isProbablePrime=function(t,r){var i=N(this);if(i!==e)return i;for(var a=this.abs(),o=t===e?5:t,s=[],c=0;c<o;c++)s.push(n.randBetween(2,a.minus(2),r));return P(a,s)},u.prototype.isProbablePrime=l.prototype.isProbablePrime=c.prototype.isProbablePrime,c.prototype.modInv=function(e){for(var t=n.zero,r=n.one,i=Q(e),a=this.abs(),o,s,c;!a.isZero();)o=i.divide(a),s=t,c=i,t=r,i=a,r=s.subtract(o.multiply(r)),a=c.subtract(o.multiply(a));if(!i.isUnit())throw Error(this.toString()+` and `+e.toString()+` are not co-prime`);return t.compare(0)===-1&&(t=t.add(e)),this.isNegative()?t.negate():t},u.prototype.modInv=l.prototype.modInv=c.prototype.modInv,c.prototype.next=function(){var e=this.value;return this.sign?S(e,1,this.sign):new c(y(e,1),this.sign)},l.prototype.next=function(){var e=this.value;return e+1<r?new l(e+1):new c(i,!1)},u.prototype.next=function(){return new u(this.value+BigInt(1))},c.prototype.prev=function(){var e=this.value;return this.sign?new c(y(e,1),!0):S(e,1,this.sign)},l.prototype.prev=function(){var e=this.value;return e-1>-r?new l(e-1):new c(i,!0)},u.prototype.prev=function(){return new u(this.value-BigInt(1))};for(var F=[1];2*F[F.length-1]<=t;)F.push(2*F[F.length-1]);var I=F.length,L=F[I-1];function R(e){return Math.abs(e)<=t}c.prototype.shiftLeft=function(e){var t=Q(e).toJSNumber();if(!R(t))throw Error(String(t)+` is too large for shifting.`);if(t<0)return this.shiftRight(-t);var n=this;if(n.isZero())return n;for(;t>=I;)n=n.multiply(L),t-=I-1;return n.multiply(F[t])},u.prototype.shiftLeft=l.prototype.shiftLeft=c.prototype.shiftLeft,c.prototype.shiftRight=function(e){var t,n=Q(e).toJSNumber();if(!R(n))throw Error(String(n)+` is too large for shifting.`);if(n<0)return this.shiftLeft(-n);for(var r=this;n>=I;){if(r.isZero()||r.isNegative()&&r.isUnit())return r;t=j(r,L),r=t[1].isNegative()?t[0].prev():t[0],n-=I-1}return t=j(r,F[n]),t[1].isNegative()?t[0].prev():t[0]},u.prototype.shiftRight=l.prototype.shiftRight=c.prototype.shiftRight;function z(e,t,r){t=Q(t);for(var i=e.isNegative(),a=t.isNegative(),o=i?e.not():e,s=a?t.not():t,c=0,l=0,u=null,d=null,f=[];!o.isZero()||!s.isZero();)u=j(o,L),c=u[1].toJSNumber(),i&&(c=L-1-c),d=j(s,L),l=d[1].toJSNumber(),a&&(l=L-1-l),o=u[0],s=d[0],f.push(r(c,l));for(var p=r(+!!i,+!!a)===0?n(0):n(-1),m=f.length-1;m>=0;--m)p=p.multiply(L).add(n(f[m]));return p}c.prototype.not=function(){return this.negate().prev()},u.prototype.not=l.prototype.not=c.prototype.not,c.prototype.and=function(e){return z(this,e,function(e,t){return e&t})},u.prototype.and=l.prototype.and=c.prototype.and,c.prototype.or=function(e){return z(this,e,function(e,t){return e|t})},u.prototype.or=l.prototype.or=c.prototype.or,c.prototype.xor=function(e){return z(this,e,function(e,t){return e^t})},u.prototype.xor=l.prototype.xor=c.prototype.xor;var B=1<<30,V=(t&-t)*(t&-t)|B;function H(e){var n=e.value,r=typeof n==`number`?n|B:typeof n==`bigint`?n|BigInt(B):n[0]+n[1]*t|V;return r&-r}function U(e,t){if(t.compareTo(e)<=0){var r=U(e,t.square(t)),i=r.p,a=r.e,o=i.multiply(t);return o.compareTo(e)<=0?{p:o,e:a*2+1}:{p:i,e:a*2}}return{p:n(1),e:0}}c.prototype.bitLength=function(){var e=this;return e.compareTo(n(0))<0&&(e=e.negate().subtract(n(1))),e.compareTo(n(0))===0?n(0):n(U(e,n(2)).e).add(n(1))},u.prototype.bitLength=l.prototype.bitLength=c.prototype.bitLength;function W(e,t){return e=Q(e),t=Q(t),e.greater(t)?e:t}function G(e,t){return e=Q(e),t=Q(t),e.lesser(t)?e:t}function K(e,t){if(e=Q(e).abs(),t=Q(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var n=s[1],r,i;e.isEven()&&t.isEven();)r=G(H(e),H(t)),e=e.divide(r),t=t.divide(r),n=n.multiply(r);for(;e.isEven();)e=e.divide(H(e));do{for(;t.isEven();)t=t.divide(H(t));e.greater(t)&&(i=t,t=e,e=i),t=t.subtract(e)}while(!t.isZero());return n.isUnit()?e:e.multiply(n)}function q(e,t){return e=Q(e).abs(),t=Q(t).abs(),e.divide(K(e,t)).multiply(t)}function ne(e,n,r){e=Q(e),n=Q(n);var i=r||Math.random,a=G(e,n),o=W(e,n).subtract(a).add(1);if(o.isSmall)return a.add(Math.floor(i()*o));for(var c=Y(o,t).value,l=[],u=!0,d=0;d<c.length;d++){var f=u?c[d]+(d+1<c.length?c[d+1]/t:0):t,p=g(i()*f);l.push(p),p<c[d]&&(u=!1)}return a.add(s.fromArray(l,t,!1))}var re=function(e,t,n,r){n||=a,e=String(e),r||(e=e.toLowerCase(),n=n.toLowerCase());var i=e.length,o,s=Math.abs(t),c={};for(o=0;o<n.length;o++)c[n[o]]=o;for(o=0;o<i;o++){var l=e[o];if(l!==`-`&&l in c&&c[l]>=s){if(l===`1`&&s===1)continue;throw Error(l+` is not a valid digit in base `+t+`.`)}}t=Q(t);var u=[],d=e[0]===`-`;for(o=+!!d;o<e.length;o++){var l=e[o];if(l in c)u.push(Q(c[l]));else if(l===`<`){var f=o;do o++;while(e[o]!==`>`&&o<e.length);u.push(Q(e.slice(f+1,o)))}else throw Error(l+` is not a valid character`)}return J(u,t,d)};function J(e,t,n){var r=s[0],i=s[1],a;for(a=e.length-1;a>=0;a--)r=r.add(e[a].times(i)),i=i.times(t);return n?r.negate():r}function ie(e,t){return t||=a,e<t.length?t[e]:`<`+e+`>`}function Y(e,t){if(t=n(t),t.isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw Error(`Cannot convert nonzero numbers to base 0.`)}if(t.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(e.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var i=!1;if(e.isNegative()&&t.isPositive()&&(i=!0,e=e.abs()),t.isUnit())return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(e.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:i};for(var a=[],o=e,s;o.isNegative()||o.compareAbs(t)>=0;){s=o.divmod(t),o=s.quotient;var c=s.remainder;c.isNegative()&&(c=t.minus(c).abs(),o=o.next()),a.push(c.toJSNumber())}return a.push(o.toJSNumber()),{value:a.reverse(),isNegative:i}}function X(e,t,n){var r=Y(e,t);return(r.isNegative?`-`:``)+r.value.map(function(e){return ie(e,n)}).join(``)}c.prototype.toArray=function(e){return Y(this,e)},l.prototype.toArray=function(e){return Y(this,e)},u.prototype.toArray=function(e){return Y(this,e)},c.prototype.toString=function(t,n){if(t===e&&(t=10),t!==10||n)return X(this,t,n);for(var r=this.value,i=r.length,a=String(r[--i]),o=`0000000`,s;--i>=0;)s=String(r[i]),a+=o.slice(s.length)+s;return(this.sign?`-`:``)+a},l.prototype.toString=function(t,n){return t===e&&(t=10),t!=10||n?X(this,t,n):String(this.value)},u.prototype.toString=l.prototype.toString,u.prototype.toJSON=c.prototype.toJSON=l.prototype.toJSON=function(){return this.toString()},c.prototype.valueOf=function(){return parseInt(this.toString(),10)},c.prototype.toJSNumber=c.prototype.valueOf,l.prototype.valueOf=function(){return this.value},l.prototype.toJSNumber=l.prototype.valueOf,u.prototype.valueOf=u.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function Z(e){if(d(+e)){var t=+e;if(t===g(t))return o?new u(BigInt(t)):new l(t);throw Error(`Invalid integer: `+e)}var n=e[0]===`-`;n&&(e=e.slice(1));var r=e.split(/e/i);if(r.length>2)throw Error(`Invalid integer: `+r.join(`e`));if(r.length===2){var i=r[1];if(i[0]===`+`&&(i=i.slice(1)),i=+i,i!==g(i)||!d(i))throw Error(`Invalid integer: `+i+` is not a valid exponent.`);var a=r[0],s=a.indexOf(`.`);if(s>=0&&(i-=a.length-s-1,a=a.slice(0,s)+a.slice(s+1)),i<0)throw Error(`Cannot include negative exponent part for integers`);a+=Array(i+1).join(`0`),e=a}if(!/^([0-9][0-9]*)$/.test(e))throw Error(`Invalid integer: `+e);if(o)return new u(BigInt(n?`-`+e:e));for(var f=[],p=e.length,h=7,_=p-h;p>0;)f.push(+e.slice(_,p)),_-=h,_<0&&(_=0),p-=h;return m(f),new c(f,n)}function ae(e){if(o)return new u(BigInt(e));if(d(e)){if(e!==g(e))throw Error(e+` is not an integer.`);return new l(e)}return Z(e.toString())}function Q(e){return typeof e==`number`?ae(e):typeof e==`string`?Z(e):typeof e==`bigint`?new u(e):e}for(var $=0;$<1e3;$++)s[$]=Q($),$>0&&(s[-$]=Q(-$));return s.one=s[1],s.zero=s[0],s.minusOne=s[-1],s.max=W,s.min=G,s.gcd=K,s.lcm=q,s.isInstance=function(e){return e instanceof c||e instanceof l||e instanceof u},s.randBetween=ne,s.fromArray=function(e,t,n){return J(e.map(Q),Q(t||10),n)},s})();t!==void 0&&t.hasOwnProperty(`exports`)&&(t.exports=n),typeof define==`function`&&define.amd&&define(function(){return n})}));export{t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,C as r,F as i,I as a,S as o,a as s,b as c,c as l,i as u,k as d,l as f,n as p,o as m,r as h,s as g,u as _,ut as v,v as y,x as b,y as x}from"./main-C-Gt0g0g.js";import{h as S,n as C,t as w}from"./ui-store-5IssrgmG.js";import{l as T,m as E,t as D}from"./button-B2EsmMJs.js";import{a as O,i as k,n as A,r as j,t as M}from"./select-DwgCtoqv.js";import{C as N,a as P,b as F,f as I,p as ee,x as L}from"./tunneling-BPoIRxJA.js";import{t as R}from"./connection-store-BnO3WqEO.js";import{n as te}from"./query-store-dYiA8oM5.js";import{S as ne,d as z,g as re,i as ie,l as B,r as ae}from"./database-BvWJHB7q.js";import{n as V,t as H}from"./dbms-BwnatOMe.js";import{n as U}from"./pro-gate-DZATEYdR.js";import{a as oe,i as se,n as ce,o as le,t as ue}from"./dialog-FBpgH0QJ.js";var W=e(S(),1),G=new Set([`postgres:`,`postgresql:`]);function K(e){let t=e.trim().replace(/^psql\s+(['"])?/,``).replace(/['"]$/,``);if(!/^postgres(ql)?:\/\//i.test(t))return null;let n;try{n=new URL(t)}catch{return null}if(!G.has(n.protocol.toLowerCase())||!n.hostname)return null;let r=e=>{try{return decodeURIComponent(e)}catch{return e}},i={host:n.hostname};n.port&&(i.port=Number(n.port)),n.username&&(i.user=r(n.username)),n.password&&(i.pass=r(n.password));let a=r(n.pathname.replace(/^\//,``));return a&&(i.database=a),i}var q=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function J(e,t){let n;try{let t=new URL(e);if(!q.has(t.hostname.toLowerCase()))return[];n=t.origin}catch{return[]}try{let e=await fetch(`${n}/cdn-cgi/local/explorer/api/d1/database`,{signal:t});if(!e.ok)return[];let r=await e.json(),i=new Map;for(let e of r.result??[])e.uuid&&i.set(e.uuid,{name:e.name??e.uuid,id:e.uuid});return[...i.values()]}catch{return[]}}var Y=T(),X=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],Z={enabled:!1,host:``,port:22,user:``,auth:`key`};function Q({label:e,htmlFor:t,children:n}){return(0,Y.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,Y.jsx)(l,{htmlFor:t,children:e}),n]})}function de({value:e,onChange:t}){let{t:r}=E();function i(n,r){t({...e,[n]:r})}let[o,s]=(0,W.useState)([]),c=e.dbms===`d1`?e.devUrl??``:``;(0,W.useEffect)(()=>{if(!c){s([]);return}let e=new AbortController,t=setTimeout(()=>{J(c,e.signal).then(s)},300);return()=>{clearTimeout(t),e.abort()}},[c]);let l=e.dbms===`sqlite`,u=e.transport??`browser`,p=l&&u===`browser`,h=L.has(e.dbms),v=e.dbms===`d1`,y=e.dbms===`do`,b=H.find(t=>t.id===e.dbms)?.capabilities,x=e.ssh??Z,[S,C]=(0,W.useState)(``),w=S.trim()===``?`empty`:K(S)?`applied`:`invalid`,T=e.dbms===`supabase`&&e.port===6543;function P(n){C(n);let r=K(n);r&&t({...e,host:r.host??e.host,port:r.port??H.find(t=>t.id===e.dbms)?.defaultPort??e.port,user:r.user??e.user,pass:r.pass??e.pass,database:r.database??e.database})}function F(n){t({...e,ssh:{...x,...n}})}async function I(e){e&&F({privateKey:await e.text(),privateKeyName:e.name})}return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,Y.jsx)(Q,{label:r(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,Y.jsx)(f,{id:`conn-hostName`,placeholder:r(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>i(`hostName`,e.target.value)})}),(0,Y.jsx)(Q,{label:r(`connection.form.dataSource`),children:(0,Y.jsxs)(M,{value:e.dbms,onValueChange:n=>{let r=H.find(e=>e.id===n);if(!r)return;let i=r.id,a=L.has(i)||i===`d1`||i===`do`;C(``),t({...e,dbms:i,transactionMode:r.capabilities.transactions?e.transactionMode:`auto`,port:r.defaultPort??e.port,host:a&&e.host===`localhost`?``:!a&&e.host===``?`localhost`:e.host,user:a||h||v||y?g(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!h&&!v&&!y?e.database:m(i)??e.database})},children:[(0,Y.jsx)(k,{id:`conn-dbms`,className:`w-full`,children:(0,Y.jsx)(O,{})}),(0,Y.jsx)(A,{children:H.map(e=>(0,Y.jsx)(j,{value:e.id,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(_,{dbms:e.id}),e.label]})},e.id))})]})}),h&&(0,Y.jsx)(Q,{label:r(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(f,{id:`conn-uri`,type:`password`,autoComplete:`new-password`,spellCheck:!1,className:`font-mono text-xs`,placeholder:e.dbms===`neon`?`postgresql://neondb_owner:npg_…@ep-….neon.tech/neondb?sslmode=require`:`postgresql://postgres.[ref]:[password]@aws-0-….pooler.supabase.com:5432/postgres`,value:S,onChange:e=>P(e.target.value)}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${w===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:r(w===`invalid`?`connection.form.connectionStringInvalid`:w===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),l&&(0,Y.jsxs)(Q,{label:r(`connection.form.openVia`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:u===`browser`,onChange:()=>i(`transport`,`browser`),className:`accent-primary`}),r(`connection.form.viaBrowser`)]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:u===`tunnel`,onChange:()=>i(`transport`,`tunnel`),className:`accent-primary`}),r(`connection.form.viaAgent`)]})]}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(u===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),p?(0,Y.jsx)(Q,{label:r(`connection.form.databaseFile`),children:(0,Y.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,Y.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{B(e.id),i(`file`,``)},children:r(`connection.form.changeFile`)})]}):(0,Y.jsx)(`p`,{children:r(`connection.form.filePickerHint`)}),(0,Y.jsx)(`p`,{className:`mt-1`,children:r(`connection.form.fileRememberedHint`)})]})}):null,!p&&(0,Y.jsx)(Q,{label:r(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,Y.jsx)(f,{id:`conn-authToken`,type:`password`,autoComplete:`new-password`,placeholder:r(`connection.form.authTokenPlaceholder`),value:e.authToken,onChange:e=>i(`authToken`,e.target.value.trim())})}),p?null:y?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,Y.jsx)(f,{id:`conn-do-url`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>i(`devUrl`,e.target.value.trim())})}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.doHint`)}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.doLimitsHint`)})]}):v?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,Y.jsx)(f,{id:`conn-d1-dev`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>i(`devUrl`,e.target.value.trim())})}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.d1DevUrlHint`)}),(0,Y.jsx)(Q,{label:r(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,Y.jsx)(f,{id:`conn-d1-account`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:e.accountId??``,onChange:e=>i(`accountId`,e.target.value.trim())})}),(0,Y.jsx)(Q,{label:r(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:o.length>0?(0,Y.jsxs)(M,{value:e.databaseId??``,onValueChange:e=>i(`databaseId`,e),children:[(0,Y.jsx)(k,{id:`conn-d1-database`,children:(0,Y.jsx)(O,{placeholder:r(`connection.form.d1PickDatabase`)})}),(0,Y.jsx)(A,{children:o.map(e=>(0,Y.jsxs)(j,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,Y.jsx)(f,{id:`conn-d1-database`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:e.databaseId??``,onChange:e=>i(`databaseId`,e.target.value.trim())})}),(0,Y.jsx)(Q,{label:r(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(f,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>i(`pass`,e.target.value.trim())}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:r(`connection.form.savePasswordHint`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>i(`savePassword`,e.target.checked)}),r(`connection.form.savePassword`)]})]})}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.d1Hint`)}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.d1LimitsHint`)})]}):l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,Y.jsx)(f,{id:`conn-file`,placeholder:r(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>i(`file`,e.target.value)})}),(0,Y.jsx)(Q,{label:r(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-create`,type:`checkbox`,checked:e.createIfMissing??!1,onChange:e=>i(`createIfMissing`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`connection.form.createIfMissingHint`)})]})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.host`),htmlFor:`conn-host`,children:(0,Y.jsx)(f,{id:`conn-host`,placeholder:e.dbms===`neon`?`ep-….aws.neon.tech`:e.dbms===`supabase`?`aws-0-….pooler.supabase.com`:`localhost`,value:e.host,onChange:e=>i(`host`,e.target.value)})}),(0,Y.jsx)(Q,{label:r(`connection.form.port`),htmlFor:`conn-port`,children:(0,Y.jsx)(f,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>i(`port`,Number(t.target.value)||H.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),T&&(0,Y.jsx)(`p`,{className:`col-start-2 rounded-md border border-yellow-500/40 bg-yellow-500/10 px-2 py-1.5 text-xs leading-relaxed text-foreground`,children:r(`connection.form.supabasePoolerWarning`)}),(N(e.dbms)||e.dbms===`mssql`||e.dbms===`oracle`)&&(0,Y.jsx)(Q,{label:e.dbms===`oracle`?r(`connection.form.serviceName`):r(`connection.form.database`),htmlFor:`conn-database`,children:(0,Y.jsx)(f,{id:`conn-database`,placeholder:m(e.dbms),value:e.database??``,onChange:e=>i(`database`,e.target.value.trim())})}),(0,Y.jsx)(Q,{label:r(`connection.form.user`),htmlFor:`conn-user`,children:(0,Y.jsx)(f,{id:`conn-user`,autoComplete:`off`,placeholder:g(e.dbms),value:e.user,onChange:e=>i(`user`,e.target.value)})}),(0,Y.jsx)(Q,{label:r(`connection.form.password`),htmlFor:`conn-pass`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(f,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>i(`pass`,e.target.value)}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:r(`connection.form.savePasswordHint`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>i(`savePassword`,e.target.checked)}),r(`connection.form.savePassword`)]})]})}),h&&(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.managedTlsHint`)}),!h&&e.dbms!==`oracle`&&(0,Y.jsx)(Q,{label:r(`connection.form.tls`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:e.ssl??!1,onChange:e=>i(`ssl`,e.target.checked),className:`size-4 accent-primary`}),r(`connection.form.tlsEnable`)]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:r(`connection.form.tlsVerifyHint`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,disabled:!e.ssl,checked:e.sslVerify??!1,onChange:e=>i(`sslVerify`,e.target.checked),className:`size-4 accent-primary`}),r(`connection.form.tlsVerify`)]})]})}),!h&&(0,Y.jsx)(Q,{label:r(`connection.form.charset`),children:(0,Y.jsxs)(M,{value:e.charset,onValueChange:e=>i(`charset`,e),children:[(0,Y.jsx)(k,{className:`w-full`,children:(0,Y.jsx)(O,{})}),(0,Y.jsx)(A,{children:X.map(e=>(0,Y.jsx)(j,{value:e,children:e},e))})]})})]}),!l&&!h&&!v&&!y&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mt-1 flex items-center border-t pt-3 text-xs font-medium text-muted-foreground`,children:[r(`connection.form.ssh`),(0,Y.jsx)(a,{className:`ml-2`})]}),(0,Y.jsx)(Q,{label:r(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:x.enabled,onChange:e=>{(!e.target.checked||U(`ssh_tunnel`))&&F({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`connection.form.sshTunnelHint`)})]})}),x.enabled&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(f,{id:`conn-ssh-host`,placeholder:r(`connection.form.sshHostPlaceholder`),value:x.host,onChange:e=>F({host:e.target.value.trim()})}),(0,Y.jsx)(f,{"aria-label":r(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:x.port,onChange:e=>F({port:Number(e.target.value)||22})})]})}),(0,Y.jsx)(Q,{label:r(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,Y.jsx)(f,{id:`conn-ssh-user`,placeholder:r(`connection.form.sshUserPlaceholder`),value:x.user,onChange:e=>F({user:e.target.value.trim()})})}),(0,Y.jsx)(Q,{label:r(`connection.form.sshAuth`),children:(0,Y.jsxs)(M,{value:x.auth,onValueChange:e=>F({auth:e}),children:[(0,Y.jsx)(k,{className:`w-full`,children:(0,Y.jsx)(O,{})}),(0,Y.jsxs)(A,{children:[(0,Y.jsx)(j,{value:`key`,children:r(`connection.form.sshAuthKey`)}),(0,Y.jsx)(j,{value:`password`,children:r(`connection.form.sshAuthPassword`)}),(0,Y.jsx)(j,{value:`agent`,children:r(`connection.form.sshAuthAgent`)})]})]})}),x.auth===`password`&&(0,Y.jsx)(Q,{label:r(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,Y.jsx)(f,{id:`conn-ssh-pass`,type:`password`,autoComplete:`new-password`,value:x.password??``,onChange:e=>F({password:e.target.value})})}),x.auth===`key`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{I(e.target.files?.[0]),e.target.value=``}}),(0,Y.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:x.privateKey?r(`connection.form.changeFile`):r(`connection.form.sshKeyPick`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:x.privateKeyName,children:x.privateKey?x.privateKeyName||r(`connection.form.sshKeyLoaded`):r(`connection.form.sshKeyHint`)})]})}),(0,Y.jsx)(Q,{label:r(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,Y.jsx)(f,{id:`conn-ssh-passphrase`,type:`password`,autoComplete:`new-password`,placeholder:r(`connection.form.sshPassphrasePlaceholder`),value:x.passphrase??``,onChange:e=>F({passphrase:e.target.value})})})]}),x.auth===`agent`&&(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.sshAuthAgentHint`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.sshTargetHint`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.sshSecretsHint`)})]})]}),(0,Y.jsx)(Q,{label:r(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,Y.jsx)(`div`,{className:`flex items-center`,children:(0,Y.jsx)(`input`,{id:`conn-auto`,type:`checkbox`,checked:e.autoConnection,onChange:e=>i(`autoConnection`,e.target.checked),className:`size-4 accent-primary cursor-pointer`})})}),(0,Y.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:r(`connection.form.safety`)}),(0,Y.jsx)(Q,{label:r(`connection.form.environment`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[d.map(t=>{let r=(e.environmentColor??`none`)===t.id;return(0,Y.jsx)(`button`,{type:`button`,title:n(t.id),"aria-label":n(t.id),"aria-pressed":r,onClick:()=>i(`environmentColor`,t.id),className:`size-6 rounded-full border-2 transition-transform ${r?`scale-110 border-foreground`:`border-transparent hover:scale-105`}`,style:{background:t.id===`none`?`repeating-linear-gradient(45deg, transparent, transparent 3px, var(--muted-foreground) 3px, var(--muted-foreground) 4px)`:t.hex}},t.id)}),(0,Y.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:r(`connection.form.environmentHint`)})]})}),(0,Y.jsx)(Q,{label:r(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-readonly`,type:`checkbox`,checked:e.readOnly??!1,onChange:e=>i(`readOnly`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`connection.form.readOnlyHint`)})]})}),b?.transactions!==!1&&(0,Y.jsx)(Q,{label:r(`connection.form.transactions`),children:(0,Y.jsxs)(M,{value:e.transactionMode??`auto`,onValueChange:e=>i(`transactionMode`,e),children:[(0,Y.jsx)(k,{className:`w-full`,children:(0,Y.jsx)(O,{})}),(0,Y.jsxs)(A,{children:[(0,Y.jsx)(j,{value:`auto`,children:r(`connection.form.txAuto`)}),(0,Y.jsx)(j,{value:`manual`,children:r(`connection.form.txManual`)})]})]})})]})}function fe(){let{t:e}=E(),{activeDialog:n,closeDialog:a,showMessage:l}=C(),[d,f]=(0,W.useState)(!1),{savedConnections:m,addSavedConnection:g,updateSavedConnection:S,deleteSavedConnection:T,openConnection:O}=R(),k=w(`connect`)?.profileId,[A,j]=(0,W.useState)(()=>k??null),[M,N]=(0,W.useState)(()=>{let e=k?m.find(e=>e.id===k):void 0;return e?{...e}:null}),L=n===`connect`,[B,H]=(0,W.useState)(null),[U,G]=(0,W.useState)(null),K=i(e=>e.url),q=i(e=>e.token);(0,W.useEffect)(()=>{if(!L)return;let e=!1;return(async()=>{try{let t=await P();if(e||t.state!==`online`||!t.gateway){e||H(null);return}let n=await I();e||(H({name:n.gateway,profiles:n.profiles}),G(null))}catch(t){e||G(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[L,K,q]);function J(t){let n=m.find(e=>e.gatewayProfile===t.name);if(n){Z(n);return}let r=h(t);g(r),Z(r),C.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function X(e){e||(a(),j(null),N(null))}function Z(e){j(e.id),N({...e})}function Q(e){N(e),S(e.id,e)}function fe(){let e=s();g(e),j(e.id),N(e)}function pe(){A&&(T(A),j(null),N(null))}let[me,he]=(0,W.useState)(!1),ge=te(e=>e.addQueryTab);function $(t){let n=R.getState().activeConnections.some(e=>e.id===t.id);if(O(t),ne.getState().removeTree(t.id),n){a(),j(null),N(null);return}ge(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),a(),j(null),N(null)}async function _e(t){let n=await ae(t.id,{interactive:!0});if(!n)return;let r={...t,file:n.fileName,serverConnectionId:n.connectionId};S(t.id,{file:n.fileName}),$(r),R.getState().setFileDetached(t.id,n.fileDetached),n.restoredUnsaved?C.getState().setFooterMessage(e(n.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:n.fileName})):n.wal&&!n.walApplied?C.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:n.fileName})):n.walApplied&&C.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:n.fileName}))}async function ve(t,n){try{return await n(t)}catch(r){let i=ee(r);if(!i||!(`ssh`in t)||!t.ssh||!await C.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,i),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw r;return n({...t,ssh:{...t.ssh,acceptHostKey:i.fingerprint}})}}async function ye(){if(M){he(!0);try{if(z(M)===`browser`){await _e(M);return}let t=await ve(F(M),e=>ie(e,M.authToken||void 0));t.success?$({...M,serverConnectionId:t.connectionId}):l({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){l({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{he(!1)}}}async function be(){if(M){if(z(M)===`browser`){l({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}f(!0);try{let t=await ve(F(M),e=>re(e,M.authToken||void 0));t.success?l({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)}):l({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){l({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{f(!1)}}}return(0,Y.jsx)(ue,{open:L,onOpenChange:X,children:(0,Y.jsxs)(ce,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,Y.jsx)(oe,{children:(0,Y.jsx)(le,{children:e(`connection.dialog.title`)})}),(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-catppuccin-green/40 bg-catppuccin-green/10 px-3 py-2 text-xs leading-relaxed text-foreground`,children:[(0,Y.jsx)(v,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,Y.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,Y.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(B||U)&&(0,Y.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,Y.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),B?` — ${B.name}`:``]}),U&&(0,Y.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:U})}),B?.profiles.map(t=>(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,Y.jsx)(_,{dbms:p[t.driver],className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t.name}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,Y.jsx)(D,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>J(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,Y.jsx)(t,{className:`h-full`,children:(0,Y.jsxs)(y,{className:`table-fixed`,children:[(0,Y.jsx)(o,{children:(0,Y.jsxs)(r,{children:[(0,Y.jsx)(b,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,Y.jsx)(b,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,Y.jsx)(b,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,Y.jsx)(x,{children:m.length===0?(0,Y.jsx)(r,{children:(0,Y.jsx)(c,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):m.map(t=>(0,Y.jsxs)(r,{"data-state":A===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>Z(t),onDoubleClick:()=>{Z(t),ye()},children:[(0,Y.jsx)(c,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,Y.jsx)(c,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:t.dbms===`do`?t.devUrl:`${t.user}@${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(z(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:t.dbms===`do`?t.devUrl||`—`:`${t.user}@${t.host}:${t.port}`}),(0,Y.jsx)(c,{className:`truncate`,title:V(t.dbms).label,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(_,{dbms:t.dbms,className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`truncate`,children:V(t.dbms).label})]})})]},t.id))})]})})]}),(0,Y.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:M?(0,Y.jsxs)(Y.Fragment,{children:[z(M)!==`browser`&&(0,Y.jsx)(`div`,{className:`p-4 pb-0`,children:(0,Y.jsx)(u,{})}),M.gatewayProfile?(0,Y.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,Y.jsx)(_,{dbms:M.dbms,className:`size-4`}),M.hostName]}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:M.gatewayProfile})}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[M.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),M.database?` · ${M.database}`:``]})]}):(0,Y.jsx)(de,{value:M,onChange:Q})]}):(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,Y.jsxs)(se,{className:`sm:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(D,{variant:`outline`,onClick:fe,children:e(`connection.dialog.addNew`)}),(0,Y.jsx)(D,{variant:`destructive`,onClick:pe,disabled:!A,children:e(`connection.dialog.delete`)})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(D,{variant:`outline`,onClick:be,disabled:!M||d,children:e(`connection.dialog.testConnection`)}),(0,Y.jsx)(D,{onClick:ye,disabled:!M||me,children:e(`connection.dialog.connect`)}),(0,Y.jsx)(D,{variant:`outline`,onClick:()=>X(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{fe as ConnectDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-C-Gt0g0g.js";import{h as r,n as i,t as a}from"./ui-store-5IssrgmG.js";import{l as o,m as s,t as c}from"./button-B2EsmMJs.js";import{t as l}from"./connection-store-BnO3WqEO.js";import{a as u}from"./database-BvWJHB7q.js";import{n as d}from"./engine-s5WfEr4n.js";import{c as f,p}from"./query-execution-CZvQYEUq.js";import{n as m,t as h}from"./table-copy-LtbDgIEc.js";import{a as g,i as _,n as v,o as y,t as b}from"./dialog-FBpgH0QJ.js";var x=e(r(),1),S=o();function C(){let{t:e}=s(),{activeDialog:r,closeDialog:o}=i(),C=a(`copy-database`),w=r===`copy-database`,T=C?.database??``,[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(`structure_data`),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(null);function P(e){e||(o(),N(null),j(null),D(``),k(`structure_data`))}async function F(){let t=l.getState().activeConnectionId,n=E.trim();if(!t||!n||!T)return;N(null);let r=d(t),i=l.getState().activeConnections.find(e=>e.id===t);if(i?.serverConnectionId)try{j(e(`database.copy.creating`,{database:n})),await f(t,r.getQuery(`CREATE_DATABASE`,n,`utf8mb4`,`utf8mb4_general_ci`));let a=u(i.serverConnectionId),o=await r.introspect.listTables(a,T);for(let[r,i]of o.entries()){j(e(`database.copy.copying`,{table:i.name,index:r+1,total:o.length}));let a={connectionId:t,database:T,table:i.name},s={connectionId:t,database:n,table:i.name},c=await h(a,s);await m({source:a,target:s,mode:O,onConflict:`abort`,createSql:d(t).ddl.createTable(c)})}await p(t),P(!1)}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(null)}}return(0,S.jsx)(b,{open:w,onOpenChange:P,children:(0,S.jsxs)(v,{className:`sm:max-w-[450px]`,children:[(0,S.jsx)(g,{children:(0,S.jsx)(y,{children:e(`database.copy.title`)})}),(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(t,{children:e(`database.copy.source`)}),(0,S.jsx)(n,{value:T,disabled:!0})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(t,{htmlFor:`target-db-name`,children:e(`database.copy.target`)}),(0,S.jsx)(n,{id:`target-db-name`,value:E,onChange:e=>D(e.target.value),placeholder:e(`database.copy.targetPlaceholder`)})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(t,{children:e(`database.copy.options`)}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_data`,checked:O===`structure_data`,onChange:()=>k(`structure_data`)}),e(`database.copy.structureAndData`)]}),(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_only`,checked:O===`structure_only`,onChange:()=>k(`structure_only`)}),e(`database.copy.structureOnly`)]})]})]})]}),A&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:A}),M&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:M}),(0,S.jsxs)(_,{children:[(0,S.jsx)(c,{variant:`outline`,onClick:()=>P(!1),children:e(`database.copy.cancel`)}),(0,S.jsx)(c,{onClick:()=>void F(),disabled:!E.trim()||A!==null,children:e(`database.copy.copy`)})]})]})})}export{C as CopyDatabaseDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,j as n,l as r}from"./main-C-Gt0g0g.js";import{h as i,n as a,t as ee}from"./ui-store-5IssrgmG.js";import{l as o,m as te,t as s}from"./button-B2EsmMJs.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-DwgCtoqv.js";import{t as ne}from"./connection-store-BnO3WqEO.js";import{a as re}from"./database-BvWJHB7q.js";import{n as p}from"./engine-s5WfEr4n.js";import{t as ie}from"./query-execution-CZvQYEUq.js";import{n as ae,t as oe}from"./table-copy-LtbDgIEc.js";import{a as m,i as se,n as ce,o as le,t as h}from"./dialog-FBpgH0QJ.js";var g=e(i(),1),_=o(),v=e=>e instanceof Error?e.message:String(e),y=e=>e.hostName||e.host||e.file||e.id,ue=`w-full rounded border bg-background px-2 py-1 text-xs font-mono outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 min-h-[160px] resize-y`;function b(){let{t:e}=te(),i=a(e=>e.activeDialog),o=a(e=>e.closeDialog),b=a(e=>e.showMessage),x=ee(`copy-table`),S=ne(e=>e.activeConnections),C=i===`copy-table`,w=x?.connectionId??``,T=String(x?.metadata?.database??``),E=x?.nodeText??``,D=S.find(e=>e.id===w),de=S.filter(e=>e.serverConnectionId),[O,k]=(0,g.useState)(w),[A,j]=(0,g.useState)([]),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(E),[I,L]=(0,g.useState)(`structure_data`),[R,z]=(0,g.useState)(`abort`),[B,V]=(0,g.useState)(``),[H,U]=(0,g.useState)(null),[W,G]=(0,g.useState)(null),[K,q]=(0,g.useState)(null),[J,Y]=(0,g.useState)(!1),X=(0,g.useRef)(null),Z=S.find(e=>e.id===O),Q=Z?p(O):null,fe=!!D&&!!Z&&p(w).id===Q?.id;(0,g.useEffect)(()=>{if(!C||!Z?.serverConnectionId)return;let e=!1,t=p(O),n=re(Z.serverConnectionId);return(async()=>{j([]);try{let r=await t.introspect.listDatabases(n);if(e)return;j(r);let i=O===w,a=i||r.includes(T)?T:r[0]??``;N(a),F(e=>i&&a===T&&e===E?`${E}_copy`:e)}catch(t){e||q(v(t))}})(),()=>{e=!0}},[C,O]),(0,g.useEffect)(()=>{if(!C||!Z||!M||!P.trim()||!D)return;let e=!1;return(async()=>{U(null);try{let t=await oe({connectionId:w,database:T,table:E},{connectionId:O,database:M,table:P.trim()});e||V(p(O).ddl.createTable(t))}catch(t){e||U(v(t))}})(),()=>{e=!0}},[C,O,M,P]);function $(e){if(!e){if(J){X.current?.abort();return}o()}}async function pe(){if(!M||!P.trim()||!B.trim())return;Y(!0),q(null),G({phase:`create`,copied:0,total:null});let t=new AbortController;X.current=t;try{let n=await ae({source:{connectionId:w,database:T,table:E},target:{connectionId:O,database:M,table:P.trim()},mode:I,onConflict:R,createSql:B},G,t.signal);o(),await b({title:e(`table.copy.doneTitle`),description:I===`structure_data`?e(`table.copy.doneRows`,{count:n.rows,table:P.trim()}):e(`table.copy.doneStructure`,{table:P.trim()}),tone:`success`})}catch(e){e instanceof ie||q(v(e)),G(null)}finally{Y(!1),X.current=null}}let me=W?.phase===`copy`&&W.total?Math.min(100,Math.round(W.copied/W.total*100)):null,he=W?W.phase===`create`?e(`table.copy.progressCreate`):W.phase===`count`?e(`table.copy.progressCount`):W.phase===`copy`?e(`table.copy.progressRows`,{copied:W.copied,total:W.total??`?`}):e(`table.copy.progressDone`):``;return(0,_.jsx)(h,{open:C,onOpenChange:$,children:(0,_.jsxs)(ce,{className:`sm:max-w-[640px]`,children:[(0,_.jsx)(m,{children:(0,_.jsx)(le,{children:e(`table.copy.title`)})}),(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{children:e(`table.copy.source`)}),(0,_.jsx)(r,{value:D?`${y(D)} / ${T} / ${E}`:``,disabled:!0})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-target-conn`,children:e(`table.copy.targetConnection`)}),(0,_.jsxs)(f,{value:O,onValueChange:k,disabled:J,children:[(0,_.jsx)(l,{id:`copy-target-conn`,className:`w-full`,children:(0,_.jsx)(c,{})}),(0,_.jsx)(u,{children:de.map(t=>(0,_.jsxs)(d,{value:t.id,children:[y(t),t.readOnly?` (${e(`table.copy.readOnly`)})`:``]},t.id))})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-target-db`,children:e(`table.copy.targetDatabase`)}),(0,_.jsxs)(f,{value:M,onValueChange:N,disabled:J||A.length===0,children:[(0,_.jsx)(l,{id:`copy-target-db`,className:`w-full`,children:(0,_.jsx)(c,{placeholder:e(`table.copy.loading`)})}),(0,_.jsx)(u,{children:A.map(e=>(0,_.jsx)(d,{value:e,children:e},e))})]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-target-table`,children:e(`table.copy.targetTable`)}),(0,_.jsx)(r,{id:`copy-target-table`,value:P,onChange:e=>F(e.target.value),disabled:J,spellCheck:!1})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{children:e(`table.copy.what`)}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_data`,onChange:()=>L(`structure_data`),disabled:J}),e(`table.copy.structureAndData`)]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_only`,onChange:()=>L(`structure_only`),disabled:J}),e(`table.copy.structureOnly`)]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{children:e(`table.copy.ifExists`)}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`abort`,onChange:()=>z(`abort`),disabled:J}),e(`table.copy.abort`)]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer text-destructive`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`drop`,onChange:()=>z(`drop`),disabled:J}),e(`table.copy.dropAndRecreate`)]})]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-ddl`,children:e(`table.copy.preview`)}),!fe&&Q&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`table.copy.crossEngineHint`,{engine:Q.label})}),(0,_.jsx)(`textarea`,{id:`copy-ddl`,className:ue,value:B,onChange:e=>V(e.target.value),disabled:J,spellCheck:!1}),H&&(0,_.jsx)(`p`,{className:`text-xs text-destructive`,children:H})]}),W&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(n,{value:me??(W.phase===`done`?100:0)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:he})]}),K&&(0,_.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:K})]}),(0,_.jsxs)(se,{children:[(0,_.jsx)(s,{variant:`outline`,onClick:()=>$(!1),children:e(J?`table.copy.stop`:`table.copy.cancel`)}),(0,_.jsx)(s,{onClick:()=>{pe()},disabled:J||!M||!P.trim()||!B.trim()||!!H,children:e(`table.copy.copy`)})]})]})})}export{b as CopyTableDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-C-Gt0g0g.js";import{h as r,n as i}from"./ui-store-5IssrgmG.js";import{l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-DwgCtoqv.js";import{t as p}from"./connection-store-BnO3WqEO.js";import{n as m}from"./engine-s5WfEr4n.js";import{c as h,p as g}from"./query-execution-CZvQYEUq.js";import{a as _,i as v,n as y,o as b,t as x}from"./dialog-FBpgH0QJ.js";var S=e(r(),1),C=a(),w=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],T={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function E(){let{t:e}=o(),{activeDialog:r,closeDialog:a}=i(),E=r===`create-database`,[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(`utf8mb4`),[j,M]=(0,S.useState)(`utf8mb4_general_ci`),[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(null);function L(e){e||(a(),I(null),O(``),A(`utf8mb4`),M(`utf8mb4_general_ci`))}function R(e){A(e);let t=T[e];M(t?.[0]??``)}async function z(){let e=p.getState().activeConnectionId,t=D.trim();if(!(!e||!t)){I(null),P(!0);try{let n=m(e).getQuery(`CREATE_DATABASE`,t,k,j);await h(e,n),await g(e),L(!1)}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}}}let B=T[k]??[];return(0,C.jsx)(x,{open:E,onOpenChange:L,children:(0,C.jsxs)(y,{className:`sm:max-w-[450px]`,children:[(0,C.jsx)(_,{children:(0,C.jsx)(b,{children:e(`database.create.title`)})}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(t,{htmlFor:`db-name`,children:e(`database.create.name`)}),(0,C.jsx)(n,{id:`db-name`,value:D,onChange:e=>O(e.target.value),placeholder:e(`database.create.namePlaceholder`)})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(t,{htmlFor:`db-charset`,children:e(`database.create.charset`)}),(0,C.jsxs)(f,{value:k,onValueChange:R,children:[(0,C.jsx)(l,{id:`db-charset`,className:`w-full`,children:(0,C.jsx)(c,{})}),(0,C.jsx)(u,{children:w.map(e=>(0,C.jsx)(d,{value:e,children:e},e))})]})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(t,{htmlFor:`db-collation`,children:e(`database.create.collation`)}),(0,C.jsxs)(f,{value:j,onValueChange:M,children:[(0,C.jsx)(l,{id:`db-collation`,className:`w-full`,children:(0,C.jsx)(c,{})}),(0,C.jsx)(u,{children:B.map(e=>(0,C.jsx)(d,{value:e,children:e},e))})]})]})]}),F&&(0,C.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:F}),(0,C.jsxs)(v,{children:[(0,C.jsx)(s,{variant:`outline`,onClick:()=>L(!1),children:e(`database.create.cancel`)}),(0,C.jsx)(s,{onClick:()=>void z(),disabled:!D.trim()||N,children:e(`database.create.create`)})]})]})})}export{E as CreateDatabaseDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-C-Gt0g0g.js";import{h as r,n as i,t as a}from"./ui-store-5IssrgmG.js";import{l as o,m as s,t as c}from"./button-B2EsmMJs.js";import{t as l}from"./connection-store-BnO3WqEO.js";import{n as u}from"./engine-s5WfEr4n.js";import{c as d,p as f}from"./query-execution-CZvQYEUq.js";import{a as p,i as m,n as h,o as g,t as _}from"./dialog-FBpgH0QJ.js";var v=e(r(),1),y=o();function b(){let{t:e}=s(),{activeDialog:r,closeDialog:o}=i(),b=a(`create-schema`),x=r===`create-schema`,[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(null);function O(e){e||(o(),C(``),D(null))}async function k(){let e=b?.connectionId??l.getState().activeConnectionId,t=S.trim();if(!(!e||!t)){D(null),T(!0);try{await d(e,u(e).getQuery(`CREATE_SCHEMA`,t)),await f(e),O(!1)}catch(e){D(e instanceof Error?e.message:String(e))}finally{T(!1)}}}return(0,y.jsx)(_,{open:x,onOpenChange:O,children:(0,y.jsxs)(h,{className:`sm:max-w-[420px]`,children:[(0,y.jsx)(p,{children:(0,y.jsx)(g,{children:e(`database.schema.createTitle`)})}),(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(t,{htmlFor:`schema-name`,children:e(`database.schema.name`)}),(0,y.jsx)(n,{id:`schema-name`,value:S,autoFocus:!0,placeholder:e(`database.schema.namePlaceholder`),onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k()}})]}),E&&(0,y.jsx)(`p`,{className:`text-xs text-destructive leading-relaxed`,children:E}),(0,y.jsxs)(m,{children:[(0,y.jsx)(c,{variant:`outline`,onClick:()=>O(!1),children:e(`database.schema.cancel`)}),(0,y.jsx)(c,{onClick:()=>void k(),disabled:!S.trim()||w,children:e(`database.schema.create`)})]})]})})}export{b as CreateSchemaDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{X as t,_ as n,c as r,g as i,h as a,z as o}from"./main-C-Gt0g0g.js";import{c as s,h as c,n as l,t as u}from"./ui-store-5IssrgmG.js";import{l as d,m as f,t as p}from"./button-B2EsmMJs.js";import{a as m,i as h,n as g,r as _,t as v}from"./select-DwgCtoqv.js";import{t as y}from"./connection-store-BnO3WqEO.js";import{a as b}from"./database-BvWJHB7q.js";import{n as x}from"./engine-s5WfEr4n.js";import{t as ee}from"./pro-usage-C661VD02.js";import{a as S,i as te,n as ne,o as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(c(),1),E=d(),D=e=>e instanceof Error?e.message:String(e),O=e=>e.hostName||e.host||e.file||e.id,k=5e4;function A({id:e,label:t,side:n,onChange:i,connections:a,disabled:o}){let{t:s}=f(),[c,l]=(0,T.useState)([]),[u,d]=(0,T.useState)([]),p=a.find(e=>e.id===n.connectionId);return(0,T.useEffect)(()=>{if(!p?.serverConnectionId)return;let e=!1;return(async()=>{try{let t=await x(p.id).introspect.listDatabases(b(p.serverConnectionId));if(e)return;l(t),t.includes(n.database)||i({connectionId:p.id,database:t[0]??``,table:``})}catch{e||l([])}})(),()=>{e=!0}},[p?.id,p?.serverConnectionId]),(0,T.useEffect)(()=>{if(!p?.serverConnectionId||!n.database)return;let e=!1;return(async()=>{try{let t=await x(p.id).introspect.listTables(b(p.serverConnectionId),n.database);if(e)return;let r=t.map(e=>e.name);d(r),n.table&&!r.includes(n.table)&&i({...n,table:``})}catch{e||d([])}})(),()=>{e=!0}},[p?.id,p?.serverConnectionId,n.database]),(0,E.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,E.jsx)(r,{className:`font-medium`,children:t}),(0,E.jsxs)(v,{value:n.connectionId,onValueChange:e=>i({connectionId:e,database:``,table:``}),disabled:o,children:[(0,E.jsx)(h,{id:`${e}-conn`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:s(`database.diff.pickConnection`)})}),(0,E.jsx)(g,{children:a.map(e=>(0,E.jsx)(_,{value:e.id,children:O(e)},e.id))})]}),(0,E.jsxs)(v,{value:n.database,onValueChange:e=>i({...n,database:e,table:``}),disabled:o||c.length===0,children:[(0,E.jsx)(h,{id:`${e}-db`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:s(`database.diff.pickDatabase`)})}),(0,E.jsx)(g,{children:c.map(e=>(0,E.jsx)(_,{value:e,children:e},e))})]}),(0,E.jsxs)(v,{value:n.table,onValueChange:e=>i({...n,table:e}),disabled:o||u.length===0,children:[(0,E.jsx)(h,{id:`${e}-table`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:s(`database.dataDiff.pickTable`)})}),(0,E.jsx)(g,{children:u.map(e=>(0,E.jsx)(_,{value:e,children:e},e))})]})]})}async function j(e,t){let n=await o({connectionId:e.connectionId,database:e.database,table:e.table,limit:k,onProgress:t}),r=[];for await(let e of n.pages)r.push(...e);return{rows:r,columns:n.fields.map(e=>e.name),capped:r.length>=k}}function M({diff:e,row:t,other:n,changed:r}){let{t:a}=f(),o=[...e.keyColumns,...e.compareColumns];return(0,E.jsxs)(`table`,{className:`w-full text-xs font-mono`,children:[(0,E.jsx)(`thead`,{className:`text-muted-foreground`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:a(`database.diff.column`)}),(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:a(`database.diff.source`)}),(0,E.jsx)(`th`,{className:`text-left font-normal`,children:a(`database.diff.target`)})]})}),(0,E.jsx)(`tbody`,{children:o.map(e=>(0,E.jsxs)(`tr`,{className:r?.includes(e)?`text-amber-600 dark:text-amber-400`:``,children:[(0,E.jsx)(`td`,{className:`pr-2 align-top whitespace-nowrap`,children:e}),(0,E.jsx)(`td`,{className:`pr-2 align-top break-all`,children:i(t[e])}),(0,E.jsx)(`td`,{className:`align-top break-all`,children:n?i(n[e]):`—`})]},e))})]})}function N(){let{t:e}=f(),r=l(e=>e.activeDialog),o=l(e=>e.closeDialog),c=u(`data-diff`),d=y(e=>e.activeConnections),m=(0,T.useMemo)(()=>d.filter(e=>e.serverConnectionId),[d]),h=y(e=>e.activeConnectionId),g=r===`data-diff`,[_,v]=(0,T.useState)(()=>c&&m.some(e=>e.id===c.connectionId)?{connectionId:c.connectionId,database:c.database,table:c.table}:{connectionId:h&&m.some(e=>e.id===h)?h:m[0]?.id??``,database:``,table:``}),[O,N]=(0,T.useState)(()=>({connectionId:m.find(e=>e.id!==_.connectionId)?.id??_.connectionId,database:``,table:``})),[P,re]=(0,T.useState)([]),[F,I]=(0,T.useState)(null),[ie,ae]=(0,T.useState)(!1),[L,R]=(0,T.useState)(`changed`),[z,B]=(0,T.useState)(0),[V,H]=(0,T.useState)(!1),[U,W]=(0,T.useState)(!1),[G,K]=(0,T.useState)({source:null,target:null}),[q,J]=(0,T.useState)(null),oe=e=>N(e.database&&!e.table&&_.table?{...e,table:_.table}:e),Y=_.connectionId===O.connectionId&&_.database===O.database&&_.table===O.table,se=!!_.table&&!!O.table&&!Y,X=O.connectionId?x(O.connectionId):null;async function ce(){W(!0),J(null),I(null);try{let t=y.getState().activeConnections.find(e=>e.id===_.connectionId);if(!t?.serverConnectionId)throw Error(e(`services.query.notConnected`));let r=await x(_.connectionId).introspect.getPrimaryKeys(b(t.serverConnectionId),_.database,_.table);if(r.length===0)throw Error(e(`database.dataDiff.noPrimaryKey`,{table:_.table}));K({source:{loaded:0,total:null},target:{loaded:0,total:null}});let[i,a]=await Promise.all([j(_,e=>K(t=>({...t,source:e}))),j(O,e=>K(t=>({...t,target:e})))]);if(r.some(e=>!a.columns.includes(e)))throw Error(e(`database.dataDiff.keyMissingInTarget`,{columns:r.join(`, `)}));let o=n(i.rows,a.rows,r,i.columns,a.columns);re(r),ae(i.capped||a.capped),I(o),R(o.changed.length>0?`changed`:o.added.length>0?`added`:`removed`),B(0),ee(`compare_data`),s(`data_diff`,{source_dbms:x(_.connectionId).id,target_dbms:X?.id??`unknown`,added:o.added.length,changed:o.changed.length,removed:o.removed.length})}catch(e){J(D(e))}finally{W(!1),K({source:null,target:null})}}let Z=e=>e?e.total===null?e.loaded.toLocaleString():`${e.loaded.toLocaleString()} / ${e.total.toLocaleString()}`:``,Q=(0,T.useMemo)(()=>F&&X?a(F,X,{database:O.database,table:O.table},{includeDeletes:V}):``,[F,X,O.database,O.table,V]);function le(){Q&&(t(O.connectionId,Q,O.database,e(`database.dataDiff.tabTitle`,{table:O.table})),o())}let $=F?L===`added`?F.added:L===`removed`?F.removed:F.changed.map(e=>e.source):[],ue=!!F&&F.added.length+F.changed.length+F.removed.length>0,de=e=>P.map(t=>i(e[t])).join(`, `);return(0,E.jsx)(w,{open:g,onOpenChange:e=>{e||o()},children:(0,E.jsxs)(ne,{className:`sm:max-w-[900px]`,children:[(0,E.jsx)(S,{children:(0,E.jsx)(C,{children:e(`database.dataDiff.title`)})}),(0,E.jsxs)(`div`,{className:`space-y-3`,children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,E.jsx)(A,{id:`ddiff-source`,label:e(`database.diff.source`),side:_,onChange:v,connections:m,disabled:U}),(0,E.jsx)(A,{id:`ddiff-target`,label:e(`database.diff.target`),side:O,onChange:oe,connections:m,disabled:U})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.dataDiff.hint`,{cap:k.toLocaleString()})}),Y&&_.table&&(0,E.jsx)(`p`,{className:`text-xs text-destructive`,children:e(`database.dataDiff.sameSide`)}),q&&(0,E.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:q}),U&&(G.source||G.target)&&(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.dataDiff.loading`,{source:Z(G.source),target:Z(G.target)})}),F&&(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e(`database.dataDiff.summary`,{key:P.join(`, `),added:F.added.length,changed:F.changed.length,removed:F.removed.length,identical:F.identical})}),ie&&(0,E.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:e(`database.dataDiff.capped`,{cap:k.toLocaleString()})}),(F.sourceOnlyColumns.length>0||F.targetOnlyColumns.length>0)&&(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e(`database.dataDiff.ignoredColumns`,{columns:[...F.sourceOnlyColumns,...F.targetOnlyColumns].join(`, `)})})]}),(0,E.jsx)(`div`,{className:`flex gap-1 text-xs`,children:[`added`,`changed`,`removed`].map(t=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>{R(t),B(0)},className:`rounded border px-2 py-0.5 ${L===t?`bg-accent`:``}`,children:e(`database.dataDiff.${t}`,{count:t===`added`?F.added.length:t===`removed`?F.removed.length:F.changed.length})},t))}),(0,E.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] gap-3 h-[280px]`,children:[(0,E.jsxs)(`ul`,{className:`overflow-auto rounded-md border text-sm font-mono`,children:[$.slice(0,2e3).map((e,t)=>(0,E.jsx)(`li`,{className:`px-2 py-1 cursor-pointer ${z===t?`bg-accent`:``}`,onClick:()=>B(t),children:de(e)},t)),$.length===0&&(0,E.jsx)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:e(`database.dataDiff.none`)}),$.length>2e3&&(0,E.jsx)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:e(`database.dataDiff.more`,{count:$.length-2e3})})]}),(0,E.jsx)(`div`,{className:`overflow-auto rounded-md border p-2`,children:$[z]?L===`changed`?(0,E.jsx)(M,{diff:F,row:F.changed[z].source,other:F.changed[z].target,changed:F.changed[z].columns}):L===`removed`?(0,E.jsx)(M,{diff:F,row:{},other:$[z]}):(0,E.jsx)(M,{diff:F,row:$[z]}):(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.diff.selectTable`)})})]}),(0,E.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:V,onChange:e=>H(e.target.checked)}),(0,E.jsx)(`span`,{className:V?`text-destructive`:``,children:e(`database.dataDiff.includeDeletes`)})]})]})]}),(0,E.jsxs)(te,{children:[(0,E.jsx)(p,{variant:`outline`,onClick:o,children:e(`database.diff.close`)}),(0,E.jsx)(p,{variant:`secondary`,onClick:()=>{ce()},disabled:!se||U,children:e(U?`database.diff.comparing`:`database.diff.compare`)}),(0,E.jsx)(p,{onClick:le,disabled:!ue,children:e(`database.diff.openScript`)})]})]})})}export{N as DataDiffDialog};
@@ -1,3 +1,3 @@
1
- import{c as e,h as t,n,t as r,v as i}from"./ui-store-DfspmPOn.js";import{P as a,R as o,l as s,u as c}from"./main-BLydvBDF.js";import{l,m as u,t as d}from"./button--s6nUzD8.js";import{a as f,i as p,n as m,r as h,t as g}from"./select-ibmUj7AE.js";import{t as _}from"./connection-store-N-ZwIkVg.js";import{r as v}from"./hmr-singleton-DWC1xbJ4.js";import{a as y}from"./database-CpQt6YGv.js";import{o as b}from"./dbms-BwnatOMe.js";import{n as x}from"./engine-CpwlM_Ww.js";import{n as S}from"./query-execution-4-JHu9gp.js";import{a as ee,i as te,n as ne,o as re,t as ie}from"./dialog-CJoWJzRo.js";import{t as C}from"./file-name-CnYBZPf9.js";var w=i(t(),1);function T(e,t){let n=e==null?``:typeof e==`object`?JSON.stringify(e):String(e);return!(typeof e==`number`||typeof e==`bigint`||/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(n))&&/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),n.includes(t)||n.includes(`"`)||n.includes(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,j as n,l as r,z as i}from"./main-C-Gt0g0g.js";import{c as a,h as o,n as s,t as c}from"./ui-store-5IssrgmG.js";import{l,m as u,t as d}from"./button-B2EsmMJs.js";import{a as f,i as p,n as m,r as h,t as g}from"./select-DwgCtoqv.js";import{t as _}from"./connection-store-BnO3WqEO.js";import{n as v}from"./query-store-dYiA8oM5.js";import{a as ee}from"./database-BvWJHB7q.js";import{o as y}from"./dbms-BwnatOMe.js";import{n as b}from"./engine-s5WfEr4n.js";import{n as x}from"./query-execution-CZvQYEUq.js";import{a as S,i as te,n as ne,o as re,t as ie}from"./dialog-FBpgH0QJ.js";import{t as C}from"./file-name-CnYBZPf9.js";var w=e(o(),1);function T(e,t){let n=e==null?``:typeof e==`object`?JSON.stringify(e):String(e);return!(typeof e==`number`||typeof e==`bigint`||/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(n))&&/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),n.includes(t)||n.includes(`"`)||n.includes(`
2
2
  `)||n.includes(`\r`)?`"${n.replace(/"/g,`""`)}"`:n}var E=(e,t)=>e.map(e=>T(e,t)).join(t)+`
3
- `,D=e=>e===` `,O=e=>D(e)?`TSV`:`CSV`,k=e=>D(e)?`.tsv`:`.csv`,A=e=>D(e)?`text/tab-separated-values`:`text/csv`;async function j(e,t){let n=C(e),r=A(t);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:n,types:[{description:O(t),accept:{[r]:[k(t)]}}]})).createWritable();return await e.write(``),{write:t=>e.write(t),finish:()=>e.close(),abort:()=>e.abort()}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw new M}let i=[``];return{write:async e=>{i.push(e)},finish:async()=>{let e=new Blob(i,{type:`${r};charset=utf-8;`}),t=URL.createObjectURL(e),a=document.createElement(`a`);a.href=t,a.download=n,a.click(),URL.revokeObjectURL(t)},abort:async()=>{i.length=0}}}var M=class extends Error{constructor(){super(`CSV export cancelled`)}};async function N(t){let n=await j(`${t.table}${k(t.delimiter)}`,t.delimiter),r=0;try{let i=await o({connectionId:t.connectionId,database:t.database,table:t.table,signal:t.signal,onProgress:t.onProgress}),a=i.fields.map(e=>e.name);t.includeHeaders&&await n.write(E(a,t.delimiter));for await(let e of i.pages)await n.write(e.map(e=>E(a.map(t=>e[t]),t.delimiter)).join(``)),r+=e.length;return await n.finish(),e(`export_csv`,{source:`table`,rows:r,format:O(t.delimiter)}),r}catch(e){throw await n.abort().catch(()=>void 0),e}}function P(t,n,r,i,a){let o=t.map(e=>e.name),s=[``];i&&s.push(E(o,r));for(let e of n)s.push(E(o.map(t=>e[t]),r));let c=new Blob(s,{type:`${A(r)};charset=utf-8;`}),l=URL.createObjectURL(c),u=document.createElement(`a`);u.href=l,u.download=C(a??`query_result${k(r)}`),u.click(),URL.revokeObjectURL(l),e(`export_csv`,{source:`result`,rows:n.length,format:O(r)})}var F=l(),I=[{value:`,`,label:`database.csv.delimiterComma`},{value:` `,label:`database.csv.delimiterTab`},{value:`;`,label:`database.csv.delimiterSemicolon`},{value:`|`,label:`database.csv.delimiterPipe`}];function L(){let{t:e}=u(),{activeDialog:t,closeDialog:i}=n(),o=r(`export-csv`),l=_(e=>e.activeConnectionId),C=v(),T=t===`export-csv`,[E,O]=(0,w.useState)(`query_result`),[k,A]=(0,w.useState)(``),[j,L]=(0,w.useState)([]),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(`,`),[H,U]=(0,w.useState)(!0),[W,G]=(0,w.useState)(!1),[K,q]=(0,w.useState)(null),[J,Y]=(0,w.useState)(null),X=(0,w.useRef)(null),Z=D(B)?`TSV`:`CSV`,Q=()=>{if(o?.nodeText&&(o.nodeType===b.TABLE||o.nodeType===b.VIEW)){let e=o.metadata?.database;return{table:o.nodeText,database:typeof e==`string`?e:``}}if(!l)return null;let e=(C.tabs[l]??[]).find(e=>e.id===C.activeTabId[l]);return e?.sourceTable?{table:e.sourceTable.table,database:e.sourceTable.database}:null};(0,w.useEffect)(()=>{if(!T)return;let e=Q();V(o?.delimiter??`,`),e&&(A(e.table),O(`table_data`))},[T]),(0,w.useEffect)(()=>{if(!T||!l)return;let e=_.getState().activeConnections.find(e=>e.id===l);if(!e?.serverConnectionId)return;let t=!1;return(async()=>{try{let n=await x(l).introspect.listDatabases(y(e.serverConnectionId));if(t)return;L(n);let r=C.tabs[l]?.find(e=>e.id===C.activeTabId[l])?.database||``,i=Q()?.database||``;z(e=>n.includes(i)?i:n.includes(e)?e:n.includes(r)?r:n.length===1?n[0]:``)}catch{t||L([])}})(),()=>{t=!0}},[T,l]);function $(e){if(!e){if(W){X.current?.abort();return}i(),O(`query_result`),A(``),V(`,`),U(!0)}}async function ae(){if(!l)return;if(Y(null),E===`query_result`){let e=C.activeTabId[l],t=(C.tabs[l]??[]).find(t=>t.id===e)?.results?.[0];if(!t||t.rows.length===0)return;P(t.fields,t.rows,B,H),i();return}if(!k.trim()||!R)return;let t=new AbortController;X.current=t,G(!0),q({loaded:0,total:null});try{let r=await N({connectionId:l,database:R,table:k.trim(),delimiter:B,includeHeaders:H,onProgress:q,signal:t.signal});n.getState().setFooterMessage(e(`database.csv.done`,{count:r,table:k.trim(),format:Z})),i()}catch(e){!(e instanceof M)&&!(e instanceof S&&t.signal.aborted)&&Y(e instanceof Error?e.message:String(e))}finally{G(!1),q(null),X.current=null}}let oe=K?.total?Math.min(100,Math.round(K.loaded/K.total*100)):null;return(0,F.jsx)(ie,{open:T,onOpenChange:$,children:(0,F.jsxs)(ne,{className:`sm:max-w-[450px]`,children:[(0,F.jsx)(ee,{children:(0,F.jsx)(re,{children:e(`database.csv.title`,{format:Z})})}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(s,{children:e(`database.csv.target`)}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`query_result`,checked:E===`query_result`,onChange:()=>O(`query_result`)}),e(`database.csv.targetQueryResult`)]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`table_data`,checked:E===`table_data`,onChange:()=>O(`table_data`)}),e(`database.csv.targetTableData`)]})]})]}),E===`table_data`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(s,{htmlFor:`csv-database`,children:e(`database.csv.database`)}),(0,F.jsxs)(g,{value:R,onValueChange:z,disabled:j.length===0,children:[(0,F.jsx)(p,{id:`csv-database`,className:`w-full`,children:(0,F.jsx)(f,{placeholder:e(`database.csv.databasePlaceholder`)})}),(0,F.jsx)(m,{children:j.map(e=>(0,F.jsx)(h,{value:e,children:e},e))})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(s,{htmlFor:`csv-table-name`,children:e(`database.csv.tableName`)}),(0,F.jsx)(c,{id:`csv-table-name`,value:k,onChange:e=>A(e.target.value),placeholder:e(`database.csv.tableNamePlaceholder`)})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(s,{htmlFor:`csv-delimiter`,children:e(`database.csv.delimiter`)}),(0,F.jsxs)(g,{value:B,onValueChange:V,children:[(0,F.jsx)(p,{id:`csv-delimiter`,className:`w-full`,children:(0,F.jsx)(f,{})}),(0,F.jsx)(m,{children:I.map(t=>(0,F.jsx)(h,{value:t.value,children:e(t.label)},t.value))})]})]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>U(e.target.checked)}),e(`database.csv.includeHeaders`)]})]}),K&&(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(a,{value:oe??0}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:K.total===null?e(`database.csv.progressUnknown`,{loaded:K.loaded}):e(`database.csv.progress`,{loaded:K.loaded,total:K.total})})]}),J&&(0,F.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:J}),(0,F.jsxs)(te,{children:[(0,F.jsx)(d,{variant:`outline`,onClick:()=>$(!1),children:e(W?`database.csv.stop`:`database.csv.cancel`)}),(0,F.jsx)(d,{onClick:ae,disabled:W||E===`table_data`&&!k.trim(),children:e(W?`database.csv.downloading`:`database.csv.download`)})]})]})})}export{L as DownloadToCSVDialog};
3
+ `,D=e=>e===` `,O=e=>D(e)?`TSV`:`CSV`,k=e=>D(e)?`.tsv`:`.csv`,A=e=>D(e)?`text/tab-separated-values`:`text/csv`;async function j(e,t){let n=C(e),r=A(t);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:n,types:[{description:O(t),accept:{[r]:[k(t)]}}]})).createWritable();return await e.write(``),{write:t=>e.write(t),finish:()=>e.close(),abort:()=>e.abort()}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw new M}let i=[``];return{write:async e=>{i.push(e)},finish:async()=>{let e=new Blob(i,{type:`${r};charset=utf-8;`}),t=URL.createObjectURL(e),a=document.createElement(`a`);a.href=t,a.download=n,a.click(),URL.revokeObjectURL(t)},abort:async()=>{i.length=0}}}var M=class extends Error{constructor(){super(`CSV export cancelled`)}};async function N(e){let t=await j(`${e.table}${k(e.delimiter)}`,e.delimiter),n=0;try{let r=await i({connectionId:e.connectionId,database:e.database,table:e.table,signal:e.signal,onProgress:e.onProgress}),o=r.fields.map(e=>e.name);e.includeHeaders&&await t.write(E(o,e.delimiter));for await(let i of r.pages)await t.write(i.map(t=>E(o.map(e=>t[e]),e.delimiter)).join(``)),n+=i.length;return await t.finish(),a(`export_csv`,{source:`table`,rows:n,format:O(e.delimiter)}),n}catch(e){throw await t.abort().catch(()=>void 0),e}}function P(e,t,n,r,i){let o=e.map(e=>e.name),s=[``];r&&s.push(E(o,n));for(let e of t)s.push(E(o.map(t=>e[t]),n));let c=new Blob(s,{type:`${A(n)};charset=utf-8;`}),l=URL.createObjectURL(c),u=document.createElement(`a`);u.href=l,u.download=C(i??`query_result${k(n)}`),u.click(),URL.revokeObjectURL(l),a(`export_csv`,{source:`result`,rows:t.length,format:O(n)})}var F=l(),I=[{value:`,`,label:`database.csv.delimiterComma`},{value:` `,label:`database.csv.delimiterTab`},{value:`;`,label:`database.csv.delimiterSemicolon`},{value:`|`,label:`database.csv.delimiterPipe`}];function L(){let{t:e}=u(),{activeDialog:i,closeDialog:a}=s(),o=c(`export-csv`),l=_(e=>e.activeConnectionId),C=v(),T=i===`export-csv`,[E,O]=(0,w.useState)(`query_result`),[k,A]=(0,w.useState)(``),[j,L]=(0,w.useState)([]),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(`,`),[H,U]=(0,w.useState)(!0),[W,G]=(0,w.useState)(!1),[K,q]=(0,w.useState)(null),[J,Y]=(0,w.useState)(null),X=(0,w.useRef)(null),Z=D(B)?`TSV`:`CSV`,Q=()=>{if(o?.nodeText&&(o.nodeType===y.TABLE||o.nodeType===y.VIEW)){let e=o.metadata?.database;return{table:o.nodeText,database:typeof e==`string`?e:``}}if(!l)return null;let e=(C.tabs[l]??[]).find(e=>e.id===C.activeTabId[l]);return e?.sourceTable?{table:e.sourceTable.table,database:e.sourceTable.database}:null};(0,w.useEffect)(()=>{if(!T)return;let e=Q();V(o?.delimiter??`,`),e&&(A(e.table),O(`table_data`))},[T]),(0,w.useEffect)(()=>{if(!T||!l)return;let e=_.getState().activeConnections.find(e=>e.id===l);if(!e?.serverConnectionId)return;let t=!1;return(async()=>{try{let n=await b(l).introspect.listDatabases(ee(e.serverConnectionId));if(t)return;L(n);let r=C.tabs[l]?.find(e=>e.id===C.activeTabId[l])?.database||``,i=Q()?.database||``;z(e=>n.includes(i)?i:n.includes(e)?e:n.includes(r)?r:n.length===1?n[0]:``)}catch{t||L([])}})(),()=>{t=!0}},[T,l]);function $(e){if(!e){if(W){X.current?.abort();return}a(),O(`query_result`),A(``),V(`,`),U(!0)}}async function ae(){if(!l)return;if(Y(null),E===`query_result`){let e=C.activeTabId[l],t=(C.tabs[l]??[]).find(t=>t.id===e)?.results?.[0];if(!t||t.rows.length===0)return;P(t.fields,t.rows,B,H),a();return}if(!k.trim()||!R)return;let t=new AbortController;X.current=t,G(!0),q({loaded:0,total:null});try{let n=await N({connectionId:l,database:R,table:k.trim(),delimiter:B,includeHeaders:H,onProgress:q,signal:t.signal});s.getState().setFooterMessage(e(`database.csv.done`,{count:n,table:k.trim(),format:Z})),a()}catch(e){!(e instanceof M)&&!(e instanceof x&&t.signal.aborted)&&Y(e instanceof Error?e.message:String(e))}finally{G(!1),q(null),X.current=null}}let oe=K?.total?Math.min(100,Math.round(K.loaded/K.total*100)):null;return(0,F.jsx)(ie,{open:T,onOpenChange:$,children:(0,F.jsxs)(ne,{className:`sm:max-w-[450px]`,children:[(0,F.jsx)(S,{children:(0,F.jsx)(re,{children:e(`database.csv.title`,{format:Z})})}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(t,{children:e(`database.csv.target`)}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`query_result`,checked:E===`query_result`,onChange:()=>O(`query_result`)}),e(`database.csv.targetQueryResult`)]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`table_data`,checked:E===`table_data`,onChange:()=>O(`table_data`)}),e(`database.csv.targetTableData`)]})]})]}),E===`table_data`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(t,{htmlFor:`csv-database`,children:e(`database.csv.database`)}),(0,F.jsxs)(g,{value:R,onValueChange:z,disabled:j.length===0,children:[(0,F.jsx)(p,{id:`csv-database`,className:`w-full`,children:(0,F.jsx)(f,{placeholder:e(`database.csv.databasePlaceholder`)})}),(0,F.jsx)(m,{children:j.map(e=>(0,F.jsx)(h,{value:e,children:e},e))})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(t,{htmlFor:`csv-table-name`,children:e(`database.csv.tableName`)}),(0,F.jsx)(r,{id:`csv-table-name`,value:k,onChange:e=>A(e.target.value),placeholder:e(`database.csv.tableNamePlaceholder`)})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(t,{htmlFor:`csv-delimiter`,children:e(`database.csv.delimiter`)}),(0,F.jsxs)(g,{value:B,onValueChange:V,children:[(0,F.jsx)(p,{id:`csv-delimiter`,className:`w-full`,children:(0,F.jsx)(f,{})}),(0,F.jsx)(m,{children:I.map(t=>(0,F.jsx)(h,{value:t.value,children:e(t.label)},t.value))})]})]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>U(e.target.checked)}),e(`database.csv.includeHeaders`)]})]}),K&&(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(n,{value:oe??0}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:K.total===null?e(`database.csv.progressUnknown`,{loaded:K.loaded}):e(`database.csv.progress`,{loaded:K.loaded,total:K.total})})]}),J&&(0,F.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:J}),(0,F.jsxs)(te,{children:[(0,F.jsx)(d,{variant:`outline`,onClick:()=>$(!1),children:e(W?`database.csv.stop`:`database.csv.cancel`)}),(0,F.jsx)(d,{onClick:ae,disabled:W||E===`table_data`&&!k.trim(),children:e(W?`database.csv.downloading`:`database.csv.download`)})]})]})})}export{L as DownloadToCSVDialog};
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,C as n,D as r,E as i,Nt as a,O as o,Q as s,S as c,T as l,W as u,Z as d,b as f,c as p,l as m,v as h,x as g,y as _}from"./main-C-Gt0g0g.js";import{h as v,n as y,t as ee}from"./ui-store-5IssrgmG.js";import{l as b,m as x,t as S}from"./button-B2EsmMJs.js";import{a as C,i as w,n as T,r as E,t as D}from"./select-DwgCtoqv.js";import{t as O}from"./connection-store-BnO3WqEO.js";import{a as te}from"./database-BvWJHB7q.js";import{n as k}from"./engine-s5WfEr4n.js";import{c as ne,f as re}from"./query-execution-CZvQYEUq.js";import{i as ie}from"./table-copy-LtbDgIEc.js";import{a as A,i as j,n as M,o as N,t as P}from"./dialog-FBpgH0QJ.js";var F=e(v(),1);function I(){return{id:crypto.randomUUID(),field:``,type:`varchar`,length:``,defaultValue:``,pk:!1,notNull:!1,unsigned:!1,autoIncrement:!1,zerofill:!1,comment:``}}function L(){return{id:crypto.randomUUID(),name:``,type:`INDEX`,columns:[]}}function R(){return{engine:`InnoDB`,charset:`utf8mb4`,collation:`utf8mb4_general_ci`,autoIncrement:``,comment:``}}function z(e,t,n,r,i){return{database:e,name:t,columns:n.map(e=>({name:e.field,type:e.type,length:e.length,defaultValue:e.defaultValue,primaryKey:e.pk,notNull:e.notNull,unsigned:e.unsigned,autoIncrement:e.autoIncrement,zerofill:e.zerofill,comment:e.comment})),indexes:r.map(e=>({name:e.name,type:e.type,columns:[...e.columns]})),options:{...i}}}var B=b(),V=`w-auto min-w-full [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0 [&_td]:p-0 [&_td]:h-8 [&_tr:nth-child(even)_td]:bg-muted/60 [&_tr:focus-within_td]:bg-primary/5`,H=`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:uppercase [&_th]:tracking-wide [&_th]:text-[11px]`,U=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none ring-0 focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary dark:bg-transparent`,W=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary data-[state=open]:bg-primary/10 dark:bg-transparent dark:hover:bg-transparent`;function ae({columns:e,onChange:r}){let{t:i}=x(),a=d().getDataTypes(),o=(0,F.useCallback)((t,n,i)=>{r(e.map(e=>e.id===t?{...e,[n]:i}:e))},[e,r]);function s(){r([...e,I()])}function l(){e.length>0&&r(e.slice(0,-1))}return(0,B.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,B.jsx)(t,{className:`flex-1`,children:(0,B.jsxs)(h,{className:V,children:[(0,B.jsx)(c,{className:H,children:(0,B.jsxs)(n,{children:[(0,B.jsx)(g,{className:`w-[120px]`,children:i(`table.schema.colField`)}),(0,B.jsx)(g,{className:`w-[120px]`,children:i(`table.schema.colType`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:i(`table.schema.colLength`)}),(0,B.jsx)(g,{className:`w-[100px]`,children:i(`table.schema.colDefault`)}),(0,B.jsx)(g,{className:`w-[40px]`,children:i(`table.schema.colPk`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:i(`table.schema.colNotNull`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:i(`table.schema.colUnsigned`)}),(0,B.jsx)(g,{className:`w-[70px]`,children:i(`table.schema.colAutoIncrement`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:i(`table.schema.colZerofill`)}),(0,B.jsx)(g,{children:i(`table.schema.colComment`)})]})}),(0,B.jsx)(_,{children:e.length===0?(0,B.jsx)(n,{children:(0,B.jsx)(f,{colSpan:10,className:`text-center text-muted-foreground`,children:i(`table.schema.empty`)})}):e.map(e=>(0,B.jsxs)(n,{children:[(0,B.jsx)(f,{children:(0,B.jsx)(m,{className:U,value:e.field,onChange:t=>o(e.id,`field`,t.target.value),placeholder:`column_name`})}),(0,B.jsx)(f,{children:(0,B.jsxs)(D,{value:e.type,onValueChange:t=>o(e.id,`type`,t),children:[(0,B.jsx)(w,{className:W,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:a.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})}),(0,B.jsx)(f,{children:(0,B.jsx)(m,{className:U,value:e.length,onChange:t=>o(e.id,`length`,t.target.value)})}),(0,B.jsx)(f,{children:(0,B.jsx)(m,{className:U,value:e.defaultValue,onChange:t=>o(e.id,`defaultValue`,t.target.value),placeholder:`NULL`})}),(0,B.jsx)(f,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.pk,onChange:t=>o(e.id,`pk`,t.target.checked)})}),(0,B.jsx)(f,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.notNull,onChange:t=>o(e.id,`notNull`,t.target.checked)})}),(0,B.jsx)(f,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.unsigned,onChange:t=>o(e.id,`unsigned`,t.target.checked)})}),(0,B.jsx)(f,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.autoIncrement,onChange:t=>o(e.id,`autoIncrement`,t.target.checked)})}),(0,B.jsx)(f,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.zerofill,onChange:t=>o(e.id,`zerofill`,t.target.checked)})}),(0,B.jsx)(f,{children:(0,B.jsx)(m,{className:U,value:e.comment,onChange:t=>o(e.id,`comment`,t.target.value)})})]},e.id))})]})}),(0,B.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:s,children:i(`table.schema.add`)}),(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:l,disabled:e.length===0,children:i(`table.schema.remove`)})]})]})}var G=[`PRIMARY`,`UNIQUE`,`INDEX`,`FULLTEXT`];function K({open:e,index:t,availableColumns:n,onSave:r,onClose:i}){let{t:a}=x(),[o,s]=(0,F.useState)(t.name),[c,l]=(0,F.useState)(t.type),[u,d]=(0,F.useState)(t.columns);function f(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function h(){r({id:t.id,name:c===`PRIMARY`?`PRIMARY`:o,type:c,columns:u})}return(0,B.jsx)(P,{open:e,onOpenChange:e=>{e||i()},children:(0,B.jsxs)(M,{className:`sm:max-w-[500px]`,children:[(0,B.jsx)(A,{children:(0,B.jsx)(N,{children:t.name?a(`table.index.editTitle`):a(`table.index.addTitle`)})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`idx-name`,children:a(`table.index.name`)}),(0,B.jsx)(m,{id:`idx-name`,value:c===`PRIMARY`?`PRIMARY`:o,onChange:e=>s(e.target.value),disabled:c===`PRIMARY`,placeholder:a(`table.index.namePlaceholder`)})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`idx-type`,children:a(`table.index.type`)}),(0,B.jsxs)(D,{value:c,onValueChange:e=>l(e),children:[(0,B.jsx)(w,{id:`idx-type`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:G.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{children:a(`table.index.columns`)}),(0,B.jsx)(`div`,{className:`border rounded-md p-2 max-h-[200px] overflow-y-auto space-y-1`,children:n.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`table.index.noColumns`)}):n.map(e=>(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:u.includes(e.field),onChange:()=>f(e.field)}),(0,B.jsx)(`span`,{children:e.field||a(`table.index.unnamed`)}),(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.type,`)`]})]},e.id))})]})]}),(0,B.jsxs)(j,{children:[(0,B.jsx)(S,{variant:`outline`,onClick:i,children:a(`table.index.cancel`)}),(0,B.jsx)(S,{onClick:h,disabled:u.length===0,children:a(`table.index.ok`)})]})]})})}function oe({indexes:e,availableColumns:r,onChange:i}){let{t:a}=x(),[o,s]=(0,F.useState)(null),[l,u]=(0,F.useState)(!1);function d(){let e=L();s(e),u(!0)}function p(e){s({...e}),u(!0)}function m(){e.length>0&&i(e.slice(0,-1))}function v(t){e.find(e=>e.id===t.id)?i(e.map(e=>e.id===t.id?t:e)):i([...e,t]),u(!1),s(null)}function y(){u(!1),s(null)}return(0,B.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,B.jsx)(t,{className:`flex-1`,children:(0,B.jsxs)(h,{className:V+` [&_td]:px-2`,children:[(0,B.jsx)(c,{className:H,children:(0,B.jsxs)(n,{children:[(0,B.jsx)(g,{className:`w-[150px]`,children:a(`table.indexes.colName`)}),(0,B.jsx)(g,{className:`w-[120px]`,children:a(`table.indexes.colType`)}),(0,B.jsx)(g,{children:a(`table.indexes.colColumns`)})]})}),(0,B.jsx)(_,{children:e.length===0?(0,B.jsx)(n,{children:(0,B.jsx)(f,{colSpan:3,className:`text-center text-muted-foreground`,children:a(`table.indexes.empty`)})}):e.map(e=>(0,B.jsxs)(n,{className:`cursor-pointer`,onDoubleClick:()=>p(e),children:[(0,B.jsx)(f,{children:e.name}),(0,B.jsx)(f,{children:e.type}),(0,B.jsx)(f,{children:e.columns.join(`, `)})]},e.id))})]})}),(0,B.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:d,children:a(`table.indexes.add`)}),(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:m,disabled:e.length===0,children:a(`table.indexes.remove`)})]}),o&&(0,B.jsx)(K,{open:l,index:o,availableColumns:r,onSave:v,onClose:y})]})}var q=[`InnoDB`,`MyISAM`,`MEMORY`,`CSV`,`ARCHIVE`,`BLACKHOLE`,`MRG_MYISAM`,`FEDERATED`,`PERFORMANCE_SCHEMA`],J=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],Y={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function se({properties:e,onChange:t}){let{t:n}=x();function r(n,r){let i={...e,[n]:r};n===`charset`&&(i.collation=Y[r]?.[0]??``),t(i)}let i=Y[e.charset]??[];return(0,B.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`prop-engine`,children:n(`table.properties.engine`)}),(0,B.jsxs)(D,{value:e.engine,onValueChange:e=>r(`engine`,e),children:[(0,B.jsx)(w,{id:`prop-engine`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:q.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`prop-charset`,children:n(`table.properties.charset`)}),(0,B.jsxs)(D,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,B.jsx)(w,{id:`prop-charset`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:J.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`prop-collation`,children:n(`table.properties.collation`)}),(0,B.jsxs)(D,{value:e.collation,onValueChange:e=>r(`collation`,e),children:[(0,B.jsx)(w,{id:`prop-collation`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:i.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`prop-auto-incr`,children:n(`table.properties.autoIncrement`)}),(0,B.jsx)(m,{id:`prop-auto-incr`,type:`number`,value:e.autoIncrement,onChange:e=>r(`autoIncrement`,e.target.value),placeholder:n(`table.properties.autoIncrementPlaceholder`)})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`prop-comment`,children:n(`table.properties.comment`)}),(0,B.jsx)(m,{id:`prop-comment`,value:e.comment,onChange:e=>r(`comment`,e.target.value)})]})]})}function ce({connectionId:e,database:t,tableName:n,columns:r,indexes:i,properties:o}){let c=u(e=>e.themeId),l=s(e),d=c===`light`||c===`light-blue`||c===`solarized-light`?`vs`:`vs-dark`,f=(0,F.useMemo)(()=>l.ddl.createTable(z(t,n,r,i,o)),[l,t,n,r,i,o]);return(0,B.jsx)(`div`,{className:`h-[320px]`,children:(0,B.jsx)(a,{height:`100%`,language:`sql`,theme:d,value:f,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:`on`,wordWrap:`on`}})})}function X(e){return JSON.stringify([e.type,e.length,e.defaultValue,e.pk,e.notNull,e.unsigned,e.autoIncrement,e.zerofill,e.comment])}function Z(e){return{name:e.field,type:e.length?`${e.type}(${e.length})`:e.type,nullable:!e.notNull,key:e.pk?`PRI`:``,defaultValue:e.defaultValue===``?null:e.defaultValue,extra:e.autoIncrement?`auto_increment`:``,comment:e.comment,collation:null}}function Q(e){return{name:e.name,type:e.type,columns:[...e.columns]}}function $(e,t){return e.name===t.name&&e.type===t.type&&e.columns.join(`,`)===t.columns.join(`,`)}function le({engine:e,database:t,table:n,before:r,after:i}){let{ddl:a}=e,o=[],s=[],c=[],l=new Map(r.columns.map(e=>[e.id,e])),u=new Map(i.columns.map(e=>[e.id,e])),d=new Map(r.indexes.map(e=>[e.id,e])),f=new Map(i.indexes.map(e=>[e.id,e])),p=[];for(let[e,r]of d){let i=f.get(e);i?$(r,i)||(o.push(a.dropIndex(t,n,r.name)),p.push(i)):o.push(a.dropIndex(t,n,r.name))}for(let[e,r]of u){let i=l.get(e);if(!i){r.field.trim()&&o.push(a.addColumn(t,n,Z(r)));continue}if(i.field!==r.field&&o.push(a.renameColumn(t,n,i.field,r.field)),X(i)!==X(r)){let e=a.alterColumn(t,n,Z(r));e?o.push(e):c.push(r.field)}}for(let[e,r]of l)if(!u.has(e)){let e=a.dropColumn(t,n,r.field);o.push(e),s.push(e)}for(let e of p)o.push(a.createIndex(t,n,Q(e)));for(let[e,r]of f)!d.has(e)&&r.columns.length>0&&o.push(a.createIndex(t,n,Q(r)));return{statements:o,destructive:s,unsupported:c}}function ue(){let{t:e}=x(),{activeDialog:t,closeDialog:n}=y(),a=ee(`create-table`,`alter-table`,`duplicate-table-structure`),c=t===`create-table`||t===`alter-table`||t===`duplicate-table-structure`,u=t===`alter-table`,d=t===`duplicate-table-structure`,f=a?.nodeText??``,h=a?.metadata?.database??``,[g,_]=(0,F.useState)(``),[v,b]=(0,F.useState)([I()]),[C,w]=(0,F.useState)([]),[T,E]=(0,F.useState)(R()),[D,L]=(0,F.useState)(!1),[V,H]=(0,F.useState)(!1),[U,W]=(0,F.useState)(null),[G,K]=(0,F.useState)(null),q=a?.connectionId??O.getState().activeConnectionId,J=s(q);(0,F.useEffect)(()=>{c&&(W(null),K(null),u||d?(_(d?`${f}_copy`:f),Y()):(_(``),b([I()]),w([]),E(R())))},[c,t]);async function Y(){let e=O.getState(),t=a?.connectionId??e.activeConnectionId,n=e.activeConnections.find(e=>e.id===t)?.serverConnectionId;if(!n||!h||!f)return;L(!0);let{introspect:r,capabilities:i}=k(t),o=te(n);try{let e=await r.listColumns(o,h,f),t=[];if(e.length>0){let n=e.map(e=>{let t=e.type,n=t.match(/^(\w+)(?:\(([^)]+)\))?/);return{id:crypto.randomUUID(),field:e.name,type:n?.[1]?.toLowerCase()??t.toLowerCase(),length:n?.[2]??``,defaultValue:e.defaultValue??``,pk:e.key===`PRI`,notNull:!e.nullable,unsigned:t.includes(`unsigned`),autoIncrement:e.extra.includes(`auto_increment`),zerofill:t.includes(`zerofill`),comment:e.comment}});b(n),t=n}let n=await r.listIndexes(o,h,f),a=[];if(n.length>0&&(a=n.map(e=>({id:crypto.randomUUID(),name:e.name,type:e.type===`SPATIAL`?`INDEX`:e.type,columns:[...e.columns]})),w(a)),K({columns:t,indexes:a}),i.tableProperties){let e=await r.getTableInfo(o,h,f);e&&E({engine:e.engine??`InnoDB`,charset:(e.collation??`utf8mb4`).replace(/_.*/,``),collation:e.collation??`utf8mb4_unicode_ci`,autoIncrement:e.autoIncrement??``,comment:e.comment})}}catch(e){console.error(`Failed to load table schema:`,e),W(e instanceof Error?e.message:String(e))}finally{L(!1)}}function X(e){e||n()}async function Z(){let t=a?.connectionId??O.getState().activeConnectionId;if(!t||!g.trim())return;let r=k(t);W(null);let i,o=[];if(u){if(!G)return;let t=le({engine:r,database:h,table:f,before:G,after:{columns:v,indexes:C}});if(t.unsupported.length>0){W(e(`table.dialog.cannotAlterColumns`,{engine:r.label,columns:t.unsupported.join(`, `)}));return}if(t.statements.length===0){n();return}i=t.statements.join(`
2
+ `),o=t.destructive}else{let e=d?C.map(e=>({...e,name:ie(e.name,f,g.trim())})):C;i=r.ddl.createTable(z(h,g.trim(),v,e,T))}H(!0);try{await ne(t,i,{skipDestructiveConfirm:o.length===0}),await re(t,h),n()}catch(e){W(e instanceof Error?e.message:String(e))}finally{H(!1)}}let Q=e(u?`table.dialog.alterTitle`:d?`table.dialog.duplicateTitle`:`table.dialog.createTitle`),$=e(u?`table.dialog.alter`:`table.dialog.create`);return(0,B.jsx)(P,{open:c,onOpenChange:X,children:(0,B.jsxs)(M,{className:`sm:max-w-[1000px] max-h-[80vh] flex flex-col`,children:[(0,B.jsx)(A,{children:(0,B.jsx)(N,{children:Q})}),(0,B.jsxs)(`div`,{className:`space-y-3 flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5 px-1`,children:[(0,B.jsx)(p,{htmlFor:`table-name`,children:e(`table.dialog.tableName`)}),(0,B.jsx)(m,{id:`table-name`,value:g,onChange:e=>_(e.target.value),placeholder:e(`table.dialog.tableNamePlaceholder`),disabled:u})]}),D?(0,B.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:e(`table.dialog.loading`)}):(0,B.jsxs)(l,{defaultValue:`schema`,className:`flex-1 min-h-0 flex flex-col`,children:[(0,B.jsxs)(r,{children:[(0,B.jsx)(o,{value:`schema`,children:e(`table.dialog.tabSchema`)}),(0,B.jsx)(o,{value:`indexes`,children:e(`table.dialog.tabIndexes`)}),J.capabilities.tableProperties&&(0,B.jsx)(o,{value:`properties`,children:e(`table.dialog.tabProperties`)}),(0,B.jsx)(o,{value:`sql`,children:`SQL`})]}),(0,B.jsx)(i,{value:`schema`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,B.jsx)(ae,{columns:v,onChange:b})}),(0,B.jsx)(i,{value:`indexes`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,B.jsx)(oe,{indexes:C,availableColumns:v,onChange:w})}),(0,B.jsx)(i,{value:`properties`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,B.jsx)(se,{properties:T,onChange:E})}),(0,B.jsx)(i,{value:`sql`,className:`flex-1 min-h-0 border rounded-md`,children:(0,B.jsx)(ce,{connectionId:q,database:h,tableName:g,columns:v,indexes:C,properties:T})})]})]}),U&&(0,B.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:U}),(0,B.jsxs)(j,{children:[(0,B.jsx)(S,{variant:`outline`,onClick:()=>X(!1),children:e(`table.dialog.cancel`)}),(0,B.jsx)(S,{onClick:()=>void Z(),disabled:D||V||!g.trim(),children:V?e(`table.dialog.applying`):$})]})]})})}export{ue as EditSchemaDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Dt as t,c as n,l as r}from"./main-C-Gt0g0g.js";import{h as i,n as a}from"./ui-store-5IssrgmG.js";import{i as o,l as s,m as c,t as l}from"./button-B2EsmMJs.js";import{t as u}from"./chevron-up-CBnVjNE1.js";import{t as d}from"./connection-store-BnO3WqEO.js";import{n as f}from"./query-store-dYiA8oM5.js";import{n as p,o as m,s as h,t as g}from"./editor-registry-ukUyoekH.js";var _=e(i(),1),v=s();function y(){let{t:e}=c(),{activeDialog:i,closeDialog:s}=a(),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(!1),[k,A]=(0,_.useState)(0),j=d(e=>e.activeConnectionId)??``,M=f(e=>j?e.activeTabId[j]:void 0)??``;if(i!==`find-replace`)return null;let N={query:y,caseSensitive:C,regex:T,wholeWord:D},P=j!==``&&M!==``&&y!==``;function F(){s()}function I(){A(P?p(j,M,N,`next`):0)}function L(){A(P?p(j,M,N,`prev`):0)}function R(){P&&A(h(j,M,N,x))}function z(){P&&(m(j,M,N,x),A(g(j,M,N)))}return(0,v.jsxs)(`div`,{className:`fixed top-12 right-4 z-50 bg-background border rounded-md shadow-lg p-3 w-[400px] space-y-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(r,{placeholder:e(`command.findReplace.findPlaceholder`),value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.shiftKey?L():I()),e.key===`Escape`&&F()},className:`flex-1 h-7 text-sm`,autoFocus:!0}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap min-w-[60px] text-center`,children:k>0?e(`command.findReplace.found`,{count:k}):e(`command.findReplace.noResults`)}),(0,v.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:L,title:e(`command.findReplace.previous`),children:(0,v.jsx)(u,{className:`h-4 w-4`})}),(0,v.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:I,title:e(`command.findReplace.next`),children:(0,v.jsx)(t,{className:`h-4 w-4`})}),(0,v.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:F,title:e(`command.findReplace.close`),children:(0,v.jsx)(o,{className:`h-4 w-4`})})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(r,{placeholder:e(`command.findReplace.replacePlaceholder`),value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Escape`&&F()},className:`flex-1 h-7 text-sm`}),(0,v.jsx)(l,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:R,children:e(`command.findReplace.replace`)}),(0,v.jsx)(l,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:z,children:e(`command.findReplace.all`)})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,v.jsxs)(n,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.caseSensitive`)]}),(0,v.jsxs)(n,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:T,onChange:e=>E(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.regex`)]}),(0,v.jsxs)(n,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:D,onChange:e=>O(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.wholeWord`)]})]})]})}export{y as FindReplaceDialog};