/* esm.sh - @assistant-ui/core@0.3.31/dist/runtime/base/default-edit-composer-runtime-core */
import{liftNonTextParts as u}from"../../adapters/attachment.mjs";import{getThreadMessageText as l}from"../../utils/text.mjs";import{BaseComposerRuntimeCore as h}from"./base-composer-runtime-core.mjs";var f=class extends h{get canCancel(){return!0}get detachesDraftOnSend(){return!1}get cleanupOwner(){return this.runtime.composer instanceof h?this.runtime.composer:this}get canSend(){return!this.runtime.isDisabled&&!this.isEmpty&&!this.runtime.voice&&!this.isSubmitting}addAttachment(t){return this.runtime.isDisabled?Promise.resolve():super.addAttachment(t)}startDictation(){this.runtime.isDisabled||super.startDictation()}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextPassthrough;_parentId;_sourceId;runtime;endEditCallback;_ended=!1;constructor(t,n,{parentId:i,message:e}){super(),this.runtime=t;let a=t.voice!==void 0,o=t.isDisabled,d=t.subscribe(()=>{let s=t.voice!==void 0,c=t.isDisabled;s===a&&c===o||(a=s,o=c,this._notifySubscribers())});this.endEditCallback=()=>{d(),n()},this._parentId=i,this._sourceId=e.id,this.setText(l(e)),this.setRole(e.role);let r;e.role==="user"?(r=[...e.attachments??[],...u(e.content)],this._nonTextPassthrough=[]):(r=e.attachments??[],this._nonTextPassthrough=e.content.filter(s=>s.type!=="text")),this.setAttachments(r),this.setQuote(e.metadata.custom.quote),this.setRunConfig({...t.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(t,n){let i=this._nonTextPassthrough.length>0?[...t.content,...this._nonTextPassthrough]:t.content,e=this.runtime.append({...t,content:i,parentId:this._parentId,sourceId:this._sourceId,startRun:n?.startRun});return this.handleCancel(),e}handleCancel(){this._ended||(this._ended=!0,this.reset().catch(t=>{console.error("[assistant-ui] Failed to clear cancelled edit",t)}),this.endEditCallback(),this._notifySubscribers())}};export{f as DefaultEditComposerRuntimeCore};
//# sourceMappingURL=default-edit-composer-runtime-core.mjs.map