@piedata/pieui 2.0.4 → 2.0.6
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 +223 -97
- package/dist/code/commands/init.d.ts.map +1 -1
- package/dist/code/templates/index.d.ts +2 -1
- package/dist/code/templates/index.d.ts.map +1 -1
- package/dist/code/templates/nextConfig.d.ts +3 -0
- package/dist/code/templates/nextConfig.d.ts.map +1 -0
- package/dist/components/Common/CloudStorageCard/index.d.ts +3 -0
- package/dist/components/Common/CloudStorageCard/index.d.ts.map +1 -0
- package/dist/components/Common/CloudStorageCard/types/index.d.ts +13 -0
- package/dist/components/Common/CloudStorageCard/types/index.d.ts.map +1 -0
- package/dist/components/Common/CloudStorageCard/ui/CloudStorageCard.d.ts +4 -0
- package/dist/components/Common/CloudStorageCard/ui/CloudStorageCard.d.ts.map +1 -0
- package/dist/components/Common/DeviceStorageCard/index.d.ts +3 -0
- package/dist/components/Common/DeviceStorageCard/index.d.ts.map +1 -0
- package/dist/components/Common/DeviceStorageCard/types/index.d.ts +13 -0
- package/dist/components/Common/DeviceStorageCard/types/index.d.ts.map +1 -0
- package/dist/components/Common/DeviceStorageCard/ui/DeviceStorageCard.d.ts +4 -0
- package/dist/components/Common/DeviceStorageCard/ui/DeviceStorageCard.d.ts.map +1 -0
- package/dist/components/Common/SecureStorageCard/index.d.ts +3 -0
- package/dist/components/Common/SecureStorageCard/index.d.ts.map +1 -0
- package/dist/components/Common/SecureStorageCard/types/index.d.ts +13 -0
- package/dist/components/Common/SecureStorageCard/types/index.d.ts.map +1 -0
- package/dist/components/Common/SecureStorageCard/ui/SecureStorageCard.d.ts +4 -0
- package/dist/components/Common/SecureStorageCard/ui/SecureStorageCard.d.ts.map +1 -0
- package/dist/components/Common/SessionStorageCard/index.d.ts +3 -0
- package/dist/components/Common/SessionStorageCard/index.d.ts.map +1 -0
- package/dist/components/Common/SessionStorageCard/types/index.d.ts +13 -0
- package/dist/components/Common/SessionStorageCard/types/index.d.ts.map +1 -0
- package/dist/components/Common/SessionStorageCard/ui/SessionStorageCard.d.ts +4 -0
- package/dist/components/Common/SessionStorageCard/ui/SessionStorageCard.d.ts.map +1 -0
- package/dist/components/PieBaseRoot/index.d.ts +11 -0
- package/dist/components/PieBaseRoot/index.d.ts.map +1 -1
- package/dist/components/PieBaseRoot/types/index.d.ts +6 -0
- package/dist/components/PieBaseRoot/types/index.d.ts.map +1 -1
- package/dist/components/PieCard/index.d.ts +18 -0
- package/dist/components/PieCard/index.d.ts.map +1 -1
- package/dist/components/PieCard/types/index.d.ts +36 -0
- package/dist/components/PieCard/types/index.d.ts.map +1 -1
- package/dist/components/PieMaxRoot/index.d.ts +12 -0
- package/dist/components/PieMaxRoot/index.d.ts.map +1 -1
- package/dist/components/PieRoot/index.d.ts +17 -0
- package/dist/components/PieRoot/index.d.ts.map +1 -1
- package/dist/components/PieRoot/types/index.d.ts +31 -0
- package/dist/components/PieRoot/types/index.d.ts.map +1 -1
- package/dist/components/PieTelegramRoot/index.d.ts +13 -0
- package/dist/components/PieTelegramRoot/index.d.ts.map +1 -1
- package/dist/components/index.d.ts +4 -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 +3 -0
- 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 +144 -0
- package/dist/tests/mittAgentTools.test.d.ts +2 -0
- package/dist/tests/mittAgentTools.test.d.ts.map +1 -0
- package/dist/util/ajaxCommonUtils.d.ts +69 -3
- package/dist/util/ajaxCommonUtils.d.ts.map +1 -1
- package/dist/util/centrifuge.d.ts +22 -0
- package/dist/util/centrifuge.d.ts.map +1 -1
- package/dist/util/fallback.d.ts +6 -0
- package/dist/util/fallback.d.ts.map +1 -1
- package/dist/util/globalForm.d.ts +8 -0
- package/dist/util/globalForm.d.ts.map +1 -1
- package/dist/util/lazy.d.ts +25 -0
- package/dist/util/lazy.d.ts.map +1 -1
- package/dist/util/mitt.d.ts +37 -0
- package/dist/util/mitt.d.ts.map +1 -1
- package/dist/util/mittAgentTools.d.ts +89 -0
- package/dist/util/mittAgentTools.d.ts.map +1 -0
- package/dist/util/navigate.d.ts +11 -0
- package/dist/util/navigate.d.ts.map +1 -1
- package/dist/util/pieConfig.d.ts +35 -0
- package/dist/util/pieConfig.d.ts.map +1 -1
- package/dist/util/pieName.d.ts +12 -0
- package/dist/util/pieName.d.ts.map +1 -1
- package/dist/util/piecache.d.ts +15 -0
- package/dist/util/piecache.d.ts.map +1 -1
- package/dist/util/registry.d.ts +49 -0
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/socket.d.ts +22 -0
- package/dist/util/socket.d.ts.map +1 -1
- package/dist/util/tailwindCommonUtils.d.ts +14 -0
- package/dist/util/tailwindCommonUtils.d.ts.map +1 -1
- package/dist/util/uiRenderer.d.ts +14 -0
- package/dist/util/uiRenderer.d.ts.map +1 -1
- package/dist/util/useIsSupported.d.ts +18 -0
- package/dist/util/useIsSupported.d.ts.map +1 -1
- package/dist/util/useMaxWebApp.d.ts +27 -0
- package/dist/util/useMaxWebApp.d.ts.map +1 -1
- package/dist/util/useOpenAIWebRTC.d.ts +44 -0
- package/dist/util/useOpenAIWebRTC.d.ts.map +1 -1
- package/dist/util/useWebApp.d.ts +21 -0
- package/dist/util/useWebApp.d.ts.map +1 -1
- package/dist/util/webrtcClient.d.ts +61 -0
- package/dist/util/webrtcClient.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var tn=Object.create;var{getPrototypeOf:nn,defineProperty:io,getOwnPropertyNames:qo,getOwnPropertyDescriptor:rn}=Object,Ko=Object.prototype.hasOwnProperty;var Lo=(o,t,f)=>{f=o!=null?tn(nn(o)):{};let n=t||!o||!o.__esModule?io(f,"default",{value:o,enumerable:!0}):f;for(let m of qo(o))if(!Ko.call(n,m))io(n,m,{get:()=>o[m],enumerable:!0});return n},Yo=new WeakMap,mn=(o)=>{var t=Yo.get(o),f;if(t)return t;if(t=io({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function")qo(o).map((n)=>!Ko.call(t,n)&&io(t,n,{get:()=>o[n],enumerable:!(f=rn(o,n))||f.enumerable}));return Yo.set(o,t),t};var fn=(o,t)=>{for(var f in t)io(o,f,{get:t[f],enumerable:!0,configurable:!0,set:(n)=>t[f]=()=>n})};var En={};fn(En,{useWebApp:()=>Mo,useOpenAIWebRTC:()=>ao,useAjaxSubmit:()=>Lt,unregisterComponent:()=>dt,submitGlobalForm:()=>jt,registry:()=>E,registerPieComponent:()=>R,registerMultipleComponents:()=>ct,pieName:()=>vt,hasComponent:()=>et,getRegistrySize:()=>at,getRegistryEntry:()=>Q,getComponentMeta:()=>it,getAllRegisteredComponents:()=>pt,cn:()=>St,UnionCard:()=>wt,UIRendererContext:()=>Z,UILoading:()=>Ro,UI:()=>g,SequenceCard:()=>Pt,PieTelegramRoot:()=>Vt,PieRoot:()=>Et,PieMaxRoot:()=>qt,PieCard:()=>I,PieBaseRoot:()=>Xt,PIEBREAK:()=>Co,IOEventsCard:()=>Nt,HiddenCard:()=>At,HTMLEmbedCard:()=>$t,BoxCard:()=>_t,AutoRedirectCard:()=>ht,AjaxGroupCard:()=>Mt});module.exports=mn(En);var O=require("react");var so=require("react"),G=so.createContext(null),F=()=>{let o=so.useContext(G);if(!o)throw new Error("usePieConfig must be used within PieConfigProvider");return o},b=()=>{let{apiServer:o}=F();return o},lo=b,k=()=>{let{centrifugeServer:o}=F();return o};var H=()=>{let{enableRenderingLog:o}=F();return o},Fo=H,Qo=()=>{let{pageProcessor:o}=F();return o};var Co="__piedemo__";var jo=require("react"),Zo=require("centrifuge"),So=new Map,V=(o,t)=>{if(!t)return null;let f=`${o}::${t}`,n=So.get(f);if(n)return n;async function m(){let c=await fetch(o+"api/centrifuge/gen_token");if(!c.ok){if(c.status===403)throw new Zo.Centrifuge.UnauthorizedError("Backend is not answering");throw new Error(`Unexpected status code ${c.status}`)}return(await c.json()).token}let r=new Zo.Centrifuge(t,{getToken:m});return So.set(f,r),r},cn=jo.createContext(null),M=cn;var ot=require("socket.io-client"),tt=require("react"),vo=new Map,X=(o)=>{let t=vo.get(o);if(t)return t;let f=ot.io(o,{autoConnect:!1,transports:["websocket"]});return vo.set(o,f),f},dn=tt.createContext(null),W=dn;var nt=Lo(require("mitt")),rt=require("react"),Oo=null;function J(){if(!Oo)Oo=nt.default();return Oo}var en=rt.createContext(null),_=en;var pn=({card:o,data:t,children:f,useSocketioSupport:n=!1,useCentrifugeSupport:m=!1,useMittSupport:r=!1,centrifugeChannel:c=void 0,methods:d=void 0})=>{let e=Fo(),s=O.useRef(d);if(O.useEffect(()=>{s.current=d},[d]),e)console.log("[PieCard] Rendering card:",o),console.log("[PieCard] Card data:",t),console.log("[PieCard] Component name:",t?.name),console.log("[PieCard] Real-time support:",{socketio:n,centrifuge:m,mitt:r,centrifugeChannel:c}),console.log("[PieCard] Methods:",d?Object.keys(d):"none"),console.log("[PieCard] Has children:",!!f);let C=O.useContext(W),l=O.useContext(M),p=O.useContext(_);if(O.useEffect(()=>{if(!C||!n||!s.current||!t.name){if(e&&n)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!C,useSocketioSupport:n,hasMethods:!!s.current,hasDataName:!!t?.name});return}let u=Object.keys(s.current??{});return u.forEach((i)=>{let a=`pie${i}_${t.name}`;if(e)console.log(`[PieCard] Socket.IO registering event: ${a}`);C.on(a,(y)=>{s.current?.[i]?.(y)})}),()=>{u.forEach((i)=>{let a=`pie${i}_${t.name}`;if(e)console.log(`[PieCard] Socket.IO unregistering event: ${a}`);C.off(a)})}},[C,t.name,n]),O.useEffect(()=>{if(!l||!m||!c||!t.name){if(e&&m)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!l,useCentrifugeSupport:m,hasCentrifugeChannel:!!c,hasMethods:!!s.current,hasDataName:!!t?.name});return}let i=Object.keys(s.current??{}).map((a)=>{let y=`pie${a}_${t.name}_${c}`;if(e)console.log(`[PieCard] Centrifuge subscribing to channel: ${y}`);let P=l.newSubscription(y);return P.on("publication",(w)=>{if(e)console.log(`[PieCard] Centrifuge received data on ${y}:`,w.data);s.current?.[a]?.(w.data)}),P.subscribe(),P});return()=>{i.forEach((a)=>{if(e)console.log("[PieCard] Centrifuge unsubscribing from channel");a.unsubscribe(),l.removeSubscription(a)})}},[l,c,t.name,m]),O.useEffect(()=>{if(!p||!r||!t.name){if(e&&r)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!p,useMittSupport:r,hasMethods:!!s.current,hasDataName:!!t?.name});return}let u=Object.keys(s.current??{}),i={};return u.forEach((a)=>{let y=`pie${a}_${t.name}`,P=(w)=>{if(e)console.log(`[PieCard] Mitt registering event: ${y}`);s.current?.[a]?.(w)};i[y]=P,p.on(y,P)}),()=>{Object.entries(i).forEach(([a,y])=>{if(e)console.log(`[PieCard] Mitt unregistering event: ${a}`);p.off(a,y)})}},[p,t.name,r]),e)console.log("[PieCard] Rendering complete, returning children");return f},I=pn;var mt=require("react"),Go=new Map;function ft(o,t){return mt.lazy(()=>{if(Go.has(t))return Go.get(t);let f=o().then((n)=>n);return Go.set(t,f),f})}var E=new Map,an=(o)=>{if(!o.name)throw new Error("Component registration requires a name");if(!o.component&&!o.loader)throw new Error(`Component "${o.name}" requires component or loader`);let t={name:o.name,component:o.component,loader:o.loader,metadata:o.metadata,fallback:o.fallback,isLazy:!1};if(!t.component&&t.loader)t.component=ft(t.loader,o.name),t.loader=void 0,t.isLazy=!0;return t};function R(o){let t=an(o);return E.set(t.name,t),t.component}var ct=(o)=>{o.forEach((t)=>R(t))},dt=(o)=>{E.delete(o)},et=(o)=>{return E.has(o)},it=(o)=>{return E.get(o)?.metadata},Q=(o)=>{return E.get(o)},pt=()=>{return Array.from(E.keys())},at=()=>{return E.size};var S=require("react");var ut=require("react"),yo=require("react/jsx-runtime"),un=ut.createContext(yo.jsx(yo.Fragment,{})),T=un;var Po=require("react/jsx-runtime");function sn({uiConfig:o,setUiAjaxConfiguration:t}){let f=S.useContext(T),n=H();if(n)console.log("[UI] Rendering component:",o.card),console.log("[UI] Component data:",o.data),console.log("[UI] Component content:",o.content),console.log("[UI] Has setUiAjaxConfiguration:",!!t);let m=Q(o.card);if(!m?.component){if(n)console.warn(`[UI] Component not found in registry: ${o.card}`),console.log("[UI] Returning fallback component");return f}if(n)console.log("[UI] Found component in registry:",{name:m.name,isLazy:m.isLazy,hasMetadata:!!m.metadata});let r=m.component,c=Po.jsx(r,{data:o.data,content:o.content,setUiAjaxConfiguration:t});if(m.isLazy){if(n)console.log("[UI] Rendering lazy component with Suspense:",m.name);return Po.jsx(S.Suspense,{fallback:m.fallback?Po.jsx(m.fallback,{}):f,children:c},`${m.name}`)}if(n)console.log("[UI] Rendering component directly:",m.name);return c}var g=S.memo(sn);var Uo=require("react");var st=require("react"),ln=st.createContext(null),Z=ln;var po=require("react/jsx-runtime");function lt({uiConfig:o,setUiAjaxConfiguration:t}){let f=Uo.useContext(T),n=H();if(n)console.log("[UILoading] Rendering fallback for:",o.card),console.log("[UILoading] Component data:",o.data),console.log("[UILoading] Component content:",o.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!t);let m=Q(o.card);if(!m?.component){if(n)console.warn(`[UILoading] Component not found in registry: ${o.card}`),console.log("[UILoading] Returning fallback component");return f}if(n)console.log("[UILoading] Found component in registry:",{name:m.name,isLazy:m.isLazy,hasMetadata:!!m.metadata,hasFallback:!!m.fallback});if(m.fallback){if(n)console.log("[UILoading] Rendering fallback for:",m.name);let d=m.fallback;return po.jsx(d,{})}if(n)console.log("[UILoading] No fallback, rendering full component:",m.name);let r=m.component,c=po.jsx(Z.Provider,{value:lt,children:po.jsx(r,{data:o.data,content:o.content,setUiAjaxConfiguration:t})});if(m.isLazy)return po.jsx(Uo.Suspense,{fallback:f,children:c},`${m.name}`);return c}var Ro=lt;var Ct=require("react");var wo=require("react/jsx-runtime"),Cn=({data:o,content:t,setUiAjaxConfiguration:f})=>{let{name:n,sx:m}=o,r=Ct.useContext(Z)??g;return wo.jsx(I,{card:n,data:o,children:wo.jsx("div",{style:m,id:n,children:t.map((c,d)=>{return wo.jsx(r,{uiConfig:c,setUiAjaxConfiguration:f},`children-${d}`)})})})},yt=Cn;var Pt=R({name:"SequenceCard",component:yt,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});var Ut=require("react");var bo=require("react/jsx-runtime"),yn=({data:o,content:t,setUiAjaxConfiguration:f})=>{let{name:n}=o,m=Ut.useContext(Z)??g;return bo.jsx(I,{card:n,data:o,children:t.map((r,c)=>{return bo.jsx(m,{uiConfig:r,setUiAjaxConfiguration:f},`children-${c}`)})})},Rt=yn;var wt=R({name:"UnionCard",component:Rt,metadata:{author:"PieData",description:"Renders one of many components"}});var Io=require("react"),It=Lo(require("html-react-parser"));var N=require("react");function Pn(){let o=new AudioContext,t=o.createOscillator(),f=t.connect(o.createMediaStreamDestination());t.start();let n=f.stream.getAudioTracks()[0];return n.enabled=!1,n}function ao(o=null,t){let[f,n]=N.useState(!1),m=N.useRef(null),r=N.useRef(null),c=N.useRef(null),d=N.useCallback(async(l,p=!0)=>{if(m.current)e();let u=new RTCPeerConnection;if(u.onconnectionstatechange=()=>{if(u.connectionState==="connected")n(!0);else if(["disconnected","failed","closed"].includes(u.connectionState))n(!1)},u.ontrack=(U)=>{if(o)o.srcObject=U.streams[0]},p){let U=await navigator.mediaDevices.getUserMedia({audio:!0});u.addTrack(U.getTracks()[0],U)}else{let U=Pn();u.addTrack(U)}let i=u.createDataChannel("oai-events");r.current=i,c.current=new Promise((U)=>{i.addEventListener("open",()=>{U()})});let a=await u.createOffer();await u.setLocalDescription(a);let x=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:a.sdp,headers:{Authorization:`Bearer ${l}`,"Content-Type":"application/sdp"}})).text();await u.setRemoteDescription({type:"answer",sdp:x}),m.current=u,await c.current},[o]),e=N.useCallback(()=>{let l=r.current;if(l)l.close();m.current?.getSenders()?.forEach((p)=>p.track?.stop()),m.current?.close(),n(!1),m.current=null,r.current=null,c.current=null},[o]),s=N.useCallback((l)=>{let p=r.current;if(!p){console.error("Data channel is not ready",l);return}let u=new Date().toLocaleTimeString();if(l.event_id=l.event_id||crypto.randomUUID(),p.send(JSON.stringify(l)),!l.timestamp)l.timestamp=u;t?.(l)},[t,o]),C=N.useCallback((l)=>{if(!r.current){console.error("Data channel is not ready");return}let u=()=>{s({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:l}]}}),s({type:"response.create"})};if(c.current)c.current.then(u);else u()},[t,o]);return N.useEffect(()=>{let l=r.current;if(!l)return;let p=(u)=>{let i=JSON.parse(u.data);if(!i.timestamp)i.timestamp=new Date().toLocaleTimeString();t?.(i)};return l.addEventListener("message",p),()=>{l.removeEventListener("message",p)}},[t,o]),{isSessionActive:f,startSession:d,stopSession:e,sendTextMessage:C}}var gt=require("react/jsx-runtime"),Un=({data:o})=>{let{html:t,useSocketioSupport:f,useCentrifugeSupport:n,useMittSupport:m,centrifugeChannel:r}=o,[c,d]=Io.useState(t),{isSessionActive:e,startSession:s,sendTextMessage:C}=ao(null,(i)=>{if(console.log(i.type,i.type==="response.output_text.delta"&&i.delta),i.type==="response.output_text.delta"&&i.delta)d((a)=>a+i.delta)});return Io.useEffect(()=>{d(t)},[t]),gt.jsx(I,{card:"HTMLEmbedCard",data:o,methods:{update:(i)=>{d(i.value)},generateUsingAI:async(i)=>{try{if(!e&&i.token)await s(i.token,!1);C(i.prompt)}catch(a){console.error("Failed to generate using AI",a)}},initializeAI:async(i)=>{if(!e&&i.token)await s(i.token,!1)}},useCentrifugeSupport:n,useSocketioSupport:f,useMittSupport:m,centrifugeChannel:r,children:It.default(c)})},Tt=Un;var $t=R({name:"HTMLEmbedCard",component:Tt,metadata:{author:"PieData"}});var To=require("react");var Eo=require("react/jsx-runtime"),Rn=({data:o})=>{let{name:t,value:f,useSocketioSupport:n,useCentrifugeSupport:m,useMittSupport:r,centrifugeChannel:c}=o,[d,e]=To.useState(f);return To.useEffect(()=>{e(f)},[f]),Eo.jsx(I,{card:"HiddenCard",data:o,useSocketioSupport:n,useCentrifugeSupport:m,useMittSupport:r,centrifugeChannel:c,methods:{update:({value:s})=>{e(s)}},children:Eo.jsx("input",{type:"hidden",id:t,name:t,value:d})})},zt=Rn;var At=R({name:"HiddenCard",component:zt,metadata:{author:"PieData"}});var uo=require("react");var Bt=require("react"),wn=Bt.createContext(void 0),h=wn;var go=require("react/jsx-runtime"),In=({data:o})=>{let{url:t}=o,f=uo.useContext(h),n=uo.useContext(T);return uo.useEffect(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(t))window.location.href=t;else f?.(t)},[t,f]),go.jsx(go.Fragment,{children:n})},Dt=In;var ht=R({name:"AutoRedirectCard",component:Dt,metadata:{author:"PieData"}});var Y=require("react-toastify"),$o=require("react-toastify");var v=require("react");var j=require("react/jsx-runtime"),Tn={bounce:Y.Bounce,slide:Y.Slide,zoom:Y.Zoom,flip:Y.Flip},gn=(o)=>{let t={...o,type:o.alertType,transition:o.transition?Tn[o.transition]:void 0,position:o.position??"bottom-right",autoClose:o.autoClose??3000,style:{backgroundColor:"black",...o.sx}};$o.toast(o.message,t)},$n=(o)=>{console.log("Log event",o)},zn=(o)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let t=()=>{try{new window.Notification(o.title,{body:o.message??o.subtitle,icon:o.icon,silent:o.silent})}catch(n){console.error("[IOEventsCard] Failed to show notification",n)}},f=window.Notification.permission;if(f==="granted"){t();return}if(f==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((n)=>{if(n==="granted")t()})},An=({data:o})=>{let{useCentrifugeSupport:t,useSocketioSupport:f,useMittSupport:n,centrifugeChannel:m}=o,r=v.useContext(h),c=v.useRef(r);c.current=r;let d=v.useMemo(()=>({alert:gn,log:$n,push:zn,redirect:(e)=>{if(e.to){let s=e.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(s))window.location.href=s;else c.current?.(s)}else window.location.reload()},reload:(e)=>{if(e.to){let s=e.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(s))window.location.href=s;else c.current?.(s)}else window.location.reload()}}),[]);return j.jsx(j.Fragment,{children:j.jsx(I,{card:"IOEventsCard",data:o,useCentrifugeSupport:t,useSocketioSupport:f,useMittSupport:n,centrifugeChannel:m,methods:d,children:j.jsx($o.ToastContainer,{})})})},Ht=An;var Nt=R({name:"IOEventsCard",component:Ht,metadata:{author:"PieData"}});var B=require("react");var ko=require("react/jsx-runtime"),Bn=({data:o,content:t})=>{let{useLoader:f,noReturn:n,returnType:m,useSocketioSupport:r,useCentrifugeSupport:c,useMittSupport:d,centrifugeChannel:e}=o,s=B.useContext(T),C=B.useContext(Z)??g,[l,p]=B.useState(!1),[u,i]=B.useState(null),a=B.useRef(t),y=B.useContext(_),P=B.useCallback((U)=>{if(U===null)p(!0);else if(p(!1),!n)a.current=U;if(!n)i(U)},[n]),w=B.useCallback((U)=>{a.current=U.content,i(U.content)},[]),x=B.useCallback((U)=>{if(U===null)p(!0);else if(p(!1),!n)for(let L of U)y?.emit(L.name,L.data)},[n,y]);if(B.useEffect(()=>{i(t),p(!1)},[t]),!u&&f)return s;return ko.jsx(I,{card:"AjaxGroupCard",data:o,methods:{changeContent:w},useSocketioSupport:r,useCentrifugeSupport:c,useMittSupport:d,centrifugeChannel:e,children:ko.jsx(C,{uiConfig:u??a.current,setUiAjaxConfiguration:m==="events"?x:P})})},xt=Bn;var Mt=R({name:"AjaxGroupCard",component:xt,metadata:{author:"PieData",description:"Group card with AJAX support"}});var Vo=require("react");var zo=require("react/jsx-runtime"),Dn=({data:o,content:t,setUiAjaxConfiguration:f})=>{let{name:n,url:m,sx:r}=o,c=Vo.useContext(h),d=Vo.useContext(Z)??g;return zo.jsx(I,{card:n,data:o,children:zo.jsx("div",{style:r,id:n,onClick:(s)=>{if(m)if(s.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(m))window.location.href=m;else c?.(m)},children:zo.jsx(d,{setUiAjaxConfiguration:f,uiConfig:t})})})},Wt=Dn;var _t=R({name:"BoxCard",component:Wt,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});var to=require("react"),no=require("@tanstack/react-query");var Ho=require("react");var Do=require("react"),Ao=new Map,Bo=new Map;function ho(o,t){let f=`${o}::${t}`,n=o?Ao.get(f):void 0,[m,r]=Do.useState(n??null);return Do.useEffect(()=>{if(!o)return;if(Ao.has(f)){r(Ao.get(f));return}let c=Bo.get(f);if(!c)c=fetch(o+`api/support/${t}`,{method:"GET"}).then((e)=>e.json()).then((e)=>{return Ao.set(f,e),Bo.delete(f),e}).catch((e)=>{throw Bo.delete(f),e}),Bo.set(f,c);let d=!1;return c.then((e)=>{if(!d)r(e)}).catch(()=>{}),()=>{d=!0}},[o,t,f]),m}var Xo=null,Zt=null;function Ot(){Zt?.()}function Jo(){if(typeof window==="undefined")return Promise.resolve();if(typeof window.sid!=="undefined")return Promise.resolve();if(!Xo)Xo=new Promise((o)=>{Zt=()=>{o()}});return Xo}var hn=({children:o})=>{let t=Ho.useContext(W),f=lo(),n=ho(f,"socketIO"),m=(r)=>{if(typeof window!=="undefined")window.sid=r.sid,Ot(),console.log(`SocketIO initialized: ${window.sid}`)};return Ho.useEffect(()=>{if(!t)return;let r=()=>{console.log("SocketIO connected")},c=(d)=>{console.log(`SocketIO disconnected: ${d}`),t.connect()};if(n)t.on("pieinit",m),t.on("connect",r),t.on("disconnect",c),t.connect();return()=>{if(n)t.off("pieinit",m),t.off("connect",r),t.off("disconnect",c),t.disconnect()}},[t,n]),o},q=hn;var No=require("react");var Hn=({children:o})=>{let t=No.useContext(M),f=lo(),n=ho(f,"centrifuge");return No.useEffect(()=>{if(!t)return;let m=()=>{console.log("Centrifuge connected")},r=(c)=>{console.log("Centrifuge disconnected:",c)};if(n)t.on("connected",m),t.on("disconnected",r),t.connect();return()=>{if(n)t.disconnect()}},[t,n]),o},K=Hn;var bt=require("axios-date-transformer");var Gt=require("react/jsx-runtime");function oo(o,t,f){if(!t)return f;let n=o.replace(/^\//,""),m=t[n];if(!m)return f;return Gt.jsx(Ro,{uiConfig:m})}var $=require("react/jsx-runtime"),Nn=({location:o,fallback:t,piecache:f,onError:n,queryOptions:m})=>{let r=b(),c=k(),d=H(),e=to.useMemo(()=>bt.createAxiosDateTransformer({baseURL:r||""}),[r]),s=to.useMemo(()=>J(),[]),C=to.useMemo(()=>r?X(r):null,[r]),l=to.useMemo(()=>r?V(r,c):null,[r,c]),{data:p,isLoading:u,error:i}=no.useQuery({queryKey:["uiConfig",o.pathname+o.search,r],enabled:!!r,queryFn:async()=>{let y=new URLSearchParams(o.search);y.set("__pieroot","web");let P="/api/content"+o.pathname+"?"+y.toString();if(d)console.log("[PieRoot] Fetching UI configuration from:",P);let w=await e.get(P,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(d)console.log("[PieRoot] Received UI configuration:",w.data);return w.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(y)=>Math.min(1000*2**y,30000),...m}),a=oo(o.pathname,f,t);if(!r)return a??null;if(d)console.log("[PieRoot] Rendering with location:",o),console.log("[PieRoot] API_SERVER:",r),console.log("[PieRoot] CENTRIFUGE_SERVER:",c),console.log("[PieRoot] Fallback provided:",!!t),console.log("[PieRoot] Piecache provided:",!!f);if(i){if(d)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 n?.(),a}if(u||!p){if(d)console.log("[PieRoot] Loading state:",{isLoading:u,hasUiConfiguration:!!p});return a}if(d)console.log("[PieRoot] UI configuration loaded successfully:",p),console.log("[PieRoot] Rendering UI with configuration");return $.jsx(_.Provider,{value:s,children:$.jsx(W.Provider,{value:C,children:$.jsx(M.Provider,{value:l,children:$.jsx(T.Provider,{value:t??$.jsx($.Fragment,{}),children:$.jsx(q,{children:$.jsx(K,{children:$.jsx("form",{id:"piedata_global_form",action:r+"api/process"+o.pathname,method:"post",encType:"multipart/form-data",children:$.jsx(g,{uiConfig:p})})})})})})})})},xn=(o)=>{let t=to.useMemo(()=>new no.QueryClient,[]);return $.jsx(h.Provider,{value:o.onNavigate,children:$.jsx(G.Provider,{value:o.config,children:$.jsx(no.QueryClientProvider,{client:t,children:$.jsx(Nn,{...o})})})})},Et=xn;var ro=require("react"),mo=require("@tanstack/react-query");var kt=require("axios-date-transformer");var xo=require("react");var Mo=({onError:o}={})=>{let[t,f]=xo.useState(null),n=Qo();return xo.useEffect(()=>{if(typeof window==="undefined")return;let m=window.Telegram?.WebApp;if(!m)return;try{m.ready?.()}catch(r){o?.()}if(n==="telegram_expanded"&&(m.platform==="ios"||m.platform==="android"))m.expand();f(m)},[]),t};var z=require("react/jsx-runtime"),Mn=({location:o,fallback:t,piecache:f,onError:n,queryOptions:m})=>{let r=b(),c=k(),d=H(),e=ro.useMemo(()=>kt.createAxiosDateTransformer({baseURL:r}),[r]),s=ro.useMemo(()=>J(),[]),C=ro.useMemo(()=>r?X(r):null,[r]),l=ro.useMemo(()=>r?V(r,c):null,[r,c]),p=Mo({onError:n}),{data:u,isLoading:i,error:a}=mo.useQuery({queryKey:["uiConfig",o.pathname+o.search,p?.initData],enabled:!!p?.initData,queryFn:async()=>{let P=new URLSearchParams(o.search);if(P.set("__pieroot","telegram"),p?.initData)P.set("initData",p.initData);let w="/api/content"+o.pathname+"?"+P.toString();if(d)console.log("[PieRoot] Fetching UI configuration from:",w);let x=await e.get(w,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(d)console.log("[PieRoot] Received UI configuration:",x.data);return x.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(P)=>Math.min(1000*2**P,30000),...m}),y=oo(o.pathname,f,t);if(!r)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(a&&d)return console.error("[PieRoot] Error fetching UI configuration:",a),console.error("[PieRoot] Error details:",{message:a.message,status:a.response?.status,data:a.response?.data}),n?.(),y;if(i||!u){if(d)console.log("[PieRoot] Loading state:",{isLoading:i,hasUiConfiguration:!!u});return y}if(d)console.log("[PieRoot] UI configuration loaded successfully:",u),console.log("[PieRoot] Rendering UI with configuration");return z.jsx(_.Provider,{value:s,children:z.jsx(W.Provider,{value:C,children:z.jsx(M.Provider,{value:l,children:z.jsx(T.Provider,{value:t??z.jsx(z.Fragment,{}),children:z.jsx(q,{children:z.jsx(K,{children:z.jsx("form",{id:"piedata_global_form",action:r+"api/process"+o.pathname,method:"post",encType:"multipart/form-data",children:z.jsx(g,{uiConfig:u})})})})})})})})},Wn=(o)=>{let t=ro.useMemo(()=>new mo.QueryClient,[]);return z.jsx(h.Provider,{value:o.onNavigate,children:z.jsx(G.Provider,{value:o.config,children:z.jsx(mo.QueryClientProvider,{client:t,children:z.jsx(Mn,{...o})})})})},Vt=Wn;var fo=require("react"),Wo=require("@tanstack/react-query");var D=require("react/jsx-runtime"),_n=({location:o,fallback:t,children:f})=>{let n=b(),m=k(),r=H(),c=fo.useMemo(()=>J(),[]),d=fo.useMemo(()=>n?X(n):null,[n]),e=fo.useMemo(()=>n?V(n,m):null,[n,m]);if(r)console.log("[PieRoot] Rendering with location:",o),console.log("[PieRoot] API_SERVER:",n),console.log("[PieRoot] CENTRIFUGE_SERVER:",m),console.log("[PieRoot] Fallback provided:",!!t);return D.jsx(_.Provider,{value:c,children:D.jsx(W.Provider,{value:d,children:D.jsx(M.Provider,{value:e,children:D.jsx(T.Provider,{value:t??D.jsx(D.Fragment,{}),children:D.jsx(q,{children:D.jsx(K,{children:D.jsx("form",{id:"piedata_global_form",action:n+"api/process"+o.pathname,method:"post",encType:"multipart/form-data",children:f})})})})})})})},Zn=(o)=>{let[t]=fo.useState(()=>new Wo.QueryClient);return D.jsx(h.Provider,{value:o.onNavigate,children:D.jsx(G.Provider,{value:o.config,children:D.jsx(Wo.QueryClientProvider,{client:t,children:D.jsx(_n,{...o})})})})},Xt=Zn;var co=require("react"),eo=require("@tanstack/react-query");var Yt=require("axios-date-transformer");var _o=require("react"),Jt=()=>{let[o,t]=_o.useState(null);return _o.useEffect(()=>{if(typeof window==="undefined")return;let f=window.WebApp;if(!f)return;f.ready(),t(f)},[]),o};var A=require("react/jsx-runtime"),On=({location:o,fallback:t,piecache:f,onError:n,queryOptions:m})=>{let r=b(),c=k(),d=H(),e=co.useMemo(()=>Yt.createAxiosDateTransformer({baseURL:r}),[r]),s=co.useMemo(()=>J(),[]),C=co.useMemo(()=>r?X(r):null,[r]),l=co.useMemo(()=>r?V(r,c):null,[r,c]),p=Jt(),{data:u,isLoading:i,error:a}=eo.useQuery({queryKey:["uiConfig",o.pathname+o.search,p?.initData],queryFn:async()=>{let P=new URLSearchParams(o.search);if(P.set("__pieroot","max"),p?.initData)P.set("initData",p.initData);let w="/api/content"+o.pathname+"?"+P.toString();if(d)console.log("[PieRoot] Fetching UI configuration from:",w);let x=await e.get(w,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(d)console.log("[PieRoot] Received UI configuration:",x.data);return x.data},enabled:!!p?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(P)=>Math.min(1000*2**P,30000),...m}),y=oo(o.pathname,f,t);if(!r)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(a&&d)return console.error("[PieRoot] Error fetching UI configuration:",a),console.error("[PieRoot] Error details:",{message:a.message,status:a.response?.status,data:a.response?.data}),n?.(),y;if(i||!u){if(d)console.log("[PieRoot] Loading state:",{isLoading:i,hasUiConfiguration:!!u});return y}if(d)console.log("[PieRoot] UI configuration loaded successfully:",u),console.log("[PieRoot] Rendering UI with configuration");return A.jsx(_.Provider,{value:s,children:A.jsx(W.Provider,{value:C,children:A.jsx(M.Provider,{value:l,children:A.jsx(T.Provider,{value:t??A.jsx(A.Fragment,{}),children:A.jsx(q,{children:A.jsx(K,{children:A.jsx("form",{id:"piedata_global_form",action:r+"api/process"+o.pathname,method:"post",encType:"multipart/form-data",children:A.jsx(g,{uiConfig:u})})})})})})})})},Gn=(o)=>{let t=co.useMemo(()=>new eo.QueryClient,[]);return A.jsx(h.Provider,{value:o.onNavigate,children:A.jsx(G.Provider,{value:o.config,children:A.jsx(eo.QueryClientProvider,{client:t,children:A.jsx(On,{...o})})})})},qt=Gn;var Kt=require("react"),bn=(o,t={},f=[],n,m)=>{let r=m?.renderingLogEnabled??!1;if(!m?.apiServer){if(r)console.warn("Registration FAILED: apiServer is missing!");return()=>{}}let c=m?.apiServer;if(r)console.log("Registering AJAX: ",n,t,f);if(!n||!o){if(r)console.warn("Registration FAILED: pathname or setUiAjaxConfiguration is missing!");return()=>{}}return async(d={})=>{if(typeof window==="undefined"||typeof document==="undefined"){if(r)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}if(f.includes("sid"))await Jo();let e=new FormData;for(let[C,l]of Object.entries({...t,...d}))e.append(C,l);for(let C of f)if(C==="sid"){if(!window.sid)throw new Error("SocketIO isn't initialized properly");e.append("sid",window.sid)}else{let l=document.getElementsByName(C);if(!l.length){if(r)console.warn(`No input found with name ${C}`);continue}let p=l[0];if(p instanceof HTMLInputElement)if(p.type==="file"&&p.files)Array.from(p.files).forEach((u)=>e.append(C,u));else e.append(C,p.value);else if(p instanceof HTMLTextAreaElement)e.append(C,p.value)}let s=c+"api/ajax_content"+n;return o(null),await fetch(s,{method:"POST",body:e}).then(async(C)=>{let p=(C.headers.get("content-type")||"").includes("application/json");if(!!C.body?.getReader&&!p){let i=C.body.getReader(),a=new TextDecoder,y="";while(!0){let{done:P,value:w}=await i.read();if(P)break;y+=a.decode(w,{stream:!0});let x=y.split(`
|
|
3
|
-
`);
|
|
2
|
+
var oD=Object.create;var{getPrototypeOf:ED,defineProperty:Gf,getOwnPropertyNames:TU,getOwnPropertyDescriptor:mD}=Object,GU=Object.prototype.hasOwnProperty;var VU=(f,U,H)=>{H=f!=null?oD(ED(f)):{};let D=U||!f||!f.__esModule?Gf(H,"default",{value:f,enumerable:!0}):H;for(let P of TU(f))if(!GU.call(D,P))Gf(D,P,{get:()=>f[P],enumerable:!0});return D},$U=new WeakMap,kD=(f)=>{var U=$U.get(f),H;if(U)return U;if(U=Gf({},"__esModule",{value:!0}),f&&typeof f==="object"||typeof f==="function")TU(f).map((D)=>!GU.call(U,D)&&Gf(U,D,{get:()=>f[D],enumerable:!(H=mD(f,D))||H.enumerable}));return $U.set(f,U),U};var jD=(f,U)=>{for(var H in U)Gf(f,H,{get:U[H],enumerable:!0,configurable:!0,set:(D)=>U[H]=()=>D})};var CH={};jD(CH,{useWebApp:()=>uf,usePieMittAgentTools:()=>RD,usePieEmit:()=>OU,useOpenAIWebRTC:()=>If,useAjaxSubmit:()=>CD,unregisterComponent:()=>KU,submitGlobalForm:()=>LD,registry:()=>v,registerPieComponent:()=>C,registerMultipleComponents:()=>FU,pieName:()=>MD,hasComponent:()=>wU,getRegistrySize:()=>SU,getRegistryEntry:()=>t,getMittAgentTools:()=>ZU,getComponentMeta:()=>LU,getAllRegisteredComponents:()=>MU,cn:()=>wD,UnionCard:()=>xU,UIRendererContext:()=>x,UILoading:()=>wf,UI:()=>K,SessionStorageCard:()=>iU,SequenceCard:()=>mU,SecureStorageCard:()=>DD,PieTelegramRoot:()=>YD,PieRoot:()=>ID,PieMaxRoot:()=>QD,PieCard:()=>_,PieBaseRoot:()=>XD,PIEBREAK:()=>_f,IOEventsCard:()=>nU,HiddenCard:()=>pU,HTMLEmbedCard:()=>vU,DeviceStorageCard:()=>aU,CloudStorageCard:()=>fD,BoxCard:()=>zD,AutoRedirectCard:()=>lU,AjaxGroupCard:()=>PD});module.exports=kD(CH);var d=require("react");var Cf=require("react"),u=Cf.createContext(null),s=()=>{let f=Cf.useContext(u);if(!f)throw new Error("usePieConfig must be used within PieConfigProvider");return f},b=()=>{let{apiServer:f}=s();return f},Of=b,g=()=>{let{centrifugeServer:f}=s();return f};var o=()=>{let{enableRenderingLog:f}=s();return f},IU=o,JU=()=>{let{pageProcessor:f}=s();return f};var _f="__piedemo__";var XU=require("react"),hf=require("centrifuge"),YU=new Map,p=(f,U)=>{if(!U)return null;let H=`${f}::${U}`,D=YU.get(H);if(D)return D;async function P(){let z=await fetch(f+"api/centrifuge/gen_token");if(!z.ok){if(z.status===403)throw new hf.Centrifuge.UnauthorizedError("Backend is not answering");throw new Error(`Unexpected status code ${z.status}`)}return(await z.json()).token}let Z=new hf.Centrifuge(U,{getToken:P});return YU.set(H,Z),Z},xD=XU.createContext(null),m=xD;var BU=require("socket.io-client"),QU=require("react"),qU=new Map,c=(f)=>{let U=qU.get(f);if(U)return U;let H=BU.io(f,{autoConnect:!1,transports:["websocket"]});return qU.set(f,H),H},dD=QU.createContext(null),k=dD;var WU=VU(require("mitt")),i=require("react"),lf=null;function j(){if(!lf)lf=WU.default();return lf}var CU=i.createContext(null);function OU(f){let U=i.useContext(CU);return i.useCallback((H,D)=>{(U??j()).emit(`pie${H}_${f}`,D)},[f,U])}var N=CU;var uD=({card:f,data:U,children:H,useSocketioSupport:D=!1,useCentrifugeSupport:P=!1,useMittSupport:Z=!1,centrifugeChannel:z=void 0,methods:T=void 0})=>{let $=IU(),G=d.useRef(T);if(G.current=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:D,centrifuge:P,mitt:Z,centrifugeChannel:z}),console.log("[PieCard] Methods:",T?Object.keys(T):"none"),console.log("[PieCard] Has children:",!!H);let X=d.useContext(k),B=d.useContext(m),q=d.useContext(N);if(d.useEffect(()=>{if(!X||!D||!G.current||!U.name){if($&&D)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!X,useSocketioSupport:D,hasMethods:!!G.current,hasDataName:!!U?.name});return}let I=Object.keys(G.current??{}).map((V)=>{let J=`pie${V}_${U.name}`;if($)console.log(`[PieCard] Socket.IO registering event: ${J}`);let Q=(W)=>{G.current?.[V]?.(W)};return X.on(J,Q),[J,Q]});return()=>{I.forEach(([V,J])=>{if($)console.log(`[PieCard] Socket.IO unregistering event: ${V}`);X.off(V,J)})}},[X,U.name,D]),d.useEffect(()=>{if(!B||!P||!z||!U.name){if($&&P)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!B,useCentrifugeSupport:P,hasCentrifugeChannel:!!z,hasMethods:!!G.current,hasDataName:!!U?.name});return}let I=Object.keys(G.current??{}).map((V)=>{let J=`pie${V}_${U.name}_${z}`;if($)console.log(`[PieCard] Centrifuge subscribing to channel: ${J}`);let Q=B.newSubscription(J);return Q.on("publication",(W)=>{if($)console.log(`[PieCard] Centrifuge received data on ${J}:`,W.data);G.current?.[V]?.(W.data)}),Q.subscribe(),Q});return()=>{I.forEach((V)=>{if($)console.log("[PieCard] Centrifuge unsubscribing from channel");V.unsubscribe(),B.removeSubscription(V)})}},[B,z,U.name,P]),d.useEffect(()=>{if(!q||!Z||!U.name){if($&&Z)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!q,useMittSupport:Z,hasMethods:!!G.current,hasDataName:!!U?.name});return}let Y=Object.keys(G.current??{}),I={};return Y.forEach((V)=>{let J=`pie${V}_${U.name}`,Q=(W)=>{if($)console.log(`[PieCard] Mitt registering event: ${J}`);G.current?.[V]?.(W)};I[J]=Q,q.on(J,Q)}),()=>{Object.entries(I).forEach(([V,J])=>{if($)console.log(`[PieCard] Mitt unregistering event: ${V}`);q.off(V,J)})}},[q,U.name,Z]),$)console.log("[PieCard] Rendering complete, returning children");return H},_=uD;var _U=require("react"),rf=new Map;function RU(f,U){return _U.lazy(()=>{if(rf.has(U))return rf.get(U);let H=f().then((D)=>D);return rf.set(U,H),H})}var v=new Map,bD=(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=RU(U.loader,f.name),U.loader=void 0,U.isLazy=!0;return U};function C(f){let U=bD(f);return v.set(U.name,U),U.component}var FU=(f)=>{f.forEach((U)=>C(U))},KU=(f)=>{v.delete(f)},wU=(f)=>{return v.has(f)},LU=(f)=>{return v.get(f)?.metadata},t=(f)=>{return v.get(f)},MU=()=>{return Array.from(v.keys())},SU=()=>{return v.size};var a=require("react");var AU=require("react"),Rf=require("react/jsx-runtime"),vD=AU.createContext(Rf.jsx(Rf.Fragment,{})),F=vD;var Ff=require("react/jsx-runtime");function gD({uiConfig:f,setUiAjaxConfiguration:U}){let H=a.useContext(F),D=o();if(D)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=t(f.card);if(!P?.component){if(D)console.warn(`[UI] Component not found in registry: ${f.card}`),console.log("[UI] Returning fallback component");return H}if(D)console.log("[UI] Found component in registry:",{name:P.name,isLazy:P.isLazy,hasMetadata:!!P.metadata});let Z=P.component,z=Ff.jsx(Z,{data:f.data,content:f.content,setUiAjaxConfiguration:U});if(P.isLazy){if(D)console.log("[UI] Rendering lazy component with Suspense:",P.name);return Ff.jsx(a.Suspense,{fallback:P.fallback?Ff.jsx(P.fallback,{}):H,children:z},`${P.name}`)}if(D)console.log("[UI] Rendering component directly:",P.name);return z}var K=a.memo(gD);var Kf=require("react");var NU=require("react"),pD=NU.createContext(null),x=pD;var Vf=require("react/jsx-runtime");function yU({uiConfig:f,setUiAjaxConfiguration:U}){let H=Kf.useContext(F),D=o();if(D)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=t(f.card);if(!P?.component){if(D)console.warn(`[UILoading] Component not found in registry: ${f.card}`),console.log("[UILoading] Returning fallback component");return H}if(D)console.log("[UILoading] Found component in registry:",{name:P.name,isLazy:P.isLazy,hasMetadata:!!P.metadata,hasFallback:!!P.fallback});if(P.fallback){if(D)console.log("[UILoading] Rendering fallback for:",P.name);let T=P.fallback;return Vf.jsx(T,{})}if(D)console.log("[UILoading] No fallback, rendering full component:",P.name);let Z=P.component,z=Vf.jsx(x.Provider,{value:yU,children:Vf.jsx(Z,{data:f.data,content:f.content,setUiAjaxConfiguration:U})});if(P.isLazy)return Vf.jsx(Kf.Suspense,{fallback:H,children:z},`${P.name}`);return z}var wf=yU;var oU=require("react");var Lf=require("react/jsx-runtime"),cD=({data:f,content:U,setUiAjaxConfiguration:H})=>{let{name:D,sx:P}=f,Z=oU.useContext(x)??K;return Lf.jsx(_,{card:D,data:f,children:Lf.jsx("div",{style:P,id:D,children:U.map((z,T)=>{return Lf.jsx(Z,{uiConfig:z,setUiAjaxConfiguration:H},`children-${T}`)})})})},EU=cD;var mU=C({name:"SequenceCard",component:EU,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});var kU=require("react");var nf=require("react/jsx-runtime"),hD=({data:f,content:U,setUiAjaxConfiguration:H})=>{let{name:D}=f,P=kU.useContext(x)??K;return nf.jsx(_,{card:D,data:f,children:U.map((Z,z)=>{return nf.jsx(P,{uiConfig:Z,setUiAjaxConfiguration:H},`children-${z}`)})})},jU=hD;var xU=C({name:"UnionCard",component:jU,metadata:{author:"PieData",description:"Renders one of many components"}});var Mf=require("react"),dU=VU(require("html-react-parser"));var E=require("react");function lD(){let f=new AudioContext,U=f.createOscillator(),H=U.connect(f.createMediaStreamDestination());U.start();let D=H.stream.getAudioTracks()[0];return D.enabled=!1,D}function If(f=null,U){let[H,D]=E.useState(!1),P=E.useRef(null),Z=E.useRef(null),z=E.useRef(null),T=E.useCallback(async(B,q=!0)=>{if(P.current)$();let Y=new RTCPeerConnection;if(Y.onconnectionstatechange=()=>{if(Y.connectionState==="connected")D(!0);else if(["disconnected","failed","closed"].includes(Y.connectionState))D(!1)},Y.ontrack=(R)=>{if(f)f.srcObject=R.streams[0]},q){let R=await navigator.mediaDevices.getUserMedia({audio:!0});Y.addTrack(R.getTracks()[0],R)}else{let R=lD();Y.addTrack(R)}let I=Y.createDataChannel("oai-events");Z.current=I,z.current=new Promise((R)=>{I.addEventListener("open",()=>{R()})});let V=await Y.createOffer();await Y.setLocalDescription(V);let O=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:V.sdp,headers:{Authorization:`Bearer ${B}`,"Content-Type":"application/sdp"}})).text();await Y.setRemoteDescription({type:"answer",sdp:O}),P.current=Y,await z.current},[f]),$=E.useCallback(()=>{let B=Z.current;if(B)B.close();P.current?.getSenders()?.forEach((q)=>q.track?.stop()),P.current?.close(),D(!1),P.current=null,Z.current=null,z.current=null},[f]),G=E.useCallback((B)=>{let q=Z.current;if(!q){console.error("Data channel is not ready",B);return}let Y=new Date().toLocaleTimeString();if(B.event_id=B.event_id||crypto.randomUUID(),q.send(JSON.stringify(B)),!B.timestamp)B.timestamp=Y;U?.(B)},[U,f]),X=E.useCallback((B)=>{if(!Z.current){console.error("Data channel is not ready");return}let Y=()=>{G({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:B}]}}),G({type:"response.create"})};if(z.current)z.current.then(Y);else Y()},[U,f]);return E.useEffect(()=>{let B=Z.current;if(!B)return;let q=(Y)=>{let I=JSON.parse(Y.data);if(!I.timestamp)I.timestamp=new Date().toLocaleTimeString();U?.(I)};return B.addEventListener("message",q),()=>{B.removeEventListener("message",q)}},[U,f]),{isSessionActive:H,startSession:T,stopSession:$,sendTextMessage:X}}var bU=require("react/jsx-runtime"),rD=({data:f})=>{let{html:U,useSocketioSupport:H,useCentrifugeSupport:D,useMittSupport:P,centrifugeChannel:Z}=f,[z,T]=Mf.useState(U),{isSessionActive:$,startSession:G,sendTextMessage:X}=If(null,(I)=>{if(console.log(I.type,I.type==="response.output_text.delta"&&I.delta),I.type==="response.output_text.delta"&&I.delta)T((V)=>V+I.delta)});return Mf.useEffect(()=>{T(U)},[U]),bU.jsx(_,{card:"HTMLEmbedCard",data:f,methods:{update:(I)=>{T(I.value)},generateUsingAI:async(I)=>{try{if(!$&&I.token)await G(I.token,!1);X(I.prompt)}catch(V){console.error("Failed to generate using AI",V)}},initializeAI:async(I)=>{if(!$&&I.token)await G(I.token,!1)}},useCentrifugeSupport:D,useSocketioSupport:H,useMittSupport:P,centrifugeChannel:Z,children:dU.default(z)})},uU=rD;var vU=C({name:"HTMLEmbedCard",component:uU,metadata:{author:"PieData"}});var Sf=require("react");var sf=require("react/jsx-runtime"),nD=({data:f})=>{let{name:U,value:H,useSocketioSupport:D,useCentrifugeSupport:P,useMittSupport:Z,centrifugeChannel:z}=f,[T,$]=Sf.useState(H);return Sf.useEffect(()=>{$(H)},[H]),sf.jsx(_,{card:"HiddenCard",data:f,useSocketioSupport:D,useCentrifugeSupport:P,useMittSupport:Z,centrifugeChannel:z,methods:{update:({value:G})=>{$(G)}},children:sf.jsx("input",{type:"hidden",id:U,name:U,value:T})})},gU=nD;var pU=C({name:"HiddenCard",component:gU,metadata:{author:"PieData"}});var Jf=require("react");var cU=require("react"),sD=cU.createContext(void 0),y=sD;var Af=require("react/jsx-runtime"),iD=({data:f})=>{let{url:U}=f,H=Jf.useContext(y),D=Jf.useContext(F);return Jf.useEffect(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(U))window.location.href=U;else H?.(U)},[U,H]),Af.jsx(Af.Fragment,{children:D})},hU=iD;var lU=C({name:"AutoRedirectCard",component:hU,metadata:{author:"PieData"}});var h=require("react-toastify"),Nf=require("react-toastify");var ff=require("react");var e=require("react/jsx-runtime"),tD={bounce:h.Bounce,slide:h.Slide,zoom:h.Zoom,flip:h.Flip},aD=(f)=>{let U={...f,type:f.alertType,transition:f.transition?tD[f.transition]:void 0,position:f.position??"bottom-right",autoClose:f.autoClose??3000,style:{backgroundColor:"black",...f.sx}};Nf.toast(f.message,U)},eD=(f)=>{console.log("Log event",f)},fH=(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(D){console.error("[IOEventsCard] Failed to show notification",D)}},H=window.Notification.permission;if(H==="granted"){U();return}if(H==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((D)=>{if(D==="granted")U()})},UH=({data:f})=>{let{useCentrifugeSupport:U,useSocketioSupport:H,useMittSupport:D,centrifugeChannel:P}=f,Z=ff.useContext(y),z=ff.useRef(Z);z.current=Z;let T=ff.useMemo(()=>({alert:aD,log:eD,push:fH,redirect:($)=>{if($.to){let G=$.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(G))window.location.href=G;else z.current?.(G)}else window.location.reload()},reload:($)=>{if($.to){let G=$.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(G))window.location.href=G;else z.current?.(G)}else window.location.reload()}}),[]);return e.jsx(e.Fragment,{children:e.jsx(_,{card:"IOEventsCard",data:f,useCentrifugeSupport:U,useSocketioSupport:H,useMittSupport:D,centrifugeChannel:P,methods:T,children:e.jsx(Nf.ToastContainer,{})})})},rU=UH;var nU=C({name:"IOEventsCard",component:rU,metadata:{author:"PieData"}});var Yf=require("react");var tf=require("react/jsx-runtime"),DH=({data:f})=>{let{name:U,key:H,value:D,useSocketioSupport:P,useCentrifugeSupport:Z,useMittSupport:z,centrifugeChannel:T}=f,[$,G]=Yf.useState(D);return Yf.useEffect(()=>{G(D)},[D]),Yf.useEffect(()=>{if(typeof window==="undefined")return;sessionStorage.setItem(H,$)},[H,$]),tf.jsx(_,{card:"SessionStorageCard",data:f,useSocketioSupport:P,useCentrifugeSupport:Z,useMittSupport:z,centrifugeChannel:T,methods:{update:({value:X})=>{G(X)},remove:()=>{sessionStorage.removeItem(H),G("")}},children:tf.jsx("input",{type:"hidden",id:U,name:U,value:$})})},sU=DH;var iU=C({name:"SessionStorageCard",component:sU,metadata:{author:"PieData"}});var Xf=require("react");var af=require("react/jsx-runtime"),HH=({data:f})=>{let{name:U,key:H,value:D,useSocketioSupport:P,useCentrifugeSupport:Z,useMittSupport:z,centrifugeChannel:T}=f,[$,G]=Xf.useState(D);return Xf.useEffect(()=>{G(D)},[D]),Xf.useEffect(()=>{if(typeof window==="undefined")return;localStorage.setItem(H,$)},[H,$]),af.jsx(_,{card:"DeviceStorageCard",data:f,useSocketioSupport:P,useCentrifugeSupport:Z,useMittSupport:z,centrifugeChannel:T,methods:{update:({value:X})=>{G(X)},remove:()=>{localStorage.removeItem(H),G("")}},children:af.jsx("input",{type:"hidden",id:U,name:U,value:$})})},tU=HH;var aU=C({name:"DeviceStorageCard",component:tU,metadata:{author:"PieData"}});var qf=require("react");var ef=require("react/jsx-runtime"),PH=({data:f})=>{let{name:U,key:H,value:D,useSocketioSupport:P,useCentrifugeSupport:Z,useMittSupport:z,centrifugeChannel:T}=f,[$,G]=qf.useState(D);return qf.useEffect(()=>{G(D)},[D]),qf.useEffect(()=>{if(typeof window==="undefined")return;let X=window.Telegram?.WebApp?.CloudStorage;if(!X)return;X.setItem(H,$)},[H,$]),ef.jsx(_,{card:"CloudStorageCard",data:f,useSocketioSupport:P,useCentrifugeSupport:Z,useMittSupport:z,centrifugeChannel:T,methods:{update:({value:X})=>{G(X)},remove:()=>{let X=window.Telegram?.WebApp?.CloudStorage;if(X)X.removeItem(H);G("")}},children:ef.jsx("input",{type:"hidden",id:U,name:U,value:$})})},eU=PH;var fD=C({name:"CloudStorageCard",component:eU,metadata:{author:"PieData"}});var Bf=require("react");var fU=require("react/jsx-runtime"),ZH=({data:f})=>{let{name:U,key:H,value:D,useSocketioSupport:P,useCentrifugeSupport:Z,useMittSupport:z,centrifugeChannel:T}=f,[$,G]=Bf.useState(D);return Bf.useEffect(()=>{G(D)},[D]),Bf.useEffect(()=>{if(typeof window==="undefined")return;let X=window.Telegram?.WebApp?.SecureStorage;if(!X)return;X.setItem(H,$)},[H,$]),fU.jsx(_,{card:"SecureStorageCard",data:f,useSocketioSupport:P,useCentrifugeSupport:Z,useMittSupport:z,centrifugeChannel:T,methods:{update:({value:X})=>{G(X)},remove:()=>{let X=window.Telegram?.WebApp?.SecureStorage;if(X)X.removeItem(H);G("")}},children:fU.jsx("input",{type:"hidden",id:U,name:U,value:$})})},UD=ZH;var DD=C({name:"SecureStorageCard",component:UD,metadata:{author:"PieData"}});var S=require("react");var UU=require("react/jsx-runtime"),zH=({data:f,content:U})=>{let{useLoader:H,noReturn:D,returnType:P,useSocketioSupport:Z,useCentrifugeSupport:z,useMittSupport:T,centrifugeChannel:$}=f,G=S.useContext(F),X=S.useContext(x)??K,[B,q]=S.useState(!1),[Y,I]=S.useState(null),V=S.useRef(U),J=S.useContext(N),Q=S.useCallback((R)=>{if(R===null)q(!0);else if(q(!1),!D)V.current=R;if(!D)I(R)},[D]),W=S.useCallback((R)=>{V.current=R.content,I(R.content)},[]),O=S.useCallback((R)=>{if(R===null)q(!0);else if(q(!1),!D)for(let Qf of R)J?.emit(Qf.name,Qf.data)},[D,J]);if(S.useEffect(()=>{I(U),q(!1)},[U]),!Y&&H)return G;return UU.jsx(_,{card:"AjaxGroupCard",data:f,methods:{changeContent:W},useSocketioSupport:Z,useCentrifugeSupport:z,useMittSupport:T,centrifugeChannel:$,children:UU.jsx(X,{uiConfig:Y??V.current,setUiAjaxConfiguration:P==="events"?O:Q})})},HD=zH;var PD=C({name:"AjaxGroupCard",component:HD,metadata:{author:"PieData",description:"Group card with AJAX support"}});var DU=require("react");var yf=require("react/jsx-runtime"),$H=({data:f,content:U,setUiAjaxConfiguration:H})=>{let{name:D,url:P,sx:Z}=f,z=DU.useContext(y),T=DU.useContext(x)??K;return yf.jsx(_,{card:D,data:f,children:yf.jsx("div",{style:Z,id:D,onClick:(G)=>{if(P)if(G.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(P))window.location.href=P;else z?.(P)},children:yf.jsx(T,{setUiAjaxConfiguration:H,uiConfig:U})})})},ZD=$H;var zD=C({name:"BoxCard",component:ZD,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});var Df=require("react"),Hf=require("@tanstack/react-query");var jf=require("react");var mf=require("react"),of=new Map,Ef=new Map;function kf(f,U){let H=`${f}::${U}`,D=f?of.get(H):void 0,[P,Z]=mf.useState(D??null);return mf.useEffect(()=>{if(!f)return;if(of.has(H)){Z(of.get(H));return}let z=Ef.get(H);if(!z)z=fetch(f+`api/support/${U}`,{method:"GET"}).then(($)=>$.json()).then(($)=>{return of.set(H,$),Ef.delete(H),$}).catch(($)=>{throw Ef.delete(H),$}),Ef.set(H,z);let T=!1;return z.then(($)=>{if(!T)Z($)}).catch(()=>{}),()=>{T=!0}},[f,U,H]),P}var HU=null,$D=null;function TD(){$D?.()}function PU(){if(typeof window==="undefined")return Promise.resolve();if(typeof window.sid!=="undefined")return Promise.resolve();if(!HU)HU=new Promise((f)=>{$D=()=>{f()}});return HU}var TH=({children:f})=>{let U=jf.useContext(k),H=Of(),D=kf(H,"socketIO"),P=(Z)=>{if(typeof window!=="undefined")window.sid=Z.sid,TD(),console.log(`SocketIO initialized: ${window.sid}`)};return jf.useEffect(()=>{if(!U)return;let Z=()=>{console.log("SocketIO connected")},z=(T)=>{console.log(`SocketIO disconnected: ${T}`),U.connect()};if(D)U.on("pieinit",P),U.on("connect",Z),U.on("disconnect",z),U.connect();return()=>{if(D)U.off("pieinit",P),U.off("connect",Z),U.off("disconnect",z),U.disconnect()}},[U,D]),f},l=TH;var xf=require("react");var GH=({children:f})=>{let U=xf.useContext(m),H=Of(),D=kf(H,"centrifuge");return xf.useEffect(()=>{if(!U)return;let P=()=>{console.log("Centrifuge connected")},Z=(z)=>{console.log("Centrifuge disconnected:",z)};if(D)U.on("connected",P),U.on("disconnected",Z),U.connect();return()=>{if(D)U.disconnect()}},[U,D]),f},r=GH;var VD=require("axios-date-transformer");var GD=require("react/jsx-runtime");function Uf(f,U,H){if(!U)return H;let D=f.replace(/^\//,""),P=U[D];if(!P)return H;return GD.jsx(wf,{uiConfig:P})}var w=require("react/jsx-runtime"),VH=({location:f,fallback:U,piecache:H,onError:D,queryOptions:P})=>{let Z=b(),z=g(),T=o(),$=Df.useMemo(()=>VD.createAxiosDateTransformer({baseURL:Z||""}),[Z]),G=Df.useMemo(()=>j(),[]),X=Df.useMemo(()=>Z?c(Z):null,[Z]),B=Df.useMemo(()=>Z?p(Z,z):null,[Z,z]),{data:q,isLoading:Y,error:I}=Hf.useQuery({queryKey:["uiConfig",f.pathname+f.search,Z],enabled:!!Z,queryFn:async()=>{let J=new URLSearchParams(f.search);J.set("__pieroot","web");let Q="/api/content"+f.pathname+"?"+J.toString();if(T)console.log("[PieRoot] Fetching UI configuration from:",Q);let W=await $.get(Q,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(T)console.log("[PieRoot] Received UI configuration:",W.data);return W.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(J)=>Math.min(1000*2**J,30000),...P}),V=Uf(f.pathname,H,U);if(!Z)return V??null;if(T)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",Z),console.log("[PieRoot] CENTRIFUGE_SERVER:",z),console.log("[PieRoot] Fallback provided:",!!U),console.log("[PieRoot] Piecache provided:",!!H);if(I){if(T)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 D?.(),V}if(Y||!q){if(T)console.log("[PieRoot] Loading state:",{isLoading:Y,hasUiConfiguration:!!q});return V}if(T)console.log("[PieRoot] UI configuration loaded successfully:",q),console.log("[PieRoot] Rendering UI with configuration");return w.jsx(N.Provider,{value:G,children:w.jsx(k.Provider,{value:X,children:w.jsx(m.Provider,{value:B,children:w.jsx(F.Provider,{value:U??w.jsx(w.Fragment,{}),children:w.jsx(l,{children:w.jsx(r,{children:w.jsx("form",{id:"piedata_global_form",action:Z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:w.jsx(K,{uiConfig:q})})})})})})})})},IH=(f)=>{let U=Df.useMemo(()=>new Hf.QueryClient,[]);return w.jsx(y.Provider,{value:f.onNavigate,children:w.jsx(u.Provider,{value:f.config,children:w.jsx(Hf.QueryClientProvider,{client:U,children:w.jsx(VH,{...f})})})})},ID=IH;var Pf=require("react"),Zf=require("@tanstack/react-query");var JD=require("axios-date-transformer");var df=require("react");var uf=({onError:f}={})=>{let[U,H]=df.useState(null),D=JU();return df.useEffect(()=>{if(typeof window==="undefined")return;let P=window.Telegram?.WebApp;if(!P)return;try{P.ready?.()}catch(Z){f?.()}if(D==="telegram_expanded"&&(P.platform==="ios"||P.platform==="android"))P.expand();H(P)},[]),U};var L=require("react/jsx-runtime"),JH=({location:f,fallback:U,piecache:H,onError:D,queryOptions:P})=>{let Z=b(),z=g(),T=o(),$=Pf.useMemo(()=>JD.createAxiosDateTransformer({baseURL:Z}),[Z]),G=Pf.useMemo(()=>j(),[]),X=Pf.useMemo(()=>Z?c(Z):null,[Z]),B=Pf.useMemo(()=>Z?p(Z,z):null,[Z,z]),q=uf({onError:D}),{data:Y,isLoading:I,error:V}=Zf.useQuery({queryKey:["uiConfig",f.pathname+f.search,q?.initData],enabled:!!q?.initData,queryFn:async()=>{let Q=new URLSearchParams(f.search);if(Q.set("__pieroot","telegram"),q?.initData)Q.set("initData",q.initData);let W="/api/content"+f.pathname+"?"+Q.toString();if(T)console.log("[PieRoot] Fetching UI configuration from:",W);let O=await $.get(W,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(T)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),...P}),J=Uf(f.pathname,H,U);if(!Z)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(V&&T)return console.error("[PieRoot] Error fetching UI configuration:",V),console.error("[PieRoot] Error details:",{message:V.message,status:V.response?.status,data:V.response?.data}),D?.(),J;if(I||!Y){if(T)console.log("[PieRoot] Loading state:",{isLoading:I,hasUiConfiguration:!!Y});return J}if(T)console.log("[PieRoot] UI configuration loaded successfully:",Y),console.log("[PieRoot] Rendering UI with configuration");return L.jsx(N.Provider,{value:G,children:L.jsx(k.Provider,{value:X,children:L.jsx(m.Provider,{value:B,children:L.jsx(F.Provider,{value:U??L.jsx(L.Fragment,{}),children:L.jsx(l,{children:L.jsx(r,{children:L.jsx("form",{id:"piedata_global_form",action:Z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:L.jsx(K,{uiConfig:Y})})})})})})})})},YH=(f)=>{let U=Pf.useMemo(()=>new Zf.QueryClient,[]);return L.jsx(y.Provider,{value:f.onNavigate,children:L.jsx(u.Provider,{value:f.config,children:L.jsx(Zf.QueryClientProvider,{client:U,children:L.jsx(JH,{...f})})})})},YD=YH;var zf=require("react"),bf=require("@tanstack/react-query");var A=require("react/jsx-runtime"),XH=({location:f,fallback:U,children:H})=>{let D=b(),P=g(),Z=o(),z=zf.useMemo(()=>j(),[]),T=zf.useMemo(()=>D?c(D):null,[D]),$=zf.useMemo(()=>D?p(D,P):null,[D,P]);if(Z)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",D),console.log("[PieRoot] CENTRIFUGE_SERVER:",P),console.log("[PieRoot] Fallback provided:",!!U);return A.jsx(N.Provider,{value:z,children:A.jsx(k.Provider,{value:T,children:A.jsx(m.Provider,{value:$,children:A.jsx(F.Provider,{value:U??A.jsx(A.Fragment,{}),children:A.jsx(l,{children:A.jsx(r,{children:A.jsx("form",{id:"piedata_global_form",action:D+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:H})})})})})})})},qH=(f)=>{let[U]=zf.useState(()=>new bf.QueryClient);return A.jsx(y.Provider,{value:f.onNavigate,children:A.jsx(u.Provider,{value:f.config,children:A.jsx(bf.QueryClientProvider,{client:U,children:A.jsx(XH,{...f})})})})},XD=qH;var $f=require("react"),Tf=require("@tanstack/react-query");var BD=require("axios-date-transformer");var vf=require("react"),qD=()=>{let[f,U]=vf.useState(null);return vf.useEffect(()=>{if(typeof window==="undefined")return;let H=window.WebApp;if(!H)return;H.ready(),U(H)},[]),f};var M=require("react/jsx-runtime"),BH=({location:f,fallback:U,piecache:H,onError:D,queryOptions:P})=>{let Z=b(),z=g(),T=o(),$=$f.useMemo(()=>BD.createAxiosDateTransformer({baseURL:Z}),[Z]),G=$f.useMemo(()=>j(),[]),X=$f.useMemo(()=>Z?c(Z):null,[Z]),B=$f.useMemo(()=>Z?p(Z,z):null,[Z,z]),q=qD(),{data:Y,isLoading:I,error:V}=Tf.useQuery({queryKey:["uiConfig",f.pathname+f.search,q?.initData],queryFn:async()=>{let Q=new URLSearchParams(f.search);if(Q.set("__pieroot","max"),q?.initData)Q.set("initData",q.initData);let W="/api/content"+f.pathname+"?"+Q.toString();if(T)console.log("[PieRoot] Fetching UI configuration from:",W);let O=await $.get(W,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(T)console.log("[PieRoot] Received UI configuration:",O.data);return O.data},enabled:!!q?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Q)=>Math.min(1000*2**Q,30000),...P}),J=Uf(f.pathname,H,U);if(!Z)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(V&&T)return console.error("[PieRoot] Error fetching UI configuration:",V),console.error("[PieRoot] Error details:",{message:V.message,status:V.response?.status,data:V.response?.data}),D?.(),J;if(I||!Y){if(T)console.log("[PieRoot] Loading state:",{isLoading:I,hasUiConfiguration:!!Y});return J}if(T)console.log("[PieRoot] UI configuration loaded successfully:",Y),console.log("[PieRoot] Rendering UI with configuration");return M.jsx(N.Provider,{value:G,children:M.jsx(k.Provider,{value:X,children:M.jsx(m.Provider,{value:B,children:M.jsx(F.Provider,{value:U??M.jsx(M.Fragment,{}),children:M.jsx(l,{children:M.jsx(r,{children:M.jsx("form",{id:"piedata_global_form",action:Z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:M.jsx(K,{uiConfig:Y})})})})})})})})},QH=(f)=>{let U=$f.useMemo(()=>new Tf.QueryClient,[]);return M.jsx(y.Provider,{value:f.onNavigate,children:M.jsx(u.Provider,{value:f.config,children:M.jsx(Tf.QueryClientProvider,{client:U,children:M.jsx(BH,{...f})})})})},QD=QH;var WD=require("react"),WH=(f,U={},H=[],D,P)=>{let Z=P?.renderingLogEnabled??!1,z=P?.timeout,T=P?.retryPolicy,$=T?.maxRetries??0,G=T?.baseDelay??1000,X=T?.retryOn??[502,503,504];if(Z)console.log("Registering AJAX: ",D,U,H);return async(B={})=>{if(typeof window==="undefined"||typeof document==="undefined"){if(Z)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}let q=P?.apiServer;if(!q){if(Z)console.warn("AJAX skipped: apiServer is missing");return}if(!D||!f){if(Z)console.warn("AJAX skipped: pathname or setUiAjaxConfiguration is missing");return}if(H.includes("sid"))await PU();let Y=new FormData;for(let[J,Q]of Object.entries({...U,...B}))Y.append(J,Q);for(let J of H)if(J==="sid"){if(!window.sid)throw new Error("SocketIO isn't initialized properly");Y.append("sid",window.sid)}else{let Q=document.getElementsByName(J);if(!Q.length){if(Z)console.warn(`No input found with name ${J}`);continue}let W=Q[0];if(W instanceof HTMLInputElement)if(W.type==="file"&&W.files)Array.from(W.files).forEach((O)=>Y.append(J,O));else Y.append(J,W.value);else if(W instanceof HTMLTextAreaElement)Y.append(J,W.value)}let I=q+"api/ajax_content"+D;f(null);let V;for(let J=0;J<=$;J++){if(J>0){let O=G*2**(J-1);if(Z)console.log(`AJAX retry ${J}/${$} after ${O}ms`);await new Promise((R)=>setTimeout(R,O))}let Q=z!=null?new AbortController:null,W=Q&&setTimeout(()=>Q.abort(),z);try{let O=await fetch(I,{method:"POST",body:Y,signal:Q?.signal});if(W)clearTimeout(W);if(!O.ok&&X.includes(O.status)&&J<$){V=new Error(`HTTP ${O.status}`);continue}let Qf=(O.headers.get("content-type")||"").includes("application/json");if(!!O.body?.getReader&&!Qf){let Wf=O.body.getReader(),SD=new TextDecoder,n="";while(!0){let{done:pf,value:AD}=await Wf.read();if(pf)break;n+=SD.decode(AD,{stream:!0});let zU=n.split(`
|
|
3
|
+
`);n=zU.pop()??"";for(let ND of zU){let cf=ND.trim();if(!cf)continue;try{let yD=JSON.parse(cf);f([yD])}catch{if(Z)console.warn("Failed to parse streamed line:",cf)}}}if(n.trim())try{let pf=JSON.parse(n);f([pf])}catch{if(Z)console.warn("Failed to parse final streamed line:",n)}return{}}else{let Wf=await O.json();return f(Wf),Wf}}catch(O){if(W)clearTimeout(W);if(V=O,J<$)continue;if(Z)console.error("AJAX request failed:",O);return f(null),O}}if(Z)console.error("AJAX request failed after retries:",V);return f(null),V}},CD=(f,U={},H=[],D,P)=>{let{apiServer:Z,enableRenderingLog:z}=s(),T=JSON.stringify(U),$=JSON.stringify(H),G=JSON.stringify(P);return WD.useMemo(()=>WH(f,U,H,D,{apiServer:Z,renderingLogEnabled:z,timeout:P?.timeout,retryPolicy:P?.retryPolicy}),[f,T,$,D,Z,z,G])};var OD=require("@openai/agents"),gf=require("react");var _D=/^pie(.+?)_(.+)$/;function ZU(f=j(),U={}){let H=[],D=new Set;for(let P of f.all.keys()){if(typeof P!=="string")continue;let Z=P.match(_D);if(!Z)continue;let[,z,T]=Z,$={methodName:z,cardName:T,eventName:P};if(U.filter&&!U.filter($))continue;let G=U.nameFor?.($)??`${T}_${z}`;if(D.has(G))continue;D.add(G);let X=U.describe?.($)??`Invokes the "${z}" method on the PieCard "${T}" by emitting the in-process mitt event "${P}". The optional "payload" argument is forwarded verbatim to the card's handler.`;H.push(OD.tool({name:G,description:X,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(B)=>{let q=B?.payload;return f.emit(P,q),`Emitted "${P}"`}}))}return H}function RD(f={}){let H=gf.useContext(N)??j(),D=[];for(let $ of H.all.keys())if(typeof $==="string"&&_D.test($))D.push($);D.sort();let P=D.join("|"),{filter:Z,describe:z,nameFor:T}=f;return gf.useMemo(()=>ZU(H,{filter:Z,describe:z,nameFor:T}),[H,P,Z,z,T])}var FD=require("clsx"),KD=require("tailwind-merge");function wD(...f){return KD.twMerge(FD.clsx(f))}var LD=()=>{if(typeof document==="undefined")return;let f=document.getElementById("piedata_global_form");f&&f.submit()};var MD=(f,U)=>`${f}${_f}${U}`;
|
|
@@ -149,6 +149,150 @@
|
|
|
149
149
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
|
+
{
|
|
153
|
+
"card": "SessionStorageCard",
|
|
154
|
+
"data": {
|
|
155
|
+
"type": "object",
|
|
156
|
+
"properties": {
|
|
157
|
+
"name": {
|
|
158
|
+
"type": "string"
|
|
159
|
+
},
|
|
160
|
+
"key": {
|
|
161
|
+
"type": "string"
|
|
162
|
+
},
|
|
163
|
+
"value": {
|
|
164
|
+
"type": "string"
|
|
165
|
+
},
|
|
166
|
+
"useSocketioSupport": {
|
|
167
|
+
"type": "boolean"
|
|
168
|
+
},
|
|
169
|
+
"useCentrifugeSupport": {
|
|
170
|
+
"type": "boolean"
|
|
171
|
+
},
|
|
172
|
+
"useMittSupport": {
|
|
173
|
+
"type": "boolean"
|
|
174
|
+
},
|
|
175
|
+
"centrifugeChannel": {
|
|
176
|
+
"type": "string"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"additionalProperties": false,
|
|
180
|
+
"required": [
|
|
181
|
+
"key",
|
|
182
|
+
"name",
|
|
183
|
+
"value"
|
|
184
|
+
],
|
|
185
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"card": "DeviceStorageCard",
|
|
190
|
+
"data": {
|
|
191
|
+
"type": "object",
|
|
192
|
+
"properties": {
|
|
193
|
+
"name": {
|
|
194
|
+
"type": "string"
|
|
195
|
+
},
|
|
196
|
+
"key": {
|
|
197
|
+
"type": "string"
|
|
198
|
+
},
|
|
199
|
+
"value": {
|
|
200
|
+
"type": "string"
|
|
201
|
+
},
|
|
202
|
+
"useSocketioSupport": {
|
|
203
|
+
"type": "boolean"
|
|
204
|
+
},
|
|
205
|
+
"useCentrifugeSupport": {
|
|
206
|
+
"type": "boolean"
|
|
207
|
+
},
|
|
208
|
+
"useMittSupport": {
|
|
209
|
+
"type": "boolean"
|
|
210
|
+
},
|
|
211
|
+
"centrifugeChannel": {
|
|
212
|
+
"type": "string"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"additionalProperties": false,
|
|
216
|
+
"required": [
|
|
217
|
+
"key",
|
|
218
|
+
"name",
|
|
219
|
+
"value"
|
|
220
|
+
],
|
|
221
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"card": "CloudStorageCard",
|
|
226
|
+
"data": {
|
|
227
|
+
"type": "object",
|
|
228
|
+
"properties": {
|
|
229
|
+
"name": {
|
|
230
|
+
"type": "string"
|
|
231
|
+
},
|
|
232
|
+
"key": {
|
|
233
|
+
"type": "string"
|
|
234
|
+
},
|
|
235
|
+
"value": {
|
|
236
|
+
"type": "string"
|
|
237
|
+
},
|
|
238
|
+
"useSocketioSupport": {
|
|
239
|
+
"type": "boolean"
|
|
240
|
+
},
|
|
241
|
+
"useCentrifugeSupport": {
|
|
242
|
+
"type": "boolean"
|
|
243
|
+
},
|
|
244
|
+
"useMittSupport": {
|
|
245
|
+
"type": "boolean"
|
|
246
|
+
},
|
|
247
|
+
"centrifugeChannel": {
|
|
248
|
+
"type": "string"
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
"additionalProperties": false,
|
|
252
|
+
"required": [
|
|
253
|
+
"key",
|
|
254
|
+
"name",
|
|
255
|
+
"value"
|
|
256
|
+
],
|
|
257
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"card": "SecureStorageCard",
|
|
262
|
+
"data": {
|
|
263
|
+
"type": "object",
|
|
264
|
+
"properties": {
|
|
265
|
+
"name": {
|
|
266
|
+
"type": "string"
|
|
267
|
+
},
|
|
268
|
+
"key": {
|
|
269
|
+
"type": "string"
|
|
270
|
+
},
|
|
271
|
+
"value": {
|
|
272
|
+
"type": "string"
|
|
273
|
+
},
|
|
274
|
+
"useSocketioSupport": {
|
|
275
|
+
"type": "boolean"
|
|
276
|
+
},
|
|
277
|
+
"useCentrifugeSupport": {
|
|
278
|
+
"type": "boolean"
|
|
279
|
+
},
|
|
280
|
+
"useMittSupport": {
|
|
281
|
+
"type": "boolean"
|
|
282
|
+
},
|
|
283
|
+
"centrifugeChannel": {
|
|
284
|
+
"type": "string"
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
"additionalProperties": false,
|
|
288
|
+
"required": [
|
|
289
|
+
"key",
|
|
290
|
+
"name",
|
|
291
|
+
"value"
|
|
292
|
+
],
|
|
293
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
294
|
+
}
|
|
295
|
+
},
|
|
152
296
|
{
|
|
153
297
|
"card": "AjaxGroupCard",
|
|
154
298
|
"data": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mittAgentTools.test.d.ts","sourceRoot":"","sources":["../../src/tests/mittAgentTools.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,76 @@
|
|
|
1
1
|
import '../types';
|
|
2
2
|
import { SetUiAjaxConfigurationType } from '../types';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Retry policy configuration for AJAX requests.
|
|
5
|
+
*/
|
|
6
|
+
export type RetryPolicy = {
|
|
7
|
+
/** Maximum number of retry attempts (default: 0 — no retries). */
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
/** Base delay in ms between retries (default: 1000). Doubled on each attempt. */
|
|
10
|
+
baseDelay?: number;
|
|
11
|
+
/** HTTP status codes that should trigger a retry (default: [502, 503, 504]). Timeouts and network errors always retry regardless of this list. */
|
|
12
|
+
retryOn?: number[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Options for {@link getAjaxSubmit}. Passed explicitly so that the helper can
|
|
16
|
+
* stay a plain function — callers forward the values they already obtained
|
|
17
|
+
* from {@link usePieConfig} instead of the helper calling hooks on its own.
|
|
18
|
+
*/
|
|
4
19
|
export type GetAjaxSubmitOptions = {
|
|
20
|
+
/** Base URL of the PieUI API server (must end with `/`). */
|
|
5
21
|
apiServer?: string | null;
|
|
22
|
+
/** When `true`, the helper will log registration and error details. */
|
|
6
23
|
renderingLogEnabled?: boolean;
|
|
24
|
+
/** Request timeout in milliseconds. No timeout if omitted. */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
/** Retry policy for failed requests. No retries if omitted. */
|
|
27
|
+
retryPolicy?: RetryPolicy;
|
|
7
28
|
};
|
|
8
|
-
|
|
9
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Builds an async "submit" function that issues an AJAX request to
|
|
31
|
+
* `api/ajax_content{pathname}` and streams (or JSON-decodes) the response
|
|
32
|
+
* into a `setUiAjaxConfiguration` callback supplied by an Ajax container.
|
|
33
|
+
*
|
|
34
|
+
* The returned function collects form data from:
|
|
35
|
+
* 1. the static `kwargs` object,
|
|
36
|
+
* 2. any `extraKwargs` passed at call time,
|
|
37
|
+
* 3. named inputs from the DOM listed in `depsNames` (including `sid`,
|
|
38
|
+
* which is resolved via {@link waitForSidAvailable}), and
|
|
39
|
+
* 4. file inputs (multiple files supported).
|
|
40
|
+
*
|
|
41
|
+
* If the server streams NDJSON, each line is parsed as a `UIEventType` and
|
|
42
|
+
* applied incrementally; otherwise the full JSON body replaces the current
|
|
43
|
+
* Ajax configuration.
|
|
44
|
+
*
|
|
45
|
+
* On missing `apiServer`, `pathname` or `setUiAjaxConfiguration` the helper
|
|
46
|
+
* returns a no-op function so call sites do not need to null-check.
|
|
47
|
+
*
|
|
48
|
+
* @param setUiAjaxConfiguration Setter provided by the enclosing Ajax card.
|
|
49
|
+
* @param kwargs Static key/value pairs appended to the request.
|
|
50
|
+
* @param depsNames Names of DOM inputs whose current values should
|
|
51
|
+
* also be sent.
|
|
52
|
+
* @param pathname Path segment appended to `api/ajax_content`.
|
|
53
|
+
* @param options See {@link GetAjaxSubmitOptions}.
|
|
54
|
+
* @returns An `async (extraKwargs?) => Promise<any>` submit function.
|
|
55
|
+
*/
|
|
56
|
+
export declare const getAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record<string, any>, depsNames?: Array<string>, pathname?: string, options?: GetAjaxSubmitOptions) => (extraKwargs?: Record<string, any>) => Promise<any>;
|
|
57
|
+
/**
|
|
58
|
+
* React hook wrapper around {@link getAjaxSubmit}. Reads `apiServer` and
|
|
59
|
+
* `enableRenderingLog` from {@link usePieConfig} and memoizes the submit
|
|
60
|
+
* function so that stable inline literals from server-driven UIConfig don't
|
|
61
|
+
* cause a new function identity on every render — memoization is keyed on
|
|
62
|
+
* the stringified `kwargs`/`depsNames` rather than their reference.
|
|
63
|
+
*
|
|
64
|
+
* @param setUiAjaxConfiguration Setter provided by the enclosing Ajax card.
|
|
65
|
+
* @param kwargs Static key/value pairs appended to the request.
|
|
66
|
+
* @param depsNames Names of DOM inputs whose current values should
|
|
67
|
+
* be sent alongside the request.
|
|
68
|
+
* @param pathname Path segment appended to `api/ajax_content`.
|
|
69
|
+
* @param options Optional `timeout` (ms) and `retryPolicy`.
|
|
70
|
+
* @returns A memoized submit function; see {@link getAjaxSubmit}.
|
|
71
|
+
*/
|
|
72
|
+
export declare const useAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record<string, any>, depsNames?: Array<string>, pathname?: string, options?: {
|
|
73
|
+
timeout?: number;
|
|
74
|
+
retryPolicy?: RetryPolicy;
|
|
75
|
+
}) => (extraKwargs?: Record<string, any>) => Promise<any>;
|
|
10
76
|
//# sourceMappingURL=ajaxCommonUtils.d.ts.map
|
|
@@ -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,
|
|
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,iBA6LtD,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,oBAnN9B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBA+OjD,CAAA"}
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import { Centrifuge } from 'centrifuge';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a cached {@link Centrifuge} client for the given API/Centrifuge
|
|
4
|
+
* server pair, creating one on first access. Tokens are fetched on demand
|
|
5
|
+
* from `{apiServer}api/centrifuge/gen_token`; a 403 response throws a
|
|
6
|
+
* `Centrifuge.UnauthorizedError` so the client treats it as an auth failure
|
|
7
|
+
* and does not retry indefinitely.
|
|
8
|
+
*
|
|
9
|
+
* The cache is keyed by `"${apiServer}::${centrifugeServer}"`, so repeated
|
|
10
|
+
* calls with the same arguments always return the same instance — which is
|
|
11
|
+
* important because `Centrifuge` holds a live WebSocket connection.
|
|
12
|
+
*
|
|
13
|
+
* @param apiServer Base URL of the PieUI API server (must end with `/`).
|
|
14
|
+
* @param centrifugeServer WebSocket URL of the Centrifuge server. When
|
|
15
|
+
* omitted, the function returns `null` and the
|
|
16
|
+
* feature is disabled.
|
|
17
|
+
* @returns A shared Centrifuge instance, or `null` if no server was provided.
|
|
18
|
+
*/
|
|
2
19
|
export declare const getCentrifuge: (apiServer: string, centrifugeServer?: string) => Centrifuge | null;
|
|
20
|
+
/**
|
|
21
|
+
* React context that exposes the current {@link Centrifuge} client to the
|
|
22
|
+
* component tree. Populated by PieRoot variants; consumers read it to create
|
|
23
|
+
* subscriptions scoped to a specific `PieCard`.
|
|
24
|
+
*/
|
|
3
25
|
declare const CentrifugeIOContext: import("react").Context<Centrifuge | null>;
|
|
4
26
|
export default CentrifugeIOContext;
|
|
5
27
|
//# sourceMappingURL=centrifuge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"centrifuge.d.ts","sourceRoot":"","sources":["../../src/util/centrifuge.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAIvC,eAAO,MAAM,aAAa,GACtB,WAAW,MAAM,EACjB,mBAAmB,MAAM,KAC1B,UAAU,GAAG,IAwBf,CAAA;AAED,QAAA,MAAM,mBAAmB,4CAAyC,CAAA;AAClE,eAAe,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"centrifuge.d.ts","sourceRoot":"","sources":["../../src/util/centrifuge.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAIvC;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,GACtB,WAAW,MAAM,EACjB,mBAAmB,MAAM,KAC1B,UAAU,GAAG,IAwBf,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,mBAAmB,4CAAyC,CAAA;AAClE,eAAe,mBAAmB,CAAA"}
|
package/dist/util/fallback.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* React context that carries the "loading / missing data" fallback node used
|
|
4
|
+
* by PieUI. PieRoot variants populate it from their `fallback` prop, and
|
|
5
|
+
* dynamic components (lazy-loaded cards, deferred UI regions) read from this
|
|
6
|
+
* context so that every empty state in a tree shares the same visual.
|
|
7
|
+
*/
|
|
2
8
|
declare const FallbackContext: import("react").Context<ReactNode>;
|
|
3
9
|
export default FallbackContext;
|
|
4
10
|
//# sourceMappingURL=fallback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../src/util/fallback.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;AAEhD,QAAA,MAAM,eAAe,oCAAkC,CAAA;AAEvD,eAAe,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../src/util/fallback.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;AAEhD;;;;;GAKG;AACH,QAAA,MAAM,eAAe,oCAAkC,CAAA;AAEvD,eAAe,eAAe,CAAA"}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Submits the hidden global PieUI form (`#piedata_global_form`) that is
|
|
3
|
+
* rendered by every PieRoot variant. All PieUI inputs live inside this form,
|
|
4
|
+
* so calling this function triggers a native multipart POST to the server
|
|
5
|
+
* endpoint wired up at render time (usually `/api/process{pathname}`).
|
|
6
|
+
*
|
|
7
|
+
* No-ops on the server and when the form element has not been mounted yet.
|
|
8
|
+
*/
|
|
1
9
|
export declare const submitGlobalForm: () => void;
|
|
2
10
|
//# sourceMappingURL=globalForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalForm.d.ts","sourceRoot":"","sources":["../../src/util/globalForm.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,YAO5B,CAAA"}
|
|
1
|
+
{"version":3,"file":"globalForm.d.ts","sourceRoot":"","sources":["../../src/util/globalForm.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,YAO5B,CAAA"}
|
package/dist/util/lazy.d.ts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import { ComponentType, LazyExoticComponent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `React.lazy()` wrapper that dedupes identical dynamic imports by name.
|
|
4
|
+
*
|
|
5
|
+
* Calling `trackLazy(loader, 'Foo')` multiple times — for example from a
|
|
6
|
+
* registered component and from a manual preload — will share a single
|
|
7
|
+
* module promise, so the underlying `import()` only runs once even if the
|
|
8
|
+
* component mounts and unmounts several times.
|
|
9
|
+
*
|
|
10
|
+
* @param loader A dynamic `import()` factory returning a module with a
|
|
11
|
+
* default export.
|
|
12
|
+
* @param name Stable cache key; typically the registered component name.
|
|
13
|
+
* @returns A memoized `LazyExoticComponent` suitable for use with Suspense.
|
|
14
|
+
*/
|
|
2
15
|
export declare function trackLazy<T extends ComponentType<any>>(loader: () => Promise<{
|
|
3
16
|
default: T;
|
|
4
17
|
}>, name: string): LazyExoticComponent<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Eagerly kicks off a dynamic import and stores its promise in the same
|
|
20
|
+
* cache used by {@link trackLazy}, so that a later `React.lazy` render of
|
|
21
|
+
* the same `name` resolves synchronously once the module has loaded.
|
|
22
|
+
*
|
|
23
|
+
* Safe to call when the `loader` is `undefined` (no-op) or when the module
|
|
24
|
+
* has already been preloaded (returns the cached promise).
|
|
25
|
+
*
|
|
26
|
+
* @param name Stable cache key; must match the name used by `trackLazy`.
|
|
27
|
+
* @param loader Optional dynamic `import()` factory.
|
|
28
|
+
* @returns The cached module promise, or `undefined` when no loader was provided.
|
|
29
|
+
*/
|
|
5
30
|
export declare const preloadComponent: (name: string, loader?: () => Promise<any>) => Promise<any>;
|
|
6
31
|
//# sourceMappingURL=lazy.d.ts.map
|
package/dist/util/lazy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/util/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,aAAa,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAA;AAIhE,wBAAgB,SAAS,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EAClD,MAAM,EAAE,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC,EACrC,IAAI,EAAE,MAAM,GACb,mBAAmB,CAAC,CAAC,CAAC,CASxB;AAED,eAAO,MAAM,gBAAgB,GACzB,MAAM,MAAM,EACZ,SAAS,MAAM,OAAO,CAAC,GAAG,CAAC,iBAO9B,CAAA"}
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/util/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,aAAa,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAA;AAIhE;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EAClD,MAAM,EAAE,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC,EACrC,IAAI,EAAE,MAAM,GACb,mBAAmB,CAAC,CAAC,CAAC,CASxB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GACzB,MAAM,MAAM,EACZ,SAAS,MAAM,OAAO,CAAC,GAAG,CAAC,iBAO9B,CAAA"}
|
package/dist/util/mitt.d.ts
CHANGED
|
@@ -1,8 +1,45 @@
|
|
|
1
1
|
import { Emitter } from 'mitt';
|
|
2
|
+
/**
|
|
3
|
+
* Event map used by the PieUI Mitt emitter. Event names follow the convention
|
|
4
|
+
* `pie{methodName}_{componentName}` and the payload is an arbitrary value
|
|
5
|
+
* forwarded verbatim to registered handlers.
|
|
6
|
+
*/
|
|
2
7
|
export type MittEvents = {
|
|
3
8
|
[key: string]: any;
|
|
4
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Returns the lazily-initialized singleton Mitt emitter used for cross-component
|
|
12
|
+
* PieUI messaging outside of any React context.
|
|
13
|
+
*
|
|
14
|
+
* Prefer {@link usePieEmit} from within React components — it honours the
|
|
15
|
+
* provider-supplied emitter from `MittContext` when one is available.
|
|
16
|
+
*
|
|
17
|
+
* @returns The process-wide Mitt emitter instance.
|
|
18
|
+
*/
|
|
5
19
|
export declare function getEmitter(): Emitter<MittEvents>;
|
|
20
|
+
/**
|
|
21
|
+
* React context carrying the Mitt emitter injected by a PieRoot provider.
|
|
22
|
+
* Consumers that need to emit from within a component tree should read from
|
|
23
|
+
* this context (directly or via {@link usePieEmit}) so that events flow
|
|
24
|
+
* through the same emitter the surrounding roots use.
|
|
25
|
+
*/
|
|
6
26
|
declare const MittContext: import("react").Context<Emitter<MittEvents> | null>;
|
|
27
|
+
/**
|
|
28
|
+
* React hook that returns a stable emitter function bound to a specific
|
|
29
|
+
* `PieCard` name. The returned callback accepts `(methodName, payload?)` and
|
|
30
|
+
* dispatches through `MittContext` when available, falling back to the global
|
|
31
|
+
* singleton returned by {@link getEmitter} when used outside of a PieRoot.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* const emit = usePieEmit('mySequence')
|
|
36
|
+
* emit('changeContent', { content: newConfig })
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param name The `data.name` of the target `PieCard` — must match the card
|
|
40
|
+
* that was rendered with `useMittSupport={true}`.
|
|
41
|
+
* @returns A memoized `(methodName: string, payload?: any) => void` function.
|
|
42
|
+
*/
|
|
43
|
+
export declare function usePieEmit(name: string): (methodName: string, payload?: any) => void;
|
|
7
44
|
export default MittContext;
|
|
8
45
|
//# sourceMappingURL=mitt.d.ts.map
|
package/dist/util/mitt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mitt.d.ts","sourceRoot":"","sources":["../../src/util/mitt.ts"],"names":[],"mappings":"AAEA,OAAa,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGpC,MAAM,MAAM,UAAU,GAAG;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AAID,wBAAgB,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,CAKhD;AAED,QAAA,MAAM,WAAW,qDAAkD,CAAA;AAEnE,eAAe,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"mitt.d.ts","sourceRoot":"","sources":["../../src/util/mitt.ts"],"names":[],"mappings":"AAEA,OAAa,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGpC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AAID;;;;;;;;GAQG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,CAKhD;AAED;;;;;GAKG;AACH,QAAA,MAAM,WAAW,qDAAkD,CAAA;AAEnE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,gBAGlB,MAAM,YAAY,GAAG,UAKzC;AAED,eAAe,WAAW,CAAA"}
|