tweakcc 3.1.4 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -176,7 +176,7 @@ ${w} </div>
|
|
|
176
176
|
</body>
|
|
177
177
|
</html>`,E=re.join(Se,`${e}.diff.html`);return await oe.writeFile(E,S,"utf-8"),E},Lt=async e=>{const t={id:e.id,name:e.name,description:e.description,action:"skipped",newVersion:e.version};if(!await Nt(e.id)){const r=vn(e);return await on(e.id,r),t.action="created",t}const o=await Ot(e.id);if(t.oldVersion=o.ccVersion,await Bt(e.id,e.identifierMap),o.ccVersion&&e.version){const r=Mt(o.ccVersion,e.version);if(r===0)return t.action="skipped",t;if(r!=0){const i=await It(e.id,o.ccVersion),a=We(o.content);if(!i||i!==a){t.action="conflict";let u=o.content;try{const b=(await sn(o.ccVersion)).prompts.find(p=>p.id===e.id);b&&(u=Ve(b.pieces,b.identifiers,b.identifierMap))}catch{console.log(H.yellow(`Warning: Could not fetch old version ${o.ccVersion} for comparison. Using current file as baseline.`))}const d=Ve(e.pieces,e.identifiers,e.identifierMap),h=Be(e.id),f=await Pt(e.id,e.name,u,o.content,d,o.ccVersion,e.version,h);t.diffHtmlPath=f}else{const u=vn(e);await on(e.id,u),t.action="updated"}}}return t},Dt=async e=>{const t={ccVersion:e,results:[]},n=await sn(e);await Ct(n),await oe.mkdir(Se,{recursive:!0});for(const o of n.prompts)try{const r=await Lt(o);t.results.push(r)}catch(r){throw console.log(H.red(`Failed to sync prompt ${o.id}:`)),r}return t};let ze=null,rn=null;const _n=async e=>{try{return ze=await sn(e),rn=e,{success:!0}}catch(t){return ze=null,rn=null,t instanceof Error?{success:!1,errorMessage:t.message}:{success:!1,errorMessage:"Unknown error occurred while downloading system prompts"}}},Rt=e=>e.replace(/[^\x00-\x7F]/g,t=>{const o=`\\\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`;return`(?:${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}|${o})`}),Ft=e=>e.replace(/[^\x00-\x7F]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),Vt=(e,t)=>{let n="";for(let o=0;o<e.length;o++){const i=e[o].replace(/<<CCVERSION>>/g,t).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=Rt(i);n+=a,o<e.length-1&&(n+="([\\w$]+)")}return n},jt=e=>{const t=new Map;let n=0,o=1,r=1;for(let i=0;i<e.length;i++,r++){const a=e[i];if(a===`
|
|
178
178
|
`){o++,r=0;continue}const l=e[i+1];if(a==="$"&&l==="{"){n++,i++,r++;continue}if(n){a==="{"?n++:a==="}"&&n--;continue}if(a==="`"&&e[i-1]!=="\\"){const u=t.get(o)??[];u.push(r),t.set(o,u)}}return t},Ut=(e,t,n,o)=>{const r=[],i=String(t),a=i.length,l=" ".repeat(a),u=o[0],d=o[o.length-1],h=30,f=30,y=u-1,b=n.length-d;let p=n,w=o,S="",E="",x=0;if(y>h||b>f){let I=0,z=n.length,W=0;if(y>h){const Q=y-h;I=Q,W=-Q;const q=`[${Q} chars] ...`;S=H.dim(q),x=q.length}if(b>f){const Q=b-f;z=n.length-Q,E=H.dim(`... [${Q} chars]`)}p=n.substring(I,z),w=o.map(Q=>Q+W)}r.push(`${H.red.bold("error")}${H.bold(": system prompt file contains unescaped backtick")}`),r.push(`${H.blue.bold(" ".repeat(a)+" -->")} ${e}:${t}:${u}`),r.push(`${l} ${H.blue.bold("|")}`);const k=S+p+E;r.push(`${H.blue.bold(i)} ${H.blue.bold("|")} ${k}`);const D=x+w[0]-1,O=" ".repeat(D)+"^ unescaped backtick";r.push(`${l} ${H.blue.bold("|")} ${H.red.bold(O)}`),r.push(`${l} ${H.blue.bold("|")}`),r.push(`${H.cyan.bold("help")}: add \`\\\` before the backtick to escape it`),r.push(`${l} ${H.blue.bold("|")}`);const N=[];let j=0;for(const I of w)N.push(p.substring(j,I-1)),N.push(H.green("\\")+"`"),j=I;N.push(p.substring(j));const L=S+N.join("")+E;r.push(`${H.blue.bold(i)} ${H.blue.bold("|")} ${L}`);let B="",T=0;for(let I=0;I<w.length;I++){const z=w[I],W=x+z-1+T;B=B.padEnd(W," ")+"+",T++}return r.push(`${l} ${H.blue.bold("|")} ${H.green(B)}`),r.join(`
|
|
179
|
-
`)},Ht=(e,t,n,o,r,i=!1)=>{const a={};for(let d=0;d<o.length;d++){const h=o[d],f=String(t[d]),y=n[f];y&&(a[y]=h)}let l=e;const u=Object.entries(a).sort((d,h)=>h[0].length-d[0].length);for(const[d,h]of u){const f=new RegExp(`\\b${d}\\b`,"g");l=l.replace(f,h)}return l=l.replace(/<<CCVERSION>>/g,r),i&&(l=Ft(l)),l},Gt=async(e,t=!1)=>{if(!ze||rn!==e)return[];const n=ze,o=[];for(const r of n.prompts){const i=Vt(r.pieces,e),a=re.join(Se,`${r.id}.md`);let l;try{l=await oe.readFile(a,"utf8")}catch(h){console.error(`Failed to read markdown file ${a}:`,h);continue}const u=Vn(l),d=h=>{const f=h.slice(1);return Ht(u.content,r.identifiers,r.identifierMap,f,e,t)};o.push({promptId:r.id,prompt:u,regex:i,getInterpolatedContent:d,pieces:r.pieces,identifiers:r.identifiers,identifierMap:r.identifierMap})}return o},zt=e=>{const t=e.results.filter(i=>i.action==="created"),n=e.results.filter(i=>i.action==="updated"),o=e.results.filter(i=>i.action==="conflict"),r=e.results.filter(i=>i.action==="skipped");if((t.length>0||n.length>0||o.length>0)&&r.length>0&&(console.log(H.dim(`Skipped ${r.length} up-to-date file(s)`)),console.log()),t.length>0){console.log(H.bold.green(`Created ${t.length} new prompt file(s):`));for(const i of t)console.log(H.green(` ${Se}/${i.id}.md`)),console.log(H.green.dim(` ${i.description}`));console.log()}if(n.length>0){console.log(H.bold.blue(`Updated ${n.length} system prompt file(s):`));for(const i of n)i.oldVersion?console.log(H.blue(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)):console.log(H.blue(` ${i.id}.md (→ ${i.newVersion})`));console.log()}if(o.length>0){console.log(H.bold.yellow(`WARNING: Conflicts detected for ${o.length} system prompt file(s)`));for(const i of o)console.log(H.yellow(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)),console.log(H.yellow(` Open the diff in your browser: ${i.diffHtmlPath}`));console.log()}if(t.length>0&&(console.log(H.green.bold("New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.")),console.log(H.green(`You can now customize the markdown files at ${Se} in a text editor.`)),console.log(H.green('Then run tweakcc and select "apply" or use tweakcc --apply to update your system prompts')),console.log()),o.length>0){console.log(),console.log("Review conflicts:"),console.log(" 1. Open the diff HTML files in your browser"),console.log(" 2. Verify your customizations are still appropriate"),console.log(" 3. Update your markdown files if needed"),console.log(H.bold.cyan(" 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:"));for(const i of o)console.log(H.yellow(` ${i.id}.md → `)+H.bold.magenta(i.newVersion));console.log(" 5. Delete the diff HTML files"),console.log()}},le=Buffer.from(`
|
|
179
|
+
`)},Ht=(e,t,n,o,r,i=!1)=>{const a={};for(let d=0;d<o.length;d++){const h=o[d],f=String(t[d]),y=n[f];y&&(a[y]=h)}let l=e;const u=Object.entries(a).sort((d,h)=>h[0].length-d[0].length);for(const[d,h]of u){const f=new RegExp(`\\b${d}\\b`,"g");l=l.replace(f,()=>h)}return l=l.replace(/<<CCVERSION>>/g,r),i&&(l=Ft(l)),l},Gt=async(e,t=!1)=>{if(!ze||rn!==e)return[];const n=ze,o=[];for(const r of n.prompts){const i=Vt(r.pieces,e),a=re.join(Se,`${r.id}.md`);let l;try{l=await oe.readFile(a,"utf8")}catch(h){console.error(`Failed to read markdown file ${a}:`,h);continue}const u=Vn(l),d=h=>{const f=h.slice(1);return Ht(u.content,r.identifiers,r.identifierMap,f,e,t)};o.push({promptId:r.id,prompt:u,regex:i,getInterpolatedContent:d,pieces:r.pieces,identifiers:r.identifiers,identifierMap:r.identifierMap})}return o},zt=e=>{const t=e.results.filter(i=>i.action==="created"),n=e.results.filter(i=>i.action==="updated"),o=e.results.filter(i=>i.action==="conflict"),r=e.results.filter(i=>i.action==="skipped");if((t.length>0||n.length>0||o.length>0)&&r.length>0&&(console.log(H.dim(`Skipped ${r.length} up-to-date file(s)`)),console.log()),t.length>0){console.log(H.bold.green(`Created ${t.length} new prompt file(s):`));for(const i of t)console.log(H.green(` ${Se}/${i.id}.md`)),console.log(H.green.dim(` ${i.description}`));console.log()}if(n.length>0){console.log(H.bold.blue(`Updated ${n.length} system prompt file(s):`));for(const i of n)i.oldVersion?console.log(H.blue(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)):console.log(H.blue(` ${i.id}.md (→ ${i.newVersion})`));console.log()}if(o.length>0){console.log(H.bold.yellow(`WARNING: Conflicts detected for ${o.length} system prompt file(s)`));for(const i of o)console.log(H.yellow(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)),console.log(H.yellow(` Open the diff in your browser: ${i.diffHtmlPath}`));console.log()}if(t.length>0&&(console.log(H.green.bold("New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.")),console.log(H.green(`You can now customize the markdown files at ${Se} in a text editor.`)),console.log(H.green('Then run tweakcc and select "apply" or use tweakcc --apply to update your system prompts')),console.log()),o.length>0){console.log(),console.log("Review conflicts:"),console.log(" 1. Open the diff HTML files in your browser"),console.log(" 2. Verify your customizations are still appropriate"),console.log(" 3. Update your markdown files if needed"),console.log(H.bold.cyan(" 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:"));for(const i of o)console.log(H.yellow(` ${i.id}.md → `)+H.bold.magenta(i.newVersion));console.log(" 5. Delete the diff HTML files"),console.log()}},le=Buffer.from(`
|
|
180
180
|
---- Bun! ----
|
|
181
181
|
`),Ce=32,Yt=8,Ye=4*Yt+4;function ve(e,t){return e.subarray(t.offset,t.offset+t.length)}function Te(e,t){return{offset:e.readUInt32LE(t),length:e.readUInt32LE(t+4)}}function jn(e){return e.endsWith("/claude")||e==="claude"||e.endsWith("/claude.exe")||e==="claude.exe"}function Un(e,t,n){const o=ve(e,t.modulesPtr),r=Math.floor(o.length/Ye);for(let i=0;i<r;i++){const a=i*Ye,l=Wt(o,a),u=ve(e,l.name).toString("utf-8"),d=n(l,u,i);if(d!==void 0)return d}}function Hn(e){let t=0;const n=e.readBigUInt64LE(t);t+=8;const o=Te(e,t);t+=8;const r=e.readUInt32LE(t);t+=4;const i=Te(e,t);return{byteCount:n,modulesPtr:o,entryPointId:r,compileExecArgvPtr:i}}function Wt(e,t){let n=t;const o=Te(e,n);n+=8;const r=Te(e,n);n+=8;const i=Te(e,n);n+=8;const a=Te(e,n);n+=8;const l=e.readUInt8(n);n+=1;const u=e.readUInt8(n);n+=1;const d=e.readUInt8(n);n+=1;const h=e.readUInt8(n);return{name:o,contents:r,sourcemap:i,bytecode:a,encoding:l,loader:u,moduleFormat:d,side:h}}function Jt(e){if(e.length<Ce+le.length)throw new Error("BUN data is too small to contain trailer and offsets");const t=e.length-le.length,n=e.subarray(t);if(M()&&(console.log(`parseBunDataBlob: Expected trailer: ${le.toString("hex")}`),console.log(`parseBunDataBlob: Got trailer: ${n.toString("hex")}`)),!n.equals(le))throw M()&&(console.log(`Expected: ${le.toString("hex")}`),console.log(`Got: ${n.toString("hex")}`)),new Error("BUN trailer bytes do not match trailer");const o=e.length-Ce-le.length,r=e.subarray(o,o+Ce);return{bunOffsets:Hn(r),bunData:e}}function Gn(e){if(e.length<4)throw new Error("Section data too small");M()&&console.log(`extractBunDataFromSection: sectionData.length=${e.length}`);const t=e.readUInt32LE(0);M()&&console.log(`extractBunDataFromSection: bunDataSize from header=${t}`);const n=e.subarray(4,4+t);M()&&console.log(`extractBunDataFromSection: bunDataContent.length=${n.length}`);const{bunOffsets:o,bunData:r}=Jt(n);return{bunOffsets:o,bunData:r}}function qt(e){if(!e.hasOverlay)throw new Error("ELF binary has no overlay data");const t=e.overlay;if(M()&&console.log(`extractBunDataFromELFOverlay: Overlay size=${t.length} bytes`),t.length<le.length+8+Ce)throw new Error("ELF overlay data is too small");const n=t.readBigUInt64LE(t.length-8);if(M()&&console.log(`extractBunDataFromELFOverlay: Total byte count from tail=${n}`),n<4096n||n>2n**32n-1n)throw new Error(`ELF total byte count is out of range: ${n}`);const o=t.length-8-le.length,r=t.subarray(o,t.length-8);if(M()&&(console.log(`extractBunDataFromELFOverlay: Expected trailer: ${le.toString("hex")}`),console.log(`extractBunDataFromELFOverlay: Got trailer: ${r.toString("hex")}`)),!r.equals(le))throw new Error("BUN trailer bytes do not match trailer");const i=t.length-8-le.length-Ce,a=t.subarray(i,t.length-8-le.length),l=Hn(a);M()&&console.log(`extractBunDataFromELFOverlay: Offsets.byteCount=${l.byteCount}`);const u=typeof l.byteCount=="bigint"?l.byteCount:BigInt(l.byteCount);if(u>=n)throw new Error("ELF total byte count is out of range");const d=8+le.length+Ce,h=t.length-d-Number(u),f=t.subarray(h,t.length-d);M()&&console.log(`extractBunDataFromELFOverlay: Extracted ${f.length} bytes of data`);const y=Buffer.concat([f,a,r]);return{bunOffsets:l,bunData:y}}function Kt(e){const t=e.getSegment("__BUN");if(!t)throw new Error("__BUN segment not found");const n=t.getSection("__bun");if(!n)throw new Error("__bun section not found");return Gn(n.content)}function Xt(e){const t=e.sections().find(n=>n.name===".bun");if(!t)throw new Error(".bun section not found");return Gn(t.content)}function zn(e){switch(M()&&console.log(`getBunData: Binary format detected as ${e.format}`),e.format){case"MachO":return Kt(e);case"PE":return Xt(e);case"ELF":return qt(e);default:throw new Error(`Unsupported binary format: ${e.format}`)}}function Yn(e){try{Fe.logging.disable();const t=Fe.parse(e),{bunOffsets:n,bunData:o}=zn(t);M()&&console.log(`extractClaudeJsFromNativeInstallation: Got bunData, size=${o.length} bytes`);const r=Un(o,n,(i,a,l)=>{if(M()&&console.log(`extractClaudeJsFromNativeInstallation: Module ${l}: ${a}`),!jn(a))return;const u=ve(o,i.contents);return M()&&console.log(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${u.length}`),u.length>0?u:void 0});return r||(M()&&console.log("extractClaudeJsFromNativeInstallation: claude module not found in any module"),null)}catch(t){return M()&&console.log("extractClaudeJsFromNativeInstallation: Error during extraction:",t),null}}function Zt(e,t,n){const o=[],r=[];Un(e,t,(k,D)=>{const O=ve(e,k.name);let N;n&&jn(D)?N=n:N=ve(e,k.contents);const j=ve(e,k.sourcemap),L=ve(e,k.bytecode);r.push({name:O,contents:N,sourcemap:j,bytecode:L,encoding:k.encoding,loader:k.loader,moduleFormat:k.moduleFormat,side:k.side}),o.push(O,N,j,L)});let i=0;const a=[];for(const k of o)a.push({offset:i,length:k.length}),i+=k.length+1;const l=i,u=r.length*Ye;i+=u;const d=ve(e,t.compileExecArgvPtr),h=i,f=d.length;i+=f+1;const y=i;i+=Ce;const b=i;i+=le.length;const p=Buffer.allocUnsafe(i);p.fill(0);let w=0;for(const{offset:k,length:D}of a)D>0&&o[w].copy(p,k,0,D),p[k+D]=0,w++;f>0&&(d.copy(p,h,0,f),p[h+f]=0);for(let k=0;k<r.length;k++){const D=r[k],O=k*4,N={name:{offset:a[O].offset,length:a[O].length},contents:{offset:a[O+1].offset,length:a[O+1].length},sourcemap:{offset:a[O+2].offset,length:a[O+2].length},bytecode:{offset:a[O+3].offset,length:a[O+3].length},encoding:D.encoding,loader:D.loader,moduleFormat:D.moduleFormat,side:D.side};let L=l+k*Ye;p.writeUInt32LE(N.name.offset,L),p.writeUInt32LE(N.name.length,L+4),L+=8,p.writeUInt32LE(N.contents.offset,L),p.writeUInt32LE(N.contents.length,L+4),L+=8,p.writeUInt32LE(N.sourcemap.offset,L),p.writeUInt32LE(N.sourcemap.length,L+4),L+=8,p.writeUInt32LE(N.bytecode.offset,L),p.writeUInt32LE(N.bytecode.length,L+4),L+=8,p.writeUInt8(N.encoding,L),p.writeUInt8(N.loader,L+1),p.writeUInt8(N.moduleFormat,L+2),p.writeUInt8(N.side,L+3)}const S={byteCount:y,modulesPtr:{offset:l,length:u},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:h,length:f}};let E=y;const x=typeof S.byteCount=="bigint"?S.byteCount:BigInt(S.byteCount);return p.writeBigUInt64LE(x,E),E+=8,p.writeUInt32LE(S.modulesPtr.offset,E),p.writeUInt32LE(S.modulesPtr.length,E+4),E+=8,p.writeUInt32LE(S.entryPointId,E),E+=4,p.writeUInt32LE(S.compileExecArgvPtr.offset,E),p.writeUInt32LE(S.compileExecArgvPtr.length,E+4),le.copy(p,b),p}function an(e,t,n,o=!0){const r=t+".tmp";if(e.write(r),o){const i=Le.statSync(n);Le.chmodSync(r,i.mode)}try{Le.renameSync(r,t)}catch(i){try{Le.existsSync(r)&&Le.unlinkSync(r)}catch{}throw i instanceof Error&&"code"in i&&(i.code==="ETXTBSY"||i.code==="EBUSY"||i.code==="EPERM")?new Error(`Cannot update the Claude executable while it is running.
|
|
182
182
|
Please close all Claude instances and try again.`):i}}function Wn(e){const t=Buffer.allocUnsafe(4+e.length);return t.writeUInt32LE(e.length,0),e.copy(t,4),t}function Qt(e,t,n,o){try{M()&&console.log(`repackMachO: Has code signature: ${e.hasCodeSignature}`),e.hasCodeSignature&&(M()&&console.log("repackMachO: Removing code signature..."),e.removeSignature());const r=e.getSegment("__BUN");if(!r)throw new Error("__BUN segment not found");const i=r.getSection("__bun");if(!i)throw new Error("__bun section not found");const a=Wn(n);M()&&(console.log(`repackMachO: Original section size: ${i.size}`),console.log(`repackMachO: Original segment fileSize: ${r.fileSize}`),console.log(`repackMachO: Original segment virtualSize: ${r.virtualSize}`),console.log(`repackMachO: New data size: ${a.length}`));const l=a.length-Number(i.size);if(l>0){const u=e.header.cpuType===Fe.MachO.Header.CPU_TYPE.ARM64,d=u?16384:4096,h=Math.ceil(l/d)*d;M()&&(console.log(`repackMachO: CPU type: ${u?"ARM64":"x86_64"}`),console.log(`repackMachO: Page size: ${d} bytes`),console.log(`repackMachO: Need to expand by ${l} bytes`),console.log(`repackMachO: Rounding up to page-aligned: ${h} bytes`));const f=e.extendSegment(r,h);if(M()&&console.log(`repackMachO: extendSegment returned: ${f}`),!f)throw new Error("Failed to extend __BUN segment");M()&&(console.log(`repackMachO: Section size after extend: ${i.size}`),console.log(`repackMachO: Segment fileSize after extend: ${r.fileSize}`),console.log(`repackMachO: Segment virtualSize after extend: ${r.virtualSize}`))}i.content=a,i.size=BigInt(a.length),M()&&(console.log(`repackMachO: Final section size: ${i.size}`),console.log(`repackMachO: Writing modified binary to ${o}...`)),an(e,o,t);try{M()&&console.log("repackMachO: Re-signing binary with ad-hoc signature..."),Bn(`codesign -s - -f "${o}"`,{stdio:M()?"inherit":"ignore"}),M()&&console.log("repackMachO: Code signing completed successfully")}catch(u){console.warn("Warning: Failed to re-sign binary. The binary may not run correctly on macOS:",u)}M()&&console.log("repackMachO: Write completed successfully")}catch(r){throw console.error("repackMachO failed:",r),r}}function eo(e,t,n,o){try{const r=e.sections().find(a=>a.name===".bun");if(!r)throw new Error(".bun section not found");const i=Wn(n);M()&&(console.log(`repackPE: Original section size: ${r.size}, virtual size: ${r.virtualSize}`),console.log(`repackPE: New data size: ${i.length}`)),r.content=i,r.virtualSize=BigInt(i.length),r.size=BigInt(i.length),M()&&console.log(`repackPE: Writing modified binary to ${o}...`),an(e,o,t,!1),M()&&console.log("repackPE: Write completed successfully")}catch(r){throw console.error("repackPE failed:",r),r}}function no(e,t,n,o){try{const r=Buffer.allocUnsafe(n.length+8);n.copy(r,0),r.writeBigUInt64LE(BigInt(n.length),n.length),M()&&console.log(`repackELF: Setting overlay data (${r.length} bytes)`),e.overlay=r,M()&&console.log(`repackELF: Writing modified binary to ${o}...`),an(e,o,t),M()&&console.log("repackELF: Write completed successfully")}catch(r){throw console.error("repackELF failed:",r),r}}function to(e,t,n){Fe.logging.disable();const o=Fe.parse(e),{bunOffsets:r,bunData:i}=zn(o),a=Zt(i,r,t);switch(o.format){case"MachO":Qt(o,e,a,n);break;case"PE":eo(o,e,a,n);break;case"ELF":no(o,e,a,n);break;default:throw new Error(`Unsupported binary format: ${o.format}`)}}const cn=async()=>{await ie.mkdir(ce,{recursive:!0}),await ie.mkdir(Se,{recursive:!0});const e=On.join(ce,".gitignore");try{await ie.stat(e)}catch(t){t instanceof Error&&"code"in t&&t.code==="ENOENT"&&await ie.writeFile(e,[".DS_Store","prompt-data-cache","cli.js.backup","native-binary.backup","native-claudejs-orig.js","native-claudejs-patched.js","systemPromptAppliedHashes.json","systemPromptOriginalHashes.json","system-prompts"].join(bn)+bn)}};let Re={settings:ee,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null};const dn=async()=>{const e={ccVersion:"",ccInstallationDir:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:ee};try{M()&&console.log(`Reading config at ${ae}`);const t=await ie.readFile(ae,"utf8"),n={...e,...JSON.parse(t)},o=n?.settings?.thinkingVerbs;o?.punctuation&&(o.format="{}"+o.punctuation,delete o.punctuation),n.settings.inputBox||(n.settings.inputBox=ee.inputBox),n.settings.toolsets||(n.settings.toolsets=ee.toolsets),Object.hasOwn(n.settings,"defaultToolset")||(n.settings.defaultToolset=ee.defaultToolset),Object.hasOwn(n.settings,"planModeToolset")||(n.settings.planModeToolset=ee.planModeToolset);for(const i of ee.themes){const a=n?.settings?.themes.find(l=>l.id===i.id||l.name===i.name);if(a){for(const[l,u]of Object.entries(i))l!=="colors"&&!Object.hasOwn(a,l)&&(a[l]=u);a.colors||(a.colors={});for(const[l,u]of Object.entries(i.colors))Object.hasOwn(a.colors,l)||(a.colors[l]=u)}}for(const i of n?.settings?.themes||[]){if(ee.themes.some(u=>u.id===i.id||u.name===i.name))continue;const l=ee.themes[0];i.colors||(i.colors={});for(const[u,d]of Object.entries(l.colors))Object.hasOwn(i.colors,u)||(i.colors[u]=d)}return n?.settings?.userMessageDisplay||(n.settings=n.settings||ee,n.settings.userMessageDisplay=ee.userMessageDisplay),delete n.settings.launchText,await Tt(Se)&&(n.changesApplied=!1),Re=n,n}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return e;throw t}},je=async e=>(M()&&console.log(`Updating config at ${ae}`),e(Re),Re.lastModified=new Date().toISOString(),await oo(Re),Re),oo=async e=>{try{e.lastModified=new Date().toISOString(),await cn(),await ie.writeFile(ae,JSON.stringify(e,null,2))}catch(t){throw console.error("Error saving config:",t),t}},Jn=async e=>{if(!e.cliPath)return M()&&console.log("restoreClijsFromBackup: Skipping for native installation (no cliPath)"),!1;M()&&console.log(`Restoring cli.js from backup to ${e.cliPath}`);const t=await ie.readFile(Ne);return await fn(e.cliPath,t,"restore"),await kt(),await je(n=>{n.changesApplied=!1}),!0},qn=async e=>{if(!e.nativeInstallationPath)return M()&&console.log("restoreNativeBinaryFromBackup: No native installation path, skipping"),!1;if(!await Oe(ge))return M()&&console.log("restoreNativeBinaryFromBackup: No backup file exists, skipping"),!1;M()&&console.log(`Restoring native binary from backup to ${e.nativeInstallationPath}`);const t=await ie.readFile(ge);return await fn(e.nativeInstallationPath,t,"restore"),!0};async function ro(){try{const t=process.platform==="win32"?"where claude.exe":"which claude";M()&&console.log(`Looking for claude executable using: ${t}`);const o=Bn(t,{encoding:"utf8"}).trim().split(`
|
|
@@ -191,7 +191,7 @@ Please close all Claude instances and try again.`):i}}function Wn(e){const t=Buf
|
|
|
191
191
|
${D}`),console.log(`
|
|
192
192
|
User's content:
|
|
193
193
|
${h.content}`))),M()&&(console.log(`
|
|
194
|
-
Found match for prompt: ${h.name}`),console.log(` Match location: index ${E.index}, length ${E[0].length}`),console.log(` Original content (first 100 chars): ${E[0].substring(0,100)}...`),console.log(` Replacement content (first 100 chars): ${x.substring(0,100)}...`),console.log(` Captured variables: ${E.slice(1).join(", ")}`),console.log(` Content identical: ${E[0]===x}`));const j=e,L=E.index,B=E[0].length;e=e.replace(S,x);const T=We(h.content);await Et(d,T),M()&&G(j,e,x,L,L+B)}else if(console.log(H.yellow(`Could not find system prompt "${h.name}" in cli.js (using regex ${zo(S)})`)),M()){console.log(`
|
|
194
|
+
Found match for prompt: ${h.name}`),console.log(` Match location: index ${E.index}, length ${E[0].length}`),console.log(` Original content (first 100 chars): ${E[0].substring(0,100)}...`),console.log(` Replacement content (first 100 chars): ${x.substring(0,100)}...`),console.log(` Captured variables: ${E.slice(1).join(", ")}`),console.log(` Content identical: ${E[0]===x}`));const j=e,L=E.index,B=E[0].length;e=e.replace(S,()=>x);const T=We(h.content);await Et(d,T),M()&&G(j,e,x,L,L+B)}else if(console.log(H.yellow(`Could not find system prompt "${h.name}" in cli.js (using regex ${zo(S)})`)),M()){console.log(`
|
|
195
195
|
Debug info for ${h.name}:`),console.log(` Regex pattern (first 200 chars): ${f.substring(0,200)}...`),console.log(" Trying to match pattern in cli.js...");const x=e.match(new RegExp(f.substring(0,100)));console.log(` Partial match result: ${x?"found partial":"no match"}`)}}const l=[],u=i-a;return u>0?l.push(`system prompts: \${CHALK_VAR.green('${u} fewer chars')} than original`):u<0&&l.push(`system prompts: \${CHALK_VAR.red('${Math.abs(u)} more chars')} than original`),{newContent:e,items:l}},Wo=e=>{const t=/ensureServerStarted:([$\w]+)\b/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: fixLspSupport: failed to find ensureServerStarted"),null;const o=Math.max(0,n.index-50),r=Math.min(e.length,n.index+50),i=e.slice(o,r),a=/sendRequest:([$\w]+)[,}]/,l=i.match(a);if(!l)return console.error(`patch: fixLspSupport: failed to find sendRequest near ensureServerStarted, window=${JSON.stringify([o,r,i])}`),null;const u=l[1],d=Math.max(0,n.index-2e3),h=e.slice(d,n.index),f=new RegExp(`async function ${fe(u)}\\(([$\\w]+),`,"g");let y,b=null;for(;(y=f.exec(h))!==null;)b=y;if(!b)return console.error(`patch: fixLspSupport: failed to find async function ${u}`),null;const p=b[1],w=d+b.index,S=e.slice(w,n.index),E=/let ([$\w]+)=await [$\w]+\([$\w]+\);/,x=S.match(E);if(!x||x.index===void 0)return console.error("patch: fixLspSupport: failed to find second line of sendRequest"),null;const k=x[1],D=w+x.index+x[0].length,O=e.slice(D,n.index),N=new RegExp(`if\\(!${fe(k)}\\)return;`),j=O.match(N);if(!j||j.index===void 0)return console.error("patch: fixLspSupport: failed to find if(!serverVar)return; line"),null;const L=D+j.index+j[0].length;return{startIndex:L,endIndex:L,identifiers:[p,k]}},Jo=e=>{const t=/if\([$\w]+\.restartOnCrash!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': restartOnCrash is not yet implemented\. Remove this field from the configuration\.`\);/g,n=/if\([$\w]+\.startupTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': startupTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g,o=/if\([$\w]+\.shutdownTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': shutdownTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g;let r=e;const i=r;r=r.replace(t,""),r!==i?G(i,r,"",0,0):console.warn("patch: fixLspSupport: restartOnCrash validation not found");const a=r;r=r.replace(n,""),r!==a?G(a,r,"",0,0):console.warn("patch: fixLspSupport: startupTimeout validation not found");const l=r;r=r.replace(o,""),r!==l?G(l,r,"",0,0):console.warn("patch: fixLspSupport: shutdownTimeout validation not found");const u=Wo(r);if(!u||!u.identifiers)return null;const[d,h]=u.identifiers,f=`
|
|
196
196
|
const path = await import('path');
|
|
197
197
|
const ext = path.extname(${d}).toLowerCase();
|
|
@@ -644,9 +644,9 @@ for (const file of ${a}) {
|
|
|
644
644
|
}
|
|
645
645
|
`;l=l.slice(0,r)+u+l.slice(r),G(e,l,u,r,r);const d=o+u.length,h=`||tweakccSummaries.has(${i}.uuid)`,f=l.slice(0,d)+h+l.slice(d);return G(l,f,h,d,d),f},xr=e=>{const t=/description:"Rename the current conversation",isEnabled:\(\)=>!1,/,n=e.match(t);if(!n)return console.error("patch: conversationTitle: enableRenameConversationCommand: failed to find pattern"),null;if(n.index===void 0)return console.error("patch: conversationTitle: enableRenameConversationCommand: match.index is undefined"),null;const o='description:"Rename the current conversation",isEnabled:()=>!1,',r='description:"Rename the current conversation",isEnabled:()=>!0,',i=e.replace(o,r);return i===e?(console.error("patch: conversationTitle: enableRenameConversationCommand: replacement failed"),null):(G(e,i,r,n.index,n.index+63),i)},yr=e=>{let t=e;if(t=hr(t),!t)return console.error("patch: conversationTitle: step 1 failed (writeTitleSlashCommand)"),null;if(t=fr(t),!t)return console.error("patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)"),null;if(t=pr(t),!t)return console.error("patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)"),null;if(t=wr(t),!t)return console.error("patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)"),null;const n=xr(t);return n?t=n:console.log("patch: conversationTitle: step 5 failed (enableRenameConversationCommand)"),t},G=(e,t,n,o,r)=>{if(!M())return;const i=Math.max(0,o-20),a=Math.min(e.length,r+20),l=Math.min(t.length,o+n.length+20),u=e.slice(i,o),d=e.slice(o,r),h=e.slice(r,a),f=t.slice(i,o),y=t.slice(o,o+n.length),b=t.slice(o+n.length,l);d!==y&&(console.log(`
|
|
646
646
|
--- Diff ---`),console.log("OLD:",u+`\x1B[31m${d}\x1B[0m`+h),console.log("NEW:",f+`\x1B[32m${y}\x1B[0m`+b),console.log(`--- End Diff ---
|
|
647
|
-
`))},fe=e=>e.replace(/\$/g,"\\$"),un=e=>{const t=/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g,n=Array.from(e.matchAll(t)),o={};for(const a of n){const l=a[1];o[l]=(o[l]||0)+1}let r,i=0;for(const[a,l]of Object.entries(o))l>i&&(i=l,r=a);return r},Sr=e=>{const t=e.slice(0,1e3),n=/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/,o=t.match(n);if(!o){console.log("patch: getModuleLoaderFunction: failed to find module loader function");return}return o[1]},et=e=>{const t=/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.element"\)/,n=e.match(t);if(!n){console.log("patch: getReactModuleNameNonBun: failed to find React module name");return}return n[1]},vr=e=>{const t=et(e);if(!t){console.log("^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)");return}const n=new RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${fe(t)}\\(\\)`),o=e.match(n);if(!o){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return o[1]};let he=null,ke=null;const qe=e=>{if(he!=null)return he;const t=Sr(e);if(!t){console.log("^ patch: getReactVar: failed to find moduleLoader"),he=void 0;return}const n=et(e);if(!n){console.log("^ patch: getReactVar: failed to find reactModuleVarNonBun"),he=void 0;return}const o=new RegExp(`\\b([$\\w]+)=${fe(t)}\\(${fe(n)}\\(\\),1\\)`),r=e.match(o);if(r)return he=r[1],he;const i=vr(e);if(!i){console.log("^ patch: getReactVar: failed to find reactModuleFunctionBun"),he=void 0;return}const a=new RegExp(`\\b([$\\w]+)=${fe(t)}\\(${fe(i)}\\(\\),1\\)`),l=e.match(a);if(!l){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${i})`),he=void 0;return}return he=l[1],he},$r=e=>{const t=/import\{createRequire as ([$\w]+)\}from"node:module";/,n=e.match(t);if(!n)return;const o=n[1],r=new RegExp(`var ([$\\w]+)=${fe(o)}\\(import\\.meta\\.url\\)`),i=e.match(r);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${o})`);return}return i[1]},hn=e=>{if(ke!=null)return ke;const t=$r(e);return t?(ke=t,ke):(ke="require",ke)},nt=e=>{const t=/\bfunction ([$\w]+)\(\{color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+=![01],bold:[$\w]+=![01]/,n=e.match(t);if(!n){console.log("patch: findTextComponent: failed to find text component");return}return n[1]},tt=e=>{const t=/\b([$\w]+)\.displayName="Box"/,n=e.match(t);if(!n){console.error("patch: findBoxComponent: failed to find Box displayName");return}const o=n[1],r=new RegExp(`\\b([$\\w]+)=${fe(o)}[^$\\w]`),i=e.match(r);if(!i){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${o})`);return}return i[1]},ot=async(e,t)=>{let n;if(t.nativeInstallationPath){await qn(t);let u=!1;try{await oe.stat(ge),u=!0}catch{}const d=u?ge:t.nativeInstallationPath;M()&&console.log(`Extracting claude.js from ${u?"backup":"native installation"}: ${d}`);const h=Yn(d);if(!h)throw new Error("Failed to extract claude.js from native installation");const f=re.join(ye.homedir(),".tweakcc"),y=re.join(f,"native-claudejs-orig.js");Ie.writeFileSync(y,h),M()&&console.log(`Saved original extracted JS from native to: ${y}`),n=h.toString("utf8")}else{if(await Jn(t),!t.cliPath)throw new Error("cliPath is required for NPM installations");n=await oe.readFile(t.cliPath,{encoding:"utf8"})}const o=[],r=await Yo(n,t.version);n=r.newContent,o.push(...r.items);let i=null;e.settings.themes&&e.settings.themes.length>0&&(i=uo(n,e.settings.themes))&&(n=i),e.settings.thinkingVerbs&&((i=Mo(n,e.settings.thinkingVerbs.verbs))&&(n=i),(i=xo(n,e.settings.thinkingVerbs.format))&&(n=i)),(i=$o(n,e.settings.thinkingStyle.phases))&&(n=i),(i=Co(n,e.settings.thinkingStyle.updateInterval))&&(n=i),(i=Eo(n,Math.max(...e.settings.thinkingStyle.phases.map(u=>u.length))+1))&&(n=i),(i=So(n,e.settings.thinkingStyle.reverseMirror))&&(n=i),e.settings.userMessageDisplay&&(i=Oo(n,e.settings.userMessageDisplay.prefix.format,e.settings.userMessageDisplay.prefix.foreground_color,e.settings.userMessageDisplay.prefix.background_color,e.settings.userMessageDisplay.prefix.styling.includes("bold"),e.settings.userMessageDisplay.prefix.styling.includes("italic"),e.settings.userMessageDisplay.prefix.styling.includes("underline"),e.settings.userMessageDisplay.prefix.styling.includes("strikethrough"),e.settings.userMessageDisplay.prefix.styling.includes("inverse"),e.settings.userMessageDisplay.message.foreground_color,e.settings.userMessageDisplay.message.background_color,e.settings.userMessageDisplay.message.styling.includes("bold"),e.settings.userMessageDisplay.message.styling.includes("italic"),e.settings.userMessageDisplay.message.styling.includes("underline"),e.settings.userMessageDisplay.message.styling.includes("strikethrough"),e.settings.userMessageDisplay.message.styling.includes("inverse")))&&(n=i),e.settings.inputBox&&typeof e.settings.inputBox.removeBorder=="boolean"&&(i=mo(n,e.settings.inputBox.removeBorder))&&(n=i),(i=Ao(n))&&(n=i),(i=bo(n))&&(n=i),(i=go(n))&&(n=i),(i=Ir(n))&&(n=i),(i=ao(n,25))&&(n=i),(i=Do(n))&&(n=i);const a=e.settings.misc?.showTweakccVersion??!0,l=e.settings.misc?.showPatchesApplied??!0;if((i=Ho(n,"3.1.4",o,a,l))&&(n=i),(i=Jo(n))&&(n=i),e.settings.toolsets&&e.settings.toolsets.length>0&&(i=ur(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=i),e.settings.planModeToolset&&e.settings.defaultToolset&&((i=ar(n))&&(n=i),(i=dr(n,e.settings.planModeToolset,e.settings.defaultToolset))&&(n=i)),(i=yr(n))&&(n=i),t.nativeInstallationPath){M()&&console.log(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);const u=re.join(ye.homedir(),".tweakcc"),d=re.join(u,"native-claudejs-patched.js");Ie.writeFileSync(d,n,"utf8"),M()&&console.log(`Saved patched JS from native to: ${d}`);const h=Buffer.from(n,"utf8");to(t.nativeInstallationPath,h,t.nativeInstallationPath)}else{if(!t.cliPath)throw new Error("cliPath is required for NPM installations");await fn(t.cliPath,n,"patch")}return await je(u=>{u.changesApplied=!0})},rt=[{label:"Opus 4.1",slug:"opus-4.1",internal:"claude-opus-4-1-20250805"},{label:"Opus 4",slug:"opus-4",internal:"claude-opus-4-20250514"},{label:"Sonnet 4",slug:"sonnet-4",internal:"claude-sonnet-4-20250514"},{label:"Sonnet 3.7",slug:"sonnet-3.7",internal:"claude-3-7-sonnet-20250219"},{label:"Sonnet 3.5 (October)",slug:"sonnet-3.5-october",internal:"claude-3-5-sonnet-20241022"},{label:"Sonnet 3.5 (June)",slug:"sonnet-3.5-june",internal:"claude-3-5-sonnet-20240620"},{label:"Haiku 3.5",slug:"haiku-3.5",internal:"claude-3-5-haiku-20241022"},{label:"Haiku 3",slug:"haiku-3",internal:"claude-3-haiku-20240307"},{label:"Opus 3",slug:"opus-3",internal:"claude-3-opus-20240229"}],_r=e=>{const t=e.indexOf("Switch between Claude models");if(t===-1)return console.error("patch: getModelSelectorInsertionPoint: failed to find labelIndex"),null;const n=Math.max(0,t-600),o=t,i=e.slice(n,o).match(/\[[$\w]+,\s*[$\w]+\]\s*=\s*[$\w]+\.useState\([^)]*\)\s*,\s*([$\w]+)=/);if(!i||i.index===void 0)return console.error("patch: getModelSelectorInsertionPoint: failed to find useState"),null;let l=n+i.index;for(;l<e.length&&e[l]!==";";)l++;if(l>=e.length)return console.error("patch: getModelSelectorInsertionPoint: failed to find semicolon"),null;const u=l+1,d=i[1];return{insertionIndex:u,optionsVar:d}},Cr=e=>{const t=_r(e);if(!t)return null;const{insertionIndex:n,optionsVar:o}=t,r=rt.map(a=>{const l=JSON.stringify(a.label),u=JSON.stringify(a.slug);return`${o}.push({value:${u},label:${l}});`}).join(""),i=e.slice(0,n)+r+e.slice(n);return G(e,i,r,n,n),i},Ir=e=>{let t=e;const n=Cr(t);return n&&(t=n),t===e?null:t};let it=!1;const M=()=>it,Er=()=>{it=!0};function Ke(){try{const e=re.join(ye.homedir(),".claude.json");return JSON.parse(Ie.readFileSync(e,"utf8")).theme||"dark"}catch{}return"dark"}function kr(){try{const e=re.join(ye.homedir(),".claude",".credentials.json");switch(JSON.parse(Ie.readFileSync(e,"utf8"))?.claudeAiOauth?.subscriptionType||"unknown"){case"enterprise":return"Claude Enterprise";case"team":return"Claude Team";case"max":return"Claude Max";case"pro":return"Claude Pro"}}catch{}return"Claude API"}function Tr(){try{const e=re.join(ye.homedir(),".claude","settings.json"),n=JSON.parse(Ie.readFileSync(e,"utf8"))?.model||"default";if(n==="opus")return"Opus 4.1";const o=rt.find(r=>r.slug===n);if(o)return o.label}catch{}return"Sonnet 4.5"}function Mr(e){process.platform==="win32"?Me.spawn("explorer",[e],{detached:!0,stdio:"ignore"}).unref():process.platform==="darwin"?Me.spawn("open",[e],{detached:!0,stdio:"ignore"}).unref():Me.spawn("xdg-open",[e],{detached:!0,stdio:"ignore"}).unref()}function kn(e){if(process.platform==="win32")Me.spawn("explorer",["/select,",e],{detached:!0,stdio:"ignore"}).unref();else if(process.platform==="darwin")Me.spawn("open",["-R",e],{detached:!0,stdio:"ignore"}).unref();else{const t=re.dirname(e);Me.spawn("xdg-open",[t],{detached:!0,stdio:"ignore"}).unref()}}function gn(e){if(!e||typeof e!="string")return!1;const t=e.trim();if(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/.test(t))return!0;if(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/.test(t)){const n=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const[,o,r,i]=n;return parseInt(o)<=255&&parseInt(r)<=255&&parseInt(i)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const[,o,r,i]=n;return parseInt(o)<=360&&parseInt(r)<=100&&parseInt(i)<=100}}return!1}function st(e){if(!gn(e))return e;const t=e.trim();if(t.startsWith("rgb("))return t;if(t.startsWith("#")){let n=t.slice(1);n.length===3&&(n=n.split("").map(a=>a+a).join(""));const o=parseInt(n.slice(0,2),16),r=parseInt(n.slice(2,4),16),i=parseInt(n.slice(4,6),16);return`rgb(${o},${r},${i})`}if(t.startsWith("hsl(")){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const o=parseInt(n[1])/360,r=parseInt(n[2])/100,i=parseInt(n[3])/100,a=(y,b,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<1/6?y+(b-y)*6*p:p<1/2?b:p<2/3?y+(b-y)*(2/3-p)*6:y),l=i<.5?i*(1+r):i+r-i*r,u=2*i-l,d=Math.round(a(u,l,o+1/3)*255),h=Math.round(a(u,l,o)*255),f=Math.round(a(u,l,o-1/3)*255);return`rgb(${d},${h},${f})`}}return e}async function Nr(e,t="sha256",n=64*1024){return new Promise((o,r)=>{const i=An.createHash(t),a=Ie.createReadStream(e,{highWaterMark:n});a.on("data",l=>{i.update(l)}),a.on("end",()=>{o(i.digest("hex"))}),a.on("error",l=>{r(l)})})}const Tn=(e,t,n,o,r,i,a,l)=>{let u=e;return t&&(u+=`.rgb(${t})`),n&&n!=="transparent"&&(u+=`.bgRgb(${n})`),o&&(u+=".bold"),r&&(u+=".italic"),i&&(u+=".underline"),a&&(u+=".strikethrough"),l&&(u+=".inverse"),u};async function fn(e,t,n="replace"){let o=493;try{o=(await oe.stat(e)).mode,M()&&console.log(`[${n}] Original file mode for ${e}: ${(o&parseInt("777",8)).toString(8)}`)}catch(r){M()&&console.log(`[${n}] Could not stat ${e} (error: ${r}), using default mode 755`)}try{await oe.unlink(e),M()&&console.log(`[${n}] Unlinked ${e} to break hard links`)}catch(r){M()&&console.log(`[${n}] Could not unlink ${e}: ${r}`)}await oe.writeFile(e,t),await oe.chmod(e,o),M()&&console.log(`[${n}] Restored permissions to ${(o&parseInt("777",8)).toString(8)}`)}function U({color:e,backgroundColor:t,bold:n,dimColor:o,children:r}){const i=e?.startsWith("ansi:"),a=t?.startsWith("ansi:");if(i||a){if(Ze.Children.toArray(r).some(f=>Ze.isValidElement(f)))return s(c,{children:r});let u=H;if(i){const f=e.slice(5);u=u[f]||u}if(a){const f=t.slice(5),y=f.startsWith("bg")?f:`bg${f.charAt(0).toUpperCase()}${f.slice(1)}`;u=u[y]||u}n&&(u=u.bold),o&&(u=u.dim);const h=Ze.Children.toArray(r).map(f=>typeof f=="string"||typeof f=="number"?String(f):"").join("");return s(c,{children:u(h)})}return s(c,{color:e,backgroundColor:t,bold:n,dimColor:o,children:r})}function Or({text:e,nonShimmerColors:t,shimmerColors:n,shimmerWidth:o=3,updateDuration:r=50,restartPoint:i=10}){const[a,l]=P(0);return xe(()=>{const u=setInterval(()=>{l(d=>{const h=d+1;return h>=e.length+i?-o:h})},r);return()=>clearInterval(u)},[e.length,i,r]),t.length!==n.length?(console.error("UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length"),s(c,{children:e})):s(c,{children:e.split("").map((u,d)=>{const h=d>=a&&d<a+o&&a<e.length,f=d%t.length,y=h?n[f]:t[f];return s(c,{color:y,children:u},d)})})}const Br=ft.cwd();function lt({theme:e}){const{ccVersion:t}=be(ue);return g(m,{flexDirection:"column",paddingLeft:1,children:[s(m,{marginBottom:1,children:g(c,{bold:!0,children:["Preview: ",e.name]})}),s(m,{borderStyle:"single",borderColor:"gray",paddingX:1,children:g(m,{flexDirection:"column",children:[g(m,{flexDirection:"column",children:[g(c,{children:[s(U,{color:e.colors.clawd_body,children:" ▐"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"▛███▜"}),g(c,{children:[s(U,{color:e.colors.clawd_body,children:"▌ "})," ",s(c,{bold:!0,children:"Claude Code"})," ",t?`v${t}`:"v2.0.14"]})]}),g(c,{children:[s(U,{color:e.colors.clawd_body,children:"▝▜"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"█████"}),s(U,{color:e.colors.clawd_body,children:"▛▘"})," ",Tr()," · ",kr()]}),g(U,{color:e.colors.clawd_body,children:[" ","▘▘ ▝▝"," ",Br]}),g(c,{children:[g(U,{color:e.colors.success,children:["Login successful. Press"," "]}),s(U,{bold:!0,color:e.colors.success,children:"Enter"}),g(U,{color:e.colors.success,children:[" ","to continue…"]})]})]}),s(c,{children:"╭─────────────────────────────────────────────╮"}),g(c,{children:["│ 1 function greet() ","{"," ","│"]}),g(c,{children:["│ 2"," ",s(U,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:'- console.log("'}),s(U,{backgroundColor:e.colors.diffRemovedWord,children:"Hello, World!"}),s(U,{backgroundColor:e.colors.diffRemoved,children:'");'})," ","│"]}),g(c,{children:["│ 2"," ",s(U,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:'+ console.log("'}),s(U,{backgroundColor:e.colors.diffAddedWord,children:"Hello, Claude!"}),s(U,{backgroundColor:e.colors.diffAdded,children:'");'})," ","│"]}),s(U,{color:e.colors.warning,children:"╭─────────────────────────────────────────────╮"}),g(U,{color:e.colors.warning,children:["│ Do you trust the files in this folder?"," ","│"]}),g(c,{children:[s(U,{color:e.colors.warning,children:"│ "}),s(c,{dimColor:!0,children:"Enter to confirm · Esc to exit"}),g(U,{color:e.colors.warning,children:[" ","│"]})]}),s(U,{color:e.colors.bashBorder,children:"───────────────────────────────────────────────"}),g(c,{children:[s(U,{color:e.colors.bashBorder,children:"!"}),s(c,{children:" ls"})]}),s(U,{color:e.colors.promptBorder,children:"───────────────────────────────────────────────"}),s(c,{children:g(c,{children:["> list the dir"," ",s(Or,{text:"ultrathink",nonShimmerColors:[e.colors.rainbow_red,e.colors.rainbow_orange,e.colors.rainbow_yellow,e.colors.rainbow_green,e.colors.rainbow_blue,e.colors.rainbow_indigo,e.colors.rainbow_violet],shimmerColors:[e.colors.rainbow_red_shimmer,e.colors.rainbow_orange_shimmer,e.colors.rainbow_yellow_shimmer,e.colors.rainbow_green_shimmer,e.colors.rainbow_blue_shimmer,e.colors.rainbow_indigo_shimmer,e.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),s(U,{color:e.colors.planMode,children:"╭─────────────────────────────────────────────╮"}),g(c,{children:[s(U,{color:e.colors.planMode,children:"│ "}),g(U,{color:e.colors.permission,children:["Ready to code?"," "]}),s(c,{children:"Here is Claude's plan:"}),g(U,{color:e.colors.planMode,children:[" ","│"]})]}),s(U,{color:e.colors.permission,children:"╭─────────────────────────────────────────────╮"}),g(c,{children:[s(U,{color:e.colors.permission,children:"│ "}),s(c,{bold:!0,children:"Permissions:"})," ",g(U,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[" ","Allow"," "]})," ","Deny"," ","Workspace"," ",s(U,{color:e.colors.permission,children:"│"})]}),s(c,{children:"> list the dir"}),g(c,{children:[s(U,{color:e.colors.error,children:"●"}),s(c,{children:" Update(__init__.py)"})]}),g(c,{children:[s(c,{children:" ⎿ "}),s(U,{color:e.colors.error,children:"User rejected update to __init__.py"})]}),g(c,{children:[" ","1"," ",g(U,{backgroundColor:e.colors.diffRemovedDimmed,children:["- import"," "]}),s(U,{backgroundColor:e.colors.diffRemovedWordDimmed,children:"os"})]}),g(c,{children:[" ","2"," ",g(U,{backgroundColor:e.colors.diffAddedDimmed,children:["+ import"," "]}),s(U,{backgroundColor:e.colors.diffAddedWordDimmed,children:"random"})]}),g(c,{children:[s(U,{color:e.colors.success,children:"●"}),s(c,{children:" List(.)"})]}),g(c,{children:[s(c,{children:"●"}),s(c,{children:" The directory "}),s(U,{color:e.colors.permission,children:"C:\\Users\\user"}),g(c,{children:[" ","contains ",s(c,{bold:!0,children:"123"})," files."]})]}),g(c,{children:[s(U,{color:e.colors.claude,children:"✻ Th"}),s(U,{color:e.colors.claudeShimmer,children:"ink"}),s(U,{color:e.colors.claude,children:"ing… "}),s(c,{children:"(esc to interrupt)"})]}),s(c,{children:s(U,{color:e.colors.autoAccept,children:"⏵⏵ accept edits on (shift+tab to cycle)"})}),s(c,{children:s(U,{color:e.colors.planMode,children:"⏸ plan mode on (shift+tab to cycle)"})}),s(c,{children:s(U,{color:e.colors.ide,children:"◯ IDE connected ⧉ 44 lines selected"})})]})})]})}function Qe({colorKey:e,theme:t,bold:n=!1}){const o=t.colors[e];return e==="inverseText"?s(U,{color:o,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith("diff")?s(U,{backgroundColor:o,bold:n,color:t.colors.text,children:e}):s(U,{color:o,bold:n,children:e})}function at({initialValue:e,onColorChange:t,onExit:n,colorKey:o,theme:r}){const i=nn(e)||{h:0,s:50,l:50},a=en(e)||{r:128,g:128,b:128},[l,u]=P(i),[d,h]=P(a),[f,y]=P("hsl"),[b,p]=P("h"),[w,S]=P(!1),[E,x]=P(!1);xe(()=>{const C=nn(e),_=en(e);C&&_&&(S(!0),u(C),h(_),S(!1))},[e]),xe(()=>{if(!w&&E){const C=`rgb(${d.r},${d.g},${d.b})`;t(C)}},[l,d,w,E]),xe(()=>{x(!0)},[]);const k=C=>{if(gn(C)){const _=st(C),$=nn(_),A=en(_);$&&A&&(S(!0),u($),h(A),S(!1))}};de((C,_)=>{if(C.length>1&&!_.ctrl&&!_.meta){k(C);return}if(_.return)n();else if(_.escape)n();else if(_.ctrl&&C==="a")y($=>$==="hsl"?"rgb":"hsl"),p($=>f==="hsl"?$==="h"?"r":$==="s"?"g":"b":$==="r"?"h":$==="g"?"s":"l");else if(_.upArrow)p(f==="hsl"?$=>$==="h"?"l":$==="s"?"h":"s":$=>$==="r"?"b":$==="g"?"r":"g");else if(_.downArrow||_.tab)p(f==="hsl"?$=>$==="h"?"s":$==="s"?"l":"h":$=>$==="r"?"g":$==="g"?"b":"r");else if(_.leftArrow){const $=_.shift||_.ctrl||_.meta?-10:-1;D($)}else if(_.rightArrow){const $=_.shift||_.ctrl||_.meta?10:1;D($)}});const D=C=>{S(!0),f==="hsl"?u(_=>{const $={..._};b==="h"?$.h=Math.max(0,Math.min(359,_.h+C)):b==="s"?$.s=Math.max(0,Math.min(100,_.s+C)):b==="l"&&($.l=Math.max(0,Math.min(100,_.l+C)));const[A,v,R]=N($.h,$.s,$.l);return h({r:A,g:v,b:R}),$}):h(_=>{const $={..._};b==="r"?$.r=Math.max(0,Math.min(255,_.r+C)):b==="g"?$.g=Math.max(0,Math.min(255,_.g+C)):b==="b"&&($.b=Math.max(0,Math.min(255,_.b+C)));const A=O($.r,$.g,$.b);return u(A),$}),S(!1)},O=(C,_,$)=>{const A=C/255,v=_/255,R=$/255,K=Math.max(A,v,R),J=Math.min(A,v,R),te=K-J,se=(K+J)/2;let $e=0;te!==0&&($e=se>.5?te/(2-K-J):te/(K+J));let we=0;return te!==0&&(K===A?we=((v-R)/te+(v<R?6:0))/6:K===v?we=((R-A)/te+2)/6:we=((A-v)/te+4)/6),{h:Math.round(we*360),s:Math.round($e*100),l:Math.round(se*100)}},N=(C,_,$)=>{C/=360,_/=100,$/=100;const A=(1-Math.abs(2*$-1))*_,v=A*(1-Math.abs(C*6%2-1)),R=$-A/2;let K=0,J=0,te=0;return 0<=C&&C<1/6?(K=A,J=v,te=0):1/6<=C&&C<2/6?(K=v,J=A,te=0):2/6<=C&&C<3/6?(K=0,J=A,te=v):3/6<=C&&C<4/6?(K=0,J=v,te=A):4/6<=C&&C<5/6?(K=v,J=0,te=A):5/6<=C&&C<1&&(K=A,J=0,te=v),[Math.round((K+R)*255),Math.round((J+R)*255),Math.round((te+R)*255)]},j=()=>{const C=[],_=[[255,0,0],[255,127,0],[255,255,0],[127,255,0],[0,255,0],[0,255,127],[0,255,255],[0,127,255],[0,0,255],[127,0,255],[255,0,255],[255,0,127],[255,0,0]];for(let $=0;$<40;$++){const v=$/39*(_.length-1),R=Math.floor(v),K=Math.ceil(v),J=v-R,[te,se,$e]=_[R],[we,Y,V]=_[K],F=Math.round(te+(we-te)*J),ne=Math.round(se+(Y-se)*J),X=Math.round($e+(V-$e)*J);C.push(s(c,{backgroundColor:`rgb(${F},${ne},${X})`,children:" "},$))}return C},L=()=>{const C=[];for(let _=0;_<40;_++){const $=_/39*100,[A,v,R]=N(l.h,$,l.l);C.push(s(c,{backgroundColor:`rgb(${A},${v},${R})`,children:" "},_))}return C},B=()=>{const C=[];for(let _=0;_<40;_++){const $=_/39*100,[A,v,R]=N(l.h,l.s,$);C.push(s(c,{backgroundColor:`rgb(${A},${v},${R})`,children:" "},_))}return C},T=()=>{const[C,_,$]=N(l.h,l.s,l.l);return`rgb(${C},${_},${$})`},I=(C,_,$)=>{const A=v=>v.toString(16).padStart(2,"0");return`#${A(C)}${A(_)}${A($)}`},z=()=>{const C=[];for(let _=0;_<40;_++){const $=Math.round(_/39*255);C.push(s(c,{backgroundColor:`rgb(${$},${d.g},${d.b})`,children:" "},_))}return C},W=()=>{const C=[];for(let _=0;_<40;_++){const $=Math.round(_/39*255);C.push(s(c,{backgroundColor:`rgb(${d.r},${$},${d.b})`,children:" "},_))}return C},Q=()=>{const C=[];for(let _=0;_<40;_++){const $=Math.round(_/39*255);C.push(s(c,{backgroundColor:`rgb(${d.r},${d.g},${$})`,children:" "},_))}return C},q=(C,_)=>Math.round(C/_*39);return g(m,{flexDirection:"column",borderStyle:"single",borderColor:"white",padding:1,children:[g(m,{flexDirection:"column",children:[s(c,{bold:!0,children:"Color Picker"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{color:"gray",dimColor:!0,children:"←→ to adjust (shift/ctrl/cmd +10)"}),s(c,{color:"gray",dimColor:!0,children:"↑↓ to change bar"}),s(c,{color:"gray",dimColor:!0,children:"ctrl+a to switch rgb/hsl"}),s(c,{color:"gray",dimColor:!0,children:"paste color from clipboard"}),s(c,{color:"gray",dimColor:!0,children:"enter to exit (auto-saved)"}),s(c,{color:"gray",dimColor:!0,children:"esc to save and exit"})]})]}),f==="hsl"?g(me,{children:[g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="h"?"yellow":"white",children:[b==="h"?"❯ ":" ","Hue (",l.h,"°):"]})}),s(m,{children:j().map((C,_)=>s(Ee,{children:_===q(l.h,360)?s(c,{children:"|"}):C},_))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="s"?"yellow":"white",children:[b==="s"?"❯ ":" ","Saturation (",l.s,"%):"]})}),s(m,{children:L().map((C,_)=>s(Ee,{children:_===q(l.s,100)?s(c,{children:"|"}):C},_))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="l"?"yellow":"white",children:[b==="l"?"❯ ":" ","Lightness (",l.l,"%):"]})}),s(m,{children:B().map((C,_)=>s(Ee,{children:_===q(l.l,100)?s(c,{children:"|"}):C},_))})]})]}):g(me,{children:[g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="r"?"yellow":"white",children:[b==="r"?"❯ ":" ","Red (",d.r,"):"]})}),s(m,{children:z().map((C,_)=>s(Ee,{children:_===q(d.r,255)?s(c,{children:"|"}):C},_))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="g"?"yellow":"white",children:[b==="g"?"❯ ":" ","Green (",d.g,"):"]})}),s(m,{children:W().map((C,_)=>s(Ee,{children:_===q(d.g,255)?s(c,{children:"|"}):C},_))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="b"?"yellow":"white",children:[b==="b"?"❯ ":" ","Blue (",d.b,"):"]})}),s(m,{children:Q().map((C,_)=>s(Ee,{children:_===q(d.b,255)?s(c,{children:"|"}):C},_))})]})]}),g(m,{marginBottom:1,children:[s(c,{children:"Current: "}),s(c,{backgroundColor:T(),children:" "})]}),g(m,{flexDirection:"row",justifyContent:"space-between",children:[g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"Hex "}),o?.startsWith("diff")?s(c,{backgroundColor:T(),color:r?.colors?.text||"white",bold:!0,children:I(d.r,d.g,d.b)}):o==="inverseText"?s(c,{color:T(),backgroundColor:r?.colors?.permission,bold:!0,children:I(d.r,d.g,d.b)}):s(c,{color:T(),bold:!0,children:I(d.r,d.g,d.b)})]}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"RGB "}),o?.startsWith("diff")?s(c,{backgroundColor:T(),color:r?.colors?.text||"white",bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):o==="inverseText"?s(c,{color:T(),backgroundColor:r?.colors?.permission,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):s(c,{color:T(),bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`})]}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"HSL "}),o?.startsWith("diff")?s(c,{backgroundColor:T(),color:r?.colors?.text||"white",bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):o==="inverseText"?s(c,{color:T(),backgroundColor:r?.colors?.permission,bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):s(c,{color:T(),bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`})]})]})]})}function en(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t)return{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])};const n=e.match(/^#([a-fA-F0-9]{6})$/);if(n){const o=n[1];return{r:parseInt(o.substr(0,2),16),g:parseInt(o.substr(2,2),16),b:parseInt(o.substr(4,2),16)}}return null}function nn(e){const t=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t)return{h:parseInt(t[1]),s:parseInt(t[2]),l:parseInt(t[3])};const n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const r=parseInt(n[1])/255,i=parseInt(n[2])/255,a=parseInt(n[3])/255,l=Math.max(r,i,a),u=Math.min(r,i,a),d=l-u,h=(l+u)/2;let f=0;d!==0&&(f=h>.5?d/(2-l-u):d/(l+u));let y=0;return d!==0&&(l===r?y=((i-a)/d+(i<a?6:0))/6:l===i?y=((a-r)/d+2)/6:y=((r-i)/d+4)/6),{h:Math.round(y*360),s:Math.round(f*100),l:Math.round(h*100)}}const o=e.match(/^#([a-fA-F0-9]{6})$/);if(o){const r=o[1],i=parseInt(r.substr(0,2),16)/255,a=parseInt(r.substr(2,2),16)/255,l=parseInt(r.substr(4,2),16)/255,u=Math.max(i,a,l),d=Math.min(i,a,l),h=u-d,f=(u+d)/2;let y=0;h!==0&&(y=f>.5?h/(2-u-d):h/(u+d));let b=0;return h!==0&&(u===i?b=((a-l)/h+(a<l?6:0))/6:u===a?b=((l-i)/h+2)/6:b=((i-a)/h+4)/6),{h:Math.round(b*360),s:Math.round(y*100),l:Math.round(f*100)}}return{h:0,s:50,l:50}}function Ar({onBack:e,themeId:t}){const{settings:{themes:n},updateSettings:o}=be(ue),[r,i]=P(t),a=n.find(B=>B.id===r)||n[0],[l,u]=P("rgb"),[d,h]=P(0),[f,y]=P(null),[b,p]=P(null),[w,S]=P(""),[E,x]=P(""),k=Nn(B=>{o(T=>{const I=T.themes.findIndex(z=>z.id===r);I!==-1&&B(T.themes[I])})},[r,o]),D=B=>{if(d>=2&&gn(B)){const T=st(B),I=d-2,z=O[I];k(W=>{W.colors[z]=T})}};de((B,T)=>{if(f===null&&b===null){if(B.length>1&&!T.ctrl&&!T.meta){D(B);return}if(T.escape)e();else if(T.ctrl&&B==="a")u(I=>I==="rgb"?"hex":I==="hex"?"hsl":"rgb");else if(T.upArrow)h(I=>Math.max(0,I-1));else if(T.downArrow)h(I=>Math.min(O.length+1,I+1));else if(T.return)if(d===0)p("name"),S(a.name),x(a.name);else if(d===1)p("id"),S(a.id),x(a.id);else{const I=d-2,z=O[I],W=a.colors[z];y(I),S(W),x(W)}}else if(f!==null)T.ctrl&&B==="a"&&u(I=>I==="rgb"?"hex":I==="hex"?"hsl":"rgb");else if(b!==null)if(T.return){if(b==="id"){const I=r;i(w),o(z=>{const W=z.themes.findIndex(Q=>Q.id===I);W!==-1&&(z.themes[W].id=w)})}else k(I=>{I.name=w});p(null),S(""),x("")}else T.escape?(p(null),S(""),x("")):T.backspace||T.delete?S(I=>I.slice(0,-1)):B&&S(I=>I+B)});const O=Object.keys(a.colors),N=(B,T)=>{const I=B.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!I)return B;const z=parseInt(I[1]),W=parseInt(I[2]),Q=parseInt(I[3]);switch(T){case"hex":{const q=C=>C.toString(16).padStart(2,"0");return`#${q(z)}${q(W)}${q(Q)}`}case"hsl":{const q=z/255,C=W/255,_=Q/255,$=Math.max(q,C,_),A=Math.min(q,C,_),v=$-A,R=($+A)/2;let K=0;v!==0&&(K=R>.5?v/(2-$-A):v/($+A));let J=0;return v!==0&&($===q?J=((C-_)/v+(C<_?6:0))/6:$===C?J=((_-q)/v+2)/6:J=((q-C)/v+4)/6),`hsl(${Math.round(J*360)}, ${Math.round(K*100)}%, ${Math.round(R*100)}%)`}case"rgb":default:return B}},j=B=>({autoAccept:"Auto-accept edits mode indicator",bashBorder:"Bash command border",claude:"Claude branding color. Used for the Claude logo, the welcome message, and the thinking text.",claudeShimmer:"Color used for the shimmering effect on the thinking verb.",claudeBlue_FOR_SYSTEM_SPINNER:"System spinner color (blue variant)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"System spinner shimmer color (blue variant)",permission:"Permission prompt color",permissionShimmer:"Permission prompt shimmer color",planMode:"Plan mode indicator",ide:"Color used for IDE-related messages.",promptBorder:"Input prompt border color",promptBorderShimmer:"Input prompt border shimmer color",text:"Code color. Used in diffs.",inverseText:"Inverse text color. Used for the text of tabs, where the background is filled in.",inactive:"Inactive/dimmed text. Used for line numbers and less prominent text.",subtle:"Subtle text. Used for help text and secondary information.",suggestion:"Suggestion text color. Used for suggestions for theme names and various other things.",remember:"Remember/note color. Used for various text relating to memories.",background:"Background color for certain UI elements",success:"Success indicator. Used for the bullet on successful tool calls, and various success messages (such as sign in successful).",error:"Error indicator",warning:"Warning indicator",warningShimmer:"Warning shimmer color",diffAdded:"Added diff background",diffRemoved:"Removed diff background",diffAddedDimmed:"Added diff background (dimmed)",diffRemovedDimmed:"Removed diff background (dimmed)",diffAddedWord:"Added word highlight",diffRemovedWord:"Removed word highlight",diffAddedWordDimmed:"Added word highlight (dimmed)",diffRemovedWordDimmed:"Removed word highlight (dimmed)",red_FOR_SUBAGENTS_ONLY:"Red color for sub agents",blue_FOR_SUBAGENTS_ONLY:"Blue color for sub agents",green_FOR_SUBAGENTS_ONLY:"Green color for sub agents",yellow_FOR_SUBAGENTS_ONLY:"Yellow color for sub agents",purple_FOR_SUBAGENTS_ONLY:"Purple color for sub agents",orange_FOR_SUBAGENTS_ONLY:"Orange color for sub agents",pink_FOR_SUBAGENTS_ONLY:"Pink color for sub agents",cyan_FOR_SUBAGENTS_ONLY:"Cyan color for sub agents",professionalBlue:"Professional blue color for business contexts?",rainbow_red:'"ultrathink" rainbow - red',rainbow_orange:'"ultrathink" rainbow - orange',rainbow_yellow:'"ultrathink" rainbow - yellow',rainbow_green:'"ultrathink" rainbow - green',rainbow_blue:'"ultrathink" rainbow - blue',rainbow_indigo:'"ultrathink" rainbow - indigo',rainbow_violet:'"ultrathink" rainbow - violet',rainbow_red_shimmer:'"ultrathink" rainbow (shimmer) - red',rainbow_orange_shimmer:'"ultrathink" rainbow (shimmer) - orange',rainbow_yellow_shimmer:'"ultrathink" rainbow (shimmer) - yellow',rainbow_green_shimmer:'"ultrathink" rainbow (shimmer) - green',rainbow_blue_shimmer:'"ultrathink" rainbow (shimmer) - blue',rainbow_indigo_shimmer:'"ultrathink" rainbow (shimmer) - indigo',rainbow_violet_shimmer:'"ultrathink" rainbow (shimmer) - violet',clawd_body:'"Clawd" character body color',clawd_background:'"Clawd" character background color',userMessageBackground:"Background color for user messages",bashMessageBackgroundColor:"Background color for bash command output",memoryBackgroundColor:"Background color for memory/context information",rate_limit_fill:"Rate limit indicator fill color",rate_limit_empty:"Rate limit indicator empty/background color"})[B]||"",L=Math.max(...O.map(B=>B.length));return g(m,{children:[g(m,{flexDirection:"column",width:"50%",children:[s(m,{children:g(pe,{children:["Editing theme “",a.name,"” (",a.id,")"]})}),f===null&&b===null?g(me,{children:[g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"enter to edit theme name, id, or color"}),s(c,{dimColor:!0,children:"ctrl+a to toggle rgb, hex, hsl"}),s(c,{dimColor:!0,children:"paste color from clipboard (when on color)"}),s(c,{dimColor:!0,children:"esc to go back"})]}),d<2?g(m,{marginBottom:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:"yellow",flexDirection:"column",paddingLeft:1,children:[s(c,{bold:!0,children:d===0?"Theme Name":"Theme ID"}),s(c,{children:d===0?"The display name for this theme":"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):g(m,{marginBottom:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:a.colors[O[d-2]],flexDirection:"column",paddingLeft:1,children:[s(Qe,{colorKey:O[d-2],theme:a,bold:!0}),s(c,{children:j(O[d-2])})]}),g(m,{flexDirection:"column",children:[g(m,{children:[s(c,{color:d===0?"yellow":"white",children:d===0?"❯ ":" "}),s(c,{bold:!0,children:"Name: "}),s(c,{children:a.name})]}),g(m,{marginBottom:1,children:[s(c,{color:d===1?"yellow":"white",children:d===1?"❯ ":" "}),s(c,{bold:!0,children:"ID: "}),s(c,{children:a.id})]}),(()=>{if(d<2){const q=O.slice(0,20);return g(me,{children:[q.map((C,_)=>{const $=_+2;return g(m,{children:[s(c,{color:d===$?"yellow":"white",children:d===$?"❯ ":" "}),s(m,{width:L+2,children:s(c,{children:s(Qe,{colorKey:C,theme:a,bold:!0})})}),s(U,{color:a.colors[C],children:N(a.colors[C],l)})]},C)}),O.length>20&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",O.length-20," more below"]})]})}const T=d-2,I=Math.max(0,T-Math.floor(20/2)),z=Math.min(O.length,I+20),W=Math.max(0,z-20),Q=O.slice(W,z);return g(me,{children:[W>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",W," more above"]}),Q.map((q,C)=>{const $=W+C+2;return g(m,{children:[s(c,{color:d===$?"yellow":"white",children:d===$?"❯ ":" "}),s(m,{width:L+2,children:s(c,{children:s(Qe,{colorKey:q,theme:a,bold:!0})})}),s(U,{color:a.colors[q],children:N(a.colors[q],l)})]},q)}),z<O.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",O.length-z," more below"]})]})})()]})]}):b?g(m,{flexDirection:"column",marginTop:1,children:[g(c,{children:["Editing ",b==="name"?"theme name":"theme ID",":"]}),s(m,{borderStyle:"round",borderColor:"yellow",paddingX:1,children:s(c,{children:w})}),s(c,{dimColor:!0,children:"enter to save, esc to cancel"})]}):s(at,{initialValue:E,colorKey:O[f],theme:a,onColorChange:B=>{S(B),k(T=>{T.colors[O[f]]=B})},onExit:()=>{k(B=>{B.colors[O[f]]=w}),y(null),S(""),x("")}})]}),s(m,{width:"50%",children:s(lt,{theme:a})})]})}function Pr(e){return e.map(t=>`${t.name} (${t.id})`)}function Lr({onBack:e}){const{settings:{themes:t},updateSettings:n}=be(ue),[o,r]=P(0),[i,a]=P(null),[l,u]=P(!0),d=()=>{const w={colors:{...(t[0]||ee.themes[0]).colors},name:"New Custom Theme",id:`custom-${Date.now()}`};n(S=>{S.themes.push(w)}),a(w.id),u(!1)},h=p=>{t.length<=1||(n(w=>{w.themes=w.themes.filter(S=>S.id!==p)}),o>=t.length-1&&r(Math.max(0,t.length-2)))},f=()=>{n(p=>{p.themes=[...ee.themes]}),r(0)};if(de((p,w)=>{if(w.escape)e();else if(w.upArrow)r(S=>Math.max(0,S-1));else if(w.downArrow)r(S=>Math.min(t.length-1,S+1));else if(w.return){const S=t[o];S&&(a(S.id),u(!1))}else if(p==="n")d();else if(p==="d"){const S=t[o];S&&h(S.id)}else w.ctrl&&p==="r"&&f()},{isActive:l}),i)return s(Ar,{themeId:i,onBack:()=>{a(null),u(!0)}});const y=Pr(t),b=t.find(p=>y[o]?.includes(`(${p.id})`))||t[0];return t.length===0?s(m,{children:g(m,{flexDirection:"column",width:"100%",children:[s(pe,{children:"Themes"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new theme"}),s(c,{dimColor:!0,children:"esc to go back"})]}),s(c,{children:"No themes available!"})]})}):g(m,{children:[g(m,{flexDirection:"column",width:"50%",children:[s(pe,{children:"Themes"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new theme"}),s(c,{dimColor:!0,children:"d to delete a theme"}),s(c,{dimColor:!0,children:"ctrl+r to delete all themes and restore built-in"}),s(c,{dimColor:!0,children:"enter to edit theme"}),s(c,{dimColor:!0,children:"esc to go back"})]}),s(m,{flexDirection:"column",children:y.map((p,w)=>g(c,{color:o===w?"yellow":void 0,children:[o===w?"❯ ":" ",p]},w))})]}),s(m,{width:"50%",children:s(lt,{theme:b})})]})}function Dr({onBack:e}){const{settings:{thinkingVerbs:{format:t,verbs:n},themes:o},updateSettings:r}=be(ue),i=["format","verbs"],[a,l]=P(0),u=i[a],[d,h]=P(0),[f,y]=P(!1),[b,p]=P(""),[w,S]=P(!1),[E,x]=P(!1),[k,D]=P(t),O=Ke(),j=(o.find(B=>B.id===O)||o.find(B=>B.id==="dark"))?.colors.claude||"rgb(215,119,87)";de((B,T)=>{if(E){T.return?(r(I=>{I.thinkingVerbs.format=k}),x(!1)):T.escape?(D(t),x(!1)):T.backspace||T.delete?D(I=>I.slice(0,-1)):B&&D(I=>I+B);return}if(f||w){T.return&&b.trim()?(w?(r(I=>{I.thinkingVerbs.verbs.push(b.trim())}),S(!1)):(r(I=>{I.thinkingVerbs.verbs[d]=b.trim()}),y(!1)),p("")):T.escape?(p(""),y(!1),S(!1)):T.backspace||T.delete?p(I=>I.slice(0,-1)):B&&p(I=>I+B);return}T.escape?e():T.return?u==="format"&&(D(t),x(!0)):T.tab?T.shift?l(I=>I===0?i.length-1:I-1):l(I=>I===i.length-1?0:I+1):T.upArrow?u==="verbs"&&n.length>0&&h(I=>I>0?I-1:n.length-1):T.downArrow?u==="verbs"&&n.length>0&&h(I=>I<n.length-1?I+1:0):B==="e"&&u==="verbs"?n.length>0&&(p(n[d]),y(!0)):B==="d"&&u==="verbs"?n.length>1&&(r(I=>{I.thinkingVerbs.verbs=I.thinkingVerbs.verbs.filter((z,W)=>W!==d)}),d>=n.length-1&&h(Math.max(0,n.length-2))):B==="n"&&u==="verbs"?(S(!0),p("")):T.ctrl&&B==="r"&&u==="verbs"&&(r(I=>{I.thinkingVerbs.verbs=[...ee.thinkingVerbs.verbs]}),h(0))});const L=50;return g(m,{children:[g(m,{flexDirection:"column",width:`${100-L}%`,children:[g(m,{marginBottom:1,flexDirection:"column",children:[s(pe,{children:"Thinking Verbs"}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:u==="format"?"enter to edit format":"changes auto-saved"}),s(c,{dimColor:!0,children:"esc to go back"}),s(c,{dimColor:!0,children:"tab to switch sections"})]})]}),s(m,{marginBottom:1,children:s(c,{dimColor:!0,children:"Customize the verbs shown during generation and their format."})}),g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:u==="format"?"yellow":void 0,children:u==="format"?"❯ ":" "}),s(c,{bold:!0,color:u==="format"?"yellow":void 0,children:"Format"})]}),u==="format"&&(E?g(c,{dimColor:!0,children:[" ","enter to save"]}):g(c,{dimColor:!0,children:[" ","enter to edit"]}))]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:E?"yellow":"gray",children:s(c,{children:E?k:t})})}),s(m,{children:g(c,{children:[s(c,{color:u==="verbs"?"yellow":void 0,children:u==="verbs"?"❯ ":" "}),s(c,{bold:!0,color:u==="verbs"?"yellow":void 0,children:"Verbs"})]})}),u==="verbs"&&s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","e to edit · d to delete · n to add new · ctrl+r to reset"]})}),s(m,{marginLeft:2,marginBottom:1,children:g(m,{flexDirection:"column",children:[(()=>{const T=Math.max(0,d-Math.floor(4)),I=Math.min(n.length,T+8),z=Math.max(0,I-8),W=n.slice(z,I);return g(me,{children:[z>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",z," more above"]}),W.map((Q,q)=>{const C=z+q;return g(c,{color:u==="verbs"&&C===d?"cyan":void 0,children:[u==="verbs"&&C===d?"❯ ":" ",Q]},C)}),I<n.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",n.length-I," more below"]})]})})(),w&&g(m,{alignItems:"center",children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:b})})]}),f&&g(m,{marginTop:1,alignItems:"center",children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:b})})]})]})})]}),g(m,{width:`${L}%`,flexDirection:"column",children:[s(m,{marginBottom:1,children:s(c,{bold:!0,children:"Preview"})}),s(m,{borderStyle:"single",borderColor:"gray",padding:1,flexDirection:"column",children:g(c,{children:[g(c,{color:j,children:["✻ ",t.replace(/\{\}/g,n[d])," "]}),s(c,{children:"(esc to interrupt)"})]})})]})]})}const _e=[{name:"Default",phases:ee.thinkingStyle.phases,reverseMirror:ee.thinkingStyle.reverseMirror},{name:"Basic",phases:["|","/","-","\\"],reverseMirror:!1},{name:"Braille",phases:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],reverseMirror:!1},{name:"Circle",phases:["◐","◓","◑","◒"],reverseMirror:!1},{name:"Wave",phases:["▁","▃","▄","▅","▆","▇","█"],reverseMirror:!0},{name:"Glow",phases:["░","▒","▓","█"],reverseMirror:!0},{name:"Partial block",phases:["▏","▎","▍","▌","▋","▊","▉","█"],reverseMirror:!0},{name:"Clock",phases:["🕛","🕐","🕑","🕒","🕓","🕔","🕕","🕖","🕗","🕘","🕙","🕚"],reverseMirror:!1},{name:"Globe",phases:["🌍","🌎","🌏"],reverseMirror:!1},{name:"Arc",phases:["◜","◠","◝","◞","◡","◟"],reverseMirror:!1},{name:"Triangle",phases:["◤","◥","◢","◣"],reverseMirror:!1},{name:"Bouncing",phases:["⠁","⠂","⠄","⡀","⢀","⠠","⠐","⠈"],reverseMirror:!1},{name:"Dots",phases:[".","..","..."],reverseMirror:!1},{name:"Colors",phases:["🔴","🟠","🟡","🟢","🔵","🟣"],reverseMirror:!1}];function Rr({onBack:e}){const{settings:{thinkingStyle:{phases:t,updateInterval:n,reverseMirror:o},themes:r},updateSettings:i}=be(ue),a=["reverseMirror","updateInterval","phases","presets"],[l,u]=P(0),d=a[l],[h,f]=P(0),[y,b]=P(0),[p,w]=P(!1),[S,E]=P(""),[x,k]=P(!1),[D,O]=P(!1),[N,j]=P(n.toString()),[L,B]=P(0),T=Ke(),z=(r.find($=>$.id===T)||r.find($=>$.id==="dark"))?.colors.claude||"rgb(215,119,87)";xe(()=>{if(t.length>0){const $=o?[...t,...[...t].reverse().slice(1,-1)]:t,A=setInterval(()=>{B(v=>(v+1)%$.length)},n);return()=>clearInterval(A)}},[t,n,o]),de(($,A)=>{if(D){if(A.return){const v=parseInt(N);!isNaN(v)&&v>0&&i(R=>{R.thinkingStyle.updateInterval=v}),O(!1)}else A.escape?(j(n.toString()),O(!1)):A.backspace||A.delete?j(v=>v.slice(0,-1)):$&&$.match(/^[0-9]$/)&&j(v=>v+$);return}if(p||x){if(A.return&&S.length){const v=x?[...t,S]:t.map((R,K)=>K===h?S:R);i(R=>{R.thinkingStyle.phases=v}),w(!1),E("")}else A.escape?(E(""),w(!1),k(!1)):A.backspace||A.delete?E(v=>v.slice(0,-1)):$&&E(v=>v+$);return}if(A.escape)e();else if(A.return)if(d==="updateInterval")j(n.toString()),O(!0);else if(d==="presets"){const v=_e[y];i(R=>{R.thinkingStyle.phases=[...v.phases],R.thinkingStyle.reverseMirror=v.reverseMirror})}else d==="reverseMirror"&&i(v=>{v.thinkingStyle.reverseMirror=!v.thinkingStyle.reverseMirror});else if(A.tab)A.shift?u(v=>v===0?a.length-1:v-1):u(v=>v===a.length-1?0:v+1);else if(A.upArrow)d==="phases"&&t.length>0?f(v=>v>0?v-1:t.length-1):d==="presets"&&b(v=>v>0?v-1:_e.length-1);else if(A.downArrow)d==="phases"&&t.length>0?f(v=>v<t.length-1?v+1:0):d==="presets"&&b(v=>v<_e.length-1?v+1:0);else if($===" ")d==="reverseMirror"&&i(v=>{v.thinkingStyle.reverseMirror=!v.thinkingStyle.reverseMirror});else if($==="e"&&d==="phases")t.length>0&&(E(t[h]),w(!0));else if($==="a"&&d==="phases")k(!0),E("");else if($==="d"&&d==="phases")t.length>1&&(i(v=>{v.thinkingStyle.phases=t.filter((R,K)=>K!==h)}),h>=t.length&&f(Math.max(0,t.length-1)));else if($==="w"&&d==="phases"){if(h>0){const v=[...t];[v[h-1],v[h]]=[v[h],v[h-1]],i(R=>{R.thinkingStyle.phases=v}),f(R=>R-1)}}else if($==="s"&&d==="phases"){if(h<t.length-1){const v=[...t];[v[h],v[h+1]]=[v[h+1],v[h]],i(R=>{R.thinkingStyle.phases=v}),f(R=>R+1)}}else A.ctrl&&$==="r"&&(i(v=>{v.thinkingStyle=ee.thinkingStyle}),f(0),b(0))});const W=o?"●":"○",Q=50,C=o?[...t,...[...t].reverse().slice(1,-1)]:t,_=C.length>0?C[L]:"·";return s(m,{children:g(m,{flexDirection:"column",width:"100%",children:[g(m,{flexDirection:"row",width:"100%",children:[g(m,{marginBottom:1,flexDirection:"column",width:`${100-Q}%`,children:[s(pe,{children:"Thinking style"}),g(m,{flexDirection:"column",children:[g(c,{dimColor:!0,children:["enter to"," ",d==="updateInterval"?"edit interval":d==="presets"?"apply preset":"save"]}),s(c,{dimColor:!0,children:"esc to go back"}),s(c,{dimColor:!0,children:"tab to switch sections"})]})]}),g(m,{width:`${Q}%`,flexDirection:"column",children:[s(m,{children:s(c,{bold:!0,children:"Preview"})}),g(m,{borderStyle:"single",borderColor:"gray",paddingX:1,flexDirection:"row",children:[s(m,{width:(_?.length??0)+1,children:s(c,{color:z,children:_})}),g(c,{children:[s(c,{color:z,children:"Thinking… "}),s(c,{children:"(esc to interrupt)"})]})]})]})]}),g(m,{flexDirection:"row",gap:4,children:[g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:d==="reverseMirror"?"yellow":void 0,children:d==="reverseMirror"?"❯ ":" "}),s(c,{bold:!0,color:d==="reverseMirror"?"yellow":void 0,children:"Reverse-mirror phases"})]}),d==="reverseMirror"&&g(c,{dimColor:!0,children:[" ","space to toggle"]}),s(m,{marginLeft:2,marginBottom:1,children:g(c,{children:[W," ",o?"Enabled":"Disabled"]})})]}),g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:d==="updateInterval"?"yellow":void 0,children:d==="updateInterval"?"❯ ":" "}),s(c,{bold:!0,color:d==="updateInterval"?"yellow":void 0,children:"Update interval (ms)"})]}),d==="updateInterval"&&(D?g(c,{dimColor:!0,children:[" ","enter to save"]}):g(c,{dimColor:!0,children:[" ","enter to edit"]})),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:D?"yellow":"gray",children:s(c,{children:D?N:n})})})]})]}),s(m,{children:g(c,{children:[s(c,{color:d==="phases"?"yellow":void 0,children:d==="phases"?"❯ ":" "}),s(c,{bold:!0,color:d==="phases"?"yellow":void 0,children:"Phases"})]})}),d==="phases"&&s(m,{marginBottom:1,flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","[e]dit"," ","[a]dd"," ","[d]elete"," ","[w]move up"," ","[s]move down"]})}),s(m,{marginLeft:2,marginBottom:1,children:g(m,{flexDirection:"column",children:[(()=>{const A=Math.max(0,h-Math.floor(4)),v=Math.min(t.length,A+8),R=Math.max(0,v-8),K=t.slice(R,v);return g(me,{children:[R>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",R," more above"]}),K.map((J,te)=>{const se=R+te;return g(c,{color:d==="phases"&&se===h?"cyan":void 0,children:[d==="phases"&&se===h?"❯ ":" ",J]},se)}),v<t.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",t.length-v," more below"]})]})})(),x&&g(m,{children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:S})})]}),p&&g(m,{marginTop:1,children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:S})})]})]})}),s(m,{children:g(c,{children:[s(c,{color:d==="presets"?"yellow":void 0,children:d==="presets"?"❯ ":" "}),s(c,{bold:!0,color:d==="presets"?"yellow":void 0,children:"Presets"})]})}),d==="presets"&&g(c,{dimColor:!0,children:[" ","Selecting one will overwrite your choice of phases"]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{flexDirection:"column",children:(()=>{const A=Math.max(0,y-Math.floor(4)),v=Math.min(_e.length,A+8),R=Math.max(0,v-8),K=_e.slice(R,v);return g(me,{children:[R>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",R," more above"]}),K.map((J,te)=>{const se=R+te;return g(c,{color:d==="presets"&&se===y?"cyan":void 0,children:[d==="presets"&&se===y?"❯ ":" ",J.name," ",J.phases.join("")]},se)}),v<_e.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",_e.length-v," more below"]})]})})()})}),s(m,{marginTop:1,children:s(c,{dimColor:!0,children:"ctrl+r to reset all settings to default"})})]})})}const De=[{label:"bold",value:"bold"},{label:"italic",value:"italic"},{label:"underline",value:"underline"},{label:"strikethrough",value:"strikethrough"},{label:"inverse",value:"inverse"}];function Fr({onBack:e}){const{settings:t,updateSettings:n}=be(ue),[o,r]=P("prefix"),[i,a]=P(0),[l,u]=P(!1),[d,h]=P(()=>t.userMessageDisplay.prefix.format),[f,y]=P(0),[b,p]=P(()=>[...t.userMessageDisplay.prefix.styling]),[w,S]=P(()=>t.userMessageDisplay.prefix.foreground_color),[E,x]=P(()=>t.userMessageDisplay.prefix.background_color),[k,D]=P(0),[O,N]=P(0),[j,L]=P(()=>[...t.userMessageDisplay.message.styling]),[B,T]=P(()=>t.userMessageDisplay.message.foreground_color),[I,z]=P(()=>t.userMessageDisplay.message.background_color),[W,Q]=P(null),[q,C]=P(""),_=Ke(),$=t.themes?.find(Y=>Y.id===_)||t.themes?.[0],A=["format","styling","foreground","background"],v=["styling","foreground","background"],R=A[i],K=v[k],J=(Y,V)=>{n(F=>{const ne=Y==="prefix"?F.userMessageDisplay.prefix:F.userMessageDisplay.message;V(ne)})},te=Y=>{n(V=>{Y==="prefix"?V.userMessageDisplay.prefix={...ee.userMessageDisplay.prefix}:V.userMessageDisplay.message={...ee.userMessageDisplay.message}}),Y==="prefix"?(h(ee.userMessageDisplay.prefix.format),p([...ee.userMessageDisplay.prefix.styling]),S(ee.userMessageDisplay.prefix.foreground_color),x(ee.userMessageDisplay.prefix.background_color)):(L([...ee.userMessageDisplay.message.styling]),T(ee.userMessageDisplay.message.foreground_color),z(ee.userMessageDisplay.message.background_color))};xe(()=>{const Y=t.userMessageDisplay.prefix;h(Y.format),p([...Y.styling]),S(Y.foreground_color),x(Y.background_color);const V=t.userMessageDisplay.message;L([...V.styling]),T(V.foreground_color),z(V.background_color)},[]),de((Y,V)=>{if(l){if(V.return)J("prefix",F=>{F.format=d}),u(!1);else if(V.escape){const F=t.userMessageDisplay.prefix;h(F.format),u(!1)}else V.backspace||V.delete?h(F=>F.slice(0,-1)):Y&&h(F=>F+Y);return}if(W===null){if(V.escape)e();else if(V.ctrl&&Y==="r")te(o);else if(V.leftArrow||V.rightArrow)r(F=>F==="prefix"?"message":"prefix");else if(V.tab)o==="prefix"?V.shift?a(F=>F===0?A.length-1:F-1):a(F=>F===A.length-1?0:F+1):V.shift?D(F=>F===0?v.length-1:F-1):D(F=>F===v.length-1?0:F+1);else if(V.return)o==="prefix"?R==="format"?u(!0):R==="foreground"?(C(w),Q({column:"prefix",type:"foreground"})):R==="background"&&(C(E),Q({column:"prefix",type:"background"})):K==="foreground"?(C(B),Q({column:"message",type:"foreground"})):K==="background"&&(C(I),Q({column:"message",type:"background"}));else if(V.upArrow)o==="prefix"&&R==="styling"?y(F=>Math.max(0,F-1)):o==="message"&&K==="styling"&&N(F=>Math.max(0,F-1));else if(V.downArrow)o==="prefix"&&R==="styling"?y(F=>Math.min(De.length-1,F+1)):o==="message"&&K==="styling"&&N(F=>Math.min(De.length-1,F+1));else if(Y===" "){if(o==="prefix"&&R==="styling"){const F=De[f].value,ne=b.indexOf(F)>=0?b.filter(X=>X!==F):[...b,F];p(ne),J("prefix",X=>{X.styling=[...ne]})}else if(o==="message"&&K==="styling"){const F=De[O].value,ne=j.indexOf(F)>=0?j.filter(X=>X!==F):[...j,F];L(ne),J("message",X=>{X.styling=[...ne]})}}}});const se=(Y,V,F=!0)=>{const ne=F?V==="prefix"?b:j:[],X=F?V==="prefix"?w:B:"rgb(255,255,255)",Ae=F?V==="prefix"?E:I:"rgb(0,0,0)",Pe=X==="rgb(0,0,0)"&&Ae==="rgb(0,0,0)",Ue=ne.length>0;return Pe&&!Ue?s(c,{children:Y}):s(c,{bold:ne.includes("bold"),italic:ne.includes("italic"),underline:ne.includes("underline"),strikethrough:ne.includes("strikethrough"),inverse:ne.includes("inverse"),color:Pe?void 0:X,backgroundColor:Pe?void 0:Ae,children:Y})},$e=(Y=!0)=>g(c,{children:[d&&g(me,{children:[se(d,"prefix",Y)," "]}),se("list the dir","message",Y)]}),we=Y=>{const V=o===Y,X=(Y==="prefix"?A:v)[Y==="prefix"?i:k],Ae=Y==="prefix"?f:O,Pe=Y==="prefix"?b:j,Ue=Y==="prefix"?w:B,mn=Y==="prefix"?E:I;return g(m,{flexDirection:"column",width:"45%",borderStyle:V?"round":"single",borderColor:V?"yellow":"gray",padding:1,children:[s(m,{marginBottom:1,children:g(c,{bold:!0,color:V?"yellow":void 0,children:[Y.charAt(0).toUpperCase()+Y.slice(1)," ","Configuration"]})}),Y==="prefix"&&g(me,{children:[s(m,{children:g(c,{color:V&&X==="format"?"yellow":void 0,bold:V&&X==="format",children:[V&&X==="format"?"❯ ":" ","Prefix Text"]})}),V&&X==="format"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:l?"enter to save":"enter to edit (appears before message)"})}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:l?"yellow":"gray",children:s(c,{children:d})})})]}),s(m,{children:g(c,{color:V&&X==="styling"?"yellow":void 0,bold:V&&X==="styling",children:[V&&X==="styling"?"❯ ":" ","Styling"]})}),V&&X==="styling"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"up/down to navigate · space to toggle"})}),s(m,{marginLeft:2,marginBottom:1,flexDirection:"column",children:De.map((Xe,pn)=>s(m,{children:g(c,{color:V&&X==="styling"&&Ae===pn?"cyan":void 0,children:[V&&X==="styling"&&Ae===pn?"❯ ":" ",Pe.includes(Xe.value)?"●":"○"," ",Xe.label]})},Xe.value))}),s(m,{children:g(c,{color:V&&X==="foreground"?"yellow":void 0,bold:V&&X==="foreground",children:[V&&X==="foreground"?"❯ ":" ","Foreground color"]})}),V&&X==="foreground"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,marginBottom:1,children:s(c,{color:Ue,children:Ue})}),s(m,{children:g(c,{color:V&&X==="background"?"yellow":void 0,bold:V&&X==="background",children:[V&&X==="background"?"❯ ":" ","Background color"]})}),V&&X==="background"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,children:s(c,{backgroundColor:mn,children:mn})})]})};if(W){const{column:Y,type:V}=W;return s(at,{initialValue:q,theme:$,onColorChange:F=>{Y==="prefix"?V==="foreground"?(S(F),J("prefix",ne=>{ne.foreground_color=F})):(x(F),J("prefix",ne=>{ne.background_color=F})):V==="foreground"?(T(F),J("message",ne=>{ne.foreground_color=F})):(z(F),J("message",ne=>{ne.background_color=F}))},onExit:()=>{Q(null),C("")}})}return g(m,{flexDirection:"column",children:[s(pe,{children:"Customize how user messages are displayed"}),g(m,{flexDirection:"column",marginBottom:1,children:[s(c,{dimColor:!0,children:"left/right arrows to switch columns · tab to navigate options"}),s(c,{dimColor:!0,children:"enter to edit · ctrl+r to reset active column · esc to go back"})]}),g(m,{flexDirection:"row",gap:1,children:[we("prefix"),we("message")]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(c,{bold:!0,children:"Preview"})}),g(m,{flexDirection:"row",gap:2,children:[g(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(c,{underline:!0,children:"Before (Claude Code default):"})}),s(m,{marginLeft:1,marginTop:1,children:g(c,{children:[s(c,{color:$?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:$?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]}),g(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(c,{underline:!0,children:"After (Your customization):"})}),s(m,{marginLeft:1,children:$e(!0)}),s(m,{marginLeft:1,marginTop:1,children:g(c,{children:[s(c,{color:$?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:$?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]})]})]})})]})}function Vr({onSubmit:e}){const{settings:t,updateSettings:n}=be(ue),[o,r]=P(0),i=()=>{n(b=>{b.inputBox||(b.inputBox={removeBorder:!1}),b.inputBox.removeBorder=!b.inputBox.removeBorder})},a=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showTweakccVersion=!b.misc.showTweakccVersion})},l=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showPatchesApplied=!b.misc.showPatchesApplied})},u=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.expandThinkingBlocks=!b.misc.expandThinkingBlocks})};de((b,p)=>{p.return||p.escape?e():p.upArrow?r(w=>Math.max(0,w-1)):p.downArrow?r(w=>Math.min(3,w+1)):b===" "&&(o===0?i():o===1?a():o===2?l():o===3&&u())});const d=t.inputBox?.removeBorder?"☑":"☐",h=t.misc?.showTweakccVersion?"☑":"☐",f=t.misc?.showPatchesApplied?"☑":"☐",y=t.misc?.expandThinkingBlocks?"☑":"☐";return g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(pe,{children:"Miscellaneous Settings"})}),s(m,{marginBottom:1,children:s(c,{color:"gray",children:s(c,{dimColor:!0,children:"Various tweaks and customizations. Press space to toggle settings, enter to go back."})})}),s(m,{children:g(c,{children:[s(c,{color:o===0?"cyan":void 0,children:o===0?"❯ ":" "}),s(c,{bold:!0,color:o===0?"cyan":void 0,children:"Remove input box border"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","Removes the rounded border around the input box for a cleaner look."]})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[d," ",t.inputBox?.removeBorder?"Enabled":"Disabled"]})}),s(m,{children:g(c,{children:[s(c,{color:o===1?"cyan":void 0,children:o===1?"❯ ":" "}),s(c,{bold:!0,color:o===1?"cyan":void 0,children:"Show tweakcc version at startup"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ",'Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.']})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[h," ",t.misc?.showTweakccVersion?"Enabled":"Disabled"]})}),s(m,{children:g(c,{children:[s(c,{color:o===2?"cyan":void 0,children:o===2?"❯ ":" "}),s(c,{bold:!0,color:o===2?"cyan":void 0,children:"Show patches applied indicator at startup"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ",'Shows the green "tweakcc patches are applied" indicator when starting Claude Code.']})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[f," ",t.misc?.showPatchesApplied?"Enabled":"Disabled"]})}),s(m,{children:g(c,{children:[s(c,{color:o===3?"cyan":void 0,children:o===3?"❯ ":" "}),s(c,{bold:!0,color:o===3?"cyan":void 0,children:"Expand thinking blocks"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","Makes thinking blocks always expanded by default instead of collapsed."]})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[y," ",t.misc?.expandThinkingBlocks?"Enabled":"Disabled"]})})]})}const He=["Task","Bash","Glob","Grep","Read","Edit","Write","NotebookEdit","WebFetch","WebSearch","BashOutput","KillShell","TodoWrite","AskUserQuestion","Skill","SlashCommand","ExitPlanMode"];function jr({toolsetIndex:e,onBack:t}){const{settings:n,updateSettings:o}=be(ue),r=n.toolsets[e],[i,a]=P(r?.name||"New Toolset"),[l,u]=P(r?.allowedTools||[]),[d,h]=P(!1),[f,y]=P(0);xe(()=>{r&&o(E=>{const x=E.toolsets[e].name;E.toolsets[e].name=i,E.toolsets[e].allowedTools=l,x!==i&&(E.defaultToolset===x&&(E.defaultToolset=i),E.planModeToolset===x&&(E.planModeToolset=i))})},[i,l]);const b=E=>l==="*"?!0:l.includes(E),p=E=>{E==="All"?u("*"):E==="None"?u([]):l==="*"?u(He.filter(x=>x!==E)):l.includes(E)?u(l.filter(x=>x!==E)):u([...l,E])};if(de((E,x)=>{if(d){x.return?h(!1):x.escape?(a(r?.name||"New Toolset"),h(!1)):x.backspace||x.delete?a(k=>k.slice(0,-1)):E&&E.length===1&&a(k=>k+E);return}if(x.escape)t();else if(x.upArrow)y(k=>Math.max(0,k-1));else if(x.downArrow)y(k=>Math.min(He.length+1,k+1));else if(E===" "||x.return)if(f===0)p("All");else if(f===1)p("None");else{const k=He[f-2];k&&p(k)}else E==="n"&&h(!0)}),!r)return s(m,{flexDirection:"column",children:s(c,{color:"red",children:"Toolset not found"})});const w=l==="*",S=Array.isArray(l)&&l.length===0;return g(m,{flexDirection:"column",children:[s(pe,{children:"Edit Toolset"}),s(m,{marginBottom:1,flexDirection:"column",children:s(c,{dimColor:!0,children:"n to edit name · space/enter to toggle · esc to go back"})}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{bold:!0,children:"Name:"}),s(m,{marginLeft:2,children:s(m,{borderStyle:"round",borderColor:d?"yellow":"gray",children:s(c,{children:i})})}),d&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to save · esc to cancel"})})]}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{bold:!0,children:"Allowed Tools:"}),s(m,{marginLeft:2,children:g(c,{color:f===0?"cyan":void 0,children:[f===0?"❯ ":" ",w?"●":"○"," All"]})}),s(m,{marginLeft:2,children:g(c,{color:f===1?"cyan":void 0,children:[f===1?"❯ ":" ",S?"●":"○"," None"]})}),He.map((E,x)=>{const k=x+2;return s(m,{marginLeft:2,children:g(c,{color:f===k?"cyan":void 0,children:[f===k?"❯ ":" ",b(E)?"◉":"○"," ",E]})},E)})]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:g(m,{flexDirection:"column",children:[s(c,{bold:!0,children:"Summary:"}),g(c,{children:["Name: ",s(c,{color:"cyan",children:i})]}),g(c,{children:["Tools:"," ",l==="*"?s(c,{color:"green",children:"All tools (*)"}):l.length===0?s(c,{color:"red",children:"No tools ([])"}):g(c,{color:"yellow",children:[l.length," selected"]})]})]})})]})}function Ur({onBack:e}){const{settings:{toolsets:t,defaultToolset:n,planModeToolset:o,themes:r},updateSettings:i}=be(ue),a=Ke(),l=r.find(N=>N.id===a)||r[0],u=ee.themes[0],d=l?.colors.planMode||u.colors.planMode,h=l?.colors.autoAccept||u.colors.autoAccept,[f,y]=P(0),[b,p]=P(null),[w,S]=P(!0),E=()=>{const N={name:"New Toolset",allowedTools:[]};i(j=>{j.toolsets.push(N)}),p(t.length),S(!1)},x=N=>{const j=t[N];i(L=>{L.toolsets.splice(N,1),L.defaultToolset===j.name&&(L.defaultToolset=null),L.planModeToolset===j.name&&(L.planModeToolset=null)}),f>=t.length-1&&y(Math.max(0,t.length-2))},k=N=>{const j=t[N];i(L=>{L.defaultToolset=j.name})},D=N=>{const j=t[N];i(L=>{L.planModeToolset=j.name})};if(de((N,j)=>{j.escape?e():j.upArrow?y(L=>Math.max(0,L-1)):j.downArrow?y(L=>Math.min(t.length-1,L+1)):j.return&&t.length>0?(p(f),S(!1)):N==="n"?E():N==="x"&&t.length>0?x(f):N==="d"&&t.length>0?k(f):N==="p"&&t.length>0&&D(f)},{isActive:w}),b!==null)return s(jr,{toolsetIndex:b,onBack:()=>{p(null),S(!0)}});const O=N=>N.allowedTools==="*"?"All tools":N.allowedTools.length===0?"No tools":`${N.allowedTools.length} tool${N.allowedTools.length===1?"":"s"}`;return g(m,{flexDirection:"column",children:[s(pe,{children:"Toolsets"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new toolset"}),t.length>0&&s(c,{dimColor:!0,children:"d to set as default toolset"}),t.length>0&&s(c,{dimColor:!0,children:"p to set as plan mode toolset"}),t.length>0&&s(c,{dimColor:!0,children:"x to delete a toolset"}),t.length>0&&s(c,{dimColor:!0,children:"enter to edit toolset"}),s(c,{dimColor:!0,children:"esc to go back"})]}),t.length===0?s(c,{children:"No toolsets created yet. Press n to create one."}):s(m,{flexDirection:"column",children:t.map((N,j)=>{const L=N.name===n,B=N.name===o,T=f===j;let I;return T&&(I="yellow"),g(m,{flexDirection:"row",children:[g(c,{color:I,children:[T?"❯ ":" ",N.name," "]}),g(c,{color:I,children:["(",O(N),")"]}),L&&s(c,{color:h,children:" ⏵⏵ accept edits"}),B&&s(c,{color:d,children:" ⏸ plan mode"})]},j)})})]})}const ue=ut({settings:ee,updateSettings:e=>{},changesApplied:!1,ccVersion:""});function Hr({startupCheckInfo:e}){const[t,n]=P({settings:ee,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null});xe(()=>{(async()=>{n(await dn())})()},[]);const o=Nn(h=>{const f=JSON.parse(JSON.stringify(t.settings));h(f),n(y=>({...y,settings:f,changesApplied:!1})),je(y=>{y.settings=f,y.changesApplied=!1})},[t.settings]),[r,i]=P(null),[a,l]=P(null);xe(()=>{e.wasUpdated&&e.oldVersion&&(l({message:`Your Claude Code installation was updated from ${e.oldVersion} to ${e.newVersion}, and the patching was likely overwritten
|
|
647
|
+
`))},fe=e=>e.replace(/\$/g,"\\$"),un=e=>{const t=/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g,n=Array.from(e.matchAll(t)),o={};for(const a of n){const l=a[1];o[l]=(o[l]||0)+1}let r,i=0;for(const[a,l]of Object.entries(o))l>i&&(i=l,r=a);return r},Sr=e=>{const t=e.slice(0,1e3),n=/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/,o=t.match(n);if(!o){console.log("patch: getModuleLoaderFunction: failed to find module loader function");return}return o[1]},et=e=>{const t=/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.element"\)/,n=e.match(t);if(!n){console.log("patch: getReactModuleNameNonBun: failed to find React module name");return}return n[1]},vr=e=>{const t=et(e);if(!t){console.log("^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)");return}const n=new RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${fe(t)}\\(\\)`),o=e.match(n);if(!o){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return o[1]};let he=null,ke=null;const qe=e=>{if(he!=null)return he;const t=Sr(e);if(!t){console.log("^ patch: getReactVar: failed to find moduleLoader"),he=void 0;return}const n=et(e);if(!n){console.log("^ patch: getReactVar: failed to find reactModuleVarNonBun"),he=void 0;return}const o=new RegExp(`\\b([$\\w]+)=${fe(t)}\\(${fe(n)}\\(\\),1\\)`),r=e.match(o);if(r)return he=r[1],he;const i=vr(e);if(!i){console.log("^ patch: getReactVar: failed to find reactModuleFunctionBun"),he=void 0;return}const a=new RegExp(`\\b([$\\w]+)=${fe(t)}\\(${fe(i)}\\(\\),1\\)`),l=e.match(a);if(!l){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${i})`),he=void 0;return}return he=l[1],he},$r=e=>{const t=/import\{createRequire as ([$\w]+)\}from"node:module";/,n=e.match(t);if(!n)return;const o=n[1],r=new RegExp(`var ([$\\w]+)=${fe(o)}\\(import\\.meta\\.url\\)`),i=e.match(r);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${o})`);return}return i[1]},hn=e=>{if(ke!=null)return ke;const t=$r(e);return t?(ke=t,ke):(ke="require",ke)},nt=e=>{const t=/\bfunction ([$\w]+)\(\{color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+=![01],bold:[$\w]+=![01]/,n=e.match(t);if(!n){console.log("patch: findTextComponent: failed to find text component");return}return n[1]},tt=e=>{const t=/\b([$\w]+)\.displayName="Box"/,n=e.match(t);if(!n){console.error("patch: findBoxComponent: failed to find Box displayName");return}const o=n[1],r=new RegExp(`\\b([$\\w]+)=${fe(o)}[^$\\w]`),i=e.match(r);if(!i){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${o})`);return}return i[1]},ot=async(e,t)=>{let n;if(t.nativeInstallationPath){await qn(t);let u=!1;try{await oe.stat(ge),u=!0}catch{}const d=u?ge:t.nativeInstallationPath;M()&&console.log(`Extracting claude.js from ${u?"backup":"native installation"}: ${d}`);const h=Yn(d);if(!h)throw new Error("Failed to extract claude.js from native installation");const f=re.join(ye.homedir(),".tweakcc"),y=re.join(f,"native-claudejs-orig.js");Ie.writeFileSync(y,h),M()&&console.log(`Saved original extracted JS from native to: ${y}`),n=h.toString("utf8")}else{if(await Jn(t),!t.cliPath)throw new Error("cliPath is required for NPM installations");n=await oe.readFile(t.cliPath,{encoding:"utf8"})}const o=[],r=await Yo(n,t.version);n=r.newContent,o.push(...r.items);let i=null;e.settings.themes&&e.settings.themes.length>0&&(i=uo(n,e.settings.themes))&&(n=i),e.settings.thinkingVerbs&&((i=Mo(n,e.settings.thinkingVerbs.verbs))&&(n=i),(i=xo(n,e.settings.thinkingVerbs.format))&&(n=i)),(i=$o(n,e.settings.thinkingStyle.phases))&&(n=i),(i=Co(n,e.settings.thinkingStyle.updateInterval))&&(n=i),(i=Eo(n,Math.max(...e.settings.thinkingStyle.phases.map(u=>u.length))+1))&&(n=i),(i=So(n,e.settings.thinkingStyle.reverseMirror))&&(n=i),e.settings.userMessageDisplay&&(i=Oo(n,e.settings.userMessageDisplay.prefix.format,e.settings.userMessageDisplay.prefix.foreground_color,e.settings.userMessageDisplay.prefix.background_color,e.settings.userMessageDisplay.prefix.styling.includes("bold"),e.settings.userMessageDisplay.prefix.styling.includes("italic"),e.settings.userMessageDisplay.prefix.styling.includes("underline"),e.settings.userMessageDisplay.prefix.styling.includes("strikethrough"),e.settings.userMessageDisplay.prefix.styling.includes("inverse"),e.settings.userMessageDisplay.message.foreground_color,e.settings.userMessageDisplay.message.background_color,e.settings.userMessageDisplay.message.styling.includes("bold"),e.settings.userMessageDisplay.message.styling.includes("italic"),e.settings.userMessageDisplay.message.styling.includes("underline"),e.settings.userMessageDisplay.message.styling.includes("strikethrough"),e.settings.userMessageDisplay.message.styling.includes("inverse")))&&(n=i),e.settings.inputBox&&typeof e.settings.inputBox.removeBorder=="boolean"&&(i=mo(n,e.settings.inputBox.removeBorder))&&(n=i),(i=Ao(n))&&(n=i),(i=bo(n))&&(n=i),(i=go(n))&&(n=i),(i=Ir(n))&&(n=i),(i=ao(n,25))&&(n=i),(i=Do(n))&&(n=i);const a=e.settings.misc?.showTweakccVersion??!0,l=e.settings.misc?.showPatchesApplied??!0;if((i=Ho(n,"3.1.5",o,a,l))&&(n=i),(i=Jo(n))&&(n=i),e.settings.toolsets&&e.settings.toolsets.length>0&&(i=ur(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=i),e.settings.planModeToolset&&e.settings.defaultToolset&&((i=ar(n))&&(n=i),(i=dr(n,e.settings.planModeToolset,e.settings.defaultToolset))&&(n=i)),(i=yr(n))&&(n=i),t.nativeInstallationPath){M()&&console.log(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);const u=re.join(ye.homedir(),".tweakcc"),d=re.join(u,"native-claudejs-patched.js");Ie.writeFileSync(d,n,"utf8"),M()&&console.log(`Saved patched JS from native to: ${d}`);const h=Buffer.from(n,"utf8");to(t.nativeInstallationPath,h,t.nativeInstallationPath)}else{if(!t.cliPath)throw new Error("cliPath is required for NPM installations");await fn(t.cliPath,n,"patch")}return await je(u=>{u.changesApplied=!0})},rt=[{label:"Opus 4.1",slug:"opus-4.1",internal:"claude-opus-4-1-20250805"},{label:"Opus 4",slug:"opus-4",internal:"claude-opus-4-20250514"},{label:"Sonnet 4",slug:"sonnet-4",internal:"claude-sonnet-4-20250514"},{label:"Sonnet 3.7",slug:"sonnet-3.7",internal:"claude-3-7-sonnet-20250219"},{label:"Sonnet 3.5 (October)",slug:"sonnet-3.5-october",internal:"claude-3-5-sonnet-20241022"},{label:"Sonnet 3.5 (June)",slug:"sonnet-3.5-june",internal:"claude-3-5-sonnet-20240620"},{label:"Haiku 3.5",slug:"haiku-3.5",internal:"claude-3-5-haiku-20241022"},{label:"Haiku 3",slug:"haiku-3",internal:"claude-3-haiku-20240307"},{label:"Opus 3",slug:"opus-3",internal:"claude-3-opus-20240229"}],_r=e=>{const t=e.indexOf("Switch between Claude models");if(t===-1)return console.error("patch: getModelSelectorInsertionPoint: failed to find labelIndex"),null;const n=Math.max(0,t-600),o=t,i=e.slice(n,o).match(/\[[$\w]+,\s*[$\w]+\]\s*=\s*[$\w]+\.useState\([^)]*\)\s*,\s*([$\w]+)=/);if(!i||i.index===void 0)return console.error("patch: getModelSelectorInsertionPoint: failed to find useState"),null;let l=n+i.index;for(;l<e.length&&e[l]!==";";)l++;if(l>=e.length)return console.error("patch: getModelSelectorInsertionPoint: failed to find semicolon"),null;const u=l+1,d=i[1];return{insertionIndex:u,optionsVar:d}},Cr=e=>{const t=_r(e);if(!t)return null;const{insertionIndex:n,optionsVar:o}=t,r=rt.map(a=>{const l=JSON.stringify(a.label),u=JSON.stringify(a.slug);return`${o}.push({value:${u},label:${l}});`}).join(""),i=e.slice(0,n)+r+e.slice(n);return G(e,i,r,n,n),i},Ir=e=>{let t=e;const n=Cr(t);return n&&(t=n),t===e?null:t};let it=!1;const M=()=>it,Er=()=>{it=!0};function Ke(){try{const e=re.join(ye.homedir(),".claude.json");return JSON.parse(Ie.readFileSync(e,"utf8")).theme||"dark"}catch{}return"dark"}function kr(){try{const e=re.join(ye.homedir(),".claude",".credentials.json");switch(JSON.parse(Ie.readFileSync(e,"utf8"))?.claudeAiOauth?.subscriptionType||"unknown"){case"enterprise":return"Claude Enterprise";case"team":return"Claude Team";case"max":return"Claude Max";case"pro":return"Claude Pro"}}catch{}return"Claude API"}function Tr(){try{const e=re.join(ye.homedir(),".claude","settings.json"),n=JSON.parse(Ie.readFileSync(e,"utf8"))?.model||"default";if(n==="opus")return"Opus 4.1";const o=rt.find(r=>r.slug===n);if(o)return o.label}catch{}return"Sonnet 4.5"}function Mr(e){process.platform==="win32"?Me.spawn("explorer",[e],{detached:!0,stdio:"ignore"}).unref():process.platform==="darwin"?Me.spawn("open",[e],{detached:!0,stdio:"ignore"}).unref():Me.spawn("xdg-open",[e],{detached:!0,stdio:"ignore"}).unref()}function kn(e){if(process.platform==="win32")Me.spawn("explorer",["/select,",e],{detached:!0,stdio:"ignore"}).unref();else if(process.platform==="darwin")Me.spawn("open",["-R",e],{detached:!0,stdio:"ignore"}).unref();else{const t=re.dirname(e);Me.spawn("xdg-open",[t],{detached:!0,stdio:"ignore"}).unref()}}function gn(e){if(!e||typeof e!="string")return!1;const t=e.trim();if(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/.test(t))return!0;if(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/.test(t)){const n=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const[,o,r,i]=n;return parseInt(o)<=255&&parseInt(r)<=255&&parseInt(i)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const[,o,r,i]=n;return parseInt(o)<=360&&parseInt(r)<=100&&parseInt(i)<=100}}return!1}function st(e){if(!gn(e))return e;const t=e.trim();if(t.startsWith("rgb("))return t;if(t.startsWith("#")){let n=t.slice(1);n.length===3&&(n=n.split("").map(a=>a+a).join(""));const o=parseInt(n.slice(0,2),16),r=parseInt(n.slice(2,4),16),i=parseInt(n.slice(4,6),16);return`rgb(${o},${r},${i})`}if(t.startsWith("hsl(")){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const o=parseInt(n[1])/360,r=parseInt(n[2])/100,i=parseInt(n[3])/100,a=(y,b,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<1/6?y+(b-y)*6*p:p<1/2?b:p<2/3?y+(b-y)*(2/3-p)*6:y),l=i<.5?i*(1+r):i+r-i*r,u=2*i-l,d=Math.round(a(u,l,o+1/3)*255),h=Math.round(a(u,l,o)*255),f=Math.round(a(u,l,o-1/3)*255);return`rgb(${d},${h},${f})`}}return e}async function Nr(e,t="sha256",n=64*1024){return new Promise((o,r)=>{const i=An.createHash(t),a=Ie.createReadStream(e,{highWaterMark:n});a.on("data",l=>{i.update(l)}),a.on("end",()=>{o(i.digest("hex"))}),a.on("error",l=>{r(l)})})}const Tn=(e,t,n,o,r,i,a,l)=>{let u=e;return t&&(u+=`.rgb(${t})`),n&&n!=="transparent"&&(u+=`.bgRgb(${n})`),o&&(u+=".bold"),r&&(u+=".italic"),i&&(u+=".underline"),a&&(u+=".strikethrough"),l&&(u+=".inverse"),u};async function fn(e,t,n="replace"){let o=493;try{o=(await oe.stat(e)).mode,M()&&console.log(`[${n}] Original file mode for ${e}: ${(o&parseInt("777",8)).toString(8)}`)}catch(r){M()&&console.log(`[${n}] Could not stat ${e} (error: ${r}), using default mode 755`)}try{await oe.unlink(e),M()&&console.log(`[${n}] Unlinked ${e} to break hard links`)}catch(r){M()&&console.log(`[${n}] Could not unlink ${e}: ${r}`)}await oe.writeFile(e,t),await oe.chmod(e,o),M()&&console.log(`[${n}] Restored permissions to ${(o&parseInt("777",8)).toString(8)}`)}function U({color:e,backgroundColor:t,bold:n,dimColor:o,children:r}){const i=e?.startsWith("ansi:"),a=t?.startsWith("ansi:");if(i||a){if(Ze.Children.toArray(r).some(f=>Ze.isValidElement(f)))return s(c,{children:r});let u=H;if(i){const f=e.slice(5);u=u[f]||u}if(a){const f=t.slice(5),y=f.startsWith("bg")?f:`bg${f.charAt(0).toUpperCase()}${f.slice(1)}`;u=u[y]||u}n&&(u=u.bold),o&&(u=u.dim);const h=Ze.Children.toArray(r).map(f=>typeof f=="string"||typeof f=="number"?String(f):"").join("");return s(c,{children:u(h)})}return s(c,{color:e,backgroundColor:t,bold:n,dimColor:o,children:r})}function Or({text:e,nonShimmerColors:t,shimmerColors:n,shimmerWidth:o=3,updateDuration:r=50,restartPoint:i=10}){const[a,l]=P(0);return xe(()=>{const u=setInterval(()=>{l(d=>{const h=d+1;return h>=e.length+i?-o:h})},r);return()=>clearInterval(u)},[e.length,i,r]),t.length!==n.length?(console.error("UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length"),s(c,{children:e})):s(c,{children:e.split("").map((u,d)=>{const h=d>=a&&d<a+o&&a<e.length,f=d%t.length,y=h?n[f]:t[f];return s(c,{color:y,children:u},d)})})}const Br=ft.cwd();function lt({theme:e}){const{ccVersion:t}=be(ue);return g(m,{flexDirection:"column",paddingLeft:1,children:[s(m,{marginBottom:1,children:g(c,{bold:!0,children:["Preview: ",e.name]})}),s(m,{borderStyle:"single",borderColor:"gray",paddingX:1,children:g(m,{flexDirection:"column",children:[g(m,{flexDirection:"column",children:[g(c,{children:[s(U,{color:e.colors.clawd_body,children:" ▐"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"▛███▜"}),g(c,{children:[s(U,{color:e.colors.clawd_body,children:"▌ "})," ",s(c,{bold:!0,children:"Claude Code"})," ",t?`v${t}`:"v2.0.14"]})]}),g(c,{children:[s(U,{color:e.colors.clawd_body,children:"▝▜"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"█████"}),s(U,{color:e.colors.clawd_body,children:"▛▘"})," ",Tr()," · ",kr()]}),g(U,{color:e.colors.clawd_body,children:[" ","▘▘ ▝▝"," ",Br]}),g(c,{children:[g(U,{color:e.colors.success,children:["Login successful. Press"," "]}),s(U,{bold:!0,color:e.colors.success,children:"Enter"}),g(U,{color:e.colors.success,children:[" ","to continue…"]})]})]}),s(c,{children:"╭─────────────────────────────────────────────╮"}),g(c,{children:["│ 1 function greet() ","{"," ","│"]}),g(c,{children:["│ 2"," ",s(U,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:'- console.log("'}),s(U,{backgroundColor:e.colors.diffRemovedWord,children:"Hello, World!"}),s(U,{backgroundColor:e.colors.diffRemoved,children:'");'})," ","│"]}),g(c,{children:["│ 2"," ",s(U,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:'+ console.log("'}),s(U,{backgroundColor:e.colors.diffAddedWord,children:"Hello, Claude!"}),s(U,{backgroundColor:e.colors.diffAdded,children:'");'})," ","│"]}),s(U,{color:e.colors.warning,children:"╭─────────────────────────────────────────────╮"}),g(U,{color:e.colors.warning,children:["│ Do you trust the files in this folder?"," ","│"]}),g(c,{children:[s(U,{color:e.colors.warning,children:"│ "}),s(c,{dimColor:!0,children:"Enter to confirm · Esc to exit"}),g(U,{color:e.colors.warning,children:[" ","│"]})]}),s(U,{color:e.colors.bashBorder,children:"───────────────────────────────────────────────"}),g(c,{children:[s(U,{color:e.colors.bashBorder,children:"!"}),s(c,{children:" ls"})]}),s(U,{color:e.colors.promptBorder,children:"───────────────────────────────────────────────"}),s(c,{children:g(c,{children:["> list the dir"," ",s(Or,{text:"ultrathink",nonShimmerColors:[e.colors.rainbow_red,e.colors.rainbow_orange,e.colors.rainbow_yellow,e.colors.rainbow_green,e.colors.rainbow_blue,e.colors.rainbow_indigo,e.colors.rainbow_violet],shimmerColors:[e.colors.rainbow_red_shimmer,e.colors.rainbow_orange_shimmer,e.colors.rainbow_yellow_shimmer,e.colors.rainbow_green_shimmer,e.colors.rainbow_blue_shimmer,e.colors.rainbow_indigo_shimmer,e.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),s(U,{color:e.colors.planMode,children:"╭─────────────────────────────────────────────╮"}),g(c,{children:[s(U,{color:e.colors.planMode,children:"│ "}),g(U,{color:e.colors.permission,children:["Ready to code?"," "]}),s(c,{children:"Here is Claude's plan:"}),g(U,{color:e.colors.planMode,children:[" ","│"]})]}),s(U,{color:e.colors.permission,children:"╭─────────────────────────────────────────────╮"}),g(c,{children:[s(U,{color:e.colors.permission,children:"│ "}),s(c,{bold:!0,children:"Permissions:"})," ",g(U,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[" ","Allow"," "]})," ","Deny"," ","Workspace"," ",s(U,{color:e.colors.permission,children:"│"})]}),s(c,{children:"> list the dir"}),g(c,{children:[s(U,{color:e.colors.error,children:"●"}),s(c,{children:" Update(__init__.py)"})]}),g(c,{children:[s(c,{children:" ⎿ "}),s(U,{color:e.colors.error,children:"User rejected update to __init__.py"})]}),g(c,{children:[" ","1"," ",g(U,{backgroundColor:e.colors.diffRemovedDimmed,children:["- import"," "]}),s(U,{backgroundColor:e.colors.diffRemovedWordDimmed,children:"os"})]}),g(c,{children:[" ","2"," ",g(U,{backgroundColor:e.colors.diffAddedDimmed,children:["+ import"," "]}),s(U,{backgroundColor:e.colors.diffAddedWordDimmed,children:"random"})]}),g(c,{children:[s(U,{color:e.colors.success,children:"●"}),s(c,{children:" List(.)"})]}),g(c,{children:[s(c,{children:"●"}),s(c,{children:" The directory "}),s(U,{color:e.colors.permission,children:"C:\\Users\\user"}),g(c,{children:[" ","contains ",s(c,{bold:!0,children:"123"})," files."]})]}),g(c,{children:[s(U,{color:e.colors.claude,children:"✻ Th"}),s(U,{color:e.colors.claudeShimmer,children:"ink"}),s(U,{color:e.colors.claude,children:"ing… "}),s(c,{children:"(esc to interrupt)"})]}),s(c,{children:s(U,{color:e.colors.autoAccept,children:"⏵⏵ accept edits on (shift+tab to cycle)"})}),s(c,{children:s(U,{color:e.colors.planMode,children:"⏸ plan mode on (shift+tab to cycle)"})}),s(c,{children:s(U,{color:e.colors.ide,children:"◯ IDE connected ⧉ 44 lines selected"})})]})})]})}function Qe({colorKey:e,theme:t,bold:n=!1}){const o=t.colors[e];return e==="inverseText"?s(U,{color:o,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith("diff")?s(U,{backgroundColor:o,bold:n,color:t.colors.text,children:e}):s(U,{color:o,bold:n,children:e})}function at({initialValue:e,onColorChange:t,onExit:n,colorKey:o,theme:r}){const i=nn(e)||{h:0,s:50,l:50},a=en(e)||{r:128,g:128,b:128},[l,u]=P(i),[d,h]=P(a),[f,y]=P("hsl"),[b,p]=P("h"),[w,S]=P(!1),[E,x]=P(!1);xe(()=>{const C=nn(e),_=en(e);C&&_&&(S(!0),u(C),h(_),S(!1))},[e]),xe(()=>{if(!w&&E){const C=`rgb(${d.r},${d.g},${d.b})`;t(C)}},[l,d,w,E]),xe(()=>{x(!0)},[]);const k=C=>{if(gn(C)){const _=st(C),$=nn(_),A=en(_);$&&A&&(S(!0),u($),h(A),S(!1))}};de((C,_)=>{if(C.length>1&&!_.ctrl&&!_.meta){k(C);return}if(_.return)n();else if(_.escape)n();else if(_.ctrl&&C==="a")y($=>$==="hsl"?"rgb":"hsl"),p($=>f==="hsl"?$==="h"?"r":$==="s"?"g":"b":$==="r"?"h":$==="g"?"s":"l");else if(_.upArrow)p(f==="hsl"?$=>$==="h"?"l":$==="s"?"h":"s":$=>$==="r"?"b":$==="g"?"r":"g");else if(_.downArrow||_.tab)p(f==="hsl"?$=>$==="h"?"s":$==="s"?"l":"h":$=>$==="r"?"g":$==="g"?"b":"r");else if(_.leftArrow){const $=_.shift||_.ctrl||_.meta?-10:-1;D($)}else if(_.rightArrow){const $=_.shift||_.ctrl||_.meta?10:1;D($)}});const D=C=>{S(!0),f==="hsl"?u(_=>{const $={..._};b==="h"?$.h=Math.max(0,Math.min(359,_.h+C)):b==="s"?$.s=Math.max(0,Math.min(100,_.s+C)):b==="l"&&($.l=Math.max(0,Math.min(100,_.l+C)));const[A,v,R]=N($.h,$.s,$.l);return h({r:A,g:v,b:R}),$}):h(_=>{const $={..._};b==="r"?$.r=Math.max(0,Math.min(255,_.r+C)):b==="g"?$.g=Math.max(0,Math.min(255,_.g+C)):b==="b"&&($.b=Math.max(0,Math.min(255,_.b+C)));const A=O($.r,$.g,$.b);return u(A),$}),S(!1)},O=(C,_,$)=>{const A=C/255,v=_/255,R=$/255,K=Math.max(A,v,R),J=Math.min(A,v,R),te=K-J,se=(K+J)/2;let $e=0;te!==0&&($e=se>.5?te/(2-K-J):te/(K+J));let we=0;return te!==0&&(K===A?we=((v-R)/te+(v<R?6:0))/6:K===v?we=((R-A)/te+2)/6:we=((A-v)/te+4)/6),{h:Math.round(we*360),s:Math.round($e*100),l:Math.round(se*100)}},N=(C,_,$)=>{C/=360,_/=100,$/=100;const A=(1-Math.abs(2*$-1))*_,v=A*(1-Math.abs(C*6%2-1)),R=$-A/2;let K=0,J=0,te=0;return 0<=C&&C<1/6?(K=A,J=v,te=0):1/6<=C&&C<2/6?(K=v,J=A,te=0):2/6<=C&&C<3/6?(K=0,J=A,te=v):3/6<=C&&C<4/6?(K=0,J=v,te=A):4/6<=C&&C<5/6?(K=v,J=0,te=A):5/6<=C&&C<1&&(K=A,J=0,te=v),[Math.round((K+R)*255),Math.round((J+R)*255),Math.round((te+R)*255)]},j=()=>{const C=[],_=[[255,0,0],[255,127,0],[255,255,0],[127,255,0],[0,255,0],[0,255,127],[0,255,255],[0,127,255],[0,0,255],[127,0,255],[255,0,255],[255,0,127],[255,0,0]];for(let $=0;$<40;$++){const v=$/39*(_.length-1),R=Math.floor(v),K=Math.ceil(v),J=v-R,[te,se,$e]=_[R],[we,Y,V]=_[K],F=Math.round(te+(we-te)*J),ne=Math.round(se+(Y-se)*J),X=Math.round($e+(V-$e)*J);C.push(s(c,{backgroundColor:`rgb(${F},${ne},${X})`,children:" "},$))}return C},L=()=>{const C=[];for(let _=0;_<40;_++){const $=_/39*100,[A,v,R]=N(l.h,$,l.l);C.push(s(c,{backgroundColor:`rgb(${A},${v},${R})`,children:" "},_))}return C},B=()=>{const C=[];for(let _=0;_<40;_++){const $=_/39*100,[A,v,R]=N(l.h,l.s,$);C.push(s(c,{backgroundColor:`rgb(${A},${v},${R})`,children:" "},_))}return C},T=()=>{const[C,_,$]=N(l.h,l.s,l.l);return`rgb(${C},${_},${$})`},I=(C,_,$)=>{const A=v=>v.toString(16).padStart(2,"0");return`#${A(C)}${A(_)}${A($)}`},z=()=>{const C=[];for(let _=0;_<40;_++){const $=Math.round(_/39*255);C.push(s(c,{backgroundColor:`rgb(${$},${d.g},${d.b})`,children:" "},_))}return C},W=()=>{const C=[];for(let _=0;_<40;_++){const $=Math.round(_/39*255);C.push(s(c,{backgroundColor:`rgb(${d.r},${$},${d.b})`,children:" "},_))}return C},Q=()=>{const C=[];for(let _=0;_<40;_++){const $=Math.round(_/39*255);C.push(s(c,{backgroundColor:`rgb(${d.r},${d.g},${$})`,children:" "},_))}return C},q=(C,_)=>Math.round(C/_*39);return g(m,{flexDirection:"column",borderStyle:"single",borderColor:"white",padding:1,children:[g(m,{flexDirection:"column",children:[s(c,{bold:!0,children:"Color Picker"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{color:"gray",dimColor:!0,children:"←→ to adjust (shift/ctrl/cmd +10)"}),s(c,{color:"gray",dimColor:!0,children:"↑↓ to change bar"}),s(c,{color:"gray",dimColor:!0,children:"ctrl+a to switch rgb/hsl"}),s(c,{color:"gray",dimColor:!0,children:"paste color from clipboard"}),s(c,{color:"gray",dimColor:!0,children:"enter to exit (auto-saved)"}),s(c,{color:"gray",dimColor:!0,children:"esc to save and exit"})]})]}),f==="hsl"?g(me,{children:[g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="h"?"yellow":"white",children:[b==="h"?"❯ ":" ","Hue (",l.h,"°):"]})}),s(m,{children:j().map((C,_)=>s(Ee,{children:_===q(l.h,360)?s(c,{children:"|"}):C},_))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="s"?"yellow":"white",children:[b==="s"?"❯ ":" ","Saturation (",l.s,"%):"]})}),s(m,{children:L().map((C,_)=>s(Ee,{children:_===q(l.s,100)?s(c,{children:"|"}):C},_))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="l"?"yellow":"white",children:[b==="l"?"❯ ":" ","Lightness (",l.l,"%):"]})}),s(m,{children:B().map((C,_)=>s(Ee,{children:_===q(l.l,100)?s(c,{children:"|"}):C},_))})]})]}):g(me,{children:[g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="r"?"yellow":"white",children:[b==="r"?"❯ ":" ","Red (",d.r,"):"]})}),s(m,{children:z().map((C,_)=>s(Ee,{children:_===q(d.r,255)?s(c,{children:"|"}):C},_))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="g"?"yellow":"white",children:[b==="g"?"❯ ":" ","Green (",d.g,"):"]})}),s(m,{children:W().map((C,_)=>s(Ee,{children:_===q(d.g,255)?s(c,{children:"|"}):C},_))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="b"?"yellow":"white",children:[b==="b"?"❯ ":" ","Blue (",d.b,"):"]})}),s(m,{children:Q().map((C,_)=>s(Ee,{children:_===q(d.b,255)?s(c,{children:"|"}):C},_))})]})]}),g(m,{marginBottom:1,children:[s(c,{children:"Current: "}),s(c,{backgroundColor:T(),children:" "})]}),g(m,{flexDirection:"row",justifyContent:"space-between",children:[g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"Hex "}),o?.startsWith("diff")?s(c,{backgroundColor:T(),color:r?.colors?.text||"white",bold:!0,children:I(d.r,d.g,d.b)}):o==="inverseText"?s(c,{color:T(),backgroundColor:r?.colors?.permission,bold:!0,children:I(d.r,d.g,d.b)}):s(c,{color:T(),bold:!0,children:I(d.r,d.g,d.b)})]}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"RGB "}),o?.startsWith("diff")?s(c,{backgroundColor:T(),color:r?.colors?.text||"white",bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):o==="inverseText"?s(c,{color:T(),backgroundColor:r?.colors?.permission,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):s(c,{color:T(),bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`})]}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"HSL "}),o?.startsWith("diff")?s(c,{backgroundColor:T(),color:r?.colors?.text||"white",bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):o==="inverseText"?s(c,{color:T(),backgroundColor:r?.colors?.permission,bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):s(c,{color:T(),bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`})]})]})]})}function en(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t)return{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])};const n=e.match(/^#([a-fA-F0-9]{6})$/);if(n){const o=n[1];return{r:parseInt(o.substr(0,2),16),g:parseInt(o.substr(2,2),16),b:parseInt(o.substr(4,2),16)}}return null}function nn(e){const t=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t)return{h:parseInt(t[1]),s:parseInt(t[2]),l:parseInt(t[3])};const n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const r=parseInt(n[1])/255,i=parseInt(n[2])/255,a=parseInt(n[3])/255,l=Math.max(r,i,a),u=Math.min(r,i,a),d=l-u,h=(l+u)/2;let f=0;d!==0&&(f=h>.5?d/(2-l-u):d/(l+u));let y=0;return d!==0&&(l===r?y=((i-a)/d+(i<a?6:0))/6:l===i?y=((a-r)/d+2)/6:y=((r-i)/d+4)/6),{h:Math.round(y*360),s:Math.round(f*100),l:Math.round(h*100)}}const o=e.match(/^#([a-fA-F0-9]{6})$/);if(o){const r=o[1],i=parseInt(r.substr(0,2),16)/255,a=parseInt(r.substr(2,2),16)/255,l=parseInt(r.substr(4,2),16)/255,u=Math.max(i,a,l),d=Math.min(i,a,l),h=u-d,f=(u+d)/2;let y=0;h!==0&&(y=f>.5?h/(2-u-d):h/(u+d));let b=0;return h!==0&&(u===i?b=((a-l)/h+(a<l?6:0))/6:u===a?b=((l-i)/h+2)/6:b=((i-a)/h+4)/6),{h:Math.round(b*360),s:Math.round(y*100),l:Math.round(f*100)}}return{h:0,s:50,l:50}}function Ar({onBack:e,themeId:t}){const{settings:{themes:n},updateSettings:o}=be(ue),[r,i]=P(t),a=n.find(B=>B.id===r)||n[0],[l,u]=P("rgb"),[d,h]=P(0),[f,y]=P(null),[b,p]=P(null),[w,S]=P(""),[E,x]=P(""),k=Nn(B=>{o(T=>{const I=T.themes.findIndex(z=>z.id===r);I!==-1&&B(T.themes[I])})},[r,o]),D=B=>{if(d>=2&&gn(B)){const T=st(B),I=d-2,z=O[I];k(W=>{W.colors[z]=T})}};de((B,T)=>{if(f===null&&b===null){if(B.length>1&&!T.ctrl&&!T.meta){D(B);return}if(T.escape)e();else if(T.ctrl&&B==="a")u(I=>I==="rgb"?"hex":I==="hex"?"hsl":"rgb");else if(T.upArrow)h(I=>Math.max(0,I-1));else if(T.downArrow)h(I=>Math.min(O.length+1,I+1));else if(T.return)if(d===0)p("name"),S(a.name),x(a.name);else if(d===1)p("id"),S(a.id),x(a.id);else{const I=d-2,z=O[I],W=a.colors[z];y(I),S(W),x(W)}}else if(f!==null)T.ctrl&&B==="a"&&u(I=>I==="rgb"?"hex":I==="hex"?"hsl":"rgb");else if(b!==null)if(T.return){if(b==="id"){const I=r;i(w),o(z=>{const W=z.themes.findIndex(Q=>Q.id===I);W!==-1&&(z.themes[W].id=w)})}else k(I=>{I.name=w});p(null),S(""),x("")}else T.escape?(p(null),S(""),x("")):T.backspace||T.delete?S(I=>I.slice(0,-1)):B&&S(I=>I+B)});const O=Object.keys(a.colors),N=(B,T)=>{const I=B.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!I)return B;const z=parseInt(I[1]),W=parseInt(I[2]),Q=parseInt(I[3]);switch(T){case"hex":{const q=C=>C.toString(16).padStart(2,"0");return`#${q(z)}${q(W)}${q(Q)}`}case"hsl":{const q=z/255,C=W/255,_=Q/255,$=Math.max(q,C,_),A=Math.min(q,C,_),v=$-A,R=($+A)/2;let K=0;v!==0&&(K=R>.5?v/(2-$-A):v/($+A));let J=0;return v!==0&&($===q?J=((C-_)/v+(C<_?6:0))/6:$===C?J=((_-q)/v+2)/6:J=((q-C)/v+4)/6),`hsl(${Math.round(J*360)}, ${Math.round(K*100)}%, ${Math.round(R*100)}%)`}case"rgb":default:return B}},j=B=>({autoAccept:"Auto-accept edits mode indicator",bashBorder:"Bash command border",claude:"Claude branding color. Used for the Claude logo, the welcome message, and the thinking text.",claudeShimmer:"Color used for the shimmering effect on the thinking verb.",claudeBlue_FOR_SYSTEM_SPINNER:"System spinner color (blue variant)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"System spinner shimmer color (blue variant)",permission:"Permission prompt color",permissionShimmer:"Permission prompt shimmer color",planMode:"Plan mode indicator",ide:"Color used for IDE-related messages.",promptBorder:"Input prompt border color",promptBorderShimmer:"Input prompt border shimmer color",text:"Code color. Used in diffs.",inverseText:"Inverse text color. Used for the text of tabs, where the background is filled in.",inactive:"Inactive/dimmed text. Used for line numbers and less prominent text.",subtle:"Subtle text. Used for help text and secondary information.",suggestion:"Suggestion text color. Used for suggestions for theme names and various other things.",remember:"Remember/note color. Used for various text relating to memories.",background:"Background color for certain UI elements",success:"Success indicator. Used for the bullet on successful tool calls, and various success messages (such as sign in successful).",error:"Error indicator",warning:"Warning indicator",warningShimmer:"Warning shimmer color",diffAdded:"Added diff background",diffRemoved:"Removed diff background",diffAddedDimmed:"Added diff background (dimmed)",diffRemovedDimmed:"Removed diff background (dimmed)",diffAddedWord:"Added word highlight",diffRemovedWord:"Removed word highlight",diffAddedWordDimmed:"Added word highlight (dimmed)",diffRemovedWordDimmed:"Removed word highlight (dimmed)",red_FOR_SUBAGENTS_ONLY:"Red color for sub agents",blue_FOR_SUBAGENTS_ONLY:"Blue color for sub agents",green_FOR_SUBAGENTS_ONLY:"Green color for sub agents",yellow_FOR_SUBAGENTS_ONLY:"Yellow color for sub agents",purple_FOR_SUBAGENTS_ONLY:"Purple color for sub agents",orange_FOR_SUBAGENTS_ONLY:"Orange color for sub agents",pink_FOR_SUBAGENTS_ONLY:"Pink color for sub agents",cyan_FOR_SUBAGENTS_ONLY:"Cyan color for sub agents",professionalBlue:"Professional blue color for business contexts?",rainbow_red:'"ultrathink" rainbow - red',rainbow_orange:'"ultrathink" rainbow - orange',rainbow_yellow:'"ultrathink" rainbow - yellow',rainbow_green:'"ultrathink" rainbow - green',rainbow_blue:'"ultrathink" rainbow - blue',rainbow_indigo:'"ultrathink" rainbow - indigo',rainbow_violet:'"ultrathink" rainbow - violet',rainbow_red_shimmer:'"ultrathink" rainbow (shimmer) - red',rainbow_orange_shimmer:'"ultrathink" rainbow (shimmer) - orange',rainbow_yellow_shimmer:'"ultrathink" rainbow (shimmer) - yellow',rainbow_green_shimmer:'"ultrathink" rainbow (shimmer) - green',rainbow_blue_shimmer:'"ultrathink" rainbow (shimmer) - blue',rainbow_indigo_shimmer:'"ultrathink" rainbow (shimmer) - indigo',rainbow_violet_shimmer:'"ultrathink" rainbow (shimmer) - violet',clawd_body:'"Clawd" character body color',clawd_background:'"Clawd" character background color',userMessageBackground:"Background color for user messages",bashMessageBackgroundColor:"Background color for bash command output",memoryBackgroundColor:"Background color for memory/context information",rate_limit_fill:"Rate limit indicator fill color",rate_limit_empty:"Rate limit indicator empty/background color"})[B]||"",L=Math.max(...O.map(B=>B.length));return g(m,{children:[g(m,{flexDirection:"column",width:"50%",children:[s(m,{children:g(pe,{children:["Editing theme “",a.name,"” (",a.id,")"]})}),f===null&&b===null?g(me,{children:[g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"enter to edit theme name, id, or color"}),s(c,{dimColor:!0,children:"ctrl+a to toggle rgb, hex, hsl"}),s(c,{dimColor:!0,children:"paste color from clipboard (when on color)"}),s(c,{dimColor:!0,children:"esc to go back"})]}),d<2?g(m,{marginBottom:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:"yellow",flexDirection:"column",paddingLeft:1,children:[s(c,{bold:!0,children:d===0?"Theme Name":"Theme ID"}),s(c,{children:d===0?"The display name for this theme":"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):g(m,{marginBottom:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:a.colors[O[d-2]],flexDirection:"column",paddingLeft:1,children:[s(Qe,{colorKey:O[d-2],theme:a,bold:!0}),s(c,{children:j(O[d-2])})]}),g(m,{flexDirection:"column",children:[g(m,{children:[s(c,{color:d===0?"yellow":"white",children:d===0?"❯ ":" "}),s(c,{bold:!0,children:"Name: "}),s(c,{children:a.name})]}),g(m,{marginBottom:1,children:[s(c,{color:d===1?"yellow":"white",children:d===1?"❯ ":" "}),s(c,{bold:!0,children:"ID: "}),s(c,{children:a.id})]}),(()=>{if(d<2){const q=O.slice(0,20);return g(me,{children:[q.map((C,_)=>{const $=_+2;return g(m,{children:[s(c,{color:d===$?"yellow":"white",children:d===$?"❯ ":" "}),s(m,{width:L+2,children:s(c,{children:s(Qe,{colorKey:C,theme:a,bold:!0})})}),s(U,{color:a.colors[C],children:N(a.colors[C],l)})]},C)}),O.length>20&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",O.length-20," more below"]})]})}const T=d-2,I=Math.max(0,T-Math.floor(20/2)),z=Math.min(O.length,I+20),W=Math.max(0,z-20),Q=O.slice(W,z);return g(me,{children:[W>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",W," more above"]}),Q.map((q,C)=>{const $=W+C+2;return g(m,{children:[s(c,{color:d===$?"yellow":"white",children:d===$?"❯ ":" "}),s(m,{width:L+2,children:s(c,{children:s(Qe,{colorKey:q,theme:a,bold:!0})})}),s(U,{color:a.colors[q],children:N(a.colors[q],l)})]},q)}),z<O.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",O.length-z," more below"]})]})})()]})]}):b?g(m,{flexDirection:"column",marginTop:1,children:[g(c,{children:["Editing ",b==="name"?"theme name":"theme ID",":"]}),s(m,{borderStyle:"round",borderColor:"yellow",paddingX:1,children:s(c,{children:w})}),s(c,{dimColor:!0,children:"enter to save, esc to cancel"})]}):s(at,{initialValue:E,colorKey:O[f],theme:a,onColorChange:B=>{S(B),k(T=>{T.colors[O[f]]=B})},onExit:()=>{k(B=>{B.colors[O[f]]=w}),y(null),S(""),x("")}})]}),s(m,{width:"50%",children:s(lt,{theme:a})})]})}function Pr(e){return e.map(t=>`${t.name} (${t.id})`)}function Lr({onBack:e}){const{settings:{themes:t},updateSettings:n}=be(ue),[o,r]=P(0),[i,a]=P(null),[l,u]=P(!0),d=()=>{const w={colors:{...(t[0]||ee.themes[0]).colors},name:"New Custom Theme",id:`custom-${Date.now()}`};n(S=>{S.themes.push(w)}),a(w.id),u(!1)},h=p=>{t.length<=1||(n(w=>{w.themes=w.themes.filter(S=>S.id!==p)}),o>=t.length-1&&r(Math.max(0,t.length-2)))},f=()=>{n(p=>{p.themes=[...ee.themes]}),r(0)};if(de((p,w)=>{if(w.escape)e();else if(w.upArrow)r(S=>Math.max(0,S-1));else if(w.downArrow)r(S=>Math.min(t.length-1,S+1));else if(w.return){const S=t[o];S&&(a(S.id),u(!1))}else if(p==="n")d();else if(p==="d"){const S=t[o];S&&h(S.id)}else w.ctrl&&p==="r"&&f()},{isActive:l}),i)return s(Ar,{themeId:i,onBack:()=>{a(null),u(!0)}});const y=Pr(t),b=t.find(p=>y[o]?.includes(`(${p.id})`))||t[0];return t.length===0?s(m,{children:g(m,{flexDirection:"column",width:"100%",children:[s(pe,{children:"Themes"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new theme"}),s(c,{dimColor:!0,children:"esc to go back"})]}),s(c,{children:"No themes available!"})]})}):g(m,{children:[g(m,{flexDirection:"column",width:"50%",children:[s(pe,{children:"Themes"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new theme"}),s(c,{dimColor:!0,children:"d to delete a theme"}),s(c,{dimColor:!0,children:"ctrl+r to delete all themes and restore built-in"}),s(c,{dimColor:!0,children:"enter to edit theme"}),s(c,{dimColor:!0,children:"esc to go back"})]}),s(m,{flexDirection:"column",children:y.map((p,w)=>g(c,{color:o===w?"yellow":void 0,children:[o===w?"❯ ":" ",p]},w))})]}),s(m,{width:"50%",children:s(lt,{theme:b})})]})}function Dr({onBack:e}){const{settings:{thinkingVerbs:{format:t,verbs:n},themes:o},updateSettings:r}=be(ue),i=["format","verbs"],[a,l]=P(0),u=i[a],[d,h]=P(0),[f,y]=P(!1),[b,p]=P(""),[w,S]=P(!1),[E,x]=P(!1),[k,D]=P(t),O=Ke(),j=(o.find(B=>B.id===O)||o.find(B=>B.id==="dark"))?.colors.claude||"rgb(215,119,87)";de((B,T)=>{if(E){T.return?(r(I=>{I.thinkingVerbs.format=k}),x(!1)):T.escape?(D(t),x(!1)):T.backspace||T.delete?D(I=>I.slice(0,-1)):B&&D(I=>I+B);return}if(f||w){T.return&&b.trim()?(w?(r(I=>{I.thinkingVerbs.verbs.push(b.trim())}),S(!1)):(r(I=>{I.thinkingVerbs.verbs[d]=b.trim()}),y(!1)),p("")):T.escape?(p(""),y(!1),S(!1)):T.backspace||T.delete?p(I=>I.slice(0,-1)):B&&p(I=>I+B);return}T.escape?e():T.return?u==="format"&&(D(t),x(!0)):T.tab?T.shift?l(I=>I===0?i.length-1:I-1):l(I=>I===i.length-1?0:I+1):T.upArrow?u==="verbs"&&n.length>0&&h(I=>I>0?I-1:n.length-1):T.downArrow?u==="verbs"&&n.length>0&&h(I=>I<n.length-1?I+1:0):B==="e"&&u==="verbs"?n.length>0&&(p(n[d]),y(!0)):B==="d"&&u==="verbs"?n.length>1&&(r(I=>{I.thinkingVerbs.verbs=I.thinkingVerbs.verbs.filter((z,W)=>W!==d)}),d>=n.length-1&&h(Math.max(0,n.length-2))):B==="n"&&u==="verbs"?(S(!0),p("")):T.ctrl&&B==="r"&&u==="verbs"&&(r(I=>{I.thinkingVerbs.verbs=[...ee.thinkingVerbs.verbs]}),h(0))});const L=50;return g(m,{children:[g(m,{flexDirection:"column",width:`${100-L}%`,children:[g(m,{marginBottom:1,flexDirection:"column",children:[s(pe,{children:"Thinking Verbs"}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:u==="format"?"enter to edit format":"changes auto-saved"}),s(c,{dimColor:!0,children:"esc to go back"}),s(c,{dimColor:!0,children:"tab to switch sections"})]})]}),s(m,{marginBottom:1,children:s(c,{dimColor:!0,children:"Customize the verbs shown during generation and their format."})}),g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:u==="format"?"yellow":void 0,children:u==="format"?"❯ ":" "}),s(c,{bold:!0,color:u==="format"?"yellow":void 0,children:"Format"})]}),u==="format"&&(E?g(c,{dimColor:!0,children:[" ","enter to save"]}):g(c,{dimColor:!0,children:[" ","enter to edit"]}))]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:E?"yellow":"gray",children:s(c,{children:E?k:t})})}),s(m,{children:g(c,{children:[s(c,{color:u==="verbs"?"yellow":void 0,children:u==="verbs"?"❯ ":" "}),s(c,{bold:!0,color:u==="verbs"?"yellow":void 0,children:"Verbs"})]})}),u==="verbs"&&s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","e to edit · d to delete · n to add new · ctrl+r to reset"]})}),s(m,{marginLeft:2,marginBottom:1,children:g(m,{flexDirection:"column",children:[(()=>{const T=Math.max(0,d-Math.floor(4)),I=Math.min(n.length,T+8),z=Math.max(0,I-8),W=n.slice(z,I);return g(me,{children:[z>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",z," more above"]}),W.map((Q,q)=>{const C=z+q;return g(c,{color:u==="verbs"&&C===d?"cyan":void 0,children:[u==="verbs"&&C===d?"❯ ":" ",Q]},C)}),I<n.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",n.length-I," more below"]})]})})(),w&&g(m,{alignItems:"center",children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:b})})]}),f&&g(m,{marginTop:1,alignItems:"center",children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:b})})]})]})})]}),g(m,{width:`${L}%`,flexDirection:"column",children:[s(m,{marginBottom:1,children:s(c,{bold:!0,children:"Preview"})}),s(m,{borderStyle:"single",borderColor:"gray",padding:1,flexDirection:"column",children:g(c,{children:[g(c,{color:j,children:["✻ ",t.replace(/\{\}/g,n[d])," "]}),s(c,{children:"(esc to interrupt)"})]})})]})]})}const _e=[{name:"Default",phases:ee.thinkingStyle.phases,reverseMirror:ee.thinkingStyle.reverseMirror},{name:"Basic",phases:["|","/","-","\\"],reverseMirror:!1},{name:"Braille",phases:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],reverseMirror:!1},{name:"Circle",phases:["◐","◓","◑","◒"],reverseMirror:!1},{name:"Wave",phases:["▁","▃","▄","▅","▆","▇","█"],reverseMirror:!0},{name:"Glow",phases:["░","▒","▓","█"],reverseMirror:!0},{name:"Partial block",phases:["▏","▎","▍","▌","▋","▊","▉","█"],reverseMirror:!0},{name:"Clock",phases:["🕛","🕐","🕑","🕒","🕓","🕔","🕕","🕖","🕗","🕘","🕙","🕚"],reverseMirror:!1},{name:"Globe",phases:["🌍","🌎","🌏"],reverseMirror:!1},{name:"Arc",phases:["◜","◠","◝","◞","◡","◟"],reverseMirror:!1},{name:"Triangle",phases:["◤","◥","◢","◣"],reverseMirror:!1},{name:"Bouncing",phases:["⠁","⠂","⠄","⡀","⢀","⠠","⠐","⠈"],reverseMirror:!1},{name:"Dots",phases:[".","..","..."],reverseMirror:!1},{name:"Colors",phases:["🔴","🟠","🟡","🟢","🔵","🟣"],reverseMirror:!1}];function Rr({onBack:e}){const{settings:{thinkingStyle:{phases:t,updateInterval:n,reverseMirror:o},themes:r},updateSettings:i}=be(ue),a=["reverseMirror","updateInterval","phases","presets"],[l,u]=P(0),d=a[l],[h,f]=P(0),[y,b]=P(0),[p,w]=P(!1),[S,E]=P(""),[x,k]=P(!1),[D,O]=P(!1),[N,j]=P(n.toString()),[L,B]=P(0),T=Ke(),z=(r.find($=>$.id===T)||r.find($=>$.id==="dark"))?.colors.claude||"rgb(215,119,87)";xe(()=>{if(t.length>0){const $=o?[...t,...[...t].reverse().slice(1,-1)]:t,A=setInterval(()=>{B(v=>(v+1)%$.length)},n);return()=>clearInterval(A)}},[t,n,o]),de(($,A)=>{if(D){if(A.return){const v=parseInt(N);!isNaN(v)&&v>0&&i(R=>{R.thinkingStyle.updateInterval=v}),O(!1)}else A.escape?(j(n.toString()),O(!1)):A.backspace||A.delete?j(v=>v.slice(0,-1)):$&&$.match(/^[0-9]$/)&&j(v=>v+$);return}if(p||x){if(A.return&&S.length){const v=x?[...t,S]:t.map((R,K)=>K===h?S:R);i(R=>{R.thinkingStyle.phases=v}),w(!1),E("")}else A.escape?(E(""),w(!1),k(!1)):A.backspace||A.delete?E(v=>v.slice(0,-1)):$&&E(v=>v+$);return}if(A.escape)e();else if(A.return)if(d==="updateInterval")j(n.toString()),O(!0);else if(d==="presets"){const v=_e[y];i(R=>{R.thinkingStyle.phases=[...v.phases],R.thinkingStyle.reverseMirror=v.reverseMirror})}else d==="reverseMirror"&&i(v=>{v.thinkingStyle.reverseMirror=!v.thinkingStyle.reverseMirror});else if(A.tab)A.shift?u(v=>v===0?a.length-1:v-1):u(v=>v===a.length-1?0:v+1);else if(A.upArrow)d==="phases"&&t.length>0?f(v=>v>0?v-1:t.length-1):d==="presets"&&b(v=>v>0?v-1:_e.length-1);else if(A.downArrow)d==="phases"&&t.length>0?f(v=>v<t.length-1?v+1:0):d==="presets"&&b(v=>v<_e.length-1?v+1:0);else if($===" ")d==="reverseMirror"&&i(v=>{v.thinkingStyle.reverseMirror=!v.thinkingStyle.reverseMirror});else if($==="e"&&d==="phases")t.length>0&&(E(t[h]),w(!0));else if($==="a"&&d==="phases")k(!0),E("");else if($==="d"&&d==="phases")t.length>1&&(i(v=>{v.thinkingStyle.phases=t.filter((R,K)=>K!==h)}),h>=t.length&&f(Math.max(0,t.length-1)));else if($==="w"&&d==="phases"){if(h>0){const v=[...t];[v[h-1],v[h]]=[v[h],v[h-1]],i(R=>{R.thinkingStyle.phases=v}),f(R=>R-1)}}else if($==="s"&&d==="phases"){if(h<t.length-1){const v=[...t];[v[h],v[h+1]]=[v[h+1],v[h]],i(R=>{R.thinkingStyle.phases=v}),f(R=>R+1)}}else A.ctrl&&$==="r"&&(i(v=>{v.thinkingStyle=ee.thinkingStyle}),f(0),b(0))});const W=o?"●":"○",Q=50,C=o?[...t,...[...t].reverse().slice(1,-1)]:t,_=C.length>0?C[L]:"·";return s(m,{children:g(m,{flexDirection:"column",width:"100%",children:[g(m,{flexDirection:"row",width:"100%",children:[g(m,{marginBottom:1,flexDirection:"column",width:`${100-Q}%`,children:[s(pe,{children:"Thinking style"}),g(m,{flexDirection:"column",children:[g(c,{dimColor:!0,children:["enter to"," ",d==="updateInterval"?"edit interval":d==="presets"?"apply preset":"save"]}),s(c,{dimColor:!0,children:"esc to go back"}),s(c,{dimColor:!0,children:"tab to switch sections"})]})]}),g(m,{width:`${Q}%`,flexDirection:"column",children:[s(m,{children:s(c,{bold:!0,children:"Preview"})}),g(m,{borderStyle:"single",borderColor:"gray",paddingX:1,flexDirection:"row",children:[s(m,{width:(_?.length??0)+1,children:s(c,{color:z,children:_})}),g(c,{children:[s(c,{color:z,children:"Thinking… "}),s(c,{children:"(esc to interrupt)"})]})]})]})]}),g(m,{flexDirection:"row",gap:4,children:[g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:d==="reverseMirror"?"yellow":void 0,children:d==="reverseMirror"?"❯ ":" "}),s(c,{bold:!0,color:d==="reverseMirror"?"yellow":void 0,children:"Reverse-mirror phases"})]}),d==="reverseMirror"&&g(c,{dimColor:!0,children:[" ","space to toggle"]}),s(m,{marginLeft:2,marginBottom:1,children:g(c,{children:[W," ",o?"Enabled":"Disabled"]})})]}),g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:d==="updateInterval"?"yellow":void 0,children:d==="updateInterval"?"❯ ":" "}),s(c,{bold:!0,color:d==="updateInterval"?"yellow":void 0,children:"Update interval (ms)"})]}),d==="updateInterval"&&(D?g(c,{dimColor:!0,children:[" ","enter to save"]}):g(c,{dimColor:!0,children:[" ","enter to edit"]})),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:D?"yellow":"gray",children:s(c,{children:D?N:n})})})]})]}),s(m,{children:g(c,{children:[s(c,{color:d==="phases"?"yellow":void 0,children:d==="phases"?"❯ ":" "}),s(c,{bold:!0,color:d==="phases"?"yellow":void 0,children:"Phases"})]})}),d==="phases"&&s(m,{marginBottom:1,flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","[e]dit"," ","[a]dd"," ","[d]elete"," ","[w]move up"," ","[s]move down"]})}),s(m,{marginLeft:2,marginBottom:1,children:g(m,{flexDirection:"column",children:[(()=>{const A=Math.max(0,h-Math.floor(4)),v=Math.min(t.length,A+8),R=Math.max(0,v-8),K=t.slice(R,v);return g(me,{children:[R>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",R," more above"]}),K.map((J,te)=>{const se=R+te;return g(c,{color:d==="phases"&&se===h?"cyan":void 0,children:[d==="phases"&&se===h?"❯ ":" ",J]},se)}),v<t.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",t.length-v," more below"]})]})})(),x&&g(m,{children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:S})})]}),p&&g(m,{marginTop:1,children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:S})})]})]})}),s(m,{children:g(c,{children:[s(c,{color:d==="presets"?"yellow":void 0,children:d==="presets"?"❯ ":" "}),s(c,{bold:!0,color:d==="presets"?"yellow":void 0,children:"Presets"})]})}),d==="presets"&&g(c,{dimColor:!0,children:[" ","Selecting one will overwrite your choice of phases"]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{flexDirection:"column",children:(()=>{const A=Math.max(0,y-Math.floor(4)),v=Math.min(_e.length,A+8),R=Math.max(0,v-8),K=_e.slice(R,v);return g(me,{children:[R>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",R," more above"]}),K.map((J,te)=>{const se=R+te;return g(c,{color:d==="presets"&&se===y?"cyan":void 0,children:[d==="presets"&&se===y?"❯ ":" ",J.name," ",J.phases.join("")]},se)}),v<_e.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",_e.length-v," more below"]})]})})()})}),s(m,{marginTop:1,children:s(c,{dimColor:!0,children:"ctrl+r to reset all settings to default"})})]})})}const De=[{label:"bold",value:"bold"},{label:"italic",value:"italic"},{label:"underline",value:"underline"},{label:"strikethrough",value:"strikethrough"},{label:"inverse",value:"inverse"}];function Fr({onBack:e}){const{settings:t,updateSettings:n}=be(ue),[o,r]=P("prefix"),[i,a]=P(0),[l,u]=P(!1),[d,h]=P(()=>t.userMessageDisplay.prefix.format),[f,y]=P(0),[b,p]=P(()=>[...t.userMessageDisplay.prefix.styling]),[w,S]=P(()=>t.userMessageDisplay.prefix.foreground_color),[E,x]=P(()=>t.userMessageDisplay.prefix.background_color),[k,D]=P(0),[O,N]=P(0),[j,L]=P(()=>[...t.userMessageDisplay.message.styling]),[B,T]=P(()=>t.userMessageDisplay.message.foreground_color),[I,z]=P(()=>t.userMessageDisplay.message.background_color),[W,Q]=P(null),[q,C]=P(""),_=Ke(),$=t.themes?.find(Y=>Y.id===_)||t.themes?.[0],A=["format","styling","foreground","background"],v=["styling","foreground","background"],R=A[i],K=v[k],J=(Y,V)=>{n(F=>{const ne=Y==="prefix"?F.userMessageDisplay.prefix:F.userMessageDisplay.message;V(ne)})},te=Y=>{n(V=>{Y==="prefix"?V.userMessageDisplay.prefix={...ee.userMessageDisplay.prefix}:V.userMessageDisplay.message={...ee.userMessageDisplay.message}}),Y==="prefix"?(h(ee.userMessageDisplay.prefix.format),p([...ee.userMessageDisplay.prefix.styling]),S(ee.userMessageDisplay.prefix.foreground_color),x(ee.userMessageDisplay.prefix.background_color)):(L([...ee.userMessageDisplay.message.styling]),T(ee.userMessageDisplay.message.foreground_color),z(ee.userMessageDisplay.message.background_color))};xe(()=>{const Y=t.userMessageDisplay.prefix;h(Y.format),p([...Y.styling]),S(Y.foreground_color),x(Y.background_color);const V=t.userMessageDisplay.message;L([...V.styling]),T(V.foreground_color),z(V.background_color)},[]),de((Y,V)=>{if(l){if(V.return)J("prefix",F=>{F.format=d}),u(!1);else if(V.escape){const F=t.userMessageDisplay.prefix;h(F.format),u(!1)}else V.backspace||V.delete?h(F=>F.slice(0,-1)):Y&&h(F=>F+Y);return}if(W===null){if(V.escape)e();else if(V.ctrl&&Y==="r")te(o);else if(V.leftArrow||V.rightArrow)r(F=>F==="prefix"?"message":"prefix");else if(V.tab)o==="prefix"?V.shift?a(F=>F===0?A.length-1:F-1):a(F=>F===A.length-1?0:F+1):V.shift?D(F=>F===0?v.length-1:F-1):D(F=>F===v.length-1?0:F+1);else if(V.return)o==="prefix"?R==="format"?u(!0):R==="foreground"?(C(w),Q({column:"prefix",type:"foreground"})):R==="background"&&(C(E),Q({column:"prefix",type:"background"})):K==="foreground"?(C(B),Q({column:"message",type:"foreground"})):K==="background"&&(C(I),Q({column:"message",type:"background"}));else if(V.upArrow)o==="prefix"&&R==="styling"?y(F=>Math.max(0,F-1)):o==="message"&&K==="styling"&&N(F=>Math.max(0,F-1));else if(V.downArrow)o==="prefix"&&R==="styling"?y(F=>Math.min(De.length-1,F+1)):o==="message"&&K==="styling"&&N(F=>Math.min(De.length-1,F+1));else if(Y===" "){if(o==="prefix"&&R==="styling"){const F=De[f].value,ne=b.indexOf(F)>=0?b.filter(X=>X!==F):[...b,F];p(ne),J("prefix",X=>{X.styling=[...ne]})}else if(o==="message"&&K==="styling"){const F=De[O].value,ne=j.indexOf(F)>=0?j.filter(X=>X!==F):[...j,F];L(ne),J("message",X=>{X.styling=[...ne]})}}}});const se=(Y,V,F=!0)=>{const ne=F?V==="prefix"?b:j:[],X=F?V==="prefix"?w:B:"rgb(255,255,255)",Ae=F?V==="prefix"?E:I:"rgb(0,0,0)",Pe=X==="rgb(0,0,0)"&&Ae==="rgb(0,0,0)",Ue=ne.length>0;return Pe&&!Ue?s(c,{children:Y}):s(c,{bold:ne.includes("bold"),italic:ne.includes("italic"),underline:ne.includes("underline"),strikethrough:ne.includes("strikethrough"),inverse:ne.includes("inverse"),color:Pe?void 0:X,backgroundColor:Pe?void 0:Ae,children:Y})},$e=(Y=!0)=>g(c,{children:[d&&g(me,{children:[se(d,"prefix",Y)," "]}),se("list the dir","message",Y)]}),we=Y=>{const V=o===Y,X=(Y==="prefix"?A:v)[Y==="prefix"?i:k],Ae=Y==="prefix"?f:O,Pe=Y==="prefix"?b:j,Ue=Y==="prefix"?w:B,mn=Y==="prefix"?E:I;return g(m,{flexDirection:"column",width:"45%",borderStyle:V?"round":"single",borderColor:V?"yellow":"gray",padding:1,children:[s(m,{marginBottom:1,children:g(c,{bold:!0,color:V?"yellow":void 0,children:[Y.charAt(0).toUpperCase()+Y.slice(1)," ","Configuration"]})}),Y==="prefix"&&g(me,{children:[s(m,{children:g(c,{color:V&&X==="format"?"yellow":void 0,bold:V&&X==="format",children:[V&&X==="format"?"❯ ":" ","Prefix Text"]})}),V&&X==="format"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:l?"enter to save":"enter to edit (appears before message)"})}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:l?"yellow":"gray",children:s(c,{children:d})})})]}),s(m,{children:g(c,{color:V&&X==="styling"?"yellow":void 0,bold:V&&X==="styling",children:[V&&X==="styling"?"❯ ":" ","Styling"]})}),V&&X==="styling"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"up/down to navigate · space to toggle"})}),s(m,{marginLeft:2,marginBottom:1,flexDirection:"column",children:De.map((Xe,pn)=>s(m,{children:g(c,{color:V&&X==="styling"&&Ae===pn?"cyan":void 0,children:[V&&X==="styling"&&Ae===pn?"❯ ":" ",Pe.includes(Xe.value)?"●":"○"," ",Xe.label]})},Xe.value))}),s(m,{children:g(c,{color:V&&X==="foreground"?"yellow":void 0,bold:V&&X==="foreground",children:[V&&X==="foreground"?"❯ ":" ","Foreground color"]})}),V&&X==="foreground"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,marginBottom:1,children:s(c,{color:Ue,children:Ue})}),s(m,{children:g(c,{color:V&&X==="background"?"yellow":void 0,bold:V&&X==="background",children:[V&&X==="background"?"❯ ":" ","Background color"]})}),V&&X==="background"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,children:s(c,{backgroundColor:mn,children:mn})})]})};if(W){const{column:Y,type:V}=W;return s(at,{initialValue:q,theme:$,onColorChange:F=>{Y==="prefix"?V==="foreground"?(S(F),J("prefix",ne=>{ne.foreground_color=F})):(x(F),J("prefix",ne=>{ne.background_color=F})):V==="foreground"?(T(F),J("message",ne=>{ne.foreground_color=F})):(z(F),J("message",ne=>{ne.background_color=F}))},onExit:()=>{Q(null),C("")}})}return g(m,{flexDirection:"column",children:[s(pe,{children:"Customize how user messages are displayed"}),g(m,{flexDirection:"column",marginBottom:1,children:[s(c,{dimColor:!0,children:"left/right arrows to switch columns · tab to navigate options"}),s(c,{dimColor:!0,children:"enter to edit · ctrl+r to reset active column · esc to go back"})]}),g(m,{flexDirection:"row",gap:1,children:[we("prefix"),we("message")]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(c,{bold:!0,children:"Preview"})}),g(m,{flexDirection:"row",gap:2,children:[g(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(c,{underline:!0,children:"Before (Claude Code default):"})}),s(m,{marginLeft:1,marginTop:1,children:g(c,{children:[s(c,{color:$?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:$?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]}),g(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(c,{underline:!0,children:"After (Your customization):"})}),s(m,{marginLeft:1,children:$e(!0)}),s(m,{marginLeft:1,marginTop:1,children:g(c,{children:[s(c,{color:$?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:$?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]})]})]})})]})}function Vr({onSubmit:e}){const{settings:t,updateSettings:n}=be(ue),[o,r]=P(0),i=()=>{n(b=>{b.inputBox||(b.inputBox={removeBorder:!1}),b.inputBox.removeBorder=!b.inputBox.removeBorder})},a=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showTweakccVersion=!b.misc.showTweakccVersion})},l=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showPatchesApplied=!b.misc.showPatchesApplied})},u=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.expandThinkingBlocks=!b.misc.expandThinkingBlocks})};de((b,p)=>{p.return||p.escape?e():p.upArrow?r(w=>Math.max(0,w-1)):p.downArrow?r(w=>Math.min(3,w+1)):b===" "&&(o===0?i():o===1?a():o===2?l():o===3&&u())});const d=t.inputBox?.removeBorder?"☑":"☐",h=t.misc?.showTweakccVersion?"☑":"☐",f=t.misc?.showPatchesApplied?"☑":"☐",y=t.misc?.expandThinkingBlocks?"☑":"☐";return g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(pe,{children:"Miscellaneous Settings"})}),s(m,{marginBottom:1,children:s(c,{color:"gray",children:s(c,{dimColor:!0,children:"Various tweaks and customizations. Press space to toggle settings, enter to go back."})})}),s(m,{children:g(c,{children:[s(c,{color:o===0?"cyan":void 0,children:o===0?"❯ ":" "}),s(c,{bold:!0,color:o===0?"cyan":void 0,children:"Remove input box border"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","Removes the rounded border around the input box for a cleaner look."]})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[d," ",t.inputBox?.removeBorder?"Enabled":"Disabled"]})}),s(m,{children:g(c,{children:[s(c,{color:o===1?"cyan":void 0,children:o===1?"❯ ":" "}),s(c,{bold:!0,color:o===1?"cyan":void 0,children:"Show tweakcc version at startup"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ",'Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.']})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[h," ",t.misc?.showTweakccVersion?"Enabled":"Disabled"]})}),s(m,{children:g(c,{children:[s(c,{color:o===2?"cyan":void 0,children:o===2?"❯ ":" "}),s(c,{bold:!0,color:o===2?"cyan":void 0,children:"Show patches applied indicator at startup"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ",'Shows the green "tweakcc patches are applied" indicator when starting Claude Code.']})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[f," ",t.misc?.showPatchesApplied?"Enabled":"Disabled"]})}),s(m,{children:g(c,{children:[s(c,{color:o===3?"cyan":void 0,children:o===3?"❯ ":" "}),s(c,{bold:!0,color:o===3?"cyan":void 0,children:"Expand thinking blocks"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","Makes thinking blocks always expanded by default instead of collapsed."]})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[y," ",t.misc?.expandThinkingBlocks?"Enabled":"Disabled"]})})]})}const He=["Task","Bash","Glob","Grep","Read","Edit","Write","NotebookEdit","WebFetch","WebSearch","BashOutput","KillShell","TodoWrite","AskUserQuestion","Skill","SlashCommand","ExitPlanMode"];function jr({toolsetIndex:e,onBack:t}){const{settings:n,updateSettings:o}=be(ue),r=n.toolsets[e],[i,a]=P(r?.name||"New Toolset"),[l,u]=P(r?.allowedTools||[]),[d,h]=P(!1),[f,y]=P(0);xe(()=>{r&&o(E=>{const x=E.toolsets[e].name;E.toolsets[e].name=i,E.toolsets[e].allowedTools=l,x!==i&&(E.defaultToolset===x&&(E.defaultToolset=i),E.planModeToolset===x&&(E.planModeToolset=i))})},[i,l]);const b=E=>l==="*"?!0:l.includes(E),p=E=>{E==="All"?u("*"):E==="None"?u([]):l==="*"?u(He.filter(x=>x!==E)):l.includes(E)?u(l.filter(x=>x!==E)):u([...l,E])};if(de((E,x)=>{if(d){x.return?h(!1):x.escape?(a(r?.name||"New Toolset"),h(!1)):x.backspace||x.delete?a(k=>k.slice(0,-1)):E&&E.length===1&&a(k=>k+E);return}if(x.escape)t();else if(x.upArrow)y(k=>Math.max(0,k-1));else if(x.downArrow)y(k=>Math.min(He.length+1,k+1));else if(E===" "||x.return)if(f===0)p("All");else if(f===1)p("None");else{const k=He[f-2];k&&p(k)}else E==="n"&&h(!0)}),!r)return s(m,{flexDirection:"column",children:s(c,{color:"red",children:"Toolset not found"})});const w=l==="*",S=Array.isArray(l)&&l.length===0;return g(m,{flexDirection:"column",children:[s(pe,{children:"Edit Toolset"}),s(m,{marginBottom:1,flexDirection:"column",children:s(c,{dimColor:!0,children:"n to edit name · space/enter to toggle · esc to go back"})}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{bold:!0,children:"Name:"}),s(m,{marginLeft:2,children:s(m,{borderStyle:"round",borderColor:d?"yellow":"gray",children:s(c,{children:i})})}),d&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to save · esc to cancel"})})]}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{bold:!0,children:"Allowed Tools:"}),s(m,{marginLeft:2,children:g(c,{color:f===0?"cyan":void 0,children:[f===0?"❯ ":" ",w?"●":"○"," All"]})}),s(m,{marginLeft:2,children:g(c,{color:f===1?"cyan":void 0,children:[f===1?"❯ ":" ",S?"●":"○"," None"]})}),He.map((E,x)=>{const k=x+2;return s(m,{marginLeft:2,children:g(c,{color:f===k?"cyan":void 0,children:[f===k?"❯ ":" ",b(E)?"◉":"○"," ",E]})},E)})]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:g(m,{flexDirection:"column",children:[s(c,{bold:!0,children:"Summary:"}),g(c,{children:["Name: ",s(c,{color:"cyan",children:i})]}),g(c,{children:["Tools:"," ",l==="*"?s(c,{color:"green",children:"All tools (*)"}):l.length===0?s(c,{color:"red",children:"No tools ([])"}):g(c,{color:"yellow",children:[l.length," selected"]})]})]})})]})}function Ur({onBack:e}){const{settings:{toolsets:t,defaultToolset:n,planModeToolset:o,themes:r},updateSettings:i}=be(ue),a=Ke(),l=r.find(N=>N.id===a)||r[0],u=ee.themes[0],d=l?.colors.planMode||u.colors.planMode,h=l?.colors.autoAccept||u.colors.autoAccept,[f,y]=P(0),[b,p]=P(null),[w,S]=P(!0),E=()=>{const N={name:"New Toolset",allowedTools:[]};i(j=>{j.toolsets.push(N)}),p(t.length),S(!1)},x=N=>{const j=t[N];i(L=>{L.toolsets.splice(N,1),L.defaultToolset===j.name&&(L.defaultToolset=null),L.planModeToolset===j.name&&(L.planModeToolset=null)}),f>=t.length-1&&y(Math.max(0,t.length-2))},k=N=>{const j=t[N];i(L=>{L.defaultToolset=j.name})},D=N=>{const j=t[N];i(L=>{L.planModeToolset=j.name})};if(de((N,j)=>{j.escape?e():j.upArrow?y(L=>Math.max(0,L-1)):j.downArrow?y(L=>Math.min(t.length-1,L+1)):j.return&&t.length>0?(p(f),S(!1)):N==="n"?E():N==="x"&&t.length>0?x(f):N==="d"&&t.length>0?k(f):N==="p"&&t.length>0&&D(f)},{isActive:w}),b!==null)return s(jr,{toolsetIndex:b,onBack:()=>{p(null),S(!0)}});const O=N=>N.allowedTools==="*"?"All tools":N.allowedTools.length===0?"No tools":`${N.allowedTools.length} tool${N.allowedTools.length===1?"":"s"}`;return g(m,{flexDirection:"column",children:[s(pe,{children:"Toolsets"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new toolset"}),t.length>0&&s(c,{dimColor:!0,children:"d to set as default toolset"}),t.length>0&&s(c,{dimColor:!0,children:"p to set as plan mode toolset"}),t.length>0&&s(c,{dimColor:!0,children:"x to delete a toolset"}),t.length>0&&s(c,{dimColor:!0,children:"enter to edit toolset"}),s(c,{dimColor:!0,children:"esc to go back"})]}),t.length===0?s(c,{children:"No toolsets created yet. Press n to create one."}):s(m,{flexDirection:"column",children:t.map((N,j)=>{const L=N.name===n,B=N.name===o,T=f===j;let I;return T&&(I="yellow"),g(m,{flexDirection:"row",children:[g(c,{color:I,children:[T?"❯ ":" ",N.name," "]}),g(c,{color:I,children:["(",O(N),")"]}),L&&s(c,{color:h,children:" ⏵⏵ accept edits"}),B&&s(c,{color:d,children:" ⏸ plan mode"})]},j)})})]})}const ue=ut({settings:ee,updateSettings:e=>{},changesApplied:!1,ccVersion:""});function Hr({startupCheckInfo:e}){const[t,n]=P({settings:ee,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null});xe(()=>{(async()=>{n(await dn())})()},[]);const o=Nn(h=>{const f=JSON.parse(JSON.stringify(t.settings));h(f),n(y=>({...y,settings:f,changesApplied:!1})),je(y=>{y.settings=f,y.changesApplied=!1})},[t.settings]),[r,i]=P(null),[a,l]=P(null);xe(()=>{e.wasUpdated&&e.oldVersion&&(l({message:`Your Claude Code installation was updated from ${e.oldVersion} to ${e.newVersion}, and the patching was likely overwritten
|
|
648
648
|
(However, your customization are still remembered in ${ae}.)
|
|
649
|
-
Please reapply your changes below.`,type:"warning"}),o(()=>{}))},[]),de((h,f)=>{(f.ctrl&&h==="c"||(h==="q"||f.escape)&&!r)&&process.exit(0)},{isActive:!r});const u=h=>{switch(l(null),h){case Z.APPLY_CHANGES:e.ccInstInfo&&(l({message:"Applying patches...",type:"info"}),ot(t,e.ccInstInfo).then(f=>{n(f),l({message:"Customization patches applied successfully!",type:"success"})}));break;case Z.THEMES:case Z.THINKING_VERBS:case Z.THINKING_STYLE:case Z.USER_MESSAGE_DISPLAY:case Z.MISC:case Z.TOOLSETS:i(h);break;case Z.VIEW_SYSTEM_PROMPTS:Mr(Se);break;case Z.RESTORE_ORIGINAL:e.ccInstInfo&&(e.ccInstInfo.nativeInstallationPath?qn(e.ccInstInfo):Jn(e.ccInstInfo)).then(()=>{l({message:"Original Claude Code restored successfully!",type:"success"}),o(()=>{})});break;case Z.OPEN_CONFIG:kn(ae);break;case Z.OPEN_CLI:e.ccInstInfo?.cliPath&&kn(e.ccInstInfo.cliPath);break;case Z.EXIT:process.exit(0)}},d=()=>{i(null)};return s(ue.Provider,{value:{settings:t.settings,updateSettings:o,changesApplied:t.changesApplied,ccVersion:e.ccInstInfo?.version||""},children:s(m,{flexDirection:"column",children:r===null?s(yt,{onSubmit:u,notification:a,isNativeInstallation:!!e.ccInstInfo?.nativeInstallationPath}):r===Z.THEMES?s(Lr,{onBack:d}):r===Z.THINKING_VERBS?s(Dr,{onBack:d}):r===Z.THINKING_STYLE?s(Rr,{onBack:d}):r===Z.USER_MESSAGE_DISPLAY?s(Fr,{onBack:d}):r===Z.MISC?s(Vr,{onSubmit:d}):r===Z.TOOLSETS?s(Ur,{onBack:d}):null})})}const Mn=async e=>{try{await ie.mkdir(ce,{recursive:!0});try{await ie.stat(ae)}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT"){const n={ccInstallationDir:e};await ie.writeFile(ae,JSON.stringify(n,null,2))}}}catch{}},Gr=async()=>{const e=new dt;e.name("tweakcc").description("Command-line tool to customize your Claude Code theme colors, thinking verbs and more.").version("3.1.
|
|
649
|
+
Please reapply your changes below.`,type:"warning"}),o(()=>{}))},[]),de((h,f)=>{(f.ctrl&&h==="c"||(h==="q"||f.escape)&&!r)&&process.exit(0)},{isActive:!r});const u=h=>{switch(l(null),h){case Z.APPLY_CHANGES:e.ccInstInfo&&(l({message:"Applying patches...",type:"info"}),ot(t,e.ccInstInfo).then(f=>{n(f),l({message:"Customization patches applied successfully!",type:"success"})}));break;case Z.THEMES:case Z.THINKING_VERBS:case Z.THINKING_STYLE:case Z.USER_MESSAGE_DISPLAY:case Z.MISC:case Z.TOOLSETS:i(h);break;case Z.VIEW_SYSTEM_PROMPTS:Mr(Se);break;case Z.RESTORE_ORIGINAL:e.ccInstInfo&&(e.ccInstInfo.nativeInstallationPath?qn(e.ccInstInfo):Jn(e.ccInstInfo)).then(()=>{l({message:"Original Claude Code restored successfully!",type:"success"}),o(()=>{})});break;case Z.OPEN_CONFIG:kn(ae);break;case Z.OPEN_CLI:e.ccInstInfo?.cliPath&&kn(e.ccInstInfo.cliPath);break;case Z.EXIT:process.exit(0)}},d=()=>{i(null)};return s(ue.Provider,{value:{settings:t.settings,updateSettings:o,changesApplied:t.changesApplied,ccVersion:e.ccInstInfo?.version||""},children:s(m,{flexDirection:"column",children:r===null?s(yt,{onSubmit:u,notification:a,isNativeInstallation:!!e.ccInstInfo?.nativeInstallationPath}):r===Z.THEMES?s(Lr,{onBack:d}):r===Z.THINKING_VERBS?s(Dr,{onBack:d}):r===Z.THINKING_STYLE?s(Rr,{onBack:d}):r===Z.USER_MESSAGE_DISPLAY?s(Fr,{onBack:d}):r===Z.MISC?s(Vr,{onSubmit:d}):r===Z.TOOLSETS?s(Ur,{onBack:d}):null})})}const Mn=async e=>{try{await ie.mkdir(ce,{recursive:!0});try{await ie.stat(ae)}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT"){const n={ccInstallationDir:e};await ie.writeFile(ae,JSON.stringify(n,null,2))}}}catch{}},Gr=async()=>{const e=new dt;e.name("tweakcc").description("Command-line tool to customize your Claude Code theme colors, thinking verbs and more.").version("3.1.5").option("-d, --debug","enable debug mode").option("-a, --apply","apply saved customizations without interactive UI"),e.parse();const t=e.opts();if(t.debug&&Er(),t.apply){console.log("Applying saved customizations to Claude Code..."),console.log(`Configuration saved at: ${ae}`);const o=await dn();(!o.settings||Object.keys(o.settings).length===0)&&(console.error("No saved customizations found in "+ae),process.exit(1));const r=await En();if(!r||!r.ccInstInfo){const a=process.platform=="win32"?"C:\\absolute\\path\\to\\node_modules\\@anthropic-ai\\claude-code":"/absolute/path/to/node_modules/@anthropic-ai/claude-code";await Mn(a),console.error("Cannot find Claude Code's cli.js"),console.error("Searched for cli.js at the following locations:"),tn.forEach(l=>{l.isGlob?l.expandedPaths.length===0?console.error(` - ${l.pattern} (no matches)`):(console.error(` - ${l.pattern}`),l.expandedPaths.forEach(u=>{console.error(` - ${u}`)})):console.error(` - ${l.pattern}`)}),console.error(`
|
|
650
650
|
Also checked for 'claude' executable on PATH using '${process.platform==="win32"?"where claude.exe":"which claude"}'.`),process.exit(1)}r.ccInstInfo.nativeInstallationPath?console.log(`Found Claude Code (native installation): ${r.ccInstInfo.nativeInstallationPath}`):console.log(`Found Claude Code at: ${r.ccInstInfo.cliPath}`),console.log(`Version: ${r.ccInstInfo.version}`),console.log("Loading system prompts...");const i=await _n(r.ccInstInfo.version);i.success||(console.log(H.red(`
|
|
651
651
|
✖ Error downloading system prompts:`)),console.log(H.red(` ${i.errorMessage}`)),console.log(H.yellow(`
|
|
652
652
|
⚠ System prompts not available - skipping system prompt customizations`))),console.log("Applying customizations..."),await ot(o,r.ccInstInfo),console.log("Customizations applied successfully!"),process.exit(0)}const n=await En();if(n){const o=await _n(n.ccInstInfo.version);o.success||(console.log(H.red(`
|