PageSourceSearch

https://myechoboard.com/assets/BulkTagPicker-BObvNe3s.js

js myechoboard.com collected 2026-09-24 13:50:36 UTC 8,715 bytes, 1 lines download raw bytes

1import{r as e,j as t}from"./vendor-react-C9yDzYQD.js";import{B as r}from"./button-CcIRk75H.js";import{D as a,F as s}from"./memoryDetailMetadata-YR61o5BJ.js";import{a as o}from"./runtime-utils-GN4cODRt.js";import{X as n}from"./x-lNdY5pWw.js";import{S as l}from"./search-D7ByVMw5.js";import{C as d}from"./check-MQhLD6FV.js";import{M as i}from"./minus-DTEknrgZ.js";import{T as c}from"./tag-DttT5I5w.js";const m=e=>e.trim().replace(/\s+/g," ").slice(0,50),u=e=>`${e.source||("id"in e&&e.id?"manual":"new")}:${m(e.name).toLocaleLowerCase()}`;function p({availableTags:p,selectedTags:g,onSelectedTagsChange:x,selectedEchoCount:h,editableEchoCount:b,tagCoverage:f={},isCoverageLoading:w=!1,operation:v,onOperationChange:j,recentTagIds:N=[],metadataTags:y=[],isApplying:C,onApply:k,onCancel:L}){const[S,D]=e.useState(""),[A,M]=e.useState(0),[E,T]=e.useState(a),_=e.useRef(null),$=e.useMemo(()=>new Set(g.map(u)),[g]),R=e.useMemo(()=>new Set(N),[N]),F=m(S),B=e.useMemo(()=>{const e=F.toLocaleLowerCase(),t=new Map(N.map((e,t)=>[e,t])),r=[...p.map(e=>({...e,source:"manual"})),..."remove"===v?y:[]].filter(e=>!$.has(u(e))).filter(e=>"add"===v||(e.coverageCount||(e.id?f[e.id]:0))>0).filter(t=>!e||t.name.toLocaleLowerCase().includes(e)).sort((r,a)=>{if(e){const t=r.name.toLocaleLowerCase().startsWith(e);if(t!==a.name.toLocaleLowerCase().startsWith(e))return t?-1:1}const s=r.id?t.get(r.id):void 0,o=a.id?t.get(a.id):void 0;return void 0!==s||void 0!==o?(s??Number.MAX_SAFE_INTEGER)-(o??Number.MAX_SAFE_INTEGER):(a.usage_count||0)-(r.usage_count||0)||r.name.localeCompare(a.name)});return"remove"===v?r:r.slice(0,8)},[p,y,F,v,N,$,f]),I=p.find(e=>m(e.name).toLocaleLowerCase()===F.toLocaleLowerCase()),U=Boolean("add"===v&&F&&!I&&!$.has(F.toLocaleLowerCase())),G=e=>{$.has(u(e))||(x([...g,e]),D(""),M(0),requestAnimationFrame(()=>{var e;return null==(e=_.current)?void 0:e.focus()}))},K=()=>{F&&(I?G(I):U&&G({name:F,color:E,source:"new"}))},W=e=>{const t=u(e);x(g.filter(e=>u(e)!==t))},X=e.useMemo(()=>g.reduce((e,t)=>{const r=t.coverageCount??(t.id&&f[t.id]||0);return e+("add"===v?Math.max(0,b-r):r)},0),[b,v,g,f]);return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"grid grid-cols-2 rounded-2xl bg-muted/50 p-1",children:["add","remove"].map(e=>t.jsxs("button",{type:"button",onClick:()=>{j(e),x([]),D("")},disabled:C,className:o("rounded-xl px-4 py-2 text-sm font-bold capitalize transition-all",v===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e," tags"]},e))}),t.jsxs("div",{className:o("rounded-2xl border border-border/70 bg-muted/20 p-2 transition-colors","focus-within:border-primary/45 focus-within:ring-2 focus-within:ring-primary/15"),children:[g.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2 p-1 pb-2",children:g.map(e=>t.jsxs("span",{className:"inline-flex min-h-9 items-center gap-2 rounded-xl border border-border/60 bg-background px-3 py-1.5 text-sm font-semibold shadow-sm",children:[t.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),e.name,t.jsx("button",{type:"button",onClick:()=>W(e),disabled:C,className:"-mr-1 rounded-md p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":`Remove ${e.name}`,children:t.jsx(n,{className:"h-3.5 w-3.5"})})]},u(e)))}),t.jsxs("div",{className:"relative",children:[t.jsx(l,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx("input",{ref:_,autoFocus:!0,value:S,onChange:e=>D(e.target.value),onPaste:e=>{const t=e.clipboardData.getData("text");/[,\n]/.test(t)&&(e.preventDefault(),(e=>{const t=[...g],r=new Set($);e.forEach(e=>{const a=m(e);if(!a)return;const s=[...p.map(e=>({...e,source:"manual"})),..."remove"===v?y:[]].find(e=>m(e.name).toLocaleLowerCase()===a.toLocaleLowerCase());if("remove"===v&&!s)return;const o=s||{name:a,color:E,source:"new"};r.has(u(o))||(r.add(u(o)),t.push(o))}),x(t),D(""),M(0)})(t.split(/[,\n]+/)))},onKeyDown:e=>"ArrowDown"===e.key&&B.length>0?(e.preventDefault(),void M(e=>(e+1)%B.length)):"ArrowUp"===e.key&&B.length>0?(e.preventDefault(),void M(e=>(e-1+B.length)%B.length)):("Enter"===e.key&&(e.preventDefault(),B[A]?G(B[A]):K()),","===e.key&&(e.preventDefault(),K()),void("Backspace"===e.key&&!S&&g.length>0&&W(g[g.length-1]))),placeholder:"remove"===v?"Search tags currently on these echoes…":g.length?"Add another tag…":"Search, create, or paste tags…",disabled:C,className:"h-11 w-full bg-transparent pl-10 pr-3 text-base outline-none placeholder:text-muted-foreground
1/70","aria-label":"Search or create tags"})]}),U?t.jsxs("div",{className:"mx-1 mb-1 mt-2 flex flex-wrap items-center gap-2 rounded-xl border border-border/50 bg-background/70 px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[10px] font-bold uppercase tracking-wide text-muted-foreground",children:"New tag color"}),s.map(e=>t.jsx("button",{type:"button",onClick:()=>T(e),disabled:C,"aria-label":`Use ${e} for ${F}`,"aria-pressed":E===e,className:o("grid h-7 w-7 place-items-center rounded-lg transition-transform hover:scale-110 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",E===e&&"ring-2 ring-foreground ring-offset-2 ring-offset-background"),style:{backgroundColor:e},children:E===e?t.jsx(d,{className:"h-3.5 w-3.5 text-white drop-shadow"}):null},e))]}):null]}),t.jsxs("div",{className:"min-h-24 overflow-hidden rounded-2xl border border-border/60 bg-background/55",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 px-4 py-2.5",children:[t.jsx("p",{className:"text-xs font-bold uppercase tracking-wide text-muted-foreground",children:F?"Matches":"Your tags"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Tap to select"})]}),t.jsxs("div",{className:"max-h-56 overflow-y-auto p-1.5",children:[U&&t.jsxs("button",{type:"button",onClick:K,className:"flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition-colors hover:bg-muted",children:[t.jsx("span",{className:"grid h-8 w-8 place-items-center rounded-lg bg-primary/10 text-primary",children:t.jsx("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:E}})}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"block truncate text-sm font-semibold",children:["Create “",F,"”"]}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Created when you apply"})]})]}),B.map((e,r)=>{const a=e.coverageCount??(e.id&&f[e.id]||0),s=b>0&&a>=b,n=a>0&&!s;return t.jsxs("button",{type:"button",onClick:()=>G(e),className:o("flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition-colors hover:bg-muted",r===A&&F&&"bg-muted"),children:[t.jsx("span",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:e.color}}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:e.name}),e.id&&R.has(e.id)&&t.jsx("span",{className:"rounded-md bg-primary/10 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wide text-primary",children:"Recent"}),t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:w?"…":a>0?`${a}/${b}`:"number"==typeof e.usage_count?e.usage_count.toLocaleString():""}),t.jsx("span",{className:o("grid h-5 w-5 shrink-0 place-items-center rounded-md border",s||n?"border-primary bg-primary text-primary-foreground":"border-border"),children:s?t.jsx(d,{className:"h-3.5 w-3.5"}):n?t.jsx(i,{className:"h-3.5 w-3.5"}):null})]},e.id)}),!U&&0===B.length&&t.jsx("div",{className:"grid min-h-20 place-items-center px-4 text-center text-sm text-muted-foreground",children:p.length?"No other matching tags.":"Type a name to create your first tag."})]})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"text-sm text-muted-foreground",children:[t.jsxs("p",{children:[t.jsx("span",{className:"font-semibold text-foreground",children:b.toLocaleString()})," ","editable",h>b?` · ${(h-b).toLocaleString()} not editable`:""]}),t.jsxs("p",{className:"text-xs",children:[X.toLocaleString()," tag assignment",1===X?"":"s"," will be ","add"===v?"added":"removed"]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(r,{type:"button",variant:"outline",onClick:L,disabled:C,children:"Cancel"}),t.jsxs(r,{type:"button",onClick:k,disabled:C||0===g.length||0===b,className:"min-w-32 gap-2",children:[C?t.jsx("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-r-transparent"}):t.jsx(c,{className:"h-4 w-4"}),"add"===v?"Apply":"Remove"," ",g.length||""," tag",1===g.length?"":"s"]})]})]})]})}export{p as BulkTagPicker};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.