shraga 0.1.72 → 0.1.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1455,7 +1455,7 @@ Error generating stack: `+g.message+`
|
|
|
1455
1455
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1456
1456
|
* See the License for the specific language governing permissions and
|
|
1457
1457
|
* limitations under the License.
|
|
1458
|
-
*/const AK=300,kK=vD("authIdTokenMaxAge")||AK;let TT=null;const OK=e=>async t=>{const n=t&&await t.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>kK)return;const i=n==null?void 0:n.token;TT!==i&&(TT=i,await fetch(e,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))};function CK(e=mH()){const t=wD(e,"auth");if(t.isInitialized())return t.getImmediate();const n=a7(e,{popupRedirectResolver:wK,persistence:[I7,x7,VD]}),r=vD("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const a=new URL(r,location.origin);if(location.origin===a.origin){const s=OK(a.toString());m7(n,s,()=>s(n.currentUser)),p7(n,c=>s(c))}}const i=Z8("auth");return i&&s7(n,`http://${i}`),n}function TK(){var e,t;return(t=(e=document.getElementsByTagName("head"))===null||e===void 0?void 0:e[0])!==null&&t!==void 0?t:document}t7({loadJS(e){return new Promise((t,n)=>{const r=document.createElement("script");r.setAttribute("src",e),r.onload=t,r.onerror=i=>{const a=Di("internal-error");a.customData=i,n(a)},r.type="text/javascript",r.charset="UTF-8",TK().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});_K("Browser");const NK={initNative:()=>Promise.resolve(!1),push:{capability:"none",register:()=>Promise.reject(new Error("push unavailable on web")),requestPermission:()=>Promise.resolve("denied"),onTap:()=>()=>{},onMessage:()=>()=>{}},initDesktopAttention:()=>Promise.resolve(!1),isDesktopShell:()=>!1,requestDesktopAttention:()=>{},setDesktopBadge:()=>{},canUseNativeGoogleSignIn:()=>Promise.resolve(!1),signInWithGoogleNative:()=>Promise.reject(new Error("native Google sign-in unavailable on web"))};let MK=NK;function Za(){return MK}function IK(){return Za().canUseNativeGoogleSignIn()}function RK(e){return Za().signInWithGoogleNative(e)}const PK=typeof window<"u"&&window.__SHRAGA_WEB_CONFIG__||{},tj=PK.firebase??JSON.parse("{}"),nj=!!tj.apiKey,kl=nj?CK(ED(tj)):null;async function DK(){if(!kl)throw new Error("Firebase not configured");if(await IK()){await RK(kl);return}await L7(kl,new Xa)}async function jK(){kl&&await v7(kl)}function LK(e){return kl?g7(kl,e):(e(null),()=>{})}const R0="shraga_token";function zK(e){try{const t=atob(e.slice(4).split(".")[1].replace(/-/g,"+").replace(/_/g,"/"));return t.slice(0,t.lastIndexOf(":"))||null}catch{return null}}function rj(){const[e,t]=y.useState(null),[n,r]=y.useState(null),[i,a]=y.useState(!0),[s,c]=y.useState(null),[u,f]=y.useState(!1),h=y.useRef(null),p=y.useRef(null);y.useEffect(()=>{let O;return(async()=>{let k=nj?"firebase":"local";try{const C=await fetch("/api/auth/mode");if(C.ok){const N=await C.json();k=N.provider==="firebase"?"firebase":"local",f(!!N.needsSetup)}}catch{}if(c(k),k==="firebase")O=LK(async C=>{p.current=C;const N=C?await C.getIdToken():null;h.current=N,r(N),t(C?{uid:C.uid,email:C.email}:null),a(!1)});else{const C=localStorage.getItem(R0);if(C){h.current=C,r(C);const N=zK(C);t({uid:N??"user",email:N})}a(!1)}})(),()=>O==null?void 0:O()},[]);const m=y.useCallback(async()=>s==="firebase"?p.current?p.current.getIdToken():null:h.current,[s]),v=(O,k)=>{localStorage.setItem(R0,O),h.current=O,r(O),t({uid:k,email:k}),f(!1)},x=y.useCallback(async(O,k,C)=>{try{const N=await fetch(`/api/auth/${O}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({email:k,password:C})}),T=await N.json().catch(()=>({}));return!N.ok||!T.token?T.error||"Authentication failed":(v(T.token,k),null)}catch(N){return(N==null?void 0:N.message)||"Network error"}},[]),b=y.useCallback((O,k)=>x("login",O,k),[x]),S=y.useCallback((O,k)=>x("register",O,k),[x]),_=y.useCallback(async()=>{s==="firebase"?await jK():(localStorage.removeItem(R0),h.current=null,r(null),t(null))},[s]);return{user:e,token:n,getToken:m,loading:i,mode:s,needsSetup:u,loginLocal:b,registerLocal:S,logout:_}}class $K{constructor(){fi(this,"ws",null);fi(this,"listeners",new Set);fi(this,"tokenProvider",async()=>null);fi(this,"intentionalClose",!1);fi(this,"reconnecting",!1);fi(this,"authRetries",0);fi(this,"pendingMessage",null);fi(this,"connectAttempts",0)}connect(t){this.tokenProvider=t,this.intentionalClose=!1;const r=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`;console.log("[ws] connecting…"),this.ws=new WebSocket(r),this.ws.onopen=async()=>{var a;this.connectAttempts=0;let i=null;try{i=await this.tokenProvider()}catch(s){console.warn("[ws] token fetch failed",s)}((a=this.ws)==null?void 0:a.readyState)===WebSocket.OPEN&&(console.log("[ws] open, sending auth"),this.ws.send(JSON.stringify({type:"auth",token:i})),this.reconnecting&&(this.reconnecting=!1,this.listeners.forEach(s=>s({type:"reconnected"}))))},this.ws.onmessage=i=>{var a;try{const s=JSON.parse(i.data);if(s.type!=="text_delta"&&console.log("[ws] ←",s.type),s.type==="auth_ok"&&(this.authRetries=0,this.flushPending()),s.type==="auth_error"){const c=((a=s.message)==null?void 0:a.toLowerCase())??"";c.includes("whitelist")||c.includes("audience mismatch")||c.includes("sign out and sign in")?this.intentionalClose=!0:(this.authRetries++,console.log(`[ws] auth failed (attempt ${this.authRetries}), will retry with fresh token`))}this.listeners.forEach(c=>c(s))}catch(s){console.warn("[ws] bad frame",s)}},this.ws.onclose=i=>{if(console.log(`[ws] closed code=${i.code} intentional=${this.intentionalClose}`),!this.intentionalClose){this.reconnecting=!0,this.connectAttempts++,this.listeners.forEach(u=>u({type:"disconnected"}));const a=this.authRetries>0?Math.min(2e3*this.authRetries,1e4):Math.min(1e3*2**this.connectAttempts,3e4),s=Math.random()*1e3,c=a+s;console.log(`[ws] reconnecting in ${(c/1e3).toFixed(1)}s (attempt ${this.connectAttempts})`),setTimeout(()=>this.connect(this.tokenProvider),c)}},this.ws.onerror=i=>console.warn("[ws] error",i)}flushPending(){if(this.pendingMessage){const t=this.pendingMessage;this.pendingMessage=null,console.log("[ws] flushing pending message after reconnect"),this.send(t)||(this.pendingMessage=t)}}disconnect(){var t;this.intentionalClose=!0,(t=this.ws)==null||t.close(),this.ws=null}send(t){var n,r;return((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN?(console.log("[ws] →",t.type),this.ws.send(JSON.stringify(t)),!0):(console.warn("[ws] send failed, readyState=",(r=this.ws)==null?void 0:r.readyState),!1)}sendOrQueue(t){return this.send(t)?!0:(this.pendingMessage=t,console.log("[ws] message queued for reconnect"),!1)}cancel(t){this.send({type:"cancel",sessionId:t})}steer(t,n){this.send({type:"steer",text:t,sessionId:n})}respondPermission(t,n,r){this.send({type:"permission_response",id:t,allow:n,allowAll:r})}respondQuestion(t,n){this.send({type:"question_response",id:t,answers:n})}sendPresence(t,n){this.send({type:"presence",sessionId:t??null,focused:n})}sendClientPresence(t,n){this.send({type:"client_presence",sessionId:t??null,visible:n})}markRead(t){this.send({type:"mark_read",sessionId:t})}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}}function BK(e,t,n){const[r,i]=y.useState(null),[a,s]=y.useState(null),[c,u]=y.useState(null),f=y.useRef(void 0),h=y.useRef(t);h.current=t;const p=y.useRef(n);return p.current=n,y.useEffect(()=>{if(!e)return;let m;const v=new $K;i(v),v.connect(()=>h.current());const x=v.on(b=>{var S,_;switch(b.type){case"auth_ok":b.buildId&&(f.current&&f.current!==b.buildId?s("update_available"):f.current=b.buildId);break;case"auth_error":(S=b.message)!=null&&S.toLowerCase().includes("whitelist")&&u(b.message);break;case"server_restarting":s("server_restarting");break;case"disconnected":s(O=>O==="server_restarting"?O:"disconnected");break;case"reconnected":s(O=>O==="update_available"?O:"reconnected"),m=setTimeout(()=>s(O=>O==="update_available"?O:null),2e3);break}(_=p.current)==null||_.call(p,b)});return()=>{x(),clearTimeout(m),v.disconnect(),i(null)}},[e]),{socket:r,connectionStatus:a,authError:c}}const UK={get capability(){return Za().push.capability},register:()=>Za().push.register(),requestPermission:()=>Za().push.requestPermission(),onTap:e=>Za().push.onTap(e),onMessage:e=>Za().push.onMessage(e)};function FK(){return Za().initNative()}function HK(){return typeof document>"u"?!0:!document.hidden}function KK(e){if(typeof document>"u")return()=>{};const t=()=>e(!document.hidden);return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)}function ij(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=ij(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function vt(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=ij(e))&&(r&&(r+=" "),r+=t);return r}const nE="-",qK=e=>{const t=VK(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:s=>{const c=s.split(nE);return c[0]===""&&c.length!==1&&c.shift(),aj(c,t)||GK(s)},getConflictingClassGroupIds:(s,c)=>{const u=n[s]||[];return c&&r[s]?[...u,...r[s]]:u}}},aj=(e,t)=>{var s;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?aj(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const a=e.join(nE);return(s=t.validators.find(({validator:c})=>c(a)))==null?void 0:s.classGroupId},NT=/^\[(.+)\]$/,GK=e=>{if(NT.test(e)){const t=NT.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},VK=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return YK(Object.entries(e.classGroups),n).forEach(([a,s])=>{cw(s,r,a,t)}),r},cw=(e,t,n,r)=>{e.forEach(i=>{if(typeof i=="string"){const a=i===""?t:MT(t,i);a.classGroupId=n;return}if(typeof i=="function"){if(WK(i)){cw(i(r),t,n,r);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([a,s])=>{cw(s,MT(t,a),n,r)})})},MT=(e,t)=>{let n=e;return t.split(nE).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},WK=e=>e.isThemeGetter,YK=(e,t)=>t?e.map(([n,r])=>{const i=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([s,c])=>[t+s,c])):a);return[n,i]}):e,XK=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(a,s)=>{n.set(a,s),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let s=n.get(a);if(s!==void 0)return s;if((s=r.get(a))!==void 0)return i(a,s),s},set(a,s){n.has(a)?n.set(a,s):i(a,s)}}},oj="!",ZK=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],a=t.length,s=c=>{const u=[];let f=0,h=0,p;for(let S=0;S<c.length;S++){let _=c[S];if(f===0){if(_===i&&(r||c.slice(S,S+a)===t)){u.push(c.slice(h,S)),h=S+a;continue}if(_==="/"){p=S;continue}}_==="["?f++:_==="]"&&f--}const m=u.length===0?c:c.substring(h),v=m.startsWith(oj),x=v?m.substring(1):m,b=p&&p>h?p-h:void 0;return{modifiers:u,hasImportantModifier:v,baseClassName:x,maybePostfixModifierPosition:b}};return n?c=>n({className:c,parseClassName:s}):s},QK=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},JK=e=>({cache:XK(e.cacheSize),parseClassName:ZK(e),...qK(e)}),eq=/\s+/,tq=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,a=[],s=e.trim().split(eq);let c="";for(let u=s.length-1;u>=0;u-=1){const f=s[u],{modifiers:h,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:v}=n(f);let x=!!v,b=r(x?m.substring(0,v):m);if(!b){if(!x){c=f+(c.length>0?" "+c:c);continue}if(b=r(m),!b){c=f+(c.length>0?" "+c:c);continue}x=!1}const S=QK(h).join(":"),_=p?S+oj:S,O=_+b;if(a.includes(O))continue;a.push(O);const k=i(b,x);for(let C=0;C<k.length;++C){const N=k[C];a.push(_+N)}c=f+(c.length>0?" "+c:c)}return c};function nq(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=sj(t))&&(r&&(r+=" "),r+=n);return r}const sj=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=sj(e[r]))&&(n&&(n+=" "),n+=t);return n};function rq(e,...t){let n,r,i,a=s;function s(u){const f=t.reduce((h,p)=>p(h),e());return n=JK(f),r=n.cache.get,i=n.cache.set,a=c,c(u)}function c(u){const f=r(u);if(f)return f;const h=tq(u,n);return i(u,h),h}return function(){return a(nq.apply(null,arguments))}}const Wt=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},lj=/^\[(?:([a-z-]+):)?(.+)\]$/i,iq=/^\d+\/\d+$/,aq=new Set(["px","full","screen"]),oq=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sq=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,lq=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,cq=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,uq=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Va=e=>lu(e)||aq.has(e)||iq.test(e),is=e=>Ru(e,"length",yq),lu=e=>!!e&&!Number.isNaN(Number(e)),P0=e=>Ru(e,"number",lu),Yf=e=>!!e&&Number.isInteger(Number(e)),fq=e=>e.endsWith("%")&&lu(e.slice(0,-1)),tt=e=>lj.test(e),as=e=>oq.test(e),dq=new Set(["length","size","percentage"]),hq=e=>Ru(e,dq,cj),pq=e=>Ru(e,"position",cj),mq=new Set(["image","url"]),gq=e=>Ru(e,mq,xq),vq=e=>Ru(e,"",bq),Xf=()=>!0,Ru=(e,t,n)=>{const r=lj.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},yq=e=>sq.test(e)&&!lq.test(e),cj=()=>!1,bq=e=>cq.test(e),xq=e=>uq.test(e),wq=()=>{const e=Wt("colors"),t=Wt("spacing"),n=Wt("blur"),r=Wt("brightness"),i=Wt("borderColor"),a=Wt("borderRadius"),s=Wt("borderSpacing"),c=Wt("borderWidth"),u=Wt("contrast"),f=Wt("grayscale"),h=Wt("hueRotate"),p=Wt("invert"),m=Wt("gap"),v=Wt("gradientColorStops"),x=Wt("gradientColorStopPositions"),b=Wt("inset"),S=Wt("margin"),_=Wt("opacity"),O=Wt("padding"),k=Wt("saturate"),C=Wt("scale"),N=Wt("sepia"),T=Wt("skew"),R=Wt("space"),L=Wt("translate"),D=()=>["auto","contain","none"],P=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto",tt,t],I=()=>[tt,t],U=()=>["",Va,is],V=()=>["auto",lu,tt],G=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],$=()=>["solid","dashed","dotted","double","none"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>["start","end","center","between","around","evenly","stretch"],Z=()=>["","0",tt],j=()=>["auto","avoid","all","avoid-page","page","left","right","column"],H=()=>[lu,tt];return{cacheSize:500,separator:":",theme:{colors:[Xf],spacing:[Va,is],blur:["none","",as,tt],brightness:H(),borderColor:[e],borderRadius:["none","","full",as,tt],borderSpacing:I(),borderWidth:U(),contrast:H(),grayscale:Z(),hueRotate:H(),invert:Z(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[fq,is],inset:B(),margin:B(),opacity:H(),padding:I(),saturate:H(),scale:H(),sepia:Z(),skew:H(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",tt]}],container:["container"],columns:[{columns:[as]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...G(),tt]}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[b]}],"inset-x":[{"inset-x":[b]}],"inset-y":[{"inset-y":[b]}],start:[{start:[b]}],end:[{end:[b]}],top:[{top:[b]}],right:[{right:[b]}],bottom:[{bottom:[b]}],left:[{left:[b]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Yf,tt]}],basis:[{basis:B()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",tt]}],grow:[{grow:Z()}],shrink:[{shrink:Z()}],order:[{order:["first","last","none",Yf,tt]}],"grid-cols":[{"grid-cols":[Xf]}],"col-start-end":[{col:["auto",{span:["full",Yf,tt]},tt]}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":[Xf]}],"row-start-end":[{row:["auto",{span:[Yf,tt]},tt]}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",tt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",tt]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...K()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...K(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...K(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[O]}],px:[{px:[O]}],py:[{py:[O]}],ps:[{ps:[O]}],pe:[{pe:[O]}],pt:[{pt:[O]}],pr:[{pr:[O]}],pb:[{pb:[O]}],pl:[{pl:[O]}],m:[{m:[S]}],mx:[{mx:[S]}],my:[{my:[S]}],ms:[{ms:[S]}],me:[{me:[S]}],mt:[{mt:[S]}],mr:[{mr:[S]}],mb:[{mb:[S]}],ml:[{ml:[S]}],"space-x":[{"space-x":[R]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[R]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",tt,t]}],"min-w":[{"min-w":[tt,t,"min","max","fit"]}],"max-w":[{"max-w":[tt,t,"none","full","min","max","fit","prose",{screen:[as]},as]}],h:[{h:[tt,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[tt,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[tt,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[tt,t,"auto","min","max","fit"]}],"font-size":[{text:["base",as,is]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",P0]}],"font-family":[{font:[Xf]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",tt]}],"line-clamp":[{"line-clamp":["none",lu,P0]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Va,tt]}],"list-image":[{"list-image":["none",tt]}],"list-style-type":[{list:["none","disc","decimal",tt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[_]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[_]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...$(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Va,is]}],"underline-offset":[{"underline-offset":["auto",Va,tt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",tt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",tt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[_]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...G(),pq]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",hq]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},gq]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[v]}],"gradient-via":[{via:[v]}],"gradient-to":[{to:[v]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[c]}],"border-w-x":[{"border-x":[c]}],"border-w-y":[{"border-y":[c]}],"border-w-s":[{"border-s":[c]}],"border-w-e":[{"border-e":[c]}],"border-w-t":[{"border-t":[c]}],"border-w-r":[{"border-r":[c]}],"border-w-b":[{"border-b":[c]}],"border-w-l":[{"border-l":[c]}],"border-opacity":[{"border-opacity":[_]}],"border-style":[{border:[...$(),"hidden"]}],"divide-x":[{"divide-x":[c]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[c]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[_]}],"divide-style":[{divide:$()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...$()]}],"outline-offset":[{"outline-offset":[Va,tt]}],"outline-w":[{outline:[Va,is]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[_]}],"ring-offset-w":[{"ring-offset":[Va,is]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",as,vq]}],"shadow-color":[{shadow:[Xf]}],opacity:[{opacity:[_]}],"mix-blend":[{"mix-blend":[...q(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":q()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",as,tt]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[p]}],saturate:[{saturate:[k]}],sepia:[{sepia:[N]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[p]}],"backdrop-opacity":[{"backdrop-opacity":[_]}],"backdrop-saturate":[{"backdrop-saturate":[k]}],"backdrop-sepia":[{"backdrop-sepia":[N]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",tt]}],duration:[{duration:H()}],ease:[{ease:["linear","in","out","in-out",tt]}],delay:[{delay:H()}],animate:[{animate:["none","spin","ping","pulse","bounce",tt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[C]}],"scale-x":[{"scale-x":[C]}],"scale-y":[{"scale-y":[C]}],rotate:[{rotate:[Yf,tt]}],"translate-x":[{"translate-x":[L]}],"translate-y":[{"translate-y":[L]}],"skew-x":[{"skew-x":[T]}],"skew-y":[{"skew-y":[T]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",tt]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",tt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",tt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Va,is,P0]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},Eq=rq(wq);function He(...e){return Eq(vt(e))}function ms(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Sq(e){const{socket:t,getToken:n,pushEnabled:r,activeSessionId:i,switchTo:a,openSession:s,onForegroundMessage:c}=e,[u,f]=y.useState(!1),h=y.useRef(a);h.current=a;const p=y.useRef(s);p.current=s;const m=y.useRef(c);m.current=c;const v=y.useRef(n);v.current=n,y.useEffect(()=>{FK().then(f)},[]);const x=y.useCallback(async()=>{try{const{platform:b,token:S,topic:_}=await UK.register(),O=await v.current(),k=await fetch("/api/push/register",{method:"POST",headers:{"Content-Type":"application/json",...O?{Authorization:`Bearer ${O}`}:{}},body:JSON.stringify({token:S,platform:b,topic:_})});if(!k.ok){console.warn("[push] register POST failed",k.status);return}console.log("[push] registered token with",window.location.origin)}catch(b){console.warn("[push] token registration failed",b)}},[]);return y.useEffect(()=>{},[u,r,x]),y.useEffect(()=>{if(!t)return;const b=()=>t.sendClientPresence(i,HK());return b(),KK(b)},[t,i]),{isNative:u}}function _q(){return Za().initDesktopAttention()}class Aq extends Error{constructor(t,n){super(`${t} ${n}`),this.status=t,this.name="ApiError"}}async function bl(e,t,n){const r=await t();if(!r)throw new Error("No auth token");const i=15e3,a=new AbortController,s=setTimeout(()=>a.abort(),i);try{const c=await fetch(e,{...n,signal:a.signal,headers:{Authorization:`Bearer ${r}`,...n==null?void 0:n.headers}});if(!c.ok)throw new Aq(c.status,c.statusText);return c}finally{clearTimeout(s)}}function uj(e){if(e.format==="conv")return e.messages.filter(n=>{var r;return((r=n.blocks)==null?void 0:r.length)>0});const t=[];for(const n of e.messages){const r=n.message;if(!(r!=null&&r.content))continue;const i=[];for(const a of r.content)if(a.type==="text"&&a.text)i.push({type:"text",text:a.text});else if(a.type==="tool_use")i.push({type:"tool_use",tool:a.name,toolUseId:a.id,input:a.input});else if(a.type==="tool_result"){const s=Array.isArray(a.content)?a.content.map(c=>c.text??"").join(""):String(a.content??"");i.push({type:"tool_result",toolUseId:String(a.tool_use_id),output:s})}i.length>0&&t.push({id:n.uuid||ms(),role:n.type==="user"?"user":"assistant",blocks:i})}return t}const fj=y.createContext(null),kq=fj.Provider;function rE(){const e=y.useContext(fj);if(!e)throw new Error("useWorkspace must be used within a WorkspaceProvider");return e}const dj=y.createContext({}),Oq=dj.Provider;function Sa(){return y.useContext(dj)}/**
|
|
1458
|
+
*/const AK=300,kK=vD("authIdTokenMaxAge")||AK;let TT=null;const OK=e=>async t=>{const n=t&&await t.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>kK)return;const i=n==null?void 0:n.token;TT!==i&&(TT=i,await fetch(e,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))};function CK(e=mH()){const t=wD(e,"auth");if(t.isInitialized())return t.getImmediate();const n=a7(e,{popupRedirectResolver:wK,persistence:[I7,x7,VD]}),r=vD("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const a=new URL(r,location.origin);if(location.origin===a.origin){const s=OK(a.toString());m7(n,s,()=>s(n.currentUser)),p7(n,c=>s(c))}}const i=Z8("auth");return i&&s7(n,`http://${i}`),n}function TK(){var e,t;return(t=(e=document.getElementsByTagName("head"))===null||e===void 0?void 0:e[0])!==null&&t!==void 0?t:document}t7({loadJS(e){return new Promise((t,n)=>{const r=document.createElement("script");r.setAttribute("src",e),r.onload=t,r.onerror=i=>{const a=Di("internal-error");a.customData=i,n(a)},r.type="text/javascript",r.charset="UTF-8",TK().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});_K("Browser");const NK={initNative:()=>Promise.resolve(!1),push:{capability:"none",register:()=>Promise.reject(new Error("push unavailable on web")),requestPermission:()=>Promise.resolve("denied"),onTap:()=>()=>{},onMessage:()=>()=>{}},initDesktopAttention:()=>Promise.resolve(!1),isDesktopShell:()=>!1,requestDesktopAttention:()=>{},setDesktopBadge:()=>{},canUseNativeGoogleSignIn:()=>Promise.resolve(!1),signInWithGoogleNative:()=>Promise.reject(new Error("native Google sign-in unavailable on web"))};let MK=NK;function Za(){return MK}function IK(){return Za().canUseNativeGoogleSignIn()}function RK(e){return Za().signInWithGoogleNative(e)}const PK=typeof window<"u"&&window.__SHRAGA_WEB_CONFIG__||{},tj=PK.firebase??JSON.parse("{}"),nj=!!tj.apiKey,kl=nj?CK(ED(tj)):null;async function DK(){if(!kl)throw new Error("Firebase not configured");if(await IK()){await RK(kl);return}const e=new Xa;e.setCustomParameters({prompt:"select_account"}),await L7(kl,e)}async function jK(){kl&&await v7(kl)}function LK(e){return kl?g7(kl,e):(e(null),()=>{})}const R0="shraga_token";function zK(e){try{const t=atob(e.slice(4).split(".")[1].replace(/-/g,"+").replace(/_/g,"/"));return t.slice(0,t.lastIndexOf(":"))||null}catch{return null}}function rj(){const[e,t]=y.useState(null),[n,r]=y.useState(null),[i,a]=y.useState(!0),[s,c]=y.useState(null),[u,f]=y.useState(!1),h=y.useRef(null),p=y.useRef(null);y.useEffect(()=>{let O;return(async()=>{let k=nj?"firebase":"local";try{const C=await fetch("/api/auth/mode");if(C.ok){const N=await C.json();k=N.provider==="firebase"?"firebase":"local",f(!!N.needsSetup)}}catch{}if(c(k),k==="firebase")O=LK(async C=>{p.current=C;const N=C?await C.getIdToken():null;h.current=N,r(N),t(C?{uid:C.uid,email:C.email}:null),a(!1)});else{const C=localStorage.getItem(R0);if(C){h.current=C,r(C);const N=zK(C);t({uid:N??"user",email:N})}a(!1)}})(),()=>O==null?void 0:O()},[]);const m=y.useCallback(async()=>s==="firebase"?p.current?p.current.getIdToken():null:h.current,[s]),v=(O,k)=>{localStorage.setItem(R0,O),h.current=O,r(O),t({uid:k,email:k}),f(!1)},x=y.useCallback(async(O,k,C)=>{try{const N=await fetch(`/api/auth/${O}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({email:k,password:C})}),T=await N.json().catch(()=>({}));return!N.ok||!T.token?T.error||"Authentication failed":(v(T.token,k),null)}catch(N){return(N==null?void 0:N.message)||"Network error"}},[]),b=y.useCallback((O,k)=>x("login",O,k),[x]),S=y.useCallback((O,k)=>x("register",O,k),[x]),_=y.useCallback(async()=>{s==="firebase"?await jK():(localStorage.removeItem(R0),h.current=null,r(null),t(null))},[s]);return{user:e,token:n,getToken:m,loading:i,mode:s,needsSetup:u,loginLocal:b,registerLocal:S,logout:_}}class $K{constructor(){fi(this,"ws",null);fi(this,"listeners",new Set);fi(this,"tokenProvider",async()=>null);fi(this,"intentionalClose",!1);fi(this,"reconnecting",!1);fi(this,"authRetries",0);fi(this,"pendingMessage",null);fi(this,"connectAttempts",0)}connect(t){this.tokenProvider=t,this.intentionalClose=!1;const r=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`;console.log("[ws] connecting…"),this.ws=new WebSocket(r),this.ws.onopen=async()=>{var a;this.connectAttempts=0;let i=null;try{i=await this.tokenProvider()}catch(s){console.warn("[ws] token fetch failed",s)}((a=this.ws)==null?void 0:a.readyState)===WebSocket.OPEN&&(console.log("[ws] open, sending auth"),this.ws.send(JSON.stringify({type:"auth",token:i})),this.reconnecting&&(this.reconnecting=!1,this.listeners.forEach(s=>s({type:"reconnected"}))))},this.ws.onmessage=i=>{var a;try{const s=JSON.parse(i.data);if(s.type!=="text_delta"&&console.log("[ws] ←",s.type),s.type==="auth_ok"&&(this.authRetries=0,this.flushPending()),s.type==="auth_error"){const c=((a=s.message)==null?void 0:a.toLowerCase())??"";c.includes("whitelist")||c.includes("audience mismatch")||c.includes("sign out and sign in")?this.intentionalClose=!0:(this.authRetries++,console.log(`[ws] auth failed (attempt ${this.authRetries}), will retry with fresh token`))}this.listeners.forEach(c=>c(s))}catch(s){console.warn("[ws] bad frame",s)}},this.ws.onclose=i=>{if(console.log(`[ws] closed code=${i.code} intentional=${this.intentionalClose}`),!this.intentionalClose){this.reconnecting=!0,this.connectAttempts++,this.listeners.forEach(u=>u({type:"disconnected"}));const a=this.authRetries>0?Math.min(2e3*this.authRetries,1e4):Math.min(1e3*2**this.connectAttempts,3e4),s=Math.random()*1e3,c=a+s;console.log(`[ws] reconnecting in ${(c/1e3).toFixed(1)}s (attempt ${this.connectAttempts})`),setTimeout(()=>this.connect(this.tokenProvider),c)}},this.ws.onerror=i=>console.warn("[ws] error",i)}flushPending(){if(this.pendingMessage){const t=this.pendingMessage;this.pendingMessage=null,console.log("[ws] flushing pending message after reconnect"),this.send(t)||(this.pendingMessage=t)}}disconnect(){var t;this.intentionalClose=!0,(t=this.ws)==null||t.close(),this.ws=null}send(t){var n,r;return((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN?(console.log("[ws] →",t.type),this.ws.send(JSON.stringify(t)),!0):(console.warn("[ws] send failed, readyState=",(r=this.ws)==null?void 0:r.readyState),!1)}sendOrQueue(t){return this.send(t)?!0:(this.pendingMessage=t,console.log("[ws] message queued for reconnect"),!1)}cancel(t){this.send({type:"cancel",sessionId:t})}steer(t,n){this.send({type:"steer",text:t,sessionId:n})}respondPermission(t,n,r){this.send({type:"permission_response",id:t,allow:n,allowAll:r})}respondQuestion(t,n){this.send({type:"question_response",id:t,answers:n})}sendPresence(t,n){this.send({type:"presence",sessionId:t??null,focused:n})}sendClientPresence(t,n){this.send({type:"client_presence",sessionId:t??null,visible:n})}markRead(t){this.send({type:"mark_read",sessionId:t})}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}}function BK(e,t,n){const[r,i]=y.useState(null),[a,s]=y.useState(null),[c,u]=y.useState(null),f=y.useRef(void 0),h=y.useRef(t);h.current=t;const p=y.useRef(n);return p.current=n,y.useEffect(()=>{if(!e)return;let m;const v=new $K;i(v),v.connect(()=>h.current());const x=v.on(b=>{var S,_;switch(b.type){case"auth_ok":b.buildId&&(f.current&&f.current!==b.buildId?s("update_available"):f.current=b.buildId);break;case"auth_error":(S=b.message)!=null&&S.toLowerCase().includes("whitelist")&&u(b.message);break;case"server_restarting":s("server_restarting");break;case"disconnected":s(O=>O==="server_restarting"?O:"disconnected");break;case"reconnected":s(O=>O==="update_available"?O:"reconnected"),m=setTimeout(()=>s(O=>O==="update_available"?O:null),2e3);break}(_=p.current)==null||_.call(p,b)});return()=>{x(),clearTimeout(m),v.disconnect(),i(null)}},[e]),{socket:r,connectionStatus:a,authError:c}}const UK={get capability(){return Za().push.capability},register:()=>Za().push.register(),requestPermission:()=>Za().push.requestPermission(),onTap:e=>Za().push.onTap(e),onMessage:e=>Za().push.onMessage(e)};function FK(){return Za().initNative()}function HK(){return typeof document>"u"?!0:!document.hidden}function KK(e){if(typeof document>"u")return()=>{};const t=()=>e(!document.hidden);return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)}function ij(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=ij(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function vt(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=ij(e))&&(r&&(r+=" "),r+=t);return r}const nE="-",qK=e=>{const t=VK(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:s=>{const c=s.split(nE);return c[0]===""&&c.length!==1&&c.shift(),aj(c,t)||GK(s)},getConflictingClassGroupIds:(s,c)=>{const u=n[s]||[];return c&&r[s]?[...u,...r[s]]:u}}},aj=(e,t)=>{var s;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?aj(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const a=e.join(nE);return(s=t.validators.find(({validator:c})=>c(a)))==null?void 0:s.classGroupId},NT=/^\[(.+)\]$/,GK=e=>{if(NT.test(e)){const t=NT.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},VK=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return YK(Object.entries(e.classGroups),n).forEach(([a,s])=>{cw(s,r,a,t)}),r},cw=(e,t,n,r)=>{e.forEach(i=>{if(typeof i=="string"){const a=i===""?t:MT(t,i);a.classGroupId=n;return}if(typeof i=="function"){if(WK(i)){cw(i(r),t,n,r);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([a,s])=>{cw(s,MT(t,a),n,r)})})},MT=(e,t)=>{let n=e;return t.split(nE).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},WK=e=>e.isThemeGetter,YK=(e,t)=>t?e.map(([n,r])=>{const i=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([s,c])=>[t+s,c])):a);return[n,i]}):e,XK=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(a,s)=>{n.set(a,s),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let s=n.get(a);if(s!==void 0)return s;if((s=r.get(a))!==void 0)return i(a,s),s},set(a,s){n.has(a)?n.set(a,s):i(a,s)}}},oj="!",ZK=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],a=t.length,s=c=>{const u=[];let f=0,h=0,p;for(let S=0;S<c.length;S++){let _=c[S];if(f===0){if(_===i&&(r||c.slice(S,S+a)===t)){u.push(c.slice(h,S)),h=S+a;continue}if(_==="/"){p=S;continue}}_==="["?f++:_==="]"&&f--}const m=u.length===0?c:c.substring(h),v=m.startsWith(oj),x=v?m.substring(1):m,b=p&&p>h?p-h:void 0;return{modifiers:u,hasImportantModifier:v,baseClassName:x,maybePostfixModifierPosition:b}};return n?c=>n({className:c,parseClassName:s}):s},QK=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},JK=e=>({cache:XK(e.cacheSize),parseClassName:ZK(e),...qK(e)}),eq=/\s+/,tq=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,a=[],s=e.trim().split(eq);let c="";for(let u=s.length-1;u>=0;u-=1){const f=s[u],{modifiers:h,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:v}=n(f);let x=!!v,b=r(x?m.substring(0,v):m);if(!b){if(!x){c=f+(c.length>0?" "+c:c);continue}if(b=r(m),!b){c=f+(c.length>0?" "+c:c);continue}x=!1}const S=QK(h).join(":"),_=p?S+oj:S,O=_+b;if(a.includes(O))continue;a.push(O);const k=i(b,x);for(let C=0;C<k.length;++C){const N=k[C];a.push(_+N)}c=f+(c.length>0?" "+c:c)}return c};function nq(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=sj(t))&&(r&&(r+=" "),r+=n);return r}const sj=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=sj(e[r]))&&(n&&(n+=" "),n+=t);return n};function rq(e,...t){let n,r,i,a=s;function s(u){const f=t.reduce((h,p)=>p(h),e());return n=JK(f),r=n.cache.get,i=n.cache.set,a=c,c(u)}function c(u){const f=r(u);if(f)return f;const h=tq(u,n);return i(u,h),h}return function(){return a(nq.apply(null,arguments))}}const Wt=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},lj=/^\[(?:([a-z-]+):)?(.+)\]$/i,iq=/^\d+\/\d+$/,aq=new Set(["px","full","screen"]),oq=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sq=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,lq=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,cq=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,uq=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Va=e=>lu(e)||aq.has(e)||iq.test(e),is=e=>Ru(e,"length",yq),lu=e=>!!e&&!Number.isNaN(Number(e)),P0=e=>Ru(e,"number",lu),Yf=e=>!!e&&Number.isInteger(Number(e)),fq=e=>e.endsWith("%")&&lu(e.slice(0,-1)),tt=e=>lj.test(e),as=e=>oq.test(e),dq=new Set(["length","size","percentage"]),hq=e=>Ru(e,dq,cj),pq=e=>Ru(e,"position",cj),mq=new Set(["image","url"]),gq=e=>Ru(e,mq,xq),vq=e=>Ru(e,"",bq),Xf=()=>!0,Ru=(e,t,n)=>{const r=lj.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},yq=e=>sq.test(e)&&!lq.test(e),cj=()=>!1,bq=e=>cq.test(e),xq=e=>uq.test(e),wq=()=>{const e=Wt("colors"),t=Wt("spacing"),n=Wt("blur"),r=Wt("brightness"),i=Wt("borderColor"),a=Wt("borderRadius"),s=Wt("borderSpacing"),c=Wt("borderWidth"),u=Wt("contrast"),f=Wt("grayscale"),h=Wt("hueRotate"),p=Wt("invert"),m=Wt("gap"),v=Wt("gradientColorStops"),x=Wt("gradientColorStopPositions"),b=Wt("inset"),S=Wt("margin"),_=Wt("opacity"),O=Wt("padding"),k=Wt("saturate"),C=Wt("scale"),N=Wt("sepia"),T=Wt("skew"),R=Wt("space"),L=Wt("translate"),D=()=>["auto","contain","none"],P=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto",tt,t],I=()=>[tt,t],U=()=>["",Va,is],V=()=>["auto",lu,tt],G=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],$=()=>["solid","dashed","dotted","double","none"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>["start","end","center","between","around","evenly","stretch"],Z=()=>["","0",tt],j=()=>["auto","avoid","all","avoid-page","page","left","right","column"],H=()=>[lu,tt];return{cacheSize:500,separator:":",theme:{colors:[Xf],spacing:[Va,is],blur:["none","",as,tt],brightness:H(),borderColor:[e],borderRadius:["none","","full",as,tt],borderSpacing:I(),borderWidth:U(),contrast:H(),grayscale:Z(),hueRotate:H(),invert:Z(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[fq,is],inset:B(),margin:B(),opacity:H(),padding:I(),saturate:H(),scale:H(),sepia:Z(),skew:H(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",tt]}],container:["container"],columns:[{columns:[as]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...G(),tt]}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[b]}],"inset-x":[{"inset-x":[b]}],"inset-y":[{"inset-y":[b]}],start:[{start:[b]}],end:[{end:[b]}],top:[{top:[b]}],right:[{right:[b]}],bottom:[{bottom:[b]}],left:[{left:[b]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Yf,tt]}],basis:[{basis:B()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",tt]}],grow:[{grow:Z()}],shrink:[{shrink:Z()}],order:[{order:["first","last","none",Yf,tt]}],"grid-cols":[{"grid-cols":[Xf]}],"col-start-end":[{col:["auto",{span:["full",Yf,tt]},tt]}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":[Xf]}],"row-start-end":[{row:["auto",{span:[Yf,tt]},tt]}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",tt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",tt]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...K()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...K(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...K(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[O]}],px:[{px:[O]}],py:[{py:[O]}],ps:[{ps:[O]}],pe:[{pe:[O]}],pt:[{pt:[O]}],pr:[{pr:[O]}],pb:[{pb:[O]}],pl:[{pl:[O]}],m:[{m:[S]}],mx:[{mx:[S]}],my:[{my:[S]}],ms:[{ms:[S]}],me:[{me:[S]}],mt:[{mt:[S]}],mr:[{mr:[S]}],mb:[{mb:[S]}],ml:[{ml:[S]}],"space-x":[{"space-x":[R]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[R]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",tt,t]}],"min-w":[{"min-w":[tt,t,"min","max","fit"]}],"max-w":[{"max-w":[tt,t,"none","full","min","max","fit","prose",{screen:[as]},as]}],h:[{h:[tt,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[tt,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[tt,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[tt,t,"auto","min","max","fit"]}],"font-size":[{text:["base",as,is]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",P0]}],"font-family":[{font:[Xf]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",tt]}],"line-clamp":[{"line-clamp":["none",lu,P0]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Va,tt]}],"list-image":[{"list-image":["none",tt]}],"list-style-type":[{list:["none","disc","decimal",tt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[_]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[_]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...$(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Va,is]}],"underline-offset":[{"underline-offset":["auto",Va,tt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",tt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",tt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[_]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...G(),pq]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",hq]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},gq]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[v]}],"gradient-via":[{via:[v]}],"gradient-to":[{to:[v]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[c]}],"border-w-x":[{"border-x":[c]}],"border-w-y":[{"border-y":[c]}],"border-w-s":[{"border-s":[c]}],"border-w-e":[{"border-e":[c]}],"border-w-t":[{"border-t":[c]}],"border-w-r":[{"border-r":[c]}],"border-w-b":[{"border-b":[c]}],"border-w-l":[{"border-l":[c]}],"border-opacity":[{"border-opacity":[_]}],"border-style":[{border:[...$(),"hidden"]}],"divide-x":[{"divide-x":[c]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[c]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[_]}],"divide-style":[{divide:$()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...$()]}],"outline-offset":[{"outline-offset":[Va,tt]}],"outline-w":[{outline:[Va,is]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[_]}],"ring-offset-w":[{"ring-offset":[Va,is]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",as,vq]}],"shadow-color":[{shadow:[Xf]}],opacity:[{opacity:[_]}],"mix-blend":[{"mix-blend":[...q(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":q()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",as,tt]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[p]}],saturate:[{saturate:[k]}],sepia:[{sepia:[N]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[p]}],"backdrop-opacity":[{"backdrop-opacity":[_]}],"backdrop-saturate":[{"backdrop-saturate":[k]}],"backdrop-sepia":[{"backdrop-sepia":[N]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",tt]}],duration:[{duration:H()}],ease:[{ease:["linear","in","out","in-out",tt]}],delay:[{delay:H()}],animate:[{animate:["none","spin","ping","pulse","bounce",tt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[C]}],"scale-x":[{"scale-x":[C]}],"scale-y":[{"scale-y":[C]}],rotate:[{rotate:[Yf,tt]}],"translate-x":[{"translate-x":[L]}],"translate-y":[{"translate-y":[L]}],"skew-x":[{"skew-x":[T]}],"skew-y":[{"skew-y":[T]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",tt]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",tt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",tt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Va,is,P0]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},Eq=rq(wq);function He(...e){return Eq(vt(e))}function ms(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Sq(e){const{socket:t,getToken:n,pushEnabled:r,activeSessionId:i,switchTo:a,openSession:s,onForegroundMessage:c}=e,[u,f]=y.useState(!1),h=y.useRef(a);h.current=a;const p=y.useRef(s);p.current=s;const m=y.useRef(c);m.current=c;const v=y.useRef(n);v.current=n,y.useEffect(()=>{FK().then(f)},[]);const x=y.useCallback(async()=>{try{const{platform:b,token:S,topic:_}=await UK.register(),O=await v.current(),k=await fetch("/api/push/register",{method:"POST",headers:{"Content-Type":"application/json",...O?{Authorization:`Bearer ${O}`}:{}},body:JSON.stringify({token:S,platform:b,topic:_})});if(!k.ok){console.warn("[push] register POST failed",k.status);return}console.log("[push] registered token with",window.location.origin)}catch(b){console.warn("[push] token registration failed",b)}},[]);return y.useEffect(()=>{},[u,r,x]),y.useEffect(()=>{if(!t)return;const b=()=>t.sendClientPresence(i,HK());return b(),KK(b)},[t,i]),{isNative:u}}function _q(){return Za().initDesktopAttention()}class Aq extends Error{constructor(t,n){super(`${t} ${n}`),this.status=t,this.name="ApiError"}}async function bl(e,t,n){const r=await t();if(!r)throw new Error("No auth token");const i=15e3,a=new AbortController,s=setTimeout(()=>a.abort(),i);try{const c=await fetch(e,{...n,signal:a.signal,headers:{Authorization:`Bearer ${r}`,...n==null?void 0:n.headers}});if(!c.ok)throw new Aq(c.status,c.statusText);return c}finally{clearTimeout(s)}}function uj(e){if(e.format==="conv")return e.messages.filter(n=>{var r;return((r=n.blocks)==null?void 0:r.length)>0});const t=[];for(const n of e.messages){const r=n.message;if(!(r!=null&&r.content))continue;const i=[];for(const a of r.content)if(a.type==="text"&&a.text)i.push({type:"text",text:a.text});else if(a.type==="tool_use")i.push({type:"tool_use",tool:a.name,toolUseId:a.id,input:a.input});else if(a.type==="tool_result"){const s=Array.isArray(a.content)?a.content.map(c=>c.text??"").join(""):String(a.content??"");i.push({type:"tool_result",toolUseId:String(a.tool_use_id),output:s})}i.length>0&&t.push({id:n.uuid||ms(),role:n.type==="user"?"user":"assistant",blocks:i})}return t}const fj=y.createContext(null),kq=fj.Provider;function rE(){const e=y.useContext(fj);if(!e)throw new Error("useWorkspace must be used within a WorkspaceProvider");return e}const dj=y.createContext({}),Oq=dj.Provider;function Sa(){return y.useContext(dj)}/**
|
|
1459
1459
|
* @license lucide-react v0.468.0 - ISC
|
|
1460
1460
|
*
|
|
1461
1461
|
* This source code is licensed under the ISC license.
|
package/dist/client/index.html
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
14
14
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
15
15
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet" />
|
|
16
|
-
<script type="module" crossorigin src="/assets/index-
|
|
16
|
+
<script type="module" crossorigin src="/assets/index-BCX3Z2qh.js"></script>
|
|
17
17
|
<link rel="stylesheet" crossorigin href="/assets/index-uvYJNXVj.css">
|
|
18
18
|
</head>
|
|
19
19
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shraga",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.74",
|
|
4
4
|
"description": "The teammate you delegate coding to — a self-hostable, multi-user AI coding agent web UI (Claude Code, with a pluggable engine seam).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
package/src/cli.ts
CHANGED
|
@@ -29,6 +29,9 @@ Subcommands:
|
|
|
29
29
|
ingress Run the host-header TCP router (INGRESS_PORT, default 3100)
|
|
30
30
|
for previews + blue-green flips. Own process, survives restarts.
|
|
31
31
|
user add <email> <pw> Seed a local username/password user
|
|
32
|
+
para post [text] Push a message into a linked para.li conversation.
|
|
33
|
+
Text from [text], --file <path>, or stdin (preferred for
|
|
34
|
+
multi-line reports). --conn <id> picks a link when several exist.
|
|
32
35
|
|
|
33
36
|
Environment:
|
|
34
37
|
CLOUDFLARE_TUNNEL_TOKEN If set, starts a Cloudflare Tunnel alongside the server.
|
|
@@ -59,6 +62,60 @@ if (args[0] === 'user' && args[1] === 'add') {
|
|
|
59
62
|
process.exit(0);
|
|
60
63
|
}
|
|
61
64
|
|
|
65
|
+
// `shraga para post [text]` — the PROACTIVE half of the para.li agent lane.
|
|
66
|
+
//
|
|
67
|
+
// The reactive half (para asks, shraga answers) is driven by para.li calling `/api/para/turn`, and
|
|
68
|
+
// the only other outbound path is the deploy-notice bus subscriber in `para/feature.ts` — which is
|
|
69
|
+
// gated on `kind === 'deploy'`. So a SCHEDULED run (a daily digest) had no way to reach the lane at
|
|
70
|
+
// all: it composes text on its own clock with no inbound turn to answer and no deploy event to ride.
|
|
71
|
+
// This is that door, and it is a CLI rather than a route because the caller is the agent itself,
|
|
72
|
+
// running Bash on this very box: a local process reading the same `para-links.json` the feature
|
|
73
|
+
// writes needs no listener, no API key, and no second copy of the callback secret.
|
|
74
|
+
//
|
|
75
|
+
// Text comes from stdin by default. A digest is multi-line markdown with backticks and emoji, and
|
|
76
|
+
// making a model shell-quote that into argv is a defect generator; `... | shraga para post` is not.
|
|
77
|
+
if (args[0] === 'para' && args[1] === 'post') {
|
|
78
|
+
const { loadLinks } = await import('./server/para/feature.ts');
|
|
79
|
+
const { postProactive } = await import('./server/para/streamer.ts');
|
|
80
|
+
|
|
81
|
+
const links = loadLinks();
|
|
82
|
+
const wanted = flag('conn');
|
|
83
|
+
const ids = Object.keys(links);
|
|
84
|
+
// Refuse to guess. Picking "the first" would silently deliver a private report to whichever
|
|
85
|
+
// connection happened to sort first the day a second one is added.
|
|
86
|
+
const connId = wanted ?? (ids.length === 1 ? ids[0] : undefined);
|
|
87
|
+
if (!connId || !links[connId]) {
|
|
88
|
+
console.error(ids.length
|
|
89
|
+
? `usage: shraga para post --conn <connId> (linked: ${ids.join(', ')})`
|
|
90
|
+
: 'no para link yet — send one message from para.li to this agent first, then retry.');
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
const link = links[connId];
|
|
94
|
+
|
|
95
|
+
const file = flag('file');
|
|
96
|
+
let text: string;
|
|
97
|
+
if (file) {
|
|
98
|
+
text = (await import('node:fs')).readFileSync(file, 'utf-8');
|
|
99
|
+
} else {
|
|
100
|
+
// A bare positional (not a flag, and not a flag's VALUE) is accepted for one-liners.
|
|
101
|
+
const flagVals = new Set<string>();
|
|
102
|
+
for (let i = 0; i < args.length; i++) if (args[i].startsWith('--')) flagVals.add(args[i + 1]);
|
|
103
|
+
const positional = args.slice(2).find((a) => !a.startsWith('--') && !flagVals.has(a));
|
|
104
|
+
text = positional ?? await new Response(Bun.stdin.stream()).text();
|
|
105
|
+
}
|
|
106
|
+
if (!text.trim()) {
|
|
107
|
+
console.error('nothing to post: text was empty (pipe it on stdin, pass --file, or give it as an argument)');
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const ok = await postProactive({ url: link.url, secret: link.secret, connId }, link.convId, text);
|
|
112
|
+
// Exit code is the point: `postProactive` swallows transport failures into `false`, so a caller
|
|
113
|
+
// that only looked at stdout would read a silent drop as a successful delivery.
|
|
114
|
+
if (!ok) { console.error(`\u2716 para post FAILED \u2192 ${link.convId}`); process.exit(1); }
|
|
115
|
+
console.log(`\u2705 posted to ${link.convId}`);
|
|
116
|
+
process.exit(0);
|
|
117
|
+
}
|
|
118
|
+
|
|
62
119
|
// `shraga ingress` — host-header TCP router for previews + blue-green flips.
|
|
63
120
|
// Runs as its OWN process (INGRESS_PORT), deliberately separate from the server so it
|
|
64
121
|
// survives server restarts during a flip. Reads dataPath('ingress-router.json').
|
|
@@ -20,7 +20,11 @@ export async function signInWithGoogle() {
|
|
|
20
20
|
await signInWithGoogleNative(auth);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
const provider = new GoogleAuthProvider();
|
|
24
|
+
// Force the account chooser — without it Google silently re-uses the single signed-in
|
|
25
|
+
// account, so signing out and back in can never land on a different user.
|
|
26
|
+
provider.setCustomParameters({ prompt: 'select_account' });
|
|
27
|
+
await signInWithPopup(auth, provider);
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export async function signOutUser() {
|
|
@@ -50,9 +50,9 @@ const LINKS_PATH = dataPath('para-links.json');
|
|
|
50
50
|
* taken from `validateApiKey`, never from the request body. A link written before this field
|
|
51
51
|
* existed has no email and is therefore not an owner: it receives no notices until its next turn
|
|
52
52
|
* refreshes the entry. */
|
|
53
|
-
type Link = ParaCallback & { convId: string; at: number; uid: string; email?: string };
|
|
53
|
+
export type Link = ParaCallback & { convId: string; at: number; uid: string; email?: string };
|
|
54
54
|
|
|
55
|
-
function loadLinks(): Record<string, Link> {
|
|
55
|
+
export function loadLinks(): Record<string, Link> {
|
|
56
56
|
if (!existsSync(LINKS_PATH)) return {};
|
|
57
57
|
try { return JSON.parse(readFileSync(LINKS_PATH, 'utf-8')); } catch (err) {
|
|
58
58
|
console.warn('[para] links file unreadable, starting empty:', (err as Error).message);
|