PageSourceSearch

https://www.basilica.ai/_next/static/chunks/3823.d0f4ab06b19eae6d.js

js basilica.ai collected 2026-10-03 23:52:35 UTC 6,633 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3823],{3823:function(e,t,n){let o;n.d(t,{getWsProvider:function(){return C}});let r=e=>JSON.stringify({jsonrpc:"2.0",...e}),a=0,s=()=>`proxyOpaque${a++}`,i=()=>`___proxyInternalId__${s()}`,l=e=>{let t={type:1,activeBroadcasts:new Map,pending:[]},n=n=>{let o=!0;if(0===t.type){let e=JSON.parse(n);if("id"in e){let{id:n}=e;if(t.pendingBroadcasts.has(n)){let o=t.pendingBroadcasts.get(n),a=e.result;t.pendingBroadcasts.delete(n),t.activeBroadcasts.get(o)?t.activeBroadcasts.get(o).upToken=a:t.connection.send(r({id:i(),method:"transaction_v1_stop",params:[a]}));return}o=t.onGoingRequests.has(n),"result"in e&&t.onGoingRequests.get(n)?.type===0&&t.activeChainHeads.add(e.result),t.onGoingRequests.delete(e.id)}else if("params"in e){let{subscription:n,result:o}=e.params;o?.event==="stop"&&t.activeChainHeads.delete(n)}}o&&2!==t.type&&e(n)},o=n=>{if(2===t.type)return;let o=JSON.parse(n);if("id"in o){let{method:a,id:i,params:l}=o,[c,,d]=a.split("_");if("transaction"===c){if("stop"===d){let[n]=l,o=t.activeBroadcasts.get(n);t.activeBroadcasts.delete(n),e(r({id:i,result:null})),0===t.type&&o&&o.upToken&&t.connection.send(r({id:i,method:a,params:[o.upToken]}));return}if("broadcast"===d){let o=s();t.activeBroadcasts.set(o,{tx:l[0],synToken:o}),0===t.type&&(t.pendingBroadcasts.set(i,o),t.connection.send(n)),e(r({id:i,result:o}));return}}}if(1===t.type){t.pending.push(n);return}if("chainHead_v1_unfollow"===o.method&&t.activeChainHeads.delete(o.params[0]),"id"in o){let{method:e,id:r}=o,[a,,s]=e.split("_"),i="chainHead"===a?"follow"===s?{type:0,msg:n}:{type:1,id:r}:{type:2,msg:n};t.onGoingRequests.set(r,i)}t.connection.send(n)};return{send:o,disconnect:()=>{2!==t.type&&(0===t.type&&t.connection.disconnect(),t={type:2})},connect:e=>{if(1!==t.type)throw Error("Nonesense");let{pending:a,activeBroadcasts:s}=t,l=new Map,c=new Set;(t={type:0,connection:null,activeBroadcasts:s,pendingBroadcasts:new Map,onGoingRequests:l,activeChainHeads:c}).connection=e(n,()=>{let e=2!==t.type?t.activeBroadcasts:new Map;for(let a of(e.forEach(e=>e.upToken=void 0),t={type:1,activeBroadcasts:e,pending:[]},c.forEach(e=>{n(r({params:{subscription:e,result:{event:"stop",internal:!0}}}))}
1),c.clear(),l.values()))1===a.type?n(r({id:a.id,error:{code:-32603,message:"Internal error"},internal:!0})):o(a.msg);l.clear()}),s.forEach(e=>{if(0===t.type){let n=i();t.pendingBroadcasts.set(n,e.synToken),o(r({id:n,method:"transaction_v1_broadcast",params:[e.tx]}))}}),a.forEach(o)}}},c=e=>t=>{let n,o=l(t),r=Date.now(),a=0,s=()=>a&&2**Math.min(5,a)*250,i=()=>e().then(e=>{if(o)o.connect((t,n)=>{let o=!0;return e(t,()=>{if(o){o=!1;let e=Date.now()-r;a+=e>250+s()?-a:1,r+=e,n(),c()}})});else try{e(()=>{},()=>{}).disconnect()}catch(e){}},c),c=()=>{n=setTimeout(i,s())};return i(),{send:e=>{o?.send(e)},disconnect:()=>{clearTimeout(n);let e=o?.disconnect||(()=>{});o=null,e()}}};var d,p=((d=p||{})[d.CONNECTING=0]="CONNECTING",d[d.CONNECTED=1]="CONNECTED",d[d.ERROR=2]="ERROR",d[d.CLOSE=3]="CLOSE",d);let u={};["v1","unstable"].forEach(e=>{u[`chainHead_${e}_follow`]="follow",u[`chainHead_${e}_unfollow`]="unfollow"});let f=()=>({latest:Date.now(),count:0}),h=(e,t)=>{let n;let o=new Set,r=new Map,a=new Set,s=f();return Object.assign(i=>{let{send:l,disconnect:c}=e(e=>{let c=JSON.parse(e);if("id"in c){let{id:s,result:d}=c;if(s===n&&(n=void 0,d&&!d.methods.some(e=>{let[t,,n]=e.split("_");return"chainHead"===t&&"follow"===n}))){i(e),t();return}let p=r.get(s);if(p){if(r.delete(s),o.has(d)){o.delete(d);return}a.add(d);let e=a.size+r.size;if(e>2)console.warn(`Too many chainHead follow subscriptions (${e})`);else if(c.error){console.warn(`chainHead follow failed on the ${e} sub`),t(),r.set(s,p),l(p);return}}}else{let{subscription:e,result:t}=c.params;if(t?.event==="stop"){let t=Date.now()-s.latest;s.latest+=t,s.count=t<1e3?s.count+1:1,a.has(e)?a.delete(e):o.add(e)}}i(e),s.count>2&&(s=f(),t())});return{send(e){let t=JSON.parse(e);"rpc_methods"===t.method&&(n=t.id);let o=u[t.method];"follow"===o?r.set(t.id,e):"unfollow"===o&&a.delete(t.params[0]),l(e)},disconnect:c}},{cleanup:()=>{o.clear(),r.clear(),a.clear()}})},m={type:p.ERROR,event:{type:"timeout"}},v=()=>{},y={onStatusChanged:v,innerEnhancer:e=>e,timeout:5e3,heartbeatTimeout:4e4},E=e=>e.map(e=>"string"==typeof e?[e]:[e.uri,e.protocol]),g=(e,t)=>{let n;let{onStatusChanged:o,innerEnhancer:r,timeout:a,heartbeatTimeout:s}={...y,...t},i=E(Array.isArray(e)?e:[e]),l=t?.websocketClass??globalThis.WebSocket;if(!l)throw Error("Missing WebSocket class");let d=0,u=null,f=v,g=v,C=h(c(async()=>{let e;let[t,c]=u??i[d++%i.length];u=null;let h=new l(t,c),y=()=>{try{h.addEventListener("error",v,{once:!0}),h.close()}catch{}};o(n={type:p.CONNECTING,uri:t,protocols:c}),await new Promise((e,r)=>{let s=()=>{d(),e()},i=e=>{d(),null==e&&y(),console.error(`Unable to connect to ${t}${c?", protocols: "+c:""}`),o(n={type:e?p.ERROR:p.CLOSE,event:e}),setTimeout(r,e?300:0,e)},l=a!==1/0?setTimeout(()=>{d(),y(),o(n=m),r(m.event)},a):void 0,d=()=>{clearTimeout(l),h.removeEventListener("error",i),h.removeEventListener("open",s)};h.addEventListener("open",s),h.addEventListener("error",i),f=()=>{i(null)}}),o(n={type:p.CONNECTED,uri:t,protocols:c});let E=r(t=>(e=t,{send:e=>{h.send(e)},disconnect:()=>{f()}}));return(t,r)=>{let a;let i=()=>{s>w||(clearTimeout(a),a=setTimeout(()=>{console.warn("Terminate: heartbeat timeout"),f(!0)},s))};i();let l=E(t),c=t=>{i(),"string"==typeof t.data&&e(t.data)},d=e=>t=>{clearTimeout(a),console.warn(`WS halt (${e})`),o(n={type:e,event:t}),r()},u=d(p.ERROR),m=d(p.CLOSE);return h.addEventListener("ping",i),h.addEventListener("message",c),h.addEventListener("error",u),h.addEventListener("close",m),f=e=>{clearTimeout(a),g(),f=v,h.removeEventListener("ping",i),h.removeEventListener("message",c),h.removeEventListener("error",u),h.removeEventListener("close",m),y(),e&&m({}),l.disconnect()},l}}),()=>{O()});g=C.cleanup,delete C.cleanup;let O=(...e)=>{n.type!==p.CLOSE&&(e.length&&(u=e),n.type!==p.ERROR&&f(!0))};return Object.assign(C,{switch:O,getStatus:()=>n})},w=2147483647,C=(o=WebSocket,(...e)=>{let t=[],{heartbeatTimeout:n,timeout:r,innerEnhancer:a,onStatusChanged:s}=y,[i]=e;return 1!==e.length||"object"!=typeof i||Array.isArray(i)?("function"==typeof e[1]&&(s=e[1]),Array.isArray(i)?t=E(i):(t=[[i]],e[1]&&e[1]!==s&&(t[0][1]=e[1]),e[2]&&(s=e[2]))):(t=E(i.endpoints),s=i.onStatusChanged??v,r=i.timeout??r,n=i.heartbeatTimeout??n,a=i.innerEnhancer??(e=>e)),g(t.map(e=>1===e.length?e[0]:{uri:e[0],protocol:e[1]}),{websocketClass:o,onStatusChanged:s,timeout:r,innerEnhancer:a,heartbeatTimeout:n})})}}]);

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.