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