import{bL as S,a as h,d as V,al as D,u as I,N as j,bZ as B,bM as F,o as v,e as y,i as L,t as O,h as f,f as M,b_ as R,q as U,r as q,k as u,aV as z,_ as G}from"./index-D92x6h1h.js";function K(a){if(!a||!S(a)||a.uri!=="channel/list")return a;const r=h(),o={};return r.chnameNum&&(o.numbers=1),r.chnameSrc&&(o.sources=1),Object.keys(o).length===0?a:{...a,params:{...a.params,...o}}}const P={class:"enum-name-cell"},T=["title"],Z=["title","aria-label"],H=V({__name:"EnumNameCell",props:{value:{},row:{},col:{}},setup(a){const r=a,o=h(),g=D(),{t:c}=I(),_=z("idnodeGridActivelyEditing",void 0),i=q(null);j(()=>{const e=K(r.col.enumSource);if(e){if(B(e)){i.value=e;return}F(e).then(t=>{i.value=t}).catch(()=>{i.value=[]})}});function b(){const e=r.col.fallbackField;if(!e||!r.row)return"";const t=r.row[e];return typeof t=="string"?t:""}function d(e){const t=b();if(i.value===null)return t||e;const l=i.value.find(n=>String(n.key)===e);return l?l.val:t||"—"}const p=u(()=>{const e=r.value;if(Array.isArray(e)){if(e.length===0)return{display:"—"};const t=e.map(n=>{const s=String(n),w=d(s),A=i.value?.findIndex(N=>String(N.key)===s)??-1;return{label:w,idx:A}});if(i.value!==null&&t.every(n=>n.label==="—"))return{display:"—"};i.value!==null&&t.sort((n,s)=>n.idx===-1&&s.idx===-1?0:n.idx===-1?1:s.idx===-1?-1:n.idx-s.idx);const l=t.map(n=>n.label);return l.length===1?{display:l[0]}:{display:c("{0}, +{1} more",l[0],l.length-1),full:l.join(", ")}}return e==null||e===""?{display:"—"}:{display:d(String(e))}}),k=u(()=>p.value.display),m=u(()=>{const e=r.col.targetUuidField;if(!e||!r.row)return null;const t=r.row[e];if(typeof t=="string"&&t)return[t];if(Array.isArray(t)){const l=t.filter(n=>typeof n=="string"&&!!n);return l.length?l:null}return null}),x=u(()=>{const e=r.col.targetAccessKey;return e?!!o.data?.[e]:!0}),E=u(()=>!_?.value&&m.value!==null&&x.value);function C(e){e.stopPropagation();const t=m.value;if(!t||t.length===0)return;const l=t.map(s=>({uuid:s,name:d(s)})),n=[{field:"name",label:c("Name")}];g.openList(l,n,r.col.pickerTitle??r.col.label)}return(e,t)=>(v(),y("span",P,[L("span",{class:"enum-name-cell__text",title:p.value.full},O(k.value),9,T),E.value?(v(),y("button",{key:0,type:"button",class:"enum-name-cell__drill",title:f(c)("Open in editor"),"aria-label":f(c)("Open in editor"),onClick:C},[M(f(R),{size:14,"aria-hidden":"true"})],8,Z)):U("",!0)]))}}),Q=G(H,[["__scopeId","data-v-9b09e46f"]]);export{Q as E,K as r};
