PageSourceSearch

https://www.bittradehq.ai/static/js/945.cfd7114f.chunk.js

js bittradehq.ai collected 2026-10-05 13:30:35 UTC 22,629 bytes, 3 lines download raw bytes

1/*! For license information please see 945.cfd7114f.chunk.js.LICENSE.txt */
2"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[945],{9855(e,t,a){a.d(t,{A:()=>s});const s=(0,a(77784).A)("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},27899(e,t,a){a.d(t,{A:()=>s});const s=(0,a(77784).A)("arrow-down-right",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]])},39292(e,t,a){a.d(t,{A:()=>s});const s=(0,a(77784).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},60945(e,t,a){a.r(t),a.d(t,{default:()=>R});var s=a(89379),l=a(65043),r=a(45685),n=a(79722),c=a(69284),i=a(13390),o=a(92264),d=a(56328),x=a(33033),h=a(22024),m=a(37719),p=a(27899),u=a(65469),b=a(67010),j=a(75088),g=a(71360),f=a(50516),v=a(88693),N=a(23165),y=a(9855),w=a(40614),k=a(20073),A=a(91122),C=a(70579);const _=["#f59e0b","#3b82f6","#10b981","#ef4444","#8b5cf6","#06b6d4","#f97316","#ec4899","#14b8a6","#6366f1"];function S(e){let{allocations:t}=e;if(null===t||void 0===t||!t.length)return null;let a=0;const l=t.map((e,t)=>{const l=a;return a+=e.target_pct,(0,s.A)((0,s.A)({},e),{},{start:l,end:a,color:_[t%_.length]})});return(0,C.jsxs)("div",{className:"relative w-40 h-40 mx-auto",children:[(0,C.jsx)("svg",{viewBox:"0 0 36 36",className:"w-full h-full -rotate-90",children:l.map((e,t)=>{const a="".concat(e.target_pct," ").concat(100-e.target_pct),s=100-e.start;return(0,C.jsx)("circle",{cx:"18",cy:"18",r:"15.9155",fill:"transparent",stroke:e.color,strokeWidth:"3.5",strokeDasharray:a,strokeDashoffset:s},t)})}),(0,C.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,C.jsxs)("span",{className:"text-xs text-slate-400",children:[t.length," assets"]})})]})}function R(e){let{auth:t}=e;const a=(0,r.Zp)(),R=(null===t||void 0===t?void 0:t.token)||localStorage.getItem("token"),M={Authorization:"Bearer ".concat(R)},[T,F]=(0,l.useState)(null),[E,D]=(0,l.useState)(null),[L,P]=(0,l.useState)([]),[$,z]=(0,l.useState)(!0),[U,H]=(0,l.useState)(!1),[B,V]=(0,l.useState)(!1),[q,I]=(0,l.useState)(!1),[K,O]=(0,l.useState)(!1),[W,Z]=(0,l.useState)(null),[G,J]=(0,l.useState)("My Portfolio"),[Q,X]=(0,l.useState)([{asset:"BTC",target_pct:50},{asset:"ETH",target_pct:30},{asset:"SOL",target_pct:20}]),[Y,ee]=(0,l.useState)(5),[te,ae]=(0,l.useState)(!1),[se,le]=(0,l.useState)(24),re=(0,l.useCallback)(async()=>{try{var e;const[t,a,s,l]=await Promise.all([n.A.get("".concat(c.nC,"/rebalance/config"),{headers:M}),n.A.get("".concat(c.nC,"/rebalance/status"),{headers:M}),n.A.get("".concat(c.nC,"/rebalance/history"),{headers:M}),n.A.get("".concat(c.nC,"/rebalance/auto/status"),{headers:M}).catch(()=>({data:{}}))]);F(t.data),D(a.data),P(s.data.trades||[]),Z(l.data),t.data.has_config&&null!==(e=t.data.allocations)&&void 0!==e&&e.length&&(J(t.data.name||"My Portfolio"),X(t.data.allocations),ee(t.data.drift_threshold||5),ae(t.data.auto_rebalance||!1),le(t.data.auto_interval_hours||24))}catch(t){console.error("Failed to load rebalancing data:",t)}finally{z(!1)}},[R]);(0,l.useEffect)(()=>{re()},[re]);const ne=Q.reduce((e,t)=>e+(parseFloat(t.target_pct)||0),0),ce=async(e,t)=>{O(!0);try{const a=await n.A.post("".concat(c.nC,"/rebalance/auto"),{enabled:e,interval_hours:t||se},{headers:M});d.oR.success(a.data.message),ae(e),t&&le(t),re()}catch(l){var a,s;d.oR.error((null===(a=l.response)||void 0===a||null===(s=a.data)||void 0===s?void 0:s.detail)||"Failed to update auto-rebalance")}finally{O(!1)}},ie=(e,t,a)=>{X(Q.map((l,r)=>r===e?(0,s.A)((0,s.A)({},l),{},{[t]:a}):l))};return $?(0,C.jsx)("div",{className:"flex items-center justify-center h-96",children:(0,C.jsx)(h.A,{className:"w-8 h-8 animate-spin text-sky-400"})}):(0,C.jsxs)("div",{className:"space-y-6 p-4 md:p-6 max-w-6xl mx-auto","data-testid":"rebalancing-page",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[(0,C.jsxs)("div",{className:"flex items-center gap-3",children:[(0,C.jsx)("button",{onClick:()=>
2a("/dashboard"),className:"text-slate-400 hover:text-white transition-colors",children:(0,C.jsx)(u.A,{className:"w-5 h-5"})}),(0,C.jsxs)("div",{children:[(0,C.jsxs)("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight flex items-center gap-2",children:[(0,C.jsx)(x.A,{className:"w-7 h-7 text-sky-400"})," Portfolio Rebalancing"]}),(0,C.jsx)("p",{className:"text-sm text-slate-400 mt-0.5",children:"Auto-maintain target asset allocations"})]})]}),(0,C.jsx)(i.$,{onClick:()=>I(!q),variant:"outline",className:"border-white/10","data-testid":"toggle-edit-btn",children:q?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(w.A,{className:"w-4 h-4 mr-2"})," Cancel"]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(N.A,{className:"w-4 h-4 mr-2"})," Edit Targets"]})})]}),(0,C.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,C.jsxs)("div",{className:"lg:col-span-1 space-y-4",children:[(0,C.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-5","data-testid":"allocation-chart",children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-slate-400 mb-3",children:"Target Allocation"}),(0,C.jsx)(S,{allocations:Q}),(0,C.jsx)("div",{className:"mt-4 space-y-1.5",children:Q.map((e,t)=>(0,C.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,C.jsx)("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:_[t%_.length]}}),(0,C.jsx)("span",{className:"text-white font-medium",children:e.asset}),(0,C.jsxs)("span",{className:"text-slate-400 ml-auto",children:[e.target_pct,"%"]})]},t))})]}),(null===T||void 0===T?void 0:T.has_config)&&(0,C.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-5","data-testid":"config-info",children:[(0,C.jsx)("h3",{className:"text-sm font-medium text-slate-400 mb-2",children:"Settings"}),(0,C.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,C.jsxs)("div",{className:"flex justify-between",children:[(0,C.jsx)("span",{className:"text-slate-400",children:"Drift Threshold"}),(0,C.jsxs)("span",{className:"text-white",children:[T.drift_threshold,"%"]})]}),(0,C.jsxs)("div",{className:"flex justify-between",children:[(0,C.jsx)("span",{className:"text-slate-400",children:"Last Rebalance"}),(0,C.jsx)("span",{className:"text-white",children:T.last_rebalance?new Date(T.last_rebalance).toLocaleDateString():"Never"})]})]})]}),(null===T||void 0===T?void 0:T.has_config)&&(0,C.jsxs)("div",{className:"backdrop-blur-xl border rounded-xl p-5 ".concat(te?"bg-emerald-500/5 border-emerald-500/20":"bg-slate-900/60 border-white/10"),"data-testid":"auto-rebalance-panel",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,C.jsxs)("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[(0,C.jsx)(f.A,{className:"w-4 h-4 ".concat(te?"text-emerald-400":"text-slate-400")}),"Auto-Rebalance"]}),(0,C.jsx)("button",{onClick:()=>ce(!te),disabled:K,"data-testid":"auto-rebalance-toggle",className:"relative inline-flex h-6 w-11 items-center rounded-full transition-colors ".concat(te?"bg-emerald-500":"bg-slate-700"),children:(0,C.jsx)("span",{className:"inline-block h-4 w-4 transform rounded-full bg-white transition-transform ".concat(te?"translate-x-6":"translate-x-1")})})]}),te?(0,C.jsxs)("div",{className:"space-y-2",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)("label",{className:"text-xs text-slate-400",children:"Check every:"}),(0,C.jsxs)("select",{value:se,onChange:e=>{const t=parseInt(e.target.value);le(t),ce(!0,t)},className:"bg-slate-800/50 border border-white/10 rounded px-2 py-1 text-xs text-white","data-testid":"auto-interval-select",children:[(0,C.jsx)("option",{value:4,children:"4 hours"}),(0,C.jsx)("option",{value:8,children:"8 hours"}),(0,C.jsx)("option",{value:12,children:"12 hours"}),(0,C.jsx)("option",{value:24,children:"24 hours"}),(0,C.jsx)("option",{value:48,children:"48 hours"}),(0,C.jsx)("option",{value:168,children:"Weekly"})]})]}),(null===W||void 0===W?void 0:W.next_check)&&(0,C.jsxs)("p",{className:"text-[10px] text-slate-500",children:["Next check: ",new Date(W.next_check).toLocaleStr
2ing()]}),(null===W||void 0===W?void 0:W.auto_trades_count)>0&&(0,C.jsxs)("p",{className:"text-[10px] text-emerald-400",children:[W.auto_trades_count," auto trades executed"]})]}):(0,C.jsx)("p",{className:"text-xs text-slate-500",children:"Enable to automatically rebalance when drift exceeds threshold"})]})]}),(0,C.jsx)("div",{className:"lg:col-span-2 space-y-4",children:q?(0,C.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-6","data-testid":"allocation-editor",children:[(0,C.jsx)("h3",{className:"font-semibold text-white mb-4",children:"Configure Target Allocations"}),(0,C.jsxs)("div",{className:"mb-4",children:[(0,C.jsx)("label",{className:"text-xs text-slate-500 block mb-1",children:"Portfolio Name"}),(0,C.jsx)(o.p,{value:G,onChange:e=>J(e.target.value),className:"bg-slate-800/50 border-white/10 max-w-xs","data-testid":"portfolio-name-input"})]}),(0,C.jsx)("div",{className:"space-y-2 mb-4",children:Q.map((e,t)=>(0,C.jsxs)("div",{className:"flex items-center gap-3","data-testid":"allocation-row-".concat(t),children:[(0,C.jsx)("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:_[t%_.length]}}),(0,C.jsx)("div",{className:"w-32",children:(0,C.jsx)(A.A,{value:e.asset,onChange:e=>ie(t,"asset",e.toUpperCase()),placeholder:"Search asset...",className:"h-8 text-xs"})}),(0,C.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,C.jsx)(o.p,{type:"number",value:e.target_pct,onChange:e=>ie(t,"target_pct",parseFloat(e.target.value)||0),className:"bg-slate-800/50 border-white/10 w-20 font-mono",min:"0",max:"100",step:"1","data-testid":"pct-input-".concat(t)}),(0,C.jsx)("span",{className:"text-slate-400 text-sm",children:"%"})]}),Q.length>2&&(0,C.jsx)(i.$,{variant:"ghost",size:"sm",onClick:()=>{return e=t,void X(Q.filter((t,a)=>a!==e));var e},className:"text-red-400 hover:bg-red-500/10","data-testid":"remove-alloc-".concat(t),children:(0,C.jsx)(y.A,{className:"w-3.5 h-3.5"})})]},t))}),(0,C.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,C.jsxs)(i.$,{variant:"ghost",size:"sm",onClick:()=>{X([...Q,{asset:"",target_pct:0}])},className:"text-sky-400","data-testid":"add-asset-btn",children:[(0,C.jsx)(g.A,{className:"w-4 h-4 mr-1"})," Add Asset"]}),(0,C.jsxs)("span",{className:"text-sm font-mono ".concat(Math.abs(ne-100)<.1?"text-emerald-400":"text-red-400"),children:["Total: ",ne.toFixed(1),"%"]})]}),(0,C.jsxs)("div",{className:"mb-4",children:[(0,C.jsx)("label",{className:"text-xs text-slate-500 block mb-1",children:"Drift Threshold (%)"}),(0,C.jsx)(o.p,{type:"number",value:Y,onChange:e=>ee(parseFloat(e.target.value)||5),className:"bg-slate-800/50 border-white/10 w-24 font-mono",min:"1",max:"50",step:"1","data-testid":"drift-threshold-input"}),(0,C.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:"Rebalance when any asset drifts more than this from target"})]}),(0,C.jsxs)(i.$,{onClick:async()=>{if(Math.abs(ne-100)>.1)return d.oR.error("Allocations must sum to 100%. Current: ".concat(ne.toFixed(1),"%"));if(Q.length<2)return d.oR.error("At least 2 assets required");H(!0);try{const e=await n.A.post("".concat(c.nC,"/rebalance/config"),{name:G,allocations:Q.map(e=>({asset:e.asset.toUpperCase(),target_pct:parseFloat(e.target_pct)})),drift_threshold:parseFloat(Y)},{headers:M});d.oR.success(e.data.message),I(!1),re()}catch(a){var e,t;d.oR.error((null===(e=a.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||"Failed to save")}finally{H(!1)}},disabled:U,className:"bg-sky-500 hover:bg-sky-600","data-testid":"save-config-btn",children:[U?(0,C.jsx)(h.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,C.jsx)(v.A,{className:"w-4 h-4 mr-2"}),"Save Configuration"]})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl overflow-hidden","data-testid":"drift-table",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-white/5",children:[(0,C.jsxs)("h3",{className:"font-semibold text-white flex items-center gap-2",children:[(0,C.jsx)(N.A,{className:"w-4 h-4 text-sky-400"})," Current Drift",(null===E||void 0===E?void 0:E.needs_rebalance)&&(0,C.jsx)("span",{className:"text-xs bg-amber-500/15 text-amber-400 px-2 py-0.5 rounded-full ml-2",children:"Rebalance needed"})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(null===E||void 0===E?void 0:E.total_value)>0&&(0,C.jsxs)("span",{className:"text-sm text-emerald-400 font-mono",children:["$",E.total_value.toLocaleStr
2ing()]}),(0,C.jsx)(i.$,{variant:"ghost",size:"sm",onClick:re,"data-testid":"refresh-status-btn",children:(0,C.jsx)(f.A,{className:"w-4 h-4"})})]})]}),null!==E&&void 0!==E&&E.has_config?(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)("table",{className:"w-full text-sm",children:[(0,C.jsx)("thead",{children:(0,C.jsxs)("tr",{className:"text-xs text-slate-500 border-b border-white/5",children:[(0,C.jsx)("th",{className:"text-left px-4 py-3",children:"Asset"}),(0,C.jsx)("th",{className:"text-right px-4 py-3",children:"Target"}),(0,C.jsx)("th",{className:"text-right px-4 py-3",children:"Current"}),(0,C.jsx)("th",{className:"text-right px-4 py-3",children:"Drift"}),(0,C.jsx)("th",{className:"text-right px-4 py-3",children:"Action"}),(0,C.jsx)("th",{className:"text-right px-4 py-3",children:"Amount"})]})}),(0,C.jsx)("tbody",{children:((null===E||void 0===E?void 0:E.actions)||[]).map((e,t)=>(0,C.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/[0.02]","data-testid":"drift-row-".concat(t),children:[(0,C.jsx)("td",{className:"px-4 py-3 font-medium text-white",children:e.asset}),(0,C.jsxs)("td",{className:"px-4 py-3 text-right font-mono text-slate-300",children:[e.target_pct,"%"]}),(0,C.jsxs)("td",{className:"px-4 py-3 text-right font-mono text-white",children:[e.current_pct,"%"]}),(0,C.jsxs)("td",{className:"px-4 py-3 text-right font-mono font-semibold ".concat(Math.abs(e.drift)>(E.drift_threshold||5)?"text-amber-400":"text-slate-400"),children:[e.drift>0?"+":"",e.drift,"%"]}),(0,C.jsx)("td",{className:"px-4 py-3 text-right",children:e.needs_action?(0,C.jsxs)("span",{className:"text-xs font-medium ".concat("buy"===e.side?"text-emerald-400":"text-red-400"),children:["buy"===e.side?(0,C.jsx)(b.A,{className:"w-3 h-3 inline"}):(0,C.jsx)(p.A,{className:"w-3 h-3 inline"})," ",e.side.toUpperCase()]}):(0,C.jsx)("span",{className:"text-xs text-slate-500",children:"OK"})}),(0,C.jsx)("td",{className:"px-4 py-3 text-right font-mono text-sm",children:e.needs_action?"$".concat(e.amount_usd.toLocaleString()):"\u2014"})]},t))})]})}):(0,C.jsxs)("div",{className:"p-8 text-center text-slate-500 text-sm","data-testid":"no-config",children:[(0,C.jsx)(N.A,{className:"w-10 h-10 mx-auto mb-3 text-slate-600"}),(0,C.jsx)("p",{children:"No allocation targets configured yet."}),(0,C.jsx)("p",{className:"mt-1",children:'Click "Edit Targets" to set up your portfolio allocations.'})]})]}),(null===E||void 0===E?void 0:E.needs_rebalance)&&(0,C.jsxs)("div",{className:"backdrop-blur-xl bg-
2amber-500/5 border border-amber-500/20 rounded-xl p-5 flex items-center justify-between","data-testid":"rebalance-cta",children:[(0,C.jsxs)("div",{children:[(0,C.jsxs)("p",{className:"text-white font-medium flex items-center gap-2",children:[(0,C.jsx)(m.A,{className:"w-4 h-4 text-amber-400"}),"Portfolio drift detected (max ",E.max_drift,"%)"]}),(0,C.jsx)("p",{className:"text-xs text-slate-400 mt-1",children:"Execute rebalancing trades to return to target allocations"})]}),(0,C.jsxs)(i.$,{onClick:async()=>{V(!0);try{const e=await n.A.post("".concat(c.nC,"/rebalance/execute"),{},{headers:M});d.oR.success(e.data.message),re()}catch(a){var e,t;d.oR.error((null===(e=a.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||"Rebalance failed")}finally{V(!1)}},disabled:B,className:"bg-amber-500 hover:bg-amber-600 text-black font-semibold","data-testid":"execute-rebalance-btn",children:[B?(0,C.jsx)(h.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,C.jsx)(k.A,{className:"w-4 h-4 mr-2"}),"Rebalance Now"]})]}),L.length>0&&(0,C.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl overflow-hidden","data-testid":"rebalance-history",children:[(0,C.jsx)("div",{className:"p-4 border-b border-white/5",children:(0,C.jsxs)("h3",{className:"font-semibold text-white flex items-center gap-2",children:[(0,C.jsx)(j.A,{className:"w-4 h-4 text-slate-400"})," Rebalance History"]})}),(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)("table",{className:"w-full text-sm",children:[(0,C.jsx)("thead",{children:(0,C.jsxs)("tr",{className:"text-xs text-slate-500 border-b border-white/5",children:[(0,C.jsx)("th",{className:"text-left px-4 py-3",children:"Time"}),(0,C.jsx)("th",{className:"text-left px-4 py-3",children:"Asset"}),(0,C.jsx)("th",{className:"text-left px-4 py-3",children:"Side"}),(0,C.jsx)("th",{className:"text-right px-4 py-3",children:"Amount"}),(0,C.jsx)("th",{className:"text-left px-4 py-3",children:"Status"})]})}),(0,C.jsx)("tbody",{children:L.map((e,t)=>{var a;return(0,C.jsxs)("tr",{className:"border-b border-white/5","data-testid":"history-row-".concat(t),children:[(0,C.jsx)("td",{className:"px-4 py-3 text-xs text-slate-400 font-mono",children:new Date(e.created_at).toLocaleString()}),(0,C.jsx)("td",{className:"px-4 py-3 font-medium text-white",children:e.asset}),(0,C.jsx)("td",{className:"px-4 py-3 font-semibold ".concat("buy"===e.side?"text-emerald-400":"text-red-400"),children:e.side.toUpperCase()}),(0,C.jsxs)("td",{className:"px-4 py-3 text-right font-mono",children:["$",null===(a=e.amount_usd)||void 0===a?void 0:a.toLocaleString()]}),(0,C.jsx)("td",{className:"px-4 py-3",children:(0,C.jsx)("span",{className:"text-xs text-emerald-400 bg-emerald-500/10 px-2 py-0.5 rounded",children:e.status})})]},t)})})]})})]})]})})]})]})}},67010(e,t,a){a.d(t,{A:()=>s});const s=(0,a(77784).A)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]])},71360(e,t,a){a.d(t,{A:()=>s});const s=(0,a(77784).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},88693(e,t,a){a.d(t,{A:()=>s});const s=(0,a(77784).A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},91122(e,t,a){a.d(t,{A:()=>x});var s=a(65043),l=a(92382),r=a(55731),n=a(39292),c=a(40614),i=a(79722),o=a(69284),d=a(70579);function x(e){let{value:t,onChange:a,assetType:x,placeholder:h,className:m}=e;const[p,u]=(0,s.useState)(!1),[b,j]=(0,s.useState)(""),[g,f]=(0,s.useState)([]),[v,N]=(0,s.useState)(!1),y=(0,s.useRef)(null),w=(0,s.useRef)(null),k=localStorage.getItem("token"),A=(0,s.useRef)(0),C=(0,s.useCallback)(async e=>{const t=++A.current;N(!0);try{const a=new URLSearchParams;x&&a.set("asset_type",x),e&&a.set("search",e);const{data:s}=await i.A.get("".concat(o.nC,"/market/pairs?").concat(a),{headers:{Authorization:"Bearer ".concat(k)}});t===A.current&&f(s.pairs||[])}catch(a){t===A.current&&f([])}t===A.current&&N(!1)},[x,k]);(0,s.useEffect)(()=>{f([]),j(""),C("")},[C]),(0,s.useEffect)(()=>{const e=setTimeout(()=>{b.length>=1&&C(b)},200);return()=>clearTimeout(e)},[b,C]),(0,s.useEffect)(()=>{const e=e=>{w.current&&!w.current.contains(e.target)&&(u(!1),j(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const _=e=>{a(e),j(""),u(!1)};return(0,d.jsxs)("div",{className:"relative",ref:w,"data-testid":"trading-pair-input",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 bg-slate-800/50 border border-white/10 rounded-md px-3 h-9 cursor-text ".concat(m||""),onClick:()=>{var e;null===(e=y.current)||void 0===e||e.focus(),u(!0)},children:[(0,d.jsx)(n.A,{className:"w-3.5 h-3.5 text-gray-500 shrink-0"}),(0,d.jsx)("input",{ref:y,value:p?b||"":t||"",onChange:e=>{const t=e.target.value.toUpperCase();j(t),p||u(!0)},onFocus:()=>u(!0),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),b&&(a(b.toUpperCase()),j(""),u(!1))),"Escape"===e.key&&(u(!1),j(""))},placeholder:t||h||"Search or type any pair...",className:"bg-transparent text-sm text-white flex-1 outline-none placeholder-gray-600 w-full","data-testid":"pair-search-input"}),t&&!p&&(0,d.jsx)(c.A,{className:"w-3.5 h-3.5 text-gray-500 hover:text-white cursor-pointer shrink-0",onClick:e=>{e.stopPropagation(),a(""),j("")}}),(0,d.jsx)(l.A,{className:"w-3.5 h-3.5 text-gray-500 shrink-0 transition-transform ".concat(p?"rotate-180":"")})]}),p&&(0,d.jsxs)("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-slate-900 border border-white/10 rounded-md shadow-xl","data-testid":"pair-dropdown",children:[b&&!g.find(e=>e.symbol===b)&&(0,d.jsxs)("div",{className:"px-3 py-2 flex items-center gap-2 hover:bg-slate-800 cursor-pointer border-b border-white/5",onClick:()=>_(b),"data-testid":"pair-custom-option",children:[(0,d.jsx)(r.A,{className:"w-3.5 h-3.5 text-cyan-400"}),(0,d.jsxs)("span",{className:"text-sm text-cyan-400",children:["Use custom pair: ",(0,d.jsx)("strong",{children:b})]})]}),v?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-gray-500 text-center",children:"Loading pairs..."}):0!==g.length||b?g.slice(0,30).map(e=>(0,d.jsxs)("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-slate-800 cursor-pointer ".concat(e.symbol===t?"bg-slate-800/70":""),onClick:()=>_(e.symbol),"data-testid":"pair-option-".concat(e.symbol.replace(/\//g,"-")),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-sm font-mono text-white",children:e.symbol}),(0,d.jsx)("span",{className:"text-xs text-gray-500",children:e.name})]}),e.quote&&(0,d.jsx)("span",{className:"text-[10px] text-gray-600",children:e.quote})]},e.symbol)):(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-gray-500 text-center",children:"Type to search for any trading pair"})]})]})}}}]);
3//# sourceMappingURL=945.cfd7114f.chunk.js.map

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.