PageSourceSearch

https://opentug.com/assets/Autocomplete-DEgXh-fX.js

js opentug.com collected 2026-09-29 08:53:38 UTC 7,774 bytes, 1 lines download raw bytes

1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`8996b9409a959cec3baed6da20d365a7da20654f`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`9c4df184-6f1f-4b15-bf3e-67d2902d419d`,e._sentryDebugIdIdentifier=`sentry-dbid-9c4df184-6f1f-4b15-bf3e-67d2902d419d`)}catch{}})();import{C as e,I as t,L as n,M as r,N as i,O as a,U as o,W as s,a as c,b as l,c as u,h as d,j as f,m as p,n as m,o as h,s as g,u as _}from"./web-DDgQJ4e4.js";import{B as v}from"./utils-C2jyzqC3.js";import{t as y}from"./dist-Dbw8Fiyh.js";import{t as b}from"./Badge-CeBGScZj.js";import{t as x}from"./fuse-8xzuQjRW.js";var S=p(`<span class=tw:text-red-500 aria-hidden=true> *`),C=p(`<label class="tw:block tw:text-sm tw:font-medium tw:text-gray-900 tw:dark:text-gray-100">`),w=p(`<li class="tw:px-3 tw:py-1.5 tw:text-xs tw:font-semibold tw:uppercase tw:tracking-wide tw:text-gray-500 tw:dark:text-gray-400 tw:bg-gray-100 tw:dark:bg-gray-700">Suggested`),T=p(`<div data-testid=dropdown class="tw:absolute tw:rounded-md tw:bg-white tw:dark:bg-gray-800 tw:shadow-md tw:ring-1 tw:ring-black/5 tw:dark:ring-white/10 tw:max-h-60 tw:overflow-auto tw:z-[9999]"><ul class="tw:px-0 tw:py-0 tw:my-0">`),E=p(`<p class="tw:text-sm tw:text-left tw:text-red-500 tw:dark:text-red-400">`),D=p(`<p class="tw:text-sm tw:text-left tw:text-gray-500 tw:dark:text-gray-400">`),O=p(`<div class="tw:mt-2 tw:h-5">`),k=p(`<div><div aria-haspopup=listbox><div><input autocomplete=off aria-autocomplete=list>`),A=p(`<li class="tw:px-3 tw:py-1.5 tw:text-xs tw:font-semibold tw:uppercase tw:tracking-wide tw:text-gray-500 tw:dark:text-gray-400 tw:border-t tw:border-gray-100 tw:dark:border-gray-700 tw:mt-0.5">All assets`),j=p(`<span>`),M=p(`<li><button type=button><span>`),ee=y(`tw:relative tw:w-full`,{variants:{fullWidth:{true:`tw:max-w-none`,false:`tw:max-w-md`}},defaultVariants:{fullWidth:!1}}),te=y(`tw:flex tw:items-center tw:gap-2 tw:border tw:rounded-md tw:px-2 tw:py-2 tw:mt-2`,{variants:{disabled:{true:`tw:cursor-not-allowed tw:bg-gray-50 tw:dark:bg-gray-700`,false:`tw:bg-white tw:dark:bg-gray-700`},error:{true:`tw:border-red-500 tw:dark:border-red-400`,false:`tw:border-gray-300 tw:dark:border-gray-600`}},defaultVariants:{disabled:!1,error:!1}}),N=y(`tw:flex-1 tw:min-w-[150px] tw:h-[32px] tw:px-2 tw:text-sm tw:focus:outline-none tw:placeholder:text-gray-400 tw:dark:placeholder:text-gray-400`,{variants:{disabled:{true:`tw:cursor-not-allowed tw:bg-gray-50 tw:text-gray-500 tw:dark:bg-gray-700 tw:dark:text-gray-400`,false:`tw:bg-white tw:text-gray-900 tw:dark:bg-gray-700 tw:dark:text-white`}},defaultVariants:{disabled:!1}}),P=p=>{let h=n(),y,P,[F,I]=t(!1),[L,R]=t(``),[z,B]=t(-1),[V,H]=t({top:0,left:0,width:0});s(()=>{let e=e=>{let t=e.target,n=y&&!y.contains(t),r=P&&!P.contains(t);n&&r&&I(!1)};document.addEventListener(`mousedown`,e),o(()=>{document.removeEventListener(`mousedown`,e)})});let U=r(()=>new Set(p.selectedOptions.map(e=>e.id))),W=r(()=>p.options.filter(e=>!U().has(e.id))),G=r(()=>new Set((p.suggestedOptions??[]).map(e=>e.id))),K=r(()=>(p.suggestedOptions??[]).filter(e=>!U().has(e.id))),q=r(()=>new x(W(),{keys:[`title`],threshold:.3})),J=r(()=>new x(K(),{keys:[`title`],threshold:.3})),Y=r(()=>{let e=L().trim();return(e===``?W():q().search(e).map(e=>e.item)).filter(e=>!G().has(e.id))}),X=r(()=>{if(K().length===0)return[];let e=L().trim();return e===``?K():J().search(e).map(e=>e.item)}),Z=r(()=>[...X(),...Y()]);f(()=>{let e=p.selectedOptions.length;p.trackSelectedOptionsEnd&&e!==0&&requestAnimationFrame(()=>{P&&(P.scrollTop=P.scrollHeight,P.scrollLeft=P.scrollWidth)})});let ne=e=>{let t=e.target.value;R(t),B(p.focusFirstResultOnInput&&t.trim()?0:-1),F()||($(),I(!0))},Q=e=>{p.onSelect?.(e),R(``),B(-1),I(!1)},re=e=>{p.onDeselect?.(e)},ie=e=>{if(e.key===`Enter`)e.preventDefault(),z()>=0&&Z()[z()]?Q(Z()[z()]):ae();else if(e.key===`ArrowDown`){e.preventDefault(),F()||($(),I(!0));let t=z(),n=Z().length-1;B(t<n?t+1:0)}else if(e.key===`ArrowUp`){e.preventDefault(),F()||($(),I(!0));let t=z(),n=Z().length-1;B(t>0?t-1:n)}else e.key===`Escape`&&(I(!1),B(-1))},ae=async()=>{let e=L().trim();if(!e)return;let t=await p.addOption?.(e);t&&(p.onSelect?.(t),R(``))},$=()=>{if(P){let e=P.getBoundingClientRect();H({top:e.bottom+window.scrollY,left:e.left+window.scrollX,width:e.width})}},oe=()=>{$(),I(e=>!e),B(-1)};return(()=>{var t=k(),n=t.firstChild,r=n.firstChild,o=r.firstChild;g(t,a(e,{get when(){return p.label},get children(){var t=C();return _(t,`for`,`autocomplete-${h}`),g(t,()=>p.label,null),g(t,a(e,{get when(){return p.required},get children(){return S()}}),null),t}}),n);var s=P;return typeof s==`function`?d(s,n):P=n,g(r,a(l,{get each(){return[...p.selectedOptions]},children:e=>a(b,{get onRemove(){return p.disabled||e.preventDelete?void 0:()=>re(e)},get color(){return e.color},get children(){return e.title}}
1)}),o),o.$$click=oe,o.$$keydown=ie,o.$$input=ne,_(o,`id`,`autocomplete-${h}`),_(o,`aria-controls`,h),g(t,a(e,{get when(){return u(()=>!!F())()&&Z().length>0},get children(){return a(m,{get children(){var t=T(),n=t.firstChild,r=y;return typeof r==`function`?d(r,t):y=t,_(t,`id`,h),t.style.setProperty(`margin-top`,`4px`),g(n,a(e,{get when(){return X().length>0},get children(){return w()}}),null),g(n,a(l,{get each(){return Z()},children:(t,n)=>[a(e,{get when(){return u(()=>X().length>0)()&&n()===X().length},get children(){return A()}}),(()=>{var r=M(),o=r.firstChild,s=o.firstChild;return o.$$keydown=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Q(t))},o.$$mousedown=e=>{e.preventDefault(),Q(t)},g(s,()=>t.title),g(o,a(e,{get when(){return t.subtitle},get children(){var e=j();return g(e,()=>t.subtitle),i(()=>c(e,`tw:ml-2 tw:rounded-full tw:px-2 tw:py-0.5 tw:text-xs tw:font-medium tw:shrink-0 ${t.color===`green`?`tw:bg-green-100 tw:text-green-800 tw:dark:bg-green-900/30 tw:dark:text-green-300`:t.color===`blue`?`tw:bg-blue-100 tw:text-blue-800 tw:dark:bg-blue-900/30 tw:dark:text-blue-300`:`tw:bg-gray-100 tw:text-gray-600 tw:dark:bg-gray-700 tw:dark:text-gray-300`}`)),e}}),null),i(e=>{var t=`option-${n()}`,r=`tw:w-full tw:text-left tw:px-2 tw:py-2 tw:text-sm tw:text-gray-700 tw:dark:text-gray-200 tw:hover:bg-gray-100 tw:dark:hover:bg-gray-700 tw:flex tw:items-center tw:justify-between ${z()===n()?`tw:bg-gray-100 tw:dark:bg-gray-700`:``}`;return t!==e.e&&_(o,`id`,e.e=t),r!==e.t&&c(o,e.t=r),e},{e:void 0,t:void 0}),r})()]}),null),i(e=>{var n=`${V().top}px`,r=`${V().left}px`,i=`${V().width}px`;return n!==e.e&&((e.e=n)==null?t.style.removeProperty(`top`):t.style.setProperty(`top`,n)),r!==e.t&&((e.t=r)==null?t.style.removeProperty(`left`):t.style.setProperty(`left`,r)),i!==e.a&&((e.a=i)==null?t.style.removeProperty(`width`):t.style.setProperty(`width`,i)),e},{e:void 0,t:void 0,a:void 0}),t}})}}),null),g(t,a(e,{get when(){return p.error||p.helpText},get children(){var t=O();return g(t,a(e,{get when(){return p.error},get children(){var e=E();return _(e,`id`,`${h}-error`),g(e,()=>p.error),e}}),null),g(t,a(e,{get when(){return!p.error&&p.helpText},get children(){var e=D();return _(e,`id`,`${h}-help`),g(e,()=>p.helpText),e}}),null),t}}),null),i(e=>{var i=v(ee({fullWidth:p.fullWidth})),a=v(te({disabled:p.disabled,error:!!p.error}),p.inputContainerClass),s=v(`tw:flex tw:flex-wrap tw:gap-2 tw:max-w-full tw:min-w-0 tw:flex-1`,p.chipsContainerClass),l=p.placeholder,u=N({disabled:p.disabled}),d=p.disabled;return i!==e.e&&c(t,e.e=i),a!==e.t&&c(n,e.t=a),s!==e.a&&c(r,e.a=s),l!==e.o&&_(o,`placeholder`,e.o=l),u!==e.i&&c(o,e.i=u),d!==e.n&&(o.disabled=e.n=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),i(()=>o.value=L()),t})()};h([`input`,`keydown`,`click`,`mousedown`]);export{P 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.