-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
7958 lines (7307 loc) · 285 KB
/
Copy pathapp.js
File metadata and controls
7958 lines (7307 loc) · 285 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const bootOverlay = document.getElementById("boot-overlay");
const form = document.getElementById("launch-form");
const launchSurfaceCard = form ? form.querySelector(".launch-surface") : null;
const output = document.getElementById("output");
const statusNode = document.getElementById("status");
const metaNode = document.getElementById("meta");
const outputSection = document.getElementById("output-section");
const reportsTerminalSection = document.getElementById("reports-terminal-section");
const reportsTerminalList = document.getElementById("reports-terminal-list");
const reportsTerminalOutput = document.getElementById("reports-terminal-output");
const reportsTerminalMeta = document.getElementById("reports-terminal-meta");
const reportsTerminalResizeHandle = document.getElementById("reports-terminal-resize-handle");
const launchdeckHostBanner = document.getElementById("launchdeck-host-banner");
const benchmarksPopoutModal = document.getElementById("benchmarks-popout-modal");
const benchmarksPopoutTitle = document.getElementById("benchmarks-popout-title");
const benchmarksPopoutClose = document.getElementById("benchmarks-popout-close");
const benchmarksPopoutBody = document.getElementById("benchmarks-popout-body");
const buttons = Array.from(document.querySelectorAll("[data-action]"));
const shellMain = document.querySelector(".shell");
const workspaceShell = document.querySelector(".workspace-shell");
const walletBox = document.querySelector(".wallet-box");
const walletSelect = document.getElementById("wallet-select");
const walletBalance = document.getElementById("wallet-balance");
const walletTriggerButton = document.getElementById("wallet-trigger-button");
const walletDropdown = document.getElementById("wallet-dropdown");
const walletDropdownList = document.getElementById("wallet-dropdown-list");
const walletRefreshButton = document.getElementById("wallet-refresh-button");
const walletSummarySol = document.getElementById("wallet-summary-sol");
const walletSummaryUsd = document.getElementById("wallet-summary-usd");
const topPresetChipBar = document.getElementById("top-preset-chip-bar");
const openVampButton = document.getElementById("open-vamp-button");
const themeToggleButton = document.getElementById("toggle-theme-button");
const themeToggleSunIcon = themeToggleButton ? themeToggleButton.querySelector(".theme-icon-sun") : null;
const themeToggleMoonIcon = themeToggleButton ? themeToggleButton.querySelector(".theme-icon-moon") : null;
const feeSplitPill = document.getElementById("fee-split-pill");
const feeSplitPillTitle = document.getElementById("fee-split-pill-title");
const feeSplitPillProgress = document.getElementById("fee-split-pill-progress");
const imageInput = document.getElementById("image-input");
const openImageLibraryButton = document.getElementById("open-image-library-button");
const j7OpenImageLibraryButton = document.getElementById("j7-open-image-library-button");
const imageLayoutToggle = document.getElementById("image-layout-toggle");
const editSelectedImageButton = document.getElementById("edit-selected-image-button");
const tokenSurfaceSection = document.getElementById("token-surface-section");
const imagePreview = document.getElementById("image-preview");
const imageEmpty = document.getElementById("image-empty");
const imageStatus = document.getElementById("image-status");
const imagePath = document.getElementById("image-path");
const j7ImageCandidates = document.getElementById("j7-image-candidates");
const imageLibraryModal = document.getElementById("image-library-modal");
const imageLibraryClose = document.getElementById("image-library-close");
const imageLibrarySearchInput = document.getElementById("image-library-search-input");
const imageLibraryUploadButton = document.getElementById("image-library-upload-button");
const imageLibraryGrid = document.getElementById("image-library-grid");
const imageLibraryEmpty = document.getElementById("image-library-empty");
const imageCategoryChips = document.getElementById("image-category-chips");
const newImageCategoryButton = document.getElementById("new-image-category-button");
const imageItemMenu = document.getElementById("image-item-menu");
const imageMenuFavorite = document.getElementById("image-menu-favorite");
const imageMenuCrop = document.getElementById("image-menu-crop");
const imageMenuEdit = document.getElementById("image-menu-edit");
const imageMenuDelete = document.getElementById("image-menu-delete");
const imageDetailsModal = document.getElementById("image-details-modal");
const imageDetailsTitle = document.getElementById("image-details-title");
const imageDetailsClose = document.getElementById("image-details-close");
const imageDetailsCancel = document.getElementById("image-details-cancel");
const imageDetailsSave = document.getElementById("image-details-save");
const imageDetailsName = document.getElementById("image-details-name");
const imageDetailsTags = document.getElementById("image-details-tags");
const imageDetailsAddTag = document.getElementById("image-details-add-tag");
const imageDetailsTagList = document.getElementById("image-details-tag-list");
const imageDetailsError = document.getElementById("image-details-error");
const imageDetailsCategoryRow = document.getElementById("image-details-category-row");
const imageDetailsCategory = document.getElementById("image-details-category");
const imageDetailsNewCategory = document.getElementById("image-details-new-category");
const imageCategoryModal = document.getElementById("image-category-modal");
const imageCategoryClose = document.getElementById("image-category-close");
const imageCategoryCancel = document.getElementById("image-category-cancel");
const imageCategorySave = document.getElementById("image-category-save");
const imageCategoryName = document.getElementById("image-category-name");
const imageCategoryError = document.getElementById("image-category-error");
const metadataUri = document.getElementById("metadata-uri");
const nameInput = form.querySelector('[name="name"]');
const symbolInput = form.querySelector('[name="symbol"]');
const descriptionInput = form.querySelector('[name="description"]');
const websiteInput = form.querySelector('[name="website"]');
const twitterInput = form.querySelector('[name="twitter"]');
const telegramInput = form.querySelector('[name="telegram"]');
const descriptionDisclosure = document.getElementById("description-disclosure");
const descriptionToggle = document.getElementById("description-toggle");
const descriptionPanelBody = document.getElementById("description-panel-body");
const descriptionCharCount = document.getElementById("description-char-count");
const nameCharCount = document.getElementById("name-char-count");
const symbolCharCount = document.getElementById("symbol-char-count");
const tickerCapsToggle = document.getElementById("ticker-caps-toggle");
const namePresetStrip = document.getElementById("name-preset-strip");
const namePresetModal = document.getElementById("name-preset-modal");
const namePresetClose = document.getElementById("name-preset-close");
const namePresetEditorList = document.getElementById("name-preset-editor-list");
const namePresetFormActions = document.querySelector(".name-preset-form-actions");
const namePresetAddButton = document.getElementById("name-preset-add");
const namePresetCancelEditButton = document.getElementById("name-preset-cancel-edit");
const namePresetUpdateButton = document.getElementById("name-preset-update");
const namePresetFormTitle = document.getElementById("name-preset-form-title");
const namePresetNewName = document.getElementById("name-preset-new-name");
const namePresetNewNamePrefix = document.getElementById("name-preset-new-name-prefix");
const namePresetNewNameSuffix = document.getElementById("name-preset-new-name-suffix");
const namePresetNewTickerPrefix = document.getElementById("name-preset-new-ticker-prefix");
const namePresetNewTickerSuffix = document.getElementById("name-preset-new-ticker-suffix");
const namePresetNewFirstWord = document.getElementById("name-preset-new-first-word");
const namePresetNewAbbreviate = document.getElementById("name-preset-new-abbreviate");
const namePresetError = document.getElementById("name-preset-error");
const devBuyModeInput = getNamedInput("devBuyMode");
const devBuyAmountInput = getNamedInput("devBuyAmount");
const postLaunchStrategyInput = getNamedInput("postLaunchStrategy");
const snipeBuyAmountInput = getNamedInput("snipeBuyAmountSol");
const sniperEnabledInput = getNamedInput("sniperEnabled");
const sniperConfigJsonInput = getNamedInput("sniperConfigJson");
const vanityPrivateKeyInput = getNamedInput("vanityPrivateKey");
const devBuyQuickButtons = document.getElementById("dev-buy-quick-buttons");
const changeDevBuyPresetsButton = document.getElementById("change-dev-buy-presets-button");
const cancelDevBuyPresetsButton = document.getElementById("cancel-dev-buy-presets-button");
const saveDevBuyPresetsButton = document.getElementById("save-dev-buy-presets-button");
const devBuySolInput = document.getElementById("dev-buy-sol-input");
const devBuyPercentInput = document.getElementById("dev-buy-percent-input");
const devBuyCustomDeployButton = document.getElementById("dev-buy-custom-deploy");
const quoteOutput = document.getElementById("quote-output");
const bonkQuoteAssetInput = getNamedInput("quoteAsset");
const bonkQuoteAssetToggle = document.getElementById("bonk-quote-asset-toggle");
const bonkQuoteAssetToggleSolIcon = document.getElementById("bonk-quote-asset-toggle-sol-icon");
const bonkQuoteAssetToggleUsd1Icon = document.getElementById("bonk-quote-asset-toggle-usd1-icon");
const bonkQuoteAssetToggleUsdcIcon = document.getElementById("bonk-quote-asset-toggle-usdc-icon");
const devBuyQuotePrefixIcon = document.getElementById("dev-buy-quote-prefix-icon");
const devBuyQuotePrefixText = document.getElementById("dev-buy-quote-prefix-text");
const creationTipInput = document.getElementById("creation-tip-input");
const creationPriorityInput = document.getElementById("creation-priority-input");
const creationMevModeSelect = document.getElementById("creation-mev-mode-select");
const creationAutoFeeInput = document.getElementById("creation-auto-fee-input");
const creationAutoFeeButton = document.getElementById("creation-auto-fee-button");
const creationMaxFeeInput = document.getElementById("creation-max-fee-input");
const launchpadInputs = Array.from(document.querySelectorAll('input[name="launchpad"]'));
const providerSelect = document.getElementById("provider-select");
const buyProviderSelect = document.getElementById("buy-provider-select");
const sellProviderSelect = document.getElementById("sell-provider-select");
const settingsBackendRegionSummary = document.getElementById("settings-backend-region-summary");
const platformRuntimeIndicators = document.getElementById("platform-runtime-indicators");
const buyPriorityFeeInput = document.getElementById("buy-priority-fee-input");
const buyTipInput = document.getElementById("buy-tip-input");
const buySlippageInput = document.getElementById("buy-slippage-input");
const buyMevModeSelect = document.getElementById("buy-mev-mode-select");
const buyAutoFeeInput = document.getElementById("buy-auto-fee-input");
const buyAutoFeeButton = document.getElementById("buy-auto-fee-button");
const buyMaxFeeInput = document.getElementById("buy-max-fee-input");
const buyHelloMoonMevWarning = document.getElementById("buy-hellomoon-mev-warning");
const buyStandardRpcWarning = document.getElementById("buy-standard-rpc-warning");
const sellPriorityFeeInput = document.getElementById("sell-priority-fee-input");
const sellTipInput = document.getElementById("sell-tip-input");
const sellSlippageInput = document.getElementById("sell-slippage-input");
const sellMevModeSelect = document.getElementById("sell-mev-mode-select");
const sellAutoFeeInput = document.getElementById("sell-auto-fee-input");
const sellAutoFeeButton = document.getElementById("sell-auto-fee-button");
const sellMaxFeeInput = document.getElementById("sell-max-fee-input");
const sellHelloMoonMevWarning = document.getElementById("sell-hellomoon-mev-warning");
const sellStandardRpcWarning = document.getElementById("sell-standard-rpc-warning");
const settingsPresetChipBar = document.getElementById("settings-preset-chip-bar");
const presetEditToggle = document.getElementById("preset-edit-toggle");
const agentUnlockedAuthority = document.getElementById("agent-unlocked-authority");
const agentSplitList = document.getElementById("agent-split-list");
const agentSplitAdd = document.getElementById("agent-split-add");
const agentSplitReset = document.getElementById("agent-split-reset");
const agentSplitEven = document.getElementById("agent-split-even");
const agentSplitClearAll = document.getElementById("agent-split-clear-all");
const agentSplitTotal = document.getElementById("agent-split-total");
const agentSplitBar = document.getElementById("agent-split-bar");
const agentSplitLegendList = document.getElementById("agent-split-legend-list");
const agentSplitModal = document.getElementById("agent-split-modal");
const agentSplitClose = document.getElementById("agent-split-close");
const agentSplitCancel = document.getElementById("agent-split-cancel");
const agentSplitSave = document.getElementById("agent-split-save");
const agentSplitModalError = document.getElementById("agent-split-modal-error");
const agentSplitTitle = document.getElementById("agent-split-title");
const feeSplitEnabled = form.querySelector('[name="feeSplitEnabled"]');
const feeSplitList = document.getElementById("fee-split-list");
const feeSplitAdd = document.getElementById("fee-split-add");
const feeSplitReset = document.getElementById("fee-split-reset");
const feeSplitEven = document.getElementById("fee-split-even");
const feeSplitClearAll = document.getElementById("fee-split-clear-all");
const feeSplitTotal = document.getElementById("fee-split-total");
const feeSplitBar = document.getElementById("fee-split-bar");
const feeSplitLegendList = document.getElementById("fee-split-legend-list");
const feeSplitModal = document.getElementById("fee-split-modal");
const feeSplitClose = document.getElementById("fee-split-close");
const feeSplitDisable = document.getElementById("fee-split-disable");
const feeSplitSave = document.getElementById("fee-split-save");
const feeSplitModalError = document.getElementById("fee-split-modal-error");
const feeSplitTitle = document.getElementById("fee-split-title");
const feeSplitIntro = document.getElementById("fee-split-intro");
const feeSplitRecipientsCopy = document.getElementById("fee-split-recipients-copy");
const bagsFeeSplitSummary = document.getElementById("bags-fee-split-summary");
const feeSplitSummaryPrimaryLabel = document.getElementById("fee-split-summary-primary-label");
const feeSplitSummarySecondaryLabel = document.getElementById("fee-split-summary-secondary-label");
const bagsFeeSplitCreatorShare = document.getElementById("bags-fee-split-creator-share");
const bagsFeeSplitSharedShare = document.getElementById("bags-fee-split-shared-share");
const bagsFeeSplitValidationCopy = document.getElementById("bags-fee-split-validation-copy");
const deployModal = document.getElementById("deploy-modal");
const modalBody = document.getElementById("modal-body");
const modalClose = document.getElementById("modal-close");
const modalCancel = document.getElementById("modal-cancel");
const modalConfirm = document.getElementById("modal-confirm");
const testFillButton = document.getElementById("test-fill-button");
const openPopoutButton = document.getElementById("open-popout-button");
const toggleOutputButton = document.getElementById("toggle-output-button");
const toggleReportsButton = document.getElementById("toggle-reports-button");
const reportsRefreshButton = document.getElementById("reports-refresh-button");
const reportsTransactionsButton = document.getElementById("reports-transactions-button");
const reportsLaunchesButton = document.getElementById("reports-launches-button");
const reportsActiveJobsButton = document.getElementById("reports-active-jobs-button");
const reportsActiveLogsButton = document.getElementById("reports-active-logs-button");
const openSettingsButton = document.getElementById("open-settings-button");
const saveSettingsButton = document.getElementById("save-settings-button");
const settingsModal = document.getElementById("settings-modal");
const settingsClose = document.getElementById("settings-close");
const settingsCancel = document.getElementById("settings-cancel");
const modeSniperButton = document.getElementById("mode-sniper-button");
const modeSniperProgress = document.getElementById("mode-sniper-progress");
const modeVanityButton = document.getElementById("mode-vanity-button");
let vanityDerivedAddressPill = document.getElementById("mode-vanity-address");
let vanityDerivedPublicKey = "";
const devAutoSellButton = document.getElementById("dev-auto-sell-button");
const devAutoSellPopover = devAutoSellButton ? devAutoSellButton.closest(".auto-sell-popover") : null;
const autoSellButtonProgress = document.getElementById("auto-sell-button-progress");
const devAutoSellPanel = document.getElementById("dev-auto-sell-panel");
const autoSellEnabledInput = document.getElementById("auto-sell-enabled-input");
const autoSellToggleState = document.getElementById("auto-sell-toggle-state");
const autoSellTriggerFamilyValue = document.getElementById("auto-sell-trigger-family-value");
const autoSellTriggerValue = document.getElementById("auto-sell-trigger-value");
const autoSellTimeSettings = document.getElementById("auto-sell-time-settings");
const autoSellTriggerFamilyButtons = Array.from(document.querySelectorAll("[data-auto-sell-trigger-family]"));
const autoSellDelaySlider = document.getElementById("auto-sell-delay-slider");
const autoSellDelayInput = document.getElementById("auto-sell-delay-input");
const autoSellDelayControl = document.getElementById("auto-sell-delay-control");
const autoSellPercentSlider = document.getElementById("auto-sell-percent-slider");
const autoSellPercentInput = document.getElementById("auto-sell-percent-input");
const autoSellDelayValue = document.getElementById("auto-sell-delay-value");
const autoSellBlockControl = document.getElementById("auto-sell-block-control");
const autoSellBlockValue = document.getElementById("auto-sell-block-value");
const autoSellPercentValue = document.getElementById("auto-sell-percent-value");
const autoSellSettings = document.getElementById("auto-sell-settings");
const autoSellTriggerModeButtons = Array.from(document.querySelectorAll("[data-auto-sell-trigger-mode]"));
const autoSellBlockOffsetButtons = Array.from(document.querySelectorAll("[data-auto-sell-block-offset]"));
const autoSellMarketCapEnabledInput = document.getElementById("auto-sell-market-cap-enabled-input");
const autoSellMarketCapSettings = document.getElementById("auto-sell-market-cap-settings");
const autoSellMarketCapThresholdInput = document.getElementById("auto-sell-market-cap-threshold-input");
const autoSellMarketCapThresholdValue = document.getElementById("auto-sell-market-cap-threshold-value");
const autoSellMarketCapTimeoutInput = document.getElementById("auto-sell-market-cap-timeout-input");
const autoSellMarketCapTimeoutActionInput = document.getElementById("auto-sell-market-cap-timeout-action-input");
const autoSellSniperEnabledInput = document.getElementById("auto-sell-sniper-enabled-input");
const autoSellSniperToggleState = document.getElementById("auto-sell-sniper-toggle-state");
const autoSellSniperWalletList = document.getElementById("auto-sell-sniper-wallet-list");
const launchSurfaceModeSection = form ? form.querySelector(".launch-surface-mode") : null;
const sniperModal = document.getElementById("sniper-modal");
const sniperClose = document.getElementById("sniper-close");
const sniperCancel = document.getElementById("sniper-cancel");
const sniperSave = document.getElementById("sniper-save");
const sniperEnabledToggle = document.getElementById("sniper-enabled-toggle");
const sniperEnabledState = document.getElementById("sniper-enabled-state");
const sniperHostBanner = document.getElementById("sniper-host-banner");
const sniperWalletsSection = document.getElementById("sniper-wallets-section");
const sniperWalletList = document.getElementById("sniper-wallet-list");
const sniperSelectionSummary = document.getElementById("sniper-selection-summary");
const sniperTotalSummary = document.getElementById("sniper-total-summary");
const sniperModalError = document.getElementById("sniper-modal-error");
const vanityModal = document.getElementById("vanity-modal");
const vanityClose = document.getElementById("vanity-close");
const vanitySave = document.getElementById("vanity-save");
const vanityClear = document.getElementById("vanity-clear");
const vanityPrivateKeyText = document.getElementById("vanity-private-key-input");
const vanityModalError = document.getElementById("vanity-modal-error");
const vampModal = document.getElementById("vamp-modal");
const vampClose = document.getElementById("vamp-close");
const vampCancel = document.getElementById("vamp-cancel");
const vampImport = document.getElementById("vamp-import");
const vampContractInput = document.getElementById("vamp-contract-input");
const vampTweetUrlInput = document.getElementById("vamp-tweet-url-input");
const vampAutoLoadInput = document.getElementById("vamp-auto-load-input");
const vampClipboardDetectInput = document.getElementById("vamp-clipboard-detect-input");
const vampStatus = document.getElementById("vamp-status");
const vampError = document.getElementById("vamp-error");
let vampAutoImportTimer = null;
let vampInFlightAddress = "";
let consumedVampImageCaptureKey = "";
const OUTPUT_SECTION_VISIBILITY_KEY = "launchdeck.outputSectionVisible";
const REPORTS_TERMINAL_VISIBILITY_KEY = "launchdeck.reportsTerminalVisible";
const REPORTS_TERMINAL_LIST_WIDTH_KEY = "launchdeck.reportsTerminalListWidth";
const REPORTS_TERMINAL_VIEW_KEY = "launchdeck.reportsTerminalView";
const REPORTS_ACTIVE_LOGS_VIEW_KEY = "launchdeck.reportsActiveLogsView";
const THEME_MODE_STORAGE_KEY = "launchdeck.themeMode";
const SELECTED_WALLET_STORAGE_KEY = "launchdeck.selectedWalletKey";
const SELECTED_LAUNCHPAD_STORAGE_KEY = "launchdeck.selectedLaunchpad";
const SNIPER_DRAFT_STORAGE_KEY = "launchdeck.sniperDraft.v1";
const SNIPER_DRAFT_STORAGE_PREFIX = "launchdeck.sniperDraft";
const IMAGE_LAYOUT_COMPACT_STORAGE_KEY = "launchdeck.imageLayoutCompact";
const SELECTED_MODE_STORAGE_KEY = "launchdeck.selectedMode";
const SELECTED_PUMP_QUOTE_ASSET_STORAGE_KEY = "launchdeck.pumpQuoteAsset";
const SELECTED_BONK_QUOTE_ASSET_STORAGE_KEY = "launchdeck.bonkQuoteAsset";
const FEE_SPLIT_DRAFT_STORAGE_KEY = "launchdeck.feeSplitDraft.v1";
const AGENT_SPLIT_DRAFT_STORAGE_KEY = "launchdeck.agentSplitDraft.v1";
const AUTO_SELL_DRAFT_STORAGE_KEY = "launchdeck.autoSellDraft.v1";
const AUTO_SELL_DRAFT_STORAGE_PREFIX = "launchdeck.autoSellDraft";
const LAST_CUSTOM_DEV_BUY_SOL_STORAGE_KEY = "launchdeck.lastCustomDevBuySol";
const TICKER_CAPS_STORAGE_KEY = "launchdeck.tickerCapsEnabled";
const LaunchDeckLayout = globalThis.LaunchDeckLayout || {};
const launchDeckLayoutTokens = LaunchDeckLayout.TOKENS || {};
const popoutLayoutTokens = launchDeckLayoutTokens.popout || {};
const createOverlayLayoutTokens = launchDeckLayoutTokens.createOverlay || {};
const POPOUT_FORM_WIDTH = popoutLayoutTokens.formWidth || 532;
const POPOUT_REPORTS_WIDTH = popoutLayoutTokens.reportsWidth || 560;
const POPOUT_WORKSPACE_GAP = popoutLayoutTokens.workspaceGap || 12;
const POPOUT_WINDOW_NAME = "launchdeck-popout";
const CREATE_OVERLAY_STABLE_WIDTH = createOverlayLayoutTokens.width || 532;
const CREATE_OVERLAY_STABLE_HEIGHT = createOverlayLayoutTokens.height || 717;
const WEBAPP_POPOUT_STABLE_OUTER_WIDTH = popoutLayoutTokens.outerWidth || 552;
const WEBAPP_POPOUT_STABLE_OUTER_HEIGHT = popoutLayoutTokens.outerHeight || 727;
const pageSearchParams = new URLSearchParams(window.location.search);
const hasLegacyPopoutQuery = pageSearchParams.get("popout") === "1";
const isPopoutMode = window.name === POPOUT_WINDOW_NAME || hasLegacyPopoutQuery;
const extensionShellConfig = window.__launchdeckExtensionShell || null;
const isOverlayMode = Boolean(extensionShellConfig && extensionShellConfig.shell === "overlay");
const isCreateOverlayMode = Boolean(
isOverlayMode
&& extensionShellConfig
&& String(extensionShellConfig.mode || "").trim().toLowerCase() === "create"
);
let popoutAutosizeFrame = 0;
let popoutAutosizeTimeout = 0;
let createOverlayAutosizeFrame = 0;
let createOverlayResizeObserver = null;
let createOverlayMutationObserver = null;
let lastCreateOverlayPostedWidth = 0;
let lastCreateOverlayPostedHeight = 0;
const CREATE_OVERLAY_RESIZE_MESSAGE_SOURCE = "trench-tools-launchdeck";
const CREATE_OVERLAY_RESIZE_MESSAGE_TYPE = "resize-create-overlay";
const POST_DEPLOY_MESSAGE_TYPE = "post-deploy-success";
const TRUSTED_OVERLAY_PARENT_ORIGINS = new Set([
"https://axiom.trade",
"https://backup.axiom.trade",
"https://j7tracker.io",
]);
const overlayParentOrigin = (() => {
const candidates = [String(extensionShellConfig?.parentOrigin || "").trim()];
const ancestorOrigins = window.location?.ancestorOrigins;
if (ancestorOrigins && ancestorOrigins.length) {
candidates.push(String(ancestorOrigins[0] || "").trim());
}
for (const candidate of candidates) {
if (!candidate) continue;
try {
const origin = new URL(candidate).origin;
if (TRUSTED_OVERLAY_PARENT_ORIGINS.has(origin)) return origin;
} catch (_error) {
continue;
}
}
return "";
})();
const SITE_FEATURES_STORAGE_KEY = "trenchTools.siteFeatures";
const POST_DEPLOY_ACTIONS = new Set([
"close_modal_toast",
"toast_only",
"open_tab_toast",
"open_window_toast",
]);
const POST_DEPLOY_DESTINATIONS = new Set(["axiom"]);
const LIVE_SYNC_SOURCE_ID = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
const RequestUtils = window.LaunchDeckRequestUtils || {};
const RenderUtils = window.LaunchDeckRenderUtils || {};
const FormDomainModule = window.LaunchDeckFormDomain || {};
const QuotePreviewDomainModule = window.LaunchDeckQuotePreviewDomain || {};
const RuntimeActionsModule = window.LaunchDeckRuntimeActions || {};
const FeeRoutingModule = window.LaunchDeckFeeRouting || {};
const SplitEditorsDomainModule = window.LaunchDeckSplitEditorsDomain || {};
const SettingsDomainModule = window.LaunchDeckSettingsDomain || {};
const WalletRuntimeDomainModule = window.LaunchDeckWalletRuntimeDomain || {};
const LiveSyncModule = window.LaunchDeckLiveSync || {};
const LocalBindersModule = window.LaunchDeckLocalBinders || {};
const ImageMetadataDomainModule = window.LaunchDeckImageMetadataDomain || {};
const ImageCropDomainModule = window.LaunchDeckImageCropDomain || {};
let settingsDomain = null;
let splitEditorsDomain = null;
let walletRuntimeDomain = null;
let imageMetadataDomain = null;
let imageCropDomain = null;
let quotePreviewDomain = null;
let reportsPresenters = null;
let reportsHistory = null;
let reportsFeature = null;
let liveSyncSupport = null;
const DEFAULT_LAUNCHPAD_TOKEN_METADATA = Object.freeze({
nameMaxLength: 32,
symbolMaxLength: 10,
});
const STANDARD_RPC_SLIPPAGE_DEFAULT = "20";
function readEarlyLiveSyncSnapshot() {
return typeof LiveSyncModule.readEarlyLiveSyncSnapshot === "function"
? LiveSyncModule.readEarlyLiveSyncSnapshot()
: null;
}
const earlyLiveSyncSnapshot = readEarlyLiveSyncSnapshot();
if (earlyLiveSyncSnapshot) {
window.__launchdeckEarlyLiveSyncSnapshot = earlyLiveSyncSnapshot;
}
if (isPopoutMode) {
try {
if (window.name !== POPOUT_WINDOW_NAME) window.name = POPOUT_WINDOW_NAME;
} catch (_error) {
// Ignore window.name failures and continue with static popout behavior.
}
document.body.classList.add("popout-mode");
document.title = "Trench.Tools - LaunchDeck Popout";
window.addEventListener("load", () => {
schedulePopoutAutosize({ immediate: true });
});
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(() => {
schedulePopoutAutosize({ immediate: true });
}).catch(() => {});
}
}
if (isCreateOverlayMode) {
document.documentElement.classList.add("overlay-create-mode");
document.documentElement.classList.remove("theme-light");
document.body.classList.add("overlay-create-mode");
document.title = "Trench.Tools - LaunchDeck Create";
window.addEventListener("load", () => {
scheduleCreateOverlayAutosize();
});
if (document.fonts && document.fonts.ready) {
document.fonts.ready.then(() => {
scheduleCreateOverlayAutosize();
}).catch(() => {});
}
}
if (pageSearchParams.has("popout") || pageSearchParams.has("output") || pageSearchParams.has("reports")) {
const cleanUrl = new URL(window.location.href);
cleanUrl.searchParams.delete("popout");
cleanUrl.searchParams.delete("output");
cleanUrl.searchParams.delete("reports");
try {
window.history.replaceState(null, "", `${cleanUrl.pathname}${cleanUrl.search}${cleanUrl.hash}`);
} catch (_error) {
// Ignore history replacement failures and keep boot functional.
}
}
let j7TweetContext = null;
let j7ImageCandidateState = {
candidates: [],
selectedId: "",
source: "",
};
let j7ImagePersistPromise = null;
setThemeMode(getStoredThemeMode(), { persist: false });
setOutputSectionVisible(
getStoredOutputSectionVisible(),
);
setImageLayoutCompact(getStoredImageLayoutCompact(), { persist: false });
initCreateOverlayAutosizeSync();
if (!isPopoutMode) {
if (output) output.textContent = "";
if (metaNode) metaNode.textContent = "";
setStatusLabel("");
}
let uploadedImage = null;
let latestWalletStatus = null;
let latestRuntimeStatus = null;
let latestLaunchpadRegistry = {};
let importedCreatorFeeState = {
mode: "",
address: "",
githubUsername: "",
githubUserId: "",
};
let walletStatusRequestSerial = 0;
let appBootstrapState = {
started: false,
staticLoaded: false,
configLoaded: false,
walletsLoaded: false,
runtimeLoaded: false,
};
const LAUNCHDECK_SHARED_CONSTANTS = (typeof window !== "undefined" && window.__launchdeckShared) || {};
const LAUNCHDECK_HOST_OFFLINE_BANNER_HTML = LAUNCHDECK_SHARED_CONSTANTS.HOST_OFFLINE_BANNER_HTML
|| 'LaunchDeck host offline - start <code>launchdeck-engine</code> to use Launch, Snipe and Reports.';
let launchdeckHostConnectionState = {
checked: !extensionShellConfig,
reachable: true,
error: "",
};
let launchdeckBootstrapPromise = null;
let launchdeckHostRecoveryTimer = null;
let startupWarmState = {
started: false,
ready: false,
promise: null,
enabled: true,
backendLoaded: false,
backendPayload: null,
backendError: "",
};
const STARTUP_WARM_REQUEST_TIMEOUT_MS = 4000;
const STARTUP_WARM_WAIT_TIMEOUT_MS = 1500;
const STARTUP_WARM_CACHE_STORAGE_KEY = "launchdeck.startupWarmCache.v2";
const LEGACY_STARTUP_WARM_CACHE_STORAGE_KEY = "launchdeck.startupWarmCache.v1";
const STARTUP_WARM_CACHE_SCHEMA_VERSION = 2;
const LAUNCHDECK_HOST_RECOVERY_RETRY_MS = 5000;
const PREVIEW_INPUTS_STORAGE_KEY = "launchdeck.previewInputs.v1";
const PREVIEW_INPUTS_SCHEMA_VERSION = 1;
const WALLET_STATUS_LAST_REFRESH_STORAGE_KEY = "launchdeck.walletStatusLastRefreshAtMs";
let walletStatusRefreshIntervalMs = 30000;
const RUNTIME_STATUS_REFRESH_INTERVAL_MS = 15000;
const STARTUP_WARM_CACHE_MAX_AGE_MS = RUNTIME_STATUS_REFRESH_INTERVAL_MS;
const WARM_ACTIVITY_DEBOUNCE_MS = 1000;
const WARM_PRESENCE_IDLE_MS = 10 * 60 * 1000;
const WARM_PRESENCE_HEARTBEAT_MS = 60 * 1000;
let defaultsApplied = false;
const requestStates = {
bootstrap: RequestUtils.createLatestRequestState ? RequestUtils.createLatestRequestState() : { serial: 0, controller: null, debounceTimer: null },
walletStatus: RequestUtils.createLatestRequestState ? RequestUtils.createLatestRequestState() : { serial: 0, controller: null, debounceTimer: null },
runtimeStatus: RequestUtils.createLatestRequestState ? RequestUtils.createLatestRequestState() : { serial: 0, controller: null, debounceTimer: null },
followJobs: RequestUtils.createLatestRequestState ? RequestUtils.createLatestRequestState() : { serial: 0, controller: null, debounceTimer: null },
logs: RequestUtils.createLatestRequestState ? RequestUtils.createLatestRequestState() : { serial: 0, controller: null, debounceTimer: null },
reports: RequestUtils.createLatestRequestState ? RequestUtils.createLatestRequestState() : { serial: 0, controller: null, debounceTimer: null },
reportView: RequestUtils.createLatestRequestState ? RequestUtils.createLatestRequestState() : { serial: 0, controller: null, debounceTimer: null },
images: RequestUtils.createLatestRequestState ? RequestUtils.createLatestRequestState() : { serial: 0, controller: null, debounceTimer: null },
bagsFeeRecipientLookup: RequestUtils.createLatestRequestState ? RequestUtils.createLatestRequestState() : { serial: 0, controller: null, debounceTimer: null },
};
const renderCache = {
walletDropdown: "",
platformRuntimeIndicators: "",
sniperWalletList: "",
reportsList: "",
imageGrid: "",
backendRegion: "",
};
let metadataUploadState = {
debounceTimer: null,
inFlightPromise: null,
inFlightFingerprint: "",
completedFingerprint: "",
latestScheduledFingerprint: "",
lastCanPreupload: false,
staleWhileUploading: false,
autoRetryFailures: 0,
autoRetryDisabled: false,
lastAlertedWarning: "",
suppressWarningFingerprint: "",
};
let runtimeStatusRefreshTimer = null;
let walletStatusRefreshTimer = null;
let warmActivityState = {
debounceTimer: null,
inFlightPromise: null,
lastSentAtMs: 0,
pendingFlush: false,
};
let warmPresenceState = {
active: false,
idleTimer: null,
heartbeatTimer: null,
lastReason: "",
};
let imageLibraryState = {
images: [],
categories: [],
search: "",
category: "all",
activeImageId: "",
};
let activeImageMenuId = "";
let activeImageDetailsId = "";
let imageDetailsTagsState = [];
let isEditingNewImageUpload = false;
let imageCategoryModalContext = "library";
let tickerManuallyEdited = false;
let syncingTickerFromName = false;
let tickerClearedForManualEntry = false;
let syncingDevBuyInputs = false;
let lastDevBuyEditSource = "sol";
let previewInputsState = null;
let reportsTerminalState = {
allEntries: [],
entries: [],
launches: [],
activeLogs: {
live: [],
errors: [],
error: "",
updatedAtMs: 0,
},
launchBundles: {},
launchMetadataByUri: {},
activeId: "",
activePayload: null,
activeBenchmarkReportId: "",
activeBenchmarkSnapshot: null,
activeText: "",
activeTab: "overview",
view: getStoredReportsTerminalView(),
activeLogsView: getStoredActiveLogsView(),
sort: "newest",
};
let reportsTerminalLoadSerial = 0;
let reportsTerminalResizeState = null;
let followJobsState = {
configured: false,
reachable: false,
jobs: [],
health: null,
error: "",
loaded: false,
refreshTimer: null,
};
let outputFollowRefreshState = {
serial: 0,
timer: null,
reportId: "",
startedAtMs: 0,
};
const REPORTS_TERMINAL_DEFAULT_LIST_WIDTH = 152;
const REPORTS_TERMINAL_MIN_LIST_WIDTH = 120;
const REPORTS_TERMINAL_MAX_LIST_WIDTH = 240;
const REPORTS_TERMINAL_ITEM_LIMIT = 25;
const OUTPUT_FOLLOW_REFRESH_INTERVAL_MS = 1500;
const OUTPUT_FOLLOW_REFRESH_TIMEOUT_MS = 90000;
const FOLLOW_JOBS_REFRESH_INTERVAL_MS = 5000;
const FOLLOW_JOBS_OFFLINE_RETRY_MS = 15000;
const SPLIT_COLORS = ["#5b7cff", "#ff5d5d", "#14c38e", "#ffb020", "#7c5cff", "#00b8d9", "#ef5da8", "#8b5cf6"];
const DEFAULT_QUICK_DEV_BUY_AMOUNTS = ["0.5", "1", "2"];
const DEFAULT_PRESET_ID = "preset1";
const METADATA_PREUPLOAD_DEBOUNCE_MS = 500;
const MAX_FEE_SPLIT_RECIPIENTS = 10;
const BAGS_FEE_SPLIT_VISIBLE_CARD_COUNT = 5;
const BAGS_FEE_SPLIT_VIEWPORT_BUFFER_PX = 4;
const SNIPER_EXECUTION_RESERVE_SOL = 0.005;
const SNIPER_BALANCE_PRESETS = [
{ label: "Max", ratio: 1 },
{ label: "75%", ratio: 0.75 },
{ label: "50%", ratio: 0.5 },
{ label: "25%", ratio: 0.25 },
];
const PROVIDER_LABELS = {
"helius-sender": "Helius Sender",
hellomoon: "Hello Moon QUIC",
"standard-rpc": "Standard RPC",
"jito-bundle": "Jito Bundle",
};
const ROUTE_CAPABILITIES = {
"helius-sender": {
creation: { tip: true, priority: true, slippage: false },
buy: { tip: true, priority: true, slippage: true },
sell: { tip: true, priority: true, slippage: true },
},
hellomoon: {
creation: { tip: true, priority: true, slippage: false },
buy: { tip: true, priority: true, slippage: true },
sell: { tip: true, priority: true, slippage: true },
},
"standard-rpc": {
creation: { tip: false, priority: true, slippage: false },
buy: { tip: false, priority: true, slippage: true },
sell: { tip: false, priority: true, slippage: true },
},
"jito-bundle": {
creation: { tip: true, priority: true, slippage: false },
buy: { tip: true, priority: true, slippage: true },
sell: { tip: true, priority: true, slippage: true },
},
};
const PROVIDER_FEE_REQUIREMENTS = {
"helius-sender": { minTipSol: 0.0002, priorityRequired: true },
hellomoon: { minTipSol: 0.001, priorityRequired: true },
"jito-bundle": { minTipSol: 0.000001, priorityRequired: true },
};
settingsDomain = SettingsDomainModule.create ? SettingsDomainModule.create({
elements: {
topPresetChipBar,
settingsPresetChipBar,
presetEditToggle,
devBuyQuickButtons,
changeDevBuyPresetsButton,
cancelDevBuyPresetsButton,
saveDevBuyPresetsButton,
providerSelect,
creationTipInput,
creationPriorityInput,
creationMevModeSelect,
creationAutoFeeInput,
creationAutoFeeButton,
creationMaxFeeInput,
buyProviderSelect,
buyPriorityFeeInput,
buyTipInput,
buySlippageInput,
buyMevModeSelect,
buyAutoFeeInput,
buyAutoFeeButton,
buyMaxFeeInput,
buyHelloMoonMevWarning,
buyStandardRpcWarning,
sellProviderSelect,
sellPriorityFeeInput,
sellTipInput,
sellSlippageInput,
sellMevModeSelect,
sellAutoFeeInput,
sellAutoFeeButton,
sellMaxFeeInput,
sellHelloMoonMevWarning,
sellStandardRpcWarning,
settingsBackendRegionSummary,
namePresetModal,
namePresetClose,
namePresetEditorList,
namePresetFormActions,
namePresetAddButton,
namePresetCancelEditButton,
namePresetUpdateButton,
namePresetFormTitle,
namePresetNewName,
namePresetNewNamePrefix,
namePresetNewNameSuffix,
namePresetNewTickerPrefix,
namePresetNewTickerSuffix,
namePresetNewFirstWord,
namePresetNewAbbreviate,
namePresetError,
settingsModal,
settingsClose,
settingsCancel,
output,
},
constants: {
defaultQuickDevBuyAmounts: DEFAULT_QUICK_DEV_BUY_AMOUNTS,
defaultPresetId: DEFAULT_PRESET_ID,
standardRpcSlippageDefault: STANDARD_RPC_SLIPPAGE_DEFAULT,
providerLabels: PROVIDER_LABELS,
routeCapabilities: ROUTE_CAPABILITIES,
providerFeeRequirements: PROVIDER_FEE_REQUIREMENTS,
},
renderCache,
renderUtils: RenderUtils,
state: {
getLatestWalletStatus: () => latestWalletStatus,
setLatestWalletStatus: (value) => {
latestWalletStatus = value;
},
getLatestRuntimeStatus: () => latestRuntimeStatus,
},
helpers: {
escapeHTML,
getNamedValue,
isNamedChecked,
validateFieldByName,
validateAllInlineFields,
focusFirstInvalidInlineField,
hasBootstrapConfig,
setStatusLabel,
},
actions: {
scheduleLiveSyncBroadcast: (options) => scheduleLiveSyncBroadcast(options),
queueWarmActivity: (options) => queueWarmActivity(options),
syncDevAutoSellUI: () => syncDevAutoSellUI(),
clearDevBuyState: () => clearDevBuyState(),
renderNamePresetStrip: () => renderNamePresetStrip(),
},
}) : null;
const TOTAL_SUPPLY_TOKENS = 1_000_000_000n;
const TOKEN_DECIMALS = 6;
const TEST_PRESET = {
name: "test",
symbol: "test",
description: "test",
website: "https://test.com/",
twitter: "https://x.com/test",
telegram: "https://t.me/test",
devBuyMode: "sol",
devBuyAmount: "0.001",
};
function setStatusLabel(label = "") {
const normalized = String(label || "").trim();
const hidden = !normalized || /^(idle|ready)$/i.test(normalized);
if (statusNode) {
statusNode.textContent = hidden ? "" : normalized;
statusNode.hidden = hidden;
}
if (imageStatus) {
imageStatus.textContent = hidden ? "" : normalized;
}
}
function currentStatusLabel() {
if (imageStatus && imageStatus.textContent.trim()) return imageStatus.textContent.trim();
if (statusNode && statusNode.textContent.trim()) return statusNode.textContent.trim();
return "";
}
function setBusy(busy, label) {
setStatusLabel(label);
buttons.forEach((button) => {
button.disabled = busy;
});
if (openSettingsButton) openSettingsButton.disabled = busy;
if (modeSniperButton) modeSniperButton.disabled = busy;
if (modeVanityButton) modeVanityButton.disabled = busy;
if (devAutoSellButton) devAutoSellButton.disabled = busy;
if (saveSettingsButton) saveSettingsButton.disabled = busy;
if (changeDevBuyPresetsButton) changeDevBuyPresetsButton.disabled = busy;
if (saveDevBuyPresetsButton) saveDevBuyPresetsButton.disabled = busy;
if (cancelDevBuyPresetsButton) cancelDevBuyPresetsButton.disabled = busy;
if (devBuyCustomDeployButton) devBuyCustomDeployButton.disabled = busy;
}
function getNamedInput(name) {
return document.querySelector(`[name="${name}"]`);
}
function getNamedValue(name) {
const input = getNamedInput(name);
return input ? input.value : "";
}
function setNamedValue(name, value) {
const input = getNamedInput(name);
if (input) input.value = value;
}
function setNamedChecked(name, checked) {
const input = getNamedInput(name);
if (input) input.checked = Boolean(checked);
}
function isNamedChecked(name) {
const input = getNamedInput(name);
return Boolean(input && input.checked);
}
function formatSliderValue(value, suffix, digits = 0) {
const numeric = Number(value || 0);
if (!Number.isFinite(numeric)) return `0${suffix}`;
return `${numeric.toFixed(digits)}${suffix}`;
}
function normalizeLaunchMode(value) {
const mode = String(value || "").trim();
if ([
"regular",
"bonkers",
"cashback",
"agent-custom",
"agent-unlocked",
"agent-locked",
"bags-2-2",
"bags-025-1",
"bags-1-025",
].includes(mode)) {
return mode;
}
return "regular";
}
function defaultLaunchModeForLaunchpad(launchpad) {
const normalizedLaunchpad = normalizeLaunchpad(launchpad);
if (normalizedLaunchpad === "bagsapp") return "bags-2-2";
return "regular";
}
function normalizeLaunchModeForLaunchpad(mode, launchpad = getLaunchpad()) {
const normalizedMode = normalizeLaunchMode(mode);
const allowedModes = getLaunchpadUiCapabilities(normalizeLaunchpad(launchpad)).allowedModes || ["regular"];
return allowedModes.includes(normalizedMode)
? normalizedMode
: (allowedModes[0] || defaultLaunchModeForLaunchpad(launchpad));
}
function normalizeLaunchpad(value) {
const launchpad = String(value || "").trim().toLowerCase();
if (["pump", "bonk", "bagsapp"].includes(launchpad)) {
return launchpad;
}
return "pump";
}
function normalizeStoredBonkQuoteAsset(value) {
return normalizeQuoteAsset(value) === "usd1" ? "usd1" : "sol";
}
function normalizeStoredPumpQuoteAsset(value) {
return normalizeQuoteAsset(value) === "usdc" ? "usdc" : "sol";
}
function selectedModeStorageKeyForLaunchpad(launchpad = getLaunchpad()) {
return `${SELECTED_MODE_STORAGE_KEY}.${normalizeLaunchpad(launchpad)}`;
}
function getStoredLaunchMode(launchpad = getLaunchpad()) {
try {
const scoped = window.localStorage.getItem(selectedModeStorageKeyForLaunchpad(launchpad));
if (scoped) return normalizeLaunchMode(scoped);
const legacy = window.localStorage.getItem(SELECTED_MODE_STORAGE_KEY);
return legacy ? normalizeLaunchMode(legacy) : "";
} catch (_error) {
return "";
}
}
function setStoredLaunchMode(mode, launchpad = getLaunchpad()) {
try {
const normalizedLaunchpad = normalizeLaunchpad(launchpad);
const normalizedMode = normalizeLaunchModeForLaunchpad(mode, normalizedLaunchpad);
window.localStorage.setItem(selectedModeStorageKeyForLaunchpad(normalizedLaunchpad), normalizedMode);
window.localStorage.setItem(SELECTED_MODE_STORAGE_KEY, normalizedMode);
} catch (_error) {
// Ignore storage failures and keep mode controls functional.
}
}
function getStoredLaunchpad() {
try {
const stored = window.localStorage.getItem(SELECTED_LAUNCHPAD_STORAGE_KEY);
return stored ? normalizeLaunchpad(stored) : "";
} catch (_error) {
return "";
}
}
function setStoredLaunchpad(launchpad) {
try {
window.localStorage.setItem(SELECTED_LAUNCHPAD_STORAGE_KEY, normalizeLaunchpad(launchpad));
} catch (_error) {
// Ignore storage failures and keep launchpad controls functional.
}
}
function scopedLaunchpadDraftKey(prefix, launchpad = getLaunchpad()) {
const scopedLaunchpad = normalizeLaunchpad(launchpad) || "pump";
return `${prefix}.${scopedLaunchpad}.v2`;
}
function knownDraftScopeLaunchpads() {
const values = new Set(["pump", "bonk", "bagsapp"]);
document.querySelectorAll('input[name="launchpad"]').forEach((input) => {
const value = normalizeLaunchpad(input && input.value);
if (value) values.add(value);
});
return Array.from(values);
}
function readStoredScopedDraft(prefix, legacyStorageKey, launchpad = getLaunchpad()) {
const normalizedLaunchpad = normalizeLaunchpad(launchpad) || "pump";
const parseScopedValue = (raw, { hydrateLaunchpad = false } = {}) => {
if (!raw) return null;
const parsed = JSON.parse(raw);
if (!parsed || typeof parsed !== "object") return parsed;
const parsedLaunchpad = normalizeLaunchpad(parsed.launchpad || normalizedLaunchpad) || normalizedLaunchpad;
if (!hydrateLaunchpad && parsed.launchpad && parsedLaunchpad !== normalizedLaunchpad) {
return null;
}
return {
...parsed,
launchpad: normalizedLaunchpad,
};
};
try {
const scopedRaw = window.localStorage.getItem(scopedLaunchpadDraftKey(prefix, normalizedLaunchpad));
if (scopedRaw) return parseScopedValue(scopedRaw);
if (!legacyStorageKey) return null;
return parseScopedValue(
window.localStorage.getItem(legacyStorageKey),
{ hydrateLaunchpad: true },
);
} catch (_error) {
return null;
}
}
function setStoredScopedDraft(prefix, legacyStorageKey, value, launchpad = getLaunchpad()) {
const normalizedLaunchpad = normalizeLaunchpad(launchpad) || "pump";
const scopedKey = scopedLaunchpadDraftKey(prefix, normalizedLaunchpad);
try {
if (!value) {
window.localStorage.removeItem(scopedKey);
if (legacyStorageKey) window.localStorage.removeItem(legacyStorageKey);
return;
}