1import{s as e,t}from"./react-CtTwWkI9.js";import{t as n}from"./jsx-runtime-Deq3KfO3.js";import{t as r}from"./compiler-runtime-Bx0QOiZF.js";import{c as i,s as a,t as o}from"./api-DnNaRTil.js";import{t as s}from"./button-Fzfr68yO.js";import{i as c,n as l,t as u}from"./tooltip-CR2DoYAq.js";import{d}from"./favicon-with-fallback-BRZy5eDY.js";import{t as f}from"./debounce-CFl1tkgZ.js";import{t as p}from"./createLucideIcon-Db2XrkAh.js";import{t as m}from"./arrow-right-D7FKTLHv.js";import{t as h}from"./check-BDacwJ7Q.js";import{t as g}from"./loader-circle-DAaU68Bw.js";import{t as _}from"./plus-CFY2eEzv.js";import{t as v}from"./search-C0XrV_Ft.js";import{c as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./dialog-DlcRpJbt.js";import{n as E}from"./dist-Csh7gSRG.js";import{n as D}from"./use-media-query-Gwh38Mqb.js";import{h as O}from"./format-time-BT9mCNLK.js";import{t as k}from"./badge-C6BvNm5n.js";var A=r(),j=e(t()),M=e(n()),N=(0,j.createContext)(null),P=({children:e})=>{let[t,n]=(0,j.useState)(``),[r,a]=(0,j.useState)(``),s=(0,j.useRef)(!1),c=i(o.version.v0_3_0.queries.search.searchMemoryMaps.searchMemoryMapsQuery,{memoryMapName:r}),l=(0,j.useCallback)(f(e=>{a(e.trim()),s.current=!1},150),[]);return(0,M.jsx)(N.Provider,{value:{inputValue:t,setInputValue:n,searchTerm:r,setSearchTerm:a,searchMemoryMapsMutation:c,handleInputChange:e=>{s.current=!0;let t=e.target.value;n(t),l(t)},isTypingRef:s},children:e})},F=()=>{let e=(0,j.useContext)(N);if(!e)throw Error(`useSearchMemoryMapContext must be used within a SearchMemoryMapProvider`);return e},I=p(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),L=()=>{let e=(0,A.c)(19),{inputValue:t,setInputValue:n,searchTerm:r,setSearchTerm:i,searchMemoryMapsMutation:s,handleInputChange:c,isTypingRef:l}=F(),{handleMemoryMapClick:u}=d(),f=a(o.version.v0_3_0.mutations.create.createMemoryMap.createMemoryMapMutation),p=(s?.exactMatches?.length??0)>0,m;e[0]!==f||e[1]!==u||e[2]!==p||e[3]!==l||e[4]!==t||e[5]!==n||e[6]!==i?(m=async e=>{let{onCreated:r}=e===void 0?{}:e;if(t===``||l.current===!0)return;if(p){E.error(`MemoryMap already exists`,{description:`A MemoryMap named "${t}" already exists.`});return}let a=await f({memoryMapName:t});n(``),i(``),await r?.(),a?.userObjectMemoryMap&&u({userObjectMemoryMapId:a.userObjectMemoryMap._id})},e[0]=f,e[1]=u,e[2]=p,e[3]=l,e[4]=t,e[5]=n,e[6]=i,e[7]=m):m=e[7];let h=m,g;return e[8]!==h||e[9]!==f||e[10]!==c||e[11]!==p||e[12]!==l||e[13]!==t||e[14]!==s||e[15]!==r||e[16]!==n||e[17]!==i?(g={memoryMapName:t,setMemoryMapName:n,searchTerm:r,setSearchTerm:i,searchMemoryMapsMutation:s,createMemoryMapMutation:f,createMemoryMapHandler:h,handleInputChange:c,isTypingRef:l,hasExactMatch:p},e[8]=h,e[9]=f,e[10]=c,e[11]=p,e[12]=l,e[13]=t,e[14]=s,e[15]=r,e[16]=n,e[17]=i,e[18]=g):g=e[18],g},R=e=>{let t=(0,A.c)(5),{memoryMapsAsSuperObjects:n}=e,{handleMemoryMapClick:r}=d(),i;t[0]!==r||t[1]!==n?(i=n?.map(e=>{let t=e.userObjectMemoryMap;return t?(0,M.jsx)(`div`,{role:`button`,tabIndex:0,onKeyDown:O,className:`opacity-60 cursor-pointer`,onClick:()=>{r({userObjectMemoryMapId:t._id})},children:(0,M.jsx)(k,{memoryMap:t})},t._id):null}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,M.jsx)(`div`,{className:`overflow-y-auto h-48 flex flex-wrap gap-2`,children:i}),t[3]=i,t[4]=a),a},z=400,B=({iconOnly:e=!1})=>{let{memoryMapName:t,searchTerm:n,searchMemoryMapsMutation:r,createMemoryMapHandler:i,handleInputChange:a,isTypingRef:o,hasExactMatch:d}=L(),[f,p]=(0,j.useState)(!1),[E,O]=(0,j.useState)(!1),k=(0,j.useRef)(null),A=(0,j.useId)(),N=(0,j.useId)(),P=(0,j.useId)(),F=D(`(max-width: 768px)`),B=t.trim(),V=r?.partialMatches??[],H=B.length>0&&!E,U=H&&(o.current||n!==B||r===void 0),W=H&&!U&&d,G=H&&!U&&!d,K=B.length>0&&(G||E),q=(0,j.useRef)(null),J=(0,j.useRef)(null),Y=(0,j.useCallback)(()=>{J.current!==null&&(clearTimeout(J.current),J.current=null),q.current?.(),q.current=null},[]),X=(0,j.useCallback)(e=>{e||Y()},[Y]),Z=()=>new Promise(e=>{q.current=e,p(!1),J.current=setTimeout(()=>{k.current?.unmount(),Y()},z)}),ee=async()=>
1{if(G){O(!0);try{await i({onCreated:Z})}finally{O(!1)}}},Q=!e&&!F,$=(0,M.jsx)(y,{render:(0,M.jsxs)(s,{variant:`outline`,size:e?`icon`:`sm`,"aria-label":Q?void 0:`New memory map`,className:`active:scale-[0.97] motion-reduce:transform-none`,children:[(0,M.jsx)(_,{className:`size-4`,"aria-hidden":`true`}),Q&&`New memory map`]})});return(0,M.jsxs)(T,{open:f,onOpenChange:p,onOpenChangeComplete:X,actionsRef:k,children:[e?(0,M.jsxs)(u,{children:[(0,M.jsx)(c,{render:$}),(0,M.jsx)(l,{children:(0,M.jsx)(`p`,{className:`font-medium`,children:`New memory map`})})]}):$,(0,M.jsxs)(C,{overlayClassName:`data-open:duration-200 data-closed:duration-200`,className:`gap-0 overflow-hidden rounded-[1.5rem] bg-popover/95 p-0 shadow-[0_1px_2px_rgba(0,0,0,0.04),0_24px_64px_-16px_rgba(0,0,0,0.28)] ring-1 ring-foreground/10 backdrop-blur-2xl sm:max-w-xl data-open:duration-200 data-closed:duration-200 motion-reduce:data-open:zoom-in-100 motion-reduce:data-closed:zoom-out-100`,children:[(0,M.jsxs)(S,{className:`gap-2 px-6 pb-5 pt-6 pr-14 sm:px-7 sm:pb-6 sm:pt-7 sm:pr-16`,children:[(0,M.jsx)(`div`,{className:`mb-1 flex size-10 items-center justify-center rounded-xl bg-foreground text-background shadow-sm`,children:(0,M.jsx)(_,{className:`size-5`,strokeWidth:2.25,"aria-hidden":`true`})}),(0,M.jsx)(w,{className:`text-[1.375rem] font-semibold leading-tight tracking-[-0.025em]`,children:`Create MemoryMap`}),(0,M.jsx)(b,{className:`max-w-md leading-relaxed`,children:`Give this space a clear name. Weâll check for similar maps before creating it.`})]}),(0,M.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ee()},children:[(0,M.jsxs)(`div`,{className:`px-6 pb-6 sm:px-7 sm:pb-7`,children:[(0,M.jsx)(`label`,{htmlFor:A,className:`mb-2 block text-[0.75rem] font-semibold tracking-[0.02em] text-foreground/80`,children:`MemoryMap name`}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(`input`,{id:A,value:t,onChange:a,autoFocus:!0,autoComplete:`off`,enterKeyHint:`done`,placeholder:`For example, Product research`,"aria-describedby":N,"aria-invalid":W||void 0,className:`h-14 w-full rounded-xl border border-input bg-background/80 px-4 pr-11 text-[1rem] font-medium tracking-[-0.01em] text-foreground shadow-xs outline-none transition-[border-color,box-shadow,background-color] placeholder:font-normal placeholder:text-muted-foreground/55 focus:border-ring focus:bg-background focus:ring-[3px] focus:ring-ring/20 aria-invalid:border-destructive/50 aria-invalid:ring-destructive/10`}),(0,M.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-4 flex items-center`,children:U?(0,M.jsx)(g,{className:`size-4 animate-spin text-muted-foreground motion-reduce:animate-none`,"aria-hidden":`true`}):W?(0,M.jsx)(I,{className:`size-4 text-destructive`,"aria-hidden":`true`}):K?(0,M.jsx)(h,{className:`size-4 text-emerald-600 dark:text-emerald-400`,"aria-hidden":`true`}):null})]}),(0,M.jsx)(`div`,{id:N,"aria-live":`polite`,className:`mt-2 min-h-5 text-[0.8125rem] leading-5`,children:U?(0,M.jsx)(`p`,{className:`text-muted-foreground`,children:`Checking availabilityâ¦`}):W?(0,M.jsx)(`p`,{className:`font-medium text-destructive`,children:`A memory map with this name already exists.`}):K?(0,M.jsx)(`p`,{className:`text-emerald-700 dark:text-emerald-400`,children:`This name is available.`}):(0,M.jsx)(`p`,{className:`text-muted-foreground`,children:`Use a name youâll recognize at a glance.`})}),K&&!U&&(0,M.jsxs)(`section`,{"aria-labelledby":P,className:`mt-5 rounded-xl border border-border/70 bg-muted/35 p-3.5`,children:[(0,M.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(v,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,M.jsx)(`h3`,{id:P,className:`truncate text-[0.75rem] font-semibold tracking-[0.01em] text-foreground/80`,children:`Similar memory maps`})]}),(0,M.jsx)(`span`,{className:`rounded-full bg-background px-2 py-0.5 text-[0.6875rem] font-medium tabular-nums text-muted-foreground ring-1 ring-border/70`,children:V.length})]}),V.length>0?(0,M.jsx)(`div`,{onClick:()=>p(!1),className:`[&>div]:h-auto [&>div]:max-h-28 [&>div]:content-start [&>div]:gap-2 [&>div>div]:opacity-100 [&>div>div]:transition-transform [&>div>div]:duration-100 [&>div>div]:active:scale-[0.97] motion-reduce:[&>div>div]:transform-none`,children:(0,M.jsx)(R,{memoryMapsAsSuperObjects:V})}):(0,M.jsx)(`p`,{className:`py-1 text-[0.8125rem] leading-relaxed text-muted-foreground`,children:`No similar maps found. Youâre starting with a distinct name.`})]})]}),(0,M.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 border-t border-border/70 bg-muted/45 px-6 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-7`,children:[(0,M.jsxs)(`p`,{className:`hidden text-[0.6875rem] text-muted-foreground sm:block`,children:[`Press`,` `,(0,M.jsx)(`kbd`,{className:`font-medium text-foreground
1/70`,children:`Enter âµ`}),` to create`]}),(0,M.jsxs)(`div`,{className:`flex gap-2 sm:ml-auto`,children:[(0,M.jsx)(x,{render:(0,M.jsx)(s,{type:`button`,variant:`ghost`,className:`flex-1 active:scale-[0.97] sm:flex-none motion-reduce:transform-none`,children:`Cancel`})}),(0,M.jsx)(s,{type:`submit`,disabled:!G,className:`flex-1 px-4 active:scale-[0.97] sm:flex-none motion-reduce:transform-none`,children:E?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(g,{className:`animate-spin motion-reduce:animate-none`,"aria-hidden":`true`}),`Creatingâ¦`]}):(0,M.jsxs)(M.Fragment,{children:[`Create map`,(0,M.jsx)(m,{"aria-hidden":`true`})]})})]})]})]})]})]})};export{P as n,B as t};
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.