@swarm.ing/pieui 2.1.1 → 2.1.3
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/README.md +52 -0
- package/dist/agent/index.esm.js +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/components/Common/DeviceStorageCard/ui/DeviceStorageCard.d.ts +15 -0
- package/dist/components/Common/DeviceStorageCard/ui/DeviceStorageCard.d.ts.map +1 -1
- package/dist/components/Common/SessionStorageCard/ui/SessionStorageCard.d.ts +15 -0
- package/dist/components/Common/SessionStorageCard/ui/SessionStorageCard.d.ts.map +1 -1
- package/dist/components/index.d.ts +0 -2
- 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 +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/max/index.esm.js +1 -1
- package/dist/max/index.js +1 -1
- package/dist/pieui.components.json +62 -62
- package/dist/storybook/addon/manager.esm.js +2 -0
- package/dist/storybook/addon/manager.js +2 -0
- package/dist/telegram/components/CloudStorageCard/index.d.ts.map +1 -0
- package/dist/telegram/components/CloudStorageCard/types/index.d.ts.map +1 -0
- package/dist/telegram/components/CloudStorageCard/ui/CloudStorageCard.d.ts +15 -0
- package/dist/telegram/components/CloudStorageCard/ui/CloudStorageCard.d.ts.map +1 -0
- package/dist/telegram/components/SecureStorageCard/index.d.ts.map +1 -0
- package/dist/telegram/components/SecureStorageCard/types/index.d.ts.map +1 -0
- package/dist/telegram/components/SecureStorageCard/ui/SecureStorageCard.d.ts +15 -0
- package/dist/telegram/components/SecureStorageCard/ui/SecureStorageCard.d.ts.map +1 -0
- package/dist/telegram/index.d.ts +4 -0
- package/dist/telegram/index.d.ts.map +1 -1
- package/dist/telegram/index.esm.js +1 -1
- package/dist/telegram/index.js +1 -1
- package/dist/util/ajaxCommonUtils.d.ts +60 -13
- package/dist/util/ajaxCommonUtils.d.ts.map +1 -1
- package/dist/util/centrifuge.d.ts.map +1 -1
- package/dist/util/fallback.d.ts.map +1 -1
- package/dist/util/globalSingleton.d.ts +2 -0
- package/dist/util/globalSingleton.d.ts.map +1 -0
- package/dist/util/lazyError.d.ts.map +1 -1
- package/dist/util/mitt.d.ts +3 -0
- package/dist/util/mitt.d.ts.map +1 -1
- package/dist/util/navigate.d.ts.map +1 -1
- package/dist/util/pieConfig.d.ts.map +1 -1
- package/dist/util/registry.d.ts +16 -0
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/socket.d.ts.map +1 -1
- package/dist/util/uiRenderer.d.ts.map +1 -1
- package/dist/util/waitForSidAvailable.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/components/Common/CloudStorageCard/index.d.ts.map +0 -1
- package/dist/components/Common/CloudStorageCard/types/index.d.ts.map +0 -1
- package/dist/components/Common/CloudStorageCard/ui/CloudStorageCard.d.ts +0 -4
- package/dist/components/Common/CloudStorageCard/ui/CloudStorageCard.d.ts.map +0 -1
- package/dist/components/Common/SecureStorageCard/index.d.ts.map +0 -1
- package/dist/components/Common/SecureStorageCard/types/index.d.ts.map +0 -1
- package/dist/components/Common/SecureStorageCard/ui/SecureStorageCard.d.ts +0 -4
- package/dist/components/Common/SecureStorageCard/ui/SecureStorageCard.d.ts.map +0 -1
- /package/dist/{components/Common → telegram/components}/CloudStorageCard/index.d.ts +0 -0
- /package/dist/{components/Common → telegram/components}/CloudStorageCard/types/index.d.ts +0 -0
- /package/dist/{components/Common → telegram/components}/SecureStorageCard/index.d.ts +0 -0
- /package/dist/{components/Common → telegram/components}/SecureStorageCard/types/index.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var kC=Object.create;var{getPrototypeOf:jC,defineProperty:a,getOwnPropertyNames:OU,getOwnPropertyDescriptor:xC}=Object,VU=Object.prototype.hasOwnProperty;var $U=(f,U,C)=>{C=f!=null?kC(jC(f)):{};let H=U||!f||!f.__esModule?a(C,"default",{value:f,enumerable:!0}):C;for(let D of OU(f))if(!VU.call(H,D))a(H,D,{get:()=>f[D],enumerable:!0});return H},ZU=new WeakMap,mC=(f)=>{var U=ZU.get(f),C;if(U)return U;if(U=a({},"__esModule",{value:!0}),f&&typeof f==="object"||typeof f==="function")OU(f).map((H)=>!VU.call(U,H)&&a(U,H,{get:()=>f[H],enumerable:!(C=xC(f,H))||C.enumerable}));return ZU.set(f,U),U};var uC=(f,U)=>{for(var C in U)a(f,C,{get:U[C],enumerable:!0,configurable:!0,set:(H)=>U[C]=()=>H})};var KH={};uC(KH,{usePieEmit:()=>QU,useAjaxSubmit:()=>SC,unregisterComponent:()=>wU,trackLazy:()=>Gf,submitGlobalForm:()=>LC,registry:()=>R,registerPieComponent:()=>W,registerMultipleComponents:()=>_U,readAjaxKey:()=>IU,preloadComponent:()=>gf,prefetchLazyComponents:()=>NU,pieName:()=>oC,hasComponent:()=>MU,getRegistrySize:()=>RU,getRegistryEntry:()=>l,getLazyComponentNames:()=>pf,getEmitter:()=>d,getComponentMeta:()=>LU,getAllRegisteredComponents:()=>oU,cn:()=>MC,UnionCard:()=>pU,UIRendererContext:()=>L,UILoading:()=>Af,UI:()=>_,SocketIOContext:()=>E,SessionStorageCard:()=>UC,SequenceCard:()=>bU,SecureStorageCard:()=>OC,PieRoot:()=>xf,PiePreviewRoot:()=>FC,PieConfigContext:()=>b,PieCard:()=>A,PieBaseRoot:()=>AC,PIEBREAK:()=>Bf,OneOfCard:()=>JC,MittContext:()=>y,IOEventsCard:()=>eU,HiddenCard:()=>nU,HTMLEmbedCard:()=>hU,FallbackContext:()=>M,DeviceStorageCard:()=>HC,CloudStorageCard:()=>DC,CentrifugeIOContext:()=>N,BoxCard:()=>TC,AutoRedirectCard:()=>tU,AjaxGroupCard:()=>$C});module.exports=mC(KH);var k=require("react");var zf=require("react"),b=zf.createContext(null),e=()=>{let f=zf.useContext(b);if(!f)throw Error("usePieConfig must be used within PieConfigProvider");return f},ff=()=>{let{apiServer:f}=e();return f},Tf=ff,qf=()=>{let{centrifugeServer:f}=e();return f};var x=()=>{let{enableRenderingLog:f}=e();return f},zU=x;var Bf="__piedemo__";var qU=require("react"),df=require("centrifuge"),TU=new Map,Jf=(f,U)=>{if(!U)return null;let C=`${f}::${U}`,H=TU.get(C);if(H)return H;async function D(){let Z=await fetch(f+"api/centrifuge/gen_token");if(!Z.ok){if(Z.status===403)throw new df.Centrifuge.UnauthorizedError("Backend is not answering");throw Error(`Unexpected status code ${Z.status}`)}return(await Z.json()).token}let I=new df.Centrifuge(U,{getToken:D});return TU.set(C,I),I},bC=qU.createContext(null),N=bC;var JU=require("socket.io-client"),XU=require("react"),BU=new Map,Xf=(f)=>{let U=BU.get(f);if(U)return U;let C=JU.io(f,{autoConnect:!1,transports:["websocket"]});return BU.set(f,C),C},dC=XU.createContext(null),E=dC;var GU=$U(require("mitt")),g=require("react"),vf=null;function d(){if(!vf)vf=GU.default();return vf}var WU=g.createContext(null);function QU(f){let U=g.useContext(WU);return g.useCallback((C,H)=>{(U??d()).emit(`pie${C}_${f}`,H)},[f,U])}var y=WU;var c=require("react/jsx-runtime"),vC=({card:f,data:U,children:C,useSocketioSupport:H=!1,useCentrifugeSupport:D=!1,useMittSupport:I=!1,centrifugeChannel:Z=void 0,methods:$=void 0,stored:O=void 0})=>{let V=zU(),z=k.useRef($);if(z.current=$,V)console.log("[PieCard] Rendering card:",f),console.log("[PieCard] Card data:",U),console.log("[PieCard] Component name:",U?.name),console.log("[PieCard] Real-time support:",{socketio:H,centrifuge:D,mitt:I,centrifugeChannel:Z}),console.log("[PieCard] Methods:",$?Object.keys($):"none"),console.log("[PieCard] Has children:",!!C);let X=k.useContext(E),Q=k.useContext(N),T=k.useContext(y);if(k.useEffect(()=>{if(!X||!H||!z.current||!U.name){if(V&&H)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!X,useSocketioSupport:H,hasMethods:!!z.current,hasDataName:!!U?.name});return}let G=Object.keys(z.current??{}).map((q)=>{let J=`pie${q}_${U.name}`;if(V)console.log(`[PieCard] Socket.IO registering event: ${J}`);let F=(Y)=>{z.current?.[q]?.(Y)};return X.on(J,F),[J,F]});return()=>{G.forEach(([q,J])=>{if(V)console.log(`[PieCard] Socket.IO unregistering event: ${q}`);X.off(q,J)})}},[X,U.name,H]),k.useEffect(()=>{if(!Q||!D||!Z||!U.name){if(V&&D)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!Q,useCentrifugeSupport:D,hasCentrifugeChannel:!!Z,hasMethods:!!z.current,hasDataName:!!U?.name});return}let G=Object.keys(z.current??{}).map((q)=>{let J=`pie${q}_${U.name}_${Z}`;if(V)console.log(`[PieCard] Centrifuge subscribing to channel: ${J}`);let F=Q.newSubscription(J);return F.on("publication",(Y)=>{if(V)console.log(`[PieCard] Centrifuge received data on ${J}:`,Y.data);z.current?.[q]?.(Y.data)}),F.subscribe(),F});return()=>{G.forEach((q)=>{if(V)console.log("[PieCard] Centrifuge unsubscribing from channel");q.unsubscribe(),Q.removeSubscription(q)})}},[Q,Z,U.name,D]),k.useEffect(()=>{if(!T||!I||!U.name){if(V&&I)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!T,useMittSupport:I,hasMethods:!!z.current,hasDataName:!!U?.name});return}let B=Object.keys(z.current??{}),G={};return B.forEach((q)=>{let J=`pie${q}_${U.name}`,F=(Y)=>{if(V)console.log(`[PieCard] Mitt registering event: ${J}`);z.current?.[q]?.(Y)};G[J]=F,T.on(J,F)}),()=>{Object.entries(G).forEach(([q,J])=>{if(V)console.log(`[PieCard] Mitt unregistering event: ${q}`);T.off(q,J)})}},[T,U.name,I]),V)console.log("[PieCard] Rendering complete, returning children");if(O!==void 0)return c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"hidden",name:U.name,value:JSON.stringify(O)}),C]});return C},A=vC;var YU=require("react"),v=new Map;function AU(f,U){return U.catch(()=>{if(v.get(f)===U)v.delete(f)}),v.set(f,U),U}function Gf(f,U){return YU.lazy(()=>{if(v.has(U))return v.get(U);return AU(U,f().then((C)=>C))})}var PU=async(f,U)=>{if(!U)return;if(v.has(f))return v.get(f);return AU(f,U().then((C)=>C))};var FU=Symbol.for("@swarm.ing/pieui:component-registry"),KU=globalThis,R=KU[FU]??(KU[FU]=new Map),pC=(f)=>{if(!f.name)throw Error("Component registration requires a name");if(!f.component&&!f.loader)throw 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=Gf(U.loader,f.name),U.isLazy=!0;return U};function W(f){let U=pC(f);return R.set(U.name,U),U.component}var _U=(f)=>{f.forEach((U)=>W(U))},wU=(f)=>{R.delete(f)},MU=(f)=>{return R.has(f)},LU=(f)=>{return R.get(f)?.metadata},l=(f)=>{return R.get(f)},oU=()=>{return Array.from(R.keys())},RU=()=>{return R.size},pf=()=>Array.from(R.values()).filter((f)=>f.isLazy&&typeof f.loader==="function").map((f)=>f.name),gf=(f)=>{let U=R.get(f);if(!U?.isLazy||typeof U.loader!=="function")return;return PU(f,U.loader)},SU=!1,NU=()=>{if(SU||typeof window>"u")return;SU=!0;let f=navigator.connection;if(f?.saveData)return;if(f?.effectiveType&&["slow-2g","2g"].includes(f.effectiveType))return;let U=pf(),C="requestIdleCallback"in window?(D)=>window.requestIdleCallback(D,{timeout:2000}):(D)=>window.setTimeout(D,300),H=(D)=>{if(D>=U.length)return;C(()=>{Promise.resolve().then(()=>gf(U[D])).catch(()=>{}).finally(()=>H(D+1))})};H(0)};var Uf=require("react");var EU=require("react"),Wf=require("react/jsx-runtime"),gC=EU.createContext(Wf.jsx(Wf.Fragment,{})),M=gC;var yU=require("react"),cC=yU.createContext(void 0),m=cC;var Qf=require("react"),kU=require("react/jsx-runtime"),lC=2,hC=400;class h extends Qf.Component{state={failed:!1,attempt:0};timer;static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(f){if(this.props.onError?.(f),this.state.attempt<lC){let U=hC*(this.state.attempt+1);this.timer=setTimeout(()=>{this.setState((C)=>({failed:!1,attempt:C.attempt+1}))},U)}}componentDidUpdate(f){if(f.name!==this.props.name&&this.state.attempt!==0)this.setState({failed:!1,attempt:0})}componentWillUnmount(){if(this.timer)clearTimeout(this.timer)}render(){if(this.state.failed)return this.props.fallback;return kU.jsx(Qf.Suspense,{fallback:this.props.fallback,children:this.props.children},`${this.props.name}:${this.state.attempt}`)}}var Yf=require("react/jsx-runtime");function rC({uiConfig:f,setUiAjaxConfiguration:U}){let C=Uf.useContext(M),H=Uf.useContext(m),D=x();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 I=l(f.card);if(!I?.component){if(D)console.warn(`[UI] Component not found in registry: ${f.card}`),console.log("[UI] Returning fallback component");return C}if(D)console.log("[UI] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata});let Z=I.component,$=Yf.jsx(Z,{data:f.data,content:f.content,setUiAjaxConfiguration:U});if(I.isLazy){if(D)console.log("[UI] Rendering lazy component with Suspense:",I.name);return Yf.jsx(h,{name:I.name,fallback:I.fallback?Yf.jsx(I.fallback,{}):C,onError:H,children:$})}if(D)console.log("[UI] Rendering component directly:",I.name);return $}var _=Uf.memo(rC);var cf=require("react");var jU=require("react"),nC=jU.createContext(null),L=nC;var Cf=require("react/jsx-runtime");function xU({uiConfig:f,setUiAjaxConfiguration:U}){let C=cf.useContext(M),H=cf.useContext(m),D=x();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 I=l(f.card);if(!I?.component){if(D)console.warn(`[UILoading] Component not found in registry: ${f.card}`),console.log("[UILoading] Returning fallback component");return C}if(D)console.log("[UILoading] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata,hasFallback:!!I.fallback});if(I.fallback){if(D)console.log("[UILoading] Rendering fallback for:",I.name);let O=I.fallback;return Cf.jsx(O,{})}if(D)console.log("[UILoading] No fallback, rendering full component:",I.name);let Z=I.component,$=Cf.jsx(L.Provider,{value:xU,children:Cf.jsx(Z,{data:f.data,content:f.content,setUiAjaxConfiguration:U})});if(I.isLazy)return Cf.jsx(h,{name:I.name,fallback:C,onError:H,children:$});return $}var Af=xU;var mU=require("react");var Pf=require("react/jsx-runtime"),iC=({data:f,content:U,setUiAjaxConfiguration:C})=>{let{name:H,sx:D}=f,I=mU.useContext(L)??_;return Pf.jsx(A,{card:H,data:f,children:Pf.jsx("div",{style:D,id:H,children:U.map((Z,$)=>{return Pf.jsx(I,{uiConfig:Z,setUiAjaxConfiguration:C},`children-${$}`)})})})},uU=iC;var bU=W({name:"SequenceCard",component:uU,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});var dU=require("react");var lf=require("react/jsx-runtime"),sC=({data:f,content:U,setUiAjaxConfiguration:C})=>{let{name:H}=f,D=dU.useContext(L)??_;return lf.jsx(A,{card:H,data:f,children:U.map((I,Z)=>{return lf.jsx(D,{uiConfig:I,setUiAjaxConfiguration:C},`children-${Z}`)})})},vU=sC;var pU=W({name:"UnionCard",component:vU,metadata:{author:"Swarm.ing",description:"Renders one of many components"}});var Ff=require("react"),gU=$U(require("html-react-parser"));var o=require("react");function tC(){let f=new AudioContext,U=f.createOscillator(),C=U.connect(f.createMediaStreamDestination());U.start();let H=C.stream.getAudioTracks()[0];return H.enabled=!1,H}function hf(f=null,U){let[C,H]=o.useState(!1),D=o.useRef(null),I=o.useRef(null),Z=o.useRef(null),$=o.useCallback(async(X,Q=!0)=>{if(D.current)O();let T=new RTCPeerConnection;if(T.onconnectionstatechange=()=>{if(T.connectionState==="connected")H(!0);else if(["disconnected","failed","closed"].includes(T.connectionState))H(!1)},T.ontrack=(P)=>{if(f)f.srcObject=P.streams[0]},Q){let P=await navigator.mediaDevices.getUserMedia({audio:!0});T.addTrack(P.getTracks()[0],P)}else{let P=tC();T.addTrack(P)}let B=T.createDataChannel("oai-events");I.current=B,Z.current=new Promise((P)=>{B.addEventListener("open",()=>{P()})});let G=await T.createOffer();await T.setLocalDescription(G);let Y=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:G.sdp,headers:{Authorization:`Bearer ${X}`,"Content-Type":"application/sdp"}})).text();await T.setRemoteDescription({type:"answer",sdp:Y}),D.current=T,await Z.current},[f]),O=o.useCallback(()=>{let X=I.current;if(X)X.close();D.current?.getSenders()?.forEach((Q)=>Q.track?.stop()),D.current?.close(),H(!1),D.current=null,I.current=null,Z.current=null},[f]),V=o.useCallback((X)=>{let Q=I.current;if(!Q){console.error("Data channel is not ready",X);return}let T=new Date().toLocaleTimeString();if(X.event_id=X.event_id||crypto.randomUUID(),Q.send(JSON.stringify(X)),!X.timestamp)X.timestamp=T;U?.(X)},[U,f]),z=o.useCallback((X)=>{if(!I.current){console.error("Data channel is not ready");return}let T=()=>{V({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:X}]}}),V({type:"response.create"})};if(Z.current)Z.current.then(T);else T()},[U,f]);return o.useEffect(()=>{let X=I.current;if(!X)return;let Q=(T)=>{let B=JSON.parse(T.data);if(!B.timestamp)B.timestamp=new Date().toLocaleTimeString();U?.(B)};return X.addEventListener("message",Q),()=>{X.removeEventListener("message",Q)}},[U,f]),{isSessionActive:C,startSession:$,stopSession:O,sendTextMessage:z}}var lU=require("react/jsx-runtime"),aC=({data:f})=>{let{html:U,useSocketioSupport:C,useCentrifugeSupport:H,useMittSupport:D,centrifugeChannel:I}=f,[Z,$]=Ff.useState(U),{isSessionActive:O,startSession:V,sendTextMessage:z}=hf(null,(B)=>{if(console.log(B.type,B.type==="response.output_text.delta"&&B.delta),B.type==="response.output_text.delta"&&B.delta)$((G)=>G+B.delta)});return Ff.useEffect(()=>{$(U)},[U]),lU.jsx(A,{card:"HTMLEmbedCard",data:f,methods:{update:(B)=>{$(B.value)},generateUsingAI:async(B)=>{try{if(!O&&B.token)await V(B.token,!1);z(B.prompt)}catch(G){console.error("Failed to generate using AI",G)}},initializeAI:async(B)=>{if(!O&&B.token)await V(B.token,!1)}},useCentrifugeSupport:H,useSocketioSupport:C,useMittSupport:D,centrifugeChannel:I,children:gU.default(Z)})},cU=aC;var hU=W({name:"HTMLEmbedCard",component:cU,metadata:{author:"Swarm.ing"}});var Kf=require("react");var rf=require("react/jsx-runtime"),eC=({data:f})=>{let{name:U,value:C,useSocketioSupport:H,useCentrifugeSupport:D,useMittSupport:I,centrifugeChannel:Z}=f,[$,O]=Kf.useState(C);return Kf.useEffect(()=>{O(C)},[C]),rf.jsx(A,{card:"HiddenCard",data:f,useSocketioSupport:H,useCentrifugeSupport:D,useMittSupport:I,centrifugeChannel:Z,methods:{update:({value:V})=>{O(V)}},children:rf.jsx("input",{type:"hidden",id:U,name:U,value:$})})},rU=eC;var nU=W({name:"HiddenCard",component:rU,metadata:{author:"Swarm.ing"}});var Hf=require("react");var iU=require("react"),fH=iU.createContext(void 0),j=fH;var Sf=require("react/jsx-runtime"),UH=({data:f})=>{let{url:U}=f,C=Hf.useContext(j),H=Hf.useContext(M);return Hf.useEffect(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(U))window.location.href=U;else C?.(U)},[U,C]),Sf.jsx(Sf.Fragment,{children:H})},sU=UH;var tU=W({name:"AutoRedirectCard",component:sU,metadata:{author:"Swarm.ing"}});var u=require("react-toastify"),_f=require("react-toastify");var n=require("react");var r=require("react/jsx-runtime"),CH={bounce:u.Bounce,slide:u.Slide,zoom:u.Zoom,flip:u.Flip},HH=(f)=>{let U={...f,type:f.alertType,transition:f.transition?CH[f.transition]:void 0,position:f.position??"bottom-right",autoClose:f.autoClose??3000,style:{backgroundColor:"black",...f.sx}};_f.toast(f.message,U)},IH=(f)=>{console.log("Log event",f)},DH=(f)=>{if(typeof window>"u"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let U=()=>{try{new window.Notification(f.title,{body:f.message??f.subtitle,icon:f.icon,silent:f.silent})}catch(H){console.error("[IOEventsCard] Failed to show notification",H)}},C=window.Notification.permission;if(C==="granted"){U();return}if(C==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((H)=>{if(H==="granted")U()})},ZH=({data:f})=>{let{useCentrifugeSupport:U,useSocketioSupport:C,useMittSupport:H,centrifugeChannel:D}=f,I=n.useContext(j),Z=n.useRef(I);Z.current=I;let $=n.useMemo(()=>({alert:HH,log:IH,push:DH,redirect:(O)=>{if(O.to){let V=O.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(V))window.location.href=V;else Z.current?.(V)}else window.location.reload()},reload:(O)=>{if(O.to){let V=O.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(V))window.location.href=V;else Z.current?.(V)}else window.location.reload()}}),[]);return r.jsx(r.Fragment,{children:r.jsx(A,{card:"IOEventsCard",data:f,useCentrifugeSupport:U,useSocketioSupport:C,useMittSupport:H,centrifugeChannel:D,methods:$,children:r.jsx(_f.ToastContainer,{})})})},aU=ZH;var eU=W({name:"IOEventsCard",component:aU,metadata:{author:"Swarm.ing"}});var If=require("react");var nf=require("react/jsx-runtime"),OH=({data:f})=>{let{name:U,key:C,value:H,useSocketioSupport:D,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:$}=f,[O,V]=If.useState(H);return If.useEffect(()=>{V(H)},[H]),If.useEffect(()=>{if(typeof window>"u")return;sessionStorage.setItem(C,O)},[C,O]),nf.jsx(A,{card:"SessionStorageCard",data:f,useSocketioSupport:D,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:$,methods:{update:({value:z})=>{V(z)},remove:()=>{sessionStorage.removeItem(C),V("")}},children:nf.jsx("input",{type:"hidden",id:U,name:U,value:O})})},fC=OH;var UC=W({name:"SessionStorageCard",component:fC,metadata:{author:"PieData"}});var Df=require("react");var sf=require("react/jsx-runtime"),VH=({data:f})=>{let{name:U,key:C,value:H,useSocketioSupport:D,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:$}=f,[O,V]=Df.useState(H);return Df.useEffect(()=>{V(H)},[H]),Df.useEffect(()=>{if(typeof window>"u")return;localStorage.setItem(C,O)},[C,O]),sf.jsx(A,{card:"DeviceStorageCard",data:f,useSocketioSupport:D,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:$,methods:{update:({value:z})=>{V(z)},remove:()=>{localStorage.removeItem(C),V("")}},children:sf.jsx("input",{type:"hidden",id:U,name:U,value:O})})},CC=VH;var HC=W({name:"DeviceStorageCard",component:CC,metadata:{author:"PieData"}});var Zf=require("react");var tf=require("react/jsx-runtime"),$H=({data:f})=>{let{name:U,key:C,value:H,useSocketioSupport:D,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:$}=f,[O,V]=Zf.useState(H);return Zf.useEffect(()=>{V(H)},[H]),Zf.useEffect(()=>{if(typeof window>"u")return;let z=window.Telegram?.WebApp?.CloudStorage;if(!z)return;z.setItem(C,O)},[C,O]),tf.jsx(A,{card:"CloudStorageCard",data:f,useSocketioSupport:D,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:$,methods:{update:({value:z})=>{V(z)},remove:()=>{let z=window.Telegram?.WebApp?.CloudStorage;if(z)z.removeItem(C);V("")}},children:tf.jsx("input",{type:"hidden",id:U,name:U,value:O})})},IC=$H;var DC=W({name:"CloudStorageCard",component:IC,metadata:{author:"PieData"}});var Of=require("react");var af=require("react/jsx-runtime"),zH=({data:f})=>{let{name:U,key:C,value:H,useSocketioSupport:D,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:$}=f,[O,V]=Of.useState(H);return Of.useEffect(()=>{V(H)},[H]),Of.useEffect(()=>{if(typeof window>"u")return;let z=window.Telegram?.WebApp?.SecureStorage;if(!z)return;z.setItem(C,O)},[C,O]),af.jsx(A,{card:"SecureStorageCard",data:f,useSocketioSupport:D,useCentrifugeSupport:I,useMittSupport:Z,centrifugeChannel:$,methods:{update:({value:z})=>{V(z)},remove:()=>{let z=window.Telegram?.WebApp?.SecureStorage;if(z)z.removeItem(C);V("")}},children:af.jsx("input",{type:"hidden",id:U,name:U,value:O})})},ZC=zH;var OC=W({name:"SecureStorageCard",component:ZC,metadata:{author:"PieData"}});var w=require("react");var ef=require("react/jsx-runtime"),TH=({data:f,content:U})=>{let{useLoader:C,noReturn:H,returnType:D,useSocketioSupport:I,useCentrifugeSupport:Z,useMittSupport:$,centrifugeChannel:O}=f,V=w.useContext(M),z=w.useContext(L)??_,[X,Q]=w.useState(!1),[T,B]=w.useState(null),G=w.useRef(U),q=w.useContext(y),J=w.useCallback((P)=>{if(P===null)Q(!0);else if(Q(!1),!H)G.current=P;if(!H)B(P)},[H]),F=w.useCallback((P)=>{G.current=P.content,B(P.content)},[]),Y=w.useCallback((P)=>{if(P===null)Q(!0);else if(Q(!1),!H)for(let Vf of P)q?.emit(Vf.name,Vf.data)},[H,q]);if(w.useEffect(()=>{B(U),Q(!1)},[U]),!T&&C)return V;return ef.jsx(A,{card:"AjaxGroupCard",data:f,methods:{changeContent:F},useSocketioSupport:I,useCentrifugeSupport:Z,useMittSupport:$,centrifugeChannel:O,children:ef.jsx(z,{uiConfig:T??G.current,setUiAjaxConfiguration:D==="events"?Y:J})})},VC=TH;var $C=W({name:"AjaxGroupCard",component:VC,metadata:{author:"Swarm.ing",description:"Group card with AJAX support"}});var fU=require("react");var wf=require("react/jsx-runtime"),qH=({data:f,content:U,setUiAjaxConfiguration:C})=>{let{name:H,url:D,sx:I}=f,Z=fU.useContext(j),$=fU.useContext(L)??_;return wf.jsx(A,{card:H,data:f,children:wf.jsx("div",{style:I,id:H,onClick:(V)=>{if(D)if(V.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(D))window.location.href=D;else Z?.(D)},children:wf.jsx($,{setUiAjaxConfiguration:C,uiConfig:U})})})},zC=qH;var TC=W({name:"BoxCard",component:zC,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});var qC=require("react");var Mf=require("react/jsx-runtime"),BH=({data:f,content:U,setUiAjaxConfiguration:C})=>{let{name:H,sx:D}=f,I=qC.useContext(L)??_;return Mf.jsx(A,{card:H,data:f,children:Mf.jsx("div",{style:D,id:H,children:U.map((Z,$)=>{return Mf.jsx(I,{uiConfig:Z,setUiAjaxConfiguration:C},`children-${$}`)})})})},BC=BH;var JC=W({name:"OneOfCard",component:BC,metadata:{author:"Swarm.ing",description:"Different variants"}});var i=require("react"),s=require("@tanstack/react-query");var Ef=require("react");var Rf=require("react"),Lf=new Map,of=new Map;function Nf(f,U){let C=`${f}::${U}`,H=f?Lf.get(C):void 0,[D,I]=Rf.useState(H??null);return Rf.useEffect(()=>{if(!f)return;if(Lf.has(C)){I(Lf.get(C));return}let Z=of.get(C);if(!Z)Z=fetch(f+`api/support/${U}`,{method:"GET"}).then((O)=>O.json()).then((O)=>{return Lf.set(C,O),of.delete(C),O}).catch((O)=>{throw of.delete(C),O}),of.set(C,Z);let $=!1;return Z.then((O)=>{if(!$)I(O)}).catch(()=>{}),()=>{$=!0}},[f,U,C]),D}var UU=null,XC=null;function GC(){XC?.()}function CU(){if(typeof window>"u")return Promise.resolve();if(typeof window.sid<"u")return Promise.resolve();if(!UU)UU=new Promise((f)=>{XC=()=>{f()}});return UU}var JH=({children:f})=>{let U=Ef.useContext(E),C=Tf(),H=Nf(C,"socketIO"),D=(I)=>{if(typeof window<"u")window.sid=I.sid,GC(),console.log(`SocketIO initialized: ${window.sid}`)};return Ef.useEffect(()=>{if(!U)return;let I=()=>{console.log("SocketIO connected")},Z=($)=>{console.log(`SocketIO disconnected: ${$}`),U.connect()};if(H)U.on("pieinit",D),U.on("connect",I),U.on("disconnect",Z),U.connect();return()=>{if(H)U.off("pieinit",D),U.off("connect",I),U.off("disconnect",Z),U.disconnect()}},[U,H]),f},yf=JH;var kf=require("react");var XH=({children:f})=>{let U=kf.useContext(N),C=Tf(),H=Nf(C,"centrifuge");return kf.useEffect(()=>{if(!U)return;let D=()=>{console.log("Centrifuge connected")},I=(Z)=>{console.log("Centrifuge disconnected:",Z)};if(H)U.on("connected",D),U.on("disconnected",I),U.connect();return()=>{if(H)U.disconnect()}},[U,H]),f},jf=XH;var YC=require("axios-date-transformer");var QC=require("react/jsx-runtime");function WC(f,U,C){if(!U)return C;let H=f.replace(/^\//,""),D=U[H];if(!D)return C;return QC.jsx(Af,{uiConfig:D})}var K=require("react/jsx-runtime"),GH=({location:f,fallback:U,piecache:C,onError:H,queryOptions:D,disableGlobalForm:I})=>{let Z=ff(),$=qf(),O=x(),V=i.useMemo(()=>YC.createAxiosDateTransformer({baseURL:Z||""}),[Z]),z=i.useMemo(()=>d(),[]),X=i.useMemo(()=>Z?Xf(Z):null,[Z]),Q=i.useMemo(()=>Z?Jf(Z,$):null,[Z,$]),{data:T,isLoading:B,error:G}=s.useQuery({queryKey:["uiConfig",f.pathname+f.search,Z],enabled:!!Z,queryFn:async()=>{let J=new URLSearchParams(f.search);J.set("__pieroot","web");let F="/api/content"+f.pathname+"?"+J.toString();if(O)console.log("[PieRoot] Fetching UI configuration from:",F);let Y=await V.get(F,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(O)console.log("[PieRoot] Received UI configuration:",Y.data);return Y.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(J)=>Math.min(1000*2**J,30000),...D}),q=WC(f.pathname,C,U);if(!Z)return q??null;if(O)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",Z),console.log("[PieRoot] CENTRIFUGE_SERVER:",$),console.log("[PieRoot] Fallback provided:",!!U),console.log("[PieRoot] Piecache provided:",!!C);if(G){if(O)console.error("[PieRoot] Error fetching UI configuration:",G),console.error("[PieRoot] Error details:",{message:G.message,status:G.response?.status,data:G.response?.data});return H?.(G),q}if(B||!T){if(O)console.log("[PieRoot] Loading state:",{isLoading:B,hasUiConfiguration:!!T});return q}if(O)console.log("[PieRoot] UI configuration loaded successfully:",T),console.log("[PieRoot] Rendering UI with configuration");return K.jsx(y.Provider,{value:z,children:K.jsx(E.Provider,{value:X,children:K.jsx(N.Provider,{value:Q,children:K.jsx(M.Provider,{value:U??K.jsx(K.Fragment,{}),children:K.jsx(yf,{children:K.jsx(jf,{children:I?K.jsx(_,{uiConfig:T}):K.jsx("form",{id:"piedata_global_form",action:Z+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:K.jsx(_,{uiConfig:T})})})})})})})})},WH=(f)=>{let U=i.useMemo(()=>new s.QueryClient,[]),C=f.queryClient??U;return K.jsx(j.Provider,{value:f.onNavigate,children:K.jsx(b.Provider,{value:f.config,children:K.jsx(m.Provider,{value:f.onError,children:K.jsx(s.QueryClientProvider,{client:C,children:K.jsx(GH,{...f})})})})})},xf=WH;var t=require("react"),mf=require("@tanstack/react-query");var S=require("react/jsx-runtime"),QH=({location:f,fallback:U,children:C,disableGlobalForm:H})=>{let D=ff(),I=qf(),Z=x(),$=t.useMemo(()=>d(),[]),O=t.useMemo(()=>D?Xf(D):null,[D]),V=t.useMemo(()=>D?Jf(D,I):null,[D,I]);if(Z)console.log("[PieRoot] Rendering with location:",f),console.log("[PieRoot] API_SERVER:",D),console.log("[PieRoot] CENTRIFUGE_SERVER:",I),console.log("[PieRoot] Fallback provided:",!!U);return S.jsx(y.Provider,{value:$,children:S.jsx(E.Provider,{value:O,children:S.jsx(N.Provider,{value:V,children:S.jsx(M.Provider,{value:U??S.jsx(S.Fragment,{}),children:S.jsx(yf,{children:S.jsx(jf,{children:H?C:S.jsx("form",{id:"piedata_global_form",action:D+"api/process"+f.pathname,method:"post",encType:"multipart/form-data",children:C})})})})})})})},YH=(f)=>{let[U]=t.useState(()=>new mf.QueryClient),C=f.queryClient??U;return S.jsx(j.Provider,{value:f.onNavigate,children:S.jsx(b.Provider,{value:f.config,children:S.jsx(m.Provider,{value:f.onError,children:S.jsx(mf.QueryClientProvider,{client:C,children:S.jsx(QH,{...f})})})})})},AC=YH;var PC=require("react");var HU=require("react/jsx-runtime"),AH=HU.jsx("div",{style:{padding:16,fontFamily:"system-ui, sans-serif",color:"#888"},children:"Loading card…"}),PH=({apiServer:f,pathname:U="/",search:C="",centrifugeServer:H,fallback:D,enableRenderingLog:I=!1})=>{let Z=f??(typeof process<"u"?process.env.PIE_API_SERVER:void 0)??"",$=PC.useMemo(()=>({apiServer:Z,centrifugeServer:H,enableRenderingLog:I,pageProcessor:"web"}),[Z,H,I]);return HU.jsx(xf,{location:{pathname:U,search:C},config:$,fallback:D??AH,onNavigate:(V)=>{if(typeof window<"u")window.history.pushState(null,"",V)}})},FC=PH;var KC=require("react"),IU=(f,U=!1)=>{if(f==="sid"){if(!window.sid)throw Error("SocketIO isn't initialized properly");return[window.sid]}let C=document.getElementsByName(f);if(!C.length){if(U)console.warn(`No input found with name ${f}`);return[]}let H=C[0];if(H instanceof HTMLInputElement){if(H.type==="file"&&H.files)return Array.from(H.files);return[H.value]}if(H instanceof HTMLTextAreaElement)return[H.value];return[]},FH=(f,U={},C=[],H,D)=>{let I=D?.renderingLogEnabled??!1,Z=D?.timeout,$=D?.retryPolicy,O=$?.maxRetries??0,V=$?.baseDelay??1000,z=$?.retryOn??[502,503,504];if(I)console.log("Registering AJAX: ",H,U,C);return async(X={})=>{if(typeof window>"u"||typeof document>"u"){if(I)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}let Q=D?.apiServer;if(!Q){if(I)console.warn("AJAX skipped: apiServer is missing");return}if(!H||!f){if(I)console.warn("AJAX skipped: pathname or setUiAjaxConfiguration is missing");return}if(C.includes("sid"))await CU();let T=new FormData;for(let[q,J]of Object.entries({...U,...X}))T.append(q,J);for(let q of C)for(let J of IU(q,I))T.append(q,J);let B=Q+"api/ajax_content"+H;f(null);let G;for(let q=0;q<=O;q++){if(q>0){let Y=V*2**(q-1);if(I)console.log(`AJAX retry ${q}/${O} after ${Y}ms`);await new Promise((P)=>setTimeout(P,Y))}let J=Z!=null?new AbortController:null,F=J&&setTimeout(()=>J.abort(),Z);try{let Y=await fetch(B,{method:"POST",body:T,signal:J?.signal});if(F)clearTimeout(F);if(!Y.ok&&z.includes(Y.status)&&q<O){G=Error(`HTTP ${Y.status}`);continue}let Vf=(Y.headers.get("content-type")||"").includes("application/json");if(!!Y.body?.getReader&&!Vf){let $f=Y.body.getReader(),RC=new TextDecoder,p="";while(!0){let{done:uf,value:NC}=await $f.read();if(uf)break;p+=RC.decode(NC,{stream:!0});let DU=p.split(`
|
|
3
|
-
`);
|
|
2
|
+
var wZ=Object.create;var{getPrototypeOf:LZ,defineProperty:e,getOwnPropertyNames:TU,getOwnPropertyDescriptor:NZ}=Object,JU=Object.prototype.hasOwnProperty;var BU=(H,U,Z)=>{Z=H!=null?wZ(LZ(H)):{};let $=U||!H||!H.__esModule?e(Z,"default",{value:H,enumerable:!0}):Z;for(let T of TU(H))if(!JU.call($,T))e($,T,{get:()=>H[T],enumerable:!0});return $},zU=new WeakMap,fZ=(H)=>{var U=zU.get(H),Z;if(U)return U;if(U=e({},"__esModule",{value:!0}),H&&typeof H==="object"||typeof H==="function")TU(H).map(($)=>!JU.call(U,$)&&e(U,$,{get:()=>H[$],enumerable:!(Z=NZ(H,$))||Z.enumerable}));return zU.set(H,U),U};var EZ=(H,U)=>{for(var Z in U)e(H,Z,{get:U[Z],enumerable:!0,configurable:!0,set:($)=>U[Z]=()=>$})};var D$={};EZ(D$,{usePieEmit:()=>DU,useAjaxSubmit:()=>WZ,unregisterComponent:()=>AU,trackLazy:()=>VH,submitGlobalForm:()=>_Z,registry:()=>j,registerPieComponent:()=>_,registerMultipleComponents:()=>MU,readAjaxKeyAsync:()=>ZU,readAjaxKey:()=>UU,preloadComponent:()=>dH,prefetchLazyComponents:()=>NU,pieName:()=>KZ,parseDepName:()=>IH,hasComponent:()=>PU,getRegistrySize:()=>LU,getRegistryEntry:()=>l,getLazyComponentNames:()=>uH,getEmitter:()=>p,getComponentMeta:()=>RU,getAllRegisteredComponents:()=>wU,cn:()=>FZ,UnionCard:()=>mU,UIRendererContext:()=>E,UILoading:()=>MH,UI:()=>L,SocketIOContext:()=>k,SessionStorageCard:()=>tU,SequenceCard:()=>SU,PieRoot:()=>vH,PiePreviewRoot:()=>qZ,PieConfigContext:()=>h,PieCard:()=>A,PieBaseRoot:()=>XZ,PIEBREAK:()=>QH,OneOfCard:()=>JZ,MittContext:()=>x,IOEventsCard:()=>nU,HiddenCard:()=>dU,HTMLEmbedCard:()=>gU,FallbackContext:()=>f,DeviceStorageCard:()=>eU,CentrifugeIOContext:()=>y,BoxCard:()=>$Z,AutoRedirectCard:()=>iU,AjaxGroupCard:()=>UZ});module.exports=fZ(D$);var S=require("react");var XH=require("react");var pH=globalThis,K=(H,U)=>{let Z=Symbol.for(H);if(!(Z in pH))pH[Z]=U();return pH[Z]};var h=K("@swarm.ing/pieui:context:pieConfig",()=>XH.createContext(null)),HH=()=>{let H=XH.useContext(h);if(!H)throw Error("usePieConfig must be used within PieConfigProvider");return H},UH=()=>{let{apiServer:H}=HH();return H},YH=UH,qH=()=>{let{centrifugeServer:H}=HH();return H};var v=()=>{let{enableRenderingLog:H}=HH();return H},IU=v;var QH="__piedemo__";var GU=require("react"),gH=require("centrifuge");var OU=K("@swarm.ing/pieui:centrifuge-cache",()=>new Map),WH=(H,U)=>{if(!U)return null;let Z=`${H}::${U}`,$=OU.get(Z);if($)return $;async function T(){let J=await fetch(H+"api/centrifuge/gen_token");if(!J.ok){if(J.status===403)throw new gH.Centrifuge.UnauthorizedError("Backend is not answering");throw Error(`Unexpected status code ${J.status}`)}return(await J.json()).token}let z=new gH.Centrifuge(U,{getToken:T});return OU.set(Z,z),z},CZ=K("@swarm.ing/pieui:context:centrifuge",()=>GU.createContext(null)),y=CZ;var YU=require("socket.io-client"),qU=require("react");var XU=K("@swarm.ing/pieui:socket-cache",()=>new Map),DH=(H)=>{let U=XU.get(H);if(U)return U;let Z=YU.io(H,{autoConnect:!1,transports:["websocket"]});return XU.set(H,Z),Z},jZ=K("@swarm.ing/pieui:context:socket",()=>qU.createContext(null)),k=jZ;var QU=BU(require("mitt")),d=require("react");function p(){return K("@swarm.ing/pieui:mitt-emitter",()=>QU.default())}var WU=K("@swarm.ing/pieui:context:mitt",()=>d.createContext(null));function DU(H){let U=d.useContext(WU);return d.useCallback((Z,$)=>{(U??p()).emit(`pie${Z}_${H}`,$)},[H,U])}var x=WU;var o=require("react/jsx-runtime"),yZ=({card:H,data:U,children:Z,useSocketioSupport:$=!1,useCentrifugeSupport:T=!1,useMittSupport:z=!1,centrifugeChannel:J=void 0,methods:B=void 0,stored:I=void 0})=>{let O=IU(),D=S.useRef(B);if(D.current=B,O)console.log("[PieCard] Rendering card:",H),console.log("[PieCard] Card data:",U),console.log("[PieCard] Component name:",U?.name),console.log("[PieCard] Real-time support:",{socketio:$,centrifuge:T,mitt:z,centrifugeChannel:J}),console.log("[PieCard] Methods:",B?Object.keys(B):"none"),console.log("[PieCard] Has children:",!!Z);let Q=S.useContext(k),V=S.useContext(y),G=S.useContext(x);if(S.useEffect(()=>{if(!Q||!$||!D.current||!U.name){if(O&&$)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!Q,useSocketioSupport:$,hasMethods:!!D.current,hasDataName:!!U?.name});return}let W=Object.keys(D.current??{}).map((X)=>{let q=`pie${X}_${U.name}`;if(O)console.log(`[PieCard] Socket.IO registering event: ${q}`);let M=(F)=>{D.current?.[X]?.(F)};return Q.on(q,M),[q,M]});return()=>{W.forEach(([X,q])=>{if(O)console.log(`[PieCard] Socket.IO unregistering event: ${X}`);Q.off(X,q)})}},[Q,U.name,$]),S.useEffect(()=>{if(!V||!T||!J||!U.name){if(O&&T)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!V,useCentrifugeSupport:T,hasCentrifugeChannel:!!J,hasMethods:!!D.current,hasDataName:!!U?.name});return}let W=Object.keys(D.current??{}).map((X)=>{let q=`pie${X}_${U.name}_${J}`;if(O)console.log(`[PieCard] Centrifuge subscribing to channel: ${q}`);let M=V.newSubscription(q);return M.on("publication",(F)=>{if(O)console.log(`[PieCard] Centrifuge received data on ${q}:`,F.data);D.current?.[X]?.(F.data)}),M.subscribe(),M});return()=>{W.forEach((X)=>{if(O)console.log("[PieCard] Centrifuge unsubscribing from channel");X.unsubscribe(),V.removeSubscription(X)})}},[V,J,U.name,T]),S.useEffect(()=>{if(!G||!z||!U.name){if(O&&z)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!G,useMittSupport:z,hasMethods:!!D.current,hasDataName:!!U?.name});return}let Y=Object.keys(D.current??{}),W={};return Y.forEach((X)=>{let q=`pie${X}_${U.name}`,M=(F)=>{if(O)console.log(`[PieCard] Mitt registering event: ${q}`);D.current?.[X]?.(F)};W[q]=M,G.on(q,M)}),()=>{Object.entries(W).forEach(([X,q])=>{if(O)console.log(`[PieCard] Mitt unregistering event: ${X}`);G.off(X,q)})}},[G,U.name,z]),O)console.log("[PieCard] Rendering complete, returning children");if(I!==void 0)return o.jsxs(o.Fragment,{children:[o.jsx("input",{type:"hidden",name:U.name,value:JSON.stringify(I)}),Z]});return Z},A=yZ;var VU=require("react"),g=new Map;function FU(H,U){return U.catch(()=>{if(g.get(H)===U)g.delete(H)}),g.set(H,U),U}function VH(H,U){return VU.lazy(()=>{if(g.has(U))return g.get(U);return FU(U,H().then((Z)=>Z))})}var _U=async(H,U)=>{if(!U)return;if(g.has(H))return g.get(H);return FU(H,U().then((Z)=>Z))};var j=K("@swarm.ing/pieui:component-registry",()=>new Map),kZ=(H)=>{if(!H.name)throw Error("Component registration requires a name");if(!H.component&&!H.loader)throw Error(`Component "${H.name}" requires component or loader`);let U={name:H.name,component:H.component,loader:H.loader,metadata:H.metadata,fallback:H.fallback,isLazy:!1};if(!U.component&&U.loader)U.component=VH(U.loader,H.name),U.isLazy=!0;return U};function _(H){let U=kZ(H);return j.set(U.name,U),U.component}var MU=(H)=>{H.forEach((U)=>_(U))},AU=(H)=>{j.delete(H)},PU=(H)=>{return j.has(H)},RU=(H)=>{return j.get(H)?.metadata},l=(H)=>{return j.get(H)},wU=()=>{return Array.from(j.keys())},LU=()=>{return j.size},uH=()=>Array.from(j.values()).filter((H)=>H.isLazy&&typeof H.loader==="function").map((H)=>H.name),dH=(H)=>{let U=j.get(H);if(!U?.isLazy||typeof U.loader!=="function")return;return _U(H,U.loader)},KU=!1,NU=()=>{if(KU||typeof window>"u")return;KU=!0;let H=navigator.connection;if(H?.saveData)return;if(H?.effectiveType&&["slow-2g","2g"].includes(H.effectiveType))return;let U=uH(),Z="requestIdleCallback"in window?(T)=>window.requestIdleCallback(T,{timeout:2000}):(T)=>window.setTimeout(T,300),$=(T)=>{if(T>=U.length)return;Z(()=>{Promise.resolve().then(()=>dH(U[T])).catch(()=>{}).finally(()=>$(T+1))})};$(0)};var ZH=require("react");var fU=require("react");var FH=require("react/jsx-runtime"),xZ=K("@swarm.ing/pieui:context:fallback",()=>fU.createContext(FH.jsx(FH.Fragment,{}))),f=xZ;var EU=require("react");var SZ=K("@swarm.ing/pieui:context:lazyError",()=>EU.createContext(void 0)),m=SZ;var _H=require("react"),CU=require("react/jsx-runtime"),bZ=2,vZ=400;class i extends _H.Component{state={failed:!1,attempt:0};timer;static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(H){if(this.props.onError?.(H),this.state.attempt<bZ){let U=vZ*(this.state.attempt+1);this.timer=setTimeout(()=>{this.setState((Z)=>({failed:!1,attempt:Z.attempt+1}))},U)}}componentDidUpdate(H){if(H.name!==this.props.name&&this.state.attempt!==0)this.setState({failed:!1,attempt:0})}componentWillUnmount(){if(this.timer)clearTimeout(this.timer)}render(){if(this.state.failed)return this.props.fallback;return CU.jsx(_H.Suspense,{fallback:this.props.fallback,children:this.props.children},`${this.props.name}:${this.state.attempt}`)}}var KH=require("react/jsx-runtime");function mZ({uiConfig:H,setUiAjaxConfiguration:U}){let Z=ZH.useContext(f),$=ZH.useContext(m),T=v();if(T)console.log("[UI] Rendering component:",H.card),console.log("[UI] Component data:",H.data),console.log("[UI] Component content:",H.content),console.log("[UI] Has setUiAjaxConfiguration:",!!U);let z=l(H.card);if(!z?.component){if(T)console.warn(`[UI] Component not found in registry: ${H.card}`),console.log("[UI] Returning fallback component");return Z}if(T)console.log("[UI] Found component in registry:",{name:z.name,isLazy:z.isLazy,hasMetadata:!!z.metadata});let J=z.component,B=KH.jsx(J,{data:H.data,content:H.content,setUiAjaxConfiguration:U});if(z.isLazy){if(T)console.log("[UI] Rendering lazy component with Suspense:",z.name);return KH.jsx(i,{name:z.name,fallback:z.fallback?KH.jsx(z.fallback,{}):Z,onError:$,children:B})}if(T)console.log("[UI] Rendering component directly:",z.name);return B}var L=ZH.memo(mZ);var oH=require("react");var jU=require("react");var cZ=K("@swarm.ing/pieui:context:uiRenderer",()=>jU.createContext(null)),E=cZ;var $H=require("react/jsx-runtime");function yU({uiConfig:H,setUiAjaxConfiguration:U}){let Z=oH.useContext(f),$=oH.useContext(m),T=v();if(T)console.log("[UILoading] Rendering fallback for:",H.card),console.log("[UILoading] Component data:",H.data),console.log("[UILoading] Component content:",H.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!U);let z=l(H.card);if(!z?.component){if(T)console.warn(`[UILoading] Component not found in registry: ${H.card}`),console.log("[UILoading] Returning fallback component");return Z}if(T)console.log("[UILoading] Found component in registry:",{name:z.name,isLazy:z.isLazy,hasMetadata:!!z.metadata,hasFallback:!!z.fallback});if(z.fallback){if(T)console.log("[UILoading] Rendering fallback for:",z.name);let I=z.fallback;return $H.jsx(I,{})}if(T)console.log("[UILoading] No fallback, rendering full component:",z.name);let J=z.component,B=$H.jsx(E.Provider,{value:yU,children:$H.jsx(J,{data:H.data,content:H.content,setUiAjaxConfiguration:U})});if(z.isLazy)return $H.jsx(i,{name:z.name,fallback:Z,onError:$,children:B});return B}var MH=yU;var kU=require("react");var AH=require("react/jsx-runtime"),hZ=({data:H,content:U,setUiAjaxConfiguration:Z})=>{let{name:$,sx:T}=H,z=kU.useContext(E)??L;return AH.jsx(A,{card:$,data:H,children:AH.jsx("div",{style:T,id:$,children:U.map((J,B)=>{return AH.jsx(z,{uiConfig:J,setUiAjaxConfiguration:Z},`children-${B}`)})})})},xU=hZ;var SU=_({name:"SequenceCard",component:xU,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});var bU=require("react");var lH=require("react/jsx-runtime"),pZ=({data:H,content:U,setUiAjaxConfiguration:Z})=>{let{name:$}=H,T=bU.useContext(E)??L;return lH.jsx(A,{card:$,data:H,children:U.map((z,J)=>{return lH.jsx(T,{uiConfig:z,setUiAjaxConfiguration:Z},`children-${J}`)})})},vU=pZ;var mU=_({name:"UnionCard",component:vU,metadata:{author:"Swarm.ing",description:"Renders one of many components"}});var PH=require("react"),cU=BU(require("html-react-parser"));var C=require("react");function gZ(){let H=new AudioContext,U=H.createOscillator(),Z=U.connect(H.createMediaStreamDestination());U.start();let $=Z.stream.getAudioTracks()[0];return $.enabled=!1,$}function iH(H=null,U){let[Z,$]=C.useState(!1),T=C.useRef(null),z=C.useRef(null),J=C.useRef(null),B=C.useCallback(async(Q,V=!0)=>{if(T.current)I();let G=new RTCPeerConnection;if(G.onconnectionstatechange=()=>{if(G.connectionState==="connected")$(!0);else if(["disconnected","failed","closed"].includes(G.connectionState))$(!1)},G.ontrack=(P)=>{if(H)H.srcObject=P.streams[0]},V){let P=await navigator.mediaDevices.getUserMedia({audio:!0});G.addTrack(P.getTracks()[0],P)}else{let P=gZ();G.addTrack(P)}let Y=G.createDataChannel("oai-events");z.current=Y,J.current=new Promise((P)=>{Y.addEventListener("open",()=>{P()})});let W=await G.createOffer();await G.setLocalDescription(W);let F=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:W.sdp,headers:{Authorization:`Bearer ${Q}`,"Content-Type":"application/sdp"}})).text();await G.setRemoteDescription({type:"answer",sdp:F}),T.current=G,await J.current},[H]),I=C.useCallback(()=>{let Q=z.current;if(Q)Q.close();T.current?.getSenders()?.forEach((V)=>V.track?.stop()),T.current?.close(),$(!1),T.current=null,z.current=null,J.current=null},[H]),O=C.useCallback((Q)=>{let V=z.current;if(!V){console.error("Data channel is not ready",Q);return}let G=new Date().toLocaleTimeString();if(Q.event_id=Q.event_id||crypto.randomUUID(),V.send(JSON.stringify(Q)),!Q.timestamp)Q.timestamp=G;U?.(Q)},[U,H]),D=C.useCallback((Q)=>{if(!z.current){console.error("Data channel is not ready");return}let G=()=>{O({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:Q}]}}),O({type:"response.create"})};if(J.current)J.current.then(G);else G()},[U,H]);return C.useEffect(()=>{let Q=z.current;if(!Q)return;let V=(G)=>{let Y=JSON.parse(G.data);if(!Y.timestamp)Y.timestamp=new Date().toLocaleTimeString();U?.(Y)};return Q.addEventListener("message",V),()=>{Q.removeEventListener("message",V)}},[U,H]),{isSessionActive:Z,startSession:B,stopSession:I,sendTextMessage:D}}var pU=require("react/jsx-runtime"),uZ=({data:H})=>{let{html:U,useSocketioSupport:Z,useCentrifugeSupport:$,useMittSupport:T,centrifugeChannel:z}=H,[J,B]=PH.useState(U),{isSessionActive:I,startSession:O,sendTextMessage:D}=iH(null,(Y)=>{if(console.log(Y.type,Y.type==="response.output_text.delta"&&Y.delta),Y.type==="response.output_text.delta"&&Y.delta)B((W)=>W+Y.delta)});return PH.useEffect(()=>{B(U)},[U]),pU.jsx(A,{card:"HTMLEmbedCard",data:H,methods:{update:(Y)=>{B(Y.value)},generateUsingAI:async(Y)=>{try{if(!I&&Y.token)await O(Y.token,!1);D(Y.prompt)}catch(W){console.error("Failed to generate using AI",W)}},initializeAI:async(Y)=>{if(!I&&Y.token)await O(Y.token,!1)}},useCentrifugeSupport:$,useSocketioSupport:Z,useMittSupport:T,centrifugeChannel:z,children:cU.default(J)})},hU=uZ;var gU=_({name:"HTMLEmbedCard",component:hU,metadata:{author:"Swarm.ing"}});var RH=require("react");var sH=require("react/jsx-runtime"),dZ=({data:H})=>{let{name:U,value:Z,useSocketioSupport:$,useCentrifugeSupport:T,useMittSupport:z,centrifugeChannel:J}=H,[B,I]=RH.useState(Z);return RH.useEffect(()=>{I(Z)},[Z]),sH.jsx(A,{card:"HiddenCard",data:H,useSocketioSupport:$,useCentrifugeSupport:T,useMittSupport:z,centrifugeChannel:J,methods:{update:({value:O})=>{I(O)}},children:sH.jsx("input",{type:"hidden",id:U,name:U,value:B})})},uU=dZ;var dU=_({name:"HiddenCard",component:uU,metadata:{author:"Swarm.ing"}});var zH=require("react");var oU=require("react");var oZ=K("@swarm.ing/pieui:context:navigate",()=>oU.createContext(void 0)),b=oZ;var wH=require("react/jsx-runtime"),lZ=({data:H})=>{let{url:U}=H,Z=zH.useContext(b),$=zH.useContext(f);return zH.useEffect(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(U))window.location.href=U;else Z?.(U)},[U,Z]),wH.jsx(wH.Fragment,{children:$})},lU=lZ;var iU=_({name:"AutoRedirectCard",component:lU,metadata:{author:"Swarm.ing"}});var c=require("react-toastify"),LH=require("react-toastify");var n=require("react");var s=require("react/jsx-runtime"),iZ={bounce:c.Bounce,slide:c.Slide,zoom:c.Zoom,flip:c.Flip},sZ=(H)=>{let U={...H,type:H.alertType,transition:H.transition?iZ[H.transition]:void 0,position:H.position??"bottom-right",autoClose:H.autoClose??3000,style:{backgroundColor:"black",...H.sx}};LH.toast(H.message,U)},nZ=(H)=>{console.log("Log event",H)},rZ=(H)=>{if(typeof window>"u"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let U=()=>{try{new window.Notification(H.title,{body:H.message??H.subtitle,icon:H.icon,silent:H.silent})}catch($){console.error("[IOEventsCard] Failed to show notification",$)}},Z=window.Notification.permission;if(Z==="granted"){U();return}if(Z==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then(($)=>{if($==="granted")U()})},tZ=({data:H})=>{let{useCentrifugeSupport:U,useSocketioSupport:Z,useMittSupport:$,centrifugeChannel:T}=H,z=n.useContext(b),J=n.useRef(z);J.current=z;let B=n.useMemo(()=>({alert:sZ,log:nZ,push:rZ,redirect:(I)=>{if(I.to){let O=I.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(O))window.location.href=O;else J.current?.(O)}else window.location.reload()},reload:(I)=>{if(I.to){let O=I.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(O))window.location.href=O;else J.current?.(O)}else window.location.reload()}}),[]);return s.jsx(s.Fragment,{children:s.jsx(A,{card:"IOEventsCard",data:H,useCentrifugeSupport:U,useSocketioSupport:Z,useMittSupport:$,centrifugeChannel:T,methods:B,children:s.jsx(LH.ToastContainer,{})})})},sU=tZ;var nU=_({name:"IOEventsCard",component:sU,metadata:{author:"Swarm.ing"}});var TH=require("react");var nH=require("react/jsx-runtime"),aZ=({data:H})=>{let{name:U,key:Z,value:$,useSocketioSupport:T,useCentrifugeSupport:z,useMittSupport:J,centrifugeChannel:B}=H,[I,O]=TH.useState($);return TH.useEffect(()=>{O($)},[$]),TH.useEffect(()=>{if(typeof window>"u")return;sessionStorage.setItem(Z,I)},[Z,I]),nH.jsx(A,{card:"SessionStorageCard",data:H,useSocketioSupport:T,useCentrifugeSupport:z,useMittSupport:J,centrifugeChannel:B,methods:{update:({value:D})=>{O(D)},remove:()=>{sessionStorage.removeItem(Z),O("")}},children:nH.jsx("input",{type:"hidden",id:U,name:U,value:I})})},rU=aZ;var tU=_({name:"SessionStorageCard",component:rU,metadata:{author:"PieData"}});var JH=require("react");var rH=require("react/jsx-runtime"),eZ=({data:H})=>{let{name:U,key:Z,value:$,useSocketioSupport:T,useCentrifugeSupport:z,useMittSupport:J,centrifugeChannel:B}=H,[I,O]=JH.useState($);return JH.useEffect(()=>{O($)},[$]),JH.useEffect(()=>{if(typeof window>"u")return;localStorage.setItem(Z,I)},[Z,I]),rH.jsx(A,{card:"DeviceStorageCard",data:H,useSocketioSupport:T,useCentrifugeSupport:z,useMittSupport:J,centrifugeChannel:B,methods:{update:({value:D})=>{O(D)},remove:()=>{localStorage.removeItem(Z),O("")}},children:rH.jsx("input",{type:"hidden",id:U,name:U,value:I})})},aU=eZ;var eU=_({name:"DeviceStorageCard",component:aU,metadata:{author:"PieData"}});var N=require("react");var tH=require("react/jsx-runtime"),H$=({data:H,content:U})=>{let{useLoader:Z,noReturn:$,returnType:T,useSocketioSupport:z,useCentrifugeSupport:J,useMittSupport:B,centrifugeChannel:I}=H,O=N.useContext(f),D=N.useContext(E)??L,[Q,V]=N.useState(!1),[G,Y]=N.useState(null),W=N.useRef(U),X=N.useContext(x),q=N.useCallback((P)=>{if(P===null)V(!0);else if(V(!1),!$)W.current=P;if(!$)Y(P)},[$]),M=N.useCallback((P)=>{W.current=P.content,Y(P.content)},[]),F=N.useCallback((P)=>{if(P===null)V(!0);else if(V(!1),!$)for(let OH of P)X?.emit(OH.name,OH.data)},[$,X]);if(N.useEffect(()=>{Y(U),V(!1)},[U]),!G&&Z)return O;return tH.jsx(A,{card:"AjaxGroupCard",data:H,methods:{changeContent:M},useSocketioSupport:z,useCentrifugeSupport:J,useMittSupport:B,centrifugeChannel:I,children:tH.jsx(D,{uiConfig:G??W.current,setUiAjaxConfiguration:T==="events"?F:q})})},HZ=H$;var UZ=_({name:"AjaxGroupCard",component:HZ,metadata:{author:"Swarm.ing",description:"Group card with AJAX support"}});var aH=require("react");var NH=require("react/jsx-runtime"),U$=({data:H,content:U,setUiAjaxConfiguration:Z})=>{let{name:$,url:T,sx:z}=H,J=aH.useContext(b),B=aH.useContext(E)??L;return NH.jsx(A,{card:$,data:H,children:NH.jsx("div",{style:z,id:$,onClick:(O)=>{if(T)if(O.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(T))window.location.href=T;else J?.(T)},children:NH.jsx(B,{setUiAjaxConfiguration:Z,uiConfig:U})})})},ZZ=U$;var $Z=_({name:"BoxCard",component:ZZ,metadata:{author:"Swarm.ing",description:"Simple div with styles joining few components"}});var zZ=require("react");var fH=require("react/jsx-runtime"),Z$=({data:H,content:U,setUiAjaxConfiguration:Z})=>{let{name:$,sx:T}=H,z=zZ.useContext(E)??L;return fH.jsx(A,{card:$,data:H,children:fH.jsx("div",{style:T,id:$,children:U.map((J,B)=>{return fH.jsx(z,{uiConfig:J,setUiAjaxConfiguration:Z},`children-${B}`)})})})},TZ=Z$;var JZ=_({name:"OneOfCard",component:TZ,metadata:{author:"Swarm.ing",description:"Different variants"}});var r=require("react"),t=require("@tanstack/react-query");var kH=require("react");var jH=require("react"),EH=new Map,CH=new Map;function yH(H,U){let Z=`${H}::${U}`,$=H?EH.get(Z):void 0,[T,z]=jH.useState($??null);return jH.useEffect(()=>{if(!H)return;if(EH.has(Z)){z(EH.get(Z));return}let J=CH.get(Z);if(!J)J=fetch(H+`api/support/${U}`,{method:"GET"}).then((I)=>I.json()).then((I)=>{return EH.set(Z,I),CH.delete(Z),I}).catch((I)=>{throw CH.delete(Z),I}),CH.set(Z,J);let B=!1;return J.then((I)=>{if(!B)z(I)}).catch(()=>{}),()=>{B=!0}},[H,U,Z]),T}var BH=K("@swarm.ing/pieui:sid-state",()=>({promise:null,resolve:null}));function BZ(){BH.resolve?.()}function eH(){if(typeof window>"u")return Promise.resolve();if(typeof window.sid<"u")return Promise.resolve();if(!BH.promise)BH.promise=new Promise((H)=>{BH.resolve=()=>{H()}});return BH.promise}var $$=({children:H})=>{let U=kH.useContext(k),Z=YH(),$=yH(Z,"socketIO"),T=(z)=>{if(typeof window<"u")window.sid=z.sid,BZ(),console.log(`SocketIO initialized: ${window.sid}`)};return kH.useEffect(()=>{if(!U)return;let z=()=>{console.log("SocketIO connected")},J=(B)=>{console.log(`SocketIO disconnected: ${B}`),U.connect()};if($)U.on("pieinit",T),U.on("connect",z),U.on("disconnect",J),U.connect();return()=>{if($)U.off("pieinit",T),U.off("connect",z),U.off("disconnect",J),U.disconnect()}},[U,$]),H},xH=$$;var SH=require("react");var z$=({children:H})=>{let U=SH.useContext(y),Z=YH(),$=yH(Z,"centrifuge");return SH.useEffect(()=>{if(!U)return;let T=()=>{console.log("Centrifuge connected")},z=(J)=>{console.log("Centrifuge disconnected:",J)};if($)U.on("connected",T),U.on("disconnected",z),U.connect();return()=>{if($)U.disconnect()}},[U,$]),H},bH=z$;var GZ=require("axios-date-transformer");var OZ=require("react/jsx-runtime");function IZ(H,U,Z){if(!U)return Z;let $=H.replace(/^\//,""),T=U[$];if(!T)return Z;return OZ.jsx(MH,{uiConfig:T})}var R=require("react/jsx-runtime"),T$=({location:H,fallback:U,piecache:Z,onError:$,queryOptions:T,disableGlobalForm:z})=>{let J=UH(),B=qH(),I=v(),O=r.useMemo(()=>GZ.createAxiosDateTransformer({baseURL:J||""}),[J]),D=r.useMemo(()=>p(),[]),Q=r.useMemo(()=>J?DH(J):null,[J]),V=r.useMemo(()=>J?WH(J,B):null,[J,B]),{data:G,isLoading:Y,error:W}=t.useQuery({queryKey:["uiConfig",H.pathname+H.search,J],enabled:!!J,queryFn:async()=>{let q=new URLSearchParams(H.search);q.set("__pieroot","web");let M="/api/content"+H.pathname+"?"+q.toString();if(I)console.log("[PieRoot] Fetching UI configuration from:",M);let F=await O.get(M,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(I)console.log("[PieRoot] Received UI configuration:",F.data);return F.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(q)=>Math.min(1000*2**q,30000),...T}),X=IZ(H.pathname,Z,U);if(!J)return X??null;if(I)console.log("[PieRoot] Rendering with location:",H),console.log("[PieRoot] API_SERVER:",J),console.log("[PieRoot] CENTRIFUGE_SERVER:",B),console.log("[PieRoot] Fallback provided:",!!U),console.log("[PieRoot] Piecache provided:",!!Z);if(W){if(I)console.error("[PieRoot] Error fetching UI configuration:",W),console.error("[PieRoot] Error details:",{message:W.message,status:W.response?.status,data:W.response?.data});return $?.(W),X}if(Y||!G){if(I)console.log("[PieRoot] Loading state:",{isLoading:Y,hasUiConfiguration:!!G});return X}if(I)console.log("[PieRoot] UI configuration loaded successfully:",G),console.log("[PieRoot] Rendering UI with configuration");return R.jsx(x.Provider,{value:D,children:R.jsx(k.Provider,{value:Q,children:R.jsx(y.Provider,{value:V,children:R.jsx(f.Provider,{value:U??R.jsx(R.Fragment,{}),children:R.jsx(xH,{children:R.jsx(bH,{children:z?R.jsx(L,{uiConfig:G}):R.jsx("form",{id:"piedata_global_form",action:J+"api/process"+H.pathname,method:"post",encType:"multipart/form-data",children:R.jsx(L,{uiConfig:G})})})})})})})})},J$=(H)=>{let U=r.useMemo(()=>new t.QueryClient,[]),Z=H.queryClient??U;return R.jsx(b.Provider,{value:H.onNavigate,children:R.jsx(h.Provider,{value:H.config,children:R.jsx(m.Provider,{value:H.onError,children:R.jsx(t.QueryClientProvider,{client:Z,children:R.jsx(T$,{...H})})})})})},vH=J$;var a=require("react"),mH=require("@tanstack/react-query");var w=require("react/jsx-runtime"),B$=({location:H,fallback:U,children:Z,disableGlobalForm:$})=>{let T=UH(),z=qH(),J=v(),B=a.useMemo(()=>p(),[]),I=a.useMemo(()=>T?DH(T):null,[T]),O=a.useMemo(()=>T?WH(T,z):null,[T,z]);if(J)console.log("[PieRoot] Rendering with location:",H),console.log("[PieRoot] API_SERVER:",T),console.log("[PieRoot] CENTRIFUGE_SERVER:",z),console.log("[PieRoot] Fallback provided:",!!U);return w.jsx(x.Provider,{value:B,children:w.jsx(k.Provider,{value:I,children:w.jsx(y.Provider,{value:O,children:w.jsx(f.Provider,{value:U??w.jsx(w.Fragment,{}),children:w.jsx(xH,{children:w.jsx(bH,{children:$?Z:w.jsx("form",{id:"piedata_global_form",action:T+"api/process"+H.pathname,method:"post",encType:"multipart/form-data",children:Z})})})})})})})},I$=(H)=>{let[U]=a.useState(()=>new mH.QueryClient),Z=H.queryClient??U;return w.jsx(b.Provider,{value:H.onNavigate,children:w.jsx(h.Provider,{value:H.config,children:w.jsx(m.Provider,{value:H.onError,children:w.jsx(mH.QueryClientProvider,{client:Z,children:w.jsx(B$,{...H})})})})})},XZ=I$;var YZ=require("react");var HU=require("react/jsx-runtime"),O$=HU.jsx("div",{style:{padding:16,fontFamily:"system-ui, sans-serif",color:"#888"},children:"Loading card…"}),G$=({apiServer:H,pathname:U="/",search:Z="",centrifugeServer:$,fallback:T,enableRenderingLog:z=!1})=>{let J=H??(typeof process<"u"?process.env.PIE_API_SERVER:void 0)??"",B=YZ.useMemo(()=>({apiServer:J,centrifugeServer:$,enableRenderingLog:z,pageProcessor:"web"}),[J,$,z]);return HU.jsx(vH,{location:{pathname:U,search:Z},config:B,fallback:T??O$,onNavigate:(O)=>{if(typeof window<"u")window.history.pushState(null,"",O)}})},qZ=G$;var QZ=require("react"),X$=["localStorage","sessionStorage","cookie","url","telegram:cloud","telegram:secure"],Y$=new Set(["telegram:cloud","telegram:secure"]),IH=(H)=>{if(H==="sid")return{source:"sid",key:"sid"};for(let U of X$){let Z=U+":";if(H.startsWith(Z))return{source:U,key:H.slice(Z.length)}}return{source:"dom",key:H}},UU=(H,U=!1)=>{let{source:Z,key:$}=IH(H);if(Z==="sid"){if(!window.sid)throw Error("SocketIO isn't initialized properly");return[window.sid]}if(Z==="localStorage"||Z==="sessionStorage")try{let B=(Z==="localStorage"?window.localStorage:window.sessionStorage).getItem($);if(B===null){if(U)console.warn(`No ${Z} value found for key ${$}`);return[]}return[B]}catch(J){if(U)console.warn(`Failed to read ${Z} key ${$}:`,J);return[]}if(Z==="cookie"){let J=q$($);if(J===null){if(U)console.warn(`No cookie found for key ${$}`);return[]}return[J]}if(Z==="url"){let J=new URLSearchParams(window.location.search).getAll($);if(!J.length&&U)console.warn(`No URL query param found for key ${$}`);return J}if(Y$.has(Z)){if(U)console.warn(`Source ${Z} is async; use readAjaxKeyAsync (readAjaxKey returns [])`);return[]}let T=document.getElementsByName($);if(!T.length){if(U)console.warn(`No input found with name ${$}`);return[]}let z=T[0];if(z instanceof HTMLInputElement){if(z.type==="file"&&z.files)return Array.from(z.files);return[z.value]}if(z instanceof HTMLTextAreaElement)return[z.value];return[]},q$=(H)=>{let U=document.cookie?document.cookie.split(";"):[];for(let Z of U){let $=Z.indexOf("=");if(($===-1?Z:Z.slice(0,$)).trim()===H){let z=$===-1?"":Z.slice($+1).trim();try{return decodeURIComponent(z)}catch{return z}}}return null},Q$=(H,U,Z)=>{let $=window.Telegram?.WebApp,T=H==="telegram:cloud"?$?.CloudStorage:$?.SecureStorage,z=H==="telegram:cloud"?"Telegram CloudStorage":"Telegram SecureStorage";if(!T){if(Z)console.warn(`${z} is not available`);return Promise.resolve([])}return new Promise((J)=>{try{T.getItem(U,(B,I)=>{if(B){if(Z)console.warn(`Failed to read ${z} key ${U}:`,B);J([]);return}if(I==null||I===""){if(Z)console.warn(`No ${z} value found for key ${U}`);J([]);return}J([I])})}catch(B){if(Z)console.warn(`Failed to read ${z} key ${U}:`,B);J([])}})},ZU=async(H,U=!1)=>{let{source:Z,key:$}=IH(H);if(Z==="telegram:cloud"||Z==="telegram:secure")return Q$(Z,$,U);return UU(H,U)},W$=(H,U={},Z=[],$,T)=>{let z=T?.renderingLogEnabled??!1,J=T?.timeout,B=T?.retryPolicy,I=B?.maxRetries??0,O=B?.baseDelay??1000,D=B?.retryOn??[502,503,504];if(z)console.log("Registering AJAX: ",$,U,Z);return async(Q={})=>{if(typeof window>"u"||typeof document>"u"){if(z)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}let V=T?.apiServer;if(!V){if(z)console.warn("AJAX skipped: apiServer is missing");return}if(!$||!H){if(z)console.warn("AJAX skipped: pathname or setUiAjaxConfiguration is missing");return}if(Z.includes("sid"))await eH();let G=new FormData;for(let[X,q]of Object.entries({...U,...Q}))G.append(X,q);for(let X of Z){let{key:q}=IH(X);for(let M of await ZU(X,z))G.append(q,M)}let Y=V+"api/ajax_content"+$;H(null);let W;for(let X=0;X<=I;X++){if(X>0){let F=O*2**(X-1);if(z)console.log(`AJAX retry ${X}/${I} after ${F}ms`);await new Promise((P)=>setTimeout(P,F))}let q=J!=null?new AbortController:null,M=q&&setTimeout(()=>q.abort(),J);try{let F=await fetch(Y,{method:"POST",body:G,signal:q?.signal});if(M)clearTimeout(M);if(!F.ok&&D.includes(F.status)&&X<I){W=Error(`HTTP ${F.status}`);continue}let OH=(F.headers.get("content-type")||"").includes("application/json");if(!!F.body?.getReader&&!OH){let GH=F.body.getReader(),MZ=new TextDecoder,u="";while(!0){let{done:cH,value:AZ}=await GH.read();if(cH)break;u+=MZ.decode(AZ,{stream:!0});let $U=u.split(`
|
|
3
|
+
`);u=$U.pop()??"";for(let PZ of $U){let hH=PZ.trim();if(!hH)continue;try{let RZ=JSON.parse(hH);H([RZ])}catch{if(z)console.warn("Failed to parse streamed line:",hH)}}}if(u.trim())try{let cH=JSON.parse(u);H([cH])}catch{if(z)console.warn("Failed to parse final streamed line:",u)}return{}}else{let GH=await F.json();return H(GH),GH}}catch(F){if(M)clearTimeout(M);if(W=F,X<I)continue;if(z)console.error("AJAX request failed:",F);return H(null),F}}if(z)console.error("AJAX request failed after retries:",W);return H(null),W}},WZ=(H,U={},Z=[],$,T)=>{let{apiServer:z,enableRenderingLog:J}=HH(),B=JSON.stringify(U),I=JSON.stringify(Z),O=JSON.stringify(T);return QZ.useMemo(()=>W$(H,U,Z,$,{apiServer:z,renderingLogEnabled:J,timeout:T?.timeout,retryPolicy:T?.retryPolicy}),[H,B,I,$,z,J,O])};var DZ=require("clsx"),VZ=require("tailwind-merge");function FZ(...H){return VZ.twMerge(DZ.clsx(H))}var _Z=()=>{if(typeof document>"u")return;let H=document.getElementById("piedata_global_form");H&&H.submit()};var KZ=(H,U)=>`${H}${QH}${U}`;
|
package/dist/max/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{useMemo as
|
|
2
|
+
import{useMemo as R}from"react";import{QueryClient as rU,QueryClientProvider as aU,useQuery as tU}from"@tanstack/react-query";import HU from"mitt";import{createContext as NU,useCallback as HL,useContext as NL}from"react";var A=globalThis,J=(U,L)=>{let T=Symbol.for(U);if(!(T in A))A[T]=L();return A[T]};function b(){return J("@swarm.ing/pieui:mitt-emitter",()=>HU())}var ZU=J("@swarm.ing/pieui:context:mitt",()=>NU(null));var u=ZU;import{io as VU}from"socket.io-client";import{createContext as YU}from"react";var c=J("@swarm.ing/pieui:socket-cache",()=>new Map),o=(U)=>{let L=c.get(U);if(L)return L;let T=VU(U,{autoConnect:!1,transports:["websocket"]});return c.set(U,T),T},FU=J("@swarm.ing/pieui:context:socket",()=>YU(null)),K=FU;import{createContext as GU}from"react";import{Centrifuge as g}from"centrifuge";var h=J("@swarm.ing/pieui:centrifuge-cache",()=>new Map),l=(U,L)=>{if(!L)return null;let T=`${U}::${L}`,D=h.get(T);if(D)return D;async function z(){let $=await fetch(U+"api/centrifuge/gen_token");if(!$.ok){if($.status===403)throw new g.UnauthorizedError("Backend is not answering");throw Error(`Unexpected status code ${$.status}`)}return(await $.json()).token}let I=new g(L,{getToken:z});return h.set(T,I),I},OU=J("@swarm.ing/pieui:context:centrifuge",()=>GU(null)),X=OU;import{useContext as KU,useEffect as XU}from"react";import{useEffect as QU,useState as _U}from"react";var B=new Map,W=new Map;function f(U,L){let T=`${U}::${L}`,D=U?B.get(T):void 0,[z,I]=_U(D??null);return QU(()=>{if(!U)return;if(B.has(T)){I(B.get(T));return}let $=W.get(T);if(!$)$=fetch(U+`api/support/${L}`,{method:"GET"}).then((H)=>H.json()).then((H)=>{return B.set(T,H),W.delete(T),H}).catch((H)=>{throw W.delete(T),H}),W.set(T,$);let Z=!1;return $.then((H)=>{if(!Z)I(H)}).catch(()=>{}),()=>{Z=!0}},[U,L,T]),z}import{createContext as qU,useContext as RU}from"react";var y=J("@swarm.ing/pieui:context:pieConfig",()=>qU(null)),w=()=>{let U=RU(y);if(!U)throw Error("usePieConfig must be used within PieConfigProvider");return U},k=()=>{let{apiServer:U}=w();return U},j=k,p=()=>{let{centrifugeServer:U}=w();return U};var Y=()=>{let{enableRenderingLog:U}=w();return U};var EU=J("@swarm.ing/pieui:sid-state",()=>({promise:null,resolve:null}));function n(){EU.resolve?.()}var BU=({children:U})=>{let L=KU(K),T=j(),D=f(T,"socketIO"),z=(I)=>{if(typeof window<"u")window.sid=I.sid,n(),console.log(`SocketIO initialized: ${window.sid}`)};return XU(()=>{if(!L)return;let I=()=>{console.log("SocketIO connected")},$=(Z)=>{console.log(`SocketIO disconnected: ${Z}`),L.connect()};if(D)L.on("pieinit",z),L.on("connect",I),L.on("disconnect",$),L.connect();return()=>{if(D)L.off("pieinit",z),L.off("connect",I),L.off("disconnect",$),L.disconnect()}},[L,D]),U},s=BU;import{useContext as WU,useEffect as fU}from"react";var jU=({children:U})=>{let L=WU(X),T=j(),D=f(T,"centrifuge");return fU(()=>{if(!L)return;let z=()=>{console.log("Centrifuge connected")},I=($)=>{console.log("Centrifuge disconnected:",$)};if(D)L.on("connected",z),L.on("disconnected",I),L.connect();return()=>{if(D)L.disconnect()}},[L,D]),U},i=jU;import{createContext as MU}from"react";import{jsx as yU,Fragment as AU}from"react/jsx-runtime";var PU=J("@swarm.ing/pieui:context:fallback",()=>MU(yU(AU,{}))),F=PU;import{createContext as wU}from"react";var kU=J("@swarm.ing/pieui:context:lazyError",()=>wU(void 0)),G=kU;var mU=J("@swarm.ing/pieui:component-registry",()=>new Map);var M=(U)=>{return mU.get(U)};import{useContext as r,memo as bU}from"react";import{Component as CU,Suspense as dU}from"react";import{jsx as xU}from"react/jsx-runtime";var SU=2,vU=400;class O extends CU{state={failed:!1,attempt:0};timer;static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(U){if(this.props.onError?.(U),this.state.attempt<SU){let L=vU*(this.state.attempt+1);this.timer=setTimeout(()=>{this.setState((T)=>({failed:!1,attempt:T.attempt+1}))},L)}}componentDidUpdate(U){if(U.name!==this.props.name&&this.state.attempt!==0)this.setState({failed:!1,attempt:0})}componentWillUnmount(){if(this.timer)clearTimeout(this.timer)}render(){if(this.state.failed)return this.props.fallback;return xU(dU,{fallback:this.props.fallback,children:this.props.children},`${this.props.name}:${this.state.attempt}`)}}import{jsx as m}from"react/jsx-runtime";function uU({uiConfig:U,setUiAjaxConfiguration:L}){let T=r(F),D=r(G),z=Y();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:",!!L);let I=M(U.card);if(!I?.component){if(z)console.warn(`[UI] Component not found in registry: ${U.card}`),console.log("[UI] Returning fallback component");return T}if(z)console.log("[UI] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata});let $=I.component,Z=m($,{data:U.data,content:U.content,setUiAjaxConfiguration:L});if(I.isLazy){if(z)console.log("[UI] Rendering lazy component with Suspense:",I.name);return m(O,{name:I.name,fallback:I.fallback?m(I.fallback,{}):T,onError:D,children:Z})}if(z)console.log("[UI] Rendering component directly:",I.name);return Z}var C=bU(uU);import{createAxiosDateTransformer as eU}from"axios-date-transformer";import{useEffect as a,useState as cU}from"react";var Q=()=>{let[U,L]=cU(null);return a(()=>{if(typeof window>"u")return;let T=window.WebApp;if(!T)return;T.ready(),L(T)},[]),U},oU=()=>{let U=Q();return[U?.initDataUnsafe,U?.initData]},gU=(U)=>{let L=Q();return a(()=>{if(!L||!U)return;return L.BackButton.onClick(U),L.BackButton.show(),()=>{L.BackButton.offClick(U),L.BackButton.hide()}},[L,U]),L?.BackButton??null},hU=()=>{return Q()?.HapticFeedback??null};import{createContext as lU}from"react";var pU=J("@swarm.ing/pieui:context:navigate",()=>lU(void 0)),t=pU;import{useContext as UU}from"react";import{createContext as nU}from"react";var sU=J("@swarm.ing/pieui:context:uiRenderer",()=>nU(null)),e=sU;import{jsx as P}from"react/jsx-runtime";function LU({uiConfig:U,setUiAjaxConfiguration:L}){let T=UU(F),D=UU(G),z=Y();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:",!!L);let I=M(U.card);if(!I?.component){if(z)console.warn(`[UILoading] Component not found in registry: ${U.card}`),console.log("[UILoading] Returning fallback component");return T}if(z)console.log("[UILoading] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata,hasFallback:!!I.fallback});if(I.fallback){if(z)console.log("[UILoading] Rendering fallback for:",I.name);let H=I.fallback;return P(H,{})}if(z)console.log("[UILoading] No fallback, rendering full component:",I.name);let $=I.component,Z=P(e.Provider,{value:LU,children:P($,{data:U.data,content:U.content,setUiAjaxConfiguration:L})});if(I.isLazy)return P(O,{name:I.name,fallback:T,onError:D,children:Z});return Z}var TU=LU;import{jsx as iU}from"react/jsx-runtime";function IU(U,L,T){if(!L)return T;let D=U.replace(/^\//,""),z=L[D];if(!z)return T;return iU(TU,{uiConfig:z})}import{jsx as N,Fragment as TL}from"react/jsx-runtime";var UL=({location:U,fallback:L,piecache:T,onError:D,queryOptions:z,disableGlobalForm:I})=>{let $=k(),Z=p(),H=Y(),$U=R(()=>eU({baseURL:$}),[$]),zU=R(()=>b(),[]),JU=R(()=>$?o($):null,[$]),DU=R(()=>$?l($,Z):null,[$,Z]),E=Q(),{data:_,isLoading:d,error:V}=tU({queryKey:["uiConfig",U.pathname+U.search,E?.initData],queryFn:async()=>{let q=new URLSearchParams(U.search);if(q.set("__pieroot","max"),E?.initData)q.set("initData",E.initData);let v="/api/content"+U.pathname+"?"+q.toString();if(H)console.log("[PieRoot] Fetching UI configuration from:",v);let x=await $U.get(v,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(H)console.log("[PieRoot] Received UI configuration:",x.data);return x.data},enabled:!!E?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(q)=>Math.min(1000*2**q,30000),...z}),S=IU(U.pathname,T,L);if(!$)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(V&&H)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?.(V),S;if(d||!_){if(H)console.log("[PieRoot] Loading state:",{isLoading:d,hasUiConfiguration:!!_});return S}if(H)console.log("[PieRoot] UI configuration loaded successfully:",_),console.log("[PieRoot] Rendering UI with configuration");return N(u.Provider,{value:zU,children:N(K.Provider,{value:JU,children:N(X.Provider,{value:DU,children:N(F.Provider,{value:L??N(TL,{}),children:N(s,{children:N(i,{children:I?N(C,{uiConfig:_}):N("form",{id:"piedata_global_form",action:$+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:N(C,{uiConfig:_})})})})})})})})},LL=(U)=>{let L=R(()=>new rU,[]),T=U.queryClient??L;return N(t.Provider,{value:U.onNavigate,children:N(y.Provider,{value:U.config,children:N(G.Provider,{value:U.onError,children:N(aU,{client:T,children:N(UL,{...U})})})})})},IL=LL;export{Q as useMaxWebApp,oU as useMaxInitData,hU as useMaxHapticFeedback,gU as useMaxBackButton,IL as PieMaxRoot};
|
package/dist/max/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var xU=Object.create;var{getPrototypeOf:vU,defineProperty:K,getOwnPropertyNames:t,getOwnPropertyDescriptor:mU}=Object,e=Object.prototype.hasOwnProperty;var dU=(U,L,$)=>{$=U!=null?xU(vU(U)):{};let I=L||!U||!U.__esModule?K($,"default",{value:U,enumerable:!0}):$;for(let D of t(U))if(!e.call(I,D))K(I,D,{get:()=>U[D],enumerable:!0});return I},r=new WeakMap,gU=(U)=>{var L=r.get(U),$;if(L)return L;if(L=K({},"__esModule",{value:!0}),U&&typeof U==="object"||typeof U==="function")t(U).map((I)=>!e.call(L,I)&&K(L,I,{get:()=>U[I],enumerable:!($=mU(U,I))||$.enumerable}));return r.set(U,L),L};var uU=(U,L)=>{for(var $ in L)K(U,$,{get:L[$],enumerable:!0,configurable:!0,set:(I)=>L[$]=()=>I})};var IL={};uU(IL,{useMaxWebApp:()=>V,useMaxInitData:()=>BU,useMaxHapticFeedback:()=>_U,useMaxBackButton:()=>KU,PieMaxRoot:()=>kU});module.exports=gU(IL);var G=require("react"),Y=require("@tanstack/react-query");var UU=dU(require("mitt")),j=require("react"),g=null;function LU(){if(!g)g=UU.default();return g}var lU=j.createContext(null);var $U=lU;var IU=require("socket.io-client"),DU=require("react"),zU=new Map,HU=(U)=>{let L=zU.get(U);if(L)return L;let $=IU.io(U,{autoConnect:!1,transports:["websocket"]});return zU.set(U,$),$},cU=DU.createContext(null),M=cU;var ZU=require("react"),u=require("centrifuge"),JU=new Map,NU=(U,L)=>{if(!L)return null;let $=`${U}::${L}`,I=JU.get($);if(I)return I;async function D(){let H=await fetch(U+"api/centrifuge/gen_token");if(!H.ok){if(H.status===403)throw new u.Centrifuge.UnauthorizedError("Backend is not answering");throw Error(`Unexpected status code ${H.status}`)}return(await H.json()).token}let z=new u.Centrifuge(L,{getToken:D});return JU.set($,z),z},hU=ZU.createContext(null),f=hU;var C=require("react");var S=require("react"),A=new Map,P=new Map;function k(U,L){let $=`${U}::${L}`,I=U?A.get($):void 0,[D,z]=S.useState(I??null);return S.useEffect(()=>{if(!U)return;if(A.has($)){z(A.get($));return}let H=P.get($);if(!H)H=fetch(U+`api/support/${L}`,{method:"GET"}).then((Z)=>Z.json()).then((Z)=>{return A.set($,Z),P.delete($),Z}).catch((Z)=>{throw P.delete($),Z}),P.set($,H);let N=!1;return H.then((Z)=>{if(!N)z(Z)}).catch(()=>{}),()=>{N=!0}},[U,L,$]),D}var y=require("react"),l=y.createContext(null),c=()=>{let U=y.useContext(l);if(!U)throw Error("usePieConfig must be used within PieConfigProvider");return U},h=()=>{let{apiServer:U}=c();return U},w=h,VU=()=>{let{centrifugeServer:U}=c();return U};var O=()=>{let{enableRenderingLog:U}=c();return U};var oU=null;function FU(){oU?.()}var pU=({children:U})=>{let L=C.useContext(M),$=w(),I=k($,"socketIO"),D=(z)=>{if(typeof window<"u")window.sid=z.sid,FU(),console.log(`SocketIO initialized: ${window.sid}`)};return C.useEffect(()=>{if(!L)return;let z=()=>{console.log("SocketIO connected")},H=(N)=>{console.log(`SocketIO disconnected: ${N}`),L.connect()};if(I)L.on("pieinit",D),L.on("connect",z),L.on("disconnect",H),L.connect();return()=>{if(I)L.off("pieinit",D),L.off("connect",z),L.off("disconnect",H),L.disconnect()}},[L,I]),U},OU=pU;var b=require("react");var nU=({children:U})=>{let L=b.useContext(f),$=w(),I=k($,"centrifuge");return b.useEffect(()=>{if(!L)return;let D=()=>{console.log("Centrifuge connected")},z=(H)=>{console.log("Centrifuge disconnected:",H)};if(I)L.on("connected",D),L.on("disconnected",z),L.connect();return()=>{if(I)L.disconnect()}},[L,I]),U},QU=nU;var TU=require("react"),x=require("react/jsx-runtime"),sU=TU.createContext(x.jsx(x.Fragment,{})),Q=sU;var qU=require("react"),iU=qU.createContext(void 0),T=iU;var GU=Symbol.for("@swarm.ing/pieui:component-registry"),YU=globalThis,aU=YU[GU]??(YU[GU]=new Map);var v=(U)=>{return aU.get(U)};var _=require("react");var m=require("react"),XU=require("react/jsx-runtime"),rU=2,tU=400;class q extends m.Component{state={failed:!1,attempt:0};timer;static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(U){if(this.props.onError?.(U),this.state.attempt<rU){let L=tU*(this.state.attempt+1);this.timer=setTimeout(()=>{this.setState(($)=>({failed:!1,attempt:$.attempt+1}))},L)}}componentDidUpdate(U){if(U.name!==this.props.name&&this.state.attempt!==0)this.setState({failed:!1,attempt:0})}componentWillUnmount(){if(this.timer)clearTimeout(this.timer)}render(){if(this.state.failed)return this.props.fallback;return XU.jsx(m.Suspense,{fallback:this.props.fallback,children:this.props.children},`${this.props.name}:${this.state.attempt}`)}}var d=require("react/jsx-runtime");function eU({uiConfig:U,setUiAjaxConfiguration:L}){let $=_.useContext(Q),I=_.useContext(T),D=O();if(D)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:",!!L);let z=v(U.card);if(!z?.component){if(D)console.warn(`[UI] Component not found in registry: ${U.card}`),console.log("[UI] Returning fallback component");return $}if(D)console.log("[UI] Found component in registry:",{name:z.name,isLazy:z.isLazy,hasMetadata:!!z.metadata});let H=z.component,N=d.jsx(H,{data:U.data,content:U.content,setUiAjaxConfiguration:L});if(z.isLazy){if(D)console.log("[UI] Rendering lazy component with Suspense:",z.name);return d.jsx(q,{name:z.name,fallback:z.fallback?d.jsx(z.fallback,{}):$,onError:I,children:N})}if(D)console.log("[UI] Rendering component directly:",z.name);return N}var o=_.memo(eU);var SU=require("axios-date-transformer");var W=require("react"),V=()=>{let[U,L]=W.useState(null);return W.useEffect(()=>{if(typeof window>"u")return;let $=window.WebApp;if(!$)return;$.ready(),L($)},[]),U},BU=()=>{let U=V();return[U?.initDataUnsafe,U?.initData]},KU=(U)=>{let L=V();return W.useEffect(()=>{if(!L||!U)return;return L.BackButton.onClick(U),L.BackButton.show(),()=>{L.BackButton.offClick(U),L.BackButton.hide()}},[L,U]),L?.BackButton??null},_U=()=>{return V()?.HapticFeedback??null};var WU=require("react"),UL=WU.createContext(void 0),EU=UL;var p=require("react");var RU=require("react"),LL=RU.createContext(null),jU=LL;var E=require("react/jsx-runtime");function MU({uiConfig:U,setUiAjaxConfiguration:L}){let $=p.useContext(Q),I=p.useContext(T),D=O();if(D)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:",!!L);let z=v(U.card);if(!z?.component){if(D)console.warn(`[UILoading] Component not found in registry: ${U.card}`),console.log("[UILoading] Returning fallback component");return $}if(D)console.log("[UILoading] Found component in registry:",{name:z.name,isLazy:z.isLazy,hasMetadata:!!z.metadata,hasFallback:!!z.fallback});if(z.fallback){if(D)console.log("[UILoading] Rendering fallback for:",z.name);let Z=z.fallback;return E.jsx(Z,{})}if(D)console.log("[UILoading] No fallback, rendering full component:",z.name);let H=z.component,N=E.jsx(jU.Provider,{value:MU,children:E.jsx(H,{data:U.data,content:U.content,setUiAjaxConfiguration:L})});if(z.isLazy)return E.jsx(q,{name:z.name,fallback:$,onError:I,children:N});return N}var fU=MU;var PU=require("react/jsx-runtime");function AU(U,L,$){if(!L)return $;let I=U.replace(/^\//,""),D=L[I];if(!D)return $;return PU.jsx(fU,{uiConfig:D})}var J=require("react/jsx-runtime"),$L=({location:U,fallback:L,piecache:$,onError:I,queryOptions:D,disableGlobalForm:z})=>{let H=h(),N=VU(),Z=O(),yU=G.useMemo(()=>SU.createAxiosDateTransformer({baseURL:H}),[H]),wU=G.useMemo(()=>LU(),[]),CU=G.useMemo(()=>H?HU(H):null,[H]),bU=G.useMemo(()=>H?NU(H,N):null,[H,N]),R=V(),{data:X,isLoading:n,error:F}=Y.useQuery({queryKey:["uiConfig",U.pathname+U.search,R?.initData],queryFn:async()=>{let B=new URLSearchParams(U.search);if(B.set("__pieroot","max"),R?.initData)B.set("initData",R.initData);let i="/api/content"+U.pathname+"?"+B.toString();if(Z)console.log("[PieRoot] Fetching UI configuration from:",i);let a=await yU.get(i,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(Z)console.log("[PieRoot] Received UI configuration:",a.data);return a.data},enabled:!!R?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(B)=>Math.min(1000*2**B,30000),...D}),s=AU(U.pathname,$,L);if(!H)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(F&&Z)return console.error("[PieRoot] Error fetching UI configuration:",F),console.error("[PieRoot] Error details:",{message:F.message,status:F.response?.status,data:F.response?.data}),I?.(F),s;if(n||!X){if(Z)console.log("[PieRoot] Loading state:",{isLoading:n,hasUiConfiguration:!!X});return s}if(Z)console.log("[PieRoot] UI configuration loaded successfully:",X),console.log("[PieRoot] Rendering UI with configuration");return J.jsx($U.Provider,{value:wU,children:J.jsx(M.Provider,{value:CU,children:J.jsx(f.Provider,{value:bU,children:J.jsx(Q.Provider,{value:L??J.jsx(J.Fragment,{}),children:J.jsx(OU,{children:J.jsx(QU,{children:z?J.jsx(o,{uiConfig:X}):J.jsx("form",{id:"piedata_global_form",action:H+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:J.jsx(o,{uiConfig:X})})})})})})})})},zL=(U)=>{let L=G.useMemo(()=>new Y.QueryClient,[]),$=U.queryClient??L;return J.jsx(EU.Provider,{value:U.onNavigate,children:J.jsx(l.Provider,{value:U.config,children:J.jsx(T.Provider,{value:U.onError,children:J.jsx(Y.QueryClientProvider,{client:$,children:J.jsx($L,{...U})})})})})},kU=zL;
|
|
2
|
+
var dU=Object.create;var{getPrototypeOf:SU,defineProperty:K,getOwnPropertyNames:e,getOwnPropertyDescriptor:vU}=Object,UU=Object.prototype.hasOwnProperty;var xU=(U,L,T)=>{T=U!=null?dU(SU(U)):{};let $=L||!U||!U.__esModule?K(T,"default",{value:U,enumerable:!0}):T;for(let z of e(U))if(!UU.call($,z))K($,z,{get:()=>U[z],enumerable:!0});return $},t=new WeakMap,bU=(U)=>{var L=t.get(U),T;if(L)return L;if(L=K({},"__esModule",{value:!0}),U&&typeof U==="object"||typeof U==="function")e(U).map(($)=>!UU.call(L,$)&&K(L,$,{get:()=>U[$],enumerable:!(T=vU(U,$))||T.enumerable}));return t.set(U,L),L};var uU=(U,L)=>{for(var T in L)K(U,T,{get:L[T],enumerable:!0,configurable:!0,set:($)=>L[T]=()=>$})};var IL={};uU(IL,{useMaxWebApp:()=>V,useMaxInitData:()=>qU,useMaxHapticFeedback:()=>EU,useMaxBackButton:()=>RU,PieMaxRoot:()=>yU});module.exports=bU(IL);var _=require("react"),q=require("@tanstack/react-query");var LU=xU(require("mitt")),j=require("react");var c=globalThis,D=(U,L)=>{let T=Symbol.for(U);if(!(T in c))c[T]=L();return c[T]};function TU(){return D("@swarm.ing/pieui:mitt-emitter",()=>LU.default())}var cU=D("@swarm.ing/pieui:context:mitt",()=>j.createContext(null));var IU=cU;var zU=require("socket.io-client"),JU=require("react");var $U=D("@swarm.ing/pieui:socket-cache",()=>new Map),DU=(U)=>{let L=$U.get(U);if(L)return L;let T=zU.io(U,{autoConnect:!1,transports:["websocket"]});return $U.set(U,T),T},oU=D("@swarm.ing/pieui:context:socket",()=>JU.createContext(null)),M=oU;var NU=require("react"),o=require("centrifuge");var HU=D("@swarm.ing/pieui:centrifuge-cache",()=>new Map),ZU=(U,L)=>{if(!L)return null;let T=`${U}::${L}`,$=HU.get(T);if($)return $;async function z(){let J=await fetch(U+"api/centrifuge/gen_token");if(!J.ok){if(J.status===403)throw new o.Centrifuge.UnauthorizedError("Backend is not answering");throw Error(`Unexpected status code ${J.status}`)}return(await J.json()).token}let I=new o.Centrifuge(L,{getToken:z});return HU.set(T,I),I},gU=D("@swarm.ing/pieui:context:centrifuge",()=>NU.createContext(null)),P=gU;var d=require("react");var w=require("react"),A=new Map,y=new Map;function k(U,L){let T=`${U}::${L}`,$=U?A.get(T):void 0,[z,I]=w.useState($??null);return w.useEffect(()=>{if(!U)return;if(A.has(T)){I(A.get(T));return}let J=y.get(T);if(!J)J=fetch(U+`api/support/${L}`,{method:"GET"}).then((N)=>N.json()).then((N)=>{return A.set(T,N),y.delete(T),N}).catch((N)=>{throw y.delete(T),N}),y.set(T,J);let Z=!1;return J.then((N)=>{if(!Z)I(N)}).catch(()=>{}),()=>{Z=!0}},[U,L,T]),z}var m=require("react");var g=D("@swarm.ing/pieui:context:pieConfig",()=>m.createContext(null)),h=()=>{let U=m.useContext(g);if(!U)throw Error("usePieConfig must be used within PieConfigProvider");return U},l=()=>{let{apiServer:U}=h();return U},C=l,VU=()=>{let{centrifugeServer:U}=h();return U};var F=()=>{let{enableRenderingLog:U}=h();return U};var hU=D("@swarm.ing/pieui:sid-state",()=>({promise:null,resolve:null}));function YU(){hU.resolve?.()}var lU=({children:U})=>{let L=d.useContext(M),T=C(),$=k(T,"socketIO"),z=(I)=>{if(typeof window<"u")window.sid=I.sid,YU(),console.log(`SocketIO initialized: ${window.sid}`)};return d.useEffect(()=>{if(!L)return;let I=()=>{console.log("SocketIO connected")},J=(Z)=>{console.log(`SocketIO disconnected: ${Z}`),L.connect()};if($)L.on("pieinit",z),L.on("connect",I),L.on("disconnect",J),L.connect();return()=>{if($)L.off("pieinit",z),L.off("connect",I),L.off("disconnect",J),L.disconnect()}},[L,$]),U},FU=lU;var S=require("react");var pU=({children:U})=>{let L=S.useContext(P),T=C(),$=k(T,"centrifuge");return S.useEffect(()=>{if(!L)return;let z=()=>{console.log("Centrifuge connected")},I=(J)=>{console.log("Centrifuge disconnected:",J)};if($)L.on("connected",z),L.on("disconnected",I),L.connect();return()=>{if($)L.disconnect()}},[L,$]),U},GU=pU;var OU=require("react");var v=require("react/jsx-runtime"),nU=D("@swarm.ing/pieui:context:fallback",()=>OU.createContext(v.jsx(v.Fragment,{}))),G=nU;var QU=require("react");var sU=D("@swarm.ing/pieui:context:lazyError",()=>QU.createContext(void 0)),O=sU;var iU=D("@swarm.ing/pieui:component-registry",()=>new Map);var x=(U)=>{return iU.get(U)};var X=require("react");var b=require("react"),_U=require("react/jsx-runtime"),rU=2,aU=400;class Q extends b.Component{state={failed:!1,attempt:0};timer;static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(U){if(this.props.onError?.(U),this.state.attempt<rU){let L=aU*(this.state.attempt+1);this.timer=setTimeout(()=>{this.setState((T)=>({failed:!1,attempt:T.attempt+1}))},L)}}componentDidUpdate(U){if(U.name!==this.props.name&&this.state.attempt!==0)this.setState({failed:!1,attempt:0})}componentWillUnmount(){if(this.timer)clearTimeout(this.timer)}render(){if(this.state.failed)return this.props.fallback;return _U.jsx(b.Suspense,{fallback:this.props.fallback,children:this.props.children},`${this.props.name}:${this.state.attempt}`)}}var u=require("react/jsx-runtime");function tU({uiConfig:U,setUiAjaxConfiguration:L}){let T=X.useContext(G),$=X.useContext(O),z=F();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:",!!L);let I=x(U.card);if(!I?.component){if(z)console.warn(`[UI] Component not found in registry: ${U.card}`),console.log("[UI] Returning fallback component");return T}if(z)console.log("[UI] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata});let J=I.component,Z=u.jsx(J,{data:U.data,content:U.content,setUiAjaxConfiguration:L});if(I.isLazy){if(z)console.log("[UI] Rendering lazy component with Suspense:",I.name);return u.jsx(Q,{name:I.name,fallback:I.fallback?u.jsx(I.fallback,{}):T,onError:$,children:Z})}if(z)console.log("[UI] Rendering component directly:",I.name);return Z}var p=X.memo(tU);var AU=require("axios-date-transformer");var B=require("react"),V=()=>{let[U,L]=B.useState(null);return B.useEffect(()=>{if(typeof window>"u")return;let T=window.WebApp;if(!T)return;T.ready(),L(T)},[]),U},qU=()=>{let U=V();return[U?.initDataUnsafe,U?.initData]},RU=(U)=>{let L=V();return B.useEffect(()=>{if(!L||!U)return;return L.BackButton.onClick(U),L.BackButton.show(),()=>{L.BackButton.offClick(U),L.BackButton.hide()}},[L,U]),L?.BackButton??null},EU=()=>{return V()?.HapticFeedback??null};var KU=require("react");var eU=D("@swarm.ing/pieui:context:navigate",()=>KU.createContext(void 0)),XU=eU;var n=require("react");var BU=require("react");var UL=D("@swarm.ing/pieui:context:uiRenderer",()=>BU.createContext(null)),WU=UL;var W=require("react/jsx-runtime");function fU({uiConfig:U,setUiAjaxConfiguration:L}){let T=n.useContext(G),$=n.useContext(O),z=F();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:",!!L);let I=x(U.card);if(!I?.component){if(z)console.warn(`[UILoading] Component not found in registry: ${U.card}`),console.log("[UILoading] Returning fallback component");return T}if(z)console.log("[UILoading] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata,hasFallback:!!I.fallback});if(I.fallback){if(z)console.log("[UILoading] Rendering fallback for:",I.name);let N=I.fallback;return W.jsx(N,{})}if(z)console.log("[UILoading] No fallback, rendering full component:",I.name);let J=I.component,Z=W.jsx(WU.Provider,{value:fU,children:W.jsx(J,{data:U.data,content:U.content,setUiAjaxConfiguration:L})});if(I.isLazy)return W.jsx(Q,{name:I.name,fallback:T,onError:$,children:Z});return Z}var jU=fU;var PU=require("react/jsx-runtime");function MU(U,L,T){if(!L)return T;let $=U.replace(/^\//,""),z=L[$];if(!z)return T;return PU.jsx(jU,{uiConfig:z})}var H=require("react/jsx-runtime"),LL=({location:U,fallback:L,piecache:T,onError:$,queryOptions:z,disableGlobalForm:I})=>{let J=l(),Z=VU(),N=F(),wU=_.useMemo(()=>AU.createAxiosDateTransformer({baseURL:J}),[J]),kU=_.useMemo(()=>TU(),[]),mU=_.useMemo(()=>J?DU(J):null,[J]),CU=_.useMemo(()=>J?ZU(J,Z):null,[J,Z]),f=V(),{data:R,isLoading:s,error:Y}=q.useQuery({queryKey:["uiConfig",U.pathname+U.search,f?.initData],queryFn:async()=>{let E=new URLSearchParams(U.search);if(E.set("__pieroot","max"),f?.initData)E.set("initData",f.initData);let r="/api/content"+U.pathname+"?"+E.toString();if(N)console.log("[PieRoot] Fetching UI configuration from:",r);let a=await wU.get(r,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(N)console.log("[PieRoot] Received UI configuration:",a.data);return a.data},enabled:!!f?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(E)=>Math.min(1000*2**E,30000),...z}),i=MU(U.pathname,T,L);if(!J)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(Y&&N)return console.error("[PieRoot] Error fetching UI configuration:",Y),console.error("[PieRoot] Error details:",{message:Y.message,status:Y.response?.status,data:Y.response?.data}),$?.(Y),i;if(s||!R){if(N)console.log("[PieRoot] Loading state:",{isLoading:s,hasUiConfiguration:!!R});return i}if(N)console.log("[PieRoot] UI configuration loaded successfully:",R),console.log("[PieRoot] Rendering UI with configuration");return H.jsx(IU.Provider,{value:kU,children:H.jsx(M.Provider,{value:mU,children:H.jsx(P.Provider,{value:CU,children:H.jsx(G.Provider,{value:L??H.jsx(H.Fragment,{}),children:H.jsx(FU,{children:H.jsx(GU,{children:I?H.jsx(p,{uiConfig:R}):H.jsx("form",{id:"piedata_global_form",action:J+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:H.jsx(p,{uiConfig:R})})})})})})})})},TL=(U)=>{let L=_.useMemo(()=>new q.QueryClient,[]),T=U.queryClient??L;return H.jsx(XU.Provider,{value:U.onNavigate,children:H.jsx(g.Provider,{value:U.config,children:H.jsx(O.Provider,{value:U.onError,children:H.jsx(q.QueryClientProvider,{client:T,children:H.jsx(LL,{...U})})})})})},yU=TL;
|
|
@@ -222,19 +222,26 @@
|
|
|
222
222
|
}
|
|
223
223
|
},
|
|
224
224
|
{
|
|
225
|
-
"card": "
|
|
225
|
+
"card": "AjaxGroupCard",
|
|
226
226
|
"data": {
|
|
227
227
|
"type": "object",
|
|
228
228
|
"properties": {
|
|
229
229
|
"name": {
|
|
230
230
|
"type": "string"
|
|
231
231
|
},
|
|
232
|
-
"
|
|
233
|
-
"type": "
|
|
232
|
+
"noReturn": {
|
|
233
|
+
"type": "boolean"
|
|
234
234
|
},
|
|
235
|
-
"
|
|
235
|
+
"returnType": {
|
|
236
|
+
"enum": [
|
|
237
|
+
"content",
|
|
238
|
+
"events"
|
|
239
|
+
],
|
|
236
240
|
"type": "string"
|
|
237
241
|
},
|
|
242
|
+
"useLoader": {
|
|
243
|
+
"type": "boolean"
|
|
244
|
+
},
|
|
238
245
|
"useSocketioSupport": {
|
|
239
246
|
"type": "boolean"
|
|
240
247
|
},
|
|
@@ -250,69 +257,73 @@
|
|
|
250
257
|
},
|
|
251
258
|
"additionalProperties": false,
|
|
252
259
|
"required": [
|
|
253
|
-
"key",
|
|
254
260
|
"name",
|
|
255
|
-
"
|
|
261
|
+
"noReturn",
|
|
262
|
+
"returnType",
|
|
263
|
+
"useLoader"
|
|
256
264
|
],
|
|
257
265
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
258
266
|
}
|
|
259
267
|
},
|
|
260
268
|
{
|
|
261
|
-
"card": "
|
|
269
|
+
"card": "BoxCard",
|
|
262
270
|
"data": {
|
|
263
271
|
"type": "object",
|
|
264
272
|
"properties": {
|
|
265
273
|
"name": {
|
|
266
274
|
"type": "string"
|
|
267
275
|
},
|
|
268
|
-
"
|
|
276
|
+
"url": {
|
|
269
277
|
"type": "string"
|
|
270
278
|
},
|
|
271
|
-
"
|
|
279
|
+
"sx": {
|
|
280
|
+
"type": "object",
|
|
281
|
+
"additionalProperties": {}
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
"additionalProperties": false,
|
|
285
|
+
"required": [
|
|
286
|
+
"name",
|
|
287
|
+
"sx",
|
|
288
|
+
"url"
|
|
289
|
+
],
|
|
290
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"card": "OneOfCard",
|
|
295
|
+
"data": {
|
|
296
|
+
"type": "object",
|
|
297
|
+
"properties": {
|
|
298
|
+
"name": {
|
|
272
299
|
"type": "string"
|
|
273
300
|
},
|
|
274
|
-
"
|
|
275
|
-
"type": "
|
|
276
|
-
|
|
277
|
-
"useCentrifugeSupport": {
|
|
278
|
-
"type": "boolean"
|
|
279
|
-
},
|
|
280
|
-
"useMittSupport": {
|
|
281
|
-
"type": "boolean"
|
|
282
|
-
},
|
|
283
|
-
"centrifugeChannel": {
|
|
284
|
-
"type": "string"
|
|
301
|
+
"sx": {
|
|
302
|
+
"type": "object",
|
|
303
|
+
"additionalProperties": {}
|
|
285
304
|
}
|
|
286
305
|
},
|
|
287
306
|
"additionalProperties": false,
|
|
288
307
|
"required": [
|
|
289
|
-
"key",
|
|
290
308
|
"name",
|
|
291
|
-
"
|
|
309
|
+
"sx"
|
|
292
310
|
],
|
|
293
311
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
294
312
|
}
|
|
295
313
|
},
|
|
296
314
|
{
|
|
297
|
-
"card": "
|
|
315
|
+
"card": "CloudStorageCard",
|
|
298
316
|
"data": {
|
|
299
317
|
"type": "object",
|
|
300
318
|
"properties": {
|
|
301
319
|
"name": {
|
|
302
320
|
"type": "string"
|
|
303
321
|
},
|
|
304
|
-
"
|
|
305
|
-
"type": "boolean"
|
|
306
|
-
},
|
|
307
|
-
"returnType": {
|
|
308
|
-
"enum": [
|
|
309
|
-
"content",
|
|
310
|
-
"events"
|
|
311
|
-
],
|
|
322
|
+
"key": {
|
|
312
323
|
"type": "string"
|
|
313
324
|
},
|
|
314
|
-
"
|
|
315
|
-
"type": "
|
|
325
|
+
"value": {
|
|
326
|
+
"type": "string"
|
|
316
327
|
},
|
|
317
328
|
"useSocketioSupport": {
|
|
318
329
|
"type": "boolean"
|
|
@@ -329,56 +340,45 @@
|
|
|
329
340
|
},
|
|
330
341
|
"additionalProperties": false,
|
|
331
342
|
"required": [
|
|
343
|
+
"key",
|
|
332
344
|
"name",
|
|
333
|
-
"
|
|
334
|
-
"returnType",
|
|
335
|
-
"useLoader"
|
|
345
|
+
"value"
|
|
336
346
|
],
|
|
337
347
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
338
348
|
}
|
|
339
349
|
},
|
|
340
350
|
{
|
|
341
|
-
"card": "
|
|
351
|
+
"card": "SecureStorageCard",
|
|
342
352
|
"data": {
|
|
343
353
|
"type": "object",
|
|
344
354
|
"properties": {
|
|
345
355
|
"name": {
|
|
346
356
|
"type": "string"
|
|
347
357
|
},
|
|
348
|
-
"
|
|
358
|
+
"key": {
|
|
349
359
|
"type": "string"
|
|
350
360
|
},
|
|
351
|
-
"
|
|
352
|
-
"type": "object",
|
|
353
|
-
"additionalProperties": {}
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
"additionalProperties": false,
|
|
357
|
-
"required": [
|
|
358
|
-
"name",
|
|
359
|
-
"sx",
|
|
360
|
-
"url"
|
|
361
|
-
],
|
|
362
|
-
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
"card": "OneOfCard",
|
|
367
|
-
"data": {
|
|
368
|
-
"type": "object",
|
|
369
|
-
"properties": {
|
|
370
|
-
"name": {
|
|
361
|
+
"value": {
|
|
371
362
|
"type": "string"
|
|
372
363
|
},
|
|
373
|
-
"
|
|
374
|
-
"type": "
|
|
375
|
-
|
|
364
|
+
"useSocketioSupport": {
|
|
365
|
+
"type": "boolean"
|
|
366
|
+
},
|
|
367
|
+
"useCentrifugeSupport": {
|
|
368
|
+
"type": "boolean"
|
|
369
|
+
},
|
|
370
|
+
"useMittSupport": {
|
|
371
|
+
"type": "boolean"
|
|
372
|
+
},
|
|
373
|
+
"centrifugeChannel": {
|
|
374
|
+
"type": "string"
|
|
376
375
|
}
|
|
377
376
|
},
|
|
378
377
|
"additionalProperties": false,
|
|
379
378
|
"required": [
|
|
379
|
+
"key",
|
|
380
380
|
"name",
|
|
381
|
-
"
|
|
381
|
+
"value"
|
|
382
382
|
],
|
|
383
383
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
384
384
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"react";import{addons as U,types as I}from"storybook/manager-api";import"react";import{useEffect as Z,useMemo as $,useState as z}from"react";import{addons as K,useParameter as Y}from"storybook/manager-api";var q="piecard",J="piecard/fire";import{jsx as w,jsxs as R}from"react/jsx-runtime";var f=({children:i,style:n})=>w("pre",{style:{margin:0,padding:8,fontSize:11,background:"#f5f5f5",border:"1px solid #e0e0e0",borderRadius:4,overflow:"auto",...n??{}},children:i}),k=(i)=>{if(i.samplePayload!==void 0)try{return JSON.stringify(i.samplePayload,null,2)}catch{}let n=i.payloadSchema;if(!n||typeof n!=="object")return"{}";let g=n.properties??{};if(!Object.keys(g).length)return"{}";let C={};for(let[T,O]of Object.entries(g)){if(typeof O!=="object"||O===null)continue;let b=O.type;if(b==="string")C[T]="";else if(b==="number"||b==="integer")C[T]=0;else if(b==="boolean")C[T]=!1;else if(b==="array")C[T]=[];else if(b==="object")C[T]={};else C[T]=null}return JSON.stringify(C,null,2)},u=({card:i,method:n})=>{let g=$(()=>k(n),[n]),[C,T]=z(g),[O,b]=z(null),[B,W]=z(null),X=()=>{let S=void 0,G=C.trim();if(G.length>0)try{S=JSON.parse(G)}catch(H){b(H instanceof Error?H.message:"Invalid JSON payload");return}b(null),K.getChannel().emit(J,{card:i,method:n.name,payload:S}),W(Date.now())};return R("div",{style:{padding:12,borderBottom:"1px solid #eee",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},children:[R("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:6},children:[R("code",{style:{fontSize:13,fontWeight:600},children:[i,".",n.name]}),w("button",{type:"button",onClick:X,style:{marginLeft:"auto",padding:"4px 10px",fontSize:12,background:"#1ea7fd",color:"white",border:"none",borderRadius:4,cursor:"pointer"},children:"Fire"})]}),n.payloadCode?R("details",{style:{marginBottom:6},children:[w("summary",{style:{fontSize:11,cursor:"pointer"},children:"Payload type"}),w(f,{children:n.payloadCode})]}):null,w("textarea",{value:C,onChange:(S)=>T(S.target.value),rows:Math.min(10,Math.max(2,C.split(`
|
|
2
|
+
`).length)),style:{width:"100%",fontFamily:"monospace",fontSize:12,padding:6,border:"1px solid #ddd",borderRadius:4,boxSizing:"border-box"}}),O?w("div",{style:{marginTop:4,color:"#c00",fontSize:11},children:O}):null,B?R("div",{style:{marginTop:4,color:"#666",fontSize:11},children:["Fired at ",new Date(B).toLocaleTimeString()]}):null]})},Q=({active:i})=>{let n=Y(q,null);if(Z(()=>{},[n]),!i)return null;if(!n||!n.card)return R("div",{style:{padding:16,fontSize:13,color:"#666"},children:[w("strong",{children:"No PieCard parameters on this story."}),R("p",{style:{marginTop:8},children:["Add"," ",R("code",{children:["parameters.",q," = ","{"," card, methods"," ","}"]})," ","to your story to surface method triggers here."]})]});let g=n.methods??[];if(g.length===0)return R("div",{style:{padding:16,fontSize:13,color:"#666"},children:["No methods declared for ",w("code",{children:n.card}),"."]});return w("div",{children:g.map((C)=>w(u,{card:n.card,method:C},C.name))})};var V="piecard",L=`${V}/panel`;U.register(V,()=>{U.add(L,{type:I.PANEL,title:"PieCard Methods",match:({viewMode:i})=>i==="story",render:({active:i})=>Q({active:i})})});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=require("react"),S=require("storybook/manager-api");var k=require("react"),T=require("react"),z=require("storybook/manager-api");var B="piecard",Q="piecard/fire";var n=require("react/jsx-runtime"),Z=({children:C,style:i})=>n.jsx("pre",{style:{margin:0,padding:8,fontSize:11,background:"#f5f5f5",border:"1px solid #e0e0e0",borderRadius:4,overflow:"auto",...i??{}},children:C}),$=(C)=>{if(C.samplePayload!==void 0)try{return JSON.stringify(C.samplePayload,null,2)}catch{}let i=C.payloadSchema;if(!i||typeof i!=="object")return"{}";let g=i.properties??{};if(!Object.keys(g).length)return"{}";let w={};for(let[R,O]of Object.entries(g)){if(typeof O!=="object"||O===null)continue;let b=O.type;if(b==="string")w[R]="";else if(b==="number"||b==="integer")w[R]=0;else if(b==="boolean")w[R]=!1;else if(b==="array")w[R]=[];else if(b==="object")w[R]={};else w[R]=null}return JSON.stringify(w,null,2)},K=({card:C,method:i})=>{let g=T.useMemo(()=>$(i),[i]),[w,R]=T.useState(g),[O,b]=T.useState(null),[G,W]=T.useState(null),X=()=>{let q=void 0,H=w.trim();if(H.length>0)try{q=JSON.parse(H)}catch(J){b(J instanceof Error?J.message:"Invalid JSON payload");return}b(null),z.addons.getChannel().emit(Q,{card:C,method:i.name,payload:q}),W(Date.now())};return n.jsxs("div",{style:{padding:12,borderBottom:"1px solid #eee",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:6},children:[n.jsxs("code",{style:{fontSize:13,fontWeight:600},children:[C,".",i.name]}),n.jsx("button",{type:"button",onClick:X,style:{marginLeft:"auto",padding:"4px 10px",fontSize:12,background:"#1ea7fd",color:"white",border:"none",borderRadius:4,cursor:"pointer"},children:"Fire"})]}),i.payloadCode?n.jsxs("details",{style:{marginBottom:6},children:[n.jsx("summary",{style:{fontSize:11,cursor:"pointer"},children:"Payload type"}),n.jsx(Z,{children:i.payloadCode})]}):null,n.jsx("textarea",{value:w,onChange:(q)=>R(q.target.value),rows:Math.min(10,Math.max(2,w.split(`
|
|
2
|
+
`).length)),style:{width:"100%",fontFamily:"monospace",fontSize:12,padding:6,border:"1px solid #ddd",borderRadius:4,boxSizing:"border-box"}}),O?n.jsx("div",{style:{marginTop:4,color:"#c00",fontSize:11},children:O}):null,G?n.jsxs("div",{style:{marginTop:4,color:"#666",fontSize:11},children:["Fired at ",new Date(G).toLocaleTimeString()]}):null]})},U=({active:C})=>{let i=z.useParameter(B,null);if(T.useEffect(()=>{},[i]),!C)return null;if(!i||!i.card)return n.jsxs("div",{style:{padding:16,fontSize:13,color:"#666"},children:[n.jsx("strong",{children:"No PieCard parameters on this story."}),n.jsxs("p",{style:{marginTop:8},children:["Add"," ",n.jsxs("code",{children:["parameters.",B," = ","{"," card, methods"," ","}"]})," ","to your story to surface method triggers here."]})]});let g=i.methods??[];if(g.length===0)return n.jsxs("div",{style:{padding:16,fontSize:13,color:"#666"},children:["No methods declared for ",n.jsx("code",{children:i.card}),"."]});return n.jsx("div",{children:g.map((w)=>n.jsx(K,{card:i.card,method:w},w.name))})};var V="piecard",Y=`${V}/panel`;S.addons.register(V,()=>{S.addons.add(Y,{type:S.types.PANEL,title:"PieCard Methods",match:({viewMode:C})=>C==="story",render:({active:C})=>U({active:C})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/telegram/components/CloudStorageCard/index.ts"],"names":[],"mappings":";AAGA,wBAIE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/telegram/components/CloudStorageCard/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IAEb,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB,CAAC,oBAAoB,CAAC;CAAG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CloudStorageCardProps } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Persists `data.value` to Telegram `WebApp.CloudStorage` under `data.key` and
|
|
4
|
+
* mirrors it into a hidden input named `data.name`.
|
|
5
|
+
*
|
|
6
|
+
* Sending the value with an Ajax submit — two options:
|
|
7
|
+
* - **Direct:** add `'telegram:cloud:<key>'` to the Ajax card's `depsNames`.
|
|
8
|
+
* `readAjaxKeyAsync` reads it straight from CloudStorage (async) and submits
|
|
9
|
+
* it under the bare `<key>`.
|
|
10
|
+
* - **Via the hidden input:** add this card's `data.name` to `depsNames`; the
|
|
11
|
+
* value is read synchronously from the rendered hidden input by name.
|
|
12
|
+
*/
|
|
13
|
+
declare const CloudStorageCard: ({ data }: CloudStorageCardProps) => import("react").JSX.Element;
|
|
14
|
+
export default CloudStorageCard;
|
|
15
|
+
//# sourceMappingURL=CloudStorageCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloudStorageCard.d.ts","sourceRoot":"","sources":["../../../../../src/telegram/components/CloudStorageCard/ui/CloudStorageCard.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAGhD;;;;;;;;;;GAUG;AACH,QAAA,MAAM,gBAAgB,GAAI,UAAU,qBAAqB,gCA6CxD,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/telegram/components/SecureStorageCard/index.ts"],"names":[],"mappings":";AAGA,wBAIE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/telegram/components/SecureStorageCard/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IAEb,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,sBAAuB,SAAQ,uBAAuB,CAAC,qBAAqB,CAAC;CAAG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SecureStorageCardProps } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Persists `data.value` to Telegram `WebApp.SecureStorage` under `data.key` and
|
|
4
|
+
* mirrors it into a hidden input named `data.name`.
|
|
5
|
+
*
|
|
6
|
+
* Sending the value with an Ajax submit — two options:
|
|
7
|
+
* - **Direct:** add `'telegram:secure:<key>'` to the Ajax card's `depsNames`.
|
|
8
|
+
* `readAjaxKeyAsync` reads it straight from SecureStorage (async) and submits
|
|
9
|
+
* it under the bare `<key>`.
|
|
10
|
+
* - **Via the hidden input:** add this card's `data.name` to `depsNames`; the
|
|
11
|
+
* value is read synchronously from the rendered hidden input by name.
|
|
12
|
+
*/
|
|
13
|
+
declare const SecureStorageCard: ({ data }: SecureStorageCardProps) => import("react").JSX.Element;
|
|
14
|
+
export default SecureStorageCard;
|
|
15
|
+
//# sourceMappingURL=SecureStorageCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SecureStorageCard.d.ts","sourceRoot":"","sources":["../../../../../src/telegram/components/SecureStorageCard/ui/SecureStorageCard.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAGjD;;;;;;;;;;GAUG;AACH,QAAA,MAAM,iBAAiB,GAAI,UAAU,sBAAsB,gCA6C1D,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
package/dist/telegram/index.d.ts
CHANGED
|
@@ -8,5 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { default as PieTelegramRoot } from '../components/PieTelegramRoot';
|
|
10
10
|
export { useWebApp, useInitData } from '../util/useWebApp';
|
|
11
|
+
export { default as CloudStorageCard } from './components/CloudStorageCard';
|
|
12
|
+
export { default as SecureStorageCard } from './components/SecureStorageCard';
|
|
13
|
+
export type { CloudStorageCardData } from './components/CloudStorageCard/types';
|
|
14
|
+
export type { SecureStorageCardData } from './components/SecureStorageCard/types';
|
|
11
15
|
export type { WebApp, Telegram, InitData, InitDataUnsafe, WebAppUser, WebAppInitData, } from '../types';
|
|
12
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telegram/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telegram/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAI1D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAE7E,YAAY,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC/E,YAAY,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAEjF,YAAY,EACR,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,UAAU,EACV,cAAc,GACjB,MAAM,UAAU,CAAA"}
|