import { f as fallback } from './async-D55cHugf.js';
import { f as attr_class, e as ensure_array_like, g as attr_style, i as stringify, a as attr, d as bind_props, c as spread_props } from './index-u8mz_F03.js';
import './2-BLdXJizP.js';
import { $ } from './utils.svelte-B2py64Fz.js';
import { c } from './BlockTitle-BnJIYf6a.js';
import { w } from './IconButton-BRnu7KaR.js';
import { e as e$1 } from './Check-C7_ZsXgh.js';
import { h } from './Copy-B8YOhH7c.js';
import { M } from './Send-C1RPCeF6.js';
import { r } from './Trash-DLGOAhrN.js';
import { y } from './IconButtonWrapper-CjFRPb3y.js';
import { S } from './Dropdown-D-In1KD6.js';
import { G } from './Block-DZmzQwnI.js';
import { W } from './index3-Df92vI-L.js';
export { default as BaseExample } from './Example15-OgTyyC0U.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import './context-CBkBucIx.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';
import './index-Cg-Pg6j3.js';
import './clone-Yk88IHKV.js';
import './Info-DU6zbiUl.js';
import './html-CfyvkLET.js';
import './Clear-D7Yjckqz.js';

function e(o){o.push('<svg width="100%" height="100%" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 12H12M18 12H12M12 12V6M12 12V18" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>');}

function X(n,e){n.component(c=>{let d=e.label,m=fallback(e.checked,false),h=fallback(e.disabled,false);c.push(`<div class="s s--slider svelte-1io85vl" style="font-size:var(--font-size-sm)px"><button role="switch"${attr("aria-checked",m)}${attr("disabled",h,true)} class="svelte-1io85vl"></button> <span>${escape_html(d)}</span></div>`),bind_props(e,{label:d,checked:m,disabled:h});});}function Y(n,e$2){n.component(c$1=>{const{$$slots:d,$$events:m,...h$1}=e$2,t=h$1.gradio;let i=false,p=!t.shared.interactive,v=[],f=t.props.buttons||["copy"],I=s=>{t.dispatch("custom_button_click",{id:s});};t.props.value;let b=false,g,_="",S$1=null,y$1=false,D=false;const C=["red","green","blue","yellow","purple","teal","orange","cyan","lime","pink"],E={red:"rgba(254, 202, 202, 0.7)",green:"rgba(209, 250, 229, 0.7)",blue:"rgba(219, 234, 254, 0.7)",yellow:"rgba(254, 243, 199, 0.7)",purple:"rgba(233, 213, 255, 0.7)",teal:"rgba(204, 251, 241, 0.7)",orange:"rgba(254, 215, 170, 0.7)",cyan:"rgba(207, 250, 254, 0.7)",lime:"rgba(217, 249, 157, 0.7)",pink:"rgba(252, 231, 243, 0.7)"};let N=(()=>{let s={};return t.props.color_map?s={...t.props.color_map}:(s={},t.props.speakers.forEach((o,l)=>{const x=C[l%C.length];s[o]=E[x];})),s})();function P(s,o,l){v[s][o]=l,v=[...v],t.props.value=[...v];}async function B(s){return typeof s=="string"?s:await t.shared.server.format(s)}async function z(){if("clipboard"in navigator){const s=await B(t.props.value);await navigator.clipboard.writeText(s),G();}}function G(){b=true,g&&clearTimeout(g),g=setTimeout(()=>{b=false;},1e3);}let k=true,w$1;function A(s){if(s.push(`<div${attr_class("svelte-1p54cvv",void 0,{container:t.shared.container})}>`),t.shared.show_label&&(f.some(o=>typeof o=="string"&&o==="copy")||f.some(o=>typeof o!="string"))?(s.push("<!--[-->"),y(s,{buttons:f,on_custom_button_click:I,children:o=>{f.some(l=>typeof l=="string"&&l==="copy")?(o.push("<!--[-->"),w(o,{Icon:b?e$1:h,onclick:z,label:b?"Copied":"Copy"})):o.push("<!--[!-->"),o.push("<!--]-->");}})):s.push("<!--[!-->"),s.push("<!--]--> "),c(s,{show_label:t.shared.show_label,info:t.props.info,children:o=>{o.push(`<!---->${escape_html(t.shared.label||"Dialogue")}`);},$$slots:{default:true}}),s.push("<!----> "),t.props.ui_mode==="both"?(s.push("<!--[-->"),s.push(`<div${attr_class("switch-container top-switch svelte-1p54cvv",void 0,{"switch-disabled":y$1})}>`),X(s,{label:"Plain Text",disabled:y$1,get checked(){return i},set checked(o){i=o,k=false;}}),s.push("<!----></div>")):s.push("<!--[!-->"),s.push("<!--]--> "),!i&&t.props.ui_mode!=="text"){s.push("<!--[-->"),s.push(`<div${attr_class("dialogue-container svelte-1p54cvv",void 0,{loading:y$1})}>`),s.push("<!--[!-->"),s.push("<!--]--> <!--[-->");const o=ensure_array_like(v);for(let l=0,x=o.length;l<x;l++){let r$1=o[l];if(s.push(`<div class="dialogue-line svelte-1p54cvv"${attr_style(`--speaker-bg-color: ${stringify(p&&S$1===null&&N[r$1.speaker]||"transparent")}`)}><div class="speaker-column svelte-1p54cvv" role="button" tabindex="0">`),p){s.push("<!--[-->"),s.push(`<textarea${attr("disabled",p,true)} rows="1" readonly class="svelte-1p54cvv">`);const u=escape_html(r$1.speaker);u&&s.push(`${u}`),s.push("</textarea>");}else s.push("<!--[!-->"),S(s,{label:"",show_label:false,container:true,interactive:true,value:r$1.speaker,choices:t.props.speakers.map(u=>[u,u]),on_change:u=>P(l,"speaker",u)});s.push(`<!--]--></div> <div class="text-column svelte-1p54cvv"><div class="input-container svelte-1p54cvv"><textarea${attr("placeholder",t.props.placeholder)}${attr("disabled",p,true)} rows="1" class="svelte-1p54cvv">`);const T=escape_html(r$1.text);T&&s.push(`${T}`),s.push("</textarea> "),s.push("<!--[!-->"),s.push("<!--]--></div></div> "),t.props.max_lines==null||t.props.max_lines&&l<t.props.max_lines-1?(s.push("<!--[-->"),s.push(`<div${attr_class("svelte-1p54cvv",void 0,{"action-column":l==0,hidden:p})}><button class="add-button svelte-1p54cvv" aria-label="Add new line"${attr("disabled",p,true)}>`),e(s),s.push("<!----></button></div>")):s.push("<!--[!-->"),s.push(`<!--]--> <div${attr_class("action-column svelte-1p54cvv",void 0,{hidden:p||l==0})}><button class="delete-button svelte-1p54cvv" aria-label="Remove current line"${attr("disabled",p,true)}>`),r(s),s.push("<!----></button></div></div>");}s.push("<!--]--></div>");}else {if(s.push("<!--[!-->"),i||t.props.ui_mode!=="dialogue"){s.push("<!--[-->"),s.push(`<div${attr_class("textarea-container svelte-1p54cvv",void 0,{loading:D})}>`),s.push("<!--[!-->"),s.push(`<!--]--> <textarea data-testid="textbox"${attr("placeholder",t.props.placeholder)}${attr("rows",5)}${attr("disabled",p,true)} class="svelte-1p54cvv">`);const o=escape_html(_);o&&s.push(`${o}`),s.push("</textarea> "),s.push("<!--[!-->"),s.push("<!--]--></div>");}else s.push("<!--[!-->");s.push("<!--]-->");}s.push("<!--]--> "),t.props.submit_btn&&!p?(s.push("<!--[-->"),s.push(`<div class="submit-container svelte-1p54cvv"><button class="submit-button svelte-1p54cvv"${attr("disabled",p,true)}>`),typeof t.props.submit_btn=="string"?(s.push("<!--[-->"),s.push(`${escape_html(t.props.submit_btn)}`)):(s.push("<!--[!-->"),M(s)),s.push("<!--]--></button></div>")):s.push("<!--[!-->"),s.push("<!--]--></div>");}do k=true,w$1=c$1.copy(),A(w$1);while(!k);c$1.subsume(w$1);});}function rs(n,e){n.component(c=>{const{$$slots:d,$$events:m,...h}=e,t=new $(h);G(c,{visible:t.shared.visible,elem_id:t.shared.elem_id,elem_classes:t.shared.elem_classes,scale:t.shared.scale,min_width:t.shared.min_width,allow_overflow:true,padding:t.shared.container,children:i=>{t.shared.loading_status?(i.push("<!--[-->"),W(i,spread_props([{autoscroll:t.shared.autoscroll,i18n:t.i18n},t.shared.loading_status,{on_clear_status:()=>t.dispatch("clear_status",t.shared.loading_status)}]))):i.push("<!--[!-->"),i.push("<!--]--> "),Y(i,{gradio:t}),i.push("<!---->");},$$slots:{default:true}});});}

export { Y as BaseDialogue, rs as default };
//# sourceMappingURL=Index46-B2HXwsTl.js.map
