import{AK as c,AN as X0,BK as jQ,Fh as XQ,Gq as N,Hq as vQ,OO as VQ,Ow as d,Pw as DQ,VO as zQ,XO as BQ,Yq as YQ,Zq as RQ,eP as Y0,oi as u}from"./cli-0.5.4-k5fz4zd3.mjs";import"./cli-0.5.4-wbqf44ym.mjs";import"./cli-0.5.4-9ewg9gfs.mjs";import"./cli-0.5.4-we3mspgg.mjs";import"./cli-0.5.4-jzhazry0.mjs";import"./cli-0.5.4-82sw3hrw.mjs";import"./cli-0.5.4-31v143kt.mjs";import"./cli-0.5.4-1cy7wd6s.mjs";import"./cli-0.5.4-5e0pk96f.mjs";import"./cli-0.5.4-z154a7bp.mjs";import"./cli-0.5.4-ng5p0zjs.mjs";import"./cli-0.5.4-5hp7ks3t.mjs";import"./cli-0.5.4-8hdwp78f.mjs";import"./cli-0.5.4-mr9aznxx.mjs";import"./cli-0.5.4-jevfk5q7.mjs";import"./cli-0.5.4-27dzbzdy.mjs";import"./cli-0.5.4-a5bkdqqb.mjs";import"./cli-0.5.4-j2hnw539.mjs";import"./cli-0.5.4-9w59nnw4.mjs";import"./cli-0.5.4-z5d3q8kh.mjs";import"./cli-0.5.4-c0r12dqp.mjs";import"./cli-0.5.4-kqh172jk.mjs";import"./cli-0.5.4-vv4jbgkc.mjs";import"./cli-0.5.4-s7k1f0wc.mjs";import"./cli-0.5.4-0h0yz2k5.mjs";import"./cli-0.5.4-942dm5q1.mjs";import"./cli-0.5.4-rcmp5h4y.mjs";import"./cli-0.5.4-xdcww3x8.mjs";import"./cli-0.5.4-fq32ny1h.mjs";import"./cli-0.5.4-h1m67ngp.mjs";import"./cli-0.5.4-49erze3e.mjs";import"./cli-0.5.4-jytjks37.mjs";import"./cli-0.5.4-mn22gk7g.mjs";import"./cli-0.5.4-5t3jj85n.mjs";import"./cli-0.5.4-5shjmmkz.mjs";import"./cli-0.5.4-zb412kkm.mjs";import"./cli-0.5.4-prfn3sxd.mjs";import"./cli-0.5.4-6xmgebmk.mjs";import"./cli-0.5.4-vjgejcrz.mjs";import{R1 as PQ,u1 as o}from"./cli-0.5.4-jqt00ywx.mjs";import"./cli-0.5.4-9e7rkd8e.mjs";import"./cli-0.5.4-jp4wtw87.mjs";import"./cli-0.5.4-hambpq58.mjs";import"./cli-0.5.4-syvgmg9g.mjs";import"./cli-0.5.4-w8ttefr5.mjs";import"./cli-0.5.4-j7kkqxv6.mjs";import"./cli-0.5.4-qrwczx7j.mjs";import"./cli-0.5.4-v2z6p9td.mjs";import{$_ as JQ,B6 as i,J6 as NQ,f$ as _Q}from"./cli-0.5.4-cbq01zg3.mjs";import"./cli-0.5.4-37v5fhf1.mjs";import"./cli-0.5.4-7grzwf6q.mjs";import"./cli-0.5.4-9qmek5dq.mjs";import{Ada as GQ,xda as QQ,yda as $Q}from"./cli-0.5.4-9c6r1fjg.mjs";import"./cli-0.5.4-2dw33ms6.mjs";import"./cli-0.5.4-x1fzfxmm.mjs";import"./cli-0.5.4-e822fzaq.mjs";import"./cli-0.5.4-09dvrzcr.mjs";import{sfa as b,tfa as h,xfa as OQ}from"./cli-0.5.4-end8wj9r.mjs";import"./cli-0.5.4-4x206j04.mjs";import{$fa as s,mga as LQ}from"./cli-0.5.4-yd3rd9qt.mjs";import{Fga as l,Nga as WQ}from"./cli-0.5.4-sgcaw17t.mjs";import"./cli-0.5.4-jmc3bzbn.mjs";import"./cli-0.5.4-959vxhhb.mjs";import{Zma as UQ}from"./cli-0.5.4-aacw1src.mjs";import{mkdir as n,readdir as EQ,readFile as qQ,unlink as wQ,writeFile as a}from"fs/promises";import{extname as FQ,join as H}from"path";function ZQ(){return o()}function xQ(){return o()}function g(){return H(s(),"usage-data")}function m(){return H(g(),"facets")}function r(){return H(g(),"session-meta")}function CQ(Q){let $=FQ(Q).toLowerCase();return AQ[$]||null}function HQ(Q){let $={},J={},Y=0,q=0,B=0,V=0,X=0,K=[],z=0,O={},R=!1,E=0,v=0,A=new Set,I=[],T=[],M=!1,L=!1,F=!1,y=null;for(let w of Q.messages){let x=w.timestamp;if(w.type==="assistant"&&w.message){if(x)y=x;let U=w.message.usage;if(U)B+=U.input_tokens||0,V+=U.output_tokens||0;let j=w.message.content;if(Array.isArray(j)){for(let Z of j)if(Z.type==="tool_use"&&"name"in Z){let W=Z.name;if($[W]=($[W]||0)+1,W===QQ||W===$Q)R=!0;if(W.startsWith("mcp__"))M=!0;if(W==="WebSearch")L=!0;if(W==="WebFetch")F=!0;let _=Z.input;if(_){let P=_.file_path||"";if(P){let D=CQ(P);if(D)J[D]=(J[D]||0)+1;if(W==="Edit"||W==="Write")A.add(P)}if(W==="Edit"){let D=_.old_string||"",k=_.new_string||"";for(let f of YQ(D,k)){if(f.added)E+=f.count||0;if(f.removed)v+=f.count||0}}if(W==="Write"){let D=_.content||"";if(D)E+=JQ(D,`
`)+1}let G=_.command||"";if(G.includes("git commit"))Y++;if(G.includes("git push"))q++}}}}if(w.type==="user"&&w.message){let U=w.message.content,j=!1;if(typeof U==="string"&&U.trim())j=!0;else if(Array.isArray(U)){for(let Z of U)if(Z.type==="text"&&"text"in Z){j=!0;break}}if(j){if(x)try{let W=new Date(x).getHours();I.push(W),T.push(x)}catch{}if(y&&x){let Z=new Date(y).getTime(),_=(new Date(x).getTime()-Z)/1000;if(_>2&&_<3600)K.push(_)}}if(Array.isArray(U)){for(let Z of U)if(Z.type==="tool_result"&&"content"in Z){if(Z.is_error){z++;let _=Z.content,P="Other";if(typeof _==="string"){let G=_.toLowerCase();if(G.includes("exit code"))P="Command Failed";else if(G.includes("rejected")||G.includes("doesn't want"))P="User Rejected";else if(G.includes("string to replace not found")||G.includes("no changes"))P="Edit Failed";else if(G.includes("modified since read"))P="File Changed";else if(G.includes("exceeds maximum")||G.includes("too large"))P="File Too Large";else if(G.includes("file not found")||G.includes("does not exist"))P="File Not Found"}O[P]=(O[P]||0)+1}}}if(typeof U==="string"){if(U.includes("[Request interrupted by user"))X++}else if(Array.isArray(U)){for(let Z of U)if(Z.type==="text"&&"text"in Z&&Z.text.includes("[Request interrupted by user")){X++;break}}}}return{toolCounts:$,languages:J,gitCommits:Y,gitPushes:q,inputTokens:B,outputTokens:V,userInterruptions:X,userResponseTimes:K,toolErrors:z,toolErrorCategories:O,usesTaskAgent:R,usesMcp:M,usesWebSearch:L,usesWebFetch:F,linesAdded:E,linesRemoved:v,filesModified:A,messageHours:I,userMessageTimestamps:T}}function TQ(Q){return!Number.isNaN(Q.created.getTime())&&!Number.isNaN(Q.modified.getTime())}function t(Q){let $=HQ(Q),J=VQ(Q)||"unknown",Y=Q.created.toISOString(),q=Math.round((Q.modified.getTime()-Q.created.getTime())/1000/60),B=0,V=0;for(let X of Q.messages){if(X.type==="assistant")V++;if(X.type==="user"&&X.message){let K=X.message.content,z=!1;if(typeof K==="string"&&K.trim())z=!0;else if(Array.isArray(K)){for(let O of K)if(O.type==="text"&&"text"in O){z=!0;break}}if(z)B++}}return{session_id:J,project_path:Q.projectPath||"",start_time:Y,duration_minutes:q,user_message_count:B,assistant_message_count:V,tool_counts:$.toolCounts,languages:$.languages,git_commits:$.gitCommits,git_pushes:$.gitPushes,input_tokens:$.inputTokens,output_tokens:$.outputTokens,first_prompt:Q.firstPrompt||"",summary:Q.summary,user_interruptions:$.userInterruptions,user_response_times:$.userResponseTimes,tool_errors:$.toolErrors,tool_error_categories:$.toolErrorCategories,uses_task_agent:$.usesTaskAgent,uses_mcp:$.usesMcp,uses_web_search:$.usesWebSearch,uses_web_fetch:$.usesWebFetch,lines_added:$.linesAdded,lines_removed:$.linesRemoved,files_modified:$.filesModified.size,message_hours:$.messageHours,user_message_timestamps:$.userMessageTimestamps}}function R0(Q){let $=new Map;for(let J of Q){let Y=J.meta.session_id,q=$.get(Y);if(!q||J.meta.user_message_count>q.meta.user_message_count||J.meta.user_message_count===q.meta.user_message_count&&J.meta.duration_minutes>q.meta.duration_minutes)$.set(Y,J)}return[...$.values()]}function yQ(Q){let $=[],J=t(Q);$.push(`Session: ${J.session_id.slice(0,8)}`),$.push(`Date: ${J.start_time}`),$.push(`Project: ${J.project_path}`),$.push(`Duration: ${J.duration_minutes} min`),$.push("");for(let Y of Q.messages)if(Y.type==="user"&&Y.message){let q=Y.message.content;if(typeof q==="string")$.push(`[User]: ${q.slice(0,500)}`);else if(Array.isArray(q)){for(let B of q)if(B.type==="text"&&"text"in B)$.push(`[User]: ${B.text.slice(0,500)}`)}}else if(Y.type==="assistant"&&Y.message){let q=Y.message.content;if(Array.isArray(q)){for(let B of q)if(B.type==="text"&&"text"in B)$.push(`[Assistant]: ${B.text.slice(0,300)}`);else if(B.type==="tool_use"&&"name"in B)$.push(`[Tool: ${B.name}]`)}}return $.join(`
`)}async function SQ(Q){try{let $=await c({systemPrompt:d([]),userPrompt:kQ+Q,signal:new AbortController().signal,options:{model:ZQ(),querySource:"insights",agents:[],isNonInteractiveSession:!0,hasAppendSystemPrompt:!1,mcpTools:[],maxOutputTokensOverride:500}});return u($.message.content)||Q.slice(0,2000)}catch{return Q.slice(0,2000)}}async function bQ(Q){let $=yQ(Q);if($.length<=30000)return $;let J=25000,Y=[];for(let X=0;X<$.length;X+=J)Y.push($.slice(X,X+J));let q=await Promise.all(Y.map(SQ)),B=t(Q);return[`Session: ${B.session_id.slice(0,8)}`,`Date: ${B.start_time}`,`Project: ${B.project_path}`,`Duration: ${B.duration_minutes} min`,`[Long session - ${Y.length} parts summarized]`,""].join(`
`)+q.join(`

---

`)}async function hQ(Q){let $=H(m(),`${Q}.json`);try{let J=await qQ($,{encoding:"utf-8"}),Y=h(J);if(!KQ(Y)){try{await wQ($)}catch{}return null}return Y}catch{return null}}async function fQ(Q){try{await n(m(),{recursive:!0})}catch{}let $=H(m(),`${Q.session_id}.json`);await a($,b(Q,null,2),{encoding:"utf-8",mode:384})}async function pQ(Q){let $=H(r(),`${Q}.json`);try{let J=await qQ($,{encoding:"utf-8"});return h(J)}catch{return null}}async function gQ(Q){try{await n(r(),{recursive:!0})}catch{}let $=H(r(),`${Q.session_id}.json`);await a($,b(Q,null,2),{encoding:"utf-8",mode:384})}async function mQ(Q,$){try{let J=await bQ(Q),Y=`${MQ}${J}

RESPOND WITH ONLY A VALID JSON OBJECT matching this schema:
{
  "underlying_goal": "What the user fundamentally wanted to achieve",
  "goal_categories": {"category_name": count, ...},
  "outcome": "fully_achieved|mostly_achieved|partially_achieved|not_achieved|unclear_from_transcript",
  "user_satisfaction_counts": {"level": count, ...},
  "claude_helpfulness": "unhelpful|slightly_helpful|moderately_helpful|very_helpful|essential",
  "session_type": "single_task|multi_task|iterative_refinement|exploration|quick_question",
  "friction_counts": {"friction_type": count, ...},
  "friction_detail": "One sentence describing friction or empty",
  "primary_success": "none|fast_accurate_search|correct_code_edits|good_explanations|proactive_help|multi_file_changes|good_debugging",
  "brief_summary": "One sentence: what user wanted and whether they got it"
}`,q=await c({systemPrompt:d([]),userPrompt:Y,signal:new AbortController().signal,options:{model:ZQ(),querySource:"insights",agents:[],isNonInteractiveSession:!0,hasAppendSystemPrompt:!1,mcpTools:[],maxOutputTokensOverride:4096}}),V=u(q.message.content).match(/\{[\s\S]*\}/);if(!V)return null;let X=h(V[0]);if(!KQ(X))return null;return{...X,session_id:$}}catch(J){return i(Error(`Facet extraction failed: ${l(J).message}`)),null}}function uQ(Q){let J=[];for(let K of Q)for(let z of K.user_message_timestamps)try{let O=new Date(z).getTime();J.push({ts:O,sessionId:K.session_id})}catch{}J.sort((K,z)=>K.ts-z.ts);let Y=new Set,q=new Set,B=0,V=new Map;for(let K=0;K<J.length;K++){let z=J[K];while(B<K&&z.ts-J[B].ts>1800000){let R=J[B];if(V.get(R.sessionId)===B)V.delete(R.sessionId);B++}let O=V.get(z.sessionId);if(O!==void 0)for(let R=O+1;R<K;R++){let E=J[R];if(E.sessionId!==z.sessionId){let v=[z.sessionId,E.sessionId].sort().join(":");Y.add(v),q.add(`${J[O].ts}:${z.sessionId}`),q.add(`${E.ts}:${E.sessionId}`),q.add(`${z.ts}:${z.sessionId}`);break}}V.set(z.sessionId,K)}let X=new Set;for(let K of Y){let[z,O]=K.split(":");if(z)X.add(z);if(O)X.add(O)}return{overlap_events:Y.size,sessions_involved:X.size,user_messages_during:q.size}}function dQ(Q,$){let J={total_sessions:Q.length,sessions_with_facets:$.size,date_range:{start:"",end:""},total_messages:0,total_duration_hours:0,total_input_tokens:0,total_output_tokens:0,tool_counts:{},languages:{},git_commits:0,git_pushes:0,projects:{},goal_categories:{},outcomes:{},satisfaction:{},helpfulness:{},session_types:{},friction:{},success:{},session_summaries:[],total_interruptions:0,total_tool_errors:0,tool_error_categories:{},user_response_times:[],median_response_time:0,avg_response_time:0,sessions_using_task_agent:0,sessions_using_mcp:0,sessions_using_web_search:0,sessions_using_web_fetch:0,total_lines_added:0,total_lines_removed:0,total_files_modified:0,days_active:0,messages_per_day:0,message_hours:[],multi_clauding:{overlap_events:0,sessions_involved:0,user_messages_during:0}},Y=[],q=[],B=[];for(let X of Q){Y.push(X.start_time),J.total_messages+=X.user_message_count,J.total_duration_hours+=X.duration_minutes/60,J.total_input_tokens+=X.input_tokens,J.total_output_tokens+=X.output_tokens,J.git_commits+=X.git_commits,J.git_pushes+=X.git_pushes,J.total_interruptions+=X.user_interruptions,J.total_tool_errors+=X.tool_errors;for(let[z,O]of Object.entries(X.tool_error_categories))J.tool_error_categories[z]=(J.tool_error_categories[z]||0)+O;if(q.push(...X.user_response_times),X.uses_task_agent)J.sessions_using_task_agent++;if(X.uses_mcp)J.sessions_using_mcp++;if(X.uses_web_search)J.sessions_using_web_search++;if(X.uses_web_fetch)J.sessions_using_web_fetch++;J.total_lines_added+=X.lines_added,J.total_lines_removed+=X.lines_removed,J.total_files_modified+=X.files_modified,B.push(...X.message_hours);for(let[z,O]of Object.entries(X.tool_counts))J.tool_counts[z]=(J.tool_counts[z]||0)+O;for(let[z,O]of Object.entries(X.languages))J.languages[z]=(J.languages[z]||0)+O;if(X.project_path)J.projects[X.project_path]=(J.projects[X.project_path]||0)+1;let K=$.get(X.session_id);if(K){for(let[z,O]of S(K.goal_categories))if(O>0)J.goal_categories[z]=(J.goal_categories[z]||0)+O;J.outcomes[K.outcome]=(J.outcomes[K.outcome]||0)+1;for(let[z,O]of S(K.user_satisfaction_counts))if(O>0)J.satisfaction[z]=(J.satisfaction[z]||0)+O;J.helpfulness[K.claude_helpfulness]=(J.helpfulness[K.claude_helpfulness]||0)+1,J.session_types[K.session_type]=(J.session_types[K.session_type]||0)+1;for(let[z,O]of S(K.friction_counts))if(O>0)J.friction[z]=(J.friction[z]||0)+O;if(K.primary_success!=="none")J.success[K.primary_success]=(J.success[K.primary_success]||0)+1}if(J.session_summaries.length<50)J.session_summaries.push({id:X.session_id.slice(0,8),date:X.start_time.split("T")[0]||"",summary:X.summary||X.first_prompt.slice(0,100),goal:K?.underlying_goal})}if(Y.sort(),J.date_range.start=Y[0]?.split("T")[0]||"",J.date_range.end=Y[Y.length-1]?.split("T")[0]||"",J.user_response_times=q,q.length>0){let X=[...q].sort((K,z)=>K-z);J.median_response_time=X[Math.floor(X.length/2)]||0,J.avg_response_time=q.reduce((K,z)=>K+z,0)/q.length}let V=new Set(Y.map((X)=>X.split("T")[0]));return J.days_active=V.size,J.messages_per_day=J.days_active>0?Math.round(J.total_messages/J.days_active*10)/10:0,J.message_hours=B,J.multi_clauding=uQ(Q),J}async function e(Q,$){try{let J=await c({systemPrompt:d([]),userPrompt:Q.prompt+`

DATA:
`+$,signal:new AbortController().signal,options:{model:xQ(),querySource:"insights",agents:[],isNonInteractiveSession:!0,hasAppendSystemPrompt:!1,mcpTools:[],maxOutputTokensOverride:Q.maxTokens}}),Y=u(J.message.content);if(Y){let q=Y.match(/\{[\s\S]*\}/);if(q)try{return{name:Q.name,result:h(q[0])}}catch{return{name:Q.name,result:null}}}return{name:Q.name,result:null}}catch(J){return i(Error(`${Q.name} failed: ${l(J).message}`)),{name:Q.name,result:null}}}async function rQ(Q,$){let J=Array.from($.values()).slice(0,50).map((L)=>`- ${L.brief_summary} (${L.outcome}, ${L.claude_helpfulness})`).join(`
`),Y=Array.from($.values()).filter((L)=>L.friction_detail).slice(0,20).map((L)=>`- ${L.friction_detail}`).join(`
`),q=Array.from($.values()).flatMap((L)=>L.user_instructions_to_claude||[]).slice(0,15).map((L)=>`- ${L}`).join(`
`),V=b({sessions:Q.total_sessions,analyzed:Q.sessions_with_facets,date_range:Q.date_range,messages:Q.total_messages,hours:Math.round(Q.total_duration_hours),commits:Q.git_commits,top_tools:Object.entries(Q.tool_counts).sort((L,F)=>F[1]-L[1]).slice(0,8),top_goals:Object.entries(Q.goal_categories).sort((L,F)=>F[1]-L[1]).slice(0,8),outcomes:Q.outcomes,satisfaction:Q.satisfaction,friction:Q.friction,success:Q.success,languages:Q.languages},null,2)+`

SESSION SUMMARIES:
`+J+`

FRICTION DETAILS:
`+Y+`

USER INSTRUCTIONS TO CLAUDE:
`+(q||"None captured"),X=await Promise.all(cQ.map((L)=>e(L,V))),K={};for(let{name:L,result:F}of X)if(F)K[L]=F;let z=K.project_areas?.areas?.map((L)=>`- ${L.name}: ${L.description}`).join(`
`)||"",O=K.what_works?.impressive_workflows?.map((L)=>`- ${L.title}: ${L.description}`).join(`
`)||"",R=K.friction_analysis?.categories?.map((L)=>`- ${L.category}: ${L.description}`).join(`
`)||"",E=K.suggestions?.features_to_try?.map((L)=>`- ${L.feature}: ${L.one_liner}`).join(`
`)||"",v=K.suggestions?.usage_patterns?.map((L)=>`- ${L.title}: ${L.suggestion}`).join(`
`)||"",A=K.on_the_horizon?.opportunities?.map((L)=>`- ${L.title}: ${L.whats_possible}`).join(`
`)||"",T={name:"at_a_glance",prompt:`You're writing an "At a Glance" summary for a Claude Code usage insights report for Claude Code users. The goal is to help them understand their usage and improve how they can use Claude better, especially as models improve.

Use this 4-part structure:

1. **What's working** - What is the user's unique style of interacting with Claude and what are some impactful things they've done? You can include one or two details, but keep it high level since things might not be fresh in the user's memory. Don't be fluffy or overly complimentary. Also, don't focus on the tool calls they use.

2. **What's hindering you** - Split into (a) Claude's fault (misunderstandings, wrong approaches, bugs) and (b) user-side friction (not providing enough context, environment issues -- ideally more general than just one project). Be honest but constructive.

3. **Quick wins to try** - Specific Claude Code features they could try from the examples below, or a workflow technique if you think it's really compelling. (Avoid stuff like "Ask Claude to confirm before taking actions" or "Type out more context up front" which are less compelling.)

4. **Ambitious workflows for better models** - As we move to much more capable models over the next 3-6 months, what should they prepare for? What workflows that seem impossible now will become possible? Draw from the appropriate section below.

Keep each section to 2-3 not-too-long sentences. Don't overwhelm the user. Don't mention specific numerical stats or underlined_categories from the session data below. Use a coaching tone.

RESPOND WITH ONLY A VALID JSON OBJECT:
{
  "whats_working": "(refer to instructions above)",
  "whats_hindering": "(refer to instructions above)",
  "quick_wins": "(refer to instructions above)",
  "ambitious_workflows": "(refer to instructions above)"
}

SESSION DATA:
${V}

## Project Areas (what user works on)
${z}

## Big Wins (impressive accomplishments)
${O}

## Friction Categories (where things go wrong)
${R}

## Features to Try
${E}

## Usage Patterns to Adopt
${v}

## On the Horizon (ambitious workflows for better models)
${A}`,maxTokens:8192},M=await e(T,"");if(M.result)K.at_a_glance=M.result;return K}function p(Q){return N(Q).replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>")}function C(Q,$,J=6,Y){let q;if(Y)q=Y.filter((V)=>(V in Q)&&(Q[V]??0)>0).map((V)=>[V,Q[V]??0]);else q=Object.entries(Q).sort((V,X)=>X[1]-V[1]).slice(0,J);if(q.length===0)return'<p class="empty">No data</p>';let B=Math.max(...q.map((V)=>V[1]));return q.map(([V,X])=>{let K=X/B*100,z=IQ[V]||V.replace(/_/g," ").replace(/\b\w/g,(O)=>O.toUpperCase());return`<div class="bar-row">
        <div class="bar-label">${N(z)}</div>
        <div class="bar-track"><div class="bar-fill" style="width:${K}%;background:${$}"></div></div>
        <div class="bar-value">${X}</div>
      </div>`}).join(`
`)}function oQ(Q){if(Q.length===0)return'<p class="empty">No response time data</p>';let $={"2-10s":0,"10-30s":0,"30s-1m":0,"1-2m":0,"2-5m":0,"5-15m":0,">15m":0};for(let Y of Q)if(Y<10)$["2-10s"]=($["2-10s"]??0)+1;else if(Y<30)$["10-30s"]=($["10-30s"]??0)+1;else if(Y<60)$["30s-1m"]=($["30s-1m"]??0)+1;else if(Y<120)$["1-2m"]=($["1-2m"]??0)+1;else if(Y<300)$["2-5m"]=($["2-5m"]??0)+1;else if(Y<900)$["5-15m"]=($["5-15m"]??0)+1;else $[">15m"]=($[">15m"]??0)+1;let J=Math.max(...Object.values($));if(J===0)return'<p class="empty">No response time data</p>';return Object.entries($).map(([Y,q])=>{let B=q/J*100;return`<div class="bar-row">
        <div class="bar-label">${Y}</div>
        <div class="bar-track"><div class="bar-fill" style="width:${B}%;background:#6366f1"></div></div>
        <div class="bar-value">${q}</div>
      </div>`}).join(`
`)}function nQ(Q){if(Q.length===0)return'<p class="empty">No time data</p>';let $=[{label:"Morning (6-12)",range:[6,7,8,9,10,11]},{label:"Afternoon (12-18)",range:[12,13,14,15,16,17]},{label:"Evening (18-24)",range:[18,19,20,21,22,23]},{label:"Night (0-6)",range:[0,1,2,3,4,5]}],J={};for(let V of Q)J[V]=(J[V]||0)+1;let Y=$.map((V)=>({label:V.label,count:V.range.reduce((X,K)=>X+(J[K]||0),0)})),q=Math.max(...Y.map((V)=>V.count))||1;return`<div id="hour-histogram">${Y.map((V)=>`
      <div class="bar-row">
        <div class="bar-label">${V.label}</div>
        <div class="bar-track"><div class="bar-fill" style="width:${V.count/q*100}%;background:#8b5cf6"></div></div>
        <div class="bar-value">${V.count}</div>
      </div>`).join(`
`)}</div>`}function aQ(Q){let $={};for(let J of Q)$[J]=($[J]||0)+1;return b($)}function tQ(Q,$){let J=(U)=>{if(!U)return"";return U.split(`

`).map((j)=>{let Z=N(j);return Z=Z.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),Z=Z.replace(/^- /gm,"• "),Z=Z.replace(/\n/g,"<br>"),`<p>${Z}</p>`}).join(`
`)},Y=$.at_a_glance,q=Y?`
    <div class="at-a-glance">
      <div class="glance-title">At a Glance</div>
      <div class="glance-sections">
        ${Y.whats_working?`<div class="glance-section"><strong>What's working:</strong> ${p(Y.whats_working)} <a href="#section-wins" class="see-more">Impressive Things You Did →</a></div>`:""}
        ${Y.whats_hindering?`<div class="glance-section"><strong>What's hindering you:</strong> ${p(Y.whats_hindering)} <a href="#section-friction" class="see-more">Where Things Go Wrong →</a></div>`:""}
        ${Y.quick_wins?`<div class="glance-section"><strong>Quick wins to try:</strong> ${p(Y.quick_wins)} <a href="#section-features" class="see-more">Features to Try →</a></div>`:""}
        ${Y.ambitious_workflows?`<div class="glance-section"><strong>Ambitious workflows:</strong> ${p(Y.ambitious_workflows)} <a href="#section-horizon" class="see-more">On the Horizon →</a></div>`:""}
      </div>
    </div>
    `:"",B=$.project_areas?.areas||[],V=B.length>0?`
    <h2 id="section-work">What You Work On</h2>
    <div class="project-areas">
      ${B.map((U)=>`
        <div class="project-area">
          <div class="area-header">
            <span class="area-name">${N(U.name)}</span>
            <span class="area-count">~${U.session_count} sessions</span>
          </div>
          <div class="area-desc">${N(U.description)}</div>
        </div>
      `).join("")}
    </div>
    `:"",X=$.interaction_style,K=X?.narrative?`
    <h2 id="section-usage">How You Use Claude Code</h2>
    <div class="narrative">
      ${J(X.narrative)}
      ${X.key_pattern?`<div class="key-insight"><strong>Key pattern:</strong> ${N(X.key_pattern)}</div>`:""}
    </div>
    `:"",z=$.what_works,O=z?.impressive_workflows&&z.impressive_workflows.length>0?`
    <h2 id="section-wins">Impressive Things You Did</h2>
    ${z.intro?`<p class="section-intro">${N(z.intro)}</p>`:""}
    <div class="big-wins">
      ${z.impressive_workflows.map((U)=>`
        <div class="big-win">
          <div class="big-win-title">${N(U.title||"")}</div>
          <div class="big-win-desc">${N(U.description||"")}</div>
        </div>
      `).join("")}
    </div>
    `:"",R=$.friction_analysis,E=R?.categories&&R.categories.length>0?`
    <h2 id="section-friction">Where Things Go Wrong</h2>
    ${R.intro?`<p class="section-intro">${N(R.intro)}</p>`:""}
    <div class="friction-categories">
      ${R.categories.map((U)=>`
        <div class="friction-category">
          <div class="friction-title">${N(U.category||"")}</div>
          <div class="friction-desc">${N(U.description||"")}</div>
          ${U.examples?`<ul class="friction-examples">${U.examples.map((j)=>`<li>${N(j)}</li>`).join("")}</ul>`:""}
        </div>
      `).join("")}
    </div>
    `:"",v=$.suggestions,A=v?`
    ${v.claude_md_additions&&v.claude_md_additions.length>0?`
    <h2 id="section-features">Existing CC Features to Try</h2>
    <div class="claude-md-section">
      <h3>Suggested CLAUDE.md Additions</h3>
      <p style="font-size: 12px; color: #64748b; margin-bottom: 12px;">Just copy this into Claude Code to add it to your CLAUDE.md.</p>
      <div class="claude-md-actions">
        <button class="copy-all-btn" onclick="copyAllCheckedClaudeMd()">Copy All Checked</button>
      </div>
      ${v.claude_md_additions.map((U,j)=>`
        <div class="claude-md-item">
          <input type="checkbox" id="cmd-${j}" class="cmd-checkbox" checked data-text="${N(U.prompt_scaffold||U.where||"Add to CLAUDE.md")}\\n\\n${N(U.addition)}">
          <label for="cmd-${j}">
            <code class="cmd-code">${N(U.addition)}</code>
            <button class="copy-btn" onclick="copyCmdItem(${j})">Copy</button>
          </label>
          <div class="cmd-why">${N(U.why)}</div>
        </div>
      `).join("")}
    </div>
    `:""}
    ${v.features_to_try&&v.features_to_try.length>0?`
    <p style="font-size: 13px; color: #64748b; margin-bottom: 12px;">Just copy this into Claude Code and it'll set it up for you.</p>
    <div class="features-section">
      ${v.features_to_try.map((U)=>`
        <div class="feature-card">
          <div class="feature-title">${N(U.feature||"")}</div>
          <div class="feature-oneliner">${N(U.one_liner||"")}</div>
          <div class="feature-why"><strong>Why for you:</strong> ${N(U.why_for_you||"")}</div>
          ${U.example_code?`
          <div class="feature-examples">
            <div class="feature-example">
              <div class="example-code-row">
                <code class="example-code">${N(U.example_code)}</code>
                <button class="copy-btn" onclick="copyText(this)">Copy</button>
              </div>
            </div>
          </div>
          `:""}
        </div>
      `).join("")}
    </div>
    `:""}
    ${v.usage_patterns&&v.usage_patterns.length>0?`
    <h2 id="section-patterns">New Ways to Use Claude Code</h2>
    <p style="font-size: 13px; color: #64748b; margin-bottom: 12px;">Just copy this into Claude Code and it'll walk you through it.</p>
    <div class="patterns-section">
      ${v.usage_patterns.map((U)=>`
        <div class="pattern-card">
          <div class="pattern-title">${N(U.title||"")}</div>
          <div class="pattern-summary">${N(U.suggestion||"")}</div>
          ${U.detail?`<div class="pattern-detail">${N(U.detail)}</div>`:""}
          ${U.copyable_prompt?`
          <div class="copyable-prompt-section">
            <div class="prompt-label">Paste into Claude Code:</div>
            <div class="copyable-prompt-row">
              <code class="copyable-prompt">${N(U.copyable_prompt)}</code>
              <button class="copy-btn" onclick="copyText(this)">Copy</button>
            </div>
          </div>
          `:""}
        </div>
      `).join("")}
    </div>
    `:""}
    `:"",I=$.on_the_horizon,T=I?.opportunities&&I.opportunities.length>0?`
    <h2 id="section-horizon">On the Horizon</h2>
    ${I.intro?`<p class="section-intro">${N(I.intro)}</p>`:""}
    <div class="horizon-section">
      ${I.opportunities.map((U)=>`
        <div class="horizon-card">
          <div class="horizon-title">${N(U.title||"")}</div>
          <div class="horizon-possible">${N(U.whats_possible||"")}</div>
          ${U.how_to_try?`<div class="horizon-tip"><strong>Getting started:</strong> ${N(U.how_to_try)}</div>`:""}
          ${U.copyable_prompt?`<div class="pattern-prompt"><div class="prompt-label">Paste into Claude Code:</div><code>${N(U.copyable_prompt)}</code><button class="copy-btn" onclick="copyText(this)">Copy</button></div>`:""}
        </div>
      `).join("")}
    </div>
    `:"",M="",L=$.fun_ending,F=L?.headline?`
    <div class="fun-ending">
      <div class="fun-headline">"${N(L.headline)}"</div>
      ${L.detail?`<div class="fun-detail">${N(L.detail)}</div>`:""}
    </div>
    `:"",y=`
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: #f8fafc; color: #334155; line-height: 1.65; padding: 48px 24px; }
    .container { max-width: 800px; margin: 0 auto; }
    h1 { font-size: 32px; font-weight: 700; color: #0f172a; margin-bottom: 8px; }
    h2 { font-size: 20px; font-weight: 600; color: #0f172a; margin-top: 48px; margin-bottom: 16px; }
    .subtitle { color: #64748b; font-size: 15px; margin-bottom: 32px; }
    .nav-toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 32px 0; padding: 16px; background: white; border-radius: 8px; border: 1px solid #e2e8f0; }
    .nav-toc a { font-size: 12px; color: #64748b; text-decoration: none; padding: 6px 12px; border-radius: 6px; background: #f1f5f9; transition: all 0.15s; }
    .nav-toc a:hover { background: #e2e8f0; color: #334155; }
    .stats-row { display: flex; gap: 24px; margin-bottom: 40px; padding: 20px 0; border-top: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; }
    .stat { text-align: center; }
    .stat-value { font-size: 24px; font-weight: 700; color: #0f172a; }
    .stat-label { font-size: 11px; color: #64748b; text-transform: uppercase; }
    .at-a-glance { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); border: 1px solid #f59e0b; border-radius: 12px; padding: 20px 24px; margin-bottom: 32px; }
    .glance-title { font-size: 16px; font-weight: 700; color: #92400e; margin-bottom: 16px; }
    .glance-sections { display: flex; flex-direction: column; gap: 12px; }
    .glance-section { font-size: 14px; color: #78350f; line-height: 1.6; }
    .glance-section strong { color: #92400e; }
    .see-more { color: #b45309; text-decoration: none; font-size: 13px; white-space: nowrap; }
    .see-more:hover { text-decoration: underline; }
    .project-areas { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }
    .project-area { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; }
    .area-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
    .area-name { font-weight: 600; font-size: 15px; color: #0f172a; }
    .area-count { font-size: 12px; color: #64748b; background: #f1f5f9; padding: 2px 8px; border-radius: 4px; }
    .area-desc { font-size: 14px; color: #475569; line-height: 1.5; }
    .narrative { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 20px; margin-bottom: 24px; }
    .narrative p { margin-bottom: 12px; font-size: 14px; color: #475569; line-height: 1.7; }
    .key-insight { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 12px 16px; margin-top: 12px; font-size: 14px; color: #166534; }
    .section-intro { font-size: 14px; color: #64748b; margin-bottom: 16px; }
    .big-wins { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
    .big-win { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 16px; }
    .big-win-title { font-weight: 600; font-size: 15px; color: #166534; margin-bottom: 8px; }
    .big-win-desc { font-size: 14px; color: #15803d; line-height: 1.5; }
    .friction-categories { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
    .friction-category { background: #fef2f2; border: 1px solid #fca5a5; border-radius: 8px; padding: 16px; }
    .friction-title { font-weight: 600; font-size: 15px; color: #991b1b; margin-bottom: 6px; }
    .friction-desc { font-size: 13px; color: #7f1d1d; margin-bottom: 10px; }
    .friction-examples { margin: 0 0 0 20px; font-size: 13px; color: #334155; }
    .friction-examples li { margin-bottom: 4px; }
    .claude-md-section { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 16px; margin-bottom: 20px; }
    .claude-md-section h3 { font-size: 14px; font-weight: 600; color: #1e40af; margin: 0 0 12px 0; }
    .claude-md-actions { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid #dbeafe; }
    .copy-all-btn { background: #2563eb; color: white; border: none; border-radius: 4px; padding: 6px 12px; font-size: 12px; cursor: pointer; font-weight: 500; transition: all 0.2s; }
    .copy-all-btn:hover { background: #1d4ed8; }
    .copy-all-btn.copied { background: #16a34a; }
    .claude-md-item { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding: 10px 0; border-bottom: 1px solid #dbeafe; }
    .claude-md-item:last-child { border-bottom: none; }
    .cmd-checkbox { margin-top: 2px; }
    .cmd-code { background: white; padding: 8px 12px; border-radius: 4px; font-size: 12px; color: #1e40af; border: 1px solid #bfdbfe; font-family: monospace; display: block; white-space: pre-wrap; word-break: break-word; flex: 1; }
    .cmd-why { font-size: 12px; color: #64748b; width: 100%; padding-left: 24px; margin-top: 4px; }
    .features-section, .patterns-section { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
    .feature-card { background: #f0fdf4; border: 1px solid #86efac; border-radius: 8px; padding: 16px; }
    .pattern-card { background: #f0f9ff; border: 1px solid #7dd3fc; border-radius: 8px; padding: 16px; }
    .feature-title, .pattern-title { font-weight: 600; font-size: 15px; color: #0f172a; margin-bottom: 6px; }
    .feature-oneliner { font-size: 14px; color: #475569; margin-bottom: 8px; }
    .pattern-summary { font-size: 14px; color: #475569; margin-bottom: 8px; }
    .feature-why, .pattern-detail { font-size: 13px; color: #334155; line-height: 1.5; }
    .feature-examples { margin-top: 12px; }
    .feature-example { padding: 8px 0; border-top: 1px solid #d1fae5; }
    .feature-example:first-child { border-top: none; }
    .example-desc { font-size: 13px; color: #334155; margin-bottom: 6px; }
    .example-code-row { display: flex; align-items: flex-start; gap: 8px; }
    .example-code { flex: 1; background: #f1f5f9; padding: 8px 12px; border-radius: 4px; font-family: monospace; font-size: 12px; color: #334155; overflow-x: auto; white-space: pre-wrap; }
    .copyable-prompt-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid #e2e8f0; }
    .copyable-prompt-row { display: flex; align-items: flex-start; gap: 8px; }
    .copyable-prompt { flex: 1; background: #f8fafc; padding: 10px 12px; border-radius: 4px; font-family: monospace; font-size: 12px; color: #334155; border: 1px solid #e2e8f0; white-space: pre-wrap; line-height: 1.5; }
    .feature-code { background: #f8fafc; padding: 12px; border-radius: 6px; margin-top: 12px; border: 1px solid #e2e8f0; display: flex; align-items: flex-start; gap: 8px; }
    .feature-code code { flex: 1; font-family: monospace; font-size: 12px; color: #334155; white-space: pre-wrap; }
    .pattern-prompt { background: #f8fafc; padding: 12px; border-radius: 6px; margin-top: 12px; border: 1px solid #e2e8f0; }
    .pattern-prompt code { font-family: monospace; font-size: 12px; color: #334155; display: block; white-space: pre-wrap; margin-bottom: 8px; }
    .prompt-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: #64748b; margin-bottom: 6px; }
    .copy-btn { background: #e2e8f0; border: none; border-radius: 4px; padding: 4px 8px; font-size: 11px; cursor: pointer; color: #475569; flex-shrink: 0; }
    .copy-btn:hover { background: #cbd5e1; }
    .charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 24px 0; }
    .chart-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; }
    .chart-title { font-size: 12px; font-weight: 600; color: #64748b; text-transform: uppercase; margin-bottom: 12px; }
    .bar-row { display: flex; align-items: center; margin-bottom: 6px; }
    .bar-label { width: 100px; font-size: 11px; color: #475569; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .bar-track { flex: 1; height: 6px; background: #f1f5f9; border-radius: 3px; margin: 0 8px; }
    .bar-fill { height: 100%; border-radius: 3px; }
    .bar-value { width: 28px; font-size: 11px; font-weight: 500; color: #64748b; text-align: right; }
    .empty { color: #94a3b8; font-size: 13px; }
    .horizon-section { display: flex; flex-direction: column; gap: 16px; }
    .horizon-card { background: linear-gradient(135deg, #faf5ff 0%, #f5f3ff 100%); border: 1px solid #c4b5fd; border-radius: 8px; padding: 16px; }
    .horizon-title { font-weight: 600; font-size: 15px; color: #5b21b6; margin-bottom: 8px; }
    .horizon-possible { font-size: 14px; color: #334155; margin-bottom: 10px; line-height: 1.5; }
    .horizon-tip { font-size: 13px; color: #6b21a8; background: rgba(255,255,255,0.6); padding: 8px 12px; border-radius: 4px; }
    .feedback-header { margin-top: 48px; color: #64748b; font-size: 16px; }
    .feedback-intro { font-size: 13px; color: #94a3b8; margin-bottom: 16px; }
    .feedback-section { margin-top: 16px; }
    .feedback-section h3 { font-size: 14px; font-weight: 600; color: #475569; margin-bottom: 12px; }
    .feedback-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 12px; }
    .feedback-card.team-card { background: #eff6ff; border-color: #bfdbfe; }
    .feedback-card.model-card { background: #faf5ff; border-color: #e9d5ff; }
    .feedback-title { font-weight: 600; font-size: 14px; color: #0f172a; margin-bottom: 6px; }
    .feedback-detail { font-size: 13px; color: #475569; line-height: 1.5; }
    .feedback-evidence { font-size: 12px; color: #64748b; margin-top: 8px; }
    .fun-ending { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); border: 1px solid #fbbf24; border-radius: 12px; padding: 24px; margin-top: 40px; text-align: center; }
    .fun-headline { font-size: 18px; font-weight: 600; color: #78350f; margin-bottom: 8px; }
    .fun-detail { font-size: 14px; color: #92400e; }
    .collapsible-section { margin-top: 16px; }
    .collapsible-header { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 12px 0; border-bottom: 1px solid #e2e8f0; }
    .collapsible-header h3 { margin: 0; font-size: 14px; font-weight: 600; color: #475569; }
    .collapsible-arrow { font-size: 12px; color: #94a3b8; transition: transform 0.2s; }
    .collapsible-content { display: none; padding-top: 16px; }
    .collapsible-content.open { display: block; }
    .collapsible-header.open .collapsible-arrow { transform: rotate(90deg); }
    @media (max-width: 640px) { .charts-row { grid-template-columns: 1fr; } .stats-row { justify-content: center; } }
  `,x=`
    function toggleCollapsible(header) {
      header.classList.toggle('open');
      const content = header.nextElementSibling;
      content.classList.toggle('open');
    }
    function copyText(btn) {
      const code = btn.previousElementSibling;
      navigator.clipboard.writeText(code.textContent).then(() => {
        btn.textContent = 'Copied!';
        setTimeout(() => { btn.textContent = 'Copy'; }, 2000);
      });
    }
    function copyCmdItem(idx) {
      const checkbox = document.getElementById('cmd-' + idx);
      if (checkbox) {
        const text = checkbox.dataset.text;
        navigator.clipboard.writeText(text).then(() => {
          const btn = checkbox.nextElementSibling.querySelector('.copy-btn');
          if (btn) { btn.textContent = 'Copied!'; setTimeout(() => { btn.textContent = 'Copy'; }, 2000); }
        });
      }
    }
    function copyAllCheckedClaudeMd() {
      const checkboxes = document.querySelectorAll('.cmd-checkbox:checked');
      const texts = [];
      checkboxes.forEach(cb => {
        if (cb.dataset.text) { texts.push(cb.dataset.text); }
      });
      const combined = texts.join('\\n');
      const btn = document.querySelector('.copy-all-btn');
      if (btn) {
        navigator.clipboard.writeText(combined).then(() => {
          btn.textContent = 'Copied ' + texts.length + ' items!';
          btn.classList.add('copied');
          setTimeout(() => { btn.textContent = 'Copy All Checked'; btn.classList.remove('copied'); }, 2000);
        });
      }
    }
    // Timezone selector for time of day chart (data is from our own analytics, not user input)
    const rawHourCounts = ${aQ(Q.message_hours)};
    function updateHourHistogram(offsetFromPT) {
      const periods = [
        { label: "Morning (6-12)", range: [6,7,8,9,10,11] },
        { label: "Afternoon (12-18)", range: [12,13,14,15,16,17] },
        { label: "Evening (18-24)", range: [18,19,20,21,22,23] },
        { label: "Night (0-6)", range: [0,1,2,3,4,5] }
      ];
      const adjustedCounts = {};
      for (const [hour, count] of Object.entries(rawHourCounts)) {
        const newHour = (parseInt(hour) + offsetFromPT + 24) % 24;
        adjustedCounts[newHour] = (adjustedCounts[newHour] || 0) + count;
      }
      const periodCounts = periods.map(p => ({
        label: p.label,
        count: p.range.reduce((sum, h) => sum + (adjustedCounts[h] || 0), 0)
      }));
      const maxCount = Math.max(...periodCounts.map(p => p.count)) || 1;
      const container = document.getElementById('hour-histogram');
      container.textContent = '';
      periodCounts.forEach(p => {
        const row = document.createElement('div');
        row.className = 'bar-row';
        const label = document.createElement('div');
        label.className = 'bar-label';
        label.textContent = p.label;
        const track = document.createElement('div');
        track.className = 'bar-track';
        const fill = document.createElement('div');
        fill.className = 'bar-fill';
        fill.style.width = (p.count / maxCount) * 100 + '%';
        fill.style.background = '#8b5cf6';
        track.appendChild(fill);
        const value = document.createElement('div');
        value.className = 'bar-value';
        value.textContent = p.count;
        row.appendChild(label);
        row.appendChild(track);
        row.appendChild(value);
        container.appendChild(row);
      });
    }
    document.getElementById('timezone-select').addEventListener('change', function() {
      const customInput = document.getElementById('custom-offset');
      if (this.value === 'custom') {
        customInput.style.display = 'inline-block';
        customInput.focus();
      } else {
        customInput.style.display = 'none';
        updateHourHistogram(parseInt(this.value));
      }
    });
    document.getElementById('custom-offset').addEventListener('change', function() {
      const offset = parseInt(this.value) + 8;
      updateHourHistogram(offset);
    });
  `;return`<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Claude Code Insights</title>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: #f8fafc; color: #334155; line-height: 1.65; padding: 48px 24px; }
    .container { max-width: 800px; margin: 0 auto; }
    h1 { font-size: 32px; font-weight: 700; color: #0f172a; margin-bottom: 8px; }
    h2 { font-size: 20px; font-weight: 600; color: #0f172a; margin-top: 48px; margin-bottom: 16px; }
    .subtitle { color: #64748b; font-size: 15px; margin-bottom: 32px; }
    .nav-toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 32px 0; padding: 16px; background: white; border-radius: 8px; border: 1px solid #e2e8f0; }
    .nav-toc a { font-size: 12px; color: #64748b; text-decoration: none; padding: 6px 12px; border-radius: 6px; background: #f1f5f9; transition: all 0.15s; }
    .nav-toc a:hover { background: #e2e8f0; color: #334155; }
    .stats-row { display: flex; gap: 24px; margin-bottom: 40px; padding: 20px 0; border-top: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; }
    .stat { text-align: center; }
    .stat-value { font-size: 24px; font-weight: 700; color: #0f172a; }
    .stat-label { font-size: 11px; color: #64748b; text-transform: uppercase; }
    .at-a-glance { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); border: 1px solid #f59e0b; border-radius: 12px; padding: 20px 24px; margin-bottom: 32px; }
    .glance-title { font-size: 16px; font-weight: 700; color: #92400e; margin-bottom: 16px; }
    .glance-sections { display: flex; flex-direction: column; gap: 12px; }
    .glance-section { font-size: 14px; color: #78350f; line-height: 1.6; }
    .glance-section strong { color: #92400e; }
    .see-more { color: #b45309; text-decoration: none; font-size: 13px; white-space: nowrap; }
    .see-more:hover { text-decoration: underline; }
    .project-areas { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }
    .project-area { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; }
    .area-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
    .area-name { font-weight: 600; font-size: 15px; color: #0f172a; }
    .area-count { font-size: 12px; color: #64748b; background: #f1f5f9; padding: 2px 8px; border-radius: 4px; }
    .area-desc { font-size: 14px; color: #475569; line-height: 1.5; }
    .narrative { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 20px; margin-bottom: 24px; }
    .narrative p { margin-bottom: 12px; font-size: 14px; color: #475569; line-height: 1.7; }
    .key-insight { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 12px 16px; margin-top: 12px; font-size: 14px; color: #166534; }
    .section-intro { font-size: 14px; color: #64748b; margin-bottom: 16px; }
    .big-wins { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
    .big-win { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 16px; }
    .big-win-title { font-weight: 600; font-size: 15px; color: #166534; margin-bottom: 8px; }
    .big-win-desc { font-size: 14px; color: #15803d; line-height: 1.5; }
    .friction-categories { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
    .friction-category { background: #fef2f2; border: 1px solid #fca5a5; border-radius: 8px; padding: 16px; }
    .friction-title { font-weight: 600; font-size: 15px; color: #991b1b; margin-bottom: 6px; }
    .friction-desc { font-size: 13px; color: #7f1d1d; margin-bottom: 10px; }
    .friction-examples { margin: 0 0 0 20px; font-size: 13px; color: #334155; }
    .friction-examples li { margin-bottom: 4px; }
    .claude-md-section { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 16px; margin-bottom: 20px; }
    .claude-md-section h3 { font-size: 14px; font-weight: 600; color: #1e40af; margin: 0 0 12px 0; }
    .claude-md-actions { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid #dbeafe; }
    .copy-all-btn { background: #2563eb; color: white; border: none; border-radius: 4px; padding: 6px 12px; font-size: 12px; cursor: pointer; font-weight: 500; transition: all 0.2s; }
    .copy-all-btn:hover { background: #1d4ed8; }
    .copy-all-btn.copied { background: #16a34a; }
    .claude-md-item { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding: 10px 0; border-bottom: 1px solid #dbeafe; }
    .claude-md-item:last-child { border-bottom: none; }
    .cmd-checkbox { margin-top: 2px; }
    .cmd-code { background: white; padding: 8px 12px; border-radius: 4px; font-size: 12px; color: #1e40af; border: 1px solid #bfdbfe; font-family: monospace; display: block; white-space: pre-wrap; word-break: break-word; flex: 1; }
    .cmd-why { font-size: 12px; color: #64748b; width: 100%; padding-left: 24px; margin-top: 4px; }
    .features-section, .patterns-section { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
    .feature-card { background: #f0fdf4; border: 1px solid #86efac; border-radius: 8px; padding: 16px; }
    .pattern-card { background: #f0f9ff; border: 1px solid #7dd3fc; border-radius: 8px; padding: 16px; }
    .feature-title, .pattern-title { font-weight: 600; font-size: 15px; color: #0f172a; margin-bottom: 6px; }
    .feature-oneliner { font-size: 14px; color: #475569; margin-bottom: 8px; }
    .pattern-summary { font-size: 14px; color: #475569; margin-bottom: 8px; }
    .feature-why, .pattern-detail { font-size: 13px; color: #334155; line-height: 1.5; }
    .feature-examples { margin-top: 12px; }
    .feature-example { padding: 8px 0; border-top: 1px solid #d1fae5; }
    .feature-example:first-child { border-top: none; }
    .example-desc { font-size: 13px; color: #334155; margin-bottom: 6px; }
    .example-code-row { display: flex; align-items: flex-start; gap: 8px; }
    .example-code { flex: 1; background: #f1f5f9; padding: 8px 12px; border-radius: 4px; font-family: monospace; font-size: 12px; color: #334155; overflow-x: auto; white-space: pre-wrap; }
    .copyable-prompt-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid #e2e8f0; }
    .copyable-prompt-row { display: flex; align-items: flex-start; gap: 8px; }
    .copyable-prompt { flex: 1; background: #f8fafc; padding: 10px 12px; border-radius: 4px; font-family: monospace; font-size: 12px; color: #334155; border: 1px solid #e2e8f0; white-space: pre-wrap; line-height: 1.5; }
    .feature-code { background: #f8fafc; padding: 12px; border-radius: 6px; margin-top: 12px; border: 1px solid #e2e8f0; display: flex; align-items: flex-start; gap: 8px; }
    .feature-code code { flex: 1; font-family: monospace; font-size: 12px; color: #334155; white-space: pre-wrap; }
    .pattern-prompt { background: #f8fafc; padding: 12px; border-radius: 6px; margin-top: 12px; border: 1px solid #e2e8f0; }
    .pattern-prompt code { font-family: monospace; font-size: 12px; color: #334155; display: block; white-space: pre-wrap; margin-bottom: 8px; }
    .prompt-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: #64748b; margin-bottom: 6px; }
    .copy-btn { background: #e2e8f0; border: none; border-radius: 4px; padding: 4px 8px; font-size: 11px; cursor: pointer; color: #475569; flex-shrink: 0; }
    .copy-btn:hover { background: #cbd5e1; }
    .charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 24px 0; }
    .chart-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; }
    .chart-title { font-size: 12px; font-weight: 600; color: #64748b; text-transform: uppercase; margin-bottom: 12px; }
    .bar-row { display: flex; align-items: center; margin-bottom: 6px; }
    .bar-label { width: 100px; font-size: 11px; color: #475569; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .bar-track { flex: 1; height: 6px; background: #f1f5f9; border-radius: 3px; margin: 0 8px; }
    .bar-fill { height: 100%; border-radius: 3px; }
    .bar-value { width: 28px; font-size: 11px; font-weight: 500; color: #64748b; text-align: right; }
    .empty { color: #94a3b8; font-size: 13px; }
    .horizon-section { display: flex; flex-direction: column; gap: 16px; }
    .horizon-card { background: linear-gradient(135deg, #faf5ff 0%, #f5f3ff 100%); border: 1px solid #c4b5fd; border-radius: 8px; padding: 16px; }
    .horizon-title { font-weight: 600; font-size: 15px; color: #5b21b6; margin-bottom: 8px; }
    .horizon-possible { font-size: 14px; color: #334155; margin-bottom: 10px; line-height: 1.5; }
    .horizon-tip { font-size: 13px; color: #6b21a8; background: rgba(255,255,255,0.6); padding: 8px 12px; border-radius: 4px; }
    .feedback-header { margin-top: 48px; color: #64748b; font-size: 16px; }
    .feedback-intro { font-size: 13px; color: #94a3b8; margin-bottom: 16px; }
    .feedback-section { margin-top: 16px; }
    .feedback-section h3 { font-size: 14px; font-weight: 600; color: #475569; margin-bottom: 12px; }
    .feedback-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 12px; }
    .feedback-card.team-card { background: #eff6ff; border-color: #bfdbfe; }
    .feedback-card.model-card { background: #faf5ff; border-color: #e9d5ff; }
    .feedback-title { font-weight: 600; font-size: 14px; color: #0f172a; margin-bottom: 6px; }
    .feedback-detail { font-size: 13px; color: #475569; line-height: 1.5; }
    .feedback-evidence { font-size: 12px; color: #64748b; margin-top: 8px; }
    .fun-ending { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); border: 1px solid #fbbf24; border-radius: 12px; padding: 24px; margin-top: 40px; text-align: center; }
    .fun-headline { font-size: 18px; font-weight: 600; color: #78350f; margin-bottom: 8px; }
    .fun-detail { font-size: 14px; color: #92400e; }
    .collapsible-section { margin-top: 16px; }
    .collapsible-header { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 12px 0; border-bottom: 1px solid #e2e8f0; }
    .collapsible-header h3 { margin: 0; font-size: 14px; font-weight: 600; color: #475569; }
    .collapsible-arrow { font-size: 12px; color: #94a3b8; transition: transform 0.2s; }
    .collapsible-content { display: none; padding-top: 16px; }
    .collapsible-content.open { display: block; }
    .collapsible-header.open .collapsible-arrow { transform: rotate(90deg); }
    @media (max-width: 640px) { .charts-row { grid-template-columns: 1fr; } .stats-row { justify-content: center; } }
  </style>
</head>
<body>
  <div class="container">
    <h1>Claude Code Insights</h1>
    <p class="subtitle">${Q.total_messages.toLocaleString()} messages across ${Q.total_sessions} sessions${Q.total_sessions_scanned&&Q.total_sessions_scanned>Q.total_sessions?` (${Q.total_sessions_scanned.toLocaleString()} total)`:""} | ${Q.date_range.start} to ${Q.date_range.end}</p>

    ${q}

    <nav class="nav-toc">
      <a href="#section-work">What You Work On</a>
      <a href="#section-usage">How You Use CC</a>
      <a href="#section-wins">Impressive Things</a>
      <a href="#section-friction">Where Things Go Wrong</a>
      <a href="#section-features">Features to Try</a>
      <a href="#section-patterns">New Usage Patterns</a>
      <a href="#section-horizon">On the Horizon</a>
      <a href="#section-feedback">Team Feedback</a>
    </nav>

    <div class="stats-row">
      <div class="stat"><div class="stat-value">${Q.total_messages.toLocaleString()}</div><div class="stat-label">Messages</div></div>
      <div class="stat"><div class="stat-value">+${Q.total_lines_added.toLocaleString()}/-${Q.total_lines_removed.toLocaleString()}</div><div class="stat-label">Lines</div></div>
      <div class="stat"><div class="stat-value">${Q.total_files_modified}</div><div class="stat-label">Files</div></div>
      <div class="stat"><div class="stat-value">${Q.days_active}</div><div class="stat-label">Days</div></div>
      <div class="stat"><div class="stat-value">${Q.messages_per_day}</div><div class="stat-label">Msgs/Day</div></div>
    </div>

    ${V}

    <div class="charts-row">
      <div class="chart-card">
        <div class="chart-title">What You Wanted</div>
        ${C(Q.goal_categories,"#2563eb")}
      </div>
      <div class="chart-card">
        <div class="chart-title">Top Tools Used</div>
        ${C(Q.tool_counts,"#0891b2")}
      </div>
    </div>

    <div class="charts-row">
      <div class="chart-card">
        <div class="chart-title">Languages</div>
        ${C(Q.languages,"#10b981")}
      </div>
      <div class="chart-card">
        <div class="chart-title">Session Types</div>
        ${C(Q.session_types||{},"#8b5cf6")}
      </div>
    </div>

    ${K}

    <!-- Response Time Distribution -->
    <div class="chart-card" style="margin: 24px 0;">
      <div class="chart-title">User Response Time Distribution</div>
      ${oQ(Q.user_response_times)}
      <div style="font-size: 12px; color: #64748b; margin-top: 8px;">
        Median: ${Q.median_response_time.toFixed(1)}s &bull; Average: ${Q.avg_response_time.toFixed(1)}s
      </div>
    </div>

    <!-- Multi-clauding Section (matching Python reference) -->
    <div class="chart-card" style="margin: 24px 0;">
      <div class="chart-title">Multi-Clauding (Parallel Sessions)</div>
      ${Q.multi_clauding.overlap_events===0?`
        <p style="font-size: 14px; color: #64748b; padding: 8px 0;">
          No parallel session usage detected. You typically work with one Claude Code session at a time.
        </p>
      `:`
        <div style="display: flex; gap: 24px; margin: 12px 0;">
          <div style="text-align: center;">
            <div style="font-size: 24px; font-weight: 700; color: #7c3aed;">${Q.multi_clauding.overlap_events}</div>
            <div style="font-size: 11px; color: #64748b; text-transform: uppercase;">Overlap Events</div>
          </div>
          <div style="text-align: center;">
            <div style="font-size: 24px; font-weight: 700; color: #7c3aed;">${Q.multi_clauding.sessions_involved}</div>
            <div style="font-size: 11px; color: #64748b; text-transform: uppercase;">Sessions Involved</div>
          </div>
          <div style="text-align: center;">
            <div style="font-size: 24px; font-weight: 700; color: #7c3aed;">${Q.total_messages>0?Math.round(100*Q.multi_clauding.user_messages_during/Q.total_messages):0}%</div>
            <div style="font-size: 11px; color: #64748b; text-transform: uppercase;">Of Messages</div>
          </div>
        </div>
        <p style="font-size: 13px; color: #475569; margin-top: 12px;">
          You run multiple Claude Code sessions simultaneously. Multi-clauding is detected when sessions
          overlap in time, suggesting parallel workflows.
        </p>
      `}
    </div>

    <!-- Time of Day & Tool Errors -->
    <div class="charts-row">
      <div class="chart-card">
        <div class="chart-title" style="display: flex; align-items: center; gap: 12px;">
          User Messages by Time of Day
          <select id="timezone-select" style="font-size: 12px; padding: 4px 8px; border-radius: 4px; border: 1px solid #e2e8f0;">
            <option value="0">PT (UTC-8)</option>
            <option value="3">ET (UTC-5)</option>
            <option value="8">London (UTC)</option>
            <option value="9">CET (UTC+1)</option>
            <option value="17">Tokyo (UTC+9)</option>
            <option value="custom">Custom offset...</option>
          </select>
          <input type="number" id="custom-offset" placeholder="UTC offset" style="display: none; width: 80px; font-size: 12px; padding: 4px; border-radius: 4px; border: 1px solid #e2e8f0;">
        </div>
        ${nQ(Q.message_hours)}
      </div>
      <div class="chart-card">
        <div class="chart-title">Tool Errors Encountered</div>
        ${Object.keys(Q.tool_error_categories).length>0?C(Q.tool_error_categories,"#dc2626"):'<p class="empty">No tool errors</p>'}
      </div>
    </div>

    ${O}

    <div class="charts-row">
      <div class="chart-card">
        <div class="chart-title">What Helped Most (Claude's Capabilities)</div>
        ${C(Q.success,"#16a34a")}
      </div>
      <div class="chart-card">
        <div class="chart-title">Outcomes</div>
        ${C(Q.outcomes,"#8b5cf6",6,iQ)}
      </div>
    </div>

    ${E}

    <div class="charts-row">
      <div class="chart-card">
        <div class="chart-title">Primary Friction Types</div>
        ${C(Q.friction,"#dc2626")}
      </div>
      <div class="chart-card">
        <div class="chart-title">Inferred Satisfaction (model-estimated)</div>
        ${C(Q.satisfaction,"#eab308",6,lQ)}
      </div>
    </div>

    ${A}

    ${T}

    ${F}

    
  </div>
  <script>${x}</script>
</body>
</html>`}function D0(Q,$,J){let Y=typeof MACRO<"u"?"99.0.0":"unknown",q={total:J.size,goal_categories:{},outcomes:{},satisfaction:{},friction:{}};for(let B of J.values()){for(let[V,X]of S(B.goal_categories))if(X>0)q.goal_categories[V]=(q.goal_categories[V]||0)+X;q.outcomes[B.outcome]=(q.outcomes[B.outcome]||0)+1;for(let[V,X]of S(B.user_satisfaction_counts))if(X>0)q.satisfaction[V]=(q.satisfaction[V]||0)+X;for(let[V,X]of S(B.friction_counts))if(X>0)q.friction[V]=(q.friction[V]||0)+X}return{metadata:{username:process.env.SAFEUSER||process.env.USER||"unknown",generated_at:new Date().toISOString(),claude_code_version:Y,date_range:Q.date_range,session_count:Q.total_sessions},aggregated_data:Q,insights:$,facets_summary:q}}async function eQ(){let Q=XQ(),$;try{$=await EQ(Q,{withFileTypes:!0})}catch{return[]}let J=$.filter((q)=>q.isDirectory()).map((q)=>H(Q,q.name)),Y=[];for(let q=0;q<J.length;q++){let B=await zQ(J[q]);for(let[V,X]of B)Y.push({sessionId:V,path:X.path,mtime:X.mtime,size:X.size});if(q%10===9)await new Promise((V)=>setImmediate(V))}return Y.sort((q,B)=>B.mtime-q.mtime),Y}async function sQ(){let Q=await eQ(),$=Q.length,J=50,Y=200,q=[],B=[];for(let Z=0;Z<Q.length;Z+=50){let W=Q.slice(Z,Z+50),_=await Promise.all(W.map(async(P)=>({sessionInfo:P,cached:await pQ(P.sessionId)})));for(let{sessionInfo:P,cached:G}of _)if(G)q.push(G);else if(B.length<200)B.push(P)}let V=new Map,X=(Z)=>{for(let W of Z.messages.slice(0,5))if(W.type==="user"&&W.message){let _=W.message.content;if(typeof _==="string"){if(_.includes("RESPOND WITH ONLY A VALID JSON OBJECT")||_.includes("record_facets"))return!0}}return!1},K=10;for(let Z=0;Z<B.length;Z+=K){let W=B.slice(Z,Z+K),_=await Promise.all(W.map(async(G)=>{try{return await BQ(G.path)}catch{return[]}})),P=[];for(let G of _)for(let D of G){if(X(D)||!TQ(D))continue;let k=t(D);q.push(k),P.push(k),V.set(k.session_id,D)}await Promise.all(P.map((G)=>gQ(G)))}let z=new Map;for(let Z of q){let W=z.get(Z.session_id);if(!W||Z.user_message_count>W.user_message_count||Z.user_message_count===W.user_message_count&&Z.duration_minutes>W.duration_minutes)z.set(Z.session_id,Z)}let O=new Set(z.keys());q=[...z.values()];for(let Z of V.keys())if(!O.has(Z))V.delete(Z);q.sort((Z,W)=>W.start_time.localeCompare(Z.start_time));let R=(Z)=>{if(Z.user_message_count<2)return!1;if(Z.duration_minutes<1)return!1;return!0},E=q.filter(R),v=new Map,A=[],I=50,T=await Promise.all(E.map(async(Z)=>({sessionId:Z.session_id,cached:await hQ(Z.session_id)})));for(let{sessionId:Z,cached:W}of T)if(W)v.set(Z,W);else{let _=V.get(Z);if(_&&A.length<I)A.push({log:_,sessionId:Z})}let M=50;for(let Z=0;Z<A.length;Z+=M){let W=A.slice(Z,Z+M),_=await Promise.all(W.map(async({log:G,sessionId:D})=>{let k=await mQ(G,D);return{sessionId:D,newFacets:k}})),P=[];for(let{sessionId:G,newFacets:D}of _)if(D)v.set(G,D),P.push(D);await Promise.all(P.map((G)=>fQ(G)))}let L=(Z)=>{let W=v.get(Z);if(!W)return!1;let _=W.goal_categories,P=Q0(_).filter((G)=>(_[G]??0)>0);return P.length===1&&P[0]==="warmup_minimal"},F=E.filter((Z)=>!L(Z.session_id)),y=new Map;for(let[Z,W]of v)if(!L(Z))y.set(Z,W);let w=dQ(F,y);w.total_sessions_scanned=$;let x=await rQ(w,v),U=tQ(w,x);try{await n(g(),{recursive:!0})}catch{}let j=H(g(),"report.html");return await a(j,U,{encoding:"utf-8",mode:384}),{insights:x,htmlPath:j,data:w,facets:y}}function S(Q){return Q?Object.entries(Q):[]}function Q0(Q){return Q?Object.keys(Q):[]}function KQ(Q){if(!Q||typeof Q!=="object")return!1;let $=Q;return typeof $.underlying_goal==="string"&&typeof $.outcome==="string"&&typeof $.brief_summary==="string"&&$.goal_categories!==null&&typeof $.goal_categories==="object"&&$.user_satisfaction_counts!==null&&typeof $.user_satisfaction_counts==="object"&&$.friction_counts!==null&&typeof $.friction_counts==="object"}var AQ,IQ,MQ=`Analyze this Claude Code session and extract structured facets.

CRITICAL GUIDELINES:

1. **goal_categories**: Count ONLY what the USER explicitly asked for.
   - DO NOT count Claude's autonomous codebase exploration
   - DO NOT count work Claude decided to do on its own
   - ONLY count when user says "can you...", "please...", "I need...", "let's..."

2. **user_satisfaction_counts**: Base ONLY on explicit user signals.
   - "Yay!", "great!", "perfect!" → happy
   - "thanks", "looks good", "that works" → satisfied
   - "ok, now let's..." (continuing without complaint) → likely_satisfied
   - "that's not right", "try again" → dissatisfied
   - "this is broken", "I give up" → frustrated

3. **friction_counts**: Be specific about what went wrong.
   - misunderstood_request: Claude interpreted incorrectly
   - wrong_approach: Right goal, wrong solution method
   - buggy_code: Code didn't work correctly
   - user_rejected_action: User said no/stop to a tool call
   - excessive_changes: Over-engineered or changed too much

4. If very short or just warmup, use warmup_minimal for goal_category

SESSION:
`,kQ=`Summarize this portion of a Claude Code session transcript. Focus on:
1. What the user asked for
2. What Claude did (tools used, files modified)
3. Any friction or issues
4. The outcome

Keep it concise - 3-5 sentences. Preserve specific details like file names, error messages, and user feedback.

TRANSCRIPT CHUNK:
`,cQ,lQ,iQ,$0,E0;var J0=UQ(()=>{RQ();jQ();GQ();LQ();WQ();NQ();X0();PQ();Y0();OQ();_Q();DQ();vQ();AQ={".ts":"TypeScript",".tsx":"TypeScript",".js":"JavaScript",".jsx":"JavaScript",".py":"Python",".rb":"Ruby",".go":"Go",".rs":"Rust",".java":"Java",".md":"Markdown",".json":"JSON",".yaml":"YAML",".yml":"YAML",".sh":"Shell",".css":"CSS",".html":"HTML"},IQ={debug_investigate:"Debug/Investigate",implement_feature:"Implement Feature",fix_bug:"Fix Bug",write_script_tool:"Write Script/Tool",refactor_code:"Refactor Code",configure_system:"Configure System",create_pr_commit:"Create PR/Commit",analyze_data:"Analyze Data",understand_codebase:"Understand Codebase",write_tests:"Write Tests",write_docs:"Write Docs",deploy_infra:"Deploy/Infra",warmup_minimal:"Cache Warmup",fast_accurate_search:"Fast/Accurate Search",correct_code_edits:"Correct Code Edits",good_explanations:"Good Explanations",proactive_help:"Proactive Help",multi_file_changes:"Multi-file Changes",handled_complexity:"Multi-file Changes",good_debugging:"Good Debugging",misunderstood_request:"Misunderstood Request",wrong_approach:"Wrong Approach",buggy_code:"Buggy Code",user_rejected_action:"User Rejected Action",claude_got_blocked:"Claude Got Blocked",user_stopped_early:"User Stopped Early",wrong_file_or_location:"Wrong File/Location",excessive_changes:"Excessive Changes",slow_or_verbose:"Slow/Verbose",tool_failed:"Tool Failed",user_unclear:"User Unclear",external_issue:"External Issue",frustrated:"Frustrated",dissatisfied:"Dissatisfied",likely_satisfied:"Likely Satisfied",satisfied:"Satisfied",happy:"Happy",unsure:"Unsure",neutral:"Neutral",delighted:"Delighted",single_task:"Single Task",multi_task:"Multi Task",iterative_refinement:"Iterative Refinement",exploration:"Exploration",quick_question:"Quick Question",fully_achieved:"Fully Achieved",mostly_achieved:"Mostly Achieved",partially_achieved:"Partially Achieved",not_achieved:"Not Achieved",unclear_from_transcript:"Unclear",unhelpful:"Unhelpful",slightly_helpful:"Slightly Helpful",moderately_helpful:"Moderately Helpful",very_helpful:"Very Helpful",essential:"Essential"};cQ=[{name:"project_areas",prompt:`Analyze this Claude Code usage data and identify project areas.

RESPOND WITH ONLY A VALID JSON OBJECT:
{
  "areas": [
    {"name": "Area name", "session_count": N, "description": "2-3 sentences about what was worked on and how Claude Code was used."}
  ]
}

Include 4-5 areas. Skip internal CC operations.`,maxTokens:8192},{name:"interaction_style",prompt:`Analyze this Claude Code usage data and describe the user's interaction style.

RESPOND WITH ONLY A VALID JSON OBJECT:
{
  "narrative": "2-3 paragraphs analyzing HOW the user interacts with Claude Code. Use second person 'you'. Describe patterns: iterate quickly vs detailed upfront specs? Interrupt often or let Claude run? Include specific examples. Use **bold** for key insights.",
  "key_pattern": "One sentence summary of most distinctive interaction style"
}`,maxTokens:8192},{name:"what_works",prompt:`Analyze this Claude Code usage data and identify what's working well for this user. Use second person ("you").

RESPOND WITH ONLY A VALID JSON OBJECT:
{
  "intro": "1 sentence of context",
  "impressive_workflows": [
    {"title": "Short title (3-6 words)", "description": "2-3 sentences describing the impressive workflow or approach. Use 'you' not 'the user'."}
  ]
}

Include 3 impressive workflows.`,maxTokens:8192},{name:"friction_analysis",prompt:`Analyze this Claude Code usage data and identify friction points for this user. Use second person ("you").

RESPOND WITH ONLY A VALID JSON OBJECT:
{
  "intro": "1 sentence summarizing friction patterns",
  "categories": [
    {"category": "Concrete category name", "description": "1-2 sentences explaining this category and what could be done differently. Use 'you' not 'the user'.", "examples": ["Specific example with consequence", "Another example"]}
  ]
}

Include 3 friction categories with 2 examples each.`,maxTokens:8192},{name:"suggestions",prompt:`Analyze this Claude Code usage data and suggest improvements.

## CC FEATURES REFERENCE (pick from these for features_to_try):
1. **MCP Servers**: Connect Claude to external tools, databases, and APIs via Model Context Protocol.
   - How to use: Run \`claude mcp add <server-name> -- <command>\`
   - Good for: database queries, Slack integration, GitHub issue lookup, connecting to internal APIs

2. **Custom Skills**: Reusable prompts you define as markdown files that run with a single /command.
   - How to use: Create \`.claudio/skills/commit/SKILL.md\` with instructions. Then type \`/commit\` to run it.
   - Good for: repetitive workflows - /commit, /review, /test, /deploy, /pr, or complex multi-step workflows

3. **Hooks**: Shell commands that auto-run at specific lifecycle events.
   - How to use: Add to \`.claudio/settings.json\` under "hooks" key.
   - Good for: auto-formatting code, running type checks, enforcing conventions

4. **Headless Mode**: Run Claude non-interactively from scripts and CI/CD.
   - How to use: \`claude -p "fix lint errors" --allowedTools "Edit,Read,Bash"\`
   - Good for: CI/CD integration, batch code fixes, automated reviews

5. **Task Agents**: Claude spawns focused sub-agents for complex exploration or parallel work.
   - How to use: Claude auto-invokes when helpful, or ask "use an agent to explore X"
   - Good for: codebase exploration, understanding complex systems

RESPOND WITH ONLY A VALID JSON OBJECT:
{
  "claude_md_additions": [
    {"addition": "A specific line or block to add to CLAUDE.md based on workflow patterns. E.g., 'Always run tests after modifying auth-related files'", "why": "1 sentence explaining why this would help based on actual sessions", "prompt_scaffold": "Instructions for where to add this in CLAUDE.md. E.g., 'Add under ## Testing section'"}
  ],
  "features_to_try": [
    {"feature": "Feature name from CC FEATURES REFERENCE above", "one_liner": "What it does", "why_for_you": "Why this would help YOU based on your sessions", "example_code": "Actual command or config to copy"}
  ],
  "usage_patterns": [
    {"title": "Short title", "suggestion": "1-2 sentence summary", "detail": "3-4 sentences explaining how this applies to YOUR work", "copyable_prompt": "A specific prompt to copy and try"}
  ]
}

IMPORTANT for claude_md_additions: PRIORITIZE instructions that appear MULTIPLE TIMES in the user data. If user told Claude the same thing in 2+ sessions (e.g., 'always run tests', 'use TypeScript'), that's a PRIME candidate - they shouldn't have to repeat themselves.

IMPORTANT for features_to_try: Pick 2-3 from the CC FEATURES REFERENCE above. Include 2-3 items for each category.`,maxTokens:8192},{name:"on_the_horizon",prompt:`Analyze this Claude Code usage data and identify future opportunities.

RESPOND WITH ONLY A VALID JSON OBJECT:
{
  "intro": "1 sentence about evolving AI-assisted development",
  "opportunities": [
    {"title": "Short title (4-8 words)", "whats_possible": "2-3 ambitious sentences about autonomous workflows", "how_to_try": "1-2 sentences mentioning relevant tooling", "copyable_prompt": "Detailed prompt to try"}
  ]
}

Include 3 opportunities. Think BIG - autonomous workflows, parallel agents, iterating against tests.`,maxTokens:8192},{name:"fun_ending",prompt:`Analyze this Claude Code usage data and find a memorable moment.

RESPOND WITH ONLY A VALID JSON OBJECT:
{
  "headline": "A memorable QUALITATIVE moment from the transcripts - not a statistic. Something human, funny, or surprising.",
  "detail": "Brief context about when/where this happened"
}

Find something genuinely interesting or amusing from the session summaries.`,maxTokens:8192}];lQ=["frustrated","dissatisfied","likely_satisfied","satisfied","happy","unsure"],iQ=["not_achieved","partially_achieved","mostly_achieved","fully_achieved","unclear_from_transcript"];$0={type:"prompt",name:"insights",description:"Generate a report analyzing your Claude Code sessions",contentLength:0,progressMessage:"analyzing your sessions",source:"builtin",async getPromptForCommand(Q){let{insights:$,htmlPath:J,data:Y}=await sQ(),q=`file://${J}`,B="",X=[Y.total_sessions_scanned&&Y.total_sessions_scanned>Y.total_sessions?`${Y.total_sessions_scanned.toLocaleString()} sessions total · ${Y.total_sessions} analyzed`:`${Y.total_sessions} sessions`,`${Y.total_messages.toLocaleString()} messages`,`${Math.round(Y.total_duration_hours)}h`,`${Y.git_commits} commits`].join(" · "),K=$.at_a_glance,z=K?`## At a Glance

${K.whats_working?`**What's working:** ${K.whats_working} See _Impressive Things You Did_.`:""}

${K.whats_hindering?`**What's hindering you:** ${K.whats_hindering} See _Where Things Go Wrong_.`:""}

${K.quick_wins?`**Quick wins to try:** ${K.quick_wins} See _Features to Try_.`:""}

${K.ambitious_workflows?`**Ambitious workflows:** ${K.ambitious_workflows} See _On the Horizon_.`:""}`:"_No insights generated_",R=`${`# Claude Code Insights

${X}
${Y.date_range.start} to ${Y.date_range.end}
`}${z}

Your full shareable insights report is ready: ${q}${B}`;return[{type:"text",text:`The user just ran /insights to generate a usage report analyzing their Claude Code sessions.

Here is the full insights data:
${b($,null,2)}

Report URL: ${q}
HTML file: ${J}
Facets directory: ${m()}

Here is what the user sees:
${R}

Now output the following message exactly:

<message>
Your shareable insights report is ready:
${q}${B}

Want to dig into any section or try one of the suggestions?
</message>`}]}};E0=$0});J0();export{sQ as generateUsageReport,uQ as detectMultiClauding,E0 as default,R0 as deduplicateSessionBranches,D0 as buildExportData};
