39246-vm/frontend/out/_next/static/chunks/0d0471cb65f9ada4.js
2026-03-14 17:32:05 +03:00

1 line
26 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66027,54616,e=>{"use strict";let t;var s=e.i(75555),r=e.i(40143),i=e.i(86491),a=e.i(15823),n=e.i(93803),l=e.i(19273),o=e.i(80166),c=class extends a.Subscribable{constructor(e,t){super(),this.options=t,this.#e=e,this.#t=null,this.#s=(0,n.pendingThenable)(),this.bindMethods(),this.setOptions(t)}#e;#r=void 0;#i=void 0;#a=void 0;#n;#l;#s;#t;#o;#c;#u;#h;#d;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#r.addObserver(this),u(this.#r,this.options)?this.#x():this.updateResult(),this.#g())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return h(this.#r,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return h(this.#r,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#f(),this.#y(),this.#r.removeObserver(this)}setOptions(e){let t=this.options,s=this.#r;if(this.options=this.#e.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,l.resolveEnabled)(this.options.enabled,this.#r))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#b(),this.#r.setOptions(this.options),t._defaulted&&!(0,l.shallowEqualObjects)(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#r,observer:this});let r=this.hasListeners();r&&d(this.#r,s,this.options,t)&&this.#x(),this.updateResult(),r&&(this.#r!==s||(0,l.resolveEnabled)(this.options.enabled,this.#r)!==(0,l.resolveEnabled)(t.enabled,this.#r)||(0,l.resolveStaleTime)(this.options.staleTime,this.#r)!==(0,l.resolveStaleTime)(t.staleTime,this.#r))&&this.#v();let i=this.#j();r&&(this.#r!==s||(0,l.resolveEnabled)(this.options.enabled,this.#r)!==(0,l.resolveEnabled)(t.enabled,this.#r)||i!==this.#p)&&this.#S(i)}getOptimisticResult(e){var t,s;let r=this.#e.getQueryCache().build(this.#e,e),i=this.createResult(r,e);return t=this,s=i,(0,l.shallowEqualObjects)(t.getCurrentResult(),s)||(this.#a=i,this.#l=this.options,this.#n=this.#r.state),i}getCurrentResult(){return this.#a}trackResult(e,t){return new Proxy(e,{get:(e,s)=>(this.trackProp(s),t?.(s),"promise"===s&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#s.status||this.#s.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,s))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#r}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),s=this.#e.getQueryCache().build(this.#e,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#x({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#a))}#x(e){this.#b();let t=this.#r.fetch(this.options,e);return e?.throwOnError||(t=t.catch(l.noop)),t}#v(){this.#f();let e=(0,l.resolveStaleTime)(this.options.staleTime,this.#r);if(l.isServer||this.#a.isStale||!(0,l.isValidTimeout)(e))return;let t=(0,l.timeUntilStale)(this.#a.dataUpdatedAt,e);this.#h=o.timeoutManager.setTimeout(()=>{this.#a.isStale||this.updateResult()},t+1)}#j(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#r):this.options.refetchInterval)??!1}#S(e){this.#y(),this.#p=e,!l.isServer&&!1!==(0,l.resolveEnabled)(this.options.enabled,this.#r)&&(0,l.isValidTimeout)(this.#p)&&0!==this.#p&&(this.#d=o.timeoutManager.setInterval(()=>{(this.options.refetchIntervalInBackground||s.focusManager.isFocused())&&this.#x()},this.#p))}#g(){this.#v(),this.#S(this.#j())}#f(){this.#h&&(o.timeoutManager.clearTimeout(this.#h),this.#h=void 0)}#y(){this.#d&&(o.timeoutManager.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let s,r=this.#r,a=this.options,o=this.#a,c=this.#n,h=this.#l,m=e!==r?e.state:this.#i,{state:x}=e,g={...x},f=!1;if(t._optimisticResults){let s=this.hasListeners(),n=!s&&u(e,t),l=s&&d(e,r,t,a);(n||l)&&(g={...g,...(0,i.fetchState)(x.data,e.options)}),"isRestoring"===t._optimisticResults&&(g.fetchStatus="idle")}let{error:y,errorUpdatedAt:b,status:v}=g;s=g.data;let j=!1;if(void 0!==t.placeholderData&&void 0===s&&"pending"===v){let e;o?.isPlaceholderData&&t.placeholderData===h?.placeholderData?(e=o.data,j=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,void 0!==e&&(v="success",s=(0,l.replaceData)(o?.data,e,t),f=!0)}if(t.select&&void 0!==s&&!j)if(o&&s===c?.data&&t.select===this.#o)s=this.#c;else try{this.#o=t.select,s=t.select(s),s=(0,l.replaceData)(o?.data,s,t),this.#c=s,this.#t=null}catch(e){this.#t=e}this.#t&&(y=this.#t,s=this.#c,b=Date.now(),v="error");let S="fetching"===g.fetchStatus,w="pending"===v,R="error"===v,N=w&&S,C=void 0!==s,E={status:v,fetchStatus:g.fetchStatus,isPending:w,isSuccess:"success"===v,isError:R,isInitialLoading:N,isLoading:N,data:s,dataUpdatedAt:g.dataUpdatedAt,error:y,errorUpdatedAt:b,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>m.dataUpdateCount||g.errorUpdateCount>m.errorUpdateCount,isFetching:S,isRefetching:S&&!w,isLoadingError:R&&!C,isPaused:"paused"===g.fetchStatus,isPlaceholderData:f,isRefetchError:R&&C,isStale:p(e,t),refetch:this.refetch,promise:this.#s,isEnabled:!1!==(0,l.resolveEnabled)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=void 0!==E.data,s="error"===E.status&&!t,i=e=>{s?e.reject(E.error):t&&e.resolve(E.data)},a=()=>{i(this.#s=E.promise=(0,n.pendingThenable)())},l=this.#s;switch(l.status){case"pending":e.queryHash===r.queryHash&&i(l);break;case"fulfilled":(s||E.data!==l.value)&&a();break;case"rejected":s&&E.error===l.reason||a()}}return E}updateResult(){let e=this.#a,t=this.createResult(this.#r,this.options);if(this.#n=this.#r.state,this.#l=this.options,void 0!==this.#n.data&&(this.#u=this.#r),(0,l.shallowEqualObjects)(t,e))return;this.#a=t;let s=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,s="function"==typeof t?t():t;if("all"===s||!s&&!this.#m.size)return!0;let r=new Set(s??this.#m);return this.options.throwOnError&&r.add("error"),Object.keys(this.#a).some(t=>this.#a[t]!==e[t]&&r.has(t))};this.#w({listeners:s()})}#b(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#r)return;let t=this.#r;this.#r=e,this.#i=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#g()}#w(e){r.notifyManager.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#a)}),this.#e.getQueryCache().notify({query:this.#r,type:"observerResultsUpdated"})})}};function u(e,t){return!1!==(0,l.resolveEnabled)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==t.retryOnMount)||void 0!==e.state.data&&h(e,t,t.refetchOnMount)}function h(e,t,s){if(!1!==(0,l.resolveEnabled)(t.enabled,e)&&"static"!==(0,l.resolveStaleTime)(t.staleTime,e)){let r="function"==typeof s?s(e):s;return"always"===r||!1!==r&&p(e,t)}return!1}function d(e,t,s,r){return(e!==t||!1===(0,l.resolveEnabled)(r.enabled,e))&&(!s.suspense||"error"!==e.state.status)&&p(e,s)}function p(e,t){return!1!==(0,l.resolveEnabled)(t.enabled,e)&&e.isStaleByTime((0,l.resolveStaleTime)(t.staleTime,e))}e.i(47167);var m=e.i(71645),x=e.i(12598);e.i(43476);var g=m.createContext((t=!1,{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t})),f=m.createContext(!1);f.Provider;var y=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function b(e,t){return function(e,t,s){let i,a=m.useContext(f),n=m.useContext(g),o=(0,x.useQueryClient)(s),c=o.defaultQueryOptions(e);o.getDefaultOptions().queries?._experimental_beforeQuery?.(c);let u=o.getQueryCache().get(c.queryHash);if(c._optimisticResults=a?"isRestoring":"optimistic",c.suspense){let e=e=>"static"===e?e:Math.max(e??1e3,1e3),t=c.staleTime;c.staleTime="function"==typeof t?(...s)=>e(t(...s)):e(t),"number"==typeof c.gcTime&&(c.gcTime=Math.max(c.gcTime,1e3))}i=u?.state.error&&"function"==typeof c.throwOnError?(0,l.shouldThrowError)(c.throwOnError,[u.state.error,u]):c.throwOnError,(c.suspense||c.experimental_prefetchInRender||i)&&!n.isReset()&&(c.retryOnMount=!1),m.useEffect(()=>{n.clearReset()},[n]);let h=!o.getQueryCache().get(c.queryHash),[d]=m.useState(()=>new t(o,c)),p=d.getOptimisticResult(c),b=!a&&!1!==e.subscribed;if(m.useSyncExternalStore(m.useCallback(e=>{let t=b?d.subscribe(r.notifyManager.batchCalls(e)):l.noop;return d.updateResult(),t},[d,b]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),m.useEffect(()=>{d.setOptions(c)},[c,d]),c?.suspense&&p.isPending)throw y(c,d,n);if((({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&void 0===e.data||(0,l.shouldThrowError)(s,[e.error,r])))({result:p,errorResetBoundary:n,throwOnError:c.throwOnError,query:u,suspense:c.suspense}))throw p.error;if(o.getDefaultOptions().queries?._experimental_afterQuery?.(c,p),c.experimental_prefetchInRender&&!l.isServer&&p.isLoading&&p.isFetching&&!a){let e=h?y(c,d,n):u?.promise;e?.catch(l.noop).finally(()=>{d.updateResult()})}return c.notifyOnChangeProps?p:d.trackResult(p)}(e,c,t)}e.s(["useQuery",()=>b],66027);var v=e.i(14272),j=a,S=class extends j.Subscribable{#e;#a=void 0;#R;#N;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#C()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),(0,l.shallowEqualObjects)(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#R,observer:this}),t?.mutationKey&&this.options.mutationKey&&(0,l.hashKey)(t.mutationKey)!==(0,l.hashKey)(this.options.mutationKey)?this.reset():this.#R?.state.status==="pending"&&this.#R.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#R?.removeObserver(this)}onMutationUpdate(e){this.#C(),this.#w(e)}getCurrentResult(){return this.#a}reset(){this.#R?.removeObserver(this),this.#R=void 0,this.#C(),this.#w()}mutate(e,t){return this.#N=t,this.#R?.removeObserver(this),this.#R=this.#e.getMutationCache().build(this.#e,this.options),this.#R.addObserver(this),this.#R.execute(e)}#C(){let e=this.#R?.state??(0,v.getDefaultState)();this.#a={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#w(e){r.notifyManager.batch(()=>{if(this.#N&&this.hasListeners()){let t=this.#a.variables,s=this.#a.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#N.onSuccess?.(e.data,t,s,r)}catch(e){Promise.reject(e)}try{this.#N.onSettled?.(e.data,null,t,s,r)}catch(e){Promise.reject(e)}}else if(e?.type==="error"){try{this.#N.onError?.(e.error,t,s,r)}catch(e){Promise.reject(e)}try{this.#N.onSettled?.(void 0,e.error,t,s,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#a)})})}};function w(e,t){let s=(0,x.useQueryClient)(t),[i]=m.useState(()=>new S(s,e));m.useEffect(()=>{i.setOptions(e)},[i,e]);let a=m.useSyncExternalStore(m.useCallback(e=>i.subscribe(r.notifyManager.batchCalls(e)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),n=m.useCallback((e,t)=>{i.mutate(e,t).catch(l.noop)},[i]);if(a.error&&(0,l.shouldThrowError)(i.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:n,mutateAsync:a.mutate}}e.s(["useMutation",()=>w],54616)},52749,e=>{"use strict";let t="http://localhost:8000",s=async()=>{let e=await fetch(`${t}/api/config`);if(!e.ok)throw Error("Failed to fetch config");return e.json()},r=async e=>{if(!(await fetch(`${t}/api/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok)throw Error("Failed to save config")};e.s(["fetchConfig",0,s,"saveConfig",0,r])},5699,e=>{"use strict";var t=e.i(43476),s=e.i(46932),r=e.i(71645),i=e.i(77183),a=e.i(76590),n=e.i(7311),l=e.i(66027),o=e.i(54616),c=e.i(12598);let u="http://localhost:8000",h=async()=>{let e=await fetch(`${u}/api/keywords`);if(!e.ok)throw Error("Failed to fetch keywords");return e.json()},d=async(e,t=1)=>{let s=await fetch(`${u}/api/keywords`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({term:e,weight:t})});if(!s.ok)throw Error("Failed to add keyword");return s.json()},p=async(e,t)=>{if(!(await fetch(`${u}/api/keywords/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok)throw Error("Failed to update keyword")},m=async e=>{if(!(await fetch(`${u}/api/keywords/${e}`,{method:"DELETE"})).ok)throw Error("Failed to delete keyword")},x=async e=>{if(!(await fetch(`${u}/api/keywords/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:e})})).ok)throw Error("Failed to reorder")},g=["keywords"];function f({keyword:e}){let s,i,{attributes:l,listeners:u,setNodeRef:h,transform:d,transition:x}=(0,a.useSortable)({id:e.id}),f=(s=(0,c.useQueryClient)(),(0,o.useMutation)({mutationFn:({id:e,data:t})=>p(e,t),onSuccess:()=>s.invalidateQueries({queryKey:g})})),y=(i=(0,c.useQueryClient)(),(0,o.useMutation)({mutationFn:m,onSuccess:()=>i.invalidateQueries({queryKey:g})})),[b,v]=(0,r.useState)(!1),[j,S]=(0,r.useState)(!1),[w,R]=(0,r.useState)(e.term),[N,C]=(0,r.useState)(String(e.weight)),E=()=>{f.mutate({id:e.id,data:{term:w}}),v(!1)},O=()=>{f.mutate({id:e.id,data:{weight:parseFloat(N)}}),S(!1)},Q={transform:n.CSS.Transform.toString(d),transition:x};return(0,t.jsxs)("tr",{ref:h,style:Q,className:"group",children:[(0,t.jsx)("td",{className:"w-8",children:(0,t.jsx)("span",{...l,...u,className:"cursor-grab text-g-faint/30 hover:text-g-faint transition-colors select-none",title:"Drag to reorder",children:"⋮⋮"})}),(0,t.jsx)("td",{children:b?(0,t.jsx)("input",{autoFocus:!0,value:w,onChange:e=>R(e.target.value),onBlur:E,onKeyDown:e=>"Enter"===e.key&&E(),className:"g-input h-7 text-sm py-0 w-full"}):(0,t.jsx)("button",{onClick:()=>v(!0),className:"text-sm font-medium text-g-text hover:text-g-green transition-colors text-left",children:e.term})}),(0,t.jsx)("td",{className:"text-center",children:j?(0,t.jsx)("input",{autoFocus:!0,type:"number",step:"0.1",value:N,onChange:e=>C(e.target.value),onBlur:O,onKeyDown:e=>"Enter"===e.key&&O(),className:"g-input h-7 text-sm py-0 w-16 text-center font-mono"}):(0,t.jsxs)("button",{onClick:()=>S(!0),className:"font-mono text-sm text-g-amber hover:text-g-green transition-colors font-semibold",children:[e.weight,"×"]})}),(0,t.jsx)("td",{children:e.ai_target?(0,t.jsx)("span",{className:"text-xs text-g-muted",children:e.ai_target.length>48?e.ai_target.slice(0,48)+"…":e.ai_target}):(0,t.jsx)("span",{className:"text-xs text-g-faint italic",children:"Not set"})}),(0,t.jsx)("td",{children:e.min_price||e.max_price?(0,t.jsx)("span",{className:"text-xs font-mono text-g-muted",children:[e.min_price?`$${e.min_price}`:"",e.max_price?`$${e.max_price}`:""].filter(Boolean).join(" ")}):(0,t.jsx)("span",{className:"text-xs text-g-faint",children:"—"})}),(0,t.jsx)("td",{className:"w-10 text-right",children:(0,t.jsx)("button",{onClick:()=>{confirm(`Delete "${e.term}"?`)&&y.mutate(e.id)},className:"text-g-faint hover:text-g-red transition-colors text-xs opacity-0 group-hover:opacity-100",children:"✕"})})]})}function y(){let e,s,{data:n,isLoading:u}=(0,l.useQuery)({queryKey:g,queryFn:h}),p=(e=(0,c.useQueryClient)(),(0,o.useMutation)({mutationFn:({term:e,weight:t})=>d(e,t),onSuccess:()=>e.invalidateQueries({queryKey:g})})),m=(s=(0,c.useQueryClient)(),(0,o.useMutation)({mutationFn:x,onSuccess:()=>s.invalidateQueries({queryKey:g})})),[y,b]=(0,r.useState)(""),[v,j]=(0,r.useState)("1"),[S,w]=(0,r.useState)(""),[R,N]=(0,r.useState)(!1);return u?(0,t.jsx)("div",{className:"g-card p-5 space-y-3",children:Array.from({length:4}).map((e,s)=>(0,t.jsx)("div",{className:"h-10 bg-g-raised rounded-lg animate-pulse",style:{opacity:1-.2*s}},s))}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"g-card p-4",children:[(0,t.jsxs)("p",{className:"text-xs text-g-faint mb-3 leading-relaxed",children:["Each target is a search label sent to auction sites. Set an ",(0,t.jsx)("span",{className:"text-g-green",children:"AI Description"})," on each target to filter lot titles semantically."]}),(0,t.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,t.jsx)("input",{value:y,onChange:e=>b(e.target.value),onKeyDown:e=>"Enter"===e.key&&y.trim()&&(p.mutate({term:y,weight:parseFloat(v)}),b(""),j("1")),placeholder:"Search term…",className:"g-input h-9 flex-1 min-w-44 text-sm"}),(0,t.jsx)("input",{value:v,onChange:e=>j(e.target.value),type:"number",step:"0.1",placeholder:"Weight",className:"g-input h-9 w-24 text-sm font-mono"}),(0,t.jsx)("button",{onClick:()=>{y.trim()&&(p.mutate({term:y,weight:parseFloat(v)}),b(""),j("1"))},className:"g-btn-primary h-9 text-sm px-4",children:"+ Add"}),(0,t.jsx)("button",{onClick:()=>N(!R),className:"g-btn h-9 text-sm",children:"Batch"})]}),R&&(0,t.jsxs)("div",{className:"mt-3 space-y-2 pt-3 border-t border-g-border/40",children:[(0,t.jsxs)("p",{className:"text-xs text-g-faint",children:["One target per line. Format: ",(0,t.jsx)("code",{className:"text-g-muted",children:"laptop:2"})]}),(0,t.jsx)("textarea",{value:S,onChange:e=>w(e.target.value),placeholder:"laptop:2\nRTX 4090:3\niPhone 15",rows:4,className:"g-input text-sm font-mono resize-none"}),(0,t.jsx)("button",{onClick:()=>{S.split("\n").map(e=>e.trim()).filter(Boolean).forEach(e=>{let[t,s]=e.split(":");p.mutate({term:t.trim(),weight:parseFloat(s||"1")})}),w(""),N(!1)},className:"g-btn-primary text-sm",children:"Import all"})]})]}),(0,t.jsx)("div",{className:"g-card overflow-hidden",children:(0,t.jsx)(i.DndContext,{collisionDetection:i.closestCenter,onDragEnd:({active:e,over:t})=>{if(!t||e.id===t.id||!n)return;let s=n.map(e=>e.id),r=s.indexOf(Number(e.id)),i=s.indexOf(Number(t.id)),a=[...s];a.splice(i,0,a.splice(r,1)[0]),m.mutate(a)},children:(0,t.jsx)(a.SortableContext,{items:(n??[]).map(e=>e.id),strategy:a.verticalListSortingStrategy,children:(0,t.jsxs)("div",{className:"overflow-x-auto",children:[(0,t.jsxs)("table",{className:"g-table",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"w-8"}),(0,t.jsx)("th",{children:"Target label"}),(0,t.jsx)("th",{className:"text-center",children:"Weight"}),(0,t.jsx)("th",{children:"AI description"}),(0,t.jsx)("th",{children:"Price filter"}),(0,t.jsx)("th",{className:"w-10"})]})}),(0,t.jsx)("tbody",{children:(n??[]).map(e=>(0,t.jsx)(f,{keyword:e},e.id))})]}),!(n??[]).length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-g-faint gap-2",children:[(0,t.jsx)("span",{className:"text-3xl opacity-20",children:"⌖"}),(0,t.jsx)("p",{className:"text-sm",children:"No targets yet — add one above"})]})]})})})})]})}let b="http://localhost:8000/api";async function v(){let e=await fetch(`${b}/scoring-rules`);if(!e.ok)throw Error("Failed to fetch scoring rules");return e.json()}async function j(e,t,s){let r=await fetch(`${b}/scoring-rules`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({signal:e,delta:t,notes:s})});if(!r.ok)throw Error((await r.json().catch(()=>({}))).error||"Failed to create rule");return r.json()}async function S(e,t){let s=await fetch(`${b}/scoring-rules/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw Error("Failed to update rule");return s.json()}async function w(e){if(!(await fetch(`${b}/scoring-rules/${e}`,{method:"DELETE"})).ok)throw Error("Failed to delete rule")}var R=e.i(52749),N=e.i(47163);function C(){let e=(0,c.useQueryClient)(),{data:s=[],isLoading:i}=(0,l.useQuery)({queryKey:["scoring-rules"],queryFn:v}),[a,n]=(0,r.useState)(!0),[u,h]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(0,R.fetchConfig)().then(e=>{n((e.scoring_enabled??"true")!=="false")})},[]);let d=async()=>{h(!0);let e=!a;await (0,R.saveConfig)({scoring_enabled:String(e)}),n(e),h(!1)},[p,m]=(0,r.useState)(""),[x,g]=(0,r.useState)(""),[f,y]=(0,r.useState)(""),[b,C]=(0,r.useState)(""),[O,Q]=(0,r.useState)(null),[T,I]=(0,r.useState)(""),[k,F]=(0,r.useState)(""),D=()=>e.invalidateQueries({queryKey:["scoring-rules"]}),M=(0,o.useMutation)({mutationFn:()=>j(p.trim(),parseInt(x),f.trim()||void 0),onSuccess:()=>{m(""),g(""),y(""),C(""),D()},onError:e=>C(e.message)}),P=(0,o.useMutation)({mutationFn:()=>S(O,{signal:T.trim(),delta:parseInt(k)}),onSuccess:()=>{Q(null),D()}}),_=(0,o.useMutation)({mutationFn:e=>w(e),onSuccess:D}),U=s.filter(e=>e.delta>0),q=s.filter(e=>e.delta<0);return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-g-text",children:"Scoring Rules"}),(0,t.jsx)("p",{className:"text-xs text-g-faint mt-0.5",children:"Token signals that boost (+) or penalise () lot scores"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,t.jsx)("span",{className:"text-xs text-g-faint",children:"Scoring"}),(0,t.jsx)("button",{onClick:d,disabled:u,className:(0,N.cn)("g-btn text-xs h-7",a&&"!border-g-green/40 !text-g-green !bg-g-green/8"),children:a?"On":"Off"})]})]}),!a&&(0,t.jsxs)("div",{className:"g-card border-g-green/20 bg-g-green/4 px-4 py-3 text-xs text-g-green space-y-1",children:[(0,t.jsx)("div",{className:"font-semibold",children:"AI-first mode active"}),(0,t.jsx)("div",{className:"text-g-muted leading-relaxed",children:"Score signals are disabled. The AI description on each target is the sole judge. Set an AI Description on every target and enable AI Filter in Settings."})]}),(0,t.jsxs)("div",{className:(0,N.cn)(a?"":"opacity-40 pointer-events-none select-none","space-y-4"),children:[(0,t.jsxs)("form",{className:"g-card p-4 flex gap-2 flex-wrap items-end",onSubmit:e=>{e.preventDefault(),p&&x&&M.mutate()},children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{className:"text-[10px] uppercase tracking-widest text-g-faint",children:"Signal"}),(0,t.jsx)("input",{className:"g-input h-8 w-32 text-sm",placeholder:"RTX",value:p,onChange:e=>m(e.target.value)})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("label",{className:"text-[10px] uppercase tracking-widest text-g-faint",children:"Delta"}),(0,t.jsx)("input",{type:"number",className:"g-input h-8 w-20 text-sm font-mono",placeholder:"+10",value:x,onChange:e=>g(e.target.value)})]}),(0,t.jsxs)("div",{className:"space-y-1 flex-1 min-w-36",children:[(0,t.jsx)("label",{className:"text-[10px] uppercase tracking-widest text-g-faint",children:"Notes"}),(0,t.jsx)("input",{className:"g-input h-8 text-sm",placeholder:"GPU keyword",value:f,onChange:e=>y(e.target.value)})]}),(0,t.jsx)("button",{type:"submit",disabled:!p||!x||M.isPending,className:"g-btn-primary h-8 text-xs disabled:opacity-40",children:"+ Add rule"}),b&&(0,t.jsx)("span",{className:"text-xs text-g-red w-full",children:b})]}),i&&(0,t.jsx)("p",{className:"text-xs text-g-faint",children:"Loading…"}),U.length>0&&(0,t.jsxs)("div",{className:"g-card overflow-hidden",children:[(0,t.jsxs)("div",{className:"px-4 py-2.5 border-b border-g-border/50 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-g-green"}),(0,t.jsx)("span",{className:"text-xs font-medium text-g-green uppercase tracking-wider",children:"Boosts"})]}),(0,t.jsxs)("table",{className:"g-table",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"Signal"}),(0,t.jsx)("th",{children:"Delta"}),(0,t.jsx)("th",{children:"Notes"}),(0,t.jsx)("th",{className:"w-10"})]})}),(0,t.jsx)("tbody",{children:U.map(e=>(0,t.jsx)(E,{rule:e,editId:O,editSignal:T,editDelta:k,setEditId:Q,setEditSignal:I,setEditDelta:F,onSave:()=>P.mutate(),onDelete:()=>_.mutate(e.id)},e.id))})]})]}),q.length>0&&(0,t.jsxs)("div",{className:"g-card overflow-hidden",children:[(0,t.jsxs)("div",{className:"px-4 py-2.5 border-b border-g-border/50 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-g-red"}),(0,t.jsx)("span",{className:"text-xs font-medium text-g-red uppercase tracking-wider",children:"Penalties"})]}),(0,t.jsxs)("table",{className:"g-table",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"Signal"}),(0,t.jsx)("th",{children:"Delta"}),(0,t.jsx)("th",{children:"Notes"}),(0,t.jsx)("th",{className:"w-10"})]})}),(0,t.jsx)("tbody",{children:q.map(e=>(0,t.jsx)(E,{rule:e,editId:O,editSignal:T,editDelta:k,setEditId:Q,setEditSignal:I,setEditDelta:F,onSave:()=>P.mutate(),onDelete:()=>_.mutate(e.id)},e.id))})]})]})]})]})}function E({rule:e,editId:s,editSignal:r,editDelta:i,setEditId:a,setEditSignal:n,setEditDelta:l,onSave:o,onDelete:c}){return s===e.id?(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:(0,t.jsx)("input",{className:"g-input h-7 text-sm w-28",value:r,onChange:e=>n(e.target.value)})}),(0,t.jsx)("td",{children:(0,t.jsx)("input",{type:"number",className:"g-input h-7 text-sm font-mono w-16",value:i,onChange:e=>l(e.target.value)})}),(0,t.jsx)("td",{className:"text-xs text-g-faint",children:e.notes||"—"}),(0,t.jsxs)("td",{className:"flex gap-2 items-center",children:[(0,t.jsx)("button",{onClick:o,className:"g-btn text-xs h-7",children:"Save"}),(0,t.jsx)("button",{onClick:()=>a(null),className:"text-g-faint hover:text-g-text text-xs",children:"×"})]})]}):(0,t.jsxs)("tr",{className:"group",children:[(0,t.jsx)("td",{children:(0,t.jsx)("button",{className:"text-sm text-g-text hover:text-g-green transition-colors font-medium",onClick:()=>{a(e.id),n(e.signal),l(String(e.delta))},children:e.signal})}),(0,t.jsx)("td",{children:(0,t.jsxs)("span",{className:(0,N.cn)("font-mono text-sm font-bold",e.delta>0?"text-g-green":"text-g-red"),children:[e.delta>0?"+":"",e.delta]})}),(0,t.jsx)("td",{className:"text-xs text-g-faint",children:e.notes||"—"}),(0,t.jsx)("td",{children:(0,t.jsx)("button",{onClick:c,className:"text-g-faint hover:text-g-red transition-colors text-xs opacity-0 group-hover:opacity-100",children:"✕"})})]})}function O(){return(0,t.jsxs)("div",{className:"space-y-7",children:[(0,t.jsxs)(s.motion.div,{initial:{opacity:1,y:-8},animate:{opacity:1,y:0},transition:{duration:.4},children:[(0,t.jsx)("h1",{className:"g-page-title",children:"Targets"}),(0,t.jsx)("p",{className:"g-page-sub",children:"Search labels and AI descriptions — AI accepts or rejects lots per target"})]}),(0,t.jsx)(y,{}),(0,t.jsx)("div",{className:"glow-line"}),(0,t.jsx)(C,{})]})}e.s(["default",()=>O],5699)}]);