@m6d/cortex-react 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +191 -13
- package/dist/styles.css +24 -43
- package/dist/theme.css +5 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,13 +1,191 @@
|
|
|
1
|
-
var Q5=Object.create;var{getPrototypeOf:X5,defineProperty:j0,getOwnPropertyNames:Z5}=Object;var G5=Object.prototype.hasOwnProperty;var I_=(_,$,Y)=>{Y=_!=null?Q5(X5(_)):{};let Q=$||!_||!_.__esModule?j0(Y,"default",{value:_,enumerable:!0}):Y;for(let X of Z5(_))if(!G5.call(Q,X))j0(Q,X,{get:()=>_[X],enumerable:!0});return Q};var y_=((_)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(_,{get:($,Y)=>(typeof require<"u"?require:$)[Y]}):_)(function(_){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+_+'" is not supported')});import{useEffect as G7,useRef as r2,useState as z1}from"react";var D1=["en","ar"];var H1=["image/png","image/jpeg","image/webp","application/pdf"];var g0=5;function m0(_,$){if(!H1.some((Y)=>Y===_))return"type";if($>10485760)return"size";return"ok"}var x0=["executeCode","queryDataset","describeDataset"];function B1(_){return{..._,role:_.role==="trigger"?"user":_.role}}var h0="clientToolAnswers";function u0(_){return _.approval?.id??`approval_${_.id}`}var q1="X-Cortex-Timezone";function F1(_){let $=_.getHeaders();return $ instanceof Promise?$.then(c0):Promise.resolve(c0($))}function c0(_){let $={..._},Y=J5(),Q=Object.keys($).some((X)=>X.toLowerCase()===q1.toLowerCase());if(Y&&!Q)$[q1]=Y;return $}function J5(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function N5(_,$){let Y=_.baseUrl;return(typeof Y==="string"?Y:Y()).replace(/\/$/,"")+$}function V5(_){let $=_?.match(/filename\*\s*=\s*[^']*'[^']*'([^;\r\n]+)/i)?.[1]?.trim().replace(/^"|"$/g,"");if($)try{return decodeURIComponent($)}catch{}return _?.match(/filename\s*=\s*"?([^";\r\n]+)"?/i)?.[1]}function U1(_){function $(){return F1(_())}function Y(X){return N5(_(),X)}async function Q(X,Z){let G=new Headers(await $());if(new Headers(Z?.headers).forEach((V,K)=>{G.set(K,V)}),Z?.body instanceof FormData)G.delete("Content-Type");else if(!G.has("Content-Type"))G.set("Content-Type","application/json");let J=await fetch(Y(X),{...Z,headers:G});if(!J.ok)throw Error(`HTTP ${J.status}: ${J.statusText}`);let N=await J.text();return N?JSON.parse(N):void 0}return{getCapabilities(){return Q("/capabilities")},listThreads(){return Q("/threads")},createThread(){return Q("/threads",{method:"POST"})},deleteThread(X){return Q(`/threads/${X}`,{method:"DELETE"})},listMessages(X){return Q(`/threads/${X}/messages`)},listLlmRequests(X){return Q(`/messages/${X}/llm-requests`)},abortStream(X){return Q(`/chat/${X}/abort`,{method:"POST"})},initiateToolCall(X,Z){return Q(`/chat/${X}/tools/${Z}/initiate`,{method:"POST"})},uploadAttachment(X,Z){let G=new FormData;return G.append("file",Z),Q(`/threads/${X}/files`,{method:"POST",body:G})},deleteAttachment(X){return Q(`/files/${X}`,{method:"DELETE"})},async downloadAttachment(X){let Z=await fetch(Y(`/files/${X}`),{headers:await $()});if(!Z.ok)throw Error(`HTTP ${Z.status}: ${Z.statusText}`);return{blob:await Z.blob(),name:V5(Z.headers.get("Content-Disposition"))??X}},resolveHeaders:$,resolveUrl:Y}}function H_(_,$){if(_===void 0||typeof _==="string"||Array.isArray(_))return _;let Y=_;return Y[$]??Y.en??Object.values(Y)[0]}var p0={translate_history:"السجل",translate_back:"رجوع",translate_greeting:"بماذا يمكنني مساعدتك اليوم؟",translate_n_conversations:"{{count}} محادثات",translate_one_conversation:"محادثة واحدة",translate_no_threads_yet:"لا توجد محادثات بعد",translate_start_a_new_conversation:"ابدأ محادثة جديدة",translate_untitled:"بدون عنوان",translate_new_chat:"محادثة جديدة",translate_normal:"عادي",translate_debug:"تصحيح",translate_type_a_message:"اكتب رسالة...",translate_completed:"مكتمل",translate_attach_files:"إرفاق ملفات",translate_drop_files_here:"أفلت ملفاتك هنا...",translate_remove_attachment:"إزالة المرفق",translate_attachment_rejected:"لا يمكن إرفاق هذا الملف",translate_attachment_caption:"من فضلك اطّلع على الملفات المرفقة.",translate_download:"تنزيل",translate_tool_status_0:"جارٍ جلب البيانات…",translate_tool_status_1:"جارٍ تحليل المعلومات…",translate_tool_status_2:"جارٍ معالجة الطلب…",translate_tool_status_3:"جارٍ تجميع النتائج…",translate_tool_status_4:"جارٍ تحضير الرد…",translate_tool_status_5:"جارٍ البحث…",translate_tool_status_6:"جارٍ فحص السجلات…",translate_tool_status_7:"جارٍ مراجعة التفاصيل…",translate_tool_status_8:"جارٍ إجراء الحسابات…",translate_tool_status_9:"جارٍ سحب المعلومات…",translate_tool_done_0:"تم جلب البيانات بنجاح",translate_tool_done_1:"تم التحليل بنجاح",translate_tool_done_2:"تمت معالجة الطلب بنجاح",translate_tool_done_3:"تم تجميع النتائج بنجاح",translate_tool_done_4:"تم تحضير الرد بنجاح",translate_tool_done_5:"تم البحث بنجاح",translate_tool_done_6:"تم فحص السجلات بنجاح",translate_tool_done_7:"تمت المراجعة بنجاح",translate_tool_done_8:"تمت الحسابات بنجاح",translate_tool_done_9:"تم استرجاع المعلومات بنجاح",translate_rows_read:"{{count}} صفوف",translate_one_more_step:"وخطوة أخرى",translate_n_more_steps:"و{{count}} خطوات أخرى",translate_tool_error:"حدث خطأ",translate_attachment_status:"جارٍ قراءة الملف المرفق…",translate_attachment_done:"تمت قراءة الملف المرفق",translate_graph_0:"جارٍ استكشاف الروابط...",translate_graph_1:"جارٍ رسم الخريطة...",translate_graph_2:"جارٍ اكتشاف العلاقات...",translate_graph_3:"جارٍ تتبع الروابط...",translate_graph_4:"جارٍ التنقل في المعرفة...",translate_graph_5:"جارٍ كشف الرؤى...",translate_graph_6:"جارٍ ربط النقاط...",translate_graph_7:"جارٍ تتبع المسار...",translate_graph_8:"جارٍ تجميع الأجزاء...",translate_graph_9:"جارٍ بناء الصورة...",translate_code_0:"جارٍ حساب الأرقام...",translate_code_1:"جارٍ معالجة البيانات...",translate_code_2:"جارٍ تنفيذ طلبك...",translate_code_3:"جارٍ تحليل الأرقام...",translate_code_4:"جارٍ تجميع كل شيء...",translate_code_5:"جارٍ تحليل النتائج...",translate_code_6:"جارٍ العمل خلف الكواليس...",translate_code_7:"جارٍ ترتيب التفاصيل...",translate_code_8:"جارٍ تحضير إجابتك...",translate_code_9:"أوشك على الانتهاء...",translate_reasoning_0:"جارٍ التفكير...",translate_reasoning_1:"جارٍ دراسة الخيارات...",translate_reasoning_2:"جارٍ تقييم الاحتمالات...",translate_reasoning_3:"جارٍ التأمل في هذا...",translate_reasoning_4:"جارٍ إيجاد الحل...",translate_reasoning_5:"جارٍ ترتيب الأفكار...",translate_reasoning_6:"جارٍ التمعن في الأمر...",translate_reasoning_7:"جارٍ إيجاد أفضل طريقة...",translate_reasoning_8:"جارٍ تنظيم أفكاري...",translate_reasoning_9:"أوشك على الانتهاء...",translate_running:"قيد التنفيذ",translate_aborted:"تم الإلغاء",translate_input:"المدخلات",translate_output:"المخرجات",translate_calling:"جارٍ الاستدعاء",translate_input_ready:"المدخلات جاهزة",translate_needs_approval:"بحاجة إلى موافقة",translate_approved:"تمت الموافقة",translate_responded:"تم الرد",translate_declined:"تم الرفض",translate_approve:"موافقة",translate_deny:"رفض",translate_error:"خطأ",translate_approval_requested:"طلب موافقة",translate_approval_response:"رد الموافقة",translate_waiting_for_approval:"في انتظار الموافقة لتنفيذ هذه الأداة.",translate_tool_approved:"تمت الموافقة.",translate_tool_response_received:"تم استلام الرد.",translate_tokens:"رمز",translate_fresh:"جديد",translate_cache_read:"قراءة من الذاكرة",translate_cache_write:"كتابة في الذاكرة",translate_n_percent_cached:"{{percent}}٪ مخزّن مؤقتًا",translate_text:"نص",translate_reasoning:"الاستنتاج",translate_read:"قراءة",translate_write:"كتابة",translate_total:"الإجمالي",translate_request:"الطلب",translate_response:"الرد",translate_step_n:"الخطوة {{number}}",translate_inspect_llm_requests:"فحص طلبات النموذج",translate_loading:"جارٍ التحميل…",translate_no_llm_requests:"لا توجد طلبات نموذج مسجّلة لهذه الرسالة.",translate_unhandled_type:"نوع غير مدعوم:",translate_client_tool_title:"أكمل هذه الخطوة للمتابعة",translate_client_tool_loading:"جارٍ تجهيز خطوة آمنة...",translate_client_tool_failed:"تعذّر تحميل هذه الخطوة",translate_client_tool_retry:"حاول مرة أخرى",translate_client_tool_cancel:"إلغاء",translate_location_hint:"انقر على الخريطة لتثبيت الدبوس",translate_location_locate:"استخدم موقعي",translate_location_locating:"جارٍ تحديد موقعك",translate_location_locate_failed:"موقعك غير متاح",translate_location_map_failed:"تعذّر تحميل الخريطة",translate_location_send_failed:"تعذّر الإرسال، حاول مرة أخرى",translate_location_skip:"ليس الآن",translate_location_send:"إرسال",translate_location_shared:"تمت مشاركة الموقع",translate_location_not_shared:"لم تتم مشاركة الموقع",translate_trigger_fired:"تم التشغيل بواسطة",translate_trigger_payload:"الحمولة",translate_messages_disabled:"يعمل هذا الوكيل من مشغّلاته فقط.",translate_streaming:"جارٍ البث",translate_done:"تم",translate_no_reasoning:"لا يوجد تفكير مسجّل.",translate_copy:"نسخ إلى الحافظة",translate_copied:"تم النسخ",translate_media_pending_mermaid:"جارٍ رسم المخطط",translate_media_pending_vega_lite:"جارٍ رسم الرسم البياني",translate_media_pending_map:"جارٍ رسم الخريطة",translate_media_cut_off:"انقطع هذا المقطع قبل اكتماله.",translate_media_failed:"تعذر عرض هذا المقطع.",translate_media_source:"المصدر",translate_media_pending:"جارٍ الرسم",translate_media_mermaid:"مخطط",translate_media_vega_lite:"رسم بياني",translate_media_map:"خريطة",translate_media:"معاينة",translate_image_unavailable:"الصورة غير متاحة",translate_image_unavailable_alt:"الصورة غير متاحة: {{alt}}",translate_image:"صورة",translate_send:"إرسال",translate_table:"جدول",translate_expand:"توسيع {{name}}",translate_table_export:"تصدير إلى Excel",translate_close:"إغلاق",translate_approval_needed:"بحاجة إلى موافقتك",translate_approval_action:"تنفيذ {{tool}}",translate_approved_failed:"تمت الموافقة لكنه فشل",translate_approval_cancelled:"لم يُتخذ قرار"};var d0={translate_history:"History",translate_back:"Back",translate_greeting:"What can I help you with today?",translate_n_conversations:"{{count}} conversations",translate_one_conversation:"1 conversation",translate_no_threads_yet:"No threads yet",translate_start_a_new_conversation:"Start a new conversation",translate_untitled:"Untitled",translate_new_chat:"New Chat",translate_normal:"Normal",translate_debug:"Debug",translate_type_a_message:"Type a message...",translate_completed:"Completed",translate_attach_files:"Attach files",translate_drop_files_here:"Drop your files here...",translate_remove_attachment:"Remove attachment",translate_attachment_rejected:"This file cannot be attached",translate_attachment_caption:"Please take a look at the attached files.",translate_download:"Download",translate_tool_status_0:"Fetching data...",translate_tool_status_1:"Analyzing information...",translate_tool_status_2:"Processing request...",translate_tool_status_3:"Gathering results...",translate_tool_status_4:"Preparing response...",translate_tool_status_5:"Looking things up...",translate_tool_status_6:"Checking records...",translate_tool_status_7:"Reviewing details...",translate_tool_status_8:"Running calculations...",translate_tool_status_9:"Pulling information...",translate_tool_done_0:"Data fetched successfully",translate_tool_done_1:"Analysis completed successfully",translate_tool_done_2:"Request processed successfully",translate_tool_done_3:"Results gathered successfully",translate_tool_done_4:"Response prepared successfully",translate_tool_done_5:"Lookup completed successfully",translate_tool_done_6:"Records checked successfully",translate_tool_done_7:"Review completed successfully",translate_tool_done_8:"Calculations completed successfully",translate_tool_done_9:"Information retrieved successfully",translate_rows_read:"{{count}} rows",translate_one_more_step:"and 1 more step",translate_n_more_steps:"and {{count}} more steps",translate_tool_error:"Something went wrong",translate_attachment_status:"Reading the attached file...",translate_attachment_done:"Finished reading the file",translate_graph_0:"Exploring connections...",translate_graph_1:"Mapping out the links...",translate_graph_2:"Discovering relationships...",translate_graph_3:"Tracing the connections...",translate_graph_4:"Navigating the knowledge...",translate_graph_5:"Uncovering insights...",translate_graph_6:"Connecting the dots...",translate_graph_7:"Following the trail...",translate_graph_8:"Piecing things together...",translate_graph_9:"Building the picture...",translate_code_0:"Running the numbers...",translate_code_1:"Working through the data...",translate_code_2:"Processing your request...",translate_code_3:"Crunching the figures...",translate_code_4:"Putting it all together...",translate_code_5:"Analyzing the results...",translate_code_6:"Working behind the scenes...",translate_code_7:"Sorting through the details...",translate_code_8:"Preparing your answer...",translate_code_9:"Almost ready...",translate_reasoning_0:"Thinking it through...",translate_reasoning_1:"Considering the options...",translate_reasoning_2:"Weighing the possibilities...",translate_reasoning_3:"Reflecting on this...",translate_reasoning_4:"Working it out...",translate_reasoning_5:"Putting thoughts together...",translate_reasoning_6:"Mulling it over...",translate_reasoning_7:"Finding the best approach...",translate_reasoning_8:"Organizing my thoughts...",translate_reasoning_9:"Almost there...",translate_running:"Running",translate_aborted:"Aborted",translate_input:"Input",translate_output:"Output",translate_calling:"Calling",translate_input_ready:"Input ready",translate_needs_approval:"Needs approval",translate_approved:"Approved",translate_responded:"Responded",translate_declined:"Declined",translate_approve:"Approve",translate_deny:"Deny",translate_error:"Error",translate_approval_requested:"Approval requested",translate_approval_response:"Approval response",translate_waiting_for_approval:"Waiting for approval to execute this tool.",translate_tool_approved:"Approved.",translate_tool_response_received:"Response received.",translate_tokens:"tokens",translate_fresh:"Fresh",translate_cache_read:"Cache read",translate_cache_write:"Cache write",translate_n_percent_cached:"{{percent}}% cached",translate_text:"Text",translate_reasoning:"Reasoning",translate_read:"Read",translate_write:"Write",translate_total:"Total",translate_request:"Request",translate_response:"Response",translate_step_n:"Step {{number}}",translate_inspect_llm_requests:"Inspect LLM requests",translate_loading:"loading…",translate_no_llm_requests:"No LLM requests recorded for this message.",translate_unhandled_type:"Unhandled type:",translate_client_tool_title:"Complete this step to continue",translate_client_tool_loading:"Preparing a secure step...",translate_client_tool_failed:"This step could not be loaded",translate_client_tool_retry:"Try again",translate_client_tool_cancel:"Cancel",translate_location_hint:"Tap the map to drop a pin",translate_location_locate:"Use my location",translate_location_locating:"Finding your location",translate_location_locate_failed:"Your location is not available",translate_location_map_failed:"The map could not be loaded",translate_location_send_failed:"Could not send, try again",translate_location_skip:"Not now",translate_location_send:"Send",translate_location_shared:"Location shared",translate_location_not_shared:"Location not shared",translate_trigger_fired:"Triggered by",translate_trigger_payload:"Payload",translate_messages_disabled:"This agent only runs from its triggers.",translate_streaming:"Streaming",translate_done:"Done",translate_no_reasoning:"No reasoning provided.",translate_copy:"Copy to clipboard",translate_copied:"Copied",translate_media_pending_mermaid:"Drawing diagram",translate_media_pending_vega_lite:"Drawing chart",translate_media_pending_map:"Drawing map",translate_media_cut_off:"This block was cut off before it finished.",translate_media_failed:"Could not render this block.",translate_media_source:"Source",translate_media_pending:"Drawing",translate_media_mermaid:"Diagram",translate_media_vega_lite:"Chart",translate_media_map:"Map",translate_media:"Preview",translate_image_unavailable:"Image unavailable",translate_image_unavailable_alt:"Image unavailable: {{alt}}",translate_image:"Image",translate_send:"Send",translate_table:"Table",translate_expand:"Expand {{name}}",translate_table_export:"Export to Excel",translate_close:"Close",translate_approval_needed:"Needs your approval",translate_approval_action:"Run {{tool}}",translate_approved_failed:"Approved, but it failed",translate_approval_cancelled:"Not decided"};var W5={en:d0,ar:p0};function L1(_){return _&&D1.includes(_)?_:D1[0]}function G_(_,$,Y){let Q=W5[_][$];if(!Y)return Q;return Q.replace(/\{\{\s*(\w+)\s*\}\}/g,(X,Z)=>(Z in Y)?String(Y[Z]):X)}function C_(_,$,Y){return _===1?$:Y}function O1(_,$,Y){let Q=_!==void 0&&_.messages!==!1;return{greeting:H_(_?.greeting,$)||G_($,"translate_greeting"),suggestions:Q&&H_(_.suggestions,$)||[],send:(X)=>{if(Q)Y(X)}}}var D5=["completed","cancelled","failed"],r_="requestLocation";function l0(_,$,Y){if($!==Y)return null;if(typeof _!=="object"||_===null)return null;let Q=_;if(Q.type!=="cortex:client-tool")return null;let X=D5.find((G)=>G===Q.status);if(!X)return null;let Z=Q.reference;return{type:"cortex:client-tool",status:X,...typeof Z==="string"?{reference:Z}:{},...Q.result!==void 0?{result:Q.result}:{}}}var H5=new Set(["complete","error"]);function f(_){return H5.has(_)}function __(_){return(B5(_)?.parts??[]).filter((Y)=>Y.type==="tool-call"&&!f(Y.state))}function w_(_){let $=_.at(-1);if($?.role!=="assistant")return;let Y=$.parts.at(-1),Q=Y?.type==="tool-call"||Y?.type==="tool-result",X=$.parts.every((Z)=>Z.type!=="tool-call"||f(Z.state));return Q&&X?void 0:$}function B5(_){for(let $=_.length-1;$>=0;$-=1){let Y=_[$];if(Y?.role==="assistant")return Y}return}var q5={complete:"success",error:"error","approval-requested":"approval","approval-responded":"approval","awaiting-input":"pending","input-streaming":"pending","input-complete":"pending"},F5={"awaiting-input":"translate_calling","input-streaming":"translate_calling","input-complete":"translate_input_ready","approval-requested":"translate_needs_approval","approval-responded":"translate_responded",complete:"translate_completed",error:"translate_error"};function P1(_){let{state:$,approval:Y}=_;return{modifier:q5[$],labelKey:Y?.approved===!1?"translate_declined":$==="approval-responded"&&Y?.approved?"translate_approved":F5[$],pulse:$==="awaiting-input"||$==="input-streaming"?"default":$==="approval-requested"?"violet":void 0}}function M1(_){let $=_.output;if($===void 0||$===null)return"";if(typeof $==="string")return $;return JSON.stringify($,null,2)}var n0={code:"javascript",query:"cypher"};function A1(_){let $=_&&typeof _==="object"?_:null,Y=$?Object.entries(n0).flatMap(([X,Z])=>{let G=$[X];return typeof G==="string"?[{key:X,lang:Z,value:G.replace(/\\n/g,`
|
|
2
|
-
`)}]:[]}):[],Q=_;if($){let X=Object.fromEntries(Object.entries($).filter(([Z])=>!Object.hasOwn(n0,Z)));Q=Object.keys(X).length>0?X:null}return{codeSnippets:Y,remainingInput:Q,remainingInputText:Q?JSON.stringify(Q,null,2):""}}var
|
|
3
|
-
|
|
4
|
-
`)}function I1(_,$){if($&&_.name in $)return!1;return _.name!==r_||!f(_.state)}function i0(_,$){if(_.type!=="tool-call")return!0;return!f(_.state)&&!_.approval&&$.foldable(_)}function y1(_,$){let Y=w_(_);if(!Y)return;let Q=B_(Y.parts,{debugMode:!1,isStreaming:!0}),X=Q.at(-1);if(X&&i0(X,$))return X;return Q.filter((Z)=>Z.type==="tool-call"&&i0(Z,$)).at(-1)}function C1(){let _=new Map;return($,Y)=>{let Q=new Map;for(let[X,Z]of I5($,Y)){let G=_.get(X);Q.set(X,G&&C5(G,Z)?G:Z)}return _=Q,Q}}function I5(_,$){let Y=new Map;if($.debugMode)return Y;let X=$.agentWorking||__(_).length>0?y5(_):_,Z=[];function G(){let J=Z[0]?.part.id;if(Z.length>1&&J&&!$.opened.has(J))for(let[N,{messageId:V,part:K}]of Z.entries()){let z=Y.get(V)??new Map;Y.set(V,z);let F=N===Z.length-1;z.set(K,F?{kind:"more",count:Z.length-1,runId:J}:{kind:"hidden"})}Z=[]}for(let J of X){if(J.role!=="assistant"){G();continue}let N=B_(J.parts,{debugMode:!1,isStreaming:!1});for(let V of N)if(V.type==="tool-call"&&f(V.state)&&$.foldable(V))Z.push({messageId:J.id,part:V});else G()}return G(),Y}function y5(_){let $=_.map((Y)=>Y.role).lastIndexOf("user");return $<0?[]:_.slice(0,$)}function C5(_,$){if(_.size!==$.size)return!1;for(let[Y,Q]of _){let X=$.get(Y);if(!X||X.kind!==Q.kind)return!1;if(Q.kind==="more"&&X.kind==="more"){if(Q.count!==X.count||Q.runId!==X.runId)return!1}}return!0}import{EventType as t0}from"@tanstack/ai";import{fetchServerSentEvents as a0}from"@tanstack/ai-client";function w5(_){for(let $=_.length-1;$>=0;$-=1){let Y=_[$],Q="parts"in Y&&Y.parts.some((X)=>X.type==="tool-result"||X.type==="tool-call"&&X.state==="approval-responded");if(Y.role==="user"||Q)return _.slice($,$+1)}return _.slice(-1)}function S5(_){if(_.state==="approval-responded"){let $=_.approval?.approved;if($===void 0)return null;return{toolCallId:_.id,output:null,state:$?"approved":"denied"}}if(!f(_.state))return null;return{toolCallId:_.id,output:_.output??null,state:_.state==="error"?"error":"complete"}}function b5(_){let[$]=_;if(!$||$.role!=="assistant"||!("parts"in $))return null;let Y=$.parts.flatMap((Q)=>{let X=Q.type==="tool-call"?S5(Q):null;return X?[X]:[]});return Y.length>0?Y:null}async function*o0(_,$,Y){for await(let Q of _){if(Q.type!==t0.MESSAGES_SNAPSHOT){yield Q;continue}let X=$.localMessages(),Z=X.findIndex((J)=>J.id===Y),G=Z===-1?[]:X.slice(Z+1).filter((J)=>J.role==="user");$.onTranscriptCarried?.(Q.timestamp??Date.now()),yield{...Q,messages:[...Q.messages,...G]}}}function w1(_){let{api:$,thread:Y}=_,Q=async()=>({headers:await $.resolveHeaders()}),X=a0(()=>$.resolveUrl("/chat"),Q),Z=function(N,V,K,z){let F=w5(N),B=b5(F),q=B?X.connect([],{...V,[h0]:B},K,z):X.connect(F,V,K,z);return o0(q,_,N.at(-1)?.id)},G=a0(()=>$.resolveUrl(`/chat/${Y.id}/stream`),Q),J=[];return{connect:Z,async*joinRun(N,V){yield{type:t0.MESSAGES_SNAPSHOT,timestamp:Date.now(),messages:J},yield*o0(G.joinRun(N,V),_,J.at(-1)?.id)},hydrate:async()=>{let N=await T5(_);return J=N.messages,N}}}async function T5(_){let{api:$,thread:Y,mode:Q}=_,X=Y.isRunning?{runId:Y.id}:null;if(Q==="skip")return{messages:[],activeRun:X,interrupts:null};if(Q==="load")_.setLoadingMessages?.(!0);try{let G=(await $.listMessages(Y.id)).map(B1);return _.onHydrated?.(G),{messages:G,activeRun:X,interrupts:null}}finally{_.setLoadingMessages?.(!1)}}async function S1(_){if(_.isStale?.()||_.isStreaming())return;try{let $=await _.api.listMessages(_.threadId);if(_.isStale?.()||_.isStreaming())return;let Y=$.map(B1);return _.setMessages(Y),Y}catch{return}}function S_(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let _=crypto.getRandomValues(new Uint8Array(16));_[6]=_[6]&15|64,_[8]=_[8]&63|128;let $=Array.from(_,(Y)=>Y.toString(16).padStart(2,"0")).join("");return`${$.slice(0,8)}-${$.slice(8,12)}-${$.slice(12,16)}-${$.slice(16,20)}-${$.slice(20)}`}function b1(_){let{api:$}=_,Y=new Set,Q=new Set,X=[],Z=[];function G(){return X}function J(D){return Y.add(D),()=>{Y.delete(D)}}function N(D){X=D;for(let H of Y)H()}function V(D,H){N(X.map((W)=>W.localId===D?{...W,...H}:W))}function K(D){if(Q.delete(D))return;V(D,{status:"error"})}function z(D){let H=[];for(let W of D){let M=m0(W.type,W.size)!=="ok"||X.filter((k)=>k.status!=="error").length>=g0,A=S_();if(N([...X,{localId:A,filename:W.name,status:M?"error":"uploading"}]),!M)H.push({localId:A,file:W})}if(!H.length)return;_.ensureThread().then((W)=>{for(let{localId:M,file:A}of H){if(Q.delete(M))continue;V(M,{threadId:W}),$.uploadAttachment(W,A).then((k)=>{if(Q.delete(M)){$.deleteAttachment(k.id).catch(()=>{});return}V(M,{status:"ready",attachmentId:k.id,summary:k})},()=>K(M))}},()=>{for(let{localId:W}of H)K(W)})}function F(D){let H=X.find((W)=>W.localId===D);if(!H)return;if(H.status==="uploading"){Q.add(D),N(X.filter((W)=>W.localId!==D));return}if(H.attachmentId){V(D,{status:"deleting"}),$.deleteAttachment(H.attachmentId).then(()=>N(X.filter((W)=>W.localId!==D)),()=>V(D,{status:"error"}));return}N(X.filter((W)=>W.localId!==D))}function B(D){let H=[];for(let W of X){if(W.threadId!==void 0&&W.threadId!==D){H.push(W);continue}if(W.status==="uploading")Q.add(W.localId);else if(W.status==="ready"&&W.threadId===D&&W.attachmentId)$.deleteAttachment(W.attachmentId).catch(()=>{})}N(H)}function q(){let D=X.flatMap((H)=>H.status==="ready"&&H.summary?[{...H,status:"ready",summary:H.summary}]:[]);return N(X.filter((H)=>H.status!=="ready")),Z=D,D}function O(D){let H=Z;if(Z=[],H.some((W)=>W.threadId!==D))return;N([...H.map((W)=>({...W,status:"error"})),...X])}function P(){Z=[]}return{getState:G,subscribe:J,accept:z,remove:F,clear:B,consumeReady:q,restoreConsumed:O,discardConsumed:P}}function T1(_){return{uploading:_.some(($)=>$.status==="uploading"),busy:_.some(($)=>$.status==="uploading"||$.status==="deleting"),hasReady:_.some(($)=>$.status==="ready")}}function v1(_,$,Y){try{return new URL(_).origin===$&&!Y?"allow-scripts allow-forms allow-popups":"allow-scripts allow-forms allow-popups allow-same-origin"}catch{return"allow-scripts allow-forms allow-popups"}}function f1(_,$,Y){try{return Y===!0&&new URL(_).origin===$}catch{return!1}}function j1(_,$){try{return _.contentWindow?.location.origin===$}catch{return!1}}function g1(_){let $=!1,Y=!1,Q,X;function Z(N){if(!$)_.onState(N)}function G(){if($)return;Y=!1,Z({phase:"error"})}function J(N){if($||Y)return;Y=!0,Z({phase:"settling"});try{let V=_.submit(N);if(V instanceof Promise)V.catch(G)}catch{G()}}return{async start(){Z({phase:"initiating"});try{let N=await _.initiate();if(!N.embed){Z({phase:"unavailable"});return}if(!/^https?:$/.test(new URL(N.embedUrl).protocol)){Z({phase:"error"});return}Q=N.embedOrigin,Z({phase:"embedded",embedUrl:N.embedUrl,surface:N.surface,embedOrigin:N.embedOrigin})}catch(N){let V=N instanceof Error?N.message:"";Z({phase:/HTTP 404/.test(V)?"unavailable":"error"})}},setSource(N){if(N!==null&&N!==void 0)X=N},handleMessage(N){if(!Q)return;if(X===void 0||N.source!==X)return;let V=l0(N.data,N.origin,Q);if(!V)return;J({status:V.status,reference:V.reference,result:V.result})},cancel(){J({status:"cancelled"})},terminate(){if($||Y)return;Q=void 0,X=void 0,Z({phase:"error"})},dispose(){$=!0}}}function m1(_,$,Y){let Q=_.interrupts.find((X)=>X.id===$);if(!Q||!("resolveInterrupt"in Q))return _.addToolApprovalResponse({id:$,approved:Y});return Q.resolveInterrupt({approved:Y}),Promise.resolve()}async function b_(_,$){let Y=await import("leaflet"),Q=!$.interactive,X=Y.map(_,{center:$.center,zoom:$.zoom,zoomControl:!Q,dragging:!Q,scrollWheelZoom:!Q,doubleClickZoom:!Q,touchZoom:!Q,boxZoom:!Q,keyboard:!Q});Y.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'}).addTo(X);let Z=new ResizeObserver(()=>X.invalidateSize());return Z.observe(_),{leaflet:Y,map:X,dispose(){Z.disconnect(),X.remove()}}}var a_={position:void 0,locating:!1,locateFailed:!1,mapFailed:!1,submitting:!1,deliveryFailed:!1},v5={center:{lat:20,lng:0},zoom:2},f5=13,e0=16,j5=1e4;function x1(_,$){let Y=a_,Q=!1,X=!1,Z,G,J,N=0;function V(B){if(Y={...Y,...B},!Q)$.onState(Y)}function K(){let B=Y.position;if(!Z||!B)return;let{leaflet:q,map:O}=Z;if(G)G.setLatLng(B);else{let P=q.marker(B,{draggable:!Y.submitting}).addTo(O);P.on("dragend",()=>{let{lat:D,lng:H}=P.getLatLng();z({lat:D,lng:s0(H)})}),G=P}J?.remove(),J=B.accuracy?q.circle(B,{radius:B.accuracy}).addTo(O):void 0}function z(B){if(Y.submitting)return;N+=1,V({position:B,locating:!1,locateFailed:!1}),K()}function F(B){if(Q||X)return;X=!0,N+=1,G?.dragging?.disable(),V({submitting:!0,locating:!1,deliveryFailed:!1});let q=()=>{X=!1,G?.dragging?.enable(),V({submitting:!1,deliveryFailed:!0})};try{let O=$.submit(B);if(O instanceof Promise)O.catch(q)}catch{q()}}return{async start(){let B=$.center?{center:$.center,zoom:f5}:v5,q;try{q=await b_(_,{...B,interactive:!0})}catch{V({mapFailed:!0});return}if(Q){q.dispose();return}Z=q,q.map.on("click",(O)=>z({lat:O.latlng.lat,lng:s0(O.latlng.lng)})),K()},locate(){if(Y.locating||Y.submitting)return;if(!navigator.geolocation){V({locateFailed:!0});return}N+=1;let B=N;V({locating:!0,locateFailed:!1}),navigator.geolocation.getCurrentPosition(({coords:q})=>{if(Q||B!==N)return;let O={lat:q.latitude,lng:q.longitude,accuracy:Math.round(q.accuracy)};z(O),Z?.map.setView(O,e0)},()=>{if(B===N)V({locating:!1,locateFailed:!0})},{enableHighAccuracy:!0,timeout:j5})},confirm(){if(Y.position)F({status:"completed",result:Y.position})},cancel(){F({status:"cancelled"})},dispose(){Q=!0,Z?.dispose()}}}function h1(_,$,Y){let Q=!1,X;return b_(_,{center:$,zoom:e0,interactive:!1}).then((Z)=>{if(Q){Z.dispose();return}X=Z.dispose,Z.leaflet.marker($).addTo(Z.map)},()=>{if(!Q)Y()}),()=>{Q=!0,X?.()}}function s0(_){if(_>=-180&&_<=180)return _;return((_+180)%360+360)%360-180}function _6(_){if(!_||typeof _!=="object")return!1;let{lat:$,lng:Y}=_;return typeof $==="number"&&typeof Y==="number"&&Math.abs($)<=90&&Math.abs(Y)<=180}function u1(_){let $=_&&typeof _==="object"?_.center:void 0;return _6($)?$:void 0}function c1(_){if(!_||typeof _!=="object")return;let{status:$,result:Y}=_;if($!=="completed"||!_6(Y))return;let{accuracy:Q}=Y;return{...Y,...typeof Q==="number"?{accuracy:Q}:{}}}function o_(_){let $=`${_.lat.toFixed(4)}, ${_.lng.toFixed(4)}`;return _.accuracy?`${$} ±${_.accuracy} m`:$}function p1(_){if(_.locating)return{key:"translate_location_locating",failed:!1};if(_.deliveryFailed)return{key:"translate_location_send_failed",failed:!0};if(_.locateFailed)return{key:"translate_location_locate_failed",failed:!0};if(_.mapFailed)return{key:"translate_location_map_failed",failed:!0};return{key:"translate_location_hint",failed:!1}}function d1(_){return Math.min(1000*2**(_-1),30000)}var g5=1e4;function l1(_){let $,Y,Q=0,X=!1;function Z(){let{wsUrl:J,transport:N}=_.getConfig();if(J===!1)return;let V=m5(J,N.baseUrl);F1(N).then((K)=>{if(X)return;$=new WebSocket(x5(V,K)),$.addEventListener("open",()=>{let z=$;setTimeout(()=>{if($===z&&!X)Q=0},g5),_.onOpen?.()}),$.addEventListener("message",(z)=>{let F=z.data;if(typeof F!=="string")return;let B;try{B=JSON.parse(F)}catch{return}_.onEvent(B)}),$.addEventListener("close",G)}).catch(G)}function G(){if(X||Y)return;Q+=1,Y=setTimeout(()=>{Y=void 0,Z()},d1(Q))}return Z(),{close(){X=!0,clearTimeout(Y),$?.close()}}}function m5(_,$){if(_)return _;let Y=typeof $==="string"?$:$(),Q=new URL(Y,window.location.origin);return Q.protocol=Q.protocol==="https:"?"wss:":"ws:",Q.pathname=Q.pathname.replace(/\/$/,"")+"/ws",Q.toString()}function x5(_,$){let Y=$.Authorization??$.authorization;if(!Y?.startsWith("Bearer "))return _;let Q=new URL(_,window.location.origin);if(Q.searchParams.has("token"))return Q.toString();return Q.searchParams.set("token",Y.slice(7)),Q.toString()}function n1(_,$,Y=d1){let Q=!1,X,Z=0;function G(){_.getCapabilities().then((J)=>{if(!Q)$(J)},()=>{if(Q)return;Z+=1,X=setTimeout(G,Y(Z))})}return G(),function(){Q=!0,clearTimeout(X)}}function t_(_){return[..._].sort(($,Y)=>{let Q=Date.parse(Y.updatedAt)-Date.parse($.updatedAt);if(Q!==0)return Q;return Date.parse(Y.createdAt)-Date.parse($.createdAt)})}function T_(_,$){let Y=[..._],Q=Y.findIndex((X)=>X.id===$.id);if(Q===-1)Y.push($);else Y[Q]={...Y[Q],...$};return t_(Y)}function s_(_,$){return _.filter((Y)=>Y.id!==$)}function i1(_,$){switch($.type){case"thread:deleted":return s_(_,$.payload.threadId);case"thread:created":case"thread:title-updated":case"thread:run-started":case"thread:run-finished":case"thread:messages-updated":return T_(_,$.payload.thread);default:return _}}import{marked as h5}from"marked";import u5 from"dompurify";function v_(_,$=[]){if(!_)return"";let Y=h5.parse(_,{async:!1});if(Y=Y.replace(/<table>/g,'<div style="overflow-x:auto"><table style="width:max-content">').replace(/<\/table>/g,"</table></div>").replace(/<(t[hd])([\s>])/g,'<$1 style="padding:0.5rem 1rem"$2'),$.length)Y=c5(Y,$);return u5.sanitize(Y,{FORBID_TAGS:["img","picture","source"]})}function c5(_,$){let Y=document.createElement("template");Y.innerHTML=_;let Q=[...$].sort((G,J)=>G.length-J.length),X=Q[Q.length-1]?.length??0,Z=0;for(let G of p5(Y.content)){if(Z>=X)break;G.replaceWith(...d5(G.data,Z,Q)),Z+=G.data.length}return Y.innerHTML}function p5(_){let $=document.createTreeWalker(_,4),Y=[];for(let Q=$.nextNode();Q;Q=$.nextNode())if(Q.data.trim())Y.push(Q);return Y.reverse()}function d5(_,$,Y){let Q=[],X=_.length;for(let Z of Y){if(Z.length<=$)continue;if(X<=0)break;let G=Math.min(X,Z.length-$);if(G<X&&/[\uDC00-\uDFFF]/.test(_[X-G]))G+=1;let J=document.createElement("span");J.className="cortex-stream-fade",J.style.animationDelay=`-${Z.age}ms`,J.textContent=_.slice(X-G,X),Q.unshift(J),X-=G,$+=G}if(X>0)Q.unshift(document.createTextNode(_.slice(0,X)));return Q}import{marked as Y6}from"marked";function $6(){let _=null;return($)=>{let Y=/^ {0,3}(`{3,}|~{3,})(.*)$/.exec($),Q=Y?.[1],X=Y?.[2]??"";if(Q){let Z=Q.charAt(0);if(_){if(Z===_.marker&&Q.length>=_.length&&X.trim()==="")return _=null,"close";return"inside"}if(Z==="`"&&X.includes("`"))return"outside";return _={marker:Z,length:Q.length},"open"}return _?"inside":"outside"}}var l5=/^\s*!\[([^\]]*)\]\(attachment#([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\)\s*$/i,n5=/^\s*(`{3,}|~{3,})/;function r1(_,$){let Y=[],Q=[],X=null;function Z(V=!1){if(Q.length)Y.push(...r5(Q.join(`
|
|
5
|
-
`),
|
|
6
|
-
`),closed:
|
|
7
|
-
`);for(let[
|
|
8
|
-
`),Z=(
|
|
9
|
-
|
|
10
|
-
${
|
|
11
|
-
`));return($.textContent??"").trim()}function
|
|
12
|
-
|
|
13
|
-
`).find((Y)=>/\S/.test(Y)&&!/^\s*%%/.test(Y));return/^\s*(\S+)/.exec($??"")?.[1]??""}function Y0(_){return _===void 0||_==="container"}var F8=["row","column","facet"];function q6(_){let $=_.encoding,Y=typeof $==="object"&&$!==null&&F8.some((Q)=>(Q in $));return(("mark"in _)||("layer"in _))&&Y0(_.width)&&!Y}function U8(_){let $={..._};if(Y0($.width))delete $.width;if(Y0($.height))delete $.height;return $}function L8(_,$){let Y=U8(_);if($<=0||!q6(_))return Y;return{...Y,width:$,height:Y.height??Math.round(Math.min(480,Math.max(200,$/2))),autosize:Y.autosize??{type:"fit",contains:"padding"}}}var O8="vg-tooltip-element",K6=Promise.resolve(),z6=!1,W6=0;function P8(){return W6+=1,W6}var M8=new Set(["image","use","feImage"]);function D6(_){for(let $ of[_,..._.querySelectorAll("*")]){for(let Y of[...$.attributes])if((Y.name==="href"||Y.name==="xlink:href")&&M8.has($.tagName)&&!Y.value.trim().startsWith("#")||e_(Y.value))$.removeAttribute(Y.name);if($.tagName==="style"&&$.textContent)$.textContent=$0($.textContent)}}function A8(_){if(!_||typeof _!=="object")throw Error("A map needs a JSON object.");let $=_,Y=$.zoom??10;if(typeof Y!=="number"||Y<0||Y>22)throw Error("zoom must be 0 to 22.");let Q=$.markers??[];if(!Array.isArray(Q))throw Error("markers must be a list.");return{center:H6($.center,"center"),zoom:Y,markers:Q.map((X,Z)=>{let G=X??{},J=G.label;return{position:H6(G.position,`markers[${Z}].position`),label:typeof J==="string"?J:void 0}})}}function H6(_,$){let Y=Array.isArray(_)?_:[],[Q,X]=Y;if(typeof Q!=="number"||typeof X!=="number"||Math.abs(Q)>90||Math.abs(X)>180)throw Error(`${$} must be [latitude, longitude].`);return{lat:Q,lng:X}}function Z0(_,$){if(_!=="system")return $(_??"light"),()=>{};let Y=window.matchMedia("(prefers-color-scheme: dark)"),Q=()=>$(Y.matches?"dark":"light");return Q(),Y.addEventListener("change",Q),()=>Y.removeEventListener("change",Q)}import j_ from"highlight.js/lib/core";import E8 from"highlight.js/lib/languages/javascript";import k8 from"highlight.js/lib/languages/json";import R8 from"highlight.js/lib/languages/sql";var F6=!1;function I8(){if(F6)return;F6=!0,j_.registerLanguage("javascript",E8),j_.registerLanguage("json",k8),j_.registerLanguage("cypher",R8)}function G0(_,$){if(!_)return"";return I8(),j_.getLanguage($)?j_.highlight(_,{language:$}).value:y8(_)}function y8(_){return _.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function q_(_){if(typeof _==="string"){let $=_.trim();if(!($.startsWith("{")&&$.endsWith("}")||$.startsWith("[")&&$.endsWith("]")))return _;try{return q_(JSON.parse($))}catch{return _}}if(Array.isArray(_))return _.map(($)=>q_($));if(_!==null&&typeof _==="object"){let $={};for(let[Y,Q]of Object.entries(_))$[Y]=q_(Q);return $}return _}function J0(_,$){if(Array.isArray(_)){let Y=_;return{kind:"container",open:"[",close:"]",summary:U6(Y.length,"item","items"),entries:Y.map((Q,X)=>({key:null,value:Q,path:`${$}[${X}]`}))}}if(_!==null&&typeof _==="object"){let Y=Object.entries(_);return{kind:"container",open:"{",close:"}",summary:U6(Y.length,"property","properties"),entries:Y.map(([Q,X])=>({key:Q,value:X,path:`${$}.${Q}`}))}}return{kind:"primitive",text:C8(_),className:w8(_)}}function U6(_,$,Y){return`${_} ${_===1?$:Y}`}function C8(_){if(_===null||_===void 0)return"null";if(typeof _==="string")return JSON.stringify(_);if(typeof _==="number"||typeof _==="boolean")return String(_);return JSON.stringify(_)??"null"}function w8(_){if(_===null||_===void 0)return"cortex-json-tree__null";if(typeof _==="string")return"cortex-json-tree__string";if(typeof _==="number")return"cortex-json-tree__number";if(typeof _==="boolean")return"cortex-json-tree__boolean";return""}function N0(_){if(!_)return null;try{return JSON.parse(_)}catch{return _}}function V0(_){if(!_)return"";try{return JSON.stringify(JSON.parse(_),null,2)}catch{return _}}function r(_,$,Y=Date.now()){let Q=new Date(_);if(Number.isNaN(Q.getTime()))return"";let X=Q.toDateString()===new Date(Y).toDateString();return new Intl.DateTimeFormat($,{...X?{}:{dateStyle:"medium"},timeStyle:"short"}).format(Q)}function g_(_,$){let Y=URL.createObjectURL(_),Q=document.createElement("a");Q.href=Y,Q.download=$,document.body.append(Q),Q.click(),Q.remove(),setTimeout(()=>URL.revokeObjectURL(Y),40000)}class $_{onUpdate;fullText="";displayedLength=0;animationFrameId=null;isDone=!1;releases=[];static DRAIN_FRACTION=0.03;static MIN_CHARS_PER_FRAME=1;static DONE_DRAIN_FRACTION=0.1;static FADE_WINDOW_MS=500;constructor(_){this.onUpdate=_}seed(_){this.fullText=_,this.displayedLength=_.length,this.releases=[],this.onUpdate(_,[])}update(_,$){if(this.fullText=_,this.isDone=$,this.displayedLength=Math.min(this.displayedLength,this.fullText.length),this.releases=this.releases.filter((Y)=>Y.from<this.displayedLength),$&&this.displayedLength>=this.fullText.length){this.onUpdate(this.fullText,[]),this.stopAnimation();return}if(!this.animationFrameId)this.scheduleFrame()}destroy(){this.stopAnimation()}scheduleFrame(){this.animationFrameId=requestAnimationFrame((_)=>this.tick(_))}tick(_){let $=this.fullText.length-this.displayedLength;if($<=0){this.animationFrameId=null;return}let Y=this.isDone?$_.DONE_DRAIN_FRACTION:$_.DRAIN_FRACTION,Q=Math.max($_.MIN_CHARS_PER_FRAME,Math.ceil($*Y));if(this.releases=this.releases.filter((X)=>_-X.at<$_.FADE_WINDOW_MS),this.releases.push({from:this.displayedLength,at:_}),this.displayedLength=Math.min(this.fullText.length,this.displayedLength+Q),this.onUpdate(this.fullText.substring(0,this.displayedLength),this.releases.map((X)=>({length:this.displayedLength-X.from,age:_-X.at}))),this.displayedLength<this.fullText.length)this.scheduleFrame();else this.animationFrameId=null}stopAnimation(){if(this.animationFrameId)cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null}}var K0=new WeakMap;function z0(_,$){let Y=_.closest(".cortex-widget__screen"),Q=Y?.querySelector(".cortex-message-list");if(!Y||!Q||!_.value.trim())return;let X=getComputedStyle(_),Z=_.getBoundingClientRect(),G=(J)=>parseFloat(X[`padding${J}`])+parseFloat(X[`border${J}Width`]);K0.set(Y,{text:$,textarea:_,from:new DOMRect(Z.left+G("Left"),Z.top+G("Top"),Z.width-G("Left")-G("Right"),Z.height-G("Top")-G("Bottom")),rtl:X.direction==="rtl",scrollTop:Q.scrollTop})}function W0(_,$){let Y=_.closest(".cortex-widget__screen"),Q=Y?K0.get(Y):void 0;if(!Y||!Q)return;K0.delete(Y);let X=_.querySelectorAll(":scope > .cortex-message"),Z=X[X.length-1]?.querySelector(".cortex-text-bubble--user"),G=_.closest(".cortex-message-list");if(!Z||!G||Q.text!==$||!Q.textarea.isConnected)return;Z.closest(".cortex-message-part")?.getAnimations().forEach((D)=>D.finish()),$1(G);let J=Z.getBoundingClientRect(),N=Y.getBoundingClientRect(),V=getComputedStyle(Z),K=parseFloat(V.paddingTop)+parseFloat(V.borderTopWidth),z=Q.rtl?parseFloat(V.paddingRight)+parseFloat(V.borderRightWidth):parseFloat(V.paddingLeft)+parseFloat(V.borderLeftWidth),F=Q.rtl?Q.from.right+z-J.width:Q.from.left-z,B=G.scrollTop-Q.scrollTop;if(B)_.style.setProperty("--cortex-slide",`${B}px`),_.classList.remove("cortex-message-list__content--settling"),_.offsetWidth,_.classList.add("cortex-message-list__content--settling"),_.getAnimations()[0]?.finished.then(()=>_.classList.remove("cortex-message-list__content--settling"),()=>{return});let q=Z.cloneNode(!0);q.classList.add("cortex-send-flight"),q.setAttribute("aria-hidden","true"),Object.assign(q.style,{left:`${J.left-N.left}px`,top:`${J.top-N.top}px`,width:`${J.width}px`}),q.style.setProperty("--cortex-fly-x",`${F-J.left}px`),q.style.setProperty("--cortex-fly-y",`${Q.from.top-K-J.top}px`),Z.style.visibility="hidden",Y.append(q);let O=G.scrollTop,P=()=>{q.style.top=`${J.top-N.top-(G.scrollTop-O)}px`};G.addEventListener("scroll",P,{passive:!0}),P6(q).then(()=>{G.removeEventListener("scroll",P),Z.style.visibility="",q.remove()})}function $1(_){_.scrollTop=O6(_)}function D0(_){return O6(_)-_.scrollTop}function O6(_){let $=_.querySelector(".cortex-message-list__content");if(!$)return _.scrollHeight-_.clientHeight;let Y=getComputedStyle(_);return $.offsetHeight+parseFloat(Y.paddingTop)+parseFloat(Y.paddingBottom)-_.clientHeight}function H0(_){let $=!1,Y=_.parentElement,Q=typeof ResizeObserver>"u"?void 0:new ResizeObserver(X);Q?.observe(Y);function X(){let Z=Y.querySelector(":scope > .cortex-working-thinking, :scope > .cortex-message > .cortex-message-parts > [data-cortex-frontier]");if(!Z)return!1;return _.style.setProperty("--cortex-avatar-y",`${S8(Z,Y)-_.offsetHeight/2}px`),!0}return{sync(Z){if(Z===$){if(Z)X();return}if(Z){if(!X())return;_.classList.remove("cortex-working-avatar--leaving"),_.offsetWidth,_.classList.add("cortex-working-avatar--shown"),$=!0;return}$=!1,_.classList.add("cortex-working-avatar--leaving"),P6(_,!0).then(()=>{if($)return;_.classList.remove("cortex-working-avatar--shown","cortex-working-avatar--leaving")})},dispose(){Q?.disconnect()}}}function S8(_,$){let Y=_.querySelector(".cortex-text-bubble");if(!Y)return L6(_,$)+_.offsetHeight/2;let Q=getComputedStyle(Y);return L6(Y,$)+parseFloat(Q.paddingTop)+parseFloat(Q.borderTopWidth)+parseFloat(Q.lineHeight)/2}function L6(_,$){let Y=0;for(let Q=_;Q instanceof HTMLElement&&Q!==$;)Y+=Q.offsetTop,Q=Q.offsetParent;return Y}function P6(_,$=!1){return Promise.allSettled(_.getAnimations({subtree:$}).map((Y)=>Y.finished))}var b8=2;function B0(_){let $=!1,Y=!1,Q=!1,X=!1,Z=!1,G=!1,J,N=new Set,V=0,K=!1;function z(){if($&&V===0)return!1;if(V+=1,!$)$=!0,_.setRunning(!0);return!0}function F(D){if(V-=1,D)K=!0;else if(V===0&&!K)$=!1,_.setRunning(!1)}async function B(D,H){for(let W=0;W<b8;W+=1){let M=await _.refreshMessages().catch(()=>{return});if(!_.isAlive())return!1;if(!M)continue;if(!__(M).some((k)=>k.id===D.id))return!0;if(await _.deliver(H).then(()=>!0,()=>!1))return!0}return!1}async function q(D,H){let W;try{let n=H({toolCallId:D.id,toolName:D.name,input:D.input},{threadId:_.threadId});if(n===null||n===void 0)return;W=await Promise.resolve(n)}catch{N.delete(D.id);return}if(W===null||W===void 0)return;if(!_.isAlive())return;let M=z(),A={toolCallId:D.id,tool:D.name,output:W},k=await _.deliver(A).then(()=>!0,()=>B(D,A));if(M)F(k);if(!k)N.delete(D.id)}function O(D){let H=__(D),W=_.onToolCall();if(!W)return H.length>0;for(let M of H){if(M.state!=="input-complete"||N.has(M.id))continue;N.add(M.id),q(M,W)}return H.length>0}async function P(D){let H=X;if(X=!1,!H&&$){if(O(D()))return;if(Q)_.reloadThreads().catch(()=>{});else _.setRunning(!1)}if(J===void 0&&(G||H))return;J=void 0;let W=await _.refreshMessages();if(!H&&$&&W)O(W)}return{chunkArrived(){Y=!0},transcriptCarried(D){if(G=!0,J!==void 0&&J<=D)J=void 0},transcriptUpdated(D){if(!Z){_.refreshMessages();return}J=Math.max(J??0,Date.parse(D))},streamFailed(){if(Q=!0,Y)_.onTurnFinished();else _.onSendFailed()},loadingChanged(D,H){if(D){Z=!0,Q=!1,G=!1;return}if(!Z)return;Z=!1,_.onTurnFinished(),P(H)},hydrated(D,H){if(H)return;setTimeout(()=>{if(_.isAlive())O(D)},0)},sendStarted(){_.setRunning(!0),$=!0,Y=!1},abortConfirmed(){X=!0,_.setRunning(!1)}}}function m_(_){if(_.input.total<=0)return null;return Math.round(_.input.cacheRead/_.input.total*100)}import{createContext as M6,useContext as A6}from"react";var q0=M6(void 0);function L(){let _=A6(q0);if(!_)throw Error("useCortex must be used inside <CortexChatWidget>");return _}var F0={messages:[],isAgentWorking:!1,isLoadingMessages:!1,hasPendingToolCalls:!1},U0=M6(F0);function F_(){return A6(U0)}import{useEffect as T8,useState as v8}from"react";function E6(_,$){let[Y,Q]=v8();return T8(()=>{return Q(void 0),n1(_,Q)},[_,$]),Y}import{useRef as c8}from"react";import{useRef as f8,useState as j8,useSyncExternalStore as g8}from"react";function k6(_,$){let Y=f8($);Y.current=$;let[Q]=j8(()=>b1({api:_,ensureThread:()=>Y.current()})),X=g8(Q.subscribe,Q.getState,Q.getState);return{store:Q,value:{items:X,...T1(X),accept:Q.accept,remove:Q.remove,consumeReady:Q.consumeReady}}}import{useEffect as m8,useRef as x8}from"react";function R6(_,$){let Y=x8(void 0);m8(()=>{if($===Y.current)return;_.clear(Y.current),Y.current=$},[$,_])}import{useRef as I6}from"react";function y6(_){let $=I6([]),Y=I6(void 0);function Q(){let Z=_.selectedRef.current;if(Z)return Promise.resolve(Z.id);return Y.current??=_.api.createThread().then((G)=>{return Y.current=void 0,_.onCreated(G),G.id},(G)=>{throw Y.current=void 0,G}),Y.current}async function X(Z,G=[]){let J=_.sessionRef.current;if(J){await J.send(Z,G);return}$.current.push({prompt:Z,attachments:G});try{await Q()}catch(N){throw $.current=[],N}}return{ensureThread:Q,send:X,pendingSendRef:$}}import{useRef as h8,useState as u8}from"react";function C6(_){let[$,Y]=u8(),Q=$?.thread,X=Q?_.threads?.find((V)=>V.id===Q.id)??Q:void 0,Z=h8(X);Z.current=X;function G(V,K){if(Z.current?.id===V.id&&_.hasSession())return;let z=Z.current;if(Z.current=V,Y({thread:V,mode:K,epoch:0}),z&&z.id!==V.id)_.getHooks()?.onThreadDeselected?.(z);_.getHooks()?.onThreadSelected?.(V)}function J(){let V=Z.current;if(!V&&!_.hasSession())return;if(Z.current=void 0,Y(void 0),V)_.getHooks()?.onThreadDeselected?.(V)}function N(V,K){Y((z)=>({thread:V,mode:"reload",epoch:(z?.epoch??0)+1,initialMessages:K}))}return{session:$,selected:X,selectedRef:Z,select:G,deselect:J,remount:N}}function w6(_){let{api:$,threads:Y}=_,Q=c8(void 0),X=C6({threads:Y.threads,getHooks:_.getHooks,hasSession:()=>Q.current!==void 0}),Z=y6({api:$,sessionRef:Q,selectedRef:X.selectedRef,onCreated:(V)=>{Y.upsert(V),X.select(V,"skip")}}),G=k6($,Z.ensureThread);R6(G.store,X.selected?.id);async function J(V){if(X.selectedRef.current?.id===V)X.deselect();await Y.remove(V)}function N(V){X.select(V,"load")}return{sessionRef:Q,selection:X,queue:G,deleteThread:J,openThread:N,...Z}}import{useEffect as p8,useRef as d8}from"react";function S6(_){let $=d8(_);$.current=_,p8(()=>{$.current.onMount();let Y=!1,Q=l1({getConfig:()=>$.current.getConfig(),onEvent:(X)=>$.current.onEvent(X),onOpen:()=>{if(Y)$.current.onReconnect();Y=!0}});return()=>Q.close()},[])}function b6(_){let{threads:$,selectedRef:Y,sessionRef:Q}=_;function X(G){$.applyEvent(G);let J=Y.current?.id;switch(G.type){case"thread:deleted":if(J===G.payload.threadId)_.deselect();break;case"thread:run-started":if(J===G.payload.thread.id)Q.current?.reattach(G.payload.thread);break;case"thread:messages-updated":Q.current?.transcriptUpdated(G.payload.thread.id,G.payload.thread.updatedAt);break}}function Z(){_.onReconnect(),$.reload().then((G)=>{let J=Y.current;if(!J)return;Q.current?.reattach(G.find((N)=>N.id===J.id)??J)})}return{onEvent:X,onReconnect:Z}}function T6(_){return{abort:async()=>{await _.current?.abort()},addToolResult:($,Y,Q)=>_.current?.addToolResult($,Y,Q)??Promise.resolve(),respondToApproval:($,Y)=>_.current?.respondToApproval($,Y)??Promise.resolve()}}import{useState as l8}from"react";function v6(_){let[$,Y]=l8();async function Q(){let N=t_(await _.listThreads());return Y(N),N}function X(N){Y((V)=>T_(V??[],N))}function Z(N,V){Y((K)=>{let z=K?.find((F)=>F.id===N);return z?T_(K??[],{...z,isRunning:V}):K})}async function G(N){await _.deleteThread(N),Y((V)=>V?s_(V,N):V)}function J(N){Y((V)=>{let K=i1(V??[],N);return V||K.length?K:V})}return{threads:$,reload:Q,upsert:X,setRunning:Z,remove:G,applyEvent:J}}import{useState as f6}from"react";function j6(_){let[$,Y]=f6("chat"),[Q,X]=f6(!1);return{screen:$,sidebarOpen:Q,showChat:()=>{Y("chat"),X(!1)},openHistory:()=>_==="full"?X(!0):Y("threads"),closeHistory:()=>_==="full"?X(!1):Y("chat"),closeSidebar:()=>X(!1)}}import{forwardRef as s8,useEffect as e8,useImperativeHandle as _4,useRef as c6,useState as $4}from"react";function U(..._){return _.filter(Boolean).join(" ")}import{useState as n8}from"react";function g6(_,$){let[Y,Q]=n8(!1);return{dragging:Y,onDragOver:(X)=>{if(X.preventDefault(),_)Q(!0)},onDragLeave:(X)=>{if(!X.currentTarget.contains(X.relatedTarget))Q(!1)},onDrop:(X)=>{if(X.preventDefault(),Q(!1),_)$([...X.dataTransfer.files])},onPaste:(X)=>{let Z=X.clipboardData.files;if(!_||!Z.length)return;X.preventDefault(),$([...Z])}}}var S={bubble:"M13.5 7.6c0 2.4-2.5 4.4-5.5 4.4-.6 0-1.2-.08-1.7-.23L3 13l.8-2.3C3 9.8 2.5 8.7 2.5 7.6 2.5 5.2 5 3.2 8 3.2s5.5 2 5.5 4.4Z",chevronDown:"M3 4.5L6 7.5L9 4.5",chevronDownLarge:"m5.75 8.25 4.25 4.25 4.25-4.25",file:["M4 1.5h5.172a2 2 0 0 1 1.414.586l2.328 2.328a2 2 0 0 1 .586 1.414V12.5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2Z","M9.5 1.5v2a2 2 0 0 0 2 2h2"]};import{jsx as a,jsxs as L0}from"react/jsx-runtime";function m6(){let{queue:_,t:$}=L();if(!_.items.length)return null;return a("div",{className:"cortex-attachment-queue",children:_.items.map((Y)=>L0("div",{className:U("cortex-attachment-chip",Y.status==="error"&&"cortex-attachment-chip--error"),title:Y.status==="error"?$("translate_attachment_rejected"):"",children:[Y.status==="uploading"||Y.status==="deleting"?L0("svg",{className:"cortex-attachment-chip__spinner",viewBox:"0 0 16 16",fill:"none",children:[a("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",className:"cortex-attachment-chip__spinner-track"}),a("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}):L0("svg",{viewBox:"0 0 16 16",className:"cortex-attachment-chip__icon",fill:"none",children:[a("path",{d:S.file[0],stroke:"currentColor",strokeWidth:"1.25"}),a("path",{d:S.file[1],stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]}),a("span",{className:"cortex-attachment-chip__name",children:Y.filename}),a("button",{type:"button",onClick:()=>_.remove(Y.localId),className:"cortex-attachment-chip__remove",disabled:Y.status==="deleting","aria-label":$("translate_remove_attachment"),children:a("svg",{viewBox:"0 0 16 16",fill:"none",children:a("path",{d:"M4.5 4.5l7 7m0-7l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]},Y.localId))})}import{useRef as i8}from"react";import{jsx as J_,jsxs as x6,Fragment as a8}from"react/jsx-runtime";var r8=H1.join(",");function h6({attachmentsEnabled:_,canSend:$,onSend:Y}){let{t:Q,queue:X}=L(),Z=i8(null);return x6("div",{className:"cortex-widget__input-actions",children:[_&&x6(a8,{children:[J_("button",{type:"button",onClick:()=>Z.current?.click(),className:"cortex-widget__attach-btn","aria-label":Q("translate_attach_files"),children:J_("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:J_("path",{d:"M10.5 5.5 6.2 9.8a1.4 1.4 0 0 0 2 2l4.6-4.6a2.8 2.8 0 0 0-4-4L4.2 7.8a4.2 4.2 0 0 0 6 6l4-4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),J_("input",{ref:Z,type:"file",multiple:!0,accept:r8,onChange:(G)=>{X.accept([...G.target.files??[]]),G.target.value=""},className:"cortex-widget__file-input"})]}),J_("button",{onClick:Y,"aria-label":Q("translate_send"),className:U("cortex-widget__send-btn",!$&&"cortex-widget__send-btn--empty",$&&"cortex-widget__send-btn--ready"),disabled:!$,children:J_("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",className:"cortex-widget__send-icon",children:J_("path",{d:"M3 8h10M9 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}import{useLayoutEffect as o8}from"react";import{jsx as t8}from"react/jsx-runtime";function u6(_){let{t:$}=L();o8(()=>{let Q=_.inputRef.current;if(!Q)return;Q.style.height="0px",Q.style.height=`${Q.scrollHeight}px`},[_.inputRef,_.value]);function Y(Q){if(Q.key==="Enter"&&!Q.shiftKey)Q.preventDefault(),_.onSubmit()}return t8("textarea",{ref:_.inputRef,onKeyDown:Y,onPaste:_.onPaste,value:_.value,onChange:(Q)=>_.onChange(Q.target.value),placeholder:_.dragging?$("translate_drop_files_here"):_.disabled?"":$("translate_type_a_message"),disabled:_.disabled,rows:1,className:U("cortex-widget__textarea",_.disabled&&"cortex-widget__textarea--disabled")})}import{jsx as U_,jsxs as O0}from"react/jsx-runtime";var p6=s8(function($,Y){let{t:Q,queue:X,send:Z,abort:G,capabilities:J}=L(),{isAgentWorking:N}=F_(),V=J?.attachments??!1,[K,z]=$4(""),F=g6(V,X.accept),B=c6(null);_4(Y,()=>({focusInput:()=>B.current?.focus()}));let q=c6(N);e8(()=>{if(q.current&&!N)B.current?.focus();q.current=N},[N]);let O=!X.busy&&(Boolean(K.trim())||X.hasReady);function P(){if(N||!O)return;let D=K.trim()||Q("translate_attachment_caption"),H=X.consumeReady();if(B.current)z0(B.current,D);z(""),Z(D,H.map((W)=>W.summary))}return O0("div",{className:"cortex-widget__input-area",onDragOver:F.onDragOver,onDragLeave:F.onDragLeave,onDrop:F.onDrop,children:[U_(m6,{}),O0("div",{className:U("cortex-widget__input-box",N&&"cortex-widget__input-box--disabled",!N&&"cortex-widget__input-box--enabled",F.dragging&&"cortex-widget__input-box--dragging"),children:[U_(u6,{inputRef:B,value:K,onChange:z,onSubmit:P,onPaste:F.onPaste,disabled:N,dragging:F.dragging}),N?O0("button",{onClick:()=>void G(),className:"cortex-stop-btn",children:[U_("span",{className:"cortex-stop-btn__ring"}),U_("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"cortex-stop-btn__icon",children:U_("rect",{x:"1",y:"1",width:"10",height:"10",rx:"2.5",fill:"currentColor"})})]}):U_(h6,{attachmentsEnabled:V,canSend:O,onSend:P})]})]})});import{jsx as d6}from"react/jsx-runtime";function Y1({capabilities:_,composerRef:$}){let{t:Y}=L();if(_===void 0)return null;return _.messages===!1?d6("p",{className:"cortex-widget__messages-disabled",children:Y("translate_messages_disabled")}):d6(p6,{ref:$})}import{jsx as v,jsxs as Q1}from"react/jsx-runtime";function l6(_){let{t:$}=L(),Y=v("button",{type:"button",onClick:_.newChat,"aria-label":$("translate_new_chat"),title:$("translate_new_chat"),className:"cortex-widget__header-btn cortex-widget__new-btn",children:v("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:v("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})});if(_.screen==="threads")return Q1("div",{className:"cortex-widget__threads-header",children:[v("button",{type:"button",onClick:_.closeHistory,"aria-label":$("translate_back"),className:"cortex-widget__header-btn cortex-widget__back-btn",children:v("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"cortex-widget__back-icon",children:v("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),Q1("div",{children:[v("h2",{className:"cortex-widget__threads-title",children:$("translate_history")}),v("p",{className:"cortex-widget__threads-count",children:$(C_(_.threadCount,"translate_one_conversation","translate_n_conversations"),{count:_.threadCount})})]}),Y]});return Q1("div",{className:"cortex-widget__chat-header",children:[v("button",{onClick:_.openHistory,className:"cortex-widget__sidebar-toggle-btn",children:v("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:v("path",{d:"M2.5 4h11M2.5 8h11M2.5 12h11",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}),v("div",{className:"cortex-widget__chat-title-wrap",children:v("p",{className:"cortex-widget__chat-title",children:_.title??_.agentName??$("translate_new_chat")})}),_.debug.shown&&v("button",{onClick:_.toggleDebug,className:U("cortex-widget__debug-btn",_.debug.on?"cortex-widget__debug-btn--on":"cortex-widget__debug-btn--off"),children:_.debug.on?$("translate_debug"):$("translate_normal")}),Y,v("button",{type:"button",onClick:_.openHistory,"aria-label":$("translate_history"),title:$("translate_history"),className:"cortex-widget__header-btn cortex-widget__history-btn",children:Q1("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[v("circle",{cx:"8",cy:"8",r:"5.75",stroke:"currentColor",strokeWidth:"1.3"}),v("path",{d:"M8 5v3l2 1.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})}import{jsx as o,jsxs as n6}from"react/jsx-runtime";function i6(_){let{locale:$,t:Y}=L();return n6("div",{className:"cortex-widget__landing",children:[o("div",{className:"cortex-widget__landing-icon",children:o("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",children:o("path",{d:S.bubble,stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),o("p",{className:"cortex-widget__landing-greeting",children:_.greeting}),!!_.suggestions.length&&o("div",{className:"cortex-widget__landing-chips",children:_.suggestions.map((Q,X)=>o("button",{type:"button",onClick:()=>_.send(Q.prompt),className:"cortex-widget__landing-chip",children:Q.title},X))}),_.composer,!!_.threads?.length&&o("div",{className:"cortex-widget__landing-recent",children:_.threads.slice(0,2).map((Q)=>{let X=r(Q.updatedAt,$);return n6("button",{type:"button",onClick:()=>_.openThread(Q),className:"cortex-widget__landing-recent-item",children:[o("p",{className:"cortex-widget__landing-recent-title",children:Q.title??Y("translate_untitled")}),X&&o("p",{className:"cortex-widget__landing-recent-time",children:X})]},Q.id)})})]})}import{useCallback as n_,useEffect as I0,useLayoutEffect as y0,useMemo as c4,useRef as W_,useState as C0}from"react";import{memo as h4}from"react";import{Fragment as g4}from"react";import{useRef as Y4,useState as Q4}from"react";import{jsx as L_,jsxs as X4}from"react/jsx-runtime";function h({value:_,className:$}){let{t:Y}=L(),[Q,X]=Q4(!1),Z=Y4(null);async function G(J){J.stopPropagation(),J.preventDefault();try{if(await navigator.clipboard.writeText(_),X(!0),Z.current)clearTimeout(Z.current);Z.current=setTimeout(()=>X(!1),1500)}catch{}}return L_("span",{className:U("cortex-copy-btn",$),children:L_("button",{className:U("cortex-copy-btn__button",Q&&"cortex-copy-btn__button--copied"),onClick:(J)=>void G(J),"aria-label":Q?Y("translate_copied"):Y("translate_copy"),type:"button",children:Q?L_("svg",{className:"cortex-copy-btn__icon cortex-copy-btn__icon--check",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",children:L_("path",{d:"M5 13l4 4L19 7",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}):X4("svg",{className:"cortex-copy-btn__icon",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",children:[L_("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2",stroke:"currentColor",strokeWidth:"2"}),L_("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})})})}import{jsx as X1,jsxs as r6}from"react/jsx-runtime";function a6(){let{t:_}=L();return r6("div",{className:"cortex-aborted-flag",children:[X1("span",{className:"cortex-aborted-flag__line"}),r6("span",{className:"cortex-aborted-flag__label",children:[X1("svg",{className:"cortex-aborted-flag__icon",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:X1("path",{d:"M6 1.5v5M6 8.75v.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})}),_("translate_aborted")]}),X1("span",{className:"cortex-aborted-flag__line"})]})}import{jsx as O_,jsxs as o6}from"react/jsx-runtime";function t6(_){let{api:$,t:Y}=L();async function Q(X){let{blob:Z,name:G}=await $.downloadAttachment(X);g_(Z,G)}return O_("div",{className:U("cortex-message-attachments",_.isUser&&"cortex-message-attachments--user"),children:_.attachments.map((X)=>o6("button",{type:"button",onClick:()=>void Q(X.id),className:"cortex-message-attachment","aria-label":`${Y("translate_download")}: ${X.filename}`,children:[o6("svg",{viewBox:"0 0 16 16",className:"cortex-message-attachment__icon",fill:"none",children:[O_("path",{d:S.file[0],stroke:"currentColor",strokeWidth:"1.25"}),O_("path",{d:S.file[1],stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]}),O_("span",{className:"cortex-message-attachment__name",children:X.filename}),O_("svg",{viewBox:"0 0 16 16",className:"cortex-message-attachment__dl-icon",fill:"none",children:O_("path",{d:"M8 3v7m0 0L5.5 7.5M8 10l2.5-2.5M3 13h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]},X.id))})}import{useRef as J4,useState as x_}from"react";import{useMemo as Z4,useState as G4}from"react";import{jsx as x,jsxs as N_,Fragment as Z1}from"react/jsx-runtime";function Y_({data:_,expandDepth:$,className:Y}){let Q=Z4(()=>q_(_),[_]),[X,Z]=G4({});function G(N,V){return X[N]??V>=$}function J(N,V){Z((K)=>({...K,[N]:!G(N,V)}))}return x("div",{className:U("cortex-json-tree",Y),children:x(s6,{value:Q,path:"$",depth:0,isCollapsed:G,toggle:J})})}function s6({value:_,path:$,depth:Y,isCollapsed:Q,toggle:X}){let Z=J0(_,$);if(Z.kind==="primitive")return x("span",{className:Z.className,children:Z.text});if(Z.entries.length===0)return N_("span",{className:"cortex-json-tree__bracket",children:[Z.open,Z.close]});let G=Q($,Y);function J(N){X($,Y),N.stopPropagation()}return N_(Z1,{children:[N_("span",{className:"cortex-json-tree__toggle",onClick:J,role:"button",children:[x("span",{className:U("cortex-json-tree__arrow",G&&"cortex-json-tree__arrow--collapsed"),children:"▾"}),x("span",{className:"cortex-json-tree__bracket",children:Z.open})]}),G?N_(Z1,{children:[x("span",{className:"cortex-json-tree__collapsed-hint",onClick:J,role:"button",children:Z.summary}),x("span",{className:"cortex-json-tree__bracket",children:Z.close})]}):N_(Z1,{children:[x("div",{className:"cortex-json-tree__indent",children:Z.entries.map((N,V)=>N_("div",{className:"cortex-json-tree__line",children:[N.key!==null&&N_(Z1,{children:[x("span",{className:"cortex-json-tree__key",children:`"${N.key}"`}),x("span",{className:"cortex-json-tree__colon",children:": "})]}),x(s6,{value:N.value,path:N.path,depth:Y+1,isCollapsed:Q,toggle:X}),V<Z.entries.length-1&&x("span",{className:"cortex-json-tree__comma",children:","})]},N.path))}),x("span",{className:"cortex-json-tree__bracket",children:Z.close})]})]})}function R(_){return _.toLocaleString("en-US")}import{jsx as P_,jsxs as M_}from"react/jsx-runtime";function e6({usage:_}){let{t:$}=L();return M_("div",{className:"cortex-llm-inspector__usage-rows",children:[M_("div",{className:"cortex-llm-inspector__usage-row",children:[P_("span",{className:"cortex-llm-inspector__usage-lbl",children:$("translate_input")}),P_("span",{className:"cortex-llm-inspector__usage-val",children:R(_.input.total)}),M_("span",{className:"cortex-llm-inspector__usage-detail",children:[$("translate_fresh")," ",R(_.input.noCache)," · ",$("translate_read")," ",R(_.input.cacheRead)," · ",$("translate_write")," ",R(_.input.cacheWrite)]})]}),M_("div",{className:"cortex-llm-inspector__usage-row",children:[P_("span",{className:"cortex-llm-inspector__usage-lbl",children:$("translate_output")}),P_("span",{className:"cortex-llm-inspector__usage-val",children:R(_.output.total)}),M_("span",{className:"cortex-llm-inspector__usage-detail",children:[$("translate_text")," ",R(_.output.text)," · ",$("translate_reasoning")," ",R(_.output.reasoning)]})]}),M_("div",{className:"cortex-llm-inspector__usage-row cortex-llm-inspector__usage-row--total",children:[P_("span",{className:"cortex-llm-inspector__usage-lbl",children:$("translate_total")}),P_("span",{className:"cortex-llm-inspector__usage-val",children:R(_.total)})]})]})}import{jsx as _2,jsxs as G1}from"react/jsx-runtime";function $2({usage:_}){let $=m_(_);return G1("span",{className:"cortex-llm-inspector__step-metrics",children:[G1("span",{className:"cortex-llm-inspector__metric",children:[_2("span",{className:"cortex-llm-inspector__dot cortex-llm-inspector__dot--input"}),R(_.input.total)]}),G1("span",{className:"cortex-llm-inspector__metric",children:[_2("span",{className:"cortex-llm-inspector__dot cortex-llm-inspector__dot--output"}),R(_.output.total)]}),$!==null&&G1("span",{className:"cortex-llm-inspector__cache-pct",children:[$,"%"]})]})}import{jsx as y,jsxs as Q_}from"react/jsx-runtime";function Y2({messageId:_}){let{t:$,api:Y}=L(),[Q,X]=x_(!1),[Z,G]=x_(!1),[J,N]=x_([]),[V,K]=x_(null),[z,F]=x_({}),B=J4(!1);async function q(){if(!B.current){G(!0);try{N(await Y.listLlmRequests(_))}finally{G(!1),B.current=!0}}X((W)=>!W)}function O(W){K((M)=>M===W?null:W)}function P(W){return z[W]??"prompt"}function D(W,M){F((A)=>({...A,[W]:M}))}function H(W){return P(W.id)==="prompt"?W.prompt:W.output}return Q_("div",{className:U("cortex-llm-inspector",Q&&"cortex-llm-inspector--open"),children:[Q_("button",{className:"cortex-llm-inspector__trigger",onClick:()=>void q(),children:[y("svg",{className:"cortex-llm-inspector__icon",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:y("path",{d:"M6 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8ZM0 6a6 6 0 1 1 10.89 3.477l4.817 4.816a1 1 0 0 1-1.414 1.414l-4.816-4.816A6 6 0 0 1 0 6Z",fill:"currentColor"})}),y("span",{children:$("translate_inspect_llm_requests")}),Z?y("span",{className:"cortex-llm-inspector__loading",children:$("translate_loading")}):J.length>0?y("span",{className:"cortex-llm-inspector__badge",children:J.length}):null,y("svg",{className:"cortex-llm-inspector__chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:y("path",{d:S.chevronDown,stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),y("div",{className:"cortex-llm-inspector__panel-wrapper",children:y("div",{className:"cortex-llm-inspector__panel-inner",children:Q_("div",{className:"cortex-llm-inspector__panel",children:[J.length===0&&!Z&&y("div",{className:"cortex-llm-inspector__empty",children:$("translate_no_llm_requests")}),J.map((W,M)=>Q_("div",{className:U("cortex-llm-inspector__step",V===W.id&&"cortex-llm-inspector__step--expanded"),children:[Q_("button",{className:"cortex-llm-inspector__step-header",onClick:()=>O(W.id),children:[y("span",{className:"cortex-llm-inspector__step-label",children:$("translate_step_n",{number:M+1})}),W.tokenUsage&&y($2,{usage:W.tokenUsage}),y("svg",{className:"cortex-llm-inspector__step-chevron",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:y("path",{d:S.chevronDown,stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),y("div",{className:"cortex-llm-inspector__step-body-wrapper",children:y("div",{className:"cortex-llm-inspector__step-body-inner",children:Q_("div",{className:"cortex-llm-inspector__step-body",children:[W.tokenUsage&&y(e6,{usage:W.tokenUsage}),Q_("div",{className:"cortex-llm-inspector__tabs",children:[y("button",{className:U("cortex-llm-inspector__tab",P(W.id)==="prompt"&&"cortex-llm-inspector__tab--active"),onClick:()=>D(W.id,"prompt"),children:$("translate_request")}),y("button",{className:U("cortex-llm-inspector__tab",P(W.id)==="response"&&"cortex-llm-inspector__tab--active"),onClick:()=>D(W.id,"response"),children:$("translate_response")})]}),Q_("div",{className:"cortex-llm-inspector__json-pane",children:[y(h,{className:"cortex-llm-inspector__json-copy",value:V0(H(W))}),y(Y_,{data:N0(H(W)),expandDepth:2})]})]})})})]},W.id))]})})})]})}import{useState as N4}from"react";import{jsx as E,jsxs as b}from"react/jsx-runtime";function Q2({usage:_,modelId:$}){let{t:Y}=L(),[Q,X]=N4(!1),Z=m_(_)??0;return b("div",{className:U("cortex-token-usage",Q&&"cortex-token-usage--expanded"),children:[b("button",{className:"cortex-token-usage__summary",onClick:()=>X((G)=>!G),children:[b("span",{className:"cortex-token-usage__total",children:[E("span",{className:"cortex-token-usage__total-number",children:R(_.total)}),E("span",{className:"cortex-token-usage__total-label",children:Y("translate_tokens")})]}),$?E("span",{className:"cortex-token-usage__model",children:$}):null,b("span",{className:"cortex-token-usage__pills",children:[b("span",{className:"cortex-token-usage__pill",children:[E("span",{className:"cortex-token-usage__dot cortex-token-usage__dot--input"}),R(_.input.total)]}),b("span",{className:"cortex-token-usage__pill",children:[E("span",{className:"cortex-token-usage__dot cortex-token-usage__dot--output"}),R(_.output.total)]})]}),Z>0&&b("span",{className:"cortex-token-usage__cache-badge",children:[Z,"%"]}),E("svg",{className:"cortex-token-usage__chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:E("path",{d:S.chevronDown,stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),E("div",{className:"cortex-token-usage__details",children:E("div",{className:"cortex-token-usage__details-inner",children:b("div",{className:"cortex-token-usage__columns",children:[b("div",{className:"cortex-token-usage__col",children:[b("div",{className:"cortex-token-usage__col-header",children:[E("span",{className:"cortex-token-usage__dot cortex-token-usage__dot--input"}),E("span",{className:"cortex-token-usage__col-label",children:Y("translate_input")}),E("span",{className:"cortex-token-usage__col-total",children:R(_.input.total)})]}),b("div",{className:"cortex-token-usage__rows",children:[_.input.noCache?b("div",{className:"cortex-token-usage__row",children:[E("span",{className:"cortex-token-usage__row-label",children:Y("translate_fresh")}),E("span",{className:"cortex-token-usage__row-value",children:R(_.input.noCache)})]}):null,_.input.cacheRead?b("div",{className:"cortex-token-usage__row",children:[E("span",{className:"cortex-token-usage__row-label",children:Y("translate_cache_read")}),E("span",{className:"cortex-token-usage__row-value",children:R(_.input.cacheRead)})]}):null,_.input.cacheWrite?b("div",{className:"cortex-token-usage__row",children:[E("span",{className:"cortex-token-usage__row-label",children:Y("translate_cache_write")}),E("span",{className:"cortex-token-usage__row-value",children:R(_.input.cacheWrite)})]}):null]}),Z>0&&b("div",{className:"cortex-token-usage__cache-bar-row",children:[E("div",{className:"cortex-token-usage__cache-bar",children:E("div",{className:"cortex-token-usage__cache-fill",style:{width:`${Z}%`}})}),E("span",{className:"cortex-token-usage__cache-label",children:Y("translate_n_percent_cached",{percent:Z})})]})]}),b("div",{className:"cortex-token-usage__col",children:[b("div",{className:"cortex-token-usage__col-header",children:[E("span",{className:"cortex-token-usage__dot cortex-token-usage__dot--output"}),E("span",{className:"cortex-token-usage__col-label",children:Y("translate_output")}),E("span",{className:"cortex-token-usage__col-total",children:R(_.output.total)})]}),b("div",{className:"cortex-token-usage__rows",children:[_.output.text?b("div",{className:"cortex-token-usage__row",children:[E("span",{className:"cortex-token-usage__row-label",children:Y("translate_text")}),E("span",{className:"cortex-token-usage__row-value",children:R(_.output.text)})]}):null,_.output.reasoning?b("div",{className:"cortex-token-usage__row",children:[E("span",{className:"cortex-token-usage__row-label",children:Y("translate_reasoning")}),E("span",{className:"cortex-token-usage__row-value",children:R(_.output.reasoning)})]}):null]})]})]})})})]})}import{jsx as X2,jsxs as V4}from"react/jsx-runtime";function Z2({messageId:_,isAssistant:$,metadata:Y}){let{tokenUsage:Q}=Y;if(!Q&&!$)return null;return V4("div",{className:"cortex-message-debug-zone",children:[Q&&X2(Q2,{usage:Q,modelId:Y.modelId}),$&&X2(Y2,{messageId:_})]})}import{jsx as u,jsxs as h_}from"react/jsx-runtime";function G2(_){let{reasoningPart:$,streaming:Y=!1}=_,{t:Q}=L();return h_("details",{className:"cortex-reasoning-details",children:[h_("summary",{className:"cortex-reasoning-details__summary",children:[h_("div",{className:"cortex-reasoning-details__header",children:[u("span",{className:"cortex-reasoning-details__icon",children:h_("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[u("path",{d:"M10 2C6.686 2 4 4.686 4 8c0 1.655.672 3.154 1.757 4.243.362.363.576.858.576 1.371V14.5a1 1 0 0 0 1 1h5.334a1 1 0 0 0 1-1v-.886c0-.513.214-1.008.576-1.371A5.978 5.978 0 0 0 16 8c0-3.314-2.686-6-6-6Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),u("path",{d:"M7.5 17.5h5M8.5 8a2 2 0 0 1 2-2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]})}),u("div",{className:"cortex-reasoning-details__title-group",children:h_("div",{className:"cortex-reasoning-details__title-row",children:[u("div",{className:"cortex-reasoning-details__title",children:Q("translate_reasoning")}),u("span",{className:U("cortex-reasoning-details__badge",Y?"cortex-reasoning-details__badge--streaming":"cortex-reasoning-details__badge--done"),children:Y?Q("translate_streaming"):Q("translate_done")})]})})]}),u("span",{className:"cortex-reasoning-details__chevron","aria-hidden":"true",children:u("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"none",children:u("path",{d:S.chevronDownLarge,stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),u("div",{className:"cortex-reasoning-details__body",children:u("div",{className:"cortex-reasoning-details__content",children:u("pre",{className:"cortex-reasoning-details__pre",children:$.content.trim()?$.content:Q("translate_no_reasoning")})})})]})}import{useEffect as D2,useMemo as M4,useRef as M0,useState as A4}from"react";import{useEffect as W4,useState as J2}from"react";import{useRef as K4,useState as z4}from"react";import{jsx as t,jsxs as J1}from"react/jsx-runtime";function A_(_){let{label:$,ready:Y=!0,actions:Q,expanded:X,children:Z}=_,{t:G}=L(),J=K4(null),[N,V]=z4(!1);return J1("div",{className:"cortex-expandable",children:[Y&&J1("div",{className:"cortex-expandable__toolbar",role:"group","aria-label":$,children:[Q,t("button",{type:"button",className:"cortex-expandable__action","aria-label":G("translate_expand",{name:$}),title:G("translate_expand",{name:$}),onClick:()=>{V(!0),J.current?.showModal()},children:t("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:t("path",{d:"M9.5 2.5h4v4M6.5 13.5h-4v-4M13.5 2.5 9 7M2.5 13.5 7 9",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),t("div",{className:"cortex-expandable__content",children:Z}),J1("dialog",{ref:J,className:"cortex-expandable__dialog","aria-label":$,closedby:"any",onClose:()=>V(!1),children:[J1("div",{className:"cortex-expandable__head",children:[t("span",{className:"cortex-expandable__title",children:$}),Q,t("button",{type:"button",className:"cortex-expandable__action","aria-label":G("translate_close"),title:G("translate_close"),onClick:()=>J.current?.close(),children:t("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:t("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})]}),N&&t("div",{className:"cortex-expandable__body",children:X})]})]})}import{jsx as u_,jsxs as D4}from"react/jsx-runtime";function N2(_){let{id:$,alt:Y,attachment:Q}=_,{api:X,t:Z}=L(),[G,J]=J2(),[N,V]=J2(!1);if(W4(()=>{let K,z=!1;return J(void 0),V(!1),X.downloadAttachment($).then(({blob:F})=>{if(z)return;K=URL.createObjectURL(F),J(K)},()=>{if(!z)V(!0)}),()=>{if(z=!0,K)URL.revokeObjectURL(K)}},[X,$]),N)return u_("p",{className:"cortex-attachment-image__caption",children:Y?Z("translate_image_unavailable_alt",{alt:Y}):Z("translate_image_unavailable")});if(!G)return null;return D4("figure",{className:"cortex-attachment-image",children:[u_(A_,{label:Q?.filename||Y||Z("translate_image"),expanded:u_("img",{className:"cortex-attachment-image__expanded",src:G,alt:Y}),children:u_("img",{src:G,alt:Y})}),Q&&u_("figcaption",{className:"cortex-attachment-image__caption",children:Q.filename})]})}import{useEffect as H4,useRef as B4,useState as P0}from"react";import{jsx as j,jsxs as c_,Fragment as U4}from"react/jsx-runtime";function q4(_){let{t:$}=L();if(!_.pending&&!_.debugMode)return null;return c_("div",{className:"cortex-media-block__head",children:[_.debugMode&&j("span",{className:"cortex-media-block__lang",children:_.language}),_.pending&&j("span",{className:"cortex-media-block__pending",children:$(_1(_.language).pending)}),_.debugMode&&_.closed&&c_("span",{className:"cortex-media-block__actions",children:[_.onToggleSource&&j("button",{type:"button",className:"cortex-media-block__action","aria-pressed":_.sourceShown,onClick:_.onToggleSource,children:$("translate_media_source")}),j(h,{value:_.source})]})]})}function V2(_){let{debugMode:$,t:Y}=L();return j("div",{className:"cortex-media-block__body",children:c_("p",{className:"cortex-media-block__error",children:[_.cutOff?Y("translate_media_cut_off"):Y("translate_media_failed"),!_.cutOff&&$&&` ${_.reason}`]})})}function K2(_){let{language:$,source:Y,closed:Q,hidden:X,onError:Z}=_,{config:G,scheme:J}=L(),N=B4(null);return H4(()=>{Z(void 0);let V=N.current;if(!Q||!J||!V)return;return X0(V,{language:$,source:Y,context:{scheme:J},overrides:G.mediaRenderers,onError:Z})},[$,Y,Q,J,G.mediaRenderers,Z]),j("div",{ref:N,hidden:X,className:U("cortex-media-block__body",`cortex-media-block__body--${$}`)})}function F4(_){let[$,Y]=P0();return c_(U4,{children:[$&&j(V2,{cutOff:!1,reason:$}),j(K2,{language:_.language,source:_.source,closed:!0,hidden:Boolean($),onError:Y})]})}function z2(_){let{language:$,source:Y,closed:Q,streaming:X}=_,{debugMode:Z,t:G}=L(),[J,N]=P0(),[V,K]=P0(!1),z=!Q&&!X,F=z||Boolean(J);return c_("div",{className:"cortex-media-block",children:[j(q4,{language:$,source:Y,pending:!Q&&X,closed:Q,debugMode:Z,sourceShown:V,onToggleSource:F?void 0:()=>K((q)=>!q)}),F&&j(V2,{cutOff:z,reason:J}),j(A_,{label:G(_1($).title),ready:Q&&!F,expanded:j(F4,{language:$,source:Y}),children:j(K2,{language:$,source:Y,closed:Q,hidden:F,onError:N})}),Z&&(F||V)&&j("pre",{className:"cortex-media-block__source",children:Y})]})}import{useMemo as L4,useRef as O4}from"react";import{jsx as V_}from"react/jsx-runtime";var P4="M8 2.5v7.5M5 7l3 3 3-3M2.75 11v1.25a1.25 1.25 0 0 0 1.25 1.25h8a1.25 1.25 0 0 0 1.25-1.25V11";function W2(_){let{t:$}=L(),Y=O4(null),Q=L4(()=>({__html:v_(_.text)}),[_.text]);function X(){let Z=Y.current?.querySelector("table");if(Z)g_(o1(a1(Z)),"table.xlsx")}return V_("div",{className:"cortex-table-block",children:V_(A_,{label:$("translate_table"),ready:_.closed,actions:V_("button",{type:"button",className:"cortex-expandable__action","aria-label":$("translate_table_export"),title:$("translate_table_export"),onClick:X,children:V_("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:V_("path",{d:P4,stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),expanded:V_("div",{className:"cortex-table-block__expanded",dangerouslySetInnerHTML:Q}),children:V_("div",{ref:Y,dangerouslySetInnerHTML:Q})})})}import{jsx as E_}from"react/jsx-runtime";function H2(_){let{role:$,textPart:Y,streaming:Q=!1,attachments:X=[]}=_,{config:Z}=L(),G=$==="assistant"&&Q?"":Y.content,[J,N]=A4({text:G,fading:[]}),V=M0(G),K=M0(null),z=M0(!0);D2(()=>{function q(O,P){V.current=O,N((D)=>D.text===O&&!D.fading.length&&!P.length?D:{text:O,fading:P})}if($!=="assistant"||!Q){K.current?.destroy(),K.current=null,q(Y.content,[]),z.current=!1;return}if(!K.current)K.current=new $_(q),K.current.seed(V.current);if(z.current){z.current=!1,K.current.seed(Y.content);return}K.current.update(Y.content,!1)},[$,Q,Y]),D2(()=>()=>{K.current?.destroy(),K.current=null},[]);let F=M4(()=>{let q=$==="assistant"?r1(J.text,Q0(Z.mediaRenderers)):[{kind:"markdown",text:J.text}];return q.map((O,P)=>O.kind==="markdown"?{...O,html:{__html:v_(O.text,P===q.length-1?J.fading:[])}}:O)},[$,J,Z.mediaRenderers]),B=Q||J.text!==Y.content;return E_("div",{className:U("cortex-text-part",$==="assistant"&&"cortex-text-part--assistant",$==="user"&&"cortex-text-part--user"),children:E_("div",{className:U("cortex-text-bubble",$==="assistant"&&"cortex-text-bubble--assistant",$==="user"&&"cortex-text-bubble--user"),children:F.map((q,O)=>{switch(q.kind){case"markdown":return E_("div",{dangerouslySetInnerHTML:q.html},O);case"media":return E_(z2,{...q,streaming:B},O);case"table":return E_(W2,{text:q.text,closed:q.closed||!B},O);case"attachment":return E_(N2,{id:q.id,alt:q.alt,attachment:X.find((P)=>P.id.toLowerCase()===q.id)},O)}})})})}import{jsx as g,jsxs as X_}from"react/jsx-runtime";function B2({toolCallPart:_}){let{t:$}=L(),{state:Y,approval:Q}=_,X=_.output,Z=M1(_);if(Y==="complete")return X_("div",{className:"cortex-debug-tool__section cortex-debug-tool__section--success",children:[X_("div",{className:"cortex-debug-tool__section-bar",children:[g("span",{className:"cortex-debug-tool__section-label cortex-debug-tool__section-label--success",children:$("translate_output")}),g("span",{className:"cortex-debug-tool__section-lang",children:"json"}),g(h,{value:Z})]}),g("div",{dir:"ltr",className:"cortex-debug-tool__tree",children:g(Y_,{data:X,expandDepth:2})})]});if(Y==="error")return X_("div",{className:"cortex-debug-tool__section cortex-debug-tool__section--error",children:[X_("div",{className:"cortex-debug-tool__section-bar",children:[g("span",{className:"cortex-debug-tool__section-label cortex-debug-tool__section-label--error",children:$("translate_error")}),g(h,{value:Z})]}),g("pre",{dir:"ltr",className:"cortex-debug-tool__error-pre",children:Z})]});if(Y==="approval-requested")return X_("div",{className:"cortex-debug-tool__section cortex-debug-tool__section--approval",children:[X_("div",{className:"cortex-debug-tool__section-bar",children:[g("span",{className:"cortex-debug-tool__section-label cortex-debug-tool__section-label--approval",children:$("translate_approval_requested")}),g("span",{className:"cortex-debug-tool__section-lang",children:Q?.id})]}),g("div",{className:"cortex-debug-tool__message cortex-debug-tool__message--approval",children:$("translate_waiting_for_approval")})]});if(Y==="approval-responded")return X_("div",{className:"cortex-debug-tool__section cortex-debug-tool__section--approval",children:[X_("div",{className:"cortex-debug-tool__section-bar",children:[g("span",{className:"cortex-debug-tool__section-label cortex-debug-tool__section-label--approval",children:$("translate_approval_response")}),g("span",{className:"cortex-debug-tool__section-lang",children:Q?.id})]}),g("div",{className:"cortex-debug-tool__message cortex-debug-tool__message--approval",children:$(Q?.approved?"translate_tool_approved":"translate_tool_response_received")})]});return null}import{jsx as E4,jsxs as k4}from"react/jsx-runtime";function q2({toolCallPart:_}){let{t:$}=L(),Y=P1(_);return k4("span",{className:U("cortex-debug-tool__state",Y.modifier&&`cortex-debug-tool__state--${Y.modifier}`),children:[Y.pulse&&E4("span",{className:U("cortex-debug-tool__pulse",Y.pulse==="violet"&&"cortex-debug-tool__pulse--violet")}),$(Y.labelKey)]})}import{jsx as T,jsxs as s}from"react/jsx-runtime";function F2({toolCallPart:_}){let{t:$}=L(),{codeSnippets:Y,remainingInput:Q,remainingInputText:X}=A1(_.input);return s("details",{className:"cortex-debug-tool","data-state":_.state,children:[T("summary",{className:"cortex-debug-tool__summary",children:s("div",{className:"cortex-debug-tool__header",children:[s("div",{className:"cortex-debug-tool__meta",children:[T("div",{className:"cortex-debug-tool__title-row",children:T("span",{className:"cortex-debug-tool__name",title:_.name,children:_.name})}),T("div",{className:"cortex-debug-tool__id-row",children:T("span",{className:"cortex-debug-tool__id",children:_.id})})]}),s("div",{className:"cortex-debug-tool__actions",children:[T(q2,{toolCallPart:_}),T("svg",{className:"cortex-debug-tool__chevron",width:"14",height:"14",viewBox:"0 0 20 20",fill:"none",children:T("path",{d:S.chevronDownLarge,stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}),s("div",{className:"cortex-debug-tool__body",children:[Y.map((Z)=>s("div",{className:"cortex-debug-tool__section",children:[s("div",{className:"cortex-debug-tool__section-bar",children:[T("span",{className:"cortex-debug-tool__section-label",children:Z.key}),T("span",{className:"cortex-debug-tool__section-lang",children:Z.lang}),T(h,{value:Z.value})]}),T("pre",{dir:"ltr",className:"cortex-debug-tool__pre",children:T("code",{className:"hljs",dangerouslySetInnerHTML:{__html:G0(Z.value,Z.lang)}})})]},Z.key)),!!Q&&s("div",{className:"cortex-debug-tool__section",children:[s("div",{className:"cortex-debug-tool__section-bar",children:[T("span",{className:"cortex-debug-tool__section-label",children:$("translate_input")}),T("span",{className:"cortex-debug-tool__section-lang",children:"json"}),T(h,{value:X})]}),T("div",{dir:"ltr",className:"cortex-debug-tool__tree",children:T(Y_,{data:Q,expandDepth:2})})]}),T(B2,{toolCallPart:_})]})]})}import{useEffect as R4,useRef as I4,useState as U2}from"react";import{jsx as p_,jsxs as L2}from"react/jsx-runtime";function K_({activity:_,className:$}){let{t:Y}=L(),Q=k1(_),[X,Z]=U2(0),[G,J]=U2("idle"),N=I4(Q.length);return N.current=Q.length,R4(()=>{let V,K;function z(){V=setTimeout(()=>{J("exiting"),V=setTimeout(()=>{Z((F)=>(F+1)%N.current),J("enter-start"),K=requestAnimationFrame(()=>{J("entering"),V=setTimeout(()=>{J("idle"),z()},300)})},300)},2000)}return z(),()=>{if(V)clearTimeout(V);if(K)cancelAnimationFrame(K)}},[]),L2("div",{className:U("cortex-subtle-activity",$),children:[L2("div",{className:"cortex-subtle-activity__dots",children:[p_("span",{className:"cortex-subtle-activity__dot"}),p_("span",{className:"cortex-subtle-activity__dot cortex-subtle-activity__dot--d1"}),p_("span",{className:"cortex-subtle-activity__dot cortex-subtle-activity__dot--d2"})]}),p_("div",{className:"cortex-subtle-activity__label-mask",children:p_("span",{className:U("cortex-subtle-activity__label",`cortex-subtle-activity__label--${G}`),children:Y(Q[X])})})]})}import{useEffect as k2,useRef as A0,useState as E2}from"react";import{jsx as c,jsxs as k_,Fragment as y4}from"react/jsx-runtime";function O2({toolCallPart:_,asking:$}){let{t:Y,locale:Q,respondToApproval:X}=L(),{sentence:Z,decision:G,decisionKey:J}=E1(_,Q),N=`cortex-approval-${_.id}`,V=u0(_),K=G==="pending",{state:z,active:F}=i(_);return k_("div",{className:U("cortex-approval-card",K&&"cortex-approval-card--asking"),children:[K?k_(y4,{children:[k_("div",{className:"cortex-approval-card__head",children:[c("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:c("path",{d:"M8 1.75 2.75 3.75v4c0 3 2.2 5.3 5.25 6.5 3.05-1.2 5.25-3.5 5.25-6.5v-4L8 1.75Z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})}),Y("translate_approval_needed")]}),c("p",{className:"cortex-approval-card__sentence",id:N,children:Z})]}):k_("div",{className:"cortex-approval-card__line",children:[k_("span",{className:"cortex-tool-pill__icon","aria-hidden":"true",children:[c("span",{className:U("cortex-tool-pill__spinner",F&&"cortex-tool-pill__spinner--visible")}),c("svg",{className:U("cortex-tool-pill__svg cortex-tool-pill__svg--check",z==="complete"&&"cortex-tool-pill__svg--visible"),viewBox:"0 0 20 20",fill:"none",children:c("path",{d:"M5.5 10.5 L8.5 13.5 L14.5 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),c("svg",{className:U("cortex-tool-pill__svg cortex-tool-pill__svg--error",z==="error"&&"cortex-tool-pill__svg--visible"),viewBox:"0 0 20 20",fill:"none",children:c("path",{d:"M6.5 6.5 L13.5 13.5 M13.5 6.5 L6.5 13.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]}),J&&c("span",{className:"cortex-approval-card__decision",children:Y(J)}),c("span",{className:"cortex-approval-card__summary",children:Z})]}),K&&$&&k_("div",{className:"cortex-approval-card__foot",children:[c("button",{type:"button",className:"cortex-approval-card__button cortex-approval-card__button--approve","aria-describedby":N,onClick:()=>void X(V,!0),children:Y("translate_approve")}),c("button",{type:"button",className:"cortex-approval-card__button","aria-describedby":N,onClick:()=>void X(V,!1),children:Y("translate_deny")})]})]})}import{useEffect as P2,useRef as N1,useState as M2}from"react";import{jsx as C,jsxs as p}from"react/jsx-runtime";function A2({toolCallPart:_,setOutput:$}){let{t:Y}=L(),{state:Q,id:X,input:Z}=_;if(Q==="complete"||Q==="error"){let G=c1(_.output);return G?C(w4,{position:G}):p("div",{className:"cortex-tool-pill",children:[C("span",{className:"cortex-tool-pill__icon",children:C("svg",{className:U("cortex-tool-pill__svg cortex-tool-pill__svg--visible",Q==="error"&&"cortex-tool-pill__svg--error"),viewBox:"0 0 20 20",fill:"none",children:C("path",{d:"M6.5 6.5 L13.5 13.5 M13.5 6.5 L6.5 13.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}),C("span",{className:"cortex-tool-pill__title",children:Y("translate_location_not_shared")})]})}if(Q!=="input-complete")return null;return C(C4,{center:u1(Z),submit:$},X)}function C4({center:_,submit:$}){let{t:Y}=L(),Q=N1(null),X=N1(void 0),[Z,G]=M2(a_),J=N1({center:_,submit:$});J.current={center:_,submit:$},P2(()=>{let V=Q.current;if(!V)return;let K=x1(V,{center:J.current.center,onState:G,submit:(z)=>J.current.submit(z)});return X.current=K,K.start(),()=>{if(K.dispose(),X.current===K)X.current=void 0}},[]);let N=p1(Z);return p("div",{className:"cortex-location-input",children:[p("div",{className:"cortex-location-input__map",children:[C("div",{className:"cortex-location-input__canvas",ref:Q}),C("button",{type:"button",className:"cortex-location-input__locate","aria-label":Y("translate_location_locate"),title:Y("translate_location_locate"),disabled:Z.locating||Z.submitting,onClick:()=>X.current?.locate(),children:C(S4,{})})]}),p("div",{className:"cortex-location-input__foot",children:[Z.position&&!Z.deliveryFailed?C("span",{className:"cortex-location-input__coords",children:o_(Z.position)}):p("span",{className:U("cortex-location-input__hint",N.failed&&"cortex-location-input__hint--failed"),children:[Z.locating&&C("span",{className:"cortex-location-input__spinner"}),Y(N.key)]}),p("span",{className:"cortex-location-input__actions",children:[C("button",{type:"button",className:"cortex-location-input__skip",disabled:Z.submitting,onClick:()=>X.current?.cancel(),children:Y("translate_location_skip")}),C("button",{type:"button",className:"cortex-location-input__send",disabled:!Z.position||Z.submitting,onClick:()=>X.current?.confirm(),children:Y("translate_location_send")})]})]})]})}function w4({position:_}){let{t:$}=L(),Y=N1(null),[Q,X]=M2(!1),{lat:Z,lng:G}=_;return P2(()=>{let J=Y.current;if(!J)return;return X(!1),h1(J,{lat:Z,lng:G},()=>X(!0))},[Z,G]),p("div",{className:"cortex-location-input cortex-location-input--settled",children:[p("div",{className:"cortex-location-input__map cortex-location-input__map--still",children:[C("div",{className:"cortex-location-input__canvas",ref:Y,hidden:Q}),Q&&C("span",{className:"cortex-location-input__still-failed",children:$("translate_location_map_failed")})]}),p("div",{className:"cortex-location-input__body",children:[p("span",{className:"cortex-location-input__title",children:[C("svg",{viewBox:"0 0 20 20",fill:"none",children:C("path",{d:"M5.5 10.5 L8.5 13.5 L14.5 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),$("translate_location_shared")]}),C("span",{className:"cortex-location-input__coords",children:o_(_)})]})]})}function S4(){return p("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:[C("circle",{cx:"10",cy:"10",r:"5.5"}),C("circle",{cx:"10",cy:"10",r:"1.6",fill:"currentColor",stroke:"none"}),C("path",{d:"M10 1.5v3M10 15.5v3M1.5 10h3M15.5 10h3"})]})}import{jsx as I,jsxs as d_}from"react/jsx-runtime";var b4=new Map([[r_,A2]]);function R2({message:_,toolCallPart:$,agentWorking:Y}){let{config:Q,addToolResult:X}=L(),Z=$.state==="input-complete"&&!Y,G=$.state==="approval-requested"&&!Y,J=Q.toolComponents?.[$.name]??(Z||f($.state)?b4.get($.name):void 0);return I("div",{className:"cortex-tool-call-animated",children:J?I(J,{toolCallPart:$,message:_,setOutput:(N)=>X($.id,$.name,N)}):Z?I(T4,{toolCallPart:$}):I(I2,{toolCallPart:$,asking:G})})}function T4({toolCallPart:_}){let{api:$,t:Y,addToolResult:Q,selectedThread:X,config:Z}=L(),G=X?.id,[J,N]=E2({phase:"initiating"}),[V]=E2(Z.trustSameOriginEmbeds),K=A0(void 0),z=A0({api:$,addToolResult:Q,toolName:_.name});if(z.current={api:$,addToolResult:Q,toolName:_.name},k2(()=>{if(!G)return;let B=g1({initiate:()=>z.current.api.initiateToolCall(G,_.id),onState:N,submit:(O)=>z.current.addToolResult(_.id,z.current.toolName,O)});K.current=B,B.start();let q=(O)=>B.handleMessage(O);return window.addEventListener("message",q),()=>{if(window.removeEventListener("message",q),B.dispose(),K.current===B)K.current=void 0}},[_.id,G]),!G||J.phase==="unavailable"||J.phase==="settling")return I(I2,{toolCallPart:_,asking:!1});let F=d_("div",{className:"cortex-client-tool-embed",children:[d_("div",{className:"cortex-client-tool-embed__bar",children:[I("span",{children:Y("translate_client_tool_title")}),I("button",{type:"button",className:"cortex-client-tool-embed__cancel",onClick:()=>K.current?.cancel(),children:Y("translate_client_tool_cancel")})]}),J.phase==="embedded"?I("iframe",{className:"cortex-client-tool-embed__frame",src:J.embedUrl,sandbox:v1(J.embedUrl,window.location.origin,V),title:Y("translate_client_tool_title"),ref:(B)=>K.current?.setSource(B?.contentWindow),onLoad:(B)=>{if(!f1(J.embedUrl,window.location.origin,V)&&j1(B.currentTarget,window.location.origin))K.current?.terminate()}}):J.phase==="error"?d_("div",{className:"cortex-client-tool-embed__status",children:[I("span",{children:Y("translate_client_tool_failed")}),I("button",{type:"button",className:"cortex-client-tool-embed__retry",onClick:()=>void K.current?.start(),children:Y("translate_client_tool_retry")})]}):I("div",{className:"cortex-client-tool-embed__status",children:Y("translate_client_tool_loading")})]});return J.phase==="embedded"&&J.surface==="modal"?I(v4,{label:Y("translate_client_tool_title"),onCancel:()=>K.current?.cancel(),children:F}):F}function v4({label:_,onCancel:$,children:Y}){let Q=A0(null);return k2(()=>{let X=Q.current;return X?.showModal(),()=>X?.close()},[]),I("dialog",{ref:Q,className:"cortex-client-tool-embed-dialog","aria-label":_,onCancel:(X)=>{X.preventDefault(),$()},children:Y})}function I2({toolCallPart:_,asking:$}){return i(_).gated?I(O2,{toolCallPart:_,asking:$}):I(f4,{toolCallPart:_})}function f4({toolCallPart:_}){let{t:$}=L(),{state:Y,active:Q,titleKey:X,statement:Z,rowCount:G}=i(_);return d_("div",{className:"cortex-tool-pill",children:[d_("span",{className:"cortex-tool-pill__icon",children:[I("span",{className:U("cortex-tool-pill__spinner",Q&&"cortex-tool-pill__spinner--visible")}),I("svg",{className:U("cortex-tool-pill__svg","cortex-tool-pill__svg--check",Y==="complete"&&"cortex-tool-pill__svg--visible"),viewBox:"0 0 20 20",fill:"none",children:I("path",{d:"M5.5 10.5 L8.5 13.5 L14.5 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),I("svg",{className:U("cortex-tool-pill__svg","cortex-tool-pill__svg--error",Y==="error"&&"cortex-tool-pill__svg--visible"),viewBox:"0 0 20 20",fill:"none",children:I("path",{d:"M6.5 6.5 L13.5 13.5 M13.5 6.5 L6.5 13.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]}),I("span",{className:U("cortex-tool-pill__title",Y==="error"&&"cortex-tool-pill__title--error",Y==="starting"&&Z&&"cortex-tool-pill__title--pending"),children:Z??$(X)}),G!==void 0&&I("span",{className:"cortex-tool-pill__meta",children:$("translate_rows_read",{count:G})})]})}import{jsx as E0}from"react/jsx-runtime";function y2({message:_,toolCallPart:$,agentWorking:Y}){if(!f($.state)&&!i($).statement){if($.name==="queryGraph")return E0(K_,{activity:"graph"});if($.name==="executeCode")return E0(K_,{activity:"code"})}return E0(R2,{toolCallPart:$,message:_,agentWorking:Y})}import{jsx as R_,jsxs as j4}from"react/jsx-runtime";function C2(_){let{message:$,part:Y,debugMode:Q,animate:X,streaming:Z,agentWorking:G,attachments:J}=_,{t:N}=L();function V(){switch(Y.type){case"text":return R_(H2,{textPart:Y,role:$.role,streaming:Z,attachments:J});case"thinking":return Q?R_(G2,{reasoningPart:Y,streaming:Z}):R_(K_,{activity:"reasoning",className:"cortex-reasoning-animated"});case"tool-call":return Q?R_(F2,{toolCallPart:Y}):R_(y2,{toolCallPart:Y,message:$,agentWorking:G});default:return j4("p",{className:"cortex-unhandled-type",children:[N("translate_unhandled_type")," ",Y.type]})}}return R_("div",{className:U("cortex-message-part",X&&"cortex-message-part--animated",_.folded&&"cortex-message-part--folded"),"data-cortex-frontier":_.frontier?"":void 0,children:V()})}import{jsx as e,jsxs as k0}from"react/jsx-runtime";function m4({isUser:_,clipboardText:$,createdAt:Y}){let{locale:Q}=L();return k0("div",{className:U("cortex-message-actions",_&&"cortex-message-actions--user"),children:[$&&e(h,{value:$}),Y&&e("time",{className:"cortex-message-actions__time",dateTime:Y,children:r(Y,Q)})]})}function x4({count:_,animate:$,onOpen:Y}){let{t:Q}=L();return e("button",{type:"button",className:U("cortex-tool-fold",$&&"cortex-message-part--animated"),onClick:Y,children:Q(C_(_,"translate_one_more_step","translate_n_more_steps"),{count:_})})}function w2(_){let{message:$,parts:Y,metadata:Q,debugMode:X,animate:Z,isStreaming:G,agentWorking:J,closesTurn:N,fold:V,onOpenRun:K,frontier:z}=_,F=$.role==="assistant",B=$.role==="user",q=G?Y.length-1:-1,O=Q?.attachments??[],P=Y.filter((k)=>V?.get(k)?.kind!=="hidden"),D=P.filter((k)=>k.type==="text").at(-1),H=D?Y.indexOf(D):-1,W=(B||F)&&!G&&H>=0,M=D!==P.at(-1)?H:-1,A=W&&e(m4,{isUser:B,clipboardText:R1(Y),createdAt:Q?.createdAt});return k0("div",{className:"cortex-message-parts",children:[Y.map((k,n)=>{let Z_=V?.get(k);return k0(g4,{children:[e(C2,{part:k,message:$,debugMode:X,animate:Z,streaming:n===q,agentWorking:J,attachments:O,frontier:k===z,folded:Z_?.kind==="hidden"}),Z_?.kind==="more"&&e(x4,{count:Z_.count,animate:Z,onOpen:()=>K(Z_.runId)}),n===M&&A]},$.parts.indexOf(k))}),O.length>0&&e(t6,{attachments:O,isUser:B}),Q?.isAborted&&e(a6,{}),M===-1&&A,X&&Q&&N&&e(Z2,{messageId:$.id,isAssistant:F,metadata:Q})]})}import{jsx as z_,jsxs as R0}from"react/jsx-runtime";function S2({firing:_,debugMode:$}){let{t:Y,locale:Q}=L();return R0("div",{className:U("cortex-trigger-block",$&&"cortex-trigger-block--debug"),children:[R0("div",{className:"cortex-trigger-block__head",children:[z_("svg",{className:"cortex-trigger-block__icon",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:z_("path",{d:"M6.75 1 2.5 6.75h3l-.25 4.25L9.5 5.25h-3z",fill:"currentColor"})}),$&&z_("span",{children:Y("translate_trigger_fired")}),z_("span",{className:"cortex-trigger-block__name",children:_.name}),z_("time",{className:"cortex-trigger-block__time",dateTime:_.firedAt,children:r(_.firedAt,Q)})]}),$&&R0("details",{className:"cortex-trigger-block__payload",children:[z_("summary",{children:Y("translate_trigger_payload")}),z_(Y_,{data:_.payload,expandDepth:2})]})]})}import{jsx as l_}from"react/jsx-runtime";var b2=h4(function($){let{message:Y,metadata:Q,isStreaming:X,agentWorking:Z,closesTurn:G,debugMode:J,animate:N,fold:V,onOpenRun:K,workingTurn:z,frontier:F}=$,B=B_(Y.parts,{debugMode:J,isStreaming:X});if(Q?.trigger)return l_("div",{className:"cortex-message",children:l_(S2,{firing:Q.trigger,debugMode:J})});if(B.length===0&&!Q?.attachments?.length)return l_("div",{className:"cortex-message"});return l_("div",{className:U("cortex-message",z&&"cortex-message--working-turn"),children:l_(w2,{message:Y,parts:B,metadata:Q,debugMode:J,animate:N,isStreaming:X,agentWorking:Z,closesTurn:G,fold:V,onOpenRun:K,frontier:F})})});import{jsx as V1}from"react/jsx-runtime";var u4=[{role:"user",lines:[13,9]},{role:"assistant",lines:[16,18,12]},{role:"user",lines:[11]},{role:"assistant",lines:[14,15]}];function T2(){return V1("div",{className:"cortex-widget__messages-skeleton",children:u4.map((_,$)=>V1("div",{className:`cortex-widget__msg-skel cortex-widget__msg-skel--${_.role}`,children:V1("div",{className:`cortex-widget__msg-skel-bubble cortex-widget__msg-skel-bubble--${_.role}`,children:_.lines.map((Y)=>V1("div",{className:"cortex-skeleton cortex-widget__msg-skel-line",style:{width:`${Y}rem`}},Y))})},$))})}import{jsx as d,jsxs as K1,Fragment as i4}from"react/jsx-runtime";function p4(_){let $=W_(null),Y=W_(null),Q=W_(!0),X=W_(!0),Z=W_(!1),G=n_(()=>{if(Z.current)return;Z.current=!0,queueMicrotask(()=>{Z.current=!1;let K=$.current;if(!K)return;$1(K),X.current=!0,Q.current=!1})},[]);I0(()=>{let K=Y.current;if(!_||!$.current||!K)return;if(G(),typeof ResizeObserver>"u")return;let z=0,F=new ResizeObserver(([B])=>{let q=B?.contentRect.height??0,O=q>z;if(z=q,O&&(Q.current||X.current))G()});return F.observe(K),()=>F.disconnect()},[_,G]);let J=n_(()=>{Q.current=!0},[]),N=n_(()=>{if(Q.current)G()},[G]);function V(){let K=$.current;if(K)X.current=D0(K)<100}return{containerRef:$,contentRef:Y,onScroll:V,pin:J,settlePinned:N}}function d4({pin:_,settlePinned:$,contentRef:Y},Q,X){let[Z,G]=C0(!1);I0(()=>{G(!1),_(),queueMicrotask(()=>G(!0))},[Q,_]);let J=X[X.length-1],N=J?.role==="user"?J.id:void 0,V=N?J?.parts.find((K)=>K.type==="text")?.content:void 0;return y0(()=>{if(!N)return;_();let K=Y.current;if(K&&V!==void 0)W0(K,V)},[N,V,_,Y]),I0(()=>{$()},[X,$]),Z}function l4(_,$,Y,Q){let[X,Z]=C0(new Set),G=n_((V)=>Z((K)=>new Set(K).add(V)),[]),[J]=C0(C1);return{folds:c4(()=>J(_,{agentWorking:$,debugMode:Y,opened:X,foldable:Q}),[J,_,$,Y,X,Q]),openRun:G}}function n4({working:_}){let $=W_(null),Y=W_(void 0);return y0(()=>{let Q=$.current;if(!Q)return;let X=H0(Q);return Y.current=X,()=>{X.dispose(),Y.current=void 0}},[]),y0(()=>Y.current?.sync(_)),K1("div",{ref:$,className:"cortex-working-avatar","aria-hidden":"true",children:[K1("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d("path",{d:"M9.94 15.5a2 2 0 0 0-1.44-1.44l-6.13-1.58a.5.5 0 0 1 0-.96L8.5 9.94A2 2 0 0 0 9.94 8.5l1.58-6.14a.5.5 0 0 1 .96 0l1.58 6.14a2 2 0 0 0 1.44 1.44l6.14 1.58a.5.5 0 0 1 0 .96l-6.14 1.58a2 2 0 0 0-1.44 1.44l-1.58 6.14a.5.5 0 0 1-.96 0z"}),d("path",{d:"M20 3v4M22 5h-4M4 17v2M5 18H3"})]}),d("span",{className:"cortex-working-avatar__ring"})]})}function v2(_){let{config:$,selectedThread:Y}=L(),{messages:Q,isAgentWorking:X,isLoadingMessages:Z,hasPendingToolCalls:G}=F_(),{capabilities:J,composerRef:N,debugMode:V}=_,K=!Z||X,z=p4(K),F=d4(z,Y?.id,Q),B=X?w_(Q)?.id:void 0,q=$.toolComponents,O=n_((A)=>I1(A,q),[q]),{folds:P,openRun:D}=l4(Q,X,V,O),H=Q.map((A)=>A.role).lastIndexOf("user"),W=X&&!V,M=W?y1(Q,{foldable:O}):void 0;return K1(i4,{children:[!K?d(T2,{}):d("div",{className:_.className,children:d("div",{ref:z.containerRef,className:"cortex-message-list",onScroll:z.onScroll,children:K1("div",{ref:z.contentRef,className:"cortex-message-list__content",children:[Q.map((A,k)=>d(b2,{message:A,metadata:A.metadata,isStreaming:A.id===B,agentWorking:X,fold:P.get(A.id),onOpenRun:D,closesTurn:A.role==="assistant"&&Q[k+1]?.role!=="assistant",debugMode:V,animate:F,workingTurn:W&&k>H,frontier:A.id===B?M:void 0},A.id)),X&&!M&&d("div",{className:"cortex-working-thinking","data-cortex-frontier":"",children:d(K_,{activity:"reasoning"})}),d(n4,{working:X},Y?.id)]})})}),!G&&d(Y1,{capabilities:J,composerRef:N})]})}import{jsx as f2,jsxs as r4}from"react/jsx-runtime";function j2(_){let{debugMode:$,selectedThread:Y}=L(),{screens:Q}=_;return r4("div",{className:U("cortex-widget__screen",Q.screen==="chat"&&"cortex-widget__screen--active",Q.screen!=="chat"&&"cortex-widget__screen--right"),children:[_.header,Y?f2(v2,{className:"cortex-widget__messages",debugMode:$,capabilities:_.capabilities,composerRef:_.composerRef}):_.landing,f2("div",{className:"cortex-widget__sidebar-backdrop",onClick:Q.closeSidebar})]})}import{useState as e4}from"react";import{useEffect as w0,useRef as h2,useState as S0}from"react";import{useChat as s4}from"@tanstack/ai-react";import{useEffect as a4,useLayoutEffect as o4,useState as t4}from"react";function g2(_,{sessionRef:$,pendingSendRef:Y}){let[Q]=t4(_);return o4(()=>{return $.current=Q,()=>{if($.current===Q)$.current=void 0}},[Q,$]),a4(()=>{if(!Y.current.length)return;let X=setTimeout(()=>{let Z=Y.current;Y.current=[],(async()=>{for(let{prompt:G,attachments:J}of Z)await Q.send(G,J)})()});return()=>clearTimeout(X)},[Q,Y]),Q}import{useRef as m2}from"react";function x2(_){let $=m2(_);$.current=_;let Y=m2(Promise.resolve(void 0));async function Q(X){let Z=$.current;if(!Z.isAlive()||X!==Z.threadId)return;return S1({api:Z.api,threadId:X,isStale:()=>!$.current.isAlive(),isStreaming:()=>$.current.isStreaming(),setMessages:(G)=>$.current.setMessages(G)})}return function(Z){return Y.current=Y.current.then(()=>Q(Z)),Y.current}}function u2(_){let{thread:$,api:Y}=_,Q=h2(!0),[X,Z]=S0(!1),G=h2(null),J=x2({api:Y,threadId:$.id,isAlive:()=>Q.current,isStreaming:()=>G.current.chat.isLoading,setMessages:(H)=>G.current.chat.setMessages(H)}),[N]=S0(()=>B0({threadId:$.id,isAlive:()=>Q.current,onToolCall:()=>G.current.props.configRef.current.hooks?.onToolCall,deliver:(H)=>G.current.chat.addToolResult(H),setRunning:(H)=>G.current.props.setRunning($.id,H),reloadThreads:()=>G.current.props.reloadThreads(),refreshMessages:()=>J($.id),onTurnFinished:()=>G.current.props.onTurnFinished(),onSendFailed:()=>G.current.props.onSendFailed()})),[V]=S0(()=>w1({api:Y,thread:{id:$.id,isRunning:$.isRunning},mode:_.mode,localMessages:()=>G.current.chat.messages,onHydrated:(H)=>{if(Q.current)N.hydrated(H,$.isRunning)},onTranscriptCarried:(H)=>{if(Q.current)N.transcriptCarried(H)},setLoadingMessages:(H)=>{if(Q.current)Z(H)}})),K=s4({threadId:$.id,persistence:!0,initialMessages:_.initialMessages,connection:V,onChunk:()=>{if(Q.current)N.chunkArrived()},onError:()=>{if(Q.current)N.streamFailed()}});G.current={chat:K,props:_};async function z(H,W){N.sendStarted();let M={id:S_(),role:"user",parts:[{type:"text",content:H}],metadata:{createdAt:new Date().toISOString(),attachments:W}};await G.current.chat.append(M)}async function F(){if(!G.current.chat.isLoading)return;let{aborted:H}=await Y.abortStream($.id).catch(()=>({aborted:!1}));if(!Q.current)return;if(H)N.abortConfirmed();G.current.chat.stop()}function B(H,W,M){return G.current.chat.addToolResult({toolCallId:H,tool:W,output:M}).catch((A)=>{throw J($.id),A})}function q(H,W){return m1(G.current.chat,H,W)}function O(H){if(G.current.chat.isLoading)return;if(H.isRunning){G.current.props.remount(H,G.current.chat.messages);return}J(H.id)}w0(()=>{return Q.current=!0,()=>{Q.current=!1}},[]),g2(()=>({threadId:$.id,send:z,abort:F,addToolResult:B,respondToApproval:q,reattach:O,transcriptUpdated:(H,W)=>{if(H===$.id)N.transcriptUpdated(W)}}),{sessionRef:_.sessionRef,pendingSendRef:_.pendingSendRef});let{messages:P,isLoading:D}=K;return w0(()=>{N.loadingChanged(D,()=>G.current.chat.messages)},[N,D]),w0(()=>{G.current.props.publish({messages:P,isAgentWorking:D,isLoadingMessages:X,hasPendingToolCalls:!D&&__(P).length>0})},[P,D,X]),null}import{jsx as _7,jsxs as $7}from"react/jsx-runtime";function c2({selection:_,threads:$,children:Y,...Q}){let{session:X}=_,[Z,G]=e4(),J=X&&`${X.thread.id}:${X.epoch}`,N=X&&Z&&(Z.key===J||X.mode==="reload")?Z.value:F0;return $7(U0.Provider,{value:N,children:[X&&J&&_7(u2,{thread:X.thread,mode:X.mode,initialMessages:X.initialMessages,setRunning:$.setRunning,reloadThreads:$.reload,remount:_.remount,publish:(V)=>G({key:J,value:V}),...Q},J),Y]})}import{jsx as w,jsxs as D_,Fragment as Y7}from"react/jsx-runtime";function p2(_){let{locale:$,t:Y}=L(),{threads:Q}=_;return w("div",{className:"cortex-widget__threads-list",children:Q===void 0?[1,2,3,4].map((X)=>D_("div",{className:"cortex-widget__thread-skeleton",children:[w("div",{className:"cortex-skeleton cortex-widget__thread-skeleton-icon"}),w("div",{className:"cortex-widget__thread-skeleton-lines",children:w("div",{className:"cortex-skeleton cortex-widget__thread-skeleton-line",style:{width:`${40+X*12}%`}})})]},X)):D_(Y7,{children:[Q.map((X)=>{let Z=X.id===_.selectedThreadId,G=r(X.updatedAt,$);return D_("button",{onClick:()=>_.openThread(X),className:U("cortex-widget__thread-item",Z&&"cortex-widget__thread-item--active"),children:[w("div",{className:U("cortex-widget__thread-icon",Z&&"cortex-widget__thread-icon--active"),children:w("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:w("path",{d:S.bubble,stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),D_("div",{className:"cortex-widget__thread-info",children:[D_("div",{className:"cortex-widget__thread-title-row",children:[w("p",{className:U("cortex-widget__thread-title",Z&&"cortex-widget__thread-title--active"),children:X.title??Y("translate_untitled")}),X.isRunning&&D_("span",{className:U("cortex-widget__thread-running",Z&&"cortex-widget__thread-running--active"),children:[w("span",{className:"cortex-widget__thread-running-dot"}),Y("translate_running")]})]}),G&&w("p",{className:"cortex-widget__thread-time",children:G})]}),w("span",{role:"button",tabIndex:0,onClick:(J)=>{J.stopPropagation(),_.deleteThread(X.id)},onKeyDown:(J)=>{if(J.key!=="Enter"&&J.key!==" ")return;J.preventDefault(),J.stopPropagation(),_.deleteThread(X.id)},className:U("cortex-widget__thread-delete",Z&&"cortex-widget__thread-delete--active"),children:w("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:w("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})})}),w("svg",{className:U("cortex-widget__thread-arrow",Z&&"cortex-widget__thread-arrow--active"),width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",children:w("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]},X.id)}),!Q.length&&D_("div",{className:"cortex-widget__threads-empty",children:[w("div",{className:"cortex-widget__threads-empty-icon",children:w("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",className:"cortex-widget__threads-empty-svg",children:w("path",{d:S.bubble,stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),w("p",{className:"cortex-widget__threads-empty-title",children:Y("translate_no_threads_yet")}),w("p",{className:"cortex-widget__threads-empty-subtitle",children:Y("translate_start_a_new_conversation")}),w("button",{onClick:_.newChat,className:"cortex-widget__new-chat-btn cortex-widget__new-chat-btn--empty-state",children:Y("translate_new_chat")})]})]})})}import{useSyncExternalStore as Q7}from"react";function d2(_){return Q7(($)=>{let Y=window.matchMedia(_);return Y.addEventListener("change",$),()=>Y.removeEventListener("change",$)},()=>window.matchMedia(_).matches,()=>!1)}import{jsx as Z7,jsxs as n2}from"react/jsx-runtime";var X7="(max-width: 768px)";function l2(_){_.preventDefault()}function i2(_){let{screens:$}=_,Y=d2(X7),Q=_.viewMode==="full"?Y&&!$.sidebarOpen:$.screen!=="threads";return Z7("div",{className:U("cortex-widget",_.className),"data-cortex-theme":_.theme,children:n2("div",{className:U("cortex-widget__container",_.viewMode==="full"&&"cortex-widget__container--full",$.sidebarOpen&&"cortex-widget__container--sidebar-open"),onDragOver:l2,onDrop:l2,children:[n2("div",{className:U("cortex-widget__screen",$.screen==="threads"&&"cortex-widget__screen--active",$.screen!=="threads"&&"cortex-widget__screen--left"),"aria-hidden":Q||void 0,inert:Q||void 0,children:[_.header,_.threadList]}),_.children]})})}import{jsx as l}from"react/jsx-runtime";var J7={header:l6,landing:i6,threadList:p2};function b0(_,$){return _?.[$]??J7[$]}function N7(_){let{isAgentWorking:$}=F_();return l(_.component,{..._.context,isWorking:$})}function V7({config:_,className:$,slots:Y}){let Q=r2(_);Q.current=_;let[X]=z1(()=>U1(()=>Q.current.transport)),Z=v6(X),[G,J]=z1(!1),[N,V]=z1();G7(()=>Z0(_.theme,V),[_.theme]);let K=_.viewMode??"helper",z=j6(K),[F,B]=z1(0),q=E6(X,F),O=r2(null),P=w6({api:X,threads:Z,getHooks:()=>Q.current.hooks}),{sessionRef:D,selection:H,queue:W,send:M,pendingSendRef:A}=P,{selected:k,selectedRef:n}=H,Z_=b6({threads:Z,selectedRef:n,sessionRef:D,deselect:H.deselect,onReconnect:()=>B((m)=>m+1)});S6({getConfig:()=>Q.current,onEvent:Z_.onEvent,onMount:()=>void Z.reload(),onReconnect:Z_.onReconnect});let i_=L1(_.locale),a2={config:_,locale:i_,t:(m,W1)=>G_(i_,m,W1),api:X,debugMode:G,scheme:N,capabilities:q,selectedThread:k,send:M,...T6(D),queue:W.value};function o2(){W.store.discardConsumed(),setTimeout(()=>O.current?.focusInput())}function t2(){W.store.restoreConsumed(n.current?.id)}function T0(m){P.openThread(m),z.showChat()}function v0(){H.deselect(),z.showChat()}function s2(){J((m)=>!m)}function f0(m){let W1={screen:m,viewMode:K,title:k?.title??null,agentName:H_(_.agentName,i_),threadCount:Z.threads?.length??0,debug:{shown:Boolean(_.showDebugButton),on:G},newChat:v0,openHistory:z.openHistory,closeHistory:z.closeHistory,toggleDebug:s2};return l(N7,{component:b0(Y,"header"),context:W1})}let e2=b0(Y,"landing"),_5={...O1(q,i_,(m)=>void M(m)),threads:Z.threads,composer:l("div",{className:"cortex-widget__landing-composer",children:l(Y1,{capabilities:q})}),openThread:T0,openHistory:z.openHistory},$5=b0(Y,"threadList"),Y5={threads:Z.threads,selectedThreadId:k?.id,openThread:T0,deleteThread:(m)=>void P.deleteThread(m),newChat:v0};return l(q0.Provider,{value:a2,children:l(c2,{selection:H,threads:Z,api:X,configRef:Q,sessionRef:D,pendingSendRef:A,onTurnFinished:o2,onSendFailed:t2,children:l(i2,{className:$,theme:_.theme,viewMode:K,screens:z,header:f0("threads"),threadList:l($5,{...Y5}),children:l(j2,{screens:z,capabilities:q,composerRef:O,header:f0("chat"),landing:l(e2,{..._5})})})})})}export{V7 as CortexChatWidget};
|
|
1
|
+
var K5=Object.create;var{getPrototypeOf:N5,defineProperty:g0,getOwnPropertyNames:z5}=Object;var W5=Object.prototype.hasOwnProperty;var D_=(_,$,Y)=>{Y=_!=null?K5(N5(_)):{};let Q=$||!_||!_.__esModule?g0(Y,"default",{value:_,enumerable:!0}):Y;for(let X of z5(_))if(!W5.call(Q,X))g0(Q,X,{get:()=>_[X],enumerable:!0});return Q};var B_=((_)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(_,{get:($,Y)=>(typeof require<"u"?require:$)[Y]}):_)(function(_){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+_+'" is not supported')});import{useEffect as L7,useRef as _5,useState as H1}from"react";var B1=["en","ar"];var q1=["image/png","image/jpeg","image/webp","application/pdf"];var m0=5;function x0(_,$){if(!q1.some((Y)=>Y===_))return"type";if($>10485760)return"size";return"ok"}var h0=["executeCode","queryDataset","describeDataset"];function F1(_){return{..._,role:_.role==="trigger"?"user":_.role}}var u0="clientToolAnswers";function c0(_){return _.approval?.id??`approval_${_.id}`}var U1="X-Cortex-Timezone";function L1(_){let $=_.getHeaders();return $ instanceof Promise?$.then(p0):Promise.resolve(p0($))}function p0(_){let $={..._},Y=H5(),Q=Object.keys($).some((X)=>X.toLowerCase()===U1.toLowerCase());if(Y&&!Q)$[U1]=Y;return $}function H5(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function D5(_,$){let Y=_.baseUrl;return(typeof Y==="string"?Y:Y()).replace(/\/$/,"")+$}function B5(_){let $=_?.match(/filename\*\s*=\s*[^']*'[^']*'([^;\r\n]+)/i)?.[1]?.trim().replace(/^"|"$/g,"");if($)try{return decodeURIComponent($)}catch{}return _?.match(/filename\s*=\s*"?([^";\r\n]+)"?/i)?.[1]}function P1(_){function $(){return L1(_())}function Y(X){return D5(_(),X)}async function Q(X,Z){let G=new Headers(await $());if(new Headers(Z?.headers).forEach((K,N)=>{G.set(N,K)}),Z?.body instanceof FormData)G.delete("Content-Type");else if(!G.has("Content-Type"))G.set("Content-Type","application/json");let J=await fetch(Y(X),{...Z,headers:G});if(!J.ok)throw Error(`HTTP ${J.status}: ${J.statusText}`);let V=await J.text();return V?JSON.parse(V):void 0}return{getCapabilities(){return Q("/capabilities")},listThreads(){return Q("/threads")},createThread(){return Q("/threads",{method:"POST"})},deleteThread(X){return Q(`/threads/${X}`,{method:"DELETE"})},listMessages(X){return Q(`/threads/${X}/messages`)},listLlmRequests(X){return Q(`/messages/${X}/llm-requests`)},abortStream(X){return Q(`/chat/${X}/abort`,{method:"POST"})},initiateToolCall(X,Z){return Q(`/chat/${X}/tools/${Z}/initiate`,{method:"POST"})},uploadAttachment(X,Z){let G=new FormData;return G.append("file",Z),Q(`/threads/${X}/files`,{method:"POST",body:G})},deleteAttachment(X){return Q(`/files/${X}`,{method:"DELETE"})},async downloadAttachment(X){let Z=await fetch(Y(`/files/${X}`),{headers:await $()});if(!Z.ok)throw Error(`HTTP ${Z.status}: ${Z.statusText}`);return{blob:await Z.blob(),name:B5(Z.headers.get("Content-Disposition"))??X}},resolveHeaders:$,resolveUrl:Y}}function q_(_,$){if(_===void 0||typeof _==="string"||Array.isArray(_))return _;let Y=_;return Y[$]??Y.en??Object.values(Y)[0]}var d0={translate_history:"السجل",translate_back:"رجوع",translate_greeting:"بماذا يمكنني مساعدتك اليوم؟",translate_n_conversations:"{{count}} محادثات",translate_one_conversation:"محادثة واحدة",translate_no_threads_yet:"لا توجد محادثات بعد",translate_start_a_new_conversation:"ابدأ محادثة جديدة",translate_untitled:"بدون عنوان",translate_new_chat:"محادثة جديدة",translate_normal:"عادي",translate_debug:"تصحيح",translate_type_a_message:"اكتب رسالة...",translate_completed:"مكتمل",translate_attach_files:"إرفاق ملفات",translate_drop_files_here:"أفلت ملفاتك هنا...",translate_remove_attachment:"إزالة المرفق",translate_attachment_rejected:"لا يمكن إرفاق هذا الملف",translate_attachment_caption:"من فضلك اطّلع على الملفات المرفقة.",translate_download:"تنزيل",translate_tool_status_0:"جارٍ جلب البيانات…",translate_tool_status_1:"جارٍ تحليل المعلومات…",translate_tool_status_2:"جارٍ معالجة الطلب…",translate_tool_status_3:"جارٍ تجميع النتائج…",translate_tool_status_4:"جارٍ تحضير الرد…",translate_tool_status_5:"جارٍ البحث…",translate_tool_status_6:"جارٍ فحص السجلات…",translate_tool_status_7:"جارٍ مراجعة التفاصيل…",translate_tool_status_8:"جارٍ إجراء الحسابات…",translate_tool_status_9:"جارٍ سحب المعلومات…",translate_tool_done_0:"تم جلب البيانات بنجاح",translate_tool_done_1:"تم التحليل بنجاح",translate_tool_done_2:"تمت معالجة الطلب بنجاح",translate_tool_done_3:"تم تجميع النتائج بنجاح",translate_tool_done_4:"تم تحضير الرد بنجاح",translate_tool_done_5:"تم البحث بنجاح",translate_tool_done_6:"تم فحص السجلات بنجاح",translate_tool_done_7:"تمت المراجعة بنجاح",translate_tool_done_8:"تمت الحسابات بنجاح",translate_tool_done_9:"تم استرجاع المعلومات بنجاح",translate_rows_read:"{{count}} صفوف",translate_one_more_step:"وخطوة أخرى",translate_n_more_steps:"و{{count}} خطوات أخرى",translate_tool_error:"حدث خطأ",translate_attachment_status:"جارٍ قراءة الملف المرفق…",translate_attachment_done:"تمت قراءة الملف المرفق",translate_graph_0:"جارٍ استكشاف الروابط...",translate_graph_1:"جارٍ رسم الخريطة...",translate_graph_2:"جارٍ اكتشاف العلاقات...",translate_graph_3:"جارٍ تتبع الروابط...",translate_graph_4:"جارٍ التنقل في المعرفة...",translate_graph_5:"جارٍ كشف الرؤى...",translate_graph_6:"جارٍ ربط النقاط...",translate_graph_7:"جارٍ تتبع المسار...",translate_graph_8:"جارٍ تجميع الأجزاء...",translate_graph_9:"جارٍ بناء الصورة...",translate_code_0:"جارٍ حساب الأرقام...",translate_code_1:"جارٍ معالجة البيانات...",translate_code_2:"جارٍ تنفيذ طلبك...",translate_code_3:"جارٍ تحليل الأرقام...",translate_code_4:"جارٍ تجميع كل شيء...",translate_code_5:"جارٍ تحليل النتائج...",translate_code_6:"جارٍ العمل خلف الكواليس...",translate_code_7:"جارٍ ترتيب التفاصيل...",translate_code_8:"جارٍ تحضير إجابتك...",translate_code_9:"أوشك على الانتهاء...",translate_reasoning_0:"جارٍ التفكير...",translate_reasoning_1:"جارٍ دراسة الخيارات...",translate_reasoning_2:"جارٍ تقييم الاحتمالات...",translate_reasoning_3:"جارٍ التأمل في هذا...",translate_reasoning_4:"جارٍ إيجاد الحل...",translate_reasoning_5:"جارٍ ترتيب الأفكار...",translate_reasoning_6:"جارٍ التمعن في الأمر...",translate_reasoning_7:"جارٍ إيجاد أفضل طريقة...",translate_reasoning_8:"جارٍ تنظيم أفكاري...",translate_reasoning_9:"أوشك على الانتهاء...",translate_running:"قيد التنفيذ",translate_aborted:"تم الإلغاء",translate_input:"المدخلات",translate_output:"المخرجات",translate_calling:"جارٍ الاستدعاء",translate_input_ready:"المدخلات جاهزة",translate_needs_approval:"بحاجة إلى موافقة",translate_approved:"تمت الموافقة",translate_responded:"تم الرد",translate_declined:"تم الرفض",translate_approve:"موافقة",translate_deny:"رفض",translate_error:"خطأ",translate_approval_requested:"طلب موافقة",translate_approval_response:"رد الموافقة",translate_waiting_for_approval:"في انتظار الموافقة لتنفيذ هذه الأداة.",translate_tool_approved:"تمت الموافقة.",translate_tool_response_received:"تم استلام الرد.",translate_tokens:"رمز",translate_fresh:"جديد",translate_cache_read:"قراءة من الذاكرة",translate_cache_write:"كتابة في الذاكرة",translate_n_percent_cached:"{{percent}}٪ مخزّن مؤقتًا",translate_text:"نص",translate_reasoning:"الاستنتاج",translate_read:"قراءة",translate_write:"كتابة",translate_total:"الإجمالي",translate_request:"الطلب",translate_response:"الرد",translate_step_n:"الخطوة {{number}}",translate_inspect_llm_requests:"فحص طلبات النموذج",translate_loading:"جارٍ التحميل…",translate_no_llm_requests:"لا توجد طلبات نموذج مسجّلة لهذه الرسالة.",translate_unhandled_type:"نوع غير مدعوم:",translate_client_tool_title:"أكمل هذه الخطوة للمتابعة",translate_client_tool_loading:"جارٍ تجهيز خطوة آمنة...",translate_client_tool_failed:"تعذّر تحميل هذه الخطوة",translate_client_tool_retry:"حاول مرة أخرى",translate_client_tool_cancel:"إلغاء",translate_location_hint:"انقر على الخريطة لتثبيت الدبوس",translate_location_locate:"استخدم موقعي",translate_location_locating:"جارٍ تحديد موقعك",translate_location_locate_failed:"موقعك غير متاح",translate_location_map_failed:"تعذّر تحميل الخريطة",translate_location_send_failed:"تعذّر الإرسال، حاول مرة أخرى",translate_location_skip:"ليس الآن",translate_location_send:"إرسال",translate_location_shared:"تمت مشاركة الموقع",translate_location_not_shared:"لم تتم مشاركة الموقع",translate_trigger_fired:"تم التشغيل بواسطة",translate_trigger_payload:"الحمولة",translate_messages_disabled:"يعمل هذا الوكيل من مشغّلاته فقط.",translate_streaming:"جارٍ البث",translate_done:"تم",translate_no_reasoning:"لا يوجد تفكير مسجّل.",translate_copy:"نسخ إلى الحافظة",translate_copied:"تم النسخ",translate_media_pending_mermaid:"جارٍ رسم المخطط",translate_media_pending_vega_lite:"جارٍ رسم الرسم البياني",translate_media_pending_map:"جارٍ رسم الخريطة",translate_media_pending_report:"جارٍ كتابة التقرير",translate_media_cut_off:"انقطع هذا المقطع قبل اكتماله.",translate_media_failed:"تعذر عرض هذا المقطع.",translate_media_source:"المصدر",translate_media_pending:"جارٍ الرسم",translate_media_mermaid:"مخطط",translate_media_vega_lite:"رسم بياني",translate_media_map:"خريطة",translate_media_report:"تقرير",translate_media:"معاينة",translate_image_unavailable:"الصورة غير متاحة",translate_image_unavailable_alt:"الصورة غير متاحة: {{alt}}",translate_image:"صورة",translate_send:"إرسال",translate_table:"جدول",translate_expand:"توسيع {{name}}",translate_table_export:"تصدير إلى Excel",translate_close:"إغلاق",translate_approval_needed:"بحاجة إلى موافقتك",translate_approval_action:"تنفيذ {{tool}}",translate_approved_failed:"تمت الموافقة لكنه فشل",translate_approval_cancelled:"لم يُتخذ قرار"};var l0={translate_history:"History",translate_back:"Back",translate_greeting:"What can I help you with today?",translate_n_conversations:"{{count}} conversations",translate_one_conversation:"1 conversation",translate_no_threads_yet:"No threads yet",translate_start_a_new_conversation:"Start a new conversation",translate_untitled:"Untitled",translate_new_chat:"New Chat",translate_normal:"Normal",translate_debug:"Debug",translate_type_a_message:"Type a message...",translate_completed:"Completed",translate_attach_files:"Attach files",translate_drop_files_here:"Drop your files here...",translate_remove_attachment:"Remove attachment",translate_attachment_rejected:"This file cannot be attached",translate_attachment_caption:"Please take a look at the attached files.",translate_download:"Download",translate_tool_status_0:"Fetching data...",translate_tool_status_1:"Analyzing information...",translate_tool_status_2:"Processing request...",translate_tool_status_3:"Gathering results...",translate_tool_status_4:"Preparing response...",translate_tool_status_5:"Looking things up...",translate_tool_status_6:"Checking records...",translate_tool_status_7:"Reviewing details...",translate_tool_status_8:"Running calculations...",translate_tool_status_9:"Pulling information...",translate_tool_done_0:"Data fetched successfully",translate_tool_done_1:"Analysis completed successfully",translate_tool_done_2:"Request processed successfully",translate_tool_done_3:"Results gathered successfully",translate_tool_done_4:"Response prepared successfully",translate_tool_done_5:"Lookup completed successfully",translate_tool_done_6:"Records checked successfully",translate_tool_done_7:"Review completed successfully",translate_tool_done_8:"Calculations completed successfully",translate_tool_done_9:"Information retrieved successfully",translate_rows_read:"{{count}} rows",translate_one_more_step:"and 1 more step",translate_n_more_steps:"and {{count}} more steps",translate_tool_error:"Something went wrong",translate_attachment_status:"Reading the attached file...",translate_attachment_done:"Finished reading the file",translate_graph_0:"Exploring connections...",translate_graph_1:"Mapping out the links...",translate_graph_2:"Discovering relationships...",translate_graph_3:"Tracing the connections...",translate_graph_4:"Navigating the knowledge...",translate_graph_5:"Uncovering insights...",translate_graph_6:"Connecting the dots...",translate_graph_7:"Following the trail...",translate_graph_8:"Piecing things together...",translate_graph_9:"Building the picture...",translate_code_0:"Running the numbers...",translate_code_1:"Working through the data...",translate_code_2:"Processing your request...",translate_code_3:"Crunching the figures...",translate_code_4:"Putting it all together...",translate_code_5:"Analyzing the results...",translate_code_6:"Working behind the scenes...",translate_code_7:"Sorting through the details...",translate_code_8:"Preparing your answer...",translate_code_9:"Almost ready...",translate_reasoning_0:"Thinking it through...",translate_reasoning_1:"Considering the options...",translate_reasoning_2:"Weighing the possibilities...",translate_reasoning_3:"Reflecting on this...",translate_reasoning_4:"Working it out...",translate_reasoning_5:"Putting thoughts together...",translate_reasoning_6:"Mulling it over...",translate_reasoning_7:"Finding the best approach...",translate_reasoning_8:"Organizing my thoughts...",translate_reasoning_9:"Almost there...",translate_running:"Running",translate_aborted:"Aborted",translate_input:"Input",translate_output:"Output",translate_calling:"Calling",translate_input_ready:"Input ready",translate_needs_approval:"Needs approval",translate_approved:"Approved",translate_responded:"Responded",translate_declined:"Declined",translate_approve:"Approve",translate_deny:"Deny",translate_error:"Error",translate_approval_requested:"Approval requested",translate_approval_response:"Approval response",translate_waiting_for_approval:"Waiting for approval to execute this tool.",translate_tool_approved:"Approved.",translate_tool_response_received:"Response received.",translate_tokens:"tokens",translate_fresh:"Fresh",translate_cache_read:"Cache read",translate_cache_write:"Cache write",translate_n_percent_cached:"{{percent}}% cached",translate_text:"Text",translate_reasoning:"Reasoning",translate_read:"Read",translate_write:"Write",translate_total:"Total",translate_request:"Request",translate_response:"Response",translate_step_n:"Step {{number}}",translate_inspect_llm_requests:"Inspect LLM requests",translate_loading:"loading…",translate_no_llm_requests:"No LLM requests recorded for this message.",translate_unhandled_type:"Unhandled type:",translate_client_tool_title:"Complete this step to continue",translate_client_tool_loading:"Preparing a secure step...",translate_client_tool_failed:"This step could not be loaded",translate_client_tool_retry:"Try again",translate_client_tool_cancel:"Cancel",translate_location_hint:"Tap the map to drop a pin",translate_location_locate:"Use my location",translate_location_locating:"Finding your location",translate_location_locate_failed:"Your location is not available",translate_location_map_failed:"The map could not be loaded",translate_location_send_failed:"Could not send, try again",translate_location_skip:"Not now",translate_location_send:"Send",translate_location_shared:"Location shared",translate_location_not_shared:"Location not shared",translate_trigger_fired:"Triggered by",translate_trigger_payload:"Payload",translate_messages_disabled:"This agent only runs from its triggers.",translate_streaming:"Streaming",translate_done:"Done",translate_no_reasoning:"No reasoning provided.",translate_copy:"Copy to clipboard",translate_copied:"Copied",translate_media_pending_mermaid:"Drawing diagram",translate_media_pending_vega_lite:"Drawing chart",translate_media_pending_map:"Drawing map",translate_media_pending_report:"Writing report",translate_media_cut_off:"This block was cut off before it finished.",translate_media_failed:"Could not render this block.",translate_media_source:"Source",translate_media_pending:"Drawing",translate_media_mermaid:"Diagram",translate_media_vega_lite:"Chart",translate_media_map:"Map",translate_media_report:"Report",translate_media:"Preview",translate_image_unavailable:"Image unavailable",translate_image_unavailable_alt:"Image unavailable: {{alt}}",translate_image:"Image",translate_send:"Send",translate_table:"Table",translate_expand:"Expand {{name}}",translate_table_export:"Export to Excel",translate_close:"Close",translate_approval_needed:"Needs your approval",translate_approval_action:"Run {{tool}}",translate_approved_failed:"Approved, but it failed",translate_approval_cancelled:"Not decided"};var U5={en:l0,ar:d0};function O1(_){return _&&B1.includes(_)?_:B1[0]}function n(_,$,Y){let Q=U5[_][$];if(!Y)return Q;return Q.replace(/\{\{\s*(\w+)\s*\}\}/g,(X,Z)=>(Z in Y)?String(Y[Z]):X)}function C_(_,$,Y){return _===1?$:Y}function M1(_,$,Y){let Q=_!==void 0&&_.messages!==!1;return{greeting:q_(_?.greeting,$)||n($,"translate_greeting"),suggestions:Q&&q_(_.suggestions,$)||[],send:(X)=>{if(Q)Y(X)}}}var L5=["completed","cancelled","failed"],a_="requestLocation";function i0(_,$,Y){if($!==Y)return null;if(typeof _!=="object"||_===null)return null;let Q=_;if(Q.type!=="cortex:client-tool")return null;let X=L5.find((G)=>G===Q.status);if(!X)return null;let Z=Q.reference;return{type:"cortex:client-tool",status:X,...typeof Z==="string"?{reference:Z}:{},...Q.result!==void 0?{result:Q.result}:{}}}var P5=new Set(["complete","error"]);function f(_){return P5.has(_)}function $_(_){return(O5(_)?.parts??[]).filter((Y)=>Y.type==="tool-call"&&!f(Y.state))}function S_(_){let $=_.at(-1);if($?.role!=="assistant")return;let Y=$.parts.at(-1),Q=Y?.type==="tool-call"||Y?.type==="tool-result",X=$.parts.every((Z)=>Z.type!=="tool-call"||f(Z.state));return Q&&X?void 0:$}function O5(_){for(let $=_.length-1;$>=0;$-=1){let Y=_[$];if(Y?.role==="assistant")return Y}return}var M5={complete:"success",error:"error","approval-requested":"approval","approval-responded":"approval","awaiting-input":"pending","input-streaming":"pending","input-complete":"pending"},A5={"awaiting-input":"translate_calling","input-streaming":"translate_calling","input-complete":"translate_input_ready","approval-requested":"translate_needs_approval","approval-responded":"translate_responded",complete:"translate_completed",error:"translate_error"};function A1(_){let{state:$,approval:Y}=_;return{modifier:M5[$],labelKey:Y?.approved===!1?"translate_declined":$==="approval-responded"&&Y?.approved?"translate_approved":A5[$],pulse:$==="awaiting-input"||$==="input-streaming"?"default":$==="approval-requested"?"violet":void 0}}function E1(_){let $=_.output;if($===void 0||$===null)return"";if(typeof $==="string")return $;return JSON.stringify($,null,2)}var n0={code:"javascript",query:"cypher"};function k1(_){let $=_&&typeof _==="object"?_:null,Y=$?Object.entries(n0).flatMap(([X,Z])=>{let G=$[X];return typeof G==="string"?[{key:X,lang:Z,value:G.replace(/\\n/g,`
|
|
2
|
+
`)}]:[]}):[],Q=_;if($){let X=Object.fromEntries(Object.entries($).filter(([Z])=>!Object.hasOwn(n0,Z)));Q=Object.keys(X).length>0?X:null}return{codeSnippets:Y,remainingInput:Q,remainingInputText:Q?JSON.stringify(Q,null,2):""}}var a0=10,E5={"awaiting-input":"starting","input-streaming":"starting","input-complete":"processing","approval-requested":"approval","approval-responded":"processing",complete:"complete",error:"error"};function k5(_){let $=0;for(let Y=0;Y<_.length;Y++)$=$*31+_.charCodeAt(Y)|0;return Math.abs($)%a0}function R5(_){if(!h0.some((Q)=>Q===_.name))return;let $=_.input;if(!$||typeof $!=="object"||!("status"in $))return;let Y=$.status;return typeof Y==="string"&&Y.trim()?Y.trim():void 0}function I5(_){let $=_.output;if(typeof $==="string")try{$=JSON.parse($)}catch{return!1}return!!$&&typeof $==="object"&&"error"in $&&$.error===!0}function y5(_){let $=_.output;if(!$||typeof $!=="object"||!("rowCount"in $))return;return typeof $.rowCount==="number"?$.rowCount:void 0}function C5(_,$,Y){if(Y)return"translate_declined";if($==="error")return"translate_tool_error";if($==="approval")return"translate_needs_approval";let Q=_.name==="readAttachment"?"attachment":"tool",X=Q==="tool"?`_${k5(_.id)}`:"";return`translate_${Q}_${$==="complete"?"done":"status"}${X}`}function r(_){let $=_.approval?.approved===!1,Q=$||_.state==="complete"&&I5(_)?"error":E5[_.state]??"processing";return{state:Q,active:Q==="starting"||Q==="processing",gated:_.approval!==void 0||_.state==="approval-requested",titleKey:C5(_,Q,$),statement:R5(_),rowCount:Q==="complete"?y5(_):void 0}}function S5(_,$){let Y=_.metadata;if(!Y||typeof Y!=="object"||!("cortex"in Y))return;return Y.cortex?.approval?.[$]||void 0}function R1(_,$){let Y=_.approval?.approved,{state:Q}=r(_),X=Y===void 0?_.state==="approval-requested"?"pending":"cancelled":!Y?"declined":Q==="error"?"failed":"approved";return{sentence:S5(_,$)??n($,"translate_approval_action",{tool:b5(_.name)}),decision:X,decisionKey:w5[X]}}var w5={pending:void 0,approved:"translate_approved",declined:"translate_declined",failed:"translate_approved_failed",cancelled:"translate_approval_cancelled"};function b5(_){let $=_.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_\-.]+/g," ").trim().toLowerCase();return $.charAt(0).toUpperCase()+$.slice(1)}function I1(_){return Array.from({length:a0},($,Y)=>`translate_${_}_${Y}`)}function F_(_,$){return _.filter((Y,Q)=>{if(Y.type==="tool-result")return!1;if($.debugMode)return!0;if(Y.type==="text"&&!Y.content.trim())return!1;let X=Q===_.length-1;return Y.type!=="thinking"||$.isStreaming&&X})}function y1(_){return _.filter(($)=>$.type==="text").map(($)=>$.content).join(`
|
|
3
|
+
|
|
4
|
+
`)}function C1(_,$){if($&&_.name in $)return!1;return _.name!==a_||!f(_.state)}function r0(_,$){if(_.type!=="tool-call")return!0;return!f(_.state)&&!_.approval&&$.foldable(_)}function S1(_,$){let Y=S_(_);if(!Y)return;let Q=F_(Y.parts,{debugMode:!1,isStreaming:!0}),X=Q.at(-1);if(X&&r0(X,$))return X;return Q.filter((Z)=>Z.type==="tool-call"&&r0(Z,$)).at(-1)}function w1(){let _=new Map;return($,Y)=>{let Q=new Map;for(let[X,Z]of T5($,Y)){let G=_.get(X);Q.set(X,G&&f5(G,Z)?G:Z)}return _=Q,Q}}function T5(_,$){let Y=new Map;if($.debugMode)return Y;let X=$.agentWorking||$_(_).length>0?v5(_):_,Z=[];function G(){let J=Z[0]?.part.id;if(Z.length>1&&J&&!$.opened.has(J))for(let[V,{messageId:K,part:N}]of Z.entries()){let z=Y.get(K)??new Map;Y.set(K,z);let F=V===Z.length-1;z.set(N,F?{kind:"more",count:Z.length-1,runId:J}:{kind:"hidden"})}Z=[]}for(let J of X){if(J.role!=="assistant"){G();continue}let V=F_(J.parts,{debugMode:!1,isStreaming:!1});for(let K of V)if(K.type==="tool-call"&&f(K.state)&&$.foldable(K))Z.push({messageId:J.id,part:K});else G()}return G(),Y}function v5(_){let $=_.map((Y)=>Y.role).lastIndexOf("user");return $<0?[]:_.slice(0,$)}function f5(_,$){if(_.size!==$.size)return!1;for(let[Y,Q]of _){let X=$.get(Y);if(!X||X.kind!==Q.kind)return!1;if(Q.kind==="more"&&X.kind==="more"){if(Q.count!==X.count||Q.runId!==X.runId)return!1}}return!0}import{EventType as t0}from"@tanstack/ai";import{fetchServerSentEvents as o0}from"@tanstack/ai-client";function j5(_){for(let $=_.length-1;$>=0;$-=1){let Y=_[$],Q="parts"in Y&&Y.parts.some((X)=>X.type==="tool-result"||X.type==="tool-call"&&X.state==="approval-responded");if(Y.role==="user"||Q)return _.slice($,$+1)}return _.slice(-1)}function g5(_){if(_.state==="approval-responded"){let $=_.approval?.approved;if($===void 0)return null;return{toolCallId:_.id,output:null,state:$?"approved":"denied"}}if(!f(_.state))return null;return{toolCallId:_.id,output:_.output??null,state:_.state==="error"?"error":"complete"}}function m5(_){let[$]=_;if(!$||$.role!=="assistant"||!("parts"in $))return null;let Y=$.parts.flatMap((Q)=>{let X=Q.type==="tool-call"?g5(Q):null;return X?[X]:[]});return Y.length>0?Y:null}async function*s0(_,$,Y){for await(let Q of _){if(Q.type!==t0.MESSAGES_SNAPSHOT){yield Q;continue}let X=$.localMessages(),Z=X.findIndex((J)=>J.id===Y),G=Z===-1?[]:X.slice(Z+1).filter((J)=>J.role==="user");$.onTranscriptCarried?.(Q.timestamp??Date.now()),yield{...Q,messages:[...Q.messages,...G]}}}function b1(_){let{api:$,thread:Y}=_,Q=async()=>({headers:await $.resolveHeaders()}),X=o0(()=>$.resolveUrl("/chat"),Q),Z=function(V,K,N,z){let F=j5(V),B=m5(F),q=B?X.connect([],{...K,[u0]:B},N,z):X.connect(F,K,N,z);return s0(q,_,V.at(-1)?.id)},G=o0(()=>$.resolveUrl(`/chat/${Y.id}/stream`),Q),J=[];return{connect:Z,async*joinRun(V,K){yield{type:t0.MESSAGES_SNAPSHOT,timestamp:Date.now(),messages:J},yield*s0(G.joinRun(V,K),_,J.at(-1)?.id)},hydrate:async()=>{let V=await x5(_);return J=V.messages,V}}}async function x5(_){let{api:$,thread:Y,mode:Q}=_,X=Y.isRunning?{runId:Y.id}:null;if(Q==="skip")return{messages:[],activeRun:X,interrupts:null};if(Q==="load")_.setLoadingMessages?.(!0);try{let G=(await $.listMessages(Y.id)).map(F1);return _.onHydrated?.(G),{messages:G,activeRun:X,interrupts:null}}finally{_.setLoadingMessages?.(!1)}}async function T1(_){if(_.isStale?.()||_.isStreaming())return;try{let $=await _.api.listMessages(_.threadId);if(_.isStale?.()||_.isStreaming())return;let Y=$.map(F1);return _.setMessages(Y),Y}catch{return}}function w_(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let _=crypto.getRandomValues(new Uint8Array(16));_[6]=_[6]&15|64,_[8]=_[8]&63|128;let $=Array.from(_,(Y)=>Y.toString(16).padStart(2,"0")).join("");return`${$.slice(0,8)}-${$.slice(8,12)}-${$.slice(12,16)}-${$.slice(16,20)}-${$.slice(20)}`}function v1(_){let{api:$}=_,Y=new Set,Q=new Set,X=[],Z=[];function G(){return X}function J(H){return Y.add(H),()=>{Y.delete(H)}}function V(H){X=H;for(let D of Y)D()}function K(H,D){V(X.map((W)=>W.localId===H?{...W,...D}:W))}function N(H){if(Q.delete(H))return;K(H,{status:"error"})}function z(H){let D=[];for(let W of H){let M=x0(W.type,W.size)!=="ok"||X.filter((k)=>k.status!=="error").length>=m0,A=w_();if(V([...X,{localId:A,filename:W.name,status:M?"error":"uploading"}]),!M)D.push({localId:A,file:W})}if(!D.length)return;_.ensureThread().then((W)=>{for(let{localId:M,file:A}of D){if(Q.delete(M))continue;K(M,{threadId:W}),$.uploadAttachment(W,A).then((k)=>{if(Q.delete(M)){$.deleteAttachment(k.id).catch(()=>{});return}K(M,{status:"ready",attachmentId:k.id,summary:k})},()=>N(M))}},()=>{for(let{localId:W}of D)N(W)})}function F(H){let D=X.find((W)=>W.localId===H);if(!D)return;if(D.status==="uploading"){Q.add(H),V(X.filter((W)=>W.localId!==H));return}if(D.attachmentId){K(H,{status:"deleting"}),$.deleteAttachment(D.attachmentId).then(()=>V(X.filter((W)=>W.localId!==H)),()=>K(H,{status:"error"}));return}V(X.filter((W)=>W.localId!==H))}function B(H){let D=[];for(let W of X){if(W.threadId!==void 0&&W.threadId!==H){D.push(W);continue}if(W.status==="uploading")Q.add(W.localId);else if(W.status==="ready"&&W.threadId===H&&W.attachmentId)$.deleteAttachment(W.attachmentId).catch(()=>{})}V(D)}function q(){let H=X.flatMap((D)=>D.status==="ready"&&D.summary?[{...D,status:"ready",summary:D.summary}]:[]);return V(X.filter((D)=>D.status!=="ready")),Z=H,H}function P(H){let D=Z;if(Z=[],D.some((W)=>W.threadId!==H))return;V([...D.map((W)=>({...W,status:"error"})),...X])}function O(){Z=[]}return{getState:G,subscribe:J,accept:z,remove:F,clear:B,consumeReady:q,restoreConsumed:P,discardConsumed:O}}function f1(_){return{uploading:_.some(($)=>$.status==="uploading"),busy:_.some(($)=>$.status==="uploading"||$.status==="deleting"),hasReady:_.some(($)=>$.status==="ready")}}function j1(_,$,Y){try{return new URL(_).origin===$&&!Y?"allow-scripts allow-forms allow-popups":"allow-scripts allow-forms allow-popups allow-same-origin"}catch{return"allow-scripts allow-forms allow-popups"}}function g1(_,$,Y){try{return Y===!0&&new URL(_).origin===$}catch{return!1}}function m1(_,$){try{return _.contentWindow?.location.origin===$}catch{return!1}}function x1(_){let $=!1,Y=!1,Q,X;function Z(V){if(!$)_.onState(V)}function G(){if($)return;Y=!1,Z({phase:"error"})}function J(V){if($||Y)return;Y=!0,Z({phase:"settling"});try{let K=_.submit(V);if(K instanceof Promise)K.catch(G)}catch{G()}}return{async start(){Z({phase:"initiating"});try{let V=await _.initiate();if(!V.embed){Z({phase:"unavailable"});return}if(!/^https?:$/.test(new URL(V.embedUrl).protocol)){Z({phase:"error"});return}Q=V.embedOrigin,Z({phase:"embedded",embedUrl:V.embedUrl,surface:V.surface,embedOrigin:V.embedOrigin})}catch(V){let K=V instanceof Error?V.message:"";Z({phase:/HTTP 404/.test(K)?"unavailable":"error"})}},setSource(V){if(V!==null&&V!==void 0)X=V},handleMessage(V){if(!Q)return;if(X===void 0||V.source!==X)return;let K=i0(V.data,V.origin,Q);if(!K)return;J({status:K.status,reference:K.reference,result:K.result})},cancel(){J({status:"cancelled"})},terminate(){if($||Y)return;Q=void 0,X=void 0,Z({phase:"error"})},dispose(){$=!0}}}function h1(_,$,Y){let Q=_.interrupts.find((X)=>X.id===$);if(!Q||!("resolveInterrupt"in Q))return _.addToolApprovalResponse({id:$,approved:Y});return Q.resolveInterrupt({approved:Y}),Promise.resolve()}async function b_(_,$){let Y=await import("leaflet"),Q=!$.interactive,X=Y.map(_,{center:$.center,zoom:$.zoom,zoomControl:!Q,dragging:!Q,scrollWheelZoom:!Q,doubleClickZoom:!Q,touchZoom:!Q,boxZoom:!Q,keyboard:!Q});Y.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'}).addTo(X);let Z=new ResizeObserver(()=>X.invalidateSize());return Z.observe(_),{leaflet:Y,map:X,dispose(){Z.disconnect(),X.remove()}}}var o_={position:void 0,locating:!1,locateFailed:!1,mapFailed:!1,submitting:!1,deliveryFailed:!1},h5={center:{lat:20,lng:0},zoom:2},u5=13,_6=16,c5=1e4;function u1(_,$){let Y=o_,Q=!1,X=!1,Z,G,J,V=0;function K(B){if(Y={...Y,...B},!Q)$.onState(Y)}function N(){let B=Y.position;if(!Z||!B)return;let{leaflet:q,map:P}=Z;if(G)G.setLatLng(B);else{let O=q.marker(B,{draggable:!Y.submitting}).addTo(P);O.on("dragend",()=>{let{lat:H,lng:D}=O.getLatLng();z({lat:H,lng:e0(D)})}),G=O}J?.remove(),J=B.accuracy?q.circle(B,{radius:B.accuracy}).addTo(P):void 0}function z(B){if(Y.submitting)return;V+=1,K({position:B,locating:!1,locateFailed:!1}),N()}function F(B){if(Q||X)return;X=!0,V+=1,G?.dragging?.disable(),K({submitting:!0,locating:!1,deliveryFailed:!1});let q=()=>{X=!1,G?.dragging?.enable(),K({submitting:!1,deliveryFailed:!0})};try{let P=$.submit(B);if(P instanceof Promise)P.catch(q)}catch{q()}}return{async start(){let B=$.center?{center:$.center,zoom:u5}:h5,q;try{q=await b_(_,{...B,interactive:!0})}catch{K({mapFailed:!0});return}if(Q){q.dispose();return}Z=q,q.map.on("click",(P)=>z({lat:P.latlng.lat,lng:e0(P.latlng.lng)})),N()},locate(){if(Y.locating||Y.submitting)return;if(!navigator.geolocation){K({locateFailed:!0});return}V+=1;let B=V;K({locating:!0,locateFailed:!1}),navigator.geolocation.getCurrentPosition(({coords:q})=>{if(Q||B!==V)return;let P={lat:q.latitude,lng:q.longitude,accuracy:Math.round(q.accuracy)};z(P),Z?.map.setView(P,_6)},()=>{if(B===V)K({locating:!1,locateFailed:!0})},{enableHighAccuracy:!0,timeout:c5})},confirm(){if(Y.position)F({status:"completed",result:Y.position})},cancel(){F({status:"cancelled"})},dispose(){Q=!0,Z?.dispose()}}}function c1(_,$,Y){let Q=!1,X;return b_(_,{center:$,zoom:_6,interactive:!1}).then((Z)=>{if(Q){Z.dispose();return}X=Z.dispose,Z.leaflet.marker($).addTo(Z.map)},()=>{if(!Q)Y()}),()=>{Q=!0,X?.()}}function e0(_){if(_>=-180&&_<=180)return _;return((_+180)%360+360)%360-180}function $6(_){if(!_||typeof _!=="object")return!1;let{lat:$,lng:Y}=_;return typeof $==="number"&&typeof Y==="number"&&Math.abs($)<=90&&Math.abs(Y)<=180}function p1(_){let $=_&&typeof _==="object"?_.center:void 0;return $6($)?$:void 0}function d1(_){if(!_||typeof _!=="object")return;let{status:$,result:Y}=_;if($!=="completed"||!$6(Y))return;let{accuracy:Q}=Y;return{...Y,...typeof Q==="number"?{accuracy:Q}:{}}}function s_(_){let $=`${_.lat.toFixed(4)}, ${_.lng.toFixed(4)}`;return _.accuracy?`${$} ±${_.accuracy} m`:$}function l1(_){if(_.locating)return{key:"translate_location_locating",failed:!1};if(_.deliveryFailed)return{key:"translate_location_send_failed",failed:!0};if(_.locateFailed)return{key:"translate_location_locate_failed",failed:!0};if(_.mapFailed)return{key:"translate_location_map_failed",failed:!0};return{key:"translate_location_hint",failed:!1}}function i1(_){return Math.min(1000*2**(_-1),30000)}var p5=1e4;function n1(_){let $,Y,Q=0,X=!1;function Z(){let{wsUrl:J,transport:V}=_.getConfig();if(J===!1)return;let K=d5(J,V.baseUrl);L1(V).then((N)=>{if(X)return;$=new WebSocket(l5(K,N)),$.addEventListener("open",()=>{let z=$;setTimeout(()=>{if($===z&&!X)Q=0},p5),_.onOpen?.()}),$.addEventListener("message",(z)=>{let F=z.data;if(typeof F!=="string")return;let B;try{B=JSON.parse(F)}catch{return}_.onEvent(B)}),$.addEventListener("close",G)}).catch(G)}function G(){if(X||Y)return;Q+=1,Y=setTimeout(()=>{Y=void 0,Z()},i1(Q))}return Z(),{close(){X=!0,clearTimeout(Y),$?.close()}}}function d5(_,$){if(_)return _;let Y=typeof $==="string"?$:$(),Q=new URL(Y,window.location.origin);return Q.protocol=Q.protocol==="https:"?"wss:":"ws:",Q.pathname=Q.pathname.replace(/\/$/,"")+"/ws",Q.toString()}function l5(_,$){let Y=$.Authorization??$.authorization;if(!Y?.startsWith("Bearer "))return _;let Q=new URL(_,window.location.origin);if(Q.searchParams.has("token"))return Q.toString();return Q.searchParams.set("token",Y.slice(7)),Q.toString()}function r1(_,$,Y=i1){let Q=!1,X,Z=0;function G(){_.getCapabilities().then((J)=>{if(!Q)$(J)},()=>{if(Q)return;Z+=1,X=setTimeout(G,Y(Z))})}return G(),function(){Q=!0,clearTimeout(X)}}function t_(_){return[..._].sort(($,Y)=>{let Q=Date.parse(Y.updatedAt)-Date.parse($.updatedAt);if(Q!==0)return Q;return Date.parse(Y.createdAt)-Date.parse($.createdAt)})}function T_(_,$){let Y=[..._],Q=Y.findIndex((X)=>X.id===$.id);if(Q===-1)Y.push($);else Y[Q]={...Y[Q],...$};return t_(Y)}function e_(_,$){return _.filter((Y)=>Y.id!==$)}function a1(_,$){switch($.type){case"thread:deleted":return e_(_,$.payload.threadId);case"thread:created":case"thread:title-updated":case"thread:run-started":case"thread:run-finished":case"thread:messages-updated":return T_(_,$.payload.thread);default:return _}}import{marked as i5}from"marked";import n5 from"dompurify";function v_(_,$=[]){if(!_)return"";let Y=i5.parse(_,{async:!1});if(Y=Y.replace(/<table>/g,'<div style="overflow-x:auto"><table style="width:max-content">').replace(/<\/table>/g,"</table></div>").replace(/<(t[hd])([\s>])/g,'<$1 style="padding:0.5rem 1rem"$2'),$.length)Y=r5(Y,$);return n5.sanitize(Y,{FORBID_TAGS:["img","picture","source"]})}function r5(_,$){let Y=document.createElement("template");Y.innerHTML=_;let Q=[...$].sort((G,J)=>G.length-J.length),X=Q[Q.length-1]?.length??0,Z=0;for(let G of a5(Y.content)){if(Z>=X)break;G.replaceWith(...o5(G.data,Z,Q)),Z+=G.data.length}return Y.innerHTML}function a5(_){let $=document.createTreeWalker(_,4),Y=[];for(let Q=$.nextNode();Q;Q=$.nextNode())if(Q.data.trim())Y.push(Q);return Y.reverse()}function o5(_,$,Y){let Q=[],X=_.length;for(let Z of Y){if(Z.length<=$)continue;if(X<=0)break;let G=Math.min(X,Z.length-$);if(G<X&&/[\uDC00-\uDFFF]/.test(_[X-G]))G+=1;let J=document.createElement("span");J.className="cortex-stream-fade",J.style.animationDelay=`-${Z.age}ms`,J.textContent=_.slice(X-G,X),Q.unshift(J),X-=G,$+=G}if(X>0)Q.unshift(document.createTextNode(_.slice(0,X)));return Q}import{marked as Z6}from"marked";var Y6=/^ {0,3}(`{3,}|~{3,})(.*)$/;function Q6(){let _=null;return($)=>{let Y=Y6.exec($),Q=Y?.[1],X=Y?.[2]??"";if(Q){let Z=Q.charAt(0);if(_){if(Z===_.marker&&Q.length>=_.length&&X.trim()==="")return _=null,"close";return"inside"}if(Z==="`"&&X.includes("`"))return"outside";return _={marker:Z,length:Q.length},"open"}return _?"inside":"outside"}}function X6(_){return Y6.exec(_)?.[2]?.trim().split(/\s+/)[0]??""}var s5=/^\s*!\[([^\]]*)\]\(attachment#([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\)\s*$/i;function o1(_,$){let Y=[],Q=[],X=null;function Z(K=!1){if(Q.length)Y.push(...e5(Q.join(`
|
|
5
|
+
`),K));Q=[]}function G(K){if(X)Y.push({kind:"media",...X,source:X.source.join(`
|
|
6
|
+
`),closed:K});X=null}let J=Q6(),V=_.split(`
|
|
7
|
+
`);for(let[K,N]of V.entries()){let z=J(N);if(X){if(z==="close")G(!0);else X.source.push(N);continue}if(z==="open"&&K===V.length-1)break;let F=t5(N,z,$);if(!F){Q.push(N);continue}if(Z(),F.kind==="media")X={language:F.language,source:[]};else Y.push(F)}return G(!1),Z(!0),Y}function t5(_,$,Y){if($==="open"){let X=X6(_),Z=Y.find((G)=>G===X);return Z?{kind:"media",language:Z}:void 0}let Q=$==="outside"?s5.exec(_):null;return Q?{kind:"attachment",alt:Q[1]??"",id:(Q[2]??"").toLowerCase()}:void 0}function e5(_,$){let Y=Z6.lexer(_);if(!Y.some((N)=>N.type==="table"))return[{kind:"markdown",text:_}];let Q=[];Z6.walkTokens(Y,(N)=>{if(N.type==="def")Q.push(N.raw.trim())});let X=Q.join(`
|
|
8
|
+
`),Z=(N)=>X?`${X}
|
|
9
|
+
|
|
10
|
+
${N}`:N,G=[],J="";function V(){if(J.trim())G.push({kind:"markdown",text:Z(J)});J=""}let K=Y.filter((N)=>N.type!=="def");for(let[N,z]of K.entries()){if(z.type!=="table"){J+=z.raw;continue}V();let F=K.slice(N+1).some((B)=>B.raw.trim()!=="");G.push({kind:"table",text:Z(z.raw.trimEnd()),closed:F||!$})}return V(),G}var _8=/^-?(?:0|[1-9]\d*)(?:\.\d*[1-9])?$/;function $8(_){return _8.test(_)&&_!=="-0"&&_.replace(/[-.]/g,"").replace(/^0/,"").length<=15}var Y8=32767,G6=new TextEncoder;function s1(_){return Array.from(_.rows,($)=>Array.from($.cells,Q8))}function Q8(_){let $=_.cloneNode(!0);if($ instanceof Element)$.querySelectorAll("br").forEach((Y)=>Y.replaceWith(`
|
|
11
|
+
`));return($.textContent??"").trim()}function t1(_){return new Blob([N8(J8(_))],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}function X8(_){return _.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\ufffe\uffff]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/_(x[0-9a-f]{4}_)/gi,"_x005F_$1")}function Z8(_){let $="";for(let Y=_+1;Y>0;Y=Math.floor((Y-1)/26))$=String.fromCharCode(65+(Y-1)%26)+$;return $}function G8(_){return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>${_.map((Y,Q)=>{let X=Y.map((Z,G)=>{let J=`${Z8(G)}${Q+1}`,V=Q===0?' s="1"':"";return Q>0&&$8(Z)?`<c r="${J}"${V}><v>${Z}</v></c>`:`<c r="${J}"${V} t="inlineStr"><is><t xml:space="preserve">${X8(Z.slice(0,Y8))}</t></is></c>`}).join("");return`<row r="${Q+1}">${X}</row>`}).join("")}</sheetData></worksheet>`}function J8(_){return[{name:"[Content_Types].xml",text:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>'},{name:"_rels/.rels",text:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>'},{name:"xl/workbook.xml",text:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="Sheet1" sheetId="1" r:id="rId1"/></sheets></workbook>'},{name:"xl/_rels/workbook.xml.rels",text:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>'},{name:"xl/styles.xml",text:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><fonts count="2"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><name val="Calibri"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border/></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="2"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>'},{name:"xl/worksheets/sheet1.xml",text:G8(_)}]}var V8=Array.from({length:256},(_,$)=>{let Y=$;for(let Q=0;Q<8;Q++)Y=Y&1?3988292384^Y>>>1:Y>>>1;return Y>>>0});function K8(_){let $=4294967295;for(let Y of _)$=(V8[($^Y)&255]??0)^$>>>8;return($^4294967295)>>>0}function N8(_){let $=[],Y=[],Q=0;for(let K of _){let N=G6.encode(K.name),z=G6.encode(K.text),F=K8(z),B=new DataView(new ArrayBuffer(30));B.setUint32(0,67324752,!0),B.setUint16(4,20,!0),B.setUint16(6,2048,!0),B.setUint32(14,F,!0),B.setUint32(18,z.length,!0),B.setUint32(22,z.length,!0),B.setUint16(26,N.length,!0),$.push(new Uint8Array(B.buffer),N,z);let q=new DataView(new ArrayBuffer(46));q.setUint32(0,33639248,!0),q.setUint16(4,20,!0),q.setUint16(6,20,!0),q.setUint16(8,2048,!0),q.setUint32(16,F,!0),q.setUint32(20,z.length,!0),q.setUint32(24,z.length,!0),q.setUint16(28,N.length,!0),q.setUint32(42,Q,!0),Y.push(new Uint8Array(q.buffer),N),Q+=30+N.length+z.length}let X=Y.reduce((K,N)=>K+N.length,0),Z=new DataView(new ArrayBuffer(22));Z.setUint32(0,101010256,!0),Z.setUint16(8,_.length,!0),Z.setUint16(10,_.length,!0),Z.setUint32(12,X,!0),Z.setUint32(16,Q,!0);let G=[...$,...Y,new Uint8Array(Z.buffer)],J=new Uint8Array(G.reduce((K,N)=>K+N.length,0)),V=0;for(let K of G)J.set(K,V),V+=K.length;return J}var K6=new Set(["flatten","fold","density","impute","regression","loess","quantile","sample"]),z8=`Use Vega-Lite JSON with inline \`data.values\` only, at most 200 rows, and no \`url\` anywhere. Compute folds, trend lines and densities yourself. For several series, write one row per series and x value, or keep one row per x value and draw a layer per series (color by \`datum\`) when that would exceed the row limit. These keys are refused anywhere in the spec: ${[...K6,"params","selection"].join(", ")}. Expressions in \`calculate\`, \`filter\` and \`labelExpr\` may use only datum fields, literals, operators and simple math or date-part functions (no format or timeFormat), so put formatted values in the rows or use an axis \`format\`.`;function N6(_,$){if(_==="url")return"Charts may only use inline data and no URLs.";if(_==="sequence"||_==="graticule")return"Charts may only use inline data.";if(K6.has(_))return"Charts may not use transforms that generate rows.";if(_==="params"||_==="selection"||_==="signals"||_==="on")return"Charts may not be interactive.";if(_==="expr")return"Charts may not carry expressions.";if(W8.has(_)&&typeof $==="string"&&!H8($))return"Charts may only use simple expressions over datum.";if(_==="usermeta")return"Charts may not carry usermeta.";if(typeof $==="string"&&_1($))return"Charts may not reference URLs.";if((_==="width"||_==="height")&&D8($)>4000)return"Charts may be at most 4000 pixels wide or tall.";return}var W8=new Set(["calculate","filter","test","signal","labelExpr"]),J6=new Set(["abs","ceil","floor","round","min","max","sqrt","pow","log","exp","year","month","date","day","hours","minutes","toNumber","toString","toDate","isValid","isNaN","if","indexof","length"]);function H8(_){if(_.length>500||/[\\`]/.test(_))return!1;let $=_.replace(/'[^']*'|"[^"]*"/g,'""');for(let[,Q]of $.matchAll(/([A-Za-z_$][\w$]*)\s*\(/g))if(!J6.has(Q??""))return!1;let Y=$.replace(/(datum|parent)(\s*\.[\w$]+|\s*\[\s*""\s*\])+|\b\d[\w.]*/g,"").matchAll(/[A-Za-z_$][\w$]*/g);for(let[Q]of Y)if(!J6.has(Q)&&!["true","false","null"].includes(Q))return!1;return!0}function D8(_){if(typeof _==="number")return _;let $=_?.step;return typeof $==="number"?$:0}function V6(_,$){let Y=_?.features,Q=Array.isArray(_)?_.length:Array.isArray(Y)?Y.length:-1;if(Q<0)return N6($,_)??_0(e1(_,$),f_);return Q>200?"Charts may hold at most 200 rows.":void 0}function f_(_,$=""){if($==="values")return V6(_,$);if($==="datasets")return _0(e1(_),V6);return N6($,_)??_0(e1(_,$),(Y,Q)=>f_(Y,Q))}function e1(_,$=""){if(Array.isArray(_))return _.map((Y)=>[$,Y]);return _&&typeof _==="object"?Object.entries(_):[]}function _0(_,$){for(let[Y,Q]of _){let X=$(Q,Y);if(X)return X}return}var z6=/url\(([^)]*)\)/gi,$0="src|image|image-set|-webkit-image-set|cross-fade|element",Y0=new RegExp(String.raw`\b(url|${$0})\(`,"i"),B8=new RegExp(String.raw`\b(${$0})\(`,"i"),q8=new RegExp(String.raw`\b(${$0})\([^)]*\)`,"gi"),F8=/\\([0-9a-f]{1,6})\s?|\\(.)/gi,U8=/@import[^;]*;?/gi;function L8(_){return _.replace(F8,($,Y,Q)=>{if(!Y)return Q??"";let X=parseInt(Y,16),Z=X===0||X>=55296&&X<=57343||X>1114111;return String.fromCodePoint(Z?65533:X)})}function W6(_){return _.trim().replace(/^(['"])(.*)\1$/s,"$2").trim()}function _1(_){if(_.includes("\\")||B8.test(_))return!0;for(let[,$]of _.matchAll(z6))if(!W6($??"").startsWith("#"))return!0;return!1}function Q0(_){return L8(_).replaceAll("\\"," ").replace(U8," ").replace(q8,"none").replace(z6,($,Y)=>W6(Y).startsWith("#")?$:"none")}var P8=new Set(["src","srcset","poster","background","action","formaction","ping"]);function j_(_){for(let $ of[_,..._.querySelectorAll("*")]){for(let Y of[...$.attributes])if(P8.has(Y.name)||(Y.name==="href"||Y.name==="xlink:href")&&$.localName!=="a"&&!Y.value.trim().startsWith("#")||_1(Y.value))$.removeAttribute(Y.name);if($.localName==="style"&&$.textContent)$.textContent=Q0($.textContent)}}var O8=`
|
|
12
|
+
@layer {
|
|
13
|
+
:host {
|
|
14
|
+
display: block !important;
|
|
15
|
+
position: relative !important;
|
|
16
|
+
contain: paint !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
*,
|
|
20
|
+
*::before,
|
|
21
|
+
*::after {
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
animation: none !important;
|
|
24
|
+
transition: none !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.cortex-report {
|
|
28
|
+
container-type: inline-size;
|
|
29
|
+
overflow-x: auto;
|
|
30
|
+
overflow-wrap: break-word;
|
|
31
|
+
font-size: var(--cortex-font-size-message, var(--cortex-font-size));
|
|
32
|
+
line-height: 1.625;
|
|
33
|
+
color: var(--cortex-color-text-strong);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* The report's own stylesheet comes first, so its first block is the first that is not a style. */
|
|
37
|
+
.cortex-report > :nth-child(1 of :not(style)) {
|
|
38
|
+
margin-top: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.cortex-report > :nth-last-child(1 of :not(style)) {
|
|
42
|
+
margin-bottom: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
h1,
|
|
46
|
+
h2,
|
|
47
|
+
h3,
|
|
48
|
+
h4,
|
|
49
|
+
h5,
|
|
50
|
+
h6 {
|
|
51
|
+
margin: 1.5em 0 0.5em;
|
|
52
|
+
font-family: var(--cortex-font-display, inherit);
|
|
53
|
+
font-size: 1em;
|
|
54
|
+
font-weight: 600;
|
|
55
|
+
line-height: 1.3;
|
|
56
|
+
color: var(--cortex-color-text-heading);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
h1 {
|
|
60
|
+
font-size: 1.5em;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
h2 {
|
|
64
|
+
font-size: 1.2em;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
p,
|
|
68
|
+
ul,
|
|
69
|
+
ol,
|
|
70
|
+
dl,
|
|
71
|
+
blockquote,
|
|
72
|
+
pre,
|
|
73
|
+
table {
|
|
74
|
+
margin: 0.75em 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
ul,
|
|
78
|
+
ol {
|
|
79
|
+
padding-inline-start: 1.5em;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
li + li {
|
|
83
|
+
margin-top: 0.25em;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
blockquote {
|
|
87
|
+
padding-inline-start: 1em;
|
|
88
|
+
border-inline-start: 3px solid var(--cortex-color-border-strong);
|
|
89
|
+
color: var(--cortex-color-text-secondary);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
code {
|
|
93
|
+
font-family: var(--cortex-font-mono);
|
|
94
|
+
font-size: 0.875em;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
pre {
|
|
98
|
+
padding: 0.75em 1em;
|
|
99
|
+
overflow-x: auto;
|
|
100
|
+
background: var(--cortex-color-code-surface);
|
|
101
|
+
border-radius: var(--cortex-radius);
|
|
102
|
+
color: var(--cortex-color-code-text);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
hr {
|
|
106
|
+
margin: 1.5em 0;
|
|
107
|
+
border: 0;
|
|
108
|
+
border-top: 1px solid var(--cortex-color-border);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
table {
|
|
112
|
+
width: 100%;
|
|
113
|
+
border-collapse: collapse;
|
|
114
|
+
font-variant-numeric: tabular-nums;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
caption {
|
|
118
|
+
padding-bottom: 0.5em;
|
|
119
|
+
text-align: start;
|
|
120
|
+
color: var(--cortex-color-text-secondary);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
th,
|
|
124
|
+
td {
|
|
125
|
+
padding: 0.5em 0.75em;
|
|
126
|
+
border-bottom: 1px solid var(--cortex-color-border);
|
|
127
|
+
text-align: start;
|
|
128
|
+
vertical-align: top;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
th {
|
|
132
|
+
font-weight: 600;
|
|
133
|
+
color: var(--cortex-color-text-heading);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
thead th {
|
|
137
|
+
border-bottom-color: var(--cortex-color-border-strong);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
:is(th, td):first-child {
|
|
141
|
+
padding-inline-start: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
:is(th, td):last-child {
|
|
145
|
+
padding-inline-end: 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
tbody tr:last-child > * {
|
|
149
|
+
border-bottom: 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
tfoot > tr:first-child > * {
|
|
153
|
+
border-top: 1px solid var(--cortex-color-border-strong);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
figure {
|
|
157
|
+
min-width: 0;
|
|
158
|
+
margin: 1em 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.cortex-report-chart-failed {
|
|
162
|
+
margin: 0;
|
|
163
|
+
font-size: 0.875em;
|
|
164
|
+
color: var(--cortex-color-text-muted);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
figcaption {
|
|
168
|
+
margin-top: 0.5em;
|
|
169
|
+
font-size: 0.875em;
|
|
170
|
+
color: var(--cortex-color-text-secondary);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* As in the chat: chart labels are placed for left-to-right text, and each
|
|
174
|
+
takes its own reading order from its first strong character. */
|
|
175
|
+
svg {
|
|
176
|
+
max-width: 100%;
|
|
177
|
+
height: auto;
|
|
178
|
+
direction: ltr;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
svg text {
|
|
182
|
+
unicode-bidi: plaintext;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
figure[data-chart] svg {
|
|
186
|
+
display: block;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
`,M8=/(["'])(?:(?!\1)[^\n\r\f])*\1?|\/\*[\s\S]*?(?:\*\/|$)/g;function A8(_){return/:host|@(-[a-z]+-)?keyframes|@property/i.test(H6(_))}function H6(_){return _.replace(M8,($)=>$.startsWith("/*")?"":$)}async function D6(_){let{default:$}=await import("dompurify"),Y=$.sanitize(_,{FORCE_BODY:!0,RETURN_DOM_FRAGMENT:!0,USE_PROFILES:{html:!0,svg:!0,svgFilters:!0},FORBID_TAGS:["img","picture","source","video","audio","track","a","area","form","input","button","select","textarea","dialog","template","slot","marquee","animatecolor","animatemotion","animatetransform","image","feimage"],FORBID_ATTR:["popover","popovertarget","popovertargetaction"]}),Q=Y.ownerDocument.createElement("div");Q.append(Y);for(let X of Q.querySelectorAll("[style]"))k8(X);j_(Q);for(let X of Q.querySelectorAll("style"))if(A8(X.textContent??""))X.remove();return Q}var E8=/^(-[a-z]+-)?(animation|transition)/i;function k8(_){let $=H6(_.getAttribute("style")??"").split(";");_.setAttribute("style",$.filter((Y)=>!E8.test(Y.trim())).join(";"))}function B6(_,$,Y,Q){let X=document.createElement("style");X.textContent=O8,$.className="cortex-report",_.attachShadow({mode:"open"}).append(X,$);let Z=[...$.querySelectorAll("figure[data-chart]")].map((G)=>{let{box:J,spec:V}=R8(G);return Y(J,V,()=>{let K=document.createElement("p");K.className="cortex-report-chart-failed",K.textContent=Q,J.append(K)})});return()=>{for(let G of Z)G()}}function R8(_){let $=[..._.childNodes].filter((X)=>X.nodeName!=="FIGCAPTION"),Y=document.createElement("div");_.insertBefore(Y,$.find((X)=>X.textContent?.trim())??null);for(let X of $)X.remove();let Q=$.map((X)=>X.textContent).join("");return{box:Y,spec:I8.exec(Q)?.[2]??Q}}var I8=/^\s*(`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n\s*\1\s*$/;var P6={async mermaid(_,$,{scheme:Y}){let[{default:Q},{default:X}]=await Promise.all([import("mermaid"),import("dompurify")]);if(Y0.test($)||$.includes("\\"))throw Error("Diagrams may not reference URLs.");if(/%%\{/.test($))throw Error("Diagrams may not carry init directives.");if(/^\s*---\s*$/m.test($))throw Error("Diagrams may not carry frontmatter.");if(/\bimg\s*:/.test($))throw Error("Diagrams may not embed images.");let Z=S8($);if(!C8.test(Z))throw Error(`Unsupported diagram type: ${Z}`);let G=q6.then(async()=>{if(!F6)Q.initialize({startOnLoad:!1,securityLevel:"strict",htmlLabels:!1}),F6=!0;let K=`%%{init: {"theme": "${Y==="dark"?"dark":"default"}"}}%%
|
|
190
|
+
${$}`;return await Q.parse(K),(await Q.render(`cortex-mermaid-${f8()}`,K,_)).svg});q6=G.catch(()=>{return});let J=await G,V=document.createElement("div");return V.innerHTML=X.sanitize(J,{USE_PROFILES:{svg:!0,svgFilters:!0}}),j_(V),_.replaceChildren(...V.childNodes),()=>{_.innerHTML=""}},async "vega-lite"(_,$,{scheme:Y}){let Q=JSON.parse($),X=f_(Q);if(X)throw Error(X);if(!Q||typeof Q!=="object"||Array.isArray(Q))throw Error("A chart needs a JSON object.");let Z=Q,[{default:G},J]=await Promise.all([import("vega-embed"),import("vega")]),V=()=>Promise.reject(Error("Charts may only use inline data."));async function K(H){let D=document.createElement("div"),W=await G(D,T8(Z,H),{actions:!1,renderer:"svg",mode:"vega-lite",loader:{...J.loader(),load:V,sanitize:V},ast:!0,...Y==="dark"?{theme:"dark"}:{},config:{background:"transparent"}});return j_(D),{drawing:D,result:W,width:H}}let N=await K(_.clientWidth);_.replaceChildren(N.drawing);let z=!1,F,B=0;function q(){F??=(async()=>{let H=_.clientWidth;while(!z&&H>0&&H!==N.width&&H!==B){try{let D=await K(H);if(z){D.result.finalize();return}N.result.finalize(),N=D,_.replaceChildren(D.drawing)}catch{B=H}H=_.clientWidth}})().finally(()=>{F=void 0})}let P=new ResizeObserver(q);if(O6(Z))P.observe(_);function O(){let H=document.getElementById(v8),D=M6(_)??document.body;if(H&&H.parentElement!==D)D.append(H)}return _.addEventListener("pointermove",O),()=>{z=!0,P.disconnect(),_.removeEventListener("pointermove",O),N.result.finalize()}},async map(_,$){let Y=j8(JSON.parse($)),{leaflet:Q,map:X,dispose:Z}=await b_(_,{...Y,interactive:!0});for(let G of Y.markers){let J=Q.marker(G.position).addTo(X);if(G.label){let V=document.createElement("span");V.textContent=G.label,J.bindTooltip(V)}}return Z},async report(_,$,Y){let Q=await D6($);return B6(_,Q,(X,Z,G)=>Y1(X,{language:"vega-lite",source:Z,context:Y,overrides:void 0,onError:G}),n(Y.locale,"translate_media_failed"))}},y8={mermaid:{title:"translate_media_mermaid",pending:"translate_media_pending_mermaid"},"vega-lite":{title:"translate_media_vega_lite",pending:"translate_media_pending_vega_lite"},map:{title:"translate_media_map",pending:"translate_media_pending_map"},report:{title:"translate_media_report",pending:"translate_media_pending_report"}};function $1(_){return y8[_]??{title:"translate_media",pending:"translate_media_pending"}}function Z0(_){return Object.keys({...P6,..._})}function Y1(_,$){let{language:Y,source:Q,context:X,overrides:Z,onError:G}=$,J=_.appendChild(document.createElement("div")),V=Z?.[Y]??P6[Y],K,N=!1;return(V?V(J,Q,X):Promise.reject(Error(`No renderer for ${Y}.`))).then((F)=>{if(N)F();else K=F},(F)=>{if(!N)G(F instanceof Error?F.message:String(F))}),()=>{N=!0,K?.(),J.remove()}}var C8=/^(flowchart|graph|sequenceDiagram|stateDiagram(-v2)?|erDiagram|gantt|pie|classDiagram|journey|timeline|mindmap)$/;function S8(_){let $=_.split(`
|
|
191
|
+
`).find((Y)=>/\S/.test(Y)&&!/^\s*%%/.test(Y));return/^\s*(\S+)/.exec($??"")?.[1]??""}function X0(_){return _===void 0||_==="container"}var w8=["row","column","facet"];function O6(_){let $=_.encoding,Y=typeof $==="object"&&$!==null&&w8.some((Q)=>(Q in $));return(("mark"in _)||("layer"in _))&&X0(_.width)&&!Y}function b8(_){let $={..._};if(X0($.width))delete $.width;if(X0($.height))delete $.height;return $}function T8(_,$){let Y=b8(_);if($<=0||!O6(_))return Y;return{...Y,width:$,height:Y.height??Math.round(Math.min(480,Math.max(200,$/2))),autosize:Y.autosize??{type:"fit",contains:"padding"}}}var v8="vg-tooltip-element";function M6(_){let $=_.getRootNode();return _.closest("dialog")??($ instanceof ShadowRoot?M6($.host):null)}var q6=Promise.resolve(),F6=!1,U6=0;function f8(){return U6+=1,U6}function j8(_){if(!_||typeof _!=="object")throw Error("A map needs a JSON object.");let $=_,Y=$.zoom??10;if(typeof Y!=="number"||Y<0||Y>22)throw Error("zoom must be 0 to 22.");let Q=$.markers??[];if(!Array.isArray(Q))throw Error("markers must be a list.");return{center:L6($.center,"center"),zoom:Y,markers:Q.map((X,Z)=>{let G=X??{},J=G.label;return{position:L6(G.position,`markers[${Z}].position`),label:typeof J==="string"?J:void 0}})}}function L6(_,$){let Y=Array.isArray(_)?_:[],[Q,X]=Y;if(typeof Q!=="number"||typeof X!=="number"||Math.abs(Q)>90||Math.abs(X)>180)throw Error(`${$} must be [latitude, longitude].`);return{lat:Q,lng:X}}function G0(_,$){if(_!=="system")return $(_??"light"),()=>{};let Y=window.matchMedia("(prefers-color-scheme: dark)"),Q=()=>$(Y.matches?"dark":"light");return Q(),Y.addEventListener("change",Q),()=>Y.removeEventListener("change",Q)}import g_ from"highlight.js/lib/core";import g8 from"highlight.js/lib/languages/javascript";import m8 from"highlight.js/lib/languages/json";import x8 from"highlight.js/lib/languages/sql";var A6=!1;function h8(){if(A6)return;A6=!0,g_.registerLanguage("javascript",g8),g_.registerLanguage("json",m8),g_.registerLanguage("cypher",x8)}function J0(_,$){if(!_)return"";return h8(),g_.getLanguage($)?g_.highlight(_,{language:$}).value:u8(_)}function u8(_){return _.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function U_(_){if(typeof _==="string"){let $=_.trim();if(!($.startsWith("{")&&$.endsWith("}")||$.startsWith("[")&&$.endsWith("]")))return _;try{return U_(JSON.parse($))}catch{return _}}if(Array.isArray(_))return _.map(($)=>U_($));if(_!==null&&typeof _==="object"){let $={};for(let[Y,Q]of Object.entries(_))$[Y]=U_(Q);return $}return _}function V0(_,$){if(Array.isArray(_)){let Y=_;return{kind:"container",open:"[",close:"]",summary:E6(Y.length,"item","items"),entries:Y.map((Q,X)=>({key:null,value:Q,path:`${$}[${X}]`}))}}if(_!==null&&typeof _==="object"){let Y=Object.entries(_);return{kind:"container",open:"{",close:"}",summary:E6(Y.length,"property","properties"),entries:Y.map(([Q,X])=>({key:Q,value:X,path:`${$}.${Q}`}))}}return{kind:"primitive",text:c8(_),className:p8(_)}}function E6(_,$,Y){return`${_} ${_===1?$:Y}`}function c8(_){if(_===null||_===void 0)return"null";if(typeof _==="string")return JSON.stringify(_);if(typeof _==="number"||typeof _==="boolean")return String(_);return JSON.stringify(_)??"null"}function p8(_){if(_===null||_===void 0)return"cortex-json-tree__null";if(typeof _==="string")return"cortex-json-tree__string";if(typeof _==="number")return"cortex-json-tree__number";if(typeof _==="boolean")return"cortex-json-tree__boolean";return""}function K0(_){if(!_)return null;try{return JSON.parse(_)}catch{return _}}function N0(_){if(!_)return"";try{return JSON.stringify(JSON.parse(_),null,2)}catch{return _}}function a(_,$,Y=Date.now()){let Q=new Date(_);if(Number.isNaN(Q.getTime()))return"";let X=Q.toDateString()===new Date(Y).toDateString();return new Intl.DateTimeFormat($,{...X?{}:{dateStyle:"medium"},timeStyle:"short"}).format(Q)}function m_(_,$){let Y=URL.createObjectURL(_),Q=document.createElement("a");Q.href=Y,Q.download=$,document.body.append(Q),Q.click(),Q.remove(),setTimeout(()=>URL.revokeObjectURL(Y),40000)}class Y_{onUpdate;fullText="";displayedLength=0;animationFrameId=null;isDone=!1;releases=[];static DRAIN_FRACTION=0.03;static MIN_CHARS_PER_FRAME=1;static DONE_DRAIN_FRACTION=0.1;static FADE_WINDOW_MS=500;constructor(_){this.onUpdate=_}seed(_){this.fullText=_,this.displayedLength=_.length,this.releases=[],this.onUpdate(_,[])}update(_,$){if(this.fullText=_,this.isDone=$,this.displayedLength=Math.min(this.displayedLength,this.fullText.length),this.releases=this.releases.filter((Y)=>Y.from<this.displayedLength),$&&this.displayedLength>=this.fullText.length){this.onUpdate(this.fullText,[]),this.stopAnimation();return}if(!this.animationFrameId)this.scheduleFrame()}destroy(){this.stopAnimation()}scheduleFrame(){this.animationFrameId=requestAnimationFrame((_)=>this.tick(_))}tick(_){let $=this.fullText.length-this.displayedLength;if($<=0){this.animationFrameId=null;return}let Y=this.isDone?Y_.DONE_DRAIN_FRACTION:Y_.DRAIN_FRACTION,Q=Math.max(Y_.MIN_CHARS_PER_FRAME,Math.ceil($*Y));if(this.releases=this.releases.filter((X)=>_-X.at<Y_.FADE_WINDOW_MS),this.releases.push({from:this.displayedLength,at:_}),this.displayedLength=Math.min(this.fullText.length,this.displayedLength+Q),this.onUpdate(this.fullText.substring(0,this.displayedLength),this.releases.map((X)=>({length:this.displayedLength-X.from,age:_-X.at}))),this.displayedLength<this.fullText.length)this.scheduleFrame();else this.animationFrameId=null}stopAnimation(){if(this.animationFrameId)cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null}}var z0=new WeakMap;function W0(_,$){let Y=_.closest(".cortex-widget__screen"),Q=Y?.querySelector(".cortex-message-list");if(!Y||!Q||!_.value.trim())return;let X=getComputedStyle(_),Z=_.getBoundingClientRect(),G=(J)=>parseFloat(X[`padding${J}`])+parseFloat(X[`border${J}Width`]);z0.set(Y,{text:$,textarea:_,from:new DOMRect(Z.left+G("Left"),Z.top+G("Top"),Z.width-G("Left")-G("Right"),Z.height-G("Top")-G("Bottom")),rtl:X.direction==="rtl",scrollTop:Q.scrollTop})}function H0(_,$){let Y=_.closest(".cortex-widget__screen"),Q=Y?z0.get(Y):void 0;if(!Y||!Q)return;z0.delete(Y);let X=_.querySelectorAll(":scope > .cortex-message"),Z=X[X.length-1]?.querySelector(".cortex-text-bubble--user"),G=_.closest(".cortex-message-list");if(!Z||!G||Q.text!==$||!Q.textarea.isConnected)return;Z.closest(".cortex-message-part")?.getAnimations().forEach((H)=>H.finish()),Q1(G);let J=Z.getBoundingClientRect(),V=Y.getBoundingClientRect(),K=getComputedStyle(Z),N=parseFloat(K.paddingTop)+parseFloat(K.borderTopWidth),z=Q.rtl?parseFloat(K.paddingRight)+parseFloat(K.borderRightWidth):parseFloat(K.paddingLeft)+parseFloat(K.borderLeftWidth),F=Q.rtl?Q.from.right+z-J.width:Q.from.left-z,B=G.scrollTop-Q.scrollTop;if(B)_.style.setProperty("--cortex-slide",`${B}px`),_.classList.remove("cortex-message-list__content--settling"),_.offsetWidth,_.classList.add("cortex-message-list__content--settling"),_.getAnimations()[0]?.finished.then(()=>_.classList.remove("cortex-message-list__content--settling"),()=>{return});let q=Z.cloneNode(!0);q.classList.add("cortex-send-flight"),q.setAttribute("aria-hidden","true"),Object.assign(q.style,{left:`${J.left-V.left}px`,top:`${J.top-V.top}px`,width:`${J.width}px`}),q.style.setProperty("--cortex-fly-x",`${F-J.left}px`),q.style.setProperty("--cortex-fly-y",`${Q.from.top-N-J.top}px`),Z.style.visibility="hidden",Y.append(q);let P=G.scrollTop,O=()=>{q.style.top=`${J.top-V.top-(G.scrollTop-P)}px`};G.addEventListener("scroll",O,{passive:!0}),I6(q).then(()=>{G.removeEventListener("scroll",O),Z.style.visibility="",q.remove()})}function Q1(_){_.scrollTop=R6(_)}function D0(_){return R6(_)-_.scrollTop}function R6(_){let $=_.querySelector(".cortex-message-list__content");if(!$)return _.scrollHeight-_.clientHeight;let Y=getComputedStyle(_);return $.offsetHeight+parseFloat(Y.paddingTop)+parseFloat(Y.paddingBottom)-_.clientHeight}function B0(_){let $=!1,Y=_.parentElement,Q=typeof ResizeObserver>"u"?void 0:new ResizeObserver(X);Q?.observe(Y);function X(){let Z=Y.querySelector(":scope > .cortex-working-thinking, :scope > .cortex-message > .cortex-message-parts > [data-cortex-frontier]");if(!Z)return!1;return _.style.setProperty("--cortex-avatar-y",`${d8(Z,Y)-_.offsetHeight/2}px`),!0}return{sync(Z){if(Z===$){if(Z)X();return}if(Z){if(!X())return;_.classList.remove("cortex-working-avatar--leaving"),_.offsetWidth,_.classList.add("cortex-working-avatar--shown"),$=!0;return}$=!1,_.classList.add("cortex-working-avatar--leaving"),I6(_,!0).then(()=>{if($)return;_.classList.remove("cortex-working-avatar--shown","cortex-working-avatar--leaving")})},dispose(){Q?.disconnect()}}}function d8(_,$){let Y=_.querySelector(".cortex-text-bubble");if(!Y)return k6(_,$)+_.offsetHeight/2;let Q=getComputedStyle(Y);return k6(Y,$)+parseFloat(Q.paddingTop)+parseFloat(Q.borderTopWidth)+parseFloat(Q.lineHeight)/2}function k6(_,$){let Y=0;for(let Q=_;Q instanceof HTMLElement&&Q!==$;)Y+=Q.offsetTop,Q=Q.offsetParent;return Y}function I6(_,$=!1){return Promise.allSettled(_.getAnimations({subtree:$}).map((Y)=>Y.finished))}var l8=2;function q0(_){let $=!1,Y=!1,Q=!1,X=!1,Z=!1,G=!1,J,V=new Set,K=0,N=!1;function z(){if($&&K===0)return!1;if(K+=1,!$)$=!0,_.setRunning(!0);return!0}function F(H){if(K-=1,H)N=!0;else if(K===0&&!N)$=!1,_.setRunning(!1)}async function B(H,D){for(let W=0;W<l8;W+=1){let M=await _.refreshMessages().catch(()=>{return});if(!_.isAlive())return!1;if(!M)continue;if(!$_(M).some((k)=>k.id===H.id))return!0;if(await _.deliver(D).then(()=>!0,()=>!1))return!0}return!1}async function q(H,D){let W;try{let i=D({toolCallId:H.id,toolName:H.name,input:H.input},{threadId:_.threadId});if(i===null||i===void 0)return;W=await Promise.resolve(i)}catch{V.delete(H.id);return}if(W===null||W===void 0)return;if(!_.isAlive())return;let M=z(),A={toolCallId:H.id,tool:H.name,output:W},k=await _.deliver(A).then(()=>!0,()=>B(H,A));if(M)F(k);if(!k)V.delete(H.id)}function P(H){let D=$_(H),W=_.onToolCall();if(!W)return D.length>0;for(let M of D){if(M.state!=="input-complete"||V.has(M.id))continue;V.add(M.id),q(M,W)}return D.length>0}async function O(H){let D=X;if(X=!1,!D&&$){if(P(H()))return;if(Q)_.reloadThreads().catch(()=>{});else _.setRunning(!1)}if(J===void 0&&(G||D))return;J=void 0;let W=await _.refreshMessages();if(!D&&$&&W)P(W)}return{chunkArrived(){Y=!0},transcriptCarried(H){if(G=!0,J!==void 0&&J<=H)J=void 0},transcriptUpdated(H){if(!Z){_.refreshMessages();return}J=Math.max(J??0,Date.parse(H))},streamFailed(){if(Q=!0,Y)_.onTurnFinished();else _.onSendFailed()},loadingChanged(H,D){if(H){Z=!0,Q=!1,G=!1;return}if(!Z)return;Z=!1,_.onTurnFinished(),O(D)},hydrated(H,D){if(D)return;setTimeout(()=>{if(_.isAlive())P(H)},0)},sendStarted(){_.setRunning(!0),$=!0,Y=!1},abortConfirmed(){X=!0,_.setRunning(!1)}}}function x_(_){if(_.input.total<=0)return null;return Math.round(_.input.cacheRead/_.input.total*100)}import{createContext as y6,useContext as C6}from"react";var F0=y6(void 0);function L(){let _=C6(F0);if(!_)throw Error("useCortex must be used inside <CortexChatWidget>");return _}var U0={messages:[],isAgentWorking:!1,isLoadingMessages:!1,hasPendingToolCalls:!1},L0=y6(U0);function L_(){return C6(L0)}import{useEffect as i8,useState as n8}from"react";function S6(_,$){let[Y,Q]=n8();return i8(()=>{return Q(void 0),r1(_,Q)},[_,$]),Y}import{useRef as $4}from"react";import{useRef as r8,useState as a8,useSyncExternalStore as o8}from"react";function w6(_,$){let Y=r8($);Y.current=$;let[Q]=a8(()=>v1({api:_,ensureThread:()=>Y.current()})),X=o8(Q.subscribe,Q.getState,Q.getState);return{store:Q,value:{items:X,...f1(X),accept:Q.accept,remove:Q.remove,consumeReady:Q.consumeReady}}}import{useEffect as s8,useRef as t8}from"react";function b6(_,$){let Y=t8(void 0);s8(()=>{if($===Y.current)return;_.clear(Y.current),Y.current=$},[$,_])}import{useRef as T6}from"react";function v6(_){let $=T6([]),Y=T6(void 0);function Q(){let Z=_.selectedRef.current;if(Z)return Promise.resolve(Z.id);return Y.current??=_.api.createThread().then((G)=>{return Y.current=void 0,_.onCreated(G),G.id},(G)=>{throw Y.current=void 0,G}),Y.current}async function X(Z,G=[]){let J=_.sessionRef.current;if(J){await J.send(Z,G);return}$.current.push({prompt:Z,attachments:G});try{await Q()}catch(V){throw $.current=[],V}}return{ensureThread:Q,send:X,pendingSendRef:$}}import{useRef as e8,useState as _4}from"react";function f6(_){let[$,Y]=_4(),Q=$?.thread,X=Q?_.threads?.find((K)=>K.id===Q.id)??Q:void 0,Z=e8(X);Z.current=X;function G(K,N){if(Z.current?.id===K.id&&_.hasSession())return;let z=Z.current;if(Z.current=K,Y({thread:K,mode:N,epoch:0}),z&&z.id!==K.id)_.getHooks()?.onThreadDeselected?.(z);_.getHooks()?.onThreadSelected?.(K)}function J(){let K=Z.current;if(!K&&!_.hasSession())return;if(Z.current=void 0,Y(void 0),K)_.getHooks()?.onThreadDeselected?.(K)}function V(K,N){Y((z)=>({thread:K,mode:"reload",epoch:(z?.epoch??0)+1,initialMessages:N}))}return{session:$,selected:X,selectedRef:Z,select:G,deselect:J,remount:V}}function j6(_){let{api:$,threads:Y}=_,Q=$4(void 0),X=f6({threads:Y.threads,getHooks:_.getHooks,hasSession:()=>Q.current!==void 0}),Z=v6({api:$,sessionRef:Q,selectedRef:X.selectedRef,onCreated:(K)=>{Y.upsert(K),X.select(K,"skip")}}),G=w6($,Z.ensureThread);b6(G.store,X.selected?.id);async function J(K){if(X.selectedRef.current?.id===K)X.deselect();await Y.remove(K)}function V(K){X.select(K,"load")}return{sessionRef:Q,selection:X,queue:G,deleteThread:J,openThread:V,...Z}}import{useEffect as Y4,useRef as Q4}from"react";function g6(_){let $=Q4(_);$.current=_,Y4(()=>{$.current.onMount();let Y=!1,Q=n1({getConfig:()=>$.current.getConfig(),onEvent:(X)=>$.current.onEvent(X),onOpen:()=>{if(Y)$.current.onReconnect();Y=!0}});return()=>Q.close()},[])}function m6(_){let{threads:$,selectedRef:Y,sessionRef:Q}=_;function X(G){$.applyEvent(G);let J=Y.current?.id;switch(G.type){case"thread:deleted":if(J===G.payload.threadId)_.deselect();break;case"thread:run-started":if(J===G.payload.thread.id)Q.current?.reattach(G.payload.thread);break;case"thread:messages-updated":Q.current?.transcriptUpdated(G.payload.thread.id,G.payload.thread.updatedAt);break}}function Z(){_.onReconnect(),$.reload().then((G)=>{let J=Y.current;if(!J)return;Q.current?.reattach(G.find((V)=>V.id===J.id)??J)})}return{onEvent:X,onReconnect:Z}}function x6(_){return{abort:async()=>{await _.current?.abort()},addToolResult:($,Y,Q)=>_.current?.addToolResult($,Y,Q)??Promise.resolve(),respondToApproval:($,Y)=>_.current?.respondToApproval($,Y)??Promise.resolve()}}import{useState as X4}from"react";function h6(_){let[$,Y]=X4();async function Q(){let V=t_(await _.listThreads());return Y(V),V}function X(V){Y((K)=>T_(K??[],V))}function Z(V,K){Y((N)=>{let z=N?.find((F)=>F.id===V);return z?T_(N??[],{...z,isRunning:K}):N})}async function G(V){await _.deleteThread(V),Y((K)=>K?e_(K,V):K)}function J(V){Y((K)=>{let N=a1(K??[],V);return K||N.length?N:K})}return{threads:$,reload:Q,upsert:X,setRunning:Z,remove:G,applyEvent:J}}import{useState as u6}from"react";function c6(_){let[$,Y]=u6("chat"),[Q,X]=u6(!1);return{screen:$,sidebarOpen:Q,showChat:()=>{Y("chat"),X(!1)},openHistory:()=>_==="full"?X(!0):Y("threads"),closeHistory:()=>_==="full"?X(!1):Y("chat"),closeSidebar:()=>X(!1)}}import{forwardRef as z4,useEffect as W4,useImperativeHandle as H4,useRef as r6,useState as D4}from"react";function U(..._){return _.filter(Boolean).join(" ")}import{useState as Z4}from"react";function p6(_,$){let[Y,Q]=Z4(!1);return{dragging:Y,onDragOver:(X)=>{if(X.preventDefault(),_)Q(!0)},onDragLeave:(X)=>{if(!X.currentTarget.contains(X.relatedTarget))Q(!1)},onDrop:(X)=>{if(X.preventDefault(),Q(!1),_)$([...X.dataTransfer.files])},onPaste:(X)=>{let Z=X.clipboardData.files;if(!_||!Z.length)return;X.preventDefault(),$([...Z])}}}var w={bubble:"M13.5 7.6c0 2.4-2.5 4.4-5.5 4.4-.6 0-1.2-.08-1.7-.23L3 13l.8-2.3C3 9.8 2.5 8.7 2.5 7.6 2.5 5.2 5 3.2 8 3.2s5.5 2 5.5 4.4Z",chevronDown:"M3 4.5L6 7.5L9 4.5",chevronDownLarge:"m5.75 8.25 4.25 4.25 4.25-4.25",file:["M4 1.5h5.172a2 2 0 0 1 1.414.586l2.328 2.328a2 2 0 0 1 .586 1.414V12.5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2Z","M9.5 1.5v2a2 2 0 0 0 2 2h2"]};import{jsx as o,jsxs as P0}from"react/jsx-runtime";function d6(){let{queue:_,t:$}=L();if(!_.items.length)return null;return o("div",{className:"cortex-attachment-queue",children:_.items.map((Y)=>P0("div",{className:U("cortex-attachment-chip",Y.status==="error"&&"cortex-attachment-chip--error"),title:Y.status==="error"?$("translate_attachment_rejected"):"",children:[Y.status==="uploading"||Y.status==="deleting"?P0("svg",{className:"cortex-attachment-chip__spinner",viewBox:"0 0 16 16",fill:"none",children:[o("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",className:"cortex-attachment-chip__spinner-track"}),o("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}):P0("svg",{viewBox:"0 0 16 16",className:"cortex-attachment-chip__icon",fill:"none",children:[o("path",{d:w.file[0],stroke:"currentColor",strokeWidth:"1.25"}),o("path",{d:w.file[1],stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]}),o("span",{className:"cortex-attachment-chip__name",children:Y.filename}),o("button",{type:"button",onClick:()=>_.remove(Y.localId),className:"cortex-attachment-chip__remove",disabled:Y.status==="deleting","aria-label":$("translate_remove_attachment"),children:o("svg",{viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M4.5 4.5l7 7m0-7l-7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]},Y.localId))})}import{useRef as G4}from"react";import{jsx as J_,jsxs as l6,Fragment as V4}from"react/jsx-runtime";var J4=q1.join(",");function i6({attachmentsEnabled:_,canSend:$,onSend:Y}){let{t:Q,queue:X}=L(),Z=G4(null);return l6("div",{className:"cortex-widget__input-actions",children:[_&&l6(V4,{children:[J_("button",{type:"button",onClick:()=>Z.current?.click(),className:"cortex-widget__attach-btn","aria-label":Q("translate_attach_files"),children:J_("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:J_("path",{d:"M10.5 5.5 6.2 9.8a1.4 1.4 0 0 0 2 2l4.6-4.6a2.8 2.8 0 0 0-4-4L4.2 7.8a4.2 4.2 0 0 0 6 6l4-4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),J_("input",{ref:Z,type:"file",multiple:!0,accept:J4,onChange:(G)=>{X.accept([...G.target.files??[]]),G.target.value=""},className:"cortex-widget__file-input"})]}),J_("button",{onClick:Y,"aria-label":Q("translate_send"),className:U("cortex-widget__send-btn",!$&&"cortex-widget__send-btn--empty",$&&"cortex-widget__send-btn--ready"),disabled:!$,children:J_("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",className:"cortex-widget__send-icon",children:J_("path",{d:"M3 8h10M9 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}import{useLayoutEffect as K4}from"react";import{jsx as N4}from"react/jsx-runtime";function n6(_){let{t:$}=L();K4(()=>{let Q=_.inputRef.current;if(!Q)return;Q.style.height="0px",Q.style.height=`${Q.scrollHeight}px`},[_.inputRef,_.value]);function Y(Q){if(Q.key==="Enter"&&!Q.shiftKey)Q.preventDefault(),_.onSubmit()}return N4("textarea",{ref:_.inputRef,onKeyDown:Y,onPaste:_.onPaste,value:_.value,onChange:(Q)=>_.onChange(Q.target.value),placeholder:_.dragging?$("translate_drop_files_here"):_.disabled?"":$("translate_type_a_message"),disabled:_.disabled,rows:1,className:U("cortex-widget__textarea",_.disabled&&"cortex-widget__textarea--disabled")})}import{jsx as P_,jsxs as O0}from"react/jsx-runtime";var a6=z4(function($,Y){let{t:Q,queue:X,send:Z,abort:G,capabilities:J}=L(),{isAgentWorking:V}=L_(),K=J?.attachments??!1,[N,z]=D4(""),F=p6(K,X.accept),B=r6(null);H4(Y,()=>({focusInput:()=>B.current?.focus()}));let q=r6(V);W4(()=>{if(q.current&&!V)B.current?.focus();q.current=V},[V]);let P=!X.busy&&(Boolean(N.trim())||X.hasReady);function O(){if(V||!P)return;let H=N.trim()||Q("translate_attachment_caption"),D=X.consumeReady();if(B.current)W0(B.current,H);z(""),Z(H,D.map((W)=>W.summary))}return O0("div",{className:"cortex-widget__input-area",onDragOver:F.onDragOver,onDragLeave:F.onDragLeave,onDrop:F.onDrop,children:[P_(d6,{}),O0("div",{className:U("cortex-widget__input-box",V&&"cortex-widget__input-box--disabled",!V&&"cortex-widget__input-box--enabled",F.dragging&&"cortex-widget__input-box--dragging"),children:[P_(n6,{inputRef:B,value:N,onChange:z,onSubmit:O,onPaste:F.onPaste,disabled:V,dragging:F.dragging}),V?O0("button",{onClick:()=>void G(),className:"cortex-stop-btn",children:[P_("span",{className:"cortex-stop-btn__ring"}),P_("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"cortex-stop-btn__icon",children:P_("rect",{x:"1",y:"1",width:"10",height:"10",rx:"2.5",fill:"currentColor"})})]}):P_(i6,{attachmentsEnabled:K,canSend:P,onSend:O})]})]})});import{jsx as o6}from"react/jsx-runtime";function X1({capabilities:_,composerRef:$}){let{t:Y}=L();if(_===void 0)return null;return _.messages===!1?o6("p",{className:"cortex-widget__messages-disabled",children:Y("translate_messages_disabled")}):o6(a6,{ref:$})}import{jsx as v,jsxs as Z1}from"react/jsx-runtime";function s6(_){let{t:$}=L(),Y=v("button",{type:"button",onClick:_.newChat,"aria-label":$("translate_new_chat"),title:$("translate_new_chat"),className:"cortex-widget__header-btn cortex-widget__new-btn",children:v("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:v("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})});if(_.screen==="threads")return Z1("div",{className:"cortex-widget__threads-header",children:[v("button",{type:"button",onClick:_.closeHistory,"aria-label":$("translate_back"),className:"cortex-widget__header-btn cortex-widget__back-btn",children:v("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"cortex-widget__back-icon",children:v("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),Z1("div",{children:[v("h2",{className:"cortex-widget__threads-title",children:$("translate_history")}),v("p",{className:"cortex-widget__threads-count",children:$(C_(_.threadCount,"translate_one_conversation","translate_n_conversations"),{count:_.threadCount})})]}),Y]});return Z1("div",{className:"cortex-widget__chat-header",children:[v("button",{onClick:_.openHistory,className:"cortex-widget__sidebar-toggle-btn",children:v("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:v("path",{d:"M2.5 4h11M2.5 8h11M2.5 12h11",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}),v("div",{className:"cortex-widget__chat-title-wrap",children:v("p",{className:"cortex-widget__chat-title",children:_.title??_.agentName??$("translate_new_chat")})}),_.debug.shown&&v("button",{onClick:_.toggleDebug,className:U("cortex-widget__debug-btn",_.debug.on?"cortex-widget__debug-btn--on":"cortex-widget__debug-btn--off"),children:_.debug.on?$("translate_debug"):$("translate_normal")}),Y,v("button",{type:"button",onClick:_.openHistory,"aria-label":$("translate_history"),title:$("translate_history"),className:"cortex-widget__header-btn cortex-widget__history-btn",children:Z1("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[v("circle",{cx:"8",cy:"8",r:"5.75",stroke:"currentColor",strokeWidth:"1.3"}),v("path",{d:"M8 5v3l2 1.5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})}import{jsx as s,jsxs as t6}from"react/jsx-runtime";function e6(_){let{locale:$,t:Y}=L();return t6("div",{className:"cortex-widget__landing",children:[s("div",{className:"cortex-widget__landing-icon",children:s("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",children:s("path",{d:w.bubble,stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),s("p",{className:"cortex-widget__landing-greeting",children:_.greeting}),!!_.suggestions.length&&s("div",{className:"cortex-widget__landing-chips",children:_.suggestions.map((Q,X)=>s("button",{type:"button",onClick:()=>_.send(Q.prompt),className:"cortex-widget__landing-chip",children:Q.title},X))}),_.composer,!!_.threads?.length&&s("div",{className:"cortex-widget__landing-recent",children:_.threads.slice(0,2).map((Q)=>{let X=a(Q.updatedAt,$);return t6("button",{type:"button",onClick:()=>_.openThread(Q),className:"cortex-widget__landing-recent-item",children:[s("p",{className:"cortex-widget__landing-recent-title",children:Q.title??Y("translate_untitled")}),X&&s("p",{className:"cortex-widget__landing-recent-time",children:X})]},Q.id)})})]})}import{useCallback as n_,useEffect as y0,useLayoutEffect as C0,useMemo as $7,useRef as W_,useState as S0}from"react";import{memo as e4}from"react";import{Fragment as o4}from"react";import{useRef as B4,useState as q4}from"react";import{jsx as O_,jsxs as F4}from"react/jsx-runtime";function h({value:_,className:$}){let{t:Y}=L(),[Q,X]=q4(!1),Z=B4(null);async function G(J){J.stopPropagation(),J.preventDefault();try{if(await navigator.clipboard.writeText(_),X(!0),Z.current)clearTimeout(Z.current);Z.current=setTimeout(()=>X(!1),1500)}catch{}}return O_("span",{className:U("cortex-copy-btn",$),children:O_("button",{className:U("cortex-copy-btn__button",Q&&"cortex-copy-btn__button--copied"),onClick:(J)=>void G(J),"aria-label":Q?Y("translate_copied"):Y("translate_copy"),type:"button",children:Q?O_("svg",{className:"cortex-copy-btn__icon cortex-copy-btn__icon--check",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",children:O_("path",{d:"M5 13l4 4L19 7",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}):F4("svg",{className:"cortex-copy-btn__icon",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",children:[O_("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2",stroke:"currentColor",strokeWidth:"2"}),O_("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})})})}import{jsx as G1,jsxs as _2}from"react/jsx-runtime";function $2(){let{t:_}=L();return _2("div",{className:"cortex-aborted-flag",children:[G1("span",{className:"cortex-aborted-flag__line"}),_2("span",{className:"cortex-aborted-flag__label",children:[G1("svg",{className:"cortex-aborted-flag__icon",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:G1("path",{d:"M6 1.5v5M6 8.75v.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})}),_("translate_aborted")]}),G1("span",{className:"cortex-aborted-flag__line"})]})}import{jsx as M_,jsxs as Y2}from"react/jsx-runtime";function Q2(_){let{api:$,t:Y}=L();async function Q(X){let{blob:Z,name:G}=await $.downloadAttachment(X);m_(Z,G)}return M_("div",{className:U("cortex-message-attachments",_.isUser&&"cortex-message-attachments--user"),children:_.attachments.map((X)=>Y2("button",{type:"button",onClick:()=>void Q(X.id),className:"cortex-message-attachment","aria-label":`${Y("translate_download")}: ${X.filename}`,children:[Y2("svg",{viewBox:"0 0 16 16",className:"cortex-message-attachment__icon",fill:"none",children:[M_("path",{d:w.file[0],stroke:"currentColor",strokeWidth:"1.25"}),M_("path",{d:w.file[1],stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]}),M_("span",{className:"cortex-message-attachment__name",children:X.filename}),M_("svg",{viewBox:"0 0 16 16",className:"cortex-message-attachment__dl-icon",fill:"none",children:M_("path",{d:"M8 3v7m0 0L5.5 7.5M8 10l2.5-2.5M3 13h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]},X.id))})}import{useRef as P4,useState as h_}from"react";import{useMemo as U4,useState as L4}from"react";import{jsx as x,jsxs as V_,Fragment as J1}from"react/jsx-runtime";function Q_({data:_,expandDepth:$,className:Y}){let Q=U4(()=>U_(_),[_]),[X,Z]=L4({});function G(V,K){return X[V]??K>=$}function J(V,K){Z((N)=>({...N,[V]:!G(V,K)}))}return x("div",{className:U("cortex-json-tree",Y),children:x(X2,{value:Q,path:"$",depth:0,isCollapsed:G,toggle:J})})}function X2({value:_,path:$,depth:Y,isCollapsed:Q,toggle:X}){let Z=V0(_,$);if(Z.kind==="primitive")return x("span",{className:Z.className,children:Z.text});if(Z.entries.length===0)return V_("span",{className:"cortex-json-tree__bracket",children:[Z.open,Z.close]});let G=Q($,Y);function J(V){X($,Y),V.stopPropagation()}return V_(J1,{children:[V_("span",{className:"cortex-json-tree__toggle",onClick:J,role:"button",children:[x("span",{className:U("cortex-json-tree__arrow",G&&"cortex-json-tree__arrow--collapsed"),children:"▾"}),x("span",{className:"cortex-json-tree__bracket",children:Z.open})]}),G?V_(J1,{children:[x("span",{className:"cortex-json-tree__collapsed-hint",onClick:J,role:"button",children:Z.summary}),x("span",{className:"cortex-json-tree__bracket",children:Z.close})]}):V_(J1,{children:[x("div",{className:"cortex-json-tree__indent",children:Z.entries.map((V,K)=>V_("div",{className:"cortex-json-tree__line",children:[V.key!==null&&V_(J1,{children:[x("span",{className:"cortex-json-tree__key",children:`"${V.key}"`}),x("span",{className:"cortex-json-tree__colon",children:": "})]}),x(X2,{value:V.value,path:V.path,depth:Y+1,isCollapsed:Q,toggle:X}),K<Z.entries.length-1&&x("span",{className:"cortex-json-tree__comma",children:","})]},V.path))}),x("span",{className:"cortex-json-tree__bracket",children:Z.close})]})]})}function R(_){return _.toLocaleString("en-US")}import{jsx as A_,jsxs as E_}from"react/jsx-runtime";function Z2({usage:_}){let{t:$}=L();return E_("div",{className:"cortex-llm-inspector__usage-rows",children:[E_("div",{className:"cortex-llm-inspector__usage-row",children:[A_("span",{className:"cortex-llm-inspector__usage-lbl",children:$("translate_input")}),A_("span",{className:"cortex-llm-inspector__usage-val",children:R(_.input.total)}),E_("span",{className:"cortex-llm-inspector__usage-detail",children:[$("translate_fresh")," ",R(_.input.noCache)," · ",$("translate_read")," ",R(_.input.cacheRead)," · ",$("translate_write")," ",R(_.input.cacheWrite)]})]}),E_("div",{className:"cortex-llm-inspector__usage-row",children:[A_("span",{className:"cortex-llm-inspector__usage-lbl",children:$("translate_output")}),A_("span",{className:"cortex-llm-inspector__usage-val",children:R(_.output.total)}),E_("span",{className:"cortex-llm-inspector__usage-detail",children:[$("translate_text")," ",R(_.output.text)," · ",$("translate_reasoning")," ",R(_.output.reasoning)]})]}),E_("div",{className:"cortex-llm-inspector__usage-row cortex-llm-inspector__usage-row--total",children:[A_("span",{className:"cortex-llm-inspector__usage-lbl",children:$("translate_total")}),A_("span",{className:"cortex-llm-inspector__usage-val",children:R(_.total)})]})]})}import{jsx as G2,jsxs as V1}from"react/jsx-runtime";function J2({usage:_}){let $=x_(_);return V1("span",{className:"cortex-llm-inspector__step-metrics",children:[V1("span",{className:"cortex-llm-inspector__metric",children:[G2("span",{className:"cortex-llm-inspector__dot cortex-llm-inspector__dot--input"}),R(_.input.total)]}),V1("span",{className:"cortex-llm-inspector__metric",children:[G2("span",{className:"cortex-llm-inspector__dot cortex-llm-inspector__dot--output"}),R(_.output.total)]}),$!==null&&V1("span",{className:"cortex-llm-inspector__cache-pct",children:[$,"%"]})]})}import{jsx as y,jsxs as X_}from"react/jsx-runtime";function V2({messageId:_}){let{t:$,api:Y}=L(),[Q,X]=h_(!1),[Z,G]=h_(!1),[J,V]=h_([]),[K,N]=h_(null),[z,F]=h_({}),B=P4(!1);async function q(){if(!B.current){G(!0);try{V(await Y.listLlmRequests(_))}finally{G(!1),B.current=!0}}X((W)=>!W)}function P(W){N((M)=>M===W?null:W)}function O(W){return z[W]??"prompt"}function H(W,M){F((A)=>({...A,[W]:M}))}function D(W){return O(W.id)==="prompt"?W.prompt:W.output}return X_("div",{className:U("cortex-llm-inspector",Q&&"cortex-llm-inspector--open"),children:[X_("button",{className:"cortex-llm-inspector__trigger",onClick:()=>void q(),children:[y("svg",{className:"cortex-llm-inspector__icon",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:y("path",{d:"M6 2a4 4 0 1 0 0 8 4 4 0 0 0 0-8ZM0 6a6 6 0 1 1 10.89 3.477l4.817 4.816a1 1 0 0 1-1.414 1.414l-4.816-4.816A6 6 0 0 1 0 6Z",fill:"currentColor"})}),y("span",{children:$("translate_inspect_llm_requests")}),Z?y("span",{className:"cortex-llm-inspector__loading",children:$("translate_loading")}):J.length>0?y("span",{className:"cortex-llm-inspector__badge",children:J.length}):null,y("svg",{className:"cortex-llm-inspector__chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:y("path",{d:w.chevronDown,stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),y("div",{className:"cortex-llm-inspector__panel-wrapper",children:y("div",{className:"cortex-llm-inspector__panel-inner",children:X_("div",{className:"cortex-llm-inspector__panel",children:[J.length===0&&!Z&&y("div",{className:"cortex-llm-inspector__empty",children:$("translate_no_llm_requests")}),J.map((W,M)=>X_("div",{className:U("cortex-llm-inspector__step",K===W.id&&"cortex-llm-inspector__step--expanded"),children:[X_("button",{className:"cortex-llm-inspector__step-header",onClick:()=>P(W.id),children:[y("span",{className:"cortex-llm-inspector__step-label",children:$("translate_step_n",{number:M+1})}),W.tokenUsage&&y(J2,{usage:W.tokenUsage}),y("svg",{className:"cortex-llm-inspector__step-chevron",width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",children:y("path",{d:w.chevronDown,stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),y("div",{className:"cortex-llm-inspector__step-body-wrapper",children:y("div",{className:"cortex-llm-inspector__step-body-inner",children:X_("div",{className:"cortex-llm-inspector__step-body",children:[W.tokenUsage&&y(Z2,{usage:W.tokenUsage}),X_("div",{className:"cortex-llm-inspector__tabs",children:[y("button",{className:U("cortex-llm-inspector__tab",O(W.id)==="prompt"&&"cortex-llm-inspector__tab--active"),onClick:()=>H(W.id,"prompt"),children:$("translate_request")}),y("button",{className:U("cortex-llm-inspector__tab",O(W.id)==="response"&&"cortex-llm-inspector__tab--active"),onClick:()=>H(W.id,"response"),children:$("translate_response")})]}),X_("div",{className:"cortex-llm-inspector__json-pane",children:[y(h,{className:"cortex-llm-inspector__json-copy",value:N0(D(W))}),y(Q_,{data:K0(D(W)),expandDepth:2})]})]})})})]},W.id))]})})})]})}import{useState as O4}from"react";import{jsx as E,jsxs as b}from"react/jsx-runtime";function K2({usage:_,modelId:$}){let{t:Y}=L(),[Q,X]=O4(!1),Z=x_(_)??0;return b("div",{className:U("cortex-token-usage",Q&&"cortex-token-usage--expanded"),children:[b("button",{className:"cortex-token-usage__summary",onClick:()=>X((G)=>!G),children:[b("span",{className:"cortex-token-usage__total",children:[E("span",{className:"cortex-token-usage__total-number",children:R(_.total)}),E("span",{className:"cortex-token-usage__total-label",children:Y("translate_tokens")})]}),$?E("span",{className:"cortex-token-usage__model",children:$}):null,b("span",{className:"cortex-token-usage__pills",children:[b("span",{className:"cortex-token-usage__pill",children:[E("span",{className:"cortex-token-usage__dot cortex-token-usage__dot--input"}),R(_.input.total)]}),b("span",{className:"cortex-token-usage__pill",children:[E("span",{className:"cortex-token-usage__dot cortex-token-usage__dot--output"}),R(_.output.total)]})]}),Z>0&&b("span",{className:"cortex-token-usage__cache-badge",children:[Z,"%"]}),E("svg",{className:"cortex-token-usage__chevron",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:E("path",{d:w.chevronDown,stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),E("div",{className:"cortex-token-usage__details",children:E("div",{className:"cortex-token-usage__details-inner",children:b("div",{className:"cortex-token-usage__columns",children:[b("div",{className:"cortex-token-usage__col",children:[b("div",{className:"cortex-token-usage__col-header",children:[E("span",{className:"cortex-token-usage__dot cortex-token-usage__dot--input"}),E("span",{className:"cortex-token-usage__col-label",children:Y("translate_input")}),E("span",{className:"cortex-token-usage__col-total",children:R(_.input.total)})]}),b("div",{className:"cortex-token-usage__rows",children:[_.input.noCache?b("div",{className:"cortex-token-usage__row",children:[E("span",{className:"cortex-token-usage__row-label",children:Y("translate_fresh")}),E("span",{className:"cortex-token-usage__row-value",children:R(_.input.noCache)})]}):null,_.input.cacheRead?b("div",{className:"cortex-token-usage__row",children:[E("span",{className:"cortex-token-usage__row-label",children:Y("translate_cache_read")}),E("span",{className:"cortex-token-usage__row-value",children:R(_.input.cacheRead)})]}):null,_.input.cacheWrite?b("div",{className:"cortex-token-usage__row",children:[E("span",{className:"cortex-token-usage__row-label",children:Y("translate_cache_write")}),E("span",{className:"cortex-token-usage__row-value",children:R(_.input.cacheWrite)})]}):null]}),Z>0&&b("div",{className:"cortex-token-usage__cache-bar-row",children:[E("div",{className:"cortex-token-usage__cache-bar",children:E("div",{className:"cortex-token-usage__cache-fill",style:{width:`${Z}%`}})}),E("span",{className:"cortex-token-usage__cache-label",children:Y("translate_n_percent_cached",{percent:Z})})]})]}),b("div",{className:"cortex-token-usage__col",children:[b("div",{className:"cortex-token-usage__col-header",children:[E("span",{className:"cortex-token-usage__dot cortex-token-usage__dot--output"}),E("span",{className:"cortex-token-usage__col-label",children:Y("translate_output")}),E("span",{className:"cortex-token-usage__col-total",children:R(_.output.total)})]}),b("div",{className:"cortex-token-usage__rows",children:[_.output.text?b("div",{className:"cortex-token-usage__row",children:[E("span",{className:"cortex-token-usage__row-label",children:Y("translate_text")}),E("span",{className:"cortex-token-usage__row-value",children:R(_.output.text)})]}):null,_.output.reasoning?b("div",{className:"cortex-token-usage__row",children:[E("span",{className:"cortex-token-usage__row-label",children:Y("translate_reasoning")}),E("span",{className:"cortex-token-usage__row-value",children:R(_.output.reasoning)})]}):null]})]})]})})})]})}import{jsx as N2,jsxs as M4}from"react/jsx-runtime";function z2({messageId:_,isAssistant:$,metadata:Y}){let{tokenUsage:Q}=Y;if(!Q&&!$)return null;return M4("div",{className:"cortex-message-debug-zone",children:[Q&&N2(K2,{usage:Q,modelId:Y.modelId}),$&&N2(V2,{messageId:_})]})}import{jsx as u,jsxs as u_}from"react/jsx-runtime";function W2(_){let{reasoningPart:$,streaming:Y=!1}=_,{t:Q}=L();return u_("details",{className:"cortex-reasoning-details",children:[u_("summary",{className:"cortex-reasoning-details__summary",children:[u_("div",{className:"cortex-reasoning-details__header",children:[u("span",{className:"cortex-reasoning-details__icon",children:u_("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[u("path",{d:"M10 2C6.686 2 4 4.686 4 8c0 1.655.672 3.154 1.757 4.243.362.363.576.858.576 1.371V14.5a1 1 0 0 0 1 1h5.334a1 1 0 0 0 1-1v-.886c0-.513.214-1.008.576-1.371A5.978 5.978 0 0 0 16 8c0-3.314-2.686-6-6-6Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),u("path",{d:"M7.5 17.5h5M8.5 8a2 2 0 0 1 2-2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]})}),u("div",{className:"cortex-reasoning-details__title-group",children:u_("div",{className:"cortex-reasoning-details__title-row",children:[u("div",{className:"cortex-reasoning-details__title",children:Q("translate_reasoning")}),u("span",{className:U("cortex-reasoning-details__badge",Y?"cortex-reasoning-details__badge--streaming":"cortex-reasoning-details__badge--done"),children:Y?Q("translate_streaming"):Q("translate_done")})]})})]}),u("span",{className:"cortex-reasoning-details__chevron","aria-hidden":"true",children:u("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"none",children:u("path",{d:w.chevronDownLarge,stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),u("div",{className:"cortex-reasoning-details__body",children:u("div",{className:"cortex-reasoning-details__content",children:u("pre",{className:"cortex-reasoning-details__pre",children:$.content.trim()?$.content:Q("translate_no_reasoning")})})})]})}import{useEffect as L2,useMemo as f4,useRef as A0,useState as j4}from"react";import{useEffect as k4,useState as H2}from"react";import{useRef as A4,useState as E4}from"react";import{jsx as t,jsxs as K1}from"react/jsx-runtime";function k_(_){let{label:$,ready:Y=!0,actions:Q,expanded:X,children:Z}=_,{t:G}=L(),J=A4(null),[V,K]=E4(!1);return K1("div",{className:"cortex-expandable",children:[Y&&K1("div",{className:"cortex-expandable__toolbar",role:"group","aria-label":$,children:[Q,t("button",{type:"button",className:"cortex-expandable__action","aria-label":G("translate_expand",{name:$}),title:G("translate_expand",{name:$}),onClick:()=>{K(!0),J.current?.showModal()},children:t("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:t("path",{d:"M9.5 2.5h4v4M6.5 13.5h-4v-4M13.5 2.5 9 7M2.5 13.5 7 9",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),t("div",{className:"cortex-expandable__content",children:Z}),K1("dialog",{ref:J,className:"cortex-expandable__dialog","aria-label":$,closedby:"any",onClose:()=>K(!1),children:[K1("div",{className:"cortex-expandable__head",children:[t("span",{className:"cortex-expandable__title",children:$}),Q,t("button",{type:"button",className:"cortex-expandable__action","aria-label":G("translate_close"),title:G("translate_close"),onClick:()=>J.current?.close(),children:t("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:t("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})]}),V&&t("div",{className:"cortex-expandable__body",children:X})]})]})}import{jsx as c_,jsxs as R4}from"react/jsx-runtime";function D2(_){let{id:$,alt:Y,attachment:Q}=_,{api:X,t:Z}=L(),[G,J]=H2(),[V,K]=H2(!1);if(k4(()=>{let N,z=!1;return J(void 0),K(!1),X.downloadAttachment($).then(({blob:F})=>{if(z)return;N=URL.createObjectURL(F),J(N)},()=>{if(!z)K(!0)}),()=>{if(z=!0,N)URL.revokeObjectURL(N)}},[X,$]),V)return c_("p",{className:"cortex-attachment-image__caption",children:Y?Z("translate_image_unavailable_alt",{alt:Y}):Z("translate_image_unavailable")});if(!G)return null;return R4("figure",{className:"cortex-attachment-image",children:[c_(k_,{label:Q?.filename||Y||Z("translate_image"),expanded:c_("img",{className:"cortex-attachment-image__expanded",src:G,alt:Y}),children:c_("img",{src:G,alt:Y})}),Q&&c_("figcaption",{className:"cortex-attachment-image__caption",children:Q.filename})]})}import{useEffect as I4,useRef as y4,useState as M0}from"react";import{jsx as j,jsxs as p_,Fragment as w4}from"react/jsx-runtime";function C4(_){let{t:$}=L();if(!_.pending&&!_.debugMode)return null;return p_("div",{className:"cortex-media-block__head",children:[_.debugMode&&j("span",{className:"cortex-media-block__lang",children:_.language}),_.pending&&j("span",{className:"cortex-media-block__pending",children:$($1(_.language).pending)}),_.debugMode&&_.closed&&p_("span",{className:"cortex-media-block__actions",children:[_.onToggleSource&&j("button",{type:"button",className:"cortex-media-block__action","aria-pressed":_.sourceShown,onClick:_.onToggleSource,children:$("translate_media_source")}),j(h,{value:_.source})]})]})}function B2(_){let{debugMode:$,t:Y}=L();return j("div",{className:"cortex-media-block__body",children:p_("p",{className:"cortex-media-block__error",children:[_.cutOff?Y("translate_media_cut_off"):Y("translate_media_failed"),!_.cutOff&&$&&` ${_.reason}`]})})}function q2(_){let{language:$,source:Y,closed:Q,hidden:X,onError:Z}=_,{config:G,scheme:J,locale:V}=L(),K=y4(null);return I4(()=>{Z(void 0);let N=K.current;if(!Q||!J||!N)return;return Y1(N,{language:$,source:Y,context:{scheme:J,locale:V},overrides:G.mediaRenderers,onError:Z})},[$,Y,Q,J,V,G.mediaRenderers,Z]),j("div",{ref:K,hidden:X,className:U("cortex-media-block__body",`cortex-media-block__body--${$}`)})}function S4(_){let[$,Y]=M0();return p_(w4,{children:[$&&j(B2,{cutOff:!1,reason:$}),j(q2,{language:_.language,source:_.source,closed:!0,hidden:Boolean($),onError:Y})]})}function F2(_){let{language:$,source:Y,closed:Q,streaming:X}=_,{debugMode:Z,t:G}=L(),[J,V]=M0(),[K,N]=M0(!1),z=!Q&&!X,F=z||Boolean(J);return p_("div",{className:"cortex-media-block",children:[j(C4,{language:$,source:Y,pending:!Q&&X,closed:Q,debugMode:Z,sourceShown:K,onToggleSource:F?void 0:()=>N((q)=>!q)}),F&&j(B2,{cutOff:z,reason:J}),j(k_,{label:G($1($).title),ready:Q&&!F,expanded:j(S4,{language:$,source:Y}),children:j(q2,{language:$,source:Y,closed:Q,hidden:F,onError:V})}),Z&&(F||K)&&j("pre",{className:"cortex-media-block__source",children:Y})]})}import{useMemo as b4,useRef as T4}from"react";import{jsx as K_}from"react/jsx-runtime";var v4="M8 2.5v7.5M5 7l3 3 3-3M2.75 11v1.25a1.25 1.25 0 0 0 1.25 1.25h8a1.25 1.25 0 0 0 1.25-1.25V11";function U2(_){let{t:$}=L(),Y=T4(null),Q=b4(()=>({__html:v_(_.text)}),[_.text]);function X(){let Z=Y.current?.querySelector("table");if(Z)m_(t1(s1(Z)),"table.xlsx")}return K_("div",{className:"cortex-table-block",children:K_(k_,{label:$("translate_table"),ready:_.closed,actions:K_("button",{type:"button",className:"cortex-expandable__action","aria-label":$("translate_table_export"),title:$("translate_table_export"),onClick:X,children:K_("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:K_("path",{d:v4,stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),expanded:K_("div",{className:"cortex-table-block__expanded",dangerouslySetInnerHTML:Q}),children:K_("div",{ref:Y,dangerouslySetInnerHTML:Q})})})}import{jsx as R_}from"react/jsx-runtime";function P2(_){let{role:$,textPart:Y,streaming:Q=!1,attachments:X=[]}=_,{config:Z}=L(),G=$==="assistant"&&Q?"":Y.content,[J,V]=j4({text:G,fading:[]}),K=A0(G),N=A0(null),z=A0(!0);L2(()=>{function q(P,O){K.current=P,V((H)=>H.text===P&&!H.fading.length&&!O.length?H:{text:P,fading:O})}if($!=="assistant"||!Q){N.current?.destroy(),N.current=null,q(Y.content,[]),z.current=!1;return}if(!N.current)N.current=new Y_(q),N.current.seed(K.current);if(z.current){z.current=!1,N.current.seed(Y.content);return}N.current.update(Y.content,!1)},[$,Q,Y]),L2(()=>()=>{N.current?.destroy(),N.current=null},[]);let F=f4(()=>{let q=$==="assistant"?o1(J.text,Z0(Z.mediaRenderers)):[{kind:"markdown",text:J.text}];return q.map((P,O)=>P.kind==="markdown"?{...P,html:{__html:v_(P.text,O===q.length-1?J.fading:[])}}:P)},[$,J,Z.mediaRenderers]),B=Q||J.text!==Y.content;return R_("div",{className:U("cortex-text-part",$==="assistant"&&"cortex-text-part--assistant",$==="user"&&"cortex-text-part--user"),children:R_("div",{className:U("cortex-text-bubble",$==="assistant"&&"cortex-text-bubble--assistant",$==="user"&&"cortex-text-bubble--user"),children:F.map((q,P)=>{switch(q.kind){case"markdown":return R_("div",{dangerouslySetInnerHTML:q.html},P);case"media":return R_(F2,{...q,streaming:B},P);case"table":return R_(U2,{text:q.text,closed:q.closed||!B},P);case"attachment":return R_(D2,{id:q.id,alt:q.alt,attachment:X.find((O)=>O.id.toLowerCase()===q.id)},P)}})})})}import{jsx as g,jsxs as Z_}from"react/jsx-runtime";function O2({toolCallPart:_}){let{t:$}=L(),{state:Y,approval:Q}=_,X=_.output,Z=E1(_);if(Y==="complete")return Z_("div",{className:"cortex-debug-tool__section cortex-debug-tool__section--success",children:[Z_("div",{className:"cortex-debug-tool__section-bar",children:[g("span",{className:"cortex-debug-tool__section-label cortex-debug-tool__section-label--success",children:$("translate_output")}),g("span",{className:"cortex-debug-tool__section-lang",children:"json"}),g(h,{value:Z})]}),g("div",{dir:"ltr",className:"cortex-debug-tool__tree",children:g(Q_,{data:X,expandDepth:2})})]});if(Y==="error")return Z_("div",{className:"cortex-debug-tool__section cortex-debug-tool__section--error",children:[Z_("div",{className:"cortex-debug-tool__section-bar",children:[g("span",{className:"cortex-debug-tool__section-label cortex-debug-tool__section-label--error",children:$("translate_error")}),g(h,{value:Z})]}),g("pre",{dir:"ltr",className:"cortex-debug-tool__error-pre",children:Z})]});if(Y==="approval-requested")return Z_("div",{className:"cortex-debug-tool__section cortex-debug-tool__section--approval",children:[Z_("div",{className:"cortex-debug-tool__section-bar",children:[g("span",{className:"cortex-debug-tool__section-label cortex-debug-tool__section-label--approval",children:$("translate_approval_requested")}),g("span",{className:"cortex-debug-tool__section-lang",children:Q?.id})]}),g("div",{className:"cortex-debug-tool__message cortex-debug-tool__message--approval",children:$("translate_waiting_for_approval")})]});if(Y==="approval-responded")return Z_("div",{className:"cortex-debug-tool__section cortex-debug-tool__section--approval",children:[Z_("div",{className:"cortex-debug-tool__section-bar",children:[g("span",{className:"cortex-debug-tool__section-label cortex-debug-tool__section-label--approval",children:$("translate_approval_response")}),g("span",{className:"cortex-debug-tool__section-lang",children:Q?.id})]}),g("div",{className:"cortex-debug-tool__message cortex-debug-tool__message--approval",children:$(Q?.approved?"translate_tool_approved":"translate_tool_response_received")})]});return null}import{jsx as g4,jsxs as m4}from"react/jsx-runtime";function M2({toolCallPart:_}){let{t:$}=L(),Y=A1(_);return m4("span",{className:U("cortex-debug-tool__state",Y.modifier&&`cortex-debug-tool__state--${Y.modifier}`),children:[Y.pulse&&g4("span",{className:U("cortex-debug-tool__pulse",Y.pulse==="violet"&&"cortex-debug-tool__pulse--violet")}),$(Y.labelKey)]})}import{jsx as T,jsxs as e}from"react/jsx-runtime";function A2({toolCallPart:_}){let{t:$}=L(),{codeSnippets:Y,remainingInput:Q,remainingInputText:X}=k1(_.input);return e("details",{className:"cortex-debug-tool","data-state":_.state,children:[T("summary",{className:"cortex-debug-tool__summary",children:e("div",{className:"cortex-debug-tool__header",children:[e("div",{className:"cortex-debug-tool__meta",children:[T("div",{className:"cortex-debug-tool__title-row",children:T("span",{className:"cortex-debug-tool__name",title:_.name,children:_.name})}),T("div",{className:"cortex-debug-tool__id-row",children:T("span",{className:"cortex-debug-tool__id",children:_.id})})]}),e("div",{className:"cortex-debug-tool__actions",children:[T(M2,{toolCallPart:_}),T("svg",{className:"cortex-debug-tool__chevron",width:"14",height:"14",viewBox:"0 0 20 20",fill:"none",children:T("path",{d:w.chevronDownLarge,stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}),e("div",{className:"cortex-debug-tool__body",children:[Y.map((Z)=>e("div",{className:"cortex-debug-tool__section",children:[e("div",{className:"cortex-debug-tool__section-bar",children:[T("span",{className:"cortex-debug-tool__section-label",children:Z.key}),T("span",{className:"cortex-debug-tool__section-lang",children:Z.lang}),T(h,{value:Z.value})]}),T("pre",{dir:"ltr",className:"cortex-debug-tool__pre",children:T("code",{className:"hljs",dangerouslySetInnerHTML:{__html:J0(Z.value,Z.lang)}})})]},Z.key)),!!Q&&e("div",{className:"cortex-debug-tool__section",children:[e("div",{className:"cortex-debug-tool__section-bar",children:[T("span",{className:"cortex-debug-tool__section-label",children:$("translate_input")}),T("span",{className:"cortex-debug-tool__section-lang",children:"json"}),T(h,{value:X})]}),T("div",{dir:"ltr",className:"cortex-debug-tool__tree",children:T(Q_,{data:Q,expandDepth:2})})]}),T(O2,{toolCallPart:_})]})]})}import{useEffect as x4,useRef as h4,useState as E2}from"react";import{jsx as d_,jsxs as k2}from"react/jsx-runtime";function N_({activity:_,className:$}){let{t:Y}=L(),Q=I1(_),[X,Z]=E2(0),[G,J]=E2("idle"),V=h4(Q.length);return V.current=Q.length,x4(()=>{let K,N;function z(){K=setTimeout(()=>{J("exiting"),K=setTimeout(()=>{Z((F)=>(F+1)%V.current),J("enter-start"),N=requestAnimationFrame(()=>{J("entering"),K=setTimeout(()=>{J("idle"),z()},300)})},300)},2000)}return z(),()=>{if(K)clearTimeout(K);if(N)cancelAnimationFrame(N)}},[]),k2("div",{className:U("cortex-subtle-activity",$),children:[k2("div",{className:"cortex-subtle-activity__dots",children:[d_("span",{className:"cortex-subtle-activity__dot"}),d_("span",{className:"cortex-subtle-activity__dot cortex-subtle-activity__dot--d1"}),d_("span",{className:"cortex-subtle-activity__dot cortex-subtle-activity__dot--d2"})]}),d_("div",{className:"cortex-subtle-activity__label-mask",children:d_("span",{className:U("cortex-subtle-activity__label",`cortex-subtle-activity__label--${G}`),children:Y(Q[X])})})]})}import{useEffect as w2,useRef as E0,useState as S2}from"react";import{jsx as c,jsxs as I_,Fragment as u4}from"react/jsx-runtime";function R2({toolCallPart:_,asking:$}){let{t:Y,locale:Q,respondToApproval:X}=L(),{sentence:Z,decision:G,decisionKey:J}=R1(_,Q),V=`cortex-approval-${_.id}`,K=c0(_),N=G==="pending",{state:z,active:F}=r(_);return I_("div",{className:U("cortex-approval-card",N&&"cortex-approval-card--asking"),children:[N?I_(u4,{children:[I_("div",{className:"cortex-approval-card__head",children:[c("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:c("path",{d:"M8 1.75 2.75 3.75v4c0 3 2.2 5.3 5.25 6.5 3.05-1.2 5.25-3.5 5.25-6.5v-4L8 1.75Z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})}),Y("translate_approval_needed")]}),c("p",{className:"cortex-approval-card__sentence",id:V,children:Z})]}):I_("div",{className:"cortex-approval-card__line",children:[I_("span",{className:"cortex-tool-pill__icon","aria-hidden":"true",children:[c("span",{className:U("cortex-tool-pill__spinner",F&&"cortex-tool-pill__spinner--visible")}),c("svg",{className:U("cortex-tool-pill__svg cortex-tool-pill__svg--check",z==="complete"&&"cortex-tool-pill__svg--visible"),viewBox:"0 0 20 20",fill:"none",children:c("path",{d:"M5.5 10.5 L8.5 13.5 L14.5 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),c("svg",{className:U("cortex-tool-pill__svg cortex-tool-pill__svg--error",z==="error"&&"cortex-tool-pill__svg--visible"),viewBox:"0 0 20 20",fill:"none",children:c("path",{d:"M6.5 6.5 L13.5 13.5 M13.5 6.5 L6.5 13.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]}),J&&c("span",{className:"cortex-approval-card__decision",children:Y(J)}),c("span",{className:"cortex-approval-card__summary",children:Z})]}),N&&$&&I_("div",{className:"cortex-approval-card__foot",children:[c("button",{type:"button",className:"cortex-approval-card__button cortex-approval-card__button--approve","aria-describedby":V,onClick:()=>void X(K,!0),children:Y("translate_approve")}),c("button",{type:"button",className:"cortex-approval-card__button","aria-describedby":V,onClick:()=>void X(K,!1),children:Y("translate_deny")})]})]})}import{useEffect as I2,useRef as N1,useState as y2}from"react";import{jsx as C,jsxs as p}from"react/jsx-runtime";function C2({toolCallPart:_,setOutput:$}){let{t:Y}=L(),{state:Q,id:X,input:Z}=_;if(Q==="complete"||Q==="error"){let G=d1(_.output);return G?C(p4,{position:G}):p("div",{className:"cortex-tool-pill",children:[C("span",{className:"cortex-tool-pill__icon",children:C("svg",{className:U("cortex-tool-pill__svg cortex-tool-pill__svg--visible",Q==="error"&&"cortex-tool-pill__svg--error"),viewBox:"0 0 20 20",fill:"none",children:C("path",{d:"M6.5 6.5 L13.5 13.5 M13.5 6.5 L6.5 13.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}),C("span",{className:"cortex-tool-pill__title",children:Y("translate_location_not_shared")})]})}if(Q!=="input-complete")return null;return C(c4,{center:p1(Z),submit:$},X)}function c4({center:_,submit:$}){let{t:Y}=L(),Q=N1(null),X=N1(void 0),[Z,G]=y2(o_),J=N1({center:_,submit:$});J.current={center:_,submit:$},I2(()=>{let K=Q.current;if(!K)return;let N=u1(K,{center:J.current.center,onState:G,submit:(z)=>J.current.submit(z)});return X.current=N,N.start(),()=>{if(N.dispose(),X.current===N)X.current=void 0}},[]);let V=l1(Z);return p("div",{className:"cortex-location-input",children:[p("div",{className:"cortex-location-input__map",children:[C("div",{className:"cortex-location-input__canvas",ref:Q}),C("button",{type:"button",className:"cortex-location-input__locate","aria-label":Y("translate_location_locate"),title:Y("translate_location_locate"),disabled:Z.locating||Z.submitting,onClick:()=>X.current?.locate(),children:C(d4,{})})]}),p("div",{className:"cortex-location-input__foot",children:[Z.position&&!Z.deliveryFailed?C("span",{className:"cortex-location-input__coords",children:s_(Z.position)}):p("span",{className:U("cortex-location-input__hint",V.failed&&"cortex-location-input__hint--failed"),children:[Z.locating&&C("span",{className:"cortex-location-input__spinner"}),Y(V.key)]}),p("span",{className:"cortex-location-input__actions",children:[C("button",{type:"button",className:"cortex-location-input__skip",disabled:Z.submitting,onClick:()=>X.current?.cancel(),children:Y("translate_location_skip")}),C("button",{type:"button",className:"cortex-location-input__send",disabled:!Z.position||Z.submitting,onClick:()=>X.current?.confirm(),children:Y("translate_location_send")})]})]})]})}function p4({position:_}){let{t:$}=L(),Y=N1(null),[Q,X]=y2(!1),{lat:Z,lng:G}=_;return I2(()=>{let J=Y.current;if(!J)return;return X(!1),c1(J,{lat:Z,lng:G},()=>X(!0))},[Z,G]),p("div",{className:"cortex-location-input cortex-location-input--settled",children:[p("div",{className:"cortex-location-input__map cortex-location-input__map--still",children:[C("div",{className:"cortex-location-input__canvas",ref:Y,hidden:Q}),Q&&C("span",{className:"cortex-location-input__still-failed",children:$("translate_location_map_failed")})]}),p("div",{className:"cortex-location-input__body",children:[p("span",{className:"cortex-location-input__title",children:[C("svg",{viewBox:"0 0 20 20",fill:"none",children:C("path",{d:"M5.5 10.5 L8.5 13.5 L14.5 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),$("translate_location_shared")]}),C("span",{className:"cortex-location-input__coords",children:s_(_)})]})]})}function d4(){return p("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:[C("circle",{cx:"10",cy:"10",r:"5.5"}),C("circle",{cx:"10",cy:"10",r:"1.6",fill:"currentColor",stroke:"none"}),C("path",{d:"M10 1.5v3M10 15.5v3M1.5 10h3M15.5 10h3"})]})}import{jsx as I,jsxs as l_}from"react/jsx-runtime";var l4=new Map([[a_,C2]]);function b2({message:_,toolCallPart:$,agentWorking:Y}){let{config:Q,addToolResult:X}=L(),Z=$.state==="input-complete"&&!Y,G=$.state==="approval-requested"&&!Y,J=Q.toolComponents?.[$.name]??(Z||f($.state)?l4.get($.name):void 0);return I("div",{className:"cortex-tool-call-animated",children:J?I(J,{toolCallPart:$,message:_,setOutput:(V)=>X($.id,$.name,V)}):Z?I(i4,{toolCallPart:$}):I(T2,{toolCallPart:$,asking:G})})}function i4({toolCallPart:_}){let{api:$,t:Y,addToolResult:Q,selectedThread:X,config:Z}=L(),G=X?.id,[J,V]=S2({phase:"initiating"}),[K]=S2(Z.trustSameOriginEmbeds),N=E0(void 0),z=E0({api:$,addToolResult:Q,toolName:_.name});if(z.current={api:$,addToolResult:Q,toolName:_.name},w2(()=>{if(!G)return;let B=x1({initiate:()=>z.current.api.initiateToolCall(G,_.id),onState:V,submit:(P)=>z.current.addToolResult(_.id,z.current.toolName,P)});N.current=B,B.start();let q=(P)=>B.handleMessage(P);return window.addEventListener("message",q),()=>{if(window.removeEventListener("message",q),B.dispose(),N.current===B)N.current=void 0}},[_.id,G]),!G||J.phase==="unavailable"||J.phase==="settling")return I(T2,{toolCallPart:_,asking:!1});let F=l_("div",{className:"cortex-client-tool-embed",children:[l_("div",{className:"cortex-client-tool-embed__bar",children:[I("span",{children:Y("translate_client_tool_title")}),I("button",{type:"button",className:"cortex-client-tool-embed__cancel",onClick:()=>N.current?.cancel(),children:Y("translate_client_tool_cancel")})]}),J.phase==="embedded"?I("iframe",{className:"cortex-client-tool-embed__frame",src:J.embedUrl,sandbox:j1(J.embedUrl,window.location.origin,K),title:Y("translate_client_tool_title"),ref:(B)=>N.current?.setSource(B?.contentWindow),onLoad:(B)=>{if(!g1(J.embedUrl,window.location.origin,K)&&m1(B.currentTarget,window.location.origin))N.current?.terminate()}}):J.phase==="error"?l_("div",{className:"cortex-client-tool-embed__status",children:[I("span",{children:Y("translate_client_tool_failed")}),I("button",{type:"button",className:"cortex-client-tool-embed__retry",onClick:()=>void N.current?.start(),children:Y("translate_client_tool_retry")})]}):I("div",{className:"cortex-client-tool-embed__status",children:Y("translate_client_tool_loading")})]});return J.phase==="embedded"&&J.surface==="modal"?I(n4,{label:Y("translate_client_tool_title"),onCancel:()=>N.current?.cancel(),children:F}):F}function n4({label:_,onCancel:$,children:Y}){let Q=E0(null);return w2(()=>{let X=Q.current;return X?.showModal(),()=>X?.close()},[]),I("dialog",{ref:Q,className:"cortex-client-tool-embed-dialog","aria-label":_,onCancel:(X)=>{X.preventDefault(),$()},children:Y})}function T2({toolCallPart:_,asking:$}){return r(_).gated?I(R2,{toolCallPart:_,asking:$}):I(r4,{toolCallPart:_})}function r4({toolCallPart:_}){let{t:$}=L(),{state:Y,active:Q,titleKey:X,statement:Z,rowCount:G}=r(_);return l_("div",{className:"cortex-tool-pill",children:[l_("span",{className:"cortex-tool-pill__icon",children:[I("span",{className:U("cortex-tool-pill__spinner",Q&&"cortex-tool-pill__spinner--visible")}),I("svg",{className:U("cortex-tool-pill__svg","cortex-tool-pill__svg--check",Y==="complete"&&"cortex-tool-pill__svg--visible"),viewBox:"0 0 20 20",fill:"none",children:I("path",{d:"M5.5 10.5 L8.5 13.5 L14.5 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),I("svg",{className:U("cortex-tool-pill__svg","cortex-tool-pill__svg--error",Y==="error"&&"cortex-tool-pill__svg--visible"),viewBox:"0 0 20 20",fill:"none",children:I("path",{d:"M6.5 6.5 L13.5 13.5 M13.5 6.5 L6.5 13.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]}),I("span",{className:U("cortex-tool-pill__title",Y==="error"&&"cortex-tool-pill__title--error",Y==="starting"&&Z&&"cortex-tool-pill__title--pending"),children:Z??$(X)}),G!==void 0&&I("span",{className:"cortex-tool-pill__meta",children:$("translate_rows_read",{count:G})})]})}import{jsx as k0}from"react/jsx-runtime";function v2({message:_,toolCallPart:$,agentWorking:Y}){if(!f($.state)&&!r($).statement){if($.name==="queryGraph")return k0(N_,{activity:"graph"});if($.name==="executeCode")return k0(N_,{activity:"code"})}return k0(b2,{toolCallPart:$,message:_,agentWorking:Y})}import{jsx as y_,jsxs as a4}from"react/jsx-runtime";function f2(_){let{message:$,part:Y,debugMode:Q,animate:X,streaming:Z,agentWorking:G,attachments:J}=_,{t:V}=L();function K(){switch(Y.type){case"text":return y_(P2,{textPart:Y,role:$.role,streaming:Z,attachments:J});case"thinking":return Q?y_(W2,{reasoningPart:Y,streaming:Z}):y_(N_,{activity:"reasoning",className:"cortex-reasoning-animated"});case"tool-call":return Q?y_(A2,{toolCallPart:Y}):y_(v2,{toolCallPart:Y,message:$,agentWorking:G});default:return a4("p",{className:"cortex-unhandled-type",children:[V("translate_unhandled_type")," ",Y.type]})}}return y_("div",{className:U("cortex-message-part",X&&"cortex-message-part--animated",_.folded&&"cortex-message-part--folded"),"data-cortex-frontier":_.frontier?"":void 0,children:K()})}import{jsx as __,jsxs as R0}from"react/jsx-runtime";function s4({isUser:_,clipboardText:$,createdAt:Y}){let{locale:Q}=L();return R0("div",{className:U("cortex-message-actions",_&&"cortex-message-actions--user"),children:[$&&__(h,{value:$}),Y&&__("time",{className:"cortex-message-actions__time",dateTime:Y,children:a(Y,Q)})]})}function t4({count:_,animate:$,onOpen:Y}){let{t:Q}=L();return __("button",{type:"button",className:U("cortex-tool-fold",$&&"cortex-message-part--animated"),onClick:Y,children:Q(C_(_,"translate_one_more_step","translate_n_more_steps"),{count:_})})}function j2(_){let{message:$,parts:Y,metadata:Q,debugMode:X,animate:Z,isStreaming:G,agentWorking:J,closesTurn:V,fold:K,onOpenRun:N,frontier:z}=_,F=$.role==="assistant",B=$.role==="user",q=G?Y.length-1:-1,P=Q?.attachments??[],O=Y.filter((k)=>K?.get(k)?.kind!=="hidden"),H=O.filter((k)=>k.type==="text").at(-1),D=H?Y.indexOf(H):-1,W=(B||F)&&!G&&D>=0,M=H!==O.at(-1)?D:-1,A=W&&__(s4,{isUser:B,clipboardText:y1(Y),createdAt:Q?.createdAt});return R0("div",{className:"cortex-message-parts",children:[Y.map((k,i)=>{let G_=K?.get(k);return R0(o4,{children:[__(f2,{part:k,message:$,debugMode:X,animate:Z,streaming:i===q,agentWorking:J,attachments:P,frontier:k===z,folded:G_?.kind==="hidden"}),G_?.kind==="more"&&__(t4,{count:G_.count,animate:Z,onOpen:()=>N(G_.runId)}),i===M&&A]},$.parts.indexOf(k))}),P.length>0&&__(Q2,{attachments:P,isUser:B}),Q?.isAborted&&__($2,{}),M===-1&&A,X&&Q&&V&&__(z2,{messageId:$.id,isAssistant:F,metadata:Q})]})}import{jsx as z_,jsxs as I0}from"react/jsx-runtime";function g2({firing:_,debugMode:$}){let{t:Y,locale:Q}=L();return I0("div",{className:U("cortex-trigger-block",$&&"cortex-trigger-block--debug"),children:[I0("div",{className:"cortex-trigger-block__head",children:[z_("svg",{className:"cortex-trigger-block__icon",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:z_("path",{d:"M6.75 1 2.5 6.75h3l-.25 4.25L9.5 5.25h-3z",fill:"currentColor"})}),$&&z_("span",{children:Y("translate_trigger_fired")}),z_("span",{className:"cortex-trigger-block__name",children:_.name}),z_("time",{className:"cortex-trigger-block__time",dateTime:_.firedAt,children:a(_.firedAt,Q)})]}),$&&I0("details",{className:"cortex-trigger-block__payload",children:[z_("summary",{children:Y("translate_trigger_payload")}),z_(Q_,{data:_.payload,expandDepth:2})]})]})}import{jsx as i_}from"react/jsx-runtime";var m2=e4(function($){let{message:Y,metadata:Q,isStreaming:X,agentWorking:Z,closesTurn:G,debugMode:J,animate:V,fold:K,onOpenRun:N,workingTurn:z,frontier:F}=$,B=F_(Y.parts,{debugMode:J,isStreaming:X});if(Q?.trigger)return i_("div",{className:"cortex-message",children:i_(g2,{firing:Q.trigger,debugMode:J})});if(B.length===0&&!Q?.attachments?.length)return i_("div",{className:"cortex-message"});return i_("div",{className:U("cortex-message",z&&"cortex-message--working-turn"),children:i_(j2,{message:Y,parts:B,metadata:Q,debugMode:J,animate:V,isStreaming:X,agentWorking:Z,closesTurn:G,fold:K,onOpenRun:N,frontier:F})})});import{jsx as z1}from"react/jsx-runtime";var _7=[{role:"user",lines:[13,9]},{role:"assistant",lines:[16,18,12]},{role:"user",lines:[11]},{role:"assistant",lines:[14,15]}];function x2(){return z1("div",{className:"cortex-widget__messages-skeleton",children:_7.map((_,$)=>z1("div",{className:`cortex-widget__msg-skel cortex-widget__msg-skel--${_.role}`,children:z1("div",{className:`cortex-widget__msg-skel-bubble cortex-widget__msg-skel-bubble--${_.role}`,children:_.lines.map((Y)=>z1("div",{className:"cortex-skeleton cortex-widget__msg-skel-line",style:{width:`${Y}rem`}},Y))})},$))})}import{jsx as d,jsxs as W1,Fragment as G7}from"react/jsx-runtime";function Y7(_){let $=W_(null),Y=W_(null),Q=W_(!0),X=W_(!0),Z=W_(!1),G=n_(()=>{if(Z.current)return;Z.current=!0,queueMicrotask(()=>{Z.current=!1;let N=$.current;if(!N)return;Q1(N),X.current=!0,Q.current=!1})},[]);y0(()=>{let N=Y.current;if(!_||!$.current||!N)return;if(G(),typeof ResizeObserver>"u")return;let z=0,F=new ResizeObserver(([B])=>{let q=B?.contentRect.height??0,P=q>z;if(z=q,P&&(Q.current||X.current))G()});return F.observe(N),()=>F.disconnect()},[_,G]);let J=n_(()=>{Q.current=!0},[]),V=n_(()=>{if(Q.current)G()},[G]);function K(){let N=$.current;if(N)X.current=D0(N)<100}return{containerRef:$,contentRef:Y,onScroll:K,pin:J,settlePinned:V}}function Q7({pin:_,settlePinned:$,contentRef:Y},Q,X){let[Z,G]=S0(!1);y0(()=>{G(!1),_(),queueMicrotask(()=>G(!0))},[Q,_]);let J=X[X.length-1],V=J?.role==="user"?J.id:void 0,K=V?J?.parts.find((N)=>N.type==="text")?.content:void 0;return C0(()=>{if(!V)return;_();let N=Y.current;if(N&&K!==void 0)H0(N,K)},[V,K,_,Y]),y0(()=>{$()},[X,$]),Z}function X7(_,$,Y,Q){let[X,Z]=S0(new Set),G=n_((K)=>Z((N)=>new Set(N).add(K)),[]),[J]=S0(w1);return{folds:$7(()=>J(_,{agentWorking:$,debugMode:Y,opened:X,foldable:Q}),[J,_,$,Y,X,Q]),openRun:G}}function Z7({working:_}){let $=W_(null),Y=W_(void 0);return C0(()=>{let Q=$.current;if(!Q)return;let X=B0(Q);return Y.current=X,()=>{X.dispose(),Y.current=void 0}},[]),C0(()=>Y.current?.sync(_)),W1("div",{ref:$,className:"cortex-working-avatar","aria-hidden":"true",children:[W1("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d("path",{d:"M9.94 15.5a2 2 0 0 0-1.44-1.44l-6.13-1.58a.5.5 0 0 1 0-.96L8.5 9.94A2 2 0 0 0 9.94 8.5l1.58-6.14a.5.5 0 0 1 .96 0l1.58 6.14a2 2 0 0 0 1.44 1.44l6.14 1.58a.5.5 0 0 1 0 .96l-6.14 1.58a2 2 0 0 0-1.44 1.44l-1.58 6.14a.5.5 0 0 1-.96 0z"}),d("path",{d:"M20 3v4M22 5h-4M4 17v2M5 18H3"})]}),d("span",{className:"cortex-working-avatar__ring"})]})}function h2(_){let{config:$,selectedThread:Y}=L(),{messages:Q,isAgentWorking:X,isLoadingMessages:Z,hasPendingToolCalls:G}=L_(),{capabilities:J,composerRef:V,debugMode:K}=_,N=!Z||X,z=Y7(N),F=Q7(z,Y?.id,Q),B=X?S_(Q)?.id:void 0,q=$.toolComponents,P=n_((A)=>C1(A,q),[q]),{folds:O,openRun:H}=X7(Q,X,K,P),D=Q.map((A)=>A.role).lastIndexOf("user"),W=X&&!K,M=W?S1(Q,{foldable:P}):void 0;return W1(G7,{children:[!N?d(x2,{}):d("div",{className:_.className,children:d("div",{ref:z.containerRef,className:"cortex-message-list",onScroll:z.onScroll,children:W1("div",{ref:z.contentRef,className:"cortex-message-list__content",children:[Q.map((A,k)=>d(m2,{message:A,metadata:A.metadata,isStreaming:A.id===B,agentWorking:X,fold:O.get(A.id),onOpenRun:H,closesTurn:A.role==="assistant"&&Q[k+1]?.role!=="assistant",debugMode:K,animate:F,workingTurn:W&&k>D,frontier:A.id===B?M:void 0},A.id)),X&&!M&&d("div",{className:"cortex-working-thinking","data-cortex-frontier":"",children:d(N_,{activity:"reasoning"})}),d(Z7,{working:X},Y?.id)]})})}),!G&&d(X1,{capabilities:J,composerRef:V})]})}import{jsx as u2,jsxs as J7}from"react/jsx-runtime";function c2(_){let{debugMode:$,selectedThread:Y}=L(),{screens:Q}=_;return J7("div",{className:U("cortex-widget__screen",Q.screen==="chat"&&"cortex-widget__screen--active",Q.screen!=="chat"&&"cortex-widget__screen--right"),children:[_.header,Y?u2(h2,{className:"cortex-widget__messages",debugMode:$,capabilities:_.capabilities,composerRef:_.composerRef}):_.landing,u2("div",{className:"cortex-widget__sidebar-backdrop",onClick:Q.closeSidebar})]})}import{useState as W7}from"react";import{useEffect as w0,useRef as i2,useState as b0}from"react";import{useChat as z7}from"@tanstack/ai-react";import{useEffect as V7,useLayoutEffect as K7,useState as N7}from"react";function p2(_,{sessionRef:$,pendingSendRef:Y}){let[Q]=N7(_);return K7(()=>{return $.current=Q,()=>{if($.current===Q)$.current=void 0}},[Q,$]),V7(()=>{if(!Y.current.length)return;let X=setTimeout(()=>{let Z=Y.current;Y.current=[],(async()=>{for(let{prompt:G,attachments:J}of Z)await Q.send(G,J)})()});return()=>clearTimeout(X)},[Q,Y]),Q}import{useRef as d2}from"react";function l2(_){let $=d2(_);$.current=_;let Y=d2(Promise.resolve(void 0));async function Q(X){let Z=$.current;if(!Z.isAlive()||X!==Z.threadId)return;return T1({api:Z.api,threadId:X,isStale:()=>!$.current.isAlive(),isStreaming:()=>$.current.isStreaming(),setMessages:(G)=>$.current.setMessages(G)})}return function(Z){return Y.current=Y.current.then(()=>Q(Z)),Y.current}}function n2(_){let{thread:$,api:Y}=_,Q=i2(!0),[X,Z]=b0(!1),G=i2(null),J=l2({api:Y,threadId:$.id,isAlive:()=>Q.current,isStreaming:()=>G.current.chat.isLoading,setMessages:(D)=>G.current.chat.setMessages(D)}),[V]=b0(()=>q0({threadId:$.id,isAlive:()=>Q.current,onToolCall:()=>G.current.props.configRef.current.hooks?.onToolCall,deliver:(D)=>G.current.chat.addToolResult(D),setRunning:(D)=>G.current.props.setRunning($.id,D),reloadThreads:()=>G.current.props.reloadThreads(),refreshMessages:()=>J($.id),onTurnFinished:()=>G.current.props.onTurnFinished(),onSendFailed:()=>G.current.props.onSendFailed()})),[K]=b0(()=>b1({api:Y,thread:{id:$.id,isRunning:$.isRunning},mode:_.mode,localMessages:()=>G.current.chat.messages,onHydrated:(D)=>{if(Q.current)V.hydrated(D,$.isRunning)},onTranscriptCarried:(D)=>{if(Q.current)V.transcriptCarried(D)},setLoadingMessages:(D)=>{if(Q.current)Z(D)}})),N=z7({threadId:$.id,persistence:!0,initialMessages:_.initialMessages,connection:K,onChunk:()=>{if(Q.current)V.chunkArrived()},onError:()=>{if(Q.current)V.streamFailed()}});G.current={chat:N,props:_};async function z(D,W){V.sendStarted();let M={id:w_(),role:"user",parts:[{type:"text",content:D}],metadata:{createdAt:new Date().toISOString(),attachments:W}};await G.current.chat.append(M)}async function F(){if(!G.current.chat.isLoading)return;let{aborted:D}=await Y.abortStream($.id).catch(()=>({aborted:!1}));if(!Q.current)return;if(D)V.abortConfirmed();G.current.chat.stop()}function B(D,W,M){return G.current.chat.addToolResult({toolCallId:D,tool:W,output:M}).catch((A)=>{throw J($.id),A})}function q(D,W){return h1(G.current.chat,D,W)}function P(D){if(G.current.chat.isLoading)return;if(D.isRunning){G.current.props.remount(D,G.current.chat.messages);return}J(D.id)}w0(()=>{return Q.current=!0,()=>{Q.current=!1}},[]),p2(()=>({threadId:$.id,send:z,abort:F,addToolResult:B,respondToApproval:q,reattach:P,transcriptUpdated:(D,W)=>{if(D===$.id)V.transcriptUpdated(W)}}),{sessionRef:_.sessionRef,pendingSendRef:_.pendingSendRef});let{messages:O,isLoading:H}=N;return w0(()=>{V.loadingChanged(H,()=>G.current.chat.messages)},[V,H]),w0(()=>{G.current.props.publish({messages:O,isAgentWorking:H,isLoadingMessages:X,hasPendingToolCalls:!H&&$_(O).length>0})},[O,H,X]),null}import{jsx as H7,jsxs as D7}from"react/jsx-runtime";function r2({selection:_,threads:$,children:Y,...Q}){let{session:X}=_,[Z,G]=W7(),J=X&&`${X.thread.id}:${X.epoch}`,V=X&&Z&&(Z.key===J||X.mode==="reload")?Z.value:U0;return D7(L0.Provider,{value:V,children:[X&&J&&H7(n2,{thread:X.thread,mode:X.mode,initialMessages:X.initialMessages,setRunning:$.setRunning,reloadThreads:$.reload,remount:_.remount,publish:(K)=>G({key:J,value:K}),...Q},J),Y]})}import{jsx as S,jsxs as H_,Fragment as B7}from"react/jsx-runtime";function a2(_){let{locale:$,t:Y}=L(),{threads:Q}=_;return S("div",{className:"cortex-widget__threads-list",children:Q===void 0?[1,2,3,4].map((X)=>H_("div",{className:"cortex-widget__thread-skeleton",children:[S("div",{className:"cortex-skeleton cortex-widget__thread-skeleton-icon"}),S("div",{className:"cortex-widget__thread-skeleton-lines",children:S("div",{className:"cortex-skeleton cortex-widget__thread-skeleton-line",style:{width:`${40+X*12}%`}})})]},X)):H_(B7,{children:[Q.map((X)=>{let Z=X.id===_.selectedThreadId,G=a(X.updatedAt,$);return H_("button",{onClick:()=>_.openThread(X),className:U("cortex-widget__thread-item",Z&&"cortex-widget__thread-item--active"),children:[S("div",{className:U("cortex-widget__thread-icon",Z&&"cortex-widget__thread-icon--active"),children:S("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:S("path",{d:w.bubble,stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),H_("div",{className:"cortex-widget__thread-info",children:[H_("div",{className:"cortex-widget__thread-title-row",children:[S("p",{className:U("cortex-widget__thread-title",Z&&"cortex-widget__thread-title--active"),children:X.title??Y("translate_untitled")}),X.isRunning&&H_("span",{className:U("cortex-widget__thread-running",Z&&"cortex-widget__thread-running--active"),children:[S("span",{className:"cortex-widget__thread-running-dot"}),Y("translate_running")]})]}),G&&S("p",{className:"cortex-widget__thread-time",children:G})]}),S("span",{role:"button",tabIndex:0,onClick:(J)=>{J.stopPropagation(),_.deleteThread(X.id)},onKeyDown:(J)=>{if(J.key!=="Enter"&&J.key!==" ")return;J.preventDefault(),J.stopPropagation(),_.deleteThread(X.id)},className:U("cortex-widget__thread-delete",Z&&"cortex-widget__thread-delete--active"),children:S("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:S("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})})}),S("svg",{className:U("cortex-widget__thread-arrow",Z&&"cortex-widget__thread-arrow--active"),width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",children:S("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]},X.id)}),!Q.length&&H_("div",{className:"cortex-widget__threads-empty",children:[S("div",{className:"cortex-widget__threads-empty-icon",children:S("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",className:"cortex-widget__threads-empty-svg",children:S("path",{d:w.bubble,stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),S("p",{className:"cortex-widget__threads-empty-title",children:Y("translate_no_threads_yet")}),S("p",{className:"cortex-widget__threads-empty-subtitle",children:Y("translate_start_a_new_conversation")}),S("button",{onClick:_.newChat,className:"cortex-widget__new-chat-btn cortex-widget__new-chat-btn--empty-state",children:Y("translate_new_chat")})]})]})})}import{useSyncExternalStore as q7}from"react";function o2(_){return q7(($)=>{let Y=window.matchMedia(_);return Y.addEventListener("change",$),()=>Y.removeEventListener("change",$)},()=>window.matchMedia(_).matches,()=>!1)}import{jsx as U7,jsxs as t2}from"react/jsx-runtime";var F7="(max-width: 768px)";function s2(_){_.preventDefault()}function e2(_){let{screens:$}=_,Y=o2(F7),Q=_.viewMode==="full"?Y&&!$.sidebarOpen:$.screen!=="threads";return U7("div",{className:U("cortex-widget",_.className),"data-cortex-theme":_.theme,children:t2("div",{className:U("cortex-widget__container",_.viewMode==="full"&&"cortex-widget__container--full",$.sidebarOpen&&"cortex-widget__container--sidebar-open"),onDragOver:s2,onDrop:s2,children:[t2("div",{className:U("cortex-widget__screen",$.screen==="threads"&&"cortex-widget__screen--active",$.screen!=="threads"&&"cortex-widget__screen--left"),"aria-hidden":Q||void 0,inert:Q||void 0,children:[_.header,_.threadList]}),_.children]})})}import{jsx as l}from"react/jsx-runtime";var P7={header:s6,landing:e6,threadList:a2};function T0(_,$){return _?.[$]??P7[$]}function O7(_){let{isAgentWorking:$}=L_();return l(_.component,{..._.context,isWorking:$})}function M7({config:_,className:$,slots:Y}){let Q=_5(_);Q.current=_;let[X]=H1(()=>P1(()=>Q.current.transport)),Z=h6(X),[G,J]=H1(!1),[V,K]=H1();L7(()=>G0(_.theme,K),[_.theme]);let N=_.viewMode??"helper",z=c6(N),[F,B]=H1(0),q=S6(X,F),P=_5(null),O=j6({api:X,threads:Z,getHooks:()=>Q.current.hooks}),{sessionRef:H,selection:D,queue:W,send:M,pendingSendRef:A}=O,{selected:k,selectedRef:i}=D,G_=m6({threads:Z,selectedRef:i,sessionRef:H,deselect:D.deselect,onReconnect:()=>B((m)=>m+1)});g6({getConfig:()=>Q.current,onEvent:G_.onEvent,onMount:()=>void Z.reload(),onReconnect:G_.onReconnect});let r_=O1(_.locale),$5={config:_,locale:r_,t:(m,D1)=>n(r_,m,D1),api:X,debugMode:G,scheme:V,capabilities:q,selectedThread:k,send:M,...x6(H),queue:W.value};function Y5(){W.store.discardConsumed(),setTimeout(()=>P.current?.focusInput())}function Q5(){W.store.restoreConsumed(i.current?.id)}function v0(m){O.openThread(m),z.showChat()}function f0(){D.deselect(),z.showChat()}function X5(){J((m)=>!m)}function j0(m){let D1={screen:m,viewMode:N,title:k?.title??null,agentName:q_(_.agentName,r_),threadCount:Z.threads?.length??0,debug:{shown:Boolean(_.showDebugButton),on:G},newChat:f0,openHistory:z.openHistory,closeHistory:z.closeHistory,toggleDebug:X5};return l(O7,{component:T0(Y,"header"),context:D1})}let Z5=T0(Y,"landing"),G5={...M1(q,r_,(m)=>void M(m)),threads:Z.threads,composer:l("div",{className:"cortex-widget__landing-composer",children:l(X1,{capabilities:q})}),openThread:v0,openHistory:z.openHistory},J5=T0(Y,"threadList"),V5={threads:Z.threads,selectedThreadId:k?.id,openThread:v0,deleteThread:(m)=>void O.deleteThread(m),newChat:f0};return l(F0.Provider,{value:$5,children:l(r2,{selection:D,threads:Z,api:X,configRef:Q,sessionRef:H,pendingSendRef:A,onTurnFinished:Y5,onSendFailed:Q5,children:l(e2,{className:$,theme:_.theme,viewMode:N,screens:z,header:j0("threads"),threadList:l(J5,{...V5}),children:l(c2,{screens:z,capabilities:q,composerRef:P,header:j0("chat"),landing:l(Z5,{...G5})})})})})}export{M7 as CortexChatWidget};
|
package/dist/styles.css
CHANGED
|
@@ -33,8 +33,6 @@
|
|
|
33
33
|
* without touching anything else. */
|
|
34
34
|
--cortex-color-user-surface: var(--cortex-color-surface-subtle);
|
|
35
35
|
--cortex-color-user-border: var(--cortex-color-border);
|
|
36
|
-
/* Code blocks sit a step below the bubble they are in, in either scheme. */
|
|
37
|
-
--cortex-color-code-surface: light-dark(#e8edf3, #111111);
|
|
38
36
|
--cortex-color-code-text: light-dark(#334155, #e5e5e5);
|
|
39
37
|
--cortex-color-success: light-dark(#059669, #34d399);
|
|
40
38
|
--cortex-color-success-surface: light-dark(#ecfdf5, #064e3b);
|
|
@@ -56,12 +54,15 @@
|
|
|
56
54
|
);
|
|
57
55
|
--cortex-font-size: 0.8125rem;
|
|
58
56
|
/* These read --cortex-font-size (or the color named) when unset, so they ship
|
|
59
|
-
* unset: declaring one here gives that part its own value.
|
|
57
|
+
* unset: declaring one here gives that part its own value. Code blocks default
|
|
58
|
+
* to a tint of the heading color, so they stand a step off whatever they sit
|
|
59
|
+
* on: the transcript, the user's bubble, or a host's own surface.
|
|
60
60
|
*
|
|
61
|
-
* --cortex-font-size-message: 0.875rem; message
|
|
61
|
+
* --cortex-font-size-message: 0.875rem; message text and the composer
|
|
62
62
|
* --cortex-font-size-header: 0.875rem; the chat and history titles
|
|
63
63
|
* --cortex-color-send-empty: transparent; the send button with nothing to send
|
|
64
64
|
* --cortex-color-send-empty-text: var(--cortex-color-text-muted);
|
|
65
|
+
* --cortex-color-code-surface: color-mix(in oklab, var(--cortex-color-text-heading) 8%, transparent);
|
|
65
66
|
*/
|
|
66
67
|
/* The widget's headings read --cortex-font-display and fall back to `inherit`,
|
|
67
68
|
* so it ships unset on purpose — declaring it here is how you opt in:
|
|
@@ -315,20 +316,16 @@
|
|
|
315
316
|
|
|
316
317
|
.cortex-widget__msg-skel-bubble {
|
|
317
318
|
max-width: 80%;
|
|
318
|
-
padding: 1rem;
|
|
319
|
-
border-radius: calc(var(--cortex-radius) * 2);
|
|
320
|
-
border: 1px solid var(--cortex-color-border);
|
|
321
319
|
display: flex;
|
|
322
320
|
flex-direction: column;
|
|
323
321
|
gap: 0.5rem;
|
|
324
322
|
}
|
|
325
323
|
.cortex-widget__msg-skel-bubble--user {
|
|
324
|
+
padding: 0.75rem 1rem;
|
|
325
|
+
border-radius: calc(var(--cortex-radius) * 2);
|
|
326
|
+
border-end-end-radius: 0;
|
|
327
|
+
border: 1px solid var(--cortex-color-border);
|
|
326
328
|
background: var(--cortex-color-surface-subtle);
|
|
327
|
-
border-bottom-right-radius: 0;
|
|
328
|
-
}
|
|
329
|
-
.cortex-widget__msg-skel-bubble--assistant {
|
|
330
|
-
background: var(--cortex-color-surface-muted);
|
|
331
|
-
border-bottom-left-radius: 0;
|
|
332
329
|
}
|
|
333
330
|
|
|
334
331
|
.cortex-widget__msg-skel-line {
|
|
@@ -384,13 +381,13 @@
|
|
|
384
381
|
background: var(--cortex-color-surface);
|
|
385
382
|
}
|
|
386
383
|
.cortex-widget__container--full .cortex-message-list {
|
|
387
|
-
padding: 1.5rem 2rem;
|
|
384
|
+
padding: 1.5rem max(2rem, (100% - 48rem) / 2);
|
|
388
385
|
}
|
|
389
386
|
.cortex-widget__container--full .cortex-widget__messages-skeleton {
|
|
390
|
-
padding: 1.5rem 2rem;
|
|
387
|
+
padding: 1.5rem max(2rem, (100% - 48rem) / 2);
|
|
391
388
|
}
|
|
392
389
|
.cortex-widget__container--full .cortex-widget__input-area {
|
|
393
|
-
padding: 0.75rem 2rem 1.25rem;
|
|
390
|
+
padding: 0.75rem max(2rem, (100% - 48rem) / 2) 1.25rem;
|
|
394
391
|
}
|
|
395
392
|
@media (max-width: 768px) {
|
|
396
393
|
.cortex-widget__container--full > .cortex-widget__screen:first-child {
|
|
@@ -1425,46 +1422,27 @@ cortex-llm-usage-chips {
|
|
|
1425
1422
|
display: flex;
|
|
1426
1423
|
flex-direction: column;
|
|
1427
1424
|
}
|
|
1428
|
-
.cortex-text-part--assistant {
|
|
1429
|
-
align-items: flex-start;
|
|
1430
|
-
}
|
|
1431
1425
|
.cortex-text-part--user {
|
|
1432
1426
|
align-items: flex-end;
|
|
1433
1427
|
}
|
|
1434
|
-
[dir=rtl] .cortex-text-part--assistant {
|
|
1435
|
-
align-items: flex-start;
|
|
1436
|
-
}
|
|
1437
|
-
[dir=rtl] .cortex-text-part--user {
|
|
1438
|
-
align-items: flex-end;
|
|
1439
|
-
}
|
|
1440
1428
|
|
|
1441
1429
|
.cortex-text-bubble {
|
|
1442
|
-
max-width: 80%;
|
|
1443
1430
|
min-width: 0;
|
|
1444
1431
|
overflow-wrap: anywhere;
|
|
1445
1432
|
font-size: var(--cortex-font-size-message, var(--cortex-font-size));
|
|
1446
1433
|
line-height: 1.625;
|
|
1447
|
-
padding: 1rem;
|
|
1448
|
-
border-radius: calc(var(--cortex-radius) * 2);
|
|
1449
|
-
border: 1px solid var(--cortex-color-border);
|
|
1450
1434
|
color: var(--cortex-color-text-strong);
|
|
1451
1435
|
}
|
|
1452
1436
|
.cortex-text-bubble--assistant {
|
|
1453
|
-
|
|
1454
|
-
border-bottom-left-radius: 0;
|
|
1455
|
-
}
|
|
1456
|
-
[dir=rtl] .cortex-text-bubble--assistant {
|
|
1457
|
-
border-bottom-left-radius: calc(var(--cortex-radius) * 2);
|
|
1458
|
-
border-bottom-right-radius: 0;
|
|
1437
|
+
width: calc(100% - 2rem);
|
|
1459
1438
|
}
|
|
1460
1439
|
.cortex-text-bubble--user {
|
|
1440
|
+
max-width: 80%;
|
|
1441
|
+
padding: 0.75rem 1rem;
|
|
1442
|
+
border-radius: calc(var(--cortex-radius) * 2);
|
|
1443
|
+
border-end-end-radius: 0;
|
|
1444
|
+
border: 1px solid var(--cortex-color-user-border);
|
|
1461
1445
|
background: var(--cortex-color-user-surface);
|
|
1462
|
-
border-color: var(--cortex-color-user-border);
|
|
1463
|
-
border-bottom-right-radius: 0;
|
|
1464
|
-
}
|
|
1465
|
-
[dir=rtl] .cortex-text-bubble--user {
|
|
1466
|
-
border-bottom-right-radius: calc(var(--cortex-radius) * 2);
|
|
1467
|
-
border-bottom-left-radius: 0;
|
|
1468
1446
|
}
|
|
1469
1447
|
.cortex-text-bubble h1,
|
|
1470
1448
|
.cortex-text-bubble h2,
|
|
@@ -1532,7 +1510,7 @@ cortex-llm-usage-chips {
|
|
|
1532
1510
|
margin-top: 0.75em;
|
|
1533
1511
|
margin-bottom: 0.75em;
|
|
1534
1512
|
padding: 0.75em 1em;
|
|
1535
|
-
background: var(--cortex-color-code-surface);
|
|
1513
|
+
background: var(--cortex-color-code-surface, color-mix(in oklab, var(--cortex-color-text-heading) 8%, transparent));
|
|
1536
1514
|
border-radius: var(--cortex-radius);
|
|
1537
1515
|
max-width: 100%;
|
|
1538
1516
|
overflow-x: auto;
|
|
@@ -1814,14 +1792,17 @@ cortex-llm-usage-chips {
|
|
|
1814
1792
|
.cortex-media-block__body--map > div {
|
|
1815
1793
|
height: 100%;
|
|
1816
1794
|
}
|
|
1795
|
+
.cortex-media-block__body--report {
|
|
1796
|
+
padding: 1rem;
|
|
1797
|
+
}
|
|
1817
1798
|
|
|
1818
1799
|
.cortex-expandable__body .cortex-media-block__body {
|
|
1819
1800
|
width: min(72rem, 100vw - 2rem - 2px);
|
|
1820
1801
|
}
|
|
1821
|
-
.cortex-expandable__body .cortex-media-block__body:not(.cortex-media-block__body--map) > div {
|
|
1802
|
+
.cortex-expandable__body .cortex-media-block__body:not(.cortex-media-block__body--map, .cortex-media-block__body--report) > div {
|
|
1822
1803
|
display: grid;
|
|
1823
1804
|
}
|
|
1824
|
-
.cortex-expandable__body .cortex-media-block__body:not(.cortex-media-block__body--map) svg {
|
|
1805
|
+
.cortex-expandable__body .cortex-media-block__body:not(.cortex-media-block__body--map, .cortex-media-block__body--report) svg {
|
|
1825
1806
|
width: 100%;
|
|
1826
1807
|
max-width: none !important;
|
|
1827
1808
|
max-height: calc(100dvh - 6.5rem);
|
package/dist/theme.css
CHANGED
|
@@ -37,8 +37,6 @@
|
|
|
37
37
|
--cortex-color-user-surface: var(--cortex-color-surface-subtle);
|
|
38
38
|
--cortex-color-user-border: var(--cortex-color-border);
|
|
39
39
|
|
|
40
|
-
/* Code blocks sit a step below the bubble they are in, in either scheme. */
|
|
41
|
-
--cortex-color-code-surface: light-dark(#e8edf3, #111111);
|
|
42
40
|
--cortex-color-code-text: light-dark(#334155, #e5e5e5);
|
|
43
41
|
|
|
44
42
|
--cortex-color-success: light-dark(#059669, #34d399);
|
|
@@ -64,12 +62,15 @@
|
|
|
64
62
|
--cortex-font-size: 0.8125rem;
|
|
65
63
|
|
|
66
64
|
/* These read --cortex-font-size (or the color named) when unset, so they ship
|
|
67
|
-
* unset: declaring one here gives that part its own value.
|
|
65
|
+
* unset: declaring one here gives that part its own value. Code blocks default
|
|
66
|
+
* to a tint of the heading color, so they stand a step off whatever they sit
|
|
67
|
+
* on: the transcript, the user's bubble, or a host's own surface.
|
|
68
68
|
*
|
|
69
|
-
* --cortex-font-size-message: 0.875rem; message
|
|
69
|
+
* --cortex-font-size-message: 0.875rem; message text and the composer
|
|
70
70
|
* --cortex-font-size-header: 0.875rem; the chat and history titles
|
|
71
71
|
* --cortex-color-send-empty: transparent; the send button with nothing to send
|
|
72
72
|
* --cortex-color-send-empty-text: var(--cortex-color-text-muted);
|
|
73
|
+
* --cortex-color-code-surface: color-mix(in oklab, var(--cortex-color-text-heading) 8%, transparent);
|
|
73
74
|
*/
|
|
74
75
|
|
|
75
76
|
/* The widget's headings read --cortex-font-display and fall back to `inherit`,
|