-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
2201 lines (1964 loc) · 84.5 KB
/
script.js
File metadata and controls
2201 lines (1964 loc) · 84.5 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 page = document.body.dataset.page;
const navLink = document.querySelector(`[data-nav="${page}"]`);
if (navLink) navLink.classList.add("active");
const revealElements = document.querySelectorAll(".reveal");
const revealObserver = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("show");
revealObserver.unobserve(entry.target);
}
});
},
{ threshold: 0.16 }
);
revealElements.forEach((el) => revealObserver.observe(el));
const canvas = document.getElementById("starfield");
const ctx = canvas?.getContext("2d");
let stars = [];
let lastStarFrame = 0;
const runtimeFlags = {
isConstrained: false,
isFirefoxLike: false,
isVivaldi: false,
};
function computeRuntimeFlags() {
const ua = navigator.userAgent || "";
const isSmallViewport = window.matchMedia?.("(max-width: 820px)")?.matches || false;
const isCoarsePointer = window.matchMedia?.("(pointer: coarse)")?.matches || false;
runtimeFlags.isConstrained = isSmallViewport || isCoarsePointer;
runtimeFlags.isFirefoxLike = ua.includes("Firefox") || ua.includes("LibreWolf");
runtimeFlags.isVivaldi = /vivaldi/i.test(ua);
}
function getStarFieldProfile() {
const isLiquidGlass = document.body.dataset.theme === "liquidglass";
const { isConstrained } = runtimeFlags;
if (isLiquidGlass && isConstrained) return { density: 0.42, frameBudget: 56 };
if (isLiquidGlass) return { density: 0.55, frameBudget: 46 };
if (isConstrained) return { density: 0.72, frameBudget: 28 };
return { density: 1, frameBudget: 18 };
}
function resizeCanvas() {
if (!canvas || !ctx) return;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const profile = getStarFieldProfile();
const baseCount = Math.min(140, Math.floor((canvas.width * canvas.height) / 17500));
const count = Math.max(24, Math.floor(baseCount * profile.density));
stars = Array.from({ length: count }, () => ({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
speed: Math.random() * 0.2 + 0.05,
size: Math.random() * 1.05 + 0.22,
alpha: Math.random() * 0.5 + 0.25,
}));
}
function drawStars(timestamp = 0) {
if (!canvas || !ctx) return;
const profile = getStarFieldProfile();
const elapsed = timestamp - lastStarFrame;
if (document.hidden) {
requestAnimationFrame(drawStars);
return;
}
if (elapsed < profile.frameBudget) {
requestAnimationFrame(drawStars);
return;
}
const frameFactor = Math.min(3, Math.max(0.9, elapsed / 16.67));
lastStarFrame = timestamp;
ctx.clearRect(0, 0, canvas.width, canvas.height);
stars.forEach((star) => {
star.y += star.speed * frameFactor;
if (star.y > canvas.height + 4) {
star.y = -4;
star.x = Math.random() * canvas.width;
}
ctx.beginPath();
ctx.fillStyle = `rgba(193, 222, 255, ${star.alpha})`;
ctx.arc(star.x, star.y, star.size, 0, Math.PI * 2);
ctx.fill();
});
requestAnimationFrame(drawStars);
}
resizeCanvas();
window.addEventListener("resize", resizeCanvas);
requestAnimationFrame(drawStars);
function attachTiltBehavior(card) {
let tiltFrame = null;
let lastMouseEvent = null;
const reset = () => {
card.style.transform = "rotateX(0deg) rotateY(0deg)";
card.style.removeProperty("--mx");
card.style.removeProperty("--my");
lastMouseEvent = null;
if (tiltFrame) {
cancelAnimationFrame(tiltFrame);
tiltFrame = null;
}
};
card.addEventListener("mousemove", (event) => {
lastMouseEvent = event;
if (tiltFrame) return;
tiltFrame = requestAnimationFrame(() => {
tiltFrame = null;
if (!lastMouseEvent || document.body.dataset.theme === "liquidglass") {
reset();
return;
}
const rect = card.getBoundingClientRect();
const dx = (lastMouseEvent.clientX - rect.left) / rect.width - 0.5;
const dy = (lastMouseEvent.clientY - rect.top) / rect.height - 0.5;
card.style.transform = `rotateX(${(-dy * 5).toFixed(2)}deg) rotateY(${(dx * 6).toFixed(2)}deg)`;
card.style.setProperty("--mx", `${((lastMouseEvent.clientX - rect.left) / rect.width) * 100}%`);
card.style.setProperty("--my", `${((lastMouseEvent.clientY - rect.top) / rect.height) * 100}%`);
});
});
card.addEventListener("mouseleave", reset);
}
const tiltElements = document.querySelectorAll(".tilt");
tiltElements.forEach((card) => attachTiltBehavior(card));
const quoteBtn = document.getElementById("quote-btn");
const launchBtn = document.getElementById("launch-btn");
const quoteOutput = document.getElementById("quote-output");
const signalCount = document.getElementById("signal-count");
const penguinAvatar = document.querySelector(".penguin-avatar");
const penguinBelly = document.querySelector(".penguin-belly");
const androidDateBadge = document.querySelector(".android-date-badge");
const paletteOpenBtn = document.getElementById("palette-open");
let commandPalette = document.getElementById("command-palette");
let commandBackdrop = document.getElementById("command-backdrop");
let commandInput = document.getElementById("command-input");
let commandResults = document.getElementById("command-results");
const quizQuestion = document.getElementById("quiz-question");
const quizProgress = document.getElementById("quiz-progress");
const quizOptions = document.getElementById("quiz-options");
const quizStartBtn = document.getElementById("quiz-start");
const quizResetBtn = document.getElementById("quiz-reset");
const quizScore = document.getElementById("quiz-score");
const headerThemeSelect = document.getElementById("header-theme-select");
const themeCycleBtn = document.getElementById("theme-cycle-btn");
const heroName = document.getElementById("hero-name");
const heroStatus = document.getElementById("hero-status");
const heroTagline = document.getElementById("hero-tagline");
const pageFooterLine = document.getElementById("page-footer-line");
const miniTerminalForm = document.getElementById("mini-terminal-form");
const miniTerminalInput = document.getElementById("mini-terminal-input");
const miniTerminalOutput = document.getElementById("mini-terminal-output");
const miniTerminalScreen = document.querySelector(".mini-terminal-screen");
const miniTerminalTheme = document.getElementById("mini-terminal-theme");
const NEPAL_TIMEZONE = "Asia/Kathmandu";
const BS_CONVERTER_URL = "https://cdn.jsdelivr.net/npm/nepali-date-library@1.1.9/+esm";
const THEME_STORAGE_KEY = "neoThemeVariant.v1";
const ACTION_STORAGE_KEY = "neoAutoAction.v1";
const HERO_TYPED_KEY = "neoHeroTyped.v1";
const MINI_PROMPT_NERD = "╰─❯";
const MINI_PROMPT_FALLBACK = "$";
const NERD_FONT_FAMILIES = [
"JetBrainsMono Nerd Font",
"FiraCode Nerd Font",
"CaskaydiaCove Nerd Font",
];
const THEME_OPTIONS = [
"neo",
"mint",
"sunset",
"midnight",
"ember",
"arctic",
"grape",
"toxic",
"ocean",
"bloodmoon",
"liquidglass",
"material3",
"paper",
"blackflag",
];
const MAX_TERMINAL_LINES = 220;
const TERMINAL_COMMANDS = [
"help", "whoami", "mission", "status", "clear",
"stack", "skills", "age", "location", "school", "goal", "motto",
"books", "movies", "games", "anime", "crypto", "people", "youtube",
"launch", "insight", "quote", "matrix", "music", "elon", "istj", "reset", "quiz",
"theme", "home", "about", "contact", "github",
"ls", "pwd", "uname", "nepal", "date", "time", "pulse", "echo",
];
let launches = 0;
let adToBsConverter = null;
let startPersonaQuiz = null;
let currentTheme = "neo";
let terminalHistory = [];
let terminalHistoryIndex = 0;
let terminalDraft = "";
let blackflagShotLockUntil = 0;
let pulseWaveLayer = null;
let pulseWaveRing = null;
let pulseCoreFlash = null;
let pulseFallbackTimeout = 0;
const typewriterTokens = new WeakMap();
const heroTaglineVariants = [
"Aura Farmer // Chaotic Fun 🚀",
"Neo Build Mode // Signal > Noise",
"Debate + Code + Ship ⚡",
"Open Source + AI + Linux 🐧",
"Chaos Energy // Clean Execution",
"From Gongabu to Global Ideas 🌍",
"Future AI Engineer // In Progress",
"Keyboard Warrior // Builder Mindset",
];
const aiConstellationTaglines = [
"Aura Farmer",
"Signal > Noise",
"Debate Mode Always Ready",
"Build Fast, Think Deep",
"Linux Brain, Space Heart",
"Chaos Energy, Clean Execution",
"Ship Weird Ideas",
"Open Source Mindset",
"AI Tools, Real Impact",
"Gongabu to Global",
"Minimal UI, Max Aura",
"Neo Stack Activated",
"Focus: Learn, Build, Debate",
"Future AI Engineer Loading",
"Curiosity Over Comfort",
"Mission: Make It Work",
];
const aboutFooterLines = [
"Aura Farmer: thinking deep, building fast.",
"Neo lore: chaotic fun, clean execution.",
"Debate mode always ready, code mode always on.",
"Space theme, hacker heart, aura farming daily.",
"Signal over noise, curiosity over comfort.",
"Gongabu mind, global ambitions.",
"Arch + Hyprland energy, zero fluff.",
"Less scrolling, more shipping.",
"I build fast, debug faster, sleep last.",
"Chaotic fun with a clean commit history.",
"Neo ops online. Aura farming in progress.",
"I argue with logic, not volume.",
"Code is my canvas, Linux is my brush.",
"I ship ideas before they feel ready.",
"Coffee, keyboards, and stubborn curiosity.",
"Future-proof mindset, present-day hustle.",
"Minimalism in UI, maximalism in ideas.",
"I like hard books and harder bugs.",
"Each commit is a small rebellion.",
"Curiosity is the only permanent fuel.",
"Build small. Think big. Iterate always.",
"Aura farming is a daily discipline.",
"No fluff, just signal.",
"Debate mode: always armed with facts.",
"Quiet focus, loud results.",
"Ship in public, refine in private.",
"Chaos is fine when the fundamentals are clean.",
"I turn problems into prototypes.",
"Less talk, more terminal.",
"Neo mindset: stay dangerous, stay curious.",
"Ideas first, ego last.",
"If it compiles, it ships.",
"Hard problems are my cardio.",
"I collect bugs like trophies.",
"Design with intent, code with speed.",
"I don’t chase trends, I build systems.",
"Not perfect, just progressing.",
"Signal the mission, cut the noise.",
"I debate to learn, not to win.",
"Keyboard warrior, logic defender.",
"Clean diff, loud impact.",
"Every error is an invitation.",
"Debugging is my form of meditation.",
"Weird ideas, real builds.",
"No sleep, just prototypes.",
"I’m not late, I’m iterating.",
"Neo energy, Gongabu roots.",
"Courage is just a commit away.",
"Minimal UI, maximal aura.",
"Rust? Python? I’m still shipping.",
"Everything is solvable with enough clarity.",
"A good argument is just a clean stack trace.",
"I build the thing I wanted to exist.",
"Aura farming is just consistent output.",
"I read error messages after I panic.",
"Fast feedback beats perfect plans.",
"Learn fast, ship faster.",
"Discipline beats motivation on slow days.",
];
const quotes = [
"Aura farmer protocol: build daily.",
"Debate mode: logic over noise.",
"AI mindset: practical systems beat hype.",
"Neo mode: stay curious, stay dangerous.",
"Open source: ship in public, improve fast.",
"Discipline is a multiplier.",
"Bug found, ego down, skills up.",
"My keyboard gets more workouts than I do.",
"Coffee in, code out.",
"If it compiles first try, I get suspicious.",
"Linux teaches patience and power.",
"The stack trace is a treasure map.",
"I do not fear hard problems, I schedule them.",
"Small commits, big progress.",
"Git is my memory when my brain cache misses.",
"Every error message is free tutoring.",
"I refactor because future-me has standards.",
"A good engineer is a professional note taker.",
"If docs are optional, chaos is mandatory.",
"Late night coding is just time travel with bugs.",
"Do not panic. Read the logs.",
"Everything is impossible until it is merged.",
"I talk fast, type faster, debug longest.",
"Coding is 10 percent typing and 90 percent thinking.",
"The best optimization is deleting useless code.",
"When in doubt, write tests.",
"Future AI engineer loading.",
"I break things to understand them deeply.",
"Neat code is silent confidence.",
"I like open source because receipts are public.",
"Less scrolling, more shipping.",
"Touch grass, then touch code.",
"I do not chase trends, I build systems.",
"One more commit and then I sleep. Maybe.",
"My room is messy, my logic is not.",
"I solve a Rubik's cube faster than bad architecture.",
"Debate skill unlocked: argue with facts, not volume.",
"Speak clearly, code clearly.",
"No excuses in prod, only fixes.",
"The matrix is real, it is called dependency hell.",
"If you can explain it simply, you own it.",
"Read books, write code, repeat.",
"Philosophy for coders: know thy bug.",
"Discipline beats motivation on slow days.",
"I like difficult books and difficult problems.",
"Linux terminal is where confidence lives.",
"I ship weird ideas on purpose.",
"Chaos is fine if your fundamentals are clean.",
"Minimal UI, maximal aura.",
"Never trust a silent build pipeline.",
"A fast learner is a dangerous builder.",
"No roadmap survives first user feedback.",
"Programmer joke: I changed one line and fixed five bugs. I changed it back and fixed six.",
"I do not copy code blindly. I audit it.",
"If your code needs luck, it needs work.",
"Readable code is social respect.",
"Quality is not extra. It is the job.",
"Ship in public, improve in public.",
"Keyboard shortcuts are free power-ups.",
"You do not need permission to learn deeply.",
"I like ideas that scare lazy people.",
"Every repo is a time capsule of decisions.",
"Winners take notes, builders take action.",
"I test edge cases because reality is rude.",
"A bug report is a love letter from production.",
"No one debates better than clean evidence.",
"The simplest fix that works is elite.",
"Logs do not lie, assumptions do.",
"Version control is emotional control.",
"If there is no challenge, there is no story.",
"Calm mind, sharp output.",
"I learn faster than yesterday's excuses.",
"I do not chase perfection, I chase iteration.",
"The command line never gaslights.",
"Security is a feature, not a patch note.",
"Tight loops build strong intuition.",
"Complexity grows by default. Simplicity takes intent.",
"Best flex: clean architecture at midnight.",
"Sometimes the fix is deleting the feature.",
"Great products are edited, not just built.",
"The grind looks boring before it looks legendary.",
"If you cannot measure it, you cannot improve it.",
"No drama in commits, only clarity.",
"AI is leverage for builders who think clearly.",
"I optimize for signal, not noise.",
"My tabs are many, my focus is one.",
"I break procrastination with the first commit.",
"Crypto taught me risk, code taught me control.",
"Fewer excuses, more pull requests.",
"Quiet room, loud ideas.",
"Impossible is usually undocumented.",
"The TODO list fears consistency.",
"My English is fluent, my code should be too.",
"I can debate anything, but I prefer shipping.",
"Wired for learning, built for execution.",
"Fun fact: production finds every shortcut.",
"Build habits, not hype.",
"Bug today, lesson forever.",
"There are only 10 kinds of people: those who understand binary and those who do not.",
"I debug because being psychic is not in the standard library.",
"Works on my machine is not a deployment strategy.",
"Programmer humor: semicolon missing, happiness missing.",
"I would love to change the world, but they will not give me production access.",
"Any code of your own that you have not looked at for 6 months is someone else's code.",
"AI quote: automation rewards people who understand systems, not just tools.",
"First make it work, then make it right, then make it fast.",
"If at first you do not succeed, call it version 1.0.",
"There is no place like 127.0.0.1.",
"My code does not always run, but my confidence compiles.",
"A clean commit is better than a perfect excuse.",
"Real flex: readable code at 2 AM.",
"Hard problems make strong engineers.",
];
function pickRandomQuote(exclude = "") {
const candidates = quotes.filter((line) => line !== exclude);
return candidates[Math.floor(Math.random() * candidates.length)] || quotes[0];
}
const personaQuizQuestions = [
{ question: "Your coding peak time?", options: ["Early morning", "Afternoon", "Late night", "Random"], answer: 1 },
{ question: "When stuck, first move?", options: ["Read docs", "Use ChatGPT/AI", "Ask a friend", "Take a break"], answer: 1 },
{ question: "Preferred coding drink?", options: ["Water", "Tea", "Coffee", "Energy drink"], answer: 2 },
{ question: "Desk vibe?", options: ["Minimal clean", "Controlled chaos", "Fully messy", "Changes daily"], answer: 1 },
{ question: "Hardest school subject?", options: ["Math", "Science", "Nepali/English", "C++"], answer: 0 },
{ question: "Main motivation source?", options: ["Competition", "Curiosity", "Future goals", "Proving doubters wrong"], answer: 2 },
{ question: "You read error messages fully before fixing.", options: ["True", "False"], answer: 1 },
{ question: "Best non-Python language for you?", options: ["C/C++", "JavaScript", "Java", "None"], answer: 0 },
{ question: "Weekend coding hours?", options: ["0-2", "3-5", "6-8", "9+"], answer: 2 },
{ question: "If code works first try, you?", options: ["Celebrate", "Distrust it", "Commit instantly", "Re-run tests"], answer: 3 },
{ question: "Book type you enjoy most?", options: ["Self-help", "Philosophy", "Fiction/sci-fi", "Biography"], answer: 0 },
{ question: "Best study mode?", options: ["Silence", "Lo-fi/music", "Cafe noise", "With friends"], answer: 1 },
{ question: "In group chats you are:", options: ["Silent reader", "Meme sender", "Problem solver", "Debate starter"], answer: 3 },
{ question: "If someone challenges your idea:", options: ["Defend hard", "Ask questions", "Test both", "Ignore"], answer: 0 },
{ question: "You enjoy speaking in front of large groups.", options: ["True", "False"], answer: 0 },
{ question: "Puzzle preference?", options: ["Logic grids", "Chess", "Rubik's cube", "Riddles"], answer: 2 },
{ question: "Meme style you laugh at most?", options: ["Dark humor", "Coding memes", "Absurd memes", "Roasts"], answer: 0 },
{ question: "Biggest productivity killer?", options: ["Phone", "YouTube", "Overthinking", "Laziness"], answer: 1 },
{ question: "File naming style?", options: ["Super clean", "Kinda clean", "Total chaos", "Depends on mood"], answer: 1 },
{ question: "You make handwritten notes regularly.", options: ["True", "False"], answer: 0 },
{ question: "One app you use most daily?", options: ["YouTube", "VS Code", "Terminal", "Messaging app"], answer: 0 },
{ question: "Notifications setting?", options: ["Always on", "Important only", "Mostly off", "Flight mode often"], answer: 2 },
{ question: "Favorite weather?", options: ["Rainy", "Cold", "Sunny", "Stormy/cloudy"], answer: 2 },
{ question: "Dream place to visit?", options: ["Japan", "USA", "Europe", "Other"], answer: 3 },
{ question: "Debate strategy?", options: ["Facts/data", "Logic traps", "Calm persuasion", "Aggressive style"], answer: 1 },
{ question: "You sometimes wait till the last day to finish tasks.", options: ["True", "False"], answer: 0 },
{ question: "If you had a pet:", options: ["Dog", "Cat", "Bird", "None"], answer: 2 },
{ question: "Coding snack choice?", options: ["Chips", "Biscuits", "Fruits", "No snacks"], answer: 3 },
{ question: "School break vibe?", options: ["Talk with friends", "Read/watch stuff", "Wander around", "Practice debate"], answer: 0 },
{ question: "Ideal Saturday?", options: ["Build project", "Game all day", "Go out", "Sleep/rest"], answer: 0 },
{ question: "What annoys you most?", options: ["Slow internet", "Bad UI", "People acting dumb", "Wasted time"], answer: 2 },
{ question: "You usually re-read messages before sending.", options: ["True", "False"], answer: 1 },
{ question: "Team role you naturally take:", options: ["Leader", "Builder", "Researcher", "Critic"], answer: 3 },
{ question: "Favorite compliment to hear?", options: ["Smart", "Disciplined", "Creative", "Fearless"], answer: 0 },
{ question: "After school your energy is:", options: ["High", "Medium", "Low", "Unpredictable"], answer: 1 },
{ question: "Skill to max this year?", options: ["AI/ML", "Communication", "Math", "Discipline"], answer: 2 },
{ question: "You keep backup plans for important goals.", options: ["True", "False"], answer: 1 },
{ question: "In games you pick:", options: ["Tactical/stealth", "Aggressive fighter", "Support/utility", "Mixed"], answer: 3 },
{ question: "Movie ending preference?", options: ["Happy", "Dark", "Mind-bending", "Open ending"], answer: 2 },
{ question: "Favorite non-black tone?", options: ["Blue", "Orange", "Red", "Green"], answer: 0 },
{ question: "If you lose a debate:", options: ["Analyze mistakes", "Get mad", "Move on fast", "Demand rematch"], answer: 1 },
{ question: "You enjoy routine and structure.", options: ["True", "False"], answer: 1 },
{ question: "If you mastered one instrument:", options: ["Guitar", "Piano", "Drums", "Flute"], answer: 0 },
{ question: "Dream startup type?", options: ["AI tools", "EdTech", "Gaming tech", "Cybersecurity"], answer: 0 },
{ question: "Friends describe you as:", options: ["Intense", "Funny", "Reliable", "Unpredictable"], answer: 1 },
{ question: "Exam style?", options: ["Early prep", "Steady prep", "Last-minute grind", "Instinct + luck"], answer: 3 },
{ question: "You like unexpected surprises in real life.", options: ["True", "False"], answer: 0 },
{ question: "Best personal motto?", options: ["Build daily", "Stay dangerous", "Discipline > mood", "Outsmart chaos"], answer: 3 },
{ question: "Ideal birthday plan?", options: ["Small close circle", "Big party", "Solo chill", "Build + celebrate"], answer: 2 },
{ question: "Hidden question type you want most?", options: ["Personal habits", "Funny school moments", "Secret opinions", "Mixed chaos"], answer: 3 },
{ question: "Launch pulse message says it launches from:", options: ["Gongabu", "Mars", "Nepal", "Matrix"], answer: 1 },
{ question: "Drop Insight button does what to pulse chain?", options: ["Adds +5 pulses", "Resets chain", "Starts music", "Turns on matrix"], answer: 1 },
{ question: "At 5 pulses, which mode unlocks?", options: ["ISTJ Grid", "Chill Music", "Elon Warp", "Matrix Rain"], answer: 2 },
{ question: "At 10 pulses, which mode unlocks?", options: ["Chill Music", "Elon Warp", "Matrix Rain", "ISTJ Grid"], answer: 0 },
{ question: "At 15 pulses, which mode unlocks?", options: ["Matrix Rain", "ISTJ Grid", "Chill Music", "Elon Warp"], answer: 1 },
{ question: "At 20 pulses, which mode unlocks?", options: ["ISTJ Grid", "Elon Warp", "Matrix Rain", "Chill Music"], answer: 2 },
{ question: "GitHub profile featured on site:", options: ["DevXtechnic", "BikramGole", "NeoCoder", "AuraFarmer"], answer: 0 },
{ question: "Primary footer email uses which domain?", options: ["gmail.com", "proton.me", "keemail.me", "outlook.com"], answer: 2 },
{ question: "Main location shown on site:", options: ["Pokhara", "Gongabu, KTM, Nepal", "Lalitpur", "Bhaktapur"], answer: 1 },
{ question: "Age shown in identity snapshot:", options: ["14", "15", "16", "17"], answer: 1 },
{ question: "Distro and WM listed in About:", options: ["Ubuntu + GNOME", "Fedora + KDE", "Arch + Hyprland", "Debian + i3"], answer: 2 },
{ question: "Goal card in About says:", options: ["Become a game dev", "Become an AI Engineer", "Become a trader", "Become a designer"], answer: 1 },
{ question: "Hero status line says:", options: ["Always online", "Debater mode always ready", "Sleep mode active", "Build mode maybe"], answer: 1 },
{ question: "Movies list includes:", options: ["Interstellar", "Ready Player One", "Inception", "The Dark Knight"], answer: 1 },
{ question: "Games list includes:", options: ["Valorant", "Black Myth: Wukong", "CS2", "Dota 2"], answer: 1 },
{ question: "Anime list includes:", options: ["Jujutsu Kaisen", "Demon Slayer", "Classroom of the Elite", "Bleach"], answer: 2 },
{ question: "Books list includes:", options: ["Atomic Habits", "Sapiens", "1984", "The Alchemist"], answer: 2 },
{ question: "AI leaders card lists:", options: ["Mark Zuckerberg, Sundar Pichai, Satya Nadella", "Sam Altman, Dario Amodei, Elon Musk", "Linus Torvalds, Guido van Rossum, Vitalik Buterin", "Andrew Ng, Ilya Sutskever, Jensen Huang"], answer: 1 },
{ question: "YouTube card lists:", options: ["Luke Smith and Fireship", "Matt Wolfe and AI Explained", "Lex Fridman and Huberman", "MKBHD and Veritasium"], answer: 1 },
{ question: "The penguin tummy badge displays:", options: ["Static </> tag", "Current BS day number", "Current AD month", "CPU usage"], answer: 1 },
{ question: "Quick panel open hint is shown as:", options: ["Ctrl/Cmd + K", "Alt + P", "Ctrl/🐧 + K", "Shift + Space"], answer: 2 },
{ question: "Navbar pages are:", options: ["Home, Projects, Blog", "Home, About, Contact", "About, Works, Contact", "Home only"], answer: 1 },
{ question: "Default site vibe is:", options: ["Light and minimal", "Dark playful space theme", "Corporate white", "Monochrome print style"], answer: 1 },
{ question: "Each quiz run currently asks:", options: ["3 random questions", "5 random questions", "10 random questions", "All questions"], answer: 2 },
{ question: "Launch Pulse includes:", options: ["Only text update", "Visual + sound reaction", "Only sound", "Only matrix effect"], answer: 1 },
{ question: "Which mode adds falling code rain?", options: ["ISTJ mode", "Elon mode", "Matrix mode", "Chill mode"], answer: 2 },
{ question: "The chaos tagline used on site is:", options: ["Aura Farmer", "System Hacker", "Cloud Ninja", "Night Coder"], answer: 0 },
{ question: "Brand name shown in header:", options: ["Bikram", "Aura", "Neo", "DevX"], answer: 2 },
{ question: "Which section fetches repositories from GitHub API?", options: ["Mission Console", "Persona Quiz", "Culture + Brain Fuel", "Live GitHub"], answer: 3 },
{ question: "Which movie in your list is based on a virtual-world competition?", options: ["Nayak", "Ready Player One", "BFG", "The Real Jackpot"], answer: 1 },
{ question: "Which keyboard combo opens the command palette on site?", options: ["Ctrl + P", "Ctrl + J", "Ctrl + K", "Alt + Enter"], answer: 2 },
{ question: "In Black Flag theme, the hero gun appears on which side of title?", options: ["Left", "Right", "Both sides", "It is hidden"], answer: 0 },
{ question: "Which mode label replaced the old Libertarian theme?", options: ["Paper Link", "Neo Blue", "Black Flag Uprising", "Blood Moon"], answer: 2 },
{ question: "What vibe best matches this site?", options: ["Corporate dashboard", "Chaotic fun", "News portal", "Minimal blog"], answer: 1 },
{ question: "Which email is marked as Primary in Contact?", options: ["Develope.genius@gmail.com", "Bikramgole.genius@keemail.me", "neo@matrix.com", "devx@proton.me"], answer: 1 },
{ question: "What does the quiz do when current pool runs out?", options: ["Auto-download more", "Stops and asks reset/refresh", "Repeats previous 10", "Crashes intentionally"], answer: 1 },
{ question: "Which page describes Identity Snapshot?", options: ["Home", "Contact", "About", "All pages"], answer: 2 },
{ question: "Which section title includes the word Console?", options: ["Mission Console", "Open Channel", "Identity Snapshot", "Live GitHub"], answer: 0 },
{ question: "What is the section where custom commands run?", options: ["AI Constellation", "Neo Terminal", "Culture + Brain Fuel", "Direct Links"], answer: 1 },
{ question: "Which item is NOT in your stated interests?", options: ["Linux", "Open source", "Philosophy", "Golf"], answer: 3 },
{ question: "What theme style did you explicitly reject?", options: ["Dark mode", "Light chunky UI", "Space visuals", "Interactive effects"], answer: 1 },
{ question: "Which phrase best describes your debate style from quiz answers?", options: ["Avoid conflict", "Logic traps", "Only humor", "Never defend ideas"], answer: 1 },
{ question: "What is shown under your strengths in About?", options: ["Great English speaker", "Graphic design only", "Cooking", "Photography"], answer: 0 },
{ question: "Which card category appears in Culture + Brain Fuel?", options: ["Podcasts", "Movies", "Travel", "Finance index"], answer: 1 },
{ question: "What is the intended deploy target for this site?", options: ["Heroku", "GitHub Pages", "Netlify Functions only", "Vercel Edge only"], answer: 1 },
{ question: "Which operating style matches your identity line?", options: ["Mac + Finder", "Windows + Explorer", "Arch + Hyprland", "ChromeOS"], answer: 2 },
{ question: "The persona nickname used in branding is:", options: ["Cipher", "Neo", "Agent", "Root"], answer: 1 },
{ question: "What happens at 20 pulse milestone?", options: ["Theme reset", "Matrix Rain", "Quiz reset", "Music off"], answer: 1 },
{ question: "Which card appears in AI + Influence Stack?", options: ["Crypto", "Car collection", "Sports team", "Fitness plan"], answer: 0 },
{ question: "Which section pushes your quote/insight lines with typing effect?", options: ["Mission Console", "Direct Links", "Live GitHub", "Identity Snapshot"], answer: 0 },
];
function triggerPulseBackdrop(clientX = null, clientY = null) {
const width = window.innerWidth || 1;
const height = window.innerHeight || 1;
const x = typeof clientX === "number" && clientX > 0 ? clientX : width * 0.5;
const y = typeof clientY === "number" && clientY > 0 ? clientY : height * 0.35;
const { isConstrained, isFirefoxLike } = runtimeFlags;
if (!pulseWaveLayer) {
pulseWaveLayer = document.createElement("div");
pulseWaveLayer.className = "pulse-wave";
pulseWaveRing = document.createElement("span");
pulseWaveRing.className = "pulse-wave-ring";
pulseWaveLayer.appendChild(pulseWaveRing);
document.body.appendChild(pulseWaveLayer);
}
if (!pulseCoreFlash) {
pulseCoreFlash = document.createElement("span");
pulseCoreFlash.className = "pulse-core-flash";
document.body.appendChild(pulseCoreFlash);
}
const px = `${Math.round((x / width) * 100)}%`;
const py = `${Math.round((y / height) * 100)}%`;
pulseWaveLayer.style.setProperty("--pulse-x", px);
pulseWaveLayer.style.setProperty("--pulse-y", py);
pulseCoreFlash.style.left = `${x}px`;
pulseCoreFlash.style.top = `${y}px`;
pulseWaveLayer.classList.remove("pulse-active");
pulseCoreFlash.classList.remove("pulse-active");
// Reflow so fallback class animation retriggers on rapid launches.
void pulseWaveLayer.offsetWidth;
pulseWaveLayer.classList.add("pulse-active");
pulseCoreFlash.classList.add("pulse-active");
if (pulseFallbackTimeout) window.clearTimeout(pulseFallbackTimeout);
pulseFallbackTimeout = window.setTimeout(() => {
pulseWaveLayer?.classList.remove("pulse-active");
pulseCoreFlash?.classList.remove("pulse-active");
}, 920);
if (typeof pulseWaveLayer.animate !== "function" || typeof pulseCoreFlash.animate !== "function") {
return;
}
pulseWaveLayer.getAnimations().forEach((animation) => animation.cancel());
pulseWaveRing?.getAnimations().forEach((animation) => animation.cancel());
pulseCoreFlash.getAnimations().forEach((animation) => animation.cancel());
const waveDuration = isConstrained ? 640 : 820;
const waveScaleTo = isConstrained ? 1.12 : 1.2;
try {
pulseWaveLayer.animate(
[
{ transform: "scale(0.92)", opacity: 0 },
{ opacity: isFirefoxLike ? 0.62 : 0.82, offset: 0.18 },
{ opacity: 0.3, offset: 0.6 },
{ transform: `scale(${waveScaleTo})`, opacity: 0 },
],
{ duration: waveDuration, easing: "cubic-bezier(0.16, 0.82, 0.27, 1)", fill: "forwards" }
);
pulseWaveRing?.animate(
[
{ transform: "translate(-50%, -50%) scale(0.34)", opacity: 0.95 },
{ transform: `translate(-50%, -50%) scale(${isConstrained ? 9.5 : 13})`, opacity: 0 },
],
{ duration: waveDuration, easing: "ease-out", fill: "forwards" }
);
pulseCoreFlash.animate(
[
{ transform: "translate(-50%, -50%) scale(0.45)", opacity: 0.9 },
{ transform: "translate(-50%, -50%) scale(3.4)", opacity: 0 },
],
{ duration: isConstrained ? 320 : 420, easing: "cubic-bezier(0.2, 0.7, 0.3, 1)", fill: "forwards" }
);
} catch (error) {
// Class-based fallback above already guarantees a visible pulse.
}
}
function playPulseSound(pulseCount = 1) {
const context = ensureAudioContext();
if (!context) return;
const now = context.currentTime;
const lead = context.createOscillator();
const sub = context.createOscillator();
const gain = context.createGain();
const filter = context.createBiquadFilter();
const accent = (pulseCount % 6) * 22;
lead.type = "triangle";
lead.frequency.setValueAtTime(460 + accent, now);
lead.frequency.exponentialRampToValueAtTime(170, now + 0.2);
sub.type = "sine";
sub.frequency.setValueAtTime(90, now);
sub.frequency.exponentialRampToValueAtTime(52, now + 0.2);
filter.type = "bandpass";
filter.frequency.setValueAtTime(980, now);
filter.frequency.exponentialRampToValueAtTime(420, now + 0.2);
filter.Q.value = 1.1;
gain.gain.setValueAtTime(0.0001, now);
gain.gain.exponentialRampToValueAtTime(0.17, now + 0.02);
gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.22);
lead.connect(filter);
sub.connect(filter);
filter.connect(gain).connect(context.destination);
lead.start(now);
sub.start(now);
lead.stop(now + 0.24);
sub.stop(now + 0.24);
}
function triggerPenguinPowerUp() {
if (!penguinAvatar) return;
penguinAvatar.classList.remove("power-up");
// Restart animation if pulses happen quickly.
void penguinAvatar.offsetWidth;
penguinAvatar.classList.add("power-up");
window.setTimeout(() => penguinAvatar.classList.remove("power-up"), 620);
}
function initRuntimeCompatibility() {
const apply = () => {
computeRuntimeFlags();
document.body.classList.toggle("browser-firefox", runtimeFlags.isFirefoxLike);
document.body.classList.toggle("browser-not-firefox", !runtimeFlags.isFirefoxLike);
document.body.classList.toggle("browser-vivaldi", runtimeFlags.isVivaldi);
document.body.classList.toggle("force-terminal-fallback", runtimeFlags.isConstrained);
resizeCanvas();
};
apply();
window.addEventListener("resize", apply);
}
function applyTerminalFontFallbackMode() {
if (document.body.classList.contains("force-terminal-fallback")) {
document.body.classList.add("no-nerd-font");
return;
}
const hasNerdFont = NERD_FONT_FAMILIES.some((family) => {
if (!window?.document?.fonts?.check) return false;
return window.document.fonts.check(`12px "${family}"`);
});
document.body.classList.toggle("no-nerd-font", !hasNerdFont);
}
function initTerminalFontFallbackMode() {
applyTerminalFontFallbackMode();
if (window?.document?.fonts?.ready) {
window.document.fonts.ready
.then(() => applyTerminalFontFallbackMode())
.catch(() => {
// Ignore font readiness failures.
});
}
}
function initPenguinDateBadge() {
if (!penguinBelly && !androidDateBadge) return;
let lastAdDate = "";
const getNepalAdDate = () => {
const parts = new Intl.DateTimeFormat("en-US", {
timeZone: NEPAL_TIMEZONE,
year: "numeric",
month: "2-digit",
day: "2-digit",
}).formatToParts(new Date());
const year = parts.find((part) => part.type === "year")?.value;
const month = parts.find((part) => part.type === "month")?.value;
const day = parts.find((part) => part.type === "day")?.value;
return `${year}-${month}-${day}`;
};
const parseBsDate = (value) => {
if (typeof value === "string") {
const match = value.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/);
if (match) {
return {
year: Number.parseInt(match[1], 10),
month: Number.parseInt(match[2], 10),
day: Number.parseInt(match[3], 10),
};
}
}
if (value && typeof value === "object" && "day" in value) {
return {
year: Number.parseInt(value.year, 10),
month: Number.parseInt(value.month, 10),
day: Number.parseInt(value.day, 10),
};
}
return null;
};
const getFallbackDay = () =>
new Intl.DateTimeFormat("en-US", {
timeZone: NEPAL_TIMEZONE,
day: "numeric",
}).format(new Date());
const loadBsConverter = async () => {
if (adToBsConverter) return adToBsConverter;
try {
const module = await import(BS_CONVERTER_URL);
if (typeof module.ADtoBS === "function") {
adToBsConverter = module.ADtoBS;
}
} catch (error) {
adToBsConverter = null;
}
return adToBsConverter;
};
const tick = async () => {
const adDate = getNepalAdDate();
if (adDate === lastAdDate && (penguinBelly?.dataset.day || androidDateBadge?.dataset.day)) return;
let bsDate = null;
const converter = await loadBsConverter();
if (converter) {
try {
const bsValue = converter(adDate);
bsDate = parseBsDate(bsValue);
} catch (error) {
bsDate = null;
}
}
const fallbackDay = getFallbackDay();
if (penguinBelly) {
penguinBelly.dataset.day = String(bsDate?.day || fallbackDay);
}
if (androidDateBadge) {
const dayText = String(bsDate?.day || fallbackDay);
androidDateBadge.textContent = dayText;
androidDateBadge.dataset.day = dayText;
}
lastAdDate = adDate;
};
void tick();
window.setInterval(() => {
void tick();
}, 60 * 1000);
}
function applyTheme(theme, notify = false) {
const selected = THEME_OPTIONS.includes(theme) ? theme : "neo";
currentTheme = selected;
document.documentElement.dataset.theme = selected;
document.body.dataset.theme = selected;
if (headerThemeSelect) headerThemeSelect.value = selected;
if (heroName) {
if (selected === "blackflag" && heroName.textContent.trim().length > 0) {
heroName.classList.add("name-armed");
} else {
heroName.classList.remove("name-armed");
}
}
if (miniTerminalTheme) {
miniTerminalTheme.textContent = `theme: ${selected}`;
}
try {
window.localStorage.setItem(THEME_STORAGE_KEY, selected);
} catch (error) {
// Ignore storage errors.
}
setThemeInUrl(selected);
updateInternalLinks();
resizeCanvas();
if (notify) showToast(`Theme changed: ${selected}`);
}
function initThemeSwitcher() {
let savedTheme = "neo";
try {
const urlTheme = getThemeFromUrl();
const storedTheme = window.localStorage.getItem(THEME_STORAGE_KEY);
savedTheme = storedTheme || urlTheme || "neo";
if (!storedTheme && urlTheme) {
window.localStorage.setItem(THEME_STORAGE_KEY, urlTheme);
}
} catch (error) {
savedTheme = "neo";
}
applyTheme(savedTheme, false);
window.addEventListener("pageshow", () => {
let latestTheme = "neo";
try {
const storedTheme = window.localStorage.getItem(THEME_STORAGE_KEY);
latestTheme = storedTheme || getThemeFromUrl() || "neo";
} catch (error) {
latestTheme = "neo";
}
if (latestTheme !== currentTheme) {
applyTheme(latestTheme, false);
}
});
window.addEventListener("storage", (event) => {
if (event.key !== THEME_STORAGE_KEY || !event.newValue) return;
if (!THEME_OPTIONS.includes(event.newValue)) return;
if (event.newValue !== currentTheme) {
applyTheme(event.newValue, false);
}
});
headerThemeSelect?.addEventListener("change", (event) => {
applyTheme(event.target.value, true);
});
themeCycleBtn?.addEventListener("click", () => {
const idx = THEME_OPTIONS.indexOf(currentTheme);
const next = THEME_OPTIONS[(idx + 1 + THEME_OPTIONS.length) % THEME_OPTIONS.length];
applyTheme(next, true);
});
}
function initNavThemeGuard() {
const navLinks = document.querySelectorAll('a[href$=".html"], a[href*=".html?"]');
navLinks.forEach((link) => {
link.addEventListener("click", () => {
try {
const theme = THEME_OPTIONS.includes(currentTheme) ? currentTheme : "neo";
window.localStorage.setItem(THEME_STORAGE_KEY, theme);
const href = link.getAttribute("href");
if (href) {
link.setAttribute("href", applyThemeToUrl(href, theme));
}
} catch (error) {
// Ignore storage/link update failures.
}
});
});
}
function spawnBlackflagShot(startX, startY, side, targetX = null, targetY = null) {
const bullet = document.createElement("span");
bullet.className = "gun-bullet";
bullet.style.left = `${startX}px`;
bullet.style.top = `${startY}px`;
document.body.appendChild(bullet);
const fallbackX = side === "left" ? startX + window.innerWidth * 0.58 : startX - window.innerWidth * 0.58;
const fallbackY = startY + (side === "left" ? 6 : -6);
const endX = Number.isFinite(targetX) ? targetX : fallbackX;
const endY = Number.isFinite(targetY) ? targetY : fallbackY;
const dx = endX - startX;
const dy = endY - startY;
const angle = Math.atan2(dy, dx) * (180 / Math.PI);
const distance = Math.max(260, Math.min(920, Math.hypot(dx, dy)));
const unitX = dx / (Math.hypot(dx, dy) || 1);
const unitY = dy / (Math.hypot(dx, dy) || 1);
const travelX = unitX * distance;
const travelY = unitY * distance;
bullet.animate(
[
{ transform: `translate(-50%, -50%) rotate(${angle}deg) scaleX(1)`, opacity: 1 },
{ transform: `translate(calc(-50% + ${travelX}px), calc(-50% + ${travelY}px)) rotate(${angle}deg) scaleX(0.46)`, opacity: 0 },
],
{ duration: 340, easing: "cubic-bezier(0.12, 0.77, 0.3, 1)", fill: "forwards" }
).onfinish = () => bullet.remove();
const flash = document.createElement("span");
flash.className = "gun-flash";
flash.style.left = `${startX}px`;
flash.style.top = `${startY}px`;
document.body.appendChild(flash);
flash.animate(
[
{ transform: "translate(-50%, -50%) scale(0.55)", opacity: 0.95 },
{ transform: "translate(-50%, -50%) scale(1.75)", opacity: 0 },
],
{ duration: 170, easing: "ease-out", fill: "forwards" }
).onfinish = () => flash.remove();
}
function triggerBlackflagBlast(x, y) {
const pulse = document.createElement("span");
pulse.className = "gun-flash";
pulse.style.left = `${x}px`;
pulse.style.top = `${y}px`;
pulse.style.width = "66px";
pulse.style.height = "66px";
pulse.style.transform = "translate(-50%, -50%)";
document.body.appendChild(pulse);
window.setTimeout(() => pulse.remove(), 170);
}
function updateBlackflagGunAim(targetX, targetY, rect) {
if (!heroName) return;
const centerX = rect.left + rect.width * 0.5;
const centerY = rect.top + rect.height * 0.55;
const tx = Number.isFinite(targetX) ? targetX : centerX;
const ty = Number.isFinite(targetY) ? targetY : centerY;
const leftX = rect.left - 26;
const leftAngle = Math.atan2(ty - centerY, tx - leftX) * (180 / Math.PI);
const clamp = (n, min, max) => Math.max(min, Math.min(max, n));
const yShift = clamp((ty - centerY) * 0.12, -12, 12);
const xSwing = clamp((tx - centerX) * 0.02, -8, 8);
heroName.style.setProperty("--gun-left-angle", `${clamp(leftAngle, -80, 80)}deg`);
heroName.style.setProperty("--gun-y-shift", `${yShift}px`);
heroName.style.setProperty("--gun-left-x", `${xSwing}px`);
}
function fireBlackflagShots(event = null) {
if (currentTheme !== "blackflag") return;
if (!heroName || !heroName.classList.contains("name-armed")) return;
const now = performance.now();
if (now < blackflagShotLockUntil) return;
blackflagShotLockUntil = now + 160;
const rect = heroName.getBoundingClientRect();
const style = window.getComputedStyle(heroName);
const anchorOffset = Number.parseFloat(style.getPropertyValue("--gun-anchor-x")) || -28;
const muzzleLen = Number.parseFloat(style.getPropertyValue("--gun-muzzle-len")) || 154;
const y = rect.top + rect.height * 0.56;
const leftStockX = rect.left + anchorOffset;
const tx = Number.isFinite(event?.clientX) ? event.clientX : rect.left + rect.width * 0.5;
const ty = Number.isFinite(event?.clientY) ? event.clientY : y;
updateBlackflagGunAim(tx, ty, rect);
const leftAngleDeg = Math.atan2(ty - y, tx - leftStockX) * (180 / Math.PI);
const leftAngleRad = (leftAngleDeg * Math.PI) / 180;
const leftMuzzleX = leftStockX + Math.cos(leftAngleRad) * muzzleLen;
const leftMuzzleY = y + Math.sin(leftAngleRad) * muzzleLen;
spawnBlackflagShot(leftMuzzleX, leftMuzzleY, "left", tx, ty);
if (event?.clientX && event?.clientY) {
triggerBlackflagBlast(event.clientX, event.clientY);
}
}
function initBlackflagGunfire() {
document.addEventListener("click", (event) => {
fireBlackflagShots(event);
});
}
function appendTerminalLine(text, type = "out") {
if (!miniTerminalOutput) return;
const line = document.createElement("p");