@plitzi/plitzi-sdk 0.38.23 → 0.38.24

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,34 @@
1
1
  # @plitzi/plitzi-sdk
2
2
 
3
+ ## 0.38.24
4
+
5
+ ### Patch Changes
6
+
7
+ - 5858b9f: ## Server
8
+
9
+ - **`ctx.oauth.callbackUrl()`** (`@plitzi/sdk-server`) — PZ-161. The address providers send a visitor back to, as this
10
+ run's `connect` hands it to them: for a page that shows whoever sets up the app what to register, instead of
11
+ rebuilding the platform's rule. Refused in a run no visitor's request started when the deployment fixed no
12
+ `functions.oauth.callbackOrigin`.
13
+ - **In production the project's server fixes no OAuth callback** (`@plitzi/sdk-server`). 0.38.23's loopback default
14
+ applied wherever `PUBLIC_URL` was not HTTPS — a container behind a proxy sent providers to its own
15
+ `http://127.0.0.1:8080`. Now loopback is the default while developing only; in production the callback is on the
16
+ address each visitor's request came on (the site's domain, from `Host` and `X-Forwarded-Proto`), and the server says
17
+ to register that domain's `/fn/oauth/callback`.
18
+
19
+ - Updated dependencies [5858b9f]
20
+ - @plitzi/sdk-auth@0.38.24
21
+ - @plitzi/sdk-dev-tools@0.38.24
22
+ - @plitzi/sdk-elements@0.38.24
23
+ - @plitzi/sdk-event-bridge@0.38.24
24
+ - @plitzi/sdk-interactions@0.38.24
25
+ - @plitzi/sdk-navigation@0.38.24
26
+ - @plitzi/sdk-plugins@0.38.24
27
+ - @plitzi/sdk-schema@0.38.24
28
+ - @plitzi/sdk-shared@0.38.24
29
+ - @plitzi/sdk-style@0.38.24
30
+ - @plitzi/sdk-variables@0.38.24
31
+
3
32
  ## 0.38.23
4
33
 
5
34
  ### Patch Changes
@@ -126,7 +126,7 @@ return e.createElement(e.Fragment,null,h.map(t=>/* @__PURE__ */e.createElement("
126
126
  return e.createElement(wO,{...c,"aria-current":C,className:k,ref:u,style:E,to:a,viewTransition:s},"function"==typeof l?l(T):l)});kO.displayName="NavLink";var xO=e.forwardRef(({discover:t="render",fetcherKey:n,navigate:r,reloadDocument:i,replace:o,state:a,method:s=ZI,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:p,defaultShouldRevalidate:h,...f},m)=>{let{useTransitions:g}=e.useContext(II),y=function(){let{router:t}=SO("useSubmit"),{basename:n}=e.useContext(II),r=VI("useRouteId"),i=t.fetch,o=t.navigate;return e.useCallback(async(e,t={})=>{let{action:a,method:s,encType:l,formData:c,body:u}=function(e,t){let n,r,i,o,a;if(eO(s=e)&&"form"===s.tagName.toLowerCase()){let a=e.getAttribute("action");r=a?eI(a,t):null,n=e.getAttribute("method")||ZI,i=rO(e.getAttribute("enctype"))||QI,o=new FormData(e)}else if(function(e){return eO(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return eO(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let a=e.form;if(null==a)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let s=e.getAttribute("formaction")||a.getAttribute("action");if(r=s?eI(s,t):null,n=e.getAttribute("formmethod")||a.getAttribute("method")||ZI,i=rO(e.getAttribute("formenctype"))||rO(a.getAttribute("enctype"))||QI,o=new FormData(a,e),!function(){if(null===tO)try{new FormData(document.createElement("form"),0),tO=!1}catch(vM){tO=!0}return tO}()){let{name:t,type:n,value:r}=e;if("image"===n){let e=t?`${t}.`:"";o.append(`${e}x`,"0"),o.append(`${e}y`,"0")}else t&&o.append(t,r)}}else{if(eO(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ZI,r=null,i=QI,a=e}var s;return o&&"text/plain"===i&&(a=o,o=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:o,body:a}}(e,n);if(!1===t.navigate){let e=t.fetcherKey||CO();await i(e,r,t.action||a,{defaultShouldRevalidate:t.defaultShouldRevalidate,preventScrollReset:t.preventScrollReset,formData:c,body:u,formMethod:t.method||s,formEncType:t.encType||l,flushSync:t.flushSync})}else await o(t.action||a,{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})},[i,o,n,r])}(),b=function(t,{relative:n}={}){let{basename:r}=e.useContext(II),i=e.useContext(_I);MA(i,"useFormAction must be used inside a RouteContext");let[o]=i.matches.slice(-1),a={...DI(t||".",{relative:n})},s=LI();if(null==t){a.search=s.search;let e=new URLSearchParams(a.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();a.search=n?`?${n}`:""}}return t&&"."!==t||!o.route.index||(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),"/"!==r&&(a.pathname="/"===a.pathname?r:aI([r,a.pathname])),RA(a)}(l,{relative:u}),v="get"===s.toLowerCase()?"get":"post",w="string"==typeof l&&IA.test(l);/* @__PURE__ */
127
127
  return e.createElement("form",{ref:m,method:v,action:b,onSubmit:i?c:t=>{if(c&&c(t),t.defaultPrevented)return;t.preventDefault();let i=t.nativeEvent.submitter,l=i?.getAttribute("formmethod")||s,f=()=>y(i||t.currentTarget,{fetcherKey:n,method:l,navigate:r,replace:o,state:a,relative:u,preventScrollReset:d,viewTransition:p,defaultShouldRevalidate:h});g&&!1!==r?e.startTransition(()=>f()):f()},...f,"data-discover":w||"render"!==t?void 0:"true"})});function SO(t){let n=e.useContext(SI);return MA(n,function(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}(t)),n}xO.displayName="Form";var TO=0,CO=()=>`__${String(++TO)}__`;function EO({basename:t,children:n,location:r="/"}){"string"==typeof r&&(r=zA(r));let i={pathname:r.pathname||"/",search:r.search||"",hash:r.hash||"",state:null!=r.state?r.state:null,key:r.key||"default",mask:void 0},o={createHref:AO,encodeLocation:IO,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__ */
128
128
  return e.createElement(XI,{basename:t,children:n,location:i,navigationType:"POP",navigator:o,static:!0,useTransitions:!1})}function AO(e){return"string"==typeof e?e:RA(e)}function IO(e){let t="string"==typeof e?e:RA(e);t=t.replace(/ $/,"%20");let n=IA.test(t)?new URL(t):new URL(t,"http://localhost");return{pathname:n.pathname,search:n.search,hash:n.hash}}var OO,_O=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],NO=()=>{const e=new URLSearchParams(window.location.search),t={};for(const n of _O){const r=e.get(n);r&&(t[n.slice(4)]=r)}return Object.keys(t).length>0?t:void 0},MO=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,PO=e=>{OO=e},LO=(e,t)=>{OO?.track(e,t)},jO=({analytics:e})=>{const t=LI(),n=x(!0===e?.firstViewCounted);return g(()=>{if(!e?.endpoint||!e.key)return;const t=((e,t=20,n=5e3)=>{const r=[],i=`${e.endpoint.replace(/\/+$/,"")}/batch?k=${encodeURIComponent(e.key)}`;let o;const a=()=>{0!==r.length&&(e=>{const t=JSON.stringify({events:e});"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(i,t)||fetch(i,{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&&a()},l=()=>({path:window.location.pathname,title:document.title||void 0});return"undefined"!=typeof window&&(o=setInterval(a,n),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&a()}),window.addEventListener("pagehide",a)),{trackRender:()=>{s({id:MO(),type:"render",ts:Date.now(),page:l(),ref:{referrer:document.referrer||void 0,utm:NO()}})},track:(e,t)=>{s({id:MO(),type:"interaction",ts:Date.now(),page:l(),name:e,props:t})},flush:a,stop:()=>{o&&(clearInterval(o),o=void 0),a()}}})(e);return PO(t),()=>{PO(void 0),t.stop()}},[e]),g(()=>{n.current?n.current=!1:OO?.trackRender()},[t.pathname,t.search]),null},RO=["wheel","touchmove","keydown","pointerdown"],zO=e=>{const t=document.getElementById(e);return t?.scrollIntoView({block:"start"}),null!==t},DO=({children:e,currentPageId:t})=>{const{server:n}=h(nh),r=Lo(),{renderMode:i,previewMode:o,environment:a}=ta(),[[s,l,c,u,d]]=Vo(["schema.pageFolders","pageDefinitions","schema.variables","schema.flags","flags.overrides"]),p=n.ssr?.renderResult,m="widget"!==i?LI():void 0,{queryParams:y,hostname:b,origin:v,location:w}=th({server:n,routerLocation:m}),S=x(l);S.current=l;const T=x(s);T.current=s;const{authenticated:C,user:E}=h(Dp),A="widget"!==i?zI():void 0,_=x(A);g(()=>{_.current=A},[A]);const N=k(()=>Zu(l,s,C,n.basePath,o),[l,s,C,n.basePath,o]),{action:M,pageId:P="",pathMatch:L}=k(()=>"widget"===i?{action:{type:"normal",path:""},pageId:t||Qu(N,"/",C).pageId}:Qu(N,w.pathname,C),[N,w.pathname,C,i,t]),j=t||P;(({hash:e,navigationKey:t,enabled:n})=>{g(()=>{const t=(e=>{const t=e.replace(/^#/,"");try{return decodeURIComponent(t)}catch{return t}})(e);if(!n||!t||"undefined"==typeof document||zO(t))return;const r=new AbortController,i=new MutationObserver(()=>{zO(t)&&r.abort()}),o=setTimeout(()=>r.abort(),3e3);return r.signal.addEventListener("abort",()=>{i.disconnect(),clearTimeout(o)}),i.observe(document.body,{childList:!0,subtree:!0}),RO.forEach(e=>window.addEventListener(e,()=>r.abort(),{once:!0,passive:!0,signal:r.signal})),()=>r.abort()},[e,t,n])})({hash:m?.hash??"",navigationKey:m?.key,enabled:o&&"widget"!==i}),g(()=>{Xc.info("navigation",/* @__PURE__ */O("span",{children:["Navigated to page"," ",
129
- /* @__PURE__ */I("b",{children:Qn(l,`${j}.attributes.name`,j||"Unknown")})]}),{status:M.type,elementId:j})},[M.type,j,l]);const R=f(e=>Ju(S.current,T.current,e),[]),z=x(0),D=f((e,t=!1)=>{if(t&&"undefined"!=typeof window)return void(window.location.href=e);const n=R(e),i=++z.current;if(!r.get("rsc.enabled"))return r.set("navigation.pendingLocation",""),void _.current?.(n);r.set("navigation.pendingLocation",n);const o=cd(r,void 0,void 0,{location:n}).finally(()=>{z.current===i&&r.set("navigation.pendingLocation","")}),a=()=>{z.current===i&&_.current?.(n)};Promise.race([o,new Promise(e=>setTimeout(e,1500))]).then(a,a)},[R,r]),$=k(()=>{const e=N.find(e=>e.pageId===j&&!e.isRaw);return e?{...ed(e.path).reduce((e,t)=>({...e,[t]:""}),{}),...Qn(L,"params",{})}:Qn(L,"params",{})},[N,L,j]),F=ou($),q=ou(y),B=k(()=>new URLSearchParams(w.search),[w.search]),U=v?`${v}${w.pathname}${w.search}`:"",H=Object.hasOwn(l,j)?l[j].definition.flag:void 0,W=void 0!==H&&!za(H,Ra(ja(u,{environment:a,hostname:b,routeParams:F,queryParams:q,user:Ma({authenticated:C,user:E})},d))),V=W?((e,t)=>e.find(e=>e.hasAccess&&e.notFound&&Hu({path:e.path,end:!0},t))?.pageId)(N,w.pathname)??"":j;if(Go(["navigation.urlSearchParams","navigation.routeParams","navigation.queryParams","navigation.hostname","navigation.origin","navigation.href","navigation.currentPageId","navigation.navigate"],[B,F,q,b,v,U,V,D],{raw:!0}),"notFound"===M.type||W)return p&&(p.status=404),V?e:"Not Found";if("accessDenied"===M.type)return p&&(p.status=403),"Access Denied";if("redirect"===M.type){const e=Tc(c,{queryParams:y,routeParams:F,hostname:b,environment:a}),t=M.path?String(Dn(M.path,{variables:e},!1,!0)):"";if(t&&Wu(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}`)(w)),p?(p.redirect=e.toString(),null):(window.location.assign(e.toString()),null)}return p?(p.redirect=M.path??"",null):/* @__PURE__ */I(JI,{to:M.path??"",replace:!0})}return e},$O=(e,{src:t,type:n,isMain:r},i=!1)=>{let o,a=`${e}/${t}`,s=btoa(a);return o="style"===n&&a.endsWith(".css")?{type:"link",id:s,params:{href:a,rel:"stylesheet",type:"text/css"},isMain:r}:{type:"script",id:s,params:{src:a,type:"text/javascript"},isMain:r},i&&delete o.isMain,o},FO=(e,t)=>{try{let{resource:n,settings:r,type:i}=e,{definition:{name:o="Plitzi's Demo Plugin",owner:a="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:h,pluginSchema:f}=t;return Object.values(Qn(t,"pluginSchema",{})).reduce((e,m)=>{let{definition:g,builder:y,defaultStyle:b,attributes:v}=m,w=[];return g.type===i&&(w=Object.keys(Ur(f,[i]))),{...e,[g.type]:{attributes:v,builder:y,defaultStyle:b,definition:g,market:{owner:a,verified:s,license:l,website:c,backgroundColor:u,icon:d,category:o},resource:n,isMain:g.type===i,manifest:t,type:i,settings:r,assetsSettings:Object.values(h).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>$O(n,e,!0)),assets:Object.values(p).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>$O(n,e)),subPlugins:w}}},{})}catch{return{}}},qO=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,[Qn(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,i=Qn(n,r);t={...t,...FO(e,i)}}),t},BO=class extends Error{failure;statusCode;constructor(e,t,n){super(e),this.name="GraphqlRequestError",this.failure=t,this.statusCode=n}},UO=async(e,t)=>e.plugins&&e.plugins.length>0?qO(e.plugins.filter(e=>!t.current[e.type])):{},HO=({children:e,server:t,revision:n,webKey:r="",webId:i,userKey:o="",instanceId:a,offlineMode:s=!1,offlineData:l,offlineDataType:c="json"})=>{const{environment:u,debugMode:d}=ta(),p=Yo(),m=s&&!!l&&!!l.schema,y=k(()=>((e,t)=>({request:async(n,r)=>{let i;try{i=await fetch(e,{method:"POST",headers:{accept:"application/graphql-response+json, application/json;q=0.9","content-type":"application/json","sdk-version":"0.38.23",authorization:t?`Bearer ${t}`:""},body:JSON.stringify({query:n,variables:r})})}catch(vM){throw new BO(vM instanceof Error?vM.message:"Network request failed","network")}const o=(e=>{try{return JSON.parse(e)}catch{return}})(await i.text());if(!i.ok){const t=uu(i.status,o);throw t&&lu({reason:t,url:e}),new BO(`Response not successful: Received status code ${i.status}`,"http",i.status)}const a=(e=>{const t=qt(e)?e.errors:void 0;return Array.isArray(t)?t.map(e=>qt(e)&&"string"==typeof e.message?e.message:"Unknown error"):[]})(o);if(a.length)throw new BO(a.join("\n"),"graphql",i.status);if(!qt(o)||!qt(o.data))throw new BO("The server answered without data","graphql",i.status);return o.data}}))(t.serverUrl,r),[t.serverUrl,r]),[b,v]=S(!(s&&l)),[w,T]=S(void 0),{components:C}=h(hi),[E,A]=S(()=>m&&"json"===c?{...l,plugins:{}}:{plugins:{}}),_=f(async(e,t)=>{try{return{success:!0,result:await y.request(oh[e],{environment:u,...t})}}catch(vM){return{success:!1,result:void 0,error:vM instanceof Error?vM:String(vM)}}},[y,u]),N=f(async(e,t,n=!0)=>{const r=ih[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(vM){return{success:!1,result:void 0,error:vM instanceof Error?vM:String(vM)}}},[y,u]),M=async()=>{let e=n;"number"==typeof n&&0!==n||(e=void 0);const t=await _("Init",{environment:u,revision:e});if(t.error)return v(!1),void T((e=>e instanceof BO?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}=$r(t.result);if(!e)return T(/* @__PURE__ */O("span",{children:["Space not found, publish to ",
129
+ /* @__PURE__ */I("b",{children:Qn(l,`${j}.attributes.name`,j||"Unknown")})]}),{status:M.type,elementId:j})},[M.type,j,l]);const R=f(e=>Ju(S.current,T.current,e),[]),z=x(0),D=f((e,t=!1)=>{if(t&&"undefined"!=typeof window)return void(window.location.href=e);const n=R(e),i=++z.current;if(!r.get("rsc.enabled"))return r.set("navigation.pendingLocation",""),void _.current?.(n);r.set("navigation.pendingLocation",n);const o=cd(r,void 0,void 0,{location:n}).finally(()=>{z.current===i&&r.set("navigation.pendingLocation","")}),a=()=>{z.current===i&&_.current?.(n)};Promise.race([o,new Promise(e=>setTimeout(e,1500))]).then(a,a)},[R,r]),$=k(()=>{const e=N.find(e=>e.pageId===j&&!e.isRaw);return e?{...ed(e.path).reduce((e,t)=>({...e,[t]:""}),{}),...Qn(L,"params",{})}:Qn(L,"params",{})},[N,L,j]),F=ou($),q=ou(y),B=k(()=>new URLSearchParams(w.search),[w.search]),U=v?`${v}${w.pathname}${w.search}`:"",H=Object.hasOwn(l,j)?l[j].definition.flag:void 0,W=void 0!==H&&!za(H,Ra(ja(u,{environment:a,hostname:b,routeParams:F,queryParams:q,user:Ma({authenticated:C,user:E})},d))),V=W?((e,t)=>e.find(e=>e.hasAccess&&e.notFound&&Hu({path:e.path,end:!0},t))?.pageId)(N,w.pathname)??"":j;if(Go(["navigation.urlSearchParams","navigation.routeParams","navigation.queryParams","navigation.hostname","navigation.origin","navigation.href","navigation.currentPageId","navigation.navigate"],[B,F,q,b,v,U,V,D],{raw:!0}),"notFound"===M.type||W)return p&&(p.status=404),V?e:"Not Found";if("accessDenied"===M.type)return p&&(p.status=403),"Access Denied";if("redirect"===M.type){const e=Tc(c,{queryParams:y,routeParams:F,hostname:b,environment:a}),t=M.path?String(Dn(M.path,{variables:e},!1,!0)):"";if(t&&Wu(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}`)(w)),p?(p.redirect=e.toString(),null):(window.location.assign(e.toString()),null)}return p?(p.redirect=M.path??"",null):/* @__PURE__ */I(JI,{to:M.path??"",replace:!0})}return e},$O=(e,{src:t,type:n,isMain:r},i=!1)=>{let o,a=`${e}/${t}`,s=btoa(a);return o="style"===n&&a.endsWith(".css")?{type:"link",id:s,params:{href:a,rel:"stylesheet",type:"text/css"},isMain:r}:{type:"script",id:s,params:{src:a,type:"text/javascript"},isMain:r},i&&delete o.isMain,o},FO=(e,t)=>{try{let{resource:n,settings:r,type:i}=e,{definition:{name:o="Plitzi's Demo Plugin",owner:a="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:h,pluginSchema:f}=t;return Object.values(Qn(t,"pluginSchema",{})).reduce((e,m)=>{let{definition:g,builder:y,defaultStyle:b,attributes:v}=m,w=[];return g.type===i&&(w=Object.keys(Ur(f,[i]))),{...e,[g.type]:{attributes:v,builder:y,defaultStyle:b,definition:g,market:{owner:a,verified:s,license:l,website:c,backgroundColor:u,icon:d,category:o},resource:n,isMain:g.type===i,manifest:t,type:i,settings:r,assetsSettings:Object.values(h).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>$O(n,e,!0)),assets:Object.values(p).filter(({src:e})=>!!e&&[".css",".js",".mjs",".cjs"].some(t=>e.endsWith(t))).map(e=>$O(n,e)),subPlugins:w}}},{})}catch{return{}}},qO=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,[Qn(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,i=Qn(n,r);t={...t,...FO(e,i)}}),t},BO=class extends Error{failure;statusCode;constructor(e,t,n){super(e),this.name="GraphqlRequestError",this.failure=t,this.statusCode=n}},UO=async(e,t)=>e.plugins&&e.plugins.length>0?qO(e.plugins.filter(e=>!t.current[e.type])):{},HO=({children:e,server:t,revision:n,webKey:r="",webId:i,userKey:o="",instanceId:a,offlineMode:s=!1,offlineData:l,offlineDataType:c="json"})=>{const{environment:u,debugMode:d}=ta(),p=Yo(),m=s&&!!l&&!!l.schema,y=k(()=>((e,t)=>({request:async(n,r)=>{let i;try{i=await fetch(e,{method:"POST",headers:{accept:"application/graphql-response+json, application/json;q=0.9","content-type":"application/json","sdk-version":"0.38.24",authorization:t?`Bearer ${t}`:""},body:JSON.stringify({query:n,variables:r})})}catch(vM){throw new BO(vM instanceof Error?vM.message:"Network request failed","network")}const o=(e=>{try{return JSON.parse(e)}catch{return}})(await i.text());if(!i.ok){const t=uu(i.status,o);throw t&&lu({reason:t,url:e}),new BO(`Response not successful: Received status code ${i.status}`,"http",i.status)}const a=(e=>{const t=qt(e)?e.errors:void 0;return Array.isArray(t)?t.map(e=>qt(e)&&"string"==typeof e.message?e.message:"Unknown error"):[]})(o);if(a.length)throw new BO(a.join("\n"),"graphql",i.status);if(!qt(o)||!qt(o.data))throw new BO("The server answered without data","graphql",i.status);return o.data}}))(t.serverUrl,r),[t.serverUrl,r]),[b,v]=S(!(s&&l)),[w,T]=S(void 0),{components:C}=h(hi),[E,A]=S(()=>m&&"json"===c?{...l,plugins:{}}:{plugins:{}}),_=f(async(e,t)=>{try{return{success:!0,result:await y.request(oh[e],{environment:u,...t})}}catch(vM){return{success:!1,result:void 0,error:vM instanceof Error?vM:String(vM)}}},[y,u]),N=f(async(e,t,n=!0)=>{const r=ih[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(vM){return{success:!1,result:void 0,error:vM instanceof Error?vM:String(vM)}}},[y,u]),M=async()=>{let e=n;"number"==typeof n&&0!==n||(e=void 0);const t=await _("Init",{environment:u,revision:e});if(t.error)return v(!1),void T((e=>e instanceof BO?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}=$r(t.result);if(!e)return T(/* @__PURE__ */O("span",{children:["Space not found, publish to ",
130
130
  /* @__PURE__ */I("b",{children:u})," environment"]})),void v(!1);let n={};e.plugins.length>0&&(n=await qO(e.plugins.filter(e=>!C.current[e.type]))),p("render.overQuota",e.render?.overQuota??!1),A({schema:{...Mc,...Ic(e.schema)},plugins:n,style:e.style})}v(!1)},P=x(l),L=x(0);g(()=>{if(!m||"json"!==c||P.current===l)return;P.current=l,L.current+=1;const e=L.current;UO(l,C).then(t=>{e===L.current&&A({...l,plugins:t})},e=>{console.error("[plitzi] The new space could not be drawn — its plugins did not load: the page stays as it was",e)})},[l,m,c,C]),g(()=>{s&&l?m&&(async e=>{const t=await UO(e,C);A(e=>({...e,plugins:t})),v(!1)})(l):(v(e=>e||!0),M())},[m,s&&c,r,u,d]);const j=k(()=>({query:_,mutate:N,webKey:r,webId:i,server:t,environment:u,instanceId:a,userKey:o}),[_,N,r,i,t,u,a,o]);return w?/* @__PURE__ */I("div",{children:w}):b?null:/* @__PURE__ */I(nh,{value:j,children:/* @__PURE__ */I(rh,{value:E,children:e})})},WO=({children:e,plugins:t,sdkStylePath:n="./plitzi-sdk.css",sdkIconsPath:r="./plitzi-sdk-icons.css"})=>{const{renderMode:i}=ta(),[o,a]=S({}),s=h(rh),l=k(()=>t||s.plugins,[t,s]),{components:c}=h(hi),u=f((e,t,n="")=>t?Qn(l,`${e}.settings.${t}`,n):Qn(l,`${e}.settings`,{}),[l]),d=f((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&&a(e=>({...e,...t}))},[]),p=f((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));a(e=>Ur(e,t))},[]),m=k(()=>(e=>Object.values(e).reduce((e,t)=>({...e,...Qn(t,"assets",[]).filter(e=>"link"===e.type).reduce((e,t)=>({...e,[btoa(t.id)]:t}),{})}),{}))(l),[l]),g=k(()=>Object.keys(c.current).filter(e=>"local-custom"===c.current[e].origin).reduce((e,t)=>({...e,...Qn(c,`${t}.assets`,[]).reduce((e,n,r)=>({...e,[`${t}-${r}`]:{type:"link",id:`${t}-${r}`,params:n}}),{})}),{}),[c.current]),y=k(()=>{const e={};return"iframe"!==i&&"shadow"!==i||(e["static-99"]={type:"link",id:"static-99",params:{type:"text/css",href:n,rel:"stylesheet"}},e["static-100"]={type:"link",id:"static-100",params:{type:"text/css",href:r,rel:"stylesheet"}}),{...e,...g,...m,...o}},[g,m,o,i,n,r]),b=k(()=>({assets:y,getSettings:u,plugins:l,registerCustomAssets:d,unregisterCustomAssets:p}),[y,u,l,d,p]),v=k(()=>Object.values({...m,...o}).map((e,t)=>/* @__PURE__ */I(e.type,{...e.params},t)),[m,o]);/* @__PURE__ */
131
131
  return O(A,{children:[/* @__PURE__ */I(aC,{children:("raw"===i||"widget"===i)&&v}),/* @__PURE__ */I(Da,{value:b,children:e})]})},VO=({children:e,schema:t})=>{const n=h(rh),r=k(()=>({...Mc,...t||n.schema}),[t,n.schema]);Go("schema",r);const{flat:i,pages:o}=r,a=ou(k(()=>Dr(i,o),[i,o]));return Go("pageDefinitions",a),e},GO=l({});GO.displayName="ContainerRootContext";var KO=({className:e="",children:t,...n})=>{let r=x(null),i=f(()=>r.current instanceof HTMLElement?r.current.getRootNode():void 0,[r]),o=f(()=>i()instanceof ShadowRoot,[i]),a=k(()=>({getHost:i,rootRef:r,isRootShadow:o}),[i,r,o]);/* @__PURE__ */
132
132
  return I("div",{...n,ref:r,className:e,children:/* @__PURE__ */I(GO,{value:a,children:t})})},YO=()=>{let{environment:e}=ta(),[[t,n,r,i]]=Bo(["schema.variables","navigation.routeParams","navigation.queryParams","navigation.hostname"]);return ou(k(()=>Tc(t,{routeParams:n,queryParams:r,hostname:i,environment:e}),[e,i,r,n,t]))},JO=({children:e})=>{let[[t,n,r,i,o,a=""]]=Bo(["navigation.routeParams","navigation.queryParams","navigation.origin","navigation.href","navigation.currentPageId","navigation.pendingLocation"]),s=YO(),l=f(()=>Xr(s).map(e=>({path:e,name:`variables.${e}`})),[s]);JS({id:"global",source:"variables",name:"Variables",fields:l}),Uo("runtime.sources.variables",s);let[c={}]=Bo("pageDefinitions"),u=k(()=>Object.values(c).map(e=>({value:e.id,label:Qn(e,"attributes.name",e.id)})),[c]),d=k(()=>({routeParams:t,queryParams:n,origin:r,href:i,currentPageId:o,pending:""!==a,pendingLocation:a}),[t,n,r,i,o,a]),p=f(()=>[...Xr({routeParams:t,queryParams:n}).map(e=>({path:e,name:`navigation.${e}`})),{path:"origin",name:"Origin"},{path:"href",name:"This page’s address"},{path:"pending",name:"A navigation is on its way"},{path:"pendingLocation",name:"Where a navigation is going"},u.length>0?{path:"currentPageId",name:"Current Page",inputType:"select",values:u}:{path:"currentPageId",name:"Current Page"}],[t,n,u]);JS({id:"global",source:"navigation",name:"Navigation",fields:p}),Uo("runtime.sources.navigation",d);let m=h(Dp),{user:y,authenticated:b,state:v,provider:w}=m,S=k(()=>w?{isAuthenticated:b,...void 0===v?{}:{status:v},accessToken:y?.accessToken??"",details:{username:"",email:"",roles:"",permissions:"",verified:"",...y?.details??{}}}:{},[w,y,b,v]),T=f(()=>Xr(S).map(e=>({path:e,name:`user.${e}`})),[S]);JS({id:"global",source:"auth",name:"Auth State",fields:T}),Uo("runtime.sources.auth",S);let C=(e=>{let{environment:t}=ta(),[[n,r,i,o,a]]=Bo(["schema.flags","navigation.routeParams","navigation.queryParams","navigation.hostname","flags.overrides"]),{authenticated:s,user:l}=e,c=k(()=>Ma({authenticated:s,user:l}),[s,l]);return ou(k(()=>ja(n,{environment:t,hostname:o,routeParams:r,queryParams:i,user:c},a),[n,t,o,r,i,c,a]))})(m),E=k(()=>Ra(C),[C]),A=f(()=>Object.keys(E).map(e=>({path:e,name:`flags.${e}`,inputType:"checkbox"})),[E]);JS({id:"global",source:"flags",name:"Feature Flags",fields:A}),Uo("runtime.sources.flags",E),Uo("flags.resolved",C);let[I,O]=Bo(["schema.flags","flags.overrides"])[0],_=ou(((e,t)=>Pa.flatMap(n=>Object.keys(t[n]??{}).filter(t=>!Object.hasOwn(e??{},t)).map(e=>({layer:n,name:e}))))(I,O??{}));g(()=>{_.forEach(({layer:e,name:t})=>console.warn(`[plitzi] The ${e} sets the feature flag "${t}", which this space does not declare: the override is ignored. Declare the flag in the space, or remove the override.`))},[_]);let[N]=Bo("runtime.state"),M=f(()=>Xr(N).map(e=>({path:e,name:`state.${e}`})),[N]);JS({id:"global",source:"state",name:"State",fields:M}),Uo("runtime.sources.state",N);let[P]=Bo("runtime.host"),L=f(()=>Xr(P).map(e=>({path:e,name:`host.${e}`})),[P]);JS({id:"global",source:"host",name:"Host",fields:L}),Uo("runtime.sources.host",P);let{theme:j,resolvedTheme:R}=BS(qS),z=k(()=>({mode:j,resolved:R}),[j,R]),D=f(()=>Xr(z).map(e=>({path:e,name:`theme.${e}`})),[z]);JS({id:"global",source:"theme",name:"Theme",fields:D}),Uo("runtime.sources.theme",z);let[$]=Bo("schema.settings.computed"),F=x(void 0),q=k(()=>Ja($??{},{variables:s,navigation:d,auth:S,state:N??{},host:P??{},theme:z,flags:E},F.current),[$,s,d,S,N,P,z,E]);F.current=q;let B=f(()=>Xr(q).map(e=>({path:e,name:`computed.${e}`})),[q]);return JS({id:"global",source:"computed",name:"Computed",fields:B}),Uo("runtime.sources.computed",q),e},XO=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/,ZO=/^rgba?\(\s*(\d{1,3}%?\s*,\s*){2,3}\d{1,3}%?\s*\)$/,QO=/^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*\)$/,e_=/* @__PURE__ */new Set(["black","white","red","green","blue","yellow","cyan","magenta","orange","purple","brown","pink","gray","lime","teal","navy","silver","maroon","olive","aqua","fuchsia"]),t_=({children:e,contentDidMount:t,contentDidDismount:n})=>(g(()=>(t?.(),()=>{n?.()}),[]),e),n_=({ref:e,className:t="",ssrMode:r=!1,id:i="",css:o="",style:a,zoom:s=1,assets:l,viewport:c="width=device-width, initial-scale=1",children:u,contentDidMount:d,contentDidDismount:p,contentDidUpdate:h,onLoad:m})=>{t=Em("ContainerFrame",{className:t,componentKey:"root"});let y=x(null);v(e,()=>y.current,[y]);let[b,w]=S(!1),[k,T]=S(null),C=f((e,t,n)=>{let r=[...t.childNodes],i=n.getElementById("customStyle");Object.values(e).forEach(e=>{let o=n.createElement(e.type);e.id&&o.setAttribute("data-id",e.id),Object.keys(e.params).forEach(t=>{("link"===e.type||"script"===e.type)&&o.setAttribute(t,e.params[t])}),r.find(t=>"link"===e.type&&t.href===o.href||"script"===e.type&&t.src===o.src)||(t.insertBefore(o,i),r.push(o))})},[]),E=f((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]),[N]=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=f(()=>d?.(),[d]);g(()=>{b&&k&&E(k,l)},[b,l,k,E]);let P=f(()=>{let e=y.current&&k,t=y.current?.contentDocument===k;e&&!t?T(y.current?.contentDocument):b||(m?.(y.current),w(!0),T(y.current?.contentDocument))},[b,k,m]);return g(()=>{k&&(k.body.style.zoom=1===s?"":`${s}`)},[k,s]),/* @__PURE__ */O("iframe",{ref:y,className:t,title:"#",srcDoc:`<!DOCTYPE html><html><head>${N}</head><body></body></html>`,id:i,onLoad:P,style:a,children:[b&&k&&_(/* @__PURE__ */O(A,{children:[
@@ -155,4 +155,4 @@ return O(KO,{className:Tt(e,t&&"system"!==r&&r),"data-hydrated":i?"":void 0,chil
155
155
  return I(hi,{value:p,children:n})},nM=e=>new Set(Array.isArray(e?.paintedState)?e.paintedState.filter(e=>"string"==typeof e&&""!==e):[]),rM=(e,t)=>qt(e)?Object.fromEntries(Object.entries(e).filter(([e,n])=>t.has(e)&&void 0!==n)):{},iM=e=>{try{document.cookie=`${e}=;path=/;max-age=0;SameSite=Lax`}catch{}},oM=/* @__PURE__ */new Set(["init","initLoading","authenticating"]),aM=e=>{let t=e.runtime?.sources.auth;if(t){if(void 0===t.status)return{kind:"browser"};if(!oM.has(t.status))return t.isAuthenticated&&void 0!==t.details?.id?{kind:"account",id:String(t.details.id)}:{kind:"guest"}}},sM=e=>{switch(e.kind){case"account":return`user:${e.id}`;case"guest":return"guest";case"browser":return""}},lM=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.has(e))),cM=(e,t)=>qt(e)?Object.fromEntries(Object.entries(e).filter(([e])=>t.has(e))):{},uM=e=>e.schema?.settings,dM=e=>new Set((e?.transientState??[]).filter(e=>"string"==typeof e&&""!==e)),pM=(e,t)=>{let n,r=((e,t)=>{let n=t?.split(":")[1];return n?`plitzi_${e}_painted_${n}`:`plitzi_${e}_painted`})(t,typeof window>"u"?void 0:window.location.host),i=!1;return()=>{let t=e.getState();if(typeof document>"u"||t.render?.isHydrating&&!t.render.hydrated)return;let o=uM(t),a=nM(o),s=aM(t);if(!o?.keepState||0===a.size||void 0===s)return;let l=sM(s),c=t.runtime?.state;if(!i){i=!0;let t=(e=>((e,t)=>{let n=Kn(e,t);if(void 0!==n)try{let e=JSON.parse(n);return qt(e)&&"string"==typeof e.owner&&qt(e.values)?{owner:e.owner,values:e.values}:void 0}catch{return}})(Yn(),e))(r);if(t&&t.owner!==l&&(iM(r),qt(c)&&[...a].some(e=>e in c)))return void e.setState("runtime.state",lM(c,a));n=t?.owner===l?JSON.stringify(rM(t.values,a)):void 0}let u=rM(c,a),d=JSON.stringify(u);d!==n&&(n=d,0===Object.keys(u).length?iM(r):"too-large"===((e,t)=>{let n=encodeURIComponent(JSON.stringify(t));if(n.length>3072)return iM(e),"too-large";try{return document.cookie=`${e}=${n};path=/;max-age=31536000;SameSite=Lax`,"written"}catch{return"unavailable"}})(r,{owner:l,values:u})&&Xc.warning("store",`settings.paintedState holds more than a cookie can carry — the first paint uses the space's defaults for ${[...a].join(", ")}. Declare only what the first paint shows.`,{storeName:"runtime",path:"runtime.state",prev:void 0,next:u}))}},hM=e=>{let t=(e=>{let{key:t,storage:n,paths:r,partialize:i,partializePath:o,version:a=0,migrate:s,merge:l,mergePath:c,enabled:u}=e,d="function"==typeof n?n:void 0,p="function"==typeof n?void 0:oa(n);if(!d&&!p)return()=>{};let h=e=>{if(!d)return p;let t=d(e);return t?oa(t):void 0},f=e=>{if(r){let t={};for(let n of r){let r=Oi(e,n);t[n]=o?o(n,r,e):r}return t}return i?i(e):e};return e=>{if(jo(u,e.getState()))return;let n=!1,i=()=>{if(n)return;let i=h(e.getState());i&&(n=!0,function(e,t,n,{version:r,paths:i,migrate:o,merge:a,mergePath:s}){let l=n?.getItem(t);if(l)try{let t=JSON.parse(l),n=t.version!==r;if(n&&!o)return;let c=n&&o?o(t.state,t.version):t.state;if(i){let t=c;return void e.batch(()=>{for(let n of i)if(n in t){let r=s?s(n,t[n],Oi(e.getState(),n),e.getState()):t[n];e.setState(n,r)}})}let u=c;e.setState(void 0,a?a(u,e.getState()):u)}catch{n?.removeItem(t)}}(e,t,i,{version:a,paths:r,migrate:s,merge:l,mergePath:c}))};return{hydrate:i,onChange:n=>{i(),(e=>!r||r.some(t=>Ro(e,t)))(n.path)&&(e=>{let n=e.getState(),r=h(n);if(!r)return;let i={version:a,state:f(n)};r.setItem(t,JSON.stringify(i))})(e)}}}})({key:`plitzi_${e}_state`,paths:["runtime.state"],partializePath:(e,t,n)=>qt(t)?lM(t,dM(uM(n))):t,mergePath:(e,t,n,r)=>{let i=dM(uM(r));return i.size>0&&qt(t)?{...lM(t,i),...cM(n,i)}:t},storage:e=>{let{render:t}=e;if(t?.isHydrating&&!t.hydrated)return!1;let n=uM(e),r=aM(e);if(!n?.keepState||void 0===r)return!1;let i=(e=>{try{return"session"===e?globalThis.sessionStorage:globalThis.localStorage}catch{return}})("sessionStorage"===n.stateStorage?"session":"local");return!!i&&((e,t)=>({getItem:n=>{let r=e.getItem(n);if(null===r)return null;try{let e=JSON.parse(r);if(e.owner===t&&"string"==typeof e.payload)return e.payload}catch{}return e.removeItem(n),null},setItem:(n,r)=>e.setItem(n,JSON.stringify({owner:t,payload:r})),removeItem:t=>e.removeItem(t)}))(i,sM(r))}});return n=>{let r=t(n),i=n.getState().runtime?.state,o=aM(n.getState()),a=pM(n,e);return{...r,onChange:e=>{let t=o,s=aM(n.getState());if(void 0!==s&&(o=s),"account"===t?.kind&&void 0!==s&&sM(s)!==sM(t)){let e=qt(i)?lM(i,nM(uM(n.getState()))):i;n.setState("runtime.state",e)}r?.onChange?.(e),a()}}}},fM=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}),mM={Button:ZE,ContentEditable:Am,Input:SA,Heading:yA,ContainerResizable:lA,ContainerCollapsable:aA,Text:AA,ContainerTabs:mA},gM=({className:e,children:t,webKey:r="",server:o,renderMode:a=ea.renderMode,routing:s="browser",debugMode:l=!1,themeScope:c,theme:d,state:p,forcedFlags:m,...y})=>{const b=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}let n=Number(Qn(t,"sub",0));return Number.isInteger(n)&&n>0?n:0}(r),[r]),v=h(zr),w=c??(v?"container":"document"),T=v&&"raw"===a?"widget":a,C=e??(v?void 0:"min-h-screen"),E=x(p).current,A=k(()=>({runtime:{sources:{},state:E??{}},render:{...ea,ownsHead:!v,enclosed:v}}),[E,v]),O=k(()=>(e=>{let t=e?.split(":")[1];return t?`plitzi_debug_${t}`:"plitzi_debug"})("undefined"==typeof window?void 0:window.location.host),[]),[_,N]=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})(O)),M=l&&_,[P]=S(()=>m||!l||"undefined"==typeof window?m:((e,t)=>(e=>e?Object.fromEntries(e.split(",").map(e=>e.split(":")).filter(([e,t])=>Ia(e)&&("1"===t||"0"===t)).map(([e,t])=>[e,"1"===t])):{})(Kn(e,Oa(t))))(Yn(),window.location.host)),L=k(()=>fM(o),[o]);g(()=>{},[]);const j=f(()=>{const e=!_;((e,t)=>{"undefined"!=typeof document&&(document.cookie=`${e}=${JSON.stringify(t)}; path=/; max-age=31536000; samesite=lax`)})(O,e),N(e)},[O,_]);(({authorized:e,onToggle:t})=>{const n=f(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:j}),g(()=>{},[l,_,O]),g(()=>{if(M)return window.plitziTracing={lastCommitId:Fu.lastCommitId,commitsSince:Fu.commitsSince},()=>{delete window.plitziTracing}},[M]),g(()=>{y.isHydrating&&Fu.setHydrated()},[y.isHydrating]);const R=k(()=>{const e={};return n.forEach(t,t=>{if(!u(t))return;if(t.type!==nN)return;const{renderType:n,component:r,assets:i=[],...o}=t.props;if(!n||!r)return;const a=r;a.type=n,a.assets=i,a.extraProps=o,e[n]=a}),e},[t]);"undefined"==typeof window&&L.requestUrl;const z="widget"===T?i:"undefined"==typeof window?EO:"memory"===s?YI:vO,D="widget"===T?{}:{..."memory"===s&&"undefined"!=typeof window?{}:{basename:Qn(L,"basePath","/"),location:"undefined"==typeof window?L.requestUrl??"":void 0}};/* @__PURE__ */
156
156
  return I(zr,{value:!0,children:/* @__PURE__ */I(Oo,{value:A,middlewares:[ia(Zc("sdk")),hM(b),...M?[()=>({onChange:e=>Fu.recordStoreChange(e)}),qo({shouldRecord:e=>!(e?.startsWith("runtime.elements")||e?.startsWith("rsc")||e?.startsWith("theme")||e?.startsWith("flags"))})]:[]],children:/* @__PURE__ */I(HN,{scope:w,theme:d,children:/* @__PURE__ */I(EA,{components:mM,applyColorModeClass:!1,children:/* @__PURE__ */I(VN,{scoped:"container"===w,className:Tt("plitzi-sdk","flex",C,{"sdk-debug-mode":M}),children:/* @__PURE__ */I(rC,{children:/* @__PURE__ */I(z,{...D,children:/* @__PURE__ */I(tM,{localCustomComponents:R,localComponents:bM,children:/* @__PURE__ */I(UN,{server:L,webKey:r,renderMode:T,debugMode:M,webId:b,forcedFlags:P,...y})})})})})})})})})},yM=Bu(({ref:e,className:t,spaceKey:n,environment:r="main",offlineData:i})=>{const{settings:{previewMode:o}}=hu(),{server:a}=h(nh),s=k(()=>void 0===i?void 0:(e=>{if(!qt(e))return{problem:"The documents cannot be drawn: they are not an object with `schema` and `style`."};const t=["schema","style"].filter(t=>void 0===e[t]);return t.length>0?{waiting:t}:(e=>void 0===KE(e.schema,e.style))(e)?{documents:e}:{problem:`The documents cannot be drawn: ${KE(e.schema,e.style)??"their shape is unknown"}.`}})(i),[i]),l=s&&"problem"in s?s.problem:void 0,c=s&&"waiting"in s?s.waiting:void 0,u=s&&"documents"in s?s.documents:void 0,d=void 0!==s&&!!n;return g(()=>{l&&console.error(`[plitziSdk] ${l}`)},[l]),g(()=>{d&&console.warn("[plitziSdk] Both `offlineData` and `spaceKey` are set: the documents are drawn, the key is not.")},[d]),/* @__PURE__ */O(kh,{ref:e,className:Tt("plitzi-component__plitzi-sdk",t,{"with__plitzi-sdk":!o}),children:[u&&/* @__PURE__ */I(gM,{offlineMode:!0,offlineData:u,environment:r,renderMode:"widget",className:"h-full w-full"}),!s&&n&&/* @__PURE__ */I(gM,{webKey:n,environment:r,server:a,renderMode:"widget",className:"h-full w-full"}),l&&!o&&/* @__PURE__ */I("p",{className:"plitzi-sdk__problem",children:l}),c&&!o&&/* @__PURE__ */O("p",{className:"plitzi-sdk__waiting",children:["Waiting for ",c.map(e=>`\`${e}\``).join(" and ")," to be bound."]})]})}),bM={plitziSdk:Object.assign(yM,{...ke,content:{...ke.content,market:{...ke.content.market,icon:/* @__PURE__ */I(q,{})}}})},vM=class extends Error{stage;log;constructor(e,t){super(`${"link"===e?"program failed to link":`${e} shader failed`}: ${t.trim()||"no log given"}`),this.name="ShaderError",this.stage=e,this.log=t}},wM=(e,t,n)=>{let r=e.createShader("vertex"===t?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(!r)throw new vM(t,"the context made no shader (it is lost)");if(e.shaderSource(r,n),e.compileShader(r),!0!==e.getShaderParameter(r,e.COMPILE_STATUS)){let n=e.getShaderInfoLog(r)??"";throw e.deleteShader(r),new vM(t,n)}return r},kM=(e,{vertex:t,fragment:n})=>{let r=wM(e,"vertex",t),i=wM(e,"fragment",n),o=e.createProgram();if(e.attachShader(o,r),e.attachShader(o,i),e.linkProgram(o),e.deleteShader(r),e.deleteShader(i),!0!==e.getProgramParameter(o,e.LINK_STATUS)){let t=e.getProgramInfoLog(o)??"";throw e.deleteProgram(o),new vM("link",t)}return o},xM="(prefers-reduced-motion: reduce)",SM=()=>"function"==typeof window.matchMedia&&window.matchMedia(xM).matches||document.documentElement.classList.contains("plitzi-reduced-motion"),TM=e=>{let t="function"==typeof window.matchMedia?window.matchMedia(xM):void 0;t?.addEventListener("change",e);let n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{t?.removeEventListener("change",e),n.disconnect()}},CM=()=>T(TM,SM,()=>!1),EM=e=>(document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)),AM=()=>"hidden"!==document.visibilityState,IM=(e,{paused:t=!1,fps:n,target:r}={})=>{let i=hu().settings.previewMode??!0,o=CM(),a=T(EM,AM,()=>!1),s=(e=>{let[t,n]=S(!0);return g(()=>{let t=e?.current;if(!t||typeof IntersectionObserver>"u")return;let r=new IntersectionObserver(e=>n(e.some(e=>e.isIntersecting)));return r.observe(t),()=>r.disconnect()},[e]),t})(r),l=i&&!o&&!t&&a&&s,c=x(e);g(()=>{c.current=e},[e]);let u=x({time:0,frame:0});return g(()=>{if(!l)return;let e,t=n&&n>0?1e3/n:0,r=0,i=0,o=n=>{let a=void 0===e?0:n-e;if(e=n,i+=a,i>=t){let e=t>0?i:a;i=t>0?i%t:0,u.current={time:u.current.time+e,frame:u.current.frame+1},c.current({...u.current,delta:e})}r=requestAnimationFrame(o)};return r=requestAnimationFrame(o),()=>cancelAnimationFrame(r)},[l,n]),{running:l}},OM=(e,{setup:t,draw:n,maxPixelRatio:r=2,paused:i,fps:o})=>{let a=(e=>`[plugin ${e?.definition?.type??"canvas"}${e?.id?` "${e.id}"`:""}]`)(h(ai)),s=x(null),[l,c]=S(null),[u,d]=S({width:0,height:0,pixelRatio:1}),[p,m]=S(),[y,b]=S(!1),[v,w]=S(0),k=x(null),T=x({acquire:e,setup:t,draw:n});g(()=>{T.current={acquire:e,setup:t,draw:n}},[e,t,n]);let C=f(e=>{let t=e instanceof Error?e.message:String(e);console.error(`${a} ${t}`),m(t)},[a]),E=f(e=>{s.current=e,c(e)},[]);g(()=>{if(!l)return;let e=()=>{let e=l.getBoundingClientRect(),t=Math.min(window.devicePixelRatio||1,r);l.width=Math.max(1,Math.round(e.width*t)),l.height=Math.max(1,Math.round(e.height*t)),d({width:e.width,height:e.height,pixelRatio:t})};if(e(),typeof ResizeObserver>"u")return;let t=new ResizeObserver(e);return t.observe(l),()=>t.disconnect()},[l,r]),g(()=>{if(!l)return;let e=e=>{e.preventDefault(),k.current=null,b(!1)},t=()=>w(e=>e+1);return l.addEventListener("webglcontextlost",e),l.addEventListener("webglcontextrestored",t),()=>{l.removeEventListener("webglcontextlost",e),l.removeEventListener("webglcontextrestored",t)}},[l]),g(()=>{if(l&&0!==u.width&&void 0===p)try{let e=T.current.acquire(l);if(!e)return void C(/* @__PURE__ */Error("the browser gave no drawing context (WebGL may be off)"));e.prepare(u);let t=T.current.setup?T.current.setup(e.context,u):void 0;k.current={handle:e,state:t}}catch(vM){C(vM)}},[l,u,v,p,C]);let A=f(e=>{let t=k.current;if(t&&void 0===p)try{t.handle.prepare(u),T.current.draw(t.handle.context,{...e,...u,state:t.state}),b(!0)}catch(e){k.current=null,C(e)}},[u,p,C]),{running:I}=IM(A,{paused:i||void 0!==p,fps:o,target:s});return g(()=>{!I&&u.width>0&&A({time:0,delta:0,frame:0})},[I,u,v,A]),{ref:E,ready:y,error:p,running:I}},_M=({attributes:e,...t})=>OM(f(t=>{let n=t.getContext("2d",e);return n&&{context:n,prepare:({pixelRatio:e})=>n.setTransform(e,0,0,e,0,0)}},[e]),t),NM=({attributes:e,...t})=>OM(f(t=>{let n=t.getContext("webgl",e);return n&&{context:n,prepare:()=>n.viewport(0,0,t.width,t.height)}},[e]),t),MM=({attributes:e,...t})=>OM(f(t=>{let n=t.getContext("webgl2",e);return n&&{context:n,prepare:()=>n.viewport(0,0,t.width,t.height)}},[e]),t),PM={mobile:`(max-width: ${bd("tablet")})`,tablet:`(max-width: ${bd("desktop")})`},LM=e=>typeof window>"u"||"function"!=typeof window.matchMedia?void 0:window.matchMedia(e),jM=()=>LM(PM.mobile)?.matches?"mobile":LM(PM.tablet)?.matches?"tablet":"desktop",RM=e=>{let t=[LM(PM.mobile),LM(PM.tablet)].filter(e=>void 0!==e);return t.forEach(t=>{t.addEventListener("change",e)}),()=>{t.forEach(t=>{t.removeEventListener("change",e)})}},zM=()=>"desktop",DM=()=>T(RM,jM,zM),$M=e=>{let[t,n]=S(void 0);return g(()=>{let t=e.current;if(!t||typeof ResizeObserver>"u")return;let r=(e,t)=>n(n=>n?.width===e&&n.height===t?n:{width:e,height:t}),i=t.getBoundingClientRect();r(i.width,i.height);let o=new ResizeObserver(e=>{e.slice(-1).forEach(e=>r(e.contentRect.width,e.contentRect.height))});return o.observe(t),()=>o.disconnect()},[e]),t},FM=e=>{const t=h(Ip);return f(async(n,r={})=>{if(!t)return console.warn(`[plitzi] useServerAction: nothing on this page runs server actions, so "${e}" was skipped`),{ok:!1,runId:"",reason:"skipped"};const i=await t({actionId:e,input:n,...r});return"completed"!==i.status?{ok:!1,runId:i.runId,reason:i.reason??i.status,...i.error?{error:i.error}:{}}:{ok:!0,runId:i.runId,output:i.output}},[e,t])},qM=(e,t)=>new Promise(n=>{const r=document.createElement("link");r.rel="stylesheet",r.href=e,r.dataset.plitziPlugin=t,r.onload=()=>n(),r.onerror=()=>n(),document.head.append(r)}),BM=(e,{load:t,css:n,declaration:r})=>{let i;const o=(r,{content:s,version:l,initialItems:c,plugins:u})=>{const p=d(async()=>({default:r.reduce((t,n)=>{const r=t.plugins?.[n];if(!r)throw new Error(`[plitzi] plugin "${e}" was loaded without the "${n}" it declared`);return r},await(i??=Promise.all([t(),n?qM(n,e):void 0]).then(([e])=>e.default)))})),h=e=>/* @__PURE__ */I(a,{fallback:null,children:/* @__PURE__ */I(p,{...e})});return h.displayName=`Deferred(${r.at(-1)??e})`,Object.assign(h,{content:s,version:l,initialItems:c,plugins:u?Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o([...r,e],t)])):void 0})};return o([],r)},UM=e=>{try{return JSON.stringify({...e},(e,t)=>"function"==typeof t?void 0:t)}catch{return}},HM=e=>{const t=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;return{plugins:Object.fromEntries(Object.entries(e).map(([e,i])=>{t.set(e,i.component);const o=((e,r)=>{const i=(e=>t=>{const r=n.get(e)??/* @__PURE__ */new Set;return r.add(t),n.set(e,r),()=>{r.delete(t)}})(e),o=()=>t.get(e)??r,a=e=>{const t=T(i,o,o);/* @__PURE__ */
157
157
  return I(t,{...e})};return a.displayName=`Hot(${r.displayName??r.name})`,Object.assign(a,r)})(e,i.component);return r.set(e,o),[e,{...i,component:o}]})),replace:(e,i)=>{const o=t.get(e),a=r.get(e);return!(!o||!a||UM(o)!==UM(i)||(t.set(e,i),n.get(e)?.forEach(e=>{e()}),0))}}};Promise.resolve({ });var WM=e=>Object.values(e?.schema.flat??{}).some(e=>"server"===e.definition.runtime);function VM(e,t={},n={},r=!1,i=!1,{hotPlugins:o=!1}={}){const a=Object.fromEntries(Object.entries(n).map(([e,t])=>{if("component"in t)return[e,t];const{load:n,css:r,declaration:i,...o}=t;return[e,{...o,component:BM(e,{load:n,css:r,declaration:i})}]})),s=o?HM(a):void 0,l=s?.plugins??a,{actionRuns:c,styleCacheInDocument:u,...d}=(e=>{if(e.analytics||e.offlineMode||!e.webKey)return e;const{apiServer:t}=fM(e.server);return t?{...e,analytics:{endpoint:`${t.replace(/\/+$/,"")}/v1/collect`,key:e.webKey}}:e})(t),p="undefined"!=typeof document?document.getElementById(e):void 0,h=u?((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(Nd),r=t.indexOf(Md,n);if(!(n<0||r<0))return t.slice(n+22,r)})(t);return void 0===r?(console.error("[plitzi] The server-rendered stylesheet is missing from the page: it renders without its styles."),e):{...e,offlineData:{...n,style:{...n.style,cache:r}}}})(d,p):d,m=h.debugMode??r;m&&c?.length&&pa(c);let y,b=h.offlineData;const v=({isHydrating:e=!1})=>{const[t,n]=S(h.offlineData);g(()=>(y=n,()=>{y=void 0}),[]);const[r,i]=S(!e);g(()=>i(!0),[]);const o=Object.keys(l).filter(e=>r||!l[e].clientOnly);m||(()=>{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 a=f(e=>{sN=e},[]),s=f(e=>{lN=e},[]);/* @__PURE__ */
158
- return I(gM,{...h,offlineData:t,debugMode:m,isHydrating:e,onInitStateManager:a,onInitEventBridge:s,children:o.filter(e=>!!l[e].component).map(e=>/* @__PURE__ */I(cN.Plugin,{renderType:e,component:l[e].component,...l[e].props},e))})};if(!p)return;const w=i?E(p,/* @__PURE__ */I(v,{isHydrating:!0})):C(p);return i||w.render(/* @__PURE__ */I(v,{})),{unmount:()=>w.unmount(),replacePlugin:(e,t)=>s?.replace(e,t)??!1,replaceSpace:e=>!(!y||!h.offlineMode||WM(b)||WM(e)||(b=e,y(e),0))}}var GM=({debugMode:e=!1,isHydrating:t=!1,children:n,webKey:r="",environment:i="main",renderMode:o=ea.renderMode,...a})=>/* @__PURE__ */I(gM,{...a,isHydrating:t,renderMode:o,debugMode:e,webKey:r,environment:i,children:n});GM.Plugin=cN.Plugin;var KM="0.38.23",YM=()=>sN,JM=()=>lN;export{Co as A,gr as B,_a as C,hi as ComponentContext,tM as ComponentProvider,aa as D,ua as E,Jr as F,Jn as H,Wr as I,Ch as JsxManager,Rr as L,Ri as M,Ni as N,Bo as O,Si as P,fu as PlitziProvider,jh as PluginManager,fi as PluginRemote,Da as PluginsContext,jr as R,Rh as ReplicaProvider,kh as RootElement,nl as S,vM as ShaderError,fa as T,Tt as U,Qn as V,bu as _,uN as a,Lc as b,uA as c,kM as createShaderProgram,BS as d,GM as default,UE as elementChildren,Fm as f,Fu as g,JM as getEventBridge,YM as getStateManager,vd as h,gN as i,Eo as j,$o as k,sA as l,Gd as m,IN as n,TA as o,jm as p,ON as r,VM as render,gA as s,bM as sdkComponents,jN as t,LO as track,QE as u,IM as useAnimationFrame,_M as useCanvas2d,VC as useChannel,DM as useDisplayMode,Uu as useElement,$M as useElementSize,WE as useElementVisible,qE as useFlag,FE as useJob,B_ as useNotify,hu as usePlitzi,dd as usePluginRoute,VE as usePluginTrigger,CM as useReducedMotion,pd as useRscData,ud as useRscRefresh,FM as useServerAction,Vo as useStore,NM as useWebGL,MM as useWebGL2,Kc as v,KM as version,Na as w,Bu as withElement,rl as x,qc as y,Pr as z};
158
+ return I(gM,{...h,offlineData:t,debugMode:m,isHydrating:e,onInitStateManager:a,onInitEventBridge:s,children:o.filter(e=>!!l[e].component).map(e=>/* @__PURE__ */I(cN.Plugin,{renderType:e,component:l[e].component,...l[e].props},e))})};if(!p)return;const w=i?E(p,/* @__PURE__ */I(v,{isHydrating:!0})):C(p);return i||w.render(/* @__PURE__ */I(v,{})),{unmount:()=>w.unmount(),replacePlugin:(e,t)=>s?.replace(e,t)??!1,replaceSpace:e=>!(!y||!h.offlineMode||WM(b)||WM(e)||(b=e,y(e),0))}}var GM=({debugMode:e=!1,isHydrating:t=!1,children:n,webKey:r="",environment:i="main",renderMode:o=ea.renderMode,...a})=>/* @__PURE__ */I(gM,{...a,isHydrating:t,renderMode:o,debugMode:e,webKey:r,environment:i,children:n});GM.Plugin=cN.Plugin;var KM="0.38.24",YM=()=>sN,JM=()=>lN;export{Co as A,gr as B,_a as C,hi as ComponentContext,tM as ComponentProvider,aa as D,ua as E,Jr as F,Jn as H,Wr as I,Ch as JsxManager,Rr as L,Ri as M,Ni as N,Bo as O,Si as P,fu as PlitziProvider,jh as PluginManager,fi as PluginRemote,Da as PluginsContext,jr as R,Rh as ReplicaProvider,kh as RootElement,nl as S,vM as ShaderError,fa as T,Tt as U,Qn as V,bu as _,uN as a,Lc as b,uA as c,kM as createShaderProgram,BS as d,GM as default,UE as elementChildren,Fm as f,Fu as g,JM as getEventBridge,YM as getStateManager,vd as h,gN as i,Eo as j,$o as k,sA as l,Gd as m,IN as n,TA as o,jm as p,ON as r,VM as render,gA as s,bM as sdkComponents,jN as t,LO as track,QE as u,IM as useAnimationFrame,_M as useCanvas2d,VC as useChannel,DM as useDisplayMode,Uu as useElement,$M as useElementSize,WE as useElementVisible,qE as useFlag,FE as useJob,B_ as useNotify,hu as usePlitzi,dd as usePluginRoute,VE as usePluginTrigger,CM as useReducedMotion,pd as useRscData,ud as useRscRefresh,FM as useServerAction,Vo as useStore,NM as useWebGL,MM as useWebGL2,Kc as v,KM as version,Na as w,Bu as withElement,rl as x,qc as y,Pr as z};
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/plitzi-sdk",
3
- "version": "0.38.23",
3
+ "version": "0.38.24",
4
4
  "homepage": "./",
5
5
  "license": "AGPL-3.0",
6
6
  "files": [
@@ -33,17 +33,17 @@
33
33
  "@fortawesome/fontawesome-free": "^7.3.1",
34
34
  "@plitzi/nexus": "^1.4.0",
35
35
  "@plitzi/plitzi-ui": "^1.6.34",
36
- "@plitzi/sdk-auth": "0.38.23",
37
- "@plitzi/sdk-dev-tools": "0.38.23",
38
- "@plitzi/sdk-elements": "0.38.23",
39
- "@plitzi/sdk-event-bridge": "0.38.23",
40
- "@plitzi/sdk-interactions": "0.38.23",
41
- "@plitzi/sdk-navigation": "0.38.23",
42
- "@plitzi/sdk-plugins": "0.38.23",
43
- "@plitzi/sdk-schema": "0.38.23",
44
- "@plitzi/sdk-shared": "0.38.23",
45
- "@plitzi/sdk-style": "0.38.23",
46
- "@plitzi/sdk-variables": "0.38.23",
36
+ "@plitzi/sdk-auth": "0.38.24",
37
+ "@plitzi/sdk-dev-tools": "0.38.24",
38
+ "@plitzi/sdk-elements": "0.38.24",
39
+ "@plitzi/sdk-event-bridge": "0.38.24",
40
+ "@plitzi/sdk-interactions": "0.38.24",
41
+ "@plitzi/sdk-navigation": "0.38.24",
42
+ "@plitzi/sdk-plugins": "0.38.24",
43
+ "@plitzi/sdk-schema": "0.38.24",
44
+ "@plitzi/sdk-shared": "0.38.24",
45
+ "@plitzi/sdk-style": "0.38.24",
46
+ "@plitzi/sdk-variables": "0.38.24",
47
47
  "clsx": "^2.1.1",
48
48
  "react-router-dom": "^7.18.4"
49
49
  },