@plitzi/plitzi-sdk 0.37.7 → 0.37.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @plitzi/plitzi-sdk
2
2
 
3
+ ## 0.37.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 4d10e0a: ## Fixed: an api container could not read a file from a CDN
8
+
9
+ - **What happened:** the api container sent `Content-Type: application/json` on every request, including a GET with no
10
+ body to describe. That made every read a non-simple cross-origin request, so the browser asked the host's
11
+ permission first.
12
+ - **Who it hit:** hosts that allow plain cross-origin reads (GET and HEAD from any origin, the usual CORS of a public
13
+ bucket, the space's own CDN among them) refused that preflight. The file never loaded. Tremor's world outlines on
14
+ `cdn-dev.plitzi.com` are one example.
15
+ - **What changes:** a read now sends `Accept: application/json`, and `Content-Type` goes only with a body, unless the
16
+ author set their own. Headers the author adds still make the request non-simple, as they must.
17
+
18
+ - Updated dependencies [4d10e0a]
19
+ - @plitzi/sdk-auth@0.37.8
20
+ - @plitzi/sdk-dev-tools@0.37.8
21
+ - @plitzi/sdk-elements@0.37.8
22
+ - @plitzi/sdk-event-bridge@0.37.8
23
+ - @plitzi/sdk-interactions@0.37.8
24
+ - @plitzi/sdk-navigation@0.37.8
25
+ - @plitzi/sdk-plugins@0.37.8
26
+ - @plitzi/sdk-schema@0.37.8
27
+ - @plitzi/sdk-shared@0.37.8
28
+ - @plitzi/sdk-style@0.37.8
29
+ - @plitzi/sdk-variables@0.37.8
30
+
3
31
  ## 0.37.7
4
32
 
5
33
  ### Patch Changes
@@ -55,7 +55,7 @@ return e.createElement(e.Fragment,null,f.map(t=>/* @__PURE__ */e.createElement("
55
55
  return e.createElement(Kk,{...c,"aria-current":C,className:k,ref:u,style:A,to:o,viewTransition:s},"function"==typeof l?l(T):l)});Jk.displayName="NavLink";var Xk=e.forwardRef(({discover:t="render",fetcherKey:n,navigate:r,reloadDocument:a,replace:i,state:o,method:s=Ek,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:p,defaultShouldRevalidate:f,...h},m)=>{let{useTransitions:g}=e.useContext(rk),y=function(){let{router:t}=Zk("useSubmit"),{basename:n}=e.useContext(rk),r=kk("useRouteId"),a=t.fetch,i=t.navigate;return e.useCallback(async(e,t={})=>{let{action:o,method:s,encType:l,formData:c,body:u}=function(e,t){let n,r,a,i,o;if(_k(s=e)&&"form"===s.tagName.toLowerCase()){let o=e.getAttribute("action");r=o?_w(o,t):null,n=e.getAttribute("method")||Ek,a=Mk(e.getAttribute("enctype"))||Ik,i=new FormData(e)}else if(function(e){return _k(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return _k(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let o=e.form;if(null==o)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let s=e.getAttribute("formaction")||o.getAttribute("action");if(r=s?_w(s,t):null,n=e.getAttribute("formmethod")||o.getAttribute("method")||Ek,a=Mk(e.getAttribute("formenctype"))||Mk(o.getAttribute("enctype"))||Ik,i=new FormData(o,e),!function(){if(null===Nk)try{new FormData(document.createElement("form"),0),Nk=!1}catch(tI){Nk=!0}return Nk}()){let{name:t,type:n,value:r}=e;if("image"===n){let e=t?`${t}.`:"";i.append(`${e}x`,"0"),i.append(`${e}y`,"0")}else t&&i.append(t,r)}}else{if(_k(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Ek,r=null,a=Ik,o=e}var s;return i&&"text/plain"===a&&(o=i,i=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:i,body:o}}(e,n);if(!1===t.navigate){let e=t.fetcherKey||ex();await a(e,r,t.action||o,{defaultShouldRevalidate:t.defaultShouldRevalidate,preventScrollReset:t.preventScrollReset,formData:c,body:u,formMethod:t.method||s,formEncType:t.encType||l,flushSync:t.flushSync})}else await i(t.action||o,{defaultShouldRevalidate:t.defaultShouldRevalidate,preventScrollReset:t.preventScrollReset,formData:c,body:u,formMethod:t.method||s,formEncType:t.encType||l,replace:t.replace,state:t.state,fromRouteId:r,flushSync:t.flushSync,viewTransition:t.viewTransition})},[a,i,n,r])}(),b=function(t,{relative:n}={}){let{basename:r}=e.useContext(rk),a=e.useContext(ik);sw(a,"useFormAction must be used inside a RouteContext");let[i]=a.matches.slice(-1),o={...fk(t||".",{relative:n})},s=ck();if(null==t){o.search=s.search;let e=new URLSearchParams(o.search),t=e.getAll("index");if(t.some(e=>""===e)){e.delete("index"),t.filter(e=>e).forEach(t=>e.append("index",t));let n=e.toString();o.search=n?`?${n}`:""}}return t&&"."!==t||!i.route.index||(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),"/"!==r&&(o.pathname="/"===o.pathname?r:Dw([r,o.pathname])),dw(o)}(l,{relative:u}),v="get"===s.toLowerCase()?"get":"post",w="string"==typeof l&&rw.test(l);/* @__PURE__ */
56
56
  return e.createElement("form",{ref:m,method:v,action:b,onSubmit:a?c:t=>{if(c&&c(t),t.defaultPrevented)return;t.preventDefault();let a=t.nativeEvent.submitter,l=a?.getAttribute("formmethod")||s,h=()=>y(a||t.currentTarget,{fetcherKey:n,method:l,navigate:r,replace:i,state:o,relative:u,preventScrollReset:d,viewTransition:p,defaultShouldRevalidate:f});g&&!1!==r?e.startTransition(()=>h()):h()},...h,"data-discover":w||"render"!==t?void 0:"true"})});function Zk(t){let n=e.useContext(Zw);return sw(n,function(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}(t)),n}Xk.displayName="Form";var Qk=0,ex=()=>`__${String(++Qk)}__`;function tx({basename:t,children:n,location:r="/"}){"string"==typeof r&&(r=pw(r));let a={pathname:r.pathname||"/",search:r.search||"",hash:r.hash||"",state:null!=r.state?r.state:null,key:r.key||"default",mask:void 0},i={createHref:nx,encodeLocation:rx,push(e){throw new Error(`You cannot use navigator.push() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(e)})\` somewhere in your app.`)},replace(e){throw new Error(`You cannot use navigator.replace() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(e)}, { replace: true })\` somewhere in your app.`)},go(e){throw new Error(`You cannot use navigator.go() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${e})\` somewhere in your app.`)},back(){throw new Error("You cannot use navigator.back() on the server because it is a stateless environment.")},forward(){throw new Error("You cannot use navigator.forward() on the server because it is a stateless environment.")}};/* @__PURE__ */
57
57
  return e.createElement(Ak,{basename:t,children:n,location:a,navigationType:"POP",navigator:i,static:!0,useTransitions:!1})}function nx(e){return"string"==typeof e?e:dw(e)}function rx(e){let t="string"==typeof e?e:dw(e);t=t.replace(/ $/,"%20");let n=rw.test(t)?new URL(t):new URL(t,"http://localhost");return{pathname:n.pathname,search:n.search,hash:n.hash}}var ax,ix=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],ox=()=>{const e=new URLSearchParams(window.location.search),t={};for(const n of ix){const r=e.get(n);r&&(t[n.slice(4)]=r)}return Object.keys(t).length>0?t:void 0},sx=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,lx=e=>{ax=e},cx=(e,t)=>{ax?.track(e,t)},ux=({analytics:e})=>{const t=ck(),n=x(!0===e?.firstViewCounted);return g(()=>{if(!e?.endpoint||!e.key)return;const t=((e,t=20,n=5e3)=>{const r=[],a=`${e.endpoint.replace(/\/+$/,"")}/batch?k=${encodeURIComponent(e.key)}`;let i;const o=()=>{0!==r.length&&(e=>{const t=JSON.stringify({events:e});"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(a,t)||fetch(a,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},body:t,keepalive:!0,mode:"no-cors"}).catch(()=>{})})(r.splice(0,r.length))},s=e=>{r.push(e),r.length>=t&&o()},l=()=>({path:window.location.pathname,title:document.title||void 0});return"undefined"!=typeof window&&(i=setInterval(o,n),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&o()}),window.addEventListener("pagehide",o)),{trackRender:()=>{s({id:sx(),type:"render",ts:Date.now(),page:l(),ref:{referrer:document.referrer||void 0,utm:ox()}})},track:(e,t)=>{s({id:sx(),type:"interaction",ts:Date.now(),page:l(),name:e,props:t})},flush:o,stop:()=>{i&&(clearInterval(i),i=void 0),o()}}})(e);return lx(t),()=>{lx(void 0),t.stop()}},[e]),g(()=>{n.current?n.current=!1:ax?.trackRender()},[t.pathname,t.search]),null},dx=l({});dx.displayName="AuthContext";var px=({server:e,routerLocation:t})=>{let n=k(()=>typeof window<"u"?window.location:Jn(e,"location",{pathname:"/"}),[e]),r=k(()=>{if(!t)return n;let{origin:e,host:r,hostname:a,protocol:i,href:o}=n,{pathname:s,search:l}=t;return{origin:e,host:r,hostname:a,protocol:i,pathname:s,search:l,hash:"",href:e?`${e}${s}${l}`:o}},[n,t]),a=k(()=>function(e){!e&&typeof window<"u"&&(e=window.location.search);let t={};if(!e||0===e.length)return t;let n=e.replace("?","").split("&");for(let r=0;r<n.length;r++){let e=n[r].split("="),a=decodeURIComponent(e[0]),i=decodeURIComponent(e[1]);void 0===t[a]?t[a]=decodeURIComponent(i):"string"==typeof t[a]?t[a]=[t[a],decodeURIComponent(i)]:t[a].push(decodeURIComponent(i))}return t}(r.search),[r.search]),i=k(()=>r.hostname?r.hostname:"localhost",[r.hostname]),o=r.origin||"";return k(()=>({queryParams:a,hostname:i,origin:o,location:r}),[a,i,o,r])},fx=({children:e,currentPageId:t})=>{const{server:n}=f(nc),r=At(),{renderMode:a,previewMode:i,environment:o}=K(),[[s,l,c]]=Ot(["schema.pageFolders","pageDefinitions","schema.variables"]),u=n.ssr?.renderResult,d="widget"!==a?ck():void 0,{queryParams:p,hostname:m,origin:y,location:b}=px({server:n,routerLocation:d}),v=x(l);v.current=l;const w=x(s);w.current=s;const{authenticated:S}=f(dx),T="widget"!==a?pk():void 0,C=x(T);g(()=>{C.current=T},[T]);const A=k(()=>Ec(l,s,S,n.basePath,i),[l,s,S,n.basePath,i]),{action:E,pageId:N="",pathMatch:O}=k(()=>"widget"===a?{action:{type:"normal",path:""},pageId:t}:Ic(A,b.pathname,S),[A,b.pathname,S,a,t]),M=t||N;g(()=>{Ml.info("navigation",/* @__PURE__ */_("span",{children:["Navigated to page"," ",
58
- /* @__PURE__ */I("b",{children:Jn(l,`${M}.attributes.name`,M||"Unknown")})]}),{status:E.type,elementId:M})},[E.type,M,l]);const P=h(e=>((e,t,n)=>{let r=e[n];if(!r)return n;let{slug:a,default:i}=r.attributes;return"string"==typeof a?Cc(e,t,n,!0):i?"/":`/${n}`})(v.current,w.current,e),[]),L=h((e,t=!1)=>{if(t&&"undefined"!=typeof window)return void(window.location.href=e);const n=P(e);if(!r.get("rsc.enabled"))return void C.current?.(n);const a=()=>C.current?.(n);Promise.race([Mc(r,void 0,void 0,n),new Promise(e=>setTimeout(e,1500))]).then(a,a)},[P,r]),D=k(()=>{const e=A.find(e=>e.pageId===M&&!e.isRaw);return e?{..._c(e.path).reduce((e,t)=>({...e,[t]:""}),{}),...Jn(O,"params",{})}:Jn(O,"params",{})},[A,O,M]),z=jl(D),R=jl(p),j=k(()=>new URLSearchParams(b.search),[b.search]),$=y?`${y}${b.pathname}${b.search}`:"";if(Mt(["navigation.urlSearchParams","navigation.routeParams","navigation.queryParams","navigation.hostname","navigation.origin","navigation.href","navigation.currentPageId","navigation.navigate"],[j,z,R,m,y,$,M,L],{raw:!0}),"notFound"===E.type)return u&&(u.status=404),"Not Found";if("accessDenied"===E.type)return u&&(u.status=403),"Access Denied";if("redirect"===E.type){const e=_l(c,{queryParams:p,routeParams:z,hostname:m,environment:o}),t=E.path?String(On(E.path,{variables:e},!1,!0)):"";if(t&&kc(t)){const e=new URL(t);return e.searchParams.has("redirect")||e.searchParams.set("redirect",(e=>e.href?e.href:`${e.protocol||"https:"}//${e.host||e.hostname}${e.pathname}${e.search}`)(b)),u?(u.redirect=e.toString(),null):(window.location.assign(e.toString()),null)}return u?(u.redirect=E.path??"",null):/* @__PURE__ */I(Ck,{to:E.path??"",replace:!0})}return e},hx=(e,{src:t,type:n,isMain:r},a=!1)=>{let i,o=`${e}/${t}`,s=btoa(o);return i="style"===n&&o.endsWith(".css")?{type:"link",id:s,params:{href:o,rel:"stylesheet",type:"text/css"},isMain:r}:{type:"script",id:s,params:{src:o,type:"text/javascript"},isMain:r},a&&delete i.isMain,i},mx=(e,t)=>{try{let{resource:n,settings:r,type:a}=e,{definition:{name:i="Plitzi's Demo Plugin",owner:o="Plitzi",verified:s=!1,license:l="MIT",website:c="https://plitzi.com",backgroundColor:u="#4422ee",icon:d="https://cdn.plitzi.com/resources/img/favicon.svg"},assets:p,assetsSettings:f,pluginSchema:h}=t;return Object.values(Jn(t,"pluginSchema",{})).reduce((e,m)=>{let{definition:g,builder:y,defaultStyle:b,attributes:v}=m,w=[];return g.type===a&&(w=Object.keys(rr(h,[a]))),{...e,[g.type]:{attributes:v,builder:y,defaultStyle:b,definition:g,market:{owner:o,verified:s,license:l,website:c,backgroundColor:u,icon:d,category:i},resource:n,isMain:g.type===a,manifest:t,type:a,settings:r,assetsSettings:Object.values(f).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>hx(n,e,!0)),assets:Object.values(p).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>hx(n,e)),subPlugins:w}}},{})}catch{return{}}},gx=async(e=[])=>{let t={};if(!Array.isArray(e))return t;let n=await(async e=>{if(!Array.isArray(e)||0===e.length)return{};let t=e.map(e=>(async e=>{try{let t=await fetch(e,{headers:{Accept:"application/json"}});return t.ok?await t.json():void 0}catch{return}})(e));return(await Promise.allSettled(t)).reduce((e,t)=>"fulfilled"===t.status&&t.value?{...e,[Jn(t.value,"root","")]:t.value}:e,{})})(e.filter(e=>e.resource).reduce((e,t)=>[...e,`${t.resource}/plugin-manifest.json`],[]));return e.forEach(e=>{let{type:r}=e,a=Jn(n,r);t={...t,...mx(e,a)}}),t},yx=class extends Error{failure;statusCode;constructor(e,t,n){super(e),this.name="GraphqlRequestError",this.failure=t,this.statusCode=n}},bx=e=>"object"==typeof e&&null!==e,vx=({children:e,server:t,revision:n,webKey:r="",webId:a,userKey:i="",instanceId:o,offlineMode:s=!1,offlineData:l,offlineDataType:c="json"})=>{const{environment:u,debugMode:d}=K(),p=Lt(),m=s&&!!l&&!!l.schema,y=k(()=>((e,t)=>({request:async(n,r)=>{let a;try{a=await fetch(e,{method:"POST",headers:{accept:"application/graphql-response+json, application/json;q=0.9","content-type":"application/json","sdk-version":"0.37.7",authorization:t?`Bearer ${t}`:""},body:JSON.stringify({query:n,variables:r})})}catch(tI){throw new yx(tI instanceof Error?tI.message:"Network request failed","network")}const i=(e=>{try{return JSON.parse(e)}catch{return}})(await a.text());if(!a.ok){const t=Hr(a.status,i);throw t&&Br({reason:t,url:e}),new yx(`Response not successful: Received status code ${a.status}`,"http",a.status)}const o=(e=>{const t=bx(e)?e.errors:void 0;return Array.isArray(t)?t.map(e=>bx(e)&&"string"==typeof e.message?e.message:"Unknown error"):[]})(i);if(o.length)throw new yx(o.join("\n"),"graphql",a.status);if(!bx(i)||!bx(i.data))throw new yx("The server answered without data","graphql",a.status);return i.data}}))(t.serverUrl,r),[t.serverUrl,r]),[b,v]=S(!(s&&l)),[w,x]=S(void 0),{components:T}=f(_r),[C,A]=S(()=>m&&"json"===c?{...l,plugins:{},segments:{}}:{plugins:{},segments:{}}),E=h(async(e,t)=>{try{return{success:!0,result:await y.request(ic[e],{environment:u,...t})}}catch(tI){return{success:!1,result:void 0,error:tI instanceof Error?tI:String(tI)}}},[y,u]),N=h(async(e,t,n=!0)=>{const r=ac[e];if(!r)return{success:!1,result:void 0,error:"Mutation Not Found"};try{return{success:!0,result:await y.request(r,n?{environment:u,...t}:t)}}catch(tI){return{success:!1,result:void 0,error:tI instanceof Error?tI:String(tI)}}},[y,u]),O=async()=>{let e=n;"number"==typeof n&&0!==n||(e=void 0);const t=await E("Init",{environment:u,revision:e});if(t.error)return v(!1),void x((e=>e instanceof yx?401===e.statusCode?"Access not authorized":"network"===e.failure?"Service not available":e.message:"string"==typeof e?e:e.message)(t.error));if(t.success&&t.result){const{Space:e}=Qn(t.result);if(!e)return x(/* @__PURE__ */_("span",{children:["Space not found, publish to ",
58
+ /* @__PURE__ */I("b",{children:Jn(l,`${M}.attributes.name`,M||"Unknown")})]}),{status:E.type,elementId:M})},[E.type,M,l]);const P=h(e=>((e,t,n)=>{let r=e[n];if(!r)return n;let{slug:a,default:i}=r.attributes;return"string"==typeof a?Cc(e,t,n,!0):i?"/":`/${n}`})(v.current,w.current,e),[]),L=h((e,t=!1)=>{if(t&&"undefined"!=typeof window)return void(window.location.href=e);const n=P(e);if(!r.get("rsc.enabled"))return void C.current?.(n);const a=()=>C.current?.(n);Promise.race([Mc(r,void 0,void 0,n),new Promise(e=>setTimeout(e,1500))]).then(a,a)},[P,r]),D=k(()=>{const e=A.find(e=>e.pageId===M&&!e.isRaw);return e?{..._c(e.path).reduce((e,t)=>({...e,[t]:""}),{}),...Jn(O,"params",{})}:Jn(O,"params",{})},[A,O,M]),z=jl(D),R=jl(p),j=k(()=>new URLSearchParams(b.search),[b.search]),$=y?`${y}${b.pathname}${b.search}`:"";if(Mt(["navigation.urlSearchParams","navigation.routeParams","navigation.queryParams","navigation.hostname","navigation.origin","navigation.href","navigation.currentPageId","navigation.navigate"],[j,z,R,m,y,$,M,L],{raw:!0}),"notFound"===E.type)return u&&(u.status=404),"Not Found";if("accessDenied"===E.type)return u&&(u.status=403),"Access Denied";if("redirect"===E.type){const e=_l(c,{queryParams:p,routeParams:z,hostname:m,environment:o}),t=E.path?String(On(E.path,{variables:e},!1,!0)):"";if(t&&kc(t)){const e=new URL(t);return e.searchParams.has("redirect")||e.searchParams.set("redirect",(e=>e.href?e.href:`${e.protocol||"https:"}//${e.host||e.hostname}${e.pathname}${e.search}`)(b)),u?(u.redirect=e.toString(),null):(window.location.assign(e.toString()),null)}return u?(u.redirect=E.path??"",null):/* @__PURE__ */I(Ck,{to:E.path??"",replace:!0})}return e},hx=(e,{src:t,type:n,isMain:r},a=!1)=>{let i,o=`${e}/${t}`,s=btoa(o);return i="style"===n&&o.endsWith(".css")?{type:"link",id:s,params:{href:o,rel:"stylesheet",type:"text/css"},isMain:r}:{type:"script",id:s,params:{src:o,type:"text/javascript"},isMain:r},a&&delete i.isMain,i},mx=(e,t)=>{try{let{resource:n,settings:r,type:a}=e,{definition:{name:i="Plitzi's Demo Plugin",owner:o="Plitzi",verified:s=!1,license:l="MIT",website:c="https://plitzi.com",backgroundColor:u="#4422ee",icon:d="https://cdn.plitzi.com/resources/img/favicon.svg"},assets:p,assetsSettings:f,pluginSchema:h}=t;return Object.values(Jn(t,"pluginSchema",{})).reduce((e,m)=>{let{definition:g,builder:y,defaultStyle:b,attributes:v}=m,w=[];return g.type===a&&(w=Object.keys(rr(h,[a]))),{...e,[g.type]:{attributes:v,builder:y,defaultStyle:b,definition:g,market:{owner:o,verified:s,license:l,website:c,backgroundColor:u,icon:d,category:i},resource:n,isMain:g.type===a,manifest:t,type:a,settings:r,assetsSettings:Object.values(f).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>hx(n,e,!0)),assets:Object.values(p).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>hx(n,e)),subPlugins:w}}},{})}catch{return{}}},gx=async(e=[])=>{let t={};if(!Array.isArray(e))return t;let n=await(async e=>{if(!Array.isArray(e)||0===e.length)return{};let t=e.map(e=>(async e=>{try{let t=await fetch(e,{headers:{Accept:"application/json"}});return t.ok?await t.json():void 0}catch{return}})(e));return(await Promise.allSettled(t)).reduce((e,t)=>"fulfilled"===t.status&&t.value?{...e,[Jn(t.value,"root","")]:t.value}:e,{})})(e.filter(e=>e.resource).reduce((e,t)=>[...e,`${t.resource}/plugin-manifest.json`],[]));return e.forEach(e=>{let{type:r}=e,a=Jn(n,r);t={...t,...mx(e,a)}}),t},yx=class extends Error{failure;statusCode;constructor(e,t,n){super(e),this.name="GraphqlRequestError",this.failure=t,this.statusCode=n}},bx=e=>"object"==typeof e&&null!==e,vx=({children:e,server:t,revision:n,webKey:r="",webId:a,userKey:i="",instanceId:o,offlineMode:s=!1,offlineData:l,offlineDataType:c="json"})=>{const{environment:u,debugMode:d}=K(),p=Lt(),m=s&&!!l&&!!l.schema,y=k(()=>((e,t)=>({request:async(n,r)=>{let a;try{a=await fetch(e,{method:"POST",headers:{accept:"application/graphql-response+json, application/json;q=0.9","content-type":"application/json","sdk-version":"0.37.8",authorization:t?`Bearer ${t}`:""},body:JSON.stringify({query:n,variables:r})})}catch(tI){throw new yx(tI instanceof Error?tI.message:"Network request failed","network")}const i=(e=>{try{return JSON.parse(e)}catch{return}})(await a.text());if(!a.ok){const t=Hr(a.status,i);throw t&&Br({reason:t,url:e}),new yx(`Response not successful: Received status code ${a.status}`,"http",a.status)}const o=(e=>{const t=bx(e)?e.errors:void 0;return Array.isArray(t)?t.map(e=>bx(e)&&"string"==typeof e.message?e.message:"Unknown error"):[]})(i);if(o.length)throw new yx(o.join("\n"),"graphql",a.status);if(!bx(i)||!bx(i.data))throw new yx("The server answered without data","graphql",a.status);return i.data}}))(t.serverUrl,r),[t.serverUrl,r]),[b,v]=S(!(s&&l)),[w,x]=S(void 0),{components:T}=f(_r),[C,A]=S(()=>m&&"json"===c?{...l,plugins:{},segments:{}}:{plugins:{},segments:{}}),E=h(async(e,t)=>{try{return{success:!0,result:await y.request(ic[e],{environment:u,...t})}}catch(tI){return{success:!1,result:void 0,error:tI instanceof Error?tI:String(tI)}}},[y,u]),N=h(async(e,t,n=!0)=>{const r=ac[e];if(!r)return{success:!1,result:void 0,error:"Mutation Not Found"};try{return{success:!0,result:await y.request(r,n?{environment:u,...t}:t)}}catch(tI){return{success:!1,result:void 0,error:tI instanceof Error?tI:String(tI)}}},[y,u]),O=async()=>{let e=n;"number"==typeof n&&0!==n||(e=void 0);const t=await E("Init",{environment:u,revision:e});if(t.error)return v(!1),void x((e=>e instanceof yx?401===e.statusCode?"Access not authorized":"network"===e.failure?"Service not available":e.message:"string"==typeof e?e:e.message)(t.error));if(t.success&&t.result){const{Space:e}=Qn(t.result);if(!e)return x(/* @__PURE__ */_("span",{children:["Space not found, publish to ",
59
59
  /* @__PURE__ */I("b",{children:u})," environment"]})),void v(!1);let n={};e.plugins.length>0&&(n=await gx(e.plugins.filter(e=>!T.current[e.type]))),p("render.overQuota",e.render?.overQuota??!1),A({schema:{...Ql,...e.schema,flat:e.schema.flat.reduce((e,t)=>({...e,[t.id]:t}),{})},plugins:n,style:e.style,segments:e.segments?.map(e=>({...e,schema:{...Jn(e,"schema"),flat:Jn(e,"schema.flat",[]).reduce((e,t)=>({...e,[t.id]:t}),{})}})).reduce((e,t)=>({...e,[t.identifier]:t}),{})??{}})}v(!1)};g(()=>{s&&l?m&&(async()=>{let e={};l?.plugins&&l.plugins.length>0&&(e=await gx(l.plugins.filter(e=>!T.current[e.type]))),A(t=>({...t,plugins:e})),v(!1)})():(v(e=>e||!0),O())},[m,s&&c,r,u,d]);const M=k(()=>({query:E,mutate:N,webKey:r,webId:a,server:t,environment:u,instanceId:o,userKey:i}),[E,N,r,a,t,u,o,i]);return w?/* @__PURE__ */I("div",{children:w}):b?null:/* @__PURE__ */I(nc,{value:M,children:/* @__PURE__ */I(rc,{value:C,children:e})})},wx=l({assets:{}});wx.displayName="PluginsContext";var kx=({children:e,plugins:t,sdkStylePath:n="./plitzi-sdk.css"})=>{const{renderMode:r}=K(),[a,i]=S({}),o=f(rc),s=k(()=>t||o.plugins,[t,o]),{components:l}=f(_r),c=h((e,t,n="")=>t?Jn(s,`${e}.settings.${t}`,n):Jn(s,`${e}.settings`,{}),[s]),u=h((e=[])=>{const t=e.reduce((e,t)=>{let n="";return n="script"===t.type?t.params.src:t.params.href,n?(n=btoa(n),{...e,[n]:{...t,key:n}}):e},{});0!==Object.keys(t).length&&i(e=>({...e,...t}))},[]),d=h((e=[])=>{const t=e.filter(e=>!function(e){return null==e||"number"!=typeof e&&"boolean"!=typeof e&&"function"!=typeof e&&"symbol"!=typeof e&&("string"==typeof e||Array.isArray(e)?0===e.length:e instanceof Map||e instanceof Set?0===e.size:"object"==typeof e&&0===Object.keys(e).length)}(e)).map(e=>btoa(e));i(e=>rr(e,t))},[]),p=k(()=>(e=>Object.values(e).reduce((e,t)=>({...e,...Jn(t,"assets",[]).filter(e=>"link"===e.type).reduce((e,t)=>({...e,[btoa(t.id)]:t}),{})}),{}))(s),[s]),m=k(()=>Object.keys(l.current).filter(e=>"local-custom"===l.current[e].origin).reduce((e,t)=>({...e,...Jn(l,`${t}.assets`,[]).reduce((e,n,r)=>({...e,[`${t}-${r}`]:{type:"link",id:`${t}-${r}`,params:n}}),{})}),{}),[l.current]),g=k(()=>{const e={};return"iframe"!==r&&"shadow"!==r||(e["static-99"]={type:"link",id:"static-99",params:{type:"text/css",href:n,rel:"stylesheet"}}),{...e,...m,...p,...a}},[m,p,a,r,n]),y=k(()=>({assets:g,getSettings:c,plugins:s,registerCustomAssets:u,unregisterCustomAssets:d}),[g,c,s,u,d]),b=k(()=>Object.values({...p,...a}).map((e,t)=>/* @__PURE__ */I(e.type,{...e.params},t)),[p,a]);/* @__PURE__ */
60
60
  return _(E,{children:[/* @__PURE__ */I(Ud,{children:("raw"===r||"widget"===r)&&b}),/* @__PURE__ */I(wx,{value:y,children:e})]})},xx=({children:e,schema:t})=>{const n=f(rc),r=k(()=>({...Ql,...t||n.schema}),[t,n.schema]);Mt("schema",r);const a=k(()=>Zn(Jn(r,"flat",{}),Jn(r,"pages",[])),[r.pages]);return Mt("pageDefinitions",a),e},Sx=l({});Sx.displayName="ContainerRootContext";var Tx=({className:e="",children:t,...n})=>{let r=x(null),a=h(()=>r.current instanceof HTMLElement?r.current.getRootNode():void 0,[r]),i=h(()=>a()instanceof ShadowRoot,[a]),o=k(()=>({getHost:a,rootRef:r,isRootShadow:i}),[a,r,i]);/* @__PURE__ */
61
61
  return I("div",{...n,ref:r,className:e,children:/* @__PURE__ */I(Sx,{value:o,children:t})})},Cx=l({});Cx.displayName="InteractionsContext";var Ax=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/,Ex=/^rgba?\(\s*(\d{1,3}%?\s*,\s*){2,3}\d{1,3}%?\s*\)$/,Ix=/^hsla?\(\s*\d{1,3}(deg|rad|turn)?\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%(\s*,\s*(0|0?\.\d+|1))?\s*\)$/,_x=/* @__PURE__ */new Set(["black","white","red","green","blue","yellow","cyan","magenta","orange","purple","brown","pink","gray","lime","teal","navy","silver","maroon","olive","aqua","fuchsia"]),Nx=({children:e,contentDidMount:t,contentDidDismount:n})=>(g(()=>(t?.(),()=>{n?.()}),[]),e),Ox=({ref:e,className:t="",ssrMode:r=!1,id:a="",css:i="",style:o,zoom:s=1,assets:l,viewport:c="width=device-width, initial-scale=1",children:u,contentDidMount:d,contentDidDismount:p,contentDidUpdate:f,onLoad:m})=>{t=ns("ContainerFrame",{className:t,componentKey:"root"});let y=x(null);v(e,()=>y.current,[y]);let[b,w]=S(!1),[k,T]=S(null),C=h((e,t,n)=>{let r=[...t.childNodes],a=n.getElementById("customStyle");Object.values(e).forEach(e=>{let i=n.createElement(e.type);e.id&&i.setAttribute("data-id",e.id),Object.keys(e.params).forEach(t=>{("link"===e.type||"script"===e.type)&&i.setAttribute(t,e.params[t])}),r.find(t=>"link"===e.type&&t.href===i.href||"script"===e.type&&t.src===i.src)||(t.insertBefore(i,a),r.push(i))})},[]),A=h((e,t)=>{let{head:n}=e,r=n.querySelectorAll('*:not([asset-static="true"])');Object.values(r).forEach(e=>{n.removeChild(e)}),t&&C(t,n,e)},[C]),[O]=S(()=>(e=>{if(!e)return"";let t=[];return Object.values(e).forEach(e=>{t.push(`<${e.type} ${Object.keys(e.params).map(t=>`${t}="${e.params[t]}"`).join(" ")}>`)}),t.join("")})(l)),M=h(()=>d?.(),[d]);g(()=>{b&&k&&A(k,l)},[b,l,k,A]);let P=h(()=>{let e=y.current&&k,t=y.current?.contentDocument===k;!e||t?b||(m?.(y.current),w(!0),T(y.current?.contentDocument)):T(y.current?.contentDocument)},[b,k,m]);return g(()=>{k&&(k.body.style.zoom=1===s?"":`${s}`)},[k,s]),/* @__PURE__ */_("iframe",{ref:y,className:t,title:"#",srcDoc:`<!DOCTYPE html><html><head>${O}</head><body></body></html>`,id:a,onLoad:P,style:o,children:[b&&k&&N(/* @__PURE__ */_(E,{children:[
@@ -90,7 +90,7 @@ return I(sd,{ref:e,className:U("plitzi-component__loading",t),children:/* @__PUR
90
90
  /* @__PURE__ */I("b",{children:n})," Not Found"]}),!n&&"Component Not Found"]})})},eT=Lu(QS),tT=Object.assign(eT,{type:"notFound",content:{attributes:{},definition:{label:"Not Found",type:"notFound",description:"The 404 screen shown when no route matches.",bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!1,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"internal",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"https://cdn.plitzi.com/resources/img/favicon.svg"},defaultStyle:{name:"Not Found",displayMode:"desktop",style:{base:{default:{}}}},settings:{}}}),nT={type:"page",triggers:{onPageLoad:{action:"onPageLoad",title:"On Page Load",type:"trigger",params:{},preview:{pageId:"",routeParams:"",queryParams:""}}},content:{attributes:{enabled:!0,name:"Page",slug:"",folder:"",layout:"",layoutContainer:"",seoEnabled:!1,seoPageTitle:"Title",seoPageDescription:"Description"},definition:{label:"Page",type:"page",description:"The root of a routable screen. Managed through the page ops (upsertPage/deletePage), not added as a child element.",items:[],bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!1,canSelect:!0,canDragDrop:!1,canMove:!1,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"internal",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"fas fa-file"},defaultStyle:{name:"Page",displayMode:"desktop",style:{base:{default:{display:"flex","flex-direction":"column","min-height":"100%","min-width":"100%","font-family":"Arial",color:"#333","font-size":"14px","font-weight":400,"line-height":"16px","text-align":"left","background-color":"#ffffff"}}}},settings:{}}},rT=[],aT=Lu(({ref:e,seoEnabled:t=!1,seoPageTitle:n="Title",seoPageDescription:r="Description",className:a="",layout:i="",layoutContainer:o="",children:s})=>{let{id:l}=Du(),{settings:{previewMode:c},contexts:{InteractionsContext:u}}=zl(),{interactionsManager:d}=f(u),[[p,y]]=Ot(["navigation.routeParams","navigation.queryParams"]),b=((e,t)=>{let n=m(ut),r=x(rT),a=h(e=>n?n.subscribePath("schema.flat",e):()=>{},[n]),i=h(()=>{let a=e&&n?tc(e=>{let t=(e=>n.getPath(e))(`schema.flat.${e}`);return(e=>"object"==typeof e&&!!e&&"definition"in e&&"attributes"in e)(t)?t:void 0},e,t):rT;return((e,t)=>e.length===t.length&&e.every((e,n)=>e.layout===t[n].layout&&e.slot===t[n].slot))(r.current,a)||(r.current=a),r.current},[n,e,t]);return T(a,i,i)})(i,o),v=k(()=>(e=>e.map(e=>({...e,plitziElementLayout:{containerId:e.slot,rootId:e.slot,type:"layout"}})))(b),[b]),w=k(()=>((e,t,n)=>e.reduce((e,{layout:n,slot:r,plitziElementLayout:a})=>/* @__PURE__ */I(jr,{body:e,children:/* @__PURE__ */I(KS,{internalProps:{id:n,rootId:t,plitziElementLayout:a}})},r),n))(v,l,s),[v,l,s]);return g(()=>{let e=!1;return queueMicrotask(()=>{e||d.interactionTrigger(l,"onPageLoad",{pageId:l,routeParams:p,queryParams:y})}),()=>{e=!0}},[l,d,y,p]),/* @__PURE__ */_(sd,{ref:e,className:U("plitzi-component__page",a),interactionTriggers:nT.triggers,children:[t&&c&&/* @__PURE__ */_(Ud,{children:[!!n&&/* @__PURE__ */I("title",{children:n}),!!r&&/* @__PURE__ */I("meta",{name:"description",content:r})]}),w]})}),iT=Object.assign(aT,nT),oT=Lu(({ref:e,className:t="",icon:n="fas fa-flag",size:r="fa-1x",iconAnimation:a="",label:i=""})=>{let o=i?{role:"img","aria-label":i}:{"aria-hidden":!0};/* @__PURE__ */
91
91
  return I(sd,{ref:e,tag:"i",className:U("plitzi-component__fontawesome",t,n,r,a),...o})}),sT=Object.assign(oT,{type:"fontAwesome",content:{attributes:{icon:"fas fa-flag",size:"fa-1x",iconAnimation:""},definition:{label:"Font Awesome",type:"fontAwesome",description:"Renders a Font Awesome icon by its icon name.",bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!0,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"media",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"fa-solid fa-font-awesome"},defaultStyle:{name:"Font Awesome",displayMode:"desktop",style:{base:{default:{display:"inline-block","font-size":"16px"}}}},settings:{}}}),lT="data:image/svg+xml;base64,"+btoa('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 1200" fill="none">\n <rect width="1200" height="1200" fill="#EAEAEA" rx="3"/>\n <path fill="#FAFAFA" opacity="0.5" d="M600.709 736.5c-75.454 0-136.621-61.167-136.621-136.62 0-75.454 61.167-136.621 136.621-136.621 75.453 0 136.62 61.167 136.62 136.621 0 75.453-61.167 136.62-136.62 136.62Z"/>\n <path stroke="#C9C9C9" stroke-width="2.418" opacity="0.5" d="M600.709 736.5c-75.454 0-136.621-61.167-136.621-136.62 0-75.454 61.167-136.621 136.621-136.621 75.453 0 136.62 61.167 136.62 136.621 0 75.453-61.167 136.62-136.62 136.62Z"/>\n <path stroke="url(#a)" stroke-width="2.418" d="M0-1.209h553.581" transform="scale(1 -1) rotate(45 1163.11 91.165)"/>\n <path stroke="url(#b)" stroke-width="2.418" d="M404.846 598.671h391.726"/>\n <path stroke="url(#c)" stroke-width="2.418" d="M599.5 795.742V404.017"/>\n <path stroke="url(#d)" stroke-width="2.418" d="m795.717 796.597-391.441-391.44"/>\n <path fill="#fff" d="M600.709 656.704c-31.384 0-56.825-25.441-56.825-56.824 0-31.384 25.441-56.825 56.825-56.825 31.383 0 56.824 25.441 56.824 56.825 0 31.383-25.441 56.824-56.824 56.824Z"/>\n <path fill="#666" fill-rule="evenodd" d="M616.426 586.58h-31.434v16.176l3.553-3.554.531-.531h9.068l.074-.074 8.463-8.463h2.565l7.18 7.181V586.58Zm-15.715 14.654 3.698 3.699 1.283 1.282-2.565 2.565-1.282-1.283-5.2-5.199h-6.066l-5.514 5.514-.073.073v2.876a2.418 2.418 0 0 0 2.418 2.418h26.598a2.418 2.418 0 0 0 2.418-2.418v-8.317l-8.463-8.463-7.181 7.181-.071.072Zm-19.347 5.442v4.085a6.045 6.045 0 0 0 6.046 6.045h26.598a6.044 6.044 0 0 0 6.045-6.045v-7.108l1.356-1.355-1.282-1.283-.074-.073v-17.989h-38.689v23.43l-.146.146.146.147Z" clip-rule="evenodd"/>\n <path stroke="#C9C9C9" stroke-width="2.418" d="M600.709 656.704c-31.384 0-56.825-25.441-56.825-56.824 0-31.384 25.441-56.825 56.825-56.825 31.383 0 56.824 25.441 56.824 56.825 0 31.383-25.441 56.824-56.824 56.824Z"/>\n <defs>\n <linearGradient id="a" x1="554.061" x2="-.48" y1=".083" y2=".087" gradientUnits="userSpaceOnUse">\n <stop stop-color="#C9C9C9" stop-opacity="0"/><stop offset=".208" stop-color="#C9C9C9"/><stop offset=".792" stop-color="#C9C9C9"/><stop offset="1" stop-color="#C9C9C9" stop-opacity="0"/>\n </linearGradient>\n <linearGradient id="b" x1="796.912" x2="404.507" y1="599.963" y2="599.965" gradientUnits="userSpaceOnUse">\n <stop stop-color="#C9C9C9" stop-opacity="0"/><stop offset=".208" stop-color="#C9C9C9"/><stop offset=".792" stop-color="#C9C9C9"/><stop offset="1" stop-color="#C9C9C9" stop-opacity="0"/>\n </linearGradient>\n <linearGradient id="c" x1="600.792" x2="600.794" y1="403.677" y2="796.082" gradientUnits="userSpaceOnUse">\n <stop stop-color="#C9C9C9" stop-opacity="0"/><stop offset=".208" stop-color="#C9C9C9"/><stop offset=".792" stop-color="#C9C9C9"/><stop offset="1" stop-color="#C9C9C9" stop-opacity="0"/>\n </linearGradient>\n <linearGradient id="d" x1="404.85" x2="796.972" y1="403.903" y2="796.02" gradientUnits="userSpaceOnUse">\n <stop stop-color="#C9C9C9" stop-opacity="0"/><stop offset=".208" stop-color="#C9C9C9"/><stop offset=".792" stop-color="#C9C9C9"/><stop offset="1" stop-color="#C9C9C9" stop-opacity="0"/>\n </linearGradient>\n <clipPath id="e"><path fill="#fff" d="M581.364 580.535h38.689v38.689h-38.689z"/></clipPath>\n </defs>\n</svg>'),cT=Lu(({ref:e,className:t="",src:n,alt:r="",decorative:a=!1,fetchPriority:i="auto",loadMode:o})=>{let{settings:{previewMode:s}}=zl(),l=n||"https://cdn.plitzi.com/resources/img/placeholder-img.svg",c=a?"":r,[u,d]=S(void 0),p=u===l,f=h(()=>d(l),[l]),m=p?lT:l,g=p?{"data-plitzi-failed":l}:{},y="auto"===o?void 0:o;/* @__PURE__ */
92
92
  return I(sd,s?{tag:"img",draggable:!1,ref:e,className:U("plitzi-component__image",t),src:m,alt:c,loading:y,fetchPriority:i,onError:p?void 0:f,...g}:{ref:e,className:U("plitzi-component__image image--edit-mode",t),children:/* @__PURE__ */I("img",{draggable:!1,src:m,alt:c,loading:y,fetchPriority:i,onError:p?void 0:f,...g})})}),uT=Object.assign(cT,{type:"image",attributeValues:{fetchPriority:["high","low","auto"],loadMode:["auto","eager","lazy"]},content:{attributes:{src:"https://cdn.plitzi.com/resources/img/placeholder-img.svg",alt:"",decorative:!1,fetchPriority:"auto",loadMode:"auto"},definition:{label:"Image",type:"image",description:"Displays an image from a URL.",bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!0,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"media",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"fa-solid fa-image"},defaultStyle:{name:"Image",displayMode:"desktop",style:{base:{default:{display:"block",width:"140px",height:"140px"}}}},settings:{}}}),dT=Lu(({ref:e,src:t,autoPlay:n=!1,playsInline:r=!1,loop:a=!1,muted:i=!0,className:o=""})=>{let{settings:{previewMode:s}}=zl();/* @__PURE__ */
93
- return I(sd,s?{tag:"video",draggable:!1,ref:e,className:U("plitzi-component__video",o),src:t,autoPlay:n,playsInline:r,loop:a,muted:i}:{ref:e,className:U("plitzi-component__video video--edit-mode",o),children:/* @__PURE__ */I("video",{src:t,autoPlay:n,playsInline:r,loop:a,muted:i,children:/* @__PURE__ */I("track",{kind:"captions"})})})}),pT=Object.assign(dT,{type:"video",content:{attributes:{src:"",autoPlay:!1,playsInline:!1,loop:!1,muted:!0},definition:{label:"Video",type:"video",description:"Embeds a video from a URL.",bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!0,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"media",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"fa-solid fa-video"},defaultStyle:{name:"Video",displayMode:"desktop",style:{base:{default:{display:"block",width:"400px",height:"250px"}}}},settings:{}}}),fT={type:"apiContainer",attributeValues:{subType:["","div","header","footer","nav","main","section","article","aside","address","figure"],method:["get","post","put","delete","patch"],credentials:["include","omit","same-origin"],pagination:["none","url","append"]},sourceType:"apiContainer",triggers:{onApiError:{action:"onApiError",title:"On Api Error",type:"trigger",params:{},preview:{url:"",method:"",status:"",data:""}},onApiSuccess:{action:"onApiSuccess",title:"On Api Success",type:"trigger",params:{},preview:{url:"",method:"",status:"",data:""}}},callbacks:{performQuery:{action:"performQuery",title:"Perform Query",type:"callback",preview:{},params:{input:{label:"Input (server providers)",type:"codemirror-json",defaultValue:"{}",description:"Values handed to a server-driven provider with its request, beside the page’s own route and query params — a search, a filter. Kept for the pages it loads after (`loadMore`, `goToPage`) until the next query."}}},loadMore:{action:"loadMore",title:"Load More",type:"callback",preview:{},params:{}},goToPage:{action:"goToPage",title:"Go To Page",type:"callback",preview:{},params:{page:{label:"Page",defaultValue:"1",type:"text"}}},writeRecord:{action:"writeRecord",title:"Write Record",type:"callback",preview:{action:"create"},params:{action:{label:"Endpoint",defaultValue:"create",type:"text"},recordId:{label:"Record Id",defaultValue:"",type:"text"}}}},content:{attributes:{query:"",method:"get",accessToken:"",mockData:"{}",subType:"",credentials:"same-origin",connector:"",resource:"",limit:"10",singleRecord:!1,filters:[],pagination:"none",pageParam:"page",renderWhileLoading:!1,cache:!1,staleTime:30,gcTime:300},definition:{label:"Api Container",type:"apiContainer",description:'Fetches data from a backend HTTP API (its `query`/`method`/`credentials`) and exposes the response as a data source ITS DESCENDANTS bind to (source `apiContainer_<id>.data`; only elements inside it can consume it). This is how you get backend data into the frontend. Its `mockData` prop is builder-only sample data — the published runtime fetches the real `query`, so always set a real query for production. With `cache: true` a browser request is kept for `staleTime` seconds (default 30) and shared with every provider asking the same thing; it is off unless set. A flow refreshes it with `performQuery` or the global `invalidateQueries` step, and `refreshSeconds` makes it ask again on its own every N seconds (either runtime; paused while the tab is hidden) — the way to keep a queue, feed or status board current without a plugin. Its `subType` (container tag) is empty by default, and then it renders NO element of its own: its children lay out directly in its parent, and any class, variant or style binding on it applies to nothing. To style the provider itself give it a tag (`subType: "div"`, `section`, …); otherwise style its parent or a child.',items:[],bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!0,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"provider",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"fa-solid fa-server"},defaultStyle:{name:"Api Container",displayMode:"desktop",style:{base:{default:{}}},subTypes:{}},settings:{}}},hT=()=>{let{id:e,rootId:t}=Du(),[[n=!1,r=!1,a=!1,i,o,s,l]]=Et(["rsc.enabled","rsc.loaded","rsc.stale","rsc.location",Nc(e),"navigation.currentPageId","schema.pages"]),c=Pc(),u=void 0!==i&&i!==Oc()||void 0!==t&&t!==s&&Array.isArray(l)&&l.includes(t),d=x(void 0);!u&&void 0!==o&&(d.current=o);let p=u&&void 0!==d.current?d.current:o;return{enabled:n,loaded:r,stale:a,location:i,elementData:p??null,isServerElement:void 0!==p,refresh:c}},mT=(e,t,n)=>n?void 0===e.record:Array.isArray(e.records)?0===t.length:(e=>null==e||""===e||Array.isArray(e)&&0===e.length||"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length)(e.data),gT=3e5,yT=e=>{let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let a=e.charCodeAt(r);t=Math.imul(t^a,2654435761),n=Math.imul(n^a,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)},bT=e=>`entries.${yT(e)}`,vT=new class{store;runtimes=/* @__PURE__ */new Map;epochValue=0;unwatch;constructor(e=Be({entries:{}},{id:"queries"})){this.store=e}get epoch(){return this.epochValue}getEntry(e){let t=this.store.getPath(bT(e));return t?.key===e?t:void 0}hasAnswer(e){return void 0!==this.getEntry(e)&&void 0!==this.store.getFreshness(bT(e))}usage(e){let t=this.runtimes.get(yT(e));return t&&{observers:t.observers.size,holds:t.holds,collectAt:t.collectAt}}remove(e){let t=this.runtimes.get(yT(e));return!(!t||t.observers.size>0||t.holds>0||(this.cancelGc(t),this.collect(t),0))}hold(e,t=gT){let n=this.ensure(e);return n.gcTime=t,n.holds++,this.cancelGc(n),()=>{n.holds--,this.scheduleGc(n)}}observe(e,t){let n=this.ensure(e),{isCacheable:r}=t,a={meta:t.meta,staleTime:t.staleTime,fetcher:t.fetcher,isCacheable:r&&(e=>r(e))};return n.observers.add(a),this.cancelGc(n),(!this.hasAnswer(e)||this.store.isStale(bT(e)))&&this.fetch(n,a),()=>{n.observers.delete(a),this.scheduleGc(n)}}async fetchQuery(e,t){let n=this.ensure(e);if(void 0!==t.gcTime&&(n.gcTime=t.gcTime),this.hasAnswer(e)&&!this.store.isStale(bT(e)))return this.scheduleGc(n),this.getEntry(e)?.data;let{isCacheable:r}=t;await this.fetch(n,{meta:t.meta,staleTime:t.staleTime,fetcher:t.fetcher,isCacheable:r&&(e=>r(e))});let a=this.getEntry(e)?.data;return this.scheduleGc(n),a}refetch(e){let t=this.runtimes.get(yT(e));return t?this.invalidateOne(t):Promise.resolve()}invalidate(e){let t=[];return this.runtimes.forEach(n=>{let r=this.getEntry(n.key);!r||e&&!e({url:r.url,tags:r.tags})||t.push(this.invalidateOne(n))}),Promise.all(t).then(()=>{})}reset({refetch:e=!0}={}){if(this.epochValue++,this.runtimes.forEach(e=>{e.version++,e.inFlight=void 0,e.controller?.abort(),e.controller=void 0}),this.store.setState("entries",{}),!e)return this.runtimes.forEach(e=>this.markUnasked(e)),Promise.resolve();let t=[];return this.runtimes.forEach(e=>t.push(this.fetchActive(e))),Promise.all(t).then(()=>{})}markUnasked(e){let t=e.observers.values().next();if(t.done)return;let n={key:e.key,url:t.value.meta.url,tags:[...e.tags],isFetching:!1};this.store.setState(bT(e.key),n,{ttl:0})}invalidateOne(e){return 0===this.store.expire(bT(e.key)).length&&e.version++,this.fetchActive(e)}onExpired(e){let t=this.runtimes.get(e.slice(8).split(".")[0]);t&&(t.version++,this.fetchActive(t))}fetchActive(e){let t=e.observers.values().next();return t.done?Promise.resolve():this.fetch(e,t.value)}fetch(e,t){if(e.inFlight)return e.inFlight;let{key:n}=e,{url:r}=t.meta;t.meta.tags?.forEach(t=>e.tags.add(t));let a=[...e.tags],i=bT(n);this.getEntry(n)?this.store.setState(`${i}.isFetching`,!0):this.store.setState(i,{key:n,url:r,tags:a,isFetching:!0});let o=this.epochValue,s=e.version,l=l=>{if(o!==this.epochValue||this.runtimes.get(yT(n))!==e)return Promise.resolve();e.inFlight=void 0,e.controller=void 0;let c=s!==e.version;if("error"in l){let e=this.getEntry(n);this.store.setState(i,{key:n,url:r,tags:a,data:e?.data,error:l.error,isFetching:!1},{ttl:0})}else{let o=!c&&(t.isCacheable?.(l.data)??!0);this.store.setState(i,{key:n,url:r,tags:a,data:l.data,isFetching:!1},{ttl:o?this.ttlOf(e,t):0})}return c?this.fetchActive(e):Promise.resolve()},c=new AbortController;return e.controller=c,e.inFlight=t.fetcher(c.signal).then(e=>l({data:e}),e=>l({error:e})),e.inFlight}ttlOf(e,t){let n=e.observers.size>0?1/0:t.staleTime;return e.observers.forEach(e=>{n=Math.min(n,e.staleTime)}),n}ensure(e){let t=yT(e),n=this.runtimes.get(t);return n||(n={key:e,tags:/* @__PURE__ */new Set,observers:/* @__PURE__ */new Set,holds:0,version:0,gcTime:3e5},this.runtimes.set(t,n)),this.unwatch??=this.store.watchFreshness("entries",e=>{"expired"===e.type&&this.onExpired(e.path)}),n}cancelGc(e){clearTimeout(e.gcTimer),e.gcTimer=void 0,e.collectAt=void 0}scheduleGc(e){if(!(e.holds>0||e.observers.size>0)){if(this.cancelGc(e),e.gcTime<=0)return void this.collect(e);e.collectAt=Date.now()+e.gcTime,e.gcTimer=setTimeout(()=>this.collect(e),e.gcTime)}}collect(e){let t=yT(e.key);this.runtimes.get(t)===e&&0===e.holds&&0===e.observers.size&&(this.runtimes.delete(t),e.controller?.abort(),this.store.setState(bT(e.key),void 0,{unmount:!0}))}},{useStore:wT}=Ct(),kT=()=>typeof location>"u"?void 0:location.href,xT=e=>{try{return new URL(e,kT()).origin}catch{return}},ST=e=>Array.isArray(e)?e.filter(e=>"string"==typeof e&&""!==e.trim()).map(e=>e.trim()):"string"==typeof e?e.split(",").map(e=>e.trim()).filter(Boolean):[],TT=e=>{try{return new URL(e,kT()).href}catch{return e}},CT=(e={})=>e.url||e.elements?.length?vT.invalidate((({url:e,elements:t})=>{let n=e?TT(e):void 0;return e=>(void 0===n||TT(e.url).startsWith(n))&&(!t?.length||t.some(t=>e.tags?.includes(t)??!1))})(e)):vT.invalidate(),AT=({method:e,url:t,credentials:n,headers:r})=>JSON.stringify([e.toLowerCase(),t,n,Object.entries(r).filter(([e])=>"content-type"!==e.toLowerCase()).sort(([e],[t])=>e<t?-1:+(e>t))]),ET=({mode:e,fallback:t,elements:n,url:r})=>{let a="origin"===e||"all"===e||"elements"===e||"none"===e?e:t;if("none"===a)return Promise.resolve();if("elements"===a){let e=ST(n);return e.length>0?CT({elements:e}):Promise.resolve()}return"origin"===a&&r?(e=>{let t=xT(e);return t?vT.invalidate(e=>xT(e.url)===t):Promise.resolve()})(r):CT()},IT=e=>e.status<400,_T=(e,t)=>{let n="number"==typeof e?e:Number(e);return 1e3*(Number.isFinite(n)&&n>=0?n:t)},NT=e=>Or(e).map(e=>({path:e,name:e.split(".").slice(-2).join(" ")})),OT=Lu(({ref:e,className:t="",children:n,query:r="",method:a="get",accessToken:i="",when:o=Nr,headers:s=Nr,mockData:l="{}",subType:c="",credentials:u="same-origin",singleRecord:d=!1,pagination:p="none",pageParam:m="page",renderWhileLoading:y=!1,cache:v=!1,staleTime:w=30,gcTime:T=300,refreshSeconds:C=0})=>{let{id:A,visible:E,definition:{label:_="Api Container",runtime:N,items:O}}=Du(),M="server"===N,{loaded:P,stale:L,location:D,elementData:z,refresh:R}=hT(),j=El(fT.sourceType,A),{settings:{previewMode:$},contexts:{InteractionsContext:F}}=zl(),{interactionsManager:q}=f(F),[[B,H,W]]=Ot(["navigation.routeParams","navigation.queryParams","navigation.navigate"]),V=k(()=>i?{...s,Authorization:`Bearer ${i}`}:s,[s,i]),G=k(()=>!(M||!E||!($&&r&&(o===Nr||wi(o,{...B,...H}))||!$&&(r||l&&"{}"!==l&&l!==Nr))),[M,E,$,r,o,B,H,l]),Y=k(()=>[A],[A]),{isLoading:K,isFetching:J,data:X,refetch:Z,isSuccess:Q,isError:ee}=(({url:e="",method:t="get",mock:n,customHeaders:r=Nr,enabled:a=!0,credentials:i="same-origin",cache:o=!1,staleTime:s=30,gcTime:l=300,tags:c})=>{let u=(e=>!!e&&"{}"!==e&&e!==Nr)(n),d=b(),p=!u&&(!e||Bn(e)),f=k(()=>{if(u||p)return;let n=AT({method:t,url:e,credentials:i,headers:r});return o?n:`${n}#${d}`},[u,p,e,t,i,r,o,d]),m=h(n=>(async(e,t,n,r,a)=>{if(!e)return{status:400,data:"URL is required"};let i=new Headers(r);i.has("Content-Type")||i.set("Content-Type","application/json");let o={method:t,credentials:n,headers:i,signal:a};"get"!==t&&(o.body="{}");try{let t=await fetch(e,o),n=await t.json(),r=Hr(t.status,n);return r&&Br({reason:r,url:e}),{status:t.status,data:n}}catch(e){if(a.aborted)throw e;return{status:500,data:e.message}}})(e,t,i,r,n),[e,t,i,r]),y=(({key:e,meta:t,fetcher:n,enabled:r=!0,staleTime:a,gcTime:i=gT,isCacheable:o})=>{let s=void 0!==e,[l]=wT(bT(e??""),{store:vT.store,enabled:s}),c=s&&l?.key===e?l:void 0,u=void 0!==c&&vT.hasAnswer(c.key),d=x(n),p=x(o);g(()=>{d.current=n,p.current=o},[n,o]),g(()=>void 0===e?void 0:vT.hold(e,i),[e,i]);let{url:f}=t,m=t.tags?.join("\0")??"";g(()=>{if(r&&void 0!==e)return vT.observe(e,{meta:{url:f,tags:m?m.split("\0"):[]},staleTime:a,fetcher:e=>d.current(e),isCacheable:e=>p.current?.(e)??!0})},[r,e,f,m,a]);let y=u?c.data:void 0,b=x(void 0);void 0===y?b.current&&b.current.epoch!==vT.epoch&&(b.current=void 0):b.current={epoch:vT.epoch,data:y};let v=y??b.current?.data,w=(c?.isFetching??!1)||r&&s&&!u;return{data:v,isFetching:w,isLoading:w&&void 0===v,refetch:h(()=>{r&&void 0!==e&&vT.refetch(e)},[r,e])}})({key:f,meta:{url:e,tags:c},fetcher:m,enabled:a,staleTime:o?_T(s,30):0,gcTime:o?_T(l,300):0,isCacheable:IT}),v=k(()=>u?(e=>{if("string"!=typeof e)return{status:200,data:e};try{return{status:200,data:JSON.parse(e)}}catch(e){return{status:500,data:e.message}}})(n):void 0,[u,n]),w=a&&v?v:y.data,S=!v&&y.isFetching;return{isLoading:S&&void 0===w,isFetching:S,data:w,refetch:y.refetch,isSuccess:!p&&!S&&!!w&&w.status<400,isError:!p&&!S&&!!w&&w.status>=400}})({url:r,method:a,credentials:u,mock:$?void 0:l,customHeaders:V,enabled:G,cache:v,staleTime:w,gcTime:T,tags:Y}),te=M&&!!D&&D!==Oc(),ne=M&&P&&!te&&null===z,re=k(()=>{if(!M)return X??Nr;if(z)return z;if(P)return Nr;if("string"!=typeof l)return l;try{return JSON.parse(l||"{}")}catch{return Nr}},[M,X,z,P,l]),ae=M?te:J,ie=M?te:K,oe=x({}),se=h((e,t)=>R(e,{...oe.current,...t}),[R]),le=h(async()=>{M?await se([A]):Z()},[M,Z,se,A]),ce=h(async({input:e}={})=>{let t=(e=>{let t=e;if("string"==typeof t)try{t=JSON.parse(t||"{}")}catch{return}if("object"==typeof t&&t&&!Array.isArray(t))return Object.fromEntries(Object.entries(t).flatMap(([e,t])=>"string"==typeof t||"number"==typeof t||"boolean"==typeof t?[[e,String(t)]]:[]))})(e);t&&(oe.current=t),await le()},[le]);(({seconds:e,enabled:t,refresh:n})=>{let r=x(n);r.current=n;let a=Number(e),i=t&&Number.isFinite(a)&&a>0;g(()=>{if(!i)return;let e=!1,t=setInterval(()=>{e||"hidden"===document.visibilityState||(e=!0,Promise.resolve().then(()=>r.current()).catch(()=>{}).finally(()=>{e=!1}))},1e3*a);return()=>clearInterval(t)},[i,a])})({seconds:C,enabled:E&&(M?P&&!te:G),refresh:le});let ue=re,de=k(()=>Array.isArray(ue.records)?ue.records:[],[ue.records]),{records:pe,isLoadingMore:fe,goToPage:he,loadMore:me}=(({elementId:e,mode:t,pageParam:n,records:r,page:a,refresh:i,navigate:o})=>{let[s,l]=S(r),[c,u]=S(!1),d=x(0);g(()=>{if("append"===t){if(a<=1)return d.current=1,void l(r);d.current!==a&&(d.current=a,l(e=>[...e,...r]))}},[t,a,r]);let p=h(async r=>{let a=Math.max(r,1);if("url"!==t){if(i){u(!0);try{await i([e],{[n]:String(a)})}finally{u(!1)}}}else o?.(((e,t)=>{if(typeof window>"u")return"";let n=new URL(window.location.href);return t<=1?n.searchParams.delete(e):n.searchParams.set(e,String(t)),`${n.pathname}${n.search}`})(n,a))},[t,o,n,i,e]),f=h(()=>p(a+1),[p,a]);return{records:"append"===t?s:r,isLoadingMore:c,goToPage:p,loadMore:f}})({elementId:A,mode:p,pageParam:m,records:de,page:ue.pageInfo?.page??1,refresh:se,navigate:W}),ge=(({serverMode:e,isSuccess:t,isError:n,rscResolved:r,rscPending:a,elementData:i})=>e?r&&!a?null==i?"error":"success":void 0:t?"success":n?"error":void 0)({serverMode:M,isSuccess:Q,isError:ee,rscResolved:P,rscPending:te,elementData:z});g(()=>{!ae&&A&&ge&&q.interactionTrigger(A,"success"===ge?"onApiSuccess":"onApiError",{url:r,method:a,...re})},[re,A,q,ae,a,ge,r]);let ye=k(()=>({...re,...Array.isArray(ue.records)?{records:pe}:Nr,isLoading:ae||fe,isEmpty:mT(ue,pe,d),hasError:ne,errorMessage:ne?"The data provider could not be reached":"",isStale:M&&L}),[re,ue.records,ue.record,pe,ae,fe,d,ne,M,L]),be=h(()=>NT(ye),[ye]);Il({id:A,source:j,name:_||`API - ${A}`,fields:be});let{writeRecord:ve}=(({elementId:e,enabled:t,actionPath:n="/_action",onDone:r})=>({writeRecord:h(async(a={})=>{let{action:i,recordId:o,...s}=a;if(!t||"string"!=typeof i||!i)return;let l=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({elementId:e,action:i,recordId:o,values:s})});if(!l.ok){let e=Hr(l.status,await l.json().catch(()=>{}));throw e&&Br({reason:e,url:n}),Error(`Write failed with status ${l.status}`)}let c=await l.json();return CT(),await(r?.()),c.record},[n,e,t,r])}))({elementId:A,enabled:M,onDone:le}),we=k(()=>{let e={performQuery:{...fT.callbacks.performQuery,title:`Perform Query ${_}`,callback:ce},loadMore:{...fT.callbacks.loadMore,title:`Load More ${_}`,callback:me},goToPage:{...fT.callbacks.goToPage,title:`Go To Page ${_}`,callback:({page:e})=>he(Number(e)||1)}};return M&&(e.writeRecord={...fT.callbacks.writeRecord,title:`Write Record ${_}`,callback:ve}),e},[_,ce,me,he,M,ve]),ke=k(()=>j?{runtime:{sources:{[j]:ye}}}:Nr,[ye,j]);/* @__PURE__ */
93
+ return I(sd,s?{tag:"video",draggable:!1,ref:e,className:U("plitzi-component__video",o),src:t,autoPlay:n,playsInline:r,loop:a,muted:i}:{ref:e,className:U("plitzi-component__video video--edit-mode",o),children:/* @__PURE__ */I("video",{src:t,autoPlay:n,playsInline:r,loop:a,muted:i,children:/* @__PURE__ */I("track",{kind:"captions"})})})}),pT=Object.assign(dT,{type:"video",content:{attributes:{src:"",autoPlay:!1,playsInline:!1,loop:!1,muted:!0},definition:{label:"Video",type:"video",description:"Embeds a video from a URL.",bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!0,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"media",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"fa-solid fa-video"},defaultStyle:{name:"Video",displayMode:"desktop",style:{base:{default:{display:"block",width:"400px",height:"250px"}}}},settings:{}}}),fT={type:"apiContainer",attributeValues:{subType:["","div","header","footer","nav","main","section","article","aside","address","figure"],method:["get","post","put","delete","patch"],credentials:["include","omit","same-origin"],pagination:["none","url","append"]},sourceType:"apiContainer",triggers:{onApiError:{action:"onApiError",title:"On Api Error",type:"trigger",params:{},preview:{url:"",method:"",status:"",data:""}},onApiSuccess:{action:"onApiSuccess",title:"On Api Success",type:"trigger",params:{},preview:{url:"",method:"",status:"",data:""}}},callbacks:{performQuery:{action:"performQuery",title:"Perform Query",type:"callback",preview:{},params:{input:{label:"Input (server providers)",type:"codemirror-json",defaultValue:"{}",description:"Values handed to a server-driven provider with its request, beside the page’s own route and query params — a search, a filter. Kept for the pages it loads after (`loadMore`, `goToPage`) until the next query."}}},loadMore:{action:"loadMore",title:"Load More",type:"callback",preview:{},params:{}},goToPage:{action:"goToPage",title:"Go To Page",type:"callback",preview:{},params:{page:{label:"Page",defaultValue:"1",type:"text"}}},writeRecord:{action:"writeRecord",title:"Write Record",type:"callback",preview:{action:"create"},params:{action:{label:"Endpoint",defaultValue:"create",type:"text"},recordId:{label:"Record Id",defaultValue:"",type:"text"}}}},content:{attributes:{query:"",method:"get",accessToken:"",mockData:"{}",subType:"",credentials:"same-origin",connector:"",resource:"",limit:"10",singleRecord:!1,filters:[],pagination:"none",pageParam:"page",renderWhileLoading:!1,cache:!1,staleTime:30,gcTime:300},definition:{label:"Api Container",type:"apiContainer",description:'Fetches data from a backend HTTP API (its `query`/`method`/`credentials`) and exposes the response as a data source ITS DESCENDANTS bind to (source `apiContainer_<id>.data`; only elements inside it can consume it). This is how you get backend data into the frontend. Its `mockData` prop is builder-only sample data — the published runtime fetches the real `query`, so always set a real query for production. With `cache: true` a browser request is kept for `staleTime` seconds (default 30) and shared with every provider asking the same thing; it is off unless set. A flow refreshes it with `performQuery` or the global `invalidateQueries` step, and `refreshSeconds` makes it ask again on its own every N seconds (either runtime; paused while the tab is hidden) — the way to keep a queue, feed or status board current without a plugin. Its `subType` (container tag) is empty by default, and then it renders NO element of its own: its children lay out directly in its parent, and any class, variant or style binding on it applies to nothing. To style the provider itself give it a tag (`subType: "div"`, `section`, …); otherwise style its parent or a child.',items:[],bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!0,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"provider",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"fa-solid fa-server"},defaultStyle:{name:"Api Container",displayMode:"desktop",style:{base:{default:{}}},subTypes:{}},settings:{}}},hT=()=>{let{id:e,rootId:t}=Du(),[[n=!1,r=!1,a=!1,i,o,s,l]]=Et(["rsc.enabled","rsc.loaded","rsc.stale","rsc.location",Nc(e),"navigation.currentPageId","schema.pages"]),c=Pc(),u=void 0!==i&&i!==Oc()||void 0!==t&&t!==s&&Array.isArray(l)&&l.includes(t),d=x(void 0);!u&&void 0!==o&&(d.current=o);let p=u&&void 0!==d.current?d.current:o;return{enabled:n,loaded:r,stale:a,location:i,elementData:p??null,isServerElement:void 0!==p,refresh:c}},mT=(e,t,n)=>n?void 0===e.record:Array.isArray(e.records)?0===t.length:(e=>null==e||""===e||Array.isArray(e)&&0===e.length||"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length)(e.data),gT=3e5,yT=e=>{let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let a=e.charCodeAt(r);t=Math.imul(t^a,2654435761),n=Math.imul(n^a,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)},bT=e=>`entries.${yT(e)}`,vT=new class{store;runtimes=/* @__PURE__ */new Map;epochValue=0;unwatch;constructor(e=Be({entries:{}},{id:"queries"})){this.store=e}get epoch(){return this.epochValue}getEntry(e){let t=this.store.getPath(bT(e));return t?.key===e?t:void 0}hasAnswer(e){return void 0!==this.getEntry(e)&&void 0!==this.store.getFreshness(bT(e))}usage(e){let t=this.runtimes.get(yT(e));return t&&{observers:t.observers.size,holds:t.holds,collectAt:t.collectAt}}remove(e){let t=this.runtimes.get(yT(e));return!(!t||t.observers.size>0||t.holds>0||(this.cancelGc(t),this.collect(t),0))}hold(e,t=gT){let n=this.ensure(e);return n.gcTime=t,n.holds++,this.cancelGc(n),()=>{n.holds--,this.scheduleGc(n)}}observe(e,t){let n=this.ensure(e),{isCacheable:r}=t,a={meta:t.meta,staleTime:t.staleTime,fetcher:t.fetcher,isCacheable:r&&(e=>r(e))};return n.observers.add(a),this.cancelGc(n),(!this.hasAnswer(e)||this.store.isStale(bT(e)))&&this.fetch(n,a),()=>{n.observers.delete(a),this.scheduleGc(n)}}async fetchQuery(e,t){let n=this.ensure(e);if(void 0!==t.gcTime&&(n.gcTime=t.gcTime),this.hasAnswer(e)&&!this.store.isStale(bT(e)))return this.scheduleGc(n),this.getEntry(e)?.data;let{isCacheable:r}=t;await this.fetch(n,{meta:t.meta,staleTime:t.staleTime,fetcher:t.fetcher,isCacheable:r&&(e=>r(e))});let a=this.getEntry(e)?.data;return this.scheduleGc(n),a}refetch(e){let t=this.runtimes.get(yT(e));return t?this.invalidateOne(t):Promise.resolve()}invalidate(e){let t=[];return this.runtimes.forEach(n=>{let r=this.getEntry(n.key);!r||e&&!e({url:r.url,tags:r.tags})||t.push(this.invalidateOne(n))}),Promise.all(t).then(()=>{})}reset({refetch:e=!0}={}){if(this.epochValue++,this.runtimes.forEach(e=>{e.version++,e.inFlight=void 0,e.controller?.abort(),e.controller=void 0}),this.store.setState("entries",{}),!e)return this.runtimes.forEach(e=>this.markUnasked(e)),Promise.resolve();let t=[];return this.runtimes.forEach(e=>t.push(this.fetchActive(e))),Promise.all(t).then(()=>{})}markUnasked(e){let t=e.observers.values().next();if(t.done)return;let n={key:e.key,url:t.value.meta.url,tags:[...e.tags],isFetching:!1};this.store.setState(bT(e.key),n,{ttl:0})}invalidateOne(e){return 0===this.store.expire(bT(e.key)).length&&e.version++,this.fetchActive(e)}onExpired(e){let t=this.runtimes.get(e.slice(8).split(".")[0]);t&&(t.version++,this.fetchActive(t))}fetchActive(e){let t=e.observers.values().next();return t.done?Promise.resolve():this.fetch(e,t.value)}fetch(e,t){if(e.inFlight)return e.inFlight;let{key:n}=e,{url:r}=t.meta;t.meta.tags?.forEach(t=>e.tags.add(t));let a=[...e.tags],i=bT(n);this.getEntry(n)?this.store.setState(`${i}.isFetching`,!0):this.store.setState(i,{key:n,url:r,tags:a,isFetching:!0});let o=this.epochValue,s=e.version,l=l=>{if(o!==this.epochValue||this.runtimes.get(yT(n))!==e)return Promise.resolve();e.inFlight=void 0,e.controller=void 0;let c=s!==e.version;if("error"in l){let e=this.getEntry(n);this.store.setState(i,{key:n,url:r,tags:a,data:e?.data,error:l.error,isFetching:!1},{ttl:0})}else{let o=!c&&(t.isCacheable?.(l.data)??!0);this.store.setState(i,{key:n,url:r,tags:a,data:l.data,isFetching:!1},{ttl:o?this.ttlOf(e,t):0})}return c?this.fetchActive(e):Promise.resolve()},c=new AbortController;return e.controller=c,e.inFlight=t.fetcher(c.signal).then(e=>l({data:e}),e=>l({error:e})),e.inFlight}ttlOf(e,t){let n=e.observers.size>0?1/0:t.staleTime;return e.observers.forEach(e=>{n=Math.min(n,e.staleTime)}),n}ensure(e){let t=yT(e),n=this.runtimes.get(t);return n||(n={key:e,tags:/* @__PURE__ */new Set,observers:/* @__PURE__ */new Set,holds:0,version:0,gcTime:3e5},this.runtimes.set(t,n)),this.unwatch??=this.store.watchFreshness("entries",e=>{"expired"===e.type&&this.onExpired(e.path)}),n}cancelGc(e){clearTimeout(e.gcTimer),e.gcTimer=void 0,e.collectAt=void 0}scheduleGc(e){if(!(e.holds>0||e.observers.size>0)){if(this.cancelGc(e),e.gcTime<=0)return void this.collect(e);e.collectAt=Date.now()+e.gcTime,e.gcTimer=setTimeout(()=>this.collect(e),e.gcTime)}}collect(e){let t=yT(e.key);this.runtimes.get(t)===e&&0===e.holds&&0===e.observers.size&&(this.runtimes.delete(t),e.controller?.abort(),this.store.setState(bT(e.key),void 0,{unmount:!0}))}},{useStore:wT}=Ct(),kT=()=>typeof location>"u"?void 0:location.href,xT=e=>{try{return new URL(e,kT()).origin}catch{return}},ST=e=>Array.isArray(e)?e.filter(e=>"string"==typeof e&&""!==e.trim()).map(e=>e.trim()):"string"==typeof e?e.split(",").map(e=>e.trim()).filter(Boolean):[],TT=e=>{try{return new URL(e,kT()).href}catch{return e}},CT=(e={})=>e.url||e.elements?.length?vT.invalidate((({url:e,elements:t})=>{let n=e?TT(e):void 0;return e=>(void 0===n||TT(e.url).startsWith(n))&&(!t?.length||t.some(t=>e.tags?.includes(t)??!1))})(e)):vT.invalidate(),AT=({method:e,url:t,credentials:n,headers:r})=>JSON.stringify([e.toLowerCase(),t,n,Object.entries(r).filter(([e])=>"content-type"!==e.toLowerCase()).sort(([e],[t])=>e<t?-1:+(e>t))]),ET=({mode:e,fallback:t,elements:n,url:r})=>{let a="origin"===e||"all"===e||"elements"===e||"none"===e?e:t;if("none"===a)return Promise.resolve();if("elements"===a){let e=ST(n);return e.length>0?CT({elements:e}):Promise.resolve()}return"origin"===a&&r?(e=>{let t=xT(e);return t?vT.invalidate(e=>xT(e.url)===t):Promise.resolve()})(r):CT()},IT=e=>e.status<400,_T=(e,t)=>{let n="number"==typeof e?e:Number(e);return 1e3*(Number.isFinite(n)&&n>=0?n:t)},NT=e=>Or(e).map(e=>({path:e,name:e.split(".").slice(-2).join(" ")})),OT=Lu(({ref:e,className:t="",children:n,query:r="",method:a="get",accessToken:i="",when:o=Nr,headers:s=Nr,mockData:l="{}",subType:c="",credentials:u="same-origin",singleRecord:d=!1,pagination:p="none",pageParam:m="page",renderWhileLoading:y=!1,cache:v=!1,staleTime:w=30,gcTime:T=300,refreshSeconds:C=0})=>{let{id:A,visible:E,definition:{label:_="Api Container",runtime:N,items:O}}=Du(),M="server"===N,{loaded:P,stale:L,location:D,elementData:z,refresh:R}=hT(),j=El(fT.sourceType,A),{settings:{previewMode:$},contexts:{InteractionsContext:F}}=zl(),{interactionsManager:q}=f(F),[[B,H,W]]=Ot(["navigation.routeParams","navigation.queryParams","navigation.navigate"]),V=k(()=>i?{...s,Authorization:`Bearer ${i}`}:s,[s,i]),G=k(()=>!(M||!E||!($&&r&&(o===Nr||wi(o,{...B,...H}))||!$&&(r||l&&"{}"!==l&&l!==Nr))),[M,E,$,r,o,B,H,l]),Y=k(()=>[A],[A]),{isLoading:K,isFetching:J,data:X,refetch:Z,isSuccess:Q,isError:ee}=(({url:e="",method:t="get",mock:n,customHeaders:r=Nr,enabled:a=!0,credentials:i="same-origin",cache:o=!1,staleTime:s=30,gcTime:l=300,tags:c})=>{let u=(e=>!!e&&"{}"!==e&&e!==Nr)(n),d=b(),p=!u&&(!e||Bn(e)),f=k(()=>{if(u||p)return;let n=AT({method:t,url:e,credentials:i,headers:r});return o?n:`${n}#${d}`},[u,p,e,t,i,r,o,d]),m=h(n=>(async(e,t,n,r,a)=>{if(!e)return{status:400,data:"URL is required"};let i=new Headers(r);i.has("Accept")||i.set("Accept","application/json");let o={method:t,credentials:n,headers:i,signal:a};"get"!==t&&(o.body="{}",i.has("Content-Type")||i.set("Content-Type","application/json"));try{let t=await fetch(e,o),n=await t.json(),r=Hr(t.status,n);return r&&Br({reason:r,url:e}),{status:t.status,data:n}}catch(e){if(a.aborted)throw e;return{status:500,data:e.message}}})(e,t,i,r,n),[e,t,i,r]),y=(({key:e,meta:t,fetcher:n,enabled:r=!0,staleTime:a,gcTime:i=gT,isCacheable:o})=>{let s=void 0!==e,[l]=wT(bT(e??""),{store:vT.store,enabled:s}),c=s&&l?.key===e?l:void 0,u=void 0!==c&&vT.hasAnswer(c.key),d=x(n),p=x(o);g(()=>{d.current=n,p.current=o},[n,o]),g(()=>void 0===e?void 0:vT.hold(e,i),[e,i]);let{url:f}=t,m=t.tags?.join("\0")??"";g(()=>{if(r&&void 0!==e)return vT.observe(e,{meta:{url:f,tags:m?m.split("\0"):[]},staleTime:a,fetcher:e=>d.current(e),isCacheable:e=>p.current?.(e)??!0})},[r,e,f,m,a]);let y=u?c.data:void 0,b=x(void 0);void 0===y?b.current&&b.current.epoch!==vT.epoch&&(b.current=void 0):b.current={epoch:vT.epoch,data:y};let v=y??b.current?.data,w=(c?.isFetching??!1)||r&&s&&!u;return{data:v,isFetching:w,isLoading:w&&void 0===v,refetch:h(()=>{r&&void 0!==e&&vT.refetch(e)},[r,e])}})({key:f,meta:{url:e,tags:c},fetcher:m,enabled:a,staleTime:o?_T(s,30):0,gcTime:o?_T(l,300):0,isCacheable:IT}),v=k(()=>u?(e=>{if("string"!=typeof e)return{status:200,data:e};try{return{status:200,data:JSON.parse(e)}}catch(e){return{status:500,data:e.message}}})(n):void 0,[u,n]),w=a&&v?v:y.data,S=!v&&y.isFetching;return{isLoading:S&&void 0===w,isFetching:S,data:w,refetch:y.refetch,isSuccess:!p&&!S&&!!w&&w.status<400,isError:!p&&!S&&!!w&&w.status>=400}})({url:r,method:a,credentials:u,mock:$?void 0:l,customHeaders:V,enabled:G,cache:v,staleTime:w,gcTime:T,tags:Y}),te=M&&!!D&&D!==Oc(),ne=M&&P&&!te&&null===z,re=k(()=>{if(!M)return X??Nr;if(z)return z;if(P)return Nr;if("string"!=typeof l)return l;try{return JSON.parse(l||"{}")}catch{return Nr}},[M,X,z,P,l]),ae=M?te:J,ie=M?te:K,oe=x({}),se=h((e,t)=>R(e,{...oe.current,...t}),[R]),le=h(async()=>{M?await se([A]):Z()},[M,Z,se,A]),ce=h(async({input:e}={})=>{let t=(e=>{let t=e;if("string"==typeof t)try{t=JSON.parse(t||"{}")}catch{return}if("object"==typeof t&&t&&!Array.isArray(t))return Object.fromEntries(Object.entries(t).flatMap(([e,t])=>"string"==typeof t||"number"==typeof t||"boolean"==typeof t?[[e,String(t)]]:[]))})(e);t&&(oe.current=t),await le()},[le]);(({seconds:e,enabled:t,refresh:n})=>{let r=x(n);r.current=n;let a=Number(e),i=t&&Number.isFinite(a)&&a>0;g(()=>{if(!i)return;let e=!1,t=setInterval(()=>{e||"hidden"===document.visibilityState||(e=!0,Promise.resolve().then(()=>r.current()).catch(()=>{}).finally(()=>{e=!1}))},1e3*a);return()=>clearInterval(t)},[i,a])})({seconds:C,enabled:E&&(M?P&&!te:G),refresh:le});let ue=re,de=k(()=>Array.isArray(ue.records)?ue.records:[],[ue.records]),{records:pe,isLoadingMore:fe,goToPage:he,loadMore:me}=(({elementId:e,mode:t,pageParam:n,records:r,page:a,refresh:i,navigate:o})=>{let[s,l]=S(r),[c,u]=S(!1),d=x(0);g(()=>{if("append"===t){if(a<=1)return d.current=1,void l(r);d.current!==a&&(d.current=a,l(e=>[...e,...r]))}},[t,a,r]);let p=h(async r=>{let a=Math.max(r,1);if("url"!==t){if(i){u(!0);try{await i([e],{[n]:String(a)})}finally{u(!1)}}}else o?.(((e,t)=>{if(typeof window>"u")return"";let n=new URL(window.location.href);return t<=1?n.searchParams.delete(e):n.searchParams.set(e,String(t)),`${n.pathname}${n.search}`})(n,a))},[t,o,n,i,e]),f=h(()=>p(a+1),[p,a]);return{records:"append"===t?s:r,isLoadingMore:c,goToPage:p,loadMore:f}})({elementId:A,mode:p,pageParam:m,records:de,page:ue.pageInfo?.page??1,refresh:se,navigate:W}),ge=(({serverMode:e,isSuccess:t,isError:n,rscResolved:r,rscPending:a,elementData:i})=>e?r&&!a?null==i?"error":"success":void 0:t?"success":n?"error":void 0)({serverMode:M,isSuccess:Q,isError:ee,rscResolved:P,rscPending:te,elementData:z});g(()=>{!ae&&A&&ge&&q.interactionTrigger(A,"success"===ge?"onApiSuccess":"onApiError",{url:r,method:a,...re})},[re,A,q,ae,a,ge,r]);let ye=k(()=>({...re,...Array.isArray(ue.records)?{records:pe}:Nr,isLoading:ae||fe,isEmpty:mT(ue,pe,d),hasError:ne,errorMessage:ne?"The data provider could not be reached":"",isStale:M&&L}),[re,ue.records,ue.record,pe,ae,fe,d,ne,M,L]),be=h(()=>NT(ye),[ye]);Il({id:A,source:j,name:_||`API - ${A}`,fields:be});let{writeRecord:ve}=(({elementId:e,enabled:t,actionPath:n="/_action",onDone:r})=>({writeRecord:h(async(a={})=>{let{action:i,recordId:o,...s}=a;if(!t||"string"!=typeof i||!i)return;let l=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({elementId:e,action:i,recordId:o,values:s})});if(!l.ok){let e=Hr(l.status,await l.json().catch(()=>{}));throw e&&Br({reason:e,url:n}),Error(`Write failed with status ${l.status}`)}let c=await l.json();return CT(),await(r?.()),c.record},[n,e,t,r])}))({elementId:A,enabled:M,onDone:le}),we=k(()=>{let e={performQuery:{...fT.callbacks.performQuery,title:`Perform Query ${_}`,callback:ce},loadMore:{...fT.callbacks.loadMore,title:`Load More ${_}`,callback:me},goToPage:{...fT.callbacks.goToPage,title:`Go To Page ${_}`,callback:({page:e})=>he(Number(e)||1)}};return M&&(e.writeRecord={...fT.callbacks.writeRecord,title:`Write Record ${_}`,callback:ve}),e},[_,ce,me,he,M,ve]),ke=k(()=>j?{runtime:{sources:{[j]:ye}}}:Nr,[ye,j]);/* @__PURE__ */
94
94
  return I(sd,{ref:e,tag:$||O?.length?c:"div",className:U("plitzi-component__api-container",t),interactionTriggers:fT.triggers,interactionCallbacks:we,children:(!ie||y)&&/* @__PURE__ */I(kt,{inherit:"live",name:`Api:${A}`,value:ke,children:n})})}),MT=Object.assign(OT,fT),PT={type:"channel",attributeValues:{subType:["","div","section","aside","main"]},sourceType:"channel",triggers:{onMessage:{action:"onMessage",title:"On Message",type:"trigger",params:{},preview:{type:"",data:"",from:"",user:"",at:""}},onJoin:{action:"onJoin",title:"On Join",type:"trigger",params:{},preview:{from:"",user:"",state:{}}},onLeave:{action:"onLeave",title:"On Leave",type:"trigger",params:{},preview:{from:"",user:"",state:{}}}},callbacks:{publish:{action:"publish",title:"Publish",type:"callback",preview:{},params:{type:{label:"Type",defaultValue:"",type:"text"},data:{label:"Data (JSON or a template)",defaultValue:"",type:"text"}}},setPresence:{action:"setPresence",title:"Set Presence",type:"callback",preview:{},params:{data:{label:"State (JSON or a template)",defaultValue:"",type:"text"}}}},content:{attributes:{topic:"",grant:"",keep:20,subType:""},definition:{label:"Channel",type:"channel",description:"A realtime channel: every page on the same `topic` hears what any of them publishes, within milliseconds. The topic must match a channel the space declares in its settings (`channels`), e.g. `board:{{ id }}` under `board:{id}`. A topic of a private channel (`grant: true`) opens only with `grant`, bound to the grant the action that let this visitor in returned (its `realtime.grant` step). ITS DESCENDANTS bind to its source `channel_<id>`: `connected`, `members` (with the state each announced), `messages` (the last `keep`) and `last`. It fires `onMessage`; `onJoin` when somebody who came after this page has announced who they are, and `onLeave` when somebody goes — each with `from`, `user` and the `state` they announced; and answers `publish({ type, data })` and `setPresence({ data })`; `presence` is the state this page announces (a name, a colour). Closed in the builder and anywhere without a server.",items:[],bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!0,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"provider",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"fa-solid fa-tower-broadcast"},defaultStyle:{name:"Channel",displayMode:"desktop",style:{base:{default:{}}},subTypes:{}},settings:{}}},LT=[500,1e3,2e3,5e3,1e4],DT=e=>"object"==typeof e&&!!e&&"connection"in e&&"string"==typeof e.connection&&"refused"in e&&Array.isArray(e.refused),zT=e=>"object"==typeof e&&!!e&&"topic"in e&&"string"==typeof e.topic&&"type"in e&&"string"==typeof e.type,RT=e=>{let t="message",n=[];for(let r of e.split("\n"))r.startsWith("event: ")?t=r.slice(7):r.startsWith("data: ")&&n.push(r.slice(6));if(n.length)try{return{event:t,data:JSON.parse(n.join("\n"))}}catch{return}},jT=/* @__PURE__ */new Map,$T=/* @__PURE__ */new WeakMap,FT=(e,{grant:t,presence:n,onMessage:r,onJoin:a,onLeave:i}={})=>{let[o]=Et("realtime.endpoint"),[s]=Et("realtime.transport"),l=k(()=>o&&typeof window<"u"?((e,t="sse")=>{let n=`${t} ${e}`,r=jT.get(n);if(r)return r;let a=((e,{transport:t="sse",fetchImpl:n=fetch,WebSocketImpl:r=globalThis.WebSocket}={})=>{let a,i,o,s=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map,c=/* @__PURE__ */new Set,u="idle",d=/* @__PURE__ */new Map,p=0,f="websocket"===t&&"function"==typeof r,h=e=>{u=e,c.forEach(t=>t(e))},m=()=>[...s.keys()].sort().join(","),g=e=>{"$revoked"===e.type&&"server"===e.from&&d.set(e.topic,"revoked"),s.get(e.topic)?.forEach(t=>t(e))},y=(e,t)=>{e.me=t.connection,d=new Map(t.refused.map(e=>[e.topic,e.reason])),p=0,h("open")},b=e=>{if(a!==e)return;h("connecting");let t=LT[Math.min(p,LT.length-1)];p+=1,o=setTimeout(k,t)},v=(t,r)=>{let i,o=new AbortController,s={topics:t,transport:"sse",close:()=>o.abort(),publish:async(t,r,o)=>{if(!i)return!1;let l=await n(e,{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify({token:i,topic:t,type:r,data:o})}).catch(()=>{});return 401===l?.status&&a===s&&k(),l?.ok??!1}};return n(`${e}?${r}`,{headers:{accept:"text/event-stream"},credentials:"same-origin",signal:o.signal}).then(async e=>{if(!e.ok)return d=new Map(t.split(",").map(t=>[t,`http_${e.status}`])),void h("closed");throw await(async e=>{let t=e.body?.getReader();if(!t)return;let n=new TextDecoder,r="";for(;;){let{done:e,value:a}=await t.read();if(e)return;r+=n.decode(a,{stream:!0});let o=r.indexOf("\n\n");for(;-1!==o;){let e=RT(r.slice(0,o));r=r.slice(o+2),o=r.indexOf("\n\n"),"ready"===e?.event&&DT(e.data)?(i=e.data.token,y(s,e.data)):"message"===e?.event&&zT(e.data)&&g(e.data)}}})(e),Error("The realtime stream ended")}).catch(()=>{o.signal.aborted||b(s)}),s},w=(t,n)=>{let i=new r(((e,t)=>{let n=new URL(`${e}?${t}`,globalThis.location.href);return n.protocol="https:"===n.protocol?"wss:":"ws:",n.href})(e,n)),o=/* @__PURE__ */new Map,s=0,l=!1,c=!1,u=()=>{o.forEach(e=>e(!1)),o.clear()},d={topics:t,transport:"websocket",close:()=>{c=!0,u(),i.close()},publish:(e,t,n)=>new Promise(r=>{if(i.readyState!==i.OPEN)return void r(!1);s+=1;let a=s,l=setTimeout(()=>{o.delete(a),r(!1)},5e3);o.set(a,e=>{clearTimeout(l),r(e)}),i.send(JSON.stringify({id:a,topic:e,type:t,data:n}))})};return i.onmessage=e=>{let t=(e=>{try{let t=JSON.parse(String(e));return"object"==typeof t&&t&&"event"in t&&"string"==typeof t.event?{event:t.event,data:"data"in t?t.data:void 0}:void 0}catch{return}})(e.data);"ready"===t?.event&&DT(t.data)?(l=!0,y(d,t.data)):"message"===t?.event&&zT(t.data)?g(t.data):"ack"===t?.event&&(e=>"object"==typeof e&&!!e&&"id"in e&&"number"==typeof e.id&&"ok"in e&&"boolean"==typeof e.ok)(t.data)&&(o.get(t.data.id)?.(t.data.ok),o.delete(t.data.id))},i.onclose=()=>{if(u(),!c&&a===d){if(!l)return f=!1,void k();b(d)}},d};function k(){a?.close(),a=void 0;let e=m();if(!e)return void h("idle");h("connecting");let t=(e=>{let t=e.split(",").flatMap(e=>l.get(e)??[]);return`topics=${encodeURIComponent(e)}${t.length?`&grants=${encodeURIComponent(t.join(","))}`:""}`})(e);a=f?w(e,t):v(e,t)}let x=(e=!1)=>{clearTimeout(i),clearTimeout(o),i=setTimeout(()=>{(e||a?.topics!==m())&&k()},30)},S=e=>"open"===u&&!0===a?.topics.split(",").includes(e),T={subscribe:(e,t)=>{let n=s.get(e)??/* @__PURE__ */new Set;return n.add(t),s.set(e,n),x(),()=>{n.delete(t),n.size||(s.delete(e),l.delete(e),x())}},grant:(e,t)=>{if(l.get(e)===t)return;t?l.set(e,t):l.delete(e);let n=S(e)&&!d.has(e);t&&s.has(e)&&!n&&x(!0)},publish:async(e,t,n)=>!(!(await(e=>S(e)?Promise.resolve(!0):new Promise(t=>{let n=setTimeout(()=>{r(),t(!1)},5e3),r=T.onStatus(a=>{("closed"===a||S(e))&&(clearTimeout(n),r(),t("closed"!==a))})}))(e))||!a)&&a.publish(e,t,n),onStatus:e=>(c.add(e),()=>c.delete(e)),get status(){return u},get me(){return a?.me},get transport(){return a?.transport??(f?"websocket":"sse")},refusal:e=>d.get(e)};return T})(e,{transport:t});return jT.set(n,a),a})(o,s):void 0,[o,s]),[c,u]=S(!1),[d,p]=S([]),f=x(void 0),m=x({onMessage:r,onJoin:a,onLeave:i});g(()=>{m.current={onMessage:r,onJoin:a,onLeave:i}}),g(()=>{l&&e&&t&&l.grant(e,t)},[l,e,t]),g(()=>{if(!l||!e)return;let t=((e,t,n)=>{let r=$T.get(e)??/* @__PURE__ */new Map;$T.set(e,r);let a=r.get(t)??((e,t,n)=>{let r,a=/* @__PURE__ */new Map,i=/* @__PURE__ */new Set,o=/* @__PURE__ */new Set,s=!1,l=()=>[...s&&e.me?[{from:e.me,state:r,me:!0}]:[],...[...a.values()].map(e=>e.member)],c=()=>{let e=l();o.forEach(t=>t.onChange(e))},u=e=>{let t=e.flatMap(e=>{let t=a.get(e);return a.delete(e),t?[t.member]:[]});if(t.length){c();for(let e of t)o.forEach(t=>t.onDepart?.(e))}},d=()=>{s&&e.publish(t,"$presence",r)},p=e.subscribe(t,t=>{if(t.from!==e.me){if("$presence"===t.type){let e={from:t.from,...t.user?{user:t.user}:{},state:t.data,me:!1},n=!a.has(t.from)&&i.delete(t.from);a.set(t.from,{member:e,heardAt:Date.now()}),c(),n&&o.forEach(t=>t.onArrive?.(e))}else"$leave"===t.type?(i.delete(t.from),u([t.from])):"$join"===t.type?(i.add(t.from),d()):"$revoked"===t.type&&"server"===t.from&&(a.clear(),i.clear(),c());o.forEach(e=>e.onMessage?.(t))}}),f=e.onStatus(e=>{"open"===e&&(d(),c())}),h=setInterval(()=>{d();let e=Date.now();u([...a].filter(([,t])=>e-t.heardAt>65e3).map(([e])=>e))},2e4);return{members:l,set:e=>{r=e,s=!0,d(),c()},listeners:o,teardown:()=>{clearInterval(h),f(),p(),n()}}})(e,t,()=>r.delete(t));r.set(t,a),a.listeners.add(n);let i=a.members();return i.length&&n.onChange(i),{set:a.set,members:a.members,stop:()=>{a.listeners.delete(n)&&!a.listeners.size&&a.teardown()}}})(l,e,{onChange:p,onMessage:e=>{"$revoked"===e.type&&"server"===e.from&&u(!1),m.current.onMessage?.(e)},onArrive:e=>m.current.onJoin?.(e),onDepart:e=>m.current.onLeave?.(e)});f.current=t,u("open"===l.status&&!l.refusal(e));let n=l.onStatus(t=>u("open"===t&&!l.refusal(e)));return()=>{n(),t.stop(),f.current=void 0,p([]),u(!1)}},[l,e]);let y=void 0===n?void 0:JSON.stringify(n);g(()=>{void 0!==y&&f.current?.set(JSON.parse(y))},[y,l,e]);let b=h((t,n)=>l&&e?l.publish(e,t,n):Promise.resolve(!1),[l,e]),v=h(e=>f.current?.set(e),[]);return{connected:c,me:c?l?.me:void 0,members:d,publish:b,setPresence:v}},qT=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}},BT=/* @__PURE__ */new Set(["$presence","$join","$leave"]),UT=Lu(({ref:e,className:t,children:n,topic:r="",grant:a="",presence:i,keep:o=20,subType:s=""})=>{let{id:l,definition:{label:c="Channel"}}=Du(),{settings:{previewMode:u},contexts:{InteractionsContext:d}}=zl(),{interactionsManager:p}=f(d),m=Math.max(0,Number(o)||0),[g,y]=S([]),b=h(e=>{BT.has(e.type)||(m>0&&y(t=>[...t,e].slice(-m)),p.interactionTrigger(l,"onMessage",{...e}))},[l,p,m]),v=h(({from:e,user:t,state:n})=>{p.interactionTrigger(l,"onJoin",{from:e,user:t??"",state:n})},[l,p]),w=h(({from:e,user:t,state:n})=>{p.interactionTrigger(l,"onLeave",{from:e,user:t??"",state:n})},[l,p]),x=FT(u&&r?r:void 0,{grant:a||void 0,presence:void 0===i||""===i?void 0:qT(i),onMessage:b,onJoin:v,onLeave:w}),T=k(()=>({publish:{...PT.callbacks.publish,callback:({type:e,data:t})=>"string"==typeof e&&e?x.publish(e,qT(t)):Promise.resolve(!1)},setPresence:{...PT.callbacks.setPresence,callback:({data:e})=>x.setPresence(qT(e))}}),[x]),C=El(PT.sourceType,l),A=k(()=>({connected:x.connected,me:x.me??"",members:x.members,messages:g,last:g.at(-1)??null}),[x.connected,x.me,x.members,g]),E=h(()=>NT(A),[A]);Il({id:l,source:C,name:c||`Channel - ${l}`,fields:E});let _=k(()=>C?{runtime:{sources:{[C]:A}}}:Nr,[A,C]);/* @__PURE__ */
95
95
  return I(sd,{ref:e,tag:s,className:U("plitzi-component__channel",t),interactionTriggers:PT.triggers,interactionCallbacks:T,children:/* @__PURE__ */I(kt,{inherit:"live",name:`Channel:${l}`,value:_,children:n})})}),HT=Object.assign(UT,PT),WT=["div","header","footer","nav","main","section","article","aside","figure"],VT=Lu(({ref:e,className:t="",subType:n="div",label:r="",decorative:a=!1,children:i})=>{let o=!a&&r&&WT.includes(n)?{"aria-label":r,..."div"===n?{role:"group"}:{}}:{},s=a?{"aria-hidden":!0}:{};/* @__PURE__ */
96
96
  return I(sd,{ref:e,tag:n,className:U(`plitzi-component__container plitzi-component__container-${n}`,t),...o,...s,children:i})}),GT=Object.assign(VT,{type:"container",attributeValues:{subType:["div","header","footer","nav","main","section","article","aside","address","figure","dl","dt","dd","li","h1","h2","h3","h4","h5","h6"]},content:{attributes:{subType:"div"},definition:{label:"Container",type:"container",description:"Generic layout box (a div). The primary building block for structure: groups and positions child elements with flex/grid. Reach for it whenever you need to wrap or arrange other elements.",items:[],bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!0,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"structure",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"fa-regular fa-square"},defaultStyle:{name:"Container",displayMode:"desktop",style:{base:{default:{}}},subTypes:{}},settings:{}}}),YT={type:"dialogContainer",sourceType:"dialogContainer",triggers:{onDialogAccept:{action:"onDialogAccept",title:"On Dialog Accept",type:"trigger",params:{metadata:{type:"text",defaultValue:""}},preview:{metadata:""}},onDialogReject:{action:"onDialogReject",title:"On Dialog Reject",type:"trigger",params:{metadata:{type:"text",defaultValue:""}},preview:{metadata:""}},onDialogOpen:{action:"onDialogOpen",title:"On Dialog Open",type:"trigger",params:{metadata:{type:"text",defaultValue:""}},preview:{metadata:""}},onDialogClose:{action:"onDialogClose",title:"On Dialog Close",type:"trigger",params:{metadata:{type:"text",defaultValue:""}},preview:{metadata:""}}},callbacks:{openDialog:{action:"openDialog",title:"Open Dialog",type:"callback",params:{metadata:{type:"text",defaultValue:""}},preview:{metadata:""}},closeDialog:{action:"closeDialog",title:"Close Dialog",type:"callback",preview:{},params:{}}},content:{attributes:{headerLabel:"Dialog Header",acceptButtonLabel:"Accept",rejectButtonLabel:"Cancel",autoHideAfterClick:!0},definition:{label:"Dialog Container",type:"dialogContainer",description:"A native <dialog> container shown or hidden through interactions (e.g. an onClick open/close).",items:[],bindings:{},loadStrategy:"lazy",styleSelectors:{base:"",backgroundContainer:"",rootContainer:"",headerContainer:"",headerTitle:"",headerCloseButton:"",bodyContainer:"",footerContainer:"",acceptButton:"",cancelButton:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!0,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"structure",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:"fa-regular fa-clone"},defaultStyle:{name:"Dialog Container",displayMode:"desktop",style:{base:{default:{position:"absolute",top:"0",bottom:"0",left:"0",right:"0"}},backgroundContainer:{default:{height:"100%",width:"100%",left:"0",top:"0",position:"absolute","background-color":"black",opacity:"0.5"}},rootContainer:{default:{display:"flex","flex-direction":"column",position:"absolute",top:"50%",left:"50%",width:"500px",height:"300px","background-color":"light-dark(white, oklch(0.21 0.006 285.885))",transform:"translate3d(-50%, -50%, 0px)","padding-top":"20px","padding-bottom":"20px","padding-left":"20px","padding-right":"20px","border-top-left-radius":"8px","border-top-right-radius":"8px","border-bottom-left-radius":"8px","border-bottom-right-radius":"8px"}},headerContainer:{default:{display:"flex","align-items":"center","justify-content":"space-between"}},headerTitle:{default:{"font-size":"20px","font-weight":"500","line-height":"1.2",color:"#333"}},headerCloseButton:{default:{height:"20px",width:"20px",padding:"4px",display:"flex","justify-content":"center","align-items":"center",cursor:"pointer"}},bodyContainer:{default:{display:"flex","flex-direction":"column","flex-grow":"1","flex-basis":"0"}},footerContainer:{default:{display:"flex","justify-content":"flex-end","margin-top":"8px"}}},subTypes:{}},settings:{}},initialItems:["container"]},KT=({panelRef:e,open:t,onClose:n})=>{let r=y(n);g(()=>{let n=e.current;if(!t||!n)return;let a=n.ownerDocument.activeElement;n.contains(a)||n.focus({preventScroll:!0});let i=e=>{if(e.defaultPrevented)return;if("Escape"===e.key)return e.preventDefault(),void r();if("Tab"!==e.key)return;let t=(e=>[...e.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), [contenteditable="true"]')].filter(e=>"function"!=typeof e.checkVisibility||e.checkVisibility()))(n);if(0===t.length)return e.preventDefault(),void n.focus({preventScroll:!0});let a=t[0],i=t[t.length-1],o=n.ownerDocument.activeElement;!e.shiftKey||o!==a&&o!==n&&n.contains(o)?!e.shiftKey&&(o===i||!n.contains(o))&&(e.preventDefault(),a.focus()):(e.preventDefault(),i.focus())},o=n.ownerDocument.defaultView;return o?.addEventListener("keydown",i),()=>{o?.removeEventListener("keydown",i),a instanceof HTMLElement&&a.isConnected&&a.focus({preventScroll:!0})}},[t,e])},JT=Lu(({ref:e,className:t="",children:n,headerLabel:r="Dialog Header",acceptButtonLabel:a="Accept",acceptButtonLabelLoading:i="Loading...",rejectButtonLabel:o="Cancel",autoHideAfterClick:s=!0})=>{let{id:l,rootId:c,visible:u,setElementState:d,definition:{styleSelectors:p,label:m="Dialog"},elementState:y}=Du(),b=El(YT.sourceType,l),{settings:{previewMode:v},contexts:{InteractionsContext:w}}=zl(),{interactionsManager:T}=f(w),[C,A]=S({}),[E,N]=S(!1),O=x(null),M=`${c}_${l}_title`,P=h(e=>{let{metadata:t}=e;if(t&&"object"==typeof t)A(t);else if("string"==typeof t)try{A(JSON.parse(t))}catch{A({content:t})}else A("boolean"==typeof t||"number"==typeof t?{content:t}:{});d(e=>({...e,visibility:!0}))},[d,A]),L=h(()=>{T.interactionTrigger(l,"onDialogClose",{metadata:C}),A({}),d(e=>({...e,visibility:!1}))},[T,d,A,C,l]),D=h(()=>{s&&(T.interactionTrigger(l,"onDialogClose",{metadata:C}),A({}),d(e=>({...e,visibility:!1})))},[T,s,d,A,C,l]),z=h(async()=>{N(!0),await T.interactionTrigger(l,"onDialogAccept",{metadata:C}),N(!1),d(e=>({...e,visibility:!1}))},[T,l,C,d]),R=h(async()=>{N(!0),await T.interactionTrigger(l,"onDialogReject",{metadata:C}),N(!1),d(e=>({...e,visibility:!1}))},[T,l,C,d]),j=k(()=>({openDialog:{...YT.callbacks.openDialog,title:`Open ${m}`,callback:P},closeDialog:{...YT.callbacks.closeDialog,title:`Close ${m}`,callback:L}}),[L,P,m]);KT({panelRef:O,open:!!v&&u,onClose:()=>{R()}}),g(()=>{!1!==y.visibility&&T.interactionTrigger(l,"onDialogOpen",{metadata:C})},[l,T,C,y.visibility]);let $=h(()=>NT(C),[C]);Il({id:l,source:b,name:m||`Dialog - ${l}`,fields:$});let F=k(()=>b?{runtime:{sources:{[b]:C}}}:Nr,[b,C]);/* @__PURE__ */
@@ -147,4 +147,4 @@ return I(Tx,{className:U(e,t&&"system"!==r&&r),children:n})},fI=/* @__PURE__ */$
147
147
  return I(_r,{value:p,children:n})},xI=e=>({apiServer:"https://api.plitzi.com",ssrServer:"https://ssr.plitzi.com",serverUrl:"https://server.plitzi.com",websocketServer:"wss://server.plitzi.com",subscriptionServer:"wss://server.plitzi.com/subscriptions",...e}),SI={Button:ss,ContentEditable:op,Input:hs,Heading:lp,ContainerResizable:Xd,ContainerCollapsable:Kd,Text:nw,Markdown:Zv,ContainerTabs:ap},TI=({className:e="min-h-screen",children:t,webKey:r="",server:i,renderMode:o=Y.renderMode,routing:s="browser",debugMode:l=!1,themeScope:c="document",theme:d,state:p,...f})=>{const m=k(()=>function(e){if(!e)return 0;let t={};try{let n=e.split(".")[1],r=typeof window<"u"?window.atob(n):Buffer.from(n,"base64").toString();t=JSON.parse(r)}catch{return 0}return Jn(t,"data.spaceId",0)}(r),[r]),y=x(p).current,b=k(()=>({segments:{},runtime:{sources:{},state:y??{}},render:Y}),[y]),v=k(()=>(e=>{let t=e?.split(":")[1];return t?`plitzi_debug_${t}`:"plitzi_debug"})("undefined"==typeof window?void 0:window.location.host),[]),[w,T]=S(()=>(e=>{if("undefined"==typeof document)return!0;for(const t of document.cookie.split(";")){const n=t.indexOf("=");if(-1!==n&&t.slice(0,n).trim()===e)return"false"!==decodeURIComponent(t.slice(n+1).trim())}return!0})(v)),C=l&&w,A=k(()=>xI(i),[i]);g(()=>{},[]);const E=h(()=>{const e=!w;((e,t)=>{"undefined"!=typeof document&&(document.cookie=`${e}=${JSON.stringify(t)}; path=/; max-age=31536000; samesite=lax`)})(v,e),T(e)},[v,w]);(({authorized:e,onToggle:t})=>{const n=h(e=>{var n;e.shiftKey&&"F12"===e.key?t():!e.shiftKey||!e.altKey||"KeyD"!==e.code||(n=e.target)instanceof HTMLElement&&(n.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(n.tagName))||(e.preventDefault(),t())},[t]);g(()=>{if(e)return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,n])})({authorized:l,onToggle:E}),g(()=>{},[l,w,v]),g(()=>{if(C)return window.plitziTracing={lastCommitId:Mu.lastCommitId,commitsSince:Mu.commitsSince},()=>{delete window.plitziTracing}},[C]),g(()=>{f.isHydrating&&Mu.setHydrated()},[f.isHydrating]);const _=k(()=>{const e={};return n.forEach(t,t=>{if(!u(t))return;if(t.type!==vA)return;const{renderType:n,component:r,assets:a=[],...i}=t.props;if(!n||!r)return;const o=r;o.type=n,o.assets=a,o.extraProps=i,e[n]=o}),e},[t]);"undefined"==typeof window&&A.requestUrl;const N="widget"===o?a:"undefined"==typeof window?tx:"memory"===s?Tk:Yk,O="widget"===o?{}:{..."memory"===s&&"undefined"!=typeof window?{}:{basename:Jn(A,"basePath","/"),location:"undefined"==typeof window?A.requestUrl??"":void 0}};/* @__PURE__ */
148
148
  return I(kt,{value:b,middlewares:[fe(Pl("sdk")),Gc(m),...C?[()=>({onChange:e=>Mu.recordStoreChange(e)}),ue({shouldRecord:e=>!e?.startsWith("runtime.elements")&&!e?.startsWith("rsc")&&!e?.startsWith("theme")})]:[]],children:/* @__PURE__ */I(dI,{scope:c,theme:d,children:/* @__PURE__ */I(tw,{components:SI,children:/* @__PURE__ */I(pI,{scoped:"container"===c,className:U("plitzi-sdk flex",e,{"sdk-debug-mode":C}),children:/* @__PURE__ */I(Fd,{children:/* @__PURE__ */I(N,{...O,children:/* @__PURE__ */I(kI,{localCustomComponents:_,localComponents:AI,children:/* @__PURE__ */I(uI,{server:A,webKey:r,renderMode:o,debugMode:C,webId:m,...f})})})})})})})})},CI=Lu(({ref:e,className:t,spaceKey:n,environment:r="main"})=>{const{settings:{previewMode:a},contexts:{NetworkContext:i}}=zl(),{server:o}=f(i);/* @__PURE__ */
149
149
  return I(sd,{ref:e,className:U("plitzi-component__plitzi-sdk",t,{"with__plitzi-sdk":!a}),children:n&&/* @__PURE__ */I(TI,{webKey:n,environment:r,renderMode:"widget",server:o,className:"h-full w-full"})})}),AI={plitziSdk:Object.assign(CI,{type:"plitziSdk",content:{attributes:{spaceId:"",spaceKey:"",environment:"main"},definition:{label:"Plitzi Sdk",type:"plitziSdk",bindings:{},styleSelectors:{base:""},initialState:{visibility:!0}},builder:{canDelete:!0,canSelect:!0,canDragDrop:!0,canMove:!0,canTemplate:!0,itemsAllowed:[],itemsNotAllowed:[]},market:{category:"advanced",owner:"Plitzi",verified:!0,license:"MIT",website:"https://plitzi.com",backgroundColor:"#4422ee",icon:/* @__PURE__ */I(q,{})},defaultStyle:{name:"Plitzi Sdk",displayMode:"desktop",style:{base:{default:{}}}},settings:{}}})};Promise.resolve({ });function EI(e,t={},n={},r=!1,a=!1){const{actionRuns:i,styleCacheInDocument:o,...s}=(e=>{if(e.analytics||e.offlineMode||!e.webKey)return e;const{apiServer:t}=xI(e.server);return t?{...e,analytics:{endpoint:`${t.replace(/\/+$/,"")}/v1/collect`,key:e.webKey}}:e})(t),l="undefined"!=typeof document?document.getElementById(e):void 0,c=o?((e,t)=>{const{offlineData:n}=e;if(!n||!t)return e;const r=(e=>{let t=e.querySelector('style[data-id="plitzi-runtime-style"]')?.textContent??"",n=t.indexOf(Jl),r=t.indexOf(Xl,n);if(!(n<0||r<0))return t.slice(n+22,r)})(t);return void 0===r?e:{...e,offlineData:{...n,style:{...n.style,cache:r}}}})(s,l):s,u=c.debugMode??r;u&&i?.length&&it(i);const d=({isHydrating:e=!1})=>{const[t,r]=S(!e);g(()=>r(!0),[]);const a=Object.keys(n).filter(e=>t||!n[e].clientOnly);u||(()=>{if(typeof window>"u")return;let e=()=>{},t=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;"object"==typeof t&&Object.keys(t).forEach(n=>{let r=t[n];t[n]="function"==typeof r?e:null})})();const i=h(e=>{oI=e},[]),o=h(e=>{sI=e},[]);/* @__PURE__ */
150
- return I(TI,{...c,debugMode:u,isHydrating:e,onInitStateManager:i,onInitEventBridge:o,children:a.filter(e=>!!n[e].component).map(e=>/* @__PURE__ */I(TA.Plugin,{renderType:e,component:n[e].component,...n[e].props},e))})};if(!l)return;const p=a?A(l,/* @__PURE__ */I(d,{isHydrating:!0})):C(l);return a||p.render(/* @__PURE__ */I(d,{})),{unmount:()=>p.unmount()}}var II=({debugMode:e=!1,isHydrating:t=!1,children:n,webKey:r="",environment:a="main",renderMode:i=Y.renderMode,...o})=>/* @__PURE__ */I(TI,{...o,isHydrating:t,renderMode:i,debugMode:e,webKey:r,environment:a,children:n});II.Plugin=TA.Plugin;var _I=zl,NI="0.37.7",OI=()=>oI,MI=()=>sI;export{Ze as A,ir as C,_r as ComponentContext,kI as ComponentProvider,lt as D,ht as E,vI as JsxManager,le as M,U as N,rt as O,Rl as PlitziServiceProvider,Bx as PluginManager,Mr as PluginRemote,eC as ReplicaProvider,sd as RootElement,Ar as S,Et as T,xi as _,wx as a,ri as b,ip as c,Mu as d,II as default,uu as f,ls as g,MI as getEventBridge,OI as getStateManager,ms as h,vT as i,Ie as j,Xe as k,Qd as l,Nl as m,QA as n,Vg as o,wc as p,eE as r,EI as render,qg as s,AI as sdkComponents,oE as t,cx as track,Jd as u,FT as useChannel,Du as useElement,_I as usePlitziServiceContext,hT as useRscData,Pc as useRscRefresh,Ot as useStore,ii as v,NI as version,Jn as w,Lu as withElement,Nr as x,ai as y};
150
+ return I(TI,{...c,debugMode:u,isHydrating:e,onInitStateManager:i,onInitEventBridge:o,children:a.filter(e=>!!n[e].component).map(e=>/* @__PURE__ */I(TA.Plugin,{renderType:e,component:n[e].component,...n[e].props},e))})};if(!l)return;const p=a?A(l,/* @__PURE__ */I(d,{isHydrating:!0})):C(l);return a||p.render(/* @__PURE__ */I(d,{})),{unmount:()=>p.unmount()}}var II=({debugMode:e=!1,isHydrating:t=!1,children:n,webKey:r="",environment:a="main",renderMode:i=Y.renderMode,...o})=>/* @__PURE__ */I(TI,{...o,isHydrating:t,renderMode:i,debugMode:e,webKey:r,environment:a,children:n});II.Plugin=TA.Plugin;var _I=zl,NI="0.37.8",OI=()=>oI,MI=()=>sI;export{Ze as A,ir as C,_r as ComponentContext,kI as ComponentProvider,lt as D,ht as E,vI as JsxManager,le as M,U as N,rt as O,Rl as PlitziServiceProvider,Bx as PluginManager,Mr as PluginRemote,eC as ReplicaProvider,sd as RootElement,Ar as S,Et as T,xi as _,wx as a,ri as b,ip as c,Mu as d,II as default,uu as f,ls as g,MI as getEventBridge,OI as getStateManager,ms as h,vT as i,Ie as j,Xe as k,Qd as l,Nl as m,QA as n,Vg as o,wc as p,eE as r,EI as render,qg as s,AI as sdkComponents,oE as t,cx as track,Jd as u,FT as useChannel,Du as useElement,_I as usePlitziServiceContext,hT as useRscData,Pc as useRscRefresh,Ot as useStore,ii as v,NI as version,Jn as w,Lu as withElement,Nr as x,ai as y};
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/plitzi-sdk",
3
- "version": "0.37.7",
3
+ "version": "0.37.8",
4
4
  "homepage": "./",
5
5
  "license": "AGPL-3.0",
6
6
  "files": [
@@ -32,17 +32,17 @@
32
32
  "@fortawesome/fontawesome-free": "^7.3.1",
33
33
  "@plitzi/nexus": "^1.3.1",
34
34
  "@plitzi/plitzi-ui": "^1.6.24",
35
- "@plitzi/sdk-auth": "0.37.7",
36
- "@plitzi/sdk-dev-tools": "0.37.7",
37
- "@plitzi/sdk-elements": "0.37.7",
38
- "@plitzi/sdk-event-bridge": "0.37.7",
39
- "@plitzi/sdk-interactions": "0.37.7",
40
- "@plitzi/sdk-navigation": "0.37.7",
41
- "@plitzi/sdk-plugins": "0.37.7",
42
- "@plitzi/sdk-schema": "0.37.7",
43
- "@plitzi/sdk-shared": "0.37.7",
44
- "@plitzi/sdk-style": "0.37.7",
45
- "@plitzi/sdk-variables": "0.37.7",
35
+ "@plitzi/sdk-auth": "0.37.8",
36
+ "@plitzi/sdk-dev-tools": "0.37.8",
37
+ "@plitzi/sdk-elements": "0.37.8",
38
+ "@plitzi/sdk-event-bridge": "0.37.8",
39
+ "@plitzi/sdk-interactions": "0.37.8",
40
+ "@plitzi/sdk-navigation": "0.37.8",
41
+ "@plitzi/sdk-plugins": "0.37.8",
42
+ "@plitzi/sdk-schema": "0.37.8",
43
+ "@plitzi/sdk-shared": "0.37.8",
44
+ "@plitzi/sdk-style": "0.37.8",
45
+ "@plitzi/sdk-variables": "0.37.8",
46
46
  "clsx": "^2.1.1",
47
47
  "immer": "^11.1.18",
48
48
  "react-router-dom": "^7.18.4"