import{Bi as Q,Ci as I,Oj as W,RM as Y,Rj as P,yN as R}from"./cli-0.5.3-jbzr8k4s.mjs";import{Lca as J,Mca as F}from"./cli-0.5.3-9bdwhdys.mjs";import{Aea as f,dea as B,eea as H}from"./cli-0.5.3-6j2jk6dt.mjs";import{gma as $,pia as v}from"./cli-0.5.3-qrvd6cmy.mjs";import{Xma as Z}from"./cli-0.5.3-0df3r78b.mjs";import{randomUUID as U}from"crypto";function S(j){return j.flatMap((h)=>{switch(h.type){case"assistant":return[{type:"assistant",message:h.message,uuid:h.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case"user":return[{type:"user",message:h.message,uuid:h.uuid??U(),timestamp:h.timestamp??new Date().toISOString(),isMeta:h.isSynthetic}];case"system":if(h.subtype==="compact_boundary")return[{type:"system",content:"Conversation compacted",level:"info",subtype:"compact_boundary",compactMetadata:X(h.compact_metadata),uuid:h.uuid,timestamp:new Date().toISOString()}];return[];default:return[]}})}function V(j){let h=j.preservedSegment;return{trigger:j.trigger,pre_tokens:j.preTokens,...h&&{preserved_segment:{head_uuid:h.headUuid,anchor_uuid:h.anchorUuid,tail_uuid:h.tailUuid}}}}function X(j){let h=j.preserved_segment;return{trigger:j.trigger,preTokens:j.pre_tokens,...h&&{preservedSegment:{headUuid:h.head_uuid,anchorUuid:h.anchor_uuid,tailUuid:h.tail_uuid}}}}function r(j){return j.flatMap((h)=>{switch(h.type){case"assistant":return[{type:"assistant",message:z(h),session_id:v(),parent_tool_use_id:null,uuid:h.uuid,error:h.error}];case"user":return[{type:"user",message:h.message,session_id:v(),parent_tool_use_id:null,uuid:h.uuid,timestamp:h.timestamp,isSynthetic:h.isMeta||h.isVisibleInTranscriptOnly,...h.toolUseResult!==void 0?{tool_use_result:h.toolUseResult}:{}}];case"system":if(h.subtype==="compact_boundary"&&h.compactMetadata)return[{type:"system",subtype:"compact_boundary",session_id:v(),uuid:h.uuid,compact_metadata:V(h.compactMetadata)}];if(h.subtype==="local_command"&&(h.content.includes(`<${B}>`)||h.content.includes(`<${H}>`)))return[w(h.content,h.uuid)];return[];default:return[]}})}function w(j,h){let x=J(j).replace(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/,"$1").replace(/<local-command-stderr>([\s\S]*?)<\/local-command-stderr>/,"$1").trim();return{type:"assistant",message:Y({content:x}).message,parent_tool_use_id:null,session_id:v(),uuid:h}}function T(j){if(!j)return;return{status:j.status,...j.resetsAt!==void 0&&{resetsAt:j.resetsAt},...j.rateLimitType!==void 0&&{rateLimitType:j.rateLimitType},...j.utilization!==void 0&&{utilization:j.utilization},...j.overageStatus!==void 0&&{overageStatus:j.overageStatus},...j.overageResetsAt!==void 0&&{overageResetsAt:j.overageResetsAt},...j.overageDisabledReason!==void 0&&{overageDisabledReason:j.overageDisabledReason},...j.isUsingOverage!==void 0&&{isUsingOverage:j.isUsingOverage},...j.surpassedThreshold!==void 0&&{surpassedThreshold:j.surpassedThreshold}}}function z(j){let h=j.message.content;if(!Array.isArray(h))return j.message;let x=h.map((q)=>{if(q.type!=="tool_use")return q;if(q.name===Q){let y=W();if(y)return{...q,input:{...q.input,plan:y}}}return q});return{...j.message,content:x}}var G=Z(()=>{$();f();I();F();R();P()});
export{S as Qd,V as Rd,X as Sd,r as Td,w as Ud,T as Vd,G as Wd};
