import{b as c}from"./vendor-lit-BtHfzs80.js";import{a as w}from"./vendor-mini-lit-Cx886NBU.js";import{ay as h,au as m,aw as g}from"./index-rvuS68Al.js";import{aF as l}from"./vendor-lucide-DBEJLfdn.js";import"./vendor-marked-_iteVaMm.js";import"./vendor-sortable-B1o3v0Qs.js";function u(s){return s&&s.content?.filter(e=>e.type==="text").map(e=>e.text).join(`
`)||""}function A(s){if(!s||s.isError)return!1;const e=u(s);if(!e)return!1;try{const r=JSON.parse(e);return r&&typeof r=="object"&&r.status==="posted"}catch{return!1}}function v(s){if(!s||s.isError)return null;const e=u(s);if(!e)return null;try{const r=JSON.parse(e);if(r&&Array.isArray(r.answers))return r.answers.every(t=>t&&typeof t=="object"&&typeof t.question=="string"&&(typeof t.selected=="string"||Array.isArray(t.selected)&&t.selected.every(n=>typeof n=="string"))&&(t.other_text===null||typeof t.other_text=="string"))?r.answers:null}catch{}return null}function k(s){return u(s)||"ask_user_choices failed."}function p(s,e){return s!=="inprogress"?g(s,l,e):c`
		<div class="flex items-center justify-between gap-2 text-sm text-muted-foreground">
			<div class="flex items-center gap-2">
				<span class="inline-block text-foreground">${w(l,"sm")}</span>
				${e}
			</div>
			<span
				class="inline-block h-2.5 w-2.5 rounded-full bg-foreground ask-heartbeat"
				aria-label="Waiting for your answer"
				title="Waiting for your answer"
			></span>
		</div>
	`}class T{render(e,r,d,t){h();const n=m(r,d);if(!e||!Array.isArray(e.questions)||e.questions.length===0)return{content:c`<div>${p(n,"Preparing questions…")}</div>`,isCustom:!1};const o=A(r),y=o&&t?.toolUseId&&t?.getAskResponseAnswers?t.getAskResponseAnswers(t.toolUseId):null,f=o?null:v(r),a=y??f,i=!!r?.isError||n!=="inprogress"&&!!r&&!o&&!f;return{content:c`
				<div class="space-y-2">
					${(n==="inprogress"||o&&!a&&!i)&&!a&&!i?p("inprogress","Multiple-choice question"):g(n,l,"Multiple-choice question")}
					<ask-user-choices-widget
						.questions=${e.questions}
						.answers=${a}
						.sessionId=${t?.sessionId??""}
						.toolUseId=${t?.toolUseId??""}
						.errored=${i}
						.errorText=${i?k(r):""}
					></ask-user-choices-widget>
				</div>`,isCustom:!1}}}export{T as AskUserChoicesRenderer};
