import './async-Djx13DAD.js';
import { c as bind_props, e as ensure_array_like, g as attr_style, d as attr_class, a as attr, b as spread_props } from './index-B7gr0Dsc.js';
import './2-CeYbpaU1.js';
import { o } from './Clear-CiR-WD8W.js';
import { G } from './Block-2-03Azgw.js';
import './MarkdownCode.svelte_svelte_type_style_lang-DJRtJayx.js';
import { k } from './BlockLabel-DYKzuObf.js';
import { p } from './Empty-uaeWNu3s.js';
import { g } from './utils.svelte-D8Xdzglu.js';
import { y } from './IconButtonWrapper-DlgTGGi-.js';
import { R } from './index3-DONAw0dG.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import './context-BZS6UlnY.js';
import './uneval-DjLoL4oF.js';
import './clone-BLo8hHdj.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';
import './prism-python-BaDPvmdn.js';
import './spring-DyDQVd5U.js';
import './IconButton-7VBZdgpA.js';

function H(l){l.push('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--carbon" width="100%" height="100%" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path fill="currentColor" d="M12 15H5a3 3 0 0 1-3-3v-2a3 3 0 0 1 3-3h5V5a1 1 0 0 0-1-1H3V2h6a3 3 0 0 1 3 3zM5 9a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h5V9zm15 14v2a1 1 0 0 0 1 1h5v-4h-5a1 1 0 0 0-1 1z"></path><path fill="currentColor" d="M2 30h28V2Zm26-2h-7a3 3 0 0 1-3-3v-2a3 3 0 0 1 3-3h5v-2a1 1 0 0 0-1-1h-6v-2h6a3 3 0 0 1 3 3Z"></path></svg>');}function I(l){if(!l)return  true;const h=l.toLowerCase().trim();return h==="transparent"||h.length===9&&h.endsWith("00")}function N(l,h){if(l.length===0)return [];const p=[];let u=l[0].token,r=l[0].class_or_confidence;for(let o=1;o<l.length;o++){const{token:t,class_or_confidence:c}=l[o];r===c?u+=t:(p.push({token:u,class_or_confidence:r}),u=t,r=c);}return p.push({token:u,class_or_confidence:r}),p}function P(l){return l===null?"":l<0?`rgba(128, 90, 213, ${-l})`:`rgba(239, 68, 60, ${l})`}function Q(l,h){l.component(p=>{let{value:u=[],label_to_edit:r=-1,category:o,active_legend:t,color_map:c,label_index:g,token:f,onchange:k,is_scores_mode:_=false}=h,s$1=o?.toString()??"";function n(){if(_){const m=typeof o=="number"?o:parseFloat(o??"0");return P(m)}return o===null||t&&t!==o?"":c[o]?.primary??""}p.push(`<input class="label-input svelte-14ic1z3" autofocus${attr("type",_?"number":"text")}${attr("step",_?"0.1":void 0)}${attr("placeholder",_?void 0:"label")}${attr("value",o)}${attr_style("",{"background-color":n(),width:_?"7ch":`${(s$1?.length||4)+4}ch`})}/>`),bind_props(h,{value:u,label_to_edit:r});});}function U(l,h){l.component(p=>{let {value:u=[],show_legend:r=false,show_inline_category:o$1=true,color_map:t={},interactive:c=false,onselect:g,onchange:f}=h,_="",s$1=-1,m={};function j(){f?.(u),s$1=-1;}function S(e){return e===null?"":m[e]?.secondary??""}function A(e){return e===null?"":m[e]?.primary??""}function O(e){const b=S(e);return I(b)?"":"black"}let w=true,L;function T(e){e.push('<div class="container svelte-1akrbo3">');{if(e.push("<!--[-->"),r){e.push("<!--[-->"),e.push('<div class="legend svelte-1akrbo3" data-testid="highlighted-text:category-legend"><!--[-->');const d=ensure_array_like(Object.entries(m));for(let v=0,y=d.length;v<y;v++){let[i,x]=d[v];e.push(`<button class="legend-item svelte-1akrbo3"${attr_style("",{"background-color":x.secondary})}>${escape_html(i)}</button>`);}e.push("<!--]--></div>");}else e.push("<!--[!-->");e.push('<!--]--> <div class="textfield svelte-1akrbo3"><!--[-->');const b=ensure_array_like(u);for(let d=0,v=b.length;d<v;d++){let{token:y,class_or_confidence:i}=b[d];const x=y.split(`
`);e.push("<!--[-->");const z=ensure_array_like(x);for(let B=0,G=z.length;B<G;B++){let C=z[B];if(C.trim()){e.push("<!--[-->");const E=S(i);e.push(`<span class="token-container svelte-1akrbo3"><span${attr_class("token svelte-1akrbo3",void 0,{highlighted:i!==null,transparent:i!==null&&I(E),dimmed:_})}${attr("role",i!==null?"button":void 0)}${attr("tabindex",i!==null?0:void 0)}${attr_style("",{"background-color":E,color:O(i)})}><span${attr_class("text svelte-1akrbo3",void 0,{unlabeled:i===null})}>${escape_html(C)}</span> `),!r&&o$1&&i!==null&&s$1!==d?(e.push("<!--[-->"),e.push(`<span class="label svelte-1akrbo3"${attr_style("",{"background-color":A(i)})}>${escape_html(i)}</span>`)):e.push("<!--[!-->"),e.push("<!--]--> "),c&&s$1===d&&i!==null?(e.push("<!--[-->"),Q(e,{category:i,active_legend:_,color_map:m,label_index:d,token:y,onchange:j,get value(){return u},set value(M){u=M,w=false;},get label_to_edit(){return s$1},set label_to_edit(M){s$1=M,w=false;}})):e.push("<!--[!-->"),e.push("<!--]--></span> "),c&&i!==null?(e.push("<!--[-->"),e.push('<button class="remove-btn svelte-1akrbo3" aria-label="Remove label">'),o(e),e.push("<!----></button>")):e.push("<!--[!-->"),e.push("<!--]--></span>");}else e.push("<!--[!-->");e.push("<!--]--> "),B<x.length-1?(e.push("<!--[-->"),e.push('<span class="line-break svelte-1akrbo3"></span>')):e.push("<!--[!-->"),e.push("<!--]-->");}e.push("<!--]-->");}e.push("<!--]--></div>");}e.push("<!--]--></div>");}do w=true,L=p.copy(),T(L);while(!w);p.subsume(L),bind_props(h,{value:u});});}function _t(l,h){l.component(p$1=>{const{$$slots:u,$$events:r,...o}=h,t=new g(o);t.props.value;let c=t.props.combine_adjacent?N(t.props.value||[]):t.props.value,g$1=true,f;function k$1(_){G(_,{variant:t.shared.interactive?"dashed":"solid",test_id:"highlighted-text",visible:t.shared.visible,elem_id:t.shared.elem_id,elem_classes:t.shared.elem_classes,padding:false,container:t.shared.container,scale:t.shared.scale,min_width:t.shared.min_width,rtl:t.props.rtl,children:s$1=>{R(s$1,spread_props([{autoscroll:t.shared.autoscroll,i18n:t.i18n},t.shared.loading_status,{onclearstatus:()=>t.dispatch("clear_status",t.shared.loading_status)}])),s$1.push("<!----> "),t.shared.interactive&&t.shared.label&&t.shared.show_label&&t.props.buttons?.length?(s$1.push("<!--[-->"),y(s$1,{buttons:t.props.buttons,on_custom_button_click:n=>t.dispatch("custom_button_click",{id:n})})):s$1.push("<!--[!-->"),s$1.push("<!--]--> "),t.shared.label&&t.shared.show_label?(s$1.push("<!--[-->"),k(s$1,{Icon:H,label:t.shared.label||t.i18n("highlighted_text.highlighted_text"),float:false,disable:t.shared.container===false,show_label:t.shared.show_label,rtl:t.props.rtl})):s$1.push("<!--[!-->"),s$1.push("<!--]--> "),c?(s$1.push("<!--[-->"),U(s$1,{interactive:t.shared.interactive,show_legend:t.props.show_legend,show_inline_category:t.props.show_inline_category,color_map:t.props.color_map,onselect:n=>t.dispatch("select",n),onchange:()=>{t.props.value=c,t.dispatch("change");},get value(){return c},set value(n){c=n,g$1=false;}})):(s$1.push("<!--[!-->"),p(s$1,{size:t.shared.interactive?"small":"large",unpadded_box:t.shared.interactive,children:n=>{H(n);},$$slots:{default:true}})),s$1.push("<!--]-->");},$$slots:{default:true}});}do g$1=true,f=p$1.copy(),k$1(f);while(!g$1);p$1.subsume(f);});}

export { U as BaseHighlightedText, _t as default };
//# sourceMappingURL=Index52-C5_BNk8p.js.map
