siluzan-tso-cli 1.1.64-beta.2 → 1.1.64-beta.4

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.js CHANGED
@@ -2172,8 +2172,8 @@ function jsonParseReviverStringifyIds(key, value) {
2172
2172
  }
2173
2173
  return value;
2174
2174
  }
2175
- function parseJsonWithStringIds(text3) {
2176
- return JSON.parse(text3, jsonParseReviverStringifyIds);
2175
+ function parseJsonWithStringIds(text4) {
2176
+ return JSON.parse(text4, jsonParseReviverStringifyIds);
2177
2177
  }
2178
2178
  function hasSiluzanAgentCredentials() {
2179
2179
  const apiKey = process.env.SILUZAN_API_KEY?.trim();
@@ -2333,7 +2333,28 @@ function rawRequest(url, options) {
2333
2333
  const perfOn = isPerfEnabled();
2334
2334
  const t0 = perfOn ? performance.now() : 0;
2335
2335
  const method = options.method ?? "GET";
2336
- return new Promise((resolve52, reject) => {
2336
+ return new Promise((resolvePromise, rejectPromise) => {
2337
+ const signal = options.signal;
2338
+ if (signal?.aborted) {
2339
+ rejectPromise(new RequestAbortedError(method, url));
2340
+ return;
2341
+ }
2342
+ let settled = false;
2343
+ let onAbort;
2344
+ const settle = () => {
2345
+ settled = true;
2346
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
2347
+ };
2348
+ const resolve52 = (value) => {
2349
+ if (settled) return;
2350
+ settle();
2351
+ resolvePromise(value);
2352
+ };
2353
+ const reject = (err) => {
2354
+ if (settled) return;
2355
+ settle();
2356
+ rejectPromise(err);
2357
+ };
2337
2358
  const parsed = new URL(url);
2338
2359
  const transport = parsed.protocol === "https:" ? https : http;
2339
2360
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
@@ -2380,6 +2401,7 @@ function rawRequest(url, options) {
2380
2401
  if (failed) return;
2381
2402
  failed = true;
2382
2403
  res.destroy();
2404
+ if (settled) return;
2383
2405
  if (perfOn) {
2384
2406
  emitPerf({
2385
2407
  method,
@@ -2414,7 +2436,7 @@ function rawRequest(url, options) {
2414
2436
  });
2415
2437
  stream.on("end", () => {
2416
2438
  if (failed) return;
2417
- const text3 = Buffer.concat(chunks).toString("utf8");
2439
+ const text4 = Buffer.concat(chunks).toString("utf8");
2418
2440
  const responseHeaders = {};
2419
2441
  for (const [key, val] of Object.entries(res.headers)) {
2420
2442
  if (val !== void 0) {
@@ -2432,7 +2454,7 @@ function rawRequest(url, options) {
2432
2454
  ok: status >= 200 && status < 300
2433
2455
  });
2434
2456
  }
2435
- resolve52({ status, text: text3, headers: responseHeaders });
2457
+ resolve52({ status, text: text4, headers: responseHeaders });
2436
2458
  });
2437
2459
  });
2438
2460
  req.on("timeout", () => {
@@ -2451,6 +2473,7 @@ function rawRequest(url, options) {
2451
2473
  reject(new Error(`\u8BF7\u6C42\u8D85\u65F6\uFF08${(timeoutMs / 1e3).toFixed(0)} \u79D2\uFF09\uFF1A${method} ${url}`));
2452
2474
  });
2453
2475
  req.on("error", (err) => {
2476
+ if (settled) return;
2454
2477
  if (perfOn) {
2455
2478
  emitPerf({
2456
2479
  method,
@@ -2464,6 +2487,25 @@ function rawRequest(url, options) {
2464
2487
  }
2465
2488
  reject(err);
2466
2489
  });
2490
+ if (signal) {
2491
+ onAbort = () => {
2492
+ if (settled) return;
2493
+ if (perfOn) {
2494
+ emitPerf({
2495
+ method,
2496
+ url,
2497
+ status: 0,
2498
+ elapsedMs: performance.now() - t0,
2499
+ bytes: 0,
2500
+ ok: false,
2501
+ error: "cancelled"
2502
+ });
2503
+ }
2504
+ reject(new RequestAbortedError(method, url));
2505
+ req.destroy();
2506
+ };
2507
+ signal.addEventListener("abort", onAbort, { once: true });
2508
+ }
2467
2509
  if (options.body !== void 0) {
2468
2510
  const payload = typeof options.body === "string" ? Buffer.from(options.body) : options.body;
2469
2511
  if (!headers["Content-Length"] && !headers["content-length"]) {
@@ -2483,8 +2525,8 @@ function redactSensitive(input) {
2483
2525
  );
2484
2526
  return output;
2485
2527
  }
2486
- function trimDetail(text3, maxLen) {
2487
- const t = text3.trim();
2528
+ function trimDetail(text4, maxLen) {
2529
+ const t = text4.trim();
2488
2530
  if (t.length <= maxLen) return t;
2489
2531
  return `${t.slice(0, maxLen)}\u2026`;
2490
2532
  }
@@ -2530,25 +2572,25 @@ function messageFromJsonValue(value) {
2530
2572
  return void 0;
2531
2573
  }
2532
2574
  function extractHttpErrorDetail(rawBody) {
2533
- const text3 = rawBody?.trim();
2534
- if (!text3) return void 0;
2535
- if (text3.startsWith('"')) {
2575
+ const text4 = rawBody?.trim();
2576
+ if (!text4) return void 0;
2577
+ if (text4.startsWith('"')) {
2536
2578
  try {
2537
- const parsed = JSON.parse(text3);
2579
+ const parsed = JSON.parse(text4);
2538
2580
  if (typeof parsed === "string" && parsed.trim()) return parsed.trim();
2539
2581
  } catch {
2540
2582
  }
2541
2583
  }
2542
- if (text3.startsWith("{") || text3.startsWith("[")) {
2584
+ if (text4.startsWith("{") || text4.startsWith("[")) {
2543
2585
  try {
2544
- const parsed = JSON.parse(text3);
2586
+ const parsed = JSON.parse(text4);
2545
2587
  const msg = messageFromJsonValue(parsed);
2546
2588
  if (msg) return msg;
2547
2589
  } catch {
2548
2590
  }
2549
2591
  }
2550
- if (text3.startsWith("<")) return void 0;
2551
- return text3;
2592
+ if (text4.startsWith("<")) return void 0;
2593
+ return text4;
2552
2594
  }
2553
2595
  function formatHttpError(status, rawBody, opts) {
2554
2596
  const verbose = opts?.verbose === true;
@@ -2565,23 +2607,24 @@ function formatHttpError(status, rawBody, opts) {
2565
2607
  function buildAuthHeaders(config) {
2566
2608
  return buildSiluzanAuthHeaders(config);
2567
2609
  }
2568
- async function parseApiResponse(status, text3, verbose) {
2610
+ async function parseApiResponse(status, text4, verbose) {
2569
2611
  if (status < 200 || status >= 300) {
2570
- const err = new Error(formatHttpError(status, text3, { verbose }));
2571
- Object.assign(err, { status, rawBody: text3 });
2612
+ const err = new Error(formatHttpError(status, text4, { verbose }));
2613
+ Object.assign(err, { status, rawBody: text4 });
2572
2614
  throw err;
2573
2615
  }
2574
- if (!text3.trim()) return null;
2616
+ if (!text4.trim()) return null;
2575
2617
  try {
2576
- return parseJsonWithStringIds(text3);
2618
+ return parseJsonWithStringIds(text4);
2577
2619
  } catch {
2578
2620
  if (verbose) {
2579
- console.error(` \u26A0\uFE0F \u54CD\u5E94\u975E JSON\uFF0C\u539F\u59CB\u5185\u5BB9\uFF1A${redactSensitive(text3).slice(0, 200)}`);
2621
+ console.error(` \u26A0\uFE0F \u54CD\u5E94\u975E JSON\uFF0C\u539F\u59CB\u5185\u5BB9\uFF1A${redactSensitive(text4).slice(0, 200)}`);
2580
2622
  }
2581
- return text3;
2623
+ return text4;
2582
2624
  }
2583
2625
  }
2584
2626
  function isTransientNetworkError(err) {
2627
+ if (err instanceof RequestAbortedError) return false;
2585
2628
  const msg = err instanceof Error ? err.message : String(err);
2586
2629
  const code = err?.code;
2587
2630
  if (typeof code === "string" && ["ECONNRESET", "EPIPE", "ETIMEDOUT", "ECONNABORTED"].includes(code)) {
@@ -2595,7 +2638,7 @@ async function requestWithReadRetry(url, options) {
2595
2638
  try {
2596
2639
  return await rawRequest(url, options);
2597
2640
  } catch (err) {
2598
- if (method !== "GET" || attempt >= GET_RETRY_DELAYS_MS.length || !isTransientNetworkError(err)) {
2641
+ if (method !== "GET" || options.signal?.aborted || attempt >= GET_RETRY_DELAYS_MS.length || !isTransientNetworkError(err)) {
2599
2642
  throw err;
2600
2643
  }
2601
2644
  await new Promise((r) => setTimeout(r, GET_RETRY_DELAYS_MS[attempt]));
@@ -2618,7 +2661,8 @@ async function apiFetch(url, config, options = {}, verbose = false) {
2618
2661
  const res = await requestWithReadRetry(url, {
2619
2662
  method,
2620
2663
  headers: reqHeaders,
2621
- body
2664
+ body,
2665
+ signal: options.signal ?? void 0
2622
2666
  });
2623
2667
  return parseApiResponse(res.status, res.text, verbose);
2624
2668
  }
@@ -2633,19 +2677,24 @@ async function apiFetchWithHeaders(url, config, options = {}, verbose = false) {
2633
2677
  ...options.headers ?? {}
2634
2678
  };
2635
2679
  const body = typeof options.body === "string" ? options.body : void 0;
2636
- const res = await requestWithReadRetry(url, { method, headers: reqHeaders, body });
2637
- const text3 = res.text;
2680
+ const res = await requestWithReadRetry(url, {
2681
+ method,
2682
+ headers: reqHeaders,
2683
+ body,
2684
+ signal: options.signal ?? void 0
2685
+ });
2686
+ const text4 = res.text;
2638
2687
  if (res.status < 200 || res.status >= 300) {
2639
- throw new Error(formatHttpError(res.status, text3, { verbose }));
2688
+ throw new Error(formatHttpError(res.status, text4, { verbose }));
2640
2689
  }
2641
2690
  let data;
2642
- if (!text3.trim()) {
2691
+ if (!text4.trim()) {
2643
2692
  data = null;
2644
2693
  } else {
2645
2694
  try {
2646
- data = parseJsonWithStringIds(text3);
2695
+ data = parseJsonWithStringIds(text4);
2647
2696
  } catch {
2648
- data = text3;
2697
+ data = text4;
2649
2698
  }
2650
2699
  }
2651
2700
  return { data, headers: res.headers };
@@ -3247,9 +3296,9 @@ function pickCompanyId(data) {
3247
3296
  }
3248
3297
  return void 0;
3249
3298
  }
3250
- function parseMeResponse(text3) {
3299
+ function parseMeResponse(text4) {
3251
3300
  try {
3252
- const json = JSON.parse(text3);
3301
+ const json = JSON.parse(text4);
3253
3302
  const data = json?.data && typeof json.data === "object" ? json.data : json;
3254
3303
  const id = pickStr(data, "entityId") ?? pickStr(data, "id") ?? pickStr(data, "userId") ?? pickStr(data, "accountId");
3255
3304
  const email = pickStr(data, "email");
@@ -3921,7 +3970,7 @@ async function issueApiKeyWithPhoneCode(opts) {
3921
3970
  });
3922
3971
  return apiKey;
3923
3972
  }
3924
- var import_semver, SILUZAN_DIR, CONFIG_FILE, inProcessLockChain, ALLOWED_HOSTNAME_SUFFIXES, EXACT_ID_FIELD_NAMES, SILUZAN_AGENT_COMPANY_SOURCE_TYPE, DEERFLOW_AGENT_ENV, _clientProduct, _resolveVersion, DEFAULT_TIMEOUT_MS, httpsAgent, httpAgent, PERF_PREFIX, DEFAULT_DETAIL_MAX, VERBOSE_DETAIL_MAX, GET_RETRY_DELAYS_MS, TABLE_CELL_PIPE, ASCII_TABLE_CHARS, CLI_SNAPSHOT_MANIFEST_FILE, SCHEMA_VERSION, FALLBACK_FIELD_GUIDE_REFS, _cliPackage, _resolveCliVersion, _fieldGuideRefs, OUTLINE_AGENT_HINT, TS_LIKE_ARRAY_SAMPLE_MAX, MAX_INVOCATION_CHARS, currentInvocation, MAX_COMMIT_CHARS, WRITE_AUDIT_AGENT_AUTO_COMMIT, cliCommitOverride, WRITE_AUDIT_SCHEMA_VERSION, MUTATING, BEIJING_TZ, AUDIT_LOG_FILENAME_RE, DEFAULT_MAX_FILE_MB, MIN_SEGMENT_BYTES, MAX_SEGMENT_BYTES, DEFAULT_RETENTION_DAYS, MIN_RETENTION_DAYS, MAX_RETENTION_DAYS, PRUNE_THROTTLE_MS, lastPruneAtMs, MAX_BODY_CHARS, MAX_ERROR_CHARS, DEFAULT_FIND_AUDIT_MAX_DAYS, MAX_SNAPSHOT_FILE_BYTES, API_KEY_SERVICE_VALUES;
3973
+ var import_semver, SILUZAN_DIR, CONFIG_FILE, inProcessLockChain, ALLOWED_HOSTNAME_SUFFIXES, EXACT_ID_FIELD_NAMES, SILUZAN_AGENT_COMPANY_SOURCE_TYPE, DEERFLOW_AGENT_ENV, _clientProduct, _resolveVersion, DEFAULT_TIMEOUT_MS, httpsAgent, httpAgent, PERF_PREFIX, RequestAbortedError, DEFAULT_DETAIL_MAX, VERBOSE_DETAIL_MAX, GET_RETRY_DELAYS_MS, TABLE_CELL_PIPE, ASCII_TABLE_CHARS, CLI_SNAPSHOT_MANIFEST_FILE, SCHEMA_VERSION, FALLBACK_FIELD_GUIDE_REFS, _cliPackage, _resolveCliVersion, _fieldGuideRefs, OUTLINE_AGENT_HINT, TS_LIKE_ARRAY_SAMPLE_MAX, MAX_INVOCATION_CHARS, currentInvocation, MAX_COMMIT_CHARS, WRITE_AUDIT_AGENT_AUTO_COMMIT, cliCommitOverride, WRITE_AUDIT_SCHEMA_VERSION, MUTATING, BEIJING_TZ, AUDIT_LOG_FILENAME_RE, DEFAULT_MAX_FILE_MB, MIN_SEGMENT_BYTES, MAX_SEGMENT_BYTES, DEFAULT_RETENTION_DAYS, MIN_RETENTION_DAYS, MAX_RETENTION_DAYS, PRUNE_THROTTLE_MS, lastPruneAtMs, MAX_BODY_CHARS, MAX_ERROR_CHARS, DEFAULT_FIND_AUDIT_MAX_DAYS, MAX_SNAPSHOT_FILE_BYTES, API_KEY_SERVICE_VALUES;
3925
3974
  var init_dist = __esm({
3926
3975
  "../common/dist/index.js"() {
3927
3976
  "use strict";
@@ -3986,6 +4035,13 @@ var init_dist = __esm({
3986
4035
  scheduling: "lifo"
3987
4036
  });
3988
4037
  PERF_PREFIX = "[SILUZAN_HTTP_PERF]";
4038
+ RequestAbortedError = class extends Error {
4039
+ code = "SILUZAN_REQUEST_CANCELLED";
4040
+ constructor(method, url) {
4041
+ super(`\u8BF7\u6C42\u5DF2\u53D6\u6D88\uFF1A${method} ${url}`);
4042
+ this.name = "RequestAbortedError";
4043
+ }
4044
+ };
3989
4045
  DEFAULT_DETAIL_MAX = 400;
3990
4046
  VERBOSE_DETAIL_MAX = 800;
3991
4047
  GET_RETRY_DELAYS_MS = [1e3, 3e3];
@@ -4395,12 +4451,12 @@ async function apiDeleteRaw(url, config, options = {}) {
4395
4451
  if (res.status < 200 || res.status >= 300) {
4396
4452
  throw new Error(formatHttpError(res.status, res.text, { verbose: options.verbose }));
4397
4453
  }
4398
- const text3 = res.text;
4399
- const value = !text3.trim() ? null : (() => {
4454
+ const text4 = res.text;
4455
+ const value = !text4.trim() ? null : (() => {
4400
4456
  try {
4401
- return JSON.parse(text3);
4457
+ return JSON.parse(text4);
4402
4458
  } catch {
4403
- return text3;
4459
+ return text4;
4404
4460
  }
4405
4461
  })();
4406
4462
  return { value, httpStatus: res.status };
@@ -5497,13 +5553,13 @@ function skippedNoSpendCampaignTypes() {
5497
5553
  };
5498
5554
  }
5499
5555
  function errorCampaignTypes(message) {
5500
- const text3 = message.replace(/\s+/g, " ").trim().slice(0, 180);
5556
+ const text4 = message.replace(/\s+/g, " ").trim().slice(0, 180);
5501
5557
  return {
5502
5558
  campaignTypesStatus: "error",
5503
5559
  campaignTypes: null,
5504
5560
  hasDisplay: null,
5505
5561
  hasPmax: null,
5506
- campaignTypesError: text3 || "unknown error"
5562
+ campaignTypesError: text4 || "unknown error"
5507
5563
  };
5508
5564
  }
5509
5565
  function errorMessage(err) {
@@ -5565,8 +5621,8 @@ function negativeKeywordSlimListUrl(googleApiUrl, accountId, query) {
5565
5621
  if (query?.appliedLevel) params.set("appliedlevel", query.appliedLevel);
5566
5622
  if (query?.readDeleted) params.set("readDeleted", "true");
5567
5623
  if (query?.excludePaused) params.set("excludePaused", "true");
5568
- const text3 = query?.keywordText?.trim();
5569
- if (text3) params.set("keywordtext", text3);
5624
+ const text4 = query?.keywordText?.trim();
5625
+ if (text4) params.set("keywordtext", text4);
5570
5626
  if (query?.matchType) params.set("matchtype", query.matchType);
5571
5627
  const qs = params.toString();
5572
5628
  return `${googleApiUrl}/negativekeywordmanagement/v2/list/${accountId}/slim${qs ? `?${qs}` : ""}`;
@@ -6837,8 +6893,8 @@ function relLuminance(hex) {
6837
6893
  function textColorFor(bgHex) {
6838
6894
  return relLuminance(bgHex) > 0.55 ? NEUTRAL.textDark : NEUTRAL.white;
6839
6895
  }
6840
- function xmlEscape(text3) {
6841
- return text3.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
6896
+ function xmlEscape(text4) {
6897
+ return text4.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
6842
6898
  }
6843
6899
  function colLetter(index) {
6844
6900
  let n = index + 1;
@@ -6960,8 +7016,8 @@ function sheetRelsXml(sheet) {
6960
7016
  ).join("");
6961
7017
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${rels}</Relationships>`;
6962
7018
  }
6963
- function estimateWrapHeight(text3, colWidthChars) {
6964
- const str3 = String(text3 ?? "");
7019
+ function estimateWrapHeight(text4, colWidthChars) {
7020
+ const str3 = String(text4 ?? "");
6965
7021
  if (!str3) return void 0;
6966
7022
  const lines = str3.split("\n").reduce((sum, line) => {
6967
7023
  const width = Math.max(colWidthChars || 20, 8);
@@ -7109,7 +7165,7 @@ var init_xlsx_style_engine = __esm({
7109
7165
  for (let i = 0; i < n; i++) this.pushRow([]);
7110
7166
  return this;
7111
7167
  }
7112
- titleBar(text3, opts = {}) {
7168
+ titleBar(text4, opts = {}) {
7113
7169
  const fill = opts.fill === null ? void 0 : opts.fill ?? NEUTRAL.titleFill;
7114
7170
  const fontColor = opts.fontColor ?? (fill ? textColorFor(fill) : NEUTRAL.textDark);
7115
7171
  const s = this.registry.resolve({
@@ -7120,22 +7176,22 @@ var init_xlsx_style_engine = __esm({
7120
7176
  border: opts.border ?? false,
7121
7177
  hAlign: opts.hAlign ?? "left"
7122
7178
  });
7123
- this.pushRow([{ value: text3, styleId: s }], { height: 28 });
7179
+ this.pushRow([{ value: text4, styleId: s }], { height: 28 });
7124
7180
  this.mergeCurrentRow(opts.span || this.colCount);
7125
7181
  return this;
7126
7182
  }
7127
- subtitleBar(text3, opts = {}) {
7183
+ subtitleBar(text4, opts = {}) {
7128
7184
  const s = this.registry.resolve({
7129
7185
  fontSize: 10.5,
7130
7186
  fontColor: NEUTRAL.subtitleText,
7131
7187
  fill: NEUTRAL.subtitleFill,
7132
7188
  border: false
7133
7189
  });
7134
- this.pushRow([{ value: text3, styleId: s }], { height: 20 });
7190
+ this.pushRow([{ value: text4, styleId: s }], { height: 20 });
7135
7191
  this.mergeCurrentRow(opts.span || this.colCount);
7136
7192
  return this;
7137
7193
  }
7138
- sectionBar(text3, opts = {}) {
7194
+ sectionBar(text4, opts = {}) {
7139
7195
  const fill = opts.fill ?? this.accentHex;
7140
7196
  const s = this.registry.resolve({
7141
7197
  fontSize: 11,
@@ -7145,11 +7201,11 @@ var init_xlsx_style_engine = __esm({
7145
7201
  border: false,
7146
7202
  hAlign: "center"
7147
7203
  });
7148
- this.pushRow([{ value: text3, styleId: s }], { height: 22 });
7204
+ this.pushRow([{ value: text4, styleId: s }], { height: 22 });
7149
7205
  this.mergeCurrentRow(opts.span || this.colCount);
7150
7206
  return this;
7151
7207
  }
7152
- noteRow(text3, span) {
7208
+ noteRow(text4, span) {
7153
7209
  const s = this.registry.resolve({
7154
7210
  fontSize: 9,
7155
7211
  fontColor: NEUTRAL.textMuted,
@@ -7157,8 +7213,8 @@ var init_xlsx_style_engine = __esm({
7157
7213
  border: true,
7158
7214
  vAlign: "top"
7159
7215
  });
7160
- const height = estimateWrapHeight(text3, this.colWidths.reduce((a, b) => a + b, 0) || 60);
7161
- this.pushRow([{ value: text3, styleId: s }], { height });
7216
+ const height = estimateWrapHeight(text4, this.colWidths.reduce((a, b) => a + b, 0) || 60);
7217
+ this.pushRow([{ value: text4, styleId: s }], { height });
7162
7218
  this.mergeCurrentRow(span || this.colCount);
7163
7219
  return this;
7164
7220
  }
@@ -8341,20 +8397,27 @@ function sleep3(ms, signal) {
8341
8397
  signal?.addEventListener("abort", onAbort, { once: true });
8342
8398
  });
8343
8399
  }
8344
- async function withTaskTimeout(factory, timeoutMs, label2) {
8345
- if (!timeoutMs || timeoutMs <= 0) return factory();
8400
+ async function withTaskTimeout(factory, timeoutMs, label2, parentSignal) {
8401
+ const controller = new AbortController();
8402
+ const abortFromParent = () => controller.abort();
8403
+ if (parentSignal?.aborted) controller.abort();
8404
+ else parentSignal?.addEventListener("abort", abortFromParent, { once: true });
8346
8405
  let timer;
8347
8406
  try {
8407
+ if (!timeoutMs || timeoutMs <= 0) return await factory(controller.signal);
8348
8408
  return await Promise.race([
8349
- factory(),
8409
+ factory(controller.signal),
8350
8410
  new Promise((_, reject) => {
8351
8411
  timer = setTimeout(() => {
8352
- reject(new Error(`\u8BF7\u6C42\u8D85\u65F6\uFF08${(timeoutMs / 1e3).toFixed(0)} \u79D2\uFF09\uFF1A${label2}`));
8412
+ const seconds = (timeoutMs / 1e3).toFixed(timeoutMs < 1e3 ? 1 : 0);
8413
+ reject(new Error(`\u8BF7\u6C42\u8D85\u65F6\uFF08${seconds} \u79D2\uFF09\uFF1A${label2}`));
8414
+ controller.abort();
8353
8415
  }, timeoutMs);
8354
8416
  })
8355
8417
  ]);
8356
8418
  } finally {
8357
8419
  if (timer) clearTimeout(timer);
8420
+ parentSignal?.removeEventListener("abort", abortFromParent);
8358
8421
  }
8359
8422
  }
8360
8423
  async function fetchWithRetry(factory, options) {
@@ -8368,12 +8431,18 @@ async function fetchWithRetry(factory, options) {
8368
8431
  });
8369
8432
  }
8370
8433
  try {
8371
- return await withTaskTimeout(factory, policy.taskTimeoutMs, options.label);
8434
+ return await withTaskTimeout(factory, policy.taskTimeoutMs, options.label, options.signal);
8372
8435
  } catch (raw) {
8373
8436
  const err = raw instanceof Error ? raw : new Error(String(raw));
8374
8437
  const cls = classifyError(err);
8375
8438
  lastErr = err;
8376
8439
  lastStatus = cls.status;
8440
+ if (options.signal?.aborted) {
8441
+ throw new AbortRunError({
8442
+ message: `\u4EFB\u52A1\u88AB\u5916\u90E8\u4FE1\u53F7\u4E2D\u6B62\uFF1A${options.label}`,
8443
+ cause: err
8444
+ });
8445
+ }
8377
8446
  if (cls.class === "abort") {
8378
8447
  throw new AbortRunError({
8379
8448
  message: `Token \u5931\u6548\u6216\u81F4\u547D\u9519\u8BEF\uFF08${options.label}\uFF09\uFF1A${err.message}`,
@@ -103881,10 +103950,18 @@ async function fetchGoogleAnalysisHttp(label2, factory, http2) {
103881
103950
  }
103882
103951
  async function fetchJson(config, pathWithQuery, verbose, label2 = pathWithQuery, http2) {
103883
103952
  const url = `${config.googleApiUrl}${pathWithQuery}`;
103884
- return fetchGoogleAnalysisHttp(label2, () => apiFetch2(url, config, {}, verbose), http2);
103953
+ return fetchGoogleAnalysisHttp(
103954
+ label2,
103955
+ (signal) => apiFetch2(url, config, { signal }, verbose),
103956
+ http2
103957
+ );
103885
103958
  }
103886
103959
  async function fetchMainPlatformJson(url, config, verbose, label2, http2) {
103887
- return fetchGoogleAnalysisHttp(label2, () => apiFetch2(url, config, {}, verbose), http2);
103960
+ return fetchGoogleAnalysisHttp(
103961
+ label2,
103962
+ (signal) => apiFetch2(url, config, { signal }, verbose),
103963
+ http2
103964
+ );
103888
103965
  }
103889
103966
  function deviceBidModifierLookupKey(campaignId, adGroupId, deviceType) {
103890
103967
  return `${campaignId ?? ""}\0${adGroupId ?? ""}\0${deviceType ?? ""}`;
@@ -104178,6 +104255,121 @@ var init_fetch = __esm({
104178
104255
  }
104179
104256
  });
104180
104257
 
104258
+ // src/commands/google-analysis/demand-gen-report-content.ts
104259
+ function isRecord4(value) {
104260
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
104261
+ }
104262
+ function text3(value) {
104263
+ return typeof value === "string" ? value.trim() : "";
104264
+ }
104265
+ function asDemandGenReport(value) {
104266
+ if (!isRecord4(value)) throw new Error("\u62A5\u544A\u6570\u636E\u987B\u4E3A JSON \u5BF9\u8C61");
104267
+ return value;
104268
+ }
104269
+ function validateDemandGenReport(payload) {
104270
+ const errors = [];
104271
+ const meta = payload.meta;
104272
+ const narrative = payload.narrative;
104273
+ if (!meta || !narrative) {
104274
+ return { ok: false, errors: ["JSON \u987B\u542B meta \u4E0E narrative"] };
104275
+ }
104276
+ if (!text3(meta.accountId)) errors.push("meta.accountId \u5FC5\u586B");
104277
+ if (!text3(meta.currency)) errors.push("meta.currency \u5FC5\u586B");
104278
+ if (!text3(meta.startDate) || !text3(meta.endDate)) errors.push("meta.startDate / meta.endDate \u5FC5\u586B");
104279
+ if (!text3(narrative.headline)) errors.push("narrative.headline \u5FC5\u586B");
104280
+ const kpiCount = (narrative.headlineKpis?.length ?? 0) + (narrative.kpiGroups ?? []).reduce((sum, group) => sum + (group.items?.length ?? 0), 0);
104281
+ if (kpiCount < 1) errors.push("\u81F3\u5C11 1 \u4E2A\u6838\u5FC3\u6307\u6807\uFF08headlineKpis \u6216 kpiGroups\uFF09");
104282
+ if ((narrative.funnel?.stages?.length ?? 0) < 1) errors.push("narrative.funnel.stages \u81F3\u5C11 1 \u7EA7");
104283
+ if ((narrative.dimensions?.length ?? 0) < 1) errors.push("narrative.dimensions \u81F3\u5C11 1 \u4E2A\u7EF4\u5EA6");
104284
+ if ((narrative.actions?.length ?? 0) < 1) errors.push("narrative.actions \u81F3\u5C11 1 \u6761");
104285
+ if ((narrative.tests?.length ?? 0) < 1) errors.push("narrative.tests \u81F3\u5C11 1 \u6761");
104286
+ for (const dimension of narrative.dimensions ?? []) {
104287
+ if (!text3(dimension.title)) errors.push("\u7EF4\u5EA6\u7F3A\u5C11 title");
104288
+ if (!dimension.columns?.length) errors.push(`\u7EF4\u5EA6\u300C${dimension.title || "\u672A\u547D\u540D"}\u300D\u7F3A\u5C11 columns`);
104289
+ }
104290
+ return { ok: errors.length === 0, errors };
104291
+ }
104292
+ function formatDemandGenReportErrors(check) {
104293
+ return check.errors.map((item) => `- ${item}`).join("\n");
104294
+ }
104295
+ var init_demand_gen_report_content = __esm({
104296
+ "src/commands/google-analysis/demand-gen-report-content.ts"() {
104297
+ "use strict";
104298
+ }
104299
+ });
104300
+
104301
+ // src/commands/google-analysis/demand-gen-render.ts
104302
+ import fs28 from "fs";
104303
+ import fsPromises2 from "fs/promises";
104304
+ import path33 from "path";
104305
+ import { fileURLToPath as fileURLToPath9 } from "url";
104306
+ function resolveSkillTemplatePath3(basename13) {
104307
+ const dir = path33.dirname(fileURLToPath9(import.meta.url));
104308
+ const candidates = [
104309
+ path33.join(dir, "skill", "report-templates", basename13),
104310
+ path33.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
104311
+ path33.join(dir, "..", "..", "..", "assets", "siluzan-ads", "report-templates", basename13),
104312
+ path33.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
104313
+ ];
104314
+ for (const candidate of candidates) {
104315
+ if (fs28.existsSync(candidate)) return candidate;
104316
+ }
104317
+ return path33.join(dir, "skill", "report-templates", basename13);
104318
+ }
104319
+ function demandGenReportTemplatePath() {
104320
+ return resolveSkillTemplatePath3(TEMPLATE_BASENAME);
104321
+ }
104322
+ async function readJsonFile2(filePath) {
104323
+ const text4 = await fsPromises2.readFile(filePath, "utf8");
104324
+ try {
104325
+ return JSON.parse(text4);
104326
+ } catch {
104327
+ throw new Error(`\u65E0\u6CD5\u89E3\u6790 JSON\uFF1A${filePath}`);
104328
+ }
104329
+ }
104330
+ function injectDemandGenReport(html, payload) {
104331
+ if (!html.includes(DEMAND_GEN_INJECT_MARKER)) {
104332
+ throw new Error("\u62A5\u544A\u6A21\u677F\u7F3A\u5C11\u6570\u636E\u6CE8\u5165\u951A\u70B9\uFF0C\u8BF7\u66F4\u65B0 demand-gen-analysis-report.html");
104333
+ }
104334
+ const json = JSON.stringify(payload).replace(/</g, "\\u003c");
104335
+ return html.replace(DEMAND_GEN_INJECT_MARKER, `window.__DEMAND_GEN_REPORT__ = ${json};`);
104336
+ }
104337
+ async function runDemandGenRender(opts) {
104338
+ const dataPath = path33.resolve(opts.dataFile);
104339
+ const data = asDemandGenReport(await readJsonFile2(dataPath));
104340
+ if (opts.lang?.trim()) data.meta.lang = opts.lang.trim();
104341
+ const check = validateDemandGenReport(data);
104342
+ if (!check.ok) {
104343
+ throw new Error(`Demand Gen \u62A5\u544A\u7F3A\u5FC5\u586B\u5185\u5BB9\uFF1A
104344
+ ${formatDemandGenReportErrors(check)}`);
104345
+ }
104346
+ const templatePath = demandGenReportTemplatePath();
104347
+ let html;
104348
+ try {
104349
+ html = await fsPromises2.readFile(templatePath, "utf8");
104350
+ } catch {
104351
+ throw new Error(`\u672A\u627E\u5230\u62A5\u544A\u6A21\u677F\uFF1A${templatePath}\u3002\u8BF7\u5148\u6267\u884C npm run build`);
104352
+ }
104353
+ const outPath = path33.resolve(
104354
+ opts.out ?? path33.join(path33.dirname(dataPath), "demand-gen-analysis-report.html")
104355
+ );
104356
+ await fsPromises2.mkdir(path33.dirname(outPath), { recursive: true });
104357
+ await fsPromises2.writeFile(outPath, injectDemandGenReport(html, data), "utf8");
104358
+ console.log(`
104359
+ \u2705 Demand Gen \u6295\u653E\u6570\u636E\u5206\u6790 HTML \u5DF2\u751F\u6210\uFF1A${outPath}
104360
+ `);
104361
+ return outPath;
104362
+ }
104363
+ var TEMPLATE_BASENAME, DEMAND_GEN_INJECT_MARKER;
104364
+ var init_demand_gen_render = __esm({
104365
+ "src/commands/google-analysis/demand-gen-render.ts"() {
104366
+ "use strict";
104367
+ init_demand_gen_report_content();
104368
+ TEMPLATE_BASENAME = "demand-gen-analysis-report.html";
104369
+ DEMAND_GEN_INJECT_MARKER = "window.__DEMAND_GEN_REPORT__ = window.__DEMAND_GEN_REPORT__ || null;";
104370
+ }
104371
+ });
104372
+
104181
104373
  // src/commands/google-analysis/okki-display.ts
104182
104374
  function num3(value) {
104183
104375
  const n = typeof value === "number" ? value : Number(value);
@@ -104267,8 +104459,8 @@ function summarizeOkkiDeviceSpend(rows) {
104267
104459
  otherConversions: conv.other
104268
104460
  };
104269
104461
  }
104270
- function narrativeClaimsMobileSpendLeads(text3) {
104271
- const t = text3.replace(/\s+/g, "");
104462
+ function narrativeClaimsMobileSpendLeads(text4) {
104463
+ const t = text4.replace(/\s+/g, "");
104272
104464
  if (!t.includes("\u79FB\u52A8")) return false;
104273
104465
  return /移动(?:端|设备)?(?:为|是)主要消耗/.test(t) || /移动(?:端|设备)?为主要(?:消耗)?设备/.test(t) || /移动(?:端|设备)?(?:消耗|花费|费用|流量)?占比高/.test(t);
104274
104466
  }
@@ -104304,8 +104496,8 @@ var init_okki_display = __esm({
104304
104496
  });
104305
104497
 
104306
104498
  // src/commands/google-analysis/merge-snapshot.ts
104307
- import * as fs28 from "fs/promises";
104308
- import * as path33 from "path";
104499
+ import * as fs29 from "fs/promises";
104500
+ import * as path34 from "path";
104309
104501
  function asRecord21(value) {
104310
104502
  if (value && typeof value === "object" && !Array.isArray(value)) {
104311
104503
  return value;
@@ -104323,7 +104515,7 @@ async function readManifest(snapshotDir, accountId) {
104323
104515
  const candidates = [];
104324
104516
  if (accountId) candidates.push(googleAnalysisManifestFile(accountId));
104325
104517
  try {
104326
- const entries = await fs28.readdir(snapshotDir);
104518
+ const entries = await fs29.readdir(snapshotDir);
104327
104519
  const manifestNames = entries.filter((n) => n.startsWith("manifest") && n.endsWith(".json"));
104328
104520
  for (const name2 of manifestNames) {
104329
104521
  if (!candidates.includes(name2)) candidates.push(name2);
@@ -104332,7 +104524,7 @@ async function readManifest(snapshotDir, accountId) {
104332
104524
  }
104333
104525
  for (const name2 of candidates) {
104334
104526
  try {
104335
- const raw = await fs28.readFile(path33.join(snapshotDir, name2), "utf8");
104527
+ const raw = await fs29.readFile(path34.join(snapshotDir, name2), "utf8");
104336
104528
  const parsed = JSON.parse(raw);
104337
104529
  if (Array.isArray(parsed.artifacts) && parsed.artifacts.length > 0) return parsed;
104338
104530
  } catch {
@@ -104342,7 +104534,7 @@ async function readManifest(snapshotDir, accountId) {
104342
104534
  }
104343
104535
  async function loadSectionFile(snapshotDir, file) {
104344
104536
  try {
104345
- const raw = await fs28.readFile(path33.join(snapshotDir, file), "utf8");
104537
+ const raw = await fs29.readFile(path34.join(snapshotDir, file), "utf8");
104346
104538
  const parsed = JSON.parse(raw);
104347
104539
  if (parsed && typeof parsed === "object") return parsed;
104348
104540
  return null;
@@ -104351,12 +104543,12 @@ async function loadSectionFile(snapshotDir, file) {
104351
104543
  }
104352
104544
  }
104353
104545
  function negativeKeywordText(row) {
104354
- const text3 = row.keywordText;
104355
- if (Array.isArray(text3)) {
104356
- const parts = text3.map((part) => String(part).trim()).filter(Boolean);
104546
+ const text4 = row.keywordText;
104547
+ if (Array.isArray(text4)) {
104548
+ const parts = text4.map((part) => String(part).trim()).filter(Boolean);
104357
104549
  if (parts.length > 0) return parts.join(", ");
104358
104550
  }
104359
- if (typeof text3 === "string" && text3.trim()) return text3.trim();
104551
+ if (typeof text4 === "string" && text4.trim()) return text4.trim();
104360
104552
  if (typeof row.keyword === "string" && row.keyword.trim()) return row.keyword.trim();
104361
104553
  return "\u2014";
104362
104554
  }
@@ -104411,7 +104603,7 @@ async function recoverMissingReportSections(sectionMap, absDir, accountId, prefe
104411
104603
  if (!accountId) return;
104412
104604
  let entries;
104413
104605
  try {
104414
- entries = await fs28.readdir(absDir);
104606
+ entries = await fs29.readdir(absDir);
104415
104607
  } catch {
104416
104608
  return;
104417
104609
  }
@@ -104483,7 +104675,7 @@ function sumCampaignRowsToPeriodKpis(rows) {
104483
104675
  };
104484
104676
  }
104485
104677
  async function mergeGoogleAnalysisSnapshotIntoReport(payload, snapshotDir) {
104486
- const absDir = path33.resolve(snapshotDir);
104678
+ const absDir = path34.resolve(snapshotDir);
104487
104679
  const metaAccountId = typeof asRecord21(payload.meta)?.accountId === "string" ? asRecord21(payload.meta)?.accountId : void 0;
104488
104680
  const manifest = await readManifest(snapshotDir, metaAccountId);
104489
104681
  if (!manifest) {
@@ -104839,8 +105031,8 @@ var init_okki_report_content = __esm({
104839
105031
  });
104840
105032
 
104841
105033
  // src/commands/google-analysis/okki-merge-snapshot.ts
104842
- import * as fs29 from "fs/promises";
104843
- import * as path34 from "path";
105034
+ import * as fs30 from "fs/promises";
105035
+ import * as path35 from "path";
104844
105036
  function num5(value) {
104845
105037
  const n = Number(value);
104846
105038
  return Number.isFinite(n) ? n : void 0;
@@ -104866,7 +105058,7 @@ async function readManifest2(snapshotDir, accountId) {
104866
105058
  const candidates = [];
104867
105059
  if (accountId) candidates.push(googleAnalysisManifestFile(accountId));
104868
105060
  try {
104869
- const entries = await fs29.readdir(snapshotDir);
105061
+ const entries = await fs30.readdir(snapshotDir);
104870
105062
  for (const name2 of entries.filter((n) => n.startsWith("manifest") && n.endsWith(".json"))) {
104871
105063
  if (!candidates.includes(name2)) candidates.push(name2);
104872
105064
  }
@@ -104874,7 +105066,7 @@ async function readManifest2(snapshotDir, accountId) {
104874
105066
  }
104875
105067
  for (const name2 of candidates) {
104876
105068
  try {
104877
- const raw = await fs29.readFile(path34.join(snapshotDir, name2), "utf8");
105069
+ const raw = await fs30.readFile(path35.join(snapshotDir, name2), "utf8");
104878
105070
  const parsed = JSON.parse(raw);
104879
105071
  if (Array.isArray(parsed.artifacts) && parsed.artifacts.length > 0) return parsed;
104880
105072
  } catch {
@@ -104884,7 +105076,7 @@ async function readManifest2(snapshotDir, accountId) {
104884
105076
  }
104885
105077
  async function loadSectionFile2(snapshotDir, file) {
104886
105078
  try {
104887
- const raw = await fs29.readFile(path34.join(snapshotDir, file), "utf8");
105079
+ const raw = await fs30.readFile(path35.join(snapshotDir, file), "utf8");
104888
105080
  const parsed = JSON.parse(raw);
104889
105081
  if (parsed && typeof parsed === "object") return parsed;
104890
105082
  return null;
@@ -104893,7 +105085,7 @@ async function loadSectionFile2(snapshotDir, file) {
104893
105085
  }
104894
105086
  }
104895
105087
  async function mergeOkkiSnapshotIntoReport(payload, snapshotDir) {
104896
- const absDir = path34.resolve(snapshotDir);
105088
+ const absDir = path35.resolve(snapshotDir);
104897
105089
  const metaAccountId = typeof asRecord22(payload.meta)?.accountId === "string" ? asRecord22(payload.meta)?.accountId : void 0;
104898
105090
  const manifest = await readManifest2(absDir, metaAccountId);
104899
105091
  if (!manifest) {
@@ -104910,7 +105102,7 @@ async function mergeOkkiSnapshotIntoReport(payload, snapshotDir) {
104910
105102
  if (accountId) {
104911
105103
  let entries = [];
104912
105104
  try {
104913
- entries = await fs29.readdir(absDir);
105105
+ entries = await fs30.readdir(absDir);
104914
105106
  } catch {
104915
105107
  entries = [];
104916
105108
  }
@@ -105078,9 +105270,9 @@ function sortBySpendDesc(rows) {
105078
105270
  return [...rows].sort((a, b) => (num6(b.spend) ?? 0) - (num6(a.spend) ?? 0));
105079
105271
  }
105080
105272
  function prefixLines(items3, firstPrefix) {
105081
- return items3.map((text3, idx) => {
105082
- if (idx === 0 && !text3.startsWith(firstPrefix)) return `${firstPrefix}${text3}`;
105083
- return text3;
105273
+ return items3.map((text4, idx) => {
105274
+ if (idx === 0 && !text4.startsWith(firstPrefix)) return `${firstPrefix}${text4}`;
105275
+ return text4;
105084
105276
  });
105085
105277
  }
105086
105278
  function analysisLines(data, key) {
@@ -105355,13 +105547,13 @@ function buildOkkiWeeklySheetDrafts(data, lang = "zh") {
105355
105547
  }
105356
105548
  function localizeOkkiDraft(draft, lang) {
105357
105549
  if (lang !== "en") return draft;
105358
- const text3 = (value) => applyEnglishPhrases(value);
105550
+ const text4 = (value) => applyEnglishPhrases(value);
105359
105551
  return {
105360
105552
  ...draft,
105361
- name: text3(draft.name),
105362
- title: text3(draft.title),
105363
- headers: draft.headers.map(text3),
105364
- reviewTitle: draft.reviewTitle ? text3(draft.reviewTitle) : draft.reviewTitle
105553
+ name: text4(draft.name),
105554
+ title: text4(draft.title),
105555
+ headers: draft.headers.map(text4),
105556
+ reviewTitle: draft.reviewTitle ? text4(draft.reviewTitle) : draft.reviewTitle
105365
105557
  };
105366
105558
  }
105367
105559
  function writeOkkiWeeklyExcel(outPath, data, lang = "zh") {
@@ -105433,12 +105625,12 @@ var init_okki_render_excel = __esm({
105433
105625
  });
105434
105626
 
105435
105627
  // src/commands/google-analysis/okki-render-report.ts
105436
- import fs30 from "fs/promises";
105437
- import path35 from "path";
105438
- async function readJsonFile2(filePath) {
105439
- const text3 = await fs30.readFile(filePath, "utf8");
105628
+ import fs31 from "fs/promises";
105629
+ import path36 from "path";
105630
+ async function readJsonFile3(filePath) {
105631
+ const text4 = await fs31.readFile(filePath, "utf8");
105440
105632
  try {
105441
- return JSON.parse(text3);
105633
+ return JSON.parse(text4);
105442
105634
  } catch {
105443
105635
  throw new Error(`\u65E0\u6CD5\u89E3\u6790 JSON\uFF1A${filePath}`);
105444
105636
  }
@@ -105450,15 +105642,15 @@ function asPayload(value) {
105450
105642
  throw new Error("\u62A5\u544A\u6570\u636E\u987B\u4E3A JSON \u5BF9\u8C61");
105451
105643
  }
105452
105644
  async function runGoogleAnalysisOkkiRender(opts) {
105453
- const dataPath = path35.resolve(opts.dataFile);
105645
+ const dataPath = path36.resolve(opts.dataFile);
105454
105646
  const snapshotDir = opts.snapshotDir?.trim();
105455
105647
  if (!snapshotDir) {
105456
105648
  console.error("\n\u274C okki-render \u5FC5\u987B\u4F20 --snapshot-dir\uFF08google-analysis --json-out \u76EE\u5F55\uFF09\n");
105457
105649
  process.exit(1);
105458
105650
  }
105459
- let data = asPayload(await readJsonFile2(dataPath));
105651
+ let data = asPayload(await readJsonFile3(dataPath));
105460
105652
  try {
105461
- data = await mergeOkkiSnapshotIntoReport(data, path35.resolve(snapshotDir));
105653
+ data = await mergeOkkiSnapshotIntoReport(data, path36.resolve(snapshotDir));
105462
105654
  } catch (err) {
105463
105655
  console.error(`
105464
105656
  \u274C ${err instanceof Error ? err.message : String(err)}
@@ -105478,10 +105670,10 @@ async function runGoogleAnalysisOkkiRender(opts) {
105478
105670
  );
105479
105671
  process.exit(1);
105480
105672
  }
105481
- const outPath = path35.resolve(
105482
- opts.out ?? path35.join(path35.dirname(dataPath), "okki-weekly-report.xlsx")
105673
+ const outPath = path36.resolve(
105674
+ opts.out ?? path36.join(path36.dirname(dataPath), "okki-weekly-report.xlsx")
105483
105675
  );
105484
- await fs30.mkdir(path35.dirname(outPath), { recursive: true });
105676
+ await fs31.mkdir(path36.dirname(outPath), { recursive: true });
105485
105677
  writeOkkiWeeklyExcel(outPath, data, lang);
105486
105678
  console.log(`
105487
105679
  \u2705 OKKI \u5468\u62A5\u5DF2\u751F\u6210\uFF1A${outPath}
@@ -105654,29 +105846,29 @@ var init_report_content = __esm({
105654
105846
  });
105655
105847
 
105656
105848
  // src/commands/google-analysis/render-report.ts
105657
- import fs31 from "fs";
105658
- import fsPromises2 from "fs/promises";
105659
- import path36 from "path";
105660
- import { fileURLToPath as fileURLToPath9 } from "url";
105661
- function resolveSkillTemplatePath3(basename13) {
105662
- const dir = path36.dirname(fileURLToPath9(import.meta.url));
105849
+ import fs32 from "fs";
105850
+ import fsPromises3 from "fs/promises";
105851
+ import path37 from "path";
105852
+ import { fileURLToPath as fileURLToPath10 } from "url";
105853
+ function resolveSkillTemplatePath4(basename13) {
105854
+ const dir = path37.dirname(fileURLToPath10(import.meta.url));
105663
105855
  const candidates = [
105664
- path36.join(dir, "skill", "report-templates", basename13),
105665
- path36.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
105666
- path36.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
105856
+ path37.join(dir, "skill", "report-templates", basename13),
105857
+ path37.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
105858
+ path37.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
105667
105859
  ];
105668
105860
  for (const p of candidates) {
105669
- if (fs31.existsSync(p)) return p;
105861
+ if (fs32.existsSync(p)) return p;
105670
105862
  }
105671
105863
  return candidates[0];
105672
105864
  }
105673
105865
  function googlePeriodReportTemplatePath() {
105674
- return resolveSkillTemplatePath3(TEMPLATE_BASENAME);
105866
+ return resolveSkillTemplatePath4(TEMPLATE_BASENAME2);
105675
105867
  }
105676
- async function readJsonFile3(filePath) {
105677
- const text3 = await fsPromises2.readFile(filePath, "utf8");
105868
+ async function readJsonFile4(filePath) {
105869
+ const text4 = await fsPromises3.readFile(filePath, "utf8");
105678
105870
  try {
105679
- return JSON.parse(text3);
105871
+ return JSON.parse(text4);
105680
105872
  } catch {
105681
105873
  throw new Error(`\u65E0\u6CD5\u89E3\u6790 JSON\uFF1A${filePath}`);
105682
105874
  }
@@ -105696,10 +105888,10 @@ function injectReportData2(html, payload, lang) {
105696
105888
  return localized.replace(INJECT_MARKER, `window.__GOOGLE_PERIOD_REPORT__ = ${json};`);
105697
105889
  }
105698
105890
  async function runGoogleAnalysisRender(opts) {
105699
- const dataPath = path36.resolve(opts.dataFile);
105700
- let data = asRecord24(await readJsonFile3(dataPath));
105891
+ const dataPath = path37.resolve(opts.dataFile);
105892
+ let data = asRecord24(await readJsonFile4(dataPath));
105701
105893
  if (opts.snapshotDir?.trim()) {
105702
- data = await mergeGoogleAnalysisSnapshotIntoReport(data, path36.resolve(opts.snapshotDir));
105894
+ data = await mergeGoogleAnalysisSnapshotIntoReport(data, path37.resolve(opts.snapshotDir));
105703
105895
  }
105704
105896
  const lang = readReportLangOrExit({ flag: opts.lang, meta: data.meta });
105705
105897
  const contentCheck = validateGooglePeriodReportContent(data);
@@ -105718,7 +105910,7 @@ async function runGoogleAnalysisRender(opts) {
105718
105910
  const templatePath = googlePeriodReportTemplatePath();
105719
105911
  let html;
105720
105912
  try {
105721
- html = await fsPromises2.readFile(templatePath, "utf8");
105913
+ html = await fsPromises3.readFile(templatePath, "utf8");
105722
105914
  } catch {
105723
105915
  console.error(`
105724
105916
  \u274C \u672A\u627E\u5230\u62A5\u544A\u6A21\u677F\uFF1A${templatePath}
@@ -105726,12 +105918,12 @@ async function runGoogleAnalysisRender(opts) {
105726
105918
  `);
105727
105919
  process.exit(1);
105728
105920
  }
105729
- const outPath = path36.resolve(
105730
- opts.out ?? path36.join(path36.dirname(dataPath), "google-period-report.html")
105921
+ const outPath = path37.resolve(
105922
+ opts.out ?? path37.join(path37.dirname(dataPath), "google-period-report.html")
105731
105923
  );
105732
- const outDir = path36.dirname(outPath);
105733
- await fsPromises2.mkdir(outDir, { recursive: true });
105734
- await fsPromises2.writeFile(outPath, injectReportData2(html, data, lang), "utf8");
105924
+ const outDir = path37.dirname(outPath);
105925
+ await fsPromises3.mkdir(outDir, { recursive: true });
105926
+ await fsPromises3.writeFile(outPath, injectReportData2(html, data, lang), "utf8");
105735
105927
  const { stats } = contentCheck;
105736
105928
  const cover = periodWord(attachPeriodChrome(data).periodChrome.unit, "\u5468\u671F");
105737
105929
  console.log(`
@@ -105745,7 +105937,7 @@ async function runGoogleAnalysisRender(opts) {
105745
105937
  "\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00 HTML \u6587\u4EF6\u5373\u53EF\u67E5\u770B\u56FE\u8868\u4E0E\u5B8C\u6574\u7AE0\u8282\uFF08ECharts\uFF1Astaticpn.siluzan.com/homeCDN/echarts.min.js\uFF09\u3002\n"
105746
105938
  );
105747
105939
  }
105748
- var TEMPLATE_BASENAME, INJECT_MARKER;
105940
+ var TEMPLATE_BASENAME2, INJECT_MARKER;
105749
105941
  var init_render_report = __esm({
105750
105942
  "src/commands/google-analysis/render-report.ts"() {
105751
105943
  "use strict";
@@ -105754,14 +105946,14 @@ var init_render_report = __esm({
105754
105946
  init_report_period();
105755
105947
  init_lang();
105756
105948
  init_html();
105757
- TEMPLATE_BASENAME = "google-period-report.html";
105949
+ TEMPLATE_BASENAME2 = "google-period-report.html";
105758
105950
  INJECT_MARKER = "window.__GOOGLE_PERIOD_REPORT__ = window.__GOOGLE_PERIOD_REPORT__ || null;";
105759
105951
  }
105760
105952
  });
105761
105953
 
105762
105954
  // src/utils/batch-manifest.ts
105763
- import * as fs32 from "fs/promises";
105764
- import * as path37 from "path";
105955
+ import * as fs33 from "fs/promises";
105956
+ import * as path38 from "path";
105765
105957
  import { randomUUID as randomUUID2 } from "crypto";
105766
105958
  function generateRunId(now = /* @__PURE__ */ new Date()) {
105767
105959
  const pad3 = (n) => String(n).padStart(2, "0");
@@ -105775,26 +105967,26 @@ function isValidRunId(id) {
105775
105967
  }
105776
105968
  function resolveBatchPaths(baseDir, runId) {
105777
105969
  if (!isValidRunId(runId)) throw new Error(`\u975E\u6CD5 runId\uFF1A${runId}`);
105778
- const runDir = path37.resolve(baseDir, runId);
105779
- const stateDir = path37.join(runDir, "state");
105970
+ const runDir = path38.resolve(baseDir, runId);
105971
+ const stateDir = path38.join(runDir, "state");
105780
105972
  return {
105781
105973
  runDir,
105782
- runManifestFile: path37.join(runDir, "run-manifest.json"),
105783
- progressFile: path37.join(runDir, "progress.json"),
105784
- accountsFile: path37.join(runDir, "accounts.json"),
105785
- resultsDir: path37.join(runDir, "results"),
105786
- errorsDir: path37.join(runDir, "errors"),
105974
+ runManifestFile: path38.join(runDir, "run-manifest.json"),
105975
+ progressFile: path38.join(runDir, "progress.json"),
105976
+ accountsFile: path38.join(runDir, "accounts.json"),
105977
+ resultsDir: path38.join(runDir, "results"),
105978
+ errorsDir: path38.join(runDir, "errors"),
105787
105979
  stateDir,
105788
- tasksLogFile: path37.join(stateDir, "tasks.jsonl"),
105789
- lockFile: path37.join(stateDir, "tasks.lock")
105980
+ tasksLogFile: path38.join(stateDir, "tasks.jsonl"),
105981
+ lockFile: path38.join(stateDir, "tasks.lock")
105790
105982
  };
105791
105983
  }
105792
105984
  async function ensureAccountDirs(paths, accountId) {
105793
105985
  const safe = sanitizeAccountSegment(accountId);
105794
- const results = path37.join(paths.resultsDir, safe);
105795
- const errors = path37.join(paths.errorsDir, safe);
105796
- await fs32.mkdir(results, { recursive: true });
105797
- await fs32.mkdir(errors, { recursive: true });
105986
+ const results = path38.join(paths.resultsDir, safe);
105987
+ const errors = path38.join(paths.errorsDir, safe);
105988
+ await fs33.mkdir(results, { recursive: true });
105989
+ await fs33.mkdir(errors, { recursive: true });
105798
105990
  return { results, errors };
105799
105991
  }
105800
105992
  function sanitizeAccountSegment(accountId) {
@@ -105809,20 +106001,20 @@ function sanitizeAccountSegment(accountId) {
105809
106001
  return slug;
105810
106002
  }
105811
106003
  async function atomicWriteFile(target, content) {
105812
- const dir = path37.dirname(target);
105813
- await fs32.mkdir(dir, { recursive: true });
105814
- const tmp = path37.join(dir, `.tmp-${randomUUID2()}-${path37.basename(target)}`);
106004
+ const dir = path38.dirname(target);
106005
+ await fs33.mkdir(dir, { recursive: true });
106006
+ const tmp = path38.join(dir, `.tmp-${randomUUID2()}-${path38.basename(target)}`);
105815
106007
  try {
105816
- await fs32.writeFile(tmp, content, "utf8");
105817
- await fs32.rename(tmp, target);
106008
+ await fs33.writeFile(tmp, content, "utf8");
106009
+ await fs33.rename(tmp, target);
105818
106010
  } catch (e) {
105819
- await fs32.rm(tmp, { force: true }).catch(() => void 0);
106011
+ await fs33.rm(tmp, { force: true }).catch(() => void 0);
105820
106012
  throw e;
105821
106013
  }
105822
106014
  }
105823
106015
  async function readJsonIfExists(file) {
105824
106016
  try {
105825
- const raw = await fs32.readFile(file, "utf8");
106017
+ const raw = await fs33.readFile(file, "utf8");
105826
106018
  return JSON.parse(raw);
105827
106019
  } catch (e) {
105828
106020
  if (e.code === "ENOENT") return null;
@@ -105865,8 +106057,8 @@ function isTaskLogEntry(value) {
105865
106057
  return typeof row.at === "string" && typeof row.id === "string" && typeof row.accountId === "string" && typeof row.section === "string" && typeof row.state === "string" && TASK_LOG_STATES.has(row.state) && typeof row.attempts === "number";
105866
106058
  }
105867
106059
  async function writeTaskLogLine(paths, entry) {
105868
- await fs32.mkdir(paths.stateDir, { recursive: true });
105869
- await fs32.appendFile(paths.tasksLogFile, JSON.stringify(clampTaskLogEntry(entry)) + "\n", "utf8");
106060
+ await fs33.mkdir(paths.stateDir, { recursive: true });
106061
+ await fs33.appendFile(paths.tasksLogFile, JSON.stringify(clampTaskLogEntry(entry)) + "\n", "utf8");
105870
106062
  }
105871
106063
  async function appendTaskLog(paths, entry) {
105872
106064
  const file = paths.tasksLogFile;
@@ -105884,7 +106076,7 @@ async function appendTaskLog(paths, entry) {
105884
106076
  async function readTaskLog(paths) {
105885
106077
  let raw;
105886
106078
  try {
105887
- raw = await fs32.readFile(paths.tasksLogFile, "utf8");
106079
+ raw = await fs33.readFile(paths.tasksLogFile, "utf8");
105888
106080
  } catch (e) {
105889
106081
  if (e.code === "ENOENT") return [];
105890
106082
  throw e;
@@ -105892,10 +106084,10 @@ async function readTaskLog(paths) {
105892
106084
  const entries = [];
105893
106085
  let skipped = 0;
105894
106086
  for (const line of raw.split("\n")) {
105895
- const text3 = line.trim();
105896
- if (!text3) continue;
106087
+ const text4 = line.trim();
106088
+ if (!text4) continue;
105897
106089
  try {
105898
- const parsed = JSON.parse(text3);
106090
+ const parsed = JSON.parse(text4);
105899
106091
  if (!isTaskLogEntry(parsed)) {
105900
106092
  skipped += 1;
105901
106093
  continue;
@@ -105962,9 +106154,9 @@ function emptyProgress(runId, totalTasks, accountConcurrency, sectionConcurrency
105962
106154
  };
105963
106155
  }
105964
106156
  async function tryAcquireLock(paths) {
105965
- await fs32.mkdir(paths.stateDir, { recursive: true });
106157
+ await fs33.mkdir(paths.stateDir, { recursive: true });
105966
106158
  try {
105967
- const handle = await fs32.open(paths.lockFile, "wx");
106159
+ const handle = await fs33.open(paths.lockFile, "wx");
105968
106160
  await handle.writeFile(`${process.pid}@${(/* @__PURE__ */ new Date()).toISOString()}`);
105969
106161
  await handle.close();
105970
106162
  return true;
@@ -105974,7 +106166,7 @@ async function tryAcquireLock(paths) {
105974
106166
  }
105975
106167
  }
105976
106168
  async function releaseLock(paths) {
105977
- await fs32.rm(paths.lockFile, { force: true }).catch(() => void 0);
106169
+ await fs33.rm(paths.lockFile, { force: true }).catch(() => void 0);
105978
106170
  }
105979
106171
  var BATCH_SCHEMA_VERSION, MAX_TASK_LOG_ERROR_CHARS, TASK_LOG_STATES, taskLogAppendQueue;
105980
106172
  var init_batch_manifest = __esm({
@@ -105996,8 +106188,8 @@ var init_batch_manifest = __esm({
105996
106188
 
105997
106189
  // src/utils/batch-runner.ts
105998
106190
  import { performance as performance2 } from "perf_hooks";
105999
- import * as path38 from "path";
106000
- import * as fs33 from "fs/promises";
106191
+ import * as path39 from "path";
106192
+ import * as fs34 from "fs/promises";
106001
106193
  async function runPool(items3, concurrencyRef, worker, signal) {
106002
106194
  let cursor = 0;
106003
106195
  const launch = () => {
@@ -106136,7 +106328,7 @@ async function runBatch(opts) {
106136
106328
  }
106137
106329
  const inner = {
106138
106330
  ...emptyProgress(
106139
- opts.paths.runDir.split(path38.sep).pop() ?? "run",
106331
+ opts.paths.runDir.split(path39.sep).pop() ?? "run",
106140
106332
  allTasks.length,
106141
106333
  opts.accountConcurrency,
106142
106334
  opts.sectionConcurrency
@@ -106261,7 +106453,7 @@ async function runBatch(opts) {
106261
106453
  signal: aborterToken.signal
106262
106454
  });
106263
106455
  await writer({
106264
- snapshotDir: path38.join(opts.paths.resultsDir, sanitizeAccountSegment(task.accountId)),
106456
+ snapshotDir: path39.join(opts.paths.resultsDir, sanitizeAccountSegment(task.accountId)),
106265
106457
  section: task.section,
106266
106458
  accountId: task.accountId,
106267
106459
  dateRange: result.dateRange,
@@ -106278,6 +106470,14 @@ async function runBatch(opts) {
106278
106470
  } catch (raw) {
106279
106471
  const err = raw;
106280
106472
  const durationMs = performance2.now() - t0;
106473
+ if (raw instanceof AbortRunError && raw.status !== 401 && aborterToken.signal.aborted) {
106474
+ await recordTaskTransition(opts.paths, inner, task, "failed_retryable", {
106475
+ attempts: raw.attempts,
106476
+ error: raw.message,
106477
+ durationMs
106478
+ });
106479
+ return;
106480
+ }
106281
106481
  if (raw instanceof AbortRunError) {
106282
106482
  tokenInvalidated = (raw.status ?? 0) === 401;
106283
106483
  await recordTaskTransition(opts.paths, inner, task, "failed_permanent", {
@@ -106350,7 +106550,7 @@ async function runBatch(opts) {
106350
106550
  };
106351
106551
  }
106352
106552
  async function writeTaskError(paths, errorsDir, task, err, cls) {
106353
- const file = path38.join(errorsDir, `${sanitizeSection(task.section)}.error.json`);
106553
+ const file = path39.join(errorsDir, `${sanitizeSection(task.section)}.error.json`);
106354
106554
  const payload = {
106355
106555
  schemaVersion: 1,
106356
106556
  taskId: task.id,
@@ -106396,10 +106596,10 @@ async function persistRunMetadata(input) {
106396
106596
  accountsTotal: input.accounts.length,
106397
106597
  invocation: input.invocation
106398
106598
  };
106399
- await fs33.mkdir(paths.runDir, { recursive: true });
106400
- await fs33.mkdir(paths.stateDir, { recursive: true });
106401
- await fs33.mkdir(paths.resultsDir, { recursive: true });
106402
- await fs33.mkdir(paths.errorsDir, { recursive: true });
106599
+ await fs34.mkdir(paths.runDir, { recursive: true });
106600
+ await fs34.mkdir(paths.stateDir, { recursive: true });
106601
+ await fs34.mkdir(paths.resultsDir, { recursive: true });
106602
+ await fs34.mkdir(paths.errorsDir, { recursive: true });
106403
106603
  await writeRunManifest(paths, manifest);
106404
106604
  await writeAccounts(paths, input.accounts);
106405
106605
  return paths;
@@ -106462,7 +106662,7 @@ __export(google_analysis_batch_exports, {
106462
106662
  parseAccountIds: () => parseAccountIds,
106463
106663
  registerGoogleAnalysisBatchCommands: () => registerGoogleAnalysisBatchCommands
106464
106664
  });
106465
- import * as path39 from "path";
106665
+ import * as path40 from "path";
106466
106666
  import { performance as performance3 } from "perf_hooks";
106467
106667
  function parseSections(input) {
106468
106668
  if (!input || !input.trim()) return DEFAULT_SECTIONS;
@@ -106997,7 +107197,7 @@ var init_google_analysis_batch = __esm({
106997
107197
  });
106998
107198
 
106999
107199
  // src/commands/google-analysis/register-cli.ts
107000
- import * as path40 from "path";
107200
+ import * as path41 from "path";
107001
107201
  import { performance as performance4 } from "perf_hooks";
107002
107202
  import { Command } from "commander";
107003
107203
  function normalizeAnalysisDateOpts(opts) {
@@ -107135,7 +107335,7 @@ async function runAllSections(opts) {
107135
107335
  }
107136
107336
  const succeeded = results.filter((r) => r.ok).length;
107137
107337
  const failed = results.length - succeeded;
107138
- const absoluteSnapshotDir = path40.resolve(opts.jsonOut);
107338
+ const absoluteSnapshotDir = path41.resolve(opts.jsonOut);
107139
107339
  const summary = {
107140
107340
  kind: "siluzan-tso-google-analysis-snapshot-batch",
107141
107341
  absoluteSnapshotDir,
@@ -107332,7 +107532,7 @@ ${fixHint}
107332
107532
  }
107333
107533
  function registerGoogleAnalysisCommands(program2) {
107334
107534
  const root = program2.command("google-analysis").description(
107335
- "Google \u8D26\u6237\u5206\u6790\uFF1A\u6279\u91CF\u62C9\u53D6\u4E00\u4E2A\u6216\u591A\u4E2A\u7EF4\u5EA6\uFF08\u9ED8\u8BA4\uFF09\uFF0C\u6216\u7531 render \u751F\u6210\u5468\u671F HTML / okki-render \u751F\u6210 OKKI \u5468\u62A5 xlsx"
107535
+ "Google \u8D26\u6237\u5206\u6790\uFF1A\u6279\u91CF\u62C9\u53D6\u4E00\u4E2A\u6216\u591A\u4E2A\u7EF4\u5EA6\uFF08\u9ED8\u8BA4\uFF09\uFF0C\u6216\u7531 render \u751F\u6210\u5468\u671F HTML / okki-render \u751F\u6210 OKKI \u5468\u62A5 xlsx / demand-gen-render \u751F\u6210 Demand Gen \u6C47\u603B HTML"
107336
107536
  );
107337
107537
  root.addCommand(registerRunCommand(), { isDefault: true });
107338
107538
  root.command("render").description(
@@ -107361,6 +107561,18 @@ function registerGoogleAnalysisCommands(program2) {
107361
107561
  lang: opts.lang
107362
107562
  });
107363
107563
  });
107564
+ root.command("demand-gen-render").description(
107565
+ "\u6839\u636E Agent \u64B0\u5199\u7684 Demand Gen \u6C47\u603B JSON \u751F\u6210 8 \u8282 HTML\uFF08\u4E0D\u5408\u5E76\u5FEB\u7167\uFF1BExcel \u4E0D\u8D70\u672C\u547D\u4EE4\uFF09"
107566
+ ).requiredOption("--data <file>", "Agent \u4EA7\u51FA\u7684 demand-gen-analysis-report.json").option("--out <file>", "\u8F93\u51FA HTML \u8DEF\u5F84\uFF08\u9ED8\u8BA4\u540C --data \u76EE\u5F55\uFF09").option("--lang <lang>", "\u7EC8\u7A3F\u8BED\u8A00\uFF1Azh \u6216 en\u3002\u8986\u76D6 JSON meta.lang").action(async (opts) => {
107567
+ try {
107568
+ await runDemandGenRender({ dataFile: opts.data, out: opts.out, lang: opts.lang });
107569
+ } catch (err) {
107570
+ console.error(`
107571
+ \u274C ${err instanceof Error ? err.message : String(err)}
107572
+ `);
107573
+ process.exit(1);
107574
+ }
107575
+ });
107364
107576
  }
107365
107577
  var init_register_cli = __esm({
107366
107578
  "src/commands/google-analysis/register-cli.ts"() {
@@ -107372,6 +107584,7 @@ var init_register_cli = __esm({
107372
107584
  init_http_retry();
107373
107585
  init_sections();
107374
107586
  init_fetch();
107587
+ init_demand_gen_render();
107375
107588
  init_okki_render_report();
107376
107589
  init_render_report();
107377
107590
  }
@@ -107404,9 +107617,9 @@ var init_google_analysis3 = __esm({
107404
107617
  // src/index.ts
107405
107618
  init_dist();
107406
107619
  init_dist();
107407
- import * as fs44 from "fs";
107408
- import * as path55 from "path";
107409
- import { fileURLToPath as fileURLToPath15 } from "url";
107620
+ import * as fs45 from "fs";
107621
+ import * as path56 from "path";
107622
+ import { fileURLToPath as fileURLToPath16 } from "url";
107410
107623
  import { Command as Command6 } from "commander";
107411
107624
 
107412
107625
  // src/commands/login/urls.ts
@@ -107895,8 +108108,8 @@ function deriveWebUrl(apiBaseUrl) {
107895
108108
  }
107896
108109
  var TSO_UMI_ROUTE_PREFIX = "/v3umijs/tso";
107897
108110
  function buildTsoPageWebUrl(webUrl, tsoSubRoute, extraQuery) {
107898
- const path56 = tsoSubRoute.replace(/^\/+/, "");
107899
- const umiPath = `${TSO_UMI_ROUTE_PREFIX}/${path56}`;
108111
+ const path57 = tsoSubRoute.replace(/^\/+/, "");
108112
+ const umiPath = `${TSO_UMI_ROUTE_PREFIX}/${path57}`;
107900
108113
  const q = new URLSearchParams({ tso: umiPath });
107901
108114
  if (extraQuery) {
107902
108115
  for (const [key, value] of Object.entries(extraQuery)) {
@@ -107904,7 +108117,7 @@ function buildTsoPageWebUrl(webUrl, tsoSubRoute, extraQuery) {
107904
108117
  if (v) q.set(key, v);
107905
108118
  }
107906
108119
  }
107907
- return `${webUrl.replace(/\/+$/, "")}/v3/foreign_trade/tso/${path56}?${q.toString()}`;
108120
+ return `${webUrl.replace(/\/+$/, "")}/v3/foreign_trade/tso/${path57}?${q.toString()}`;
107908
108121
  }
107909
108122
  function cmdConfigShow() {
107910
108123
  const shared = readSharedConfig();
@@ -114793,27 +115006,27 @@ function validateCalloutProperties(prefix, rec, errors, _warnings, lengthViolati
114793
115006
  );
114794
115007
  return;
114795
115008
  }
114796
- const text3 = raw["Text"];
114797
- if (typeof text3 !== "string" || !text3.trim()) {
115009
+ const text4 = raw["Text"];
115010
+ if (typeof text4 !== "string" || !text4.trim()) {
114798
115011
  pushErr(
114799
115012
  errors,
114800
115013
  `${prefix}.Properties.Text \u4E0D\u80FD\u4E3A\u7A7A\uFF08CALLOUT \u5FC5\u586B\uFF0C\u540E\u7AEF CreateCalloutFeedItem \u8BFB\u53D6 Properties["Text"]\uFF09`
114801
115014
  );
114802
115015
  return;
114803
115016
  }
114804
- if (text3.length > CALLOUT_TEXT_MAX_LEN) {
115017
+ if (text4.length > CALLOUT_TEXT_MAX_LEN) {
114805
115018
  pushLengthViolation(lengthViolations, {
114806
115019
  path: `${prefix}.Properties.Text`,
114807
115020
  field: "Text",
114808
115021
  kind: "callout_text",
114809
115022
  limit: CALLOUT_TEXT_MAX_LEN,
114810
- actual: text3.length,
115023
+ actual: text4.length,
114811
115024
  countMode: "ascii",
114812
- text: text3
115025
+ text: text4
114813
115026
  });
114814
115027
  pushErr(
114815
115028
  errors,
114816
- `${prefix}.Properties.Text \u8D85\u8FC7 ${CALLOUT_TEXT_MAX_LEN} \u5B57\u7B26\uFF08\u5F53\u524D ${text3.length}\uFF0CGoogle \u786C\u7EA6\u675F\uFF09\uFF1A"${text3}"`
115029
+ `${prefix}.Properties.Text \u8D85\u8FC7 ${CALLOUT_TEXT_MAX_LEN} \u5B57\u7B26\uFF08\u5F53\u524D ${text4.length}\uFF0CGoogle \u786C\u7EA6\u675F\uFF09\uFF1A"${text4}"`
114817
115030
  );
114818
115031
  }
114819
115032
  }
@@ -115127,8 +115340,8 @@ function judgeBudgetAfterFailedPut(input) {
115127
115340
  }
115128
115341
  return { kind: "unchanged" };
115129
115342
  }
115130
- function coreKeyword(text3) {
115131
- const t = text3.trim();
115343
+ function coreKeyword(text4) {
115344
+ const t = text4.trim();
115132
115345
  if (t.length >= 2 && (t.startsWith('"') && t.endsWith('"') || t.startsWith("[") && t.endsWith("]"))) {
115133
115346
  return t.slice(1, -1).trim();
115134
115347
  }
@@ -115171,8 +115384,8 @@ function summarizeNegativeKeywordCreate(requested, response, listItems) {
115171
115384
  const pools = listItems == null ? responseRecords : [...responseRecords, ...listItems];
115172
115385
  const matched = [];
115173
115386
  const pending = [];
115174
- for (const text3 of requested) {
115175
- const core = coreKeyword(text3);
115387
+ for (const text4 of requested) {
115388
+ const core = coreKeyword(text4);
115176
115389
  const hit = pools.find((item) => {
115177
115390
  const cores = [
115178
115391
  ...collectKeywordCores(item["keywordText"]),
@@ -115182,11 +115395,11 @@ function summarizeNegativeKeywordCreate(requested, response, listItems) {
115182
115395
  return cores.includes(core);
115183
115396
  });
115184
115397
  if (!hit) {
115185
- pending.push(text3);
115398
+ pending.push(text4);
115186
115399
  continue;
115187
115400
  }
115188
115401
  const idRaw = hit["id"] ?? hit["Id"];
115189
- matched.push({ text: text3, id: typeof idRaw === "string" ? idRaw : void 0 });
115402
+ matched.push({ text: text4, id: typeof idRaw === "string" ? idRaw : void 0 });
115190
115403
  }
115191
115404
  let verification;
115192
115405
  if (requested.length > 0 && matched.length === requested.length) verification = "verified";
@@ -115298,10 +115511,10 @@ function firstKeywordTextFromRecord(k) {
115298
115511
  return "";
115299
115512
  }
115300
115513
  function negativeKeywordWriteBody(row) {
115301
- const text3 = firstKeywordTextFromRecord(row);
115514
+ const text4 = firstKeywordTextFromRecord(row);
115302
115515
  const body = {
115303
115516
  id: row["id"],
115304
- keywordText: text3 ? [text3] : [],
115517
+ keywordText: text4 ? [text4] : [],
115305
115518
  matchTypeV2: row["matchTypeV2"],
115306
115519
  negativeLevel: row["negativeLevel"]
115307
115520
  };
@@ -115934,8 +116147,8 @@ async function runAdNegativeKeywordDelete(opts) {
115934
116147
 
115935
116148
  // src/commands/ad/campaign-keywords.ts
115936
116149
  var GOOGLE_KEYWORD_MAX_CORE_LENGTH = 80;
115937
- function collapseDuplicateSpacesInKeywordText(text3) {
115938
- return text3.replace(/\s{2,}/g, " ");
116150
+ function collapseDuplicateSpacesInKeywordText(text4) {
116151
+ return text4.replace(/\s{2,}/g, " ");
115939
116152
  }
115940
116153
  var VALID_CORE_REGEX = /^[\p{L}\p{N}\s.\-]+$/u;
115941
116154
  function matchTypeV2ToUi(raw) {
@@ -115960,8 +116173,8 @@ function matchTypeUiToV2(ui) {
115960
116173
  }
115961
116174
  }
115962
116175
  }
115963
- function inferMatchTypeFromDisplayText(text3) {
115964
- const t = text3.trim();
116176
+ function inferMatchTypeFromDisplayText(text4) {
116177
+ const t = text4.trim();
115965
116178
  if (t.length >= 2 && t.startsWith('"') && t.endsWith('"')) return "Phrase";
115966
116179
  if (t.length >= 2 && t.startsWith("[") && t.endsWith("]")) return "Exact";
115967
116180
  return "Broad";
@@ -116002,7 +116215,7 @@ function cloneKeywordBlockShell(block) {
116002
116215
  delete shell["matchTypeV2"];
116003
116216
  return shell;
116004
116217
  }
116005
- function splitKeywordsForBatchJobBlockIfMixed(block, path56, warnings) {
116218
+ function splitKeywordsForBatchJobBlockIfMixed(block, path57, warnings) {
116006
116219
  const declaredUi = matchTypeV2ToUi(readBlockMatchTypeRaw(block));
116007
116220
  const entries = collectKeywordEntriesFromBlock(block);
116008
116221
  if (entries.length === 0) return [block];
@@ -116021,7 +116234,7 @@ function splitKeywordsForBatchJobBlockIfMixed(block, path56, warnings) {
116021
116234
  (ui) => matchTypeUiToV2(ui)
116022
116235
  );
116023
116236
  warnings.push(
116024
- `${path56} \u542B\u591A\u79CD\u5339\u914D\u7C7B\u578B\uFF0C\u5DF2\u81EA\u52A8\u62C6\u5206\u4E3A ${groups.size} \u4E2A KeywordsForBatchJob \u5757\uFF08${labels.join("\u3001")}\uFF09`
116237
+ `${path57} \u542B\u591A\u79CD\u5339\u914D\u7C7B\u578B\uFF0C\u5DF2\u81EA\u52A8\u62C6\u5206\u4E3A ${groups.size} \u4E2A KeywordsForBatchJob \u5757\uFF08${labels.join("\u3001")}\uFF09`
116025
116238
  );
116026
116239
  const shell = cloneKeywordBlockShell(block);
116027
116240
  const splitBlocks = [];
@@ -116041,16 +116254,16 @@ function splitKeywordsForBatchJobBlockIfMixed(block, path56, warnings) {
116041
116254
  }
116042
116255
  return splitBlocks;
116043
116256
  }
116044
- function validateKeywordCore(core, path56, errors, lengthViolations) {
116257
+ function validateKeywordCore(core, path57, errors, lengthViolations) {
116045
116258
  const trimmed = core.trim();
116046
116259
  if (!trimmed) {
116047
- errors.push(`${path56} \u5173\u952E\u8BCD\u8BCD\u5E72\u4E0D\u80FD\u4E3A\u7A7A`);
116260
+ errors.push(`${path57} \u5173\u952E\u8BCD\u8BCD\u5E72\u4E0D\u80FD\u4E3A\u7A7A`);
116048
116261
  return false;
116049
116262
  }
116050
116263
  if (trimmed.length > GOOGLE_KEYWORD_MAX_CORE_LENGTH) {
116051
116264
  if (lengthViolations) {
116052
116265
  pushLengthViolation(lengthViolations, {
116053
- path: path56,
116266
+ path: path57,
116054
116267
  field: "KeywordText",
116055
116268
  kind: "keyword_core",
116056
116269
  limit: GOOGLE_KEYWORD_MAX_CORE_LENGTH,
@@ -116060,13 +116273,13 @@ function validateKeywordCore(core, path56, errors, lengthViolations) {
116060
116273
  });
116061
116274
  }
116062
116275
  errors.push(
116063
- `${path56} \u5173\u952E\u8BCD\u8BCD\u5E72\u8D85\u8FC7 ${GOOGLE_KEYWORD_MAX_CORE_LENGTH} \u5B57\u7B26\uFF08\u5F53\u524D ${trimmed.length}\uFF09\uFF1A"${trimmed}"`
116276
+ `${path57} \u5173\u952E\u8BCD\u8BCD\u5E72\u8D85\u8FC7 ${GOOGLE_KEYWORD_MAX_CORE_LENGTH} \u5B57\u7B26\uFF08\u5F53\u524D ${trimmed.length}\uFF09\uFF1A"${trimmed}"`
116064
116277
  );
116065
116278
  return false;
116066
116279
  }
116067
116280
  if (!VALID_CORE_REGEX.test(trimmed)) {
116068
116281
  errors.push(
116069
- `${path56} \u542B Google \u4E0D\u5141\u8BB8\u7684\u5B57\u7B26\uFF08\u8BCD\u5E72\u4EC5\u5141\u8BB8\u5B57\u6BCD/\u6570\u5B57/\u7A7A\u683C/\u8FDE\u5B57\u7B26/\u53E5\u70B9\uFF09\uFF1A"${trimmed.slice(0, 40)}${trimmed.length > 40 ? "\u2026" : ""}"`
116282
+ `${path57} \u542B Google \u4E0D\u5141\u8BB8\u7684\u5B57\u7B26\uFF08\u8BCD\u5E72\u4EC5\u5141\u8BB8\u5B57\u6BCD/\u6570\u5B57/\u7A7A\u683C/\u8FDE\u5B57\u7B26/\u53E5\u70B9\uFF09\uFF1A"${trimmed.slice(0, 40)}${trimmed.length > 40 ? "\u2026" : ""}"`
116070
116283
  );
116071
116284
  return false;
116072
116285
  }
@@ -116123,10 +116336,10 @@ function canonicalizeKeywordBatchBlock(block, resolvedMatchV2, normalizedTexts,
116123
116336
  }
116124
116337
  }
116125
116338
  }
116126
- function pushKeywordAutoFixWarning(warnings, path56, fieldLabel, trimmedRaw, formatted, declaredUi, beforeUi, matchType, inferredMatchType) {
116339
+ function pushKeywordAutoFixWarning(warnings, path57, fieldLabel, trimmedRaw, formatted, declaredUi, beforeUi, matchType, inferredMatchType) {
116127
116340
  if (inferredMatchType) {
116128
116341
  warnings.push(
116129
- `${path56}.${fieldLabel} \u672A\u6307\u5B9A MatchTypeV2\uFF0C\u5DF2\u6309\u8BCD\u9762\u63A8\u65AD\u4E3A ${matchTypeUiToV2(matchType)}`
116342
+ `${path57}.${fieldLabel} \u672A\u6307\u5B9A MatchTypeV2\uFF0C\u5DF2\u6309\u8BCD\u9762\u63A8\u65AD\u4E3A ${matchTypeUiToV2(matchType)}`
116130
116343
  );
116131
116344
  return false;
116132
116345
  }
@@ -116135,16 +116348,16 @@ function pushKeywordAutoFixWarning(warnings, path56, fieldLabel, trimmedRaw, for
116135
116348
  }
116136
116349
  if (declaredUi && beforeUi !== declaredUi) {
116137
116350
  warnings.push(
116138
- `${path56}.${fieldLabel} MatchTypeV2=${matchTypeUiToV2(declaredUi)} \u4E0E\u8BCD\u9762\u4E0D\u4E00\u81F4\uFF0C\u5DF2\u81EA\u52A8\u4FEE\u590D\u4E3A\uFF1A${formatted}`
116351
+ `${path57}.${fieldLabel} MatchTypeV2=${matchTypeUiToV2(declaredUi)} \u4E0E\u8BCD\u9762\u4E0D\u4E00\u81F4\uFF0C\u5DF2\u81EA\u52A8\u4FEE\u590D\u4E3A\uFF1A${formatted}`
116139
116352
  );
116140
116353
  return false;
116141
116354
  }
116142
116355
  if (formatted !== trimmedRaw) {
116143
- warnings.push(`${path56}.${fieldLabel} \u5DF2\u81EA\u52A8\u4FEE\u590D\u8BCD\u9762\uFF1A${trimmedRaw} \u2192 ${formatted}`);
116356
+ warnings.push(`${path57}.${fieldLabel} \u5DF2\u81EA\u52A8\u4FEE\u590D\u8BCD\u9762\uFF1A${trimmedRaw} \u2192 ${formatted}`);
116144
116357
  }
116145
116358
  return false;
116146
116359
  }
116147
- function normalizeKeywordTextList(texts, matchTypeRaw, path56, fieldLabel, errors, warnings, lengthViolations) {
116360
+ function normalizeKeywordTextList(texts, matchTypeRaw, path57, fieldLabel, errors, warnings, lengthViolations) {
116148
116361
  const declaredUi = matchTypeV2ToUi(matchTypeRaw);
116149
116362
  const normalized = [];
116150
116363
  const seen = /* @__PURE__ */ new Set();
@@ -116153,7 +116366,7 @@ function normalizeKeywordTextList(texts, matchTypeRaw, path56, fieldLabel, error
116153
116366
  for (let k = 0; k < texts.length; k++) {
116154
116367
  const raw = texts[k];
116155
116368
  if (typeof raw !== "string" || !raw.trim()) {
116156
- errors.push(`${path56}.${fieldLabel}[${k}] \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`);
116369
+ errors.push(`${path57}.${fieldLabel}[${k}] \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`);
116157
116370
  continue;
116158
116371
  }
116159
116372
  const trimmedRaw = collapseDuplicateSpacesInKeywordText(raw.trim());
@@ -116164,7 +116377,7 @@ function normalizeKeywordTextList(texts, matchTypeRaw, path56, fieldLabel, error
116164
116377
  );
116165
116378
  if (pushKeywordAutoFixWarning(
116166
116379
  warnings,
116167
- path56,
116380
+ path57,
116168
116381
  fieldLabel,
116169
116382
  trimmedRaw,
116170
116383
  formatted,
@@ -116176,11 +116389,11 @@ function normalizeKeywordTextList(texts, matchTypeRaw, path56, fieldLabel, error
116176
116389
  bareWrapped++;
116177
116390
  }
116178
116391
  const core = unwrapKeywordDisplayTextForEdit(formatted);
116179
- if (!validateKeywordCore(core, `${path56}.${fieldLabel}[${k}]`, errors, lengthViolations))
116392
+ if (!validateKeywordCore(core, `${path57}.${fieldLabel}[${k}]`, errors, lengthViolations))
116180
116393
  continue;
116181
116394
  const dedupeKey = `${matchTypeUiToV2(matchType)}:${core.toLowerCase()}`;
116182
116395
  if (seen.has(dedupeKey)) {
116183
- warnings.push(`${path56}.${fieldLabel}[${k}] \u4E0E\u540C\u7EC4\u91CD\u590D\uFF0C\u5DF2\u8DF3\u8FC7\uFF1A${formatted}`);
116396
+ warnings.push(`${path57}.${fieldLabel}[${k}] \u4E0E\u540C\u7EC4\u91CD\u590D\uFF0C\u5DF2\u8DF3\u8FC7\uFF1A${formatted}`);
116184
116397
  continue;
116185
116398
  }
116186
116399
  seen.add(dedupeKey);
@@ -116189,17 +116402,17 @@ function normalizeKeywordTextList(texts, matchTypeRaw, path56, fieldLabel, error
116189
116402
  }
116190
116403
  if (bareWrapped > 0 && declaredUi) {
116191
116404
  warnings.push(
116192
- `${path56}.${fieldLabel}\uFF1A${bareWrapped} \u4E2A\u88F8\u8BCD\u5DF2\u6309 MatchTypeV2=${matchTypeUiToV2(declaredUi)} \u81EA\u52A8\u4FEE\u590D\uFF08\u8865\u5168${declaredUi === "Exact" ? " [ ]" : "\u5F15\u53F7"}\uFF0C\u9884\u671F\u884C\u4E3A\uFF09`
116405
+ `${path57}.${fieldLabel}\uFF1A${bareWrapped} \u4E2A\u88F8\u8BCD\u5DF2\u6309 MatchTypeV2=${matchTypeUiToV2(declaredUi)} \u81EA\u52A8\u4FEE\u590D\uFF08\u8865\u5168${declaredUi === "Exact" ? " [ ]" : "\u5F15\u53F7"}\uFF0C\u9884\u671F\u884C\u4E3A\uFF09`
116193
116406
  );
116194
116407
  }
116195
116408
  return { normalized, resolvedUi };
116196
116409
  }
116197
- function normalizeKeywordsForBatchJobBlock(block, path56, errors, warnings, lengthViolations) {
116410
+ function normalizeKeywordsForBatchJobBlock(block, path57, errors, warnings, lengthViolations) {
116198
116411
  const matchTypeRaw = readBlockMatchTypeRaw(block);
116199
116412
  const declaredUi = matchTypeV2ToUi(matchTypeRaw);
116200
116413
  if (matchTypeRaw !== void 0 && declaredUi === null) {
116201
116414
  errors.push(
116202
- `${path56}.MatchTypeV2 \u65E0\u6548\uFF08${String(matchTypeRaw)}\uFF09\uFF0C\u5408\u6CD5\u503C\uFF1ABROAD | PHRASE | EXACT`
116415
+ `${path57}.MatchTypeV2 \u65E0\u6548\uFF08${String(matchTypeRaw)}\uFF09\uFF0C\u5408\u6CD5\u503C\uFF1ABROAD | PHRASE | EXACT`
116203
116416
  );
116204
116417
  return;
116205
116418
  }
@@ -116214,7 +116427,7 @@ function normalizeKeywordsForBatchJobBlock(block, path56, errors, warnings, leng
116214
116427
  const result = normalizeKeywordTextList(
116215
116428
  texts,
116216
116429
  matchTypeRaw,
116217
- path56,
116430
+ path57,
116218
116431
  "KeywordText",
116219
116432
  errors,
116220
116433
  warnings,
@@ -116223,7 +116436,7 @@ function normalizeKeywordsForBatchJobBlock(block, path56, errors, warnings, leng
116223
116436
  normalizedTexts = result.normalized;
116224
116437
  if (result.resolvedUi) resolvedUi = result.resolvedUi;
116225
116438
  if (normalizedTexts.length === 0 && texts.length > 0) {
116226
- errors.push(`${path56}.KeywordText \u7ECF\u6821\u9A8C\u540E\u65E0\u6709\u6548\u5173\u952E\u8BCD\uFF0C\u8BF7\u4FEE\u6B63\u8BCD\u9762\u6216 MatchTypeV2`);
116439
+ errors.push(`${path57}.KeywordText \u7ECF\u6821\u9A8C\u540E\u65E0\u6709\u6548\u5173\u952E\u8BCD\uFF0C\u8BF7\u4FEE\u6B63\u8BCD\u9762\u6216 MatchTypeV2`);
116227
116440
  }
116228
116441
  }
116229
116442
  if (hasItems && items3) {
@@ -116231,12 +116444,12 @@ function normalizeKeywordsForBatchJobBlock(block, path56, errors, warnings, leng
116231
116444
  for (let k = 0; k < items3.length; k++) {
116232
116445
  const item = items3[k];
116233
116446
  if (!item || typeof item !== "object") {
116234
- errors.push(`${path56}.Items[${k}] \u5FC5\u987B\u662F\u5BF9\u8C61`);
116447
+ errors.push(`${path57}.Items[${k}] \u5FC5\u987B\u662F\u5BF9\u8C61`);
116235
116448
  continue;
116236
116449
  }
116237
116450
  const raw = readItemText(item);
116238
116451
  if (raw === null || !raw.trim()) {
116239
- errors.push(`${path56}.Items[${k}].Text \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`);
116452
+ errors.push(`${path57}.Items[${k}].Text \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`);
116240
116453
  continue;
116241
116454
  }
116242
116455
  const trimmedRaw = collapseDuplicateSpacesInKeywordText(raw.trim());
@@ -116247,7 +116460,7 @@ function normalizeKeywordsForBatchJobBlock(block, path56, errors, warnings, leng
116247
116460
  );
116248
116461
  if (pushKeywordAutoFixWarning(
116249
116462
  warnings,
116250
- path56,
116463
+ path57,
116251
116464
  `Items[${k}].Text`,
116252
116465
  trimmedRaw,
116253
116466
  formatted,
@@ -116256,14 +116469,14 @@ function normalizeKeywordsForBatchJobBlock(block, path56, errors, warnings, leng
116256
116469
  matchType,
116257
116470
  inferredMatchType
116258
116471
  )) {
116259
- warnings.push(`${path56}.Items[${k}].Text \u5DF2\u6309\u5757\u7EA7\u5339\u914D\u7C7B\u578B\u81EA\u52A8\u4FEE\u590D\u4E3A\uFF1A${formatted}`);
116472
+ warnings.push(`${path57}.Items[${k}].Text \u5DF2\u6309\u5757\u7EA7\u5339\u914D\u7C7B\u578B\u81EA\u52A8\u4FEE\u590D\u4E3A\uFF1A${formatted}`);
116260
116473
  }
116261
116474
  const core = unwrapKeywordDisplayTextForEdit(formatted);
116262
- if (!validateKeywordCore(core, `${path56}.Items[${k}].Text`, errors, lengthViolations))
116475
+ if (!validateKeywordCore(core, `${path57}.Items[${k}].Text`, errors, lengthViolations))
116263
116476
  continue;
116264
116477
  const dedupeKey = `${matchTypeUiToV2(matchType)}:${core.toLowerCase()}`;
116265
116478
  if (seen.has(dedupeKey)) {
116266
- warnings.push(`${path56}.Items[${k}].Text \u4E0E\u540C\u7EC4\u91CD\u590D\uFF0C\u5DF2\u8DF3\u8FC7\uFF1A${formatted}`);
116479
+ warnings.push(`${path57}.Items[${k}].Text \u4E0E\u540C\u7EC4\u91CD\u590D\uFF0C\u5DF2\u8DF3\u8FC7\uFF1A${formatted}`);
116267
116480
  continue;
116268
116481
  }
116269
116482
  seen.add(dedupeKey);
@@ -116409,16 +116622,16 @@ function warnIfNegativeKeywordsInPositiveKeywords(campaign, warnings) {
116409
116622
  const raw = texts[ki];
116410
116623
  if (typeof raw !== "string" || !raw.trim()) continue;
116411
116624
  const core = normalizeKeywordCoreForNegativeCheck(raw);
116412
- const path56 = `campaign.AdGroupsForBatchJob[${gi}].KeywordsForBatchJob[${bi}].KeywordText[${ki}]`;
116625
+ const path57 = `campaign.AdGroupsForBatchJob[${gi}].KeywordsForBatchJob[${bi}].KeywordText[${ki}]`;
116413
116626
  if (plannedNegCores.has(core)) {
116414
116627
  warnings.push(
116415
- `${path56} \u8BCD\u9762\u300C${raw}\u300D\u5DF2\u51FA\u73B0\u5728 campaign.NegativeKeywordsForBatchJob\uFF0C\u4E0D\u5E94\u91CD\u590D\u5199\u5165\u6B63\u5411 KeywordsForBatchJob\uFF1B\u5426\u8BCD\u53EA\u653E NegativeKeywordsForBatchJob`
116628
+ `${path57} \u8BCD\u9762\u300C${raw}\u300D\u5DF2\u51FA\u73B0\u5728 campaign.NegativeKeywordsForBatchJob\uFF0C\u4E0D\u5E94\u91CD\u590D\u5199\u5165\u6B63\u5411 KeywordsForBatchJob\uFF1B\u5426\u8BCD\u53EA\u653E NegativeKeywordsForBatchJob`
116416
116629
  );
116417
116630
  continue;
116418
116631
  }
116419
116632
  if (looksLikeStandaloneNegativeKeyword(core)) {
116420
116633
  warnings.push(
116421
- `${path56} \u8BCD\u9762\u300C${raw}\u300D\u7591\u4F3C\u5426\u5B9A\u5173\u952E\u8BCD\uFF08\u5E38\u89C1\u5426\u8BCD\u8BCD\u6839\uFF09\uFF0C\u5E94\u5199\u5165 campaign.NegativeKeywordsForBatchJob\uFF08MatchTypeV2: BROAD\uFF09\uFF0C\u52FF\u653E\u5165 KeywordsForBatchJob`
116634
+ `${path57} \u8BCD\u9762\u300C${raw}\u300D\u7591\u4F3C\u5426\u5B9A\u5173\u952E\u8BCD\uFF08\u5E38\u89C1\u5426\u8BCD\u8BCD\u6839\uFF09\uFF0C\u5E94\u5199\u5165 campaign.NegativeKeywordsForBatchJob\uFF08MatchTypeV2: BROAD\uFF09\uFF0C\u52FF\u653E\u5165 KeywordsForBatchJob`
116422
116635
  );
116423
116636
  }
116424
116637
  }
@@ -116499,9 +116712,9 @@ var POLICY_RISK_RULES = [
116499
116712
  { re: /\b(alcohol|whisk(e)?y|vodka|liquor)\b/i, label: "\u9152\u7CBE\uFF08\u5730\u57DF\u9650\u5236\uFF09" },
116500
116713
  { re: /(最好|第一|国家级|绝对|100%)/, label: "\u5E7F\u544A\u6CD5\u7EDD\u5BF9\u5316\u7528\u8BED" }
116501
116714
  ];
116502
- function matchRisk(text3) {
116715
+ function matchRisk(text4) {
116503
116716
  for (const r of POLICY_RISK_RULES) {
116504
- if (r.re.test(text3)) return r.label;
116717
+ if (r.re.test(text4)) return r.label;
116505
116718
  }
116506
116719
  return void 0;
116507
116720
  }
@@ -116524,10 +116737,10 @@ function warnPolicyRiskTerms(campaign, warnings) {
116524
116737
  const groups = campaign["AdGroupsForBatchJob"];
116525
116738
  if (!Array.isArray(groups)) return;
116526
116739
  const hitsByLabel = /* @__PURE__ */ new Map();
116527
- const add = (label2, text3) => {
116740
+ const add = (label2, text4) => {
116528
116741
  let set = hitsByLabel.get(label2);
116529
116742
  if (!set) hitsByLabel.set(label2, set = /* @__PURE__ */ new Set());
116530
- set.add(text3.trim());
116743
+ set.add(text4.trim());
116531
116744
  };
116532
116745
  for (const g of groups) {
116533
116746
  const gr = g;
@@ -116563,8 +116776,8 @@ function warnPolicyRiskTerms(campaign, warnings) {
116563
116776
  }
116564
116777
 
116565
116778
  // src/commands/ad/campaign-rsa.ts
116566
- function normalizeRsaAssetKey(text3) {
116567
- return text3.trim().replace(/\s+/g, " ").toLowerCase();
116779
+ function normalizeRsaAssetKey(text4) {
116780
+ return text4.trim().replace(/\s+/g, " ").toLowerCase();
116568
116781
  }
116569
116782
  function listRsaHeadlines(ad) {
116570
116783
  const parts = [
@@ -116732,9 +116945,9 @@ function validateLocationsFidelity(cfg, campaign, errors) {
116732
116945
  }
116733
116946
  }
116734
116947
  }
116735
- function calcGoogleCharLength(text3) {
116948
+ function calcGoogleCharLength(text4) {
116736
116949
  let len = 0;
116737
- for (const ch of text3) {
116950
+ for (const ch of text4) {
116738
116951
  const code = ch.codePointAt(0) ?? 0;
116739
116952
  if (code >= 19968 && code <= 40959 || code >= 13312 && code <= 19903 || code >= 131072 && code <= 173791 || code >= 12288 && code <= 12351 || code >= 65280 && code <= 65519) {
116740
116953
  len += 2;
@@ -117537,8 +117750,8 @@ async function reportFailedCampaignPut(opts) {
117537
117750
  async function reportCampaignWrite(opts) {
117538
117751
  const nextQuery = `siluzan-tso ad campaigns -a ${opts.account} --json-out ./snap`;
117539
117752
  const unmatched = describeUnmatchedChecks(opts.checks);
117540
- const text3 = opts.verification === "verified" ? opts.detail : unmatched || opts.detail;
117541
- const headline = writeVerificationHeadline(opts.verification, text3);
117753
+ const text4 = opts.verification === "verified" ? opts.detail : unmatched || opts.detail;
117754
+ const headline = writeVerificationHeadline(opts.verification, text4);
117542
117755
  if (opts.verification !== "verified") {
117543
117756
  console.error(`
117544
117757
  ${headline}
@@ -120214,14 +120427,14 @@ function buildExtensionRemediateCommandLine(opts) {
120214
120427
  const campaignFlag = level === "Campaign" ? `--campaign-id ${campaignId}` : "";
120215
120428
  const base2 = ["siluzan-tso", "ad", "extension"];
120216
120429
  if (type === "SITELINK") {
120217
- const text3 = pickString(props["Text"], props["LinkText"]);
120430
+ const text4 = pickString(props["Text"], props["LinkText"]);
120218
120431
  const url = pickString(props["DestinationUrl"]);
120219
- if (!text3 || !url) return null;
120432
+ if (!text4 || !url) return null;
120220
120433
  const parts = [
120221
120434
  ...base2,
120222
120435
  "sitelink",
120223
120436
  `-a ${accountId}`,
120224
- `--text ${shellArg(text3)}`,
120437
+ `--text ${shellArg(text4)}`,
120225
120438
  `--url ${shellArg(url)}`
120226
120439
  ];
120227
120440
  const line2 = pickString(props["Line2"], props["Description1"]);
@@ -120235,9 +120448,9 @@ function buildExtensionRemediateCommandLine(opts) {
120235
120448
  return parts.join(" ");
120236
120449
  }
120237
120450
  if (type === "CALLOUT") {
120238
- const text3 = pickString(props["Text"], props["CalloutText"]);
120239
- if (!text3) return null;
120240
- const parts = [...base2, "callout", `-a ${accountId}`, `--text ${shellArg(text3)}`, levelFlag];
120451
+ const text4 = pickString(props["Text"], props["CalloutText"]);
120452
+ if (!text4) return null;
120453
+ const parts = [...base2, "callout", `-a ${accountId}`, `--text ${shellArg(text4)}`, levelFlag];
120241
120454
  if (campaignFlag) parts.push(campaignFlag);
120242
120455
  parts.push(`--json-out ${jsonOut}`);
120243
120456
  parts.push(`--commit ${shellArg("batch-diff remediate extension")}`);
@@ -120326,7 +120539,7 @@ function buildBatchOperationSlots(cfg) {
120326
120539
  const campaign = asRecord3(cfg.campaign) ?? {};
120327
120540
  const names = Array.isArray(cfg.locations) ? cfg.locations : [];
120328
120541
  const slots = [];
120329
- const push = (kind, path56, label2) => slots.push({ index: slots.length, kind, path: path56, label: label2 });
120542
+ const push = (kind, path57, label2) => slots.push({ index: slots.length, kind, path: path57, label: label2 });
120330
120543
  push("campaign_budget", "campaign.Budget", "\u7CFB\u5217\u9884\u7B97");
120331
120544
  push("campaign", "campaign.Name", `\u7CFB\u5217\u300C${pickText(campaign, "Name", "name") || "\u2014"}\u300D`);
120332
120545
  pickArray(campaign, "targetedLocations", "TargetedLocations").forEach((loc, i) => {
@@ -120397,11 +120610,11 @@ function buildBatchOperationSlots(cfg) {
120397
120610
  return;
120398
120611
  }
120399
120612
  pickArray(block, "Items", "items").forEach((it, ii) => {
120400
- const text3 = pickText(asRecord3(it), "Text", "text");
120613
+ const text4 = pickText(asRecord3(it), "Text", "text");
120401
120614
  push(
120402
120615
  "ad_group_criterion",
120403
120616
  `${groupPath}.KeywordsForBatchJob[${bi}].Items[${ii}]`,
120404
- `\u5173\u952E\u8BCD\u300C${text3}\u300D\uFF08\u7EC4\u300C${groupName}\u300D\uFF09`
120617
+ `\u5173\u952E\u8BCD\u300C${text4}\u300D\uFF08\u7EC4\u300C${groupName}\u300D\uFF09`
120405
120618
  );
120406
120619
  });
120407
120620
  });
@@ -120434,9 +120647,9 @@ function buildSubmittedOperationSlots(cfg) {
120434
120647
  return buildBatchOperationSlots(clone);
120435
120648
  }
120436
120649
  var OP_RE = /mutate_operations\[(\d+)\]\.([a-z_]+?)_operation\.([a-z_.]+)/;
120437
- function parseBatchOperationErrors(text3) {
120650
+ function parseBatchOperationErrors(text4) {
120438
120651
  const out = [];
120439
- for (const seg of text3.split(/Processing error:\s*/).slice(1)) {
120652
+ for (const seg of text4.split(/Processing error:\s*/).slice(1)) {
120440
120653
  const m = OP_RE.exec(seg);
120441
120654
  if (!m) continue;
120442
120655
  const head = seg.slice(0, m.index);
@@ -120593,8 +120806,8 @@ function pickLiveAdForPlannedRsa(plannedHeadlines, primary, unmatchedLiveAds) {
120593
120806
  const [picked] = unmatchedLiveAds.splice(bestIdx, 1);
120594
120807
  return picked ?? null;
120595
120808
  }
120596
- function livePoolHasText(pool, text3) {
120597
- const t = text3.trim().toLowerCase();
120809
+ function livePoolHasText(pool, text4) {
120810
+ const t = text4.trim().toLowerCase();
120598
120811
  return t.length > 0 && pool.has(t);
120599
120812
  }
120600
120813
  function listPlannedRsaAssets(ad, groupPath, adIndex, adGroupName) {
@@ -120809,13 +121022,13 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
120809
121022
  for (let ki = 0; ki < texts.length; ki++) {
120810
121023
  const t = texts[ki];
120811
121024
  if (typeof t !== "string" || !t.trim()) continue;
120812
- const path56 = `${groupPath}.KeywordsForBatchJob[${bi}].KeywordText[${ki}]`;
121025
+ const path57 = `${groupPath}.KeywordsForBatchJob[${bi}].KeywordText[${ki}]`;
120813
121026
  const key = keywordKey(t, matchTypeV2);
120814
121027
  const plannedContent = `\u8BCD\u9762: ${t} | \u5339\u914D: ${matchTypeV2}`;
120815
121028
  if (groupAbsent) {
120816
121029
  pushItem(items3, {
120817
121030
  layer: "keyword",
120818
- path: path56,
121031
+ path: path57,
120819
121032
  adGroupName: groupName,
120820
121033
  plannedContent,
120821
121034
  status: "skipped",
@@ -120827,7 +121040,7 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
120827
121040
  if (!liveKwKeys.has(key)) {
120828
121041
  pushItem(items3, {
120829
121042
  layer: "keyword",
120830
- path: path56,
121043
+ path: path57,
120831
121044
  adGroupName: groupName,
120832
121045
  plannedContent,
120833
121046
  status: "missing",
@@ -120837,7 +121050,7 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
120837
121050
  } else {
120838
121051
  pushItem(items3, {
120839
121052
  layer: "keyword",
120840
- path: path56,
121053
+ path: path57,
120841
121054
  adGroupName: groupName,
120842
121055
  plannedContent,
120843
121056
  status: "ok",
@@ -120857,7 +121070,7 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
120857
121070
  for (let ai = 0; ai < ads.length; ai++) {
120858
121071
  const ad = asRecord4(ads[ai]);
120859
121072
  if (!ad) continue;
120860
- const path56 = `${groupPath}.AdsForBatchJob[${ai}]`;
121073
+ const path57 = `${groupPath}.AdsForBatchJob[${ai}]`;
120861
121074
  const primary = pickString2(ad["headlinePart1"], ad["AdTitle"]);
120862
121075
  const finalUrl = pickString2(ad["Finalurl"], ad["DestinationUrl"], ad["finalUrl"]);
120863
121076
  const rsaAssets = listPlannedRsaAssets(ad, groupPath, ai, groupName);
@@ -120866,7 +121079,7 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
120866
121079
  if (groupAbsent) {
120867
121080
  pushItem(items3, {
120868
121081
  layer: "ad",
120869
- path: path56,
121082
+ path: path57,
120870
121083
  adGroupName: groupName,
120871
121084
  adLabel,
120872
121085
  plannedContent: primary ? `RSA \u9996\u6807\u9898: ${primary}${finalUrl ? ` | \u843D\u5730\u9875: ${finalUrl}` : ""}` : `AdsForBatchJob[${ai}]\uFF08\u7F3A\u5C11 headlinePart1\uFF09`,
@@ -120895,7 +121108,7 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
120895
121108
  if (!primary) {
120896
121109
  pushItem(items3, {
120897
121110
  layer: "ad",
120898
- path: path56,
121111
+ path: path57,
120899
121112
  adGroupName: groupName,
120900
121113
  adLabel,
120901
121114
  plannedContent: `AdsForBatchJob[${ai}]\uFF08\u7F3A\u5C11 headlinePart1\uFF0C\u65E0\u6CD5\u6BD4\u5BF9\u6574\u6761 RSA\uFF09`,
@@ -120923,7 +121136,7 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
120923
121136
  const rsaFound = matchedLive != null && liveAdHasHeadline(matchedLive, primary);
120924
121137
  pushItem(items3, {
120925
121138
  layer: "ad",
120926
- path: path56,
121139
+ path: path57,
120927
121140
  adGroupName: groupName,
120928
121141
  adLabel,
120929
121142
  plannedContent: `RSA \u9996\u6807\u9898: ${primary}${finalUrl ? ` | \u843D\u5730\u9875: ${finalUrl}` : ""}`,
@@ -120991,11 +121204,11 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
120991
121204
  for (let ei = 0; ei < extBlocks.length; ei++) {
120992
121205
  const ext = asRecord4(extBlocks[ei]);
120993
121206
  const plannedContent = formatExtensionPlanned(ext);
120994
- const path56 = `campaign.ExtensionsForBatchJob[${ei}]`;
121207
+ const path57 = `campaign.ExtensionsForBatchJob[${ei}]`;
120995
121208
  if (campaignMissing) {
120996
121209
  pushItem(items3, {
120997
121210
  layer: "extension",
120998
- path: path56,
121211
+ path: path57,
120999
121212
  plannedContent,
121000
121213
  status: "skipped",
121001
121214
  liveNote: "\u7CFB\u5217\u672A\u627E\u5230\uFF0C\u8DF3\u8FC7\u9644\u52A0\u4FE1\u606F\u6BD4\u5BF9",
@@ -121007,7 +121220,7 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
121007
121220
  const remediateCommand = !found && ext && accountId && campaignId ? buildExtensionRemediateCommandLine({ accountId, campaignId, ext }) ?? void 0 : void 0;
121008
121221
  pushItem(items3, {
121009
121222
  layer: "extension",
121010
- path: path56,
121223
+ path: path57,
121011
121224
  plannedContent,
121012
121225
  status: found ? "ok" : "missing",
121013
121226
  liveNote: `\u7CFB\u5217\u7EA7\u9644\u52A0\u4FE1\u606F\u8D26\u6237\u5185 ${liveExt}/${plannedExt} \u6761`,
@@ -121034,11 +121247,11 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
121034
121247
  if (!id) continue;
121035
121248
  const displayName = locationNames[li] || pickString2(loc["locationName"], loc["name"], loc["countryOrRegion"]) || "";
121036
121249
  const plannedContent = `locationId: ${id}${displayName ? ` | \u540D\u79F0: ${displayName}` : ""}`;
121037
- const path56 = `campaign.targetedLocations[${li}]`;
121250
+ const path57 = `campaign.targetedLocations[${li}]`;
121038
121251
  if (campaignMissing) {
121039
121252
  pushItem(items3, {
121040
121253
  layer: "location",
121041
- path: path56,
121254
+ path: path57,
121042
121255
  plannedContent,
121043
121256
  status: "skipped",
121044
121257
  liveNote: "\u7CFB\u5217\u672A\u627E\u5230\uFF0C\u8DF3\u8FC7\u5730\u57DF\u6BD4\u5BF9",
@@ -121050,7 +121263,7 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
121050
121263
  const remediateCommand = !found && accountId && campaignId ? buildGeoRemediateCommandLine({ accountId, campaignId, locationId: id }) : void 0;
121051
121264
  pushItem(items3, {
121052
121265
  layer: "location",
121053
- path: path56,
121266
+ path: path57,
121054
121267
  plannedContent,
121055
121268
  status: found ? "ok" : "missing",
121056
121269
  liveNote: `\u7CFB\u5217\u5DF2\u5B9A\u5411 ${liveLocIds.size}/${plannedLocCount} \u4E2A\u5730\u57DF`,
@@ -121070,12 +121283,12 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
121070
121283
  const loc = asRecord4(plannedExcl[li]);
121071
121284
  const id = loc ? pickString2(loc["id"], loc["Id"]) : "";
121072
121285
  if (!id) continue;
121073
- const path56 = `campaign.excludedLocations[${li}]`;
121286
+ const path57 = `campaign.excludedLocations[${li}]`;
121074
121287
  const plannedContent = `\u6392\u9664 locationId: ${id}`;
121075
121288
  if (campaignMissing) {
121076
121289
  pushItem(items3, {
121077
121290
  layer: "excluded_location",
121078
- path: path56,
121291
+ path: path57,
121079
121292
  plannedContent,
121080
121293
  status: "skipped",
121081
121294
  liveNote: "\u7CFB\u5217\u672A\u627E\u5230\uFF0C\u8DF3\u8FC7\u6392\u9664\u5730\u57DF\u6BD4\u5BF9",
@@ -121086,7 +121299,7 @@ function compareCampaignCreateToLive(cfg, campaignId, live, meta) {
121086
121299
  const found = liveExclIds.has(id);
121087
121300
  pushItem(items3, {
121088
121301
  layer: "excluded_location",
121089
- path: path56,
121302
+ path: path57,
121090
121303
  plannedContent,
121091
121304
  status: found ? "ok" : "missing",
121092
121305
  liveNote: `\u7CFB\u5217\u5DF2\u6392\u9664 ${liveExclIds.size}/${plannedExclCount} \u4E2A\u5730\u57DF`,
@@ -121493,8 +121706,8 @@ function printPlanItemsByAdGroup(configFile, layer, layerItems) {
121493
121706
  }
121494
121707
  }
121495
121708
  }
121496
- function mdCell(text3) {
121497
- return text3.replace(/\r?\n/g, " ").replace(/\|/g, "\uFF5C").trim();
121709
+ function mdCell(text4) {
121710
+ return text4.replace(/\r?\n/g, " ").replace(/\|/g, "\uFF5C").trim();
121498
121711
  }
121499
121712
  function statusLabel(status, lang = "zh") {
121500
121713
  if (lang === "en") {
@@ -122342,8 +122555,8 @@ function normalizeBidding(raw) {
122342
122555
  return byNum[n] ?? null;
122343
122556
  }
122344
122557
  function validateTextLengths(errors, lengthViolations, texts, arrayField, kind, limit, label2) {
122345
- texts.forEach((text3, i) => {
122346
- const len = calcGoogleCharLength(text3);
122558
+ texts.forEach((text4, i) => {
122559
+ const len = calcGoogleCharLength(text4);
122347
122560
  if (len > limit) {
122348
122561
  const field = `${arrayField}[${i}]`;
122349
122562
  pushLengthViolation(lengthViolations, {
@@ -122353,9 +122566,9 @@ function validateTextLengths(errors, lengthViolations, texts, arrayField, kind,
122353
122566
  limit,
122354
122567
  actual: len,
122355
122568
  countMode: "google",
122356
- text: text3
122569
+ text: text4
122357
122570
  });
122358
- pushErr3(errors, `${label2}[${i}] \u8D85\u8FC7 ${limit} \u5B57\u7B26\uFF08\u5F53\u524D ${len}\uFF0CCJK \u8BA1 2\uFF09\uFF1A"${text3}"`);
122571
+ pushErr3(errors, `${label2}[${i}] \u8D85\u8FC7 ${limit} \u5B57\u7B26\uFF08\u5F53\u524D ${len}\uFF0CCJK \u8BA1 2\uFF09\uFF1A"${text4}"`);
122359
122572
  }
122360
122573
  });
122361
122574
  }
@@ -122766,8 +122979,8 @@ function pmaxChannelTypesUrl(googleApiUrl) {
122766
122979
  }
122767
122980
  function pmaxCampaignUrl(googleApiUrl, accountId, campaignId) {
122768
122981
  const base2 = googleApiUrl.replace(/\/$/, "");
122769
- const path56 = `${base2}/accounts/${accountId}/campaign/pmax`;
122770
- return campaignId ? `${path56}/${campaignId}` : path56;
122982
+ const path57 = `${base2}/accounts/${accountId}/campaign/pmax`;
122983
+ return campaignId ? `${path57}/${campaignId}` : path57;
122771
122984
  }
122772
122985
  function pmaxBrandAssetsUrl(googleApiUrl, accountId, campaignId) {
122773
122986
  return `${pmaxCampaignUrl(googleApiUrl, accountId, campaignId)}/brand-assets`;
@@ -122777,8 +122990,8 @@ function pmaxBrandGuidelinesEnableUrl(googleApiUrl, accountId, campaignId) {
122777
122990
  }
122778
122991
  function pmaxAssetGroupUrl(googleApiUrl, accountId, assetGroupId, suffix) {
122779
122992
  const base2 = googleApiUrl.replace(/\/$/, "");
122780
- const path56 = `${base2}/accounts/${accountId}/campaign/pmax/asset-group/${assetGroupId}`;
122781
- return suffix ? `${path56}/${suffix.replace(/^\//, "")}` : path56;
122993
+ const path57 = `${base2}/accounts/${accountId}/campaign/pmax/asset-group/${assetGroupId}`;
122994
+ return suffix ? `${path57}/${suffix.replace(/^\//, "")}` : path57;
122782
122995
  }
122783
122996
  function pmaxCampaignAssetGroupUrl(googleApiUrl, accountId, campaignId) {
122784
122997
  const base2 = googleApiUrl.replace(/\/$/, "");
@@ -122887,14 +123100,14 @@ async function uploadPmaxImageFileMultipart(config, googleApiUrl, accountId, abs
122887
123100
  if (config.apiKey) headers["x-api-key"] = config.apiKey;
122888
123101
  else headers.Authorization = `Bearer ${config.authToken}`;
122889
123102
  const res = await fetch(url, { method: "POST", headers, body: form });
122890
- const text3 = await res.text();
123103
+ const text4 = await res.text();
122891
123104
  if (!res.ok) {
122892
- const detail = verbose ? `\uFF1A${text3.slice(0, 300)}` : "";
123105
+ const detail = verbose ? `\uFF1A${text4.slice(0, 300)}` : "";
122893
123106
  throw new Error(`\u4E0A\u4F20\u56FE\u7247\u8D44\u4EA7 HTTP ${res.status}${detail}\uFF08${absImagePath}\uFF09`);
122894
123107
  }
122895
123108
  let data;
122896
123109
  try {
122897
- data = JSON.parse(text3);
123110
+ data = JSON.parse(text4);
122898
123111
  } catch {
122899
123112
  throw new Error(`\u4E0A\u4F20\u56FE\u7247\u8D44\u4EA7\u54CD\u5E94\u975E JSON\uFF08${absImagePath}\uFF09`);
122900
123113
  }
@@ -123034,9 +123247,9 @@ init_shared();
123034
123247
  // src/commands/ad/pmax-create-http-error.ts
123035
123248
  function normalizePmaxResumeId(value) {
123036
123249
  if (value == null) return null;
123037
- const text3 = String(value).trim();
123038
- if (!text3 || text3.toLowerCase() === "null") return null;
123039
- return text3;
123250
+ const text4 = String(value).trim();
123251
+ if (!text4 || text4.toLowerCase() === "null") return null;
123252
+ return text4;
123040
123253
  }
123041
123254
  function quoteLongResumeIds(rawBody) {
123042
123255
  return rawBody.replace(
@@ -123045,11 +123258,11 @@ function quoteLongResumeIds(rawBody) {
123045
123258
  );
123046
123259
  }
123047
123260
  function parsePmaxCreateFailureBody(rawBody) {
123048
- const text3 = rawBody.trim();
123049
- if (!text3.startsWith("{")) return null;
123261
+ const text4 = rawBody.trim();
123262
+ if (!text4.startsWith("{")) return null;
123050
123263
  let parsed;
123051
123264
  try {
123052
- parsed = JSON.parse(quoteLongResumeIds(text3));
123265
+ parsed = JSON.parse(quoteLongResumeIds(text4));
123053
123266
  } catch {
123054
123267
  return null;
123055
123268
  }
@@ -123169,19 +123382,19 @@ function validatePmaxSitelinkSpec(link, prefix, errors, warnings) {
123169
123382
  errors.push(`${prefix} \u4E0D\u80FD\u4E3A\u7A7A`);
123170
123383
  return;
123171
123384
  }
123172
- const text3 = link.text?.trim();
123385
+ const text4 = link.text?.trim();
123173
123386
  const url = link.destinationUrl?.trim();
123174
- if (!text3) errors.push(`${prefix}.text \u4E0D\u80FD\u4E3A\u7A7A`);
123387
+ if (!text4) errors.push(`${prefix}.text \u4E0D\u80FD\u4E3A\u7A7A`);
123175
123388
  if (!url) {
123176
123389
  errors.push(`${prefix}.destinationUrl \u4E0D\u80FD\u4E3A\u7A7A`);
123177
123390
  } else if (!/^https?:\/\/.+/i.test(url)) {
123178
123391
  errors.push(`${prefix}.destinationUrl \u683C\u5F0F\u4E0D\u6B63\u786E\uFF1A${url}`);
123179
123392
  }
123180
- if (text3 && url) {
123393
+ if (text4 && url) {
123181
123394
  validateSitelinkProperties(
123182
123395
  prefix,
123183
123396
  {
123184
- Text: text3,
123397
+ Text: text4,
123185
123398
  DestinationUrl: url,
123186
123399
  Line2: link.line2?.trim() ?? "",
123187
123400
  Line3: link.line3?.trim() ?? ""
@@ -123232,16 +123445,16 @@ function convertExtensionsForBatchJobToCampaignExtensions(items3) {
123232
123445
  const type = String(ext.typeV2 ?? ext.TypeV2 ?? ext.AssetFieldType ?? "").toUpperCase();
123233
123446
  const props = ext.Properties ?? {};
123234
123447
  if (type === "CALLOUT") {
123235
- const text3 = String(props.Text ?? props.CalloutText ?? "").trim();
123236
- if (text3) config.callouts.push(text3);
123448
+ const text4 = String(props.Text ?? props.CalloutText ?? "").trim();
123449
+ if (text4) config.callouts.push(text4);
123237
123450
  continue;
123238
123451
  }
123239
123452
  if (type === "SITELINK") {
123240
- const text3 = String(props.Text ?? props.LinkText ?? "").trim();
123453
+ const text4 = String(props.Text ?? props.LinkText ?? "").trim();
123241
123454
  const destinationUrl = String(props.DestinationUrl ?? "").trim();
123242
- if (text3 && destinationUrl) {
123455
+ if (text4 && destinationUrl) {
123243
123456
  config.sitelinks.push({
123244
- text: text3,
123457
+ text: text4,
123245
123458
  destinationUrl,
123246
123459
  line2: String(props.Line2 ?? props.Description1 ?? "").trim() || void 0,
123247
123460
  line3: String(props.Line3 ?? props.Description2 ?? "").trim() || void 0
@@ -123310,14 +123523,14 @@ function validatePmaxCampaignExtensions(ext, opts) {
123310
123523
  }
123311
123524
  const callouts = ext.callouts ?? [];
123312
123525
  for (let i = 0; i < callouts.length; i++) {
123313
- const text3 = callouts[i]?.trim();
123314
- if (!text3) {
123526
+ const text4 = callouts[i]?.trim();
123527
+ if (!text4) {
123315
123528
  errors.push(`campaignExtensions.callouts[${i}] \u4E0D\u80FD\u4E3A\u7A7A`);
123316
123529
  continue;
123317
123530
  }
123318
- if (text3.length > CALLOUT_TEXT_MAX_LEN) {
123531
+ if (text4.length > CALLOUT_TEXT_MAX_LEN) {
123319
123532
  errors.push(
123320
- `campaignExtensions.callouts[${i}] \u8D85\u8FC7 ${CALLOUT_TEXT_MAX_LEN} \u5B57\u7B26\uFF08\u5F53\u524D ${text3.length}\uFF09\uFF1A"${text3}"`
123533
+ `campaignExtensions.callouts[${i}] \u8D85\u8FC7 ${CALLOUT_TEXT_MAX_LEN} \u5B57\u7B26\uFF08\u5F53\u524D ${text4.length}\uFF09\uFF1A"${text4}"`
123321
123534
  );
123322
123535
  }
123323
123536
  }
@@ -123390,14 +123603,14 @@ async function postExtension(config, googleApiUrl, accountId, body, verbose) {
123390
123603
  return { ok: false, error: err instanceof Error ? err.message : String(err) };
123391
123604
  }
123392
123605
  }
123393
- function buildCalloutBody(accountId, campaignId, text3) {
123606
+ function buildCalloutBody(accountId, campaignId, text4) {
123394
123607
  return {
123395
123608
  activeuseridg: accountId,
123396
123609
  campaignId,
123397
123610
  level: "Campaign",
123398
123611
  typeV2: "CALLOUT",
123399
123612
  assetFieldType: "CALLOUT",
123400
- properties: { Text: text3.trim() }
123613
+ properties: { Text: text4.trim() }
123401
123614
  };
123402
123615
  }
123403
123616
  function buildSnippetBody(accountId, campaignId, header, values) {
@@ -123414,8 +123627,8 @@ function buildSnippetBody(accountId, campaignId, header, values) {
123414
123627
  };
123415
123628
  }
123416
123629
  function buildSitelinkBody(accountId, campaignId, link) {
123417
- const text3 = link.text.trim();
123418
- const line2 = link.line2?.trim() || text3;
123630
+ const text4 = link.text.trim();
123631
+ const line2 = link.line2?.trim() || text4;
123419
123632
  const line3 = link.line3?.trim() || line2;
123420
123633
  return {
123421
123634
  activeuseridg: accountId,
@@ -123424,7 +123637,7 @@ function buildSitelinkBody(accountId, campaignId, link) {
123424
123637
  typeV2: "SITELINK",
123425
123638
  assetFieldType: "SITELINK",
123426
123639
  properties: {
123427
- Text: text3,
123640
+ Text: text4,
123428
123641
  Line2: line2,
123429
123642
  Line3: line3,
123430
123643
  DestinationUrl: link.destinationUrl.trim()
@@ -123452,26 +123665,26 @@ async function attachPmaxCampaignExtensions(opts) {
123452
123665
  allOk: true
123453
123666
  };
123454
123667
  for (const raw of ext.callouts ?? []) {
123455
- const text3 = raw?.trim();
123456
- if (!text3) continue;
123668
+ const text4 = raw?.trim();
123669
+ if (!text4) continue;
123457
123670
  if (opts.logProgress) console.log(`
123458
- \u6302\u8F7D\u5BA3\u4F20\u4FE1\u606F\uFF1A${text3}`);
123671
+ \u6302\u8F7D\u5BA3\u4F20\u4FE1\u606F\uFF1A${text4}`);
123459
123672
  const posted = await postExtension(
123460
123673
  opts.config,
123461
123674
  opts.googleApiUrl,
123462
123675
  opts.accountId,
123463
- buildCalloutBody(opts.accountId, opts.campaignId, text3),
123676
+ buildCalloutBody(opts.accountId, opts.campaignId, text4),
123464
123677
  opts.verbose
123465
123678
  );
123466
123679
  if (posted.ok) {
123467
123680
  result.callouts.push({
123468
123681
  ok: true,
123469
123682
  id: String(posted.data["id"] ?? ""),
123470
- label: text3
123683
+ label: text4
123471
123684
  });
123472
123685
  } else {
123473
123686
  result.allOk = false;
123474
- result.callouts.push({ ok: false, error: posted.error, label: text3 });
123687
+ result.callouts.push({ ok: false, error: posted.error, label: text4 });
123475
123688
  }
123476
123689
  }
123477
123690
  for (const s of ext.structuredSnippets ?? []) {
@@ -123500,11 +123713,11 @@ async function attachPmaxCampaignExtensions(opts) {
123500
123713
  }
123501
123714
  }
123502
123715
  for (const link of ext.sitelinks ?? []) {
123503
- const text3 = link?.text?.trim();
123716
+ const text4 = link?.text?.trim();
123504
123717
  const url = link?.destinationUrl?.trim();
123505
- if (!text3 || !url) continue;
123718
+ if (!text4 || !url) continue;
123506
123719
  if (opts.logProgress) console.log(`
123507
- \u6302\u8F7D\u7AD9\u5185\u94FE\u63A5\uFF1A${text3} \u2192 ${url}`);
123720
+ \u6302\u8F7D\u7AD9\u5185\u94FE\u63A5\uFF1A${text4} \u2192 ${url}`);
123508
123721
  const posted = await postExtension(
123509
123722
  opts.config,
123510
123723
  opts.googleApiUrl,
@@ -123516,11 +123729,11 @@ async function attachPmaxCampaignExtensions(opts) {
123516
123729
  result.sitelinks.push({
123517
123730
  ok: true,
123518
123731
  id: String(posted.data["id"] ?? ""),
123519
- label: text3
123732
+ label: text4
123520
123733
  });
123521
123734
  } else {
123522
123735
  result.allOk = false;
123523
- result.sitelinks.push({ ok: false, error: posted.error, label: text3 });
123736
+ result.sitelinks.push({ ok: false, error: posted.error, label: text4 });
123524
123737
  }
123525
123738
  }
123526
123739
  if (ext.leadForm) {
@@ -123996,13 +124209,13 @@ function runPmaxVideoValidation(configFile, cfg) {
123996
124209
  async function fetchVideoUploadStatus(config, googleApiUrl, mediaAccountId, resourceName, verbose) {
123997
124210
  const url = pyapiVideoStatusUrl(googleApiUrl, mediaAccountId, resourceName);
123998
124211
  const res = await fetch(url, { method: "GET", headers: authHeaders(config) });
123999
- const text3 = await res.text();
124212
+ const text4 = await res.text();
124000
124213
  if (!res.ok) {
124001
- const detail = verbose ? `\uFF1A${text3.slice(0, 300)}` : "";
124214
+ const detail = verbose ? `\uFF1A${text4.slice(0, 300)}` : "";
124002
124215
  throw new Error(`\u67E5\u8BE2\u89C6\u9891\u5904\u7406\u72B6\u6001 HTTP ${res.status}${detail}`);
124003
124216
  }
124004
124217
  try {
124005
- return JSON.parse(text3);
124218
+ return JSON.parse(text4);
124006
124219
  } catch {
124007
124220
  throw new Error("\u67E5\u8BE2\u89C6\u9891\u5904\u7406\u72B6\u6001\u54CD\u5E94\u975E JSON");
124008
124221
  }
@@ -124058,14 +124271,14 @@ async function uploadPmaxLocalVideo(opts) {
124058
124271
  );
124059
124272
  const url = pyapiVideoUploadUrl(opts.googleApiUrl);
124060
124273
  const res = await fetch(url, { method: "POST", headers: authHeaders(opts.config), body: form });
124061
- const text3 = await res.text();
124274
+ const text4 = await res.text();
124062
124275
  if (!res.ok) {
124063
- const detail = opts.verbose ? `\uFF1A${text3.slice(0, 400)}` : "";
124276
+ const detail = opts.verbose ? `\uFF1A${text4.slice(0, 400)}` : "";
124064
124277
  throw new Error(`\u4E0A\u4F20\u89C6\u9891 HTTP ${res.status}${detail}\uFF08${opts.absVideoPath}\uFF09`);
124065
124278
  }
124066
124279
  let data;
124067
124280
  try {
124068
- data = JSON.parse(text3);
124281
+ data = JSON.parse(text4);
124069
124282
  } catch {
124070
124283
  throw new Error(`\u4E0A\u4F20\u89C6\u9891\u54CD\u5E94\u975E JSON\uFF08${opts.absVideoPath}\uFF09`);
124071
124284
  }
@@ -125760,8 +125973,8 @@ async function runAdPmaxImageConvert(opts) {
125760
125973
  }
125761
125974
 
125762
125975
  // src/commands/ad/pmax-brand-mgmt.ts
125763
- function loadBrandConfig(path56, accountId, campaignId) {
125764
- const cfg = loadPmaxJsonFile(path56);
125976
+ function loadBrandConfig(path57, accountId, campaignId) {
125977
+ const cfg = loadPmaxJsonFile(path57);
125765
125978
  return {
125766
125979
  ...cfg,
125767
125980
  account: String(cfg["account"] ?? accountId).trim(),
@@ -125944,16 +126157,16 @@ function quoteLongResumeIds2(rawBody) {
125944
126157
  }
125945
126158
  function normalizeResumeId(value) {
125946
126159
  if (value == null) return null;
125947
- const text3 = String(value).trim();
125948
- if (!text3 || text3.toLowerCase() === "null") return null;
125949
- return text3;
126160
+ const text4 = String(value).trim();
126161
+ if (!text4 || text4.toLowerCase() === "null") return null;
126162
+ return text4;
125950
126163
  }
125951
126164
  function parseDemandGenCreateFailure(rawBody) {
125952
- const text3 = rawBody.trim();
125953
- if (!text3.startsWith("{")) return null;
126165
+ const text4 = rawBody.trim();
126166
+ if (!text4.startsWith("{")) return null;
125954
126167
  let parsed;
125955
126168
  try {
125956
- parsed = JSON.parse(quoteLongResumeIds2(text3));
126169
+ parsed = JSON.parse(quoteLongResumeIds2(text4));
125957
126170
  } catch {
125958
126171
  return null;
125959
126172
  }
@@ -126009,10 +126222,10 @@ function decorateDemandGenRead(value) {
126009
126222
  }
126010
126223
  function normalizeCampaignStatus(raw) {
126011
126224
  if (raw == null || String(raw).trim() === "") return null;
126012
- const text3 = String(raw).trim().toLowerCase();
126013
- if (text3 === "enabled" || text3 === "2") return "Enabled";
126014
- if (text3 === "paused" || text3 === "3") return "Paused";
126015
- if (text3 === "removed" || text3 === "4") return "Removed";
126225
+ const text4 = String(raw).trim().toLowerCase();
126226
+ if (text4 === "enabled" || text4 === "2") return "Enabled";
126227
+ if (text4 === "paused" || text4 === "3") return "Paused";
126228
+ if (text4 === "removed" || text4 === "4") return "Removed";
126016
126229
  return null;
126017
126230
  }
126018
126231
  function normalizeAdStatus(raw) {
@@ -126116,12 +126329,12 @@ function demandGenConversionsValidateUrl(googleApiUrl, accountId) {
126116
126329
  return `${demandGenCollectionUrl(googleApiUrl, accountId)}/conversions/validate`;
126117
126330
  }
126118
126331
  function demandGenAdGroupUrl(googleApiUrl, accountId, campaignId, adGroupId, suffix) {
126119
- const path56 = `${demandGenCampaignUrl(googleApiUrl, accountId, campaignId)}/ad-groups/${adGroupId}`;
126120
- return suffix ? `${path56}/${suffix.replace(/^\//, "")}` : path56;
126332
+ const path57 = `${demandGenCampaignUrl(googleApiUrl, accountId, campaignId)}/ad-groups/${adGroupId}`;
126333
+ return suffix ? `${path57}/${suffix.replace(/^\//, "")}` : path57;
126121
126334
  }
126122
126335
  function demandGenAdUrl(googleApiUrl, accountId, campaignId, adGroupId, adId, suffix) {
126123
- const path56 = `${demandGenAdGroupUrl(googleApiUrl, accountId, campaignId, adGroupId)}/ads/${adId}`;
126124
- return suffix ? `${path56}/${suffix.replace(/^\//, "")}` : path56;
126336
+ const path57 = `${demandGenAdGroupUrl(googleApiUrl, accountId, campaignId, adGroupId)}/ads/${adId}`;
126337
+ return suffix ? `${path57}/${suffix.replace(/^\//, "")}` : path57;
126125
126338
  }
126126
126339
  function demandGenChannelReportUrl(googleApiUrl, accountId, campaignId, startDate, endDate) {
126127
126340
  const params = new URLSearchParams({ startDate, endDate });
@@ -126225,7 +126438,7 @@ function explainCreateError(err) {
126225
126438
  if (failure) return demandGenResumeHint(failure);
126226
126439
  return err instanceof Error ? err.message : String(err);
126227
126440
  }
126228
- async function postCreate(opts, path56, commandLabel) {
126441
+ async function postCreate(opts, path57, commandLabel) {
126229
126442
  const accountId = requireAccountId(opts.account);
126230
126443
  const raw = loadBody(opts.configFile);
126231
126444
  await withGoogleApi(opts, async (config, googleApiUrl) => {
@@ -126237,7 +126450,7 @@ async function postCreate(opts, path56, commandLabel) {
126237
126450
  fail(err instanceof Error ? err.message : String(err));
126238
126451
  }
126239
126452
  printIssues(demandGenCreateIssues(body));
126240
- const url = path56 ? `${demandGenCollectionUrl(googleApiUrl, accountId)}/${path56}` : demandGenCollectionUrl(googleApiUrl, accountId);
126453
+ const url = path57 ? `${demandGenCollectionUrl(googleApiUrl, accountId)}/${path57}` : demandGenCollectionUrl(googleApiUrl, accountId);
126241
126454
  let data;
126242
126455
  try {
126243
126456
  data = await pmaxApiFetch(
@@ -126250,7 +126463,7 @@ async function postCreate(opts, path56, commandLabel) {
126250
126463
  fail(explainCreateError(err));
126251
126464
  }
126252
126465
  const payload = decorateDemandGenRead(data);
126253
- if (await emit({ ...opts, account: accountId }, `ad-demand-gen-${path56 || "create"}`, commandLabel, payload, accountId)) {
126466
+ if (await emit({ ...opts, account: accountId }, `ad-demand-gen-${path57 || "create"}`, commandLabel, payload, accountId)) {
126254
126467
  return;
126255
126468
  }
126256
126469
  console.log(`
@@ -128392,15 +128605,15 @@ function formatMetaAdError(err) {
128392
128605
  }
128393
128606
  return appendMetaAdErrorHint(raw);
128394
128607
  }
128395
- function appendMetaAdErrorHint(text3) {
128396
- if (!/advantage_audience|targeting_automation/i.test(text3)) return text3;
128397
- return `${text3}
128608
+ function appendMetaAdErrorHint(text4) {
128609
+ if (!/advantage_audience|targeting_automation/i.test(text4)) return text4;
128610
+ return `${text4}
128398
128611
  \u63D0\u793A\uFF1Acreate / adset-create \u5DF2\u63D0\u4EA4 targeting_automation.advantage_audience\uFF08\u9ED8\u8BA4 1\uFF1B\u6709 flexibleSpec \u65F6\u9ED8\u8BA4 0\uFF09\u3002
128399
128612
  \u4E0D\u8981\u65B0\u5EFA\u7CFB\u5217\u3002\u7528 --json-out \u91CC\u5DF2\u5EFA\u6210\u7684 campaignId \u8DD1 adset-create \u7EED\u8DD1\uFF1B\u7EC6\u5B9A\u5411\u53EF\u663E\u5F0F\u8BBE adset.advantageAudience=0\u3002`;
128400
128613
  }
128401
128614
  function isBidAmountRequired(err) {
128402
- const text3 = formatMetaAdError(err);
128403
- return /BID_AMOUNT_REQUIRED/i.test(text3) || /缺少竞价金额/.test(text3) || /必须提供 bid_amount/.test(text3) || /必须在 bid_amount/.test(text3);
128615
+ const text4 = formatMetaAdError(err);
128616
+ return /BID_AMOUNT_REQUIRED/i.test(text4) || /缺少竞价金额/.test(text4) || /必须提供 bid_amount/.test(text4) || /必须在 bid_amount/.test(text4);
128404
128617
  }
128405
128618
  function failMetaAd(action, err) {
128406
128619
  console.error(`
@@ -128469,9 +128682,9 @@ function metaAdContext(token) {
128469
128682
  const config = loadConfig(token);
128470
128683
  return { config, facebookApiUrl: requireFacebookApi(config) };
128471
128684
  }
128472
- function adsUrl(facebookApiUrl, account, path56) {
128685
+ function adsUrl(facebookApiUrl, account, path57) {
128473
128686
  const base2 = metaAdsBaseUrl(facebookApiUrl, account);
128474
- const p = path56.startsWith("/") ? path56 : `/${path56}`;
128687
+ const p = path57.startsWith("/") ? path57 : `/${path57}`;
128475
128688
  return `${base2}${p}`;
128476
128689
  }
128477
128690
  async function metaAdGet(url, config, verbose, action) {
@@ -129678,9 +129891,9 @@ async function runMetaAdForms(opts) {
129678
129891
  if (opts.after) params.set("after", opts.after);
129679
129892
  if (opts.before) params.set("before", opts.before);
129680
129893
  const qs = params.toString();
129681
- const path56 = `/pages/${encodeURIComponent(opts.pageId)}/forms${qs ? `?${qs}` : ""}`;
129894
+ const path57 = `/pages/${encodeURIComponent(opts.pageId)}/forms${qs ? `?${qs}` : ""}`;
129682
129895
  const raw = await metaAdGet(
129683
- adsUrl(facebookApiUrl, digits, path56),
129896
+ adsUrl(facebookApiUrl, digits, path57),
129684
129897
  config,
129685
129898
  opts.verbose,
129686
129899
  "\u5217\u8868\u5355\u5931\u8D25"
@@ -129799,8 +130012,8 @@ var QUESTION_TYPE_LABEL = {
129799
130012
  JOB_TITLE: "Job Title",
129800
130013
  CUSTOM: "Custom"
129801
130014
  };
129802
- function chrome(text3, lang) {
129803
- return lang === "en" ? applyEnglishPhrases(text3) : text3;
130015
+ function chrome(text4, lang) {
130016
+ return lang === "en" ? applyEnglishPhrases(text4) : text4;
129804
130017
  }
129805
130018
  function text2(value) {
129806
130019
  if (value == null) return PENDING;
@@ -131185,9 +131398,9 @@ async function fetchAccountPositiveKeywordNormSet(config, googleApiUrl, accountI
131185
131398
  if (seenIds.has(id)) continue;
131186
131399
  seenIds.add(id);
131187
131400
  }
131188
- const text3 = extractKeywordTextFromManagementRow(row);
131189
- if (!text3) continue;
131190
- const norm = normalizeKeywordForAccountMatch(text3);
131401
+ const text4 = extractKeywordTextFromManagementRow(row);
131402
+ if (!text4) continue;
131403
+ const norm = normalizeKeywordForAccountMatch(text4);
131191
131404
  if (norm) normSet.add(norm);
131192
131405
  }
131193
131406
  return normSet;
@@ -131781,8 +131994,8 @@ function similarityPercent(score) {
131781
131994
  const s = Math.min(1, Math.max(0, score));
131782
131995
  return `${Math.round(s * 100)}%`;
131783
131996
  }
131784
- function blockquoteMarkdown(text3) {
131785
- return text3.split("\n").map((line) => `> ${line}`).join("\n");
131997
+ function blockquoteMarkdown(text4) {
131998
+ return text4.split("\n").map((line) => `> ${line}`).join("\n");
131786
131999
  }
131787
132000
  function formatTime(iso) {
131788
132001
  if (!iso) return "";
@@ -132450,8 +132663,8 @@ function assertGoogleMediaCustomerId(raw) {
132450
132663
  process.exit(1);
132451
132664
  }
132452
132665
  }
132453
- function parseCustomerAccessPermissionBody(text3) {
132454
- const trimmed = text3.trim();
132666
+ function parseCustomerAccessPermissionBody(text4) {
132667
+ const trimmed = text4.trim();
132455
132668
  if (!trimmed) return null;
132456
132669
  try {
132457
132670
  const parsed = JSON.parse(trimmed);
@@ -132493,8 +132706,8 @@ function interpretCustomerAccessPermission(mediaCustomerId, httpStatus, rawBody)
132493
132706
  };
132494
132707
  }
132495
132708
  if (httpStatus === 403) {
132496
- const text3 = typeof rawBody === "string" ? rawBody : rawBody == null ? "" : String(rawBody);
132497
- if (text3.includes("token\u4E0D\u80FD\u4E3A\u7A7A") || text3.toLowerCase().includes("token") && text3.includes("\u7A7A")) {
132709
+ const text4 = typeof rawBody === "string" ? rawBody : rawBody == null ? "" : String(rawBody);
132710
+ if (text4.includes("token\u4E0D\u80FD\u4E3A\u7A7A") || text4.toLowerCase().includes("token") && text4.includes("\u7A7A")) {
132498
132711
  return {
132499
132712
  ...base2,
132500
132713
  status: "google_not_bound",
@@ -134409,12 +134622,12 @@ async function uploadAttachment(filePath, apiBaseUrl, config, verbose) {
134409
134622
  headers,
134410
134623
  body: form
134411
134624
  });
134412
- const text3 = await res.text();
134625
+ const text4 = await res.text();
134413
134626
  if (!res.ok) {
134414
- const detail = verbose ? `\uFF1A${text3.slice(0, 300)}` : "";
134627
+ const detail = verbose ? `\uFF1A${text4.slice(0, 300)}` : "";
134415
134628
  throw new Error(`\u4E0A\u4F20\u6587\u4EF6 HTTP ${res.status}${detail}`);
134416
134629
  }
134417
- const data = JSON.parse(text3);
134630
+ const data = JSON.parse(text4);
134418
134631
  if (!data.id) {
134419
134632
  throw new Error("\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25\uFF1A\u54CD\u5E94\u4E2D\u672A\u5305\u542B\u6587\u4EF6 ID");
134420
134633
  }
@@ -136160,9 +136373,9 @@ init_cli_json_snapshot();
136160
136373
  import fs15 from "fs";
136161
136374
  import path20 from "path";
136162
136375
  function readJson(filePath) {
136163
- const text3 = fs15.readFileSync(filePath, "utf8");
136376
+ const text4 = fs15.readFileSync(filePath, "utf8");
136164
136377
  try {
136165
- const v = JSON.parse(text3);
136378
+ const v = JSON.parse(text4);
136166
136379
  if (!v || typeof v !== "object" || Array.isArray(v)) {
136167
136380
  throw new Error("\u987B\u4E3A JSON \u5BF9\u8C61");
136168
136381
  }
@@ -136271,9 +136484,9 @@ function websiteDiagnosisRuntimePath() {
136271
136484
  }
136272
136485
  function readJsonFile(filePath) {
136273
136486
  const raw = fsPromises.readFile(filePath, "utf8");
136274
- return raw.then((text3) => {
136487
+ return raw.then((text4) => {
136275
136488
  try {
136276
- return JSON.parse(text3);
136489
+ return JSON.parse(text4);
136277
136490
  } catch {
136278
136491
  throw new Error(`\u65E0\u6CD5\u89E3\u6790 JSON\uFF1A${filePath}`);
136279
136492
  }
@@ -138655,9 +138868,9 @@ function asRecord12(value) {
138655
138868
  }
138656
138869
  return null;
138657
138870
  }
138658
- function getNestedValue(root, path56) {
138871
+ function getNestedValue(root, path57) {
138659
138872
  let cur = root;
138660
- for (const key of path56) {
138873
+ for (const key of path57) {
138661
138874
  const rec = asRecord12(cur);
138662
138875
  if (!rec) return void 0;
138663
138876
  cur = rec[key];
@@ -139049,7 +139262,7 @@ function collectGoldClaimTexts(data) {
139049
139262
  if (rec) texts.push(String(rec.title ?? ""), String(rec.description ?? ""));
139050
139263
  }
139051
139264
  }
139052
- return texts.filter((text3) => text3.trim().length > 0);
139265
+ return texts.filter((text4) => text4.trim().length > 0);
139053
139266
  }
139054
139267
  function findIdenticalTexts(texts, minCount) {
139055
139268
  const counts = /* @__PURE__ */ new Map();
@@ -139057,8 +139270,8 @@ function findIdenticalTexts(texts, minCount) {
139057
139270
  if (!t) continue;
139058
139271
  counts.set(t, (counts.get(t) ?? 0) + 1);
139059
139272
  }
139060
- for (const [text3, count2] of counts) {
139061
- if (count2 >= minCount) return text3;
139273
+ for (const [text4, count2] of counts) {
139274
+ if (count2 >= minCount) return text4;
139062
139275
  }
139063
139276
  return null;
139064
139277
  }
@@ -139131,20 +139344,20 @@ function asRecord15(value) {
139131
139344
  }
139132
139345
  return null;
139133
139346
  }
139134
- function proseColonIndex(text3) {
139135
- const cn = text3.indexOf("\uFF1A");
139136
- if (cn > 0 && cn < text3.length - 1) return cn;
139137
- for (let i = 1; i < text3.length - 1; i++) {
139138
- if (text3[i] !== ":") continue;
139139
- if (text3[i + 1] === "/") continue;
139140
- const scheme = text3.slice(Math.max(0, i - 5), i);
139347
+ function proseColonIndex(text4) {
139348
+ const cn = text4.indexOf("\uFF1A");
139349
+ if (cn > 0 && cn < text4.length - 1) return cn;
139350
+ for (let i = 1; i < text4.length - 1; i++) {
139351
+ if (text4[i] !== ":") continue;
139352
+ if (text4[i + 1] === "/") continue;
139353
+ const scheme = text4.slice(Math.max(0, i - 5), i);
139141
139354
  if (/https?$/i.test(scheme)) continue;
139142
139355
  return i;
139143
139356
  }
139144
139357
  return -1;
139145
139358
  }
139146
- function splitOverviewProse(text3) {
139147
- const trimmed = text3.trim();
139359
+ function splitOverviewProse(text4) {
139360
+ const trimmed = text4.trim();
139148
139361
  const cut = proseColonIndex(trimmed);
139149
139362
  if (cut > 0) {
139150
139363
  const title = trimmed.slice(0, cut).trim();
@@ -139155,9 +139368,9 @@ function splitOverviewProse(text3) {
139155
139368
  }
139156
139369
  function normalizeOverviewItem(item) {
139157
139370
  if (typeof item === "string" || typeof item === "number") {
139158
- const text3 = String(item).trim();
139159
- if (!text3) return null;
139160
- return splitOverviewProse(text3);
139371
+ const text4 = String(item).trim();
139372
+ if (!text4) return null;
139373
+ return splitOverviewProse(text4);
139161
139374
  }
139162
139375
  const rec = asRecord15(item);
139163
139376
  if (!rec) return null;
@@ -139238,16 +139451,16 @@ function creativeSuggestionFromRow(row) {
139238
139451
  function distinctCopies(rows, key) {
139239
139452
  const counts = /* @__PURE__ */ new Map();
139240
139453
  for (const row of rows) {
139241
- const text3 = String(row[key] ?? "");
139242
- counts.set(text3, (counts.get(text3) ?? 0) + 1);
139454
+ const text4 = String(row[key] ?? "");
139455
+ counts.set(text4, (counts.get(text4) ?? 0) + 1);
139243
139456
  }
139244
139457
  const seen = /* @__PURE__ */ new Map();
139245
139458
  return rows.map((row) => {
139246
- const text3 = String(row[key] ?? "");
139247
- if ((counts.get(text3) ?? 0) < 3) return row;
139248
- const n = (seen.get(text3) ?? 0) + 1;
139249
- seen.set(text3, n);
139250
- return { ...row, [key]: `${text3}\uFF08\u540C\u7ED3\u6784\u7B2C ${n} \u6761\uFF09` };
139459
+ const text4 = String(row[key] ?? "");
139460
+ if ((counts.get(text4) ?? 0) < 3) return row;
139461
+ const n = (seen.get(text4) ?? 0) + 1;
139462
+ seen.set(text4, n);
139463
+ return { ...row, [key]: `${text4}\uFF08\u540C\u7ED3\u6784\u7B2C ${n} \u6761\uFF09` };
139251
139464
  });
139252
139465
  }
139253
139466
  function mapRows(rows, write) {
@@ -140948,14 +141161,14 @@ var FACEBOOK_SECTION_ALIASES = {
140948
141161
  import { Command as Command2 } from "commander";
140949
141162
 
140950
141163
  // src/commands/facebook-analysis/render-report.ts
140951
- import fs35 from "fs";
140952
- import fsPromises3 from "fs/promises";
140953
- import path42 from "path";
140954
- import { fileURLToPath as fileURLToPath10 } from "url";
141164
+ import fs36 from "fs";
141165
+ import fsPromises4 from "fs/promises";
141166
+ import path43 from "path";
141167
+ import { fileURLToPath as fileURLToPath11 } from "url";
140955
141168
 
140956
141169
  // src/commands/facebook-analysis/merge-snapshot.ts
140957
- import * as fs34 from "fs/promises";
140958
- import * as path41 from "path";
141170
+ import * as fs35 from "fs/promises";
141171
+ import * as path42 from "path";
140959
141172
 
140960
141173
  // src/commands/facebook-analysis/report-metrics.ts
140961
141174
  function asRecord25(value) {
@@ -141107,7 +141320,7 @@ function hasResults(row) {
141107
141320
 
141108
141321
  // src/commands/facebook-analysis/merge-snapshot.ts
141109
141322
  async function readManifest3(snapshotDir) {
141110
- const entries = await fs34.readdir(snapshotDir);
141323
+ const entries = await fs35.readdir(snapshotDir);
141111
141324
  const manifestNames = entries.filter(
141112
141325
  (n) => n.startsWith("report-manifest") && n.endsWith(".json")
141113
141326
  );
@@ -141117,7 +141330,7 @@ async function readManifest3(snapshotDir) {
141117
141330
  ];
141118
141331
  for (const name2 of ordered) {
141119
141332
  try {
141120
- const raw = await fs34.readFile(path41.join(snapshotDir, name2), "utf8");
141333
+ const raw = await fs35.readFile(path42.join(snapshotDir, name2), "utf8");
141121
141334
  const parsed = JSON.parse(raw);
141122
141335
  if (parsed?.artifacts?.length) return parsed;
141123
141336
  } catch {
@@ -141127,7 +141340,7 @@ async function readManifest3(snapshotDir) {
141127
141340
  }
141128
141341
  async function loadSectionFile3(snapshotDir, file) {
141129
141342
  try {
141130
- const raw = await fs34.readFile(path41.join(snapshotDir, file), "utf8");
141343
+ const raw = await fs35.readFile(path42.join(snapshotDir, file), "utf8");
141131
141344
  return asRecord25(JSON.parse(raw));
141132
141345
  } catch {
141133
141346
  return null;
@@ -141171,7 +141384,7 @@ function mapAdSetRows(groups) {
141171
141384
  })).sort((a, b) => (b.spend ?? 0) - (a.spend ?? 0));
141172
141385
  }
141173
141386
  async function mergeFacebookSnapshotIntoReport(payload, snapshotDir) {
141174
- const absDir = path41.resolve(snapshotDir);
141387
+ const absDir = path42.resolve(snapshotDir);
141175
141388
  const manifest = await readManifest3(snapshotDir);
141176
141389
  if (!manifest) {
141177
141390
  throw new Error(
@@ -141438,7 +141651,7 @@ function buildMetaPeriodExcelSheets(data) {
141438
141651
  })
141439
141652
  ],
141440
141653
  [],
141441
- ...buildSummaryNarrative(data).map((text3) => [text3])
141654
+ ...buildSummaryNarrative(data).map((text4) => [text4])
141442
141655
  ];
141443
141656
  const dailyRows = [metricHeaders(currency, "\u5355\u65E5")];
141444
141657
  for (const raw of asArray3(tables.daily)) {
@@ -141485,8 +141698,8 @@ function buildMetaPeriodExcelSheets(data) {
141485
141698
  { name: "\u53D7\u4F17", rows: audienceRows }
141486
141699
  ];
141487
141700
  }
141488
- function chrome2(text3, lang) {
141489
- return lang === "en" ? applyEnglishPhrases(text3) : text3;
141701
+ function chrome2(text4, lang) {
141702
+ return lang === "en" ? applyEnglishPhrases(text4) : text4;
141490
141703
  }
141491
141704
  function writeMetaPeriodExcel(outPath, data, lang = "zh") {
141492
141705
  const sheets = buildMetaPeriodExcelSheets(data).map((sheet) => ({
@@ -141792,20 +142005,20 @@ var TEMPLATE_BASENAMES2 = {
141792
142005
  html: "meta-period-report.html"
141793
142006
  };
141794
142007
  var INJECT_MARKER2 = "window.__META_PERIOD_REPORT__ = window.__META_PERIOD_REPORT__ || null;";
141795
- function resolveSkillTemplatePath4(basename13) {
141796
- const dir = path42.dirname(fileURLToPath10(import.meta.url));
142008
+ function resolveSkillTemplatePath5(basename13) {
142009
+ const dir = path43.dirname(fileURLToPath11(import.meta.url));
141797
142010
  const candidates = [
141798
- path42.join(dir, "skill", "report-templates", basename13),
141799
- path42.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
141800
- path42.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
142011
+ path43.join(dir, "skill", "report-templates", basename13),
142012
+ path43.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
142013
+ path43.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
141801
142014
  ];
141802
142015
  for (const p of candidates) {
141803
- if (fs35.existsSync(p)) return p;
142016
+ if (fs36.existsSync(p)) return p;
141804
142017
  }
141805
142018
  return candidates[0];
141806
142019
  }
141807
142020
  function metaPeriodReportTemplatePath() {
141808
- return resolveSkillTemplatePath4(TEMPLATE_BASENAMES2.html);
142021
+ return resolveSkillTemplatePath5(TEMPLATE_BASENAMES2.html);
141809
142022
  }
141810
142023
  function parseRenderFormats(raw) {
141811
142024
  const tokens = (raw ?? "html").split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
@@ -141822,10 +142035,10 @@ function parseRenderFormats(raw) {
141822
142035
  }
141823
142036
  return [...new Set(out)];
141824
142037
  }
141825
- async function readJsonFile4(filePath) {
141826
- const text3 = await fsPromises3.readFile(filePath, "utf8");
142038
+ async function readJsonFile5(filePath) {
142039
+ const text4 = await fsPromises4.readFile(filePath, "utf8");
141827
142040
  try {
141828
- return JSON.parse(text3);
142041
+ return JSON.parse(text4);
141829
142042
  } catch {
141830
142043
  throw new Error(`\u65E0\u6CD5\u89E3\u6790 JSON\uFF1A${filePath}`);
141831
142044
  }
@@ -141846,7 +142059,7 @@ function injectReportData3(html, payload, lang) {
141846
142059
  }
141847
142060
  function defaultOutPath(dataPath, format, out) {
141848
142061
  if (out?.trim()) {
141849
- const resolved = path42.resolve(out);
142062
+ const resolved = path43.resolve(out);
141850
142063
  if (format === "xlsx" && !/\.xlsx$/i.test(resolved)) {
141851
142064
  return resolved.replace(/\.(html?)$/i, ".xlsx");
141852
142065
  }
@@ -141855,14 +142068,14 @@ function defaultOutPath(dataPath, format, out) {
141855
142068
  }
141856
142069
  return resolved;
141857
142070
  }
141858
- const dir = path42.dirname(dataPath);
141859
- return path42.join(dir, format === "xlsx" ? "meta-period-report.xlsx" : "meta-period-report.html");
142071
+ const dir = path43.dirname(dataPath);
142072
+ return path43.join(dir, format === "xlsx" ? "meta-period-report.xlsx" : "meta-period-report.html");
141860
142073
  }
141861
142074
  async function runFacebookAnalysisRender(opts) {
141862
- const dataPath = path42.resolve(opts.dataFile);
141863
- let data = asRecord28(await readJsonFile4(dataPath));
142075
+ const dataPath = path43.resolve(opts.dataFile);
142076
+ let data = asRecord28(await readJsonFile5(dataPath));
141864
142077
  if (opts.snapshotDir?.trim()) {
141865
- data = await mergeFacebookSnapshotIntoReport(data, path42.resolve(opts.snapshotDir));
142078
+ data = await mergeFacebookSnapshotIntoReport(data, path43.resolve(opts.snapshotDir));
141866
142079
  }
141867
142080
  localizeFacebookReportLabels(data);
141868
142081
  const lang = readReportLangOrExit({ flag: opts.lang, meta: data.meta });
@@ -141882,14 +142095,14 @@ async function runFacebookAnalysisRender(opts) {
141882
142095
  const written = [];
141883
142096
  for (const format of formats) {
141884
142097
  const outPath = defaultOutPath(dataPath, format, opts.out);
141885
- await fsPromises3.mkdir(path42.dirname(outPath), { recursive: true });
142098
+ await fsPromises4.mkdir(path43.dirname(outPath), { recursive: true });
141886
142099
  if (format === "xlsx") {
141887
142100
  writeMetaPeriodExcel(outPath, data, lang);
141888
142101
  } else {
141889
142102
  const templatePath = metaPeriodReportTemplatePath();
141890
142103
  let html;
141891
142104
  try {
141892
- html = await fsPromises3.readFile(templatePath, "utf8");
142105
+ html = await fsPromises4.readFile(templatePath, "utf8");
141893
142106
  } catch {
141894
142107
  console.error(`
141895
142108
  \u274C \u672A\u627E\u5230\u62A5\u544A\u6A21\u677F\uFF1A${templatePath}
@@ -141897,7 +142110,7 @@ async function runFacebookAnalysisRender(opts) {
141897
142110
  `);
141898
142111
  process.exit(1);
141899
142112
  }
141900
- await fsPromises3.writeFile(outPath, injectReportData3(html, data, lang), "utf8");
142113
+ await fsPromises4.writeFile(outPath, injectReportData3(html, data, lang), "utf8");
141901
142114
  }
141902
142115
  written.push(outPath);
141903
142116
  }
@@ -141918,14 +142131,14 @@ async function runFacebookAnalysisRender(opts) {
141918
142131
  }
141919
142132
 
141920
142133
  // src/commands/facebook-analysis/diagnosis-render-report.ts
141921
- import fs37 from "fs";
141922
- import fsPromises4 from "fs/promises";
141923
- import path44 from "path";
141924
- import { fileURLToPath as fileURLToPath11 } from "url";
142134
+ import fs38 from "fs";
142135
+ import fsPromises5 from "fs/promises";
142136
+ import path45 from "path";
142137
+ import { fileURLToPath as fileURLToPath12 } from "url";
141925
142138
 
141926
142139
  // src/commands/facebook-analysis/diagnosis-merge-snapshot.ts
141927
- import * as fs36 from "fs/promises";
141928
- import * as path43 from "path";
142140
+ import * as fs37 from "fs/promises";
142141
+ import * as path44 from "path";
141929
142142
  function asRecord29(value) {
141930
142143
  if (value && typeof value === "object" && !Array.isArray(value)) {
141931
142144
  return value;
@@ -141961,7 +142174,7 @@ async function readManifest4(snapshotDir, accountId) {
141961
142174
  const candidates = [];
141962
142175
  if (accountId) candidates.push(reportManifestFile(accountId));
141963
142176
  try {
141964
- const entries = await fs36.readdir(snapshotDir);
142177
+ const entries = await fs37.readdir(snapshotDir);
141965
142178
  const manifestNames = entries.filter(
141966
142179
  (n) => n.startsWith("report-manifest") && n.endsWith(".json")
141967
142180
  );
@@ -141975,7 +142188,7 @@ async function readManifest4(snapshotDir, accountId) {
141975
142188
  }
141976
142189
  for (const name2 of candidates) {
141977
142190
  try {
141978
- const raw = await fs36.readFile(path43.join(snapshotDir, name2), "utf8");
142191
+ const raw = await fs37.readFile(path44.join(snapshotDir, name2), "utf8");
141979
142192
  const parsed = JSON.parse(raw);
141980
142193
  if (Array.isArray(parsed.artifacts) && parsed.artifacts.length > 0) return parsed;
141981
142194
  } catch {
@@ -141985,14 +142198,14 @@ async function readManifest4(snapshotDir, accountId) {
141985
142198
  }
141986
142199
  async function loadSectionFile4(snapshotDir, file) {
141987
142200
  try {
141988
- const raw = await fs36.readFile(path43.join(snapshotDir, file), "utf8");
142201
+ const raw = await fs37.readFile(path44.join(snapshotDir, file), "utf8");
141989
142202
  return asRecord29(JSON.parse(raw));
141990
142203
  } catch {
141991
142204
  return null;
141992
142205
  }
141993
142206
  }
141994
142207
  async function mergeMetaDiagnosisSnapshotIntoReport(payload, snapshotDir) {
141995
- const absDir = path43.resolve(snapshotDir);
142208
+ const absDir = path44.resolve(snapshotDir);
141996
142209
  const metaAccountId = typeof asRecord29(payload.meta)?.accountId === "string" ? asRecord29(payload.meta)?.accountId : void 0;
141997
142210
  const manifest = await readManifest4(snapshotDir, metaAccountId);
141998
142211
  if (!manifest) {
@@ -142270,27 +142483,27 @@ function formatMetaDiagnosisReportErrors(result) {
142270
142483
  // src/commands/facebook-analysis/diagnosis-render-report.ts
142271
142484
  init_lang();
142272
142485
  init_html();
142273
- var TEMPLATE_BASENAME2 = "meta-account-diagnosis-report.html";
142486
+ var TEMPLATE_BASENAME3 = "meta-account-diagnosis-report.html";
142274
142487
  var INJECT_MARKER3 = "window.__META_DIAGNOSIS_REPORT__ = window.__META_DIAGNOSIS_REPORT__ || null;";
142275
- function resolveSkillTemplatePath5(basename13) {
142276
- const dir = path44.dirname(fileURLToPath11(import.meta.url));
142488
+ function resolveSkillTemplatePath6(basename13) {
142489
+ const dir = path45.dirname(fileURLToPath12(import.meta.url));
142277
142490
  const candidates = [
142278
- path44.join(dir, "skill", "report-templates", basename13),
142279
- path44.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
142280
- path44.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
142491
+ path45.join(dir, "skill", "report-templates", basename13),
142492
+ path45.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
142493
+ path45.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
142281
142494
  ];
142282
142495
  for (const p of candidates) {
142283
- if (fs37.existsSync(p)) return p;
142496
+ if (fs38.existsSync(p)) return p;
142284
142497
  }
142285
142498
  return candidates[0];
142286
142499
  }
142287
142500
  function metaDiagnosisReportTemplatePath() {
142288
- return resolveSkillTemplatePath5(TEMPLATE_BASENAME2);
142501
+ return resolveSkillTemplatePath6(TEMPLATE_BASENAME3);
142289
142502
  }
142290
- async function readJsonFile5(filePath) {
142291
- const text3 = await fsPromises4.readFile(filePath, "utf8");
142503
+ async function readJsonFile6(filePath) {
142504
+ const text4 = await fsPromises5.readFile(filePath, "utf8");
142292
142505
  try {
142293
- return JSON.parse(text3);
142506
+ return JSON.parse(text4);
142294
142507
  } catch {
142295
142508
  throw new Error(`\u65E0\u6CD5\u89E3\u6790 JSON\uFF1A${filePath}`);
142296
142509
  }
@@ -142310,10 +142523,10 @@ function injectReportData4(html, payload, lang) {
142310
142523
  return localized.replace(INJECT_MARKER3, `window.__META_DIAGNOSIS_REPORT__ = ${json};`);
142311
142524
  }
142312
142525
  async function runFacebookAnalysisDiagnosisRender(opts) {
142313
- const dataPath = path44.resolve(opts.dataFile);
142314
- let data = asRecord31(await readJsonFile5(dataPath));
142526
+ const dataPath = path45.resolve(opts.dataFile);
142527
+ let data = asRecord31(await readJsonFile6(dataPath));
142315
142528
  if (opts.snapshotDir?.trim()) {
142316
- data = await mergeMetaDiagnosisSnapshotIntoReport(data, path44.resolve(opts.snapshotDir));
142529
+ data = await mergeMetaDiagnosisSnapshotIntoReport(data, path45.resolve(opts.snapshotDir));
142317
142530
  }
142318
142531
  const lang = readReportLangOrExit({ flag: opts.lang, meta: data.meta });
142319
142532
  const contentCheck = validateMetaDiagnosisReportContent(data);
@@ -142332,7 +142545,7 @@ async function runFacebookAnalysisDiagnosisRender(opts) {
142332
142545
  const templatePath = metaDiagnosisReportTemplatePath();
142333
142546
  let html;
142334
142547
  try {
142335
- html = await fsPromises4.readFile(templatePath, "utf8");
142548
+ html = await fsPromises5.readFile(templatePath, "utf8");
142336
142549
  } catch {
142337
142550
  console.error(`
142338
142551
  \u274C \u672A\u627E\u5230\u62A5\u544A\u6A21\u677F\uFF1A${templatePath}
@@ -142340,12 +142553,12 @@ async function runFacebookAnalysisDiagnosisRender(opts) {
142340
142553
  `);
142341
142554
  process.exit(1);
142342
142555
  }
142343
- const outPath = path44.resolve(
142344
- opts.out ?? path44.join(path44.dirname(dataPath), "meta-account-diagnosis-report.html")
142556
+ const outPath = path45.resolve(
142557
+ opts.out ?? path45.join(path45.dirname(dataPath), "meta-account-diagnosis-report.html")
142345
142558
  );
142346
- const outDir = path44.dirname(outPath);
142347
- await fsPromises4.mkdir(outDir, { recursive: true });
142348
- await fsPromises4.writeFile(outPath, injectReportData4(html, data, lang), "utf8");
142559
+ const outDir = path45.dirname(outPath);
142560
+ await fsPromises5.mkdir(outDir, { recursive: true });
142561
+ await fsPromises5.writeFile(outPath, injectReportData4(html, data, lang), "utf8");
142349
142562
  const { stats } = contentCheck;
142350
142563
  console.log(`
142351
142564
  \u2705 Meta\uFF08Facebook\uFF09\u8D26\u6237\u8BCA\u65AD HTML \u62A5\u544A\u5DF2\u751F\u6210\uFF1A${outPath}
@@ -142361,7 +142574,7 @@ async function runFacebookAnalysisDiagnosisRender(opts) {
142361
142574
 
142362
142575
  // src/commands/facebook-analysis/run-batch.ts
142363
142576
  init_auth();
142364
- import * as path45 from "path";
142577
+ import * as path46 from "path";
142365
142578
  import { performance as performance5 } from "perf_hooks";
142366
142579
  init_version();
142367
142580
 
@@ -142463,7 +142676,7 @@ async function runAllFacebookSections(opts) {
142463
142676
  const results = await runWithConcurrency3(tasks, concurrency);
142464
142677
  const succeeded = results.filter((r) => r.ok).length;
142465
142678
  const failed = results.length - succeeded;
142466
- const absoluteSnapshotDir = path45.resolve(opts.jsonOut);
142679
+ const absoluteSnapshotDir = path46.resolve(opts.jsonOut);
142467
142680
  const summary = {
142468
142681
  kind: "siluzan-tso-facebook-analysis-snapshot-batch",
142469
142682
  absoluteSnapshotDir,
@@ -142587,9 +142800,9 @@ function parseEffectiveStatusFilter(raw) {
142587
142800
  }
142588
142801
  return canonical.length ? canonical.join(",") : void 0;
142589
142802
  }
142590
- function facebookAdsUrl(facebookApiUrl, digits, path56) {
142803
+ function facebookAdsUrl(facebookApiUrl, digits, path57) {
142591
142804
  const base2 = facebookApiUrl.replace(/\/$/, "");
142592
- const p = path56.startsWith("/") ? path56 : `/${path56}`;
142805
+ const p = path57.startsWith("/") ? path57 : `/${path57}`;
142593
142806
  return `${base2}/api/fb/ads/${digits}${p}`;
142594
142807
  }
142595
142808
  function facebookInsightsUrl(facebookApiUrl, digits, level) {
@@ -142626,7 +142839,7 @@ async function fetchFacebookAccount(config, digits, verbose) {
142626
142839
  verbose
142627
142840
  );
142628
142841
  }
142629
- async function fetchFacebookPagedList(config, digits, path56, opts) {
142842
+ async function fetchFacebookPagedList(config, digits, path57, opts) {
142630
142843
  const base2 = requireFacebookApi(config);
142631
142844
  const items3 = [];
142632
142845
  let after;
@@ -142641,7 +142854,7 @@ async function fetchFacebookPagedList(config, digits, path56, opts) {
142641
142854
  adsetId: opts.adsetId
142642
142855
  });
142643
142856
  const raw = await apiFetch2(
142644
- `${facebookAdsUrl(base2, digits, path56)}?${query}`,
142857
+ `${facebookAdsUrl(base2, digits, path57)}?${query}`,
142645
142858
  config,
142646
142859
  {},
142647
142860
  opts.verbose
@@ -142776,7 +142989,7 @@ async function runFacebookEntityList(opts, kind) {
142776
142989
  }
142777
142990
  const pageSize = resolveFacebookPageSize(opts.pageSize);
142778
142991
  const config = loadConfig(opts.token);
142779
- const path56 = `/${kind}`;
142992
+ const path57 = `/${kind}`;
142780
142993
  const labels = {
142781
142994
  campaigns: {
142782
142995
  section: "facebook-campaign-entities",
@@ -142789,7 +143002,7 @@ async function runFacebookEntityList(opts, kind) {
142789
143002
  const meta = labels[kind];
142790
143003
  let result;
142791
143004
  try {
142792
- result = await fetchFacebookPagedList(config, manifestId, path56, {
143005
+ result = await fetchFacebookPagedList(config, manifestId, path57, {
142793
143006
  pageSize,
142794
143007
  verbose: !!opts.verbose,
142795
143008
  effectiveStatus,
@@ -143537,7 +143750,7 @@ function endpointHintForBingSection(def) {
143537
143750
 
143538
143751
  // src/commands/bing-analysis/run-batch.ts
143539
143752
  init_auth();
143540
- import * as path46 from "path";
143753
+ import * as path47 from "path";
143541
143754
  import { performance as performance6 } from "perf_hooks";
143542
143755
  init_version();
143543
143756
  async function runWithConcurrency4(tasks, concurrency) {
@@ -143612,7 +143825,7 @@ async function runAllBingSections(opts) {
143612
143825
  const results = await runWithConcurrency4(tasks, concurrency);
143613
143826
  const succeeded = results.filter((r) => r.ok).length;
143614
143827
  const failed = results.length - succeeded;
143615
- const absoluteSnapshotDir = path46.resolve(opts.jsonOut);
143828
+ const absoluteSnapshotDir = path47.resolve(opts.jsonOut);
143616
143829
  const summary = {
143617
143830
  kind: "siluzan-tso-bing-analysis-snapshot-batch",
143618
143831
  absoluteSnapshotDir,
@@ -143956,14 +144169,14 @@ Bing \u5B98\u65B9\u6708\u6D88\u8017\uFF08${id}\uFF09
143956
144169
  import { Command as Command3 } from "commander";
143957
144170
 
143958
144171
  // src/commands/bing-analysis/render-report.ts
143959
- import fs39 from "fs";
143960
- import fsPromises5 from "fs/promises";
143961
- import path48 from "path";
143962
- import { fileURLToPath as fileURLToPath12 } from "url";
144172
+ import fs40 from "fs";
144173
+ import fsPromises6 from "fs/promises";
144174
+ import path49 from "path";
144175
+ import { fileURLToPath as fileURLToPath13 } from "url";
143963
144176
 
143964
144177
  // src/commands/bing-analysis/merge-snapshot.ts
143965
- import * as fs38 from "fs/promises";
143966
- import * as path47 from "path";
144178
+ import * as fs39 from "fs/promises";
144179
+ import * as path48 from "path";
143967
144180
  function asRecord33(value) {
143968
144181
  if (value && typeof value === "object" && !Array.isArray(value)) {
143969
144182
  return value;
@@ -143985,7 +144198,7 @@ function asRows2(value) {
143985
144198
  }
143986
144199
  async function loadSectionPayload(snapshotDir, file) {
143987
144200
  try {
143988
- const raw = await fs38.readFile(path47.join(snapshotDir, file), "utf8");
144201
+ const raw = await fs39.readFile(path48.join(snapshotDir, file), "utf8");
143989
144202
  return JSON.parse(raw);
143990
144203
  } catch {
143991
144204
  return null;
@@ -143995,7 +144208,7 @@ async function readManifest5(snapshotDir, accountId) {
143995
144208
  const candidates = [];
143996
144209
  if (accountId) candidates.push(reportManifestFile(accountId));
143997
144210
  try {
143998
- const entries = await fs38.readdir(snapshotDir);
144211
+ const entries = await fs39.readdir(snapshotDir);
143999
144212
  const manifestNames = entries.filter(
144000
144213
  (n) => n.startsWith("report-manifest") && n.endsWith(".json")
144001
144214
  );
@@ -144006,7 +144219,7 @@ async function readManifest5(snapshotDir, accountId) {
144006
144219
  }
144007
144220
  for (const name2 of candidates) {
144008
144221
  try {
144009
- const raw = await fs38.readFile(path47.join(snapshotDir, name2), "utf8");
144222
+ const raw = await fs39.readFile(path48.join(snapshotDir, name2), "utf8");
144010
144223
  const parsed = JSON.parse(raw);
144011
144224
  if (Array.isArray(parsed.artifacts) && parsed.artifacts.length > 0) return parsed;
144012
144225
  } catch {
@@ -144173,7 +144386,7 @@ function mapSearchTermRows(payload) {
144173
144386
  );
144174
144387
  }
144175
144388
  async function mergeBingAnalysisSnapshotIntoReport(payload, snapshotDir) {
144176
- const absDir = path47.resolve(snapshotDir);
144389
+ const absDir = path48.resolve(snapshotDir);
144177
144390
  const metaAccountId = typeof asRecord33(payload.meta)?.accountId === "string" ? asRecord33(payload.meta)?.accountId : void 0;
144178
144391
  const manifest = await readManifest5(snapshotDir, metaAccountId);
144179
144392
  if (!manifest) {
@@ -144408,27 +144621,27 @@ function formatBingPeriodReportErrors(result) {
144408
144621
  init_report_period();
144409
144622
  init_lang();
144410
144623
  init_html();
144411
- var TEMPLATE_BASENAME3 = "bing-period-report.html";
144624
+ var TEMPLATE_BASENAME4 = "bing-period-report.html";
144412
144625
  var INJECT_MARKER4 = "window.__BING_PERIOD_REPORT__ = window.__BING_PERIOD_REPORT__ || null;";
144413
- function resolveSkillTemplatePath6(basename13) {
144414
- const dir = path48.dirname(fileURLToPath12(import.meta.url));
144626
+ function resolveSkillTemplatePath7(basename13) {
144627
+ const dir = path49.dirname(fileURLToPath13(import.meta.url));
144415
144628
  const candidates = [
144416
- path48.join(dir, "skill", "report-templates", basename13),
144417
- path48.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
144418
- path48.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
144629
+ path49.join(dir, "skill", "report-templates", basename13),
144630
+ path49.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
144631
+ path49.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
144419
144632
  ];
144420
144633
  for (const p of candidates) {
144421
- if (fs39.existsSync(p)) return p;
144634
+ if (fs40.existsSync(p)) return p;
144422
144635
  }
144423
144636
  return candidates[0];
144424
144637
  }
144425
144638
  function bingPeriodReportTemplatePath() {
144426
- return resolveSkillTemplatePath6(TEMPLATE_BASENAME3);
144639
+ return resolveSkillTemplatePath7(TEMPLATE_BASENAME4);
144427
144640
  }
144428
- async function readJsonFile6(filePath) {
144429
- const text3 = await fsPromises5.readFile(filePath, "utf8");
144641
+ async function readJsonFile7(filePath) {
144642
+ const text4 = await fsPromises6.readFile(filePath, "utf8");
144430
144643
  try {
144431
- return JSON.parse(text3);
144644
+ return JSON.parse(text4);
144432
144645
  } catch {
144433
144646
  throw new Error(`\u65E0\u6CD5\u89E3\u6790 JSON\uFF1A${filePath}`);
144434
144647
  }
@@ -144448,10 +144661,10 @@ function injectReportData5(html, payload, lang) {
144448
144661
  return localized.replace(INJECT_MARKER4, `window.__BING_PERIOD_REPORT__ = ${json};`);
144449
144662
  }
144450
144663
  async function runBingAnalysisRender(opts) {
144451
- const dataPath = path48.resolve(opts.dataFile);
144452
- let data = asRecord35(await readJsonFile6(dataPath));
144664
+ const dataPath = path49.resolve(opts.dataFile);
144665
+ let data = asRecord35(await readJsonFile7(dataPath));
144453
144666
  if (opts.snapshotDir?.trim()) {
144454
- data = await mergeBingAnalysisSnapshotIntoReport(data, path48.resolve(opts.snapshotDir));
144667
+ data = await mergeBingAnalysisSnapshotIntoReport(data, path49.resolve(opts.snapshotDir));
144455
144668
  }
144456
144669
  const lang = readReportLangOrExit({ flag: opts.lang, meta: data.meta });
144457
144670
  const contentCheck = validateBingPeriodReportContent(data);
@@ -144470,7 +144683,7 @@ async function runBingAnalysisRender(opts) {
144470
144683
  const templatePath = bingPeriodReportTemplatePath();
144471
144684
  let html;
144472
144685
  try {
144473
- html = await fsPromises5.readFile(templatePath, "utf8");
144686
+ html = await fsPromises6.readFile(templatePath, "utf8");
144474
144687
  } catch {
144475
144688
  console.error(`
144476
144689
  \u274C \u672A\u627E\u5230\u62A5\u544A\u6A21\u677F\uFF1A${templatePath}
@@ -144478,12 +144691,12 @@ async function runBingAnalysisRender(opts) {
144478
144691
  `);
144479
144692
  process.exit(1);
144480
144693
  }
144481
- const outPath = path48.resolve(
144482
- opts.out ?? path48.join(path48.dirname(dataPath), "bing-period-report.html")
144694
+ const outPath = path49.resolve(
144695
+ opts.out ?? path49.join(path49.dirname(dataPath), "bing-period-report.html")
144483
144696
  );
144484
- const outDir = path48.dirname(outPath);
144485
- await fsPromises5.mkdir(outDir, { recursive: true });
144486
- await fsPromises5.writeFile(outPath, injectReportData5(html, data, lang), "utf8");
144697
+ const outDir = path49.dirname(outPath);
144698
+ await fsPromises6.mkdir(outDir, { recursive: true });
144699
+ await fsPromises6.writeFile(outPath, injectReportData5(html, data, lang), "utf8");
144487
144700
  const { stats } = contentCheck;
144488
144701
  const cover = periodWord(attachPeriodChrome(data).periodChrome.unit, "\u8D26\u6237");
144489
144702
  console.log(`
@@ -144819,7 +145032,7 @@ async function fetchTikTokInterestList(config, account, verbose) {
144819
145032
 
144820
145033
  // src/commands/tiktok-analysis/run-batch.ts
144821
145034
  init_auth();
144822
- import * as path49 from "path";
145035
+ import * as path50 from "path";
144823
145036
  import { performance as performance7 } from "perf_hooks";
144824
145037
  init_version();
144825
145038
  async function runWithConcurrency5(tasks, concurrency) {
@@ -144894,7 +145107,7 @@ async function runAllTikTokSections(opts) {
144894
145107
  const results = await runWithConcurrency5(tasks, concurrency);
144895
145108
  const succeeded = results.filter((r) => r.ok).length;
144896
145109
  const failed = results.length - succeeded;
144897
- const absoluteSnapshotDir = path49.resolve(opts.jsonOut);
145110
+ const absoluteSnapshotDir = path50.resolve(opts.jsonOut);
144898
145111
  const summary = {
144899
145112
  kind: "siluzan-tso-tiktok-analysis-snapshot-batch",
144900
145113
  absoluteSnapshotDir,
@@ -144917,14 +145130,14 @@ init_auth();
144917
145130
  import { Command as Command4 } from "commander";
144918
145131
 
144919
145132
  // src/commands/tiktok-analysis/render-report.ts
144920
- import fs41 from "fs";
144921
- import fsPromises6 from "fs/promises";
144922
- import path51 from "path";
144923
- import { fileURLToPath as fileURLToPath13 } from "url";
145133
+ import fs42 from "fs";
145134
+ import fsPromises7 from "fs/promises";
145135
+ import path52 from "path";
145136
+ import { fileURLToPath as fileURLToPath14 } from "url";
144924
145137
 
144925
145138
  // src/commands/tiktok-analysis/merge-snapshot.ts
144926
- import * as fs40 from "fs/promises";
144927
- import * as path50 from "path";
145139
+ import * as fs41 from "fs/promises";
145140
+ import * as path51 from "path";
144928
145141
  function asRecord36(value) {
144929
145142
  if (value && typeof value === "object" && !Array.isArray(value)) {
144930
145143
  return value;
@@ -144940,7 +145153,7 @@ function round28(value) {
144940
145153
  }
144941
145154
  async function loadSectionPayload2(snapshotDir, file) {
144942
145155
  try {
144943
- const raw = await fs40.readFile(path50.join(snapshotDir, file), "utf8");
145156
+ const raw = await fs41.readFile(path51.join(snapshotDir, file), "utf8");
144944
145157
  return JSON.parse(raw);
144945
145158
  } catch {
144946
145159
  return null;
@@ -144950,7 +145163,7 @@ async function readManifest6(snapshotDir, accountId) {
144950
145163
  const candidates = [];
144951
145164
  if (accountId) candidates.push(reportManifestFile(accountId));
144952
145165
  try {
144953
- const entries = await fs40.readdir(snapshotDir);
145166
+ const entries = await fs41.readdir(snapshotDir);
144954
145167
  const manifestNames = entries.filter(
144955
145168
  (n) => n.startsWith("report-manifest") && n.endsWith(".json")
144956
145169
  );
@@ -144961,7 +145174,7 @@ async function readManifest6(snapshotDir, accountId) {
144961
145174
  }
144962
145175
  for (const name2 of candidates) {
144963
145176
  try {
144964
- const raw = await fs40.readFile(path50.join(snapshotDir, name2), "utf8");
145177
+ const raw = await fs41.readFile(path51.join(snapshotDir, name2), "utf8");
144965
145178
  const parsed = JSON.parse(raw);
144966
145179
  if (Array.isArray(parsed.artifacts) && parsed.artifacts.length > 0) return parsed;
144967
145180
  } catch {
@@ -145102,7 +145315,7 @@ function mapAudienceMerged(payload) {
145102
145315
  };
145103
145316
  }
145104
145317
  async function mergeTikTokAnalysisSnapshotIntoReport(payload, snapshotDir) {
145105
- const absDir = path50.resolve(snapshotDir);
145318
+ const absDir = path51.resolve(snapshotDir);
145106
145319
  const metaAccountId = typeof asRecord36(payload.meta)?.accountId === "string" ? asRecord36(payload.meta)?.accountId : void 0;
145107
145320
  const manifest = await readManifest6(snapshotDir, metaAccountId);
145108
145321
  if (!manifest) {
@@ -145312,27 +145525,27 @@ function formatTikTokPeriodReportErrors(result) {
145312
145525
  init_report_period();
145313
145526
  init_lang();
145314
145527
  init_html();
145315
- var TEMPLATE_BASENAME4 = "tiktok-period-report.html";
145528
+ var TEMPLATE_BASENAME5 = "tiktok-period-report.html";
145316
145529
  var INJECT_MARKER5 = "window.__TIKTOK_PERIOD_REPORT__ = window.__TIKTOK_PERIOD_REPORT__ || null;";
145317
- function resolveSkillTemplatePath7(basename13) {
145318
- const dir = path51.dirname(fileURLToPath13(import.meta.url));
145530
+ function resolveSkillTemplatePath8(basename13) {
145531
+ const dir = path52.dirname(fileURLToPath14(import.meta.url));
145319
145532
  const candidates = [
145320
- path51.join(dir, "skill", "report-templates", basename13),
145321
- path51.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
145322
- path51.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
145533
+ path52.join(dir, "skill", "report-templates", basename13),
145534
+ path52.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
145535
+ path52.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
145323
145536
  ];
145324
145537
  for (const p of candidates) {
145325
- if (fs41.existsSync(p)) return p;
145538
+ if (fs42.existsSync(p)) return p;
145326
145539
  }
145327
145540
  return candidates[0];
145328
145541
  }
145329
145542
  function tiktokPeriodReportTemplatePath() {
145330
- return resolveSkillTemplatePath7(TEMPLATE_BASENAME4);
145543
+ return resolveSkillTemplatePath8(TEMPLATE_BASENAME5);
145331
145544
  }
145332
- async function readJsonFile7(filePath) {
145333
- const text3 = await fsPromises6.readFile(filePath, "utf8");
145545
+ async function readJsonFile8(filePath) {
145546
+ const text4 = await fsPromises7.readFile(filePath, "utf8");
145334
145547
  try {
145335
- return JSON.parse(text3);
145548
+ return JSON.parse(text4);
145336
145549
  } catch {
145337
145550
  throw new Error(`\u65E0\u6CD5\u89E3\u6790 JSON\uFF1A${filePath}`);
145338
145551
  }
@@ -145352,10 +145565,10 @@ function injectReportData6(html, payload, lang) {
145352
145565
  return localized.replace(INJECT_MARKER5, `window.__TIKTOK_PERIOD_REPORT__ = ${json};`);
145353
145566
  }
145354
145567
  async function runTikTokAnalysisRender(opts) {
145355
- const dataPath = path51.resolve(opts.dataFile);
145356
- let data = asRecord38(await readJsonFile7(dataPath));
145568
+ const dataPath = path52.resolve(opts.dataFile);
145569
+ let data = asRecord38(await readJsonFile8(dataPath));
145357
145570
  if (opts.snapshotDir?.trim()) {
145358
- data = await mergeTikTokAnalysisSnapshotIntoReport(data, path51.resolve(opts.snapshotDir));
145571
+ data = await mergeTikTokAnalysisSnapshotIntoReport(data, path52.resolve(opts.snapshotDir));
145359
145572
  }
145360
145573
  const lang = readReportLangOrExit({ flag: opts.lang, meta: data.meta });
145361
145574
  const contentCheck = validateTikTokPeriodReportContent(data);
@@ -145374,7 +145587,7 @@ async function runTikTokAnalysisRender(opts) {
145374
145587
  const templatePath = tiktokPeriodReportTemplatePath();
145375
145588
  let html;
145376
145589
  try {
145377
- html = await fsPromises6.readFile(templatePath, "utf8");
145590
+ html = await fsPromises7.readFile(templatePath, "utf8");
145378
145591
  } catch {
145379
145592
  console.error(`
145380
145593
  \u274C \u672A\u627E\u5230\u62A5\u544A\u6A21\u677F\uFF1A${templatePath}
@@ -145382,12 +145595,12 @@ async function runTikTokAnalysisRender(opts) {
145382
145595
  `);
145383
145596
  process.exit(1);
145384
145597
  }
145385
- const outPath = path51.resolve(
145386
- opts.out ?? path51.join(path51.dirname(dataPath), "tiktok-period-report.html")
145598
+ const outPath = path52.resolve(
145599
+ opts.out ?? path52.join(path52.dirname(dataPath), "tiktok-period-report.html")
145387
145600
  );
145388
- const outDir = path51.dirname(outPath);
145389
- await fsPromises6.mkdir(outDir, { recursive: true });
145390
- await fsPromises6.writeFile(outPath, injectReportData6(html, data, lang), "utf8");
145601
+ const outDir = path52.dirname(outPath);
145602
+ await fsPromises7.mkdir(outDir, { recursive: true });
145603
+ await fsPromises7.writeFile(outPath, injectReportData6(html, data, lang), "utf8");
145391
145604
  const { stats } = contentCheck;
145392
145605
  const cover = periodWord(attachPeriodChrome(data).periodChrome.unit, "\u8D26\u6237");
145393
145606
  console.log(`
@@ -146313,7 +146526,7 @@ var YANDEX_SECTION_ALIASES = {
146313
146526
 
146314
146527
  // src/commands/yandex-analysis/run-batch.ts
146315
146528
  init_auth();
146316
- import * as path53 from "path";
146529
+ import * as path54 from "path";
146317
146530
  import { performance as performance8 } from "perf_hooks";
146318
146531
  init_version();
146319
146532
 
@@ -146453,8 +146666,8 @@ function endpointHintForYandexSection(def) {
146453
146666
  }
146454
146667
 
146455
146668
  // src/commands/yandex-analysis/merge-snapshot.ts
146456
- import * as fs42 from "fs/promises";
146457
- import * as path52 from "path";
146669
+ import * as fs43 from "fs/promises";
146670
+ import * as path53 from "path";
146458
146671
  function asRecord39(value) {
146459
146672
  if (value && typeof value === "object" && !Array.isArray(value)) {
146460
146673
  return value;
@@ -146504,7 +146717,7 @@ function pickMetrics2(row, extras = []) {
146504
146717
  }
146505
146718
  async function loadSectionPayload3(snapshotDir, file) {
146506
146719
  try {
146507
- const raw = await fs42.readFile(path52.join(snapshotDir, file), "utf8");
146720
+ const raw = await fs43.readFile(path53.join(snapshotDir, file), "utf8");
146508
146721
  return JSON.parse(raw);
146509
146722
  } catch {
146510
146723
  return null;
@@ -146514,7 +146727,7 @@ async function readManifest7(snapshotDir, accountId) {
146514
146727
  const candidates = [];
146515
146728
  if (accountId) candidates.push(reportManifestFile(accountId));
146516
146729
  try {
146517
- const entries = await fs42.readdir(snapshotDir);
146730
+ const entries = await fs43.readdir(snapshotDir);
146518
146731
  for (const name2 of entries.filter(
146519
146732
  (n) => n.startsWith("report-manifest") && n.endsWith(".json")
146520
146733
  )) {
@@ -146524,7 +146737,7 @@ async function readManifest7(snapshotDir, accountId) {
146524
146737
  }
146525
146738
  for (const name2 of candidates) {
146526
146739
  try {
146527
- const raw = await fs42.readFile(path52.join(snapshotDir, name2), "utf8");
146740
+ const raw = await fs43.readFile(path53.join(snapshotDir, name2), "utf8");
146528
146741
  const parsed = JSON.parse(raw);
146529
146742
  if (Array.isArray(parsed.artifacts) && parsed.artifacts.length > 0) return parsed;
146530
146743
  } catch {
@@ -146683,7 +146896,7 @@ function mapDeviceRows2(payload) {
146683
146896
  return asItems(payload).map((r) => pickMetrics2(r, ["device", "network"]));
146684
146897
  }
146685
146898
  async function mergeYandexAnalysisSnapshotIntoReport(payload, snapshotDir) {
146686
- const absDir = path52.resolve(snapshotDir);
146899
+ const absDir = path53.resolve(snapshotDir);
146687
146900
  const metaAccountId = typeof asRecord39(payload.meta)?.accountId === "string" ? asRecord39(payload.meta)?.accountId : void 0;
146688
146901
  const manifest = await readManifest7(snapshotDir, metaAccountId);
146689
146902
  if (!manifest) {
@@ -146869,7 +147082,7 @@ async function runAllYandexSections(opts) {
146869
147082
  const results = await runWithConcurrency6(tasks, concurrency);
146870
147083
  const succeeded = results.filter((r) => r.ok).length;
146871
147084
  const failed = results.length - succeeded;
146872
- const absoluteSnapshotDir = path53.resolve(opts.jsonOut);
147085
+ const absoluteSnapshotDir = path54.resolve(opts.jsonOut);
146873
147086
  const summary = {
146874
147087
  kind: "siluzan-tso-yandex-analysis-snapshot-batch",
146875
147088
  absoluteSnapshotDir,
@@ -146887,10 +147100,10 @@ async function runAllYandexSections(opts) {
146887
147100
  }
146888
147101
 
146889
147102
  // src/commands/yandex-analysis/render-report.ts
146890
- import fs43 from "fs";
146891
- import fsPromises7 from "fs/promises";
146892
- import path54 from "path";
146893
- import { fileURLToPath as fileURLToPath14 } from "url";
147103
+ import fs44 from "fs";
147104
+ import fsPromises8 from "fs/promises";
147105
+ import path55 from "path";
147106
+ import { fileURLToPath as fileURLToPath15 } from "url";
146894
147107
 
146895
147108
  // src/commands/yandex-analysis/report-content.ts
146896
147109
  var SECTION_KEYS4 = [
@@ -147093,27 +147306,27 @@ function formatYandexPeriodReportErrors(result) {
147093
147306
  init_report_period();
147094
147307
  init_lang();
147095
147308
  init_html();
147096
- var TEMPLATE_BASENAME5 = "yandex-period-report.html";
147309
+ var TEMPLATE_BASENAME6 = "yandex-period-report.html";
147097
147310
  var INJECT_MARKER6 = "window.__YANDEX_PERIOD_REPORT__ = window.__YANDEX_PERIOD_REPORT__ || null;";
147098
- function resolveSkillTemplatePath8(basename13) {
147099
- const dir = path54.dirname(fileURLToPath14(import.meta.url));
147311
+ function resolveSkillTemplatePath9(basename13) {
147312
+ const dir = path55.dirname(fileURLToPath15(import.meta.url));
147100
147313
  const candidates = [
147101
- path54.join(dir, "skill", "report-templates", basename13),
147102
- path54.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
147103
- path54.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
147314
+ path55.join(dir, "skill", "report-templates", basename13),
147315
+ path55.join(dir, "skill", "siluzan-ads", "report-templates", basename13),
147316
+ path55.join(dir, "..", "..", "assets", "siluzan-ads", "report-templates", basename13)
147104
147317
  ];
147105
147318
  for (const p of candidates) {
147106
- if (fs43.existsSync(p)) return p;
147319
+ if (fs44.existsSync(p)) return p;
147107
147320
  }
147108
147321
  return candidates[0];
147109
147322
  }
147110
147323
  function yandexPeriodReportTemplatePath() {
147111
- return resolveSkillTemplatePath8(TEMPLATE_BASENAME5);
147324
+ return resolveSkillTemplatePath9(TEMPLATE_BASENAME6);
147112
147325
  }
147113
- async function readJsonFile8(filePath) {
147114
- const text3 = await fsPromises7.readFile(filePath, "utf8");
147326
+ async function readJsonFile9(filePath) {
147327
+ const text4 = await fsPromises8.readFile(filePath, "utf8");
147115
147328
  try {
147116
- return JSON.parse(text3);
147329
+ return JSON.parse(text4);
147117
147330
  } catch {
147118
147331
  throw new Error(`\u65E0\u6CD5\u89E3\u6790 JSON\uFF1A${filePath}`);
147119
147332
  }
@@ -147146,10 +147359,10 @@ function injectReportData7(html, payload, lang) {
147146
147359
  return localized.replace(INJECT_MARKER6, `window.__YANDEX_PERIOD_REPORT__ = ${json};`);
147147
147360
  }
147148
147361
  async function runYandexAnalysisRender(opts) {
147149
- const dataPath = path54.resolve(opts.dataFile);
147150
- let data = asRecord41(await readJsonFile8(dataPath));
147362
+ const dataPath = path55.resolve(opts.dataFile);
147363
+ let data = asRecord41(await readJsonFile9(dataPath));
147151
147364
  if (opts.snapshotDir?.trim()) {
147152
- data = await mergeYandexAnalysisSnapshotIntoReport(data, path54.resolve(opts.snapshotDir));
147365
+ data = await mergeYandexAnalysisSnapshotIntoReport(data, path55.resolve(opts.snapshotDir));
147153
147366
  }
147154
147367
  data = refreshWeeklyFromDaily(data);
147155
147368
  const lang = readReportLangOrExit({ flag: opts.lang, meta: data.meta });
@@ -147167,7 +147380,7 @@ async function runYandexAnalysisRender(opts) {
147167
147380
  const templatePath = yandexPeriodReportTemplatePath();
147168
147381
  let html;
147169
147382
  try {
147170
- html = await fsPromises7.readFile(templatePath, "utf8");
147383
+ html = await fsPromises8.readFile(templatePath, "utf8");
147171
147384
  } catch {
147172
147385
  console.error(`
147173
147386
  \u274C \u672A\u627E\u5230\u62A5\u544A\u6A21\u677F\uFF1A${templatePath}
@@ -147175,12 +147388,12 @@ async function runYandexAnalysisRender(opts) {
147175
147388
  `);
147176
147389
  process.exit(1);
147177
147390
  }
147178
- const outPath = path54.resolve(
147179
- opts.out ?? path54.join(path54.dirname(dataPath), "yandex-period-report.html")
147391
+ const outPath = path55.resolve(
147392
+ opts.out ?? path55.join(path55.dirname(dataPath), "yandex-period-report.html")
147180
147393
  );
147181
- const outDir = path54.dirname(outPath);
147182
- await fsPromises7.mkdir(outDir, { recursive: true });
147183
- await fsPromises7.writeFile(outPath, injectReportData7(html, data, lang), "utf8");
147394
+ const outDir = path55.dirname(outPath);
147395
+ await fsPromises8.mkdir(outDir, { recursive: true });
147396
+ await fsPromises8.writeFile(outPath, injectReportData7(html, data, lang), "utf8");
147184
147397
  const { stats } = contentCheck;
147185
147398
  const cover = periodWord(attachPeriodChrome(data).periodChrome.unit, "\u8D26\u6237");
147186
147399
  console.log(`
@@ -147279,13 +147492,13 @@ function optionalId(raw) {
147279
147492
  function insightsLevelToPath(level) {
147280
147493
  return level;
147281
147494
  }
147282
- function assertYandexAnalysisQuery(path56, query) {
147283
- const caps = YANDEX_PATH_CAPS[path56];
147495
+ function assertYandexAnalysisQuery(path57, query) {
147496
+ const caps = YANDEX_PATH_CAPS[path57];
147284
147497
  if (query.timeIncrement != null && !caps.timeIncrement) {
147285
- throw new Error(`--time-increment \u4E0D\u80FD\u7528\u4E8E /${path56}\uFF08\u4EC5 campaigns / adgroups / ads\uFF09\u3002`);
147498
+ throw new Error(`--time-increment \u4E0D\u80FD\u7528\u4E8E /${path57}\uFF08\u4EC5 campaigns / adgroups / ads\uFF09\u3002`);
147286
147499
  }
147287
147500
  if (query.network != null && !caps.network) {
147288
- throw new Error(`--network \u4E0D\u80FD\u7528\u4E8E /${path56}\uFF08\u4EC5 campaigns / geo / devices\uFF09\u3002`);
147501
+ throw new Error(`--network \u4E0D\u80FD\u7528\u4E8E /${path57}\uFF08\u4EC5 campaigns / geo / devices\uFF09\u3002`);
147289
147502
  }
147290
147503
  if (query.status != null && !caps.status) {
147291
147504
  throw new Error(`--status \u4EC5\u7528\u4E8E /ads\uFF08\u62D2\u5BA1/\u5BA1\u6838\u6001\u8D70\u7ED3\u6784\u67E5\u8BE2\uFF0C\u884C\u5185 spend \u4E3A 0\uFF09\u3002`);
@@ -147302,12 +147515,12 @@ function assertYandexAnalysisQuery(path56, query) {
147302
147515
  );
147303
147516
  }
147304
147517
  if (query.limit != null && !caps.limit) {
147305
- throw new Error(`--limit \u4E0D\u80FD\u7528\u4E8E /${path56}\uFF08overview / daily / devices \u65E0\u6B64\u53C2\u6570\uFF09\u3002`);
147518
+ throw new Error(`--limit \u4E0D\u80FD\u7528\u4E8E /${path57}\uFF08overview / daily / devices \u65E0\u6B64\u53C2\u6570\uFF09\u3002`);
147306
147519
  }
147307
147520
  }
147308
- function buildYandexAnalysisSearchParams(path56, query) {
147309
- assertYandexAnalysisQuery(path56, query);
147310
- const caps = YANDEX_PATH_CAPS[path56];
147521
+ function buildYandexAnalysisSearchParams(path57, query) {
147522
+ assertYandexAnalysisQuery(path57, query);
147523
+ const caps = YANDEX_PATH_CAPS[path57];
147311
147524
  const params = new URLSearchParams({
147312
147525
  account: query.account,
147313
147526
  start: query.start,
@@ -147333,10 +147546,10 @@ function buildYandexAnalysisSearchParams(path56, query) {
147333
147546
  }
147334
147547
  return params;
147335
147548
  }
147336
- async function fetchYandexAnalysisPath(config, path56, query, verbose) {
147549
+ async function fetchYandexAnalysisPath(config, path57, query, verbose) {
147337
147550
  const yandexApiUrl = requireYandexApi(config);
147338
- const params = buildYandexAnalysisSearchParams(path56, query);
147339
- const url = analysisUrl(yandexApiUrl, path56, params.toString());
147551
+ const params = buildYandexAnalysisSearchParams(path57, query);
147552
+ const url = analysisUrl(yandexApiUrl, path57, params.toString());
147340
147553
  return apiFetch2(url, config, {}, verbose);
147341
147554
  }
147342
147555
  function unwrapYandexItems(raw) {
@@ -147400,13 +147613,13 @@ ${args.title}
147400
147613
  console.log(` ${args.footnote}
147401
147614
  `);
147402
147615
  }
147403
- async function fetchPath(opts, path56, extra) {
147616
+ async function fetchPath(opts, path57, extra) {
147404
147617
  const accountId = assertYandexAccountId(opts.account);
147405
147618
  const { startDate, endDate } = resolveRange(opts.start, opts.end);
147406
147619
  const config = loadConfig(opts.token);
147407
147620
  const raw = await fetchYandexAnalysisPath(
147408
147621
  config,
147409
- path56,
147622
+ path57,
147410
147623
  {
147411
147624
  account: accountId,
147412
147625
  start: startDate,
@@ -147775,12 +147988,12 @@ function hasDateFromTo(args) {
147775
147988
  }
147776
147989
  var RERUN_HINT = "\u7ACB\u523B\u6539\u8DD1\u63D0\u793A\u4E2D\u7684\u90A3\u6761\uFF0C\u4E0D\u8981\u505C\u5728\u9519\u8BEF\u547D\u4EE4\u3002";
147777
147990
  function fatal(body) {
147778
- const text3 = body.replace(/\s+$/g, "");
147779
- if (text3.includes(RERUN_HINT)) return `
147780
- ${text3}
147991
+ const text4 = body.replace(/\s+$/g, "");
147992
+ if (text4.includes(RERUN_HINT)) return `
147993
+ ${text4}
147781
147994
  `;
147782
147995
  return `
147783
- ${text3}
147996
+ ${text4}
147784
147997
  ${RERUN_HINT}
147785
147998
  `;
147786
147999
  }
@@ -147930,9 +148143,9 @@ function interceptAgentCompatArgv(argv) {
147930
148143
  installProcessHandlers();
147931
148144
  function getVersion() {
147932
148145
  try {
147933
- const __dirname3 = path55.dirname(fileURLToPath15(import.meta.url));
147934
- const pkgPath = path55.join(__dirname3, "..", "package.json");
147935
- const pkg = JSON.parse(fs44.readFileSync(pkgPath, "utf8"));
148146
+ const __dirname3 = path56.dirname(fileURLToPath16(import.meta.url));
148147
+ const pkgPath = path56.join(__dirname3, "..", "package.json");
148148
+ const pkg = JSON.parse(fs45.readFileSync(pkgPath, "utf8"));
147936
148149
  return pkg.version ?? "0.0.0";
147937
148150
  } catch {
147938
148151
  return "0.0.0";