@builder.io/dev-tools
Version:
Builder.io Visual CMS Devtools
31 lines (30 loc) • 33.5 kB
JavaScript
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
var jt=Object.create;var pe=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,Ht=Object.prototype.hasOwnProperty;var Pt=(n,e,t)=>e in n?pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var N=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Wt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Rt(e))!Ht.call(n,i)&&i!==t&&pe(n,i,{get:()=>e[i],enumerable:!(r=It(e,i))||r.enumerable});return n};var Gt=(n,e,t)=>(t=n!=null?jt(Lt(n)):{},Wt(e||!n||!n.__esModule?pe(t,"default",{value:n,enumerable:!0}):t,n));var xe=(n,e,t)=>Pt(n,typeof e!="symbol"?e+"":e,t);var $=N((os,De)=>{"use strict";var de=class{source(){throw new Error("Abstract")}buffer(){let e=this.source();return Buffer.isBuffer(e)?e:Buffer.from(e,"utf8")}size(){return this.buffer().length}map(e){return null}sourceAndMap(e){return{source:this.source(),map:this.map(e)}}updateHash(e){throw new Error("Abstract")}};De.exports=de});var ie=N((as,je)=>{"use strict";var $t=n=>{if(n===void 0)return{};let e=n.lastIndexOf(`
`);if(e===-1)return{generatedLine:1,generatedColumn:n.length,source:n};let t=2;for(let r=0;r<e;r++)n.charCodeAt(r)===10&&t++;return{generatedLine:t,generatedColumn:n.length-e-1,source:n}};je.exports=$t});var J=N((ls,Ie)=>{"use strict";var Ut=n=>{let e=[],t=n.length,r=0;for(;r<t;)if(n.charCodeAt(r)===10)e.push(`
`),r++;else{let s=r+1;for(;s<t&&n.charCodeAt(s)!==10;)s++;e.push(n.slice(r,s+1)),r=s+1}return e};Ie.exports=Ut});var ue=N((hs,Re)=>{"use strict";var Ft=ie(),Vt=J(),Jt=(n,e,t,r)=>{let i=1,s=Vt(n),f;for(f of s)e(f,i,0,-1,-1,-1,-1),i++;return s.length===0||f.endsWith(`
`)?{generatedLine:s.length+1,generatedColumn:0}:{generatedLine:s.length,generatedColumn:f.length}};Re.exports=(n,e,t,r,i)=>i?Ft(n):Jt(n,e,t,r)});var X=N((ps,Le)=>{"use strict";var _e=!0;function Xt(){return _e}function Kt(){_e=!0}function Qt(){_e=!1}var ge=new Map,fe=0;function Yt(){return fe>0}function Zt(){fe++}function er(){--fe<=0&&(ge.clear(),fe=0)}function tr(n){if(!Yt()||!n||n.length<128||typeof n!="string")return n;let e=ge.get(n);return e===void 0&&(e=n,ge.set(n,e)),e}Le.exports={disableDualStringBufferCaching:Qt,enableDualStringBufferCaching:Kt,enterStringInterningRange:Zt,exitStringInterningRange:er,internString:tr,isDualStringBufferCachingEnabled:Xt}});var ce=N((ds,He)=>{"use strict";var rr=$(),sr=ue(),{internString:Se,isDualStringBufferCachingEnabled:me}=X(),Ae=class extends rr{constructor(e,t=!1){super();let r=Buffer.isBuffer(e);if(!r&&typeof e!="string")throw new TypeError("argument 'value' must be either string or Buffer");this._valueIsBuffer=!t&&r;let i=typeof e=="string"?Se(e):void 0;this._value=t&&r?void 0:typeof e=="string"?i:e,this._valueAsBuffer=r?e:void 0,this._valueAsString=r?void 0:i}isBuffer(){return this._valueIsBuffer}source(){if(this._value===void 0){let e=this._valueAsBuffer.toString("utf8");return me()&&(this._value=Se(e)),e}return this._value}buffer(){if(this._valueAsBuffer===void 0){let e=Buffer.from(this._value,"utf8");return me()&&(this._valueAsBuffer=e),e}return this._valueAsBuffer}map(e){return null}streamChunks(e,t,r,i){let s=this._valueAsString;if(s===void 0){let f=this.source();s=typeof f=="string"?f:f.toString("utf8"),me()&&(this._valueAsString=Se(s))}return sr(s,t,r,i,!!(e&&e.finalSource))}updateHash(e){e.update("RawSource"),e.update(this.buffer())}};He.exports=Ae});var Me=N((gs,We)=>{"use strict";var oe=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],Pe=32,nr=()=>{let n=1,e=0,t=0,r=1,i=0,s=0,f=!1,u=!1,p=!0;return(l,h,o,a,S,c)=>{if(f&&n===l){if(o===t&&a===r&&S===i&&!u&&c<0)return""}else if(o<0)return"";let d;n<l?(d=";".repeat(l-n),n=l,e=0,p=!1):p?(d="",p=!1):d=",";let g=A=>{let y=A>>>31&1,w=A>>31,E=(A+w^w)<<1|y;for(;;){let _=E&31;if(E>>=5,E===0){d+=oe[_];break}else d+=oe[_|Pe]}};return g(h-e),e=h,o>=0?(f=!0,o===t?d+="A":(g(o-t),t=o),g(a-r),r=a,S===i?d+="A":(g(S-i),i=S),c>=0?(g(c-s),s=c,u=!0):u=!1):f=!1,d}},ir=()=>{let n=0,e=1,t=0,r=1;return(i,s,f,u,p,l)=>{if(f<0||n===i)return"";let h,o=a=>{let S=a>>>31&1,c=a>>31,g=(a+c^c)<<1|S;for(;;){let A=g&31;if(g>>=5,g===0){h+=oe[A];break}else h+=oe[A|Pe]}};return n=i,i===e+1?(e=i,f===t?u===r+1?(r=u,";AACA"):(h=";AA",o(u-r),r=u,`${h}A`):(h=";A",o(f-t),t=f,o(u-r),r=u,`${h}A`)):(h=";".repeat(i-e),e=i,f===t?u===r+1?(r=u,`${h}AACA`):(h+="AA",o(u-r),r=u,`${h}A`):(h+="A",o(f-t),t=f,o(u-r),r=u,`${h}A`))}},ur=n=>n&&n.columns===!1?ir():nr();We.exports=ur});var K=N((_s,Be)=>{"use strict";var Ge=Me();Be.exports.getMap=(n,e)=>{let t="",r=[],i=[],s=[],f=Ge(e);return n.streamChunks({...e,source:!1,finalSource:!0},(u,p,l,h,o,a,S)=>{t+=f(p,l,h,o,a,S)},(u,p,l)=>{for(;r.length<u;)r.push(null);if(r[u]=p,l!==void 0){for(;i.length<u;)i.push(null);i[u]=l}},(u,p)=>{for(;s.length<u;)s.push(null);s[u]=p}),t.length>0?{version:3,file:"x",mappings:t,sources:r,sourcesContent:i.length>0?i:void 0,names:s}:null};Be.exports.getSourceAndMap=(n,e)=>{let t="",r="",i=[],s=[],f=[],u=Ge(e),{source:p}=n.streamChunks({...e,finalSource:!0},(l,h,o,a,S,c,d)=>{l!==void 0&&(t+=l),r+=u(h,o,a,S,c,d)},(l,h,o)=>{for(;i.length<l;)i.push(null);if(i[l]=h,o!==void 0){for(;s.length<l;)s.push(null);s[l]=o}},(l,h)=>{for(;f.length<l;)f.push(null);f[l]=h});return{source:p!==void 0?p:t,map:r.length>0?{version:3,file:"x",mappings:r,sources:i,sourcesContent:s.length>0?s:void 0,names:f}:null}}});var Ue=N((Ss,$e)=>{"use strict";var fr=n=>{let e=n.length;if(e===0)return null;let t=[],r=0;for(;r<e;){let i=r;e:{let s=n.charCodeAt(r);for(;s!==10&&s!==59&&s!==123&&s!==125;){if(++r>=e)break e;s=n.charCodeAt(r)}for(;s===59||s===32||s===123||s===125||s===13||s===9;){if(++r>=e)break e;s=n.charCodeAt(r)}s===10&&r++}t.push(n.slice(i,r))}return t};$e.exports=fr});var Je=N((ms,Ve)=>{"use strict";var cr=$(),{getMap:or,getSourceAndMap:ar}=K(),lr=ie(),hr=J(),pr=Ue(),{isDualStringBufferCachingEnabled:Fe}=X(),be=class extends cr{constructor(e,t){super();let r=Buffer.isBuffer(e);this._value=r?void 0:e,this._valueAsBuffer=r?e:void 0,this._name=t}getName(){return this._name}source(){if(this._value===void 0){let e=this._valueAsBuffer.toString("utf8");return Fe()&&(this._value=e),e}return this._value}buffer(){if(this._valueAsBuffer===void 0){let e=Buffer.from(this._value,"utf8");return Fe()&&(this._valueAsBuffer=e),e}return this._valueAsBuffer}map(e){return or(this,e)}sourceAndMap(e){return ar(this,e)}streamChunks(e,t,r,i){this._value===void 0&&(this._value=this._valueAsBuffer.toString("utf8")),r(0,this._name,this._value);let s=!!(e&&e.finalSource);if(!e||e.columns!==!1){let l=pr(this._value),h=1,o=0;if(l!==null)for(let a of l){let S=a.endsWith(`
`);S&&a.length===1?s||t(a,h,o,-1,-1,-1,-1):t(s?void 0:a,h,o,0,h,o,-1),S?(h++,o=0):o+=a.length}return{generatedLine:h,generatedColumn:o,source:s?this._value:void 0}}else if(s){let l=lr(this._value),{generatedLine:h,generatedColumn:o}=l;if(o===0)for(let a=1;a<h;a++)t(void 0,a,0,0,a,0,-1);else for(let a=1;a<=h;a++)t(void 0,a,0,0,a,0,-1);return l}let f=1,u=hr(this._value),p;for(p of u)t(s?void 0:p,f,0,0,f,0,-1),f++;return u.length===0||p.endsWith(`
`)?{generatedLine:u.length+1,generatedColumn:0,source:s?this._value:void 0}:{generatedLine:u.length,generatedColumn:p.length,source:s?this._value:void 0}}updateHash(e){e.update("OriginalSource"),e.update(this.buffer()),e.update(this._name||"")}};Ve.exports=be});var Ke=N((As,Xe)=>{"use strict";var dr=(n,e)=>{if(e<0)return null;let{sourceRoot:t,sources:r}=n,i=r[e];return t?t.endsWith("/")?t+i:`${t}/${i}`:i};Xe.exports=dr});var Ze=N((Ms,Ye)=>{"use strict";var Qe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Q=new Uint8Array(123);Q.fill(66);for(let n=0;n<Qe.length;n++)Q[Qe.charCodeAt(n)]=n;Q[44]=64;Q[59]=65;var gr=Q.length-1,_r=(n,e)=>{let t=new Uint32Array([0,0,1,0,0]),r=0,i=0,s=0,f=1,u=-1;for(let p=0;p<n.length;p++){let l=n.charCodeAt(p);if(l>gr)continue;let h=Q[l];if((h&64)!==0)t[0]>u&&(r===1?e(f,t[0],-1,-1,-1,-1):r===4?e(f,t[0],t[1],t[2],t[3],-1):r===5&&e(f,t[0],t[1],t[2],t[3],t[4]),[u]=t),r=0,h===65&&(f++,t[0]=0,u=-1);else if((h&32)===0){i|=h<<s;let o=i&1?-(i>>1):i>>1;t[r++]+=o,s=0,i=0}else i|=(h&31)<<s,s+=5}r===1?e(f,t[0],-1,-1,-1,-1):r===4?e(f,t[0],t[1],t[2],t[3],-1):r===5&&e(f,t[0],t[1],t[2],t[3],t[4])};Ye.exports=_r});var Y=N((Bs,rt)=>{"use strict";var et=ie(),ae=Ke(),le=Ze(),tt=J(),Sr=(n,e,t,r,i)=>{let s=tt(n);if(s.length===0)return{generatedLine:1,generatedColumn:0};let{sources:f,sourcesContent:u,names:p,mappings:l}=e;for(let _=0;_<f.length;_++)r(_,ae(e,_),u&&u[_]||void 0);if(p)for(let _=0;_<p.length;_++)i(_,p[_]);let h=s[s.length-1],o=h.endsWith(`
`),a=o?s.length+1:s.length,S=o?0:h.length,c=1,d=0,g=!1,A=-1,y=-1,w=-1,B=-1,E=(_,b,z,T,v,C)=>{if(g&&c<=s.length){let m,M=c,O=d,q=s[c-1];_!==c?(m=q.slice(d),c++,d=0):(m=q.slice(d,b),d=b),m&&t(m,M,O,A,y,w,B),g=!1}if(_>c&&d>0){if(c<=s.length){let m=s[c-1].slice(d);t(m,c,d,-1,-1,-1,-1)}c++,d=0}for(;_>c;)c<=s.length&&t(s[c-1],c,0,-1,-1,-1,-1),c++;if(b>d){if(c<=s.length){let m=s[c-1].slice(d,b);t(m,c,d,-1,-1,-1,-1)}d=b}z>=0&&(_<a||_===a&&b<S)&&(g=!0,A=z,y=T,w=v,B=C)};return le(l,E),E(a,S,-1,-1,-1,-1),{generatedLine:a,generatedColumn:S}},mr=(n,e,t,r,i)=>{let s=tt(n);if(s.length===0)return{generatedLine:1,generatedColumn:0};let{sources:f,sourcesContent:u,mappings:p}=e;for(let d=0;d<f.length;d++)r(d,ae(e,d),u&&u[d]||void 0);let l=1;for(le(p,(d,g,A,y,w,B)=>{if(!(A<0||d<l||d>s.length)){for(;d>l;)l<=s.length&&t(s[l-1],l,0,-1,-1,-1,-1),l++;d<=s.length&&(t(s[d-1],d,0,A,y,w,-1),l++)}});l<=s.length;l++)t(s[l-1],l,0,-1,-1,-1,-1);let o=s[s.length-1],a=o.endsWith(`
`),S=a?s.length+1:s.length,c=a?0:o.length;return{generatedLine:S,generatedColumn:c}},Ar=(n,e,t,r,i)=>{let s=et(n),{generatedLine:f,generatedColumn:u}=s;if(f===1&&u===0)return s;let{sources:p,sourcesContent:l,names:h,mappings:o}=e;for(let c=0;c<p.length;c++)r(c,ae(e,c),l&&l[c]||void 0);if(h)for(let c=0;c<h.length;c++)i(c,h[c]);let a=0;return le(o,(c,d,g,A,y,w)=>{c>=f&&(d>=u||c>f)||(g>=0?(t(void 0,c,d,g,A,y,w),a=c):a===c&&(t(void 0,c,d,-1,-1,-1,-1),a=0))}),s},Mr=(n,e,t,r,i)=>{let s=et(n),{generatedLine:f,generatedColumn:u}=s;if(f===1&&u===0)return{generatedLine:1,generatedColumn:0};let{sources:p,sourcesContent:l,mappings:h}=e;for(let c=0;c<p.length;c++)r(c,ae(e,c),l&&l[c]||void 0);let o=u===0?f-1:f,a=1;return le(h,(c,d,g,A,y,w)=>{g>=0&&a<=c&&c<=o&&(t(void 0,c,0,g,A,y,-1),a=c+1)}),s};rt.exports=(n,e,t,r,i,s,f)=>f?s?Ar(n,e,t,r,i):Sr(n,e,t,r,i):s?Mr(n,e,t,r,i):mr(n,e,t,r,i)});var ut=N((bs,it)=>{"use strict";var st=J(),nt=Y(),Br=(n,e,t,r,i,s,f,u,p,l,h)=>{let o=new Map,a=new Map,S=[],c=[],d=[],g=-2,A=[],y=[],w=[],B=[],E=[],_=[],b=[],z=(T,v)=>{if(T>b.length)return-1;let{mappingsData:C}=b[T-1],m=0,M=C.length/5;for(;m<M;){let O=m+M>>1;C[O*5]<=v?m=O+1:M=O}return m===0?-1:m-1};return nt(n,e,(T,v,C,m,M,O,q)=>{if(m===g){let j=z(M,O);if(j!==-1){let{chunks:L,mappingsData:H}=b[M-1],U=j*5,x=H[U+1],k=H[U+2],I=H[U+3],F=H[U+4];if(x>=0){let xt=L[j],Dt=H[U],te=O-Dt;if(te>0){let D=x<B.length?B[x]:null;if(D===void 0){let P=w[x];D=P?st(P):null,B[x]=D}if(D!==null){let P=k<=D.length?D[k-1].slice(I,I+te):"";xt.slice(0,te)===P&&(I+=te,F=-1)}}let re=x<A.length?A[x]:-2;if(re===-2){let[D,P]=x<y.length?y[x]:[null,void 0],V=o.get(D);V===void 0&&(o.set(D,V=o.size),u(V,D,P)),re=V,A[x]=re}let G=-1;if(F>=0){if(G=F<E.length?E[F]:-2,G===-2){let D=F<_.length?_[F]:void 0;if(D){let P=a.get(D);P===void 0&&(a.set(D,P=a.size),p(P,D)),G=P}else G=-1;E[F]=G}}else if(q>=0){let D=B[x];if(D===void 0){let P=w[x];D=P?st(P):null,B[x]=D}if(D!==null){let P=d[q],V=k<=D.length?D[k-1].slice(I,I+P.length):"";if(P===V&&(G=q<c.length?c[q]:-2,G===-2)){let se=d[q];if(se){let ne=a.get(se);ne===void 0&&(a.set(se,ne=a.size),p(ne,se)),G=ne}else G=-1;c[q]=G}}}f(T,v,C,re,k,I,G);return}}if(s){f(T,v,C,-1,-1,-1,-1);return}if(S[m]===-2){let L=o.get(t);L===void 0&&(o.set(n,L=o.size),u(L,t,r)),S[m]=L}}let R=m<0||m>=S.length?-1:S[m];if(R<0)f(T,v,C,-1,-1,-1,-1);else{let j=-1;if(q>=0&&q<c.length&&(j=c[q],j===-2)){let L=d[q],H=a.get(L);H===void 0&&(a.set(L,H=a.size),p(H,L)),j=H,c[q]=j}f(T,v,C,R,M,O,j)}},(T,v,C)=>{if(v===t)g=T,r!==void 0?C=r:r=C,S[T]=-2,nt(C,i,(m,M,O,q,R,j,L)=>{for(;b.length<M;)b.push({mappingsData:[],chunks:[]});let H=b[M-1];H.mappingsData.push(O,q,R,j,L),H.chunks.push(m)},(m,M,O)=>{w[m]=O,B[m]=void 0,A[m]=-2,y[m]=[M,O]},(m,M)=>{E[m]=-2,_[m]=M},!1,h);else{let m=o.get(v);m===void 0&&(o.set(v,m=o.size),u(m,v,C)),S[T]=m}},(T,v)=>{c[T]=-2,d[T]=v},l,h)};it.exports=Br});var ct=N((vs,ft)=>{"use strict";var br=$(),{getMap:vr,getSourceAndMap:Or}=K(),yr=ut(),wr=Y(),{isDualStringBufferCachingEnabled:W}=X(),ve=class extends br{constructor(e,t,r,i,s,f){super();let u=Buffer.isBuffer(e);this._valueAsString=u?void 0:e,this._valueAsBuffer=u?e:void 0,this._name=t,this._hasSourceMap=!!r;let p=Buffer.isBuffer(r),l=typeof r=="string";this._sourceMapAsObject=p||l?void 0:r,this._sourceMapAsString=l?r:void 0,this._sourceMapAsBuffer=p?r:void 0,this._hasOriginalSource=!!i;let h=Buffer.isBuffer(i);this._originalSourceAsString=h?void 0:i,this._originalSourceAsBuffer=h?i:void 0,this._hasInnerSourceMap=!!s;let o=Buffer.isBuffer(s),a=typeof s=="string";this._innerSourceMapAsObject=o||a?void 0:s||void 0,this._innerSourceMapAsString=a?s:void 0,this._innerSourceMapAsBuffer=o?s:void 0,this._removeOriginalSource=f}getArgsAsBuffers(){return[this.buffer(),this._name,this._sourceMapBuffer(),this._originalSourceBuffer(),this._innerSourceMapBuffer(),this._removeOriginalSource]}buffer(){if(this._valueAsBuffer===void 0){let e=Buffer.from(this._valueAsString,"utf8");return W()&&(this._valueAsBuffer=e),e}return this._valueAsBuffer}source(){if(this._valueAsString===void 0){let e=this._valueAsBuffer.toString("utf8");return W()&&(this._valueAsString=e),e}return this._valueAsString}_originalSourceBuffer(){if(this._originalSourceAsBuffer===void 0&&this._hasOriginalSource){let e=Buffer.from(this._originalSourceAsString,"utf8");return W()&&(this._originalSourceAsBuffer=e),e}return this._originalSourceAsBuffer}_originalSourceString(){if(this._originalSourceAsString===void 0&&this._hasOriginalSource){let e=this._originalSourceAsBuffer.toString("utf8");return W()&&(this._originalSourceAsString=e),e}return this._originalSourceAsString}_innerSourceMapObject(){if(this._innerSourceMapAsObject===void 0&&this._hasInnerSourceMap){let e=JSON.parse(this._innerSourceMapString());return W()&&(this._innerSourceMapAsObject=e),e}return this._innerSourceMapAsObject}_innerSourceMapBuffer(){if(this._innerSourceMapAsBuffer===void 0&&this._hasInnerSourceMap){let e=Buffer.from(this._innerSourceMapString(),"utf8");return W()&&(this._innerSourceMapAsBuffer=e),e}return this._innerSourceMapAsBuffer}_innerSourceMapString(){if(this._innerSourceMapAsString===void 0&&this._hasInnerSourceMap){if(this._innerSourceMapAsBuffer!==void 0){let t=this._innerSourceMapAsBuffer.toString("utf8");return W()&&(this._innerSourceMapAsString=t),t}let e=JSON.stringify(this._innerSourceMapAsObject);return W()&&(this._innerSourceMapAsString=e),e}return this._innerSourceMapAsString}_sourceMapObject(){if(this._sourceMapAsObject===void 0){let e=JSON.parse(this._sourceMapString());return W()&&(this._sourceMapAsObject=e),e}return this._sourceMapAsObject}_sourceMapBuffer(){if(this._sourceMapAsBuffer===void 0){let e=Buffer.from(this._sourceMapString(),"utf8");return W()&&(this._sourceMapAsBuffer=e),e}return this._sourceMapAsBuffer}_sourceMapString(){if(this._sourceMapAsString===void 0){if(this._sourceMapAsBuffer!==void 0){let t=this._sourceMapAsBuffer.toString("utf8");return W()&&(this._sourceMapAsString=t),t}let e=JSON.stringify(this._sourceMapAsObject);return W()&&(this._sourceMapAsString=e),e}return this._sourceMapAsString}map(e){return this._hasInnerSourceMap?vr(this,e):this._sourceMapObject()}sourceAndMap(e){return this._hasInnerSourceMap?Or(this,e):{source:this.source(),map:this._sourceMapObject()}}streamChunks(e,t,r,i){return this._hasInnerSourceMap?yr(this.source(),this._sourceMapObject(),this._name,this._originalSourceString(),this._innerSourceMapObject(),this._removeOriginalSource,t,r,i,!!(e&&e.finalSource),!!(e&&e.columns!==!1)):wr(this.source(),this._sourceMapObject(),t,r,i,!!(e&&e.finalSource),!!(e&&e.columns!==!1))}updateHash(e){e.update("SourceMapSource"),e.update(this.buffer()),e.update(this._sourceMapBuffer()),this._hasOriginalSource&&e.update(this._originalSourceBuffer()),this._hasInnerSourceMap&&e.update(this._innerSourceMapBuffer()),e.update(this._removeOriginalSource?"true":"false")}};ft.exports=ve});var Z=N((Os,ot)=>{"use strict";var Tr=ue(),Cr=Y();ot.exports=(n,e,t,r,i)=>{if(typeof n.streamChunks=="function")return n.streamChunks(e,t,r,i);let s=n.sourceAndMap(e);return s.map?Cr(s.source,s.map,t,r,i,!!(e&&e.finalSource),!!(e&&e.columns!==!1)):Tr(s.source,t,r,i,!!(e&&e.finalSource))}});var lt=N((ys,at)=>{"use strict";var Er=Me(),zr=Z(),qr=(n,e,t,r,i)=>{let s="",f="",u=[],p=[],l=[],h=Er({...e,columns:!0}),o=!!(e&&e.finalSource),{generatedLine:a,generatedColumn:S,source:c}=zr(n,e,(g,A,y,w,B,E,_)=>(g!==void 0&&(s+=g),f+=h(A,y,w,B,E,_),t(o?void 0:g,A,y,w,B,E,_)),(g,A,y)=>{for(;u.length<g;)u.push(null);if(u[g]=A,y!==void 0){for(;p.length<g;)p.push(null);p[g]=y}return r(g,A,y)},(g,A)=>{for(;l.length<g;)l.push(null);return l[g]=A,i(g,A)}),d=c!==void 0?c:s;return{result:{generatedLine:a,generatedColumn:S,source:o?d:void 0},source:d,map:f.length>0?{version:3,file:"x",mappings:f,sources:u,sourcesContent:p.length>0?p:void 0,names:l}:null}};at.exports=qr});var pt=N((ws,ht)=>{"use strict";var Nr=$(),kr=lt(),xr=ue(),Dr=Y(),{isDualStringBufferCachingEnabled:Oe}=X(),jr=n=>{if(typeof n!="object"||!n)return n;let e={...n};return n.mappings&&(e.mappings=Buffer.from(n.mappings,"utf8")),n.sourcesContent&&(e.sourcesContent=n.sourcesContent.map(t=>t&&Buffer.from(t,"utf8"))),e},Ir=n=>{if(typeof n!="object"||!n)return n;let e={...n};return n.mappings&&(e.mappings=n.mappings.toString("utf8")),n.sourcesContent&&(e.sourcesContent=n.sourcesContent.map(t=>t&&t.toString("utf8"))),e},ye=class extends Nr{constructor(e,t){super(),this._source=e,this._cachedSourceType=t?t.source:void 0,this._cachedSource=void 0,this._cachedBuffer=t?t.buffer:void 0,this._cachedSize=t?t.size:void 0,this._cachedMaps=t?t.maps:new Map,this._cachedHashUpdate=t?t.hash:void 0}getCachedData(){let e=new Map;for(let t of this._cachedMaps){let[,r]=t;r.bufferedMap===void 0&&(r.bufferedMap=jr(this._getMapFromCacheEntry(r))),e.set(t[0],{map:void 0,bufferedMap:r.bufferedMap})}return{buffer:this._cachedSource?this.buffer():this._cachedBuffer,source:this._cachedSourceType!==void 0?this._cachedSourceType:typeof this._cachedSource=="string"?!0:Buffer.isBuffer(this._cachedSource)?!1:void 0,size:this._cachedSize,maps:e,hash:this._cachedHashUpdate}}originalLazy(){return this._source}original(){return typeof this._source=="function"&&(this._source=this._source()),this._source}source(){let e=this._getCachedSource();return e!==void 0?e:this._cachedSource=this.original().source()}_getMapFromCacheEntry(e){return e.map!==void 0?e.map:e.bufferedMap!==void 0?e.map=Ir(e.bufferedMap):null}_getCachedSource(){if(this._cachedSource!==void 0)return this._cachedSource;if(this._cachedBuffer&&this._cachedSourceType!==void 0){let e=this._cachedSourceType?this._cachedBuffer.toString("utf8"):this._cachedBuffer;return Oe()&&(this._cachedSource=e),e}}buffer(){if(this._cachedBuffer!==void 0)return this._cachedBuffer;if(this._cachedSource!==void 0){let r=Buffer.isBuffer(this._cachedSource)?this._cachedSource:Buffer.from(this._cachedSource,"utf8");return Oe()&&(this._cachedBuffer=r),r}if(typeof this.original().buffer=="function")return this._cachedBuffer=this.original().buffer();let e=this.source();if(Buffer.isBuffer(e))return this._cachedBuffer=e;let t=Buffer.from(e,"utf8");return Oe()&&(this._cachedBuffer=t),t}size(){if(this._cachedSize!==void 0)return this._cachedSize;if(this._cachedBuffer!==void 0)return this._cachedSize=this._cachedBuffer.length;let e=this._getCachedSource();return e!==void 0?this._cachedSize=Buffer.byteLength(e):this._cachedSize=this.original().size()}sourceAndMap(e){let t=e?JSON.stringify(e):"{}",r=this._cachedMaps.get(t);if(r!==void 0){let f=this._getMapFromCacheEntry(r);return{source:this.source(),map:f}}let i=this._getCachedSource(),s;if(i!==void 0)s=this.original().map(e);else{let f=this.original().sourceAndMap(e);i=f.source,s=f.map,this._cachedSource=i}return this._cachedMaps.set(t,{map:s,bufferedMap:void 0}),{source:i,map:s}}streamChunks(e,t,r,i){let s=e?JSON.stringify(e):"{}";if(this._cachedMaps.has(s)&&(this._cachedBuffer!==void 0||this._cachedSource!==void 0)){let{source:u,map:p}=this.sourceAndMap(e);return p?Dr(u,p,t,r,i,!!(e&&e.finalSource),!0):xr(u,t,r,i,!!(e&&e.finalSource))}let f=kr(this.original(),e,t,r,i);return this._cachedSource=f.source,this._cachedMaps.set(s,{map:f.map,bufferedMap:void 0}),f.result}map(e){let t=e?JSON.stringify(e):"{}",r=this._cachedMaps.get(t);if(r!==void 0)return this._getMapFromCacheEntry(r);let i=this.original().map(e);return this._cachedMaps.set(t,{map:i,bufferedMap:void 0}),i}updateHash(e){if(this._cachedHashUpdate!==void 0){for(let s of this._cachedHashUpdate)e.update(s);return}let t=[],r,i={update:s=>{typeof s=="string"&&s.length<10240?r===void 0?r=s:(r+=s,r.length>102400&&(t.push(Buffer.from(r)),r=void 0)):(r!==void 0&&(t.push(Buffer.from(r)),r=void 0),t.push(s))}};this.original().updateHash(i),r!==void 0&&t.push(Buffer.from(r));for(let s of t)e.update(s);this._cachedHashUpdate=t}};ht.exports=ye});var _t=N((Ts,gt)=>{"use strict";var dt=ce(),Rr=$(),{getMap:Lr,getSourceAndMap:Hr}=K(),Pr=Z(),we=new WeakSet,Te=class n extends Rr{constructor(...e){super(),this._children=[];for(let t of e)if(t instanceof n)for(let r of t._children)this._children.push(r);else this._children.push(t);this._isOptimized=e.length===0}getChildren(){return this._isOptimized||this._optimize(),this._children}add(e){if(e instanceof n)for(let t of e._children)this._children.push(t);else this._children.push(e);this._isOptimized=!1}addAllSkipOptimizing(e){for(let t of e)this._children.push(t)}buffer(){this._isOptimized||this._optimize();let e=[];for(let t of this._children)if(typeof t.buffer=="function")e.push(t.buffer());else{let r=t.source();Buffer.isBuffer(r)?e.push(r):e.push(Buffer.from(r,"utf8"))}return Buffer.concat(e)}source(){this._isOptimized||this._optimize();let e="";for(let t of this._children)e+=t.source();return e}size(){this._isOptimized||this._optimize();let e=0;for(let t of this._children)e+=t.size();return e}map(e){return Lr(this,e)}sourceAndMap(e){return Hr(this,e)}streamChunks(e,t,r,i){if(this._isOptimized||this._optimize(),this._children.length===1)return this._children[0].streamChunks(e,t,r,i);let s=0,f=0,u=new Map,p=new Map,l=!!(e&&e.finalSource),h="",o=!1;for(let a of this._children){let S=[],c=[],d=0,{generatedLine:g,generatedColumn:A,source:y}=Pr(a,e,(w,B,E,_,b,z,T)=>{let v=B+s,C=B===1?E+f:E;o&&((B!==1||E!==0)&&t(void 0,s+1,f,-1,-1,-1,-1),o=!1);let m=_<0||_>=S.length?-1:S[_],M=T<0||T>=c.length?-1:c[T];d=m<0?0:B;let O;l?w!==void 0&&(h+=w):O=w,m<0?t(O,v,C,-1,-1,-1,-1):t(O,v,C,m,b,z,M)},(w,B,E)=>{let _=u.get(B);_===void 0&&(u.set(B,_=u.size),r(_,B,E)),S[w]=_},(w,B)=>{let E=p.get(B);E===void 0&&(p.set(B,E=p.size),i(E,B)),c[w]=E});y!==void 0&&(h+=y),o&&(g!==1||A!==0)&&(t(void 0,s+1,f,-1,-1,-1,-1),o=!1),g>1?f=A:f+=A,o=o||l&&d===g,s+=g-1}return{generatedLine:s+1,generatedColumn:f,source:l?h:void 0}}updateHash(e){this._isOptimized||this._optimize(),e.update("ConcatSource");for(let t of this._children)t.updateHash(e)}_optimize(){let e=[],t,r,i=u=>{r===void 0?r=u:Array.isArray(r)?r.push(u):r=[typeof r=="string"?r:r.source(),u]},s=u=>{r===void 0?r=u:Array.isArray(r)?r.push(u.source()):r=[typeof r=="string"?r:r.source(),u.source()]},f=()=>{if(Array.isArray(r)){let u=new dt(r.join(""));we.add(u),e.push(u)}else if(typeof r=="string"){let u=new dt(r);we.add(u),e.push(u)}else e.push(r)};for(let u of this._children)typeof u=="string"?t===void 0?t=u:t+=u:(t!==void 0&&(i(t),t=void 0),we.has(u)?s(u):(r!==void 0&&(f(),r=void 0),e.push(u)));t!==void 0&&i(t),r!==void 0&&f(),this._children=e,this._isOptimized=!0}};gt.exports=Te});var At=N((Cs,ze)=>{"use strict";var Wr=$(),{getMap:Gr,getSourceAndMap:$r}=K(),Ce=J(),Ur=Z(),mt=typeof process=="object"&&process.versions&&typeof process.versions.v8=="string"&&!/^[0-6]\./.test(process.versions.v8),St=536870912,ee=class{constructor(e,t,r,i){this.start=e,this.end=t,this.content=r,this.name=i,mt||(this.index=-1)}},Ee=class extends Wr{constructor(e,t){super(),this._source=e,this._name=t,this._replacements=[],this._isSorted=!0}getName(){return this._name}getReplacements(){return this._sortReplacements(),this._replacements}replace(e,t,r,i){if(typeof r!="string")throw new Error(`insertion must be a string, but is a ${typeof r}`);this._replacements.push(new ee(e,t,r,i)),this._isSorted=!1}insert(e,t,r){if(typeof t!="string")throw new Error(`insertion must be a string, but is a ${typeof t}: ${t}`);this._replacements.push(new ee(e,e-1,t,r)),this._isSorted=!1}source(){if(this._replacements.length===0)return this._source.source();let e=this._source.source(),t=0,r=[];this._sortReplacements();for(let i of this._replacements){let s=Math.floor(i.start),f=Math.floor(i.end+1);if(t<s){let u=s-t;r.push(e.slice(0,u)),e=e.slice(u),t=s}if(r.push(i.content),t<f){let u=f-t;e=e.slice(u),t=f}}return r.push(e),r.join("")}map(e){return this._replacements.length===0?this._source.map(e):Gr(this,e)}sourceAndMap(e){return this._replacements.length===0?this._source.sourceAndMap(e):$r(this,e)}original(){return this._source}_sortReplacements(){if(!this._isSorted){if(mt)this._replacements.sort((e,t)=>{let r=e.start-t.start;if(r!==0)return r;let i=e.end-t.end;return i!==0?i:0});else{for(let[e,t]of this._replacements.entries())t.index=e;this._replacements.sort((e,t)=>{let r=e.start-t.start;if(r!==0)return r;let i=e.end-t.end;return i!==0?i:e.index-t.index})}this._isSorted=!0}}streamChunks(e,t,r,i){this._sortReplacements();let s=this._replacements,f=0,u=0,p=-1,l=u<s.length?Math.floor(s[u].start):St,h=0,o=0,a=0,S=[],c=new Map,d=[],g=(_,b,z,T)=>{let v=_<S.length?S[_]:void 0;if(v===void 0)return!1;typeof v=="string"&&(v=Ce(v),S[_]=v);let C=b<=v.length?v[b-1]:null;return C===null?!1:C.slice(z,z+T.length)===T},{generatedLine:A,generatedColumn:y}=Ur(this._source,{...e,finalSource:!1},(_,b,z,T,v,C,m)=>{let M=0,O=_,q=f+O.length;if(p>f){if(p>=q){let j=b+h;O.endsWith(`
`)?(h--,a===j&&(o+=z)):a===j?o-=O.length:(o=-O.length,a=j),f=q;return}M=p-f,g(T,v,C,O.slice(0,M))&&(C+=M),f+=M;let R=b+h;a===R?o-=M:(o=-M,a=R),z+=M}if(l<q)do{let R=b+h;if(l>f){let k=l-f,I=O.slice(M,M+k);t(I,R,z+(R===a?o:0),T,v,C,m<0||m>=d.length?-1:d[m]),z+=k,M+=k,f=l,g(T,v,C,I)&&(C+=I.length)}let{content:j,name:L}=s[u],H=Ce(j),U=m;if(T>=0&&L){let k=c.get(L);k===void 0&&(k=c.size,c.set(L,k),i(k,L)),U=k}for(let k=0;k<H.length;k++){let I=H[k];t(I,R,z+(R===a?o:0),T,v,C,U),U=-1,k===H.length-1&&!I.endsWith(`
`)?a===R?o+=I.length:(o=I.length,a=R):(h++,R++,o=-z,a=R)}p=Math.max(p,Math.floor(s[u].end+1)),u++,l=u<s.length?Math.floor(s[u].start):St;let x=O.length-q+p-M;if(x>0){if(p>=q){let I=b+h;O.endsWith(`
`)?(h--,a===I&&(o+=z)):a===I?o-=O.length-M:(o=M-O.length,a=I),f=q;return}let k=b+h;g(T,v,C,O.slice(M,M+x))&&(C+=x),M+=x,f+=x,a===k?o-=x:(o=-x,a=k),z+=x}}while(l<q);if(M<O.length){let R=M===0?O:O.slice(M),j=b+h;t(R,j,z+(j===a?o:0),T,v,C,m<0?-1:d[m])}f=q},(_,b,z)=>{for(;S.length<_;)S.push(void 0);S[_]=z,r(_,b,z)},(_,b)=>{let z=c.get(b);z===void 0&&(z=c.size,c.set(b,z),i(z,b)),d[_]=z}),w="";for(;u<s.length;u++)w+=s[u].content;let B=A+h,E=Ce(w);for(let _=0;_<E.length;_++){let b=E[_];t(b,B,y+(B===a?o:0),-1,-1,-1,-1),_===E.length-1&&!b.endsWith(`
`)?a===B?o+=b.length:(o=b.length,a=B):(h++,B++,o=-y,a=B)}return{generatedLine:B,generatedColumn:y+(B===a?o:0)}}updateHash(e){this._sortReplacements(),e.update("ReplaceSource"),this._source.updateHash(e),e.update(this._name||"");for(let t of this._replacements)e.update(`${t.start}${t.end}${t.content}${t.name?t.name:""}`)}};ze.exports=Ee;ze.exports.Replacement=ee});var bt=N((Es,Bt)=>{"use strict";var Fr=ce(),Vr=$(),{getMap:Jr,getSourceAndMap:Xr}=K(),Kr=Z(),Mt=/\n(?=.|\s)/g,qe=class extends Vr{constructor(e,t){super(),this._prefix=e,this._source=typeof t=="string"||Buffer.isBuffer(t)?new Fr(t,!0):t}getPrefix(){return this._prefix}original(){return this._source}source(){let e=this._source.source(),t=this._prefix;return t+e.replace(Mt,`
${t}`)}map(e){return Jr(this,e)}sourceAndMap(e){return Xr(this,e)}streamChunks(e,t,r,i){let s=this._prefix,f=s.length,u=!!(e&&e.columns===!1),{generatedLine:p,generatedColumn:l,source:h}=Kr(this._source,e,(o,a,S,c,d,g,A)=>{S!==0?S+=f:o!==void 0?u||c<0?o=s+o:f>0&&(t(s,a,S,-1,-1,-1,-1),S+=f):u||(S+=f),t(o,a,S,c,d,g,A)},r,i);return{generatedLine:p,generatedColumn:l===0?0:f+l,source:h!==void 0?s+h.replace(Mt,`
${s}`):void 0}}updateHash(e){e.update("PrefixSource"),this._source.updateHash(e),e.update(this._prefix)}};Bt.exports=qe});var Ot=N((zs,vt)=>{"use strict";var Qr=$(),Ne=class extends Qr{constructor(e){super(),this._size=e}_error(){return new Error("Content and Map of this Source is not available (only size() is supported)")}size(){return this._size}source(){throw this._error()}buffer(){throw this._error()}map(e){throw this._error()}updateHash(e){throw this._error()}};vt.exports=Ne});var Tt=N((qs,wt)=>{"use strict";var yt=$(),ke=class n extends yt{static from(e){return e instanceof yt?e:new n(e)}constructor(e){super(),this._sourceLike=e}source(){return this._sourceLike.source()}buffer(){return typeof this._sourceLike.buffer=="function"?this._sourceLike.buffer():super.buffer()}size(){return typeof this._sourceLike.size=="function"?this._sourceLike.size():super.size()}map(e){return typeof this._sourceLike.map=="function"?this._sourceLike.map(e):super.map(e)}sourceAndMap(e){return typeof this._sourceLike.sourceAndMap=="function"?this._sourceLike.sourceAndMap(e):super.sourceAndMap(e)}updateHash(e){if(typeof this._sourceLike.updateHash=="function")return this._sourceLike.updateHash(e);if(typeof this._sourceLike.map=="function")throw new Error("A Source-like object with a 'map' method must also provide an 'updateHash' method");e.update(this.buffer())}};wt.exports=ke});var zt=N((Ns,Et)=>{"use strict";var Yr=n=>{let e=!1,t;return()=>(e||(t=n(),e=!0,n=void 0),t)},Ct=(n,e)=>{let t=Object.getOwnPropertyDescriptors(e);for(let r of Object.keys(t)){let i=t[r];if(i.get){let s=i.get;Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:Yr(s)})}else if(typeof i.value=="object")Object.defineProperty(n,r,{configurable:!1,enumerable:!0,writable:!1,value:Ct({},i.value)});else throw new Error("Exposed values must be either a getter or an nested object")}return Object.freeze(n)};Et.exports=Ct({},{get Source(){return $()},get RawSource(){return ce()},get OriginalSource(){return Je()},get SourceMapSource(){return ct()},get CachedSource(){return pt()},get ConcatSource(){return _t()},get ReplaceSource(){return At()},get PrefixSource(){return bt()},get SizeOnlySource(){return Ot()},get CompatSource(){return Tt()},util:{get stringBufferUtils(){return X()}}})});var kt=Gt(zt(),1);import{basename as Zr,join as es}from"node:path";import{existsSync as ts,readFileSync as rs,writeFileSync as ss}from"node:fs";import{createDevTools as ns}from"../core/index.mjs";import{createDevToolsNodeSys as is}from"../node/index.mjs";import{createDevToolsServer as us}from"../server/index.mjs";var qt="BuilderDevToolsPlugin",he=null;async function fs(n){let e=await is({cwd:process.cwd()});e.debug("webpack setupDevTools init");let t=await ns(e),r=await us({...t,getClientId:()=>"webpack-builder-dev-tools",closeAppServer:async()=>{},restartAppServer:async()=>{e.debug("restart server");let i=["next.config.js","next.config.ts","next.config.mjs","webpack.config.js","webpack.config.ts"].map(s=>es(e.getAppRootDir(),s));for(let s of i)if(ts(s)){e.debug(`restart server: ${s}`),ss(s,rs(s,{encoding:"utf-8"})),await new Promise(f=>setTimeout(f,50));return}},enableAppWatch:async i=>i,...e,...n});return e.debug("webpack setupDevTools done"),{server:r,sys:e}}var Nt=class{constructor(e){xe(this,"opts");this.opts=e||{},typeof this.opts.enabled!="boolean"&&(this.opts.enabled=process.env.NODE_ENV!=="production"),this.opts.enabled&&he==null&&(he=fs(this.opts))}apply(e){if(this.opts.enabled===!1)return;let t=e,r=t.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,i=new WeakMap;t.hooks.compilation.tap(qt,s=>{s.hooks.processAssets.tapAsync({name:qt,stage:r},async(f,u)=>{if(he!=null){for(let p of s.chunks)for(let l of p.files){let h=Zr(l),{server:o,sys:a}=await he;if(a.getFrameworks().some(A=>A.name==="next")&&h!=="webpack.js")continue;a.getAppRootDir=()=>t.context;let S=new URL("/~builder-dev-tools.js",o.getUrl()),c=`
;
/* Builder Devtools (Webpack) */
`;c+=`(() => {
`,c+=` if (typeof document !== "undefined") {
`,c+=` let devToolsScript = document.head.querySelector("script[data-builder-dev-tools]");
`,c+=` if (!devToolsScript) {
`,c+=` devToolsScript = document.createElement("script");
`,c+=` devToolsScript.setAttribute("src", ${JSON.stringify(S)});
`,c+=` devToolsScript.setAttribute("data-builder-dev-tools", "");
`,c+=` devToolsScript.setAttribute("async", "");
`,c+=` document.head.appendChild(devToolsScript);
`,c+=` }
`,c+=` }
`,c+=`})();
`;let d={chunk:p,filename:l},g=s.getPath(c,d);s.updateAsset(l,A=>{let y=i.get(A);if(!y||y.inject!==g){let w=new kt.ConcatSource(A,g);return i.set(A,{source:w,inject:g}),w}return y.source})}u()}})})}};export{Nt as BuilderDevToolsPlugin};