@swarm.ing/pieui 2.0.21 → 2.0.23
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.
- package/dist/cli.js +20448 -15722
- package/dist/code/args.d.ts +3 -1
- package/dist/code/args.d.ts.map +1 -1
- package/dist/code/commands/add.d.ts.map +1 -1
- package/dist/code/commands/addEvent.d.ts.map +1 -1
- package/dist/code/commands/cardPull.d.ts +2 -0
- package/dist/code/commands/cardPull.d.ts.map +1 -0
- package/dist/code/commands/cardView.d.ts +2 -0
- package/dist/code/commands/cardView.d.ts.map +1 -0
- package/dist/code/commands/create.d.ts +1 -1
- package/dist/code/commands/create.d.ts.map +1 -1
- package/dist/code/commands/init.d.ts +1 -1
- package/dist/code/commands/init.d.ts.map +1 -1
- package/dist/code/commands/list.d.ts.map +1 -1
- package/dist/code/commands/pageAdd.d.ts.map +1 -1
- package/dist/code/commands/pageAjax.d.ts +3 -0
- package/dist/code/commands/pageAjax.d.ts.map +1 -0
- package/dist/code/commands/pageView.d.ts +2 -0
- package/dist/code/commands/pageView.d.ts.map +1 -0
- package/dist/code/scan.d.ts.map +1 -1
- package/dist/code/types.d.ts +7 -3
- package/dist/code/types.d.ts.map +1 -1
- package/dist/components/Containers/OneOfCard/index.d.ts +3 -0
- package/dist/components/Containers/OneOfCard/index.d.ts.map +1 -0
- package/dist/components/Containers/OneOfCard/types/index.d.ts +9 -0
- package/dist/components/Containers/OneOfCard/types/index.d.ts.map +1 -0
- package/dist/components/Containers/OneOfCard/ui/OneOfCard.d.ts +4 -0
- package/dist/components/Containers/OneOfCard/ui/OneOfCard.d.ts.map +1 -0
- package/dist/components/PieCard/index.d.ts +1 -1
- package/dist/components/PieCard/index.d.ts.map +1 -1
- package/dist/components/PieCard/types/index.d.ts +6 -0
- package/dist/components/PieCard/types/index.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/pieui.components.json +21 -0
- package/dist/util/ajaxCommonUtils.d.ts +18 -0
- package/dist/util/ajaxCommonUtils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{useContext as Jf,useEffect as Yf,useRef as MU}from"react";import{createContext as BU,useContext as WU}from"react";var j=BU(null),h=()=>{let f=WU(j);if(!f)throw new Error("usePieConfig must be used within PieConfigProvider");return f},x=()=>{let{apiServer:f}=h();return f},e=x,u=()=>{let{centrifugeServer:f}=h();return f};var N=()=>{let{enableRenderingLog:f}=h();return f},Lf=N,Mf=()=>{let{pageProcessor:f}=h();return f};var Pf="__piedemo__";import{createContext as QU}from"react";import{Centrifuge as Af}from"centrifuge";var Nf=new Map,d=(f,U)=>{if(!U)return null;let z=`${f}::${U}`,Z=Nf.get(z);if(Z)return Z;async function H(){let D=await fetch(f+"api/centrifuge/gen_token");if(!D.ok){if(D.status===403)throw new Af.UnauthorizedError("Backend is not answering");throw new Error(`Unexpected status code ${D.status}`)}return(await D.json()).token}let T=new Af(U,{getToken:H});return Nf.set(z,T),T},OU=QU(null),y=OU;import{io as _U}from"socket.io-client";import{createContext as CU}from"react";var yf=new Map,b=(f)=>{let U=yf.get(f);if(U)return U;let z=_U(f,{autoConnect:!1,transports:["websocket"]});return yf.set(f,z),z},RU=CU(null),E=RU;import wU from"mitt";import{createContext as KU,useCallback as FU,useContext as SU}from"react";var Vf=null;function o(){if(!Vf)Vf=wU();return Vf}var Ef=KU(null);function LU(f){let U=SU(Ef);return FU((z,Z)=>{(U??o()).emit(`pie${z}_${f}`,Z)},[f,U])}var F=Ef;var AU=({card:f,data:U,children:z,useSocketioSupport:Z=!1,useCentrifugeSupport:H=!1,useMittSupport:T=!1,centrifugeChannel:D=void 0,methods:V=void 0})=>{let $=Lf(),P=MU(V);if(P.current=V,$)console.log("[PieCard] Rendering card:",f),console.log("[PieCard] Card data:",U),console.log("[PieCard] Component name:",U?.name),console.log("[PieCard] Real-time support:",{socketio:Z,centrifuge:H,mitt:T,centrifugeChannel:D}),console.log("[PieCard] Methods:",V?Object.keys(V):"none"),console.log("[PieCard] Has children:",!!z);let G=Jf(E),B=Jf(y),W=Jf(F);if(Yf(()=>{if(!G||!Z||!P.current||!U.name){if($&&Z)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!G,useSocketioSupport:Z,hasMethods:!!P.current,hasDataName:!!U?.name});return}let Y=Object.keys(P.current??{}).map((I)=>{let J=`pie${I}_${U.name}`;if($)console.log(`[PieCard] Socket.IO registering event: ${J}`);let Q=(q)=>{P.current?.[I]?.(q)};return G.on(J,Q),[J,Q]});return()=>{Y.forEach(([I,J])=>{if($)console.log(`[PieCard] Socket.IO unregistering event: ${I}`);G.off(I,J)})}},[G,U.name,Z]),Yf(()=>{if(!B||!H||!D||!U.name){if($&&H)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!B,useCentrifugeSupport:H,hasCentrifugeChannel:!!D,hasMethods:!!P.current,hasDataName:!!U?.name});return}let Y=Object.keys(P.current??{}).map((I)=>{let J=`pie${I}_${U.name}_${D}`;if($)console.log(`[PieCard] Centrifuge subscribing to channel: ${J}`);let Q=B.newSubscription(J);return Q.on("publication",(q)=>{if($)console.log(`[PieCard] Centrifuge received data on ${J}:`,q.data);P.current?.[I]?.(q.data)}),Q.subscribe(),Q});return()=>{Y.forEach((I)=>{if($)console.log("[PieCard] Centrifuge unsubscribing from channel");I.unsubscribe(),B.removeSubscription(I)})}},[B,D,U.name,H]),Yf(()=>{if(!W||!T||!U.name){if($&&T)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!W,useMittSupport:T,hasMethods:!!P.current,hasDataName:!!U?.name});return}let X=Object.keys(P.current??{}),Y={};return X.forEach((I)=>{let J=`pie${I}_${U.name}`,Q=(q)=>{if($)console.log(`[PieCard] Mitt registering event: ${J}`);P.current?.[I]?.(q)};Y[J]=Q,W.on(J,Q)}),()=>{Object.entries(Y).forEach(([I,J])=>{if($)console.log(`[PieCard] Mitt unregistering event: ${I}`);W.off(I,J)})}},[W,U.name,T]),$)console.log("[PieCard] Rendering complete, returning children");return z},R=AU;import{lazy as NU}from"react";var Xf=new Map;function of(f,U){return NU(()=>{if(Xf.has(U))return Xf.get(U);let z=f().then((Z)=>Z);return Xf.set(U,z),z})}var g=new Map,yU=(f)=>{if(!f.name)throw new Error("Component registration requires a name");if(!f.component&&!f.loader)throw new Error(`Component "${f.name}" requires component or loader`);let U={name:f.name,component:f.component,loader:f.loader,metadata:f.metadata,fallback:f.fallback,isLazy:!1};if(!U.component&&U.loader)U.component=of(U.loader,f.name),U.loader=void 0,U.isLazy=!0;return U};function C(f){let U=yU(f);return g.set(U.name,U),U.component}var EU=(f)=>{f.forEach((U)=>C(U))},oU=(f)=>{g.delete(f)},mU=(f)=>{return g.has(f)},kU=(f)=>{return g.get(f)?.metadata},r=(f)=>{return g.get(f)},jU=()=>{return Array.from(g.keys())},xU=()=>{return g.size};import{Suspense as vU,useContext as pU,memo as cU}from"react";import{createContext as uU}from"react";import{jsx as gU,Fragment as bU}from"react/jsx-runtime";var dU=uU(gU(bU,{})),K=dU;import{jsx as If}from"react/jsx-runtime";function hU({uiConfig:f,setUiAjaxConfiguration:U}){let z=pU(K),Z=N();if(Z)console.log("[UI] Rendering component:",f.card),console.log("[UI] Component data:",f.data),console.log("[UI] Component content:",f.content),console.log("[UI] Has setUiAjaxConfiguration:",!!U);let H=r(f.card);if(!H?.component){if(Z)console.warn(`[UI] Component not found in registry: ${f.card}`),console.log("[UI] Returning fallback component");return z}if(Z)console.log("[UI] Found component in registry:",{name:H.name,isLazy:H.isLazy,hasMetadata:!!H.metadata});let T=H.component,D=If(T,{data:f.data,content:f.content,setUiAjaxConfiguration:U});if(H.isLazy){if(Z)console.log("[UI] Rendering lazy component with Suspense:",H.name);return If(vU,{fallback:H.fallback?If(H.fallback,{}):z,children:D},`${H.name}`)}if(Z)console.log("[UI] Rendering component directly:",H.name);return D}var w=cU(hU);import{Suspense as nU,useContext as sU}from"react";import{createContext as lU}from"react";var rU=lU(null),k=rU;import{jsx as ff}from"react/jsx-runtime";function mf({uiConfig:f,setUiAjaxConfiguration:U}){let z=sU(K),Z=N();if(Z)console.log("[UILoading] Rendering fallback for:",f.card),console.log("[UILoading] Component data:",f.data),console.log("[UILoading] Component content:",f.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!U);let H=r(f.card);if(!H?.component){if(Z)console.warn(`[UILoading] Component not found in registry: ${f.card}`),console.log("[UILoading] Returning fallback component");return z}if(Z)console.log("[UILoading] Found component in registry:",{name:H.name,isLazy:H.isLazy,hasMetadata:!!H.metadata,hasFallback:!!H.fallback});if(H.fallback){if(Z)console.log("[UILoading] Rendering fallback for:",H.name);let V=H.fallback;return ff(V,{})}if(Z)console.log("[UILoading] No fallback, rendering full component:",H.name);let T=H.component,D=ff(k.Provider,{value:mf,children:ff(T,{data:f.data,content:f.content,setUiAjaxConfiguration:U})});if(H.isLazy)return ff(nU,{fallback:z,children:D},`${H.name}`);return D}var Gf=mf;import{useContext as iU}from"react";import{jsx as qf}from"react/jsx-runtime";var tU=({data:f,content:U,setUiAjaxConfiguration:z})=>{let{name:Z,sx:H}=f,T=iU(k)??w;return qf(R,{card:Z,data:f,children:qf("div",{style:H,id:Z,children:U.map((D,V)=>{return qf(T,{uiConfig:D,setUiAjaxConfiguration:z},`children-${V}`)})})})},kf=tU;var aU=C({name:"SequenceCard",component:kf,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});import{useContext as eU}from"react";import{jsx as jf}from"react/jsx-runtime";var fH=({data:f,content:U,setUiAjaxConfiguration:z})=>{let{name:Z}=f,H=eU(k)??w;return jf(R,{card:Z,data:f,children:U.map((T,D)=>{return jf(H,{uiConfig:T,setUiAjaxConfiguration:z},`children-${D}`)})})},xf=fH;var UH=C({name:"UnionCard",component:xf,metadata:{author:"Swarm.ing",description:"Renders one of many components"}});import{useEffect as DH,useState as $H}from"react";import TH from"html-react-parser";import{useCallback as Uf,useEffect as HH,useRef as Bf,useState as ZH}from"react";function zH(){let f=new AudioContext,U=f.createOscillator(),z=U.connect(f.createMediaStreamDestination());U.start();let Z=z.stream.getAudioTracks()[0];return Z.enabled=!1,Z}function Hf(f=null,U){let[z,Z]=ZH(!1),H=Bf(null),T=Bf(null),D=Bf(null),V=Uf(async(B,W=!0)=>{if(H.current)$();let X=new RTCPeerConnection;if(X.onconnectionstatechange=()=>{if(X.connectionState==="connected")Z(!0);else if(["disconnected","failed","closed"].includes(X.connectionState))Z(!1)},X.ontrack=(_)=>{if(f)f.srcObject=_.streams[0]},W){let _=await navigator.mediaDevices.getUserMedia({audio:!0});X.addTrack(_.getTracks()[0],_)}else{let _=zH();X.addTrack(_)}let Y=X.createDataChannel("oai-events");T.current=Y,D.current=new Promise((_)=>{Y.addEventListener("open",()=>{_()})});let I=await X.createOffer();await X.setLocalDescription(I);let O=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:I.sdp,headers:{Authorization:`Bearer ${B}`,"Content-Type":"application/sdp"}})).text();await X.setRemoteDescription({type:"answer",sdp:O}),H.current=X,await D.current},[f]),$=Uf(()=>{let B=T.current;if(B)B.close();H.current?.getSenders()?.forEach((W)=>W.track?.stop()),H.current?.close(),Z(!1),H.current=null,T.current=null,D.current=null},[f]),P=Uf((B)=>{let W=T.current;if(!W){console.error("Data channel is not ready",B);return}let X=new Date().toLocaleTimeString();if(B.event_id=B.event_id||crypto.randomUUID(),W.send(JSON.stringify(B)),!B.timestamp)B.timestamp=X;U?.(B)},[U,f]),G=Uf((B)=>{if(!T.current){console.error("Data channel is not ready");return}let X=()=>{P({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:B}]}}),P({type:"response.create"})};if(D.current)D.current.then(X);else X()},[U,f]);return HH(()=>{let B=T.current;if(!B)return;let W=(X)=>{let Y=JSON.parse(X.data);if(!Y.timestamp)Y.timestamp=new Date().toLocaleTimeString();U?.(Y)};return B.addEventListener("message",W),()=>{B.removeEventListener("message",W)}},[U,f]),{isSessionActive:z,startSession:V,stopSession:$,sendTextMessage:G}}import{jsx as VH}from"react/jsx-runtime";var PH=({data:f})=>{let{html:U,useSocketioSupport:z,useCentrifugeSupport:Z,useMittSupport:H,centrifugeChannel:T}=f,[D,V]=$H(U),{isSessionActive:$,startSession:P,sendTextMessage:G}=Hf(null,(Y)=>{if(console.log(Y.type,Y.type==="response.output_text.delta"&&Y.delta),Y.type==="response.output_text.delta"&&Y.delta)V((I)=>I+Y.delta)});return DH(()=>{V(U)},[U]),VH(R,{card:"HTMLEmbedCard",data:f,methods:{update:(Y)=>{V(Y.value)},generateUsingAI:async(Y)=>{try{if(!$&&Y.token)await P(Y.token,!1);G(Y.prompt)}catch(I){console.error("Failed to generate using AI",I)}},initializeAI:async(Y)=>{if(!$&&Y.token)await P(Y.token,!1)}},useCentrifugeSupport:Z,useSocketioSupport:z,useMittSupport:H,centrifugeChannel:T,children:TH(D)})},uf=PH;var JH=C({name:"HTMLEmbedCard",component:uf,metadata:{author:"Swarm.ing"}});import{useEffect as YH,useState as XH}from"react";import{jsx as df}from"react/jsx-runtime";var IH=({data:f})=>{let{name:U,value:z,useSocketioSupport:Z,useCentrifugeSupport:H,useMittSupport:T,centrifugeChannel:D}=f,[V,$]=XH(z);return YH(()=>{$(z)},[z]),df(R,{card:"HiddenCard",data:f,useSocketioSupport:Z,useCentrifugeSupport:H,useMittSupport:T,centrifugeChannel:D,methods:{update:({value:P})=>{$(P)}},children:df("input",{type:"hidden",id:U,name:U,value:V})})},bf=IH;var GH=C({name:"HiddenCard",component:bf,metadata:{author:"Swarm.ing"}});import{useContext as gf,useEffect as WH}from"react";import{createContext as qH}from"react";var BH=qH(void 0),S=BH;import{jsx as _H,Fragment as OH}from"react/jsx-runtime";var QH=({data:f})=>{let{url:U}=f,z=gf(S),Z=gf(K);return WH(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(U))window.location.href=U;else z?.(U)},[U,z]),_H(OH,{children:Z})},vf=QH;var CH=C({name:"AutoRedirectCard",component:vf,metadata:{author:"Swarm.ing"}});import{Bounce as RH,Slide as wH,Zoom as KH,Flip as FH}from"react-toastify";import{toast as SH,ToastContainer as LH}from"react-toastify";import{useContext as MH,useMemo as AH,useRef as NH}from"react";import{jsx as Wf,Fragment as jH}from"react/jsx-runtime";var yH={bounce:RH,slide:wH,zoom:KH,flip:FH},EH=(f)=>{let U={...f,type:f.alertType,transition:f.transition?yH[f.transition]:void 0,position:f.position??"bottom-right",autoClose:f.autoClose??3000,style:{backgroundColor:"black",...f.sx}};SH(f.message,U)},oH=(f)=>{console.log("Log event",f)},mH=(f)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let U=()=>{try{new window.Notification(f.title,{body:f.message??f.subtitle,icon:f.icon,silent:f.silent})}catch(Z){console.error("[IOEventsCard] Failed to show notification",Z)}},z=window.Notification.permission;if(z==="granted"){U();return}if(z==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((Z)=>{if(Z==="granted")U()})},kH=({data:f})=>{let{useCentrifugeSupport:U,useSocketioSupport:z,useMittSupport:Z,centrifugeChannel:H}=f,T=MH(S),D=NH(T);D.current=T;let V=AH(()=>({alert:EH,log:oH,push:mH,redirect:($)=>{if($.to){let P=$.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(P))window.location.href=P;else D.current?.(P)}else window.location.reload()},reload:($)=>{if($.to){let P=$.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(P))window.location.href=P;else D.current?.(P)}else window.location.reload()}}),[]);return Wf(jH,{children:Wf(R,{card:"IOEventsCard",data:f,useCentrifugeSupport:U,useSocketioSupport:z,useMittSupport:Z,centrifugeChannel:H,methods:V,children:Wf(LH,{})})})},pf=kH;var xH=C({name:"IOEventsCard",component:pf,metadata:{author:"Swarm.ing"}});import{useEffect as cf,useState as uH}from"react";import{jsx as hf}from"react/jsx-runtime";var dH=({data:f})=>{let{name:U,key:z,value:Z,useSocketioSupport:H,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V}=f,[$,P]=uH(Z);return cf(()=>{P(Z)},[Z]),cf(()=>{if(typeof window==="undefined")return;sessionStorage.setItem(z,$)},[z,$]),hf(R,{card:"SessionStorageCard",data:f,useSocketioSupport:H,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V,methods:{update:({value:G})=>{P(G)},remove:()=>{sessionStorage.removeItem(z),P("")}},children:hf("input",{type:"hidden",id:U,name:U,value:$})})},lf=dH;var bH=C({name:"SessionStorageCard",component:lf,metadata:{author:"PieData"}});import{useEffect as rf,useState as gH}from"react";import{jsx as nf}from"react/jsx-runtime";var vH=({data:f})=>{let{name:U,key:z,value:Z,useSocketioSupport:H,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V}=f,[$,P]=gH(Z);return rf(()=>{P(Z)},[Z]),rf(()=>{if(typeof window==="undefined")return;localStorage.setItem(z,$)},[z,$]),nf(R,{card:"DeviceStorageCard",data:f,useSocketioSupport:H,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V,methods:{update:({value:G})=>{P(G)},remove:()=>{localStorage.removeItem(z),P("")}},children:nf("input",{type:"hidden",id:U,name:U,value:$})})},sf=vH;var pH=C({name:"DeviceStorageCard",component:sf,metadata:{author:"PieData"}});import{useEffect as tf,useState as cH}from"react";import{jsx as af}from"react/jsx-runtime";var hH=({data:f})=>{let{name:U,key:z,value:Z,useSocketioSupport:H,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V}=f,[$,P]=cH(Z);return tf(()=>{P(Z)},[Z]),tf(()=>{if(typeof window==="undefined")return;let G=window.Telegram?.WebApp?.CloudStorage;if(!G)return;G.setItem(z,$)},[z,$]),af(R,{card:"CloudStorageCard",data:f,useSocketioSupport:H,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V,methods:{update:({value:G})=>{P(G)},remove:()=>{let G=window.Telegram?.WebApp?.CloudStorage;if(G)G.removeItem(z);P("")}},children:af("input",{type:"hidden",id:U,name:U,value:$})})},ef=hH;var lH=C({name:"CloudStorageCard",component:ef,metadata:{author:"PieData"}});import{useEffect as fU,useState as rH}from"react";import{jsx as UU}from"react/jsx-runtime";var nH=({data:f})=>{let{name:U,key:z,value:Z,useSocketioSupport:H,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V}=f,[$,P]=rH(Z);return fU(()=>{P(Z)},[Z]),fU(()=>{if(typeof window==="undefined")return;let G=window.Telegram?.WebApp?.SecureStorage;if(!G)return;G.setItem(z,$)},[z,$]),UU(R,{card:"SecureStorageCard",data:f,useSocketioSupport:H,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V,methods:{update:({value:G})=>{P(G)},remove:()=>{let G=window.Telegram?.WebApp?.SecureStorage;if(G)G.removeItem(z);P("")}},children:UU("input",{type:"hidden",id:U,name:U,value:$})})},HU=nH;var sH=C({name:"SecureStorageCard",component:HU,metadata:{author:"PieData"}});import{useCallback as Qf,useContext as Of,useEffect as iH,useRef as tH,useState as ZU}from"react";import{jsx as zU}from"react/jsx-runtime";var aH=({data:f,content:U})=>{let{useLoader:z,noReturn:Z,returnType:H,useSocketioSupport:T,useCentrifugeSupport:D,useMittSupport:V,centrifugeChannel:$}=f,P=Of(K),G=Of(k)??w,[B,W]=ZU(!1),[X,Y]=ZU(null),I=tH(U),J=Of(F),Q=Qf((_)=>{if(_===null)W(!0);else if(W(!1),!Z)I.current=_;if(!Z)Y(_)},[Z]),q=Qf((_)=>{I.current=_.content,Y(_.content)},[]),O=Qf((_)=>{if(_===null)W(!0);else if(W(!1),!Z)for(let t of _)J?.emit(t.name,t.data)},[Z,J]);if(iH(()=>{Y(U),W(!1)},[U]),!X&&z)return P;return zU(R,{card:"AjaxGroupCard",data:f,methods:{changeContent:q},useSocketioSupport:T,useCentrifugeSupport:D,useMittSupport:V,centrifugeChannel:$,children:zU(G,{uiConfig:X??I.current,setUiAjaxConfiguration:H==="events"?O:Q})})},DU=aH;var eH=C({name:"AjaxGroupCard",component:DU,metadata:{author:"Swarm.ing",description:"Group card with AJAX support"}});import{useContext as $U}from"react";import{jsx as _f}from"react/jsx-runtime";var fZ=({data:f,content:U,setUiAjaxConfiguration:z})=>{let{name:Z,url:H,sx:T}=f,D=$U(S),V=$U(k)??w;return _f(R,{card:Z,data:f,children:_f("div",{style:T,id:Z,onClick:(P)=>{if(H)if(P.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(H))window.location.href=H;else D?.(H)},children:_f(V,{setUiAjaxConfiguration:z,uiConfig:U})})})},TU=fZ;var UZ=C({name:"BoxCard",component:TU,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});import{useMemo as n}from"react";import{QueryClient as YZ,QueryClientProvider as XZ,useQuery as IZ}from"@tanstack/react-query";import{useContext as zZ,useEffect as DZ}from"react";import{useEffect as HZ,useState as ZZ}from"react";var Zf=new Map,zf=new Map;function Df(f,U){let z=`${f}::${U}`,Z=f?Zf.get(z):void 0,[H,T]=ZZ(Z??null);return HZ(()=>{if(!f)return;if(Zf.has(z)){T(Zf.get(z));return}let D=zf.get(z);if(!D)D=fetch(f+`api/support/${U}`,{method:"GET"}).then(($)=>$.json()).then(($)=>{return Zf.set(z,$),zf.delete(z),$}).catch(($)=>{throw zf.delete(z),$}),zf.set(z,D);let V=!1;return D.then(($)=>{if(!V)T($)}).catch(()=>{}),()=>{V=!0}},[f,U,z]),H}var Cf=null,PU=null;function VU(){PU?.()}function Rf(){if(typeof window==="undefined")return Promise.resolve();if(typeof window.sid!=="undefined")return Promise.resolve();if(!Cf)Cf=new Promise((f)=>{PU=()=>{f()}});return Cf}var $Z=({children:f})=>{let U=zZ(E),z=e(),Z=Df(z,"socketIO"),H=(T)=>{if(typeof window!=="undefined")window.sid=T.sid,VU(),console.log(`SocketIO initialized: ${window.sid}`)};return DZ(()=>{if(!U)return;let T=()=>{console.log("SocketIO connected")},D=(V)=>{console.log(`SocketIO disconnected: ${V}`),U.connect()};if(Z)U.on("pieinit",H),U.on("connect",T),U.on("disconnect",D),U.connect();return()=>{if(Z)U.off("pieinit",H),U.off("connect",T),U.off("disconnect",D),U.disconnect()}},[U,Z]),f},v=$Z;import{useContext as TZ,useEffect as PZ}from"react";var VZ=({children:f})=>{let U=TZ(y),z=e(),Z=Df(z,"centrifuge");return PZ(()=>{if(!U)return;let H=()=>{console.log("Centrifuge connected")},T=(D)=>{console.log("Centrifuge disconnected:",D)};if(Z)U.on("connected",H),U.on("disconnected",T),U.connect();return()=>{if(Z)U.disconnect()}},[U,Z]),f},p=VZ;import{createAxiosDateTransformer as GZ}from"axios-date-transformer";import{jsx as JZ}from"react/jsx-runtime";function l(f,U,z){if(!U)return z;let Z=f.replace(/^\//,""),H=U[Z];if(!H)return z;return JZ(Gf,{uiConfig:H})}import{jsx as L,Fragment as WZ}from"react/jsx-runtime";var qZ=({location:f,fallback:U,piecache:z,onError:Z,queryOptions:H,disableGlobalForm:T})=>{let D=x(),V=u(),$=N(),P=n(()=>GZ({baseURL:D||""}),[D]),G=n(()=>o(),[]),B=n(()=>D?b(D):null,[D]),W=n(()=>D?d(D,V):null,[D,V]),{data:X,isLoading:Y,error:I}=IZ({queryKey:["uiConfig",f.pathname+f.search,D],enabled:!!D,queryFn:async()=>{let Q=new URLSearchParams(f.search);Q.set("__pieroot","web");let q="/api/content"+f.pathname+"?"+Q.toString();if($)console.log("[PieRoot] Fetching UI configuration from:",q);let O=await P.get(q,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if($)console.log("[PieRoot] Received UI configuration:",O.data);return O.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Q)=>Math.min(1000*2**Q,30000),...H}),J=l(f.pathname,z,U);if(!D)return J??null;if($)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",D),console.log("[PieRoot] CENTRIFUGE_SERVER:",V),console.log("[PieRoot] Fallback provided:",!!U),console.log("[PieRoot] Piecache provided:",!!z);if(I){if($)console.error("[PieRoot] Error fetching UI configuration:",I),console.error("[PieRoot] Error details:",{message:I.message,status:I.response?.status,data:I.response?.data});return Z?.(),J}if(Y||!X){if($)console.log("[PieRoot] Loading state:",{isLoading:Y,hasUiConfiguration:!!X});return J}if($)console.log("[PieRoot] UI configuration loaded successfully:",X),console.log("[PieRoot] Rendering UI with configuration");return L(F.Provider,{value:G,children:L(E.Provider,{value:B,children:L(y.Provider,{value:W,children:L(K.Provider,{value:U??L(WZ,{}),children:L(v,{children:L(p,{children:T?L(w,{uiConfig:X}):L("form",{id:"piedata_global_form",action:D+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:L(w,{uiConfig:X})})})})})})})})},BZ=(f)=>{let U=n(()=>new YZ,[]);return L(S.Provider,{value:f.onNavigate,children:L(j.Provider,{value:f.config,children:L(XZ,{client:U,children:L(qZ,{...f})})})})},QZ=BZ;import{useMemo as s}from"react";import{QueryClient as CZ,QueryClientProvider as RZ,useQuery as wZ}from"@tanstack/react-query";import{createAxiosDateTransformer as KZ}from"axios-date-transformer";import{useEffect as OZ,useState as _Z}from"react";var wf=({onError:f}={})=>{let[U,z]=_Z(null),Z=Mf();return OZ(()=>{if(typeof window==="undefined")return;let H=window.Telegram?.WebApp;if(!H)return;try{H.ready?.()}catch(T){f?.()}if(Z==="telegram_expanded"&&(H.platform==="ios"||H.platform==="android"))H.expand();z(H)},[]),U};import{jsx as M,Fragment as LZ}from"react/jsx-runtime";var FZ=({location:f,fallback:U,piecache:z,onError:Z,queryOptions:H,disableGlobalForm:T})=>{let D=x(),V=u(),$=N(),P=s(()=>KZ({baseURL:D}),[D]),G=s(()=>o(),[]),B=s(()=>D?b(D):null,[D]),W=s(()=>D?d(D,V):null,[D,V]),X=wf({onError:Z}),{data:Y,isLoading:I,error:J}=wZ({queryKey:["uiConfig",f.pathname+f.search,X?.initData],enabled:!!X?.initData,queryFn:async()=>{let q=new URLSearchParams(f.search);if(q.set("__pieroot","telegram"),X?.initData)q.set("initData",X.initData);let O="/api/content"+f.pathname+"?"+q.toString();if($)console.log("[PieRoot] Fetching UI configuration from:",O);let _=await P.get(O,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if($)console.log("[PieRoot] Received UI configuration:",_.data);return _.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(q)=>Math.min(1000*2**q,30000),...H}),Q=l(f.pathname,z,U);if(!D)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(J&&$)return console.error("[PieRoot] Error fetching UI configuration:",J),console.error("[PieRoot] Error details:",{message:J.message,status:J.response?.status,data:J.response?.data}),Z?.(),Q;if(I||!Y){if($)console.log("[PieRoot] Loading state:",{isLoading:I,hasUiConfiguration:!!Y});return Q}if($)console.log("[PieRoot] UI configuration loaded successfully:",Y),console.log("[PieRoot] Rendering UI with configuration");return M(F.Provider,{value:G,children:M(E.Provider,{value:B,children:M(y.Provider,{value:W,children:M(K.Provider,{value:U??M(LZ,{}),children:M(v,{children:M(p,{children:T?M(w,{uiConfig:Y}):M("form",{id:"piedata_global_form",action:D+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:M(w,{uiConfig:Y})})})})})})})})},SZ=(f)=>{let U=s(()=>new CZ,[]);return M(S.Provider,{value:f.onNavigate,children:M(j.Provider,{value:f.config,children:M(RZ,{client:U,children:M(FZ,{...f})})})})},MZ=SZ;import{useMemo as Kf,useState as AZ}from"react";import{QueryClient as NZ,QueryClientProvider as yZ}from"@tanstack/react-query";import{jsx as m,Fragment as mZ}from"react/jsx-runtime";var EZ=({location:f,fallback:U,children:z,disableGlobalForm:Z})=>{let H=x(),T=u(),D=N(),V=Kf(()=>o(),[]),$=Kf(()=>H?b(H):null,[H]),P=Kf(()=>H?d(H,T):null,[H,T]);if(D)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",H),console.log("[PieRoot] CENTRIFUGE_SERVER:",T),console.log("[PieRoot] Fallback provided:",!!U);return m(F.Provider,{value:V,children:m(E.Provider,{value:$,children:m(y.Provider,{value:P,children:m(K.Provider,{value:U??m(mZ,{}),children:m(v,{children:m(p,{children:Z?z:m("form",{id:"piedata_global_form",action:H+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:z})})})})})})})},oZ=(f)=>{let[U]=AZ(()=>new NZ);return m(S.Provider,{value:f.onNavigate,children:m(j.Provider,{value:f.config,children:m(yZ,{client:U,children:m(EZ,{...f})})})})},kZ=oZ;import{useMemo as i}from"react";import{QueryClient as uZ,QueryClientProvider as dZ,useQuery as bZ}from"@tanstack/react-query";import{createAxiosDateTransformer as gZ}from"axios-date-transformer";import{useEffect as jZ,useState as xZ}from"react";var Ff=()=>{let[f,U]=xZ(null);return jZ(()=>{if(typeof window==="undefined")return;let z=window.WebApp;if(!z)return;z.ready(),U(z)},[]),f};import{jsx as A,Fragment as cZ}from"react/jsx-runtime";var vZ=({location:f,fallback:U,piecache:z,onError:Z,queryOptions:H,disableGlobalForm:T})=>{let D=x(),V=u(),$=N(),P=i(()=>gZ({baseURL:D}),[D]),G=i(()=>o(),[]),B=i(()=>D?b(D):null,[D]),W=i(()=>D?d(D,V):null,[D,V]),X=Ff(),{data:Y,isLoading:I,error:J}=bZ({queryKey:["uiConfig",f.pathname+f.search,X?.initData],queryFn:async()=>{let q=new URLSearchParams(f.search);if(q.set("__pieroot","max"),X?.initData)q.set("initData",X.initData);let O="/api/content"+f.pathname+"?"+q.toString();if($)console.log("[PieRoot] Fetching UI configuration from:",O);let _=await P.get(O,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if($)console.log("[PieRoot] Received UI configuration:",_.data);return _.data},enabled:!!X?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(q)=>Math.min(1000*2**q,30000),...H}),Q=l(f.pathname,z,U);if(!D)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(J&&$)return console.error("[PieRoot] Error fetching UI configuration:",J),console.error("[PieRoot] Error details:",{message:J.message,status:J.response?.status,data:J.response?.data}),Z?.(),Q;if(I||!Y){if($)console.log("[PieRoot] Loading state:",{isLoading:I,hasUiConfiguration:!!Y});return Q}if($)console.log("[PieRoot] UI configuration loaded successfully:",Y),console.log("[PieRoot] Rendering UI with configuration");return A(F.Provider,{value:G,children:A(E.Provider,{value:B,children:A(y.Provider,{value:W,children:A(K.Provider,{value:U??A(cZ,{}),children:A(v,{children:A(p,{children:T?A(w,{uiConfig:Y}):A("form",{id:"piedata_global_form",action:D+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:A(w,{uiConfig:Y})})})})})})})})},pZ=(f)=>{let U=i(()=>new uZ,[]);return A(S.Provider,{value:f.onNavigate,children:A(j.Provider,{value:f.config,children:A(dZ,{client:U,children:A(vZ,{...f})})})})},hZ=pZ;import{useMemo as lZ}from"react";var rZ=(f,U={},z=[],Z,H)=>{let T=H?.renderingLogEnabled??!1,D=H?.timeout,V=H?.retryPolicy,$=V?.maxRetries??0,P=V?.baseDelay??1000,G=V?.retryOn??[502,503,504];if(T)console.log("Registering AJAX: ",Z,U,z);return async(B={})=>{if(typeof window==="undefined"||typeof document==="undefined"){if(T)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}let W=H?.apiServer;if(!W){if(T)console.warn("AJAX skipped: apiServer is missing");return}if(!Z||!f){if(T)console.warn("AJAX skipped: pathname or setUiAjaxConfiguration is missing");return}if(z.includes("sid"))await Rf();let X=new FormData;for(let[J,Q]of Object.entries({...U,...B}))X.append(J,Q);for(let J of z)if(J==="sid"){if(!window.sid)throw new Error("SocketIO isn't initialized properly");X.append("sid",window.sid)}else{let Q=document.getElementsByName(J);if(!Q.length){if(T)console.warn(`No input found with name ${J}`);continue}let q=Q[0];if(q instanceof HTMLInputElement)if(q.type==="file"&&q.files)Array.from(q.files).forEach((O)=>X.append(J,O));else X.append(J,q.value);else if(q instanceof HTMLTextAreaElement)X.append(J,q.value)}let Y=W+"api/ajax_content"+Z;f(null);let I;for(let J=0;J<=$;J++){if(J>0){let O=P*2**(J-1);if(T)console.log(`AJAX retry ${J}/${$} after ${O}ms`);await new Promise((_)=>setTimeout(_,O))}let Q=D!=null?new AbortController:null,q=Q&&setTimeout(()=>Q.abort(),D);try{let O=await fetch(Y,{method:"POST",body:X,signal:Q?.signal});if(q)clearTimeout(q);if(!O.ok&&G.includes(O.status)&&J<$){I=new Error(`HTTP ${O.status}`);continue}let t=(O.headers.get("content-type")||"").includes("application/json");if(!!O.body?.getReader&&!t){let a=O.body.getReader(),XU=new TextDecoder,c="";while(!0){let{done:$f,value:IU}=await a.read();if($f)break;c+=XU.decode(IU,{stream:!0});let Sf=c.split(`
|
|
3
|
-
`);c=
|
|
2
|
+
import{useContext as If,useEffect as Cf,useRef as yU}from"react";import{createContext as WU,useContext as QU}from"react";var j=WU(null),h=()=>{let f=QU(j);if(!f)throw new Error("usePieConfig must be used within PieConfigProvider");return f},x=()=>{let{apiServer:f}=h();return f},e=x,u=()=>{let{centrifugeServer:f}=h();return f};var N=()=>{let{enableRenderingLog:f}=h();return f},Lf=N,Af=()=>{let{pageProcessor:f}=h();return f};var Tf="__piedemo__";import{createContext as RU}from"react";import{Centrifuge as Nf}from"centrifuge";var yf=new Map,d=(f,U)=>{if(!U)return null;let D=`${f}::${U}`,H=yf.get(D);if(H)return H;async function P(){let Z=await fetch(f+"api/centrifuge/gen_token");if(!Z.ok){if(Z.status===403)throw new Nf.UnauthorizedError("Backend is not answering");throw new Error(`Unexpected status code ${Z.status}`)}return(await Z.json()).token}let $=new Nf(U,{getToken:P});return yf.set(D,$),$},_U=RU(null),o=_U;import{io as wU}from"socket.io-client";import{createContext as KU}from"react";var of=new Map,b=(f)=>{let U=of.get(f);if(U)return U;let D=wU(f,{autoConnect:!1,transports:["websocket"]});return of.set(f,D),D},SU=KU(null),m=SU;import FU from"mitt";import{createContext as MU,useCallback as LU,useContext as AU}from"react";var Vf=null;function E(){if(!Vf)Vf=FU();return Vf}var mf=MU(null);function NU(f){let U=AU(mf);return LU((D,H)=>{(U??E()).emit(`pie${D}_${f}`,H)},[f,U])}var S=mf;import{jsx as EU,jsxs as kU,Fragment as mU}from"react/jsx-runtime";var oU=({card:f,data:U,children:D,useSocketioSupport:H=!1,useCentrifugeSupport:P=!1,useMittSupport:$=!1,centrifugeChannel:Z=void 0,methods:V=void 0,stored:z=void 0})=>{let T=Lf(),I=yU(V);if(I.current=V,T)console.log("[PieCard] Rendering card:",f),console.log("[PieCard] Card data:",U),console.log("[PieCard] Component name:",U?.name),console.log("[PieCard] Real-time support:",{socketio:H,centrifuge:P,mitt:$,centrifugeChannel:Z}),console.log("[PieCard] Methods:",V?Object.keys(V):"none"),console.log("[PieCard] Has children:",!!D);let X=If(m),G=If(o),J=If(S);if(Cf(()=>{if(!X||!H||!I.current||!U.name){if(T&&H)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!X,useSocketioSupport:H,hasMethods:!!I.current,hasDataName:!!U?.name});return}let q=Object.keys(I.current??{}).map((C)=>{let O=`pie${C}_${U.name}`;if(T)console.log(`[PieCard] Socket.IO registering event: ${O}`);let W=(B)=>{I.current?.[C]?.(B)};return X.on(O,W),[O,W]});return()=>{q.forEach(([C,O])=>{if(T)console.log(`[PieCard] Socket.IO unregistering event: ${C}`);X.off(C,O)})}},[X,U.name,H]),Cf(()=>{if(!G||!P||!Z||!U.name){if(T&&P)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!G,useCentrifugeSupport:P,hasCentrifugeChannel:!!Z,hasMethods:!!I.current,hasDataName:!!U?.name});return}let q=Object.keys(I.current??{}).map((C)=>{let O=`pie${C}_${U.name}_${Z}`;if(T)console.log(`[PieCard] Centrifuge subscribing to channel: ${O}`);let W=G.newSubscription(O);return W.on("publication",(B)=>{if(T)console.log(`[PieCard] Centrifuge received data on ${O}:`,B.data);I.current?.[C]?.(B.data)}),W.subscribe(),W});return()=>{q.forEach((C)=>{if(T)console.log("[PieCard] Centrifuge unsubscribing from channel");C.unsubscribe(),G.removeSubscription(C)})}},[G,Z,U.name,P]),Cf(()=>{if(!J||!$||!U.name){if(T&&$)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!J,useMittSupport:$,hasMethods:!!I.current,hasDataName:!!U?.name});return}let Y=Object.keys(I.current??{}),q={};return Y.forEach((C)=>{let O=`pie${C}_${U.name}`,W=(B)=>{if(T)console.log(`[PieCard] Mitt registering event: ${O}`);I.current?.[C]?.(B)};q[O]=W,J.on(O,W)}),()=>{Object.entries(q).forEach(([C,O])=>{if(T)console.log(`[PieCard] Mitt unregistering event: ${C}`);J.off(C,O)})}},[J,U.name,$]),T)console.log("[PieCard] Rendering complete, returning children");if(z!==void 0)return kU(mU,{children:[EU("input",{type:"hidden",name:U.name,value:JSON.stringify(z)}),D]});return D},_=oU;import{lazy as jU}from"react";var Jf=new Map;function Ef(f,U){return jU(()=>{if(Jf.has(U))return Jf.get(U);let D=f().then((H)=>H);return Jf.set(U,D),D})}var g=new Map,xU=(f)=>{if(!f.name)throw new Error("Component registration requires a name");if(!f.component&&!f.loader)throw new Error(`Component "${f.name}" requires component or loader`);let U={name:f.name,component:f.component,loader:f.loader,metadata:f.metadata,fallback:f.fallback,isLazy:!1};if(!U.component&&U.loader)U.component=Ef(U.loader,f.name),U.loader=void 0,U.isLazy=!0;return U};function Q(f){let U=xU(f);return g.set(U.name,U),U.component}var uU=(f)=>{f.forEach((U)=>Q(U))},dU=(f)=>{g.delete(f)},bU=(f)=>{return g.has(f)},gU=(f)=>{return g.get(f)?.metadata},r=(f)=>{return g.get(f)},vU=()=>{return Array.from(g.keys())},pU=()=>{return g.size};import{Suspense as nU,useContext as iU,memo as tU}from"react";import{createContext as cU}from"react";import{jsx as rU,Fragment as lU}from"react/jsx-runtime";var hU=cU(rU(lU,{})),K=hU;import{jsx as Yf}from"react/jsx-runtime";function sU({uiConfig:f,setUiAjaxConfiguration:U}){let D=iU(K),H=N();if(H)console.log("[UI] Rendering component:",f.card),console.log("[UI] Component data:",f.data),console.log("[UI] Component content:",f.content),console.log("[UI] Has setUiAjaxConfiguration:",!!U);let P=r(f.card);if(!P?.component){if(H)console.warn(`[UI] Component not found in registry: ${f.card}`),console.log("[UI] Returning fallback component");return D}if(H)console.log("[UI] Found component in registry:",{name:P.name,isLazy:P.isLazy,hasMetadata:!!P.metadata});let $=P.component,Z=Yf($,{data:f.data,content:f.content,setUiAjaxConfiguration:U});if(P.isLazy){if(H)console.log("[UI] Rendering lazy component with Suspense:",P.name);return Yf(nU,{fallback:P.fallback?Yf(P.fallback,{}):D,children:Z},`${P.name}`)}if(H)console.log("[UI] Rendering component directly:",P.name);return Z}var w=tU(sU);import{Suspense as fH,useContext as UH}from"react";import{createContext as aU}from"react";var eU=aU(null),y=eU;import{jsx as ff}from"react/jsx-runtime";function kf({uiConfig:f,setUiAjaxConfiguration:U}){let D=UH(K),H=N();if(H)console.log("[UILoading] Rendering fallback for:",f.card),console.log("[UILoading] Component data:",f.data),console.log("[UILoading] Component content:",f.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!U);let P=r(f.card);if(!P?.component){if(H)console.warn(`[UILoading] Component not found in registry: ${f.card}`),console.log("[UILoading] Returning fallback component");return D}if(H)console.log("[UILoading] Found component in registry:",{name:P.name,isLazy:P.isLazy,hasMetadata:!!P.metadata,hasFallback:!!P.fallback});if(P.fallback){if(H)console.log("[UILoading] Rendering fallback for:",P.name);let V=P.fallback;return ff(V,{})}if(H)console.log("[UILoading] No fallback, rendering full component:",P.name);let $=P.component,Z=ff(y.Provider,{value:kf,children:ff($,{data:f.data,content:f.content,setUiAjaxConfiguration:U})});if(P.isLazy)return ff(fH,{fallback:D,children:Z},`${P.name}`);return Z}var Of=kf;import{useContext as HH}from"react";import{jsx as Xf}from"react/jsx-runtime";var PH=({data:f,content:U,setUiAjaxConfiguration:D})=>{let{name:H,sx:P}=f,$=HH(y)??w;return Xf(_,{card:H,data:f,children:Xf("div",{style:P,id:H,children:U.map((Z,V)=>{return Xf($,{uiConfig:Z,setUiAjaxConfiguration:D},`children-${V}`)})})})},jf=PH;var DH=Q({name:"SequenceCard",component:jf,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});import{useContext as ZH}from"react";import{jsx as xf}from"react/jsx-runtime";var $H=({data:f,content:U,setUiAjaxConfiguration:D})=>{let{name:H}=f,P=ZH(y)??w;return xf(_,{card:H,data:f,children:U.map(($,Z)=>{return xf(P,{uiConfig:$,setUiAjaxConfiguration:D},`children-${Z}`)})})},uf=$H;var zH=Q({name:"UnionCard",component:uf,metadata:{author:"Swarm.ing",description:"Renders one of many components"}});import{useEffect as CH,useState as JH}from"react";import YH from"html-react-parser";import{useCallback as Uf,useEffect as TH,useRef as Gf,useState as VH}from"react";function IH(){let f=new AudioContext,U=f.createOscillator(),D=U.connect(f.createMediaStreamDestination());U.start();let H=D.stream.getAudioTracks()[0];return H.enabled=!1,H}function Hf(f=null,U){let[D,H]=VH(!1),P=Gf(null),$=Gf(null),Z=Gf(null),V=Uf(async(X,G=!0)=>{if(P.current)z();let J=new RTCPeerConnection;if(J.onconnectionstatechange=()=>{if(J.connectionState==="connected")H(!0);else if(["disconnected","failed","closed"].includes(J.connectionState))H(!1)},J.ontrack=(R)=>{if(f)f.srcObject=R.streams[0]},G){let R=await navigator.mediaDevices.getUserMedia({audio:!0});J.addTrack(R.getTracks()[0],R)}else{let R=IH();J.addTrack(R)}let Y=J.createDataChannel("oai-events");$.current=Y,Z.current=new Promise((R)=>{Y.addEventListener("open",()=>{R()})});let q=await J.createOffer();await J.setLocalDescription(q);let B=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:q.sdp,headers:{Authorization:`Bearer ${X}`,"Content-Type":"application/sdp"}})).text();await J.setRemoteDescription({type:"answer",sdp:B}),P.current=J,await Z.current},[f]),z=Uf(()=>{let X=$.current;if(X)X.close();P.current?.getSenders()?.forEach((G)=>G.track?.stop()),P.current?.close(),H(!1),P.current=null,$.current=null,Z.current=null},[f]),T=Uf((X)=>{let G=$.current;if(!G){console.error("Data channel is not ready",X);return}let J=new Date().toLocaleTimeString();if(X.event_id=X.event_id||crypto.randomUUID(),G.send(JSON.stringify(X)),!X.timestamp)X.timestamp=J;U?.(X)},[U,f]),I=Uf((X)=>{if(!$.current){console.error("Data channel is not ready");return}let J=()=>{T({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:X}]}}),T({type:"response.create"})};if(Z.current)Z.current.then(J);else J()},[U,f]);return TH(()=>{let X=$.current;if(!X)return;let G=(J)=>{let Y=JSON.parse(J.data);if(!Y.timestamp)Y.timestamp=new Date().toLocaleTimeString();U?.(Y)};return X.addEventListener("message",G),()=>{X.removeEventListener("message",G)}},[U,f]),{isSessionActive:D,startSession:V,stopSession:z,sendTextMessage:I}}import{jsx as XH}from"react/jsx-runtime";var OH=({data:f})=>{let{html:U,useSocketioSupport:D,useCentrifugeSupport:H,useMittSupport:P,centrifugeChannel:$}=f,[Z,V]=JH(U),{isSessionActive:z,startSession:T,sendTextMessage:I}=Hf(null,(Y)=>{if(console.log(Y.type,Y.type==="response.output_text.delta"&&Y.delta),Y.type==="response.output_text.delta"&&Y.delta)V((q)=>q+Y.delta)});return CH(()=>{V(U)},[U]),XH(_,{card:"HTMLEmbedCard",data:f,methods:{update:(Y)=>{V(Y.value)},generateUsingAI:async(Y)=>{try{if(!z&&Y.token)await T(Y.token,!1);I(Y.prompt)}catch(q){console.error("Failed to generate using AI",q)}},initializeAI:async(Y)=>{if(!z&&Y.token)await T(Y.token,!1)}},useCentrifugeSupport:H,useSocketioSupport:D,useMittSupport:P,centrifugeChannel:$,children:YH(Z)})},df=OH;var GH=Q({name:"HTMLEmbedCard",component:df,metadata:{author:"Swarm.ing"}});import{useEffect as qH,useState as BH}from"react";import{jsx as bf}from"react/jsx-runtime";var WH=({data:f})=>{let{name:U,value:D,useSocketioSupport:H,useCentrifugeSupport:P,useMittSupport:$,centrifugeChannel:Z}=f,[V,z]=BH(D);return qH(()=>{z(D)},[D]),bf(_,{card:"HiddenCard",data:f,useSocketioSupport:H,useCentrifugeSupport:P,useMittSupport:$,centrifugeChannel:Z,methods:{update:({value:T})=>{z(T)}},children:bf("input",{type:"hidden",id:U,name:U,value:V})})},gf=WH;var QH=Q({name:"HiddenCard",component:gf,metadata:{author:"Swarm.ing"}});import{useContext as vf,useEffect as wH}from"react";import{createContext as RH}from"react";var _H=RH(void 0),F=_H;import{jsx as FH,Fragment as SH}from"react/jsx-runtime";var KH=({data:f})=>{let{url:U}=f,D=vf(F),H=vf(K);return wH(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(U))window.location.href=U;else D?.(U)},[U,D]),FH(SH,{children:H})},pf=KH;var MH=Q({name:"AutoRedirectCard",component:pf,metadata:{author:"Swarm.ing"}});import{Bounce as LH,Slide as AH,Zoom as NH,Flip as yH}from"react-toastify";import{toast as oH,ToastContainer as mH}from"react-toastify";import{useContext as EH,useMemo as kH,useRef as jH}from"react";import{jsx as qf,Fragment as vH}from"react/jsx-runtime";var xH={bounce:LH,slide:AH,zoom:NH,flip:yH},uH=(f)=>{let U={...f,type:f.alertType,transition:f.transition?xH[f.transition]:void 0,position:f.position??"bottom-right",autoClose:f.autoClose??3000,style:{backgroundColor:"black",...f.sx}};oH(f.message,U)},dH=(f)=>{console.log("Log event",f)},bH=(f)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let U=()=>{try{new window.Notification(f.title,{body:f.message??f.subtitle,icon:f.icon,silent:f.silent})}catch(H){console.error("[IOEventsCard] Failed to show notification",H)}},D=window.Notification.permission;if(D==="granted"){U();return}if(D==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((H)=>{if(H==="granted")U()})},gH=({data:f})=>{let{useCentrifugeSupport:U,useSocketioSupport:D,useMittSupport:H,centrifugeChannel:P}=f,$=EH(F),Z=jH($);Z.current=$;let V=kH(()=>({alert:uH,log:dH,push:bH,redirect:(z)=>{if(z.to){let T=z.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(T))window.location.href=T;else Z.current?.(T)}else window.location.reload()},reload:(z)=>{if(z.to){let T=z.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(T))window.location.href=T;else Z.current?.(T)}else window.location.reload()}}),[]);return qf(vH,{children:qf(_,{card:"IOEventsCard",data:f,useCentrifugeSupport:U,useSocketioSupport:D,useMittSupport:H,centrifugeChannel:P,methods:V,children:qf(mH,{})})})},cf=gH;var pH=Q({name:"IOEventsCard",component:cf,metadata:{author:"Swarm.ing"}});import{useEffect as hf,useState as cH}from"react";import{jsx as lf}from"react/jsx-runtime";var hH=({data:f})=>{let{name:U,key:D,value:H,useSocketioSupport:P,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V}=f,[z,T]=cH(H);return hf(()=>{T(H)},[H]),hf(()=>{if(typeof window==="undefined")return;sessionStorage.setItem(D,z)},[D,z]),lf(_,{card:"SessionStorageCard",data:f,useSocketioSupport:P,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V,methods:{update:({value:I})=>{T(I)},remove:()=>{sessionStorage.removeItem(D),T("")}},children:lf("input",{type:"hidden",id:U,name:U,value:z})})},rf=hH;var lH=Q({name:"SessionStorageCard",component:rf,metadata:{author:"PieData"}});import{useEffect as nf,useState as rH}from"react";import{jsx as tf}from"react/jsx-runtime";var nH=({data:f})=>{let{name:U,key:D,value:H,useSocketioSupport:P,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V}=f,[z,T]=rH(H);return nf(()=>{T(H)},[H]),nf(()=>{if(typeof window==="undefined")return;localStorage.setItem(D,z)},[D,z]),tf(_,{card:"DeviceStorageCard",data:f,useSocketioSupport:P,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V,methods:{update:({value:I})=>{T(I)},remove:()=>{localStorage.removeItem(D),T("")}},children:tf("input",{type:"hidden",id:U,name:U,value:z})})},sf=nH;var iH=Q({name:"DeviceStorageCard",component:sf,metadata:{author:"PieData"}});import{useEffect as af,useState as tH}from"react";import{jsx as ef}from"react/jsx-runtime";var sH=({data:f})=>{let{name:U,key:D,value:H,useSocketioSupport:P,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V}=f,[z,T]=tH(H);return af(()=>{T(H)},[H]),af(()=>{if(typeof window==="undefined")return;let I=window.Telegram?.WebApp?.CloudStorage;if(!I)return;I.setItem(D,z)},[D,z]),ef(_,{card:"CloudStorageCard",data:f,useSocketioSupport:P,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V,methods:{update:({value:I})=>{T(I)},remove:()=>{let I=window.Telegram?.WebApp?.CloudStorage;if(I)I.removeItem(D);T("")}},children:ef("input",{type:"hidden",id:U,name:U,value:z})})},fU=sH;var aH=Q({name:"CloudStorageCard",component:fU,metadata:{author:"PieData"}});import{useEffect as UU,useState as eH}from"react";import{jsx as HU}from"react/jsx-runtime";var fP=({data:f})=>{let{name:U,key:D,value:H,useSocketioSupport:P,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V}=f,[z,T]=eH(H);return UU(()=>{T(H)},[H]),UU(()=>{if(typeof window==="undefined")return;let I=window.Telegram?.WebApp?.SecureStorage;if(!I)return;I.setItem(D,z)},[D,z]),HU(_,{card:"SecureStorageCard",data:f,useSocketioSupport:P,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V,methods:{update:({value:I})=>{T(I)},remove:()=>{let I=window.Telegram?.WebApp?.SecureStorage;if(I)I.removeItem(D);T("")}},children:HU("input",{type:"hidden",id:U,name:U,value:z})})},PU=fP;var UP=Q({name:"SecureStorageCard",component:PU,metadata:{author:"PieData"}});import{useCallback as Bf,useContext as Wf,useEffect as HP,useRef as PP,useState as DU}from"react";import{jsx as ZU}from"react/jsx-runtime";var DP=({data:f,content:U})=>{let{useLoader:D,noReturn:H,returnType:P,useSocketioSupport:$,useCentrifugeSupport:Z,useMittSupport:V,centrifugeChannel:z}=f,T=Wf(K),I=Wf(y)??w,[X,G]=DU(!1),[J,Y]=DU(null),q=PP(U),C=Wf(S),O=Bf((R)=>{if(R===null)G(!0);else if(G(!1),!H)q.current=R;if(!H)Y(R)},[H]),W=Bf((R)=>{q.current=R.content,Y(R.content)},[]),B=Bf((R)=>{if(R===null)G(!0);else if(G(!1),!H)for(let s of R)C?.emit(s.name,s.data)},[H,C]);if(HP(()=>{Y(U),G(!1)},[U]),!J&&D)return T;return ZU(_,{card:"AjaxGroupCard",data:f,methods:{changeContent:W},useSocketioSupport:$,useCentrifugeSupport:Z,useMittSupport:V,centrifugeChannel:z,children:ZU(I,{uiConfig:J??q.current,setUiAjaxConfiguration:P==="events"?B:O})})},$U=DP;var ZP=Q({name:"AjaxGroupCard",component:$U,metadata:{author:"Swarm.ing",description:"Group card with AJAX support"}});import{useContext as zU}from"react";import{jsx as Qf}from"react/jsx-runtime";var $P=({data:f,content:U,setUiAjaxConfiguration:D})=>{let{name:H,url:P,sx:$}=f,Z=zU(F),V=zU(y)??w;return Qf(_,{card:H,data:f,children:Qf("div",{style:$,id:H,onClick:(T)=>{if(P)if(T.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(P))window.location.href=P;else Z?.(P)},children:Qf(V,{setUiAjaxConfiguration:D,uiConfig:U})})})},TU=$P;var zP=Q({name:"BoxCard",component:TU,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});import{useContext as TP}from"react";import{jsx as Rf}from"react/jsx-runtime";var VP=({data:f,content:U,setUiAjaxConfiguration:D})=>{let{name:H,sx:P}=f,$=TP(y)??w;return Rf(_,{card:H,data:f,children:Rf("div",{style:P,id:H,children:U.map((Z,V)=>{return Rf($,{uiConfig:Z,setUiAjaxConfiguration:D},`children-${V}`)})})})},VU=VP;var IP=Q({name:"OneOfCard",component:VU,metadata:{author:"Swarm.ing",description:"Different variants"}});import{useMemo as n}from"react";import{QueryClient as QP,QueryClientProvider as RP,useQuery as _P}from"@tanstack/react-query";import{useContext as YP,useEffect as OP}from"react";import{useEffect as CP,useState as JP}from"react";var Pf=new Map,Df=new Map;function Zf(f,U){let D=`${f}::${U}`,H=f?Pf.get(D):void 0,[P,$]=JP(H??null);return CP(()=>{if(!f)return;if(Pf.has(D)){$(Pf.get(D));return}let Z=Df.get(D);if(!Z)Z=fetch(f+`api/support/${U}`,{method:"GET"}).then((z)=>z.json()).then((z)=>{return Pf.set(D,z),Df.delete(D),z}).catch((z)=>{throw Df.delete(D),z}),Df.set(D,Z);let V=!1;return Z.then((z)=>{if(!V)$(z)}).catch(()=>{}),()=>{V=!0}},[f,U,D]),P}var _f=null,IU=null;function CU(){IU?.()}function wf(){if(typeof window==="undefined")return Promise.resolve();if(typeof window.sid!=="undefined")return Promise.resolve();if(!_f)_f=new Promise((f)=>{IU=()=>{f()}});return _f}var XP=({children:f})=>{let U=YP(m),D=e(),H=Zf(D,"socketIO"),P=($)=>{if(typeof window!=="undefined")window.sid=$.sid,CU(),console.log(`SocketIO initialized: ${window.sid}`)};return OP(()=>{if(!U)return;let $=()=>{console.log("SocketIO connected")},Z=(V)=>{console.log(`SocketIO disconnected: ${V}`),U.connect()};if(H)U.on("pieinit",P),U.on("connect",$),U.on("disconnect",Z),U.connect();return()=>{if(H)U.off("pieinit",P),U.off("connect",$),U.off("disconnect",Z),U.disconnect()}},[U,H]),f},v=XP;import{useContext as GP,useEffect as qP}from"react";var BP=({children:f})=>{let U=GP(o),D=e(),H=Zf(D,"centrifuge");return qP(()=>{if(!U)return;let P=()=>{console.log("Centrifuge connected")},$=(Z)=>{console.log("Centrifuge disconnected:",Z)};if(H)U.on("connected",P),U.on("disconnected",$),U.connect();return()=>{if(H)U.disconnect()}},[U,H]),f},p=BP;import{createAxiosDateTransformer as wP}from"axios-date-transformer";import{jsx as WP}from"react/jsx-runtime";function l(f,U,D){if(!U)return D;let H=f.replace(/^\//,""),P=U[H];if(!P)return D;return WP(Of,{uiConfig:P})}import{jsx as M,Fragment as FP}from"react/jsx-runtime";var KP=({location:f,fallback:U,piecache:D,onError:H,queryOptions:P,disableGlobalForm:$})=>{let Z=x(),V=u(),z=N(),T=n(()=>wP({baseURL:Z||""}),[Z]),I=n(()=>E(),[]),X=n(()=>Z?b(Z):null,[Z]),G=n(()=>Z?d(Z,V):null,[Z,V]),{data:J,isLoading:Y,error:q}=_P({queryKey:["uiConfig",f.pathname+f.search,Z],enabled:!!Z,queryFn:async()=>{let O=new URLSearchParams(f.search);O.set("__pieroot","web");let W="/api/content"+f.pathname+"?"+O.toString();if(z)console.log("[PieRoot] Fetching UI configuration from:",W);let B=await T.get(W,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(z)console.log("[PieRoot] Received UI configuration:",B.data);return B.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(O)=>Math.min(1000*2**O,30000),...P}),C=l(f.pathname,D,U);if(!Z)return C??null;if(z)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",Z),console.log("[PieRoot] CENTRIFUGE_SERVER:",V),console.log("[PieRoot] Fallback provided:",!!U),console.log("[PieRoot] Piecache provided:",!!D);if(q){if(z)console.error("[PieRoot] Error fetching UI configuration:",q),console.error("[PieRoot] Error details:",{message:q.message,status:q.response?.status,data:q.response?.data});return H?.(),C}if(Y||!J){if(z)console.log("[PieRoot] Loading state:",{isLoading:Y,hasUiConfiguration:!!J});return C}if(z)console.log("[PieRoot] UI configuration loaded successfully:",J),console.log("[PieRoot] Rendering UI with configuration");return M(S.Provider,{value:I,children:M(m.Provider,{value:X,children:M(o.Provider,{value:G,children:M(K.Provider,{value:U??M(FP,{}),children:M(v,{children:M(p,{children:$?M(w,{uiConfig:J}):M("form",{id:"piedata_global_form",action:Z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:M(w,{uiConfig:J})})})})})})})})},SP=(f)=>{let U=n(()=>new QP,[]);return M(F.Provider,{value:f.onNavigate,children:M(j.Provider,{value:f.config,children:M(RP,{client:U,children:M(KP,{...f})})})})},MP=SP;import{useMemo as i}from"react";import{QueryClient as NP,QueryClientProvider as yP,useQuery as oP}from"@tanstack/react-query";import{createAxiosDateTransformer as mP}from"axios-date-transformer";import{useEffect as LP,useState as AP}from"react";var Kf=({onError:f}={})=>{let[U,D]=AP(null),H=Af();return LP(()=>{if(typeof window==="undefined")return;let P=window.Telegram?.WebApp;if(!P)return;try{P.ready?.()}catch($){f?.()}if(H==="telegram_expanded"&&(P.platform==="ios"||P.platform==="android"))P.expand();D(P)},[]),U};import{jsx as L,Fragment as jP}from"react/jsx-runtime";var EP=({location:f,fallback:U,piecache:D,onError:H,queryOptions:P,disableGlobalForm:$})=>{let Z=x(),V=u(),z=N(),T=i(()=>mP({baseURL:Z}),[Z]),I=i(()=>E(),[]),X=i(()=>Z?b(Z):null,[Z]),G=i(()=>Z?d(Z,V):null,[Z,V]),J=Kf({onError:H}),{data:Y,isLoading:q,error:C}=oP({queryKey:["uiConfig",f.pathname+f.search,J?.initData],enabled:!!J?.initData,queryFn:async()=>{let W=new URLSearchParams(f.search);if(W.set("__pieroot","telegram"),J?.initData)W.set("initData",J.initData);let B="/api/content"+f.pathname+"?"+W.toString();if(z)console.log("[PieRoot] Fetching UI configuration from:",B);let R=await T.get(B,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(z)console.log("[PieRoot] Received UI configuration:",R.data);return R.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(W)=>Math.min(1000*2**W,30000),...P}),O=l(f.pathname,D,U);if(!Z)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(C&&z)return console.error("[PieRoot] Error fetching UI configuration:",C),console.error("[PieRoot] Error details:",{message:C.message,status:C.response?.status,data:C.response?.data}),H?.(),O;if(q||!Y){if(z)console.log("[PieRoot] Loading state:",{isLoading:q,hasUiConfiguration:!!Y});return O}if(z)console.log("[PieRoot] UI configuration loaded successfully:",Y),console.log("[PieRoot] Rendering UI with configuration");return L(S.Provider,{value:I,children:L(m.Provider,{value:X,children:L(o.Provider,{value:G,children:L(K.Provider,{value:U??L(jP,{}),children:L(v,{children:L(p,{children:$?L(w,{uiConfig:Y}):L("form",{id:"piedata_global_form",action:Z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:L(w,{uiConfig:Y})})})})})})})})},kP=(f)=>{let U=i(()=>new NP,[]);return L(F.Provider,{value:f.onNavigate,children:L(j.Provider,{value:f.config,children:L(yP,{client:U,children:L(EP,{...f})})})})},xP=kP;import{useMemo as Sf,useState as uP}from"react";import{QueryClient as dP,QueryClientProvider as bP}from"@tanstack/react-query";import{jsx as k,Fragment as pP}from"react/jsx-runtime";var gP=({location:f,fallback:U,children:D,disableGlobalForm:H})=>{let P=x(),$=u(),Z=N(),V=Sf(()=>E(),[]),z=Sf(()=>P?b(P):null,[P]),T=Sf(()=>P?d(P,$):null,[P,$]);if(Z)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",P),console.log("[PieRoot] CENTRIFUGE_SERVER:",$),console.log("[PieRoot] Fallback provided:",!!U);return k(S.Provider,{value:V,children:k(m.Provider,{value:z,children:k(o.Provider,{value:T,children:k(K.Provider,{value:U??k(pP,{}),children:k(v,{children:k(p,{children:H?D:k("form",{id:"piedata_global_form",action:P+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:D})})})})})})})},vP=(f)=>{let[U]=uP(()=>new dP);return k(F.Provider,{value:f.onNavigate,children:k(j.Provider,{value:f.config,children:k(bP,{client:U,children:k(gP,{...f})})})})},cP=vP;import{useMemo as t}from"react";import{QueryClient as rP,QueryClientProvider as nP,useQuery as iP}from"@tanstack/react-query";import{createAxiosDateTransformer as tP}from"axios-date-transformer";import{useEffect as hP,useState as lP}from"react";var Ff=()=>{let[f,U]=lP(null);return hP(()=>{if(typeof window==="undefined")return;let D=window.WebApp;if(!D)return;D.ready(),U(D)},[]),f};import{jsx as A,Fragment as eP}from"react/jsx-runtime";var sP=({location:f,fallback:U,piecache:D,onError:H,queryOptions:P,disableGlobalForm:$})=>{let Z=x(),V=u(),z=N(),T=t(()=>tP({baseURL:Z}),[Z]),I=t(()=>E(),[]),X=t(()=>Z?b(Z):null,[Z]),G=t(()=>Z?d(Z,V):null,[Z,V]),J=Ff(),{data:Y,isLoading:q,error:C}=iP({queryKey:["uiConfig",f.pathname+f.search,J?.initData],queryFn:async()=>{let W=new URLSearchParams(f.search);if(W.set("__pieroot","max"),J?.initData)W.set("initData",J.initData);let B="/api/content"+f.pathname+"?"+W.toString();if(z)console.log("[PieRoot] Fetching UI configuration from:",B);let R=await T.get(B,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(z)console.log("[PieRoot] Received UI configuration:",R.data);return R.data},enabled:!!J?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(W)=>Math.min(1000*2**W,30000),...P}),O=l(f.pathname,D,U);if(!Z)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(C&&z)return console.error("[PieRoot] Error fetching UI configuration:",C),console.error("[PieRoot] Error details:",{message:C.message,status:C.response?.status,data:C.response?.data}),H?.(),O;if(q||!Y){if(z)console.log("[PieRoot] Loading state:",{isLoading:q,hasUiConfiguration:!!Y});return O}if(z)console.log("[PieRoot] UI configuration loaded successfully:",Y),console.log("[PieRoot] Rendering UI with configuration");return A(S.Provider,{value:I,children:A(m.Provider,{value:X,children:A(o.Provider,{value:G,children:A(K.Provider,{value:U??A(eP,{}),children:A(v,{children:A(p,{children:$?A(w,{uiConfig:Y}):A("form",{id:"piedata_global_form",action:Z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:A(w,{uiConfig:Y})})})})})})})})},aP=(f)=>{let U=t(()=>new rP,[]);return A(F.Provider,{value:f.onNavigate,children:A(j.Provider,{value:f.config,children:A(nP,{client:U,children:A(sP,{...f})})})})},fD=aP;import{useMemo as UD}from"react";var JU=(f,U=!1)=>{if(f==="sid"){if(!window.sid)throw new Error("SocketIO isn't initialized properly");return[window.sid]}let D=document.getElementsByName(f);if(!D.length){if(U)console.warn(`No input found with name ${f}`);return[]}let H=D[0];if(H instanceof HTMLInputElement){if(H.type==="file"&&H.files)return Array.from(H.files);return[H.value]}if(H instanceof HTMLTextAreaElement)return[H.value];return[]},HD=(f,U={},D=[],H,P)=>{let $=P?.renderingLogEnabled??!1,Z=P?.timeout,V=P?.retryPolicy,z=V?.maxRetries??0,T=V?.baseDelay??1000,I=V?.retryOn??[502,503,504];if($)console.log("Registering AJAX: ",H,U,D);return async(X={})=>{if(typeof window==="undefined"||typeof document==="undefined"){if($)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}let G=P?.apiServer;if(!G){if($)console.warn("AJAX skipped: apiServer is missing");return}if(!H||!f){if($)console.warn("AJAX skipped: pathname or setUiAjaxConfiguration is missing");return}if(D.includes("sid"))await wf();let J=new FormData;for(let[C,O]of Object.entries({...U,...X}))J.append(C,O);for(let C of D)for(let O of JU(C,$))J.append(C,O);let Y=G+"api/ajax_content"+H;f(null);let q;for(let C=0;C<=z;C++){if(C>0){let B=T*2**(C-1);if($)console.log(`AJAX retry ${C}/${z} after ${B}ms`);await new Promise((R)=>setTimeout(R,B))}let O=Z!=null?new AbortController:null,W=O&&setTimeout(()=>O.abort(),Z);try{let B=await fetch(Y,{method:"POST",body:J,signal:O?.signal});if(W)clearTimeout(W);if(!B.ok&&I.includes(B.status)&&C<z){q=new Error(`HTTP ${B.status}`);continue}let s=(B.headers.get("content-type")||"").includes("application/json");if(!!B.body?.getReader&&!s){let a=B.body.getReader(),XU=new TextDecoder,c="";while(!0){let{done:$f,value:GU}=await a.read();if($f)break;c+=XU.decode(GU,{stream:!0});let Mf=c.split(`
|
|
3
|
+
`);c=Mf.pop()??"";for(let qU of Mf){let zf=qU.trim();if(!zf)continue;try{let BU=JSON.parse(zf);f([BU])}catch{if($)console.warn("Failed to parse streamed line:",zf)}}}if(c.trim())try{let $f=JSON.parse(c);f([$f])}catch{if($)console.warn("Failed to parse final streamed line:",c)}return{}}else{let a=await B.json();return f(a),a}}catch(B){if(W)clearTimeout(W);if(q=B,C<z)continue;if($)console.error("AJAX request failed:",B);return f(null),B}}if($)console.error("AJAX request failed after retries:",q);return f(null),q}},PD=(f,U={},D=[],H,P)=>{let{apiServer:$,enableRenderingLog:Z}=h(),V=JSON.stringify(U),z=JSON.stringify(D),T=JSON.stringify(P);return UD(()=>HD(f,U,D,H,{apiServer:$,renderingLogEnabled:Z,timeout:P?.timeout,retryPolicy:P?.retryPolicy}),[f,V,z,H,$,Z,T])};import{tool as DD}from"@openai/agents";import{useContext as ZD,useMemo as $D}from"react";var YU=/^pie(.+?)_(.+)$/;function OU(f=E(),U={}){let D=[],H=new Set;for(let P of f.all.keys()){if(typeof P!=="string")continue;let $=P.match(YU);if(!$)continue;let[,Z,V]=$,z={methodName:Z,cardName:V,eventName:P};if(U.filter&&!U.filter(z))continue;let T=U.nameFor?.(z)??`${V}_${Z}`;if(H.has(T))continue;H.add(T);let I=U.describe?.(z)??`Invokes the "${Z}" method on the PieCard "${V}" by emitting the in-process mitt event "${P}". The optional "payload" argument is forwarded verbatim to the card's handler.`;D.push(DD({name:T,description:I,strict:!1,parameters:{type:"object",properties:{payload:{description:"Arbitrary JSON payload forwarded to the PieCard method handler. Omit for fire-and-forget calls."}},required:[],additionalProperties:!0},execute:async(X)=>{let G=X?.payload;return f.emit(P,G),`Emitted "${P}"`}}))}return D}function zD(f={}){let D=ZD(S)??E(),H=[];for(let z of D.all.keys())if(typeof z==="string"&&YU.test(z))H.push(z);H.sort();let P=H.join("|"),{filter:$,describe:Z,nameFor:V}=f;return $D(()=>OU(D,{filter:$,describe:Z,nameFor:V}),[D,P,$,Z,V])}import{clsx as TD}from"clsx";import{twMerge as VD}from"tailwind-merge";function ID(...f){return VD(TD(f))}var CD=()=>{if(typeof document==="undefined")return;let f=document.getElementById("piedata_global_form");f&&f.submit()};var JD=(f,U)=>`${f}${Tf}${U}`;export{Kf as useWebApp,zD as usePieMittAgentTools,NU as usePieEmit,Hf as useOpenAIWebRTC,Ff as useMaxWebApp,PD as useAjaxSubmit,dU as unregisterComponent,CD as submitGlobalForm,g as registry,Q as registerPieComponent,uU as registerMultipleComponents,JU as readAjaxKey,JD as pieName,bU as hasComponent,pU as getRegistrySize,r as getRegistryEntry,OU as getMittAgentTools,gU as getComponentMeta,vU as getAllRegisteredComponents,ID as cn,zH as UnionCard,y as UIRendererContext,Of as UILoading,w as UI,lH as SessionStorageCard,DH as SequenceCard,UP as SecureStorageCard,xP as PieTelegramRoot,MP as PieRoot,fD as PieMaxRoot,_ as PieCard,cP as PieBaseRoot,Tf as PIEBREAK,IP as OneOfCard,pH as IOEventsCard,QH as HiddenCard,GH as HTMLEmbedCard,iH as DeviceStorageCard,aH as CloudStorageCard,zP as BoxCard,MH as AutoRedirectCard,ZP as AjaxGroupCard};
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var EH=Object.create;var{getPrototypeOf:oH,defineProperty:Vf,getOwnPropertyNames:VU,getOwnPropertyDescriptor:mH}=Object,JU=Object.prototype.hasOwnProperty;var YU=(f,U,Z)=>{Z=f!=null?EH(oH(f)):{};let H=U||!f||!f.__esModule?Vf(Z,"default",{value:f,enumerable:!0}):Z;for(let z of VU(f))if(!JU.call(H,z))Vf(H,z,{get:()=>f[z],enumerable:!0});return H},PU=new WeakMap,kH=(f)=>{var U=PU.get(f),Z;if(U)return U;if(U=Vf({},"__esModule",{value:!0}),f&&typeof f==="object"||typeof f==="function")VU(f).map((H)=>!JU.call(U,H)&&Vf(U,H,{get:()=>f[H],enumerable:!(Z=mH(f,H))||Z.enumerable}));return PU.set(f,U),U};var jH=(f,U)=>{for(var Z in U)Vf(f,Z,{get:U[Z],enumerable:!0,configurable:!0,set:(H)=>U[Z]=()=>H})};var OZ={};jH(OZ,{useWebApp:()=>df,usePieMittAgentTools:()=>RH,usePieEmit:()=>CU,useOpenAIWebRTC:()=>Yf,useMaxWebApp:()=>vf,useAjaxSubmit:()=>OH,unregisterComponent:()=>FU,submitGlobalForm:()=>SH,registry:()=>g,registerPieComponent:()=>C,registerMultipleComponents:()=>KU,pieName:()=>LH,hasComponent:()=>SU,getRegistrySize:()=>AU,getRegistryEntry:()=>t,getMittAgentTools:()=>$U,getComponentMeta:()=>LU,getAllRegisteredComponents:()=>MU,cn:()=>FH,UnionCard:()=>uU,UIRendererContext:()=>x,UILoading:()=>Ff,UI:()=>w,SessionStorageCard:()=>tU,SequenceCard:()=>kU,SecureStorageCard:()=>ZH,PieTelegramRoot:()=>GH,PieRoot:()=>XH,PieMaxRoot:()=>WH,PieCard:()=>R,PieBaseRoot:()=>qH,PIEBREAK:()=>Cf,IOEventsCard:()=>sU,HiddenCard:()=>cU,HTMLEmbedCard:()=>vU,DeviceStorageCard:()=>eU,CloudStorageCard:()=>UH,BoxCard:()=>TH,AutoRedirectCard:()=>rU,AjaxGroupCard:()=>DH});module.exports=kH(OZ);var u=require("react");var Of=require("react"),d=Of.createContext(null),s=()=>{let f=Of.useContext(d);if(!f)throw new Error("usePieConfig must be used within PieConfigProvider");return f},b=()=>{let{apiServer:f}=s();return f},_f=b,v=()=>{let{centrifugeServer:f}=s();return f};var E=()=>{let{enableRenderingLog:f}=s();return f},XU=E,IU=()=>{let{pageProcessor:f}=s();return f};var Cf="__piedemo__";var qU=require("react"),lf=require("centrifuge"),GU=new Map,p=(f,U)=>{if(!U)return null;let Z=`${f}::${U}`,H=GU.get(Z);if(H)return H;async function z(){let D=await fetch(f+"api/centrifuge/gen_token");if(!D.ok){if(D.status===403)throw new lf.Centrifuge.UnauthorizedError("Backend is not answering");throw new Error(`Unexpected status code ${D.status}`)}return(await D.json()).token}let T=new lf.Centrifuge(U,{getToken:z});return GU.set(Z,T),T},xH=qU.createContext(null),m=xH;var WU=require("socket.io-client"),QU=require("react"),BU=new Map,c=(f)=>{let U=BU.get(f);if(U)return U;let Z=WU.io(f,{autoConnect:!1,transports:["websocket"]});return BU.set(f,Z),Z},uH=QU.createContext(null),k=uH;var OU=YU(require("mitt")),i=require("react"),rf=null;function j(){if(!rf)rf=OU.default();return rf}var _U=i.createContext(null);function CU(f){let U=i.useContext(_U);return i.useCallback((Z,H)=>{(U??j()).emit(`pie${Z}_${f}`,H)},[f,U])}var N=_U;var dH=({card:f,data:U,children:Z,useSocketioSupport:H=!1,useCentrifugeSupport:z=!1,useMittSupport:T=!1,centrifugeChannel:D=void 0,methods:V=void 0})=>{let $=XU(),P=u.useRef(V);if(P.current=V,$)console.log("[PieCard] Rendering card:",f),console.log("[PieCard] Card data:",U),console.log("[PieCard] Component name:",U?.name),console.log("[PieCard] Real-time support:",{socketio:H,centrifuge:z,mitt:T,centrifugeChannel:D}),console.log("[PieCard] Methods:",V?Object.keys(V):"none"),console.log("[PieCard] Has children:",!!Z);let G=u.useContext(k),B=u.useContext(m),W=u.useContext(N);if(u.useEffect(()=>{if(!G||!H||!P.current||!U.name){if($&&H)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!G,useSocketioSupport:H,hasMethods:!!P.current,hasDataName:!!U?.name});return}let Y=Object.keys(P.current??{}).map((I)=>{let J=`pie${I}_${U.name}`;if($)console.log(`[PieCard] Socket.IO registering event: ${J}`);let Q=(q)=>{P.current?.[I]?.(q)};return G.on(J,Q),[J,Q]});return()=>{Y.forEach(([I,J])=>{if($)console.log(`[PieCard] Socket.IO unregistering event: ${I}`);G.off(I,J)})}},[G,U.name,H]),u.useEffect(()=>{if(!B||!z||!D||!U.name){if($&&z)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!B,useCentrifugeSupport:z,hasCentrifugeChannel:!!D,hasMethods:!!P.current,hasDataName:!!U?.name});return}let Y=Object.keys(P.current??{}).map((I)=>{let J=`pie${I}_${U.name}_${D}`;if($)console.log(`[PieCard] Centrifuge subscribing to channel: ${J}`);let Q=B.newSubscription(J);return Q.on("publication",(q)=>{if($)console.log(`[PieCard] Centrifuge received data on ${J}:`,q.data);P.current?.[I]?.(q.data)}),Q.subscribe(),Q});return()=>{Y.forEach((I)=>{if($)console.log("[PieCard] Centrifuge unsubscribing from channel");I.unsubscribe(),B.removeSubscription(I)})}},[B,D,U.name,z]),u.useEffect(()=>{if(!W||!T||!U.name){if($&&T)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!W,useMittSupport:T,hasMethods:!!P.current,hasDataName:!!U?.name});return}let X=Object.keys(P.current??{}),Y={};return X.forEach((I)=>{let J=`pie${I}_${U.name}`,Q=(q)=>{if($)console.log(`[PieCard] Mitt registering event: ${J}`);P.current?.[I]?.(q)};Y[J]=Q,W.on(J,Q)}),()=>{Object.entries(Y).forEach(([I,J])=>{if($)console.log(`[PieCard] Mitt unregistering event: ${I}`);W.off(I,J)})}},[W,U.name,T]),$)console.log("[PieCard] Rendering complete, returning children");return Z},R=dH;var RU=require("react"),nf=new Map;function wU(f,U){return RU.lazy(()=>{if(nf.has(U))return nf.get(U);let Z=f().then((H)=>H);return nf.set(U,Z),Z})}var g=new Map,bH=(f)=>{if(!f.name)throw new Error("Component registration requires a name");if(!f.component&&!f.loader)throw new Error(`Component "${f.name}" requires component or loader`);let U={name:f.name,component:f.component,loader:f.loader,metadata:f.metadata,fallback:f.fallback,isLazy:!1};if(!U.component&&U.loader)U.component=wU(U.loader,f.name),U.loader=void 0,U.isLazy=!0;return U};function C(f){let U=bH(f);return g.set(U.name,U),U.component}var KU=(f)=>{f.forEach((U)=>C(U))},FU=(f)=>{g.delete(f)},SU=(f)=>{return g.has(f)},LU=(f)=>{return g.get(f)?.metadata},t=(f)=>{return g.get(f)},MU=()=>{return Array.from(g.keys())},AU=()=>{return g.size};var a=require("react");var NU=require("react"),Rf=require("react/jsx-runtime"),gH=NU.createContext(Rf.jsx(Rf.Fragment,{})),L=gH;var wf=require("react/jsx-runtime");function vH({uiConfig:f,setUiAjaxConfiguration:U}){let Z=a.useContext(L),H=E();if(H)console.log("[UI] Rendering component:",f.card),console.log("[UI] Component data:",f.data),console.log("[UI] Component content:",f.content),console.log("[UI] Has setUiAjaxConfiguration:",!!U);let z=t(f.card);if(!z?.component){if(H)console.warn(`[UI] Component not found in registry: ${f.card}`),console.log("[UI] Returning fallback component");return Z}if(H)console.log("[UI] Found component in registry:",{name:z.name,isLazy:z.isLazy,hasMetadata:!!z.metadata});let T=z.component,D=wf.jsx(T,{data:f.data,content:f.content,setUiAjaxConfiguration:U});if(z.isLazy){if(H)console.log("[UI] Rendering lazy component with Suspense:",z.name);return wf.jsx(a.Suspense,{fallback:z.fallback?wf.jsx(z.fallback,{}):Z,children:D},`${z.name}`)}if(H)console.log("[UI] Rendering component directly:",z.name);return D}var w=a.memo(vH);var Kf=require("react");var yU=require("react"),pH=yU.createContext(null),x=pH;var Jf=require("react/jsx-runtime");function EU({uiConfig:f,setUiAjaxConfiguration:U}){let Z=Kf.useContext(L),H=E();if(H)console.log("[UILoading] Rendering fallback for:",f.card),console.log("[UILoading] Component data:",f.data),console.log("[UILoading] Component content:",f.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!U);let z=t(f.card);if(!z?.component){if(H)console.warn(`[UILoading] Component not found in registry: ${f.card}`),console.log("[UILoading] Returning fallback component");return Z}if(H)console.log("[UILoading] Found component in registry:",{name:z.name,isLazy:z.isLazy,hasMetadata:!!z.metadata,hasFallback:!!z.fallback});if(z.fallback){if(H)console.log("[UILoading] Rendering fallback for:",z.name);let V=z.fallback;return Jf.jsx(V,{})}if(H)console.log("[UILoading] No fallback, rendering full component:",z.name);let T=z.component,D=Jf.jsx(x.Provider,{value:EU,children:Jf.jsx(T,{data:f.data,content:f.content,setUiAjaxConfiguration:U})});if(z.isLazy)return Jf.jsx(Kf.Suspense,{fallback:Z,children:D},`${z.name}`);return D}var Ff=EU;var oU=require("react");var Sf=require("react/jsx-runtime"),cH=({data:f,content:U,setUiAjaxConfiguration:Z})=>{let{name:H,sx:z}=f,T=oU.useContext(x)??w;return Sf.jsx(R,{card:H,data:f,children:Sf.jsx("div",{style:z,id:H,children:U.map((D,V)=>{return Sf.jsx(T,{uiConfig:D,setUiAjaxConfiguration:Z},`children-${V}`)})})})},mU=cH;var kU=C({name:"SequenceCard",component:mU,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});var jU=require("react");var sf=require("react/jsx-runtime"),hH=({data:f,content:U,setUiAjaxConfiguration:Z})=>{let{name:H}=f,z=jU.useContext(x)??w;return sf.jsx(R,{card:H,data:f,children:U.map((T,D)=>{return sf.jsx(z,{uiConfig:T,setUiAjaxConfiguration:Z},`children-${D}`)})})},xU=hH;var uU=C({name:"UnionCard",component:xU,metadata:{author:"Swarm.ing",description:"Renders one of many components"}});var Lf=require("react"),dU=YU(require("html-react-parser"));var o=require("react");function lH(){let f=new AudioContext,U=f.createOscillator(),Z=U.connect(f.createMediaStreamDestination());U.start();let H=Z.stream.getAudioTracks()[0];return H.enabled=!1,H}function Yf(f=null,U){let[Z,H]=o.useState(!1),z=o.useRef(null),T=o.useRef(null),D=o.useRef(null),V=o.useCallback(async(B,W=!0)=>{if(z.current)$();let X=new RTCPeerConnection;if(X.onconnectionstatechange=()=>{if(X.connectionState==="connected")H(!0);else if(["disconnected","failed","closed"].includes(X.connectionState))H(!1)},X.ontrack=(_)=>{if(f)f.srcObject=_.streams[0]},W){let _=await navigator.mediaDevices.getUserMedia({audio:!0});X.addTrack(_.getTracks()[0],_)}else{let _=lH();X.addTrack(_)}let Y=X.createDataChannel("oai-events");T.current=Y,D.current=new Promise((_)=>{Y.addEventListener("open",()=>{_()})});let I=await X.createOffer();await X.setLocalDescription(I);let O=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:I.sdp,headers:{Authorization:`Bearer ${B}`,"Content-Type":"application/sdp"}})).text();await X.setRemoteDescription({type:"answer",sdp:O}),z.current=X,await D.current},[f]),$=o.useCallback(()=>{let B=T.current;if(B)B.close();z.current?.getSenders()?.forEach((W)=>W.track?.stop()),z.current?.close(),H(!1),z.current=null,T.current=null,D.current=null},[f]),P=o.useCallback((B)=>{let W=T.current;if(!W){console.error("Data channel is not ready",B);return}let X=new Date().toLocaleTimeString();if(B.event_id=B.event_id||crypto.randomUUID(),W.send(JSON.stringify(B)),!B.timestamp)B.timestamp=X;U?.(B)},[U,f]),G=o.useCallback((B)=>{if(!T.current){console.error("Data channel is not ready");return}let X=()=>{P({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:B}]}}),P({type:"response.create"})};if(D.current)D.current.then(X);else X()},[U,f]);return o.useEffect(()=>{let B=T.current;if(!B)return;let W=(X)=>{let Y=JSON.parse(X.data);if(!Y.timestamp)Y.timestamp=new Date().toLocaleTimeString();U?.(Y)};return B.addEventListener("message",W),()=>{B.removeEventListener("message",W)}},[U,f]),{isSessionActive:Z,startSession:V,stopSession:$,sendTextMessage:G}}var gU=require("react/jsx-runtime"),rH=({data:f})=>{let{html:U,useSocketioSupport:Z,useCentrifugeSupport:H,useMittSupport:z,centrifugeChannel:T}=f,[D,V]=Lf.useState(U),{isSessionActive:$,startSession:P,sendTextMessage:G}=Yf(null,(Y)=>{if(console.log(Y.type,Y.type==="response.output_text.delta"&&Y.delta),Y.type==="response.output_text.delta"&&Y.delta)V((I)=>I+Y.delta)});return Lf.useEffect(()=>{V(U)},[U]),gU.jsx(R,{card:"HTMLEmbedCard",data:f,methods:{update:(Y)=>{V(Y.value)},generateUsingAI:async(Y)=>{try{if(!$&&Y.token)await P(Y.token,!1);G(Y.prompt)}catch(I){console.error("Failed to generate using AI",I)}},initializeAI:async(Y)=>{if(!$&&Y.token)await P(Y.token,!1)}},useCentrifugeSupport:H,useSocketioSupport:Z,useMittSupport:z,centrifugeChannel:T,children:dU.default(D)})},bU=rH;var vU=C({name:"HTMLEmbedCard",component:bU,metadata:{author:"Swarm.ing"}});var Mf=require("react");var tf=require("react/jsx-runtime"),nH=({data:f})=>{let{name:U,value:Z,useSocketioSupport:H,useCentrifugeSupport:z,useMittSupport:T,centrifugeChannel:D}=f,[V,$]=Mf.useState(Z);return Mf.useEffect(()=>{$(Z)},[Z]),tf.jsx(R,{card:"HiddenCard",data:f,useSocketioSupport:H,useCentrifugeSupport:z,useMittSupport:T,centrifugeChannel:D,methods:{update:({value:P})=>{$(P)}},children:tf.jsx("input",{type:"hidden",id:U,name:U,value:V})})},pU=nH;var cU=C({name:"HiddenCard",component:pU,metadata:{author:"Swarm.ing"}});var Xf=require("react");var hU=require("react"),sH=hU.createContext(void 0),y=sH;var Af=require("react/jsx-runtime"),iH=({data:f})=>{let{url:U}=f,Z=Xf.useContext(y),H=Xf.useContext(L);return Xf.useEffect(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(U))window.location.href=U;else Z?.(U)},[U,Z]),Af.jsx(Af.Fragment,{children:H})},lU=iH;var rU=C({name:"AutoRedirectCard",component:lU,metadata:{author:"Swarm.ing"}});var h=require("react-toastify"),Nf=require("react-toastify");var ff=require("react");var e=require("react/jsx-runtime"),tH={bounce:h.Bounce,slide:h.Slide,zoom:h.Zoom,flip:h.Flip},aH=(f)=>{let U={...f,type:f.alertType,transition:f.transition?tH[f.transition]:void 0,position:f.position??"bottom-right",autoClose:f.autoClose??3000,style:{backgroundColor:"black",...f.sx}};Nf.toast(f.message,U)},eH=(f)=>{console.log("Log event",f)},fZ=(f)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let U=()=>{try{new window.Notification(f.title,{body:f.message??f.subtitle,icon:f.icon,silent:f.silent})}catch(H){console.error("[IOEventsCard] Failed to show notification",H)}},Z=window.Notification.permission;if(Z==="granted"){U();return}if(Z==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((H)=>{if(H==="granted")U()})},UZ=({data:f})=>{let{useCentrifugeSupport:U,useSocketioSupport:Z,useMittSupport:H,centrifugeChannel:z}=f,T=ff.useContext(y),D=ff.useRef(T);D.current=T;let V=ff.useMemo(()=>({alert:aH,log:eH,push:fZ,redirect:($)=>{if($.to){let P=$.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(P))window.location.href=P;else D.current?.(P)}else window.location.reload()},reload:($)=>{if($.to){let P=$.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(P))window.location.href=P;else D.current?.(P)}else window.location.reload()}}),[]);return e.jsx(e.Fragment,{children:e.jsx(R,{card:"IOEventsCard",data:f,useCentrifugeSupport:U,useSocketioSupport:Z,useMittSupport:H,centrifugeChannel:z,methods:V,children:e.jsx(Nf.ToastContainer,{})})})},nU=UZ;var sU=C({name:"IOEventsCard",component:nU,metadata:{author:"Swarm.ing"}});var If=require("react");var af=require("react/jsx-runtime"),HZ=({data:f})=>{let{name:U,key:Z,value:H,useSocketioSupport:z,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V}=f,[$,P]=If.useState(H);return If.useEffect(()=>{P(H)},[H]),If.useEffect(()=>{if(typeof window==="undefined")return;sessionStorage.setItem(Z,$)},[Z,$]),af.jsx(R,{card:"SessionStorageCard",data:f,useSocketioSupport:z,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V,methods:{update:({value:G})=>{P(G)},remove:()=>{sessionStorage.removeItem(Z),P("")}},children:af.jsx("input",{type:"hidden",id:U,name:U,value:$})})},iU=HZ;var tU=C({name:"SessionStorageCard",component:iU,metadata:{author:"PieData"}});var Gf=require("react");var ef=require("react/jsx-runtime"),ZZ=({data:f})=>{let{name:U,key:Z,value:H,useSocketioSupport:z,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V}=f,[$,P]=Gf.useState(H);return Gf.useEffect(()=>{P(H)},[H]),Gf.useEffect(()=>{if(typeof window==="undefined")return;localStorage.setItem(Z,$)},[Z,$]),ef.jsx(R,{card:"DeviceStorageCard",data:f,useSocketioSupport:z,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V,methods:{update:({value:G})=>{P(G)},remove:()=>{localStorage.removeItem(Z),P("")}},children:ef.jsx("input",{type:"hidden",id:U,name:U,value:$})})},aU=ZZ;var eU=C({name:"DeviceStorageCard",component:aU,metadata:{author:"PieData"}});var qf=require("react");var fU=require("react/jsx-runtime"),zZ=({data:f})=>{let{name:U,key:Z,value:H,useSocketioSupport:z,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V}=f,[$,P]=qf.useState(H);return qf.useEffect(()=>{P(H)},[H]),qf.useEffect(()=>{if(typeof window==="undefined")return;let G=window.Telegram?.WebApp?.CloudStorage;if(!G)return;G.setItem(Z,$)},[Z,$]),fU.jsx(R,{card:"CloudStorageCard",data:f,useSocketioSupport:z,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V,methods:{update:({value:G})=>{P(G)},remove:()=>{let G=window.Telegram?.WebApp?.CloudStorage;if(G)G.removeItem(Z);P("")}},children:fU.jsx("input",{type:"hidden",id:U,name:U,value:$})})},fH=zZ;var UH=C({name:"CloudStorageCard",component:fH,metadata:{author:"PieData"}});var Bf=require("react");var UU=require("react/jsx-runtime"),DZ=({data:f})=>{let{name:U,key:Z,value:H,useSocketioSupport:z,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V}=f,[$,P]=Bf.useState(H);return Bf.useEffect(()=>{P(H)},[H]),Bf.useEffect(()=>{if(typeof window==="undefined")return;let G=window.Telegram?.WebApp?.SecureStorage;if(!G)return;G.setItem(Z,$)},[Z,$]),UU.jsx(R,{card:"SecureStorageCard",data:f,useSocketioSupport:z,useCentrifugeSupport:T,useMittSupport:D,centrifugeChannel:V,methods:{update:({value:G})=>{P(G)},remove:()=>{let G=window.Telegram?.WebApp?.SecureStorage;if(G)G.removeItem(Z);P("")}},children:UU.jsx("input",{type:"hidden",id:U,name:U,value:$})})},HH=DZ;var ZH=C({name:"SecureStorageCard",component:HH,metadata:{author:"PieData"}});var M=require("react");var HU=require("react/jsx-runtime"),$Z=({data:f,content:U})=>{let{useLoader:Z,noReturn:H,returnType:z,useSocketioSupport:T,useCentrifugeSupport:D,useMittSupport:V,centrifugeChannel:$}=f,P=M.useContext(L),G=M.useContext(x)??w,[B,W]=M.useState(!1),[X,Y]=M.useState(null),I=M.useRef(U),J=M.useContext(N),Q=M.useCallback((_)=>{if(_===null)W(!0);else if(W(!1),!H)I.current=_;if(!H)Y(_)},[H]),q=M.useCallback((_)=>{I.current=_.content,Y(_.content)},[]),O=M.useCallback((_)=>{if(_===null)W(!0);else if(W(!1),!H)for(let Wf of _)J?.emit(Wf.name,Wf.data)},[H,J]);if(M.useEffect(()=>{Y(U),W(!1)},[U]),!X&&Z)return P;return HU.jsx(R,{card:"AjaxGroupCard",data:f,methods:{changeContent:q},useSocketioSupport:T,useCentrifugeSupport:D,useMittSupport:V,centrifugeChannel:$,children:HU.jsx(G,{uiConfig:X??I.current,setUiAjaxConfiguration:z==="events"?O:Q})})},zH=$Z;var DH=C({name:"AjaxGroupCard",component:zH,metadata:{author:"Swarm.ing",description:"Group card with AJAX support"}});var ZU=require("react");var yf=require("react/jsx-runtime"),TZ=({data:f,content:U,setUiAjaxConfiguration:Z})=>{let{name:H,url:z,sx:T}=f,D=ZU.useContext(y),V=ZU.useContext(x)??w;return yf.jsx(R,{card:H,data:f,children:yf.jsx("div",{style:T,id:H,onClick:(P)=>{if(z)if(P.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(z))window.location.href=z;else D?.(z)},children:yf.jsx(V,{setUiAjaxConfiguration:Z,uiConfig:U})})})},$H=TZ;var TH=C({name:"BoxCard",component:$H,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});var Hf=require("react"),Zf=require("@tanstack/react-query");var jf=require("react");var mf=require("react"),Ef=new Map,of=new Map;function kf(f,U){let Z=`${f}::${U}`,H=f?Ef.get(Z):void 0,[z,T]=mf.useState(H??null);return mf.useEffect(()=>{if(!f)return;if(Ef.has(Z)){T(Ef.get(Z));return}let D=of.get(Z);if(!D)D=fetch(f+`api/support/${U}`,{method:"GET"}).then(($)=>$.json()).then(($)=>{return Ef.set(Z,$),of.delete(Z),$}).catch(($)=>{throw of.delete(Z),$}),of.set(Z,D);let V=!1;return D.then(($)=>{if(!V)T($)}).catch(()=>{}),()=>{V=!0}},[f,U,Z]),z}var zU=null,PH=null;function VH(){PH?.()}function DU(){if(typeof window==="undefined")return Promise.resolve();if(typeof window.sid!=="undefined")return Promise.resolve();if(!zU)zU=new Promise((f)=>{PH=()=>{f()}});return zU}var PZ=({children:f})=>{let U=jf.useContext(k),Z=_f(),H=kf(Z,"socketIO"),z=(T)=>{if(typeof window!=="undefined")window.sid=T.sid,VH(),console.log(`SocketIO initialized: ${window.sid}`)};return jf.useEffect(()=>{if(!U)return;let T=()=>{console.log("SocketIO connected")},D=(V)=>{console.log(`SocketIO disconnected: ${V}`),U.connect()};if(H)U.on("pieinit",z),U.on("connect",T),U.on("disconnect",D),U.connect();return()=>{if(H)U.off("pieinit",z),U.off("connect",T),U.off("disconnect",D),U.disconnect()}},[U,H]),f},l=PZ;var xf=require("react");var VZ=({children:f})=>{let U=xf.useContext(m),Z=_f(),H=kf(Z,"centrifuge");return xf.useEffect(()=>{if(!U)return;let z=()=>{console.log("Centrifuge connected")},T=(D)=>{console.log("Centrifuge disconnected:",D)};if(H)U.on("connected",z),U.on("disconnected",T),U.connect();return()=>{if(H)U.disconnect()}},[U,H]),f},r=VZ;var YH=require("axios-date-transformer");var JH=require("react/jsx-runtime");function Uf(f,U,Z){if(!U)return Z;let H=f.replace(/^\//,""),z=U[H];if(!z)return Z;return JH.jsx(Ff,{uiConfig:z})}var K=require("react/jsx-runtime"),JZ=({location:f,fallback:U,piecache:Z,onError:H,queryOptions:z,disableGlobalForm:T})=>{let D=b(),V=v(),$=E(),P=Hf.useMemo(()=>YH.createAxiosDateTransformer({baseURL:D||""}),[D]),G=Hf.useMemo(()=>j(),[]),B=Hf.useMemo(()=>D?c(D):null,[D]),W=Hf.useMemo(()=>D?p(D,V):null,[D,V]),{data:X,isLoading:Y,error:I}=Zf.useQuery({queryKey:["uiConfig",f.pathname+f.search,D],enabled:!!D,queryFn:async()=>{let Q=new URLSearchParams(f.search);Q.set("__pieroot","web");let q="/api/content"+f.pathname+"?"+Q.toString();if($)console.log("[PieRoot] Fetching UI configuration from:",q);let O=await P.get(q,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if($)console.log("[PieRoot] Received UI configuration:",O.data);return O.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Q)=>Math.min(1000*2**Q,30000),...z}),J=Uf(f.pathname,Z,U);if(!D)return J??null;if($)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",D),console.log("[PieRoot] CENTRIFUGE_SERVER:",V),console.log("[PieRoot] Fallback provided:",!!U),console.log("[PieRoot] Piecache provided:",!!Z);if(I){if($)console.error("[PieRoot] Error fetching UI configuration:",I),console.error("[PieRoot] Error details:",{message:I.message,status:I.response?.status,data:I.response?.data});return H?.(),J}if(Y||!X){if($)console.log("[PieRoot] Loading state:",{isLoading:Y,hasUiConfiguration:!!X});return J}if($)console.log("[PieRoot] UI configuration loaded successfully:",X),console.log("[PieRoot] Rendering UI with configuration");return K.jsx(N.Provider,{value:G,children:K.jsx(k.Provider,{value:B,children:K.jsx(m.Provider,{value:W,children:K.jsx(L.Provider,{value:U??K.jsx(K.Fragment,{}),children:K.jsx(l,{children:K.jsx(r,{children:T?K.jsx(w,{uiConfig:X}):K.jsx("form",{id:"piedata_global_form",action:D+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:K.jsx(w,{uiConfig:X})})})})})})})})},YZ=(f)=>{let U=Hf.useMemo(()=>new Zf.QueryClient,[]);return K.jsx(y.Provider,{value:f.onNavigate,children:K.jsx(d.Provider,{value:f.config,children:K.jsx(Zf.QueryClientProvider,{client:U,children:K.jsx(JZ,{...f})})})})},XH=YZ;var zf=require("react"),Df=require("@tanstack/react-query");var IH=require("axios-date-transformer");var uf=require("react");var df=({onError:f}={})=>{let[U,Z]=uf.useState(null),H=IU();return uf.useEffect(()=>{if(typeof window==="undefined")return;let z=window.Telegram?.WebApp;if(!z)return;try{z.ready?.()}catch(T){f?.()}if(H==="telegram_expanded"&&(z.platform==="ios"||z.platform==="android"))z.expand();Z(z)},[]),U};var F=require("react/jsx-runtime"),XZ=({location:f,fallback:U,piecache:Z,onError:H,queryOptions:z,disableGlobalForm:T})=>{let D=b(),V=v(),$=E(),P=zf.useMemo(()=>IH.createAxiosDateTransformer({baseURL:D}),[D]),G=zf.useMemo(()=>j(),[]),B=zf.useMemo(()=>D?c(D):null,[D]),W=zf.useMemo(()=>D?p(D,V):null,[D,V]),X=df({onError:H}),{data:Y,isLoading:I,error:J}=Df.useQuery({queryKey:["uiConfig",f.pathname+f.search,X?.initData],enabled:!!X?.initData,queryFn:async()=>{let q=new URLSearchParams(f.search);if(q.set("__pieroot","telegram"),X?.initData)q.set("initData",X.initData);let O="/api/content"+f.pathname+"?"+q.toString();if($)console.log("[PieRoot] Fetching UI configuration from:",O);let _=await P.get(O,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if($)console.log("[PieRoot] Received UI configuration:",_.data);return _.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(q)=>Math.min(1000*2**q,30000),...z}),Q=Uf(f.pathname,Z,U);if(!D)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(J&&$)return console.error("[PieRoot] Error fetching UI configuration:",J),console.error("[PieRoot] Error details:",{message:J.message,status:J.response?.status,data:J.response?.data}),H?.(),Q;if(I||!Y){if($)console.log("[PieRoot] Loading state:",{isLoading:I,hasUiConfiguration:!!Y});return Q}if($)console.log("[PieRoot] UI configuration loaded successfully:",Y),console.log("[PieRoot] Rendering UI with configuration");return F.jsx(N.Provider,{value:G,children:F.jsx(k.Provider,{value:B,children:F.jsx(m.Provider,{value:W,children:F.jsx(L.Provider,{value:U??F.jsx(F.Fragment,{}),children:F.jsx(l,{children:F.jsx(r,{children:T?F.jsx(w,{uiConfig:Y}):F.jsx("form",{id:"piedata_global_form",action:D+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:F.jsx(w,{uiConfig:Y})})})})})})})})},IZ=(f)=>{let U=zf.useMemo(()=>new Df.QueryClient,[]);return F.jsx(y.Provider,{value:f.onNavigate,children:F.jsx(d.Provider,{value:f.config,children:F.jsx(Df.QueryClientProvider,{client:U,children:F.jsx(XZ,{...f})})})})},GH=IZ;var $f=require("react"),bf=require("@tanstack/react-query");var A=require("react/jsx-runtime"),GZ=({location:f,fallback:U,children:Z,disableGlobalForm:H})=>{let z=b(),T=v(),D=E(),V=$f.useMemo(()=>j(),[]),$=$f.useMemo(()=>z?c(z):null,[z]),P=$f.useMemo(()=>z?p(z,T):null,[z,T]);if(D)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",z),console.log("[PieRoot] CENTRIFUGE_SERVER:",T),console.log("[PieRoot] Fallback provided:",!!U);return A.jsx(N.Provider,{value:V,children:A.jsx(k.Provider,{value:$,children:A.jsx(m.Provider,{value:P,children:A.jsx(L.Provider,{value:U??A.jsx(A.Fragment,{}),children:A.jsx(l,{children:A.jsx(r,{children:H?Z:A.jsx("form",{id:"piedata_global_form",action:z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:Z})})})})})})})},qZ=(f)=>{let[U]=$f.useState(()=>new bf.QueryClient);return A.jsx(y.Provider,{value:f.onNavigate,children:A.jsx(d.Provider,{value:f.config,children:A.jsx(bf.QueryClientProvider,{client:U,children:A.jsx(GZ,{...f})})})})},qH=qZ;var Tf=require("react"),Pf=require("@tanstack/react-query");var BH=require("axios-date-transformer");var gf=require("react"),vf=()=>{let[f,U]=gf.useState(null);return gf.useEffect(()=>{if(typeof window==="undefined")return;let Z=window.WebApp;if(!Z)return;Z.ready(),U(Z)},[]),f};var S=require("react/jsx-runtime"),BZ=({location:f,fallback:U,piecache:Z,onError:H,queryOptions:z,disableGlobalForm:T})=>{let D=b(),V=v(),$=E(),P=Tf.useMemo(()=>BH.createAxiosDateTransformer({baseURL:D}),[D]),G=Tf.useMemo(()=>j(),[]),B=Tf.useMemo(()=>D?c(D):null,[D]),W=Tf.useMemo(()=>D?p(D,V):null,[D,V]),X=vf(),{data:Y,isLoading:I,error:J}=Pf.useQuery({queryKey:["uiConfig",f.pathname+f.search,X?.initData],queryFn:async()=>{let q=new URLSearchParams(f.search);if(q.set("__pieroot","max"),X?.initData)q.set("initData",X.initData);let O="/api/content"+f.pathname+"?"+q.toString();if($)console.log("[PieRoot] Fetching UI configuration from:",O);let _=await P.get(O,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if($)console.log("[PieRoot] Received UI configuration:",_.data);return _.data},enabled:!!X?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(q)=>Math.min(1000*2**q,30000),...z}),Q=Uf(f.pathname,Z,U);if(!D)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(J&&$)return console.error("[PieRoot] Error fetching UI configuration:",J),console.error("[PieRoot] Error details:",{message:J.message,status:J.response?.status,data:J.response?.data}),H?.(),Q;if(I||!Y){if($)console.log("[PieRoot] Loading state:",{isLoading:I,hasUiConfiguration:!!Y});return Q}if($)console.log("[PieRoot] UI configuration loaded successfully:",Y),console.log("[PieRoot] Rendering UI with configuration");return S.jsx(N.Provider,{value:G,children:S.jsx(k.Provider,{value:B,children:S.jsx(m.Provider,{value:W,children:S.jsx(L.Provider,{value:U??S.jsx(S.Fragment,{}),children:S.jsx(l,{children:S.jsx(r,{children:T?S.jsx(w,{uiConfig:Y}):S.jsx("form",{id:"piedata_global_form",action:D+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:S.jsx(w,{uiConfig:Y})})})})})})})})},WZ=(f)=>{let U=Tf.useMemo(()=>new Pf.QueryClient,[]);return S.jsx(y.Provider,{value:f.onNavigate,children:S.jsx(d.Provider,{value:f.config,children:S.jsx(Pf.QueryClientProvider,{client:U,children:S.jsx(BZ,{...f})})})})},WH=WZ;var QH=require("react"),QZ=(f,U={},Z=[],H,z)=>{let T=z?.renderingLogEnabled??!1,D=z?.timeout,V=z?.retryPolicy,$=V?.maxRetries??0,P=V?.baseDelay??1000,G=V?.retryOn??[502,503,504];if(T)console.log("Registering AJAX: ",H,U,Z);return async(B={})=>{if(typeof window==="undefined"||typeof document==="undefined"){if(T)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}let W=z?.apiServer;if(!W){if(T)console.warn("AJAX skipped: apiServer is missing");return}if(!H||!f){if(T)console.warn("AJAX skipped: pathname or setUiAjaxConfiguration is missing");return}if(Z.includes("sid"))await DU();let X=new FormData;for(let[J,Q]of Object.entries({...U,...B}))X.append(J,Q);for(let J of Z)if(J==="sid"){if(!window.sid)throw new Error("SocketIO isn't initialized properly");X.append("sid",window.sid)}else{let Q=document.getElementsByName(J);if(!Q.length){if(T)console.warn(`No input found with name ${J}`);continue}let q=Q[0];if(q instanceof HTMLInputElement)if(q.type==="file"&&q.files)Array.from(q.files).forEach((O)=>X.append(J,O));else X.append(J,q.value);else if(q instanceof HTMLTextAreaElement)X.append(J,q.value)}let Y=W+"api/ajax_content"+H;f(null);let I;for(let J=0;J<=$;J++){if(J>0){let O=P*2**(J-1);if(T)console.log(`AJAX retry ${J}/${$} after ${O}ms`);await new Promise((_)=>setTimeout(_,O))}let Q=D!=null?new AbortController:null,q=Q&&setTimeout(()=>Q.abort(),D);try{let O=await fetch(Y,{method:"POST",body:X,signal:Q?.signal});if(q)clearTimeout(q);if(!O.ok&&G.includes(O.status)&&J<$){I=new Error(`HTTP ${O.status}`);continue}let Wf=(O.headers.get("content-type")||"").includes("application/json");if(!!O.body?.getReader&&!Wf){let Qf=O.body.getReader(),MH=new TextDecoder,n="";while(!0){let{done:cf,value:AH}=await Qf.read();if(cf)break;n+=MH.decode(AH,{stream:!0});let TU=n.split(`
|
|
3
|
-
`);n=
|
|
2
|
+
var uH=Object.create;var{getPrototypeOf:dH,defineProperty:If,getOwnPropertyNames:JU,getOwnPropertyDescriptor:bH}=Object,YU=Object.prototype.hasOwnProperty;var OU=(f,U,P)=>{P=f!=null?uH(dH(f)):{};let H=U||!f||!f.__esModule?If(P,"default",{value:f,enumerable:!0}):P;for(let D of JU(f))if(!YU.call(H,D))If(H,D,{get:()=>f[D],enumerable:!0});return H},CU=new WeakMap,gH=(f)=>{var U=CU.get(f),P;if(U)return U;if(U=If({},"__esModule",{value:!0}),f&&typeof f==="object"||typeof f==="function")JU(f).map((H)=>!YU.call(U,H)&&If(U,H,{get:()=>f[H],enumerable:!(P=bH(f,H))||P.enumerable}));return CU.set(f,U),U};var vH=(f,U)=>{for(var P in U)If(f,P,{get:U[P],enumerable:!0,configurable:!0,set:(H)=>U[P]=()=>H})};var FP={};vH(FP,{useWebApp:()=>gf,usePieMittAgentTools:()=>LH,usePieEmit:()=>KU,useOpenAIWebRTC:()=>Jf,useMaxWebApp:()=>cf,useAjaxSubmit:()=>SH,unregisterComponent:()=>LU,submitGlobalForm:()=>oH,registry:()=>g,registerPieComponent:()=>Q,registerMultipleComponents:()=>MU,readAjaxKey:()=>TU,pieName:()=>mH,hasComponent:()=>AU,getRegistrySize:()=>oU,getRegistryEntry:()=>a,getMittAgentTools:()=>VU,getComponentMeta:()=>NU,getAllRegisteredComponents:()=>yU,cn:()=>yH,UnionCard:()=>gU,UIRendererContext:()=>y,UILoading:()=>Ff,UI:()=>w,SessionStorageCard:()=>fH,SequenceCard:()=>uU,SecureStorageCard:()=>$H,PieTelegramRoot:()=>QH,PieRoot:()=>BH,PieMaxRoot:()=>wH,PieCard:()=>_,PieBaseRoot:()=>RH,PIEBREAK:()=>_f,OneOfCard:()=>YH,IOEventsCard:()=>aU,HiddenCard:()=>rU,HTMLEmbedCard:()=>hU,DeviceStorageCard:()=>HH,CloudStorageCard:()=>DH,BoxCard:()=>IH,AutoRedirectCard:()=>tU,AjaxGroupCard:()=>TH});module.exports=gH(FP);var u=require("react");var Qf=require("react"),d=Qf.createContext(null),i=()=>{let f=Qf.useContext(d);if(!f)throw new Error("usePieConfig must be used within PieConfigProvider");return f},b=()=>{let{apiServer:f}=i();return f},Rf=b,v=()=>{let{centrifugeServer:f}=i();return f};var m=()=>{let{enableRenderingLog:f}=i();return f},XU=m,GU=()=>{let{pageProcessor:f}=i();return f};var _f="__piedemo__";var BU=require("react"),nf=require("centrifuge"),qU=new Map,p=(f,U)=>{if(!U)return null;let P=`${f}::${U}`,H=qU.get(P);if(H)return H;async function D(){let Z=await fetch(f+"api/centrifuge/gen_token");if(!Z.ok){if(Z.status===403)throw new nf.Centrifuge.UnauthorizedError("Backend is not answering");throw new Error(`Unexpected status code ${Z.status}`)}return(await Z.json()).token}let $=new nf.Centrifuge(U,{getToken:D});return qU.set(P,$),$},pH=BU.createContext(null),k=pH;var QU=require("socket.io-client"),RU=require("react"),WU=new Map,c=(f)=>{let U=WU.get(f);if(U)return U;let P=QU.io(f,{autoConnect:!1,transports:["websocket"]});return WU.set(f,P),P},cH=RU.createContext(null),j=cH;var _U=OU(require("mitt")),t=require("react"),tf=null;function x(){if(!tf)tf=_U.default();return tf}var wU=t.createContext(null);function KU(f){let U=t.useContext(wU);return t.useCallback((P,H)=>{(U??x()).emit(`pie${P}_${f}`,H)},[f,U])}var N=wU;var s=require("react/jsx-runtime"),hH=({card:f,data:U,children:P,useSocketioSupport:H=!1,useCentrifugeSupport:D=!1,useMittSupport:$=!1,centrifugeChannel:Z=void 0,methods:V=void 0,stored:z=void 0})=>{let T=XU(),I=u.useRef(V);if(I.current=V,T)console.log("[PieCard] Rendering card:",f),console.log("[PieCard] Card data:",U),console.log("[PieCard] Component name:",U?.name),console.log("[PieCard] Real-time support:",{socketio:H,centrifuge:D,mitt:$,centrifugeChannel:Z}),console.log("[PieCard] Methods:",V?Object.keys(V):"none"),console.log("[PieCard] Has children:",!!P);let X=u.useContext(j),G=u.useContext(k),J=u.useContext(N);if(u.useEffect(()=>{if(!X||!H||!I.current||!U.name){if(T&&H)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!X,useSocketioSupport:H,hasMethods:!!I.current,hasDataName:!!U?.name});return}let q=Object.keys(I.current??{}).map((C)=>{let O=`pie${C}_${U.name}`;if(T)console.log(`[PieCard] Socket.IO registering event: ${O}`);let W=(B)=>{I.current?.[C]?.(B)};return X.on(O,W),[O,W]});return()=>{q.forEach(([C,O])=>{if(T)console.log(`[PieCard] Socket.IO unregistering event: ${C}`);X.off(C,O)})}},[X,U.name,H]),u.useEffect(()=>{if(!G||!D||!Z||!U.name){if(T&&D)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!G,useCentrifugeSupport:D,hasCentrifugeChannel:!!Z,hasMethods:!!I.current,hasDataName:!!U?.name});return}let q=Object.keys(I.current??{}).map((C)=>{let O=`pie${C}_${U.name}_${Z}`;if(T)console.log(`[PieCard] Centrifuge subscribing to channel: ${O}`);let W=G.newSubscription(O);return W.on("publication",(B)=>{if(T)console.log(`[PieCard] Centrifuge received data on ${O}:`,B.data);I.current?.[C]?.(B.data)}),W.subscribe(),W});return()=>{q.forEach((C)=>{if(T)console.log("[PieCard] Centrifuge unsubscribing from channel");C.unsubscribe(),G.removeSubscription(C)})}},[G,Z,U.name,D]),u.useEffect(()=>{if(!J||!$||!U.name){if(T&&$)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!J,useMittSupport:$,hasMethods:!!I.current,hasDataName:!!U?.name});return}let Y=Object.keys(I.current??{}),q={};return Y.forEach((C)=>{let O=`pie${C}_${U.name}`,W=(B)=>{if(T)console.log(`[PieCard] Mitt registering event: ${O}`);I.current?.[C]?.(B)};q[O]=W,J.on(O,W)}),()=>{Object.entries(q).forEach(([C,O])=>{if(T)console.log(`[PieCard] Mitt unregistering event: ${C}`);J.off(C,O)})}},[J,U.name,$]),T)console.log("[PieCard] Rendering complete, returning children");if(z!==void 0)return s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"hidden",name:U.name,value:JSON.stringify(z)}),P]});return P},_=hH;var SU=require("react"),sf=new Map;function FU(f,U){return SU.lazy(()=>{if(sf.has(U))return sf.get(U);let P=f().then((H)=>H);return sf.set(U,P),P})}var g=new Map,lH=(f)=>{if(!f.name)throw new Error("Component registration requires a name");if(!f.component&&!f.loader)throw new Error(`Component "${f.name}" requires component or loader`);let U={name:f.name,component:f.component,loader:f.loader,metadata:f.metadata,fallback:f.fallback,isLazy:!1};if(!U.component&&U.loader)U.component=FU(U.loader,f.name),U.loader=void 0,U.isLazy=!0;return U};function Q(f){let U=lH(f);return g.set(U.name,U),U.component}var MU=(f)=>{f.forEach((U)=>Q(U))},LU=(f)=>{g.delete(f)},AU=(f)=>{return g.has(f)},NU=(f)=>{return g.get(f)?.metadata},a=(f)=>{return g.get(f)},yU=()=>{return Array.from(g.keys())},oU=()=>{return g.size};var e=require("react");var mU=require("react"),wf=require("react/jsx-runtime"),rH=mU.createContext(wf.jsx(wf.Fragment,{})),M=rH;var Kf=require("react/jsx-runtime");function nH({uiConfig:f,setUiAjaxConfiguration:U}){let P=e.useContext(M),H=m();if(H)console.log("[UI] Rendering component:",f.card),console.log("[UI] Component data:",f.data),console.log("[UI] Component content:",f.content),console.log("[UI] Has setUiAjaxConfiguration:",!!U);let D=a(f.card);if(!D?.component){if(H)console.warn(`[UI] Component not found in registry: ${f.card}`),console.log("[UI] Returning fallback component");return P}if(H)console.log("[UI] Found component in registry:",{name:D.name,isLazy:D.isLazy,hasMetadata:!!D.metadata});let $=D.component,Z=Kf.jsx($,{data:f.data,content:f.content,setUiAjaxConfiguration:U});if(D.isLazy){if(H)console.log("[UI] Rendering lazy component with Suspense:",D.name);return Kf.jsx(e.Suspense,{fallback:D.fallback?Kf.jsx(D.fallback,{}):P,children:Z},`${D.name}`)}if(H)console.log("[UI] Rendering component directly:",D.name);return Z}var w=e.memo(nH);var Sf=require("react");var EU=require("react"),iH=EU.createContext(null),y=iH;var Cf=require("react/jsx-runtime");function kU({uiConfig:f,setUiAjaxConfiguration:U}){let P=Sf.useContext(M),H=m();if(H)console.log("[UILoading] Rendering fallback for:",f.card),console.log("[UILoading] Component data:",f.data),console.log("[UILoading] Component content:",f.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!U);let D=a(f.card);if(!D?.component){if(H)console.warn(`[UILoading] Component not found in registry: ${f.card}`),console.log("[UILoading] Returning fallback component");return P}if(H)console.log("[UILoading] Found component in registry:",{name:D.name,isLazy:D.isLazy,hasMetadata:!!D.metadata,hasFallback:!!D.fallback});if(D.fallback){if(H)console.log("[UILoading] Rendering fallback for:",D.name);let V=D.fallback;return Cf.jsx(V,{})}if(H)console.log("[UILoading] No fallback, rendering full component:",D.name);let $=D.component,Z=Cf.jsx(y.Provider,{value:kU,children:Cf.jsx($,{data:f.data,content:f.content,setUiAjaxConfiguration:U})});if(D.isLazy)return Cf.jsx(Sf.Suspense,{fallback:P,children:Z},`${D.name}`);return Z}var Ff=kU;var jU=require("react");var Mf=require("react/jsx-runtime"),tH=({data:f,content:U,setUiAjaxConfiguration:P})=>{let{name:H,sx:D}=f,$=jU.useContext(y)??w;return Mf.jsx(_,{card:H,data:f,children:Mf.jsx("div",{style:D,id:H,children:U.map((Z,V)=>{return Mf.jsx($,{uiConfig:Z,setUiAjaxConfiguration:P},`children-${V}`)})})})},xU=tH;var uU=Q({name:"SequenceCard",component:xU,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});var dU=require("react");var af=require("react/jsx-runtime"),sH=({data:f,content:U,setUiAjaxConfiguration:P})=>{let{name:H}=f,D=dU.useContext(y)??w;return af.jsx(_,{card:H,data:f,children:U.map(($,Z)=>{return af.jsx(D,{uiConfig:$,setUiAjaxConfiguration:P},`children-${Z}`)})})},bU=sH;var gU=Q({name:"UnionCard",component:bU,metadata:{author:"Swarm.ing",description:"Renders one of many components"}});var Lf=require("react"),vU=OU(require("html-react-parser"));var E=require("react");function aH(){let f=new AudioContext,U=f.createOscillator(),P=U.connect(f.createMediaStreamDestination());U.start();let H=P.stream.getAudioTracks()[0];return H.enabled=!1,H}function Jf(f=null,U){let[P,H]=E.useState(!1),D=E.useRef(null),$=E.useRef(null),Z=E.useRef(null),V=E.useCallback(async(X,G=!0)=>{if(D.current)z();let J=new RTCPeerConnection;if(J.onconnectionstatechange=()=>{if(J.connectionState==="connected")H(!0);else if(["disconnected","failed","closed"].includes(J.connectionState))H(!1)},J.ontrack=(R)=>{if(f)f.srcObject=R.streams[0]},G){let R=await navigator.mediaDevices.getUserMedia({audio:!0});J.addTrack(R.getTracks()[0],R)}else{let R=aH();J.addTrack(R)}let Y=J.createDataChannel("oai-events");$.current=Y,Z.current=new Promise((R)=>{Y.addEventListener("open",()=>{R()})});let q=await J.createOffer();await J.setLocalDescription(q);let B=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:q.sdp,headers:{Authorization:`Bearer ${X}`,"Content-Type":"application/sdp"}})).text();await J.setRemoteDescription({type:"answer",sdp:B}),D.current=J,await Z.current},[f]),z=E.useCallback(()=>{let X=$.current;if(X)X.close();D.current?.getSenders()?.forEach((G)=>G.track?.stop()),D.current?.close(),H(!1),D.current=null,$.current=null,Z.current=null},[f]),T=E.useCallback((X)=>{let G=$.current;if(!G){console.error("Data channel is not ready",X);return}let J=new Date().toLocaleTimeString();if(X.event_id=X.event_id||crypto.randomUUID(),G.send(JSON.stringify(X)),!X.timestamp)X.timestamp=J;U?.(X)},[U,f]),I=E.useCallback((X)=>{if(!$.current){console.error("Data channel is not ready");return}let J=()=>{T({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:X}]}}),T({type:"response.create"})};if(Z.current)Z.current.then(J);else J()},[U,f]);return E.useEffect(()=>{let X=$.current;if(!X)return;let G=(J)=>{let Y=JSON.parse(J.data);if(!Y.timestamp)Y.timestamp=new Date().toLocaleTimeString();U?.(Y)};return X.addEventListener("message",G),()=>{X.removeEventListener("message",G)}},[U,f]),{isSessionActive:P,startSession:V,stopSession:z,sendTextMessage:I}}var cU=require("react/jsx-runtime"),eH=({data:f})=>{let{html:U,useSocketioSupport:P,useCentrifugeSupport:H,useMittSupport:D,centrifugeChannel:$}=f,[Z,V]=Lf.useState(U),{isSessionActive:z,startSession:T,sendTextMessage:I}=Jf(null,(Y)=>{if(console.log(Y.type,Y.type==="response.output_text.delta"&&Y.delta),Y.type==="response.output_text.delta"&&Y.delta)V((q)=>q+Y.delta)});return Lf.useEffect(()=>{V(U)},[U]),cU.jsx(_,{card:"HTMLEmbedCard",data:f,methods:{update:(Y)=>{V(Y.value)},generateUsingAI:async(Y)=>{try{if(!z&&Y.token)await T(Y.token,!1);I(Y.prompt)}catch(q){console.error("Failed to generate using AI",q)}},initializeAI:async(Y)=>{if(!z&&Y.token)await T(Y.token,!1)}},useCentrifugeSupport:H,useSocketioSupport:P,useMittSupport:D,centrifugeChannel:$,children:vU.default(Z)})},pU=eH;var hU=Q({name:"HTMLEmbedCard",component:pU,metadata:{author:"Swarm.ing"}});var Af=require("react");var ef=require("react/jsx-runtime"),fP=({data:f})=>{let{name:U,value:P,useSocketioSupport:H,useCentrifugeSupport:D,useMittSupport:$,centrifugeChannel:Z}=f,[V,z]=Af.useState(P);return Af.useEffect(()=>{z(P)},[P]),ef.jsx(_,{card:"HiddenCard",data:f,useSocketioSupport:H,useCentrifugeSupport:D,useMittSupport:$,centrifugeChannel:Z,methods:{update:({value:T})=>{z(T)}},children:ef.jsx("input",{type:"hidden",id:U,name:U,value:V})})},lU=fP;var rU=Q({name:"HiddenCard",component:lU,metadata:{author:"Swarm.ing"}});var Yf=require("react");var nU=require("react"),UP=nU.createContext(void 0),o=UP;var Nf=require("react/jsx-runtime"),HP=({data:f})=>{let{url:U}=f,P=Yf.useContext(o),H=Yf.useContext(M);return Yf.useEffect(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(U))window.location.href=U;else P?.(U)},[U,P]),Nf.jsx(Nf.Fragment,{children:H})},iU=HP;var tU=Q({name:"AutoRedirectCard",component:iU,metadata:{author:"Swarm.ing"}});var h=require("react-toastify"),yf=require("react-toastify");var Uf=require("react");var ff=require("react/jsx-runtime"),PP={bounce:h.Bounce,slide:h.Slide,zoom:h.Zoom,flip:h.Flip},DP=(f)=>{let U={...f,type:f.alertType,transition:f.transition?PP[f.transition]:void 0,position:f.position??"bottom-right",autoClose:f.autoClose??3000,style:{backgroundColor:"black",...f.sx}};yf.toast(f.message,U)},ZP=(f)=>{console.log("Log event",f)},$P=(f)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let U=()=>{try{new window.Notification(f.title,{body:f.message??f.subtitle,icon:f.icon,silent:f.silent})}catch(H){console.error("[IOEventsCard] Failed to show notification",H)}},P=window.Notification.permission;if(P==="granted"){U();return}if(P==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((H)=>{if(H==="granted")U()})},zP=({data:f})=>{let{useCentrifugeSupport:U,useSocketioSupport:P,useMittSupport:H,centrifugeChannel:D}=f,$=Uf.useContext(o),Z=Uf.useRef($);Z.current=$;let V=Uf.useMemo(()=>({alert:DP,log:ZP,push:$P,redirect:(z)=>{if(z.to){let T=z.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(T))window.location.href=T;else Z.current?.(T)}else window.location.reload()},reload:(z)=>{if(z.to){let T=z.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(T))window.location.href=T;else Z.current?.(T)}else window.location.reload()}}),[]);return ff.jsx(ff.Fragment,{children:ff.jsx(_,{card:"IOEventsCard",data:f,useCentrifugeSupport:U,useSocketioSupport:P,useMittSupport:H,centrifugeChannel:D,methods:V,children:ff.jsx(yf.ToastContainer,{})})})},sU=zP;var aU=Q({name:"IOEventsCard",component:sU,metadata:{author:"Swarm.ing"}});var Of=require("react");var fU=require("react/jsx-runtime"),TP=({data:f})=>{let{name:U,key:P,value:H,useSocketioSupport:D,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V}=f,[z,T]=Of.useState(H);return Of.useEffect(()=>{T(H)},[H]),Of.useEffect(()=>{if(typeof window==="undefined")return;sessionStorage.setItem(P,z)},[P,z]),fU.jsx(_,{card:"SessionStorageCard",data:f,useSocketioSupport:D,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V,methods:{update:({value:I})=>{T(I)},remove:()=>{sessionStorage.removeItem(P),T("")}},children:fU.jsx("input",{type:"hidden",id:U,name:U,value:z})})},eU=TP;var fH=Q({name:"SessionStorageCard",component:eU,metadata:{author:"PieData"}});var Xf=require("react");var UU=require("react/jsx-runtime"),VP=({data:f})=>{let{name:U,key:P,value:H,useSocketioSupport:D,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V}=f,[z,T]=Xf.useState(H);return Xf.useEffect(()=>{T(H)},[H]),Xf.useEffect(()=>{if(typeof window==="undefined")return;localStorage.setItem(P,z)},[P,z]),UU.jsx(_,{card:"DeviceStorageCard",data:f,useSocketioSupport:D,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V,methods:{update:({value:I})=>{T(I)},remove:()=>{localStorage.removeItem(P),T("")}},children:UU.jsx("input",{type:"hidden",id:U,name:U,value:z})})},UH=VP;var HH=Q({name:"DeviceStorageCard",component:UH,metadata:{author:"PieData"}});var Gf=require("react");var HU=require("react/jsx-runtime"),IP=({data:f})=>{let{name:U,key:P,value:H,useSocketioSupport:D,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V}=f,[z,T]=Gf.useState(H);return Gf.useEffect(()=>{T(H)},[H]),Gf.useEffect(()=>{if(typeof window==="undefined")return;let I=window.Telegram?.WebApp?.CloudStorage;if(!I)return;I.setItem(P,z)},[P,z]),HU.jsx(_,{card:"CloudStorageCard",data:f,useSocketioSupport:D,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V,methods:{update:({value:I})=>{T(I)},remove:()=>{let I=window.Telegram?.WebApp?.CloudStorage;if(I)I.removeItem(P);T("")}},children:HU.jsx("input",{type:"hidden",id:U,name:U,value:z})})},PH=IP;var DH=Q({name:"CloudStorageCard",component:PH,metadata:{author:"PieData"}});var qf=require("react");var PU=require("react/jsx-runtime"),CP=({data:f})=>{let{name:U,key:P,value:H,useSocketioSupport:D,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V}=f,[z,T]=qf.useState(H);return qf.useEffect(()=>{T(H)},[H]),qf.useEffect(()=>{if(typeof window==="undefined")return;let I=window.Telegram?.WebApp?.SecureStorage;if(!I)return;I.setItem(P,z)},[P,z]),PU.jsx(_,{card:"SecureStorageCard",data:f,useSocketioSupport:D,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:V,methods:{update:({value:I})=>{T(I)},remove:()=>{let I=window.Telegram?.WebApp?.SecureStorage;if(I)I.removeItem(P);T("")}},children:PU.jsx("input",{type:"hidden",id:U,name:U,value:z})})},ZH=CP;var $H=Q({name:"SecureStorageCard",component:ZH,metadata:{author:"PieData"}});var L=require("react");var DU=require("react/jsx-runtime"),JP=({data:f,content:U})=>{let{useLoader:P,noReturn:H,returnType:D,useSocketioSupport:$,useCentrifugeSupport:Z,useMittSupport:V,centrifugeChannel:z}=f,T=L.useContext(M),I=L.useContext(y)??w,[X,G]=L.useState(!1),[J,Y]=L.useState(null),q=L.useRef(U),C=L.useContext(N),O=L.useCallback((R)=>{if(R===null)G(!0);else if(G(!1),!H)q.current=R;if(!H)Y(R)},[H]),W=L.useCallback((R)=>{q.current=R.content,Y(R.content)},[]),B=L.useCallback((R)=>{if(R===null)G(!0);else if(G(!1),!H)for(let Bf of R)C?.emit(Bf.name,Bf.data)},[H,C]);if(L.useEffect(()=>{Y(U),G(!1)},[U]),!J&&P)return T;return DU.jsx(_,{card:"AjaxGroupCard",data:f,methods:{changeContent:W},useSocketioSupport:$,useCentrifugeSupport:Z,useMittSupport:V,centrifugeChannel:z,children:DU.jsx(I,{uiConfig:J??q.current,setUiAjaxConfiguration:D==="events"?B:O})})},zH=JP;var TH=Q({name:"AjaxGroupCard",component:zH,metadata:{author:"Swarm.ing",description:"Group card with AJAX support"}});var ZU=require("react");var of=require("react/jsx-runtime"),YP=({data:f,content:U,setUiAjaxConfiguration:P})=>{let{name:H,url:D,sx:$}=f,Z=ZU.useContext(o),V=ZU.useContext(y)??w;return of.jsx(_,{card:H,data:f,children:of.jsx("div",{style:$,id:H,onClick:(T)=>{if(D)if(T.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(D))window.location.href=D;else Z?.(D)},children:of.jsx(V,{setUiAjaxConfiguration:P,uiConfig:U})})})},VH=YP;var IH=Q({name:"BoxCard",component:VH,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});var CH=require("react");var mf=require("react/jsx-runtime"),OP=({data:f,content:U,setUiAjaxConfiguration:P})=>{let{name:H,sx:D}=f,$=CH.useContext(y)??w;return mf.jsx(_,{card:H,data:f,children:mf.jsx("div",{style:D,id:H,children:U.map((Z,V)=>{return mf.jsx($,{uiConfig:Z,setUiAjaxConfiguration:P},`children-${V}`)})})})},JH=OP;var YH=Q({name:"OneOfCard",component:JH,metadata:{author:"Swarm.ing",description:"Different variants"}});var Pf=require("react"),Df=require("@tanstack/react-query");var uf=require("react");var jf=require("react"),Ef=new Map,kf=new Map;function xf(f,U){let P=`${f}::${U}`,H=f?Ef.get(P):void 0,[D,$]=jf.useState(H??null);return jf.useEffect(()=>{if(!f)return;if(Ef.has(P)){$(Ef.get(P));return}let Z=kf.get(P);if(!Z)Z=fetch(f+`api/support/${U}`,{method:"GET"}).then((z)=>z.json()).then((z)=>{return Ef.set(P,z),kf.delete(P),z}).catch((z)=>{throw kf.delete(P),z}),kf.set(P,Z);let V=!1;return Z.then((z)=>{if(!V)$(z)}).catch(()=>{}),()=>{V=!0}},[f,U,P]),D}var $U=null,OH=null;function XH(){OH?.()}function zU(){if(typeof window==="undefined")return Promise.resolve();if(typeof window.sid!=="undefined")return Promise.resolve();if(!$U)$U=new Promise((f)=>{OH=()=>{f()}});return $U}var XP=({children:f})=>{let U=uf.useContext(j),P=Rf(),H=xf(P,"socketIO"),D=($)=>{if(typeof window!=="undefined")window.sid=$.sid,XH(),console.log(`SocketIO initialized: ${window.sid}`)};return uf.useEffect(()=>{if(!U)return;let $=()=>{console.log("SocketIO connected")},Z=(V)=>{console.log(`SocketIO disconnected: ${V}`),U.connect()};if(H)U.on("pieinit",D),U.on("connect",$),U.on("disconnect",Z),U.connect();return()=>{if(H)U.off("pieinit",D),U.off("connect",$),U.off("disconnect",Z),U.disconnect()}},[U,H]),f},l=XP;var df=require("react");var GP=({children:f})=>{let U=df.useContext(k),P=Rf(),H=xf(P,"centrifuge");return df.useEffect(()=>{if(!U)return;let D=()=>{console.log("Centrifuge connected")},$=(Z)=>{console.log("Centrifuge disconnected:",Z)};if(H)U.on("connected",D),U.on("disconnected",$),U.connect();return()=>{if(H)U.disconnect()}},[U,H]),f},r=GP;var qH=require("axios-date-transformer");var GH=require("react/jsx-runtime");function Hf(f,U,P){if(!U)return P;let H=f.replace(/^\//,""),D=U[H];if(!D)return P;return GH.jsx(Ff,{uiConfig:D})}var K=require("react/jsx-runtime"),qP=({location:f,fallback:U,piecache:P,onError:H,queryOptions:D,disableGlobalForm:$})=>{let Z=b(),V=v(),z=m(),T=Pf.useMemo(()=>qH.createAxiosDateTransformer({baseURL:Z||""}),[Z]),I=Pf.useMemo(()=>x(),[]),X=Pf.useMemo(()=>Z?c(Z):null,[Z]),G=Pf.useMemo(()=>Z?p(Z,V):null,[Z,V]),{data:J,isLoading:Y,error:q}=Df.useQuery({queryKey:["uiConfig",f.pathname+f.search,Z],enabled:!!Z,queryFn:async()=>{let O=new URLSearchParams(f.search);O.set("__pieroot","web");let W="/api/content"+f.pathname+"?"+O.toString();if(z)console.log("[PieRoot] Fetching UI configuration from:",W);let B=await T.get(W,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(z)console.log("[PieRoot] Received UI configuration:",B.data);return B.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(O)=>Math.min(1000*2**O,30000),...D}),C=Hf(f.pathname,P,U);if(!Z)return C??null;if(z)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",Z),console.log("[PieRoot] CENTRIFUGE_SERVER:",V),console.log("[PieRoot] Fallback provided:",!!U),console.log("[PieRoot] Piecache provided:",!!P);if(q){if(z)console.error("[PieRoot] Error fetching UI configuration:",q),console.error("[PieRoot] Error details:",{message:q.message,status:q.response?.status,data:q.response?.data});return H?.(),C}if(Y||!J){if(z)console.log("[PieRoot] Loading state:",{isLoading:Y,hasUiConfiguration:!!J});return C}if(z)console.log("[PieRoot] UI configuration loaded successfully:",J),console.log("[PieRoot] Rendering UI with configuration");return K.jsx(N.Provider,{value:I,children:K.jsx(j.Provider,{value:X,children:K.jsx(k.Provider,{value:G,children:K.jsx(M.Provider,{value:U??K.jsx(K.Fragment,{}),children:K.jsx(l,{children:K.jsx(r,{children:$?K.jsx(w,{uiConfig:J}):K.jsx("form",{id:"piedata_global_form",action:Z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:K.jsx(w,{uiConfig:J})})})})})})})})},BP=(f)=>{let U=Pf.useMemo(()=>new Df.QueryClient,[]);return K.jsx(o.Provider,{value:f.onNavigate,children:K.jsx(d.Provider,{value:f.config,children:K.jsx(Df.QueryClientProvider,{client:U,children:K.jsx(qP,{...f})})})})},BH=BP;var Zf=require("react"),$f=require("@tanstack/react-query");var WH=require("axios-date-transformer");var bf=require("react");var gf=({onError:f}={})=>{let[U,P]=bf.useState(null),H=GU();return bf.useEffect(()=>{if(typeof window==="undefined")return;let D=window.Telegram?.WebApp;if(!D)return;try{D.ready?.()}catch($){f?.()}if(H==="telegram_expanded"&&(D.platform==="ios"||D.platform==="android"))D.expand();P(D)},[]),U};var S=require("react/jsx-runtime"),WP=({location:f,fallback:U,piecache:P,onError:H,queryOptions:D,disableGlobalForm:$})=>{let Z=b(),V=v(),z=m(),T=Zf.useMemo(()=>WH.createAxiosDateTransformer({baseURL:Z}),[Z]),I=Zf.useMemo(()=>x(),[]),X=Zf.useMemo(()=>Z?c(Z):null,[Z]),G=Zf.useMemo(()=>Z?p(Z,V):null,[Z,V]),J=gf({onError:H}),{data:Y,isLoading:q,error:C}=$f.useQuery({queryKey:["uiConfig",f.pathname+f.search,J?.initData],enabled:!!J?.initData,queryFn:async()=>{let W=new URLSearchParams(f.search);if(W.set("__pieroot","telegram"),J?.initData)W.set("initData",J.initData);let B="/api/content"+f.pathname+"?"+W.toString();if(z)console.log("[PieRoot] Fetching UI configuration from:",B);let R=await T.get(B,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(z)console.log("[PieRoot] Received UI configuration:",R.data);return R.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(W)=>Math.min(1000*2**W,30000),...D}),O=Hf(f.pathname,P,U);if(!Z)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(C&&z)return console.error("[PieRoot] Error fetching UI configuration:",C),console.error("[PieRoot] Error details:",{message:C.message,status:C.response?.status,data:C.response?.data}),H?.(),O;if(q||!Y){if(z)console.log("[PieRoot] Loading state:",{isLoading:q,hasUiConfiguration:!!Y});return O}if(z)console.log("[PieRoot] UI configuration loaded successfully:",Y),console.log("[PieRoot] Rendering UI with configuration");return S.jsx(N.Provider,{value:I,children:S.jsx(j.Provider,{value:X,children:S.jsx(k.Provider,{value:G,children:S.jsx(M.Provider,{value:U??S.jsx(S.Fragment,{}),children:S.jsx(l,{children:S.jsx(r,{children:$?S.jsx(w,{uiConfig:Y}):S.jsx("form",{id:"piedata_global_form",action:Z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:S.jsx(w,{uiConfig:Y})})})})})})})})},QP=(f)=>{let U=Zf.useMemo(()=>new $f.QueryClient,[]);return S.jsx(o.Provider,{value:f.onNavigate,children:S.jsx(d.Provider,{value:f.config,children:S.jsx($f.QueryClientProvider,{client:U,children:S.jsx(WP,{...f})})})})},QH=QP;var zf=require("react"),vf=require("@tanstack/react-query");var A=require("react/jsx-runtime"),RP=({location:f,fallback:U,children:P,disableGlobalForm:H})=>{let D=b(),$=v(),Z=m(),V=zf.useMemo(()=>x(),[]),z=zf.useMemo(()=>D?c(D):null,[D]),T=zf.useMemo(()=>D?p(D,$):null,[D,$]);if(Z)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",D),console.log("[PieRoot] CENTRIFUGE_SERVER:",$),console.log("[PieRoot] Fallback provided:",!!U);return A.jsx(N.Provider,{value:V,children:A.jsx(j.Provider,{value:z,children:A.jsx(k.Provider,{value:T,children:A.jsx(M.Provider,{value:U??A.jsx(A.Fragment,{}),children:A.jsx(l,{children:A.jsx(r,{children:H?P:A.jsx("form",{id:"piedata_global_form",action:D+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:P})})})})})})})},_P=(f)=>{let[U]=zf.useState(()=>new vf.QueryClient);return A.jsx(o.Provider,{value:f.onNavigate,children:A.jsx(d.Provider,{value:f.config,children:A.jsx(vf.QueryClientProvider,{client:U,children:A.jsx(RP,{...f})})})})},RH=_P;var Tf=require("react"),Vf=require("@tanstack/react-query");var _H=require("axios-date-transformer");var pf=require("react"),cf=()=>{let[f,U]=pf.useState(null);return pf.useEffect(()=>{if(typeof window==="undefined")return;let P=window.WebApp;if(!P)return;P.ready(),U(P)},[]),f};var F=require("react/jsx-runtime"),wP=({location:f,fallback:U,piecache:P,onError:H,queryOptions:D,disableGlobalForm:$})=>{let Z=b(),V=v(),z=m(),T=Tf.useMemo(()=>_H.createAxiosDateTransformer({baseURL:Z}),[Z]),I=Tf.useMemo(()=>x(),[]),X=Tf.useMemo(()=>Z?c(Z):null,[Z]),G=Tf.useMemo(()=>Z?p(Z,V):null,[Z,V]),J=cf(),{data:Y,isLoading:q,error:C}=Vf.useQuery({queryKey:["uiConfig",f.pathname+f.search,J?.initData],queryFn:async()=>{let W=new URLSearchParams(f.search);if(W.set("__pieroot","max"),J?.initData)W.set("initData",J.initData);let B="/api/content"+f.pathname+"?"+W.toString();if(z)console.log("[PieRoot] Fetching UI configuration from:",B);let R=await T.get(B,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(z)console.log("[PieRoot] Received UI configuration:",R.data);return R.data},enabled:!!J?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(W)=>Math.min(1000*2**W,30000),...D}),O=Hf(f.pathname,P,U);if(!Z)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(C&&z)return console.error("[PieRoot] Error fetching UI configuration:",C),console.error("[PieRoot] Error details:",{message:C.message,status:C.response?.status,data:C.response?.data}),H?.(),O;if(q||!Y){if(z)console.log("[PieRoot] Loading state:",{isLoading:q,hasUiConfiguration:!!Y});return O}if(z)console.log("[PieRoot] UI configuration loaded successfully:",Y),console.log("[PieRoot] Rendering UI with configuration");return F.jsx(N.Provider,{value:I,children:F.jsx(j.Provider,{value:X,children:F.jsx(k.Provider,{value:G,children:F.jsx(M.Provider,{value:U??F.jsx(F.Fragment,{}),children:F.jsx(l,{children:F.jsx(r,{children:$?F.jsx(w,{uiConfig:Y}):F.jsx("form",{id:"piedata_global_form",action:Z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:F.jsx(w,{uiConfig:Y})})})})})})})})},KP=(f)=>{let U=Tf.useMemo(()=>new Vf.QueryClient,[]);return F.jsx(o.Provider,{value:f.onNavigate,children:F.jsx(d.Provider,{value:f.config,children:F.jsx(Vf.QueryClientProvider,{client:U,children:F.jsx(wP,{...f})})})})},wH=KP;var KH=require("react"),TU=(f,U=!1)=>{if(f==="sid"){if(!window.sid)throw new Error("SocketIO isn't initialized properly");return[window.sid]}let P=document.getElementsByName(f);if(!P.length){if(U)console.warn(`No input found with name ${f}`);return[]}let H=P[0];if(H instanceof HTMLInputElement){if(H.type==="file"&&H.files)return Array.from(H.files);return[H.value]}if(H instanceof HTMLTextAreaElement)return[H.value];return[]},SP=(f,U={},P=[],H,D)=>{let $=D?.renderingLogEnabled??!1,Z=D?.timeout,V=D?.retryPolicy,z=V?.maxRetries??0,T=V?.baseDelay??1000,I=V?.retryOn??[502,503,504];if($)console.log("Registering AJAX: ",H,U,P);return async(X={})=>{if(typeof window==="undefined"||typeof document==="undefined"){if($)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}let G=D?.apiServer;if(!G){if($)console.warn("AJAX skipped: apiServer is missing");return}if(!H||!f){if($)console.warn("AJAX skipped: pathname or setUiAjaxConfiguration is missing");return}if(P.includes("sid"))await zU();let J=new FormData;for(let[C,O]of Object.entries({...U,...X}))J.append(C,O);for(let C of P)for(let O of TU(C,$))J.append(C,O);let Y=G+"api/ajax_content"+H;f(null);let q;for(let C=0;C<=z;C++){if(C>0){let B=T*2**(C-1);if($)console.log(`AJAX retry ${C}/${z} after ${B}ms`);await new Promise((R)=>setTimeout(R,B))}let O=Z!=null?new AbortController:null,W=O&&setTimeout(()=>O.abort(),Z);try{let B=await fetch(Y,{method:"POST",body:J,signal:O?.signal});if(W)clearTimeout(W);if(!B.ok&&I.includes(B.status)&&C<z){q=new Error(`HTTP ${B.status}`);continue}let Bf=(B.headers.get("content-type")||"").includes("application/json");if(!!B.body?.getReader&&!Bf){let Wf=B.body.getReader(),EH=new TextDecoder,n="";while(!0){let{done:lf,value:kH}=await Wf.read();if(lf)break;n+=EH.decode(kH,{stream:!0});let IU=n.split(`
|
|
3
|
+
`);n=IU.pop()??"";for(let jH of IU){let rf=jH.trim();if(!rf)continue;try{let xH=JSON.parse(rf);f([xH])}catch{if($)console.warn("Failed to parse streamed line:",rf)}}}if(n.trim())try{let lf=JSON.parse(n);f([lf])}catch{if($)console.warn("Failed to parse final streamed line:",n)}return{}}else{let Wf=await B.json();return f(Wf),Wf}}catch(B){if(W)clearTimeout(W);if(q=B,C<z)continue;if($)console.error("AJAX request failed:",B);return f(null),B}}if($)console.error("AJAX request failed after retries:",q);return f(null),q}},SH=(f,U={},P=[],H,D)=>{let{apiServer:$,enableRenderingLog:Z}=i(),V=JSON.stringify(U),z=JSON.stringify(P),T=JSON.stringify(D);return KH.useMemo(()=>SP(f,U,P,H,{apiServer:$,renderingLogEnabled:Z,timeout:D?.timeout,retryPolicy:D?.retryPolicy}),[f,V,z,H,$,Z,T])};var FH=require("@openai/agents"),hf=require("react");var MH=/^pie(.+?)_(.+)$/;function VU(f=x(),U={}){let P=[],H=new Set;for(let D of f.all.keys()){if(typeof D!=="string")continue;let $=D.match(MH);if(!$)continue;let[,Z,V]=$,z={methodName:Z,cardName:V,eventName:D};if(U.filter&&!U.filter(z))continue;let T=U.nameFor?.(z)??`${V}_${Z}`;if(H.has(T))continue;H.add(T);let I=U.describe?.(z)??`Invokes the "${Z}" method on the PieCard "${V}" by emitting the in-process mitt event "${D}". The optional "payload" argument is forwarded verbatim to the card's handler.`;P.push(FH.tool({name:T,description:I,strict:!1,parameters:{type:"object",properties:{payload:{description:"Arbitrary JSON payload forwarded to the PieCard method handler. Omit for fire-and-forget calls."}},required:[],additionalProperties:!0},execute:async(X)=>{let G=X?.payload;return f.emit(D,G),`Emitted "${D}"`}}))}return P}function LH(f={}){let P=hf.useContext(N)??x(),H=[];for(let z of P.all.keys())if(typeof z==="string"&&MH.test(z))H.push(z);H.sort();let D=H.join("|"),{filter:$,describe:Z,nameFor:V}=f;return hf.useMemo(()=>VU(P,{filter:$,describe:Z,nameFor:V}),[P,D,$,Z,V])}var AH=require("clsx"),NH=require("tailwind-merge");function yH(...f){return NH.twMerge(AH.clsx(f))}var oH=()=>{if(typeof document==="undefined")return;let f=document.getElementById("piedata_global_form");f&&f.submit()};var mH=(f,U)=>`${f}${_f}${U}`;
|
|
@@ -361,5 +361,26 @@
|
|
|
361
361
|
],
|
|
362
362
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
363
363
|
}
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"card": "OneOfCard",
|
|
367
|
+
"data": {
|
|
368
|
+
"type": "object",
|
|
369
|
+
"properties": {
|
|
370
|
+
"name": {
|
|
371
|
+
"type": "string"
|
|
372
|
+
},
|
|
373
|
+
"sx": {
|
|
374
|
+
"type": "object",
|
|
375
|
+
"additionalProperties": {}
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
"additionalProperties": false,
|
|
379
|
+
"required": [
|
|
380
|
+
"name",
|
|
381
|
+
"sx"
|
|
382
|
+
],
|
|
383
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
384
|
+
}
|
|
364
385
|
}
|
|
365
386
|
]
|
|
@@ -26,6 +26,24 @@ export type GetAjaxSubmitOptions = {
|
|
|
26
26
|
/** Retry policy for failed requests. No retries if omitted. */
|
|
27
27
|
retryPolicy?: RetryPolicy;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Reads the value(s) for a single dep name from the DOM, following the same
|
|
31
|
+
* convention used by Ajax cards. Returns an array because file inputs can
|
|
32
|
+
* contribute multiple values for the same key.
|
|
33
|
+
*
|
|
34
|
+
* - `'sid'` resolves to `window.sid`. The caller must ensure SocketIO is
|
|
35
|
+
* ready (e.g. via {@link waitForSidAvailable}) before calling this.
|
|
36
|
+
* - Other names are looked up via `document.getElementsByName`; only the
|
|
37
|
+
* first match is read.
|
|
38
|
+
* - `<input type="file">` returns every selected `File`.
|
|
39
|
+
* - Other `<input>` / `<textarea>` returns the current `.value`.
|
|
40
|
+
* - Missing inputs return `[]` (and emit a warning when `renderingLogEnabled`).
|
|
41
|
+
*
|
|
42
|
+
* Must run in a browser environment — relies on `document` and `window`.
|
|
43
|
+
*
|
|
44
|
+
* @throws if `depName === 'sid'` and `window.sid` is not initialized.
|
|
45
|
+
*/
|
|
46
|
+
export declare const readAjaxKey: (depName: string, renderingLogEnabled?: boolean) => Array<string | File>;
|
|
29
47
|
/**
|
|
30
48
|
* Builds an async "submit" function that issues an AJAX request to
|
|
31
49
|
* `api/ajax_content{pathname}` and streams (or JSON-decodes) the response
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ajaxCommonUtils.d.ts","sourceRoot":"","sources":["../../src/util/ajaxCommonUtils.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,CAAA;AACjB,OAAO,EAAE,0BAA0B,EAAe,MAAM,UAAU,CAAA;AAKlE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kJAAkJ;IAClJ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,uEAAuE;IACvE,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,WAAW,CAAA;CAC5B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,aAAa,GACtB,yBAAyB,0BAA0B,EACnD,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAChC,YAAW,KAAK,CAAC,MAAM,CAAM,EAC7B,WAAW,MAAM,EACjB,UAAU,oBAAoB,MAahB,cAAa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,
|
|
1
|
+
{"version":3,"file":"ajaxCommonUtils.d.ts","sourceRoot":"","sources":["../../src/util/ajaxCommonUtils.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,CAAA;AACjB,OAAO,EAAE,0BAA0B,EAAe,MAAM,UAAU,CAAA;AAKlE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kJAAkJ;IAClJ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,uEAAuE;IACvE,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,WAAW,CAAA;CAC5B,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,GACpB,SAAS,MAAM,EACf,sBAAqB,OAAe,KACrC,KAAK,CAAC,MAAM,GAAG,IAAI,CA0BrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,aAAa,GACtB,yBAAyB,0BAA0B,EACnD,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAChC,YAAW,KAAK,CAAC,MAAM,CAAM,EAC7B,WAAW,MAAM,EACjB,UAAU,oBAAoB,MAahB,cAAa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,iBAuKtD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GACtB,yBAAyB,0BAA0B,EACnD,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAChC,YAAW,KAAK,CAAC,MAAM,CAAM,EAC7B,WAAW,MAAM,EACjB,UAAU;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,oBA7L9B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBAyNjD,CAAA"}
|