@studioindia/designx 1.0.4 → 1.1.0

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.
@@ -1,4 +1,4 @@
1
- import{r as s,p as R,a as O,j as o,n as N,b as U,s as Z,c as H}from"./index-B4DsP2aY.js";const k=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M71.68,97.22,34.74,128l36.94,30.78a12,12,0,1,1-15.36,18.44l-48-40a12,12,0,0,1,0-18.44l48-40A12,12,0,0,1,71.68,97.22Zm176,21.56-48-40a12,12,0,1,0-15.36,18.44L221.26,128l-36.94,30.78a12,12,0,1,0,15.36,18.44l48-40a12,12,0,0,0,0-18.44ZM164.1,28.72a12,12,0,0,0-15.38,7.18l-64,176a12,12,0,0,0,7.18,15.37A11.79,11.79,0,0,0,96,228a12,12,0,0,0,11.28-7.9l64-176A12,12,0,0,0,164.1,28.72Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M240,128l-48,40H64L16,128,64,88H192Z",opacity:"0.2"}),s.createElement("path",{d:"M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM92.8,145.6a8,8,0,1,1-9.6,12.8l-32-24a8,8,0,0,1,0-12.8l32-24a8,8,0,0,1,9.6,12.8L69.33,128Zm58.89-71.4-32,112a8,8,0,1,1-15.38-4.4l32-112a8,8,0,0,1,15.38,4.4Zm53.11,60.2-32,24a8,8,0,0,1-9.6-12.8L186.67,128,163.2,110.4a8,8,0,1,1,9.6-12.8l32,24a8,8,0,0,1,0,12.8Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M67.84,92.61,25.37,128l42.47,35.39a6,6,0,1,1-7.68,9.22l-48-40a6,6,0,0,1,0-9.22l48-40a6,6,0,0,1,7.68,9.22Zm176,30.78-48-40a6,6,0,1,0-7.68,9.22L230.63,128l-42.47,35.39a6,6,0,1,0,7.68,9.22l48-40a6,6,0,0,0,0-9.22Zm-81.79-89A6,6,0,0,0,154.36,38l-64,176A6,6,0,0,0,94,221.64a6.15,6.15,0,0,0,2,.36,6,6,0,0,0,5.64-3.95l64-176A6,6,0,0,0,162.05,34.36Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M66.56,91.07,22.25,128l44.31,36.93A4,4,0,0,1,64,172a3.94,3.94,0,0,1-2.56-.93l-48-40a4,4,0,0,1,0-6.14l48-40a4,4,0,0,1,5.12,6.14Zm176,33.86-48-40a4,4,0,1,0-5.12,6.14L233.75,128l-44.31,36.93a4,4,0,1,0,5.12,6.14l48-40a4,4,0,0,0,0-6.14ZM161.37,36.24a4,4,0,0,0-5.13,2.39l-64,176a4,4,0,0,0,2.39,5.13A4.12,4.12,0,0,0,96,220a4,4,0,0,0,3.76-2.63l64-176A4,4,0,0,0,161.37,36.24Z"}))]]),M=s.forwardRef((e,t)=>s.createElement(R,{ref:t,...e,weights:k}));M.displayName="CodeIcon";const z=M,q=500,K=20,V=300,B="https://stackblitz.com",A=["angular-cli","create-react-app","html","javascript","node","polymer","typescript","vue"],W=["project","search","ports","settings"],G=["light","dark"],J=["editor","preview"],I={clickToLoad:e=>m("ctl",e),devToolsHeight:e=>$("devtoolsheight",e),forceEmbedLayout:e=>m("embed",e),hideDevTools:e=>m("hidedevtools",e),hideExplorer:e=>m("hideExplorer",e),hideNavigation:e=>m("hideNavigation",e),openFile:e=>g("file",e),showSidebar:e=>X("showSidebar",e),sidebarView:e=>x("sidebarView",e,W),startScript:e=>g("startScript",e),terminalHeight:e=>$("terminalHeight",e),theme:e=>x("theme",e,G),view:e=>x("view",e,J),zenMode:e=>m("zenMode",e),organization:e=>`${g("orgName",e==null?void 0:e.name)}&${g("orgProvider",e==null?void 0:e.provider)}`,crossOriginIsolated:e=>m("corp",e)};function F(e={}){const t=Object.entries(e).map(([n,r])=>r!=null&&I.hasOwnProperty(n)?I[n](r):"").filter(Boolean);return t.length?`?${t.join("&")}`:""}function m(e,t){return t===!0?`${e}=1`:""}function X(e,t){return typeof t=="boolean"?`${e}=${t?"1":"0"}`:""}function $(e,t){if(typeof t=="number"&&!Number.isNaN(t)){const n=Math.min(100,Math.max(0,t));return`${e}=${encodeURIComponent(Math.round(n))}`}return""}function x(e,t="",n=[]){return n.includes(t)?`${e}=${encodeURIComponent(t)}`:""}function g(e,t){return(Array.isArray(t)?t:[t]).filter(r=>typeof r=="string"&&r.trim()!=="").map(r=>`${e}=${encodeURIComponent(r)}`).join("&")}function L(){return Math.random().toString(36).slice(2,6)+Math.random().toString(36).slice(2,6)}function w(e,t){return`${D(t)}${e}${F(t)}`}function E(e,t){const n={forceEmbedLayout:!0};return t&&typeof t=="object"&&Object.assign(n,t),`${D(n)}${e}${F(n)}`}function D(e={}){return(typeof e.origin=="string"?e.origin:B).replace(/\/$/,"")}function _(e,t,n){if(!t||!e||!e.parentNode)throw new Error("Invalid Element");e.id&&(t.id=e.id),e.className&&(t.className=e.className),Y(t,n),Q(e,t,n),e.replaceWith(t)}function j(e){if(typeof e=="string"){const t=document.getElementById(e);if(!t)throw new Error(`Could not find element with id '${e}'`);return t}else if(e instanceof HTMLElement)return e;throw new Error(`Invalid element: ${e}`)}function v(e){return e&&e.newWindow===!1?"_self":"_blank"}function Y(e,t={}){const n=Object.hasOwnProperty.call(t,"height")?`${t.height}`:`${V}`,r=Object.hasOwnProperty.call(t,"width")?`${t.width}`:void 0;e.setAttribute("height",n),r?e.setAttribute("width",r):e.setAttribute("style","width:100%;")}function Q(e,t,n={}){var i,a;const r=((a=(i=e.allow)==null?void 0:i.split(";"))==null?void 0:a.map(l=>l.trim()))??[];n.crossOriginIsolated&&!r.includes("cross-origin-isolated")&&r.push("cross-origin-isolated"),r.length>0&&(t.allow=r.join("; "))}class ee{constructor(t){this.pending={},this.port=t,this.port.onmessage=this.messageListener.bind(this)}request({type:t,payload:n}){return new Promise((r,i)=>{const a=L();this.pending[a]={resolve:r,reject:i},this.port.postMessage({type:t,payload:{...n,__reqid:a}})})}messageListener(t){var d;if(typeof((d=t.data.payload)==null?void 0:d.__reqid)!="string")return;const{type:n,payload:r}=t.data,{__reqid:i,__success:a,__error:l}=r;this.pending[i]&&(a?this.pending[i].resolve(this.cleanResult(r)):this.pending[i].reject(l?`${n}: ${l}`:n),delete this.pending[i])}cleanResult(t){const n={...t};return delete n.__reqid,delete n.__success,delete n.__error,Object.keys(n).length?n:null}}class te{constructor(t,n){this.editor={openFile:r=>this._rdc.request({type:"SDK_OPEN_FILE",payload:{path:r}}),setCurrentFile:r=>this._rdc.request({type:"SDK_SET_CURRENT_FILE",payload:{path:r}}),setTheme:r=>this._rdc.request({type:"SDK_SET_UI_THEME",payload:{theme:r}}),setView:r=>this._rdc.request({type:"SDK_SET_UI_VIEW",payload:{view:r}}),showSidebar:(r=!0)=>this._rdc.request({type:"SDK_TOGGLE_SIDEBAR",payload:{visible:r}})},this.preview={origin:"",getUrl:()=>this._rdc.request({type:"SDK_GET_PREVIEW_URL",payload:{}}).then(r=>(r==null?void 0:r.url)??null),setUrl:(r="/")=>{if(typeof r!="string"||!r.startsWith("/"))throw new Error(`Invalid argument: expected a path starting with '/', got '${r}'`);return this._rdc.request({type:"SDK_SET_PREVIEW_URL",payload:{path:r}})}},this._rdc=new ee(t),Object.defineProperty(this.preview,"origin",{value:typeof n.previewOrigin=="string"?n.previewOrigin:null,writable:!1})}applyFsDiff(t){const n=r=>r!==null&&typeof r=="object";if(!n(t)||!n(t.create))throw new Error("Invalid diff object: expected diff.create to be an object.");if(!Array.isArray(t.destroy))throw new Error("Invalid diff object: expected diff.destroy to be an array.");return this._rdc.request({type:"SDK_APPLY_FS_DIFF",payload:t})}getDependencies(){return this._rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})}getFsSnapshot(){return this._rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})}}const y=[];class ne{constructor(t){this.id=L(),this.element=t,this.pending=new Promise((n,r)=>{const i=({data:c,ports:u})=>{(c==null?void 0:c.action)==="SDK_INIT_SUCCESS"&&c.id===this.id&&(this.vm=new te(u[0],c.payload),n(this.vm),l())},a=()=>{var c;(c=this.element.contentWindow)==null||c.postMessage({action:"SDK_INIT",id:this.id},"*")};function l(){window.clearInterval(p),window.removeEventListener("message",i)}window.addEventListener("message",i),a();let d=0;const p=window.setInterval(()=>{if(this.vm){l();return}if(d>=K){l(),r("Timeout: Unable to establish a connection with the StackBlitz VM"),y.forEach((c,u)=>{c.id===this.id&&y.splice(u,1)});return}d++,a()},q)}),y.push(this)}}const re=e=>{const t=e instanceof Element?"element":"id";return y.find(n=>n[t]===e)??null};function ie(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function se(e){return e.replace(/\[/g,"%5B").replace(/\]/g,"%5D")}function C({template:e,title:t,description:n,dependencies:r,files:i,settings:a}){if(!A.includes(e)){const c=A.map(u=>`'${u}'`).join(", ");console.warn(`Unsupported project.template: must be one of ${c}`)}const l=[],d=(c,u,h="")=>{l.push(ie(c,typeof u=="string"?u:h))};d("project[title]",t),typeof n=="string"&&n.length>0&&d("project[description]",n),d("project[template]",e,"javascript"),r&&(e==="node"?console.warn("Invalid project.dependencies: dependencies must be provided as a 'package.json' file when using the 'node' template."):d("project[dependencies]",JSON.stringify(r))),a&&d("project[settings]",JSON.stringify(a)),Object.entries(i).forEach(([c,u])=>{d(`project[files][${se(c)}]`,u)});const p=document.createElement("form");return p.method="POST",p.setAttribute("style","display:none!important;"),p.append(...l),p}function oe(e,t){const n=C(e);return n.action=E("/run",t),n.id="sb_run",`<!doctype html>
1
+ import{r as s,p as R,a as O,j as o,n as N,b as U,s as Z,c as H}from"./index-BD0bOY-g.js";const k=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M71.68,97.22,34.74,128l36.94,30.78a12,12,0,1,1-15.36,18.44l-48-40a12,12,0,0,1,0-18.44l48-40A12,12,0,0,1,71.68,97.22Zm176,21.56-48-40a12,12,0,1,0-15.36,18.44L221.26,128l-36.94,30.78a12,12,0,1,0,15.36,18.44l48-40a12,12,0,0,0,0-18.44ZM164.1,28.72a12,12,0,0,0-15.38,7.18l-64,176a12,12,0,0,0,7.18,15.37A11.79,11.79,0,0,0,96,228a12,12,0,0,0,11.28-7.9l64-176A12,12,0,0,0,164.1,28.72Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M240,128l-48,40H64L16,128,64,88H192Z",opacity:"0.2"}),s.createElement("path",{d:"M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM92.8,145.6a8,8,0,1,1-9.6,12.8l-32-24a8,8,0,0,1,0-12.8l32-24a8,8,0,0,1,9.6,12.8L69.33,128Zm58.89-71.4-32,112a8,8,0,1,1-15.38-4.4l32-112a8,8,0,0,1,15.38,4.4Zm53.11,60.2-32,24a8,8,0,0,1-9.6-12.8L186.67,128,163.2,110.4a8,8,0,1,1,9.6-12.8l32,24a8,8,0,0,1,0,12.8Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M67.84,92.61,25.37,128l42.47,35.39a6,6,0,1,1-7.68,9.22l-48-40a6,6,0,0,1,0-9.22l48-40a6,6,0,0,1,7.68,9.22Zm176,30.78-48-40a6,6,0,1,0-7.68,9.22L230.63,128l-42.47,35.39a6,6,0,1,0,7.68,9.22l48-40a6,6,0,0,0,0-9.22Zm-81.79-89A6,6,0,0,0,154.36,38l-64,176A6,6,0,0,0,94,221.64a6.15,6.15,0,0,0,2,.36,6,6,0,0,0,5.64-3.95l64-176A6,6,0,0,0,162.05,34.36Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M66.56,91.07,22.25,128l44.31,36.93A4,4,0,0,1,64,172a3.94,3.94,0,0,1-2.56-.93l-48-40a4,4,0,0,1,0-6.14l48-40a4,4,0,0,1,5.12,6.14Zm176,33.86-48-40a4,4,0,1,0-5.12,6.14L233.75,128l-44.31,36.93a4,4,0,1,0,5.12,6.14l48-40a4,4,0,0,0,0-6.14ZM161.37,36.24a4,4,0,0,0-5.13,2.39l-64,176a4,4,0,0,0,2.39,5.13A4.12,4.12,0,0,0,96,220a4,4,0,0,0,3.76-2.63l64-176A4,4,0,0,0,161.37,36.24Z"}))]]),M=s.forwardRef((e,t)=>s.createElement(R,{ref:t,...e,weights:k}));M.displayName="CodeIcon";const z=M,q=500,K=20,V=300,B="https://stackblitz.com",A=["angular-cli","create-react-app","html","javascript","node","polymer","typescript","vue"],W=["project","search","ports","settings"],G=["light","dark"],J=["editor","preview"],I={clickToLoad:e=>m("ctl",e),devToolsHeight:e=>$("devtoolsheight",e),forceEmbedLayout:e=>m("embed",e),hideDevTools:e=>m("hidedevtools",e),hideExplorer:e=>m("hideExplorer",e),hideNavigation:e=>m("hideNavigation",e),openFile:e=>g("file",e),showSidebar:e=>X("showSidebar",e),sidebarView:e=>x("sidebarView",e,W),startScript:e=>g("startScript",e),terminalHeight:e=>$("terminalHeight",e),theme:e=>x("theme",e,G),view:e=>x("view",e,J),zenMode:e=>m("zenMode",e),organization:e=>`${g("orgName",e==null?void 0:e.name)}&${g("orgProvider",e==null?void 0:e.provider)}`,crossOriginIsolated:e=>m("corp",e)};function F(e={}){const t=Object.entries(e).map(([n,r])=>r!=null&&I.hasOwnProperty(n)?I[n](r):"").filter(Boolean);return t.length?`?${t.join("&")}`:""}function m(e,t){return t===!0?`${e}=1`:""}function X(e,t){return typeof t=="boolean"?`${e}=${t?"1":"0"}`:""}function $(e,t){if(typeof t=="number"&&!Number.isNaN(t)){const n=Math.min(100,Math.max(0,t));return`${e}=${encodeURIComponent(Math.round(n))}`}return""}function x(e,t="",n=[]){return n.includes(t)?`${e}=${encodeURIComponent(t)}`:""}function g(e,t){return(Array.isArray(t)?t:[t]).filter(r=>typeof r=="string"&&r.trim()!=="").map(r=>`${e}=${encodeURIComponent(r)}`).join("&")}function L(){return Math.random().toString(36).slice(2,6)+Math.random().toString(36).slice(2,6)}function w(e,t){return`${D(t)}${e}${F(t)}`}function E(e,t){const n={forceEmbedLayout:!0};return t&&typeof t=="object"&&Object.assign(n,t),`${D(n)}${e}${F(n)}`}function D(e={}){return(typeof e.origin=="string"?e.origin:B).replace(/\/$/,"")}function _(e,t,n){if(!t||!e||!e.parentNode)throw new Error("Invalid Element");e.id&&(t.id=e.id),e.className&&(t.className=e.className),Y(t,n),Q(e,t,n),e.replaceWith(t)}function j(e){if(typeof e=="string"){const t=document.getElementById(e);if(!t)throw new Error(`Could not find element with id '${e}'`);return t}else if(e instanceof HTMLElement)return e;throw new Error(`Invalid element: ${e}`)}function v(e){return e&&e.newWindow===!1?"_self":"_blank"}function Y(e,t={}){const n=Object.hasOwnProperty.call(t,"height")?`${t.height}`:`${V}`,r=Object.hasOwnProperty.call(t,"width")?`${t.width}`:void 0;e.setAttribute("height",n),r?e.setAttribute("width",r):e.setAttribute("style","width:100%;")}function Q(e,t,n={}){var i,a;const r=((a=(i=e.allow)==null?void 0:i.split(";"))==null?void 0:a.map(l=>l.trim()))??[];n.crossOriginIsolated&&!r.includes("cross-origin-isolated")&&r.push("cross-origin-isolated"),r.length>0&&(t.allow=r.join("; "))}class ee{constructor(t){this.pending={},this.port=t,this.port.onmessage=this.messageListener.bind(this)}request({type:t,payload:n}){return new Promise((r,i)=>{const a=L();this.pending[a]={resolve:r,reject:i},this.port.postMessage({type:t,payload:{...n,__reqid:a}})})}messageListener(t){var d;if(typeof((d=t.data.payload)==null?void 0:d.__reqid)!="string")return;const{type:n,payload:r}=t.data,{__reqid:i,__success:a,__error:l}=r;this.pending[i]&&(a?this.pending[i].resolve(this.cleanResult(r)):this.pending[i].reject(l?`${n}: ${l}`:n),delete this.pending[i])}cleanResult(t){const n={...t};return delete n.__reqid,delete n.__success,delete n.__error,Object.keys(n).length?n:null}}class te{constructor(t,n){this.editor={openFile:r=>this._rdc.request({type:"SDK_OPEN_FILE",payload:{path:r}}),setCurrentFile:r=>this._rdc.request({type:"SDK_SET_CURRENT_FILE",payload:{path:r}}),setTheme:r=>this._rdc.request({type:"SDK_SET_UI_THEME",payload:{theme:r}}),setView:r=>this._rdc.request({type:"SDK_SET_UI_VIEW",payload:{view:r}}),showSidebar:(r=!0)=>this._rdc.request({type:"SDK_TOGGLE_SIDEBAR",payload:{visible:r}})},this.preview={origin:"",getUrl:()=>this._rdc.request({type:"SDK_GET_PREVIEW_URL",payload:{}}).then(r=>(r==null?void 0:r.url)??null),setUrl:(r="/")=>{if(typeof r!="string"||!r.startsWith("/"))throw new Error(`Invalid argument: expected a path starting with '/', got '${r}'`);return this._rdc.request({type:"SDK_SET_PREVIEW_URL",payload:{path:r}})}},this._rdc=new ee(t),Object.defineProperty(this.preview,"origin",{value:typeof n.previewOrigin=="string"?n.previewOrigin:null,writable:!1})}applyFsDiff(t){const n=r=>r!==null&&typeof r=="object";if(!n(t)||!n(t.create))throw new Error("Invalid diff object: expected diff.create to be an object.");if(!Array.isArray(t.destroy))throw new Error("Invalid diff object: expected diff.destroy to be an array.");return this._rdc.request({type:"SDK_APPLY_FS_DIFF",payload:t})}getDependencies(){return this._rdc.request({type:"SDK_GET_DEPS_SNAPSHOT",payload:{}})}getFsSnapshot(){return this._rdc.request({type:"SDK_GET_FS_SNAPSHOT",payload:{}})}}const y=[];class ne{constructor(t){this.id=L(),this.element=t,this.pending=new Promise((n,r)=>{const i=({data:c,ports:u})=>{(c==null?void 0:c.action)==="SDK_INIT_SUCCESS"&&c.id===this.id&&(this.vm=new te(u[0],c.payload),n(this.vm),l())},a=()=>{var c;(c=this.element.contentWindow)==null||c.postMessage({action:"SDK_INIT",id:this.id},"*")};function l(){window.clearInterval(p),window.removeEventListener("message",i)}window.addEventListener("message",i),a();let d=0;const p=window.setInterval(()=>{if(this.vm){l();return}if(d>=K){l(),r("Timeout: Unable to establish a connection with the StackBlitz VM"),y.forEach((c,u)=>{c.id===this.id&&y.splice(u,1)});return}d++,a()},q)}),y.push(this)}}const re=e=>{const t=e instanceof Element?"element":"id";return y.find(n=>n[t]===e)??null};function ie(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n}function se(e){return e.replace(/\[/g,"%5B").replace(/\]/g,"%5D")}function C({template:e,title:t,description:n,dependencies:r,files:i,settings:a}){if(!A.includes(e)){const c=A.map(u=>`'${u}'`).join(", ");console.warn(`Unsupported project.template: must be one of ${c}`)}const l=[],d=(c,u,h="")=>{l.push(ie(c,typeof u=="string"?u:h))};d("project[title]",t),typeof n=="string"&&n.length>0&&d("project[description]",n),d("project[template]",e,"javascript"),r&&(e==="node"?console.warn("Invalid project.dependencies: dependencies must be provided as a 'package.json' file when using the 'node' template."):d("project[dependencies]",JSON.stringify(r))),a&&d("project[settings]",JSON.stringify(a)),Object.entries(i).forEach(([c,u])=>{d(`project[files][${se(c)}]`,u)});const p=document.createElement("form");return p.method="POST",p.setAttribute("style","display:none!important;"),p.append(...l),p}function oe(e,t){const n=C(e);return n.action=E("/run",t),n.id="sb_run",`<!doctype html>
2
2
  <html>
3
3
  <head><title></title></head>
4
4
  <body>