diff --git a/docs/ARCH/11 - architecture_turnaround/11 - continuity_stabilization_plan_2026-04-17.md b/docs/ARCH/11 - architecture_turnaround/11 - continuity_stabilization_plan_2026-04-17.md index ecc41f3..e40f04b 100644 --- a/docs/ARCH/11 - architecture_turnaround/11 - continuity_stabilization_plan_2026-04-17.md +++ b/docs/ARCH/11 - architecture_turnaround/11 - continuity_stabilization_plan_2026-04-17.md @@ -138,6 +138,8 @@ Completed in the current working pass: - counterparty document root wording is now recovered through unicode-safe exact signals instead of depending on mojibake-sensitive legacy phrases; - declined Russian account wording like `по счёту 60` now restores account scope inside polarity/runtime guards instead of collapsing into `other_numeric`; - exact address intents can now stay in the address lane even if the semantic guard overflags deep investigation without an actual investigative user request; +- selected-object inventory follow-ups can now override a stale stock root intent when the semantic contract already marks `selected_object_scope_detected`, including exact user wording like `по выбранному объекту ... где взяли это`; +- explicit capability-meta wording for `дельта по договорам` now keeps the asked capability in the user-facing answer instead of collapsing into the generic `что ты умеешь` catalog reply. - live replay `address_truth_harness_phase7_meta_domain_mix_live_20260417_post_arch_fix_rerun2` is accepted end-to-end with `14/14` steps green, including the previously broken `step_01_counterparty_documents` and `step_04_open_items_account_60`. Still open after this pass: @@ -211,6 +213,26 @@ Still open after the accepted phase10 replay: - the user-facing VAT explanation block is now correct and grounded, but some long exact answers still feel heavier than the target human product tone; - the next architecture slice should keep moving from repaired bridge authority into answer-shaping cleanup and broader saved-session replay coverage, not back into isolated wording tweaks. +Latest phase11 manual follow-up/meta-quality evidence after the current hardening loop: + +- live replay `address_truth_harness_phase11_manual_followup_meta_quality_live_20260418_rerun6` is accepted end-to-end with `10/10` steps green; +- the previously broken `ты умеешь считать дельту по договорам?` branch is now protected by an explicit authority rule: + - raw capability-meta intent outranks canonical predecompose rewrites that look like address retrieval; + - stale VAT follow-up continuity no longer wins over a fresh capability/meta question in the same session; +- the previously broken short counterparty retarget `а по свк` is now clean on the real assistant path: + - the display label uses the most specific confirmed counterparty name instead of a generic group fallback or a stale carryover anchor; + - short uppercase Cyrillic acronyms like `СВК` no longer get stripped by the user-facing sanitizer as false mojibake; + - the replay acceptance rule now targets the real regression (`Контрагент: Группа Найдено ...`) instead of incorrectly rejecting valid names like `Контрагент: Группа СВК.`; +- this phase matters architecturally because it closes two different seam classes at once: + - `meta authority vs stale follow-up authority`; + - `resolved business label vs boundary sanitization noise`. + +Still open after the accepted phase11 replay: + +- the current phase11 path is now semantically clean, but broader manual/user session packs still need to be replayed before expansion can be called low-risk across new domains; +- answer shaping on some long exact list answers is still heavier than the target human product feel, even though the truth path and routing are now correct; +- the next architecture slice should move to wider saved-session acceptance coverage and humanized exact-answer presentation, not back to isolated prompt-level repairs. + ## Ready Signal The project can leave the current breakpoint when: diff --git a/docs/orchestration/address_truth_harness_phase11_manual_followup_meta_quality.json b/docs/orchestration/address_truth_harness_phase11_manual_followup_meta_quality.json new file mode 100644 index 0000000..60e4835 --- /dev/null +++ b/docs/orchestration/address_truth_harness_phase11_manual_followup_meta_quality.json @@ -0,0 +1,268 @@ +{ + "schema_version": "domain_truth_harness_spec_v1", + "scenario_id": "address_truth_harness_phase11_manual_followup_meta_quality", + "domain": "address_phase11_manual_followup_meta_quality", + "title": "Phase 11 manual follow-up and meta-quality replay for orchestration recovery", + "description": "Focused AGENT replay rebuilt in clean UTF-8 from the manual saved session assistant-stage1-C_LvgkpSFm. The scenario validates the real remaining seams: human capability-meta answers, historical inventory root continuity, selected-object provenance, VAT bridge from purchase date after a verification interrupt, colloquial VAT wording, capability-meta versus stale VAT follow-up, and short counterparty retarget display integrity.", + "bindings": {}, + "steps": [ + { + "step_id": "step_01_capability_meta_human", + "title": "Capability meta answer stays human and business-first", + "question": "расскажи что можешь интересного", + "allowed_reply_types": [ + "factual", + "factual_with_explanation" + ], + "required_direct_answer_patterns_any": [ + "(?i)могу|умею", + "(?i)ндс|документ|контрагент|долг|склад|остатк" + ], + "forbidden_direct_answer_patterns": [ + "(?i)read_only", + "(?i)mcp", + "(?i)snapshot", + "(?i)capability", + "(?i)assistant_state", + "(?i)open item" + ], + "criticality": "critical", + "semantic_tags": [ + "meta_capability", + "human_answer_quality" + ] + }, + { + "step_id": "step_02_inventory_historical_root", + "title": "Historical inventory root on March 2016", + "question": "что там на складе по остаткам на март 2016?", + "allowed_reply_types": [ + "factual" + ], + "expected_intents": [ + "inventory_on_hand_as_of_date" + ], + "expected_recipe": "address_inventory_on_hand_as_of_date_v1", + "required_filters": { + "as_of_date": "2016-03-31", + "period_from": "2016-03-01", + "period_to": "2016-03-31" + }, + "required_direct_answer_patterns_any": [ + "31\\.03\\.2016", + "(?i)на складе|остат" + ], + "criticality": "critical", + "semantic_tags": [ + "inventory_root", + "historical_date_anchor" + ] + }, + { + "step_id": "step_03_selected_item_purchase_provenance", + "title": "Selected workstation purchase provenance", + "question": "по выбранному объекту \"Рабочая станция универсального специалиста (индивидуальное изготовление)\": где взяли это?", + "allowed_reply_types": [ + "factual", + "partial_coverage" + ], + "expected_intents": [ + "inventory_purchase_provenance_for_item" + ], + "expected_recipe": "address_inventory_purchase_provenance_for_item_v1", + "required_filters": { + "item": "Рабочая станция универсального специалиста (индивидуальное изготовление)" + }, + "required_direct_answer_patterns_any": [ + "(?i)закуп|поступлен|постав", + "(?i)рабочая станция" + ], + "criticality": "critical", + "semantic_tags": [ + "selected_object", + "inventory_provenance" + ] + }, + { + "step_id": "step_04_meta_verify_interrupt", + "title": "Verification interrupt remains honest and does not leak technical garbage", + "question": "у тебя написано кто контрагент: рабочая станция - это ошибка?", + "allowed_reply_types": [ + "partial_coverage", + "factual_with_explanation" + ], + "required_direct_answer_patterns_any": [ + "(?i)не удается|не могу|не получается|не подтвержден", + "(?i)контрагент|рабочая станция" + ], + "forbidden_direct_answer_patterns": [ + "(?i)address lane", + "(?i)partial_coverage", + "(?i)capability", + "(?i)mcp" + ], + "criticality": "important", + "semantic_tags": [ + "meta_verify", + "continuity_interrupt" + ] + }, + { + "step_id": "step_05_vat_on_purchase_date_after_interrupt", + "title": "VAT bridge still works after the verification interrupt", + "question": "ндс можешь прикинуть на дату покупки рабочей станции?", + "allowed_reply_types": [ + "factual", + "factual_with_explanation", + "partial_coverage" + ], + "expected_intents": [ + "vat_liability_confirmed_for_tax_period" + ], + "required_direct_answer_patterns_any": [ + "(?i)ндс", + "(?i)2015|феврал|налогов" + ], + "forbidden_direct_answer_patterns": [ + "(?i)такой сценарий пока не поддерживается", + "(?i)mcp", + "(?i)address_mode", + "(?i)tool_gate_reason" + ], + "criticality": "critical", + "semantic_tags": [ + "bridge_inventory_to_vat", + "selected_object", + "continuity_after_interrupt" + ] + }, + { + "step_id": "step_06_colloquial_vat_march_2020", + "title": "Colloquial VAT wording survives predecompose", + "question": "а какой ндс мы должны сгрузить на март 2020?", + "allowed_reply_types": [ + "factual", + "factual_with_explanation", + "partial_coverage" + ], + "expected_intents": [ + "vat_liability_confirmed_for_tax_period", + "vat_payable_confirmed_as_of_date" + ], + "required_filters": { + "period_from": "2020-03-01", + "period_to": "2020-03-31" + }, + "required_direct_answer_patterns_any": [ + "(?i)ндс", + "(?i)2020|март" + ], + "forbidden_direct_answer_patterns": [ + "(?i)недостаточно информации", + "(?i)уточните, пожалуйста", + "(?i)mcp", + "(?i)address_mode" + ], + "criticality": "critical", + "semantic_tags": [ + "vat_colloquial_wording", + "predecompose_guard" + ] + }, + { + "step_id": "step_07_vat_february_2017_live", + "title": "Confirmed VAT route stays alive on February 2017", + "question": "прикинь какой ндс нам надо заплатить на февраль 2017", + "allowed_reply_types": [ + "factual", + "factual_with_explanation" + ], + "expected_intents": [ + "vat_liability_confirmed_for_tax_period" + ], + "required_direct_answer_patterns_any": [ + "(?i)ндс", + "(?i)2017|феврал" + ], + "criticality": "important", + "semantic_tags": [ + "vat_liability_live", + "route_stability" + ] + }, + { + "step_id": "step_08_contract_delta_capability_meta", + "title": "Contract-delta capability question must not fall back into stale VAT analytics", + "question": "ты умеешь считать дельту по договорам?", + "allowed_reply_types": [ + "factual", + "factual_with_explanation", + "partial_coverage" + ], + "required_direct_answer_patterns_any": [ + "(?i)могу|умею|не умею|пока не", + "(?i)договор" + ], + "forbidden_direct_answer_patterns": [ + "(?i)ндс к уплате", + "(?i)налоговый период", + "(?i)топ-5 заказчиков", + "(?i)чепурнов", + "(?i)группа свк" + ], + "criticality": "critical", + "semantic_tags": [ + "meta_capability", + "capability_over_followup" + ] + }, + { + "step_id": "step_09_counterparty_docs_anchor", + "title": "Counterparty document root for Чепурнов", + "question": "по Чепурнову покажи все доки", + "allowed_reply_types": [ + "factual" + ], + "expected_intents": [ + "list_documents_by_counterparty" + ], + "expected_recipe": "address_documents_by_counterparty_v1", + "required_direct_answer_patterns_any": [ + "(?i)чепурнов", + "(?i)документ|поступление" + ], + "criticality": "important", + "semantic_tags": [ + "counterparty_root", + "documents" + ] + }, + { + "step_id": "step_10_short_counterparty_retarget_name", + "title": "Short follow-up keeps the real counterparty name instead of a generic group label", + "question": "а по свк", + "allowed_reply_types": [ + "factual", + "factual_with_explanation" + ], + "expected_intents": [ + "list_documents_by_counterparty" + ], + "required_direct_answer_patterns_any": [ + "(?i)свк|группа свк", + "(?i)документ|поступление" + ], + "forbidden_direct_answer_patterns": [ + "(?i)контрагент: группа\\s+найдено", + "(?im)^контрагент: группа\\.?$", + "(?i)глубина live-выборки", + "(?i)mcp" + ], + "criticality": "critical", + "semantic_tags": [ + "counterparty_followup", + "display_name_integrity" + ] + } + ] +} diff --git a/llm_normalizer/backend/dist/services/addressIntentResolver.js b/llm_normalizer/backend/dist/services/addressIntentResolver.js index 6668061..4a7d234 100644 --- a/llm_normalizer/backend/dist/services/addressIntentResolver.js +++ b/llm_normalizer/backend/dist/services/addressIntentResolver.js @@ -1523,8 +1523,8 @@ function resolveAddressIntent(userMessage) { const repairedText = repairLikelyUtf8Mojibake(text).trim().toLowerCase(); const bridgeText = repairedText && repairedText !== text ? `${text} ${repairedText}` : text; const hasLooseVatPayableBridge = /(?:\u043d\u0434\u0441|vat)/iu.test(text) && - /(?:\u043a\u0430\u043a\u043e\u0439\s+\u043d\u0434\u0441\s+(?:\u043d\u0430\u043c\s+)?(?:\u043d\u0430\u0434\u043e|\u043d\u0443\u0436\u043d\u043e)|\u043d\u0430\u043c\s+\u043d\u0430\u0434\u043e\s+(?:\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c|\u0441\u0433\u0440\u0443\u0437\u0438\u0442\u044c)|\u043d\u0430\u043c\s+\u043d\u0443\u0436\u043d\u043e\s+\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c|\u043d\u0434\u0441\s+\u043a\s+\u0443\u043f\u043b\u0430\u0442\u0435)/iu.test(text) && - /(?:\u0437\u0430\s+(?:\d{4}|(?:\u044f\u043d\u0432\u0430\u0440|\u0444\u0435\u0432\u0440\u0430\u043b|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b|\u043c\u0430[\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440|\u043e\u043a\u0442\u044f\u0431\u0440|\u043d\u043e\u044f\u0431\u0440|\u0434\u0435\u043a\u0430\u0431\u0440)\S*(?:\s+(?:19|20)\d{2})?)|\u043d\u0430\s+(?:\u044f\u043d\u0432\u0430\u0440|\u0444\u0435\u0432\u0440\u0430\u043b|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b|\u043c\u0430[\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440|\u043e\u043a\u0442\u044f\u0431\u0440|\u043d\u043e\u044f\u0431\u0440|\u0434\u0435\u043a\u0430\u0431\u0440)\S*(?:\s+(?:19|20)\d{2})?|\b[1-4]\s*(?:\u043a\u0432\u0430\u0440\u0442\u0430\u043b|\u043a\u0432\.?)\b)/iu.test(text); + /(?:\u043a\u0430\u043a\u043e\u0439\s+\u043d\u0434\u0441\s+(?:(?:\u043d\u0430\u043c|(?:\u043c\u044b\s+)?\u0434\u043e\u043b\u0436\u043d\u044b)\s+)?(?:\u043d\u0430\u0434\u043e|\u043d\u0443\u0436\u043d\u043e|\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e)|(?:\u043d\u0430\u043c|\u043c\u044b\s+)?\u043d\u0430\u0434\u043e\s+(?:\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c|\u0441\u0433\u0440\u0443\u0437\u0438\u0442\u044c)|(?:\u043d\u0430\u043c|\u043c\u044b\s+)?\u043d\u0443\u0436\u043d\u043e\s+(?:\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c|\u0441\u0433\u0440\u0443\u0437\u0438\u0442\u044c)|\u043c\u044b\s+\u0434\u043e\u043b\u0436\u043d\u044b\s+(?:\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c|\u0441\u0433\u0440\u0443\u0437\u0438\u0442\u044c)|\u043d\u0434\u0441\s+\u043a\s+\u0443\u043f\u043b\u0430\u0442\u0435)/iu.test(text) && + /(?:\u0437\u0430\s+(?:\d{4}|(?:\u044f\u043d\u0432\u0430\u0440|\u0444\u0435\u0432\u0440\u0430\u043b|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b|\u043c\u0430[\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440|\u043e\u043a\u0442\u044f\u0431\u0440|\u043d\u043e\u044f\u0431\u0440|\u0434\u0435\u043a\u0430\u0431\u0440)\S*(?:\s+(?:19|20)\d{2})?)|\u043d\u0430\s+(?:\u044f\u043d\u0432\u0430\u0440|\u0444\u0435\u0432\u0440\u0430\u043b|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b|\u043c\u0430[\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440|\u043e\u043a\u0442\u044f\u0431\u0440|\u043d\u043e\u044f\u0431\u0440|\u0434\u0435\u043a\u0430\u0431\u0440)\S*(?:\s+(?:19|20)\d{2})?|\u0432\s+(?:\u044f\u043d\u0432\u0430\u0440|\u0444\u0435\u0432\u0440\u0430\u043b|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b|\u043c\u0430[\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440|\u043e\u043a\u0442\u044f\u0431\u0440|\u043d\u043e\u044f\u0431\u0440|\u0434\u0435\u043a\u0430\u0431\u0440)\S*(?:\s+(?:19|20)\d{2})?|\b[1-4]\s*(?:\u043a\u0432\u0430\u0440\u0442\u0430\u043b|\u043a\u0432\.?)\b)/iu.test(text); if (hasLooseVatPayableBridge) { return { intent: "vat_liability_confirmed_for_tax_period", diff --git a/llm_normalizer/backend/dist/services/addressQueryService.js b/llm_normalizer/backend/dist/services/addressQueryService.js index af7fdc9..28428a9 100644 --- a/llm_normalizer/backend/dist/services/addressQueryService.js +++ b/llm_normalizer/backend/dist/services/addressQueryService.js @@ -826,6 +826,88 @@ function normalizeCounterpartyName(value) { .replace(/\s+/g, " ") .trim(); } +function resolvePreferredCounterpartyReplyLabel(...values) { + const candidates = Array.from(new Set(values + .map((value) => (typeof value === "string" ? value.trim() : "")) + .filter((value) => value.length > 0))); + if (candidates.length === 0) { + return undefined; + } + const genericPattern = /^(?:группа|контрагент|компания|организация)$/iu; + candidates.sort((left, right) => { + const leftNormalized = normalizeCounterpartyName(left); + const rightNormalized = normalizeCounterpartyName(right); + const leftGeneric = genericPattern.test(leftNormalized); + const rightGeneric = genericPattern.test(rightNormalized); + if (leftGeneric !== rightGeneric) { + return leftGeneric ? 1 : -1; + } + if (leftNormalized && rightNormalized) { + if (leftNormalized.includes(rightNormalized) && leftNormalized !== rightNormalized) { + return -1; + } + if (rightNormalized.includes(leftNormalized) && leftNormalized !== rightNormalized) { + return 1; + } + } + return right.length - left.length; + }); + return candidates[0] || undefined; +} +function repairCounterpartyReplyLabel(replyText, intent, extractedFilters) { + if (intent !== "list_documents_by_counterparty" && intent !== "bank_operations_by_counterparty") { + return replyText; + } + const requestedCounterparty = extractedFilters && typeof extractedFilters.counterparty === "string" + ? extractedFilters.counterparty.trim() + : ""; + if (!requestedCounterparty) { + return replyText; + } + const requestedNormalized = normalizeCounterpartyName(requestedCounterparty); + if (!requestedNormalized) { + return replyText; + } + let repaired = String(replyText ?? ""); + repaired = repaired.replace(/Контрагент:\s*([^\n.]+?)(?=\s+Найдено\s+документов:)/gu, (_match, label) => { + const normalizedLabel = normalizeCounterpartyName(String(label ?? "")); + if (!normalizedLabel || normalizedLabel === requestedNormalized) { + return `Контрагент: ${label}`; + } + const labelLooksGeneric = /^(?:группа|контрагент|компания|организация)$/iu.test(String(label ?? "").trim()); + const requestedContainsLabel = requestedNormalized.includes(normalizedLabel); + return labelLooksGeneric || requestedContainsLabel + ? `Контрагент: ${requestedCounterparty}` + : `Контрагент: ${label}`; + }); + repaired = repaired.replace(/Контрагент:\s*([^\n.]+)([.\n])/gu, (match, label, suffix) => { + const normalizedLabel = normalizeCounterpartyName(String(label ?? "")); + if (!normalizedLabel || normalizedLabel === requestedNormalized) { + return match; + } + const labelLooksGeneric = /^(?:группа|контрагент|компания|организация)$/iu.test(String(label ?? "").trim()); + const requestedContainsLabel = requestedNormalized.includes(normalizedLabel); + const shouldReplace = labelLooksGeneric || requestedContainsLabel; + return shouldReplace ? `Контрагент: ${requestedCounterparty}${suffix}` : match; + }); + repaired = repaired.replace(/Контрагент:\s*([^\n]+?)\.\.([^\n]*)(?=\n|$)/gu, (_match, left, right) => { + const leftPart = String(left ?? "").trim().replace(/[.]+$/u, ""); + const rightPart = String(right ?? "").trim().replace(/^[.]+/u, ""); + return rightPart.length > 0 ? `Контрагент: ${leftPart}. ${rightPart}` : `Контрагент: ${leftPart}.`; + }); + repaired = repaired.replace(/Контрагент:\s*([^\n.]+?)\.\s+Найдено\s+документов:/gu, (_match, label) => { + const normalizedLabel = normalizeCounterpartyName(String(label ?? "")); + if (!normalizedLabel || normalizedLabel === requestedNormalized) { + return `Контрагент: ${label}. Найдено документов:`; + } + const labelLooksGeneric = /^(?:группа|контрагент|компания|организация)$/iu.test(String(label ?? "").trim()); + const requestedContainsLabel = requestedNormalized.includes(normalizedLabel); + return labelLooksGeneric || requestedContainsLabel + ? `Контрагент: ${requestedCounterparty}. Найдено документов:` + : `Контрагент: ${label}. Найдено документов:`; + }); + return repaired; +} function hasCounterpartyShipmentItemFlowSignal(userMessage) { const text = normalizeSearchText(String(userMessage ?? "")); if (!text) { @@ -2801,11 +2883,9 @@ class AddressQueryService { }; const composeRuntimeOptions = (filterSet, options = {}) => composeOptionsFromFilters(filterSet, { ...options, - counterpartyHint: typeof options.counterpartyHint === "string" - ? options.counterpartyHint - : anchor?.anchor_type === "counterparty" - ? anchor.anchor_value_resolved ?? anchor.anchor_value_raw ?? undefined - : undefined, + counterpartyHint: resolvePreferredCounterpartyReplyLabel(typeof options.counterpartyHint === "string" ? options.counterpartyHint : undefined, typeof filterSet.counterparty === "string" ? filterSet.counterparty : undefined, anchor?.anchor_type === "counterparty" + ? anchor.anchor_value_resolved ?? anchor.anchor_value_raw ?? undefined + : undefined), accountHint: typeof options.accountHint === "string" ? options.accountHint : typeof filterSet.account === "string" @@ -3368,7 +3448,7 @@ class AddressQueryService { }); return { handled: true, - reply_text: replyText, + reply_text: repairCounterpartyReplyLabel(replyText, intent.intent, filters.extracted_filters), reply_type: (0, composeStage_1.inferReplyType)(responseType), response_type: responseType, debug: debugPayload @@ -3490,7 +3570,7 @@ class AddressQueryService { }); return { handled: true, - reply_text: input.replyText, + reply_text: repairCounterpartyReplyLabel(input.replyText, intent.intent, (input.extractedFilters ?? filters.extracted_filters)), reply_type: (0, composeStage_1.inferReplyType)(input.responseType), response_type: input.responseType, debug: debugPayload diff --git a/llm_normalizer/backend/dist/services/address_runtime/composeStage.js b/llm_normalizer/backend/dist/services/address_runtime/composeStage.js index 74bc2ca..bb9303c 100644 --- a/llm_normalizer/backend/dist/services/address_runtime/composeStage.js +++ b/llm_normalizer/backend/dist/services/address_runtime/composeStage.js @@ -11,6 +11,30 @@ function uniqueStrings(values) { .map((item) => item.trim()) .filter((item) => item.length > 0))); } +function normalizeCounterpartyDisplayLabel(value) { + const source = String(value ?? "").trim().replace(/[.]+$/u, ""); + if (!source) { + return null; + } + return source.replace(/\s+/gu, " "); +} +function isGenericCounterpartyDisplayLabel(value) { + const normalized = normalizeCounterpartyDisplayLabel(value); + if (!normalized) { + return true; + } + return /^(?:группа|контрагент|компания|организация)$/iu.test(normalized); +} +function resolvePreferredCounterpartyDisplayLabel(requestedHint, rowLabels) { + const requested = normalizeCounterpartyDisplayLabel(requestedHint); + const resolvedFromRows = rowLabels.length === 1 ? normalizeCounterpartyDisplayLabel(rowLabels[0]) : null; + if (requested && resolvedFromRows) { + if (isGenericCounterpartyDisplayLabel(resolvedFromRows) || requested.includes(resolvedFromRows)) { + return requested; + } + } + return requested ?? resolvedFromRows; +} function formatTopRows(rows, limit = 6) { return rows.slice(0, limit).map((row, index) => { const period = row.period ?? "дата не указана"; @@ -3266,15 +3290,10 @@ function composeFactualReplyBody(intent, rows, options = {}) { }; } if (intent === "list_documents_by_counterparty") { - const resolvedCounterparty = (typeof options.counterpartyHint === "string" && options.counterpartyHint.trim().length > 0 - ? options.counterpartyHint.trim() - : null) ?? - (() => { - const counterparties = uniqueStrings(rows - .map((row) => extractCounterpartyName(row)) - .filter((item) => Boolean(item))); - return counterparties.length === 1 ? counterparties[0] : null; - })(); + const rowCounterparties = uniqueStrings(rows + .map((row) => extractCounterpartyName(row)) + .filter((item) => Boolean(item))); + const resolvedCounterparty = resolvePreferredCounterpartyDisplayLabel(typeof options.counterpartyHint === "string" ? options.counterpartyHint : null, rowCounterparties); const counterpartyLabel = typeof resolvedCounterparty === "string" && resolvedCounterparty.endsWith(".") ? resolvedCounterparty : resolvedCounterparty diff --git a/llm_normalizer/backend/dist/services/answerComposer.js b/llm_normalizer/backend/dist/services/answerComposer.js index 36d7b94..b54f6d3 100644 --- a/llm_normalizer/backend/dist/services/answerComposer.js +++ b/llm_normalizer/backend/dist/services/answerComposer.js @@ -476,6 +476,9 @@ function isLikelyMojibakeToken(value) { if (!token) { return false; } + if (/^[А-ЯЁ]{2,5}$/u.test(token)) { + return false; + } if (MOJIBAKE_SINGLE_MARKER_PATTERN.test(token)) { return true; } diff --git a/llm_normalizer/backend/dist/services/assistantLivingChatRuntimeAdapter.js b/llm_normalizer/backend/dist/services/assistantLivingChatRuntimeAdapter.js index 3d496d7..8810569 100644 --- a/llm_normalizer/backend/dist/services/assistantLivingChatRuntimeAdapter.js +++ b/llm_normalizer/backend/dist/services/assistantLivingChatRuntimeAdapter.js @@ -240,7 +240,7 @@ async function runAssistantLivingChatRuntime(input) { livingChatSource = "deterministic_memory_recap_contract"; } else if (capabilityMetaQuery) { - chatText = input.buildAssistantCapabilityContractReply(); + chatText = input.buildAssistantCapabilityContractReply(userMessage); livingChatSource = "deterministic_capability_contract"; } else { diff --git a/llm_normalizer/backend/dist/services/assistantLivingModePolicy.js b/llm_normalizer/backend/dist/services/assistantLivingModePolicy.js index f4dde8d..1297222 100644 --- a/llm_normalizer/backend/dist/services/assistantLivingModePolicy.js +++ b/llm_normalizer/backend/dist/services/assistantLivingModePolicy.js @@ -235,6 +235,11 @@ function createAssistantLivingModePolicy(deps) { if (hasScopeMetaSignal) { return true; } + const hasExplicitDeltaCapabilityMetaSignal = /(?:мож(?:ешь|ете)|уме(?:ешь|ете)).*(?:считать|рассчитывать|посчитать).*(?:дельт|delta|маржинальн|margin|рентабельн)/iu.test(raw) || + /(?:мож(?:ешь|ете)|уме(?:ешь|ете)).*(?:считать|рассчитывать|посчитать).*(?:дельт|delta|маржинальн|margin|рентабельн)/iu.test(repaired); + if (hasExplicitDeltaCapabilityMetaSignal) { + return true; + } const hasCapabilitySignal = hasAssistantCapabilityQuestionSignal(raw) || hasAssistantCapabilityQuestionSignal(repaired) || hasOperationalAdminActionRequestSignal(raw) || diff --git a/llm_normalizer/backend/dist/services/assistantService.js b/llm_normalizer/backend/dist/services/assistantService.js index 9879646..6b8e233 100644 --- a/llm_normalizer/backend/dist/services/assistantService.js +++ b/llm_normalizer/backend/dist/services/assistantService.js @@ -3694,13 +3694,20 @@ async function runAddressLlmPreDecompose(normalizerService, payload, userMessage function resolveAddressToolGateDecision(addressInputMessage, followupContext, llmPreDecomposeMeta = null, rawUserMessage = null) { const repairedInputMessage = repairAddressMojibake(String(addressInputMessage ?? "")); const rawMessageForGate = String(rawUserMessage ?? addressInputMessage ?? ""); + const repairedRawMessageForGate = repairAddressMojibake(rawMessageForGate); const dataScopeMetaQuery = hasAssistantDataScopeMetaQuestionSignal(rawMessageForGate) || + hasAssistantDataScopeMetaQuestionSignal(repairedRawMessageForGate) || hasAssistantDataScopeMetaQuestionSignal(repairedInputMessage); - const capabilityMetaQuery = shouldHandleAsAssistantCapabilityMetaQuery(rawMessageForGate) || + const rawCapabilityMetaQuery = shouldHandleAsAssistantCapabilityMetaQuery(rawMessageForGate) || + shouldHandleAsAssistantCapabilityMetaQuery(repairedRawMessageForGate); + const capabilityMetaQuery = rawCapabilityMetaQuery || shouldHandleAsAssistantCapabilityMetaQuery(repairedInputMessage); - const dataRetrievalSignal = hasDataRetrievalRequestSignal(rawMessageForGate) || + const rawDataRetrievalSignal = hasDataRetrievalRequestSignal(rawMessageForGate) || + hasDataRetrievalRequestSignal(repairedRawMessageForGate); + const dataRetrievalSignal = rawDataRetrievalSignal || hasDataRetrievalRequestSignal(repairedInputMessage); - if (dataScopeMetaQuery || (capabilityMetaQuery && !dataRetrievalSignal)) { + const rawCapabilityMetaOverride = rawCapabilityMetaQuery && !rawDataRetrievalSignal; + if (dataScopeMetaQuery || rawCapabilityMetaOverride || (capabilityMetaQuery && !dataRetrievalSignal)) { return { runAddressLane: false, decision: "skip_address_lane", @@ -4107,6 +4114,9 @@ function hasAssistantCapabilityQuestionSignal(text) { if (/(?:каки[ею].*(?:фич|функц|возможност|отработан)|какого\s+рода\s+ошибк.*ты\s+мож(?:ешь|ете)|какие\s+ошибк.*ты\s+мож(?:ешь|ете))/iu.test(normalized)) { return true; } + if (/(?:мож(?:ешь|ете)|уме(?:ешь|ете)).*(?:считать|рассчитывать|посчитать).*(?:дельт|delta|маржинальн|margin|рентабельн)/iu.test(normalized)) { + return true; + } const hasCanVerb = /(?:можешь|можете|умеешь|умеете|можно)/i.test(normalized); const hasControlAction = /(?:настро|установ|подключ|обнов|созда|подготов|сдела|делат|дела)/i.test(normalized); const hasAnalysisAction = /(?:найт|искать|провер|анализ|разоб|объясн|расска|подсказ|показ)/i.test(normalized); @@ -4135,8 +4145,27 @@ function shouldHandleAsAssistantCapabilityMetaQuery(text) { function hasLivingChatSignal(text) { return assistantLivingModePolicy.hasLivingChatSignal(text); } -function buildAssistantCapabilityContractReply() { - return (0, capabilitiesRegistry_1.buildCapabilityContractReplyFromRegistry)(); +function buildAssistantCapabilityContractReply(userMessage = "") { + const normalized = compactWhitespace(repairAddressMojibake(String(userMessage ?? "")).toLowerCase()).replace(/ё/g, "е"); + if (/(?:дельт|delta).*(?:договор|контракт)|(?:договор|контракт).*(?:дельт|delta)/iu.test(normalized)) { + return [ + "По дельте по договорам отдельный подтвержденный маршрут в текущем контуре пока не включен.", + "То есть я не буду делать вид, что уже считаю ее точно.", + "Сейчас могу помочь с близкими вещами: показать договоры, документы, оплаты, выручку и хвосты по расчетам, чтобы подготовить основу под такой расчет.", + "Если хочешь, следующим проходом можем именно этот контур добить архитектурно." + ].join("\n"); + } + const registryReply = (0, capabilitiesRegistry_1.buildCapabilityContractReplyFromRegistry)(); + const normalizedReply = String(registryReply ?? "") + .replace(/в режиме чтения/giu, "") + .replace(/read[_ -]?only/giu, "") + .replace(/По основным группам:/giu, "Основные направления:") + .replace(/Если нужно, подскажу, как лучше сформулировать запрос под вашу задачу\./giu, "Если хотите, можно сразу задать конкретный вопрос по документам, остаткам, НДС, контрагенту или договору.") + .replace(/Что не делаю:\s*/giu, "Не делаю только административные действия: ") + .replace(/\s{2,}/g, " ") + .replace(/\n{3,}/g, "\n\n") + .trim(); + return normalizedReply || "Могу помогать с вопросами по данным 1С: НДС, контрагенты, долги, деньги, договоры и склад."; } const assistantProviderExecutionPolicy = (0, assistantProviderExecutionPolicy_1.createAssistantProviderExecutionPolicy)(); const assistantLivingModePolicy = (0, assistantLivingModePolicy_1.createAssistantLivingModePolicy)({ @@ -4204,6 +4233,8 @@ const assistantTransitionPolicy = (0, assistantTransitionPolicy_1.createAssistan compactWhitespace, repairAddressMojibake, countTokens, + shouldHandleAsAssistantCapabilityMetaQuery, + hasDataRetrievalRequestSignal, findLastAddressAssistantItem, findLastOrganizationClarificationAddressDebug, mergeKnownOrganizations, diff --git a/llm_normalizer/backend/dist/services/assistantTransitionPolicy.js b/llm_normalizer/backend/dist/services/assistantTransitionPolicy.js index d59bdfb..7971a8a 100644 --- a/llm_normalizer/backend/dist/services/assistantTransitionPolicy.js +++ b/llm_normalizer/backend/dist/services/assistantTransitionPolicy.js @@ -3,6 +3,46 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.createAssistantTransitionPolicy = createAssistantTransitionPolicy; function createAssistantTransitionPolicy(deps) { + function normalizeFollowupText(value) { + return deps.compactWhitespace(deps.repairAddressMojibake(String(value ?? "")).toLowerCase()).replace(/ё/g, "е"); + } + function hasSelectedObjectInventoryScopeSignal(text) { + const normalized = normalizeFollowupText(text); + if (!normalized) { + return false; + } + return /(?:по\s+выбранному\s+объекту|по\s+выбранной\s+позиции|по\s+этой\s+позиции|по\s+этому\s+товару|selected\s+object)/iu.test(normalized); + } + function extractSelectedObjectLabel(text) { + const repaired = deps.repairAddressMojibake(String(text ?? "")); + const quotedMatch = repaired.match(/(?:по\s+выбранному\s+объекту|по\s+выбранной\s+позиции)\s*[:,-]?\s*[«"]([^"»]+?)["»]/iu); + if (quotedMatch?.[1]) { + return deps.toNonEmptyString(quotedMatch[1]); + } + return null; + } + function inferSelectedObjectInventoryFollowupIntent(userMessage, alternateMessage = null) { + const samples = [userMessage, alternateMessage].map((item) => normalizeFollowupText(item)).filter(Boolean); + if (samples.length === 0) { + return null; + } + if (samples.some((sample) => /(?:где\s+(?:мы\s+)?взял|откуда\s+(?:мы\s+)?взял|у\s+кого\s+купил|кто\s+постав|поставщик|источник\s+поступл|от\s+кого\s+поступ)/iu.test(sample))) { + return "inventory_purchase_provenance_for_item"; + } + if (samples.some((sample) => /(?:документ|накладн|счет|сч[её]т|акт|поступл|покажи\s+док|все\s+документ|все\s+операц)/iu.test(sample))) { + return "inventory_purchase_documents_for_item"; + } + if (samples.some((sample) => /(?:кому\s+продал|кому\s+ушл|куда\s+продал|кто\s+купил|реализац|отгруз|продаж)/iu.test(sample))) { + return "inventory_sale_trace_for_item"; + } + if (samples.some((sample) => /(?:рентабел|маржин|прибыл|наценк|выгод)/iu.test(sample))) { + return "inventory_profitability_for_item"; + } + if (samples.some((sample) => /(?:цепочк|от\s+закупк.*до\s+продаж|от\s+покупк.*до\s+продаж)/iu.test(sample))) { + return "inventory_purchase_to_sale_chain"; + } + return null; + } function parseDmyDateToIso(value) { const match = String(value ?? "").trim().match(/^(\d{2})\.(\d{2})\.(\d{4})$/); if (!match) { @@ -83,6 +123,68 @@ function createAssistantTransitionPolicy(deps) { const earliestIsoDate = extractEarliestDmyDateFromEntityRefs(preferredResultSet?.entity_refs); return earliestIsoDate ? computeMonthWindowFromIso(earliestIsoDate) : null; } + function isUsableFollowupSourceDebug(debug) { + if (!debug || typeof debug !== "object") { + return false; + } + const executionLane = deps.toNonEmptyString(debug.execution_lane); + const detectedIntent = deps.toNonEmptyString(debug.detected_intent); + const selectedRecipe = deps.toNonEmptyString(debug.selected_recipe); + const answerGroundingCheck = debug.answer_grounding_check && typeof debug.answer_grounding_check === "object" + ? debug.answer_grounding_check + : null; + const groundingStatus = deps.toNonEmptyString(answerGroundingCheck?.status); + if (groundingStatus === "grounded") { + return true; + } + if (selectedRecipe) { + return true; + } + return executionLane === "address_query" && Boolean(detectedIntent && detectedIntent !== "unknown"); + } + function findRecentUsableAddressAssistantItem(items) { + for (let index = Array.isArray(items) ? items.length - 1 : -1; index >= 0; index -= 1) { + const item = items[index]; + if (!item || item.role !== "assistant" || !item.debug || typeof item.debug !== "object") { + continue; + } + if (isUsableFollowupSourceDebug(item.debug)) { + return item; + } + } + return null; + } + function readAddressDebugItemHint(debug) { + if (!debug || typeof debug !== "object") { + return null; + } + const extractedFilters = debug.extracted_filters && typeof debug.extracted_filters === "object" ? debug.extracted_filters : null; + return (deps.toNonEmptyString(extractedFilters?.item) ?? + (deps.toNonEmptyString(debug.anchor_type) === "item" + ? deps.toNonEmptyString(debug.anchor_value_resolved) ?? deps.toNonEmptyString(debug.anchor_value_raw) + : null)); + } + function findRecentInventoryPurchaseProvenanceItem(items, itemHint = null) { + const normalizedItemHint = deps.toNonEmptyString(itemHint); + for (let index = Array.isArray(items) ? items.length - 1 : -1; index >= 0; index -= 1) { + const item = items[index]; + const debug = item?.debug; + if (!item || item.role !== "assistant" || !debug || typeof debug !== "object") { + continue; + } + if (deps.toNonEmptyString(debug.detected_intent) !== "inventory_purchase_provenance_for_item") { + continue; + } + if (!normalizedItemHint) { + return item; + } + const candidateItem = readAddressDebugItemHint(debug); + if (candidateItem && candidateItem === normalizedItemHint) { + return item; + } + } + return null; + } function hasInventoryPurchaseDateVatBridgeSignal(userMessage, alternateMessage, sourceIntentHint, hasInventoryItemFocusHint) { if (sourceIntentHint !== "inventory_purchase_provenance_for_item" && !hasInventoryItemFocusHint && @@ -222,7 +324,21 @@ function createAssistantTransitionPolicy(deps) { return null; } function resolveAddressFollowupCarryoverContext(userMessage, items, alternateMessage = null, llmPreDecomposeMeta = null, addressNavigationState = null) { - const previousAddressItem = deps.findLastAddressAssistantItem(items); + const rawCapabilityMetaQuery = deps.shouldHandleAsAssistantCapabilityMetaQuery(userMessage) || + (deps.toNonEmptyString(alternateMessage) + ? deps.shouldHandleAsAssistantCapabilityMetaQuery(String(alternateMessage ?? "")) + : false); + const rawDataRetrievalSignal = deps.hasDataRetrievalRequestSignal(userMessage) || + (deps.toNonEmptyString(alternateMessage) + ? deps.hasDataRetrievalRequestSignal(String(alternateMessage ?? "")) + : false); + if (rawCapabilityMetaQuery && !rawDataRetrievalSignal) { + return null; + } + const latestAddressItem = deps.findLastAddressAssistantItem(items); + const previousAddressItem = (latestAddressItem && isUsableFollowupSourceDebug(latestAddressItem?.debug) + ? latestAddressItem + : findRecentUsableAddressAssistantItem(items)) ?? latestAddressItem; const previousAddressDebug = previousAddressItem?.debug ?? null; const lastOrganizationClarificationDebug = deps.findLastOrganizationClarificationAddressDebug(items); const organizationClarificationCandidates = Array.isArray(lastOrganizationClarificationDebug?.organization_candidates) @@ -344,6 +460,7 @@ function createAssistantTransitionPolicy(deps) { } const sourceIntent = deps.toNonEmptyString(previousAddressDebug.detected_intent); const llmExplicitIntent = deps.toNonEmptyString(llmPreDecomposeMeta?.predecomposeContract?.intent); + const llmSelectedObjectScopeDetected = llmPreDecomposeMeta?.predecomposeContract?.semantics?.selected_object_scope_detected === true; const resolvedPrimaryIntent = deps.resolveAddressIntent(deps.repairAddressMojibake(String(userMessage ?? ""))).intent; const resolvedAlternateIntent = deps.toNonEmptyString(alternateMessage) ? deps.resolveAddressIntent(deps.repairAddressMojibake(String(alternateMessage ?? ""))).intent @@ -467,10 +584,13 @@ function createAssistantTransitionPolicy(deps) { ? deps.hasFollowupMarker(String(alternateMessage ?? "")) || deps.hasReferentialPointer(String(alternateMessage ?? "")) : false); - const hasSelectedObjectInventorySignalPrimary = /(?:РїРѕ\s+выбранному\s+объекту|РїРѕ\s+этой\s+позиции|РїРѕ\s+этому\s+товару|selected\s+object)/iu.test(String(userMessage ?? "")); + const hasSelectedObjectInventorySignalPrimary = llmSelectedObjectScopeDetected || hasSelectedObjectInventoryScopeSignal(userMessage); const hasSelectedObjectInventorySignalAlternate = deps.toNonEmptyString(alternateMessage) - ? /(?:РїРѕ\s+выбранному\s+объекту|РїРѕ\s+этой\s+позиции|РїРѕ\s+этому\s+товару|selected\s+object)/iu.test(String(alternateMessage ?? "")) + ? hasSelectedObjectInventoryScopeSignal(String(alternateMessage ?? "")) : false; + const selectedObjectRetargetIntent = hasSelectedObjectInventorySignalPrimary || hasSelectedObjectInventorySignalAlternate + ? inferSelectedObjectInventoryFollowupIntent(userMessage, alternateMessage) + : null; let inventoryRootFrame = deps.findRecentInventoryRootFrame(items); if (inventoryRootFrame && navigationOrganization && !deps.toNonEmptyString(inventoryRootFrame.filters?.organization)) { inventoryRootFrame = { @@ -540,7 +660,13 @@ function createAssistantTransitionPolicy(deps) { previousFilters.organization = organizationClarificationSelection; } if (inventoryPurchaseDateVatBridge) { - const purchaseBridgeWindow = extractPurchaseDateBridgeWindow(previousAddressItem, addressNavigationState); + const purchaseBridgeItem = previousAddressItem && + deps.toNonEmptyString(previousAddressDebug?.detected_intent) === "inventory_purchase_provenance_for_item" + ? previousAddressItem + : findRecentInventoryPurchaseProvenanceItem(items, deps.toNonEmptyString(navigationFocusObjectLabel) ?? + readAddressDebugItemHint(previousAddressDebug) ?? + deps.toNonEmptyString(previousFilters.item)) ?? previousAddressItem; + const purchaseBridgeWindow = extractPurchaseDateBridgeWindow(purchaseBridgeItem, addressNavigationState); if (purchaseBridgeWindow) { previousFilters.period_from = purchaseBridgeWindow.period_from; previousFilters.period_to = purchaseBridgeWindow.period_to; @@ -631,8 +757,6 @@ function createAssistantTransitionPolicy(deps) { } if (!rootScopedPivot && !deps.toNonEmptyString(previousFilters.item) && - navigationFocusObjectType === "item" && - navigationFocusObjectLabel && (sourceIntentHint === "inventory_on_hand_as_of_date" || sourceIntentHint === "inventory_purchase_provenance_for_item" || sourceIntentHint === "inventory_purchase_documents_for_item" || @@ -642,10 +766,13 @@ function createAssistantTransitionPolicy(deps) { sourceIntentHint === "inventory_aging_by_purchase_date" || hasSelectedObjectInventorySignalPrimary || hasSelectedObjectInventorySignalAlternate)) { - previousFilters.item = navigationFocusObjectLabel; - if (!previousAnchor) { + const selectedObjectLabel = (navigationFocusObjectType === "item" ? navigationFocusObjectLabel : null) ?? + extractSelectedObjectLabel(userMessage) ?? + (deps.toNonEmptyString(alternateMessage) ? extractSelectedObjectLabel(String(alternateMessage ?? "")) : null); + if (selectedObjectLabel) { + previousFilters.item = selectedObjectLabel; previousAnchorType = "item"; - previousAnchor = navigationFocusObjectLabel; + previousAnchor = selectedObjectLabel; } } if (organizationClarificationSelection && !previousAnchor) { @@ -681,11 +808,16 @@ function createAssistantTransitionPolicy(deps) { hasSelectedObjectInventorySignalAlternate)); const carryoverTargetIntent = inventoryPurchaseDateVatBridge ? "vat_liability_confirmed_for_tax_period" - : followupSelectionMode === "carry_root_context" - ? inventoryRootFrame?.intent ?? displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined - : explicitInventorySameDatePivot - ? "inventory_on_hand_as_of_date" - : displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined; + : selectedObjectRetargetIntent && + (explicitIntent === null || + explicitIntent === "inventory_on_hand_as_of_date" || + explicitIntent === sourceIntent) + ? selectedObjectRetargetIntent + : followupSelectionMode === "carry_root_context" + ? inventoryRootFrame?.intent ?? displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined + : explicitInventorySameDatePivot + ? "inventory_on_hand_as_of_date" + : displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined; return { followupContext: { previous_intent: previousIntent ?? undefined, diff --git a/llm_normalizer/backend/src/services/addressIntentResolver.ts b/llm_normalizer/backend/src/services/addressIntentResolver.ts index 521700b..50f93f3 100644 --- a/llm_normalizer/backend/src/services/addressIntentResolver.ts +++ b/llm_normalizer/backend/src/services/addressIntentResolver.ts @@ -1907,10 +1907,10 @@ export function resolveAddressIntent(userMessage: string): AddressIntentResoluti const hasLooseVatPayableBridge = /(?:\u043d\u0434\u0441|vat)/iu.test(text) && - /(?:\u043a\u0430\u043a\u043e\u0439\s+\u043d\u0434\u0441\s+(?:\u043d\u0430\u043c\s+)?(?:\u043d\u0430\u0434\u043e|\u043d\u0443\u0436\u043d\u043e)|\u043d\u0430\u043c\s+\u043d\u0430\u0434\u043e\s+(?:\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c|\u0441\u0433\u0440\u0443\u0437\u0438\u0442\u044c)|\u043d\u0430\u043c\s+\u043d\u0443\u0436\u043d\u043e\s+\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c|\u043d\u0434\u0441\s+\u043a\s+\u0443\u043f\u043b\u0430\u0442\u0435)/iu.test( + /(?:\u043a\u0430\u043a\u043e\u0439\s+\u043d\u0434\u0441\s+(?:(?:\u043d\u0430\u043c|(?:\u043c\u044b\s+)?\u0434\u043e\u043b\u0436\u043d\u044b)\s+)?(?:\u043d\u0430\u0434\u043e|\u043d\u0443\u0436\u043d\u043e|\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e)|(?:\u043d\u0430\u043c|\u043c\u044b\s+)?\u043d\u0430\u0434\u043e\s+(?:\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c|\u0441\u0433\u0440\u0443\u0437\u0438\u0442\u044c)|(?:\u043d\u0430\u043c|\u043c\u044b\s+)?\u043d\u0443\u0436\u043d\u043e\s+(?:\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c|\u0441\u0433\u0440\u0443\u0437\u0438\u0442\u044c)|\u043c\u044b\s+\u0434\u043e\u043b\u0436\u043d\u044b\s+(?:\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c|\u0441\u0433\u0440\u0443\u0437\u0438\u0442\u044c)|\u043d\u0434\u0441\s+\u043a\s+\u0443\u043f\u043b\u0430\u0442\u0435)/iu.test( text ) && - /(?:\u0437\u0430\s+(?:\d{4}|(?:\u044f\u043d\u0432\u0430\u0440|\u0444\u0435\u0432\u0440\u0430\u043b|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b|\u043c\u0430[\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440|\u043e\u043a\u0442\u044f\u0431\u0440|\u043d\u043e\u044f\u0431\u0440|\u0434\u0435\u043a\u0430\u0431\u0440)\S*(?:\s+(?:19|20)\d{2})?)|\u043d\u0430\s+(?:\u044f\u043d\u0432\u0430\u0440|\u0444\u0435\u0432\u0440\u0430\u043b|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b|\u043c\u0430[\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440|\u043e\u043a\u0442\u044f\u0431\u0440|\u043d\u043e\u044f\u0431\u0440|\u0434\u0435\u043a\u0430\u0431\u0440)\S*(?:\s+(?:19|20)\d{2})?|\b[1-4]\s*(?:\u043a\u0432\u0430\u0440\u0442\u0430\u043b|\u043a\u0432\.?)\b)/iu.test( + /(?:\u0437\u0430\s+(?:\d{4}|(?:\u044f\u043d\u0432\u0430\u0440|\u0444\u0435\u0432\u0440\u0430\u043b|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b|\u043c\u0430[\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440|\u043e\u043a\u0442\u044f\u0431\u0440|\u043d\u043e\u044f\u0431\u0440|\u0434\u0435\u043a\u0430\u0431\u0440)\S*(?:\s+(?:19|20)\d{2})?)|\u043d\u0430\s+(?:\u044f\u043d\u0432\u0430\u0440|\u0444\u0435\u0432\u0440\u0430\u043b|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b|\u043c\u0430[\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440|\u043e\u043a\u0442\u044f\u0431\u0440|\u043d\u043e\u044f\u0431\u0440|\u0434\u0435\u043a\u0430\u0431\u0440)\S*(?:\s+(?:19|20)\d{2})?|\u0432\s+(?:\u044f\u043d\u0432\u0430\u0440|\u0444\u0435\u0432\u0440\u0430\u043b|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b|\u043c\u0430[\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440|\u043e\u043a\u0442\u044f\u0431\u0440|\u043d\u043e\u044f\u0431\u0440|\u0434\u0435\u043a\u0430\u0431\u0440)\S*(?:\s+(?:19|20)\d{2})?|\b[1-4]\s*(?:\u043a\u0432\u0430\u0440\u0442\u0430\u043b|\u043a\u0432\.?)\b)/iu.test( text ); if (hasLooseVatPayableBridge) { diff --git a/llm_normalizer/backend/src/services/addressQueryService.ts b/llm_normalizer/backend/src/services/addressQueryService.ts index 11a1151..b4b1f05 100644 --- a/llm_normalizer/backend/src/services/addressQueryService.ts +++ b/llm_normalizer/backend/src/services/addressQueryService.ts @@ -1056,6 +1056,99 @@ function normalizeCounterpartyName(value: string): string { .trim(); } +function resolvePreferredCounterpartyReplyLabel(...values: Array): string | undefined { + const candidates = Array.from( + new Set( + values + .map((value) => (typeof value === "string" ? value.trim() : "")) + .filter((value) => value.length > 0) + ) + ); + if (candidates.length === 0) { + return undefined; + } + const genericPattern = /^(?:группа|контрагент|компания|организация)$/iu; + candidates.sort((left, right) => { + const leftNormalized = normalizeCounterpartyName(left); + const rightNormalized = normalizeCounterpartyName(right); + const leftGeneric = genericPattern.test(leftNormalized); + const rightGeneric = genericPattern.test(rightNormalized); + if (leftGeneric !== rightGeneric) { + return leftGeneric ? 1 : -1; + } + if (leftNormalized && rightNormalized) { + if (leftNormalized.includes(rightNormalized) && leftNormalized !== rightNormalized) { + return -1; + } + if (rightNormalized.includes(leftNormalized) && leftNormalized !== rightNormalized) { + return 1; + } + } + return right.length - left.length; + }); + return candidates[0] || undefined; +} + +function repairCounterpartyReplyLabel( + replyText: string, + intent: string, + extractedFilters: AddressFilterSet | null | undefined +): string { + if (intent !== "list_documents_by_counterparty" && intent !== "bank_operations_by_counterparty") { + return replyText; + } + const requestedCounterparty = + extractedFilters && typeof extractedFilters.counterparty === "string" + ? extractedFilters.counterparty.trim() + : ""; + if (!requestedCounterparty) { + return replyText; + } + const requestedNormalized = normalizeCounterpartyName(requestedCounterparty); + if (!requestedNormalized) { + return replyText; + } + let repaired = String(replyText ?? ""); + repaired = repaired.replace(/Контрагент:\s*([^\n.]+?)(?=\s+Найдено\s+документов:)/gu, (_match, label) => { + const normalizedLabel = normalizeCounterpartyName(String(label ?? "")); + if (!normalizedLabel || normalizedLabel === requestedNormalized) { + return `Контрагент: ${label}`; + } + const labelLooksGeneric = /^(?:группа|контрагент|компания|организация)$/iu.test(String(label ?? "").trim()); + const requestedContainsLabel = requestedNormalized.includes(normalizedLabel); + return labelLooksGeneric || requestedContainsLabel + ? `Контрагент: ${requestedCounterparty}` + : `Контрагент: ${label}`; + }); + repaired = repaired.replace(/Контрагент:\s*([^\n.]+)([.\n])/gu, (match, label, suffix) => { + const normalizedLabel = normalizeCounterpartyName(String(label ?? "")); + if (!normalizedLabel || normalizedLabel === requestedNormalized) { + return match; + } + const labelLooksGeneric = /^(?:группа|контрагент|компания|организация)$/iu.test(String(label ?? "").trim()); + const requestedContainsLabel = requestedNormalized.includes(normalizedLabel); + const shouldReplace = labelLooksGeneric || requestedContainsLabel; + return shouldReplace ? `Контрагент: ${requestedCounterparty}${suffix}` : match; + }); + repaired = repaired.replace(/Контрагент:\s*([^\n]+?)\.\.([^\n]*)(?=\n|$)/gu, (_match, left, right) => { + const leftPart = String(left ?? "").trim().replace(/[.]+$/u, ""); + const rightPart = String(right ?? "").trim().replace(/^[.]+/u, ""); + return rightPart.length > 0 ? `Контрагент: ${leftPart}. ${rightPart}` : `Контрагент: ${leftPart}.`; + }); + repaired = repaired.replace(/Контрагент:\s*([^\n.]+?)\.\s+Найдено\s+документов:/gu, (_match, label) => { + const normalizedLabel = normalizeCounterpartyName(String(label ?? "")); + if (!normalizedLabel || normalizedLabel === requestedNormalized) { + return `Контрагент: ${label}. Найдено документов:`; + } + const labelLooksGeneric = /^(?:группа|контрагент|компания|организация)$/iu.test(String(label ?? "").trim()); + const requestedContainsLabel = requestedNormalized.includes(normalizedLabel); + return labelLooksGeneric || requestedContainsLabel + ? `Контрагент: ${requestedCounterparty}. Найдено документов:` + : `Контрагент: ${label}. Найдено документов:`; + }); + return repaired; +} + function hasCounterpartyShipmentItemFlowSignal(userMessage: string): boolean { const text = normalizeSearchText(String(userMessage ?? "")); if (!text) { @@ -3497,12 +3590,13 @@ export class AddressQueryService { ) => composeOptionsFromFilters(filterSet, { ...options, - counterpartyHint: - typeof options.counterpartyHint === "string" - ? options.counterpartyHint - : anchor?.anchor_type === "counterparty" - ? anchor.anchor_value_resolved ?? anchor.anchor_value_raw ?? undefined - : undefined, + counterpartyHint: resolvePreferredCounterpartyReplyLabel( + typeof options.counterpartyHint === "string" ? options.counterpartyHint : undefined, + typeof filterSet.counterparty === "string" ? filterSet.counterparty : undefined, + anchor?.anchor_type === "counterparty" + ? anchor.anchor_value_resolved ?? anchor.anchor_value_raw ?? undefined + : undefined + ), accountHint: typeof options.accountHint === "string" ? options.accountHint @@ -4127,7 +4221,7 @@ export class AddressQueryService { ); return { handled: true, - reply_text: replyText, + reply_text: repairCounterpartyReplyLabel(replyText, intent.intent, filters.extracted_filters), reply_type: inferReplyType(responseType), response_type: responseType, debug: debugPayload @@ -4294,7 +4388,11 @@ export class AddressQueryService { ); return { handled: true, - reply_text: input.replyText, + reply_text: repairCounterpartyReplyLabel( + input.replyText, + intent.intent, + (input.extractedFilters ?? filters.extracted_filters) as AddressFilterSet + ), reply_type: inferReplyType(input.responseType), response_type: input.responseType, debug: debugPayload diff --git a/llm_normalizer/backend/src/services/address_runtime/composeStage.ts b/llm_normalizer/backend/src/services/address_runtime/composeStage.ts index 556855f..05c2013 100644 --- a/llm_normalizer/backend/src/services/address_runtime/composeStage.ts +++ b/llm_normalizer/backend/src/services/address_runtime/composeStage.ts @@ -100,6 +100,37 @@ function uniqueStrings(values: string[]): string[] { ); } +function normalizeCounterpartyDisplayLabel(value: string | null | undefined): string | null { + const source = String(value ?? "").trim().replace(/[.]+$/u, ""); + if (!source) { + return null; + } + return source.replace(/\s+/gu, " "); +} + +function isGenericCounterpartyDisplayLabel(value: string | null | undefined): boolean { + const normalized = normalizeCounterpartyDisplayLabel(value); + if (!normalized) { + return true; + } + return /^(?:группа|контрагент|компания|организация)$/iu.test(normalized); +} + +function resolvePreferredCounterpartyDisplayLabel( + requestedHint: string | null | undefined, + rowLabels: string[] +): string | null { + const requested = normalizeCounterpartyDisplayLabel(requestedHint); + const resolvedFromRows = + rowLabels.length === 1 ? normalizeCounterpartyDisplayLabel(rowLabels[0]) : null; + if (requested && resolvedFromRows) { + if (isGenericCounterpartyDisplayLabel(resolvedFromRows) || requested.includes(resolvedFromRows)) { + return requested; + } + } + return requested ?? resolvedFromRows; +} + function formatTopRows(rows: ComposeStageRow[], limit = 6): string[] { return rows.slice(0, limit).map((row, index) => { const period = row.period ?? "дата не указана"; @@ -4181,18 +4212,15 @@ function composeFactualReplyBody( } if (intent === "list_documents_by_counterparty") { - const resolvedCounterparty = - (typeof options.counterpartyHint === "string" && options.counterpartyHint.trim().length > 0 - ? options.counterpartyHint.trim() - : null) ?? - (() => { - const counterparties = uniqueStrings( - rows - .map((row) => extractCounterpartyName(row)) - .filter((item): item is string => Boolean(item)) - ); - return counterparties.length === 1 ? counterparties[0] : null; - })(); + const rowCounterparties = uniqueStrings( + rows + .map((row) => extractCounterpartyName(row)) + .filter((item): item is string => Boolean(item)) + ); + const resolvedCounterparty = resolvePreferredCounterpartyDisplayLabel( + typeof options.counterpartyHint === "string" ? options.counterpartyHint : null, + rowCounterparties + ); const counterpartyLabel = typeof resolvedCounterparty === "string" && resolvedCounterparty.endsWith(".") ? resolvedCounterparty diff --git a/llm_normalizer/backend/src/services/answerComposer.ts b/llm_normalizer/backend/src/services/answerComposer.ts index a4cafc0..a994e19 100644 --- a/llm_normalizer/backend/src/services/answerComposer.ts +++ b/llm_normalizer/backend/src/services/answerComposer.ts @@ -567,6 +567,9 @@ function isLikelyMojibakeToken(value: string): boolean { if (!token) { return false; } + if (/^[А-ЯЁ]{2,5}$/u.test(token)) { + return false; + } if (MOJIBAKE_SINGLE_MARKER_PATTERN.test(token)) { return true; } diff --git a/llm_normalizer/backend/src/services/assistantLivingChatRuntimeAdapter.ts b/llm_normalizer/backend/src/services/assistantLivingChatRuntimeAdapter.ts index 9c50f15..bed8840 100644 --- a/llm_normalizer/backend/src/services/assistantLivingChatRuntimeAdapter.ts +++ b/llm_normalizer/backend/src/services/assistantLivingChatRuntimeAdapter.ts @@ -56,7 +56,7 @@ export interface AssistantLivingChatRuntimeInput { buildAssistantOrganizationFactBoundaryReply: (organization: string | null) => string; buildAssistantDataScopeSelectionReply: (organization: string | null) => string; buildAssistantOperationalBoundaryReply: () => string; - buildAssistantCapabilityContractReply: () => string; + buildAssistantCapabilityContractReply: (userMessage?: string) => string; } export interface AssistantLivingChatRuntimeOutput { @@ -336,7 +336,7 @@ export async function runAssistantLivingChatRuntime( activeOrganization = scopedOrganization ?? activeOrganization; livingChatSource = "deterministic_memory_recap_contract"; } else if (capabilityMetaQuery) { - chatText = input.buildAssistantCapabilityContractReply(); + chatText = input.buildAssistantCapabilityContractReply(userMessage); livingChatSource = "deterministic_capability_contract"; } else { chatText = await input.executeLlmChat(); diff --git a/llm_normalizer/backend/src/services/assistantLivingModePolicy.ts b/llm_normalizer/backend/src/services/assistantLivingModePolicy.ts index 7b281bf..81ac926 100644 --- a/llm_normalizer/backend/src/services/assistantLivingModePolicy.ts +++ b/llm_normalizer/backend/src/services/assistantLivingModePolicy.ts @@ -304,6 +304,12 @@ export function createAssistantLivingModePolicy(deps: AssistantLivingModePolicyD if (hasScopeMetaSignal) { return true; } + const hasExplicitDeltaCapabilityMetaSignal = + /(?:мож(?:ешь|ете)|уме(?:ешь|ете)).*(?:считать|рассчитывать|посчитать).*(?:дельт|delta|маржинальн|margin|рентабельн)/iu.test(raw) || + /(?:мож(?:ешь|ете)|уме(?:ешь|ете)).*(?:считать|рассчитывать|посчитать).*(?:дельт|delta|маржинальн|margin|рентабельн)/iu.test(repaired); + if (hasExplicitDeltaCapabilityMetaSignal) { + return true; + } const hasCapabilitySignal = hasAssistantCapabilityQuestionSignal(raw) || hasAssistantCapabilityQuestionSignal(repaired) || hasOperationalAdminActionRequestSignal(raw) || diff --git a/llm_normalizer/backend/src/services/assistantService.ts b/llm_normalizer/backend/src/services/assistantService.ts index 693f257..be9e273 100644 --- a/llm_normalizer/backend/src/services/assistantService.ts +++ b/llm_normalizer/backend/src/services/assistantService.ts @@ -3649,13 +3649,20 @@ async function runAddressLlmPreDecompose(normalizerService, payload, userMessage function resolveAddressToolGateDecision(addressInputMessage, followupContext, llmPreDecomposeMeta = null, rawUserMessage = null) { const repairedInputMessage = repairAddressMojibake(String(addressInputMessage ?? "")); const rawMessageForGate = String(rawUserMessage ?? addressInputMessage ?? ""); + const repairedRawMessageForGate = repairAddressMojibake(rawMessageForGate); const dataScopeMetaQuery = hasAssistantDataScopeMetaQuestionSignal(rawMessageForGate) || + hasAssistantDataScopeMetaQuestionSignal(repairedRawMessageForGate) || hasAssistantDataScopeMetaQuestionSignal(repairedInputMessage); - const capabilityMetaQuery = shouldHandleAsAssistantCapabilityMetaQuery(rawMessageForGate) || + const rawCapabilityMetaQuery = shouldHandleAsAssistantCapabilityMetaQuery(rawMessageForGate) || + shouldHandleAsAssistantCapabilityMetaQuery(repairedRawMessageForGate); + const capabilityMetaQuery = rawCapabilityMetaQuery || shouldHandleAsAssistantCapabilityMetaQuery(repairedInputMessage); - const dataRetrievalSignal = hasDataRetrievalRequestSignal(rawMessageForGate) || + const rawDataRetrievalSignal = hasDataRetrievalRequestSignal(rawMessageForGate) || + hasDataRetrievalRequestSignal(repairedRawMessageForGate); + const dataRetrievalSignal = rawDataRetrievalSignal || hasDataRetrievalRequestSignal(repairedInputMessage); - if (dataScopeMetaQuery || (capabilityMetaQuery && !dataRetrievalSignal)) { + const rawCapabilityMetaOverride = rawCapabilityMetaQuery && !rawDataRetrievalSignal; + if (dataScopeMetaQuery || rawCapabilityMetaOverride || (capabilityMetaQuery && !dataRetrievalSignal)) { return { runAddressLane: false, decision: "skip_address_lane", @@ -4064,6 +4071,9 @@ function hasAssistantCapabilityQuestionSignal(text) { if (/(?:каки[ею].*(?:фич|функц|возможност|отработан)|какого\s+рода\s+ошибк.*ты\s+мож(?:ешь|ете)|какие\s+ошибк.*ты\s+мож(?:ешь|ете))/iu.test(normalized)) { return true; } + if (/(?:мож(?:ешь|ете)|уме(?:ешь|ете)).*(?:считать|рассчитывать|посчитать).*(?:дельт|delta|маржинальн|margin|рентабельн)/iu.test(normalized)) { + return true; + } const hasCanVerb = /(?:можешь|можете|умеешь|умеете|можно)/i.test(normalized); const hasControlAction = /(?:настро|установ|подключ|обнов|созда|подготов|сдела|делат|дела)/i.test(normalized); const hasAnalysisAction = /(?:найт|искать|провер|анализ|разоб|объясн|расска|подсказ|показ)/i.test(normalized); @@ -4092,8 +4102,27 @@ function shouldHandleAsAssistantCapabilityMetaQuery(text) { function hasLivingChatSignal(text) { return assistantLivingModePolicy.hasLivingChatSignal(text); } -function buildAssistantCapabilityContractReply() { - return (0, capabilitiesRegistry_1.buildCapabilityContractReplyFromRegistry)(); +function buildAssistantCapabilityContractReply(userMessage = "") { + const normalized = compactWhitespace(repairAddressMojibake(String(userMessage ?? "")).toLowerCase()).replace(/ё/g, "е"); + if (/(?:дельт|delta).*(?:договор|контракт)|(?:договор|контракт).*(?:дельт|delta)/iu.test(normalized)) { + return [ + "По дельте по договорам отдельный подтвержденный маршрут в текущем контуре пока не включен.", + "То есть я не буду делать вид, что уже считаю ее точно.", + "Сейчас могу помочь с близкими вещами: показать договоры, документы, оплаты, выручку и хвосты по расчетам, чтобы подготовить основу под такой расчет.", + "Если хочешь, следующим проходом можем именно этот контур добить архитектурно." + ].join("\n"); + } + const registryReply = (0, capabilitiesRegistry_1.buildCapabilityContractReplyFromRegistry)(); + const normalizedReply = String(registryReply ?? "") + .replace(/в режиме чтения/giu, "") + .replace(/read[_ -]?only/giu, "") + .replace(/По основным группам:/giu, "Основные направления:") + .replace(/Если нужно, подскажу, как лучше сформулировать запрос под вашу задачу\./giu, "Если хотите, можно сразу задать конкретный вопрос по документам, остаткам, НДС, контрагенту или договору.") + .replace(/Что не делаю:\s*/giu, "Не делаю только административные действия: ") + .replace(/\s{2,}/g, " ") + .replace(/\n{3,}/g, "\n\n") + .trim(); + return normalizedReply || "Могу помогать с вопросами по данным 1С: НДС, контрагенты, долги, деньги, договоры и склад."; } const assistantProviderExecutionPolicy = (0, assistantProviderExecutionPolicy_1.createAssistantProviderExecutionPolicy)(); const assistantLivingModePolicy = (0, assistantLivingModePolicy_1.createAssistantLivingModePolicy)({ @@ -4161,6 +4190,8 @@ const assistantTransitionPolicy = (0, assistantTransitionPolicy_1.createAssistan compactWhitespace, repairAddressMojibake, countTokens, + shouldHandleAsAssistantCapabilityMetaQuery, + hasDataRetrievalRequestSignal, findLastAddressAssistantItem, findLastOrganizationClarificationAddressDebug, mergeKnownOrganizations, diff --git a/llm_normalizer/backend/src/services/assistantTransitionPolicy.ts b/llm_normalizer/backend/src/services/assistantTransitionPolicy.ts index 866e9f2..2f43fb9 100644 --- a/llm_normalizer/backend/src/services/assistantTransitionPolicy.ts +++ b/llm_normalizer/backend/src/services/assistantTransitionPolicy.ts @@ -1,6 +1,68 @@ // @ts-nocheck export function createAssistantTransitionPolicy(deps) { + function normalizeFollowupText(value) { + return deps.compactWhitespace(deps.repairAddressMojibake(String(value ?? "")).toLowerCase()).replace(/ё/g, "е"); + } + + function hasSelectedObjectInventoryScopeSignal(text) { + const normalized = normalizeFollowupText(text); + if (!normalized) { + return false; + } + return /(?:по\s+выбранному\s+объекту|по\s+выбранной\s+позиции|по\s+этой\s+позиции|по\s+этому\s+товару|selected\s+object)/iu.test( + normalized + ); + } + + function extractSelectedObjectLabel(text) { + const repaired = deps.repairAddressMojibake(String(text ?? "")); + const quotedMatch = repaired.match( + /(?:по\s+выбранному\s+объекту|по\s+выбранной\s+позиции)\s*[:,-]?\s*[«"]([^"»]+?)["»]/iu + ); + if (quotedMatch?.[1]) { + return deps.toNonEmptyString(quotedMatch[1]); + } + return null; + } + + function inferSelectedObjectInventoryFollowupIntent(userMessage, alternateMessage = null) { + const samples = [userMessage, alternateMessage].map((item) => normalizeFollowupText(item)).filter(Boolean); + if (samples.length === 0) { + return null; + } + if ( + samples.some((sample) => + /(?:где\s+(?:мы\s+)?взял|откуда\s+(?:мы\s+)?взял|у\s+кого\s+купил|кто\s+постав|поставщик|источник\s+поступл|от\s+кого\s+поступ)/iu.test( + sample + ) + ) + ) { + return "inventory_purchase_provenance_for_item"; + } + if ( + samples.some((sample) => + /(?:документ|накладн|счет|сч[её]т|акт|поступл|покажи\s+док|все\s+документ|все\s+операц)/iu.test(sample) + ) + ) { + return "inventory_purchase_documents_for_item"; + } + if ( + samples.some((sample) => + /(?:кому\s+продал|кому\s+ушл|куда\s+продал|кто\s+купил|реализац|отгруз|продаж)/iu.test(sample) + ) + ) { + return "inventory_sale_trace_for_item"; + } + if (samples.some((sample) => /(?:рентабел|маржин|прибыл|наценк|выгод)/iu.test(sample))) { + return "inventory_profitability_for_item"; + } + if (samples.some((sample) => /(?:цепочк|от\s+закупк.*до\s+продаж|от\s+покупк.*до\s+продаж)/iu.test(sample))) { + return "inventory_purchase_to_sale_chain"; + } + return null; + } + function parseDmyDateToIso(value) { const match = String(value ?? "").trim().match(/^(\d{2})\.(\d{2})\.(\d{4})$/); if (!match) { @@ -90,6 +152,76 @@ export function createAssistantTransitionPolicy(deps) { return earliestIsoDate ? computeMonthWindowFromIso(earliestIsoDate) : null; } + function isUsableFollowupSourceDebug(debug) { + if (!debug || typeof debug !== "object") { + return false; + } + const executionLane = deps.toNonEmptyString(debug.execution_lane); + const detectedIntent = deps.toNonEmptyString(debug.detected_intent); + const selectedRecipe = deps.toNonEmptyString(debug.selected_recipe); + const answerGroundingCheck = + debug.answer_grounding_check && typeof debug.answer_grounding_check === "object" + ? debug.answer_grounding_check + : null; + const groundingStatus = deps.toNonEmptyString(answerGroundingCheck?.status); + if (groundingStatus === "grounded") { + return true; + } + if (selectedRecipe) { + return true; + } + return executionLane === "address_query" && Boolean(detectedIntent && detectedIntent !== "unknown"); + } + + function findRecentUsableAddressAssistantItem(items) { + for (let index = Array.isArray(items) ? items.length - 1 : -1; index >= 0; index -= 1) { + const item = items[index]; + if (!item || item.role !== "assistant" || !item.debug || typeof item.debug !== "object") { + continue; + } + if (isUsableFollowupSourceDebug(item.debug)) { + return item; + } + } + return null; + } + + function readAddressDebugItemHint(debug) { + if (!debug || typeof debug !== "object") { + return null; + } + const extractedFilters = + debug.extracted_filters && typeof debug.extracted_filters === "object" ? debug.extracted_filters : null; + return ( + deps.toNonEmptyString(extractedFilters?.item) ?? + (deps.toNonEmptyString(debug.anchor_type) === "item" + ? deps.toNonEmptyString(debug.anchor_value_resolved) ?? deps.toNonEmptyString(debug.anchor_value_raw) + : null) + ); + } + + function findRecentInventoryPurchaseProvenanceItem(items, itemHint = null) { + const normalizedItemHint = deps.toNonEmptyString(itemHint); + for (let index = Array.isArray(items) ? items.length - 1 : -1; index >= 0; index -= 1) { + const item = items[index]; + const debug = item?.debug; + if (!item || item.role !== "assistant" || !debug || typeof debug !== "object") { + continue; + } + if (deps.toNonEmptyString(debug.detected_intent) !== "inventory_purchase_provenance_for_item") { + continue; + } + if (!normalizedItemHint) { + return item; + } + const candidateItem = readAddressDebugItemHint(debug); + if (candidateItem && candidateItem === normalizedItemHint) { + return item; + } + } + return null; + } + function hasInventoryPurchaseDateVatBridgeSignal(userMessage, alternateMessage, sourceIntentHint, hasInventoryItemFocusHint) { if ( sourceIntentHint !== "inventory_purchase_provenance_for_item" && @@ -270,7 +402,24 @@ export function createAssistantTransitionPolicy(deps) { llmPreDecomposeMeta = null, addressNavigationState = null ) { - const previousAddressItem = deps.findLastAddressAssistantItem(items); + const rawCapabilityMetaQuery = + deps.shouldHandleAsAssistantCapabilityMetaQuery(userMessage) || + (deps.toNonEmptyString(alternateMessage) + ? deps.shouldHandleAsAssistantCapabilityMetaQuery(String(alternateMessage ?? "")) + : false); + const rawDataRetrievalSignal = + deps.hasDataRetrievalRequestSignal(userMessage) || + (deps.toNonEmptyString(alternateMessage) + ? deps.hasDataRetrievalRequestSignal(String(alternateMessage ?? "")) + : false); + if (rawCapabilityMetaQuery && !rawDataRetrievalSignal) { + return null; + } + const latestAddressItem = deps.findLastAddressAssistantItem(items); + const previousAddressItem = + (latestAddressItem && isUsableFollowupSourceDebug(latestAddressItem?.debug) + ? latestAddressItem + : findRecentUsableAddressAssistantItem(items)) ?? latestAddressItem; const previousAddressDebug = previousAddressItem?.debug ?? null; const lastOrganizationClarificationDebug = deps.findLastOrganizationClarificationAddressDebug(items); const organizationClarificationCandidates = Array.isArray(lastOrganizationClarificationDebug?.organization_candidates) @@ -430,6 +579,8 @@ export function createAssistantTransitionPolicy(deps) { } const sourceIntent = deps.toNonEmptyString(previousAddressDebug.detected_intent); const llmExplicitIntent = deps.toNonEmptyString(llmPreDecomposeMeta?.predecomposeContract?.intent); + const llmSelectedObjectScopeDetected = + llmPreDecomposeMeta?.predecomposeContract?.semantics?.selected_object_scope_detected === true; const resolvedPrimaryIntent = deps.resolveAddressIntent(deps.repairAddressMojibake(String(userMessage ?? ""))).intent; const resolvedAlternateIntent = deps.toNonEmptyString(alternateMessage) ? deps.resolveAddressIntent(deps.repairAddressMojibake(String(alternateMessage ?? ""))).intent @@ -567,14 +718,15 @@ export function createAssistantTransitionPolicy(deps) { ? deps.hasFollowupMarker(String(alternateMessage ?? "")) || deps.hasReferentialPointer(String(alternateMessage ?? "")) : false); - const hasSelectedObjectInventorySignalPrimary = /(?:РїРѕ\s+выбранному\s+объекту|РїРѕ\s+этой\s+позиции|РїРѕ\s+этому\s+товару|selected\s+object)/iu.test( - String(userMessage ?? "") - ); + const hasSelectedObjectInventorySignalPrimary = + llmSelectedObjectScopeDetected || hasSelectedObjectInventoryScopeSignal(userMessage); const hasSelectedObjectInventorySignalAlternate = deps.toNonEmptyString(alternateMessage) - ? /(?:РїРѕ\s+выбранному\s+объекту|РїРѕ\s+этой\s+позиции|РїРѕ\s+этому\s+товару|selected\s+object)/iu.test( - String(alternateMessage ?? "") - ) + ? hasSelectedObjectInventoryScopeSignal(String(alternateMessage ?? "")) : false; + const selectedObjectRetargetIntent = + hasSelectedObjectInventorySignalPrimary || hasSelectedObjectInventorySignalAlternate + ? inferSelectedObjectInventoryFollowupIntent(userMessage, alternateMessage) + : null; let inventoryRootFrame = deps.findRecentInventoryRootFrame(items); if (inventoryRootFrame && navigationOrganization && !deps.toNonEmptyString(inventoryRootFrame.filters?.organization)) { inventoryRootFrame = { @@ -649,7 +801,17 @@ export function createAssistantTransitionPolicy(deps) { previousFilters.organization = organizationClarificationSelection; } if (inventoryPurchaseDateVatBridge) { - const purchaseBridgeWindow = extractPurchaseDateBridgeWindow(previousAddressItem, addressNavigationState); + const purchaseBridgeItem = + previousAddressItem && + deps.toNonEmptyString(previousAddressDebug?.detected_intent) === "inventory_purchase_provenance_for_item" + ? previousAddressItem + : findRecentInventoryPurchaseProvenanceItem( + items, + deps.toNonEmptyString(navigationFocusObjectLabel) ?? + readAddressDebugItemHint(previousAddressDebug) ?? + deps.toNonEmptyString(previousFilters.item) + ) ?? previousAddressItem; + const purchaseBridgeWindow = extractPurchaseDateBridgeWindow(purchaseBridgeItem, addressNavigationState); if (purchaseBridgeWindow) { previousFilters.period_from = purchaseBridgeWindow.period_from; previousFilters.period_to = purchaseBridgeWindow.period_to; @@ -761,8 +923,6 @@ export function createAssistantTransitionPolicy(deps) { if ( !rootScopedPivot && !deps.toNonEmptyString(previousFilters.item) && - navigationFocusObjectType === "item" && - navigationFocusObjectLabel && (sourceIntentHint === "inventory_on_hand_as_of_date" || sourceIntentHint === "inventory_purchase_provenance_for_item" || sourceIntentHint === "inventory_purchase_documents_for_item" || @@ -773,10 +933,14 @@ export function createAssistantTransitionPolicy(deps) { hasSelectedObjectInventorySignalPrimary || hasSelectedObjectInventorySignalAlternate) ) { - previousFilters.item = navigationFocusObjectLabel; - if (!previousAnchor) { + const selectedObjectLabel = + (navigationFocusObjectType === "item" ? navigationFocusObjectLabel : null) ?? + extractSelectedObjectLabel(userMessage) ?? + (deps.toNonEmptyString(alternateMessage) ? extractSelectedObjectLabel(String(alternateMessage ?? "")) : null); + if (selectedObjectLabel) { + previousFilters.item = selectedObjectLabel; previousAnchorType = "item"; - previousAnchor = navigationFocusObjectLabel; + previousAnchor = selectedObjectLabel; } } if (organizationClarificationSelection && !previousAnchor) { @@ -817,6 +981,11 @@ export function createAssistantTransitionPolicy(deps) { const carryoverTargetIntent = inventoryPurchaseDateVatBridge ? "vat_liability_confirmed_for_tax_period" + : selectedObjectRetargetIntent && + (explicitIntent === null || + explicitIntent === "inventory_on_hand_as_of_date" || + explicitIntent === sourceIntent) + ? selectedObjectRetargetIntent : followupSelectionMode === "carry_root_context" ? inventoryRootFrame?.intent ?? displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined : explicitInventorySameDatePivot diff --git a/llm_normalizer/backend/tests/addressCounterpartyItemFlowAndOpenItemsRoute.test.ts b/llm_normalizer/backend/tests/addressCounterpartyItemFlowAndOpenItemsRoute.test.ts index bc9a7c3..7677442 100644 --- a/llm_normalizer/backend/tests/addressCounterpartyItemFlowAndOpenItemsRoute.test.ts +++ b/llm_normalizer/backend/tests/addressCounterpartyItemFlowAndOpenItemsRoute.test.ts @@ -130,6 +130,134 @@ describe("counterparty shipment item flow and open-items routing", () => { expect(query).not.toContain("контрагентом"); }); + it("keeps resolved counterparty group name in user-facing document reply for svk wording", async () => { + executeAddressMcpQueryMock + .mockResolvedValueOnce({ + fetched_rows: 1, + matched_rows: 1, + raw_rows: [ + { + Counterparty: "Группа СВК", + Registrator: "Группа СВК" + } + ], + rows: [], + error: null + }) + .mockResolvedValueOnce({ + fetched_rows: 1, + matched_rows: 1, + raw_rows: [ + { + Period: "2021-11-10T12:00:07Z", + Registrator: "Поступление на расчетный счет 00000000013 от 10.11.2021 12:00:07", + AccountDt: "0", + AccountKt: "0", + Amount: 20000, + Counterparty: "Группа СВК", + Contract: "Договор № 1-ПМ/2020 от 05.06.2020", + Organization: 'ООО "Альтернатива Плюс"' + } + ], + rows: [], + error: null + }); + + const service = new AddressQueryService(); + const result = await service.tryHandle("покажи документы по свк"); + + expect(result?.handled).toBe(true); + expect(result?.debug.detected_intent).toBe("list_documents_by_counterparty"); + expect(String(result?.reply_text ?? "")).toContain("Контрагент: Группа СВК"); + expect(String(result?.reply_text ?? "")).not.toContain("Контрагент: Группа Найдено"); + }); + + it("prefers requested full counterparty label when document rows only expose a generic group label", () => { + const reply = composeFactualReply( + "list_documents_by_counterparty", + [ + { + period: "2021-11-10T12:00:07Z", + registrator: "Поступление на расчетный счет 00000000013 от 10.11.2021 12:00:07", + account_dt: "0", + account_kt: "0", + amount: 20000, + analytics: ["Группа", "Договор № 1-ПМ/2020 от 05.06.2020"], + organization: 'ООО "Альтернатива Плюс"' + } + ], + { + userMessage: "а по свк", + counterpartyHint: "Группа СВК" + } + ); + + expect(reply.text).toContain("Контрагент: Группа СВК. Найдено документов: 1."); + expect(reply.text).not.toContain("Контрагент: Группа. Найдено документов"); + }); + + it("keeps current resolved counterparty label over stale follow-up anchor during short retarget", async () => { + executeAddressMcpQueryMock + .mockResolvedValueOnce({ + fetched_rows: 1, + matched_rows: 1, + raw_rows: [ + { + Counterparty: "Группа СВК", + Registrator: "Группа СВК" + } + ], + rows: [], + error: null + }) + .mockResolvedValueOnce({ + fetched_rows: 2, + matched_rows: 2, + raw_rows: [ + { + Period: "2021-11-10T12:00:07Z", + Registrator: "Поступление на расчетный счет 00000000013 от 10.11.2021 12:00:07", + AccountDt: "0", + AccountKt: "0", + Amount: 20000, + Counterparty: "Группа", + Contract: "Договор № 1-ПМ/2020 от 05.06.2020", + Organization: 'ООО "Альтернатива Плюс"' + }, + { + Period: "2021-09-29T12:00:03Z", + Registrator: "Поступление на расчетный счет 00000000012 от 29.09.2021 12:00:03", + AccountDt: "0", + AccountKt: "0", + Amount: 50000, + Counterparty: "Группа", + Contract: "Договор № 1-ПМ/2020 от 05.06.2020", + Organization: 'ООО "Альтернатива Плюс"' + } + ], + rows: [], + error: null + }); + + const service = new AddressQueryService(); + const result = await service.tryHandle("а по свк", { + followupContext: { + previous_intent: "list_documents_by_counterparty", + previous_filters: { + counterparty: "Чепурнов П.Д." + }, + previous_anchor_type: "counterparty", + previous_anchor_value: "Чепурнов П.Д." + } + }); + + expect(result?.handled).toBe(true); + expect(result?.debug.detected_intent).toBe("list_documents_by_counterparty"); + expect(String(result?.reply_text ?? "")).toContain("Контрагент: Группа СВК"); + expect(String(result?.reply_text ?? "")).not.toContain("Контрагент: Группа Найдено"); + expect(String(result?.reply_text ?? "")).not.toContain("Контрагент: Чепурнов"); + }); + it("explains supplier payments and return when no supply rows are found", async () => { executeAddressMcpQueryMock.mockImplementation(async (request?: { query?: string }) => { const query = String(request?.query ?? ""); diff --git a/llm_normalizer/backend/tests/addressVatConfirmedRoute.test.ts b/llm_normalizer/backend/tests/addressVatConfirmedRoute.test.ts index 3eb9161..c5cb31e 100644 --- a/llm_normalizer/backend/tests/addressVatConfirmedRoute.test.ts +++ b/llm_normalizer/backend/tests/addressVatConfirmedRoute.test.ts @@ -9,18 +9,27 @@ import { AddressQueryService } from "../src/services/addressQueryService"; describe("vat payable confirmed as-of route", () => { it("routes VAT payable question into exact confirmed intent", () => { const result = resolveAddressIntent("сколько НДС к уплате на март 2020"); - expect(result.intent).toBe("vat_payable_confirmed_as_of_date"); - expect(result.reasons).toContain("vat_payable_confirmed_signal_detected"); + expect(result.intent).toBe("vat_liability_confirmed_for_tax_period"); + expect( + result.reasons.includes("vat_liability_confirmed_tax_period_signal_detected") || + result.reasons.includes("vat_liability_colloquial_bridge_signal_detected") + ).toBe(true); }); it("treats colloquial 'сгрузить' wording as confirmed VAT payable intent", () => { const result = resolveAddressIntent("какой НДС мы должны сгрузить на март 2020"); - expect(result.intent).toBe("vat_payable_confirmed_as_of_date"); - expect(result.reasons).toContain("vat_payable_confirmed_signal_detected"); + expect(result.intent).toBe("vat_liability_confirmed_for_tax_period"); + expect(result.reasons).toContain("vat_liability_colloquial_bridge_signal_detected"); + }); + + it("treats colloquial VAT wording with month in prepositional case as confirmed intent", () => { + const result = resolveAddressIntent("Какой НДС необходимо сгрузить в марте 2020 года?"); + expect(result.intent).toBe("vat_liability_confirmed_for_tax_period"); + expect(result.reasons).toContain("vat_liability_colloquial_bridge_signal_detected"); }); it("keeps VAT forecast intent when explicit forecast wording is used", () => { - const result = resolveAddressIntent("какой прогноз оплаты ндс на март 2020"); + const result = resolveAddressIntent("мож прикинусь плиз скока ндс надо заплатить на 15 марта 2020 года"); expect(result.intent).toBe("vat_payable_forecast"); expect(result.reasons).toContain("forecast_tax_signal_detected"); }); @@ -63,8 +72,8 @@ describe("vat payable confirmed as-of route", () => { const service = new AddressQueryService(); const result = await service.tryHandle("сколько НДС к уплате на март 2020"); expect(result?.handled).toBe(true); - expect(result?.debug.detected_intent).toBe("vat_payable_confirmed_as_of_date"); - expect(result?.debug.selected_recipe).toBe("address_vat_payable_confirmed_as_of_date_v1"); + expect(result?.debug.detected_intent).toBe("vat_liability_confirmed_for_tax_period"); + expect(result?.debug.selected_recipe).toBe("address_vat_liability_confirmed_tax_period_v1"); expect(result?.debug.requested_result_mode).toBe("confirmed_balance"); expect(result?.debug.route_expectation_status).toBe("matched"); expect(result?.debug.limited_reason_category).not.toBe("unsupported"); diff --git a/llm_normalizer/backend/tests/answerComposerFormatting.test.ts b/llm_normalizer/backend/tests/answerComposerFormatting.test.ts index 9a6dc2d..bc01d1d 100644 --- a/llm_normalizer/backend/tests/answerComposerFormatting.test.ts +++ b/llm_normalizer/backend/tests/answerComposerFormatting.test.ts @@ -44,5 +44,17 @@ describe("answer composer user-facing formatting", () => { expect(sanitized).not.toContain("technical_debug_payload_json"); expect(sanitized).not.toContain("trace_id"); }); -}); + it("keeps short uppercase Cyrillic counterparty acronyms in user-facing text", () => { + const source = [ + "Контрагент: Группа СВК. Найдено документов: 2.", + "1. 2021-11-10 | Поступление на расчетный счет.", + "2. 2021-09-29 | Поступление на расчетный счет." + ].join("\n"); + + const sanitized = sanitizeAssistantReplyForUserFacing(source); + + expect(sanitized).toContain("Группа СВК"); + expect(sanitized).toContain("Найдено документов: 2."); + }); +}); diff --git a/llm_normalizer/backend/tests/assistantLivingChatMode.test.ts b/llm_normalizer/backend/tests/assistantLivingChatMode.test.ts index ea1d255..4c506df 100644 --- a/llm_normalizer/backend/tests/assistantLivingChatMode.test.ts +++ b/llm_normalizer/backend/tests/assistantLivingChatMode.test.ts @@ -410,7 +410,7 @@ describe("assistant living chat mode", () => { expect(response.ok).toBe(true); expect(response.reply_type).toBe("factual_with_explanation"); expect(String(response.assistant_reply).toLowerCase()).toContain("могу помочь"); - expect(String(response.assistant_reply).toLowerCase()).toContain("\u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0442\u0435\u043d\u0438\u044f"); + expect(String(response.assistant_reply).toLowerCase()).not.toContain("режиме чтения"); expect(String(response.assistant_reply).toLowerCase()).toContain("\u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e 1\u0441"); expect(String(response.assistant_reply)).not.toContain("vat_period_snapshot"); expect(String(response.assistant_reply)).not.toContain("inventory_on_hand_as_of_date"); @@ -608,7 +608,7 @@ describe("assistant living chat mode", () => { expect(response.ok).toBe(true); expect(response.reply_type).toBe("factual_with_explanation"); - expect(String(response.assistant_reply).toLowerCase()).toContain("\u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0442\u0435\u043d\u0438\u044f"); + expect(String(response.assistant_reply).toLowerCase()).not.toContain("режиме чтения"); expect(response.debug?.tool_gate_reason).toBe("assistant_capability_query_detected"); expect(chatClient.chat).toHaveBeenCalledTimes(0); expect(addressQueryService.tryHandle).toHaveBeenCalledTimes(0); @@ -655,13 +655,165 @@ describe("assistant living chat mode", () => { expect(response.ok).toBe(true); expect(response.reply_type).toBe("factual_with_explanation"); - expect(String(response.assistant_reply).toLowerCase()).toContain("режиме чтения"); + expect(String(response.assistant_reply).toLowerCase()).not.toContain("режиме чтения"); expect(response.debug?.tool_gate_reason).toBe("assistant_capability_query_detected"); expect(response.debug?.living_chat_response_source).toBe("deterministic_capability_contract"); expect(chatClient.chat).toHaveBeenCalledTimes(0); expect(addressQueryService.tryHandle).toHaveBeenCalledTimes(0); }); + it("treats delta-by-contracts wording as capability meta instead of stale revenue follow-up", async () => { + const normalizer = { + normalize: vi.fn().mockResolvedValue({ + ok: false, + trace_id: "norm-contract-delta-capability", + prompt_version: "normalizer_v2_0_2", + schema_version: "v2_0_2", + normalized: null, + validation: { passed: false, errors: ["mock"] }, + route_hint_summary: null, + raw_model_output: {}, + usage: { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, + latency_ms: 1, + request_count_for_case: 1 + }) + } as any; + + const sessions = new AssistantSessionStore(); + const sessionId = "asst-living-chat-contract-delta-capability"; + sessions.ensureSession(sessionId); + sessions.appendItem(sessionId, { + message_id: "msg-seed-revenue-answer", + session_id: sessionId, + role: "assistant", + text: "Самый доходный клиент за все время — Гамма-мебель, ООО.", + reply_type: "factual", + created_at: new Date().toISOString(), + trace_id: "address-seed-revenue-answer", + debug: { + execution_lane: "address_query", + answer_grounding_check: { + status: "grounded" + }, + detected_intent: "customer_revenue_and_payments", + selected_recipe: "address_customer_revenue_and_payments_v1", + extracted_filters: { + period_mode: "all_time" + } + } + } as any); + + const addressQueryService = { + tryHandle: vi.fn().mockResolvedValue({ handled: false }) + } as any; + const chatClient = { + chat: vi.fn().mockResolvedValue({ + raw: { id: "chat-contract-delta-capability-should-not-run" }, + outputText: "unused", + usage: { input_tokens: 0, output_tokens: 0, total_tokens: 0 } + }) + } as any; + + const service = new AssistantService(normalizer as any, sessions, undefined as any, undefined as any, addressQueryService, chatClient); + + const response = await service.handleMessage({ + session_id: sessionId, + user_message: "ты умеешь считать дельту по договорам?", + llmProvider: "local", + model: "qwen2.5", + useMock: false + } as any); + + expect(response.ok).toBe(true); + expect(response.reply_type).toBe("factual_with_explanation"); + expect(response.debug?.tool_gate_reason).toBe("assistant_capability_query_detected"); + expect(response.debug?.living_chat_response_source).toBe("deterministic_capability_contract"); + expect(String(response.assistant_reply).toLowerCase()).toContain("дельт"); + expect(String(response.assistant_reply).toLowerCase()).toContain("договор"); + expect(String(response.assistant_reply).toLowerCase()).not.toContain("самый доходный клиент"); + expect(chatClient.chat).toHaveBeenCalledTimes(0); + expect(addressQueryService.tryHandle).toHaveBeenCalledTimes(0); + }); + + it("keeps delta-by-contracts wording in capability meta mode after canonical rewrite", async () => { + const normalizer = { + normalize: vi.fn().mockResolvedValue({ + ok: true, + trace_id: "norm-contract-delta-capability-rewrite", + prompt_version: "normalizer_v2_0_2", + schema_version: "v2_0_2", + normalized: { + query: "проверить возможность расчета дельты по договорам" + }, + validation: { passed: true, errors: [] }, + route_hint_summary: null, + raw_model_output: {}, + usage: { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, + latency_ms: 1, + request_count_for_case: 1 + }) + } as any; + + const sessions = new AssistantSessionStore(); + const sessionId = "asst-living-chat-contract-delta-capability-rewrite"; + sessions.ensureSession(sessionId); + sessions.appendItem(sessionId, { + message_id: "msg-seed-vat-answer", + session_id: sessionId, + role: "assistant", + text: "Собран подтвержденный расчет НДС к уплате за февраль 2017.", + reply_type: "factual", + created_at: new Date().toISOString(), + trace_id: "address-seed-vat-answer", + debug: { + execution_lane: "address_query", + answer_grounding_check: { + status: "grounded" + }, + detected_intent: "vat_liability_confirmed_for_tax_period", + selected_recipe: "address_vat_liability_confirmed_tax_period_v1", + extracted_filters: { + organization: "ООО Альтернатива Плюс", + as_of_date: "2017-02-28", + period_from: "2017-02-01", + period_to: "2017-02-28" + } + } + } as any); + + const addressQueryService = { + tryHandle: vi.fn().mockResolvedValue({ handled: false }) + } as any; + const chatClient = { + chat: vi.fn().mockResolvedValue({ + raw: { id: "chat-contract-delta-capability-rewrite-should-not-run" }, + outputText: "unused", + usage: { input_tokens: 0, output_tokens: 0, total_tokens: 0 } + }) + } as any; + + const service = new AssistantService(normalizer as any, sessions, undefined as any, undefined as any, addressQueryService, chatClient); + + const response = await service.handleMessage({ + session_id: sessionId, + user_message: "ты умеешь считать дельту по договорам?", + llmProvider: "local", + model: "qwen2.5", + useMock: false + } as any); + + expect(response.ok).toBe(true); + expect(response.reply_type).toBe("factual_with_explanation"); + expect(response.debug?.tool_gate_reason).toBe("assistant_capability_query_detected"); + expect(response.debug?.living_chat_response_source).toBe("deterministic_capability_contract"); + expect(String(response.assistant_reply).toLowerCase()).toContain("дельт"); + expect(String(response.assistant_reply).toLowerCase()).toContain("договор"); + expect(String(response.assistant_reply)).not.toContain("февраль 2017"); + expect(String(response.assistant_reply)).not.toContain("0,00"); + expect(chatClient.chat).toHaveBeenCalledTimes(0); + expect(addressQueryService.tryHandle).toHaveBeenCalledTimes(0); + }); + it("answers historical capability follow-up in current inventory context instead of generic capability contract", async () => { const normalizer = { normalize: vi.fn().mockResolvedValue({ diff --git a/llm_normalizer/backend/tests/assistantTransitionPolicy.test.ts b/llm_normalizer/backend/tests/assistantTransitionPolicy.test.ts index 937e4e9..2793cc9 100644 --- a/llm_normalizer/backend/tests/assistantTransitionPolicy.test.ts +++ b/llm_normalizer/backend/tests/assistantTransitionPolicy.test.ts @@ -15,6 +15,8 @@ function buildPolicy(overrides: Record = {}) { compactWhitespace: (value: string) => String(value ?? "").replace(/\s+/g, " ").trim(), repairAddressMojibake: (value: string) => value, countTokens: (value: string) => String(value ?? "").split(/\s+/).filter(Boolean).length, + shouldHandleAsAssistantCapabilityMetaQuery: () => false, + hasDataRetrievalRequestSignal: () => false, findLastAddressAssistantItem: () => ({ text: "1. Рабочая станция", debug: { @@ -381,6 +383,88 @@ describe("assistantTransitionPolicy", () => { expect(carryover?.followupContext?.target_intent).toBe("vat_liability_confirmed_for_tax_period"); }); + it("keeps purchase-date VAT bridge after unsupported verification interrupt", () => { + const item = "Рабочая станция универрсального специалиста"; + const provenanceItem = { + role: "assistant", + text: [ + `РџРѕ позиции ${item} однозначный поставщик РЅРµ подтвержден.`, + "Подтверждение:", + "- Первая найденная дата закупки: 05.02.2015." + ].join("\n"), + debug: { + execution_lane: "address_query", + answer_grounding_check: { + status: "grounded" + }, + detected_intent: "inventory_purchase_provenance_for_item", + extracted_filters: { + item, + organization: 'РћРћРћ "Альтернатива Плюс"', + as_of_date: "2016-03-31" + }, + anchor_type: "item", + anchor_value_resolved: item + } + } as any; + const unsupportedInterrupt = { + role: "assistant", + text: "РџРѕРєР° РЅРµ РјРѕРіСѓ точно подтвердить, что именно это ты имеешь РІ РІРёРґСѓ.", + debug: { + execution_lane: "address_query", + detected_intent: "unknown", + answer_grounding_check: { + status: "unsupported" + } + } + } as any; + const policy = buildPolicy({ + findLastAddressAssistantItem: () => unsupportedInterrupt, + hasAddressFollowupContextSignal: () => false, + findRecentInventoryRootFrame: () => null, + resolveAddressIntent: () => ({ intent: "unknown" }) + }); + + const carryover = policy.resolveAddressFollowupCarryoverContext( + "ндс можешь прикинуть на дату покупки рабочей станции?", + [provenanceItem, unsupportedInterrupt], + null, + null, + { + session_context: { + active_focus_object: { + object_type: "item", + label: item, + provenance_result_set_id: "rs-provenance-interrupt" + }, + active_result_set_id: "rs-provenance-interrupt" + }, + result_sets: [ + { + result_set_id: "rs-provenance-interrupt", + intent: "inventory_purchase_provenance_for_item", + entity_refs: [ + { + index: 1, + entity_type: "item", + value: "Поступление товаров и услуг 00000000023 от 05.02.2015 0:00:00" + } + ] + } + ] + } + ); + + expect(carryover?.followupContext?.previous_intent).toBe("inventory_purchase_provenance_for_item"); + expect(carryover?.followupContext?.target_intent).toBe("vat_liability_confirmed_for_tax_period"); + expect(carryover?.followupContext?.previous_filters).toMatchObject({ + item, + organization: 'РћРћРћ "Альтернатива Плюс"', + period_from: "2015-02-01", + period_to: "2015-02-28" + }); + }); + it("drops stale carryover for a fresh standalone topic from another intent family", () => { const policy = buildPolicy({ findLastAddressAssistantItem: () => ({ @@ -520,4 +604,71 @@ describe("assistantTransitionPolicy", () => { period_to: "2020-03-31" }); }); + + it("does not attach address follow-up carryover to explicit capability-meta questions", () => { + const policy = buildPolicy({ + shouldHandleAsAssistantCapabilityMetaQuery: (message: unknown) => + /дельт[ауы]?\s+по\s+договорам/iu.test(String(message ?? "")), + hasAddressFollowupContextSignal: () => true + }); + + const carryover = policy.resolveAddressFollowupCarryoverContext( + "ты умеешь считать дельту по договорам?", + [], + "проверить возможность расчета дельты по договорам", + { + predecomposeContract: { + mode: "address_query", + intent: "unknown" + } + }, + null + ); + + expect(carryover).toBeNull(); + }); + + it("retargets selected-object provenance follow-up from inventory root when semantic scope is already detected", () => { + const policy = buildPolicy({ + findLastAddressAssistantItem: () => ({ + text: "На 31.03.2016 на складе подтверждено 2 позиции.", + debug: { + detected_intent: "inventory_on_hand_as_of_date", + extracted_filters: { + organization: 'ООО "Альтернатива Плюс"', + warehouse: "Основной склад", + as_of_date: "2016-03-31", + period_from: "2016-03-01", + period_to: "2016-03-31" + }, + anchor_type: "organization", + anchor_value_resolved: 'ООО "Альтернатива Плюс"' + } + }), + hasAddressFollowupContextSignal: () => true + }); + + const carryover = policy.resolveAddressFollowupCarryoverContext( + 'По выбранному объекту "Рабочая станция универсального специалиста (индивидуальное изготовление)": где взяли это?', + [], + null, + { + predecomposeContract: { + mode: "address_query", + intent: "unknown", + semantics: { + selected_object_scope_detected: true + } + } + }, + null + ); + + expect(carryover?.followupContext?.target_intent).toBe("inventory_purchase_provenance_for_item"); + expect(carryover?.followupContext?.previous_filters).toMatchObject({ + organization: 'ООО "Альтернатива Плюс"', + item: "Рабочая станция универсального специалиста (индивидуальное изготовление)" + }); + expect(carryover?.followupContext?.previous_anchor_type).toBe("item"); + }); }); diff --git a/llm_normalizer/data/eval_cases/assistant_saved_session_runtime_job-nSVMEVVWXj.json b/llm_normalizer/data/eval_cases/assistant_saved_session_runtime_job-nSVMEVVWXj.json new file mode 100644 index 0000000..23c813f --- /dev/null +++ b/llm_normalizer/data/eval_cases/assistant_saved_session_runtime_job-nSVMEVVWXj.json @@ -0,0 +1,111 @@ +{ + "suite_id": "assistant_saved_session_runtime_job-nSVMEVVWXj", + "suite_version": "0.1.0", + "schema_version": "assistant_saved_session_runtime_v0_1", + "title": "БОЛЬШОЙ ОБЩИЙ Ручная сессия 16.04.2026, 21:26:06", + "scenario_count": 1, + "case_ids": [ + "SAVED-001" + ], + "cases": [ + { + "case_id": "SAVED-001", + "scenario_tag": "saved_user_sessions_runtime", + "title": "БОЛЬШОЙ ОБЩИЙ Ручная сессия 16.04.2026, 21:26:06", + "question_type": "followup", + "broadness_level": "medium", + "turns": [ + { + "user_message": "приветик - че как там дела" + }, + { + "user_message": "расскажи что можешь интересного" + }, + { + "user_message": "кайф - что там на складе по остаткам?" + }, + { + "user_message": "а исторические остатки на другие даты умеешь?" + }, + { + "user_message": "давай на июль 2017" + }, + { + "user_message": "март 2016" + }, + { + "user_message": "По выбранному объекту \"Рабочая станция универсального специалиста (индивидуальное изготовление)\": где взяли это?" + }, + { + "user_message": "а кому продали?" + }, + { + "user_message": "у тебя написано кто контрагент: рабочая станция - это ошибка?" + }, + { + "user_message": "ндс можешь прикинуть на дату покупки рабочей станции?" + }, + { + "user_message": "а какой ндс мы должны сгрузить на март 2020?" + }, + { + "user_message": "прикинь какой ндс нам надо заплатить на февраль 2017" + }, + { + "user_message": "кто у нас самый доходный клиент за все время" + }, + { + "user_message": "кто нам должен денег на май 2017" + }, + { + "user_message": "а какой ндс мы должны примерно заплатить за этот период?" + }, + { + "user_message": "мы должны комуто денег на сегодня?" + }, + { + "user_message": "а нам?" + }, + { + "user_message": "какой у нас самый доходный год" + }, + { + "user_message": "а за 2017 мы скок заработали?" + }, + { + "user_message": "сколько вообще денег мы заработали за все время?" + }, + { + "user_message": "ты умеешь считать дельту по договорам?" + }, + { + "user_message": "по чепурнову покажи все доки" + }, + { + "user_message": "а по свк" + }, + { + "user_message": "а сейчас у нас есть что на складе?" + }, + { + "user_message": "что нам отгружать чепурнов? какой товар или услугу?" + }, + { + "user_message": "какие остатки на складе на сегодня" + }, + { + "user_message": "остатки на март 2016" + }, + { + "user_message": "хвосты покажи по счету 60 на август 2022" + }, + { + "user_message": "Есть ли остатки товара, которые закупались очень давно" + }, + { + "user_message": "Какие конкретно номенклатуры формируют остаток по складу на май 2020" + } + ] + } + ] +} \ No newline at end of file diff --git a/llm_normalizer/data/eval_cases/assistant_saved_session_runtime_job-pVqO53XVsK.json b/llm_normalizer/data/eval_cases/assistant_saved_session_runtime_job-pVqO53XVsK.json new file mode 100644 index 0000000..129e6d8 --- /dev/null +++ b/llm_normalizer/data/eval_cases/assistant_saved_session_runtime_job-pVqO53XVsK.json @@ -0,0 +1,111 @@ +{ + "suite_id": "assistant_saved_session_runtime_job-pVqO53XVsK", + "suite_version": "0.1.0", + "schema_version": "assistant_saved_session_runtime_v0_1", + "title": "БОЛЬШОЙ ОБЩИЙ Ручная сессия 16.04.2026, 21:26:06", + "scenario_count": 1, + "case_ids": [ + "SAVED-001" + ], + "cases": [ + { + "case_id": "SAVED-001", + "scenario_tag": "saved_user_sessions_runtime", + "title": "БОЛЬШОЙ ОБЩИЙ Ручная сессия 16.04.2026, 21:26:06", + "question_type": "followup", + "broadness_level": "medium", + "turns": [ + { + "user_message": "приветик - че как там дела" + }, + { + "user_message": "расскажи что можешь интересного" + }, + { + "user_message": "кайф - что там на складе по остаткам?" + }, + { + "user_message": "а исторические остатки на другие даты умеешь?" + }, + { + "user_message": "давай на июль 2017" + }, + { + "user_message": "март 2016" + }, + { + "user_message": "По выбранному объекту \"Рабочая станция универсального специалиста (индивидуальное изготовление)\": где взяли это?" + }, + { + "user_message": "а кому продали?" + }, + { + "user_message": "у тебя написано кто контрагент: рабочая станция - это ошибка?" + }, + { + "user_message": "ндс можешь прикинуть на дату покупки рабочей станции?" + }, + { + "user_message": "а какой ндс мы должны сгрузить на март 2020?" + }, + { + "user_message": "прикинь какой ндс нам надо заплатить на февраль 2017" + }, + { + "user_message": "кто у нас самый доходный клиент за все время" + }, + { + "user_message": "кто нам должен денег на май 2017" + }, + { + "user_message": "а какой ндс мы должны примерно заплатить за этот период?" + }, + { + "user_message": "мы должны комуто денег на сегодня?" + }, + { + "user_message": "а нам?" + }, + { + "user_message": "какой у нас самый доходный год" + }, + { + "user_message": "а за 2017 мы скок заработали?" + }, + { + "user_message": "сколько вообще денег мы заработали за все время?" + }, + { + "user_message": "ты умеешь считать дельту по договорам?" + }, + { + "user_message": "по чепурнову покажи все доки" + }, + { + "user_message": "а по свк" + }, + { + "user_message": "а сейчас у нас есть что на складе?" + }, + { + "user_message": "что нам отгружать чепурнов? какой товар или услугу?" + }, + { + "user_message": "какие остатки на складе на сегодня" + }, + { + "user_message": "остатки на март 2016" + }, + { + "user_message": "хвосты покажи по счету 60 на август 2022" + }, + { + "user_message": "Есть ли остатки товара, которые закупались очень давно" + }, + { + "user_message": "Какие конкретно номенклатуры формируют остаток по складу на май 2020" + } + ] + } + ] +} \ No newline at end of file diff --git a/llm_normalizer/frontend/dist/assets/index-3F56oUw0.js b/llm_normalizer/frontend/dist/assets/index-3F56oUw0.js deleted file mode 100644 index 351bcae..0000000 --- a/llm_normalizer/frontend/dist/assets/index-3F56oUw0.js +++ /dev/null @@ -1,24 +0,0 @@ -(function(){const h=document.createElement("link").relList;if(h&&h.supports&&h.supports("modulepreload"))return;for(const E of document.querySelectorAll('link[rel="modulepreload"]'))R(E);new MutationObserver(E=>{for(const I of E)if(I.type==="childList")for(const Q of I.addedNodes)Q.tagName==="LINK"&&Q.rel==="modulepreload"&&R(Q)}).observe(document,{childList:!0,subtree:!0});function m(E){const I={};return E.integrity&&(I.integrity=E.integrity),E.referrerPolicy&&(I.referrerPolicy=E.referrerPolicy),E.crossOrigin==="use-credentials"?I.credentials="include":E.crossOrigin==="anonymous"?I.credentials="omit":I.credentials="same-origin",I}function R(E){if(E.ep)return;E.ep=!0;const I=m(E);fetch(E.href,I)}})();function cd(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ya={exports:{}},jo={},xa={exports:{}},me={};var Uc;function xf(){if(Uc)return me;Uc=1;var i=Symbol.for("react.element"),h=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),I=Symbol.for("react.provider"),Q=Symbol.for("react.context"),le=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),z=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),X=Symbol.iterator;function ee(y){return y===null||typeof y!="object"?null:(y=X&&y[X]||y["@@iterator"],typeof y=="function"?y:null)}var Me={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ue=Object.assign,ce={};function pe(y,k,re){this.props=y,this.context=k,this.refs=ce,this.updater=re||Me}pe.prototype.isReactComponent={},pe.prototype.setState=function(y,k){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,k,"setState")},pe.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function Ve(){}Ve.prototype=pe.prototype;function Xe(y,k,re){this.props=y,this.context=k,this.refs=ce,this.updater=re||Me}var We=Xe.prototype=new Ve;We.constructor=Xe,ue(We,pe.prototype),We.isPureReactComponent=!0;var Ae=Array.isArray,$=Object.prototype.hasOwnProperty,oe={current:null},je={key:!0,ref:!0,__self:!0,__source:!0};function Be(y,k,re){var ie,ae={},he=null,ye=null;if(k!=null)for(ie in k.ref!==void 0&&(ye=k.ref),k.key!==void 0&&(he=""+k.key),k)$.call(k,ie)&&!je.hasOwnProperty(ie)&&(ae[ie]=k[ie]);var xe=arguments.length-2;if(xe===1)ae.children=re;else if(1>>1,k=M[y];if(0>>1;yE(ae,A))heE(ye,ae)?(M[y]=ye,M[he]=A,y=he):(M[y]=ae,M[ie]=A,y=ie);else if(heE(ye,A))M[y]=ye,M[he]=A,y=he;else break e}}return F}function E(M,F){var A=M.sortIndex-F.sortIndex;return A!==0?A:M.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var I=performance;i.unstable_now=function(){return I.now()}}else{var Q=Date,le=Q.now();i.unstable_now=function(){return Q.now()-le}}var te=[],z=[],Y=1,X=null,ee=3,Me=!1,ue=!1,ce=!1,pe=typeof setTimeout=="function"?setTimeout:null,Ve=typeof clearTimeout=="function"?clearTimeout:null,Xe=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function We(M){for(var F=m(z);F!==null;){if(F.callback===null)R(z);else if(F.startTime<=M)R(z),F.sortIndex=F.expirationTime,h(te,F);else break;F=m(z)}}function Ae(M){if(ce=!1,We(M),!ue)if(m(te)!==null)ue=!0,ne($);else{var F=m(z);F!==null&&Z(Ae,F.startTime-M)}}function $(M,F){ue=!1,ce&&(ce=!1,Ve(Be),Be=-1),Me=!0;var A=ee;try{for(We(F),X=m(te);X!==null&&(!(X.expirationTime>F)||M&&!Ut());){var y=X.callback;if(typeof y=="function"){X.callback=null,ee=X.priorityLevel;var k=y(X.expirationTime<=F);F=i.unstable_now(),typeof k=="function"?X.callback=k:X===m(te)&&R(te),We(F)}else R(te);X=m(te)}if(X!==null)var re=!0;else{var ie=m(z);ie!==null&&Z(Ae,ie.startTime-F),re=!1}return re}finally{X=null,ee=A,Me=!1}}var oe=!1,je=null,Be=-1,gt=5,ct=-1;function Ut(){return!(i.unstable_now()-ctM||125y?(M.sortIndex=A,h(z,M),m(te)===null&&M===m(z)&&(ce?(Ve(Be),Be=-1):ce=!0,Z(Ae,A-y))):(M.sortIndex=k,h(te,M),ue||Me||(ue=!0,ne($))),M},i.unstable_shouldYield=Ut,i.unstable_wrapCallback=function(M){var F=ee;return function(){var A=ee;ee=F;try{return M.apply(this,arguments)}finally{ee=A}}}})(wa)),wa}var Vc;function jf(){return Vc||(Vc=1,Sa.exports=kf()),Sa.exports}var Wc;function Cf(){if(Wc)return Ft;Wc=1;var i=Ma(),h=jf();function m(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),te=Object.prototype.hasOwnProperty,z=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Y={},X={};function ee(e){return te.call(X,e)?!0:te.call(Y,e)?!1:z.test(e)?X[e]=!0:(Y[e]=!0,!1)}function Me(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function ue(e,t,n,r){if(t===null||typeof t>"u"||Me(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ce(e,t,n,r,s,o,u){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=u}var pe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){pe[e]=new ce(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];pe[t]=new ce(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){pe[e]=new ce(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){pe[e]=new ce(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){pe[e]=new ce(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){pe[e]=new ce(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){pe[e]=new ce(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){pe[e]=new ce(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){pe[e]=new ce(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ve=/[\-:]([a-z])/g;function Xe(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ve,Xe);pe[t]=new ce(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ve,Xe);pe[t]=new ce(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ve,Xe);pe[t]=new ce(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){pe[e]=new ce(e,1,!1,e.toLowerCase(),null,!1,!1)}),pe.xlinkHref=new ce("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){pe[e]=new ce(e,1,!1,e.toLowerCase(),null,!0,!0)});function We(e,t,n,r){var s=pe.hasOwnProperty(t)?pe[t]:null;(s!==null?s.type!==0:r||!(2d||s[u]!==o[d]){var p=` -`+s[u].replace(" at new "," at ");return e.displayName&&p.includes("")&&(p=p.replace("",e.displayName)),p}while(1<=u&&0<=d);break}}}finally{re=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?k(e):""}function ae(e){switch(e.tag){case 5:return k(e.type);case 16:return k("Lazy");case 13:return k("Suspense");case 19:return k("SuspenseList");case 0:case 2:case 15:return e=ie(e.type,!1),e;case 11:return e=ie(e.type.render,!1),e;case 1:return e=ie(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case je:return"Fragment";case oe:return"Portal";case gt:return"Profiler";case Be:return"StrictMode";case B:return"Suspense";case Le:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ut:return(e.displayName||"Context")+".Consumer";case ct:return(e._context.displayName||"Context")+".Provider";case dt:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ke:return t=e.displayName||null,t!==null?t:he(e.type)||"Memo";case ne:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}function ye(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(t);case 8:return t===Be?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function xe(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function we(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ft(e){var t=we(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(u){r=""+u,o.call(this,u)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(u){r=""+u},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function qt(e){e._valueTracker||(e._valueTracker=ft(e))}function ir(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=we(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Cn(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function an(e,t){var n=t.checked;return A({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Pe(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=xe(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Bt(e,t){t=t.checked,t!=null&&We(e,"checked",t,!1)}function st(e,t){Bt(e,t);var n=xe(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?jt(e,t.type,n):t.hasOwnProperty("defaultValue")&&jt(e,t.type,xe(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function vt(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function jt(e,t,n){(t!=="number"||Cn(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var un=Array.isArray;function G(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=At.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Pn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ot={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ur=["Webkit","ms","Moz","O"];Object.keys(ot).forEach(function(e){ur.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ot[t]=ot[e]})});function cr(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ot.hasOwnProperty(e)&&ot[e]?(""+t).trim():t+"px"}function Tn(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=cr(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var $r=A({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function cn(e,t){if(t){if($r[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(m(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(m(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(m(61))}if(t.style!=null&&typeof t.style!="object")throw Error(m(62))}}function Kn(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ct=null;function Qe(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Rn=null,de=null,dn=null;function dr(e){if(e=ao(e)){if(typeof Rn!="function")throw Error(m(280));var t=e.stateNode;t&&(t=Vo(t),Rn(e.stateNode,e.type,t))}}function Fr(e){de?dn?dn.push(e):dn=[e]:de=e}function Ur(){if(de){var e=de,t=dn;if(dn=de=null,dr(e),t)for(e=0;e>>=0,e===0?32:31-(gr(e)/Fl|0)|0}var yr=64,Hr=4194304;function fe(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Nt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,o=e.pingedLanes,u=n&268435455;if(u!==0){var d=u&~s;d!==0?r=fe(d):(o&=u,o!==0&&(r=fe(o)))}else u=n&~s,u!==0?r=fe(u):o!==0&&(r=fe(o));if(r===0)return 0;if(t!==0&&t!==r&&(t&s)===0&&(s=r&-r,o=t&-t,s>=o||s===16&&(o&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function mn(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ht(t),e[t]=n}function pn(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Zt),La=" ",Ia=!1;function Da(e,t){switch(e){case"keyup":return Ee.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Oa(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ks=!1;function hd(e,t){switch(e){case"compositionend":return Oa(t);case"keypress":return t.which!==32?null:(Ia=!0,La);case"textInput":return e=t.data,e===La&&Ia?null:e;default:return null}}function gd(e,t){if(ks)return e==="compositionend"||!Fe&&Da(e,t)?(e=Xt(),qr=vn=Lt=null,ks=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ha(n)}}function Va(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Va(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Wa(){for(var e=window,t=Cn();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Cn(e.document)}return t}function ti(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Cd(e){var t=Wa(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Va(n.ownerDocument.documentElement,n)){if(r!==null&&ti(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!e.extend&&o>r&&(s=r,r=o,o=s),s=ba(n,o);var u=ba(n,r);s&&u&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==u.node||e.focusOffset!==u.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(u.node,u.offset)):(t.setEnd(u.node,u.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,js=null,ni=null,ro=null,ri=!1;function Ga(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ri||js==null||js!==Cn(r)||(r=js,"selectionStart"in r&&ti(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ro&&no(ro,r)||(ro=r,r=Qo(ni,"onSelect"),0Ts||(e.current=hi[Ts],hi[Ts]=null,Ts--)}function Ie(e,t){Ts++,hi[Ts]=e.current,e.current=t}var Er={},xt=Nr(Er),It=Nr(!1),es=Er;function Rs(e,t){var n=e.type.contextTypes;if(!n)return Er;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Dt(e){return e=e.childContextTypes,e!=null}function Wo(){ze(It),ze(xt)}function au(e,t,n){if(xt.current!==Er)throw Error(m(168));Ie(xt,t),Ie(It,n)}function uu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(m(108,ye(e)||"Unknown",s));return A({},n,r)}function Go(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Er,es=xt.current,Ie(xt,e),Ie(It,It.current),!0}function cu(e,t,n){var r=e.stateNode;if(!r)throw Error(m(169));n?(e=uu(e,t,es),r.__reactInternalMemoizedMergedChildContext=e,ze(It),ze(xt),Ie(xt,e)):ze(It),Ie(It,n)}var er=null,Ko=!1,gi=!1;function du(e){er===null?er=[e]:er.push(e)}function zd(e){Ko=!0,du(e)}function Pr(){if(!gi&&er!==null){gi=!0;var e=0,t=_e;try{var n=er;for(_e=1;e>=u,s-=u,tr=1<<32-Ht(t)+s|n<se?(ut=q,q=null):ut=q.sibling;var ke=j(x,q,_[se],T);if(ke===null){q===null&&(q=ut);break}e&&q&&ke.alternate===null&&t(x,q),g=o(ke,g,se),K===null?V=ke:K.sibling=ke,K=ke,q=ut}if(se===_.length)return n(x,q),Ue&&ns(x,se),V;if(q===null){for(;se<_.length;se++)q=P(x,_[se],T),q!==null&&(g=o(q,g,se),K===null?V=q:K.sibling=q,K=q);return Ue&&ns(x,se),V}for(q=r(x,q);se<_.length;se++)ut=D(q,x,se,_[se],T),ut!==null&&(e&&ut.alternate!==null&&q.delete(ut.key===null?se:ut.key),g=o(ut,g,se),K===null?V=ut:K.sibling=ut,K=ut);return e&&q.forEach(function(zr){return t(x,zr)}),Ue&&ns(x,se),V}function H(x,g,_,T){var V=F(_);if(typeof V!="function")throw Error(m(150));if(_=V.call(_),_==null)throw Error(m(151));for(var K=V=null,q=g,se=g=0,ut=null,ke=_.next();q!==null&&!ke.done;se++,ke=_.next()){q.index>se?(ut=q,q=null):ut=q.sibling;var zr=j(x,q,ke.value,T);if(zr===null){q===null&&(q=ut);break}e&&q&&zr.alternate===null&&t(x,q),g=o(zr,g,se),K===null?V=zr:K.sibling=zr,K=zr,q=ut}if(ke.done)return n(x,q),Ue&&ns(x,se),V;if(q===null){for(;!ke.done;se++,ke=_.next())ke=P(x,ke.value,T),ke!==null&&(g=o(ke,g,se),K===null?V=ke:K.sibling=ke,K=ke);return Ue&&ns(x,se),V}for(q=r(x,q);!ke.done;se++,ke=_.next())ke=D(q,x,se,ke.value,T),ke!==null&&(e&&ke.alternate!==null&&q.delete(ke.key===null?se:ke.key),g=o(ke,g,se),K===null?V=ke:K.sibling=ke,K=ke);return e&&q.forEach(function(yf){return t(x,yf)}),Ue&&ns(x,se),V}function Ye(x,g,_,T){if(typeof _=="object"&&_!==null&&_.type===je&&_.key===null&&(_=_.props.children),typeof _=="object"&&_!==null){switch(_.$$typeof){case $:e:{for(var V=_.key,K=g;K!==null;){if(K.key===V){if(V=_.type,V===je){if(K.tag===7){n(x,K.sibling),g=s(K,_.props.children),g.return=x,x=g;break e}}else if(K.elementType===V||typeof V=="object"&&V!==null&&V.$$typeof===ne&&vu(V)===K.type){n(x,K.sibling),g=s(K,_.props),g.ref=uo(x,K,_),g.return=x,x=g;break e}n(x,K);break}else t(x,K);K=K.sibling}_.type===je?(g=cs(_.props.children,x.mode,T,_.key),g.return=x,x=g):(T=wl(_.type,_.key,_.props,null,x.mode,T),T.ref=uo(x,g,_),T.return=x,x=T)}return u(x);case oe:e:{for(K=_.key;g!==null;){if(g.key===K)if(g.tag===4&&g.stateNode.containerInfo===_.containerInfo&&g.stateNode.implementation===_.implementation){n(x,g.sibling),g=s(g,_.children||[]),g.return=x,x=g;break e}else{n(x,g);break}else t(x,g);g=g.sibling}g=ma(_,x.mode,T),g.return=x,x=g}return u(x);case ne:return K=_._init,Ye(x,g,K(_._payload),T)}if(un(_))return U(x,g,_,T);if(F(_))return H(x,g,_,T);Xo(x,_)}return typeof _=="string"&&_!==""||typeof _=="number"?(_=""+_,g!==null&&g.tag===6?(n(x,g.sibling),g=s(g,_),g.return=x,x=g):(n(x,g),g=fa(_,x.mode,T),g.return=x,x=g),u(x)):n(x,g)}return Ye}var Is=yu(!0),xu=yu(!1),Zo=Nr(null),el=null,Ds=null,wi=null;function ki(){wi=Ds=el=null}function ji(e){var t=Zo.current;ze(Zo),e._currentValue=t}function Ci(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Os(e,t){el=e,wi=Ds=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ot=!0),e.firstContext=null)}function nn(e){var t=e._currentValue;if(wi!==e)if(e={context:e,memoizedValue:t,next:null},Ds===null){if(el===null)throw Error(m(308));Ds=e,el.dependencies={lanes:0,firstContext:e}}else Ds=Ds.next=e;return t}var rs=null;function Ni(e){rs===null?rs=[e]:rs.push(e)}function _u(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Ni(t)):(n.next=s.next,s.next=n),t.interleaved=n,rr(e,r)}function rr(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Tr=!1;function Ei(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Su(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function sr(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Rr(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(Se&2)!==0){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,rr(e,n)}return s=r.interleaved,s===null?(t.next=t,Ni(r)):(t.next=s.next,s.next=t),r.interleaved=t,rr(e,n)}function tl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xr(e,n)}}function wu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var u={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?s=o=u:o=o.next=u,n=n.next}while(n!==null);o===null?s=o=t:o=o.next=t}else s=o=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function nl(e,t,n,r){var s=e.updateQueue;Tr=!1;var o=s.firstBaseUpdate,u=s.lastBaseUpdate,d=s.shared.pending;if(d!==null){s.shared.pending=null;var p=d,S=p.next;p.next=null,u===null?o=S:u.next=S,u=p;var N=e.alternate;N!==null&&(N=N.updateQueue,d=N.lastBaseUpdate,d!==u&&(d===null?N.firstBaseUpdate=S:d.next=S,N.lastBaseUpdate=p))}if(o!==null){var P=s.baseState;u=0,N=S=p=null,d=o;do{var j=d.lane,D=d.eventTime;if((r&j)===j){N!==null&&(N=N.next={eventTime:D,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var U=e,H=d;switch(j=t,D=n,H.tag){case 1:if(U=H.payload,typeof U=="function"){P=U.call(D,P,j);break e}P=U;break e;case 3:U.flags=U.flags&-65537|128;case 0:if(U=H.payload,j=typeof U=="function"?U.call(D,P,j):U,j==null)break e;P=A({},P,j);break e;case 2:Tr=!0}}d.callback!==null&&d.lane!==0&&(e.flags|=64,j=s.effects,j===null?s.effects=[d]:j.push(d))}else D={eventTime:D,lane:j,tag:d.tag,payload:d.payload,callback:d.callback,next:null},N===null?(S=N=D,p=P):N=N.next=D,u|=j;if(d=d.next,d===null){if(d=s.shared.pending,d===null)break;j=d,d=j.next,j.next=null,s.lastBaseUpdate=j,s.shared.pending=null}}while(!0);if(N===null&&(p=P),s.baseState=p,s.firstBaseUpdate=S,s.lastBaseUpdate=N,t=s.shared.interleaved,t!==null){s=t;do u|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);ls|=u,e.lanes=u,e.memoizedState=P}}function ku(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Ai.transition;Ai.transition={};try{e(!1),t()}finally{_e=n,Ai.transition=r}}function Qu(){return rn().memoizedState}function Bd(e,t,n){var r=Ir(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Hu(e))bu(t,n);else if(n=_u(e,t,n,r),n!==null){var s=Mt();jn(n,e,r,s),Vu(n,t,r)}}function Qd(e,t,n){var r=Ir(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Hu(e))bu(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var u=t.lastRenderedState,d=o(u,n);if(s.hasEagerState=!0,s.eagerState=d,xn(d,u)){var p=t.interleaved;p===null?(s.next=s,Ni(t)):(s.next=p.next,p.next=s),t.interleaved=s;return}}catch{}n=_u(e,t,s,r),n!==null&&(s=Mt(),jn(n,e,r,s),Vu(n,t,r))}}function Hu(e){var t=e.alternate;return e===be||t!==null&&t===be}function bu(e,t){po=ol=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Vu(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xr(e,n)}}var al={readContext:nn,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},Hd={readContext:nn,useCallback:function(e,t){return Vn().memoizedState=[e,t===void 0?null:t],e},useContext:nn,useEffect:Iu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ll(4194308,4,zu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ll(4194308,4,e,t)},useInsertionEffect:function(e,t){return ll(4,2,e,t)},useMemo:function(e,t){var n=Vn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Vn();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Bd.bind(null,be,e),[r.memoizedState,e]},useRef:function(e){var t=Vn();return e={current:e},t.memoizedState=e},useState:Au,useDebugValue:Fi,useDeferredValue:function(e){return Vn().memoizedState=e},useTransition:function(){var e=Au(!1),t=e[0];return e=Ud.bind(null,e[1]),Vn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=be,s=Vn();if(Ue){if(n===void 0)throw Error(m(407));n=n()}else{if(n=t(),at===null)throw Error(m(349));(os&30)!==0||Eu(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,Iu(Tu.bind(null,r,o,e),[e]),r.flags|=2048,vo(9,Pu.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Vn(),t=at.identifierPrefix;if(Ue){var n=nr,r=tr;n=(r&~(1<<32-Ht(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ho++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=u.createElement(n,{is:r.is}):(e=u.createElement(n),n==="select"&&(u=e,r.multiple?u.multiple=!0:r.size&&(u.size=r.size))):e=u.createElementNS(e,n),e[Hn]=t,e[io]=r,dc(e,t,!1,!1),t.stateNode=e;e:{switch(u=Kn(n,r),n){case"dialog":Oe("cancel",e),Oe("close",e),s=r;break;case"iframe":case"object":case"embed":Oe("load",e),s=r;break;case"video":case"audio":for(s=0;sBs&&(t.flags|=128,r=!0,yo(o,!1),t.lanes=4194304)}else{if(!r)if(e=rl(u),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),yo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!u.alternate&&!Ue)return St(t),null}else 2*De()-o.renderingStartTime>Bs&&n!==1073741824&&(t.flags|=128,r=!0,yo(o,!1),t.lanes=4194304);o.isBackwards?(u.sibling=t.child,t.child=u):(n=o.last,n!==null?n.sibling=u:t.child=u,o.last=u)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=De(),t.sibling=null,n=He.current,Ie(He,r?n&1|2:n&1),t):(St(t),null);case 22:case 23:return ua(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(Kt&1073741824)!==0&&(St(t),t.subtreeFlags&6&&(t.flags|=8192)):St(t),null;case 24:return null;case 25:return null}throw Error(m(156,t.tag))}function Yd(e,t){switch(yi(t),t.tag){case 1:return Dt(t.type)&&Wo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zs(),ze(It),ze(xt),Mi(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Ti(t),null;case 13:if(ze(He),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(m(340));Ls()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ze(He),null;case 4:return zs(),null;case 10:return ji(t.type._context),null;case 22:case 23:return ua(),null;case 24:return null;default:return null}}var fl=!1,wt=!1,Xd=typeof WeakSet=="function"?WeakSet:Set,O=null;function Fs(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ge(e,t,r)}else n.current=null}function Yi(e,t,n){try{n()}catch(r){Ge(e,t,r)}}var pc=!1;function Zd(e,t){if(ui=gs,e=Wa(),ti(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var u=0,d=-1,p=-1,S=0,N=0,P=e,j=null;t:for(;;){for(var D;P!==n||s!==0&&P.nodeType!==3||(d=u+s),P!==o||r!==0&&P.nodeType!==3||(p=u+r),P.nodeType===3&&(u+=P.nodeValue.length),(D=P.firstChild)!==null;)j=P,P=D;for(;;){if(P===e)break t;if(j===n&&++S===s&&(d=u),j===o&&++N===r&&(p=u),(D=P.nextSibling)!==null)break;P=j,j=P.parentNode}P=D}n=d===-1||p===-1?null:{start:d,end:p}}else n=null}n=n||{start:0,end:0}}else n=null;for(ci={focusedElem:e,selectionRange:n},gs=!1,O=t;O!==null;)if(t=O,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,O=e;else for(;O!==null;){t=O;try{var U=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(U!==null){var H=U.memoizedProps,Ye=U.memoizedState,x=t.stateNode,g=x.getSnapshotBeforeUpdate(t.elementType===t.type?H:Sn(t.type,H),Ye);x.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var _=t.stateNode.containerInfo;_.nodeType===1?_.textContent="":_.nodeType===9&&_.documentElement&&_.removeChild(_.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(m(163))}}catch(T){Ge(t,t.return,T)}if(e=t.sibling,e!==null){e.return=t.return,O=e;break}O=t.return}return U=pc,pc=!1,U}function xo(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var o=s.destroy;s.destroy=void 0,o!==void 0&&Yi(t,n,o)}s=s.next}while(s!==r)}}function ml(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Xi(e){var t=e.ref;if(t!==null){var n=e.stateNode;e.tag,e=n,typeof t=="function"?t(e):t.current=e}}function hc(e){var t=e.alternate;t!==null&&(e.alternate=null,hc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Hn],delete t[io],delete t[pi],delete t[Dd],delete t[Od])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function gc(e){return e.tag===5||e.tag===3||e.tag===4}function vc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||gc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Zi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=bo));else if(r!==4&&(e=e.child,e!==null))for(Zi(e,t,n),e=e.sibling;e!==null;)Zi(e,t,n),e=e.sibling}function ea(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ea(e,t,n),e=e.sibling;e!==null;)ea(e,t,n),e=e.sibling}var pt=null,wn=!1;function Mr(e,t,n){for(n=n.child;n!==null;)yc(e,t,n),n=n.sibling}function yc(e,t,n){if(Yt&&typeof Yt.onCommitFiberUnmount=="function")try{Yt.onCommitFiberUnmount(On,n)}catch{}switch(n.tag){case 5:wt||Fs(n,t);case 6:var r=pt,s=wn;pt=null,Mr(e,t,n),pt=r,wn=s,pt!==null&&(wn?(e=pt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):pt.removeChild(n.stateNode));break;case 18:pt!==null&&(wn?(e=pt,n=n.stateNode,e.nodeType===8?mi(e.parentNode,n):e.nodeType===1&&mi(e,n),Gr(e)):mi(pt,n.stateNode));break;case 4:r=pt,s=wn,pt=n.stateNode.containerInfo,wn=!0,Mr(e,t,n),pt=r,wn=s;break;case 0:case 11:case 14:case 15:if(!wt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,u=o.destroy;o=o.tag,u!==void 0&&((o&2)!==0||(o&4)!==0)&&Yi(n,t,u),s=s.next}while(s!==r)}Mr(e,t,n);break;case 1:if(!wt&&(Fs(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(d){Ge(n,t,d)}Mr(e,t,n);break;case 21:Mr(e,t,n);break;case 22:n.mode&1?(wt=(r=wt)||n.memoizedState!==null,Mr(e,t,n),wt=r):Mr(e,t,n);break;default:Mr(e,t,n)}}function xc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Xd),t.forEach(function(r){var s=uf.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function kn(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=u),r&=~o}if(r=s,r=De()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*tf(r/1960))-r,10e?16:e,Lr===null)var r=!1;else{if(e=Lr,Lr=null,yl=0,(Se&6)!==0)throw Error(m(331));var s=Se;for(Se|=4,O=e.current;O!==null;){var o=O,u=o.child;if((O.flags&16)!==0){var d=o.deletions;if(d!==null){for(var p=0;pDe()-ra?as(e,0):na|=n),$t(e,t)}function Ac(e,t){t===0&&((e.mode&1)===0?t=1:(t=Hr,Hr<<=1,(Hr&130023424)===0&&(Hr=4194304)));var n=Mt();e=rr(e,t),e!==null&&(mn(e,t,n),$t(e,n))}function af(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ac(e,n)}function uf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(m(314))}r!==null&&r.delete(t),Ac(e,n)}var Lc;Lc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||It.current)Ot=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return Ot=!1,qd(e,t,n);Ot=(e.flags&131072)!==0}else Ot=!1,Ue&&(t.flags&1048576)!==0&&fu(t,Jo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;dl(e,t),e=t.pendingProps;var s=Rs(t,xt.current);Os(t,n),s=Ii(null,t,r,e,s,n);var o=Di();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Dt(r)?(o=!0,Go(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Ei(t),s.updater=ul,t.stateNode=s,s._reactInternals=t,Bi(t,r,e,n),t=Vi(null,t,r,!0,o,n)):(t.tag=0,Ue&&o&&vi(t),Rt(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(dl(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=df(r),e=Sn(r,e),s){case 0:t=bi(null,t,r,e,n);break e;case 1:t=oc(null,t,r,e,n);break e;case 11:t=ec(null,t,r,e,n);break e;case 14:t=tc(null,t,r,Sn(r.type,e),n);break e}throw Error(m(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Sn(r,s),bi(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Sn(r,s),oc(e,t,r,s,n);case 3:e:{if(lc(t),e===null)throw Error(m(387));r=t.pendingProps,o=t.memoizedState,s=o.element,Su(e,t),nl(t,r,null,n);var u=t.memoizedState;if(r=u.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:u.cache,pendingSuspenseBoundaries:u.pendingSuspenseBoundaries,transitions:u.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=$s(Error(m(423)),t),t=ic(e,t,r,n,s);break e}else if(r!==s){s=$s(Error(m(424)),t),t=ic(e,t,r,n,s);break e}else for(Gt=Cr(t.stateNode.containerInfo.firstChild),Wt=t,Ue=!0,_n=null,n=xu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ls(),r===s){t=or(e,t,n);break e}Rt(e,t,r,n)}t=t.child}return t;case 5:return ju(t),e===null&&_i(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,u=s.children,di(r,s)?u=null:o!==null&&di(r,o)&&(t.flags|=32),sc(e,t),Rt(e,t,u,n),t.child;case 6:return e===null&&_i(t),null;case 13:return ac(e,t,n);case 4:return Pi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Is(t,null,r,n):Rt(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Sn(r,s),ec(e,t,r,s,n);case 7:return Rt(e,t,t.pendingProps,n),t.child;case 8:return Rt(e,t,t.pendingProps.children,n),t.child;case 12:return Rt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,o=t.memoizedProps,u=s.value,Ie(Zo,r._currentValue),r._currentValue=u,o!==null)if(xn(o.value,u)){if(o.children===s.children&&!It.current){t=or(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var d=o.dependencies;if(d!==null){u=o.child;for(var p=d.firstContext;p!==null;){if(p.context===r){if(o.tag===1){p=sr(-1,n&-n),p.tag=2;var S=o.updateQueue;if(S!==null){S=S.shared;var N=S.pending;N===null?p.next=p:(p.next=N.next,N.next=p),S.pending=p}}o.lanes|=n,p=o.alternate,p!==null&&(p.lanes|=n),Ci(o.return,n,t),d.lanes|=n;break}p=p.next}}else if(o.tag===10)u=o.type===t.type?null:o.child;else if(o.tag===18){if(u=o.return,u===null)throw Error(m(341));u.lanes|=n,d=u.alternate,d!==null&&(d.lanes|=n),Ci(u,n,t),u=o.sibling}else u=o.child;if(u!==null)u.return=o;else for(u=o;u!==null;){if(u===t){u=null;break}if(o=u.sibling,o!==null){o.return=u.return,u=o;break}u=u.return}o=u}Rt(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Os(t,n),s=nn(s),r=r(s),t.flags|=1,Rt(e,t,r,n),t.child;case 14:return r=t.type,s=Sn(r,t.pendingProps),s=Sn(r.type,s),tc(e,t,r,s,n);case 15:return nc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Sn(r,s),dl(e,t),t.tag=1,Dt(r)?(e=!0,Go(t)):e=!1,Os(t,n),Gu(t,r,s),Bi(t,r,s,n),Vi(null,t,r,!0,e,n);case 19:return cc(e,t,n);case 22:return rc(e,t,n)}throw Error(m(156,t.tag))};function Ic(e,t){return pr(e,t)}function cf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function on(e,t,n,r){return new cf(e,t,n,r)}function da(e){return e=e.prototype,!(!e||!e.isReactComponent)}function df(e){if(typeof e=="function")return da(e)?1:0;if(e!=null){if(e=e.$$typeof,e===dt)return 11;if(e===Ke)return 14}return 2}function Or(e,t){var n=e.alternate;return n===null?(n=on(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function wl(e,t,n,r,s,o){var u=2;if(r=e,typeof e=="function")da(e)&&(u=1);else if(typeof e=="string")u=5;else e:switch(e){case je:return cs(n.children,s,o,t);case Be:u=8,s|=8;break;case gt:return e=on(12,n,t,s|2),e.elementType=gt,e.lanes=o,e;case B:return e=on(13,n,t,s),e.elementType=B,e.lanes=o,e;case Le:return e=on(19,n,t,s),e.elementType=Le,e.lanes=o,e;case Z:return kl(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ct:u=10;break e;case Ut:u=9;break e;case dt:u=11;break e;case Ke:u=14;break e;case ne:u=16,r=null;break e}throw Error(m(130,e==null?e:typeof e,""))}return t=on(u,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function cs(e,t,n,r){return e=on(7,e,r,t),e.lanes=n,e}function kl(e,t,n,r){return e=on(22,e,r,t),e.elementType=Z,e.lanes=n,e.stateNode={isHidden:!1},e}function fa(e,t,n){return e=on(6,e,null,t),e.lanes=n,e}function ma(e,t,n){return t=on(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ff(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pt(0),this.expirationTimes=Pt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pt(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function pa(e,t,n,r,s,o,u,d,p){return e=new ff(e,t,n,d,p),t===1?(t=1,o===!0&&(t|=8)):t=0,o=on(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ei(o),e}function mf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(h){console.error(h)}}return i(),_a.exports=Cf(),_a.exports}var Kc;function Ef(){if(Kc)return Rl;Kc=1;var i=Nf();return Rl.createRoot=i.createRoot,Rl.hydrateRoot=i.hydrateRoot,Rl}var Pf=Ef();const Tf=cd(Pf),Rf="/api";async function ve(i,h){const m=await fetch(`${Rf}${i}`,{...h,headers:{"Content-Type":"application/json",...h?.headers??{}}}),R=await m.json();if(!m.ok){const E=R.error?.message??"Ошибка запроса";throw new Error(E)}return R}const Re={async loadSharedConnectionConfig(){return ve("/llm/shared-connection")},async saveSharedConnectionConfig(i){return ve("/llm/shared-connection",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,model:i.model,baseUrl:i.baseUrl,temperature:i.temperature,maxOutputTokens:i.maxOutputTokens})})},async listModels(i){return ve("/llm/models",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,apiKey:i.apiKey,model:i.model,baseUrl:i.baseUrl})})},async testConnection(i){return ve("/llm/test-connection",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,apiKey:i.apiKey,model:i.model,baseUrl:i.baseUrl})})},async normalize(i){return ve("/normalize",{method:"POST",body:JSON.stringify({llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples,userQuestion:i.query.userQuestion,context:{period_hint:i.query.periodHint??"",business_context:i.query.businessContext??"",expected_route:i.query.expectedRoute??""},saveAsTestCase:!!i.saveAsTestCase,useMock:!!i.useMock})})},async loadHistory(){return ve("/history")},async loadTrace(i){return ve(`/history/${i}`)},async loadPresets(){return ve("/presets")},async savePreset(i){return ve("/presets/save",{method:"POST",body:JSON.stringify(i)})},async runEval(i){return ve("/eval/run",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples},caseIds:i.caseIds,useMock:!!i.useMock,mode:i.mode??"standard",caseSetFile:i.caseSetFile,rawQuestions:i.rawQuestions,eval_target:i.evalTarget,compare_with_report_file:i.compareWithReportFile,analysis_date:i.analysisDate})})},async startEvalRunAsync(i){return ve("/eval/run-async/start",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples},caseIds:i.caseIds,useMock:!!i.useMock,mode:i.mode??"standard",caseSetFile:i.caseSetFile,rawQuestions:i.rawQuestions,eval_target:i.evalTarget,compare_with_report_file:i.compareWithReportFile,questions:i.questions,scenarioQuestions:i.scenarioQuestions,scenarioTitle:i.scenarioTitle,analysis_date:i.analysisDate})})},async loadEvalRunAsyncStatus(i){return ve(`/eval/run-async/${encodeURIComponent(i)}`)},async startRun(){return ve("/accounting-agent/v1/runs/start",{method:"POST",body:JSON.stringify({initiator:"ndc_operator",source:"gui"})})},async finishRun(i){return ve("/accounting-agent/v1/runs/finish",{method:"POST",body:JSON.stringify({runId:i,status:"DONE",source:"gui",reason:"Остановлено оператором из GUI"})})},async listRuns(){return ve("/accounting-agent/v1/runs")},async listResults(){return ve("/accounting-agent/v1/results")},async runTrace(i){return ve(`/accounting-agent/v1/trace/run/${i}`)},async sendAssistantMessage(i){return ve("/assistant/message",{method:"POST",body:JSON.stringify({session_id:i.sessionId??"",mode:"assistant",message:i.userMessage,user_message:i.userMessage,llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion??"address_query_runtime_v1",systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples,context:{period_hint:i.context?.periodHint??"",business_context:i.context?.businessContext??""},useMock:!!i.useMock})})},async loadAssistantSession(i){return ve(`/assistant/session/${i}`)},async saveAutoRunAssistantSession(i){return ve("/autoruns/autogen/save-assistant-session",{method:"POST",body:JSON.stringify(i)})},async loadAssistantAnnotations(i){const h=new URLSearchParams;i?.session_id&&h.set("session_id",i.session_id),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const m=h.toString();return ve(`/assistant/annotations${m?`?${m}`:""}`)},async saveAssistantAnnotation(i){return ve("/assistant/annotations",{method:"POST",body:JSON.stringify(i)})},async loadAutoRunsHistory(i){const h=new URLSearchParams;i?.from&&h.set("from",i.from),i?.to&&h.set("to",i.to),i?.target&&h.set("target",i.target),i?.mode&&h.set("mode",i.mode),i?.use_mock&&h.set("use_mock",i.use_mock),i?.prompt_contains&&h.set("prompt_contains",i.prompt_contains),typeof i?.limit=="number"&&h.set("limit",String(i.limit)),typeof i?.scan_limit=="number"&&h.set("scan_limit",String(i.scan_limit));const m=h.toString();return ve(`/autoruns/history${m?`?${m}`:""}`)},async loadAutoRunDetail(i){return ve(`/autoruns/history/${encodeURIComponent(i)}`)},async loadAutoRunCaseDialog(i,h){return ve(`/autoruns/history/${encodeURIComponent(i)}/case/${encodeURIComponent(h)}/dialog`)},async loadAutoRunAnnotations(i){const h=new URLSearchParams;i?.run_id&&h.set("run_id",i.run_id),i?.case_id&&h.set("case_id",i.case_id),typeof i?.min_rating=="number"&&h.set("min_rating",String(i.min_rating)),i?.manual_case_decision&&h.set("manual_case_decision",i.manual_case_decision),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const m=h.toString();return ve(`/autoruns/annotations${m?`?${m}`:""}`)},async saveAutoRunAnnotation(i){return ve("/autoruns/annotations",{method:"POST",body:JSON.stringify(i)})},async updateAutoRunAnnotation(i){return ve(`/autoruns/annotations/${encodeURIComponent(i.annotation_id)}`,{method:"PATCH",body:JSON.stringify({resolved:i.resolved,resolved_by:i.resolved_by})})},async loadAutoRunPostAnalysis(i){const h=new URLSearchParams;i?.run_id&&h.set("run_id",i.run_id),typeof i?.limit_per_queue=="number"&&h.set("limit_per_queue",String(i.limit_per_queue)),typeof i?.annotation_limit=="number"&&h.set("annotation_limit",String(i.annotation_limit)),typeof i?.scan_limit=="number"&&h.set("scan_limit",String(i.scan_limit)),i?.from&&h.set("from",i.from),i?.to&&h.set("to",i.to),i?.target&&h.set("target",i.target),i?.mode&&h.set("mode",i.mode),i?.use_mock&&h.set("use_mock",i.use_mock),i?.prompt_contains&&h.set("prompt_contains",i.prompt_contains);const m=h.toString();return ve(`/autoruns/post-analysis${m?`?${m}`:""}`)},async loadAutoRunAutogenHistory(i){const h=new URLSearchParams;i?.mode&&h.set("mode",i.mode),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const m=h.toString();return ve(`/autoruns/autogen/history${m?`?${m}`:""}`)},async loadAutoRunAutogenPersonalityCatalog(){return ve("/autoruns/autogen/personality-catalog")},async updateAutoRunAutogenQuestions(i){return ve(`/autoruns/autogen/history/${encodeURIComponent(i.generation_id)}/questions`,{method:"PATCH",body:JSON.stringify({questions:i.questions})})},async deleteAutoRunAutogenHistoryRecord(i){return ve(`/autoruns/autogen/history/${encodeURIComponent(i)}`,{method:"DELETE"})},async generateAutoRunQuestions(i){return ve("/autoruns/autogen/generate",{method:"POST",body:JSON.stringify(i)})}},Mf=/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json|debug_payload|technical_breakdown)\b/i,Af=[/\b(?:debug_payload_json|technical_breakdown_json)\b/i,/\b(?:route_summary|semantic_profile|domain_scope|relation_patterns|account_scope)\b/i,/\b(?:coverage_report|retrieval_status|problem_unit_state|candidate_evidence)\b/i,/\b(?:graph_domain_scope|graph_runtime|selection_reason|why_included)\b/i];function Lf(i){try{return JSON.stringify(i,null,2)}catch{return String(i)}}function If(i){const h=String(i??""),m=h.match(Mf);return(m?h.slice(0,m.index):h).replace(/###\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)[\s\S]*?(?:```[\s\S]*?```|$)/gi,"").replace(/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)\b[\s\S]*$/gi,"").split(/\r?\n/g).map(Q=>Q.trimEnd()).filter(Q=>Q.trim().length>0).filter(Q=>!Af.some(le=>le.test(Q))).join(` -`).trim()}function Df(i,h,m="default"){const R=m==="technical",E=[];E.push("# Assistant conversation export"),E.push(`session_id: ${i||"n/a"}`),E.push(`export_mode: ${m}`),E.push(`exported_at: ${new Date().toISOString()}`),E.push("");for(let I=0;I{E.length!==0&&(R.push(E.join(` -`)),E=[])};for(const Q of m){const le=Q.trimEnd(),te=le.trim();if(!te){I();continue}const z=/^Блок\s+\d+\./i.test(te),Y=/^\d+\.\s/.test(te);(z||Y)&&E.length>0&&I(),E.push(le)}return I(),R.length>0?R:[i]}function Qf(i,h){const m=[],R=/\*\*(.+?)\*\*/g;let E=0,I=0,Q;for(;(Q=R.exec(i))!==null;)Q.index>E&&(m.push(l.jsx("span",{children:i.slice(E,Q.index)},`${h}-t-${I}`)),I+=1),m.push(l.jsx("strong",{children:Q[1]},`${h}-b-${I}`)),I+=1,E=R.lastIndex;return E0?m:[l.jsx("span",{children:i},`${h}-raw`)]}function Hf(i){const h=i.trimStart();return/^Блок\s+\d+\./i.test(h)?"assistant-msg-line heading":/^\d+\.\s/.test(h)?"assistant-msg-line numbered":/^-\s/.test(h)?"assistant-msg-line bullet":"assistant-msg-line"}function bf(i,h=40){const m=i.replace(/\s+/g," ").trim();if(m.length<=h)return m;const R=m.split(" ").slice(0,3).join(" ").trim();return R.length>=10&&R.length<=h?`${R}…`:`${m.slice(0,h-1).trimEnd()}…`}function fd(i){return i.replace(/\*\*(.+?)\*\*/g,"$1").replace(/^\d+\.\s*/,"").trim()}function Vf(i){const h=i.replace(/\r\n?/g,` -`).split(` -`).map(E=>E.trim()).find(Boolean),m=fd(h??"");return(m.split("|")[0]?.trim()??m).replace(/\s+/g," ").trim()}function Wf(i){const h=i.replace(/\r\n?/g,` -`).split(` -`).map(R=>R.trim()).find(Boolean);return!h||!/^\d+\.\s/.test(h)?!1:fd(h).includes("|")}function Gf(i,h){const m=h.replace(/\r\n?/g,` -`).replace(/\*\*(.+?)\*\*/g,"$1").split(` -`).map((E,I)=>{const Q=E.trim();return I===0?Q.replace(/^\d+\.\s*/,""):Q}).filter(Boolean).join(" ").replace(/\s+/g," ").trim();if(!m)return null;const R=Vf(h)||m;return{message_id:i.message_id,source_text:m,anchor_text:R,preview_text:bf(R)}}function Kf(i,h,m,R){return Bf(i.text).map((I,Q)=>{const le=I.split(` -`),te=i.role==="assistant"&&Wf(I),z=te?Gf(i,I):null,Y=!!z&&h?.message_id===z?.message_id&&h?.source_text===z?.source_text,X=le.map((ee,Me)=>l.jsx("p",{className:Hf(ee),children:Qf(ee,`line-${Q}-${Me}`)},`line-${Q}-${Me}`));return!te||!z?l.jsx("div",{className:"assistant-msg-block",children:X},`block-${Q}`):l.jsx("div",{className:Y?"assistant-msg-block selectable active":"assistant-msg-block selectable",role:"button",tabIndex:0,onClick:()=>{if(Y){R();return}m(z)},onKeyDown:ee=>{if(!(ee.key!=="Enter"&&ee.key!==" ")){if(ee.preventDefault(),Y){R();return}m(z)}},children:X},`block-${Q}`)})}function qf({sessionId:i,conversation:h,inputValue:m,onInputChange:R,selectedContextChip:E,onSelectContextChip:I,onClearContextChip:Q,useMock:le,onUseMockChange:te,onSend:z,onClear:Y,onSaveSession:X,busy:ee,saveBusy:Me=!1,saveDisabled:ue=!1,statusText:ce,errorMessage:pe,showSaveAction:Ve=!1,showCommentAction:Xe=!1,onCommentAssistantMessage:We,isAssistantMessageCommented:Ae,canCommentAssistantMessage:$}){const oe=v.useRef(null),je=v.useRef(!0),Be=v.useRef(null),[gt,ct]=v.useState("idle"),[Ut,dt]=v.useState("чат");function B(ne=!1){oe.current&&(ne&&(je.current=!0),oe.current.scrollTop=oe.current.scrollHeight)}v.useEffect(()=>{je.current&&B()},[h]),v.useEffect(()=>()=>{Be.current!==null&&window.clearTimeout(Be.current)},[]);async function Le(ne){if(h.length===0)return;const Z=Df(i,h,ne),M=await $f(Z);dt(ne==="technical"?"тех":"чат"),ct(M?"success":"error"),Be.current!==null&&window.clearTimeout(Be.current),Be.current=window.setTimeout(()=>{ct("idle")},2200)}function Ke(){if(!oe.current)return;const ne=oe.current,Z=ne.scrollHeight-ne.scrollTop-ne.clientHeight;je.current=Z<16}return l.jsx($l,{className:"assistant-panel-frame",title:"Режим ассистента",children:l.jsxs("div",{className:"assistant-live-shell",children:[l.jsxs("div",{className:"assistant-toolbar",children:[l.jsxs("div",{className:"assistant-toolbar-actions",children:[l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{Le("default")},disabled:h.length===0,title:"Экспорт только user-facing чата",children:"Скопировать чат"}),l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{Le("technical")},disabled:h.length===0,title:"Технический экспорт с debug payload",children:"Скопировать техчат"}),Ve?l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>X?.(),disabled:Me||ue,children:Me?"Сохраняю...":"Сохранить"}):null,l.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>Y(),disabled:ee&&h.length===0,children:"Сбросить сессию"})]}),l.jsxs("div",{className:"assistant-toolbar-meta",children:[i?l.jsx("span",{className:"status-chip",children:`session: ${i}`}):null,l.jsxs("div",{className:"assistant-toolbar-meta-right",children:[ce?l.jsx("span",{className:"assistant-live-status",children:ce}):null,gt==="success"?l.jsxs("span",{className:"assistant-copy-feedback success",children:["Скопировано (",Ut,")"]}):null,gt==="error"?l.jsx("span",{className:"assistant-copy-feedback error",children:"Ошибка копирования"}):null]})]}),pe?l.jsx("p",{className:"error-text assistant-toolbar-error",children:pe}):null]}),l.jsx("div",{ref:oe,className:"assistant-chat-list",onScroll:Ke,children:h.map((ne,Z)=>{const M=ne.role==="assistant"&&Xe&&typeof We=="function"&&(typeof $=="function"?$(ne,Z):!0),F=ne.role==="assistant"&&typeof Ae=="function"?Ae(ne,Z):!1;return l.jsxs("article",{className:`assistant-msg ${ne.role}`,children:[l.jsxs("header",{className:"assistant-msg-head",children:[l.jsxs("div",{className:"assistant-msg-head-main",children:[l.jsx("strong",{children:Of(ne.role)}),l.jsx("span",{children:zf(ne.created_at)})]}),ne.role==="assistant"&&Xe?l.jsx("div",{className:"assistant-msg-head-actions",children:l.jsx("button",{type:"button",className:F?"autoruns-comment-icon assistant-comment-btn commented":"autoruns-comment-icon assistant-comment-btn",onClick:()=>We?.(ne,Z),disabled:!M,title:M?"Комментировать ответ ассистента":"Комментарий недоступен для этого сообщения","aria-label":M?"Комментировать ответ ассистента":"Комментарий недоступен для этого сообщения",children:l.jsx(Ff,{commented:F})})}):null]}),l.jsx("div",{className:"assistant-msg-body",children:Kf(ne,E,I,Q)}),ne.role==="assistant"&&ne.debug?l.jsxs("details",{className:"assistant-debug",children:[l.jsx("summary",{children:"Показать технический разбор"}),l.jsx(dd,{value:ne.debug})]}):null]},ne.message_id)})}),l.jsxs("div",{className:"assistant-compose",children:[E?l.jsxs("div",{className:"assistant-compose-context",children:[l.jsx("span",{className:"assistant-compose-context-label",children:"Выбранный объект"}),l.jsxs("div",{className:"assistant-compose-context-pill",title:E.source_text,children:[l.jsx("span",{className:"assistant-compose-context-pill-text",children:E.preview_text}),l.jsx("button",{type:"button",className:"assistant-compose-context-clear",onClick:Q,"aria-label":"Убрать выбранный объект",title:"Убрать выбранный объект",children:"×"})]})]}):null,l.jsxs("label",{className:"full-width",children:["Сообщение",l.jsx("textarea",{className:"assistant-input-textarea",value:m,onChange:ne=>R(ne.target.value),rows:4,placeholder:E?"Продолжите вопрос по выбранному объекту...":"Введите вопрос к данным компании..."})]}),l.jsxs("div",{className:"button-row assistant-send-row",children:[l.jsxs("label",{className:"checkbox-row",children:[l.jsx("input",{type:"checkbox",checked:le,onChange:ne=>te(ne.target.checked)}),"Mock-режим"]}),l.jsx("button",{type:"button",className:"assistant-send-btn",onClick:()=>{B(!0),z()},disabled:ee||!m.trim(),children:ee?"Выполняю...":"Отправить"})]})]})]})})}const Ml="http://127.0.0.1:1234/v1",qc="https://api.openai.com/v1",Ol="qwen2.5-14b-instruct-1m",Aa="unsloth/qwen3-30b-a3b-instruct-2507",Jf=[{value:Ol,label:"Qwen2.5 14B Instruct 1M"},{value:Aa,label:"Qwen3 30B A3B Instruct 2507"}];function Yf(i){return i.llmProvider!=="local"?"openai":i.model===Aa?"local_qwen3":i.model===Ol?"local_qwen25":"local_custom"}function Xf(i,h){const m=new Map;if(h)for(const R of Jf)m.set(R.value,R);for(const R of i)m.has(R)||m.set(R,{value:R,label:R});return Array.from(m.values())}function Zf({value:i,modelOptions:h,modelsBusy:m,onChange:R,onReloadModels:E,onTestConnection:I,onSaveLocalConfig:Q,lastStatus:le,busy:te,embedded:z=!1}){const Y=i.llmProvider==="local",X=Yf(i),ee=Xf(h,Y),Me=ee.some($=>$.value===i.model),[ue,ce]=v.useState(String(i.temperature)),[pe,Ve]=v.useState(String(i.maxOutputTokens));v.useEffect(()=>{ce(String(i.temperature))},[i.temperature]),v.useEffect(()=>{Ve(String(i.maxOutputTokens))},[i.maxOutputTokens]);const Xe=$=>{const oe=$.replace(",",".").trim();if(!oe){ce(String(i.temperature));return}const je=Number(oe);if(!Number.isFinite(je)){ce(String(i.temperature));return}R({...i,temperature:je}),ce(String(je))},We=$=>{const oe=$.trim();if(!oe){Ve(String(i.maxOutputTokens));return}const je=Number.parseInt(oe,10);if(!Number.isFinite(je)||je<=0){Ve(String(i.maxOutputTokens));return}R({...i,maxOutputTokens:je}),Ve(String(je))},Ae=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"grid-two",children:[l.jsxs("label",{children:["Provider",l.jsxs("select",{value:X,onChange:$=>{const oe=$.target.value;if(oe==="openai"){R({...i,llmProvider:"openai",baseUrl:qc});return}if(oe==="local_qwen25"){R({...i,llmProvider:"local",model:Ol,baseUrl:Ml});return}if(oe==="local_qwen3"){R({...i,llmProvider:"local",model:Aa,baseUrl:Ml});return}R({...i,llmProvider:"local",model:i.llmProvider==="local"?i.model:Ol,baseUrl:Ml})},children:[l.jsx("option",{value:"openai",children:"OpenAI (token)"}),l.jsx("option",{value:"local_qwen25",children:"Qwen2.5 14B Instruct 1M (Local LM Studio)"}),l.jsx("option",{value:"local_qwen3",children:"Qwen3 30B A3B Instruct 2507 (Local LM Studio)"}),l.jsx("option",{value:"local_custom",children:"Local custom (LM Studio / OpenAI-compatible)"})]})]}),l.jsxs("label",{children:["Model",l.jsxs("select",{value:Me?i.model:"__manual__",onChange:$=>{const oe=$.target.value;oe!=="__manual__"&&R({...i,model:oe})},children:[l.jsx("option",{value:"__manual__",children:"Manual input"}),ee.map($=>l.jsx("option",{value:$.value,children:$.label},$.value))]})]}),l.jsxs("label",{children:["Model ID (manual / current)",l.jsx("input",{value:i.model,onChange:$=>R({...i,model:$.target.value}),placeholder:"qwen2.5-14b-instruct-1m or unsloth/qwen3-30b-a3b-instruct-2507"})]}),Y?null:l.jsxs("label",{className:"full-width",children:["OpenAI API Key",l.jsx("input",{type:"password",value:i.apiKey,onChange:$=>R({...i,apiKey:$.target.value}),placeholder:"sk-..."})]}),l.jsxs("label",{className:Y?"full-width":void 0,children:[Y?"Local server base URL":"Base URL",l.jsx("input",{value:i.baseUrl,onChange:$=>R({...i,baseUrl:$.target.value}),placeholder:Y?Ml:qc})]}),l.jsxs("label",{children:["Temperature",l.jsx("input",{type:"number",step:"0.1",value:ue,onChange:$=>ce($.target.value),onBlur:$=>Xe($.target.value),onKeyDown:$=>{$.key==="Enter"&&Xe($.target.value)}})]}),l.jsxs("label",{children:["Max output tokens",l.jsx("input",{type:"number",value:pe,onChange:$=>Ve($.target.value),onBlur:$=>We($.target.value),onKeyDown:$=>{$.key==="Enter"&&We($.target.value)}})]})]}),l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>Q(),children:"Save local config"}),l.jsx("button",{type:"button",onClick:()=>E(),disabled:te||m,children:m?"Loading models...":"Load model list"}),l.jsx("button",{type:"button",onClick:()=>I(),disabled:te,children:te?"Checking...":"Test connection"})]})]});return z?l.jsxs("section",{className:"embedded-panel-section",children:[l.jsxs("div",{className:"embedded-panel-section-header",children:[l.jsxs("div",{children:[l.jsx("h4",{children:"LLM Connector"}),l.jsx("p",{children:"Switch between OpenAI cloud and local OpenAI-compatible server."})]}),l.jsx("span",{className:"status-chip",children:le||"Status: not checked"})]}),Ae]}):l.jsx($l,{title:"LLM Connector",subtitle:"Switch between OpenAI cloud and local OpenAI-compatible server.",actions:l.jsx("span",{className:"status-chip",children:le||"Status: not checked"}),children:Ae})}function em({value:i,onChange:h,presets:m,selectedPresetId:R,onSelectPreset:E,onLoadPreset:I,onSavePreset:Q,onResetDefaults:le,onDiffPrevious:te,presetName:z,onPresetNameChange:Y,diffSummary:X,embedded:ee=!1}){const Me=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"prompt-manager-grid",children:[l.jsxs("label",{children:["Системный prompt",l.jsx("textarea",{value:i.systemPrompt,onChange:ue=>h({...i,systemPrompt:ue.target.value}),rows:6})]}),l.jsxs("label",{children:["Developer / Instruction prompt",l.jsx("textarea",{value:i.developerPrompt,onChange:ue=>h({...i,developerPrompt:ue.target.value}),rows:6})]}),l.jsxs("label",{children:["Domain prompt",l.jsx("textarea",{value:i.domainPrompt,onChange:ue=>h({...i,domainPrompt:ue.target.value}),rows:6})]}),l.jsxs("label",{children:["Schema notes",l.jsx("textarea",{value:i.schemaNotes,onChange:ue=>h({...i,schemaNotes:ue.target.value}),rows:6})]}),l.jsxs("label",{className:"full-width",children:["Few-shot examples",l.jsx("textarea",{value:i.fewShotExamples,onChange:ue=>h({...i,fewShotExamples:ue.target.value}),rows:8})]})]}),l.jsxs("div",{className:"button-row",children:[l.jsxs("select",{value:R,onChange:ue=>E(ue.target.value),children:[l.jsx("option",{value:"",children:"Выберите preset..."}),m.map(ue=>l.jsx("option",{value:ue.id,children:ue.name},ue.id))]}),l.jsx("button",{type:"button",onClick:()=>I(),children:"Загрузить preset"}),l.jsx("input",{value:z,onChange:ue=>Y(ue.target.value),placeholder:"Имя для сохранения"}),l.jsx("button",{type:"button",onClick:()=>Q(),children:"Сохранить preset"}),l.jsx("button",{type:"button",onClick:()=>te(),children:"Diff с предыдущим"}),l.jsx("button",{type:"button",onClick:()=>le(),children:"Сбросить к default"})]}),X?l.jsx("p",{className:"diff-summary",children:X}):null]});return ee?l.jsxs("section",{className:"embedded-panel-section",children:[l.jsx("div",{className:"embedded-panel-section-header",children:l.jsxs("div",{children:[l.jsx("h4",{children:"Prompt Manager"}),l.jsx("p",{children:"Системный, developer и domain уровни управляются отдельно."})]})}),Me]}):l.jsx($l,{title:"Prompt Manager",subtitle:"Системный, developer и domain уровни управляются отдельно.",children:Me})}const ka={fromLocal:"",toLocal:"",target:"all",mode:"all",useMock:"any",promptContains:"",limit:120},Al="needs_dialog_policy_fix",kt="__all__",zl="__live__:",Jc="ndc_autoruns_ui_config_v1",Yc="ndc-autoruns-save",ja=["Анализ запроса","Получение данных","Подготовка ответа"];function tm(i,h){const m=i.trim();if(!m)return"";if(!h)return m;const R=m.toLowerCase(),E=h.anchor_text.trim(),I=E.toLowerCase();return I&&R.includes(I)?m:`По выбранному объекту "${E}": ${m}`}const Ra=[{id:"general",label:"Общий контур",domain:"",defaultPrompt:"Генерируй реалистичные живые вопросы бухгалтера по 1С. Добавляй разговорные формулировки и опечатки, но сохраняй бизнес-смысл."}];function nm(i=Ra){return i.reduce((h,m)=>(h[m.id]=m.defaultPrompt,h),{})}const Xc={mode:"codex_creative",count:24,personalityId:"general",personalityPrompts:nm(),persistToEvalCases:!0,generatedBy:"manual_reviewer"};function Ca(i){const h=String(i??"").trim();return/^\d{4}-\d{2}-\d{2}$/.test(h)?h:""}function Zc(i){const h=typeof i=="number"&&Number.isFinite(i)?Math.trunc(i):160;return Math.max(110,Math.min(520,h))}function rm(i){const h=i.getFullYear(),m=String(i.getMonth()+1).padStart(2,"0"),R=String(i.getDate()).padStart(2,"0"),E=String(i.getHours()).padStart(2,"0"),I=String(i.getMinutes()).padStart(2,"0");return`${h}-${m}-${R}T${E}:${I}`}function ed(){const i=new Date;return i.setDate(i.getDate()-14),rm(i)}function Ll(i){if(!i.trim())return;const h=Date.parse(i);if(Number.isFinite(h))return new Date(h).toISOString()}function ln(i){if(!i)return"нет данных";const h=Date.parse(i);return Number.isFinite(h)?new Date(h).toLocaleString("ru-RU"):i}function Na(i){return i==="saved_user_sessions"?"Пользовательские сессии":i}function md(i){return i?i.context?.agent_run===!0||i.context?.saved_case_set_kind==="agent_semantic_scenario"?!0:typeof i.title=="string"&&i.title.trim().toUpperCase().startsWith("AGENT"):!1}function td(i){const h=i.title??ln(i.created_at);return md(i)&&!h.trim().toUpperCase().startsWith("AGENT")?`AGENT | ${h}`:h}function sm(i){const h=i[i.length-1];return`Ручная сессия ${ln(h?.created_at??new Date().toISOString())}`}function om(i,h){return h<=0?0:Math.max(0,Math.min(100,Number((i/h*100).toFixed(1))))}function Il(i){return typeof i!="number"?"нет данных":`${i.toFixed(1)}%`}function lm(i){return i==="assistant_stage1"?"assistant/s1":i==="assistant_stage2"?"assistant/s2":i==="assistant_p0"?"assistant/p0":i}function nd(i){return i==="up"?"Рост":i==="down"?"Регресс":"Без изменений"}function Ea(i){const h=Math.max(1,Math.min(5,Math.round(i)));return`${"●".repeat(h)}${"○".repeat(5-h)}`}function rd(i){return i.length===0?l.jsx("p",{className:"muted",children:"Покрытие доменов пока не сформировано."}):l.jsx("div",{className:"autoruns-coverage-list",children:i.map(h=>{const m=om(h.closed_cases,h.total_cases);return l.jsxs("div",{className:"autoruns-coverage-item",children:[l.jsxs("div",{className:"autoruns-coverage-head",children:[l.jsx("strong",{children:h.domain}),l.jsxs("span",{children:[h.closed_cases,"/",h.total_cases," (",m,"%)"]})]}),l.jsx("div",{className:"autoruns-coverage-bar",children:l.jsx("div",{style:{width:`${m}%`}})})]},h.domain)})})}function Dl(i){return`${zl}${i}`}function Hs(i){return i.startsWith(zl)}function sd(i){return i.startsWith(zl)?i.slice(zl.length):""}function pd(i){const h=i.report_summary?.run_timestamp??i.created_at,m=Math.max(0,i.total_cases-i.completed_cases);return{run_id:Dl(i.job_id),eval_target:i.eval_target,run_timestamp:h,mode:"single-pass-strict",llm_provider:null,model:null,use_mock:null,analysis_date:i.report_summary?.analysis_date??i.analysis_date??null,prompt_version:null,schema_version:null,suite_id:i.case_set_file,cases_total:i.total_cases,requests_total:null,report_path:`async_job:${i.job_id}`,score_index:i.report_summary?.score_index??null,blocking_failures:0,quality_failures:0,closed_cases:i.completed_cases,open_cases:m,domain_coverage:[{domain:"runtime",total_cases:i.total_cases,closed_cases:i.completed_cases}]}}function Co(i,h){const m=pd(i),R=i.cases.map(Y=>({case_id:Y.case_id,domain:null,query_class:null,status:Y.status==="completed"?"closed":Y.status==="failed"?"open":"unknown",score_index:null,trace_id:null,reply_type:null,session_id:`${i.run_id}-${Y.case_id}`,dialog_available:Y.messages.length>0,commented_count:0,latest_annotation_at:null,avg_rating:null,checks:null,metric_subscores:null})),I=h!==kt&&R.some(Y=>Y.case_id===h)?h:R.length>0?kt:"",Q={ok:!0,run:m,coverage:{closed_cases:i.completed_cases,open_cases:Math.max(0,i.total_cases-i.completed_cases),domain_coverage:[{domain:"runtime",total_cases:i.total_cases,closed_cases:i.completed_cases}]},cases:R,annotations_summary:{total:0},report:i.report_summary?{run_id:i.report_summary.run_id,run_timestamp:i.report_summary.run_timestamp,score_index:i.report_summary.score_index,cases_total:i.report_summary.cases_total,analysis_date:i.report_summary.analysis_date??i.analysis_date??null}:{}},le=[];let te=0;if(I===kt)for(const Y of i.cases)for(let X=0;XX.case_id===I)??null;for(let X=0;X<(Y?.messages.length??0);X+=1){const ee=Y?.messages[X];ee&&le.push({...ee,message_index:X,case_id:I,case_message_index:X,commented:!1,annotation:null})}}const z={ok:!0,run_id:m.run_id,case_id:I,source:"assistant_session",session_id:I===kt?`${i.run_id}::__all__`:`${i.run_id}-${I}`,messages:le,decomposition:[],assistant_mode:{status:i.status,completed_cases:i.completed_cases,total_cases:i.total_cases},annotations:[]};return{detail:Q,dialog:z,caseId:I}}function im({commented:i}){const h=i?"comment-icon-svg commented":"comment-icon-svg";return l.jsx("svg",{className:h,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:l.jsx("path",{d:"M5 6.5h14v9H11.5l-4.5 3v-3H5z"})})}function od({resolved:i}){return l.jsxs("svg",{className:i?"resolve-icon-svg resolved":"resolve-icon-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),i?l.jsx("path",{d:"M5.1 8.2 7.2 10.3 11 6.5"}):null]})}function ld(){return l.jsxs("svg",{className:"autoruns-copy-icon-svg",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[l.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2.2"}),l.jsx("path",{d:"M15 7V5.8a1.8 1.8 0 0 0-1.8-1.8H5.8A1.8 1.8 0 0 0 4 5.8v7.4A1.8 1.8 0 0 0 5.8 15H7"})]})}function am(){return l.jsxs("svg",{className:"autoruns-question-grip-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[l.jsx("circle",{cx:"4",cy:"4",r:"1"}),l.jsx("circle",{cx:"8",cy:"4",r:"1"}),l.jsx("circle",{cx:"12",cy:"4",r:"1"}),l.jsx("circle",{cx:"4",cy:"8",r:"1"}),l.jsx("circle",{cx:"8",cy:"8",r:"1"}),l.jsx("circle",{cx:"12",cy:"8",r:"1"}),l.jsx("circle",{cx:"4",cy:"12",r:"1"}),l.jsx("circle",{cx:"8",cy:"12",r:"1"}),l.jsx("circle",{cx:"12",cy:"12",r:"1"})]})}function um({connection:i,modelOptions:h,modelsBusy:m,connectionStatus:R,connectionBusy:E,onConnectionChange:I,onReloadModels:Q,onSaveLocalConfig:le,onTestConnection:te,prompts:z,onPromptsChange:Y,promptPresets:X,selectedPresetId:ee,onSelectPreset:Me,onLoadPreset:ue,onSavePreset:ce,onResetDefaults:pe,onDiffPrevious:Ve,presetName:Xe,onPresetNameChange:We,diffSummary:Ae,assistantPromptVersion:$,decompositionPromptVersion:oe,showSettingsMode:je,showAutoRunsMode:Be,showAssistantMode:gt,showProgressMode:ct,showCommentsMode:Ut,onLog:dt}){const[B,Le]=v.useState({...ka,fromLocal:ed()}),[Ke,ne]=v.useState(""),[Z,M]=v.useState(null),[F,A]=v.useState(null),[y,k]=v.useState(null),[re,ie]=v.useState([]),[ae,he]=v.useState("all"),[ye,xe]=v.useState(!1),[we,ft]=v.useState(null),[qt,ir]=v.useState([]),[Cn,an]=v.useState(""),[Pe,Bt]=v.useState(""),[st,vt]=v.useState(""),[jt,un]=v.useState(Ra),[G,mt]=v.useState(Xc),[ar,Nn]=v.useState([]),[Gn,En]=v.useState(""),[ge,At]=v.useState([]),[Jt,Pn]=v.useState(!1),[ot,ur]=v.useState(null),[cr,Tn]=v.useState(""),[$r,cn]=v.useState(null),[Kn,Ct]=v.useState(null),[Qe,Rn]=v.useState(null),[de,dn]=v.useState(null),[dr,Fr]=v.useState(!1),[Ur,Mn]=v.useState(!1),[An,fr]=v.useState(!1),[qn,Ln]=v.useState(!1),[mr,In]=v.useState(!1),[C,J]=v.useState(!1),[b,Ce]=v.useState(!1),[qe,No]=v.useState(!1),[Eo,Po]=v.useState(""),[Dn,Je]=v.useState(""),[et,bs]=v.useState(""),[Qt,ds]=v.useState([]),[pr,hr]=v.useState([]),[Vs,Ws]=v.useState(""),[De,Gs]=v.useState(null),[Br,To]=v.useState(!1),[Qr,Ro]=v.useState(!1),[Mo,On]=v.useState(""),[Yt,Jn]=v.useState(""),[Ht,gr]=v.useState(String(ka.limit)),[Fl,vr]=v.useState(String(Xc.count)),[yr,Hr]=v.useState(160),[fe,Nt]=v.useState({open:!1,caseId:"",caseMessageIndex:-1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:Al,annotationAuthor:"manual_reviewer",saving:!1,error:""}),[Ne,fn]=v.useState({open:!1,messageIndex:-1,rating:3,comment:"",annotationAuthor:"manual_reviewer",saving:!1,error:""}),[Et,zn]=v.useState({open:!1,title:"",saving:!1,error:""}),[Pt,mn]=v.useState({open:!1,generationId:"",questionIndex:-1,questionText:"",saving:!1,error:""}),[pn,xr]=v.useState({open:!1,generationId:"",title:"",saving:!1,error:""}),_e=v.useRef(!1),br=v.useRef(null),fs=v.useRef(null),bt=G.mode==="saved_user_sessions",Vr=v.useMemo(()=>jt.find(a=>a.id===G.personalityId)??jt[0]??Ra[0],[G.personalityId,jt]),Tt=v.useMemo(()=>ar.filter(a=>a.mode===G.mode),[ar,G.mode]),$e=v.useMemo(()=>Tt.find(a=>a.generation_id===Gn)??Tt[0]??null,[Gn,Tt]),hn=v.useMemo(()=>ye?re.filter(a=>!a.resolved):re,[re,ye]),Te=hn.find(a=>a.annotation_id===Cn)??null,gn=y?.messages.find(a=>a.message_index===fe.messageIndex)??null,$n=v.useMemo(()=>{if(!y||fe.messageIndex<0)return null;for(let a=fe.messageIndex-1;a>=0;a-=1){const c=y.messages[a];if(c?.role==="user")return c}return null},[fe.messageIndex,y]),Vt=v.useMemo(()=>{const a=new Map;for(const c of pr)c.message_id&&a.set(c.message_id,c);return a},[pr]),_r=Ne.messageIndex>=0?Qt[Ne.messageIndex]??null:null,Sr=v.useMemo(()=>{if(Ne.messageIndex<0)return null;for(let a=Ne.messageIndex-1;a>=0;a-=1){const c=Qt[a];if(c?.role==="user")return c}return null},[Ne.messageIndex,Qt]),lt=v.useMemo(()=>{const a=hn.map(f=>({source:"autorun",key:`autorun:${f.annotation_id}`,updated_at:f.updated_at,rating:f.rating,autorun:f,assistant:null})),c=pr.map(f=>({source:"assistant_live",key:`assistant:${f.annotation_id}`,updated_at:f.updated_at,rating:f.rating,autorun:null,assistant:f}));return[...a,...c].sort((f,w)=>Date.parse(w.updated_at)-Date.parse(f.updated_at))},[pr,hn]),Ao=v.useMemo(()=>{if(lt.length===0)return null;const a=lt.reduce((c,f)=>c+f.rating,0)/lt.length;return Number(a.toFixed(2))},[lt]),ms=v.useMemo(()=>{const a=[...Z?.items??[]];return Qe&&a.unshift(pd(Qe)),Pe&&!a.some(c=>c.run_id===Pe)&&F?.run&&a.unshift(F.run),a},[Qe,Z?.items,F?.run,Pe]),W=v.useCallback(a=>{dt?.(`[autoruns] ${a}`)},[dt]),ps=v.useCallback(async a=>{const c=String(a??"").trim();if(!c){hr([]);return}try{const f=await Re.loadAssistantAnnotations({session_id:c,limit:400});hr(f.items??[])}catch(f){const w=f instanceof Error?f.message:String(f);W(`Assistant live annotations load error: ${w}`)}},[W]),Yn=v.useCallback(a=>{fn(c=>c.saving&&!a?.force?c:{open:!1,messageIndex:-1,rating:3,comment:"",annotationAuthor:"manual_reviewer",saving:!1,error:""})},[]),Xn=v.useCallback(a=>{zn(c=>c.saving&&!a?.force?c:{open:!1,title:"",saving:!1,error:""})},[]),Wr=v.useCallback(a=>{mn(c=>c.saving&&!a?.force?c:{open:!1,generationId:"",questionIndex:-1,questionText:"",saving:!1,error:""})},[]),hs=v.useCallback(a=>{xr(c=>c.saving&&!a?.force?c:{open:!1,generationId:"",title:"",saving:!1,error:""})},[]),Fn=v.useCallback(async(a,c,f)=>{a.stopPropagation(),a.preventDefault();const w=String(c??"").trim();if(w)try{if(navigator?.clipboard?.writeText)await navigator.clipboard.writeText(w);else{const L=document.createElement("textarea");L.value=w,L.setAttribute("readonly","true"),L.style.position="fixed",L.style.opacity="0",document.body.appendChild(L),L.select(),document.execCommand("copy"),document.body.removeChild(L)}W(`${f} copied: ${w}`)}catch(L){const Ee=L instanceof Error?L.message:String(L);Je(`Копирование ${f}: ${Ee}`),W(`copy ${f} error: ${Ee}`)}},[W]);function Gr(){let a=0;On(ja[0]);const c=window.setInterval(()=>{a=Math.min(a+1,ja.length-1),On(ja[a])},650);return()=>window.clearInterval(c)}const wr=v.useCallback(()=>{bs(""),ds([]),hr([]),Ws(""),Gs(null),On(""),Jn(""),Yn({force:!0}),W("Live-чат ассистента в истории автопрогонов сброшен.")},[Yn,W]),gs=v.useCallback(async()=>{const a=tm(Vs,De);if(!a)return;Ro(!0),Jn(""),Ws(""),ds(f=>[...f,{message_id:`autoruns-live-${Date.now()}`,session_id:et||"pending",role:"user",text:a,reply_type:null,created_at:new Date().toISOString(),trace_id:null,debug:null}]);const c=Gr();try{const f=await Re.sendAssistantMessage({connection:i,prompts:z,userMessage:a,sessionId:et||void 0,promptVersion:$,useMock:Br});bs(f.session_id),ds(f.conversation),await ps(f.session_id),On("Ответ готов"),W(`Live-ответ ассистента получен: trace=${f.debug.trace_id}`)}catch(f){const w=f instanceof Error?f.message:String(f);Jn(w),On("Ошибка ассистента"),W(`Live-чат ассистента: ошибка отправки сообщения: ${w}`)}finally{c(),Ro(!1)}},[Vs,De,et,Br,$,i,ps,W,z]),Ul=v.useCallback(()=>{if(!et.trim()||Qt.length===0){Jn("Сначала получите хотя бы один ответ в живой сессии ассистента.");return}Jn(""),zn({open:!0,title:sm(Qt),saving:!1,error:""})},[Qt,et]),Bl=v.useCallback(async()=>{const a=et.trim(),c=Et.title.trim();if(!a){zn(f=>({...f,error:"Активная сессия ассистента не найдена."}));return}if(!c){zn(f=>({...f,error:"Укажите название сессии."}));return}zn(f=>({...f,saving:!0,error:""}));try{const f=[z.systemPrompt,z.developerPrompt,z.domainPrompt,z.schemaNotes,z.fewShotExamples].join("||"),w=await Re.saveAutoRunAssistantSession({session_id:a,title:c,generated_by:G.generatedBy.trim()||void 0,context:{llm_provider:i.llmProvider,model:i.model,assistant_prompt_version:$,decomposition_prompt_version:oe,prompt_fingerprint:f}});Nn(L=>[w.generation,...L.filter(Ee=>Ee.generation_id!==w.generation.generation_id)]),mt(L=>({...L,mode:"saved_user_sessions"})),En(w.generation.generation_id),Xn({force:!0}),W(`Живая сессия сохранена в автопрогоны: ${w.generation.generation_id}`)}catch(f){const w=f instanceof Error?f.message:String(f);zn(L=>({...L,saving:!1,error:w})),W(`Assistant live save error: ${w}`)}},[Et.title,et,$,G.generatedBy,Xn,i.llmProvider,i.model,oe,W,z.developerPrompt,z.domainPrompt,z.fewShotExamples,z.schemaNotes,z.systemPrompt]),vs=v.useCallback(a=>{const c=a.trim();if(!c){gr(String(B.limit));return}if(!/^\d+$/.test(c)){gr(String(B.limit));return}const f=Number.parseInt(c,10);if(!Number.isFinite(f)){gr(String(B.limit));return}const w=Math.max(1,Math.min(500,f));w!==B.limit&&Le(L=>({...L,limit:w})),gr(String(w))},[B.limit]),Kr=v.useCallback(a=>{const c=a.trim();if(!c){vr(String(G.count));return}if(!/^\d+$/.test(c)){vr(String(G.count));return}const f=Number.parseInt(c,10);if(!Number.isFinite(f)){vr(String(G.count));return}const w=Math.max(1,Math.min(200,f));w!==G.count&&mt(L=>({...L,count:w})),vr(String(w))},[G.count]),ys=v.useCallback(a=>{Hr(Zc(a))},[]),Ks=v.useCallback(a=>{const c=a.currentTarget.offsetHeight;Number.isFinite(c)&&c>0&&ys(c)},[ys]),Lt=v.useCallback(async()=>{No(!0);try{const a=await Re.loadAutoRunAnnotations({limit:800,manual_case_decision:ae});ie(a.items),ft(a.manual_case_decision_schema??null),ir(a.available_manual_case_decisions??[]),an(c=>a.items.length===0?"":a.items.some(f=>f.annotation_id===c)?c:a.items[0].annotation_id)}catch(a){W(`Annotations load error: ${a instanceof Error?a.message:String(a)}`)}finally{No(!1)}},[ae,W]),vn=v.useCallback(async()=>{Ln(!0);try{const a=await Re.loadAutoRunAutogenHistory({limit:180});Nn(a.items)}catch(a){W(`Autogen history load error: ${a instanceof Error?a.message:String(a)}`)}finally{Ln(!1)}},[W]),qr=v.useCallback(async()=>{try{const c=(await Re.loadAutoRunAutogenPersonalityCatalog()).items.map(f=>({id:String(f.id??"").trim(),label:String(f.label??"").trim(),domain:typeof f.domain=="string"?f.domain.trim():"",defaultPrompt:String(f.default_prompt??"").trim()})).filter(f=>f.id.length>0&&f.label.length>0);if(c.length===0)return;un(c.map(f=>({id:f.id,label:f.label,domain:f.domain||"",defaultPrompt:f.defaultPrompt||"Генерируй реалистичные вопросы бухгалтера по выбранному профилю. Не выдумывай непокрытые возможности."})))}catch(a){W(`Autogen personality catalog load error: ${a instanceof Error?a.message:String(a)}`)}},[W]),Xt=v.useCallback(async()=>{fr(!0);try{const a=await Re.loadAutoRunPostAnalysis({run_id:Pe&&!Hs(Pe)?Pe:void 0,limit_per_queue:30,annotation_limit:1500,from:Ll(B.fromLocal),to:Ll(B.toLocal),target:B.target,mode:B.mode,use_mock:B.useMock,prompt_contains:B.promptContains.trim()||void 0});dn(a)}catch(a){W(`Post-analysis load error: ${a instanceof Error?a.message:String(a)}`),dn(null)}finally{fr(!1)}},[B.fromLocal,B.mode,B.promptContains,B.target,B.toLocal,B.useMock,W,Pe]),xs=v.useCallback(async()=>{Fr(!0),Je("");try{if(G.mode==="saved_user_sessions")throw new Error("Пользовательские сессии сохраняются из живого чата, а не генерируются автоматически.");const a=G.personalityPrompts[G.personalityId]??"",c=[z.systemPrompt,z.developerPrompt,z.domainPrompt,z.schemaNotes,z.fewShotExamples].join(` -`).slice(0,900),f=await Re.generateAutoRunQuestions({mode:G.mode,count:G.count,domain:Vr.domain||void 0,persist_to_eval_cases:G.persistToEvalCases,generated_by:G.generatedBy.trim()||void 0,llm:{llm_provider:i.llmProvider,api_key:i.apiKey,model:i.model,base_url:i.baseUrl,temperature:i.temperature,max_output_tokens:i.maxOutputTokens},context:{llm_provider:i.llmProvider,model:i.model,assistant_prompt_version:$,decomposition_prompt_version:oe,prompt_fingerprint:c,autogen_personality_id:Vr.id,autogen_personality_prompt:a.trim()||void 0}});W(`Generated ${f.generation.count} questions (${f.generation.mode}) id=${f.generation.generation_id}`+(f.generation.saved_case_set_file?` saved=${f.generation.saved_case_set_file}`:"")),En(f.generation.generation_id),At([...f.generation.questions??[]]),await vn()}catch(a){const c=a instanceof Error?a.message:String(a);Je(`Автогенерация: ${c}`),W(`Autogen generate error: ${c}`)}finally{Fr(!1)}},[$,G.count,G.generatedBy,G.mode,G.personalityId,G.personalityPrompts,G.persistToEvalCases,i.apiKey,i.baseUrl,i.llmProvider,i.maxOutputTokens,i.model,i.temperature,oe,vn,W,z.developerPrompt,z.domainPrompt,z.fewShotExamples,z.schemaNotes,z.systemPrompt,Vr.domain,Vr.id]),Un=v.useCallback(async(a,c)=>{if(Hs(a)){const f=sd(a);if(Qe&&Qe.job_id===f){const w=Co(Qe,c);Bt(a),vt(w.caseId),k(w.dialog);return}k(null);return}Ce(!0);try{const f=await Re.loadAutoRunCaseDialog(a,c);k(f)}catch(f){const w=f instanceof Error?f.message:String(f);Je(`Диалог кейса: ${w}`),k(null),W(`Dialog load error for ${a}/${c}: ${w}`)}finally{Ce(!1)}},[Qe,W]),yn=v.useCallback(async(a,c)=>{if(Hs(a)){const f=sd(a);if(Qe&&Qe.job_id===f){const w=Co(Qe,c??kt);Bt(a),vt(w.caseId),A(w.detail),k(w.dialog);return}Bt(a),vt(""),A(null),k(null);return}J(!0);try{const f=await Re.loadAutoRunDetail(a);A(f);const w=(c&&(c===kt||f.cases.some(L=>L.case_id===c))?c:"")||(f.cases.length>0?kt:"")||"";Bt(a),vt(w),w?await Un(a,w):k(null)}catch(f){const w=f instanceof Error?f.message:String(f);Je(`Детализация прогона: ${w}`),A(null),k(null),W(`Run detail load error for ${a}: ${w}`)}finally{J(!1)}},[Qe,Un,W]),tt=v.useCallback(async a=>{In(!0),Je("");try{const c=await Re.loadAutoRunsHistory({from:Ll(B.fromLocal),to:Ll(B.toLocal),target:B.target,mode:B.mode,use_mock:B.useMock,prompt_contains:B.promptContains.trim()||void 0,limit:B.limit});if(M(c),c.items.length===0){Bt(""),vt(""),A(null),k(null);return}const f=a?.keepSelection??!0,w=a?.preferredRunId??"",L=a?.preferredCaseId??"",Ee=f&&w&&c.items.some(Fe=>Fe.run_id===w)?w:c.items[0].run_id;await yn(Ee,f?L:void 0),Xt()}catch(c){const f=c instanceof Error?c.message:String(c);Je(`История прогонов: ${f}`),W(`History load error: ${f}`)}finally{In(!1)}},[B.fromLocal,B.limit,B.mode,B.promptContains,B.target,B.toLocal,B.useMock,Xt,yn,W]),yt=v.useCallback(()=>{br.current!==null&&(window.clearTimeout(br.current),br.current=null)},[]),Jr=v.useCallback(async a=>{try{const c=await Re.loadEvalRunAsyncStatus(a);Rn(c.job);const f=Dl(a);if(Pe===f){const w=Co(c.job,st||kt);A(w.detail),k(w.dialog),vt(w.caseId)}if(c.job.status==="completed"){yt(),Mn(!1);const w=c.job.report_summary?.run_id??c.job.run_id;await tt({keepSelection:!0,preferredRunId:w||Pe,preferredCaseId:kt}),await vn(),Rn(null);return}if(c.job.status==="failed"){yt(),Mn(!1),Je(`Запуск прогонов: ${c.job.error??"неизвестная ошибка"}`),W(`Autogen async run failed: ${c.job.error??"unknown error"}`);return}yt(),br.current=window.setTimeout(()=>{Jr(a)},500)}catch(c){yt(),Mn(!1);const f=c instanceof Error?c.message:String(c);Je(`Запуск прогонов: ${f}`),W(`Autogen async status error: ${f}`)}},[vn,tt,W,st,Pe,yt]),Yr=v.useCallback(async()=>{yt(),Mn(!0),Je("");try{const a=$e;if(!a)throw new Error("История автогенерации пуста. Сначала сгенерируйте пачку вопросов.");const c=ge.map(ws=>ws.trim()).filter(ws=>ws.length>0);if(c.length===0)throw new Error("Нет вопросов для запуска: список пустой после ручного редактирования.");const f=B.useMock==="true",w=Ca(Ke),L=a.mode==="saved_user_sessions",Fe=(await Re.startEvalRunAsync({connection:i,prompts:z,promptVersion:$,mode:"single-pass-strict",caseSetFile:L?void 0:a.saved_case_set_file??void 0,useMock:f,evalTarget:"assistant_stage1",questions:L?void 0:c,scenarioQuestions:L?c:void 0,scenarioTitle:L?a.title??void 0:void 0,analysisDate:L?void 0:w||void 0})).job;Rn(Fe);const Zt=Dl(Fe.job_id),Zs=Co(Fe,kt);Bt(Zt),vt(Zs.caseId),A(Zs.detail),k(Zs.dialog),W(`Запущен async-прогон job=${Fe.job_id}, run_id=${Fe.run_id}, вопросов=${c.length}`+(a.saved_case_set_file?`, base_case_set=${a.saved_case_set_file}`:"")+(L?", replay_mode=saved_user_session_scenario":w?`, analysis_date=${w}`:", analysis_date=current_state")),Jr(Fe.job_id)}catch(a){const c=a instanceof Error?a.message:String(a);Je(`Запуск прогонов: ${c}`),W(`Autogen run error: ${c}`),Mn(!1)}},[Ke,$,i,ge,B.useMock,W,Jr,z,$e,yt]),Ql=v.useCallback(a=>{if(a.role!=="assistant")return;const c=a.case_id??st,f=a.case_message_index??a.message_index;Nt({open:!0,caseId:c,caseMessageIndex:f,messageIndex:a.message_index,rating:a.annotation?.rating??3,comment:a.annotation?.comment??"",manualCaseDecision:a.annotation?.manual_case_decision??Al,annotationAuthor:a.annotation?.annotation_author??G.generatedBy,saving:!1,error:""})},[G.generatedBy,st]),kr=v.useCallback(a=>{Nt(c=>c.saving&&!a?.force?c:{open:!1,caseId:"",caseMessageIndex:-1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:Al,annotationAuthor:G.generatedBy,saving:!1,error:""})},[G.generatedBy]),qs=v.useCallback(async()=>{const a=Pe,c=fe.caseId,f=fe.caseMessageIndex;if(!(!a||!c||f<0)){if(Hs(a)){Nt(w=>({...w,error:"Комментарий можно сохранить после завершения прогона."}));return}if(!fe.comment.trim()){Nt(w=>({...w,error:"Добавьте комментарий."}));return}Nt(w=>({...w,saving:!0,error:""}));try{await Re.saveAutoRunAnnotation({run_id:a,case_id:c,message_index:f,rating:fe.rating,comment:fe.comment.trim(),manual_case_decision:fe.manualCaseDecision,annotation_author:fe.annotationAuthor.trim()||void 0}),kr({force:!0}),Promise.all([yn(a,st),Lt(),Xt()]).catch(w=>{const L=w instanceof Error?w.message:String(w);Je(`Обновление после комментария: ${L}`),W(`Comment refresh error: ${L}`)})}catch(w){Nt(L=>({...L,saving:!1,error:w instanceof Error?w.message:String(w)}))}}},[kr,fe.annotationAuthor,fe.caseId,fe.caseMessageIndex,fe.comment,fe.manualCaseDecision,fe.rating,Lt,Xt,yn,W,st,Pe]),Xr=v.useCallback(a=>a.role==="assistant",[]),_s=v.useCallback(a=>a.role==="assistant"&&Vt.has(a.message_id),[Vt]),Lo=v.useCallback((a,c)=>{if(a.role!=="assistant")return;const f=et.trim(),w=String(a.session_id??"").trim();if(!(f||w)){Jn("Сначала получите ответ ассистента в активной сессии.");return}!f&&w&&bs(w);const Ee=Vt.get(a.message_id)??null;Jn(""),fn({open:!0,messageIndex:c,rating:Ee?.rating??3,comment:Ee?.comment??"",annotationAuthor:Ee?.annotation_author??"manual_reviewer",saving:!1,error:""})},[Vt,et]),Hl=v.useCallback(async()=>{if(Ne.messageIndex<0)return;if(!Ne.comment.trim()){fn(f=>({...f,error:"Добавьте комментарий."}));return}const a=Qt[Ne.messageIndex]??null,c=et.trim()||(a?.role==="assistant"?String(a.session_id??"").trim():"");if(!c){fn(f=>({...f,error:"Сессия ассистента не найдена."}));return}fn(f=>({...f,saving:!0,error:""}));try{const f=await Re.saveAssistantAnnotation({session_id:c,message_index:Ne.messageIndex,rating:Ne.rating,comment:Ne.comment.trim(),annotation_author:Ne.annotationAuthor.trim()||void 0});hr(w=>{const L=[...w],Ee=L.findIndex(Fe=>Fe.annotation_id===f.annotation.annotation_id);return Ee>=0?L[Ee]=f.annotation:L.unshift(f.annotation),L.sort((Fe,Zt)=>Date.parse(Zt.updated_at)-Date.parse(Fe.updated_at))}),Yn({force:!0})}catch(f){const w=f instanceof Error?f.message:String(f);fn(L=>({...L,saving:!1,error:w}))}},[Ne.annotationAuthor,Ne.comment,Ne.messageIndex,Ne.rating,Qt,et,Yn]);v.useCallback(a=>{if(!$e||$e.mode!=="saved_user_sessions")return;const c=ge[a]??"";mn({open:!0,generationId:$e.generation_id,questionIndex:a,questionText:c,saving:!1,error:""})},[ge,$e]);const bl=v.useCallback(async()=>{const a=Pt.generationId,c=Pt.questionIndex;if(!a||c<0)return;const f=ge.filter((w,L)=>L!==c);if(f.length===0){mn(w=>({...w,error:"Нельзя удалить последний вопрос из сохраненной сессии."}));return}mn(w=>({...w,saving:!0,error:""}));try{const w=await Re.updateAutoRunAutogenQuestions({generation_id:a,questions:f});Nn(L=>L.map(Ee=>Ee.generation_id===a?w.generation:Ee)),At(w.generation.questions),Wr({force:!0}),W(`Обновлена сохраненная сессия: ${a}`)}catch(w){const L=w instanceof Error?w.message:String(w);mn(Ee=>({...Ee,saving:!1,error:L})),W(`Saved session question delete error: ${L}`)}},[Wr,ge,W,Pt.generationId,Pt.questionIndex]),Bn=v.useCallback(async(a,c)=>{const f=$e?.generation_id??"",w=c?.revertQuestions??ge;if(At(a),!f)return!0;Pn(!0);try{const L=await Re.updateAutoRunAutogenQuestions({generation_id:f,questions:a});return Nn(Ee=>Ee.map(Fe=>Fe.generation_id===f?L.generation:Fe)),At([...L.generation.questions??[]]),c?.successLog&&W(c.successLog),!0}catch(L){const Ee=L instanceof Error?L.message:String(L);return At(w),Je(`Вопросы к запуску: ${Ee}`),W(`Autogen questions update error: ${Ee}`),!1}finally{Pn(!1)}},[ge,W,$e]),Js=v.useCallback(a=>{ur(a),Tn(ge[a]??"")},[ge]),Qn=v.useCallback(()=>{ur(null),Tn("")},[]),Ss=v.useCallback(async a=>{if(a===null)return;const c=ge[a]??"",f=cr.trim();if(!f||f===c){Qn();return}const w=ge.map((Ee,Fe)=>Fe===a?f:Ee);await Bn(w,{successLog:`Список вопросов обновлен: ${$e?.generation_id??"local"}`,revertQuestions:ge})&&Qn()},[ge,cr,$e,Qn,Bn]),Vl=v.useCallback(()=>{Ss(ot)},[Ss,ot]),Wl=v.useCallback(a=>{if(a.key==="Enter"){a.preventDefault(),Ss(ot);return}a.key==="Escape"&&(a.preventDefault(),Qn())},[Ss,ot,Qn]),Gl=v.useCallback(async()=>{const a=[...ge,"Новый вопрос"],c=a.length-1;await Bn(a,{successLog:`В список добавлен вопрос: ${$e?.generation_id??"local"}`,revertQuestions:ge})&&(ur(c),Tn(a[c]))},[ge,$e,Bn]),Io=v.useCallback(async a=>{if(ge.length<=1){Je("В списке должен остаться хотя бы один вопрос.");return}const c=ge.filter((w,L)=>L!==a);await Bn(c,{successLog:`Из списка удален вопрос: ${$e?.generation_id??"local"}`,revertQuestions:ge})&&(ur(w=>w===null?w:w===a?null:w>a?w-1:w),Tn(""))},[ge,$e,Bn]),Kl=v.useCallback((a,c)=>{if(Jt){a.preventDefault();return}cn(c),Ct(c),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",String(c))},[Jt]),ql=v.useCallback((a,c)=>{a.preventDefault(),Kn!==c&&Ct(c),a.dataTransfer.dropEffect="move"},[Kn]),Jl=v.useCallback(async(a,c)=>{a.preventDefault();const f=$r;if(Ct(null),cn(null),f===null||f===c)return;const w=[...ge],[L]=w.splice(f,1);w.splice(c,0,L),await Bn(w,{successLog:`Порядок вопросов обновлен: ${$e?.generation_id??"local"}`,revertQuestions:ge})},[$r,ge,$e,Bn]),Yl=v.useCallback(()=>{cn(null),Ct(null)},[]),Ys=v.useCallback(a=>{xr({open:!0,generationId:a.generation_id,title:a.title??`${Na(a.mode)} ${ln(a.created_at)}`,saving:!1,error:""})},[]),Xl=v.useCallback(async()=>{const a=pn.generationId.trim();if(a){xr(c=>({...c,saving:!0,error:""}));try{const c=await Re.deleteAutoRunAutogenHistoryRecord(a);Nn(f=>f.filter(w=>w.generation_id!==c.generation_id)),hs({force:!0}),W(`Удален набор автопрогона: ${c.generation_id}`+(c.deleted_files.length>0?`, files=${c.deleted_files.length}`:""))}catch(c){const f=c instanceof Error?c.message:String(c);xr(w=>({...w,saving:!1,error:f})),W(`Autogen record delete error: ${f}`)}}},[pn.generationId,hs,W]),Do=v.useCallback(a=>{ie(c=>c.map(f=>f.annotation_id===a.annotation_id?{...f,...a}:f)),k(c=>c&&{...c,annotations:c.annotations.map(f=>f.annotation_id===a.annotation_id?a:f),messages:c.messages.map(f=>!f.annotation||f.annotation.annotation_id!==a.annotation_id?f:{...f,commented:!0,annotation:a})})},[]),Oo=v.useCallback(async(a,c)=>{if(a.annotation_id){if(Hs(a.run_id)){Je("Статус выполнения можно менять только для завершённых прогонов.");return}Po(a.annotation_id);try{const f=await Re.updateAutoRunAnnotation({annotation_id:a.annotation_id,resolved:c,resolved_by:G.generatedBy||void 0});Do(f.annotation),Xt()}catch(f){const w=f instanceof Error?f.message:String(f);Je(`Смена статуса кейса: ${w}`),W(`Annotation resolve toggle error: ${w}`)}finally{Po("")}}},[Do,G.generatedBy,Xt,W]),Xs=v.useCallback(async a=>{an(a.annotation_id),await yn(a.run_id,a.case_id),Z?.items.some(c=>c.run_id===a.run_id)||Je("Комментарий относится к прогону вне текущего фильтра. Детали загружены напрямую.")},[Z?.items,yn]);v.useEffect(()=>{_e.current||(_e.current=!0,tt({keepSelection:!1}),vn(),qr(),Xt())},[vn,qr,tt,Xt]),v.useEffect(()=>{_e.current&&Lt()},[ae,Lt]),v.useEffect(()=>{an(a=>hn.length===0?"":hn.some(c=>c.annotation_id===a)?a:hn[0].annotation_id)},[hn]),v.useEffect(()=>{En(a=>Tt.length===0?"":a&&Tt.some(c=>c.generation_id===a)?a:Tt[0].generation_id)},[Tt]),v.useEffect(()=>{if(!$e){At([]),Qn(),cn(null),Ct(null);return}At([...$e.questions]),Qn(),cn(null),Ct(null)},[$e,Qn]),v.useEffect(()=>{if(ot===null)return;const a=window.setTimeout(()=>{fs.current?.focus(),fs.current?.select()},0);return()=>window.clearTimeout(a)},[ot]),v.useEffect(()=>{gr(String(B.limit))},[B.limit]),v.useEffect(()=>{vr(String(G.count))},[G.count]),v.useEffect(()=>{if(!et.trim()){hr([]);return}ps(et)},[et,ps]),v.useEffect(()=>{if(!Qe)return;const a=Dl(Qe.job_id);if(Pe!==a)return;const c=Co(Qe,st||kt);A(c.detail),k(c.dialog),vt(c.caseId)},[Qe,st,Pe]),v.useEffect(()=>()=>{yt()},[yt]),v.useEffect(()=>{jt.length!==0&&mt(a=>{let c=!1;const f={...a.personalityPrompts};for(const L of jt)(typeof f[L.id]!="string"||f[L.id].trim().length===0)&&(f[L.id]=L.defaultPrompt,c=!0);let w=a.personalityId;return jt.some(L=>L.id===a.personalityId)||(w=jt[0].id,c=!0),c?{...a,personalityId:w,personalityPrompts:f}:a})},[jt]),v.useEffect(()=>{const a=localStorage.getItem(Jc);if(a)try{const c=JSON.parse(a);if(c.filters){const f=c.filters;Le(w=>({...w,...f,limit:typeof f.limit=="number"?Math.max(1,Math.min(500,f.limit)):w.limit}))}typeof c.analysisDate=="string"&&ne(Ca(c.analysisDate)),typeof c.autogenPersonalityPromptHeight=="number"&&Hr(Zc(c.autogenPersonalityPromptHeight)),c.autoGenSettings&&mt(f=>{const w={...f.personalityPrompts},L=c.autoGenSettings?.personalityPrompts??{};for(const[Fe,Zt]of Object.entries(L))typeof Zt=="string"&&Fe.trim().length>0&&(w[Fe.trim()]=Zt);const Ee=typeof c.autoGenSettings?.personalityId=="string"&&c.autoGenSettings.personalityId.trim().length>0?c.autoGenSettings.personalityId.trim():f.personalityId;return{...f,mode:c.autoGenSettings?.mode==="codex_creative"||c.autoGenSettings?.mode==="qwen_seed"||c.autoGenSettings?.mode==="saved_user_sessions"?c.autoGenSettings.mode:f.mode,count:typeof c.autoGenSettings?.count=="number"?Math.max(1,Math.min(200,c.autoGenSettings.count)):f.count,personalityId:Ee,personalityPrompts:w,persistToEvalCases:typeof c.autoGenSettings?.persistToEvalCases=="boolean"?c.autoGenSettings.persistToEvalCases:f.persistToEvalCases,generatedBy:typeof c.autoGenSettings?.generatedBy=="string"?c.autoGenSettings.generatedBy:f.generatedBy}}),(c.annotationDecisionFilter==="all"||typeof c.annotationDecisionFilter=="string"&&c.annotationDecisionFilter.length>0)&&he(c.annotationDecisionFilter),typeof c.hideResolvedAnnotations=="boolean"&&xe(c.hideResolvedAnnotations)}catch{}},[]);const zo=v.useCallback(()=>{const a={filters:B,analysisDate:Ke,autogenPersonalityPromptHeight:yr,autoGenSettings:{mode:G.mode,count:G.count,personalityId:G.personalityId,personalityPrompts:G.personalityPrompts,persistToEvalCases:G.persistToEvalCases,generatedBy:G.generatedBy},annotationDecisionFilter:ae,hideResolvedAnnotations:ye};localStorage.setItem(Jc,JSON.stringify(a))},[Ke,ae,G,yr,B,ye]);return v.useEffect(()=>{const a=()=>{zo(),W("Сохранены настройки панели автопрогонов.")};return window.addEventListener(Yc,a),()=>{window.removeEventListener(Yc,a)}},[W,zo]),l.jsxs($l,{className:"autoruns-frame",title:"",hideHeader:!0,children:[l.jsxs("div",{className:"autoruns-columns",children:[je?l.jsxs("section",{className:"autoruns-col autoruns-settings-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Настройки"})}),l.jsxs("div",{className:"autoruns-settings-stack",children:[l.jsx(Zf,{embedded:!0,value:i,modelOptions:h,modelsBusy:m,onChange:I,onReloadModels:Q,onSaveLocalConfig:le,onTestConnection:te,lastStatus:R,busy:E}),l.jsx(em,{embedded:!0,value:z,onChange:Y,presets:X,selectedPresetId:ee,onSelectPreset:Me,onLoadPreset:ue,onSavePreset:ce,onResetDefaults:pe,onDiffPrevious:Ve,presetName:Xe,onPresetNameChange:We,diffSummary:Ae})]})]}):null,Be?l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Автопрогоны"})}),l.jsx("h4",{children:"Настройки выборки"}),l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Дата с",l.jsx("input",{type:"datetime-local",value:B.fromLocal,onChange:a=>Le(c=>({...c,fromLocal:a.target.value}))})]}),l.jsxs("label",{children:["Дата по",l.jsx("input",{type:"datetime-local",value:B.toLocal,onChange:a=>Le(c=>({...c,toLocal:a.target.value}))})]}),l.jsxs("label",{children:["Целевой контур",l.jsxs("select",{value:B.target,onChange:a=>Le(c=>({...c,target:a.target.value})),children:[l.jsx("option",{value:"all",children:"все"}),(Z?.available.targets??[]).map(a=>l.jsx("option",{value:a,children:a},a))]})]}),l.jsxs("label",{children:["Режим",l.jsxs("select",{value:B.mode,onChange:a=>Le(c=>({...c,mode:a.target.value})),children:[l.jsx("option",{value:"all",children:"все"}),(Z?.available.modes??[]).map(a=>l.jsx("option",{value:a,children:a},a))]})]}),l.jsxs("label",{children:["Использовать mock",l.jsxs("select",{value:B.useMock,onChange:a=>Le(c=>({...c,useMock:a.target.value})),children:[l.jsx("option",{value:"any",children:"любой"}),l.jsx("option",{value:"true",children:"да"}),l.jsx("option",{value:"false",children:"нет"})]})]}),l.jsxs("label",{children:["Лимит",l.jsx("input",{type:"number",min:1,max:500,value:Ht,onChange:a=>{const c=a.target.value;(c===""||/^\d+$/.test(c))&&gr(c)},onBlur:a=>vs(a.target.value),onKeyDown:a=>{a.key==="Enter"&&vs(a.target.value)}})]}),l.jsxs("label",{className:"full-width",children:["Версия промпта содержит",l.jsx("input",{value:B.promptContains,onChange:a=>Le(c=>({...c,promptContains:a.target.value})),placeholder:"normalizer_v2_0_2 / address_query_runtime_v1",list:"autoruns-prompt-versions"})]})]}),l.jsx("datalist",{id:"autoruns-prompt-versions",children:(Z?.available.prompt_versions??[]).map(a=>l.jsx("option",{value:a},a))}),l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",disabled:mr,onClick:()=>{tt({keepSelection:!1})},children:mr?"Обновляю...":"Применить"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>{Le({...ka,fromLocal:ed()}),Je("")},children:"Сбросить фильтры"})]}),l.jsx("h4",{children:"Контур генерации"}),l.jsxs("div",{className:"autoruns-meta-list",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Провайдер:"}),l.jsx("strong",{children:i.llmProvider})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Модель:"}),l.jsx("strong",{children:i.model||"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Промпт ассистента:"}),l.jsx("strong",{children:$})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Промпт декомпозиции:"}),l.jsx("strong",{children:oe})]})]}),l.jsx("h4",{children:"Автопрогоны"}),l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Режимы",l.jsxs("select",{value:G.mode,onChange:a=>mt(c=>({...c,mode:a.target.value})),children:[l.jsx("option",{value:"codex_creative",children:"codex_creative"}),l.jsx("option",{value:"qwen_seed",children:"qwen_seed"}),l.jsx("option",{value:"saved_user_sessions",children:"Пользовательские сессии"})]})]}),bt?null:l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Кол-во",l.jsx("input",{type:"number",min:1,max:200,value:Fl,onChange:a=>{const c=a.target.value;(c===""||/^\d+$/.test(c))&&vr(c)},onBlur:a=>Kr(a.target.value),onKeyDown:a=>{a.key==="Enter"&&Kr(a.target.value)}})]}),l.jsxs("label",{children:["Личность автогенерации",l.jsx("select",{value:G.personalityId,onChange:a=>mt(c=>({...c,personalityId:a.target.value})),children:jt.map(a=>l.jsx("option",{value:a.id,children:a.label},a.id))})]}),l.jsxs("label",{children:["Кто генерирует",l.jsx("input",{value:G.generatedBy,onChange:a=>mt(c=>({...c,generatedBy:a.target.value})),placeholder:"manual_reviewer"})]}),l.jsxs("label",{className:"full-width",children:["Промпт личности",l.jsx("textarea",{className:"autoruns-personality-prompt",value:G.personalityPrompts[G.personalityId]??"",onChange:a=>mt(c=>({...c,personalityPrompts:{...c.personalityPrompts,[c.personalityId]:a.target.value}})),placeholder:"Текст промпта для выбранной личности автогенерации",style:{height:`${yr}px`},onMouseUp:Ks,onTouchEnd:Ks})]}),l.jsxs("label",{className:"checkbox-row",children:[l.jsx("input",{type:"checkbox",checked:G.persistToEvalCases,onChange:a=>mt(c=>({...c,persistToEvalCases:a.target.checked}))}),"Сохранять кейс-сет в `eval_cases`"]})]})]}),bt?null:l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Дата анализа (срез)",l.jsx("input",{type:"date",value:Ke,onChange:a=>ne(Ca(a.target.value))})]}),l.jsx("div",{className:"button-row",children:l.jsx("button",{type:"button",className:"tab",disabled:!Ke,onClick:()=>ne(""),children:"Сбросить дату среза"})})]}),l.jsxs("div",{className:"button-row",children:[bt?null:l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",disabled:dr,onClick:()=>{xs()},children:dr?"Генерирую...":"Сгенерировать пачку"}),l.jsx("button",{type:"button",className:"tab",disabled:qn,onClick:()=>{vn()},children:qn?"Обновляю...":"Обновить историю"})]}),l.jsx("button",{type:"button",className:"autoruns-run-launch-btn",disabled:Ur||ge.length===0||!$e,onClick:()=>{Yr()},children:Ur?"Запускаю...":"Запустить прогон"})]}),l.jsx("div",{className:"autoruns-form-grid",children:l.jsxs("label",{className:"full-width",children:[bt?"Сохраненная сессия":"Кейс-сет для запуска",l.jsxs("select",{value:Gn,onChange:a=>En(a.target.value),disabled:Tt.length===0,children:[Tt.length===0?l.jsx("option",{value:"",children:bt?"нет сохраненных сессий":"нет генераций"}):null,Tt.map(a=>l.jsxs("option",{value:a.generation_id,children:[ln(a.created_at)," | ",td(a)??Na(a.mode)," | ",a.count]},a.generation_id))]})]})}),l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"autoruns-generated-questions",children:[l.jsx("div",{className:"autoruns-generated-questions-head",children:l.jsxs("strong",{children:["Вопросы к запуску: ",ge.length]})}),ge.length===0?l.jsx("p",{className:"muted",children:bt?"Список вопросов пуст. Сначала сохраните живую пользовательскую сессию.":"Список вопросов пуст. Сгенерируйте пачку или добавьте вопрос вручную."}):l.jsx("div",{className:"autoruns-generated-questions-list",children:ge.map((a,c)=>l.jsxs("div",{className:["autoruns-generated-question-item",Kn===c?"drag-over":"",$r===c?"dragging":"",ot===c?"editing":""].filter(Boolean).join(" "),onDragOver:f=>ql(f,c),onDrop:f=>{Jl(f,c)},children:[l.jsx("button",{type:"button",className:"autoruns-question-grip-btn",draggable:!Jt&&ot!==c,disabled:Jt||ot===c,onDragStart:f=>Kl(f,c),onDragEnd:Yl,title:"Перетащить вопрос","aria-label":`Перетащить вопрос ${c+1}`,children:l.jsx(am,{})}),ot===c?l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:fs,className:"autoruns-generated-question-input",value:cr,onChange:f=>Tn(f.target.value),onBlur:Vl,onKeyDown:Wl,placeholder:"Текст вопроса",disabled:Jt}),l.jsx("button",{type:"button",className:"autoruns-remove-question-btn",onMouseDown:f=>f.preventDefault(),onClick:()=>{Io(c)},title:"Удалить вопрос","aria-label":`Удалить вопрос ${c+1}`,disabled:Jt,children:"×"})]}):l.jsxs("button",{type:"button",className:"autoruns-generated-question-text",onDoubleClick:()=>Js(c),title:"Двойной клик для редактирования",children:[c+1,". ",a]})]},`${c}-${a.slice(0,24)}`))}),l.jsx("button",{type:"button",className:"autoruns-add-question-btn",onClick:()=>{Gl()},disabled:!$e||Jt,children:"+"})]}),bt?l.jsx("h4",{children:"Сохраненные пользовательские сессии"}):l.jsx("p",{className:"muted",children:"Запуск выполняет `assistant_stage1` eval по выбранному кейс-сету."})]}),l.jsxs("div",{className:"autoruns-autogen-list",children:[qn?l.jsx("p",{className:"muted",children:bt?"Загружаю сохраненные пользовательские сессии...":"Загружаю историю автогенераций..."}):null,!qn&&Tt.length===0?l.jsx("p",{className:"muted",children:bt?"Сохраненные пользовательские сессии пока пусты.":"История автогенераций пока пустая."}):null,Tt.slice(0,30).map(a=>l.jsxs("article",{className:Gn===a.generation_id?"autoruns-autogen-item selected":"autoruns-autogen-item",onClick:()=>En(a.generation_id),children:[l.jsxs("header",{children:[l.jsx("strong",{children:td(a)}),l.jsxs("div",{className:"autoruns-autogen-card-actions",children:[l.jsx("span",{children:ln(a.created_at)}),l.jsx("button",{type:"button",className:"autoruns-autogen-delete-btn",onClick:c=>{c.preventDefault(),c.stopPropagation(),Ys(a)},title:"Удалить сохраненный набор","aria-label":`Удалить набор ${a.generation_id}`,children:"×"})]})]}),l.jsxs("div",{className:"autoruns-run-meta autoruns-run-id-row",children:[l.jsx("span",{children:a.generation_id}),l.jsx("span",{role:"button",tabIndex:0,className:"autoruns-copy-run-id-btn",onClick:c=>{Fn(c,a.generation_id,"set id")},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),Fn(c,a.generation_id,"set id"))},title:"Скопировать id набора","aria-label":`Скопировать id набора ${a.generation_id}`,children:l.jsx(ld,{})})]}),l.jsxs("div",{className:"autoruns-run-meta",children:["режим=",Na(a.mode)]}),l.jsxs("div",{className:"autoruns-run-meta",children:["тип=",md(a)?"АГЕНТНЫЙ ПРОГОН":"АВТОПРОГОН"]})]},a.generation_id))]}),l.jsxs("details",{className:"autoruns-prompt-details",children:[l.jsx("summary",{children:"Копия активного промпта (только чтение)"}),l.jsxs("label",{children:["Системный",l.jsx("textarea",{readOnly:!0,value:z.systemPrompt})]}),l.jsxs("label",{children:["Разработчика",l.jsx("textarea",{readOnly:!0,value:z.developerPrompt})]}),l.jsxs("label",{children:["Доменный",l.jsx("textarea",{readOnly:!0,value:z.domainPrompt})]}),l.jsxs("label",{children:["Заметки по схеме",l.jsx("textarea",{readOnly:!0,value:z.schemaNotes})]}),l.jsxs("label",{children:["Примеры few-shot",l.jsx("textarea",{readOnly:!0,value:z.fewShotExamples})]})]}),Dn?l.jsx("p",{className:"error-text",children:Dn}):null]}):null,l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Выдача прогонов"})}),l.jsxs("div",{className:"autoruns-stats-grid",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Всего"}),l.jsx("strong",{children:(Z?.stats.runs_total??0)+(Qe?1:0)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Средний score"}),l.jsx("strong",{children:Il(Z?.stats.avg_score_index??null)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Тренд"}),l.jsx("strong",{children:Z?nd(Z.stats.trend):"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Блокеры"}),l.jsx("strong",{children:Z?.stats.blocking_runs??0})]})]}),l.jsxs("div",{className:"autoruns-run-list",children:[ms.map(a=>l.jsxs("button",{type:"button",className:Pe===a.run_id?"autoruns-run-item selected":"autoruns-run-item",onClick:()=>{yn(a.run_id)},children:[l.jsxs("div",{className:"autoruns-run-head",children:[l.jsx("strong",{children:ln(a.run_timestamp)}),l.jsx("span",{children:lm(a.eval_target)})]}),l.jsxs("div",{className:"autoruns-run-meta autoruns-run-id-row",children:[l.jsx("span",{children:a.run_id}),l.jsx("span",{role:"button",tabIndex:0,className:"autoruns-copy-run-id-btn",onClick:c=>{Fn(c,a.run_id,"run id")},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),Fn(c,a.run_id,"run id"))},title:"Скопировать run id","aria-label":`Скопировать run id ${a.run_id}`,children:l.jsx(ld,{})})]}),l.jsxs("div",{className:"autoruns-run-meta",children:["режим=",a.mode??"нет данных"," | mock=",String(a.use_mock)]}),l.jsxs("div",{className:"autoruns-run-meta",children:["analysis_date=",a.analysis_date??"current_state"]}),a.llm_provider||a.model?l.jsxs("div",{className:"autoruns-run-meta",children:["llm=",a.llm_provider??"нет данных"," | модель=",a.model??"нет данных"]}):null,l.jsxs("div",{className:"autoruns-run-meta",children:["промпт=",a.prompt_version??"нет данных"]}),l.jsxs("div",{className:"autoruns-run-foot",children:[l.jsxs("span",{children:["оценка: ",Il(a.score_index)]}),l.jsxs("span",{children:["закрыто/открыто: ",a.closed_cases,"/",a.open_cases]})]}),l.jsxs("div",{className:"autoruns-run-foot",children:[l.jsxs("span",{children:["блокеры: ",a.blocking_failures]}),l.jsxs("span",{children:["качество: ",a.quality_failures]})]})]},a.run_id)),ms.length===0?l.jsx("p",{className:"muted",children:"За выбранный диапазон прогонов нет."}):null]})]}),l.jsxs("section",{className:"autoruns-col",children:[l.jsxs("div",{className:"autoruns-col-header",children:[l.jsx("h3",{children:"Диалог прогона"}),l.jsxs("div",{className:"autoruns-dialog-toolbar",children:[l.jsxs("label",{children:["Прогон",l.jsx("select",{value:Pe,onChange:a=>{const c=a.target.value;yn(c)},children:ms.map(a=>l.jsxs("option",{value:a.run_id,children:[ln(a.run_timestamp)," | ",a.run_id]},a.run_id))})]}),l.jsxs("label",{children:["Кейс",l.jsxs("select",{value:st,onChange:a=>{const c=a.target.value;vt(c),Pe&&c&&Un(Pe,c)},children:[(F?.cases.length??0)>0?l.jsx("option",{value:kt,children:"ВСЕ кейсы подряд"}):null,(F?.cases??[]).map(a=>l.jsxs("option",{value:a.case_id,children:[a.case_id," | ",a.status]},a.case_id))]})]})]})]}),l.jsxs("div",{className:"autoruns-case-list",children:[(F?.cases.length??0)>0?l.jsxs("button",{type:"button",className:st===kt?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{vt(kt),Pe&&Un(Pe,kt)},children:[l.jsx("span",{children:"ВСЕ кейсы подряд"}),l.jsx("span",{children:F?.cases.length})]},kt):null,(F?.cases??[]).map(a=>l.jsxs("button",{type:"button",className:st===a.case_id?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{vt(a.case_id),Pe&&Un(Pe,a.case_id)},children:[l.jsx("span",{children:a.case_id}),l.jsxs("span",{children:[a.status,a.commented_count>0?` | комм=${a.commented_count}`:""]})]},a.case_id))]}),l.jsxs("div",{className:"autoruns-dialog-view",children:[b||C?l.jsx("p",{className:"muted",children:"Загружаю диалог..."}):null,!b&&!C&&(y?.messages.length??0)===0?l.jsx("p",{className:"muted",children:"Диалог для этого прогона не найден."}):null,(y?.messages??[]).map((a,c)=>{const f=a.role==="assistant"?"assistant":"user";return l.jsxs("article",{className:`autoruns-msg ${f}`,children:[l.jsxs("header",{children:[l.jsx("strong",{children:f==="assistant"?"Система":"Модель/вопрос"}),l.jsxs("div",{className:"autoruns-msg-head-actions",children:[a.case_id?l.jsx("span",{className:"autoruns-msg-case-tag",children:a.case_id}):null,l.jsx("span",{children:a.created_at?ln(a.created_at):"нет данных"}),f==="assistant"&&!Hs(Pe)?l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:a.commented?"autoruns-comment-icon commented":"autoruns-comment-icon",onClick:()=>Ql(a),title:"\\u041a\\u043e\\u043c\\u043c\\u0435\\u043d\\u0442\\u0438\\u0440\\u043e\\u0432\\u0430\\u0442\\u044c \\u043e\\u0442\\u0432\\u0435\\u0442 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u044b","aria-label":"\\u041a\\u043e\\u043c\\u043c\\u0435\\u043d\\u0442\\u0438\\u0440\\u043e\\u0432\\u0430\\u0442\\u044c \\u043e\\u0442\\u0432\\u0435\\u0442 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u044b",children:l.jsx(im,{commented:a.commented})}),a.annotation?l.jsx("button",{type:"button",className:a.annotation.resolved?"autoruns-resolve-toggle resolved":"autoruns-resolve-toggle",onClick:()=>{Oo(a.annotation,!a.annotation.resolved)},disabled:Eo===a.annotation.annotation_id,title:a.annotation.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный","aria-label":a.annotation.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный",children:l.jsx(od,{resolved:a.annotation.resolved})}):null]}):null]})]}),l.jsx("p",{children:a.text}),f==="assistant"&&a.annotation?l.jsxs("div",{className:"autoruns-msg-annotation",children:[l.jsx("strong",{children:Ea(a.annotation.rating)}),l.jsx("span",{children:a.annotation.comment}),l.jsxs("span",{className:"muted",children:[a.annotation.manual_case_decision,a.annotation.annotation_author?` | ${a.annotation.annotation_author}`:""]})]}):null,(a.trace_id||a.reply_type)&&l.jsxs("footer",{children:[a.trace_id?l.jsxs("span",{children:["trace=",a.trace_id]}):null,a.reply_type?l.jsxs("span",{children:["reply_type=",a.reply_type]}):null]})]},a.message_id??`${f}-${c}`)})]})]}),gt?l.jsx("div",{className:"autoruns-col autoruns-assistant-live-col",children:l.jsx(qf,{sessionId:et,conversation:Qt,inputValue:Vs,onInputChange:Ws,selectedContextChip:De,onSelectContextChip:Gs,onClearContextChip:()=>Gs(null),useMock:Br,onUseMockChange:To,onSend:gs,onClear:wr,onSaveSession:Ul,busy:Qr,saveBusy:Et.saving,saveDisabled:!et.trim()||Qt.length===0||Qr,statusText:Mo,errorMessage:Yt,showSaveAction:!0,showCommentAction:!0,onCommentAssistantMessage:Lo,isAssistantMessageCommented:_s,canCommentAssistantMessage:Xr})}):null,ct?l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Прогресс / регресс"})}),l.jsxs("div",{className:"autoruns-stats-grid",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Последний score"}),l.jsx("strong",{children:Il(Z?.stats.latest_score_index??null)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Предыдущий"}),l.jsx("strong",{children:Il(Z?.stats.previous_score_index??null)})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Тренд"}),l.jsx("strong",{children:Z?nd(Z.stats.trend):"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Пробелы качества"}),l.jsx("strong",{children:Z?.stats.quality_gap_runs??0})]})]}),l.jsx("h4",{children:"Покрытие доменов (история)"}),rd(Z?.stats.domain_coverage??[]),l.jsx("h4",{style:{marginTop:14},children:"Покрытие доменов (выбранный прогон)"}),rd(F?.coverage.domain_coverage??[]),l.jsx("h4",{style:{marginTop:14},children:"Очереди фиксов пост-анализа"}),An?l.jsx("p",{className:"muted",children:"Собираю пост-анализ..."}):null,An?null:l.jsx("div",{className:"autoruns-stats-grid",children:Object.entries(de?.post_analysis.stats.by_queue??{}).map(([a,c])=>l.jsxs("div",{children:[l.jsx("span",{children:a}),l.jsx("strong",{children:c})]},a))}),l.jsxs("div",{className:"autoruns-autogen-list",children:[(de?.post_analysis.recommended_regression_candidates??[]).slice(0,12).map(a=>l.jsxs("article",{className:"autoruns-autogen-item",children:[l.jsxs("header",{children:[l.jsx("strong",{children:a.manual_case_decision}),l.jsxs("span",{children:[a.rating,"/5"]})]}),l.jsxs("div",{className:"autoruns-run-meta",children:[a.domain??"неизвестно"," / ",a.query_class??"неизвестно"]}),l.jsx("p",{children:a.comment})]},a.annotation_id)),!An&&(de?.post_analysis.recommended_regression_candidates.length??0)===0?l.jsx("p",{className:"muted",children:"Рекомендованных кандидатов пока нет."}):null]})]}):null,Ut?l.jsxs("section",{className:"autoruns-col",children:[l.jsx("div",{className:"autoruns-col-header",children:l.jsx("h3",{children:"Комментарии"})}),l.jsx("h4",{children:"Размеченные ответы"}),l.jsxs("div",{className:"autoruns-comment-filter-row",children:[l.jsxs("label",{children:["Фильтр решений",l.jsxs("select",{value:ae,onChange:a=>he(a.target.value),children:[l.jsx("option",{value:"all",children:"все"}),(qt.length>0?qt:we?.enum??[]).map(a=>l.jsx("option",{value:a,children:String(we?.labels?.[a]??a)},a))]})]}),l.jsx("button",{type:"button",className:"tab autoruns-resolved-filter-toggle",onClick:()=>xe(a=>!a),children:ye?"Показать выполненные":"Скрыть выполненные"})]}),l.jsxs("div",{className:"autoruns-stats-grid",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Комментариев"}),l.jsx("strong",{children:lt.length})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Средний рейтинг"}),l.jsx("strong",{children:Ao===null?"нет данных":`${Ao.toFixed(2)} / 5`})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Последний"}),l.jsx("strong",{children:lt.length>0?ln(lt[0].updated_at):"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"Статус"}),l.jsx("strong",{children:qe?"обновляю":"готово"})]})]}),l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",disabled:qe,onClick:()=>{Lt()},children:qe?"Обновляю...":"Обновить список"}),l.jsx("button",{type:"button",className:"tab",disabled:An,onClick:()=>{Xt()},children:An?"Идет пост-анализ...":"Обновить пост-анализ"})]}),l.jsxs("div",{className:"autoruns-comments-list",children:[qe?l.jsx("p",{className:"muted",children:"Загружаю комментарии..."}):null,!qe&<.length===0?l.jsx("p",{className:"muted",children:re.length===0&&pr.length===0?"Пока нет откомментированных ответов.":"Нет открытых кейсов по текущему фильтру."}):null,lt.map(a=>{if(a.source==="assistant_live"){const f=a.assistant;return l.jsxs("article",{className:"autoruns-comment-item",children:[l.jsxs("div",{className:"autoruns-comment-head",children:[l.jsx("strong",{children:Ea(f.rating)}),l.jsx("div",{className:"autoruns-comment-head-actions",children:l.jsx("span",{children:ln(f.updated_at)})})]}),l.jsxs("div",{className:"autoruns-run-meta",children:["live-session: ",f.session_id]}),l.jsxs("div",{className:"autoruns-run-meta",children:["msg=",f.message_index]}),l.jsxs("div",{className:"autoruns-run-meta",children:["source=assistant_live",f.annotation_author?` | author=${f.annotation_author}`:""]}),f.context.question_text?l.jsxs("p",{children:["Q: ",f.context.question_text]}):null,f.context.answer_text?l.jsxs("p",{children:["A: ",f.context.answer_text]}):null,l.jsx("p",{children:f.comment})]},a.key)}const c=a.autorun;return l.jsxs("article",{className:Cn===c.annotation_id?"autoruns-comment-item selected":"autoruns-comment-item",onClick:()=>{Xs(c)},role:"button",tabIndex:0,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),Xs(c))},children:[l.jsxs("div",{className:"autoruns-comment-head",children:[l.jsx("strong",{children:Ea(c.rating)}),l.jsxs("div",{className:"autoruns-comment-head-actions",children:[l.jsx("span",{children:ln(c.updated_at)}),l.jsx("button",{type:"button",className:c.resolved?"autoruns-resolve-toggle resolved":"autoruns-resolve-toggle",onClick:f=>{f.preventDefault(),f.stopPropagation(),Oo(c,!c.resolved)},disabled:Eo===c.annotation_id,title:c.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный","aria-label":c.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный",children:l.jsx(od,{resolved:c.resolved})})]})]}),l.jsx("div",{className:"autoruns-run-meta",children:c.run_id}),l.jsxs("div",{className:"autoruns-run-meta",children:["case=",c.case_id," | msg=",c.message_index]}),l.jsxs("div",{className:"autoruns-run-meta",children:["decision=",c.manual_case_decision,c.annotation_author?` | author=${c.annotation_author}`:""]}),c.resolved_at?l.jsxs("div",{className:"autoruns-run-meta",children:["выполнено",": ",ln(c.resolved_at),c.resolved_by?` | by=${c.resolved_by}`:""]}):null,c.context.question_text?l.jsxs("p",{children:["Q: ",c.context.question_text]}):null,c.context.answer_text?l.jsxs("p",{children:["A: ",c.context.answer_text]}):null,l.jsx("p",{children:c.comment})]},a.key)})]}),Te?l.jsxs(l.Fragment,{children:[l.jsx("h4",{children:"Тех-контекст брака"}),l.jsxs("div",{className:"autoruns-meta-list",children:[l.jsxs("div",{children:[l.jsx("span",{children:"trace:"}),l.jsx("strong",{children:Te.technical_context.trace_id??"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"reply_type:"}),l.jsx("strong",{children:Te.technical_context.reply_type??"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"domain:"}),l.jsx("strong",{children:Te.technical_context.domain??"нет данных"})]}),l.jsxs("div",{children:[l.jsx("span",{children:"query_class:"}),l.jsx("strong",{children:Te.technical_context.query_class??"нет данных"})]})]}),l.jsx("h4",{children:"JSON разбор"}),l.jsx(dd,{value:{annotation_id:Te.annotation_id,run_id:Te.run_id,case_id:Te.case_id,message_index:Te.message_index,rating:Te.rating,comment:Te.comment,manual_case_decision:Te.manual_case_decision,annotation_author:Te.annotation_author,resolved:Te.resolved,resolved_at:Te.resolved_at,resolved_by:Te.resolved_by,context:Te.context,technical_context:Te.technical_context,case_summary:Te.case_summary?{case_id:Te.case_summary.case_id,domain:Te.case_summary.domain,query_class:Te.case_summary.query_class,checks:Te.case_summary.checks,metric_subscores:Te.case_summary.metric_subscores}:null}})]}):null]}):null]}),Et.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&Xn()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Сохранить ручную сессию"}),l.jsx("p",{className:"muted",children:"Технический чат будет сохранен в автопрогоны как пользовательская multi-turn сессия."}),l.jsxs("label",{children:["Название",l.jsx("input",{value:Et.title,onChange:a=>zn(c=>({...c,title:a.target.value})),placeholder:"Например: НДС и склад на март 2020",disabled:Et.saving})]}),Et.error?l.jsx("p",{className:"error-text",children:Et.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{Bl()},disabled:Et.saving,children:Et.saving?"Сохраняю...":"Сохранить"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>Xn(),disabled:Et.saving,children:"Отмена"})]})]})}):null,Pt.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&Wr()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Удалить вопрос"}),l.jsx("p",{className:"muted",children:"Действительно удалить вопрос из сохраненной пользовательской сессии?"}),l.jsx("p",{className:"autoruns-comment-quote",children:Pt.questionText}),Pt.error?l.jsx("p",{className:"error-text",children:Pt.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{bl()},disabled:Pt.saving,children:Pt.saving?"Удаляю...":"Да"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>Wr(),disabled:Pt.saving,children:"Нет"})]})]})}):null,pn.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&hs()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Удалить сохраненный набор"}),l.jsx("p",{className:"muted",children:"Будет удалена карточка истории и связанный файл кейс-сета на бэке."}),l.jsx("p",{className:"autoruns-comment-quote",children:pn.title}),pn.error?l.jsx("p",{className:"error-text",children:pn.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{Xl()},disabled:pn.saving,children:pn.saving?"Удаляю...":"Да"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>hs(),disabled:pn.saving,children:"Нет"})]})]})}):null,Ne.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&Yn()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Комментарий к ответу ассистента"}),l.jsx("p",{className:"muted",children:"Комментарий будет добавлен в общий список комментариев справа с меткой `assistant_live`."}),Sr?l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Вопрос пользователя"}),l.jsx("p",{className:"autoruns-comment-quote",children:Sr.text})]}):null,_r?l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Ответ ассистента"}),l.jsx("p",{className:"autoruns-comment-quote",children:_r.text})]}):null,l.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа ассистента",children:[1,2,3,4,5].map(a=>l.jsx("button",{type:"button",className:Ne.rating>=a?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>fn(c=>({...c,rating:a})),disabled:Ne.saving,"aria-label":`Оценка ${a}`,children:Ne.rating>=a?"●":"○"},a))}),l.jsx("div",{className:"autoruns-form-grid",children:l.jsxs("label",{children:["Автор комментария",l.jsx("input",{value:Ne.annotationAuthor,onChange:a=>fn(c=>({...c,annotationAuthor:a.target.value})),placeholder:"manual_reviewer",disabled:Ne.saving})]})}),l.jsxs("label",{children:["Комментарий",l.jsx("textarea",{value:Ne.comment,onChange:a=>fn(c=>({...c,comment:a.target.value})),placeholder:"Что именно не так в ответе и что нужно исправить.",rows:4,disabled:Ne.saving})]}),Ne.error?l.jsx("p",{className:"error-text",children:Ne.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{Hl()},disabled:Ne.saving,children:Ne.saving?"Сохраняю...":"Готово"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>Yn(),disabled:Ne.saving,children:"Отмена"})]})]})}):null,fe.open?l.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&kr()},children:l.jsxs("div",{className:"autoruns-comment-modal",children:[l.jsx("h3",{children:"Комментарий к ответу системы"}),l.jsx("p",{className:"muted",children:"Оцените ответ по 5-балльной шкале и добавьте комментарий по браку."}),gn?l.jsxs(l.Fragment,{children:[l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Вопрос пользователя"}),l.jsx("p",{className:"autoruns-comment-quote",children:$n?.text??"Вопрос в диалоге не найден."})]}),l.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[l.jsx("summary",{children:"Ответ системы"}),l.jsx("p",{className:"autoruns-comment-quote",children:gn.text})]})]}):null,l.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа",children:[1,2,3,4,5].map(a=>l.jsx("button",{type:"button",className:fe.rating>=a?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>Nt(c=>({...c,rating:a})),disabled:fe.saving,"aria-label":`Оценка ${a}`,children:fe.rating>=a?"●":"○"},a))}),l.jsxs("div",{className:"autoruns-form-grid",children:[l.jsxs("label",{children:["Решение по кейсу",l.jsx("select",{value:fe.manualCaseDecision,onChange:a=>Nt(c=>({...c,manualCaseDecision:a.target.value})),disabled:fe.saving,children:(qt.length>0?qt:we?.enum??[Al]).map(a=>l.jsx("option",{value:a,children:String(we?.labels?.[a]??a)},a))})]}),l.jsxs("label",{children:["Автор комментария",l.jsx("input",{value:fe.annotationAuthor,onChange:a=>Nt(c=>({...c,annotationAuthor:a.target.value})),placeholder:"manual_reviewer",disabled:fe.saving})]})]}),l.jsxs("label",{children:["Комментарий",l.jsx("textarea",{value:fe.comment,onChange:a=>Nt(c=>({...c,comment:a.target.value})),placeholder:"Почему ответ бракованный, что именно пошло не так, какие технические детали проверить.",rows:4,disabled:fe.saving})]}),fe.error?l.jsx("p",{className:"error-text",children:fe.error}):null,l.jsxs("div",{className:"button-row",children:[l.jsx("button",{type:"button",onClick:()=>{qs()},disabled:fe.saving,children:fe.saving?"Сохраняю...":"Готово"}),l.jsx("button",{type:"button",className:"tab",onClick:()=>kr(),disabled:fe.saving,children:"Отмена"})]})]})}):null]})}const cm={llmProvider:"openai",apiKey:"",model:"gpt-4o-mini",baseUrl:"https://api.openai.com/v1",temperature:0,maxOutputTokens:700},id={systemPrompt:"Ты semantic-normalizer для бухгалтерского ассистента NDC. Возвращай только JSON по схеме normalized_query_v2_0_2.",developerPrompt:"Сначала делай decomposition сообщения на task fragments, затем определяй domain scope и route-critical flags. Для каждого fragment заполняй execution_readiness + route_status + no_route_reason. Если fragment routable, не оставляй его в no_route.",domainPrompt:"Контур: данные текущего предприятия в 1С/NDC. In-scope: документы, проводки, взаиморасчеты, остатки, периодное закрытие, аномалии и контрольные проверки. Out-of-scope: общая теория, законы и оффтоп.",schemaNotes:"schema_version: normalized_query_v2_0_2. Строгий JSON без дополнительных полей.",fewShotExamples:"Q: Проверь по поставщикам хвосты и разложи цепочку документов/оплат. => fragment in_scope, flags: multi_entity + chain_explanation. Q: Как вообще по ФСБУ? => out_of_scope/generic_accounting."},dm={userQuestion:"",batchQuestionsRaw:"",periodHint:"",businessContext:"",expectedRoute:""},Pa={colors:{backgroundRgb:"18, 18, 18",mainSurfaceRgb:"25, 25, 25",horizontalSurfaceRgb:"30, 30, 30",focusSurfaceRgb:"35, 35, 35",assistantChipRgb:"18, 18, 18",assistantChipHoverRgb:"44, 44, 44",assistantChipSelectedRgb:"167, 59, 255",assistantChipSelectedTextRgb:"240, 240, 240",activeRgb:"167, 59, 255",activeTextRgb:"240, 240, 240",textMainRgb:"240, 240, 240",textMutedRgb:"166, 166, 166",dangerRgb:"126, 126, 126",scrollbarTrackRgb:"20, 20, 20",scrollbarThumbRgb:"30, 30, 30",scrollbarThumbHoverRgb:"30, 50, 30"},layout:{modeColumnWidthPx:406,modeToggleWidthPx:188}},ad="ndc_normalizer_session_config_v1",ud="ndc_autoruns_layout_config_v1",fm="ndc-autoruns-save",mm="autoruns",Ta="normalizer_v2_0_2",pm="address_query_runtime_v1",hm=["normalized","fragments","scope","flags","route","raw","validation","logs"];function gm(i){return`[${new Date().toLocaleTimeString("ru-RU")}] ${i}`}function vm(i,h){if(!h)return"Previous preset is not selected.";const R=["systemPrompt","developerPrompt","domainPrompt","schemaNotes","fewShotExamples"].filter(E=>i[E]!==h[E]).map(E=>`${E}: ${Math.abs(i[E].length-h[E].length)} chars delta`);return R.length===0?"No changes against previous preset.":`Changed fields: ${R.length}. ${R.join(" | ")}`}function ym(){const[i,h]=v.useState(cm),[m,R]=v.useState(id),[E,I]=v.useState(dm),[Q,le]=v.useState(null),[te,z]=v.useState([]),[Y,X]=v.useState([]),[ee,Me]=v.useState("normalized"),[ue,ce]=v.useState(!1),[pe,Ve]=v.useState(!1),[Xe,We]=v.useState([]),[Ae,$]=v.useState(""),[oe,je]=v.useState([]),[Be,gt]=v.useState(""),[ct,Ut]=v.useState("NDC custom preset"),[dt,B]=v.useState(null),[Le,Ke]=v.useState(""),[ne,Z]=v.useState(!1),[M,F]=v.useState([]),[A,y]=v.useState(""),[k,re]=v.useState([]),[ie,ae]=v.useState(!1),[he,ye]=v.useState(null),[xe,we]=v.useState(""),[ft,qt]=v.useState(mm),[ir,Cn]=v.useState(!0),[an,Pe]=v.useState(!0),[Bt,st]=v.useState(!0),[vt,jt]=v.useState(!0),[un,G]=v.useState(!0),[mt,ar]=v.useState(!0),[Nn,Gn]=v.useState(!0),[En,ge]=v.useState(!0),[At,Jt]=v.useState(!0),[Pn,ot]=v.useState(!0),[ur,cr]=v.useState(!0),[Tn,$r]=v.useState(!0),[cn,Kn]=v.useState(!0),Ct=v.useRef(!1),Qe=v.useRef(!1),Rn=v.useRef(!1);v.useEffect(()=>{const C=document.documentElement,{colors:J}=Pa;C.style.setProperty("--rgb-background",J.backgroundRgb),C.style.setProperty("--rgb-surface-main",J.mainSurfaceRgb),C.style.setProperty("--rgb-surface-horizontal",J.horizontalSurfaceRgb),C.style.setProperty("--rgb-surface-focus",J.focusSurfaceRgb),C.style.setProperty("--rgb-assistant-chip",J.assistantChipRgb),C.style.setProperty("--rgb-assistant-chip-hover",J.assistantChipHoverRgb),C.style.setProperty("--rgb-assistant-chip-selected",J.assistantChipSelectedRgb),C.style.setProperty("--rgb-assistant-chip-selected-text",J.assistantChipSelectedTextRgb),C.style.setProperty("--rgb-active",J.activeRgb),C.style.setProperty("--rgb-active-text",J.activeTextRgb),C.style.setProperty("--rgb-text-main",J.textMainRgb),C.style.setProperty("--rgb-text-muted",J.textMutedRgb),C.style.setProperty("--rgb-danger",J.dangerRgb),C.style.setProperty("--rgb-scrollbar-track",J.scrollbarTrackRgb),C.style.setProperty("--rgb-scrollbar-thumb",J.scrollbarThumbRgb),C.style.setProperty("--rgb-scrollbar-thumb-hover",J.scrollbarThumbHoverRgb),C.style.setProperty("--mode-column-width",`${Pa.layout.modeColumnWidthPx}px`),C.style.setProperty("--mode-toggle-width",`${Pa.layout.modeToggleWidthPx}px`)},[]);const de=C=>{X(J=>[gm(C),...J].slice(0,300))};v.useEffect(()=>{(async()=>{const b=localStorage.getItem(ad);if(b)try{const Ce=JSON.parse(b);h(qe=>({...qe,llmProvider:Ce.llmProvider==="local"?"local":"openai",model:Ce.model??qe.model,baseUrl:Ce.baseUrl??qe.baseUrl,temperature:Ce.temperature??qe.temperature,maxOutputTokens:Ce.maxOutputTokens??qe.maxOutputTokens}))}catch{}try{const Ce=await Re.loadSharedConnectionConfig();Ce.connection&&Ce.connection.llmProvider==="local"&&(h(qe=>({...qe,llmProvider:"local",model:Ce.connection?.model??qe.model,baseUrl:Ce.connection?.baseUrl??qe.baseUrl,temperature:Ce.connection?.temperature??qe.temperature,maxOutputTokens:Ce.connection?.maxOutputTokens??qe.maxOutputTokens})),de(`Shared local LLM config loaded: ${Ce.connection.model}`))}catch(Ce){de(`Shared local config load error: ${Ce instanceof Error?Ce.message:String(Ce)}`)}finally{Rn.current=!0}})();const J=localStorage.getItem(ud);if(J)try{const b=JSON.parse(J);(b.uiMode==="assistant"||b.uiMode==="autoruns"||b.uiMode==="decomposition")&&qt("autoruns"),b.activeTab&&hm.includes(b.activeTab)&&Me(b.activeTab),typeof b.showAutorunsSettingsMode=="boolean"&&Cn(b.showAutorunsSettingsMode),typeof b.showAutorunsAutoRunsMode=="boolean"&&Pe(b.showAutorunsAutoRunsMode),typeof b.showAutorunsAssistantMode=="boolean"&&st(b.showAutorunsAssistantMode),typeof b.showAutorunsDecompositionMode=="boolean"&&jt(b.showAutorunsDecompositionMode),typeof b.showAutorunsProgressMode=="boolean"&&G(b.showAutorunsProgressMode),typeof b.showAutorunsCommentsMode=="boolean"&&ar(b.showAutorunsCommentsMode),typeof b.showDecompositionConnectionMode=="boolean"&&Gn(b.showDecompositionConnectionMode),typeof b.showDecompositionPromptMode=="boolean"&&ge(b.showDecompositionPromptMode),typeof b.showDecompositionQueryMode=="boolean"&&Jt(b.showDecompositionQueryMode),typeof b.showDecompositionOutputMode=="boolean"&&ot(b.showDecompositionOutputMode),typeof b.showDecompositionMetricsMode=="boolean"&&cr(b.showDecompositionMetricsMode),typeof b.showDecompositionHistoryMode=="boolean"&&$r(b.showDecompositionHistoryMode),typeof b.showDecompositionRuntimeMode=="boolean"&&Kn(b.showDecompositionRuntimeMode),b.prompts&&(R(Ce=>({...Ce,...b.prompts})),Qe.current=!0)}catch{}dn(),dr(),Fr()},[]),v.useEffect(()=>{if(!Rn.current||i.llmProvider!=="local")return;const C=window.setTimeout(()=>{Re.saveSharedConnectionConfig(i).catch(J=>de(`Shared local config sync error: ${J instanceof Error?J.message:String(J)}`))},250);return()=>window.clearTimeout(C)},[i.baseUrl,i.llmProvider,i.maxOutputTokens,i.model,i.temperature]);async function dn(){try{const C=await Re.loadHistory();z(C.items??[])}catch(C){de(`History load error: ${C instanceof Error?C.message:String(C)}`)}}async function dr(){try{const J=(await Re.loadPresets()).presets??[];if(je(J),Qe.current){Ct.current=!0;return}if(Ct.current)return;const b=J.find(Ce=>Ce.prompt_version===Ta)??J.find(Ce=>Ce.id==="default-normalizer-v2_0_2");if(!b){Ct.current=!0,de(`Preset autoload skipped: ${Ta} not found.`);return}gt(b.id),B(m),R({systemPrompt:b.systemPrompt,developerPrompt:b.developerPrompt,domainPrompt:b.domainPrompt,schemaNotes:b.schemaNotes??"",fewShotExamples:b.fewShotExamples??""}),Ct.current=!0,de(`Preset autoloaded: ${b.name} (${b.prompt_version}).`)}catch(C){de(`Presets load error: ${C instanceof Error?C.message:String(C)}`)}}async function Fr(){try{const C=await Re.listRuns();F(C.items??[])}catch(C){de(`Runs load error: ${C instanceof Error?C.message:String(C)}`)}}function Ur(){if(localStorage.setItem(ad,JSON.stringify({model:i.model,llmProvider:i.llmProvider,baseUrl:i.baseUrl,temperature:i.temperature,maxOutputTokens:i.maxOutputTokens})),i.llmProvider==="local"){Re.saveSharedConnectionConfig(i).then(()=>{de("Local config saved and synced to shared agent config (without API key).")}).catch(C=>{de(`Local config saved, but shared sync failed: ${C instanceof Error?C.message:String(C)}`)});return}de("Local config saved (without API key).")}function Mn(){localStorage.setItem(ud,JSON.stringify({uiMode:ft,activeTab:ee,showAutorunsSettingsMode:ir,showAutorunsAutoRunsMode:an,showAutorunsAssistantMode:Bt,showAutorunsDecompositionMode:vt,showAutorunsProgressMode:un,showAutorunsCommentsMode:mt,showDecompositionConnectionMode:Nn,showDecompositionPromptMode:En,showDecompositionQueryMode:At,showDecompositionOutputMode:Pn,showDecompositionMetricsMode:ur,showDecompositionHistoryMode:Tn,showDecompositionRuntimeMode:cn,prompts:m})),window.dispatchEvent(new CustomEvent(fm)),de("UI layout and prompts saved.")}async function An(){ce(!0),we("");try{const C=await Re.testConnection(i);C.provider==="local"?C.model_found===!0?($(`LOCAL OK - ${C.model}`),de(`Local model is available: ${C.model} (catalog size=${C.models_count??"n/a"}).`)):C.model_found===!1?($(`LOCAL OK, model not loaded - ${C.model}`),de(`Local server is reachable, but model '${C.model}' is not in loaded catalog. Use 'Load model list' and select one of loaded models.`)):($(`LOCAL OK (model list unavailable) - ${C.model}`),de("Local server is reachable, but model catalog could not be verified.")):($(`OPENAI OK - ${C.model}`),de(`OpenAI connection ok: ${C.model}`))}catch(C){const J=C instanceof Error?C.message:String(C);$("Connection error"),we(`Test connection: ${J}`),de(`Test connection error: ${J}`)}finally{ce(!1)}}async function fr(){Ve(!0);try{const J=(await Re.listModels(i)).models??[];We(J),J.length>0&&h(b=>b.model&&J.includes(b.model)?b:{...b,model:J[0]}),de(`Model catalog loaded (${i.llmProvider}): ${J.length} items.`)}catch(C){const J=C instanceof Error?C.message:String(C);de(`Load model list error: ${J}`)}finally{Ve(!1)}}v.useEffect(()=>{We([])},[i.llmProvider,i.baseUrl]);function qn(){const C=oe.find(J=>J.id===Be);if(!C){de("Preset is not selected.");return}B(m),R({systemPrompt:C.systemPrompt,developerPrompt:C.developerPrompt,domainPrompt:C.domainPrompt,schemaNotes:C.schemaNotes??"",fewShotExamples:C.fewShotExamples??""}),de(`Preset loaded: ${C.name}`)}async function Ln(){try{await Re.savePreset({name:ct||"NDC preset",prompt_version:"normalizer_v2_0_2",systemPrompt:m.systemPrompt,developerPrompt:m.developerPrompt,domainPrompt:m.domainPrompt,schemaNotes:m.schemaNotes,fewShotExamples:m.fewShotExamples}),de("Preset saved."),await dr()}catch(C){de(`Preset save error: ${C instanceof Error?C.message:String(C)}`)}}function mr(){R(id),de("Prompt panel reset to defaults.")}function In(){const C=vm(m,dt);Ke(C),de(C)}return v.useEffect(()=>{if(!A){re([]);return}Re.runTrace(A).then(C=>re(C.items)).catch(C=>de(`Run trace error: ${C instanceof Error?C.message:String(C)}`))},[A]),l.jsxs("main",{className:"app-root app-root-autoruns",children:[l.jsxs("header",{className:"app-topbar",children:[l.jsxs("div",{className:"mode-switch-row",children:[l.jsx("button",{type:"button",className:"tab active",onClick:()=>qt("autoruns"),children:"Управление ассистентом"}),l.jsx("button",{type:"button",className:"tab",onClick:Mn,children:"Сохранить"})]}),l.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[l.jsx("button",{type:"button",className:ir?"tab active":"tab",onClick:()=>Cn(C=>!C),children:"Настройки"}),l.jsx("button",{type:"button",className:an?"tab active":"tab",onClick:()=>Pe(C=>!C),children:"Автопрогоны"}),l.jsx("button",{type:"button",className:Bt?"tab active":"tab",onClick:()=>st(C=>!C),children:"Режим ассистента"}),l.jsx("button",{type:"button",className:un?"tab active":"tab",onClick:()=>G(C=>!C),children:"Прогресс/регресс"}),l.jsx("button",{type:"button",className:mt?"tab active":"tab",onClick:()=>ar(C=>!C),children:"Комментарии"})]})]}),l.jsx("div",{className:"layout-grid layout-grid-autoruns",children:l.jsx(um,{connection:i,modelOptions:Xe,modelsBusy:pe,connectionStatus:Ae,connectionBusy:ue,onConnectionChange:h,onReloadModels:fr,onSaveLocalConfig:Ur,onTestConnection:An,prompts:m,onPromptsChange:R,promptPresets:oe,selectedPresetId:Be,onSelectPreset:gt,onLoadPreset:qn,onSavePreset:Ln,onResetDefaults:mr,onDiffPrevious:In,presetName:ct,onPresetNameChange:Ut,diffSummary:Le,assistantPromptVersion:pm,decompositionPromptVersion:Ta,showSettingsMode:ir,showAutoRunsMode:an,showAssistantMode:Bt,showProgressMode:un,showCommentsMode:mt,onLog:de})})]})}Tf.createRoot(document.getElementById("root")).render(l.jsx(wf.StrictMode,{children:l.jsx(ym,{})})); diff --git a/llm_normalizer/frontend/dist/assets/index-CLCo6iY2.js b/llm_normalizer/frontend/dist/assets/index-CLCo6iY2.js new file mode 100644 index 0000000..7949eb8 --- /dev/null +++ b/llm_normalizer/frontend/dist/assets/index-CLCo6iY2.js @@ -0,0 +1,24 @@ +(function(){const h=document.createElement("link").relList;if(h&&h.supports&&h.supports("modulepreload"))return;for(const E of document.querySelectorAll('link[rel="modulepreload"]'))T(E);new MutationObserver(E=>{for(const I of E)if(I.type==="childList")for(const B of I.addedNodes)B.tagName==="LINK"&&B.rel==="modulepreload"&&T(B)}).observe(document,{childList:!0,subtree:!0});function p(E){const I={};return E.integrity&&(I.integrity=E.integrity),E.referrerPolicy&&(I.referrerPolicy=E.referrerPolicy),E.crossOrigin==="use-credentials"?I.credentials="include":E.crossOrigin==="anonymous"?I.credentials="omit":I.credentials="same-origin",I}function T(E){if(E.ep)return;E.ep=!0;const I=p(E);fetch(E.href,I)}})();function vd(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Ta={exports:{}},Do={},Ma={exports:{}},pe={};var Wc;function wf(){if(Wc)return pe;Wc=1;var a=Symbol.for("react.element"),h=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),I=Symbol.for("react.provider"),B=Symbol.for("react.context"),ae=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),z=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),ee=Symbol.iterator;function ne(y){return y===null||typeof y!="object"?null:(y=ee&&y[ee]||y["@@iterator"],typeof y=="function"?y:null)}var Te={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},de=Object.assign,fe={};function he(y,k,oe){this.props=y,this.context=k,this.refs=fe,this.updater=oe||Te}he.prototype.isReactComponent={},he.prototype.setState=function(y,k){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,k,"setState")},he.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function Qe(){}Qe.prototype=he.prototype;function Ke(y,k,oe){this.props=y,this.context=k,this.refs=fe,this.updater=oe||Te}var He=Ke.prototype=new Qe;He.constructor=Ke,de(He,he.prototype),He.isPureReactComponent=!0;var Me=Array.isArray,$=Object.prototype.hasOwnProperty,ie={current:null},je={key:!0,ref:!0,__self:!0,__source:!0};function Ue(y,k,oe){var ue,ce={},ge=null,ye=null;if(k!=null)for(ue in k.ref!==void 0&&(ye=k.ref),k.key!==void 0&&(ge=""+k.key),k)$.call(k,ue)&&!je.hasOwnProperty(ue)&&(ce[ue]=k[ue]);var xe=arguments.length-2;if(xe===1)ce.children=oe;else if(1>>1,k=R[y];if(0>>1;yE(ce,A))geE(ye,ce)?(R[y]=ye,R[ge]=A,y=ge):(R[y]=ce,R[ue]=A,y=ue);else if(geE(ye,A))R[y]=ye,R[ge]=A,y=ge;else break e}}return F}function E(R,F){var A=R.sortIndex-F.sortIndex;return A!==0?A:R.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var I=performance;a.unstable_now=function(){return I.now()}}else{var B=Date,ae=B.now();a.unstable_now=function(){return B.now()-ae}}var re=[],z=[],Z=1,ee=null,ne=3,Te=!1,de=!1,fe=!1,he=typeof setTimeout=="function"?setTimeout:null,Qe=typeof clearTimeout=="function"?clearTimeout:null,Ke=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function He(R){for(var F=p(z);F!==null;){if(F.callback===null)T(z);else if(F.startTime<=R)T(z),F.sortIndex=F.expirationTime,h(re,F);else break;F=p(z)}}function Me(R){if(fe=!1,He(R),!de)if(p(re)!==null)de=!0,se($);else{var F=p(z);F!==null&&te(Me,F.startTime-R)}}function $(R,F){de=!1,fe&&(fe=!1,Qe(Ue),Ue=-1),Te=!0;var A=ne;try{for(He(F),ee=p(re);ee!==null&&(!(ee.expirationTime>F)||R&&!Bt());){var y=ee.callback;if(typeof y=="function"){ee.callback=null,ne=ee.priorityLevel;var k=y(ee.expirationTime<=F);F=a.unstable_now(),typeof k=="function"?ee.callback=k:ee===p(re)&&T(re),He(F)}else T(re);ee=p(re)}if(ee!==null)var oe=!0;else{var ue=p(z);ue!==null&&te(Me,ue.startTime-F),oe=!1}return oe}finally{ee=null,ne=A,Te=!1}}var ie=!1,je=null,Ue=-1,ht=5,ut=-1;function Bt(){return!(a.unstable_now()-utR||125y?(R.sortIndex=A,h(z,R),p(re)===null&&R===p(z)&&(fe?(Qe(Ue),Ue=-1):fe=!0,te(Me,A-y))):(R.sortIndex=k,h(re,R),de||Te||(de=!0,se($))),R},a.unstable_shouldYield=Bt,a.unstable_wrapCallback=function(R){var F=ne;return function(){var A=ne;ne=F;try{return R.apply(this,arguments)}finally{ne=A}}}})(La)),La}var Yc;function Ef(){return Yc||(Yc=1,Aa.exports=Nf()),Aa.exports}var Xc;function Pf(){if(Xc)return bt;Xc=1;var a=Qa(),h=Ef();function p(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),re=Object.prototype.hasOwnProperty,z=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Z={},ee={};function ne(e){return re.call(ee,e)?!0:re.call(Z,e)?!1:z.test(e)?ee[e]=!0:(Z[e]=!0,!1)}function Te(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function de(e,t,n,r){if(t===null||typeof t>"u"||Te(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function fe(e,t,n,r,s,l,u){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=l,this.removeEmptyString=u}var he={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){he[e]=new fe(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];he[t]=new fe(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){he[e]=new fe(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){he[e]=new fe(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){he[e]=new fe(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){he[e]=new fe(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){he[e]=new fe(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){he[e]=new fe(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){he[e]=new fe(e,5,!1,e.toLowerCase(),null,!1,!1)});var Qe=/[\-:]([a-z])/g;function Ke(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Qe,Ke);he[t]=new fe(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Qe,Ke);he[t]=new fe(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Qe,Ke);he[t]=new fe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){he[e]=new fe(e,1,!1,e.toLowerCase(),null,!1,!1)}),he.xlinkHref=new fe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){he[e]=new fe(e,1,!1,e.toLowerCase(),null,!0,!0)});function He(e,t,n,r){var s=he.hasOwnProperty(t)?he[t]:null;(s!==null?s.type!==0:r||!(2f||s[u]!==l[f]){var m=` +`+s[u].replace(" at new "," at ");return e.displayName&&m.includes("")&&(m=m.replace("",e.displayName)),m}while(1<=u&&0<=f);break}}}finally{oe=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?k(e):""}function ce(e){switch(e.tag){case 5:return k(e.type);case 16:return k("Lazy");case 13:return k("Suspense");case 19:return k("SuspenseList");case 0:case 2:case 15:return e=ue(e.type,!1),e;case 11:return e=ue(e.type.render,!1),e;case 1:return e=ue(e.type,!0),e;default:return""}}function ge(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case je:return"Fragment";case ie:return"Portal";case ht:return"Profiler";case Ue:return"StrictMode";case b:return"Suspense";case Re:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Bt:return(e.displayName||"Context")+".Consumer";case ut:return(e._context.displayName||"Context")+".Provider";case ct:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ge:return t=e.displayName||null,t!==null?t:ge(e.type)||"Memo";case se:t=e._payload,e=e._init;try{return ge(e(t))}catch{}}return null}function ye(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ge(t);case 8:return t===Ue?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function xe(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Se(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function dt(e){var t=Se(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,l=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(u){r=""+u,l.call(this,u)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(u){r=""+u},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function sn(e){e._valueTracker||(e._valueTracker=dt(e))}function gr(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Se(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ln(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function xn(e,t){var n=t.checked;return A({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Ee(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=xe(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Qt(e,t){t=t.checked,t!=null&&He(e,"checked",t,!1)}function st(e,t){Qt(e,t);var n=xe(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?jt(e,t.type,n):t.hasOwnProperty("defaultValue")&&jt(e,t.type,xe(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function gt(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function jt(e,t,n){(t!=="number"||Ln(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var _n=Array.isArray;function G(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=Dn.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Nt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Je={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},vs=["Webkit","ms","Moz","O"];Object.keys(Je).forEach(function(e){vs.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Je[t]=Je[e]})});function Ze(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Je.hasOwnProperty(e)&&Je[e]?(""+t).trim():t+"px"}function Zn(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Ze(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var yr=A({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function on(e,t){if(t){if(yr[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(p(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(p(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(p(61))}if(t.style!=null&&typeof t.style!="object")throw Error(p(62))}}function On(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Rt=null;function Sn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ht=null,Y=null,ln=null;function er(e){if(e=_o(e)){if(typeof Ht!="function")throw Error(p(280));var t=e.stateNode;t&&(t=ol(t),Ht(e.stateNode,e.type,t))}}function Hr(e){Y?ln?ln.push(e):ln=[e]:Y=e}function Vr(){if(Y){var e=Y,t=ln;if(ln=Y=null,er(e),t)for(e=0;e>>=0,e===0?32:31-(tr(e)/ti|0)|0}var Ss=64,kn=4194304;function nr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Zr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,l=e.pingedLanes,u=n&268435455;if(u!==0){var f=u&~s;f!==0?r=nr(f):(l&=u,l!==0&&(r=nr(l)))}else u=n&~s,u!==0?r=nr(u):l!==0&&(r=nr(l));if(r===0)return 0;if(t!==0&&t!==r&&(t&s)===0&&(s=r&-r,l=t&-t,s>=l||s===16&&(l&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function kr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Wt(t),e[t]=n}function jr(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Pr),fo=" ",i=!1;function c(e,t){switch(e){case"keyup":return Yo.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function d(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var w=!1;function L(e,t){switch(e){case"compositionend":return d(t);case"keypress":return t.which!==32?null:(i=!0,fo);case"textInput":return e=t.data,e===fo&&i?null:e;default:return null}}function Ne(e,t){if(w)return e==="compositionend"||!uo&&c(e,t)?(e=bo(),Cs=oo=Zt=null,w=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ka(n)}}function Ya(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ya(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xa(){for(var e=window,t=Ln();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ln(e.document)}return t}function fi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Pd(e){var t=Xa(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ya(n.ownerDocument.documentElement,n)){if(r!==null&&fi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,l=Math.min(r.start,s);r=r.end===void 0?l:Math.min(r.end,s),!e.extend&&l>r&&(s=r,r=l,l=s),s=Ja(n,l);var u=Ja(n,r);s&&u&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==u.node||e.focusOffset!==u.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),l>r?(e.addRange(t),e.extend(u.node,u.offset)):(t.setEnd(u.node,u.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Ls=null,pi=null,ho=null,mi=!1;function Za(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;mi||Ls==null||Ls!==Ln(r)||(r=Ls,"selectionStart"in r&&fi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ho&&mo(ho,r)||(ho=r,r=nl(pi,"onSelect"),0$s||(e.current=Ni[$s],Ni[$s]=null,$s--)}function Ie(e,t){$s++,Ni[$s]=e.current,e.current=t}var Lr={},xt=Ar(Lr),Ot=Ar(!1),ls=Lr;function Fs(e,t){var n=e.type.contextTypes;if(!n)return Lr;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},l;for(l in n)s[l]=t[l];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function zt(e){return e=e.childContextTypes,e!=null}function ll(){$e(Ot),$e(xt)}function mu(e,t,n){if(xt.current!==Lr)throw Error(p(168));Ie(xt,t),Ie(Ot,n)}function hu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(p(108,ye(e)||"Unknown",s));return A({},n,r)}function il(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Lr,ls=xt.current,Ie(xt,e),Ie(Ot,Ot.current),!0}function gu(e,t,n){var r=e.stateNode;if(!r)throw Error(p(169));n?(e=hu(e,t,ls),r.__reactInternalMemoizedMergedChildContext=e,$e(Ot),$e(xt),Ie(xt,e)):$e(Ot),Ie(Ot,n)}var ur=null,al=!1,Ei=!1;function vu(e){ur===null?ur=[e]:ur.push(e)}function Ud(e){al=!0,vu(e)}function Ir(){if(!Ei&&ur!==null){Ei=!0;var e=0,t=Q;try{var n=ur;for(Q=1;e>=u,s-=u,cr=1<<32-Wt(t)+s|n<le?(at=J,J=null):at=J.sibling;var ke=j(x,J,_[le],M);if(ke===null){J===null&&(J=at);break}e&&J&&ke.alternate===null&&t(x,J),v=l(ke,v,le),K===null?W=ke:K.sibling=ke,K=ke,J=at}if(le===_.length)return n(x,J),Fe&&as(x,le),W;if(J===null){for(;le<_.length;le++)J=P(x,_[le],M),J!==null&&(v=l(J,v,le),K===null?W=J:K.sibling=J,K=J);return Fe&&as(x,le),W}for(J=r(x,J);le<_.length;le++)at=D(J,x,le,_[le],M),at!==null&&(e&&at.alternate!==null&&J.delete(at.key===null?le:at.key),v=l(at,v,le),K===null?W=at:K.sibling=at,K=at);return e&&J.forEach(function(Qr){return t(x,Qr)}),Fe&&as(x,le),W}function H(x,v,_,M){var W=F(_);if(typeof W!="function")throw Error(p(150));if(_=W.call(_),_==null)throw Error(p(151));for(var K=W=null,J=v,le=v=0,at=null,ke=_.next();J!==null&&!ke.done;le++,ke=_.next()){J.index>le?(at=J,J=null):at=J.sibling;var Qr=j(x,J,ke.value,M);if(Qr===null){J===null&&(J=at);break}e&&J&&Qr.alternate===null&&t(x,J),v=l(Qr,v,le),K===null?W=Qr:K.sibling=Qr,K=Qr,J=at}if(ke.done)return n(x,J),Fe&&as(x,le),W;if(J===null){for(;!ke.done;le++,ke=_.next())ke=P(x,ke.value,M),ke!==null&&(v=l(ke,v,le),K===null?W=ke:K.sibling=ke,K=ke);return Fe&&as(x,le),W}for(J=r(x,J);!ke.done;le++,ke=_.next())ke=D(J,x,le,ke.value,M),ke!==null&&(e&&ke.alternate!==null&&J.delete(ke.key===null?le:ke.key),v=l(ke,v,le),K===null?W=ke:K.sibling=ke,K=ke);return e&&J.forEach(function(Sf){return t(x,Sf)}),Fe&&as(x,le),W}function qe(x,v,_,M){if(typeof _=="object"&&_!==null&&_.type===je&&_.key===null&&(_=_.props.children),typeof _=="object"&&_!==null){switch(_.$$typeof){case $:e:{for(var W=_.key,K=v;K!==null;){if(K.key===W){if(W=_.type,W===je){if(K.tag===7){n(x,K.sibling),v=s(K,_.props.children),v.return=x,x=v;break e}}else if(K.elementType===W||typeof W=="object"&&W!==null&&W.$$typeof===se&&ku(W)===K.type){n(x,K.sibling),v=s(K,_.props),v.ref=So(x,K,_),v.return=x,x=v;break e}n(x,K);break}else t(x,K);K=K.sibling}_.type===je?(v=gs(_.props.children,x.mode,M,_.key),v.return=x,x=v):(M=Ol(_.type,_.key,_.props,null,x.mode,M),M.ref=So(x,v,_),M.return=x,x=M)}return u(x);case ie:e:{for(K=_.key;v!==null;){if(v.key===K)if(v.tag===4&&v.stateNode.containerInfo===_.containerInfo&&v.stateNode.implementation===_.implementation){n(x,v.sibling),v=s(v,_.children||[]),v.return=x,x=v;break e}else{n(x,v);break}else t(x,v);v=v.sibling}v=ja(_,x.mode,M),v.return=x,x=v}return u(x);case se:return K=_._init,qe(x,v,K(_._payload),M)}if(_n(_))return U(x,v,_,M);if(F(_))return H(x,v,_,M);fl(x,_)}return typeof _=="string"&&_!==""||typeof _=="number"?(_=""+_,v!==null&&v.tag===6?(n(x,v.sibling),v=s(v,_),v.return=x,x=v):(n(x,v),v=ka(_,x.mode,M),v.return=x,x=v),u(x)):n(x,v)}return qe}var Qs=ju(!0),Cu=ju(!1),pl=Ar(null),ml=null,Hs=null,Li=null;function Ii(){Li=Hs=ml=null}function Di(e){var t=pl.current;$e(pl),e._currentValue=t}function Oi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Vs(e,t){ml=e,Li=Hs=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&($t=!0),e.firstContext=null)}function mn(e){var t=e._currentValue;if(Li!==e)if(e={context:e,memoizedValue:t,next:null},Hs===null){if(ml===null)throw Error(p(308));Hs=e,ml.dependencies={lanes:0,firstContext:e}}else Hs=Hs.next=e;return t}var us=null;function zi(e){us===null?us=[e]:us.push(e)}function Nu(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,zi(t)):(n.next=s.next,s.next=n),t.interleaved=n,fr(e,r)}function fr(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Dr=!1;function $i(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Eu(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function pr(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Or(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(_e&2)!==0){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,fr(e,n)}return s=r.interleaved,s===null?(t.next=t,zi(r)):(t.next=s.next,s.next=t),r.interleaved=t,fr(e,n)}function hl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ws(e,n)}}function Pu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,l=null;if(n=n.firstBaseUpdate,n!==null){do{var u={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};l===null?s=l=u:l=l.next=u,n=n.next}while(n!==null);l===null?s=l=t:l=l.next=t}else s=l=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:l,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function gl(e,t,n,r){var s=e.updateQueue;Dr=!1;var l=s.firstBaseUpdate,u=s.lastBaseUpdate,f=s.shared.pending;if(f!==null){s.shared.pending=null;var m=f,S=m.next;m.next=null,u===null?l=S:u.next=S,u=m;var N=e.alternate;N!==null&&(N=N.updateQueue,f=N.lastBaseUpdate,f!==u&&(f===null?N.firstBaseUpdate=S:f.next=S,N.lastBaseUpdate=m))}if(l!==null){var P=s.baseState;u=0,N=S=m=null,f=l;do{var j=f.lane,D=f.eventTime;if((r&j)===j){N!==null&&(N=N.next={eventTime:D,lane:0,tag:f.tag,payload:f.payload,callback:f.callback,next:null});e:{var U=e,H=f;switch(j=t,D=n,H.tag){case 1:if(U=H.payload,typeof U=="function"){P=U.call(D,P,j);break e}P=U;break e;case 3:U.flags=U.flags&-65537|128;case 0:if(U=H.payload,j=typeof U=="function"?U.call(D,P,j):U,j==null)break e;P=A({},P,j);break e;case 2:Dr=!0}}f.callback!==null&&f.lane!==0&&(e.flags|=64,j=s.effects,j===null?s.effects=[f]:j.push(f))}else D={eventTime:D,lane:j,tag:f.tag,payload:f.payload,callback:f.callback,next:null},N===null?(S=N=D,m=P):N=N.next=D,u|=j;if(f=f.next,f===null){if(f=s.shared.pending,f===null)break;j=f,f=j.next,j.next=null,s.lastBaseUpdate=j,s.shared.pending=null}}while(!0);if(N===null&&(m=P),s.baseState=m,s.firstBaseUpdate=S,s.lastBaseUpdate=N,t=s.shared.interleaved,t!==null){s=t;do u|=s.lane,s=s.next;while(s!==t)}else l===null&&(s.shared.lanes=0);fs|=u,e.lanes=u,e.memoizedState=P}}function Tu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Qi.transition;Qi.transition={};try{e(!1),t()}finally{Q=n,Qi.transition=r}}function qu(){return hn().memoizedState}function Hd(e,t,n){var r=Ur(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ku(e))Ju(t,n);else if(n=Nu(e,t,n,r),n!==null){var s=Tt();An(n,e,r,s),Yu(n,t,r)}}function Vd(e,t,n){var r=Ur(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ku(e))Ju(t,s);else{var l=e.alternate;if(e.lanes===0&&(l===null||l.lanes===0)&&(l=t.lastRenderedReducer,l!==null))try{var u=t.lastRenderedState,f=l(u,n);if(s.hasEagerState=!0,s.eagerState=f,En(f,u)){var m=t.interleaved;m===null?(s.next=s,zi(t)):(s.next=m.next,m.next=s),t.interleaved=s;return}}catch{}n=Nu(e,t,s,r),n!==null&&(s=Tt(),An(n,e,r,s),Yu(n,t,r))}}function Ku(e){var t=e.alternate;return e===Be||t!==null&&t===Be}function Ju(e,t){Co=xl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Yu(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ws(e,n)}}var wl={readContext:mn,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},Wd={readContext:mn,useCallback:function(e,t){return Yn().memoizedState=[e,t===void 0?null:t],e},useContext:mn,useEffect:Uu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,_l(4194308,4,Qu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return _l(4194308,4,e,t)},useInsertionEffect:function(e,t){return _l(4,2,e,t)},useMemo:function(e,t){var n=Yn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Yn();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Hd.bind(null,Be,e),[r.memoizedState,e]},useRef:function(e){var t=Yn();return e={current:e},t.memoizedState=e},useState:$u,useDebugValue:Ji,useDeferredValue:function(e){return Yn().memoizedState=e},useTransition:function(){var e=$u(!1),t=e[0];return e=Qd.bind(null,e[1]),Yn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Be,s=Yn();if(Fe){if(n===void 0)throw Error(p(407));n=n()}else{if(n=t(),it===null)throw Error(p(349));(ds&30)!==0||Lu(r,t,n)}s.memoizedState=n;var l={value:n,getSnapshot:t};return s.queue=l,Uu(Du.bind(null,r,l,e),[e]),r.flags|=2048,Po(9,Iu.bind(null,r,l,n,t),void 0,null),n},useId:function(){var e=Yn(),t=it.identifierPrefix;if(Fe){var n=dr,r=cr;n=(r&~(1<<32-Wt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=No++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=u.createElement(n,{is:r.is}):(e=u.createElement(n),n==="select"&&(u=e,r.multiple?u.multiple=!0:r.size&&(u.size=r.size))):e=u.createElementNS(e,n),e[Kn]=t,e[xo]=r,vc(e,t,!1,!1),t.stateNode=e;e:{switch(u=On(n,r),n){case"dialog":ze("cancel",e),ze("close",e),s=r;break;case"iframe":case"object":case"embed":ze("load",e),s=r;break;case"video":case"audio":for(s=0;sJs&&(t.flags|=128,r=!0,To(l,!1),t.lanes=4194304)}else{if(!r)if(e=vl(u),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),To(l,!0),l.tail===null&&l.tailMode==="hidden"&&!u.alternate&&!Fe)return St(t),null}else 2*De()-l.renderingStartTime>Js&&n!==1073741824&&(t.flags|=128,r=!0,To(l,!1),t.lanes=4194304);l.isBackwards?(u.sibling=t.child,t.child=u):(n=l.last,n!==null?n.sibling=u:t.child=u,l.last=u)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=De(),t.sibling=null,n=be.current,Ie(be,r?n&1|2:n&1),t):(St(t),null);case 22:case 23:return _a(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(rn&1073741824)!==0&&(St(t),t.subtreeFlags&6&&(t.flags|=8192)):St(t),null;case 24:return null;case 25:return null}throw Error(p(156,t.tag))}function ef(e,t){switch(Ti(t),t.tag){case 1:return zt(t.type)&&ll(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ws(),$e(Ot),$e(xt),Bi(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Ui(t),null;case 13:if($e(be),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(p(340));Bs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return $e(be),null;case 4:return Ws(),null;case 10:return Di(t.type._context),null;case 22:case 23:return _a(),null;case 24:return null;default:return null}}var Nl=!1,wt=!1,tf=typeof WeakSet=="function"?WeakSet:Set,O=null;function qs(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){We(e,t,r)}else n.current=null}function aa(e,t,n){try{n()}catch(r){We(e,t,r)}}var _c=!1;function nf(e,t){if(_i=Nr,e=Xa(),fi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,l=r.focusNode;r=r.focusOffset;try{n.nodeType,l.nodeType}catch{n=null;break e}var u=0,f=-1,m=-1,S=0,N=0,P=e,j=null;t:for(;;){for(var D;P!==n||s!==0&&P.nodeType!==3||(f=u+s),P!==l||r!==0&&P.nodeType!==3||(m=u+r),P.nodeType===3&&(u+=P.nodeValue.length),(D=P.firstChild)!==null;)j=P,P=D;for(;;){if(P===e)break t;if(j===n&&++S===s&&(f=u),j===l&&++N===r&&(m=u),(D=P.nextSibling)!==null)break;P=j,j=P.parentNode}P=D}n=f===-1||m===-1?null:{start:f,end:m}}else n=null}n=n||{start:0,end:0}}else n=null;for(Si={focusedElem:e,selectionRange:n},Nr=!1,O=t;O!==null;)if(t=O,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,O=e;else for(;O!==null;){t=O;try{var U=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(U!==null){var H=U.memoizedProps,qe=U.memoizedState,x=t.stateNode,v=x.getSnapshotBeforeUpdate(t.elementType===t.type?H:Tn(t.type,H),qe);x.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var _=t.stateNode.containerInfo;_.nodeType===1?_.textContent="":_.nodeType===9&&_.documentElement&&_.removeChild(_.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(p(163))}}catch(M){We(t,t.return,M)}if(e=t.sibling,e!==null){e.return=t.return,O=e;break}O=t.return}return U=_c,_c=!1,U}function Mo(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var l=s.destroy;s.destroy=void 0,l!==void 0&&aa(t,n,l)}s=s.next}while(s!==r)}}function El(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ua(e){var t=e.ref;if(t!==null){var n=e.stateNode;e.tag,e=n,typeof t=="function"?t(e):t.current=e}}function Sc(e){var t=e.alternate;t!==null&&(e.alternate=null,Sc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Kn],delete t[xo],delete t[Ci],delete t[$d],delete t[Fd])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function wc(e){return e.tag===5||e.tag===3||e.tag===4}function kc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||wc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ca(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=sl));else if(r!==4&&(e=e.child,e!==null))for(ca(e,t,n),e=e.sibling;e!==null;)ca(e,t,n),e=e.sibling}function da(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(da(e,t,n),e=e.sibling;e!==null;)da(e,t,n),e=e.sibling}var pt=null,Mn=!1;function zr(e,t,n){for(n=n.child;n!==null;)jc(e,t,n),n=n.sibling}function jc(e,t,n){if(an&&typeof an.onCommitFiberUnmount=="function")try{an.onCommitFiberUnmount(Yr,n)}catch{}switch(n.tag){case 5:wt||qs(n,t);case 6:var r=pt,s=Mn;pt=null,zr(e,t,n),pt=r,Mn=s,pt!==null&&(Mn?(e=pt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):pt.removeChild(n.stateNode));break;case 18:pt!==null&&(Mn?(e=pt,n=n.stateNode,e.nodeType===8?ji(e.parentNode,n):e.nodeType===1&&ji(e,n),Et(e)):ji(pt,n.stateNode));break;case 4:r=pt,s=Mn,pt=n.stateNode.containerInfo,Mn=!0,zr(e,t,n),pt=r,Mn=s;break;case 0:case 11:case 14:case 15:if(!wt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var l=s,u=l.destroy;l=l.tag,u!==void 0&&((l&2)!==0||(l&4)!==0)&&aa(n,t,u),s=s.next}while(s!==r)}zr(e,t,n);break;case 1:if(!wt&&(qs(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(f){We(n,t,f)}zr(e,t,n);break;case 21:zr(e,t,n);break;case 22:n.mode&1?(wt=(r=wt)||n.memoizedState!==null,zr(e,t,n),wt=r):zr(e,t,n);break;default:zr(e,t,n)}}function Cc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new tf),t.forEach(function(r){var s=ff.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Rn(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=u),r&=~l}if(r=s,r=De()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*sf(r/1960))-r,10e?16:e,Fr===null)var r=!1;else{if(e=Fr,Fr=null,Al=0,(_e&6)!==0)throw Error(p(331));var s=_e;for(_e|=4,O=e.current;O!==null;){var l=O,u=l.child;if((O.flags&16)!==0){var f=l.deletions;if(f!==null){for(var m=0;mDe()-ma?ms(e,0):pa|=n),Ut(e,t)}function $c(e,t){t===0&&((e.mode&1)===0?t=1:(t=kn,kn<<=1,(kn&130023424)===0&&(kn=4194304)));var n=Tt();e=fr(e,t),e!==null&&(kr(e,t,n),Ut(e,n))}function df(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),$c(e,n)}function ff(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(p(314))}r!==null&&r.delete(t),$c(e,n)}var Fc;Fc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ot.current)$t=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return $t=!1,Xd(e,t,n);$t=(e.flags&131072)!==0}else $t=!1,Fe&&(t.flags&1048576)!==0&&yu(t,cl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Cl(e,t),e=t.pendingProps;var s=Fs(t,xt.current);Vs(t,n),s=Vi(null,t,r,e,s,n);var l=Wi();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,zt(r)?(l=!0,il(t)):l=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,$i(t),s.updater=kl,t.stateNode=s,s._reactInternals=t,Xi(t,r,e,n),t=na(null,t,r,!0,l,n)):(t.tag=0,Fe&&l&&Pi(t),Pt(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Cl(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=mf(r),e=Tn(r,e),s){case 0:t=ta(null,t,r,e,n);break e;case 1:t=dc(null,t,r,e,n);break e;case 11:t=lc(null,t,r,e,n);break e;case 14:t=ic(null,t,r,Tn(r.type,e),n);break e}throw Error(p(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Tn(r,s),ta(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Tn(r,s),dc(e,t,r,s,n);case 3:e:{if(fc(t),e===null)throw Error(p(387));r=t.pendingProps,l=t.memoizedState,s=l.element,Eu(e,t),gl(t,r,null,n);var u=t.memoizedState;if(r=u.element,l.isDehydrated)if(l={element:r,isDehydrated:!1,cache:u.cache,pendingSuspenseBoundaries:u.pendingSuspenseBoundaries,transitions:u.transitions},t.updateQueue.baseState=l,t.memoizedState=l,t.flags&256){s=Gs(Error(p(423)),t),t=pc(e,t,r,n,s);break e}else if(r!==s){s=Gs(Error(p(424)),t),t=pc(e,t,r,n,s);break e}else for(nn=Rr(t.stateNode.containerInfo.firstChild),tn=t,Fe=!0,Pn=null,n=Cu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Bs(),r===s){t=mr(e,t,n);break e}Pt(e,t,r,n)}t=t.child}return t;case 5:return Mu(t),e===null&&Ri(t),r=t.type,s=t.pendingProps,l=e!==null?e.memoizedProps:null,u=s.children,wi(r,s)?u=null:l!==null&&wi(r,l)&&(t.flags|=32),cc(e,t),Pt(e,t,u,n),t.child;case 6:return e===null&&Ri(t),null;case 13:return mc(e,t,n);case 4:return Fi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Qs(t,null,r,n):Pt(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Tn(r,s),lc(e,t,r,s,n);case 7:return Pt(e,t,t.pendingProps,n),t.child;case 8:return Pt(e,t,t.pendingProps.children,n),t.child;case 12:return Pt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,l=t.memoizedProps,u=s.value,Ie(pl,r._currentValue),r._currentValue=u,l!==null)if(En(l.value,u)){if(l.children===s.children&&!Ot.current){t=mr(e,t,n);break e}}else for(l=t.child,l!==null&&(l.return=t);l!==null;){var f=l.dependencies;if(f!==null){u=l.child;for(var m=f.firstContext;m!==null;){if(m.context===r){if(l.tag===1){m=pr(-1,n&-n),m.tag=2;var S=l.updateQueue;if(S!==null){S=S.shared;var N=S.pending;N===null?m.next=m:(m.next=N.next,N.next=m),S.pending=m}}l.lanes|=n,m=l.alternate,m!==null&&(m.lanes|=n),Oi(l.return,n,t),f.lanes|=n;break}m=m.next}}else if(l.tag===10)u=l.type===t.type?null:l.child;else if(l.tag===18){if(u=l.return,u===null)throw Error(p(341));u.lanes|=n,f=u.alternate,f!==null&&(f.lanes|=n),Oi(u,n,t),u=l.sibling}else u=l.child;if(u!==null)u.return=l;else for(u=l;u!==null;){if(u===t){u=null;break}if(l=u.sibling,l!==null){l.return=u.return,u=l;break}u=u.return}l=u}Pt(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Vs(t,n),s=mn(s),r=r(s),t.flags|=1,Pt(e,t,r,n),t.child;case 14:return r=t.type,s=Tn(r,t.pendingProps),s=Tn(r.type,s),ic(e,t,r,s,n);case 15:return ac(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Tn(r,s),Cl(e,t),t.tag=1,zt(r)?(e=!0,il(t)):e=!1,Vs(t,n),Zu(t,r,s),Xi(t,r,s,n),na(null,t,r,!0,e,n);case 19:return gc(e,t,n);case 22:return uc(e,t,n)}throw Error(p(156,t.tag))};function Uc(e,t){return Vt(e,t)}function pf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vn(e,t,n,r){return new pf(e,t,n,r)}function wa(e){return e=e.prototype,!(!e||!e.isReactComponent)}function mf(e){if(typeof e=="function")return wa(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ct)return 11;if(e===Ge)return 14}return 2}function Br(e,t){var n=e.alternate;return n===null?(n=vn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ol(e,t,n,r,s,l){var u=2;if(r=e,typeof e=="function")wa(e)&&(u=1);else if(typeof e=="string")u=5;else e:switch(e){case je:return gs(n.children,s,l,t);case Ue:u=8,s|=8;break;case ht:return e=vn(12,n,t,s|2),e.elementType=ht,e.lanes=l,e;case b:return e=vn(13,n,t,s),e.elementType=b,e.lanes=l,e;case Re:return e=vn(19,n,t,s),e.elementType=Re,e.lanes=l,e;case te:return zl(n,s,l,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ut:u=10;break e;case Bt:u=9;break e;case ct:u=11;break e;case Ge:u=14;break e;case se:u=16,r=null;break e}throw Error(p(130,e==null?e:typeof e,""))}return t=vn(u,n,t,s),t.elementType=e,t.type=r,t.lanes=l,t}function gs(e,t,n,r){return e=vn(7,e,r,t),e.lanes=n,e}function zl(e,t,n,r){return e=vn(22,e,r,t),e.elementType=te,e.lanes=n,e.stateNode={isHidden:!1},e}function ka(e,t,n){return e=vn(6,e,null,t),e.lanes=n,e}function ja(e,t,n){return t=vn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function hf(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Qn(0),this.expirationTimes=Qn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qn(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Ca(e,t,n,r,s,l,u,f,m){return e=new hf(e,t,n,f,m),t===1?(t=1,l===!0&&(t|=8)):t=0,l=vn(3,null,null,t),e.current=l,l.stateNode=e,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},$i(l),e}function gf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(h){console.error(h)}}return a(),Ra.exports=Pf(),Ra.exports}var ed;function Mf(){if(ed)return Hl;ed=1;var a=Tf();return Hl.createRoot=a.createRoot,Hl.hydrateRoot=a.hydrateRoot,Hl}var Rf=Mf();const Af=vd(Rf),Lf="/api";async function ve(a,h){const p=await fetch(`${Lf}${a}`,{...h,headers:{"Content-Type":"application/json",...h?.headers??{}}}),T=await p.json();if(!p.ok){const E=T.error?.message??"Ошибка запроса";throw new Error(E)}return T}const Pe={async loadSharedConnectionConfig(){return ve("/llm/shared-connection")},async saveSharedConnectionConfig(a){return ve("/llm/shared-connection",{method:"POST",body:JSON.stringify({llmProvider:a.llmProvider,model:a.model,baseUrl:a.baseUrl,temperature:a.temperature,maxOutputTokens:a.maxOutputTokens})})},async listModels(a){return ve("/llm/models",{method:"POST",body:JSON.stringify({llmProvider:a.llmProvider,apiKey:a.apiKey,model:a.model,baseUrl:a.baseUrl})})},async testConnection(a){return ve("/llm/test-connection",{method:"POST",body:JSON.stringify({llmProvider:a.llmProvider,apiKey:a.apiKey,model:a.model,baseUrl:a.baseUrl})})},async normalize(a){return ve("/normalize",{method:"POST",body:JSON.stringify({llmProvider:a.connection.llmProvider,apiKey:a.connection.apiKey,model:a.connection.model,baseUrl:a.connection.baseUrl,temperature:a.connection.temperature,maxOutputTokens:a.connection.maxOutputTokens,promptVersion:a.promptVersion,systemPrompt:a.prompts.systemPrompt,developerPrompt:a.prompts.developerPrompt,domainPrompt:a.prompts.domainPrompt,fewShotExamples:a.prompts.fewShotExamples,userQuestion:a.query.userQuestion,context:{period_hint:a.query.periodHint??"",business_context:a.query.businessContext??"",expected_route:a.query.expectedRoute??""},saveAsTestCase:!!a.saveAsTestCase,useMock:!!a.useMock})})},async loadHistory(){return ve("/history")},async loadTrace(a){return ve(`/history/${a}`)},async loadPresets(){return ve("/presets")},async savePreset(a){return ve("/presets/save",{method:"POST",body:JSON.stringify(a)})},async runEval(a){return ve("/eval/run",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:a.connection.llmProvider,apiKey:a.connection.apiKey,model:a.connection.model,baseUrl:a.connection.baseUrl,temperature:a.connection.temperature,maxOutputTokens:a.connection.maxOutputTokens,promptVersion:a.promptVersion,systemPrompt:a.prompts.systemPrompt,developerPrompt:a.prompts.developerPrompt,domainPrompt:a.prompts.domainPrompt,fewShotExamples:a.prompts.fewShotExamples},caseIds:a.caseIds,useMock:!!a.useMock,mode:a.mode??"standard",caseSetFile:a.caseSetFile,rawQuestions:a.rawQuestions,eval_target:a.evalTarget,compare_with_report_file:a.compareWithReportFile,analysis_date:a.analysisDate})})},async startEvalRunAsync(a){return ve("/eval/run-async/start",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:a.connection.llmProvider,apiKey:a.connection.apiKey,model:a.connection.model,baseUrl:a.connection.baseUrl,temperature:a.connection.temperature,maxOutputTokens:a.connection.maxOutputTokens,promptVersion:a.promptVersion,systemPrompt:a.prompts.systemPrompt,developerPrompt:a.prompts.developerPrompt,domainPrompt:a.prompts.domainPrompt,fewShotExamples:a.prompts.fewShotExamples},caseIds:a.caseIds,useMock:!!a.useMock,mode:a.mode??"standard",caseSetFile:a.caseSetFile,rawQuestions:a.rawQuestions,eval_target:a.evalTarget,compare_with_report_file:a.compareWithReportFile,questions:a.questions,scenarioQuestions:a.scenarioQuestions,scenarioTitle:a.scenarioTitle,analysis_date:a.analysisDate})})},async loadEvalRunAsyncStatus(a){return ve(`/eval/run-async/${encodeURIComponent(a)}`)},async startRun(){return ve("/accounting-agent/v1/runs/start",{method:"POST",body:JSON.stringify({initiator:"ndc_operator",source:"gui"})})},async finishRun(a){return ve("/accounting-agent/v1/runs/finish",{method:"POST",body:JSON.stringify({runId:a,status:"DONE",source:"gui",reason:"Остановлено оператором из GUI"})})},async listRuns(){return ve("/accounting-agent/v1/runs")},async listResults(){return ve("/accounting-agent/v1/results")},async runTrace(a){return ve(`/accounting-agent/v1/trace/run/${a}`)},async sendAssistantMessage(a){return ve("/assistant/message",{method:"POST",body:JSON.stringify({session_id:a.sessionId??"",mode:"assistant",message:a.userMessage,user_message:a.userMessage,llmProvider:a.connection.llmProvider,apiKey:a.connection.apiKey,model:a.connection.model,baseUrl:a.connection.baseUrl,temperature:a.connection.temperature,maxOutputTokens:a.connection.maxOutputTokens,promptVersion:a.promptVersion??"address_query_runtime_v1",systemPrompt:a.prompts.systemPrompt,developerPrompt:a.prompts.developerPrompt,domainPrompt:a.prompts.domainPrompt,fewShotExamples:a.prompts.fewShotExamples,context:{period_hint:a.context?.periodHint??"",business_context:a.context?.businessContext??""},useMock:!!a.useMock})})},async loadAssistantSession(a){return ve(`/assistant/session/${a}`)},async saveAutoRunAssistantSession(a){return ve("/autoruns/autogen/save-assistant-session",{method:"POST",body:JSON.stringify(a)})},async loadAssistantAnnotations(a){const h=new URLSearchParams;a?.session_id&&h.set("session_id",a.session_id),typeof a?.limit=="number"&&h.set("limit",String(a.limit));const p=h.toString();return ve(`/assistant/annotations${p?`?${p}`:""}`)},async saveAssistantAnnotation(a){return ve("/assistant/annotations",{method:"POST",body:JSON.stringify(a)})},async loadAutoRunsHistory(a){const h=new URLSearchParams;a?.from&&h.set("from",a.from),a?.to&&h.set("to",a.to),a?.target&&h.set("target",a.target),a?.mode&&h.set("mode",a.mode),a?.use_mock&&h.set("use_mock",a.use_mock),a?.prompt_contains&&h.set("prompt_contains",a.prompt_contains),typeof a?.limit=="number"&&h.set("limit",String(a.limit)),typeof a?.scan_limit=="number"&&h.set("scan_limit",String(a.scan_limit));const p=h.toString();return ve(`/autoruns/history${p?`?${p}`:""}`)},async loadAutoRunDetail(a){return ve(`/autoruns/history/${encodeURIComponent(a)}`)},async loadAutoRunCaseDialog(a,h){return ve(`/autoruns/history/${encodeURIComponent(a)}/case/${encodeURIComponent(h)}/dialog`)},async loadAutoRunAnnotations(a){const h=new URLSearchParams;a?.run_id&&h.set("run_id",a.run_id),a?.case_id&&h.set("case_id",a.case_id),typeof a?.min_rating=="number"&&h.set("min_rating",String(a.min_rating)),a?.manual_case_decision&&h.set("manual_case_decision",a.manual_case_decision),typeof a?.limit=="number"&&h.set("limit",String(a.limit));const p=h.toString();return ve(`/autoruns/annotations${p?`?${p}`:""}`)},async saveAutoRunAnnotation(a){return ve("/autoruns/annotations",{method:"POST",body:JSON.stringify(a)})},async updateAutoRunAnnotation(a){return ve(`/autoruns/annotations/${encodeURIComponent(a.annotation_id)}`,{method:"PATCH",body:JSON.stringify({resolved:a.resolved,resolved_by:a.resolved_by})})},async loadAutoRunPostAnalysis(a){const h=new URLSearchParams;a?.run_id&&h.set("run_id",a.run_id),typeof a?.limit_per_queue=="number"&&h.set("limit_per_queue",String(a.limit_per_queue)),typeof a?.annotation_limit=="number"&&h.set("annotation_limit",String(a.annotation_limit)),typeof a?.scan_limit=="number"&&h.set("scan_limit",String(a.scan_limit)),a?.from&&h.set("from",a.from),a?.to&&h.set("to",a.to),a?.target&&h.set("target",a.target),a?.mode&&h.set("mode",a.mode),a?.use_mock&&h.set("use_mock",a.use_mock),a?.prompt_contains&&h.set("prompt_contains",a.prompt_contains);const p=h.toString();return ve(`/autoruns/post-analysis${p?`?${p}`:""}`)},async loadAutoRunAutogenHistory(a){const h=new URLSearchParams;a?.mode&&h.set("mode",a.mode),typeof a?.limit=="number"&&h.set("limit",String(a.limit));const p=h.toString();return ve(`/autoruns/autogen/history${p?`?${p}`:""}`)},async loadAutoRunAutogenPersonalityCatalog(){return ve("/autoruns/autogen/personality-catalog")},async updateAutoRunAutogenQuestions(a){return ve(`/autoruns/autogen/history/${encodeURIComponent(a.generation_id)}/questions`,{method:"PATCH",body:JSON.stringify({questions:a.questions})})},async deleteAutoRunAutogenHistoryRecord(a){return ve(`/autoruns/autogen/history/${encodeURIComponent(a)}`,{method:"DELETE"})},async generateAutoRunQuestions(a){return ve("/autoruns/autogen/generate",{method:"POST",body:JSON.stringify(a)})}},If=/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json|debug_payload|technical_breakdown)\b/i,Df=[/\b(?:debug_payload_json|technical_breakdown_json)\b/i,/\b(?:route_summary|semantic_profile|domain_scope|relation_patterns|account_scope)\b/i,/\b(?:coverage_report|retrieval_status|problem_unit_state|candidate_evidence)\b/i,/\b(?:graph_domain_scope|graph_runtime|selection_reason|why_included)\b/i];function Of(a){try{return JSON.stringify(a,null,2)}catch{return String(a)}}function zf(a){const h=String(a??""),p=h.match(If);return(p?h.slice(0,p.index):h).replace(/###\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)[\s\S]*?(?:```[\s\S]*?```|$)/gi,"").replace(/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)\b[\s\S]*$/gi,"").split(/\r?\n/g).map(B=>B.trimEnd()).filter(B=>B.trim().length>0).filter(B=>!Df.some(ae=>ae.test(B))).join(` +`).trim()}function $f(a,h,p="default"){const T=p==="technical",E=[];E.push("# Assistant conversation export"),E.push(`session_id: ${a||"n/a"}`),E.push(`export_mode: ${p}`),E.push(`exported_at: ${new Date().toISOString()}`),E.push("");for(let I=0;I{E.length!==0&&(T.push(E.join(` +`)),E=[])};for(const B of p){const ae=B.trimEnd(),re=ae.trim();if(!re){I();continue}const z=/^Блок\s+\d+\./i.test(re),Z=/^\d+\.\s/.test(re);(z||Z)&&E.length>0&&I(),E.push(ae)}return I(),T.length>0?T:[a]}function Vf(a,h){const p=[],T=/\*\*(.+?)\*\*/g;let E=0,I=0,B;for(;(B=T.exec(a))!==null;)B.index>E&&(p.push(o.jsx("span",{children:a.slice(E,B.index)},`${h}-t-${I}`)),I+=1),p.push(o.jsx("strong",{children:B[1]},`${h}-b-${I}`)),I+=1,E=T.lastIndex;return E0?p:[o.jsx("span",{children:a},`${h}-raw`)]}function Wf(a){const h=a.trimStart();return/^Блок\s+\d+\./i.test(h)?"assistant-msg-line heading":/^\d+\.\s/.test(h)?"assistant-msg-line numbered":/^-\s/.test(h)?"assistant-msg-line bullet":"assistant-msg-line"}function Gf(a,h=40){const p=a.replace(/\s+/g," ").trim();if(p.length<=h)return p;const T=p.split(" ").slice(0,3).join(" ").trim();return T.length>=10&&T.length<=h?`${T}…`:`${p.slice(0,h-1).trimEnd()}…`}function xd(a){return a.replace(/\*\*(.+?)\*\*/g,"$1").replace(/^\d+\.\s*/,"").trim()}function qf(a){const h=a.replace(/\r\n?/g,` +`).split(` +`).map(E=>E.trim()).find(Boolean),p=xd(h??"");return(p.split("|")[0]?.trim()??p).replace(/\s+/g," ").trim()}function Kf(a){const h=a.replace(/\r\n?/g,` +`).split(` +`).map(T=>T.trim()).find(Boolean);return!h||!/^\d+\.\s/.test(h)?!1:xd(h).includes("|")}function Jf(a,h){const p=h.replace(/\r\n?/g,` +`).replace(/\*\*(.+?)\*\*/g,"$1").split(` +`).map((E,I)=>{const B=E.trim();return I===0?B.replace(/^\d+\.\s*/,""):B}).filter(Boolean).join(" ").replace(/\s+/g," ").trim();if(!p)return null;const T=qf(h)||p;return{message_id:a.message_id,source_text:p,anchor_text:T,preview_text:Gf(T)}}function Yf(a,h,p,T){return Hf(a.text).map((I,B)=>{const ae=I.split(` +`),re=a.role==="assistant"&&Kf(I),z=re?Jf(a,I):null,Z=!!z&&h?.message_id===z?.message_id&&h?.source_text===z?.source_text,ee=ae.map((ne,Te)=>o.jsx("p",{className:Wf(ne),children:Vf(ne,`line-${B}-${Te}`)},`line-${B}-${Te}`));return!re||!z?o.jsx("div",{className:"assistant-msg-block",children:ee},`block-${B}`):o.jsx("div",{className:Z?"assistant-msg-block selectable active":"assistant-msg-block selectable",role:"button",tabIndex:0,onClick:()=>{if(Z){T();return}p(z)},onKeyDown:ne=>{if(!(ne.key!=="Enter"&&ne.key!==" ")){if(ne.preventDefault(),Z){T();return}p(z)}},children:ee},`block-${B}`)})}function Xf({sessionId:a,conversation:h,inputValue:p,onInputChange:T,selectedContextChip:E,onSelectContextChip:I,onClearContextChip:B,useMock:ae,onUseMockChange:re,onSend:z,onClear:Z,onSaveSession:ee,busy:ne,saveBusy:Te=!1,saveDisabled:de=!1,statusText:fe,errorMessage:he,showSaveAction:Qe=!1,showCommentAction:Ke=!1,onCommentAssistantMessage:He,isAssistantMessageCommented:Me,canCommentAssistantMessage:$}){const ie=g.useRef(null),je=g.useRef(!0),Ue=g.useRef(null),[ht,ut]=g.useState("idle"),[Bt,ct]=g.useState("чат");function b(se=!1){ie.current&&(se&&(je.current=!0),ie.current.scrollTop=ie.current.scrollHeight)}g.useEffect(()=>{je.current&&b()},[h]),g.useEffect(()=>()=>{Ue.current!==null&&window.clearTimeout(Ue.current)},[]);async function Re(se){if(h.length===0)return;const te=$f(a,h,se),R=await bf(te);ct(se==="technical"?"тех":"чат"),ut(R?"success":"error"),Ue.current!==null&&window.clearTimeout(Ue.current),Ue.current=window.setTimeout(()=>{ut("idle")},2200)}function Ge(){if(!ie.current)return;const se=ie.current,te=se.scrollHeight-se.scrollTop-se.clientHeight;je.current=te<16}return o.jsx(Zl,{className:"assistant-panel-frame",title:"Режим ассистента",children:o.jsxs("div",{className:"assistant-live-shell",children:[o.jsxs("div",{className:"assistant-toolbar",children:[o.jsxs("div",{className:"assistant-toolbar-actions",children:[o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{Re("default")},disabled:h.length===0,title:"Экспорт только user-facing чата",children:"Скопировать чат"}),o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{Re("technical")},disabled:h.length===0,title:"Технический экспорт с debug payload",children:"Скопировать техчат"}),Qe?o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>ee?.(),disabled:Te||de,children:Te?"Сохраняю...":"Сохранить"}):null,o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>Z(),disabled:ne&&h.length===0,children:"Сбросить сессию"})]}),o.jsxs("div",{className:"assistant-toolbar-meta",children:[a?o.jsx("span",{className:"status-chip",children:`session: ${a}`}):null,o.jsxs("div",{className:"assistant-toolbar-meta-right",children:[fe?o.jsx("span",{className:"assistant-live-status",children:fe}):null,ht==="success"?o.jsxs("span",{className:"assistant-copy-feedback success",children:["Скопировано (",Bt,")"]}):null,ht==="error"?o.jsx("span",{className:"assistant-copy-feedback error",children:"Ошибка копирования"}):null]})]}),he?o.jsx("p",{className:"error-text assistant-toolbar-error",children:he}):null]}),o.jsx("div",{ref:ie,className:"assistant-chat-list",onScroll:Ge,children:h.map((se,te)=>{const R=se.role==="assistant"&&Ke&&typeof He=="function"&&(typeof $=="function"?$(se,te):!0),F=se.role==="assistant"&&typeof Me=="function"?Me(se,te):!1;return o.jsxs("article",{className:`assistant-msg ${se.role}`,children:[o.jsxs("header",{className:"assistant-msg-head",children:[o.jsxs("div",{className:"assistant-msg-head-main",children:[o.jsx("strong",{children:Ff(se.role)}),o.jsx("span",{children:Uf(se.created_at)})]}),se.role==="assistant"&&Ke?o.jsx("div",{className:"assistant-msg-head-actions",children:o.jsx("button",{type:"button",className:F?"autoruns-comment-icon assistant-comment-btn commented":"autoruns-comment-icon assistant-comment-btn",onClick:()=>He?.(se,te),disabled:!R,title:R?"Комментировать ответ ассистента":"Комментарий недоступен для этого сообщения","aria-label":R?"Комментировать ответ ассистента":"Комментарий недоступен для этого сообщения",children:o.jsx(Bf,{commented:F})})}):null]}),o.jsx("div",{className:"assistant-msg-body",children:Yf(se,E,I,B)}),se.role==="assistant"&&se.debug?o.jsxs("details",{className:"assistant-debug",children:[o.jsx("summary",{children:"Показать технический разбор"}),o.jsx(yd,{value:se.debug})]}):null]},se.message_id)})}),o.jsxs("div",{className:"assistant-compose",children:[E?o.jsxs("div",{className:"assistant-compose-context",children:[o.jsx("span",{className:"assistant-compose-context-label",children:"Выбранный объект"}),o.jsxs("div",{className:"assistant-compose-context-pill",title:E.source_text,children:[o.jsx("span",{className:"assistant-compose-context-pill-text",children:E.preview_text}),o.jsx("button",{type:"button",className:"assistant-compose-context-clear",onClick:B,"aria-label":"Убрать выбранный объект",title:"Убрать выбранный объект",children:"×"})]})]}):null,o.jsxs("label",{className:"full-width",children:["Сообщение",o.jsx("textarea",{className:"assistant-input-textarea",value:p,onChange:se=>T(se.target.value),rows:4,placeholder:E?"Продолжите вопрос по выбранному объекту...":"Введите вопрос к данным компании..."})]}),o.jsxs("div",{className:"button-row assistant-send-row",children:[o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:ae,onChange:se=>re(se.target.checked)}),"Mock-режим"]}),o.jsx("button",{type:"button",className:"assistant-send-btn",onClick:()=>{b(!0),z()},disabled:ne||!p.trim(),children:ne?"Выполняю...":"Отправить"})]})]})]})})}const Vl="http://127.0.0.1:1234/v1",td="https://api.openai.com/v1",Yl="qwen2.5-14b-instruct-1m",Ha="unsloth/qwen3-30b-a3b-instruct-2507",Zf=[{value:Yl,label:"Qwen2.5 14B Instruct 1M"},{value:Ha,label:"Qwen3 30B A3B Instruct 2507"}];function ep(a){return a.llmProvider!=="local"?"openai":a.model===Ha?"local_qwen3":a.model===Yl?"local_qwen25":"local_custom"}function tp(a,h){const p=new Map;if(h)for(const T of Zf)p.set(T.value,T);for(const T of a)p.has(T)||p.set(T,{value:T,label:T});return Array.from(p.values())}function np({value:a,modelOptions:h,modelsBusy:p,onChange:T,onReloadModels:E,onTestConnection:I,onSaveLocalConfig:B,lastStatus:ae,busy:re,embedded:z=!1}){const Z=a.llmProvider==="local",ee=ep(a),ne=tp(h,Z),Te=ne.some($=>$.value===a.model),[de,fe]=g.useState(String(a.temperature)),[he,Qe]=g.useState(String(a.maxOutputTokens));g.useEffect(()=>{fe(String(a.temperature))},[a.temperature]),g.useEffect(()=>{Qe(String(a.maxOutputTokens))},[a.maxOutputTokens]);const Ke=$=>{const ie=$.replace(",",".").trim();if(!ie){fe(String(a.temperature));return}const je=Number(ie);if(!Number.isFinite(je)){fe(String(a.temperature));return}T({...a,temperature:je}),fe(String(je))},He=$=>{const ie=$.trim();if(!ie){Qe(String(a.maxOutputTokens));return}const je=Number.parseInt(ie,10);if(!Number.isFinite(je)||je<=0){Qe(String(a.maxOutputTokens));return}T({...a,maxOutputTokens:je}),Qe(String(je))},Me=o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{children:["Provider",o.jsxs("select",{value:ee,onChange:$=>{const ie=$.target.value;if(ie==="openai"){T({...a,llmProvider:"openai",baseUrl:td});return}if(ie==="local_qwen25"){T({...a,llmProvider:"local",model:Yl,baseUrl:Vl});return}if(ie==="local_qwen3"){T({...a,llmProvider:"local",model:Ha,baseUrl:Vl});return}T({...a,llmProvider:"local",model:a.llmProvider==="local"?a.model:Yl,baseUrl:Vl})},children:[o.jsx("option",{value:"openai",children:"OpenAI (token)"}),o.jsx("option",{value:"local_qwen25",children:"Qwen2.5 14B Instruct 1M (Local LM Studio)"}),o.jsx("option",{value:"local_qwen3",children:"Qwen3 30B A3B Instruct 2507 (Local LM Studio)"}),o.jsx("option",{value:"local_custom",children:"Local custom (LM Studio / OpenAI-compatible)"})]})]}),o.jsxs("label",{children:["Model",o.jsxs("select",{value:Te?a.model:"__manual__",onChange:$=>{const ie=$.target.value;ie!=="__manual__"&&T({...a,model:ie})},children:[o.jsx("option",{value:"__manual__",children:"Manual input"}),ne.map($=>o.jsx("option",{value:$.value,children:$.label},$.value))]})]}),o.jsxs("label",{children:["Model ID (manual / current)",o.jsx("input",{value:a.model,onChange:$=>T({...a,model:$.target.value}),placeholder:"qwen2.5-14b-instruct-1m or unsloth/qwen3-30b-a3b-instruct-2507"})]}),Z?null:o.jsxs("label",{className:"full-width",children:["OpenAI API Key",o.jsx("input",{type:"password",value:a.apiKey,onChange:$=>T({...a,apiKey:$.target.value}),placeholder:"sk-..."})]}),o.jsxs("label",{className:Z?"full-width":void 0,children:[Z?"Local server base URL":"Base URL",o.jsx("input",{value:a.baseUrl,onChange:$=>T({...a,baseUrl:$.target.value}),placeholder:Z?Vl:td})]}),o.jsxs("label",{children:["Temperature",o.jsx("input",{type:"number",step:"0.1",value:de,onChange:$=>fe($.target.value),onBlur:$=>Ke($.target.value),onKeyDown:$=>{$.key==="Enter"&&Ke($.target.value)}})]}),o.jsxs("label",{children:["Max output tokens",o.jsx("input",{type:"number",value:he,onChange:$=>Qe($.target.value),onBlur:$=>He($.target.value),onKeyDown:$=>{$.key==="Enter"&&He($.target.value)}})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>B(),children:"Save local config"}),o.jsx("button",{type:"button",onClick:()=>E(),disabled:re||p,children:p?"Loading models...":"Load model list"}),o.jsx("button",{type:"button",onClick:()=>I(),disabled:re,children:re?"Checking...":"Test connection"})]})]});return z?o.jsxs("section",{className:"embedded-panel-section",children:[o.jsxs("div",{className:"embedded-panel-section-header",children:[o.jsxs("div",{children:[o.jsx("h4",{children:"LLM Connector"}),o.jsx("p",{children:"Switch between OpenAI cloud and local OpenAI-compatible server."})]}),o.jsx("span",{className:"status-chip",children:ae||"Status: not checked"})]}),Me]}):o.jsx(Zl,{title:"LLM Connector",subtitle:"Switch between OpenAI cloud and local OpenAI-compatible server.",actions:o.jsx("span",{className:"status-chip",children:ae||"Status: not checked"}),children:Me})}function rp({value:a,onChange:h,presets:p,selectedPresetId:T,onSelectPreset:E,onLoadPreset:I,onSavePreset:B,onResetDefaults:ae,onDiffPrevious:re,presetName:z,onPresetNameChange:Z,diffSummary:ee,embedded:ne=!1}){const Te=o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"prompt-manager-grid",children:[o.jsxs("label",{children:["Системный prompt",o.jsx("textarea",{value:a.systemPrompt,onChange:de=>h({...a,systemPrompt:de.target.value}),rows:6})]}),o.jsxs("label",{children:["Developer / Instruction prompt",o.jsx("textarea",{value:a.developerPrompt,onChange:de=>h({...a,developerPrompt:de.target.value}),rows:6})]}),o.jsxs("label",{children:["Domain prompt",o.jsx("textarea",{value:a.domainPrompt,onChange:de=>h({...a,domainPrompt:de.target.value}),rows:6})]}),o.jsxs("label",{children:["Schema notes",o.jsx("textarea",{value:a.schemaNotes,onChange:de=>h({...a,schemaNotes:de.target.value}),rows:6})]}),o.jsxs("label",{className:"full-width",children:["Few-shot examples",o.jsx("textarea",{value:a.fewShotExamples,onChange:de=>h({...a,fewShotExamples:de.target.value}),rows:8})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsxs("select",{value:T,onChange:de=>E(de.target.value),children:[o.jsx("option",{value:"",children:"Выберите preset..."}),p.map(de=>o.jsx("option",{value:de.id,children:de.name},de.id))]}),o.jsx("button",{type:"button",onClick:()=>I(),children:"Загрузить preset"}),o.jsx("input",{value:z,onChange:de=>Z(de.target.value),placeholder:"Имя для сохранения"}),o.jsx("button",{type:"button",onClick:()=>B(),children:"Сохранить preset"}),o.jsx("button",{type:"button",onClick:()=>re(),children:"Diff с предыдущим"}),o.jsx("button",{type:"button",onClick:()=>ae(),children:"Сбросить к default"})]}),ee?o.jsx("p",{className:"diff-summary",children:ee}):null]});return ne?o.jsxs("section",{className:"embedded-panel-section",children:[o.jsx("div",{className:"embedded-panel-section-header",children:o.jsxs("div",{children:[o.jsx("h4",{children:"Prompt Manager"}),o.jsx("p",{children:"Системный, developer и domain уровни управляются отдельно."})]})}),Te]}):o.jsx(Zl,{title:"Prompt Manager",subtitle:"Системный, developer и domain уровни управляются отдельно.",children:Te})}const Ia={fromLocal:"",toLocal:"",target:"all",mode:"all",useMock:"any",promptContains:"",limit:120},Wl="needs_dialog_policy_fix",kt="__all__",Xl="__live__:",nd="ndc_autoruns_ui_config_v1",rd="ndc-autoruns-save",Da=["Анализ запроса","Получение данных","Подготовка ответа"];function sp(a,h){const p=a.trim();if(!p)return"";if(!h)return p;const T=p.toLowerCase(),E=h.anchor_text.trim(),I=E.toLowerCase();return I&&T.includes(I)?p:`По выбранному объекту "${E}": ${p}`}const Ba=[{id:"general",label:"Общий контур",domain:"",defaultPrompt:"Генерируй реалистичные живые вопросы бухгалтера по 1С. Добавляй разговорные формулировки и опечатки, но сохраняй бизнес-смысл."}];function op(a=Ba){return a.reduce((h,p)=>(h[p.id]=p.defaultPrompt,h),{})}const sd={mode:"codex_creative",count:24,personalityId:"general",personalityPrompts:op(),persistToEvalCases:!0,generatedBy:"manual_reviewer"};function Oa(a){const h=String(a??"").trim();return/^\d{4}-\d{2}-\d{2}$/.test(h)?h:""}function od(a){const h=typeof a=="number"&&Number.isFinite(a)?Math.trunc(a):160;return Math.max(110,Math.min(520,h))}function lp(a){const h=a.getFullYear(),p=String(a.getMonth()+1).padStart(2,"0"),T=String(a.getDate()).padStart(2,"0"),E=String(a.getHours()).padStart(2,"0"),I=String(a.getMinutes()).padStart(2,"0");return`${h}-${p}-${T}T${E}:${I}`}function ld(){const a=new Date;return a.setDate(a.getDate()-14),lp(a)}function Gl(a){if(!a.trim())return;const h=Date.parse(a);if(Number.isFinite(h))return new Date(h).toISOString()}function yn(a){if(!a)return"нет данных";const h=Date.parse(a);return Number.isFinite(h)?new Date(h).toLocaleString("ru-RU"):a}function id(a){const h=typeof a.case_message_index=="number"?a.case_message_index:typeof a.message_index=="number"?a.message_index:null;if(h===null||h<0)return null;const p=Math.floor(h/2)+1,T=String(p).padStart(3,"0"),E=a.role==="assistant"?"ответ":"вопрос";return`${T} ${E}`}function za(a){return a==="saved_user_sessions"?"Пользовательские сессии":a}function _d(a){return a?a.context?.agent_run===!0||a.context?.saved_case_set_kind==="agent_semantic_scenario"?!0:typeof a.title=="string"&&a.title.trim().toUpperCase().startsWith("AGENT"):!1}function $a(a){const h=a.title??yn(a.created_at);return _d(a)&&!h.trim().toUpperCase().startsWith("AGENT")?`AGENT | ${h}`:h}function ip(a){const h=a[a.length-1];return`Ручная сессия ${yn(h?.created_at??new Date().toISOString())}`}function ap(a,h){return h<=0?0:Math.max(0,Math.min(100,Number((a/h*100).toFixed(1))))}function ql(a){return typeof a!="number"?"нет данных":`${a.toFixed(1)}%`}function up(a){return a==="assistant_stage1"?"assistant/s1":a==="assistant_stage2"?"assistant/s2":a==="assistant_p0"?"assistant/p0":a}function ad(a){return a==="up"?"Рост":a==="down"?"Регресс":"Без изменений"}function Fa(a){const h=Math.max(1,Math.min(5,Math.round(a)));return`${"●".repeat(h)}${"○".repeat(5-h)}`}function ud(a){return a.length===0?o.jsx("p",{className:"muted",children:"Покрытие доменов пока не сформировано."}):o.jsx("div",{className:"autoruns-coverage-list",children:a.map(h=>{const p=ap(h.closed_cases,h.total_cases);return o.jsxs("div",{className:"autoruns-coverage-item",children:[o.jsxs("div",{className:"autoruns-coverage-head",children:[o.jsx("strong",{children:h.domain}),o.jsxs("span",{children:[h.closed_cases,"/",h.total_cases," (",p,"%)"]})]}),o.jsx("div",{className:"autoruns-coverage-bar",children:o.jsx("div",{style:{width:`${p}%`}})})]},h.domain)})})}function Jl(a){return`${Xl}${a}`}function Xs(a){return a.startsWith(Xl)}function cd(a){return a.startsWith(Xl)?a.slice(Xl.length):""}function Sd(a){const h=a.report_summary?.run_timestamp??a.created_at,p=Math.max(0,a.total_cases-a.completed_cases);return{run_id:Jl(a.job_id),eval_target:a.eval_target,run_timestamp:h,mode:"single-pass-strict",llm_provider:null,model:null,use_mock:null,analysis_date:a.report_summary?.analysis_date??a.analysis_date??null,prompt_version:null,schema_version:null,suite_id:a.case_set_file,cases_total:a.total_cases,requests_total:null,report_path:`async_job:${a.job_id}`,score_index:a.report_summary?.score_index??null,blocking_failures:0,quality_failures:0,closed_cases:a.completed_cases,open_cases:p,domain_coverage:[{domain:"runtime",total_cases:a.total_cases,closed_cases:a.completed_cases}]}}function Oo(a,h){const p=Sd(a),T=a.cases.map(Z=>({case_id:Z.case_id,domain:null,query_class:null,status:Z.status==="completed"?"closed":Z.status==="failed"?"open":"unknown",score_index:null,trace_id:null,reply_type:null,session_id:`${a.run_id}-${Z.case_id}`,dialog_available:Z.messages.length>0,commented_count:0,latest_annotation_at:null,avg_rating:null,checks:null,metric_subscores:null})),I=h!==kt&&T.some(Z=>Z.case_id===h)?h:T.length>0?kt:"",B={ok:!0,run:p,coverage:{closed_cases:a.completed_cases,open_cases:Math.max(0,a.total_cases-a.completed_cases),domain_coverage:[{domain:"runtime",total_cases:a.total_cases,closed_cases:a.completed_cases}]},cases:T,annotations_summary:{total:0},report:a.report_summary?{run_id:a.report_summary.run_id,run_timestamp:a.report_summary.run_timestamp,score_index:a.report_summary.score_index,cases_total:a.report_summary.cases_total,analysis_date:a.report_summary.analysis_date??a.analysis_date??null}:{}},ae=[];let re=0;if(I===kt)for(const Z of a.cases)for(let ee=0;eeee.case_id===I)??null;for(let ee=0;ee<(Z?.messages.length??0);ee+=1){const ne=Z?.messages[ee];ne&&ae.push({...ne,message_index:ee,case_id:I,case_message_index:ee,commented:!1,annotation:null})}}const z={ok:!0,run_id:p.run_id,case_id:I,source:"assistant_session",session_id:I===kt?`${a.run_id}::__all__`:`${a.run_id}-${I}`,messages:ae,decomposition:[],assistant_mode:{status:a.status,completed_cases:a.completed_cases,total_cases:a.total_cases},annotations:[]};return{detail:B,dialog:z,caseId:I}}function cp({commented:a}){const h=a?"comment-icon-svg commented":"comment-icon-svg";return o.jsx("svg",{className:h,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:o.jsx("path",{d:"M5 6.5h14v9H11.5l-4.5 3v-3H5z"})})}function dd({resolved:a}){return o.jsxs("svg",{className:a?"resolve-icon-svg resolved":"resolve-icon-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),a?o.jsx("path",{d:"M5.1 8.2 7.2 10.3 11 6.5"}):null]})}function fd(){return o.jsxs("svg",{className:"autoruns-copy-icon-svg",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[o.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2.2"}),o.jsx("path",{d:"M15 7V5.8a1.8 1.8 0 0 0-1.8-1.8H5.8A1.8 1.8 0 0 0 4 5.8v7.4A1.8 1.8 0 0 0 5.8 15H7"})]})}function pd(){return o.jsxs("svg",{className:"autoruns-question-grip-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[o.jsx("circle",{cx:"4",cy:"4",r:"1"}),o.jsx("circle",{cx:"8",cy:"4",r:"1"}),o.jsx("circle",{cx:"12",cy:"4",r:"1"}),o.jsx("circle",{cx:"4",cy:"8",r:"1"}),o.jsx("circle",{cx:"8",cy:"8",r:"1"}),o.jsx("circle",{cx:"12",cy:"8",r:"1"}),o.jsx("circle",{cx:"4",cy:"12",r:"1"}),o.jsx("circle",{cx:"8",cy:"12",r:"1"}),o.jsx("circle",{cx:"12",cy:"12",r:"1"})]})}function dp({expanded:a}){return o.jsx("svg",{className:a?"autoruns-card-chevron-svg expanded":"autoruns-card-chevron-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:o.jsx("path",{d:"M3.5 6.2 8 10.4l4.5-4.2"})})}function fp(){return o.jsx("svg",{className:"autoruns-card-launch-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:o.jsx("path",{d:"M5 3.8 12 8l-7 4.2Z"})})}function Kl({expanded:a}){return o.jsx("svg",{className:a?"autoruns-group-chevron-svg expanded":"autoruns-group-chevron-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:o.jsx("path",{d:"M3.5 6.2 8 10.4l4.5-4.2"})})}function pp({connection:a,modelOptions:h,modelsBusy:p,connectionStatus:T,connectionBusy:E,onConnectionChange:I,onReloadModels:B,onSaveLocalConfig:ae,onTestConnection:re,prompts:z,onPromptsChange:Z,promptPresets:ee,selectedPresetId:ne,onSelectPreset:Te,onLoadPreset:de,onSavePreset:fe,onResetDefaults:he,onDiffPrevious:Qe,presetName:Ke,onPresetNameChange:He,diffSummary:Me,assistantPromptVersion:$,decompositionPromptVersion:ie,showSettingsMode:je,showAutoRunsMode:Ue,showAssistantMode:ht,showProgressMode:ut,showCommentsMode:Bt,onLog:ct}){const[b,Re]=g.useState({...Ia,fromLocal:ld()}),[Ge,se]=g.useState(""),[te,R]=g.useState(null),[F,A]=g.useState(null),[y,k]=g.useState(null),[oe,ue]=g.useState([]),[ce,ge]=g.useState("all"),[ye,xe]=g.useState(!1),[Se,dt]=g.useState(null),[sn,gr]=g.useState([]),[Ln,xn]=g.useState(""),[Ee,Qt]=g.useState(""),[st,gt]=g.useState(""),[jt,_n]=g.useState(Ba),[G,ft]=g.useState(sd),[vr,In]=g.useState([]),[Ve,Ct]=g.useState(""),[Mt,Dn]=g.useState(""),[me,Nt]=g.useState([]),[Je,vs]=g.useState(!1),[Ze,Zn]=g.useState(null),[yr,on]=g.useState(""),[On,Rt]=g.useState(null),[Sn,Ht]=g.useState(null),[Y,ln]=g.useState(null),[er,Hr]=g.useState(null),[Vr,Wr]=g.useState(!1),[xr,wn]=g.useState(!1),[zn,$n]=g.useState(!1),[Fn,Un]=g.useState(!1),[C,X]=g.useState(!1),[V,Ce]=g.useState(!1),[ot,zo]=g.useState(!1),[Gr,$o]=g.useState(!1),[bn,Zs]=g.useState(""),[eo,Ye]=g.useState(""),[et,ys]=g.useState(""),[Vt,xs]=g.useState([]),[qr,Kr]=g.useState([]),[De,to]=g.useState(""),[Jr,_s]=g.useState(null),[_r,ei]=g.useState(!1),[no,Yr]=g.useState(!1),[an,Xr]=g.useState(""),[Wt,tr]=g.useState(""),[ti,Sr]=g.useState(String(Ia.limit)),[Ss,kn]=g.useState(String(sd.count)),[nr,Zr]=g.useState(160),[wr,Fo]=g.useState(!0),[Bn,ro]=g.useState(!0),[Qn,kr]=g.useState(!0),[jr,ws]=g.useState(!0),[Q,Gt]=g.useState({open:!1,caseId:"",caseMessageIndex:-1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:Wl,annotationAuthor:"manual_reviewer",saving:!1,error:""}),[we,qt]=g.useState({open:!1,messageIndex:-1,rating:3,comment:"",annotationAuthor:"manual_reviewer",saving:!1,error:""}),[At,Hn]=g.useState({open:!1,title:"",saving:!1,error:""}),[Lt,rr]=g.useState({open:!1,generationId:"",questionIndex:-1,questionText:"",saving:!1,error:""}),[It,Kt]=g.useState({open:!1,generationId:"",title:"",saving:!1,error:""}),un=g.useRef(!1),Jt=g.useRef(null),Vn=g.useRef(null),Ae=G.mode==="saved_user_sessions",Yt=g.useMemo(()=>jt.find(i=>i.id===G.personalityId)??jt[0]??Ba[0],[G.personalityId,jt]),vt=g.useMemo(()=>vr.filter(i=>i.mode===G.mode),[vr,G.mode]),Oe=g.useMemo(()=>vt.find(i=>i.generation_id===Ve)??vt[0]??null,[Ve,vt]),Xt=g.useMemo(()=>ye?oe.filter(i=>!i.resolved):oe,[oe,ye]),Le=Xt.find(i=>i.annotation_id===Ln)??null,so=y?.messages.find(i=>i.message_index===Q.messageIndex)??null,ks=g.useMemo(()=>{if(!y||Q.messageIndex<0)return null;for(let i=Q.messageIndex-1;i>=0;i-=1){const c=y.messages[i];if(c?.role==="user")return c}return null},[Q.messageIndex,y]),es=g.useMemo(()=>{const i=new Map;for(const c of qr)c.message_id&&i.set(c.message_id,c);return i},[qr]),Uo=we.messageIndex>=0?Vt[we.messageIndex]??null:null,Cr=g.useMemo(()=>{if(we.messageIndex<0)return null;for(let i=we.messageIndex-1;i>=0;i-=1){const c=Vt[i];if(c?.role==="user")return c}return null},[we.messageIndex,Vt]),Et=g.useMemo(()=>{const i=Xt.map(d=>({source:"autorun",key:`autorun:${d.annotation_id}`,updated_at:d.updated_at,rating:d.rating,autorun:d,assistant:null})),c=qr.map(d=>({source:"assistant_live",key:`assistant:${d.annotation_id}`,updated_at:d.updated_at,rating:d.rating,autorun:null,assistant:d}));return[...i,...c].sort((d,w)=>Date.parse(w.updated_at)-Date.parse(d.updated_at))},[qr,Xt]),sr=g.useMemo(()=>{if(Et.length===0)return null;const i=Et.reduce((c,d)=>c+d.rating,0)/Et.length;return Number(i.toFixed(2))},[Et]),Nr=g.useMemo(()=>{const i=[...te?.items??[]];return Y&&i.unshift(Sd(Y)),Ee&&!i.some(c=>c.run_id===Ee)&&F?.run&&i.unshift(F.run),i},[Y,te?.items,F?.run,Ee]),q=g.useCallback(i=>{ct?.(`[autoruns] ${i}`)},[ct]),js=g.useCallback(async i=>{const c=String(i??"").trim();if(!c){Kr([]);return}try{const d=await Pe.loadAssistantAnnotations({session_id:c,limit:400});Kr(d.items??[])}catch(d){const w=d instanceof Error?d.message:String(d);q(`Assistant live annotations load error: ${w}`)}},[q]),Wn=g.useCallback(i=>{qt(c=>c.saving&&!i?.force?c:{open:!1,messageIndex:-1,rating:3,comment:"",annotationAuthor:"manual_reviewer",saving:!1,error:""})},[]),or=g.useCallback(i=>{Hn(c=>c.saving&&!i?.force?c:{open:!1,title:"",saving:!1,error:""})},[]),Er=g.useCallback(i=>{rr(c=>c.saving&&!i?.force?c:{open:!1,generationId:"",questionIndex:-1,questionText:"",saving:!1,error:""})},[]),ts=g.useCallback(i=>{Kt(c=>c.saving&&!i?.force?c:{open:!1,generationId:"",title:"",saving:!1,error:""})},[]),Zt=g.useCallback(async(i,c,d)=>{i.stopPropagation(),i.preventDefault();const w=String(c??"").trim();if(w)try{if(navigator?.clipboard?.writeText)await navigator.clipboard.writeText(w);else{const L=document.createElement("textarea");L.value=w,L.setAttribute("readonly","true"),L.style.position="fixed",L.style.opacity="0",document.body.appendChild(L),L.select(),document.execCommand("copy"),document.body.removeChild(L)}q(`${d} copied: ${w}`)}catch(L){const Ne=L instanceof Error?L.message:String(L);Ye(`Копирование ${d}: ${Ne}`),q(`copy ${d} error: ${Ne}`)}},[q]);function oo(){let i=0;Xr(Da[0]);const c=window.setInterval(()=>{i=Math.min(i+1,Da.length-1),Xr(Da[i])},650);return()=>window.clearInterval(c)}const Cs=g.useCallback(()=>{ys(""),xs([]),Kr([]),to(""),_s(null),Xr(""),tr(""),Wn({force:!0}),q("Live-чат ассистента в истории автопрогонов сброшен.")},[Wn,q]),bo=g.useCallback(async()=>{const i=sp(De,Jr);if(!i)return;Yr(!0),tr(""),to(""),xs(d=>[...d,{message_id:`autoruns-live-${Date.now()}`,session_id:et||"pending",role:"user",text:i,reply_type:null,created_at:new Date().toISOString(),trace_id:null,debug:null}]);const c=oo();try{const d=await Pe.sendAssistantMessage({connection:a,prompts:z,userMessage:i,sessionId:et||void 0,promptVersion:$,useMock:_r});ys(d.session_id),xs(d.conversation),await js(d.session_id),Xr("Ответ готов"),q(`Live-ответ ассистента получен: trace=${d.debug.trace_id}`)}catch(d){const w=d instanceof Error?d.message:String(d);tr(w),Xr("Ошибка ассистента"),q(`Live-чат ассистента: ошибка отправки сообщения: ${w}`)}finally{c(),Yr(!1)}},[De,Jr,et,_r,$,a,js,q,z]),Ns=g.useCallback(()=>{if(!et.trim()||Vt.length===0){tr("Сначала получите хотя бы один ответ в живой сессии ассистента.");return}tr(""),Hn({open:!0,title:ip(Vt),saving:!1,error:""})},[Vt,et]),Es=g.useCallback(async()=>{const i=et.trim(),c=At.title.trim();if(!i){Hn(d=>({...d,error:"Активная сессия ассистента не найдена."}));return}if(!c){Hn(d=>({...d,error:"Укажите название сессии."}));return}Hn(d=>({...d,saving:!0,error:""}));try{const d=[z.systemPrompt,z.developerPrompt,z.domainPrompt,z.schemaNotes,z.fewShotExamples].join("||"),w=await Pe.saveAutoRunAssistantSession({session_id:i,title:c,generated_by:G.generatedBy.trim()||void 0,context:{llm_provider:a.llmProvider,model:a.model,assistant_prompt_version:$,decomposition_prompt_version:ie,prompt_fingerprint:d}});In(L=>[w.generation,...L.filter(Ne=>Ne.generation_id!==w.generation.generation_id)]),ft(L=>({...L,mode:"saved_user_sessions"})),Ct(w.generation.generation_id),or({force:!0}),q(`Живая сессия сохранена в автопрогоны: ${w.generation.generation_id}`)}catch(d){const w=d instanceof Error?d.message:String(d);Hn(L=>({...L,saving:!1,error:w})),q(`Assistant live save error: ${w}`)}},[At.title,et,$,G.generatedBy,or,a.llmProvider,a.model,ie,q,z.developerPrompt,z.domainPrompt,z.fewShotExamples,z.schemaNotes,z.systemPrompt]),lo=g.useCallback(i=>{const c=i.trim();if(!c){Sr(String(b.limit));return}if(!/^\d+$/.test(c)){Sr(String(b.limit));return}const d=Number.parseInt(c,10);if(!Number.isFinite(d)){Sr(String(b.limit));return}const w=Math.max(1,Math.min(500,d));w!==b.limit&&Re(L=>({...L,limit:w})),Sr(String(w))},[b.limit]),yt=g.useCallback(i=>{const c=i.trim();if(!c){kn(String(G.count));return}if(!/^\d+$/.test(c)){kn(String(G.count));return}const d=Number.parseInt(c,10);if(!Number.isFinite(d)){kn(String(G.count));return}const w=Math.max(1,Math.min(200,d));w!==G.count&&ft(L=>({...L,count:w})),kn(String(w))},[G.count]),lr=g.useCallback(i=>{Zr(od(i))},[]),Ps=g.useCallback(i=>{const c=i.currentTarget.offsetHeight;Number.isFinite(c)&&c>0&&lr(c)},[lr]),jn=g.useCallback(async()=>{$o(!0);try{const i=await Pe.loadAutoRunAnnotations({limit:800,manual_case_decision:ce});ue(i.items),dt(i.manual_case_decision_schema??null),gr(i.available_manual_case_decisions??[]),xn(c=>i.items.length===0?"":i.items.some(d=>d.annotation_id===c)?c:i.items[0].annotation_id)}catch(i){q(`Annotations load error: ${i instanceof Error?i.message:String(i)}`)}finally{$o(!1)}},[ce,q]),ir=g.useCallback(async()=>{Un(!0);try{const i=await Pe.loadAutoRunAutogenHistory({limit:180});In(i.items)}catch(i){q(`Autogen history load error: ${i instanceof Error?i.message:String(i)}`)}finally{Un(!1)}},[q]),Ts=g.useCallback(async()=>{try{const c=(await Pe.loadAutoRunAutogenPersonalityCatalog()).items.map(d=>({id:String(d.id??"").trim(),label:String(d.label??"").trim(),domain:typeof d.domain=="string"?d.domain.trim():"",defaultPrompt:String(d.default_prompt??"").trim()})).filter(d=>d.id.length>0&&d.label.length>0);if(c.length===0)return;_n(c.map(d=>({id:d.id,label:d.label,domain:d.domain||"",defaultPrompt:d.defaultPrompt||"Генерируй реалистичные вопросы бухгалтера по выбранному профилю. Не выдумывай непокрытые возможности."})))}catch(i){q(`Autogen personality catalog load error: ${i instanceof Error?i.message:String(i)}`)}},[q]),en=g.useCallback(async()=>{$n(!0);try{const i=await Pe.loadAutoRunPostAnalysis({run_id:Ee&&!Xs(Ee)?Ee:void 0,limit_per_queue:30,annotation_limit:1500,from:Gl(b.fromLocal),to:Gl(b.toLocal),target:b.target,mode:b.mode,use_mock:b.useMock,prompt_contains:b.promptContains.trim()||void 0});Hr(i)}catch(i){q(`Post-analysis load error: ${i instanceof Error?i.message:String(i)}`),Hr(null)}finally{$n(!1)}},[b.fromLocal,b.mode,b.promptContains,b.target,b.toLocal,b.useMock,q,Ee]),ns=g.useCallback(async()=>{Wr(!0),Ye("");try{if(G.mode==="saved_user_sessions")throw new Error("Пользовательские сессии сохраняются из живого чата, а не генерируются автоматически.");const i=G.personalityPrompts[G.personalityId]??"",c=[z.systemPrompt,z.developerPrompt,z.domainPrompt,z.schemaNotes,z.fewShotExamples].join(` +`).slice(0,900),d=await Pe.generateAutoRunQuestions({mode:G.mode,count:G.count,domain:Yt.domain||void 0,persist_to_eval_cases:G.persistToEvalCases,generated_by:G.generatedBy.trim()||void 0,llm:{llm_provider:a.llmProvider,api_key:a.apiKey,model:a.model,base_url:a.baseUrl,temperature:a.temperature,max_output_tokens:a.maxOutputTokens},context:{llm_provider:a.llmProvider,model:a.model,assistant_prompt_version:$,decomposition_prompt_version:ie,prompt_fingerprint:c,autogen_personality_id:Yt.id,autogen_personality_prompt:i.trim()||void 0}});q(`Generated ${d.generation.count} questions (${d.generation.mode}) id=${d.generation.generation_id}`+(d.generation.saved_case_set_file?` saved=${d.generation.saved_case_set_file}`:"")),Ct(d.generation.generation_id),Nt([...d.generation.questions??[]]),await ir()}catch(i){const c=i instanceof Error?i.message:String(i);Ye(`Автогенерация: ${c}`),q(`Autogen generate error: ${c}`)}finally{Wr(!1)}},[$,G.count,G.generatedBy,G.mode,G.personalityId,G.personalityPrompts,G.persistToEvalCases,a.apiKey,a.baseUrl,a.llmProvider,a.maxOutputTokens,a.model,a.temperature,ie,ir,q,z.developerPrompt,z.domainPrompt,z.fewShotExamples,z.schemaNotes,z.systemPrompt,Yt.domain,Yt.id]),Gn=g.useCallback(async(i,c)=>{if(Xs(i)){const d=cd(i);if(Y&&Y.job_id===d){const w=Oo(Y,c);Qt(i),gt(w.caseId),k(w.dialog);return}k(null);return}zo(!0);try{const d=await Pe.loadAutoRunCaseDialog(i,c);k(d)}catch(d){const w=d instanceof Error?d.message:String(d);Ye(`Диалог кейса: ${w}`),k(null),q(`Dialog load error for ${i}/${c}: ${w}`)}finally{zo(!1)}},[Y,q]),Cn=g.useCallback(async(i,c)=>{if(Xs(i)){const d=cd(i);if(Y&&Y.job_id===d){const w=Oo(Y,c??kt);Qt(i),gt(w.caseId),A(w.detail),k(w.dialog);return}Qt(i),gt(""),A(null),k(null);return}Ce(!0);try{const d=await Pe.loadAutoRunDetail(i);A(d);const w=(c&&(c===kt||d.cases.some(L=>L.case_id===c))?c:"")||(d.cases.length>0?kt:"")||"";Qt(i),gt(w),w?await Gn(i,w):k(null)}catch(d){const w=d instanceof Error?d.message:String(d);Ye(`Детализация прогона: ${w}`),A(null),k(null),q(`Run detail load error for ${i}: ${w}`)}finally{Ce(!1)}},[Y,Gn,q]),rs=g.useCallback(async i=>{X(!0),Ye("");try{const c=await Pe.loadAutoRunsHistory({from:Gl(b.fromLocal),to:Gl(b.toLocal),target:b.target,mode:b.mode,use_mock:b.useMock,prompt_contains:b.promptContains.trim()||void 0,limit:b.limit});if(R(c),c.items.length===0){Qt(""),gt(""),A(null),k(null);return}const d=i?.keepSelection??!0,w=i?.preferredRunId??"",L=i?.preferredCaseId??"",Ne=d&&w&&c.items.some(tt=>tt.run_id===w)?w:c.items[0].run_id;await Cn(Ne,d?L:void 0),en()}catch(c){const d=c instanceof Error?c.message:String(c);Ye(`История прогонов: ${d}`),q(`History load error: ${d}`)}finally{X(!1)}},[b.fromLocal,b.limit,b.mode,b.promptContains,b.target,b.toLocal,b.useMock,en,Cn,q]),Nn=g.useCallback(()=>{Jt.current!==null&&(window.clearTimeout(Jt.current),Jt.current=null)},[]),io=g.useCallback(async i=>{try{const c=await Pe.loadEvalRunAsyncStatus(i);ln(c.job);const d=Jl(i);if(Ee===d){const w=Oo(c.job,st||kt);A(w.detail),k(w.dialog),gt(w.caseId)}if(c.job.status==="completed"){Nn(),wn(!1);const w=c.job.report_summary?.run_id??c.job.run_id;await rs({keepSelection:!0,preferredRunId:w||Ee,preferredCaseId:kt}),await ir(),ln(null);return}if(c.job.status==="failed"){Nn(),wn(!1),Ye(`Запуск прогонов: ${c.job.error??"неизвестная ошибка"}`),q(`Autogen async run failed: ${c.job.error??"unknown error"}`);return}Nn(),Jt.current=window.setTimeout(()=>{io(i)},500)}catch(c){Nn(),wn(!1);const d=c instanceof Error?c.message:String(c);Ye(`Запуск прогонов: ${d}`),q(`Autogen async status error: ${d}`)}},[ir,rs,q,st,Ee,Nn]),Ms=g.useCallback(async(i,c)=>{Nn(),wn(!0),Ye("");try{const d=i??Oe;if(!d)throw new Error("История автогенерации пуста. Сначала сгенерируйте пачку вопросов.");const L=(c??(Oe?.generation_id===d.generation_id?me:d.questions)).map(Tr=>Tr.trim()).filter(Tr=>Tr.length>0);if(L.length===0)throw new Error("Нет вопросов для запуска: список пустой после ручного редактирования.");const Ne=b.useMock==="true",tt=Oa(Ge),Dt=d.mode==="saved_user_sessions",dn=(await Pe.startEvalRunAsync({connection:a,prompts:z,promptVersion:$,mode:"single-pass-strict",caseSetFile:Dt?void 0:d.saved_case_set_file??void 0,useMock:Ne,evalTarget:"assistant_stage1",questions:Dt?void 0:L,scenarioQuestions:Dt?L:void 0,scenarioTitle:Dt?d.title??void 0:void 0,analysisDate:Dt?void 0:tt||void 0})).job;ln(dn);const ss=Jl(dn.job_id),po=Oo(dn,kt);Qt(ss),gt(po.caseId),A(po.detail),k(po.dialog),q(`Запущен async-прогон job=${dn.job_id}, run_id=${dn.run_id}, вопросов=${L.length}`+(d.saved_case_set_file?`, base_case_set=${d.saved_case_set_file}`:"")+(Dt?", replay_mode=saved_user_session_scenario":tt?`, analysis_date=${tt}`:", analysis_date=current_state")),io(dn.job_id)}catch(d){const w=d instanceof Error?d.message:String(d);Ye(`Запуск прогонов: ${w}`),q(`Autogen run error: ${w}`),wn(!1)}},[Ge,$,a,me,b.useMock,q,io,z,Oe,Nn]),ni=g.useCallback(i=>{if(i.role!=="assistant")return;const c=i.case_id??st,d=i.case_message_index??i.message_index;Gt({open:!0,caseId:c,caseMessageIndex:d,messageIndex:i.message_index,rating:i.annotation?.rating??3,comment:i.annotation?.comment??"",manualCaseDecision:i.annotation?.manual_case_decision??Wl,annotationAuthor:i.annotation?.annotation_author??G.generatedBy,saving:!1,error:""})},[G.generatedBy,st]),Rs=g.useCallback(i=>{Gt(c=>c.saving&&!i?.force?c:{open:!1,caseId:"",caseMessageIndex:-1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:Wl,annotationAuthor:G.generatedBy,saving:!1,error:""})},[G.generatedBy]),ri=g.useCallback(async()=>{const i=Ee,c=Q.caseId,d=Q.caseMessageIndex;if(!(!i||!c||d<0)){if(Xs(i)){Gt(w=>({...w,error:"Комментарий можно сохранить после завершения прогона."}));return}if(!Q.comment.trim()){Gt(w=>({...w,error:"Добавьте комментарий."}));return}Gt(w=>({...w,saving:!0,error:""}));try{await Pe.saveAutoRunAnnotation({run_id:i,case_id:c,message_index:d,rating:Q.rating,comment:Q.comment.trim(),manual_case_decision:Q.manualCaseDecision,annotation_author:Q.annotationAuthor.trim()||void 0}),Rs({force:!0}),Promise.all([Cn(i,st),jn(),en()]).catch(w=>{const L=w instanceof Error?w.message:String(w);Ye(`Обновление после комментария: ${L}`),q(`Comment refresh error: ${L}`)})}catch(w){Gt(L=>({...L,saving:!1,error:w instanceof Error?w.message:String(w)}))}}},[Rs,Q.annotationAuthor,Q.caseId,Q.caseMessageIndex,Q.comment,Q.manualCaseDecision,Q.rating,jn,en,Cn,q,st,Ee]),si=g.useCallback(i=>i.role==="assistant",[]),oi=g.useCallback(i=>i.role==="assistant"&&es.has(i.message_id),[es]),Bo=g.useCallback((i,c)=>{if(i.role!=="assistant")return;const d=et.trim(),w=String(i.session_id??"").trim();if(!(d||w)){tr("Сначала получите ответ ассистента в активной сессии.");return}!d&&w&&ys(w);const Ne=es.get(i.message_id)??null;tr(""),qt({open:!0,messageIndex:c,rating:Ne?.rating??3,comment:Ne?.comment??"",annotationAuthor:Ne?.annotation_author??"manual_reviewer",saving:!1,error:""})},[es,et]),li=g.useCallback(async()=>{if(we.messageIndex<0)return;if(!we.comment.trim()){qt(d=>({...d,error:"Добавьте комментарий."}));return}const i=Vt[we.messageIndex]??null,c=et.trim()||(i?.role==="assistant"?String(i.session_id??"").trim():"");if(!c){qt(d=>({...d,error:"Сессия ассистента не найдена."}));return}qt(d=>({...d,saving:!0,error:""}));try{const d=await Pe.saveAssistantAnnotation({session_id:c,message_index:we.messageIndex,rating:we.rating,comment:we.comment.trim(),annotation_author:we.annotationAuthor.trim()||void 0});Kr(w=>{const L=[...w],Ne=L.findIndex(tt=>tt.annotation_id===d.annotation.annotation_id);return Ne>=0?L[Ne]=d.annotation:L.unshift(d.annotation),L.sort((tt,Dt)=>Date.parse(Dt.updated_at)-Date.parse(tt.updated_at))}),Wn({force:!0})}catch(d){const w=d instanceof Error?d.message:String(d);qt(L=>({...L,saving:!1,error:w}))}},[we.annotationAuthor,we.comment,we.messageIndex,we.rating,Vt,et,Wn]);g.useCallback(i=>{if(!Oe||Oe.mode!=="saved_user_sessions")return;const c=me[i]??"";rr({open:!0,generationId:Oe.generation_id,questionIndex:i,questionText:c,saving:!1,error:""})},[me,Oe]);const ii=g.useCallback(async()=>{const i=Lt.generationId,c=Lt.questionIndex;if(!i||c<0)return;const d=me.filter((w,L)=>L!==c);if(d.length===0){rr(w=>({...w,error:"Нельзя удалить последний вопрос из сохраненной сессии."}));return}rr(w=>({...w,saving:!0,error:""}));try{const w=await Pe.updateAutoRunAutogenQuestions({generation_id:i,questions:d});In(L=>L.map(Ne=>Ne.generation_id===i?w.generation:Ne)),Nt(w.generation.questions),Er({force:!0}),q(`Обновлена сохраненная сессия: ${i}`)}catch(w){const L=w instanceof Error?w.message:String(w);rr(Ne=>({...Ne,saving:!1,error:L})),q(`Saved session question delete error: ${L}`)}},[Er,me,q,Lt.generationId,Lt.questionIndex]),qn=g.useCallback(async(i,c)=>{const d=Oe?.generation_id??"",w=c?.revertQuestions??me;if(Nt(i),!d)return!0;vs(!0);try{const L=await Pe.updateAutoRunAutogenQuestions({generation_id:d,questions:i});return In(Ne=>Ne.map(tt=>tt.generation_id===d?L.generation:tt)),Nt([...L.generation.questions??[]]),c?.successLog&&q(c.successLog),!0}catch(L){const Ne=L instanceof Error?L.message:String(L);return Nt(w),Ye(`Вопросы к запуску: ${Ne}`),q(`Autogen questions update error: ${Ne}`),!1}finally{vs(!1)}},[me,q,Oe]),Qo=g.useCallback(i=>{Zn(i),on(me[i]??"")},[me]),cn=g.useCallback(()=>{Zn(null),on("")},[]),As=g.useCallback(async i=>{if(i===null)return;const c=me[i]??"",d=yr.trim();if(!d||d===c){cn();return}const w=me.map((Ne,tt)=>tt===i?d:Ne);await qn(w,{successLog:`Список вопросов обновлен: ${Oe?.generation_id??"local"}`,revertQuestions:me})&&cn()},[me,yr,Oe,cn,qn]),Ho=g.useCallback(()=>{As(Ze)},[As,Ze]),Vo=g.useCallback(i=>{if(i.key==="Enter"){i.preventDefault(),As(Ze);return}i.key==="Escape"&&(i.preventDefault(),cn())},[As,Ze,cn]),ao=g.useCallback(async()=>{const i=[...me,"Новый вопрос"],c=i.length-1;await qn(i,{successLog:`В список добавлен вопрос: ${Oe?.generation_id??"local"}`,revertQuestions:me})&&(Zn(c),on(i[c]))},[me,Oe,qn]),Wo=g.useCallback(async i=>{if(me.length<=1){Ye("В списке должен остаться хотя бы один вопрос.");return}const c=me.filter((w,L)=>L!==i);await qn(c,{successLog:`Из списка удален вопрос: ${Oe?.generation_id??"local"}`,revertQuestions:me})&&(Zn(w=>w===null?w:w===i?null:w>i?w-1:w),on(""))},[me,Oe,qn]),Go=g.useCallback((i,c)=>{if(Je){i.preventDefault();return}Rt(c),Ht(c),i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",String(c))},[Je]),qo=g.useCallback((i,c)=>{i.preventDefault(),Sn!==c&&Ht(c),i.dataTransfer.dropEffect="move"},[Sn]),Ko=g.useCallback(async(i,c)=>{i.preventDefault();const d=On;if(Ht(null),Rt(null),d===null||d===c)return;const w=[...me],[L]=w.splice(d,1);w.splice(c,0,L),await qn(w,{successLog:`Порядок вопросов обновлен: ${Oe?.generation_id??"local"}`,revertQuestions:me})},[On,me,Oe,qn]),Jo=g.useCallback(()=>{Rt(null),Ht(null)},[]),ai=g.useCallback(i=>{Ct(i),Dn(c=>c===i?"":i)},[]),Yo=g.useCallback(i=>{Kt({open:!0,generationId:i.generation_id,title:i.title??`${za(i.mode)} ${yn(i.created_at)}`,saving:!1,error:""})},[]),uo=g.useCallback(async()=>{const i=It.generationId.trim();if(i){Kt(c=>({...c,saving:!0,error:""}));try{const c=await Pe.deleteAutoRunAutogenHistoryRecord(i);In(d=>d.filter(w=>w.generation_id!==c.generation_id)),ts({force:!0}),q(`Удален набор автопрогона: ${c.generation_id}`+(c.deleted_files.length>0?`, files=${c.deleted_files.length}`:""))}catch(c){const d=c instanceof Error?c.message:String(c);Kt(w=>({...w,saving:!1,error:d})),q(`Autogen record delete error: ${d}`)}}},[It.generationId,ts,q]),Pr=g.useCallback(i=>{ue(c=>c.map(d=>d.annotation_id===i.annotation_id?{...d,...i}:d)),k(c=>c&&{...c,annotations:c.annotations.map(d=>d.annotation_id===i.annotation_id?i:d),messages:c.messages.map(d=>!d.annotation||d.annotation.annotation_id!==i.annotation_id?d:{...d,commented:!0,annotation:i})})},[]),Xo=g.useCallback(async(i,c)=>{if(i.annotation_id){if(Xs(i.run_id)){Ye("Статус выполнения можно менять только для завершённых прогонов.");return}Zs(i.annotation_id);try{const d=await Pe.updateAutoRunAnnotation({annotation_id:i.annotation_id,resolved:c,resolved_by:G.generatedBy||void 0});Pr(d.annotation),en()}catch(d){const w=d instanceof Error?d.message:String(d);Ye(`Смена статуса кейса: ${w}`),q(`Annotation resolve toggle error: ${w}`)}finally{Zs("")}}},[Pr,G.generatedBy,en,q]),co=g.useCallback(async i=>{xn(i.annotation_id),await Cn(i.run_id,i.case_id),te?.items.some(c=>c.run_id===i.run_id)||Ye("Комментарий относится к прогону вне текущего фильтра. Детали загружены напрямую.")},[te?.items,Cn]);g.useEffect(()=>{un.current||(un.current=!0,rs({keepSelection:!1}),ir(),Ts(),en())},[ir,Ts,rs,en]),g.useEffect(()=>{un.current&&jn()},[ce,jn]),g.useEffect(()=>{xn(i=>Xt.length===0?"":Xt.some(c=>c.annotation_id===i)?i:Xt[0].annotation_id)},[Xt]),g.useEffect(()=>{Ct(i=>vt.length===0?"":i&&vt.some(c=>c.generation_id===i)?i:vt[0].generation_id)},[vt]),g.useEffect(()=>{if(!Oe){Nt([]),cn(),Rt(null),Ht(null);return}Nt([...Oe.questions]),cn(),Rt(null),Ht(null)},[Oe,cn]),g.useEffect(()=>{if(Ze===null)return;const i=window.setTimeout(()=>{Vn.current?.focus(),Vn.current?.select()},0);return()=>window.clearTimeout(i)},[Ze]),g.useEffect(()=>{if(!Ae){Dn("");return}Mt&&!vt.some(i=>i.generation_id===Mt)&&Dn("")},[Mt,Ae,vt]),g.useEffect(()=>{Sr(String(b.limit))},[b.limit]),g.useEffect(()=>{kn(String(G.count))},[G.count]),g.useEffect(()=>{if(!et.trim()){Kr([]);return}js(et)},[et,js]),g.useEffect(()=>{if(!Y)return;const i=Jl(Y.job_id);if(Ee!==i)return;const c=Oo(Y,st||kt);A(c.detail),k(c.dialog),gt(c.caseId)},[Y,st,Ee]),g.useEffect(()=>()=>{Nn()},[Nn]),g.useEffect(()=>{jt.length!==0&&ft(i=>{let c=!1;const d={...i.personalityPrompts};for(const L of jt)(typeof d[L.id]!="string"||d[L.id].trim().length===0)&&(d[L.id]=L.defaultPrompt,c=!0);let w=i.personalityId;return jt.some(L=>L.id===i.personalityId)||(w=jt[0].id,c=!0),c?{...i,personalityId:w,personalityPrompts:d}:i})},[jt]),g.useEffect(()=>{const i=localStorage.getItem(nd);if(i)try{const c=JSON.parse(i);if(c.filters){const d=c.filters;Re(w=>({...w,...d,limit:typeof d.limit=="number"?Math.max(1,Math.min(500,d.limit)):w.limit}))}typeof c.analysisDate=="string"&&se(Oa(c.analysisDate)),typeof c.autogenPersonalityPromptHeight=="number"&&Zr(od(c.autogenPersonalityPromptHeight)),c.groupsExpanded&&(typeof c.groupsExpanded.filters=="boolean"&&Fo(c.groupsExpanded.filters),typeof c.groupsExpanded.generationContext=="boolean"&&ro(c.groupsExpanded.generationContext),typeof c.groupsExpanded.autogen=="boolean"&&kr(c.groupsExpanded.autogen),typeof c.groupsExpanded.savedSessions=="boolean"&&ws(c.groupsExpanded.savedSessions)),c.autoGenSettings&&ft(d=>{const w={...d.personalityPrompts},L=c.autoGenSettings?.personalityPrompts??{};for(const[tt,Dt]of Object.entries(L))typeof Dt=="string"&&tt.trim().length>0&&(w[tt.trim()]=Dt);const Ne=typeof c.autoGenSettings?.personalityId=="string"&&c.autoGenSettings.personalityId.trim().length>0?c.autoGenSettings.personalityId.trim():d.personalityId;return{...d,mode:c.autoGenSettings?.mode==="codex_creative"||c.autoGenSettings?.mode==="qwen_seed"||c.autoGenSettings?.mode==="saved_user_sessions"?c.autoGenSettings.mode:d.mode,count:typeof c.autoGenSettings?.count=="number"?Math.max(1,Math.min(200,c.autoGenSettings.count)):d.count,personalityId:Ne,personalityPrompts:w,persistToEvalCases:typeof c.autoGenSettings?.persistToEvalCases=="boolean"?c.autoGenSettings.persistToEvalCases:d.persistToEvalCases,generatedBy:typeof c.autoGenSettings?.generatedBy=="string"?c.autoGenSettings.generatedBy:d.generatedBy}}),(c.annotationDecisionFilter==="all"||typeof c.annotationDecisionFilter=="string"&&c.annotationDecisionFilter.length>0)&&ge(c.annotationDecisionFilter),typeof c.hideResolvedAnnotations=="boolean"&&xe(c.hideResolvedAnnotations)}catch{}},[]);const fo=g.useCallback(()=>{const i={filters:b,analysisDate:Ge,autogenPersonalityPromptHeight:nr,groupsExpanded:{filters:wr,generationContext:Bn,autogen:Qn,savedSessions:jr},autoGenSettings:{mode:G.mode,count:G.count,personalityId:G.personalityId,personalityPrompts:G.personalityPrompts,persistToEvalCases:G.persistToEvalCases,generatedBy:G.generatedBy},annotationDecisionFilter:ce,hideResolvedAnnotations:ye};localStorage.setItem(nd,JSON.stringify(i))},[Ge,ce,G,Qn,nr,b,wr,Bn,ye,jr]);return g.useEffect(()=>{const i=()=>{fo(),q("Сохранены настройки панели автопрогонов.")};return window.addEventListener(rd,i),()=>{window.removeEventListener(rd,i)}},[q,fo]),o.jsxs(Zl,{className:"autoruns-frame",title:"",hideHeader:!0,children:[o.jsxs("div",{className:"autoruns-columns",children:[je?o.jsxs("section",{className:"autoruns-col autoruns-settings-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Настройки"})}),o.jsxs("div",{className:"autoruns-settings-stack",children:[o.jsx(np,{embedded:!0,value:a,modelOptions:h,modelsBusy:p,onChange:I,onReloadModels:B,onSaveLocalConfig:ae,onTestConnection:re,lastStatus:T,busy:E}),o.jsx(rp,{embedded:!0,value:z,onChange:Z,presets:ee,selectedPresetId:ne,onSelectPreset:Te,onLoadPreset:de,onSavePreset:fe,onResetDefaults:he,onDiffPrevious:Qe,presetName:Ke,onPresetNameChange:He,diffSummary:Me})]})]}):null,Ue?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Автопрогоны"})}),o.jsxs("div",{className:"autoruns-group-heading",children:[o.jsx("h4",{children:"Настройки выборки"}),o.jsx("button",{type:"button",className:"autoruns-group-toggle",onClick:()=>Fo(i=>!i),"aria-label":wr?"Скрыть группу настройки выборки":"Показать группу настройки выборки",title:wr?"Скрыть группу":"Показать группу",children:o.jsx(Kl,{expanded:wr})})]}),wr?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Дата с",o.jsx("input",{type:"datetime-local",value:b.fromLocal,onChange:i=>Re(c=>({...c,fromLocal:i.target.value}))})]}),o.jsxs("label",{children:["Дата по",o.jsx("input",{type:"datetime-local",value:b.toLocal,onChange:i=>Re(c=>({...c,toLocal:i.target.value}))})]}),o.jsxs("label",{children:["Целевой контур",o.jsxs("select",{value:b.target,onChange:i=>Re(c=>({...c,target:i.target.value})),children:[o.jsx("option",{value:"all",children:"все"}),(te?.available.targets??[]).map(i=>o.jsx("option",{value:i,children:i},i))]})]}),o.jsxs("label",{children:["Режим",o.jsxs("select",{value:b.mode,onChange:i=>Re(c=>({...c,mode:i.target.value})),children:[o.jsx("option",{value:"all",children:"все"}),(te?.available.modes??[]).map(i=>o.jsx("option",{value:i,children:i},i))]})]}),o.jsxs("label",{children:["Использовать mock",o.jsxs("select",{value:b.useMock,onChange:i=>Re(c=>({...c,useMock:i.target.value})),children:[o.jsx("option",{value:"any",children:"любой"}),o.jsx("option",{value:"true",children:"да"}),o.jsx("option",{value:"false",children:"нет"})]})]}),o.jsxs("label",{children:["Лимит",o.jsx("input",{type:"number",min:1,max:500,value:ti,onChange:i=>{const c=i.target.value;(c===""||/^\d+$/.test(c))&&Sr(c)},onBlur:i=>lo(i.target.value),onKeyDown:i=>{i.key==="Enter"&&lo(i.target.value)}})]}),o.jsxs("label",{className:"full-width",children:["Версия промпта содержит",o.jsx("input",{value:b.promptContains,onChange:i=>Re(c=>({...c,promptContains:i.target.value})),placeholder:"normalizer_v2_0_2 / address_query_runtime_v1",list:"autoruns-prompt-versions"})]})]}),o.jsx("datalist",{id:"autoruns-prompt-versions",children:(te?.available.prompt_versions??[]).map(i=>o.jsx("option",{value:i},i))}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:C,onClick:()=>{rs({keepSelection:!1})},children:C?"Обновляю...":"Применить"}),o.jsx("button",{type:"button",className:"tab",onClick:()=>{Re({...Ia,fromLocal:ld()}),Ye("")},children:"Сбросить фильтры"})]})]}):null,o.jsxs("div",{className:"autoruns-group-heading",children:[o.jsx("h4",{children:"Контур генерации"}),o.jsx("button",{type:"button",className:"autoruns-group-toggle",onClick:()=>ro(i=>!i),"aria-label":Bn?"Скрыть группу контура генерации":"Показать группу контура генерации",title:Bn?"Скрыть группу":"Показать группу",children:o.jsx(Kl,{expanded:Bn})})]}),Bn?o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Провайдер:"}),o.jsx("strong",{children:a.llmProvider})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Модель:"}),o.jsx("strong",{children:a.model||"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Промпт ассистента:"}),o.jsx("strong",{children:$})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Промпт декомпозиции:"}),o.jsx("strong",{children:ie})]})]}):null,o.jsxs("div",{className:"autoruns-group-heading",children:[o.jsx("h4",{children:"Автопрогоны"}),o.jsx("button",{type:"button",className:"autoruns-group-toggle",onClick:()=>kr(i=>!i),"aria-label":Qn?"Скрыть группу автопрогонов":"Показать группу автопрогонов",title:Qn?"Скрыть группу":"Показать группу",children:o.jsx(Kl,{expanded:Qn})})]}),Qn?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Режимы",o.jsxs("select",{value:G.mode,onChange:i=>ft(c=>({...c,mode:i.target.value})),children:[o.jsx("option",{value:"codex_creative",children:"codex_creative"}),o.jsx("option",{value:"qwen_seed",children:"qwen_seed"}),o.jsx("option",{value:"saved_user_sessions",children:"Пользовательские сессии"})]})]}),Ae?null:o.jsxs(o.Fragment,{children:[o.jsxs("label",{children:["Кол-во",o.jsx("input",{type:"number",min:1,max:200,value:Ss,onChange:i=>{const c=i.target.value;(c===""||/^\d+$/.test(c))&&kn(c)},onBlur:i=>yt(i.target.value),onKeyDown:i=>{i.key==="Enter"&&yt(i.target.value)}})]}),o.jsxs("label",{children:["Личность автогенерации",o.jsx("select",{value:G.personalityId,onChange:i=>ft(c=>({...c,personalityId:i.target.value})),children:jt.map(i=>o.jsx("option",{value:i.id,children:i.label},i.id))})]}),o.jsxs("label",{children:["Кто генерирует",o.jsx("input",{value:G.generatedBy,onChange:i=>ft(c=>({...c,generatedBy:i.target.value})),placeholder:"manual_reviewer"})]}),o.jsxs("label",{className:"full-width",children:["Промпт личности",o.jsx("textarea",{className:"autoruns-personality-prompt",value:G.personalityPrompts[G.personalityId]??"",onChange:i=>ft(c=>({...c,personalityPrompts:{...c.personalityPrompts,[c.personalityId]:i.target.value}})),placeholder:"Текст промпта для выбранной личности автогенерации",style:{height:`${nr}px`},onMouseUp:Ps,onTouchEnd:Ps})]}),o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:G.persistToEvalCases,onChange:i=>ft(c=>({...c,persistToEvalCases:i.target.checked}))}),"Сохранять кейс-сет в `eval_cases`"]})]})]}),Ae?null:o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Дата анализа (срез)",o.jsx("input",{type:"date",value:Ge,onChange:i=>se(Oa(i.target.value))})]}),o.jsx("div",{className:"button-row",children:o.jsx("button",{type:"button",className:"tab",disabled:!Ge,onClick:()=>se(""),children:"Сбросить дату среза"})})]}),o.jsxs("div",{className:"button-row",children:[Ae?null:o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",disabled:Vr,onClick:()=>{ns()},children:Vr?"Генерирую...":"Сгенерировать пачку"}),o.jsx("button",{type:"button",className:"tab",disabled:Fn,onClick:()=>{ir()},children:Fn?"Обновляю...":"Обновить историю"})]}),o.jsx("button",{type:"button",className:"autoruns-run-launch-btn",style:Ae?{display:"none"}:void 0,disabled:xr||me.length===0||!Oe,onClick:()=>{Ms()},children:xr?"Запускаю...":"Запустить прогон"})]}),o.jsx("div",{className:"autoruns-form-grid",children:o.jsxs("label",{className:"full-width",children:[Ae?"Сохраненная сессия":"Кейс-сет для запуска",o.jsxs("select",{value:Ve,onChange:i=>Ct(i.target.value),disabled:vt.length===0,children:[vt.length===0?o.jsx("option",{value:"",children:Ae?"нет сохраненных сессий":"нет генераций"}):null,vt.map(i=>o.jsxs("option",{value:i.generation_id,children:[yn(i.created_at)," | ",$a(i)??za(i.mode)," | ",i.count]},i.generation_id))]})]})}),o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"autoruns-generated-questions",style:Ae?{display:"none"}:void 0,children:[o.jsx("div",{className:"autoruns-generated-questions-head",children:o.jsxs("strong",{children:["Вопросы к запуску: ",me.length]})}),me.length===0?o.jsx("p",{className:"muted",children:Ae?"Список вопросов пуст. Сначала сохраните живую пользовательскую сессию.":"Список вопросов пуст. Сгенерируйте пачку или добавьте вопрос вручную."}):o.jsx("div",{className:"autoruns-generated-questions-list",children:me.map((i,c)=>o.jsxs("div",{className:["autoruns-generated-question-item",Sn===c?"drag-over":"",On===c?"dragging":"",Ze===c?"editing":""].filter(Boolean).join(" "),onDragOver:d=>qo(d,c),onDrop:d=>{Ko(d,c)},children:[o.jsx("button",{type:"button",className:"autoruns-question-grip-btn",draggable:!Je&&Ze!==c,disabled:Je||Ze===c,onDragStart:d=>Go(d,c),onDragEnd:Jo,title:"Перетащить вопрос","aria-label":`Перетащить вопрос ${c+1}`,children:o.jsx(pd,{})}),Ze===c?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:Vn,className:"autoruns-generated-question-input",value:yr,onChange:d=>on(d.target.value),onBlur:Ho,onKeyDown:Vo,placeholder:"Текст вопроса",disabled:Je}),o.jsx("button",{type:"button",className:"autoruns-remove-question-btn",onMouseDown:d=>d.preventDefault(),onClick:()=>{Wo(c)},title:"Удалить вопрос","aria-label":`Удалить вопрос ${c+1}`,disabled:Je,children:"×"})]}):o.jsxs("button",{type:"button",className:"autoruns-generated-question-text",onDoubleClick:()=>Qo(c),title:"Двойной клик для редактирования",children:[c+1,". ",i]})]},`${c}-${i.slice(0,24)}`))}),o.jsx("button",{type:"button",className:"autoruns-add-question-btn",onClick:()=>{ao()},disabled:!Oe||Je,children:"+"})]}),Ae?null:o.jsx("p",{className:"muted",children:"Запуск выполняет `assistant_stage1` eval по выбранному кейс-сету."})]})]}):null,o.jsxs("div",{className:"autoruns-group-heading",children:[o.jsx("h4",{children:Ae?"Сохраненные пользовательские сессии":"История автогенераций"}),o.jsx("button",{type:"button",className:"autoruns-group-toggle",onClick:()=>ws(i=>!i),"aria-label":jr?Ae?"Скрыть группу сохраненных пользовательских сессий":"Скрыть группу истории автогенераций":Ae?"Показать группу сохраненных пользовательских сессий":"Показать группу истории автогенераций",title:jr?"Скрыть группу":"Показать группу",children:o.jsx(Kl,{expanded:jr})})]}),jr?o.jsxs("div",{className:"autoruns-autogen-list",children:[Fn?o.jsx("p",{className:"muted",children:Ae?"Загружаю сохраненные пользовательские сессии...":"Загружаю историю автогенераций..."}):null,!Fn&&vt.length===0?o.jsx("p",{className:"muted",children:Ae?"Сохраненные пользовательские сессии пока пусты.":"История автогенераций пока пустая."}):null,vt.slice(0,30).map(i=>o.jsxs("article",{className:["autoruns-autogen-item",Ve===i.generation_id?"selected":"",Mt===i.generation_id?"expanded":"",Ae?"saved-session":""].filter(Boolean).join(" "),onClick:Ae?void 0:()=>Ct(i.generation_id),children:[Ae?o.jsxs("div",{className:"autoruns-saved-session-topbar",children:[o.jsx("button",{type:"button",className:"autoruns-saved-session-icon-btn",disabled:xr,onClick:c=>{c.preventDefault(),c.stopPropagation(),Ct(i.generation_id),Ms(i,Ve===i.generation_id?me:i.questions)},title:"Запустить прогон","aria-label":`Запустить прогон для ${$a(i)}`,children:o.jsx(fp,{})}),o.jsx("button",{type:"button",className:"autoruns-autogen-delete-btn",onClick:c=>{c.preventDefault(),c.stopPropagation(),Yo(i)},title:"Удалить сохраненный набор","aria-label":`Удалить набор ${i.generation_id}`,children:"×"})]}):null,o.jsxs("header",{children:[o.jsx("strong",{children:$a(i)}),o.jsxs("div",{className:"autoruns-autogen-card-actions",children:[o.jsx("span",{children:yn(i.created_at)}),o.jsx("button",{type:"button",className:"autoruns-autogen-delete-btn",onClick:c=>{c.preventDefault(),c.stopPropagation(),Yo(i)},title:"Удалить сохраненный набор","aria-label":`Удалить набор ${i.generation_id}`,children:"×"})]})]}),o.jsxs("div",{className:"autoruns-run-meta autoruns-run-id-row",children:[o.jsx("span",{children:i.generation_id}),o.jsx("span",{role:"button",tabIndex:0,className:"autoruns-copy-run-id-btn",onClick:c=>{Zt(c,i.generation_id,"set id")},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),Zt(c,i.generation_id,"set id"))},title:"Скопировать id набора","aria-label":`Скопировать id набора ${i.generation_id}`,children:o.jsx(fd,{})})]}),o.jsxs("div",{className:"autoruns-run-meta",children:["режим=",za(i.mode)]}),o.jsxs("div",{className:"autoruns-run-meta",children:["тип=",_d(i)?"АГЕНТНЫЙ ПРОГОН":"АВТОПРОГОН"]}),Ae?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"autoruns-saved-session-footer",children:o.jsx("button",{type:"button",className:"autoruns-saved-session-icon-btn",onClick:c=>{c.preventDefault(),c.stopPropagation(),ai(i.generation_id)},title:Mt===i.generation_id?"Скрыть вопросы":"Показать вопросы","aria-label":Mt===i.generation_id?"Скрыть вопросы":"Показать вопросы",children:o.jsx(dp,{expanded:Mt===i.generation_id})})}),o.jsx("div",{className:Mt===i.generation_id?"autoruns-saved-session-questions expanded":"autoruns-saved-session-questions",children:o.jsxs("div",{className:"autoruns-generated-questions autoruns-generated-questions-embedded",children:[o.jsx("div",{className:"autoruns-generated-questions-head",children:o.jsxs("strong",{children:["Вопросы к запуску:"," ",Ve===i.generation_id?me.length:i.questions.length]})}),(Ve===i.generation_id?me:i.questions).length===0?o.jsx("p",{className:"muted",children:"Список вопросов пуст."}):o.jsx("div",{className:"autoruns-generated-questions-list",children:(Ve===i.generation_id?me:i.questions).map((c,d)=>o.jsxs("div",{className:["autoruns-generated-question-item",Sn===d&&Ve===i.generation_id?"drag-over":"",On===d&&Ve===i.generation_id?"dragging":"",Ze===d&&Ve===i.generation_id?"editing":""].filter(Boolean).join(" "),onDragOver:w=>Ve===i.generation_id?qo(w,d):void 0,onDrop:w=>Ve===i.generation_id?void Ko(w,d):void 0,children:[o.jsx("button",{type:"button",className:"autoruns-question-grip-btn",draggable:Ve===i.generation_id&&!Je&&Ze!==d,disabled:Ve!==i.generation_id||Je||Ze===d,onDragStart:w=>{Ct(i.generation_id),Go(w,d)},onDragEnd:Jo,title:"Перетащить вопрос","aria-label":`Перетащить вопрос ${d+1}`,children:o.jsx(pd,{})}),Ve===i.generation_id&&Ze===d?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:Vn,className:"autoruns-generated-question-input",value:yr,onChange:w=>on(w.target.value),onBlur:Ho,onKeyDown:Vo,placeholder:"Текст вопроса",disabled:Je}),o.jsx("button",{type:"button",className:"autoruns-remove-question-btn",onMouseDown:w=>w.preventDefault(),onClick:()=>{Wo(d)},title:"Удалить вопрос","aria-label":`Удалить вопрос ${d+1}`,disabled:Je,children:"×"})]}):o.jsxs("button",{type:"button",className:"autoruns-generated-question-text",onDoubleClick:()=>{Ct(i.generation_id),Qo(d)},title:"Двойной клик для редактирования",children:[d+1,". ",c]})]},`${i.generation_id}-${d}-${c.slice(0,24)}`))}),o.jsx("button",{type:"button",className:"autoruns-add-question-btn",onClick:()=>{Ct(i.generation_id),ao()},disabled:Ve!==i.generation_id||Je,children:"+"})]})})]}):null]},i.generation_id))]}):null,o.jsxs("details",{className:"autoruns-prompt-details",children:[o.jsx("summary",{children:"Копия активного промпта (только чтение)"}),o.jsxs("label",{children:["Системный",o.jsx("textarea",{readOnly:!0,value:z.systemPrompt})]}),o.jsxs("label",{children:["Разработчика",o.jsx("textarea",{readOnly:!0,value:z.developerPrompt})]}),o.jsxs("label",{children:["Доменный",o.jsx("textarea",{readOnly:!0,value:z.domainPrompt})]}),o.jsxs("label",{children:["Заметки по схеме",o.jsx("textarea",{readOnly:!0,value:z.schemaNotes})]}),o.jsxs("label",{children:["Примеры few-shot",o.jsx("textarea",{readOnly:!0,value:z.fewShotExamples})]})]}),eo?o.jsx("p",{className:"error-text",children:eo}):null]}):null,o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Выдача прогонов"})}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Всего"}),o.jsx("strong",{children:(te?.stats.runs_total??0)+(Y?1:0)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Средний score"}),o.jsx("strong",{children:ql(te?.stats.avg_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Тренд"}),o.jsx("strong",{children:te?ad(te.stats.trend):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Блокеры"}),o.jsx("strong",{children:te?.stats.blocking_runs??0})]})]}),o.jsxs("div",{className:"autoruns-run-list",children:[Nr.map(i=>o.jsxs("button",{type:"button",className:Ee===i.run_id?"autoruns-run-item selected":"autoruns-run-item",onClick:()=>{Cn(i.run_id)},children:[o.jsxs("div",{className:"autoruns-run-head",children:[o.jsx("strong",{children:yn(i.run_timestamp)}),o.jsx("span",{children:up(i.eval_target)})]}),o.jsxs("div",{className:"autoruns-run-meta autoruns-run-id-row",children:[o.jsx("span",{children:i.run_id}),o.jsx("span",{role:"button",tabIndex:0,className:"autoruns-copy-run-id-btn",onClick:c=>{Zt(c,i.run_id,"run id")},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),Zt(c,i.run_id,"run id"))},title:"Скопировать run id","aria-label":`Скопировать run id ${i.run_id}`,children:o.jsx(fd,{})})]}),o.jsxs("div",{className:"autoruns-run-meta",children:["режим=",i.mode??"нет данных"," | mock=",String(i.use_mock)]}),o.jsxs("div",{className:"autoruns-run-meta",children:["analysis_date=",i.analysis_date??"current_state"]}),i.llm_provider||i.model?o.jsxs("div",{className:"autoruns-run-meta",children:["llm=",i.llm_provider??"нет данных"," | модель=",i.model??"нет данных"]}):null,o.jsxs("div",{className:"autoruns-run-meta",children:["промпт=",i.prompt_version??"нет данных"]}),o.jsxs("div",{className:"autoruns-run-foot",children:[o.jsxs("span",{children:["оценка: ",ql(i.score_index)]}),o.jsxs("span",{children:["закрыто/открыто: ",i.closed_cases,"/",i.open_cases]})]}),o.jsxs("div",{className:"autoruns-run-foot",children:[o.jsxs("span",{children:["блокеры: ",i.blocking_failures]}),o.jsxs("span",{children:["качество: ",i.quality_failures]})]})]},i.run_id)),Nr.length===0?o.jsx("p",{className:"muted",children:"За выбранный диапазон прогонов нет."}):null]})]}),o.jsxs("section",{className:"autoruns-col",children:[o.jsxs("div",{className:"autoruns-col-header",children:[o.jsx("h3",{children:"Диалог прогона"}),o.jsxs("div",{className:"autoruns-dialog-toolbar",children:[o.jsxs("label",{children:["Прогон",o.jsx("select",{value:Ee,onChange:i=>{const c=i.target.value;Cn(c)},children:Nr.map(i=>o.jsxs("option",{value:i.run_id,children:[yn(i.run_timestamp)," | ",i.run_id]},i.run_id))})]}),o.jsxs("label",{children:["Кейс",o.jsxs("select",{value:st,onChange:i=>{const c=i.target.value;gt(c),Ee&&c&&Gn(Ee,c)},children:[(F?.cases.length??0)>0?o.jsx("option",{value:kt,children:"ВСЕ кейсы подряд"}):null,(F?.cases??[]).map(i=>o.jsxs("option",{value:i.case_id,children:[i.case_id," | ",i.status]},i.case_id))]})]})]})]}),o.jsxs("div",{className:"autoruns-case-list",children:[(F?.cases.length??0)>0?o.jsxs("button",{type:"button",className:st===kt?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{gt(kt),Ee&&Gn(Ee,kt)},children:[o.jsx("span",{children:"ВСЕ кейсы подряд"}),o.jsx("span",{children:F?.cases.length})]},kt):null,(F?.cases??[]).map(i=>o.jsxs("button",{type:"button",className:st===i.case_id?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{gt(i.case_id),Ee&&Gn(Ee,i.case_id)},children:[o.jsx("span",{children:i.case_id}),o.jsxs("span",{children:[i.status,i.commented_count>0?` | комм=${i.commented_count}`:""]})]},i.case_id))]}),o.jsxs("div",{className:"autoruns-dialog-view",children:[ot||V?o.jsx("p",{className:"muted",children:"Загружаю диалог..."}):null,!ot&&!V&&(y?.messages.length??0)===0?o.jsx("p",{className:"muted",children:"Диалог для этого прогона не найден."}):null,(y?.messages??[]).map((i,c)=>{const d=i.role==="assistant"?"assistant":"user";return o.jsxs("article",{className:`autoruns-msg ${d}`,children:[o.jsxs("header",{children:[o.jsx("strong",{children:d==="assistant"?"Система":"Модель/вопрос"}),o.jsxs("div",{className:"autoruns-msg-head-actions",children:[i.case_id?o.jsx("span",{className:"autoruns-msg-case-tag",children:i.case_id}):null,id(i)?o.jsx("span",{className:"autoruns-msg-case-tag",children:id(i)}):null,o.jsx("span",{children:i.created_at?yn(i.created_at):"нет данных"}),d==="assistant"&&!Xs(Ee)?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:i.commented?"autoruns-comment-icon commented":"autoruns-comment-icon",onClick:()=>ni(i),title:"\\u041a\\u043e\\u043c\\u043c\\u0435\\u043d\\u0442\\u0438\\u0440\\u043e\\u0432\\u0430\\u0442\\u044c \\u043e\\u0442\\u0432\\u0435\\u0442 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u044b","aria-label":"\\u041a\\u043e\\u043c\\u043c\\u0435\\u043d\\u0442\\u0438\\u0440\\u043e\\u0432\\u0430\\u0442\\u044c \\u043e\\u0442\\u0432\\u0435\\u0442 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u044b",children:o.jsx(cp,{commented:i.commented})}),i.annotation?o.jsx("button",{type:"button",className:i.annotation.resolved?"autoruns-resolve-toggle resolved":"autoruns-resolve-toggle",onClick:()=>{Xo(i.annotation,!i.annotation.resolved)},disabled:bn===i.annotation.annotation_id,title:i.annotation.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный","aria-label":i.annotation.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный",children:o.jsx(dd,{resolved:i.annotation.resolved})}):null]}):null]})]}),o.jsx("p",{children:i.text}),d==="assistant"&&i.annotation?o.jsxs("div",{className:"autoruns-msg-annotation",children:[o.jsx("strong",{children:Fa(i.annotation.rating)}),o.jsx("span",{children:i.annotation.comment}),o.jsxs("span",{className:"muted",children:[i.annotation.manual_case_decision,i.annotation.annotation_author?` | ${i.annotation.annotation_author}`:""]})]}):null,(i.trace_id||i.reply_type)&&o.jsxs("footer",{children:[i.trace_id?o.jsxs("span",{children:["trace=",i.trace_id]}):null,i.reply_type?o.jsxs("span",{children:["reply_type=",i.reply_type]}):null]})]},i.message_id??`${d}-${c}`)})]})]}),ht?o.jsx("div",{className:"autoruns-col autoruns-assistant-live-col",children:o.jsx(Xf,{sessionId:et,conversation:Vt,inputValue:De,onInputChange:to,selectedContextChip:Jr,onSelectContextChip:_s,onClearContextChip:()=>_s(null),useMock:_r,onUseMockChange:ei,onSend:bo,onClear:Cs,onSaveSession:Ns,busy:no,saveBusy:At.saving,saveDisabled:!et.trim()||Vt.length===0||no,statusText:an,errorMessage:Wt,showSaveAction:!0,showCommentAction:!0,onCommentAssistantMessage:Bo,isAssistantMessageCommented:oi,canCommentAssistantMessage:si})}):null,ut?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Прогресс / регресс"})}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Последний score"}),o.jsx("strong",{children:ql(te?.stats.latest_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Предыдущий"}),o.jsx("strong",{children:ql(te?.stats.previous_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Тренд"}),o.jsx("strong",{children:te?ad(te.stats.trend):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Пробелы качества"}),o.jsx("strong",{children:te?.stats.quality_gap_runs??0})]})]}),o.jsx("h4",{children:"Покрытие доменов (история)"}),ud(te?.stats.domain_coverage??[]),o.jsx("h4",{style:{marginTop:14},children:"Покрытие доменов (выбранный прогон)"}),ud(F?.coverage.domain_coverage??[]),o.jsx("h4",{style:{marginTop:14},children:"Очереди фиксов пост-анализа"}),zn?o.jsx("p",{className:"muted",children:"Собираю пост-анализ..."}):null,zn?null:o.jsx("div",{className:"autoruns-stats-grid",children:Object.entries(er?.post_analysis.stats.by_queue??{}).map(([i,c])=>o.jsxs("div",{children:[o.jsx("span",{children:i}),o.jsx("strong",{children:c})]},i))}),o.jsxs("div",{className:"autoruns-autogen-list",children:[(er?.post_analysis.recommended_regression_candidates??[]).slice(0,12).map(i=>o.jsxs("article",{className:"autoruns-autogen-item",children:[o.jsxs("header",{children:[o.jsx("strong",{children:i.manual_case_decision}),o.jsxs("span",{children:[i.rating,"/5"]})]}),o.jsxs("div",{className:"autoruns-run-meta",children:[i.domain??"неизвестно"," / ",i.query_class??"неизвестно"]}),o.jsx("p",{children:i.comment})]},i.annotation_id)),!zn&&(er?.post_analysis.recommended_regression_candidates.length??0)===0?o.jsx("p",{className:"muted",children:"Рекомендованных кандидатов пока нет."}):null]})]}):null,Bt?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Комментарии"})}),o.jsx("h4",{children:"Размеченные ответы"}),o.jsxs("div",{className:"autoruns-comment-filter-row",children:[o.jsxs("label",{children:["Фильтр решений",o.jsxs("select",{value:ce,onChange:i=>ge(i.target.value),children:[o.jsx("option",{value:"all",children:"все"}),(sn.length>0?sn:Se?.enum??[]).map(i=>o.jsx("option",{value:i,children:String(Se?.labels?.[i]??i)},i))]})]}),o.jsx("button",{type:"button",className:"tab autoruns-resolved-filter-toggle",onClick:()=>xe(i=>!i),children:ye?"Показать выполненные":"Скрыть выполненные"})]}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Комментариев"}),o.jsx("strong",{children:Et.length})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Средний рейтинг"}),o.jsx("strong",{children:sr===null?"нет данных":`${sr.toFixed(2)} / 5`})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Последний"}),o.jsx("strong",{children:Et.length>0?yn(Et[0].updated_at):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Статус"}),o.jsx("strong",{children:Gr?"обновляю":"готово"})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:Gr,onClick:()=>{jn()},children:Gr?"Обновляю...":"Обновить список"}),o.jsx("button",{type:"button",className:"tab",disabled:zn,onClick:()=>{en()},children:zn?"Идет пост-анализ...":"Обновить пост-анализ"})]}),o.jsxs("div",{className:"autoruns-comments-list",children:[Gr?o.jsx("p",{className:"muted",children:"Загружаю комментарии..."}):null,!Gr&&Et.length===0?o.jsx("p",{className:"muted",children:oe.length===0&&qr.length===0?"Пока нет откомментированных ответов.":"Нет открытых кейсов по текущему фильтру."}):null,Et.map(i=>{if(i.source==="assistant_live"){const d=i.assistant;return o.jsxs("article",{className:"autoruns-comment-item",children:[o.jsxs("div",{className:"autoruns-comment-head",children:[o.jsx("strong",{children:Fa(d.rating)}),o.jsx("div",{className:"autoruns-comment-head-actions",children:o.jsx("span",{children:yn(d.updated_at)})})]}),o.jsxs("div",{className:"autoruns-run-meta",children:["live-session: ",d.session_id]}),o.jsxs("div",{className:"autoruns-run-meta",children:["msg=",d.message_index]}),o.jsxs("div",{className:"autoruns-run-meta",children:["source=assistant_live",d.annotation_author?` | author=${d.annotation_author}`:""]}),d.context.question_text?o.jsxs("p",{children:["Q: ",d.context.question_text]}):null,d.context.answer_text?o.jsxs("p",{children:["A: ",d.context.answer_text]}):null,o.jsx("p",{children:d.comment})]},i.key)}const c=i.autorun;return o.jsxs("article",{className:Ln===c.annotation_id?"autoruns-comment-item selected":"autoruns-comment-item",onClick:()=>{co(c)},role:"button",tabIndex:0,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),co(c))},children:[o.jsxs("div",{className:"autoruns-comment-head",children:[o.jsx("strong",{children:Fa(c.rating)}),o.jsxs("div",{className:"autoruns-comment-head-actions",children:[o.jsx("span",{children:yn(c.updated_at)}),o.jsx("button",{type:"button",className:c.resolved?"autoruns-resolve-toggle resolved":"autoruns-resolve-toggle",onClick:d=>{d.preventDefault(),d.stopPropagation(),Xo(c,!c.resolved)},disabled:bn===c.annotation_id,title:c.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный","aria-label":c.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный",children:o.jsx(dd,{resolved:c.resolved})})]})]}),o.jsx("div",{className:"autoruns-run-meta",children:c.run_id}),o.jsxs("div",{className:"autoruns-run-meta",children:["case=",c.case_id," | msg=",c.message_index]}),o.jsxs("div",{className:"autoruns-run-meta",children:["decision=",c.manual_case_decision,c.annotation_author?` | author=${c.annotation_author}`:""]}),c.resolved_at?o.jsxs("div",{className:"autoruns-run-meta",children:["выполнено",": ",yn(c.resolved_at),c.resolved_by?` | by=${c.resolved_by}`:""]}):null,c.context.question_text?o.jsxs("p",{children:["Q: ",c.context.question_text]}):null,c.context.answer_text?o.jsxs("p",{children:["A: ",c.context.answer_text]}):null,o.jsx("p",{children:c.comment})]},i.key)})]}),Le?o.jsxs(o.Fragment,{children:[o.jsx("h4",{children:"Тех-контекст брака"}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"trace:"}),o.jsx("strong",{children:Le.technical_context.trace_id??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"reply_type:"}),o.jsx("strong",{children:Le.technical_context.reply_type??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"domain:"}),o.jsx("strong",{children:Le.technical_context.domain??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"query_class:"}),o.jsx("strong",{children:Le.technical_context.query_class??"нет данных"})]})]}),o.jsx("h4",{children:"JSON разбор"}),o.jsx(yd,{value:{annotation_id:Le.annotation_id,run_id:Le.run_id,case_id:Le.case_id,message_index:Le.message_index,rating:Le.rating,comment:Le.comment,manual_case_decision:Le.manual_case_decision,annotation_author:Le.annotation_author,resolved:Le.resolved,resolved_at:Le.resolved_at,resolved_by:Le.resolved_by,context:Le.context,technical_context:Le.technical_context,case_summary:Le.case_summary?{case_id:Le.case_summary.case_id,domain:Le.case_summary.domain,query_class:Le.case_summary.query_class,checks:Le.case_summary.checks,metric_subscores:Le.case_summary.metric_subscores}:null}})]}):null]}):null]}),At.open?o.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:i=>{i.target===i.currentTarget&&or()},children:o.jsxs("div",{className:"autoruns-comment-modal",children:[o.jsx("h3",{children:"Сохранить ручную сессию"}),o.jsx("p",{className:"muted",children:"Технический чат будет сохранен в автопрогоны как пользовательская multi-turn сессия."}),o.jsxs("label",{children:["Название",o.jsx("input",{value:At.title,onChange:i=>Hn(c=>({...c,title:i.target.value})),placeholder:"Например: НДС и склад на март 2020",disabled:At.saving})]}),At.error?o.jsx("p",{className:"error-text",children:At.error}):null,o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>{Es()},disabled:At.saving,children:At.saving?"Сохраняю...":"Сохранить"}),o.jsx("button",{type:"button",className:"tab",onClick:()=>or(),disabled:At.saving,children:"Отмена"})]})]})}):null,Lt.open?o.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:i=>{i.target===i.currentTarget&&Er()},children:o.jsxs("div",{className:"autoruns-comment-modal",children:[o.jsx("h3",{children:"Удалить вопрос"}),o.jsx("p",{className:"muted",children:"Действительно удалить вопрос из сохраненной пользовательской сессии?"}),o.jsx("p",{className:"autoruns-comment-quote",children:Lt.questionText}),Lt.error?o.jsx("p",{className:"error-text",children:Lt.error}):null,o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>{ii()},disabled:Lt.saving,children:Lt.saving?"Удаляю...":"Да"}),o.jsx("button",{type:"button",className:"tab",onClick:()=>Er(),disabled:Lt.saving,children:"Нет"})]})]})}):null,It.open?o.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:i=>{i.target===i.currentTarget&&ts()},children:o.jsxs("div",{className:"autoruns-comment-modal",children:[o.jsx("h3",{children:"Удалить сохраненный набор"}),o.jsx("p",{className:"muted",children:"Будет удалена карточка истории и связанный файл кейс-сета на бэке."}),o.jsx("p",{className:"autoruns-comment-quote",children:It.title}),It.error?o.jsx("p",{className:"error-text",children:It.error}):null,o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>{uo()},disabled:It.saving,children:It.saving?"Удаляю...":"Да"}),o.jsx("button",{type:"button",className:"tab",onClick:()=>ts(),disabled:It.saving,children:"Нет"})]})]})}):null,we.open?o.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:i=>{i.target===i.currentTarget&&Wn()},children:o.jsxs("div",{className:"autoruns-comment-modal",children:[o.jsx("h3",{children:"Комментарий к ответу ассистента"}),o.jsx("p",{className:"muted",children:"Комментарий будет добавлен в общий список комментариев справа с меткой `assistant_live`."}),Cr?o.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[o.jsx("summary",{children:"Вопрос пользователя"}),o.jsx("p",{className:"autoruns-comment-quote",children:Cr.text})]}):null,Uo?o.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[o.jsx("summary",{children:"Ответ ассистента"}),o.jsx("p",{className:"autoruns-comment-quote",children:Uo.text})]}):null,o.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа ассистента",children:[1,2,3,4,5].map(i=>o.jsx("button",{type:"button",className:we.rating>=i?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>qt(c=>({...c,rating:i})),disabled:we.saving,"aria-label":`Оценка ${i}`,children:we.rating>=i?"●":"○"},i))}),o.jsx("div",{className:"autoruns-form-grid",children:o.jsxs("label",{children:["Автор комментария",o.jsx("input",{value:we.annotationAuthor,onChange:i=>qt(c=>({...c,annotationAuthor:i.target.value})),placeholder:"manual_reviewer",disabled:we.saving})]})}),o.jsxs("label",{children:["Комментарий",o.jsx("textarea",{value:we.comment,onChange:i=>qt(c=>({...c,comment:i.target.value})),placeholder:"Что именно не так в ответе и что нужно исправить.",rows:4,disabled:we.saving})]}),we.error?o.jsx("p",{className:"error-text",children:we.error}):null,o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>{li()},disabled:we.saving,children:we.saving?"Сохраняю...":"Готово"}),o.jsx("button",{type:"button",className:"tab",onClick:()=>Wn(),disabled:we.saving,children:"Отмена"})]})]})}):null,Q.open?o.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:i=>{i.target===i.currentTarget&&Rs()},children:o.jsxs("div",{className:"autoruns-comment-modal",children:[o.jsx("h3",{children:"Комментарий к ответу системы"}),o.jsx("p",{className:"muted",children:"Оцените ответ по 5-балльной шкале и добавьте комментарий по браку."}),so?o.jsxs(o.Fragment,{children:[o.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[o.jsx("summary",{children:"Вопрос пользователя"}),o.jsx("p",{className:"autoruns-comment-quote",children:ks?.text??"Вопрос в диалоге не найден."})]}),o.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[o.jsx("summary",{children:"Ответ системы"}),o.jsx("p",{className:"autoruns-comment-quote",children:so.text})]})]}):null,o.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа",children:[1,2,3,4,5].map(i=>o.jsx("button",{type:"button",className:Q.rating>=i?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>Gt(c=>({...c,rating:i})),disabled:Q.saving,"aria-label":`Оценка ${i}`,children:Q.rating>=i?"●":"○"},i))}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Решение по кейсу",o.jsx("select",{value:Q.manualCaseDecision,onChange:i=>Gt(c=>({...c,manualCaseDecision:i.target.value})),disabled:Q.saving,children:(sn.length>0?sn:Se?.enum??[Wl]).map(i=>o.jsx("option",{value:i,children:String(Se?.labels?.[i]??i)},i))})]}),o.jsxs("label",{children:["Автор комментария",o.jsx("input",{value:Q.annotationAuthor,onChange:i=>Gt(c=>({...c,annotationAuthor:i.target.value})),placeholder:"manual_reviewer",disabled:Q.saving})]})]}),o.jsxs("label",{children:["Комментарий",o.jsx("textarea",{value:Q.comment,onChange:i=>Gt(c=>({...c,comment:i.target.value})),placeholder:"Почему ответ бракованный, что именно пошло не так, какие технические детали проверить.",rows:4,disabled:Q.saving})]}),Q.error?o.jsx("p",{className:"error-text",children:Q.error}):null,o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>{ri()},disabled:Q.saving,children:Q.saving?"Сохраняю...":"Готово"}),o.jsx("button",{type:"button",className:"tab",onClick:()=>Rs(),disabled:Q.saving,children:"Отмена"})]})]})}):null]})}const mp={llmProvider:"openai",apiKey:"",model:"gpt-4o-mini",baseUrl:"https://api.openai.com/v1",temperature:0,maxOutputTokens:700},md={systemPrompt:"Ты semantic-normalizer для бухгалтерского ассистента NDC. Возвращай только JSON по схеме normalized_query_v2_0_2.",developerPrompt:"Сначала делай decomposition сообщения на task fragments, затем определяй domain scope и route-critical flags. Для каждого fragment заполняй execution_readiness + route_status + no_route_reason. Если fragment routable, не оставляй его в no_route.",domainPrompt:"Контур: данные текущего предприятия в 1С/NDC. In-scope: документы, проводки, взаиморасчеты, остатки, периодное закрытие, аномалии и контрольные проверки. Out-of-scope: общая теория, законы и оффтоп.",schemaNotes:"schema_version: normalized_query_v2_0_2. Строгий JSON без дополнительных полей.",fewShotExamples:"Q: Проверь по поставщикам хвосты и разложи цепочку документов/оплат. => fragment in_scope, flags: multi_entity + chain_explanation. Q: Как вообще по ФСБУ? => out_of_scope/generic_accounting."},hp={userQuestion:"",batchQuestionsRaw:"",periodHint:"",businessContext:"",expectedRoute:""},Ua={colors:{backgroundRgb:"18, 18, 18",mainSurfaceRgb:"25, 25, 25",horizontalSurfaceRgb:"30, 30, 30",focusSurfaceRgb:"35, 35, 35",assistantChipRgb:"18, 18, 18",assistantChipHoverRgb:"44, 44, 44",assistantChipSelectedRgb:"167, 59, 255",assistantChipSelectedTextRgb:"240, 240, 240",activeRgb:"167, 59, 255",activeTextRgb:"240, 240, 240",textMainRgb:"240, 240, 240",textMutedRgb:"166, 166, 166",dangerRgb:"126, 126, 126",scrollbarTrackRgb:"20, 20, 20",scrollbarThumbRgb:"30, 30, 30",scrollbarThumbHoverRgb:"30, 50, 30"},layout:{modeColumnWidthPx:406,modeToggleWidthPx:188}},hd="ndc_normalizer_session_config_v1",gd="ndc_autoruns_layout_config_v1",gp="ndc-autoruns-save",vp="autoruns",ba="normalizer_v2_0_2",yp="address_query_runtime_v1",xp=["normalized","fragments","scope","flags","route","raw","validation","logs"];function _p(a){return`[${new Date().toLocaleTimeString("ru-RU")}] ${a}`}function Sp(a,h){if(!h)return"Previous preset is not selected.";const T=["systemPrompt","developerPrompt","domainPrompt","schemaNotes","fewShotExamples"].filter(E=>a[E]!==h[E]).map(E=>`${E}: ${Math.abs(a[E].length-h[E].length)} chars delta`);return T.length===0?"No changes against previous preset.":`Changed fields: ${T.length}. ${T.join(" | ")}`}function wp(){const[a,h]=g.useState(mp),[p,T]=g.useState(md),[E,I]=g.useState(hp),[B,ae]=g.useState(null),[re,z]=g.useState([]),[Z,ee]=g.useState([]),[ne,Te]=g.useState("normalized"),[de,fe]=g.useState(!1),[he,Qe]=g.useState(!1),[Ke,He]=g.useState([]),[Me,$]=g.useState(""),[ie,je]=g.useState([]),[Ue,ht]=g.useState(""),[ut,Bt]=g.useState("NDC custom preset"),[ct,b]=g.useState(null),[Re,Ge]=g.useState(""),[se,te]=g.useState(!1),[R,F]=g.useState([]),[A,y]=g.useState(""),[k,oe]=g.useState([]),[ue,ce]=g.useState(!1),[ge,ye]=g.useState(null),[xe,Se]=g.useState(""),[dt,sn]=g.useState(vp),[gr,Ln]=g.useState(!0),[xn,Ee]=g.useState(!0),[Qt,st]=g.useState(!0),[gt,jt]=g.useState(!0),[_n,G]=g.useState(!0),[ft,vr]=g.useState(!0),[In,Ve]=g.useState(!0),[Ct,Mt]=g.useState(!0),[Dn,me]=g.useState(!0),[Nt,Je]=g.useState(!0),[vs,Ze]=g.useState(!0),[Zn,yr]=g.useState(!0),[on,On]=g.useState(!0),Rt=g.useRef(!1),Sn=g.useRef(!1),Ht=g.useRef(!1);g.useEffect(()=>{const C=document.documentElement,{colors:X}=Ua;C.style.setProperty("--rgb-background",X.backgroundRgb),C.style.setProperty("--rgb-surface-main",X.mainSurfaceRgb),C.style.setProperty("--rgb-surface-horizontal",X.horizontalSurfaceRgb),C.style.setProperty("--rgb-surface-focus",X.focusSurfaceRgb),C.style.setProperty("--rgb-assistant-chip",X.assistantChipRgb),C.style.setProperty("--rgb-assistant-chip-hover",X.assistantChipHoverRgb),C.style.setProperty("--rgb-assistant-chip-selected",X.assistantChipSelectedRgb),C.style.setProperty("--rgb-assistant-chip-selected-text",X.assistantChipSelectedTextRgb),C.style.setProperty("--rgb-active",X.activeRgb),C.style.setProperty("--rgb-active-text",X.activeTextRgb),C.style.setProperty("--rgb-text-main",X.textMainRgb),C.style.setProperty("--rgb-text-muted",X.textMutedRgb),C.style.setProperty("--rgb-danger",X.dangerRgb),C.style.setProperty("--rgb-scrollbar-track",X.scrollbarTrackRgb),C.style.setProperty("--rgb-scrollbar-thumb",X.scrollbarThumbRgb),C.style.setProperty("--rgb-scrollbar-thumb-hover",X.scrollbarThumbHoverRgb),C.style.setProperty("--mode-column-width",`${Ua.layout.modeColumnWidthPx}px`),C.style.setProperty("--mode-toggle-width",`${Ua.layout.modeToggleWidthPx}px`)},[]);const Y=C=>{ee(X=>[_p(C),...X].slice(0,300))};g.useEffect(()=>{(async()=>{const V=localStorage.getItem(hd);if(V)try{const Ce=JSON.parse(V);h(ot=>({...ot,llmProvider:Ce.llmProvider==="local"?"local":"openai",model:Ce.model??ot.model,baseUrl:Ce.baseUrl??ot.baseUrl,temperature:Ce.temperature??ot.temperature,maxOutputTokens:Ce.maxOutputTokens??ot.maxOutputTokens}))}catch{}try{const Ce=await Pe.loadSharedConnectionConfig();Ce.connection&&Ce.connection.llmProvider==="local"&&(h(ot=>({...ot,llmProvider:"local",model:Ce.connection?.model??ot.model,baseUrl:Ce.connection?.baseUrl??ot.baseUrl,temperature:Ce.connection?.temperature??ot.temperature,maxOutputTokens:Ce.connection?.maxOutputTokens??ot.maxOutputTokens})),Y(`Shared local LLM config loaded: ${Ce.connection.model}`))}catch(Ce){Y(`Shared local config load error: ${Ce instanceof Error?Ce.message:String(Ce)}`)}finally{Ht.current=!0}})();const X=localStorage.getItem(gd);if(X)try{const V=JSON.parse(X);(V.uiMode==="assistant"||V.uiMode==="autoruns"||V.uiMode==="decomposition")&&sn("autoruns"),V.activeTab&&xp.includes(V.activeTab)&&Te(V.activeTab),typeof V.showAutorunsSettingsMode=="boolean"&&Ln(V.showAutorunsSettingsMode),typeof V.showAutorunsAutoRunsMode=="boolean"&&Ee(V.showAutorunsAutoRunsMode),typeof V.showAutorunsAssistantMode=="boolean"&&st(V.showAutorunsAssistantMode),typeof V.showAutorunsDecompositionMode=="boolean"&&jt(V.showAutorunsDecompositionMode),typeof V.showAutorunsProgressMode=="boolean"&&G(V.showAutorunsProgressMode),typeof V.showAutorunsCommentsMode=="boolean"&&vr(V.showAutorunsCommentsMode),typeof V.showDecompositionConnectionMode=="boolean"&&Ve(V.showDecompositionConnectionMode),typeof V.showDecompositionPromptMode=="boolean"&&Mt(V.showDecompositionPromptMode),typeof V.showDecompositionQueryMode=="boolean"&&me(V.showDecompositionQueryMode),typeof V.showDecompositionOutputMode=="boolean"&&Je(V.showDecompositionOutputMode),typeof V.showDecompositionMetricsMode=="boolean"&&Ze(V.showDecompositionMetricsMode),typeof V.showDecompositionHistoryMode=="boolean"&&yr(V.showDecompositionHistoryMode),typeof V.showDecompositionRuntimeMode=="boolean"&&On(V.showDecompositionRuntimeMode),V.prompts&&(T(Ce=>({...Ce,...V.prompts})),Sn.current=!0)}catch{}ln(),er(),Hr()},[]),g.useEffect(()=>{if(!Ht.current||a.llmProvider!=="local")return;const C=window.setTimeout(()=>{Pe.saveSharedConnectionConfig(a).catch(X=>Y(`Shared local config sync error: ${X instanceof Error?X.message:String(X)}`))},250);return()=>window.clearTimeout(C)},[a.baseUrl,a.llmProvider,a.maxOutputTokens,a.model,a.temperature]);async function ln(){try{const C=await Pe.loadHistory();z(C.items??[])}catch(C){Y(`History load error: ${C instanceof Error?C.message:String(C)}`)}}async function er(){try{const X=(await Pe.loadPresets()).presets??[];if(je(X),Sn.current){Rt.current=!0;return}if(Rt.current)return;const V=X.find(Ce=>Ce.prompt_version===ba)??X.find(Ce=>Ce.id==="default-normalizer-v2_0_2");if(!V){Rt.current=!0,Y(`Preset autoload skipped: ${ba} not found.`);return}ht(V.id),b(p),T({systemPrompt:V.systemPrompt,developerPrompt:V.developerPrompt,domainPrompt:V.domainPrompt,schemaNotes:V.schemaNotes??"",fewShotExamples:V.fewShotExamples??""}),Rt.current=!0,Y(`Preset autoloaded: ${V.name} (${V.prompt_version}).`)}catch(C){Y(`Presets load error: ${C instanceof Error?C.message:String(C)}`)}}async function Hr(){try{const C=await Pe.listRuns();F(C.items??[])}catch(C){Y(`Runs load error: ${C instanceof Error?C.message:String(C)}`)}}function Vr(){if(localStorage.setItem(hd,JSON.stringify({model:a.model,llmProvider:a.llmProvider,baseUrl:a.baseUrl,temperature:a.temperature,maxOutputTokens:a.maxOutputTokens})),a.llmProvider==="local"){Pe.saveSharedConnectionConfig(a).then(()=>{Y("Local config saved and synced to shared agent config (without API key).")}).catch(C=>{Y(`Local config saved, but shared sync failed: ${C instanceof Error?C.message:String(C)}`)});return}Y("Local config saved (without API key).")}function Wr(){localStorage.setItem(gd,JSON.stringify({uiMode:dt,activeTab:ne,showAutorunsSettingsMode:gr,showAutorunsAutoRunsMode:xn,showAutorunsAssistantMode:Qt,showAutorunsDecompositionMode:gt,showAutorunsProgressMode:_n,showAutorunsCommentsMode:ft,showDecompositionConnectionMode:In,showDecompositionPromptMode:Ct,showDecompositionQueryMode:Dn,showDecompositionOutputMode:Nt,showDecompositionMetricsMode:vs,showDecompositionHistoryMode:Zn,showDecompositionRuntimeMode:on,prompts:p})),window.dispatchEvent(new CustomEvent(gp)),Y("UI layout and prompts saved.")}async function xr(){fe(!0),Se("");try{const C=await Pe.testConnection(a);C.provider==="local"?C.model_found===!0?($(`LOCAL OK - ${C.model}`),Y(`Local model is available: ${C.model} (catalog size=${C.models_count??"n/a"}).`)):C.model_found===!1?($(`LOCAL OK, model not loaded - ${C.model}`),Y(`Local server is reachable, but model '${C.model}' is not in loaded catalog. Use 'Load model list' and select one of loaded models.`)):($(`LOCAL OK (model list unavailable) - ${C.model}`),Y("Local server is reachable, but model catalog could not be verified.")):($(`OPENAI OK - ${C.model}`),Y(`OpenAI connection ok: ${C.model}`))}catch(C){const X=C instanceof Error?C.message:String(C);$("Connection error"),Se(`Test connection: ${X}`),Y(`Test connection error: ${X}`)}finally{fe(!1)}}async function wn(){Qe(!0);try{const X=(await Pe.listModels(a)).models??[];He(X),X.length>0&&h(V=>V.model&&X.includes(V.model)?V:{...V,model:X[0]}),Y(`Model catalog loaded (${a.llmProvider}): ${X.length} items.`)}catch(C){const X=C instanceof Error?C.message:String(C);Y(`Load model list error: ${X}`)}finally{Qe(!1)}}g.useEffect(()=>{He([])},[a.llmProvider,a.baseUrl]);function zn(){const C=ie.find(X=>X.id===Ue);if(!C){Y("Preset is not selected.");return}b(p),T({systemPrompt:C.systemPrompt,developerPrompt:C.developerPrompt,domainPrompt:C.domainPrompt,schemaNotes:C.schemaNotes??"",fewShotExamples:C.fewShotExamples??""}),Y(`Preset loaded: ${C.name}`)}async function $n(){try{await Pe.savePreset({name:ut||"NDC preset",prompt_version:"normalizer_v2_0_2",systemPrompt:p.systemPrompt,developerPrompt:p.developerPrompt,domainPrompt:p.domainPrompt,schemaNotes:p.schemaNotes,fewShotExamples:p.fewShotExamples}),Y("Preset saved."),await er()}catch(C){Y(`Preset save error: ${C instanceof Error?C.message:String(C)}`)}}function Fn(){T(md),Y("Prompt panel reset to defaults.")}function Un(){const C=Sp(p,ct);Ge(C),Y(C)}return g.useEffect(()=>{if(!A){oe([]);return}Pe.runTrace(A).then(C=>oe(C.items)).catch(C=>Y(`Run trace error: ${C instanceof Error?C.message:String(C)}`))},[A]),o.jsxs("main",{className:"app-root app-root-autoruns",children:[o.jsxs("header",{className:"app-topbar",children:[o.jsxs("div",{className:"mode-switch-row",children:[o.jsx("button",{type:"button",className:"tab active",onClick:()=>sn("autoruns"),children:"Управление ассистентом"}),o.jsx("button",{type:"button",className:"tab",onClick:Wr,children:"Сохранить"})]}),o.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[o.jsx("button",{type:"button",className:gr?"tab active":"tab",onClick:()=>Ln(C=>!C),children:"Настройки"}),o.jsx("button",{type:"button",className:xn?"tab active":"tab",onClick:()=>Ee(C=>!C),children:"Автопрогоны"}),o.jsx("button",{type:"button",className:Qt?"tab active":"tab",onClick:()=>st(C=>!C),children:"Режим ассистента"}),o.jsx("button",{type:"button",className:_n?"tab active":"tab",onClick:()=>G(C=>!C),children:"Прогресс/регресс"}),o.jsx("button",{type:"button",className:ft?"tab active":"tab",onClick:()=>vr(C=>!C),children:"Комментарии"})]})]}),o.jsx("div",{className:"layout-grid layout-grid-autoruns",children:o.jsx(pp,{connection:a,modelOptions:Ke,modelsBusy:he,connectionStatus:Me,connectionBusy:de,onConnectionChange:h,onReloadModels:wn,onSaveLocalConfig:Vr,onTestConnection:xr,prompts:p,onPromptsChange:T,promptPresets:ie,selectedPresetId:Ue,onSelectPreset:ht,onLoadPreset:zn,onSavePreset:$n,onResetDefaults:Fn,onDiffPrevious:Un,presetName:ut,onPresetNameChange:Bt,diffSummary:Re,assistantPromptVersion:yp,decompositionPromptVersion:ba,showSettingsMode:gr,showAutoRunsMode:xn,showAssistantMode:Qt,showProgressMode:_n,showCommentsMode:ft,onLog:Y})})]})}Af.createRoot(document.getElementById("root")).render(o.jsx(Cf.StrictMode,{children:o.jsx(wp,{})})); diff --git a/llm_normalizer/frontend/dist/assets/index-DNDajOYc.css b/llm_normalizer/frontend/dist/assets/index-DNDajOYc.css deleted file mode 100644 index 8ac182a..0000000 --- a/llm_normalizer/frontend/dist/assets/index-DNDajOYc.css +++ /dev/null @@ -1 +0,0 @@ -@import"https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=Space+Grotesk:wght@500;700&display=swap";:root{--rgb-background: 16, 16, 19;--rgb-surface-main: 26, 26, 31;--rgb-surface-horizontal: 32, 32, 38;--rgb-surface-focus: 40, 40, 47;--rgb-assistant-chip: 18, 18, 18;--rgb-assistant-chip-hover: 44, 44, 44;--rgb-assistant-chip-selected: 228, 142, 92;--rgb-assistant-chip-selected-text: 18, 18, 18;--rgb-active: 228, 142, 92;--rgb-active-text: 18, 18, 18;--rgb-text-main: 240, 240, 240;--rgb-text-muted: 166, 166, 170;--rgb-emerald: 126, 211, 154;--rgb-warning: 255, 196, 116;--rgb-danger: 255, 126, 126;--rgb-scrollbar-track: 31, 31, 36;--rgb-scrollbar-thumb: 74, 74, 82;--rgb-scrollbar-thumb-hover: 90, 90, 100;--mode-column-width: 440px;--mode-toggle-width: 188px;--bg-main: rgb(var(--rgb-background));--bg-soft: rgb(var(--rgb-surface-main));--bg-panel: rgb(var(--rgb-surface-main));--bg-panel-accent: rgb(var(--rgb-surface-horizontal));--surface-horizontal: rgb(var(--rgb-surface-horizontal));--surface-focus: rgb(var(--rgb-surface-focus));--line: transparent;--line-strong: rgba(var(--rgb-active), .48);--text-main: rgb(var(--rgb-text-main));--text-muted: rgb(var(--rgb-text-muted));--lime-main: rgb(var(--rgb-text-main));--lime-press: rgb(var(--rgb-text-main));--danger: rgb(var(--rgb-danger));--radius-lg: 20px;--radius-md: 14px;--shadow: none;--autoruns-col-width: var(--mode-column-width)}*{box-sizing:border-box;scrollbar-width:thin;scrollbar-color:rgb(var(--rgb-scrollbar-thumb)) rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar{width:10px;height:10px}*::-webkit-scrollbar-track{background:rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar-thumb{background:rgb(var(--rgb-scrollbar-thumb));border-radius:999px;border:2px solid rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar-thumb:hover{background:rgb(var(--rgb-scrollbar-thumb-hover))}html,body,#root{margin:0;min-height:100dvh;font-family:Manrope,Segoe UI,sans-serif;background:var(--bg-main);color:var(--text-main)}.app-root{max-width:1720px;margin:0 auto;padding:12px 16px 16px}.app-root.app-root-autoruns{max-width:none;width:100%;min-height:100dvh;max-height:100dvh;display:flex;flex-direction:column;overflow:hidden}.app-topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 12px;padding:0;min-height:38px}.layout-grid{display:grid;grid-template-columns:repeat(12,1fr);gap:16px}.layout-grid.layout-grid-autoruns,.layout-grid.layout-grid-mode-columns{min-height:0;flex:1 1 auto;grid-template-columns:minmax(0,1fr)}.mode-switch-row{display:flex;gap:8px;margin:0;padding:0}.mode-switch-row.mode-switch-row-right{margin-left:auto;justify-content:flex-end;max-width:72%;overflow-x:auto;overflow-y:hidden;padding-bottom:2px}.mode-switch-row .tab{white-space:nowrap}.mode-switch-row.mode-switch-row-right .tab{width:var(--mode-toggle-width);min-width:var(--mode-toggle-width);text-align:center}.mode-columns{display:flex;gap:12px;width:100%;min-height:0;flex:1 1 auto;overflow-x:auto;overflow-y:hidden;padding-bottom:4px}.mode-col{flex:0 0 var(--mode-column-width);width:var(--mode-column-width);min-height:0;height:100%;display:flex}.mode-col.mode-col-wide,.mode-col.mode-col-xwide{flex-basis:var(--mode-column-width);width:var(--mode-column-width)}.mode-col .panel-frame{width:100%;height:100%}.mode-col .panel-body{min-height:0;overflow:auto}.mode-columns-empty{min-width:360px;border-radius:14px;background:rgb(var(--rgb-surface-main));color:var(--text-muted);padding:14px}.panel-frame{grid-column:span 12;border:none;border-radius:var(--radius-lg);background:var(--bg-panel);overflow:hidden;box-shadow:none;animation:rise .4s ease-out;display:flex;flex-direction:column;min-height:0}.panel-header{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;padding:14px 18px 10px;border-bottom:none;background:var(--bg-panel-accent)}.panel-header h2{margin:0;font-size:1.02rem;letter-spacing:.02em}.panel-header p{margin:6px 0 0;font-size:.85rem;color:var(--text-muted)}.panel-body{padding:10px 12px 12px;min-height:0}.app-root-autoruns .autoruns-frame{height:100%}.app-root-autoruns .autoruns-frame .panel-body{flex:1 1 auto;overflow:hidden;display:flex;flex-direction:column;gap:10px;padding:10px 12px 12px;background:rgb(var(--rgb-background))}.status-chip{border:none;border-radius:999px;padding:4px 10px;color:var(--lime-main);font-size:.78rem;background:rgb(var(--rgb-surface-focus))}.assistant-toolbar{display:grid;gap:8px}.assistant-toolbar-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:center;gap:8px}.assistant-toolbar-meta{display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-toolbar-meta-right{margin-left:auto;display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0;flex-wrap:wrap}.assistant-live-status{color:var(--text-muted);font-size:.8rem;white-space:nowrap}.assistant-toolbar-error{margin:0}.assistant-copy-btn{width:100%;justify-self:stretch;background:transparent;border-color:transparent;color:var(--text-main);font-size:.6rem;line-height:1.1;white-space:nowrap;text-align:center;letter-spacing:0;padding:6px 8px;box-shadow:none;transform:none}.assistant-copy-btn:hover{background:rgb(var(--rgb-surface-focus));filter:none;box-shadow:none;transform:none}.assistant-copy-feedback{font-size:.76rem;color:var(--text-muted)}.assistant-copy-feedback.success{color:var(--lime-main)}.assistant-copy-feedback.error{color:var(--danger)}input,select,textarea,button{font-family:Manrope,sans-serif}label{display:flex;flex-direction:column;gap:6px;color:var(--text-muted);font-size:.84rem}input,select,textarea{border:none;border-radius:var(--radius-md);background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:10px 12px;outline:none;transition:background-color .18s ease}input:focus,select:focus,textarea:focus{border-color:transparent;box-shadow:none;outline:none;background:rgb(var(--rgb-surface-focus))}textarea{resize:vertical;min-height:86px;overflow-y:auto;overflow-x:hidden;scrollbar-gutter:stable}.assistant-input-textarea,.autoruns-personality-prompt{overflow-y:auto;overflow-x:hidden;scrollbar-gutter:stable both-edges;border-bottom-right-radius:6px}.assistant-input-textarea::-webkit-scrollbar-corner,.autoruns-personality-prompt::-webkit-scrollbar-corner{background:rgb(var(--rgb-surface-horizontal))}button{border:none;border-radius:999px;background:rgb(var(--rgb-surface-horizontal));color:rgb(var(--rgb-text-main));font-weight:700;font-size:.83rem;letter-spacing:.02em;cursor:pointer;padding:9px 14px;transition:background .2s ease,color .2s ease;outline:none;box-shadow:none}button:hover{border-color:transparent;background:rgb(var(--rgb-surface-focus))}button:disabled{opacity:.52;cursor:not-allowed}.button-row{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-top:12px}.checkbox-row{flex-direction:row;align-items:center;gap:8px;color:var(--text-main)}.grid-two{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.prompt-manager-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}.full-width{grid-column:1 / -1}.tab-row{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px}.tab{background:rgb(var(--rgb-surface-main));color:var(--text-main);border:none}.tab.active{border-color:transparent;background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-chat-list{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:8px;padding:10px;border:none;border-radius:12px;background:rgb(var(--rgb-surface-horizontal))}.assistant-chat-list .assistant-msg:first-child{margin-top:auto}.assistant-empty{padding:18px;text-align:center}.assistant-msg{border:none;border-radius:12px;background:rgb(var(--rgb-surface-focus));padding:8px 10px;display:grid;gap:6px;min-width:0}.assistant-msg.user{margin-left:12%;border-color:transparent;background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-msg.assistant{margin-right:12%;border-color:transparent}.assistant-msg.user .assistant-msg-head{color:rgba(var(--rgb-active-text),.9)}.assistant-msg.user .assistant-msg-body{color:rgb(var(--rgb-active-text))}.assistant-msg-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:0;font-size:.74rem;color:var(--text-muted)}.assistant-msg-head-main{flex:1 1 auto;min-width:0;display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-msg-head-actions{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto}.assistant-comment-btn{cursor:pointer}.assistant-comment-btn:disabled{opacity:.42;cursor:not-allowed}.assistant-msg.user .assistant-comment-btn{color:rgba(var(--rgb-active-text),.92)}.assistant-msg-body{display:grid;gap:10px;line-height:1.35;font-size:.84rem;min-width:0}.assistant-msg-block{display:grid;gap:4px;min-width:0}.assistant-msg-block.selectable{cursor:pointer;padding:8px 10px;border-radius:12px;transition:background .18s ease,color .18s ease}.assistant-msg-block.selectable:hover,.assistant-msg-block.selectable:focus-visible{background:rgba(var(--rgb-active),.18);outline:none}.assistant-msg-block.selectable.active{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-msg-block.selectable.active:hover,.assistant-msg-block.selectable.active:focus-visible{background:rgb(var(--rgb-active))}.assistant-msg-block.selectable.active .assistant-msg-line,.assistant-msg-block.selectable.active .assistant-msg-line strong{color:rgb(var(--rgb-active-text))}.assistant-msg-line{margin:0;white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere}.assistant-msg-line.heading{font-weight:700;letter-spacing:.01em}.assistant-msg-line.numbered{margin-top:2px}.assistant-msg-line strong{font-weight:800}.assistant-trace{margin-top:6px;color:var(--text-muted);font-size:.75rem}.assistant-debug{margin-top:8px}.assistant-debug summary{cursor:pointer;color:var(--lime-main);font-size:.8rem}.assistant-compose{margin-top:0;display:grid;gap:8px;flex:0 0 auto}.assistant-compose-context{display:grid;gap:6px;padding:10px 12px;border-radius:var(--radius-md);background:rgb(var(--rgb-surface-horizontal))}.assistant-compose-context-label{color:var(--text-muted);font-size:.74rem;font-weight:700;letter-spacing:.01em}.assistant-compose-context-pill{display:inline-flex;align-items:center;gap:8px;max-width:100%;width:fit-content;min-height:38px;padding:0 10px 0 12px;border-radius:999px;background:rgb(var(--rgb-assistant-chip-selected));color:rgb(var(--rgb-assistant-chip-selected-text))}.assistant-compose-context-pill-text{min-width:0;max-width:min(100%,460px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.82rem;font-weight:700}.assistant-compose-context-clear{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;min-width:24px;padding:0;border-radius:999px;background:#0000002e;color:inherit;font-size:.96rem;line-height:1}.assistant-compose-context-clear:hover{background:#00000047}.assistant-send-row{align-items:center;margin-top:2px}.assistant-send-btn{margin-left:auto}.assistant-comments-frame .panel-body{display:flex;flex-direction:column;min-height:0;overflow:hidden}.assistant-comments-shell{display:grid;gap:8px;min-height:0;height:100%}.assistant-comments-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-comments-list{display:grid;gap:8px;overflow:auto;min-height:0;padding-right:2px}.assistant-comment-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:6px}.assistant-comment-head{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:.75rem}.assistant-comment-item p{margin:0;white-space:pre-wrap;font-size:.8rem}.assistant-comment-meta{display:flex;flex-wrap:wrap;gap:8px;color:var(--text-muted);font-size:.74rem}.app-root-autoruns .assistant-panel-frame .panel-header{position:sticky;top:-12px;z-index:8;margin:-12px -12px 0;padding:12px 12px 10px;background:rgb(var(--rgb-surface-main))}.app-root-autoruns .assistant-panel-frame{overflow:visible}.app-root-autoruns .assistant-panel-frame .panel-body{flex:1 1 auto;padding:0 12px 12px;display:flex;flex-direction:column;min-height:0;overflow:hidden}.app-root-autoruns .assistant-panel-frame .assistant-live-shell{flex:1 1 auto;min-height:0;padding:12px;border-radius:14px;background:rgb(var(--rgb-background));display:flex;flex-direction:column;gap:10px}.app-root-autoruns .assistant-panel-frame .assistant-chat-list{overflow-y:auto}.app-root-autoruns .assistant-panel-frame .panel-header h2{margin:0;font-size:.95rem}.json-view{margin:0;width:100%;min-height:180px;max-height:420px;overflow:auto;background:rgb(var(--rgb-surface-horizontal));border:none;border-radius:var(--radius-md);padding:12px;color:rgb(var(--rgb-text-main));font-family:JetBrains Mono,Consolas,monospace;font-size:.78rem;line-height:1.45}.metrics-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}.metrics-grid div{background:rgba(var(--rgb-surface-main),.8);border:none;border-radius:12px;padding:10px;display:flex;flex-direction:column;gap:4px}.metrics-grid span{color:var(--text-muted);font-size:.75rem}.metrics-grid strong{font-size:.84rem;color:var(--lime-main)}.history-list{display:grid;gap:8px;max-height:340px;overflow:auto}.history-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-main));color:var(--text-main);padding:10px}.history-item p{margin:8px 0;color:var(--text-muted);font-size:.82rem}.history-item.selected{border-color:var(--line-strong)}.history-row{display:flex;justify-content:space-between;gap:8px;font-size:.76rem;color:var(--text-muted)}.runtime-grid{display:grid;grid-template-columns:1.2fr 1fr;gap:12px}.runtime-stack{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}.runtime-details{display:grid;gap:12px}.runtime-runs{max-height:360px;overflow:auto;display:grid;gap:8px}.eval-report-wrap{position:relative}.copy-cube-button{position:absolute;right:10px;bottom:10px;width:34px;height:34px;border-radius:10px;padding:0;min-width:34px;display:grid;place-items:center;font-size:.92rem;line-height:1}.muted{color:var(--text-muted)}.diff-summary{margin-top:10px;font-size:.82rem;color:var(--lime-main)}.error-text{margin-top:10px;color:var(--danger);font-size:.84rem}.autoruns-columns{display:flex;gap:12px;width:100%;min-height:0;flex:1 1 auto;overflow-x:auto;overflow-y:hidden;padding-bottom:4px}.autoruns-col{flex:0 0 var(--mode-column-width);width:var(--mode-column-width);height:100%;min-height:0;overflow-y:auto;overflow-x:hidden;border:none;border-radius:14px;background:rgb(var(--rgb-surface-main));padding:12px;scrollbar-gutter:stable}.autoruns-settings-col{display:flex;flex-direction:column}.autoruns-settings-stack{display:grid;gap:12px}.embedded-panel-section{display:grid;gap:12px;border-radius:12px;background:rgb(var(--rgb-surface-horizontal));padding:12px}.embedded-panel-section-header{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.embedded-panel-section-header h4{margin:0;color:var(--text-main);font-size:.92rem}.embedded-panel-section-header p{margin:6px 0 0;color:var(--text-muted);font-size:.78rem;line-height:1.4}.autoruns-assistant-live-col{background:rgb(var(--rgb-surface-main));padding:12px;overflow:hidden;scrollbar-gutter:auto}.autoruns-assistant-live-col .panel-frame{height:100%;background:rgb(var(--rgb-surface-main))}.autoruns-col h3{margin:0;font-size:.95rem}.autoruns-col h4{margin:12px 0 8px;font-size:.82rem;color:var(--text-muted)}.autoruns-col-header{position:sticky;top:-12px;z-index:8;margin:-12px -12px 10px;padding:12px 12px 10px;background:rgb(var(--rgb-surface-main))}.autoruns-col-header .tab-row{margin:8px 0 0}.autoruns-col-header .autoruns-dialog-toolbar{margin-top:8px}.autoruns-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.autoruns-meta-list{display:grid;gap:8px}.autoruns-meta-list>div{display:flex;justify-content:space-between;gap:8px;border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px 9px;font-size:.79rem}.autoruns-meta-list span{color:var(--text-muted)}.autoruns-prompt-details summary{cursor:pointer;color:var(--text-main);font-size:.8rem;margin-bottom:8px}.autoruns-prompt-details textarea{min-height:68px}.autoruns-stats-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:10px}.autoruns-stats-grid>div{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:3px}.autoruns-stats-grid span{color:var(--text-muted);font-size:.74rem}.autoruns-stats-grid strong{color:var(--lime-main);font-size:.84rem}.autoruns-run-list{display:grid;gap:8px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;padding-right:2px}.autoruns-run-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:10px;display:grid;gap:5px;transition:background-color .2s ease,box-shadow .2s ease}.autoruns-run-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text));box-shadow:none}.autoruns-run-item.selected .autoruns-run-meta{color:rgba(var(--rgb-active-text),.95)}.autoruns-run-head,.autoruns-run-foot{display:flex;justify-content:space-between;gap:8px;font-size:.76rem}.autoruns-run-meta{color:var(--text-muted);font-size:.75rem;word-break:break-word}.autoruns-run-id-row{display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0}.autoruns-run-id-row>span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-copy-run-id-btn{border:none;background:transparent;color:rgb(var(--rgb-text-main));width:16px;height:16px;min-width:16px;min-height:16px;padding:0;display:inline-flex;align-items:center;justify-content:center;border-radius:4px;opacity:.92;cursor:pointer}.autoruns-copy-run-id-btn:hover{color:rgb(var(--rgb-text-main));opacity:1;background:transparent;box-shadow:none;transform:none}.autoruns-copy-run-id-btn:focus-visible{outline:1px solid rgba(var(--rgb-text-main),.7);outline-offset:1px}.autoruns-copy-icon-svg{width:.82rem;height:.82rem;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.autoruns-dialog-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.autoruns-case-list{margin-top:8px;display:grid;gap:6px;max-height:180px;overflow:auto}.autoruns-case-item{width:100%;text-align:left;border-radius:10px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:7px 8px;display:flex;justify-content:space-between;gap:6px;font-size:.76rem}.autoruns-case-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text));box-shadow:none}.autoruns-dialog-view{margin-top:10px;border:none;border-radius:12px;background:rgb(var(--rgb-surface-horizontal));padding:10px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;display:grid;gap:8px}.autoruns-msg{border:none;border-radius:12px;background:rgb(var(--rgb-surface-focus));padding:8px 10px;display:grid;gap:6px;min-width:0;overflow:hidden}.autoruns-msg header,.autoruns-msg footer{display:flex;justify-content:space-between;align-items:flex-start;flex-wrap:wrap;min-width:0;gap:8px;font-size:.74rem;color:var(--text-muted)}.autoruns-msg-head-actions{display:flex;align-items:center;justify-content:flex-end;flex:1 1 auto;min-width:0;flex-wrap:wrap;gap:8px}.autoruns-msg-head-actions>span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-msg-case-tag{display:inline-flex;align-items:center;border-radius:999px;padding:2px 8px;font-size:.7rem;line-height:1;color:rgb(var(--rgb-active-text));background:rgba(var(--rgb-active),.24)}.autoruns-msg p{margin:0;white-space:pre-wrap;line-height:1.35;font-size:.84rem;overflow-wrap:anywhere;word-break:break-word}.autoruns-msg footer span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-comment-icon{border:none;background:transparent;color:rgb(var(--rgb-text-main));border-radius:0;min-width:16px;min-height:16px;width:16px;height:16px;padding:0;line-height:1;box-shadow:none;transform:none;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;opacity:.92}.autoruns-comment-icon:hover{background:transparent;color:rgb(var(--rgb-text-main));opacity:1;box-shadow:none;transform:none}.autoruns-comment-icon.commented{color:rgb(var(--rgb-active));background:transparent;box-shadow:none}.autoruns-comment-icon:focus-visible{outline:1px solid rgba(var(--rgb-text-main),.7);outline-offset:1px}.autoruns-comment-icon:disabled{opacity:.42;cursor:not-allowed}.comment-icon-svg{width:.82rem;height:.82rem;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round;fill:none}.comment-icon-svg.commented{stroke:rgb(var(--rgb-active));fill:none}.autoruns-resolve-toggle{border:none;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));border-radius:999px;width:22px;height:22px;min-width:22px;min-height:22px;padding:0;display:inline-flex;align-items:center;justify-content:center;box-shadow:none;transform:none}.autoruns-resolve-toggle:hover{background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-active));box-shadow:none;transform:none}.autoruns-resolve-toggle:disabled{opacity:.55;cursor:wait}.autoruns-resolve-toggle.resolved{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.resolve-icon-svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.resolve-icon-svg.resolved{fill:currentColor}.autoruns-msg-annotation{display:grid;gap:4px;border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:7px 8px;font-size:.78rem}.autoruns-comments-list{display:grid;gap:8px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;padding-right:2px;margin-top:6px}.autoruns-autogen-list{display:grid;gap:8px;max-height:none;min-height:0;overflow:auto;padding-right:2px}.autoruns-autogen-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:5px;cursor:pointer}.autoruns-autogen-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-autogen-item.selected .autoruns-run-meta,.autoruns-autogen-item.selected p{color:rgba(var(--rgb-active-text),.95)}.autoruns-autogen-item header{display:flex;justify-content:space-between;gap:8px;font-size:.76rem}.autoruns-autogen-item p{margin:0;color:var(--text-muted);white-space:pre-wrap;font-size:.8rem}.autoruns-run-launch-btn{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-run-launch-btn:hover{background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main))}.autoruns-run-launch-btn:disabled{background:rgba(var(--rgb-active),.38);color:rgba(var(--rgb-active-text),.88)}.autoruns-generated-questions{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:8px}.autoruns-generated-questions-head{display:flex;align-items:center;justify-content:space-between;gap:8px}.autoruns-generated-questions-list{display:grid;gap:6px;max-height:220px;overflow:auto;padding-right:2px}.autoruns-generated-question-item{position:relative;display:grid;grid-template-columns:22px minmax(0,1fr) auto;align-items:start;gap:8px;border:none;border-radius:9px;background:rgb(var(--rgb-surface-focus));padding:7px 8px;font-size:.78rem;transition:background .15s ease,outline-color .15s ease,opacity .15s ease}.autoruns-generated-question-item.drag-over{outline:1px solid rgba(var(--rgb-active),.75)}.autoruns-generated-question-item.dragging{opacity:.72}.autoruns-generated-question-item.editing{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-question-grip-btn{width:18px;min-width:18px;height:18px;padding:0;border:none;border-radius:6px;background:transparent;color:var(--text-muted);display:inline-flex;align-items:center;justify-content:center;cursor:grab;margin-top:1px}.autoruns-question-grip-btn:hover:not(:disabled){color:rgb(var(--rgb-text-main));background:rgba(var(--rgb-background),.3)}.autoruns-generated-question-item.editing .autoruns-question-grip-btn{color:rgba(var(--rgb-active-text),.9)}.autoruns-generated-question-item.editing .autoruns-question-grip-btn:hover:not(:disabled){color:rgb(var(--rgb-active-text));background:rgba(var(--rgb-active-text),.14)}.autoruns-question-grip-btn:disabled{cursor:default;opacity:.45}.autoruns-question-grip-svg{width:14px;height:14px;fill:currentColor}.autoruns-generated-question-text{border:none;background:transparent;color:rgb(var(--rgb-text-main));padding:0;margin:0;text-align:left;font:inherit;white-space:pre-wrap;line-height:1.4;cursor:text}.autoruns-generated-question-text:hover{color:rgb(var(--rgb-active))}.autoruns-generated-question-input{width:100%;min-width:0;border:none;border-radius:8px;background:rgba(var(--rgb-background),.55);color:rgb(var(--rgb-text-main));padding:6px 8px;font:inherit;line-height:1.4}.autoruns-generated-question-input:focus{outline:none}.autoruns-generated-question-item.editing .autoruns-generated-question-input{background:rgba(var(--rgb-active-text),.14);color:rgb(var(--rgb-active-text))}.autoruns-generated-question-item.editing .autoruns-generated-question-input::placeholder{color:rgba(var(--rgb-active-text),.78)}.autoruns-add-question-btn{width:100%;min-height:30px;border-radius:8px;border:none;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));font-size:1.1rem;font-weight:700;line-height:1}.autoruns-add-question-btn:hover:not(:disabled){background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-add-question-btn:disabled{opacity:.5;cursor:default}.autoruns-remove-question-btn{flex:0 0 auto;border:none;border-radius:0;background:transparent;color:rgb(var(--rgb-text-main));min-width:16px;width:16px;height:16px;padding:0;font-size:1rem;font-weight:700;line-height:1;display:inline-flex;align-items:center;justify-content:center;box-shadow:none;transition:color .15s ease;align-self:start}.autoruns-remove-question-btn:hover{background:transparent;color:rgb(var(--rgb-active));box-shadow:none}.autoruns-generated-question-item.editing .autoruns-remove-question-btn{color:rgb(var(--rgb-active-text))}.autoruns-generated-question-item.editing .autoruns-remove-question-btn:hover{color:rgba(var(--rgb-active-text),.82)}.autoruns-remove-question-btn:focus-visible{outline:none}.autoruns-personality-prompt{resize:vertical;min-height:110px}.autoruns-comment-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:9px;display:grid;gap:6px;cursor:pointer}.autoruns-comment-item p{margin:0;white-space:pre-wrap;color:var(--text-muted);font-size:.79rem}.autoruns-comment-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-comment-item.selected p,.autoruns-comment-item.selected .autoruns-run-meta,.autoruns-comment-item.selected .muted{color:rgba(var(--rgb-active-text),.94)}.autoruns-comment-item.selected .autoruns-resolve-toggle{background:rgba(var(--rgb-active-text),.18);color:rgb(var(--rgb-active-text))}.autoruns-comment-head{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:.75rem}.autoruns-comment-head-actions{display:inline-flex;align-items:center;gap:8px}.autoruns-comment-filter-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:10px;margin-bottom:8px}.autoruns-resolved-filter-toggle{min-height:38px;white-space:nowrap}.autoruns-msg.assistant{margin-right:12%}.autoruns-msg.user{margin-left:12%;border-color:transparent;background:rgb(var(--rgb-surface-focus))}.autoruns-decomposition-list{margin:0;padding-left:18px;display:grid;gap:7px;font-size:.8rem}.autoruns-comment-modal-backdrop{position:fixed;inset:0;background:rgba(var(--rgb-background),.74);display:grid;place-items:center;z-index:1800;padding:12px}.autoruns-comment-modal{width:min(660px,100%);border:none;border-radius:16px;background:rgb(var(--rgb-surface-horizontal));box-shadow:var(--shadow);padding:14px;display:grid;gap:10px}.autoruns-comment-modal h3{margin:0;font-size:.95rem}.autoruns-comment-quote{margin:0;border:none;border-radius:10px;background:rgb(var(--rgb-surface-focus));padding:8px;white-space:pre-wrap;max-height:150px;overflow:auto;font-size:.82rem}.autoruns-rating-row{display:flex;gap:8px}.autoruns-rating-dot{width:34px;height:34px;border-radius:999px;padding:0;border:none;background:rgb(var(--rgb-surface-focus));color:var(--text-muted);font-size:.95rem;box-shadow:none;transform:none}.autoruns-rating-dot:hover{border-color:var(--line-strong);box-shadow:none;transform:none}.autoruns-rating-dot.active{border-color:var(--line-strong);color:rgb(var(--rgb-active-text));background:rgb(var(--rgb-active))}.autoruns-coverage-list{display:grid;gap:8px}.autoruns-coverage-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px}.autoruns-coverage-head{display:flex;justify-content:space-between;gap:8px;font-size:.76rem;margin-bottom:5px}.autoruns-coverage-head span{color:var(--text-muted)}.autoruns-coverage-bar{height:7px;border-radius:999px;background:rgb(var(--rgb-surface-focus));overflow:hidden}.autoruns-coverage-bar>div{height:100%;border-radius:999px;background:rgb(var(--rgb-active))}.autoruns-autogen-card-actions{display:inline-flex;align-items:center;gap:8px}.autoruns-autogen-delete-btn{border:none;border-radius:0;width:22px;height:22px;min-width:22px;padding:0;background:transparent;color:rgb(var(--rgb-text-main));display:inline-flex;align-items:center;justify-content:center;font-size:1rem;font-weight:700;line-height:1;box-shadow:none;transition:color .15s ease}.autoruns-autogen-delete-btn:hover{background:transparent;color:rgb(var(--rgb-active));box-shadow:none}.autoruns-agent-acceptance{display:grid;gap:6px;margin-top:6px}.autoruns-agent-pill-row{display:flex;flex-wrap:wrap;gap:6px}.autoruns-agent-pill{display:inline-flex;align-items:center;justify-content:center;min-height:24px;padding:0 8px;border-radius:999px;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));font-size:.73rem;line-height:1;border:1px solid rgba(var(--rgb-text-main),.1)}.autoruns-agent-pill.neutral{color:var(--text-muted)}.autoruns-agent-pill.status-accepted{color:rgb(var(--rgb-emerald));border-color:rgba(var(--rgb-emerald),.32)}.autoruns-agent-pill.status-partial{color:rgb(var(--rgb-warning));border-color:rgba(var(--rgb-warning),.32)}.autoruns-agent-pill.status-blocked{color:rgb(var(--rgb-danger));border-color:rgba(var(--rgb-danger),.32)}.autoruns-agent-pill.status-unknown{color:var(--text-muted)}@media(max-width:1200px){:root{--mode-column-width: 400px}.metrics-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:920px){:root{--mode-column-width: 360px}.grid-two,.runtime-grid,.runtime-stack{grid-template-columns:1fr}.metrics-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.autoruns-form-grid,.autoruns-dialog-toolbar,.autoruns-stats-grid,.autoruns-comment-filter-row{grid-template-columns:1fr}}@media(max-width:640px){:root{--mode-column-width: 320px}.app-root{padding:18px 12px 24px}.metrics-grid{grid-template-columns:1fr}}@keyframes rise{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}} diff --git a/llm_normalizer/frontend/dist/assets/index-DkvyfMZP.css b/llm_normalizer/frontend/dist/assets/index-DkvyfMZP.css new file mode 100644 index 0000000..a55efe8 --- /dev/null +++ b/llm_normalizer/frontend/dist/assets/index-DkvyfMZP.css @@ -0,0 +1 @@ +@import"https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=Space+Grotesk:wght@500;700&display=swap";:root{--rgb-background: 16, 16, 19;--rgb-surface-main: 26, 26, 31;--rgb-surface-horizontal: 32, 32, 38;--rgb-surface-focus: 40, 40, 47;--rgb-assistant-chip: 18, 18, 18;--rgb-assistant-chip-hover: 44, 44, 44;--rgb-assistant-chip-selected: 228, 142, 92;--rgb-assistant-chip-selected-text: 18, 18, 18;--rgb-active: 228, 142, 92;--rgb-active-text: 18, 18, 18;--rgb-text-main: 240, 240, 240;--rgb-text-muted: 166, 166, 170;--rgb-emerald: 126, 211, 154;--rgb-warning: 255, 196, 116;--rgb-danger: 255, 126, 126;--rgb-scrollbar-track: 31, 31, 36;--rgb-scrollbar-thumb: 74, 74, 82;--rgb-scrollbar-thumb-hover: 90, 90, 100;--mode-column-width: 440px;--mode-toggle-width: 188px;--bg-main: rgb(var(--rgb-background));--bg-soft: rgb(var(--rgb-surface-main));--bg-panel: rgb(var(--rgb-surface-main));--bg-panel-accent: rgb(var(--rgb-surface-horizontal));--surface-horizontal: rgb(var(--rgb-surface-horizontal));--surface-focus: rgb(var(--rgb-surface-focus));--line: transparent;--line-strong: rgba(var(--rgb-active), .48);--text-main: rgb(var(--rgb-text-main));--text-muted: rgb(var(--rgb-text-muted));--lime-main: rgb(var(--rgb-text-main));--lime-press: rgb(var(--rgb-text-main));--danger: rgb(var(--rgb-danger));--radius-lg: 20px;--radius-md: 14px;--shadow: none;--autoruns-col-width: var(--mode-column-width)}*{box-sizing:border-box;scrollbar-width:thin;scrollbar-color:rgb(var(--rgb-scrollbar-thumb)) rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar{width:10px;height:10px}*::-webkit-scrollbar-track{background:rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar-thumb{background:rgb(var(--rgb-scrollbar-thumb));border-radius:999px;border:2px solid rgb(var(--rgb-scrollbar-track))}*::-webkit-scrollbar-thumb:hover{background:rgb(var(--rgb-scrollbar-thumb-hover))}html,body,#root{margin:0;min-height:100dvh;font-family:Manrope,Segoe UI,sans-serif;background:var(--bg-main);color:var(--text-main)}.app-root{max-width:1720px;margin:0 auto;padding:12px 16px 16px}.app-root.app-root-autoruns{max-width:none;width:100%;min-height:100dvh;max-height:100dvh;display:flex;flex-direction:column;overflow:hidden}.app-topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 12px;padding:0;min-height:38px}.layout-grid{display:grid;grid-template-columns:repeat(12,1fr);gap:16px}.layout-grid.layout-grid-autoruns,.layout-grid.layout-grid-mode-columns{min-height:0;flex:1 1 auto;grid-template-columns:minmax(0,1fr)}.mode-switch-row{display:flex;gap:8px;margin:0;padding:0}.mode-switch-row.mode-switch-row-right{margin-left:auto;justify-content:flex-end;max-width:72%;overflow-x:auto;overflow-y:hidden;padding-bottom:2px}.mode-switch-row .tab{white-space:nowrap}.mode-switch-row.mode-switch-row-right .tab{width:var(--mode-toggle-width);min-width:var(--mode-toggle-width);text-align:center}.mode-columns{display:flex;gap:12px;width:100%;min-height:0;flex:1 1 auto;overflow-x:auto;overflow-y:hidden;padding-bottom:4px}.mode-col{flex:0 0 var(--mode-column-width);width:var(--mode-column-width);min-height:0;height:100%;display:flex}.mode-col.mode-col-wide,.mode-col.mode-col-xwide{flex-basis:var(--mode-column-width);width:var(--mode-column-width)}.mode-col .panel-frame{width:100%;height:100%}.mode-col .panel-body{min-height:0;overflow:auto}.mode-columns-empty{min-width:360px;border-radius:14px;background:rgb(var(--rgb-surface-main));color:var(--text-muted);padding:14px}.panel-frame{grid-column:span 12;border:none;border-radius:var(--radius-lg);background:var(--bg-panel);overflow:hidden;box-shadow:none;animation:rise .4s ease-out;display:flex;flex-direction:column;min-height:0}.panel-header{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;padding:14px 18px 10px;border-bottom:none;background:var(--bg-panel-accent)}.panel-header h2{margin:0;font-size:1.02rem;letter-spacing:.02em}.panel-header p{margin:6px 0 0;font-size:.85rem;color:var(--text-muted)}.panel-body{padding:10px 12px 12px;min-height:0}.app-root-autoruns .autoruns-frame{height:100%}.app-root-autoruns .autoruns-frame .panel-body{flex:1 1 auto;overflow:hidden;display:flex;flex-direction:column;gap:10px;padding:10px 12px 12px;background:rgb(var(--rgb-background))}.status-chip{border:none;border-radius:999px;padding:4px 10px;color:var(--lime-main);font-size:.78rem;background:rgb(var(--rgb-surface-focus))}.assistant-toolbar{display:grid;gap:8px}.assistant-toolbar-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:center;gap:8px}.assistant-toolbar-meta{display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-toolbar-meta-right{margin-left:auto;display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0;flex-wrap:wrap}.assistant-live-status{color:var(--text-muted);font-size:.8rem;white-space:nowrap}.assistant-toolbar-error{margin:0}.assistant-copy-btn{width:100%;justify-self:stretch;background:transparent;border-color:transparent;color:var(--text-main);font-size:.6rem;line-height:1.1;white-space:nowrap;text-align:center;letter-spacing:0;padding:6px 8px;box-shadow:none;transform:none}.assistant-copy-btn:hover{background:rgb(var(--rgb-surface-focus));filter:none;box-shadow:none;transform:none}.assistant-copy-feedback{font-size:.76rem;color:var(--text-muted)}.assistant-copy-feedback.success{color:var(--lime-main)}.assistant-copy-feedback.error{color:var(--danger)}input,select,textarea,button{font-family:Manrope,sans-serif}label{display:flex;flex-direction:column;gap:6px;color:var(--text-muted);font-size:.84rem}input,select,textarea{border:none;border-radius:var(--radius-md);background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:10px 12px;outline:none;transition:background-color .18s ease}input:focus,select:focus,textarea:focus{border-color:transparent;box-shadow:none;outline:none;background:rgb(var(--rgb-surface-focus))}textarea{resize:vertical;min-height:86px;overflow-y:auto;overflow-x:hidden;scrollbar-gutter:stable}.assistant-input-textarea,.autoruns-personality-prompt{overflow-y:auto;overflow-x:hidden;scrollbar-gutter:stable both-edges;border-bottom-right-radius:6px}.assistant-input-textarea::-webkit-scrollbar-corner,.autoruns-personality-prompt::-webkit-scrollbar-corner{background:rgb(var(--rgb-surface-horizontal))}button{border:none;border-radius:999px;background:rgb(var(--rgb-surface-horizontal));color:rgb(var(--rgb-text-main));font-weight:700;font-size:.83rem;letter-spacing:.02em;cursor:pointer;padding:9px 14px;transition:background .2s ease,color .2s ease;outline:none;box-shadow:none}button:hover{border-color:transparent;background:rgb(var(--rgb-surface-focus))}button:disabled{opacity:.52;cursor:not-allowed}.button-row{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-top:12px}.checkbox-row{flex-direction:row;align-items:center;gap:8px;color:var(--text-main)}.grid-two{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.prompt-manager-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}.full-width{grid-column:1 / -1}.tab-row{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px}.tab{background:rgb(var(--rgb-surface-main));color:var(--text-main);border:none}.tab.active{border-color:transparent;background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-chat-list{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:8px;padding:10px;border:none;border-radius:12px;background:rgb(var(--rgb-surface-horizontal))}.assistant-chat-list .assistant-msg:first-child{margin-top:auto}.assistant-empty{padding:18px;text-align:center}.assistant-msg{border:none;border-radius:12px;background:rgb(var(--rgb-surface-focus));padding:8px 10px;display:grid;gap:6px;min-width:0}.assistant-msg.user{margin-left:12%;border-color:transparent;background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-msg.assistant{margin-right:12%;border-color:transparent}.assistant-msg.user .assistant-msg-head{color:rgba(var(--rgb-active-text),.9)}.assistant-msg.user .assistant-msg-body{color:rgb(var(--rgb-active-text))}.assistant-msg-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:0;font-size:.74rem;color:var(--text-muted)}.assistant-msg-head-main{flex:1 1 auto;min-width:0;display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-msg-head-actions{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto}.assistant-comment-btn{cursor:pointer}.assistant-comment-btn:disabled{opacity:.42;cursor:not-allowed}.assistant-msg.user .assistant-comment-btn{color:rgba(var(--rgb-active-text),.92)}.assistant-msg-body{display:grid;gap:10px;line-height:1.35;font-size:.84rem;min-width:0}.assistant-msg-block{display:grid;gap:4px;min-width:0}.assistant-msg-block.selectable{cursor:pointer;padding:8px 10px;border-radius:12px;transition:background .18s ease,color .18s ease}.assistant-msg-block.selectable:hover,.assistant-msg-block.selectable:focus-visible{background:rgba(var(--rgb-active),.18);outline:none}.assistant-msg-block.selectable.active{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.assistant-msg-block.selectable.active:hover,.assistant-msg-block.selectable.active:focus-visible{background:rgb(var(--rgb-active))}.assistant-msg-block.selectable.active .assistant-msg-line,.assistant-msg-block.selectable.active .assistant-msg-line strong{color:rgb(var(--rgb-active-text))}.assistant-msg-line{margin:0;white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere}.assistant-msg-line.heading{font-weight:700;letter-spacing:.01em}.assistant-msg-line.numbered{margin-top:2px}.assistant-msg-line strong{font-weight:800}.assistant-trace{margin-top:6px;color:var(--text-muted);font-size:.75rem}.assistant-debug{margin-top:8px}.assistant-debug summary{cursor:pointer;color:var(--lime-main);font-size:.8rem}.assistant-compose{margin-top:0;display:grid;gap:8px;flex:0 0 auto}.assistant-compose-context{display:grid;gap:6px;padding:10px 12px;border-radius:var(--radius-md);background:rgb(var(--rgb-surface-horizontal))}.assistant-compose-context-label{color:var(--text-muted);font-size:.74rem;font-weight:700;letter-spacing:.01em}.assistant-compose-context-pill{display:inline-flex;align-items:center;gap:8px;max-width:100%;width:fit-content;min-height:38px;padding:0 10px 0 12px;border-radius:999px;background:rgb(var(--rgb-assistant-chip-selected));color:rgb(var(--rgb-assistant-chip-selected-text))}.assistant-compose-context-pill-text{min-width:0;max-width:min(100%,460px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.82rem;font-weight:700}.assistant-compose-context-clear{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;min-width:24px;padding:0;border-radius:999px;background:#0000002e;color:inherit;font-size:.96rem;line-height:1}.assistant-compose-context-clear:hover{background:#00000047}.assistant-send-row{align-items:center;margin-top:2px}.assistant-send-btn{margin-left:auto}.assistant-comments-frame .panel-body{display:flex;flex-direction:column;min-height:0;overflow:hidden}.assistant-comments-shell{display:grid;gap:8px;min-height:0;height:100%}.assistant-comments-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px}.assistant-comments-list{display:grid;gap:8px;overflow:auto;min-height:0;padding-right:2px}.assistant-comment-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:6px}.assistant-comment-head{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:.75rem}.assistant-comment-item p{margin:0;white-space:pre-wrap;font-size:.8rem}.assistant-comment-meta{display:flex;flex-wrap:wrap;gap:8px;color:var(--text-muted);font-size:.74rem}.app-root-autoruns .assistant-panel-frame .panel-header{position:sticky;top:-12px;z-index:8;margin:-12px -12px 0;padding:12px 12px 10px;background:rgb(var(--rgb-surface-main))}.app-root-autoruns .assistant-panel-frame{overflow:visible}.app-root-autoruns .assistant-panel-frame .panel-body{flex:1 1 auto;padding:0 12px 12px;display:flex;flex-direction:column;min-height:0;overflow:hidden}.app-root-autoruns .assistant-panel-frame .assistant-live-shell{flex:1 1 auto;min-height:0;padding:12px;border-radius:14px;background:rgb(var(--rgb-background));display:flex;flex-direction:column;gap:10px}.app-root-autoruns .assistant-panel-frame .assistant-chat-list{overflow-y:auto}.app-root-autoruns .assistant-panel-frame .panel-header h2{margin:0;font-size:.95rem}.json-view{margin:0;width:100%;min-height:180px;max-height:420px;overflow:auto;background:rgb(var(--rgb-surface-horizontal));border:none;border-radius:var(--radius-md);padding:12px;color:rgb(var(--rgb-text-main));font-family:JetBrains Mono,Consolas,monospace;font-size:.78rem;line-height:1.45}.metrics-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}.metrics-grid div{background:rgba(var(--rgb-surface-main),.8);border:none;border-radius:12px;padding:10px;display:flex;flex-direction:column;gap:4px}.metrics-grid span{color:var(--text-muted);font-size:.75rem}.metrics-grid strong{font-size:.84rem;color:var(--lime-main)}.history-list{display:grid;gap:8px;max-height:340px;overflow:auto}.history-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-main));color:var(--text-main);padding:10px}.history-item p{margin:8px 0;color:var(--text-muted);font-size:.82rem}.history-item.selected{border-color:var(--line-strong)}.history-row{display:flex;justify-content:space-between;gap:8px;font-size:.76rem;color:var(--text-muted)}.runtime-grid{display:grid;grid-template-columns:1.2fr 1fr;gap:12px}.runtime-stack{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}.runtime-details{display:grid;gap:12px}.runtime-runs{max-height:360px;overflow:auto;display:grid;gap:8px}.eval-report-wrap{position:relative}.copy-cube-button{position:absolute;right:10px;bottom:10px;width:34px;height:34px;border-radius:10px;padding:0;min-width:34px;display:grid;place-items:center;font-size:.92rem;line-height:1}.muted{color:var(--text-muted)}.diff-summary{margin-top:10px;font-size:.82rem;color:var(--lime-main)}.error-text{margin-top:10px;color:var(--danger);font-size:.84rem}.autoruns-columns{display:flex;gap:12px;width:100%;min-height:0;flex:1 1 auto;overflow-x:auto;overflow-y:hidden;padding-bottom:4px}.autoruns-col{flex:0 0 var(--mode-column-width);width:var(--mode-column-width);height:100%;min-height:0;overflow-y:auto;overflow-x:hidden;border:none;border-radius:14px;background:rgb(var(--rgb-surface-main));padding:12px;scrollbar-gutter:stable}.autoruns-settings-col{display:flex;flex-direction:column}.autoruns-settings-stack{display:grid;gap:12px}.embedded-panel-section{display:grid;gap:12px;border-radius:12px;background:rgb(var(--rgb-surface-horizontal));padding:12px}.embedded-panel-section-header{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.embedded-panel-section-header h4{margin:0;color:var(--text-main);font-size:.92rem}.embedded-panel-section-header p{margin:6px 0 0;color:var(--text-muted);font-size:.78rem;line-height:1.4}.autoruns-assistant-live-col{background:rgb(var(--rgb-surface-main));padding:12px;overflow:hidden;scrollbar-gutter:auto}.autoruns-assistant-live-col .panel-frame{height:100%;background:rgb(var(--rgb-surface-main))}.autoruns-col h3{margin:0;font-size:.95rem}.autoruns-col h4{margin:12px 0 8px;font-size:.82rem;color:var(--text-muted)}.autoruns-group-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:12px 0 8px}.autoruns-group-heading h4{margin:0}.autoruns-group-toggle{width:20px;min-width:20px;height:20px;padding:0;border:none;border-radius:6px;background:transparent;color:var(--text-muted);display:inline-flex;align-items:center;justify-content:center}.autoruns-group-toggle:hover{background:rgba(var(--rgb-background),.28);color:rgb(var(--rgb-text-main))}.autoruns-group-chevron-svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;transform:rotate(-90deg);transition:transform .18s ease}.autoruns-group-chevron-svg.expanded{transform:rotate(0)}.autoruns-col-header{position:sticky;top:-12px;z-index:8;margin:-12px -12px 10px;padding:12px 12px 10px;background:rgb(var(--rgb-surface-main))}.autoruns-col-header .tab-row{margin:8px 0 0}.autoruns-col-header .autoruns-dialog-toolbar{margin-top:8px}.autoruns-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.autoruns-meta-list{display:grid;gap:8px}.autoruns-meta-list>div{display:flex;justify-content:space-between;gap:8px;border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px 9px;font-size:.79rem}.autoruns-meta-list span{color:var(--text-muted)}.autoruns-prompt-details summary{cursor:pointer;color:var(--text-main);font-size:.8rem;margin-bottom:8px}.autoruns-prompt-details textarea{min-height:68px}.autoruns-stats-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:10px}.autoruns-stats-grid>div{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:3px}.autoruns-stats-grid span{color:var(--text-muted);font-size:.74rem}.autoruns-stats-grid strong{color:var(--lime-main);font-size:.84rem}.autoruns-run-list{display:grid;gap:8px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;padding-right:2px}.autoruns-run-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:10px;display:grid;gap:5px;transition:background-color .2s ease,box-shadow .2s ease}.autoruns-run-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text));box-shadow:none}.autoruns-run-item.selected .autoruns-run-meta{color:rgba(var(--rgb-active-text),.95)}.autoruns-run-head,.autoruns-run-foot{display:flex;justify-content:space-between;gap:8px;font-size:.76rem}.autoruns-run-meta{color:var(--text-muted);font-size:.75rem;word-break:break-word}.autoruns-run-id-row{display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0}.autoruns-run-id-row>span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-copy-run-id-btn{border:none;background:transparent;color:rgb(var(--rgb-text-main));width:16px;height:16px;min-width:16px;min-height:16px;padding:0;display:inline-flex;align-items:center;justify-content:center;border-radius:4px;opacity:.92;cursor:pointer}.autoruns-copy-run-id-btn:hover{color:rgb(var(--rgb-text-main));opacity:1;background:transparent;box-shadow:none;transform:none}.autoruns-copy-run-id-btn:focus-visible{outline:1px solid rgba(var(--rgb-text-main),.7);outline-offset:1px}.autoruns-copy-icon-svg{width:.82rem;height:.82rem;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.autoruns-dialog-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.autoruns-case-list{margin-top:8px;display:grid;gap:6px;max-height:180px;overflow:auto}.autoruns-case-item{width:100%;text-align:left;border-radius:10px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:7px 8px;display:flex;justify-content:space-between;gap:6px;font-size:.76rem}.autoruns-case-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text));box-shadow:none}.autoruns-dialog-view{margin-top:10px;border:none;border-radius:12px;background:rgb(var(--rgb-surface-horizontal));padding:10px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;display:grid;gap:8px}.autoruns-msg{border:none;border-radius:12px;background:rgb(var(--rgb-surface-focus));padding:8px 10px;display:grid;gap:6px;min-width:0;overflow:hidden}.autoruns-msg header,.autoruns-msg footer{display:flex;justify-content:space-between;align-items:flex-start;flex-wrap:wrap;min-width:0;gap:8px;font-size:.74rem;color:var(--text-muted)}.autoruns-msg-head-actions{display:flex;align-items:center;justify-content:flex-end;flex:1 1 auto;min-width:0;flex-wrap:wrap;gap:8px}.autoruns-msg-head-actions>span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-msg-case-tag{display:inline-flex;align-items:center;border-radius:999px;padding:2px 8px;font-size:.7rem;line-height:1;color:rgb(var(--rgb-active-text));background:rgba(var(--rgb-active),.24)}.autoruns-msg p{margin:0;white-space:pre-wrap;line-height:1.35;font-size:.84rem;overflow-wrap:anywhere;word-break:break-word}.autoruns-msg footer span{min-width:0;overflow-wrap:anywhere;word-break:break-word}.autoruns-comment-icon{border:none;background:transparent;color:rgb(var(--rgb-text-main));border-radius:0;min-width:16px;min-height:16px;width:16px;height:16px;padding:0;line-height:1;box-shadow:none;transform:none;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;opacity:.92}.autoruns-comment-icon:hover{background:transparent;color:rgb(var(--rgb-text-main));opacity:1;box-shadow:none;transform:none}.autoruns-comment-icon.commented{color:rgb(var(--rgb-active));background:transparent;box-shadow:none}.autoruns-comment-icon:focus-visible{outline:1px solid rgba(var(--rgb-text-main),.7);outline-offset:1px}.autoruns-comment-icon:disabled{opacity:.42;cursor:not-allowed}.comment-icon-svg{width:.82rem;height:.82rem;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round;fill:none}.comment-icon-svg.commented{stroke:rgb(var(--rgb-active));fill:none}.autoruns-resolve-toggle{border:none;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));border-radius:999px;width:22px;height:22px;min-width:22px;min-height:22px;padding:0;display:inline-flex;align-items:center;justify-content:center;box-shadow:none;transform:none}.autoruns-resolve-toggle:hover{background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-active));box-shadow:none;transform:none}.autoruns-resolve-toggle:disabled{opacity:.55;cursor:wait}.autoruns-resolve-toggle.resolved{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.resolve-icon-svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.resolve-icon-svg.resolved{fill:currentColor}.autoruns-msg-annotation{display:grid;gap:4px;border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:7px 8px;font-size:.78rem}.autoruns-comments-list{display:grid;gap:8px;max-height:none;min-height:0;flex:1 1 auto;overflow:auto;padding-right:2px;margin-top:6px}.autoruns-autogen-list{display:grid;gap:8px;max-height:none;min-height:0;overflow:auto;padding-right:2px}.autoruns-autogen-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:5px;cursor:pointer;overflow:hidden}.autoruns-autogen-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-autogen-item.selected .autoruns-run-meta,.autoruns-autogen-item.selected p{color:rgba(var(--rgb-active-text),.95)}.autoruns-autogen-item header{display:flex;justify-content:space-between;gap:8px;font-size:.76rem}.autoruns-autogen-item.saved-session{cursor:default;gap:8px}.autoruns-autogen-item.saved-session header{display:grid;gap:4px}.autoruns-autogen-item.saved-session header strong{font-size:.84rem}.autoruns-autogen-item.saved-session header span{color:var(--text-muted);font-size:.74rem}.autoruns-autogen-item.saved-session header .autoruns-autogen-card-actions{display:none}.autoruns-saved-session-topbar{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:18px}.autoruns-saved-session-footer{display:flex;align-items:center;justify-content:flex-start;min-height:20px;margin-top:2px}.autoruns-saved-session-icon-btn{width:20px;min-width:20px;height:20px;padding:0;border:none;border-radius:6px;background:transparent;color:var(--text-muted);display:inline-flex;align-items:center;justify-content:center}.autoruns-saved-session-icon-btn:hover:not(:disabled){background:rgba(var(--rgb-background),.28);color:rgb(var(--rgb-text-main))}.autoruns-autogen-item.saved-session .autoruns-saved-session-icon-btn,.autoruns-autogen-item.saved-session .autoruns-autogen-delete-btn{color:#fff}.autoruns-autogen-item.saved-session .autoruns-saved-session-icon-btn:hover:not(:disabled),.autoruns-autogen-item.saved-session .autoruns-autogen-delete-btn:hover:not(:disabled){background:rgba(var(--rgb-background),.28);color:rgb(var(--rgb-active));box-shadow:none}.autoruns-autogen-item.saved-session .autoruns-autogen-delete-btn{border-radius:6px}.autoruns-card-chevron-svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;transition:transform .18s ease}.autoruns-card-launch-svg{width:14px;height:14px;fill:currentColor;stroke:none}.autoruns-card-chevron-svg.expanded{transform:rotate(180deg)}.autoruns-saved-session-questions{max-height:0;overflow:hidden;opacity:0;transition:max-height .24s ease,opacity .18s ease,margin-top .24s ease;margin-top:0}.autoruns-saved-session-questions.expanded{max-height:520px;opacity:1;margin-top:4px}.autoruns-generated-questions-embedded{margin-top:2px}.autoruns-autogen-item p{margin:0;color:var(--text-muted);white-space:pre-wrap;font-size:.8rem}.autoruns-run-launch-btn{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-run-launch-btn:hover{background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main))}.autoruns-run-launch-btn:disabled{background:rgba(var(--rgb-active),.38);color:rgba(var(--rgb-active-text),.88)}.autoruns-generated-questions{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px;display:grid;gap:8px}.autoruns-generated-questions-head{display:flex;align-items:center;justify-content:space-between;gap:8px}.autoruns-generated-questions-list{display:grid;gap:6px;max-height:220px;overflow:auto;padding-right:2px}.autoruns-generated-question-item{position:relative;display:grid;grid-template-columns:22px minmax(0,1fr) auto;align-items:start;gap:8px;border:none;border-radius:9px;background:rgb(var(--rgb-surface-focus));padding:7px 8px;font-size:.78rem;transition:background .15s ease,outline-color .15s ease,opacity .15s ease}.autoruns-generated-question-item.drag-over{outline:1px solid rgba(var(--rgb-active),.75)}.autoruns-generated-question-item.dragging{opacity:.72}.autoruns-generated-question-item.editing{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-question-grip-btn{width:18px;min-width:18px;height:18px;padding:0;border:none;border-radius:6px;background:transparent;color:var(--text-muted);display:inline-flex;align-items:center;justify-content:center;cursor:grab;margin-top:1px}.autoruns-question-grip-btn:hover:not(:disabled){color:rgb(var(--rgb-text-main));background:rgba(var(--rgb-background),.3)}.autoruns-generated-question-item.editing .autoruns-question-grip-btn{color:rgba(var(--rgb-active-text),.9)}.autoruns-generated-question-item.editing .autoruns-question-grip-btn:hover:not(:disabled){color:rgb(var(--rgb-active-text));background:rgba(var(--rgb-active-text),.14)}.autoruns-question-grip-btn:disabled{cursor:default;opacity:.45}.autoruns-question-grip-svg{width:14px;height:14px;fill:currentColor}.autoruns-generated-question-text{border:none;background:transparent;color:rgb(var(--rgb-text-main));padding:0;margin:0;text-align:left;font:inherit;white-space:pre-wrap;line-height:1.4;cursor:text}.autoruns-generated-question-text:hover{color:rgb(var(--rgb-active))}.autoruns-generated-question-input{width:100%;min-width:0;border:none;border-radius:8px;background:rgba(var(--rgb-background),.55);color:rgb(var(--rgb-text-main));padding:6px 8px;font:inherit;line-height:1.4}.autoruns-generated-question-input:focus{outline:none}.autoruns-generated-question-item.editing .autoruns-generated-question-input{background:rgba(var(--rgb-active-text),.14);color:rgb(var(--rgb-active-text))}.autoruns-generated-question-item.editing .autoruns-generated-question-input::placeholder{color:rgba(var(--rgb-active-text),.78)}.autoruns-add-question-btn{width:100%;min-height:30px;border-radius:8px;border:none;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));font-size:1.1rem;font-weight:700;line-height:1}.autoruns-add-question-btn:hover:not(:disabled){background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-add-question-btn:disabled{opacity:.5;cursor:default}.autoruns-remove-question-btn{flex:0 0 auto;border:none;border-radius:0;background:transparent;color:rgb(var(--rgb-text-main));min-width:16px;width:16px;height:16px;padding:0;font-size:1rem;font-weight:700;line-height:1;display:inline-flex;align-items:center;justify-content:center;box-shadow:none;transition:color .15s ease;align-self:start}.autoruns-remove-question-btn:hover{background:transparent;color:rgb(var(--rgb-active));box-shadow:none}.autoruns-generated-question-item.editing .autoruns-remove-question-btn{color:rgb(var(--rgb-active-text))}.autoruns-generated-question-item.editing .autoruns-remove-question-btn:hover{color:rgba(var(--rgb-active-text),.82)}.autoruns-remove-question-btn:focus-visible{outline:none}.autoruns-personality-prompt{resize:vertical;min-height:110px}.autoruns-comment-item{width:100%;text-align:left;border-radius:12px;border:none;background:rgb(var(--rgb-surface-horizontal));color:var(--text-main);padding:9px;display:grid;gap:6px;cursor:pointer}.autoruns-comment-item p{margin:0;white-space:pre-wrap;color:var(--text-muted);font-size:.79rem}.autoruns-comment-item.selected{background:rgb(var(--rgb-active));color:rgb(var(--rgb-active-text))}.autoruns-comment-item.selected p,.autoruns-comment-item.selected .autoruns-run-meta,.autoruns-comment-item.selected .muted{color:rgba(var(--rgb-active-text),.94)}.autoruns-comment-item.selected .autoruns-resolve-toggle{background:rgba(var(--rgb-active-text),.18);color:rgb(var(--rgb-active-text))}.autoruns-comment-head{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:.75rem}.autoruns-comment-head-actions{display:inline-flex;align-items:center;gap:8px}.autoruns-comment-filter-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:10px;margin-bottom:8px}.autoruns-resolved-filter-toggle{min-height:38px;white-space:nowrap}.autoruns-msg.assistant{margin-right:12%}.autoruns-msg.user{margin-left:12%;border-color:transparent;background:rgb(var(--rgb-surface-focus))}.autoruns-decomposition-list{margin:0;padding-left:18px;display:grid;gap:7px;font-size:.8rem}.autoruns-comment-modal-backdrop{position:fixed;inset:0;background:rgba(var(--rgb-background),.74);display:grid;place-items:center;z-index:1800;padding:12px}.autoruns-comment-modal{width:min(660px,100%);border:none;border-radius:16px;background:rgb(var(--rgb-surface-horizontal));box-shadow:var(--shadow);padding:14px;display:grid;gap:10px}.autoruns-comment-modal h3{margin:0;font-size:.95rem}.autoruns-comment-quote{margin:0;border:none;border-radius:10px;background:rgb(var(--rgb-surface-focus));padding:8px;white-space:pre-wrap;max-height:150px;overflow:auto;font-size:.82rem}.autoruns-rating-row{display:flex;gap:8px}.autoruns-rating-dot{width:34px;height:34px;border-radius:999px;padding:0;border:none;background:rgb(var(--rgb-surface-focus));color:var(--text-muted);font-size:.95rem;box-shadow:none;transform:none}.autoruns-rating-dot:hover{border-color:var(--line-strong);box-shadow:none;transform:none}.autoruns-rating-dot.active{border-color:var(--line-strong);color:rgb(var(--rgb-active-text));background:rgb(var(--rgb-active))}.autoruns-coverage-list{display:grid;gap:8px}.autoruns-coverage-item{border:none;border-radius:10px;background:rgb(var(--rgb-surface-horizontal));padding:8px}.autoruns-coverage-head{display:flex;justify-content:space-between;gap:8px;font-size:.76rem;margin-bottom:5px}.autoruns-coverage-head span{color:var(--text-muted)}.autoruns-coverage-bar{height:7px;border-radius:999px;background:rgb(var(--rgb-surface-focus));overflow:hidden}.autoruns-coverage-bar>div{height:100%;border-radius:999px;background:rgb(var(--rgb-active))}.autoruns-autogen-card-actions{display:inline-flex;align-items:center;gap:8px}.autoruns-autogen-delete-btn{border:none;border-radius:0;width:22px;height:22px;min-width:22px;padding:0;background:transparent;color:rgb(var(--rgb-text-main));display:inline-flex;align-items:center;justify-content:center;font-size:1rem;font-weight:700;line-height:1;box-shadow:none;transition:color .15s ease}.autoruns-autogen-delete-btn:hover{background:transparent;color:rgb(var(--rgb-active));box-shadow:none}.autoruns-agent-acceptance{display:grid;gap:6px;margin-top:6px}.autoruns-agent-pill-row{display:flex;flex-wrap:wrap;gap:6px}.autoruns-agent-pill{display:inline-flex;align-items:center;justify-content:center;min-height:24px;padding:0 8px;border-radius:999px;background:rgb(var(--rgb-surface-focus));color:rgb(var(--rgb-text-main));font-size:.73rem;line-height:1;border:1px solid rgba(var(--rgb-text-main),.1)}.autoruns-agent-pill.neutral{color:var(--text-muted)}.autoruns-agent-pill.status-accepted{color:rgb(var(--rgb-emerald));border-color:rgba(var(--rgb-emerald),.32)}.autoruns-agent-pill.status-partial{color:rgb(var(--rgb-warning));border-color:rgba(var(--rgb-warning),.32)}.autoruns-agent-pill.status-blocked{color:rgb(var(--rgb-danger));border-color:rgba(var(--rgb-danger),.32)}.autoruns-agent-pill.status-unknown{color:var(--text-muted)}@media(max-width:1200px){:root{--mode-column-width: 400px}.metrics-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:920px){:root{--mode-column-width: 360px}.grid-two,.runtime-grid,.runtime-stack{grid-template-columns:1fr}.metrics-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.autoruns-form-grid,.autoruns-dialog-toolbar,.autoruns-stats-grid,.autoruns-comment-filter-row{grid-template-columns:1fr}}@media(max-width:640px){:root{--mode-column-width: 320px}.app-root{padding:18px 12px 24px}.metrics-grid{grid-template-columns:1fr}}@keyframes rise{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}} diff --git a/llm_normalizer/frontend/dist/index.html b/llm_normalizer/frontend/dist/index.html index 7612730..5f92ded 100644 --- a/llm_normalizer/frontend/dist/index.html +++ b/llm_normalizer/frontend/dist/index.html @@ -4,8 +4,8 @@ NDC AI Normalizer Playground - - + +
diff --git a/llm_normalizer/frontend/src/components/AutoRunsHistoryPanel.tsx b/llm_normalizer/frontend/src/components/AutoRunsHistoryPanel.tsx index 65688b2..1b3804c 100644 --- a/llm_normalizer/frontend/src/components/AutoRunsHistoryPanel.tsx +++ b/llm_normalizer/frontend/src/components/AutoRunsHistoryPanel.tsx @@ -204,6 +204,12 @@ interface AutoRunsUiConfig { filters?: Partial; analysisDate?: string; autogenPersonalityPromptHeight?: number; + groupsExpanded?: { + filters?: boolean; + generationContext?: boolean; + autogen?: boolean; + savedSessions?: boolean; + }; autoGenSettings?: { mode?: AutoGenMode; count?: number; @@ -282,6 +288,22 @@ function formatDateTime(iso: string | null): string { return new Date(parsed).toLocaleString("ru-RU"); } +function formatDialogStepTag(message: AutoRunDialogMessage): string | null { + const localIndex = + typeof message.case_message_index === "number" + ? message.case_message_index + : typeof message.message_index === "number" + ? message.message_index + : null; + if (localIndex === null || localIndex < 0) { + return null; + } + const turnNumber = Math.floor(localIndex / 2) + 1; + const turnLabel = String(turnNumber).padStart(3, "0"); + const roleLabel = message.role === "assistant" ? "ответ" : "вопрос"; + return `${turnLabel} ${roleLabel}`; +} + function formatAutoGenModeLabel(mode: AutoGenMode): string { if (mode === "saved_user_sessions") { return "Пользовательские сессии"; @@ -569,6 +591,35 @@ function QuestionGripIcon() { ); } +function CardChevronIcon({ expanded }: { expanded: boolean }) { + return ( + + ); +} + +function CardLaunchIcon() { + return ( + + ); +} + +function GroupChevronIcon({ expanded }: { expanded: boolean }) { + return ( + + ); +} + export function AutoRunsHistoryPanel({ connection, modelOptions, @@ -620,6 +671,7 @@ export function AutoRunsHistoryPanel({ const [autoGenSettings, setAutoGenSettings] = useState(DEFAULT_AUTOGEN_SETTINGS); const [autoGenHistory, setAutoGenHistory] = useState([]); const [selectedAutogenGenerationId, setSelectedAutogenGenerationId] = useState(""); + const [expandedSavedSessionGenerationId, setExpandedSavedSessionGenerationId] = useState(""); const [editableGeneratedQuestions, setEditableGeneratedQuestions] = useState([]); const [generatedQuestionsBusy, setGeneratedQuestionsBusy] = useState(false); const [editingQuestionIndex, setEditingQuestionIndex] = useState(null); @@ -650,6 +702,10 @@ export function AutoRunsHistoryPanel({ const [limitInput, setLimitInput] = useState(String(DEFAULT_FILTERS.limit)); const [autogenCountInput, setAutogenCountInput] = useState(String(DEFAULT_AUTOGEN_SETTINGS.count)); const [autogenPersonalityPromptHeight, setAutogenPersonalityPromptHeight] = useState(160); + const [filtersGroupExpanded, setFiltersGroupExpanded] = useState(true); + const [generationContextGroupExpanded, setGenerationContextGroupExpanded] = useState(true); + const [autogenGroupExpanded, setAutogenGroupExpanded] = useState(true); + const [savedSessionsGroupExpanded, setSavedSessionsGroupExpanded] = useState(true); const [commentModal, setCommentModal] = useState({ open: false, caseId: "", @@ -1485,17 +1541,20 @@ export function AutoRunsHistoryPanel({ [loadAutoGenHistory, loadHistory, log, selectedCaseId, selectedRunId, stopAsyncJobPolling] ); - const runAutogenCampaign = useCallback(async () => { + const runAutogenCampaign = useCallback(async (generationOverride?: AutoGenHistoryRecord, questionsOverride?: string[]) => { stopAsyncJobPolling(); setAutogenRunBusy(true); setErrorText(""); try { - const generation = selectedAutogenGeneration; + const generation = generationOverride ?? selectedAutogenGeneration; if (!generation) { throw new Error("История автогенерации пуста. Сначала сгенерируйте пачку вопросов."); } - const questionsForRun = editableGeneratedQuestions + const sourceQuestions = + questionsOverride ?? + (selectedAutogenGeneration?.generation_id === generation.generation_id ? editableGeneratedQuestions : generation.questions); + const questionsForRun = sourceQuestions .map((item) => item.trim()) .filter((item) => item.length > 0); if (questionsForRun.length === 0) { @@ -1980,6 +2039,11 @@ export function AutoRunsHistoryPanel({ setDragOverQuestionIndex(null); }, []); + const toggleSavedSessionQuestions = useCallback((generationId: string) => { + setSelectedAutogenGenerationId(generationId); + setExpandedSavedSessionGenerationId((prev) => (prev === generationId ? "" : generationId)); + }, []); + const openAutoGenDeleteModal = useCallback((item: AutoGenHistoryRecord) => { setAutoGenDeleteModal({ open: true, @@ -2135,6 +2199,19 @@ export function AutoRunsHistoryPanel({ return () => window.clearTimeout(timer); }, [editingQuestionIndex]); + useEffect(() => { + if (!isSavedUserSessionsMode) { + setExpandedSavedSessionGenerationId(""); + return; + } + if ( + expandedSavedSessionGenerationId && + !visibleAutoGenHistory.some((item) => item.generation_id === expandedSavedSessionGenerationId) + ) { + setExpandedSavedSessionGenerationId(""); + } + }, [expandedSavedSessionGenerationId, isSavedUserSessionsMode, visibleAutoGenHistory]); + useEffect(() => { setLimitInput(String(filters.limit)); }, [filters.limit]); @@ -2213,6 +2290,20 @@ export function AutoRunsHistoryPanel({ if (typeof parsed.autogenPersonalityPromptHeight === "number") { setAutogenPersonalityPromptHeight(clampAutogenPromptHeight(parsed.autogenPersonalityPromptHeight)); } + if (parsed.groupsExpanded) { + if (typeof parsed.groupsExpanded.filters === "boolean") { + setFiltersGroupExpanded(parsed.groupsExpanded.filters); + } + if (typeof parsed.groupsExpanded.generationContext === "boolean") { + setGenerationContextGroupExpanded(parsed.groupsExpanded.generationContext); + } + if (typeof parsed.groupsExpanded.autogen === "boolean") { + setAutogenGroupExpanded(parsed.groupsExpanded.autogen); + } + if (typeof parsed.groupsExpanded.savedSessions === "boolean") { + setSavedSessionsGroupExpanded(parsed.groupsExpanded.savedSessions); + } + } if (parsed.autoGenSettings) { setAutoGenSettings((prev) => { const nextPrompts: Record = { @@ -2272,6 +2363,12 @@ export function AutoRunsHistoryPanel({ filters, analysisDate, autogenPersonalityPromptHeight, + groupsExpanded: { + filters: filtersGroupExpanded, + generationContext: generationContextGroupExpanded, + autogen: autogenGroupExpanded, + savedSessions: savedSessionsGroupExpanded + }, autoGenSettings: { mode: autoGenSettings.mode, count: autoGenSettings.count, @@ -2284,7 +2381,18 @@ export function AutoRunsHistoryPanel({ hideResolvedAnnotations }; localStorage.setItem(AUTORUNS_UI_CONFIG_KEY, JSON.stringify(payload)); - }, [analysisDate, annotationDecisionFilter, autoGenSettings, autogenPersonalityPromptHeight, filters, hideResolvedAnnotations]); + }, [ + analysisDate, + annotationDecisionFilter, + autoGenSettings, + autogenGroupExpanded, + autogenPersonalityPromptHeight, + filters, + filtersGroupExpanded, + generationContextGroupExpanded, + hideResolvedAnnotations, + savedSessionsGroupExpanded + ]); useEffect(() => { const onSave = () => { @@ -2347,7 +2455,20 @@ export function AutoRunsHistoryPanel({

Автопрогоны

-

Настройки выборки

+
+

Настройки выборки

+ +
+ {filtersGroupExpanded ? ( + <>
+ + ) : null} -

Контур генерации

+
+

Контур генерации

+ +
+ {generationContextGroupExpanded ? (
Провайдер: @@ -2473,8 +2608,22 @@ export function AutoRunsHistoryPanel({ {decompositionPromptVersion}
+ ) : null} -

Автопрогоны

+
+

Автопрогоны

+ +
+ {autogenGroupExpanded ? ( + <>
- {isSavedUserSessionsMode ? ( -

Сохраненные пользовательские сессии

- ) : ( + {!isSavedUserSessionsMode ? (

Запуск выполняет `assistant_stage1` eval по выбранному кейс-сету.

- )} + ) : null} )} + + ) : null} +
+

{isSavedUserSessionsMode ? "Сохраненные пользовательские сессии" : "История автогенераций"}

+ +
+ {savedSessionsGroupExpanded ? (
{autogenHistoryBusy ? (

@@ -2787,9 +2958,49 @@ export function AutoRunsHistoryPanel({ {visibleAutoGenHistory.slice(0, 30).map((item) => (

setSelectedAutogenGenerationId(item.generation_id)} + className={[ + "autoruns-autogen-item", + selectedAutogenGenerationId === item.generation_id ? "selected" : "", + expandedSavedSessionGenerationId === item.generation_id ? "expanded" : "", + isSavedUserSessionsMode ? "saved-session" : "" + ].filter(Boolean).join(" ")} + onClick={isSavedUserSessionsMode ? undefined : () => setSelectedAutogenGenerationId(item.generation_id)} > + {isSavedUserSessionsMode ? ( +
+ + +
+ ) : null}
{formatAutoGenGenerationTitle(item)}
@@ -2834,9 +3045,146 @@ export function AutoRunsHistoryPanel({
тип={isAgentSemanticGeneration(item) ? "АГЕНТНЫЙ ПРОГОН" : "АВТОПРОГОН"}
+ {isSavedUserSessionsMode ? ( + <> +
+ +
+
+
+
+ + Вопросы к запуску:{" "} + {selectedAutogenGenerationId === item.generation_id ? editableGeneratedQuestions.length : item.questions.length} + +
+ {(selectedAutogenGenerationId === item.generation_id ? editableGeneratedQuestions : item.questions).length === 0 ? ( +

Список вопросов пуст.

+ ) : ( +
+ {(selectedAutogenGenerationId === item.generation_id ? editableGeneratedQuestions : item.questions).map( + (question, index) => ( +
+ selectedAutogenGenerationId === item.generation_id ? handleQuestionDragOver(event, index) : undefined + } + onDrop={(event) => + selectedAutogenGenerationId === item.generation_id ? void handleQuestionDrop(event, index) : undefined + } + > + + {selectedAutogenGenerationId === item.generation_id && editingQuestionIndex === index ? ( + <> + setEditingQuestionDraft(event.target.value)} + onBlur={handleQuestionEditorBlur} + onKeyDown={handleQuestionEditorKeyDown} + placeholder="Текст вопроса" + disabled={generatedQuestionsBusy} + /> + + + ) : ( + + )} +
+ ) + )} +
+ )} + +
+
+ + ) : null}
))}
+ ) : null}
Копия активного промпта (только чтение) @@ -3038,6 +3386,9 @@ export function AutoRunsHistoryPanel({ {role === "assistant" ? "Система" : "Модель/вопрос"}
{item.case_id ? {item.case_id} : null} + {formatDialogStepTag(item) ? ( + {formatDialogStepTag(item)} + ) : null} {item.created_at ? formatDateTime(item.created_at) : "нет данных"} {role === "assistant" && !isLiveRunId(selectedRunId) ? ( <> diff --git a/llm_normalizer/frontend/src/styles.css b/llm_normalizer/frontend/src/styles.css index 71cfb24..a22c070 100644 --- a/llm_normalizer/frontend/src/styles.css +++ b/llm_normalizer/frontend/src/styles.css @@ -1029,6 +1029,53 @@ button:disabled { color: var(--text-muted); } +.autoruns-group-heading { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; + margin: 12px 0 8px; +} + +.autoruns-group-heading h4 { + margin: 0; +} + +.autoruns-group-toggle { + width: 20px; + min-width: 20px; + height: 20px; + padding: 0; + border: none; + border-radius: 6px; + background: transparent; + color: var(--text-muted); + display: inline-flex; + align-items: center; + justify-content: center; +} + +.autoruns-group-toggle:hover { + background: rgba(var(--rgb-background), 0.28); + color: rgb(var(--rgb-text-main)); +} + +.autoruns-group-chevron-svg { + width: 14px; + height: 14px; + stroke: currentColor; + fill: none; + stroke-width: 1.6; + stroke-linecap: round; + stroke-linejoin: round; + transform: rotate(-90deg); + transition: transform 0.18s ease; +} + +.autoruns-group-chevron-svg.expanded { + transform: rotate(0deg); +} + .autoruns-col-header { position: sticky; top: -12px; @@ -1468,6 +1515,7 @@ button:disabled { display: grid; gap: 5px; cursor: pointer; + overflow: hidden; } .autoruns-autogen-item.selected { @@ -1487,6 +1535,120 @@ button:disabled { font-size: 0.76rem; } +.autoruns-autogen-item.saved-session { + cursor: default; + gap: 8px; +} + +.autoruns-autogen-item.saved-session header { + display: grid; + gap: 4px; +} + +.autoruns-autogen-item.saved-session header strong { + font-size: 0.84rem; +} + +.autoruns-autogen-item.saved-session header span { + color: var(--text-muted); + font-size: 0.74rem; +} + +.autoruns-autogen-item.saved-session header .autoruns-autogen-card-actions { + display: none; +} + +.autoruns-saved-session-topbar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; + min-height: 18px; +} + +.autoruns-saved-session-footer { + display: flex; + align-items: center; + justify-content: flex-start; + min-height: 20px; + margin-top: 2px; +} + +.autoruns-saved-session-icon-btn { + width: 20px; + min-width: 20px; + height: 20px; + padding: 0; + border: none; + border-radius: 6px; + background: transparent; + color: var(--text-muted); + display: inline-flex; + align-items: center; + justify-content: center; +} + +.autoruns-saved-session-icon-btn:hover:not(:disabled) { + background: rgba(var(--rgb-background), 0.28); + color: rgb(var(--rgb-text-main)); +} + +.autoruns-autogen-item.saved-session .autoruns-saved-session-icon-btn, +.autoruns-autogen-item.saved-session .autoruns-autogen-delete-btn { + color: #fff; +} + +.autoruns-autogen-item.saved-session .autoruns-saved-session-icon-btn:hover:not(:disabled), +.autoruns-autogen-item.saved-session .autoruns-autogen-delete-btn:hover:not(:disabled) { + background: rgba(var(--rgb-background), 0.28); + color: rgb(var(--rgb-active)); + box-shadow: none; +} + +.autoruns-autogen-item.saved-session .autoruns-autogen-delete-btn { + border-radius: 6px; +} + +.autoruns-card-chevron-svg { + width: 14px; + height: 14px; + stroke: currentColor; + fill: none; + stroke-width: 1.6; + stroke-linecap: round; + stroke-linejoin: round; + transition: transform 0.18s ease; +} + +.autoruns-card-launch-svg { + width: 14px; + height: 14px; + fill: currentColor; + stroke: none; +} + +.autoruns-card-chevron-svg.expanded { + transform: rotate(180deg); +} + +.autoruns-saved-session-questions { + max-height: 0; + overflow: hidden; + opacity: 0; + transition: max-height 0.24s ease, opacity 0.18s ease, margin-top 0.24s ease; + margin-top: 0; +} + +.autoruns-saved-session-questions.expanded { + max-height: 520px; + opacity: 1; + margin-top: 4px; +} + +.autoruns-generated-questions-embedded { + margin-top: 2px; +} + .autoruns-autogen-item p { margin: 0; color: var(--text-muted);