1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[333],{11935:(t,e,r)=>{r.d(e,{xP:()=>X,QH:()=>q,ye:()=>I,AP:()=>c,w0:()=>f,St:()=>p});var n=r(62695),i=r(20623);let a=new Set(["!","?",".",",",":",";"]);function o(t){return"text"===t.type}function s(t){let e=[];for(let r of t){if(o(r)){if(!r.text)continue;let t=e.at(-1);if(t&&o(t)){t.text+=r.text;continue}}e.push(r)}return e}function l(t){var e;let r=null==t||null==(e=t.blocks)?void 0:e.find(t=>"paragraph"===t.type),n=Array.isArray(null==r?void 0:r.content)?r.content:[],i=[];for(let t of n)if(t&&"object"==typeof t&&"string"==typeof t.type){if("text"===t.type){i.push({type:"text",text:"string"==typeof t.text?t.text:""});continue}if("mention"===t.type&&t.attrs&&"string"==typeof t.attrs.username){i.push({type:"mention",attrs:{username:t.attrs.username}});continue}if("watchlist_embed"===t.type&&t.attrs&&"string"==typeof t.attrs.watchlist_id&&"string"==typeof t.attrs.watchlist_name&&"string"==typeof t.attrs.watchlist_color&&"string"==typeof t.attrs.owner_username){i.push({type:"watchlist_embed",attrs:{watchlist_id:t.attrs.watchlist_id,watchlist_name:t.attrs.watchlist_name,watchlist_color:t.attrs.watchlist_color,owner_username:t.attrs.owner_username}});continue}if("cashtag_v2"===t.type&&t.attrs&&"string"==typeof t.attrs.instrument_encoded){i.push({type:"cashtag_v2",attrs:{instrument_encoded:t.attrs.instrument_encoded,symbol:"string"==typeof t.attrs.symbol?t.attrs.symbol:void 0,name:"string"==typeof t.attrs.name?t.attrs.name:void 0,image_uri:"string"==typeof t.attrs.image_uri?t.attrs.image_uri:null,_unknown:!!t.attrs._unknown}});continue}if("cashtag_v3"===t.type&&t.attrs&&"string"==typeof t.attrs.instrument_encoded){i.push({type:"cashtag_v3",attrs:{instrument_encoded:t.attrs.instrument_encoded,intent:function(t){if(t&&"object"==typeof t){if("trade_direction"===t.type&&("LONG"===t.direction||"SHORT"===t.direction))return{type:"trade_direction",direction:t.direction}}}(t.attrs.intent),symbol:"string"==typeof t.attrs.symbol?t.attrs.symbol:void 0,name:"string"==typeof t.attrs.name?t.attrs.name:void 0,image_uri:"string"==typeof t.attrs.image_uri?t.attrs.image_uri:null,_unknown:!!t.attrs._unknown}});continue}"token_embed"===t.type&&t.attrs&&"object"==typeof t.attrs&&i.push({type:"token_embed",attrs:{chain_id:"string"==typeof t.attrs.chain_id?t.attrs.chain_id:void 0,contract_address:"string"==typeof t.attrs.contract_address?t.attrs.contract_address:void 0,symbol:"string"==typeof t.attrs.symbol?t.attrs.symbol:void 0,name:"string"==typeof t.attrs.name?t.attrs.name:void 0,image_uri:"string"==typeof t.attrs.image_uri?t.attrs.image_uri:null,_unknown:!!t.attrs._unknown}})}return s(i)}function u(t){return JSON.stringify(s(t))}function c(){return{version:1,blocks:[]}}function f(t){return l(t).some(t=>!o(t)||t.text.trim().length>0)}function p(t){let{document:e,mediaAssets:r}=t,n=l(e),i=[];for(let t of(n.length>0&&i.push({type:"paragraph",content:n}),r))i.push({type:"media",attrs:{asset_id:t.id}});return 0===i.length?c():{version:r.length>0?2:1,blocks:i}}function d(t){return t.map(t=>o(t)?t.text:"").join("")}function m(t){return o(t)?t.text.length:1}function h(t){var e,r,n,i;if("mention"===t.type)return"@".concat(t.attrs.username);if("watchlist_embed"===t.type)return"!".concat(t.attrs.watchlist_name);if("cashtag_v2"===t.type)return"$".concat(null!=(e=t.attrs.symbol)?e:"???");if("cashtag_v3"===t.type){let e=null==(r=t.attrs.intent)?void 0:r.direction;return"".concat("LONG"===e?"Long ":"SHORT"===e?"Short ":"","$").concat(null!=(n=t.attrs.symbol)?n:"???")}return"$".concat(null!=(i=t.attrs.symbol)?i:"???")}function y(t,e){let r=d(t);if(e>r.length)return null;for(let t=e-1;t>=0;t-=1){let n=r[t];if(""===n||"\n"===n)break;if("@"===n||"$"===n||"!"===n){if("\\"===r[t-1])continue;let i=r.slice(t+1,e);if("!"===n&&!function(t,e,r){var n,i,o;if(e>0&&!/\s/.test(null!=(i=t[e-1])?i:""))return!1;let s=r[0];return!s||!(/\s/.test(s)||a.has(s))&&(null!=(o=null==(n=r.match(/\s/g))?void 0:n.length)?o:0)<=2}(r,t,i)||("@"===n||"$"===n)&&0===i.length||("@"===n||"$"===n)&&/\s/.test(i))return null;return{active:!0,trigger:n,start:t,end:e,query:i}}}return null}function g(t){return t.flatMap(t=>"token"===t.type&&"perp"===t.instrument_type?[{item:t},{item:t,direction:"LONG"},{item:t,direction:"SHORT"}]:[{item:t}])}let w=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DIV","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","LI","MAIN","NAV","OL","P","PRE","SECTION","UL"]);function _(t){let e=[];return v(e,t),s(e)}function v(t,e){let r=Array.from(e.childNodes);r.forEach((e,n)=>{b(t,e,k(r,n))})}function b(t,e,r){if(e.nodeType===Node.TEXT_NODE){var n;E(t,null!=(n=e.textContent)?n:"");return}if(!(e instanceof HTMLElement))return;let i=e.dataset.atomType,a=e.dataset.atomAttrs;if(i&&a){try{t.push({type:i,attrs:JSON.parse(a)})}catch(t){}return}if("BR"===e.tagName){if(r)return;E(t,"\n");return}
1if(N(e)){if(r&&S(e))return;!function(t,e,r){x(t);let n=d(t).length;if(v(t,e),d(t).length===n){if(r&&S(e))return;E(t,"\n")}r||x(t)}(t,e,r);return}v(t,e)}function x(t){if(0===t.length)return;let e=t.at(-1);e&&o(e)&&e.text.endsWith("\n")||E(t,"\n")}function E(t,e){if(!e)return;let r=t.at(-1);if(r&&o(r)){r.text+=e;return}t.push({type:"text",text:e})}function N(t){return w.has(t.tagName)}function S(t){return Array.from(t.childNodes).every(t=>{var e;return t.nodeType===Node.TEXT_NODE&&!(null!=(e=t.textContent)?e:"").trim()||t instanceof HTMLElement&&"BR"===t.tagName})}function k(t,e){return t.slice(e+1).every(T)}function T(t){var e;return t.nodeType===Node.TEXT_NODE?!(null!=(e=t.textContent)?e:"").trim():!(t instanceof HTMLElement)||!t.dataset.atomType&&("BR"===t.tagName||N(t)&&S(t))}function A(t){let e=window.getSelection();if(!e||0===e.rangeCount)return d(_(t)).length;let{anchorNode:r,anchorOffset:n}=e;if(!r)return 0;let i=[];return function t(e,r,n,i){let a=Array.from(r.childNodes);if(r===n){for(let t=0;t<Math.min(i,a.length);t+=1)b(e,a[t],t===a.length-1);return!0}for(let r=0;r<a.length;r+=1){let o=a[r];if(function(e,r,n,i,a){if(r===n){if(r.nodeType===Node.TEXT_NODE){var o;return E(e,(null!=(o=r.textContent)?o:"").slice(0,i)),!0}if(r instanceof HTMLElement&&r.dataset.atomType)return i>0&&b(e,r,a),!0}if(!(r instanceof HTMLElement)||r.dataset.atomType||"BR"===r.tagName)return!1;if(N(r)){x(e);let o=d(e).length;
1if(t(e,r,n,i))return!0;if(d(e).length===o){if(a&&S(r))return!1;E(e,"\n")}return a||x(e),!1}return t(e,r,n,i)}(e,o,n,i,k(a,r)))return!0;b(e,o,k(a,r))}return!1}(i,t,r,n)?d(s(i)).length:d(_(t)).length}function O(t,e){var r;let n=Math.max(0,Math.min(e,d(_(t)).length)),i=window.getSelection();if(!i)return;let a=document.createRange(),o=null!=(r=function t(e,r,n){let i=Array.from(e.childNodes);for(let e=0;e<i.length;e+=1){let a=function(e,r,n,i){var a,o,s,l,u,c,f;if(e.nodeType===Node.TEXT_NODE){let t=null!=(a=e.textContent)?a:"";return r<=n.offset+t.length?{node:e,offset:r-n.offset}:(C(n,t),null)}if(!(e instanceof HTMLElement))return null;if(e.dataset.atomType){return o=e,(s=r)<=(l=n).offset?L(o):(l.offset+=1,l.lastChar=null,s<=l.offset)?R(o):null}if("BR"===e.tagName){return u=e,(c=r)<=(f=n).offset?L(u):(C(f,"\n"),c<=f.offset)?R(u):null}if(N(e)){if(j(n)&&r<=n.offset)return L(e);let a=n.offset,o=t(e,r,n);return o?o:n.offset===a&&(C(n,"\n"),r<=n.offset)?D(e):!i&&j(n)&&r<=n.offset?R(e):null}return t(e,r,n)}(i[e],r,n,k(i,e));if(a)return a}return null}(t,n,{lastChar:null,offset:0}))?r:D(t);a.setStart(o.node,o.offset),a.collapse(!0),i.removeAllRanges(),i.addRange(a)}function j(t){return 0!==t.offset&&"\n"!==t.lastChar&&(C(t,"\n"),!0)}function C(t,e){var r;e&&(t.offset+=e.length,t.lastChar=null!=(r=e.at(-1))?r:t.lastChar)}function L(t){let e=t.parentNode;return e?{node:e,offset:P(t)}:{node:t,offset:0}}function R(t){let e=t.parentNode;return e?{node:e,offset:P(t)+1}:{node:t,offset:t.childNodes.length}}function D(t){return{node:t,offset:t.childNodes.length}}function P(t){var e,r;return Array.prototype.indexOf.call(null!=(r=null==(e=t.parentNode)?void 0:e.childNodes)?r:[],t)}var F=r(87198);async function $(t,e){let r=await (0,F.v$)(function(t){let e=encodeURIComponent(t.query);return"$"===t.trigger?"/api/v1/token/instrument_search/?keyword=".concat(e,"&instrument_types=token,perp&limit=10"):"@"===t.trigger?"/api/v1/social/search/users/?q=".concat(e,"&limit=10"):"/api/v1/social/search/watchlists/?q=".concat(e,"&limit=10")}(t),{signal:e}),n=await M(r);if(!r.ok){var i;throw Error(null!=(i=n.detail)?i:"Search failed.")}var a=t.trigger,o=n;if("$"===a)return(Array.isArray(o.results)?o.results:[]).flatMap(t=>{var e;return null!=(e=function(t){let e=t.instrument;if(!e||"object"!=typeof e)return null;let r=e.encoded,n=e.type,i=function(t){let e=t.venue;if(!e||"object"!=typeof e||!("type"in e))return null;let r=e.type;return"string"==typeof r?r:null}(e),a=function(t){let e=t.venue;if(!e||"object"!=typeof e)return null;let r=e.sub_venue;return"string"==typeof r?r:null}(e);if("string"!=typeof r||"token"!==n&&"perp"!==n||"string"!=typeof t.symbol||"string"!=typeof t.name||!i)return null;let o=t.symbol.trim()&&"???"!==t.symbol.trim()?t.symbol:"string"==typeof e.asset?e.asset:t.symbol,s="perp"===n?function(t,e){var r;let n=function(t){let e=t.trim();return e.toUpperCase().endsWith("-PERP")?e.slice(0,-5):e}(t),i=null!=(r=null==e?void 0:e.trim())?r:"";if(i&&"default"!==i.toLowerCase()){let t="".concat(i,":");if(n.toLowerCase().startsWith(t.toLowerCase()))return n.slice(t.length).trim()||n}let a=n.trim(),o=a.indexOf(":");if(o<0)return a;let s=a.slice(0,o).trim(),l=a.slice(o+1).trim();return s&&l?l:a}(o,a):o,l="perp"===n?"".concat(s,"-PERP"):t.symbol,u="perp"===n?"".concat(s," Perpetual Future"):t.name;return{type:"token",instrument_encoded:r,instrument_type:n,symbol:l,name:u,image_uri:"string"==typeof t.image_uri?t.image_uri:null,venue:i,dapital_verified:!!t.dapital_verified,price:"number"==typeof t.price?t.price:null}}(t))?e:[]});let s=Array.isArray(o.items)?o.items:[];return"@"===a?s.flatMap(t=>"string"==typeof t.username?[{type:"user",username:t.username,display_name:"string"==typeof t.display_name?t.display_name:null,profile_picture_uri:"string"==typeof t.profile_picture_uri?t.profile_picture_uri:null}]:[]):s.flatMap(t=>"string"==typeof t.watchlist_id&&"string"==typeof t.name&&"string"==typeof t.color&&"string"==typeof t.owner_username?[{type:"watchlist",watchlist_id:t.watchlist_id,name:t.name,color:t.color,owner_username:t.owner_username,owner_profile_picture_uri:"string"==typeof t.owner_profile_picture_uri?t.owner_profile_picture_uri:null}]:[])}async function M(t){let e=await t.json().catch(()=>null);return e&&"object"==typeof e?e:{}}function H(t){let{highlightedIndex:e,isLoading:r,onSelect:i,placement:a="below",searchError:o,suggestions:s}=t,l=g(s);return(0,n.jsxs)("div",{className:"social-search-popover is-".concat(a),children:[r?(0,n.jsx)("div",{className:"social-search-status",children:"Searchingâ¦"}):null,!r&&o?(0,n.jsx)("div",{className:"social-search-status",children:o}):null,r||o||0!==s.length?null:(0,n.jsx)("div",{className:"social-search-status",children:"No results"}),!r&&l.length>0?(0,n.jsx)("div",{className:"social-search-list",children:l.map((t,r)=>(0,n.jsxs)("button",{type:"button",className:"social-search-row ".concat(r===e?"is-active":""),onMouseDown:e=>{e.preventDefault(),i(t)},children:[(0,n.jsx)("div",{className:"social-search-row-title",children:function(t){let{direction:e,item:r}=t;return"token"===r.type&&e?"".concat("LONG"===e?"Long":"Short"," $").concat(r.symbol):"token"===r.type?"$".concat(r.symbol):"user"===r.type?"@".concat(r.username):"!".concat(r.name)}(t)}),(0,n.jsx)("div",{className:"social-search-row-subtitle",children:function(t){let{direction:e,item:r}=t;if("token"===r.type){let t="perp"===r.instrument_type&&e?"".concat("LONG"===e?"Long":"Short"," perp"):"perp"===r.instrument_type?"Perp":"Token";return"".concat(r.name," \xb7 ").concat(t," \xb7 ").concat(r.venue)}return"user"===r.type?r.display_name||"User":"by @".concat(r.owner_username)}(t)})]},function(t,e){if("token"===t.item.type){var r;return"".concat(t.item.type,"-").concat(t.item.instrument_encoded,"-").concat(null!=(r=t.direction)?r:"plain")}return"user"===t.item.type?"user-".concat(t.item.username):"watchlist-".concat(t.item.watchlist_id,"-").concat(e)}(t,r)))}):null]})}let U=/(^|[^A-Za-z0-9_])(\$[A-Za-z][A-Za-z0-9]*(?:[-/][A-Za-z0-9]+)*)/g;function I(t){let{fallback:e="Untitled",text:r}=t,i=null==r?void 0:r.trim();if(!i)return e;let a=[],o=0;for(let t of i.matchAll(U)){var s;let[e,r,l]=t,u=null!=(s=t.index)?s:0,c=u+r.length;u>o&&a.push(i.slice(o,u)),r&&a.push(r),a.push((0,n.jsx)("span",{className:"social-rich-pill social-rich-pill-cashtag_v3",children:l.toUpperCase()},"".concat(c,"-").concat(l))),o=u+e.length}return o<i.length&&a.push(i.slice(o)),a.length>0?a:i}function q(t){let{mediaAssets:e=[],renderMedia:r=!0,richBody:a,className:o=""}=t,s=Array.isArray(null==a?void 0:a.blocks)?a.blocks:[];if(0===s.length)return null;let l=new Map(e.map(t=>[t.id,t]));return(0,n.jsx)("div",{className:"social-rich-body ".concat(o).trim(),children:s.map((t,e)=>{var a;if("media"===(a=t).type&&"object"==typeof a.attrs&&null!==a.attrs&&"string"==typeof a.attrs.asset_id)return r?(0,n.jsx)(B,{asset:l.get(t.attrs.asset_id),altText:t.attrs.alt_text},e):null;let o=(Array.isArray(null==t?void 0:t.content)?t.content:[]).map((t,r)=>{if("text"===t.type)return(0,n.jsx)(i.Fragment,{children:t.text},"".concat(e,"-").concat(r));if("mention"===t.type||"watchlist_embed"===t.type||"cashtag_v2"===t.type||"cashtag_v3"===t.type||"token_embed"===t.type){var a;let i="".concat(e,"-").concat(r),o="cashtag_v2"!==(a=t).type&&"cashtag_v3"!==a.type?null:function(t){if(!t)return null;let e=t.split(":");if(3===e.length){let[,t,r]=e;return"token"===t&&r?r:null}if(e.length>=4){let[,,t,...r]=e,n=r.join(":");return"token"===t&&n?n:null}return null}(a.attrs.instrument_encoded);return o?(0,n.jsx)(J,{contractAddress:o,node:t},i):(0,n.jsx)("span",{className:G(t),style:z(t),children:h(t)},i)}return function(t,e){var r,a,o;let s="object"==typeof t.attrs&&t.attrs?t.attrs:{};return"link_embed"===t.type?(0,n.jsx)(i.Fragment,{children:String(null!=(r=s.display_url)?r:"")},e):"titled_link"===t.type||"link_mention"===t.type?(0,n.jsx)(i.Fragment,{children:String(null!=(o=null!=(a=s.title_text)?a:s.display_url)?o:"")},e):null}(t,"".concat(e,"-").concat(r))});return(0,n.jsx)("div",{className:"social-rich-block",children:o},e)})})}function J(t){let{contractAddress:e,node:r}=t,[a,o]=(0,i.useState)(!1),s=(0,i.useRef)(null),l=h(r),u=a?"Copied contract address":"Copy ".concat(l," contract address"),c=async t=>{t.preventDefault(),t.stopPropagation(),navigator.clipboard&&(await navigator.clipboard.writeText(e),o(!0),null!==s.current&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{o(!1),s.current=null},1400))};return(0,n.jsx)("button",{type:"button","aria-label":u,className:"".concat(G(r)," social-rich-pill-copyable").concat(a?" is-copied":""),onClick:c,style:z(r),title:u,children:l})}function B(t){let{altText:e,asset:r}=t;if(!r)return(0,n.jsx)("div",{className:"social-rich-media social-rich-media-missing",children:"Image unavailable"});let i=r.preview_url||r.thumbnail_url,a=r.width>0&&r.height>0?"".concat(r.width," / ").concat(r.height):void 0;return(0,n.jsx)("figure",{className:"social-rich-media",style:{aspectRatio:a},children:(0,n.jsx)("img",{alt:null!=e?e:"",className:"social-rich-media-image",height:r.height>0?r.height:void 0,loading:"lazy",src:i,width:r.width>0?r.width:void 0})})}function z(t){if("watchlist_embed"===t.type)return{"--watchlist-accent":t.attrs.watchlist_color}}function G(t){var e;let r=["social-rich-pill","social-rich-pill-".concat(t.type)];return"cashtag_v3"===t.type&&(null==(e=t.attrs.intent)?void 0:e.direction)&&r.push("social-rich-pill-cashtag-direction-".concat(t.attrs.intent.direction.toLowerCase())),r.join(" ")}let X=(0,i.forwardRef)(function(t,e){let{value:r,onChange:a,placeholder:f,minHeight:p=120,autoFocus:d=!1,className:w="",suggestionPlacement:v="below"}=t,b=(0,i.useRef)(null),x=(0,i.useRef)(0),E=(0,i.useRef)(null),N=(0,i.useRef)(0),[S,k]=(0,i.useState)(()=>l(r)),[T,j]=(0,i.useState)(null),[C,L]=(0,i.useState)([]),[R,D]=(0,i.useState)(!1),[P,F]=(0,i.useState)(null),[M,U]=(0,i.useState)(0),I=(0,i.useRef)(JSON.stringify(null!=r?r:c()));(0,i.useImperativeHandle)(e,()=>({focus:()=>{var t;
1null==(t=b.current)||t.focus(),requestAnimationFrame(()=>{b.current&&O(b.current,x.current)})}})),(0,i.useLayoutEffect)(()=>{if(JSON.stringify(null!=r?r:c())===I.current)return;let t=l(r);k(e=>u(e)===u(t)?e:t)},[r]),(0,i.useLayoutEffect)(()=>{let t=JSON.stringify(function(t){let e=s(t);return 0===e.length?c():{version:1,blocks:[{type:"paragraph",content:e}]}}(S));t!==I.current&&(I.current=t,a(JSON.parse(t)))},[S,a]),(0,i.useLayoutEffect)(()=>{b.current&&(!function(t,e){if(u(e)===u(_(t)))return;let r=t.ownerDocument.createDocumentFragment();for(let n of e)!function(t,e,r){if(o(e))return t.append(r.createTextNode(e.text));let n=r.createElement("span");n.className=function(t){var e;if(o(t))return"";let r=["social-editor-atom","social-editor-atom-".concat(t.type)];return"cashtag_v3"===t.type&&(null==(e=t.attrs.intent)?void 0:e.direction)&&r.push("social-editor-atom-cashtag-direction-".concat(t.attrs.intent.direction.toLowerCase())),r.join(" ")}(e),n.contentEditable="false",n.dataset.atomType=e.type,n.dataset.atomAttrs=JSON.stringify(e.attrs),"watchlist_embed"===e.type&&n.style.setProperty("--watchlist-accent",e.attrs.watchlist_color),n.textContent=h(e),t.append(n)}(r,n,t.ownerDocument);t.replaceChildren(r)}(b.current,S),O(b.current,x.current))},[S]),(0,i.useLayoutEffect)(()=>{var t;d&&(null==(t=b.current)||t.focus())},[d]),(0,i.useLayoutEffect)(()=>{if(E.current&&window.clearTimeout(E.current),!(null==T?void 0:T.active)){N.current+=1,q();return}let t=N.current+1;N.current=t;let e=new AbortController;return E.current=window.setTimeout(async()=>{D(!0),F(null);try{let r=await $(T,e.signal);if(t!==N.current)return;L(r),U(0)}catch(r){if(e.signal.aborted||t!==N.current)return;L([]),F(r instanceof Error?r.message:"Search failed.")}finally{t===N.current&&D(!1)}},180),()=>{E.current&&window.clearTimeout(E.current),e.abort()}},[T]);let q=()=>{L([]),F(null),D(!1),U(0)},J=()=>{if(!b.current)return;let t=_(b.current),e=A(b.current),r=y(t,e);x.current=e,k(e=>u(e)===u(t)?e:t),j(t=>t===r||t&&r&&t.active===r.active&&t.trigger===r.trigger&&t.start===r.start&&t.end===r.end&&t.query===r.query?t:r)},B=t=>{var e;if(!T)return;let r=function(t){let e="item"in t?t.item:t,r="item"in t?t.direction:void 0;return"token"===e.type?"perp"===e.instrument_type?{type:"cashtag_v3",attrs:{instrument_encoded:e.instrument_encoded,...r?{intent:{type:"trade_direction",direction:r}}:{},symbol:e.symbol,name:e.name,image_uri:e.image_uri}}:{type:"cashtag_v2",attrs:{instrument_encoded:e.instrument_encoded,symbol:e.symbol,name:e.name,image_uri:e.image_uri}}:"user"===e.type?{type:"mention",attrs:{username:e.username}}:{type:"watchlist_embed",attrs:{watchlist_id:e.watchlist_id,watchlist_name:e.name,watchlist_color:e.color,owner_username:e.owner_username}}}(t),n=function(t,e,r,n){let i=[],a=0,l=!1;for(let s of t){let t=a,u=a+m(s);if(a=u,u<=e||t>=r){i.push(s);continue}if(o(s)){e>t&&i.push({type:"text",text:s.text.slice(0,e-t)}),l||(i.push(n),l=!0),r<u&&i.push({type:"text",text:s.text.slice(r-t)});continue}l||(i.push(n),l=!0)}return l||i.push(n),s(i)}(S,T.start,T.end,r);x.current=T.start+1,k(n),j(null),L([]),F(null),null==(e=b.current)||e.focus()},z=t=>{if(!b.current||!t)return;let e=_(b.current),r=A(b.current),n=function(t,e,r){let n=[],i=Math.max(0,Math.min(e,t.reduce((t,e)=>t+m(e),0))),a=0,l=!1;for(let e of t){let t=a+m(e);if(!l&&i<=t){if(o(e)){let t=i-a,o=e.text.slice(0,t),s=e.text.slice(t);o&&n.push({type:"text",text:o}),n.push({type:"text",text:r}),s&&n.push({type:"text",text:s})}else i<=a?n.push({type:"text",text:r},e):n.push(e,{type:"text",text:r});l=!0}else n.push(e);a=t}return l||n.push({type:"text",text:r}),s(n)}(e,r,t),i=r+t.length;x.current=i,k(n),j(y(n,i))};return(0,n.jsxs)("div",{className:"relative ".concat(w).trim(),children:[(0,n.jsx)("div",{ref:b,className:"social-rich-editor custom-scrollbar",contentEditable:!0,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","data-placeholder":f,style:{minHeight:p},onInput:J,onKeyDown:t=>{if(!(t=>{let e=g(C);if(!T||0===e.length)return!1;if("ArrowDown"===t.key)return t.preventDefault(),U(t=>(t+1)%e.length),!0;if("ArrowUp"===t.key)return t.preventDefault(),U(t=>(t-1+e.length)%e.length),!0;if("Enter"===t.key){var r;return t.preventDefault(),B(null!=(r=e[M])?r:e[0]),!0}return!1})(t)){if("Escape"===t.key){j(null),L([]),F(null);return}if("Enter"===t.key){t.preventDefault(),z("\n");return}("Backspace"===t.key||"Delete"===t.key)&&b.current&&(t=>
1{if(!b.current)return;let e=window.getSelection();if(!e||!e.isCollapsed)return;let r=A(b.current),n="Backspace"===t.key?r-1:r;if(!function(t,e){let r=0;for(let n of t){let t=r;if(r+=m(n),!o(n)&&t===e)return n}return null}(S,n)||n<0)return;t.preventDefault();let i=function(t,e){let r=[],n=0;for(let i of t){let t=n;n+=m(i),(o(i)||t!==e)&&r.push(i)}return s(r)}(S,n);x.current=n,k(i),j(y(i,n))})(t)}},onMouseUp:J,onKeyUp:J,onPaste:t=>{t.preventDefault(),z(t.clipboardData.getData("text/plain"))}}),T?(0,n.jsx)(H,{highlightedIndex:M,isLoading:R,onSelect:B,placement:v,searchError:P,suggestions:C}):null]})})},46598:(t,e,r)=>{r.d(e,{CA:()=>l,Cu:()=>v,EK:()=>i,Ev:()=>S,LG:()=>C,LX:()=>x,N8:()=>s,N9:()=>a,Nk:()=>R,Nn:()=>L,Tl:()=>E,U1:()=>f,YO:()=>u,bA:()=>b,dz:()=>p,fo:()=>d,h8:()=>m,i1:()=>c,np:()=>h,oW:()=>j,sk:()=>_,ws:()=>N,xd:()=>y});var n=r(87198);class i extends Error{constructor(){super("Hot feed is temporarily unavailable."),this.name="SocialFeedUnavailableError"}}function a(t){if(!t)return null;let e=new Date(t);return Number.isNaN(e.getTime())?null:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(e)}function o(t,e){if("string"==typeof t&&t.trim())return t;if(t&&"object"==typeof t){if("string"==typeof t.error&&t.error.trim())return t.error;if("string"==typeof t.detail&&t.detail.trim())return t.detail;if("string"==typeof t.message&&t.message.trim())return t.message;if(Array.isArray(t.messages)){let e=t.messages.find(t=>"string"==typeof t&&t.trim().length>0);if(e)return e}if("string"==typeof t.code&&t.code.trim())return t.code}return e}async function s(t){let e,{cursor:r,limit:a,mode:s="hot",scope:l,translationLocale:u}=t,c=new URLSearchParams({limit:String(a),mode:s});r&&c.set("cursor",r),"discussionBoard"===l.kind&&c.set("community",C(l.community)),u&&c.set("locale",u);let f="homepage"===l.kind?"/api/v1/social/homepage/?".concat(c.toString()):"/api/v1/social/feed_v2/?".concat(c.toString());try{e=await (0,n.v$)(f,{signal:"hot"===s?AbortSignal.timeout(5e3):void 0})}catch(t){var p;if("hot"===s&&(p=t)instanceof DOMException&&("AbortError"===p.name||"TimeoutError"===p.name))throw new i;throw t}let d=await e.json().catch(()=>null);if("hot"===s&&503===e.status)throw new i;if(!e.ok)throw Error(o(d,"Failed to load feed."));return d}async function l(){var t,e;let r=await (0,n.v$)("/api/v1/social/discussion_boards/"),i=await r.json().catch(()=>null);if(!r.ok)throw Error(o(i,"Failed to load tags."));return{boards:(e=null!=(t=null==i?void 0:i.boards)?t:[]).some(t=>R(t.slug,"main"))?e:[{is_subscribed:!0,slug:"main",visibility_badges:[]},...e],can_create_internal_posts:(null==i?void 0:i.can_create_internal_posts)===!0}}async function u(){let t=O();if(!t)throw Error("Current user is unavailable.");let e=await (0,n.v$)("/api/v1/social/profile/".concat(t,"/")),r=await k(e);if(!e.ok)throw Error(o(r,"Failed to load profile."));if(!T(r))throw Error("Profile response was missing required fields.");return r}async function c(t,e){let r=new URLSearchParams;e&&r.set("locale",e);let i=r.size>0?"?".concat(r.toString()):"",a=await (0,n.v$)("/api/v1/social/profile/username/".concat(encodeURIComponent(t),"/").concat(i)),s=await k(a);if(!a.ok)throw Error(o(s,"Failed to load profile."));if(!T(s))throw Error("Profile response was missing required fields.");return s}async function f(t){var e;let{follow:r,userUuid:i}=t,a=await (0,n.v$)("/api/v1/social/follow/",{method:"POST",body:JSON.stringify({follow:r,user_uuid:i})}),s=await k(a);if(!a.ok)throw Error(o(s,r?"Failed to follow profile.":"Failed to unfollow profile."));if(!(A(e=s)&&"number"==typeof e.follower_count&&"number"==typeof e.following_count&&"boolean"==typeof e.is_following))throw Error("Follow response was missing required fields.");return s}async function p(t){let e=await (0,n.v$)("/api/v1/social/profile/update/",{method:"POST",body:JSON.stringify(t)}),r=await k(e);if(!e.ok)throw Error(o(r,"Failed to update profile."));if(!T(r))throw Error("Profile response was missing required fields.");return r}async function d(t){return await g("/api/v1/social/profile/picture/",t),u()}async function m(){return await w("/api/v1/social/profile/picture/delete/","Failed to delete profile picture."),u()}async function h(t){return await g("/api/v1/social/profile/banner/",t),u()}async function y(){return await w("/api/v1/social/profile/banner/delete/","Failed to delete banner."),u()}async function g(t,e){let r=new FormData;r.set("file",e);let i=await (0,n.v$)(t,{method:"POST",body:r}),a=await k(i);if(!i.ok)throw Error(o(a,"Failed to upload image."))}async function w(t,e){let r=await (0,n.v$)(t,{method:"POST"}),i=await k(r);if(!r.ok)throw Error(o(i,e))}async function _(t){var e;let{cursor:r,limit:i,translationLocale:a,userUuid:s}=t,l=new URLSearchParams({limit:String(i)});r&&l.set("cursor",r),a&&l.set("locale",a);let u=await (0,n.v$)("/api/v1/social/profile/".concat(encodeURIComponent(s),"/posts/?").concat(l.toString())),c=await k(u);if(!u.ok)throw Error(o(c,"Failed to load posts."));if(!(A(e=c)&&Array.isArray(e.items)&&"boolean"==typeof e.has_next))throw Error("Posts response was missing required fields.");return c}async function v(t){var e;let{body:r,clientEventId:i,community:a,title:s,visibility:l}=t,u=await (0,n.v$)("/api/v1/social/posts_v2/?client_event_id=".concat(i),{method:"POST",body:JSON.stringify({community:C(a),rich_body:r,title:s,visibility:l})}),c=await k(u);if(!u.ok)throw Error(o(c,"Failed to publish."));if(!(A(e=c)&&"string"==typeof e.id))throw Error("Post response was missing required fields.");return c}async function b(t){var e;let r=new FormData;r.set("file",t);let i=await (0,n.v$)("/api/v1/social/assets/",{method:"POST",body:r}),a=await k(i);if(!i.ok)throw Error(o(a,"Failed to upload image."));if(!(A(e=a)&&"string"==typeof e.id&&"string"==typeof e.kind&&"string"==typeof e.status&&"string"==typeof e.mime_type&&"number"==typeof e.width&&"number"==typeof e.height&&"string"==typeof e.preview_url&&"string"==typeof e.thumbnail_url))throw Error("Asset response was missing required fields.");return a}
1async function x(t,e){var r;let i=new URLSearchParams;e&&i.set("locale",e);let a=i.size>0?"?".concat(i.toString()):"",s=await (0,n.v$)("/api/v1/social/posts/".concat(t,"/").concat(a)),l=await s.json().catch(()=>null);if(!s.ok||!(null==l?void 0:l.post))throw Error(o(l,"Failed to load post."));return{comments:null!=(r=l.comments)?r:[],post:l.post}}async function E(t,e){var r;let i=await (0,n.v$)("/api/v1/social/posts/".concat(t,"/vote/"),{method:"POST",body:JSON.stringify({vote:e})}),a=await k(i);if(!i.ok)throw Error(o(a,"Failed to update vote."));if(!(A(r=a)&&"number"==typeof r.score&&("upvote"===r.user_vote||"downvote"===r.user_vote||null===r.user_vote)))throw Error("Vote response was missing required fields.");return a}async function N(t){var e;let{body:r,clientEventId:i,parentId:a,postId:s}=t,l={rich_body:r};a&&(l.parent_id=a);let u=await (0,n.v$)("/api/v1/social/posts/".concat(s,"/comments_v2/?client_event_id=").concat(i),{method:"POST",body:JSON.stringify(l)}),c=await k(u);if(!u.ok)throw Error(o(c,"Failed to post reply."));if(!(A(e=c)&&"string"==typeof e.id))throw Error("Reply response was missing required fields.");return c}function S(t,e){let r=t.filter(t=>!t.parent_id||t.parent_id===e),n=new Set(r.map(t=>t.id)),i=new Map(t.map(t=>[t.id,t])),a=function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;if(r.has(t.id))return;if(r.add(t.id),!t.parent_id||t.parent_id===e)return t.id;if(n.has(t.parent_id))return t.parent_id;let o=i.get(t.parent_id);if(o)return a(o,r)};return{nestedByRootId:t.reduce((t,e)=>{if(n.has(e.id))return t;let r=a(e);if(r){var i;t[r]=[...null!=(i=t[r])?i:[],e]}return t},{}),rootComments:r}}async function k(t){return t.json().catch(()=>null)}function T(t){return A(t)&&"string"==typeof t.user_uuid&&"string"==typeof t.username&&t.username.trim().length>0}function A(t){return!!(t&&"object"==typeof t)}function O(){var t;let e=null==(t=(0,n.g8)())?void 0:t.accessToken;if(!e)return null;let[,r]=e.split(".");if(!r)return null;try{let t=JSON.parse(function(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");return atob(e.padEnd(e.length+(4-e.length%4)%4,"="))}(r));if(!A(t))return null;let e=t.uuid;return"string"==typeof e&&e.trim()?e:null}catch(t){return null}}function j(t){return O()===t}function C(t){return(null==t?void 0:t.trim())||"main"}function L(t){return"d/".concat(C(t))}function R(t,e){return C(t).toLowerCase()===C(e).toLowerCase()}},68094:(t,e,r)=>{r.d(e,{V:()=>a});var n=r(20623);let i={status:"idle"};function a(t,e){let r=(0,n.useRef)(null);return r.current&&r.current.key===t||(r.current=function(t,e){let r=new Set,n=i,a=!1,o=()=>{for(let t of r)t()};return{key:t,getServerSnapshot:()=>i,getSnapshot:()=>n,subscribe:t=>(r.add(t),a||(a=!0,n={status:"loading"},o(),e().then(t=>{n={data:t,status:"success"},o()}).catch(t=>{n={error:t instanceof Error?t.message:"Request failed.",status:"error"},o()})),()=>{r.delete(t)})}}(t,e)),(0,n.useSyncExternalStore)(r.current.subscribe,r.current.getSnapshot,r.current.getServerSnapshot)}}}]);
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.