@piedata/pieui 2.0.4 → 2.0.5
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/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.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/util/ajaxCommonUtils.d.ts +48 -1
- 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/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 ZZ=Object.create;var{getPrototypeOf:zZ,defineProperty:YU,getOwnPropertyNames:pU,getOwnPropertyDescriptor:$Z}=Object,nU=Object.prototype.hasOwnProperty;var sU=(U,H,z)=>{z=U!=null?ZZ(zZ(U)):{};let Z=H||!U||!U.__esModule?YU(z,"default",{value:U,enumerable:!0}):z;for(let D of pU(U))if(!nU.call(Z,D))YU(Z,D,{get:()=>U[D],enumerable:!0});return Z},lU=new WeakMap,DZ=(U)=>{var H=lU.get(U),z;if(H)return H;if(H=YU({},"__esModule",{value:!0}),U&&typeof U==="object"||typeof U==="function")pU(U).map((Z)=>!nU.call(H,Z)&&YU(H,Z,{get:()=>U[Z],enumerable:!(z=$Z(U,Z))||z.enumerable}));return lU.set(U,H),H};var GZ=(U,H)=>{for(var z in H)YU(U,z,{get:H[z],enumerable:!0,configurable:!0,set:(Z)=>H[z]=()=>Z})};var dZ={};GZ(dZ,{useWebApp:()=>kU,usePieEmit:()=>$H,useOpenAIWebRTC:()=>XU,useAjaxSubmit:()=>iH,unregisterComponent:()=>JH,submitGlobalForm:()=>eH,registry:()=>g,registerPieComponent:()=>O,registerMultipleComponents:()=>TH,pieName:()=>UZ,hasComponent:()=>YH,getRegistrySize:()=>qH,getRegistryEntry:()=>t,getComponentMeta:()=>VH,getAllRegisteredComponents:()=>XH,cn:()=>aH,UnionCard:()=>WH,UIRendererContext:()=>m,UILoading:()=>KU,UI:()=>L,SequenceCard:()=>RH,PieTelegramRoot:()=>cH,PieRoot:()=>gH,PieMaxRoot:()=>nH,PieCard:()=>W,PieBaseRoot:()=>uH,PIEBREAK:()=>_U,IOEventsCard:()=>jH,HiddenCard:()=>wH,HTMLEmbedCard:()=>NH,BoxCard:()=>mH,AutoRedirectCard:()=>EH,AjaxGroupCard:()=>xH});module.exports=DZ(dZ);var b=require("react");var BU=require("react"),v=BU.createContext(null),i=()=>{let U=BU.useContext(v);if(!U)throw new Error("usePieConfig must be used within PieConfigProvider");return U},d=()=>{let{apiServer:U}=i();return U},IU=d,h=()=>{let{centrifugeServer:U}=i();return U};var E=()=>{let{enableRenderingLog:U}=i();return U},iU=E,rU=()=>{let{pageProcessor:U}=i();return U};var _U="__piedemo__";var aU=require("react"),mU=require("centrifuge"),tU=new Map,c=(U,H)=>{if(!H)return null;let z=`${U}::${H}`,Z=tU.get(z);if(Z)return Z;async function D(){let G=await fetch(U+"api/centrifuge/gen_token");if(!G.ok){if(G.status===403)throw new mU.Centrifuge.UnauthorizedError("Backend is not answering");throw new Error(`Unexpected status code ${G.status}`)}return(await G.json()).token}let $=new mU.Centrifuge(H,{getToken:D});return tU.set(z,$),$},TZ=aU.createContext(null),k=TZ;var UH=require("socket.io-client"),HH=require("react"),eU=new Map,u=(U)=>{let H=eU.get(U);if(H)return H;let z=UH.io(U,{autoConnect:!1,transports:["websocket"]});return eU.set(U,z),z},JZ=HH.createContext(null),x=JZ;var ZH=sU(require("mitt")),r=require("react"),bU=null;function o(){if(!bU)bU=ZH.default();return bU}var zH=r.createContext(null);function $H(U){let H=r.useContext(zH);return r.useCallback((z,Z)=>{(H??o()).emit(`pie${z}_${U}`,Z)},[U,H])}var S=zH;var YZ=({card:U,data:H,children:z,useSocketioSupport:Z=!1,useCentrifugeSupport:D=!1,useMittSupport:$=!1,centrifugeChannel:G=void 0,methods:J=void 0})=>{let T=iU(),B=b.useRef(J);if(B.current=J,T)console.log("[PieCard] Rendering card:",U),console.log("[PieCard] Card data:",H),console.log("[PieCard] Component name:",H?.name),console.log("[PieCard] Real-time support:",{socketio:Z,centrifuge:D,mitt:$,centrifugeChannel:G}),console.log("[PieCard] Methods:",J?Object.keys(J):"none"),console.log("[PieCard] Has children:",!!z);let _=b.useContext(x),I=b.useContext(k),V=b.useContext(S);if(b.useEffect(()=>{if(!_||!Z||!B.current||!H.name){if(T&&Z)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!_,useSocketioSupport:Z,hasMethods:!!B.current,hasDataName:!!H?.name});return}let Y=Object.keys(B.current??{}).map((X)=>{let P=`pie${X}_${H.name}`;if(T)console.log(`[PieCard] Socket.IO registering event: ${P}`);let Q=(R)=>{B.current?.[X]?.(R)};return _.on(P,Q),[P,Q]});return()=>{Y.forEach(([X,P])=>{if(T)console.log(`[PieCard] Socket.IO unregistering event: ${X}`);_.off(X,P)})}},[_,H.name,Z]),b.useEffect(()=>{if(!I||!D||!G||!H.name){if(T&&D)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!I,useCentrifugeSupport:D,hasCentrifugeChannel:!!G,hasMethods:!!B.current,hasDataName:!!H?.name});return}let Y=Object.keys(B.current??{}).map((X)=>{let P=`pie${X}_${H.name}_${G}`;if(T)console.log(`[PieCard] Centrifuge subscribing to channel: ${P}`);let Q=I.newSubscription(P);return Q.on("publication",(R)=>{if(T)console.log(`[PieCard] Centrifuge received data on ${P}:`,R.data);B.current?.[X]?.(R.data)}),Q.subscribe(),Q});return()=>{Y.forEach((X)=>{if(T)console.log("[PieCard] Centrifuge unsubscribing from channel");X.unsubscribe(),I.removeSubscription(X)})}},[I,G,H.name,D]),b.useEffect(()=>{if(!V||!$||!H.name){if(T&&$)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!V,useMittSupport:$,hasMethods:!!B.current,hasDataName:!!H?.name});return}let q=Object.keys(B.current??{}),Y={};return q.forEach((X)=>{let P=`pie${X}_${H.name}`,Q=(R)=>{if(T)console.log(`[PieCard] Mitt registering event: ${P}`);B.current?.[X]?.(R)};Y[P]=Q,V.on(P,Q)}),()=>{Object.entries(Y).forEach(([X,P])=>{if(T)console.log(`[PieCard] Mitt unregistering event: ${X}`);V.off(X,P)})}},[V,H.name,$]),T)console.log("[PieCard] Rendering complete, returning children");return z},W=YZ;var DH=require("react"),vU=new Map;function GH(U,H){return DH.lazy(()=>{if(vU.has(H))return vU.get(H);let z=U().then((Z)=>Z);return vU.set(H,z),z})}var g=new Map,VZ=(U)=>{if(!U.name)throw new Error("Component registration requires a name");if(!U.component&&!U.loader)throw new Error(`Component "${U.name}" requires component or loader`);let H={name:U.name,component:U.component,loader:U.loader,metadata:U.metadata,fallback:U.fallback,isLazy:!1};if(!H.component&&H.loader)H.component=GH(H.loader,U.name),H.loader=void 0,H.isLazy=!0;return H};function O(U){let H=VZ(U);return g.set(H.name,H),H.component}var TH=(U)=>{U.forEach((H)=>O(H))},JH=(U)=>{g.delete(U)},YH=(U)=>{return g.has(U)},VH=(U)=>{return g.get(U)?.metadata},t=(U)=>{return g.get(U)},XH=()=>{return Array.from(g.keys())},qH=()=>{return g.size};var a=require("react");var BH=require("react"),PU=require("react/jsx-runtime"),XZ=BH.createContext(PU.jsx(PU.Fragment,{})),F=XZ;var QU=require("react/jsx-runtime");function qZ({uiConfig:U,setUiAjaxConfiguration:H}){let z=a.useContext(F),Z=E();if(Z)console.log("[UI] Rendering component:",U.card),console.log("[UI] Component data:",U.data),console.log("[UI] Component content:",U.content),console.log("[UI] Has setUiAjaxConfiguration:",!!H);let D=t(U.card);if(!D?.component){if(Z)console.warn(`[UI] Component not found in registry: ${U.card}`),console.log("[UI] Returning fallback component");return z}if(Z)console.log("[UI] Found component in registry:",{name:D.name,isLazy:D.isLazy,hasMetadata:!!D.metadata});let $=D.component,G=QU.jsx($,{data:U.data,content:U.content,setUiAjaxConfiguration:H});if(D.isLazy){if(Z)console.log("[UI] Rendering lazy component with Suspense:",D.name);return QU.jsx(a.Suspense,{fallback:D.fallback?QU.jsx(D.fallback,{}):z,children:G},`${D.name}`)}if(Z)console.log("[UI] Rendering component directly:",D.name);return G}var L=a.memo(qZ);var RU=require("react");var IH=require("react"),BZ=IH.createContext(null),m=BZ;var VU=require("react/jsx-runtime");function _H({uiConfig:U,setUiAjaxConfiguration:H}){let z=RU.useContext(F),Z=E();if(Z)console.log("[UILoading] Rendering fallback for:",U.card),console.log("[UILoading] Component data:",U.data),console.log("[UILoading] Component content:",U.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!H);let D=t(U.card);if(!D?.component){if(Z)console.warn(`[UILoading] Component not found in registry: ${U.card}`),console.log("[UILoading] Returning fallback component");return z}if(Z)console.log("[UILoading] Found component in registry:",{name:D.name,isLazy:D.isLazy,hasMetadata:!!D.metadata,hasFallback:!!D.fallback});if(D.fallback){if(Z)console.log("[UILoading] Rendering fallback for:",D.name);let J=D.fallback;return VU.jsx(J,{})}if(Z)console.log("[UILoading] No fallback, rendering full component:",D.name);let $=D.component,G=VU.jsx(m.Provider,{value:_H,children:VU.jsx($,{data:U.data,content:U.content,setUiAjaxConfiguration:H})});if(D.isLazy)return VU.jsx(RU.Suspense,{fallback:z,children:G},`${D.name}`);return G}var KU=_H;var PH=require("react");var OU=require("react/jsx-runtime"),IZ=({data:U,content:H,setUiAjaxConfiguration:z})=>{let{name:Z,sx:D}=U,$=PH.useContext(m)??L;return OU.jsx(W,{card:Z,data:U,children:OU.jsx("div",{style:D,id:Z,children:H.map((G,J)=>{return OU.jsx($,{uiConfig:G,setUiAjaxConfiguration:z},`children-${J}`)})})})},QH=IZ;var RH=O({name:"SequenceCard",component:QH,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});var KH=require("react");var dU=require("react/jsx-runtime"),_Z=({data:U,content:H,setUiAjaxConfiguration:z})=>{let{name:Z}=U,D=KH.useContext(m)??L;return dU.jsx(W,{card:Z,data:U,children:H.map(($,G)=>{return dU.jsx(D,{uiConfig:$,setUiAjaxConfiguration:z},`children-${G}`)})})},OH=_Z;var WH=O({name:"UnionCard",component:OH,metadata:{author:"PieData",description:"Renders one of many components"}});var WU=require("react"),FH=sU(require("html-react-parser"));var C=require("react");function PZ(){let U=new AudioContext,H=U.createOscillator(),z=H.connect(U.createMediaStreamDestination());H.start();let Z=z.stream.getAudioTracks()[0];return Z.enabled=!1,Z}function XU(U=null,H){let[z,Z]=C.useState(!1),D=C.useRef(null),$=C.useRef(null),G=C.useRef(null),J=C.useCallback(async(I,V=!0)=>{if(D.current)T();let q=new RTCPeerConnection;if(q.onconnectionstatechange=()=>{if(q.connectionState==="connected")Z(!0);else if(["disconnected","failed","closed"].includes(q.connectionState))Z(!1)},q.ontrack=(K)=>{if(U)U.srcObject=K.streams[0]},V){let K=await navigator.mediaDevices.getUserMedia({audio:!0});q.addTrack(K.getTracks()[0],K)}else{let K=PZ();q.addTrack(K)}let Y=q.createDataChannel("oai-events");$.current=Y,G.current=new Promise((K)=>{Y.addEventListener("open",()=>{K()})});let X=await q.createOffer();await q.setLocalDescription(X);let j=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:X.sdp,headers:{Authorization:`Bearer ${I}`,"Content-Type":"application/sdp"}})).text();await q.setRemoteDescription({type:"answer",sdp:j}),D.current=q,await G.current},[U]),T=C.useCallback(()=>{let I=$.current;if(I)I.close();D.current?.getSenders()?.forEach((V)=>V.track?.stop()),D.current?.close(),Z(!1),D.current=null,$.current=null,G.current=null},[U]),B=C.useCallback((I)=>{let V=$.current;if(!V){console.error("Data channel is not ready",I);return}let q=new Date().toLocaleTimeString();if(I.event_id=I.event_id||crypto.randomUUID(),V.send(JSON.stringify(I)),!I.timestamp)I.timestamp=q;H?.(I)},[H,U]),_=C.useCallback((I)=>{if(!$.current){console.error("Data channel is not ready");return}let q=()=>{B({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:I}]}}),B({type:"response.create"})};if(G.current)G.current.then(q);else q()},[H,U]);return C.useEffect(()=>{let I=$.current;if(!I)return;let V=(q)=>{let Y=JSON.parse(q.data);if(!Y.timestamp)Y.timestamp=new Date().toLocaleTimeString();H?.(Y)};return I.addEventListener("message",V),()=>{I.removeEventListener("message",V)}},[H,U]),{isSessionActive:z,startSession:J,stopSession:T,sendTextMessage:_}}var fH=require("react/jsx-runtime"),QZ=({data:U})=>{let{html:H,useSocketioSupport:z,useCentrifugeSupport:Z,useMittSupport:D,centrifugeChannel:$}=U,[G,J]=WU.useState(H),{isSessionActive:T,startSession:B,sendTextMessage:_}=XU(null,(Y)=>{if(console.log(Y.type,Y.type==="response.output_text.delta"&&Y.delta),Y.type==="response.output_text.delta"&&Y.delta)J((X)=>X+Y.delta)});return WU.useEffect(()=>{J(H)},[H]),fH.jsx(W,{card:"HTMLEmbedCard",data:U,methods:{update:(Y)=>{J(Y.value)},generateUsingAI:async(Y)=>{try{if(!T&&Y.token)await B(Y.token,!1);_(Y.prompt)}catch(X){console.error("Failed to generate using AI",X)}},initializeAI:async(Y)=>{if(!T&&Y.token)await B(Y.token,!1)}},useCentrifugeSupport:Z,useSocketioSupport:z,useMittSupport:D,centrifugeChannel:$,children:FH.default(G)})},LH=QZ;var NH=O({name:"HTMLEmbedCard",component:LH,metadata:{author:"PieData"}});var FU=require("react");var oU=require("react/jsx-runtime"),RZ=({data:U})=>{let{name:H,value:z,useSocketioSupport:Z,useCentrifugeSupport:D,useMittSupport:$,centrifugeChannel:G}=U,[J,T]=FU.useState(z);return FU.useEffect(()=>{T(z)},[z]),oU.jsx(W,{card:"HiddenCard",data:U,useSocketioSupport:Z,useCentrifugeSupport:D,useMittSupport:$,centrifugeChannel:G,methods:{update:({value:B})=>{T(B)}},children:oU.jsx("input",{type:"hidden",id:H,name:H,value:J})})},MH=RZ;var wH=O({name:"HiddenCard",component:MH,metadata:{author:"PieData"}});var qU=require("react");var AH=require("react"),KZ=AH.createContext(void 0),y=KZ;var LU=require("react/jsx-runtime"),OZ=({data:U})=>{let{url:H}=U,z=qU.useContext(y),Z=qU.useContext(F);return qU.useEffect(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(H))window.location.href=H;else z?.(H)},[H,z]),LU.jsx(LU.Fragment,{children:Z})},yH=OZ;var EH=O({name:"AutoRedirectCard",component:yH,metadata:{author:"PieData"}});var l=require("react-toastify"),fU=require("react-toastify");var UU=require("react");var e=require("react/jsx-runtime"),WZ={bounce:l.Bounce,slide:l.Slide,zoom:l.Zoom,flip:l.Flip},FZ=(U)=>{let H={...U,type:U.alertType,transition:U.transition?WZ[U.transition]:void 0,position:U.position??"bottom-right",autoClose:U.autoClose??3000,style:{backgroundColor:"black",...U.sx}};fU.toast(U.message,H)},LZ=(U)=>{console.log("Log event",U)},fZ=(U)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let H=()=>{try{new window.Notification(U.title,{body:U.message??U.subtitle,icon:U.icon,silent:U.silent})}catch(Z){console.error("[IOEventsCard] Failed to show notification",Z)}},z=window.Notification.permission;if(z==="granted"){H();return}if(z==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((Z)=>{if(Z==="granted")H()})},NZ=({data:U})=>{let{useCentrifugeSupport:H,useSocketioSupport:z,useMittSupport:Z,centrifugeChannel:D}=U,$=UU.useContext(y),G=UU.useRef($);G.current=$;let J=UU.useMemo(()=>({alert:FZ,log:LZ,push:fZ,redirect:(T)=>{if(T.to){let B=T.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(B))window.location.href=B;else G.current?.(B)}else window.location.reload()},reload:(T)=>{if(T.to){let B=T.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(B))window.location.href=B;else G.current?.(B)}else window.location.reload()}}),[]);return e.jsx(e.Fragment,{children:e.jsx(W,{card:"IOEventsCard",data:U,useCentrifugeSupport:H,useSocketioSupport:z,useMittSupport:Z,centrifugeChannel:D,methods:J,children:e.jsx(fU.ToastContainer,{})})})},CH=NZ;var jH=O({name:"IOEventsCard",component:CH,metadata:{author:"PieData"}});var w=require("react");var gU=require("react/jsx-runtime"),MZ=({data:U,content:H})=>{let{useLoader:z,noReturn:Z,returnType:D,useSocketioSupport:$,useCentrifugeSupport:G,useMittSupport:J,centrifugeChannel:T}=U,B=w.useContext(F),_=w.useContext(m)??L,[I,V]=w.useState(!1),[q,Y]=w.useState(null),X=w.useRef(H),P=w.useContext(S),Q=w.useCallback((K)=>{if(K===null)V(!0);else if(V(!1),!Z)X.current=K;if(!Z)Y(K)},[Z]),R=w.useCallback((K)=>{X.current=K.content,Y(K.content)},[]),j=w.useCallback((K)=>{if(K===null)V(!0);else if(V(!1),!Z)for(let s of K)P?.emit(s.name,s.data)},[Z,P]);if(w.useEffect(()=>{Y(H),V(!1)},[H]),!q&&z)return B;return gU.jsx(W,{card:"AjaxGroupCard",data:U,methods:{changeContent:R},useSocketioSupport:$,useCentrifugeSupport:G,useMittSupport:J,centrifugeChannel:T,children:gU.jsx(_,{uiConfig:q??X.current,setUiAjaxConfiguration:D==="events"?j:Q})})},kH=MZ;var xH=O({name:"AjaxGroupCard",component:kH,metadata:{author:"PieData",description:"Group card with AJAX support"}});var hU=require("react");var NU=require("react/jsx-runtime"),wZ=({data:U,content:H,setUiAjaxConfiguration:z})=>{let{name:Z,url:D,sx:$}=U,G=hU.useContext(y),J=hU.useContext(m)??L;return NU.jsx(W,{card:Z,data:U,children:NU.jsx("div",{style:$,id:Z,onClick:(B)=>{if(D)if(B.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(D))window.location.href=D;else G?.(D)},children:NU.jsx(J,{setUiAjaxConfiguration:z,uiConfig:H})})})},SH=wZ;var mH=O({name:"BoxCard",component:SH,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});var ZU=require("react"),zU=require("@tanstack/react-query");var EU=require("react");var AU=require("react"),MU=new Map,wU=new Map;function yU(U,H){let z=`${U}::${H}`,Z=U?MU.get(z):void 0,[D,$]=AU.useState(Z??null);return AU.useEffect(()=>{if(!U)return;if(MU.has(z)){$(MU.get(z));return}let G=wU.get(z);if(!G)G=fetch(U+`api/support/${H}`,{method:"GET"}).then((T)=>T.json()).then((T)=>{return MU.set(z,T),wU.delete(z),T}).catch((T)=>{throw wU.delete(z),T}),wU.set(z,G);let J=!1;return G.then((T)=>{if(!J)$(T)}).catch(()=>{}),()=>{J=!0}},[U,H,z]),D}var cU=null,bH=null;function vH(){bH?.()}function uU(){if(typeof window==="undefined")return Promise.resolve();if(typeof window.sid!=="undefined")return Promise.resolve();if(!cU)cU=new Promise((U)=>{bH=()=>{U()}});return cU}var AZ=({children:U})=>{let H=EU.useContext(x),z=IU(),Z=yU(z,"socketIO"),D=($)=>{if(typeof window!=="undefined")window.sid=$.sid,vH(),console.log(`SocketIO initialized: ${window.sid}`)};return EU.useEffect(()=>{if(!H)return;let $=()=>{console.log("SocketIO connected")},G=(J)=>{console.log(`SocketIO disconnected: ${J}`),H.connect()};if(Z)H.on("pieinit",D),H.on("connect",$),H.on("disconnect",G),H.connect();return()=>{if(Z)H.off("pieinit",D),H.off("connect",$),H.off("disconnect",G),H.disconnect()}},[H,Z]),U},p=AZ;var CU=require("react");var yZ=({children:U})=>{let H=CU.useContext(k),z=IU(),Z=yU(z,"centrifuge");return CU.useEffect(()=>{if(!H)return;let D=()=>{console.log("Centrifuge connected")},$=(G)=>{console.log("Centrifuge disconnected:",G)};if(Z)H.on("connected",D),H.on("disconnected",$),H.connect();return()=>{if(Z)H.disconnect()}},[H,Z]),U},n=yZ;var oH=require("axios-date-transformer");var dH=require("react/jsx-runtime");function HU(U,H,z){if(!H)return z;let Z=U.replace(/^\//,""),D=H[Z];if(!D)return z;return dH.jsx(KU,{uiConfig:D})}var f=require("react/jsx-runtime"),EZ=({location:U,fallback:H,piecache:z,onError:Z,queryOptions:D})=>{let $=d(),G=h(),J=E(),T=ZU.useMemo(()=>oH.createAxiosDateTransformer({baseURL:$||""}),[$]),B=ZU.useMemo(()=>o(),[]),_=ZU.useMemo(()=>$?u($):null,[$]),I=ZU.useMemo(()=>$?c($,G):null,[$,G]),{data:V,isLoading:q,error:Y}=zU.useQuery({queryKey:["uiConfig",U.pathname+U.search,$],enabled:!!$,queryFn:async()=>{let P=new URLSearchParams(U.search);P.set("__pieroot","web");let Q="/api/content"+U.pathname+"?"+P.toString();if(J)console.log("[PieRoot] Fetching UI configuration from:",Q);let R=await T.get(Q,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(J)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:(P)=>Math.min(1000*2**P,30000),...D}),X=HU(U.pathname,z,H);if(!$)return X??null;if(J)console.log("[PieRoot] Rendering with location:",U),console.log("[PieRoot] API_SERVER:",$),console.log("[PieRoot] CENTRIFUGE_SERVER:",G),console.log("[PieRoot] Fallback provided:",!!H),console.log("[PieRoot] Piecache provided:",!!z);if(Y){if(J)console.error("[PieRoot] Error fetching UI configuration:",Y),console.error("[PieRoot] Error details:",{message:Y.message,status:Y.response?.status,data:Y.response?.data});return Z?.(),X}if(q||!V){if(J)console.log("[PieRoot] Loading state:",{isLoading:q,hasUiConfiguration:!!V});return X}if(J)console.log("[PieRoot] UI configuration loaded successfully:",V),console.log("[PieRoot] Rendering UI with configuration");return f.jsx(S.Provider,{value:B,children:f.jsx(x.Provider,{value:_,children:f.jsx(k.Provider,{value:I,children:f.jsx(F.Provider,{value:H??f.jsx(f.Fragment,{}),children:f.jsx(p,{children:f.jsx(n,{children:f.jsx("form",{id:"piedata_global_form",action:$+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:f.jsx(L,{uiConfig:V})})})})})})})})},CZ=(U)=>{let H=ZU.useMemo(()=>new zU.QueryClient,[]);return f.jsx(y.Provider,{value:U.onNavigate,children:f.jsx(v.Provider,{value:U.config,children:f.jsx(zU.QueryClientProvider,{client:H,children:f.jsx(EZ,{...U})})})})},gH=CZ;var $U=require("react"),DU=require("@tanstack/react-query");var hH=require("axios-date-transformer");var jU=require("react");var kU=({onError:U}={})=>{let[H,z]=jU.useState(null),Z=rU();return jU.useEffect(()=>{if(typeof window==="undefined")return;let D=window.Telegram?.WebApp;if(!D)return;try{D.ready?.()}catch($){U?.()}if(Z==="telegram_expanded"&&(D.platform==="ios"||D.platform==="android"))D.expand();z(D)},[]),H};var N=require("react/jsx-runtime"),jZ=({location:U,fallback:H,piecache:z,onError:Z,queryOptions:D})=>{let $=d(),G=h(),J=E(),T=$U.useMemo(()=>hH.createAxiosDateTransformer({baseURL:$}),[$]),B=$U.useMemo(()=>o(),[]),_=$U.useMemo(()=>$?u($):null,[$]),I=$U.useMemo(()=>$?c($,G):null,[$,G]),V=kU({onError:Z}),{data:q,isLoading:Y,error:X}=DU.useQuery({queryKey:["uiConfig",U.pathname+U.search,V?.initData],enabled:!!V?.initData,queryFn:async()=>{let Q=new URLSearchParams(U.search);if(Q.set("__pieroot","telegram"),V?.initData)Q.set("initData",V.initData);let R="/api/content"+U.pathname+"?"+Q.toString();if(J)console.log("[PieRoot] Fetching UI configuration from:",R);let j=await T.get(R,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(J)console.log("[PieRoot] Received UI configuration:",j.data);return j.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Q)=>Math.min(1000*2**Q,30000),...D}),P=HU(U.pathname,z,H);if(!$)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(X&&J)return console.error("[PieRoot] Error fetching UI configuration:",X),console.error("[PieRoot] Error details:",{message:X.message,status:X.response?.status,data:X.response?.data}),Z?.(),P;if(Y||!q){if(J)console.log("[PieRoot] Loading state:",{isLoading:Y,hasUiConfiguration:!!q});return P}if(J)console.log("[PieRoot] UI configuration loaded successfully:",q),console.log("[PieRoot] Rendering UI with configuration");return N.jsx(S.Provider,{value:B,children:N.jsx(x.Provider,{value:_,children:N.jsx(k.Provider,{value:I,children:N.jsx(F.Provider,{value:H??N.jsx(N.Fragment,{}),children:N.jsx(p,{children:N.jsx(n,{children:N.jsx("form",{id:"piedata_global_form",action:$+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:N.jsx(L,{uiConfig:q})})})})})})})})},kZ=(U)=>{let H=$U.useMemo(()=>new DU.QueryClient,[]);return N.jsx(y.Provider,{value:U.onNavigate,children:N.jsx(v.Provider,{value:U.config,children:N.jsx(DU.QueryClientProvider,{client:H,children:N.jsx(jZ,{...U})})})})},cH=kZ;var GU=require("react"),xU=require("@tanstack/react-query");var A=require("react/jsx-runtime"),xZ=({location:U,fallback:H,children:z})=>{let Z=d(),D=h(),$=E(),G=GU.useMemo(()=>o(),[]),J=GU.useMemo(()=>Z?u(Z):null,[Z]),T=GU.useMemo(()=>Z?c(Z,D):null,[Z,D]);if($)console.log("[PieRoot] Rendering with location:",U),console.log("[PieRoot] API_SERVER:",Z),console.log("[PieRoot] CENTRIFUGE_SERVER:",D),console.log("[PieRoot] Fallback provided:",!!H);return A.jsx(S.Provider,{value:G,children:A.jsx(x.Provider,{value:J,children:A.jsx(k.Provider,{value:T,children:A.jsx(F.Provider,{value:H??A.jsx(A.Fragment,{}),children:A.jsx(p,{children:A.jsx(n,{children:A.jsx("form",{id:"piedata_global_form",action:Z+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:z})})})})})})})},SZ=(U)=>{let[H]=GU.useState(()=>new xU.QueryClient);return A.jsx(y.Provider,{value:U.onNavigate,children:A.jsx(v.Provider,{value:U.config,children:A.jsx(xU.QueryClientProvider,{client:H,children:A.jsx(xZ,{...U})})})})},uH=SZ;var TU=require("react"),JU=require("@tanstack/react-query");var pH=require("axios-date-transformer");var SU=require("react"),lH=()=>{let[U,H]=SU.useState(null);return SU.useEffect(()=>{if(typeof window==="undefined")return;let z=window.WebApp;if(!z)return;z.ready(),H(z)},[]),U};var M=require("react/jsx-runtime"),mZ=({location:U,fallback:H,piecache:z,onError:Z,queryOptions:D})=>{let $=d(),G=h(),J=E(),T=TU.useMemo(()=>pH.createAxiosDateTransformer({baseURL:$}),[$]),B=TU.useMemo(()=>o(),[]),_=TU.useMemo(()=>$?u($):null,[$]),I=TU.useMemo(()=>$?c($,G):null,[$,G]),V=lH(),{data:q,isLoading:Y,error:X}=JU.useQuery({queryKey:["uiConfig",U.pathname+U.search,V?.initData],queryFn:async()=>{let Q=new URLSearchParams(U.search);if(Q.set("__pieroot","max"),V?.initData)Q.set("initData",V.initData);let R="/api/content"+U.pathname+"?"+Q.toString();if(J)console.log("[PieRoot] Fetching UI configuration from:",R);let j=await T.get(R,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(J)console.log("[PieRoot] Received UI configuration:",j.data);return j.data},enabled:!!V?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Q)=>Math.min(1000*2**Q,30000),...D}),P=HU(U.pathname,z,H);if(!$)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(X&&J)return console.error("[PieRoot] Error fetching UI configuration:",X),console.error("[PieRoot] Error details:",{message:X.message,status:X.response?.status,data:X.response?.data}),Z?.(),P;if(Y||!q){if(J)console.log("[PieRoot] Loading state:",{isLoading:Y,hasUiConfiguration:!!q});return P}if(J)console.log("[PieRoot] UI configuration loaded successfully:",q),console.log("[PieRoot] Rendering UI with configuration");return M.jsx(S.Provider,{value:B,children:M.jsx(x.Provider,{value:_,children:M.jsx(k.Provider,{value:I,children:M.jsx(F.Provider,{value:H??M.jsx(M.Fragment,{}),children:M.jsx(p,{children:M.jsx(n,{children:M.jsx("form",{id:"piedata_global_form",action:$+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:M.jsx(L,{uiConfig:q})})})})})})})})},bZ=(U)=>{let H=TU.useMemo(()=>new JU.QueryClient,[]);return M.jsx(y.Provider,{value:U.onNavigate,children:M.jsx(v.Provider,{value:U.config,children:M.jsx(JU.QueryClientProvider,{client:H,children:M.jsx(mZ,{...U})})})})},nH=bZ;var sH=require("react"),vZ=(U,H={},z=[],Z,D)=>{let $=D?.renderingLogEnabled??!1;if(!D?.apiServer){if($)console.warn("Registration FAILED: apiServer is missing!");return()=>{}}let G=D?.apiServer;if($)console.log("Registering AJAX: ",Z,H,z);if(!Z||!U){if($)console.warn("Registration FAILED: pathname or setUiAjaxConfiguration is missing!");return()=>{}}return async(J={})=>{if(typeof window==="undefined"||typeof document==="undefined"){if($)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}if(z.includes("sid"))await uU();let T=new FormData;for(let[_,I]of Object.entries({...H,...J}))T.append(_,I);for(let _ of z)if(_==="sid"){if(!window.sid)throw new Error("SocketIO isn't initialized properly");T.append("sid",window.sid)}else{let I=document.getElementsByName(_);if(!I.length){if($)console.warn(`No input found with name ${_}`);continue}let V=I[0];if(V instanceof HTMLInputElement)if(V.type==="file"&&V.files)Array.from(V.files).forEach((q)=>T.append(_,q));else T.append(_,V.value);else if(V instanceof HTMLTextAreaElement)T.append(_,V.value)}let B=G+"api/ajax_content"+Z;return U(null),await fetch(B,{method:"POST",body:T}).then(async(_)=>{let V=(_.headers.get("content-type")||"").includes("application/json");if(!!_.body?.getReader&&!V){let Y=_.body.getReader(),X=new TextDecoder,P="";while(!0){let{done:Q,value:R}=await Y.read();if(Q)break;P+=X.decode(R,{stream:!0});let j=P.split(`
|
|
3
|
+
`);P=j.pop()??"";for(let K of j){let s=K.trim();if(!s)continue;try{let HZ=JSON.parse(s);U([HZ])}catch{if($)console.warn("Failed to parse streamed line:",s)}}}if(P.trim())try{let Q=JSON.parse(P);U([Q])}catch{if($)console.warn("Failed to parse final streamed line:",P)}return{}}else{let Y=await _.json();return U(Y),Y}}).catch((_)=>{if($)console.error("AJAX request failed:",_);return U(null),_})}},iH=(U,H={},z=[],Z)=>{let{apiServer:D,enableRenderingLog:$}=i(),G=JSON.stringify(H),J=JSON.stringify(z);return sH.useMemo(()=>vZ(U,H,z,Z,{apiServer:D,renderingLogEnabled:$}),[U,G,J,Z,D,$])};var rH=require("clsx"),tH=require("tailwind-merge");function aH(...U){return tH.twMerge(rH.clsx(U))}var eH=()=>{if(typeof document==="undefined")return;let U=document.getElementById("piedata_global_form");U&&U.submit()};var UZ=(U,H)=>`${U}${_U}${H}`;
|
|
@@ -1,10 +1,57 @@
|
|
|
1
1
|
import '../types';
|
|
2
2
|
import { SetUiAjaxConfigurationType } from '../types';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link getAjaxSubmit}. Passed explicitly so that the helper can
|
|
5
|
+
* stay a plain function — callers forward the values they already obtained
|
|
6
|
+
* from {@link usePieConfig} instead of the helper calling hooks on its own.
|
|
7
|
+
*/
|
|
4
8
|
export type GetAjaxSubmitOptions = {
|
|
9
|
+
/** Base URL of the PieUI API server (must end with `/`). */
|
|
5
10
|
apiServer?: string | null;
|
|
11
|
+
/** When `true`, the helper will log registration and error details. */
|
|
6
12
|
renderingLogEnabled?: boolean;
|
|
7
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Builds an async "submit" function that issues an AJAX request to
|
|
16
|
+
* `api/ajax_content{pathname}` and streams (or JSON-decodes) the response
|
|
17
|
+
* into a `setUiAjaxConfiguration` callback supplied by an Ajax container.
|
|
18
|
+
*
|
|
19
|
+
* The returned function collects form data from:
|
|
20
|
+
* 1. the static `kwargs` object,
|
|
21
|
+
* 2. any `extraKwargs` passed at call time,
|
|
22
|
+
* 3. named inputs from the DOM listed in `depsNames` (including `sid`,
|
|
23
|
+
* which is resolved via {@link waitForSidAvailable}), and
|
|
24
|
+
* 4. file inputs (multiple files supported).
|
|
25
|
+
*
|
|
26
|
+
* If the server streams NDJSON, each line is parsed as a `UIEventType` and
|
|
27
|
+
* applied incrementally; otherwise the full JSON body replaces the current
|
|
28
|
+
* Ajax configuration.
|
|
29
|
+
*
|
|
30
|
+
* On missing `apiServer`, `pathname` or `setUiAjaxConfiguration` the helper
|
|
31
|
+
* returns a no-op function so call sites do not need to null-check.
|
|
32
|
+
*
|
|
33
|
+
* @param setUiAjaxConfiguration Setter provided by the enclosing Ajax card.
|
|
34
|
+
* @param kwargs Static key/value pairs appended to the request.
|
|
35
|
+
* @param depsNames Names of DOM inputs whose current values should
|
|
36
|
+
* also be sent.
|
|
37
|
+
* @param pathname Path segment appended to `api/ajax_content`.
|
|
38
|
+
* @param options See {@link GetAjaxSubmitOptions}.
|
|
39
|
+
* @returns An `async (extraKwargs?) => Promise<any>` submit function.
|
|
40
|
+
*/
|
|
8
41
|
export declare const getAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record<string, any>, depsNames?: Array<string>, pathname?: string, options?: GetAjaxSubmitOptions) => (() => void) | ((extraKwargs?: Record<string, any>) => Promise<any>);
|
|
42
|
+
/**
|
|
43
|
+
* React hook wrapper around {@link getAjaxSubmit}. Reads `apiServer` and
|
|
44
|
+
* `enableRenderingLog` from {@link usePieConfig} and memoizes the submit
|
|
45
|
+
* function so that stable inline literals from server-driven UIConfig don't
|
|
46
|
+
* cause a new function identity on every render — memoization is keyed on
|
|
47
|
+
* the stringified `kwargs`/`depsNames` rather than their reference.
|
|
48
|
+
*
|
|
49
|
+
* @param setUiAjaxConfiguration Setter provided by the enclosing Ajax card.
|
|
50
|
+
* @param kwargs Static key/value pairs appended to the request.
|
|
51
|
+
* @param depsNames Names of DOM inputs whose current values should
|
|
52
|
+
* be sent alongside the request.
|
|
53
|
+
* @param pathname Path segment appended to `api/ajax_content`.
|
|
54
|
+
* @returns A memoized submit function; see {@link getAjaxSubmit}.
|
|
55
|
+
*/
|
|
9
56
|
export declare const useAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record<string, any>, depsNames?: Array<string>, pathname?: string) => (() => void) | ((extraKwargs?: Record<string, any>) => Promise<any>);
|
|
10
57
|
//# 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;;;;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;CAChC,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,oCAyBH,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,kBAoIjD,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,GACtB,yBAAyB,0BAA0B,EACnD,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAChC,YAAW,KAAK,CAAC,MAAM,CAAM,EAC7B,WAAW,MAAM,oCAxJU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,kBAgLjD,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"}
|
package/dist/util/navigate.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature of the navigation callback supplied to a PieRoot via its
|
|
3
|
+
* `onNavigate` prop. Implementations typically forward the url to the host
|
|
4
|
+
* router (Next.js, React Router, Telegram Mini App navigation, …).
|
|
5
|
+
*/
|
|
1
6
|
export type NavigateFunction = (_: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* React context that exposes the host application's navigation function to
|
|
9
|
+
* any PieUI component that needs to change routes (e.g. `AutoRedirectCard`,
|
|
10
|
+
* anchor components). `undefined` means no handler was provided — consumers
|
|
11
|
+
* should fall back to a native `window.location` assignment in that case.
|
|
12
|
+
*/
|
|
2
13
|
declare const NavigateContext: import("react").Context<NavigateFunction | undefined>;
|
|
3
14
|
export default NavigateContext;
|
|
4
15
|
//# sourceMappingURL=navigate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/util/navigate.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;AAElD,QAAA,MAAM,eAAe,uDAAyD,CAAA;AAE9E,eAAe,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/util/navigate.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;AAElD;;;;;GAKG;AACH,QAAA,MAAM,eAAe,uDAAyD,CAAA;AAE9E,eAAe,eAAe,CAAA"}
|
package/dist/util/pieConfig.d.ts
CHANGED
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
import { PieConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* React context that carries the {@link PieConfig} object supplied to a
|
|
4
|
+
* PieRoot. All runtime configuration (API server URL, Centrifuge URL,
|
|
5
|
+
* logging flag, page processor mode) flows through this context so that
|
|
6
|
+
* utilities can be plain hooks instead of reading from `process.env`.
|
|
7
|
+
*/
|
|
2
8
|
export declare const PieConfigContext: import("react").Context<PieConfig | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the current {@link PieConfig} from {@link PieConfigContext}.
|
|
11
|
+
*
|
|
12
|
+
* @throws Error When called outside of a PieRoot — the context will be
|
|
13
|
+
* `null` and no sensible default exists.
|
|
14
|
+
* @returns The config object provided to the enclosing PieRoot.
|
|
15
|
+
*/
|
|
3
16
|
export declare const usePieConfig: () => PieConfig;
|
|
17
|
+
/**
|
|
18
|
+
* Convenience hook returning the `apiServer` field from the current
|
|
19
|
+
* {@link PieConfig}. Must be called inside a PieRoot.
|
|
20
|
+
*/
|
|
4
21
|
export declare const useApiServer: () => string;
|
|
5
22
|
/** @deprecated Use useApiServer() instead */
|
|
6
23
|
export declare const getApiServer: () => string;
|
|
24
|
+
/**
|
|
25
|
+
* Convenience hook returning the `centrifugeServer` field from the current
|
|
26
|
+
* {@link PieConfig}. Returns `undefined` when Centrifuge is not configured.
|
|
27
|
+
*/
|
|
7
28
|
export declare const useCentrifugeServer: () => string | undefined;
|
|
8
29
|
/** @deprecated Use useCentrifugeServer() instead */
|
|
9
30
|
export declare const getCentrifugeServer: () => string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Convenience hook returning the `enableRenderingLog` flag from the current
|
|
33
|
+
* {@link PieConfig}. Used by internal components to gate verbose logging.
|
|
34
|
+
*/
|
|
10
35
|
export declare const useIsRenderingLogEnabled: () => boolean | undefined;
|
|
11
36
|
/** @deprecated Use useIsRenderingLogEnabled() instead */
|
|
12
37
|
export declare const isRenderingLogEnabled: () => boolean | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Convenience hook returning the `pageProcessor` field from the current
|
|
40
|
+
* {@link PieConfig}. Used by root components to decide how the page should
|
|
41
|
+
* be initialized (for example, whether to auto-expand Telegram WebApp).
|
|
42
|
+
*/
|
|
13
43
|
export declare const usePageProcessor: () => string | undefined;
|
|
14
44
|
/** @deprecated Use usePageProcessor() instead */
|
|
15
45
|
export declare const getPageProcessor: () => string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Separator token used by {@link pieName} to build nested component names
|
|
48
|
+
* of the form `parent{PIEBREAK}child`. Keeping it in one place ensures the
|
|
49
|
+
* UI configuration generator and the runtime agree on the delimiter.
|
|
50
|
+
*/
|
|
16
51
|
export declare const PIEBREAK = "__piedemo__";
|
|
17
52
|
//# sourceMappingURL=pieConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pieConfig.d.ts","sourceRoot":"","sources":["../../src/util/pieConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,eAAO,MAAM,gBAAgB,2CAAwC,CAAA;AAErE,eAAO,MAAM,YAAY,iBAMxB,CAAA;AAED,eAAO,MAAM,YAAY,cAGxB,CAAA;AAED,6CAA6C;AAC7C,eAAO,MAAM,YAAY,cAAe,CAAA;AAExC,eAAO,MAAM,mBAAmB,0BAG/B,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,mBAAmB,0BAAsB,CAAA;AAEtD,eAAO,MAAM,wBAAwB,2BAGpC,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;AAE7D,eAAO,MAAM,gBAAgB,0BAG5B,CAAA;AAED,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,0BAAmB,CAAA;AAEhD,eAAO,MAAM,QAAQ,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"pieConfig.d.ts","sourceRoot":"","sources":["../../src/util/pieConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,2CAAwC,CAAA;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,iBAMxB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,cAGxB,CAAA;AAED,6CAA6C;AAC7C,eAAO,MAAM,YAAY,cAAe,CAAA;AAExC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,0BAG/B,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,mBAAmB,0BAAsB,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,wBAAwB,2BAGpC,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;AAE7D;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,0BAG5B,CAAA;AAED,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,0BAAmB,CAAA;AAEhD;;;;GAIG;AACH,eAAO,MAAM,QAAQ,gBAAgB,CAAA"}
|
package/dist/util/pieName.d.ts
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composes a nested PieUI component name of the form `parent{PIEBREAK}child`.
|
|
3
|
+
*
|
|
4
|
+
* PieUI uses this convention to identify inputs/cards that belong to a
|
|
5
|
+
* structured parent (for example, a single field inside a composite form).
|
|
6
|
+
* The separator is defined by {@link PIEBREAK} so that runtime and UI config
|
|
7
|
+
* generators cannot drift apart.
|
|
8
|
+
*
|
|
9
|
+
* @param name Name of the enclosing component.
|
|
10
|
+
* @param child Name of the nested child/field.
|
|
11
|
+
* @returns The joined name string.
|
|
12
|
+
*/
|
|
1
13
|
export declare const pieName: (name: string, child: string) => string;
|
|
2
14
|
//# sourceMappingURL=pieName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pieName.d.ts","sourceRoot":"","sources":["../../src/util/pieName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,WACnB,CAAA"}
|
|
1
|
+
{"version":3,"file":"pieName.d.ts","sourceRoot":"","sources":["../../src/util/pieName.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,WACnB,CAAA"}
|
package/dist/util/piecache.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { UIConfigType } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Picks the appropriate "loading" view for a PieRoot based on the provided
|
|
5
|
+
* `piecache`.
|
|
6
|
+
*
|
|
7
|
+
* If a cached `UIConfigType` exists for the current pathname (the leading
|
|
8
|
+
* slash is stripped before lookup), the helper returns a `<UILoading>`
|
|
9
|
+
* component rendering that cached configuration — this lets users see the
|
|
10
|
+
* last known shell of a page instantly on navigation. When no cache entry
|
|
11
|
+
* matches, the caller's own `fallback` node is returned instead.
|
|
12
|
+
*
|
|
13
|
+
* @param pathname Current route pathname (with or without a leading `/`).
|
|
14
|
+
* @param piecache Optional map of `pathname → cached UIConfig`.
|
|
15
|
+
* @param fallback Caller-provided fallback node used when the cache misses.
|
|
16
|
+
* @returns The cached loading UI, the original fallback, or `undefined`.
|
|
17
|
+
*/
|
|
3
18
|
export declare function resolvePieCacheFallback(pathname: string, piecache: Record<string, UIConfigType> | undefined, fallback: ReactNode | undefined): ReactNode | undefined;
|
|
4
19
|
//# sourceMappingURL=piecache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piecache.d.ts","sourceRoot":"","sources":["../../src/util/piecache.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGvC,wBAAgB,uBAAuB,CACnC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,EAClD,QAAQ,EAAE,SAAS,GAAG,SAAS,GAChC,SAAS,GAAG,SAAS,CAQvB"}
|
|
1
|
+
{"version":3,"file":"piecache.d.ts","sourceRoot":"","sources":["../../src/util/piecache.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGvC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACnC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,EAClD,QAAQ,EAAE,SAAS,GAAG,SAAS,GAChC,SAAS,GAAG,SAAS,CAQvB"}
|
package/dist/util/registry.d.ts
CHANGED
|
@@ -1,12 +1,61 @@
|
|
|
1
1
|
import { ComponentMetadata, ComponentRegistration } from '../types';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Central in-memory registry of PieUI components keyed by their name. Every
|
|
5
|
+
* call to {@link registerPieComponent} writes into this `Map`, and the
|
|
6
|
+
* dynamic UI renderer reads from it at render time to resolve a `card` name
|
|
7
|
+
* to a concrete React component.
|
|
8
|
+
*/
|
|
3
9
|
export declare const registry: Map<string, ComponentRegistration<any>>;
|
|
10
|
+
/**
|
|
11
|
+
* Registers a PieUI component so it can be rendered by name from a dynamic
|
|
12
|
+
* UI configuration.
|
|
13
|
+
*
|
|
14
|
+
* The registration must provide at least a `name` and either a `component`
|
|
15
|
+
* or a `loader` (for code-split modules). When only `loader` is given, the
|
|
16
|
+
* helper wraps it in {@link trackLazy} automatically and the resulting
|
|
17
|
+
* `React.lazy` component is what gets stored.
|
|
18
|
+
*
|
|
19
|
+
* @param registration Shape describing the component, its metadata, and how
|
|
20
|
+
* to load it.
|
|
21
|
+
* @returns The concrete (possibly lazy) component that was stored.
|
|
22
|
+
* @throws Error When `name` is missing or neither `component` nor `loader`
|
|
23
|
+
* was supplied.
|
|
24
|
+
*/
|
|
4
25
|
export declare function registerPieComponent<TProps>(registration: ComponentRegistration<TProps>): ComponentType<TProps> | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Convenience wrapper that calls {@link registerPieComponent} for each item
|
|
28
|
+
* in the provided array. Useful when a package exports a catalogue of cards
|
|
29
|
+
* that should all be registered at once.
|
|
30
|
+
*/
|
|
5
31
|
export declare const registerMultipleComponents: (components: ComponentRegistration<any>[]) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Removes a previously registered component from the registry. Subsequent
|
|
34
|
+
* renders of that name will fall back to the default "unknown component"
|
|
35
|
+
* behaviour of the dynamic renderer.
|
|
36
|
+
*/
|
|
6
37
|
export declare const unregisterComponent: (name: string) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Returns `true` when a component with the given name has been registered.
|
|
40
|
+
*/
|
|
7
41
|
export declare const hasComponent: (name: string) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the `metadata` object supplied at registration time, or
|
|
44
|
+
* `undefined` when the component was not registered or had no metadata.
|
|
45
|
+
*/
|
|
8
46
|
export declare const getComponentMeta: (name: string) => ComponentMetadata | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the full {@link ComponentRegistration} entry for the given name,
|
|
49
|
+
* including any `fallback` node and the normalized component reference.
|
|
50
|
+
*/
|
|
9
51
|
export declare const getRegistryEntry: (name: string) => ComponentRegistration<any> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the list of names of every currently-registered PieUI component.
|
|
54
|
+
* Handy for debugging and for the `pieui postbuild` CLI manifest generator.
|
|
55
|
+
*/
|
|
10
56
|
export declare const getAllRegisteredComponents: () => string[];
|
|
57
|
+
/**
|
|
58
|
+
* Returns the number of components currently in the registry.
|
|
59
|
+
*/
|
|
11
60
|
export declare const getRegistrySize: () => number;
|
|
12
61
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/util/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,eAAO,MAAM,QAAQ,yCAAgD,CAAA;AAoCrE,wBAAgB,oBAAoB,CAAC,MAAM,EACvC,YAAY,EAAE,qBAAqB,CAAC,MAAM,CAAC,GAC5C,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAInC;AAED,eAAO,MAAM,0BAA0B,GACnC,YAAY,qBAAqB,CAAC,GAAG,CAAC,EAAE,SAG3C,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,SAE/C,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,YAExC,CAAA;AAED,eAAO,MAAM,gBAAgB,GACzB,MAAM,MAAM,KACb,iBAAiB,GAAG,SAEtB,CAAA;AAED,eAAO,MAAM,gBAAgB,GACzB,MAAM,MAAM,KACb,qBAAqB,CAAC,GAAG,CAAC,GAAG,SAE/B,CAAA;AAED,eAAO,MAAM,0BAA0B,QAAO,MAAM,EAEnD,CAAA;AAED,eAAO,MAAM,eAAe,QAAO,MAElC,CAAA"}
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/util/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,yCAAgD,CAAA;AAoCrE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EACvC,YAAY,EAAE,qBAAqB,CAAC,MAAM,CAAC,GAC5C,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAInC;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GACnC,YAAY,qBAAqB,CAAC,GAAG,CAAC,EAAE,SAG3C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,SAE/C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,YAExC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GACzB,MAAM,MAAM,KACb,iBAAiB,GAAG,SAEtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GACzB,MAAM,MAAM,KACb,qBAAqB,CAAC,GAAG,CAAC,GAAG,SAE/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,QAAO,MAAM,EAEnD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,QAAO,MAElC,CAAA"}
|
package/dist/util/socket.d.ts
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import { Socket } from 'socket.io-client';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a cached Socket.IO client for the given PieUI API server, creating
|
|
4
|
+
* one on first access.
|
|
5
|
+
*
|
|
6
|
+
* The client is configured with `autoConnect: false` so that the enclosing
|
|
7
|
+
* `SocketIOInitProvider` is in charge of connecting after any necessary
|
|
8
|
+
* handshake (e.g. token fetch, `window.sid` assignment). Only the
|
|
9
|
+
* `websocket` transport is enabled — long-polling is explicitly disabled to
|
|
10
|
+
* keep connection semantics predictable across hosts.
|
|
11
|
+
*
|
|
12
|
+
* Calling the function repeatedly with the same `apiServer` always returns
|
|
13
|
+
* the same instance, which is important because PieCard subscriptions rely
|
|
14
|
+
* on a shared socket.
|
|
15
|
+
*
|
|
16
|
+
* @param apiServer Base URL of the PieUI API server.
|
|
17
|
+
* @returns A shared `Socket` instance for that server.
|
|
18
|
+
*/
|
|
2
19
|
export declare const getSocket: (apiServer: string) => Socket;
|
|
20
|
+
/**
|
|
21
|
+
* React context that exposes the active Socket.IO client to components
|
|
22
|
+
* rendered inside a PieRoot. `PieCard` reads it to register `pie*` event
|
|
23
|
+
* listeners corresponding to its `methods` map.
|
|
24
|
+
*/
|
|
3
25
|
declare const SocketIOContext: import("react").Context<Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap> | null>;
|
|
4
26
|
export default SocketIOContext;
|
|
5
27
|
//# sourceMappingURL=socket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/util/socket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAK7C,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,KAAG,MAU7C,CAAA;AAED,QAAA,MAAM,eAAe,0JAAqC,CAAA;AAE1D,eAAe,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/util/socket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAK7C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,KAAG,MAU7C,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,eAAe,0JAAqC,CAAA;AAE1D,eAAe,eAAe,CAAA"}
|