import{b as i}from"./vendor-lit-BtHfzs80.js";import{au as m,aw as y}from"./index-rvuS68Al.js";import{p as g,a as b}from"./proposal-rev-marker-BsTX0uwt.js";import{p as $}from"./vendor-lucide-DBEJLfdn.js";import"./vendor-mini-lit-Cx886NBU.js";import"./vendor-marked-_iteVaMm.js";import"./vendor-sortable-B1o3v0Qs.js";function w(t){if(!t)return null;if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t;if(typeof t=="string")try{return JSON.parse(t)}catch{return null}return null}function d(t,n=120){return t?t.length>n?t.slice(0,n)+"…":t:""}class _{render(n,r,l){const c=m(r,l),o=w(n)||{},s=typeof o.type=="string"?o.type:"",u=typeof o.old_text=="string"?o.old_text:"",f=typeof o.new_text=="string"?o.new_text:"",e=g(r),p=b(r),v=!!r?.isError||r!==void 0&&e===void 0,x=a=>{a.preventDefault(),a.stopPropagation(),!(typeof e!="number"||e<=0||!s)&&document.dispatchEvent(new CustomEvent("proposal-open",{detail:{type:s,rev:e}}))};return{content:i`
				<div class="space-y-2">
					${y(c,$,s?`Edit ${s} draft`:"Edit draft")}
					<div class="text-xs space-y-1 font-mono whitespace-pre-wrap break-words">
						<div><span class="text-red-500">\u2212</span> ${d(u,120)}</div>
						<div><span class="text-green-500">+</span> ${d(f,120)}</div>
					</div>
					${typeof e=="number"&&e>0?i`
						<div class="text-xs text-muted-foreground" data-testid="proposal-rev">rev ${e}</div>
					`:""}
					${v&&p?i`
						<div class="text-xs text-red-500" data-testid="edit-proposal-error-code">${p}</div>
					`:""}
					${r&&typeof e=="number"&&e>0?i`
						<div class="flex justify-end">
							<button
								@click=${x}
								class="inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded bg-primary/10 text-primary hover:bg-primary/20 transition-colors cursor-pointer"
								data-testid="proposal-open-button"
							>
								Open proposal
							</button>
						</div>
					`:""}
				</div>
			`,isCustom:!1}}}export{_ as EditProposalRenderer};
