Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

livecodes

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

livecodes - npm Package Compare versions

Comparing version
0.12.0
to
0.13.0
+1
-1
livecodes.cjs

@@ -1,1 +0,1 @@

"use strict";var ee=Object.create;var K=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var se=(c,h)=>()=>(h||c((h={exports:{}}).exports,h),h.exports),ie=(c,h)=>{for(var E in h)K(c,E,{get:h[E],enumerable:!0})},$=(c,h,E,y)=>{if(h&&typeof h=="object"||typeof h=="function")for(let M of ne(h))!re.call(c,M)&&M!==E&&K(c,M,{get:()=>h[M],enumerable:!(y=te(h,M))||y.enumerable});return c};var ae=(c,h,E)=>(E=c!=null?ee(oe(c)):{},$(h||!c||!c.__esModule?K(E,"default",{value:c,enumerable:!0}):E,c)),le=c=>$(K({},"__esModule",{value:!0}),c);var G=se((pe,W)=>{var ce=function(){var c=String.fromCharCode,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",y={};function M(r,e){if(!y[r]){y[r]={};for(var l=0;l<r.length;l++)y[r][r.charAt(l)]=l}return y[r][e]}var A={compressToBase64:function(r){if(r==null)return"";var e=A._compress(r,6,function(l){return h.charAt(l)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(r){return r==null?"":r==""?null:A._decompress(r.length,32,function(e){return M(h,r.charAt(e))})},compressToUTF16:function(r){return r==null?"":A._compress(r,15,function(e){return c(e+32)})+" "},decompressFromUTF16:function(r){return r==null?"":r==""?null:A._decompress(r.length,16384,function(e){return r.charCodeAt(e)-32})},compressToUint8Array:function(r){for(var e=A.compress(r),l=new Uint8Array(e.length*2),n=0,s=e.length;n<s;n++){var m=e.charCodeAt(n);l[n*2]=m>>>8,l[n*2+1]=m%256}return l},decompressFromUint8Array:function(r){if(r==null)return A.decompress(r);for(var e=new Array(r.length/2),l=0,n=e.length;l<n;l++)e[l]=r[l*2]*256+r[l*2+1];var s=[];return e.forEach(function(m){s.push(c(m))}),A.decompress(s.join(""))},compressToEncodedURIComponent:function(r){return r==null?"":A._compress(r,6,function(e){return E.charAt(e)})},decompressFromEncodedURIComponent:function(r){return r==null?"":r==""?null:(r=r.replace(/ /g,"+"),A._decompress(r.length,32,function(e){return M(E,r.charAt(e))}))},compress:function(r){return A._compress(r,16,function(e){return c(e)})},_compress:function(r,e,l){if(r==null)return"";var n,s,m={},v={},w="",O="",g="",S=2,P=3,d=2,f=[],t=0,o=0,x;for(x=0;x<r.length;x+=1)if(w=r.charAt(x),Object.prototype.hasOwnProperty.call(m,w)||(m[w]=P++,v[w]=!0),O=g+w,Object.prototype.hasOwnProperty.call(m,O))g=O;else{if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<d;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<d;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,d),d++),delete v[g]}else for(s=m[g],n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,d),d++),m[O]=P++,g=String(w)}if(g!==""){if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<d;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<d;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,d),d++),delete v[g]}else for(s=m[g],n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,d),d++)}for(s=2,n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;for(;;)if(t=t<<1,o==e-1){f.push(l(t));break}else o++;return f.join("")},decompress:function(r){return r==null?"":r==""?null:A._decompress(r.length,32768,function(e){return r.charCodeAt(e)})},_decompress:function(r,e,l){var n=[],s,m=4,v=4,w=3,O="",g=[],S,P,d,f,t,o,x,a={val:l(0),position:e,index:1};for(S=0;S<3;S+=1)n[S]=S;for(d=0,t=Math.pow(2,2),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;switch(s=d){case 0:for(d=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;x=c(d);break;case 1:for(d=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;x=c(d);break;case 2:return""}for(n[3]=x,P=x,g.push(x);;){if(a.index>r)return"";for(d=0,t=Math.pow(2,w),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;switch(x=d){case 0:for(d=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;n[v++]=c(d),x=v-1,m--;break;case 1:for(d=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;n[v++]=c(d),x=v-1,m--;break;case 2:return g.join("")}if(m==0&&(m=Math.pow(2,w),w++),n[x])O=n[x];else if(x===v)O=P+P.charAt(0);else return null;g.push(O),n[v++]=P+O.charAt(0),m--,P=O,m==0&&(m=Math.pow(2,w),w++)}}};return A}();typeof W!="undefined"&&W!=null&&(W.exports=ce)});var fe={};ie(fe,{createPlayground:()=>de,getPlaygroundUrl:()=>X});module.exports=le(fe);var z=ae(G());async function de(c,h={}){typeof c=="object"&&!(c instanceof HTMLElement)&&(c.headless||c.view==="headless")&&(h=c,c=null);let{config:E={},headless:y,loading:M="lazy",view:A}=h,r=y||A==="headless",e=null,l=null;if(typeof c=="string")e=document.querySelector(c);else if(c instanceof HTMLElement)e=c;else if(!(r&&typeof c=="object"))throw new Error("A valid container element is required.");if(!e)if(r)e=document.createElement("div"),B(e),document.body.appendChild(e);else throw new Error(`Cannot find element: "${c}"`);let n=new URL(X(h)),s=n.origin;n.searchParams.set("embed","true"),n.searchParams.set("loading",r?"eager":M),n.searchParams.set("sdkVersion","0.12.0"),typeof E=="object"&&Object.keys(E).length>0&&n.searchParams.set("config","sdk");let m=h.params;typeof m=="object"&&Object.keys(m).length>0&&JSON.stringify(m).length<1800&&Object.keys(m).forEach(i=>{n.searchParams.set(i,encodeURIComponent(String(m[i])))});let v=!1,w="Cannot call API methods after calling `destroy()`.",O=[],g=(i,u="message")=>{addEventListener(u,i),O.push(i)},P=await new Promise(i=>{var C,U,R,k,j,q,J,N,Q;if(!e)return;let u=e.dataset.height||e.style.height;if(u&&!r){let I=isNaN(Number(u))?u:u+"px";e.style.height=I}e.dataset.defaultStyles!=="false"&&!r&&((C=e.style).backgroundColor||(C.backgroundColor="#fff"),(U=e.style).border||(U.border="1px solid black"),(R=e.style).borderRadius||(R.borderRadius="8px"),(k=e.style).boxSizing||(k.boxSizing="border-box"),(j=e.style).padding||(j.padding="0"),(q=e.style).width||(q.width="100%"),(J=e.style).height||(J.height=e.style.height||"300px"),e.style.minHeight="200px",e.style.flexGrow="1",(N=e.style).overflow||(N.overflow="hidden"),(Q=e.style).resize||(Q.resize="vertical"));let b="livecodes",L=e.querySelector(`iframe.${b}`),p=L||document.createElement("iframe");p.classList.add(b),p.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),p.setAttribute("allowtransparency","true"),p.setAttribute("allowpaymentrequest","true"),p.setAttribute("allowfullscreen","true"),p.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts");let H=M==="eager"?"eager":"lazy";p.setAttribute("loading",H),r?B(p):(p.style.height="100%",p.style.minHeight="200px",p.style.width="100%",p.style.margin="0",p.style.border="0",p.style.borderRadius=e.style.borderRadius),g(function I(T){var _;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-init"||(removeEventListener("message",I),l=Number(T.data.payload.appVersion.replace(/^v/,"")))}),(!l||l<46)&&g(function I(T){var _,Z;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-get-config"||(removeEventListener("message",I),(Z=p.contentWindow)==null||Z.postMessage({type:"livecodes-config",payload:E},s))}),p.onload=()=>{i(p)},p.src=n.href,L||e.appendChild(p)}),d=new Promise(i=>{g(function u(b){var L;b.source!==P.contentWindow||b.origin!==s||((L=b.data)==null?void 0:L.type)!=="livecodes-ready"||(removeEventListener("message",u),i(),d.settled=!0)})}),f=()=>v?Promise.reject(w):new Promise(async i=>{var b;d.settled&&i();let u={type:"livecodes-load"};(b=P.contentWindow)==null||b.postMessage(u,s),await d,i()}),t=(i,u)=>new Promise(async(b,L)=>{var H;if(v)return L(w);await f();let p=V();g(function C(U){var R,k;if(!(U.source!==P.contentWindow||U.origin!==s||((R=U.data)==null?void 0:R.type)!=="livecodes-api-response"||((k=U.data)==null?void 0:k.id)!==p)&&U.data.method===i){removeEventListener("message",C);let j=U.data.payload;j!=null&&j.error?L(j.error):b(j)}}),(H=P.contentWindow)==null||H.postMessage({method:i,id:p,args:u},s)}),o={},x=["load","ready","code","console","tests","destroy"],a=(i,u)=>{var b;if(v)throw new Error(w);return x.includes(i)?(t("watch",[i]),o[i]||(o[i]=[]),(b=o[i])==null||b.push(u),{remove:()=>{var L,p;o[i]=(L=o[i])==null?void 0:L.filter(H=>H!==u),((p=o[i])==null?void 0:p.length)===0&&t("watch",[i,"unsubscribe"])}}):{remove:()=>{}}},Y=i=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[i];g(async function(u){var p,H,C,U;let b=Y((H=(p=u.data)==null?void 0:p.type)!=null?H:"");if(u.source!==P.contentWindow||u.origin!==s||!b||!o[b])return;let L=(C=u.data)==null?void 0:C.payload;(U=o[b])==null||U.forEach(R=>{R(L)})});let F=()=>{var i;(i=P==null?void 0:P.remove)==null||i.call(P),Object.values(o).forEach(u=>{u.length=0}),O.forEach(u=>removeEventListener("message",u)),O.length=0,D&&e&&D.unobserve(e),v=!0},D;M==="lazy"&&"IntersectionObserver"in window&&(D=new IntersectionObserver((i,u)=>{i.forEach(async b=>{b.isIntersecting&&(await f(),u.unobserve(e))})},{rootMargin:"150px"}),D.observe(e));function B(i){i.style.position="absolute",i.style.top="0",i.style.visibility="hidden",i.style.opacity="0"}let V=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>f(),run:()=>t("run"),format:i=>t("format",[i]),getShareUrl:i=>t("getShareUrl",[i]),getConfig:i=>t("getConfig",[i]),setConfig:i=>t("setConfig",[i]),getCode:()=>t("getCode"),show:(i,u)=>t("show",[i,u]),runTests:()=>t("runTests"),onChange:i=>a("code",i),watch:a,exec:(i,...u)=>t("exec",[i,...u]),destroy:()=>v?Promise.reject(w):(F(),Promise.resolve())}}function X(c={}){let{appUrl:h="https://livecodes.io",params:E={},config:y={},headless:M,import:A,lite:r,view:e,...l}=c,n;try{n=new URL(h)}catch(v){throw new Error(`${h} is not a valid URL.`)}let s=new URLSearchParams;Object.entries(l).forEach(([v,w])=>{w!==void 0&&n.searchParams.set(v,String(w))});let m=c.view==="headless"||M;if(r&&(console.warn(`Deprecation notice: "lite" option is deprecated. Use "config: { mode: 'lite' }" instead.`),typeof y=="object"&&y.mode==null?y.mode="lite":n.searchParams.set("lite","true")),e&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),typeof y=="object"&&y.view==null&&e!=="headless"?y.view=e:n.searchParams.set("view",e)),typeof y=="string")try{new URL(y),n.searchParams.set("config",encodeURIComponent(y))}catch(v){throw new Error('"config" is not a valid URL or configuration object.')}else y&&typeof y=="object"&&Object.keys(y).length>0&&(y.title&&y.title!=="Untitled Project"&&n.searchParams.set("title",y.title),y.description&&y.description.length>0&&n.searchParams.set("description",y.description),s.set("config","code/"+(0,z.compressToEncodedURIComponent)(JSON.stringify(y))));if(E&&typeof E=="object"&&Object.keys(E).length>0)try{s.set("params",(0,z.compressToEncodedURIComponent)(JSON.stringify(E)))}catch(v){Object.keys(E).forEach(w=>{n.searchParams.set(w,encodeURIComponent(String(E[w])))})}return A&&n.searchParams.set("x",encodeURIComponent(A)),m&&n.searchParams.set("headless","true"),s.toString().length>0&&(n.hash=s.toString()),n.href}
"use strict";var ee=Object.create;var K=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var se=(c,h)=>()=>(h||c((h={exports:{}}).exports,h),h.exports),ie=(c,h)=>{for(var E in h)K(c,E,{get:h[E],enumerable:!0})},$=(c,h,E,y)=>{if(h&&typeof h=="object"||typeof h=="function")for(let M of ne(h))!re.call(c,M)&&M!==E&&K(c,M,{get:()=>h[M],enumerable:!(y=te(h,M))||y.enumerable});return c};var ae=(c,h,E)=>(E=c!=null?ee(oe(c)):{},$(h||!c||!c.__esModule?K(E,"default",{value:c,enumerable:!0}):E,c)),le=c=>$(K({},"__esModule",{value:!0}),c);var G=se((pe,W)=>{var ce=function(){var c=String.fromCharCode,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",y={};function M(r,e){if(!y[r]){y[r]={};for(var l=0;l<r.length;l++)y[r][r.charAt(l)]=l}return y[r][e]}var A={compressToBase64:function(r){if(r==null)return"";var e=A._compress(r,6,function(l){return h.charAt(l)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(r){return r==null?"":r==""?null:A._decompress(r.length,32,function(e){return M(h,r.charAt(e))})},compressToUTF16:function(r){return r==null?"":A._compress(r,15,function(e){return c(e+32)})+" "},decompressFromUTF16:function(r){return r==null?"":r==""?null:A._decompress(r.length,16384,function(e){return r.charCodeAt(e)-32})},compressToUint8Array:function(r){for(var e=A.compress(r),l=new Uint8Array(e.length*2),n=0,s=e.length;n<s;n++){var m=e.charCodeAt(n);l[n*2]=m>>>8,l[n*2+1]=m%256}return l},decompressFromUint8Array:function(r){if(r==null)return A.decompress(r);for(var e=new Array(r.length/2),l=0,n=e.length;l<n;l++)e[l]=r[l*2]*256+r[l*2+1];var s=[];return e.forEach(function(m){s.push(c(m))}),A.decompress(s.join(""))},compressToEncodedURIComponent:function(r){return r==null?"":A._compress(r,6,function(e){return E.charAt(e)})},decompressFromEncodedURIComponent:function(r){return r==null?"":r==""?null:(r=r.replace(/ /g,"+"),A._decompress(r.length,32,function(e){return M(E,r.charAt(e))}))},compress:function(r){return A._compress(r,16,function(e){return c(e)})},_compress:function(r,e,l){if(r==null)return"";var n,s,m={},v={},w="",O="",g="",S=2,P=3,d=2,f=[],t=0,o=0,x;for(x=0;x<r.length;x+=1)if(w=r.charAt(x),Object.prototype.hasOwnProperty.call(m,w)||(m[w]=P++,v[w]=!0),O=g+w,Object.prototype.hasOwnProperty.call(m,O))g=O;else{if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<d;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<d;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,d),d++),delete v[g]}else for(s=m[g],n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,d),d++),m[O]=P++,g=String(w)}if(g!==""){if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<d;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<d;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,d),d++),delete v[g]}else for(s=m[g],n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,d),d++)}for(s=2,n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;for(;;)if(t=t<<1,o==e-1){f.push(l(t));break}else o++;return f.join("")},decompress:function(r){return r==null?"":r==""?null:A._decompress(r.length,32768,function(e){return r.charCodeAt(e)})},_decompress:function(r,e,l){var n=[],s,m=4,v=4,w=3,O="",g=[],S,P,d,f,t,o,x,a={val:l(0),position:e,index:1};for(S=0;S<3;S+=1)n[S]=S;for(d=0,t=Math.pow(2,2),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;switch(s=d){case 0:for(d=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;x=c(d);break;case 1:for(d=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;x=c(d);break;case 2:return""}for(n[3]=x,P=x,g.push(x);;){if(a.index>r)return"";for(d=0,t=Math.pow(2,w),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;switch(x=d){case 0:for(d=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;n[v++]=c(d),x=v-1,m--;break;case 1:for(d=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;n[v++]=c(d),x=v-1,m--;break;case 2:return g.join("")}if(m==0&&(m=Math.pow(2,w),w++),n[x])O=n[x];else if(x===v)O=P+P.charAt(0);else return null;g.push(O),n[v++]=P+O.charAt(0),m--,P=O,m==0&&(m=Math.pow(2,w),w++)}}};return A}();typeof W!="undefined"&&W!=null&&(W.exports=ce)});var fe={};ie(fe,{createPlayground:()=>de,getPlaygroundUrl:()=>X});module.exports=le(fe);var z=ae(G());async function de(c,h={}){typeof c=="object"&&!(c instanceof HTMLElement)&&(c.headless||c.view==="headless")&&(h=c,c=null);let{config:E={},headless:y,loading:M="lazy",view:A}=h,r=y||A==="headless",e=null,l=null;if(typeof c=="string")e=document.querySelector(c);else if(c instanceof HTMLElement)e=c;else if(!(r&&typeof c=="object"))throw new Error("A valid container element is required.");if(!e)if(r)e=document.createElement("div"),B(e),document.body.appendChild(e);else throw new Error(`Cannot find element: "${c}"`);let n=new URL(X(h)),s=n.origin;n.searchParams.set("embed","true"),n.searchParams.set("loading",r?"eager":M),n.searchParams.set("sdkVersion","0.13.0"),typeof E=="object"&&Object.keys(E).length>0&&n.searchParams.set("config","sdk");let m=h.params;typeof m=="object"&&Object.keys(m).length>0&&JSON.stringify(m).length<1800&&Object.keys(m).forEach(i=>{n.searchParams.set(i,encodeURIComponent(String(m[i])))});let v=!1,w="Cannot call API methods after calling `destroy()`.",O=[],g=(i,u="message")=>{addEventListener(u,i),O.push(i)},P=await new Promise(i=>{var C,U,R,k,j,q,J,N,Q;if(!e)return;let u=e.dataset.height||e.style.height;if(u&&!r){let I=isNaN(Number(u))?u:u+"px";e.style.height=I}e.dataset.defaultStyles!=="false"&&!r&&((C=e.style).backgroundColor||(C.backgroundColor="#fff"),(U=e.style).border||(U.border="1px solid black"),(R=e.style).borderRadius||(R.borderRadius="8px"),(k=e.style).boxSizing||(k.boxSizing="border-box"),(j=e.style).padding||(j.padding="0"),(q=e.style).width||(q.width="100%"),(J=e.style).height||(J.height=e.style.height||"300px"),e.style.minHeight="200px",e.style.flexGrow="1",(N=e.style).overflow||(N.overflow="hidden"),(Q=e.style).resize||(Q.resize="vertical"));let b="livecodes",L=e.querySelector(`iframe.${b}`),p=L||document.createElement("iframe");p.classList.add(b),p.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),p.setAttribute("allowtransparency","true"),p.setAttribute("allowpaymentrequest","true"),p.setAttribute("allowfullscreen","true"),p.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts");let H=M==="eager"?"eager":"lazy";p.setAttribute("loading",H),r?B(p):(p.style.height="100%",p.style.minHeight="200px",p.style.width="100%",p.style.margin="0",p.style.border="0",p.style.borderRadius=e.style.borderRadius),g(function I(T){var _;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-init"||(removeEventListener("message",I),l=Number(T.data.payload.appVersion.replace(/^v/,"")))}),(!l||l<46)&&g(function I(T){var _,Z;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-get-config"||(removeEventListener("message",I),(Z=p.contentWindow)==null||Z.postMessage({type:"livecodes-config",payload:E},s))}),p.onload=()=>{i(p)},p.src=n.href,L||e.appendChild(p)}),d=new Promise(i=>{g(function u(b){var L;b.source!==P.contentWindow||b.origin!==s||((L=b.data)==null?void 0:L.type)!=="livecodes-ready"||(removeEventListener("message",u),i(),d.settled=!0)})}),f=()=>v?Promise.reject(w):new Promise(async i=>{var b;d.settled&&i();let u={type:"livecodes-load"};(b=P.contentWindow)==null||b.postMessage(u,s),await d,i()}),t=(i,u)=>new Promise(async(b,L)=>{var H;if(v)return L(w);await f();let p=V();g(function C(U){var R,k;if(!(U.source!==P.contentWindow||U.origin!==s||((R=U.data)==null?void 0:R.type)!=="livecodes-api-response"||((k=U.data)==null?void 0:k.id)!==p)&&U.data.method===i){removeEventListener("message",C);let j=U.data.payload;j!=null&&j.error?L(j.error):b(j)}}),(H=P.contentWindow)==null||H.postMessage({method:i,id:p,args:u},s)}),o={},x=["load","ready","code","console","tests","destroy"],a=(i,u)=>{var b;if(v)throw new Error(w);return x.includes(i)?(t("watch",[i]),o[i]||(o[i]=[]),(b=o[i])==null||b.push(u),{remove:()=>{var L,p;o[i]=(L=o[i])==null?void 0:L.filter(H=>H!==u),((p=o[i])==null?void 0:p.length)===0&&t("watch",[i,"unsubscribe"])}}):{remove:()=>{}}},Y=i=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[i];g(async function(u){var p,H,C,U;let b=Y((H=(p=u.data)==null?void 0:p.type)!=null?H:"");if(u.source!==P.contentWindow||u.origin!==s||!b||!o[b])return;let L=(C=u.data)==null?void 0:C.payload;(U=o[b])==null||U.forEach(R=>{R(L)})});let F=()=>{var i;(i=P==null?void 0:P.remove)==null||i.call(P),Object.values(o).forEach(u=>{u.length=0}),O.forEach(u=>removeEventListener("message",u)),O.length=0,D&&e&&D.unobserve(e),v=!0},D;M==="lazy"&&"IntersectionObserver"in window&&(D=new IntersectionObserver((i,u)=>{i.forEach(async b=>{b.isIntersecting&&(await f(),u.unobserve(e))})},{rootMargin:"150px"}),D.observe(e));function B(i){i.style.position="absolute",i.style.top="0",i.style.visibility="hidden",i.style.opacity="0"}let V=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>f(),run:()=>t("run"),format:i=>t("format",[i]),getShareUrl:i=>t("getShareUrl",[i]),getConfig:i=>t("getConfig",[i]),setConfig:i=>t("setConfig",[i]),getCode:()=>t("getCode"),show:(i,u)=>t("show",[i,u]),runTests:()=>t("runTests"),onChange:i=>a("code",i),watch:a,exec:(i,...u)=>t("exec",[i,...u]),destroy:()=>v?Promise.reject(w):(F(),Promise.resolve())}}function X(c={}){let{appUrl:h="https://livecodes.io",params:E={},config:y={},headless:M,import:A,lite:r,view:e,...l}=c,n;try{n=new URL(h)}catch(v){throw new Error(`${h} is not a valid URL.`)}let s=new URLSearchParams;Object.entries(l).forEach(([v,w])=>{w!==void 0&&n.searchParams.set(v,String(w))});let m=c.view==="headless"||M;if(r&&(console.warn(`Deprecation notice: "lite" option is deprecated. Use "config: { mode: 'lite' }" instead.`),typeof y=="object"&&y.mode==null?y.mode="lite":n.searchParams.set("lite","true")),e&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),typeof y=="object"&&y.view==null&&e!=="headless"?y.view=e:n.searchParams.set("view",e)),typeof y=="string")try{new URL(y),n.searchParams.set("config",encodeURIComponent(y))}catch(v){throw new Error('"config" is not a valid URL or configuration object.')}else y&&typeof y=="object"&&Object.keys(y).length>0&&(y.title&&y.title!=="Untitled Project"&&n.searchParams.set("title",y.title),y.description&&y.description.length>0&&n.searchParams.set("description",y.description),s.set("config","code/"+(0,z.compressToEncodedURIComponent)(JSON.stringify(y))));if(E&&typeof E=="object"&&Object.keys(E).length>0)try{s.set("params",(0,z.compressToEncodedURIComponent)(JSON.stringify(E)))}catch(v){Object.keys(E).forEach(w=>{n.searchParams.set(w,encodeURIComponent(String(E[w])))})}return A&&n.searchParams.set("x",encodeURIComponent(A)),m&&n.searchParams.set("headless","true"),s.toString().length>0&&(n.hash=s.toString()),n.href}

@@ -1,1 +0,1 @@

var F=Object.create;var Z=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var oe=(d,g)=>()=>(g||d((g={exports:{}}).exports,g),g.exports);var re=(d,g,b,y)=>{if(g&&typeof g=="object"||typeof g=="function")for(let M of ee(g))!ne.call(d,M)&&M!==b&&Z(d,M,{get:()=>g[M],enumerable:!(y=V(g,M))||y.enumerable});return d};var se=(d,g,b)=>(b=d!=null?F(te(d)):{},re(g||!d||!d.__esModule?Z(b,"default",{value:d,enumerable:!0}):b,d));var $=oe((ce,K)=>{var ie=function(){var d=String.fromCharCode,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",y={};function M(r,e){if(!y[r]){y[r]={};for(var l=0;l<r.length;l++)y[r][r.charAt(l)]=l}return y[r][e]}var A={compressToBase64:function(r){if(r==null)return"";var e=A._compress(r,6,function(l){return g.charAt(l)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(r){return r==null?"":r==""?null:A._decompress(r.length,32,function(e){return M(g,r.charAt(e))})},compressToUTF16:function(r){return r==null?"":A._compress(r,15,function(e){return d(e+32)})+" "},decompressFromUTF16:function(r){return r==null?"":r==""?null:A._decompress(r.length,16384,function(e){return r.charCodeAt(e)-32})},compressToUint8Array:function(r){for(var e=A.compress(r),l=new Uint8Array(e.length*2),n=0,s=e.length;n<s;n++){var h=e.charCodeAt(n);l[n*2]=h>>>8,l[n*2+1]=h%256}return l},decompressFromUint8Array:function(r){if(r==null)return A.decompress(r);for(var e=new Array(r.length/2),l=0,n=e.length;l<n;l++)e[l]=r[l*2]*256+r[l*2+1];var s=[];return e.forEach(function(h){s.push(d(h))}),A.decompress(s.join(""))},compressToEncodedURIComponent:function(r){return r==null?"":A._compress(r,6,function(e){return b.charAt(e)})},decompressFromEncodedURIComponent:function(r){return r==null?"":r==""?null:(r=r.replace(/ /g,"+"),A._decompress(r.length,32,function(e){return M(b,r.charAt(e))}))},compress:function(r){return A._compress(r,16,function(e){return d(e)})},_compress:function(r,e,l){if(r==null)return"";var n,s,h={},v={},w="",O="",m="",S=2,P=3,c=2,f=[],t=0,o=0,x;for(x=0;x<r.length;x+=1)if(w=r.charAt(x),Object.prototype.hasOwnProperty.call(h,w)||(h[w]=P++,v[w]=!0),O=m+w,Object.prototype.hasOwnProperty.call(h,O))m=O;else{if(Object.prototype.hasOwnProperty.call(v,m)){if(m.charCodeAt(0)<256){for(n=0;n<c;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=m.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<c;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=m.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,c),c++),delete v[m]}else for(s=h[m],n=0;n<c;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,c),c++),h[O]=P++,m=String(w)}if(m!==""){if(Object.prototype.hasOwnProperty.call(v,m)){if(m.charCodeAt(0)<256){for(n=0;n<c;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=m.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<c;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=m.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,c),c++),delete v[m]}else for(s=h[m],n=0;n<c;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,c),c++)}for(s=2,n=0;n<c;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;for(;;)if(t=t<<1,o==e-1){f.push(l(t));break}else o++;return f.join("")},decompress:function(r){return r==null?"":r==""?null:A._decompress(r.length,32768,function(e){return r.charCodeAt(e)})},_decompress:function(r,e,l){var n=[],s,h=4,v=4,w=3,O="",m=[],S,P,c,f,t,o,x,a={val:l(0),position:e,index:1};for(S=0;S<3;S+=1)n[S]=S;for(c=0,t=Math.pow(2,2),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;switch(s=c){case 0:for(c=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;x=d(c);break;case 1:for(c=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;x=d(c);break;case 2:return""}for(n[3]=x,P=x,m.push(x);;){if(a.index>r)return"";for(c=0,t=Math.pow(2,w),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;switch(x=c){case 0:for(c=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;n[v++]=d(c),x=v-1,h--;break;case 1:for(c=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;n[v++]=d(c),x=v-1,h--;break;case 2:return m.join("")}if(h==0&&(h=Math.pow(2,w),w++),n[x])O=n[x];else if(x===v)O=P+P.charAt(0);else return null;m.push(O),n[v++]=P+O.charAt(0),h--,P=O,h==0&&(h=Math.pow(2,w),w++)}}};return A}();typeof K!="undefined"&&K!=null&&(K.exports=ie)});var W=se($());async function de(d,g={}){typeof d=="object"&&!(d instanceof HTMLElement)&&(d.headless||d.view==="headless")&&(g=d,d=null);let{config:b={},headless:y,loading:M="lazy",view:A}=g,r=y||A==="headless",e=null,l=null;if(typeof d=="string")e=document.querySelector(d);else if(d instanceof HTMLElement)e=d;else if(!(r&&typeof d=="object"))throw new Error("A valid container element is required.");if(!e)if(r)e=document.createElement("div"),z(e),document.body.appendChild(e);else throw new Error(`Cannot find element: "${d}"`);let n=new URL(ae(g)),s=n.origin;n.searchParams.set("embed","true"),n.searchParams.set("loading",r?"eager":M),n.searchParams.set("sdkVersion","0.12.0"),typeof b=="object"&&Object.keys(b).length>0&&n.searchParams.set("config","sdk");let h=g.params;typeof h=="object"&&Object.keys(h).length>0&&JSON.stringify(h).length<1800&&Object.keys(h).forEach(i=>{n.searchParams.set(i,encodeURIComponent(String(h[i])))});let v=!1,w="Cannot call API methods after calling `destroy()`.",O=[],m=(i,u="message")=>{addEventListener(u,i),O.push(i)},P=await new Promise(i=>{var C,U,R,k,j,B,q,J,N;if(!e)return;let u=e.dataset.height||e.style.height;if(u&&!r){let I=isNaN(Number(u))?u:u+"px";e.style.height=I}e.dataset.defaultStyles!=="false"&&!r&&((C=e.style).backgroundColor||(C.backgroundColor="#fff"),(U=e.style).border||(U.border="1px solid black"),(R=e.style).borderRadius||(R.borderRadius="8px"),(k=e.style).boxSizing||(k.boxSizing="border-box"),(j=e.style).padding||(j.padding="0"),(B=e.style).width||(B.width="100%"),(q=e.style).height||(q.height=e.style.height||"300px"),e.style.minHeight="200px",e.style.flexGrow="1",(J=e.style).overflow||(J.overflow="hidden"),(N=e.style).resize||(N.resize="vertical"));let E="livecodes",L=e.querySelector(`iframe.${E}`),p=L||document.createElement("iframe");p.classList.add(E),p.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),p.setAttribute("allowtransparency","true"),p.setAttribute("allowpaymentrequest","true"),p.setAttribute("allowfullscreen","true"),p.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts");let H=M==="eager"?"eager":"lazy";p.setAttribute("loading",H),r?z(p):(p.style.height="100%",p.style.minHeight="200px",p.style.width="100%",p.style.margin="0",p.style.border="0",p.style.borderRadius=e.style.borderRadius),m(function I(T){var _;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-init"||(removeEventListener("message",I),l=Number(T.data.payload.appVersion.replace(/^v/,"")))}),(!l||l<46)&&m(function I(T){var _,Q;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-get-config"||(removeEventListener("message",I),(Q=p.contentWindow)==null||Q.postMessage({type:"livecodes-config",payload:b},s))}),p.onload=()=>{i(p)},p.src=n.href,L||e.appendChild(p)}),c=new Promise(i=>{m(function u(E){var L;E.source!==P.contentWindow||E.origin!==s||((L=E.data)==null?void 0:L.type)!=="livecodes-ready"||(removeEventListener("message",u),i(),c.settled=!0)})}),f=()=>v?Promise.reject(w):new Promise(async i=>{var E;c.settled&&i();let u={type:"livecodes-load"};(E=P.contentWindow)==null||E.postMessage(u,s),await c,i()}),t=(i,u)=>new Promise(async(E,L)=>{var H;if(v)return L(w);await f();let p=Y();m(function C(U){var R,k;if(!(U.source!==P.contentWindow||U.origin!==s||((R=U.data)==null?void 0:R.type)!=="livecodes-api-response"||((k=U.data)==null?void 0:k.id)!==p)&&U.data.method===i){removeEventListener("message",C);let j=U.data.payload;j!=null&&j.error?L(j.error):E(j)}}),(H=P.contentWindow)==null||H.postMessage({method:i,id:p,args:u},s)}),o={},x=["load","ready","code","console","tests","destroy"],a=(i,u)=>{var E;if(v)throw new Error(w);return x.includes(i)?(t("watch",[i]),o[i]||(o[i]=[]),(E=o[i])==null||E.push(u),{remove:()=>{var L,p;o[i]=(L=o[i])==null?void 0:L.filter(H=>H!==u),((p=o[i])==null?void 0:p.length)===0&&t("watch",[i,"unsubscribe"])}}):{remove:()=>{}}},G=i=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[i];m(async function(u){var p,H,C,U;let E=G((H=(p=u.data)==null?void 0:p.type)!=null?H:"");if(u.source!==P.contentWindow||u.origin!==s||!E||!o[E])return;let L=(C=u.data)==null?void 0:C.payload;(U=o[E])==null||U.forEach(R=>{R(L)})});let X=()=>{var i;(i=P==null?void 0:P.remove)==null||i.call(P),Object.values(o).forEach(u=>{u.length=0}),O.forEach(u=>removeEventListener("message",u)),O.length=0,D&&e&&D.unobserve(e),v=!0},D;M==="lazy"&&"IntersectionObserver"in window&&(D=new IntersectionObserver((i,u)=>{i.forEach(async E=>{E.isIntersecting&&(await f(),u.unobserve(e))})},{rootMargin:"150px"}),D.observe(e));function z(i){i.style.position="absolute",i.style.top="0",i.style.visibility="hidden",i.style.opacity="0"}let Y=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>f(),run:()=>t("run"),format:i=>t("format",[i]),getShareUrl:i=>t("getShareUrl",[i]),getConfig:i=>t("getConfig",[i]),setConfig:i=>t("setConfig",[i]),getCode:()=>t("getCode"),show:(i,u)=>t("show",[i,u]),runTests:()=>t("runTests"),onChange:i=>a("code",i),watch:a,exec:(i,...u)=>t("exec",[i,...u]),destroy:()=>v?Promise.reject(w):(X(),Promise.resolve())}}function ae(d={}){let{appUrl:g="https://livecodes.io",params:b={},config:y={},headless:M,import:A,lite:r,view:e,...l}=d,n;try{n=new URL(g)}catch(v){throw new Error(`${g} is not a valid URL.`)}let s=new URLSearchParams;Object.entries(l).forEach(([v,w])=>{w!==void 0&&n.searchParams.set(v,String(w))});let h=d.view==="headless"||M;if(r&&(console.warn(`Deprecation notice: "lite" option is deprecated. Use "config: { mode: 'lite' }" instead.`),typeof y=="object"&&y.mode==null?y.mode="lite":n.searchParams.set("lite","true")),e&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),typeof y=="object"&&y.view==null&&e!=="headless"?y.view=e:n.searchParams.set("view",e)),typeof y=="string")try{new URL(y),n.searchParams.set("config",encodeURIComponent(y))}catch(v){throw new Error('"config" is not a valid URL or configuration object.')}else y&&typeof y=="object"&&Object.keys(y).length>0&&(y.title&&y.title!=="Untitled Project"&&n.searchParams.set("title",y.title),y.description&&y.description.length>0&&n.searchParams.set("description",y.description),s.set("config","code/"+(0,W.compressToEncodedURIComponent)(JSON.stringify(y))));if(b&&typeof b=="object"&&Object.keys(b).length>0)try{s.set("params",(0,W.compressToEncodedURIComponent)(JSON.stringify(b)))}catch(v){Object.keys(b).forEach(w=>{n.searchParams.set(w,encodeURIComponent(String(b[w])))})}return A&&n.searchParams.set("x",encodeURIComponent(A)),h&&n.searchParams.set("headless","true"),s.toString().length>0&&(n.hash=s.toString()),n.href}export{de as createPlayground,ae as getPlaygroundUrl};
var F=Object.create;var Z=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var oe=(d,g)=>()=>(g||d((g={exports:{}}).exports,g),g.exports);var re=(d,g,b,y)=>{if(g&&typeof g=="object"||typeof g=="function")for(let M of ee(g))!ne.call(d,M)&&M!==b&&Z(d,M,{get:()=>g[M],enumerable:!(y=V(g,M))||y.enumerable});return d};var se=(d,g,b)=>(b=d!=null?F(te(d)):{},re(g||!d||!d.__esModule?Z(b,"default",{value:d,enumerable:!0}):b,d));var $=oe((ce,K)=>{var ie=function(){var d=String.fromCharCode,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",y={};function M(r,e){if(!y[r]){y[r]={};for(var l=0;l<r.length;l++)y[r][r.charAt(l)]=l}return y[r][e]}var A={compressToBase64:function(r){if(r==null)return"";var e=A._compress(r,6,function(l){return g.charAt(l)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(r){return r==null?"":r==""?null:A._decompress(r.length,32,function(e){return M(g,r.charAt(e))})},compressToUTF16:function(r){return r==null?"":A._compress(r,15,function(e){return d(e+32)})+" "},decompressFromUTF16:function(r){return r==null?"":r==""?null:A._decompress(r.length,16384,function(e){return r.charCodeAt(e)-32})},compressToUint8Array:function(r){for(var e=A.compress(r),l=new Uint8Array(e.length*2),n=0,s=e.length;n<s;n++){var h=e.charCodeAt(n);l[n*2]=h>>>8,l[n*2+1]=h%256}return l},decompressFromUint8Array:function(r){if(r==null)return A.decompress(r);for(var e=new Array(r.length/2),l=0,n=e.length;l<n;l++)e[l]=r[l*2]*256+r[l*2+1];var s=[];return e.forEach(function(h){s.push(d(h))}),A.decompress(s.join(""))},compressToEncodedURIComponent:function(r){return r==null?"":A._compress(r,6,function(e){return b.charAt(e)})},decompressFromEncodedURIComponent:function(r){return r==null?"":r==""?null:(r=r.replace(/ /g,"+"),A._decompress(r.length,32,function(e){return M(b,r.charAt(e))}))},compress:function(r){return A._compress(r,16,function(e){return d(e)})},_compress:function(r,e,l){if(r==null)return"";var n,s,h={},v={},w="",O="",m="",S=2,P=3,c=2,f=[],t=0,o=0,x;for(x=0;x<r.length;x+=1)if(w=r.charAt(x),Object.prototype.hasOwnProperty.call(h,w)||(h[w]=P++,v[w]=!0),O=m+w,Object.prototype.hasOwnProperty.call(h,O))m=O;else{if(Object.prototype.hasOwnProperty.call(v,m)){if(m.charCodeAt(0)<256){for(n=0;n<c;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=m.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<c;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=m.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,c),c++),delete v[m]}else for(s=h[m],n=0;n<c;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,c),c++),h[O]=P++,m=String(w)}if(m!==""){if(Object.prototype.hasOwnProperty.call(v,m)){if(m.charCodeAt(0)<256){for(n=0;n<c;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=m.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<c;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=m.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,c),c++),delete v[m]}else for(s=h[m],n=0;n<c;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,c),c++)}for(s=2,n=0;n<c;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;for(;;)if(t=t<<1,o==e-1){f.push(l(t));break}else o++;return f.join("")},decompress:function(r){return r==null?"":r==""?null:A._decompress(r.length,32768,function(e){return r.charCodeAt(e)})},_decompress:function(r,e,l){var n=[],s,h=4,v=4,w=3,O="",m=[],S,P,c,f,t,o,x,a={val:l(0),position:e,index:1};for(S=0;S<3;S+=1)n[S]=S;for(c=0,t=Math.pow(2,2),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;switch(s=c){case 0:for(c=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;x=d(c);break;case 1:for(c=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;x=d(c);break;case 2:return""}for(n[3]=x,P=x,m.push(x);;){if(a.index>r)return"";for(c=0,t=Math.pow(2,w),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;switch(x=c){case 0:for(c=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;n[v++]=d(c),x=v-1,h--;break;case 1:for(c=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),c|=(f>0?1:0)*o,o<<=1;n[v++]=d(c),x=v-1,h--;break;case 2:return m.join("")}if(h==0&&(h=Math.pow(2,w),w++),n[x])O=n[x];else if(x===v)O=P+P.charAt(0);else return null;m.push(O),n[v++]=P+O.charAt(0),h--,P=O,h==0&&(h=Math.pow(2,w),w++)}}};return A}();typeof K!="undefined"&&K!=null&&(K.exports=ie)});var W=se($());async function de(d,g={}){typeof d=="object"&&!(d instanceof HTMLElement)&&(d.headless||d.view==="headless")&&(g=d,d=null);let{config:b={},headless:y,loading:M="lazy",view:A}=g,r=y||A==="headless",e=null,l=null;if(typeof d=="string")e=document.querySelector(d);else if(d instanceof HTMLElement)e=d;else if(!(r&&typeof d=="object"))throw new Error("A valid container element is required.");if(!e)if(r)e=document.createElement("div"),z(e),document.body.appendChild(e);else throw new Error(`Cannot find element: "${d}"`);let n=new URL(ae(g)),s=n.origin;n.searchParams.set("embed","true"),n.searchParams.set("loading",r?"eager":M),n.searchParams.set("sdkVersion","0.13.0"),typeof b=="object"&&Object.keys(b).length>0&&n.searchParams.set("config","sdk");let h=g.params;typeof h=="object"&&Object.keys(h).length>0&&JSON.stringify(h).length<1800&&Object.keys(h).forEach(i=>{n.searchParams.set(i,encodeURIComponent(String(h[i])))});let v=!1,w="Cannot call API methods after calling `destroy()`.",O=[],m=(i,u="message")=>{addEventListener(u,i),O.push(i)},P=await new Promise(i=>{var C,U,R,k,j,B,q,J,N;if(!e)return;let u=e.dataset.height||e.style.height;if(u&&!r){let I=isNaN(Number(u))?u:u+"px";e.style.height=I}e.dataset.defaultStyles!=="false"&&!r&&((C=e.style).backgroundColor||(C.backgroundColor="#fff"),(U=e.style).border||(U.border="1px solid black"),(R=e.style).borderRadius||(R.borderRadius="8px"),(k=e.style).boxSizing||(k.boxSizing="border-box"),(j=e.style).padding||(j.padding="0"),(B=e.style).width||(B.width="100%"),(q=e.style).height||(q.height=e.style.height||"300px"),e.style.minHeight="200px",e.style.flexGrow="1",(J=e.style).overflow||(J.overflow="hidden"),(N=e.style).resize||(N.resize="vertical"));let E="livecodes",L=e.querySelector(`iframe.${E}`),p=L||document.createElement("iframe");p.classList.add(E),p.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),p.setAttribute("allowtransparency","true"),p.setAttribute("allowpaymentrequest","true"),p.setAttribute("allowfullscreen","true"),p.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts");let H=M==="eager"?"eager":"lazy";p.setAttribute("loading",H),r?z(p):(p.style.height="100%",p.style.minHeight="200px",p.style.width="100%",p.style.margin="0",p.style.border="0",p.style.borderRadius=e.style.borderRadius),m(function I(T){var _;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-init"||(removeEventListener("message",I),l=Number(T.data.payload.appVersion.replace(/^v/,"")))}),(!l||l<46)&&m(function I(T){var _,Q;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-get-config"||(removeEventListener("message",I),(Q=p.contentWindow)==null||Q.postMessage({type:"livecodes-config",payload:b},s))}),p.onload=()=>{i(p)},p.src=n.href,L||e.appendChild(p)}),c=new Promise(i=>{m(function u(E){var L;E.source!==P.contentWindow||E.origin!==s||((L=E.data)==null?void 0:L.type)!=="livecodes-ready"||(removeEventListener("message",u),i(),c.settled=!0)})}),f=()=>v?Promise.reject(w):new Promise(async i=>{var E;c.settled&&i();let u={type:"livecodes-load"};(E=P.contentWindow)==null||E.postMessage(u,s),await c,i()}),t=(i,u)=>new Promise(async(E,L)=>{var H;if(v)return L(w);await f();let p=Y();m(function C(U){var R,k;if(!(U.source!==P.contentWindow||U.origin!==s||((R=U.data)==null?void 0:R.type)!=="livecodes-api-response"||((k=U.data)==null?void 0:k.id)!==p)&&U.data.method===i){removeEventListener("message",C);let j=U.data.payload;j!=null&&j.error?L(j.error):E(j)}}),(H=P.contentWindow)==null||H.postMessage({method:i,id:p,args:u},s)}),o={},x=["load","ready","code","console","tests","destroy"],a=(i,u)=>{var E;if(v)throw new Error(w);return x.includes(i)?(t("watch",[i]),o[i]||(o[i]=[]),(E=o[i])==null||E.push(u),{remove:()=>{var L,p;o[i]=(L=o[i])==null?void 0:L.filter(H=>H!==u),((p=o[i])==null?void 0:p.length)===0&&t("watch",[i,"unsubscribe"])}}):{remove:()=>{}}},G=i=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[i];m(async function(u){var p,H,C,U;let E=G((H=(p=u.data)==null?void 0:p.type)!=null?H:"");if(u.source!==P.contentWindow||u.origin!==s||!E||!o[E])return;let L=(C=u.data)==null?void 0:C.payload;(U=o[E])==null||U.forEach(R=>{R(L)})});let X=()=>{var i;(i=P==null?void 0:P.remove)==null||i.call(P),Object.values(o).forEach(u=>{u.length=0}),O.forEach(u=>removeEventListener("message",u)),O.length=0,D&&e&&D.unobserve(e),v=!0},D;M==="lazy"&&"IntersectionObserver"in window&&(D=new IntersectionObserver((i,u)=>{i.forEach(async E=>{E.isIntersecting&&(await f(),u.unobserve(e))})},{rootMargin:"150px"}),D.observe(e));function z(i){i.style.position="absolute",i.style.top="0",i.style.visibility="hidden",i.style.opacity="0"}let Y=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>f(),run:()=>t("run"),format:i=>t("format",[i]),getShareUrl:i=>t("getShareUrl",[i]),getConfig:i=>t("getConfig",[i]),setConfig:i=>t("setConfig",[i]),getCode:()=>t("getCode"),show:(i,u)=>t("show",[i,u]),runTests:()=>t("runTests"),onChange:i=>a("code",i),watch:a,exec:(i,...u)=>t("exec",[i,...u]),destroy:()=>v?Promise.reject(w):(X(),Promise.resolve())}}function ae(d={}){let{appUrl:g="https://livecodes.io",params:b={},config:y={},headless:M,import:A,lite:r,view:e,...l}=d,n;try{n=new URL(g)}catch(v){throw new Error(`${g} is not a valid URL.`)}let s=new URLSearchParams;Object.entries(l).forEach(([v,w])=>{w!==void 0&&n.searchParams.set(v,String(w))});let h=d.view==="headless"||M;if(r&&(console.warn(`Deprecation notice: "lite" option is deprecated. Use "config: { mode: 'lite' }" instead.`),typeof y=="object"&&y.mode==null?y.mode="lite":n.searchParams.set("lite","true")),e&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),typeof y=="object"&&y.view==null&&e!=="headless"?y.view=e:n.searchParams.set("view",e)),typeof y=="string")try{new URL(y),n.searchParams.set("config",encodeURIComponent(y))}catch(v){throw new Error('"config" is not a valid URL or configuration object.')}else y&&typeof y=="object"&&Object.keys(y).length>0&&(y.title&&y.title!=="Untitled Project"&&n.searchParams.set("title",y.title),y.description&&y.description.length>0&&n.searchParams.set("description",y.description),s.set("config","code/"+(0,W.compressToEncodedURIComponent)(JSON.stringify(y))));if(b&&typeof b=="object"&&Object.keys(b).length>0)try{s.set("params",(0,W.compressToEncodedURIComponent)(JSON.stringify(b)))}catch(v){Object.keys(b).forEach(w=>{n.searchParams.set(w,encodeURIComponent(String(b[w])))})}return A&&n.searchParams.set("x",encodeURIComponent(A)),h&&n.searchParams.set("headless","true"),s.toString().length>0&&(n.hash=s.toString()),n.href}export{de as createPlayground,ae as getPlaygroundUrl};

@@ -1,1 +0,1 @@

"use strict";var livecodes=(()=>{var ee=Object.create;var K=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var se=(c,h)=>()=>(h||c((h={exports:{}}).exports,h),h.exports),ie=(c,h)=>{for(var E in h)K(c,E,{get:h[E],enumerable:!0})},$=(c,h,E,y)=>{if(h&&typeof h=="object"||typeof h=="function")for(let M of ne(h))!re.call(c,M)&&M!==E&&K(c,M,{get:()=>h[M],enumerable:!(y=te(h,M))||y.enumerable});return c};var ae=(c,h,E)=>(E=c!=null?ee(oe(c)):{},$(h||!c||!c.__esModule?K(E,"default",{value:c,enumerable:!0}):E,c)),le=c=>$(K({},"__esModule",{value:!0}),c);var G=se((pe,W)=>{var ce=function(){var c=String.fromCharCode,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",y={};function M(r,e){if(!y[r]){y[r]={};for(var l=0;l<r.length;l++)y[r][r.charAt(l)]=l}return y[r][e]}var A={compressToBase64:function(r){if(r==null)return"";var e=A._compress(r,6,function(l){return h.charAt(l)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(r){return r==null?"":r==""?null:A._decompress(r.length,32,function(e){return M(h,r.charAt(e))})},compressToUTF16:function(r){return r==null?"":A._compress(r,15,function(e){return c(e+32)})+" "},decompressFromUTF16:function(r){return r==null?"":r==""?null:A._decompress(r.length,16384,function(e){return r.charCodeAt(e)-32})},compressToUint8Array:function(r){for(var e=A.compress(r),l=new Uint8Array(e.length*2),n=0,s=e.length;n<s;n++){var m=e.charCodeAt(n);l[n*2]=m>>>8,l[n*2+1]=m%256}return l},decompressFromUint8Array:function(r){if(r==null)return A.decompress(r);for(var e=new Array(r.length/2),l=0,n=e.length;l<n;l++)e[l]=r[l*2]*256+r[l*2+1];var s=[];return e.forEach(function(m){s.push(c(m))}),A.decompress(s.join(""))},compressToEncodedURIComponent:function(r){return r==null?"":A._compress(r,6,function(e){return E.charAt(e)})},decompressFromEncodedURIComponent:function(r){return r==null?"":r==""?null:(r=r.replace(/ /g,"+"),A._decompress(r.length,32,function(e){return M(E,r.charAt(e))}))},compress:function(r){return A._compress(r,16,function(e){return c(e)})},_compress:function(r,e,l){if(r==null)return"";var n,s,m={},v={},w="",O="",g="",S=2,P=3,d=2,f=[],t=0,o=0,x;for(x=0;x<r.length;x+=1)if(w=r.charAt(x),Object.prototype.hasOwnProperty.call(m,w)||(m[w]=P++,v[w]=!0),O=g+w,Object.prototype.hasOwnProperty.call(m,O))g=O;else{if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<d;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<d;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,d),d++),delete v[g]}else for(s=m[g],n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,d),d++),m[O]=P++,g=String(w)}if(g!==""){if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<d;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<d;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,d),d++),delete v[g]}else for(s=m[g],n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,d),d++)}for(s=2,n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;for(;;)if(t=t<<1,o==e-1){f.push(l(t));break}else o++;return f.join("")},decompress:function(r){return r==null?"":r==""?null:A._decompress(r.length,32768,function(e){return r.charCodeAt(e)})},_decompress:function(r,e,l){var n=[],s,m=4,v=4,w=3,O="",g=[],S,P,d,f,t,o,x,a={val:l(0),position:e,index:1};for(S=0;S<3;S+=1)n[S]=S;for(d=0,t=Math.pow(2,2),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;switch(s=d){case 0:for(d=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;x=c(d);break;case 1:for(d=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;x=c(d);break;case 2:return""}for(n[3]=x,P=x,g.push(x);;){if(a.index>r)return"";for(d=0,t=Math.pow(2,w),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;switch(x=d){case 0:for(d=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;n[v++]=c(d),x=v-1,m--;break;case 1:for(d=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;n[v++]=c(d),x=v-1,m--;break;case 2:return g.join("")}if(m==0&&(m=Math.pow(2,w),w++),n[x])O=n[x];else if(x===v)O=P+P.charAt(0);else return null;g.push(O),n[v++]=P+O.charAt(0),m--,P=O,m==0&&(m=Math.pow(2,w),w++)}}};return A}();typeof W!="undefined"&&W!=null&&(W.exports=ce)});var fe={};ie(fe,{createPlayground:()=>de,getPlaygroundUrl:()=>X});var z=ae(G());async function de(c,h={}){typeof c=="object"&&!(c instanceof HTMLElement)&&(c.headless||c.view==="headless")&&(h=c,c=null);let{config:E={},headless:y,loading:M="lazy",view:A}=h,r=y||A==="headless",e=null,l=null;if(typeof c=="string")e=document.querySelector(c);else if(c instanceof HTMLElement)e=c;else if(!(r&&typeof c=="object"))throw new Error("A valid container element is required.");if(!e)if(r)e=document.createElement("div"),B(e),document.body.appendChild(e);else throw new Error(`Cannot find element: "${c}"`);let n=new URL(X(h)),s=n.origin;n.searchParams.set("embed","true"),n.searchParams.set("loading",r?"eager":M),n.searchParams.set("sdkVersion","0.12.0"),typeof E=="object"&&Object.keys(E).length>0&&n.searchParams.set("config","sdk");let m=h.params;typeof m=="object"&&Object.keys(m).length>0&&JSON.stringify(m).length<1800&&Object.keys(m).forEach(i=>{n.searchParams.set(i,encodeURIComponent(String(m[i])))});let v=!1,w="Cannot call API methods after calling `destroy()`.",O=[],g=(i,u="message")=>{addEventListener(u,i),O.push(i)},P=await new Promise(i=>{var C,U,R,k,j,q,J,N,Q;if(!e)return;let u=e.dataset.height||e.style.height;if(u&&!r){let I=isNaN(Number(u))?u:u+"px";e.style.height=I}e.dataset.defaultStyles!=="false"&&!r&&((C=e.style).backgroundColor||(C.backgroundColor="#fff"),(U=e.style).border||(U.border="1px solid black"),(R=e.style).borderRadius||(R.borderRadius="8px"),(k=e.style).boxSizing||(k.boxSizing="border-box"),(j=e.style).padding||(j.padding="0"),(q=e.style).width||(q.width="100%"),(J=e.style).height||(J.height=e.style.height||"300px"),e.style.minHeight="200px",e.style.flexGrow="1",(N=e.style).overflow||(N.overflow="hidden"),(Q=e.style).resize||(Q.resize="vertical"));let b="livecodes",L=e.querySelector(`iframe.${b}`),p=L||document.createElement("iframe");p.classList.add(b),p.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),p.setAttribute("allowtransparency","true"),p.setAttribute("allowpaymentrequest","true"),p.setAttribute("allowfullscreen","true"),p.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts");let H=M==="eager"?"eager":"lazy";p.setAttribute("loading",H),r?B(p):(p.style.height="100%",p.style.minHeight="200px",p.style.width="100%",p.style.margin="0",p.style.border="0",p.style.borderRadius=e.style.borderRadius),g(function I(T){var _;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-init"||(removeEventListener("message",I),l=Number(T.data.payload.appVersion.replace(/^v/,"")))}),(!l||l<46)&&g(function I(T){var _,Z;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-get-config"||(removeEventListener("message",I),(Z=p.contentWindow)==null||Z.postMessage({type:"livecodes-config",payload:E},s))}),p.onload=()=>{i(p)},p.src=n.href,L||e.appendChild(p)}),d=new Promise(i=>{g(function u(b){var L;b.source!==P.contentWindow||b.origin!==s||((L=b.data)==null?void 0:L.type)!=="livecodes-ready"||(removeEventListener("message",u),i(),d.settled=!0)})}),f=()=>v?Promise.reject(w):new Promise(async i=>{var b;d.settled&&i();let u={type:"livecodes-load"};(b=P.contentWindow)==null||b.postMessage(u,s),await d,i()}),t=(i,u)=>new Promise(async(b,L)=>{var H;if(v)return L(w);await f();let p=V();g(function C(U){var R,k;if(!(U.source!==P.contentWindow||U.origin!==s||((R=U.data)==null?void 0:R.type)!=="livecodes-api-response"||((k=U.data)==null?void 0:k.id)!==p)&&U.data.method===i){removeEventListener("message",C);let j=U.data.payload;j!=null&&j.error?L(j.error):b(j)}}),(H=P.contentWindow)==null||H.postMessage({method:i,id:p,args:u},s)}),o={},x=["load","ready","code","console","tests","destroy"],a=(i,u)=>{var b;if(v)throw new Error(w);return x.includes(i)?(t("watch",[i]),o[i]||(o[i]=[]),(b=o[i])==null||b.push(u),{remove:()=>{var L,p;o[i]=(L=o[i])==null?void 0:L.filter(H=>H!==u),((p=o[i])==null?void 0:p.length)===0&&t("watch",[i,"unsubscribe"])}}):{remove:()=>{}}},Y=i=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[i];g(async function(u){var p,H,C,U;let b=Y((H=(p=u.data)==null?void 0:p.type)!=null?H:"");if(u.source!==P.contentWindow||u.origin!==s||!b||!o[b])return;let L=(C=u.data)==null?void 0:C.payload;(U=o[b])==null||U.forEach(R=>{R(L)})});let F=()=>{var i;(i=P==null?void 0:P.remove)==null||i.call(P),Object.values(o).forEach(u=>{u.length=0}),O.forEach(u=>removeEventListener("message",u)),O.length=0,D&&e&&D.unobserve(e),v=!0},D;M==="lazy"&&"IntersectionObserver"in window&&(D=new IntersectionObserver((i,u)=>{i.forEach(async b=>{b.isIntersecting&&(await f(),u.unobserve(e))})},{rootMargin:"150px"}),D.observe(e));function B(i){i.style.position="absolute",i.style.top="0",i.style.visibility="hidden",i.style.opacity="0"}let V=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>f(),run:()=>t("run"),format:i=>t("format",[i]),getShareUrl:i=>t("getShareUrl",[i]),getConfig:i=>t("getConfig",[i]),setConfig:i=>t("setConfig",[i]),getCode:()=>t("getCode"),show:(i,u)=>t("show",[i,u]),runTests:()=>t("runTests"),onChange:i=>a("code",i),watch:a,exec:(i,...u)=>t("exec",[i,...u]),destroy:()=>v?Promise.reject(w):(F(),Promise.resolve())}}function X(c={}){let{appUrl:h="https://livecodes.io",params:E={},config:y={},headless:M,import:A,lite:r,view:e,...l}=c,n;try{n=new URL(h)}catch(v){throw new Error(`${h} is not a valid URL.`)}let s=new URLSearchParams;Object.entries(l).forEach(([v,w])=>{w!==void 0&&n.searchParams.set(v,String(w))});let m=c.view==="headless"||M;if(r&&(console.warn(`Deprecation notice: "lite" option is deprecated. Use "config: { mode: 'lite' }" instead.`),typeof y=="object"&&y.mode==null?y.mode="lite":n.searchParams.set("lite","true")),e&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),typeof y=="object"&&y.view==null&&e!=="headless"?y.view=e:n.searchParams.set("view",e)),typeof y=="string")try{new URL(y),n.searchParams.set("config",encodeURIComponent(y))}catch(v){throw new Error('"config" is not a valid URL or configuration object.')}else y&&typeof y=="object"&&Object.keys(y).length>0&&(y.title&&y.title!=="Untitled Project"&&n.searchParams.set("title",y.title),y.description&&y.description.length>0&&n.searchParams.set("description",y.description),s.set("config","code/"+(0,z.compressToEncodedURIComponent)(JSON.stringify(y))));if(E&&typeof E=="object"&&Object.keys(E).length>0)try{s.set("params",(0,z.compressToEncodedURIComponent)(JSON.stringify(E)))}catch(v){Object.keys(E).forEach(w=>{n.searchParams.set(w,encodeURIComponent(String(E[w])))})}return A&&n.searchParams.set("x",encodeURIComponent(A)),m&&n.searchParams.set("headless","true"),s.toString().length>0&&(n.hash=s.toString()),n.href}return le(fe);})();
"use strict";var livecodes=(()=>{var ee=Object.create;var K=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var se=(c,h)=>()=>(h||c((h={exports:{}}).exports,h),h.exports),ie=(c,h)=>{for(var E in h)K(c,E,{get:h[E],enumerable:!0})},$=(c,h,E,y)=>{if(h&&typeof h=="object"||typeof h=="function")for(let M of ne(h))!re.call(c,M)&&M!==E&&K(c,M,{get:()=>h[M],enumerable:!(y=te(h,M))||y.enumerable});return c};var ae=(c,h,E)=>(E=c!=null?ee(oe(c)):{},$(h||!c||!c.__esModule?K(E,"default",{value:c,enumerable:!0}):E,c)),le=c=>$(K({},"__esModule",{value:!0}),c);var G=se((pe,W)=>{var ce=function(){var c=String.fromCharCode,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",y={};function M(r,e){if(!y[r]){y[r]={};for(var l=0;l<r.length;l++)y[r][r.charAt(l)]=l}return y[r][e]}var A={compressToBase64:function(r){if(r==null)return"";var e=A._compress(r,6,function(l){return h.charAt(l)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(r){return r==null?"":r==""?null:A._decompress(r.length,32,function(e){return M(h,r.charAt(e))})},compressToUTF16:function(r){return r==null?"":A._compress(r,15,function(e){return c(e+32)})+" "},decompressFromUTF16:function(r){return r==null?"":r==""?null:A._decompress(r.length,16384,function(e){return r.charCodeAt(e)-32})},compressToUint8Array:function(r){for(var e=A.compress(r),l=new Uint8Array(e.length*2),n=0,s=e.length;n<s;n++){var m=e.charCodeAt(n);l[n*2]=m>>>8,l[n*2+1]=m%256}return l},decompressFromUint8Array:function(r){if(r==null)return A.decompress(r);for(var e=new Array(r.length/2),l=0,n=e.length;l<n;l++)e[l]=r[l*2]*256+r[l*2+1];var s=[];return e.forEach(function(m){s.push(c(m))}),A.decompress(s.join(""))},compressToEncodedURIComponent:function(r){return r==null?"":A._compress(r,6,function(e){return E.charAt(e)})},decompressFromEncodedURIComponent:function(r){return r==null?"":r==""?null:(r=r.replace(/ /g,"+"),A._decompress(r.length,32,function(e){return M(E,r.charAt(e))}))},compress:function(r){return A._compress(r,16,function(e){return c(e)})},_compress:function(r,e,l){if(r==null)return"";var n,s,m={},v={},w="",O="",g="",S=2,P=3,d=2,f=[],t=0,o=0,x;for(x=0;x<r.length;x+=1)if(w=r.charAt(x),Object.prototype.hasOwnProperty.call(m,w)||(m[w]=P++,v[w]=!0),O=g+w,Object.prototype.hasOwnProperty.call(m,O))g=O;else{if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<d;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<d;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,d),d++),delete v[g]}else for(s=m[g],n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,d),d++),m[O]=P++,g=String(w)}if(g!==""){if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<d;n++)t=t<<1,o==e-1?(o=0,f.push(l(t)),t=0):o++;for(s=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}else{for(s=1,n=0;n<d;n++)t=t<<1|s,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=0;for(s=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1}S--,S==0&&(S=Math.pow(2,d),d++),delete v[g]}else for(s=m[g],n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;S--,S==0&&(S=Math.pow(2,d),d++)}for(s=2,n=0;n<d;n++)t=t<<1|s&1,o==e-1?(o=0,f.push(l(t)),t=0):o++,s=s>>1;for(;;)if(t=t<<1,o==e-1){f.push(l(t));break}else o++;return f.join("")},decompress:function(r){return r==null?"":r==""?null:A._decompress(r.length,32768,function(e){return r.charCodeAt(e)})},_decompress:function(r,e,l){var n=[],s,m=4,v=4,w=3,O="",g=[],S,P,d,f,t,o,x,a={val:l(0),position:e,index:1};for(S=0;S<3;S+=1)n[S]=S;for(d=0,t=Math.pow(2,2),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;switch(s=d){case 0:for(d=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;x=c(d);break;case 1:for(d=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;x=c(d);break;case 2:return""}for(n[3]=x,P=x,g.push(x);;){if(a.index>r)return"";for(d=0,t=Math.pow(2,w),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;switch(x=d){case 0:for(d=0,t=Math.pow(2,8),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;n[v++]=c(d),x=v-1,m--;break;case 1:for(d=0,t=Math.pow(2,16),o=1;o!=t;)f=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),d|=(f>0?1:0)*o,o<<=1;n[v++]=c(d),x=v-1,m--;break;case 2:return g.join("")}if(m==0&&(m=Math.pow(2,w),w++),n[x])O=n[x];else if(x===v)O=P+P.charAt(0);else return null;g.push(O),n[v++]=P+O.charAt(0),m--,P=O,m==0&&(m=Math.pow(2,w),w++)}}};return A}();typeof W!="undefined"&&W!=null&&(W.exports=ce)});var fe={};ie(fe,{createPlayground:()=>de,getPlaygroundUrl:()=>X});var z=ae(G());async function de(c,h={}){typeof c=="object"&&!(c instanceof HTMLElement)&&(c.headless||c.view==="headless")&&(h=c,c=null);let{config:E={},headless:y,loading:M="lazy",view:A}=h,r=y||A==="headless",e=null,l=null;if(typeof c=="string")e=document.querySelector(c);else if(c instanceof HTMLElement)e=c;else if(!(r&&typeof c=="object"))throw new Error("A valid container element is required.");if(!e)if(r)e=document.createElement("div"),B(e),document.body.appendChild(e);else throw new Error(`Cannot find element: "${c}"`);let n=new URL(X(h)),s=n.origin;n.searchParams.set("embed","true"),n.searchParams.set("loading",r?"eager":M),n.searchParams.set("sdkVersion","0.13.0"),typeof E=="object"&&Object.keys(E).length>0&&n.searchParams.set("config","sdk");let m=h.params;typeof m=="object"&&Object.keys(m).length>0&&JSON.stringify(m).length<1800&&Object.keys(m).forEach(i=>{n.searchParams.set(i,encodeURIComponent(String(m[i])))});let v=!1,w="Cannot call API methods after calling `destroy()`.",O=[],g=(i,u="message")=>{addEventListener(u,i),O.push(i)},P=await new Promise(i=>{var C,U,R,k,j,q,J,N,Q;if(!e)return;let u=e.dataset.height||e.style.height;if(u&&!r){let I=isNaN(Number(u))?u:u+"px";e.style.height=I}e.dataset.defaultStyles!=="false"&&!r&&((C=e.style).backgroundColor||(C.backgroundColor="#fff"),(U=e.style).border||(U.border="1px solid black"),(R=e.style).borderRadius||(R.borderRadius="8px"),(k=e.style).boxSizing||(k.boxSizing="border-box"),(j=e.style).padding||(j.padding="0"),(q=e.style).width||(q.width="100%"),(J=e.style).height||(J.height=e.style.height||"300px"),e.style.minHeight="200px",e.style.flexGrow="1",(N=e.style).overflow||(N.overflow="hidden"),(Q=e.style).resize||(Q.resize="vertical"));let b="livecodes",L=e.querySelector(`iframe.${b}`),p=L||document.createElement("iframe");p.classList.add(b),p.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),p.setAttribute("allowtransparency","true"),p.setAttribute("allowpaymentrequest","true"),p.setAttribute("allowfullscreen","true"),p.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts");let H=M==="eager"?"eager":"lazy";p.setAttribute("loading",H),r?B(p):(p.style.height="100%",p.style.minHeight="200px",p.style.width="100%",p.style.margin="0",p.style.border="0",p.style.borderRadius=e.style.borderRadius),g(function I(T){var _;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-init"||(removeEventListener("message",I),l=Number(T.data.payload.appVersion.replace(/^v/,"")))}),(!l||l<46)&&g(function I(T){var _,Z;T.source!==p.contentWindow||T.origin!==s||((_=T.data)==null?void 0:_.type)!=="livecodes-get-config"||(removeEventListener("message",I),(Z=p.contentWindow)==null||Z.postMessage({type:"livecodes-config",payload:E},s))}),p.onload=()=>{i(p)},p.src=n.href,L||e.appendChild(p)}),d=new Promise(i=>{g(function u(b){var L;b.source!==P.contentWindow||b.origin!==s||((L=b.data)==null?void 0:L.type)!=="livecodes-ready"||(removeEventListener("message",u),i(),d.settled=!0)})}),f=()=>v?Promise.reject(w):new Promise(async i=>{var b;d.settled&&i();let u={type:"livecodes-load"};(b=P.contentWindow)==null||b.postMessage(u,s),await d,i()}),t=(i,u)=>new Promise(async(b,L)=>{var H;if(v)return L(w);await f();let p=V();g(function C(U){var R,k;if(!(U.source!==P.contentWindow||U.origin!==s||((R=U.data)==null?void 0:R.type)!=="livecodes-api-response"||((k=U.data)==null?void 0:k.id)!==p)&&U.data.method===i){removeEventListener("message",C);let j=U.data.payload;j!=null&&j.error?L(j.error):b(j)}}),(H=P.contentWindow)==null||H.postMessage({method:i,id:p,args:u},s)}),o={},x=["load","ready","code","console","tests","destroy"],a=(i,u)=>{var b;if(v)throw new Error(w);return x.includes(i)?(t("watch",[i]),o[i]||(o[i]=[]),(b=o[i])==null||b.push(u),{remove:()=>{var L,p;o[i]=(L=o[i])==null?void 0:L.filter(H=>H!==u),((p=o[i])==null?void 0:p.length)===0&&t("watch",[i,"unsubscribe"])}}):{remove:()=>{}}},Y=i=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[i];g(async function(u){var p,H,C,U;let b=Y((H=(p=u.data)==null?void 0:p.type)!=null?H:"");if(u.source!==P.contentWindow||u.origin!==s||!b||!o[b])return;let L=(C=u.data)==null?void 0:C.payload;(U=o[b])==null||U.forEach(R=>{R(L)})});let F=()=>{var i;(i=P==null?void 0:P.remove)==null||i.call(P),Object.values(o).forEach(u=>{u.length=0}),O.forEach(u=>removeEventListener("message",u)),O.length=0,D&&e&&D.unobserve(e),v=!0},D;M==="lazy"&&"IntersectionObserver"in window&&(D=new IntersectionObserver((i,u)=>{i.forEach(async b=>{b.isIntersecting&&(await f(),u.unobserve(e))})},{rootMargin:"150px"}),D.observe(e));function B(i){i.style.position="absolute",i.style.top="0",i.style.visibility="hidden",i.style.opacity="0"}let V=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>f(),run:()=>t("run"),format:i=>t("format",[i]),getShareUrl:i=>t("getShareUrl",[i]),getConfig:i=>t("getConfig",[i]),setConfig:i=>t("setConfig",[i]),getCode:()=>t("getCode"),show:(i,u)=>t("show",[i,u]),runTests:()=>t("runTests"),onChange:i=>a("code",i),watch:a,exec:(i,...u)=>t("exec",[i,...u]),destroy:()=>v?Promise.reject(w):(F(),Promise.resolve())}}function X(c={}){let{appUrl:h="https://livecodes.io",params:E={},config:y={},headless:M,import:A,lite:r,view:e,...l}=c,n;try{n=new URL(h)}catch(v){throw new Error(`${h} is not a valid URL.`)}let s=new URLSearchParams;Object.entries(l).forEach(([v,w])=>{w!==void 0&&n.searchParams.set(v,String(w))});let m=c.view==="headless"||M;if(r&&(console.warn(`Deprecation notice: "lite" option is deprecated. Use "config: { mode: 'lite' }" instead.`),typeof y=="object"&&y.mode==null?y.mode="lite":n.searchParams.set("lite","true")),e&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),typeof y=="object"&&y.view==null&&e!=="headless"?y.view=e:n.searchParams.set("view",e)),typeof y=="string")try{new URL(y),n.searchParams.set("config",encodeURIComponent(y))}catch(v){throw new Error('"config" is not a valid URL or configuration object.')}else y&&typeof y=="object"&&Object.keys(y).length>0&&(y.title&&y.title!=="Untitled Project"&&n.searchParams.set("title",y.title),y.description&&y.description.length>0&&n.searchParams.set("description",y.description),s.set("config","code/"+(0,z.compressToEncodedURIComponent)(JSON.stringify(y))));if(E&&typeof E=="object"&&Object.keys(E).length>0)try{s.set("params",(0,z.compressToEncodedURIComponent)(JSON.stringify(E)))}catch(v){Object.keys(E).forEach(w=>{n.searchParams.set(w,encodeURIComponent(String(E[w])))})}return A&&n.searchParams.set("x",encodeURIComponent(A)),m&&n.searchParams.set("headless","true"),s.toString().length>0&&(n.hash=s.toString()),n.href}return le(fe);})();
{
"name": "livecodes",
"version": "0.12.0",
"version": "0.13.0",
"description": "A Code Playground That Just Works!",

@@ -5,0 +5,0 @@ "author": "Hatem Hosny",

@@ -1,1 +0,1 @@

var te=Object.create;var $=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ie=(d,m)=>()=>(m||d((m={exports:{}}).exports,m),m.exports);var ae=(d,m,b,u)=>{if(m&&typeof m=="object"||typeof m=="function")for(let A of oe(m))!re.call(d,A)&&A!==b&&$(d,A,{get:()=>m[A],enumerable:!(u=ne(m,A))||u.enumerable});return d};var le=(d,m,b)=>(b=d!=null?te(se(d)):{},ae(m||!d||!d.__esModule?$(b,"default",{value:d,enumerable:!0}):b,d));var G=ie((ye,J)=>{var ce=function(){var d=String.fromCharCode,m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",u={};function A(s,e){if(!u[s]){u[s]={};for(var i=0;i<s.length;i++)u[s][s.charAt(i)]=i}return u[s][e]}var O={compressToBase64:function(s){if(s==null)return"";var e=O._compress(s,6,function(i){return m.charAt(i)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(s){return s==null?"":s==""?null:O._decompress(s.length,32,function(e){return A(m,s.charAt(e))})},compressToUTF16:function(s){return s==null?"":O._compress(s,15,function(e){return d(e+32)})+" "},decompressFromUTF16:function(s){return s==null?"":s==""?null:O._decompress(s.length,16384,function(e){return s.charCodeAt(e)-32})},compressToUint8Array:function(s){for(var e=O.compress(s),i=new Uint8Array(e.length*2),n=0,r=e.length;n<r;n++){var y=e.charCodeAt(n);i[n*2]=y>>>8,i[n*2+1]=y%256}return i},decompressFromUint8Array:function(s){if(s==null)return O.decompress(s);for(var e=new Array(s.length/2),i=0,n=e.length;i<n;i++)e[i]=s[i*2]*256+s[i*2+1];var r=[];return e.forEach(function(y){r.push(d(y))}),O.decompress(r.join(""))},compressToEncodedURIComponent:function(s){return s==null?"":O._compress(s,6,function(e){return b.charAt(e)})},decompressFromEncodedURIComponent:function(s){return s==null?"":s==""?null:(s=s.replace(/ /g,"+"),O._decompress(s.length,32,function(e){return A(b,s.charAt(e))}))},compress:function(s){return O._compress(s,16,function(e){return d(e)})},_compress:function(s,e,i){if(s==null)return"";var n,r,y={},v={},w="",M="",g="",S=2,E=3,l=2,f=[],t=0,o=0,x;for(x=0;x<s.length;x+=1)if(w=s.charAt(x),Object.prototype.hasOwnProperty.call(y,w)||(y[w]=E++,v[w]=!0),M=g+w,Object.prototype.hasOwnProperty.call(y,M))g=M;else{if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<l;n++)t=t<<1,o==e-1?(o=0,f.push(i(t)),t=0):o++;for(r=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1}else{for(r=1,n=0;n<l;n++)t=t<<1|r,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=0;for(r=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1}S--,S==0&&(S=Math.pow(2,l),l++),delete v[g]}else for(r=y[g],n=0;n<l;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1;S--,S==0&&(S=Math.pow(2,l),l++),y[M]=E++,g=String(w)}if(g!==""){if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<l;n++)t=t<<1,o==e-1?(o=0,f.push(i(t)),t=0):o++;for(r=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1}else{for(r=1,n=0;n<l;n++)t=t<<1|r,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=0;for(r=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1}S--,S==0&&(S=Math.pow(2,l),l++),delete v[g]}else for(r=y[g],n=0;n<l;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1;S--,S==0&&(S=Math.pow(2,l),l++)}for(r=2,n=0;n<l;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1;for(;;)if(t=t<<1,o==e-1){f.push(i(t));break}else o++;return f.join("")},decompress:function(s){return s==null?"":s==""?null:O._decompress(s.length,32768,function(e){return s.charCodeAt(e)})},_decompress:function(s,e,i){var n=[],r,y=4,v=4,w=3,M="",g=[],S,E,l,f,t,o,x,c={val:i(0),position:e,index:1};for(S=0;S<3;S+=1)n[S]=S;for(l=0,t=Math.pow(2,2),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;switch(r=l){case 0:for(l=0,t=Math.pow(2,8),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;x=d(l);break;case 1:for(l=0,t=Math.pow(2,16),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;x=d(l);break;case 2:return""}for(n[3]=x,E=x,g.push(x);;){if(c.index>s)return"";for(l=0,t=Math.pow(2,w),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;switch(x=l){case 0:for(l=0,t=Math.pow(2,8),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;n[v++]=d(l),x=v-1,y--;break;case 1:for(l=0,t=Math.pow(2,16),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;n[v++]=d(l),x=v-1,y--;break;case 2:return g.join("")}if(y==0&&(y=Math.pow(2,w),w++),n[x])M=n[x];else if(x===v)M=E+E.charAt(0);else return null;g.push(M),n[v++]=E+M.charAt(0),y--,E=M,y==0&&(y=Math.pow(2,w),w++)}}};return O}();typeof J!="undefined"&&J!=null&&(J.exports=ce)});import{useEffect as Y,useRef as fe,useState as k}from"react";var K=le(G());async function X(d,m={}){typeof d=="object"&&!(d instanceof HTMLElement)&&(d.headless||d.view==="headless")&&(m=d,d=null);let{config:b={},headless:u,loading:A="lazy",view:O}=m,s=u||O==="headless",e=null,i=null;if(typeof d=="string")e=document.querySelector(d);else if(d instanceof HTMLElement)e=d;else if(!(s&&typeof d=="object"))throw new Error("A valid container element is required.");if(!e)if(s)e=document.createElement("div"),W(e),document.body.appendChild(e);else throw new Error(`Cannot find element: "${d}"`);let n=new URL(de(m)),r=n.origin;n.searchParams.set("embed","true"),n.searchParams.set("loading",s?"eager":A),n.searchParams.set("sdkVersion","0.12.0"),typeof b=="object"&&Object.keys(b).length>0&&n.searchParams.set("config","sdk");let y=m.params;typeof y=="object"&&Object.keys(y).length>0&&JSON.stringify(y).length<1800&&Object.keys(y).forEach(a=>{n.searchParams.set(a,encodeURIComponent(String(y[a])))});let v=!1,w="Cannot call API methods after calling `destroy()`.",M=[],g=(a,p="message")=>{addEventListener(p,a),M.push(a)},E=await new Promise(a=>{var j,C,T,I,U,z,B,q,Q;if(!e)return;let p=e.dataset.height||e.style.height;if(p&&!s){let _=isNaN(Number(p))?p:p+"px";e.style.height=_}e.dataset.defaultStyles!=="false"&&!s&&((j=e.style).backgroundColor||(j.backgroundColor="#fff"),(C=e.style).border||(C.border="1px solid black"),(T=e.style).borderRadius||(T.borderRadius="8px"),(I=e.style).boxSizing||(I.boxSizing="border-box"),(U=e.style).padding||(U.padding="0"),(z=e.style).width||(z.width="100%"),(B=e.style).height||(B.height=e.style.height||"300px"),e.style.minHeight="200px",e.style.flexGrow="1",(q=e.style).overflow||(q.overflow="hidden"),(Q=e.style).resize||(Q.resize="vertical"));let P="livecodes",L=e.querySelector(`iframe.${P}`),h=L||document.createElement("iframe");h.classList.add(P),h.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),h.setAttribute("allowtransparency","true"),h.setAttribute("allowpaymentrequest","true"),h.setAttribute("allowfullscreen","true"),h.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts");let R=A==="eager"?"eager":"lazy";h.setAttribute("loading",R),s?W(h):(h.style.height="100%",h.style.minHeight="200px",h.style.width="100%",h.style.margin="0",h.style.border="0",h.style.borderRadius=e.style.borderRadius),g(function _(H){var D;H.source!==h.contentWindow||H.origin!==r||((D=H.data)==null?void 0:D.type)!=="livecodes-init"||(removeEventListener("message",_),i=Number(H.data.payload.appVersion.replace(/^v/,"")))}),(!i||i<46)&&g(function _(H){var D,Z;H.source!==h.contentWindow||H.origin!==r||((D=H.data)==null?void 0:D.type)!=="livecodes-get-config"||(removeEventListener("message",_),(Z=h.contentWindow)==null||Z.postMessage({type:"livecodes-config",payload:b},r))}),h.onload=()=>{a(h)},h.src=n.href,L||e.appendChild(h)}),l=new Promise(a=>{g(function p(P){var L;P.source!==E.contentWindow||P.origin!==r||((L=P.data)==null?void 0:L.type)!=="livecodes-ready"||(removeEventListener("message",p),a(),l.settled=!0)})}),f=()=>v?Promise.reject(w):new Promise(async a=>{var P;l.settled&&a();let p={type:"livecodes-load"};(P=E.contentWindow)==null||P.postMessage(p,r),await l,a()}),t=(a,p)=>new Promise(async(P,L)=>{var R;if(v)return L(w);await f();let h=ee();g(function j(C){var T,I;if(!(C.source!==E.contentWindow||C.origin!==r||((T=C.data)==null?void 0:T.type)!=="livecodes-api-response"||((I=C.data)==null?void 0:I.id)!==h)&&C.data.method===a){removeEventListener("message",j);let U=C.data.payload;U!=null&&U.error?L(U.error):P(U)}}),(R=E.contentWindow)==null||R.postMessage({method:a,id:h,args:p},r)}),o={},x=["load","ready","code","console","tests","destroy"],c=(a,p)=>{var P;if(v)throw new Error(w);return x.includes(a)?(t("watch",[a]),o[a]||(o[a]=[]),(P=o[a])==null||P.push(p),{remove:()=>{var L,h;o[a]=(L=o[a])==null?void 0:L.filter(R=>R!==p),((h=o[a])==null?void 0:h.length)===0&&t("watch",[a,"unsubscribe"])}}):{remove:()=>{}}},F=a=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[a];g(async function(p){var h,R,j,C;let P=F((R=(h=p.data)==null?void 0:h.type)!=null?R:"");if(p.source!==E.contentWindow||p.origin!==r||!P||!o[P])return;let L=(j=p.data)==null?void 0:j.payload;(C=o[P])==null||C.forEach(T=>{T(L)})});let V=()=>{var a;(a=E==null?void 0:E.remove)==null||a.call(E),Object.values(o).forEach(p=>{p.length=0}),M.forEach(p=>removeEventListener("message",p)),M.length=0,N&&e&&N.unobserve(e),v=!0},N;A==="lazy"&&"IntersectionObserver"in window&&(N=new IntersectionObserver((a,p)=>{a.forEach(async P=>{P.isIntersecting&&(await f(),p.unobserve(e))})},{rootMargin:"150px"}),N.observe(e));function W(a){a.style.position="absolute",a.style.top="0",a.style.visibility="hidden",a.style.opacity="0"}let ee=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>f(),run:()=>t("run"),format:a=>t("format",[a]),getShareUrl:a=>t("getShareUrl",[a]),getConfig:a=>t("getConfig",[a]),setConfig:a=>t("setConfig",[a]),getCode:()=>t("getCode"),show:(a,p)=>t("show",[a,p]),runTests:()=>t("runTests"),onChange:a=>c("code",a),watch:c,exec:(a,...p)=>t("exec",[a,...p]),destroy:()=>v?Promise.reject(w):(V(),Promise.resolve())}}function de(d={}){let{appUrl:m="https://livecodes.io",params:b={},config:u={},headless:A,import:O,lite:s,view:e,...i}=d,n;try{n=new URL(m)}catch(v){throw new Error(`${m} is not a valid URL.`)}let r=new URLSearchParams;Object.entries(i).forEach(([v,w])=>{w!==void 0&&n.searchParams.set(v,String(w))});let y=d.view==="headless"||A;if(s&&(console.warn(`Deprecation notice: "lite" option is deprecated. Use "config: { mode: 'lite' }" instead.`),typeof u=="object"&&u.mode==null?u.mode="lite":n.searchParams.set("lite","true")),e&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),typeof u=="object"&&u.view==null&&e!=="headless"?u.view=e:n.searchParams.set("view",e)),typeof u=="string")try{new URL(u),n.searchParams.set("config",encodeURIComponent(u))}catch(v){throw new Error('"config" is not a valid URL or configuration object.')}else u&&typeof u=="object"&&Object.keys(u).length>0&&(u.title&&u.title!=="Untitled Project"&&n.searchParams.set("title",u.title),u.description&&u.description.length>0&&n.searchParams.set("description",u.description),r.set("config","code/"+(0,K.compressToEncodedURIComponent)(JSON.stringify(u))));if(b&&typeof b=="object"&&Object.keys(b).length>0)try{r.set("params",(0,K.compressToEncodedURIComponent)(JSON.stringify(b)))}catch(v){Object.keys(b).forEach(w=>{n.searchParams.set(w,encodeURIComponent(String(b[w])))})}return O&&n.searchParams.set("x",encodeURIComponent(O)),y&&n.searchParams.set("headless","true"),r.toString().length>0&&(n.hash=r.toString()),n.href}import{jsx as pe}from"react/jsx-runtime";function ue(d){let m=fe(null),[b,u]=k(d.className||""),[A,O]=k(d.style||{}),[s,e]=k(d.height),[i,n]=k(),[r,y]=k(JSON.stringify(d.config||"")),[v,w]=k("");return Y(()=>{if(!m.current)return;let{className:M,style:g,height:S,sdkReady:E,config:l,...f}=d;if(u(M||""),O(g||{}),e(S),!i||v!==JSON.stringify(f))w(JSON.stringify(f)),i==null||i.destroy(),X(m.current,{config:l,...f}).then(t=>{n(t),typeof E=="function"&&E(t)});else{if(r===JSON.stringify(l))return;y(JSON.stringify(l)),typeof l=="string"?fetch(l).then(t=>t.json()).then(t=>{i==null||i.setConfig(t)}):l&&i.setConfig(l)}},[d]),Y(()=>()=>{i==null||i.destroy()},[]),pe("div",{ref:m,className:b,style:A,"data-height":s})}export{ue as default};
var te=Object.create;var $=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ie=(d,m)=>()=>(m||d((m={exports:{}}).exports,m),m.exports);var ae=(d,m,b,u)=>{if(m&&typeof m=="object"||typeof m=="function")for(let A of oe(m))!re.call(d,A)&&A!==b&&$(d,A,{get:()=>m[A],enumerable:!(u=ne(m,A))||u.enumerable});return d};var le=(d,m,b)=>(b=d!=null?te(se(d)):{},ae(m||!d||!d.__esModule?$(b,"default",{value:d,enumerable:!0}):b,d));var G=ie((ye,J)=>{var ce=function(){var d=String.fromCharCode,m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",u={};function A(s,e){if(!u[s]){u[s]={};for(var i=0;i<s.length;i++)u[s][s.charAt(i)]=i}return u[s][e]}var O={compressToBase64:function(s){if(s==null)return"";var e=O._compress(s,6,function(i){return m.charAt(i)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(s){return s==null?"":s==""?null:O._decompress(s.length,32,function(e){return A(m,s.charAt(e))})},compressToUTF16:function(s){return s==null?"":O._compress(s,15,function(e){return d(e+32)})+" "},decompressFromUTF16:function(s){return s==null?"":s==""?null:O._decompress(s.length,16384,function(e){return s.charCodeAt(e)-32})},compressToUint8Array:function(s){for(var e=O.compress(s),i=new Uint8Array(e.length*2),n=0,r=e.length;n<r;n++){var y=e.charCodeAt(n);i[n*2]=y>>>8,i[n*2+1]=y%256}return i},decompressFromUint8Array:function(s){if(s==null)return O.decompress(s);for(var e=new Array(s.length/2),i=0,n=e.length;i<n;i++)e[i]=s[i*2]*256+s[i*2+1];var r=[];return e.forEach(function(y){r.push(d(y))}),O.decompress(r.join(""))},compressToEncodedURIComponent:function(s){return s==null?"":O._compress(s,6,function(e){return b.charAt(e)})},decompressFromEncodedURIComponent:function(s){return s==null?"":s==""?null:(s=s.replace(/ /g,"+"),O._decompress(s.length,32,function(e){return A(b,s.charAt(e))}))},compress:function(s){return O._compress(s,16,function(e){return d(e)})},_compress:function(s,e,i){if(s==null)return"";var n,r,y={},v={},w="",M="",g="",S=2,E=3,l=2,f=[],t=0,o=0,x;for(x=0;x<s.length;x+=1)if(w=s.charAt(x),Object.prototype.hasOwnProperty.call(y,w)||(y[w]=E++,v[w]=!0),M=g+w,Object.prototype.hasOwnProperty.call(y,M))g=M;else{if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<l;n++)t=t<<1,o==e-1?(o=0,f.push(i(t)),t=0):o++;for(r=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1}else{for(r=1,n=0;n<l;n++)t=t<<1|r,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=0;for(r=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1}S--,S==0&&(S=Math.pow(2,l),l++),delete v[g]}else for(r=y[g],n=0;n<l;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1;S--,S==0&&(S=Math.pow(2,l),l++),y[M]=E++,g=String(w)}if(g!==""){if(Object.prototype.hasOwnProperty.call(v,g)){if(g.charCodeAt(0)<256){for(n=0;n<l;n++)t=t<<1,o==e-1?(o=0,f.push(i(t)),t=0):o++;for(r=g.charCodeAt(0),n=0;n<8;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1}else{for(r=1,n=0;n<l;n++)t=t<<1|r,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=0;for(r=g.charCodeAt(0),n=0;n<16;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1}S--,S==0&&(S=Math.pow(2,l),l++),delete v[g]}else for(r=y[g],n=0;n<l;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1;S--,S==0&&(S=Math.pow(2,l),l++)}for(r=2,n=0;n<l;n++)t=t<<1|r&1,o==e-1?(o=0,f.push(i(t)),t=0):o++,r=r>>1;for(;;)if(t=t<<1,o==e-1){f.push(i(t));break}else o++;return f.join("")},decompress:function(s){return s==null?"":s==""?null:O._decompress(s.length,32768,function(e){return s.charCodeAt(e)})},_decompress:function(s,e,i){var n=[],r,y=4,v=4,w=3,M="",g=[],S,E,l,f,t,o,x,c={val:i(0),position:e,index:1};for(S=0;S<3;S+=1)n[S]=S;for(l=0,t=Math.pow(2,2),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;switch(r=l){case 0:for(l=0,t=Math.pow(2,8),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;x=d(l);break;case 1:for(l=0,t=Math.pow(2,16),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;x=d(l);break;case 2:return""}for(n[3]=x,E=x,g.push(x);;){if(c.index>s)return"";for(l=0,t=Math.pow(2,w),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;switch(x=l){case 0:for(l=0,t=Math.pow(2,8),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;n[v++]=d(l),x=v-1,y--;break;case 1:for(l=0,t=Math.pow(2,16),o=1;o!=t;)f=c.val&c.position,c.position>>=1,c.position==0&&(c.position=e,c.val=i(c.index++)),l|=(f>0?1:0)*o,o<<=1;n[v++]=d(l),x=v-1,y--;break;case 2:return g.join("")}if(y==0&&(y=Math.pow(2,w),w++),n[x])M=n[x];else if(x===v)M=E+E.charAt(0);else return null;g.push(M),n[v++]=E+M.charAt(0),y--,E=M,y==0&&(y=Math.pow(2,w),w++)}}};return O}();typeof J!="undefined"&&J!=null&&(J.exports=ce)});import{useEffect as Y,useRef as fe,useState as k}from"react";var K=le(G());async function X(d,m={}){typeof d=="object"&&!(d instanceof HTMLElement)&&(d.headless||d.view==="headless")&&(m=d,d=null);let{config:b={},headless:u,loading:A="lazy",view:O}=m,s=u||O==="headless",e=null,i=null;if(typeof d=="string")e=document.querySelector(d);else if(d instanceof HTMLElement)e=d;else if(!(s&&typeof d=="object"))throw new Error("A valid container element is required.");if(!e)if(s)e=document.createElement("div"),W(e),document.body.appendChild(e);else throw new Error(`Cannot find element: "${d}"`);let n=new URL(de(m)),r=n.origin;n.searchParams.set("embed","true"),n.searchParams.set("loading",s?"eager":A),n.searchParams.set("sdkVersion","0.13.0"),typeof b=="object"&&Object.keys(b).length>0&&n.searchParams.set("config","sdk");let y=m.params;typeof y=="object"&&Object.keys(y).length>0&&JSON.stringify(y).length<1800&&Object.keys(y).forEach(a=>{n.searchParams.set(a,encodeURIComponent(String(y[a])))});let v=!1,w="Cannot call API methods after calling `destroy()`.",M=[],g=(a,p="message")=>{addEventListener(p,a),M.push(a)},E=await new Promise(a=>{var j,C,T,I,U,z,B,q,Q;if(!e)return;let p=e.dataset.height||e.style.height;if(p&&!s){let _=isNaN(Number(p))?p:p+"px";e.style.height=_}e.dataset.defaultStyles!=="false"&&!s&&((j=e.style).backgroundColor||(j.backgroundColor="#fff"),(C=e.style).border||(C.border="1px solid black"),(T=e.style).borderRadius||(T.borderRadius="8px"),(I=e.style).boxSizing||(I.boxSizing="border-box"),(U=e.style).padding||(U.padding="0"),(z=e.style).width||(z.width="100%"),(B=e.style).height||(B.height=e.style.height||"300px"),e.style.minHeight="200px",e.style.flexGrow="1",(q=e.style).overflow||(q.overflow="hidden"),(Q=e.style).resize||(Q.resize="vertical"));let P="livecodes",L=e.querySelector(`iframe.${P}`),h=L||document.createElement("iframe");h.classList.add(P),h.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),h.setAttribute("allowtransparency","true"),h.setAttribute("allowpaymentrequest","true"),h.setAttribute("allowfullscreen","true"),h.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts");let R=A==="eager"?"eager":"lazy";h.setAttribute("loading",R),s?W(h):(h.style.height="100%",h.style.minHeight="200px",h.style.width="100%",h.style.margin="0",h.style.border="0",h.style.borderRadius=e.style.borderRadius),g(function _(H){var D;H.source!==h.contentWindow||H.origin!==r||((D=H.data)==null?void 0:D.type)!=="livecodes-init"||(removeEventListener("message",_),i=Number(H.data.payload.appVersion.replace(/^v/,"")))}),(!i||i<46)&&g(function _(H){var D,Z;H.source!==h.contentWindow||H.origin!==r||((D=H.data)==null?void 0:D.type)!=="livecodes-get-config"||(removeEventListener("message",_),(Z=h.contentWindow)==null||Z.postMessage({type:"livecodes-config",payload:b},r))}),h.onload=()=>{a(h)},h.src=n.href,L||e.appendChild(h)}),l=new Promise(a=>{g(function p(P){var L;P.source!==E.contentWindow||P.origin!==r||((L=P.data)==null?void 0:L.type)!=="livecodes-ready"||(removeEventListener("message",p),a(),l.settled=!0)})}),f=()=>v?Promise.reject(w):new Promise(async a=>{var P;l.settled&&a();let p={type:"livecodes-load"};(P=E.contentWindow)==null||P.postMessage(p,r),await l,a()}),t=(a,p)=>new Promise(async(P,L)=>{var R;if(v)return L(w);await f();let h=ee();g(function j(C){var T,I;if(!(C.source!==E.contentWindow||C.origin!==r||((T=C.data)==null?void 0:T.type)!=="livecodes-api-response"||((I=C.data)==null?void 0:I.id)!==h)&&C.data.method===a){removeEventListener("message",j);let U=C.data.payload;U!=null&&U.error?L(U.error):P(U)}}),(R=E.contentWindow)==null||R.postMessage({method:a,id:h,args:p},r)}),o={},x=["load","ready","code","console","tests","destroy"],c=(a,p)=>{var P;if(v)throw new Error(w);return x.includes(a)?(t("watch",[a]),o[a]||(o[a]=[]),(P=o[a])==null||P.push(p),{remove:()=>{var L,h;o[a]=(L=o[a])==null?void 0:L.filter(R=>R!==p),((h=o[a])==null?void 0:h.length)===0&&t("watch",[a,"unsubscribe"])}}):{remove:()=>{}}},F=a=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[a];g(async function(p){var h,R,j,C;let P=F((R=(h=p.data)==null?void 0:h.type)!=null?R:"");if(p.source!==E.contentWindow||p.origin!==r||!P||!o[P])return;let L=(j=p.data)==null?void 0:j.payload;(C=o[P])==null||C.forEach(T=>{T(L)})});let V=()=>{var a;(a=E==null?void 0:E.remove)==null||a.call(E),Object.values(o).forEach(p=>{p.length=0}),M.forEach(p=>removeEventListener("message",p)),M.length=0,N&&e&&N.unobserve(e),v=!0},N;A==="lazy"&&"IntersectionObserver"in window&&(N=new IntersectionObserver((a,p)=>{a.forEach(async P=>{P.isIntersecting&&(await f(),p.unobserve(e))})},{rootMargin:"150px"}),N.observe(e));function W(a){a.style.position="absolute",a.style.top="0",a.style.visibility="hidden",a.style.opacity="0"}let ee=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>f(),run:()=>t("run"),format:a=>t("format",[a]),getShareUrl:a=>t("getShareUrl",[a]),getConfig:a=>t("getConfig",[a]),setConfig:a=>t("setConfig",[a]),getCode:()=>t("getCode"),show:(a,p)=>t("show",[a,p]),runTests:()=>t("runTests"),onChange:a=>c("code",a),watch:c,exec:(a,...p)=>t("exec",[a,...p]),destroy:()=>v?Promise.reject(w):(V(),Promise.resolve())}}function de(d={}){let{appUrl:m="https://livecodes.io",params:b={},config:u={},headless:A,import:O,lite:s,view:e,...i}=d,n;try{n=new URL(m)}catch(v){throw new Error(`${m} is not a valid URL.`)}let r=new URLSearchParams;Object.entries(i).forEach(([v,w])=>{w!==void 0&&n.searchParams.set(v,String(w))});let y=d.view==="headless"||A;if(s&&(console.warn(`Deprecation notice: "lite" option is deprecated. Use "config: { mode: 'lite' }" instead.`),typeof u=="object"&&u.mode==null?u.mode="lite":n.searchParams.set("lite","true")),e&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),typeof u=="object"&&u.view==null&&e!=="headless"?u.view=e:n.searchParams.set("view",e)),typeof u=="string")try{new URL(u),n.searchParams.set("config",encodeURIComponent(u))}catch(v){throw new Error('"config" is not a valid URL or configuration object.')}else u&&typeof u=="object"&&Object.keys(u).length>0&&(u.title&&u.title!=="Untitled Project"&&n.searchParams.set("title",u.title),u.description&&u.description.length>0&&n.searchParams.set("description",u.description),r.set("config","code/"+(0,K.compressToEncodedURIComponent)(JSON.stringify(u))));if(b&&typeof b=="object"&&Object.keys(b).length>0)try{r.set("params",(0,K.compressToEncodedURIComponent)(JSON.stringify(b)))}catch(v){Object.keys(b).forEach(w=>{n.searchParams.set(w,encodeURIComponent(String(b[w])))})}return O&&n.searchParams.set("x",encodeURIComponent(O)),y&&n.searchParams.set("headless","true"),r.toString().length>0&&(n.hash=r.toString()),n.href}import{jsx as pe}from"react/jsx-runtime";function ue(d){let m=fe(null),[b,u]=k(d.className||""),[A,O]=k(d.style||{}),[s,e]=k(d.height),[i,n]=k(),[r,y]=k(JSON.stringify(d.config||"")),[v,w]=k("");return Y(()=>{if(!m.current)return;let{className:M,style:g,height:S,sdkReady:E,config:l,...f}=d;if(u(M||""),O(g||{}),e(S),!i||v!==JSON.stringify(f))w(JSON.stringify(f)),i==null||i.destroy(),X(m.current,{config:l,...f}).then(t=>{n(t),typeof E=="function"&&E(t)});else{if(r===JSON.stringify(l))return;y(JSON.stringify(l)),typeof l=="string"?fetch(l).then(t=>t.json()).then(t=>{i==null||i.setConfig(t)}):l&&i.setConfig(l)}},[d]),Y(()=>()=>{i==null||i.destroy()},[]),pe("div",{ref:m,className:b,style:A,"data-height":s})}export{ue as default};

@@ -16,3 +16,3 @@ # LiveCodes

[![LiveCodes: jsdelivr downloads](https://data.jsdelivr.com/v1/package/npm/livecodes/badge?style=rounded)](https://www.jsdelivr.com/package/npm/livecodes)
[![LiveCodes: languages](https://img.shields.io/badge/languages-97-blue)](https://livecodes.io/docs/languages/)
[![LiveCodes: languages](https://img.shields.io/badge/languages-98-blue)](https://livecodes.io/docs/languages/)
[![LiveCodes: docs](https://img.shields.io/badge/Documentation-575757?logo=gitbook&logoColor=white)](https://livecodes.io/docs/)

@@ -114,3 +114,2 @@ [![LiveCodes: llms.txt](https://img.shields.io/badge/llms.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms.txt)

- [Intellisense](https://livecodes.io/docs/features/intellisense)
- [AI Code Assistant 🪄](https://livecodes.io/docs/features/ai)
- [Lite mode](https://livecodes.io/docs/features/lite)

@@ -124,3 +123,3 @@ - [Read-only mode](https://livecodes.io/docs/features/read-only)

- Developer-friendly build-free environment
- Powerful [SDK](https://livecodes.io/docs/sdk/) (available for [vanilla JavaScript, TypeScript](https://livecodes.io/docs/sdk/js-ts), [React](https://livecodes.io/docs/sdk/react), [Vue](https://livecodes.io/docs/sdk/vue) and [Svelte](https://livecodes.io/docs/sdk/svelte))
- Powerful [SDK](https://livecodes.io/docs/sdk/) (available for [vanilla JavaScript, TypeScript](https://livecodes.io/docs/sdk/js-ts), [React](https://livecodes.io/docs/sdk/react), [Vue](https://livecodes.io/docs/sdk/vue), [Svelte](https://livecodes.io/docs/sdk/svelte) and [Solid](https://livecodes.io/docs/sdk/solid))
- Comprehensive [Documentations](https://livecodes.io/docs/)

@@ -136,3 +135,3 @@ - Focused on [privacy and security](https://livecodes.io/docs/features/security)

The SDK is provided as a light-weight ([less than 5kb gzipped](https://bundlephobia.com/package/livecodes)), zero-dependencies [npm package](https://livecodes.io/docs/sdk/#npm-package), that is also available from [CDNs](https://livecodes.io/docs/sdk/#cdn). It can be used to create playgrounds with a wide variety of [configurations](https://livecodes.io/docs/configuration/configuration-object.md) and [embed options](https://livecodes.io/docs/sdk/js-ts.md#embed-options). In addition, [SDK methods](https://livecodes.io/docs/sdk/js-ts.md#sdk-methods) allow programmatic communication and control of the playgrounds during runtime.
The SDK is provided as a light-weight ([less than 5kb gzipped](https://bundlephobia.com/package/livecodes)), zero-dependencies [npm package](https://livecodes.io/docs/sdk/#npm-package), that is also available from [CDNs](https://livecodes.io/docs/sdk/#cdn). It can be used to create playgrounds with a wide variety of [configurations](https://livecodes.io/docs/configuration/configuration-object) and [embed options](https://livecodes.io/docs/sdk/js-ts#embed-options). In addition, [SDK methods](https://livecodes.io/docs/sdk/js-ts#sdk-methods) allow programmatic communication and control of the playgrounds during runtime.

@@ -163,3 +162,3 @@ ### Installation

The [JavaScript SDK](https://livecodes.io/docs/sdk/js-ts.md) is framework/library agnostic. However, wrapper components are also provided for popular libraries (currently [React](https://livecodes.io/docs/sdk/react.md) and [Vue](https://livecodes.io/docs/sdk/vue.md)). The SDK can be used in [Svelte](https://livecodes.io/docs/sdk/svelte.md) directly without wrappers. [TypeScript support](https://livecodes.io/docs/sdk/js-ts.md#typescript-types) provides type-safety and a great developer experience.
The [JavaScript SDK](https://livecodes.io/docs/sdk/js-ts) is framework/library agnostic. However, wrapper components are also provided for popular libraries (currently [React](https://livecodes.io/docs/sdk/react) and [Vue](https://livecodes.io/docs/sdk/vue)). The SDK can be used in [Svelte](https://livecodes.io/docs/sdk/svelte) and [Solid](https://livecodes.io/docs/sdk/solid) directly without wrappers. [TypeScript support](https://livecodes.io/docs/sdk/js-ts#typescript-types) provides type-safety and a great developer experience.

@@ -278,7 +277,2 @@ React SDK example: ([open in LiveCodes](https://livecodes.io/?x=code/N4IgLglmA2CmIC4QBkIDdYGED2ATWAzgAQBKsAhgMZhEDKAIgNJH4C22IANCPgZQE4QADpGwA7RCC4gAFhVySAPK1hhyRSjPL8CqgLwAdEAFUAKgDEAtAA4jRAPQA+A2OWr1Y8isMg0EWADuQtj8YHaU4mCwYmA+ARC4YDJ6+H6UsJbxiTKcRBBiUBDk0JZ8xbB6AIwAdAAMdk7SMmCs0ACCYGA6ktDkYgDmPtHhvQQEPkbSav0EiADaALrcVJAYAKK4UCGSfIIi0qzaANYArkKIoL0DJ+T98EjNrdIRMdFgkiAAvtwEYACecAuICu-Rud0klDGz0ibw+3xAu2E7wQlz6oNu9xAACsCAAPaGvGKSCCsYKhIioDA4XhEABm-GwrCIAHJoOhYBFePZ+BRqMyANwGfguIUuF6-DTiWkQfpEPREYCisREIiHfinIQIBVKlUqkFg2Ba5lqo64bABMTMzg63UvKIxI0AYiIAAlYNBoNgiAB1ELQXAAQitNu+Ss+guFYnFNAACr0-v0GScxLg5UQABQASjljiIikpWDwhElYmlg2ALzLnyIfkCPh5BBO0DCIAcjgjLlguLJNHwtPITdj8cT2GTuA7EnhvwBhDkqlmCEWPwESIXS5AkIIMYbqg+3CEDPSYxCa6WG5Ov0ZtFUkAGC+A8JJPfv8P+QkIF1fhDA9+BaINkhvoQK77NwdqwkgXzcBgOgQOIkgAMwIVM2DYNAv7ROQABGcAKEgxTQNIKzshC4gEGh8A-GoYAXhCnq6AonyfEAA))

<p>
<a href="https://windsurf.com/" target="_blank" title="Windsurf">
<img alt="Windsurf" width="200" src="https://dev.livecodes.io/docs/img/credits/windsurf.svg">
</img></a><br /><br />
</p>
<p>
<a href="https://m.do.co/c/fb8c00b45b91" target="_blank" title="DigitalOcean">

@@ -319,7 +313,2 @@ <img alt="DigitalOcean" width="200" src="https://dev.livecodes.io/docs/img/credits/digital-ocean.svg">

<p>
<a href="https://bundlewatch.io/" target="_blank" title="BundleWatch">
<img alt="BundleWatch" width="200" src="https://dev.livecodes.io/docs/img/credits/bundlewatch.svg">
</img></a><br /><br />
</p>
<p>
<a href="https://www.browserstack.com/" target="_blank" title="BrowserStack">

@@ -326,0 +315,0 @@ <img alt="BrowserStack" width="200" src="https://dev.livecodes.io/docs/img/credits/browserstack.svg">

+1
-1

@@ -1,1 +0,1 @@

var te=Object.create;var X=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ie=(c,g)=>()=>(g||c((g={exports:{}}).exports,g),g.exports);var ae=(c,g,b,p)=>{if(g&&typeof g=="object"||typeof g=="function")for(let O of oe(g))!se.call(c,O)&&O!==b&&X(c,O,{get:()=>g[O],enumerable:!(p=ne(g,O))||p.enumerable});return c};var le=(c,g,b)=>(b=c!=null?te(re(c)):{},ae(g||!c||!c.__esModule?X(b,"default",{value:c,enumerable:!0}):b,c));var Y=ie((ve,D)=>{var ce=function(){var c=String.fromCharCode,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",p={};function O(o,e){if(!p[o]){p[o]={};for(var l=0;l<o.length;l++)p[o][o.charAt(l)]=l}return p[o][e]}var x={compressToBase64:function(o){if(o==null)return"";var e=x._compress(o,6,function(l){return g.charAt(l)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(o){return o==null?"":o==""?null:x._decompress(o.length,32,function(e){return O(g,o.charAt(e))})},compressToUTF16:function(o){return o==null?"":x._compress(o,15,function(e){return c(e+32)})+" "},decompressFromUTF16:function(o){return o==null?"":o==""?null:x._decompress(o.length,16384,function(e){return o.charCodeAt(e)-32})},compressToUint8Array:function(o){for(var e=x.compress(o),l=new Uint8Array(e.length*2),t=0,s=e.length;t<s;t++){var d=e.charCodeAt(t);l[t*2]=d>>>8,l[t*2+1]=d%256}return l},decompressFromUint8Array:function(o){if(o==null)return x.decompress(o);for(var e=new Array(o.length/2),l=0,t=e.length;l<t;l++)e[l]=o[l*2]*256+o[l*2+1];var s=[];return e.forEach(function(d){s.push(c(d))}),x.decompress(s.join(""))},compressToEncodedURIComponent:function(o){return o==null?"":x._compress(o,6,function(e){return b.charAt(e)})},decompressFromEncodedURIComponent:function(o){return o==null?"":o==""?null:(o=o.replace(/ /g,"+"),x._decompress(o.length,32,function(e){return O(b,o.charAt(e))}))},compress:function(o){return x._compress(o,16,function(e){return c(e)})},_compress:function(o,e,l){if(o==null)return"";var t,s,d={},v={},w="",P="",h="",S=2,E=3,f=2,u=[],n=0,r=0,M;for(M=0;M<o.length;M+=1)if(w=o.charAt(M),Object.prototype.hasOwnProperty.call(d,w)||(d[w]=E++,v[w]=!0),P=h+w,Object.prototype.hasOwnProperty.call(d,P))h=P;else{if(Object.prototype.hasOwnProperty.call(v,h)){if(h.charCodeAt(0)<256){for(t=0;t<f;t++)n=n<<1,r==e-1?(r=0,u.push(l(n)),n=0):r++;for(s=h.charCodeAt(0),t=0;t<8;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1}else{for(s=1,t=0;t<f;t++)n=n<<1|s,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=0;for(s=h.charCodeAt(0),t=0;t<16;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1}S--,S==0&&(S=Math.pow(2,f),f++),delete v[h]}else for(s=d[h],t=0;t<f;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1;S--,S==0&&(S=Math.pow(2,f),f++),d[P]=E++,h=String(w)}if(h!==""){if(Object.prototype.hasOwnProperty.call(v,h)){if(h.charCodeAt(0)<256){for(t=0;t<f;t++)n=n<<1,r==e-1?(r=0,u.push(l(n)),n=0):r++;for(s=h.charCodeAt(0),t=0;t<8;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1}else{for(s=1,t=0;t<f;t++)n=n<<1|s,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=0;for(s=h.charCodeAt(0),t=0;t<16;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1}S--,S==0&&(S=Math.pow(2,f),f++),delete v[h]}else for(s=d[h],t=0;t<f;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1;S--,S==0&&(S=Math.pow(2,f),f++)}for(s=2,t=0;t<f;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1;for(;;)if(n=n<<1,r==e-1){u.push(l(n));break}else r++;return u.join("")},decompress:function(o){return o==null?"":o==""?null:x._decompress(o.length,32768,function(e){return o.charCodeAt(e)})},_decompress:function(o,e,l){var t=[],s,d=4,v=4,w=3,P="",h=[],S,E,f,u,n,r,M,a={val:l(0),position:e,index:1};for(S=0;S<3;S+=1)t[S]=S;for(f=0,n=Math.pow(2,2),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;switch(s=f){case 0:for(f=0,n=Math.pow(2,8),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;M=c(f);break;case 1:for(f=0,n=Math.pow(2,16),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;M=c(f);break;case 2:return""}for(t[3]=M,E=M,h.push(M);;){if(a.index>o)return"";for(f=0,n=Math.pow(2,w),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;switch(M=f){case 0:for(f=0,n=Math.pow(2,8),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;t[v++]=c(f),M=v-1,d--;break;case 1:for(f=0,n=Math.pow(2,16),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;t[v++]=c(f),M=v-1,d--;break;case 2:return h.join("")}if(d==0&&(d=Math.pow(2,w),w++),t[M])P=t[M];else if(M===v)P=E+E.charAt(0);else return null;h.push(P),t[v++]=E+P.charAt(0),d--,E=P,d==0&&(d=Math.pow(2,w),w++)}}};return x}();typeof D!="undefined"&&D!=null&&(D.exports=ce)});import{h as fe,onMounted as pe,onUnmounted as ue,ref as B,watch as ye}from"vue";var J=le(Y());async function K(c,g={}){typeof c=="object"&&!(c instanceof HTMLElement)&&(c.headless||c.view==="headless")&&(g=c,c=null);let{config:b={},headless:p,loading:O="lazy",view:x}=g,o=p||x==="headless",e=null,l=null;if(typeof c=="string")e=document.querySelector(c);else if(c instanceof HTMLElement)e=c;else if(!(o&&typeof c=="object"))throw new Error("A valid container element is required.");if(!e)if(o)e=document.createElement("div"),z(e),document.body.appendChild(e);else throw new Error(`Cannot find element: "${c}"`);let t=new URL(de(g)),s=t.origin;t.searchParams.set("embed","true"),t.searchParams.set("loading",o?"eager":O),t.searchParams.set("sdkVersion","0.12.0"),typeof b=="object"&&Object.keys(b).length>0&&t.searchParams.set("config","sdk");let d=g.params;typeof d=="object"&&Object.keys(d).length>0&&JSON.stringify(d).length<1800&&Object.keys(d).forEach(i=>{t.searchParams.set(i,encodeURIComponent(String(d[i])))});let v=!1,w="Cannot call API methods after calling `destroy()`.",P=[],h=(i,y="message")=>{addEventListener(y,i),P.push(i)},E=await new Promise(i=>{var k,L,j,H,U,q,Q,Z,$;if(!e)return;let y=e.dataset.height||e.style.height;if(y&&!o){let _=isNaN(Number(y))?y:y+"px";e.style.height=_}e.dataset.defaultStyles!=="false"&&!o&&((k=e.style).backgroundColor||(k.backgroundColor="#fff"),(L=e.style).border||(L.border="1px solid black"),(j=e.style).borderRadius||(j.borderRadius="8px"),(H=e.style).boxSizing||(H.boxSizing="border-box"),(U=e.style).padding||(U.padding="0"),(q=e.style).width||(q.width="100%"),(Q=e.style).height||(Q.height=e.style.height||"300px"),e.style.minHeight="200px",e.style.flexGrow="1",(Z=e.style).overflow||(Z.overflow="hidden"),($=e.style).resize||($.resize="vertical"));let C="livecodes",A=e.querySelector(`iframe.${C}`),m=A||document.createElement("iframe");m.classList.add(C),m.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),m.setAttribute("allowtransparency","true"),m.setAttribute("allowpaymentrequest","true"),m.setAttribute("allowfullscreen","true"),m.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts");let R=O==="eager"?"eager":"lazy";m.setAttribute("loading",R),o?z(m):(m.style.height="100%",m.style.minHeight="200px",m.style.width="100%",m.style.margin="0",m.style.border="0",m.style.borderRadius=e.style.borderRadius),h(function _(T){var I;T.source!==m.contentWindow||T.origin!==s||((I=T.data)==null?void 0:I.type)!=="livecodes-init"||(removeEventListener("message",_),l=Number(T.data.payload.appVersion.replace(/^v/,"")))}),(!l||l<46)&&h(function _(T){var I,G;T.source!==m.contentWindow||T.origin!==s||((I=T.data)==null?void 0:I.type)!=="livecodes-get-config"||(removeEventListener("message",_),(G=m.contentWindow)==null||G.postMessage({type:"livecodes-config",payload:b},s))}),m.onload=()=>{i(m)},m.src=t.href,A||e.appendChild(m)}),f=new Promise(i=>{h(function y(C){var A;C.source!==E.contentWindow||C.origin!==s||((A=C.data)==null?void 0:A.type)!=="livecodes-ready"||(removeEventListener("message",y),i(),f.settled=!0)})}),u=()=>v?Promise.reject(w):new Promise(async i=>{var C;f.settled&&i();let y={type:"livecodes-load"};(C=E.contentWindow)==null||C.postMessage(y,s),await f,i()}),n=(i,y)=>new Promise(async(C,A)=>{var R;if(v)return A(w);await u();let m=ee();h(function k(L){var j,H;if(!(L.source!==E.contentWindow||L.origin!==s||((j=L.data)==null?void 0:j.type)!=="livecodes-api-response"||((H=L.data)==null?void 0:H.id)!==m)&&L.data.method===i){removeEventListener("message",k);let U=L.data.payload;U!=null&&U.error?A(U.error):C(U)}}),(R=E.contentWindow)==null||R.postMessage({method:i,id:m,args:y},s)}),r={},M=["load","ready","code","console","tests","destroy"],a=(i,y)=>{var C;if(v)throw new Error(w);return M.includes(i)?(n("watch",[i]),r[i]||(r[i]=[]),(C=r[i])==null||C.push(y),{remove:()=>{var A,m;r[i]=(A=r[i])==null?void 0:A.filter(R=>R!==y),((m=r[i])==null?void 0:m.length)===0&&n("watch",[i,"unsubscribe"])}}):{remove:()=>{}}},F=i=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[i];h(async function(y){var m,R,k,L;let C=F((R=(m=y.data)==null?void 0:m.type)!=null?R:"");if(y.source!==E.contentWindow||y.origin!==s||!C||!r[C])return;let A=(k=y.data)==null?void 0:k.payload;(L=r[C])==null||L.forEach(j=>{j(A)})});let V=()=>{var i;(i=E==null?void 0:E.remove)==null||i.call(E),Object.values(r).forEach(y=>{y.length=0}),P.forEach(y=>removeEventListener("message",y)),P.length=0,N&&e&&N.unobserve(e),v=!0},N;O==="lazy"&&"IntersectionObserver"in window&&(N=new IntersectionObserver((i,y)=>{i.forEach(async C=>{C.isIntersecting&&(await u(),y.unobserve(e))})},{rootMargin:"150px"}),N.observe(e));function z(i){i.style.position="absolute",i.style.top="0",i.style.visibility="hidden",i.style.opacity="0"}let ee=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>u(),run:()=>n("run"),format:i=>n("format",[i]),getShareUrl:i=>n("getShareUrl",[i]),getConfig:i=>n("getConfig",[i]),setConfig:i=>n("setConfig",[i]),getCode:()=>n("getCode"),show:(i,y)=>n("show",[i,y]),runTests:()=>n("runTests"),onChange:i=>a("code",i),watch:a,exec:(i,...y)=>n("exec",[i,...y]),destroy:()=>v?Promise.reject(w):(V(),Promise.resolve())}}function de(c={}){let{appUrl:g="https://livecodes.io",params:b={},config:p={},headless:O,import:x,lite:o,view:e,...l}=c,t;try{t=new URL(g)}catch(v){throw new Error(`${g} is not a valid URL.`)}let s=new URLSearchParams;Object.entries(l).forEach(([v,w])=>{w!==void 0&&t.searchParams.set(v,String(w))});let d=c.view==="headless"||O;if(o&&(console.warn(`Deprecation notice: "lite" option is deprecated. Use "config: { mode: 'lite' }" instead.`),typeof p=="object"&&p.mode==null?p.mode="lite":t.searchParams.set("lite","true")),e&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),typeof p=="object"&&p.view==null&&e!=="headless"?p.view=e:t.searchParams.set("view",e)),typeof p=="string")try{new URL(p),t.searchParams.set("config",encodeURIComponent(p))}catch(v){throw new Error('"config" is not a valid URL or configuration object.')}else p&&typeof p=="object"&&Object.keys(p).length>0&&(p.title&&p.title!=="Untitled Project"&&t.searchParams.set("title",p.title),p.description&&p.description.length>0&&t.searchParams.set("description",p.description),s.set("config","code/"+(0,J.compressToEncodedURIComponent)(JSON.stringify(p))));if(b&&typeof b=="object"&&Object.keys(b).length>0)try{s.set("params",(0,J.compressToEncodedURIComponent)(JSON.stringify(b)))}catch(v){Object.keys(b).forEach(w=>{t.searchParams.set(w,encodeURIComponent(String(b[w])))})}return x&&t.searchParams.set("x",encodeURIComponent(x)),d&&t.searchParams.set("headless","true"),s.toString().length>0&&(t.hash=s.toString()),t.href}var me={appUrl:String,config:[Object,String],headless:Boolean,import:String,lite:Boolean,loading:String,params:Object,template:String,view:String,height:String},W=c=>JSON.parse(JSON.stringify(c)),he={props:me,emits:["sdkReady"],setup(c,g){let{height:b,...p}=c,O=B(),x=B(b||""),o=B(),{config:e,...l}=p,t=JSON.stringify(e),s=JSON.stringify(l);return pe(()=>{O.value&&K(O.value,W(p)).then(d=>{o.value=d,g.emit("sdkReady",d)})}),ye(c,async d=>{var S;if(!O.value||!o.value)return;let{height:v,...w}=d;x.value=v||"";let{config:P,...h}=w;typeof P=="string"&&(P=await fetch(P).then(E=>E.json())),JSON.stringify(h)!==s?(await((S=o.value)==null?void 0:S.destroy()),K(O.value,W(w)).then(E=>{o.value=E,g.emit("sdkReady",E)})):JSON.stringify(P)!==t&&o.value.setConfig(W(P)||{}),t=JSON.stringify(P),s=JSON.stringify(h)}),ue(()=>{var d;(d=o.value)==null||d.destroy()}),()=>{var d,v;return fe("div",{ref:O,"data-height":x.value},((v=(d=g.slots).default)==null?void 0:v.call(d))||"")}}},be=he;export{be as default};
var te=Object.create;var X=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ie=(c,g)=>()=>(g||c((g={exports:{}}).exports,g),g.exports);var ae=(c,g,b,p)=>{if(g&&typeof g=="object"||typeof g=="function")for(let O of oe(g))!se.call(c,O)&&O!==b&&X(c,O,{get:()=>g[O],enumerable:!(p=ne(g,O))||p.enumerable});return c};var le=(c,g,b)=>(b=c!=null?te(re(c)):{},ae(g||!c||!c.__esModule?X(b,"default",{value:c,enumerable:!0}):b,c));var Y=ie((ve,D)=>{var ce=function(){var c=String.fromCharCode,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",p={};function O(o,e){if(!p[o]){p[o]={};for(var l=0;l<o.length;l++)p[o][o.charAt(l)]=l}return p[o][e]}var x={compressToBase64:function(o){if(o==null)return"";var e=x._compress(o,6,function(l){return g.charAt(l)});switch(e.length%4){default:case 0:return e;case 1:return e+"===";case 2:return e+"==";case 3:return e+"="}},decompressFromBase64:function(o){return o==null?"":o==""?null:x._decompress(o.length,32,function(e){return O(g,o.charAt(e))})},compressToUTF16:function(o){return o==null?"":x._compress(o,15,function(e){return c(e+32)})+" "},decompressFromUTF16:function(o){return o==null?"":o==""?null:x._decompress(o.length,16384,function(e){return o.charCodeAt(e)-32})},compressToUint8Array:function(o){for(var e=x.compress(o),l=new Uint8Array(e.length*2),t=0,s=e.length;t<s;t++){var d=e.charCodeAt(t);l[t*2]=d>>>8,l[t*2+1]=d%256}return l},decompressFromUint8Array:function(o){if(o==null)return x.decompress(o);for(var e=new Array(o.length/2),l=0,t=e.length;l<t;l++)e[l]=o[l*2]*256+o[l*2+1];var s=[];return e.forEach(function(d){s.push(c(d))}),x.decompress(s.join(""))},compressToEncodedURIComponent:function(o){return o==null?"":x._compress(o,6,function(e){return b.charAt(e)})},decompressFromEncodedURIComponent:function(o){return o==null?"":o==""?null:(o=o.replace(/ /g,"+"),x._decompress(o.length,32,function(e){return O(b,o.charAt(e))}))},compress:function(o){return x._compress(o,16,function(e){return c(e)})},_compress:function(o,e,l){if(o==null)return"";var t,s,d={},v={},w="",P="",h="",S=2,E=3,f=2,u=[],n=0,r=0,M;for(M=0;M<o.length;M+=1)if(w=o.charAt(M),Object.prototype.hasOwnProperty.call(d,w)||(d[w]=E++,v[w]=!0),P=h+w,Object.prototype.hasOwnProperty.call(d,P))h=P;else{if(Object.prototype.hasOwnProperty.call(v,h)){if(h.charCodeAt(0)<256){for(t=0;t<f;t++)n=n<<1,r==e-1?(r=0,u.push(l(n)),n=0):r++;for(s=h.charCodeAt(0),t=0;t<8;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1}else{for(s=1,t=0;t<f;t++)n=n<<1|s,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=0;for(s=h.charCodeAt(0),t=0;t<16;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1}S--,S==0&&(S=Math.pow(2,f),f++),delete v[h]}else for(s=d[h],t=0;t<f;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1;S--,S==0&&(S=Math.pow(2,f),f++),d[P]=E++,h=String(w)}if(h!==""){if(Object.prototype.hasOwnProperty.call(v,h)){if(h.charCodeAt(0)<256){for(t=0;t<f;t++)n=n<<1,r==e-1?(r=0,u.push(l(n)),n=0):r++;for(s=h.charCodeAt(0),t=0;t<8;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1}else{for(s=1,t=0;t<f;t++)n=n<<1|s,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=0;for(s=h.charCodeAt(0),t=0;t<16;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1}S--,S==0&&(S=Math.pow(2,f),f++),delete v[h]}else for(s=d[h],t=0;t<f;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1;S--,S==0&&(S=Math.pow(2,f),f++)}for(s=2,t=0;t<f;t++)n=n<<1|s&1,r==e-1?(r=0,u.push(l(n)),n=0):r++,s=s>>1;for(;;)if(n=n<<1,r==e-1){u.push(l(n));break}else r++;return u.join("")},decompress:function(o){return o==null?"":o==""?null:x._decompress(o.length,32768,function(e){return o.charCodeAt(e)})},_decompress:function(o,e,l){var t=[],s,d=4,v=4,w=3,P="",h=[],S,E,f,u,n,r,M,a={val:l(0),position:e,index:1};for(S=0;S<3;S+=1)t[S]=S;for(f=0,n=Math.pow(2,2),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;switch(s=f){case 0:for(f=0,n=Math.pow(2,8),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;M=c(f);break;case 1:for(f=0,n=Math.pow(2,16),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;M=c(f);break;case 2:return""}for(t[3]=M,E=M,h.push(M);;){if(a.index>o)return"";for(f=0,n=Math.pow(2,w),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;switch(M=f){case 0:for(f=0,n=Math.pow(2,8),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;t[v++]=c(f),M=v-1,d--;break;case 1:for(f=0,n=Math.pow(2,16),r=1;r!=n;)u=a.val&a.position,a.position>>=1,a.position==0&&(a.position=e,a.val=l(a.index++)),f|=(u>0?1:0)*r,r<<=1;t[v++]=c(f),M=v-1,d--;break;case 2:return h.join("")}if(d==0&&(d=Math.pow(2,w),w++),t[M])P=t[M];else if(M===v)P=E+E.charAt(0);else return null;h.push(P),t[v++]=E+P.charAt(0),d--,E=P,d==0&&(d=Math.pow(2,w),w++)}}};return x}();typeof D!="undefined"&&D!=null&&(D.exports=ce)});import{h as fe,onMounted as pe,onUnmounted as ue,ref as B,watch as ye}from"vue";var J=le(Y());async function K(c,g={}){typeof c=="object"&&!(c instanceof HTMLElement)&&(c.headless||c.view==="headless")&&(g=c,c=null);let{config:b={},headless:p,loading:O="lazy",view:x}=g,o=p||x==="headless",e=null,l=null;if(typeof c=="string")e=document.querySelector(c);else if(c instanceof HTMLElement)e=c;else if(!(o&&typeof c=="object"))throw new Error("A valid container element is required.");if(!e)if(o)e=document.createElement("div"),z(e),document.body.appendChild(e);else throw new Error(`Cannot find element: "${c}"`);let t=new URL(de(g)),s=t.origin;t.searchParams.set("embed","true"),t.searchParams.set("loading",o?"eager":O),t.searchParams.set("sdkVersion","0.13.0"),typeof b=="object"&&Object.keys(b).length>0&&t.searchParams.set("config","sdk");let d=g.params;typeof d=="object"&&Object.keys(d).length>0&&JSON.stringify(d).length<1800&&Object.keys(d).forEach(i=>{t.searchParams.set(i,encodeURIComponent(String(d[i])))});let v=!1,w="Cannot call API methods after calling `destroy()`.",P=[],h=(i,y="message")=>{addEventListener(y,i),P.push(i)},E=await new Promise(i=>{var k,L,j,H,U,q,Q,Z,$;if(!e)return;let y=e.dataset.height||e.style.height;if(y&&!o){let _=isNaN(Number(y))?y:y+"px";e.style.height=_}e.dataset.defaultStyles!=="false"&&!o&&((k=e.style).backgroundColor||(k.backgroundColor="#fff"),(L=e.style).border||(L.border="1px solid black"),(j=e.style).borderRadius||(j.borderRadius="8px"),(H=e.style).boxSizing||(H.boxSizing="border-box"),(U=e.style).padding||(U.padding="0"),(q=e.style).width||(q.width="100%"),(Q=e.style).height||(Q.height=e.style.height||"300px"),e.style.minHeight="200px",e.style.flexGrow="1",(Z=e.style).overflow||(Z.overflow="hidden"),($=e.style).resize||($.resize="vertical"));let C="livecodes",A=e.querySelector(`iframe.${C}`),m=A||document.createElement("iframe");m.classList.add(C),m.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),m.setAttribute("allowtransparency","true"),m.setAttribute("allowpaymentrequest","true"),m.setAttribute("allowfullscreen","true"),m.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts");let R=O==="eager"?"eager":"lazy";m.setAttribute("loading",R),o?z(m):(m.style.height="100%",m.style.minHeight="200px",m.style.width="100%",m.style.margin="0",m.style.border="0",m.style.borderRadius=e.style.borderRadius),h(function _(T){var I;T.source!==m.contentWindow||T.origin!==s||((I=T.data)==null?void 0:I.type)!=="livecodes-init"||(removeEventListener("message",_),l=Number(T.data.payload.appVersion.replace(/^v/,"")))}),(!l||l<46)&&h(function _(T){var I,G;T.source!==m.contentWindow||T.origin!==s||((I=T.data)==null?void 0:I.type)!=="livecodes-get-config"||(removeEventListener("message",_),(G=m.contentWindow)==null||G.postMessage({type:"livecodes-config",payload:b},s))}),m.onload=()=>{i(m)},m.src=t.href,A||e.appendChild(m)}),f=new Promise(i=>{h(function y(C){var A;C.source!==E.contentWindow||C.origin!==s||((A=C.data)==null?void 0:A.type)!=="livecodes-ready"||(removeEventListener("message",y),i(),f.settled=!0)})}),u=()=>v?Promise.reject(w):new Promise(async i=>{var C;f.settled&&i();let y={type:"livecodes-load"};(C=E.contentWindow)==null||C.postMessage(y,s),await f,i()}),n=(i,y)=>new Promise(async(C,A)=>{var R;if(v)return A(w);await u();let m=ee();h(function k(L){var j,H;if(!(L.source!==E.contentWindow||L.origin!==s||((j=L.data)==null?void 0:j.type)!=="livecodes-api-response"||((H=L.data)==null?void 0:H.id)!==m)&&L.data.method===i){removeEventListener("message",k);let U=L.data.payload;U!=null&&U.error?A(U.error):C(U)}}),(R=E.contentWindow)==null||R.postMessage({method:i,id:m,args:y},s)}),r={},M=["load","ready","code","console","tests","destroy"],a=(i,y)=>{var C;if(v)throw new Error(w);return M.includes(i)?(n("watch",[i]),r[i]||(r[i]=[]),(C=r[i])==null||C.push(y),{remove:()=>{var A,m;r[i]=(A=r[i])==null?void 0:A.filter(R=>R!==y),((m=r[i])==null?void 0:m.length)===0&&n("watch",[i,"unsubscribe"])}}):{remove:()=>{}}},F=i=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[i];h(async function(y){var m,R,k,L;let C=F((R=(m=y.data)==null?void 0:m.type)!=null?R:"");if(y.source!==E.contentWindow||y.origin!==s||!C||!r[C])return;let A=(k=y.data)==null?void 0:k.payload;(L=r[C])==null||L.forEach(j=>{j(A)})});let V=()=>{var i;(i=E==null?void 0:E.remove)==null||i.call(E),Object.values(r).forEach(y=>{y.length=0}),P.forEach(y=>removeEventListener("message",y)),P.length=0,N&&e&&N.unobserve(e),v=!0},N;O==="lazy"&&"IntersectionObserver"in window&&(N=new IntersectionObserver((i,y)=>{i.forEach(async C=>{C.isIntersecting&&(await u(),y.unobserve(e))})},{rootMargin:"150px"}),N.observe(e));function z(i){i.style.position="absolute",i.style.top="0",i.style.visibility="hidden",i.style.opacity="0"}let ee=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>u(),run:()=>n("run"),format:i=>n("format",[i]),getShareUrl:i=>n("getShareUrl",[i]),getConfig:i=>n("getConfig",[i]),setConfig:i=>n("setConfig",[i]),getCode:()=>n("getCode"),show:(i,y)=>n("show",[i,y]),runTests:()=>n("runTests"),onChange:i=>a("code",i),watch:a,exec:(i,...y)=>n("exec",[i,...y]),destroy:()=>v?Promise.reject(w):(V(),Promise.resolve())}}function de(c={}){let{appUrl:g="https://livecodes.io",params:b={},config:p={},headless:O,import:x,lite:o,view:e,...l}=c,t;try{t=new URL(g)}catch(v){throw new Error(`${g} is not a valid URL.`)}let s=new URLSearchParams;Object.entries(l).forEach(([v,w])=>{w!==void 0&&t.searchParams.set(v,String(w))});let d=c.view==="headless"||O;if(o&&(console.warn(`Deprecation notice: "lite" option is deprecated. Use "config: { mode: 'lite' }" instead.`),typeof p=="object"&&p.mode==null?p.mode="lite":t.searchParams.set("lite","true")),e&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),typeof p=="object"&&p.view==null&&e!=="headless"?p.view=e:t.searchParams.set("view",e)),typeof p=="string")try{new URL(p),t.searchParams.set("config",encodeURIComponent(p))}catch(v){throw new Error('"config" is not a valid URL or configuration object.')}else p&&typeof p=="object"&&Object.keys(p).length>0&&(p.title&&p.title!=="Untitled Project"&&t.searchParams.set("title",p.title),p.description&&p.description.length>0&&t.searchParams.set("description",p.description),s.set("config","code/"+(0,J.compressToEncodedURIComponent)(JSON.stringify(p))));if(b&&typeof b=="object"&&Object.keys(b).length>0)try{s.set("params",(0,J.compressToEncodedURIComponent)(JSON.stringify(b)))}catch(v){Object.keys(b).forEach(w=>{t.searchParams.set(w,encodeURIComponent(String(b[w])))})}return x&&t.searchParams.set("x",encodeURIComponent(x)),d&&t.searchParams.set("headless","true"),s.toString().length>0&&(t.hash=s.toString()),t.href}var me={appUrl:String,config:[Object,String],headless:Boolean,import:String,lite:Boolean,loading:String,params:Object,template:String,view:String,height:String},W=c=>JSON.parse(JSON.stringify(c)),he={props:me,emits:["sdkReady"],setup(c,g){let{height:b,...p}=c,O=B(),x=B(b||""),o=B(),{config:e,...l}=p,t=JSON.stringify(e),s=JSON.stringify(l);return pe(()=>{O.value&&K(O.value,W(p)).then(d=>{o.value=d,g.emit("sdkReady",d)})}),ye(c,async d=>{var S;if(!O.value||!o.value)return;let{height:v,...w}=d;x.value=v||"";let{config:P,...h}=w;typeof P=="string"&&(P=await fetch(P).then(E=>E.json())),JSON.stringify(h)!==s?(await((S=o.value)==null?void 0:S.destroy()),K(O.value,W(w)).then(E=>{o.value=E,g.emit("sdkReady",E)})):JSON.stringify(P)!==t&&o.value.setConfig(W(P)||{}),t=JSON.stringify(P),s=JSON.stringify(h)}),ue(()=>{var d;(d=o.value)==null||d.destroy()}),()=>{var d,v;return fe("div",{ref:O,"data-height":x.value},((v=(d=g.slots).default)==null?void 0:v.call(d))||"")}}},be=he;export{be as default};

Sorry, the diff of this file is too big to display