import{r as E,R as f,p as g,a3 as j,a4 as k,a5 as u}from"./index-41a412db.js";function h(){return h=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},h.apply(this,arguments)}function T(e,r){if(e==null)return{};var t=L(e,r),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)n=o[s],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}function L(e,r){if(e==null)return{};var t={},n=Object.keys(e),s,o;for(o=0;o<n.length;o++)s=n[o],!(r.indexOf(s)>=0)&&(t[s]=e[s]);return t}var y=E.forwardRef(function(e,r){var t=e.color,n=t===void 0?"currentColor":t,s=e.size,o=s===void 0?24:s,a=T(e,["color","size"]);return f.createElement("svg",h({ref:r,xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a),f.createElement("polyline",{points:"3 6 5 6 21 6"}),f.createElement("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),f.createElement("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),f.createElement("line",{x1:"14",y1:"11",x2:"14",y2:"17"}))});y.propTypes={color:g.string,size:g.oneOfType([g.string,g.number])};y.displayName="Trash2";const P=y,x="/logs",$=new TextDecoder("utf-8"),M=()=>Math.floor((1+Math.random())*65536).toString(16);let b=!1,c=!1,p="",l,m;function v(e,r){let t;try{t=JSON.parse(e)}catch{console.log("JSON.parse error",JSON.parse(e))}const n=new Date,s=R(n);t.time=s,t.id=+n-0+M(),t.even=b=!b,r(t)}function R(e){const r=e.getFullYear()%100,t=u(e.getMonth()+1,2),n=u(e.getDate(),2),s=u(e.getHours(),2),o=u(e.getMinutes(),2),a=u(e.getSeconds(),2);return`${r}-${t}-${n} ${s}:${o}:${a}`}function S(e,r){return e.read().then(({done:t,value:n})=>{const s=$.decode(n,{stream:!t});p+=s;const o=p.split(`
`),a=o[o.length-1];for(let d=0;d<o.length-1;d++)v(o[d],r);if(t){v(a,r),p="",console.log("GET /logs streaming done"),c=!1;return}else p=a;return S(e,r)})}function w(e){const r=Object.keys(e);return r.sort(),r.map(t=>e[t]).join("|")}let O,i;function D(e,r){if(e.logLevel==="uninit"||c||l&&l.readyState===1)return;m=r;const t=j(e,x);l=new WebSocket(t),l.addEventListener("error",()=>{W(e,r)}),l.addEventListener("message",function(n){v(n.data,r)})}function H(){l.close(),i&&i.abort()}function N(e){!m||!l||(l.close(),c=!1,D(e,m))}function W(e,r){if(i&&w(e)!==O)i.abort();else if(c)return;c=!0,O=w(e),i=new AbortController;const t=i.signal,{url:n,init:s}=k(e);fetch(n+x+"?level="+e.logLevel,{...s,signal:t}).then(o=>{const a=o.body.getReader();S(a,r)},o=>{c=!1,!t.aborted&&console.log("GET /logs error:",o.message)})}export{P as T,D as f,N as r,H as s};
