PageSourceSearch

https://app.writer.plusai.studio/_next/static/chunks/1859.961c54a84ec07920.js

js plusai.studio collected 2026-10-04 19:28:03 UTC 13,264 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1859],{56263:function(e,t,s){s.d(t,{Z:function(){return l}});var n=s(67294);let a=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],c=a[Math.floor(Math.random()*a.length)],r=(0,n.createContext)({clientID:0,color:c[1],isCollabActive:!1,name:c[0],yjsDocMap:new Map});function l(e,t){let s=(0,n.useContext)(r);return null!=e&&(s.name=e),null!=t&&(s.color=t),s}},54335:function(e,t,s){s.d(t,{F:function(){return u}});var n=s(56263),a=s(46895),c=s(81919),r=s(67294),l=s(18824),o=s(61084),i=s(73935),d=s(29527),h=s(85893);function u({id:e,providerFactory:t,shouldBootstrap:s,username:l,cursorColor:o,cursorsContainerRef:i,initialEditorState:d,excludedProperties:u,awarenessData:g}){let m=(0,r.useRef)(!1),p=(0,r.useRef)(!1),b=(0,n.Z)(l,o),{yjsDocMap:w,name:y,color:E}=b,[v]=(0,a.g)();(0,r.useEffect)(()=>(b.isCollabActive=!0,()=>{null==v._parentEditor&&(b.isCollabActive=!1)}),[b,v]);let[C,_]=(0,r.useState)();(0,r.useEffect)(()=>{if(p.current)return;p.current=!0;let s=t(e,w);return _(s),()=>{s.disconnect()}},[e,t,w]);let[S,k]=(0,r.useState)(w.get(e)),[I,M]=(0,r.useState)();return(0,r.useEffect)(()=>{if(!C||m.current)return;m.current=!0;let t=(0,c.np)(v,C,e,S||w.get(e),w,u);return M(t),()=>{t.root.destroy(t)}},[v,C,e,w,S,u]),C&&I?(0,h.jsx)(f,{awarenessData:g,binding:I,collabContext:b,color:E,cursorsContainerRef:i,editor:v,id:e,initialEditorState:d,name:y,provider:C,setDoc:k,shouldBootstrap:s,yjsDocMap:w}):(0,h.jsx)(h.Fragment,{})}function f({editor:e,id:t,provider:s,yjsDocMap:n,name:a,color:u,shouldBootstrap:f,cursorsContainerRef:g,initialEditorState:m,awarenessData:p,collabContext:b,binding:w,setDoc:y}){var E,v,C,_,S;let k=function(e,t,s,n,a,l,u,f,g,m,p,b){let w=(0,r.useRef)(!1),y=(0,r.useCallback)(()=>s.connect(),[s]),E=(0,r.useCallback)(()=>{try{s.disconnect()}catch(e){}},[s]);(0,r.useEffect)(()=>{let{root:r}=f,{awareness:i}=s,h=({status:t})=>{e.dispatchCommand(c.Lb,"connected"===t)},m=t=>{u&&t&&r.isEmpty()&&0===r._xmlText._length&&!1===w.current&&function(e,t){e.update(()=>{let s=(0,o.Gv)();if(s.isEmpty()){if(t)switch(typeof t){case"string":{let n=e.parseEditorState(t);e.setEditorState(n,{tag:"history-merge"});break}case"object":e.setEditorState(t,{tag:"history-merge"});break;case"function":e.update(()=>{(0,o.Gv)().isEmpty()&&t(e)},{tag:"history-merge"})}else{let a=(0,o.BE)();s.append(a);let{activeElement:c}=document;(null!==(0,o.dL)()||null!==c&&c===e.getRootElement())&&a.select()}}},{tag:"history-merge"})}(e,p),w.current=!1},v=()=>{(0,c.Ug)(f,s)},C=(e,t)=>{let n=t.origin;n!==f&&(0,c.iw)(f,s,e,n instanceof d.H6)};(0,c.SL)(s,a,l,document.activeElement===e.getRootElement(),b||{});let _=s=>{!function(e,t){if(e.update(()=>{let e=(0,o.Gv)();e.clear(),e.select()},{tag:"skip-collab"}),null==t.cursors)return;let s=t.cursors;if(null==s)return;let n=t.cursorsContainer;if(null==n)return;let a=Array.from(s.values());for(let c=0;c<a.length;c++){let r=a[c].selection;if(r&&null!=r.selections){let l=r.selections;for(let i=0;i<l.length;i++)n.removeChild(l[c])}}}(e,f),g(s),n.set(t,s),w.current=!0};s.on("reload",_),s.on("status",h),s.on("sync",m),i.on("update",v),r.getSharedType().observeDeep(C);let S=e.registerUpdateListener(({prevEditorState:e,editorState:t,dirtyLeaves:n,dirtyElements:a,normalizedNodes:r,tags:l})=>{!1===l.has("skip-collab")&&(0,c.HU)(f,s,e,t,a,n,r,l)}),k=y();return()=>{!1===w.current&&(k?k.then(E):E()),s.off("sync",m),s.off("status",h),s.off("reload",_),i.off("update",v),r.getSharedType().unobserveDeep(C),n.delete(t),S()}},[f,l,y,E,n,e,t,p,a,s,u,b,g]);let v=(0,r.useMemo)(()=>(0,i.createPortal)((0,h.jsx)("div",{ref(e){f.cursorsContainer=e}}),m&&m.current||document.body),[f,m]);return(0,r.useEffect)(()=>e.registerCommand(c.MO,e=>(e?(console.log("Collaboration connected!"),y()):(console.log("Collaboration disconnected!"),E()),!0),o.VN),[y,E,e]),v}(e,t,s,n,a,u,f,w,y,g,m,p);
1return b.clientID=w.clientID,function(e,t){let s=(0,r.useMemo)(()=>(0,c.U0)(t,t.root.getSharedType()),[t]);(0,r.useEffect)(()=>(0,l.qV)(e.registerCommand(o.$l,()=>(s.undo(),!0),o.VN),e.registerCommand(o.zq,()=>(s.redo(),!0),o.VN)));let n=(0,r.useCallback)(()=>{s.clear()},[s]);r.useEffect(()=>{let t=()=>{e.dispatchCommand(o.yn,s.undoStack.length>0),e.dispatchCommand(o.r0,s.redoStack.length>0)};return s.on("stack-item-added",t),s.on("stack-item-popped",t),s.on("stack-cleared",t),()=>{s.off("stack-item-added",t),s.off("stack-item-popped",t),s.off("stack-cleared",t)}},[e,s])}(e,w),(0,r.useEffect)(()=>(0,l.qV)(e.registerCommand(o.m$,()=>((0,c.w3)(s,a,u,!0,p||{}),!1),o.VN),e.registerCommand(o.Gq,()=>((0,c.w3)(s,a,u,!1,p||{}),!1),o.VN)),[u,e,a,s,p]),k}},73171:function(e,t,s){s.d(t,{VU:function(){return Z}});var n=s(69805),a=s(45064),c=s(68137),r=s(5575);let l=new Map,o="undefined"==typeof BroadcastChannel?class{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&null!==this.onmessage&&this.onmessage({data:c.Gh(t.newValue||"")}),r.z2(this._onChange)}postMessage(e){r.XN.setItem(this.room,c.s3(c.eh(e)))}close(){r.F(this._onChange)}}:BroadcastChannel,i=e=>n.Yu(l,e,()=>{let t=a.Ue(),s=new o(e);return s.onmessage=e=>t.forEach(t=>t(e.data,"broadcastchannel")),{bc:s,subs:t}}),d=(e,t)=>(i(e).subs.add(t),t),h=(e,t)=>{let s=i(e),n=s.subs.delete(t);return n&&0===s.subs.size&&(s.bc.close(),l.delete(e)),n},u=(e,t,s=null)=>{let n=i(e);n.bc.postMessage(t),n.subs.forEach(e=>e(t,s))};var f=s(21371),g=s(65580),m=s(55913),p=s(29527);let b=(e,t)=>{g.uE(e,0);let s=p.gJ(t);g.mP(e,s)},w=(e,t,s)=>{g.uE(e,1),g.mP(e,p.D$(t,s))},y=(e,t,s)=>w(t,s,m.HN(e)),E=(e,t,s)=>{try{p.NG(t,m.HN(e),s)}catch(n){console.error("Caught error while handling a Yjs update",n)}},v=(e,t)=>{g.uE(e,2),g.mP(e,t)},C=(e,t,s,n)=>{let a=m.yg(e);switch(a){case 0:y(e,t,s);break;case 1:case 2:E(e,s,n);break;default:throw Error("Unknown message type")}return a},_=(e,t,s)=>{0===m.yg(e)&&s(t,m.kf(e))};var S=s(40909),k=s(46320),I=s(81351);class M extends k.y{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=f.ZG();null!==this.getLocalState()&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((s,n)=>{n!==this.clientID&&3e4<=e-s.lastUpdated&&this.states.has(n)&&t.push(n)}),t.length>0&&D(this,t,"timeout")},S.GW(3e3)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,s=this.meta.get(t),n=void 0===s?0:s.clock+1,a=this.states.get(t);null===e?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:n,lastUpdated:f.ZG()});let c=[],r=[],l=[],o=[];null===e?o.push(t):null==a?null!=e&&c.push(t):(r.push(t),I.Hi(a,e)||l.push(t)),(c.length>0||l.length>0||o.length>0)&&this.emit("change",[{added:c,updated:l,removed:o},"local"]),this.emit("update",[{added:c,updated:r,removed:o},"local"])}setLocalStateField(e,t){let s=this.getLocalState();null!==s&&this.setLocalState({...s,[e]:t})}getStates(){return this.states}}let D=(e,t,s)=>{let n=[];for(let a=0;a<t.length;a++){let c=t[a];if(e.states.has(c)){if(e.states.delete(c),c===e.clientID){let r=e.meta.get(c);e.meta.set(c,{clock:r.clock+1,lastUpdated:f.ZG()})}n.push(c)}}n.length>0&&(e.emit("change",[{added:[],updated:[],removed:n},s]),e.emit("update",[{added:[],updated:[],removed:n},s]))},U=(e,t,s=e.states)=>{let n=t.length,a=g.Mf();g.uE(a,n);for(let c=0;c<n;c++){let r=t[c],l=s.get(r)||null,o=e.meta.get(r).clock;g.uE(a,r),g.uE(a,o),g.uw(a,JSON.stringify(l))}return g._f(a)},L=(e,t,s)=>{let n=m.l1(t),a=f.ZG(),c=[],r=[],l=[],o=[],i=m.yg(n);for(let d=0;d<i;d++){let h=m.yg(n),u=m.yg(n),g=JSON.parse(m.kf(n)),p=e.meta.get(h),b=e.states.get(h),w=void 0===p?0:p.clock;(w<u||w===u&&null===g&&e.states.has(h))&&(null===g?h===e.clientID&&null!=e.getLocalState()?u++:e.states.delete(h):e.states.set(h,g),e.meta.set(h,{clock:u,lastUpdated:a}),void 0===p&&null!==g?c.push(h):void 0!==p&&null===g?o.push(h):null!==g&&(I.Hi(g,b)||l.push(h),r.push(h)))}(c.length>0||l.length>0||o.length>0)&&e.emit("change",[{added:c,updated:l,removed:o},s]),(c.length>0||r.length>0||o.length>0)&&e.emit("update",[{added:c,updated:r,removed:o},s])};var x=s(49776);let H=e=>x.UI(e,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&");var R=s(50898),G=s(83454);let N=[];N[0]=(e,t,s,n,a)=>{g.uE(e,0);let c=C(t,e,s.doc,s);n&&1===c&&!s.synced&&(s.synced=!0)},N[3]=(e,t,s,n,a)=>{g.uE(e,1),g.mP(e,U(s.awareness,Array.from(s.awareness.getStates().keys())))},N[1]=(e,t,s,n,a)=>{L(s.awareness,m.HN(t),s)},N[2]=(e,t,s,n,a)=>{_(t,s.doc,(e,t)=>B(s,t))};let B=(e,t)=>console.warn(`Permission denied to access ${e.url}.
2${t}`),P=(e,t,s)=>{let n=m.l1(t),a=g.Mf(),c=m.yg(n),r=e.messageHandlers[c];return r?r(a,n,e,s,c):console.error("Unable to compute message"),a},V=e=>{if(e.shouldConnect&&null===e.ws){let t=new e._WS(e.url,e.protocols);t.binaryType="arraybuffer",e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=s=>{e.wsLastMessageReceived=f.ZG();let n=P(e,new Uint8Array(s.data),!0);g.kE(n)>1&&t.send(g._f(n))},t.onerror=t=>{e.emit("connection-error",[t,e])},t.onclose=t=>{e.emit("connection-close",[t,e]),e.ws=null,e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,D(e.awareness,Array.from(e.awareness.getStates().keys()).filter(t=>t!==e.doc.clientID),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(V,S.VV(100*S.sQ(2,e.wsUnsuccessfulReconnects),e.maxBackoffTime),e)},t.onopen=()=>{e.wsLastMessageReceived=f.ZG(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);let s=g.Mf();
2if(g.uE(s,0),b(s,e.doc),t.send(g._f(s)),null!==e.awareness.getLocalState()){let n=g.Mf();g.uE(n,1),g.mP(n,U(e.awareness,[e.doc.clientID])),t.send(g._f(n))}},e.emit("status",[{status:"connecting"}])}},j=(e,t)=>{let s=e.ws;e.wsconnected&&s&&s.readyState===s.OPEN&&s.send(t),e.bcconnected&&u(e.bcChannel,t,e)};class Z extends k.y{constructor(e,t,s,{connect:n=!0,awareness:a=new M(s),params:c={},protocols:r=[],WebSocketPolyfill:l=WebSocket,resyncInterval:o=-1,maxBackoffTime:i=2500,disableBc:d=!1}={}){for(super();"/"===e[e.length-1];)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+"/"+t,this.maxBackoffTime=i,this.params=c,this.protocols=r,this.roomname=t,this.doc=s,this._WS=l,this.awareness=a,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=d,this.wsUnsuccessfulReconnects=0,this.messageHandlers=N.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=n,this._resyncInterval=0,o>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){let e=g.Mf();g.uE(e,0),b(e,s),this.ws.send(g._f(e))}},o)),this._bcSubscriber=(e,t)=>{if(t!==this){let s=P(this,new Uint8Array(e),!1);g.kE(s)>1&&u(this.bcChannel,g._f(s),this)}},this._updateHandler=(e,t)=>{if(t!==this){let s=g.Mf();g.uE(s,0),v(s,e),j(this,g._f(s))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:t,removed:s},n)=>{let c=e.concat(t).concat(s),r=g.Mf();g.uE(r,1),g.mP(r,U(a,c)),j(this,g._f(r))},this._exitHandler=()=>{D(this.awareness,[s.clientID],"app closed")},R.UG&&void 0!==G&&G.on("exit",this._exitHandler),a.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&3e4<f.ZG()-this.wsLastMessageReceived&&this.ws.close()},3e3),n&&this.connect()}get url(){let e=H(this.params);return this.serverUrl+"/"+this.roomname+(0===e.length?"":"?"+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){0!==this._resyncInterval&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),R.UG&&void 0!==G&&G.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(d(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);let e=g.Mf();g.uE(e,0),b(e,this.doc),u(this.bcChannel,g._f(e),this);let t=g.Mf();g.uE(t,0),w(t,this.doc),u(this.bcChannel,g._f(t),this);let s=g.Mf();g.uE(s,3),u(this.bcChannel,g._f(s),this);let n=g.Mf();g.uE(n,1),g.mP(n,U(this.awareness,[this.doc.clientID])),u(this.bcChannel,g._f(n),this)}disconnectBc(){let e=g.Mf();g.uE(e,1),g.mP(e,U(this.awareness,[this.doc.clientID],new Map)),j(this,g._f(e)),this.bcconnected&&(h(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),null!==this.ws&&this.ws.close()}connect(){this.shouldConnect=!0,this.wsconnected||null!==this.ws||(V(this),this.connectBc())}}}}]);

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.