PageSourceSearch

https://cgcircuit.com/assets/commentI18n-AZQYemGB.js

js cgcircuit.com collected 2026-09-25 19:54:54 UTC 4,354 bytes, 1 lines download raw bytes

1import{o as e}from"./rolldown-runtime-Bhmf7a9N.js";import{in as t}from"./mui-BhN7Ddpb.js";import{a as n,g as r}from"./query-DIbGofBh.js";import{t as i}from"./api-C2sPMGeX.js";import{un as a}from"./index-Czw4Hqrv.js";var o=e(t(),1),s=1e4,c=1e4,l=300*1e3,u=20,d={all:[`comments`],list:(e,t)=>[...d.all,e,t],replies:(e,t)=>[...d.all,e,`replies`,t]};function f(e){let t=e;return t?.data===void 0?t:t.data}function p(e,t=`helpful`,p){let m=p?.pageSize??u,h=(p?.enabled??!0)&&!!e,g=a(),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(null),[x,S]=(0,o.useState)(!1),[C,w]=(0,o.useState)(!1),T=n({queryKey:d.list(e,t),queryFn:async()=>{let n=f((await i.get(`/content/${encodeURIComponent(e)}/comments`,{params:{sort:t,page_size:m}})).data);return v([]),b(n.next_cursor),S(n.next_cursor===null),n},enabled:h,placeholderData:r,staleTime:c,gcTime:l,refetchInterval:g?s:!1,refetchIntervalInBackground:!1}),E=T.data?.items??[],D=(0,o.useCallback)(async()=>{if(!(x||!y||C)){w(!0);try{let n=f((await i.get(`/content/${encodeURIComponent(e)}/comments`,{params:{sort:t,page_size:m,cursor:y}})).data);v(e=>[...e,...n.items]),b(n.next_cursor),S(n.next_cursor===null)}finally{w(!1)}}},[e,t,m,y,x,C]);return{comments:[...E,..._],isLoading:T.isLoading,isFetching:T.isFetching,error:T.error,hasNextPage:!x&&y!==null,fetchNextPage:D,isFetchingNextPage:C,refetch:()=>{T.refetch()}}}var m={1:0,2:0,3:0,4:0,5:0};function h(e){return{content_id:e,rating_avg:0,rating_count:0,rating_histogram:{...m}}}var g=[``,`Poor`,`Fair`,`Good`,`Very good`,`Outstanding`],_=6e4,v=300*1e3,y=20,b={all:[`ratings`],aggregate:e=>[...b.all,e,`aggregate`],list:e=>[...b.all,e,`list`]};function x(e){let t=e;return t?.data===void 0?t:t.data}function S(e,t,a){let s=a?.pageSize??y,c=(a?.enabled??!0)&&!!e,[l,u]=(0,o.useState)([]),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(!1),[g,S]=(0,o.useState)(!1),C=n({queryKey:b.aggregate(e),queryFn:async()=>x((await i.get(`/content/${encodeURIComponent(e)}/ratings/aggregate`)).data),enabled:c,placeholderData:r,staleTime:_,gcTime:v}),w=n({queryKey:b.list(e),queryFn:async()=>{let t=x((await i.get(`/content/${encodeURIComponent(e)}/ratings`,{params:{page_size:s}})).data);return u([]),f(t.next_cursor),m(t.next_cursor===null),t},enabled:c,placeholderData:r,staleTime:_,gcTime:v}),T=w.data?.items??[],E=(0,o.useMemo)(()=>[...T,...l],[T,l]),D=(0,o.useMemo)(()=>t?E.find(e=>e.user_id===t)??null:null,[E,t]),O=(0,o.useCallback)(async()=>{if(!(p||!d||g)){S(!0);try{let t=x((await i.get(`/content/${encodeURIComponent(e)}/ratings`,{params:{page_size:s,cursor:d}})).data);u(e=>[...e,...t.items]),f(t.next_cursor),m(t.next_cursor===null)}finally{S(!1)}}},[e,s,d,p,g]);return{aggregate:C.data??h(e),ratings:E,userRating:D,isLoading:C.isLoading||w.isLoading,isFetching:C.isFetching||w.isFetching,error:C.error??w.error,hasNextPage:!p&&d!==null,fetchNextPage:O,isFetchingNextPage:g,refetch:()=>{C.refetch(),w.refetch()}}}function C(e){let t=typeof e==`number`&&isFinite(e)?Math.max(0,Math.floor(e)):0,n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=String(i).padStart(2,`0`);return n>0?`${n}:${String(r).padStart(2,`0`)}:${a}`:`${r}:${a}`}function w(e){let t=typeof e==`number`&&isFinite(e)?Math.max(0,Math.floor(e)):0,n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=[];return n>0&&a.push(`${n} hour${n===1?``:`s`}`),r>0&&a.push(`${r} minute${r===1?``:`s`}`),(i>0||a.length===0)&&a.push(`${i} second${i===1?``:`s`}`),a.join(` `)}var T=[{limit:60,div:1,unit:`second`},{limit:3600,div:60,unit:`minute`},{limit:86400,div:3600,unit:`hour`},{limit:2592e3,div:86400,unit:`day`},{limit:31536e3,div:2592e3,unit:`month`},{limit:1/0,div:31536e3,unit:`year`}];function E(e,t,n=Date.now()){if(!e)return``;let r=new Date(e).getTime();if(Number.isNaN(r))return``;let i=Math.round((r-n)/1e3),a=Math.abs(i),o=new Intl.RelativeTimeFormat(t,{numeric:`auto`});for(let{limit:e,div:t,unit:n}of T)if(a<e)return o.format(Math.round(i/t),n);return o.format(Math.round(i/31536e3),`year`)}function D(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`short`}).format(n)}function O(e,t,n){return t[new Intl.PluralRules(n).select(e)]??t.other}
1function k(e,t,n){return`${new Intl.NumberFormat(n).format(e)} ${O(e,t,n)}`}export{C as a,m as c,d,p as f,w as i,g as l,k as n,b as o,E as r,S as s,D as t,s as u};

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.