hia-frontend-debug-tool 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,1381 @@
1
+ 'use strict';
2
+
3
+ var React2 = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var hiaFrontendUtils = require('hia-frontend-utils');
6
+ var zustand = require('zustand');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var React2__default = /*#__PURE__*/_interopDefault(React2);
11
+
12
+ // src/debug-tool.tsx
13
+
14
+ // src/styles/styles.ts
15
+ var debugFloatingButtonStyle = {
16
+ position: "fixed",
17
+ right: "10px",
18
+ bottom: "80px",
19
+ borderRadius: "50%",
20
+ backgroundColor: "#f0f0f0",
21
+ border: "1px solid #ccc",
22
+ padding: "8px 12px",
23
+ fontWeight: "bold",
24
+ zIndex: 9999
25
+ };
26
+ var debugMenuPanelStyle = {
27
+ position: "fixed",
28
+ right: "20px",
29
+ bottom: "90px",
30
+ display: "flex",
31
+ flexDirection: "column",
32
+ maxHeight: "400px",
33
+ backgroundColor: "#ffffff",
34
+ border: "1px solid #e0e0e0",
35
+ borderRadius: "8px",
36
+ boxShadow: "0 4px 8px rgba(0, 0, 0, 0.1)",
37
+ zIndex: 1e4,
38
+ overflowY: "auto"
39
+ };
40
+ var panelHeaderStyle = {
41
+ display: "flex",
42
+ alignItems: "center",
43
+ justifyContent: "space-between",
44
+ padding: "10px 15px",
45
+ backgroundColor: "#f5f5f5",
46
+ borderBottom: "1px solid #e0e0e0",
47
+ flexShrink: 0
48
+ };
49
+ var h2Style = {
50
+ margin: 0,
51
+ fontSize: "16px"
52
+ };
53
+ var modalOverlayStyle = {
54
+ position: "fixed",
55
+ top: 0,
56
+ left: 0,
57
+ width: "100%",
58
+ height: "100%",
59
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
60
+ zIndex: 9999
61
+ };
62
+ var debugFeaturePanelStyle = {
63
+ margin: "20px",
64
+ position: "fixed",
65
+ top: 0,
66
+ left: 0,
67
+ width: "calc(100% - 40px)",
68
+ height: "calc(100% - 40px)",
69
+ backgroundColor: "#ffffff",
70
+ zIndex: 10001,
71
+ display: "flex",
72
+ flexDirection: "column"
73
+ };
74
+ var panelToolbarStyle = {
75
+ display: "flex",
76
+ alignItems: "center",
77
+ padding: "10px",
78
+ borderBottom: "1px solid #e0e0e0",
79
+ gap: "8px",
80
+ flexShrink: 0
81
+ };
82
+ var logListContainerStyle = {
83
+ flex: 1,
84
+ padding: "10px",
85
+ overflowY: "auto",
86
+ fontFamily: "monospace",
87
+ fontSize: "12px",
88
+ backgroundColor: "#ffffff"
89
+ };
90
+ var logItemStyle = {
91
+ display: "flex",
92
+ alignItems: "flex-start",
93
+ padding: "4px 0",
94
+ borderBottom: "1px solid #e0e0e0"
95
+ };
96
+ var logTimestampStyle = {
97
+ marginRight: "10px",
98
+ color: "#888888"
99
+ };
100
+ var logMessageStyle = {
101
+ margin: 0,
102
+ wordBreak: "break-all",
103
+ whiteSpace: "pre-wrap"
104
+ };
105
+ var logTypeStyles = {
106
+ log: { color: "#333333" },
107
+ info: { color: "#007bff" },
108
+ warn: { color: "#ffc107" },
109
+ error: { color: "#dc3545" },
110
+ debug: { color: "#6c757d" },
111
+ return: { color: "#8a2be2" }
112
+ };
113
+ var loginFormContainerStyle = {
114
+ display: "flex",
115
+ flex: 1,
116
+ flexDirection: "column",
117
+ gap: "15px",
118
+ padding: "20px",
119
+ overflowY: "auto"
120
+ };
121
+ var formActionsStyle = {
122
+ display: "flex",
123
+ justifyContent: "flex-start",
124
+ marginTop: "10px"
125
+ };
126
+ var searchContainerStyle = {
127
+ display: "flex",
128
+ gap: "8px",
129
+ marginBottom: "16px",
130
+ alignItems: "center"
131
+ };
132
+ var logListStyle = {
133
+ overflowY: "auto"
134
+ };
135
+ var logSummaryStyle = {
136
+ wordBreak: "break-all",
137
+ margin: 0,
138
+ cursor: "pointer"
139
+ };
140
+ var logContentStyle = {
141
+ padding: "8px",
142
+ wordBreak: "break-all",
143
+ whiteSpace: "pre-wrap",
144
+ backgroundColor: "#f5f5f5",
145
+ borderRadius: "4px"
146
+ };
147
+ var pageNavigationContentStyle = {
148
+ display: "flex",
149
+ flexDirection: "column",
150
+ gap: "10px",
151
+ padding: "20px"
152
+ };
153
+ var h3Style = {
154
+ margin: 0,
155
+ fontSize: "16px"
156
+ };
157
+ var scriptExecutorContentStyle = {
158
+ display: "flex",
159
+ flex: 1,
160
+ flexDirection: "column",
161
+ overflow: "hidden"
162
+ };
163
+ var scriptInputSectionStyle = {
164
+ display: "flex",
165
+ flex: 1,
166
+ flexDirection: "column",
167
+ minHeight: "150px",
168
+ borderBottom: "1px solid #e0e0e0"
169
+ };
170
+ var scriptTextareaStyle = {
171
+ flex: 1,
172
+ width: "100%",
173
+ padding: "10px",
174
+ fontFamily: "monospace",
175
+ fontSize: "14px",
176
+ resize: "none",
177
+ outline: "none",
178
+ border: "none"
179
+ };
180
+ var scriptActionsStyle = {
181
+ display: "flex",
182
+ justifyContent: "flex-end",
183
+ gap: "8px",
184
+ padding: "8px",
185
+ borderTop: "1px solid #e0e0e0"
186
+ };
187
+ var scriptOutputSectionStyle = {
188
+ display: "flex",
189
+ flex: 1,
190
+ flexDirection: "column",
191
+ overflow: "hidden"
192
+ };
193
+ var storageSearchInputStyle = {
194
+ width: "100%",
195
+ padding: "8px",
196
+ border: "1px solid #ccc",
197
+ borderRadius: "4px"
198
+ };
199
+ var storageTableContainerStyle = {
200
+ flex: 1,
201
+ overflowY: "auto",
202
+ padding: "10px"
203
+ };
204
+ var menuItemStyle = {
205
+ cursor: "pointer",
206
+ padding: "8px 12px"
207
+ };
208
+ var clearButtonStyle = {
209
+ marginLeft: "auto"
210
+ };
211
+ var networkLogContainerStyle = {
212
+ padding: "10px",
213
+ display: "flex",
214
+ flexDirection: "column",
215
+ flex: 1,
216
+ overflow: "hidden"
217
+ };
218
+ var flex1Style = {
219
+ flex: 1
220
+ };
221
+ var holdButtonsContainerStyle = {
222
+ display: "flex",
223
+ flexDirection: "row",
224
+ gap: "8px",
225
+ marginBottom: "10px"
226
+ };
227
+ var textareaStyle = {
228
+ width: "100%",
229
+ minHeight: "80px"
230
+ };
231
+ var FloatingButton = ({ onClick }) => {
232
+ const [position, setPosition] = React2.useState({ x: 0, y: 0 });
233
+ const [isDragging, setIsDragging] = React2.useState(false);
234
+ const [isVisible, setIsVisible] = React2.useState(false);
235
+ const gestureStep = React2.useRef(0);
236
+ const gestureTimeout = React2.useRef(null);
237
+ const globalDragStart = React2.useRef(null);
238
+ const dragHappened = React2.useRef(false);
239
+ const dragStartPos = React2.useRef({ x: 0, y: 0 });
240
+ const elementStartPos = React2.useRef({ x: 0, y: 0 });
241
+ const clickCount = React2.useRef(0);
242
+ const clickTimeout = React2.useRef(null);
243
+ React2.useEffect(() => {
244
+ const handleGlobalMouseDown = (e) => {
245
+ globalDragStart.current = { x: e.clientX, y: e.clientY };
246
+ };
247
+ const handleGlobalMouseUp = (e) => {
248
+ if (!globalDragStart.current) {
249
+ return;
250
+ }
251
+ const dx = e.clientX - globalDragStart.current.x;
252
+ const dy = e.clientY - globalDragStart.current.y;
253
+ const absDx = Math.abs(dx);
254
+ const absDy = Math.abs(dy);
255
+ const THRESHOLD = 200;
256
+ if (dy > THRESHOLD && absDy > absDx) {
257
+ if (gestureStep.current === 0) {
258
+ gestureStep.current = 1;
259
+ if (gestureTimeout.current) {
260
+ clearTimeout(gestureTimeout.current);
261
+ }
262
+ gestureTimeout.current = setTimeout(() => {
263
+ gestureStep.current = 0;
264
+ }, 2e3);
265
+ }
266
+ } else if (dx > THRESHOLD && absDx > absDy) {
267
+ if (gestureStep.current === 1) {
268
+ setIsVisible((prev) => !prev);
269
+ gestureStep.current = 0;
270
+ if (gestureTimeout.current) {
271
+ clearTimeout(gestureTimeout.current);
272
+ }
273
+ } else {
274
+ gestureStep.current = 0;
275
+ }
276
+ }
277
+ globalDragStart.current = null;
278
+ };
279
+ window.addEventListener("mousedown", handleGlobalMouseDown);
280
+ window.addEventListener("mouseup", handleGlobalMouseUp);
281
+ return () => {
282
+ window.removeEventListener("mousedown", handleGlobalMouseDown);
283
+ window.removeEventListener("mouseup", handleGlobalMouseUp);
284
+ if (gestureTimeout.current) {
285
+ clearTimeout(gestureTimeout.current);
286
+ }
287
+ };
288
+ }, []);
289
+ React2.useEffect(() => {
290
+ const handleGlobalClick = () => {
291
+ clickCount.current += 1;
292
+ if (clickCount.current === 1) {
293
+ clickTimeout.current = setTimeout(() => {
294
+ clickCount.current = 0;
295
+ }, 3e3);
296
+ }
297
+ if (clickCount.current >= 10) {
298
+ setIsVisible((prev) => !prev);
299
+ clickCount.current = 0;
300
+ if (clickTimeout.current) {
301
+ clearTimeout(clickTimeout.current);
302
+ }
303
+ }
304
+ };
305
+ window.addEventListener("click", handleGlobalClick);
306
+ return () => {
307
+ window.removeEventListener("click", handleGlobalClick);
308
+ if (clickTimeout.current) {
309
+ clearTimeout(clickTimeout.current);
310
+ }
311
+ };
312
+ }, []);
313
+ const handleMouseDown = (e) => {
314
+ if (e.button !== 0) {
315
+ return;
316
+ }
317
+ dragHappened.current = false;
318
+ setIsDragging(true);
319
+ dragStartPos.current = { x: e.clientX, y: e.clientY };
320
+ elementStartPos.current = { ...position };
321
+ const handleMouseMove = (event) => {
322
+ const dx = event.clientX - dragStartPos.current.x;
323
+ const dy = event.clientY - dragStartPos.current.y;
324
+ if (!dragHappened.current && (Math.abs(dx) > 5 || Math.abs(dy) > 5)) {
325
+ dragHappened.current = true;
326
+ }
327
+ setPosition({
328
+ x: elementStartPos.current.x + dx,
329
+ y: elementStartPos.current.y + dy
330
+ });
331
+ };
332
+ const handleMouseUp = () => {
333
+ window.removeEventListener("mousemove", handleMouseMove);
334
+ window.removeEventListener("mouseup", handleMouseUp);
335
+ setIsDragging(false);
336
+ };
337
+ window.addEventListener("mousemove", handleMouseMove);
338
+ window.addEventListener("mouseup", handleMouseUp);
339
+ };
340
+ const handleClick = (e) => {
341
+ if (dragHappened.current) {
342
+ e.preventDefault();
343
+ e.stopPropagation();
344
+ return;
345
+ }
346
+ onClick();
347
+ };
348
+ const buttonStyle = {
349
+ ...debugFloatingButtonStyle,
350
+ transform: `translate(${position.x}px, ${position.y}px)`,
351
+ cursor: isDragging ? "grabbing" : "grab",
352
+ display: isVisible ? "flex" : "none"
353
+ };
354
+ return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: buttonStyle, onMouseDown: handleMouseDown, onClick: handleClick, children: "DEBUG" });
355
+ };
356
+ var floating_button_default = FloatingButton;
357
+
358
+ // src/utils/cookie.ts
359
+ function getCookie(name) {
360
+ if (typeof document === "undefined") {
361
+ return "";
362
+ }
363
+ const match = document.cookie.match(new RegExp(`(?:^|; )${name.replace(/([.$?*|{}()[\]\\/+^])/g, "\\$1")}=([^;]*)`));
364
+ return match ? decodeURIComponent(match[1] ?? "") : "";
365
+ }
366
+ function setCookie(name, value, days) {
367
+ if (typeof document === "undefined") {
368
+ return;
369
+ }
370
+ let expires = "";
371
+ document.cookie = `${name}=${encodeURIComponent(value)}${expires}; path=/`;
372
+ }
373
+ function deleteCookie(name) {
374
+ if (typeof document === "undefined") {
375
+ return;
376
+ }
377
+ document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
378
+ }
379
+ function ChangeHost() {
380
+ const handleHost = (host) => {
381
+ setCookie("hia-debug-mode-env", host);
382
+ alert(`\uD638\uC2A4\uD2B8\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4. :${host}`);
383
+ console.log("\uD638\uC2A4\uD2B8\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", {
384
+ "hia-debug-mode-env": getCookie("hia-debug-mode-env")
385
+ });
386
+ };
387
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
388
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: panelHeaderStyle, children: /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: "API \uD638\uC2A4\uD2B8" }) }),
389
+ /* @__PURE__ */ jsxRuntime.jsxs("ul", { children: [
390
+ /* @__PURE__ */ jsxRuntime.jsx("li", { style: menuItemStyle, onClick: () => handleHost("local"), children: "local" }),
391
+ /* @__PURE__ */ jsxRuntime.jsx("li", { style: menuItemStyle, onClick: () => handleHost("dev"), children: "dev" }),
392
+ /* @__PURE__ */ jsxRuntime.jsx("li", { style: menuItemStyle, onClick: () => handleHost("stg"), children: "stg" })
393
+ ] })
394
+ ] });
395
+ }
396
+ var filterNameCookieKey = "hia-debug-mode-filter-name";
397
+ var filterList = [
398
+ {
399
+ key: "console-log",
400
+ description: "\uCF58\uC194\uB85C\uADF8 on/off"
401
+ },
402
+ {
403
+ key: "http-log",
404
+ description: "http \uC694\uCCAD/\uC751\uB2F5 \uB85C\uADF8 on/off"
405
+ },
406
+ {
407
+ key: "validation-off",
408
+ description: "\uC720\uD6A8\uC131\uAC80\uC0AC off"
409
+ },
410
+ {
411
+ key: "data-init-button",
412
+ description: "\uCD08\uAE30\uD654 \uBC84\uD2BC \uCD94\uAC00"
413
+ }
414
+ ];
415
+ function Filter() {
416
+ const [filterName, setFilterName] = React2__default.default.useState("");
417
+ React2.useEffect(() => {
418
+ const name = getCookie(filterNameCookieKey);
419
+ setFilterName(name);
420
+ }, []);
421
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
422
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: panelHeaderStyle, children: /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: "\uB514\uBC84\uAE45 \uC635\uC158" }) }),
423
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: filterList.map((filter) => /* @__PURE__ */ jsxRuntime.jsxs("li", { style: menuItemStyle, children: [
424
+ /* @__PURE__ */ jsxRuntime.jsx(
425
+ "input",
426
+ {
427
+ type: "checkbox",
428
+ checked: filterName.includes(filter.key),
429
+ onChange: (e) => {
430
+ if (e.target.checked) {
431
+ setFilterName((prev) => {
432
+ const newFilterName = prev ? `${prev},${filter.key}` : filter.key;
433
+ setCookie(filterNameCookieKey, newFilterName);
434
+ return newFilterName;
435
+ });
436
+ } else {
437
+ setFilterName((prev) => {
438
+ if (prev.includes(",")) {
439
+ const newFilterName = prev.split(",").filter((item) => item !== filter.key).join(",");
440
+ setCookie(filterNameCookieKey, newFilterName);
441
+ return newFilterName;
442
+ } else {
443
+ deleteCookie(filterNameCookieKey);
444
+ return "";
445
+ }
446
+ });
447
+ }
448
+ }
449
+ }
450
+ ),
451
+ filter.key,
452
+ " \u2014 ",
453
+ filter.description
454
+ ] }, filter.key)) })
455
+ ] });
456
+ }
457
+ function FormFactor() {
458
+ const handleFormFactor = (formFactor) => {
459
+ setCookie("x-channel-formfactor", formFactor);
460
+ alert(`\uD3FC\uD329\uD130\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4. :${formFactor}`);
461
+ console.log("\uD3FC\uD329\uD130\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", {
462
+ "x-channel-formfactor": getCookie("x-channel-formfactor")
463
+ });
464
+ };
465
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
466
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: panelHeaderStyle, children: /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: "\uD3FC\uD329\uD130" }) }),
467
+ /* @__PURE__ */ jsxRuntime.jsxs("ul", { children: [
468
+ /* @__PURE__ */ jsxRuntime.jsx("li", { style: menuItemStyle, onClick: () => handleFormFactor("tablet"), children: "Tablet" }),
469
+ /* @__PURE__ */ jsxRuntime.jsx("li", { style: menuItemStyle, onClick: () => handleFormFactor("phone"), children: "Phone" }),
470
+ /* @__PURE__ */ jsxRuntime.jsx("li", { style: menuItemStyle, onClick: () => handleFormFactor("pc"), children: "PC" })
471
+ ] })
472
+ ] });
473
+ }
474
+ function InitRefresh() {
475
+ const handleDeleteHostCookie = () => {
476
+ deleteCookie("hia-debug-mode-env");
477
+ alert("\uD638\uC2A4\uD2B8\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
478
+ console.log("\uD638\uC2A4\uD2B8\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", {
479
+ "hia-debug-mode-env": getCookie("hia-debug-mode-env")
480
+ });
481
+ };
482
+ const handleDeleteTokenCookie = () => {
483
+ deleteCookie("accessToken");
484
+ alert("\uD1A0\uD070\uCFE0\uD0A4\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
485
+ console.log("\uD1A0\uD070\uCFE0\uD0A4\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", {
486
+ accessToken: getCookie("accessToken")
487
+ });
488
+ };
489
+ const handleDeleteCustomCookie = () => {
490
+ deleteCookie("x-channel-appversion");
491
+ deleteCookie("x-channel-deviceid");
492
+ deleteCookie("x-channel-devicemodel");
493
+ deleteCookie("x-channel-formfactor");
494
+ deleteCookie("x-channel-loginchannel");
495
+ deleteCookie("x-channel-logintype");
496
+ deleteCookie("x-channel-platformname");
497
+ deleteCookie("x-channel-platformversion");
498
+ deleteCookie("x-channel-screenid");
499
+ alert("\uCEE4\uC2A4\uD140\uCFE0\uD0A4\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
500
+ console.log("\uCEE4\uC2A4\uD140\uCFE0\uD0A4\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
501
+ };
502
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
503
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: panelHeaderStyle, children: /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: "\uCD08\uAE30\uD654" }) }),
504
+ /* @__PURE__ */ jsxRuntime.jsxs("ul", { children: [
505
+ /* @__PURE__ */ jsxRuntime.jsx("li", { style: menuItemStyle, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => window.location.reload(), children: "\uC0C8\uB85C\uACE0\uCE68" }) }),
506
+ /* @__PURE__ */ jsxRuntime.jsx("li", { style: menuItemStyle, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleDeleteHostCookie, children: "Host \uC0AD\uC81C" }) }),
507
+ /* @__PURE__ */ jsxRuntime.jsx("li", { style: menuItemStyle, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleDeleteCustomCookie, children: "\uCEE4\uC2A4\uD140(x-channel-) \uC0AD\uC81C" }) }),
508
+ /* @__PURE__ */ jsxRuntime.jsx("li", { style: menuItemStyle, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleDeleteTokenCookie, children: "\uD1A0\uD070 \uC0AD\uC81C" }) })
509
+ ] })
510
+ ] });
511
+ }
512
+ var MenuPanel = ({ menuItems: menuItems2, onMenuItemClick, onClose, serviceCode }) => {
513
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
514
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: modalOverlayStyle, onClick: onClose }),
515
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: debugMenuPanelStyle, children: [
516
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: panelHeaderStyle, children: [
517
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: "Debug Menu" }),
518
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onClose, children: "X" })
519
+ ] }),
520
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: menuItems2.map((item) => /* @__PURE__ */ jsxRuntime.jsx("li", { onClick: () => onMenuItemClick(item.component), style: menuItemStyle, children: item.label }, item.id)) }),
521
+ serviceCode === "hia" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
522
+ /* @__PURE__ */ jsxRuntime.jsx(Filter, {}),
523
+ /* @__PURE__ */ jsxRuntime.jsx(FormFactor, {}),
524
+ /* @__PURE__ */ jsxRuntime.jsx(ChangeHost, {}),
525
+ /* @__PURE__ */ jsxRuntime.jsx(InitRefresh, {})
526
+ ] })
527
+ ] })
528
+ ] });
529
+ };
530
+ var menu_panel_default = MenuPanel;
531
+
532
+ // src/debug-utils.ts
533
+ function isDebugByFilterName(name) {
534
+ const filterNames = getCookie(filterNameCookieKey)?.split(",");
535
+ return filterNames?.includes(name) ?? false;
536
+ }
537
+
538
+ // src/features/console-log/use-console-log.ts
539
+ var globalLogs = [];
540
+ var listeners = [];
541
+ var originalConsoleMethods = {};
542
+ var isConsoleOverridden = false;
543
+ var MAX_LOGS = 10;
544
+ var addLog = (type, ...args) => {
545
+ const newLog = {
546
+ id: Date.now() + Math.random(),
547
+ type,
548
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString(),
549
+ message: args
550
+ };
551
+ if (globalLogs.length >= MAX_LOGS) {
552
+ if (!isDebugByFilterName("console-log")) {
553
+ globalLogs.shift();
554
+ }
555
+ }
556
+ globalLogs = [...globalLogs, newLog];
557
+ listeners.forEach((listener) => listener([...globalLogs]));
558
+ };
559
+ var initializeConsoleLogOverride = () => {
560
+ if (!hiaFrontendUtils.isClient() || isConsoleOverridden) {
561
+ return;
562
+ }
563
+ const logTypes = ["log", "info", "warn", "error", "debug"];
564
+ logTypes.forEach((type) => {
565
+ originalConsoleMethods[type] = console[type];
566
+ console[type] = (...args) => {
567
+ originalConsoleMethods[type]?.apply(console, args);
568
+ addLog(type, ...args);
569
+ };
570
+ });
571
+ isConsoleOverridden = true;
572
+ };
573
+ var restoreConsoleLog = () => {
574
+ if (!hiaFrontendUtils.isClient() || !isConsoleOverridden) {
575
+ return;
576
+ }
577
+ const logTypes = ["log", "info", "warn", "error", "debug"];
578
+ logTypes.forEach((type) => {
579
+ if (originalConsoleMethods[type]) {
580
+ console[type] = originalConsoleMethods[type];
581
+ }
582
+ });
583
+ isConsoleOverridden = false;
584
+ };
585
+ var useConsoleLog = () => {
586
+ const [logs, setLogs] = React2.useState(globalLogs);
587
+ React2.useEffect(() => {
588
+ listeners.push(setLogs);
589
+ return () => {
590
+ listeners = listeners.filter((l) => l !== setLogs);
591
+ };
592
+ }, []);
593
+ const clearLogs = React2.useCallback(() => {
594
+ globalLogs = [];
595
+ listeners.forEach((listener) => listener([]));
596
+ }, []);
597
+ return { logs, clearLogs };
598
+ };
599
+ var safeStringify = (obj) => {
600
+ try {
601
+ return JSON.stringify(obj, null, 2);
602
+ } catch (e) {
603
+ return "[Unserializable Object]";
604
+ }
605
+ };
606
+ var LogMessage = ({ entry }) => {
607
+ const messageParts = entry.message.map((part) => {
608
+ if (typeof part === "object" && part !== null) {
609
+ return safeStringify(part);
610
+ }
611
+ return String(part);
612
+ });
613
+ const style = { ...logMessageStyle, ...logTypeStyles[entry.type] };
614
+ return /* @__PURE__ */ jsxRuntime.jsx("pre", { style, children: messageParts.join(" ") });
615
+ };
616
+ var ConsoleLogPanel = ({ onClose }) => {
617
+ const { logs, clearLogs } = useConsoleLog();
618
+ const [filter, setFilter] = React2.useState("all");
619
+ const logContainerRef = React2.useRef(null);
620
+ const filteredLogs = React2.useMemo(() => {
621
+ if (filter === "all") {
622
+ return logs;
623
+ }
624
+ return logs.filter((log) => log.type === filter);
625
+ }, [logs, filter]);
626
+ React2.useEffect(() => {
627
+ if (logContainerRef.current) {
628
+ logContainerRef.current.scrollTop = logContainerRef.current.scrollHeight;
629
+ }
630
+ }, [filteredLogs]);
631
+ const segmentOptions = ["all", "log", "warn", "error"];
632
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
633
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: modalOverlayStyle, onClick: onClose }),
634
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: debugFeaturePanelStyle, children: [
635
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: panelHeaderStyle, children: [
636
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: "Console Logs" }),
637
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onClose, children: "X" })
638
+ ] }),
639
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: panelToolbarStyle, children: [
640
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: segmentOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => setFilter(option), disabled: filter === option, children: option.charAt(0).toUpperCase() + option.slice(1) }, option)) }),
641
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: clearLogs, style: clearButtonStyle, children: "Clear" })
642
+ ] }),
643
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: logListContainerStyle, ref: logContainerRef, children: filteredLogs.map((log) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: logItemStyle, children: [
644
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: logTimestampStyle, children: log.timestamp }),
645
+ /* @__PURE__ */ jsxRuntime.jsx(LogMessage, { entry: log })
646
+ ] }, log.id)) })
647
+ ] })
648
+ ] });
649
+ };
650
+ var console_log_panel_default = ConsoleLogPanel;
651
+ var LoginPanel = ({ onClose, onLogin }) => {
652
+ const [selectedTypeId, setSelectedTypeId] = React2.useState(loginTypes[0]?.id || "");
653
+ const [formData, setFormData] = React2.useState({});
654
+ const selectedType = React2.useMemo(() => loginTypes.find((t) => t.id === selectedTypeId), [selectedTypeId]);
655
+ const handleInputChange = (e) => {
656
+ const { name, value } = e.target;
657
+ setFormData((prev) => ({ ...prev, [name]: value }));
658
+ };
659
+ const handleSubmit = (e) => {
660
+ e.preventDefault();
661
+ if (selectedType) {
662
+ deleteCookie("accessToken");
663
+ onLogin(selectedType.id, formData);
664
+ onClose();
665
+ }
666
+ };
667
+ React2.useEffect(() => {
668
+ setFormData({});
669
+ }, [selectedType]);
670
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
671
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: modalOverlayStyle, onClick: onClose }),
672
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: debugFeaturePanelStyle, children: [
673
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: panelHeaderStyle, children: [
674
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: "\uAC04\uD3B8 \uB85C\uADF8\uC778" }),
675
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onClose, children: "X" })
676
+ ] }),
677
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { style: loginFormContainerStyle, onSubmit: handleSubmit, children: [
678
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
679
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "login-type-select", children: "\uB85C\uADF8\uC778 \uC720\uD615" }),
680
+ /* @__PURE__ */ jsxRuntime.jsx("select", { id: "login-type-select", value: selectedTypeId, onChange: (e) => setSelectedTypeId(e.target.value), children: loginTypes.map((type) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: type.id, children: type.label }, type.id)) })
681
+ ] }),
682
+ selectedType?.fields.map((field) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
683
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: field.name, children: field.label }),
684
+ /* @__PURE__ */ jsxRuntime.jsx(
685
+ "input",
686
+ {
687
+ type: field.type,
688
+ id: field.name,
689
+ name: field.name,
690
+ placeholder: field.placeholder,
691
+ value: formData[field.name] || "",
692
+ onChange: handleInputChange,
693
+ required: true
694
+ }
695
+ )
696
+ ] }, field.name)),
697
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: formActionsStyle, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", children: "\uB85C\uADF8\uC778" }) })
698
+ ] })
699
+ ] })
700
+ ] });
701
+ };
702
+ var login_panel_default = LoginPanel;
703
+ var useDebugStore = zustand.create((set, get) => ({
704
+ requests: [],
705
+ responses: [],
706
+ errors: [],
707
+ heldRequests: [],
708
+ heldResponses: [],
709
+ heldErrors: [],
710
+ isHold: false,
711
+ addRequest: (request) => set((state) => ({ requests: [...state.requests, request] })),
712
+ addResponse: (response) => set((state) => ({ responses: [...state.responses, response] })),
713
+ addError: (error) => set((state) => ({ errors: [...state.errors, error] })),
714
+ holdRequest: (item) => set((state) => ({ heldRequests: [...state.heldRequests, item] })),
715
+ holdResponse: (item) => set((state) => ({ heldResponses: [...state.heldResponses, item] })),
716
+ holdError: (item) => set((state) => ({ heldErrors: [...state.heldErrors, item] })),
717
+ playAllRequests: () => {
718
+ const { heldRequests } = get();
719
+ heldRequests.forEach((item) => item.resolver(void 0));
720
+ set({ heldRequests: [] });
721
+ },
722
+ playAllResponses: () => {
723
+ const { heldResponses } = get();
724
+ heldResponses.forEach((item) => item.resolver(void 0));
725
+ set({ heldResponses: [] });
726
+ },
727
+ toggleHold: () => set((state) => ({ isHold: !state.isHold })),
728
+ clear: () => set({
729
+ requests: [],
730
+ responses: [],
731
+ errors: [],
732
+ heldRequests: [],
733
+ heldResponses: [],
734
+ heldErrors: []
735
+ })
736
+ }));
737
+ var SEARCH_SECTIONS = [
738
+ { value: "all", label: "\uC804\uCCB4" },
739
+ { value: "url", label: "\uC8FC\uC18C" },
740
+ { value: "headers", label: "\uD5E4\uB354" },
741
+ { value: "params", label: "\uD30C\uB77C\uBBF8\uD130" },
742
+ { value: "data", label: "\uC694\uCCAD" },
743
+ { value: "response", label: "\uC751\uB2F5" },
744
+ { value: "error", label: "\uC5D0\uB7EC" }
745
+ ];
746
+ var getLogInfo = (log) => {
747
+ if (log.holdStatus === "held") {
748
+ if ("request" in log) {
749
+ return log.request;
750
+ }
751
+ if ("response" in log) {
752
+ return log.response;
753
+ }
754
+ if ("error" in log) {
755
+ return log.error;
756
+ }
757
+ }
758
+ return log;
759
+ };
760
+ var NetworkLog = ({ onClose }) => {
761
+ const {
762
+ requests,
763
+ responses,
764
+ errors,
765
+ clear,
766
+ isHold,
767
+ toggleHold,
768
+ heldRequests,
769
+ heldResponses,
770
+ heldErrors,
771
+ playAllRequests,
772
+ playAllResponses
773
+ } = useDebugStore();
774
+ const [searchTerm, setSearchTerm] = React2.useState("");
775
+ const [searchSection, setSearchSection] = React2.useState(SEARCH_SECTIONS[0]?.value);
776
+ const allLogs = React2.useMemo(() => {
777
+ const logs = [];
778
+ requests.forEach((req) => logs.push({ ...req, type: "request" }));
779
+ responses.forEach((res) => logs.push({ ...res, type: "response" }));
780
+ errors.forEach((err) => logs.push({ ...err, type: "error" }));
781
+ heldRequests.forEach((req) => logs.push({ ...req, type: "request", holdStatus: "held" }));
782
+ heldResponses.forEach((res) => logs.push({ ...res, type: "response", holdStatus: "held" }));
783
+ heldErrors.forEach((err) => logs.push({ ...err, type: "error", holdStatus: "held" }));
784
+ logs.sort((a, b) => {
785
+ const aInfo = getLogInfo(a);
786
+ const bInfo = getLogInfo(b);
787
+ const aTime = "startTime" in aInfo ? aInfo.startTime : 0;
788
+ const bTime = "startTime" in bInfo ? bInfo.startTime : 0;
789
+ return bTime - aTime;
790
+ });
791
+ return logs;
792
+ }, [requests, responses, errors, heldRequests, heldResponses, heldErrors]);
793
+ const filteredLogs = React2.useMemo(() => {
794
+ if (!searchTerm) {
795
+ return allLogs;
796
+ }
797
+ const lowercasedTerm = searchTerm.toLowerCase();
798
+ return allLogs.filter((log) => {
799
+ const logInfo = getLogInfo(log);
800
+ switch (searchSection) {
801
+ case "url":
802
+ return logInfo.url?.toLowerCase().includes(lowercasedTerm);
803
+ case "headers":
804
+ return "headers" in logInfo && logInfo.headers && JSON.stringify(logInfo.headers)?.toLowerCase().includes(lowercasedTerm);
805
+ case "params":
806
+ return "params" in logInfo && logInfo.params && JSON.stringify(logInfo.params)?.toLowerCase().includes(lowercasedTerm);
807
+ case "data":
808
+ return "data" in logInfo && logInfo.data && log.type === "request" && JSON.stringify(logInfo.data)?.toLowerCase().includes(lowercasedTerm);
809
+ case "response":
810
+ return "data" in logInfo && logInfo.data && log.type === "response" && JSON.stringify(logInfo.data)?.toLowerCase().includes(lowercasedTerm);
811
+ case "error":
812
+ return log.type === "error" && JSON.stringify(logInfo)?.toLowerCase().includes(lowercasedTerm);
813
+ case "all":
814
+ default:
815
+ return JSON.stringify(logInfo).toLowerCase().includes(lowercasedTerm);
816
+ }
817
+ });
818
+ }, [allLogs, searchTerm, searchSection]);
819
+ const renderLogSummary = (log) => {
820
+ const logInfo = getLogInfo(log);
821
+ const prefix = log.holdStatus === "held" ? "[HELD] " : "";
822
+ if (log.type === "request") {
823
+ return `${prefix}[REQ] ${logInfo.method.toUpperCase()} ${logInfo.url}`;
824
+ }
825
+ if (log.type === "response" && "status" in logInfo) {
826
+ return `${prefix}[RES] ${logInfo.method.toUpperCase()} ${logInfo.url} - ${logInfo.status}`;
827
+ }
828
+ if (log.type === "error" && "message" in logInfo) {
829
+ return `${prefix}[ERR] ${logInfo.method.toUpperCase()} ${logInfo.url} - ${logInfo.message}`;
830
+ }
831
+ return "Unknown Log";
832
+ };
833
+ const renderLogContent = (log) => {
834
+ const logInfo = getLogInfo(log);
835
+ return /* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(logInfo, null, 2) });
836
+ };
837
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
838
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: modalOverlayStyle, onClick: onClose }),
839
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: debugFeaturePanelStyle, children: [
840
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: panelHeaderStyle, children: [
841
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: "\uB124\uD2B8\uC6CC\uD06C \uB85C\uADF8" }),
842
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onClose, children: "X" })
843
+ ] }),
844
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: networkLogContainerStyle, children: [
845
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: searchContainerStyle, children: [
846
+ /* @__PURE__ */ jsxRuntime.jsx("select", { value: searchSection, onChange: (e) => setSearchSection(e.target.value), children: SEARCH_SECTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value)) }),
847
+ /* @__PURE__ */ jsxRuntime.jsx(
848
+ "input",
849
+ {
850
+ type: "text",
851
+ placeholder: "\uAC80\uC0C9...",
852
+ value: searchTerm,
853
+ onChange: (e) => setSearchTerm(e.target.value),
854
+ style: flex1Style
855
+ }
856
+ ),
857
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
858
+ /* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: isHold, onChange: toggleHold }),
859
+ "Hold"
860
+ ] }),
861
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: clear, children: "clear" })
862
+ ] }),
863
+ isHold && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: holdButtonsContainerStyle, children: [
864
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => playAllRequests(), children: "REQ Resolve" }),
865
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => playAllResponses(), children: "RES Resolve" })
866
+ ] }),
867
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: logListStyle, children: filteredLogs.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { children: "\uD45C\uC2DC\uD560 \uB85C\uADF8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { children: filteredLogs.map((log, index) => /* @__PURE__ */ jsxRuntime.jsxs("details", { children: [
868
+ /* @__PURE__ */ jsxRuntime.jsx("summary", { style: logSummaryStyle, children: renderLogSummary(log) }),
869
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: logContentStyle, children: renderLogContent(log) })
870
+ ] }, index)) }) })
871
+ ] })
872
+ ] })
873
+ ] });
874
+ };
875
+ var network_log_default = NetworkLog;
876
+ var LocationInfo = () => {
877
+ return Object.keys(location).map((key) => {
878
+ const val = location[key];
879
+ if (typeof val === "string") {
880
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
881
+ key,
882
+ ": ",
883
+ val,
884
+ " ",
885
+ val && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => navigator.clipboard.writeText(val), children: "\uBCF5\uC0AC" })
886
+ ] }, key);
887
+ }
888
+ });
889
+ };
890
+ var PageNavigationPanel = ({ onClose }) => {
891
+ const [url, setUrl] = React2.useState("");
892
+ const handleNavigate = () => {
893
+ if (url) {
894
+ self.location.href = url;
895
+ }
896
+ };
897
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
898
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: modalOverlayStyle, onClick: onClose }),
899
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: debugFeaturePanelStyle, children: [
900
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: panelHeaderStyle, children: [
901
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: "\uD398\uC774\uC9C0 \uC815\uBCF4" }),
902
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onClose, children: "X" })
903
+ ] }),
904
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: pageNavigationContentStyle, children: [
905
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
906
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
907
+ "\uD398\uC774\uC9C0\uC815\uBCF4 :",
908
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { whiteSpace: "normal", wordBreak: "break-all" }, children: LocationInfo() }),
909
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
910
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
911
+ "\uD398\uC774\uC9C0\uC774\uB3D9 :",
912
+ /* @__PURE__ */ jsxRuntime.jsx(
913
+ "input",
914
+ {
915
+ type: "text",
916
+ value: url,
917
+ onChange: (e) => setUrl(e.target.value),
918
+ placeholder: "\uC774\uB3D9\uD560 URL\uC744 \uC785\uB825\uD558\uC138\uC694 (\uC608: /main)",
919
+ style: flex1Style
920
+ }
921
+ ),
922
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleNavigate, children: "\uC774\uB3D9" })
923
+ ] })
924
+ ] })
925
+ ] });
926
+ };
927
+ var page_navigation_panel_default = PageNavigationPanel;
928
+ var logTypeStyles2 = {
929
+ log: { color: "#333333" },
930
+ warn: { color: "#ffc107" },
931
+ error: { color: "#dc3545" },
932
+ return: { color: "#8a2be2" }
933
+ };
934
+ var safeStringify2 = (obj) => {
935
+ try {
936
+ const replacer = (_key, value) => typeof value === "bigint" ? value.toString() : value;
937
+ return JSON.stringify(obj, replacer, 2);
938
+ } catch (e) {
939
+ return "[Unserializable Object]";
940
+ }
941
+ };
942
+ var ResultMessage = ({ log }) => {
943
+ const messageParts = log.message.map((part) => {
944
+ if (typeof part === "object" && part !== null) {
945
+ return safeStringify2(part);
946
+ }
947
+ return String(part);
948
+ });
949
+ const prefix = log.type === "return" ? "\u21A9 " : "";
950
+ const style = { ...logMessageStyle, ...logTypeStyles2[log.type] };
951
+ return /* @__PURE__ */ jsxRuntime.jsxs("pre", { style, children: [
952
+ prefix,
953
+ messageParts.join(" ")
954
+ ] });
955
+ };
956
+ var ScriptExecutorPanel = ({ onClose }) => {
957
+ const [code, setCode] = React2.useState('// \uC5EC\uAE30\uC5D0 \uC2E4\uD589\uD560 \uCF54\uB4DC\uB97C \uC785\uB825\uD558\uC138\uC694\nconsole.log("Hello, World!");');
958
+ const [results, setResults] = React2.useState([]);
959
+ const addResult = (type, ...args) => {
960
+ setResults((prevResults) => [
961
+ ...prevResults,
962
+ {
963
+ id: Date.now() + Math.random(),
964
+ type,
965
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString(),
966
+ message: args
967
+ }
968
+ ]);
969
+ };
970
+ const handleExecute = () => {
971
+ const originalConsole = { ...console };
972
+ const newConsole = {
973
+ log: (...args) => {
974
+ originalConsole.log(...args);
975
+ addResult("log", ...args);
976
+ },
977
+ warn: (...args) => {
978
+ originalConsole.warn(...args);
979
+ addResult("warn", ...args);
980
+ },
981
+ error: (...args) => {
982
+ originalConsole.error(...args);
983
+ addResult("error", ...args);
984
+ }
985
+ };
986
+ try {
987
+ Object.assign(console, newConsole);
988
+ const result = new Function(code)();
989
+ if (result !== void 0) {
990
+ addResult("return", result);
991
+ }
992
+ } catch (e) {
993
+ addResult("error", e.name, e.message);
994
+ } finally {
995
+ Object.assign(console, originalConsole);
996
+ }
997
+ };
998
+ const handleClear = () => {
999
+ setResults([]);
1000
+ };
1001
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1002
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: modalOverlayStyle, onClick: onClose }),
1003
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...debugFeaturePanelStyle, ...scriptExecutorContentStyle }, children: [
1004
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: panelHeaderStyle, children: [
1005
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: "\uC2A4\uD06C\uB9BD\uD2B8 \uC2E4\uD589" }),
1006
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onClose, children: "X" })
1007
+ ] }),
1008
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: scriptExecutorContentStyle, children: [
1009
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: scriptInputSectionStyle, children: [
1010
+ /* @__PURE__ */ jsxRuntime.jsx(
1011
+ "textarea",
1012
+ {
1013
+ style: scriptTextareaStyle,
1014
+ value: code,
1015
+ onChange: (e) => setCode(e.target.value),
1016
+ spellCheck: false
1017
+ }
1018
+ ),
1019
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: scriptActionsStyle, children: [
1020
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleExecute, children: "\uC2E4\uD589 (\u25B6)" }),
1021
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleClear, children: "\uACB0\uACFC \uC9C0\uC6B0\uAE30" })
1022
+ ] })
1023
+ ] }),
1024
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: scriptOutputSectionStyle, children: [
1025
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: panelHeaderStyle, children: /* @__PURE__ */ jsxRuntime.jsx("h3", { style: h3Style, children: "\uACB0\uACFC" }) }),
1026
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: logListContainerStyle, children: results.map((log) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: logItemStyle, children: [
1027
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: logTimestampStyle, children: log.timestamp }),
1028
+ /* @__PURE__ */ jsxRuntime.jsx(ResultMessage, { log })
1029
+ ] }, log.id)) })
1030
+ ] })
1031
+ ] })
1032
+ ] })
1033
+ ] });
1034
+ };
1035
+ var script_executor_panel_default = ScriptExecutorPanel;
1036
+ var useStorage = (storageType) => {
1037
+ const [items, setItems] = React2.useState([]);
1038
+ const loadItems = React2.useCallback(() => {
1039
+ const newItems = [];
1040
+ if (storageType === "localStorage") {
1041
+ for (let i = 0; i < localStorage.length; i++) {
1042
+ const key = localStorage.key(i);
1043
+ if (key) {
1044
+ newItems.push({ key, value: localStorage.getItem(key) || "" });
1045
+ }
1046
+ }
1047
+ } else {
1048
+ const cookies = document.cookie.split(";");
1049
+ cookies.forEach((cookie) => {
1050
+ const parts = cookie.split("=");
1051
+ const key = parts.shift()?.trim();
1052
+ if (key) {
1053
+ newItems.push({ key, value: decodeURIComponent(parts.join("=")) });
1054
+ }
1055
+ });
1056
+ }
1057
+ setItems(newItems);
1058
+ }, [storageType]);
1059
+ React2.useEffect(() => {
1060
+ loadItems();
1061
+ }, [loadItems]);
1062
+ const setItem = React2.useCallback(
1063
+ (key, value) => {
1064
+ if (storageType === "localStorage") {
1065
+ localStorage.setItem(key, value);
1066
+ } else {
1067
+ setCookie(key, value);
1068
+ }
1069
+ loadItems();
1070
+ },
1071
+ [storageType, loadItems]
1072
+ );
1073
+ const removeItem = React2.useCallback(
1074
+ (key) => {
1075
+ if (storageType === "localStorage") {
1076
+ localStorage.removeItem(key);
1077
+ } else {
1078
+ deleteCookie(key);
1079
+ }
1080
+ loadItems();
1081
+ },
1082
+ [storageType, loadItems]
1083
+ );
1084
+ return { items, setItem, removeItem, loadItems };
1085
+ };
1086
+ var ValueDisplay = ({ value }) => {
1087
+ try {
1088
+ const parsed = JSON.parse(value);
1089
+ if (typeof parsed === "object" && parsed !== null) {
1090
+ return /* @__PURE__ */ jsxRuntime.jsx("pre", { style: logContentStyle, children: JSON.stringify(parsed, null, 2) });
1091
+ }
1092
+ } catch (e) {
1093
+ }
1094
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: logContentStyle, children: value });
1095
+ };
1096
+ var EditableRow = ({
1097
+ item,
1098
+ onSave,
1099
+ onRemove
1100
+ }) => {
1101
+ const [isEditing, setIsEditing] = React2.useState(false);
1102
+ const [value, setValue] = React2.useState(item.value);
1103
+ const handleSave = () => {
1104
+ onSave(item.key, value);
1105
+ setIsEditing(false);
1106
+ };
1107
+ const handleEdit = () => {
1108
+ setValue(item.value);
1109
+ setIsEditing(true);
1110
+ };
1111
+ return /* @__PURE__ */ jsxRuntime.jsxs("details", { children: [
1112
+ /* @__PURE__ */ jsxRuntime.jsx("summary", { children: item.key }),
1113
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1114
+ isEditing ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleSave, children: "Save" }) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleEdit, children: "Edit" }),
1115
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => onRemove(item.key), children: "Remove" }),
1116
+ isEditing ? /* @__PURE__ */ jsxRuntime.jsx("textarea", { value, onChange: (e) => setValue(e.target.value), style: textareaStyle }) : /* @__PURE__ */ jsxRuntime.jsx(ValueDisplay, { value: item.value })
1117
+ ] })
1118
+ ] });
1119
+ };
1120
+ var StoragePanel = ({ onClose, storageType }) => {
1121
+ const { items, setItem, removeItem } = useStorage(storageType);
1122
+ const [filter, setFilter] = React2.useState("");
1123
+ const filteredItems = React2.useMemo(() => {
1124
+ if (!filter) {
1125
+ return items;
1126
+ }
1127
+ return items.filter(
1128
+ (item) => item.key.toLowerCase().includes(filter.toLowerCase()) || item.value.toLowerCase().includes(filter.toLowerCase())
1129
+ );
1130
+ }, [items, filter]);
1131
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1132
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: modalOverlayStyle, onClick: onClose }),
1133
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: debugFeaturePanelStyle, children: [
1134
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: panelHeaderStyle, children: [
1135
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: h2Style, children: storageType === "localStorage" ? "Local Storage" : "Cookies" }),
1136
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onClose, children: "X" })
1137
+ ] }),
1138
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: panelToolbarStyle, children: /* @__PURE__ */ jsxRuntime.jsx(
1139
+ "input",
1140
+ {
1141
+ type: "text",
1142
+ placeholder: "Search key or value...",
1143
+ value: filter,
1144
+ onChange: (e) => setFilter(e.target.value),
1145
+ style: storageSearchInputStyle
1146
+ }
1147
+ ) }),
1148
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: storageTableContainerStyle, children: filteredItems.map((item) => /* @__PURE__ */ jsxRuntime.jsx(EditableRow, { item, onSave: setItem, onRemove: removeItem }, item.key)) })
1149
+ ] })
1150
+ ] });
1151
+ };
1152
+ var storage_panel_default = StoragePanel;
1153
+ var loginTypes = [
1154
+ {
1155
+ id: "fp",
1156
+ label: "FP \uB85C\uADF8\uC778",
1157
+ fields: [{ name: "employeeId", label: "\uC0AC\uBC88", type: "text", placeholder: "\uC0AC\uBC88\uC744 \uC785\uB825\uD558\uC138\uC694" }]
1158
+ }
1159
+ ];
1160
+ var menuItems = [
1161
+ {
1162
+ id: "network-log",
1163
+ label: "\uB124\uD2B8\uC6CC\uD06C \uB85C\uADF8",
1164
+ component: network_log_default,
1165
+ display: true
1166
+ },
1167
+ {
1168
+ id: "console-log",
1169
+ label: "\uCF58\uC194 \uB85C\uADF8 \uD655\uC778",
1170
+ component: console_log_panel_default,
1171
+ display: true
1172
+ },
1173
+ {
1174
+ id: "local-storage",
1175
+ label: "\uB85C\uCEEC \uC2A4\uD1A0\uB9AC\uC9C0 \uAD00\uB9AC",
1176
+ component: (props) => /* @__PURE__ */ jsxRuntime.jsx(storage_panel_default, { ...props, storageType: "localStorage" }),
1177
+ display: true
1178
+ },
1179
+ {
1180
+ id: "cookie-management",
1181
+ label: "\uCFE0\uD0A4 \uAD00\uB9AC",
1182
+ component: (props) => /* @__PURE__ */ jsxRuntime.jsx(storage_panel_default, { ...props, storageType: "cookie" }),
1183
+ display: true
1184
+ },
1185
+ {
1186
+ id: "quick-login",
1187
+ label: "\uAC04\uD3B8 \uB85C\uADF8\uC778",
1188
+ component: login_panel_default,
1189
+ display: true
1190
+ },
1191
+ {
1192
+ id: "script-executor",
1193
+ label: "\uC2A4\uD06C\uB9BD\uD2B8 \uC2E4\uD589",
1194
+ component: script_executor_panel_default,
1195
+ display: true
1196
+ },
1197
+ {
1198
+ id: "page-navigation",
1199
+ label: "\uD398\uC774\uC9C0 \uC815\uBCF4",
1200
+ component: page_navigation_panel_default,
1201
+ display: true
1202
+ }
1203
+ ];
1204
+ var useEnvironment = () => {
1205
+ const [envInfo, setEnvInfo] = React2.useState({
1206
+ env: "prd"
1207
+ });
1208
+ React2.useEffect(() => {
1209
+ const { hostname } = window.location;
1210
+ setEnvInfo({ env: hiaFrontendUtils.getEnvironmentFromHostname(hostname) });
1211
+ }, []);
1212
+ return envInfo;
1213
+ };
1214
+ var DebugTool = ({
1215
+ onLogin,
1216
+ envOverride,
1217
+ menuItemsOverride,
1218
+ serviceCode = "etc"
1219
+ }) => {
1220
+ React2.useEffect(() => {
1221
+ initializeConsoleLogOverride();
1222
+ return () => {
1223
+ restoreConsoleLog();
1224
+ };
1225
+ }, []);
1226
+ const environment = useEnvironment();
1227
+ const env = envOverride || environment.env;
1228
+ const menuItems2 = menuItemsOverride || menuItems;
1229
+ const [isMenuOpen, setMenuOpen] = React2.useState(false);
1230
+ const [activeFeature, setActiveFeature] = React2.useState(null);
1231
+ const isVisible = ["local", "dev", "stg"].includes(env);
1232
+ const handleMenuClick = (itemComponent) => {
1233
+ setActiveFeature(() => itemComponent);
1234
+ setMenuOpen(false);
1235
+ };
1236
+ const handleCloseFeature = () => {
1237
+ setActiveFeature(null);
1238
+ };
1239
+ if (!isVisible) {
1240
+ return null;
1241
+ }
1242
+ const toggleMenu = () => {
1243
+ setMenuOpen((prev) => !prev);
1244
+ if (!isMenuOpen) {
1245
+ setActiveFeature(null);
1246
+ }
1247
+ };
1248
+ const availableMenuItems = menuItems2.filter(
1249
+ (item) => item.display && (item.id !== "quick-login" || item.id === "quick-login" && onLogin)
1250
+ );
1251
+ if (activeFeature) {
1252
+ const FeatureComponent = activeFeature;
1253
+ return /* @__PURE__ */ jsxRuntime.jsx(FeatureComponent, { onClose: handleCloseFeature, onLogin });
1254
+ }
1255
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1256
+ "div",
1257
+ {
1258
+ style: {
1259
+ position: "fixed",
1260
+ right: "20px",
1261
+ bottom: "20px",
1262
+ zIndex: 9999
1263
+ },
1264
+ children: [
1265
+ /* @__PURE__ */ jsxRuntime.jsx(floating_button_default, { onClick: toggleMenu }),
1266
+ isMenuOpen && /* @__PURE__ */ jsxRuntime.jsx(
1267
+ menu_panel_default,
1268
+ {
1269
+ menuItems: availableMenuItems,
1270
+ onMenuItemClick: handleMenuClick,
1271
+ onClose: () => setMenuOpen(false),
1272
+ serviceCode
1273
+ }
1274
+ )
1275
+ ]
1276
+ }
1277
+ );
1278
+ };
1279
+ var MAX_LOGS2 = 20;
1280
+ function addRequestLog(config) {
1281
+ if (!hiaFrontendUtils.isClient()) {
1282
+ return;
1283
+ }
1284
+ const env = hiaFrontendUtils.getEnvironmentFromHostname(location.hostname);
1285
+ if (env !== "prd") {
1286
+ const { addRequest, isHold, holdRequest, requests } = useDebugStore.getState();
1287
+ if (requests.length >= MAX_LOGS2) {
1288
+ if (!isDebugByFilterName("http-log")) {
1289
+ requests.shift();
1290
+ }
1291
+ }
1292
+ const startTime = Date.now();
1293
+ const requestInfo = {
1294
+ url: config.url || "",
1295
+ method: config.method || "",
1296
+ headers: config.headers,
1297
+ params: config.params,
1298
+ data: config.data,
1299
+ startTime
1300
+ };
1301
+ if (isHold) {
1302
+ return new Promise((resolver) => {
1303
+ holdRequest({ request: requestInfo, resolver });
1304
+ });
1305
+ } else {
1306
+ addRequest(requestInfo);
1307
+ }
1308
+ }
1309
+ }
1310
+ function addResponseLog(response) {
1311
+ if (!hiaFrontendUtils.isClient()) {
1312
+ return;
1313
+ }
1314
+ const env = hiaFrontendUtils.getEnvironmentFromHostname(location.hostname);
1315
+ if (env !== "prd") {
1316
+ const { addResponse, isHold, holdResponse, responses } = useDebugStore.getState();
1317
+ if (responses.length >= MAX_LOGS2) {
1318
+ if (!isDebugByFilterName("http-log")) {
1319
+ responses.shift();
1320
+ }
1321
+ }
1322
+ const { config } = response;
1323
+ const responseInfo = {
1324
+ url: config.url || "",
1325
+ method: config.method || "",
1326
+ status: response.status,
1327
+ statusText: response.statusText,
1328
+ headers: response.headers,
1329
+ data: response.data
1330
+ };
1331
+ if (isHold) {
1332
+ return new Promise((resolver) => {
1333
+ holdResponse({ response: responseInfo, resolver });
1334
+ });
1335
+ } else {
1336
+ addResponse(responseInfo);
1337
+ }
1338
+ }
1339
+ }
1340
+ function addErrorLog(error) {
1341
+ if (!hiaFrontendUtils.isClient()) {
1342
+ return;
1343
+ }
1344
+ const env = hiaFrontendUtils.getEnvironmentFromHostname(location.hostname);
1345
+ if (env !== "prd") {
1346
+ const { addError, isHold, holdError, errors } = useDebugStore.getState();
1347
+ if (errors.length >= MAX_LOGS2) {
1348
+ if (!isDebugByFilterName("http-log")) {
1349
+ errors.shift();
1350
+ }
1351
+ }
1352
+ const { config } = error;
1353
+ const errorInfo = {
1354
+ url: config?.url || "",
1355
+ method: config?.method || "",
1356
+ message: error.message,
1357
+ config: error.config,
1358
+ response: error.response ? {
1359
+ url: error.response.config?.url || "",
1360
+ method: error.response.config?.method || "",
1361
+ status: error.response.status,
1362
+ statusText: error.response.statusText,
1363
+ headers: error.response.headers,
1364
+ data: error.response.data
1365
+ } : void 0
1366
+ };
1367
+ if (isHold) {
1368
+ return new Promise((resolver) => {
1369
+ holdError({ error: errorInfo, resolver });
1370
+ });
1371
+ } else {
1372
+ addError(errorInfo);
1373
+ }
1374
+ }
1375
+ }
1376
+
1377
+ exports.DebugTool = DebugTool;
1378
+ exports.addErrorLog = addErrorLog;
1379
+ exports.addRequestLog = addRequestLog;
1380
+ exports.addResponseLog = addResponseLog;
1381
+ exports.isDebugByFilterName = isDebugByFilterName;