dsh-edge 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/worker/direct/index.js +17 -17
- package/worker/isolated/index.js +87 -87
package/worker/direct/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var fY=Object.create;var yp=Object.defineProperty;var pY=Object.getOwnPropertyDescriptor;var hY=Object.getOwnPropertyNames;var mY=Object.getPrototypeOf,gY=Object.prototype.hasOwnProperty;var R8=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),P8=e=>{throw TypeError(e)};var l=(e,t)=>yp(e,"name",{value:t,configurable:!0});var bu=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ti=(e,t)=>{for(var r in t)yp(e,r,{get:t[r],enumerable:!0})},yY=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of hY(t))!gY.call(e,i)&&i!==r&&yp(e,i,{get:()=>t[i],enumerable:!(n=pY(t,i))||n.enumerable});return e};var ay=(e,t,r)=>(r=e!=null?fY(mY(e)):{},yY(t||!e||!e.__esModule?yp(r,"default",{value:e,enumerable:!0}):r,e));var _l=(e,t,r)=>{if(t!=null){typeof t!="object"&&typeof t!="function"&&P8("Object expected");var n,i;r&&(n=t[R8("asyncDispose")]),n===void 0&&(n=t[R8("dispose")],r&&(i=n)),typeof n!="function"&&P8("Object not disposable"),i&&(n=function(){try{i.call(this)}catch(s){return Promise.reject(s)}}),e.push([r,n,t])}else r&&e.push([r]);return t},Tl=(e,t,r)=>{var n=typeof SuppressedError=="function"?SuppressedError:function(o,a,c,u){return u=Error(c),u.name="SuppressedError",u.error=o,u.suppressed=a,u},i=o=>t=r?new n(o,t,"An error was suppressed during disposal"):(r=!0,o),s=o=>{for(;o=e.pop();)try{var a=o[1]&&o[1].call(o[2]);if(o[0])return Promise.resolve(a).then(s,c=>(i(c),s()))}catch(c){i(c)}if(r)throw t};return s()};var gO=bu(($Oe,sg)=>{var mO=mO||function(e){return Buffer.from(e).toString("base64")};function wae(e){var t=this,r=Math.round,n=Math.floor,i=new Array(64),s=new Array(64),o=new Array(64),a=new Array(64),c,u,d,f,p=new Array(65535),h=new Array(65535),m=new Array(64),g=new Array(64),y=[],x=0,w=7,b=new Array(64),k=new Array(64),S=new Array(64),A=new Array(256),$=new Array(2048),O,_=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],F=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],D=[0,1,2,3,4,5,6,7,8,9,10,11],B=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],ee=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],L=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],W=[0,1,2,3,4,5,6,7,8,9,10,11],z=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],Q=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function H(j){for(var oe=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],ne=0;ne<64;ne++){var Ee=n((oe[ne]*j+50)/100);Ee<1?Ee=1:Ee>255&&(Ee=255),i[_[ne]]=Ee}for(var We=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],$e=0;$e<64;$e++){var He=n((We[$e]*j+50)/100);He<1?He=1:He>255&&(He=255),s[_[$e]]=He}for(var lt=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],Lt=0,Pt=0;Pt<8;Pt++)for(var E=0;E<8;E++)o[Lt]=1/(i[_[Lt]]*lt[Pt]*lt[E]*8),a[Lt]=1/(s[_[Lt]]*lt[Pt]*lt[E]*8),Lt++}l(H,"initQuantTables");function G(j,oe){for(var ne=0,Ee=0,We=new Array,$e=1;$e<=16;$e++){for(var He=1;He<=j[$e];He++)We[oe[Ee]]=[],We[oe[Ee]][0]=ne,We[oe[Ee]][1]=$e,Ee++,ne++;ne*=2}return We}l(G,"computeHuffmanTbl");function Z(){c=G(F,D),u=G(L,W),d=G(B,ee),f=G(z,Q)}l(Z,"initHuffmanTbl");function ue(){for(var j=1,oe=2,ne=1;ne<=15;ne++){for(var Ee=j;Ee<oe;Ee++)h[32767+Ee]=ne,p[32767+Ee]=[],p[32767+Ee][1]=ne,p[32767+Ee][0]=Ee;for(var We=-(oe-1);We<=-j;We++)h[32767+We]=ne,p[32767+We]=[],p[32767+We][1]=ne,p[32767+We][0]=oe-1+We;j<<=1,oe<<=1}}l(ue,"initCategoryNumber");function pe(){for(var j=0;j<256;j++)$[j]=19595*j,$[j+256>>0]=38470*j,$[j+512>>0]=7471*j+32768,$[j+768>>0]=-11059*j,$[j+1024>>0]=-21709*j,$[j+1280>>0]=32768*j+8421375,$[j+1536>>0]=-27439*j,$[j+1792>>0]=-5329*j}l(pe,"initRGBYUVTable");function ce(j){for(var oe=j[0],ne=j[1]-1;ne>=0;)oe&1<<ne&&(x|=1<<w),ne--,w--,w<0&&(x==255?(V(255),V(0)):V(x),w=7,x=0)}l(ce,"writeBits");function V(j){y.push(j)}l(V,"writeByte");function ve(j){V(j>>8&255),V(j&255)}l(ve,"writeWord");function Fe(j,oe){var ne,Ee,We,$e,He,lt,Lt,Pt,E=0,q,le=8,ye=64;for(q=0;q<le;++q){ne=j[E],Ee=j[E+1],We=j[E+2],$e=j[E+3],He=j[E+4],lt=j[E+5],Lt=j[E+6],Pt=j[E+7];var ae=ne+Pt,xe=ne-Pt,N=Ee+Lt,te=Ee-Lt,be=We+lt,we=We-lt,me=$e+He,Ie=$e-He,Ae=ae+me,Ve=ae-me,Ge=N+be,et=N-be;j[E]=Ae+Ge,j[E+4]=Ae-Ge;var rt=(et+Ve)*.707106781;j[E+2]=Ve+rt,j[E+6]=Ve-rt,Ae=Ie+we,Ge=we+te,et=te+xe;var St=(Ae-et)*.382683433,Zt=.5411961*Ae+St,wo=1.306562965*et+St,Fi=Ge*.707106781,Ui=xe+Fi,vu=xe-Fi;j[E+5]=vu+Zt,j[E+3]=vu-Zt,j[E+1]=Ui+wo,j[E+7]=Ui-wo,E+=8}for(E=0,q=0;q<le;++q){ne=j[E],Ee=j[E+8],We=j[E+16],$e=j[E+24],He=j[E+32],lt=j[E+40],Lt=j[E+48],Pt=j[E+56];var b8=ne+Pt,sy=ne-Pt,x8=Ee+Lt,E8=Ee-Lt,S8=We+lt,k8=We-lt,A8=$e+He,dY=$e-He,wu=b8+A8,oy=b8-A8,hp=x8+S8,mp=x8-S8;j[E]=wu+hp,j[E+32]=wu-hp;var I8=(mp+oy)*.707106781;j[E+16]=oy+I8,j[E+48]=oy-I8,wu=dY+k8,hp=k8+E8,mp=E8+sy;var $8=(wu-mp)*.382683433,_8=.5411961*wu+$8,T8=1.306562965*mp+$8,C8=hp*.707106781,O8=sy+C8,N8=sy-C8;j[E+40]=N8+_8,j[E+24]=N8-_8,j[E+8]=O8+T8,j[E+56]=O8-T8,E++}var gp;for(q=0;q<ye;++q)gp=j[q]*oe[q],m[q]=gp>0?gp+.5|0:gp-.5|0;return m}l(Fe,"fDCTQuant");function Ce(){ve(65504),ve(16),V(74),V(70),V(73),V(70),V(0),V(1),V(1),V(0),ve(1),ve(1),V(0),V(0)}l(Ce,"writeAPP0");function Pe(j){if(j){ve(65505),j[0]===69&&j[1]===120&&j[2]===105&&j[3]===102?ve(j.length+2):(ve(j.length+5+2),V(69),V(120),V(105),V(102),V(0));for(var oe=0;oe<j.length;oe++)V(j[oe])}}l(Pe,"writeAPP1");function Re(j,oe){ve(65472),ve(17),V(8),ve(oe),ve(j),V(3),V(1),V(17),V(0),V(2),V(17),V(1),V(3),V(17),V(1)}l(Re,"writeSOF0");function Le(){ve(65499),ve(132),V(0);for(var j=0;j<64;j++)V(i[j]);V(1);for(var oe=0;oe<64;oe++)V(s[oe])}l(Le,"writeDQT");function de(){ve(65476),ve(418),V(0);for(var j=0;j<16;j++)V(F[j+1]);for(var oe=0;oe<=11;oe++)V(D[oe]);V(16);for(var ne=0;ne<16;ne++)V(B[ne+1]);for(var Ee=0;Ee<=161;Ee++)V(ee[Ee]);V(1);for(var We=0;We<16;We++)V(L[We+1]);for(var $e=0;$e<=11;$e++)V(W[$e]);V(17);for(var He=0;He<16;He++)V(z[He+1]);for(var lt=0;lt<=161;lt++)V(Q[lt])}l(de,"writeDHT");function I(j){typeof j>"u"||j.constructor!==Array||j.forEach(oe=>{if(typeof oe=="string"){ve(65534);var ne=oe.length;ve(ne+2);var Ee;for(Ee=0;Ee<ne;Ee++)V(oe.charCodeAt(Ee))}})}l(I,"writeCOM");function R(){ve(65498),ve(12),V(3),V(1),V(0),V(2),V(17),V(3),V(17),V(0),V(63),V(0)}l(R,"writeSOS");function C(j,oe,ne,Ee,We){for(var $e=We[0],He=We[240],lt,Lt=16,Pt=63,E=64,q=Fe(j,oe),le=0;le<E;++le)g[_[le]]=q[le];var ye=g[0]-ne;ne=g[0],ye==0?ce(Ee[0]):(lt=32767+ye,ce(Ee[h[lt]]),ce(p[lt]));for(var ae=63;ae>0&&g[ae]==0;ae--);if(ae==0)return ce($e),ne;for(var xe=1,N;xe<=ae;){for(var te=xe;g[xe]==0&&xe<=ae;++xe);var be=xe-te;if(be>=Lt){N=be>>4;for(var we=1;we<=N;++we)ce(He);be=be&15}lt=32767+g[xe],ce(We[(be<<4)+h[lt]]),ce(p[lt]),xe++}return ae!=Pt&&ce($e),ne}l(C,"processDU");function U(){for(var j=String.fromCharCode,oe=0;oe<256;oe++)A[oe]=j(oe)}l(U,"initCharLookupTable"),this.encode=function(j,oe){var ne=new Date().getTime();oe&&K(oe),y=new Array,x=0,w=7,ve(65496),Ce(),I(j.comments),Pe(j.exifBuffer),Le(),Re(j.width,j.height),de(),R();var Ee=0,We=0,$e=0;x=0,w=7,this.encode.displayName="_encode_";for(var He=j.data,lt=j.width,Lt=j.height,Pt=lt*4,E=lt*3,q,le=0,ye,ae,xe,N,te,be,we,me;le<Lt;){for(q=0;q<Pt;){for(N=Pt*le+q,te=N,be=-1,we=0,me=0;me<64;me++)we=me>>3,be=(me&7)*4,te=N+we*Pt+be,le+we>=Lt&&(te-=Pt*(le+1+we-Lt)),q+be>=Pt&&(te-=q+be-Pt+4),ye=He[te++],ae=He[te++],xe=He[te++],b[me]=($[ye]+$[ae+256>>0]+$[xe+512>>0]>>16)-128,k[me]=($[ye+768>>0]+$[ae+1024>>0]+$[xe+1280>>0]>>16)-128,S[me]=($[ye+1280>>0]+$[ae+1536>>0]+$[xe+1792>>0]>>16)-128;Ee=C(b,o,Ee,c,d),We=C(k,a,We,u,f),$e=C(S,a,$e,u,f),q+=32}le+=8}if(w>=0){var Ie=[];Ie[1]=w+1,Ie[0]=(1<<w+1)-1,ce(Ie)}if(ve(65497),typeof sg>"u")return new Uint8Array(y);return Buffer.from(y);var Ae,Ve};function K(j){if(j<=0&&(j=1),j>100&&(j=100),O!=j){var oe=0;j<50?oe=Math.floor(5e3/j):oe=Math.floor(200-j*2),H(oe),O=j}}l(K,"setQuality");function J(){var j=new Date().getTime();e||(e=50),U(),Z(),ue(),pe(),K(e);var oe=new Date().getTime()-j}l(J,"init"),J()}l(wae,"JPEGEncoder");typeof sg<"u"?sg.exports=hO:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].encode=hO);function hO(e,t){typeof t>"u"&&(t=50);var r=new wae(t),n=r.encode(e,t);return{data:n,width:e.width,height:e.height}}l(hO,"encode")});var vO=bu((TOe,w6)=>{var v6=l((function(){"use strict";var t=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),r=4017,n=799,i=3406,s=2276,o=1567,a=3784,c=5793,u=2896;function d(){}l(d,"constructor");function f(w,b){for(var k=0,S=[],A,$,O=16;O>0&&!w[O-1];)O--;S.push({children:[],index:0});var _=S[0],F;for(A=0;A<O;A++){for($=0;$<w[A];$++){for(_=S.pop(),_.children[_.index]=b[k];_.index>0;){if(S.length===0)throw new Error("Could not recreate Huffman Table");_=S.pop()}for(_.index++,S.push(_);S.length<=A;)S.push(F={children:[],index:0}),_.children[_.index]=F.children,_=F;k++}A+1<O&&(S.push(F={children:[],index:0}),_.children[_.index]=F.children,_=F)}return S[0].children}l(f,"buildHuffmanTable");function p(w,b,k,S,A,$,O,_,F,D){var B=k.precision,ee=k.samplesPerLine,L=k.scanLines,W=k.mcusPerLine,z=k.progressive,Q=k.maxH,H=k.maxV,G=b,Z=0,ue=0;function pe(){if(ue>0)return ue--,Z>>ue&1;if(Z=w[b++],Z==255){var E=w[b++];if(E)throw new Error("unexpected marker: "+(Z<<8|E).toString(16))}return ue=7,Z>>>7}l(pe,"readBit");function ce(E){for(var q=E,le;(le=pe())!==null;){if(q=q[le],typeof q=="number")return q;if(typeof q!="object")throw new Error("invalid huffman sequence")}return null}l(ce,"decodeHuffman");function V(E){for(var q=0;E>0;){var le=pe();if(le===null)return;q=q<<1|le,E--}return q}l(V,"receive");function ve(E){var q=V(E);return q>=1<<E-1?q:q+(-1<<E)+1}l(ve,"receiveAndExtend");function Fe(E,q){var le=ce(E.huffmanTableDC),ye=le===0?0:ve(le);q[0]=E.pred+=ye;for(var ae=1;ae<64;){var xe=ce(E.huffmanTableAC),N=xe&15,te=xe>>4;if(N===0){if(te<15)break;ae+=16;continue}ae+=te;var be=t[ae];q[be]=ve(N),ae++}}l(Fe,"decodeBaseline");function Ce(E,q){var le=ce(E.huffmanTableDC),ye=le===0?0:ve(le)<<F;q[0]=E.pred+=ye}l(Ce,"decodeDCFirst");function Pe(E,q){q[0]|=pe()<<F}l(Pe,"decodeDCSuccessive");var Re=0;function Le(E,q){if(Re>0){Re--;return}for(var le=$,ye=O;le<=ye;){var ae=ce(E.huffmanTableAC),xe=ae&15,N=ae>>4;if(xe===0){if(N<15){Re=V(N)+(1<<N)-1;break}le+=16;continue}le+=N;var te=t[le];q[te]=ve(xe)*(1<<F),le++}}l(Le,"decodeACFirst");var de=0,I;function R(E,q){for(var le=$,ye=O,ae=0;le<=ye;){var xe=t[le],N=q[xe]<0?-1:1;switch(de){case 0:var te=ce(E.huffmanTableAC),be=te&15,ae=te>>4;if(be===0)ae<15?(Re=V(ae)+(1<<ae),de=4):(ae=16,de=1);else{if(be!==1)throw new Error("invalid ACn encoding");I=ve(be),de=ae?2:3}continue;case 1:case 2:q[xe]?q[xe]+=(pe()<<F)*N:(ae--,ae===0&&(de=de==2?3:0));break;case 3:q[xe]?q[xe]+=(pe()<<F)*N:(q[xe]=I<<F,de=0);break;case 4:q[xe]&&(q[xe]+=(pe()<<F)*N);break}le++}de===4&&(Re--,Re===0&&(de=0))}l(R,"decodeACSuccessive");function C(E,q,le,ye,ae){var xe=le/W|0,N=le%W,te=xe*E.v+ye,be=N*E.h+ae;E.blocks[te]===void 0&&D.tolerantDecoding||q(E,E.blocks[te][be])}l(C,"decodeMcu");function U(E,q,le){var ye=le/E.blocksPerLine|0,ae=le%E.blocksPerLine;E.blocks[ye]===void 0&&D.tolerantDecoding||q(E,E.blocks[ye][ae])}l(U,"decodeBlock");var K=S.length,J,j,oe,ne,Ee,We;z?$===0?We=_===0?Ce:Pe:We=_===0?Le:R:We=Fe;var $e=0,He,lt;K==1?lt=S[0].blocksPerLine*S[0].blocksPerColumn:lt=W*k.mcusPerColumn,A||(A=lt);for(var Lt,Pt;$e<lt;){for(j=0;j<K;j++)S[j].pred=0;if(Re=0,K==1)for(J=S[0],Ee=0;Ee<A;Ee++)U(J,We,$e),$e++;else for(Ee=0;Ee<A;Ee++){for(j=0;j<K;j++)for(J=S[j],Lt=J.h,Pt=J.v,oe=0;oe<Pt;oe++)for(ne=0;ne<Lt;ne++)C(J,We,$e,oe,ne);if($e++,$e===lt)break}if($e===lt)do{if(w[b]===255&&w[b+1]!==0)break;b+=1}while(b<w.length-2);if(ue=0,He=w[b]<<8|w[b+1],He<65280)throw new Error("marker was not found");if(He>=65488&&He<=65495)b+=2;else break}return b-G}l(p,"decodeScan");function h(w,b){var k=[],S=b.blocksPerLine,A=b.blocksPerColumn,$=S<<3,O=new Int32Array(64),_=new Uint8Array(64);function F(G,Z,ue){var pe=b.quantizationTable,ce,V,ve,Fe,Ce,Pe,Re,Le,de,I=ue,R;for(R=0;R<64;R++)I[R]=G[R]*pe[R];for(R=0;R<8;++R){var C=8*R;if(I[1+C]==0&&I[2+C]==0&&I[3+C]==0&&I[4+C]==0&&I[5+C]==0&&I[6+C]==0&&I[7+C]==0){de=c*I[0+C]+512>>10,I[0+C]=de,I[1+C]=de,I[2+C]=de,I[3+C]=de,I[4+C]=de,I[5+C]=de,I[6+C]=de,I[7+C]=de;continue}ce=c*I[0+C]+128>>8,V=c*I[4+C]+128>>8,ve=I[2+C],Fe=I[6+C],Ce=u*(I[1+C]-I[7+C])+128>>8,Le=u*(I[1+C]+I[7+C])+128>>8,Pe=I[3+C]<<4,Re=I[5+C]<<4,de=ce-V+1>>1,ce=ce+V+1>>1,V=de,de=ve*a+Fe*o+128>>8,ve=ve*o-Fe*a+128>>8,Fe=de,de=Ce-Re+1>>1,Ce=Ce+Re+1>>1,Re=de,de=Le+Pe+1>>1,Pe=Le-Pe+1>>1,Le=de,de=ce-Fe+1>>1,ce=ce+Fe+1>>1,Fe=de,de=V-ve+1>>1,V=V+ve+1>>1,ve=de,de=Ce*s+Le*i+2048>>12,Ce=Ce*i-Le*s+2048>>12,Le=de,de=Pe*n+Re*r+2048>>12,Pe=Pe*r-Re*n+2048>>12,Re=de,I[0+C]=ce+Le,I[7+C]=ce-Le,I[1+C]=V+Re,I[6+C]=V-Re,I[2+C]=ve+Pe,I[5+C]=ve-Pe,I[3+C]=Fe+Ce,I[4+C]=Fe-Ce}for(R=0;R<8;++R){var U=R;if(I[8+U]==0&&I[16+U]==0&&I[24+U]==0&&I[32+U]==0&&I[40+U]==0&&I[48+U]==0&&I[56+U]==0){de=c*ue[R+0]+8192>>14,I[0+U]=de,I[8+U]=de,I[16+U]=de,I[24+U]=de,I[32+U]=de,I[40+U]=de,I[48+U]=de,I[56+U]=de;continue}ce=c*I[0+U]+2048>>12,V=c*I[32+U]+2048>>12,ve=I[16+U],Fe=I[48+U],Ce=u*(I[8+U]-I[56+U])+2048>>12,Le=u*(I[8+U]+I[56+U])+2048>>12,Pe=I[24+U],Re=I[40+U],de=ce-V+1>>1,ce=ce+V+1>>1,V=de,de=ve*a+Fe*o+2048>>12,ve=ve*o-Fe*a+2048>>12,Fe=de,de=Ce-Re+1>>1,Ce=Ce+Re+1>>1,Re=de,de=Le+Pe+1>>1,Pe=Le-Pe+1>>1,Le=de,de=ce-Fe+1>>1,ce=ce+Fe+1>>1,Fe=de,de=V-ve+1>>1,V=V+ve+1>>1,ve=de,de=Ce*s+Le*i+2048>>12,Ce=Ce*i-Le*s+2048>>12,Le=de,de=Pe*n+Re*r+2048>>12,Pe=Pe*r-Re*n+2048>>12,Re=de,I[0+U]=ce+Le,I[56+U]=ce-Le,I[8+U]=V+Re,I[48+U]=V-Re,I[16+U]=ve+Pe,I[40+U]=ve-Pe,I[24+U]=Fe+Ce,I[32+U]=Fe-Ce}for(R=0;R<64;++R){var K=128+(I[R]+8>>4);Z[R]=K<0?0:K>255?255:K}}l(F,"quantizeAndInverse"),x($*A*8);for(var D,B,ee=0;ee<A;ee++){var L=ee<<3;for(D=0;D<8;D++)k.push(new Uint8Array($));for(var W=0;W<S;W++){F(b.blocks[ee][W],_,O);var z=0,Q=W<<3;for(B=0;B<8;B++){var H=k[L+B];for(D=0;D<8;D++)H[Q+D]=_[z++]}}}return k}l(h,"buildComponentData");function m(w){return w<0?0:w>255?255:w}l(m,"clampTo8bit"),d.prototype={load:l(function(b){var k=new XMLHttpRequest;k.open("GET",b,!0),k.responseType="arraybuffer",k.onload=(function(){var S=new Uint8Array(k.response||k.mozResponseArrayBuffer);this.parse(S),this.onload&&this.onload()}).bind(this),k.send(null)},"load"),parse:l(function(b){var k=this.opts.maxResolutionInMP*1e3*1e3,S=0,A=b.length;function $(){var te=b[S]<<8|b[S+1];return S+=2,te}l($,"readUint16");function O(){var te=$(),be=b.subarray(S,S+te-2);return S+=be.length,be}l(O,"readDataBlock");function _(te){var be=1,we=1,me,Ie;for(Ie in te.components)te.components.hasOwnProperty(Ie)&&(me=te.components[Ie],be<me.h&&(be=me.h),we<me.v&&(we=me.v));var Ae=Math.ceil(te.samplesPerLine/8/be),Ve=Math.ceil(te.scanLines/8/we);for(Ie in te.components)if(te.components.hasOwnProperty(Ie)){me=te.components[Ie];var Ge=Math.ceil(Math.ceil(te.samplesPerLine/8)*me.h/be),et=Math.ceil(Math.ceil(te.scanLines/8)*me.v/we),rt=Ae*me.h,St=Ve*me.v,Zt=St*rt,wo=[];x(Zt*256);for(var Fi=0;Fi<St;Fi++){for(var Ui=[],vu=0;vu<rt;vu++)Ui.push(new Int32Array(64));wo.push(Ui)}me.blocksPerLine=Ge,me.blocksPerColumn=et,me.blocks=wo}te.maxH=be,te.maxV=we,te.mcusPerLine=Ae,te.mcusPerColumn=Ve}l(_,"prepareComponents");var F=null,D=null,B=null,ee,L,W=[],z=[],Q=[],H=[],G=$(),Z=-1;if(this.comments=[],G!=65496)throw new Error("SOI not found");for(G=$();G!=65497;){var ue,pe,ce;switch(G){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var V=O();if(G===65534){var ve=String.fromCharCode.apply(null,V);this.comments.push(ve)}G===65504&&V[0]===74&&V[1]===70&&V[2]===73&&V[3]===70&&V[4]===0&&(F={version:{major:V[5],minor:V[6]},densityUnits:V[7],xDensity:V[8]<<8|V[9],yDensity:V[10]<<8|V[11],thumbWidth:V[12],thumbHeight:V[13],thumbData:V.subarray(14,14+3*V[12]*V[13])}),G===65505&&V[0]===69&&V[1]===120&&V[2]===105&&V[3]===102&&V[4]===0&&(this.exifBuffer=V.subarray(5,V.length)),G===65518&&V[0]===65&&V[1]===100&&V[2]===111&&V[3]===98&&V[4]===101&&V[5]===0&&(D={version:V[6],flags0:V[7]<<8|V[8],flags1:V[9]<<8|V[10],transformCode:V[11]});break;case 65499:for(var Fe=$(),Ce=Fe+S-2;S<Ce;){var Pe=b[S++];x(256);var Re=new Int32Array(64);if(Pe>>4===0)for(pe=0;pe<64;pe++){var Le=t[pe];Re[Le]=b[S++]}else if(Pe>>4===1)for(pe=0;pe<64;pe++){var Le=t[pe];Re[Le]=$()}else throw new Error("DQT: invalid table spec");W[Pe&15]=Re}break;case 65472:case 65473:case 65474:$(),ee={},ee.extended=G===65473,ee.progressive=G===65474,ee.precision=b[S++],ee.scanLines=$(),ee.samplesPerLine=$(),ee.components={},ee.componentsOrder=[];var de=ee.scanLines*ee.samplesPerLine;if(de>k){var I=Math.ceil((de-k)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${I}MP`)}var R=b[S++],C,U=0,K=0;for(ue=0;ue<R;ue++){C=b[S];var J=b[S+1]>>4,j=b[S+1]&15,oe=b[S+2];if(J<=0||j<=0)throw new Error("Invalid sampling factor, expected values above 0");ee.componentsOrder.push(C),ee.components[C]={h:J,v:j,quantizationIdx:oe},S+=3}_(ee),z.push(ee);break;case 65476:var ne=$();for(ue=2;ue<ne;){var Ee=b[S++],We=new Uint8Array(16),$e=0;for(pe=0;pe<16;pe++,S++)$e+=We[pe]=b[S];x(16+$e);var He=new Uint8Array($e);for(pe=0;pe<$e;pe++,S++)He[pe]=b[S];ue+=17+$e,(Ee>>4===0?H:Q)[Ee&15]=f(We,He)}break;case 65501:$(),L=$();break;case 65500:$(),$();break;case 65498:var lt=$(),Lt=b[S++],Pt=[],E;for(ue=0;ue<Lt;ue++){E=ee.components[b[S++]];var q=b[S++];E.huffmanTableDC=H[q>>4],E.huffmanTableAC=Q[q&15],Pt.push(E)}var le=b[S++],ye=b[S++],ae=b[S++],xe=p(b,S,ee,Pt,L,le,ye,ae>>4,ae&15,this.opts);S+=xe;break;case 65535:b[S]!==255&&S--;break;default:if(b[S-3]==255&&b[S-2]>=192&&b[S-2]<=254){S-=3;break}else if(G===224||G==225){if(Z!==-1)throw new Error(`first unknown JPEG marker at offset ${Z.toString(16)}, second unknown JPEG marker ${G.toString(16)} at offset ${(S-1).toString(16)}`);Z=S-1;let te=$();if(b[S+te-2]===255){S+=te-2;break}}throw new Error("unknown JPEG marker "+G.toString(16))}G=$()}if(z.length!=1)throw new Error("only single frame JPEGs supported");for(var ue=0;ue<z.length;ue++){var N=z[ue].components;for(var pe in N)N[pe].quantizationTable=W[N[pe].quantizationIdx],delete N[pe].quantizationIdx}this.width=ee.samplesPerLine,this.height=ee.scanLines,this.jfif=F,this.adobe=D,this.components=[];for(var ue=0;ue<ee.componentsOrder.length;ue++){var E=ee.components[ee.componentsOrder[ue]];this.components.push({lines:h(ee,E),scaleX:E.h/ee.maxH,scaleY:E.v/ee.maxV})}},"parse"),getData:l(function(b,k){var S=this.width/b,A=this.height/k,$,O,_,F,D,B,ee,L,W,z,Q=0,H,G,Z,ue,pe,ce,V,ve,Fe,Ce,Pe,Re=b*k*this.components.length;x(Re);var Le=new Uint8Array(Re);switch(this.components.length){case 1:for($=this.components[0],z=0;z<k;z++)for(D=$.lines[0|z*$.scaleY*A],W=0;W<b;W++)H=D[0|W*$.scaleX*S],Le[Q++]=H;break;case 2:for($=this.components[0],O=this.components[1],z=0;z<k;z++)for(D=$.lines[0|z*$.scaleY*A],B=O.lines[0|z*O.scaleY*A],W=0;W<b;W++)H=D[0|W*$.scaleX*S],Le[Q++]=H,H=B[0|W*O.scaleX*S],Le[Q++]=H;break;case 3:for(Pe=!0,this.adobe&&this.adobe.transformCode?Pe=!0:typeof this.opts.colorTransform<"u"&&(Pe=!!this.opts.colorTransform),$=this.components[0],O=this.components[1],_=this.components[2],z=0;z<k;z++)for(D=$.lines[0|z*$.scaleY*A],B=O.lines[0|z*O.scaleY*A],ee=_.lines[0|z*_.scaleY*A],W=0;W<b;W++)Pe?(H=D[0|W*$.scaleX*S],G=B[0|W*O.scaleX*S],Z=ee[0|W*_.scaleX*S],ve=m(H+1.402*(Z-128)),Fe=m(H-.3441363*(G-128)-.71413636*(Z-128)),Ce=m(H+1.772*(G-128))):(ve=D[0|W*$.scaleX*S],Fe=B[0|W*O.scaleX*S],Ce=ee[0|W*_.scaleX*S]),Le[Q++]=ve,Le[Q++]=Fe,Le[Q++]=Ce;break;case 4:if(!this.adobe)throw new Error("Unsupported color mode (4 components)");for(Pe=!1,this.adobe&&this.adobe.transformCode?Pe=!0:typeof this.opts.colorTransform<"u"&&(Pe=!!this.opts.colorTransform),$=this.components[0],O=this.components[1],_=this.components[2],F=this.components[3],z=0;z<k;z++)for(D=$.lines[0|z*$.scaleY*A],B=O.lines[0|z*O.scaleY*A],ee=_.lines[0|z*_.scaleY*A],L=F.lines[0|z*F.scaleY*A],W=0;W<b;W++)Pe?(H=D[0|W*$.scaleX*S],G=B[0|W*O.scaleX*S],Z=ee[0|W*_.scaleX*S],ue=L[0|W*F.scaleX*S],pe=255-m(H+1.402*(Z-128)),ce=255-m(H-.3441363*(G-128)-.71413636*(Z-128)),V=255-m(H+1.772*(G-128))):(pe=D[0|W*$.scaleX*S],ce=B[0|W*O.scaleX*S],V=ee[0|W*_.scaleX*S],ue=L[0|W*F.scaleX*S]),Le[Q++]=255-pe,Le[Q++]=255-ce,Le[Q++]=255-V,Le[Q++]=255-ue;break;default:throw new Error("Unsupported color mode")}return Le},"getData"),copyToImageData:l(function(b,k){var S=b.width,A=b.height,$=b.data,O=this.getData(S,A),_=0,F=0,D,B,ee,L,W,z,Q,H,G;switch(this.components.length){case 1:for(B=0;B<A;B++)for(D=0;D<S;D++)ee=O[_++],$[F++]=ee,$[F++]=ee,$[F++]=ee,k&&($[F++]=255);break;case 3:for(B=0;B<A;B++)for(D=0;D<S;D++)Q=O[_++],H=O[_++],G=O[_++],$[F++]=Q,$[F++]=H,$[F++]=G,k&&($[F++]=255);break;case 4:for(B=0;B<A;B++)for(D=0;D<S;D++)W=O[_++],z=O[_++],ee=O[_++],L=O[_++],Q=255-m(W*(1-L/255)+L),H=255-m(z*(1-L/255)+L),G=255-m(ee*(1-L/255)+L),$[F++]=Q,$[F++]=H,$[F++]=G,k&&($[F++]=255);break;default:throw new Error("Unsupported color mode")}},"copyToImageData")};var g=0,y=0;function x(w=0){var b=g+w;if(b>y){var k=Math.ceil((b-y)/1024/1024);throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${k}MB`)}g=b}return l(x,"requestMemoryAllocation"),d.resetMaxMemoryUsage=function(w){g=0,y=w},d.getBytesAllocated=function(){return g},d.requestMemoryAllocation=x,d}),"jpegImage")();typeof w6<"u"?w6.exports=yO:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].decode=yO);function yO(e,t={}){var r={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512},n={...r,...t},i=new Uint8Array(e),s=new v6;s.opts=n,v6.resetMaxMemoryUsage(n.maxMemoryUsageInMB*1024*1024),s.parse(i);var o=n.formatAsRGBA?4:3,a=s.width*s.height*o;try{v6.requestMemoryAllocation(a);var c={width:s.width,height:s.height,exifBuffer:s.exifBuffer,data:n.useTArray?new Uint8Array(a):Buffer.alloc(a)};s.comments.length>0&&(c.comments=s.comments)}catch(u){throw u instanceof RangeError?new Error("Could not allocate enough memory for the image. Required: "+a):u instanceof ReferenceError&&u.message==="Buffer is not defined"?new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true"):u}return s.copyToImageData(c,n.formatAsRGBA),c}l(yO,"decode")});var bO=bu((OOe,wO)=>{var bae=gO(),xae=vO();wO.exports={encode:bae,decode:xae}});var bN=bu(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});var iN=/highlight-(?:text|source)-([a-z0-9]+)/;function lN(e){e.addRule("highlightedCodeBlock",{filter:l(function(t){var r=t.firstChild;return t.nodeName==="DIV"&&iN.test(t.className)&&r&&r.nodeName==="PRE"},"filter"),replacement:l(function(t,r,n){var i=r.className||"",s=(i.match(iN)||[null,""])[1];return`
|
|
1
|
+
var fY=Object.create;var yp=Object.defineProperty;var pY=Object.getOwnPropertyDescriptor;var hY=Object.getOwnPropertyNames;var mY=Object.getPrototypeOf,gY=Object.prototype.hasOwnProperty;var R8=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),P8=e=>{throw TypeError(e)};var l=(e,t)=>yp(e,"name",{value:t,configurable:!0});var bu=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ti=(e,t)=>{for(var r in t)yp(e,r,{get:t[r],enumerable:!0})},yY=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of hY(t))!gY.call(e,i)&&i!==r&&yp(e,i,{get:()=>t[i],enumerable:!(n=pY(t,i))||n.enumerable});return e};var ay=(e,t,r)=>(r=e!=null?fY(mY(e)):{},yY(t||!e||!e.__esModule?yp(r,"default",{value:e,enumerable:!0}):r,e));var _l=(e,t,r)=>{if(t!=null){typeof t!="object"&&typeof t!="function"&&P8("Object expected");var n,i;r&&(n=t[R8("asyncDispose")]),n===void 0&&(n=t[R8("dispose")],r&&(i=n)),typeof n!="function"&&P8("Object not disposable"),i&&(n=function(){try{i.call(this)}catch(s){return Promise.reject(s)}}),e.push([r,n,t])}else r&&e.push([r]);return t},Tl=(e,t,r)=>{var n=typeof SuppressedError=="function"?SuppressedError:function(o,a,c,u){return u=Error(c),u.name="SuppressedError",u.error=o,u.suppressed=a,u},i=o=>t=r?new n(o,t,"An error was suppressed during disposal"):(r=!0,o),s=o=>{for(;o=e.pop();)try{var a=o[1]&&o[1].call(o[2]);if(o[0])return Promise.resolve(a).then(s,c=>(i(c),s()))}catch(c){i(c)}if(r)throw t};return s()};var gO=bu((_Oe,sg)=>{var mO=mO||function(e){return Buffer.from(e).toString("base64")};function wae(e){var t=this,r=Math.round,n=Math.floor,i=new Array(64),s=new Array(64),o=new Array(64),a=new Array(64),c,u,d,f,p=new Array(65535),h=new Array(65535),m=new Array(64),g=new Array(64),y=[],x=0,w=7,b=new Array(64),k=new Array(64),S=new Array(64),A=new Array(256),$=new Array(2048),O,_=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],F=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],D=[0,1,2,3,4,5,6,7,8,9,10,11],B=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],ee=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],L=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],W=[0,1,2,3,4,5,6,7,8,9,10,11],z=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],Q=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function H(j){for(var oe=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],ne=0;ne<64;ne++){var Ee=n((oe[ne]*j+50)/100);Ee<1?Ee=1:Ee>255&&(Ee=255),i[_[ne]]=Ee}for(var We=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],$e=0;$e<64;$e++){var He=n((We[$e]*j+50)/100);He<1?He=1:He>255&&(He=255),s[_[$e]]=He}for(var lt=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],Lt=0,Pt=0;Pt<8;Pt++)for(var E=0;E<8;E++)o[Lt]=1/(i[_[Lt]]*lt[Pt]*lt[E]*8),a[Lt]=1/(s[_[Lt]]*lt[Pt]*lt[E]*8),Lt++}l(H,"initQuantTables");function G(j,oe){for(var ne=0,Ee=0,We=new Array,$e=1;$e<=16;$e++){for(var He=1;He<=j[$e];He++)We[oe[Ee]]=[],We[oe[Ee]][0]=ne,We[oe[Ee]][1]=$e,Ee++,ne++;ne*=2}return We}l(G,"computeHuffmanTbl");function Z(){c=G(F,D),u=G(L,W),d=G(B,ee),f=G(z,Q)}l(Z,"initHuffmanTbl");function ue(){for(var j=1,oe=2,ne=1;ne<=15;ne++){for(var Ee=j;Ee<oe;Ee++)h[32767+Ee]=ne,p[32767+Ee]=[],p[32767+Ee][1]=ne,p[32767+Ee][0]=Ee;for(var We=-(oe-1);We<=-j;We++)h[32767+We]=ne,p[32767+We]=[],p[32767+We][1]=ne,p[32767+We][0]=oe-1+We;j<<=1,oe<<=1}}l(ue,"initCategoryNumber");function pe(){for(var j=0;j<256;j++)$[j]=19595*j,$[j+256>>0]=38470*j,$[j+512>>0]=7471*j+32768,$[j+768>>0]=-11059*j,$[j+1024>>0]=-21709*j,$[j+1280>>0]=32768*j+8421375,$[j+1536>>0]=-27439*j,$[j+1792>>0]=-5329*j}l(pe,"initRGBYUVTable");function ce(j){for(var oe=j[0],ne=j[1]-1;ne>=0;)oe&1<<ne&&(x|=1<<w),ne--,w--,w<0&&(x==255?(V(255),V(0)):V(x),w=7,x=0)}l(ce,"writeBits");function V(j){y.push(j)}l(V,"writeByte");function ve(j){V(j>>8&255),V(j&255)}l(ve,"writeWord");function Fe(j,oe){var ne,Ee,We,$e,He,lt,Lt,Pt,E=0,q,le=8,ye=64;for(q=0;q<le;++q){ne=j[E],Ee=j[E+1],We=j[E+2],$e=j[E+3],He=j[E+4],lt=j[E+5],Lt=j[E+6],Pt=j[E+7];var ae=ne+Pt,xe=ne-Pt,N=Ee+Lt,te=Ee-Lt,be=We+lt,we=We-lt,me=$e+He,Ie=$e-He,Ae=ae+me,Ve=ae-me,Ge=N+be,et=N-be;j[E]=Ae+Ge,j[E+4]=Ae-Ge;var rt=(et+Ve)*.707106781;j[E+2]=Ve+rt,j[E+6]=Ve-rt,Ae=Ie+we,Ge=we+te,et=te+xe;var St=(Ae-et)*.382683433,Zt=.5411961*Ae+St,wo=1.306562965*et+St,Fi=Ge*.707106781,Ui=xe+Fi,vu=xe-Fi;j[E+5]=vu+Zt,j[E+3]=vu-Zt,j[E+1]=Ui+wo,j[E+7]=Ui-wo,E+=8}for(E=0,q=0;q<le;++q){ne=j[E],Ee=j[E+8],We=j[E+16],$e=j[E+24],He=j[E+32],lt=j[E+40],Lt=j[E+48],Pt=j[E+56];var b8=ne+Pt,sy=ne-Pt,x8=Ee+Lt,E8=Ee-Lt,S8=We+lt,k8=We-lt,A8=$e+He,dY=$e-He,wu=b8+A8,oy=b8-A8,hp=x8+S8,mp=x8-S8;j[E]=wu+hp,j[E+32]=wu-hp;var I8=(mp+oy)*.707106781;j[E+16]=oy+I8,j[E+48]=oy-I8,wu=dY+k8,hp=k8+E8,mp=E8+sy;var $8=(wu-mp)*.382683433,_8=.5411961*wu+$8,T8=1.306562965*mp+$8,C8=hp*.707106781,O8=sy+C8,N8=sy-C8;j[E+40]=N8+_8,j[E+24]=N8-_8,j[E+8]=O8+T8,j[E+56]=O8-T8,E++}var gp;for(q=0;q<ye;++q)gp=j[q]*oe[q],m[q]=gp>0?gp+.5|0:gp-.5|0;return m}l(Fe,"fDCTQuant");function Ce(){ve(65504),ve(16),V(74),V(70),V(73),V(70),V(0),V(1),V(1),V(0),ve(1),ve(1),V(0),V(0)}l(Ce,"writeAPP0");function Pe(j){if(j){ve(65505),j[0]===69&&j[1]===120&&j[2]===105&&j[3]===102?ve(j.length+2):(ve(j.length+5+2),V(69),V(120),V(105),V(102),V(0));for(var oe=0;oe<j.length;oe++)V(j[oe])}}l(Pe,"writeAPP1");function Re(j,oe){ve(65472),ve(17),V(8),ve(oe),ve(j),V(3),V(1),V(17),V(0),V(2),V(17),V(1),V(3),V(17),V(1)}l(Re,"writeSOF0");function Le(){ve(65499),ve(132),V(0);for(var j=0;j<64;j++)V(i[j]);V(1);for(var oe=0;oe<64;oe++)V(s[oe])}l(Le,"writeDQT");function de(){ve(65476),ve(418),V(0);for(var j=0;j<16;j++)V(F[j+1]);for(var oe=0;oe<=11;oe++)V(D[oe]);V(16);for(var ne=0;ne<16;ne++)V(B[ne+1]);for(var Ee=0;Ee<=161;Ee++)V(ee[Ee]);V(1);for(var We=0;We<16;We++)V(L[We+1]);for(var $e=0;$e<=11;$e++)V(W[$e]);V(17);for(var He=0;He<16;He++)V(z[He+1]);for(var lt=0;lt<=161;lt++)V(Q[lt])}l(de,"writeDHT");function I(j){typeof j>"u"||j.constructor!==Array||j.forEach(oe=>{if(typeof oe=="string"){ve(65534);var ne=oe.length;ve(ne+2);var Ee;for(Ee=0;Ee<ne;Ee++)V(oe.charCodeAt(Ee))}})}l(I,"writeCOM");function R(){ve(65498),ve(12),V(3),V(1),V(0),V(2),V(17),V(3),V(17),V(0),V(63),V(0)}l(R,"writeSOS");function C(j,oe,ne,Ee,We){for(var $e=We[0],He=We[240],lt,Lt=16,Pt=63,E=64,q=Fe(j,oe),le=0;le<E;++le)g[_[le]]=q[le];var ye=g[0]-ne;ne=g[0],ye==0?ce(Ee[0]):(lt=32767+ye,ce(Ee[h[lt]]),ce(p[lt]));for(var ae=63;ae>0&&g[ae]==0;ae--);if(ae==0)return ce($e),ne;for(var xe=1,N;xe<=ae;){for(var te=xe;g[xe]==0&&xe<=ae;++xe);var be=xe-te;if(be>=Lt){N=be>>4;for(var we=1;we<=N;++we)ce(He);be=be&15}lt=32767+g[xe],ce(We[(be<<4)+h[lt]]),ce(p[lt]),xe++}return ae!=Pt&&ce($e),ne}l(C,"processDU");function U(){for(var j=String.fromCharCode,oe=0;oe<256;oe++)A[oe]=j(oe)}l(U,"initCharLookupTable"),this.encode=function(j,oe){var ne=new Date().getTime();oe&&K(oe),y=new Array,x=0,w=7,ve(65496),Ce(),I(j.comments),Pe(j.exifBuffer),Le(),Re(j.width,j.height),de(),R();var Ee=0,We=0,$e=0;x=0,w=7,this.encode.displayName="_encode_";for(var He=j.data,lt=j.width,Lt=j.height,Pt=lt*4,E=lt*3,q,le=0,ye,ae,xe,N,te,be,we,me;le<Lt;){for(q=0;q<Pt;){for(N=Pt*le+q,te=N,be=-1,we=0,me=0;me<64;me++)we=me>>3,be=(me&7)*4,te=N+we*Pt+be,le+we>=Lt&&(te-=Pt*(le+1+we-Lt)),q+be>=Pt&&(te-=q+be-Pt+4),ye=He[te++],ae=He[te++],xe=He[te++],b[me]=($[ye]+$[ae+256>>0]+$[xe+512>>0]>>16)-128,k[me]=($[ye+768>>0]+$[ae+1024>>0]+$[xe+1280>>0]>>16)-128,S[me]=($[ye+1280>>0]+$[ae+1536>>0]+$[xe+1792>>0]>>16)-128;Ee=C(b,o,Ee,c,d),We=C(k,a,We,u,f),$e=C(S,a,$e,u,f),q+=32}le+=8}if(w>=0){var Ie=[];Ie[1]=w+1,Ie[0]=(1<<w+1)-1,ce(Ie)}if(ve(65497),typeof sg>"u")return new Uint8Array(y);return Buffer.from(y);var Ae,Ve};function K(j){if(j<=0&&(j=1),j>100&&(j=100),O!=j){var oe=0;j<50?oe=Math.floor(5e3/j):oe=Math.floor(200-j*2),H(oe),O=j}}l(K,"setQuality");function J(){var j=new Date().getTime();e||(e=50),U(),Z(),ue(),pe(),K(e);var oe=new Date().getTime()-j}l(J,"init"),J()}l(wae,"JPEGEncoder");typeof sg<"u"?sg.exports=hO:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].encode=hO);function hO(e,t){typeof t>"u"&&(t=50);var r=new wae(t),n=r.encode(e,t);return{data:n,width:e.width,height:e.height}}l(hO,"encode")});var vO=bu((COe,w6)=>{var v6=l((function(){"use strict";var t=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),r=4017,n=799,i=3406,s=2276,o=1567,a=3784,c=5793,u=2896;function d(){}l(d,"constructor");function f(w,b){for(var k=0,S=[],A,$,O=16;O>0&&!w[O-1];)O--;S.push({children:[],index:0});var _=S[0],F;for(A=0;A<O;A++){for($=0;$<w[A];$++){for(_=S.pop(),_.children[_.index]=b[k];_.index>0;){if(S.length===0)throw new Error("Could not recreate Huffman Table");_=S.pop()}for(_.index++,S.push(_);S.length<=A;)S.push(F={children:[],index:0}),_.children[_.index]=F.children,_=F;k++}A+1<O&&(S.push(F={children:[],index:0}),_.children[_.index]=F.children,_=F)}return S[0].children}l(f,"buildHuffmanTable");function p(w,b,k,S,A,$,O,_,F,D){var B=k.precision,ee=k.samplesPerLine,L=k.scanLines,W=k.mcusPerLine,z=k.progressive,Q=k.maxH,H=k.maxV,G=b,Z=0,ue=0;function pe(){if(ue>0)return ue--,Z>>ue&1;if(Z=w[b++],Z==255){var E=w[b++];if(E)throw new Error("unexpected marker: "+(Z<<8|E).toString(16))}return ue=7,Z>>>7}l(pe,"readBit");function ce(E){for(var q=E,le;(le=pe())!==null;){if(q=q[le],typeof q=="number")return q;if(typeof q!="object")throw new Error("invalid huffman sequence")}return null}l(ce,"decodeHuffman");function V(E){for(var q=0;E>0;){var le=pe();if(le===null)return;q=q<<1|le,E--}return q}l(V,"receive");function ve(E){var q=V(E);return q>=1<<E-1?q:q+(-1<<E)+1}l(ve,"receiveAndExtend");function Fe(E,q){var le=ce(E.huffmanTableDC),ye=le===0?0:ve(le);q[0]=E.pred+=ye;for(var ae=1;ae<64;){var xe=ce(E.huffmanTableAC),N=xe&15,te=xe>>4;if(N===0){if(te<15)break;ae+=16;continue}ae+=te;var be=t[ae];q[be]=ve(N),ae++}}l(Fe,"decodeBaseline");function Ce(E,q){var le=ce(E.huffmanTableDC),ye=le===0?0:ve(le)<<F;q[0]=E.pred+=ye}l(Ce,"decodeDCFirst");function Pe(E,q){q[0]|=pe()<<F}l(Pe,"decodeDCSuccessive");var Re=0;function Le(E,q){if(Re>0){Re--;return}for(var le=$,ye=O;le<=ye;){var ae=ce(E.huffmanTableAC),xe=ae&15,N=ae>>4;if(xe===0){if(N<15){Re=V(N)+(1<<N)-1;break}le+=16;continue}le+=N;var te=t[le];q[te]=ve(xe)*(1<<F),le++}}l(Le,"decodeACFirst");var de=0,I;function R(E,q){for(var le=$,ye=O,ae=0;le<=ye;){var xe=t[le],N=q[xe]<0?-1:1;switch(de){case 0:var te=ce(E.huffmanTableAC),be=te&15,ae=te>>4;if(be===0)ae<15?(Re=V(ae)+(1<<ae),de=4):(ae=16,de=1);else{if(be!==1)throw new Error("invalid ACn encoding");I=ve(be),de=ae?2:3}continue;case 1:case 2:q[xe]?q[xe]+=(pe()<<F)*N:(ae--,ae===0&&(de=de==2?3:0));break;case 3:q[xe]?q[xe]+=(pe()<<F)*N:(q[xe]=I<<F,de=0);break;case 4:q[xe]&&(q[xe]+=(pe()<<F)*N);break}le++}de===4&&(Re--,Re===0&&(de=0))}l(R,"decodeACSuccessive");function C(E,q,le,ye,ae){var xe=le/W|0,N=le%W,te=xe*E.v+ye,be=N*E.h+ae;E.blocks[te]===void 0&&D.tolerantDecoding||q(E,E.blocks[te][be])}l(C,"decodeMcu");function U(E,q,le){var ye=le/E.blocksPerLine|0,ae=le%E.blocksPerLine;E.blocks[ye]===void 0&&D.tolerantDecoding||q(E,E.blocks[ye][ae])}l(U,"decodeBlock");var K=S.length,J,j,oe,ne,Ee,We;z?$===0?We=_===0?Ce:Pe:We=_===0?Le:R:We=Fe;var $e=0,He,lt;K==1?lt=S[0].blocksPerLine*S[0].blocksPerColumn:lt=W*k.mcusPerColumn,A||(A=lt);for(var Lt,Pt;$e<lt;){for(j=0;j<K;j++)S[j].pred=0;if(Re=0,K==1)for(J=S[0],Ee=0;Ee<A;Ee++)U(J,We,$e),$e++;else for(Ee=0;Ee<A;Ee++){for(j=0;j<K;j++)for(J=S[j],Lt=J.h,Pt=J.v,oe=0;oe<Pt;oe++)for(ne=0;ne<Lt;ne++)C(J,We,$e,oe,ne);if($e++,$e===lt)break}if($e===lt)do{if(w[b]===255&&w[b+1]!==0)break;b+=1}while(b<w.length-2);if(ue=0,He=w[b]<<8|w[b+1],He<65280)throw new Error("marker was not found");if(He>=65488&&He<=65495)b+=2;else break}return b-G}l(p,"decodeScan");function h(w,b){var k=[],S=b.blocksPerLine,A=b.blocksPerColumn,$=S<<3,O=new Int32Array(64),_=new Uint8Array(64);function F(G,Z,ue){var pe=b.quantizationTable,ce,V,ve,Fe,Ce,Pe,Re,Le,de,I=ue,R;for(R=0;R<64;R++)I[R]=G[R]*pe[R];for(R=0;R<8;++R){var C=8*R;if(I[1+C]==0&&I[2+C]==0&&I[3+C]==0&&I[4+C]==0&&I[5+C]==0&&I[6+C]==0&&I[7+C]==0){de=c*I[0+C]+512>>10,I[0+C]=de,I[1+C]=de,I[2+C]=de,I[3+C]=de,I[4+C]=de,I[5+C]=de,I[6+C]=de,I[7+C]=de;continue}ce=c*I[0+C]+128>>8,V=c*I[4+C]+128>>8,ve=I[2+C],Fe=I[6+C],Ce=u*(I[1+C]-I[7+C])+128>>8,Le=u*(I[1+C]+I[7+C])+128>>8,Pe=I[3+C]<<4,Re=I[5+C]<<4,de=ce-V+1>>1,ce=ce+V+1>>1,V=de,de=ve*a+Fe*o+128>>8,ve=ve*o-Fe*a+128>>8,Fe=de,de=Ce-Re+1>>1,Ce=Ce+Re+1>>1,Re=de,de=Le+Pe+1>>1,Pe=Le-Pe+1>>1,Le=de,de=ce-Fe+1>>1,ce=ce+Fe+1>>1,Fe=de,de=V-ve+1>>1,V=V+ve+1>>1,ve=de,de=Ce*s+Le*i+2048>>12,Ce=Ce*i-Le*s+2048>>12,Le=de,de=Pe*n+Re*r+2048>>12,Pe=Pe*r-Re*n+2048>>12,Re=de,I[0+C]=ce+Le,I[7+C]=ce-Le,I[1+C]=V+Re,I[6+C]=V-Re,I[2+C]=ve+Pe,I[5+C]=ve-Pe,I[3+C]=Fe+Ce,I[4+C]=Fe-Ce}for(R=0;R<8;++R){var U=R;if(I[8+U]==0&&I[16+U]==0&&I[24+U]==0&&I[32+U]==0&&I[40+U]==0&&I[48+U]==0&&I[56+U]==0){de=c*ue[R+0]+8192>>14,I[0+U]=de,I[8+U]=de,I[16+U]=de,I[24+U]=de,I[32+U]=de,I[40+U]=de,I[48+U]=de,I[56+U]=de;continue}ce=c*I[0+U]+2048>>12,V=c*I[32+U]+2048>>12,ve=I[16+U],Fe=I[48+U],Ce=u*(I[8+U]-I[56+U])+2048>>12,Le=u*(I[8+U]+I[56+U])+2048>>12,Pe=I[24+U],Re=I[40+U],de=ce-V+1>>1,ce=ce+V+1>>1,V=de,de=ve*a+Fe*o+2048>>12,ve=ve*o-Fe*a+2048>>12,Fe=de,de=Ce-Re+1>>1,Ce=Ce+Re+1>>1,Re=de,de=Le+Pe+1>>1,Pe=Le-Pe+1>>1,Le=de,de=ce-Fe+1>>1,ce=ce+Fe+1>>1,Fe=de,de=V-ve+1>>1,V=V+ve+1>>1,ve=de,de=Ce*s+Le*i+2048>>12,Ce=Ce*i-Le*s+2048>>12,Le=de,de=Pe*n+Re*r+2048>>12,Pe=Pe*r-Re*n+2048>>12,Re=de,I[0+U]=ce+Le,I[56+U]=ce-Le,I[8+U]=V+Re,I[48+U]=V-Re,I[16+U]=ve+Pe,I[40+U]=ve-Pe,I[24+U]=Fe+Ce,I[32+U]=Fe-Ce}for(R=0;R<64;++R){var K=128+(I[R]+8>>4);Z[R]=K<0?0:K>255?255:K}}l(F,"quantizeAndInverse"),x($*A*8);for(var D,B,ee=0;ee<A;ee++){var L=ee<<3;for(D=0;D<8;D++)k.push(new Uint8Array($));for(var W=0;W<S;W++){F(b.blocks[ee][W],_,O);var z=0,Q=W<<3;for(B=0;B<8;B++){var H=k[L+B];for(D=0;D<8;D++)H[Q+D]=_[z++]}}}return k}l(h,"buildComponentData");function m(w){return w<0?0:w>255?255:w}l(m,"clampTo8bit"),d.prototype={load:l(function(b){var k=new XMLHttpRequest;k.open("GET",b,!0),k.responseType="arraybuffer",k.onload=(function(){var S=new Uint8Array(k.response||k.mozResponseArrayBuffer);this.parse(S),this.onload&&this.onload()}).bind(this),k.send(null)},"load"),parse:l(function(b){var k=this.opts.maxResolutionInMP*1e3*1e3,S=0,A=b.length;function $(){var te=b[S]<<8|b[S+1];return S+=2,te}l($,"readUint16");function O(){var te=$(),be=b.subarray(S,S+te-2);return S+=be.length,be}l(O,"readDataBlock");function _(te){var be=1,we=1,me,Ie;for(Ie in te.components)te.components.hasOwnProperty(Ie)&&(me=te.components[Ie],be<me.h&&(be=me.h),we<me.v&&(we=me.v));var Ae=Math.ceil(te.samplesPerLine/8/be),Ve=Math.ceil(te.scanLines/8/we);for(Ie in te.components)if(te.components.hasOwnProperty(Ie)){me=te.components[Ie];var Ge=Math.ceil(Math.ceil(te.samplesPerLine/8)*me.h/be),et=Math.ceil(Math.ceil(te.scanLines/8)*me.v/we),rt=Ae*me.h,St=Ve*me.v,Zt=St*rt,wo=[];x(Zt*256);for(var Fi=0;Fi<St;Fi++){for(var Ui=[],vu=0;vu<rt;vu++)Ui.push(new Int32Array(64));wo.push(Ui)}me.blocksPerLine=Ge,me.blocksPerColumn=et,me.blocks=wo}te.maxH=be,te.maxV=we,te.mcusPerLine=Ae,te.mcusPerColumn=Ve}l(_,"prepareComponents");var F=null,D=null,B=null,ee,L,W=[],z=[],Q=[],H=[],G=$(),Z=-1;if(this.comments=[],G!=65496)throw new Error("SOI not found");for(G=$();G!=65497;){var ue,pe,ce;switch(G){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var V=O();if(G===65534){var ve=String.fromCharCode.apply(null,V);this.comments.push(ve)}G===65504&&V[0]===74&&V[1]===70&&V[2]===73&&V[3]===70&&V[4]===0&&(F={version:{major:V[5],minor:V[6]},densityUnits:V[7],xDensity:V[8]<<8|V[9],yDensity:V[10]<<8|V[11],thumbWidth:V[12],thumbHeight:V[13],thumbData:V.subarray(14,14+3*V[12]*V[13])}),G===65505&&V[0]===69&&V[1]===120&&V[2]===105&&V[3]===102&&V[4]===0&&(this.exifBuffer=V.subarray(5,V.length)),G===65518&&V[0]===65&&V[1]===100&&V[2]===111&&V[3]===98&&V[4]===101&&V[5]===0&&(D={version:V[6],flags0:V[7]<<8|V[8],flags1:V[9]<<8|V[10],transformCode:V[11]});break;case 65499:for(var Fe=$(),Ce=Fe+S-2;S<Ce;){var Pe=b[S++];x(256);var Re=new Int32Array(64);if(Pe>>4===0)for(pe=0;pe<64;pe++){var Le=t[pe];Re[Le]=b[S++]}else if(Pe>>4===1)for(pe=0;pe<64;pe++){var Le=t[pe];Re[Le]=$()}else throw new Error("DQT: invalid table spec");W[Pe&15]=Re}break;case 65472:case 65473:case 65474:$(),ee={},ee.extended=G===65473,ee.progressive=G===65474,ee.precision=b[S++],ee.scanLines=$(),ee.samplesPerLine=$(),ee.components={},ee.componentsOrder=[];var de=ee.scanLines*ee.samplesPerLine;if(de>k){var I=Math.ceil((de-k)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${I}MP`)}var R=b[S++],C,U=0,K=0;for(ue=0;ue<R;ue++){C=b[S];var J=b[S+1]>>4,j=b[S+1]&15,oe=b[S+2];if(J<=0||j<=0)throw new Error("Invalid sampling factor, expected values above 0");ee.componentsOrder.push(C),ee.components[C]={h:J,v:j,quantizationIdx:oe},S+=3}_(ee),z.push(ee);break;case 65476:var ne=$();for(ue=2;ue<ne;){var Ee=b[S++],We=new Uint8Array(16),$e=0;for(pe=0;pe<16;pe++,S++)$e+=We[pe]=b[S];x(16+$e);var He=new Uint8Array($e);for(pe=0;pe<$e;pe++,S++)He[pe]=b[S];ue+=17+$e,(Ee>>4===0?H:Q)[Ee&15]=f(We,He)}break;case 65501:$(),L=$();break;case 65500:$(),$();break;case 65498:var lt=$(),Lt=b[S++],Pt=[],E;for(ue=0;ue<Lt;ue++){E=ee.components[b[S++]];var q=b[S++];E.huffmanTableDC=H[q>>4],E.huffmanTableAC=Q[q&15],Pt.push(E)}var le=b[S++],ye=b[S++],ae=b[S++],xe=p(b,S,ee,Pt,L,le,ye,ae>>4,ae&15,this.opts);S+=xe;break;case 65535:b[S]!==255&&S--;break;default:if(b[S-3]==255&&b[S-2]>=192&&b[S-2]<=254){S-=3;break}else if(G===224||G==225){if(Z!==-1)throw new Error(`first unknown JPEG marker at offset ${Z.toString(16)}, second unknown JPEG marker ${G.toString(16)} at offset ${(S-1).toString(16)}`);Z=S-1;let te=$();if(b[S+te-2]===255){S+=te-2;break}}throw new Error("unknown JPEG marker "+G.toString(16))}G=$()}if(z.length!=1)throw new Error("only single frame JPEGs supported");for(var ue=0;ue<z.length;ue++){var N=z[ue].components;for(var pe in N)N[pe].quantizationTable=W[N[pe].quantizationIdx],delete N[pe].quantizationIdx}this.width=ee.samplesPerLine,this.height=ee.scanLines,this.jfif=F,this.adobe=D,this.components=[];for(var ue=0;ue<ee.componentsOrder.length;ue++){var E=ee.components[ee.componentsOrder[ue]];this.components.push({lines:h(ee,E),scaleX:E.h/ee.maxH,scaleY:E.v/ee.maxV})}},"parse"),getData:l(function(b,k){var S=this.width/b,A=this.height/k,$,O,_,F,D,B,ee,L,W,z,Q=0,H,G,Z,ue,pe,ce,V,ve,Fe,Ce,Pe,Re=b*k*this.components.length;x(Re);var Le=new Uint8Array(Re);switch(this.components.length){case 1:for($=this.components[0],z=0;z<k;z++)for(D=$.lines[0|z*$.scaleY*A],W=0;W<b;W++)H=D[0|W*$.scaleX*S],Le[Q++]=H;break;case 2:for($=this.components[0],O=this.components[1],z=0;z<k;z++)for(D=$.lines[0|z*$.scaleY*A],B=O.lines[0|z*O.scaleY*A],W=0;W<b;W++)H=D[0|W*$.scaleX*S],Le[Q++]=H,H=B[0|W*O.scaleX*S],Le[Q++]=H;break;case 3:for(Pe=!0,this.adobe&&this.adobe.transformCode?Pe=!0:typeof this.opts.colorTransform<"u"&&(Pe=!!this.opts.colorTransform),$=this.components[0],O=this.components[1],_=this.components[2],z=0;z<k;z++)for(D=$.lines[0|z*$.scaleY*A],B=O.lines[0|z*O.scaleY*A],ee=_.lines[0|z*_.scaleY*A],W=0;W<b;W++)Pe?(H=D[0|W*$.scaleX*S],G=B[0|W*O.scaleX*S],Z=ee[0|W*_.scaleX*S],ve=m(H+1.402*(Z-128)),Fe=m(H-.3441363*(G-128)-.71413636*(Z-128)),Ce=m(H+1.772*(G-128))):(ve=D[0|W*$.scaleX*S],Fe=B[0|W*O.scaleX*S],Ce=ee[0|W*_.scaleX*S]),Le[Q++]=ve,Le[Q++]=Fe,Le[Q++]=Ce;break;case 4:if(!this.adobe)throw new Error("Unsupported color mode (4 components)");for(Pe=!1,this.adobe&&this.adobe.transformCode?Pe=!0:typeof this.opts.colorTransform<"u"&&(Pe=!!this.opts.colorTransform),$=this.components[0],O=this.components[1],_=this.components[2],F=this.components[3],z=0;z<k;z++)for(D=$.lines[0|z*$.scaleY*A],B=O.lines[0|z*O.scaleY*A],ee=_.lines[0|z*_.scaleY*A],L=F.lines[0|z*F.scaleY*A],W=0;W<b;W++)Pe?(H=D[0|W*$.scaleX*S],G=B[0|W*O.scaleX*S],Z=ee[0|W*_.scaleX*S],ue=L[0|W*F.scaleX*S],pe=255-m(H+1.402*(Z-128)),ce=255-m(H-.3441363*(G-128)-.71413636*(Z-128)),V=255-m(H+1.772*(G-128))):(pe=D[0|W*$.scaleX*S],ce=B[0|W*O.scaleX*S],V=ee[0|W*_.scaleX*S],ue=L[0|W*F.scaleX*S]),Le[Q++]=255-pe,Le[Q++]=255-ce,Le[Q++]=255-V,Le[Q++]=255-ue;break;default:throw new Error("Unsupported color mode")}return Le},"getData"),copyToImageData:l(function(b,k){var S=b.width,A=b.height,$=b.data,O=this.getData(S,A),_=0,F=0,D,B,ee,L,W,z,Q,H,G;switch(this.components.length){case 1:for(B=0;B<A;B++)for(D=0;D<S;D++)ee=O[_++],$[F++]=ee,$[F++]=ee,$[F++]=ee,k&&($[F++]=255);break;case 3:for(B=0;B<A;B++)for(D=0;D<S;D++)Q=O[_++],H=O[_++],G=O[_++],$[F++]=Q,$[F++]=H,$[F++]=G,k&&($[F++]=255);break;case 4:for(B=0;B<A;B++)for(D=0;D<S;D++)W=O[_++],z=O[_++],ee=O[_++],L=O[_++],Q=255-m(W*(1-L/255)+L),H=255-m(z*(1-L/255)+L),G=255-m(ee*(1-L/255)+L),$[F++]=Q,$[F++]=H,$[F++]=G,k&&($[F++]=255);break;default:throw new Error("Unsupported color mode")}},"copyToImageData")};var g=0,y=0;function x(w=0){var b=g+w;if(b>y){var k=Math.ceil((b-y)/1024/1024);throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${k}MB`)}g=b}return l(x,"requestMemoryAllocation"),d.resetMaxMemoryUsage=function(w){g=0,y=w},d.getBytesAllocated=function(){return g},d.requestMemoryAllocation=x,d}),"jpegImage")();typeof w6<"u"?w6.exports=yO:typeof window<"u"&&(window["jpeg-js"]=window["jpeg-js"]||{},window["jpeg-js"].decode=yO);function yO(e,t={}){var r={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512},n={...r,...t},i=new Uint8Array(e),s=new v6;s.opts=n,v6.resetMaxMemoryUsage(n.maxMemoryUsageInMB*1024*1024),s.parse(i);var o=n.formatAsRGBA?4:3,a=s.width*s.height*o;try{v6.requestMemoryAllocation(a);var c={width:s.width,height:s.height,exifBuffer:s.exifBuffer,data:n.useTArray?new Uint8Array(a):Buffer.alloc(a)};s.comments.length>0&&(c.comments=s.comments)}catch(u){throw u instanceof RangeError?new Error("Could not allocate enough memory for the image. Required: "+a):u instanceof ReferenceError&&u.message==="Buffer is not defined"?new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true"):u}return s.copyToImageData(c,n.formatAsRGBA),c}l(yO,"decode")});var bO=bu((NOe,wO)=>{var bae=gO(),xae=vO();wO.exports={encode:bae,decode:xae}});var bN=bu(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});var iN=/highlight-(?:text|source)-([a-z0-9]+)/;function lN(e){e.addRule("highlightedCodeBlock",{filter:l(function(t){var r=t.firstChild;return t.nodeName==="DIV"&&iN.test(t.className)&&r&&r.nodeName==="PRE"},"filter"),replacement:l(function(t,r,n){var i=r.className||"",s=(i.match(iN)||[null,""])[1];return`
|
|
2
2
|
|
|
3
3
|
`+n.fence+s+`
|
|
4
4
|
`+r.firstChild.textContent+`
|
|
@@ -123,7 +123,7 @@ Example:
|
|
|
123
123
|
`,exitCode:129}}l(xt,"argvError");function Eo(e){return`${JSON.stringify(e,null,2)}
|
|
124
124
|
`}l(Eo,"json");function mi(e,t){return t instanceof ha?{stdout:"",stderr:`artifacts ${e}: ${t.message}
|
|
125
125
|
`,exitCode:1}:{stdout:"",stderr:`artifacts ${e}: ${t instanceof Error?t.message:String(t)}
|
|
126
|
-
`,exitCode:1}}l(mi,"mapError");function ji(e,t){let r={},n=[];for(let i=0;i<e.length;i++){let s=e[i];if(s==="--"){n.push(...e.slice(i+1));break}if(s.startsWith("--")){let o=s.indexOf("="),a=o===-1?s.slice(2):s.slice(2,o),c=t[a];if(!c)return{error:`unknown option '--${a}'`};if(c.kind==="bool"){if(o!==-1)return{error:`option '--${a}' takes no value`};r[a]=!0;continue}if(o!==-1){r[a]=s.slice(o+1);continue}let u=e[i+1];if(u===void 0)return{error:`option '--${a}' requires a value`};r[a]=u,i++;continue}n.push(s)}return{flags:r,positional:n}}l(ji,"parseFlags");var j8=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,z8="must start with a letter or digit and contain only letters, digits, '.', '_', and '-'";function B8(e){if(e.length===0)throw new cy(e,"must not be empty");if(!j8.test(e))throw new cy(e,z8);if(e.includes("__"))throw new cy(e,"must not contain '__'");return e}l(B8,"assertSessionId");function DY(e){if(e.length===0)throw new ly(e,"must not be empty");if(!j8.test(e))throw new ly(e,z8);if(e.includes("__"))throw new ly(e,"must not contain '__'");return e}l(DY,"assertLocalName");function bo(e,t){return`${B8(e)}__${DY(t)}`}l(bo,"scopedName");function W8(e){return`${B8(e)}__`}l(W8,"scopePrefix");function q8(e,t){let r=W8(e);if(!t.startsWith(r))return;let n=t.slice(r.length);if(!(n.length===0||n.includes("__")))return n}l(q8,"unscopedName");var LY=100;function H8(e,t){W8(t);let r={sessionId:t,async create(n,i){let s=await e.create(bo(t,n),i);return{...s,name:F8(t,s.name,n)}},async get(n){return MY(await(await e.get(bo(t,n))).info(),n)},async list(){let n=[],i,s=!1,o=new Set;for(;!s;){let a=await e.list({limit:LY,cursor:i});for(let u of a.repos){let d=q8(t,u.name);d!==void 0&&n.push({...u,name:d})}let c=a.cursor;if(c===void 0)s=!0;else{if(o.has(c))throw new Error(`artifacts list returned a non-advancing cursor: ${c}`);o.add(c),i=c}}return n},async import(n,i,s){let o=await e.import({source:i,target:{name:bo(t,n),opts:s}});return{...o,name:F8(t,o.name,n)}},async delete(n){return e.delete(bo(t,n))},async createToken(n,i,s){return(await e.get(bo(t,n))).createToken(i,s)},async listTokens(n){return(await e.get(bo(t,n))).listTokens()},async getToken(n,i){let{tokens:s}=await(await e.get(bo(t,n))).listTokens(),o=s.find(a=>a.id===i);if(!o)throw new wY(`no such token '${i}' in repo '${n}'`);return o},async revokeToken(n,i){return(await e.get(bo(t,n))).revokeToken(i)},async cli(n){return dy(r,n)}};return r}l(H8,"createArtifact");function MY(e,t){return{id:e.id,name:t,description:e.description,defaultBranch:e.defaultBranch,createdAt:e.createdAt,updatedAt:e.updatedAt,lastPushAt:e.lastPushAt,source:e.source,readOnly:e.readOnly,remote:e.remote}}l(MY,"repoInfo");function F8(e,t,r){return q8(e,t)??r}l(F8,"unscopeOr");function FY(e){return`Backend ${JSON.stringify(e)} is not callable; it does not accept structured input.`}l(FY,"notCallableMessage");var K8=class{static{l(this,"WorkspaceRuntime")}#e;constructor(e){this.#e=e}isCallable(e){return this.#e.callableBackendIds.has(e)}async exec(e,t={}){t.id!==void 0&&vp(t.id);let r=this.#r(t.backend);if(t.input!==void 0&&!this.isCallable(r))throw new Error(FY(r));let n=await this.#e.backendHandle(r),i=await n.exec({id:t.id,source:e,cwd:t.cwd,input:t.input,env:t.env,stdin:t.stdin,timeoutMs:t.timeoutMs});return G8(n,r,i.id,i.events,t.encoding,!0,i.sync)}async getExec(e,t={}){vp(e);let r=this.#r(t.backend),n=await this.#e.backendHandle(r),i=await n.getExec({id:e,after:zY(t.resume)});return G8(n,r,i.id,i.events,t.encoding,t.resume===void 0||t.resume==="full",i.sync)}async killExec(e,t={}){vp(e);let r=this.#r(t.backend);await(await this.#e.backendHandle(r)).killExec({id:e,signal:t.signal})}async disposeExec(e,t={}){vp(e);let r=this.#r(t.backend);await(await this.#e.backendHandle(r)).disposeExec({id:e})}#r(e){let t=this.#e.resolveBackendId(e);if(!t)throw new Error("Workspace has no execution backend configured. Pass `backends` to the Workspace constructor.");return t}};function G8(e,t,r,n,i,s=!0,o){let a,c=!1,u,d,f,p=new ReadableStream({async pull(h){if(a==="result"){h.error(new Error("runtime handle already consumed by result()"));return}a="stream",u??=UY(n,i).getReader();try{let m=await u.read();m.done?(u.releaseLock(),u=void 0,h.close()):h.enqueue(m.value)}catch(m){u?.releaseLock(),u=void 0,h.error(m)}},async cancel(h){if(c=!0,u)try{await u.cancel(h)}finally{u.releaseLock(),u=void 0}else await n.cancel(h)}},{highWaterMark:0});return Object.defineProperties(p,{id:{value:r,enumerable:!1},backend:{value:t,enumerable:!1},result:{value:l(()=>{if(a==="stream")throw new Error("runtime handle already streaming: result() and streaming are exclusive");return a="result",f??=(async()=>{let h=l(g=>{d=g},"setReader");if(s&&!c)return V8(n,i,h,o);c||await n.cancel("result() requested a full replay");let m=await e.getExec({id:r});return V8(m.events,i,h,m.sync)})(),f},"value")},kill:{value:l(h=>e.killExec({id:r,signal:h}),"value")},[Symbol.dispose]:{value:l(()=>{d?d.cancel().catch(()=>{}):p.cancel().catch(()=>{})},"value")}}),p}l(G8,"wrapModuleHandle");function UY(e,t){if(t!=="utf8")return e;let r=new TextDecoder,n=new TextDecoder,i,s,o=0,a=l((u,d)=>{o=d.seq,u.enqueue(d)},"enqueue"),c=l((u,d)=>{let f=[],p=r.decode(),h=n.decode();p&&i&&f.push({...i,name:"stdout",value:p}),h&&s&&f.push({...s,name:"stderr",value:h}),f.sort((y,x)=>y.seq-x.seq);let m=d!==void 0&&d>o?d-o:1,g=0;for(let y of f)g+=1,a(u,{...y,seq:o+m*g/(f.length+1)});i=void 0,s=void 0},"flushPending");return e.pipeThrough(new TransformStream({transform(u,d){u.name==="stdout"||u.name==="stderr"?(u.name==="stdout"?i={id:u.id,seq:u.seq}:s={id:u.id,seq:u.seq},a(d,{...u,value:(u.name==="stdout"?r:n).decode(u.value,{stream:!0})})):(c(d,u.seq),a(d,u))},flush:c}))}l(UY,"transformModuleEvents");async function V8(e,t,r,n){let i=[],s=[],o,a=-1,c=e.getReader();r(c);try{for(;;){let d=await c.read();if(d.done)break;let f=d.value;f.name==="stdout"&&i.push(f.value),f.name==="stderr"&&s.push(f.value),f.name==="exit"&&(a=f.code,"result"in f&&(o=f.result))}}finally{c.releaseLock(),r(void 0)}let u=n?await n.outcome:void 0;return{status:a===0?"completed":jY(a)?"cancelled":"failed",exitCode:a,stdout:Z8(i,t),stderr:Z8(s,t),...o===void 0?{}:{value:o},pushed:n?.pushed??0,pulled:u?.applied??0,skipped:u?.skipped??[],sync:u?.sync??{status:"complete",applied:0,skipped:[]}}}l(V8,"drainModuleResult");function jY(e){return e===129||e===130||e===137||e===143}l(jY,"isCancellationExitCode");function Z8(e,t){let r=e.reduce((s,o)=>s+o.byteLength,0),n=new Uint8Array(r),i=0;for(let s of e)n.set(s,i),i+=s.byteLength;return t==="utf8"?new TextDecoder().decode(n):n}l(Z8,"join");function vp(e){if(e.length===0)throw new Error("Workspace runtime execution id must not be empty.");if(new TextEncoder().encode(e).byteLength>256)throw new Error("Workspace runtime execution id exceeds 256 bytes.")}l(vp,"assertExecutionId");function zY(e){if(e==="tail")return"tail";if(typeof e=="number")return e}l(zY,"resumeToAfter");var BY=class extends Error{static{l(this,"WorkspaceTransportError")}name="WorkspaceTransportError";constructor(e,t){super(e),t?.cause!==void 0&&(this.cause=t.cause)}},WY=[/rpc session was shut down/i,/rpc stub after it has been disposed/i,/rpc was canceled/i,/websocket is not open/i,/websocket closed/i,/socket hang up/i,/connection refused/i,/econnrefused/i,/econnreset/i,/network is unreachable/i,/container exited/i];function fy(e){let t=e;for(let r=0;r<8&&t!==void 0&&t!==null;r++){if(t instanceof BY)return!0;if(t instanceof Error){if(t.name==="WorkspaceTransportError")return!0;for(let i of WY)if(i.test(t.message))return!0;let n=t.cause;if(n===t)return!1;t=n;continue}return!1}return!1}l(fy,"isWorkspaceTransportFailure");var Y8="x-workspace-egress-token",X8="x-workspace-egress-url";function J8(e){switch(e.mode){case"none":return{globalOutbound:null};case"direct":return{};case"http-gateway":return{globalOutbound:e.gateway}}}l(J8,"dynamicWorkerEgress");import{createHash as FI}from"node:crypto";import{EventEmitter as yX}from"node:events";import*as qY from"cloudflare:workers";var sI=Symbol("workers-module");globalThis[sI]=qY;Symbol.dispose||(Symbol.dispose=Symbol.for("dispose"));Symbol.asyncDispose||(Symbol.asyncDispose=Symbol.for("asyncDispose"));Promise.withResolvers||(Promise.withResolvers=function(){let e,t;return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}});var ma=globalThis[sI],bp=ma?ma.RpcTarget:class{},HY=(async function(){}).constructor,GY=typeof Buffer<"u"?Buffer.prototype:void 0;function Au(e){switch(typeof e){case"boolean":case"number":case"string":return"primitive";case"undefined":return"undefined";case"object":case"function":break;case"bigint":return"bigint";default:return"unsupported"}if(e===null)return"primitive";let t=Object.getPrototypeOf(e);switch(t){case Object.prototype:return"object";case Function.prototype:case HY.prototype:return"function";case Array.prototype:return"array";case Date.prototype:return"date";case Uint8Array.prototype:case GY:return"bytes";case WritableStream.prototype:return"writable";case ReadableStream.prototype:return"readable";case Headers.prototype:return"headers";case Request.prototype:return"request";case Response.prototype:return"response";case Blob.prototype:return"blob";case ya.prototype:return"stub";case Rr.prototype:return"rpc-promise";default:if(ma){if(t==ma.RpcStub.prototype||e instanceof ma.ServiceStub)return"rpc-target";if(t==ma.RpcPromise.prototype||t==ma.RpcProperty.prototype)return"rpc-thenable"}return e instanceof bp?"rpc-target":e instanceof Error?"error":"unsupported"}}l(Au,"typeForRpc");function Q8(){throw new Error("RPC map() implementation was not loaded.")}l(Q8,"mapNotLoaded");var xp={applyMap:Q8,sendMap:Q8};function py(){throw new Error("Stream implementation was not loaded.")}l(py,"streamNotLoaded");var Sn={createWritableStreamHook:py,createWritableStreamFromHook:py,createReadableStreamHook:py},va=class{static{l(this,"StubHook")}stream(e,t){let n=this.call(e,t).pull(),i;return n instanceof Promise?i=n.then(s=>{s.dispose()}):(n.dispose(),i=Promise.resolve()),{promise:i}}},hs=class extends va{static{l(this,"ErrorStubHook")}constructor(e){super(),this.error=e}call(e,t){return this}map(e,t,r){return this}get(e){return this}dup(){return this}pull(){return Promise.reject(this.error)}ignoreUnhandledRejections(){}dispose(){}onBroken(e){try{e(this.error)}catch(t){Promise.resolve(t)}}},VY=new hs(new Error("Attempted to use RPC stub after it has been disposed.")),wp=l((e,t,r)=>e.call(t,r),"doCall");function ZY(e,t){let r=wp;wp=e;try{return t()}finally{wp=r}}l(ZY,"withCallInterceptor");var Bi=Symbol("realStub"),KY={apply(e,t,r){let n=e.raw;return new Rr(wp(n.hook,n.pathIfPromise||[],kn.fromAppParams(r)),[])},get(e,t,r){let n=e.raw;return t===Bi?n:t in Rr.prototype?n[t]:typeof t=="string"?new Rr(n.hook,n.pathIfPromise?[...n.pathIfPromise,t]:[t]):t===Symbol.dispose&&(!n.pathIfPromise||n.pathIfPromise.length==0)?()=>{n.hook.dispose(),n.hook=VY}:void 0},has(e,t){let r=e.raw;return t===Bi?!0:t in Rr.prototype?t in r:typeof t=="string"?!0:t===Symbol.dispose&&(!r.pathIfPromise||r.pathIfPromise.length==0)},construct(e,t){throw new Error("An RPC stub cannot be used as a constructor.")},defineProperty(e,t,r){throw new Error("Can't define properties on RPC stubs.")},deleteProperty(e,t){throw new Error("Can't delete properties on RPC stubs.")},getOwnPropertyDescriptor(e,t){},getPrototypeOf(e){return Object.getPrototypeOf(e.raw)},isExtensible(e){return!1},ownKeys(e){return[]},preventExtensions(e){return!0},set(e,t,r,n){throw new Error("Can't assign properties on RPC stubs.")},setPrototypeOf(e,t){throw new Error("Can't override prototype of RPC stubs.")}},ya=class gy extends bp{static{l(this,"_RpcStub")}constructor(t,r){if(super(),!(t instanceof va)){let i=t;if(i instanceof bp||i instanceof Function?t=Su.create(i,void 0):t=new Hs(kn.fromAppReturn(i)),r)throw new TypeError("RpcStub constructor expected one argument, received two.")}this.hook=t,this.pathIfPromise=r;let n=l(()=>{},"func");return n.raw=this,new Proxy(n,KY)}hook;pathIfPromise;dup(){let t=this[Bi];return t.pathIfPromise?new gy(t.hook.get(t.pathIfPromise)):new gy(t.hook.dup())}onRpcBroken(t){this[Bi].hook.onBroken(t)}map(t){let{hook:r,pathIfPromise:n}=this[Bi];return xp.sendMap(r,n||[],t)}toString(){return"[object RpcStub]"}},Rr=class extends ya{static{l(this,"RpcPromise")}constructor(e,t){super(e,t)}then(e,t){return hy(this).then(...arguments)}catch(e){return hy(this).catch(...arguments)}finally(e){return hy(this).finally(...arguments)}toString(){return"[object RpcPromise]"}};function YY(e){let{hook:t,pathIfPromise:r}=e[Bi];return r&&r.length>0?t.get(r):t}l(YY,"unwrapStubTakingOwnership");function XY(e){let{hook:t,pathIfPromise:r}=e[Bi];return r?t.get(r):t.dup()}l(XY,"unwrapStubAndDup");function yy(e){let{hook:t,pathIfPromise:r}=e[Bi];if(!(r&&r.length>0))return t}l(yy,"unwrapStubNoProperties");function eI(e){return e[Bi].hook}l(eI,"unwrapStubOrParent");function vy(e){return e[Bi]}l(vy,"unwrapStubAndPath");async function hy(e){let{hook:t,pathIfPromise:r}=e[Bi];return r.length>0&&(t=t.get(r)),(await t.pull()).deliverResolve()}l(hy,"pullPromise");var kn=class zi{static{l(this,"_RpcPayload")}constructor(t,r,n,i){this.value=t,this.source=r,this.hooks=n,this.promises=i}static fromAppParams(t){return new zi(t,"params")}static fromAppReturn(t){return new zi(t,"return")}static fromArray(t){let r=[],n=[],i=[];for(let s of t){s.ensureDeepCopied();for(let o of s.hooks)r.push(o);for(let o of s.promises)o.parent===s&&(o={parent:i,property:i.length,promise:o.promise}),n.push(o);i.push(s.value)}return new zi(i,"owned",r,n)}static forEvaluate(t,r){return new zi(null,"owned",t,r)}static deepCopyFrom(t,r,n){let i=new zi(null,"owned",[],[]);return i.value=i.deepCopy(t,r,"value",i,!0,n),i}rpcTargets;getHookForRpcTarget(t,r,n=!0){if(this.source==="params"){if(n){let i=t;typeof i.dup=="function"&&(t=i.dup())}return Su.create(t,r)}else if(this.source==="return"){let i=this.rpcTargets?.get(t);return i?n?i.dup():(this.rpcTargets?.delete(t),i):(i=Su.create(t,r),n?(this.rpcTargets||(this.rpcTargets=new Map),this.rpcTargets.set(t,i),i.dup()):i)}else throw new Error("owned payload shouldn't contain raw RpcTargets")}getHookForWritableStream(t,r,n=!0){if(this.source==="params")return Sn.createWritableStreamHook(t);if(this.source==="return"){let i=this.rpcTargets?.get(t);return i?n?i.dup():(this.rpcTargets?.delete(t),i):(i=Sn.createWritableStreamHook(t),n?(this.rpcTargets||(this.rpcTargets=new Map),this.rpcTargets.set(t,i),i.dup()):i)}else throw new Error("owned payload shouldn't contain raw WritableStreams")}getHookForReadableStream(t,r,n=!0){if(this.source==="params")return Sn.createReadableStreamHook(t);if(this.source==="return"){let i=this.rpcTargets?.get(t);return i?n?i.dup():(this.rpcTargets?.delete(t),i):(i=Sn.createReadableStreamHook(t),n?(this.rpcTargets||(this.rpcTargets=new Map),this.rpcTargets.set(t,i),i.dup()):i)}else throw new Error("owned payload shouldn't contain raw ReadableStreams")}deepCopy(t,r,n,i,s,o){switch(Au(t)){case"unsupported":return t;case"primitive":case"bigint":case"date":case"bytes":case"blob":case"error":case"undefined":return t;case"array":{let c=t,u=c.length,d=new Array(u);for(let f=0;f<u;f++)d[f]=this.deepCopy(c[f],c,f,d,s,o);return d}case"object":{let c={},u=t;for(let d in u)c[d]=this.deepCopy(u[d],u,d,c,s,o);return c}case"stub":case"rpc-promise":{let c=t,u;if(s?u=XY(c):u=YY(c),c instanceof Rr){let d=new Rr(u,[]);return this.promises.push({parent:i,property:n,promise:d}),d}else return this.hooks.push(u),new ya(u)}case"function":case"rpc-target":{let c=t,u;return o?u=o.getHookForRpcTarget(c,r,s):u=Su.create(c,r),this.hooks.push(u),new ya(u)}case"rpc-thenable":{let c=t,u;return o?u=new Rr(o.getHookForRpcTarget(c,r,s),[]):u=new Rr(Su.create(c,r),[]),this.promises.push({parent:i,property:n,promise:u}),u}case"writable":{let c=t,u;return o?u=o.getHookForWritableStream(c,r,s):u=Sn.createWritableStreamHook(c),this.hooks.push(u),c}case"readable":{let c=t,u;return o?u=o.getHookForReadableStream(c,r,s):u=Sn.createReadableStreamHook(c),this.hooks.push(u),c}case"headers":return new Headers(t);case"request":{let c=t;return c.body&&this.deepCopy(c.body,c,"body",c,s,o),new Request(c)}case"response":{let c=t;return c.body&&this.deepCopy(c.body,c,"body",c,s,o),new Response(c.body,c)}default:throw new Error("unreachable")}}ensureDeepCopied(){if(this.source!=="owned"){let t=this.source==="params";this.hooks=[],this.promises=[];try{this.value=this.deepCopy(this.value,void 0,"value",this,t,this)}catch(r){throw this.hooks=void 0,this.promises=void 0,r}if(this.source="owned",this.rpcTargets&&this.rpcTargets.size>0)throw new Error("Not all rpcTargets were accounted for in deep-copy?");this.rpcTargets=void 0}}deliverTo(t,r,n){if(this.ensureDeepCopied(),this.value instanceof Rr)zi.deliverRpcPromiseTo(this.value,t,r,n);else{t[r]=this.value;for(let i of this.promises)zi.deliverRpcPromiseTo(i.promise,i.parent,i.property,n)}}static deliverRpcPromiseTo(t,r,n,i){let s=yy(t);if(!s)throw new Error("property promises should have been resolved earlier");let o=s.pull();o instanceof zi?o.deliverTo(r,n,i):i.push(o.then(a=>{let c=[];if(a.deliverTo(r,n,c),c.length>0)return Promise.all(c)}))}async deliverCall(t,r){try{let n=[];this.deliverTo(this,"value",n),n.length>0&&await Promise.all(n);let i=Function.prototype.apply.call(t,r,this.value);return i instanceof Rr?zi.fromAppReturn(i):zi.fromAppReturn(await i)}finally{this.dispose()}}async deliverResolve(){try{let t=[];this.deliverTo(this,"value",t),t.length>0&&await Promise.all(t);let r=this.value;return r instanceof Object&&(Symbol.dispose in r||Object.defineProperty(r,Symbol.dispose,{value:l(()=>this.dispose(),"value"),writable:!0,enumerable:!1,configurable:!0})),r}catch(t){throw this.dispose(),t}}dispose(){if(this.source==="owned")this.hooks.forEach(t=>t.dispose()),this.promises.forEach(t=>t.promise[Symbol.dispose]());else if(this.source==="return"&&(this.disposeImpl(this.value,void 0),this.rpcTargets&&this.rpcTargets.size>0))throw new Error("Not all rpcTargets were accounted for in disposeImpl()?");this.source="owned",this.hooks=[],this.promises=[]}disposeImpl(t,r){switch(Au(t)){case"unsupported":case"primitive":case"bigint":case"bytes":case"blob":case"date":case"error":case"undefined":return;case"array":{let i=t,s=i.length;for(let o=0;o<s;o++)this.disposeImpl(i[o],i);return}case"object":{let i=t;for(let s in i)this.disposeImpl(i[s],i);return}case"stub":case"rpc-promise":{let s=yy(t);s&&s.dispose();return}case"function":case"rpc-target":{let i=t,s=this.rpcTargets?.get(i);s?(s.dispose(),this.rpcTargets.delete(i)):lI(i);return}case"rpc-thenable":return;case"headers":return;case"request":{let i=t;i.body&&this.disposeImpl(i.body,i);return}case"response":{let i=t;i.body&&this.disposeImpl(i.body,i);return}case"writable":{let i=t,s=this.rpcTargets?.get(i);s?this.rpcTargets.delete(i):s=Sn.createWritableStreamHook(i),s.dispose();return}case"readable":{let i=t,s=this.rpcTargets?.get(i);s?this.rpcTargets.delete(i):s=Sn.createReadableStreamHook(i),s.dispose();return}default:return}}ignoreUnhandledRejections(){this.hooks?(this.hooks.forEach(t=>{t.ignoreUnhandledRejections()}),this.promises.forEach(t=>eI(t.promise).ignoreUnhandledRejections())):this.ignoreUnhandledRejectionsImpl(this.value)}ignoreUnhandledRejectionsImpl(t){switch(Au(t)){case"unsupported":case"primitive":case"bigint":case"bytes":case"blob":case"date":case"error":case"undefined":case"function":case"rpc-target":case"writable":case"readable":case"headers":case"request":case"response":return;case"array":{let n=t,i=n.length;for(let s=0;s<i;s++)this.ignoreUnhandledRejectionsImpl(n[s]);return}case"object":{let n=t;for(let i in n)this.ignoreUnhandledRejectionsImpl(n[i]);return}case"stub":case"rpc-promise":eI(t).ignoreUnhandledRejections();return;case"rpc-thenable":t.then(n=>{},n=>{});return;default:return}}};function my(e,t,r,n){for(let i=0;i<r.length;i++){t=e;let s=r[i];if(s in Object.prototype){e=void 0;continue}switch(Au(e)){case"object":case"function":Object.hasOwn(e,s)?e=e[s]:e=void 0;break;case"array":Number.isInteger(s)&&s>=0?e=e[s]:e=void 0;break;case"rpc-target":case"rpc-thenable":{if(Object.hasOwn(e,s))throw new TypeError(`Attempted to access property '${s}', which is an instance property of the RpcTarget. To avoid leaking private internals, instance properties cannot be accessed over RPC. If you want to make this property available over RPC, define it as a method or getter on the class, instead of an instance property.`);e=e[s],n=null;break}case"stub":case"rpc-promise":{let{hook:a,pathIfPromise:c}=vy(e);return{hook:a,remainingPath:c?c.concat(r.slice(i)):r.slice(i)}}case"writable":e=void 0;break;case"readable":e=void 0;break;case"primitive":case"bigint":case"bytes":case"blob":case"date":case"error":case"headers":case"request":case"response":e=void 0;break;case"undefined":e=e[s];break;case"unsupported":{if(i===0)throw new TypeError("RPC stub points at a non-serializable type.");{let a=r.slice(0,i).join("."),c=r.slice(0,i).join(".");throw new TypeError(`'${a}' is not a serializable type, so property ${c} cannot be accessed.`)}}default:throw new TypeError("unreachable")}}if(e instanceof Rr){let{hook:i,pathIfPromise:s}=vy(e);return{hook:i,remainingPath:s||[]}}return{value:e,parent:t,owner:n}}l(my,"followPath");var oI=class extends va{static{l(this,"ValueStubHook")}call(e,t){try{let{value:r,owner:n}=this.getValue(),i=my(r,void 0,e,n);if(i.hook)return i.hook.call(i.remainingPath,t);if(typeof i.value!="function")throw new TypeError(`'${e.join(".")}' is not a function.`);let s=t.deliverCall(i.value,i.parent);return new Ep(s.then(o=>new Hs(o)))}catch(r){return new hs(r)}}map(e,t,r){try{let n;try{let{value:i,owner:s}=this.getValue();n=my(i,void 0,e,s)}catch(i){for(let s of t)s.dispose();throw i}return n.hook?n.hook.map(n.remainingPath,t,r):xp.applyMap(n.value,n.parent,n.owner,t,r)}catch(n){return new hs(n)}}get(e){try{let{value:t,owner:r}=this.getValue();if(e.length===0&&r===null)throw new Error("Can't dup an RpcTarget stub as a promise.");let n=my(t,void 0,e,r);return n.hook?n.hook.get(n.remainingPath):new Hs(kn.deepCopyFrom(n.value,n.parent,n.owner))}catch(t){return new hs(t)}}},Hs=class aI extends oI{static{l(this,"_PayloadStubHook")}constructor(t){super(),this.payload=t}payload;getPayload(){if(this.payload)return this.payload;throw new Error("Attempted to use an RPC StubHook after it was disposed.")}getValue(){let t=this.getPayload();return{value:t.value,owner:t}}dup(){let t=this.getPayload();return new aI(kn.deepCopyFrom(t.value,void 0,t))}pull(){return this.getPayload()}ignoreUnhandledRejections(){this.payload&&this.payload.ignoreUnhandledRejections()}dispose(){this.payload&&(this.payload.dispose(),this.payload=void 0)}onBroken(t){this.payload&&this.payload.value instanceof ya&&this.payload.value.onRpcBroken(t)}};function lI(e){if(Symbol.dispose in e)try{e[Symbol.dispose]()}catch(t){Promise.reject(t)}}l(lI,"disposeRpcTarget");var Su=class wy extends oI{static{l(this,"_TargetStubHook")}static create(t,r){return typeof t!="function"&&(r=void 0),new wy(t,r)}constructor(t,r,n){super(),this.target=t,this.parent=r,n?n.refcount&&(this.refcount=n.refcount,++this.refcount.count):Symbol.dispose in t&&(this.refcount={count:1})}target;parent;refcount;getTarget(){if(this.target)return this.target;throw new Error("Attempted to use an RPC StubHook after it was disposed.")}getValue(){return{value:this.getTarget(),owner:null}}dup(){return new wy(this.getTarget(),this.parent,this)}pull(){let t=this.getTarget();return"then"in t?Promise.resolve(t).then(r=>kn.fromAppReturn(r)):Promise.reject(new Error("Tried to resolve a non-promise stub."))}ignoreUnhandledRejections(){}dispose(){this.target&&(this.refcount&&--this.refcount.count==0&&lI(this.target),this.target=void 0)}onBroken(t){}},Ep=class ku extends va{static{l(this,"_PromiseStubHook")}promise;resolution;constructor(t){super(),this.promise=t.then(r=>(this.resolution=r,r))}call(t,r){return r.ensureDeepCopied(),new ku(this.promise.then(n=>n.call(t,r)))}stream(t,r){return r.ensureDeepCopied(),{promise:this.promise.then(i=>i.stream(t,r).promise)}}map(t,r,n){return new ku(this.promise.then(i=>i.map(t,r,n),i=>{for(let s of r)s.dispose();throw i}))}get(t){return new ku(this.promise.then(r=>r.get(t)))}dup(){return this.resolution?this.resolution.dup():new ku(this.promise.then(t=>t.dup()))}pull(){return this.resolution?this.resolution.pull():this.promise.then(t=>t.pull())}ignoreUnhandledRejections(){this.resolution?this.resolution.ignoreUnhandledRejections():this.promise.then(t=>{t.ignoreUnhandledRejections()},t=>{})}dispose(){this.resolution?this.resolution.dispose():this.promise.then(t=>{t.dispose()},t=>{})}onBroken(t){this.resolution?this.resolution.onBroken(t):this.promise.then(r=>{r.onBroken(t)},t)}},JY=class{static{l(this,"NullExporter")}exportStub(e){throw new Error("Cannot serialize RPC stubs without an RPC session.")}exportPromise(e){throw new Error("Cannot serialize RPC stubs without an RPC session.")}getImport(e){}unexport(e){}createPipe(e){throw new Error("Cannot create pipes without an RPC session.")}onSendError(e){}},QY=new JY;async function eX(e,t){let r=await new Response(e).blob();return r.type===t?r:r.slice(0,r.size,t)}l(eX,"streamToBlob");var tX={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError},tI=class cI{static{l(this,"_Devaluator")}constructor(t,r){this.exporter=t,this.source=r}static devaluate(t,r,n=QY,i){let s=new cI(n,i);try{return s.devaluateImpl(t,r,0)}catch(o){if(s.exports)try{n.unexport(s.exports)}catch{}throw o}}exports;devaluateImpl(t,r,n){if(n>=64)throw new Error("Serialization exceeded maximum allowed depth. (Does the message contain cycles?)");switch(Au(t)){case"unsupported":{let s;try{s=`Cannot serialize value: ${t}`}catch{s="Cannot serialize value: (couldn't stringify value)"}throw new TypeError(s)}case"primitive":return typeof t=="number"&&!isFinite(t)?t===1/0?["inf"]:t===-1/0?["-inf"]:["nan"]:t;case"object":{let s=t,o={};for(let a in s)o[a]=this.devaluateImpl(s[a],s,n+1);return o}case"array":{let s=t,o=s.length,a=new Array(o);for(let c=0;c<o;c++)a[c]=this.devaluateImpl(s[c],s,n+1);return[a]}case"bigint":return["bigint",t.toString()];case"date":{let s=t.getTime();return["date",Number.isNaN(s)?null:s]}case"bytes":{let s=t;if(s.toBase64)return["bytes",s.toBase64({omitPadding:!0})];let o;if(typeof Buffer<"u")o=(s instanceof Buffer?s:Buffer.from(s.buffer,s.byteOffset,s.byteLength)).toString("base64");else{let a="";for(let c=0;c<s.length;c++)a+=String.fromCharCode(s[c]);o=btoa(a)}return["bytes",o.replace(/=+$/,"")]}case"headers":return["headers",[...t]];case"request":{let s=t,o={};s.method!=="GET"&&(o.method=s.method);let a=[...s.headers];if(a.length>0&&(o.headers=a),s.body)o.body=this.devaluateImpl(s.body,s,n+1),o.duplex=s.duplex||"half";else if(s.body===void 0&&!["GET","HEAD","OPTIONS","TRACE","DELETE"].includes(s.method)){let u=s.arrayBuffer(),d=new ReadableStream({async start(h){try{h.enqueue(new Uint8Array(await u)),h.close()}catch(m){h.error(m)}}}),f=Sn.createReadableStreamHook(d),p=this.exporter.createPipe(d,f);o.body=["readable",p],o.duplex=s.duplex||"half"}s.cache&&s.cache!=="default"&&(o.cache=s.cache),s.redirect!=="follow"&&(o.redirect=s.redirect),s.integrity&&(o.integrity=s.integrity),s.mode&&s.mode!=="cors"&&(o.mode=s.mode),s.credentials&&s.credentials!=="same-origin"&&(o.credentials=s.credentials),s.referrer&&s.referrer!=="about:client"&&(o.referrer=s.referrer),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.keepalive&&(o.keepalive=s.keepalive);let c=s;return c.cf&&(o.cf=c.cf),c.encodeResponseBody&&c.encodeResponseBody!=="automatic"&&(o.encodeResponseBody=c.encodeResponseBody),["request",s.url,o]}case"response":{let s=t,o=this.devaluateImpl(s.body,s,n+1),a={};s.status!==200&&(a.status=s.status),s.statusText&&(a.statusText=s.statusText);let c=[...s.headers];c.length>0&&(a.headers=c);let u=s;if(u.cf&&(a.cf=u.cf),u.encodeBody&&u.encodeBody!=="automatic"&&(a.encodeBody=u.encodeBody),u.webSocket)throw new TypeError("Can't serialize a Response containing a webSocket.");return["response",o,a]}case"blob":{let s=t,o=s.stream(),a=Sn.createReadableStreamHook(o),c=this.exporter.createPipe(o,a);return["blob",s.type,["readable",c]]}case"error":{let s=t,o=this.exporter.onSendError(s);o&&(s=o);let a=s,c,u=l((f,p)=>{let h=this.exports?.length??0;try{let m=this.devaluateImpl(p,s,n+1);c||(c={}),c[f]=m}catch{if(this.exports&&this.exports.length>h){let g=this.exports.splice(h);try{this.exporter.unexport(g)}catch{}}}},"captureProp");for(let f of Object.keys(s))f==="name"||f==="message"||f==="stack"||u(f,a[f]);"cause"in s&&u("cause",a.cause),s instanceof AggregateError&&u("errors",s.errors);let d=["error",s.name,s.message];return c?(d.push(o&&o.stack?o.stack:null),d.push(c)):o&&o.stack&&d.push(o.stack),d}case"undefined":return["undefined"];case"stub":case"rpc-promise":{if(!this.source)throw new Error("Can't serialize RPC stubs in this context.");let{hook:s,pathIfPromise:o}=vy(t),a=this.exporter.getImport(s);return a!==void 0?o?o.length>0?["pipeline",a,o]:["pipeline",a]:["import",a]:(o?s=s.get(o):s=s.dup(),this.devaluateHook(o?"promise":"export",s))}case"function":case"rpc-target":{if(!this.source)throw new Error("Can't serialize RPC stubs in this context.");let s=this.source.getHookForRpcTarget(t,r);return this.devaluateHook("export",s)}case"rpc-thenable":{if(!this.source)throw new Error("Can't serialize RPC stubs in this context.");let s=this.source.getHookForRpcTarget(t,r);return this.devaluateHook("promise",s)}case"writable":{if(!this.source)throw new Error("Can't serialize WritableStream in this context.");let s=this.source.getHookForWritableStream(t,r);return this.devaluateHook("writable",s)}case"readable":{if(!this.source)throw new Error("Can't serialize ReadableStream in this context.");let s=t,o=this.source.getHookForReadableStream(s,r);return["readable",this.exporter.createPipe(s,o)]}default:throw new Error("unreachable")}}devaluateHook(t,r){this.exports||(this.exports=[]);let n=t==="promise"?this.exporter.exportPromise(r):this.exporter.exportStub(r);return this.exports.push(n),[t,n]}};var rX=class{static{l(this,"NullImporter")}importStub(e){throw new Error("Cannot deserialize RPC stubs without an RPC session.")}importPromise(e){throw new Error("Cannot deserialize RPC stubs without an RPC session.")}getExport(e){}getPipeReadable(e){throw new Error("Cannot retrieve pipe readable without an RPC session.")}},a7e=new rX;function nX(e,t){let r=new Response(t).arrayBuffer().then(n=>{let i=new Uint8Array(n),s=new Request(e,{body:i});return new Hs(kn.fromAppReturn(s))});return new Rr(new Ep(r),[])}l(nX,"fixBrokenRequestBody");function iX(e,t){let r=eX(e,t).then(n=>new Hs(kn.fromAppReturn(n)));return new Rr(new Ep(r),[])}l(iX,"streamToBlobPromise");var rI=class uI{static{l(this,"_Evaluator")}constructor(t){this.importer=t}hooks=[];promises=[];evaluate(t){let r=kn.forEvaluate(this.hooks,this.promises);try{return r.value=this.evaluateImpl(t,r,"value"),r}catch(n){throw r.dispose(),n}}evaluateCopy(t){return this.evaluate(structuredClone(t))}evaluateImpl(t,r,n){if(t instanceof Array){if(t.length==1&&t[0]instanceof Array){let i=t[0];for(let s=0;s<i.length;s++)i[s]=this.evaluateImpl(i[s],i,s);return i}else switch(t[0]){case"bigint":if(typeof t[1]=="string")return BigInt(t[1]);break;case"date":if(t[1]===null)return new Date(NaN);if(typeof t[1]=="number")return new Date(t[1]);break;case"bytes":{if(typeof t[1]=="string"){if(typeof Buffer<"u")return Buffer.from(t[1],"base64");if(Uint8Array.fromBase64)return Uint8Array.fromBase64(t[1]);{let i=atob(t[1]),s=i.length,o=new Uint8Array(s);for(let a=0;a<s;a++)o[a]=i.charCodeAt(a);return o}}break}case"error":if(t.length>=3&&typeof t[1]=="string"&&typeof t[2]=="string"){let i=tX[t[1]]||Error,s=i===AggregateError?new i([],t[2]):new i(t[2]);if(typeof t[3]=="string"&&(s.stack=t[3]),t.length>=5){let o=t[4];if(!o||typeof o!="object"||Array.isArray(o))break;let a=s,c=o;for(let u of Object.keys(c))u==="name"||u==="message"||u==="stack"||(a[u]=this.evaluateImpl(c[u],s,u))}return s}break;case"undefined":if(t.length===1)return;break;case"inf":return 1/0;case"-inf":return-1/0;case"nan":return NaN;case"headers":if(t.length===2&&t[1]instanceof Array)return new Headers(t[1]);break;case"request":{if(t.length!==3||typeof t[1]!="string")break;let i=t[1],s=t[2];if(typeof s!="object"||s===null)break;if(s.body&&(s.body=this.evaluateImpl(s.body,s,"body"),!(s.body===null||typeof s.body=="string"||s.body instanceof Uint8Array||s.body instanceof ReadableStream)))throw new TypeError("Request body must be of type ReadableStream.");if(s.signal&&(s.signal=this.evaluateImpl(s.signal,s,"signal"),!(s.signal instanceof AbortSignal)))throw new TypeError("Request siganl must be of type AbortSignal.");if(s.headers&&!(s.headers instanceof Array))throw new TypeError("Request headers must be serialized as an array of pairs.");let o=new Request(i,s);if(s.body instanceof ReadableStream&&o.body===void 0){let a=nX(o,s.body);return this.promises.push({promise:a,parent:r,property:n}),a}else return o}case"response":{if(t.length!==3)break;let i=this.evaluateImpl(t[1],r,n);if(!(i===null||typeof i=="string"||i instanceof Uint8Array||i instanceof ReadableStream))throw new TypeError("Response body must be of type ReadableStream.");let s=t[2];if(typeof s!="object"||s===null)break;if(s.webSocket)throw new TypeError("Can't deserialize a Response containing a webSocket.");if(s.headers&&!(s.headers instanceof Array))throw new TypeError("Request headers must be serialized as an array of pairs.");return new Response(i,s)}case"blob":{if(t.length!==3||typeof t[1]!="string")break;let i=t[1],s=this.evaluateImpl(t[2],r,n);if(!(s instanceof ReadableStream))throw new TypeError("Blob content must be serialized as a ReadableStream.");let o=iX(s,i);return this.promises.push({promise:o,parent:r,property:n}),o}case"import":case"pipeline":{if(t.length<2||t.length>4||typeof t[1]!="number")break;let i=this.importer.getExport(t[1]);if(!i)throw new Error(`no such entry on exports table: ${t[1]}`);let s=t[0]=="pipeline",o=l(d=>{if(s){let f=new Rr(d,[]);return this.promises.push({promise:f,parent:r,property:n}),f}else return this.hooks.push(d),new Rr(d,[])},"addStub");if(t.length==2)return o(s?i.get([]):i.dup());let a=t[2];if(!(a instanceof Array)||!a.every(d=>typeof d=="string"||typeof d=="number"))break;if(t.length==3)return o(i.get(a));let c=t[3];if(!(c instanceof Array))break;return c=new uI(this.importer).evaluate([c]),o(i.call(a,c))}case"remap":{if(t.length!==5||typeof t[1]!="number"||!(t[2]instanceof Array)||!(t[3]instanceof Array)||!(t[4]instanceof Array))break;let i=this.importer.getExport(t[1]);if(!i)throw new Error(`no such entry on exports table: ${t[1]}`);let s=t[2];if(!s.every(d=>typeof d=="string"||typeof d=="number"))break;let o=t[3].map(d=>{if(!(d instanceof Array)||d.length!==2||d[0]!=="import"&&d[0]!=="export"||typeof d[1]!="number")throw new TypeError(`unknown map capture: ${JSON.stringify(d)}`);if(d[0]==="export")return this.importer.importStub(d[1]);{let f=this.importer.getExport(d[1]);if(!f)throw new Error(`no such entry on exports table: ${d[1]}`);return f.dup()}}),a=t[4],c=i.map(s,o,a),u=new Rr(c,[]);return this.promises.push({promise:u,parent:r,property:n}),u}case"export":case"promise":if(typeof t[1]=="number")if(t[0]=="promise"){let i=this.importer.importPromise(t[1]),s=new Rr(i,[]);return this.promises.push({parent:r,property:n,promise:s}),s}else{let i=this.importer.importStub(t[1]);return this.hooks.push(i),new ya(i)}break;case"writable":if(typeof t[1]=="number"){let i=this.importer.importStub(t[1]),s=Sn.createWritableStreamFromHook(i);return this.hooks.push(i),s}break;case"readable":if(typeof t[1]=="number"){let i=this.importer.getPipeReadable(t[1]),s=Sn.createReadableStreamHook(i);return this.hooks.push(s),i}break}throw new TypeError(`unknown special value: ${JSON.stringify(t)}`)}else if(t instanceof Object){let i=t;for(let s in i)s in Object.prototype||s==="toJSON"?(this.evaluateImpl(i[s],i,s),delete i[s]):i[s]=this.evaluateImpl(i[s],i,s);return i}else return t}};var ga,sX=class{static{l(this,"MapBuilder")}context;captureMap=new Map;instructions=[];constructor(e,t){ga?this.context={parent:ga,captures:[],subject:ga.capture(e),path:t}:this.context={parent:void 0,captures:[],subject:e,path:t},ga=this}unregister(){ga=this.context.parent}makeInput(){return new Eu(this,0)}makeOutput(e){let t;try{t=tI.devaluate(e.value,void 0,this,e)}finally{e.dispose()}return this.instructions.push(t),this.context.parent?(this.context.parent.instructions.push(["remap",this.context.subject,this.context.path,this.context.captures.map(r=>["import",r]),this.instructions]),new Eu(this.context.parent,this.context.parent.instructions.length)):this.context.subject.map(this.context.path,this.context.captures,this.instructions)}pushCall(e,t,r){let n=tI.devaluate(r.value,void 0,this,r);n=n[0];let i=this.capture(e.dup());return this.instructions.push(["pipeline",i,t,n]),new Eu(this,this.instructions.length)}pushGet(e,t){let r=this.capture(e.dup());return this.instructions.push(["pipeline",r,t]),new Eu(this,this.instructions.length)}capture(e){if(e instanceof Eu&&e.mapper===this)return e.idx;let t=this.captureMap.get(e);if(t===void 0){if(this.context.parent){let r=this.context.parent.capture(e);this.context.captures.push(r)}else this.context.captures.push(e);t=-this.context.captures.length,this.captureMap.set(e,t)}return t}exportStub(e){throw new Error("Can't construct an RpcTarget or RPC callback inside a mapper function. Try creating a new RpcStub outside the callback first, then using it inside the callback.")}exportPromise(e){return this.exportStub(e)}getImport(e){return this.capture(e)}unexport(e){}createPipe(e){throw new Error("Cannot send ReadableStream inside a mapper function.")}onSendError(e){}};xp.sendMap=(e,t,r)=>{let n=new sX(e,t),i;try{i=kn.fromAppReturn(ZY(n.pushCall.bind(n),()=>r(new Rr(n.makeInput(),[]))))}finally{n.unregister()}if(i instanceof Promise)throw i.catch(s=>{}),new Error("RPC map() callbacks cannot be async.");return new Rr(n.makeOutput(i),[])};function xu(){throw new Error("Attempted to use an abstract placeholder from a mapper function. Please make sure your map function has no side effects.")}l(xu,"throwMapperBuilderUseError");var Eu=class extends va{static{l(this,"MapVariableHook")}constructor(e,t){super(),this.mapper=e,this.idx=t}dup(){return this}dispose(){}get(e){if(e.length==0)return this;if(ga)return ga.pushGet(this,e);xu()}call(e,t){xu()}map(e,t,r){xu()}pull(){xu()}ignoreUnhandledRejections(){}onBroken(e){xu()}},oX=class{static{l(this,"MapApplicator")}constructor(e,t){this.captures=e,this.variables=[t]}variables;dispose(){for(let e of this.variables)e.dispose()}apply(e){try{if(e.length<1)throw new Error("Invalid empty mapper function.");for(let t of e.slice(0,-1)){let r=new rI(this).evaluateCopy(t);if(r.value instanceof ya){let n=yy(r.value);if(n){this.variables.push(n);continue}}this.variables.push(new Hs(r))}return new rI(this).evaluateCopy(e[e.length-1])}finally{for(let t of this.variables)t.dispose()}}importStub(e){throw new Error("A mapper function cannot refer to exports.")}importPromise(e){return this.importStub(e)}getExport(e){return e<0?this.captures[-e-1]:this.variables[e]}getPipeReadable(e){throw new Error("A mapper function cannot use pipe readables.")}};function nI(e,t,r,n,i){let s=new Hs(kn.deepCopyFrom(e,t,r)),o=new oX(n,s);try{return o.apply(i)}finally{o.dispose()}}l(nI,"applyMapToElement");xp.applyMap=(e,t,r,n,i)=>{try{let s;if(e instanceof Rr)throw new Error("applyMap() can't be called on RpcPromise");if(e instanceof Array){let o=[];try{for(let a of e)o.push(nI(a,e,r,n,i))}catch(a){for(let c of o)c.dispose();throw a}s=kn.fromArray(o)}else e==null?s=kn.fromAppReturn(e):s=nI(e,t,r,n,i);return new Hs(s)}finally{for(let s of n)s.dispose()}};var aX=class by extends va{static{l(this,"_WritableStreamStubHook")}state;static create(t){let r=t.getWriter();return new by({refcount:1,writer:r,closed:!1})}constructor(t,r){super(),this.state=t,r&&++t.refcount}getState(){if(this.state)return this.state;throw new Error("Attempted to use a WritableStreamStubHook after it was disposed.")}call(t,r){try{let n=this.getState();if(t.length!==1||typeof t[0]!="string")throw new Error("WritableStream stub only supports direct method calls");let i=t[0];if(i!=="write"&&i!=="close"&&i!=="abort")throw r.dispose(),new Error(`Unknown WritableStream method: ${i}`);(i==="close"||i==="abort")&&(n.closed=!0);let s=n.writer[i],o=r.deliverCall(s,n.writer);return new Ep(o.then(a=>new Hs(a)))}catch(n){return new hs(n)}}map(t,r,n){for(let i of r)i.dispose();return new hs(new Error("Cannot use map() on a WritableStream"))}get(t){return new hs(new Error("Cannot access properties on a WritableStream stub"))}dup(){let t=this.getState();return new by(t,this)}pull(){return Promise.reject(new Error("Cannot pull a WritableStream stub"))}ignoreUnhandledRejections(){}dispose(){let t=this.state;this.state=void 0,t&&--t.refcount===0&&(t.closed||t.writer.abort(new Error("WritableStream RPC stub was disposed without calling close()")).catch(()=>{}),t.writer.releaseLock())}onBroken(t){}},lX=256*1024,cX=1024*1024*1024,uX=64*1024,dX=2,iI=1.25,fX=.9,pX=3,hX=class{static{l(this,"FlowController")}constructor(e){this.now=e}window=lX;bytesInFlight=0;inStartupPhase=!0;delivered=0;deliveredTime=0;firstAckTime=0;firstAckDelivered=0;minRtt=1/0;roundsWithoutIncrease=0;lastRoundWindow=0;roundStartTime=0;onSend(e){this.bytesInFlight+=e;let t={sentTime:this.now(),size:e,deliveredAtSend:this.delivered,deliveredTimeAtSend:this.deliveredTime,windowAtSend:this.window,windowFullAtSend:this.bytesInFlight>=this.window};return{token:t,shouldBlock:t.windowFullAtSend}}onError(e){this.bytesInFlight-=e.size}onAck(e){let t=this.now();this.delivered+=e.size,this.deliveredTime=t,this.bytesInFlight-=e.size;let r=t-e.sentTime;if(this.minRtt=Math.min(this.minRtt,r),this.firstAckTime===0)this.firstAckTime=t,this.firstAckDelivered=this.delivered;else{let n,i;e.deliveredTimeAtSend===0?(n=this.firstAckTime,i=this.firstAckDelivered):(n=e.deliveredTimeAtSend,i=e.deliveredAtSend);let s=t-n,a=(this.delivered-i)/s,c=this.inStartupPhase?dX:iI,u=a*this.minRtt*c;u=Math.min(u,e.windowAtSend*c),e.windowFullAtSend?u=Math.max(u,e.windowAtSend*fX):u=Math.max(u,this.window),this.window=Math.max(Math.min(u,cX),uX),this.inStartupPhase&&e.sentTime>=this.roundStartTime&&(this.window>this.lastRoundWindow*iI?this.roundsWithoutIncrease=0:++this.roundsWithoutIncrease>=pX&&(this.inStartupPhase=!1),this.roundStartTime=t,this.lastRoundWindow=this.window)}return this.bytesInFlight<this.window}};function mX(e){let t,r=!1,n=new hX(()=>performance.now()),i,s,o=l(()=>{r||(r=!0,e.dispose())},"disposeHook");return new WritableStream({write(a,c){if(t!==void 0)throw t;let u=kn.fromAppParams([a]),{promise:d,size:f}=e.stream(["write"],u);if(f===void 0)return d.catch(p=>{throw t===void 0&&(t=p),p});{let{token:p,shouldBlock:h}=n.onSend(f);if(d.then(()=>{n.onAck(p)&&i&&(i(),i=void 0,s=void 0)},m=>{n.onError(p),t===void 0&&(t=m,c.error(m),o()),s&&(s(m),i=void 0,s=void 0)}),h)return new Promise((m,g)=>{i=m,s=g})}},async close(){if(t!==void 0)throw o(),t;let{promise:a}=e.stream(["close"],kn.fromAppParams([]));try{await a}catch(c){throw t??c}finally{o()}},abort(a){if(t!==void 0)return;t=a??new Error("WritableStream was aborted"),s&&(s(t),i=void 0,s=void 0);let{promise:c}=e.stream(["abort"],kn.fromAppParams([a]));c.then(()=>o(),()=>o())}})}l(mX,"createWritableStreamFromHook");var gX=class xy extends va{static{l(this,"_ReadableStreamStubHook")}state;static create(t){return new xy({refcount:1,stream:t,canceled:!1})}constructor(t,r){super(),this.state=t,r&&++t.refcount}call(t,r){return r.dispose(),new hs(new Error("Cannot call methods on a ReadableStream stub"))}map(t,r,n){for(let i of r)i.dispose();return new hs(new Error("Cannot use map() on a ReadableStream"))}get(t){return new hs(new Error("Cannot access properties on a ReadableStream stub"))}dup(){let t=this.state;if(!t)throw new Error("Attempted to dup a ReadableStreamStubHook after it was disposed.");return new xy(t,this)}pull(){return Promise.reject(new Error("Cannot pull a ReadableStream stub"))}ignoreUnhandledRejections(){}dispose(){let t=this.state;this.state=void 0,t&&--t.refcount===0&&(t.canceled||(t.canceled=!0,t.stream.locked||t.stream.cancel(new Error("ReadableStream RPC stub was disposed without being consumed")).catch(()=>{})))}onBroken(t){}};Sn.createWritableStreamHook=aX.create;Sn.createWritableStreamFromHook=mX;Sn.createReadableStreamHook=gX.create;var So=bp;import{RpcTarget as vX,WorkerEntrypoint as UI}from"cloudflare:workers";function _e(e,t,r){let n=new Error(r===void 0?t:`${t}: ${r}`);return n.name="WorkspaceFsError",n.code=e,n.path=r,n}l(_e,"createWorkspaceError");function Sp(e,t){return _e("EINVAL",`Invalid path (${t})`,e)}l(Sp,"invalidPath");function Tt(e){if(e.length===0)throw Sp(e,"empty");if(!e.startsWith("/"))throw Sp(e,"must be absolute");if(e.includes("\0"))throw Sp(e,"contains NUL byte");let t=[];for(let s of e.split("/"))if(!(s===""||s===".")){if(s===".."){if(t.length===0)throw Sp(e,"escapes root");t.pop();continue}t.push(s)}let r=t.length===0?"/":`/${t.join("/")}`,n=t.length===0?"":t[t.length-1],i=t.slice(0,-1);return{path:r,parts:t,name:n,parentPath:t.length===0?void 0:i.length===0?"/":`/${i.join("/")}`}}l(Tt,"canonicalizePath");function dn(e){let t=e.one("UPDATE vfs_meta SET v = v + 1 WHERE k = 'rev' RETURNING v");if(t===void 0)throw new Error("vfs_meta.rev row missing; was initializeSchema run?");return t.v}l(dn,"incrementRev");var My=new WeakMap;function dI(e){My.delete(e)}l(dI,"invalidateReadOnlyMountCache");function wX(e){let t=e.all("SELECT root FROM _vfs_mounts WHERE mode = 'read-only'").map(r=>r.root);return My.set(e,t),t}l(wX,"loadReadOnlyRoots");function Fy(e){let t=My.get(e);return t!==void 0?t:wX(e)}l(Fy,"getReadOnlyMountRoots");function jI(e,t){return t==="/"||e===t||e.startsWith(`${t}/`)}l(jI,"isAtOrBelowRoot");function zI(e,t){return jI(e,t)||t.startsWith(`${e}/`)}l(zI,"overlapsRoot");function xr(e,t){let r=Fy(e);if(r.length!==0){for(let n of r)if(zI(t,n))throw _e("EROFS",`read-only mount at ${n}: cannot modify`,t)}}l(xr,"assertNotReadOnly");function BI(e,t){let r=Fy(e);for(let n of r)if(jI(t,n))throw _e("EROFS",`read-only mount at ${n}: cannot modify`,t)}l(BI,"assertNotInReadOnlyMount");function bX(e,t){let r=Fy(e);for(let n of r)if(zI(t,n))return n}l(bX,"readOnlyRootFor");var xX=[`CREATE TABLE IF NOT EXISTS vfs_meta (
|
|
126
|
+
`,exitCode:1}}l(mi,"mapError");function ji(e,t){let r={},n=[];for(let i=0;i<e.length;i++){let s=e[i];if(s==="--"){n.push(...e.slice(i+1));break}if(s.startsWith("--")){let o=s.indexOf("="),a=o===-1?s.slice(2):s.slice(2,o),c=t[a];if(!c)return{error:`unknown option '--${a}'`};if(c.kind==="bool"){if(o!==-1)return{error:`option '--${a}' takes no value`};r[a]=!0;continue}if(o!==-1){r[a]=s.slice(o+1);continue}let u=e[i+1];if(u===void 0)return{error:`option '--${a}' requires a value`};r[a]=u,i++;continue}n.push(s)}return{flags:r,positional:n}}l(ji,"parseFlags");var j8=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,z8="must start with a letter or digit and contain only letters, digits, '.', '_', and '-'";function B8(e){if(e.length===0)throw new cy(e,"must not be empty");if(!j8.test(e))throw new cy(e,z8);if(e.includes("__"))throw new cy(e,"must not contain '__'");return e}l(B8,"assertSessionId");function DY(e){if(e.length===0)throw new ly(e,"must not be empty");if(!j8.test(e))throw new ly(e,z8);if(e.includes("__"))throw new ly(e,"must not contain '__'");return e}l(DY,"assertLocalName");function bo(e,t){return`${B8(e)}__${DY(t)}`}l(bo,"scopedName");function W8(e){return`${B8(e)}__`}l(W8,"scopePrefix");function q8(e,t){let r=W8(e);if(!t.startsWith(r))return;let n=t.slice(r.length);if(!(n.length===0||n.includes("__")))return n}l(q8,"unscopedName");var LY=100;function H8(e,t){W8(t);let r={sessionId:t,async create(n,i){let s=await e.create(bo(t,n),i);return{...s,name:F8(t,s.name,n)}},async get(n){return MY(await(await e.get(bo(t,n))).info(),n)},async list(){let n=[],i,s=!1,o=new Set;for(;!s;){let a=await e.list({limit:LY,cursor:i});for(let u of a.repos){let d=q8(t,u.name);d!==void 0&&n.push({...u,name:d})}let c=a.cursor;if(c===void 0)s=!0;else{if(o.has(c))throw new Error(`artifacts list returned a non-advancing cursor: ${c}`);o.add(c),i=c}}return n},async import(n,i,s){let o=await e.import({source:i,target:{name:bo(t,n),opts:s}});return{...o,name:F8(t,o.name,n)}},async delete(n){return e.delete(bo(t,n))},async createToken(n,i,s){return(await e.get(bo(t,n))).createToken(i,s)},async listTokens(n){return(await e.get(bo(t,n))).listTokens()},async getToken(n,i){let{tokens:s}=await(await e.get(bo(t,n))).listTokens(),o=s.find(a=>a.id===i);if(!o)throw new wY(`no such token '${i}' in repo '${n}'`);return o},async revokeToken(n,i){return(await e.get(bo(t,n))).revokeToken(i)},async cli(n){return dy(r,n)}};return r}l(H8,"createArtifact");function MY(e,t){return{id:e.id,name:t,description:e.description,defaultBranch:e.defaultBranch,createdAt:e.createdAt,updatedAt:e.updatedAt,lastPushAt:e.lastPushAt,source:e.source,readOnly:e.readOnly,remote:e.remote}}l(MY,"repoInfo");function F8(e,t,r){return q8(e,t)??r}l(F8,"unscopeOr");function FY(e){return`Backend ${JSON.stringify(e)} is not callable; it does not accept structured input.`}l(FY,"notCallableMessage");var K8=class{static{l(this,"WorkspaceRuntime")}#e;constructor(e){this.#e=e}isCallable(e){return this.#e.callableBackendIds.has(e)}async exec(e,t={}){t.id!==void 0&&vp(t.id);let r=this.#r(t.backend);if(t.input!==void 0&&!this.isCallable(r))throw new Error(FY(r));let n=await this.#e.backendHandle(r),i=await n.exec({id:t.id,source:e,cwd:t.cwd,input:t.input,env:t.env,stdin:t.stdin,timeoutMs:t.timeoutMs});return G8(n,r,i.id,i.events,t.encoding,!0,i.sync)}async getExec(e,t={}){vp(e);let r=this.#r(t.backend),n=await this.#e.backendHandle(r),i=await n.getExec({id:e,after:zY(t.resume)});return G8(n,r,i.id,i.events,t.encoding,t.resume===void 0||t.resume==="full",i.sync)}async killExec(e,t={}){vp(e);let r=this.#r(t.backend);await(await this.#e.backendHandle(r)).killExec({id:e,signal:t.signal})}async disposeExec(e,t={}){vp(e);let r=this.#r(t.backend);await(await this.#e.backendHandle(r)).disposeExec({id:e})}#r(e){let t=this.#e.resolveBackendId(e);if(!t)throw new Error("Workspace has no execution backend configured. Pass `backends` to the Workspace constructor.");return t}};function G8(e,t,r,n,i,s=!0,o){let a,c=!1,u,d,f,p=new ReadableStream({async pull(h){if(a==="result"){h.error(new Error("runtime handle already consumed by result()"));return}a="stream",u??=UY(n,i).getReader();try{let m=await u.read();m.done?(u.releaseLock(),u=void 0,h.close()):h.enqueue(m.value)}catch(m){u?.releaseLock(),u=void 0,h.error(m)}},async cancel(h){if(c=!0,u)try{await u.cancel(h)}finally{u.releaseLock(),u=void 0}else await n.cancel(h)}},{highWaterMark:0});return Object.defineProperties(p,{id:{value:r,enumerable:!1},backend:{value:t,enumerable:!1},result:{value:l(()=>{if(a==="stream")throw new Error("runtime handle already streaming: result() and streaming are exclusive");return a="result",f??=(async()=>{let h=l(g=>{d=g},"setReader");if(s&&!c)return V8(n,i,h,o);c||await n.cancel("result() requested a full replay");let m=await e.getExec({id:r});return V8(m.events,i,h,m.sync)})(),f},"value")},kill:{value:l(h=>e.killExec({id:r,signal:h}),"value")},[Symbol.dispose]:{value:l(()=>{d?d.cancel().catch(()=>{}):p.cancel().catch(()=>{})},"value")}}),p}l(G8,"wrapModuleHandle");function UY(e,t){if(t!=="utf8")return e;let r=new TextDecoder,n=new TextDecoder,i,s,o=0,a=l((u,d)=>{o=d.seq,u.enqueue(d)},"enqueue"),c=l((u,d)=>{let f=[],p=r.decode(),h=n.decode();p&&i&&f.push({...i,name:"stdout",value:p}),h&&s&&f.push({...s,name:"stderr",value:h}),f.sort((y,x)=>y.seq-x.seq);let m=d!==void 0&&d>o?d-o:1,g=0;for(let y of f)g+=1,a(u,{...y,seq:o+m*g/(f.length+1)});i=void 0,s=void 0},"flushPending");return e.pipeThrough(new TransformStream({transform(u,d){u.name==="stdout"||u.name==="stderr"?(u.name==="stdout"?i={id:u.id,seq:u.seq}:s={id:u.id,seq:u.seq},a(d,{...u,value:(u.name==="stdout"?r:n).decode(u.value,{stream:!0})})):(c(d,u.seq),a(d,u))},flush:c}))}l(UY,"transformModuleEvents");async function V8(e,t,r,n){let i=[],s=[],o,a=-1,c=e.getReader();r(c);try{for(;;){let d=await c.read();if(d.done)break;let f=d.value;f.name==="stdout"&&i.push(f.value),f.name==="stderr"&&s.push(f.value),f.name==="exit"&&(a=f.code,"result"in f&&(o=f.result))}}finally{c.releaseLock(),r(void 0)}let u=n?await n.outcome:void 0;return{status:a===0?"completed":jY(a)?"cancelled":"failed",exitCode:a,stdout:Z8(i,t),stderr:Z8(s,t),...o===void 0?{}:{value:o},pushed:n?.pushed??0,pulled:u?.applied??0,skipped:u?.skipped??[],sync:u?.sync??{status:"complete",applied:0,skipped:[]}}}l(V8,"drainModuleResult");function jY(e){return e===129||e===130||e===137||e===143}l(jY,"isCancellationExitCode");function Z8(e,t){let r=e.reduce((s,o)=>s+o.byteLength,0),n=new Uint8Array(r),i=0;for(let s of e)n.set(s,i),i+=s.byteLength;return t==="utf8"?new TextDecoder().decode(n):n}l(Z8,"join");function vp(e){if(e.length===0)throw new Error("Workspace runtime execution id must not be empty.");if(new TextEncoder().encode(e).byteLength>256)throw new Error("Workspace runtime execution id exceeds 256 bytes.")}l(vp,"assertExecutionId");function zY(e){if(e==="tail")return"tail";if(typeof e=="number")return e}l(zY,"resumeToAfter");var BY=class extends Error{static{l(this,"WorkspaceTransportError")}name="WorkspaceTransportError";constructor(e,t){super(e),t?.cause!==void 0&&(this.cause=t.cause)}},WY=[/rpc session was shut down/i,/rpc stub after it has been disposed/i,/rpc was canceled/i,/websocket is not open/i,/websocket closed/i,/socket hang up/i,/connection refused/i,/econnrefused/i,/econnreset/i,/network is unreachable/i,/container exited/i];function fy(e){let t=e;for(let r=0;r<8&&t!==void 0&&t!==null;r++){if(t instanceof BY)return!0;if(t instanceof Error){if(t.name==="WorkspaceTransportError")return!0;for(let i of WY)if(i.test(t.message))return!0;let n=t.cause;if(n===t)return!1;t=n;continue}return!1}return!1}l(fy,"isWorkspaceTransportFailure");var Y8="x-workspace-egress-token",X8="x-workspace-egress-url";function J8(e){switch(e.mode){case"none":return{globalOutbound:null};case"direct":return{};case"http-gateway":return{globalOutbound:e.gateway}}}l(J8,"dynamicWorkerEgress");import{createHash as FI}from"node:crypto";import{EventEmitter as yX}from"node:events";import*as qY from"cloudflare:workers";var sI=Symbol("workers-module");globalThis[sI]=qY;Symbol.dispose||(Symbol.dispose=Symbol.for("dispose"));Symbol.asyncDispose||(Symbol.asyncDispose=Symbol.for("asyncDispose"));Promise.withResolvers||(Promise.withResolvers=function(){let e,t;return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}});var ma=globalThis[sI],bp=ma?ma.RpcTarget:class{},HY=(async function(){}).constructor,GY=typeof Buffer<"u"?Buffer.prototype:void 0;function Au(e){switch(typeof e){case"boolean":case"number":case"string":return"primitive";case"undefined":return"undefined";case"object":case"function":break;case"bigint":return"bigint";default:return"unsupported"}if(e===null)return"primitive";let t=Object.getPrototypeOf(e);switch(t){case Object.prototype:return"object";case Function.prototype:case HY.prototype:return"function";case Array.prototype:return"array";case Date.prototype:return"date";case Uint8Array.prototype:case GY:return"bytes";case WritableStream.prototype:return"writable";case ReadableStream.prototype:return"readable";case Headers.prototype:return"headers";case Request.prototype:return"request";case Response.prototype:return"response";case Blob.prototype:return"blob";case ya.prototype:return"stub";case Rr.prototype:return"rpc-promise";default:if(ma){if(t==ma.RpcStub.prototype||e instanceof ma.ServiceStub)return"rpc-target";if(t==ma.RpcPromise.prototype||t==ma.RpcProperty.prototype)return"rpc-thenable"}return e instanceof bp?"rpc-target":e instanceof Error?"error":"unsupported"}}l(Au,"typeForRpc");function Q8(){throw new Error("RPC map() implementation was not loaded.")}l(Q8,"mapNotLoaded");var xp={applyMap:Q8,sendMap:Q8};function py(){throw new Error("Stream implementation was not loaded.")}l(py,"streamNotLoaded");var Sn={createWritableStreamHook:py,createWritableStreamFromHook:py,createReadableStreamHook:py},va=class{static{l(this,"StubHook")}stream(e,t){let n=this.call(e,t).pull(),i;return n instanceof Promise?i=n.then(s=>{s.dispose()}):(n.dispose(),i=Promise.resolve()),{promise:i}}},hs=class extends va{static{l(this,"ErrorStubHook")}constructor(e){super(),this.error=e}call(e,t){return this}map(e,t,r){return this}get(e){return this}dup(){return this}pull(){return Promise.reject(this.error)}ignoreUnhandledRejections(){}dispose(){}onBroken(e){try{e(this.error)}catch(t){Promise.resolve(t)}}},VY=new hs(new Error("Attempted to use RPC stub after it has been disposed.")),wp=l((e,t,r)=>e.call(t,r),"doCall");function ZY(e,t){let r=wp;wp=e;try{return t()}finally{wp=r}}l(ZY,"withCallInterceptor");var Bi=Symbol("realStub"),KY={apply(e,t,r){let n=e.raw;return new Rr(wp(n.hook,n.pathIfPromise||[],kn.fromAppParams(r)),[])},get(e,t,r){let n=e.raw;return t===Bi?n:t in Rr.prototype?n[t]:typeof t=="string"?new Rr(n.hook,n.pathIfPromise?[...n.pathIfPromise,t]:[t]):t===Symbol.dispose&&(!n.pathIfPromise||n.pathIfPromise.length==0)?()=>{n.hook.dispose(),n.hook=VY}:void 0},has(e,t){let r=e.raw;return t===Bi?!0:t in Rr.prototype?t in r:typeof t=="string"?!0:t===Symbol.dispose&&(!r.pathIfPromise||r.pathIfPromise.length==0)},construct(e,t){throw new Error("An RPC stub cannot be used as a constructor.")},defineProperty(e,t,r){throw new Error("Can't define properties on RPC stubs.")},deleteProperty(e,t){throw new Error("Can't delete properties on RPC stubs.")},getOwnPropertyDescriptor(e,t){},getPrototypeOf(e){return Object.getPrototypeOf(e.raw)},isExtensible(e){return!1},ownKeys(e){return[]},preventExtensions(e){return!0},set(e,t,r,n){throw new Error("Can't assign properties on RPC stubs.")},setPrototypeOf(e,t){throw new Error("Can't override prototype of RPC stubs.")}},ya=class gy extends bp{static{l(this,"_RpcStub")}constructor(t,r){if(super(),!(t instanceof va)){let i=t;if(i instanceof bp||i instanceof Function?t=Su.create(i,void 0):t=new Hs(kn.fromAppReturn(i)),r)throw new TypeError("RpcStub constructor expected one argument, received two.")}this.hook=t,this.pathIfPromise=r;let n=l(()=>{},"func");return n.raw=this,new Proxy(n,KY)}hook;pathIfPromise;dup(){let t=this[Bi];return t.pathIfPromise?new gy(t.hook.get(t.pathIfPromise)):new gy(t.hook.dup())}onRpcBroken(t){this[Bi].hook.onBroken(t)}map(t){let{hook:r,pathIfPromise:n}=this[Bi];return xp.sendMap(r,n||[],t)}toString(){return"[object RpcStub]"}},Rr=class extends ya{static{l(this,"RpcPromise")}constructor(e,t){super(e,t)}then(e,t){return hy(this).then(...arguments)}catch(e){return hy(this).catch(...arguments)}finally(e){return hy(this).finally(...arguments)}toString(){return"[object RpcPromise]"}};function YY(e){let{hook:t,pathIfPromise:r}=e[Bi];return r&&r.length>0?t.get(r):t}l(YY,"unwrapStubTakingOwnership");function XY(e){let{hook:t,pathIfPromise:r}=e[Bi];return r?t.get(r):t.dup()}l(XY,"unwrapStubAndDup");function yy(e){let{hook:t,pathIfPromise:r}=e[Bi];if(!(r&&r.length>0))return t}l(yy,"unwrapStubNoProperties");function eI(e){return e[Bi].hook}l(eI,"unwrapStubOrParent");function vy(e){return e[Bi]}l(vy,"unwrapStubAndPath");async function hy(e){let{hook:t,pathIfPromise:r}=e[Bi];return r.length>0&&(t=t.get(r)),(await t.pull()).deliverResolve()}l(hy,"pullPromise");var kn=class zi{static{l(this,"_RpcPayload")}constructor(t,r,n,i){this.value=t,this.source=r,this.hooks=n,this.promises=i}static fromAppParams(t){return new zi(t,"params")}static fromAppReturn(t){return new zi(t,"return")}static fromArray(t){let r=[],n=[],i=[];for(let s of t){s.ensureDeepCopied();for(let o of s.hooks)r.push(o);for(let o of s.promises)o.parent===s&&(o={parent:i,property:i.length,promise:o.promise}),n.push(o);i.push(s.value)}return new zi(i,"owned",r,n)}static forEvaluate(t,r){return new zi(null,"owned",t,r)}static deepCopyFrom(t,r,n){let i=new zi(null,"owned",[],[]);return i.value=i.deepCopy(t,r,"value",i,!0,n),i}rpcTargets;getHookForRpcTarget(t,r,n=!0){if(this.source==="params"){if(n){let i=t;typeof i.dup=="function"&&(t=i.dup())}return Su.create(t,r)}else if(this.source==="return"){let i=this.rpcTargets?.get(t);return i?n?i.dup():(this.rpcTargets?.delete(t),i):(i=Su.create(t,r),n?(this.rpcTargets||(this.rpcTargets=new Map),this.rpcTargets.set(t,i),i.dup()):i)}else throw new Error("owned payload shouldn't contain raw RpcTargets")}getHookForWritableStream(t,r,n=!0){if(this.source==="params")return Sn.createWritableStreamHook(t);if(this.source==="return"){let i=this.rpcTargets?.get(t);return i?n?i.dup():(this.rpcTargets?.delete(t),i):(i=Sn.createWritableStreamHook(t),n?(this.rpcTargets||(this.rpcTargets=new Map),this.rpcTargets.set(t,i),i.dup()):i)}else throw new Error("owned payload shouldn't contain raw WritableStreams")}getHookForReadableStream(t,r,n=!0){if(this.source==="params")return Sn.createReadableStreamHook(t);if(this.source==="return"){let i=this.rpcTargets?.get(t);return i?n?i.dup():(this.rpcTargets?.delete(t),i):(i=Sn.createReadableStreamHook(t),n?(this.rpcTargets||(this.rpcTargets=new Map),this.rpcTargets.set(t,i),i.dup()):i)}else throw new Error("owned payload shouldn't contain raw ReadableStreams")}deepCopy(t,r,n,i,s,o){switch(Au(t)){case"unsupported":return t;case"primitive":case"bigint":case"date":case"bytes":case"blob":case"error":case"undefined":return t;case"array":{let c=t,u=c.length,d=new Array(u);for(let f=0;f<u;f++)d[f]=this.deepCopy(c[f],c,f,d,s,o);return d}case"object":{let c={},u=t;for(let d in u)c[d]=this.deepCopy(u[d],u,d,c,s,o);return c}case"stub":case"rpc-promise":{let c=t,u;if(s?u=XY(c):u=YY(c),c instanceof Rr){let d=new Rr(u,[]);return this.promises.push({parent:i,property:n,promise:d}),d}else return this.hooks.push(u),new ya(u)}case"function":case"rpc-target":{let c=t,u;return o?u=o.getHookForRpcTarget(c,r,s):u=Su.create(c,r),this.hooks.push(u),new ya(u)}case"rpc-thenable":{let c=t,u;return o?u=new Rr(o.getHookForRpcTarget(c,r,s),[]):u=new Rr(Su.create(c,r),[]),this.promises.push({parent:i,property:n,promise:u}),u}case"writable":{let c=t,u;return o?u=o.getHookForWritableStream(c,r,s):u=Sn.createWritableStreamHook(c),this.hooks.push(u),c}case"readable":{let c=t,u;return o?u=o.getHookForReadableStream(c,r,s):u=Sn.createReadableStreamHook(c),this.hooks.push(u),c}case"headers":return new Headers(t);case"request":{let c=t;return c.body&&this.deepCopy(c.body,c,"body",c,s,o),new Request(c)}case"response":{let c=t;return c.body&&this.deepCopy(c.body,c,"body",c,s,o),new Response(c.body,c)}default:throw new Error("unreachable")}}ensureDeepCopied(){if(this.source!=="owned"){let t=this.source==="params";this.hooks=[],this.promises=[];try{this.value=this.deepCopy(this.value,void 0,"value",this,t,this)}catch(r){throw this.hooks=void 0,this.promises=void 0,r}if(this.source="owned",this.rpcTargets&&this.rpcTargets.size>0)throw new Error("Not all rpcTargets were accounted for in deep-copy?");this.rpcTargets=void 0}}deliverTo(t,r,n){if(this.ensureDeepCopied(),this.value instanceof Rr)zi.deliverRpcPromiseTo(this.value,t,r,n);else{t[r]=this.value;for(let i of this.promises)zi.deliverRpcPromiseTo(i.promise,i.parent,i.property,n)}}static deliverRpcPromiseTo(t,r,n,i){let s=yy(t);if(!s)throw new Error("property promises should have been resolved earlier");let o=s.pull();o instanceof zi?o.deliverTo(r,n,i):i.push(o.then(a=>{let c=[];if(a.deliverTo(r,n,c),c.length>0)return Promise.all(c)}))}async deliverCall(t,r){try{let n=[];this.deliverTo(this,"value",n),n.length>0&&await Promise.all(n);let i=Function.prototype.apply.call(t,r,this.value);return i instanceof Rr?zi.fromAppReturn(i):zi.fromAppReturn(await i)}finally{this.dispose()}}async deliverResolve(){try{let t=[];this.deliverTo(this,"value",t),t.length>0&&await Promise.all(t);let r=this.value;return r instanceof Object&&(Symbol.dispose in r||Object.defineProperty(r,Symbol.dispose,{value:l(()=>this.dispose(),"value"),writable:!0,enumerable:!1,configurable:!0})),r}catch(t){throw this.dispose(),t}}dispose(){if(this.source==="owned")this.hooks.forEach(t=>t.dispose()),this.promises.forEach(t=>t.promise[Symbol.dispose]());else if(this.source==="return"&&(this.disposeImpl(this.value,void 0),this.rpcTargets&&this.rpcTargets.size>0))throw new Error("Not all rpcTargets were accounted for in disposeImpl()?");this.source="owned",this.hooks=[],this.promises=[]}disposeImpl(t,r){switch(Au(t)){case"unsupported":case"primitive":case"bigint":case"bytes":case"blob":case"date":case"error":case"undefined":return;case"array":{let i=t,s=i.length;for(let o=0;o<s;o++)this.disposeImpl(i[o],i);return}case"object":{let i=t;for(let s in i)this.disposeImpl(i[s],i);return}case"stub":case"rpc-promise":{let s=yy(t);s&&s.dispose();return}case"function":case"rpc-target":{let i=t,s=this.rpcTargets?.get(i);s?(s.dispose(),this.rpcTargets.delete(i)):lI(i);return}case"rpc-thenable":return;case"headers":return;case"request":{let i=t;i.body&&this.disposeImpl(i.body,i);return}case"response":{let i=t;i.body&&this.disposeImpl(i.body,i);return}case"writable":{let i=t,s=this.rpcTargets?.get(i);s?this.rpcTargets.delete(i):s=Sn.createWritableStreamHook(i),s.dispose();return}case"readable":{let i=t,s=this.rpcTargets?.get(i);s?this.rpcTargets.delete(i):s=Sn.createReadableStreamHook(i),s.dispose();return}default:return}}ignoreUnhandledRejections(){this.hooks?(this.hooks.forEach(t=>{t.ignoreUnhandledRejections()}),this.promises.forEach(t=>eI(t.promise).ignoreUnhandledRejections())):this.ignoreUnhandledRejectionsImpl(this.value)}ignoreUnhandledRejectionsImpl(t){switch(Au(t)){case"unsupported":case"primitive":case"bigint":case"bytes":case"blob":case"date":case"error":case"undefined":case"function":case"rpc-target":case"writable":case"readable":case"headers":case"request":case"response":return;case"array":{let n=t,i=n.length;for(let s=0;s<i;s++)this.ignoreUnhandledRejectionsImpl(n[s]);return}case"object":{let n=t;for(let i in n)this.ignoreUnhandledRejectionsImpl(n[i]);return}case"stub":case"rpc-promise":eI(t).ignoreUnhandledRejections();return;case"rpc-thenable":t.then(n=>{},n=>{});return;default:return}}};function my(e,t,r,n){for(let i=0;i<r.length;i++){t=e;let s=r[i];if(s in Object.prototype){e=void 0;continue}switch(Au(e)){case"object":case"function":Object.hasOwn(e,s)?e=e[s]:e=void 0;break;case"array":Number.isInteger(s)&&s>=0?e=e[s]:e=void 0;break;case"rpc-target":case"rpc-thenable":{if(Object.hasOwn(e,s))throw new TypeError(`Attempted to access property '${s}', which is an instance property of the RpcTarget. To avoid leaking private internals, instance properties cannot be accessed over RPC. If you want to make this property available over RPC, define it as a method or getter on the class, instead of an instance property.`);e=e[s],n=null;break}case"stub":case"rpc-promise":{let{hook:a,pathIfPromise:c}=vy(e);return{hook:a,remainingPath:c?c.concat(r.slice(i)):r.slice(i)}}case"writable":e=void 0;break;case"readable":e=void 0;break;case"primitive":case"bigint":case"bytes":case"blob":case"date":case"error":case"headers":case"request":case"response":e=void 0;break;case"undefined":e=e[s];break;case"unsupported":{if(i===0)throw new TypeError("RPC stub points at a non-serializable type.");{let a=r.slice(0,i).join("."),c=r.slice(0,i).join(".");throw new TypeError(`'${a}' is not a serializable type, so property ${c} cannot be accessed.`)}}default:throw new TypeError("unreachable")}}if(e instanceof Rr){let{hook:i,pathIfPromise:s}=vy(e);return{hook:i,remainingPath:s||[]}}return{value:e,parent:t,owner:n}}l(my,"followPath");var oI=class extends va{static{l(this,"ValueStubHook")}call(e,t){try{let{value:r,owner:n}=this.getValue(),i=my(r,void 0,e,n);if(i.hook)return i.hook.call(i.remainingPath,t);if(typeof i.value!="function")throw new TypeError(`'${e.join(".")}' is not a function.`);let s=t.deliverCall(i.value,i.parent);return new Ep(s.then(o=>new Hs(o)))}catch(r){return new hs(r)}}map(e,t,r){try{let n;try{let{value:i,owner:s}=this.getValue();n=my(i,void 0,e,s)}catch(i){for(let s of t)s.dispose();throw i}return n.hook?n.hook.map(n.remainingPath,t,r):xp.applyMap(n.value,n.parent,n.owner,t,r)}catch(n){return new hs(n)}}get(e){try{let{value:t,owner:r}=this.getValue();if(e.length===0&&r===null)throw new Error("Can't dup an RpcTarget stub as a promise.");let n=my(t,void 0,e,r);return n.hook?n.hook.get(n.remainingPath):new Hs(kn.deepCopyFrom(n.value,n.parent,n.owner))}catch(t){return new hs(t)}}},Hs=class aI extends oI{static{l(this,"_PayloadStubHook")}constructor(t){super(),this.payload=t}payload;getPayload(){if(this.payload)return this.payload;throw new Error("Attempted to use an RPC StubHook after it was disposed.")}getValue(){let t=this.getPayload();return{value:t.value,owner:t}}dup(){let t=this.getPayload();return new aI(kn.deepCopyFrom(t.value,void 0,t))}pull(){return this.getPayload()}ignoreUnhandledRejections(){this.payload&&this.payload.ignoreUnhandledRejections()}dispose(){this.payload&&(this.payload.dispose(),this.payload=void 0)}onBroken(t){this.payload&&this.payload.value instanceof ya&&this.payload.value.onRpcBroken(t)}};function lI(e){if(Symbol.dispose in e)try{e[Symbol.dispose]()}catch(t){Promise.reject(t)}}l(lI,"disposeRpcTarget");var Su=class wy extends oI{static{l(this,"_TargetStubHook")}static create(t,r){return typeof t!="function"&&(r=void 0),new wy(t,r)}constructor(t,r,n){super(),this.target=t,this.parent=r,n?n.refcount&&(this.refcount=n.refcount,++this.refcount.count):Symbol.dispose in t&&(this.refcount={count:1})}target;parent;refcount;getTarget(){if(this.target)return this.target;throw new Error("Attempted to use an RPC StubHook after it was disposed.")}getValue(){return{value:this.getTarget(),owner:null}}dup(){return new wy(this.getTarget(),this.parent,this)}pull(){let t=this.getTarget();return"then"in t?Promise.resolve(t).then(r=>kn.fromAppReturn(r)):Promise.reject(new Error("Tried to resolve a non-promise stub."))}ignoreUnhandledRejections(){}dispose(){this.target&&(this.refcount&&--this.refcount.count==0&&lI(this.target),this.target=void 0)}onBroken(t){}},Ep=class ku extends va{static{l(this,"_PromiseStubHook")}promise;resolution;constructor(t){super(),this.promise=t.then(r=>(this.resolution=r,r))}call(t,r){return r.ensureDeepCopied(),new ku(this.promise.then(n=>n.call(t,r)))}stream(t,r){return r.ensureDeepCopied(),{promise:this.promise.then(i=>i.stream(t,r).promise)}}map(t,r,n){return new ku(this.promise.then(i=>i.map(t,r,n),i=>{for(let s of r)s.dispose();throw i}))}get(t){return new ku(this.promise.then(r=>r.get(t)))}dup(){return this.resolution?this.resolution.dup():new ku(this.promise.then(t=>t.dup()))}pull(){return this.resolution?this.resolution.pull():this.promise.then(t=>t.pull())}ignoreUnhandledRejections(){this.resolution?this.resolution.ignoreUnhandledRejections():this.promise.then(t=>{t.ignoreUnhandledRejections()},t=>{})}dispose(){this.resolution?this.resolution.dispose():this.promise.then(t=>{t.dispose()},t=>{})}onBroken(t){this.resolution?this.resolution.onBroken(t):this.promise.then(r=>{r.onBroken(t)},t)}},JY=class{static{l(this,"NullExporter")}exportStub(e){throw new Error("Cannot serialize RPC stubs without an RPC session.")}exportPromise(e){throw new Error("Cannot serialize RPC stubs without an RPC session.")}getImport(e){}unexport(e){}createPipe(e){throw new Error("Cannot create pipes without an RPC session.")}onSendError(e){}},QY=new JY;async function eX(e,t){let r=await new Response(e).blob();return r.type===t?r:r.slice(0,r.size,t)}l(eX,"streamToBlob");var tX={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError},tI=class cI{static{l(this,"_Devaluator")}constructor(t,r){this.exporter=t,this.source=r}static devaluate(t,r,n=QY,i){let s=new cI(n,i);try{return s.devaluateImpl(t,r,0)}catch(o){if(s.exports)try{n.unexport(s.exports)}catch{}throw o}}exports;devaluateImpl(t,r,n){if(n>=64)throw new Error("Serialization exceeded maximum allowed depth. (Does the message contain cycles?)");switch(Au(t)){case"unsupported":{let s;try{s=`Cannot serialize value: ${t}`}catch{s="Cannot serialize value: (couldn't stringify value)"}throw new TypeError(s)}case"primitive":return typeof t=="number"&&!isFinite(t)?t===1/0?["inf"]:t===-1/0?["-inf"]:["nan"]:t;case"object":{let s=t,o={};for(let a in s)o[a]=this.devaluateImpl(s[a],s,n+1);return o}case"array":{let s=t,o=s.length,a=new Array(o);for(let c=0;c<o;c++)a[c]=this.devaluateImpl(s[c],s,n+1);return[a]}case"bigint":return["bigint",t.toString()];case"date":{let s=t.getTime();return["date",Number.isNaN(s)?null:s]}case"bytes":{let s=t;if(s.toBase64)return["bytes",s.toBase64({omitPadding:!0})];let o;if(typeof Buffer<"u")o=(s instanceof Buffer?s:Buffer.from(s.buffer,s.byteOffset,s.byteLength)).toString("base64");else{let a="";for(let c=0;c<s.length;c++)a+=String.fromCharCode(s[c]);o=btoa(a)}return["bytes",o.replace(/=+$/,"")]}case"headers":return["headers",[...t]];case"request":{let s=t,o={};s.method!=="GET"&&(o.method=s.method);let a=[...s.headers];if(a.length>0&&(o.headers=a),s.body)o.body=this.devaluateImpl(s.body,s,n+1),o.duplex=s.duplex||"half";else if(s.body===void 0&&!["GET","HEAD","OPTIONS","TRACE","DELETE"].includes(s.method)){let u=s.arrayBuffer(),d=new ReadableStream({async start(h){try{h.enqueue(new Uint8Array(await u)),h.close()}catch(m){h.error(m)}}}),f=Sn.createReadableStreamHook(d),p=this.exporter.createPipe(d,f);o.body=["readable",p],o.duplex=s.duplex||"half"}s.cache&&s.cache!=="default"&&(o.cache=s.cache),s.redirect!=="follow"&&(o.redirect=s.redirect),s.integrity&&(o.integrity=s.integrity),s.mode&&s.mode!=="cors"&&(o.mode=s.mode),s.credentials&&s.credentials!=="same-origin"&&(o.credentials=s.credentials),s.referrer&&s.referrer!=="about:client"&&(o.referrer=s.referrer),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.keepalive&&(o.keepalive=s.keepalive);let c=s;return c.cf&&(o.cf=c.cf),c.encodeResponseBody&&c.encodeResponseBody!=="automatic"&&(o.encodeResponseBody=c.encodeResponseBody),["request",s.url,o]}case"response":{let s=t,o=this.devaluateImpl(s.body,s,n+1),a={};s.status!==200&&(a.status=s.status),s.statusText&&(a.statusText=s.statusText);let c=[...s.headers];c.length>0&&(a.headers=c);let u=s;if(u.cf&&(a.cf=u.cf),u.encodeBody&&u.encodeBody!=="automatic"&&(a.encodeBody=u.encodeBody),u.webSocket)throw new TypeError("Can't serialize a Response containing a webSocket.");return["response",o,a]}case"blob":{let s=t,o=s.stream(),a=Sn.createReadableStreamHook(o),c=this.exporter.createPipe(o,a);return["blob",s.type,["readable",c]]}case"error":{let s=t,o=this.exporter.onSendError(s);o&&(s=o);let a=s,c,u=l((f,p)=>{let h=this.exports?.length??0;try{let m=this.devaluateImpl(p,s,n+1);c||(c={}),c[f]=m}catch{if(this.exports&&this.exports.length>h){let g=this.exports.splice(h);try{this.exporter.unexport(g)}catch{}}}},"captureProp");for(let f of Object.keys(s))f==="name"||f==="message"||f==="stack"||u(f,a[f]);"cause"in s&&u("cause",a.cause),s instanceof AggregateError&&u("errors",s.errors);let d=["error",s.name,s.message];return c?(d.push(o&&o.stack?o.stack:null),d.push(c)):o&&o.stack&&d.push(o.stack),d}case"undefined":return["undefined"];case"stub":case"rpc-promise":{if(!this.source)throw new Error("Can't serialize RPC stubs in this context.");let{hook:s,pathIfPromise:o}=vy(t),a=this.exporter.getImport(s);return a!==void 0?o?o.length>0?["pipeline",a,o]:["pipeline",a]:["import",a]:(o?s=s.get(o):s=s.dup(),this.devaluateHook(o?"promise":"export",s))}case"function":case"rpc-target":{if(!this.source)throw new Error("Can't serialize RPC stubs in this context.");let s=this.source.getHookForRpcTarget(t,r);return this.devaluateHook("export",s)}case"rpc-thenable":{if(!this.source)throw new Error("Can't serialize RPC stubs in this context.");let s=this.source.getHookForRpcTarget(t,r);return this.devaluateHook("promise",s)}case"writable":{if(!this.source)throw new Error("Can't serialize WritableStream in this context.");let s=this.source.getHookForWritableStream(t,r);return this.devaluateHook("writable",s)}case"readable":{if(!this.source)throw new Error("Can't serialize ReadableStream in this context.");let s=t,o=this.source.getHookForReadableStream(s,r);return["readable",this.exporter.createPipe(s,o)]}default:throw new Error("unreachable")}}devaluateHook(t,r){this.exports||(this.exports=[]);let n=t==="promise"?this.exporter.exportPromise(r):this.exporter.exportStub(r);return this.exports.push(n),[t,n]}};var rX=class{static{l(this,"NullImporter")}importStub(e){throw new Error("Cannot deserialize RPC stubs without an RPC session.")}importPromise(e){throw new Error("Cannot deserialize RPC stubs without an RPC session.")}getExport(e){}getPipeReadable(e){throw new Error("Cannot retrieve pipe readable without an RPC session.")}},l7e=new rX;function nX(e,t){let r=new Response(t).arrayBuffer().then(n=>{let i=new Uint8Array(n),s=new Request(e,{body:i});return new Hs(kn.fromAppReturn(s))});return new Rr(new Ep(r),[])}l(nX,"fixBrokenRequestBody");function iX(e,t){let r=eX(e,t).then(n=>new Hs(kn.fromAppReturn(n)));return new Rr(new Ep(r),[])}l(iX,"streamToBlobPromise");var rI=class uI{static{l(this,"_Evaluator")}constructor(t){this.importer=t}hooks=[];promises=[];evaluate(t){let r=kn.forEvaluate(this.hooks,this.promises);try{return r.value=this.evaluateImpl(t,r,"value"),r}catch(n){throw r.dispose(),n}}evaluateCopy(t){return this.evaluate(structuredClone(t))}evaluateImpl(t,r,n){if(t instanceof Array){if(t.length==1&&t[0]instanceof Array){let i=t[0];for(let s=0;s<i.length;s++)i[s]=this.evaluateImpl(i[s],i,s);return i}else switch(t[0]){case"bigint":if(typeof t[1]=="string")return BigInt(t[1]);break;case"date":if(t[1]===null)return new Date(NaN);if(typeof t[1]=="number")return new Date(t[1]);break;case"bytes":{if(typeof t[1]=="string"){if(typeof Buffer<"u")return Buffer.from(t[1],"base64");if(Uint8Array.fromBase64)return Uint8Array.fromBase64(t[1]);{let i=atob(t[1]),s=i.length,o=new Uint8Array(s);for(let a=0;a<s;a++)o[a]=i.charCodeAt(a);return o}}break}case"error":if(t.length>=3&&typeof t[1]=="string"&&typeof t[2]=="string"){let i=tX[t[1]]||Error,s=i===AggregateError?new i([],t[2]):new i(t[2]);if(typeof t[3]=="string"&&(s.stack=t[3]),t.length>=5){let o=t[4];if(!o||typeof o!="object"||Array.isArray(o))break;let a=s,c=o;for(let u of Object.keys(c))u==="name"||u==="message"||u==="stack"||(a[u]=this.evaluateImpl(c[u],s,u))}return s}break;case"undefined":if(t.length===1)return;break;case"inf":return 1/0;case"-inf":return-1/0;case"nan":return NaN;case"headers":if(t.length===2&&t[1]instanceof Array)return new Headers(t[1]);break;case"request":{if(t.length!==3||typeof t[1]!="string")break;let i=t[1],s=t[2];if(typeof s!="object"||s===null)break;if(s.body&&(s.body=this.evaluateImpl(s.body,s,"body"),!(s.body===null||typeof s.body=="string"||s.body instanceof Uint8Array||s.body instanceof ReadableStream)))throw new TypeError("Request body must be of type ReadableStream.");if(s.signal&&(s.signal=this.evaluateImpl(s.signal,s,"signal"),!(s.signal instanceof AbortSignal)))throw new TypeError("Request siganl must be of type AbortSignal.");if(s.headers&&!(s.headers instanceof Array))throw new TypeError("Request headers must be serialized as an array of pairs.");let o=new Request(i,s);if(s.body instanceof ReadableStream&&o.body===void 0){let a=nX(o,s.body);return this.promises.push({promise:a,parent:r,property:n}),a}else return o}case"response":{if(t.length!==3)break;let i=this.evaluateImpl(t[1],r,n);if(!(i===null||typeof i=="string"||i instanceof Uint8Array||i instanceof ReadableStream))throw new TypeError("Response body must be of type ReadableStream.");let s=t[2];if(typeof s!="object"||s===null)break;if(s.webSocket)throw new TypeError("Can't deserialize a Response containing a webSocket.");if(s.headers&&!(s.headers instanceof Array))throw new TypeError("Request headers must be serialized as an array of pairs.");return new Response(i,s)}case"blob":{if(t.length!==3||typeof t[1]!="string")break;let i=t[1],s=this.evaluateImpl(t[2],r,n);if(!(s instanceof ReadableStream))throw new TypeError("Blob content must be serialized as a ReadableStream.");let o=iX(s,i);return this.promises.push({promise:o,parent:r,property:n}),o}case"import":case"pipeline":{if(t.length<2||t.length>4||typeof t[1]!="number")break;let i=this.importer.getExport(t[1]);if(!i)throw new Error(`no such entry on exports table: ${t[1]}`);let s=t[0]=="pipeline",o=l(d=>{if(s){let f=new Rr(d,[]);return this.promises.push({promise:f,parent:r,property:n}),f}else return this.hooks.push(d),new Rr(d,[])},"addStub");if(t.length==2)return o(s?i.get([]):i.dup());let a=t[2];if(!(a instanceof Array)||!a.every(d=>typeof d=="string"||typeof d=="number"))break;if(t.length==3)return o(i.get(a));let c=t[3];if(!(c instanceof Array))break;return c=new uI(this.importer).evaluate([c]),o(i.call(a,c))}case"remap":{if(t.length!==5||typeof t[1]!="number"||!(t[2]instanceof Array)||!(t[3]instanceof Array)||!(t[4]instanceof Array))break;let i=this.importer.getExport(t[1]);if(!i)throw new Error(`no such entry on exports table: ${t[1]}`);let s=t[2];if(!s.every(d=>typeof d=="string"||typeof d=="number"))break;let o=t[3].map(d=>{if(!(d instanceof Array)||d.length!==2||d[0]!=="import"&&d[0]!=="export"||typeof d[1]!="number")throw new TypeError(`unknown map capture: ${JSON.stringify(d)}`);if(d[0]==="export")return this.importer.importStub(d[1]);{let f=this.importer.getExport(d[1]);if(!f)throw new Error(`no such entry on exports table: ${d[1]}`);return f.dup()}}),a=t[4],c=i.map(s,o,a),u=new Rr(c,[]);return this.promises.push({promise:u,parent:r,property:n}),u}case"export":case"promise":if(typeof t[1]=="number")if(t[0]=="promise"){let i=this.importer.importPromise(t[1]),s=new Rr(i,[]);return this.promises.push({parent:r,property:n,promise:s}),s}else{let i=this.importer.importStub(t[1]);return this.hooks.push(i),new ya(i)}break;case"writable":if(typeof t[1]=="number"){let i=this.importer.importStub(t[1]),s=Sn.createWritableStreamFromHook(i);return this.hooks.push(i),s}break;case"readable":if(typeof t[1]=="number"){let i=this.importer.getPipeReadable(t[1]),s=Sn.createReadableStreamHook(i);return this.hooks.push(s),i}break}throw new TypeError(`unknown special value: ${JSON.stringify(t)}`)}else if(t instanceof Object){let i=t;for(let s in i)s in Object.prototype||s==="toJSON"?(this.evaluateImpl(i[s],i,s),delete i[s]):i[s]=this.evaluateImpl(i[s],i,s);return i}else return t}};var ga,sX=class{static{l(this,"MapBuilder")}context;captureMap=new Map;instructions=[];constructor(e,t){ga?this.context={parent:ga,captures:[],subject:ga.capture(e),path:t}:this.context={parent:void 0,captures:[],subject:e,path:t},ga=this}unregister(){ga=this.context.parent}makeInput(){return new Eu(this,0)}makeOutput(e){let t;try{t=tI.devaluate(e.value,void 0,this,e)}finally{e.dispose()}return this.instructions.push(t),this.context.parent?(this.context.parent.instructions.push(["remap",this.context.subject,this.context.path,this.context.captures.map(r=>["import",r]),this.instructions]),new Eu(this.context.parent,this.context.parent.instructions.length)):this.context.subject.map(this.context.path,this.context.captures,this.instructions)}pushCall(e,t,r){let n=tI.devaluate(r.value,void 0,this,r);n=n[0];let i=this.capture(e.dup());return this.instructions.push(["pipeline",i,t,n]),new Eu(this,this.instructions.length)}pushGet(e,t){let r=this.capture(e.dup());return this.instructions.push(["pipeline",r,t]),new Eu(this,this.instructions.length)}capture(e){if(e instanceof Eu&&e.mapper===this)return e.idx;let t=this.captureMap.get(e);if(t===void 0){if(this.context.parent){let r=this.context.parent.capture(e);this.context.captures.push(r)}else this.context.captures.push(e);t=-this.context.captures.length,this.captureMap.set(e,t)}return t}exportStub(e){throw new Error("Can't construct an RpcTarget or RPC callback inside a mapper function. Try creating a new RpcStub outside the callback first, then using it inside the callback.")}exportPromise(e){return this.exportStub(e)}getImport(e){return this.capture(e)}unexport(e){}createPipe(e){throw new Error("Cannot send ReadableStream inside a mapper function.")}onSendError(e){}};xp.sendMap=(e,t,r)=>{let n=new sX(e,t),i;try{i=kn.fromAppReturn(ZY(n.pushCall.bind(n),()=>r(new Rr(n.makeInput(),[]))))}finally{n.unregister()}if(i instanceof Promise)throw i.catch(s=>{}),new Error("RPC map() callbacks cannot be async.");return new Rr(n.makeOutput(i),[])};function xu(){throw new Error("Attempted to use an abstract placeholder from a mapper function. Please make sure your map function has no side effects.")}l(xu,"throwMapperBuilderUseError");var Eu=class extends va{static{l(this,"MapVariableHook")}constructor(e,t){super(),this.mapper=e,this.idx=t}dup(){return this}dispose(){}get(e){if(e.length==0)return this;if(ga)return ga.pushGet(this,e);xu()}call(e,t){xu()}map(e,t,r){xu()}pull(){xu()}ignoreUnhandledRejections(){}onBroken(e){xu()}},oX=class{static{l(this,"MapApplicator")}constructor(e,t){this.captures=e,this.variables=[t]}variables;dispose(){for(let e of this.variables)e.dispose()}apply(e){try{if(e.length<1)throw new Error("Invalid empty mapper function.");for(let t of e.slice(0,-1)){let r=new rI(this).evaluateCopy(t);if(r.value instanceof ya){let n=yy(r.value);if(n){this.variables.push(n);continue}}this.variables.push(new Hs(r))}return new rI(this).evaluateCopy(e[e.length-1])}finally{for(let t of this.variables)t.dispose()}}importStub(e){throw new Error("A mapper function cannot refer to exports.")}importPromise(e){return this.importStub(e)}getExport(e){return e<0?this.captures[-e-1]:this.variables[e]}getPipeReadable(e){throw new Error("A mapper function cannot use pipe readables.")}};function nI(e,t,r,n,i){let s=new Hs(kn.deepCopyFrom(e,t,r)),o=new oX(n,s);try{return o.apply(i)}finally{o.dispose()}}l(nI,"applyMapToElement");xp.applyMap=(e,t,r,n,i)=>{try{let s;if(e instanceof Rr)throw new Error("applyMap() can't be called on RpcPromise");if(e instanceof Array){let o=[];try{for(let a of e)o.push(nI(a,e,r,n,i))}catch(a){for(let c of o)c.dispose();throw a}s=kn.fromArray(o)}else e==null?s=kn.fromAppReturn(e):s=nI(e,t,r,n,i);return new Hs(s)}finally{for(let s of n)s.dispose()}};var aX=class by extends va{static{l(this,"_WritableStreamStubHook")}state;static create(t){let r=t.getWriter();return new by({refcount:1,writer:r,closed:!1})}constructor(t,r){super(),this.state=t,r&&++t.refcount}getState(){if(this.state)return this.state;throw new Error("Attempted to use a WritableStreamStubHook after it was disposed.")}call(t,r){try{let n=this.getState();if(t.length!==1||typeof t[0]!="string")throw new Error("WritableStream stub only supports direct method calls");let i=t[0];if(i!=="write"&&i!=="close"&&i!=="abort")throw r.dispose(),new Error(`Unknown WritableStream method: ${i}`);(i==="close"||i==="abort")&&(n.closed=!0);let s=n.writer[i],o=r.deliverCall(s,n.writer);return new Ep(o.then(a=>new Hs(a)))}catch(n){return new hs(n)}}map(t,r,n){for(let i of r)i.dispose();return new hs(new Error("Cannot use map() on a WritableStream"))}get(t){return new hs(new Error("Cannot access properties on a WritableStream stub"))}dup(){let t=this.getState();return new by(t,this)}pull(){return Promise.reject(new Error("Cannot pull a WritableStream stub"))}ignoreUnhandledRejections(){}dispose(){let t=this.state;this.state=void 0,t&&--t.refcount===0&&(t.closed||t.writer.abort(new Error("WritableStream RPC stub was disposed without calling close()")).catch(()=>{}),t.writer.releaseLock())}onBroken(t){}},lX=256*1024,cX=1024*1024*1024,uX=64*1024,dX=2,iI=1.25,fX=.9,pX=3,hX=class{static{l(this,"FlowController")}constructor(e){this.now=e}window=lX;bytesInFlight=0;inStartupPhase=!0;delivered=0;deliveredTime=0;firstAckTime=0;firstAckDelivered=0;minRtt=1/0;roundsWithoutIncrease=0;lastRoundWindow=0;roundStartTime=0;onSend(e){this.bytesInFlight+=e;let t={sentTime:this.now(),size:e,deliveredAtSend:this.delivered,deliveredTimeAtSend:this.deliveredTime,windowAtSend:this.window,windowFullAtSend:this.bytesInFlight>=this.window};return{token:t,shouldBlock:t.windowFullAtSend}}onError(e){this.bytesInFlight-=e.size}onAck(e){let t=this.now();this.delivered+=e.size,this.deliveredTime=t,this.bytesInFlight-=e.size;let r=t-e.sentTime;if(this.minRtt=Math.min(this.minRtt,r),this.firstAckTime===0)this.firstAckTime=t,this.firstAckDelivered=this.delivered;else{let n,i;e.deliveredTimeAtSend===0?(n=this.firstAckTime,i=this.firstAckDelivered):(n=e.deliveredTimeAtSend,i=e.deliveredAtSend);let s=t-n,a=(this.delivered-i)/s,c=this.inStartupPhase?dX:iI,u=a*this.minRtt*c;u=Math.min(u,e.windowAtSend*c),e.windowFullAtSend?u=Math.max(u,e.windowAtSend*fX):u=Math.max(u,this.window),this.window=Math.max(Math.min(u,cX),uX),this.inStartupPhase&&e.sentTime>=this.roundStartTime&&(this.window>this.lastRoundWindow*iI?this.roundsWithoutIncrease=0:++this.roundsWithoutIncrease>=pX&&(this.inStartupPhase=!1),this.roundStartTime=t,this.lastRoundWindow=this.window)}return this.bytesInFlight<this.window}};function mX(e){let t,r=!1,n=new hX(()=>performance.now()),i,s,o=l(()=>{r||(r=!0,e.dispose())},"disposeHook");return new WritableStream({write(a,c){if(t!==void 0)throw t;let u=kn.fromAppParams([a]),{promise:d,size:f}=e.stream(["write"],u);if(f===void 0)return d.catch(p=>{throw t===void 0&&(t=p),p});{let{token:p,shouldBlock:h}=n.onSend(f);if(d.then(()=>{n.onAck(p)&&i&&(i(),i=void 0,s=void 0)},m=>{n.onError(p),t===void 0&&(t=m,c.error(m),o()),s&&(s(m),i=void 0,s=void 0)}),h)return new Promise((m,g)=>{i=m,s=g})}},async close(){if(t!==void 0)throw o(),t;let{promise:a}=e.stream(["close"],kn.fromAppParams([]));try{await a}catch(c){throw t??c}finally{o()}},abort(a){if(t!==void 0)return;t=a??new Error("WritableStream was aborted"),s&&(s(t),i=void 0,s=void 0);let{promise:c}=e.stream(["abort"],kn.fromAppParams([a]));c.then(()=>o(),()=>o())}})}l(mX,"createWritableStreamFromHook");var gX=class xy extends va{static{l(this,"_ReadableStreamStubHook")}state;static create(t){return new xy({refcount:1,stream:t,canceled:!1})}constructor(t,r){super(),this.state=t,r&&++t.refcount}call(t,r){return r.dispose(),new hs(new Error("Cannot call methods on a ReadableStream stub"))}map(t,r,n){for(let i of r)i.dispose();return new hs(new Error("Cannot use map() on a ReadableStream"))}get(t){return new hs(new Error("Cannot access properties on a ReadableStream stub"))}dup(){let t=this.state;if(!t)throw new Error("Attempted to dup a ReadableStreamStubHook after it was disposed.");return new xy(t,this)}pull(){return Promise.reject(new Error("Cannot pull a ReadableStream stub"))}ignoreUnhandledRejections(){}dispose(){let t=this.state;this.state=void 0,t&&--t.refcount===0&&(t.canceled||(t.canceled=!0,t.stream.locked||t.stream.cancel(new Error("ReadableStream RPC stub was disposed without being consumed")).catch(()=>{})))}onBroken(t){}};Sn.createWritableStreamHook=aX.create;Sn.createWritableStreamFromHook=mX;Sn.createReadableStreamHook=gX.create;var So=bp;import{RpcTarget as vX,WorkerEntrypoint as UI}from"cloudflare:workers";function _e(e,t,r){let n=new Error(r===void 0?t:`${t}: ${r}`);return n.name="WorkspaceFsError",n.code=e,n.path=r,n}l(_e,"createWorkspaceError");function Sp(e,t){return _e("EINVAL",`Invalid path (${t})`,e)}l(Sp,"invalidPath");function Tt(e){if(e.length===0)throw Sp(e,"empty");if(!e.startsWith("/"))throw Sp(e,"must be absolute");if(e.includes("\0"))throw Sp(e,"contains NUL byte");let t=[];for(let s of e.split("/"))if(!(s===""||s===".")){if(s===".."){if(t.length===0)throw Sp(e,"escapes root");t.pop();continue}t.push(s)}let r=t.length===0?"/":`/${t.join("/")}`,n=t.length===0?"":t[t.length-1],i=t.slice(0,-1);return{path:r,parts:t,name:n,parentPath:t.length===0?void 0:i.length===0?"/":`/${i.join("/")}`}}l(Tt,"canonicalizePath");function dn(e){let t=e.one("UPDATE vfs_meta SET v = v + 1 WHERE k = 'rev' RETURNING v");if(t===void 0)throw new Error("vfs_meta.rev row missing; was initializeSchema run?");return t.v}l(dn,"incrementRev");var My=new WeakMap;function dI(e){My.delete(e)}l(dI,"invalidateReadOnlyMountCache");function wX(e){let t=e.all("SELECT root FROM _vfs_mounts WHERE mode = 'read-only'").map(r=>r.root);return My.set(e,t),t}l(wX,"loadReadOnlyRoots");function Fy(e){let t=My.get(e);return t!==void 0?t:wX(e)}l(Fy,"getReadOnlyMountRoots");function jI(e,t){return t==="/"||e===t||e.startsWith(`${t}/`)}l(jI,"isAtOrBelowRoot");function zI(e,t){return jI(e,t)||t.startsWith(`${e}/`)}l(zI,"overlapsRoot");function xr(e,t){let r=Fy(e);if(r.length!==0){for(let n of r)if(zI(t,n))throw _e("EROFS",`read-only mount at ${n}: cannot modify`,t)}}l(xr,"assertNotReadOnly");function BI(e,t){let r=Fy(e);for(let n of r)if(jI(t,n))throw _e("EROFS",`read-only mount at ${n}: cannot modify`,t)}l(BI,"assertNotInReadOnlyMount");function bX(e,t){let r=Fy(e);for(let n of r)if(zI(t,n))return n}l(bX,"readOnlyRootFor");var xX=[`CREATE TABLE IF NOT EXISTS vfs_meta (
|
|
127
127
|
k TEXT PRIMARY KEY,
|
|
128
128
|
v INTEGER NOT NULL
|
|
129
129
|
)`,`CREATE TABLE IF NOT EXISTS vfs_nodes (
|
|
@@ -292,10 +292,10 @@ Example:
|
|
|
292
292
|
`);r=s.pop()??"";for(let o of s)o&&i.enqueue(II(JSON.parse(o)))},flush(n){r+=t.decode(),r.trim()&&n.enqueue(II(JSON.parse(r)))}}))}l(hQ,"decodeRuntimeEvents");function mQ(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"raw"in e}l(mQ,"isRaw");function $I(e){return e.length>0&&/^[A-Za-z0-9_\-+=:,./@%]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}l($I,"shellQuote");function gQ(e){return mQ(e)?e.raw:Array.isArray(e)?e.map(t=>$I(String(t))).join(" "):$I(String(e))}l(gQ,"interpolate");function yQ(e){if(Array.isArray(e))throw new TypeError("The remote stub's exec() does not take a tagged template. Reach the Workspace through getWorkspace(stub) and call exec as a template there, or wrap the command in the sh tag so interpolated values are escaped before the command crosses the RPC boundary.")}l(yQ,"assertNotTemplate");function vQ(e,...t){let r=e.raw,n=r[0];for(let i=0;i<t.length;i++)n+=gQ(t[i])+r[i+1];return n}l(vQ,"sh");function ko(e){let t="";for(let r=0;r<e.byteLength;r++)t+=e[r].toString(16).padStart(2,"0");return t}l(ko,"hex");function wQ(e){let t=e?.[Symbol.dispose];typeof t=="function"&&t.call(e)}l(wQ,"maybeDispose$1");var bQ=256;async function xQ(e,t,r){return A$(e,t,r,!1)}l(xQ,"pullOnce");async function A$(e,t,r,n){let i=Yy(e,r),s=Zy(e,"pushRev",r),o=await t.fetchChanges({after:i});try{let{currentCursor:a,appliedPushCursor:c}=o,u=c.rev<s,d=Ou(a,i)<0;if(!n&&(u||d))return await o.stream.cancel().catch(()=>{}),console.debug("[pullOnce] cross-side watermark divergence; resetting and retrying",{backend:r,appliedPushCursor:c,localPushRev:s,currentCursor:a,after:i,resetPushRev:u,resetFetchCursor:d}),u&&Ky(e,"pushRev",0,r),d&&Xy(e,{rev:0,path:null},r),A$(e,t,r,!0);if(k$(c,{rev:s,path:null}),EQ(i,a))return{applied:0,skipped:[]};let f=o.stream.getReader(),p=0,h=[],m=!1;try{for(;!m;){let g=[],y=[],x=new Set;for(;g.length<bQ;){let{value:k,done:S}=await f.read();if(S){m=!0;break}if(g.push(k),k.kind==="file")for(let A of k.chunks){let $=ko(A.hash);x.has($)||(x.add($),y.push(A.hash))}}if(g.length===0)break;if(y.length>0){let k=await t.hasObjects(y),S=new Set;for(let O of k)S.add(ko(O));let A=new Set(uQ(e,y).map(ko)),$=y.filter(O=>{let _=ko(O);return S.has(_)&&!A.has(_)});if($.length>0){let O=(await t.fetchObjects($)).getReader();try{for(;;){let{value:_,done:F}=await O.read();if(F)break;zy(e,_.hash,_.bytes,Date.now())}}finally{O.releaseLock()}}}let w=await sQ(e,g,new Map,{source:"upstream",backend:r}),b=g[g.length-1];if(_I(e,{rev:b.rev,path:b.path},r),p+=w.applied,w.skipped.length>0)for(let k of w.skipped)h.push(k)}}finally{f.releaseLock()}return _I(e,a,r),{applied:p,skipped:h}}finally{wQ(o)}}l(A$,"pullOnceImpl");function EQ(e,t){return t.rev<e.rev?!0:t.rev===e.rev&&e.path===null}l(EQ,"cursorComplete");function _I(e,t,r){Ou(t,Yy(e,r))>0&&Xy(e,t,r)}l(_I,"writeFetchCursorIfAhead");async function SQ(e,t,r){let n=Zy(e,"pushRev",r),i=Ry(e);if(i<=n)return 0;let s=[],o=[],a=new Set;for await(let f of b$(e,{rev:n,path:null}))if(s.push(f),f.kind==="file")for(let p of f.chunks){let h=ko(p.hash);a.has(h)||(a.add(h),o.push(p.hash))}if(s.length===0)return 0;let c=new Set;if(o.length>0){let f=await t.hasObjects(o);for(let p of f)c.add(ko(p))}let u=o.filter(f=>!c.has(ko(f)));if(u.length>0){let f=(function*(){for(let h of u){let m=e.one("SELECT bytes FROM vfs_blob_bytes WHERE hash = ?",h);if(m===void 0)throw new Error(`pushOnce: missing local blob ${ko(h)}`);yield{hash:h,bytes:m.bytes}}})(),p=new ReadableStream({pull(h){let m=f.next();m.done?h.close():h.enqueue(m.value)}});await t.pushObjects(p)}let d=new ReadableStream({start(f){for(let p of s)f.enqueue(p);f.close()}});return k$((await t.push({senderRev:i,changes:d})).appliedPushCursor,{rev:i,path:null}),Ky(e,"pushRev",i,r),s.length}l(SQ,"pushOnce");async function kQ(e,t,r){let n=await t.watermarks(),i=Yy(e,r),s=Zy(e,"pushRev",r),o=!1,a=!1;return n.currentRev<i.rev&&(Xy(e,{rev:0,path:null},r),o=!0),n.fetchCursor.rev<s&&(Ky(e,"pushRev",0,r),a=!0),{fetchRevReset:o,pushRevReset:a}}l(kQ,"reconcileWatermarks");async function AQ(e){let{db:t,fs:r,mounts:n}=e,i=new Map;for(let a of n.keys()){let c=t.one("SELECT indexed FROM _vfs_mounts WHERE root = ?",a);i.set(a,c?.indexed===1)}let s=[...n.entries()].filter(([a])=>i.get(a)!==!0);if(s.length===0)return;let o=(await Promise.allSettled(s.map(async([a,c])=>{t.run(`INSERT INTO _vfs_mounts (root, kind, mode, indexed) VALUES (?, ?, 'read-write', 0)
|
|
293
293
|
ON CONFLICT(root) DO UPDATE SET kind = excluded.kind, mode = 'read-write', indexed = 0`,a,c.kind),dI(t);let u=_Q({fs:r,root:a,mount:c});try{await r.mkdir(a,{recursive:!0}),await c.materialize(u),$Q(t,a)}catch(d){try{await r.rm(a,{recursive:!0,force:!0})}catch{}throw d}t.run("UPDATE _vfs_mounts SET mode = ?, indexed = 1 WHERE root = ?",c.mode,a),dI(t)}))).filter(a=>a.status==="rejected");if(o.length>0)throw o[0].reason}l(AQ,"runIndex");function IQ(e,t){if(t==="/")return 1;let r=t.split("/").filter(i=>i.length>0),n=1;for(let i of r){let s=e.one(`SELECT d.child_inode AS child_inode, n.type AS type
|
|
294
294
|
FROM vfs_dirents d JOIN vfs_nodes n ON n.inode = d.child_inode
|
|
295
|
-
WHERE d.parent_inode = ? AND d.name = ?`,n,i);if(s===void 0)return;n=s.child_inode}return n}l(IQ,"findInodeAt");function $Q(e,t){let r=IQ(e,t);if(r===void 0)return;let n=[r],i=[r];for(;i.length>0;){let s=i.shift(),o=e.all("SELECT child_inode FROM vfs_dirents WHERE parent_inode = ?",s);for(let a of o)n.push(a.child_inode),i.push(a.child_inode)}for(let s of n)e.run("UPDATE vfs_nodes SET mount_root = ? WHERE inode = ?",t,s)}l($Q,"stampMountProvenance");function _Q(e){let{fs:t,root:r,mount:n}=e,i=n.maxBytes,s=n.maxEntries,o=0,a=0;function c(u){if(!u.startsWith(`${r}/`)&&u!==r)throw new Error(`mount ${r}: writeFile/mkdir target ${u} is outside the mount root`)}return l(c,"checkPath"),{root:r,async writeFile(u,d,f){if(c(u),s!==void 0&&a+1>s)throw new Error(`mount ${r}: maxEntries=${s} exceeded`);a+=1;let p=u.lastIndexOf("/");p>0&&await t.mkdir(u.slice(0,p),{recursive:!0});let h=d;if(i!==void 0){let[m,g]=d.tee();h=g;let y=l(S=>{g.cancel(S).catch(()=>{})},"cancelForwarded"),x=(async()=>{let S=m.getReader();try{for(;;){let{value:A,done:$}=await S.read();if($)break;if(A!==void 0&&(o+=A.byteLength,o>i)){let O=new Error(`mount ${r}: maxBytes=${i} exceeded (saw ${o})`);throw y(O),O}}}finally{S.releaseLock()}})(),w=t.writeFile(u,h,{mode:f}),[b,k]=await Promise.allSettled([x,w]);if(b.status==="rejected")throw b.reason;if(k.status==="rejected")throw k.reason;return}await t.writeFile(u,h,{mode:f})},async mkdir(u,d){if(c(u),s!==void 0&&a+1>s)throw new Error(`mount ${r}: maxEntries=${s} exceeded`);a+=1,await t.mkdir(u,{recursive:!0,mode:d})}}}l(_Q,"createWriteAPI");var TQ=class{static{l(this,"MountIndex")}#e;#r;#n;#t;#i=!1;constructor(e){this.#e=e.db,this.#r=e.fs,this.#n=e.mounts}ensureIndexed(){return this.#i?Promise.resolve():this.#t?this.#t:this.#n.size===0?(this.#i=!0,Promise.resolve()):(this.#t=AQ({db:this.#e,fs:this.#r,mounts:this.#n}).then(()=>{this.#i=!0}).finally(()=>{this.#t=void 0}),this.#t)}};function CQ(e){if(e.length===0||!e.startsWith("/"))throw new Error(`mount root must be absolute (starts with '/'): ${JSON.stringify(e)}`);if(e.length>1&&e.endsWith("/"))throw new Error(`mount root must not have a trailing slash: ${JSON.stringify(e)}`)}l(CQ,"validateRoot");function OQ(e){for(let t=0;t<e.length;t++)for(let r=0;r<e.length;r++){if(t===r)continue;let n=e[t],i=e[r];if(i.startsWith(`${n}/`))throw new Error(`mount roots must not nest: ${n} contains ${i}`)}}l(OQ,"rejectNesting");function NQ(e,t){let r=new Map;if(e===void 0)return r;let n=Object.keys(e);for(let a of n)CQ(a);OQ(n);let i=t.sessionId??"",s,o=l(()=>(s===void 0&&(s=t.vfs()),s),"vfs");for(let a of n){let c=e[a];if(typeof c=="function"){let u={sessionId:i,root:a,vfs:o()};r.set(a,c(u))}else r.set(a,c)}return r}l(NQ,"buildMountRegistry");var RQ={setAttribute(){}},I$={span(e,t,r){return r(RQ)}};function $r(e,t,r,n,i){return e.span(t,r,async s=>{try{let o=await n();if(i)try{i(s,{ok:!0,value:o})}catch{}return o}catch(o){if(PQ(s,o),i)try{i(s,{ok:!1,error:o})}catch{}throw o}})}l($r,"withSpan");function PQ(e,t){t instanceof Error&&e.setAttribute("error.name",t.name),e.setAttribute("error.message",Nu(t))}l(PQ,"recordError");var DQ=512;function Nu(e){let t=e instanceof Error?e.message:String(e);return Array.from(t,r=>r<" "||r.charCodeAt(0)===127?" ":r).join("").replace(/\b(authorization|token|api[_-]?key|password|secret|cookie)=([^\s&]+)/gi,"$1=[REDACTED]").replace(/\bBearer\s+[^\s,;]+/gi,"Bearer [REDACTED]").slice(0,DQ)}l(Nu,"safeErrorMessage");function TI(e){return"protocol"in e&&e.protocol==="module"}l(TI,"isModuleBackend");var LQ=class{static{l(this,"CommandExecutor")}#e;#r;#n;constructor(e,t,r=I$){this.#e=e,this.#r=t,this.#n=r}async exec(e,t={}){yQ(e);let r=0;try{r=await this.#r.push()}catch{}let n=await $r(this.#n,"workspace.runtime.exec.spawn",{"workspace.runtime.cwd":t.cwd,"workspace.runtime.timeout_ms":t.timeoutMs,"workspace.runtime.id":t.id},()=>this.#e.exec({source:e,id:t.id,cwd:t.cwd,timeoutMs:t.timeoutMs,env:t.env,stdin:typeof t.stdin=="string"?new TextEncoder().encode(t.stdin):t.stdin}),(o,a)=>{a.ok&&o.setAttribute("workspace.runtime.id",a.value.id)}),{stream:i,outcome:s}=CI(OI(n.events,()=>NI(n)),this.#r);return{id:n.id,events:i,sync:{pushed:r,outcome:s}}}async get(e,t={}){let r=MQ(t.resume),n=await this.#e.getExec({id:e,after:r}),{stream:i,outcome:s}=CI(OI(n.events,()=>NI(n)),this.#r);return{id:e,events:i,sync:{pushed:0,outcome:s}}}kill(e,t){return this.#e.killExec({id:e,signal:t})}dispose(e){return this.#e.disposeExec({id:e})}};function MQ(e){if(!(e===void 0||e==="full"))return e==="tail"?"tail":e}l(MQ,"resumeToAfter");function CI(e,t){let r=e.getReader(),n,i=new Promise(s=>{n=s});return{stream:new ReadableStream({async pull(s){try{let o=await r.read();if(!o.done){s.enqueue(o.value);return}r.releaseLock();let a=await FQ(t);n(a),s.close()}catch(o){try{r.releaseLock()}catch{}n({applied:0,skipped:[],sync:{status:"pending",applied:0,skipped:[],error:Nu(o)}}),s.error(o)}},async cancel(s){try{await r.cancel(s)}finally{r.releaseLock(),n({applied:0,skipped:[],sync:{status:"pending",applied:0,skipped:[],error:Nu(s)}})}}},{highWaterMark:0}),outcome:i}}l(CI,"withPostPull");async function FQ(e){try{let t=await e.pull();return{applied:t.applied,skipped:t.skipped,sync:{status:"complete",applied:t.applied,skipped:t.skipped}}}catch(t){try{await e.onPullPending?.(t)}catch{}return{applied:0,skipped:[],sync:{status:"pending",applied:0,skipped:[],error:Nu(t)}}}}l(FQ,"runPostPull");function OI(e,t){let r=e.getReader(),n=!1,i=l(()=>{if(!n){n=!0;try{r.releaseLock()}catch{}try{t()}catch{}}},"finish");return new ReadableStream({async pull(s){try{let{value:o,done:a}=await r.read();a?(i(),s.close()):s.enqueue(o)}catch(o){i(),s.error(o)}},async cancel(s){try{await r.cancel(s)}finally{i()}}},{highWaterMark:0})}l(OI,"disposeOnDone");function NI(e){let t=e?.[Symbol.dispose];typeof t=="function"&&t.call(e)}l(NI,"maybeDispose");var $$=UQ();function UQ(){try{if(globalThis.process?.env?.CAPNWEB_TRACK_STUBS==="1")return!0}catch{}let e=globalThis.CAPNWEB_TRACK_STUBS;return e==="1"||e===!0}l(UQ,"readFlag");var $u=new Map,Py=new WeakSet;function Sa(e){if(!$$||Py.has(e))return;Py.add(e);let t=e.constructor?.name??"anonymous";$u.set(t,($u.get(t)??0)+1)}l(Sa,"trackStub");function ka(e){if(!$$||!Py.delete(e))return;let t=e.constructor?.name??"anonymous",r=$u.get(t)??0;r<=1?$u.delete(t):$u.set(t,r-1)}l(ka,"untrackStub");var jQ=class extends So{static{l(this,"WorkspaceFilesystemStub")}#e;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){ka(this)}readFile(e,t){return $r(this.#e.observer,"workspace.fs.readFile",{"workspace.fs.path":e},()=>this.#e.fs.readFile(e,t))}exists(e){return $r(this.#e.observer,"workspace.fs.exists",{"workspace.fs.path":e},async()=>await this.statOrNull(e)!==null)}stat(e){return $r(this.#e.observer,"workspace.fs.stat",{"workspace.fs.path":e},()=>this.#e.fs.stat(e))}async statOrNull(e){return $r(this.#e.observer,"workspace.fs.statOrNull",{"workspace.fs.path":e},async()=>{try{return await this.#e.fs.stat(e)}catch(t){if(t.code==="ENOENT")return null;throw t}})}lstat(e){return $r(this.#e.observer,"workspace.fs.lstat",{"workspace.fs.path":e},()=>this.#e.fs.lstat(e))}async lstatOrNull(e){return $r(this.#e.observer,"workspace.fs.lstatOrNull",{"workspace.fs.path":e},async()=>{try{return await this.#e.fs.lstat(e)}catch(t){if(t.code==="ENOENT")return null;throw t}})}readlink(e){return $r(this.#e.observer,"workspace.fs.readlink",{"workspace.fs.path":e},()=>this.#e.fs.readlink(e))}readdir(e,t={}){return $r(this.#e.observer,"workspace.fs.readdir",{"workspace.fs.path":e},()=>this.#e.fs.readdir(e,t),(r,n)=>{n.ok&&r.setAttribute("workspace.fs.entries",n.value.length)})}find(e,t,r={}){return $r(this.#e.observer,"workspace.fs.find",{"workspace.fs.path":e,"workspace.fs.pattern":t},()=>this.#e.fs.find(e,t,r),(n,i)=>{i.ok&&n.setAttribute("workspace.fs.matches",i.value.length)})}ls(e){return $r(this.#e.observer,"workspace.fs.ls",{"workspace.fs.path":e},()=>this.#e.fs.ls(e),(t,r)=>{r.ok&&t.setAttribute("workspace.fs.entries",r.value.length)})}grep(e,t,r={}){return $r(this.#e.observer,"workspace.fs.grep",{"workspace.fs.path":t,"workspace.fs.pattern":e},()=>this.#e.fs.grep(e,t,r),(n,i)=>{i.ok&&n.setAttribute("workspace.fs.matches",i.value.length)})}writeFile(e,t,r={}){return $r(this.#e.observer,"workspace.fs.writeFile",{"workspace.fs.path":e},()=>this.#e.fs.writeFile(e,t,r))}mkdir(e,t={}){return $r(this.#e.observer,"workspace.fs.mkdir",{"workspace.fs.path":e,"workspace.fs.recursive":t.recursive},()=>this.#e.fs.mkdir(e,t))}rm(e,t={}){return $r(this.#e.observer,"workspace.fs.rm",{"workspace.fs.path":e,"workspace.fs.recursive":t.recursive,"workspace.fs.force":t.force},()=>this.#e.fs.rm(e,t))}chmod(e,t){return $r(this.#e.observer,"workspace.fs.chmod",{"workspace.fs.path":e,"workspace.fs.mode":t},()=>this.#e.fs.chmod(e,t))}symlink(e,t){return $r(this.#e.observer,"workspace.fs.symlink",{"workspace.fs.path":t,"workspace.fs.target":e},()=>this.#e.fs.symlink(e,t))}},RI=class extends So{static{l(this,"WorkspaceRuntimeExecHandleStub")}#e;#r=!1;#n=!1;#t;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){if(this.#n)return;this.#n=!0;let e=this.#t;if(this.#t=void 0,e)e.cancel().catch(()=>{}).finally(()=>e.releaseLock());else{let t=this.#e.cancel;typeof t=="function"&&t.call(this.#e).catch(()=>{})}ka(this)}get id(){return this.#e.id}get backend(){return this.#e.backend}async result(){return this.#i(),this.#e.result()}stream(){this.#i();let e=this.#e.getReader();this.#t=e;let t=this;return new ReadableStream({async pull(r){try{let{value:n,done:i}=await e.read();if(i){e.releaseLock(),t.#t=void 0,r.close();return}r.enqueue(pQ(n))}catch(n){e.releaseLock(),t.#t=void 0,r.error(n)}},async cancel(r){try{await e.cancel(r)}finally{e.releaseLock(),t.#t=void 0}}},{highWaterMark:0})}#i(){if(this.#r)throw new Error("runtime handle already consumed: result() and stream() are single-shot");this.#r=!0}kill(e){return this.#e.kill(e)}},zQ=class extends So{static{l(this,"WorkspaceRuntimeStub")}#e;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){ka(this)}async exec(e,t={}){await this.#e.ready(t.backend);let r=await this.#e.runtime.exec(e,t);if(t.id!==void 0&&r.id!==t.id)throw new Error(`backend ran exec as ${r.id}, not the requested id ${t.id}`);return new RI(r)}async getExec(e,t={}){return await this.#e.ready(t.backend),new RI(await this.#e.runtime.getExec(e,t))}killExec(e,t={}){return this.#e.runtime.killExec(e,t)}disposeExec(e,t={}){return this.#e.runtime.disposeExec(e,t)}},BQ=class extends So{static{l(this,"WorkspaceAssetsStub")}#e;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){ka(this)}publish(e,t){return $r(this.#e.observer,"workspace.assets.publish",{"workspace.fs.path":e,"workspace.assets.expires_after_ms":t.expiresAfter},async()=>{if(this.#e.assets===void 0)throw new Error("Workspace assets are not configured");return this.#e.assets.share(e,{expiresAfter:t.expiresAfter})})}},WQ=class extends So{static{l(this,"WorkspaceArtifactsStub")}#e;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){ka(this)}create(e,t){return this.#e.create(e,t)}get(e){return this.#e.get(e)}list(){return this.#e.list()}import(e,t,r){return this.#e.import(e,t,r)}delete(e){return this.#e.delete(e)}createToken(e,t,r){return this.#e.createToken(e,t,r)}listTokens(e){return this.#e.listTokens(e)}getToken(e,t){return this.#e.getToken(e,t)}revokeToken(e,t){return this.#e.revokeToken(e,t)}cli(e){return this.#e.cli(e)}},qQ=class extends So{static{l(this,"WorkspaceGitStub")}#e;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){ka(this)}cli(e){return this.#e.git.cli(e)}},HQ=class extends So{static{l(this,"WorkspaceStub")}#e;#r;#n;#t;#i;#s;constructor(e){super(),this.#e=new jQ(e),this.#r=new zQ(e),this.#n=new qQ(e),this.#t=e.assets===void 0?void 0:new BQ(e),this.#i=new WQ(e.artifacts),this.#s=e.useThink,Sa(this)}[Symbol.dispose](){this.#e[Symbol.dispose](),this.#r[Symbol.dispose](),this.#n[Symbol.dispose](),this.#t?.[Symbol.dispose](),this.#i[Symbol.dispose](),ka(this)}get fs(){return this.#e}get useThink(){return this.#s}get runtime(){return this.#r}get git(){return this.#n}get assets(){return this.#t}get artifacts(){return this.#i}},GQ=1e3,VQ=6e4,ZQ=5,_$="Workspace git is not configured. Import createGitClient from @cloudflare/computer/git and pass createGitClient() as WorkspaceOptions.git.",PI=new Proxy({},{get(e,t){if(t!=="then")return()=>Promise.reject(new Error(_$))}}),T$=class{static{l(this,"Workspace")}#e;#r;#n;#t;#i;#s;#a;#u;#l;#o;#c;#x;#h;#C;#m;#g;#f;#E;#S;#O;#y;#p;#v;#k;#d=new Map;#A=new Map;#I=new Map;#$=new Map;#N=new Map;#_=new Map;#w=0;#P;#b;#M=new Map;constructor(e){this.#c=e.now??Date.now,this.#x=e.retryScheduler,this.#h=ky(e.retry?.initialDelayMs,GQ,"initialDelayMs"),this.#C=ky(e.retry?.maxDelayMs,VQ,"maxDelayMs"),this.#m=ky(e.retry?.maxAttempts,ZQ,"maxAttempts"),this.#g=e.sessionId??"",this.#f=e.git,this.#E=e.defaultGitIdentity,this.#S=e.useThink??!1,this.#y=e.artifacts?H8(e.artifacts.binding,e.artifacts.sessionId??e.sessionId??""):KQ(),this.#e=new QJ(e.storage),TX(this.#e,this.#c),this.#r=new NJ(this.#e,{now:this.#c});let t=(e.backends??[]).slice();this.#t=t.filter(r=>!TI(r)),this.#i=new Map(this.#t.map(r=>[r.id,r])),this.#s=new Map(t.filter(TI).map(r=>[r.id,r])),this.#a=new Set,this.#u=new Set(t.filter(r=>r.callable===!0).map(r=>r.id));for(let r of t){if(this.#a.has(r.id))throw new Error(`Workspace: duplicate backend id ${JSON.stringify(r.id)}. Pass an explicit \`id\` on each backend's constructor options to distinguish them.`);this.#a.add(r.id)}if(this.#l=t[0]?.id,this.#o=e.observer??I$,this.#v=NQ(e.mounts,{sessionId:e.sessionId,vfs:l(()=>this.provider(),"vfs")}),this.#k=new TQ({db:this.#e,fs:this.#r,mounts:this.#v}),this.#O=typeof e.assets=="function"?e.assets(this):e.assets,this.#S){let r=C$(this.fs);Object.assign(this,r)}}ensureMountsIndexed(){return this.#k.ensureIndexed()}mounts(){return new Map(this.#v)}get db(){return this.#e}get observer(){return this.#o}get fs(){return this.#r}get useThink(){return this.#S}get sessionId(){return this.#g}get assets(){return this.#O}get git(){if(!this.#f)throw new Error(_$);return this.#p||(this.#p=this.#f({ws:this,defaultIdentity:this.#E})),this.#p}get artifacts(){return this.#y}get runtime(){return this.#P||(this.#P=new K8({callableBackendIds:this.#u,backendHandle:l(e=>this.#W(e),"backendHandle"),resolveBackendId:l(e=>this.#D(e)??"","resolveBackendId")})),this.#P}provider(){return this.#n||(this.#n=new HJ(this.#e,{now:this.#c})),this.#n}ready(e){if(this.#b===void 0){let r=this.#k.ensureIndexed();this.#b=r,r.catch(()=>{this.#b===r&&(this.#b=void 0)})}let t=this.#b;if(e===void 0)return t;if(typeof e=="string"){let r=this.#D(e);return(async()=>{await t,r&&(this.#s.has(r)?await this.#L(r):await this.#T(r))})()}return e.all?(async()=>{await t,await Promise.all([...this.#t.map(r=>this.#T(r.id)),...[...this.#s.keys()].map(r=>this.#L(r))])})():t}stub(){return new HQ(this)}push(e){return this.#R(e,t=>$r(this.#o,"workspace.sync.push",{"workspace.sync.backend":t},async()=>{if(t===void 0||this.#s.has(t))return 0;let r=await this.#T(t);return r.sync==="none"?0:this.#z(t,r,()=>SQ(this.#e,r.rpc.sync,t))},(r,n)=>{n.ok&&r.setAttribute("workspace.sync.pushed",n.value)}))}pull(e){return this.#R(e,t=>this.#F(t))}retryPendingSync(e){return this.#R(e,async t=>{if(t===void 0)throw new Error("Workspace has no backend configured for pending sync retry");let r=this.#x;if(r===void 0)throw new Error("Workspace has no retryScheduler configured");let n=await r.get(t);if(n===void 0)return{status:"idle",backend:t};if(n.attempt>this.#m)return{status:"exhausted",backend:t,attempt:n.attempt,error:"pending sync retry attempts exhausted"};try{let i=await this.#F(t);return await r.clear(t),{status:"complete",backend:t,applied:i.applied,skipped:i.skipped}}catch(i){let s=Nu(i);if(n.attempt>=this.#m)return{status:"exhausted",backend:t,attempt:n.attempt,error:s};let o=this.#U(t,n.attempt+1);return await r.schedule(o),{status:"pending",...o,error:s}}})}#F(e){return $r(this.#o,"workspace.sync.pull",{"workspace.sync.backend":e},async()=>{if(e===void 0||this.#s.has(e))return{applied:0,skipped:[]};let t=await this.#T(e);return t.sync==="none"?{applied:0,skipped:[]}:this.#z(e,t,()=>xQ(this.#e,t.rpc.sync,e))},(t,r)=>{r.ok&&(t.setAttribute("workspace.sync.applied",r.value.applied),t.setAttribute("workspace.sync.skipped",r.value.skipped.length))})}async#B(e){let t=this.#x;t!==void 0&&await this.#R(e,async r=>{r===void 0||await t.get(r)!==void 0||await t.schedule(this.#U(r,1))})}#U(e,t){let r=Math.min(this.#C,this.#h*2**Math.max(0,t-1));return{backend:e,attempt:t,notBefore:this.#c()+r}}#j(e,t){return this.#d.get(e)!==t?!1:(this.#d.delete(e),this.#I.delete(e),this.#$.delete(e),!0)}async#z(e,t,r){try{return await r()}catch(n){throw fy(n)&&this.#j(e,t),n}}#R(e,t){let r=this.#D(e),n=r??"",i=(this.#M.get(n)??Promise.resolve()).then(()=>t(r),()=>t(r));return this.#M.set(n,i.then(()=>{},()=>{})),i}#D(e){if(this.#a.size===0)return;let t=e??this.#l;if(t!==void 0){if(!this.#a.has(t))throw new Error(`Workspace: no backend with id ${JSON.stringify(t)}. Configured backends: ${[...this.#a].map(r=>JSON.stringify(r)).join(", ")||"<none>"}.`);return t}}async close(){this.#w+=1;let e=[...this.#d.values()],t=[...this.#N.values()];this.#d.clear(),this.#I.clear(),this.#$.clear(),this.#A.clear(),this.#N.clear(),this.#_.clear(),this.#b=void 0,await Promise.all([...e,...t].map(async r=>{try{await r.close?.()}catch{}}))}async#W(e){return this.#s.has(e)?this.#L(e):this.#q(e)}async#q(e){let t=this.#$.get(e);if(t)return t;let{shell:r,handle:n}=await this.#H(e),i=l(o=>this.#G(e,n,o),"onError"),s={exec:l(async o=>{let a;try{a=await r.exec(o.source,{id:o.id,cwd:o.cwd,timeoutMs:o.timeoutMs,env:o.env,stdin:o.stdin})}catch(c){throw i(c),c}return{id:a.id,events:DI(a.events,i),sync:a.sync}},"exec"),getExec:l(async({id:o,after:a})=>{let c=a===void 0?"full":a,u;try{u=await r.get(o,{resume:c})}catch(d){throw i(d),d}return{id:u.id,events:DI(u.events,i),sync:u.sync}},"getExec"),killExec:l(async({id:o,signal:a})=>{try{await r.kill(o,a)}catch(c){throw i(c),c}},"killExec"),disposeExec:l(async({id:o})=>{try{await r.dispose(o)}catch(a){throw i(a),a}},"disposeExec")};return this.#$.set(e,s),s}#L(e){let t=this.#N.get(e);if(t)return Promise.resolve(t);let r=this.#_.get(e);if(r)return r;let n=this.#s.get(e);if(!n)return Promise.reject(new Error(`Workspace backend ${JSON.stringify(e)} does not execute modules.`));let i=this.#w,s;return s=$r(this.#o,"workspace.connect",{"workspace.backend.id":e,"workspace.backend.type":n.type},()=>n.connect({db:this.#e,fs:this.#r,git:this.#f?this.git:PI,artifacts:this.#y})).then(async o=>{if(i!==this.#w)throw await o.close?.().catch(()=>{}),new Error(`Workspace closed while backend ${JSON.stringify(e)} was connecting.`);return this.#N.set(e,o),o}).finally(()=>{this.#_.get(e)===s&&this.#_.delete(e)}),this.#_.set(e,s),s}#T(e){let t=this.#d.get(e);if(t!==void 0)return Promise.resolve(t);let r=this.#A.get(e);if(r!==void 0)return r;let n=this.#i.get(e);if(n===void 0)return Promise.reject(new Error(`Workspace: no backend with id ${JSON.stringify(e)}`));let i=this.#w,s;return s=(async()=>{let o=await $r(this.#o,"workspace.connect",{"workspace.backend.id":e,"workspace.backend.type":n.type},()=>n.connect({db:this.#e,fs:this.#r,git:this.#f?this.git:PI,artifacts:this.#y}));if(i!==this.#w)throw await o.close().catch(()=>{}),new Error(`Workspace closed while backend ${JSON.stringify(e)} was connecting.`);if(o.sync!=="none"&&await kQ(this.#e,o.rpc.sync,e),i!==this.#w)throw await o.close().catch(()=>{}),new Error(`Workspace closed while backend ${JSON.stringify(e)} was connecting.`);return this.#d.set(e,o),o.closed&&o.closed.catch(()=>{}).then(()=>{this.#d.get(e)===o&&(this.#d.delete(e),this.#I.delete(e),this.#$.delete(e))}),o})().finally(()=>{this.#A.get(e)===s&&this.#A.delete(e)}),this.#A.set(e,s),s}async#H(e){let t=await this.#T(e),r=this.#I.get(e);if(r!==void 0)return{shell:r,handle:t};let n=new LQ(t.rpc.shell,{push:l(()=>this.push(e),"push"),pull:l(()=>this.pull(e),"pull"),onPullPending:l(()=>this.#B(e),"onPullPending")},this.#o);return this.#I.set(e,n),{shell:n,handle:t}}#G(e,t,r){fy(r)&&this.#j(e,t)}};function DI(e,t){let r=e.getReader();return new ReadableStream({async pull(n){try{let{value:i,done:s}=await r.read();if(s){n.close();return}n.enqueue(i)}catch(i){t(i),n.error(i)}},async cancel(n){await r.cancel(n)}})}l(DI,"watchStreamForTransportError");function ky(e,t,r){let n=e??t;if(!Number.isSafeInteger(n)||n<=0)throw new Error(`Workspace retry.${r} must be a positive integer`);return n}l(ky,"positiveRetryOption");function KQ(){let e=l(()=>{throw new ha("ENOCONFIG","Workspace Artifacts binding is not configured")},"fail");return{sessionId:"",create:e,get:e,list:e,import:e,delete:e,createToken:e,listTokens:e,getToken:e,revokeToken:e,async cli(t){return dy(this,t)}}}l(KQ,"createDisabledArtifactsClient");function C$(e){return{async readFile(t){try{return await e.readFile(t,"utf8")}catch(r){if(Iy(r))return null;throw r}},async readFileBytes(t){try{return await YQ(await e.readFile(t))}catch(r){if(Iy(r))return null;throw r}},async writeFile(t,r){await e.writeFile(t,r)},async readDir(t,r){let n=await e.readdir(t),i=r?.offset??0,s=r?.limit??n.length;return n.slice(i,i+s).map(o=>Ay({path:QQ(t,o.name),name:o.name,size:0,mtime:0,isDirectory:o.isDirectory,isFile:o.isFile}))},async rm(t,r){await e.rm(t,r)},async glob(t){let{directory:r,relativePattern:n}=XQ(t);return(await e.find(r,n)).map(i=>Ay({path:i.path,name:Dy(i.path),size:0,mtime:0,isDirectory:i.type==="dir",isFile:i.type==="file"}))},async mkdir(t,r){await e.mkdir(t,r)},async stat(t){try{return Ay({...await e.stat(t),path:t,name:Dy(t)})}catch(r){if(Iy(r))return null;throw r}}}}l(C$,"createThinkCompatibility");async function YQ(e){let t=e.getReader(),r=[],n=0;try{for(;;){let{value:o,done:a}=await t.read();if(a)break;o&&(r.push(o),n+=o.byteLength)}}finally{t.releaseLock()}if(r.length===1)return r[0];let i=new Uint8Array(n),s=0;for(let o of r)i.set(o,s),s+=o.byteLength;return i}l(YQ,"drainBytes");function Ay(e){let t=e.isDirectory?"directory":"file";return{path:e.path,name:e.name,type:t,mimeType:t==="directory"?"inode/directory":"application/octet-stream",size:e.size,createdAt:e.mtime,updatedAt:e.mtime}}l(Ay,"toThinkFileInfo");function XQ(e){let t=e.startsWith("/")?e:`/workspace/${e}`,r=JQ(t);if(r===-1)return{directory:eee(t),relativePattern:Dy(t)};let n=t.lastIndexOf("/",r);return{directory:n<=0?"/":t.slice(0,n),relativePattern:t.slice(n+1)}}l(XQ,"splitGlobPattern");function JQ(e){let t=e.indexOf("*"),r=e.indexOf("?");return t===-1?r:r===-1?t:Math.min(t,r)}l(JQ,"firstWildcardIndex");function QQ(e,t){return e==="/"?`/${t}`:`${e}/${t}`}l(QQ,"joinPath");function eee(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}l(eee,"dirname");function Dy(e){let t=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e,r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}l(Dy,"basename");function Iy(e){if(!e||typeof e!="object")return!1;let t=e;return t.code==="ENOENT"?!0:typeof t.message=="string"&&/ENOENT|no such/i.test(t.message)}l(Iy,"isEnoent");var Ly=Symbol("workspace");function O$(e,t){class r extends e{static{l(this,"WithWorkspace")}constructor(...i){super(...i);let s=this;this[Ly]=new T$(t(s))}__getWorkspaceStub(){let i=this[Ly];return(async()=>(await i.ready(),i.stub()))()}}return r}l(O$,"withWorkspace");async function tee(e,t={}){let[r,n]=await Promise.all([t.id??e.id,t.backend??e.backend]),i,s,o,a=new ReadableStream({pull:l(async f=>{if(i==="result"){f.error(new Error("exec handle already consumed by result(): result() and streaming are exclusive"));return}o===void 0&&(i="stream",o=hQ(await e.stream()).getReader());try{let p=o;if(!p)throw new Error("runtime stream reader was not initialized");let{value:h,done:m}=await p.read();if(m){p.releaseLock(),o=void 0,f.close();return}f.enqueue(h)}catch(p){o?.releaseLock(),o=void 0,f.error(p)}},"pull"),cancel:l(async f=>{let p=o;if(o=void 0,!p){u();return}try{await p.cancel(f)}finally{p.releaseLock(),u()}},"cancel")},{highWaterMark:0}),c=!1,u=l(()=>{if(c)return;c=!0;let f=o;o=void 0,f&&f.cancel().catch(()=>{}).finally(()=>f.releaseLock()),e[Symbol.dispose]?.()},"dispose"),d=a;return Object.defineProperties(d,{id:{value:r,enumerable:!1},backend:{value:n,enumerable:!1},result:{value:l(()=>{if(i==="stream")throw new Error("exec handle already streaming: call result() or iterate the stream, not both");return i="result",s??=e.result(),s},"value"),enumerable:!1},kill:{value:l(f=>e.kill(f),"value"),enumerable:!1},[Symbol.dispose]:{value:u,enumerable:!1}}),d}l(tee,"rebuildExecHandle");function ree(e){return Array.isArray(e)}l(ree,"isTemplateStringsArray");function nee(e,t){async function r(o,a,...c){if(ree(o)){let p=vQ(o,...a===void 0?c:[a,...c]),h=crypto.randomUUID();return t(await e.exec(p,{id:h,encoding:"utf8"}),{id:h})}let u=iee(a),d=await e.exec(o,u),f={id:u.id,backend:u.backend};return u.encoding==="utf8",t(d,f)}return l(r,"exec"),{exec:r,getExec:l(async(o,a)=>{let c=await e.getExec(o,a),u={id:o,backend:a?.backend};return a?.encoding==="utf8",t(c,u)},"getExec"),killExec:l((o,a)=>e.killExec(o,a),"killExec"),disposeExec:l((o,a)=>e.disposeExec(o,a),"disposeExec")}}l(nee,"makeRuntimeClient");function iee(e){return{...e,id:e?.id??crypto.randomUUID()}}l(iee,"withExecutionId");function LI(e,t,r,n){let i={get fs(){return e.fs},runtime:nee(e.runtime,t),get git(){return e.git},get assets(){return e.assets},get artifacts(){return e.artifacts},[Symbol.dispose]:r};return n&&Object.assign(i,C$(i.fs)),i}l(LI,"makeClient");async function Rp(e){let t=e[Ly];if(t instanceof T$)return await t.ready(),LI({fs:t.fs,runtime:t.runtime,get git(){return t.git},artifacts:t.artifacts,assets:t.assets},n=>n,()=>{},t.useThink);let r=await e.__getWorkspaceStub();try{return LI(r,(n,i)=>tee(n,i),()=>{r[Symbol.dispose]?.()},await r.useThink)}catch(n){throw r[Symbol.dispose]?.(),n}}l(Rp,"getWorkspace");var C7e=new TextEncoder;var see=class extends UI{static{l(this,"WorkspaceProxy")}async fetch(e){let t=new URL(e.url);if(this.ctx.props.egressToken!==void 0){let n=new Headers(e.headers);n.set(Y8,this.ctx.props.egressToken),n.set(X8,e.url),t.pathname="/ws",t.search="";let i=this.#e();return i===void 0?this.#r():i.fetch(new Request(t,new Request(e,{headers:n})))}let r=t.pathname.match(/^\/__workspace_connect\/([0-9a-f-]{36})\/(health|ws)$/);if(r?.[2]==="health")return new Response(`ok
|
|
295
|
+
WHERE d.parent_inode = ? AND d.name = ?`,n,i);if(s===void 0)return;n=s.child_inode}return n}l(IQ,"findInodeAt");function $Q(e,t){let r=IQ(e,t);if(r===void 0)return;let n=[r],i=[r];for(;i.length>0;){let s=i.shift(),o=e.all("SELECT child_inode FROM vfs_dirents WHERE parent_inode = ?",s);for(let a of o)n.push(a.child_inode),i.push(a.child_inode)}for(let s of n)e.run("UPDATE vfs_nodes SET mount_root = ? WHERE inode = ?",t,s)}l($Q,"stampMountProvenance");function _Q(e){let{fs:t,root:r,mount:n}=e,i=n.maxBytes,s=n.maxEntries,o=0,a=0;function c(u){if(!u.startsWith(`${r}/`)&&u!==r)throw new Error(`mount ${r}: writeFile/mkdir target ${u} is outside the mount root`)}return l(c,"checkPath"),{root:r,async writeFile(u,d,f){if(c(u),s!==void 0&&a+1>s)throw new Error(`mount ${r}: maxEntries=${s} exceeded`);a+=1;let p=u.lastIndexOf("/");p>0&&await t.mkdir(u.slice(0,p),{recursive:!0});let h=d;if(i!==void 0){let[m,g]=d.tee();h=g;let y=l(S=>{g.cancel(S).catch(()=>{})},"cancelForwarded"),x=(async()=>{let S=m.getReader();try{for(;;){let{value:A,done:$}=await S.read();if($)break;if(A!==void 0&&(o+=A.byteLength,o>i)){let O=new Error(`mount ${r}: maxBytes=${i} exceeded (saw ${o})`);throw y(O),O}}}finally{S.releaseLock()}})(),w=t.writeFile(u,h,{mode:f}),[b,k]=await Promise.allSettled([x,w]);if(b.status==="rejected")throw b.reason;if(k.status==="rejected")throw k.reason;return}await t.writeFile(u,h,{mode:f})},async mkdir(u,d){if(c(u),s!==void 0&&a+1>s)throw new Error(`mount ${r}: maxEntries=${s} exceeded`);a+=1,await t.mkdir(u,{recursive:!0,mode:d})}}}l(_Q,"createWriteAPI");var TQ=class{static{l(this,"MountIndex")}#e;#r;#n;#t;#i=!1;constructor(e){this.#e=e.db,this.#r=e.fs,this.#n=e.mounts}ensureIndexed(){return this.#i?Promise.resolve():this.#t?this.#t:this.#n.size===0?(this.#i=!0,Promise.resolve()):(this.#t=AQ({db:this.#e,fs:this.#r,mounts:this.#n}).then(()=>{this.#i=!0}).finally(()=>{this.#t=void 0}),this.#t)}};function CQ(e){if(e.length===0||!e.startsWith("/"))throw new Error(`mount root must be absolute (starts with '/'): ${JSON.stringify(e)}`);if(e.length>1&&e.endsWith("/"))throw new Error(`mount root must not have a trailing slash: ${JSON.stringify(e)}`)}l(CQ,"validateRoot");function OQ(e){for(let t=0;t<e.length;t++)for(let r=0;r<e.length;r++){if(t===r)continue;let n=e[t],i=e[r];if(i.startsWith(`${n}/`))throw new Error(`mount roots must not nest: ${n} contains ${i}`)}}l(OQ,"rejectNesting");function NQ(e,t){let r=new Map;if(e===void 0)return r;let n=Object.keys(e);for(let a of n)CQ(a);OQ(n);let i=t.sessionId??"",s,o=l(()=>(s===void 0&&(s=t.vfs()),s),"vfs");for(let a of n){let c=e[a];if(typeof c=="function"){let u={sessionId:i,root:a,vfs:o()};r.set(a,c(u))}else r.set(a,c)}return r}l(NQ,"buildMountRegistry");var RQ={setAttribute(){}},I$={span(e,t,r){return r(RQ)}};function $r(e,t,r,n,i){return e.span(t,r,async s=>{try{let o=await n();if(i)try{i(s,{ok:!0,value:o})}catch{}return o}catch(o){if(PQ(s,o),i)try{i(s,{ok:!1,error:o})}catch{}throw o}})}l($r,"withSpan");function PQ(e,t){t instanceof Error&&e.setAttribute("error.name",t.name),e.setAttribute("error.message",Nu(t))}l(PQ,"recordError");var DQ=512;function Nu(e){let t=e instanceof Error?e.message:String(e);return Array.from(t,r=>r<" "||r.charCodeAt(0)===127?" ":r).join("").replace(/\b(authorization|token|api[_-]?key|password|secret|cookie)=([^\s&]+)/gi,"$1=[REDACTED]").replace(/\bBearer\s+[^\s,;]+/gi,"Bearer [REDACTED]").slice(0,DQ)}l(Nu,"safeErrorMessage");function TI(e){return"protocol"in e&&e.protocol==="module"}l(TI,"isModuleBackend");var LQ=class{static{l(this,"CommandExecutor")}#e;#r;#n;constructor(e,t,r=I$){this.#e=e,this.#r=t,this.#n=r}async exec(e,t={}){yQ(e);let r=0;try{r=await this.#r.push()}catch{}let n=await $r(this.#n,"workspace.runtime.exec.spawn",{"workspace.runtime.cwd":t.cwd,"workspace.runtime.timeout_ms":t.timeoutMs,"workspace.runtime.id":t.id},()=>this.#e.exec({source:e,id:t.id,cwd:t.cwd,timeoutMs:t.timeoutMs,env:t.env,stdin:typeof t.stdin=="string"?new TextEncoder().encode(t.stdin):t.stdin}),(o,a)=>{a.ok&&o.setAttribute("workspace.runtime.id",a.value.id)}),{stream:i,outcome:s}=CI(OI(n.events,()=>NI(n)),this.#r);return{id:n.id,events:i,sync:{pushed:r,outcome:s}}}async get(e,t={}){let r=MQ(t.resume),n=await this.#e.getExec({id:e,after:r}),{stream:i,outcome:s}=CI(OI(n.events,()=>NI(n)),this.#r);return{id:e,events:i,sync:{pushed:0,outcome:s}}}kill(e,t){return this.#e.killExec({id:e,signal:t})}dispose(e){return this.#e.disposeExec({id:e})}};function MQ(e){if(!(e===void 0||e==="full"))return e==="tail"?"tail":e}l(MQ,"resumeToAfter");function CI(e,t){let r=e.getReader(),n,i=new Promise(s=>{n=s});return{stream:new ReadableStream({async pull(s){try{let o=await r.read();if(!o.done){s.enqueue(o.value);return}r.releaseLock();let a=await FQ(t);n(a),s.close()}catch(o){try{r.releaseLock()}catch{}n({applied:0,skipped:[],sync:{status:"pending",applied:0,skipped:[],error:Nu(o)}}),s.error(o)}},async cancel(s){try{await r.cancel(s)}finally{r.releaseLock(),n({applied:0,skipped:[],sync:{status:"pending",applied:0,skipped:[],error:Nu(s)}})}}},{highWaterMark:0}),outcome:i}}l(CI,"withPostPull");async function FQ(e){try{let t=await e.pull();return{applied:t.applied,skipped:t.skipped,sync:{status:"complete",applied:t.applied,skipped:t.skipped}}}catch(t){try{await e.onPullPending?.(t)}catch{}return{applied:0,skipped:[],sync:{status:"pending",applied:0,skipped:[],error:Nu(t)}}}}l(FQ,"runPostPull");function OI(e,t){let r=e.getReader(),n=!1,i=l(()=>{if(!n){n=!0;try{r.releaseLock()}catch{}try{t()}catch{}}},"finish");return new ReadableStream({async pull(s){try{let{value:o,done:a}=await r.read();a?(i(),s.close()):s.enqueue(o)}catch(o){i(),s.error(o)}},async cancel(s){try{await r.cancel(s)}finally{i()}}},{highWaterMark:0})}l(OI,"disposeOnDone");function NI(e){let t=e?.[Symbol.dispose];typeof t=="function"&&t.call(e)}l(NI,"maybeDispose");var $$=UQ();function UQ(){try{if(globalThis.process?.env?.CAPNWEB_TRACK_STUBS==="1")return!0}catch{}let e=globalThis.CAPNWEB_TRACK_STUBS;return e==="1"||e===!0}l(UQ,"readFlag");var $u=new Map,Py=new WeakSet;function Sa(e){if(!$$||Py.has(e))return;Py.add(e);let t=e.constructor?.name??"anonymous";$u.set(t,($u.get(t)??0)+1)}l(Sa,"trackStub");function ka(e){if(!$$||!Py.delete(e))return;let t=e.constructor?.name??"anonymous",r=$u.get(t)??0;r<=1?$u.delete(t):$u.set(t,r-1)}l(ka,"untrackStub");var jQ=class extends So{static{l(this,"WorkspaceFilesystemStub")}#e;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){ka(this)}readFile(e,t){return $r(this.#e.observer,"workspace.fs.readFile",{"workspace.fs.path":e},()=>this.#e.fs.readFile(e,t))}exists(e){return $r(this.#e.observer,"workspace.fs.exists",{"workspace.fs.path":e},async()=>await this.statOrNull(e)!==null)}stat(e){return $r(this.#e.observer,"workspace.fs.stat",{"workspace.fs.path":e},()=>this.#e.fs.stat(e))}async statOrNull(e){return $r(this.#e.observer,"workspace.fs.statOrNull",{"workspace.fs.path":e},async()=>{try{return await this.#e.fs.stat(e)}catch(t){if(t.code==="ENOENT")return null;throw t}})}lstat(e){return $r(this.#e.observer,"workspace.fs.lstat",{"workspace.fs.path":e},()=>this.#e.fs.lstat(e))}async lstatOrNull(e){return $r(this.#e.observer,"workspace.fs.lstatOrNull",{"workspace.fs.path":e},async()=>{try{return await this.#e.fs.lstat(e)}catch(t){if(t.code==="ENOENT")return null;throw t}})}readlink(e){return $r(this.#e.observer,"workspace.fs.readlink",{"workspace.fs.path":e},()=>this.#e.fs.readlink(e))}readdir(e,t={}){return $r(this.#e.observer,"workspace.fs.readdir",{"workspace.fs.path":e},()=>this.#e.fs.readdir(e,t),(r,n)=>{n.ok&&r.setAttribute("workspace.fs.entries",n.value.length)})}find(e,t,r={}){return $r(this.#e.observer,"workspace.fs.find",{"workspace.fs.path":e,"workspace.fs.pattern":t},()=>this.#e.fs.find(e,t,r),(n,i)=>{i.ok&&n.setAttribute("workspace.fs.matches",i.value.length)})}ls(e){return $r(this.#e.observer,"workspace.fs.ls",{"workspace.fs.path":e},()=>this.#e.fs.ls(e),(t,r)=>{r.ok&&t.setAttribute("workspace.fs.entries",r.value.length)})}grep(e,t,r={}){return $r(this.#e.observer,"workspace.fs.grep",{"workspace.fs.path":t,"workspace.fs.pattern":e},()=>this.#e.fs.grep(e,t,r),(n,i)=>{i.ok&&n.setAttribute("workspace.fs.matches",i.value.length)})}writeFile(e,t,r={}){return $r(this.#e.observer,"workspace.fs.writeFile",{"workspace.fs.path":e},()=>this.#e.fs.writeFile(e,t,r))}mkdir(e,t={}){return $r(this.#e.observer,"workspace.fs.mkdir",{"workspace.fs.path":e,"workspace.fs.recursive":t.recursive},()=>this.#e.fs.mkdir(e,t))}rm(e,t={}){return $r(this.#e.observer,"workspace.fs.rm",{"workspace.fs.path":e,"workspace.fs.recursive":t.recursive,"workspace.fs.force":t.force},()=>this.#e.fs.rm(e,t))}chmod(e,t){return $r(this.#e.observer,"workspace.fs.chmod",{"workspace.fs.path":e,"workspace.fs.mode":t},()=>this.#e.fs.chmod(e,t))}symlink(e,t){return $r(this.#e.observer,"workspace.fs.symlink",{"workspace.fs.path":t,"workspace.fs.target":e},()=>this.#e.fs.symlink(e,t))}},RI=class extends So{static{l(this,"WorkspaceRuntimeExecHandleStub")}#e;#r=!1;#n=!1;#t;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){if(this.#n)return;this.#n=!0;let e=this.#t;if(this.#t=void 0,e)e.cancel().catch(()=>{}).finally(()=>e.releaseLock());else{let t=this.#e.cancel;typeof t=="function"&&t.call(this.#e).catch(()=>{})}ka(this)}get id(){return this.#e.id}get backend(){return this.#e.backend}async result(){return this.#i(),this.#e.result()}stream(){this.#i();let e=this.#e.getReader();this.#t=e;let t=this;return new ReadableStream({async pull(r){try{let{value:n,done:i}=await e.read();if(i){e.releaseLock(),t.#t=void 0,r.close();return}r.enqueue(pQ(n))}catch(n){e.releaseLock(),t.#t=void 0,r.error(n)}},async cancel(r){try{await e.cancel(r)}finally{e.releaseLock(),t.#t=void 0}}},{highWaterMark:0})}#i(){if(this.#r)throw new Error("runtime handle already consumed: result() and stream() are single-shot");this.#r=!0}kill(e){return this.#e.kill(e)}},zQ=class extends So{static{l(this,"WorkspaceRuntimeStub")}#e;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){ka(this)}async exec(e,t={}){await this.#e.ready(t.backend);let r=await this.#e.runtime.exec(e,t);if(t.id!==void 0&&r.id!==t.id)throw new Error(`backend ran exec as ${r.id}, not the requested id ${t.id}`);return new RI(r)}async getExec(e,t={}){return await this.#e.ready(t.backend),new RI(await this.#e.runtime.getExec(e,t))}killExec(e,t={}){return this.#e.runtime.killExec(e,t)}disposeExec(e,t={}){return this.#e.runtime.disposeExec(e,t)}},BQ=class extends So{static{l(this,"WorkspaceAssetsStub")}#e;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){ka(this)}publish(e,t){return $r(this.#e.observer,"workspace.assets.publish",{"workspace.fs.path":e,"workspace.assets.expires_after_ms":t.expiresAfter},async()=>{if(this.#e.assets===void 0)throw new Error("Workspace assets are not configured");return this.#e.assets.share(e,{expiresAfter:t.expiresAfter})})}},WQ=class extends So{static{l(this,"WorkspaceArtifactsStub")}#e;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){ka(this)}create(e,t){return this.#e.create(e,t)}get(e){return this.#e.get(e)}list(){return this.#e.list()}import(e,t,r){return this.#e.import(e,t,r)}delete(e){return this.#e.delete(e)}createToken(e,t,r){return this.#e.createToken(e,t,r)}listTokens(e){return this.#e.listTokens(e)}getToken(e,t){return this.#e.getToken(e,t)}revokeToken(e,t){return this.#e.revokeToken(e,t)}cli(e){return this.#e.cli(e)}},qQ=class extends So{static{l(this,"WorkspaceGitStub")}#e;constructor(e){super(),this.#e=e,Sa(this)}[Symbol.dispose](){ka(this)}cli(e){return this.#e.git.cli(e)}},HQ=class extends So{static{l(this,"WorkspaceStub")}#e;#r;#n;#t;#i;#s;constructor(e){super(),this.#e=new jQ(e),this.#r=new zQ(e),this.#n=new qQ(e),this.#t=e.assets===void 0?void 0:new BQ(e),this.#i=new WQ(e.artifacts),this.#s=e.useThink,Sa(this)}[Symbol.dispose](){this.#e[Symbol.dispose](),this.#r[Symbol.dispose](),this.#n[Symbol.dispose](),this.#t?.[Symbol.dispose](),this.#i[Symbol.dispose](),ka(this)}get fs(){return this.#e}get useThink(){return this.#s}get runtime(){return this.#r}get git(){return this.#n}get assets(){return this.#t}get artifacts(){return this.#i}},GQ=1e3,VQ=6e4,ZQ=5,_$="Workspace git is not configured. Import createGitClient from @cloudflare/computer/git and pass createGitClient() as WorkspaceOptions.git.",PI=new Proxy({},{get(e,t){if(t!=="then")return()=>Promise.reject(new Error(_$))}}),T$=class{static{l(this,"Workspace")}#e;#r;#n;#t;#i;#s;#a;#u;#l;#o;#c;#x;#h;#C;#m;#g;#f;#E;#S;#O;#y;#p;#v;#k;#d=new Map;#A=new Map;#I=new Map;#$=new Map;#N=new Map;#_=new Map;#w=0;#P;#b;#M=new Map;constructor(e){this.#c=e.now??Date.now,this.#x=e.retryScheduler,this.#h=ky(e.retry?.initialDelayMs,GQ,"initialDelayMs"),this.#C=ky(e.retry?.maxDelayMs,VQ,"maxDelayMs"),this.#m=ky(e.retry?.maxAttempts,ZQ,"maxAttempts"),this.#g=e.sessionId??"",this.#f=e.git,this.#E=e.defaultGitIdentity,this.#S=e.useThink??!1,this.#y=e.artifacts?H8(e.artifacts.binding,e.artifacts.sessionId??e.sessionId??""):KQ(),this.#e=new QJ(e.storage),TX(this.#e,this.#c),this.#r=new NJ(this.#e,{now:this.#c});let t=(e.backends??[]).slice();this.#t=t.filter(r=>!TI(r)),this.#i=new Map(this.#t.map(r=>[r.id,r])),this.#s=new Map(t.filter(TI).map(r=>[r.id,r])),this.#a=new Set,this.#u=new Set(t.filter(r=>r.callable===!0).map(r=>r.id));for(let r of t){if(this.#a.has(r.id))throw new Error(`Workspace: duplicate backend id ${JSON.stringify(r.id)}. Pass an explicit \`id\` on each backend's constructor options to distinguish them.`);this.#a.add(r.id)}if(this.#l=t[0]?.id,this.#o=e.observer??I$,this.#v=NQ(e.mounts,{sessionId:e.sessionId,vfs:l(()=>this.provider(),"vfs")}),this.#k=new TQ({db:this.#e,fs:this.#r,mounts:this.#v}),this.#O=typeof e.assets=="function"?e.assets(this):e.assets,this.#S){let r=C$(this.fs);Object.assign(this,r)}}ensureMountsIndexed(){return this.#k.ensureIndexed()}mounts(){return new Map(this.#v)}get db(){return this.#e}get observer(){return this.#o}get fs(){return this.#r}get useThink(){return this.#S}get sessionId(){return this.#g}get assets(){return this.#O}get git(){if(!this.#f)throw new Error(_$);return this.#p||(this.#p=this.#f({ws:this,defaultIdentity:this.#E})),this.#p}get artifacts(){return this.#y}get runtime(){return this.#P||(this.#P=new K8({callableBackendIds:this.#u,backendHandle:l(e=>this.#W(e),"backendHandle"),resolveBackendId:l(e=>this.#D(e)??"","resolveBackendId")})),this.#P}provider(){return this.#n||(this.#n=new HJ(this.#e,{now:this.#c})),this.#n}ready(e){if(this.#b===void 0){let r=this.#k.ensureIndexed();this.#b=r,r.catch(()=>{this.#b===r&&(this.#b=void 0)})}let t=this.#b;if(e===void 0)return t;if(typeof e=="string"){let r=this.#D(e);return(async()=>{await t,r&&(this.#s.has(r)?await this.#L(r):await this.#T(r))})()}return e.all?(async()=>{await t,await Promise.all([...this.#t.map(r=>this.#T(r.id)),...[...this.#s.keys()].map(r=>this.#L(r))])})():t}stub(){return new HQ(this)}push(e){return this.#R(e,t=>$r(this.#o,"workspace.sync.push",{"workspace.sync.backend":t},async()=>{if(t===void 0||this.#s.has(t))return 0;let r=await this.#T(t);return r.sync==="none"?0:this.#z(t,r,()=>SQ(this.#e,r.rpc.sync,t))},(r,n)=>{n.ok&&r.setAttribute("workspace.sync.pushed",n.value)}))}pull(e){return this.#R(e,t=>this.#F(t))}retryPendingSync(e){return this.#R(e,async t=>{if(t===void 0)throw new Error("Workspace has no backend configured for pending sync retry");let r=this.#x;if(r===void 0)throw new Error("Workspace has no retryScheduler configured");let n=await r.get(t);if(n===void 0)return{status:"idle",backend:t};if(n.attempt>this.#m)return{status:"exhausted",backend:t,attempt:n.attempt,error:"pending sync retry attempts exhausted"};try{let i=await this.#F(t);return await r.clear(t),{status:"complete",backend:t,applied:i.applied,skipped:i.skipped}}catch(i){let s=Nu(i);if(n.attempt>=this.#m)return{status:"exhausted",backend:t,attempt:n.attempt,error:s};let o=this.#U(t,n.attempt+1);return await r.schedule(o),{status:"pending",...o,error:s}}})}#F(e){return $r(this.#o,"workspace.sync.pull",{"workspace.sync.backend":e},async()=>{if(e===void 0||this.#s.has(e))return{applied:0,skipped:[]};let t=await this.#T(e);return t.sync==="none"?{applied:0,skipped:[]}:this.#z(e,t,()=>xQ(this.#e,t.rpc.sync,e))},(t,r)=>{r.ok&&(t.setAttribute("workspace.sync.applied",r.value.applied),t.setAttribute("workspace.sync.skipped",r.value.skipped.length))})}async#B(e){let t=this.#x;t!==void 0&&await this.#R(e,async r=>{r===void 0||await t.get(r)!==void 0||await t.schedule(this.#U(r,1))})}#U(e,t){let r=Math.min(this.#C,this.#h*2**Math.max(0,t-1));return{backend:e,attempt:t,notBefore:this.#c()+r}}#j(e,t){return this.#d.get(e)!==t?!1:(this.#d.delete(e),this.#I.delete(e),this.#$.delete(e),!0)}async#z(e,t,r){try{return await r()}catch(n){throw fy(n)&&this.#j(e,t),n}}#R(e,t){let r=this.#D(e),n=r??"",i=(this.#M.get(n)??Promise.resolve()).then(()=>t(r),()=>t(r));return this.#M.set(n,i.then(()=>{},()=>{})),i}#D(e){if(this.#a.size===0)return;let t=e??this.#l;if(t!==void 0){if(!this.#a.has(t))throw new Error(`Workspace: no backend with id ${JSON.stringify(t)}. Configured backends: ${[...this.#a].map(r=>JSON.stringify(r)).join(", ")||"<none>"}.`);return t}}async close(){this.#w+=1;let e=[...this.#d.values()],t=[...this.#N.values()];this.#d.clear(),this.#I.clear(),this.#$.clear(),this.#A.clear(),this.#N.clear(),this.#_.clear(),this.#b=void 0,await Promise.all([...e,...t].map(async r=>{try{await r.close?.()}catch{}}))}async#W(e){return this.#s.has(e)?this.#L(e):this.#q(e)}async#q(e){let t=this.#$.get(e);if(t)return t;let{shell:r,handle:n}=await this.#H(e),i=l(o=>this.#G(e,n,o),"onError"),s={exec:l(async o=>{let a;try{a=await r.exec(o.source,{id:o.id,cwd:o.cwd,timeoutMs:o.timeoutMs,env:o.env,stdin:o.stdin})}catch(c){throw i(c),c}return{id:a.id,events:DI(a.events,i),sync:a.sync}},"exec"),getExec:l(async({id:o,after:a})=>{let c=a===void 0?"full":a,u;try{u=await r.get(o,{resume:c})}catch(d){throw i(d),d}return{id:u.id,events:DI(u.events,i),sync:u.sync}},"getExec"),killExec:l(async({id:o,signal:a})=>{try{await r.kill(o,a)}catch(c){throw i(c),c}},"killExec"),disposeExec:l(async({id:o})=>{try{await r.dispose(o)}catch(a){throw i(a),a}},"disposeExec")};return this.#$.set(e,s),s}#L(e){let t=this.#N.get(e);if(t)return Promise.resolve(t);let r=this.#_.get(e);if(r)return r;let n=this.#s.get(e);if(!n)return Promise.reject(new Error(`Workspace backend ${JSON.stringify(e)} does not execute modules.`));let i=this.#w,s;return s=$r(this.#o,"workspace.connect",{"workspace.backend.id":e,"workspace.backend.type":n.type},()=>n.connect({db:this.#e,fs:this.#r,git:this.#f?this.git:PI,artifacts:this.#y})).then(async o=>{if(i!==this.#w)throw await o.close?.().catch(()=>{}),new Error(`Workspace closed while backend ${JSON.stringify(e)} was connecting.`);return this.#N.set(e,o),o}).finally(()=>{this.#_.get(e)===s&&this.#_.delete(e)}),this.#_.set(e,s),s}#T(e){let t=this.#d.get(e);if(t!==void 0)return Promise.resolve(t);let r=this.#A.get(e);if(r!==void 0)return r;let n=this.#i.get(e);if(n===void 0)return Promise.reject(new Error(`Workspace: no backend with id ${JSON.stringify(e)}`));let i=this.#w,s;return s=(async()=>{let o=await $r(this.#o,"workspace.connect",{"workspace.backend.id":e,"workspace.backend.type":n.type},()=>n.connect({db:this.#e,fs:this.#r,git:this.#f?this.git:PI,artifacts:this.#y}));if(i!==this.#w)throw await o.close().catch(()=>{}),new Error(`Workspace closed while backend ${JSON.stringify(e)} was connecting.`);if(o.sync!=="none"&&await kQ(this.#e,o.rpc.sync,e),i!==this.#w)throw await o.close().catch(()=>{}),new Error(`Workspace closed while backend ${JSON.stringify(e)} was connecting.`);return this.#d.set(e,o),o.closed&&o.closed.catch(()=>{}).then(()=>{this.#d.get(e)===o&&(this.#d.delete(e),this.#I.delete(e),this.#$.delete(e))}),o})().finally(()=>{this.#A.get(e)===s&&this.#A.delete(e)}),this.#A.set(e,s),s}async#H(e){let t=await this.#T(e),r=this.#I.get(e);if(r!==void 0)return{shell:r,handle:t};let n=new LQ(t.rpc.shell,{push:l(()=>this.push(e),"push"),pull:l(()=>this.pull(e),"pull"),onPullPending:l(()=>this.#B(e),"onPullPending")},this.#o);return this.#I.set(e,n),{shell:n,handle:t}}#G(e,t,r){fy(r)&&this.#j(e,t)}};function DI(e,t){let r=e.getReader();return new ReadableStream({async pull(n){try{let{value:i,done:s}=await r.read();if(s){n.close();return}n.enqueue(i)}catch(i){t(i),n.error(i)}},async cancel(n){await r.cancel(n)}})}l(DI,"watchStreamForTransportError");function ky(e,t,r){let n=e??t;if(!Number.isSafeInteger(n)||n<=0)throw new Error(`Workspace retry.${r} must be a positive integer`);return n}l(ky,"positiveRetryOption");function KQ(){let e=l(()=>{throw new ha("ENOCONFIG","Workspace Artifacts binding is not configured")},"fail");return{sessionId:"",create:e,get:e,list:e,import:e,delete:e,createToken:e,listTokens:e,getToken:e,revokeToken:e,async cli(t){return dy(this,t)}}}l(KQ,"createDisabledArtifactsClient");function C$(e){return{async readFile(t){try{return await e.readFile(t,"utf8")}catch(r){if(Iy(r))return null;throw r}},async readFileBytes(t){try{return await YQ(await e.readFile(t))}catch(r){if(Iy(r))return null;throw r}},async writeFile(t,r){await e.writeFile(t,r)},async readDir(t,r){let n=await e.readdir(t),i=r?.offset??0,s=r?.limit??n.length;return n.slice(i,i+s).map(o=>Ay({path:QQ(t,o.name),name:o.name,size:0,mtime:0,isDirectory:o.isDirectory,isFile:o.isFile}))},async rm(t,r){await e.rm(t,r)},async glob(t){let{directory:r,relativePattern:n}=XQ(t);return(await e.find(r,n)).map(i=>Ay({path:i.path,name:Dy(i.path),size:0,mtime:0,isDirectory:i.type==="dir",isFile:i.type==="file"}))},async mkdir(t,r){await e.mkdir(t,r)},async stat(t){try{return Ay({...await e.stat(t),path:t,name:Dy(t)})}catch(r){if(Iy(r))return null;throw r}}}}l(C$,"createThinkCompatibility");async function YQ(e){let t=e.getReader(),r=[],n=0;try{for(;;){let{value:o,done:a}=await t.read();if(a)break;o&&(r.push(o),n+=o.byteLength)}}finally{t.releaseLock()}if(r.length===1)return r[0];let i=new Uint8Array(n),s=0;for(let o of r)i.set(o,s),s+=o.byteLength;return i}l(YQ,"drainBytes");function Ay(e){let t=e.isDirectory?"directory":"file";return{path:e.path,name:e.name,type:t,mimeType:t==="directory"?"inode/directory":"application/octet-stream",size:e.size,createdAt:e.mtime,updatedAt:e.mtime}}l(Ay,"toThinkFileInfo");function XQ(e){let t=e.startsWith("/")?e:`/workspace/${e}`,r=JQ(t);if(r===-1)return{directory:eee(t),relativePattern:Dy(t)};let n=t.lastIndexOf("/",r);return{directory:n<=0?"/":t.slice(0,n),relativePattern:t.slice(n+1)}}l(XQ,"splitGlobPattern");function JQ(e){let t=e.indexOf("*"),r=e.indexOf("?");return t===-1?r:r===-1?t:Math.min(t,r)}l(JQ,"firstWildcardIndex");function QQ(e,t){return e==="/"?`/${t}`:`${e}/${t}`}l(QQ,"joinPath");function eee(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}l(eee,"dirname");function Dy(e){let t=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e,r=t.lastIndexOf("/");return r===-1?t:t.slice(r+1)}l(Dy,"basename");function Iy(e){if(!e||typeof e!="object")return!1;let t=e;return t.code==="ENOENT"?!0:typeof t.message=="string"&&/ENOENT|no such/i.test(t.message)}l(Iy,"isEnoent");var Ly=Symbol("workspace");function O$(e,t){class r extends e{static{l(this,"WithWorkspace")}constructor(...i){super(...i);let s=this;this[Ly]=new T$(t(s))}__getWorkspaceStub(){let i=this[Ly];return(async()=>(await i.ready(),i.stub()))()}}return r}l(O$,"withWorkspace");async function tee(e,t={}){let[r,n]=await Promise.all([t.id??e.id,t.backend??e.backend]),i,s,o,a=new ReadableStream({pull:l(async f=>{if(i==="result"){f.error(new Error("exec handle already consumed by result(): result() and streaming are exclusive"));return}o===void 0&&(i="stream",o=hQ(await e.stream()).getReader());try{let p=o;if(!p)throw new Error("runtime stream reader was not initialized");let{value:h,done:m}=await p.read();if(m){p.releaseLock(),o=void 0,f.close();return}f.enqueue(h)}catch(p){o?.releaseLock(),o=void 0,f.error(p)}},"pull"),cancel:l(async f=>{let p=o;if(o=void 0,!p){u();return}try{await p.cancel(f)}finally{p.releaseLock(),u()}},"cancel")},{highWaterMark:0}),c=!1,u=l(()=>{if(c)return;c=!0;let f=o;o=void 0,f&&f.cancel().catch(()=>{}).finally(()=>f.releaseLock()),e[Symbol.dispose]?.()},"dispose"),d=a;return Object.defineProperties(d,{id:{value:r,enumerable:!1},backend:{value:n,enumerable:!1},result:{value:l(()=>{if(i==="stream")throw new Error("exec handle already streaming: call result() or iterate the stream, not both");return i="result",s??=e.result(),s},"value"),enumerable:!1},kill:{value:l(f=>e.kill(f),"value"),enumerable:!1},[Symbol.dispose]:{value:u,enumerable:!1}}),d}l(tee,"rebuildExecHandle");function ree(e){return Array.isArray(e)}l(ree,"isTemplateStringsArray");function nee(e,t){async function r(o,a,...c){if(ree(o)){let p=vQ(o,...a===void 0?c:[a,...c]),h=crypto.randomUUID();return t(await e.exec(p,{id:h,encoding:"utf8"}),{id:h})}let u=iee(a),d=await e.exec(o,u),f={id:u.id,backend:u.backend};return u.encoding==="utf8",t(d,f)}return l(r,"exec"),{exec:r,getExec:l(async(o,a)=>{let c=await e.getExec(o,a),u={id:o,backend:a?.backend};return a?.encoding==="utf8",t(c,u)},"getExec"),killExec:l((o,a)=>e.killExec(o,a),"killExec"),disposeExec:l((o,a)=>e.disposeExec(o,a),"disposeExec")}}l(nee,"makeRuntimeClient");function iee(e){return{...e,id:e?.id??crypto.randomUUID()}}l(iee,"withExecutionId");function LI(e,t,r,n){let i={get fs(){return e.fs},runtime:nee(e.runtime,t),get git(){return e.git},get assets(){return e.assets},get artifacts(){return e.artifacts},[Symbol.dispose]:r};return n&&Object.assign(i,C$(i.fs)),i}l(LI,"makeClient");async function Rp(e){let t=e[Ly];if(t instanceof T$)return await t.ready(),LI({fs:t.fs,runtime:t.runtime,get git(){return t.git},artifacts:t.artifacts,assets:t.assets},n=>n,()=>{},t.useThink);let r=await e.__getWorkspaceStub();try{return LI(r,(n,i)=>tee(n,i),()=>{r[Symbol.dispose]?.()},await r.useThink)}catch(n){throw r[Symbol.dispose]?.(),n}}l(Rp,"getWorkspace");var O7e=new TextEncoder;var see=class extends UI{static{l(this,"WorkspaceProxy")}async fetch(e){let t=new URL(e.url);if(this.ctx.props.egressToken!==void 0){let n=new Headers(e.headers);n.set(Y8,this.ctx.props.egressToken),n.set(X8,e.url),t.pathname="/ws",t.search="";let i=this.#e();return i===void 0?this.#r():i.fetch(new Request(t,new Request(e,{headers:n})))}let r=t.pathname.match(/^\/__workspace_connect\/([0-9a-f-]{36})\/(health|ws)$/);if(r?.[2]==="health")return new Response(`ok
|
|
296
296
|
`,{headers:{"content-type":"text/plain; charset=utf-8"}});if(t.pathname==="/health")return new Response(`ok
|
|
297
297
|
`,{headers:{"content-type":"text/plain; charset=utf-8"}});if(t.pathname==="/ws"||r?.[2]==="ws"){r?.[1]&&(t.pathname="/ws",t.searchParams.set("token",r[1]),e=new Request(t,e));let n=this.#e();return n===void 0?this.#r():n.fetch(e)}return new Response("not found",{status:404})}#e(){let{binding:e,id:t}=this.ctx.props,r=this.env[e];return r?.get(r.idFromString(t))}#r(){return new Response(`WorkspaceProxy: env.${this.ctx.props.binding} is not a DurableObjectNamespace`,{status:500})}},MI=class extends vX{static{l(this,"ArtifactsCLITarget")}#e;constructor(e){super(),this.#e=e}cli(e){return this.#e(e)}},oee=class extends UI{static{l(this,"WorkspaceServiceProxy")}async getWorkspace(){return this.#e().__getWorkspaceStub()}async getArtifacts(){let e=this.#e();return typeof e.getArtifacts=="function"?e.getArtifacts():typeof e.artifactsCLI=="function"?new MI(t=>e.artifactsCLI?.(t)):new MI(async()=>({stdout:"",stderr:`artifacts: host does not expose an Artifacts CLI
|
|
298
|
-
`,exitCode:1}))}async artifactsCLI(e){return(await this.getArtifacts()).cli(e)}#e(){let{binding:e,id:t}=this.ctx.props,r=this.env[e];if(!r)throw new Error(`WorkspaceServiceProxy: env.${e} is not a DurableObjectNamespace`);return r.get(r.idFromString(t))}};function Ar(e){return e==null}l(Ar,"isNullable");function R$(e){return!Ar(e)}l(R$,"isNonNullable");function Dp(e){return e&&typeof e=="object"&&!Array.isArray(e)}l(Dp,"isPlainObject");function P$(e,t){return Object.fromEntries(Object.entries(e).filter(([r,n])=>t(r,n)))}l(P$,"filterKeys");function qi(e,t){return Object.fromEntries(Object.entries(e).map(([r,n])=>[r,t(n,r)]))}l(qi,"mapValues");function D$(e,t,r){if(!t)return{...e};let n={};for(let i of t)(r||e[i]!==void 0)&&(n[i]=e[i]);return n}l(D$,"pick");function yi(e,t,r){return Object.defineProperty(e,t,{writable:!0,value:r,enumerable:!1})}l(yi,"defineProperty");function Aa(e,t){return arguments.length===1?r=>Aa(e,r):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}l(Aa,"is");function Lp(e){return Aa("ArrayBuffer",e)||Aa("SharedArrayBuffer",e)}l(Lp,"isArrayBufferLike");function aee(e){return Lp(e)||ArrayBuffer.isView(e)}l(aee,"isArrayBufferSource");var Wi;(function(e){e.is=Lp,e.isSource=aee;function t(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}l(t,"fromSource"),e.fromSource=t;function r(o){if(o=t(o),typeof Buffer<"u")return Buffer.from(o).toString("base64");let a="",c=new Uint8Array(o);for(let u=0;u<c.byteLength;u++)a+=String.fromCharCode(c[u]);return btoa(a)}l(r,"toBase64"),e.toBase64=r;function n(o){return typeof Buffer<"u"?t(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}l(n,"fromBase64"),e.fromBase64=n;function i(o){return o=t(o),typeof Buffer<"u"?Buffer.from(o).toString("hex"):Array.from(new Uint8Array(o),a=>a.toString(16).padStart(2,"0")).join("")}l(i,"toHex"),e.toHex=i;function s(o){if(typeof Buffer<"u")return t(Buffer.from(o,"hex"));let a=o.length%2===0?o:o.slice(0,o.length-1),c=[];for(let u=0;u<a.length;u+=2)c.push(parseInt(`${a[u]}${a[u+1]}`,16));return Uint8Array.from(c).buffer}l(s,"fromHex"),e.fromHex=s})(Wi||(Wi={}));var
|
|
298
|
+
`,exitCode:1}))}async artifactsCLI(e){return(await this.getArtifacts()).cli(e)}#e(){let{binding:e,id:t}=this.ctx.props,r=this.env[e];if(!r)throw new Error(`WorkspaceServiceProxy: env.${e} is not a DurableObjectNamespace`);return r.get(r.idFromString(t))}};function Ar(e){return e==null}l(Ar,"isNullable");function R$(e){return!Ar(e)}l(R$,"isNonNullable");function Dp(e){return e&&typeof e=="object"&&!Array.isArray(e)}l(Dp,"isPlainObject");function P$(e,t){return Object.fromEntries(Object.entries(e).filter(([r,n])=>t(r,n)))}l(P$,"filterKeys");function qi(e,t){return Object.fromEntries(Object.entries(e).map(([r,n])=>[r,t(n,r)]))}l(qi,"mapValues");function D$(e,t,r){if(!t)return{...e};let n={};for(let i of t)(r||e[i]!==void 0)&&(n[i]=e[i]);return n}l(D$,"pick");function yi(e,t,r){return Object.defineProperty(e,t,{writable:!0,value:r,enumerable:!1})}l(yi,"defineProperty");function Aa(e,t){return arguments.length===1?r=>Aa(e,r):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}l(Aa,"is");function Lp(e){return Aa("ArrayBuffer",e)||Aa("SharedArrayBuffer",e)}l(Lp,"isArrayBufferLike");function aee(e){return Lp(e)||ArrayBuffer.isView(e)}l(aee,"isArrayBufferSource");var Wi;(function(e){e.is=Lp,e.isSource=aee;function t(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}l(t,"fromSource"),e.fromSource=t;function r(o){if(o=t(o),typeof Buffer<"u")return Buffer.from(o).toString("base64");let a="",c=new Uint8Array(o);for(let u=0;u<c.byteLength;u++)a+=String.fromCharCode(c[u]);return btoa(a)}l(r,"toBase64"),e.toBase64=r;function n(o){return typeof Buffer<"u"?t(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}l(n,"fromBase64"),e.fromBase64=n;function i(o){return o=t(o),typeof Buffer<"u"?Buffer.from(o).toString("hex"):Array.from(new Uint8Array(o),a=>a.toString(16).padStart(2,"0")).join("")}l(i,"toHex"),e.toHex=i;function s(o){if(typeof Buffer<"u")return t(Buffer.from(o,"hex"));let a=o.length%2===0?o:o.slice(0,o.length-1),c=[];for(let u=0;u<a.length;u+=2)c.push(parseInt(`${a[u]}${a[u+1]}`,16));return Uint8Array.from(c).buffer}l(s,"fromHex"),e.fromHex=s})(Wi||(Wi={}));var Y7e=Wi.fromBase64,X7e=Wi.toBase64,J7e=Wi.fromHex,Q7e=Wi.toHex;function Pp(e,t=new Map){if(!e||typeof e!="object")return e;if(Aa("Date",e))return new Date(e.valueOf());if(Aa("RegExp",e))return new RegExp(e.source,e.flags);if(Lp(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let r=t.get(e);if(r)return r;if(Array.isArray(e)){let i=[];return t.set(e,i),e.forEach((s,o)=>{i[o]=Reflect.apply(Pp,null,[s,t])}),i}let n=Object.create(Object.getPrototypeOf(e));t.set(e,n);for(let i of Reflect.ownKeys(e)){let s={...Reflect.getOwnPropertyDescriptor(e,i)};"value"in s&&(s.value=Reflect.apply(Pp,null,[s.value,t])),Reflect.defineProperty(n,i,s)}return n}l(Pp,"clone");function Ao(e,t,r){if(e===t||!r&&Ar(e)&&Ar(t))return!0;if(typeof e!=typeof t||typeof e!="object"||!e||!t)return!1;function n(i,s){return i(e)?i(t)?s(e,t):!1:i(t)?!1:void 0}return l(n,"check"),n(Array.isArray,(i,s)=>i.length===s.length&&i.every((o,a)=>Ao(o,s[a])))??n(Aa("Date"),(i,s)=>i.valueOf()===s.valueOf())??n(Aa("RegExp"),(i,s)=>i.source===s.source&&i.flags===s.flags)??n(Lp,(i,s)=>{if(i.byteLength!==s.byteLength)return!1;let o=new Uint8Array(i),a=new Uint8Array(s);for(let c=0;c<o.length;c++)if(o[c]!==a[c])return!1;return!0})??Object.keys({...e,...t}).every(i=>Ao(e[i],t[i],r))}l(Ao,"deepEqual");function lee(e,t,r){let n=[],i=0;for(let s=0;s<e.length;s++){let o=e.charCodeAt(s);if(o>=65&&o<=90){if(i===1){let a=e.charCodeAt(s+1);a>=97&&a<=122&&n.push(r),n.push(o+32)}else i!==0&&n.push(r),n.push(o+32);i=1}else o>=97&&o<=122?(n.push(o),i=2):t.includes(o)?(i!==0&&n.push(r),i=0):n.push(o)}return String.fromCharCode(...n)}l(lee,"tokenize");function cee(e){return lee(e,[45,95],45)}l(cee,"paramCase");var L$=cee;var N$;(function(e){e.millisecond=1,e.second=1e3,e.minute=e.second*60,e.hour=e.minute*60,e.day=e.hour*24,e.week=e.day*7;let t=new Date().getTimezoneOffset();function r(h){t=h}l(r,"setTimezoneOffset"),e.setTimezoneOffset=r;function n(){return t}l(n,"getTimezoneOffset"),e.getTimezoneOffset=n;function i(h=new Date,m){return typeof h=="number"&&(h=new Date(h)),m===void 0&&(m=t),Math.floor((h.valueOf()/e.minute-m)/1440)}l(i,"getDateNumber"),e.getDateNumber=i;function s(h,m){let g=new Date(h*e.day);return m===void 0&&(m=t),new Date(+g+m*e.minute)}l(s,"fromDateNumber"),e.fromDateNumber=s;let o=/\d+(?:\.\d+)?/.source,a=new RegExp(`^${["w(?:eek(?:s)?)?","d(?:ay(?:s)?)?","h(?:our(?:s)?)?","m(?:in(?:ute)?(?:s)?)?","s(?:ec(?:ond)?(?:s)?)?"].map(h=>`(${o}${h})?`).join("")}$`);function c(h){let m=a.exec(h);return m?(parseFloat(m[1])*e.week||0)+(parseFloat(m[2])*e.day||0)+(parseFloat(m[3])*e.hour||0)+(parseFloat(m[4])*e.minute||0)+(parseFloat(m[5])*e.second||0):0}l(c,"parseTime"),e.parseTime=c;function u(h){let m=c(h);return m?h=Date.now()+m:/^\d{1,2}(:\d{1,2}){1,2}$/.test(h)?h=`${new Date().toLocaleDateString()}-${h}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(h)&&(h=`${new Date().getFullYear()}-${h}`),h?new Date(h):new Date}l(u,"parseDate"),e.parseDate=u;function d(h){let m=Math.abs(h);return m>=e.day-e.hour/2?Math.round(h/e.day)+"d":m>=e.hour-e.minute/2?Math.round(h/e.hour)+"h":m>=e.minute-e.second/2?Math.round(h/e.minute)+"m":m>=e.second?Math.round(h/e.second)+"s":h+"ms"}l(d,"format"),e.format=d;function f(h,m=2){return h.toString().padStart(m,"0")}l(f,"toDigits"),e.toDigits=f;function p(h,m=new Date){return h.replace("yyyy",m.getFullYear().toString()).replace("yy",m.getFullYear().toString().slice(2)).replace("MM",f(m.getMonth()+1)).replace("dd",f(m.getDate())).replace("hh",f(m.getHours())).replace("mm",f(m.getMinutes())).replace("ss",f(m.getSeconds())).replace("SSS",f(m.getMilliseconds(),3))}l(p,"template"),e.template=p})(N$||(N$={}));var sv=class{static{l(this,"DisposableList")}sn=0;map=new Map;weak=new WeakMap;get length(){return this.map.size}push(e){let t=++this.sn;return this.map.set(t,e),this.weak.set(e,t),()=>this.map.delete(t)}delete(e){let t=this.weak.get(e);return t?this.map.delete(t):!1}clear(){let e=[...this.map.values()];return this.map.clear(),e.reverse()}[Symbol.iterator](){return this.map.values()}[Symbol.for("nodejs.util.inspect.custom")](){return[...this]}},Xe={shadow:Symbol.for("cordis.shadow"),receiver:Symbol.for("cordis.receiver"),original:Symbol.for("cordis.original"),metadata:Symbol.for("cordis.metadata"),initHooks:Symbol.for("cordis.initHooks"),checkProto:Symbol.for("cordis.checkProto"),effect:Symbol.for("cordis.effect"),filter:Symbol.for("cordis.filter"),isolate:Symbol.for("cordis.isolate"),intercept:Symbol.for("cordis.intercept"),init:Symbol.for("cordis.init"),check:Symbol.for("cordis.check"),config:Symbol.for("cordis.config"),invoke:Symbol.for("cordis.invoke"),extend:Symbol.for("cordis.extend"),tracker:Symbol.for("cordis.tracker"),resolveConfig:Symbol.for("cordis.resolveConfig")},uee=function*(){}.constructor,M$=async function*(){}.constructor;function dee(e){return!(!e.prototype||e instanceof uee||M$!==Function&&e instanceof M$)}l(dee,"isConstructor");function ov(e,t){if(e===Object.prototype)return t;let r=Object.create(ov(Object.getPrototypeOf(e),t));for(let n of Reflect.ownKeys(e))Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(e,n));return r}l(ov,"joinPrototype");function Cl(e){return e&&(typeof e=="object"||typeof e=="function")}l(Cl,"isObject");function fee(e,t){let r=e;for(;r;){let n=Reflect.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}l(fee,"getPropertyDescriptor");function ys(e,t){if(!Cl(t))return t;if(Object.hasOwn(t,Xe.shadow))return Object.getPrototypeOf(t);let r=t[Xe.tracker];return r?av(e,t,r):t}l(ys,"getTraceable");function Mp(e,t){return t?new Proxy(e,{get:l((r,n,i)=>n in t&&n!=="constructor"?Reflect.get(t,n,i):Reflect.get(r,n,i),"get"),set:l((r,n,i,s)=>n in t&&n!=="constructor"?Reflect.set(t,n,i,s):Reflect.set(r,n,i,s),"set")}):e}l(Mp,"withProps");function rv(e,t,r){return Mp(e,Object.defineProperty(Object.create(null),t,{value:r,writable:!1}))}l(rv,"withProp");function Jy(e,t,r,n){if(!r)return n;let i=Reflect.getOwnPropertyDescriptor(t,r)?.value;return i?rv(n,r,e.extend({[Xe.shadow]:i})):n}l(Jy,"createShadow");function pee(e,t,r,n){return new Proxy(t,{apply:l((i,s,o)=>(s===r&&(s=n),ys(e,Reflect.apply(i,s,o))),"apply")})}l(pee,"createShadowMethod");function av(e,t,r){e[Xe.shadow]&&!r.noShadow&&(e=Object.getPrototypeOf(e));let n=new Proxy(t,{get:l((i,s,o)=>{if(s===Xe.original)return i;if(s===r.property)return e;if(typeof s=="symbol")return Reflect.get(i,s,o);if(r.associate&&e.reflect.props[`${r.associate}.${s}`])return Reflect.get(e,`${r.associate}.${s}`,rv(e,Xe.receiver,o));let a,c,u=fee(i,s);u&&"value"in u?c=u.value:(a=Jy(e,i,r.property,o),c=Reflect.get(i,s,a));let d=c?.[Xe.tracker];return d?av(e,c,d):!r.noShadow&&typeof c=="function"?(a??=Jy(e,i,r.property,o),pee(e,c,o,a)):c},"get"),set:l((i,s,o,a)=>{if(s===Xe.original||s===r.property)return!1;if(typeof s=="symbol")return Reflect.set(i,s,o,a);if(r.associate&&e.reflect.props[`${r.associate}.${s}`])return Reflect.set(e,`${r.associate}.${s}`,o,rv(e,Xe.receiver,a));let c=Jy(e,i,r.property,a);return Reflect.set(i,s,o,c)},"set"),apply:l((i,s,o)=>B$(n,i,s,o),"apply")});return n}l(av,"createTraceable");function B$(e,t,r,n){return t[Xe.invoke]?t[Xe.invoke].apply(e,n):Reflect.apply(t,r,n)}l(B$,"applyTraceable");function nv(e,t,r){let n=l(function(...i){return B$(av(n.ctx,n,r),n,this,i)},"self");return yi(n,"name",e),Object.setPrototypeOf(n,t)}l(nv,"createCallable");function F$(e,t,r){let n=e.error.stack.split(`
|
|
299
299
|
`);if(typeof t?.stack!="string"){let o=new Error(t),a=o.stack.split(`
|
|
300
300
|
`);throw a.splice(1,1/0,...r()),o.stack=a.join(`
|
|
301
301
|
`),o}let i=t.stack.split(`
|
|
@@ -425,12 +425,12 @@ tools: Tools`}
|
|
|
425
425
|
|
|
426
426
|
`)}h.write("payload.value = newResult;"),h.write("return payload;");let w=h.compile();return(b,k)=>w(p,b,k)},"generateFastpass"),s,o=Ca,a=!Ta.jitless,u=a&&Xv.value,d=t.catchall,f;e._zod.parse=(p,h)=>{f??(f=n.value);let m=p.value;return o(m)?a&&u&&h?.async===!1&&h.jitless!==!0?(s||(s=i(t.shape)),p=s(p,h),d?$T([],m,p,h,f,e):p):r(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p)}});function dT(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let i=e.filter(s=>!Mo(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(o=>$n(o,n,_r())))}),t)}l(dT,"handleUnionResults");var dd=se("$ZodUnion",(e,t)=>{vt.init(e,t),It(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),It(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),It(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),It(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){let n=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${n.map(i=>ed(i.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},i);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}return s?Promise.all(o).then(a=>dT(a,n,e,i)):dT(o,n,e,i)}});function fT(e,t,r,n){let i=e.filter(s=>s.issues.length===0);return i.length===1?(t.value=i[0].value,t):(i.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(o=>$n(o,n,_r())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}l(fT,"handleExclusiveUnionResults");var zb=se("$ZodXor",(e,t)=>{dd.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,i)=>{if(r)return r(n,i);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},i);c instanceof Promise?(o.push(c),s=!0):o.push(c)}return s?Promise.all(o).then(a=>fT(a,n,e,i)):fT(o,n,e,i)}}),Bb=se("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,dd.init(e,t);let r=e._zod.parse;It(e._zod,"propValues",()=>{let i={};for(let s of t.options){let o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[a,c]of Object.entries(o)){i[a]||(i[a]=new Set);for(let u of c)i[a].add(u)}}return i});let n=Bl(()=>{let i=t.options,s=new Map;for(let o of i){let a=o._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,o)}}return s});e._zod.parse=(i,s)=>{let o=i.value;if(!Ca(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),i;let a=n.value.get(o?.[t.discriminator]);return a?a._zod.run(i,s):t.unionFallback||s.direction==="backward"?r(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Wb=se("$ZodIntersection",(e,t)=>{vt.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,s=t.left._zod.run({value:i,issues:[]},n),o=t.right._zod.run({value:i,issues:[]},n);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>pT(r,c,u)):pT(r,s,o)}});function rb(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Lo(e)&&Lo(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),i={...e,...t};for(let s of n){let o=rb(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],s=t[n],o=rb(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}l(rb,"mergeValues");function pT(e,t,r){let n=new Map,i;for(let a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(a);let s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&e.issues.push({...i,keys:s}),Mo(e))return e;let o=rb(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}l(pT,"handleIntersectionResults");var Ah=se("$ZodTuple",(e,t)=>{vt.init(e,t);let r=t.items;e._zod.parse=(n,i)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let o=[],a=hT(r,"optin"),c=hT(r,"optout");if(!t.rest){if(s.length<a)return n.issues.push({code:"too_small",minimum:a,inclusive:!0,input:s,inst:e,origin:"array"}),n;s.length>r.length&&n.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:s,inst:e,origin:"array"})}let u=new Array(r.length);for(let d=0;d<r.length;d++){let f=r[d]._zod.run({value:s[d],issues:[]},i);f instanceof Promise?o.push(f.then(p=>{u[d]=p})):u[d]=f}if(t.rest){let d=r.length-1,f=s.slice(r.length);for(let p of f){d++;let h=t.rest._zod.run({value:p,issues:[]},i);h instanceof Promise?o.push(h.then(m=>mT(m,n,d))):mT(h,n,d)}}return o.length?Promise.all(o).then(()=>gT(u,n,r,s,c)):gT(u,n,r,s,c)}});function hT(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}l(hT,"getTupleOptStart");function mT(e,t,r){e.issues.length&&t.issues.push(...zn(r,e.issues)),t.value[r]=e.value}l(mT,"handleTupleResult");function gT(e,t,r,n,i){for(let s=0;s<r.length;s++){let o=e[s],a=s<n.length;if(o.issues.length){if(!a&&s>=i){t.value.length=s;break}t.issues.push(...zn(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=n.length&&(r[s]._zod.optout==="optional"&&t.value[s]===void 0);s--)t.value.length=s;return t}l(gT,"handleTupleResults");var qb=se("$ZodRecord",(e,t)=>{vt.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Lo(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],o=t.keyType._zod.values;if(o){r.value={};let a=new Set;for(let u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let d=t.keyType._zod.run({value:u,issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>$n(h,n,_r())),input:u,path:[u],inst:e});continue}let f=d.value,p=t.valueType._zod.run({value:i[u],issues:[]},n);p instanceof Promise?s.push(p.then(h=>{h.issues.length&&r.issues.push(...zn(u,h.issues)),r.value[f]=h.value})):(p.issues.length&&r.issues.push(...zn(u,p.issues)),r.value[f]=p.value)}let c;for(let u in i)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(i)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&gh.test(a)&&c.issues.length){let f=t.keyType._zod.run({value:Number(a),issues:[]},n);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){t.mode==="loose"?r.value[a]=i[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>$n(f,n,_r())),input:a,path:[a],inst:e});continue}let d=t.valueType._zod.run({value:i[a],issues:[]},n);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&r.issues.push(...zn(a,f.issues)),r.value[c.value]=f.value})):(d.issues.length&&r.issues.push(...zn(a,d.issues)),r.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>r):r}}),Hb=se("$ZodMap",(e,t)=>{vt.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),r;let s=[];r.value=new Map;for(let[o,a]of i){let c=t.keyType._zod.run({value:o,issues:[]},n),u=t.valueType._zod.run({value:a,issues:[]},n);c instanceof Promise||u instanceof Promise?s.push(Promise.all([c,u]).then(([d,f])=>{yT(d,f,r,o,i,e,n)})):yT(c,u,r,o,i,e,n)}return s.length?Promise.all(s).then(()=>r):r}});function yT(e,t,r,n,i,s,o){e.issues.length&&(td.has(typeof n)?r.issues.push(...zn(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:i,inst:s,issues:e.issues.map(a=>$n(a,o,_r()))})),t.issues.length&&(td.has(typeof n)?r.issues.push(...zn(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:i,inst:s,key:n,issues:t.issues.map(a=>$n(a,o,_r()))})),r.value.set(e.value,t.value)}l(yT,"handleMapResult");var Gb=se("$ZodSet",(e,t)=>{vt.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),r;let s=[];r.value=new Set;for(let o of i){let a=t.valueType._zod.run({value:o,issues:[]},n);a instanceof Promise?s.push(a.then(c=>vT(c,r))):vT(a,r)}return s.length?Promise.all(s).then(()=>r):r}});function vT(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}l(vT,"handleSetResult");var Vb=se("$ZodEnum",(e,t)=>{vt.init(e,t);let r=Qu(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(i=>td.has(typeof i)).map(i=>typeof i=="string"?vi(i):i.toString()).join("|")})$`),e._zod.parse=(i,s)=>{let o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:r,input:o,inst:e}),i}}),Zb=se("$ZodLiteral",(e,t)=>{if(vt.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?vi(n):n?vi(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,i)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}}),Kb=se("$ZodFile",(e,t)=>{vt.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return i instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),r}}),Yb=se("$ZodTransform",(e,t)=>{vt.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ro(e.constructor.name);let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(r.value=o,r.fallback=!0,r));if(i instanceof Promise)throw new Vi;return r.value=i,r.fallback=!0,r}});function wT(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}l(wT,"handleOptionalResult");var Ih=se("$ZodOptional",(e,t)=>{vt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",It(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),It(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${ed(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=r.value,s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>wT(o,i)):wT(s,i)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Xb=se("$ZodExactOptional",(e,t)=>{Ih.init(e,t),It(e._zod,"values",()=>t.innerType._zod.values),It(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Jb=se("$ZodNullable",(e,t)=>{vt.init(e,t),It(e._zod,"optin",()=>t.innerType._zod.optin),It(e._zod,"optout",()=>t.innerType._zod.optout),It(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${ed(r.source)}|null)$`):void 0}),It(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Qb=se("$ZodDefault",(e,t)=>{vt.init(e,t),e._zod.optin="optional",It(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(s=>bT(s,t)):bT(i,t)}});function bT(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}l(bT,"handleDefaultResult");var ex=se("$ZodPrefault",(e,t)=>{vt.init(e,t),e._zod.optin="optional",It(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),tx=se("$ZodNonOptional",(e,t)=>{vt.init(e,t),It(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(s=>xT(s,e)):xT(i,e)}});function xT(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}l(xT,"handleNonOptionalResult");var rx=se("$ZodSuccess",(e,t)=>{vt.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ro("ZodSuccess");let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(s=>(r.value=s.issues.length===0,r)):(r.value=i.issues.length===0,r)}}),nx=se("$ZodCatch",(e,t)=>{vt.init(e,t),e._zod.optin="optional",It(e._zod,"optout",()=>t.innerType._zod.optout),It(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>$n(o,n,_r()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(s=>$n(s,n,_r()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),ix=se("$ZodNaN",(e,t)=>{vt.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),$h=se("$ZodPipe",(e,t)=>{vt.init(e,t),It(e._zod,"values",()=>t.in._zod.values),It(e._zod,"optin",()=>t.in._zod.optin),It(e._zod,"optout",()=>t.out._zod.optout),It(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(o=>wh(o,t.in,n)):wh(s,t.in,n)}let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(s=>wh(s,t.out,n)):wh(i,t.out,n)}});function wh(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}l(wh,"handlePipeResult");var fd=se("$ZodCodec",(e,t)=>{vt.init(e,t),It(e._zod,"values",()=>t.in._zod.values),It(e._zod,"optin",()=>t.in._zod.optin),It(e._zod,"optout",()=>t.out._zod.optout),It(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let s=t.in._zod.run(r,n);return s instanceof Promise?s.then(o=>bh(o,t,n)):bh(s,t,n)}else{let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(o=>bh(o,t,n)):bh(s,t,n)}}});function bh(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>xh(e,s,t.out,r)):xh(e,i,t.out,r)}else{let i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(s=>xh(e,s,t.in,r)):xh(e,i,t.in,r)}}l(bh,"handleCodecAResult");function xh(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}l(xh,"handleCodecTxResult");var sx=se("$ZodPreprocess",(e,t)=>{$h.init(e,t)}),ox=se("$ZodReadonly",(e,t)=>{vt.init(e,t),It(e._zod,"propValues",()=>t.innerType._zod.propValues),It(e._zod,"values",()=>t.innerType._zod.values),It(e._zod,"optin",()=>t.innerType?._zod?.optin),It(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(ET):ET(i)}});function ET(e){return e.value=Object.freeze(e.value),e}l(ET,"handleReadonlyResult");var ax=se("$ZodTemplateLiteral",(e,t)=>{vt.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let i=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!i)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let s=i.startsWith("^")?1:0,o=i.endsWith("$")?i.length-1:i.length;r.push(i.slice(s,o))}else if(n===null||Qv.has(typeof n))r.push(vi(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,i)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),lx=se("$ZodFunction",(e,t)=>(vt.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...n){let i=e._def.input?sh(e._def.input,n):n,s=Reflect.apply(r,this,i);return e._def.output?sh(e._def.output,s):s}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let i=e._def.input?await oh(e._def.input,n):n,s=await Reflect.apply(r,this,i);return e._def.output?await oh(e._def.output,s):s}},e._zod.parse=(r,n)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new Ah({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),cx=se("$ZodPromise",(e,t)=>{vt.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(i=>t.innerType._zod.run({value:i,issues:[]},n))}),ux=se("$ZodLazy",(e,t)=>{vt.init(e,t),It(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),It(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),It(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),It(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),It(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),dx=se("$ZodCustom",(e,t)=>{or.init(e,t),vt.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(s=>ST(s,r,n,e));ST(i,r,n,e)}});function ST(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(Wl(i))}}l(ST,"handleRefineResult");var yd={};ti(yd,{ar:()=>fx,az:()=>px,be:()=>hx,bg:()=>mx,ca:()=>gx,cs:()=>yx,da:()=>vx,de:()=>wx,el:()=>bx,en:()=>pd,eo:()=>xx,es:()=>Ex,fa:()=>Sx,fi:()=>kx,fr:()=>Ax,frCA:()=>Ix,he:()=>$x,hr:()=>_x,hu:()=>Tx,hy:()=>Cx,id:()=>Ox,is:()=>Nx,it:()=>Rx,ja:()=>Px,ka:()=>Dx,kh:()=>Lx,km:()=>hd,ko:()=>Mx,lt:()=>Fx,mk:()=>Ux,ms:()=>jx,nl:()=>zx,no:()=>Bx,ota:()=>Wx,pl:()=>Hx,ps:()=>qx,pt:()=>Gx,ro:()=>Vx,ru:()=>Zx,sl:()=>Kx,sv:()=>Yx,ta:()=>Xx,th:()=>Jx,tr:()=>Qx,ua:()=>e2,uk:()=>gd,ur:()=>t2,uz:()=>r2,vi:()=>n2,yo:()=>o2,zhCN:()=>i2,zhTW:()=>s2});var Yne=l(()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${i.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${s}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`}case"invalid_value":return i.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${Oe(i.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${s} ${i.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${s} ${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${s} ${i.minimum.toString()} ${o.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${s} ${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${i.prefix}"`:s.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${s.suffix}"`:s.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${s.includes}"`:s.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${s.pattern}`:`${r[s.format]??i.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${i.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${i.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${i.keys.length>1?"\u0629":""}: ${fe(i.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${i.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${i.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}},"error");function fx(){return{localeError:Yne()}}l(fx,"default");var Xne=l(()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${i.expected}, daxil olan ${a}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${s}, daxil olan ${a}`}case"invalid_value":return i.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${Oe(i.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${s}${i.maximum.toString()} ${o.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${s}${i.minimum.toString()} ${o.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${s.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:s.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${s.suffix}" il\u0259 bitm\u0259lidir`:s.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${s.includes}" daxil olmal\u0131d\u0131r`:s.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${s.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[s.format]??i.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${i.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${i.keys.length>1?"lar":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`${i.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${i.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}},"error");function px(){return{localeError:Xne()}}l(px,"default");function TT(e,t,r,n){let i=Math.abs(e),s=i%10,o=i%100;return o>=11&&o<=19?n:s===1?t:s>=2&&s<=4?r:n}l(TT,"getBelarusianPlural");var Jne=l(()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},n={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${i.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${s}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${Oe(i.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);if(o){let a=Number(i.maximum),c=TT(a,o.unit.one,o.unit.few,o.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${o.verb} ${s}${i.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);if(o){let a=Number(i.minimum),c=TT(a,o.unit.one,o.unit.few,o.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${o.verb} ${s}${i.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${s.prefix}"`:s.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${s.suffix}"`:s.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${s.includes}"`:s.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${s.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[s.format]??i.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${i.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${fe(i.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${i.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${i.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}},"error");function hx(){return{localeError:Jne()}}l(hx,"default");var Qne=l(()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${i.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${s}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${Oe(i.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${s}${i.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${s}${i.minimum.toString()} ${o.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${s.prefix}"`;if(s.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${s.suffix}"`;if(s.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${s.includes}"`;if(s.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${s.pattern}`;let o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return s.format==="emoji"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),s.format==="datetime"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),s.format==="date"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),s.format==="time"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),s.format==="duration"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${o} ${r[s.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${i.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u043E\u0432\u0435":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${i.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}},"error");function mx(){return{localeError:Qne()}}l(mx,"default");var eie=l(()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${i.expected}, s'ha rebut ${a}`:`Tipus inv\xE0lid: s'esperava ${s}, s'ha rebut ${a}`}case"invalid_value":return i.values.length===1?`Valor inv\xE0lid: s'esperava ${Oe(i.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${fe(i.values," o ")}`;case"too_big":{let s=i.inclusive?"com a m\xE0xim":"menys de",o=t(i.origin);return o?`Massa gran: s'esperava que ${i.origin??"el valor"} contingu\xE9s ${s} ${i.maximum.toString()} ${o.unit??"elements"}`:`Massa gran: s'esperava que ${i.origin??"el valor"} fos ${s} ${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?"com a m\xEDnim":"m\xE9s de",o=t(i.origin);return o?`Massa petit: s'esperava que ${i.origin} contingu\xE9s ${s} ${i.minimum.toString()} ${o.unit}`:`Massa petit: s'esperava que ${i.origin} fos ${s} ${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${s.prefix}"`:s.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${s.suffix}"`:s.format==="includes"?`Format inv\xE0lid: ha d'incloure "${s.includes}"`:s.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${s.pattern}`:`Format inv\xE0lid per a ${r[s.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${i.divisor}`;case"unrecognized_keys":return`Clau${i.keys.length>1?"s":""} no reconeguda${i.keys.length>1?"s":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${i.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${i.origin}`;default:return"Entrada inv\xE0lida"}}},"error");function gx(){return{localeError:eie()}}l(gx,"default");var tie=l(()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},n={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${i.expected}, obdr\u017Eeno ${a}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${s}, obdr\u017Eeno ${a}`}case"invalid_value":return i.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${Oe(i.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${s}${i.maximum.toString()} ${o.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${s}${i.minimum.toString()} ${o.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${s.prefix}"`:s.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${s.suffix}"`:s.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${s.includes}"`:s.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${s.pattern}`:`Neplatn\xFD form\xE1t ${r[s.format]??i.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${i.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${fe(i.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${i.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${i.origin}`;default:return"Neplatn\xFD vstup"}}},"error");function yx(){return{localeError:tie()}}l(yx,"default");var rie=l(()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},n={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ugyldigt input: forventede instanceof ${i.expected}, fik ${a}`:`Ugyldigt input: forventede ${s}, fik ${a}`}case"invalid_value":return i.values.length===1?`Ugyldig v\xE6rdi: forventede ${Oe(i.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin),a=n[i.origin]??i.origin;return o?`For stor: forventede ${a??"value"} ${o.verb} ${s} ${i.maximum.toString()} ${o.unit??"elementer"}`:`For stor: forventede ${a??"value"} havde ${s} ${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin),a=n[i.origin]??i.origin;return o?`For lille: forventede ${a} ${o.verb} ${s} ${i.minimum.toString()} ${o.unit}`:`For lille: forventede ${a} havde ${s} ${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ugyldig streng: skal starte med "${s.prefix}"`:s.format==="ends_with"?`Ugyldig streng: skal ende med "${s.suffix}"`:s.format==="includes"?`Ugyldig streng: skal indeholde "${s.includes}"`:s.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${s.pattern}`:`Ugyldig ${r[s.format]??i.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${fe(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${i.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${i.origin}`;default:return"Ugyldigt input"}}},"error");function vx(){return{localeError:rie()}}l(vx,"default");var nie=l(()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},n={nan:"NaN",number:"Zahl",array:"Array"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${i.expected}, erhalten ${a}`:`Ung\xFCltige Eingabe: erwartet ${s}, erhalten ${a}`}case"invalid_value":return i.values.length===1?`Ung\xFCltige Eingabe: erwartet ${Oe(i.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${s}${i.maximum.toString()} ${o.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${s}${i.maximum.toString()} ist`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Zu klein: erwartet, dass ${i.origin} ${s}${i.minimum.toString()} ${o.unit} hat`:`Zu klein: erwartet, dass ${i.origin} ${s}${i.minimum.toString()} ist`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ung\xFCltiger String: muss mit "${s.prefix}" beginnen`:s.format==="ends_with"?`Ung\xFCltiger String: muss mit "${s.suffix}" enden`:s.format==="includes"?`Ung\xFCltiger String: muss "${s.includes}" enthalten`:s.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${s.pattern} entsprechen`:`Ung\xFCltig: ${r[s.format]??i.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${i.divisor} sein`;case"unrecognized_keys":return`${i.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${fe(i.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${i.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${i.origin}`;default:return"Ung\xFCltige Eingabe"}}},"error");function wx(){return{localeError:nie()}}l(wx,"default");var iie=l(()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return typeof i.expected=="string"&&/^[A-Z]/.test(i.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${i.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${s}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`}case"invalid_value":return i.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${Oe(i.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${s}${i.maximum.toString()} ${o.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${s}${i.minimum.toString()} ${o.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${s.prefix}"`:s.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${s.suffix}"`:s.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${s.includes}"`:s.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${s.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[s.format]??i.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${i.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${i.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${i.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${fe(i.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${i.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${i.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}},"error");function bx(){return{localeError:iie()}}l(bx,"default");var sie=l(()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${Oe(i.values[0])}`:`Invalid option: expected one of ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${o.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(o=>`'${o}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}},"error");function pd(){return{localeError:sie()}}l(pd,"default");var oie=l(()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},n={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${i.expected}, ricevi\u011Dis ${a}`:`Nevalida enigo: atendi\u011Dis ${s}, ricevi\u011Dis ${a}`}case"invalid_value":return i.values.length===1?`Nevalida enigo: atendi\u011Dis ${Oe(i.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${s}${i.maximum.toString()} ${o.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Tro malgranda: atendi\u011Dis ke ${i.origin} havu ${s}${i.minimum.toString()} ${o.unit}`:`Tro malgranda: atendi\u011Dis ke ${i.origin} estu ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${s.prefix}"`:s.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${s.suffix}"`:s.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${s.includes}"`:s.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${s.pattern}`:`Nevalida ${r[s.format]??i.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${i.divisor}`;case"unrecognized_keys":return`Nekonata${i.keys.length>1?"j":""} \u015Dlosilo${i.keys.length>1?"j":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${i.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${i.origin}`;default:return"Nevalida enigo"}}},"error");function xx(){return{localeError:oie()}}l(xx,"default");var aie=l(()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${i.expected}, recibido ${a}`:`Entrada inv\xE1lida: se esperaba ${s}, recibido ${a}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: se esperaba ${Oe(i.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin),a=n[i.origin]??i.origin;return o?`Demasiado grande: se esperaba que ${a??"valor"} tuviera ${s}${i.maximum.toString()} ${o.unit??"elementos"}`:`Demasiado grande: se esperaba que ${a??"valor"} fuera ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin),a=n[i.origin]??i.origin;return o?`Demasiado peque\xF1o: se esperaba que ${a} tuviera ${s}${i.minimum.toString()} ${o.unit}`:`Demasiado peque\xF1o: se esperaba que ${a} fuera ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${s.prefix}"`:s.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${s.suffix}"`:s.format==="includes"?`Cadena inv\xE1lida: debe incluir "${s.includes}"`:s.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${s.pattern}`:`Inv\xE1lido ${r[s.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Llave${i.keys.length>1?"s":""} desconocida${i.keys.length>1?"s":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${n[i.origin]??i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${n[i.origin]??i.origin}`;default:return"Entrada inv\xE1lida"}}},"error");function Ex(){return{localeError:aie()}}l(Ex,"default");var lie=l(()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${i.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${s} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return i.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${Oe(i.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${fe(i.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${s}${i.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${s}${i.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${s}${i.minimum.toString()} ${o.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${s}${i.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${s.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:s.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${s.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:s.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${s.includes}" \u0628\u0627\u0634\u062F`:s.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${s.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[s.format]??i.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${i.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${i.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${fe(i.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${i.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${i.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}},"error");function Sx(){return{localeError:lie()}}l(Sx,"default");var cie=l(()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Virheellinen tyyppi: odotettiin instanceof ${i.expected}, oli ${a}`:`Virheellinen tyyppi: odotettiin ${s}, oli ${a}`}case"invalid_value":return i.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${Oe(i.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Liian suuri: ${o.subject} t\xE4ytyy olla ${s}${i.maximum.toString()} ${o.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Liian pieni: ${o.subject} t\xE4ytyy olla ${s}${i.minimum.toString()} ${o.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${s.prefix}"`:s.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${s.suffix}"`:s.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${s.includes}"`:s.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${s.pattern}`:`Virheellinen ${r[s.format]??i.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${i.divisor} monikerta`;case"unrecognized_keys":return`${i.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${fe(i.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}},"error");function kx(){return{localeError:cie()}}l(kx,"default");var uie=l(()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},n={string:"cha\xEEne",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"enregistrement",map:"carte",set:"ensemble",file:"fichier",nonoptional:"non-optionnel",nan:"NaN",function:"fonction"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : instanceof ${i.expected} attendu, ${a} re\xE7u`:`Entr\xE9e invalide : ${s} attendu, ${a} re\xE7u`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : ${Oe(i.values[0])} attendu`:`Option invalide : une valeur parmi ${fe(i.values,"|")} attendue`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Trop grand : ${n[i.origin]??"valeur"} doit ${o.verb} ${s}${i.maximum.toString()} ${o.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${n[i.origin]??"valeur"} doit \xEAtre ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Trop petit : ${n[i.origin]??"valeur"} doit ${o.verb} ${s}${i.minimum.toString()} ${o.unit}`:`Trop petit : ${n[i.origin]??"valeur"} doit \xEAtre ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${s.prefix}"`:s.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${s.suffix}"`:s.format==="includes"?`Cha\xEEne invalide : doit inclure "${s.includes}"`:s.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${s.pattern}`:`${r[s.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${fe(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}},"error");function Ax(){return{localeError:uie()}}l(Ax,"default");var die=l(()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : attendu instanceof ${i.expected}, re\xE7u ${a}`:`Entr\xE9e invalide : attendu ${s}, re\xE7u ${a}`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : attendu ${Oe(i.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"\u2264":"<",o=t(i.origin);return o?`Trop grand : attendu que ${i.origin??"la valeur"} ait ${s}${i.maximum.toString()} ${o.unit}`:`Trop grand : attendu que ${i.origin??"la valeur"} soit ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?"\u2265":">",o=t(i.origin);return o?`Trop petit : attendu que ${i.origin} ait ${s}${i.minimum.toString()} ${o.unit}`:`Trop petit : attendu que ${i.origin} soit ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${s.prefix}"`:s.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${s.suffix}"`:s.format==="includes"?`Cha\xEEne invalide : doit inclure "${s.includes}"`:s.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${s.pattern}`:`${r[s.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${fe(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}},"error");function Ix(){return{localeError:die()}}l(Ix,"default");var fie=l(()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=l(u=>u?e[u]:void 0,"typeEntry"),n=l(u=>{let d=r(u);return d?d.label:u??e.unknown.label},"typeLabel"),i=l(u=>`\u05D4${n(u)}`,"withDefinite"),s=l(u=>(r(u)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA","verbFor"),o=l(u=>u?t[u]??null:null,"getSizing"),a={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return u=>{switch(u.code){case"invalid_type":{let d=u.expected,f=c[d??""]??n(d),p=Ne(u.input),h=c[p]??e[p]?.label??p;return/^[A-Z]/.test(u.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${u.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${h}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${f}, \u05D4\u05EA\u05E7\u05D1\u05DC ${h}`}case"invalid_value":{if(u.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${Oe(u.values[0])}`;let d=u.values.map(h=>Oe(h));if(u.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${d[0]} \u05D0\u05D5 ${d[1]}`;let f=d[d.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${d.slice(0,-1).join(", ")} \u05D0\u05D5 ${f}`}case"too_big":{let d=o(u.origin),f=i(u.origin??"value");if(u.origin==="string")return`${d?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.maximum.toString()} ${d?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${u.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",g=u.inclusive?`${u.maximum} ${d?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${u.maximum} ${d?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${f} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${g}`.trim()}let p=u.inclusive?"<=":"<",h=s(u.origin??"value");return d?.unit?`${d.longLabel} \u05DE\u05D3\u05D9: ${f} ${h} ${p}${u.maximum.toString()} ${d.unit}`:`${d?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${f} ${h} ${p}${u.maximum.toString()}`}case"too_small":{let d=o(u.origin),f=i(u.origin??"value");if(u.origin==="string")return`${d?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.minimum.toString()} ${d?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${u.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(u.minimum===1&&u.inclusive){let y=(u.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${y}`}let g=u.inclusive?`${u.minimum} ${d?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${u.minimum} ${d?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${g}`.trim()}let p=u.inclusive?">=":">",h=s(u.origin??"value");return d?.unit?`${d.shortLabel} \u05DE\u05D3\u05D9: ${f} ${h} ${p}${u.minimum.toString()} ${d.unit}`:`${d?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${f} ${h} ${p}${u.minimum.toString()}`}case"invalid_format":{let d=u;if(d.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${d.prefix}"`;if(d.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${d.suffix}"`;if(d.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${d.includes}"`;if(d.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${d.pattern}`;let f=a[d.format],p=f?.label??d.format,m=(f?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${p} \u05DC\u05D0 ${m}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${u.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${u.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${u.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${fe(u.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${i(u.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}},"error");function $x(){return{localeError:fie()}}l($x,"default");var pie=l(()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",jwt:"JWT",template_literal:"unos"},n={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${i.expected}, a primljeno je ${a}`:`Neispravan unos: o\u010Dekuje se ${s}, a primljeno je ${a}`}case"invalid_value":return i.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${Oe(i.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin),a=n[i.origin]??i.origin;return o?`Preveliko: o\u010Dekivano da ${a??"vrijednost"} ima ${s}${i.maximum.toString()} ${o.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${a??"vrijednost"} bude ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin),a=n[i.origin]??i.origin;return o?`Premalo: o\u010Dekivano da ${a} ima ${s}${i.minimum.toString()} ${o.unit}`:`Premalo: o\u010Dekivano da ${a} bude ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${s.prefix}"`:s.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${s.suffix}"`:s.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${s.includes}"`:s.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${s.pattern}`:`Neispravna ${r[s.format]??i.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${i.divisor}`;case"unrecognized_keys":return`Neprepoznat${i.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${fe(i.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${n[i.origin]??i.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${n[i.origin]??i.origin}`;default:return"Neispravan unos"}}},"error");function _x(){return{localeError:pie()}}l(_x,"default");var hie=l(()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},n={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${i.expected}, a kapott \xE9rt\xE9k ${a}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${s}, a kapott \xE9rt\xE9k ${a}`}case"invalid_value":return i.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${Oe(i.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`T\xFAl nagy: ${i.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${s}${i.maximum.toString()} ${o.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${i.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} m\xE9rete t\xFAl kicsi ${s}${i.minimum.toString()} ${o.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} t\xFAl kicsi ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\xC9rv\xE9nytelen string: "${s.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:s.format==="ends_with"?`\xC9rv\xE9nytelen string: "${s.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:s.format==="includes"?`\xC9rv\xE9nytelen string: "${s.includes}" \xE9rt\xE9ket kell tartalmaznia`:s.format==="regex"?`\xC9rv\xE9nytelen string: ${s.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[s.format]??i.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${i.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${i.keys.length>1?"s":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${i.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${i.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}},"error");function Tx(){return{localeError:hie()}}l(Tx,"default");function CT(e,t,r){return Math.abs(e)===1?t:r}l(CT,"getArmenianPlural");function Kl(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=e[e.length-1];return e+(t.includes(r)?"\u0576":"\u0568")}l(Kl,"withDefiniteArticle");var mie=l(()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},n={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${i.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${s}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`}case"invalid_value":return i.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${Oe(i.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);if(o){let a=Number(i.maximum),c=CT(a,o.unit.one,o.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Kl(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${s}${i.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Kl(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);if(o){let a=Number(i.minimum),c=CT(a,o.unit.one,o.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Kl(i.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${s}${i.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Kl(i.origin)} \u056C\u056B\u0576\u056B ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${s.prefix}"-\u0578\u057E`:s.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${s.suffix}"-\u0578\u057E`:s.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${s.includes}"`:s.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${s.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[s.format]??i.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${i.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${i.keys.length>1?"\u0576\u0565\u0580":""}. ${fe(i.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${Kl(i.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${Kl(i.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}},"error");function Cx(){return{localeError:mie()}}l(Cx,"default");var gie=l(()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Input tidak valid: diharapkan instanceof ${i.expected}, diterima ${a}`:`Input tidak valid: diharapkan ${s}, diterima ${a}`}case"invalid_value":return i.values.length===1?`Input tidak valid: diharapkan ${Oe(i.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Terlalu besar: diharapkan ${i.origin??"value"} memiliki ${s}${i.maximum.toString()} ${o.unit??"elemen"}`:`Terlalu besar: diharapkan ${i.origin??"value"} menjadi ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Terlalu kecil: diharapkan ${i.origin} memiliki ${s}${i.minimum.toString()} ${o.unit}`:`Terlalu kecil: diharapkan ${i.origin} menjadi ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`String tidak valid: harus dimulai dengan "${s.prefix}"`:s.format==="ends_with"?`String tidak valid: harus berakhir dengan "${s.suffix}"`:s.format==="includes"?`String tidak valid: harus menyertakan "${s.includes}"`:s.format==="regex"?`String tidak valid: harus sesuai pola ${s.pattern}`:`${r[s.format]??i.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${i.keys.length>1?"s":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${i.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${i.origin}`;default:return"Input tidak valid"}}},"error");function Ox(){return{localeError:gie()}}l(Ox,"default");var yie=l(()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},n={nan:"NaN",number:"n\xFAmer",array:"fylki"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera instanceof ${i.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera ${s}`}case"invalid_value":return i.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${Oe(i.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} hafi ${s}${i.maximum.toString()} ${o.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} s\xE9 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} hafi ${s}${i.minimum.toString()} ${o.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} s\xE9 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${s.prefix}"`:s.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${s.suffix}"`:s.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${s.includes}"`:s.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${s.pattern}`:`Rangt ${r[s.format]??i.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${i.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${i.keys.length>1?"ir lyklar":"ur lykill"}: ${fe(i.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${i.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${i.origin}`;default:return"Rangt gildi"}}},"error");function Nx(){return{localeError:yie()}}l(Nx,"default");var vie=l(()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"numero",array:"vettore"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Input non valido: atteso instanceof ${i.expected}, ricevuto ${a}`:`Input non valido: atteso ${s}, ricevuto ${a}`}case"invalid_value":return i.values.length===1?`Input non valido: atteso ${Oe(i.values[0])}`:`Opzione non valida: atteso uno tra ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Troppo grande: ${i.origin??"valore"} deve avere ${s}${i.maximum.toString()} ${o.unit??"elementi"}`:`Troppo grande: ${i.origin??"valore"} deve essere ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Troppo piccolo: ${i.origin} deve avere ${s}${i.minimum.toString()} ${o.unit}`:`Troppo piccolo: ${i.origin} deve essere ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Stringa non valida: deve iniziare con "${s.prefix}"`:s.format==="ends_with"?`Stringa non valida: deve terminare con "${s.suffix}"`:s.format==="includes"?`Stringa non valida: deve includere "${s.includes}"`:s.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${s.pattern}`:`Input non valido: ${r[s.format]??i.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${i.divisor}`;case"unrecognized_keys":return`Chiav${i.keys.length>1?"i":"e"} non riconosciut${i.keys.length>1?"e":"a"}: ${fe(i.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${i.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${i.origin}`;default:return"Input non valido"}}},"error");function Rx(){return{localeError:vie()}}l(Rx,"default");var wie=l(()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},n={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${i.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${s}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return i.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${Oe(i.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${fe(i.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let s=i.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",o=t(i.origin);return o?`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${o.unit??"\u8981\u7D20"}${s}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${s}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let s=i.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",o=t(i.origin);return o?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${o.unit}${s}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${s}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${s.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:s.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${s.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:s.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${s.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:s.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${s.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[s.format]??i.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${i.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${i.keys.length>1?"\u7FA4":""}: ${fe(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}},"error");function Px(){return{localeError:wie()}}l(Px,"default");var bie=l(()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},n={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${i.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${s}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`}case"invalid_value":return i.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${Oe(i.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${fe(i.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${o.verb} ${s}${i.maximum.toString()} ${o.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin} ${o.verb} ${s}${i.minimum.toString()} ${o.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin} \u10D8\u10E7\u10DD\u10E1 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${s.prefix}"-\u10D8\u10D7`:s.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${s.suffix}"-\u10D8\u10D7`:s.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${s.includes}"-\u10E1`:s.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${s.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[s.format]??i.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${i.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${i.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${fe(i.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${i.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${i.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}},"error");function Dx(){return{localeError:bie()}}l(Dx,"default");var xie=l(()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},n={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${i.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${s} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`}case"invalid_value":return i.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${Oe(i.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${s} ${i.maximum.toString()} ${o.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${s} ${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${s} ${i.minimum.toString()} ${o.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${s} ${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${s.prefix}"`:s.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${s.suffix}"`:s.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${s.includes}"`:s.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${s.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[s.format]??i.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${i.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${fe(i.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${i.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${i.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}},"error");function hd(){return{localeError:xie()}}l(hd,"default");function Lx(){return hd()}l(Lx,"default");var Eie=l(()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${i.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${s}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`}case"invalid_value":return i.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${Oe(i.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${fe(i.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let s=i.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",o=s==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(i.origin),c=a?.unit??"\uC694\uC18C";return a?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()}${c} ${s}${o}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()} ${s}${o}`}case"too_small":{let s=i.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",o=s==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(i.origin),c=a?.unit??"\uC694\uC18C";return a?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()}${c} ${s}${o}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()} ${s}${o}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${s.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:s.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${s.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:s.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${s.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:s.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${s.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[s.format]??i.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${i.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${fe(i.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${i.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${i.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}},"error");function Mx(){return{localeError:Eie()}}l(Mx,"default");var md=l(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalizeFirstCharacter");function OT(e){let t=Math.abs(e),r=t%10,n=t%100;return n>=11&&n<=19||r===0?"many":r===1?"one":"few"}l(OT,"getUnitTypeFromNumber");var Sie=l(()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(i,s,o,a){let c=e[i]??null;return c===null?c:{unit:c.unit[s],verb:c.verb[a][o?"inclusive":"notInclusive"]}}l(t,"getSizing");let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},n={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Gautas tipas ${a}, o tik\u0117tasi - instanceof ${i.expected}`:`Gautas tipas ${a}, o tik\u0117tasi - ${s}`}case"invalid_value":return i.values.length===1?`Privalo b\u016Bti ${Oe(i.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${fe(i.values,"|")} pasirinkim\u0173`;case"too_big":{let s=n[i.origin]??i.origin,o=t(i.origin,OT(Number(i.maximum)),i.inclusive??!1,"smaller");if(o?.verb)return`${md(s??i.origin??"reik\u0161m\u0117")} ${o.verb} ${i.maximum.toString()} ${o.unit??"element\u0173"}`;let a=i.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${md(s??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${i.maximum.toString()} ${o?.unit}`}case"too_small":{let s=n[i.origin]??i.origin,o=t(i.origin,OT(Number(i.minimum)),i.inclusive??!1,"bigger");if(o?.verb)return`${md(s??i.origin??"reik\u0161m\u0117")} ${o.verb} ${i.minimum.toString()} ${o.unit??"element\u0173"}`;let a=i.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${md(s??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${i.minimum.toString()} ${o?.unit}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${s.prefix}"`:s.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${s.suffix}"`:s.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${s.includes}"`:s.format==="regex"?`Eilut\u0117 privalo atitikti ${s.pattern}`:`Neteisingas ${r[s.format]??i.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${i.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${i.keys.length>1?"i":"as"} rakt${i.keys.length>1?"ai":"as"}: ${fe(i.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let s=n[i.origin]??i.origin;return`${md(s??i.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}},"error");function Fx(){return{localeError:Sie()}}l(Fx,"default");var kie=l(()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},n={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${i.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${s}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${Oe(i.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${s}${i.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0438\u043C\u0430 ${s}${i.minimum.toString()} ${o.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${s.prefix}"`:s.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${s.suffix}"`:s.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${s.includes}"`:s.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${s.pattern}`:`Invalid ${r[s.format]??i.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${fe(i.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${i.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${i.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}},"error");function Ux(){return{localeError:kie()}}l(Ux,"default");var Aie=l(()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"nombor"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Input tidak sah: dijangka instanceof ${i.expected}, diterima ${a}`:`Input tidak sah: dijangka ${s}, diterima ${a}`}case"invalid_value":return i.values.length===1?`Input tidak sah: dijangka ${Oe(i.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Terlalu besar: dijangka ${i.origin??"nilai"} ${o.verb} ${s}${i.maximum.toString()} ${o.unit??"elemen"}`:`Terlalu besar: dijangka ${i.origin??"nilai"} adalah ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Terlalu kecil: dijangka ${i.origin} ${o.verb} ${s}${i.minimum.toString()} ${o.unit}`:`Terlalu kecil: dijangka ${i.origin} adalah ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`String tidak sah: mesti bermula dengan "${s.prefix}"`:s.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${s.suffix}"`:s.format==="includes"?`String tidak sah: mesti mengandungi "${s.includes}"`:s.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${s.pattern}`:`${r[s.format]??i.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${fe(i.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${i.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${i.origin}`;default:return"Input tidak sah"}}},"error");function jx(){return{localeError:Aie()}}l(jx,"default");var Iie=l(()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},n={nan:"NaN",number:"getal"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ongeldige invoer: verwacht instanceof ${i.expected}, ontving ${a}`:`Ongeldige invoer: verwacht ${s}, ontving ${a}`}case"invalid_value":return i.values.length===1?`Ongeldige invoer: verwacht ${Oe(i.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin),a=i.origin==="date"?"laat":i.origin==="string"?"lang":"groot";return o?`Te ${a}: verwacht dat ${i.origin??"waarde"} ${s}${i.maximum.toString()} ${o.unit??"elementen"} ${o.verb}`:`Te ${a}: verwacht dat ${i.origin??"waarde"} ${s}${i.maximum.toString()} is`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin),a=i.origin==="date"?"vroeg":i.origin==="string"?"kort":"klein";return o?`Te ${a}: verwacht dat ${i.origin} ${s}${i.minimum.toString()} ${o.unit} ${o.verb}`:`Te ${a}: verwacht dat ${i.origin} ${s}${i.minimum.toString()} is`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ongeldige tekst: moet met "${s.prefix}" beginnen`:s.format==="ends_with"?`Ongeldige tekst: moet op "${s.suffix}" eindigen`:s.format==="includes"?`Ongeldige tekst: moet "${s.includes}" bevatten`:s.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${s.pattern}`:`Ongeldig: ${r[s.format]??i.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${i.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${i.keys.length>1?"s":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${i.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${i.origin}`;default:return"Ongeldige invoer"}}},"error");function zx(){return{localeError:Iie()}}l(zx,"default");var $ie=l(()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"tall",array:"liste"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ugyldig input: forventet instanceof ${i.expected}, fikk ${a}`:`Ugyldig input: forventet ${s}, fikk ${a}`}case"invalid_value":return i.values.length===1?`Ugyldig verdi: forventet ${Oe(i.values[0])}`:`Ugyldig valg: forventet en av ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${s}${i.maximum.toString()} ${o.unit??"elementer"}`:`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`For lite(n): forventet ${i.origin} til \xE5 ha ${s}${i.minimum.toString()} ${o.unit}`:`For lite(n): forventet ${i.origin} til \xE5 ha ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${s.prefix}"`:s.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${s.suffix}"`:s.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${s.includes}"`:s.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${s.pattern}`:`Ugyldig ${r[s.format]??i.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${fe(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${i.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${i.origin}`;default:return"Ugyldig input"}}},"error");function Bx(){return{localeError:$ie()}}l(Bx,"default");var _ie=l(()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},n={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`F\xE2sit giren: umulan instanceof ${i.expected}, al\u0131nan ${a}`:`F\xE2sit giren: umulan ${s}, al\u0131nan ${a}`}case"invalid_value":return i.values.length===1?`F\xE2sit giren: umulan ${Oe(i.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${s}${i.maximum.toString()} ${o.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${s}${i.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${s}${i.minimum.toString()} ${o.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${s}${i.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let s=i;return s.format==="starts_with"?`F\xE2sit metin: "${s.prefix}" ile ba\u015Flamal\u0131.`:s.format==="ends_with"?`F\xE2sit metin: "${s.suffix}" ile bitmeli.`:s.format==="includes"?`F\xE2sit metin: "${s.includes}" ihtiv\xE2 etmeli.`:s.format==="regex"?`F\xE2sit metin: ${s.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[s.format]??i.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${i.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${i.keys.length>1?"s":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${i.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}},"error");function Wx(){return{localeError:_ie()}}l(Wx,"default");var Tie=l(()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${i.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${s} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return i.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${Oe(i.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${fe(i.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${s}${i.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${s}${i.maximum.toString()} \u0648\u064A`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${s}${i.minimum.toString()} ${o.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${s}${i.minimum.toString()} \u0648\u064A`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${s.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:s.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${s.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:s.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${s.includes}" \u0648\u0644\u0631\u064A`:s.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${s.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[s.format]??i.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${i.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${i.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${fe(i.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${i.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${i.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}},"error");function qx(){return{localeError:Tie()}}l(qx,"default");var Cie=l(()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},n={nan:"NaN",number:"liczba",array:"tablica"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${i.expected}, otrzymano ${a}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${s}, otrzymano ${a}`}case"invalid_value":return i.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${Oe(i.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${s}${i.maximum.toString()} ${o.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${s}${i.minimum.toString()} ${o.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${s.prefix}"`:s.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${s.suffix}"`:s.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${s.includes}"`:s.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${s.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[s.format]??i.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${i.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${i.keys.length>1?"s":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${i.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${i.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}},"error");function Hx(){return{localeError:Cie()}}l(Hx,"default");var Oie=l(()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},n={nan:"NaN",number:"n\xFAmero",null:"nulo"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Tipo inv\xE1lido: esperado instanceof ${i.expected}, recebido ${a}`:`Tipo inv\xE1lido: esperado ${s}, recebido ${a}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: esperado ${Oe(i.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Muito grande: esperado que ${i.origin??"valor"} tivesse ${s}${i.maximum.toString()} ${o.unit??"elementos"}`:`Muito grande: esperado que ${i.origin??"valor"} fosse ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Muito pequeno: esperado que ${i.origin} tivesse ${s}${i.minimum.toString()} ${o.unit}`:`Muito pequeno: esperado que ${i.origin} fosse ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${s.prefix}"`:s.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${s.suffix}"`:s.format==="includes"?`Texto inv\xE1lido: deve incluir "${s.includes}"`:s.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${s.pattern}`:`${r[s.format]??i.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Chave${i.keys.length>1?"s":""} desconhecida${i.keys.length>1?"s":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${i.origin}`;default:return"Campo inv\xE1lido"}}},"error");function Gx(){return{localeError:Oie()}}l(Gx,"default");var Nie=l(()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",jwt:"JWT",template_literal:"intrare"},n={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return`Intrare invalid\u0103: a\u0219teptat ${s}, primit ${a}`}case"invalid_value":return i.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${Oe(i.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} ${o.verb} ${s}${i.maximum.toString()} ${o.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} s\u0103 fie ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Prea mic: a\u0219teptat ca ${i.origin} ${o.verb} ${s}${i.minimum.toString()} ${o.unit}`:`Prea mic: a\u0219teptat ca ${i.origin} s\u0103 fie ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${s.prefix}"`:s.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${s.suffix}"`:s.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${s.includes}"`:s.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${s.pattern}`:`Format invalid: ${r[s.format]??i.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${i.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${fe(i.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${i.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${i.origin}`;default:return"Intrare invalid\u0103"}}},"error");function Vx(){return{localeError:Nie()}}l(Vx,"default");function NT(e,t,r,n){let i=Math.abs(e),s=i%10,o=i%100;return o>=11&&o<=19?n:s===1?t:s>=2&&s<=4?r:n}l(NT,"getRussianPlural");var Rie=l(()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${i.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${s}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${Oe(i.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);if(o){let a=Number(i.maximum),c=NT(a,o.unit.one,o.unit.few,o.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${s}${i.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);if(o){let a=Number(i.minimum),c=NT(a,o.unit.one,o.unit.few,o.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${s}${i.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${i.origin} \u0431\u0443\u0434\u0435\u0442 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${s.prefix}"`:s.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${s.suffix}"`:s.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${s.includes}"`:s.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${s.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[s.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${i.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0438":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${i.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}},"error");function Zx(){return{localeError:Rie()}}l(Zx,"default");var Pie=l(()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},n={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${i.expected}, prejeto ${a}`:`Neveljaven vnos: pri\u010Dakovano ${s}, prejeto ${a}`}case"invalid_value":return i.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${Oe(i.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} imelo ${s}${i.maximum.toString()} ${o.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Premajhno: pri\u010Dakovano, da bo ${i.origin} imelo ${s}${i.minimum.toString()} ${o.unit}`:`Premajhno: pri\u010Dakovano, da bo ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${s.prefix}"`:s.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${s.suffix}"`:s.format==="includes"?`Neveljaven niz: mora vsebovati "${s.includes}"`:s.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${s.pattern}`:`Neveljaven ${r[s.format]??i.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${i.divisor}`;case"unrecognized_keys":return`Neprepoznan${i.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${fe(i.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${i.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${i.origin}`;default:return"Neveljaven vnos"}}},"error");function Kx(){return{localeError:Pie()}}l(Kx,"default");var Die=l(()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},n={nan:"NaN",number:"antal",array:"lista"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${i.expected}, fick ${a}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${s}, fick ${a}`}case"invalid_value":return i.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${Oe(i.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`F\xF6r stor(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${s}${i.maximum.toString()} ${o.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${i.origin??"v\xE4rdet"} att ha ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${s}${i.minimum.toString()} ${o.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${s.prefix}"`:s.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${s.suffix}"`:s.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${s.includes}"`:s.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${s.pattern}"`:`Ogiltig(t) ${r[s.format]??i.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${fe(i.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${i.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${i.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}},"error");function Yx(){return{localeError:Die()}}l(Yx,"default");var Lie=l(()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},n={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${i.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`}case"invalid_value":return i.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${Oe(i.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${fe(i.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${s}${i.maximum.toString()} ${o.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${s}${i.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin} ${s}${i.minimum.toString()} ${o.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i.origin} ${s}${i.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${s.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:s.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${s.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:s.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${s.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:s.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${s.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[s.format]??i.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${i.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${i.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`${i.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${i.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}},"error");function Xx(){return{localeError:Lie()}}l(Xx,"default");var Mie=l(()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},n={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${i.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${s} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`}case"invalid_value":return i.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${Oe(i.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",o=t(i.origin);return o?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${s} ${i.maximum.toString()} ${o.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${s} ${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",o=t(i.origin);return o?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${s} ${i.minimum.toString()} ${o.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${s} ${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${s.prefix}"`:s.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${s.suffix}"`:s.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${s.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:s.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${s.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[s.format]??i.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${i.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${fe(i.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${i.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${i.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}},"error");function Jx(){return{localeError:Mie()}}l(Jx,"default");var Fie=l(()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${i.expected}, al\u0131nan ${a}`:`Ge\xE7ersiz de\u011Fer: beklenen ${s}, al\u0131nan ${a}`}case"invalid_value":return i.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${Oe(i.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${s}${i.maximum.toString()} ${o.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${s}${i.minimum.toString()} ${o.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ge\xE7ersiz metin: "${s.prefix}" ile ba\u015Flamal\u0131`:s.format==="ends_with"?`Ge\xE7ersiz metin: "${s.suffix}" ile bitmeli`:s.format==="includes"?`Ge\xE7ersiz metin: "${s.includes}" i\xE7ermeli`:s.format==="regex"?`Ge\xE7ersiz metin: ${s.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[s.format]??i.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${i.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${i.keys.length>1?"lar":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${i.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}},"error");function Qx(){return{localeError:Fie()}}l(Qx,"default");var Uie=l(()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${i.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${s}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${Oe(i.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${o.verb} ${s}${i.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} ${o.verb} ${s}${i.minimum.toString()} ${o.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} \u0431\u0443\u0434\u0435 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${s.prefix}"`:s.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${s.suffix}"`:s.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${s.includes}"`:s.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${s.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[s.format]??i.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0456":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${i.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${i.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}},"error");function gd(){return{localeError:Uie()}}l(gd,"default");function e2(){return gd()}l(e2,"default");var jie=l(()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},n={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${i.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${s} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return i.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${Oe(i.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${fe(i.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${s}${i.maximum.toString()} ${o.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${s}${i.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u06D2 ${s}${i.minimum.toString()} ${o.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u0627 ${s}${i.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${s.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:s.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${s.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:s.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${s.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:s.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${s.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[s.format]??i.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${i.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${i.keys.length>1?"\u0632":""}: ${fe(i.keys,"\u060C ")}`;case"invalid_key":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}},"error");function t2(){return{localeError:jie()}}l(t2,"default");var zie=l(()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},n={nan:"NaN",number:"raqam",array:"massiv"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${i.expected}, qabul qilingan ${a}`:`Noto\u2018g\u2018ri kirish: kutilgan ${s}, qabul qilingan ${a}`}case"invalid_value":return i.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${Oe(i.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Juda katta: kutilgan ${i.origin??"qiymat"} ${s}${i.maximum.toString()} ${o.unit} ${o.verb}`:`Juda katta: kutilgan ${i.origin??"qiymat"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Juda kichik: kutilgan ${i.origin} ${s}${i.minimum.toString()} ${o.unit} ${o.verb}`:`Juda kichik: kutilgan ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${s.prefix}" bilan boshlanishi kerak`:s.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${s.suffix}" bilan tugashi kerak`:s.format==="includes"?`Noto\u2018g\u2018ri satr: "${s.includes}" ni o\u2018z ichiga olishi kerak`:s.format==="regex"?`Noto\u2018g\u2018ri satr: ${s.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[s.format]??i.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${i.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${i.keys.length>1?"lar":""}: ${fe(i.keys,", ")}`;case"invalid_key":return`${i.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${i.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}},"error");function r2(){return{localeError:zie()}}l(r2,"default");var Bie=l(()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},n={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${i.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${s}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`}case"invalid_value":return i.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${Oe(i.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${o.verb} ${s}${i.maximum.toString()} ${o.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${o.verb} ${s}${i.minimum.toString()} ${o.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${s.prefix}"`:s.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${s.suffix}"`:s.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${s.includes}"`:s.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${s.pattern}`:`${r[s.format]??i.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${i.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${fe(i.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${i.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${i.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}},"error");function n2(){return{localeError:Bie()}}l(n2,"default");var Wie=l(()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},n={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${i.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${s}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`}case"invalid_value":return i.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${Oe(i.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${s}${i.maximum.toString()} ${o.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${s}${i.minimum.toString()} ${o.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${s.prefix}" \u5F00\u5934`:s.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${s.suffix}" \u7ED3\u5C3E`:s.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${s.includes}"`:s.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${s.pattern}`:`\u65E0\u6548${r[s.format]??i.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${i.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${fe(i.keys,", ")}`;case"invalid_key":return`${i.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${i.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}},"error");function i2(){return{localeError:Wie()}}l(i2,"default");var qie=l(()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${i.expected}\uFF0C\u4F46\u6536\u5230 ${a}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${s}\uFF0C\u4F46\u6536\u5230 ${a}`}case"invalid_value":return i.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${Oe(i.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${s}${i.maximum.toString()} ${o.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${s}${i.minimum.toString()} ${o.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${s.prefix}" \u958B\u982D`:s.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${s.suffix}" \u7D50\u5C3E`:s.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${s.includes}"`:s.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${s.pattern}`:`\u7121\u6548\u7684 ${r[s.format]??i.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${i.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${i.keys.length>1?"\u5011":""}\uFF1A${fe(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}},"error");function s2(){return{localeError:qie()}}l(s2,"default");var Hie=l(()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function t(i){return e[i]??null}l(t,"getSizing");let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},n={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return i=>{switch(i.code){case"invalid_type":{let s=n[i.expected]??i.expected,o=Ne(i.input),a=n[o]??o;return/^[A-Z]/.test(i.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${i.expected}, \xE0m\u1ECD\u0300 a r\xED ${a}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${s}, \xE0m\u1ECD\u0300 a r\xED ${a}`}case"invalid_value":return i.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${Oe(i.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${fe(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",o=t(i.origin);return o?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin??"iye"} ${o.verb} ${s}${i.maximum} ${o.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${s}${i.maximum}`}case"too_small":{let s=i.inclusive?">=":">",o=t(i.origin);return o?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin} ${o.verb} ${s}${i.minimum} ${o.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${s}${i.minimum}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${s.prefix}"`:s.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${s.suffix}"`:s.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${s.includes}"`:s.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${s.pattern}`:`A\u1E63\xEC\u1E63e: ${r[s.format]??i.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${i.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${fe(i.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${i.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${i.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}},"error");function o2(){return{localeError:Hie()}}l(o2,"default");var RT,a2=Symbol("ZodOutput"),l2=Symbol("ZodInput"),_h=class{static{l(this,"$ZodRegistry")}constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Th(){return new _h}l(Th,"registry");(RT=globalThis).__zod_globalRegistry??(RT.__zod_globalRegistry=Th());var nn=globalThis.__zod_globalRegistry;function c2(e,t){return new e({type:"string",...Me(t)})}l(c2,"_string");function u2(e,t){return new e({type:"string",coerce:!0,...Me(t)})}l(u2,"_coercedString");function Ch(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Me(t)})}l(Ch,"_email");function vd(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Me(t)})}l(vd,"_guid");function Oh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Me(t)})}l(Oh,"_uuid");function Nh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Me(t)})}l(Nh,"_uuidv4");function Rh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Me(t)})}l(Rh,"_uuidv6");function Ph(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Me(t)})}l(Ph,"_uuidv7");function wd(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Me(t)})}l(wd,"_url");function Dh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Me(t)})}l(Dh,"_emoji");function Lh(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Me(t)})}l(Lh,"_nanoid");function Mh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Me(t)})}l(Mh,"_cuid");function Fh(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Me(t)})}l(Fh,"_cuid2");function Uh(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Me(t)})}l(Uh,"_ulid");function jh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Me(t)})}l(jh,"_xid");function zh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Me(t)})}l(zh,"_ksuid");function Bh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Me(t)})}l(Bh,"_ipv4");function Wh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Me(t)})}l(Wh,"_ipv6");function d2(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...Me(t)})}l(d2,"_mac");function qh(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Me(t)})}l(qh,"_cidrv4");function Hh(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Me(t)})}l(Hh,"_cidrv6");function Gh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Me(t)})}l(Gh,"_base64");function Vh(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Me(t)})}l(Vh,"_base64url");function Zh(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Me(t)})}l(Zh,"_e164");function Kh(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Me(t)})}l(Kh,"_jwt");var f2={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function p2(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Me(t)})}l(p2,"_isoDateTime");function h2(e,t){return new e({type:"string",format:"date",check:"string_format",...Me(t)})}l(h2,"_isoDate");function m2(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Me(t)})}l(m2,"_isoTime");function g2(e,t){return new e({type:"string",format:"duration",check:"string_format",...Me(t)})}l(g2,"_isoDuration");function y2(e,t){return new e({type:"number",checks:[],...Me(t)})}l(y2,"_number");function v2(e,t){return new e({type:"number",coerce:!0,checks:[],...Me(t)})}l(v2,"_coercedNumber");function w2(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Me(t)})}l(w2,"_int");function b2(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...Me(t)})}l(b2,"_float32");function x2(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...Me(t)})}l(x2,"_float64");function E2(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...Me(t)})}l(E2,"_int32");function S2(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...Me(t)})}l(S2,"_uint32");function k2(e,t){return new e({type:"boolean",...Me(t)})}l(k2,"_boolean");function A2(e,t){return new e({type:"boolean",coerce:!0,...Me(t)})}l(A2,"_coercedBoolean");function I2(e,t){return new e({type:"bigint",...Me(t)})}l(I2,"_bigint");function $2(e,t){return new e({type:"bigint",coerce:!0,...Me(t)})}l($2,"_coercedBigint");function _2(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...Me(t)})}l(_2,"_int64");function T2(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...Me(t)})}l(T2,"_uint64");function C2(e,t){return new e({type:"symbol",...Me(t)})}l(C2,"_symbol");function O2(e,t){return new e({type:"undefined",...Me(t)})}l(O2,"_undefined");function N2(e,t){return new e({type:"null",...Me(t)})}l(N2,"_null");function R2(e){return new e({type:"any"})}l(R2,"_any");function P2(e){return new e({type:"unknown"})}l(P2,"_unknown");function D2(e,t){return new e({type:"never",...Me(t)})}l(D2,"_never");function L2(e,t){return new e({type:"void",...Me(t)})}l(L2,"_void");function M2(e,t){return new e({type:"date",...Me(t)})}l(M2,"_date");function F2(e,t){return new e({type:"date",coerce:!0,...Me(t)})}l(F2,"_coercedDate");function U2(e,t){return new e({type:"nan",...Me(t)})}l(U2,"_nan");function ws(e,t){return new yh({check:"less_than",...Me(t),value:e,inclusive:!1})}l(ws,"_lt");function ni(e,t){return new yh({check:"less_than",...Me(t),value:e,inclusive:!0})}l(ni,"_lte");function bs(e,t){return new vh({check:"greater_than",...Me(t),value:e,inclusive:!1})}l(bs,"_gt");function _n(e,t){return new vh({check:"greater_than",...Me(t),value:e,inclusive:!0})}l(_n,"_gte");function Yh(e){return bs(0,e)}l(Yh,"_positive");function Xh(e){return ws(0,e)}l(Xh,"_negative");function Jh(e){return ni(0,e)}l(Jh,"_nonpositive");function Qh(e){return _n(0,e)}l(Qh,"_nonnegative");function Fo(e,t){return new Mw({check:"multiple_of",...Me(t),value:e})}l(Fo,"_multipleOf");function Uo(e,t){return new jw({check:"max_size",...Me(t),maximum:e})}l(Uo,"_maxSize");function xs(e,t){return new zw({check:"min_size",...Me(t),minimum:e})}l(xs,"_minSize");function Ra(e,t){return new Bw({check:"size_equals",...Me(t),size:e})}l(Ra,"_size");function Pa(e,t){return new Ww({check:"max_length",...Me(t),maximum:e})}l(Pa,"_maxLength");function Ys(e,t){return new qw({check:"min_length",...Me(t),minimum:e})}l(Ys,"_minLength");function Da(e,t){return new Hw({check:"length_equals",...Me(t),length:e})}l(Da,"_length");function Yl(e,t){return new Gw({check:"string_format",format:"regex",...Me(t),pattern:e})}l(Yl,"_regex");function Xl(e){return new Vw({check:"string_format",format:"lowercase",...Me(e)})}l(Xl,"_lowercase");function Jl(e){return new Zw({check:"string_format",format:"uppercase",...Me(e)})}l(Jl,"_uppercase");function Ql(e,t){return new Kw({check:"string_format",format:"includes",...Me(t),includes:e})}l(Ql,"_includes");function ec(e,t){return new Yw({check:"string_format",format:"starts_with",...Me(t),prefix:e})}l(ec,"_startsWith");function tc(e,t){return new Xw({check:"string_format",format:"ends_with",...Me(t),suffix:e})}l(tc,"_endsWith");function em(e,t,r){return new Jw({check:"property",property:e,schema:t,...Me(r)})}l(em,"_property");function rc(e,t){return new Qw({check:"mime_type",mime:e,...Me(t)})}l(rc,"_mime");function Zi(e){return new eb({check:"overwrite",tx:e})}l(Zi,"_overwrite");function nc(e){return Zi(t=>t.normalize(e))}l(nc,"_normalize");function ic(){return Zi(e=>e.trim())}l(ic,"_trim");function sc(){return Zi(e=>e.toLowerCase())}l(sc,"_toLowerCase");function oc(){return Zi(e=>e.toUpperCase())}l(oc,"_toUpperCase");function ac(){return Zi(e=>Yv(e))}l(ac,"_slugify");function j2(e,t,r){return new e({type:"array",element:t,...Me(r)})}l(j2,"_array");function Vie(e,t,r){return new e({type:"union",options:t,...Me(r)})}l(Vie,"_union");function Zie(e,t,r){return new e({type:"union",options:t,inclusive:!1,...Me(r)})}l(Zie,"_xor");function Kie(e,t,r,n){return new e({type:"union",options:r,discriminator:t,...Me(n)})}l(Kie,"_discriminatedUnion");function Yie(e,t,r){return new e({type:"intersection",left:t,right:r})}l(Yie,"_intersection");function Xie(e,t,r,n){let i=r instanceof vt,s=i?n:r,o=i?r:null;return new e({type:"tuple",items:t,rest:o,...Me(s)})}l(Xie,"_tuple");function Jie(e,t,r,n){return new e({type:"record",keyType:t,valueType:r,...Me(n)})}l(Jie,"_record");function Qie(e,t,r,n){return new e({type:"map",keyType:t,valueType:r,...Me(n)})}l(Qie,"_map");function ese(e,t,r){return new e({type:"set",valueType:t,...Me(r)})}l(ese,"_set");function tse(e,t,r){let n=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:n,...Me(r)})}l(tse,"_enum");function rse(e,t,r){return new e({type:"enum",entries:t,...Me(r)})}l(rse,"_nativeEnum");function nse(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...Me(r)})}l(nse,"_literal");function z2(e,t){return new e({type:"file",...Me(t)})}l(z2,"_file");function ise(e,t){return new e({type:"transform",transform:t})}l(ise,"_transform");function sse(e,t){return new e({type:"optional",innerType:t})}l(sse,"_optional");function ose(e,t){return new e({type:"nullable",innerType:t})}l(ose,"_nullable");function ase(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Jv(r)}})}l(ase,"_default");function lse(e,t,r){return new e({type:"nonoptional",innerType:t,...Me(r)})}l(lse,"_nonoptional");function cse(e,t){return new e({type:"success",innerType:t})}l(cse,"_success");function use(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}l(use,"_catch");function dse(e,t,r){return new e({type:"pipe",in:t,out:r})}l(dse,"_pipe");function fse(e,t){return new e({type:"readonly",innerType:t})}l(fse,"_readonly");function pse(e,t,r){return new e({type:"template_literal",parts:t,...Me(r)})}l(pse,"_templateLiteral");function hse(e,t){return new e({type:"lazy",getter:t})}l(hse,"_lazy");function mse(e,t){return new e({type:"promise",innerType:t})}l(mse,"_promise");function B2(e,t,r){let n=Me(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}l(B2,"_custom");function W2(e,t,r){return new e({type:"custom",check:"custom",fn:t,...Me(r)})}l(W2,"_refine");function q2(e,t){let r=PT(n=>(n.addIssue=i=>{if(typeof i=="string")n.issues.push(Wl(i,n.value,r._zod.def));else{let s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Wl(s))}},e(n.value,n)),t);return r}l(q2,"_superRefine");function PT(e,t){let r=new or({check:"custom",...Me(t)});return r._zod.check=e,r}l(PT,"_check");function H2(e){let t=new or({check:"describe"});return t._zod.onattach=[r=>{let n=nn.get(r)??{};nn.add(r,{...n,description:e})}],t._zod.check=()=>{},t}l(H2,"describe");function G2(e){let t=new or({check:"meta"});return t._zod.onattach=[r=>{let n=nn.get(r)??{};nn.add(r,{...n,...e})}],t._zod.check=()=>{},t}l(G2,"meta");function V2(e,t){let r=Me(t),n=r.truthy??["true","1","yes","on","y","enabled"],i=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(h=>typeof h=="string"?h.toLowerCase():h),i=i.map(h=>typeof h=="string"?h.toLowerCase():h));let s=new Set(n),o=new Set(i),a=e.Codec??fd,c=e.Boolean??ud,u=e.String??Na,d=new u({type:"string",error:r.error}),f=new c({type:"boolean",error:r.error}),p=new a({type:"pipe",in:d,out:f,transform:l(((h,m)=>{let g=h;return r.case!=="sensitive"&&(g=g.toLowerCase()),s.has(g)?!0:o.has(g)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...s,...o],input:m.value,inst:p,continue:!1}),{})}),"transform"),reverseTransform:l(((h,m)=>h===!0?n[0]||"true":i[0]||"false"),"reverseTransform"),error:r.error});return p}l(V2,"_stringbool");function lc(e,t,r,n={}){let i=Me(n),s={...Me(n),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:a=>r.test(a),...i};return r instanceof RegExp&&(s.pattern=r),new e(s)}l(lc,"_stringFormat");function jo(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??nn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}l(jo,"initializeContext");function Kt(e,t,r={path:[],schemaPath:[]}){var n;let i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,d);else{let p=o.schema,h=t.processors[i.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,p,d)}let f=e._zod.parent;f&&(o.ref||(o.ref=f),Kt(f,t,d),t.seen.get(f).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Tn(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}l(Kt,"process");function zo(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=n.get(a);if(c&&c!==o[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,o[0])}}let i=l(o=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(o[0])?.id,p=e.external.uri??(m=>m);if(f)return{ref:p(f)};let h=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=h,{defId:h,ref:`${p("__shared")}#/${a}/${h}`}}if(o[1]===r)return{ref:"#"};let u=`#/${a}/`,d=o[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},"makeURI"),s=l(o=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:u}=i(o);a.def={...a.schema},u&&(a.defId=u);let d=a.schema;for(let f in d)delete d[f];d.$ref=c},"extractToDef");if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
427
427
|
|
|
428
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let u=e.external.registry.get(o[0])?.id;if(t!==o[0]&&u){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1&&e.reused==="ref"){s(o);continue}}}l(zo,"extractDefs");function Bo(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=l(a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,d={...u},f=c.ref;if(c.ref=null,f){n(f);let h=e.seen.get(f),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,d),a._zod.parent===f)for(let y in u)y==="$ref"||y==="allOf"||y in d||delete u[y];if(m.$ref&&h.def)for(let y in u)y==="$ref"||y==="allOf"||y in h.def&&JSON.stringify(u[y])===JSON.stringify(h.def[y])&&delete u[y]}let p=a._zod.parent;if(p&&p!==f){n(p);let h=e.seen.get(p);if(h?.schema.$ref&&(u.$ref=h.schema.$ref,h.def))for(let m in u)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(u[m])===JSON.stringify(h.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})},"flattenRef");for(let a of[...e.seen.entries()].reverse())n(a[0]);let i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}Object.assign(i,r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&i.id===s&&delete i.id;let o=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,o[c.defId]=c.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{let a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:cc(t,"input",e.processors),output:cc(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}l(Bo,"finalize");function Tn(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Tn(n.element,r);if(n.type==="set")return Tn(n.valueType,r);if(n.type==="lazy")return Tn(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Tn(n.innerType,r);if(n.type==="intersection")return Tn(n.left,r)||Tn(n.right,r);if(n.type==="record"||n.type==="map")return Tn(n.keyType,r)||Tn(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Tn(n.in,r)||Tn(n.out,r);if(n.type==="object"){for(let i in n.shape)if(Tn(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(Tn(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(Tn(i,r))return!0;return!!(n.rest&&Tn(n.rest,r))}return!1}l(Tn,"isTransforming");var Z2=l((e,t={})=>r=>{let n=jo({...r,processors:t});return Kt(e,n),zo(n,e),Bo(n,e)},"createToJSONSchemaMethod"),cc=l((e,t,r={})=>n=>{let{libraryOptions:i,target:s}=n??{},o=jo({...i??{},target:s,io:t,processors:r});return Kt(e,o),zo(o,e),Bo(o,e)},"createStandardJSONSchemaMethod");var gse={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},K2=l((e,t,r,n)=>{let i=r;i.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=gse[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){let d=[...c];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},"stringProcessor"),Y2=l((e,t,r,n)=>{let i=r,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number";let f=typeof d=="number"&&d>=(s??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(o??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";f?h?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d:typeof s=="number"&&(i.minimum=s),p?h?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u:typeof o=="number"&&(i.maximum=o),typeof c=="number"&&(i.multipleOf=c)},"numberProcessor"),X2=l((e,t,r,n)=>{r.type="boolean"},"booleanProcessor"),J2=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},"bigintProcessor"),Q2=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},"symbolProcessor"),eE=l((e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},"nullProcessor"),tE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},"undefinedProcessor"),rE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},"voidProcessor"),nE=l((e,t,r,n)=>{r.not={}},"neverProcessor"),iE=l((e,t,r,n)=>{},"anyProcessor"),sE=l((e,t,r,n)=>{},"unknownProcessor"),oE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},"dateProcessor"),aE=l((e,t,r,n)=>{let i=e._zod.def,s=Qu(i.entries);s.every(o=>typeof o=="number")&&(r.type="number"),s.every(o=>typeof o=="string")&&(r.type="string"),r.enum=s},"enumProcessor"),lE=l((e,t,r,n)=>{let i=e._zod.def,s=[];for(let o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){let o=s[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else s.every(o=>typeof o=="number")&&(r.type="number"),s.every(o=>typeof o=="string")&&(r.type="string"),s.every(o=>typeof o=="boolean")&&(r.type="boolean"),s.every(o=>o===null)&&(r.type="null"),r.enum=s},"literalProcessor"),cE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},"nanProcessor"),uE=l((e,t,r,n)=>{let i=r,s=e._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=s.source},"templateLiteralProcessor"),dE=l((e,t,r,n)=>{let i=r,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:a,mime:c}=e._zod.bag;o!==void 0&&(s.minLength=o),a!==void 0&&(s.maxLength=a),c?c.length===1?(s.contentMediaType=c[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(i,s)},"fileProcessor"),fE=l((e,t,r,n)=>{r.type="boolean"},"successProcessor"),pE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},"customProcessor"),hE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},"functionProcessor"),mE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},"transformProcessor"),gE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},"mapProcessor"),yE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},"setProcessor"),vE=l((e,t,r,n)=>{let i=r,s=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Kt(s.element,t,{...n,path:[...n.path,"items"]})},"arrayProcessor"),wE=l((e,t,r,n)=>{let i=r,s=e._zod.def;i.type="object",i.properties={};let o=s.shape;for(let u in o)i.properties[u]=Kt(o[u],t,{...n,path:[...n.path,"properties",u]});let a=new Set(Object.keys(o)),c=new Set([...a].filter(u=>{let d=s.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(i.required=Array.from(c)),s.catchall?._zod.def.type==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Kt(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},"objectProcessor"),rm=l((e,t,r,n)=>{let i=e._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>Kt(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=o:r.anyOf=o},"unionProcessor"),bE=l((e,t,r,n)=>{let i=e._zod.def,s=Kt(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=Kt(i.right,t,{...n,path:[...n.path,"allOf",1]}),a=l(u=>"allOf"in u&&Object.keys(u).length===1,"isSimpleIntersection"),c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];r.allOf=c},"intersectionProcessor"),xE=l((e,t,r,n)=>{let i=r,s=e._zod.def;i.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((p,h)=>Kt(p,t,{...n,path:[...n.path,o,h]})),u=s.rest?Kt(s.rest,t,{...n,path:[...n.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=c,u&&(i.items=u)):t.target==="openapi-3.0"?(i.items={anyOf:c},u&&i.items.anyOf.push(u),i.minItems=c.length,u||(i.maxItems=c.length)):(i.items=c,u&&(i.additionalItems=u));let{minimum:d,maximum:f}=e._zod.bag;typeof d=="number"&&(i.minItems=d),typeof f=="number"&&(i.maxItems=f)},"tupleProcessor"),EE=l((e,t,r,n)=>{let i=r,s=e._zod.def;i.type="object";let o=s.keyType,c=o._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){let d=Kt(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(let f of c)i.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Kt(s.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=Kt(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=o._zod.values;if(u){let d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},"recordProcessor"),SE=l((e,t,r,n)=>{let i=e._zod.def,s=Kt(i.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=i.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},"nullableProcessor"),kE=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType},"nonoptionalProcessor"),AE=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},"defaultProcessor"),IE=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},"prefaultProcessor"),$E=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},"catchProcessor"),_E=l((e,t,r,n)=>{let i=e._zod.def,s=i.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?i.out:i.in:i.out;Kt(o,t,n);let a=t.seen.get(e);a.ref=o},"pipeProcessor"),TE=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType,r.readOnly=!0},"readonlyProcessor"),CE=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType},"promiseProcessor"),nm=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType},"optionalProcessor"),OE=l((e,t,r,n)=>{let i=e._zod.innerType;Kt(i,t,n);let s=t.seen.get(e);s.ref=i},"lazyProcessor"),tm={string:K2,number:Y2,boolean:X2,bigint:J2,symbol:Q2,null:eE,undefined:tE,void:rE,never:nE,any:iE,unknown:sE,date:oE,enum:aE,literal:lE,nan:cE,template_literal:uE,file:dE,success:fE,custom:pE,function:hE,transform:mE,map:gE,set:yE,array:vE,object:wE,union:rm,intersection:bE,tuple:xE,record:EE,nullable:SE,nonoptional:kE,default:AE,prefault:IE,catch:$E,pipe:_E,readonly:TE,promise:CE,optional:nm,lazy:OE};function im(e,t){if("_idmap"in e){let n=e,i=jo({...t,processors:tm}),s={};for(let c of n._idmap.entries()){let[u,d]=c;Kt(d,i)}let o={},a={registry:n,uri:t?.uri,defs:s};i.external=a;for(let c of n._idmap.entries()){let[u,d]=c;zo(i,d),o[u]=Bo(i,d)}if(Object.keys(s).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:s}}return{schemas:o}}let r=jo({...t,processors:tm});return Kt(e,r),zo(r,e),Bo(r,e)}l(im,"toJSONSchema");var sm=class{static{l(this,"JSONSchemaGenerator")}get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=jo({processors:tm,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return Kt(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),zo(this.ctx,t);let n=Bo(this.ctx,t),{"~standard":i,...s}=n;return s}};var DT={};var bd={};ti(bd,{ZodAny:()=>tS,ZodArray:()=>sS,ZodBase64:()=>Im,ZodBase64URL:()=>$m,ZodBigInt:()=>yc,ZodBigIntFormat:()=>Cm,ZodBoolean:()=>gc,ZodCIDRv4:()=>km,ZodCIDRv6:()=>Am,ZodCUID:()=>ym,ZodCUID2:()=>vm,ZodCatch:()=>$S,ZodCodec:()=>Nd,ZodCustom:()=>Rd,ZodCustomStringFormat:()=>hc,ZodDate:()=>$d,ZodDefault:()=>xS,ZodDiscriminatedUnion:()=>aS,ZodE164:()=>_m,ZodEmail:()=>hm,ZodEmoji:()=>mm,ZodEnum:()=>fc,ZodExactOptional:()=>vS,ZodFile:()=>gS,ZodFunction:()=>MS,ZodGUID:()=>Ed,ZodIPv4:()=>Em,ZodIPv6:()=>Sm,ZodIntersection:()=>lS,ZodJWT:()=>Tm,ZodKSUID:()=>xm,ZodLazy:()=>PS,ZodLiteral:()=>mS,ZodMAC:()=>ZE,ZodMap:()=>pS,ZodNaN:()=>TS,ZodNanoID:()=>gm,ZodNever:()=>nS,ZodNonOptional:()=>Lm,ZodNull:()=>QE,ZodNullable:()=>bS,ZodNumber:()=>mc,ZodNumberFormat:()=>Ma,ZodObject:()=>Td,ZodOptional:()=>Dm,ZodPipe:()=>Od,ZodPrefault:()=>SS,ZodPreprocess:()=>CS,ZodPromise:()=>LS,ZodReadonly:()=>OS,ZodRecord:()=>dc,ZodSet:()=>hS,ZodString:()=>pc,ZodStringFormat:()=>er,ZodSuccess:()=>IS,ZodSymbol:()=>XE,ZodTemplateLiteral:()=>RS,ZodTransform:()=>yS,ZodTuple:()=>uS,ZodType:()=>Et,ZodULID:()=>wm,ZodURL:()=>Id,ZodUUID:()=>Es,ZodUndefined:()=>JE,ZodUnion:()=>Cd,ZodUnknown:()=>rS,ZodVoid:()=>iS,ZodXID:()=>bm,ZodXor:()=>oS,_ZodString:()=>pm,_default:()=>ES,_function:()=>q5,any:()=>x5,array:()=>_d,base64:()=>i5,base64url:()=>s5,bigint:()=>g5,boolean:()=>YE,catch:()=>_S,check:()=>H5,cidrv4:()=>r5,cidrv6:()=>n5,codec:()=>j5,cuid:()=>ZT,cuid2:()=>KT,custom:()=>G5,date:()=>S5,describe:()=>V5,discriminatedUnion:()=>T5,e164:()=>o5,email:()=>FT,emoji:()=>GT,enum:()=>Rm,exactOptional:()=>wS,file:()=>L5,float32:()=>f5,float64:()=>p5,function:()=>q5,guid:()=>UT,hash:()=>d5,hex:()=>u5,hostname:()=>c5,httpUrl:()=>HT,instanceof:()=>K5,int:()=>dm,int32:()=>h5,int64:()=>y5,intersection:()=>cS,invertCodec:()=>z5,ipv4:()=>QT,ipv6:()=>t5,json:()=>X5,jwt:()=>a5,keyof:()=>k5,ksuid:()=>JT,lazy:()=>DS,literal:()=>D5,looseObject:()=>$5,looseRecord:()=>O5,mac:()=>e5,map:()=>N5,meta:()=>Z5,nan:()=>U5,nanoid:()=>VT,nativeEnum:()=>P5,never:()=>Om,nonoptional:()=>AS,null:()=>eS,nullable:()=>kd,nullish:()=>M5,number:()=>KE,object:()=>A5,optional:()=>Sd,partialRecord:()=>C5,pipe:()=>fm,prefault:()=>kS,preprocess:()=>J5,promise:()=>W5,readonly:()=>NS,record:()=>fS,refine:()=>FS,set:()=>R5,strictObject:()=>I5,string:()=>xd,stringFormat:()=>l5,stringbool:()=>Y5,success:()=>F5,superRefine:()=>US,symbol:()=>w5,templateLiteral:()=>B5,transform:()=>Pm,tuple:()=>dS,uint32:()=>m5,uint64:()=>v5,ulid:()=>YT,undefined:()=>b5,union:()=>Nm,unknown:()=>La,url:()=>qT,uuid:()=>jT,uuidv4:()=>zT,uuidv6:()=>BT,uuidv7:()=>WT,void:()=>E5,xid:()=>XT,xor:()=>_5});var om={};ti(om,{endsWith:()=>tc,gt:()=>bs,gte:()=>_n,includes:()=>Ql,length:()=>Da,lowercase:()=>Xl,lt:()=>ws,lte:()=>ni,maxLength:()=>Pa,maxSize:()=>Uo,mime:()=>rc,minLength:()=>Ys,minSize:()=>xs,multipleOf:()=>Fo,negative:()=>Xh,nonnegative:()=>Qh,nonpositive:()=>Jh,normalize:()=>nc,overwrite:()=>Zi,positive:()=>Yh,property:()=>em,regex:()=>Yl,size:()=>Ra,slugify:()=>ac,startsWith:()=>ec,toLowerCase:()=>sc,toUpperCase:()=>oc,trim:()=>ic,uppercase:()=>Jl});var uc={};ti(uc,{ZodISODate:()=>lm,ZodISODateTime:()=>am,ZodISODuration:()=>um,ZodISOTime:()=>cm,date:()=>RE,datetime:()=>NE,duration:()=>DE,time:()=>PE});var am=se("ZodISODateTime",(e,t)=>{hb.init(e,t),er.init(e,t)});function NE(e){return p2(am,e)}l(NE,"datetime");var lm=se("ZodISODate",(e,t)=>{mb.init(e,t),er.init(e,t)});function RE(e){return h2(lm,e)}l(RE,"date");var cm=se("ZodISOTime",(e,t)=>{gb.init(e,t),er.init(e,t)});function PE(e){return m2(cm,e)}l(PE,"time");var um=se("ZodISODuration",(e,t)=>{yb.init(e,t),er.init(e,t)});function DE(e){return g2(um,e)}l(DE,"duration");var LT=l((e,t)=>{id.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:l(r=>od(e,r),"value")},flatten:{value:l(r=>sd(e,r),"value")},addIssue:{value:l(r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,zl,2)},"value")},addIssues:{value:l(r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,zl,2)},"value")},isEmpty:{get(){return e.issues.length===0}}})},"initializer"),vse=se("ZodError",LT),Wn=se("ZodError",LT,{Parent:Error});var LE=ql(Wn),ME=Hl(Wn),FE=Gl(Wn),UE=Vl(Wn),jE=ah(Wn),zE=lh(Wn),BE=ch(Wn),WE=uh(Wn),qE=dh(Wn),HE=fh(Wn),GE=ph(Wn),VE=hh(Wn);var MT=new WeakMap;function Ad(e,t,r){let n=Object.getPrototypeOf(e),i=MT.get(n);if(i||(i=new Set,MT.set(n,i)),!i.has(t)){i.add(t);for(let s in r){let o=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let a=o.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}l(Ad,"_installLazyMethods");var Et=se("ZodType",(e,t)=>(vt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:cc(e,"input"),output:cc(e,"output")}}),e.toJSONSchema=Z2(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>LE(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>FE(e,r,n),e.parseAsync=async(r,n)=>ME(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>UE(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>jE(e,r,n),e.decode=(r,n)=>zE(e,r,n),e.encodeAsync=async(r,n)=>BE(e,r,n),e.decodeAsync=async(r,n)=>WE(e,r,n),e.safeEncode=(r,n)=>qE(e,r,n),e.safeDecode=(r,n)=>HE(e,r,n),e.safeEncodeAsync=async(r,n)=>GE(e,r,n),e.safeDecodeAsync=async(r,n)=>VE(e,r,n),Ad(e,"ZodType",{check(...r){let n=this.def;return this.clone(De.mergeDefs(n,{checks:[...n.checks??[],...r.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return In(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(FS(r,n))},superRefine(r,n){return this.check(US(r,n))},overwrite(r){return this.check(Zi(r))},optional(){return Sd(this)},exactOptional(){return wS(this)},nullable(){return kd(this)},nullish(){return Sd(kd(this))},nonoptional(r){return AS(this,r)},array(){return _d(this)},or(r){return Nm([this,r])},and(r){return cS(this,r)},transform(r){return fm(this,Pm(r))},default(r){return ES(this,r)},prefault(r){return kS(this,r)},catch(r){return _S(this,r)},pipe(r){return fm(this,r)},readonly(){return NS(this)},describe(r){let n=this.clone();return nn.add(n,{description:r}),n},meta(...r){if(r.length===0)return nn.get(this);let n=this.clone();return nn.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return nn.get(e)?.description},configurable:!0}),e)),pm=se("_ZodString",(e,t)=>{Na.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,s)=>K2(e,n,i,s);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Ad(e,"_ZodString",{regex(...n){return this.check(Yl(...n))},includes(...n){return this.check(Ql(...n))},startsWith(...n){return this.check(ec(...n))},endsWith(...n){return this.check(tc(...n))},min(...n){return this.check(Ys(...n))},max(...n){return this.check(Pa(...n))},length(...n){return this.check(Da(...n))},nonempty(...n){return this.check(Ys(1,...n))},lowercase(n){return this.check(Xl(n))},uppercase(n){return this.check(Jl(n))},trim(){return this.check(ic())},normalize(...n){return this.check(nc(...n))},toLowerCase(){return this.check(sc())},toUpperCase(){return this.check(oc())},slugify(){return this.check(ac())}})}),pc=se("ZodString",(e,t)=>{Na.init(e,t),pm.init(e,t),e.email=r=>e.check(Ch(hm,r)),e.url=r=>e.check(wd(Id,r)),e.jwt=r=>e.check(Kh(Tm,r)),e.emoji=r=>e.check(Dh(mm,r)),e.guid=r=>e.check(vd(Ed,r)),e.uuid=r=>e.check(Oh(Es,r)),e.uuidv4=r=>e.check(Nh(Es,r)),e.uuidv6=r=>e.check(Rh(Es,r)),e.uuidv7=r=>e.check(Ph(Es,r)),e.nanoid=r=>e.check(Lh(gm,r)),e.guid=r=>e.check(vd(Ed,r)),e.cuid=r=>e.check(Mh(ym,r)),e.cuid2=r=>e.check(Fh(vm,r)),e.ulid=r=>e.check(Uh(wm,r)),e.base64=r=>e.check(Gh(Im,r)),e.base64url=r=>e.check(Vh($m,r)),e.xid=r=>e.check(jh(bm,r)),e.ksuid=r=>e.check(zh(xm,r)),e.ipv4=r=>e.check(Bh(Em,r)),e.ipv6=r=>e.check(Wh(Sm,r)),e.cidrv4=r=>e.check(qh(km,r)),e.cidrv6=r=>e.check(Hh(Am,r)),e.e164=r=>e.check(Zh(_m,r)),e.datetime=r=>e.check(NE(r)),e.date=r=>e.check(RE(r)),e.time=r=>e.check(PE(r)),e.duration=r=>e.check(DE(r))});function xd(e){return c2(pc,e)}l(xd,"string");var er=se("ZodStringFormat",(e,t)=>{Qt.init(e,t),pm.init(e,t)}),hm=se("ZodEmail",(e,t)=>{sb.init(e,t),er.init(e,t)});function FT(e){return Ch(hm,e)}l(FT,"email");var Ed=se("ZodGUID",(e,t)=>{nb.init(e,t),er.init(e,t)});function UT(e){return vd(Ed,e)}l(UT,"guid");var Es=se("ZodUUID",(e,t)=>{ib.init(e,t),er.init(e,t)});function jT(e){return Oh(Es,e)}l(jT,"uuid");function zT(e){return Nh(Es,e)}l(zT,"uuidv4");function BT(e){return Rh(Es,e)}l(BT,"uuidv6");function WT(e){return Ph(Es,e)}l(WT,"uuidv7");var Id=se("ZodURL",(e,t)=>{ob.init(e,t),er.init(e,t)});function qT(e){return wd(Id,e)}l(qT,"url");function HT(e){return wd(Id,{protocol:ri.httpProtocol,hostname:ri.domain,...De.normalizeParams(e)})}l(HT,"httpUrl");var mm=se("ZodEmoji",(e,t)=>{ab.init(e,t),er.init(e,t)});function GT(e){return Dh(mm,e)}l(GT,"emoji");var gm=se("ZodNanoID",(e,t)=>{lb.init(e,t),er.init(e,t)});function VT(e){return Lh(gm,e)}l(VT,"nanoid");var ym=se("ZodCUID",(e,t)=>{cb.init(e,t),er.init(e,t)});function ZT(e){return Mh(ym,e)}l(ZT,"cuid");var vm=se("ZodCUID2",(e,t)=>{ub.init(e,t),er.init(e,t)});function KT(e){return Fh(vm,e)}l(KT,"cuid2");var wm=se("ZodULID",(e,t)=>{db.init(e,t),er.init(e,t)});function YT(e){return Uh(wm,e)}l(YT,"ulid");var bm=se("ZodXID",(e,t)=>{fb.init(e,t),er.init(e,t)});function XT(e){return jh(bm,e)}l(XT,"xid");var xm=se("ZodKSUID",(e,t)=>{pb.init(e,t),er.init(e,t)});function JT(e){return zh(xm,e)}l(JT,"ksuid");var Em=se("ZodIPv4",(e,t)=>{vb.init(e,t),er.init(e,t)});function QT(e){return Bh(Em,e)}l(QT,"ipv4");var ZE=se("ZodMAC",(e,t)=>{bb.init(e,t),er.init(e,t)});function e5(e){return d2(ZE,e)}l(e5,"mac");var Sm=se("ZodIPv6",(e,t)=>{wb.init(e,t),er.init(e,t)});function t5(e){return Wh(Sm,e)}l(t5,"ipv6");var km=se("ZodCIDRv4",(e,t)=>{xb.init(e,t),er.init(e,t)});function r5(e){return qh(km,e)}l(r5,"cidrv4");var Am=se("ZodCIDRv6",(e,t)=>{Eb.init(e,t),er.init(e,t)});function n5(e){return Hh(Am,e)}l(n5,"cidrv6");var Im=se("ZodBase64",(e,t)=>{kb.init(e,t),er.init(e,t)});function i5(e){return Gh(Im,e)}l(i5,"base64");var $m=se("ZodBase64URL",(e,t)=>{Ab.init(e,t),er.init(e,t)});function s5(e){return Vh($m,e)}l(s5,"base64url");var _m=se("ZodE164",(e,t)=>{Ib.init(e,t),er.init(e,t)});function o5(e){return Zh(_m,e)}l(o5,"e164");var Tm=se("ZodJWT",(e,t)=>{$b.init(e,t),er.init(e,t)});function a5(e){return Kh(Tm,e)}l(a5,"jwt");var hc=se("ZodCustomStringFormat",(e,t)=>{_b.init(e,t),er.init(e,t)});function l5(e,t,r={}){return lc(hc,e,t,r)}l(l5,"stringFormat");function c5(e){return lc(hc,"hostname",ri.hostname,e)}l(c5,"hostname");function u5(e){return lc(hc,"hex",ri.hex,e)}l(u5,"hex");function d5(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,i=ri[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return lc(hc,n,i,t)}l(d5,"hash");var mc=se("ZodNumber",(e,t)=>{Sh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,s)=>Y2(e,n,i,s),Ad(e,"ZodNumber",{gt(n,i){return this.check(bs(n,i))},gte(n,i){return this.check(_n(n,i))},min(n,i){return this.check(_n(n,i))},lt(n,i){return this.check(ws(n,i))},lte(n,i){return this.check(ni(n,i))},max(n,i){return this.check(ni(n,i))},int(n){return this.check(dm(n))},safe(n){return this.check(dm(n))},positive(n){return this.check(bs(0,n))},nonnegative(n){return this.check(_n(0,n))},negative(n){return this.check(ws(0,n))},nonpositive(n){return this.check(ni(0,n))},multipleOf(n,i){return this.check(Fo(n,i))},step(n,i){return this.check(Fo(n,i))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function KE(e){return y2(mc,e)}l(KE,"number");var Ma=se("ZodNumberFormat",(e,t)=>{Tb.init(e,t),mc.init(e,t)});function dm(e){return w2(Ma,e)}l(dm,"int");function f5(e){return b2(Ma,e)}l(f5,"float32");function p5(e){return x2(Ma,e)}l(p5,"float64");function h5(e){return E2(Ma,e)}l(h5,"int32");function m5(e){return S2(Ma,e)}l(m5,"uint32");var gc=se("ZodBoolean",(e,t)=>{ud.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>X2(e,r,n,i)});function YE(e){return k2(gc,e)}l(YE,"boolean");var yc=se("ZodBigInt",(e,t)=>{kh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,s)=>J2(e,n,i,s),e.gte=(n,i)=>e.check(_n(n,i)),e.min=(n,i)=>e.check(_n(n,i)),e.gt=(n,i)=>e.check(bs(n,i)),e.gte=(n,i)=>e.check(_n(n,i)),e.min=(n,i)=>e.check(_n(n,i)),e.lt=(n,i)=>e.check(ws(n,i)),e.lte=(n,i)=>e.check(ni(n,i)),e.max=(n,i)=>e.check(ni(n,i)),e.positive=n=>e.check(bs(BigInt(0),n)),e.negative=n=>e.check(ws(BigInt(0),n)),e.nonpositive=n=>e.check(ni(BigInt(0),n)),e.nonnegative=n=>e.check(_n(BigInt(0),n)),e.multipleOf=(n,i)=>e.check(Fo(n,i));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function g5(e){return I2(yc,e)}l(g5,"bigint");var Cm=se("ZodBigIntFormat",(e,t)=>{Cb.init(e,t),yc.init(e,t)});function y5(e){return _2(Cm,e)}l(y5,"int64");function v5(e){return T2(Cm,e)}l(v5,"uint64");var XE=se("ZodSymbol",(e,t)=>{Ob.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Q2(e,r,n,i)});function w5(e){return C2(XE,e)}l(w5,"symbol");var JE=se("ZodUndefined",(e,t)=>{Nb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>tE(e,r,n,i)});function b5(e){return O2(JE,e)}l(b5,"_undefined");var QE=se("ZodNull",(e,t)=>{Rb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>eE(e,r,n,i)});function eS(e){return N2(QE,e)}l(eS,"_null");var tS=se("ZodAny",(e,t)=>{Pb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>iE(e,r,n,i)});function x5(){return R2(tS)}l(x5,"any");var rS=se("ZodUnknown",(e,t)=>{Db.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>sE(e,r,n,i)});function La(){return P2(rS)}l(La,"unknown");var nS=se("ZodNever",(e,t)=>{Lb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>nE(e,r,n,i)});function Om(e){return D2(nS,e)}l(Om,"never");var iS=se("ZodVoid",(e,t)=>{Mb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>rE(e,r,n,i)});function E5(e){return L2(iS,e)}l(E5,"_void");var $d=se("ZodDate",(e,t)=>{Fb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,s)=>oE(e,n,i,s),e.min=(n,i)=>e.check(_n(n,i)),e.max=(n,i)=>e.check(ni(n,i));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function S5(e){return M2($d,e)}l(S5,"date");var sS=se("ZodArray",(e,t)=>{Ub.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>vE(e,r,n,i),e.element=t.element,Ad(e,"ZodArray",{min(r,n){return this.check(Ys(r,n))},nonempty(r){return this.check(Ys(1,r))},max(r,n){return this.check(Pa(r,n))},length(r,n){return this.check(Da(r,n))},unwrap(){return this.element}})});function _d(e,t){return j2(sS,e,t)}l(_d,"array");function k5(e){let t=e._zod.def.shape;return Rm(Object.keys(t))}l(k5,"keyof");var Td=se("ZodObject",(e,t)=>{jb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>wE(e,r,n,i),De.defineLazy(e,"shape",()=>t.shape),Ad(e,"ZodObject",{keyof(){return Rm(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:La()})},loose(){return this.clone({...this._zod.def,catchall:La()})},strict(){return this.clone({...this._zod.def,catchall:Om()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return De.extend(this,r)},safeExtend(r){return De.safeExtend(this,r)},merge(r){return De.merge(this,r)},pick(r){return De.pick(this,r)},omit(r){return De.omit(this,r)},partial(...r){return De.partial(Dm,this,r[0])},required(...r){return De.required(Lm,this,r[0])}})});function A5(e,t){let r={type:"object",shape:e??{},...De.normalizeParams(t)};return new Td(r)}l(A5,"object");function I5(e,t){return new Td({type:"object",shape:e,catchall:Om(),...De.normalizeParams(t)})}l(I5,"strictObject");function $5(e,t){return new Td({type:"object",shape:e,catchall:La(),...De.normalizeParams(t)})}l($5,"looseObject");var Cd=se("ZodUnion",(e,t)=>{dd.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>rm(e,r,n,i),e.options=t.options});function Nm(e,t){return new Cd({type:"union",options:e,...De.normalizeParams(t)})}l(Nm,"union");var oS=se("ZodXor",(e,t)=>{Cd.init(e,t),zb.init(e,t),e._zod.processJSONSchema=(r,n,i)=>rm(e,r,n,i),e.options=t.options});function _5(e,t){return new oS({type:"union",options:e,inclusive:!1,...De.normalizeParams(t)})}l(_5,"xor");var aS=se("ZodDiscriminatedUnion",(e,t)=>{Cd.init(e,t),Bb.init(e,t)});function T5(e,t,r){return new aS({type:"union",options:t,discriminator:e,...De.normalizeParams(r)})}l(T5,"discriminatedUnion");var lS=se("ZodIntersection",(e,t)=>{Wb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>bE(e,r,n,i)});function cS(e,t){return new lS({type:"intersection",left:e,right:t})}l(cS,"intersection");var uS=se("ZodTuple",(e,t)=>{Ah.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>xE(e,r,n,i),e.rest=r=>e.clone({...e._zod.def,rest:r})});function dS(e,t,r){let n=t instanceof vt,i=n?r:t,s=n?t:null;return new uS({type:"tuple",items:e,rest:s,...De.normalizeParams(i)})}l(dS,"tuple");var dc=se("ZodRecord",(e,t)=>{qb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>EE(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType});function fS(e,t,r){return!t||!t._zod?new dc({type:"record",keyType:xd(),valueType:e,...De.normalizeParams(t)}):new dc({type:"record",keyType:e,valueType:t,...De.normalizeParams(r)})}l(fS,"record");function C5(e,t,r){let n=In(e);return n._zod.values=void 0,new dc({type:"record",keyType:n,valueType:t,...De.normalizeParams(r)})}l(C5,"partialRecord");function O5(e,t,r){return new dc({type:"record",keyType:e,valueType:t,mode:"loose",...De.normalizeParams(r)})}l(O5,"looseRecord");var pS=se("ZodMap",(e,t)=>{Hb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>gE(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(xs(...r)),e.nonempty=r=>e.check(xs(1,r)),e.max=(...r)=>e.check(Uo(...r)),e.size=(...r)=>e.check(Ra(...r))});function N5(e,t,r){return new pS({type:"map",keyType:e,valueType:t,...De.normalizeParams(r)})}l(N5,"map");var hS=se("ZodSet",(e,t)=>{Gb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>yE(e,r,n,i),e.min=(...r)=>e.check(xs(...r)),e.nonempty=r=>e.check(xs(1,r)),e.max=(...r)=>e.check(Uo(...r)),e.size=(...r)=>e.check(Ra(...r))});function R5(e,t){return new hS({type:"set",valueType:e,...De.normalizeParams(t)})}l(R5,"set");var fc=se("ZodEnum",(e,t)=>{Vb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,s)=>aE(e,n,i,s),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let s={};for(let o of n)if(r.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new fc({...t,checks:[],...De.normalizeParams(i),entries:s})},e.exclude=(n,i)=>{let s={...t.entries};for(let o of n)if(r.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new fc({...t,checks:[],...De.normalizeParams(i),entries:s})}});function Rm(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new fc({type:"enum",entries:r,...De.normalizeParams(t)})}l(Rm,"_enum");function P5(e,t){return new fc({type:"enum",entries:e,...De.normalizeParams(t)})}l(P5,"nativeEnum");var mS=se("ZodLiteral",(e,t)=>{Zb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>lE(e,r,n,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function D5(e,t){return new mS({type:"literal",values:Array.isArray(e)?e:[e],...De.normalizeParams(t)})}l(D5,"literal");var gS=se("ZodFile",(e,t)=>{Kb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>dE(e,r,n,i),e.min=(r,n)=>e.check(xs(r,n)),e.max=(r,n)=>e.check(Uo(r,n)),e.mime=(r,n)=>e.check(rc(Array.isArray(r)?r:[r],n))});function L5(e){return z2(gS,e)}l(L5,"file");var yS=se("ZodTransform",(e,t)=>{Yb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>mE(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ro(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(De.issue(s,r.value,t));else{let o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(De.issue(o))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=i,r.fallback=!0,r)}});function Pm(e){return new yS({type:"transform",transform:e})}l(Pm,"transform");var Dm=se("ZodOptional",(e,t)=>{Ih.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>nm(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Sd(e){return new Dm({type:"optional",innerType:e})}l(Sd,"optional");var vS=se("ZodExactOptional",(e,t)=>{Xb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>nm(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function wS(e){return new vS({type:"optional",innerType:e})}l(wS,"exactOptional");var bS=se("ZodNullable",(e,t)=>{Jb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>SE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function kd(e){return new bS({type:"nullable",innerType:e})}l(kd,"nullable");function M5(e){return Sd(kd(e))}l(M5,"nullish");var xS=se("ZodDefault",(e,t)=>{Qb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>AE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ES(e,t){return new xS({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():De.shallowClone(t)}})}l(ES,"_default");var SS=se("ZodPrefault",(e,t)=>{ex.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>IE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function kS(e,t){return new SS({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():De.shallowClone(t)}})}l(kS,"prefault");var Lm=se("ZodNonOptional",(e,t)=>{tx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>kE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function AS(e,t){return new Lm({type:"nonoptional",innerType:e,...De.normalizeParams(t)})}l(AS,"nonoptional");var IS=se("ZodSuccess",(e,t)=>{rx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function F5(e){return new IS({type:"success",innerType:e})}l(F5,"success");var $S=se("ZodCatch",(e,t)=>{nx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>$E(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _S(e,t){return new $S({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}l(_S,"_catch");var TS=se("ZodNaN",(e,t)=>{ix.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>cE(e,r,n,i)});function U5(e){return U2(TS,e)}l(U5,"nan");var Od=se("ZodPipe",(e,t)=>{$h.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_E(e,r,n,i),e.in=t.in,e.out=t.out});function fm(e,t){return new Od({type:"pipe",in:e,out:t})}l(fm,"pipe");var Nd=se("ZodCodec",(e,t)=>{Od.init(e,t),fd.init(e,t)});function j5(e,t,r){return new Nd({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}l(j5,"codec");function z5(e){let t=e._zod.def;return new Nd({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}l(z5,"invertCodec");var CS=se("ZodPreprocess",(e,t)=>{Od.init(e,t),sx.init(e,t)}),OS=se("ZodReadonly",(e,t)=>{ox.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>TE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function NS(e){return new OS({type:"readonly",innerType:e})}l(NS,"readonly");var RS=se("ZodTemplateLiteral",(e,t)=>{ax.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>uE(e,r,n,i)});function B5(e,t){return new RS({type:"template_literal",parts:e,...De.normalizeParams(t)})}l(B5,"templateLiteral");var PS=se("ZodLazy",(e,t)=>{ux.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>OE(e,r,n,i),e.unwrap=()=>e._zod.def.getter()});function DS(e){return new PS({type:"lazy",getter:e})}l(DS,"lazy");var LS=se("ZodPromise",(e,t)=>{cx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>CE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function W5(e){return new LS({type:"promise",innerType:e})}l(W5,"promise");var MS=se("ZodFunction",(e,t)=>{lx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>hE(e,r,n,i)});function q5(e){return new MS({type:"function",input:Array.isArray(e?.input)?dS(e?.input):e?.input??_d(La()),output:e?.output??La()})}l(q5,"_function");var Rd=se("ZodCustom",(e,t)=>{dx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>pE(e,r,n,i)});function H5(e){let t=new or({check:"custom"});return t._zod.check=e,t}l(H5,"check");function G5(e,t){return B2(Rd,e??(()=>!0),t)}l(G5,"custom");function FS(e,t={}){return W2(Rd,e,t)}l(FS,"refine");function US(e,t){return q2(e,t)}l(US,"superRefine");var V5=H2,Z5=G2;function K5(e,t={}){let r=new Rd({type:"custom",check:"custom",fn:l(n=>n instanceof e,"fn"),abort:!0,...De.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}l(K5,"_instanceof");var Y5=l((...e)=>V2({Codec:Nd,Boolean:gc,String:pc},...e),"stringbool");function X5(e){let t=DS(()=>Nm([xd(e),KE(),YE(),eS(),_d(t),fS(xd(),t)]));return t}l(X5,"json");function J5(e,t){return new CS({type:"pipe",in:Pm(e),out:t})}l(J5,"preprocess");var bse={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function xse(e){_r({customError:e})}l(xse,"setErrorMap");function Ese(){return _r().customError}l(Ese,"getErrorMap");var jS;jS||(jS={});var Ze={...bd,...om,iso:uc},Sse=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function kse(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}l(kse,"detectVersion");function Ase(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let i=r[1];if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}l(Ase,"resolveRef");function Q5(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return Ze.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return Ze.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);let s=Ase(i,t),o=mn(s,t);return t.refs.set(i,o),t.processing.delete(i),o}if(e.enum!==void 0){let i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return Ze.null();if(i.length===0)return Ze.never();if(i.length===1)return Ze.literal(i[0]);if(i.every(o=>typeof o=="string"))return Ze.enum(i);let s=i.map(o=>Ze.literal(o));return s.length<2?s[0]:Ze.union([s[0],s[1],...s.slice(2)])}if(e.const!==void 0)return Ze.literal(e.const);let r=e.type;if(Array.isArray(r)){let i=r.map(s=>{let o={...e,type:s};return Q5(o,t)});return i.length===0?Ze.never():i.length===1?i[0]:Ze.union(i)}if(!r)return Ze.any();let n;switch(r){case"string":{let i=Ze.string();if(e.format){let s=e.format;s==="email"?i=i.check(Ze.email()):s==="uri"||s==="uri-reference"?i=i.check(Ze.url()):s==="uuid"||s==="guid"?i=i.check(Ze.uuid()):s==="date-time"?i=i.check(Ze.iso.datetime()):s==="date"?i=i.check(Ze.iso.date()):s==="time"?i=i.check(Ze.iso.time()):s==="duration"?i=i.check(Ze.iso.duration()):s==="ipv4"?i=i.check(Ze.ipv4()):s==="ipv6"?i=i.check(Ze.ipv6()):s==="mac"?i=i.check(Ze.mac()):s==="cidr"?i=i.check(Ze.cidrv4()):s==="cidr-v6"?i=i.check(Ze.cidrv6()):s==="base64"?i=i.check(Ze.base64()):s==="base64url"?i=i.check(Ze.base64url()):s==="e164"?i=i.check(Ze.e164()):s==="jwt"?i=i.check(Ze.jwt()):s==="emoji"?i=i.check(Ze.emoji()):s==="nanoid"?i=i.check(Ze.nanoid()):s==="cuid"?i=i.check(Ze.cuid()):s==="cuid2"?i=i.check(Ze.cuid2()):s==="ulid"?i=i.check(Ze.ulid()):s==="xid"?i=i.check(Ze.xid()):s==="ksuid"&&(i=i.check(Ze.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),n=i;break}case"number":case"integer":{let i=r==="integer"?Ze.number().int():Ze.number();typeof e.minimum=="number"&&(i=i.min(e.minimum)),typeof e.maximum=="number"&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum=="number"?i=i.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),n=i;break}case"boolean":{n=Ze.boolean();break}case"null":{n=Ze.null();break}case"object":{let i={},s=e.properties||{},o=new Set(e.required||[]);for(let[c,u]of Object.entries(s)){let d=mn(u,t);i[c]=o.has(c)?d:d.optional()}if(e.propertyNames){let c=mn(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?mn(e.additionalProperties,t):Ze.any();if(Object.keys(i).length===0){n=Ze.record(c,u);break}let d=Ze.object(i).passthrough(),f=Ze.looseRecord(c,u);n=Ze.intersection(d,f);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),d=[];for(let p of u){let h=mn(c[p],t),m=Ze.string().regex(new RegExp(p));d.push(Ze.looseRecord(m,h))}let f=[];if(Object.keys(i).length>0&&f.push(Ze.object(i).passthrough()),f.push(...d),f.length===0)n=Ze.object({}).passthrough();else if(f.length===1)n=f[0];else{let p=Ze.intersection(f[0],f[1]);for(let h=2;h<f.length;h++)p=Ze.intersection(p,f[h]);n=p}break}let a=Ze.object(i);e.additionalProperties===!1?n=a.strict():typeof e.additionalProperties=="object"?n=a.catchall(mn(e.additionalProperties,t)):n=a.passthrough();break}case"array":{let i=e.prefixItems,s=e.items;if(i&&Array.isArray(i)){let o=i.map(c=>mn(c,t)),a=s&&typeof s=="object"&&!Array.isArray(s)?mn(s,t):void 0;a?n=Ze.tuple(o).rest(a):n=Ze.tuple(o),typeof e.minItems=="number"&&(n=n.check(Ze.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(Ze.maxLength(e.maxItems)))}else if(Array.isArray(s)){let o=s.map(c=>mn(c,t)),a=e.additionalItems&&typeof e.additionalItems=="object"?mn(e.additionalItems,t):void 0;a?n=Ze.tuple(o).rest(a):n=Ze.tuple(o),typeof e.minItems=="number"&&(n=n.check(Ze.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(Ze.maxLength(e.maxItems)))}else if(s!==void 0){let o=mn(s,t),a=Ze.array(o);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),n=a}else n=Ze.array(Ze.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n}l(Q5,"convertBaseSchema");function mn(e,t){if(typeof e=="boolean")return e?Ze.any():Ze.never();let r=Q5(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(u=>mn(u,t)),c=Ze.union(a);r=n?Ze.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(u=>mn(u,t)),c=Ze.xor(a);r=n?Ze.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:Ze.any();else{let a=n?r:mn(e.allOf[0],t),c=n?0:1;for(let u=c;u<e.allOf.length;u++)a=Ze.intersection(a,mn(e.allOf[u],t));r=a}e.nullable===!0&&t.version==="openapi-3.0"&&(r=Ze.nullable(r)),e.readOnly===!0&&(r=Ze.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let i={},s=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of s)a in e&&(i[a]=e[a]);let o=["contentEncoding","contentMediaType","contentSchema"];for(let a of o)a in e&&(i[a]=e[a]);for(let a of Object.keys(e))Sse.has(a)||(i[a]=e[a]);return Object.keys(i).length>0&&t.registry.add(r,i),e.description&&(r=r.describe(e.description)),r}l(mn,"convertSchema");function eC(e,t){if(typeof e=="boolean")return e?Ze.any():Ze.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let n=kse(r,t?.defaultTarget),i=r.$defs||r.definitions||{},s={version:n,defs:i,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??nn};return mn(r,s)}l(eC,"fromJSONSchema");var zS={};ti(zS,{bigint:()=>Tse,boolean:()=>_se,date:()=>Cse,number:()=>$se,string:()=>Ise});function Ise(e){return u2(pc,e)}l(Ise,"string");function $se(e){return v2(mc,e)}l($se,"number");function _se(e){return A2(gc,e)}l(_se,"boolean");function Tse(e){return $2(yc,e)}l(Tse,"bigint");function Cse(e){return F2($d,e)}l(Cse,"date");_r(pd());var Mm=v.string(),Ose=v.discriminatedUnion("code",[v.object({code:v.literal("bad-request"),message:v.string(),details:v.object({issues:v.array(v.custom())})}),v.object({code:v.literal("cancelled"),message:v.string(),details:v.object({})}),v.object({code:v.literal("session-not-found"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("model-unavailable"),message:v.string(),details:v.object({provider:v.string(),model:v.string()})}),v.object({code:v.literal("session-conflict"),message:v.string(),details:v.object({sessionId:v.string(),requestedCwd:v.string(),existingCwd:v.string().optional()})}),v.object({code:v.literal("invalid-time-zone"),message:v.string(),details:v.object({value:v.string()})}),v.object({code:v.literal("workspace-attach-failed"),message:v.string(),details:v.object({sessionId:v.string(),workspaceId:v.string()})}),v.object({code:v.literal("workspace-not-found"),message:v.string(),details:v.object({workspaceId:v.string()})}),v.object({code:v.literal("workspace-invalid-path"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("workspace-name-conflict"),message:v.string(),details:v.object({name:v.string()})}),v.object({code:v.literal("workspace-move-invalid"),message:v.string(),details:v.object({workspaceId:v.string(),sessionId:v.string(),beforeSessionId:v.string().optional()})}),v.object({code:v.literal("directory-unreadable"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-exists"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-create-failed"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-picker-unavailable"),message:v.string(),details:v.object({capability:v.string()})}),v.object({code:v.literal("agent-preset-read-only"),message:v.string(),details:v.object({agentPreset:v.string(),reason:v.string()})}),v.object({code:v.literal("agent-preset-locked"),message:v.string(),details:v.object({sessionId:v.string(),agentPreset:v.string()})}),v.object({code:v.literal("agent-preset-conflict"),message:v.string(),details:v.object({sessionId:v.string(),requestedPreset:v.string(),existingPreset:v.string().optional()})}),v.object({code:v.literal("agent-preset-not-found"),message:v.string(),details:v.object({agentPreset:v.string(),available:v.array(v.string())})}),v.object({code:v.literal("agent-preset-invalid"),message:v.string(),details:v.object({agentPreset:v.string(),reason:v.string()})}),v.object({code:v.literal("agent-busy"),message:v.string(),details:v.object({reason:v.string()})}),v.object({code:v.literal("attachment-error"),message:v.string(),details:v.object({reason:v.string()})}),v.object({code:v.literal("queue-item-not-found"),message:v.string(),details:v.object({itemId:v.string()})}),v.object({code:v.literal("steer-unavailable"),message:v.string(),details:v.object({itemId:v.string()})}),v.object({code:v.literal("command-error"),message:v.string(),details:v.object({})}),v.object({code:v.literal("unknown-command"),message:v.string(),details:v.object({})}),v.object({code:v.literal("settings-rejected"),message:v.string(),details:v.object({ns:v.string()})}),v.object({code:v.literal("settings-conflict"),message:v.string(),details:v.object({ns:v.string(),expected:v.number(),actual:v.number()})}),v.object({code:v.literal("credential-rejected"),message:v.string(),details:v.object({ref:v.string()})}),v.object({code:v.literal("model-discovery-failed"),message:v.string(),details:v.object({settingsNs:v.string(),baseURL:v.string().optional()})}),v.object({code:v.literal("title-invalid"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("fork-unavailable"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("subagent-parent-unavailable"),message:v.string(),details:v.object({parentSessionId:v.string()})}),v.object({code:v.literal("subagent-not-found"),message:v.string(),details:v.object({parentSessionId:v.string(),childSessionId:v.string()})}),v.object({code:v.literal("subagent-catalog-diagnostic"),message:v.string(),details:v.object({parentSessionId:v.string(),childSessionId:v.string(),reason:v.union([v.literal("corrupt"),v.literal("unsupported"),v.literal("unavailable")])})}),v.object({code:v.literal("subagent-not-resumable"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("subagent-unauthorized"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("subagent-delivery-unavailable"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("internal"),message:v.string(),details:v.object({})})]);function tC(e){return v.union([v.object({ok:v.literal(!0),value:e}),v.object({ok:v.literal(!1),error:Ose})])}l(tC,"rpcResultSchema");var Fm=v.object({type:v.literal("client-request"),rpcId:Mm,method:v.string(),payload:v.unknown()}),rC=v.object({type:v.literal("server-response"),rpcId:Mm,result:tC(v.unknown().optional())}),nC=v.object({type:v.literal("server-request"),rpcId:Mm,method:v.string(),payload:v.unknown()}),Nse=v.object({type:v.literal("client-response"),rpcId:Mm,result:tC(v.unknown().optional())}),s5e=v.discriminatedUnion("type",[Fm,rC,nC,Nse]),o5e=v.union([v.object({accepted:v.literal(!0)}),v.object({accepted:v.literal(!1),reason:v.union([v.literal("not-pending"),v.literal("bad-response")])})]);var Pse=/(?:\u001B\]|\u009D)(?:(?!\u0007|\u001B\\)[\s\S])*(?:\u0007|\u001B\\|$)/gu,Dse=/(?:\u001B\[|\u009B)[0-?]*[ -/]*[@-~]/gu,Lse=/\u001B[@-_]/gu,Mse=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/gu,Fse=/[\u200B\u200E\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF]/gu;function oC(e,t){if(!Number.isInteger(t)||t<=0)throw new Error(`${e} must be a positive integer`)}l(oC,"assertPositiveInteger$1");function aC(e){return e.replace(Pse,"").replace(Dse,"").replace(Lse,"").replace(Mse,"").replace(Fse,"").replace(/\s+/gu," ").trim()}l(aC,"cleanTitleText");function lC(e,t){if(oC("maxBytes",t),Buffer.byteLength(e,"utf8")<=t)return e;let r=0,n="";for(let i of e){let s=Buffer.byteLength(i,"utf8");if(r+s>t)break;n+=i,r+=s}return n}l(lC,"truncateTitleUtf8");function Wo(e,t){return lC(aC(e),t).trimEnd()}l(Wo,"normalizeSessionTitle");function sC(e,t,r){return oC("maxWords",t),lC(aC(e).split(" ").filter(Boolean).slice(0,t).join(" "),r).trimEnd()}l(sC,"fallbackSessionTitle");var qS=class extends Error{static{l(this,"SessionTitleInvalidError")}name="SessionTitleInvalidError"};function Pd(e,t){let r=[];for(let n of e){if(t!==void 0&&n.seq>t)break;if(n.type!=="user/message"||n.data.source.kind!=="user")continue;let i=n.data.content.filter(s=>s.type==="text").map(s=>s.text).join(`
|
|
429
|
-
`);Wo(i,Number.MAX_SAFE_INTEGER).length!==0&&r.push({seq:n.seq,text:i})}return r}l(Pd,"collectSessionTitleMessages");function Fa(e){let t=e.findLast(r=>r.type==="session/title");if(t!==void 0)return gr({title:t.data.title,messageSeqs:[...t.data.messageSeqs],source:Use(t.data.source),eventSeq:t.seq,updatedAt:t.time})}l(Fa,"foldSessionTitle");function Use(e){switch(e.kind){case"fallback":return{kind:"fallback"};case"provider":return{kind:"provider",provider:e.provider,...e.model===void 0?{}:{model:{...e.model}}};case"user":return{kind:"user"};default:return An(e,"SessionTitleSource")}}l(Use,"copySessionTitleSource");function WS(e,t){if(!Number.isInteger(t)||t<=0)throw new Error(`session-title: ${e} must be a positive integer`)}l(WS,"assertPositiveInteger");var b5e=class extends ut{static{l(this,"SessionTitleService")}static inject=["sessions"];static Config=re.object({fallbackMaxWords:re.number().step(1).min(1).required(),fallbackMaxBytes:re.number().step(1).min(1).required(),maxTitleBytes:re.number().step(1).min(1).required()});config;ownerFiber;registration;work=new Map;lifetime=new AbortController;inFlight=new Set;constructor(e,t){super(e,"sessionTitle"),this.ownerFiber=e.fiber;let r=t;if(r===null||typeof r!="object")throw new Error("session-title: configuration is required");let n=r;if(WS("fallbackMaxWords",n.fallbackMaxWords),WS("fallbackMaxBytes",n.fallbackMaxBytes),WS("maxTitleBytes",n.maxTitleBytes),n.fallbackMaxBytes>n.maxTitleBytes)throw new Error("session-title: fallbackMaxBytes must not exceed maxTitleBytes");this.config=gr({...n}),e.effect(()=>async()=>{this.lifetime.abort(new Error("session-title service disposed")),this.registration!==void 0&&(this.registration.closing=!0),this.registration=void 0;for(let i of this.work.values())delete i.pending,i.active?.controller.abort(new Error("session-title service disposed"));await this.drain(this.inFlight),this.work.clear()},"sessionTitle lifecycle"),e.inject(["sessionProjections"],i=>{let s=v.union([v.string().min(1),v.null()]);i.sessionProjections.register({key:"title",stateSchema:s,init:l(()=>null,"init"),apply:l((o,a)=>a.type==="session/title"?a.data.title:o,"apply"),wire:{viewSchema:s,view:l(o=>o,"view")},stateVersion:1})}),e.on("session/event",(i,s)=>{switch(s.type){case"user/message":this.onUserMessage(i,s);break;case"request/header":this.onRequestHeader(i,s);break;default:break}}),e.on("llm/stream",(i,s)=>(this.onMainRequest(i),s()),{global:!0,prepend:!0}),e.on("session/disposed",i=>{let s=this.work.get(i);s!==void 0&&(s.active?.controller.abort(new Error("session disposed during title generation")),this.work.delete(i))})}get(e){return Fa(e.events)}rename(e,t){if(this.assertServiceActive(),this.ctx.sessions.get(e.id)!==e)throw new Error(`session "${e.id}" is not live in this store`);let r=Wo(t,this.config.maxTitleBytes);if(r.length===0)throw new qS("session title must contain visible characters");let n=this.stateFor(e);this.supersede(n,"user rename superseded automatic title generation"),e.append("session/title",{title:r,messageSeqs:[],source:{kind:"user"}});let i=this.get(e);if(i===void 0)throw new Error("renamed title failed to fold");return i}async refresh(e,t){if(t?.throwIfAborted(),this.assertServiceActive(),this.ctx.sessions.get(e.id)!==e)throw new Error(`session "${e.id}" is not live in this store`);let r=this.registration,n=Pd(e.events),i=n.at(-1);if(r===void 0||r.closing||i===void 0){let d=this.get(e),[f]=n;if(d?.source.kind==="user"&&f!==void 0)return this.appendFallback(e,f),t?.throwIfAborted(),this.get(e);let p=await this.ensureFallback(e);return t?.throwIfAborted(),p}let s=this.stateFor(e),o=this.supersede(s,"explicit title refresh superseded older generation"),a=this.activate({registration:r,revision:o,throughSeq:i.seq},s,t),c=e.requestHeader()?.config,u=c===void 0?void 0:{provider:c.provider,model:c.model};return this.startProvider(e,a,u)}register(e){if(this.validateProvider(e),this.registration!==void 0)throw new Error(`session-title provider "${this.registration.provider.id}" is already registered`);let t={provider:e,active:new Set,closing:!1};return this.ctx.effect(function*(){this.registration=t,yield async()=>{t.closing=!0;for(let r of this.work.values())r.pending?.registration===t&&delete r.pending,r.active?.registration===t&&r.active.controller.abort(new Error(`session-title provider "${e.id}" was disposed`));await this.drain(t.active),this.registration===t&&(this.registration=void 0)}}.bind(this),"sessionTitle.register()")}onUserMessage(e,t){if(!this.serviceActive()||t.data.source.kind!=="user"||Pd([t]).length===0||this.get(e)?.source.kind==="user")return;let r=this.registration;if(r!==void 0&&!r.closing){let n=Pd(e.events,t.seq);if(r.provider.automatic==="all-prompts"||e.header.parentSession===void 0&&n.length===1&&this.get(e)===void 0){let i=this.stateFor(e);i.pending={registration:r,revision:this.supersede(i,"newer user message superseded title generation"),throughSeq:t.seq}}}this.defer(async()=>{try{await this.ensureFallback(e)}catch(n){if(!this.serviceActive())return;this.ctx.logger.warn(`session "${e.id}": fallback title update failed: ${String(n)}`)}})}onRequestHeader(e,t){if(!this.serviceActive())return;let r=this.work.get(e),n=r?.pending;if(r===void 0||n===void 0||n.throughSeq>=t.seq)return;let i={provider:t.data.header.config.provider,model:t.data.header.config.model};this.startPending(e,r,n,i)}onMainRequest(e){if(!this.serviceActive()||e.sessionId===void 0||!s_(e))return;let t=this.ctx.sessions.get(e.sessionId),r=t===void 0?void 0:this.work.get(t),n=r?.pending;if(t===void 0||r===void 0||n===void 0)return;let i=t.events.findLast(o=>o.type==="step/start"||o.type==="step/end"),s=t.requestHeader()?.config;i?.type!=="step/start"||i.seq<=n.throughSeq||s?.provider!==e.provider||s.model!==e.model||this.startPending(t,r,n,{provider:e.provider,model:e.model})}startPending(e,t,r,n){delete t.pending,this.defer(async()=>{if(this.registration!==r.registration||r.registration.closing||this.work.get(e)!==t||t.revision!==r.revision)return;let i=this.activate(r,t);try{await this.startProvider(e,i,n)}catch(s){if(i.signal.aborted||!this.serviceActive())return;this.ctx.logger.warn(`session "${e.id}": automatic title generation failed: ${String(s)}`)}})}startProvider(e,t,r){let n=Promise.resolve().then(()=>this.runProvider(e,t,r));return this.track(n,t.registration)}async runProvider(e,t,r){try{this.assertCurrent(e,t),await this.ensureFallback(e),this.assertCurrent(e,t);let n=Pd(e.events,t.throughSeq),i=await t.registration.provider.generate({session:e,messages:n,...r===void 0?{}:{route:r},signal:t.signal});this.assertCurrent(e,t);let s=this.validateResult(i,n);return e.append("session/title",{title:s.title,messageSeqs:[...s.messageSeqs],source:{kind:"provider",provider:t.registration.provider.id,...s.model===void 0?{}:{model:s.model}}}),this.get(e)}finally{let n=this.work.get(e);n?.active===t&&delete n.active}}validateResult(e,t){if(e===null||typeof e!="object")throw new Error("session-title provider returned an invalid result");let r=e;if(typeof r.title!="string")throw new Error("session-title provider title must be a string");let n=Wo(r.title,this.config.maxTitleBytes);if(n.length===0)throw new Error("session-title provider returned an empty title");if(!Array.isArray(r.messageSeqs)||r.messageSeqs.length===0)throw new Error("session-title provider must identify at least one source message seq");let i=[],s=new Map(t.map((u,d)=>[u.seq,d])),o=-1;for(let u of r.messageSeqs){if(typeof u!="number")throw new Error("session-title provider messageSeqs must be unique, ordered seqs from the request");let d=s.get(u);if(!Number.isSafeInteger(u)||u<0||d===void 0||d<=o)throw new Error("session-title provider messageSeqs must be unique, ordered seqs from the request");i.push(u),o=d}let a=r.model,c;if(a!==void 0){if(a===null||typeof a!="object")throw new Error("session-title provider result model must contain non-empty provider and model strings");let u=a;if(typeof u.provider!="string"||u.provider.length===0||typeof u.model!="string"||u.model.length===0)throw new Error("session-title provider result model must contain non-empty provider and model strings");c={provider:u.provider,model:u.model}}return{title:n,messageSeqs:i,...c===void 0?{}:{model:c}}}assertCurrent(e,t){this.assertServiceActive(),t.signal.throwIfAborted();let r=this.work.get(e);if(this.registration!==t.registration||r?.active!==t||r.revision!==t.revision||this.ctx.sessions.get(e.id)!==e)throw new Error("session title generation state changed without cancellation")}activate(e,t,r){let n=new AbortController,i=r===void 0?AbortSignal.any([n.signal,this.lifetime.signal]):AbortSignal.any([n.signal,this.lifetime.signal,r]),s={...e,controller:n,signal:i};return t.active=s,s}supersede(e,t){return e.active?.controller.abort(new Error(t)),delete e.pending,e.revision+=1,e.revision}stateFor(e){let t=this.work.get(e);return t===void 0&&(t={revision:0},this.work.set(e,t)),t}defer(e){let t=Promise.resolve().then(async()=>{this.serviceActive()&&await e()});this.track(t)}track(e,t){this.inFlight.add(e),t?.active.add(e);let r=l(()=>{this.inFlight.delete(e),t?.active.delete(e)},"settled");return e.then(r,r),e}async drain(e){for(;e.size>0;)await Promise.allSettled([...e])}serviceActive(){return!this.lifetime.signal.aborted&&this.ownerFiber.uid!==null&&this.ownerFiber.state===2}assertServiceActive(){if(!this.serviceActive())throw new Error("session-title service disposed")}validateProvider(e){if(e===null||typeof e!="object")throw new Error("session-title provider must be an object");let t=e;if(typeof t.id!="string"||t.id.length===0)throw new Error("session-title provider id must be a non-empty string");if(t.automatic!=="first-prompt"&&t.automatic!=="all-prompts")throw new Error("session-title provider automatic mode is invalid");if(typeof t.generate!="function")throw new Error(`session-title provider "${t.id}" requires generate()`)}appendFallback(e,t){let r=sC(t.text,this.config.fallbackMaxWords,this.config.fallbackMaxBytes);r.length!==0&&e.append("session/title",{title:r,messageSeqs:[t.seq],source:{kind:"fallback"}})}async ensureFallback(e){this.assertServiceActive();let t=this.get(e);if(t!==void 0)return t;let[r]=Pd(e.events);if(r===void 0)return;let n=sC(r.text,this.config.fallbackMaxWords,this.config.fallbackMaxBytes);if(n.length===0)return;let i=this.stateFor(e);if(i.fallback!==void 0)return i.fallback;let s=Promise.resolve().then(()=>{if(this.assertServiceActive(),this.ctx.sessions.get(e.id)!==e)throw new Error(`session "${e.id}" is not live in this store`);let o=this.get(e);return o!==void 0?o:(e.append("session/title",{title:n,messageSeqs:[r.seq],source:{kind:"fallback"}}),this.get(e))});i.fallback=s;try{return await s}finally{delete i.fallback}}};var Ld=class extends Wr{static{l(this,"SessionQueryError")}constructor(e,t,r){super(e,t,r)}};function jse(e){switch(e.type){case"user/message":return HS(e.data.content);case"assistant/message":return HS(e.data.message.content);case"tool/call":return Dd([e.data.name,e.data.arguments]);case"tool/result":return Dd([HS(e.data.message.content),e.data.error?.name??"",e.data.error?.code??""]);case"todo/write":return Dd(e.data.todos.flatMap(t=>[t.status,t.content]));case"turn/end":return zse(e.data.reason);case"turn/start":case"step/start":case"step/end":case"assistant/chunk":case"request/header":return"";default:return""}}l(jse,"extractSessionEventText");function zse(e){switch(e.kind){case"error":return Dd(["error",e.error.message]);case"aborted":return"aborted";case"max-tokens":case"interrupted":return e.kind;case"completed":return"";default:return""}}l(zse,"turnEndText");function HS(e){return Dd(e.flatMap(cC))}l(HS,"contentText");function cC(e){switch(e.type){case"text":return[e.text];case"reasoning":return[];case"tool-call":return[e.name,e.arguments];case"tool-result":return e.content.flatMap(cC);default:return[]}}l(cC,"blockText");function Dd(e){return e.map(t=>t.trim()).filter(Boolean).join(`
|
|
428
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let u=e.external.registry.get(o[0])?.id;if(t!==o[0]&&u){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1&&e.reused==="ref"){s(o);continue}}}l(zo,"extractDefs");function Bo(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=l(a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,d={...u},f=c.ref;if(c.ref=null,f){n(f);let h=e.seen.get(f),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,d),a._zod.parent===f)for(let y in u)y==="$ref"||y==="allOf"||y in d||delete u[y];if(m.$ref&&h.def)for(let y in u)y==="$ref"||y==="allOf"||y in h.def&&JSON.stringify(u[y])===JSON.stringify(h.def[y])&&delete u[y]}let p=a._zod.parent;if(p&&p!==f){n(p);let h=e.seen.get(p);if(h?.schema.$ref&&(u.$ref=h.schema.$ref,h.def))for(let m in u)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(u[m])===JSON.stringify(h.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})},"flattenRef");for(let a of[...e.seen.entries()].reverse())n(a[0]);let i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}Object.assign(i,r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&i.id===s&&delete i.id;let o=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,o[c.defId]=c.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{let a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:cc(t,"input",e.processors),output:cc(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}l(Bo,"finalize");function Tn(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Tn(n.element,r);if(n.type==="set")return Tn(n.valueType,r);if(n.type==="lazy")return Tn(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Tn(n.innerType,r);if(n.type==="intersection")return Tn(n.left,r)||Tn(n.right,r);if(n.type==="record"||n.type==="map")return Tn(n.keyType,r)||Tn(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Tn(n.in,r)||Tn(n.out,r);if(n.type==="object"){for(let i in n.shape)if(Tn(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(Tn(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(Tn(i,r))return!0;return!!(n.rest&&Tn(n.rest,r))}return!1}l(Tn,"isTransforming");var Z2=l((e,t={})=>r=>{let n=jo({...r,processors:t});return Kt(e,n),zo(n,e),Bo(n,e)},"createToJSONSchemaMethod"),cc=l((e,t,r={})=>n=>{let{libraryOptions:i,target:s}=n??{},o=jo({...i??{},target:s,io:t,processors:r});return Kt(e,o),zo(o,e),Bo(o,e)},"createStandardJSONSchemaMethod");var gse={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},K2=l((e,t,r,n)=>{let i=r;i.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=gse[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){let d=[...c];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},"stringProcessor"),Y2=l((e,t,r,n)=>{let i=r,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number";let f=typeof d=="number"&&d>=(s??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(o??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";f?h?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d:typeof s=="number"&&(i.minimum=s),p?h?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u:typeof o=="number"&&(i.maximum=o),typeof c=="number"&&(i.multipleOf=c)},"numberProcessor"),X2=l((e,t,r,n)=>{r.type="boolean"},"booleanProcessor"),J2=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},"bigintProcessor"),Q2=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},"symbolProcessor"),eE=l((e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},"nullProcessor"),tE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},"undefinedProcessor"),rE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},"voidProcessor"),nE=l((e,t,r,n)=>{r.not={}},"neverProcessor"),iE=l((e,t,r,n)=>{},"anyProcessor"),sE=l((e,t,r,n)=>{},"unknownProcessor"),oE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},"dateProcessor"),aE=l((e,t,r,n)=>{let i=e._zod.def,s=Qu(i.entries);s.every(o=>typeof o=="number")&&(r.type="number"),s.every(o=>typeof o=="string")&&(r.type="string"),r.enum=s},"enumProcessor"),lE=l((e,t,r,n)=>{let i=e._zod.def,s=[];for(let o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){let o=s[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else s.every(o=>typeof o=="number")&&(r.type="number"),s.every(o=>typeof o=="string")&&(r.type="string"),s.every(o=>typeof o=="boolean")&&(r.type="boolean"),s.every(o=>o===null)&&(r.type="null"),r.enum=s},"literalProcessor"),cE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},"nanProcessor"),uE=l((e,t,r,n)=>{let i=r,s=e._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=s.source},"templateLiteralProcessor"),dE=l((e,t,r,n)=>{let i=r,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:a,mime:c}=e._zod.bag;o!==void 0&&(s.minLength=o),a!==void 0&&(s.maxLength=a),c?c.length===1?(s.contentMediaType=c[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(i,s)},"fileProcessor"),fE=l((e,t,r,n)=>{r.type="boolean"},"successProcessor"),pE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},"customProcessor"),hE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},"functionProcessor"),mE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},"transformProcessor"),gE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},"mapProcessor"),yE=l((e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},"setProcessor"),vE=l((e,t,r,n)=>{let i=r,s=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Kt(s.element,t,{...n,path:[...n.path,"items"]})},"arrayProcessor"),wE=l((e,t,r,n)=>{let i=r,s=e._zod.def;i.type="object",i.properties={};let o=s.shape;for(let u in o)i.properties[u]=Kt(o[u],t,{...n,path:[...n.path,"properties",u]});let a=new Set(Object.keys(o)),c=new Set([...a].filter(u=>{let d=s.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(i.required=Array.from(c)),s.catchall?._zod.def.type==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Kt(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},"objectProcessor"),rm=l((e,t,r,n)=>{let i=e._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>Kt(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=o:r.anyOf=o},"unionProcessor"),bE=l((e,t,r,n)=>{let i=e._zod.def,s=Kt(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=Kt(i.right,t,{...n,path:[...n.path,"allOf",1]}),a=l(u=>"allOf"in u&&Object.keys(u).length===1,"isSimpleIntersection"),c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];r.allOf=c},"intersectionProcessor"),xE=l((e,t,r,n)=>{let i=r,s=e._zod.def;i.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((p,h)=>Kt(p,t,{...n,path:[...n.path,o,h]})),u=s.rest?Kt(s.rest,t,{...n,path:[...n.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=c,u&&(i.items=u)):t.target==="openapi-3.0"?(i.items={anyOf:c},u&&i.items.anyOf.push(u),i.minItems=c.length,u||(i.maxItems=c.length)):(i.items=c,u&&(i.additionalItems=u));let{minimum:d,maximum:f}=e._zod.bag;typeof d=="number"&&(i.minItems=d),typeof f=="number"&&(i.maxItems=f)},"tupleProcessor"),EE=l((e,t,r,n)=>{let i=r,s=e._zod.def;i.type="object";let o=s.keyType,c=o._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){let d=Kt(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(let f of c)i.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Kt(s.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=Kt(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=o._zod.values;if(u){let d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},"recordProcessor"),SE=l((e,t,r,n)=>{let i=e._zod.def,s=Kt(i.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=i.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},"nullableProcessor"),kE=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType},"nonoptionalProcessor"),AE=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},"defaultProcessor"),IE=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},"prefaultProcessor"),$E=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},"catchProcessor"),_E=l((e,t,r,n)=>{let i=e._zod.def,s=i.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?i.out:i.in:i.out;Kt(o,t,n);let a=t.seen.get(e);a.ref=o},"pipeProcessor"),TE=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType,r.readOnly=!0},"readonlyProcessor"),CE=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType},"promiseProcessor"),nm=l((e,t,r,n)=>{let i=e._zod.def;Kt(i.innerType,t,n);let s=t.seen.get(e);s.ref=i.innerType},"optionalProcessor"),OE=l((e,t,r,n)=>{let i=e._zod.innerType;Kt(i,t,n);let s=t.seen.get(e);s.ref=i},"lazyProcessor"),tm={string:K2,number:Y2,boolean:X2,bigint:J2,symbol:Q2,null:eE,undefined:tE,void:rE,never:nE,any:iE,unknown:sE,date:oE,enum:aE,literal:lE,nan:cE,template_literal:uE,file:dE,success:fE,custom:pE,function:hE,transform:mE,map:gE,set:yE,array:vE,object:wE,union:rm,intersection:bE,tuple:xE,record:EE,nullable:SE,nonoptional:kE,default:AE,prefault:IE,catch:$E,pipe:_E,readonly:TE,promise:CE,optional:nm,lazy:OE};function im(e,t){if("_idmap"in e){let n=e,i=jo({...t,processors:tm}),s={};for(let c of n._idmap.entries()){let[u,d]=c;Kt(d,i)}let o={},a={registry:n,uri:t?.uri,defs:s};i.external=a;for(let c of n._idmap.entries()){let[u,d]=c;zo(i,d),o[u]=Bo(i,d)}if(Object.keys(s).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:s}}return{schemas:o}}let r=jo({...t,processors:tm});return Kt(e,r),zo(r,e),Bo(r,e)}l(im,"toJSONSchema");var sm=class{static{l(this,"JSONSchemaGenerator")}get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=jo({processors:tm,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return Kt(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),zo(this.ctx,t);let n=Bo(this.ctx,t),{"~standard":i,...s}=n;return s}};var DT={};var bd={};ti(bd,{ZodAny:()=>tS,ZodArray:()=>sS,ZodBase64:()=>Im,ZodBase64URL:()=>$m,ZodBigInt:()=>yc,ZodBigIntFormat:()=>Cm,ZodBoolean:()=>gc,ZodCIDRv4:()=>km,ZodCIDRv6:()=>Am,ZodCUID:()=>ym,ZodCUID2:()=>vm,ZodCatch:()=>$S,ZodCodec:()=>Nd,ZodCustom:()=>Rd,ZodCustomStringFormat:()=>hc,ZodDate:()=>$d,ZodDefault:()=>xS,ZodDiscriminatedUnion:()=>aS,ZodE164:()=>_m,ZodEmail:()=>hm,ZodEmoji:()=>mm,ZodEnum:()=>fc,ZodExactOptional:()=>vS,ZodFile:()=>gS,ZodFunction:()=>MS,ZodGUID:()=>Ed,ZodIPv4:()=>Em,ZodIPv6:()=>Sm,ZodIntersection:()=>lS,ZodJWT:()=>Tm,ZodKSUID:()=>xm,ZodLazy:()=>PS,ZodLiteral:()=>mS,ZodMAC:()=>ZE,ZodMap:()=>pS,ZodNaN:()=>TS,ZodNanoID:()=>gm,ZodNever:()=>nS,ZodNonOptional:()=>Lm,ZodNull:()=>QE,ZodNullable:()=>bS,ZodNumber:()=>mc,ZodNumberFormat:()=>Ma,ZodObject:()=>Td,ZodOptional:()=>Dm,ZodPipe:()=>Od,ZodPrefault:()=>SS,ZodPreprocess:()=>CS,ZodPromise:()=>LS,ZodReadonly:()=>OS,ZodRecord:()=>dc,ZodSet:()=>hS,ZodString:()=>pc,ZodStringFormat:()=>er,ZodSuccess:()=>IS,ZodSymbol:()=>XE,ZodTemplateLiteral:()=>RS,ZodTransform:()=>yS,ZodTuple:()=>uS,ZodType:()=>Et,ZodULID:()=>wm,ZodURL:()=>Id,ZodUUID:()=>Es,ZodUndefined:()=>JE,ZodUnion:()=>Cd,ZodUnknown:()=>rS,ZodVoid:()=>iS,ZodXID:()=>bm,ZodXor:()=>oS,_ZodString:()=>pm,_default:()=>ES,_function:()=>q5,any:()=>x5,array:()=>_d,base64:()=>i5,base64url:()=>s5,bigint:()=>g5,boolean:()=>YE,catch:()=>_S,check:()=>H5,cidrv4:()=>r5,cidrv6:()=>n5,codec:()=>j5,cuid:()=>ZT,cuid2:()=>KT,custom:()=>G5,date:()=>S5,describe:()=>V5,discriminatedUnion:()=>T5,e164:()=>o5,email:()=>FT,emoji:()=>GT,enum:()=>Rm,exactOptional:()=>wS,file:()=>L5,float32:()=>f5,float64:()=>p5,function:()=>q5,guid:()=>UT,hash:()=>d5,hex:()=>u5,hostname:()=>c5,httpUrl:()=>HT,instanceof:()=>K5,int:()=>dm,int32:()=>h5,int64:()=>y5,intersection:()=>cS,invertCodec:()=>z5,ipv4:()=>QT,ipv6:()=>t5,json:()=>X5,jwt:()=>a5,keyof:()=>k5,ksuid:()=>JT,lazy:()=>DS,literal:()=>D5,looseObject:()=>$5,looseRecord:()=>O5,mac:()=>e5,map:()=>N5,meta:()=>Z5,nan:()=>U5,nanoid:()=>VT,nativeEnum:()=>P5,never:()=>Om,nonoptional:()=>AS,null:()=>eS,nullable:()=>kd,nullish:()=>M5,number:()=>KE,object:()=>A5,optional:()=>Sd,partialRecord:()=>C5,pipe:()=>fm,prefault:()=>kS,preprocess:()=>J5,promise:()=>W5,readonly:()=>NS,record:()=>fS,refine:()=>FS,set:()=>R5,strictObject:()=>I5,string:()=>xd,stringFormat:()=>l5,stringbool:()=>Y5,success:()=>F5,superRefine:()=>US,symbol:()=>w5,templateLiteral:()=>B5,transform:()=>Pm,tuple:()=>dS,uint32:()=>m5,uint64:()=>v5,ulid:()=>YT,undefined:()=>b5,union:()=>Nm,unknown:()=>La,url:()=>qT,uuid:()=>jT,uuidv4:()=>zT,uuidv6:()=>BT,uuidv7:()=>WT,void:()=>E5,xid:()=>XT,xor:()=>_5});var om={};ti(om,{endsWith:()=>tc,gt:()=>bs,gte:()=>_n,includes:()=>Ql,length:()=>Da,lowercase:()=>Xl,lt:()=>ws,lte:()=>ni,maxLength:()=>Pa,maxSize:()=>Uo,mime:()=>rc,minLength:()=>Ys,minSize:()=>xs,multipleOf:()=>Fo,negative:()=>Xh,nonnegative:()=>Qh,nonpositive:()=>Jh,normalize:()=>nc,overwrite:()=>Zi,positive:()=>Yh,property:()=>em,regex:()=>Yl,size:()=>Ra,slugify:()=>ac,startsWith:()=>ec,toLowerCase:()=>sc,toUpperCase:()=>oc,trim:()=>ic,uppercase:()=>Jl});var uc={};ti(uc,{ZodISODate:()=>lm,ZodISODateTime:()=>am,ZodISODuration:()=>um,ZodISOTime:()=>cm,date:()=>RE,datetime:()=>NE,duration:()=>DE,time:()=>PE});var am=se("ZodISODateTime",(e,t)=>{hb.init(e,t),er.init(e,t)});function NE(e){return p2(am,e)}l(NE,"datetime");var lm=se("ZodISODate",(e,t)=>{mb.init(e,t),er.init(e,t)});function RE(e){return h2(lm,e)}l(RE,"date");var cm=se("ZodISOTime",(e,t)=>{gb.init(e,t),er.init(e,t)});function PE(e){return m2(cm,e)}l(PE,"time");var um=se("ZodISODuration",(e,t)=>{yb.init(e,t),er.init(e,t)});function DE(e){return g2(um,e)}l(DE,"duration");var LT=l((e,t)=>{id.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:l(r=>od(e,r),"value")},flatten:{value:l(r=>sd(e,r),"value")},addIssue:{value:l(r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,zl,2)},"value")},addIssues:{value:l(r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,zl,2)},"value")},isEmpty:{get(){return e.issues.length===0}}})},"initializer"),vse=se("ZodError",LT),Wn=se("ZodError",LT,{Parent:Error});var LE=ql(Wn),ME=Hl(Wn),FE=Gl(Wn),UE=Vl(Wn),jE=ah(Wn),zE=lh(Wn),BE=ch(Wn),WE=uh(Wn),qE=dh(Wn),HE=fh(Wn),GE=ph(Wn),VE=hh(Wn);var MT=new WeakMap;function Ad(e,t,r){let n=Object.getPrototypeOf(e),i=MT.get(n);if(i||(i=new Set,MT.set(n,i)),!i.has(t)){i.add(t);for(let s in r){let o=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let a=o.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}l(Ad,"_installLazyMethods");var Et=se("ZodType",(e,t)=>(vt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:cc(e,"input"),output:cc(e,"output")}}),e.toJSONSchema=Z2(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>LE(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>FE(e,r,n),e.parseAsync=async(r,n)=>ME(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>UE(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>jE(e,r,n),e.decode=(r,n)=>zE(e,r,n),e.encodeAsync=async(r,n)=>BE(e,r,n),e.decodeAsync=async(r,n)=>WE(e,r,n),e.safeEncode=(r,n)=>qE(e,r,n),e.safeDecode=(r,n)=>HE(e,r,n),e.safeEncodeAsync=async(r,n)=>GE(e,r,n),e.safeDecodeAsync=async(r,n)=>VE(e,r,n),Ad(e,"ZodType",{check(...r){let n=this.def;return this.clone(De.mergeDefs(n,{checks:[...n.checks??[],...r.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return In(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(FS(r,n))},superRefine(r,n){return this.check(US(r,n))},overwrite(r){return this.check(Zi(r))},optional(){return Sd(this)},exactOptional(){return wS(this)},nullable(){return kd(this)},nullish(){return Sd(kd(this))},nonoptional(r){return AS(this,r)},array(){return _d(this)},or(r){return Nm([this,r])},and(r){return cS(this,r)},transform(r){return fm(this,Pm(r))},default(r){return ES(this,r)},prefault(r){return kS(this,r)},catch(r){return _S(this,r)},pipe(r){return fm(this,r)},readonly(){return NS(this)},describe(r){let n=this.clone();return nn.add(n,{description:r}),n},meta(...r){if(r.length===0)return nn.get(this);let n=this.clone();return nn.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return nn.get(e)?.description},configurable:!0}),e)),pm=se("_ZodString",(e,t)=>{Na.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,s)=>K2(e,n,i,s);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Ad(e,"_ZodString",{regex(...n){return this.check(Yl(...n))},includes(...n){return this.check(Ql(...n))},startsWith(...n){return this.check(ec(...n))},endsWith(...n){return this.check(tc(...n))},min(...n){return this.check(Ys(...n))},max(...n){return this.check(Pa(...n))},length(...n){return this.check(Da(...n))},nonempty(...n){return this.check(Ys(1,...n))},lowercase(n){return this.check(Xl(n))},uppercase(n){return this.check(Jl(n))},trim(){return this.check(ic())},normalize(...n){return this.check(nc(...n))},toLowerCase(){return this.check(sc())},toUpperCase(){return this.check(oc())},slugify(){return this.check(ac())}})}),pc=se("ZodString",(e,t)=>{Na.init(e,t),pm.init(e,t),e.email=r=>e.check(Ch(hm,r)),e.url=r=>e.check(wd(Id,r)),e.jwt=r=>e.check(Kh(Tm,r)),e.emoji=r=>e.check(Dh(mm,r)),e.guid=r=>e.check(vd(Ed,r)),e.uuid=r=>e.check(Oh(Es,r)),e.uuidv4=r=>e.check(Nh(Es,r)),e.uuidv6=r=>e.check(Rh(Es,r)),e.uuidv7=r=>e.check(Ph(Es,r)),e.nanoid=r=>e.check(Lh(gm,r)),e.guid=r=>e.check(vd(Ed,r)),e.cuid=r=>e.check(Mh(ym,r)),e.cuid2=r=>e.check(Fh(vm,r)),e.ulid=r=>e.check(Uh(wm,r)),e.base64=r=>e.check(Gh(Im,r)),e.base64url=r=>e.check(Vh($m,r)),e.xid=r=>e.check(jh(bm,r)),e.ksuid=r=>e.check(zh(xm,r)),e.ipv4=r=>e.check(Bh(Em,r)),e.ipv6=r=>e.check(Wh(Sm,r)),e.cidrv4=r=>e.check(qh(km,r)),e.cidrv6=r=>e.check(Hh(Am,r)),e.e164=r=>e.check(Zh(_m,r)),e.datetime=r=>e.check(NE(r)),e.date=r=>e.check(RE(r)),e.time=r=>e.check(PE(r)),e.duration=r=>e.check(DE(r))});function xd(e){return c2(pc,e)}l(xd,"string");var er=se("ZodStringFormat",(e,t)=>{Qt.init(e,t),pm.init(e,t)}),hm=se("ZodEmail",(e,t)=>{sb.init(e,t),er.init(e,t)});function FT(e){return Ch(hm,e)}l(FT,"email");var Ed=se("ZodGUID",(e,t)=>{nb.init(e,t),er.init(e,t)});function UT(e){return vd(Ed,e)}l(UT,"guid");var Es=se("ZodUUID",(e,t)=>{ib.init(e,t),er.init(e,t)});function jT(e){return Oh(Es,e)}l(jT,"uuid");function zT(e){return Nh(Es,e)}l(zT,"uuidv4");function BT(e){return Rh(Es,e)}l(BT,"uuidv6");function WT(e){return Ph(Es,e)}l(WT,"uuidv7");var Id=se("ZodURL",(e,t)=>{ob.init(e,t),er.init(e,t)});function qT(e){return wd(Id,e)}l(qT,"url");function HT(e){return wd(Id,{protocol:ri.httpProtocol,hostname:ri.domain,...De.normalizeParams(e)})}l(HT,"httpUrl");var mm=se("ZodEmoji",(e,t)=>{ab.init(e,t),er.init(e,t)});function GT(e){return Dh(mm,e)}l(GT,"emoji");var gm=se("ZodNanoID",(e,t)=>{lb.init(e,t),er.init(e,t)});function VT(e){return Lh(gm,e)}l(VT,"nanoid");var ym=se("ZodCUID",(e,t)=>{cb.init(e,t),er.init(e,t)});function ZT(e){return Mh(ym,e)}l(ZT,"cuid");var vm=se("ZodCUID2",(e,t)=>{ub.init(e,t),er.init(e,t)});function KT(e){return Fh(vm,e)}l(KT,"cuid2");var wm=se("ZodULID",(e,t)=>{db.init(e,t),er.init(e,t)});function YT(e){return Uh(wm,e)}l(YT,"ulid");var bm=se("ZodXID",(e,t)=>{fb.init(e,t),er.init(e,t)});function XT(e){return jh(bm,e)}l(XT,"xid");var xm=se("ZodKSUID",(e,t)=>{pb.init(e,t),er.init(e,t)});function JT(e){return zh(xm,e)}l(JT,"ksuid");var Em=se("ZodIPv4",(e,t)=>{vb.init(e,t),er.init(e,t)});function QT(e){return Bh(Em,e)}l(QT,"ipv4");var ZE=se("ZodMAC",(e,t)=>{bb.init(e,t),er.init(e,t)});function e5(e){return d2(ZE,e)}l(e5,"mac");var Sm=se("ZodIPv6",(e,t)=>{wb.init(e,t),er.init(e,t)});function t5(e){return Wh(Sm,e)}l(t5,"ipv6");var km=se("ZodCIDRv4",(e,t)=>{xb.init(e,t),er.init(e,t)});function r5(e){return qh(km,e)}l(r5,"cidrv4");var Am=se("ZodCIDRv6",(e,t)=>{Eb.init(e,t),er.init(e,t)});function n5(e){return Hh(Am,e)}l(n5,"cidrv6");var Im=se("ZodBase64",(e,t)=>{kb.init(e,t),er.init(e,t)});function i5(e){return Gh(Im,e)}l(i5,"base64");var $m=se("ZodBase64URL",(e,t)=>{Ab.init(e,t),er.init(e,t)});function s5(e){return Vh($m,e)}l(s5,"base64url");var _m=se("ZodE164",(e,t)=>{Ib.init(e,t),er.init(e,t)});function o5(e){return Zh(_m,e)}l(o5,"e164");var Tm=se("ZodJWT",(e,t)=>{$b.init(e,t),er.init(e,t)});function a5(e){return Kh(Tm,e)}l(a5,"jwt");var hc=se("ZodCustomStringFormat",(e,t)=>{_b.init(e,t),er.init(e,t)});function l5(e,t,r={}){return lc(hc,e,t,r)}l(l5,"stringFormat");function c5(e){return lc(hc,"hostname",ri.hostname,e)}l(c5,"hostname");function u5(e){return lc(hc,"hex",ri.hex,e)}l(u5,"hex");function d5(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,i=ri[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return lc(hc,n,i,t)}l(d5,"hash");var mc=se("ZodNumber",(e,t)=>{Sh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,s)=>Y2(e,n,i,s),Ad(e,"ZodNumber",{gt(n,i){return this.check(bs(n,i))},gte(n,i){return this.check(_n(n,i))},min(n,i){return this.check(_n(n,i))},lt(n,i){return this.check(ws(n,i))},lte(n,i){return this.check(ni(n,i))},max(n,i){return this.check(ni(n,i))},int(n){return this.check(dm(n))},safe(n){return this.check(dm(n))},positive(n){return this.check(bs(0,n))},nonnegative(n){return this.check(_n(0,n))},negative(n){return this.check(ws(0,n))},nonpositive(n){return this.check(ni(0,n))},multipleOf(n,i){return this.check(Fo(n,i))},step(n,i){return this.check(Fo(n,i))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function KE(e){return y2(mc,e)}l(KE,"number");var Ma=se("ZodNumberFormat",(e,t)=>{Tb.init(e,t),mc.init(e,t)});function dm(e){return w2(Ma,e)}l(dm,"int");function f5(e){return b2(Ma,e)}l(f5,"float32");function p5(e){return x2(Ma,e)}l(p5,"float64");function h5(e){return E2(Ma,e)}l(h5,"int32");function m5(e){return S2(Ma,e)}l(m5,"uint32");var gc=se("ZodBoolean",(e,t)=>{ud.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>X2(e,r,n,i)});function YE(e){return k2(gc,e)}l(YE,"boolean");var yc=se("ZodBigInt",(e,t)=>{kh.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,s)=>J2(e,n,i,s),e.gte=(n,i)=>e.check(_n(n,i)),e.min=(n,i)=>e.check(_n(n,i)),e.gt=(n,i)=>e.check(bs(n,i)),e.gte=(n,i)=>e.check(_n(n,i)),e.min=(n,i)=>e.check(_n(n,i)),e.lt=(n,i)=>e.check(ws(n,i)),e.lte=(n,i)=>e.check(ni(n,i)),e.max=(n,i)=>e.check(ni(n,i)),e.positive=n=>e.check(bs(BigInt(0),n)),e.negative=n=>e.check(ws(BigInt(0),n)),e.nonpositive=n=>e.check(ni(BigInt(0),n)),e.nonnegative=n=>e.check(_n(BigInt(0),n)),e.multipleOf=(n,i)=>e.check(Fo(n,i));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function g5(e){return I2(yc,e)}l(g5,"bigint");var Cm=se("ZodBigIntFormat",(e,t)=>{Cb.init(e,t),yc.init(e,t)});function y5(e){return _2(Cm,e)}l(y5,"int64");function v5(e){return T2(Cm,e)}l(v5,"uint64");var XE=se("ZodSymbol",(e,t)=>{Ob.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Q2(e,r,n,i)});function w5(e){return C2(XE,e)}l(w5,"symbol");var JE=se("ZodUndefined",(e,t)=>{Nb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>tE(e,r,n,i)});function b5(e){return O2(JE,e)}l(b5,"_undefined");var QE=se("ZodNull",(e,t)=>{Rb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>eE(e,r,n,i)});function eS(e){return N2(QE,e)}l(eS,"_null");var tS=se("ZodAny",(e,t)=>{Pb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>iE(e,r,n,i)});function x5(){return R2(tS)}l(x5,"any");var rS=se("ZodUnknown",(e,t)=>{Db.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>sE(e,r,n,i)});function La(){return P2(rS)}l(La,"unknown");var nS=se("ZodNever",(e,t)=>{Lb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>nE(e,r,n,i)});function Om(e){return D2(nS,e)}l(Om,"never");var iS=se("ZodVoid",(e,t)=>{Mb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>rE(e,r,n,i)});function E5(e){return L2(iS,e)}l(E5,"_void");var $d=se("ZodDate",(e,t)=>{Fb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,s)=>oE(e,n,i,s),e.min=(n,i)=>e.check(_n(n,i)),e.max=(n,i)=>e.check(ni(n,i));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function S5(e){return M2($d,e)}l(S5,"date");var sS=se("ZodArray",(e,t)=>{Ub.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>vE(e,r,n,i),e.element=t.element,Ad(e,"ZodArray",{min(r,n){return this.check(Ys(r,n))},nonempty(r){return this.check(Ys(1,r))},max(r,n){return this.check(Pa(r,n))},length(r,n){return this.check(Da(r,n))},unwrap(){return this.element}})});function _d(e,t){return j2(sS,e,t)}l(_d,"array");function k5(e){let t=e._zod.def.shape;return Rm(Object.keys(t))}l(k5,"keyof");var Td=se("ZodObject",(e,t)=>{jb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>wE(e,r,n,i),De.defineLazy(e,"shape",()=>t.shape),Ad(e,"ZodObject",{keyof(){return Rm(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:La()})},loose(){return this.clone({...this._zod.def,catchall:La()})},strict(){return this.clone({...this._zod.def,catchall:Om()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return De.extend(this,r)},safeExtend(r){return De.safeExtend(this,r)},merge(r){return De.merge(this,r)},pick(r){return De.pick(this,r)},omit(r){return De.omit(this,r)},partial(...r){return De.partial(Dm,this,r[0])},required(...r){return De.required(Lm,this,r[0])}})});function A5(e,t){let r={type:"object",shape:e??{},...De.normalizeParams(t)};return new Td(r)}l(A5,"object");function I5(e,t){return new Td({type:"object",shape:e,catchall:Om(),...De.normalizeParams(t)})}l(I5,"strictObject");function $5(e,t){return new Td({type:"object",shape:e,catchall:La(),...De.normalizeParams(t)})}l($5,"looseObject");var Cd=se("ZodUnion",(e,t)=>{dd.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>rm(e,r,n,i),e.options=t.options});function Nm(e,t){return new Cd({type:"union",options:e,...De.normalizeParams(t)})}l(Nm,"union");var oS=se("ZodXor",(e,t)=>{Cd.init(e,t),zb.init(e,t),e._zod.processJSONSchema=(r,n,i)=>rm(e,r,n,i),e.options=t.options});function _5(e,t){return new oS({type:"union",options:e,inclusive:!1,...De.normalizeParams(t)})}l(_5,"xor");var aS=se("ZodDiscriminatedUnion",(e,t)=>{Cd.init(e,t),Bb.init(e,t)});function T5(e,t,r){return new aS({type:"union",options:t,discriminator:e,...De.normalizeParams(r)})}l(T5,"discriminatedUnion");var lS=se("ZodIntersection",(e,t)=>{Wb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>bE(e,r,n,i)});function cS(e,t){return new lS({type:"intersection",left:e,right:t})}l(cS,"intersection");var uS=se("ZodTuple",(e,t)=>{Ah.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>xE(e,r,n,i),e.rest=r=>e.clone({...e._zod.def,rest:r})});function dS(e,t,r){let n=t instanceof vt,i=n?r:t,s=n?t:null;return new uS({type:"tuple",items:e,rest:s,...De.normalizeParams(i)})}l(dS,"tuple");var dc=se("ZodRecord",(e,t)=>{qb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>EE(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType});function fS(e,t,r){return!t||!t._zod?new dc({type:"record",keyType:xd(),valueType:e,...De.normalizeParams(t)}):new dc({type:"record",keyType:e,valueType:t,...De.normalizeParams(r)})}l(fS,"record");function C5(e,t,r){let n=In(e);return n._zod.values=void 0,new dc({type:"record",keyType:n,valueType:t,...De.normalizeParams(r)})}l(C5,"partialRecord");function O5(e,t,r){return new dc({type:"record",keyType:e,valueType:t,mode:"loose",...De.normalizeParams(r)})}l(O5,"looseRecord");var pS=se("ZodMap",(e,t)=>{Hb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>gE(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(xs(...r)),e.nonempty=r=>e.check(xs(1,r)),e.max=(...r)=>e.check(Uo(...r)),e.size=(...r)=>e.check(Ra(...r))});function N5(e,t,r){return new pS({type:"map",keyType:e,valueType:t,...De.normalizeParams(r)})}l(N5,"map");var hS=se("ZodSet",(e,t)=>{Gb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>yE(e,r,n,i),e.min=(...r)=>e.check(xs(...r)),e.nonempty=r=>e.check(xs(1,r)),e.max=(...r)=>e.check(Uo(...r)),e.size=(...r)=>e.check(Ra(...r))});function R5(e,t){return new hS({type:"set",valueType:e,...De.normalizeParams(t)})}l(R5,"set");var fc=se("ZodEnum",(e,t)=>{Vb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(n,i,s)=>aE(e,n,i,s),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let s={};for(let o of n)if(r.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new fc({...t,checks:[],...De.normalizeParams(i),entries:s})},e.exclude=(n,i)=>{let s={...t.entries};for(let o of n)if(r.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new fc({...t,checks:[],...De.normalizeParams(i),entries:s})}});function Rm(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new fc({type:"enum",entries:r,...De.normalizeParams(t)})}l(Rm,"_enum");function P5(e,t){return new fc({type:"enum",entries:e,...De.normalizeParams(t)})}l(P5,"nativeEnum");var mS=se("ZodLiteral",(e,t)=>{Zb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>lE(e,r,n,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function D5(e,t){return new mS({type:"literal",values:Array.isArray(e)?e:[e],...De.normalizeParams(t)})}l(D5,"literal");var gS=se("ZodFile",(e,t)=>{Kb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>dE(e,r,n,i),e.min=(r,n)=>e.check(xs(r,n)),e.max=(r,n)=>e.check(Uo(r,n)),e.mime=(r,n)=>e.check(rc(Array.isArray(r)?r:[r],n))});function L5(e){return z2(gS,e)}l(L5,"file");var yS=se("ZodTransform",(e,t)=>{Yb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>mE(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ro(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(De.issue(s,r.value,t));else{let o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(De.issue(o))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=i,r.fallback=!0,r)}});function Pm(e){return new yS({type:"transform",transform:e})}l(Pm,"transform");var Dm=se("ZodOptional",(e,t)=>{Ih.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>nm(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Sd(e){return new Dm({type:"optional",innerType:e})}l(Sd,"optional");var vS=se("ZodExactOptional",(e,t)=>{Xb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>nm(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function wS(e){return new vS({type:"optional",innerType:e})}l(wS,"exactOptional");var bS=se("ZodNullable",(e,t)=>{Jb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>SE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function kd(e){return new bS({type:"nullable",innerType:e})}l(kd,"nullable");function M5(e){return Sd(kd(e))}l(M5,"nullish");var xS=se("ZodDefault",(e,t)=>{Qb.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>AE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ES(e,t){return new xS({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():De.shallowClone(t)}})}l(ES,"_default");var SS=se("ZodPrefault",(e,t)=>{ex.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>IE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function kS(e,t){return new SS({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():De.shallowClone(t)}})}l(kS,"prefault");var Lm=se("ZodNonOptional",(e,t)=>{tx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>kE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function AS(e,t){return new Lm({type:"nonoptional",innerType:e,...De.normalizeParams(t)})}l(AS,"nonoptional");var IS=se("ZodSuccess",(e,t)=>{rx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function F5(e){return new IS({type:"success",innerType:e})}l(F5,"success");var $S=se("ZodCatch",(e,t)=>{nx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>$E(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _S(e,t){return new $S({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}l(_S,"_catch");var TS=se("ZodNaN",(e,t)=>{ix.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>cE(e,r,n,i)});function U5(e){return U2(TS,e)}l(U5,"nan");var Od=se("ZodPipe",(e,t)=>{$h.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_E(e,r,n,i),e.in=t.in,e.out=t.out});function fm(e,t){return new Od({type:"pipe",in:e,out:t})}l(fm,"pipe");var Nd=se("ZodCodec",(e,t)=>{Od.init(e,t),fd.init(e,t)});function j5(e,t,r){return new Nd({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}l(j5,"codec");function z5(e){let t=e._zod.def;return new Nd({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}l(z5,"invertCodec");var CS=se("ZodPreprocess",(e,t)=>{Od.init(e,t),sx.init(e,t)}),OS=se("ZodReadonly",(e,t)=>{ox.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>TE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function NS(e){return new OS({type:"readonly",innerType:e})}l(NS,"readonly");var RS=se("ZodTemplateLiteral",(e,t)=>{ax.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>uE(e,r,n,i)});function B5(e,t){return new RS({type:"template_literal",parts:e,...De.normalizeParams(t)})}l(B5,"templateLiteral");var PS=se("ZodLazy",(e,t)=>{ux.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>OE(e,r,n,i),e.unwrap=()=>e._zod.def.getter()});function DS(e){return new PS({type:"lazy",getter:e})}l(DS,"lazy");var LS=se("ZodPromise",(e,t)=>{cx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>CE(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function W5(e){return new LS({type:"promise",innerType:e})}l(W5,"promise");var MS=se("ZodFunction",(e,t)=>{lx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>hE(e,r,n,i)});function q5(e){return new MS({type:"function",input:Array.isArray(e?.input)?dS(e?.input):e?.input??_d(La()),output:e?.output??La()})}l(q5,"_function");var Rd=se("ZodCustom",(e,t)=>{dx.init(e,t),Et.init(e,t),e._zod.processJSONSchema=(r,n,i)=>pE(e,r,n,i)});function H5(e){let t=new or({check:"custom"});return t._zod.check=e,t}l(H5,"check");function G5(e,t){return B2(Rd,e??(()=>!0),t)}l(G5,"custom");function FS(e,t={}){return W2(Rd,e,t)}l(FS,"refine");function US(e,t){return q2(e,t)}l(US,"superRefine");var V5=H2,Z5=G2;function K5(e,t={}){let r=new Rd({type:"custom",check:"custom",fn:l(n=>n instanceof e,"fn"),abort:!0,...De.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}l(K5,"_instanceof");var Y5=l((...e)=>V2({Codec:Nd,Boolean:gc,String:pc},...e),"stringbool");function X5(e){let t=DS(()=>Nm([xd(e),KE(),YE(),eS(),_d(t),fS(xd(),t)]));return t}l(X5,"json");function J5(e,t){return new CS({type:"pipe",in:Pm(e),out:t})}l(J5,"preprocess");var bse={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function xse(e){_r({customError:e})}l(xse,"setErrorMap");function Ese(){return _r().customError}l(Ese,"getErrorMap");var jS;jS||(jS={});var Ze={...bd,...om,iso:uc},Sse=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function kse(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}l(kse,"detectVersion");function Ase(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let i=r[1];if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}l(Ase,"resolveRef");function Q5(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return Ze.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return Ze.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);let s=Ase(i,t),o=mn(s,t);return t.refs.set(i,o),t.processing.delete(i),o}if(e.enum!==void 0){let i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return Ze.null();if(i.length===0)return Ze.never();if(i.length===1)return Ze.literal(i[0]);if(i.every(o=>typeof o=="string"))return Ze.enum(i);let s=i.map(o=>Ze.literal(o));return s.length<2?s[0]:Ze.union([s[0],s[1],...s.slice(2)])}if(e.const!==void 0)return Ze.literal(e.const);let r=e.type;if(Array.isArray(r)){let i=r.map(s=>{let o={...e,type:s};return Q5(o,t)});return i.length===0?Ze.never():i.length===1?i[0]:Ze.union(i)}if(!r)return Ze.any();let n;switch(r){case"string":{let i=Ze.string();if(e.format){let s=e.format;s==="email"?i=i.check(Ze.email()):s==="uri"||s==="uri-reference"?i=i.check(Ze.url()):s==="uuid"||s==="guid"?i=i.check(Ze.uuid()):s==="date-time"?i=i.check(Ze.iso.datetime()):s==="date"?i=i.check(Ze.iso.date()):s==="time"?i=i.check(Ze.iso.time()):s==="duration"?i=i.check(Ze.iso.duration()):s==="ipv4"?i=i.check(Ze.ipv4()):s==="ipv6"?i=i.check(Ze.ipv6()):s==="mac"?i=i.check(Ze.mac()):s==="cidr"?i=i.check(Ze.cidrv4()):s==="cidr-v6"?i=i.check(Ze.cidrv6()):s==="base64"?i=i.check(Ze.base64()):s==="base64url"?i=i.check(Ze.base64url()):s==="e164"?i=i.check(Ze.e164()):s==="jwt"?i=i.check(Ze.jwt()):s==="emoji"?i=i.check(Ze.emoji()):s==="nanoid"?i=i.check(Ze.nanoid()):s==="cuid"?i=i.check(Ze.cuid()):s==="cuid2"?i=i.check(Ze.cuid2()):s==="ulid"?i=i.check(Ze.ulid()):s==="xid"?i=i.check(Ze.xid()):s==="ksuid"&&(i=i.check(Ze.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),n=i;break}case"number":case"integer":{let i=r==="integer"?Ze.number().int():Ze.number();typeof e.minimum=="number"&&(i=i.min(e.minimum)),typeof e.maximum=="number"&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum=="number"?i=i.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),n=i;break}case"boolean":{n=Ze.boolean();break}case"null":{n=Ze.null();break}case"object":{let i={},s=e.properties||{},o=new Set(e.required||[]);for(let[c,u]of Object.entries(s)){let d=mn(u,t);i[c]=o.has(c)?d:d.optional()}if(e.propertyNames){let c=mn(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?mn(e.additionalProperties,t):Ze.any();if(Object.keys(i).length===0){n=Ze.record(c,u);break}let d=Ze.object(i).passthrough(),f=Ze.looseRecord(c,u);n=Ze.intersection(d,f);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),d=[];for(let p of u){let h=mn(c[p],t),m=Ze.string().regex(new RegExp(p));d.push(Ze.looseRecord(m,h))}let f=[];if(Object.keys(i).length>0&&f.push(Ze.object(i).passthrough()),f.push(...d),f.length===0)n=Ze.object({}).passthrough();else if(f.length===1)n=f[0];else{let p=Ze.intersection(f[0],f[1]);for(let h=2;h<f.length;h++)p=Ze.intersection(p,f[h]);n=p}break}let a=Ze.object(i);e.additionalProperties===!1?n=a.strict():typeof e.additionalProperties=="object"?n=a.catchall(mn(e.additionalProperties,t)):n=a.passthrough();break}case"array":{let i=e.prefixItems,s=e.items;if(i&&Array.isArray(i)){let o=i.map(c=>mn(c,t)),a=s&&typeof s=="object"&&!Array.isArray(s)?mn(s,t):void 0;a?n=Ze.tuple(o).rest(a):n=Ze.tuple(o),typeof e.minItems=="number"&&(n=n.check(Ze.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(Ze.maxLength(e.maxItems)))}else if(Array.isArray(s)){let o=s.map(c=>mn(c,t)),a=e.additionalItems&&typeof e.additionalItems=="object"?mn(e.additionalItems,t):void 0;a?n=Ze.tuple(o).rest(a):n=Ze.tuple(o),typeof e.minItems=="number"&&(n=n.check(Ze.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(Ze.maxLength(e.maxItems)))}else if(s!==void 0){let o=mn(s,t),a=Ze.array(o);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),n=a}else n=Ze.array(Ze.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n}l(Q5,"convertBaseSchema");function mn(e,t){if(typeof e=="boolean")return e?Ze.any():Ze.never();let r=Q5(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(u=>mn(u,t)),c=Ze.union(a);r=n?Ze.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(u=>mn(u,t)),c=Ze.xor(a);r=n?Ze.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:Ze.any();else{let a=n?r:mn(e.allOf[0],t),c=n?0:1;for(let u=c;u<e.allOf.length;u++)a=Ze.intersection(a,mn(e.allOf[u],t));r=a}e.nullable===!0&&t.version==="openapi-3.0"&&(r=Ze.nullable(r)),e.readOnly===!0&&(r=Ze.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let i={},s=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of s)a in e&&(i[a]=e[a]);let o=["contentEncoding","contentMediaType","contentSchema"];for(let a of o)a in e&&(i[a]=e[a]);for(let a of Object.keys(e))Sse.has(a)||(i[a]=e[a]);return Object.keys(i).length>0&&t.registry.add(r,i),e.description&&(r=r.describe(e.description)),r}l(mn,"convertSchema");function eC(e,t){if(typeof e=="boolean")return e?Ze.any():Ze.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let n=kse(r,t?.defaultTarget),i=r.$defs||r.definitions||{},s={version:n,defs:i,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??nn};return mn(r,s)}l(eC,"fromJSONSchema");var zS={};ti(zS,{bigint:()=>Tse,boolean:()=>_se,date:()=>Cse,number:()=>$se,string:()=>Ise});function Ise(e){return u2(pc,e)}l(Ise,"string");function $se(e){return v2(mc,e)}l($se,"number");function _se(e){return A2(gc,e)}l(_se,"boolean");function Tse(e){return $2(yc,e)}l(Tse,"bigint");function Cse(e){return F2($d,e)}l(Cse,"date");_r(pd());var Mm=v.string(),Ose=v.discriminatedUnion("code",[v.object({code:v.literal("bad-request"),message:v.string(),details:v.object({issues:v.array(v.custom())})}),v.object({code:v.literal("cancelled"),message:v.string(),details:v.object({})}),v.object({code:v.literal("session-not-found"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("model-unavailable"),message:v.string(),details:v.object({provider:v.string(),model:v.string()})}),v.object({code:v.literal("session-conflict"),message:v.string(),details:v.object({sessionId:v.string(),requestedCwd:v.string(),existingCwd:v.string().optional()})}),v.object({code:v.literal("invalid-time-zone"),message:v.string(),details:v.object({value:v.string()})}),v.object({code:v.literal("workspace-attach-failed"),message:v.string(),details:v.object({sessionId:v.string(),workspaceId:v.string()})}),v.object({code:v.literal("workspace-not-found"),message:v.string(),details:v.object({workspaceId:v.string()})}),v.object({code:v.literal("workspace-invalid-path"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("workspace-name-conflict"),message:v.string(),details:v.object({name:v.string()})}),v.object({code:v.literal("workspace-move-invalid"),message:v.string(),details:v.object({workspaceId:v.string(),sessionId:v.string(),beforeSessionId:v.string().optional()})}),v.object({code:v.literal("directory-unreadable"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-exists"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-create-failed"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-picker-unavailable"),message:v.string(),details:v.object({capability:v.string()})}),v.object({code:v.literal("agent-preset-read-only"),message:v.string(),details:v.object({agentPreset:v.string(),reason:v.string()})}),v.object({code:v.literal("agent-preset-locked"),message:v.string(),details:v.object({sessionId:v.string(),agentPreset:v.string()})}),v.object({code:v.literal("agent-preset-conflict"),message:v.string(),details:v.object({sessionId:v.string(),requestedPreset:v.string(),existingPreset:v.string().optional()})}),v.object({code:v.literal("agent-preset-not-found"),message:v.string(),details:v.object({agentPreset:v.string(),available:v.array(v.string())})}),v.object({code:v.literal("agent-preset-invalid"),message:v.string(),details:v.object({agentPreset:v.string(),reason:v.string()})}),v.object({code:v.literal("agent-busy"),message:v.string(),details:v.object({reason:v.string()})}),v.object({code:v.literal("attachment-error"),message:v.string(),details:v.object({reason:v.string()})}),v.object({code:v.literal("queue-item-not-found"),message:v.string(),details:v.object({itemId:v.string()})}),v.object({code:v.literal("steer-unavailable"),message:v.string(),details:v.object({itemId:v.string()})}),v.object({code:v.literal("command-error"),message:v.string(),details:v.object({})}),v.object({code:v.literal("unknown-command"),message:v.string(),details:v.object({})}),v.object({code:v.literal("settings-rejected"),message:v.string(),details:v.object({ns:v.string()})}),v.object({code:v.literal("settings-conflict"),message:v.string(),details:v.object({ns:v.string(),expected:v.number(),actual:v.number()})}),v.object({code:v.literal("credential-rejected"),message:v.string(),details:v.object({ref:v.string()})}),v.object({code:v.literal("model-discovery-failed"),message:v.string(),details:v.object({settingsNs:v.string(),baseURL:v.string().optional()})}),v.object({code:v.literal("title-invalid"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("fork-unavailable"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("subagent-parent-unavailable"),message:v.string(),details:v.object({parentSessionId:v.string()})}),v.object({code:v.literal("subagent-not-found"),message:v.string(),details:v.object({parentSessionId:v.string(),childSessionId:v.string()})}),v.object({code:v.literal("subagent-catalog-diagnostic"),message:v.string(),details:v.object({parentSessionId:v.string(),childSessionId:v.string(),reason:v.union([v.literal("corrupt"),v.literal("unsupported"),v.literal("unavailable")])})}),v.object({code:v.literal("subagent-not-resumable"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("subagent-unauthorized"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("subagent-delivery-unavailable"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("internal"),message:v.string(),details:v.object({})})]);function tC(e){return v.union([v.object({ok:v.literal(!0),value:e}),v.object({ok:v.literal(!1),error:Ose})])}l(tC,"rpcResultSchema");var Fm=v.object({type:v.literal("client-request"),rpcId:Mm,method:v.string(),payload:v.unknown()}),rC=v.object({type:v.literal("server-response"),rpcId:Mm,result:tC(v.unknown().optional())}),nC=v.object({type:v.literal("server-request"),rpcId:Mm,method:v.string(),payload:v.unknown()}),Nse=v.object({type:v.literal("client-response"),rpcId:Mm,result:tC(v.unknown().optional())}),o5e=v.discriminatedUnion("type",[Fm,rC,nC,Nse]),a5e=v.union([v.object({accepted:v.literal(!0)}),v.object({accepted:v.literal(!1),reason:v.union([v.literal("not-pending"),v.literal("bad-response")])})]);var Pse=/(?:\u001B\]|\u009D)(?:(?!\u0007|\u001B\\)[\s\S])*(?:\u0007|\u001B\\|$)/gu,Dse=/(?:\u001B\[|\u009B)[0-?]*[ -/]*[@-~]/gu,Lse=/\u001B[@-_]/gu,Mse=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/gu,Fse=/[\u200B\u200E\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF]/gu;function oC(e,t){if(!Number.isInteger(t)||t<=0)throw new Error(`${e} must be a positive integer`)}l(oC,"assertPositiveInteger$1");function aC(e){return e.replace(Pse,"").replace(Dse,"").replace(Lse,"").replace(Mse,"").replace(Fse,"").replace(/\s+/gu," ").trim()}l(aC,"cleanTitleText");function lC(e,t){if(oC("maxBytes",t),Buffer.byteLength(e,"utf8")<=t)return e;let r=0,n="";for(let i of e){let s=Buffer.byteLength(i,"utf8");if(r+s>t)break;n+=i,r+=s}return n}l(lC,"truncateTitleUtf8");function Wo(e,t){return lC(aC(e),t).trimEnd()}l(Wo,"normalizeSessionTitle");function sC(e,t,r){return oC("maxWords",t),lC(aC(e).split(" ").filter(Boolean).slice(0,t).join(" "),r).trimEnd()}l(sC,"fallbackSessionTitle");var qS=class extends Error{static{l(this,"SessionTitleInvalidError")}name="SessionTitleInvalidError"};function Pd(e,t){let r=[];for(let n of e){if(t!==void 0&&n.seq>t)break;if(n.type!=="user/message"||n.data.source.kind!=="user")continue;let i=n.data.content.filter(s=>s.type==="text").map(s=>s.text).join(`
|
|
429
|
+
`);Wo(i,Number.MAX_SAFE_INTEGER).length!==0&&r.push({seq:n.seq,text:i})}return r}l(Pd,"collectSessionTitleMessages");function Fa(e){let t=e.findLast(r=>r.type==="session/title");if(t!==void 0)return gr({title:t.data.title,messageSeqs:[...t.data.messageSeqs],source:Use(t.data.source),eventSeq:t.seq,updatedAt:t.time})}l(Fa,"foldSessionTitle");function Use(e){switch(e.kind){case"fallback":return{kind:"fallback"};case"provider":return{kind:"provider",provider:e.provider,...e.model===void 0?{}:{model:{...e.model}}};case"user":return{kind:"user"};default:return An(e,"SessionTitleSource")}}l(Use,"copySessionTitleSource");function WS(e,t){if(!Number.isInteger(t)||t<=0)throw new Error(`session-title: ${e} must be a positive integer`)}l(WS,"assertPositiveInteger");var x5e=class extends ut{static{l(this,"SessionTitleService")}static inject=["sessions"];static Config=re.object({fallbackMaxWords:re.number().step(1).min(1).required(),fallbackMaxBytes:re.number().step(1).min(1).required(),maxTitleBytes:re.number().step(1).min(1).required()});config;ownerFiber;registration;work=new Map;lifetime=new AbortController;inFlight=new Set;constructor(e,t){super(e,"sessionTitle"),this.ownerFiber=e.fiber;let r=t;if(r===null||typeof r!="object")throw new Error("session-title: configuration is required");let n=r;if(WS("fallbackMaxWords",n.fallbackMaxWords),WS("fallbackMaxBytes",n.fallbackMaxBytes),WS("maxTitleBytes",n.maxTitleBytes),n.fallbackMaxBytes>n.maxTitleBytes)throw new Error("session-title: fallbackMaxBytes must not exceed maxTitleBytes");this.config=gr({...n}),e.effect(()=>async()=>{this.lifetime.abort(new Error("session-title service disposed")),this.registration!==void 0&&(this.registration.closing=!0),this.registration=void 0;for(let i of this.work.values())delete i.pending,i.active?.controller.abort(new Error("session-title service disposed"));await this.drain(this.inFlight),this.work.clear()},"sessionTitle lifecycle"),e.inject(["sessionProjections"],i=>{let s=v.union([v.string().min(1),v.null()]);i.sessionProjections.register({key:"title",stateSchema:s,init:l(()=>null,"init"),apply:l((o,a)=>a.type==="session/title"?a.data.title:o,"apply"),wire:{viewSchema:s,view:l(o=>o,"view")},stateVersion:1})}),e.on("session/event",(i,s)=>{switch(s.type){case"user/message":this.onUserMessage(i,s);break;case"request/header":this.onRequestHeader(i,s);break;default:break}}),e.on("llm/stream",(i,s)=>(this.onMainRequest(i),s()),{global:!0,prepend:!0}),e.on("session/disposed",i=>{let s=this.work.get(i);s!==void 0&&(s.active?.controller.abort(new Error("session disposed during title generation")),this.work.delete(i))})}get(e){return Fa(e.events)}rename(e,t){if(this.assertServiceActive(),this.ctx.sessions.get(e.id)!==e)throw new Error(`session "${e.id}" is not live in this store`);let r=Wo(t,this.config.maxTitleBytes);if(r.length===0)throw new qS("session title must contain visible characters");let n=this.stateFor(e);this.supersede(n,"user rename superseded automatic title generation"),e.append("session/title",{title:r,messageSeqs:[],source:{kind:"user"}});let i=this.get(e);if(i===void 0)throw new Error("renamed title failed to fold");return i}async refresh(e,t){if(t?.throwIfAborted(),this.assertServiceActive(),this.ctx.sessions.get(e.id)!==e)throw new Error(`session "${e.id}" is not live in this store`);let r=this.registration,n=Pd(e.events),i=n.at(-1);if(r===void 0||r.closing||i===void 0){let d=this.get(e),[f]=n;if(d?.source.kind==="user"&&f!==void 0)return this.appendFallback(e,f),t?.throwIfAborted(),this.get(e);let p=await this.ensureFallback(e);return t?.throwIfAborted(),p}let s=this.stateFor(e),o=this.supersede(s,"explicit title refresh superseded older generation"),a=this.activate({registration:r,revision:o,throughSeq:i.seq},s,t),c=e.requestHeader()?.config,u=c===void 0?void 0:{provider:c.provider,model:c.model};return this.startProvider(e,a,u)}register(e){if(this.validateProvider(e),this.registration!==void 0)throw new Error(`session-title provider "${this.registration.provider.id}" is already registered`);let t={provider:e,active:new Set,closing:!1};return this.ctx.effect(function*(){this.registration=t,yield async()=>{t.closing=!0;for(let r of this.work.values())r.pending?.registration===t&&delete r.pending,r.active?.registration===t&&r.active.controller.abort(new Error(`session-title provider "${e.id}" was disposed`));await this.drain(t.active),this.registration===t&&(this.registration=void 0)}}.bind(this),"sessionTitle.register()")}onUserMessage(e,t){if(!this.serviceActive()||t.data.source.kind!=="user"||Pd([t]).length===0||this.get(e)?.source.kind==="user")return;let r=this.registration;if(r!==void 0&&!r.closing){let n=Pd(e.events,t.seq);if(r.provider.automatic==="all-prompts"||e.header.parentSession===void 0&&n.length===1&&this.get(e)===void 0){let i=this.stateFor(e);i.pending={registration:r,revision:this.supersede(i,"newer user message superseded title generation"),throughSeq:t.seq}}}this.defer(async()=>{try{await this.ensureFallback(e)}catch(n){if(!this.serviceActive())return;this.ctx.logger.warn(`session "${e.id}": fallback title update failed: ${String(n)}`)}})}onRequestHeader(e,t){if(!this.serviceActive())return;let r=this.work.get(e),n=r?.pending;if(r===void 0||n===void 0||n.throughSeq>=t.seq)return;let i={provider:t.data.header.config.provider,model:t.data.header.config.model};this.startPending(e,r,n,i)}onMainRequest(e){if(!this.serviceActive()||e.sessionId===void 0||!s_(e))return;let t=this.ctx.sessions.get(e.sessionId),r=t===void 0?void 0:this.work.get(t),n=r?.pending;if(t===void 0||r===void 0||n===void 0)return;let i=t.events.findLast(o=>o.type==="step/start"||o.type==="step/end"),s=t.requestHeader()?.config;i?.type!=="step/start"||i.seq<=n.throughSeq||s?.provider!==e.provider||s.model!==e.model||this.startPending(t,r,n,{provider:e.provider,model:e.model})}startPending(e,t,r,n){delete t.pending,this.defer(async()=>{if(this.registration!==r.registration||r.registration.closing||this.work.get(e)!==t||t.revision!==r.revision)return;let i=this.activate(r,t);try{await this.startProvider(e,i,n)}catch(s){if(i.signal.aborted||!this.serviceActive())return;this.ctx.logger.warn(`session "${e.id}": automatic title generation failed: ${String(s)}`)}})}startProvider(e,t,r){let n=Promise.resolve().then(()=>this.runProvider(e,t,r));return this.track(n,t.registration)}async runProvider(e,t,r){try{this.assertCurrent(e,t),await this.ensureFallback(e),this.assertCurrent(e,t);let n=Pd(e.events,t.throughSeq),i=await t.registration.provider.generate({session:e,messages:n,...r===void 0?{}:{route:r},signal:t.signal});this.assertCurrent(e,t);let s=this.validateResult(i,n);return e.append("session/title",{title:s.title,messageSeqs:[...s.messageSeqs],source:{kind:"provider",provider:t.registration.provider.id,...s.model===void 0?{}:{model:s.model}}}),this.get(e)}finally{let n=this.work.get(e);n?.active===t&&delete n.active}}validateResult(e,t){if(e===null||typeof e!="object")throw new Error("session-title provider returned an invalid result");let r=e;if(typeof r.title!="string")throw new Error("session-title provider title must be a string");let n=Wo(r.title,this.config.maxTitleBytes);if(n.length===0)throw new Error("session-title provider returned an empty title");if(!Array.isArray(r.messageSeqs)||r.messageSeqs.length===0)throw new Error("session-title provider must identify at least one source message seq");let i=[],s=new Map(t.map((u,d)=>[u.seq,d])),o=-1;for(let u of r.messageSeqs){if(typeof u!="number")throw new Error("session-title provider messageSeqs must be unique, ordered seqs from the request");let d=s.get(u);if(!Number.isSafeInteger(u)||u<0||d===void 0||d<=o)throw new Error("session-title provider messageSeqs must be unique, ordered seqs from the request");i.push(u),o=d}let a=r.model,c;if(a!==void 0){if(a===null||typeof a!="object")throw new Error("session-title provider result model must contain non-empty provider and model strings");let u=a;if(typeof u.provider!="string"||u.provider.length===0||typeof u.model!="string"||u.model.length===0)throw new Error("session-title provider result model must contain non-empty provider and model strings");c={provider:u.provider,model:u.model}}return{title:n,messageSeqs:i,...c===void 0?{}:{model:c}}}assertCurrent(e,t){this.assertServiceActive(),t.signal.throwIfAborted();let r=this.work.get(e);if(this.registration!==t.registration||r?.active!==t||r.revision!==t.revision||this.ctx.sessions.get(e.id)!==e)throw new Error("session title generation state changed without cancellation")}activate(e,t,r){let n=new AbortController,i=r===void 0?AbortSignal.any([n.signal,this.lifetime.signal]):AbortSignal.any([n.signal,this.lifetime.signal,r]),s={...e,controller:n,signal:i};return t.active=s,s}supersede(e,t){return e.active?.controller.abort(new Error(t)),delete e.pending,e.revision+=1,e.revision}stateFor(e){let t=this.work.get(e);return t===void 0&&(t={revision:0},this.work.set(e,t)),t}defer(e){let t=Promise.resolve().then(async()=>{this.serviceActive()&&await e()});this.track(t)}track(e,t){this.inFlight.add(e),t?.active.add(e);let r=l(()=>{this.inFlight.delete(e),t?.active.delete(e)},"settled");return e.then(r,r),e}async drain(e){for(;e.size>0;)await Promise.allSettled([...e])}serviceActive(){return!this.lifetime.signal.aborted&&this.ownerFiber.uid!==null&&this.ownerFiber.state===2}assertServiceActive(){if(!this.serviceActive())throw new Error("session-title service disposed")}validateProvider(e){if(e===null||typeof e!="object")throw new Error("session-title provider must be an object");let t=e;if(typeof t.id!="string"||t.id.length===0)throw new Error("session-title provider id must be a non-empty string");if(t.automatic!=="first-prompt"&&t.automatic!=="all-prompts")throw new Error("session-title provider automatic mode is invalid");if(typeof t.generate!="function")throw new Error(`session-title provider "${t.id}" requires generate()`)}appendFallback(e,t){let r=sC(t.text,this.config.fallbackMaxWords,this.config.fallbackMaxBytes);r.length!==0&&e.append("session/title",{title:r,messageSeqs:[t.seq],source:{kind:"fallback"}})}async ensureFallback(e){this.assertServiceActive();let t=this.get(e);if(t!==void 0)return t;let[r]=Pd(e.events);if(r===void 0)return;let n=sC(r.text,this.config.fallbackMaxWords,this.config.fallbackMaxBytes);if(n.length===0)return;let i=this.stateFor(e);if(i.fallback!==void 0)return i.fallback;let s=Promise.resolve().then(()=>{if(this.assertServiceActive(),this.ctx.sessions.get(e.id)!==e)throw new Error(`session "${e.id}" is not live in this store`);let o=this.get(e);return o!==void 0?o:(e.append("session/title",{title:n,messageSeqs:[r.seq],source:{kind:"fallback"}}),this.get(e))});i.fallback=s;try{return await s}finally{delete i.fallback}}};var Ld=class extends Wr{static{l(this,"SessionQueryError")}constructor(e,t,r){super(e,t,r)}};function jse(e){switch(e.type){case"user/message":return HS(e.data.content);case"assistant/message":return HS(e.data.message.content);case"tool/call":return Dd([e.data.name,e.data.arguments]);case"tool/result":return Dd([HS(e.data.message.content),e.data.error?.name??"",e.data.error?.code??""]);case"todo/write":return Dd(e.data.todos.flatMap(t=>[t.status,t.content]));case"turn/end":return zse(e.data.reason);case"turn/start":case"step/start":case"step/end":case"assistant/chunk":case"request/header":return"";default:return""}}l(jse,"extractSessionEventText");function zse(e){switch(e.kind){case"error":return Dd(["error",e.error.message]);case"aborted":return"aborted";case"max-tokens":case"interrupted":return e.kind;case"completed":return"";default:return""}}l(zse,"turnEndText");function HS(e){return Dd(e.flatMap(cC))}l(HS,"contentText");function cC(e){switch(e.type){case"text":return[e.text];case"reasoning":return[];case"tool-call":return[e.name,e.arguments];case"tool-result":return e.content.flatMap(cC);default:return[]}}l(cC,"blockText");function Dd(e){return e.map(t=>t.trim()).filter(Boolean).join(`
|
|
430
430
|
`)}l(Dd,"joinText");function uC(e,t){let r=Bse(t),n=[];for(let i of t){let s=jse(i);s.length!==0&&n.push({sessionId:e,seq:i.seq,type:i.type,time:i.time,surface:r.get(i.seq)??"log-only",text:s})}return n}l(uC,"buildSessionEventSearchDocuments");function Bse(e){let t;try{t=K_(e)}catch(n){throw new Ld(`invalid session surface: ${n instanceof Error?n.message:"unknown error"}`,"SESSION_QUERY_INVALID_SURFACE",{cause:n})}let r=new Map;for(let n of t.nodes)r.set(n,"current");for(let n of t.replacements)for(let i of n.shadowedSeqs)r.set(i,"shadowed");return r}l(Bse,"classifySurface");var Um="dsh-edge:direct-output-truncated";var zm="You are dsh-edge, a coding agent running in a Cloudflare Worker. Your persistent working directory is /workspace. Use the bash tool when you need to inspect or modify workspace files, then answer with the result. The shell is just-bash, not Linux: native binaries and background processes are unavailable.",jm=class{static{l(this,"EdgeShellBindings")}shells=new Map;bind(t,r){if(this.shells.has(t))throw new Error(`dsh-edge: shell is already bound for session "${t}"`);return this.shells.set(t,r),()=>{this.shells.get(t)===r&&this.shells.delete(t)}}require(t){let r=this.shells.get(t);if(r===void 0)throw new Error(`dsh-edge: no active Computer workspace for session "${t}"`);return r}};function dC(e){return jl({name:"bash",description:"Execute a just-bash command against the persistent /workspace virtual filesystem. Each call starts in /workspace unless workdir is supplied.",parameters:{command:{type:"string",required:!0,description:"The shell command to execute."},description:{type:"string",required:!0,description:"A short explanation of what the command does."},workdir:{type:"string",description:"An absolute directory below /workspace."},timeoutMs:{type:"number",description:"Optional execution timeout in milliseconds."}},output:{schema:{type:"object",additionalProperties:!1,properties:{executionId:{type:"string",required:!0},status:{type:"string",enum:["completed","failed","cancelled"],required:!0},timedOut:{type:"boolean",required:!0},exitCode:{type:"number",required:!0},stdout:{type:"string",required:!0},stderr:{type:"string",required:!0},outputTruncated:{type:"boolean",required:!0}}},render:l((t,r)=>[{type:"text",text:Wse(r)}],"render")},async execute(t,r){let n=r.agent;if(n===void 0)throw new Error("dsh-edge: bash requires an initiating agent");return e.require(n.id).exec(t.command,{cwd:t.workdir??"/workspace",...t.timeoutMs===void 0?{}:{timeoutMs:t.timeoutMs},signal:r.signal})}})}l(dC,"createEdgeBashTool");function Wse(e){let t=`${e.stdout}${e.stderr}`,r=e.outputTruncated?`
|
|
431
431
|
[output truncated after ${65536} UTF-8 bytes]`:"",n=e.timedOut?`
|
|
432
432
|
[command timed out]`:"",i=e.exitCode===0?"":`
|
|
433
|
-
[exit code: ${e.exitCode}]`;return t+r+n+i||"(no output)"}l(Wse,"formatExecution");var QS={};ti(QS,{Config:()=>jC,DEFAULT_CONTEXT_WINDOW:()=>Ud,DEFAULT_MAX_REQUEST_IMAGE_BYTES:()=>NC,DEFAULT_MAX_TOKENS:()=>OC,DEFAULT_STREAM_IDLE_TIMEOUT_MS:()=>CC,DeepSeekAdapter:()=>LC,PUBLIC_BASE_URL:()=>Coe,apply:()=>Roe,inject:()=>_oe,name:()=>$oe,resolveAdapterOptions:()=>zC});var fC=["process","project-env","user-env"];function pC(e){return process.platform==="win32"?e.toUpperCase():e}l(pC,"lookupKey");function qse(e){let t=new Map;for(let n of e)t.set(n.source,{...n.path===void 0?{}:{path:n.path},values:new Map(Object.entries(n.values).map(([i,s])=>[pC(i),s]))});let r=l((n,i)=>{let s=pC(n);for(let o of fC){if(!i.includes(o))continue;let a=t.get(o),c=a?.values.get(s);if(c!==void 0)return{value:c,source:o,...a?.path===void 0?{}:{path:a.path}}}},"getFrom");return{get:l(n=>r(n,fC),"get"),getFrom:r}}l(qse,"createLaunchEnvironmentSnapshot");function vc(e){return e.get("launchEnvironment")??qse([{source:"process",values:process.env}])}l(vc,"launchEnvironmentOf");import{randomUUID as Zse}from"node:crypto";import{mkdirSync as Kse,readFileSync as Yse,writeFileSync as gC}from"node:fs";import{dirname as Xse,join as Jse}from"node:path";import{opendir as
|
|
433
|
+
[exit code: ${e.exitCode}]`;return t+r+n+i||"(no output)"}l(Wse,"formatExecution");var QS={};ti(QS,{Config:()=>jC,DEFAULT_CONTEXT_WINDOW:()=>Ud,DEFAULT_MAX_REQUEST_IMAGE_BYTES:()=>NC,DEFAULT_MAX_TOKENS:()=>OC,DEFAULT_STREAM_IDLE_TIMEOUT_MS:()=>CC,DeepSeekAdapter:()=>LC,PUBLIC_BASE_URL:()=>Coe,apply:()=>Roe,inject:()=>_oe,name:()=>$oe,resolveAdapterOptions:()=>zC});var fC=["process","project-env","user-env"];function pC(e){return process.platform==="win32"?e.toUpperCase():e}l(pC,"lookupKey");function qse(e){let t=new Map;for(let n of e)t.set(n.source,{...n.path===void 0?{}:{path:n.path},values:new Map(Object.entries(n.values).map(([i,s])=>[pC(i),s]))});let r=l((n,i)=>{let s=pC(n);for(let o of fC){if(!i.includes(o))continue;let a=t.get(o),c=a?.values.get(s);if(c!==void 0)return{value:c,source:o,...a?.path===void 0?{}:{path:a.path}}}},"getFrom");return{get:l(n=>r(n,fC),"get"),getFrom:r}}l(qse,"createLaunchEnvironmentSnapshot");function vc(e){return e.get("launchEnvironment")??qse([{source:"process",values:process.env}])}l(vc,"launchEnvironmentOf");import{randomUUID as Zse}from"node:crypto";import{mkdirSync as Kse,readFileSync as Yse,writeFileSync as gC}from"node:fs";import{dirname as Xse,join as Jse}from"node:path";import{opendir as z5e,realpath as B5e}from"node:fs/promises";import{homedir as GS}from"node:os";import{basename as H5e,dirname as G5e,join as VS,resolve as Hse}from"node:path";var hC=".dsh",V5e=`~/${hC}`,Gse="DSH_HOME";function Vse(){return VS(GS(),hC)}l(Vse,"defaultDshHome");function Bm(e){return e==="~"?GS():e.startsWith("~/")||e.startsWith("~\\")?VS(GS(),e.slice(2)):e}l(Bm,"expandHomePath");function ZS(e,t=process.env){let r=t[Gse];return Hse(Bm(e??(r!==void 0&&r.trim().length>0?r:Vse())))}l(ZS,"resolveDshHome");function mC(...e){return VS(ZS(),...e)}l(mC,"dshHomePath");var Qse=".anonymous-user-id",eoe=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,yC=new Map;function vC(e){let t;try{t=Yse(e,"utf8")}catch{return}let r=t.trim();return eoe.test(r)?r:void 0}l(vC,"readPersistedId");function wC(e={}){let t=Jse(ZS(void 0,e.env??process.env),Qse),r=yC.get(t);if(r!==void 0)return r;let n=vC(t);if(n===void 0){let i=(e.randomUUID??Zse)();try{Kse(Xse(t),{recursive:!0}),gC(t,`${i}
|
|
434
434
|
`,{encoding:"utf8",flag:"wx"}),n=i}catch{if(n=vC(t),n===void 0){try{gC(t,`${i}
|
|
435
435
|
`,"utf8")}catch{}n=i}}}return yC.set(t,n),n}l(wC,"getOrCreateAnonymousUserId");import{Buffer as toe}from"node:buffer";var Ct=class extends Error{static{l(this,"AttachmentError")}code;constructor(e,t,r){super(e,r),this.name="AttachmentError",this.code=t}};function roe(e){let t=toe.from(e,"base64");if(e.length===0||t.toString("base64")!==e)throw new Ct("Image upload is not canonical base64.","INVALID_IMAGE_BASE64");return new Uint8Array(t)}l(roe,"decodeBase64");function noe(e){return{data:roe(e.data),mediaType:e.mediaType,...e.name===void 0?{}:{name:e.name}}}l(noe,"saveInput");async function Wm(e,t){return e.saveImages(t.map(noe))}l(Wm,"admitEncodedImages");var KS=class extends ut{static{l(this,"AttachmentStore")}constructor(e){super(e,"attachments")}async saveImages(e){let{maxImagesPerMessage:t,maxMessageImageBytes:r,mediaTypes:n}=this.imageLimits;if(e.length>t)throw new Ct("Image batch exceeds the configured image-count limit.","TOO_MANY_IMAGES");if(e.reduce((s,o)=>s+o.data.byteLength,0)>r)throw new Ct("Image batch exceeds the configured aggregate image-byte limit.","IMAGES_TOO_LARGE");for(let s of e)if(!n.includes(s.mediaType))throw new Ct(`Image type ${s.mediaType} is not accepted by this deployment.`,"UNSUPPORTED_IMAGE_TYPE");for(let s of e)await this.validateImage(s);let i=[];for(let s of e)i.push(await this.saveImage(s));return i}};var Md=class extends Error{static{l(this,"ParseError")}constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},bC=10,ioe=13,ja=32;function YS(e){}l(YS,"noop");function SC(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=YS,onError:r=YS,onRetry:n=YS,onComment:i,maxBufferSize:s}=e,o=[],a=0,c=!0,u,d="",f=0,p,h=!1;function m(S){if(h)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,S.charCodeAt(0)===239&&S.charCodeAt(1)===187&&S.charCodeAt(2)===191&&(S=S.slice(3))),o.length===0){let O=y(S);O!==""&&(o.push(O),a=O.length),g();return}if(S.indexOf(`
|
|
436
436
|
`)===-1&&S.indexOf("\r")===-1){o.push(S),a+=S.length,g();return}o.push(S);let A=o.join("");o.length=0,a=0;let $=y(A);$!==""&&(o.push($),a=$.length),g()}l(m,"feed");function g(){s!==void 0&&(a+d.length<=s||(h=!0,o.length=0,a=0,u=void 0,d="",f=0,p=void 0,r(new Md(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}l(g,"checkBufferSize");function y(S){let A=0;if(S.indexOf("\r")===-1){let $=S.indexOf(`
|
|
@@ -709,7 +709,7 @@ ${n}`:""}`}});function NN(e){if(e.url.trim().length===0)throw new Error("url mus
|
|
|
709
709
|
button, .button { display: inline-block; box-sizing: border-box; margin-top: 1rem; padding: .75rem 1rem; border: 0; border-radius: .6rem; background: #5a87ff; color: #071022; font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
|
|
710
710
|
.secondary { background: #29314b; color: #edf2ff; }
|
|
711
711
|
.error { padding: .75rem; border-radius: .5rem; background: #461d2b; color: #ffd6df; }
|
|
712
|
-
`}l(OR,"pageStyles");var tue="https://api.deepseek.com";var rue="deepseek-v4-flash",nue="high";var iue=/^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,127}$/;function lk(e){let t=e??tue,r;try{r=new URL(t)}catch{throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL")}if(r.protocol!=="http:"&&r.protocol!=="https:"||r.username.length>0||r.password.length>0)throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL without credentials");return t}l(lk,"resolveEdgeBaseURL");function sf(e){if(e===void 0)return rue;if(!iue.test(e))throw new Error("dsh-edge: DEEPSEEK_MODEL must be a valid model id of at most 128 characters");return e}l(sf,"resolveEdgeModel");function ck(e){if(e===void 0)return nue;if(e!=="off"&&e!=="low"&&e!=="high"&&e!=="max")throw new Error("dsh-edge: DEEPSEEK_REASONING_EFFORT must be one of off, low, high, or max");return e}l(ck,"resolveEdgeReasoningEffort");function uk(e){if(e===void 0)return 12e4;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t)||t>2147483647)throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be no greater than 2147483647");return t}l(uk,"resolveEdgeStreamIdleTimeoutMs");function dk(e){if(e===void 0)return 256e3;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t))throw new Error(`dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be no greater than ${Number.MAX_SAFE_INTEGER}`);return t}l(dk,"resolveEdgeMaxOutputTokens");var fk={name:"dsh-edge",version:"0.4.0",description:"Your DeepSeek Harness, anywhere \u2014 deploy a persistent personal coding agent to Cloudflare Workers in one command",author:"pawaca",license:"MIT",type:"module",bin:{"dsh-edge":"scripts/cli.mjs"},files:["dist","worker","scripts/*.d.mts","scripts/*.mjs","wrangler.jsonc","README.md","README.zh.md","LICENSE","THIRD_PARTY_NOTICES.md"],repository:{type:"git",url:"git+https://github.com/pawaca/dsh-edge.git",directory:"apps/dsh-edge"},homepage:"https://github.com/pawaca/dsh-edge#readme",bugs:{url:"https://github.com/pawaca/dsh-edge/issues"},keywords:["deepseek","deepseek-harness","ai-agents","byok","cloudflare-workers","durable-objects","self-hosted"],engines:{node:">=22.14.0"},publishConfig:{access:"public"},dshEdge:{upstreamVersion:"0.1.1-rc.1"},scripts:{"bundle:direct":"pnpm run web:build && pnpm --dir standalone run build:worker:direct && node standalone/scripts/promote.mjs direct","bundle:isolated":"pnpm run web:build && pnpm --dir standalone run build:worker:isolated && node standalone/scripts/promote.mjs isolated","bundle:workers":"pnpm --dir standalone run build && pnpm --dir standalone run verify && node standalone/scripts/promote.mjs all",dev:"pnpm run bundle:direct && node scripts/dev.mjs direct","dev:isolated":"pnpm run bundle:isolated && node scripts/dev.mjs isolated","dsh-edge":"node scripts/cli.mjs","example:install":"node examples/install-keyless.mjs","install:cloudflare":"pnpm run bundle:workers && node scripts/cli.mjs install","legal:write":"node scripts/legal-files.mjs write","pack:verify":"node scripts/verify-packed.mjs",prepack:"node scripts/legal-files.mjs verify && pnpm run bundle:workers","web:build":"pnpm --dir standalone run build:web && node standalone/scripts/promote.mjs web",test:"vitest run --root ../.. --project edge-runtime","test:integration":"pnpm run bundle:workers && node tests/run-session-integration.mjs","test:snapshot":"vitest run --root ../.. --config apps/dsh-edge/vitest.snapshot.config.ts",typecheck:"tsc --noEmit"},dependencies:{"@clack/prompts":"1.7.0","compare-versions":"6.1.1",execa:"^10.0.0","jsonc-parser":"^3.3.1",wrangler:"4.123.0"},devDependencies:{"@cloudflare/computer":"0.2.0","@cloudflare/workers-types":"5.20260812.1","@deepseek-ai/cordis":"4.0.1","@deepseek-ai/dsh-agent":"0.1.1-rc.1","@deepseek-ai/dsh-agent-loop":"0.1.1-rc.1","@deepseek-ai/dsh-anonymous-user-id":"0.1.1-rc.1","@deepseek-ai/dsh-attachment":"0.1.1-rc.1","@deepseek-ai/dsh-brand":"0.1.1-rc.1","@deepseek-ai/dsh-credentials":"0.1.1-rc.1","@deepseek-ai/dsh-host-apiproxy":"0.1.1-rc.1","@deepseek-ai/dsh-launch-environment":"0.1.1-rc.1","@deepseek-ai/dsh-llm":"0.1.1-rc.1","@deepseek-ai/dsh-llm-deepseek":"0.1.1-rc.1","@deepseek-ai/dsh-session":"0.1.1-rc.1","@deepseek-ai/dsh-session-persistence":"0.1.1-rc.1","@deepseek-ai/dsh-session-query":"0.1.1-rc.1","@deepseek-ai/dsh-session-title":"0.1.1-rc.1","@deepseek-ai/dsh-settings":"0.1.1-rc.1","@deepseek-ai/dsh-system-prompt":"0.1.1-rc.1","@deepseek-ai/dsh-tool-call-timeout-policy":"0.1.1-rc.1","@deepseek-ai/dsh-tool-web":"0.1.1-rc.1","@deepseek-ai/dsh-tools":"0.1.1-rc.1","@deepseek-ai/dsh-web":"0.1.1-rc.1","@deepseek-ai/dsh-web-search-deepseek":"0.1.1-rc.1","just-bash":"3.3.0","fast-png":"8.0.0","jpeg-js":"0.4.4",playwright:"^1.49.0",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}};var Ng=fk.version,NR=fk.dshEdge.upstreamVersion;function oue(){return"dsh-edge@0.4.0/direct"}l(oue,"resolveEdgeDeploymentId");function Rg(e){return{baseURL:lk(e.DEEPSEEK_BASE_URL),maxTokens:dk(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:sf(e.DEEPSEEK_MODEL),reasoningEffort:ck(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:yg(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:uk(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:ef(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(Rg,"resolveEdgeDeploymentConfig");function aue(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}l(aue,"edgeDeploymentApiKeyConfigured");function lue(e){let t=lk(e),r=new URL(t);return r.search.length===0&&r.hash.length===0?t:(r.search="",r.hash="",r.href)}l(lue,"projectedEdgeBaseURL");function pk(e,t){return{shell:e.LOADER===void 0?"just-bash-direct":"just-bash-isolated",storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:oue(),apiKeyConfigured:aue(e),baseURL:lue(e.DEEPSEEK_BASE_URL),maxTokens:dk(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:sf(e.DEEPSEEK_MODEL),reasoningEffort:ck(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:yg(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:uk(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:ef(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(pk,"resolveEdgeDeploymentProfile");function RR(e){Rg(e);let t=pk(e);return{ok:!0,service:"dsh-edge",storage:t.storage,attachmentStorage:t.attachmentStorage,shell:t.shell,agent:"upstream-react-loop-agent",access:"single-owner-cookie",deploymentId:t.deploymentId,version:Ng,upstreamVersion:NR,status:"ready"}}l(RR,"resolveEdgeDeploymentHealth");import{WorkerEntrypoint as uLe}from"cloudflare:workers";var El=ay(PR());var hk=l((e,t,r)=>{let n=e instanceof RegExp?DR(e,r):e,i=t instanceof RegExp?DR(t,r):t,s=n!==null&&i!=null&&cue(n,i,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+n.length,s[1]),post:r.slice(s[1]+i.length)}},"balanced"),DR=l((e,t)=>{let r=t.match(e);return r?r[0]:null},"maybeMatch"),cue=l((e,t,r)=>{let n,i,s,o,a,c=r.indexOf(e),u=r.indexOf(t,c+1),d=c;if(c>=0&&u>0){if(e===t)return[c,u];for(n=[],s=r.length;d>=0&&!a;){if(d===c)n.push(d),c=r.indexOf(e,d+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,u])}else i=n.pop(),i!==void 0&&i<s&&(s=i,o=u),u=r.indexOf(t,d+1);d=c<u&&c>=0?c:u}n.length&&o!==void 0&&(a=[s,o])}return a},"range");var LR="\0SLASH"+Math.random()+"\0",MR="\0OPEN"+Math.random()+"\0",yk="\0CLOSE"+Math.random()+"\0",FR="\0COMMA"+Math.random()+"\0",UR="\0PERIOD"+Math.random()+"\0",uue=new RegExp(LR,"g"),due=new RegExp(MR,"g"),fue=new RegExp(yk,"g"),pue=new RegExp(FR,"g"),hue=new RegExp(UR,"g"),mue=/\\\\/g,gue=/\\{/g,yue=/\\}/g,vue=/\\,/g,wue=/\\\./g,bue=1e5,xue=4e6;function mk(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}l(mk,"numeric");function Eue(e){return e.replace(mue,LR).replace(gue,MR).replace(yue,yk).replace(vue,FR).replace(wue,UR)}l(Eue,"escapeBraces");function Sue(e){return e.replace(uue,"\\").replace(due,"{").replace(fue,"}").replace(pue,",").replace(hue,".")}l(Sue,"unescapeBraces");function jR(e){if(!e)return[""];let t=[],r=hk("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:s}=r,o=n.split(",");o[o.length-1]+="{"+i+"}";let a=jR(s);return s.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}l(jR,"parseCommaParts");function zR(e,t={}){if(!e)return[];let{max:r=bue,maxLength:n=xue}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),gk(Eue(e),r,n,!0).map(Sue)}l(zR,"expand");function kue(e){return"{"+e+"}"}l(kue,"embrace");function Aue(e){return/^-?0\d/.test(e)}l(Aue,"isPadded");function Iue(e,t){return e<=t}l(Iue,"lte");function $ue(e,t){return e>=t}l($ue,"gte");function of(e,t,r,n,i,s){let o=[],a=0;for(let c=0;c<e.length;c++)for(let u=0;u<r.length;u++){if(o.length>=n)return o;let d=e[c]+t+r[u];if(!(s&&!d)){if(a+d.length>i)return o;o.push(d),a+=d.length}}return o}l(of,"combine");function _ue(e,t,r,n){let i=e.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let o=mk(i[0]),a=mk(i[1]),c=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(mk(i[2])),1):1,d=Iue;a<o&&(u*=-1,d=$ue);let p=i.some(Aue),h=0;for(let m=o;d(m,a)&&s.length<r;m+=u){let g;if(t)g=String.fromCharCode(m),g==="\\"&&(g="");else if(g=String(m),p){let y=c-g.length;if(y>0){let x=new Array(y+1).join("0");m<0?g="-"+x+g.slice(1):g=x+g}}if(h+g.length>n)break;s.push(g),h+=g.length}return s}l(_ue,"expandSequence");function gk(e,t,r,n){let i=[""],s=!1,o=!0;for(;;){let a=hk("{","}",e);if(!a)return of(i,e,[""],t,r,s);let c=a.pre;if(/\$$/.test(c)){if(i=of(i,c+"{"+a.body+"}",[""],t,r,s&&!a.post.length),o=!1,!a.post.length)break;e=a.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=u||d,p=a.body.indexOf(",")>=0;if(!f&&!p){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+yk+a.post,n=!0;continue}return of(i,c+"{"+a.body+"}"+a.post,[""],t,r,s)}o&&(s=n&&!f,o=!1);let h;if(f)h=_ue(a.body,d,t,r);else{let m=jR(a.body);if(m.length===1&&m[0]!==void 0&&(m=gk(m[0],t,r,!1).map(kue),m.length===1)){if(i=of(i,c+m[0],[""],t,r,s&&!a.post.length),!a.post.length)break;e=a.post;continue}let g=s&&!a.post.length&&!c;for(let x=0;g&&x<i.length;x++)i[x]&&(g=!1);h=[];let y=0;e:for(let x=0;x<m.length;x++){let w=gk(m[x],t,r,!1);for(let b=0;b<w.length;b++){let k=w[b];if(!(g&&!k)){if(h.length>=t||y+k.length>r)break e;h.push(k),y+=k.length}}}}if(i=of(i,c,h,t,r,s&&!a.post.length),!a.post.length)break;e=a.post}return i}l(gk,"expand_");var af=l(e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var Tue={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},lf=l(e=>e.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Cue=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),BR=l(e=>e.join(""),"rangesToString"),WR=l((e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,o=!1,a=!1,c=!1,u=!1,d=r,f="";e:for(;s<e.length;){let g=e.charAt(s);if((g==="!"||g==="^")&&s===r+1){u=!0,s++;continue}if(g==="]"&&o&&!c){d=s+1;break}if(o=!0,g==="\\"&&!c){c=!0,s++;continue}if(g==="["&&!c){for(let[y,[x,w,b]]of Object.entries(Tue))if(e.startsWith(y,s)){if(f)return["$.",!1,e.length-r,!0];s+=y.length,b?i.push(x):n.push(x),a=a||w;continue e}}if(c=!1,f){g>f?n.push(lf(f)+"-"+lf(g)):g===f&&n.push(lf(g)),f="",s++;continue}if(e.startsWith("-]",s+1)){n.push(lf(g+"-")),s+=2;continue}if(e.startsWith("-",s+1)){f=g,s+=2;continue}n.push(lf(g)),s++}if(d<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let g=n[0].length===2?n[0].slice(-1):n[0];return[Cue(g),!1,d-r,!1]}let p="["+(u?"^":"")+BR(n)+"]",h="["+(u?"":"^")+BR(i)+"]";return[n.length&&i.length?"("+p+"|"+h+")":n.length?p:h,a,d-r,!0]},"parseClass");var Ko=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape");var Hn,Oue=new Set(["!","?","+","*","@"]),vk=l(e=>Oue.has(e),"isExtglobType"),qR=l(e=>vk(e.type),"isExtglobAST"),Nue=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Rue=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Pue=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),HR=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Due="(?!(?:^|/)\\.\\.?(?:$|/))",Dg="(?!\\.)",Lue=new Set(["[","."]),Mue=new Set(["..","."]),Fue=new Set("().*{}+?[]^$\\!"),Uue=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),wk="[^/]",GR=wk+"*?",VR=wk+"+?",jue=0,Ha=class{static{l(this,"AST")}type;#e;#r;#n=!1;#t=[];#i;#s;#a;#u=!1;#l;#o;#c=!1;id=++jue;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#i=r,this.#e=this.#i?this.#i.#e:this,this.#l=this.#e===this?n:this.#e.#l,this.#a=this.#e===this?[]:this.#e.#a,t==="!"&&!this.#e.#u&&this.#a.push(this),this.#s=this.#i?this.#i.#t.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#o=this.#t.map(t=>String(t)).join("")}#x(){if(this!==this.#e)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let t;for(;t=this.#a.pop();){if(t.type!=="!")continue;let r=t,n=r.#i;for(;n;){for(let i=r.#s+1;!n.type&&i<n.#t.length;i++)for(let s of t.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#t[i])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof Hn&&r.#i===this))throw new Error("invalid part: "+r);this.#t.push(r)}}toJSON(){let t=this.type===null?this.#t.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#t.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#u&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#s===0)return!0;let t=this.#i;for(let r=0;r<this.#s;r++){let n=t.#t[r];if(!(n instanceof Hn&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#t.length:0;return this.#s===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new Hn(this.type,t);for(let n of this.#t)r.copyIn(n);return r}static#h(t,r,n,i,s){let o=i.maxExtglobRecursion??2,a=!1,c=!1,u=-1,d=!1;if(r.type===null){let g=n,y="";for(;g<t.length;){let x=t.charAt(g++);if(a||x==="\\"){a=!a,y+=x;continue}if(c){g===u+1?(x==="^"||x==="!")&&(d=!0):x==="]"&&!(g===u+2&&d)&&(c=!1),y+=x;continue}else if(x==="["){c=!0,u=g,d=!1,y+=x;continue}if(!i.noext&&vk(x)&&t.charAt(g)==="("&&s<=o){r.push(y),y="";let b=new Hn(x,r);g=Hn.#h(t,b,g,i,s+1),r.push(b);continue}y+=x}return r.push(y),g}let f=n+1,p=new Hn(null,r),h=[],m="";for(;f<t.length;){let g=t.charAt(f++);if(a||g==="\\"){a=!a,m+=g;continue}if(c){f===u+1?(g==="^"||g==="!")&&(d=!0):g==="]"&&!(f===u+2&&d)&&(c=!1),m+=g;continue}else if(g==="["){c=!0,u=f,d=!1,m+=g;continue}if(!i.noext&&vk(g)&&t.charAt(f)==="("&&(s<=o||r&&r.#g(g))){let x=r&&r.#g(g)?0:1;p.push(m),m="";let w=new Hn(g,p);p.push(w),f=Hn.#h(t,w,f,i,s+x);continue}if(g==="|"){p.push(m),m="",h.push(p),p=new Hn(null,r);continue}if(g===")")return m===""&&r.#t.length===0&&(r.#c=!0),p.push(m),m="",r.push(...h,p),f;m+=g}return r.type=null,r.#r=void 0,r.#t=[t.substring(n-1)],f}#C(t){return this.#m(t,Rue)}#m(t,r=Nue){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null)return!1;let n=t.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#g(n.type,r)}#g(t,r=Pue){return!!r.get(this.type)?.includes(t)}#f(t,r){let n=t.#t[0],i=new Hn(null,n,this.options);i.#t.push(""),n.push(i),this.#E(t,r)}#E(t,r){let n=t.#t[0];this.#t.splice(r,1,...n.#t);for(let i of n.#t)typeof i=="object"&&(i.#i=this);this.#o=void 0}#S(t){return!!HR.get(this.type)?.has(t)}#O(t){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let r=t.#t[0];return!r||typeof r!="object"||r.type===null?!1:this.#S(r.type)}#y(t){let r=HR.get(this.type),n=t.#t[0],i=r?.get(n.type);if(!i)return!1;this.#t=n.#t;for(let s of this.#t)typeof s=="object"&&(s.#i=this);this.type=i,this.#o=void 0,this.#c=!1}static fromGlob(t,r={}){let n=new Hn(null,void 0,r);return Hn.#h(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#r||this.#l.nocase&&!this.#l.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#l.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#l}toRegExpSource(t){let r=t??!!this.#l.dot;if(this.#e===this&&(this.#p(),this.#x()),!qR(this)){let c=this.isStart()&&this.isEnd()&&!this.#t.some(h=>typeof h!="string"),u=this.#t.map(h=>{let[m,g,y,x]=typeof h=="string"?Hn.#k(h,this.#r,c):h.toRegExpSource(t);return this.#r=this.#r||y,this.#n=this.#n||x,m}).join(""),d="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&Mue.has(this.#t[0]))){let m=Lue,g=r&&m.has(u.charAt(0))||u.startsWith("\\.")&&m.has(u.charAt(2))||u.startsWith("\\.\\.")&&m.has(u.charAt(4)),y=!r&&!t&&m.has(u.charAt(0));d=g?Due:y?Dg:""}let f="";return this.isEnd()&&this.#e.#u&&this.#i?.type==="!"&&(f="(?:$|\\/)"),[d+u+f,Ko(u),this.#r=!!this.#r,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#v(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#t=[c],u.type=null,u.#r=void 0,[c,Ko(this.toString()),!1,!1]}let o=!n||t||r||!Dg?"":this.#v(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!r?Dg:"")+VR;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!t?Dg:"")+GR+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+s+c}return[a,Ko(s),this.#r=!!this.#r,this.#n]}#p(){if(qR(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#t.length;n++){let i=this.#t[n];typeof i=="object"&&(i.#p(),this.#m(i)?(r=!1,this.#E(i,n)):this.#C(i)?(r=!1,this.#f(i,n)):this.#O(i)&&(r=!1,this.#y(i)))}}while(!r&&++t<10)}else for(let t of this.#t)typeof t=="object"&&t.#p();this.#o=void 0}#v(t){return this.#t.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=r.toRegExpSource(t);return this.#n=this.#n||o,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#k(t,r,n=!1){let i=!1,s="",o=!1,a=!1;for(let c=0;c<t.length;c++){let u=t.charAt(c);if(i){i=!1,s+=(Fue.has(u)?"\\":"")+u;continue}if(u==="*"){if(a)continue;a=!0,s+=n&&/^[*]+$/.test(t)?VR:GR,r=!0;continue}else a=!1;if(u==="\\"){c===t.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[d,f,p,h]=WR(t,c);if(p){s+=d,o=o||f,c+=p-1,r=r||h;continue}}if(u==="?"){s+=wk,r=!0;continue}s+=Uue(u)}return[s,Ko(t),!!r,o]}};Hn=Ha;var bk=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Xr=l((e,t,r={})=>(af(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Ac(t,r).match(e)),"minimatch"),zue=/^\*+([^+@!?*[(]*)$/,Bue=l(e=>t=>!t.startsWith(".")&&t.endsWith(e),"starDotExtTest"),Wue=l(e=>t=>t.endsWith(e),"starDotExtTestDot"),que=l(e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),"starDotExtTestNocase"),Hue=l(e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),"starDotExtTestNocaseDot"),Gue=/^\*+\.\*+$/,Vue=l(e=>!e.startsWith(".")&&e.includes("."),"starDotStarTest"),Zue=l(e=>e!=="."&&e!==".."&&e.includes("."),"starDotStarTestDot"),Kue=/^\.\*+$/,Yue=l(e=>e!=="."&&e!==".."&&e.startsWith("."),"dotStarTest"),Xue=/^\*+$/,Jue=l(e=>e.length!==0&&!e.startsWith("."),"starTest"),Que=l(e=>e.length!==0&&e!=="."&&e!=="..","starTestDot"),ede=/^\?+([^+@!?*[(]*)?$/,tde=l(([e,t=""])=>{let r=YR([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},"qmarksTestNocase"),rde=l(([e,t=""])=>{let r=XR([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},"qmarksTestNocaseDot"),nde=l(([e,t=""])=>{let r=XR([e]);return t?n=>r(n)&&n.endsWith(t):r},"qmarksTestDot"),ide=l(([e,t=""])=>{let r=YR([e]);return t?n=>r(n)&&n.endsWith(t):r},"qmarksTest"),YR=l(([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},"qmarksTestNoExt"),XR=l(([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},"qmarksTestNoExtDot"),JR=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ZR={win32:{sep:"\\"},posix:{sep:"/"}},sde=JR==="win32"?ZR.win32.sep:ZR.posix.sep;Xr.sep=sde;var vn=Symbol("globstar **");Xr.GLOBSTAR=vn;var ode="[^/]",ade=ode+"*?",lde="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",cde="(?:(?!(?:\\/|^)\\.).)*?",ude=l((e,t={})=>r=>Xr(r,e,t),"filter");Xr.filter=ude;var bi=l((e,t={})=>Object.assign({},e,t),"ext"),dde=l(e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Xr;let t=Xr;return Object.assign(l((n,i,s={})=>t(n,i,bi(e,s)),"m"),{Minimatch:class extends t.Minimatch{static{l(this,"Minimatch")}constructor(i,s={}){super(i,bi(e,s))}static defaults(i){return t.defaults(bi(e,i)).Minimatch}},AST:class extends t.AST{static{l(this,"AST")}constructor(i,s,o={}){super(i,s,bi(e,o))}static fromGlob(i,s={}){return t.AST.fromGlob(i,bi(e,s))}},unescape:l((n,i={})=>t.unescape(n,bi(e,i)),"unescape"),escape:l((n,i={})=>t.escape(n,bi(e,i)),"escape"),filter:l((n,i={})=>t.filter(n,bi(e,i)),"filter"),defaults:l(n=>t.defaults(bi(e,n)),"defaults"),makeRe:l((n,i={})=>t.makeRe(n,bi(e,i)),"makeRe"),braceExpand:l((n,i={})=>t.braceExpand(n,bi(e,i)),"braceExpand"),match:l((n,i,s={})=>t.match(n,i,bi(e,s)),"match"),sep:t.sep,GLOBSTAR:vn})},"defaults");Xr.defaults=dde;var QR=l((e,t={})=>(af(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:zR(e,{max:t.braceExpandMax})),"braceExpand");Xr.braceExpand=QR;var fde=l((e,t={})=>new Ac(e,t).makeRe(),"makeRe");Xr.makeRe=fde;var pde=l((e,t,r={})=>{let n=new Ac(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e},"match");Xr.match=pde;var KR=/[?*]|[+@!]\(.*?\)|\[|\]/,hde=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Ac=class{static{l(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){af(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||JR,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!KR.test(s[2]))&&!KR.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(d=>this.parse(d))];if(u)return[s[0],...s.slice(1).map(d=>this.parse(d))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let s=t[i];i===1&&s===""&&t[0]===""||(s==="."||s==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let a=n[i+1],c=n[i+2],u=n[i+3];if(a!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(i,1);let d=n.slice(0);d[i]="**",t.push(d),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=!0;let c=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...c),n.length===0&&n.push(""),s-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,s=0,o=[],a="";for(;i<t.length&&s<r.length;)if(t[i]===r[s])o.push(a==="b"?r[s]:t[i]),i++,s++;else if(n&&t[i]==="**"&&r[s]===t[i+1])o.push(t[i]),i++;else if(n&&r[s]==="**"&&t[i]===r[s+1])o.push(r[s]),s++;else if(t[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(a==="b")return!1;a="a",o.push(t[i]),i++,s++}else if(r[s]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",o.push(r[s]),i++,s++}else return!1;return t.length===r.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,s=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),u=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),d=!u&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=c?3:a?0:void 0,p=d?3:u?0:void 0;if(typeof f=="number"&&typeof p=="number"){let[h,m]=[t[f],r[p]];h.toLowerCase()===m.toLowerCase()&&(r[p]=h,s=p,i=f)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(vn)?this.#e(t,r,n,i,s):this.#n(t,r,n,i,s)}#e(t,r,n,i,s){let o=r.indexOf(vn,s),a=r.lastIndexOf(vn),[c,u,d]=n?[r.slice(s,o),r.slice(o+1),[]]:[r.slice(s,o),r.slice(o+1,a),r.slice(a+1)];if(c.length){let w=t.slice(i,i+c.length);if(!this.#n(w,c,n,0,0))return!1;i+=c.length,s+=c.length}let f=0;if(d.length){if(d.length+i>t.length)return!1;let w=t.length-d.length;if(this.#n(t,d,n,w,0))f=d.length;else{if(t[t.length-1]!==""||i+d.length===t.length||(w--,!this.#n(t,d,n,w,0)))return!1;f=d.length+1}}if(!u.length){let w=!!f;for(let b=i;b<t.length-f;b++){let k=String(t[b]);if(w=!0,k==="."||k===".."||!this.options.dot&&k.startsWith("."))return!1}return n||w}let p=[[[],0]],h=p[0],m=0,g=[0];for(let w of u)w===vn?(g.push(m),h=[[],0],p.push(h)):(h[0].push(w),m++);let y=p.length-1,x=t.length-f;for(let w of p)w[1]=x-(g[y--]+w[0].length);return!!this.#r(t,p,i,0,n,0,!!f)}#r(t,r,n,i,s,o,a){let c=r[i];if(!c){for(let f=n;f<t.length;f++){a=!0;let p=t[f];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return a}let[u,d]=c;for(;n<=d;){if(this.#n(t.slice(0,n+u.length),u,s,n,0)&&o<this.maxGlobstarRecursion){let h=this.#r(t,r,n+u.length,i+1,s,o+1,a);if(h!==!1)return h}let p=t[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return s||null}#n(t,r,n,i,s){let o,a,c,u;for(o=i,a=s,u=t.length,c=r.length;o<u&&a<c;o++,a++){this.debug("matchOne loop");let d=r[a],f=t[o];if(this.debug(r,d,f),d===!1||d===vn)return!1;let p;if(typeof d=="string"?(p=f===d,this.debug("string match",d,f,p)):(p=d.test(f),this.debug("pattern match",d,f,p)),!p)return!1}if(o===u&&a===c)return!0;if(o===u)return n;if(a===c)return o===u-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return QR(this.pattern,this.options)}parse(t){af(t);let r=this.options;if(t==="**")return vn;if(t==="")return"";let n,i=null;(n=t.match(Xue))?i=r.dot?Que:Jue:(n=t.match(zue))?i=(r.nocase?r.dot?Hue:que:r.dot?Wue:Bue)(n[1]):(n=t.match(ede))?i=(r.nocase?r.dot?rde:tde:r.dot?nde:ide)(n):(n=t.match(Gue))?i=r.dot?Zue:Vue:(n=t.match(Kue))&&(i=Yue);let s=Ha.fromGlob(t,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?ade:r.dot?lde:cde,i=new Set(r.nocase?["i"]:[]),s=t.map(c=>{let u=c.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))i.add(p);return typeof f=="string"?hde(f):f===vn?vn:f._src});u.forEach((f,p)=>{let h=u[p+1],m=u[p-1];f!==vn||m===vn||(m===void 0?h!==void 0&&h!==vn?u[p+1]="(?:\\/|"+n+"\\/)?"+h:u[p]=n:h===void 0?u[p-1]=m+"(?:\\/|\\/"+n+")?":h!==vn&&(u[p-1]=m+"(?:\\/|\\/"+n+"\\/)"+h,u[p+1]=vn))});let d=u.filter(f=>f!==vn);if(this.partial&&d.length>=1){let f=[];for(let p=1;p<=d.length;p++)f.push(d.slice(0,p).join("/"));return"(?:"+f.join("|")+")"}return d.join("/")}).join("|"),[o,a]=t.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+a+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a of s){let c=i;if(n.matchBase&&a.length===1&&(c=[o]),this.matchOne(c,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return Xr.defaults(t).Minimatch}};Xr.AST=Ha;Xr.Minimatch=Ac;Xr.escape=bk;Xr.unescape=Ko;import{gunzipSync as hpe}from"node:zlib";var cf=class{static{l(this,"Diff")}diff(t,r,n={}){let i;typeof n=="function"?(i=n,n={}):"callback"in n&&(i=n.callback);let s=this.castInput(t,n),o=this.castInput(r,n),a=this.removeEmpty(this.tokenize(s,n)),c=this.removeEmpty(this.tokenize(o,n));return this.diffWithOptionsObj(a,c,n,i)}diffWithOptionsObj(t,r,n,i){var s;let o=l(w=>{if(w=this.postProcess(w,n),i){setTimeout(function(){i(w)},0);return}else return w},"done"),a=r.length,c=t.length,u=1,d=a+c;n.maxEditLength!=null&&(d=Math.min(d,n.maxEditLength));let f=(s=n.timeout)!==null&&s!==void 0?s:1/0,p=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}],m=this.extractCommon(h[0],r,t,0,n);if(h[0].oldPos+1>=c&&m+1>=a)return o(this.buildValues(h[0].lastComponent,r,t));let g=-1/0,y=1/0,x=l(()=>{for(let w=Math.max(g,-u);w<=Math.min(y,u);w+=2){let b,k=h[w-1],S=h[w+1];k&&(h[w-1]=void 0);let A=!1;if(S){let O=S.oldPos-w;A=S&&0<=O&&O<a}let $=k&&k.oldPos+1<c;if(!A&&!$){h[w]=void 0;continue}if(!$||A&&k.oldPos<S.oldPos?b=this.addToPath(S,!0,!1,0,n):b=this.addToPath(k,!1,!0,1,n),m=this.extractCommon(b,r,t,w,n),b.oldPos+1>=c&&m+1>=a)return o(this.buildValues(b.lastComponent,r,t))||!0;h[w]=b,b.oldPos+1>=c&&(y=Math.min(y,w-1)),m+1>=a&&(g=Math.max(g,w+1))}u++},"execEditLength");if(i)l(function w(){setTimeout(function(){if(u>d||Date.now()>p)return i(void 0);x()||w()},0)},"exec")();else for(;u<=d&&Date.now()<=p;){let w=x();if(w)return w}}addToPath(t,r,n,i,s){let o=t.lastComponent;return o&&!s.oneChangePerToken&&o.added===r&&o.removed===n?{oldPos:t.oldPos+i,lastComponent:{count:o.count+1,added:r,removed:n,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:r,removed:n,previousComponent:o}}}extractCommon(t,r,n,i,s){let o=r.length,a=n.length,c=t.oldPos,u=c-i,d=0;for(;u+1<o&&c+1<a&&this.equals(n[c+1],r[u+1],s);)u++,c++,d++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!s.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,u}equals(t,r,n){return n.comparator?n.comparator(t,r):t===r||!!n.ignoreCase&&t.toLowerCase()===r.toLowerCase()}removeEmpty(t){let r=[];for(let n=0;n<t.length;n++)t[n]&&r.push(t[n]);return r}castInput(t,r){return t}tokenize(t,r){return Array.from(t)}join(t){return t.join("")}postProcess(t,r){return t}get useLongestToken(){return!1}buildValues(t,r,n){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let o=i.length,a=0,c=0,u=0;for(;a<o;a++){let d=i[a];if(d.removed)d.value=this.join(n.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let f=r.slice(c,c+d.count);f=f.map(function(p,h){let m=n[u+h];return m.length>p.length?m:p}),d.value=this.join(f)}else d.value=this.join(r.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return i}};var xk=class extends cf{static{l(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=gde}equals(t,r,n){return n.ignoreWhitespace?((!n.newlineIsToken||!t.includes(`
|
|
712
|
+
`}l(OR,"pageStyles");var tue="https://api.deepseek.com";var rue="deepseek-v4-flash",nue="high";var iue=/^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,127}$/;function lk(e){let t=e??tue,r;try{r=new URL(t)}catch{throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL")}if(r.protocol!=="http:"&&r.protocol!=="https:"||r.username.length>0||r.password.length>0)throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL without credentials");return t}l(lk,"resolveEdgeBaseURL");function sf(e){if(e===void 0)return rue;if(!iue.test(e))throw new Error("dsh-edge: DEEPSEEK_MODEL must be a valid model id of at most 128 characters");return e}l(sf,"resolveEdgeModel");function ck(e){if(e===void 0)return nue;if(e!=="off"&&e!=="low"&&e!=="high"&&e!=="max")throw new Error("dsh-edge: DEEPSEEK_REASONING_EFFORT must be one of off, low, high, or max");return e}l(ck,"resolveEdgeReasoningEffort");function uk(e){if(e===void 0)return 12e4;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t)||t>2147483647)throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be no greater than 2147483647");return t}l(uk,"resolveEdgeStreamIdleTimeoutMs");function dk(e){if(e===void 0)return 256e3;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t))throw new Error(`dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be no greater than ${Number.MAX_SAFE_INTEGER}`);return t}l(dk,"resolveEdgeMaxOutputTokens");var fk={name:"dsh-edge",version:"0.4.1",description:"Your DeepSeek Harness, anywhere \u2014 deploy a persistent personal coding agent to Cloudflare Workers in one command",author:"pawaca",license:"MIT",type:"module",bin:{"dsh-edge":"scripts/cli.mjs"},files:["dist","worker","scripts/*.d.mts","scripts/*.mjs","wrangler.jsonc","README.md","README.zh.md","LICENSE","THIRD_PARTY_NOTICES.md"],repository:{type:"git",url:"git+https://github.com/pawaca/dsh-edge.git",directory:"apps/dsh-edge"},homepage:"https://github.com/pawaca/dsh-edge#readme",bugs:{url:"https://github.com/pawaca/dsh-edge/issues"},keywords:["deepseek","deepseek-harness","ai-agents","byok","cloudflare-workers","durable-objects","self-hosted"],engines:{node:">=22.14.0"},publishConfig:{access:"public"},dshEdge:{upstreamVersion:"0.1.1-rc.1"},scripts:{"bundle:direct":"pnpm run web:build && pnpm --dir standalone run build:worker:direct && node standalone/scripts/promote.mjs direct","bundle:isolated":"pnpm run web:build && pnpm --dir standalone run build:worker:isolated && node standalone/scripts/promote.mjs isolated","bundle:workers":"pnpm --dir standalone run build && pnpm --dir standalone run verify && node standalone/scripts/promote.mjs all",dev:"pnpm run bundle:direct && node scripts/dev.mjs direct","dev:isolated":"pnpm run bundle:isolated && node scripts/dev.mjs isolated","dsh-edge":"node scripts/cli.mjs","example:install":"node examples/install-keyless.mjs","install:cloudflare":"pnpm run bundle:workers && node scripts/cli.mjs install","legal:write":"node scripts/legal-files.mjs write","pack:verify":"node scripts/verify-packed.mjs",prepack:"node scripts/legal-files.mjs verify && pnpm run bundle:workers","web:build":"pnpm --dir standalone run build:web && node standalone/scripts/promote.mjs web",test:"vitest run --root ../.. --project edge-runtime","test:integration":"pnpm run bundle:workers && node tests/run-session-integration.mjs","test:snapshot":"vitest run --root ../.. --config apps/dsh-edge/vitest.snapshot.config.ts",typecheck:"tsc --noEmit"},dependencies:{"@clack/prompts":"1.7.0","compare-versions":"6.1.1",execa:"^10.0.0","jsonc-parser":"^3.3.1",wrangler:"4.123.0"},devDependencies:{"@cloudflare/computer":"0.2.0","@cloudflare/workers-types":"5.20260812.1","@deepseek-ai/cordis":"4.0.1","@deepseek-ai/dsh-agent":"0.1.1-rc.1","@deepseek-ai/dsh-agent-loop":"0.1.1-rc.1","@deepseek-ai/dsh-anonymous-user-id":"0.1.1-rc.1","@deepseek-ai/dsh-attachment":"0.1.1-rc.1","@deepseek-ai/dsh-brand":"0.1.1-rc.1","@deepseek-ai/dsh-credentials":"0.1.1-rc.1","@deepseek-ai/dsh-host-apiproxy":"0.1.1-rc.1","@deepseek-ai/dsh-launch-environment":"0.1.1-rc.1","@deepseek-ai/dsh-llm":"0.1.1-rc.1","@deepseek-ai/dsh-llm-deepseek":"0.1.1-rc.1","@deepseek-ai/dsh-session":"0.1.1-rc.1","@deepseek-ai/dsh-session-persistence":"0.1.1-rc.1","@deepseek-ai/dsh-session-query":"0.1.1-rc.1","@deepseek-ai/dsh-session-title":"0.1.1-rc.1","@deepseek-ai/dsh-settings":"0.1.1-rc.1","@deepseek-ai/dsh-system-prompt":"0.1.1-rc.1","@deepseek-ai/dsh-tool-call-timeout-policy":"0.1.1-rc.1","@deepseek-ai/dsh-tool-web":"0.1.1-rc.1","@deepseek-ai/dsh-tools":"0.1.1-rc.1","@deepseek-ai/dsh-web":"0.1.1-rc.1","@deepseek-ai/dsh-web-search-deepseek":"0.1.1-rc.1","just-bash":"3.3.0","fast-png":"8.0.0","jpeg-js":"0.4.4",playwright:"^1.49.0",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}};var Ng=fk.version,NR=fk.dshEdge.upstreamVersion;function oue(){return"dsh-edge@0.4.1/direct"}l(oue,"resolveEdgeDeploymentId");function Rg(e){return{baseURL:lk(e.DEEPSEEK_BASE_URL),maxTokens:dk(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:sf(e.DEEPSEEK_MODEL),reasoningEffort:ck(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:yg(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:uk(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:ef(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(Rg,"resolveEdgeDeploymentConfig");function aue(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}l(aue,"edgeDeploymentApiKeyConfigured");function lue(e){let t=lk(e),r=new URL(t);return r.search.length===0&&r.hash.length===0?t:(r.search="",r.hash="",r.href)}l(lue,"projectedEdgeBaseURL");function pk(e,t){return{shell:e.LOADER===void 0?"just-bash-direct":"just-bash-isolated",storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:oue(),apiKeyConfigured:aue(e),baseURL:lue(e.DEEPSEEK_BASE_URL),maxTokens:dk(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:sf(e.DEEPSEEK_MODEL),reasoningEffort:ck(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:yg(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:uk(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:ef(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(pk,"resolveEdgeDeploymentProfile");function RR(e){Rg(e);let t=pk(e);return{ok:!0,service:"dsh-edge",storage:t.storage,attachmentStorage:t.attachmentStorage,shell:t.shell,agent:"upstream-react-loop-agent",access:"single-owner-cookie",deploymentId:t.deploymentId,version:Ng,upstreamVersion:NR,status:"ready"}}l(RR,"resolveEdgeDeploymentHealth");import{WorkerEntrypoint as dLe}from"cloudflare:workers";var El=ay(PR());var hk=l((e,t,r)=>{let n=e instanceof RegExp?DR(e,r):e,i=t instanceof RegExp?DR(t,r):t,s=n!==null&&i!=null&&cue(n,i,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+n.length,s[1]),post:r.slice(s[1]+i.length)}},"balanced"),DR=l((e,t)=>{let r=t.match(e);return r?r[0]:null},"maybeMatch"),cue=l((e,t,r)=>{let n,i,s,o,a,c=r.indexOf(e),u=r.indexOf(t,c+1),d=c;if(c>=0&&u>0){if(e===t)return[c,u];for(n=[],s=r.length;d>=0&&!a;){if(d===c)n.push(d),c=r.indexOf(e,d+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,u])}else i=n.pop(),i!==void 0&&i<s&&(s=i,o=u),u=r.indexOf(t,d+1);d=c<u&&c>=0?c:u}n.length&&o!==void 0&&(a=[s,o])}return a},"range");var LR="\0SLASH"+Math.random()+"\0",MR="\0OPEN"+Math.random()+"\0",yk="\0CLOSE"+Math.random()+"\0",FR="\0COMMA"+Math.random()+"\0",UR="\0PERIOD"+Math.random()+"\0",uue=new RegExp(LR,"g"),due=new RegExp(MR,"g"),fue=new RegExp(yk,"g"),pue=new RegExp(FR,"g"),hue=new RegExp(UR,"g"),mue=/\\\\/g,gue=/\\{/g,yue=/\\}/g,vue=/\\,/g,wue=/\\\./g,bue=1e5,xue=4e6;function mk(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}l(mk,"numeric");function Eue(e){return e.replace(mue,LR).replace(gue,MR).replace(yue,yk).replace(vue,FR).replace(wue,UR)}l(Eue,"escapeBraces");function Sue(e){return e.replace(uue,"\\").replace(due,"{").replace(fue,"}").replace(pue,",").replace(hue,".")}l(Sue,"unescapeBraces");function jR(e){if(!e)return[""];let t=[],r=hk("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:s}=r,o=n.split(",");o[o.length-1]+="{"+i+"}";let a=jR(s);return s.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}l(jR,"parseCommaParts");function zR(e,t={}){if(!e)return[];let{max:r=bue,maxLength:n=xue}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),gk(Eue(e),r,n,!0).map(Sue)}l(zR,"expand");function kue(e){return"{"+e+"}"}l(kue,"embrace");function Aue(e){return/^-?0\d/.test(e)}l(Aue,"isPadded");function Iue(e,t){return e<=t}l(Iue,"lte");function $ue(e,t){return e>=t}l($ue,"gte");function of(e,t,r,n,i,s){let o=[],a=0;for(let c=0;c<e.length;c++)for(let u=0;u<r.length;u++){if(o.length>=n)return o;let d=e[c]+t+r[u];if(!(s&&!d)){if(a+d.length>i)return o;o.push(d),a+=d.length}}return o}l(of,"combine");function _ue(e,t,r,n){let i=e.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let o=mk(i[0]),a=mk(i[1]),c=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(mk(i[2])),1):1,d=Iue;a<o&&(u*=-1,d=$ue);let p=i.some(Aue),h=0;for(let m=o;d(m,a)&&s.length<r;m+=u){let g;if(t)g=String.fromCharCode(m),g==="\\"&&(g="");else if(g=String(m),p){let y=c-g.length;if(y>0){let x=new Array(y+1).join("0");m<0?g="-"+x+g.slice(1):g=x+g}}if(h+g.length>n)break;s.push(g),h+=g.length}return s}l(_ue,"expandSequence");function gk(e,t,r,n){let i=[""],s=!1,o=!0;for(;;){let a=hk("{","}",e);if(!a)return of(i,e,[""],t,r,s);let c=a.pre;if(/\$$/.test(c)){if(i=of(i,c+"{"+a.body+"}",[""],t,r,s&&!a.post.length),o=!1,!a.post.length)break;e=a.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=u||d,p=a.body.indexOf(",")>=0;if(!f&&!p){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+yk+a.post,n=!0;continue}return of(i,c+"{"+a.body+"}"+a.post,[""],t,r,s)}o&&(s=n&&!f,o=!1);let h;if(f)h=_ue(a.body,d,t,r);else{let m=jR(a.body);if(m.length===1&&m[0]!==void 0&&(m=gk(m[0],t,r,!1).map(kue),m.length===1)){if(i=of(i,c+m[0],[""],t,r,s&&!a.post.length),!a.post.length)break;e=a.post;continue}let g=s&&!a.post.length&&!c;for(let x=0;g&&x<i.length;x++)i[x]&&(g=!1);h=[];let y=0;e:for(let x=0;x<m.length;x++){let w=gk(m[x],t,r,!1);for(let b=0;b<w.length;b++){let k=w[b];if(!(g&&!k)){if(h.length>=t||y+k.length>r)break e;h.push(k),y+=k.length}}}}if(i=of(i,c,h,t,r,s&&!a.post.length),!a.post.length)break;e=a.post}return i}l(gk,"expand_");var af=l(e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var Tue={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},lf=l(e=>e.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Cue=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),BR=l(e=>e.join(""),"rangesToString"),WR=l((e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,o=!1,a=!1,c=!1,u=!1,d=r,f="";e:for(;s<e.length;){let g=e.charAt(s);if((g==="!"||g==="^")&&s===r+1){u=!0,s++;continue}if(g==="]"&&o&&!c){d=s+1;break}if(o=!0,g==="\\"&&!c){c=!0,s++;continue}if(g==="["&&!c){for(let[y,[x,w,b]]of Object.entries(Tue))if(e.startsWith(y,s)){if(f)return["$.",!1,e.length-r,!0];s+=y.length,b?i.push(x):n.push(x),a=a||w;continue e}}if(c=!1,f){g>f?n.push(lf(f)+"-"+lf(g)):g===f&&n.push(lf(g)),f="",s++;continue}if(e.startsWith("-]",s+1)){n.push(lf(g+"-")),s+=2;continue}if(e.startsWith("-",s+1)){f=g,s+=2;continue}n.push(lf(g)),s++}if(d<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let g=n[0].length===2?n[0].slice(-1):n[0];return[Cue(g),!1,d-r,!1]}let p="["+(u?"^":"")+BR(n)+"]",h="["+(u?"":"^")+BR(i)+"]";return[n.length&&i.length?"("+p+"|"+h+")":n.length?p:h,a,d-r,!0]},"parseClass");var Ko=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape");var Hn,Oue=new Set(["!","?","+","*","@"]),vk=l(e=>Oue.has(e),"isExtglobType"),qR=l(e=>vk(e.type),"isExtglobAST"),Nue=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Rue=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Pue=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),HR=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Due="(?!(?:^|/)\\.\\.?(?:$|/))",Dg="(?!\\.)",Lue=new Set(["[","."]),Mue=new Set(["..","."]),Fue=new Set("().*{}+?[]^$\\!"),Uue=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),wk="[^/]",GR=wk+"*?",VR=wk+"+?",jue=0,Ha=class{static{l(this,"AST")}type;#e;#r;#n=!1;#t=[];#i;#s;#a;#u=!1;#l;#o;#c=!1;id=++jue;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#i=r,this.#e=this.#i?this.#i.#e:this,this.#l=this.#e===this?n:this.#e.#l,this.#a=this.#e===this?[]:this.#e.#a,t==="!"&&!this.#e.#u&&this.#a.push(this),this.#s=this.#i?this.#i.#t.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#o=this.#t.map(t=>String(t)).join("")}#x(){if(this!==this.#e)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let t;for(;t=this.#a.pop();){if(t.type!=="!")continue;let r=t,n=r.#i;for(;n;){for(let i=r.#s+1;!n.type&&i<n.#t.length;i++)for(let s of t.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#t[i])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof Hn&&r.#i===this))throw new Error("invalid part: "+r);this.#t.push(r)}}toJSON(){let t=this.type===null?this.#t.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#t.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#u&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#s===0)return!0;let t=this.#i;for(let r=0;r<this.#s;r++){let n=t.#t[r];if(!(n instanceof Hn&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#t.length:0;return this.#s===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new Hn(this.type,t);for(let n of this.#t)r.copyIn(n);return r}static#h(t,r,n,i,s){let o=i.maxExtglobRecursion??2,a=!1,c=!1,u=-1,d=!1;if(r.type===null){let g=n,y="";for(;g<t.length;){let x=t.charAt(g++);if(a||x==="\\"){a=!a,y+=x;continue}if(c){g===u+1?(x==="^"||x==="!")&&(d=!0):x==="]"&&!(g===u+2&&d)&&(c=!1),y+=x;continue}else if(x==="["){c=!0,u=g,d=!1,y+=x;continue}if(!i.noext&&vk(x)&&t.charAt(g)==="("&&s<=o){r.push(y),y="";let b=new Hn(x,r);g=Hn.#h(t,b,g,i,s+1),r.push(b);continue}y+=x}return r.push(y),g}let f=n+1,p=new Hn(null,r),h=[],m="";for(;f<t.length;){let g=t.charAt(f++);if(a||g==="\\"){a=!a,m+=g;continue}if(c){f===u+1?(g==="^"||g==="!")&&(d=!0):g==="]"&&!(f===u+2&&d)&&(c=!1),m+=g;continue}else if(g==="["){c=!0,u=f,d=!1,m+=g;continue}if(!i.noext&&vk(g)&&t.charAt(f)==="("&&(s<=o||r&&r.#g(g))){let x=r&&r.#g(g)?0:1;p.push(m),m="";let w=new Hn(g,p);p.push(w),f=Hn.#h(t,w,f,i,s+x);continue}if(g==="|"){p.push(m),m="",h.push(p),p=new Hn(null,r);continue}if(g===")")return m===""&&r.#t.length===0&&(r.#c=!0),p.push(m),m="",r.push(...h,p),f;m+=g}return r.type=null,r.#r=void 0,r.#t=[t.substring(n-1)],f}#C(t){return this.#m(t,Rue)}#m(t,r=Nue){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null)return!1;let n=t.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#g(n.type,r)}#g(t,r=Pue){return!!r.get(this.type)?.includes(t)}#f(t,r){let n=t.#t[0],i=new Hn(null,n,this.options);i.#t.push(""),n.push(i),this.#E(t,r)}#E(t,r){let n=t.#t[0];this.#t.splice(r,1,...n.#t);for(let i of n.#t)typeof i=="object"&&(i.#i=this);this.#o=void 0}#S(t){return!!HR.get(this.type)?.has(t)}#O(t){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let r=t.#t[0];return!r||typeof r!="object"||r.type===null?!1:this.#S(r.type)}#y(t){let r=HR.get(this.type),n=t.#t[0],i=r?.get(n.type);if(!i)return!1;this.#t=n.#t;for(let s of this.#t)typeof s=="object"&&(s.#i=this);this.type=i,this.#o=void 0,this.#c=!1}static fromGlob(t,r={}){let n=new Hn(null,void 0,r);return Hn.#h(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#r||this.#l.nocase&&!this.#l.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#l.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#l}toRegExpSource(t){let r=t??!!this.#l.dot;if(this.#e===this&&(this.#p(),this.#x()),!qR(this)){let c=this.isStart()&&this.isEnd()&&!this.#t.some(h=>typeof h!="string"),u=this.#t.map(h=>{let[m,g,y,x]=typeof h=="string"?Hn.#k(h,this.#r,c):h.toRegExpSource(t);return this.#r=this.#r||y,this.#n=this.#n||x,m}).join(""),d="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&Mue.has(this.#t[0]))){let m=Lue,g=r&&m.has(u.charAt(0))||u.startsWith("\\.")&&m.has(u.charAt(2))||u.startsWith("\\.\\.")&&m.has(u.charAt(4)),y=!r&&!t&&m.has(u.charAt(0));d=g?Due:y?Dg:""}let f="";return this.isEnd()&&this.#e.#u&&this.#i?.type==="!"&&(f="(?:$|\\/)"),[d+u+f,Ko(u),this.#r=!!this.#r,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#v(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#t=[c],u.type=null,u.#r=void 0,[c,Ko(this.toString()),!1,!1]}let o=!n||t||r||!Dg?"":this.#v(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!r?Dg:"")+VR;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!t?Dg:"")+GR+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+s+c}return[a,Ko(s),this.#r=!!this.#r,this.#n]}#p(){if(qR(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#t.length;n++){let i=this.#t[n];typeof i=="object"&&(i.#p(),this.#m(i)?(r=!1,this.#E(i,n)):this.#C(i)?(r=!1,this.#f(i,n)):this.#O(i)&&(r=!1,this.#y(i)))}}while(!r&&++t<10)}else for(let t of this.#t)typeof t=="object"&&t.#p();this.#o=void 0}#v(t){return this.#t.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=r.toRegExpSource(t);return this.#n=this.#n||o,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#k(t,r,n=!1){let i=!1,s="",o=!1,a=!1;for(let c=0;c<t.length;c++){let u=t.charAt(c);if(i){i=!1,s+=(Fue.has(u)?"\\":"")+u;continue}if(u==="*"){if(a)continue;a=!0,s+=n&&/^[*]+$/.test(t)?VR:GR,r=!0;continue}else a=!1;if(u==="\\"){c===t.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[d,f,p,h]=WR(t,c);if(p){s+=d,o=o||f,c+=p-1,r=r||h;continue}}if(u==="?"){s+=wk,r=!0;continue}s+=Uue(u)}return[s,Ko(t),!!r,o]}};Hn=Ha;var bk=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Xr=l((e,t,r={})=>(af(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Ac(t,r).match(e)),"minimatch"),zue=/^\*+([^+@!?*[(]*)$/,Bue=l(e=>t=>!t.startsWith(".")&&t.endsWith(e),"starDotExtTest"),Wue=l(e=>t=>t.endsWith(e),"starDotExtTestDot"),que=l(e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),"starDotExtTestNocase"),Hue=l(e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),"starDotExtTestNocaseDot"),Gue=/^\*+\.\*+$/,Vue=l(e=>!e.startsWith(".")&&e.includes("."),"starDotStarTest"),Zue=l(e=>e!=="."&&e!==".."&&e.includes("."),"starDotStarTestDot"),Kue=/^\.\*+$/,Yue=l(e=>e!=="."&&e!==".."&&e.startsWith("."),"dotStarTest"),Xue=/^\*+$/,Jue=l(e=>e.length!==0&&!e.startsWith("."),"starTest"),Que=l(e=>e.length!==0&&e!=="."&&e!=="..","starTestDot"),ede=/^\?+([^+@!?*[(]*)?$/,tde=l(([e,t=""])=>{let r=YR([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},"qmarksTestNocase"),rde=l(([e,t=""])=>{let r=XR([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},"qmarksTestNocaseDot"),nde=l(([e,t=""])=>{let r=XR([e]);return t?n=>r(n)&&n.endsWith(t):r},"qmarksTestDot"),ide=l(([e,t=""])=>{let r=YR([e]);return t?n=>r(n)&&n.endsWith(t):r},"qmarksTest"),YR=l(([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},"qmarksTestNoExt"),XR=l(([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},"qmarksTestNoExtDot"),JR=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ZR={win32:{sep:"\\"},posix:{sep:"/"}},sde=JR==="win32"?ZR.win32.sep:ZR.posix.sep;Xr.sep=sde;var vn=Symbol("globstar **");Xr.GLOBSTAR=vn;var ode="[^/]",ade=ode+"*?",lde="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",cde="(?:(?!(?:\\/|^)\\.).)*?",ude=l((e,t={})=>r=>Xr(r,e,t),"filter");Xr.filter=ude;var bi=l((e,t={})=>Object.assign({},e,t),"ext"),dde=l(e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Xr;let t=Xr;return Object.assign(l((n,i,s={})=>t(n,i,bi(e,s)),"m"),{Minimatch:class extends t.Minimatch{static{l(this,"Minimatch")}constructor(i,s={}){super(i,bi(e,s))}static defaults(i){return t.defaults(bi(e,i)).Minimatch}},AST:class extends t.AST{static{l(this,"AST")}constructor(i,s,o={}){super(i,s,bi(e,o))}static fromGlob(i,s={}){return t.AST.fromGlob(i,bi(e,s))}},unescape:l((n,i={})=>t.unescape(n,bi(e,i)),"unescape"),escape:l((n,i={})=>t.escape(n,bi(e,i)),"escape"),filter:l((n,i={})=>t.filter(n,bi(e,i)),"filter"),defaults:l(n=>t.defaults(bi(e,n)),"defaults"),makeRe:l((n,i={})=>t.makeRe(n,bi(e,i)),"makeRe"),braceExpand:l((n,i={})=>t.braceExpand(n,bi(e,i)),"braceExpand"),match:l((n,i,s={})=>t.match(n,i,bi(e,s)),"match"),sep:t.sep,GLOBSTAR:vn})},"defaults");Xr.defaults=dde;var QR=l((e,t={})=>(af(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:zR(e,{max:t.braceExpandMax})),"braceExpand");Xr.braceExpand=QR;var fde=l((e,t={})=>new Ac(e,t).makeRe(),"makeRe");Xr.makeRe=fde;var pde=l((e,t,r={})=>{let n=new Ac(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e},"match");Xr.match=pde;var KR=/[?*]|[+@!]\(.*?\)|\[|\]/,hde=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Ac=class{static{l(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){af(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||JR,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!KR.test(s[2]))&&!KR.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(d=>this.parse(d))];if(u)return[s[0],...s.slice(1).map(d=>this.parse(d))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let s=t[i];i===1&&s===""&&t[0]===""||(s==="."||s==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let a=n[i+1],c=n[i+2],u=n[i+3];if(a!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(i,1);let d=n.slice(0);d[i]="**",t.push(d),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=!0;let c=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...c),n.length===0&&n.push(""),s-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,s=0,o=[],a="";for(;i<t.length&&s<r.length;)if(t[i]===r[s])o.push(a==="b"?r[s]:t[i]),i++,s++;else if(n&&t[i]==="**"&&r[s]===t[i+1])o.push(t[i]),i++;else if(n&&r[s]==="**"&&t[i]===r[s+1])o.push(r[s]),s++;else if(t[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(a==="b")return!1;a="a",o.push(t[i]),i++,s++}else if(r[s]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",o.push(r[s]),i++,s++}else return!1;return t.length===r.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,s=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),u=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),d=!u&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=c?3:a?0:void 0,p=d?3:u?0:void 0;if(typeof f=="number"&&typeof p=="number"){let[h,m]=[t[f],r[p]];h.toLowerCase()===m.toLowerCase()&&(r[p]=h,s=p,i=f)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(vn)?this.#e(t,r,n,i,s):this.#n(t,r,n,i,s)}#e(t,r,n,i,s){let o=r.indexOf(vn,s),a=r.lastIndexOf(vn),[c,u,d]=n?[r.slice(s,o),r.slice(o+1),[]]:[r.slice(s,o),r.slice(o+1,a),r.slice(a+1)];if(c.length){let w=t.slice(i,i+c.length);if(!this.#n(w,c,n,0,0))return!1;i+=c.length,s+=c.length}let f=0;if(d.length){if(d.length+i>t.length)return!1;let w=t.length-d.length;if(this.#n(t,d,n,w,0))f=d.length;else{if(t[t.length-1]!==""||i+d.length===t.length||(w--,!this.#n(t,d,n,w,0)))return!1;f=d.length+1}}if(!u.length){let w=!!f;for(let b=i;b<t.length-f;b++){let k=String(t[b]);if(w=!0,k==="."||k===".."||!this.options.dot&&k.startsWith("."))return!1}return n||w}let p=[[[],0]],h=p[0],m=0,g=[0];for(let w of u)w===vn?(g.push(m),h=[[],0],p.push(h)):(h[0].push(w),m++);let y=p.length-1,x=t.length-f;for(let w of p)w[1]=x-(g[y--]+w[0].length);return!!this.#r(t,p,i,0,n,0,!!f)}#r(t,r,n,i,s,o,a){let c=r[i];if(!c){for(let f=n;f<t.length;f++){a=!0;let p=t[f];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return a}let[u,d]=c;for(;n<=d;){if(this.#n(t.slice(0,n+u.length),u,s,n,0)&&o<this.maxGlobstarRecursion){let h=this.#r(t,r,n+u.length,i+1,s,o+1,a);if(h!==!1)return h}let p=t[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return s||null}#n(t,r,n,i,s){let o,a,c,u;for(o=i,a=s,u=t.length,c=r.length;o<u&&a<c;o++,a++){this.debug("matchOne loop");let d=r[a],f=t[o];if(this.debug(r,d,f),d===!1||d===vn)return!1;let p;if(typeof d=="string"?(p=f===d,this.debug("string match",d,f,p)):(p=d.test(f),this.debug("pattern match",d,f,p)),!p)return!1}if(o===u&&a===c)return!0;if(o===u)return n;if(a===c)return o===u-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return QR(this.pattern,this.options)}parse(t){af(t);let r=this.options;if(t==="**")return vn;if(t==="")return"";let n,i=null;(n=t.match(Xue))?i=r.dot?Que:Jue:(n=t.match(zue))?i=(r.nocase?r.dot?Hue:que:r.dot?Wue:Bue)(n[1]):(n=t.match(ede))?i=(r.nocase?r.dot?rde:tde:r.dot?nde:ide)(n):(n=t.match(Gue))?i=r.dot?Zue:Vue:(n=t.match(Kue))&&(i=Yue);let s=Ha.fromGlob(t,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?ade:r.dot?lde:cde,i=new Set(r.nocase?["i"]:[]),s=t.map(c=>{let u=c.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))i.add(p);return typeof f=="string"?hde(f):f===vn?vn:f._src});u.forEach((f,p)=>{let h=u[p+1],m=u[p-1];f!==vn||m===vn||(m===void 0?h!==void 0&&h!==vn?u[p+1]="(?:\\/|"+n+"\\/)?"+h:u[p]=n:h===void 0?u[p-1]=m+"(?:\\/|\\/"+n+")?":h!==vn&&(u[p-1]=m+"(?:\\/|\\/"+n+"\\/)"+h,u[p+1]=vn))});let d=u.filter(f=>f!==vn);if(this.partial&&d.length>=1){let f=[];for(let p=1;p<=d.length;p++)f.push(d.slice(0,p).join("/"));return"(?:"+f.join("|")+")"}return d.join("/")}).join("|"),[o,a]=t.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+a+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a of s){let c=i;if(n.matchBase&&a.length===1&&(c=[o]),this.matchOne(c,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return Xr.defaults(t).Minimatch}};Xr.AST=Ha;Xr.Minimatch=Ac;Xr.escape=bk;Xr.unescape=Ko;import{gunzipSync as hpe}from"node:zlib";var cf=class{static{l(this,"Diff")}diff(t,r,n={}){let i;typeof n=="function"?(i=n,n={}):"callback"in n&&(i=n.callback);let s=this.castInput(t,n),o=this.castInput(r,n),a=this.removeEmpty(this.tokenize(s,n)),c=this.removeEmpty(this.tokenize(o,n));return this.diffWithOptionsObj(a,c,n,i)}diffWithOptionsObj(t,r,n,i){var s;let o=l(w=>{if(w=this.postProcess(w,n),i){setTimeout(function(){i(w)},0);return}else return w},"done"),a=r.length,c=t.length,u=1,d=a+c;n.maxEditLength!=null&&(d=Math.min(d,n.maxEditLength));let f=(s=n.timeout)!==null&&s!==void 0?s:1/0,p=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}],m=this.extractCommon(h[0],r,t,0,n);if(h[0].oldPos+1>=c&&m+1>=a)return o(this.buildValues(h[0].lastComponent,r,t));let g=-1/0,y=1/0,x=l(()=>{for(let w=Math.max(g,-u);w<=Math.min(y,u);w+=2){let b,k=h[w-1],S=h[w+1];k&&(h[w-1]=void 0);let A=!1;if(S){let O=S.oldPos-w;A=S&&0<=O&&O<a}let $=k&&k.oldPos+1<c;if(!A&&!$){h[w]=void 0;continue}if(!$||A&&k.oldPos<S.oldPos?b=this.addToPath(S,!0,!1,0,n):b=this.addToPath(k,!1,!0,1,n),m=this.extractCommon(b,r,t,w,n),b.oldPos+1>=c&&m+1>=a)return o(this.buildValues(b.lastComponent,r,t))||!0;h[w]=b,b.oldPos+1>=c&&(y=Math.min(y,w-1)),m+1>=a&&(g=Math.max(g,w+1))}u++},"execEditLength");if(i)l(function w(){setTimeout(function(){if(u>d||Date.now()>p)return i(void 0);x()||w()},0)},"exec")();else for(;u<=d&&Date.now()<=p;){let w=x();if(w)return w}}addToPath(t,r,n,i,s){let o=t.lastComponent;return o&&!s.oneChangePerToken&&o.added===r&&o.removed===n?{oldPos:t.oldPos+i,lastComponent:{count:o.count+1,added:r,removed:n,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:r,removed:n,previousComponent:o}}}extractCommon(t,r,n,i,s){let o=r.length,a=n.length,c=t.oldPos,u=c-i,d=0;for(;u+1<o&&c+1<a&&this.equals(n[c+1],r[u+1],s);)u++,c++,d++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!s.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,u}equals(t,r,n){return n.comparator?n.comparator(t,r):t===r||!!n.ignoreCase&&t.toLowerCase()===r.toLowerCase()}removeEmpty(t){let r=[];for(let n=0;n<t.length;n++)t[n]&&r.push(t[n]);return r}castInput(t,r){return t}tokenize(t,r){return Array.from(t)}join(t){return t.join("")}postProcess(t,r){return t}get useLongestToken(){return!1}buildValues(t,r,n){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let o=i.length,a=0,c=0,u=0;for(;a<o;a++){let d=i[a];if(d.removed)d.value=this.join(n.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let f=r.slice(c,c+d.count);f=f.map(function(p,h){let m=n[u+h];return m.length>p.length?m:p}),d.value=this.join(f)}else d.value=this.join(r.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return i}};var xk=class extends cf{static{l(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=gde}equals(t,r,n){return n.ignoreWhitespace?((!n.newlineIsToken||!t.includes(`
|
|
713
713
|
`))&&(t=t.trim()),(!n.newlineIsToken||!r.includes(`
|
|
714
714
|
`))&&(r=r.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(t.endsWith(`
|
|
715
715
|
`)&&(t=t.slice(0,-1)),r.endsWith(`
|
|
@@ -2300,10 +2300,10 @@ const decode = () => {
|
|
|
2300
2300
|
};
|
|
2301
2301
|
|
|
2302
2302
|
export default { decode };
|
|
2303
|
-
`}}),
|
|
2303
|
+
`}}),hLe=Object.freeze({...f7});function BSe(e=[]){let t={...f7};for(let r of e)Object.assign(t,r);return Object.freeze(t)}l(BSe,"assembleShellModules");var WSe="2026-06-17",tV=["nodejs_compat"],cV=class{static{l(this,"WorkerShellBackend")}type="worker-shell";id;#e;#r;#n;constructor(e){if(this.id=e.id??"worker-shell",e.source===void 0){if(e.loader===void 0||e.workspace===void 0||e.ctx===void 0)throw new Error("WorkerShellBackend requires `source` or all of `loader`, `workspace`, and `ctx`.")}else if(e.loader!==void 0||e.workspace!==void 0||e.ctx!==void 0)throw new Error("WorkerShellBackend cannot combine `source` with loader options.");this.#e=e,this.#r=e.egress??{mode:"none"}}async connect(){let e=await this.#t(),t=e.runtime;return{rpc:{sync:GSe(),shell:{async exec(r){let n=await t.exec({command:r.source,cwd:r.cwd,id:r.id,timeoutMs:r.timeoutMs,env:r.env,stdin:r.stdin});return{id:n.id,events:rV(n.events)}},async getExec(r){let n=await t.getExec(r);return{id:n.id,events:rV(n.events)}},async killExec(r){await t.killExec(r)},async disposeExec(){}}},sync:"none",close:l(async()=>{e.dispose()},"close")}}async#t(){if(this.#e.source?.type==="external-runtime")return{runtime:await this.#e.source.connect({egress:this.#r}),dispose:l(()=>{},"dispose")};let e=this.#e.source?.type==="loader"?this.#e.source:void 0,t=e?.loader??this.#e.loader,r=e?.workspace??this.#e.workspace,n=e?.ctx??this.#e.ctx;this.#n===void 0&&(this.#n=HSe(this.#r));let i=`${this.#e.loaderId??`workspace-shell:${r.id}`}:${this.#n}`,s=this.#e.compatibilityDate??WSe,o=this.#e.compatibilityFlags?[...tV,...this.#e.compatibilityFlags]:tV,a=t.get(i,()=>({compatibilityDate:s,compatibilityFlags:o,mainModule:"shell.js",modules:{...BSe(this.#e.commands),...zSe},env:{HOST:n.exports.WorkspaceServiceProxy({props:r})},...J8(this.#r)})),c;try{c=a.getEntrypoint("ShellWorker")}catch(d){throw p7(a),d}let u=!1;return{runtime:c,dispose:l(()=>{u||(u=!0,p7(c),p7(a))},"dispose")}}};function rV(e){let t=new TextDecoder,r="";return e.pipeThrough(new TransformStream({transform(n,i){r+=t.decode(n,{stream:!0});let s=r.indexOf(`
|
|
2304
2304
|
`);for(;s!==-1;){let o=r.slice(0,s);if(r=r.slice(s+1),o.length>0)try{i.enqueue(nV(o))}catch(a){i.error(a);return}s=r.indexOf(`
|
|
2305
2305
|
`)}},flush(n){let i=r+t.decode();for(let s of i.split(`
|
|
2306
|
-
`))s.length!==0&&n.enqueue(nV(s))}}))}l(rV,"decodeFramedEvents");function nV(e){let t;try{t=JSON.parse(e)}catch{throw iV("WorkerShellBackend received invalid execution JSON")}if(typeof t.id!="string"||!Number.isSafeInteger(t.seq)||t.name!=="stdout"&&t.name!=="stderr"&&t.name!=="exit"||(t.name==="stdout"||t.name==="stderr")&&typeof t.value!="string"||t.name==="exit"&&!Number.isSafeInteger(t.value))throw iV("WorkerShellBackend received a malformed execution frame");return qSe(t)}l(nV,"parseFrame");function iV(e){let t=new Error(e);return t.code="EPROTOCOL",t}l(iV,"protocolError");function qSe(e){return e.name==="stdout"||e.name==="stderr"?{id:e.id,seq:e.seq,name:e.name,value:new TextEncoder().encode(e.value)}:{id:e.id,seq:e.seq,name:"exit",code:e.value}}l(qSe,"reshape");function HSe(e){return e.mode!=="http-gateway"?`egress-${e.mode}`:`egress-http-gateway-${e.revision??crypto.randomUUID()}`}l(HSe,"egressCacheKey");function p7(e){try{e[Symbol.dispose]?.()}catch{}}l(p7,"disposeQuietly");function GSe(){let e=l(t=>{throw new Error(`WorkerShellBackend: sync.${t} must not be called \u2014 the handle declares sync: "none"`)},"refuse");return{push:l(()=>e("push"),"push"),fetchChanges:l(()=>e("fetchChanges"),"fetchChanges"),readEntry:l(()=>e("readEntry"),"readEntry"),hasObjects:l(()=>e("hasObjects"),"hasObjects"),fetchObjects:l(()=>new ReadableStream({start(t){t.error(new Error("WorkerShellBackend: sync.fetchObjects must not be called"))}}),"fetchObjects"),pushObjects:l(()=>e("pushObjects"),"pushObjects"),watermarks:l(()=>e("watermarks"),"watermarks")}}l(GSe,"noopSync");import{mkdir as Dke,stat as Lke}from"node:fs/promises";import{homedir as Mke,release as Fke}from"node:os";import{dirname as Uke,extname as jke}from"node:path";import{randomUUID as ILe}from"node:crypto";import{accessSync as OLe,constants as NLe,statSync as RLe}from"node:fs";import{isAbsolute as DLe,resolve as LLe}from"node:path";var Sl=class extends Wr{static{l(this,"SubagentError")}constructor(e,t,r){super(e,t,r),this.name="SubagentError"}};var uV=["version","mode","provider","label"],MLe=new Set(uV),FLe=new Set([...uV,"agentProvider","agentModel","persona","toolFilter"]);var dV=v.object({since:v.number().int().nonnegative(),through:v.number().int().nonnegative()}).strict(),VSe=v.object({settledMs:v.number().int().nonnegative(),active:dV.optional()}).strict().transform(({settledMs:e,active:t})=>({settledMs:e,...t===void 0?{}:{active:t}})),ULe={key:"subagentTiming",stateSchema:v.object({settledMs:v.number().int().nonnegative(),active:dV.optional(),pendingTurnStart:v.number().int().nonnegative().optional(),descriptorSeen:v.boolean()}).strict(),init:l(()=>({descriptorSeen:!1,settledMs:0}),"init"),apply:l((e,t)=>{if(t.type==="turn/start")return e.descriptorSeen?{...e,active:{since:t.time,through:t.time}}:{...e,pendingTurnStart:t.time};if(t.type==="subagent/descriptor"){let r=e.active?.since??e.pendingTurnStart;return{descriptorSeen:!0,settledMs:0,...r===void 0?{}:{active:{since:r,through:t.time}}}}if(t.type==="turn/end"){if(!e.descriptorSeen){if(e.pendingTurnStart===void 0)return e;let{pendingTurnStart:i,...s}=e;return s}if(e.active===void 0)return e;let{active:r,...n}=e;return{...n,settledMs:e.settledMs+Math.max(0,t.time-r.since)}}return e.active===void 0?e:{...e,active:{...e.active,through:t.time}}},"apply"),wire:{viewSchema:VSe,view:l(e=>({settledMs:e.settledMs,...e.active===void 0?{}:{active:e.active}}),"view")},stateVersion:2},fV=v.discriminatedUnion("mode",[v.object({mode:v.literal("one-shot"),label:v.string().optional(),seq:v.number().int().nonnegative()}).strict(),v.object({mode:v.literal("continuable"),label:v.string(),seq:v.number().int().nonnegative()}).strict()]),jLe=fV.nullable(),zLe=v.object({identity:fV.optional()}).strict();var BLe=new TextEncoder,WLe=new TextDecoder;var qLe=Object.freeze({outputSchema:!1,depthLimit:!1,toolFilter:!1,persona:!1});var _0=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,pV=128,ZSe=2,A0="runtime",KSe=250;function YSe(e){return _0.test(e)}l(YSe,"isSkillName");function gV(e){return e.invocation.userInvocable}l(gV,"isUserInvocable");var XSe=class{static{l(this,"SkillLayer")}providers;runtime=new Map;constructor(e){this.providers=new To(t=>new Error(e===void 0?`a skill provider named "${t}" is already registered`:`a skill provider named "${t}" is already registered in this scope`))}isEmpty(){return this.providers.isEmpty()&&this.runtime.size===0}},JLe=class extends ut{static{l(this,"SkillRegistry")}static Config=re.object({collectCacheMaxEntries:re.number().default(pV)});collectCacheMaxEntries;layers=new Rl(e=>new XSe(e),()=>{this.invalidateCache()});collectCache=new Map;revision=0;nextProviderOrder=0;scopeIds=new WeakMap;nextScopeId=1;constructor(e,t={}){super(e,"skills"),this.collectCacheMaxEntries=t.collectCacheMaxEntries??pV,a6e("collectCacheMaxEntries",this.collectCacheMaxEntries)}registerProvider(e){let t=new AbortController,r,n,i={signal:t.signal,invalidate:l(()=>{let s=r;s!==void 0&&s.layer.providers.get(s.name)?.provider===n&&this.invalidateCache()},"invalidate")};try{n=e(i);let s=n.name;if(s===A0)throw new Error(`"${A0}" is reserved for runtime skill registrations`);let o=this.nextProviderOrder;return this.nextProviderOrder+=1,this.layers.effect(this.ctx,a=>{let c=a.providers.insert(s,{provider:n,order:o});return r={layer:a,name:s},()=>{r=void 0,c(),t.abort(new Error(`skill provider "${s}" disposed`))}},{label:"skills.registerProvider()"})}catch(s){throw t.abort(s),s}}register(e){r6e(e);let t=pn(this.ctx),r=t===void 0?this.layers.global:this.layers.peek(t);if(r!==void 0&&r.runtime.has(e.name))return this.ctx.logger.warn(`runtime skill "${e.name}" ignored because it is already registered`),()=>{};let n={...e,invocation:e.invocation??{modelInvocable:!0,userInvocable:!0},provider:e.provider??A0};return this.layers.effect(this.ctx,i=>(i.runtime.set(n.name,n),()=>{i.runtime.delete(n.name)}),{label:"skills.register()"})}async list(e={}){return(await this.snapshot(e)).skills}async snapshot(e={}){let t=await this.collect(e);return{skills:[...t.entries.values()].map(r=>i6e(r.candidate)).sort(s6e),complete:t.cacheable}}async get(e,t={}){if(!YSe(e))return;let r=await this.collect(t);np(t.signal);let n=r.entries.get(e);if(n===void 0)return;let i=await mV(n.provider.get(n.candidate,t),t.signal);if(i!==void 0){if(n6e(i),i.name!==n.candidate.name){this.invalidateEntry(n);return}return i}}async collect(e){np(e.signal);let t=1;for(;;){let r=this.revision,n=this.collectCacheKey(e.cwd,xv(e.scope),r),i=this.collectCache.get(n);if(i!==void 0)return{entries:i,cacheable:!0};let s=await this.collectFresh(e);if(np(e.signal),r!==this.revision){if(t<ZSe){t+=1;continue}return{entries:s.entries,cacheable:!1}}if(s.cacheable&&(this.collectCache.set(n,s.entries),this.collectCache.size>this.collectCacheMaxEntries)){let o=this.collectCache.keys().next();this.collectCache.delete(o.value)}return s}}async collectFresh(e){let t=[this.layers.global,...this.layers.chainLayers(e.scope)],r=new Map,n=!0;for(let i of t){let s=await this.collectLayer(i,e);s.cacheable||(n=!1);for(let o of s.entries)r.set(o.candidate.name,o)}return{entries:r,cacheable:n}}async collectLayer(e,t){let r=await this.listLayerCandidates(e,t);r.entries.sort(o6e);let n=new Set,i=[];for(let s of r.entries){let o=s.candidate;if(n.has(o.name)){this.ctx.logger.warn(`skill "${o.name}" from ${o.source} ignored because a higher-priority skill already exists`);continue}n.add(o.name),i.push(s)}return{entries:i,cacheable:r.cacheable}}async listLayerCandidates(e,t){np(t.signal);let r=[],n=!0,i=0;for(let s of[...e.runtime.values()].sort((o,a)=>yV(o.name,a.name)))r.push({candidate:e6e(s),provider:QSe,providerOrder:-1,localOrder:i,layer:e}),i+=1;for(let{provider:s,order:o}of[...e.providers.values()]){let a=0,c;try{c=await mV(s.list(t),t.signal)}catch(d){if(t.signal?.aborted===!0)throw $0(t.signal.reason);n=!1,this.ctx.logger.warn(`skill provider "${s.name}" skipped: ${I0(d)}`)}if(c===void 0)continue;let u=JSe(c,s.name);u.complete||(n=!1);for(let d of u.candidates)t6e(d,s.name),r.push({candidate:d,provider:s,providerOrder:o,localOrder:a,layer:e}),a+=1}return{entries:r,cacheable:n}}invalidateCache(){this.revision+=1,this.collectCache.clear(),this.notifyChange()}invalidateEntry(e){e.layer.providers.get(e.provider.name)?.provider===e.provider&&this.invalidateCache()}scopeId(e){let t=this.scopeIds.get(e);return t===void 0&&(t=this.nextScopeId,this.nextScopeId+=1,this.scopeIds.set(e,t)),t}collectCacheKey(e,t,r){return JSON.stringify({cwd:e,scopes:t.map(n=>this.scopeId(n)),revision:r})}notifyChange(){for(let e of this.ctx.events.dispatch("emit",["skills/change"]))try{let t=e();Promise.resolve(t).catch(r=>{this.ctx.logger.warn(`skills/change listener rejected: ${I0(r)}`)})}catch(t){this.ctx.logger.warn(`skills/change listener threw: ${I0(t)}`)}}};function JSe(e,t){if(Array.isArray(e))return{candidates:e,complete:!0};if(e===null||typeof e!="object")throw hV(t);let r=e;if(!Array.isArray(r.candidates)||typeof r.complete!="boolean")throw hV(t);return r}l(JSe,"normalizeProviderObservation");function hV(e){return new TypeError(`skill provider "${e}" list() must return an array or { candidates, complete } observation`)}l(hV,"invalidProviderObservation");var QSe={name:A0,list(){return Promise.resolve([])},get(e){return Promise.resolve(e.locator)}};function e6e(e){return{name:e.name,description:e.description,...e.whenToUse!==void 0?{whenToUse:e.whenToUse}:{},invocation:e.invocation,source:e.source,provider:e.provider,...e.resourceBase!==void 0?{resourceBase:e.resourceBase}:{},rank:KSe,locator:e,...e.path!==void 0?{path:e.path}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}l(e6e,"runtimeCandidate");function t6e(e,t){if(typeof e.name!="string")throw new TypeError(`skill provider "${t}" returned a non-string skill name`);if(!_0.test(e.name))throw new Error(`skill provider "${t}" returned invalid skill name "${e.name}"`);if(typeof e.description!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string description`);if(e.description.length===0)throw new Error(`skill provider "${t}" returned skill "${e.name}" without a description`);if(h7(e.invocation,`skill provider "${t}" returned skill "${e.name}"`),e.whenToUse!==void 0&&typeof e.whenToUse!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string whenToUse`);if(typeof e.source!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string source`);if(typeof e.rank!="number"||!Number.isFinite(e.rank))throw new Error(`skill provider "${t}" returned skill "${e.name}" with an invalid rank`);if(typeof e.provider!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string provider`);if(e.provider!==t)throw new Error(`skill provider "${t}" returned skill "${e.name}" for provider "${e.provider}"`);if(e.path!==void 0&&typeof e.path!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string path`)}l(t6e,"validateCandidate");function r6e(e){if(!_0.test(e.name))throw new Error(`invalid skill name "${e.name}"`);if(e.description.length===0)throw new Error(`skill "${e.name}" requires a description`);h7(e.invocation,`runtime skill "${e.name}"`)}l(r6e,"validateRuntimeSkill");function n6e(e){let t=e.name,r=e.description,n=e.whenToUse,i=e.invocation,s=e.source,o=e.provider,a=e.content,c=e.path;if(typeof t!="string")throw new TypeError("loaded skill name must be a string");if(!_0.test(t))throw new Error(`loaded skill has invalid name "${t}"`);if(typeof r!="string")throw new TypeError(`loaded skill "${t}" description must be a string`);if(r.length===0)throw new Error(`loaded skill "${t}" requires a description`);if(h7(i,`loaded skill "${t}"`),n!==void 0&&typeof n!="string")throw new TypeError(`loaded skill "${t}" whenToUse must be a string`);if(typeof s!="string")throw new TypeError(`loaded skill "${t}" source must be a string`);if(typeof o!="string")throw new TypeError(`loaded skill "${t}" provider must be a string`);if(typeof a!="string")throw new TypeError(`loaded skill "${t}" content must be a string`);if(c!==void 0&&typeof c!="string")throw new TypeError(`loaded skill "${t}" path must be a string`)}l(n6e,"validateDefinition");function i6e(e){let{name:t,description:r,whenToUse:n,invocation:i,source:s,provider:o,resourceBase:a}=e;return{name:t,description:r,...n!==void 0?{whenToUse:n}:{},invocation:i,source:s,provider:o,...a!==void 0?{resourceBase:a}:{}}}l(i6e,"toSummary");function h7(e,t){if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`${t} with a non-object invocation policy`);let r=e;if(typeof r.modelInvocable!="boolean")throw new TypeError(`${t} with a non-boolean invocation.modelInvocable`);if(typeof r.userInvocable!="boolean")throw new TypeError(`${t} with a non-boolean invocation.userInvocable`)}l(h7,"validateInvocation");function s6e(e,t){return yV(e.name,t.name)}l(s6e,"compareSkillSummary");function yV(e,t){return e<t?-1:e>t?1:0}l(yV,"compareCodePoints");function o6e(e,t){return e.candidate.rank-t.candidate.rank||e.providerOrder-t.providerOrder||e.localOrder-t.localOrder}l(o6e,"compareIndexedCandidates");function a6e(e,t,r=1){if(!Number.isInteger(t)||t<r)throw new Error(`skill: ${e} must be an integer greater than or equal to ${r}`)}l(a6e,"assertPositiveInteger");function mV(e,t){return t===void 0?e:(np(t),new Promise((r,n)=>{let i=l(()=>{t.removeEventListener("abort",s)},"cleanup"),s=l(()=>{i(),n($0(t.reason))},"onAbort");t.addEventListener("abort",s,{once:!0}),e.then(o=>{i(),r(o)},o=>{i(),n($0(o))})}))}l(mV,"waitWithAbort");function np(e){if(e?.aborted===!0)throw $0(e.reason)}l(np,"throwIfAborted");function $0(e){try{if(e instanceof Error)return e}catch{}return new Error(I0(e))}l($0,"toError");function I0(e){try{return String(e)}catch{return"[unrenderable thrown value]"}}l(I0,"errorMessage");import{randomUUID as bV}from"node:crypto";import{realpath as l6e,stat as C0}from"node:fs/promises";import{basename as xV}from"node:path";var ip=/^[a-z][a-z0-9_]*$/;function vV(e){return{valueSchema:e}}l(vV,"domainTable");function wV(e){if(!ip.test(e.name))throw new Error(`domain name '${e.name}' must match ${ip}`);if(!Number.isInteger(e.version)||e.version<0)throw new Error(`domain '${e.name}' version must be a non-negative integer, got ${e.version}`);for(let t of Object.keys(e.tables))if(!ip.test(t))throw new Error(`domain '${e.name}' table name '${t}' must match ${ip}`);if(e.global!==void 0&&e.global.schema.safeParse(null).success)throw new Error(`domain '${e.name}' global schema must not accept null: null is the medium's "never written" sentinel, so a stored null could not round-trip`);return e}l(wV,"defineDomain");var cMe=re.object({backend:re.string().required(),routes:re.dict(re.string()).default({})});async function T0(e){return await l6e(e)}l(T0,"realpathNormalize");var O0=class extends Error{static{l(this,"WorkspaceMoveInvalidError")}constructor(e){super(e),this.name="WorkspaceMoveInvalidError"}},EV=new Error("workspace record unchanged (internal sentinel)"),SV=class{static{l(this,"WorkspaceEntity")}host;id;record;constructor(e,t,r){this.host=e,this.id=t,this.record=r}get path(){return this.record.path}get title(){return this.record.title}get createdAt(){return this.record.createdAt}get updatedAt(){return this.record.updatedAt}get sessionIds(){return this.record.sessionIds.filter(e=>this.host.sessionPath(e)===this.record.path)}async setTitle(e){await this.mutate(t=>({...t,title:e}))}async attachSession(e){if(!this.record.sessionIds.includes(e)){let t=await this.host.readSessionHeader(e);if(t.cwd===void 0)throw new Error(`cannot attach session '${e}' to workspace '${this.record.path}': its stored header carries no cwd to validate against`);let r;try{r=await T0(t.cwd)}catch(n){throw new Error(`cannot attach session '${e}' to workspace '${this.record.path}': its cwd '${t.cwd}' does not resolve, so it cannot be validated`,{cause:n})}if(!(await C0(r)).isDirectory())throw new Error(`cannot attach session '${e}' to workspace '${this.record.path}': its cwd '${t.cwd}' is not a directory`);if(r!==this.record.path)throw new Error(`cannot attach session '${e}' to workspace '${this.record.path}': its cwd resolves to '${r}'`);this.host.rememberSessionPath(e,r)}await this.mutate(t=>t.sessionIds.includes(e)?t:{...t,sessionIds:[e,...t.sessionIds]})}async insertSessionBefore(e,t){await this.mutate(r=>{if(!r.sessionIds.includes(e))throw new O0(`cannot move session '${e}' in workspace '${r.path}': the session is not accounted`);if(t!==void 0&&!r.sessionIds.includes(t))throw new O0(`cannot move session '${e}' before '${t}' in workspace '${r.path}': the anchor session is not accounted`);if(t===e)return r;let n=r.sessionIds.filter(o=>o!==e),i=t===void 0?n.length:n.indexOf(t),s=[...n.slice(0,i),e,...n.slice(i)];return s.every((o,a)=>o===r.sessionIds[a])?r:{...r,sessionIds:s}})}async detachSession(e){await this.mutate(t=>t.sessionIds.includes(e)?{...t,sessionIds:t.sessionIds.filter(r=>r!==e)}:t)}async status(){try{return(await C0(this.record.path)).isDirectory()?"ok":"missing-dir"}catch{return"missing-dir"}}async mutate(e){let t;try{t=await this.host.table().update(this.id,r=>{let n=e(r),i=n.sessionIds.filter(s=>this.host.sessionPath(s)===n.path);if(n===r&&i.length===r.sessionIds.length)throw EV;return{...n,sessionIds:i,updatedAt:new Date().toISOString()}})}catch(r){if(r===EV)return;throw r}this.record=t}},m7=v.string().transform(e=>e),g7=v.object({path:v.string(),title:v.string(),sessionIds:v.array(v.string().transform(Ia)),createdAt:v.string(),updatedAt:v.string()}),c6e=v.discriminatedUnion("operation",[v.object({operation:v.literal("create"),workspaceId:m7}),v.object({operation:v.literal("delete"),workspaceId:m7})]),y7=v.object({initialized:v.boolean(),workspaceIds:v.array(m7),archivedSessionIds:v.array(v.string().transform(Ia)).default([]),pendingMutation:c6e.optional()}),u6e=wV({name:"workspace",version:2,global:{schema:y7,initial:{initialized:!1,workspaceIds:[],archivedSessionIds:[]}},tables:{workspaces:vV(g7)}});var v7=class extends Error{static{l(this,"WorkspaceUnknownSessionError")}sessionId;constructor(e){super(`cannot archive session '${e}': live sessions and session persistence hold no such session`),this.sessionId=e,this.name="WorkspaceUnknownSessionError"}},N0=class extends Error{static{l(this,"WorkspaceOrderInvalidError")}workspaceId;constructor(e){super(`cannot reorder unknown workspace '${e}'`),this.workspaceId=e,this.name="WorkspaceOrderInvalidError"}},kV=l((e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),"sameIds"),d6e=l((e,t)=>t.createdAt-e.createdAt||String(e.id).localeCompare(String(t.id)),"compareHeaders"),wMe=class extends ut{static{l(this,"WorkspaceRegistry")}static inject=["storageDomain","sessionPersistence"];table;global;state;entities=new Map;headers=new Map;sessionPaths=new Map;invalidSessionPaths=new Map;operationTail=Promise.resolve();host={table:l(()=>this.requireTable(),"table"),sessionPath:l(e=>this.sessionPaths.get(e),"sessionPath"),readSessionHeader:l(e=>this.readSessionHeader(e),"readSessionHeader"),rememberSessionPath:l((e,t)=>{this.sessionPaths.set(e,t),this.invalidSessionPaths.delete(e)},"rememberSessionPath")};constructor(e){super(e,"workspaceRegistry")}async[ut.init](){let e=await this.ctx.storageDomain.open(u6e);if(this.ctx.effect(()=>()=>e.close(),"workspace.domainClose"),this.table=e.table("workspaces"),this.global=e.global,this.state=e.global.get(),await this.recoverPendingMutation(),this.validateStoredState(this.state),this.state.initialized)this.table.size>0&&await this.replaceHeaderIndex(await this.ctx.sessionPersistence.list());else{let t=await this.ctx.sessionPersistence.list();await this.replaceHeaderIndex(t),await this.bootstrap(t)}await this.indexLiveSessions(),this.validateStoredState(this.requireState()),this.rebuildEntities(),this.reportFilteredCandidates()}async create(e,t){let r=await T0(e);if(!(await C0(r)).isDirectory())throw new Error(`cannot create a workspace at '${r}': path is not a directory`);return await this.enqueueOperation(()=>this.createCanonical(r,t))}get(e){return this.entities.get(e)}list(){return this.requireState().workspaceIds.map(e=>{let t=this.entities.get(e);if(t===void 0)throw new Error(`workspace registry order references missing workspace '${e}'`);return t})}delete(e){return this.enqueueOperation(()=>this.deleteKnown(e))}insertBefore(e,t){return this.enqueueOperation(async()=>{let r=this.requireState();if(!r.workspaceIds.includes(e))throw new N0(e);if(t!==void 0&&!r.workspaceIds.includes(t))throw new N0(t);if(t===e)return r.workspaceIds;let n=r.workspaceIds.filter(o=>o!==e),i=t===void 0?n.length:n.indexOf(t),s=[...n.slice(0,i),e,...n.slice(i)];return kV(s,r.workspaceIds)?r.workspaceIds:(await this.setState({...r,workspaceIds:s}),s)})}get archivedSessionIds(){return this.requireState().archivedSessionIds}archiveSession(e){return this.enqueueOperation(async()=>{if(this.requireState().archivedSessionIds.includes(e))return;if(!await this.sessionKnown(e))throw new v7(e);let t=this.requireState();await this.setState({...t,archivedSessionIds:[...t.archivedSessionIds,e]})})}async sessionKnown(e){return this.ctx.get("sessions")?.get(e)!==void 0||this.headers.has(e)?!0:(await this.indexHeaders(await this.ctx.sessionPersistence.list()),this.headers.has(e))}async resolveByPath(e){let t=await T0(e);for(let r of this.entities.values())if(r.path===t)return r}async createCanonical(e,t){for(let d of this.entities.values())if(d.path===e)return d;let r=t??xV(e),n=this.requireTable(),i=this.requireState(),s=bV(),o=new Date().toISOString(),a={path:e,title:r,sessionIds:[],createdAt:o,updatedAt:o},c=new SV(this.host,s,a);this.entities.set(s,c);let u={...i,pendingMutation:{operation:"create",workspaceId:s}};try{await this.setState(u)}catch(d){throw this.entities.delete(s),d}try{await n.put(s,a)}catch(d){this.entities.delete(s);try{await this.setState(i)}catch(f){throw new AggregateError([d,f],`workspace '${s}' record write and pending-marker rollback both failed`)}throw d}try{await this.setState({initialized:!0,workspaceIds:[s,...i.workspaceIds],archivedSessionIds:i.archivedSessionIds})}catch(d){this.entities.delete(s);try{await n.delete(s)}catch(f){throw new AggregateError([d,f],`workspace '${s}' order write and record rollback both failed; the pending marker remains recoverable`)}try{await this.setState(i)}catch(f){throw new AggregateError([d,f],`workspace '${s}' order write and pending-marker rollback both failed`)}throw d}return c}async deleteKnown(e){let t=this.entities.get(e);if(t===void 0)return!1;let r=this.requireState(),n={initialized:!0,workspaceIds:r.workspaceIds.filter(i=>i!==e),archivedSessionIds:r.archivedSessionIds};await this.setState({...n,pendingMutation:{operation:"delete",workspaceId:e}}),this.entities.delete(e);try{await this.requireTable().delete(e)}catch(i){this.entities.set(e,t);try{await this.setState(r)}catch(s){throw this.entities.delete(e),new AggregateError([i,s],`workspace '${e}' record deletion and registry-order rollback both failed`)}throw i}try{await this.setState(n)}catch(i){this.ctx.logger.warn(`workspace '${e}' was deleted but its pending marker could not be cleared: ${String(i)}`)}return!0}async recoverPendingMutation(){let e=this.requireState(),t=e.pendingMutation;if(t!==void 0){if(e.workspaceIds.includes(t.workspaceId))throw new Error(`workspace domain is inconsistent: pending ${t.operation} workspace '${t.workspaceId}' is still present in registry order`);await this.requireTable().delete(t.workspaceId),await this.setState({initialized:e.initialized,workspaceIds:e.workspaceIds,archivedSessionIds:e.archivedSessionIds})}}async bootstrap(e){let t=this.requireTable(),r=this.requireState(),n=new Map;for(let d of e){let f=this.sessionPaths.get(d.id);if(f===void 0)continue;let p=n.get(f);p===void 0?n.set(f,[d]):p.push(d)}let i=[...n].map(([d,f])=>(f.sort(d6e),{path:d,headers:f,newestAt:f[0].createdAt})).sort((d,f)=>f.newestAt-d.newestAt||d.path.localeCompare(f.path)),s=new Map,o=new Map;for(let[d,f]of t.entries()){s.set(f.path,d);for(let p of f.sessionIds)o.set(p,d)}for(let d of i){let f=s.get(d.path);if(f===void 0){let y=d.headers.map(b=>b.id).filter(b=>!o.has(b));if(y.length===0)continue;f=bV();let x=new Date(d.newestAt).toISOString(),w={path:d.path,title:xV(d.path),sessionIds:y,createdAt:x,updatedAt:x};await t.put(f,w),s.set(d.path,f);for(let b of y)o.set(b,f);continue}let p=t.get(f),h=d.headers.map(y=>y.id).filter(y=>o.get(y)===void 0||o.get(y)===f),m=new Set(h),g=[...h,...p.sessionIds.filter(y=>!m.has(y))];if(!f6e(p.sessionIds,g)){await t.update(f,y=>({...y,sessionIds:g,updatedAt:new Date().toISOString()}));for(let y of h)o.set(y,f)}}let a=new Map(i.map(d=>[d.path,d.newestAt])),c=new Map(r.workspaceIds.map((d,f)=>[d,f])),u=[...t.entries()].sort(([d,f],[p,h])=>{let m=a.get(f.path)??Date.parse(f.createdAt);return(a.get(h.path)??Date.parse(h.createdAt))-m||(c.get(d)??Number.MAX_SAFE_INTEGER)-(c.get(p)??Number.MAX_SAFE_INTEGER)||String(d).localeCompare(String(p))}).map(([d])=>d);kV(r.workspaceIds,u)||await this.setState({initialized:!1,workspaceIds:u,archivedSessionIds:r.archivedSessionIds}),await this.setState({initialized:!0,workspaceIds:u,archivedSessionIds:r.archivedSessionIds})}validateStoredState(e){let t=this.requireTable(),r=new Set;for(let s of e.workspaceIds){if(r.has(s))throw new Error(`workspace domain is inconsistent: registry order repeats workspace '${s}'`);if(t.get(s)===void 0)throw new Error(`workspace domain is inconsistent: registry order references missing workspace '${s}'`);r.add(s)}if(e.initialized&&r.size!==t.size){let s=[...t.keys()].find(o=>!r.has(o));throw new Error(`workspace domain is inconsistent: workspace '${s}' is absent from registry order`)}let n=new Map,i=new Map;for(let[s,o]of t.entries()){let a=n.get(o.path);if(a!==void 0)throw new Error(`workspace domain is inconsistent: path '${o.path}' is claimed by both workspace '${a}' and workspace '${s}'`);n.set(o.path,s);for(let c of o.sessionIds){let u=i.get(c);if(u!==void 0)throw new Error(`workspace domain is inconsistent: session '${c}' is accounted by both workspace '${u}' and workspace '${s}'`);i.set(c,s)}}}rebuildEntities(){this.entities.clear();for(let e of this.requireState().workspaceIds){let t=this.requireTable().get(e);this.entities.set(e,new SV(this.host,e,t))}}async replaceHeaderIndex(e){this.headers.clear(),this.sessionPaths.clear(),this.invalidSessionPaths.clear(),await this.indexHeaders(e)}async indexHeaders(e){for(let t of e)await this.indexHeader(t)}async indexHeader(e){if(this.headers.set(e.id,e),this.sessionPaths.delete(e.id),e.cwd===void 0){this.invalidSessionPaths.set(e.id,"header has no cwd");return}try{let t=await T0(e.cwd);if(!(await C0(t)).isDirectory()){this.invalidSessionPaths.set(e.id,`cwd '${e.cwd}' is not a directory`);return}this.sessionPaths.set(e.id,t),this.invalidSessionPaths.delete(e.id)}catch{this.invalidSessionPaths.set(e.id,`cwd '${e.cwd}' does not resolve`)}}async indexLiveSessions(){let e=this.ctx.get("sessions");e!==void 0&&await this.indexHeaders(e.list().map(t=>t.header))}reportFilteredCandidates(){for(let e of this.entities.values()){let t=this.requireTable().get(e.id);for(let r of t.sessionIds){let n=this.sessionPaths.get(r);if(n===t.path)continue;let i=this.invalidSessionPaths.get(r)??(this.headers.has(r)?`canonical cwd '${n}' differs from workspace path '${t.path}'`:"session header is missing");this.ctx.logger.warn(`workspace '${e.id}' filtered session '${r}' from membership: ${i}`)}}}async readSessionHeader(e){let t=this.ctx.get("sessions")?.get(e);if(t!==void 0)return this.headers.set(e,t.header),t.header;let r=this.headers.get(e);if(r!==void 0)return r;let n=await this.ctx.sessionPersistence.list();await this.indexHeaders(n);let i=this.headers.get(e);if(i===void 0)throw new Error(`cannot validate session '${e}': session persistence holds no such session`);return i}requireTable(){if(this.table===void 0)throw new Error("workspace registry is not started yet");return this.table}requireState(){if(this.state===void 0)throw new Error("workspace registry is not started yet");return this.state}async setState(e){await this.global.set(e),this.state=e}enqueueOperation(e){let t=this.operationTail.then(async()=>(await this.recoverPendingMutation(),await e()));return this.operationTail=t.then(()=>{},()=>{}),t}},f6e=l((e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),"sameSessionIds");import{chmod as IZ,cp as Z6e,readFile as Y7,readdir as TZ,rm as V7,stat as z0}from"node:fs/promises";import{dirname as K6e,isAbsolute as CZ,join as kl,resolve as OZ}from"node:path";function p6e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}l(p6e,"getDefaultExportFromCjs");var En={},R0={},ca={},AV;function sp(){if(AV)return ca;AV=1;function e(o){return typeof o>"u"||o===null}l(e,"isNothing");function t(o){return typeof o=="object"&&o!==null}l(t,"isObject");function r(o){return Array.isArray(o)?o:e(o)?[]:[o]}l(r,"toArray");function n(o,a){if(a){let c=Object.keys(a);for(let u=0,d=c.length;u<d;u+=1){let f=c[u];o[f]=a[f]}}return o}l(n,"extend");function i(o,a){let c="";for(let u=0;u<a;u+=1)c+=o;return c}l(i,"repeat");function s(o){return o===0&&Number.NEGATIVE_INFINITY===1/o}return l(s,"isNegativeZero"),ca.isNothing=e,ca.isObject=t,ca.toArray=r,ca.repeat=i,ca.isNegativeZero=s,ca.extend=n,ca}l(sp,"requireCommon");var w7,IV;function op(){if(IV)return w7;IV=1;function e(r,n){let i="",s=r.reason||"(unknown reason)";return r.mark?(r.mark.name&&(i+='in "'+r.mark.name+'" '),i+="("+(r.mark.line+1)+":"+(r.mark.column+1)+")",!n&&r.mark.snippet&&(i+=`
|
|
2306
|
+
`))s.length!==0&&n.enqueue(nV(s))}}))}l(rV,"decodeFramedEvents");function nV(e){let t;try{t=JSON.parse(e)}catch{throw iV("WorkerShellBackend received invalid execution JSON")}if(typeof t.id!="string"||!Number.isSafeInteger(t.seq)||t.name!=="stdout"&&t.name!=="stderr"&&t.name!=="exit"||(t.name==="stdout"||t.name==="stderr")&&typeof t.value!="string"||t.name==="exit"&&!Number.isSafeInteger(t.value))throw iV("WorkerShellBackend received a malformed execution frame");return qSe(t)}l(nV,"parseFrame");function iV(e){let t=new Error(e);return t.code="EPROTOCOL",t}l(iV,"protocolError");function qSe(e){return e.name==="stdout"||e.name==="stderr"?{id:e.id,seq:e.seq,name:e.name,value:new TextEncoder().encode(e.value)}:{id:e.id,seq:e.seq,name:"exit",code:e.value}}l(qSe,"reshape");function HSe(e){return e.mode!=="http-gateway"?`egress-${e.mode}`:`egress-http-gateway-${e.revision??crypto.randomUUID()}`}l(HSe,"egressCacheKey");function p7(e){try{e[Symbol.dispose]?.()}catch{}}l(p7,"disposeQuietly");function GSe(){let e=l(t=>{throw new Error(`WorkerShellBackend: sync.${t} must not be called \u2014 the handle declares sync: "none"`)},"refuse");return{push:l(()=>e("push"),"push"),fetchChanges:l(()=>e("fetchChanges"),"fetchChanges"),readEntry:l(()=>e("readEntry"),"readEntry"),hasObjects:l(()=>e("hasObjects"),"hasObjects"),fetchObjects:l(()=>new ReadableStream({start(t){t.error(new Error("WorkerShellBackend: sync.fetchObjects must not be called"))}}),"fetchObjects"),pushObjects:l(()=>e("pushObjects"),"pushObjects"),watermarks:l(()=>e("watermarks"),"watermarks")}}l(GSe,"noopSync");import{mkdir as Dke,stat as Lke}from"node:fs/promises";import{homedir as Mke,release as Fke}from"node:os";import{dirname as Uke,extname as jke}from"node:path";import{randomUUID as $Le}from"node:crypto";import{accessSync as NLe,constants as RLe,statSync as PLe}from"node:fs";import{isAbsolute as LLe,resolve as MLe}from"node:path";var Sl=class extends Wr{static{l(this,"SubagentError")}constructor(e,t,r){super(e,t,r),this.name="SubagentError"}};var uV=["version","mode","provider","label"],FLe=new Set(uV),ULe=new Set([...uV,"agentProvider","agentModel","persona","toolFilter"]);var dV=v.object({since:v.number().int().nonnegative(),through:v.number().int().nonnegative()}).strict(),VSe=v.object({settledMs:v.number().int().nonnegative(),active:dV.optional()}).strict().transform(({settledMs:e,active:t})=>({settledMs:e,...t===void 0?{}:{active:t}})),jLe={key:"subagentTiming",stateSchema:v.object({settledMs:v.number().int().nonnegative(),active:dV.optional(),pendingTurnStart:v.number().int().nonnegative().optional(),descriptorSeen:v.boolean()}).strict(),init:l(()=>({descriptorSeen:!1,settledMs:0}),"init"),apply:l((e,t)=>{if(t.type==="turn/start")return e.descriptorSeen?{...e,active:{since:t.time,through:t.time}}:{...e,pendingTurnStart:t.time};if(t.type==="subagent/descriptor"){let r=e.active?.since??e.pendingTurnStart;return{descriptorSeen:!0,settledMs:0,...r===void 0?{}:{active:{since:r,through:t.time}}}}if(t.type==="turn/end"){if(!e.descriptorSeen){if(e.pendingTurnStart===void 0)return e;let{pendingTurnStart:i,...s}=e;return s}if(e.active===void 0)return e;let{active:r,...n}=e;return{...n,settledMs:e.settledMs+Math.max(0,t.time-r.since)}}return e.active===void 0?e:{...e,active:{...e.active,through:t.time}}},"apply"),wire:{viewSchema:VSe,view:l(e=>({settledMs:e.settledMs,...e.active===void 0?{}:{active:e.active}}),"view")},stateVersion:2},fV=v.discriminatedUnion("mode",[v.object({mode:v.literal("one-shot"),label:v.string().optional(),seq:v.number().int().nonnegative()}).strict(),v.object({mode:v.literal("continuable"),label:v.string(),seq:v.number().int().nonnegative()}).strict()]),zLe=fV.nullable(),BLe=v.object({identity:fV.optional()}).strict();var WLe=new TextEncoder,qLe=new TextDecoder;var HLe=Object.freeze({outputSchema:!1,depthLimit:!1,toolFilter:!1,persona:!1});var _0=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,pV=128,ZSe=2,A0="runtime",KSe=250;function YSe(e){return _0.test(e)}l(YSe,"isSkillName");function gV(e){return e.invocation.userInvocable}l(gV,"isUserInvocable");var XSe=class{static{l(this,"SkillLayer")}providers;runtime=new Map;constructor(e){this.providers=new To(t=>new Error(e===void 0?`a skill provider named "${t}" is already registered`:`a skill provider named "${t}" is already registered in this scope`))}isEmpty(){return this.providers.isEmpty()&&this.runtime.size===0}},QLe=class extends ut{static{l(this,"SkillRegistry")}static Config=re.object({collectCacheMaxEntries:re.number().default(pV)});collectCacheMaxEntries;layers=new Rl(e=>new XSe(e),()=>{this.invalidateCache()});collectCache=new Map;revision=0;nextProviderOrder=0;scopeIds=new WeakMap;nextScopeId=1;constructor(e,t={}){super(e,"skills"),this.collectCacheMaxEntries=t.collectCacheMaxEntries??pV,a6e("collectCacheMaxEntries",this.collectCacheMaxEntries)}registerProvider(e){let t=new AbortController,r,n,i={signal:t.signal,invalidate:l(()=>{let s=r;s!==void 0&&s.layer.providers.get(s.name)?.provider===n&&this.invalidateCache()},"invalidate")};try{n=e(i);let s=n.name;if(s===A0)throw new Error(`"${A0}" is reserved for runtime skill registrations`);let o=this.nextProviderOrder;return this.nextProviderOrder+=1,this.layers.effect(this.ctx,a=>{let c=a.providers.insert(s,{provider:n,order:o});return r={layer:a,name:s},()=>{r=void 0,c(),t.abort(new Error(`skill provider "${s}" disposed`))}},{label:"skills.registerProvider()"})}catch(s){throw t.abort(s),s}}register(e){r6e(e);let t=pn(this.ctx),r=t===void 0?this.layers.global:this.layers.peek(t);if(r!==void 0&&r.runtime.has(e.name))return this.ctx.logger.warn(`runtime skill "${e.name}" ignored because it is already registered`),()=>{};let n={...e,invocation:e.invocation??{modelInvocable:!0,userInvocable:!0},provider:e.provider??A0};return this.layers.effect(this.ctx,i=>(i.runtime.set(n.name,n),()=>{i.runtime.delete(n.name)}),{label:"skills.register()"})}async list(e={}){return(await this.snapshot(e)).skills}async snapshot(e={}){let t=await this.collect(e);return{skills:[...t.entries.values()].map(r=>i6e(r.candidate)).sort(s6e),complete:t.cacheable}}async get(e,t={}){if(!YSe(e))return;let r=await this.collect(t);np(t.signal);let n=r.entries.get(e);if(n===void 0)return;let i=await mV(n.provider.get(n.candidate,t),t.signal);if(i!==void 0){if(n6e(i),i.name!==n.candidate.name){this.invalidateEntry(n);return}return i}}async collect(e){np(e.signal);let t=1;for(;;){let r=this.revision,n=this.collectCacheKey(e.cwd,xv(e.scope),r),i=this.collectCache.get(n);if(i!==void 0)return{entries:i,cacheable:!0};let s=await this.collectFresh(e);if(np(e.signal),r!==this.revision){if(t<ZSe){t+=1;continue}return{entries:s.entries,cacheable:!1}}if(s.cacheable&&(this.collectCache.set(n,s.entries),this.collectCache.size>this.collectCacheMaxEntries)){let o=this.collectCache.keys().next();this.collectCache.delete(o.value)}return s}}async collectFresh(e){let t=[this.layers.global,...this.layers.chainLayers(e.scope)],r=new Map,n=!0;for(let i of t){let s=await this.collectLayer(i,e);s.cacheable||(n=!1);for(let o of s.entries)r.set(o.candidate.name,o)}return{entries:r,cacheable:n}}async collectLayer(e,t){let r=await this.listLayerCandidates(e,t);r.entries.sort(o6e);let n=new Set,i=[];for(let s of r.entries){let o=s.candidate;if(n.has(o.name)){this.ctx.logger.warn(`skill "${o.name}" from ${o.source} ignored because a higher-priority skill already exists`);continue}n.add(o.name),i.push(s)}return{entries:i,cacheable:r.cacheable}}async listLayerCandidates(e,t){np(t.signal);let r=[],n=!0,i=0;for(let s of[...e.runtime.values()].sort((o,a)=>yV(o.name,a.name)))r.push({candidate:e6e(s),provider:QSe,providerOrder:-1,localOrder:i,layer:e}),i+=1;for(let{provider:s,order:o}of[...e.providers.values()]){let a=0,c;try{c=await mV(s.list(t),t.signal)}catch(d){if(t.signal?.aborted===!0)throw $0(t.signal.reason);n=!1,this.ctx.logger.warn(`skill provider "${s.name}" skipped: ${I0(d)}`)}if(c===void 0)continue;let u=JSe(c,s.name);u.complete||(n=!1);for(let d of u.candidates)t6e(d,s.name),r.push({candidate:d,provider:s,providerOrder:o,localOrder:a,layer:e}),a+=1}return{entries:r,cacheable:n}}invalidateCache(){this.revision+=1,this.collectCache.clear(),this.notifyChange()}invalidateEntry(e){e.layer.providers.get(e.provider.name)?.provider===e.provider&&this.invalidateCache()}scopeId(e){let t=this.scopeIds.get(e);return t===void 0&&(t=this.nextScopeId,this.nextScopeId+=1,this.scopeIds.set(e,t)),t}collectCacheKey(e,t,r){return JSON.stringify({cwd:e,scopes:t.map(n=>this.scopeId(n)),revision:r})}notifyChange(){for(let e of this.ctx.events.dispatch("emit",["skills/change"]))try{let t=e();Promise.resolve(t).catch(r=>{this.ctx.logger.warn(`skills/change listener rejected: ${I0(r)}`)})}catch(t){this.ctx.logger.warn(`skills/change listener threw: ${I0(t)}`)}}};function JSe(e,t){if(Array.isArray(e))return{candidates:e,complete:!0};if(e===null||typeof e!="object")throw hV(t);let r=e;if(!Array.isArray(r.candidates)||typeof r.complete!="boolean")throw hV(t);return r}l(JSe,"normalizeProviderObservation");function hV(e){return new TypeError(`skill provider "${e}" list() must return an array or { candidates, complete } observation`)}l(hV,"invalidProviderObservation");var QSe={name:A0,list(){return Promise.resolve([])},get(e){return Promise.resolve(e.locator)}};function e6e(e){return{name:e.name,description:e.description,...e.whenToUse!==void 0?{whenToUse:e.whenToUse}:{},invocation:e.invocation,source:e.source,provider:e.provider,...e.resourceBase!==void 0?{resourceBase:e.resourceBase}:{},rank:KSe,locator:e,...e.path!==void 0?{path:e.path}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}l(e6e,"runtimeCandidate");function t6e(e,t){if(typeof e.name!="string")throw new TypeError(`skill provider "${t}" returned a non-string skill name`);if(!_0.test(e.name))throw new Error(`skill provider "${t}" returned invalid skill name "${e.name}"`);if(typeof e.description!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string description`);if(e.description.length===0)throw new Error(`skill provider "${t}" returned skill "${e.name}" without a description`);if(h7(e.invocation,`skill provider "${t}" returned skill "${e.name}"`),e.whenToUse!==void 0&&typeof e.whenToUse!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string whenToUse`);if(typeof e.source!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string source`);if(typeof e.rank!="number"||!Number.isFinite(e.rank))throw new Error(`skill provider "${t}" returned skill "${e.name}" with an invalid rank`);if(typeof e.provider!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string provider`);if(e.provider!==t)throw new Error(`skill provider "${t}" returned skill "${e.name}" for provider "${e.provider}"`);if(e.path!==void 0&&typeof e.path!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string path`)}l(t6e,"validateCandidate");function r6e(e){if(!_0.test(e.name))throw new Error(`invalid skill name "${e.name}"`);if(e.description.length===0)throw new Error(`skill "${e.name}" requires a description`);h7(e.invocation,`runtime skill "${e.name}"`)}l(r6e,"validateRuntimeSkill");function n6e(e){let t=e.name,r=e.description,n=e.whenToUse,i=e.invocation,s=e.source,o=e.provider,a=e.content,c=e.path;if(typeof t!="string")throw new TypeError("loaded skill name must be a string");if(!_0.test(t))throw new Error(`loaded skill has invalid name "${t}"`);if(typeof r!="string")throw new TypeError(`loaded skill "${t}" description must be a string`);if(r.length===0)throw new Error(`loaded skill "${t}" requires a description`);if(h7(i,`loaded skill "${t}"`),n!==void 0&&typeof n!="string")throw new TypeError(`loaded skill "${t}" whenToUse must be a string`);if(typeof s!="string")throw new TypeError(`loaded skill "${t}" source must be a string`);if(typeof o!="string")throw new TypeError(`loaded skill "${t}" provider must be a string`);if(typeof a!="string")throw new TypeError(`loaded skill "${t}" content must be a string`);if(c!==void 0&&typeof c!="string")throw new TypeError(`loaded skill "${t}" path must be a string`)}l(n6e,"validateDefinition");function i6e(e){let{name:t,description:r,whenToUse:n,invocation:i,source:s,provider:o,resourceBase:a}=e;return{name:t,description:r,...n!==void 0?{whenToUse:n}:{},invocation:i,source:s,provider:o,...a!==void 0?{resourceBase:a}:{}}}l(i6e,"toSummary");function h7(e,t){if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`${t} with a non-object invocation policy`);let r=e;if(typeof r.modelInvocable!="boolean")throw new TypeError(`${t} with a non-boolean invocation.modelInvocable`);if(typeof r.userInvocable!="boolean")throw new TypeError(`${t} with a non-boolean invocation.userInvocable`)}l(h7,"validateInvocation");function s6e(e,t){return yV(e.name,t.name)}l(s6e,"compareSkillSummary");function yV(e,t){return e<t?-1:e>t?1:0}l(yV,"compareCodePoints");function o6e(e,t){return e.candidate.rank-t.candidate.rank||e.providerOrder-t.providerOrder||e.localOrder-t.localOrder}l(o6e,"compareIndexedCandidates");function a6e(e,t,r=1){if(!Number.isInteger(t)||t<r)throw new Error(`skill: ${e} must be an integer greater than or equal to ${r}`)}l(a6e,"assertPositiveInteger");function mV(e,t){return t===void 0?e:(np(t),new Promise((r,n)=>{let i=l(()=>{t.removeEventListener("abort",s)},"cleanup"),s=l(()=>{i(),n($0(t.reason))},"onAbort");t.addEventListener("abort",s,{once:!0}),e.then(o=>{i(),r(o)},o=>{i(),n($0(o))})}))}l(mV,"waitWithAbort");function np(e){if(e?.aborted===!0)throw $0(e.reason)}l(np,"throwIfAborted");function $0(e){try{if(e instanceof Error)return e}catch{}return new Error(I0(e))}l($0,"toError");function I0(e){try{return String(e)}catch{return"[unrenderable thrown value]"}}l(I0,"errorMessage");import{randomUUID as bV}from"node:crypto";import{realpath as l6e,stat as C0}from"node:fs/promises";import{basename as xV}from"node:path";var ip=/^[a-z][a-z0-9_]*$/;function vV(e){return{valueSchema:e}}l(vV,"domainTable");function wV(e){if(!ip.test(e.name))throw new Error(`domain name '${e.name}' must match ${ip}`);if(!Number.isInteger(e.version)||e.version<0)throw new Error(`domain '${e.name}' version must be a non-negative integer, got ${e.version}`);for(let t of Object.keys(e.tables))if(!ip.test(t))throw new Error(`domain '${e.name}' table name '${t}' must match ${ip}`);if(e.global!==void 0&&e.global.schema.safeParse(null).success)throw new Error(`domain '${e.name}' global schema must not accept null: null is the medium's "never written" sentinel, so a stored null could not round-trip`);return e}l(wV,"defineDomain");var uMe=re.object({backend:re.string().required(),routes:re.dict(re.string()).default({})});async function T0(e){return await l6e(e)}l(T0,"realpathNormalize");var O0=class extends Error{static{l(this,"WorkspaceMoveInvalidError")}constructor(e){super(e),this.name="WorkspaceMoveInvalidError"}},EV=new Error("workspace record unchanged (internal sentinel)"),SV=class{static{l(this,"WorkspaceEntity")}host;id;record;constructor(e,t,r){this.host=e,this.id=t,this.record=r}get path(){return this.record.path}get title(){return this.record.title}get createdAt(){return this.record.createdAt}get updatedAt(){return this.record.updatedAt}get sessionIds(){return this.record.sessionIds.filter(e=>this.host.sessionPath(e)===this.record.path)}async setTitle(e){await this.mutate(t=>({...t,title:e}))}async attachSession(e){if(!this.record.sessionIds.includes(e)){let t=await this.host.readSessionHeader(e);if(t.cwd===void 0)throw new Error(`cannot attach session '${e}' to workspace '${this.record.path}': its stored header carries no cwd to validate against`);let r;try{r=await T0(t.cwd)}catch(n){throw new Error(`cannot attach session '${e}' to workspace '${this.record.path}': its cwd '${t.cwd}' does not resolve, so it cannot be validated`,{cause:n})}if(!(await C0(r)).isDirectory())throw new Error(`cannot attach session '${e}' to workspace '${this.record.path}': its cwd '${t.cwd}' is not a directory`);if(r!==this.record.path)throw new Error(`cannot attach session '${e}' to workspace '${this.record.path}': its cwd resolves to '${r}'`);this.host.rememberSessionPath(e,r)}await this.mutate(t=>t.sessionIds.includes(e)?t:{...t,sessionIds:[e,...t.sessionIds]})}async insertSessionBefore(e,t){await this.mutate(r=>{if(!r.sessionIds.includes(e))throw new O0(`cannot move session '${e}' in workspace '${r.path}': the session is not accounted`);if(t!==void 0&&!r.sessionIds.includes(t))throw new O0(`cannot move session '${e}' before '${t}' in workspace '${r.path}': the anchor session is not accounted`);if(t===e)return r;let n=r.sessionIds.filter(o=>o!==e),i=t===void 0?n.length:n.indexOf(t),s=[...n.slice(0,i),e,...n.slice(i)];return s.every((o,a)=>o===r.sessionIds[a])?r:{...r,sessionIds:s}})}async detachSession(e){await this.mutate(t=>t.sessionIds.includes(e)?{...t,sessionIds:t.sessionIds.filter(r=>r!==e)}:t)}async status(){try{return(await C0(this.record.path)).isDirectory()?"ok":"missing-dir"}catch{return"missing-dir"}}async mutate(e){let t;try{t=await this.host.table().update(this.id,r=>{let n=e(r),i=n.sessionIds.filter(s=>this.host.sessionPath(s)===n.path);if(n===r&&i.length===r.sessionIds.length)throw EV;return{...n,sessionIds:i,updatedAt:new Date().toISOString()}})}catch(r){if(r===EV)return;throw r}this.record=t}},m7=v.string().transform(e=>e),g7=v.object({path:v.string(),title:v.string(),sessionIds:v.array(v.string().transform(Ia)),createdAt:v.string(),updatedAt:v.string()}),c6e=v.discriminatedUnion("operation",[v.object({operation:v.literal("create"),workspaceId:m7}),v.object({operation:v.literal("delete"),workspaceId:m7})]),y7=v.object({initialized:v.boolean(),workspaceIds:v.array(m7),archivedSessionIds:v.array(v.string().transform(Ia)).default([]),pendingMutation:c6e.optional()}),u6e=wV({name:"workspace",version:2,global:{schema:y7,initial:{initialized:!1,workspaceIds:[],archivedSessionIds:[]}},tables:{workspaces:vV(g7)}});var v7=class extends Error{static{l(this,"WorkspaceUnknownSessionError")}sessionId;constructor(e){super(`cannot archive session '${e}': live sessions and session persistence hold no such session`),this.sessionId=e,this.name="WorkspaceUnknownSessionError"}},N0=class extends Error{static{l(this,"WorkspaceOrderInvalidError")}workspaceId;constructor(e){super(`cannot reorder unknown workspace '${e}'`),this.workspaceId=e,this.name="WorkspaceOrderInvalidError"}},kV=l((e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),"sameIds"),d6e=l((e,t)=>t.createdAt-e.createdAt||String(e.id).localeCompare(String(t.id)),"compareHeaders"),bMe=class extends ut{static{l(this,"WorkspaceRegistry")}static inject=["storageDomain","sessionPersistence"];table;global;state;entities=new Map;headers=new Map;sessionPaths=new Map;invalidSessionPaths=new Map;operationTail=Promise.resolve();host={table:l(()=>this.requireTable(),"table"),sessionPath:l(e=>this.sessionPaths.get(e),"sessionPath"),readSessionHeader:l(e=>this.readSessionHeader(e),"readSessionHeader"),rememberSessionPath:l((e,t)=>{this.sessionPaths.set(e,t),this.invalidSessionPaths.delete(e)},"rememberSessionPath")};constructor(e){super(e,"workspaceRegistry")}async[ut.init](){let e=await this.ctx.storageDomain.open(u6e);if(this.ctx.effect(()=>()=>e.close(),"workspace.domainClose"),this.table=e.table("workspaces"),this.global=e.global,this.state=e.global.get(),await this.recoverPendingMutation(),this.validateStoredState(this.state),this.state.initialized)this.table.size>0&&await this.replaceHeaderIndex(await this.ctx.sessionPersistence.list());else{let t=await this.ctx.sessionPersistence.list();await this.replaceHeaderIndex(t),await this.bootstrap(t)}await this.indexLiveSessions(),this.validateStoredState(this.requireState()),this.rebuildEntities(),this.reportFilteredCandidates()}async create(e,t){let r=await T0(e);if(!(await C0(r)).isDirectory())throw new Error(`cannot create a workspace at '${r}': path is not a directory`);return await this.enqueueOperation(()=>this.createCanonical(r,t))}get(e){return this.entities.get(e)}list(){return this.requireState().workspaceIds.map(e=>{let t=this.entities.get(e);if(t===void 0)throw new Error(`workspace registry order references missing workspace '${e}'`);return t})}delete(e){return this.enqueueOperation(()=>this.deleteKnown(e))}insertBefore(e,t){return this.enqueueOperation(async()=>{let r=this.requireState();if(!r.workspaceIds.includes(e))throw new N0(e);if(t!==void 0&&!r.workspaceIds.includes(t))throw new N0(t);if(t===e)return r.workspaceIds;let n=r.workspaceIds.filter(o=>o!==e),i=t===void 0?n.length:n.indexOf(t),s=[...n.slice(0,i),e,...n.slice(i)];return kV(s,r.workspaceIds)?r.workspaceIds:(await this.setState({...r,workspaceIds:s}),s)})}get archivedSessionIds(){return this.requireState().archivedSessionIds}archiveSession(e){return this.enqueueOperation(async()=>{if(this.requireState().archivedSessionIds.includes(e))return;if(!await this.sessionKnown(e))throw new v7(e);let t=this.requireState();await this.setState({...t,archivedSessionIds:[...t.archivedSessionIds,e]})})}async sessionKnown(e){return this.ctx.get("sessions")?.get(e)!==void 0||this.headers.has(e)?!0:(await this.indexHeaders(await this.ctx.sessionPersistence.list()),this.headers.has(e))}async resolveByPath(e){let t=await T0(e);for(let r of this.entities.values())if(r.path===t)return r}async createCanonical(e,t){for(let d of this.entities.values())if(d.path===e)return d;let r=t??xV(e),n=this.requireTable(),i=this.requireState(),s=bV(),o=new Date().toISOString(),a={path:e,title:r,sessionIds:[],createdAt:o,updatedAt:o},c=new SV(this.host,s,a);this.entities.set(s,c);let u={...i,pendingMutation:{operation:"create",workspaceId:s}};try{await this.setState(u)}catch(d){throw this.entities.delete(s),d}try{await n.put(s,a)}catch(d){this.entities.delete(s);try{await this.setState(i)}catch(f){throw new AggregateError([d,f],`workspace '${s}' record write and pending-marker rollback both failed`)}throw d}try{await this.setState({initialized:!0,workspaceIds:[s,...i.workspaceIds],archivedSessionIds:i.archivedSessionIds})}catch(d){this.entities.delete(s);try{await n.delete(s)}catch(f){throw new AggregateError([d,f],`workspace '${s}' order write and record rollback both failed; the pending marker remains recoverable`)}try{await this.setState(i)}catch(f){throw new AggregateError([d,f],`workspace '${s}' order write and pending-marker rollback both failed`)}throw d}return c}async deleteKnown(e){let t=this.entities.get(e);if(t===void 0)return!1;let r=this.requireState(),n={initialized:!0,workspaceIds:r.workspaceIds.filter(i=>i!==e),archivedSessionIds:r.archivedSessionIds};await this.setState({...n,pendingMutation:{operation:"delete",workspaceId:e}}),this.entities.delete(e);try{await this.requireTable().delete(e)}catch(i){this.entities.set(e,t);try{await this.setState(r)}catch(s){throw this.entities.delete(e),new AggregateError([i,s],`workspace '${e}' record deletion and registry-order rollback both failed`)}throw i}try{await this.setState(n)}catch(i){this.ctx.logger.warn(`workspace '${e}' was deleted but its pending marker could not be cleared: ${String(i)}`)}return!0}async recoverPendingMutation(){let e=this.requireState(),t=e.pendingMutation;if(t!==void 0){if(e.workspaceIds.includes(t.workspaceId))throw new Error(`workspace domain is inconsistent: pending ${t.operation} workspace '${t.workspaceId}' is still present in registry order`);await this.requireTable().delete(t.workspaceId),await this.setState({initialized:e.initialized,workspaceIds:e.workspaceIds,archivedSessionIds:e.archivedSessionIds})}}async bootstrap(e){let t=this.requireTable(),r=this.requireState(),n=new Map;for(let d of e){let f=this.sessionPaths.get(d.id);if(f===void 0)continue;let p=n.get(f);p===void 0?n.set(f,[d]):p.push(d)}let i=[...n].map(([d,f])=>(f.sort(d6e),{path:d,headers:f,newestAt:f[0].createdAt})).sort((d,f)=>f.newestAt-d.newestAt||d.path.localeCompare(f.path)),s=new Map,o=new Map;for(let[d,f]of t.entries()){s.set(f.path,d);for(let p of f.sessionIds)o.set(p,d)}for(let d of i){let f=s.get(d.path);if(f===void 0){let y=d.headers.map(b=>b.id).filter(b=>!o.has(b));if(y.length===0)continue;f=bV();let x=new Date(d.newestAt).toISOString(),w={path:d.path,title:xV(d.path),sessionIds:y,createdAt:x,updatedAt:x};await t.put(f,w),s.set(d.path,f);for(let b of y)o.set(b,f);continue}let p=t.get(f),h=d.headers.map(y=>y.id).filter(y=>o.get(y)===void 0||o.get(y)===f),m=new Set(h),g=[...h,...p.sessionIds.filter(y=>!m.has(y))];if(!f6e(p.sessionIds,g)){await t.update(f,y=>({...y,sessionIds:g,updatedAt:new Date().toISOString()}));for(let y of h)o.set(y,f)}}let a=new Map(i.map(d=>[d.path,d.newestAt])),c=new Map(r.workspaceIds.map((d,f)=>[d,f])),u=[...t.entries()].sort(([d,f],[p,h])=>{let m=a.get(f.path)??Date.parse(f.createdAt);return(a.get(h.path)??Date.parse(h.createdAt))-m||(c.get(d)??Number.MAX_SAFE_INTEGER)-(c.get(p)??Number.MAX_SAFE_INTEGER)||String(d).localeCompare(String(p))}).map(([d])=>d);kV(r.workspaceIds,u)||await this.setState({initialized:!1,workspaceIds:u,archivedSessionIds:r.archivedSessionIds}),await this.setState({initialized:!0,workspaceIds:u,archivedSessionIds:r.archivedSessionIds})}validateStoredState(e){let t=this.requireTable(),r=new Set;for(let s of e.workspaceIds){if(r.has(s))throw new Error(`workspace domain is inconsistent: registry order repeats workspace '${s}'`);if(t.get(s)===void 0)throw new Error(`workspace domain is inconsistent: registry order references missing workspace '${s}'`);r.add(s)}if(e.initialized&&r.size!==t.size){let s=[...t.keys()].find(o=>!r.has(o));throw new Error(`workspace domain is inconsistent: workspace '${s}' is absent from registry order`)}let n=new Map,i=new Map;for(let[s,o]of t.entries()){let a=n.get(o.path);if(a!==void 0)throw new Error(`workspace domain is inconsistent: path '${o.path}' is claimed by both workspace '${a}' and workspace '${s}'`);n.set(o.path,s);for(let c of o.sessionIds){let u=i.get(c);if(u!==void 0)throw new Error(`workspace domain is inconsistent: session '${c}' is accounted by both workspace '${u}' and workspace '${s}'`);i.set(c,s)}}}rebuildEntities(){this.entities.clear();for(let e of this.requireState().workspaceIds){let t=this.requireTable().get(e);this.entities.set(e,new SV(this.host,e,t))}}async replaceHeaderIndex(e){this.headers.clear(),this.sessionPaths.clear(),this.invalidSessionPaths.clear(),await this.indexHeaders(e)}async indexHeaders(e){for(let t of e)await this.indexHeader(t)}async indexHeader(e){if(this.headers.set(e.id,e),this.sessionPaths.delete(e.id),e.cwd===void 0){this.invalidSessionPaths.set(e.id,"header has no cwd");return}try{let t=await T0(e.cwd);if(!(await C0(t)).isDirectory()){this.invalidSessionPaths.set(e.id,`cwd '${e.cwd}' is not a directory`);return}this.sessionPaths.set(e.id,t),this.invalidSessionPaths.delete(e.id)}catch{this.invalidSessionPaths.set(e.id,`cwd '${e.cwd}' does not resolve`)}}async indexLiveSessions(){let e=this.ctx.get("sessions");e!==void 0&&await this.indexHeaders(e.list().map(t=>t.header))}reportFilteredCandidates(){for(let e of this.entities.values()){let t=this.requireTable().get(e.id);for(let r of t.sessionIds){let n=this.sessionPaths.get(r);if(n===t.path)continue;let i=this.invalidSessionPaths.get(r)??(this.headers.has(r)?`canonical cwd '${n}' differs from workspace path '${t.path}'`:"session header is missing");this.ctx.logger.warn(`workspace '${e.id}' filtered session '${r}' from membership: ${i}`)}}}async readSessionHeader(e){let t=this.ctx.get("sessions")?.get(e);if(t!==void 0)return this.headers.set(e,t.header),t.header;let r=this.headers.get(e);if(r!==void 0)return r;let n=await this.ctx.sessionPersistence.list();await this.indexHeaders(n);let i=this.headers.get(e);if(i===void 0)throw new Error(`cannot validate session '${e}': session persistence holds no such session`);return i}requireTable(){if(this.table===void 0)throw new Error("workspace registry is not started yet");return this.table}requireState(){if(this.state===void 0)throw new Error("workspace registry is not started yet");return this.state}async setState(e){await this.global.set(e),this.state=e}enqueueOperation(e){let t=this.operationTail.then(async()=>(await this.recoverPendingMutation(),await e()));return this.operationTail=t.then(()=>{},()=>{}),t}},f6e=l((e,t)=>e.length===t.length&&e.every((r,n)=>r===t[n]),"sameSessionIds");import{chmod as IZ,cp as Z6e,readFile as Y7,readdir as TZ,rm as V7,stat as z0}from"node:fs/promises";import{dirname as K6e,isAbsolute as CZ,join as kl,resolve as OZ}from"node:path";function p6e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}l(p6e,"getDefaultExportFromCjs");var En={},R0={},ca={},AV;function sp(){if(AV)return ca;AV=1;function e(o){return typeof o>"u"||o===null}l(e,"isNothing");function t(o){return typeof o=="object"&&o!==null}l(t,"isObject");function r(o){return Array.isArray(o)?o:e(o)?[]:[o]}l(r,"toArray");function n(o,a){if(a){let c=Object.keys(a);for(let u=0,d=c.length;u<d;u+=1){let f=c[u];o[f]=a[f]}}return o}l(n,"extend");function i(o,a){let c="";for(let u=0;u<a;u+=1)c+=o;return c}l(i,"repeat");function s(o){return o===0&&Number.NEGATIVE_INFINITY===1/o}return l(s,"isNegativeZero"),ca.isNothing=e,ca.isObject=t,ca.toArray=r,ca.repeat=i,ca.isNegativeZero=s,ca.extend=n,ca}l(sp,"requireCommon");var w7,IV;function op(){if(IV)return w7;IV=1;function e(r,n){let i="",s=r.reason||"(unknown reason)";return r.mark?(r.mark.name&&(i+='in "'+r.mark.name+'" '),i+="("+(r.mark.line+1)+":"+(r.mark.column+1)+")",!n&&r.mark.snippet&&(i+=`
|
|
2307
2307
|
|
|
2308
2308
|
`+r.mark.snippet),s+" "+i):s}l(e,"formatError");function t(r,n){Error.call(this),this.name="YAMLException",this.reason=r,this.mark=n,this.message=e(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return l(t,"YAMLException2"),t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t.prototype.toString=l(function(n){return this.name+": "+e(this,n)},"toString"),w7=t,w7}l(op,"requireException");var b7,$V;function h6e(){if($V)return b7;$V=1;let e=sp();function t(i,s,o,a,c){let u="",d="",f=Math.floor(c/2)-1;return a-s>f&&(u=" ... ",s=a-f+u.length),o-a>f&&(d=" ...",o=a+f-d.length),{str:u+i.slice(s,o).replace(/\t/g,"\u2192")+d,pos:a-s+u.length}}l(t,"getLine");function r(i,s){return e.repeat(" ",s-i.length)+i}l(r,"padStart");function n(i,s){if(s=Object.create(s||null),!i.buffer)return null;s.maxLength||(s.maxLength=79),typeof s.indent!="number"&&(s.indent=1),typeof s.linesBefore!="number"&&(s.linesBefore=3),typeof s.linesAfter!="number"&&(s.linesAfter=2);let o=/\r?\n|\r|\0/g,a=[0],c=[],u,d=-1;for(;u=o.exec(i.buffer);)c.push(u.index),a.push(u.index+u[0].length),i.position<=u.index&&d<0&&(d=a.length-2);d<0&&(d=a.length-1);let f="",p=Math.min(i.line+s.linesAfter,c.length).toString().length,h=s.maxLength-(s.indent+p+3);for(let g=1;g<=s.linesBefore&&!(d-g<0);g++){let y=t(i.buffer,a[d-g],c[d-g],i.position-(a[d]-a[d-g]),h);f=e.repeat(" ",s.indent)+r((i.line-g+1).toString(),p)+" | "+y.str+`
|
|
2309
2309
|
`+f}let m=t(i.buffer,a[d],c[d],i.position,h);f+=e.repeat(" ",s.indent)+r((i.line+1).toString(),p)+" | "+m.str+`
|
|
@@ -2334,29 +2334,29 @@ export default { decode };
|
|
|
2334
2334
|
`+N.slice(me,Ie),me=Ie+1),Ae=Ve;return Ge+=`
|
|
2335
2335
|
`,N.length-me>te&&Ae>me?Ge+=N.slice(me,Ae)+`
|
|
2336
2336
|
`+N.slice(Ae+1):Ge+=N.slice(me),Ge.slice(1)}l($e,"foldLine");function He(N){let te="",be=0;for(let we=0;we<N.length;be>=65536?we+=2:we++){be=de(N,we);let me=L[be];!me&&Fe(be)?(te+=N[we],be>=65536&&(te+=N[we+1])):te+=me||H(be)}return te}l(He,"escapeString");function lt(N,te,be){let we="",me=N.tag;for(let Ie=0,Ae=be.length;Ie<Ae;Ie+=1){let Ve=be[Ie];N.replacer&&(Ve=N.replacer.call(be,String(Ie),Ve)),(le(N,te,Ve,!1,!1)||typeof Ve>"u"&&le(N,te,null,!1,!1))&&(we!==""&&(we+=","+(N.condenseFlow?"":" ")),we+=N.dump)}N.tag=me,N.dump="["+we+"]"}l(lt,"writeFlowSequence");function Lt(N,te,be,we){let me="",Ie=N.tag;for(let Ae=0,Ve=be.length;Ae<Ve;Ae+=1){let Ge=be[Ae];N.replacer&&(Ge=N.replacer.call(be,String(Ae),Ge)),(le(N,te+1,Ge,!0,!0,!1,!0)||typeof Ge>"u"&&le(N,te+1,null,!0,!0,!1,!0))&&((!we||me!=="")&&(me+=ce(N,te)),N.dump&&a===N.dump.charCodeAt(0)?me+="-":me+="- ",me+=N.dump)}N.tag=Ie,N.dump=me||"[]"}l(Lt,"writeBlockSequence");function Pt(N,te,be){let we="",me=N.tag,Ie=Object.keys(be);for(let Ae=0,Ve=Ie.length;Ae<Ve;Ae+=1){let Ge="";we!==""&&(Ge+=", "),N.condenseFlow&&(Ge+='"');let et=Ie[Ae],rt=be[et];N.replacer&&(rt=N.replacer.call(be,et,rt)),le(N,te,et,!1,!1)&&(N.dump.length>1024&&(Ge+="? "),Ge+=N.dump+(N.condenseFlow?'"':"")+":"+(N.condenseFlow?"":" "),le(N,te,rt,!1,!1)&&(Ge+=N.dump,we+=Ge))}N.tag=me,N.dump="{"+we+"}"}l(Pt,"writeFlowMapping");function E(N,te,be,we){let me="",Ie=N.tag,Ae=Object.keys(be);if(N.sortKeys===!0)Ae.sort();else if(typeof N.sortKeys=="function")Ae.sort(N.sortKeys);else if(N.sortKeys)throw new t("sortKeys must be a boolean or a function");for(let Ve=0,Ge=Ae.length;Ve<Ge;Ve+=1){let et="";(!we||me!=="")&&(et+=ce(N,te));let rt=Ae[Ve],St=be[rt];if(N.replacer&&(St=N.replacer.call(be,rt,St)),!le(N,te+1,rt,!0,!0,!0))continue;let Zt=N.tag!==null&&N.tag!=="?"||N.dump&&N.dump.length>1024;Zt&&(N.dump&&a===N.dump.charCodeAt(0)?et+="?":et+="? "),et+=N.dump,Zt&&(et+=ce(N,te)),le(N,te+1,St,!0,Zt)&&(N.dump&&a===N.dump.charCodeAt(0)?et+=":":et+=": ",et+=N.dump,me+=et)}N.tag=Ie,N.dump=me||"{}"}l(E,"writeBlockMapping");function q(N,te,be){let we=be?N.explicitTypes:N.implicitTypes;for(let me=0,Ie=we.length;me<Ie;me+=1){let Ae=we[me];if((Ae.instanceOf||Ae.predicate)&&(!Ae.instanceOf||typeof te=="object"&&te instanceof Ae.instanceOf)&&(!Ae.predicate||Ae.predicate(te))){if(be?Ae.multi&&Ae.representName?N.tag=Ae.representName(te):N.tag=Ae.tag:N.tag="?",Ae.represent){let Ve=N.styleMap[Ae.tag]||Ae.defaultStyle,Ge;if(n.call(Ae.represent)==="[object Function]")Ge=Ae.represent(te,Ve);else if(i.call(Ae.represent,Ve))Ge=Ae.represent[Ve](te,Ve);else throw new t("!<"+Ae.tag+'> tag resolver accepts not "'+Ve+'" style');N.dump=Ge}return!0}}return!1}l(q,"detectType");function le(N,te,be,we,me,Ie,Ae){N.tag=null,N.dump=be,q(N,be,!1)||q(N,be,!0);let Ve=n.call(N.dump),Ge=we;we&&(we=N.flowLevel<0||N.flowLevel>te);let et=Ve==="[object Object]"||Ve==="[object Array]",rt,St;if(et&&(rt=N.duplicates.indexOf(be),St=rt!==-1),(N.tag!==null&&N.tag!=="?"||St||N.indent!==2&&te>0)&&(me=!1),St&&N.usedDuplicates[rt])N.dump="*ref_"+rt;else{if(et&&St&&!N.usedDuplicates[rt]&&(N.usedDuplicates[rt]=!0),Ve==="[object Object]")we&&Object.keys(N.dump).length!==0?(E(N,te,N.dump,me),St&&(N.dump="&ref_"+rt+N.dump)):(Pt(N,te,N.dump),St&&(N.dump="&ref_"+rt+" "+N.dump));else if(Ve==="[object Array]")we&&N.dump.length!==0?(N.noArrayIndent&&!Ae&&te>0?Lt(N,te-1,N.dump,me):Lt(N,te,N.dump,me),St&&(N.dump="&ref_"+rt+N.dump)):(lt(N,te,N.dump),St&&(N.dump="&ref_"+rt+" "+N.dump));else if(Ve==="[object String]")N.tag!=="?"&&oe(N,N.dump,te,Ie,Ge);else{if(Ve==="[object Undefined]")return!1;if(N.skipInvalid)return!1;throw new t("unacceptable kind of an object to dump "+Ve)}if(N.tag!==null&&N.tag!=="?"){let Zt=encodeURI(N.tag[0]==="!"?N.tag.slice(1):N.tag).replace(/!/g,"%21");N.tag[0]==="!"?Zt="!"+Zt:Zt.slice(0,18)==="tag:yaml.org,2002:"?Zt="!!"+Zt.slice(18):Zt="!<"+Zt+">",N.dump=Zt+" "+N.dump}}return!0}l(le,"writeNode");function ye(N,te){let be=[],we=[];ae(N,be,we);let me=we.length;for(let Ie=0;Ie<me;Ie+=1)te.duplicates.push(be[we[Ie]]);te.usedDuplicates=new Array(me)}l(ye,"getDuplicateReferences");function ae(N,te,be){if(N!==null&&typeof N=="object"){let we=te.indexOf(N);if(we!==-1)be.indexOf(we)===-1&&be.push(we);else if(te.push(N),Array.isArray(N))for(let me=0,Ie=N.length;me<Ie;me+=1)ae(N[me],te,be);else{let me=Object.keys(N);for(let Ie=0,Ae=me.length;Ie<Ae;Ie+=1)ae(N[me[Ie]],te,be)}}}l(ae,"inspectNode");function xe(N,te){te=te||{};let be=new ue(te);be.noRefs||ye(N,be);let we=N;return be.replacer&&(we=be.replacer.call({"":we},"",we)),le(be,0,we,!0,!0)?be.dump+`
|
|
2337
|
-
`:""}return l(xe,"dump2"),j7.dump=xe,j7}l(g6e,"requireDumper");var KV;function y6e(){if(KV)return En;KV=1;let e=m6e(),t=g6e();function r(n,i){return function(){throw new Error("Function yaml."+n+" is removed in js-yaml 4. Use yaml."+i+" instead, which is now safe by default.")}}return l(r,"renamed"),En.Type=Rn(),En.Schema=YV(),En.FAILSAFE_SCHEMA=eZ(),En.JSON_SCHEMA=sZ(),En.CORE_SCHEMA=oZ(),En.DEFAULT_SCHEMA=z7(),En.load=e.load,En.loadAll=e.loadAll,En.dump=t.dump,En.YAMLException=op(),En.types={binary:cZ(),float:iZ(),map:QV(),null:tZ(),pairs:dZ(),set:fZ(),timestamp:aZ(),bool:rZ(),int:nZ(),merge:lZ(),omap:uZ(),seq:JV(),str:XV()},En.safeLoad=r("safeLoad","load"),En.safeLoadAll=r("safeLoadAll","loadAll"),En.safeDump=r("safeDump","dump"),En}l(y6e,"requireJsYaml");var v6e=y6e(),P0=p6e(v6e),{Type:pZ,Schema
|
|
2337
|
+
`:""}return l(xe,"dump2"),j7.dump=xe,j7}l(g6e,"requireDumper");var KV;function y6e(){if(KV)return En;KV=1;let e=m6e(),t=g6e();function r(n,i){return function(){throw new Error("Function yaml."+n+" is removed in js-yaml 4. Use yaml."+i+" instead, which is now safe by default.")}}return l(r,"renamed"),En.Type=Rn(),En.Schema=YV(),En.FAILSAFE_SCHEMA=eZ(),En.JSON_SCHEMA=sZ(),En.CORE_SCHEMA=oZ(),En.DEFAULT_SCHEMA=z7(),En.load=e.load,En.loadAll=e.loadAll,En.dump=t.dump,En.YAMLException=op(),En.types={binary:cZ(),float:iZ(),map:QV(),null:tZ(),pairs:dZ(),set:fZ(),timestamp:aZ(),bool:rZ(),int:nZ(),merge:lZ(),omap:uZ(),seq:JV(),str:XV()},En.safeLoad=r("safeLoad","load"),En.safeLoadAll=r("safeLoadAll","loadAll"),En.safeDump=r("safeDump","dump"),En}l(y6e,"requireJsYaml");var v6e=y6e(),P0=p6e(v6e),{Type:pZ,Schema:_Me,FAILSAFE_SCHEMA:TMe,JSON_SCHEMA:hZ,CORE_SCHEMA:CMe,DEFAULT_SCHEMA:OMe,load:D0,loadAll:NMe,dump:mZ,YAMLException:RMe,types:PMe,safeLoad:DMe,safeLoadAll:LMe,safeDump:MMe}=P0;import{createRequire as b6e}from"node:module";var W7;(function(e){let t;function r(i){let s=b6e(import.meta.url);if(process.execArgv.includes("--expose-internals"))try{return s(i)}catch{}try{return s("node-addon-require-builtin").requireBuiltin(i)}catch{}}l(r,"requireInternal");function n(){if(t)return t;let[i]=process.versions.node.split(".").map(Number);if(i>=24){let s=r("internal/modules/esm/loader")?.getOrInitializeCascadedLoader();if(s)return t=Object.assign(s,{version:"v2"})}else if(i>=22){let s=r("internal/modules/esm/loader")?.getOrInitializeCascadedLoader();if(s)return t=Object.assign(s,{version:"v1"})}}l(n,"fromInternal"),e.fromInternal=n})(W7||(W7={}));var pu=class{static{l(this,"EntryGroup")}ctx;tree;static key=Symbol.for("cordis.group");data=[];constructor(e,t){this.ctx=e,this.tree=t;let r=e.fiber.entry;r&&(r.subgroup=this)}get context(){return this.ctx}async create(e){let t=this.tree.ensureId(e),r=this.tree.store[t],n=r??(this.tree.store[t]=new H7(this.ctx.loader)),i=n.parent;n.parent=this;try{await n.update(e,!0,!0)}catch(s){throw r?n.parent=i:delete this.tree.store[t],s}return n.id}unlink(e){let t=this.data,r=t.indexOf(e);r>=0&&t.splice(r,1)}async remove(e,t=!1){let r=this.tree.store[e];r&&(await r._dispose(),t||this.unlink(r.options),delete this.tree.store[e],this.context.emit("loader/partial-dispose",r,r.options,!1))}async update(e){let t=this.data,r=new Set;for(let s of e){let o=this.tree.ensureId(s);if(r.has(o))throw new TypeError(`duplicate loader entry id: ${o}`);r.add(o)}let n=Object.fromEntries(t.map(s=>[s.id,s])),i=Object.fromEntries(e.map(s=>[s.id,s]));try{let s=await Promise.allSettled(e.map(a=>this.create(a)));if(this.ctx.fiber.uid===null)return;let o=s.filter(a=>a.status==="rejected").map(a=>a.reason);if(o.length===1)throw o[0];if(o.length>1)throw new AggregateError(o,"loader entries failed to apply");for(let a of Object.keys(n))i[a]||await this.remove(a,!0);this.data=e}catch(s){let o=[];for(let a of Object.keys(i).reverse())if(!n[a])try{await this.remove(a,!0)}catch(c){o.push(c)}for(let a of t)try{await this.create(a)}catch(c){o.push(c)}throw this.data=t,o.length?new AggregateError([s,...o],"loader entry rollback failed"):s}}async stop(){for(let e of this.data)await this.remove(e.id,!0)}},BMe=class extends pu{static{l(this,"Group")}ctx;config;static initial=[];static[pu.key]=!0;constructor(e,t){super(e,e.fiber.entry.parent.tree),this.ctx=e,this.config=t,e.on("internal/update",r=>this.update(r))}async*[ut.init](){yield()=>this.stop(),await this.update(this.config)}},gZ=l(function(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,i,s,o){return n?t?".jsx":".js":i&&(!s||!o)?r:i+s+"."+o.toLowerCase()+"js"}):e},"__rewriteRelativeImportExtension"),L0=class vZ{static{l(this,"EntryTree")}static sep=":";ctx;enableLogs;root;store=Object.create(null);constructor(t){this.ctx=t.extend({baseUrl:t.baseUrl}),this.root=new pu(this.ctx,this);let r=this.ctx.fiber.entry;r&&(r.subtree=this)}get context(){return this.ctx}*entries(){for(let t of Object.values(this.store))yield t,t.subtree&&(yield*t.subtree.entries())}getTasks(){return[...this.entries()].map(t=>t._initTask||t.fiber?.inertia).filter(R$)}async await(){for(;;){let t=this.getTasks();if(t.length){await Promise.allSettled(t);continue}let r=(await Promise.allSettled([...this.entries()].map(n=>n._await()))).filter(n=>n.status==="rejected").map(n=>n.reason);if(r.length===1)throw r[0];if(r.length>1)throw new AggregateError(r,"loader fibers failed");if(this.ctx.reflect.notify(["loader"]),!this.getTasks().length)return}}ensureId(t){if(!t.id)do t.id=Math.random().toString(16).slice(2,10);while(this.store[t.id]);return t.id}resolve(t){let r=t.split(vZ.sep),n=this,i=r.pop();for(let o of r)if(n=n.store[o]?.subtree,!n)throw new Error(`cannot resolve entry ${t}`);let s=n.store[i];if(!s)throw new Error(`cannot resolve entry ${t}`);return s}resolveGroup(t){if(!t)return this.root;let r=this.resolve(t);if(!r.subgroup)throw new Error(`entry ${t} is not a group`);return r.subgroup}async create(t,r=null,n=1/0){let i=this.resolveGroup(r),s=await i.create(t),o=this.resolve(s);return i.data.splice(n,0,o.options),i.tree.write(),s}async remove(t){let r=this.resolve(t);await r.parent.remove(t),r.parent.tree.write()}async update(t,r,n,i){let s=this.resolve(t),o=s.parent,a=o.data.indexOf(s.options),c=o;n!==void 0&&(c=this.resolveGroup(n),o.unlink(s.options),c.data.splice(i??1/0,0,s.options),s.parent=c);try{await s.update(r,!1,!0)}catch(u){if(n!==void 0){c.unlink(s.options),o.data.splice(a<0?o.data.length:a,0,s.options),s.parent=o;try{await s.update({},!1,!0)}catch(d){throw new AggregateError([u,d],`failed to roll back loader entry move ${t}`)}}throw u}o.tree.write(),c!==o&&c.tree.write()}import(t,r){return t.startsWith("cordis:")?this.ctx.loader.builtins[t.slice(7)]:Fp(async n=>(n.offset+=3,this.ctx.loader.internal?await this.ctx.loader.internal.import(t,this.ctx.baseUrl,{}):t.startsWith(".")?await import(gZ(new URL(t,this.ctx.baseUrl).href)):await import(gZ(t))),r)}},wZ=new Function("ctx","expr",`
|
|
2338
2338
|
with (ctx) {
|
|
2339
2339
|
return eval(expr)
|
|
2340
2340
|
}
|
|
2341
|
-
`);function q7(e,t){return M0(t)?wZ(e,t.__jsExpr):!t||typeof t!="object"?t:Array.isArray(t)?t.map(r=>q7(e,r)):qi(t,r=>q7(e,r))}l(q7,"interpolate");function M0(e){return e instanceof Object&&"__jsExpr"in e}l(M0,"isJsExpr");function zs(e,t,r){let n=r instanceof Error?r.message:String(r);return new Error(`failed to ${e} loader entry ${t.id} (${t.name}): ${n}`,{cause:r})}l(zs,"updateError");function B7(e,t){let r=[];for(let n of t)n in e&&(r.push([n,e[n]]),delete e[n]);return r}l(B7,"takeEntries");function x6e(e,t=["id","name"],r=["config"]){let n=B7(e,t),i=B7(e,r),s=B7(e,Object.keys(e)).sort(([o],[a])=>o.localeCompare(a));return Object.assign(e,Object.fromEntries([...n,...s,...i]))}l(x6e,"sortKeys");function E6e(e,t){for(let r of Object.keys(e))Reflect.deleteProperty(e,r);return Object.assign(e,t)}l(E6e,"replaceKeys");var H7=class bZ{static{l(this,"Entry")}loader;static key=Symbol.for("cordis.entry");ctx;fiber;parent;options={};subgroup;subtree;_initTask;_disposing=0;constructor(t){this.loader=t,this.ctx=t.ctx.extend({[bZ.key]:this}),this.context.emit("loader/entry-init",this)}get context(){return this.ctx}get id(){let t=this.options.id;return this.parent.tree.ctx.fiber.entry&&(t=this.parent.tree.ctx.fiber.entry.id+L0.sep+t),t}get disabled(){return this._disabled(this.options)}_disabled(t){if(t.group)return!1;if(this.disabledOf(t))return!0;let r=this.parent.ctx.fiber.entry;for(;r;){if(this.disabledOf(r.options))return!0;r=r.parent.ctx.fiber.entry}return!1}disabledOf(t){return M0(t.disabled)?!!this.evaluate(t.disabled.__jsExpr):!!t.disabled}evaluate(t){return wZ(this.ctx,t)}async _patchContext(t){await this.context.waterfall("loader/patch-context",this,async()=>{Object.setPrototypeOf(this.ctx,this.parent.ctx),this.fiber?.uid&&(t.includes("config")||this.options.group)&&await this.fiber.update(this.options.config,!0)})}async refresh(){this.fiber||this.disabled||await this.init()}async _dispose(t=this.fiber){if(t){this.fiber===t&&(this.fiber=void 0),this._disposing+=1;try{await t.dispose()}finally{this._disposing-=1}}}async update(t,r=!1,n=!1){let i=this.options,s={...i},o=r?t:{...i};if(!r)for(let[p,h]of Object.entries(t))Ar(h)?delete o[p]:o[p]=h;x6e(o);let a=Object.keys({...o,...s}).filter(p=>!Ao(o[p],s[p]));if(!a.length&&!n)return;let c=l(()=>{r||(this.options=E6e(i,o))},"commit"),u=this.fiber;if(!u?.uid){this.fiber=void 0,this.options=o;try{this._disabled(o)||await this.init()}catch(p){throw this.options=i,p}c();return}if(this._disabled(o)){this.options=o;try{await this._dispose(u)}catch(p){throw this.options=i,zs("dispose",o,p)}c(),this.context.emit("loader/partial-dispose",this,s,!0);return}if(!a.some(p=>p==="name"||p==="inject"||p==="group")){this.options=o;try{await this._patchContext(a)}catch(p){this.options=i;try{await this._patchContext(a)}catch(h){throw zs("rollback",s,new AggregateError([p,h]))}throw this.context.emit("loader/partial-dispose",this,o,!0),zs("apply",o,p)}c(),this.context.emit("loader/partial-dispose",this,s,!0);return}let d;try{d=a.includes("name")?this.loader.unwrapExports(await this.parent.tree.import(o.name,this.getOuterStack)):u.runtime.callback}catch(p){throw zs("import",o,p)}let f=u.runtime.callback;this.options=o;try{await this._dispose(u)}catch(p){throw this.options=i,zs("dispose",o,p)}try{await this._start(d)}catch(p){this.options=i;try{await this._start(f)}catch(h){throw zs("rollback",s,new AggregateError([p,h]))}throw this.context.emit("loader/partial-dispose",this,o,!0),zs("apply",o,p)}c(),this.context.emit("loader/partial-dispose",this,s,!0)}getOuterStack=l(()=>{let t=this,r=[];do r.push(` at ${t.parent.tree.ctx.baseUrl}#${t.options.id}`),t=t.parent.ctx.fiber.entry;while(t);return r},"getOuterStack");async init(){try{await(this._initTask??=this._init())}finally{this._initTask=void 0,this.loader.getTasks().length||this.ctx.reflect.notify(["loader"])}await this._await()}async _await(){try{await this.fiber?.await()}catch(t){throw zs("apply",this.options,t)}}async _init(){let t;try{t=this.loader.unwrapExports(await this.parent.tree.import(this.options.name,this.getOuterStack))}catch(r){throw zs("import",this.options,r)}try{await this._start(t)}catch(r){throw zs("apply",this.options,r)}}async _start(t){let r;try{await this._patchContext([]),this.loader.showLog(this,"apply"),r=this.fiber=this.ctx.registry.plugin(t,this.options.config,this.getOuterStack),await r.await()}catch(n){throw await this._dispose(r),n}}};function yZ(e,t){for(let r of Reflect.ownKeys(e))Reflect.deleteProperty(e,r);for(let r of Reflect.ownKeys(t||{}))Reflect.defineProperty(e,r,Reflect.getOwnPropertyDescriptor(t,r))}l(yZ,"swap");var xZ=class{static{l(this,"Realm")}store=Object.create(null);access(e,t=!1){return t?this.store[e]??=Symbol(`${e}${this.suffix}`):this.store[e]??Symbol(`${e}${this.suffix}`)}delete(e){delete this.store[e]}get size(){return Object.keys(this.store).length}},S6e=class extends xZ{static{l(this,"LocalRealm")}entry;constructor(e){super(),this.entry=e}get suffix(){return"#"+this.entry.options.id}},k6e=class extends xZ{static{l(this,"GlobalRealm")}label;constructor(e){super(),this.label=e}get suffix(){return"@"+this.label}};function A6e(e){let t=Object.create(null),r=Object.create(null);function n(i,s,o=!1){let a,c=i.options.isolate?.[s];if(c)return c===!0?a=i.realm??=new S6e(i):o?a=t[c]??=new k6e(c):a=t[c],a?.access(s,o)}l(n,"access"),e.on("loader/entry-init",i=>{i.ctx[ur.intercept]=Object.create(i.ctx[ur.intercept]),i.ctx[ur.isolate]=Object.create(i.ctx[ur.isolate])}),e.on("loader/patch-context",async(i,s)=>{let o=Object.create(i.parent.ctx[ur.isolate]);for(let u of Object.keys(i.options.isolate??{}))o[u]=n(i,u,!0);let a=Object.create(null),c=i.ctx[ur.isolate];for(let u in{...o,...r}){if(o[u]===c[u])continue;let d=r[u]??=Symbol(`delim:${u}`);i.ctx[d]=Symbol(`${u}#${i.id}`);for(let f of[c[u],o[u]]){let p=f&&i.ctx.reflect.store[f];if(p){if(!p.fiber){i.ctx.logger.warn(new Error(`expected service ${u} to be implemented`));continue}if(a[u]=[c[u],o[u],i.ctx[d],p.fiber.ctx[d]],i.ctx[d]!==p.fiber.ctx[d])break}}}Object.setPrototypeOf(i.ctx[ur.isolate],i.parent.ctx[ur.isolate]),Object.setPrototypeOf(i.ctx[ur.intercept],i.parent.ctx[ur.intercept]),yZ(i.ctx[ur.isolate],o),yZ(i.ctx[ur.intercept],i.options.intercept),await s();for(let[u,d,f,p]of Object.values(a))f===p&&i.ctx.reflect.store[u]&&!i.ctx.reflect.store[d]&&(i.ctx.reflect.store[d]=i.ctx.reflect.store[u],delete i.ctx.reflect.store[u]);e.reflect.notify(Object.keys(a),(u,d)=>{let[f,p,h,m]=a[d],g=u[ur.isolate][d],y=u[r[d]];return(f===g||p===g)&&h===y!=(h===m)});for(let u in r)Reflect.ownKeys(o).includes(u)||delete i.ctx[r[u]]}),e.on("loader/partial-dispose",(i,s,o)=>{for(let[a,c]of Object.entries(s.isolate??{})){if(c===!0||o&&i.options.isolate?.[a]===c)continue;let u=t[c];if(u){for(let d of e.loader.entries())if(d.options.isolate?.[a]===u.label)return;u.delete(a),u.size||delete t[u.label]}}})}l(A6e,"isolate");var BMe=class extends L0{static{l(this,"Loader")}config;envData=process.env.CORDIS_SHARED?JSON.parse(process.env.CORDIS_SHARED):{startTime:Date.now()};name="loader";internal=W7.fromInternal();builtins=Object.create(null);constructor(e,t={}){super(e),this.config=t,t.baseUrl&&(this.ctx.baseUrl=t.baseUrl);let r=this;yi(this,ut.tracker,{associate:"loader",property:"ctx",noShadow:!0}),e.reflect.provide("loader",this,this[ut.check]),e.on("internal/config",function(n,i){let s=i();return!this.entry||this.parent.fiber?.entry===this.entry||this.runtime?.callback?.[pu.key]?s:q7(this.ctx,s)},{global:!0}),e.on("internal/update",async function(n,i,s){if(!this.entry||i||this.parent.fiber?.entry===this.entry)return s();await s();let o=this.runtime?.Config?.simplify;this.entry.options.config=o?o(n):n,this.entry.parent.tree.write()},{global:!0,prepend:!0}),e.on("internal/update",function(n,i,s){return!this.entry||this.parent.fiber?.entry===this.entry||r.showLog(this.entry,"reload"),s()},{global:!0}),e.on("internal/plugin",n=>{if(n.parent[H7.key]&&!n.entry&&(n.entry=n.parent[H7.key],Mu.resolve(n.entry.options.inject,n.inject)),n.uid||!n.entry||n.parent.fiber?.entry===n.entry||!e.registry.has(n.runtime.callback))return;let i=n.entry.parent.tree.ctx.fiber;!i.uid||i.state===5||n.entry._disposing||(this.showLog(n.entry,"unload"),!n.entry.disabled&&(n.entry.options.disabled=!0,n.entry.parent.tree.write()))}),e.plugin(A6e)}write(){}[ut.check](){return!(ut.prototype[ut.resolveConfig].call(this).await&&this.getTasks().length)}showLog(e,t){e.options.group||!e.parent.tree.enableLogs||this.ctx.root.logger?.("loader").info("%s plugin %C",t,e.options.name)}locate(e=this.ctx.fiber){for(;;){if(e.entry)return e.entry.id;let t=e.parent.fiber;if(e===t)return;e=t}}exit(){}unwrapExports(e){return Ar(e)||(e=e.default??e,!e.__esModule)?e:e.default??e}};import{extname as I6e}from"node:path";import{access as $6e,constants as _6e,readFile as T6e,rename as C6e,writeFile as O6e}from"node:fs/promises";import{setTimeout as N6e}from"node:timers/promises";import{fileURLToPath as R6e,pathToFileURL as P6e}from"node:url";var D6e=l(function(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,i,s,o){return n?t?".jsx":".js":i&&(!s||!o)?r:i+s+"."+o.toLowerCase()+"js"}):e},"__rewriteRelativeImportExtension"),L6e=new pZ("tag:yaml.org,2002:js",{kind:"scalar",resolve:l(e=>typeof e=="string","resolve"),construct:l(e=>({__jsExpr:e}),"construct"),predicate:M0,represent:l(e=>e.__jsExpr,"represent")}),G7=hZ.extend(L6e),EZ=G7,SZ={".json":"application/json",".yaml":"application/yaml",".yml":"application/yaml"},M6e=new Set(Object.keys(SZ)),F6e=10,U6e=50;function j6e(e){let t=e?.code;return t==="EACCES"||t==="EBUSY"||t==="EPERM"}l(j6e,"retryableWriteError");function z6e(e,t,r){if(e=structuredClone(e),!t?.length)return e;let n=new Map,i=l(s=>{for(let o of s)o.id&&n.set(o.id,o),o.group&&Array.isArray(o.config)&&i(o.config)},"buildMap");i(e);for(let s of t){let{id:o,insert:a,name:c,...u}=s;if(a){if(o){let f=n.get(o);if(!f){r("patch insert: entry %C not found",o);continue}if(!f.group){r("patch insert: entry %C is not a group",o);continue}Array.isArray(f.config)||(f.config=[]),f.config.push(...a)}else e.push(...a);i(a);continue}if(!o){r("patch: id is required for non-insert patches");continue}let d=n.get(o);if(!d){r("patch: entry %C not found",o);continue}if(c&&c!==d.name){r("patch: name mismatch for %C (expected %C, got %C), skipping",o,d.name,c);continue}for(let[f,p]of Object.entries(u))f!=="id"&&(d[f]=p)}return e}l(z6e,"applyEntryPatches");var F0=class extends Error{static{l(this,"ConfigFileError")}stage;constructor(e,t,r){super(`failed to ${e} config file ${t}`,{cause:r}),this.stage=e,this.name="ConfigFileError"}},kZ=class extends L0{static{l(this,"Include")}config;static inject=["loader"];static[pu.key]=!0;filename;type;readonly;content;data;writeTask;pendingWrite;writeQueue=Promise.resolve();applyQueue=Promise.resolve();constructor(e,t){super(e),this.config=t,this.enableLogs=t.enableLogs??e.fiber.entry?.parent.tree.enableLogs??!1,this.filename=R6e(new URL(this.config.path,this.ctx.baseUrl));let r=I6e(this.filename);if(!M6e.has(r))throw new Error(`extension "${r}" not supported`);this.type=SZ[r],this.readonly=!this.type,this.ctx.baseUrl=new URL(".",P6e(this.filename)).href,e.on("internal/update",async(n,i,s)=>{if(n.path!==this.config.path)return s();await this.enqueue(async()=>{let o=this.applyPatches(this.data,n.patches);await this.root.update(o),this.config=n})})}enqueue(e){let t=this.applyQueue.then(e,e);return this.applyQueue=t.then(()=>{},()=>{}),t}async checkAccess(){if(this.type)try{await $6e(this.filename,_6e.W_OK)}catch{this.readonly=!0}}async read(e=!1){let t;try{t=await T6e(this.filename,"utf8")}catch(n){throw new F0("read",this.filename,n)}if(!e&&this.content===t)return;let r;try{if(this.type==="application/yaml")r=D0(t,{schema:EZ});else if(this.type==="application/json")r=JSON.parse(t);else{let n=await import(D6e(this.filename));r=n.default||n}}catch(n){throw new F0("parse",this.filename,n)}if(!Array.isArray(r))throw new F0("validate",this.filename,new TypeError("config file must be a top-level array"));return{content:t,data:r}}applyPatches(e,t){return z6e(e,t,(r,...n)=>{this.ctx.root.logger?.("loader").warn(r,...n)})}async*[ut.init](){let e;try{e=await this.read(!0)}catch(t){if(!(t instanceof F0)||t.stage!=="read"||t.cause?.code!=="ENOENT")throw t;if(this.config.initial)await this._writeFile(this.config.initial),e=await this.read(!0);else throw new Error(`config file not found: ${this.filename}`)}yield()=>this.stop(),await this.apply(e)}async stop(){await this.root.stop(),await this.flushWrite()}async refresh(){await this.enqueue(async()=>{let e=await this.read();e&&await this._apply(e)})}apply(e){return this.enqueue(()=>this._apply(e))}async _apply(e){let t=this.applyPatches(e.data,this.config.patches);await this.root.update(t),this.content=e.content,this.data=e.data,await this.checkAccess()}async _writeFile(e){if(this.readonly)throw new Error("cannot overwrite readonly config");this.type==="application/yaml"?this.content=mZ(e,{schema:EZ}):this.type==="application/json"&&(this.content=JSON.stringify(e,null,2)),await O6e(this.filename+".tmp",this.content);for(let t=0;;t++)try{await C6e(this.filename+".tmp",this.filename);return}catch(r){if(!j6e(r)||t>=F6e)throw r;await N6e((t+1)*U6e)}}writeFile(e){clearTimeout(this.writeTask),this.pendingWrite=e,this.writeTask=setTimeout(()=>{this.flushWrite()},0)}flushWrite(){clearTimeout(this.writeTask),this.writeTask=void 0;let e=this.pendingWrite;if(this.pendingWrite=void 0,e===void 0)return this.writeQueue;let t=this.writeQueue.then(()=>this._writeFile(e),()=>this._writeFile(e));return this.writeQueue=t,t.catch(r=>{this.ctx.root.logger?.("loader").warn("failed to write config file %C",this.filename),this.ctx.root.logger?.("loader").warn(r)}),t}write(){return this.context.emit("loader/config-update"),this.writeFile(this.root.data)}};import{randomBytes as B6e}from"node:crypto";import{lstat as cFe,mkdir as W6e,rename as q6e,rm as H6e,writeFile as G6e}from"node:fs/promises";import{dirname as V6e}from"node:path";async function AZ(e,t,r){await W6e(V6e(e),{recursive:!0,...r.dirMode===void 0?{}:{mode:r.dirMode}});let n=`${e}.${B6e(6).toString("hex")}.tmp`;try{await G6e(n,t,{mode:r.mode,flag:"wx"}),await q6e(n,e)}catch(i){throw await H6e(n,{force:!0}),i}}l(AZ,"writeFileAtomic");import{pathToFileURL as NZ}from"node:url";var RZ="preset.yml";function U0(e){if(typeof e!="string")return;let t=e.trim();return t===""?void 0:t}l(U0,"text");async function Y6e(e){let t;try{t=await Y7(kl(e,RZ),"utf8")}catch{return{}}let r;try{r=P0.load(t)}catch{return{}}if(typeof r!="object"||r===null||Array.isArray(r))return{};let n=r,i=U0(n.name),s=U0(n.description),o=typeof n.order=="number"&&Number.isFinite(n.order)?n.order:void 0;return{...i===void 0?{}:{name:i},...s===void 0?{}:{description:s},...o===void 0?{}:{order:o}}}l(Y6e,"readPresetMetadata");function X6e(e){let t=U0(e.name),r=U0(e.description),{order:n}=e;if(!(t===void 0&&r===void 0&&n===void 0))return P0.dump({...t===void 0?{}:{name:t},...r===void 0?{}:{description:r},...n===void 0?{}:{order:n}},{lineWidth:-1})}l(X6e,"renderPresetMetadata");var X7=/^[a-z0-9][a-z0-9-]*$/,B0=class extends Error{static{l(this,"UnknownPresetError")}presetId;available;constructor(e,t){super(`agent-presets: preset "${e}" not found (available: ${t.join(", ")||"none"})`),this.presetId=e,this.available=t}},ap=class extends Error{static{l(this,"PresetMountError")}presetId;reason;constructor(e,t,r){super(`agent-presets: preset "${e}" failed to mount: ${t}`,r),this.presetId=e,this.reason=t}},Z7="agent.cordis.yml",J6e=".agent-presets";function PZ(e,t=""){if(!Array.isArray(e))return t===""?"the composition must be a top-level list of plugin rows":`group ${t} must hold a list of plugin rows`;for(let[r,n]of e.entries()){let i=t===""?`row ${String(r+1)}`:`${t} row ${String(r+1)}`;if(typeof n!="object"||n===null||Array.isArray(n))return`${i} is not a plugin row (expected a map with a "name")`;let{name:s,group:o,config:a}=n;if(typeof s!="string"||s==="")return`${i} names no plugin (a "name" string is required)`;if(o===!0){let c=PZ(a,i);if(c!==void 0)return c}}}l(PZ,"entryListProblem");async function Q6e(e){let t;try{t=await Y7(e,"utf8")}catch{return`the composition file ${Z7} cannot be read`}let r;try{r=D0(t,{schema:G7})}catch(n){return`the composition is not valid YAML: ${(n instanceof Error?n.message:String(n)).replace(/\n[\s\S]*$/,"")}`}return PZ(r)}l(Q6e,"compositionProblem");async function eke(e){try{return(await z0(e)).isFile()}catch{return!1}}l(eke,"isFile");async function tke(e){let t=OZ(Bm(e.path)),r;try{r=await TZ(t,{withFileTypes:!0})}catch(i){if(i.code==="ENOENT")return[];throw new Error(`agent-presets: cannot read preset root ${t}: ${String(i)}`,{cause:i})}let n=[];for(let i of r){if(!i.isDirectory()||!X7.test(i.name))continue;let s=kl(t,i.name),o=kl(s,Z7),a=await eke(o)?await Q6e(o):`the composition file ${Z7} is missing \u2014 the directory still occupies the id; delete it or restore the file`,c=await Y6e(s);n.push({id:i.name,trust:e.trust,path:o,...c,...a===void 0?{}:{broken:a}})}return n.sort((i,s)=>{let o=(i.order??Number.POSITIVE_INFINITY)-(s.order??Number.POSITIVE_INFINITY);return o===0?i.id.localeCompare(s.id):o})}l(tke,"scanRoot");async function rke(e){let t=new Map;for(let r of e)for(let n of await tke(r))t.has(n.id)||t.set(n.id,n);return[...t.values()]}l(rke,"discoverPresets");var J7=class extends Error{static{l(this,"InvalidPresetIdError")}presetId;constructor(e){super(`agent-presets: preset id ${JSON.stringify(e)} must match ${String(X7)} \u2014 the id is a directory name, so anything else could escape the preset root`),this.presetId=e}},W0=class extends Error{static{l(this,"PresetExistsError")}presetId;constructor(e){super(`agent-presets: preset "${e}" already exists \u2014 a copy never overwrites; delete the existing preset first or choose another id`),this.presetId=e}},hu=class extends Error{static{l(this,"PresetNotWritableError")}presetId;constructor(e,t){super(`agent-presets: preset "${e}" cannot be written: ${t}`),this.presetId=e}};function DZ(e){let t=e.find(r=>r.trust==="user");if(t===void 0)throw new hu("","this deployment configures no user-writable preset root");return OZ(Bm(t.path))}l(DZ,"writableRoot");async function nke(e){return await Y7(e.path,"utf8")}l(nke,"readComposition");async function ike(e){let t=!0;try{await z0(e)}catch{t=!1}return t}l(ike,"occupied");async function LZ(e){await IZ(e,448);for(let t of await TZ(e,{withFileTypes:!0})){let r=kl(e,t.name);t.isDirectory()?await LZ(r):await IZ(r,((await z0(r)).mode&64)===0?384:448)}}l(LZ,"tightenModes");async function ske(e,t,r,n){if(!X7.test(r))throw new J7(r);let i=kl(DZ(e),r);if(await ike(i))throw new W0(r);try{await Z6e(K6e(t.path),i,{recursive:!0,dereference:!0,force:!1,errorOnExist:!0}),await LZ(i);let s=X6e({...n===void 0?{}:{name:n},...t.description===void 0?{}:{description:t.description}}),o=kl(i,RZ);s===void 0?await V7(o,{force:!0}):await AZ(o,s,{mode:384,dirMode:448})}catch(s){throw await V7(i,{recursive:!0,force:!0}),s}return i}l(ske,"copyComposition");async function oke(e,t){if(t.trust!=="user")throw new hu(t.id,"it ships with the deployment");let r=kl(DZ(e),t.id);if(!CZ(t.path)||!t.path.startsWith(r))throw new hu(t.id,"it does not live under the writable preset root");await V7(r,{recursive:!0,force:!0})}l(oke,"deleteComposition");var MZ=new WeakMap,FZ=new WeakMap,ake=class extends kZ{static{l(this,"PresetTree")}constructor(e,t){super(e,t),MZ.set(t,{tree:this,fiber:e.fiber})}import(e,t){let r=CZ(e)?NZ(e).href:e,n=FZ.get(this.config);if(n===void 0)return super.import(r,t);if(e.startsWith(".")||e.startsWith("cordis:"))return super.import(e,t);let i=this.ctx.loader.internal;return i===void 0?super.import(r,t):i.import(r,n,{})}write(){}},j0=new Set;function UZ(){for(let e of j0)e.fiber.uid===null&&j0.delete(e)}l(UZ,"pruneDisposedMounts");function lke(){return UZ(),[...j0]}l(lke,"livePresetMounts");function jZ(e,t){let r=e;for(;;){if(r===t)return!0;let n=r.parent.fiber;if(n===r)return!1;r=n}}l(jZ,"withinFiber");function cke(e,t){let r=e.reflect.store,n=e.root[ur.isolate],i=[];for(let s of Object.getOwnPropertySymbols(r)){let o=r[s];o!==void 0&&jZ(o.fiber,t)&&n[o.name]===s&&i.push(o.name)}return i.sort((s,o)=>s.localeCompare(o))}l(cke,"leakedServices");function K7(e){let t=pn(e);if(t===void 0)return;let r=I_(t);if(r!==void 0)return lke().find(n=>n.key===r)}l(K7,"standingMountFor");function uke(e,t,r){let n=K7(t.ctx);if(n===void 0)return;let i=e.reflect.store;for(let s of Object.getOwnPropertySymbols(i)){let o=i[s];if(o!==void 0&&o.name===r&&jZ(o.fiber,n.fiber))return o.value}}l(uke,"serviceForAgent");function dke(e){let t=[];for(let r of e.entries()){if(r.disabled)continue;let n=r.fiber;if(n===void 0){t.push(`${r.options.id} (${r.options.name}): never started`);continue}let i=Object.keys(n.inject).filter(s=>n.ctx.get(s)===void 0);i.length>0&&t.push(`${r.options.id} (${r.options.name}): waiting for ${i.join(", ")}`)}return t}l(dke,"inactiveRows");function zZ(e){return e instanceof Error?e instanceof AggregateError?[e.message,...e.errors.map(t=>`- ${zZ(t)}`)].join(`
|
|
2341
|
+
`);function q7(e,t){return M0(t)?wZ(e,t.__jsExpr):!t||typeof t!="object"?t:Array.isArray(t)?t.map(r=>q7(e,r)):qi(t,r=>q7(e,r))}l(q7,"interpolate");function M0(e){return e instanceof Object&&"__jsExpr"in e}l(M0,"isJsExpr");function zs(e,t,r){let n=r instanceof Error?r.message:String(r);return new Error(`failed to ${e} loader entry ${t.id} (${t.name}): ${n}`,{cause:r})}l(zs,"updateError");function B7(e,t){let r=[];for(let n of t)n in e&&(r.push([n,e[n]]),delete e[n]);return r}l(B7,"takeEntries");function x6e(e,t=["id","name"],r=["config"]){let n=B7(e,t),i=B7(e,r),s=B7(e,Object.keys(e)).sort(([o],[a])=>o.localeCompare(a));return Object.assign(e,Object.fromEntries([...n,...s,...i]))}l(x6e,"sortKeys");function E6e(e,t){for(let r of Object.keys(e))Reflect.deleteProperty(e,r);return Object.assign(e,t)}l(E6e,"replaceKeys");var H7=class bZ{static{l(this,"Entry")}loader;static key=Symbol.for("cordis.entry");ctx;fiber;parent;options={};subgroup;subtree;_initTask;_disposing=0;constructor(t){this.loader=t,this.ctx=t.ctx.extend({[bZ.key]:this}),this.context.emit("loader/entry-init",this)}get context(){return this.ctx}get id(){let t=this.options.id;return this.parent.tree.ctx.fiber.entry&&(t=this.parent.tree.ctx.fiber.entry.id+L0.sep+t),t}get disabled(){return this._disabled(this.options)}_disabled(t){if(t.group)return!1;if(this.disabledOf(t))return!0;let r=this.parent.ctx.fiber.entry;for(;r;){if(this.disabledOf(r.options))return!0;r=r.parent.ctx.fiber.entry}return!1}disabledOf(t){return M0(t.disabled)?!!this.evaluate(t.disabled.__jsExpr):!!t.disabled}evaluate(t){return wZ(this.ctx,t)}async _patchContext(t){await this.context.waterfall("loader/patch-context",this,async()=>{Object.setPrototypeOf(this.ctx,this.parent.ctx),this.fiber?.uid&&(t.includes("config")||this.options.group)&&await this.fiber.update(this.options.config,!0)})}async refresh(){this.fiber||this.disabled||await this.init()}async _dispose(t=this.fiber){if(t){this.fiber===t&&(this.fiber=void 0),this._disposing+=1;try{await t.dispose()}finally{this._disposing-=1}}}async update(t,r=!1,n=!1){let i=this.options,s={...i},o=r?t:{...i};if(!r)for(let[p,h]of Object.entries(t))Ar(h)?delete o[p]:o[p]=h;x6e(o);let a=Object.keys({...o,...s}).filter(p=>!Ao(o[p],s[p]));if(!a.length&&!n)return;let c=l(()=>{r||(this.options=E6e(i,o))},"commit"),u=this.fiber;if(!u?.uid){this.fiber=void 0,this.options=o;try{this._disabled(o)||await this.init()}catch(p){throw this.options=i,p}c();return}if(this._disabled(o)){this.options=o;try{await this._dispose(u)}catch(p){throw this.options=i,zs("dispose",o,p)}c(),this.context.emit("loader/partial-dispose",this,s,!0);return}if(!a.some(p=>p==="name"||p==="inject"||p==="group")){this.options=o;try{await this._patchContext(a)}catch(p){this.options=i;try{await this._patchContext(a)}catch(h){throw zs("rollback",s,new AggregateError([p,h]))}throw this.context.emit("loader/partial-dispose",this,o,!0),zs("apply",o,p)}c(),this.context.emit("loader/partial-dispose",this,s,!0);return}let d;try{d=a.includes("name")?this.loader.unwrapExports(await this.parent.tree.import(o.name,this.getOuterStack)):u.runtime.callback}catch(p){throw zs("import",o,p)}let f=u.runtime.callback;this.options=o;try{await this._dispose(u)}catch(p){throw this.options=i,zs("dispose",o,p)}try{await this._start(d)}catch(p){this.options=i;try{await this._start(f)}catch(h){throw zs("rollback",s,new AggregateError([p,h]))}throw this.context.emit("loader/partial-dispose",this,o,!0),zs("apply",o,p)}c(),this.context.emit("loader/partial-dispose",this,s,!0)}getOuterStack=l(()=>{let t=this,r=[];do r.push(` at ${t.parent.tree.ctx.baseUrl}#${t.options.id}`),t=t.parent.ctx.fiber.entry;while(t);return r},"getOuterStack");async init(){try{await(this._initTask??=this._init())}finally{this._initTask=void 0,this.loader.getTasks().length||this.ctx.reflect.notify(["loader"])}await this._await()}async _await(){try{await this.fiber?.await()}catch(t){throw zs("apply",this.options,t)}}async _init(){let t;try{t=this.loader.unwrapExports(await this.parent.tree.import(this.options.name,this.getOuterStack))}catch(r){throw zs("import",this.options,r)}try{await this._start(t)}catch(r){throw zs("apply",this.options,r)}}async _start(t){let r;try{await this._patchContext([]),this.loader.showLog(this,"apply"),r=this.fiber=this.ctx.registry.plugin(t,this.options.config,this.getOuterStack),await r.await()}catch(n){throw await this._dispose(r),n}}};function yZ(e,t){for(let r of Reflect.ownKeys(e))Reflect.deleteProperty(e,r);for(let r of Reflect.ownKeys(t||{}))Reflect.defineProperty(e,r,Reflect.getOwnPropertyDescriptor(t,r))}l(yZ,"swap");var xZ=class{static{l(this,"Realm")}store=Object.create(null);access(e,t=!1){return t?this.store[e]??=Symbol(`${e}${this.suffix}`):this.store[e]??Symbol(`${e}${this.suffix}`)}delete(e){delete this.store[e]}get size(){return Object.keys(this.store).length}},S6e=class extends xZ{static{l(this,"LocalRealm")}entry;constructor(e){super(),this.entry=e}get suffix(){return"#"+this.entry.options.id}},k6e=class extends xZ{static{l(this,"GlobalRealm")}label;constructor(e){super(),this.label=e}get suffix(){return"@"+this.label}};function A6e(e){let t=Object.create(null),r=Object.create(null);function n(i,s,o=!1){let a,c=i.options.isolate?.[s];if(c)return c===!0?a=i.realm??=new S6e(i):o?a=t[c]??=new k6e(c):a=t[c],a?.access(s,o)}l(n,"access"),e.on("loader/entry-init",i=>{i.ctx[ur.intercept]=Object.create(i.ctx[ur.intercept]),i.ctx[ur.isolate]=Object.create(i.ctx[ur.isolate])}),e.on("loader/patch-context",async(i,s)=>{let o=Object.create(i.parent.ctx[ur.isolate]);for(let u of Object.keys(i.options.isolate??{}))o[u]=n(i,u,!0);let a=Object.create(null),c=i.ctx[ur.isolate];for(let u in{...o,...r}){if(o[u]===c[u])continue;let d=r[u]??=Symbol(`delim:${u}`);i.ctx[d]=Symbol(`${u}#${i.id}`);for(let f of[c[u],o[u]]){let p=f&&i.ctx.reflect.store[f];if(p){if(!p.fiber){i.ctx.logger.warn(new Error(`expected service ${u} to be implemented`));continue}if(a[u]=[c[u],o[u],i.ctx[d],p.fiber.ctx[d]],i.ctx[d]!==p.fiber.ctx[d])break}}}Object.setPrototypeOf(i.ctx[ur.isolate],i.parent.ctx[ur.isolate]),Object.setPrototypeOf(i.ctx[ur.intercept],i.parent.ctx[ur.intercept]),yZ(i.ctx[ur.isolate],o),yZ(i.ctx[ur.intercept],i.options.intercept),await s();for(let[u,d,f,p]of Object.values(a))f===p&&i.ctx.reflect.store[u]&&!i.ctx.reflect.store[d]&&(i.ctx.reflect.store[d]=i.ctx.reflect.store[u],delete i.ctx.reflect.store[u]);e.reflect.notify(Object.keys(a),(u,d)=>{let[f,p,h,m]=a[d],g=u[ur.isolate][d],y=u[r[d]];return(f===g||p===g)&&h===y!=(h===m)});for(let u in r)Reflect.ownKeys(o).includes(u)||delete i.ctx[r[u]]}),e.on("loader/partial-dispose",(i,s,o)=>{for(let[a,c]of Object.entries(s.isolate??{})){if(c===!0||o&&i.options.isolate?.[a]===c)continue;let u=t[c];if(u){for(let d of e.loader.entries())if(d.options.isolate?.[a]===u.label)return;u.delete(a),u.size||delete t[u.label]}}})}l(A6e,"isolate");var WMe=class extends L0{static{l(this,"Loader")}config;envData=process.env.CORDIS_SHARED?JSON.parse(process.env.CORDIS_SHARED):{startTime:Date.now()};name="loader";internal=W7.fromInternal();builtins=Object.create(null);constructor(e,t={}){super(e),this.config=t,t.baseUrl&&(this.ctx.baseUrl=t.baseUrl);let r=this;yi(this,ut.tracker,{associate:"loader",property:"ctx",noShadow:!0}),e.reflect.provide("loader",this,this[ut.check]),e.on("internal/config",function(n,i){let s=i();return!this.entry||this.parent.fiber?.entry===this.entry||this.runtime?.callback?.[pu.key]?s:q7(this.ctx,s)},{global:!0}),e.on("internal/update",async function(n,i,s){if(!this.entry||i||this.parent.fiber?.entry===this.entry)return s();await s();let o=this.runtime?.Config?.simplify;this.entry.options.config=o?o(n):n,this.entry.parent.tree.write()},{global:!0,prepend:!0}),e.on("internal/update",function(n,i,s){return!this.entry||this.parent.fiber?.entry===this.entry||r.showLog(this.entry,"reload"),s()},{global:!0}),e.on("internal/plugin",n=>{if(n.parent[H7.key]&&!n.entry&&(n.entry=n.parent[H7.key],Mu.resolve(n.entry.options.inject,n.inject)),n.uid||!n.entry||n.parent.fiber?.entry===n.entry||!e.registry.has(n.runtime.callback))return;let i=n.entry.parent.tree.ctx.fiber;!i.uid||i.state===5||n.entry._disposing||(this.showLog(n.entry,"unload"),!n.entry.disabled&&(n.entry.options.disabled=!0,n.entry.parent.tree.write()))}),e.plugin(A6e)}write(){}[ut.check](){return!(ut.prototype[ut.resolveConfig].call(this).await&&this.getTasks().length)}showLog(e,t){e.options.group||!e.parent.tree.enableLogs||this.ctx.root.logger?.("loader").info("%s plugin %C",t,e.options.name)}locate(e=this.ctx.fiber){for(;;){if(e.entry)return e.entry.id;let t=e.parent.fiber;if(e===t)return;e=t}}exit(){}unwrapExports(e){return Ar(e)||(e=e.default??e,!e.__esModule)?e:e.default??e}};import{extname as I6e}from"node:path";import{access as $6e,constants as _6e,readFile as T6e,rename as C6e,writeFile as O6e}from"node:fs/promises";import{setTimeout as N6e}from"node:timers/promises";import{fileURLToPath as R6e,pathToFileURL as P6e}from"node:url";var D6e=l(function(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,i,s,o){return n?t?".jsx":".js":i&&(!s||!o)?r:i+s+"."+o.toLowerCase()+"js"}):e},"__rewriteRelativeImportExtension"),L6e=new pZ("tag:yaml.org,2002:js",{kind:"scalar",resolve:l(e=>typeof e=="string","resolve"),construct:l(e=>({__jsExpr:e}),"construct"),predicate:M0,represent:l(e=>e.__jsExpr,"represent")}),G7=hZ.extend(L6e),EZ=G7,SZ={".json":"application/json",".yaml":"application/yaml",".yml":"application/yaml"},M6e=new Set(Object.keys(SZ)),F6e=10,U6e=50;function j6e(e){let t=e?.code;return t==="EACCES"||t==="EBUSY"||t==="EPERM"}l(j6e,"retryableWriteError");function z6e(e,t,r){if(e=structuredClone(e),!t?.length)return e;let n=new Map,i=l(s=>{for(let o of s)o.id&&n.set(o.id,o),o.group&&Array.isArray(o.config)&&i(o.config)},"buildMap");i(e);for(let s of t){let{id:o,insert:a,name:c,...u}=s;if(a){if(o){let f=n.get(o);if(!f){r("patch insert: entry %C not found",o);continue}if(!f.group){r("patch insert: entry %C is not a group",o);continue}Array.isArray(f.config)||(f.config=[]),f.config.push(...a)}else e.push(...a);i(a);continue}if(!o){r("patch: id is required for non-insert patches");continue}let d=n.get(o);if(!d){r("patch: entry %C not found",o);continue}if(c&&c!==d.name){r("patch: name mismatch for %C (expected %C, got %C), skipping",o,d.name,c);continue}for(let[f,p]of Object.entries(u))f!=="id"&&(d[f]=p)}return e}l(z6e,"applyEntryPatches");var F0=class extends Error{static{l(this,"ConfigFileError")}stage;constructor(e,t,r){super(`failed to ${e} config file ${t}`,{cause:r}),this.stage=e,this.name="ConfigFileError"}},kZ=class extends L0{static{l(this,"Include")}config;static inject=["loader"];static[pu.key]=!0;filename;type;readonly;content;data;writeTask;pendingWrite;writeQueue=Promise.resolve();applyQueue=Promise.resolve();constructor(e,t){super(e),this.config=t,this.enableLogs=t.enableLogs??e.fiber.entry?.parent.tree.enableLogs??!1,this.filename=R6e(new URL(this.config.path,this.ctx.baseUrl));let r=I6e(this.filename);if(!M6e.has(r))throw new Error(`extension "${r}" not supported`);this.type=SZ[r],this.readonly=!this.type,this.ctx.baseUrl=new URL(".",P6e(this.filename)).href,e.on("internal/update",async(n,i,s)=>{if(n.path!==this.config.path)return s();await this.enqueue(async()=>{let o=this.applyPatches(this.data,n.patches);await this.root.update(o),this.config=n})})}enqueue(e){let t=this.applyQueue.then(e,e);return this.applyQueue=t.then(()=>{},()=>{}),t}async checkAccess(){if(this.type)try{await $6e(this.filename,_6e.W_OK)}catch{this.readonly=!0}}async read(e=!1){let t;try{t=await T6e(this.filename,"utf8")}catch(n){throw new F0("read",this.filename,n)}if(!e&&this.content===t)return;let r;try{if(this.type==="application/yaml")r=D0(t,{schema:EZ});else if(this.type==="application/json")r=JSON.parse(t);else{let n=await import(D6e(this.filename));r=n.default||n}}catch(n){throw new F0("parse",this.filename,n)}if(!Array.isArray(r))throw new F0("validate",this.filename,new TypeError("config file must be a top-level array"));return{content:t,data:r}}applyPatches(e,t){return z6e(e,t,(r,...n)=>{this.ctx.root.logger?.("loader").warn(r,...n)})}async*[ut.init](){let e;try{e=await this.read(!0)}catch(t){if(!(t instanceof F0)||t.stage!=="read"||t.cause?.code!=="ENOENT")throw t;if(this.config.initial)await this._writeFile(this.config.initial),e=await this.read(!0);else throw new Error(`config file not found: ${this.filename}`)}yield()=>this.stop(),await this.apply(e)}async stop(){await this.root.stop(),await this.flushWrite()}async refresh(){await this.enqueue(async()=>{let e=await this.read();e&&await this._apply(e)})}apply(e){return this.enqueue(()=>this._apply(e))}async _apply(e){let t=this.applyPatches(e.data,this.config.patches);await this.root.update(t),this.content=e.content,this.data=e.data,await this.checkAccess()}async _writeFile(e){if(this.readonly)throw new Error("cannot overwrite readonly config");this.type==="application/yaml"?this.content=mZ(e,{schema:EZ}):this.type==="application/json"&&(this.content=JSON.stringify(e,null,2)),await O6e(this.filename+".tmp",this.content);for(let t=0;;t++)try{await C6e(this.filename+".tmp",this.filename);return}catch(r){if(!j6e(r)||t>=F6e)throw r;await N6e((t+1)*U6e)}}writeFile(e){clearTimeout(this.writeTask),this.pendingWrite=e,this.writeTask=setTimeout(()=>{this.flushWrite()},0)}flushWrite(){clearTimeout(this.writeTask),this.writeTask=void 0;let e=this.pendingWrite;if(this.pendingWrite=void 0,e===void 0)return this.writeQueue;let t=this.writeQueue.then(()=>this._writeFile(e),()=>this._writeFile(e));return this.writeQueue=t,t.catch(r=>{this.ctx.root.logger?.("loader").warn("failed to write config file %C",this.filename),this.ctx.root.logger?.("loader").warn(r)}),t}write(){return this.context.emit("loader/config-update"),this.writeFile(this.root.data)}};import{randomBytes as B6e}from"node:crypto";import{lstat as uFe,mkdir as W6e,rename as q6e,rm as H6e,writeFile as G6e}from"node:fs/promises";import{dirname as V6e}from"node:path";async function AZ(e,t,r){await W6e(V6e(e),{recursive:!0,...r.dirMode===void 0?{}:{mode:r.dirMode}});let n=`${e}.${B6e(6).toString("hex")}.tmp`;try{await G6e(n,t,{mode:r.mode,flag:"wx"}),await q6e(n,e)}catch(i){throw await H6e(n,{force:!0}),i}}l(AZ,"writeFileAtomic");import{pathToFileURL as NZ}from"node:url";var RZ="preset.yml";function U0(e){if(typeof e!="string")return;let t=e.trim();return t===""?void 0:t}l(U0,"text");async function Y6e(e){let t;try{t=await Y7(kl(e,RZ),"utf8")}catch{return{}}let r;try{r=P0.load(t)}catch{return{}}if(typeof r!="object"||r===null||Array.isArray(r))return{};let n=r,i=U0(n.name),s=U0(n.description),o=typeof n.order=="number"&&Number.isFinite(n.order)?n.order:void 0;return{...i===void 0?{}:{name:i},...s===void 0?{}:{description:s},...o===void 0?{}:{order:o}}}l(Y6e,"readPresetMetadata");function X6e(e){let t=U0(e.name),r=U0(e.description),{order:n}=e;if(!(t===void 0&&r===void 0&&n===void 0))return P0.dump({...t===void 0?{}:{name:t},...r===void 0?{}:{description:r},...n===void 0?{}:{order:n}},{lineWidth:-1})}l(X6e,"renderPresetMetadata");var X7=/^[a-z0-9][a-z0-9-]*$/,B0=class extends Error{static{l(this,"UnknownPresetError")}presetId;available;constructor(e,t){super(`agent-presets: preset "${e}" not found (available: ${t.join(", ")||"none"})`),this.presetId=e,this.available=t}},ap=class extends Error{static{l(this,"PresetMountError")}presetId;reason;constructor(e,t,r){super(`agent-presets: preset "${e}" failed to mount: ${t}`,r),this.presetId=e,this.reason=t}},Z7="agent.cordis.yml",J6e=".agent-presets";function PZ(e,t=""){if(!Array.isArray(e))return t===""?"the composition must be a top-level list of plugin rows":`group ${t} must hold a list of plugin rows`;for(let[r,n]of e.entries()){let i=t===""?`row ${String(r+1)}`:`${t} row ${String(r+1)}`;if(typeof n!="object"||n===null||Array.isArray(n))return`${i} is not a plugin row (expected a map with a "name")`;let{name:s,group:o,config:a}=n;if(typeof s!="string"||s==="")return`${i} names no plugin (a "name" string is required)`;if(o===!0){let c=PZ(a,i);if(c!==void 0)return c}}}l(PZ,"entryListProblem");async function Q6e(e){let t;try{t=await Y7(e,"utf8")}catch{return`the composition file ${Z7} cannot be read`}let r;try{r=D0(t,{schema:G7})}catch(n){return`the composition is not valid YAML: ${(n instanceof Error?n.message:String(n)).replace(/\n[\s\S]*$/,"")}`}return PZ(r)}l(Q6e,"compositionProblem");async function eke(e){try{return(await z0(e)).isFile()}catch{return!1}}l(eke,"isFile");async function tke(e){let t=OZ(Bm(e.path)),r;try{r=await TZ(t,{withFileTypes:!0})}catch(i){if(i.code==="ENOENT")return[];throw new Error(`agent-presets: cannot read preset root ${t}: ${String(i)}`,{cause:i})}let n=[];for(let i of r){if(!i.isDirectory()||!X7.test(i.name))continue;let s=kl(t,i.name),o=kl(s,Z7),a=await eke(o)?await Q6e(o):`the composition file ${Z7} is missing \u2014 the directory still occupies the id; delete it or restore the file`,c=await Y6e(s);n.push({id:i.name,trust:e.trust,path:o,...c,...a===void 0?{}:{broken:a}})}return n.sort((i,s)=>{let o=(i.order??Number.POSITIVE_INFINITY)-(s.order??Number.POSITIVE_INFINITY);return o===0?i.id.localeCompare(s.id):o})}l(tke,"scanRoot");async function rke(e){let t=new Map;for(let r of e)for(let n of await tke(r))t.has(n.id)||t.set(n.id,n);return[...t.values()]}l(rke,"discoverPresets");var J7=class extends Error{static{l(this,"InvalidPresetIdError")}presetId;constructor(e){super(`agent-presets: preset id ${JSON.stringify(e)} must match ${String(X7)} \u2014 the id is a directory name, so anything else could escape the preset root`),this.presetId=e}},W0=class extends Error{static{l(this,"PresetExistsError")}presetId;constructor(e){super(`agent-presets: preset "${e}" already exists \u2014 a copy never overwrites; delete the existing preset first or choose another id`),this.presetId=e}},hu=class extends Error{static{l(this,"PresetNotWritableError")}presetId;constructor(e,t){super(`agent-presets: preset "${e}" cannot be written: ${t}`),this.presetId=e}};function DZ(e){let t=e.find(r=>r.trust==="user");if(t===void 0)throw new hu("","this deployment configures no user-writable preset root");return OZ(Bm(t.path))}l(DZ,"writableRoot");async function nke(e){return await Y7(e.path,"utf8")}l(nke,"readComposition");async function ike(e){let t=!0;try{await z0(e)}catch{t=!1}return t}l(ike,"occupied");async function LZ(e){await IZ(e,448);for(let t of await TZ(e,{withFileTypes:!0})){let r=kl(e,t.name);t.isDirectory()?await LZ(r):await IZ(r,((await z0(r)).mode&64)===0?384:448)}}l(LZ,"tightenModes");async function ske(e,t,r,n){if(!X7.test(r))throw new J7(r);let i=kl(DZ(e),r);if(await ike(i))throw new W0(r);try{await Z6e(K6e(t.path),i,{recursive:!0,dereference:!0,force:!1,errorOnExist:!0}),await LZ(i);let s=X6e({...n===void 0?{}:{name:n},...t.description===void 0?{}:{description:t.description}}),o=kl(i,RZ);s===void 0?await V7(o,{force:!0}):await AZ(o,s,{mode:384,dirMode:448})}catch(s){throw await V7(i,{recursive:!0,force:!0}),s}return i}l(ske,"copyComposition");async function oke(e,t){if(t.trust!=="user")throw new hu(t.id,"it ships with the deployment");let r=kl(DZ(e),t.id);if(!CZ(t.path)||!t.path.startsWith(r))throw new hu(t.id,"it does not live under the writable preset root");await V7(r,{recursive:!0,force:!0})}l(oke,"deleteComposition");var MZ=new WeakMap,FZ=new WeakMap,ake=class extends kZ{static{l(this,"PresetTree")}constructor(e,t){super(e,t),MZ.set(t,{tree:this,fiber:e.fiber})}import(e,t){let r=CZ(e)?NZ(e).href:e,n=FZ.get(this.config);if(n===void 0)return super.import(r,t);if(e.startsWith(".")||e.startsWith("cordis:"))return super.import(e,t);let i=this.ctx.loader.internal;return i===void 0?super.import(r,t):i.import(r,n,{})}write(){}},j0=new Set;function UZ(){for(let e of j0)e.fiber.uid===null&&j0.delete(e)}l(UZ,"pruneDisposedMounts");function lke(){return UZ(),[...j0]}l(lke,"livePresetMounts");function jZ(e,t){let r=e;for(;;){if(r===t)return!0;let n=r.parent.fiber;if(n===r)return!1;r=n}}l(jZ,"withinFiber");function cke(e,t){let r=e.reflect.store,n=e.root[ur.isolate],i=[];for(let s of Object.getOwnPropertySymbols(r)){let o=r[s];o!==void 0&&jZ(o.fiber,t)&&n[o.name]===s&&i.push(o.name)}return i.sort((s,o)=>s.localeCompare(o))}l(cke,"leakedServices");function K7(e){let t=pn(e);if(t===void 0)return;let r=I_(t);if(r!==void 0)return lke().find(n=>n.key===r)}l(K7,"standingMountFor");function uke(e,t,r){let n=K7(t.ctx);if(n===void 0)return;let i=e.reflect.store;for(let s of Object.getOwnPropertySymbols(i)){let o=i[s];if(o!==void 0&&o.name===r&&jZ(o.fiber,n.fiber))return o.value}}l(uke,"serviceForAgent");function dke(e){let t=[];for(let r of e.entries()){if(r.disabled)continue;let n=r.fiber;if(n===void 0){t.push(`${r.options.id} (${r.options.name}): never started`);continue}let i=Object.keys(n.inject).filter(s=>n.ctx.get(s)===void 0);i.length>0&&t.push(`${r.options.id} (${r.options.name}): waiting for ${i.join(", ")}`)}return t}l(dke,"inactiveRows");function zZ(e){return e instanceof Error?e instanceof AggregateError?[e.message,...e.errors.map(t=>`- ${zZ(t)}`)].join(`
|
|
2342
2342
|
`):e.message:String(e)}l(zZ,"mountDetail");async function fke(e,t){if(pn(e)===void 0)throw new Error(`agent-presets: refusing to mount preset "${t.id}" into an unscoped context; its registrations would apply to every agent in the process`);let r={path:NZ(t.path).href};e.baseUrl!==void 0&&FZ.set(r,e.baseUrl),UZ();let n=e.plugin(ake,r);try{await n.await();let i=MZ.get(r);if(i===void 0)throw new Error("mounted subtree did not publish its entry tree");let{tree:s,fiber:o}=i,a=dke(s);if(a.length>0)throw new Error(`${String(a.length)} row(s) did not activate:
|
|
2343
2343
|
${a.join(`
|
|
2344
|
-
`)}`);let c=cke(e,o);if(c.length>0)throw new Error(`row(s) published process-global service(s) [${c.join(", ")}]; a preset service must sit behind an \`isolate\` realm or move to the host composition`);j0.add({presetId:t.id,fiber:o,key:pn(e)})}catch(i){try{await n.dispose()}catch{}throw new ap(t.id,`${zZ(i)} (${t.path})`,{cause:i})}}l(fke,"mountPreset");function ua(e){for(let t=e.events.length-1;t>=0;t-=1){let r=e.events[t];if(r?.type==="agent-preset/selected")return r.data.agentPreset}return e.header.agentPreset}l(ua,"resolveSessionPreset");var $Z="agent-presets",pke=re.object({default:re.string()}),kFe=class extends ut{static{l(this,"AgentPresets")}config;static inject=["loader"];static Config=re.object({default:re.string().required(),roots:re.array(re.object({path:re.string().required(),trust:re.union(["system","user"]).default("user")})).default([]),includeUserRoot:re.boolean().default(!0)});resolvedRoots;settings;settingsService;selfCtx;constructor(e,t){super(e,"agentPresets"),this.config=t,this.selfCtx=e,this.resolvedRoots=t.includeUserRoot?[...t.roots,{path:mC(J6e),trust:"user"}]:[...t.roots],e.inject(["settings"],r=>{this.settings=r.settings.register(hn($Z),pke,{base:{default:t.default}}),this.settingsService=r.settings,r.effect(()=>()=>{this.settings=void 0,this.settingsService=void 0},"agentPresets.settings()")}),e.on("agent/created",({agent:r})=>{this.resolvedRoots.length!==0&&this.composedPreset(r.ctx)===void 0&&e.logger.warn(`agent "${r.id}" was published without joining an agent preset; its tools, prompt sections, and skill catalog resolve against the empty global layer (join through AgentPresets.mount() or composeFrom() in the agent factory setup)`)}),e.on("session/event",(r,n)=>{n.type==="agent-preset/selected"&&e.emit("agent-preset/selected",r.id,n.data.agentPreset)})}get defaultId(){return this.settings?.get().default??this.config.default}async list(){return await rke(this.resolvedRoots)}async resolve(e){let t=e??this.defaultId,r=await this.list(),n=r.find(i=>i.id===t);if(n===void 0)throw new B0(t,r.map(i=>i.id));return n}async resolveMountable(e){let t=await this.resolve(e);if(t.broken!==void 0)throw new ap(t.id,t.broken);return t}standing=new Map;bindings=new WeakMap;async mount(e,t){let r=pn(e);if(r===void 0)throw new Error("agent-presets: refusing to compose an unscoped context; the scope key is what joins an agent to its preset");let n=await this.resolveMountable(t),i=await this.ensureStanding(n);return this.bindings.set(r,ju(r,i.key)),n}composeFrom(e,t){let r=pn(e);if(r===void 0)throw new Error("agent-presets: refusing to compose an unscoped context; the scope key is what joins an agent to its preset");let n=K7(t);if(n!==void 0)return this.bindings.set(r,ju(r,n.key)),n.presetId}composedPreset(e){return K7(e)?.presetId}get roots(){return this.resolvedRoots}get authorable(){return this.resolvedRoots.some(e=>e.trust==="user")}async read(e){return await nke(await this.resolve(e))}async copy(e,t,r){let n=await this.resolve(e);if((await this.list()).some(i=>i.id===t))throw new W0(t);await ske(this.resolvedRoots,n,t,r),this.standing.delete(t)}async remove(e){await oke(this.resolvedRoots,await this.resolve(e)),this.standing.delete(e),this.settings?.get().default===e&&await this.settingsService?.mutate(hn($Z),[{op:"unset",path:["default"]}])}serviceFor(e,t){return uke(this.ctx,e,t)}async recompose(e,t){let r=pn(e);if(r===void 0)throw new Error("agent-presets: refusing to recompose an unscoped context");let n=await this.resolveMountable(t),i=await this.ensureStanding(n),s=this.bindings.get(r);return s===void 0?this.bindings.set(r,ju(r,i.key)):s.rebind(i.key),n}async standingKeyFor(e){let t=await this.resolveMountable(e);return(await this.ensureStanding(t)).key}async ensureStanding(e){let t=this.standing.get(e.id);if(t!==void 0){let n=await t,i=await _Z(e.path);return i===void 0||hke(n.stamp,i)?n:(this.standing.get(e.id)===t&&this.standing.delete(e.id),this.ensureStanding(e))}let r=(async()=>{let n={agentPreset:e.id},i=qp(this.selfCtx,n);try{let s=await _Z(e.path);if(s===void 0)throw new ap(e.id,`composition file is unreadable: ${e.path}`);return await fke(i.ctx,e),{key:n,scope:i,stamp:s}}catch(s){throw this.standing.delete(e.id),await i.dispose(),s}})();return this.standing.set(e.id,r),r}};async function _Z(e){try{let{mtimeMs:t,size:r}=await z0(e);return{mtimeMs:t,size:r}}catch{return}}l(_Z,"compositionStamp");function hke(e,t){return e.mtimeMs===t.mtimeMs&&e.size===t.size}l(hke,"sameStamp");import{randomUUID as bke}from"node:crypto";var mke=/^[A-Za-z0-9_$.-]+$/;function gke(e){return e!=="."&&e!==".."&&mke.test(e)}l(gke,"isTypertRemoteSegment");var qZ=class extends Error{static{l(this,"TypertLookupFailure")}failure;constructor(e){super("Typert lookup policy rejected the requested identity"),this.name="TypertLookupFailure",this.failure=e}},BZ=new WeakMap;function yke(e,t,r={}){Q7("service key",t);let n=r.namespace??t;return Q7("namespace",n),Object.freeze({service:e,serviceKey:t,namespace:n})}l(yke,"bindTypertRemote");var HZ=class extends ut{static{l(this,"TypertRemoteService")}typertRemote;constructor(e,t,r={}){super(e,t),this.typertRemote=yke(this,this.name,r)}};function Al(e,t){if(typeof e=="string")return Q7("Remote export name",e),function(r,n){WZ(n,{kind:"direct"},e)};if(t===void 0)throw new TypeError("typert-protocol: Remote decorator context is missing");WZ(t,{kind:"direct"})}l(Al,"Remote");function WZ(e,t,r){if(e.private||e.static||typeof e.name!="string")throw new TypeError("typert-protocol: Remote decorators require a public instance method with a string name");let n=e.name;e.addInitializer(function(){let i=Object.getPrototypeOf(this);if(i===null)throw new TypeError(`typert-protocol: cannot mark Remote method "${n}" on an object without a prototype`);vke(i,n,t,r)})}l(WZ,"addMarkerInitializer");function vke(e,t,r,n){let i=BZ.get(e);i===void 0&&(i=new Map,BZ.set(e,i));let s={...n===void 0||n===t?{}:{exportName:n},invocation:Object.freeze(r)},o=i.get(t);if(o!==void 0){if(o.exportName===s.exportName&&wke(o.invocation,r))return;throw new Error(`typert-protocol: Remote method "${t}" has conflicting invocation markers`)}i.set(t,Object.freeze(s))}l(vke,"mark");function wke(e,t){return e.kind===t.kind&&(e.kind==="direct"||t.kind==="context"&&e.context===t.context)}l(wke,"sameInvocation");function Q7(e,t){if(!gke(t))throw new TypeError(`typert-protocol: ${e} must contain only RPC endpoint segment characters`)}l(Q7,"validateName");var hi=class extends Wr{static{l(this,"GoalError")}constructor(e,t){super(e,t)}},xke=new Set(["create","edit","pause","resume","complete","block"]),Eke=new Set(["active","paused","blocked","complete"]);function Ske(){return{goal:void 0,roundsStarted:0,createdAt:void 0,updatedAt:void 0,lastRef:void 0,seenGoalIds:new Set}}l(Ske,"emptyGoalFoldState");function G0(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}l(G0,"isRecord");function e8(e,t){if(typeof e!="number"||!Number.isSafeInteger(e)||e<1)throw new Error(`goal change ${t} must be a positive safe integer`);return e}l(e8,"positiveInteger");function q0(e,t){if(typeof e!="number"||!Number.isSafeInteger(e)||e<0)throw new Error(`goal change ${t} must be a non-negative safe integer`);return e}l(q0,"nonNegativeInteger");function kke(e){if(!G0(e)||Object.keys(e).sort().join(",")!=="code,message")throw new Error("goal change goal.blockedReason must have exactly code and message fields");if(typeof e.code!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(e.code))throw new Error("goal change goal.blockedReason.code must be lower-kebab-case");if(typeof e.message!="string"||e.message.trim().length===0||e.message!==e.message.trim())throw new Error("goal change goal.blockedReason.message must be non-empty and normalized");return{code:e.code,message:e.message}}l(kke,"decodeBlockReason");function Ake(e){if(!G0(e))throw new Error("goal change goal must be a record");if(typeof e.id!="string"||e.id.length===0)throw new Error("goal change goal.id must be a non-empty string");if(typeof e.objective!="string"||e.objective.trim().length===0||e.objective!==e.objective.trim())throw new Error("goal change goal.objective must be non-empty and normalized");if(typeof e.phase!="string"||!Eke.has(e.phase))throw new Error("goal change goal.phase is invalid");let t=e.phase,r=t==="blocked"?"blockedReason,id,maxGoalRounds,objective,phase,revision":"id,maxGoalRounds,objective,phase,revision";if(Object.keys(e).sort().join(",")!==r)throw new Error(`goal change goal for phase ${t} must have exactly ${r} fields`);return{id:e.id,revision:e8(e.revision,"goal.revision"),objective:e.objective,phase:t,maxGoalRounds:e8(e.maxGoalRounds,"goal.maxGoalRounds"),...t==="blocked"?{blockedReason:kke(e.blockedReason)}:{}}}l(Ake,"decodeSnapshot");function Ike(e){if(!G0(e)||Object.keys(e).sort().join(",")!=="id,revision")throw new Error("goal clear tombstone must have exactly id and revision fields");if(typeof e.id!="string"||e.id.length===0)throw new Error("goal clear tombstone id must be a non-empty string");return{id:e.id,revision:e8(e.revision,"cleared.revision")}}l(Ike,"decodeRef");function ZZ(e){if(!G0(e)||e.kind!=="goal/change")return;if(e.version!==1)throw new Error(`unsupported goal change version ${String(e.version)}`);if(e.operation==="clear"){let i=["cleared","clearedAt","kind","operation","version"];if(Object.keys(e).sort().join(",")!==i.sort().join(","))throw new Error(`goal clear change must have exactly ${i.sort().join(",")} fields`);return{kind:"goal/change",version:1,operation:"clear",cleared:Ike(e.cleared),clearedAt:q0(e.clearedAt,"clearedAt")}}if(typeof e.operation!="string"||!xke.has(e.operation))throw new Error("goal change operation is invalid");let t=["createdAt","goal","kind","operation","roundsStarted","updatedAt","version"];if(Object.keys(e).sort().join(",")!==t.sort().join(","))throw new Error(`goal snapshot change must have exactly ${t.sort().join(",")} fields`);let r=q0(e.createdAt,"createdAt"),n=q0(e.updatedAt,"updatedAt");if(n<r)throw new Error("goal change updatedAt cannot precede createdAt");return{kind:"goal/change",version:1,operation:e.operation,goal:Ake(e.goal),roundsStarted:q0(e.roundsStarted,"roundsStarted"),createdAt:r,updatedAt:n}}l(ZZ,"decodeGoalChange");function $ke(e){if(e.kind==="goal"){if(typeof e.goalId!="string"||e.goalId.length===0||!Number.isSafeInteger(e.revision)||e.revision<1||!Number.isSafeInteger(e.round)||e.round<1)throw new Error("goal message source is invalid");return e}}l($ke,"goalSource");function H0(e,t,r){if(t.objective!==e.objective||t.maxGoalRounds!==e.maxGoalRounds)throw new Error(`goal ${r} cannot change objective or maxGoalRounds`)}l(H0,"requireSameDefinition");function KZ(e,t,r){if(t.id!==e.id||t.revision!==e.revision+1)throw new Error(`goal ${r} must advance the current goal by one revision`)}l(KZ,"requireNextRevision");function _ke(e,t,r){let n=t.goal;if(KZ(r,n,t.operation),e.updatedAt===void 0)throw new Error("current goal fold lacks updatedAt");if(t.createdAt!==e.createdAt||t.updatedAt<e.updatedAt||t.roundsStarted!==e.roundsStarted)throw new Error(`goal ${t.operation} does not preserve the current counters and timestamps`);switch(t.operation){case"edit":if(n.phase!==r.phase||JSON.stringify(n.blockedReason)!==JSON.stringify(r.blockedReason))throw new Error("goal edit cannot change phase or blocked reason");break;case"pause":if(H0(r,n,t.operation),r.phase!=="active"||n.phase!=="paused")throw new Error("goal pause has an invalid phase transition");break;case"resume":if(H0(r,n,t.operation),!new Set(["active","paused","blocked"]).has(r.phase)||n.phase!=="active"||e.roundsStarted>=n.maxGoalRounds)throw new Error("goal resume has an invalid phase transition or exhausted round budget");break;case"complete":if(H0(r,n,t.operation),r.phase==="complete"||n.phase!=="complete")throw new Error("goal complete has an invalid phase transition");break;case"block":if(H0(r,n,t.operation),r.phase!=="active"||n.phase!=="blocked")throw new Error("goal block has an invalid phase transition");break;case"create":throw new Error("goal create cannot be validated as a current-goal transition");default:throw t.operation,new Error("unknown goal snapshot operation")}}l(_ke,"validateSnapshotTransition");function YZ(e){return e.operation==="clear"?e.cleared:{id:e.goal.id,revision:e.goal.revision}}l(YZ,"goalChangeRef");function Tke(e,t){let r=YZ(t);if(t.operation==="clear"){let n=e.goal;if(n===void 0)throw new Error("goal clear requires a current goal");if(KZ(n,t.cleared,t.operation),e.updatedAt===void 0)throw new Error("current goal fold lacks updatedAt");if(t.clearedAt<e.updatedAt)throw new Error("goal clear timestamp cannot precede the current goal update");e.goal=void 0,e.roundsStarted=0,e.createdAt=void 0,e.updatedAt=void 0,e.lastRef=r;return}if(t.operation==="create"){if(t.goal.revision!==1||t.goal.phase!=="active"||t.roundsStarted!==0||e.goal!==void 0&&e.goal.phase!=="complete"||e.seenGoalIds.has(t.goal.id))throw new Error("goal create requires a fresh active revision-one goal with zero rounds");e.seenGoalIds.add(t.goal.id)}else{let n=e.goal;if(n===void 0)throw new Error(`goal ${t.operation} requires a current goal`);_ke(e,t,n)}e.goal=t.goal,e.roundsStarted=t.roundsStarted,e.createdAt=t.createdAt,e.updatedAt=t.updatedAt,e.lastRef=r}l(Tke,"applyGoalChange");function GZ(e,t){if(t.type==="goal/change"){let r=ZZ(t.data);if(r===void 0)throw new Error(`goal change at session event ${t.seq} has an invalid kind`);Tke(e,r);return}if(t.type==="user/message"){let r=$ke(t.data.source);if(r===void 0)return;let n=e.goal;if(n===void 0||n.phase!=="active"||r.goalId!==n.id||r.revision!==n.revision||r.round!==e.roundsStarted+1||r.round>n.maxGoalRounds)throw new Error(`goal round at session event ${t.seq} is not the next admitted round of the active goal`);e.roundsStarted=r.round}}l(GZ,"applyGoalEvent");var Cke=l(function(e,t,r){for(var n=arguments.length>2,i=0;i<t.length;i++)r=n?t[i].call(e,r):t[i].call(e);return n?r:void 0},"__runInitializers"),mu=l(function(e,t,r,n,i,s){function o(x){if(x!==void 0&&typeof x!="function")throw new TypeError("Function expected");return x}l(o,"accept");for(var a=n.kind,c=a==="getter"?"get":a==="setter"?"set":"value",u=!t&&e?n.static?e:e.prototype:null,d=t||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),f,p=!1,h=r.length-1;h>=0;h--){var m={};for(var g in n)m[g]=g==="access"?{}:n[g];for(var g in n.access)m.access[g]=n.access[g];m.addInitializer=function(x){if(p)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(x||null))};var y=(0,r[h])(a==="accessor"?{get:d.get,set:d.set}:d[c],m);if(a==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(f=o(y.get))&&(d.get=f),(f=o(y.set))&&(d.set=f),(f=o(y.init))&&i.unshift(f)}else(f=o(y))&&(a==="field"?i.unshift(f):d[c]=f)}u&&Object.defineProperty(u,n.name,d),p=!0},"__esDecorate"),VZ=v.union([v.object({goal:v.object({id:v.string().min(1),revision:v.number().int().positive(),objective:v.string().min(1),phase:v.union([v.literal("active"),v.literal("paused"),v.literal("blocked"),v.literal("complete")]),blockedReason:v.object({code:v.string(),message:v.string()}).optional(),maxGoalRounds:v.number().int().positive()}),roundsStarted:v.number().int().nonnegative(),createdAt:v.number(),updatedAt:v.number()}),v.null()]);function Oke(e,t){if(t.type!=="goal/change")return e;let r;try{r=ZZ(t.data)}catch{return e}return r===void 0?e:r.operation==="clear"?null:{goal:r.goal,roundsStarted:r.roundsStarted,createdAt:r.createdAt,updatedAt:r.updatedAt}}l(Oke,"applyGoalProjection");function t8(e){if(!Number.isSafeInteger(e)||e<1)throw new hi("maxGoalRounds must be a positive safe integer","GOAL_INVALID_MAX_ROUNDS");return e}l(t8,"resolveMaxGoalRounds");function XZ(e){if(typeof e!="string"||e.trim().length===0)throw new hi("goal objective must be a non-empty string","GOAL_INVALID_OBJECTIVE");return e.trim()}l(XZ,"resolveObjective");function Nke(e,t){return{objective:XZ(e.objective),maxGoalRounds:t8(e.maxGoalRounds??t)}}l(Nke,"resolveCreateGoal");function Rke(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,r=t?.code,n=t?.message;if(typeof r!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(r)||typeof n!="string"||n.trim().length===0)throw new hi("goal block reason requires a lower-kebab-case code and a non-empty message","GOAL_INVALID_BLOCK_REASON");return{code:r,message:n.trim()}}l(Rke,"resolveBlockReason");var HFe=(()=>{let e=HZ,t=[],r,n,i,s,o,a;return class extends e{static{l(this,"GoalService")}static{let u=typeof Symbol=="function"&&Symbol.metadata?Object.create(e[Symbol.metadata]??null):void 0;r=[Al("edit")],n=[Al("pause")],i=[Al("resume")],s=[Al("complete")],o=[Al("clear")],a=[Al("create")],mu(this,null,r,{kind:"method",name:"edit",static:!1,private:!1,access:{has:l(d=>"edit"in d,"has"),get:l(d=>d.edit,"get")},metadata:u},null,t),mu(this,null,n,{kind:"method",name:"pause",static:!1,private:!1,access:{has:l(d=>"pause"in d,"has"),get:l(d=>d.pause,"get")},metadata:u},null,t),mu(this,null,i,{kind:"method",name:"resume",static:!1,private:!1,access:{has:l(d=>"resume"in d,"has"),get:l(d=>d.resume,"get")},metadata:u},null,t),mu(this,null,s,{kind:"method",name:"complete",static:!1,private:!1,access:{has:l(d=>"complete"in d,"has"),get:l(d=>d.complete,"get")},metadata:u},null,t),mu(this,null,o,{kind:"method",name:"clear",static:!1,private:!1,access:{has:l(d=>"clear"in d,"has"),get:l(d=>d.clear,"get")},metadata:u},null,t),mu(this,null,a,{kind:"method",name:"remoteExportCreate",static:!1,private:!1,access:{has:l(d=>"remoteExportCreate"in d,"has"),get:l(d=>d.remoteExportCreate,"get")},metadata:u},null,t),u&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:u})}static inject=["agents"];static Config=re.object({defaultMaxGoalRounds:re.number().default(256)});resolved=Cke(this,t);caches=new WeakMap;constructor(u,d={}){super(u,"goals"),this.resolved={defaultMaxGoalRounds:t8(d.defaultMaxGoalRounds??256)},u.on("agent/session-start",({agent:f})=>{this.cache(f.session).activation="disarmed"}),u.inject(["sessionProjections"],f=>{f.sessionProjections.register({key:"goal",stateSchema:VZ,init:l(()=>null,"init"),apply:Oke,wire:{viewSchema:VZ,view:l(p=>p,"view")},stateVersion:4})})}get(u){this.assertLive(u);let d=this.cache(u.session);return this.sync(u.session,d),this.view(d)}disarm(u){this.assertLive(u);let d=this.cache(u.session);return this.sync(u.session,d),d.activation="disarmed",this.view(d)}create(u,d){let f=Nke(d,this.resolved.defaultMaxGoalRounds),p=this.prepareMutation(u),h=p.state.goal;if(h!==void 0&&h.phase!=="complete")throw new hi(`goal "${h.id}" already exists with phase "${h.phase}"`,"GOAL_ALREADY_EXISTS");let m=Date.now(),g={id:`goal-${bke()}`,revision:1,objective:f.objective,phase:"active",maxGoalRounds:f.maxGoalRounds};return this.commitSnapshot(u,p,"create",g,0,m,m,"armed")}edit(u,d,f){let p=this.prepareMutation(u),h=this.expectCurrent(p,d);if(f.objective===void 0&&f.maxGoalRounds===void 0)throw new hi("goal edit requires objective and/or maxGoalRounds","GOAL_INVALID_EDIT");let m={...h,revision:h.revision+1,...f.objective===void 0?{}:{objective:XZ(f.objective)},...f.maxGoalRounds===void 0?{}:{maxGoalRounds:t8(f.maxGoalRounds)}};return this.commitCurrent(u,p,"edit",m,p.activation)}pause(u,d){return this.transition(u,d,"pause",["active"],"paused","disarmed")}resume(u,d){let f=this.prepareMutation(u),p=this.expectCurrent(f,d),h=["active","paused","blocked"];if(!h.includes(p.phase))throw this.transitionError(p,"resume",h);if(p.phase==="active"&&f.activation==="armed")throw new hi(`goal "${p.id}" is already active and armed`,"GOAL_INVALID_TRANSITION");if(f.state.roundsStarted>=p.maxGoalRounds)throw new hi(`goal "${p.id}" exhausted ${p.maxGoalRounds} goal rounds; increase maxGoalRounds before resuming`,"GOAL_INVALID_TRANSITION");return this.commitCurrent(u,f,"resume",this.withPhase(p,"active"),"armed")}complete(u,d){return this.transition(u,d,"complete",["active","paused","blocked"],"complete","disarmed")}block(u,d,f){let p=this.prepareMutation(u),h=this.expectCurrent(p,d);if(h.phase!=="active")throw this.transitionError(h,"block",["active"]);return this.commitCurrent(u,p,"block",{...this.withPhase(h,"blocked"),blockedReason:Rke(f)},"disarmed")}clear(u,d){let f=this.prepareMutation(u),p=this.expectCurrent(f,d),h={id:p.id,revision:p.revision+1},m={kind:"goal/change",version:1,operation:"clear",cleared:h,clearedAt:this.nextMutationTime(f)};return this.commit(u,f,m,"disarmed"),{...h}}prepareMutation(u){this.assertLive(u);let d=this.cache(u.session);return this.sync(u.session,d),d}expectCurrent(u,d){let f=u.state.goal;if(f===void 0)throw new hi("no current goal","GOAL_NOT_FOUND");if(d.id!==f.id||d.revision!==f.revision)throw new hi(`stale goal ref "${d.id}" revision ${d.revision}; current is "${f.id}" revision ${f.revision}`,"GOAL_STALE_REVISION");return f}assertLive(u){if(this.ctx.agents.get(u.id)!==u)throw new hi(`agent "${u.id}" is not live in this registry`,"GOAL_AGENT_NOT_LIVE")}cache(u){let d=this.caches.get(u);if(d!==void 0)return d;let f=Ske();for(let p of u.events)GZ(f,p);return d={state:f,activation:"disarmed",observedSeq:u.seq,pendingActivation:void 0},this.caches.set(u,d),d}sync(u,d){for(let f of u.events.slice(d.observedSeq))GZ(d.state,f),f.type==="goal/change"&&(d.activation=d.pendingActivation?.seq===f.seq?d.pendingActivation.activation:"disarmed"),d.observedSeq+=1}withPhase(u,d){return{id:u.id,revision:u.revision+1,objective:u.objective,phase:d,maxGoalRounds:u.maxGoalRounds}}transition(u,d,f,p,h,m){let g=this.prepareMutation(u),y=this.expectCurrent(g,d);if(!p.includes(y.phase))throw this.transitionError(y,f,p);return this.commitCurrent(u,g,f,this.withPhase(y,h),m)}transitionError(u,d,f){return new hi(`cannot ${d} goal "${u.id}" from phase "${u.phase}"; expected ${f.join(" or ")}`,"GOAL_INVALID_TRANSITION")}commitCurrent(u,d,f,p,h){let m=d.state.createdAt;if(m===void 0)throw new Error("current goal cache lacks createdAt");return this.commitSnapshot(u,d,f,p,d.state.roundsStarted,m,this.nextMutationTime(d),h)}nextMutationTime(u){let d=u.state.updatedAt;if(d===void 0)throw new Error("current goal cache lacks updatedAt");return Math.max(Date.now(),d)}commitSnapshot(u,d,f,p,h,m,g,y){let x={kind:"goal/change",version:1,operation:f,goal:p,roundsStarted:h,createdAt:m,updatedAt:g};this.commit(u,d,x,y);let w=this.view(d);if(w===void 0)throw new Error("snapshot commit cleared the goal unexpectedly");return w}commit(u,d,f,p){let h=YZ(f);d.pendingActivation={seq:u.session.seq,activation:p};try{u.session.append("goal/change",f),this.sync(u.session,d)}finally{d.pendingActivation=void 0}let m=this.view(d),g={operation:f.operation,ref:{...h},...m===void 0?{}:{goal:m}};zu(this.ctx,u).emit("goal/changed",{change:g})}view(u){let d=u.state.goal,f=u.state.createdAt,p=u.state.updatedAt;if(d!==void 0){if(f===void 0||p===void 0)throw new Error(`goal "${d.id}" cache lacks timestamps`);return{...d,roundsStarted:u.state.roundsStarted,createdAt:f,updatedAt:p,activation:u.activation}}}remoteExportCreate(u,d){let f=this.create(u,d);return{ref:{id:f.id,revision:f.revision}}}}})();var lp=class extends Wr{static{l(this,"UserQuestionError")}constructor(e,t,r){super(e,t,r),this.name="UserQuestionError"}};var JZ=class extends Error{static{l(this,"DirectoryPickerError")}code;path;constructor(e,t,r){super(r),this.code=e,this.path=t,this.name="DirectoryPickerError"}};var QZ=["agent-preset/selected","commands/change","credentials/reference-updated","cordis/request-run","cordis/request-run-resolved","cordis/dynamic-package","cordis/dynamic-retract","cordis/inspect-query","cordis/inspect-query-resolved","llm/adapters-updated","settings/document-updated"],da=class extends Error{static{l(this,"ApiRemoteSessionNotFound")}},Bs=class extends Error{static{l(this,"ApiRemoteSubagentSessionOwnership")}sessionId;constructor(e){super(`session "${e}" is a subagent session; use subagent delivery`),this.sessionId=e}};function Il(e,t,r){if(t.header.origin==="subagent")return!0;let n=t.header.parentSession;if(n===void 0||r===void 0)return!1;let i=e.agents.get(n);return i!==void 0&&e.agents.isOwnedBy(r.id,i)}l(Il,"hasApiRemoteSubagentOwner");function gu(e){return{code:"agent-busy",message:`session "${e}" is owned by subagent routing`,details:{reason:"use subagent delivery for this child session"}}}l(gu,"apiRemoteSubagentOwnershipError");async function r8(e,t){let r=e.get("sessionPersistence");if(r===void 0)throw new Error("session persistence is not configured (load a dsh-session-persistence backend)");let n=(await r.list()).find(s=>s.id===t);if(n===void 0||n.cwd===void 0)throw new da(`session "${t}" not found`);let i=await r.inspect(t);if(i.meta.cwd===void 0)throw new da(`session "${t}" not found`);return{meta:i.meta,events:[...i.events]}}l(r8,"inspectApiRemoteSession");function eK(e,t){let r=new Map,n=l(s=>{let o=e.agents.get(s);if(o!==void 0)return Il(e,o.session,o)?{error:gu(s)}:{agent:o}},"fencedLiveAgent"),i=l(async s=>{let o=n(s);if(o!==void 0)return o;let a=e.sessions.get(s);if(a!==void 0&&Il(e,a,void 0))return{error:gu(s)};let c=r.get(s);c===void 0&&(c=(async()=>{try{let u=await r8(e,s);if(Il(e,{header:u.meta},void 0))throw new Bs(s);let d=t.setup===void 0?void 0:await t.setup(u),f=e.sessions.get(s),p=e.agents.get(s);if(f!==void 0&&Il(e,f,p))throw new Bs(s);return(await e.agents.resume({resumeSessionId:s,...t.agentOptions===void 0?{}:{agentOptions:t.agentOptions()},...d===void 0?{}:{setup:d}})).agent}finally{r.delete(s)}})(),r.set(s,c));try{return{agent:await c}}catch(u){if(u instanceof da)return{error:{code:"session-not-found",message:u.message,details:{sessionId:s}}};if(u instanceof Bs)return{error:gu(u.sessionId)};let d=n(s);if(d!==void 0)return d;let f=e.sessions.get(s);return f!==void 0&&Il(e,f,void 0)?{error:gu(s)}:{error:{code:"internal",message:`resume failed for session "${s}": ${String(u)}`,details:{}}}}},"agentFor");return e.inject(["typert"],s=>{let o=l(async a=>{let c=await i(a);if("error"in c)throw new qZ(c.error);return c.agent},"resolveAgent");s.typert.lookups.configure("agent",o),s.typert.lookups.configure("session",async a=>(await o(a)).session),s.typert.contexts.configureHost("agent",async a=>(await o(a)).ctx)}),i}l(eK,"createApiRemoteAgentResolver");import{execFile as Pke}from"node:child_process";var tK=l((e,t,r)=>new Promise((n,i)=>{Pke(e,[...t],{encoding:"utf8",signal:r,windowsHide:!0},(s,o,a)=>{if(s!==null){i(Object.assign(new Error(s.message,{cause:s}),{code:s.code,stdout:o,stderr:a}));return}n({stdout:o,stderr:a})})}),"runNativeCommand");function zke(e){return{sessionQuery:e.get("sessionQuery"),sessionPersistence:e.get("sessionPersistence"),attachments:e.get("attachments"),sessions:e.get("sessions")}}l(zke,"sessionLogExportDeps");async function kK(e,t,r){r?.throwIfAborted();let n=e.sessions;if(n===void 0)return;let i=n.get(t);i!==void 0&&(await n.flush(i),r?.throwIfAborted())}l(kK,"flushLiveSessionLog");var Bke={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"};function Wke(e){return`media/${String(e.attachmentId)}.${Bke[e.mediaType]}`}l(Wke,"mediaEntryPath");function V0(e,t){if(!Array.isArray(e))return;let r=[];for(let n of e)r.push(n);for(;r.length>0;){let n=r.pop();if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;if(i.type==="image"&&typeof i.attachment=="object"&&i.attachment!==null){let s=i.attachment;t.set(String(s.attachmentId),s)}if(Array.isArray(i.content))for(let s of i.content)r.push(s)}}l(V0,"collectImageRefs");function qke(e,t){let r=e.data;if(typeof r!="object"||r===null)return;let n=r;if(V0(n.content,t),n.message!==void 0&&V0(n.message.content,t),n.inserted!==void 0)for(let i of n.inserted)V0(i.content,t);n.chunk?.type==="block-end"&&V0([n.chunk.block],t)}l(qke,"collectEventImageRefs");function Hke(e){let t=new Map;for(let r of e.split(`
|
|
2345
|
-
`)){if(r==="")continue;let n;try{n=JSON.parse(r)}catch{continue}qke(n,t)}return t}l(Hke,"imageRefsInArtifact");function AK(e){return e.replace(/[^A-Za-z0-9_-]/g,"_")}l(AK,"safeSessionIdSegment");function Gke(e){return`dsh-session-${AK(e)}.zip`}l(Gke,"sessionLogZipFilename");async function*Vke(e,t,r,n,i){let s=new Map,o=l(a=>{for(let[c,u]of Hke(a))s.set(c,u)},"rememberMedia");if(o(t.content),yield{path:t.filename,content:t.content},n){let a=new Set([r]),c=l(async function*(d){for(let f of d){i?.throwIfAborted();let p=f.session.header.id;if(a.has(p))continue;a.add(p),await kK(e,p,i);let h=await e.sessionPersistence.readRaw(p,i);if(i?.throwIfAborted(),h===void 0)throw new Error(`subagent "${p}" has no stored log artifact`);o(h.content),yield{path:`subagents/${AK(p)}/${h.filename}`,content:h.content},yield*c(f.descendants)}},"collect"),u=await e.sessionQuery.traceSession(r,i);i?.throwIfAborted(),yield*c(u.descendants)}for(let a of s.values()){i?.throwIfAborted();let c=await e.attachments.readImage(a,i);i?.throwIfAborted(),yield{path:Wke(a),data:c.data}}}l(Vke,"sessionLogZipEntries");var Zke=65536,Kke=65536,Yke=65536,Xke=class{static{l(this,"ResponseCapacityGate")}releasePending;async wait(e,t){t.throwIfAborted(),!(e.desiredSize===null||e.desiredSize>0)&&(await new Promise(r=>{let n=l(()=>{this.releasePending=void 0,t.removeEventListener("abort",n),r()},"release");this.releasePending=n,t.addEventListener("abort",n,{once:!0})}),t.throwIfAborted())}pulled(){this.releasePending?.()}};async function Jke(e,t,r,n,i){let s=0;do{i.throwIfAborted();let o=Math.min(s+Kke,t.byteLength),a=o>=t.byteLength;e.push(t.subarray(s,o),a),s=o,await n.wait(r,i)}while(s<t.byteLength)}l(Jke,"pushBinaryChunks");async function Qke(e,t,r,n,i){let s=new TextEncoder,o=0,a;do{i.throwIfAborted();let c=Math.min(o+Zke,t.length);if(c<t.length&&c-o>1){let u=t.charCodeAt(c-1);u>=55296&&u<=56319&&(c-=1)}a=c>=t.length,e.push(s.encode(t.slice(o,c)),a),o=c,await n.wait(r,i)}while(!a)}l(Qke,"pushArtifactChunks");function e4e(e,t,r,n,i,s){let o=new AbortController,a=AbortSignal.any([s,o.signal]),c,u=!1,d=new Xke,f=l(()=>{c===void 0||u||(u=!0,c.terminate())},"terminateZip");return new ReadableStream({start(p){let h=new nO((m,g,y)=>{if(m){p.error(m);return}g.byteLength>0&&p.enqueue(g),y&&p.close()});c=h,(async()=>{try{for await(let m of Vke(e,t,r,n,a)){let g=new rO(m.path,{level:i});h.add(g),"content"in m?await Qke(g,m.content,p,d,a):await Jke(g,m.data,p,d,a)}h.end()}catch(m){f(),p.error(m instanceof Error?m:new Error(String(m)))}})()},pull(){d.pulled()},cancel(p){o.abort(p instanceof Error?p:new Error("session log export stream cancelled")),f()}},{highWaterMark:Yke,size:l(p=>p.byteLength,"size")})}l(e4e,"streamSessionLogZip");function IK(e,t){let r=0,n=0;for(let i of e){if(r===t)return e.slice(0,n);r++,n+=i.length}return e}l(IK,"truncateUnicodeCodePoints");var ct=v.string().min(1),$K=v.string().min(1),Ws=v.string().min(1),_K=v.object({type:v.string(),seq:v.number().int().nonnegative(),time:v.number(),data:v.unknown(),sourceEventSeqs:v.array(v.number()).optional(),surfaceOp:v.unknown().optional(),ignorable:v.literal(!0).optional()}),t4e=v.object({sessionId:ct,updatedAt:v.number(),running:v.boolean(),blank:v.boolean(),parentSessionId:ct.optional(),origin:v.literal("subagent").optional(),cwd:v.string().optional(),agentPreset:v.string().optional(),projections:v.lazy(()=>a8).optional()}),r4e=v.object({cursor:v.string().optional()}),FUe=v.object({items:v.array(t4e)}),n4e=v.object({query:v.string().trim().min(1).max(500).refine(e=>!e.includes("\0"),{message:"search query must not contain NUL"})}),i4e=v.object({sessionId:ct,snippet:v.string().refine(e=>IK(e,240)===e,{message:"search snippet must contain at most 240 Unicode code points"})}),UUe=v.object({items:v.array(i4e).max(20),hasMore:v.boolean()}),s4e=v.object({workspaceId:Ws.optional(),cwd:v.string().optional(),sessionId:ct.optional(),agentPreset:v.string().optional(),reuseWorkspaceBlank:v.literal(!0).optional()}).refine(e=>e.workspaceId===void 0||e.cwd===void 0,{message:"session.create accepts workspaceId or cwd, not both"}).refine(e=>e.reuseWorkspaceBlank!==!0||e.workspaceId!==void 0&&e.sessionId!==void 0,{message:"session.create reuseWorkspaceBlank requires workspaceId and sessionId"}),jUe=v.object({sessionId:ct,agentPreset:v.string().optional()}),o4e=v.object({sessionId:ct,title:v.string()}),zUe=v.object({title:v.string().min(1),seq:v.number().int().nonnegative()}),a4e=v.object({sessionId:ct,atSeq:v.number().int().nonnegative().optional()}),BUe=v.object({sessionId:ct}),l4e=v.object({sessionId:ct,beforeSeq:v.number().int().nonnegative().optional(),maxMessages:v.number().int().positive().optional()}),TK=v.object({provider:v.string().min(1),model:v.string().min(1),reasoningEffort:v.string().min(1).optional()}),c4e=v.object({id:v.string().min(1),name:v.string().min(1),description:v.string().optional()}),u4e=v.object({efforts:v.array(c4e).min(1),defaultEffort:v.string().min(1).optional()}),d4e=v.object({id:v.string().min(1),name:v.string().min(1),description:v.string().optional(),reasoning:u4e.optional()}),CK=v.object({id:v.string().min(1),name:v.string().min(1),models:v.array(d4e)}),OK=v.object({id:v.string().min(1),name:v.string().min(1),message:v.string()}),NK=v.discriminatedUnion("for",[v.object({for:v.literal("call"),view:v.looseObject({card:v.string()})}),v.object({for:v.literal("result"),view:v.looseObject({card:v.string()})})]),RK=v.object({event:_K,view:NK.optional()}),a8=v.object({asOfSeq:v.number().int().min(-1),values:v.record(v.string(),v.unknown())}),rK=v.object({blank:v.boolean(),lastPromptAt:v.number().nullable()}),f4e=v.object({maxImageBytes:v.number().int().positive(),maxImagesPerMessage:v.number().int().positive(),maxMessageImageBytes:v.number().int().positive(),maxImagePixels:v.number().int().positive(),maxImageDimension:v.number().int().positive(),mediaTypes:v.array(v.string())}),WUe=v.object({events:v.array(RK),hasMore:v.boolean(),projections:a8.optional()}),p4e=v.object({sessionId:ct}),qUe=v.object({current:TK,routable:v.boolean(),groups:v.array(CK),failures:v.array(OK)}),h4e=v.object({sessionId:ct,provider:v.string().min(1),model:v.string().min(1),reasoningEffort:v.string().min(1).optional()}),HUe=v.object({selected:TK}),l8=v.looseObject({type:v.string()}),PK=v.union([v.literal("image/png"),v.literal("image/jpeg"),v.literal("image/webp"),v.literal("image/gif")]),m4e=v.discriminatedUnion("type",[v.object({type:v.literal("text"),text:v.string()}),v.object({type:v.literal("image"),mediaType:PK,data:v.string(),name:v.string().optional()})]),g4e=v.object({sessionId:ct,mode:v.union([v.literal("queue"),v.literal("steer")]),content:v.array(m4e),clientTimeZone:v.string().optional()}),GUe=v.object({accepted:v.literal(!0),command:v.object({kind:v.literal("success"),text:v.string().optional()}).optional()}),DK=v.string().min(1),y4e=v.object({attachmentId:DK,mediaType:PK,bytes:v.number().int().positive(),width:v.number().int().positive(),height:v.number().int().positive(),name:v.string().optional()}),v4e=v.object({sessionId:ct,attachmentId:DK}),VUe=v.object({attachment:y4e,data:v.string()}),w4e=v.object({sessionId:ct,itemId:$K,action:v.discriminatedUnion("kind",[v.object({kind:v.literal("edit"),content:v.array(l8)}),v.object({kind:v.literal("remove")}),v.object({kind:v.literal("steer")})])}),ZUe=v.object({accepted:v.literal(!0)}),b4e=v.object({sessionId:ct}),KUe=v.object({accepted:v.literal(!0)}),s8=v.string().min(1),x4e=v.object({sessionId:ct,approvalId:s8,outcome:v.union([v.literal("allowed-once"),v.literal("rejected")])}),E4e=v.object({answers:v.array(v.object({id:v.string(),selected:v.array(v.string()),custom:v.string().optional()}))}),S4e=v.object({sessionId:ct,answer:E4e});var k4e=new Set([".html",".htm",".xhtml",".svg"]);function A4e(e){let t=e.replace(/LSHandlerPreferredVersions\s*=\s*\{[^}]*\};/g,""),r=/\{[^{}]*LSHandlerURLScheme\s*=\s*"?https"?;[^{}]*\}/.exec(t)?.[0];if(r!==void 0)return/LSHandlerRoleAll\s*=\s*"?([\w.-]+)"?;/.exec(r)?.[1]}l(A4e,"macBundleForHttps");async function I4e(e,t,r,n,i){if(r==="darwin"){let s;try{let{stdout:o}=await n("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure"],t);s=A4e(o)}catch{return!1}return s===void 0?!1:(await n("open",["-b",s,e],t),!0)}if(r==="linux"){let s=i.BROWSER;return s===void 0||s===""?!1:(await n(s,[e],t),!0)}return!1}l(I4e,"openInBrowser");function $4e(e){return`'${e.replace(/'/g,"''")}'`}l($4e,"powershellLiteral");function J0(e){return e!==void 0&&e!==""}l(J0,"present");function LK(e){let t=e.env??process.env;return J0(t.WSL_DISTRO_NAME)||J0(t.WSL_INTEROP)?!0:(e.osRelease??Fke()).toLowerCase().includes("microsoft")}l(LK,"isWsl");async function MK(e,t,r){await r("powershell.exe",["-NoProfile","-Command",`Invoke-Item -LiteralPath ${$4e(e)}`],t)}l(MK,"openWindowsPath");async function _4e(e,t,r){let n=await r("wslpath",["-w",e],t);t.throwIfAborted();let i=n.stdout.replace(/[\r\n]+$/,"");if(i==="")throw new Error("wslpath returned no Windows path");await MK(i,t,r)}l(_4e,"openWslPath");async function FK(e,t,r,n={}){let i=n.platform??process.platform,s=n.run??tK,o=n.env??process.env,a=i==="linux"&&LK(n);if(!(!a&&r==="default"&&k4e.has(jke(e).toLowerCase())&&await I4e(e,t,i,s,o))){if(i==="darwin"){await s("open",r==="text-editor"?["-t",e]:[e],t);return}if(i==="win32"){await MK(e,t,s);return}if(i==="linux"){if(a){await _4e(e,t,s);return}await s("xdg-open",[e],t);return}throw new Error(`native path opener is unsupported on ${i}`)}}l(FK,"openNativePathWithIntent");function T4e(e={}){let t=e.platform??process.platform;if(t==="darwin"||t==="win32")return!0;if(t!=="linux")return!1;let r=e.env??process.env;return LK(e)||J0(r.DISPLAY)||J0(r.WAYLAND_DISPLAY)}l(T4e,"canOpenNativePath");function C4e(e,t,r={}){return FK(e,t,"default",r)}l(C4e,"openNativePath");function O4e(e,t,r={}){return FK(e,t,"text-editor",r)}l(O4e,"openNativeTextFile");var N4e=50,nK=100,iK=16,R4e=1024,UK=new Set(["user/message","assistant/message"]);async function P4e(e,t){if(t.every(i=>i.type==="text"))return t.map(i=>({type:"text",text:i.text}));let r=await Wm(e.attachments,t.filter(i=>i.type==="image")),n=0;return t.map(i=>i.type==="text"?{type:"text",text:i.text}:{type:"image",attachment:r[n++]})}l(P4e,"durablePromptContent");function up(e,t){if(Array.isArray(e))for(let r of e){if(typeof r!="object"||r===null||Array.isArray(r))continue;let n=r;if(n.type==="image"&&typeof n.attachment=="object"&&n.attachment!==null){let i=n.attachment;if(t(i))return i}if(n.type==="tool-result"){let i=up(n.content,t);if(i!==void 0)return i}}}l(up,"imageBlockIn");function D4e(e,t){let r=e.data,n=up(r.content,t);if(n!==void 0)return n;if(r.message!==void 0){let i=up(r.message.content,t);if(i!==void 0)return i}if(r.inserted!==void 0)for(let i of r.inserted){let s=up(i.content,t);if(s!==void 0)return s}if(e.type==="assistant/chunk"&&r.chunk?.type==="block-end")return up([r.chunk.block],t)}l(D4e,"imageInEvent");function L4e(e){return e.some(t=>_o(t.content))}l(L4e,"messagesHaveImage");function M4e(e,t){for(let r of e){let n=D4e(r,i=>String(i.attachmentId)===t);if(n!==void 0)return n}}l(M4e,"referencedImage");var sK=/^[A-Za-z][A-Za-z0-9_+.-]*(?:\/[A-Za-z0-9_+.-]+)+$/;function oK(e){if(!(e.length===0||e.trim()!==e||e!=="UTC"&&!sK.test(e)))try{let t=new Intl.DateTimeFormat("en-US",{timeZone:e}).resolvedOptions().timeZone;return t!=="UTC"&&!sK.test(t)?void 0:t}catch{return}}l(oK,"canonicalClientTimeZone");function go(e){return e.aborted}l(go,"isAborted");function F4e(e,t,r){let n=t===void 0?[...e]:e.filter(o=>o.seq<t),i=0,s=0;for(let o=n.length-1;o>=0;o--){let a=n[o];if(!UK.has(a.type)||!Ll(a))continue;i++;let c=a.sourceEventSeqs,u=a.seq;if(c!==void 0)for(let d of c)d<u&&(u=d);if(i>=r){s=u;break}}return{events:n.filter(o=>o.seq>=s),hasMore:s>0}}l(F4e,"paginate");function yt(e,t){return{rpcId:e.rpcId,result:{ok:!0,value:t}}}l(yt,"ok");async function aK(e){let t=await Promise.all(e.llm.listProviders().map(async r=>{try{let n=await e.llm.listModels(r.id),i=await Promise.all(n.map(async s=>{let o=await e.llm.resolveModelInfo(r.id,s.id),a=o.reasoning===void 0?void 0:{efforts:o.reasoning.efforts.map(c=>({id:c.id,name:c.name,...c.description===void 0?{}:{description:c.description}})),...o.reasoning.defaultEffort===void 0?{}:{defaultEffort:o.reasoning.defaultEffort}};return{id:s.id,name:s.name,...s.description===void 0?{}:{description:s.description},...a===void 0?{}:{reasoning:a}}}));return{kind:"group",group:{id:r.id,name:r.name,models:i}}}catch(n){return{kind:"failure",failure:{id:r.id,name:r.name,message:n instanceof Error?n.message:String(n)}}}}));return{groups:t.flatMap(r=>r.kind==="group"?[r.group]:[]).filter(r=>r.models.length>0),failures:t.flatMap(r=>r.kind==="failure"?[r.failure]:[])}}l(aK,"buildModelCatalog");function ke(e,t){return{rpcId:e.rpcId,result:{ok:!1,error:t}}}l(ke,"err");function lK(e,t){if(t instanceof B0)return ke(e,{code:"agent-preset-not-found",message:t.message,details:{agentPreset:t.presetId,available:[...t.available]}});if(t instanceof ap)return ke(e,{code:"agent-preset-invalid",message:t.message,details:{agentPreset:t.presetId,reason:t.reason}})}l(lK,"presetFailure");var cK=class{static{l(this,"FrameQueue")}buffer=[];waiter;done=!1;push(e){this.done||(this.buffer.push(e),this.waiter?.())}end(){this.done=!0,this.waiter?.()}async*iterate(e,t){let r=l(()=>{this.end()},"onAbort");e.addEventListener("abort",r,{once:!0});try{for(;;){for(;this.buffer.length>0;)yield this.buffer.shift();if(this.done||e.aborted)return;await new Promise(n=>{this.waiter=n}),this.waiter=void 0}}finally{e.removeEventListener("abort",r),t()}}};function en(e){return{rpcId:crypto.randomUUID(),payload:e}}l(en,"frame");function U4e(e,t){for(let[r,n]of t.entries())if(!qu(n))throw new Error(`forwarded host event "${e}" argument ${r} is not lossless JSON data`);return t}l(U4e,"assertJsonArgs");function uK(e,t){e.push(en({type:"session/subscribed",sessionId:t.id,lastSeq:t.seq-1}))}l(uK,"subscribeSession");function Z0(e){return e.map(t=>({id:t.id,kind:t.kind,label:t.label,status:t.status,...t.detail===void 0?{}:{detail:t.detail},startedAt:t.startedAt,...t.finishedAt===void 0?{}:{finishedAt:t.finishedAt}}))}l(Z0,"jobViews");function n8(e){return!e.events.some(t=>t.type==="turn/start")}l(n8,"sessionBlank");function jK(e,t){let r=e.blank&&t.type!=="turn/start",n=t.type==="user/message"&&t.data.source.kind==="user"?t.time:e.lastPromptAt;return r===e.blank&&n===e.lastPromptAt?e:{blank:r,lastPromptAt:n}}l(jK,"applySessionListMetadata");function zK(e){let t={blank:!0,lastPromptAt:null};for(let r of e)t=jK(t,r);return t}l(zK,"sessionListMetadata");function BK(e,t){return Math.max(e.createdAt,t?.lastPromptAt??0)}l(BK,"sessionListUpdatedAt");function c8(e,t=[]){let r=ua({header:e,events:t});return{...e.parentSession===void 0?{}:{parentSessionId:e.parentSession},...e.origin===void 0?{}:{origin:e.origin},...e.cwd===void 0?{}:{cwd:e.cwd},...r===void 0?{}:{agentPreset:r}}}l(c8,"sessionListFields");function j4e(e,t){let r=zK(e.events);return{sessionId:e.id,updatedAt:BK(e.header,r),running:t,blank:r.blank,...c8(e.header,e.events)}}l(j4e,"summarize");async function z4e(e,t,r,n,i){if(n===0)return;i?.throwIfAborted();let s=t.locate(r);if(s===void 0)return;i?.throwIfAborted();let o;try{o=(await Lke(s.path)).size}catch{i?.throwIfAborted();return}if(!(o>n))try{let{events:a}=await t.readFrom(r.id,0,i);return i?.throwIfAborted(),zK(a)}catch(a){i?.throwIfAborted(),e.logger.warn(`session.list: blank probe for "${r.id}" failed (serving it as visible): ${String(a)}`);return}}l(z4e,"probeColdSessionMetadata");async function B4e(e,t,r,n,i,s){let o=n?.blank===!1?void 0:await z4e(e,t,r,i,s);return{sessionId:r.id,updatedAt:BK(r,o??n),running:!1,blank:n?.blank===!1?!1:o?.blank??!1,...c8(r)}}l(B4e,"summarizeCold");function dK(e){return e instanceof JZ?{code:e.code,message:e.message,details:{path:e.path}}:{code:"internal",message:e instanceof Error?e.message:String(e),details:{}}}l(dK,"directoryError");function fK(e){return{rpcId:e.rpcId,payload:{type:"approval/requested",sessionId:e.sessionId,approvalId:e.approvalId,toolName:e.toolName,...e.callId===void 0?{}:{callId:e.callId},...e.reason===void 0?{}:{reason:e.reason}}}}l(fK,"requestedFrame");function W4e(e,t){if(e.sessionId!==t.sessionId)return!1;let r=e.answer.answers;return r.length!==t.questions.length?!1:r.every((n,i)=>{let s=t.questions[i];if(n.id!==s.id||new Set(n.selected).size!==n.selected.length)return!1;let o=n.custom?.trim();if(o!==void 0&&o===""||s.multiSelect!==!0&&(o!==void 0&&n.selected.length>0||n.selected.length>1))return!1;let a=new Set(s.options?.map(c=>c.label)??[]);return n.selected.every(c=>a.has(c))})}l(W4e,"matchesQuestions");function WK(e,t,r,n){try{if(t.type==="tool/call"){let{name:i,arguments:s}=t.data,o=e.tools.get(i,n)?.presentCall?.(JSON.parse(s));return o===void 0?void 0:{for:"call",view:o}}if(t.type==="tool/result"){let{message:i,meta:s}=t.data,[o]=i.content,a=i.source.callId,c=r(a);if(c===void 0)return;let u=e.tools.get(c.name,n)?.presentResult?.(c.args,{content:o.content,isError:o.isError===!0,...s===void 0?{}:{meta:s}});return u===void 0?void 0:{for:"result",view:u}}}catch(i){console.error(`api-proxy: presenter failed for ${t.type}, falling back to generic: ${String(i)}`)}}l(WK,"viewFor");function qK(e,t){for(let r=e.length-1;r>=0;r--){let n=e[r];if(n.type!=="tool/call")continue;let i=n.data;if(i.callId===t)try{return{name:i.name,args:JSON.parse(i.arguments)}}catch{return}}}l(qK,"backscanArgs");function pK(e,t,r,n,i){let s=F4e(t,r,n??N4e);return{events:s.events.map(o=>{let a=WK(e,o,c=>qK(s.events,c),i);return{event:o,...a===void 0?{}:{view:a}}}),hasMore:s.hasMore}}l(pK,"historyPage");function hK(e,t){let r=e.get("sessionProjections");if(r!==void 0)return r.snapshot(t)}l(hK,"projectionsFor");function mK(e,t,r){try{let n=r!==void 0?e.get("sessionProjections")?.snapshot(r):e.get("sessionProjectionCache")?.cachedSnapshot(t);return n!==void 0&&Object.keys(n.values).length>0?n:void 0}catch(n){e.logger.warn(`session.list: projection column for "${t.id}" failed (serving the row without it): ${String(n)}`);return}}l(mK,"listProjectionsFor");function gK(e,t){let r=e.get("sessionProjections");if(r!==void 0)return r.restore({},t,0).snapshot}l(gK,"detachedProjectionsFor");function yK(e,t,r){try{return r()}catch(n){e.logger.warn(`subagent.history: projections for "${t}" failed (serving the page without them): ${String(n)}`);return}}l(yK,"subagentHistoryProjections");function q4e(e,t,r){let n=e.payload.childSessionId;if(r.aborted)return ke(e,{code:"cancelled",message:"subagent prompt was cancelled",details:{}});if(t instanceof Sl)switch(t.code){case"NOT_RESUMABLE":return ke(e,{code:"subagent-not-resumable",message:"subagent cannot be resumed",details:{childSessionId:n}});case"UNAUTHORIZED":return ke(e,{code:"subagent-unauthorized",message:"subagent does not belong to this parent",details:{childSessionId:n}});case"DRAINING":case"ACTIVATION_CLOSING":case"CONTINUATION_UNAVAILABLE":case"PERSISTENCE_UNAVAILABLE":return ke(e,{code:"subagent-delivery-unavailable",message:"subagent follow-up is temporarily unavailable",details:{childSessionId:n}});default:break}return ke(e,{code:"internal",message:"subagent prompt failed",details:{}})}l(q4e,"subagentPromptError");function HK(){return{code:"internal",message:"subagent catalog is unavailable: this deployment does not mount the sessionProjections registry (load @deepseek-ai/dsh-session-projection)",details:{}}}l(HK,"projectionsUnavailableError");async function vK(e,t,r){let{parentSessionId:n,childSessionId:i,mode:s}=t;try{let o=(await e.subagents.listChildren(n,r)).find(a=>a.id===i);return o===void 0||o.kind==="child"&&o.mode!==s?{error:{code:"subagent-not-found",message:`session "${i}" is not a ${s} direct child of "${n}"`,details:{parentSessionId:n,childSessionId:i}}}:o.kind==="diagnostic"?{error:{code:"subagent-catalog-diagnostic",message:`subagent "${i}" is ${o.reason}`,details:{parentSessionId:n,childSessionId:i,reason:o.reason}}}:{entry:o}}catch(o){return r?.aborted||o instanceof Sl&&o.code==="CANCELLED"?{error:{code:"cancelled",message:"subagent catalog read was cancelled",details:{}}}:o instanceof Sl&&o.code==="SUBAGENT_CONTROL_PROJECTIONS_UNAVAILABLE"?{error:HK()}:{error:{code:"internal",message:"subagent catalog read failed",details:{}}}}}l(vK,"catalogChild");function K0(e){return{code:"agent-preset-not-found",message:"this deployment composes no agent presets",details:{agentPreset:e,available:[]}}}l(K0,"noRoster");function Y0(e,t){return t instanceof B0?{code:"agent-preset-not-found",message:t.message,details:{agentPreset:t.presetId,available:[...t.available]}}:t instanceof hu?{code:"agent-preset-read-only",message:t.message,details:{agentPreset:e,reason:t.message}}:t instanceof J7||t instanceof W0?{code:"agent-preset-invalid",message:t.message,details:{agentPreset:e,reason:t.message}}:{code:"internal",message:`agent preset "${e}": ${String(t)}`,details:{}}}l(Y0,"presetError");var wK=class extends Error{static{l(this,"AgentPresetConflict")}sessionId;requestedPreset;existingPreset;constructor(e,t,r){super(r===void 0?`session "${e}" records no agent preset, so it cannot be adopted under one; a deployment composing no roster records none on any session \u2014 `:`session "${e}" already runs agent preset ${JSON.stringify(r)}; requested ${JSON.stringify(t)}. A session's preset is fixed at creation.`),this.sessionId=e,this.requestedPreset=t,this.existingPreset=r}},i8=class extends Error{static{l(this,"SessionCwdConflict")}sessionId;requestedCwd;existingCwd;constructor(e,t,r){super(`session "${e}" already exists with cwd ${JSON.stringify(r)}; requested ${JSON.stringify(t)}`),this.sessionId=e,this.requestedCwd=t,this.existingCwd=r}},bK=class extends Error{static{l(this,"WorkspaceNameConflictError")}workspaceName;constructor(e){super(`workspace name '${e}' is already in use`),this.workspaceName=e,this.name="WorkspaceNameConflictError"}};function X0(e,t){return ke(e,{code:"workspace-not-found",message:`workspace "${t}" not found`,details:{workspaceId:t}})}l(X0,"workspaceNotFound");function cp(e){return{workspaceId:e.id,path:e.path,title:e.title,sessionIds:[...e.sessionIds],createdAt:e.createdAt,updatedAt:e.updatedAt}}l(cp,"workspaceView");function H4e(e,t){let r=g7.parse(t);return{workspaceId:e,path:r.path,title:r.title,sessionIds:[...r.sessionIds],createdAt:r.createdAt,updatedAt:r.updatedAt}}l(H4e,"changedWorkspaceView");function G4e(e,t){let r=t.sessionExportCompressionLevel??6,n=t.coldBlankProbeMaxBytes??1024,i=l(()=>{let{provider:I,model:R}=t.defaultModelSelection();return{provider:I,model:R}},"agentOptions"),s=new WeakMap,o=new Map,a=new Map,c=Promise.resolve(),u=new Map,d=new Map,f=new Set,p=new WeakMap;function h(I,R){let C=(p.get(I)??Promise.resolve()).then(R);return p.set(I,C.then(()=>{},()=>{})),C}l(h,"serializeImageAdmission");function m(I){let R=s.get(I);if(R!==void 0)return R;let C,U={get current(){if(C!==void 0)return C;let K=I.session.requestHeader()?.config;return K===void 0?t.defaultModelSelection():{provider:K.provider,model:K.model,...K.reasoningEffort===void 0?{}:{reasoningEffort:K.reasoningEffort}}},set current(K){C=K},assembled:void 0};return Hp(I.ctx,U),s.set(I,U),U}l(m,"selectionFor");function g(I){let R=I.agent;if(R===void 0)throw new Error("api-proxy: agent setup has no scoped agent");m(R)}l(g,"installSelection");function y(I,R,C){if(!(R===void 0||R===C))throw new wK(I,R,C)}l(y,"assertPresetUnchanged");async function x(I){let R=e.get("agentPresets");if(R===void 0)return{setup:l(U=>(g(U),Promise.resolve()),"setup")};let C=(await R.resolve(I)).id;return{agentPreset:C,setup:l(async U=>{g(U),await R.mount(U,C)},"setup")}}l(x,"composeAgent");let w=l((I,R)=>Il(e,I,R),"hasSubagentOwner"),b=l(I=>gu(I),"subagentOwnershipError"),k=l(I=>r8(e,I),"inspectServable"),S=eK(e,{agentOptions:i,setup:l(async({meta:I,events:R})=>(await x(ua({header:I,events:R}))).setup,"setup")});function A(I){let R=en(I);for(let C of f)C.push(R)}l(A,"broadcast"),e.inject(["sessionProjections"],I=>{I.sessionProjections.onChanged((R,C,U,K)=>{A({type:"session/projection",sessionId:R.id,key:C,value:U,seq:K})})}),e.inject(["sessionProjections"],I=>{I.sessionProjections.register({key:"sessionListMetadata",stateSchema:rK,init:l(()=>({blank:!0,lastPromptAt:null}),"init"),apply:jK,wire:{viewSchema:rK,view:l(R=>R,"view")},stateVersion:1})}),e.inject(["sessionProjections","attachments"],I=>{I.sessionProjections.register({key:"imageLimits",stateSchema:v.null(),init:l(()=>null,"init"),apply:l(R=>R,"apply"),wire:{viewSchema:f4e,view:l(()=>I.attachments.imageLimits,"view")},stateVersion:1})});let $=l((I,R)=>{let C=l(U=>{let K=U==="next-turn"?I.inbox.nextTurn:I.inbox.nextStep;return R?.target===U?K.toSpliced(R.start,R.removedCount??0,...R.inserted):K},"project");return[...C("next-turn").map(U=>({id:U.id,placement:"queued",message:U})),...C("next-step").map(U=>({id:U.id,placement:U.source.kind==="user"?"steering":"context",message:U}))]},"queueItems");e.on("session/event",(I,R)=>{if(R.type!=="agent/inbox/spliced")return;let C=e.agents.get(I.id);C?.session===I&&A({type:"session/queue",sessionId:I.id,items:$(C,R.data)})});function O(I,R){u.delete(I.rpcId),I.signal!==void 0&&I.onAbort!==void 0&&I.signal.removeEventListener("abort",I.onAbort),A({type:"question/resolved",sessionId:I.sessionId,questionRpcId:I.rpcId,outcome:R})}l(O,"claimQuestion");let _=e.userQuestions.registerProvider({ask(I){let R=I.agent?.id;return R===void 0?Promise.reject(new lp("web user interaction requires an agent-owned session","ASK_MISSING_AGENT")):new Promise((C,U)=>{let K=crypto.randomUUID(),J={rpcId:K,sessionId:R,questions:I.questions,resolve:C,reject:U,...I.signal===void 0?{}:{signal:I.signal}},j=l(()=>{O(J,"cancelled"),U(new lp("ask_user_question was aborted before the user answered","ASK_ABORTED"))},"onAbort");J.onAbort=j,u.set(K,J),I.signal?.addEventListener("abort",j,{once:!0});let oe={rpcId:K,payload:{type:"question/requested",sessionId:R,questions:I.questions}};for(let ne of f)ne.push(oe)})}});e.effect(()=>()=>{_();for(let I of[...u.values()])O(I,"cancelled"),I.reject(new lp("web user-questions provider was disposed","ASK_ABORTED"))},"api-proxy: user-questions provider"),e.get("approval")!==void 0&&(e.effect(()=>()=>{for(let I of[...d.values()])I.resolve("cancelled")},"api-proxy: approval registry teardown"),e.on("approval/request",(I,R)=>{if(I.signal?.aborted===!0)return Promise.resolve("cancelled");let C=I.agent.session.events,U=new Set;for(let oe of d.values())U.add(oe.approvalId);let K=new Set,J;for(let oe=C.length-1;oe>=0;oe-=1){let ne=C[oe];if(ne.type==="approval/decided")K.add(ne.data.id);else if(ne.type==="approval/asked"){if(K.has(ne.data.id)||U.has(ne.data.id)||(I.callId??null)!==(ne.data.callId??null))continue;J=ne.data.id;break}}if(J===void 0)return R();let j=J;return new Promise(oe=>{let ne=l(He=>{d.delete(We.rpcId)&&(I.signal?.removeEventListener("abort",Ee),A({type:"approval/resolved",sessionId:We.sessionId,approvalId:j,outcome:He}),oe(He))},"settle"),Ee=l(()=>{ne("cancelled")},"onAbort"),We={rpcId:crypto.randomUUID(),sessionId:I.agent.session.id,approvalId:j,toolName:I.toolName,...I.callId===void 0?{}:{callId:I.callId},...I.reason===void 0?{}:{reason:I.reason},resolve:ne};d.set(We.rpcId,We),I.signal?.addEventListener("abort",Ee,{once:!0});let $e=fK(We);for(let He of f)He.push($e)})}));async function F(I){let R=e.sessions.get(I);if(R!==void 0)return{id:R.id,header:R.header,events:[...R.events]};let C=await k(I);return{id:C.meta.id,header:C.meta,events:C.events}}l(F,"readSessionState");async function D(I){let R=e.workspaceRegistry.list(),C=R.find(K=>K.sessionIds.includes(I.id));if(C!==void 0||I.header.origin!=="subagent")return C;let U=await e.sessionQuery.traceSession(I.id);for(let K of U.ancestors){let J=R.find(j=>j.sessionIds.includes(K.header.id));if(J!==void 0)return J}}l(D,"forkWorkspace");async function B(I){let R=e.sessions.get(I);if(R!==void 0)return{kind:"attached",session:R};let C=await k(I);return{kind:"detached",header:C.meta,events:C.events}}l(B,"historySourceFor");function ee(I){return I.kind==="detached"?{header:I.header,events:I.events}:{header:I.session.header,events:I.session.events}}l(ee,"sourceSession");function L(I,R){if(I.kind==="detached"){let K=R?gK(e,I.events):void 0;return{events:I.events,...K===void 0?{}:{projections:K}}}let C=[...I.session.events],U=R?hK(e,I.session):void 0;return{events:C,...U===void 0?{}:{projections:U}}}l(L,"historyCutOf");async function W(I,R){let C=e.get("agents")?.get(I);if(C!==void 0)return C;let U=e.get("agentPresets");if(U!==void 0)try{return await U.standingKeyFor(ua(R))}catch{return}}l(W,"presenterScopeFor");async function z(I,R,C,U){let K=a.get(I);K===void 0&&(K=(async()=>{let j=e.sessions.get(I),oe=e.agents.get(I);if(j!==void 0&&w(j,oe))throw new Bs(I);if(oe!==void 0)return oe;let ne=C?e.get("sessionPersistence"):void 0,Ee=ne===void 0?void 0:(await ne.list()).find($e=>$e.id===I);if(ne!==void 0&&Ee!==void 0){let $e=await ne.inspect(I);if(w({header:$e.meta},void 0))throw new Bs(I);if($e.meta.cwd!==R)throw new i8(I,R,$e.meta.cwd);let He=ua({header:$e.meta,events:$e.events});return y(I,U,He),(await e.agents.resume({resumeSessionId:I,agentOptions:i(),setup:(await x(He)).setup})).agent}try{await Dke(R,{recursive:!0})}catch($e){throw new Error(`failed to ensure project directory "${R}": ${String($e)}`,{cause:$e})}let We=await x(U);return(await e.agents.create({sessionId:I,agentOptions:i(),meta:{cwd:R,...We.agentPreset===void 0?{}:{agentPreset:We.agentPreset}},setup:We.setup})).agent})().catch(j=>{let oe=e.agents.get(I);if(oe!==void 0){if(w(oe.session,oe))throw new Bs(I);return oe}let ne=e.sessions.get(I);throw ne!==void 0&&w(ne,void 0)?new Bs(I):j}).finally(()=>{a.delete(I)}),a.set(I,K));let J=await K;if(w(J.session,J))throw new Bs(I);if(y(I,U,ua(J.session)),J.session.header.cwd!==R)throw new i8(I,R,J.session.header.cwd);return J}l(z,"ensureSession");function Q(I){let R=c.then(async()=>{let C=await e.workspaceRegistry.resolveByPath(I);return C!==void 0?{workspace:C,created:!1}:{workspace:await e.workspaceRegistry.create(I),created:!0}});return c=R.then(()=>{},()=>{}),R}l(Q,"ensureWorkspace");async function H(I){I?.throwIfAborted();let R=l(J=>{let j=e.agents.get(J.id),oe=mK(e,J.header,J);return{...j4e(J,j?.status==="running"),...oe===void 0?{}:{projections:oe}}},"summarizeAttached"),C=e.sessions.list().map(R);I?.throwIfAborted();let U=new Set(C.map(J=>J.sessionId)),K=e.get("sessionPersistence");if(K!==void 0){let J=(await K.list(I)).filter(j=>!U.has(j.id)&&j.cwd!==void 0);I?.throwIfAborted();for(let j=0;j<J.length;j+=iK){I?.throwIfAborted();let oe=J.slice(j,j+iK),ne=await Promise.allSettled(oe.map(async He=>{let lt=mK(e,He,void 0),Lt=await B4e(e,K,He,lt?.values.sessionListMetadata,n,I),Pt=e.sessions.get(He.id);return Pt!==void 0?R(Pt):{...Lt,...lt===void 0?{}:{projections:lt}}})),Ee=[],We=!1,$e;for(let He of ne)He.status==="fulfilled"?Ee.push(He.value):We||(We=!0,$e=He.reason);if(We)throw $e;I?.throwIfAborted(),C.push(...Ee)}}return C.sort((J,j)=>j.updatedAt-J.updatedAt),C}l(H,"listVisibleSessionSummaries");function G(I){let R=e.get("agentPresets")?.serviceFor(I,"goals")??e.get("goals");return R===void 0?{error:{code:"internal",message:"goal service is absent: neither this session's agent preset nor the host composition mounts @deepseek-ai/dsh-goal",details:{}}}:R}l(G,"goalServiceFor");function Z(I,R){let C=R instanceof hi?{goalCode:R.code}:{};return ke(I,{code:"internal",message:String(R),details:C})}l(Z,"goalError");async function ue(I,R){let C=await S(I.payload.sessionId);if("error"in C)return ke(I,C.error);let U=G(C.agent);if("error"in U)return ke(I,U.error);try{let K=R(U,C.agent);return yt(I,{ref:{id:K.id,revision:K.revision}})}catch(K){return Z(I,K)}}l(ue,"mutateGoal");function pe(I){let R=e.get("llm");return R===void 0||R.listProviders().some(C=>C.id===I)}l(pe,"routeServed");async function ce(I,R){let C=await S(R);if("error"in C)return{refused:ke(I,C.error)};let U=C.agent,K=m(U).current;return pe(K.provider)?{agent:U}:{refused:ke(I,{code:"model-unavailable",message:`no adapter serves provider "${K.provider}"; select a model for this session`,details:{provider:K.provider,model:K.model}})}}l(ce,"turnAgentFor");function V(){return{code:"internal",message:"settings service is absent: this deployment does not mount a settings provider (e.g. @deepseek-ai/dsh-settings-file) in its composition",details:{}}}l(V,"settingsAbsent");async function ve(I,R,C,U){try{return await U(R,C),yt(I,{opened:!0})}catch(K){return C.aborted?ke(I,{code:"cancelled",message:"path open was aborted",details:{}}):ke(I,{code:"internal",message:`path open failed: ${K instanceof Error?K.message:String(K)}`,details:{}})}}l(ve,"openTarget");function Fe(I,R,C){return ve(I,R,C,t.openPath??((U,K)=>C4e(U,K)))}l(Fe,"openPath");function Ce(I,R,C){return ve(I,R,C,t.openTextFile??((U,K)=>O4e(U,K)))}l(Ce,"openTextFile");function Pe(){return t.canOpenPath!==void 0?t.canOpenPath():t.openPath!==void 0||T4e()}l(Pe,"canOpenPaths");function Re(){return{code:"internal",message:"credentials service is absent: this deployment does not mount a credential provider (e.g. @deepseek-ai/dsh-credentials-local) in its composition",details:{}}}l(Re,"credentialsAbsent");function Le(I){return{ns:String(I.ns),schema:I.schema,value:I.value,...I.base===void 0?{}:{base:I.base},...I.user===void 0?{}:{user:I.user},applies:I.applies,secrets:(I.secrets??[]).map(R=>({path:[...R.path],set:R.set})),revision:I.revision}}l(Le,"namespaceView");async function de(I,R,C,U,K){let J=e.get("settings");if(J===void 0)return ke(I,V());let j=l(Ee=>Ee instanceof Bu?ke(I,{code:"settings-conflict",message:Ee.message,details:{ns:R,expected:Ee.expected,actual:Ee.actual}}):ke(I,{code:"settings-rejected",message:Ee instanceof Error?Ee.message:String(Ee),details:{ns:R}}),"rejected"),oe;try{oe=hn(R)}catch(Ee){return j(Ee)}try{C==="update"?await J.update(oe,U,K):C==="replace"?await J.replace(oe,U,K):await J.mutate(oe,U,K)}catch(Ee){return j(Ee)}let ne=J.describe({redactSecrets:!0}).find(Ee=>Ee.ns===oe);return ne===void 0?ke(I,{code:"internal",message:`settings namespace "${R}" was disposed after the ${C}`,details:{}}):yt(I,Le(ne))}return l(de,"settingsWrite"),{sessions:{async list(I){return yt(I,{items:await H()})},async search(I,R){let C=l(()=>ke(I,{code:"cancelled",message:"session search was aborted",details:{}}),"cancelled");if(go(R))return C();let U=e.get("sessionQuery");if(U===void 0)return ke(I,{code:"internal",message:"session search is unavailable: this deployment does not mount @deepseek-ai/dsh-session-query",details:{}});try{let K=await H(R);if(go(R))return C();if(K.length===0)return yt(I,{items:[],hasMore:!1});let J=new Set(K.map(He=>He.sessionId)),j=[],oe=new Set,ne=new Set,Ee,We=0,$e=20;for(;j.length<=20;){if(go(R))return C();if(We>=nK)throw new Error(`session search provider exceeded the ${nK}-call work budget`);We++;let He=Ee,lt=$e,Lt;try{Lt=await U.searchSessions({query:I.payload.query,eventFilters:[{kind:"type",values:["user/message","assistant/message"]},{kind:"surface",values:["current"]}],limit:lt,...He===void 0?{}:{cursor:He}},{signal:R})}catch(q){if(go(R))return C();if(He===void 0&&q instanceof Ld&&q.code==="SESSION_QUERY_INVALID_LIMIT"&<>1){$e=Math.max(1,Math.floor(lt/2));continue}if(He!==void 0&&q instanceof Ld&&q.code==="SESSION_QUERY_STALE_CURSOR"){j.length=0,oe.clear(),ne.clear(),Ee=void 0;continue}throw q}if(go(R))return C();let Pt=Lt.items.length;if(Pt>lt)throw new Error(`session search provider returned ${Pt} items; maximum is ${lt}`);for(let q of Lt.items){if(j.length>20||!J.has(q.header.id)||q.bestMatch.sessionId!==q.header.id||q.bestMatch.surface!=="current"||!UK.has(q.bestMatch.type)||oe.has(q.header.id))continue;let le=IK(q.bestMatch.snippet,240);oe.add(q.header.id),j.push({sessionId:q.header.id,snippet:le})}let E=Lt.nextCursor;if(E!==void 0){if(ne.has(E))throw new Error("session search provider repeated a continuation cursor");ne.add(E)}if(j.length>20||E===void 0)break;Ee=E}return yt(I,{items:j.slice(0,20),hasMore:j.length>20})}catch(K){return go(R)||K instanceof Ld&&K.code==="SESSION_QUERY_ABORTED"?C():ke(I,{code:"internal",message:`session search failed: ${String(K)}`,details:{}})}},async create(I){let R=I.payload.sessionId??`session-${crypto.randomUUID()}`,C;if(I.payload.workspaceId!==void 0&&(C=e.workspaceRegistry.get(I.payload.workspaceId),C===void 0))return ke(I,{code:"workspace-not-found",message:`workspace "${I.payload.workspaceId}" not found`,details:{workspaceId:I.payload.workspaceId}});let U=C?.path??I.payload.cwd??t.cwd,K=I.payload.agentPreset,J=I.payload.reuseWorkspaceBlank===!0&&C!==void 0&&C.sessionIds.includes(R)&&!e.workspaceRegistry.archivedSessionIds.includes(R),j;try{j=await z(R,U,I.payload.sessionId!==void 0,K)}catch(ne){if(ne instanceof wK)return ke(I,{code:"agent-preset-conflict",message:ne.message,details:{sessionId:ne.sessionId,requestedPreset:ne.requestedPreset,...ne.existingPreset===void 0?{}:{existingPreset:ne.existingPreset}}});let Ee=lK(I,ne);return Ee!==void 0?Ee:ne instanceof i8?ke(I,{code:"session-conflict",message:ne.message,details:{sessionId:ne.sessionId,requestedCwd:ne.requestedCwd,...ne.existingCwd===void 0?{}:{existingCwd:ne.existingCwd}}}):ne instanceof Bs?ke(I,b(ne.sessionId)):ke(I,{code:"internal",message:`failed to create session "${R}": ${String(ne)}`,details:{}})}if(C!==void 0)try{await C.attachSession(R)}catch(ne){return ke(I,{code:"workspace-attach-failed",message:`session "${R}" was created but could not attach to workspace "${C.id}": ${String(ne)}`,details:{sessionId:R,workspaceId:C.id}})}J&&n8(j.session)&&e.get("permissionPresets")?.refreshDefaultForReuse(j.session);let oe=ua(j.session);return yt(I,{sessionId:R,...oe===void 0?{}:{agentPreset:oe}})},async history(I){let{sessionId:R,beforeSeq:C,maxMessages:U}=I.payload;try{let K=await B(R),J=await W(R,ee(K)),j=L(K,C===void 0),oe=pK(e,j.events,C,U,J);return yt(I,{events:oe.events,hasMore:oe.hasMore,...j.projections===void 0?{}:{projections:j.projections}})}catch(K){return K instanceof da?ke(I,{code:"session-not-found",message:K.message,details:{sessionId:R}}):ke(I,{code:"internal",message:`history unavailable for session "${R}": ${String(K)}`,details:{}})}},async models(I){let{sessionId:R}=I.payload,C=await S(R);if("error"in C)return ke(I,C.error);let U=m(C.agent).current,{groups:K,failures:J}=await aK(e),j=pe(U.provider);return yt(I,{current:{...U},routable:j,groups:K,failures:J})},async selectModel(I){let{sessionId:R,provider:C,model:U,reasoningEffort:K}=I.payload,J=await S(R);return"error"in J?ke(I,J.error):h(J.agent,async()=>{try{let j=await e.llm.resolveCallConfig({provider:C,model:U,...K===void 0?{}:{reasoningEffort:K}});if([...J.agent.inbox.nextTurn,...J.agent.inbox.nextStep].some(ne=>_o(ne.content))||L4e(J.agent.session.deriveMessages())){let ne=await e.llm.resolveModelInfo(j.provider,j.model);if(ne.inputModalities!==void 0&&!ne.inputModalities.includes("image"))return ke(I,{code:"model-unavailable",message:`Model "${j.model}" does not accept image input, but this session already contains images; select an image-capable model.`,details:{provider:C,model:U}})}let oe={provider:j.provider,model:j.model,...j.reasoningEffort===void 0?{}:{reasoningEffort:j.reasoningEffort}};m(J.agent).current=oe;try{await t.saveDefaultModelSelection?.(oe)}catch(ne){e.logger.warn(`api-proxy: the model switch applies to this session but was not saved as the default: ${String(ne)}`)}return yt(I,{selected:{...oe}})}catch(j){return ke(I,{code:"model-unavailable",message:j instanceof Error?j.message:String(j),details:{provider:C,model:U}})}})},async rename(I){let{sessionId:R,title:C}=I.payload,U=await S(R);if("error"in U)return ke(I,U.error);let K=e.get("sessionTitle");if(K===void 0)return ke(I,{code:"internal",message:"renaming is unavailable: this deployment mounts no session-title service",details:{}});try{let J=K.rename(U.agent.session,C);return yt(I,{title:J.title,seq:J.eventSeq})}catch(J){return J instanceof qS?ke(I,{code:"title-invalid",message:J.message,details:{sessionId:R}}):ke(I,{code:"internal",message:`failed to rename session "${R}": ${String(J)}`,details:{}})}},async fork(I){let{sessionId:R,atSeq:C}=I.payload,U;try{U=await F(R)}catch($e){return $e instanceof da?ke(I,{code:"session-not-found",message:$e.message,details:{sessionId:R}}):ke(I,{code:"internal",message:`fork source unavailable for session "${R}": ${String($e)}`,details:{}})}let K=U.events,J=K.at(-1)?.seq??-1,j=(C===void 0?void 0:K.find($e=>$e.type==="turn/end"&&$e.seq>=C))??(C===void 0||C>J?K.findLast($e=>$e.type==="turn/end"):void 0);if(j===void 0)return ke(I,{code:"fork-unavailable",message:C!==void 0&&C<=J?`session "${R}" has not completed the turn containing event ${String(C)}`:`session "${R}" has no completed turn to fork from`,details:{sessionId:R}});let oe=j.seq+1;for(;oe<K.length&&K[oe]?.type!=="turn/start";)oe++;let ne;try{ne=await D(U)}catch($e){return ke(I,{code:"internal",message:`failed to resolve fork workspace for session "${R}": ${String($e)}`,details:{}})}let Ee=`session-${crypto.randomUUID()}`,We=await x(ua(U));try{await e.agents.create({sessionId:Ee,seed:K.slice(0,oe),meta:{...U.header.cwd===void 0?{}:{cwd:U.header.cwd},parentSession:U.id,seedLength:oe,...We.agentPreset===void 0?{}:{agentPreset:We.agentPreset}},agentOptions:i(),setup:We.setup})}catch($e){return ke(I,{code:"internal",message:`failed to fork session "${R}": ${String($e)}`,details:{}})}if(ne!==void 0)try{await ne.attachSession(Ee)}catch($e){return ke(I,{code:"workspace-attach-failed",message:`session "${Ee}" was forked but could not attach to workspace "${ne.id}": ${String($e)}`,details:{sessionId:Ee,workspaceId:ne.id}})}return yt(I,{sessionId:Ee})},async prompt(I){let{sessionId:R,mode:C,content:U,clientTimeZone:K}=I.payload,J=K===void 0?void 0:oK(K);if(K!==void 0&&J===void 0)return ke(I,{code:"invalid-time-zone",message:"clientTimeZone must be UTC or a valid IANA Area/Location name",details:{value:K}});let j=await ce(I,R);if("refused"in j)return j.refused;let oe=j.agent,ne={kind:"user",rpcId:I.rpcId,...J===void 0?{}:{clientTimeZone:J}},Ee=U.some($e=>$e.type==="image"),We=l(async()=>{try{if(Ee){let He=m(oe).current,lt=await e.llm.resolveModelInfo(He.provider,He.model);if(lt.inputModalities!==void 0&&!lt.inputModalities.includes("image"))return ke(I,{code:"attachment-error",message:`Model "${He.model}" does not support image input.`,details:{reason:"MODEL_DOES_NOT_SUPPORT_IMAGES"}})}let $e=vs({content:await P4e(e,U),source:ne});C==="steer"?oe.steer($e):oe.followup($e)}catch($e){return $e instanceof Ct?ke(I,{code:"attachment-error",message:$e.message,details:{reason:$e.code}}):ke(I,{code:"agent-busy",message:"prompt rejected",details:{reason:String($e)}})}return yt(I,{accepted:!0})},"admit");return Ee?h(oe,We):We()},async attachment(I){let{sessionId:R,attachmentId:C}=I.payload,U;try{U=await F(R)}catch(J){return J instanceof da?ke(I,{code:"session-not-found",message:J.message,details:{sessionId:R}}):ke(I,{code:"internal",message:`attachment authorization unavailable for session "${R}": ${String(J)}`,details:{}})}let K=M4e(U.events,String(C));if(K===void 0)return ke(I,{code:"attachment-error",message:"Image is not referenced by this session.",details:{reason:"ATTACHMENT_NOT_REFERENCED"}});try{let J=await e.attachments.readImage(K);return yt(I,{attachment:J.ref,data:Buffer.from(J.data).toString("base64")})}catch(J){return J instanceof Ct?ke(I,{code:"attachment-error",message:J.message,details:{reason:J.code}}):ke(I,{code:"internal",message:"Unable to read image attachment.",details:{}})}},updateQueue(I){let{sessionId:R,itemId:C,action:U}=I.payload;if(U.kind==="edit"&&U.content.some(oe=>oe.type!=="text"))return Promise.resolve(ke(I,{code:"attachment-error",message:"queue edits accept text content only",details:{reason:"QUEUE_EDIT_NON_TEXT"}}));let K=e.agents.get(R);if(K!==void 0&&w(K.session,K))return Promise.resolve(ke(I,b(R)));if(K===void 0)return Promise.resolve(ke(I,{code:"queue-item-not-found",message:"queued item is no longer pending",details:{itemId:C}}));let J=K.inbox.nextTurn.some(oe=>oe.id===C)?"next-turn":K.inbox.nextStep.some(oe=>oe.id===C)?"next-step":void 0,j=J===void 0?void 0:(J==="next-turn"?K.inbox.nextTurn:K.inbox.nextStep).find(oe=>oe.id===C);return J===void 0||j===void 0?Promise.resolve(ke(I,{code:"queue-item-not-found",message:"queued item is no longer pending",details:{itemId:C}})):U.kind==="steer"&&(J!=="next-turn"||K.status!=="running")?Promise.resolve(ke(I,{code:"steer-unavailable",message:"current turn no longer accepts steering",details:{itemId:C}})):(U.kind==="edit"?K.inbox.replace(C,Io({...j,content:U.content})):(K.inbox.remove(C),U.kind==="steer"&&K.steer(j)),Promise.resolve(yt(I,{accepted:!0})))},cancel(I){let{sessionId:R}=I.payload,C=e.agents.get(R);return C===void 0?Promise.resolve(ke(I,{code:"session-not-found",message:`session "${R}" not found (not attached)`,details:{sessionId:R}})):w(C.session,C)?Promise.resolve(ke(I,b(R))):(C.cancel({kind:"user"},{keepInbox:!0}),Promise.resolve(yt(I,{accepted:!0})))}},subagents:{async list(I,R){try{return yt(I,{entries:(await e.subagents.listChildren(I.payload.parentSessionId,R)).map(C=>C.kind==="child"?{...C,activity:e.agents.get(C.id)?.status==="running"?"running":"inactive"}:C),parentAvailable:e.agents.get(I.payload.parentSessionId)!==void 0})}catch(C){return R?.aborted||C instanceof Sl&&C.code==="CANCELLED"?ke(I,{code:"cancelled",message:"subagent catalog read was cancelled",details:{}}):C instanceof Sl&&C.code==="SUBAGENT_CONTROL_PROJECTIONS_UNAVAILABLE"?ke(I,HK()):ke(I,{code:"internal",message:"subagent catalog read failed",details:{}})}},async history(I,R){let{parentSessionId:C,childSessionId:U,mode:K,beforeSeq:J,maxMessages:j}=I.payload,oe=await vK(e,{parentSessionId:C,childSessionId:U,mode:K},R);if(oe.error!==void 0)return ke(I,oe.error);let ne,Ee,We,$e=e.sessions.get(U);if($e!==void 0)ne=$e.header,Ee=[...$e.events],We=J===void 0?yK(e,U,()=>hK(e,$e)):void 0;else try{let He=await k(U);ne=He.meta,Ee=He.events,We=J===void 0?yK(e,U,()=>gK(e,He.events)):void 0}catch(He){return R?.aborted?ke(I,{code:"cancelled",message:"subagent history read was cancelled",details:{}}):He instanceof da?ke(I,{code:"subagent-not-found",message:"subagent disappeared during history read",details:{parentSessionId:C,childSessionId:U}}):ke(I,{code:"internal",message:"subagent history read failed",details:{}})}return R?.aborted?ke(I,{code:"cancelled",message:"subagent history read was cancelled",details:{}}):ne.parentSession!==C?ke(I,{code:"subagent-unauthorized",message:"subagent parent changed during history read",details:{childSessionId:U}}):yt(I,{...pK(e,Ee,J,j),...We===void 0?{}:{projections:We}})},async prompt(I,R){let{parentSessionId:C,childSessionId:U,content:K,clientTimeZone:J}=I.payload,j=J===void 0?void 0:oK(J);if(J!==void 0&&j===void 0)return ke(I,{code:"invalid-time-zone",message:"clientTimeZone must be UTC or a valid IANA Area/Location name",details:{value:J}});let oe=e.agents.get(C);if(oe===void 0)return ke(I,{code:"subagent-parent-unavailable",message:`parent session "${C}" is not live`,details:{parentSessionId:C}});let ne=await vK(e,{parentSessionId:C,childSessionId:U,mode:"continuable"},R);if(ne.error!==void 0)return ke(I,ne.error);try{return yt(I,{messageId:await e.subagents.followup(oe,U,K,{source:{kind:"user",rpcId:I.rpcId,...j===void 0?{}:{clientTimeZone:j}},signal:R})})}catch(Ee){return q4e(I,Ee,R)}},interrupt(I){let{parentSessionId:R,childSessionId:C}=I.payload;try{e.subagents.interrupt(C,{kind:"user",parentSessionId:R})}catch(U){return U instanceof Sl&&U.code==="UNAUTHORIZED"?Promise.resolve(ke(I,{code:"subagent-unauthorized",message:"subagent does not belong to this parent",details:{childSessionId:C}})):Promise.resolve(ke(I,{code:"internal",message:"subagent interrupt failed",details:{}}))}return Promise.resolve(yt(I,{accepted:!0}))}},workspace:{list(I){return Promise.resolve(yt(I,{items:e.workspaceRegistry.list().map(cp),archivedSessionIds:[...e.workspaceRegistry.archivedSessionIds]}))},async create(I){let{path:R}=I.payload;try{let{workspace:C,created:U}=await Q(R);return yt(I,{workspace:cp(C),created:U})}catch(C){return ke(I,{code:"workspace-invalid-path",message:`cannot create a workspace at "${R}": ${C instanceof Error?C.message:String(C)}`,details:{path:R}})}},async rename(I){let{payload:R}=I,C=e.workspaceRegistry.get(R.workspaceId);if(C===void 0)return X0(I,R.workspaceId);let U=R.title.trim(),K=c.then(async()=>{if(U!==C.title){if(e.workspaceRegistry.list().some(J=>J.id!==C.id&&J.title===U))throw new bK(U);await C.setTitle(U)}});c=K.then(()=>{},()=>{});try{await K}catch(J){if(J instanceof bK)return ke(I,{code:"workspace-name-conflict",message:J.message,details:{name:J.workspaceName}});throw J}return yt(I,{workspace:cp(C)})},async delete(I){let{workspaceId:R}=I.payload,C=c.then(()=>e.workspaceRegistry.delete(R));return c=C.then(()=>{},()=>{}),await C?yt(I,{deleted:!0}):X0(I,R)},async insertBefore(I){let{workspaceId:R,beforeWorkspaceId:C}=I.payload;try{return yt(I,{workspaceIds:[...await e.workspaceRegistry.insertBefore(R,C===void 0?void 0:C)]})}catch(U){if(!(U instanceof N0))throw U;return X0(I,U.workspaceId)}},async insertSessionBefore(I){let{payload:R}=I,C=e.workspaceRegistry.get(R.workspaceId);if(C===void 0)return X0(I,R.workspaceId);try{await C.insertSessionBefore(R.sessionId,R.beforeSessionId)}catch(U){if(!(U instanceof O0))throw U;return ke(I,{code:"workspace-move-invalid",message:U.message,details:{workspaceId:R.workspaceId,sessionId:R.sessionId,...R.beforeSessionId===void 0?{}:{beforeSessionId:R.beforeSessionId}}})}return yt(I,{workspace:cp(C)})},async archiveSession(I){let{sessionId:R}=I.payload;try{await e.workspaceRegistry.archiveSession(R)}catch(C){if(!(C instanceof v7))throw C;return ke(I,{code:"session-not-found",message:C.message,details:{sessionId:R}})}return yt(I,{archivedSessionIds:[...e.workspaceRegistry.archivedSessionIds]})}},host:{describe(I){let R=t.defaultModelSelection();return Promise.resolve(yt(I,{version:"0.0.1",cwd:t.cwd,provider:R.provider,model:R.model,attachedSessions:e.agents.list().length,home:Mke(),canOpenPath:Pe()}))},async pickDirectory(I,R){let C=e.directoryPicker.capability();if(C.kind!=="native")return ke(I,{code:"directory-picker-unavailable",message:`host.pickDirectory needs the native capability; the composed picker serves "${C.kind}"`,details:{capability:C.kind}});try{return yt(I,{path:await C.pick(R)})}catch(U){return R.aborted?ke(I,{code:"cancelled",message:"directory picker was aborted",details:{}}):ke(I,{code:"internal",message:`directory picker failed: ${U instanceof Error?U.message:String(U)}`,details:{}})}},async listDirectory(I,R){let C=e.directoryPicker.capability();if(C.kind!=="browse")return ke(I,{code:"directory-picker-unavailable",message:`host.listDirectory needs the browse capability; the composed picker serves "${C.kind}"`,details:{capability:C.kind}});try{return yt(I,await C.list(I.payload.path,R))}catch(U){return R.aborted?ke(I,{code:"cancelled",message:"directory listing was aborted",details:{}}):ke(I,dK(U))}},async createDirectory(I){let R=e.directoryPicker.capability();if(R.kind!=="browse")return ke(I,{code:"directory-picker-unavailable",message:`host.createDirectory needs the browse capability; the composed picker serves "${R.kind}"`,details:{capability:R.kind}});try{return yt(I,{path:await R.createDirectory(I.payload.path,I.payload.name)})}catch(C){return ke(I,dK(C))}},async openPath(I,R){return Fe(I,I.payload.path,R)}},goals:{async create(I){let{objective:R,maxGoalRounds:C}=I.payload;return ue(I,(U,K)=>U.create(K,{objective:R,...C!==void 0?{maxGoalRounds:C}:{}}))},async edit(I){let{ref:R,objective:C,maxGoalRounds:U}=I.payload;return ue(I,(K,J)=>K.edit(J,R,{...C!==void 0?{objective:C}:{},...U!==void 0?{maxGoalRounds:U}:{}}))},async pause(I){return ue(I,(R,C)=>R.pause(C,I.payload.ref))},async resume(I){return ue(I,(R,C)=>R.resume(C,I.payload.ref))},async complete(I){return ue(I,(R,C)=>R.complete(C,I.payload.ref))},async clear(I){let R=await S(I.payload.sessionId);if("error"in R)return ke(I,R.error);let C=G(R.agent);if("error"in C)return ke(I,C.error);try{return C.clear(R.agent,I.payload.ref),yt(I,{cleared:!0})}catch(U){return Z(I,U)}}},agentPresets:{async list(I){let R=e.get("agentPresets");if(R===void 0)return yt(I,{presets:[],authorable:!1,hasDocument:!1});let C=R.defaultId;return yt(I,{presets:(await R.list()).map(U=>({id:U.id,trust:U.trust,isDefault:U.id===C,...U.name===void 0?{}:{name:U.name},...U.description===void 0?{}:{description:U.description},...U.broken===void 0?{}:{broken:U.broken}})),authorable:R.authorable,hasDocument:Pe()})},async select(I){let{sessionId:R,agentPreset:C}=I.payload,U=e.get("agentPresets");if(U===void 0)return ke(I,{code:"agent-preset-not-found",message:"this deployment composes no agent presets",details:{agentPreset:C,available:[]}});let K=await S(R);if("error"in K)return ke(I,K.error);let{agent:J}=K,j=l(async()=>{if(!n8(J.session))return ke(I,{code:"agent-preset-locked",message:`session "${R}" has already started; its agent preset is fixed`,details:{sessionId:R,agentPreset:C}});try{let ne=await U.recompose(J.ctx,C);return J.session.append("agent-preset/selected",{agentPreset:ne.id}),yt(I,{agentPreset:ne.id})}catch(ne){let Ee=lK(I,ne);return Ee!==void 0?Ee:ke(I,{code:"internal",message:`failed to select agent preset "${C}": ${String(ne)}`,details:{}})}},"swap"),oe=(o.get(R)??Promise.resolve()).then(j);o.set(R,oe.catch(()=>{}));try{return await oe}finally{o.get(R)===oe&&o.delete(R)}},async read(I){let{agentPreset:R}=I.payload,C=e.get("agentPresets");if(C===void 0)return ke(I,K0(R));try{let U=await C.resolve(R);return yt(I,{agentPreset:U.id,trust:U.trust,content:await C.read(U.id),...U.name===void 0?{}:{name:U.name},...U.description===void 0?{}:{description:U.description}})}catch(U){return ke(I,Y0(R,U))}},async copy(I){let{from:R,agentPreset:C,name:U}=I.payload,K=e.get("agentPresets");if(K===void 0)return ke(I,K0(C));try{return await K.copy(R,C,U),yt(I,{agentPreset:C})}catch(J){return ke(I,Y0(C,J))}},async openDocument(I,R){let{agentPreset:C}=I.payload,U=e.get("agentPresets");if(U===void 0)return ke(I,K0(C));try{let K=await U.resolve(C);if(K.trust!=="user")throw new hu(K.id,"it ships with the deployment");let J=Uke(K.path);return Pe()?await Fe(I,J,R):yt(I,{opened:!1,path:J})}catch(K){return ke(I,Y0(C,K))}},async remove(I){let{agentPreset:R}=I.payload,C=e.get("agentPresets");if(C===void 0)return ke(I,K0(R));try{return await C.remove(R),yt(I,{})}catch(U){return ke(I,Y0(R,U))}}},skills:{async list(I){let{sessionId:R}=I.payload,C=e.sessions.get(R);if(C===void 0)return ke(I,{code:"session-not-found",message:`session "${R}" not found (not attached)`,details:{sessionId:R}});if(C.header.cwd===void 0)return ke(I,{code:"internal",message:`session "${R}" has no project cwd`,details:{}});let U=C.header.cwd,K=e.agents.get(R),J=e.get("agentPresets"),j=(K===void 0?void 0:J?.serviceFor(K,"skills"))??e.get("skills");if(j===void 0)return ke(I,{code:"internal",message:"skill registry is absent: neither this session's agent preset nor the host composition mounts @deepseek-ai/dsh-skill",details:{}});let oe=await W(R,C);try{return yt(I,{skills:(await j.list({cwd:U,scope:oe})).filter(gV).map(ne=>({name:ne.name,description:ne.description,...ne.whenToUse===void 0?{}:{whenToUse:ne.whenToUse},modelInvocable:ne.invocation.modelInvocable}))})}catch(ne){return ke(I,{code:"internal",message:`skill listing failed: ${String(ne)}`,details:{}})}}},settings:{describe(I){let R=e.get("settings");return R===void 0?Promise.resolve(ke(I,V())):Promise.resolve(yt(I,{writable:R.writable,hasDocument:R.documentPath!==void 0,namespaces:R.describe({redactSecrets:!0}).map(Le)}))},async openDocument(I,R){let C=e.get("settings");if(C===void 0)return ke(I,V());if(go(R))return ke(I,{code:"cancelled",message:"settings document open was aborted",details:{}});let U;try{U=await C.prepareDocument()}catch(K){return go(R)?ke(I,{code:"cancelled",message:"settings document preparation was aborted",details:{}}):ke(I,{code:"internal",message:`settings document preparation failed: ${K instanceof Error?K.message:String(K)}`,details:{}})}return U===void 0?ke(I,{code:"internal",message:"settings provider has no local document to open",details:{}}):go(R)?ke(I,{code:"cancelled",message:"settings document open was aborted",details:{}}):Ce(I,U,R)},update:l(I=>de(I,I.payload.ns,"update",I.payload.patch,I.payload.expectedRevision),"update"),replace:l(I=>de(I,I.payload.ns,"replace",I.payload.section,I.payload.expectedRevision),"replace"),mutate:l(I=>de(I,I.payload.ns,"mutate",I.payload.ops,I.payload.expectedRevision),"mutate")},credentials:{async describe(I){let R=e.get("credentials");if(R===void 0)return ke(I,Re());let C=await Promise.all(I.payload.refs.map(async U=>{let K=await R.describe(jn(U));return[U,{configured:K.configured,...K.source===void 0?{}:{source:K.source},writable:K.writable}]}));return yt(I,{credentials:Object.fromEntries(C)})},async set(I){let R=e.get("credentials");if(R===void 0)return ke(I,Re());let{ref:C,value:U}=I.payload;try{await R.set(jn(C),U)}catch(K){return ke(I,{code:"credential-rejected",message:K instanceof Error?K.message:String(K),details:{ref:C}})}return yt(I,{})},async unset(I){let R=e.get("credentials");if(R===void 0)return ke(I,Re());let{ref:C}=I.payload;try{await R.unset(jn(C))}catch(U){return ke(I,{code:"credential-rejected",message:U instanceof Error?U.message:String(U),details:{ref:C}})}return yt(I,{})}},llm:{providers(I){let R=e.llm.listProviders(),C=new Set(R.map(j=>j.id)),U=e.llm.listConfigurableProviders(),K=new Set(U.map(j=>j.provider)),J=U.map(j=>({provider:j.provider,displayName:j.displayName,settingsNs:j.settingsNs,settingsPath:[...j.settingsPath],active:C.has(j.provider),...j.declared===void 0?{}:{declared:j.declared}}));for(let j of R)K.has(j.id)||J.push({provider:j.id,displayName:j.name,settingsNs:"",settingsPath:[],active:!0});return Promise.resolve(yt(I,{providers:J}))},async models(I){return yt(I,await aK(e))},async discoverModels(I,R){let{settingsNs:C,provider:U,baseURL:K,api:J,apiKey:j}=I.payload;try{return yt(I,{models:await e.llm.discoverModels(C,{...U===void 0?{}:{provider:U},...K===void 0?{}:{baseURL:K},...J===void 0?{}:{api:J},...j===void 0?{}:{apiKey:j},...R===void 0?{}:{signal:R}})})}catch(oe){return ke(I,{code:"model-discovery-failed",message:oe instanceof Error?oe.message:String(oe),details:{settingsNs:C,...K===void 0?{}:{baseURL:K}}})}}},events:{mux(I,R){let C=new cK;f.add(C);for(let j of e.sessions.list())uK(C,j);for(let j of u.values())C.push({rpcId:j.rpcId,payload:{type:"question/requested",sessionId:j.sessionId,questions:j.questions}});for(let j of d.values())C.push(fK(j));for(let j of e.sessions.list()){let oe=e.agents.get(j.id);oe?.session===j&&oe.inbox.hasPending&&C.push(en({type:"session/queue",sessionId:j.id,items:$(oe)}))}let U=e.get("jobs");if(U!==void 0)for(let j of e.sessions.list()){let oe=Z0(U.list(e.agents.get(j.id)));oe.length>0&&C.push(en({type:"session/jobs",sessionId:j.id,jobs:oe}))}let K=new Map,J=[e.on("session/event",(j,oe)=>{if(oe.type==="tool/call"){let Ee=oe.data;try{let We=K.get(j.id);We===void 0&&K.set(j.id,We=new Map),We.set(Ee.callId,{name:Ee.name,args:JSON.parse(Ee.arguments)})}catch{}}else oe.type==="turn/end"&&K.delete(j.id);let ne=WK(e,oe,Ee=>K.get(j.id)?.get(Ee)??qK(j.events,Ee),e.agents.get(j.id));C.push(en({type:"session/event",sessionId:j.id,event:oe,...ne===void 0?{}:{view:ne}}))}),e.on("session/created",j=>{uK(C,j);let oe=U===void 0?[]:Z0(U.list(e.agents.get(j.id)));oe.length>0&&C.push(en({type:"session/jobs",sessionId:j.id,jobs:oe}))}),e.on("session/disposed",j=>{K.delete(j.id)}),...U===void 0?[]:[U.onJobsChanged(j=>{if(j!==void 0){C.push(en({type:"session/jobs",sessionId:j.id,jobs:Z0(U.list(j))}));return}for(let oe of e.sessions.list())C.push(en({type:"session/jobs",sessionId:oe.id,jobs:Z0(U.list(e.agents.get(oe.id)))}))})]];return C.iterate(R,()=>{f.delete(C);for(let j of J)j()})},host(I,R){let C=new cK,U=e.workspaceRegistry.list(),K=new Set(U.map(ne=>String(ne.id))),J=U.map(ne=>ne.id),j=e.workspaceRegistry.archivedSessionIds,oe=[e.on("session/created",ne=>{C.push(en({type:"host/session-added",sessionId:ne.id,blank:n8(ne),...c8(ne.header,ne.events)}))}),e.on("session/disposed",ne=>{C.push(en({type:"host/session-removed",sessionId:ne.id}))}),e.on("agent/status",({agent:ne,status:Ee})=>{C.push(en({type:"host/session-status",sessionId:ne.id,running:Ee==="running"}))}),e.on("agent/error",({agent:ne,error:Ee})=>{C.push(en({type:"host/agent-error",sessionId:ne.id,message:$o(Ee)}))}),e.on("domain/changed",ne=>{if(ne.domain==="workspace"){if(ne.table===""){if(ne.operation!=="put")return;let Ee=y7.parse(ne.value),We=Ee.workspaceIds.length===J.length&&Ee.workspaceIds.every($e=>K.has(String($e)))&&Ee.workspaceIds.some(($e,He)=>$e!==J[He]);for(let $e of Ee.workspaceIds){if(K.has($e))continue;let He=e.workspaceRegistry.get($e);if(He===void 0)throw new Error(`committed workspace registry references missing workspace "${$e}"`);K.add($e),C.push(en({type:"host/workspace-changed",workspace:cp(He)}))}J=[...Ee.workspaceIds],We&&C.push(en({type:"host/workspace-order-changed",workspaceIds:[...Ee.workspaceIds]})),(Ee.archivedSessionIds.length!==j.length||Ee.archivedSessionIds.some(($e,He)=>$e!==j[He]))&&(j=Ee.archivedSessionIds,C.push(en({type:"host/archived-sessions-changed",archivedSessionIds:[...Ee.archivedSessionIds]})));return}if(ne.table==="workspaces"){if(ne.operation==="deleted"){if(!K.delete(ne.key))return;C.push(en({type:"host/workspace-removed",workspaceId:ne.key}));return}K.has(ne.key)&&C.push(en({type:"host/workspace-changed",workspace:H4e(ne.key,ne.value)}))}}}),...QZ.map(ne=>e.on(ne,((...Ee)=>{C.push(en({type:"host/remote-event",event:ne,args:U4e(ne,Ee)}))})))];return C.iterate(R,()=>{for(let ne of oe)ne()})}},downloads:{async sessionLog(I,R){let C=zke(e);if(C.sessionQuery===void 0||C.sessionPersistence===void 0||C.attachments===void 0)return new Response("session log export is unavailable: missing session-query, session-persistence, or attachments service",{status:500});if(!C.sessionPersistence.supportsRawArtifacts)return new Response("session log export is unavailable: the persistence backend does not expose per-session raw artifacts",{status:501});let U={sessionQuery:C.sessionQuery,sessionPersistence:C.sessionPersistence,attachments:C.attachments,sessions:C.sessions},K;try{await kK(C,I.sessionId,R),K=await C.sessionPersistence.readRaw(I.sessionId,R),R.throwIfAborted()}catch{return R.throwIfAborted(),new Response("session log export failed to prepare the stored artifact",{status:500})}return K===void 0?new Response("session not found",{status:404}):new Response(e4e(U,K,I.sessionId,I.includeDescendants===!0,r,R),{headers:{"content-type":"application/zip","content-disposition":`attachment; filename="${Gke(I.sessionId)}"`}})}},respond(I){let R=d.get(I.rpcId);if(R!==void 0){if(!I.result.ok)return Promise.resolve({accepted:!1,reason:"bad-response"});let J=x4e.safeParse(I.result.value);return!J.success||J.data.approvalId!==R.approvalId||J.data.sessionId!==R.sessionId?Promise.resolve({accepted:!1,reason:"bad-response"}):(R.resolve(J.data.outcome),Promise.resolve({accepted:!0}))}let C=u.get(I.rpcId);if(C===void 0)return Promise.resolve({accepted:!1,reason:"not-pending"});if(!I.result.ok)return I.result.error.code!=="cancelled"?Promise.resolve({accepted:!1,reason:"bad-response"}):(O(C,"cancelled"),C.reject(new lp("the user cancelled ask_user_question","ASK_CANCELLED")),Promise.resolve({accepted:!0}));let U=S4e.safeParse(I.result.value);if(!U.success)return Promise.resolve({accepted:!1,reason:"bad-response"});let K={sessionId:U.data.sessionId,answer:{answers:U.data.answer.answers.map(J=>({id:J.id,selected:J.selected,...J.custom===void 0?{}:{custom:J.custom}}))}};return W4e(K,C)?(O(C,"answered"),C.resolve(K.answer),Promise.resolve({accepted:!0})):Promise.resolve({accepted:!1,reason:"bad-response"})}}}l(G4e,"createApiProxy");var V4e=v.object({sessionId:ct,includeDescendants:v.union([v.literal("true"),v.literal("false")]).optional()}).transform(e=>({sessionId:e.sessionId,...e.includeDescendants==="true"?{includeDescendants:!0}:{}})),dp=v.string(),u8=v.discriminatedUnion("code",[v.object({code:v.literal("bad-request"),message:v.string(),details:v.object({issues:v.array(v.custom())})}),v.object({code:v.literal("cancelled"),message:v.string(),details:v.object({})}),v.object({code:v.literal("session-not-found"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("model-unavailable"),message:v.string(),details:v.object({provider:v.string(),model:v.string()})}),v.object({code:v.literal("session-conflict"),message:v.string(),details:v.object({sessionId:v.string(),requestedCwd:v.string(),existingCwd:v.string().optional()})}),v.object({code:v.literal("invalid-time-zone"),message:v.string(),details:v.object({value:v.string()})}),v.object({code:v.literal("workspace-attach-failed"),message:v.string(),details:v.object({sessionId:v.string(),workspaceId:v.string()})}),v.object({code:v.literal("workspace-not-found"),message:v.string(),details:v.object({workspaceId:v.string()})}),v.object({code:v.literal("workspace-invalid-path"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("workspace-name-conflict"),message:v.string(),details:v.object({name:v.string()})}),v.object({code:v.literal("workspace-move-invalid"),message:v.string(),details:v.object({workspaceId:v.string(),sessionId:v.string(),beforeSessionId:v.string().optional()})}),v.object({code:v.literal("directory-unreadable"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-exists"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-create-failed"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-picker-unavailable"),message:v.string(),details:v.object({capability:v.string()})}),v.object({code:v.literal("agent-preset-read-only"),message:v.string(),details:v.object({agentPreset:v.string(),reason:v.string()})}),v.object({code:v.literal("agent-preset-locked"),message:v.string(),details:v.object({sessionId:v.string(),agentPreset:v.string()})}),v.object({code:v.literal("agent-preset-conflict"),message:v.string(),details:v.object({sessionId:v.string(),requestedPreset:v.string(),existingPreset:v.string().optional()})}),v.object({code:v.literal("agent-preset-not-found"),message:v.string(),details:v.object({agentPreset:v.string(),available:v.array(v.string())})}),v.object({code:v.literal("agent-preset-invalid"),message:v.string(),details:v.object({agentPreset:v.string(),reason:v.string()})}),v.object({code:v.literal("agent-busy"),message:v.string(),details:v.object({reason:v.string()})}),v.object({code:v.literal("attachment-error"),message:v.string(),details:v.object({reason:v.string()})}),v.object({code:v.literal("queue-item-not-found"),message:v.string(),details:v.object({itemId:v.string()})}),v.object({code:v.literal("steer-unavailable"),message:v.string(),details:v.object({itemId:v.string()})}),v.object({code:v.literal("command-error"),message:v.string(),details:v.object({})}),v.object({code:v.literal("unknown-command"),message:v.string(),details:v.object({})}),v.object({code:v.literal("settings-rejected"),message:v.string(),details:v.object({ns:v.string()})}),v.object({code:v.literal("settings-conflict"),message:v.string(),details:v.object({ns:v.string(),expected:v.number(),actual:v.number()})}),v.object({code:v.literal("credential-rejected"),message:v.string(),details:v.object({ref:v.string()})}),v.object({code:v.literal("model-discovery-failed"),message:v.string(),details:v.object({settingsNs:v.string(),baseURL:v.string().optional()})}),v.object({code:v.literal("title-invalid"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("fork-unavailable"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("subagent-parent-unavailable"),message:v.string(),details:v.object({parentSessionId:v.string()})}),v.object({code:v.literal("subagent-not-found"),message:v.string(),details:v.object({parentSessionId:v.string(),childSessionId:v.string()})}),v.object({code:v.literal("subagent-catalog-diagnostic"),message:v.string(),details:v.object({parentSessionId:v.string(),childSessionId:v.string(),reason:v.union([v.literal("corrupt"),v.literal("unsupported"),v.literal("unavailable")])})}),v.object({code:v.literal("subagent-not-resumable"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("subagent-unauthorized"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("subagent-delivery-unavailable"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("internal"),message:v.string(),details:v.object({})})]);function GK(e){return v.union([v.object({ok:v.literal(!0),value:e}),v.object({ok:v.literal(!1),error:u8})])}l(GK,"rpcResultSchema");var VK=v.object({type:v.literal("client-request"),rpcId:dp,method:v.string(),payload:v.unknown()}),Z4e=v.object({type:v.literal("server-response"),rpcId:dp,result:GK(v.unknown().optional())}),K4e=v.object({type:v.literal("server-request"),rpcId:dp,method:v.string(),payload:v.unknown()}),ZK=v.object({type:v.literal("client-response"),rpcId:dp,result:GK(v.unknown().optional())});v.discriminatedUnion("type",[VK,Z4e,K4e,ZK]);var YUe=v.union([v.object({accepted:v.literal(!0)}),v.object({accepted:v.literal(!1),reason:v.union([v.literal("not-pending"),v.literal("bad-response")])})]),Y4e=v.object({}),XUe=v.object({version:v.string(),cwd:v.string(),provider:v.string().optional(),model:v.string().optional(),attachedSessions:v.number().int().nonnegative(),home:v.string(),canOpenPath:v.boolean()}),X4e=v.object({}),JUe=v.object({path:v.string().nullable()}),xK=v.object({name:v.string(),path:v.string(),hidden:v.boolean()}),J4e=v.object({path:v.string().optional()}),QUe=v.object({path:v.string(),home:v.string(),crumbs:v.array(xK),entries:v.array(xK),truncated:v.boolean()}),Q4e=v.object({path:v.string(),name:v.string()}).refine(e=>e.name.trim()!==""&&e.name!=="."&&e.name!==".."&&!/[/\\]/.test(e.name),{message:"host.createDirectory requires a single non-blank path segment name"}),eje=v.object({path:v.string()}),eAe=v.object({path:v.string().min(1)}),tje=v.object({opened:v.literal(!0)}),fp=v.object({workspaceId:Ws,path:v.string(),title:v.string(),sessionIds:v.array(ct),createdAt:v.string(),updatedAt:v.string()}),tAe=v.object({}),rje=v.object({items:v.array(fp),archivedSessionIds:v.array(ct)}),rAe=v.object({path:v.string()}),nje=v.object({workspace:fp,created:v.boolean()}),nAe=v.object({workspaceId:Ws,title:v.string()}).refine(e=>e.title.trim()!=="",{message:"workspace.rename requires a non-blank title"}),ije=v.object({workspace:fp}),iAe=v.object({workspaceId:Ws}),sje=v.object({deleted:v.literal(!0)}),sAe=v.object({workspaceId:Ws,beforeWorkspaceId:Ws.optional()}),oje=v.object({workspaceIds:v.array(Ws)}),oAe=v.object({workspaceId:Ws,sessionId:ct,beforeSessionId:ct.optional()}),aje=v.object({workspace:fp}),aAe=v.object({sessionId:ct}),lje=v.object({archivedSessionIds:v.array(ct)}),lAe=v.object({name:v.string().min(1),description:v.string(),whenToUse:v.string().optional(),modelInvocable:v.boolean()}),cAe=v.object({sessionId:ct}),cje=v.object({skills:v.array(lAe)}),uAe=v.object({id:v.string().min(1),trust:v.union([v.literal("system"),v.literal("user")]),isDefault:v.boolean(),name:v.string().optional(),description:v.string().optional(),broken:v.string().min(1).optional()}),dAe=v.object({}),uje=v.object({presets:v.array(uAe),authorable:v.boolean(),hasDocument:v.boolean()}),fAe=v.object({sessionId:ct,agentPreset:v.string().min(1)}),dje=v.object({agentPreset:v.string()}),pAe=v.object({agentPreset:v.string().min(1)}),fje=v.object({agentPreset:v.string(),trust:v.union([v.literal("system"),v.literal("user")]),content:v.string(),name:v.string().optional(),description:v.string().optional()}),hAe=v.object({from:v.string().min(1),agentPreset:v.string().min(1),name:v.string().optional()}),pje=v.object({agentPreset:v.string()}),mAe=v.object({agentPreset:v.string().min(1)}),hje=v.union([v.object({opened:v.literal(!0)}),v.object({opened:v.literal(!1),path:v.string()})]),gAe=v.object({agentPreset:v.string().min(1)}),mje=v.object({}),yu=v.object({id:v.string(),revision:v.number().int().positive()}),gje=v.object({ref:yu}),yAe=v.object({sessionId:v.string(),objective:v.string().min(1),maxGoalRounds:v.number().int().positive().optional()});var vAe=v.object({sessionId:v.string(),ref:yu,objective:v.string().min(1).optional(),maxGoalRounds:v.number().int().positive().optional()}).refine(e=>e.objective!==void 0||e.maxGoalRounds!==void 0,{message:"goal.edit requires objective or maxGoalRounds"});var wAe=v.object({sessionId:v.string(),ref:yu});var bAe=v.object({sessionId:v.string(),ref:yu});var xAe=v.object({sessionId:v.string(),ref:yu});var EAe=v.object({sessionId:v.string(),ref:yu}),yje=v.object({cleared:v.literal(!0)}),SAe=v.object({path:v.array(v.string()),set:v.boolean()}),kAe=v.object({ns:v.string().min(1),schema:v.unknown(),value:v.unknown(),base:v.unknown().optional(),user:v.unknown().optional(),applies:v.union([v.literal("live"),v.literal("restart")]),secrets:v.array(SAe),revision:v.number()}),AAe=v.object({}),vje=v.object({writable:v.boolean(),hasDocument:v.boolean(),namespaces:v.array(kAe)}),IAe=v.object({}),wje=v.object({opened:v.literal(!0)}),$Ae=v.object({ns:v.string().min(1),patch:v.record(v.string(),v.unknown()),expectedRevision:v.number().optional()});var _Ae=v.object({ns:v.string().min(1),section:v.record(v.string(),v.unknown()),expectedRevision:v.number().optional()}),TAe=v.discriminatedUnion("op",[v.object({op:v.literal("set"),path:v.array(v.string()),value:v.unknown()}),v.object({op:v.literal("unset"),path:v.array(v.string())})]),CAe=v.object({ns:v.string().min(1),ops:v.array(TAe),expectedRevision:v.number().optional()});var d8=v.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),OAe=v.object({configured:v.boolean(),source:v.string().optional(),writable:v.boolean()}),NAe=v.object({refs:v.array(d8).max(64)}),bje=v.object({credentials:v.record(v.string(),OAe)}),RAe=v.object({ref:d8,value:v.string().min(1)}),xje=v.object({}),PAe=v.object({ref:d8}),Eje=v.object({}),DAe=v.object({provider:v.string().min(1),displayName:v.string().min(1),settingsNs:v.string(),settingsPath:v.array(v.string()),active:v.boolean(),declared:v.boolean().optional()}),LAe=v.object({}),Sje=v.object({providers:v.array(DAe)}),MAe=v.object({}),kje=v.object({groups:v.array(CK),failures:v.array(OK)}),FAe=v.object({id:v.string().min(1),name:v.string().min(1).optional(),contextWindow:v.number().int().positive().optional(),maxTokens:v.number().int().positive().optional()}),UAe=v.object({settingsNs:v.string().min(1),provider:v.string().min(1).optional(),baseURL:v.string().min(1).optional(),api:v.string().min(1).optional(),apiKey:v.string().min(1).optional()}),Aje=v.object({models:v.array(FAe)}),jAe=v.union([v.object({kind:v.literal("child"),id:ct,mode:v.literal("one-shot"),activity:v.union([v.literal("running"),v.literal("inactive")]),hasChildren:v.boolean(),label:v.string().optional()}),v.object({kind:v.literal("child"),id:ct,mode:v.literal("continuable"),activity:v.union([v.literal("running"),v.literal("inactive")]),hasChildren:v.boolean(),label:v.string()}),v.object({kind:v.literal("diagnostic"),id:ct,reason:v.union([v.literal("corrupt"),v.literal("unsupported"),v.literal("unavailable")])})]),zAe=v.object({parentSessionId:ct}),Ije=v.object({entries:v.array(jAe),parentAvailable:v.boolean()}),BAe=v.object({parentSessionId:ct,childSessionId:ct,mode:v.union([v.literal("one-shot"),v.literal("continuable")]),beforeSeq:v.number().int().nonnegative().optional(),maxMessages:v.number().int().positive().optional()}),$je=v.object({events:v.array(RK),hasMore:v.boolean(),projections:a8.optional()}),WAe=v.object({parentSessionId:ct,childSessionId:ct,mode:v.literal("continuable"),content:v.array(l8),clientTimeZone:v.string().optional()}),qAe=v.object({parentSessionId:ct,childSessionId:ct,mode:v.literal("continuable")}),_je=v.object({accepted:v.literal(!0)}),HAe=v.string(),Tje=v.object({messageId:HAe}),KK={"session.list":{schema:r4e,invoke:l((e,t)=>e.sessions.list(t),"invoke")},"session.search":{schema:n4e,invoke:l((e,t,r)=>e.sessions.search(t,r),"invoke")},"session.create":{schema:s4e,invoke:l((e,t)=>e.sessions.create(t),"invoke")},"session.history":{schema:l4e,invoke:l((e,t)=>e.sessions.history(t),"invoke")},"session.models":{schema:p4e,invoke:l((e,t)=>e.sessions.models(t),"invoke")},"session.selectModel":{schema:h4e,invoke:l((e,t)=>e.sessions.selectModel(t),"invoke")},"session.rename":{schema:o4e,invoke:l((e,t)=>e.sessions.rename(t),"invoke")},"session.fork":{schema:a4e,invoke:l((e,t)=>e.sessions.fork(t),"invoke")},"session.prompt":{schema:g4e,invoke:l((e,t)=>e.sessions.prompt(t),"invoke")},"session.attachment":{schema:v4e,invoke:l((e,t)=>e.sessions.attachment(t),"invoke")},"session.updateQueue":{schema:w4e,invoke:l((e,t)=>e.sessions.updateQueue(t),"invoke")},"session.cancel":{schema:b4e,invoke:l((e,t)=>e.sessions.cancel(t),"invoke")},"subagent.list":{schema:zAe,invoke:l((e,t,r)=>e.subagents.list(t,r),"invoke")},"subagent.history":{schema:BAe,invoke:l((e,t,r)=>e.subagents.history(t,r),"invoke")},"subagent.prompt":{schema:WAe,invoke:l((e,t,r)=>e.subagents.prompt(t,r),"invoke")},"subagent.interrupt":{schema:qAe,invoke:l((e,t)=>e.subagents.interrupt(t),"invoke")},"host.describe":{schema:Y4e,invoke:l((e,t)=>e.host.describe(t),"invoke")},"host.pickDirectory":{schema:X4e,invoke:l((e,t,r)=>e.host.pickDirectory(t,r),"invoke")},"host.listDirectory":{schema:J4e,invoke:l((e,t,r)=>e.host.listDirectory(t,r),"invoke")},"host.createDirectory":{schema:Q4e,invoke:l((e,t)=>e.host.createDirectory(t),"invoke")},"host.openPath":{schema:eAe,invoke:l((e,t,r)=>e.host.openPath(t,r),"invoke")},"workspace.list":{schema:tAe,invoke:l((e,t)=>e.workspace.list(t),"invoke")},"workspace.create":{schema:rAe,invoke:l((e,t)=>e.workspace.create(t),"invoke")},"workspace.rename":{schema:nAe,invoke:l((e,t)=>e.workspace.rename(t),"invoke")},"workspace.delete":{schema:iAe,invoke:l((e,t)=>e.workspace.delete(t),"invoke")},"workspace.insertBefore":{schema:sAe,invoke:l((e,t)=>e.workspace.insertBefore(t),"invoke")},"workspace.insertSessionBefore":{schema:oAe,invoke:l((e,t)=>e.workspace.insertSessionBefore(t),"invoke")},"workspace.archiveSession":{schema:aAe,invoke:l((e,t)=>e.workspace.archiveSession(t),"invoke")},"skill.list":{schema:cAe,invoke:l((e,t)=>e.skills.list(t),"invoke")},"agentPreset.list":{schema:dAe,invoke:l((e,t)=>e.agentPresets.list(t),"invoke")},"agentPreset.select":{schema:fAe,invoke:l((e,t)=>e.agentPresets.select(t),"invoke")},"agentPreset.read":{schema:pAe,invoke:l((e,t)=>e.agentPresets.read(t),"invoke")},"agentPreset.copy":{schema:hAe,invoke:l((e,t)=>e.agentPresets.copy(t),"invoke")},"agentPreset.openDocument":{schema:mAe,invoke:l((e,t,r)=>e.agentPresets.openDocument(t,r),"invoke")},"agentPreset.remove":{schema:gAe,invoke:l((e,t)=>e.agentPresets.remove(t),"invoke")},"goal.create":{schema:yAe,invoke:l((e,t)=>e.goals.create(t),"invoke")},"goal.edit":{schema:vAe,invoke:l((e,t)=>e.goals.edit(t),"invoke")},"goal.pause":{schema:wAe,invoke:l((e,t)=>e.goals.pause(t),"invoke")},"goal.resume":{schema:bAe,invoke:l((e,t)=>e.goals.resume(t),"invoke")},"goal.complete":{schema:xAe,invoke:l((e,t)=>e.goals.complete(t),"invoke")},"goal.clear":{schema:EAe,invoke:l((e,t)=>e.goals.clear(t),"invoke")},"settings.describe":{schema:AAe,invoke:l((e,t)=>e.settings.describe(t),"invoke")},"settings.openDocument":{schema:IAe,invoke:l((e,t,r)=>e.settings.openDocument(t,r),"invoke")},"settings.update":{schema:$Ae,invoke:l((e,t)=>e.settings.update(t),"invoke")},"settings.replace":{schema:_Ae,invoke:l((e,t)=>e.settings.replace(t),"invoke")},"settings.mutate":{schema:CAe,invoke:l((e,t)=>e.settings.mutate(t),"invoke")},"credentials.describe":{schema:NAe,invoke:l((e,t)=>e.credentials.describe(t),"invoke")},"credentials.set":{schema:RAe,invoke:l((e,t)=>e.credentials.set(t),"invoke")},"credentials.unset":{schema:PAe,invoke:l((e,t)=>e.credentials.unset(t),"invoke")},"llm.providers":{schema:LAe,invoke:l((e,t)=>e.llm.providers(t),"invoke")},"llm.models":{schema:MAe,invoke:l((e,t)=>e.llm.models(t),"invoke")},"llm.discoverModels":{schema:UAe,invoke:l((e,t,r)=>e.llm.discoverModels(t,r),"invoke")}};function GAe(e){return Object.hasOwn(KK,e)?e:void 0}l(GAe,"methodFor");var VAe="invalid-request";function o8(e,t){let r={type:"server-response",rpcId:e,result:{ok:!1,error:t}};return Response.json(r)}l(o8,"errorResponse");function ZAe(e){let t={type:"server-response",rpcId:e.rpcId,result:e.result};return Response.json(t)}l(ZAe,"fullResponse");async function KAe(e,t,r,n){let i=KK[t],s=i.schema.safeParse(r.payload);if(!s.success)return o8(r.rpcId,{code:"bad-request",message:`invalid payload for ${t}`,details:{issues:s.error.issues}});try{return ZAe(await i.invoke(e,{rpcId:r.rpcId,payload:s.data},n))}catch(o){return new Response(`handler failure: ${String(o)}`,{status:500})}}l(KAe,"handleUnary");function EK(e){return{type:"server-request",rpcId:e.rpcId,method:e.payload.type,payload:e.payload}}l(EK,"fullFrame");function SK(e){let t=new TextEncoder,r=new ReadableStream({async start(n){try{n.enqueue(t.encode(`: connected
|
|
2344
|
+
`)}`);let c=cke(e,o);if(c.length>0)throw new Error(`row(s) published process-global service(s) [${c.join(", ")}]; a preset service must sit behind an \`isolate\` realm or move to the host composition`);j0.add({presetId:t.id,fiber:o,key:pn(e)})}catch(i){try{await n.dispose()}catch{}throw new ap(t.id,`${zZ(i)} (${t.path})`,{cause:i})}}l(fke,"mountPreset");function ua(e){for(let t=e.events.length-1;t>=0;t-=1){let r=e.events[t];if(r?.type==="agent-preset/selected")return r.data.agentPreset}return e.header.agentPreset}l(ua,"resolveSessionPreset");var $Z="agent-presets",pke=re.object({default:re.string()}),AFe=class extends ut{static{l(this,"AgentPresets")}config;static inject=["loader"];static Config=re.object({default:re.string().required(),roots:re.array(re.object({path:re.string().required(),trust:re.union(["system","user"]).default("user")})).default([]),includeUserRoot:re.boolean().default(!0)});resolvedRoots;settings;settingsService;selfCtx;constructor(e,t){super(e,"agentPresets"),this.config=t,this.selfCtx=e,this.resolvedRoots=t.includeUserRoot?[...t.roots,{path:mC(J6e),trust:"user"}]:[...t.roots],e.inject(["settings"],r=>{this.settings=r.settings.register(hn($Z),pke,{base:{default:t.default}}),this.settingsService=r.settings,r.effect(()=>()=>{this.settings=void 0,this.settingsService=void 0},"agentPresets.settings()")}),e.on("agent/created",({agent:r})=>{this.resolvedRoots.length!==0&&this.composedPreset(r.ctx)===void 0&&e.logger.warn(`agent "${r.id}" was published without joining an agent preset; its tools, prompt sections, and skill catalog resolve against the empty global layer (join through AgentPresets.mount() or composeFrom() in the agent factory setup)`)}),e.on("session/event",(r,n)=>{n.type==="agent-preset/selected"&&e.emit("agent-preset/selected",r.id,n.data.agentPreset)})}get defaultId(){return this.settings?.get().default??this.config.default}async list(){return await rke(this.resolvedRoots)}async resolve(e){let t=e??this.defaultId,r=await this.list(),n=r.find(i=>i.id===t);if(n===void 0)throw new B0(t,r.map(i=>i.id));return n}async resolveMountable(e){let t=await this.resolve(e);if(t.broken!==void 0)throw new ap(t.id,t.broken);return t}standing=new Map;bindings=new WeakMap;async mount(e,t){let r=pn(e);if(r===void 0)throw new Error("agent-presets: refusing to compose an unscoped context; the scope key is what joins an agent to its preset");let n=await this.resolveMountable(t),i=await this.ensureStanding(n);return this.bindings.set(r,ju(r,i.key)),n}composeFrom(e,t){let r=pn(e);if(r===void 0)throw new Error("agent-presets: refusing to compose an unscoped context; the scope key is what joins an agent to its preset");let n=K7(t);if(n!==void 0)return this.bindings.set(r,ju(r,n.key)),n.presetId}composedPreset(e){return K7(e)?.presetId}get roots(){return this.resolvedRoots}get authorable(){return this.resolvedRoots.some(e=>e.trust==="user")}async read(e){return await nke(await this.resolve(e))}async copy(e,t,r){let n=await this.resolve(e);if((await this.list()).some(i=>i.id===t))throw new W0(t);await ske(this.resolvedRoots,n,t,r),this.standing.delete(t)}async remove(e){await oke(this.resolvedRoots,await this.resolve(e)),this.standing.delete(e),this.settings?.get().default===e&&await this.settingsService?.mutate(hn($Z),[{op:"unset",path:["default"]}])}serviceFor(e,t){return uke(this.ctx,e,t)}async recompose(e,t){let r=pn(e);if(r===void 0)throw new Error("agent-presets: refusing to recompose an unscoped context");let n=await this.resolveMountable(t),i=await this.ensureStanding(n),s=this.bindings.get(r);return s===void 0?this.bindings.set(r,ju(r,i.key)):s.rebind(i.key),n}async standingKeyFor(e){let t=await this.resolveMountable(e);return(await this.ensureStanding(t)).key}async ensureStanding(e){let t=this.standing.get(e.id);if(t!==void 0){let n=await t,i=await _Z(e.path);return i===void 0||hke(n.stamp,i)?n:(this.standing.get(e.id)===t&&this.standing.delete(e.id),this.ensureStanding(e))}let r=(async()=>{let n={agentPreset:e.id},i=qp(this.selfCtx,n);try{let s=await _Z(e.path);if(s===void 0)throw new ap(e.id,`composition file is unreadable: ${e.path}`);return await fke(i.ctx,e),{key:n,scope:i,stamp:s}}catch(s){throw this.standing.delete(e.id),await i.dispose(),s}})();return this.standing.set(e.id,r),r}};async function _Z(e){try{let{mtimeMs:t,size:r}=await z0(e);return{mtimeMs:t,size:r}}catch{return}}l(_Z,"compositionStamp");function hke(e,t){return e.mtimeMs===t.mtimeMs&&e.size===t.size}l(hke,"sameStamp");import{randomUUID as bke}from"node:crypto";var mke=/^[A-Za-z0-9_$.-]+$/;function gke(e){return e!=="."&&e!==".."&&mke.test(e)}l(gke,"isTypertRemoteSegment");var qZ=class extends Error{static{l(this,"TypertLookupFailure")}failure;constructor(e){super("Typert lookup policy rejected the requested identity"),this.name="TypertLookupFailure",this.failure=e}},BZ=new WeakMap;function yke(e,t,r={}){Q7("service key",t);let n=r.namespace??t;return Q7("namespace",n),Object.freeze({service:e,serviceKey:t,namespace:n})}l(yke,"bindTypertRemote");var HZ=class extends ut{static{l(this,"TypertRemoteService")}typertRemote;constructor(e,t,r={}){super(e,t),this.typertRemote=yke(this,this.name,r)}};function Al(e,t){if(typeof e=="string")return Q7("Remote export name",e),function(r,n){WZ(n,{kind:"direct"},e)};if(t===void 0)throw new TypeError("typert-protocol: Remote decorator context is missing");WZ(t,{kind:"direct"})}l(Al,"Remote");function WZ(e,t,r){if(e.private||e.static||typeof e.name!="string")throw new TypeError("typert-protocol: Remote decorators require a public instance method with a string name");let n=e.name;e.addInitializer(function(){let i=Object.getPrototypeOf(this);if(i===null)throw new TypeError(`typert-protocol: cannot mark Remote method "${n}" on an object without a prototype`);vke(i,n,t,r)})}l(WZ,"addMarkerInitializer");function vke(e,t,r,n){let i=BZ.get(e);i===void 0&&(i=new Map,BZ.set(e,i));let s={...n===void 0||n===t?{}:{exportName:n},invocation:Object.freeze(r)},o=i.get(t);if(o!==void 0){if(o.exportName===s.exportName&&wke(o.invocation,r))return;throw new Error(`typert-protocol: Remote method "${t}" has conflicting invocation markers`)}i.set(t,Object.freeze(s))}l(vke,"mark");function wke(e,t){return e.kind===t.kind&&(e.kind==="direct"||t.kind==="context"&&e.context===t.context)}l(wke,"sameInvocation");function Q7(e,t){if(!gke(t))throw new TypeError(`typert-protocol: ${e} must contain only RPC endpoint segment characters`)}l(Q7,"validateName");var hi=class extends Wr{static{l(this,"GoalError")}constructor(e,t){super(e,t)}},xke=new Set(["create","edit","pause","resume","complete","block"]),Eke=new Set(["active","paused","blocked","complete"]);function Ske(){return{goal:void 0,roundsStarted:0,createdAt:void 0,updatedAt:void 0,lastRef:void 0,seenGoalIds:new Set}}l(Ske,"emptyGoalFoldState");function G0(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}l(G0,"isRecord");function e8(e,t){if(typeof e!="number"||!Number.isSafeInteger(e)||e<1)throw new Error(`goal change ${t} must be a positive safe integer`);return e}l(e8,"positiveInteger");function q0(e,t){if(typeof e!="number"||!Number.isSafeInteger(e)||e<0)throw new Error(`goal change ${t} must be a non-negative safe integer`);return e}l(q0,"nonNegativeInteger");function kke(e){if(!G0(e)||Object.keys(e).sort().join(",")!=="code,message")throw new Error("goal change goal.blockedReason must have exactly code and message fields");if(typeof e.code!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(e.code))throw new Error("goal change goal.blockedReason.code must be lower-kebab-case");if(typeof e.message!="string"||e.message.trim().length===0||e.message!==e.message.trim())throw new Error("goal change goal.blockedReason.message must be non-empty and normalized");return{code:e.code,message:e.message}}l(kke,"decodeBlockReason");function Ake(e){if(!G0(e))throw new Error("goal change goal must be a record");if(typeof e.id!="string"||e.id.length===0)throw new Error("goal change goal.id must be a non-empty string");if(typeof e.objective!="string"||e.objective.trim().length===0||e.objective!==e.objective.trim())throw new Error("goal change goal.objective must be non-empty and normalized");if(typeof e.phase!="string"||!Eke.has(e.phase))throw new Error("goal change goal.phase is invalid");let t=e.phase,r=t==="blocked"?"blockedReason,id,maxGoalRounds,objective,phase,revision":"id,maxGoalRounds,objective,phase,revision";if(Object.keys(e).sort().join(",")!==r)throw new Error(`goal change goal for phase ${t} must have exactly ${r} fields`);return{id:e.id,revision:e8(e.revision,"goal.revision"),objective:e.objective,phase:t,maxGoalRounds:e8(e.maxGoalRounds,"goal.maxGoalRounds"),...t==="blocked"?{blockedReason:kke(e.blockedReason)}:{}}}l(Ake,"decodeSnapshot");function Ike(e){if(!G0(e)||Object.keys(e).sort().join(",")!=="id,revision")throw new Error("goal clear tombstone must have exactly id and revision fields");if(typeof e.id!="string"||e.id.length===0)throw new Error("goal clear tombstone id must be a non-empty string");return{id:e.id,revision:e8(e.revision,"cleared.revision")}}l(Ike,"decodeRef");function ZZ(e){if(!G0(e)||e.kind!=="goal/change")return;if(e.version!==1)throw new Error(`unsupported goal change version ${String(e.version)}`);if(e.operation==="clear"){let i=["cleared","clearedAt","kind","operation","version"];if(Object.keys(e).sort().join(",")!==i.sort().join(","))throw new Error(`goal clear change must have exactly ${i.sort().join(",")} fields`);return{kind:"goal/change",version:1,operation:"clear",cleared:Ike(e.cleared),clearedAt:q0(e.clearedAt,"clearedAt")}}if(typeof e.operation!="string"||!xke.has(e.operation))throw new Error("goal change operation is invalid");let t=["createdAt","goal","kind","operation","roundsStarted","updatedAt","version"];if(Object.keys(e).sort().join(",")!==t.sort().join(","))throw new Error(`goal snapshot change must have exactly ${t.sort().join(",")} fields`);let r=q0(e.createdAt,"createdAt"),n=q0(e.updatedAt,"updatedAt");if(n<r)throw new Error("goal change updatedAt cannot precede createdAt");return{kind:"goal/change",version:1,operation:e.operation,goal:Ake(e.goal),roundsStarted:q0(e.roundsStarted,"roundsStarted"),createdAt:r,updatedAt:n}}l(ZZ,"decodeGoalChange");function $ke(e){if(e.kind==="goal"){if(typeof e.goalId!="string"||e.goalId.length===0||!Number.isSafeInteger(e.revision)||e.revision<1||!Number.isSafeInteger(e.round)||e.round<1)throw new Error("goal message source is invalid");return e}}l($ke,"goalSource");function H0(e,t,r){if(t.objective!==e.objective||t.maxGoalRounds!==e.maxGoalRounds)throw new Error(`goal ${r} cannot change objective or maxGoalRounds`)}l(H0,"requireSameDefinition");function KZ(e,t,r){if(t.id!==e.id||t.revision!==e.revision+1)throw new Error(`goal ${r} must advance the current goal by one revision`)}l(KZ,"requireNextRevision");function _ke(e,t,r){let n=t.goal;if(KZ(r,n,t.operation),e.updatedAt===void 0)throw new Error("current goal fold lacks updatedAt");if(t.createdAt!==e.createdAt||t.updatedAt<e.updatedAt||t.roundsStarted!==e.roundsStarted)throw new Error(`goal ${t.operation} does not preserve the current counters and timestamps`);switch(t.operation){case"edit":if(n.phase!==r.phase||JSON.stringify(n.blockedReason)!==JSON.stringify(r.blockedReason))throw new Error("goal edit cannot change phase or blocked reason");break;case"pause":if(H0(r,n,t.operation),r.phase!=="active"||n.phase!=="paused")throw new Error("goal pause has an invalid phase transition");break;case"resume":if(H0(r,n,t.operation),!new Set(["active","paused","blocked"]).has(r.phase)||n.phase!=="active"||e.roundsStarted>=n.maxGoalRounds)throw new Error("goal resume has an invalid phase transition or exhausted round budget");break;case"complete":if(H0(r,n,t.operation),r.phase==="complete"||n.phase!=="complete")throw new Error("goal complete has an invalid phase transition");break;case"block":if(H0(r,n,t.operation),r.phase!=="active"||n.phase!=="blocked")throw new Error("goal block has an invalid phase transition");break;case"create":throw new Error("goal create cannot be validated as a current-goal transition");default:throw t.operation,new Error("unknown goal snapshot operation")}}l(_ke,"validateSnapshotTransition");function YZ(e){return e.operation==="clear"?e.cleared:{id:e.goal.id,revision:e.goal.revision}}l(YZ,"goalChangeRef");function Tke(e,t){let r=YZ(t);if(t.operation==="clear"){let n=e.goal;if(n===void 0)throw new Error("goal clear requires a current goal");if(KZ(n,t.cleared,t.operation),e.updatedAt===void 0)throw new Error("current goal fold lacks updatedAt");if(t.clearedAt<e.updatedAt)throw new Error("goal clear timestamp cannot precede the current goal update");e.goal=void 0,e.roundsStarted=0,e.createdAt=void 0,e.updatedAt=void 0,e.lastRef=r;return}if(t.operation==="create"){if(t.goal.revision!==1||t.goal.phase!=="active"||t.roundsStarted!==0||e.goal!==void 0&&e.goal.phase!=="complete"||e.seenGoalIds.has(t.goal.id))throw new Error("goal create requires a fresh active revision-one goal with zero rounds");e.seenGoalIds.add(t.goal.id)}else{let n=e.goal;if(n===void 0)throw new Error(`goal ${t.operation} requires a current goal`);_ke(e,t,n)}e.goal=t.goal,e.roundsStarted=t.roundsStarted,e.createdAt=t.createdAt,e.updatedAt=t.updatedAt,e.lastRef=r}l(Tke,"applyGoalChange");function GZ(e,t){if(t.type==="goal/change"){let r=ZZ(t.data);if(r===void 0)throw new Error(`goal change at session event ${t.seq} has an invalid kind`);Tke(e,r);return}if(t.type==="user/message"){let r=$ke(t.data.source);if(r===void 0)return;let n=e.goal;if(n===void 0||n.phase!=="active"||r.goalId!==n.id||r.revision!==n.revision||r.round!==e.roundsStarted+1||r.round>n.maxGoalRounds)throw new Error(`goal round at session event ${t.seq} is not the next admitted round of the active goal`);e.roundsStarted=r.round}}l(GZ,"applyGoalEvent");var Cke=l(function(e,t,r){for(var n=arguments.length>2,i=0;i<t.length;i++)r=n?t[i].call(e,r):t[i].call(e);return n?r:void 0},"__runInitializers"),mu=l(function(e,t,r,n,i,s){function o(x){if(x!==void 0&&typeof x!="function")throw new TypeError("Function expected");return x}l(o,"accept");for(var a=n.kind,c=a==="getter"?"get":a==="setter"?"set":"value",u=!t&&e?n.static?e:e.prototype:null,d=t||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),f,p=!1,h=r.length-1;h>=0;h--){var m={};for(var g in n)m[g]=g==="access"?{}:n[g];for(var g in n.access)m.access[g]=n.access[g];m.addInitializer=function(x){if(p)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(x||null))};var y=(0,r[h])(a==="accessor"?{get:d.get,set:d.set}:d[c],m);if(a==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(f=o(y.get))&&(d.get=f),(f=o(y.set))&&(d.set=f),(f=o(y.init))&&i.unshift(f)}else(f=o(y))&&(a==="field"?i.unshift(f):d[c]=f)}u&&Object.defineProperty(u,n.name,d),p=!0},"__esDecorate"),VZ=v.union([v.object({goal:v.object({id:v.string().min(1),revision:v.number().int().positive(),objective:v.string().min(1),phase:v.union([v.literal("active"),v.literal("paused"),v.literal("blocked"),v.literal("complete")]),blockedReason:v.object({code:v.string(),message:v.string()}).optional(),maxGoalRounds:v.number().int().positive()}),roundsStarted:v.number().int().nonnegative(),createdAt:v.number(),updatedAt:v.number()}),v.null()]);function Oke(e,t){if(t.type!=="goal/change")return e;let r;try{r=ZZ(t.data)}catch{return e}return r===void 0?e:r.operation==="clear"?null:{goal:r.goal,roundsStarted:r.roundsStarted,createdAt:r.createdAt,updatedAt:r.updatedAt}}l(Oke,"applyGoalProjection");function t8(e){if(!Number.isSafeInteger(e)||e<1)throw new hi("maxGoalRounds must be a positive safe integer","GOAL_INVALID_MAX_ROUNDS");return e}l(t8,"resolveMaxGoalRounds");function XZ(e){if(typeof e!="string"||e.trim().length===0)throw new hi("goal objective must be a non-empty string","GOAL_INVALID_OBJECTIVE");return e.trim()}l(XZ,"resolveObjective");function Nke(e,t){return{objective:XZ(e.objective),maxGoalRounds:t8(e.maxGoalRounds??t)}}l(Nke,"resolveCreateGoal");function Rke(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,r=t?.code,n=t?.message;if(typeof r!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(r)||typeof n!="string"||n.trim().length===0)throw new hi("goal block reason requires a lower-kebab-case code and a non-empty message","GOAL_INVALID_BLOCK_REASON");return{code:r,message:n.trim()}}l(Rke,"resolveBlockReason");var GFe=(()=>{let e=HZ,t=[],r,n,i,s,o,a;return class extends e{static{l(this,"GoalService")}static{let u=typeof Symbol=="function"&&Symbol.metadata?Object.create(e[Symbol.metadata]??null):void 0;r=[Al("edit")],n=[Al("pause")],i=[Al("resume")],s=[Al("complete")],o=[Al("clear")],a=[Al("create")],mu(this,null,r,{kind:"method",name:"edit",static:!1,private:!1,access:{has:l(d=>"edit"in d,"has"),get:l(d=>d.edit,"get")},metadata:u},null,t),mu(this,null,n,{kind:"method",name:"pause",static:!1,private:!1,access:{has:l(d=>"pause"in d,"has"),get:l(d=>d.pause,"get")},metadata:u},null,t),mu(this,null,i,{kind:"method",name:"resume",static:!1,private:!1,access:{has:l(d=>"resume"in d,"has"),get:l(d=>d.resume,"get")},metadata:u},null,t),mu(this,null,s,{kind:"method",name:"complete",static:!1,private:!1,access:{has:l(d=>"complete"in d,"has"),get:l(d=>d.complete,"get")},metadata:u},null,t),mu(this,null,o,{kind:"method",name:"clear",static:!1,private:!1,access:{has:l(d=>"clear"in d,"has"),get:l(d=>d.clear,"get")},metadata:u},null,t),mu(this,null,a,{kind:"method",name:"remoteExportCreate",static:!1,private:!1,access:{has:l(d=>"remoteExportCreate"in d,"has"),get:l(d=>d.remoteExportCreate,"get")},metadata:u},null,t),u&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:u})}static inject=["agents"];static Config=re.object({defaultMaxGoalRounds:re.number().default(256)});resolved=Cke(this,t);caches=new WeakMap;constructor(u,d={}){super(u,"goals"),this.resolved={defaultMaxGoalRounds:t8(d.defaultMaxGoalRounds??256)},u.on("agent/session-start",({agent:f})=>{this.cache(f.session).activation="disarmed"}),u.inject(["sessionProjections"],f=>{f.sessionProjections.register({key:"goal",stateSchema:VZ,init:l(()=>null,"init"),apply:Oke,wire:{viewSchema:VZ,view:l(p=>p,"view")},stateVersion:4})})}get(u){this.assertLive(u);let d=this.cache(u.session);return this.sync(u.session,d),this.view(d)}disarm(u){this.assertLive(u);let d=this.cache(u.session);return this.sync(u.session,d),d.activation="disarmed",this.view(d)}create(u,d){let f=Nke(d,this.resolved.defaultMaxGoalRounds),p=this.prepareMutation(u),h=p.state.goal;if(h!==void 0&&h.phase!=="complete")throw new hi(`goal "${h.id}" already exists with phase "${h.phase}"`,"GOAL_ALREADY_EXISTS");let m=Date.now(),g={id:`goal-${bke()}`,revision:1,objective:f.objective,phase:"active",maxGoalRounds:f.maxGoalRounds};return this.commitSnapshot(u,p,"create",g,0,m,m,"armed")}edit(u,d,f){let p=this.prepareMutation(u),h=this.expectCurrent(p,d);if(f.objective===void 0&&f.maxGoalRounds===void 0)throw new hi("goal edit requires objective and/or maxGoalRounds","GOAL_INVALID_EDIT");let m={...h,revision:h.revision+1,...f.objective===void 0?{}:{objective:XZ(f.objective)},...f.maxGoalRounds===void 0?{}:{maxGoalRounds:t8(f.maxGoalRounds)}};return this.commitCurrent(u,p,"edit",m,p.activation)}pause(u,d){return this.transition(u,d,"pause",["active"],"paused","disarmed")}resume(u,d){let f=this.prepareMutation(u),p=this.expectCurrent(f,d),h=["active","paused","blocked"];if(!h.includes(p.phase))throw this.transitionError(p,"resume",h);if(p.phase==="active"&&f.activation==="armed")throw new hi(`goal "${p.id}" is already active and armed`,"GOAL_INVALID_TRANSITION");if(f.state.roundsStarted>=p.maxGoalRounds)throw new hi(`goal "${p.id}" exhausted ${p.maxGoalRounds} goal rounds; increase maxGoalRounds before resuming`,"GOAL_INVALID_TRANSITION");return this.commitCurrent(u,f,"resume",this.withPhase(p,"active"),"armed")}complete(u,d){return this.transition(u,d,"complete",["active","paused","blocked"],"complete","disarmed")}block(u,d,f){let p=this.prepareMutation(u),h=this.expectCurrent(p,d);if(h.phase!=="active")throw this.transitionError(h,"block",["active"]);return this.commitCurrent(u,p,"block",{...this.withPhase(h,"blocked"),blockedReason:Rke(f)},"disarmed")}clear(u,d){let f=this.prepareMutation(u),p=this.expectCurrent(f,d),h={id:p.id,revision:p.revision+1},m={kind:"goal/change",version:1,operation:"clear",cleared:h,clearedAt:this.nextMutationTime(f)};return this.commit(u,f,m,"disarmed"),{...h}}prepareMutation(u){this.assertLive(u);let d=this.cache(u.session);return this.sync(u.session,d),d}expectCurrent(u,d){let f=u.state.goal;if(f===void 0)throw new hi("no current goal","GOAL_NOT_FOUND");if(d.id!==f.id||d.revision!==f.revision)throw new hi(`stale goal ref "${d.id}" revision ${d.revision}; current is "${f.id}" revision ${f.revision}`,"GOAL_STALE_REVISION");return f}assertLive(u){if(this.ctx.agents.get(u.id)!==u)throw new hi(`agent "${u.id}" is not live in this registry`,"GOAL_AGENT_NOT_LIVE")}cache(u){let d=this.caches.get(u);if(d!==void 0)return d;let f=Ske();for(let p of u.events)GZ(f,p);return d={state:f,activation:"disarmed",observedSeq:u.seq,pendingActivation:void 0},this.caches.set(u,d),d}sync(u,d){for(let f of u.events.slice(d.observedSeq))GZ(d.state,f),f.type==="goal/change"&&(d.activation=d.pendingActivation?.seq===f.seq?d.pendingActivation.activation:"disarmed"),d.observedSeq+=1}withPhase(u,d){return{id:u.id,revision:u.revision+1,objective:u.objective,phase:d,maxGoalRounds:u.maxGoalRounds}}transition(u,d,f,p,h,m){let g=this.prepareMutation(u),y=this.expectCurrent(g,d);if(!p.includes(y.phase))throw this.transitionError(y,f,p);return this.commitCurrent(u,g,f,this.withPhase(y,h),m)}transitionError(u,d,f){return new hi(`cannot ${d} goal "${u.id}" from phase "${u.phase}"; expected ${f.join(" or ")}`,"GOAL_INVALID_TRANSITION")}commitCurrent(u,d,f,p,h){let m=d.state.createdAt;if(m===void 0)throw new Error("current goal cache lacks createdAt");return this.commitSnapshot(u,d,f,p,d.state.roundsStarted,m,this.nextMutationTime(d),h)}nextMutationTime(u){let d=u.state.updatedAt;if(d===void 0)throw new Error("current goal cache lacks updatedAt");return Math.max(Date.now(),d)}commitSnapshot(u,d,f,p,h,m,g,y){let x={kind:"goal/change",version:1,operation:f,goal:p,roundsStarted:h,createdAt:m,updatedAt:g};this.commit(u,d,x,y);let w=this.view(d);if(w===void 0)throw new Error("snapshot commit cleared the goal unexpectedly");return w}commit(u,d,f,p){let h=YZ(f);d.pendingActivation={seq:u.session.seq,activation:p};try{u.session.append("goal/change",f),this.sync(u.session,d)}finally{d.pendingActivation=void 0}let m=this.view(d),g={operation:f.operation,ref:{...h},...m===void 0?{}:{goal:m}};zu(this.ctx,u).emit("goal/changed",{change:g})}view(u){let d=u.state.goal,f=u.state.createdAt,p=u.state.updatedAt;if(d!==void 0){if(f===void 0||p===void 0)throw new Error(`goal "${d.id}" cache lacks timestamps`);return{...d,roundsStarted:u.state.roundsStarted,createdAt:f,updatedAt:p,activation:u.activation}}}remoteExportCreate(u,d){let f=this.create(u,d);return{ref:{id:f.id,revision:f.revision}}}}})();var lp=class extends Wr{static{l(this,"UserQuestionError")}constructor(e,t,r){super(e,t,r),this.name="UserQuestionError"}};var JZ=class extends Error{static{l(this,"DirectoryPickerError")}code;path;constructor(e,t,r){super(r),this.code=e,this.path=t,this.name="DirectoryPickerError"}};var QZ=["agent-preset/selected","commands/change","credentials/reference-updated","cordis/request-run","cordis/request-run-resolved","cordis/dynamic-package","cordis/dynamic-retract","cordis/inspect-query","cordis/inspect-query-resolved","llm/adapters-updated","settings/document-updated"],da=class extends Error{static{l(this,"ApiRemoteSessionNotFound")}},Bs=class extends Error{static{l(this,"ApiRemoteSubagentSessionOwnership")}sessionId;constructor(e){super(`session "${e}" is a subagent session; use subagent delivery`),this.sessionId=e}};function Il(e,t,r){if(t.header.origin==="subagent")return!0;let n=t.header.parentSession;if(n===void 0||r===void 0)return!1;let i=e.agents.get(n);return i!==void 0&&e.agents.isOwnedBy(r.id,i)}l(Il,"hasApiRemoteSubagentOwner");function gu(e){return{code:"agent-busy",message:`session "${e}" is owned by subagent routing`,details:{reason:"use subagent delivery for this child session"}}}l(gu,"apiRemoteSubagentOwnershipError");async function r8(e,t){let r=e.get("sessionPersistence");if(r===void 0)throw new Error("session persistence is not configured (load a dsh-session-persistence backend)");let n=(await r.list()).find(s=>s.id===t);if(n===void 0||n.cwd===void 0)throw new da(`session "${t}" not found`);let i=await r.inspect(t);if(i.meta.cwd===void 0)throw new da(`session "${t}" not found`);return{meta:i.meta,events:[...i.events]}}l(r8,"inspectApiRemoteSession");function eK(e,t){let r=new Map,n=l(s=>{let o=e.agents.get(s);if(o!==void 0)return Il(e,o.session,o)?{error:gu(s)}:{agent:o}},"fencedLiveAgent"),i=l(async s=>{let o=n(s);if(o!==void 0)return o;let a=e.sessions.get(s);if(a!==void 0&&Il(e,a,void 0))return{error:gu(s)};let c=r.get(s);c===void 0&&(c=(async()=>{try{let u=await r8(e,s);if(Il(e,{header:u.meta},void 0))throw new Bs(s);let d=t.setup===void 0?void 0:await t.setup(u),f=e.sessions.get(s),p=e.agents.get(s);if(f!==void 0&&Il(e,f,p))throw new Bs(s);return(await e.agents.resume({resumeSessionId:s,...t.agentOptions===void 0?{}:{agentOptions:t.agentOptions()},...d===void 0?{}:{setup:d}})).agent}finally{r.delete(s)}})(),r.set(s,c));try{return{agent:await c}}catch(u){if(u instanceof da)return{error:{code:"session-not-found",message:u.message,details:{sessionId:s}}};if(u instanceof Bs)return{error:gu(u.sessionId)};let d=n(s);if(d!==void 0)return d;let f=e.sessions.get(s);return f!==void 0&&Il(e,f,void 0)?{error:gu(s)}:{error:{code:"internal",message:`resume failed for session "${s}": ${String(u)}`,details:{}}}}},"agentFor");return e.inject(["typert"],s=>{let o=l(async a=>{let c=await i(a);if("error"in c)throw new qZ(c.error);return c.agent},"resolveAgent");s.typert.lookups.configure("agent",o),s.typert.lookups.configure("session",async a=>(await o(a)).session),s.typert.contexts.configureHost("agent",async a=>(await o(a)).ctx)}),i}l(eK,"createApiRemoteAgentResolver");import{execFile as Pke}from"node:child_process";var tK=l((e,t,r)=>new Promise((n,i)=>{Pke(e,[...t],{encoding:"utf8",signal:r,windowsHide:!0},(s,o,a)=>{if(s!==null){i(Object.assign(new Error(s.message,{cause:s}),{code:s.code,stdout:o,stderr:a}));return}n({stdout:o,stderr:a})})}),"runNativeCommand");function zke(e){return{sessionQuery:e.get("sessionQuery"),sessionPersistence:e.get("sessionPersistence"),attachments:e.get("attachments"),sessions:e.get("sessions")}}l(zke,"sessionLogExportDeps");async function kK(e,t,r){r?.throwIfAborted();let n=e.sessions;if(n===void 0)return;let i=n.get(t);i!==void 0&&(await n.flush(i),r?.throwIfAborted())}l(kK,"flushLiveSessionLog");var Bke={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"};function Wke(e){return`media/${String(e.attachmentId)}.${Bke[e.mediaType]}`}l(Wke,"mediaEntryPath");function V0(e,t){if(!Array.isArray(e))return;let r=[];for(let n of e)r.push(n);for(;r.length>0;){let n=r.pop();if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;if(i.type==="image"&&typeof i.attachment=="object"&&i.attachment!==null){let s=i.attachment;t.set(String(s.attachmentId),s)}if(Array.isArray(i.content))for(let s of i.content)r.push(s)}}l(V0,"collectImageRefs");function qke(e,t){let r=e.data;if(typeof r!="object"||r===null)return;let n=r;if(V0(n.content,t),n.message!==void 0&&V0(n.message.content,t),n.inserted!==void 0)for(let i of n.inserted)V0(i.content,t);n.chunk?.type==="block-end"&&V0([n.chunk.block],t)}l(qke,"collectEventImageRefs");function Hke(e){let t=new Map;for(let r of e.split(`
|
|
2345
|
+
`)){if(r==="")continue;let n;try{n=JSON.parse(r)}catch{continue}qke(n,t)}return t}l(Hke,"imageRefsInArtifact");function AK(e){return e.replace(/[^A-Za-z0-9_-]/g,"_")}l(AK,"safeSessionIdSegment");function Gke(e){return`dsh-session-${AK(e)}.zip`}l(Gke,"sessionLogZipFilename");async function*Vke(e,t,r,n,i){let s=new Map,o=l(a=>{for(let[c,u]of Hke(a))s.set(c,u)},"rememberMedia");if(o(t.content),yield{path:t.filename,content:t.content},n){let a=new Set([r]),c=l(async function*(d){for(let f of d){i?.throwIfAborted();let p=f.session.header.id;if(a.has(p))continue;a.add(p),await kK(e,p,i);let h=await e.sessionPersistence.readRaw(p,i);if(i?.throwIfAborted(),h===void 0)throw new Error(`subagent "${p}" has no stored log artifact`);o(h.content),yield{path:`subagents/${AK(p)}/${h.filename}`,content:h.content},yield*c(f.descendants)}},"collect"),u=await e.sessionQuery.traceSession(r,i);i?.throwIfAborted(),yield*c(u.descendants)}for(let a of s.values()){i?.throwIfAborted();let c=await e.attachments.readImage(a,i);i?.throwIfAborted(),yield{path:Wke(a),data:c.data}}}l(Vke,"sessionLogZipEntries");var Zke=65536,Kke=65536,Yke=65536,Xke=class{static{l(this,"ResponseCapacityGate")}releasePending;async wait(e,t){t.throwIfAborted(),!(e.desiredSize===null||e.desiredSize>0)&&(await new Promise(r=>{let n=l(()=>{this.releasePending=void 0,t.removeEventListener("abort",n),r()},"release");this.releasePending=n,t.addEventListener("abort",n,{once:!0})}),t.throwIfAborted())}pulled(){this.releasePending?.()}};async function Jke(e,t,r,n,i){let s=0;do{i.throwIfAborted();let o=Math.min(s+Kke,t.byteLength),a=o>=t.byteLength;e.push(t.subarray(s,o),a),s=o,await n.wait(r,i)}while(s<t.byteLength)}l(Jke,"pushBinaryChunks");async function Qke(e,t,r,n,i){let s=new TextEncoder,o=0,a;do{i.throwIfAborted();let c=Math.min(o+Zke,t.length);if(c<t.length&&c-o>1){let u=t.charCodeAt(c-1);u>=55296&&u<=56319&&(c-=1)}a=c>=t.length,e.push(s.encode(t.slice(o,c)),a),o=c,await n.wait(r,i)}while(!a)}l(Qke,"pushArtifactChunks");function e4e(e,t,r,n,i,s){let o=new AbortController,a=AbortSignal.any([s,o.signal]),c,u=!1,d=new Xke,f=l(()=>{c===void 0||u||(u=!0,c.terminate())},"terminateZip");return new ReadableStream({start(p){let h=new nO((m,g,y)=>{if(m){p.error(m);return}g.byteLength>0&&p.enqueue(g),y&&p.close()});c=h,(async()=>{try{for await(let m of Vke(e,t,r,n,a)){let g=new rO(m.path,{level:i});h.add(g),"content"in m?await Qke(g,m.content,p,d,a):await Jke(g,m.data,p,d,a)}h.end()}catch(m){f(),p.error(m instanceof Error?m:new Error(String(m)))}})()},pull(){d.pulled()},cancel(p){o.abort(p instanceof Error?p:new Error("session log export stream cancelled")),f()}},{highWaterMark:Yke,size:l(p=>p.byteLength,"size")})}l(e4e,"streamSessionLogZip");function IK(e,t){let r=0,n=0;for(let i of e){if(r===t)return e.slice(0,n);r++,n+=i.length}return e}l(IK,"truncateUnicodeCodePoints");var ct=v.string().min(1),$K=v.string().min(1),Ws=v.string().min(1),_K=v.object({type:v.string(),seq:v.number().int().nonnegative(),time:v.number(),data:v.unknown(),sourceEventSeqs:v.array(v.number()).optional(),surfaceOp:v.unknown().optional(),ignorable:v.literal(!0).optional()}),t4e=v.object({sessionId:ct,updatedAt:v.number(),running:v.boolean(),blank:v.boolean(),parentSessionId:ct.optional(),origin:v.literal("subagent").optional(),cwd:v.string().optional(),agentPreset:v.string().optional(),projections:v.lazy(()=>a8).optional()}),r4e=v.object({cursor:v.string().optional()}),UUe=v.object({items:v.array(t4e)}),n4e=v.object({query:v.string().trim().min(1).max(500).refine(e=>!e.includes("\0"),{message:"search query must not contain NUL"})}),i4e=v.object({sessionId:ct,snippet:v.string().refine(e=>IK(e,240)===e,{message:"search snippet must contain at most 240 Unicode code points"})}),jUe=v.object({items:v.array(i4e).max(20),hasMore:v.boolean()}),s4e=v.object({workspaceId:Ws.optional(),cwd:v.string().optional(),sessionId:ct.optional(),agentPreset:v.string().optional(),reuseWorkspaceBlank:v.literal(!0).optional()}).refine(e=>e.workspaceId===void 0||e.cwd===void 0,{message:"session.create accepts workspaceId or cwd, not both"}).refine(e=>e.reuseWorkspaceBlank!==!0||e.workspaceId!==void 0&&e.sessionId!==void 0,{message:"session.create reuseWorkspaceBlank requires workspaceId and sessionId"}),zUe=v.object({sessionId:ct,agentPreset:v.string().optional()}),o4e=v.object({sessionId:ct,title:v.string()}),BUe=v.object({title:v.string().min(1),seq:v.number().int().nonnegative()}),a4e=v.object({sessionId:ct,atSeq:v.number().int().nonnegative().optional()}),WUe=v.object({sessionId:ct}),l4e=v.object({sessionId:ct,beforeSeq:v.number().int().nonnegative().optional(),maxMessages:v.number().int().positive().optional()}),TK=v.object({provider:v.string().min(1),model:v.string().min(1),reasoningEffort:v.string().min(1).optional()}),c4e=v.object({id:v.string().min(1),name:v.string().min(1),description:v.string().optional()}),u4e=v.object({efforts:v.array(c4e).min(1),defaultEffort:v.string().min(1).optional()}),d4e=v.object({id:v.string().min(1),name:v.string().min(1),description:v.string().optional(),reasoning:u4e.optional()}),CK=v.object({id:v.string().min(1),name:v.string().min(1),models:v.array(d4e)}),OK=v.object({id:v.string().min(1),name:v.string().min(1),message:v.string()}),NK=v.discriminatedUnion("for",[v.object({for:v.literal("call"),view:v.looseObject({card:v.string()})}),v.object({for:v.literal("result"),view:v.looseObject({card:v.string()})})]),RK=v.object({event:_K,view:NK.optional()}),a8=v.object({asOfSeq:v.number().int().min(-1),values:v.record(v.string(),v.unknown())}),rK=v.object({blank:v.boolean(),lastPromptAt:v.number().nullable()}),f4e=v.object({maxImageBytes:v.number().int().positive(),maxImagesPerMessage:v.number().int().positive(),maxMessageImageBytes:v.number().int().positive(),maxImagePixels:v.number().int().positive(),maxImageDimension:v.number().int().positive(),mediaTypes:v.array(v.string())}),qUe=v.object({events:v.array(RK),hasMore:v.boolean(),projections:a8.optional()}),p4e=v.object({sessionId:ct}),HUe=v.object({current:TK,routable:v.boolean(),groups:v.array(CK),failures:v.array(OK)}),h4e=v.object({sessionId:ct,provider:v.string().min(1),model:v.string().min(1),reasoningEffort:v.string().min(1).optional()}),GUe=v.object({selected:TK}),l8=v.looseObject({type:v.string()}),PK=v.union([v.literal("image/png"),v.literal("image/jpeg"),v.literal("image/webp"),v.literal("image/gif")]),m4e=v.discriminatedUnion("type",[v.object({type:v.literal("text"),text:v.string()}),v.object({type:v.literal("image"),mediaType:PK,data:v.string(),name:v.string().optional()})]),g4e=v.object({sessionId:ct,mode:v.union([v.literal("queue"),v.literal("steer")]),content:v.array(m4e),clientTimeZone:v.string().optional()}),VUe=v.object({accepted:v.literal(!0),command:v.object({kind:v.literal("success"),text:v.string().optional()}).optional()}),DK=v.string().min(1),y4e=v.object({attachmentId:DK,mediaType:PK,bytes:v.number().int().positive(),width:v.number().int().positive(),height:v.number().int().positive(),name:v.string().optional()}),v4e=v.object({sessionId:ct,attachmentId:DK}),ZUe=v.object({attachment:y4e,data:v.string()}),w4e=v.object({sessionId:ct,itemId:$K,action:v.discriminatedUnion("kind",[v.object({kind:v.literal("edit"),content:v.array(l8)}),v.object({kind:v.literal("remove")}),v.object({kind:v.literal("steer")})])}),KUe=v.object({accepted:v.literal(!0)}),b4e=v.object({sessionId:ct}),YUe=v.object({accepted:v.literal(!0)}),s8=v.string().min(1),x4e=v.object({sessionId:ct,approvalId:s8,outcome:v.union([v.literal("allowed-once"),v.literal("rejected")])}),E4e=v.object({answers:v.array(v.object({id:v.string(),selected:v.array(v.string()),custom:v.string().optional()}))}),S4e=v.object({sessionId:ct,answer:E4e});var k4e=new Set([".html",".htm",".xhtml",".svg"]);function A4e(e){let t=e.replace(/LSHandlerPreferredVersions\s*=\s*\{[^}]*\};/g,""),r=/\{[^{}]*LSHandlerURLScheme\s*=\s*"?https"?;[^{}]*\}/.exec(t)?.[0];if(r!==void 0)return/LSHandlerRoleAll\s*=\s*"?([\w.-]+)"?;/.exec(r)?.[1]}l(A4e,"macBundleForHttps");async function I4e(e,t,r,n,i){if(r==="darwin"){let s;try{let{stdout:o}=await n("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure"],t);s=A4e(o)}catch{return!1}return s===void 0?!1:(await n("open",["-b",s,e],t),!0)}if(r==="linux"){let s=i.BROWSER;return s===void 0||s===""?!1:(await n(s,[e],t),!0)}return!1}l(I4e,"openInBrowser");function $4e(e){return`'${e.replace(/'/g,"''")}'`}l($4e,"powershellLiteral");function J0(e){return e!==void 0&&e!==""}l(J0,"present");function LK(e){let t=e.env??process.env;return J0(t.WSL_DISTRO_NAME)||J0(t.WSL_INTEROP)?!0:(e.osRelease??Fke()).toLowerCase().includes("microsoft")}l(LK,"isWsl");async function MK(e,t,r){await r("powershell.exe",["-NoProfile","-Command",`Invoke-Item -LiteralPath ${$4e(e)}`],t)}l(MK,"openWindowsPath");async function _4e(e,t,r){let n=await r("wslpath",["-w",e],t);t.throwIfAborted();let i=n.stdout.replace(/[\r\n]+$/,"");if(i==="")throw new Error("wslpath returned no Windows path");await MK(i,t,r)}l(_4e,"openWslPath");async function FK(e,t,r,n={}){let i=n.platform??process.platform,s=n.run??tK,o=n.env??process.env,a=i==="linux"&&LK(n);if(!(!a&&r==="default"&&k4e.has(jke(e).toLowerCase())&&await I4e(e,t,i,s,o))){if(i==="darwin"){await s("open",r==="text-editor"?["-t",e]:[e],t);return}if(i==="win32"){await MK(e,t,s);return}if(i==="linux"){if(a){await _4e(e,t,s);return}await s("xdg-open",[e],t);return}throw new Error(`native path opener is unsupported on ${i}`)}}l(FK,"openNativePathWithIntent");function T4e(e={}){let t=e.platform??process.platform;if(t==="darwin"||t==="win32")return!0;if(t!=="linux")return!1;let r=e.env??process.env;return LK(e)||J0(r.DISPLAY)||J0(r.WAYLAND_DISPLAY)}l(T4e,"canOpenNativePath");function C4e(e,t,r={}){return FK(e,t,"default",r)}l(C4e,"openNativePath");function O4e(e,t,r={}){return FK(e,t,"text-editor",r)}l(O4e,"openNativeTextFile");var N4e=50,nK=100,iK=16,R4e=1024,UK=new Set(["user/message","assistant/message"]);async function P4e(e,t){if(t.every(i=>i.type==="text"))return t.map(i=>({type:"text",text:i.text}));let r=await Wm(e.attachments,t.filter(i=>i.type==="image")),n=0;return t.map(i=>i.type==="text"?{type:"text",text:i.text}:{type:"image",attachment:r[n++]})}l(P4e,"durablePromptContent");function up(e,t){if(Array.isArray(e))for(let r of e){if(typeof r!="object"||r===null||Array.isArray(r))continue;let n=r;if(n.type==="image"&&typeof n.attachment=="object"&&n.attachment!==null){let i=n.attachment;if(t(i))return i}if(n.type==="tool-result"){let i=up(n.content,t);if(i!==void 0)return i}}}l(up,"imageBlockIn");function D4e(e,t){let r=e.data,n=up(r.content,t);if(n!==void 0)return n;if(r.message!==void 0){let i=up(r.message.content,t);if(i!==void 0)return i}if(r.inserted!==void 0)for(let i of r.inserted){let s=up(i.content,t);if(s!==void 0)return s}if(e.type==="assistant/chunk"&&r.chunk?.type==="block-end")return up([r.chunk.block],t)}l(D4e,"imageInEvent");function L4e(e){return e.some(t=>_o(t.content))}l(L4e,"messagesHaveImage");function M4e(e,t){for(let r of e){let n=D4e(r,i=>String(i.attachmentId)===t);if(n!==void 0)return n}}l(M4e,"referencedImage");var sK=/^[A-Za-z][A-Za-z0-9_+.-]*(?:\/[A-Za-z0-9_+.-]+)+$/;function oK(e){if(!(e.length===0||e.trim()!==e||e!=="UTC"&&!sK.test(e)))try{let t=new Intl.DateTimeFormat("en-US",{timeZone:e}).resolvedOptions().timeZone;return t!=="UTC"&&!sK.test(t)?void 0:t}catch{return}}l(oK,"canonicalClientTimeZone");function go(e){return e.aborted}l(go,"isAborted");function F4e(e,t,r){let n=t===void 0?[...e]:e.filter(o=>o.seq<t),i=0,s=0;for(let o=n.length-1;o>=0;o--){let a=n[o];if(!UK.has(a.type)||!Ll(a))continue;i++;let c=a.sourceEventSeqs,u=a.seq;if(c!==void 0)for(let d of c)d<u&&(u=d);if(i>=r){s=u;break}}return{events:n.filter(o=>o.seq>=s),hasMore:s>0}}l(F4e,"paginate");function yt(e,t){return{rpcId:e.rpcId,result:{ok:!0,value:t}}}l(yt,"ok");async function aK(e){let t=await Promise.all(e.llm.listProviders().map(async r=>{try{let n=await e.llm.listModels(r.id),i=await Promise.all(n.map(async s=>{let o=await e.llm.resolveModelInfo(r.id,s.id),a=o.reasoning===void 0?void 0:{efforts:o.reasoning.efforts.map(c=>({id:c.id,name:c.name,...c.description===void 0?{}:{description:c.description}})),...o.reasoning.defaultEffort===void 0?{}:{defaultEffort:o.reasoning.defaultEffort}};return{id:s.id,name:s.name,...s.description===void 0?{}:{description:s.description},...a===void 0?{}:{reasoning:a}}}));return{kind:"group",group:{id:r.id,name:r.name,models:i}}}catch(n){return{kind:"failure",failure:{id:r.id,name:r.name,message:n instanceof Error?n.message:String(n)}}}}));return{groups:t.flatMap(r=>r.kind==="group"?[r.group]:[]).filter(r=>r.models.length>0),failures:t.flatMap(r=>r.kind==="failure"?[r.failure]:[])}}l(aK,"buildModelCatalog");function ke(e,t){return{rpcId:e.rpcId,result:{ok:!1,error:t}}}l(ke,"err");function lK(e,t){if(t instanceof B0)return ke(e,{code:"agent-preset-not-found",message:t.message,details:{agentPreset:t.presetId,available:[...t.available]}});if(t instanceof ap)return ke(e,{code:"agent-preset-invalid",message:t.message,details:{agentPreset:t.presetId,reason:t.reason}})}l(lK,"presetFailure");var cK=class{static{l(this,"FrameQueue")}buffer=[];waiter;done=!1;push(e){this.done||(this.buffer.push(e),this.waiter?.())}end(){this.done=!0,this.waiter?.()}async*iterate(e,t){let r=l(()=>{this.end()},"onAbort");e.addEventListener("abort",r,{once:!0});try{for(;;){for(;this.buffer.length>0;)yield this.buffer.shift();if(this.done||e.aborted)return;await new Promise(n=>{this.waiter=n}),this.waiter=void 0}}finally{e.removeEventListener("abort",r),t()}}};function en(e){return{rpcId:crypto.randomUUID(),payload:e}}l(en,"frame");function U4e(e,t){for(let[r,n]of t.entries())if(!qu(n))throw new Error(`forwarded host event "${e}" argument ${r} is not lossless JSON data`);return t}l(U4e,"assertJsonArgs");function uK(e,t){e.push(en({type:"session/subscribed",sessionId:t.id,lastSeq:t.seq-1}))}l(uK,"subscribeSession");function Z0(e){return e.map(t=>({id:t.id,kind:t.kind,label:t.label,status:t.status,...t.detail===void 0?{}:{detail:t.detail},startedAt:t.startedAt,...t.finishedAt===void 0?{}:{finishedAt:t.finishedAt}}))}l(Z0,"jobViews");function n8(e){return!e.events.some(t=>t.type==="turn/start")}l(n8,"sessionBlank");function jK(e,t){let r=e.blank&&t.type!=="turn/start",n=t.type==="user/message"&&t.data.source.kind==="user"?t.time:e.lastPromptAt;return r===e.blank&&n===e.lastPromptAt?e:{blank:r,lastPromptAt:n}}l(jK,"applySessionListMetadata");function zK(e){let t={blank:!0,lastPromptAt:null};for(let r of e)t=jK(t,r);return t}l(zK,"sessionListMetadata");function BK(e,t){return Math.max(e.createdAt,t?.lastPromptAt??0)}l(BK,"sessionListUpdatedAt");function c8(e,t=[]){let r=ua({header:e,events:t});return{...e.parentSession===void 0?{}:{parentSessionId:e.parentSession},...e.origin===void 0?{}:{origin:e.origin},...e.cwd===void 0?{}:{cwd:e.cwd},...r===void 0?{}:{agentPreset:r}}}l(c8,"sessionListFields");function j4e(e,t){let r=zK(e.events);return{sessionId:e.id,updatedAt:BK(e.header,r),running:t,blank:r.blank,...c8(e.header,e.events)}}l(j4e,"summarize");async function z4e(e,t,r,n,i){if(n===0)return;i?.throwIfAborted();let s=t.locate(r);if(s===void 0)return;i?.throwIfAborted();let o;try{o=(await Lke(s.path)).size}catch{i?.throwIfAborted();return}if(!(o>n))try{let{events:a}=await t.readFrom(r.id,0,i);return i?.throwIfAborted(),zK(a)}catch(a){i?.throwIfAborted(),e.logger.warn(`session.list: blank probe for "${r.id}" failed (serving it as visible): ${String(a)}`);return}}l(z4e,"probeColdSessionMetadata");async function B4e(e,t,r,n,i,s){let o=n?.blank===!1?void 0:await z4e(e,t,r,i,s);return{sessionId:r.id,updatedAt:BK(r,o??n),running:!1,blank:n?.blank===!1?!1:o?.blank??!1,...c8(r)}}l(B4e,"summarizeCold");function dK(e){return e instanceof JZ?{code:e.code,message:e.message,details:{path:e.path}}:{code:"internal",message:e instanceof Error?e.message:String(e),details:{}}}l(dK,"directoryError");function fK(e){return{rpcId:e.rpcId,payload:{type:"approval/requested",sessionId:e.sessionId,approvalId:e.approvalId,toolName:e.toolName,...e.callId===void 0?{}:{callId:e.callId},...e.reason===void 0?{}:{reason:e.reason}}}}l(fK,"requestedFrame");function W4e(e,t){if(e.sessionId!==t.sessionId)return!1;let r=e.answer.answers;return r.length!==t.questions.length?!1:r.every((n,i)=>{let s=t.questions[i];if(n.id!==s.id||new Set(n.selected).size!==n.selected.length)return!1;let o=n.custom?.trim();if(o!==void 0&&o===""||s.multiSelect!==!0&&(o!==void 0&&n.selected.length>0||n.selected.length>1))return!1;let a=new Set(s.options?.map(c=>c.label)??[]);return n.selected.every(c=>a.has(c))})}l(W4e,"matchesQuestions");function WK(e,t,r,n){try{if(t.type==="tool/call"){let{name:i,arguments:s}=t.data,o=e.tools.get(i,n)?.presentCall?.(JSON.parse(s));return o===void 0?void 0:{for:"call",view:o}}if(t.type==="tool/result"){let{message:i,meta:s}=t.data,[o]=i.content,a=i.source.callId,c=r(a);if(c===void 0)return;let u=e.tools.get(c.name,n)?.presentResult?.(c.args,{content:o.content,isError:o.isError===!0,...s===void 0?{}:{meta:s}});return u===void 0?void 0:{for:"result",view:u}}}catch(i){console.error(`api-proxy: presenter failed for ${t.type}, falling back to generic: ${String(i)}`)}}l(WK,"viewFor");function qK(e,t){for(let r=e.length-1;r>=0;r--){let n=e[r];if(n.type!=="tool/call")continue;let i=n.data;if(i.callId===t)try{return{name:i.name,args:JSON.parse(i.arguments)}}catch{return}}}l(qK,"backscanArgs");function pK(e,t,r,n,i){let s=F4e(t,r,n??N4e);return{events:s.events.map(o=>{let a=WK(e,o,c=>qK(s.events,c),i);return{event:o,...a===void 0?{}:{view:a}}}),hasMore:s.hasMore}}l(pK,"historyPage");function hK(e,t){let r=e.get("sessionProjections");if(r!==void 0)return r.snapshot(t)}l(hK,"projectionsFor");function mK(e,t,r){try{let n=r!==void 0?e.get("sessionProjections")?.snapshot(r):e.get("sessionProjectionCache")?.cachedSnapshot(t);return n!==void 0&&Object.keys(n.values).length>0?n:void 0}catch(n){e.logger.warn(`session.list: projection column for "${t.id}" failed (serving the row without it): ${String(n)}`);return}}l(mK,"listProjectionsFor");function gK(e,t){let r=e.get("sessionProjections");if(r!==void 0)return r.restore({},t,0).snapshot}l(gK,"detachedProjectionsFor");function yK(e,t,r){try{return r()}catch(n){e.logger.warn(`subagent.history: projections for "${t}" failed (serving the page without them): ${String(n)}`);return}}l(yK,"subagentHistoryProjections");function q4e(e,t,r){let n=e.payload.childSessionId;if(r.aborted)return ke(e,{code:"cancelled",message:"subagent prompt was cancelled",details:{}});if(t instanceof Sl)switch(t.code){case"NOT_RESUMABLE":return ke(e,{code:"subagent-not-resumable",message:"subagent cannot be resumed",details:{childSessionId:n}});case"UNAUTHORIZED":return ke(e,{code:"subagent-unauthorized",message:"subagent does not belong to this parent",details:{childSessionId:n}});case"DRAINING":case"ACTIVATION_CLOSING":case"CONTINUATION_UNAVAILABLE":case"PERSISTENCE_UNAVAILABLE":return ke(e,{code:"subagent-delivery-unavailable",message:"subagent follow-up is temporarily unavailable",details:{childSessionId:n}});default:break}return ke(e,{code:"internal",message:"subagent prompt failed",details:{}})}l(q4e,"subagentPromptError");function HK(){return{code:"internal",message:"subagent catalog is unavailable: this deployment does not mount the sessionProjections registry (load @deepseek-ai/dsh-session-projection)",details:{}}}l(HK,"projectionsUnavailableError");async function vK(e,t,r){let{parentSessionId:n,childSessionId:i,mode:s}=t;try{let o=(await e.subagents.listChildren(n,r)).find(a=>a.id===i);return o===void 0||o.kind==="child"&&o.mode!==s?{error:{code:"subagent-not-found",message:`session "${i}" is not a ${s} direct child of "${n}"`,details:{parentSessionId:n,childSessionId:i}}}:o.kind==="diagnostic"?{error:{code:"subagent-catalog-diagnostic",message:`subagent "${i}" is ${o.reason}`,details:{parentSessionId:n,childSessionId:i,reason:o.reason}}}:{entry:o}}catch(o){return r?.aborted||o instanceof Sl&&o.code==="CANCELLED"?{error:{code:"cancelled",message:"subagent catalog read was cancelled",details:{}}}:o instanceof Sl&&o.code==="SUBAGENT_CONTROL_PROJECTIONS_UNAVAILABLE"?{error:HK()}:{error:{code:"internal",message:"subagent catalog read failed",details:{}}}}}l(vK,"catalogChild");function K0(e){return{code:"agent-preset-not-found",message:"this deployment composes no agent presets",details:{agentPreset:e,available:[]}}}l(K0,"noRoster");function Y0(e,t){return t instanceof B0?{code:"agent-preset-not-found",message:t.message,details:{agentPreset:t.presetId,available:[...t.available]}}:t instanceof hu?{code:"agent-preset-read-only",message:t.message,details:{agentPreset:e,reason:t.message}}:t instanceof J7||t instanceof W0?{code:"agent-preset-invalid",message:t.message,details:{agentPreset:e,reason:t.message}}:{code:"internal",message:`agent preset "${e}": ${String(t)}`,details:{}}}l(Y0,"presetError");var wK=class extends Error{static{l(this,"AgentPresetConflict")}sessionId;requestedPreset;existingPreset;constructor(e,t,r){super(r===void 0?`session "${e}" records no agent preset, so it cannot be adopted under one; a deployment composing no roster records none on any session \u2014 `:`session "${e}" already runs agent preset ${JSON.stringify(r)}; requested ${JSON.stringify(t)}. A session's preset is fixed at creation.`),this.sessionId=e,this.requestedPreset=t,this.existingPreset=r}},i8=class extends Error{static{l(this,"SessionCwdConflict")}sessionId;requestedCwd;existingCwd;constructor(e,t,r){super(`session "${e}" already exists with cwd ${JSON.stringify(r)}; requested ${JSON.stringify(t)}`),this.sessionId=e,this.requestedCwd=t,this.existingCwd=r}},bK=class extends Error{static{l(this,"WorkspaceNameConflictError")}workspaceName;constructor(e){super(`workspace name '${e}' is already in use`),this.workspaceName=e,this.name="WorkspaceNameConflictError"}};function X0(e,t){return ke(e,{code:"workspace-not-found",message:`workspace "${t}" not found`,details:{workspaceId:t}})}l(X0,"workspaceNotFound");function cp(e){return{workspaceId:e.id,path:e.path,title:e.title,sessionIds:[...e.sessionIds],createdAt:e.createdAt,updatedAt:e.updatedAt}}l(cp,"workspaceView");function H4e(e,t){let r=g7.parse(t);return{workspaceId:e,path:r.path,title:r.title,sessionIds:[...r.sessionIds],createdAt:r.createdAt,updatedAt:r.updatedAt}}l(H4e,"changedWorkspaceView");function G4e(e,t){let r=t.sessionExportCompressionLevel??6,n=t.coldBlankProbeMaxBytes??1024,i=l(()=>{let{provider:I,model:R}=t.defaultModelSelection();return{provider:I,model:R}},"agentOptions"),s=new WeakMap,o=new Map,a=new Map,c=Promise.resolve(),u=new Map,d=new Map,f=new Set,p=new WeakMap;function h(I,R){let C=(p.get(I)??Promise.resolve()).then(R);return p.set(I,C.then(()=>{},()=>{})),C}l(h,"serializeImageAdmission");function m(I){let R=s.get(I);if(R!==void 0)return R;let C,U={get current(){if(C!==void 0)return C;let K=I.session.requestHeader()?.config;return K===void 0?t.defaultModelSelection():{provider:K.provider,model:K.model,...K.reasoningEffort===void 0?{}:{reasoningEffort:K.reasoningEffort}}},set current(K){C=K},assembled:void 0};return Hp(I.ctx,U),s.set(I,U),U}l(m,"selectionFor");function g(I){let R=I.agent;if(R===void 0)throw new Error("api-proxy: agent setup has no scoped agent");m(R)}l(g,"installSelection");function y(I,R,C){if(!(R===void 0||R===C))throw new wK(I,R,C)}l(y,"assertPresetUnchanged");async function x(I){let R=e.get("agentPresets");if(R===void 0)return{setup:l(U=>(g(U),Promise.resolve()),"setup")};let C=(await R.resolve(I)).id;return{agentPreset:C,setup:l(async U=>{g(U),await R.mount(U,C)},"setup")}}l(x,"composeAgent");let w=l((I,R)=>Il(e,I,R),"hasSubagentOwner"),b=l(I=>gu(I),"subagentOwnershipError"),k=l(I=>r8(e,I),"inspectServable"),S=eK(e,{agentOptions:i,setup:l(async({meta:I,events:R})=>(await x(ua({header:I,events:R}))).setup,"setup")});function A(I){let R=en(I);for(let C of f)C.push(R)}l(A,"broadcast"),e.inject(["sessionProjections"],I=>{I.sessionProjections.onChanged((R,C,U,K)=>{A({type:"session/projection",sessionId:R.id,key:C,value:U,seq:K})})}),e.inject(["sessionProjections"],I=>{I.sessionProjections.register({key:"sessionListMetadata",stateSchema:rK,init:l(()=>({blank:!0,lastPromptAt:null}),"init"),apply:jK,wire:{viewSchema:rK,view:l(R=>R,"view")},stateVersion:1})}),e.inject(["sessionProjections","attachments"],I=>{I.sessionProjections.register({key:"imageLimits",stateSchema:v.null(),init:l(()=>null,"init"),apply:l(R=>R,"apply"),wire:{viewSchema:f4e,view:l(()=>I.attachments.imageLimits,"view")},stateVersion:1})});let $=l((I,R)=>{let C=l(U=>{let K=U==="next-turn"?I.inbox.nextTurn:I.inbox.nextStep;return R?.target===U?K.toSpliced(R.start,R.removedCount??0,...R.inserted):K},"project");return[...C("next-turn").map(U=>({id:U.id,placement:"queued",message:U})),...C("next-step").map(U=>({id:U.id,placement:U.source.kind==="user"?"steering":"context",message:U}))]},"queueItems");e.on("session/event",(I,R)=>{if(R.type!=="agent/inbox/spliced")return;let C=e.agents.get(I.id);C?.session===I&&A({type:"session/queue",sessionId:I.id,items:$(C,R.data)})});function O(I,R){u.delete(I.rpcId),I.signal!==void 0&&I.onAbort!==void 0&&I.signal.removeEventListener("abort",I.onAbort),A({type:"question/resolved",sessionId:I.sessionId,questionRpcId:I.rpcId,outcome:R})}l(O,"claimQuestion");let _=e.userQuestions.registerProvider({ask(I){let R=I.agent?.id;return R===void 0?Promise.reject(new lp("web user interaction requires an agent-owned session","ASK_MISSING_AGENT")):new Promise((C,U)=>{let K=crypto.randomUUID(),J={rpcId:K,sessionId:R,questions:I.questions,resolve:C,reject:U,...I.signal===void 0?{}:{signal:I.signal}},j=l(()=>{O(J,"cancelled"),U(new lp("ask_user_question was aborted before the user answered","ASK_ABORTED"))},"onAbort");J.onAbort=j,u.set(K,J),I.signal?.addEventListener("abort",j,{once:!0});let oe={rpcId:K,payload:{type:"question/requested",sessionId:R,questions:I.questions}};for(let ne of f)ne.push(oe)})}});e.effect(()=>()=>{_();for(let I of[...u.values()])O(I,"cancelled"),I.reject(new lp("web user-questions provider was disposed","ASK_ABORTED"))},"api-proxy: user-questions provider"),e.get("approval")!==void 0&&(e.effect(()=>()=>{for(let I of[...d.values()])I.resolve("cancelled")},"api-proxy: approval registry teardown"),e.on("approval/request",(I,R)=>{if(I.signal?.aborted===!0)return Promise.resolve("cancelled");let C=I.agent.session.events,U=new Set;for(let oe of d.values())U.add(oe.approvalId);let K=new Set,J;for(let oe=C.length-1;oe>=0;oe-=1){let ne=C[oe];if(ne.type==="approval/decided")K.add(ne.data.id);else if(ne.type==="approval/asked"){if(K.has(ne.data.id)||U.has(ne.data.id)||(I.callId??null)!==(ne.data.callId??null))continue;J=ne.data.id;break}}if(J===void 0)return R();let j=J;return new Promise(oe=>{let ne=l(He=>{d.delete(We.rpcId)&&(I.signal?.removeEventListener("abort",Ee),A({type:"approval/resolved",sessionId:We.sessionId,approvalId:j,outcome:He}),oe(He))},"settle"),Ee=l(()=>{ne("cancelled")},"onAbort"),We={rpcId:crypto.randomUUID(),sessionId:I.agent.session.id,approvalId:j,toolName:I.toolName,...I.callId===void 0?{}:{callId:I.callId},...I.reason===void 0?{}:{reason:I.reason},resolve:ne};d.set(We.rpcId,We),I.signal?.addEventListener("abort",Ee,{once:!0});let $e=fK(We);for(let He of f)He.push($e)})}));async function F(I){let R=e.sessions.get(I);if(R!==void 0)return{id:R.id,header:R.header,events:[...R.events]};let C=await k(I);return{id:C.meta.id,header:C.meta,events:C.events}}l(F,"readSessionState");async function D(I){let R=e.workspaceRegistry.list(),C=R.find(K=>K.sessionIds.includes(I.id));if(C!==void 0||I.header.origin!=="subagent")return C;let U=await e.sessionQuery.traceSession(I.id);for(let K of U.ancestors){let J=R.find(j=>j.sessionIds.includes(K.header.id));if(J!==void 0)return J}}l(D,"forkWorkspace");async function B(I){let R=e.sessions.get(I);if(R!==void 0)return{kind:"attached",session:R};let C=await k(I);return{kind:"detached",header:C.meta,events:C.events}}l(B,"historySourceFor");function ee(I){return I.kind==="detached"?{header:I.header,events:I.events}:{header:I.session.header,events:I.session.events}}l(ee,"sourceSession");function L(I,R){if(I.kind==="detached"){let K=R?gK(e,I.events):void 0;return{events:I.events,...K===void 0?{}:{projections:K}}}let C=[...I.session.events],U=R?hK(e,I.session):void 0;return{events:C,...U===void 0?{}:{projections:U}}}l(L,"historyCutOf");async function W(I,R){let C=e.get("agents")?.get(I);if(C!==void 0)return C;let U=e.get("agentPresets");if(U!==void 0)try{return await U.standingKeyFor(ua(R))}catch{return}}l(W,"presenterScopeFor");async function z(I,R,C,U){let K=a.get(I);K===void 0&&(K=(async()=>{let j=e.sessions.get(I),oe=e.agents.get(I);if(j!==void 0&&w(j,oe))throw new Bs(I);if(oe!==void 0)return oe;let ne=C?e.get("sessionPersistence"):void 0,Ee=ne===void 0?void 0:(await ne.list()).find($e=>$e.id===I);if(ne!==void 0&&Ee!==void 0){let $e=await ne.inspect(I);if(w({header:$e.meta},void 0))throw new Bs(I);if($e.meta.cwd!==R)throw new i8(I,R,$e.meta.cwd);let He=ua({header:$e.meta,events:$e.events});return y(I,U,He),(await e.agents.resume({resumeSessionId:I,agentOptions:i(),setup:(await x(He)).setup})).agent}try{await Dke(R,{recursive:!0})}catch($e){throw new Error(`failed to ensure project directory "${R}": ${String($e)}`,{cause:$e})}let We=await x(U);return(await e.agents.create({sessionId:I,agentOptions:i(),meta:{cwd:R,...We.agentPreset===void 0?{}:{agentPreset:We.agentPreset}},setup:We.setup})).agent})().catch(j=>{let oe=e.agents.get(I);if(oe!==void 0){if(w(oe.session,oe))throw new Bs(I);return oe}let ne=e.sessions.get(I);throw ne!==void 0&&w(ne,void 0)?new Bs(I):j}).finally(()=>{a.delete(I)}),a.set(I,K));let J=await K;if(w(J.session,J))throw new Bs(I);if(y(I,U,ua(J.session)),J.session.header.cwd!==R)throw new i8(I,R,J.session.header.cwd);return J}l(z,"ensureSession");function Q(I){let R=c.then(async()=>{let C=await e.workspaceRegistry.resolveByPath(I);return C!==void 0?{workspace:C,created:!1}:{workspace:await e.workspaceRegistry.create(I),created:!0}});return c=R.then(()=>{},()=>{}),R}l(Q,"ensureWorkspace");async function H(I){I?.throwIfAborted();let R=l(J=>{let j=e.agents.get(J.id),oe=mK(e,J.header,J);return{...j4e(J,j?.status==="running"),...oe===void 0?{}:{projections:oe}}},"summarizeAttached"),C=e.sessions.list().map(R);I?.throwIfAborted();let U=new Set(C.map(J=>J.sessionId)),K=e.get("sessionPersistence");if(K!==void 0){let J=(await K.list(I)).filter(j=>!U.has(j.id)&&j.cwd!==void 0);I?.throwIfAborted();for(let j=0;j<J.length;j+=iK){I?.throwIfAborted();let oe=J.slice(j,j+iK),ne=await Promise.allSettled(oe.map(async He=>{let lt=mK(e,He,void 0),Lt=await B4e(e,K,He,lt?.values.sessionListMetadata,n,I),Pt=e.sessions.get(He.id);return Pt!==void 0?R(Pt):{...Lt,...lt===void 0?{}:{projections:lt}}})),Ee=[],We=!1,$e;for(let He of ne)He.status==="fulfilled"?Ee.push(He.value):We||(We=!0,$e=He.reason);if(We)throw $e;I?.throwIfAborted(),C.push(...Ee)}}return C.sort((J,j)=>j.updatedAt-J.updatedAt),C}l(H,"listVisibleSessionSummaries");function G(I){let R=e.get("agentPresets")?.serviceFor(I,"goals")??e.get("goals");return R===void 0?{error:{code:"internal",message:"goal service is absent: neither this session's agent preset nor the host composition mounts @deepseek-ai/dsh-goal",details:{}}}:R}l(G,"goalServiceFor");function Z(I,R){let C=R instanceof hi?{goalCode:R.code}:{};return ke(I,{code:"internal",message:String(R),details:C})}l(Z,"goalError");async function ue(I,R){let C=await S(I.payload.sessionId);if("error"in C)return ke(I,C.error);let U=G(C.agent);if("error"in U)return ke(I,U.error);try{let K=R(U,C.agent);return yt(I,{ref:{id:K.id,revision:K.revision}})}catch(K){return Z(I,K)}}l(ue,"mutateGoal");function pe(I){let R=e.get("llm");return R===void 0||R.listProviders().some(C=>C.id===I)}l(pe,"routeServed");async function ce(I,R){let C=await S(R);if("error"in C)return{refused:ke(I,C.error)};let U=C.agent,K=m(U).current;return pe(K.provider)?{agent:U}:{refused:ke(I,{code:"model-unavailable",message:`no adapter serves provider "${K.provider}"; select a model for this session`,details:{provider:K.provider,model:K.model}})}}l(ce,"turnAgentFor");function V(){return{code:"internal",message:"settings service is absent: this deployment does not mount a settings provider (e.g. @deepseek-ai/dsh-settings-file) in its composition",details:{}}}l(V,"settingsAbsent");async function ve(I,R,C,U){try{return await U(R,C),yt(I,{opened:!0})}catch(K){return C.aborted?ke(I,{code:"cancelled",message:"path open was aborted",details:{}}):ke(I,{code:"internal",message:`path open failed: ${K instanceof Error?K.message:String(K)}`,details:{}})}}l(ve,"openTarget");function Fe(I,R,C){return ve(I,R,C,t.openPath??((U,K)=>C4e(U,K)))}l(Fe,"openPath");function Ce(I,R,C){return ve(I,R,C,t.openTextFile??((U,K)=>O4e(U,K)))}l(Ce,"openTextFile");function Pe(){return t.canOpenPath!==void 0?t.canOpenPath():t.openPath!==void 0||T4e()}l(Pe,"canOpenPaths");function Re(){return{code:"internal",message:"credentials service is absent: this deployment does not mount a credential provider (e.g. @deepseek-ai/dsh-credentials-local) in its composition",details:{}}}l(Re,"credentialsAbsent");function Le(I){return{ns:String(I.ns),schema:I.schema,value:I.value,...I.base===void 0?{}:{base:I.base},...I.user===void 0?{}:{user:I.user},applies:I.applies,secrets:(I.secrets??[]).map(R=>({path:[...R.path],set:R.set})),revision:I.revision}}l(Le,"namespaceView");async function de(I,R,C,U,K){let J=e.get("settings");if(J===void 0)return ke(I,V());let j=l(Ee=>Ee instanceof Bu?ke(I,{code:"settings-conflict",message:Ee.message,details:{ns:R,expected:Ee.expected,actual:Ee.actual}}):ke(I,{code:"settings-rejected",message:Ee instanceof Error?Ee.message:String(Ee),details:{ns:R}}),"rejected"),oe;try{oe=hn(R)}catch(Ee){return j(Ee)}try{C==="update"?await J.update(oe,U,K):C==="replace"?await J.replace(oe,U,K):await J.mutate(oe,U,K)}catch(Ee){return j(Ee)}let ne=J.describe({redactSecrets:!0}).find(Ee=>Ee.ns===oe);return ne===void 0?ke(I,{code:"internal",message:`settings namespace "${R}" was disposed after the ${C}`,details:{}}):yt(I,Le(ne))}return l(de,"settingsWrite"),{sessions:{async list(I){return yt(I,{items:await H()})},async search(I,R){let C=l(()=>ke(I,{code:"cancelled",message:"session search was aborted",details:{}}),"cancelled");if(go(R))return C();let U=e.get("sessionQuery");if(U===void 0)return ke(I,{code:"internal",message:"session search is unavailable: this deployment does not mount @deepseek-ai/dsh-session-query",details:{}});try{let K=await H(R);if(go(R))return C();if(K.length===0)return yt(I,{items:[],hasMore:!1});let J=new Set(K.map(He=>He.sessionId)),j=[],oe=new Set,ne=new Set,Ee,We=0,$e=20;for(;j.length<=20;){if(go(R))return C();if(We>=nK)throw new Error(`session search provider exceeded the ${nK}-call work budget`);We++;let He=Ee,lt=$e,Lt;try{Lt=await U.searchSessions({query:I.payload.query,eventFilters:[{kind:"type",values:["user/message","assistant/message"]},{kind:"surface",values:["current"]}],limit:lt,...He===void 0?{}:{cursor:He}},{signal:R})}catch(q){if(go(R))return C();if(He===void 0&&q instanceof Ld&&q.code==="SESSION_QUERY_INVALID_LIMIT"&<>1){$e=Math.max(1,Math.floor(lt/2));continue}if(He!==void 0&&q instanceof Ld&&q.code==="SESSION_QUERY_STALE_CURSOR"){j.length=0,oe.clear(),ne.clear(),Ee=void 0;continue}throw q}if(go(R))return C();let Pt=Lt.items.length;if(Pt>lt)throw new Error(`session search provider returned ${Pt} items; maximum is ${lt}`);for(let q of Lt.items){if(j.length>20||!J.has(q.header.id)||q.bestMatch.sessionId!==q.header.id||q.bestMatch.surface!=="current"||!UK.has(q.bestMatch.type)||oe.has(q.header.id))continue;let le=IK(q.bestMatch.snippet,240);oe.add(q.header.id),j.push({sessionId:q.header.id,snippet:le})}let E=Lt.nextCursor;if(E!==void 0){if(ne.has(E))throw new Error("session search provider repeated a continuation cursor");ne.add(E)}if(j.length>20||E===void 0)break;Ee=E}return yt(I,{items:j.slice(0,20),hasMore:j.length>20})}catch(K){return go(R)||K instanceof Ld&&K.code==="SESSION_QUERY_ABORTED"?C():ke(I,{code:"internal",message:`session search failed: ${String(K)}`,details:{}})}},async create(I){let R=I.payload.sessionId??`session-${crypto.randomUUID()}`,C;if(I.payload.workspaceId!==void 0&&(C=e.workspaceRegistry.get(I.payload.workspaceId),C===void 0))return ke(I,{code:"workspace-not-found",message:`workspace "${I.payload.workspaceId}" not found`,details:{workspaceId:I.payload.workspaceId}});let U=C?.path??I.payload.cwd??t.cwd,K=I.payload.agentPreset,J=I.payload.reuseWorkspaceBlank===!0&&C!==void 0&&C.sessionIds.includes(R)&&!e.workspaceRegistry.archivedSessionIds.includes(R),j;try{j=await z(R,U,I.payload.sessionId!==void 0,K)}catch(ne){if(ne instanceof wK)return ke(I,{code:"agent-preset-conflict",message:ne.message,details:{sessionId:ne.sessionId,requestedPreset:ne.requestedPreset,...ne.existingPreset===void 0?{}:{existingPreset:ne.existingPreset}}});let Ee=lK(I,ne);return Ee!==void 0?Ee:ne instanceof i8?ke(I,{code:"session-conflict",message:ne.message,details:{sessionId:ne.sessionId,requestedCwd:ne.requestedCwd,...ne.existingCwd===void 0?{}:{existingCwd:ne.existingCwd}}}):ne instanceof Bs?ke(I,b(ne.sessionId)):ke(I,{code:"internal",message:`failed to create session "${R}": ${String(ne)}`,details:{}})}if(C!==void 0)try{await C.attachSession(R)}catch(ne){return ke(I,{code:"workspace-attach-failed",message:`session "${R}" was created but could not attach to workspace "${C.id}": ${String(ne)}`,details:{sessionId:R,workspaceId:C.id}})}J&&n8(j.session)&&e.get("permissionPresets")?.refreshDefaultForReuse(j.session);let oe=ua(j.session);return yt(I,{sessionId:R,...oe===void 0?{}:{agentPreset:oe}})},async history(I){let{sessionId:R,beforeSeq:C,maxMessages:U}=I.payload;try{let K=await B(R),J=await W(R,ee(K)),j=L(K,C===void 0),oe=pK(e,j.events,C,U,J);return yt(I,{events:oe.events,hasMore:oe.hasMore,...j.projections===void 0?{}:{projections:j.projections}})}catch(K){return K instanceof da?ke(I,{code:"session-not-found",message:K.message,details:{sessionId:R}}):ke(I,{code:"internal",message:`history unavailable for session "${R}": ${String(K)}`,details:{}})}},async models(I){let{sessionId:R}=I.payload,C=await S(R);if("error"in C)return ke(I,C.error);let U=m(C.agent).current,{groups:K,failures:J}=await aK(e),j=pe(U.provider);return yt(I,{current:{...U},routable:j,groups:K,failures:J})},async selectModel(I){let{sessionId:R,provider:C,model:U,reasoningEffort:K}=I.payload,J=await S(R);return"error"in J?ke(I,J.error):h(J.agent,async()=>{try{let j=await e.llm.resolveCallConfig({provider:C,model:U,...K===void 0?{}:{reasoningEffort:K}});if([...J.agent.inbox.nextTurn,...J.agent.inbox.nextStep].some(ne=>_o(ne.content))||L4e(J.agent.session.deriveMessages())){let ne=await e.llm.resolveModelInfo(j.provider,j.model);if(ne.inputModalities!==void 0&&!ne.inputModalities.includes("image"))return ke(I,{code:"model-unavailable",message:`Model "${j.model}" does not accept image input, but this session already contains images; select an image-capable model.`,details:{provider:C,model:U}})}let oe={provider:j.provider,model:j.model,...j.reasoningEffort===void 0?{}:{reasoningEffort:j.reasoningEffort}};m(J.agent).current=oe;try{await t.saveDefaultModelSelection?.(oe)}catch(ne){e.logger.warn(`api-proxy: the model switch applies to this session but was not saved as the default: ${String(ne)}`)}return yt(I,{selected:{...oe}})}catch(j){return ke(I,{code:"model-unavailable",message:j instanceof Error?j.message:String(j),details:{provider:C,model:U}})}})},async rename(I){let{sessionId:R,title:C}=I.payload,U=await S(R);if("error"in U)return ke(I,U.error);let K=e.get("sessionTitle");if(K===void 0)return ke(I,{code:"internal",message:"renaming is unavailable: this deployment mounts no session-title service",details:{}});try{let J=K.rename(U.agent.session,C);return yt(I,{title:J.title,seq:J.eventSeq})}catch(J){return J instanceof qS?ke(I,{code:"title-invalid",message:J.message,details:{sessionId:R}}):ke(I,{code:"internal",message:`failed to rename session "${R}": ${String(J)}`,details:{}})}},async fork(I){let{sessionId:R,atSeq:C}=I.payload,U;try{U=await F(R)}catch($e){return $e instanceof da?ke(I,{code:"session-not-found",message:$e.message,details:{sessionId:R}}):ke(I,{code:"internal",message:`fork source unavailable for session "${R}": ${String($e)}`,details:{}})}let K=U.events,J=K.at(-1)?.seq??-1,j=(C===void 0?void 0:K.find($e=>$e.type==="turn/end"&&$e.seq>=C))??(C===void 0||C>J?K.findLast($e=>$e.type==="turn/end"):void 0);if(j===void 0)return ke(I,{code:"fork-unavailable",message:C!==void 0&&C<=J?`session "${R}" has not completed the turn containing event ${String(C)}`:`session "${R}" has no completed turn to fork from`,details:{sessionId:R}});let oe=j.seq+1;for(;oe<K.length&&K[oe]?.type!=="turn/start";)oe++;let ne;try{ne=await D(U)}catch($e){return ke(I,{code:"internal",message:`failed to resolve fork workspace for session "${R}": ${String($e)}`,details:{}})}let Ee=`session-${crypto.randomUUID()}`,We=await x(ua(U));try{await e.agents.create({sessionId:Ee,seed:K.slice(0,oe),meta:{...U.header.cwd===void 0?{}:{cwd:U.header.cwd},parentSession:U.id,seedLength:oe,...We.agentPreset===void 0?{}:{agentPreset:We.agentPreset}},agentOptions:i(),setup:We.setup})}catch($e){return ke(I,{code:"internal",message:`failed to fork session "${R}": ${String($e)}`,details:{}})}if(ne!==void 0)try{await ne.attachSession(Ee)}catch($e){return ke(I,{code:"workspace-attach-failed",message:`session "${Ee}" was forked but could not attach to workspace "${ne.id}": ${String($e)}`,details:{sessionId:Ee,workspaceId:ne.id}})}return yt(I,{sessionId:Ee})},async prompt(I){let{sessionId:R,mode:C,content:U,clientTimeZone:K}=I.payload,J=K===void 0?void 0:oK(K);if(K!==void 0&&J===void 0)return ke(I,{code:"invalid-time-zone",message:"clientTimeZone must be UTC or a valid IANA Area/Location name",details:{value:K}});let j=await ce(I,R);if("refused"in j)return j.refused;let oe=j.agent,ne={kind:"user",rpcId:I.rpcId,...J===void 0?{}:{clientTimeZone:J}},Ee=U.some($e=>$e.type==="image"),We=l(async()=>{try{if(Ee){let He=m(oe).current,lt=await e.llm.resolveModelInfo(He.provider,He.model);if(lt.inputModalities!==void 0&&!lt.inputModalities.includes("image"))return ke(I,{code:"attachment-error",message:`Model "${He.model}" does not support image input.`,details:{reason:"MODEL_DOES_NOT_SUPPORT_IMAGES"}})}let $e=vs({content:await P4e(e,U),source:ne});C==="steer"?oe.steer($e):oe.followup($e)}catch($e){return $e instanceof Ct?ke(I,{code:"attachment-error",message:$e.message,details:{reason:$e.code}}):ke(I,{code:"agent-busy",message:"prompt rejected",details:{reason:String($e)}})}return yt(I,{accepted:!0})},"admit");return Ee?h(oe,We):We()},async attachment(I){let{sessionId:R,attachmentId:C}=I.payload,U;try{U=await F(R)}catch(J){return J instanceof da?ke(I,{code:"session-not-found",message:J.message,details:{sessionId:R}}):ke(I,{code:"internal",message:`attachment authorization unavailable for session "${R}": ${String(J)}`,details:{}})}let K=M4e(U.events,String(C));if(K===void 0)return ke(I,{code:"attachment-error",message:"Image is not referenced by this session.",details:{reason:"ATTACHMENT_NOT_REFERENCED"}});try{let J=await e.attachments.readImage(K);return yt(I,{attachment:J.ref,data:Buffer.from(J.data).toString("base64")})}catch(J){return J instanceof Ct?ke(I,{code:"attachment-error",message:J.message,details:{reason:J.code}}):ke(I,{code:"internal",message:"Unable to read image attachment.",details:{}})}},updateQueue(I){let{sessionId:R,itemId:C,action:U}=I.payload;if(U.kind==="edit"&&U.content.some(oe=>oe.type!=="text"))return Promise.resolve(ke(I,{code:"attachment-error",message:"queue edits accept text content only",details:{reason:"QUEUE_EDIT_NON_TEXT"}}));let K=e.agents.get(R);if(K!==void 0&&w(K.session,K))return Promise.resolve(ke(I,b(R)));if(K===void 0)return Promise.resolve(ke(I,{code:"queue-item-not-found",message:"queued item is no longer pending",details:{itemId:C}}));let J=K.inbox.nextTurn.some(oe=>oe.id===C)?"next-turn":K.inbox.nextStep.some(oe=>oe.id===C)?"next-step":void 0,j=J===void 0?void 0:(J==="next-turn"?K.inbox.nextTurn:K.inbox.nextStep).find(oe=>oe.id===C);return J===void 0||j===void 0?Promise.resolve(ke(I,{code:"queue-item-not-found",message:"queued item is no longer pending",details:{itemId:C}})):U.kind==="steer"&&(J!=="next-turn"||K.status!=="running")?Promise.resolve(ke(I,{code:"steer-unavailable",message:"current turn no longer accepts steering",details:{itemId:C}})):(U.kind==="edit"?K.inbox.replace(C,Io({...j,content:U.content})):(K.inbox.remove(C),U.kind==="steer"&&K.steer(j)),Promise.resolve(yt(I,{accepted:!0})))},cancel(I){let{sessionId:R}=I.payload,C=e.agents.get(R);return C===void 0?Promise.resolve(ke(I,{code:"session-not-found",message:`session "${R}" not found (not attached)`,details:{sessionId:R}})):w(C.session,C)?Promise.resolve(ke(I,b(R))):(C.cancel({kind:"user"},{keepInbox:!0}),Promise.resolve(yt(I,{accepted:!0})))}},subagents:{async list(I,R){try{return yt(I,{entries:(await e.subagents.listChildren(I.payload.parentSessionId,R)).map(C=>C.kind==="child"?{...C,activity:e.agents.get(C.id)?.status==="running"?"running":"inactive"}:C),parentAvailable:e.agents.get(I.payload.parentSessionId)!==void 0})}catch(C){return R?.aborted||C instanceof Sl&&C.code==="CANCELLED"?ke(I,{code:"cancelled",message:"subagent catalog read was cancelled",details:{}}):C instanceof Sl&&C.code==="SUBAGENT_CONTROL_PROJECTIONS_UNAVAILABLE"?ke(I,HK()):ke(I,{code:"internal",message:"subagent catalog read failed",details:{}})}},async history(I,R){let{parentSessionId:C,childSessionId:U,mode:K,beforeSeq:J,maxMessages:j}=I.payload,oe=await vK(e,{parentSessionId:C,childSessionId:U,mode:K},R);if(oe.error!==void 0)return ke(I,oe.error);let ne,Ee,We,$e=e.sessions.get(U);if($e!==void 0)ne=$e.header,Ee=[...$e.events],We=J===void 0?yK(e,U,()=>hK(e,$e)):void 0;else try{let He=await k(U);ne=He.meta,Ee=He.events,We=J===void 0?yK(e,U,()=>gK(e,He.events)):void 0}catch(He){return R?.aborted?ke(I,{code:"cancelled",message:"subagent history read was cancelled",details:{}}):He instanceof da?ke(I,{code:"subagent-not-found",message:"subagent disappeared during history read",details:{parentSessionId:C,childSessionId:U}}):ke(I,{code:"internal",message:"subagent history read failed",details:{}})}return R?.aborted?ke(I,{code:"cancelled",message:"subagent history read was cancelled",details:{}}):ne.parentSession!==C?ke(I,{code:"subagent-unauthorized",message:"subagent parent changed during history read",details:{childSessionId:U}}):yt(I,{...pK(e,Ee,J,j),...We===void 0?{}:{projections:We}})},async prompt(I,R){let{parentSessionId:C,childSessionId:U,content:K,clientTimeZone:J}=I.payload,j=J===void 0?void 0:oK(J);if(J!==void 0&&j===void 0)return ke(I,{code:"invalid-time-zone",message:"clientTimeZone must be UTC or a valid IANA Area/Location name",details:{value:J}});let oe=e.agents.get(C);if(oe===void 0)return ke(I,{code:"subagent-parent-unavailable",message:`parent session "${C}" is not live`,details:{parentSessionId:C}});let ne=await vK(e,{parentSessionId:C,childSessionId:U,mode:"continuable"},R);if(ne.error!==void 0)return ke(I,ne.error);try{return yt(I,{messageId:await e.subagents.followup(oe,U,K,{source:{kind:"user",rpcId:I.rpcId,...j===void 0?{}:{clientTimeZone:j}},signal:R})})}catch(Ee){return q4e(I,Ee,R)}},interrupt(I){let{parentSessionId:R,childSessionId:C}=I.payload;try{e.subagents.interrupt(C,{kind:"user",parentSessionId:R})}catch(U){return U instanceof Sl&&U.code==="UNAUTHORIZED"?Promise.resolve(ke(I,{code:"subagent-unauthorized",message:"subagent does not belong to this parent",details:{childSessionId:C}})):Promise.resolve(ke(I,{code:"internal",message:"subagent interrupt failed",details:{}}))}return Promise.resolve(yt(I,{accepted:!0}))}},workspace:{list(I){return Promise.resolve(yt(I,{items:e.workspaceRegistry.list().map(cp),archivedSessionIds:[...e.workspaceRegistry.archivedSessionIds]}))},async create(I){let{path:R}=I.payload;try{let{workspace:C,created:U}=await Q(R);return yt(I,{workspace:cp(C),created:U})}catch(C){return ke(I,{code:"workspace-invalid-path",message:`cannot create a workspace at "${R}": ${C instanceof Error?C.message:String(C)}`,details:{path:R}})}},async rename(I){let{payload:R}=I,C=e.workspaceRegistry.get(R.workspaceId);if(C===void 0)return X0(I,R.workspaceId);let U=R.title.trim(),K=c.then(async()=>{if(U!==C.title){if(e.workspaceRegistry.list().some(J=>J.id!==C.id&&J.title===U))throw new bK(U);await C.setTitle(U)}});c=K.then(()=>{},()=>{});try{await K}catch(J){if(J instanceof bK)return ke(I,{code:"workspace-name-conflict",message:J.message,details:{name:J.workspaceName}});throw J}return yt(I,{workspace:cp(C)})},async delete(I){let{workspaceId:R}=I.payload,C=c.then(()=>e.workspaceRegistry.delete(R));return c=C.then(()=>{},()=>{}),await C?yt(I,{deleted:!0}):X0(I,R)},async insertBefore(I){let{workspaceId:R,beforeWorkspaceId:C}=I.payload;try{return yt(I,{workspaceIds:[...await e.workspaceRegistry.insertBefore(R,C===void 0?void 0:C)]})}catch(U){if(!(U instanceof N0))throw U;return X0(I,U.workspaceId)}},async insertSessionBefore(I){let{payload:R}=I,C=e.workspaceRegistry.get(R.workspaceId);if(C===void 0)return X0(I,R.workspaceId);try{await C.insertSessionBefore(R.sessionId,R.beforeSessionId)}catch(U){if(!(U instanceof O0))throw U;return ke(I,{code:"workspace-move-invalid",message:U.message,details:{workspaceId:R.workspaceId,sessionId:R.sessionId,...R.beforeSessionId===void 0?{}:{beforeSessionId:R.beforeSessionId}}})}return yt(I,{workspace:cp(C)})},async archiveSession(I){let{sessionId:R}=I.payload;try{await e.workspaceRegistry.archiveSession(R)}catch(C){if(!(C instanceof v7))throw C;return ke(I,{code:"session-not-found",message:C.message,details:{sessionId:R}})}return yt(I,{archivedSessionIds:[...e.workspaceRegistry.archivedSessionIds]})}},host:{describe(I){let R=t.defaultModelSelection();return Promise.resolve(yt(I,{version:"0.0.1",cwd:t.cwd,provider:R.provider,model:R.model,attachedSessions:e.agents.list().length,home:Mke(),canOpenPath:Pe()}))},async pickDirectory(I,R){let C=e.directoryPicker.capability();if(C.kind!=="native")return ke(I,{code:"directory-picker-unavailable",message:`host.pickDirectory needs the native capability; the composed picker serves "${C.kind}"`,details:{capability:C.kind}});try{return yt(I,{path:await C.pick(R)})}catch(U){return R.aborted?ke(I,{code:"cancelled",message:"directory picker was aborted",details:{}}):ke(I,{code:"internal",message:`directory picker failed: ${U instanceof Error?U.message:String(U)}`,details:{}})}},async listDirectory(I,R){let C=e.directoryPicker.capability();if(C.kind!=="browse")return ke(I,{code:"directory-picker-unavailable",message:`host.listDirectory needs the browse capability; the composed picker serves "${C.kind}"`,details:{capability:C.kind}});try{return yt(I,await C.list(I.payload.path,R))}catch(U){return R.aborted?ke(I,{code:"cancelled",message:"directory listing was aborted",details:{}}):ke(I,dK(U))}},async createDirectory(I){let R=e.directoryPicker.capability();if(R.kind!=="browse")return ke(I,{code:"directory-picker-unavailable",message:`host.createDirectory needs the browse capability; the composed picker serves "${R.kind}"`,details:{capability:R.kind}});try{return yt(I,{path:await R.createDirectory(I.payload.path,I.payload.name)})}catch(C){return ke(I,dK(C))}},async openPath(I,R){return Fe(I,I.payload.path,R)}},goals:{async create(I){let{objective:R,maxGoalRounds:C}=I.payload;return ue(I,(U,K)=>U.create(K,{objective:R,...C!==void 0?{maxGoalRounds:C}:{}}))},async edit(I){let{ref:R,objective:C,maxGoalRounds:U}=I.payload;return ue(I,(K,J)=>K.edit(J,R,{...C!==void 0?{objective:C}:{},...U!==void 0?{maxGoalRounds:U}:{}}))},async pause(I){return ue(I,(R,C)=>R.pause(C,I.payload.ref))},async resume(I){return ue(I,(R,C)=>R.resume(C,I.payload.ref))},async complete(I){return ue(I,(R,C)=>R.complete(C,I.payload.ref))},async clear(I){let R=await S(I.payload.sessionId);if("error"in R)return ke(I,R.error);let C=G(R.agent);if("error"in C)return ke(I,C.error);try{return C.clear(R.agent,I.payload.ref),yt(I,{cleared:!0})}catch(U){return Z(I,U)}}},agentPresets:{async list(I){let R=e.get("agentPresets");if(R===void 0)return yt(I,{presets:[],authorable:!1,hasDocument:!1});let C=R.defaultId;return yt(I,{presets:(await R.list()).map(U=>({id:U.id,trust:U.trust,isDefault:U.id===C,...U.name===void 0?{}:{name:U.name},...U.description===void 0?{}:{description:U.description},...U.broken===void 0?{}:{broken:U.broken}})),authorable:R.authorable,hasDocument:Pe()})},async select(I){let{sessionId:R,agentPreset:C}=I.payload,U=e.get("agentPresets");if(U===void 0)return ke(I,{code:"agent-preset-not-found",message:"this deployment composes no agent presets",details:{agentPreset:C,available:[]}});let K=await S(R);if("error"in K)return ke(I,K.error);let{agent:J}=K,j=l(async()=>{if(!n8(J.session))return ke(I,{code:"agent-preset-locked",message:`session "${R}" has already started; its agent preset is fixed`,details:{sessionId:R,agentPreset:C}});try{let ne=await U.recompose(J.ctx,C);return J.session.append("agent-preset/selected",{agentPreset:ne.id}),yt(I,{agentPreset:ne.id})}catch(ne){let Ee=lK(I,ne);return Ee!==void 0?Ee:ke(I,{code:"internal",message:`failed to select agent preset "${C}": ${String(ne)}`,details:{}})}},"swap"),oe=(o.get(R)??Promise.resolve()).then(j);o.set(R,oe.catch(()=>{}));try{return await oe}finally{o.get(R)===oe&&o.delete(R)}},async read(I){let{agentPreset:R}=I.payload,C=e.get("agentPresets");if(C===void 0)return ke(I,K0(R));try{let U=await C.resolve(R);return yt(I,{agentPreset:U.id,trust:U.trust,content:await C.read(U.id),...U.name===void 0?{}:{name:U.name},...U.description===void 0?{}:{description:U.description}})}catch(U){return ke(I,Y0(R,U))}},async copy(I){let{from:R,agentPreset:C,name:U}=I.payload,K=e.get("agentPresets");if(K===void 0)return ke(I,K0(C));try{return await K.copy(R,C,U),yt(I,{agentPreset:C})}catch(J){return ke(I,Y0(C,J))}},async openDocument(I,R){let{agentPreset:C}=I.payload,U=e.get("agentPresets");if(U===void 0)return ke(I,K0(C));try{let K=await U.resolve(C);if(K.trust!=="user")throw new hu(K.id,"it ships with the deployment");let J=Uke(K.path);return Pe()?await Fe(I,J,R):yt(I,{opened:!1,path:J})}catch(K){return ke(I,Y0(C,K))}},async remove(I){let{agentPreset:R}=I.payload,C=e.get("agentPresets");if(C===void 0)return ke(I,K0(R));try{return await C.remove(R),yt(I,{})}catch(U){return ke(I,Y0(R,U))}}},skills:{async list(I){let{sessionId:R}=I.payload,C=e.sessions.get(R);if(C===void 0)return ke(I,{code:"session-not-found",message:`session "${R}" not found (not attached)`,details:{sessionId:R}});if(C.header.cwd===void 0)return ke(I,{code:"internal",message:`session "${R}" has no project cwd`,details:{}});let U=C.header.cwd,K=e.agents.get(R),J=e.get("agentPresets"),j=(K===void 0?void 0:J?.serviceFor(K,"skills"))??e.get("skills");if(j===void 0)return ke(I,{code:"internal",message:"skill registry is absent: neither this session's agent preset nor the host composition mounts @deepseek-ai/dsh-skill",details:{}});let oe=await W(R,C);try{return yt(I,{skills:(await j.list({cwd:U,scope:oe})).filter(gV).map(ne=>({name:ne.name,description:ne.description,...ne.whenToUse===void 0?{}:{whenToUse:ne.whenToUse},modelInvocable:ne.invocation.modelInvocable}))})}catch(ne){return ke(I,{code:"internal",message:`skill listing failed: ${String(ne)}`,details:{}})}}},settings:{describe(I){let R=e.get("settings");return R===void 0?Promise.resolve(ke(I,V())):Promise.resolve(yt(I,{writable:R.writable,hasDocument:R.documentPath!==void 0,namespaces:R.describe({redactSecrets:!0}).map(Le)}))},async openDocument(I,R){let C=e.get("settings");if(C===void 0)return ke(I,V());if(go(R))return ke(I,{code:"cancelled",message:"settings document open was aborted",details:{}});let U;try{U=await C.prepareDocument()}catch(K){return go(R)?ke(I,{code:"cancelled",message:"settings document preparation was aborted",details:{}}):ke(I,{code:"internal",message:`settings document preparation failed: ${K instanceof Error?K.message:String(K)}`,details:{}})}return U===void 0?ke(I,{code:"internal",message:"settings provider has no local document to open",details:{}}):go(R)?ke(I,{code:"cancelled",message:"settings document open was aborted",details:{}}):Ce(I,U,R)},update:l(I=>de(I,I.payload.ns,"update",I.payload.patch,I.payload.expectedRevision),"update"),replace:l(I=>de(I,I.payload.ns,"replace",I.payload.section,I.payload.expectedRevision),"replace"),mutate:l(I=>de(I,I.payload.ns,"mutate",I.payload.ops,I.payload.expectedRevision),"mutate")},credentials:{async describe(I){let R=e.get("credentials");if(R===void 0)return ke(I,Re());let C=await Promise.all(I.payload.refs.map(async U=>{let K=await R.describe(jn(U));return[U,{configured:K.configured,...K.source===void 0?{}:{source:K.source},writable:K.writable}]}));return yt(I,{credentials:Object.fromEntries(C)})},async set(I){let R=e.get("credentials");if(R===void 0)return ke(I,Re());let{ref:C,value:U}=I.payload;try{await R.set(jn(C),U)}catch(K){return ke(I,{code:"credential-rejected",message:K instanceof Error?K.message:String(K),details:{ref:C}})}return yt(I,{})},async unset(I){let R=e.get("credentials");if(R===void 0)return ke(I,Re());let{ref:C}=I.payload;try{await R.unset(jn(C))}catch(U){return ke(I,{code:"credential-rejected",message:U instanceof Error?U.message:String(U),details:{ref:C}})}return yt(I,{})}},llm:{providers(I){let R=e.llm.listProviders(),C=new Set(R.map(j=>j.id)),U=e.llm.listConfigurableProviders(),K=new Set(U.map(j=>j.provider)),J=U.map(j=>({provider:j.provider,displayName:j.displayName,settingsNs:j.settingsNs,settingsPath:[...j.settingsPath],active:C.has(j.provider),...j.declared===void 0?{}:{declared:j.declared}}));for(let j of R)K.has(j.id)||J.push({provider:j.id,displayName:j.name,settingsNs:"",settingsPath:[],active:!0});return Promise.resolve(yt(I,{providers:J}))},async models(I){return yt(I,await aK(e))},async discoverModels(I,R){let{settingsNs:C,provider:U,baseURL:K,api:J,apiKey:j}=I.payload;try{return yt(I,{models:await e.llm.discoverModels(C,{...U===void 0?{}:{provider:U},...K===void 0?{}:{baseURL:K},...J===void 0?{}:{api:J},...j===void 0?{}:{apiKey:j},...R===void 0?{}:{signal:R}})})}catch(oe){return ke(I,{code:"model-discovery-failed",message:oe instanceof Error?oe.message:String(oe),details:{settingsNs:C,...K===void 0?{}:{baseURL:K}}})}}},events:{mux(I,R){let C=new cK;f.add(C);for(let j of e.sessions.list())uK(C,j);for(let j of u.values())C.push({rpcId:j.rpcId,payload:{type:"question/requested",sessionId:j.sessionId,questions:j.questions}});for(let j of d.values())C.push(fK(j));for(let j of e.sessions.list()){let oe=e.agents.get(j.id);oe?.session===j&&oe.inbox.hasPending&&C.push(en({type:"session/queue",sessionId:j.id,items:$(oe)}))}let U=e.get("jobs");if(U!==void 0)for(let j of e.sessions.list()){let oe=Z0(U.list(e.agents.get(j.id)));oe.length>0&&C.push(en({type:"session/jobs",sessionId:j.id,jobs:oe}))}let K=new Map,J=[e.on("session/event",(j,oe)=>{if(oe.type==="tool/call"){let Ee=oe.data;try{let We=K.get(j.id);We===void 0&&K.set(j.id,We=new Map),We.set(Ee.callId,{name:Ee.name,args:JSON.parse(Ee.arguments)})}catch{}}else oe.type==="turn/end"&&K.delete(j.id);let ne=WK(e,oe,Ee=>K.get(j.id)?.get(Ee)??qK(j.events,Ee),e.agents.get(j.id));C.push(en({type:"session/event",sessionId:j.id,event:oe,...ne===void 0?{}:{view:ne}}))}),e.on("session/created",j=>{uK(C,j);let oe=U===void 0?[]:Z0(U.list(e.agents.get(j.id)));oe.length>0&&C.push(en({type:"session/jobs",sessionId:j.id,jobs:oe}))}),e.on("session/disposed",j=>{K.delete(j.id)}),...U===void 0?[]:[U.onJobsChanged(j=>{if(j!==void 0){C.push(en({type:"session/jobs",sessionId:j.id,jobs:Z0(U.list(j))}));return}for(let oe of e.sessions.list())C.push(en({type:"session/jobs",sessionId:oe.id,jobs:Z0(U.list(e.agents.get(oe.id)))}))})]];return C.iterate(R,()=>{f.delete(C);for(let j of J)j()})},host(I,R){let C=new cK,U=e.workspaceRegistry.list(),K=new Set(U.map(ne=>String(ne.id))),J=U.map(ne=>ne.id),j=e.workspaceRegistry.archivedSessionIds,oe=[e.on("session/created",ne=>{C.push(en({type:"host/session-added",sessionId:ne.id,blank:n8(ne),...c8(ne.header,ne.events)}))}),e.on("session/disposed",ne=>{C.push(en({type:"host/session-removed",sessionId:ne.id}))}),e.on("agent/status",({agent:ne,status:Ee})=>{C.push(en({type:"host/session-status",sessionId:ne.id,running:Ee==="running"}))}),e.on("agent/error",({agent:ne,error:Ee})=>{C.push(en({type:"host/agent-error",sessionId:ne.id,message:$o(Ee)}))}),e.on("domain/changed",ne=>{if(ne.domain==="workspace"){if(ne.table===""){if(ne.operation!=="put")return;let Ee=y7.parse(ne.value),We=Ee.workspaceIds.length===J.length&&Ee.workspaceIds.every($e=>K.has(String($e)))&&Ee.workspaceIds.some(($e,He)=>$e!==J[He]);for(let $e of Ee.workspaceIds){if(K.has($e))continue;let He=e.workspaceRegistry.get($e);if(He===void 0)throw new Error(`committed workspace registry references missing workspace "${$e}"`);K.add($e),C.push(en({type:"host/workspace-changed",workspace:cp(He)}))}J=[...Ee.workspaceIds],We&&C.push(en({type:"host/workspace-order-changed",workspaceIds:[...Ee.workspaceIds]})),(Ee.archivedSessionIds.length!==j.length||Ee.archivedSessionIds.some(($e,He)=>$e!==j[He]))&&(j=Ee.archivedSessionIds,C.push(en({type:"host/archived-sessions-changed",archivedSessionIds:[...Ee.archivedSessionIds]})));return}if(ne.table==="workspaces"){if(ne.operation==="deleted"){if(!K.delete(ne.key))return;C.push(en({type:"host/workspace-removed",workspaceId:ne.key}));return}K.has(ne.key)&&C.push(en({type:"host/workspace-changed",workspace:H4e(ne.key,ne.value)}))}}}),...QZ.map(ne=>e.on(ne,((...Ee)=>{C.push(en({type:"host/remote-event",event:ne,args:U4e(ne,Ee)}))})))];return C.iterate(R,()=>{for(let ne of oe)ne()})}},downloads:{async sessionLog(I,R){let C=zke(e);if(C.sessionQuery===void 0||C.sessionPersistence===void 0||C.attachments===void 0)return new Response("session log export is unavailable: missing session-query, session-persistence, or attachments service",{status:500});if(!C.sessionPersistence.supportsRawArtifacts)return new Response("session log export is unavailable: the persistence backend does not expose per-session raw artifacts",{status:501});let U={sessionQuery:C.sessionQuery,sessionPersistence:C.sessionPersistence,attachments:C.attachments,sessions:C.sessions},K;try{await kK(C,I.sessionId,R),K=await C.sessionPersistence.readRaw(I.sessionId,R),R.throwIfAborted()}catch{return R.throwIfAborted(),new Response("session log export failed to prepare the stored artifact",{status:500})}return K===void 0?new Response("session not found",{status:404}):new Response(e4e(U,K,I.sessionId,I.includeDescendants===!0,r,R),{headers:{"content-type":"application/zip","content-disposition":`attachment; filename="${Gke(I.sessionId)}"`}})}},respond(I){let R=d.get(I.rpcId);if(R!==void 0){if(!I.result.ok)return Promise.resolve({accepted:!1,reason:"bad-response"});let J=x4e.safeParse(I.result.value);return!J.success||J.data.approvalId!==R.approvalId||J.data.sessionId!==R.sessionId?Promise.resolve({accepted:!1,reason:"bad-response"}):(R.resolve(J.data.outcome),Promise.resolve({accepted:!0}))}let C=u.get(I.rpcId);if(C===void 0)return Promise.resolve({accepted:!1,reason:"not-pending"});if(!I.result.ok)return I.result.error.code!=="cancelled"?Promise.resolve({accepted:!1,reason:"bad-response"}):(O(C,"cancelled"),C.reject(new lp("the user cancelled ask_user_question","ASK_CANCELLED")),Promise.resolve({accepted:!0}));let U=S4e.safeParse(I.result.value);if(!U.success)return Promise.resolve({accepted:!1,reason:"bad-response"});let K={sessionId:U.data.sessionId,answer:{answers:U.data.answer.answers.map(J=>({id:J.id,selected:J.selected,...J.custom===void 0?{}:{custom:J.custom}}))}};return W4e(K,C)?(O(C,"answered"),C.resolve(K.answer),Promise.resolve({accepted:!0})):Promise.resolve({accepted:!1,reason:"bad-response"})}}}l(G4e,"createApiProxy");var V4e=v.object({sessionId:ct,includeDescendants:v.union([v.literal("true"),v.literal("false")]).optional()}).transform(e=>({sessionId:e.sessionId,...e.includeDescendants==="true"?{includeDescendants:!0}:{}})),dp=v.string(),u8=v.discriminatedUnion("code",[v.object({code:v.literal("bad-request"),message:v.string(),details:v.object({issues:v.array(v.custom())})}),v.object({code:v.literal("cancelled"),message:v.string(),details:v.object({})}),v.object({code:v.literal("session-not-found"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("model-unavailable"),message:v.string(),details:v.object({provider:v.string(),model:v.string()})}),v.object({code:v.literal("session-conflict"),message:v.string(),details:v.object({sessionId:v.string(),requestedCwd:v.string(),existingCwd:v.string().optional()})}),v.object({code:v.literal("invalid-time-zone"),message:v.string(),details:v.object({value:v.string()})}),v.object({code:v.literal("workspace-attach-failed"),message:v.string(),details:v.object({sessionId:v.string(),workspaceId:v.string()})}),v.object({code:v.literal("workspace-not-found"),message:v.string(),details:v.object({workspaceId:v.string()})}),v.object({code:v.literal("workspace-invalid-path"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("workspace-name-conflict"),message:v.string(),details:v.object({name:v.string()})}),v.object({code:v.literal("workspace-move-invalid"),message:v.string(),details:v.object({workspaceId:v.string(),sessionId:v.string(),beforeSessionId:v.string().optional()})}),v.object({code:v.literal("directory-unreadable"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-exists"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-create-failed"),message:v.string(),details:v.object({path:v.string()})}),v.object({code:v.literal("directory-picker-unavailable"),message:v.string(),details:v.object({capability:v.string()})}),v.object({code:v.literal("agent-preset-read-only"),message:v.string(),details:v.object({agentPreset:v.string(),reason:v.string()})}),v.object({code:v.literal("agent-preset-locked"),message:v.string(),details:v.object({sessionId:v.string(),agentPreset:v.string()})}),v.object({code:v.literal("agent-preset-conflict"),message:v.string(),details:v.object({sessionId:v.string(),requestedPreset:v.string(),existingPreset:v.string().optional()})}),v.object({code:v.literal("agent-preset-not-found"),message:v.string(),details:v.object({agentPreset:v.string(),available:v.array(v.string())})}),v.object({code:v.literal("agent-preset-invalid"),message:v.string(),details:v.object({agentPreset:v.string(),reason:v.string()})}),v.object({code:v.literal("agent-busy"),message:v.string(),details:v.object({reason:v.string()})}),v.object({code:v.literal("attachment-error"),message:v.string(),details:v.object({reason:v.string()})}),v.object({code:v.literal("queue-item-not-found"),message:v.string(),details:v.object({itemId:v.string()})}),v.object({code:v.literal("steer-unavailable"),message:v.string(),details:v.object({itemId:v.string()})}),v.object({code:v.literal("command-error"),message:v.string(),details:v.object({})}),v.object({code:v.literal("unknown-command"),message:v.string(),details:v.object({})}),v.object({code:v.literal("settings-rejected"),message:v.string(),details:v.object({ns:v.string()})}),v.object({code:v.literal("settings-conflict"),message:v.string(),details:v.object({ns:v.string(),expected:v.number(),actual:v.number()})}),v.object({code:v.literal("credential-rejected"),message:v.string(),details:v.object({ref:v.string()})}),v.object({code:v.literal("model-discovery-failed"),message:v.string(),details:v.object({settingsNs:v.string(),baseURL:v.string().optional()})}),v.object({code:v.literal("title-invalid"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("fork-unavailable"),message:v.string(),details:v.object({sessionId:v.string()})}),v.object({code:v.literal("subagent-parent-unavailable"),message:v.string(),details:v.object({parentSessionId:v.string()})}),v.object({code:v.literal("subagent-not-found"),message:v.string(),details:v.object({parentSessionId:v.string(),childSessionId:v.string()})}),v.object({code:v.literal("subagent-catalog-diagnostic"),message:v.string(),details:v.object({parentSessionId:v.string(),childSessionId:v.string(),reason:v.union([v.literal("corrupt"),v.literal("unsupported"),v.literal("unavailable")])})}),v.object({code:v.literal("subagent-not-resumable"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("subagent-unauthorized"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("subagent-delivery-unavailable"),message:v.string(),details:v.object({childSessionId:v.string()})}),v.object({code:v.literal("internal"),message:v.string(),details:v.object({})})]);function GK(e){return v.union([v.object({ok:v.literal(!0),value:e}),v.object({ok:v.literal(!1),error:u8})])}l(GK,"rpcResultSchema");var VK=v.object({type:v.literal("client-request"),rpcId:dp,method:v.string(),payload:v.unknown()}),Z4e=v.object({type:v.literal("server-response"),rpcId:dp,result:GK(v.unknown().optional())}),K4e=v.object({type:v.literal("server-request"),rpcId:dp,method:v.string(),payload:v.unknown()}),ZK=v.object({type:v.literal("client-response"),rpcId:dp,result:GK(v.unknown().optional())});v.discriminatedUnion("type",[VK,Z4e,K4e,ZK]);var XUe=v.union([v.object({accepted:v.literal(!0)}),v.object({accepted:v.literal(!1),reason:v.union([v.literal("not-pending"),v.literal("bad-response")])})]),Y4e=v.object({}),JUe=v.object({version:v.string(),cwd:v.string(),provider:v.string().optional(),model:v.string().optional(),attachedSessions:v.number().int().nonnegative(),home:v.string(),canOpenPath:v.boolean()}),X4e=v.object({}),QUe=v.object({path:v.string().nullable()}),xK=v.object({name:v.string(),path:v.string(),hidden:v.boolean()}),J4e=v.object({path:v.string().optional()}),eje=v.object({path:v.string(),home:v.string(),crumbs:v.array(xK),entries:v.array(xK),truncated:v.boolean()}),Q4e=v.object({path:v.string(),name:v.string()}).refine(e=>e.name.trim()!==""&&e.name!=="."&&e.name!==".."&&!/[/\\]/.test(e.name),{message:"host.createDirectory requires a single non-blank path segment name"}),tje=v.object({path:v.string()}),eAe=v.object({path:v.string().min(1)}),rje=v.object({opened:v.literal(!0)}),fp=v.object({workspaceId:Ws,path:v.string(),title:v.string(),sessionIds:v.array(ct),createdAt:v.string(),updatedAt:v.string()}),tAe=v.object({}),nje=v.object({items:v.array(fp),archivedSessionIds:v.array(ct)}),rAe=v.object({path:v.string()}),ije=v.object({workspace:fp,created:v.boolean()}),nAe=v.object({workspaceId:Ws,title:v.string()}).refine(e=>e.title.trim()!=="",{message:"workspace.rename requires a non-blank title"}),sje=v.object({workspace:fp}),iAe=v.object({workspaceId:Ws}),oje=v.object({deleted:v.literal(!0)}),sAe=v.object({workspaceId:Ws,beforeWorkspaceId:Ws.optional()}),aje=v.object({workspaceIds:v.array(Ws)}),oAe=v.object({workspaceId:Ws,sessionId:ct,beforeSessionId:ct.optional()}),lje=v.object({workspace:fp}),aAe=v.object({sessionId:ct}),cje=v.object({archivedSessionIds:v.array(ct)}),lAe=v.object({name:v.string().min(1),description:v.string(),whenToUse:v.string().optional(),modelInvocable:v.boolean()}),cAe=v.object({sessionId:ct}),uje=v.object({skills:v.array(lAe)}),uAe=v.object({id:v.string().min(1),trust:v.union([v.literal("system"),v.literal("user")]),isDefault:v.boolean(),name:v.string().optional(),description:v.string().optional(),broken:v.string().min(1).optional()}),dAe=v.object({}),dje=v.object({presets:v.array(uAe),authorable:v.boolean(),hasDocument:v.boolean()}),fAe=v.object({sessionId:ct,agentPreset:v.string().min(1)}),fje=v.object({agentPreset:v.string()}),pAe=v.object({agentPreset:v.string().min(1)}),pje=v.object({agentPreset:v.string(),trust:v.union([v.literal("system"),v.literal("user")]),content:v.string(),name:v.string().optional(),description:v.string().optional()}),hAe=v.object({from:v.string().min(1),agentPreset:v.string().min(1),name:v.string().optional()}),hje=v.object({agentPreset:v.string()}),mAe=v.object({agentPreset:v.string().min(1)}),mje=v.union([v.object({opened:v.literal(!0)}),v.object({opened:v.literal(!1),path:v.string()})]),gAe=v.object({agentPreset:v.string().min(1)}),gje=v.object({}),yu=v.object({id:v.string(),revision:v.number().int().positive()}),yje=v.object({ref:yu}),yAe=v.object({sessionId:v.string(),objective:v.string().min(1),maxGoalRounds:v.number().int().positive().optional()});var vAe=v.object({sessionId:v.string(),ref:yu,objective:v.string().min(1).optional(),maxGoalRounds:v.number().int().positive().optional()}).refine(e=>e.objective!==void 0||e.maxGoalRounds!==void 0,{message:"goal.edit requires objective or maxGoalRounds"});var wAe=v.object({sessionId:v.string(),ref:yu});var bAe=v.object({sessionId:v.string(),ref:yu});var xAe=v.object({sessionId:v.string(),ref:yu});var EAe=v.object({sessionId:v.string(),ref:yu}),vje=v.object({cleared:v.literal(!0)}),SAe=v.object({path:v.array(v.string()),set:v.boolean()}),kAe=v.object({ns:v.string().min(1),schema:v.unknown(),value:v.unknown(),base:v.unknown().optional(),user:v.unknown().optional(),applies:v.union([v.literal("live"),v.literal("restart")]),secrets:v.array(SAe),revision:v.number()}),AAe=v.object({}),wje=v.object({writable:v.boolean(),hasDocument:v.boolean(),namespaces:v.array(kAe)}),IAe=v.object({}),bje=v.object({opened:v.literal(!0)}),$Ae=v.object({ns:v.string().min(1),patch:v.record(v.string(),v.unknown()),expectedRevision:v.number().optional()});var _Ae=v.object({ns:v.string().min(1),section:v.record(v.string(),v.unknown()),expectedRevision:v.number().optional()}),TAe=v.discriminatedUnion("op",[v.object({op:v.literal("set"),path:v.array(v.string()),value:v.unknown()}),v.object({op:v.literal("unset"),path:v.array(v.string())})]),CAe=v.object({ns:v.string().min(1),ops:v.array(TAe),expectedRevision:v.number().optional()});var d8=v.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),OAe=v.object({configured:v.boolean(),source:v.string().optional(),writable:v.boolean()}),NAe=v.object({refs:v.array(d8).max(64)}),xje=v.object({credentials:v.record(v.string(),OAe)}),RAe=v.object({ref:d8,value:v.string().min(1)}),Eje=v.object({}),PAe=v.object({ref:d8}),Sje=v.object({}),DAe=v.object({provider:v.string().min(1),displayName:v.string().min(1),settingsNs:v.string(),settingsPath:v.array(v.string()),active:v.boolean(),declared:v.boolean().optional()}),LAe=v.object({}),kje=v.object({providers:v.array(DAe)}),MAe=v.object({}),Aje=v.object({groups:v.array(CK),failures:v.array(OK)}),FAe=v.object({id:v.string().min(1),name:v.string().min(1).optional(),contextWindow:v.number().int().positive().optional(),maxTokens:v.number().int().positive().optional()}),UAe=v.object({settingsNs:v.string().min(1),provider:v.string().min(1).optional(),baseURL:v.string().min(1).optional(),api:v.string().min(1).optional(),apiKey:v.string().min(1).optional()}),Ije=v.object({models:v.array(FAe)}),jAe=v.union([v.object({kind:v.literal("child"),id:ct,mode:v.literal("one-shot"),activity:v.union([v.literal("running"),v.literal("inactive")]),hasChildren:v.boolean(),label:v.string().optional()}),v.object({kind:v.literal("child"),id:ct,mode:v.literal("continuable"),activity:v.union([v.literal("running"),v.literal("inactive")]),hasChildren:v.boolean(),label:v.string()}),v.object({kind:v.literal("diagnostic"),id:ct,reason:v.union([v.literal("corrupt"),v.literal("unsupported"),v.literal("unavailable")])})]),zAe=v.object({parentSessionId:ct}),$je=v.object({entries:v.array(jAe),parentAvailable:v.boolean()}),BAe=v.object({parentSessionId:ct,childSessionId:ct,mode:v.union([v.literal("one-shot"),v.literal("continuable")]),beforeSeq:v.number().int().nonnegative().optional(),maxMessages:v.number().int().positive().optional()}),_je=v.object({events:v.array(RK),hasMore:v.boolean(),projections:a8.optional()}),WAe=v.object({parentSessionId:ct,childSessionId:ct,mode:v.literal("continuable"),content:v.array(l8),clientTimeZone:v.string().optional()}),qAe=v.object({parentSessionId:ct,childSessionId:ct,mode:v.literal("continuable")}),Tje=v.object({accepted:v.literal(!0)}),HAe=v.string(),Cje=v.object({messageId:HAe}),KK={"session.list":{schema:r4e,invoke:l((e,t)=>e.sessions.list(t),"invoke")},"session.search":{schema:n4e,invoke:l((e,t,r)=>e.sessions.search(t,r),"invoke")},"session.create":{schema:s4e,invoke:l((e,t)=>e.sessions.create(t),"invoke")},"session.history":{schema:l4e,invoke:l((e,t)=>e.sessions.history(t),"invoke")},"session.models":{schema:p4e,invoke:l((e,t)=>e.sessions.models(t),"invoke")},"session.selectModel":{schema:h4e,invoke:l((e,t)=>e.sessions.selectModel(t),"invoke")},"session.rename":{schema:o4e,invoke:l((e,t)=>e.sessions.rename(t),"invoke")},"session.fork":{schema:a4e,invoke:l((e,t)=>e.sessions.fork(t),"invoke")},"session.prompt":{schema:g4e,invoke:l((e,t)=>e.sessions.prompt(t),"invoke")},"session.attachment":{schema:v4e,invoke:l((e,t)=>e.sessions.attachment(t),"invoke")},"session.updateQueue":{schema:w4e,invoke:l((e,t)=>e.sessions.updateQueue(t),"invoke")},"session.cancel":{schema:b4e,invoke:l((e,t)=>e.sessions.cancel(t),"invoke")},"subagent.list":{schema:zAe,invoke:l((e,t,r)=>e.subagents.list(t,r),"invoke")},"subagent.history":{schema:BAe,invoke:l((e,t,r)=>e.subagents.history(t,r),"invoke")},"subagent.prompt":{schema:WAe,invoke:l((e,t,r)=>e.subagents.prompt(t,r),"invoke")},"subagent.interrupt":{schema:qAe,invoke:l((e,t)=>e.subagents.interrupt(t),"invoke")},"host.describe":{schema:Y4e,invoke:l((e,t)=>e.host.describe(t),"invoke")},"host.pickDirectory":{schema:X4e,invoke:l((e,t,r)=>e.host.pickDirectory(t,r),"invoke")},"host.listDirectory":{schema:J4e,invoke:l((e,t,r)=>e.host.listDirectory(t,r),"invoke")},"host.createDirectory":{schema:Q4e,invoke:l((e,t)=>e.host.createDirectory(t),"invoke")},"host.openPath":{schema:eAe,invoke:l((e,t,r)=>e.host.openPath(t,r),"invoke")},"workspace.list":{schema:tAe,invoke:l((e,t)=>e.workspace.list(t),"invoke")},"workspace.create":{schema:rAe,invoke:l((e,t)=>e.workspace.create(t),"invoke")},"workspace.rename":{schema:nAe,invoke:l((e,t)=>e.workspace.rename(t),"invoke")},"workspace.delete":{schema:iAe,invoke:l((e,t)=>e.workspace.delete(t),"invoke")},"workspace.insertBefore":{schema:sAe,invoke:l((e,t)=>e.workspace.insertBefore(t),"invoke")},"workspace.insertSessionBefore":{schema:oAe,invoke:l((e,t)=>e.workspace.insertSessionBefore(t),"invoke")},"workspace.archiveSession":{schema:aAe,invoke:l((e,t)=>e.workspace.archiveSession(t),"invoke")},"skill.list":{schema:cAe,invoke:l((e,t)=>e.skills.list(t),"invoke")},"agentPreset.list":{schema:dAe,invoke:l((e,t)=>e.agentPresets.list(t),"invoke")},"agentPreset.select":{schema:fAe,invoke:l((e,t)=>e.agentPresets.select(t),"invoke")},"agentPreset.read":{schema:pAe,invoke:l((e,t)=>e.agentPresets.read(t),"invoke")},"agentPreset.copy":{schema:hAe,invoke:l((e,t)=>e.agentPresets.copy(t),"invoke")},"agentPreset.openDocument":{schema:mAe,invoke:l((e,t,r)=>e.agentPresets.openDocument(t,r),"invoke")},"agentPreset.remove":{schema:gAe,invoke:l((e,t)=>e.agentPresets.remove(t),"invoke")},"goal.create":{schema:yAe,invoke:l((e,t)=>e.goals.create(t),"invoke")},"goal.edit":{schema:vAe,invoke:l((e,t)=>e.goals.edit(t),"invoke")},"goal.pause":{schema:wAe,invoke:l((e,t)=>e.goals.pause(t),"invoke")},"goal.resume":{schema:bAe,invoke:l((e,t)=>e.goals.resume(t),"invoke")},"goal.complete":{schema:xAe,invoke:l((e,t)=>e.goals.complete(t),"invoke")},"goal.clear":{schema:EAe,invoke:l((e,t)=>e.goals.clear(t),"invoke")},"settings.describe":{schema:AAe,invoke:l((e,t)=>e.settings.describe(t),"invoke")},"settings.openDocument":{schema:IAe,invoke:l((e,t,r)=>e.settings.openDocument(t,r),"invoke")},"settings.update":{schema:$Ae,invoke:l((e,t)=>e.settings.update(t),"invoke")},"settings.replace":{schema:_Ae,invoke:l((e,t)=>e.settings.replace(t),"invoke")},"settings.mutate":{schema:CAe,invoke:l((e,t)=>e.settings.mutate(t),"invoke")},"credentials.describe":{schema:NAe,invoke:l((e,t)=>e.credentials.describe(t),"invoke")},"credentials.set":{schema:RAe,invoke:l((e,t)=>e.credentials.set(t),"invoke")},"credentials.unset":{schema:PAe,invoke:l((e,t)=>e.credentials.unset(t),"invoke")},"llm.providers":{schema:LAe,invoke:l((e,t)=>e.llm.providers(t),"invoke")},"llm.models":{schema:MAe,invoke:l((e,t)=>e.llm.models(t),"invoke")},"llm.discoverModels":{schema:UAe,invoke:l((e,t,r)=>e.llm.discoverModels(t,r),"invoke")}};function GAe(e){return Object.hasOwn(KK,e)?e:void 0}l(GAe,"methodFor");var VAe="invalid-request";function o8(e,t){let r={type:"server-response",rpcId:e,result:{ok:!1,error:t}};return Response.json(r)}l(o8,"errorResponse");function ZAe(e){let t={type:"server-response",rpcId:e.rpcId,result:e.result};return Response.json(t)}l(ZAe,"fullResponse");async function KAe(e,t,r,n){let i=KK[t],s=i.schema.safeParse(r.payload);if(!s.success)return o8(r.rpcId,{code:"bad-request",message:`invalid payload for ${t}`,details:{issues:s.error.issues}});try{return ZAe(await i.invoke(e,{rpcId:r.rpcId,payload:s.data},n))}catch(o){return new Response(`handler failure: ${String(o)}`,{status:500})}}l(KAe,"handleUnary");function EK(e){return{type:"server-request",rpcId:e.rpcId,method:e.payload.type,payload:e.payload}}l(EK,"fullFrame");function SK(e){let t=new TextEncoder,r=new ReadableStream({async start(n){try{n.enqueue(t.encode(`: connected
|
|
2346
2346
|
|
|
2347
2347
|
`));for await(let i of e)n.enqueue(t.encode(`data: ${JSON.stringify(EK(i))}
|
|
2348
2348
|
|
|
2349
2349
|
`))}catch(i){let s={type:"stream/error",error:{code:"internal",message:String(i),details:{}}};try{n.enqueue(t.encode(`data: ${JSON.stringify(EK({rpcId:crypto.randomUUID(),payload:s}))}
|
|
2350
2350
|
|
|
2351
|
-
`))}catch{}}finally{try{n.close()}catch{}}}});return new Response(r,{headers:{"content-type":"text/event-stream","cache-control":"no-cache"}})}l(SK,"sseResponse");function YK(e){return{async fetch(t,r){let n=t instanceof Request?t:new Request(t,r),i=new URL(n.url),s=i.pathname;if(s==="/api/events.mux"&&n.method==="GET")return SK(e.events.mux({rpcId:crypto.randomUUID(),payload:{}},n.signal));if(s==="/api/events.host"&&n.method==="GET")return SK(e.events.host({rpcId:crypto.randomUUID(),payload:{}},n.signal));if(s==="/api/session.export"&&(n.method==="GET"||n.method==="HEAD")){let d=V4e.safeParse(Object.fromEntries(i.searchParams));if(!d.success)return new Response("missing or invalid sessionId query parameter",{status:400});let f=await e.downloads.sessionLog(d.data,n.signal);return n.method==="GET"?f:(await f.body?.cancel(),new Response(null,{status:f.status,headers:f.headers}))}if(n.method!=="POST"||!s.startsWith("/api/"))return new Response("not found",{status:404});if(n.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase()!=="application/json")return new Response("content type must be application/json",{status:415});let o;try{o=await n.json()}catch{return new Response("body is not JSON",{status:400})}if(s==="/api/respond"){let d=ZK.safeParse(o);return d.success?Response.json(await e.respond(d.data)):Response.json({accepted:!1,reason:"bad-response"})}let a=GAe(s.slice(5));if(a===void 0)return new Response("not found",{status:404});let c=VK.safeParse(o);if(!c.success){let d=o?.rpcId;return o8(typeof d=="string"?d:VAe,{code:"bad-request",message:"invalid client-request message",details:{issues:c.error.issues}})}let u=c.data;return u.method!==a?o8(u.rpcId,{code:"bad-request",message:`method "${u.method}" does not match path "${a}"`,details:{issues:[]}}):KAe(e,a,u,n.signal)}}}l(YK,"toFetchHandler");var YAe=v.string().min(1),XAe=v.object({id:YAe,kind:v.string().min(1),label:v.string().min(1),status:v.union([v.literal("running"),v.literal("stopping"),v.literal("completed"),v.literal("killed"),v.literal("failed")]),detail:v.string().optional(),startedAt:v.number().int().nonnegative(),finishedAt:v.number().int().nonnegative().optional()}),JAe=v.object({id:v.string(),question:v.string(),header:v.string().optional(),detail:v.string().optional(),options:v.array(v.object({label:v.string(),description:v.string().optional()})).optional(),multiSelect:v.boolean().optional(),intent:v.discriminatedUnion("kind",[v.object({kind:v.literal("plan-review"),approve:v.string()})]).optional()}),QAe=v.object({id:v.string().min(1),role:v.union([v.literal("system"),v.literal("user"),v.literal("assistant")]),content:v.array(l8),source:v.looseObject({kind:v.string()})}),
|
|
2351
|
+
`))}catch{}}finally{try{n.close()}catch{}}}});return new Response(r,{headers:{"content-type":"text/event-stream","cache-control":"no-cache"}})}l(SK,"sseResponse");function YK(e){return{async fetch(t,r){let n=t instanceof Request?t:new Request(t,r),i=new URL(n.url),s=i.pathname;if(s==="/api/events.mux"&&n.method==="GET")return SK(e.events.mux({rpcId:crypto.randomUUID(),payload:{}},n.signal));if(s==="/api/events.host"&&n.method==="GET")return SK(e.events.host({rpcId:crypto.randomUUID(),payload:{}},n.signal));if(s==="/api/session.export"&&(n.method==="GET"||n.method==="HEAD")){let d=V4e.safeParse(Object.fromEntries(i.searchParams));if(!d.success)return new Response("missing or invalid sessionId query parameter",{status:400});let f=await e.downloads.sessionLog(d.data,n.signal);return n.method==="GET"?f:(await f.body?.cancel(),new Response(null,{status:f.status,headers:f.headers}))}if(n.method!=="POST"||!s.startsWith("/api/"))return new Response("not found",{status:404});if(n.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase()!=="application/json")return new Response("content type must be application/json",{status:415});let o;try{o=await n.json()}catch{return new Response("body is not JSON",{status:400})}if(s==="/api/respond"){let d=ZK.safeParse(o);return d.success?Response.json(await e.respond(d.data)):Response.json({accepted:!1,reason:"bad-response"})}let a=GAe(s.slice(5));if(a===void 0)return new Response("not found",{status:404});let c=VK.safeParse(o);if(!c.success){let d=o?.rpcId;return o8(typeof d=="string"?d:VAe,{code:"bad-request",message:"invalid client-request message",details:{issues:c.error.issues}})}let u=c.data;return u.method!==a?o8(u.rpcId,{code:"bad-request",message:`method "${u.method}" does not match path "${a}"`,details:{issues:[]}}):KAe(e,a,u,n.signal)}}}l(YK,"toFetchHandler");var YAe=v.string().min(1),XAe=v.object({id:YAe,kind:v.string().min(1),label:v.string().min(1),status:v.union([v.literal("running"),v.literal("stopping"),v.literal("completed"),v.literal("killed"),v.literal("failed")]),detail:v.string().optional(),startedAt:v.number().int().nonnegative(),finishedAt:v.number().int().nonnegative().optional()}),JAe=v.object({id:v.string(),question:v.string(),header:v.string().optional(),detail:v.string().optional(),options:v.array(v.object({label:v.string(),description:v.string().optional()})).optional(),multiSelect:v.boolean().optional(),intent:v.discriminatedUnion("kind",[v.object({kind:v.literal("plan-review"),approve:v.string()})]).optional()}),QAe=v.object({id:v.string().min(1),role:v.union([v.literal("system"),v.literal("user"),v.literal("assistant")]),content:v.array(l8),source:v.looseObject({kind:v.string()})}),Oje=v.discriminatedUnion("type",[v.object({type:v.literal("session/event"),sessionId:ct,event:_K,view:NK.optional()}),v.object({type:v.literal("session/subscribed"),sessionId:ct,lastSeq:v.number().int()}),v.object({type:v.literal("approval/requested"),sessionId:ct,approvalId:s8,toolName:v.string(),callId:v.string().optional(),reason:v.string().optional()}),v.object({type:v.literal("approval/resolved"),sessionId:ct,approvalId:s8,outcome:v.union([v.literal("allowed-once"),v.literal("rejected"),v.literal("cancelled"),v.literal("unavailable")])}),v.object({type:v.literal("question/requested"),sessionId:ct,questions:v.array(JAe).min(1)}),v.object({type:v.literal("question/resolved"),sessionId:ct,questionRpcId:dp,outcome:v.union([v.literal("answered"),v.literal("cancelled")])}),v.object({type:v.literal("session/queue"),sessionId:ct,items:v.array(v.object({id:$K,placement:v.union([v.literal("queued"),v.literal("steering"),v.literal("context")]),message:QAe}))}),v.object({type:v.literal("session/jobs"),sessionId:ct,jobs:v.array(XAe)}),v.object({type:v.literal("session/projection"),sessionId:ct,key:v.string().min(1),value:v.unknown(),seq:v.number().int().nonnegative()}),v.object({type:v.literal("stream/error"),error:u8})]),Nje=v.discriminatedUnion("type",[v.object({type:v.literal("host/session-added"),sessionId:ct,blank:v.boolean(),parentSessionId:ct.optional(),origin:v.literal("subagent").optional(),cwd:v.string().optional(),agentPreset:v.string().optional()}),v.object({type:v.literal("host/session-removed"),sessionId:ct}),v.object({type:v.literal("host/session-status"),sessionId:ct,running:v.boolean()}),v.object({type:v.literal("host/agent-error"),sessionId:ct,message:v.string()}),v.object({type:v.literal("host/workspace-changed"),workspace:fp}),v.object({type:v.literal("host/workspace-removed"),workspaceId:Ws}),v.object({type:v.literal("host/workspace-order-changed"),workspaceIds:v.array(Ws)}),v.object({type:v.literal("host/archived-sessions-changed"),archivedSessionIds:v.array(ct)}),v.object({type:v.literal("host/remote-event"),event:v.string().min(1),args:v.array(v.unknown())}),v.object({type:v.literal("stream/error"),error:u8})]);var Rje=class extends ut{static{l(this,"ApiProxyService")}static inject=["agentDefaultModel","agents","attachments","directoryPicker","llm","sessions","subagents","sessionQuery","tools","userQuestions","workspaceRegistry"];static Config=re.object({nativeOpen:re.boolean(),sessionExportCompressionLevel:re.number().step(1).min(0).max(9).default(6),coldBlankProbeMaxBytes:re.natural().default(R4e)});sessions;subagents;workspace;host;goals;skills;agentPresets;settings;credentials;llm;events;downloads;respond;constructor(e,t){super(e,"apiProxy");let r=G4e(e,{defaultModelSelection:l(()=>e.agentDefaultModel.currentSelection(),"defaultModelSelection"),saveDefaultModelSelection:l(n=>e.agentDefaultModel.saveSelection(n),"saveDefaultModelSelection"),cwd:process.cwd(),...t.nativeOpen===void 0?{}:{canOpenPath:l(()=>t.nativeOpen,"canOpenPath")},...t.sessionExportCompressionLevel===void 0?{}:{sessionExportCompressionLevel:t.sessionExportCompressionLevel},...t.coldBlankProbeMaxBytes===void 0?{}:{coldBlankProbeMaxBytes:t.coldBlankProbeMaxBytes}});this.sessions=r.sessions,this.subagents=r.subagents,this.workspace=r.workspace,this.host=r.host,this.goals=r.goals,this.skills=r.skills,this.agentPresets=r.agentPresets,this.settings=r.settings,this.credentials=r.credentials,this.llm=r.llm,this.events=r.events,this.downloads=r.downloads,this.respond=r.respond.bind(r)}};import{DurableObject as S3e}from"cloudflare:workers";var e3e="worker-shell",XK="/workspace",Q0=class{static{l(this,"DirectShellBackend")}type="direct-shell";id;constructor(t={}){this.id=t.id??e3e}connect(t){let r=new p8(t);return Promise.resolve({rpc:{sync:a3e(),shell:{exec:l(n=>r.exec(n),"exec"),getExec:l(n=>r.getExec(n.id),"getExec"),killExec:l(n=>r.killExec(n.id,n.signal),"killExec"),disposeExec:l(n=>r.disposeExec(n.id),"disposeExec")}},sync:"none",close:l(()=>r.close(),"close")})}},p8=class{constructor(t){this.host=t;this.fs=new sV(t3e(t))}host;static{l(this,"DirectShellRuntime")}fs;executions=new Map;closed=!1;exec(t){if(this.closed)throw fa("ECLOSED","direct shell backend is closed");let r=t.id??crypto.randomUUID();if(this.executions.has(r))throw fa("EEXEC_BUSY",`execution ${r} is running`);let n=new AbortController,i=Promise.resolve().then(()=>this.run(t,n.signal)),s=i.then(()=>{},()=>{});return this.executions.set(r,{controller:n,done:s}),Promise.resolve({id:r,events:n3e(r,i,()=>{this.deleteExecution(r,n)},()=>this.disposeExec(r))})}getExec(t){throw fa("ENOENT",`no such exec: ${t}`)}killExec(t,r="SIGTERM"){return this.executions.get(t)?.controller.abort(fa("EEXEC_CANCELLED",`execution cancelled with ${r}`)),Promise.resolve()}async disposeExec(t){let r=this.executions.get(t);r!==void 0&&(r.controller.abort(fa("EEXEC_DISPOSED",`execution disposed: ${t}`)),await r.done,this.deleteExecution(t,r.controller))}async close(){if(this.closed)return;this.closed=!0;let t=[...this.executions.values()];for(let r of t)r.controller.abort(fa("ECLOSED","direct shell backend is closing"));await Promise.allSettled(t.map(r=>r.done)),this.executions.clear()}async run(t,r){let n=t.timeoutMs!==void 0&&t.timeoutMs>0?{maxExecutionTimeMs:t.timeoutMs}:{},s=new d7({fs:this.fs,cwd:t.cwd??XK,...t.env===void 0?{}:{env:t.env},customCommands:[lV(this.host),aV({}),oV(this.host)],defenseInDepth:{enabled:"auto"},executionLimitProfile:"hardened",executionLimits:{maxOutputSize:65536,...n}});try{let o=await s.exec(t.source,{cwd:t.cwd??XK,...t.env===void 0?{}:{env:t.env},...t.stdin===void 0?{}:{stdin:o3e(t.stdin),stdinKind:"bytes"},signal:r});return{result:o,...s3e(o)?{terminalResult:Um}:{}}}catch(o){return{result:{stdout:"",stderr:`${o instanceof Error?o.message:String(o)}
|
|
2352
2352
|
`,exitCode:r.aborted?130:1,env:t.env??{}}}}}deleteExecution(t,r){this.executions.get(t)?.controller===r&&this.executions.delete(t)}};function t3e(e){let t=e.fs;return{readFile:t.readFile.bind(t),exists:l(async r=>await f8(()=>t.stat(r))!==null,"exists"),stat:l(r=>t.stat(r),"stat"),statOrNull:l(r=>f8(()=>t.stat(r)),"statOrNull"),lstat:l(r=>t.lstat(r),"lstat"),lstatOrNull:l(r=>f8(()=>t.lstat(r)),"lstatOrNull"),readdir:l(r=>t.readdir(r),"readdir"),find:l((r,n)=>t.find(r,n),"find"),ls:l(r=>t.ls(r),"ls"),grep:l((r,n,i)=>t.grep(r,n,i),"grep"),readlink:l(r=>t.readlink(r),"readlink"),writeFile:l((r,n,i)=>t.writeFile(r,n,i),"writeFile"),mkdir:l((r,n)=>t.mkdir(r,n),"mkdir"),rm:l((r,n)=>t.rm(r,n),"rm"),chmod:l((r,n)=>t.chmod(r,n),"chmod"),symlink:l((r,n)=>t.symlink(r,n),"symlink")}}l(t3e,"workspaceFs");async function f8(e){try{return await e()}catch(t){if(r3e(t,"ENOENT"))return null;throw t}}l(f8,"statOrNull");function r3e(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}l(r3e,"hasErrorCode");function n3e(e,t,r,n){let i=new TextEncoder,s;return new ReadableStream({async pull(o){try{s??=i3e(e,i,await t);let a=s.shift();if(a===void 0)return;o.enqueue(a),a.name==="exit"&&(o.close(),r())}catch(a){o.error(a),r()}},cancel:n},{highWaterMark:0})}l(n3e,"executionEvents");function i3e(e,t,r){let{result:n}=r,i=[],s=0;return n.stdout.length>0&&i.push({id:e,seq:++s,name:"stdout",value:t.encode(n.stdout)}),n.stderr.length>0&&i.push({id:e,seq:++s,name:"stderr",value:t.encode(n.stderr)}),i.push({id:e,seq:++s,name:"exit",code:n.exitCode,...r.terminalResult===void 0?{}:{result:r.terminalResult}}),i}l(i3e,"shellExecEvents");function s3e(e){if(e.exitCode!==126)return!1;let t=e.internalOutputAccounting?.stderr;if(t===void 0)return!1;let r=new TextEncoder().encode(e.stderr);if(t<0||t>r.byteLength)return!1;let n=new TextDecoder().decode(r.subarray(t));return[`limit exceeded (${65536} bytes)`,`total output size exceeded (>${65536} bytes), increase executionLimits.maxOutputSize`].some(i=>n.includes(i))}l(s3e,"hitDirectOutputLimit");function o3e(e){let t="";for(let r of e)t+=String.fromCharCode(r);return t}l(o3e,"latin1FromBytes");function fa(e,t){let r=new Error(t);return r.name="DirectShellError",r.code=e,r}l(fa,"directShellError");function a3e(){let e=l(t=>{throw fa("ENOSYS",`DirectShellBackend: sync.${t} must not be called because sync is disabled`)},"refuse");return{push:l(()=>e("push"),"push"),fetchChanges:l(()=>e("fetchChanges"),"fetchChanges"),watermarks:l(()=>e("watermarks"),"watermarks"),readEntry:l(()=>e("readEntry"),"readEntry"),hasObjects:l(()=>e("hasObjects"),"hasObjects"),fetchObjects:l(()=>new ReadableStream({start(t){t.error(fa("ENOSYS","DirectShellBackend: sync is disabled"))}}),"fetchObjects"),pushObjects:l(()=>e("pushObjects"),"pushObjects")}}l(a3e,"disabledSyncRpc");var l3e=new TextEncoder,c3e=1048576;function h8(e){let t=u3e(e.type);return l3e.encode(`id: ${e.seq}
|
|
2353
2353
|
event: ${t}
|
|
2354
2354
|
data: ${JSON.stringify(e)}
|
|
2355
2355
|
|
|
2356
2356
|
`)}l(h8,"encodeSessionEvent");function u3e(e){return e.replaceAll("%","%25").replaceAll("\r","%0D").replaceAll(`
|
|
2357
|
-
`,"%0A")}l(u3e,"encodeEventType");function m8(e={}){let t=new Headers(e);return t.set("cache-control","no-cache, no-transform"),t.set("content-type","text/event-stream; charset=utf-8"),t.set("x-accel-buffering","no"),t}l(m8,"edgeEventStreamHeaders");function JK(e,t){let r=!0,n,i=new Promise(o=>{n=o});return{stream:new ReadableStream({start(o){Promise.resolve().then(async()=>e(a=>{if(r)try{let c=h8(a);if(o.desiredSize===null||o.desiredSize<c.byteLength){r=!1,o.error(new Error("dsh-edge event stream client is too slow."));return}o.enqueue(c)}catch{r=!1}})).then(()=>{if(r)try{o.close()}catch{r=!1}},a=>{t(a),r&&(r=!1,o.error(new Error("dsh-edge turn transport failed.")))}).finally(n)},cancel(){r=!1}},{highWaterMark:c3e,size:l(o=>o.byteLength,"size")}),completion:i}}l(JK,"createLiveSessionEventStream");var un="edge-workspace",Mi="/workspace",ey="dsh-edge:workspace-domain-state:v2",$l="dsh-edge:workspace-domain-workspaces:edge-workspace:v2",yo=class extends Error{constructor(r,n){super(n);this.code=r;this.name="EdgeWorkspaceStoreError"}code;static{l(this,"EdgeWorkspaceStoreError")}},ty=class{constructor(t){this.storage=t}storage;static{l(this,"EdgeWorkspaceStore")}operationTail=Promise.resolve();list(t){return this.serialize(async()=>{let r=await this.readState();if(!r.workspaceIds.includes(un))return{items:[],archivedSessionIds:r.archivedSessionIds};let n=await this.readOrCreateRecord(t);return{items:[qs(n)],archivedSessionIds:r.archivedSessionIds}})}create(t,r){return this.serialize(async()=>{if(t!==Mi)throw new yo("INVALID_PATH",`Edge workspaces must use ${Mi}.`);let n=await this.readState();if(n.workspaceIds.includes(un)){let o=await this.readOrCreateRecord(r);return{workspace:qs(o),created:!1}}let i=new Date().toISOString(),s={path:Mi,title:"workspace",sessionIds:[],createdAt:i,updatedAt:i};return await this.storage.transaction(async o=>{await o.put($l,s),await o.put(ey,{...n,workspaceIds:[un]})}),{workspace:qs(s),created:!0}})}rename(t,r,n){return this.serialize(async()=>{await this.requireWorkspace(t);let i=await this.readOrCreateRecord(n);if(i.title===r)return{workspace:qs(i),changed:!1};let s={...i,title:r,updatedAt:new Date().toISOString()};return await this.storage.put($l,s),{workspace:qs(s),changed:!0}})}delete(t){return this.serialize(async()=>{let r=await this.requireWorkspace(t);await this.storage.transaction(async n=>{await n.delete($l),await n.put(ey,{...r,workspaceIds:[]})})})}insertBefore(t,r){return this.serialize(async()=>{let n=await this.requireWorkspace(t);if(r!==void 0&&r!==un)throw new yo("NOT_FOUND",`Workspace "${r}" is not available in this Edge instance.`);return[...n.workspaceIds]})}insertSessionBefore(t,r,n,i){return this.serialize(async()=>{await this.requireWorkspace(t);let s=await this.readOrCreateRecord(i);if(!s.sessionIds.includes(r))throw new yo("MOVE_INVALID",`Session "${r}" is not accounted by workspace "${t}".`);if(n!==void 0&&!s.sessionIds.includes(n))throw new yo("MOVE_INVALID",`Anchor session "${n}" is not accounted by workspace "${t}".`);if(n===r)return{workspace:qs(s),changed:!1};let o=s.sessionIds.filter(d=>d!==r),a=n===void 0?o.length:o.indexOf(n),c=[...o.slice(0,a),r,...o.slice(a)];if(f3e(c,s.sessionIds))return{workspace:qs(s),changed:!1};let u={...s,sessionIds:c,updatedAt:new Date().toISOString()};return await this.storage.put($l,u),{workspace:qs(u),changed:!0}})}attachSession(t,r,n){return this.serialize(async()=>{await this.requireWorkspace(t);let i=await this.readOrCreateRecord(n);if(i.sessionIds.includes(r))return qs(i);let s={...i,sessionIds:[r,...i.sessionIds],updatedAt:new Date().toISOString()};return await this.storage.put($l,s),qs(s)})}workspaceForSession(t,r){return this.serialize(async()=>(await this.readState()).workspaceIds.includes(un)&&(await this.readOrCreateRecord(r)).sessionIds.includes(t)?un:void 0)}archivedSessionIds(){return this.serialize(async()=>[...(await this.readState()).archivedSessionIds])}archiveSession(t,r){return this.serialize(async()=>{let n=await this.readState();if(n.archivedSessionIds.includes(t))return{archivedSessionIds:[...n.archivedSessionIds],changed:!1};await r();let i=[...n.archivedSessionIds,t];return await this.storage.put(ey,{...n,archivedSessionIds:i}),{archivedSessionIds:i,changed:!0}})}async requireWorkspace(t){let r=await this.readState();if(t!==un||!r.workspaceIds.includes(t))throw new yo("NOT_FOUND",`Workspace "${t}" is not available in this Edge instance.`);return r}async readOrCreateRecord(t){let r=await this.storage.get($l);if(r!==void 0)return h3e(r);let n=d3e(t);return await this.storage.put($l,n),n}async readState(){let t=await this.storage.get(ey);return t===void 0?{initialized:!0,workspaceIds:[un],archivedSessionIds:[]}:p3e(t)}serialize(t){let r=this.operationTail.then(t);return this.operationTail=r.then(()=>{},()=>{}),r}};function d3e(e){let t=e.length===0?new Date(0).toISOString():new Date(Math.min(...e.map(n=>n.createdAt))).toISOString(),r=e.length===0?t:new Date(Math.max(...e.map(n=>n.updatedAt))).toISOString();return{path:Mi,title:"Workspace",sessionIds:e.map(n=>n.id),createdAt:t,updatedAt:r}}l(d3e,"defaultWorkspaceRecord");function qs(e){return{workspaceId:un,...e,sessionIds:[...e.sessionIds]}}l(qs,"workspaceView");function f3e(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}l(f3e,"sameIds");function p3e(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("dsh-edge workspace domain state is invalid.");let t=e,r=t.workspaceIds,n=t.archivedSessionIds;if(t.initialized!==!0||!Array.isArray(r)||r.some(i=>i!==un)||new Set(r).size!==r.length||!Array.isArray(n)||n.some(i=>typeof i!="string"||i.length===0)||new Set(n).size!==n.length||Object.hasOwn(t,"pendingMutation"))throw new Error("dsh-edge workspace domain state is invalid.");return{initialized:!0,workspaceIds:r.map(()=>un),archivedSessionIds:n}}l(p3e,"workspaceDomainStateFromStorage");function h3e(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("dsh-edge workspace record is invalid.");let t=e;if(t.path!==Mi||typeof t.title!="string"||!Array.isArray(t.sessionIds)||t.sessionIds.some(r=>typeof r!="string"||r.length===0)||new Set(t.sessionIds).size!==t.sessionIds.length||typeof t.createdAt!="string"||typeof t.updatedAt!="string")throw new Error("dsh-edge workspace record is invalid.");return{path:Mi,title:t.title,sessionIds:t.sessionIds,createdAt:t.createdAt,updatedAt:t.updatedAt}}l(h3e,"workspaceRecordFromStorage");var eY="deepseek-official",m3e=50,pa=65536,g3e=new TextEncoder;function ny(e){return e.reduce((t,r)=>t+g3e.encode(r.text).byteLength,0)}l(ny,"messageTextByteLength");function tY(e){let t=new Map,r=l((i,s)=>{let o=(t.get(i)??Promise.resolve()).then(s),a=o.then(()=>{},()=>{});return t.set(i,a),o.finally(()=>{t.get(i)===a&&t.delete(i)})},"serializeImageMutation");return{sessions:{async list(i){let s=await e.sessions.listApiSessions();return zt(i,{items:s.map(o=>w3e(e,o))})},async search(i,s){try{return zt(i,await e.sessions.searchApiSessions(i.payload.query,s))}catch(o){return s.aborted||o instanceof DOMException&&o.name==="AbortError"?At(i,{code:"cancelled",message:"Session search was aborted.",details:{}}):At(i,{code:"internal",message:o instanceof Error?o.message:String(o),details:{}})}},async create(i){let{workspaceId:s,cwd:o,sessionId:a,agentPreset:c}=i.payload;if(s!==void 0&&s!==un)return At(i,{code:"workspace-not-found",message:`Workspace "${s}" is not available in this Edge instance.`,details:{workspaceId:s}});let u=await e.workspaceList(await e.sessions.listApiSessions());if(s!==void 0&&!u.items.some(d=>d.workspaceId===s))return At(i,{code:"workspace-not-found",message:`Workspace "${s}" is not available in this Edge instance.`,details:{workspaceId:s}});if(o!==void 0&&o!==Mi)return At(i,{code:"workspace-invalid-path",message:`Edge sessions must use ${Mi}.`,details:{path:o}});if(c!==void 0&&c!=="dsh-edge")return At(i,{code:"agent-preset-not-found",message:`Agent preset "${c}" is not available in this Edge instance.`,details:{agentPreset:c,available:["dsh-edge"]}});try{let d=await e.sessions.createBlankSession({model:e.model,...a===void 0?{}:{sessionId:a}}),f=(await e.sessions.listApiSessions()).find(p=>p.id===d.sessionId);if(f!==void 0&&(d.created&&e.sessionCreated(f),s!==void 0)){let p=await iy(d.sessionId,s,"created",()=>e.sessionAttached(f,s));if(p!==void 0)return At(i,p)}return zt(i,{sessionId:d.sessionId,agentPreset:d.agentPreset})}catch(d){return vo(i,d,a)}},async history(i){let{sessionId:s,beforeSeq:o,maxMessages:a}=i.payload;try{let c=await e.sessions.readHistoryPage(s,o,a??m3e),u=c.events.map(d=>({event:d}));return zt(i,{events:u,hasMore:c.hasMore,...o===void 0?{projections:rY(c.summary,e.imageLimits)}:{}})}catch(c){return vo(i,c,s)}},async models(i){try{let[s,o]=await Promise.all([e.sessions.modelSelection(i.payload.sessionId,e.model),e.sessions.modelCatalog()]);return zt(i,{current:s,routable:!0,groups:o.groups,failures:o.failures})}catch(s){return vo(i,s,i.payload.sessionId)}},async selectModel(i){let{sessionId:s,provider:o,model:a,reasoningEffort:c}=i.payload;return await r(s,async()=>{try{let u=await e.sessions.selectModel(s,{provider:o,model:a,...c===void 0?{}:{reasoningEffort:c}});return zt(i,{selected:u})}catch(u){return u instanceof dt?vo(i,u,s):At(i,{code:"model-unavailable",message:u instanceof Error?u.message:String(u),details:{provider:o,model:a}})}})},async rename(i){let{sessionId:s,title:o}=i.payload;try{let a=await e.sessions.renameSession(s,o,e.model);return a.publishRequired&&e.sessionEvent(s,a.event),zt(i,{title:a.title,seq:a.event.seq})}catch(a){return vo(i,a,s)}},async fork(i){let{sessionId:s,atSeq:o}=i.payload;try{let a=await e.workspaceForSession(s),c=await e.sessions.forkSession(s,o,e.model);if(e.sessionCreated(c),a!==void 0){let u=await iy(c.id,a,"forked",()=>e.sessionAttached(c,a));if(u!==void 0)return At(i,u)}return zt(i,{sessionId:c.id})}catch(a){return vo(i,a,s)}},async prompt(i){let{sessionId:s,mode:o,content:a,clientTimeZone:c}=i.payload,u=b3e(c);if(c!==void 0&&u===void 0)return At(i,{code:"invalid-time-zone",message:"clientTimeZone must be UTC or a valid IANA Area/Location name.",details:{value:c}});let d=a.filter(h=>h.type==="text");if(ny(d)>pa)return At(i,{code:"attachment-error",message:`Prompt text is limited to ${pa} UTF-8 bytes.`,details:{reason:"PROMPT_TEXT_TOO_LARGE"}});let f=a.some(h=>h.type==="image"),p=l(async()=>{try{let h;if(!f)h=d.map(m=>({type:"text",text:m.text}));else{let m=await e.sessions.attachmentStore();if(m===void 0)return At(i,{code:"attachment-error",message:"Image attachments are not available in this Edge instance.",details:{reason:"EDGE_ATTACHMENTS_UNAVAILABLE"}});if(!await e.sessions.modelSupportsImages(s,e.model))return At(i,{code:"attachment-error",message:"The selected model does not support image input.",details:{reason:"MODEL_DOES_NOT_SUPPORT_IMAGES"}});let g=await Wm(m,a.filter(x=>x.type==="image")),y=0;h=a.map(x=>x.type==="text"?{type:"text",text:x.text}:{type:"image",attachment:g[y++]})}return await e.prompt({sessionId:s,mode:o,content:h,rpcId:i.rpcId,...u===void 0?{}:{clientTimeZone:u}}),zt(i,{accepted:!0})}catch(h){return h instanceof Ct?At(i,{code:"attachment-error",message:h.message,details:{reason:h.code}}):vo(i,h,s)}},"admit");return f?r(s,p):p()},async attachment(i){let{sessionId:s,attachmentId:o}=i.payload;try{let a=await e.sessions.attachmentStore();if(a===void 0)return At(i,{code:"attachment-error",message:"Image attachments are not available in this Edge instance.",details:{reason:"EDGE_ATTACHMENTS_UNAVAILABLE"}});let c=await e.sessions.referencedImage(s,String(o));if(c===void 0)return At(i,{code:"attachment-error",message:"Image is not referenced by this session.",details:{reason:"ATTACHMENT_NOT_REFERENCED"}});let u=await a.readImage(c);return zt(i,{attachment:u.ref,data:v3e(u.data)})}catch(a){return a instanceof Ct?At(i,{code:"attachment-error",message:a.message,details:{reason:a.code}}):vo(i,a,s)}},updateQueue(i){let{sessionId:s,itemId:o,action:a}=i.payload;if(a.kind==="edit"&&a.content.some(u=>u.type!=="text"&&u.type!=="image"))return Promise.resolve(At(i,{code:"attachment-error",message:"Queue edits accept text and previously admitted images only.",details:{reason:"QUEUE_EDIT_NON_TEXT"}}));if(a.kind==="edit"&&ny(a.content)>pa)return Promise.resolve(At(i,{code:"attachment-error",message:`Queue edit text is limited to ${pa} UTF-8 bytes.`,details:{reason:"QUEUE_EDIT_TEXT_TOO_LARGE"}}));let c=e.updateQueue(s,o,a);return c==="queue-item-not-found"?Promise.resolve(At(i,{code:"queue-item-not-found",message:"The queued item is no longer pending.",details:{itemId:o}})):c==="steer-unavailable"?Promise.resolve(At(i,{code:"steer-unavailable",message:"The current turn no longer accepts steering.",details:{itemId:o}})):c==="queue-edit-attachment-invalid"?Promise.resolve(At(i,{code:"attachment-error",message:"Queue edits may only preserve images already admitted for this pending item.",details:{reason:"QUEUE_EDIT_ATTACHMENT_INVALID"}})):Promise.resolve(zt(i,{accepted:!0}))},cancel(i){return e.cancel(i.payload.sessionId)?Promise.resolve(zt(i,{accepted:!0})):Promise.resolve(At(i,{code:"agent-busy",message:"The session has no active turn in this Edge instance.",details:{reason:"not-running"}}))}},subagents:{list:l(i=>Promise.resolve(zt(i,{entries:[],parentAvailable:!1})),"list"),history:tn,prompt:tn,interrupt:tn},host:{async describe(i){return zt(i,{version:e.version,cwd:Mi,provider:eY,model:e.model,attachedSessions:await e.sessions.attachedSessionCount(),home:Mi,canOpenPath:!1})},pickDirectory:tn,listDirectory:tn,createDirectory:tn,openPath:tn},workspace:{async list(i){let s=await e.sessions.listApiSessions();return zt(i,await e.workspaceList(s))},async create(i){try{return zt(i,await e.workspaceCreate(i.payload.path))}catch(s){return pp(i,s,void 0,void 0,void 0,i.payload.path)}},async rename(i){let{workspaceId:s,title:o}=i.payload;try{return zt(i,{workspace:await e.workspaceRename(s,o.trim())})}catch(a){return pp(i,a,s)}},async delete(i){let{workspaceId:s}=i.payload;try{return await e.workspaceDelete(s),zt(i,{deleted:!0})}catch(o){return pp(i,o,s)}},async insertBefore(i){let{workspaceId:s,beforeWorkspaceId:o}=i.payload;try{return zt(i,{workspaceIds:await e.workspaceInsertBefore(s,o)})}catch(a){return pp(i,a,s)}},async insertSessionBefore(i){let{workspaceId:s,sessionId:o,beforeSessionId:a}=i.payload;try{return zt(i,{workspace:await e.workspaceInsertSessionBefore(s,o,a)})}catch(c){return pp(i,c,s,o,a)}},async archiveSession(i){let{sessionId:s}=i.payload;try{return zt(i,{archivedSessionIds:await e.archiveSession(s)})}catch(o){return vo(i,o,s)}}},skills:{list:l(i=>Promise.resolve(zt(i,{skills:[]})),"list")},agentPresets:{list:l(i=>Promise.resolve(zt(i,{presets:[{id:"dsh-edge",trust:"system",isDefault:!0,name:"DSH Edge",description:"DeepSeek Harness running in a Cloudflare Durable Object."}],authorable:!1,hasDocument:!1})),"list"),select(i){return i.payload.agentPreset!=="dsh-edge"?Promise.resolve(At(i,{code:"agent-preset-not-found",message:`Agent preset "${i.payload.agentPreset}" is not available.`,details:{agentPreset:i.payload.agentPreset,available:["dsh-edge"]}})):Promise.resolve(zt(i,{agentPreset:"dsh-edge"}))},async read(i){if(i.payload.agentPreset!=="dsh-edge")return At(i,{code:"agent-preset-not-found",message:`Agent preset "${i.payload.agentPreset}" is not available.`,details:{agentPreset:i.payload.agentPreset,available:["dsh-edge"]}});try{let s=await e.sessions.modelCatalog();return zt(i,{agentPreset:"dsh-edge",trust:"system",name:"DSH Edge",description:"DeepSeek Harness running in a Cloudflare Durable Object.",content:y3e(e,e.deploymentProfile(),s.groups.flatMap(o=>o.models))})}catch(s){return At(i,{code:"internal",message:s instanceof Error?s.message:String(s),details:{}})}},copy:tn,openDocument:tn,remove:tn},goals:{create:tn,edit:tn,pause:tn,resume:tn,complete:tn,clear:tn},settings:{async describe(i){let[s,o,a]=await Promise.all([e.settingsWritable(),e.settingsHasDocument(),e.describeSettings()]);return zt(i,{writable:s,hasDocument:o,namespaces:a.map(ry)})},openDocument:tn,async update(i){let{ns:s,patch:o,expectedRevision:a}=i.payload;try{let c=await e.updateSettings(s,o,a);return c===void 0?g8(i,s):zt(i,ry(c))}catch(c){return y8(i,c)}},async replace(i){let{ns:s,section:o,expectedRevision:a}=i.payload;try{let c=await e.replaceSettings(s,o,a);return c===void 0?g8(i,s):zt(i,ry(c))}catch(c){return y8(i,c)}},async mutate(i){let{ns:s,ops:o,expectedRevision:a}=i.payload;try{let c=await e.mutateSettings(s,o,a);return c===void 0?g8(i,s):zt(i,ry(c))}catch(c){return y8(i,c)}}},credentials:{async describe(i){let s=await Promise.all(i.payload.refs.map(async o=>[o,await e.describeCredential(o)]));return zt(i,{credentials:Object.fromEntries(s)})},async set(i){let{ref:s,value:o}=i.payload;try{return await e.setCredential(s,o),zt(i,{})}catch(a){return At(i,{code:"internal",message:a instanceof Error?a.message:String(a),details:{}})}},async unset(i){let{ref:s}=i.payload;try{return await e.unsetCredential(s),zt(i,{})}catch(o){return At(i,{code:"internal",message:o instanceof Error?o.message:String(o),details:{}})}}},llm:{async providers(i){let s=await e.listConfigurableProviders();return zt(i,{providers:s.map(o=>({provider:o.provider,displayName:o.displayName,settingsNs:o.settingsNs,settingsPath:[...o.settingsPath],active:o.active,...o.declared===void 0?{}:{declared:o.declared}}))})},async models(i){return zt(i,await e.sessions.modelCatalog())},discoverModels:tn},events:{mux:l((i,s)=>QK(),"mux"),host:l((i,s)=>QK(),"host")},downloads:{sessionLog:l(()=>Promise.resolve(new Response("Session export is unavailable on Edge.",{status:501})),"sessionLog")},respond:l(()=>Promise.resolve({accepted:!1,reason:"not-pending"}),"respond")}}l(tY,"createEdgeApi");function y3e(e,t,r){return["# Effective dsh-edge composition (read-only)","# Projected from the programmatic Worker runtime; this is not an editable agent.cordis.yml.","preset:"," id: dsh-edge"," trust: system","release:",` version: ${Pn(e.version)}`,` deploymentId: ${Pn(t.deploymentId)}`,"runtime:"," platform: cloudflare-workers",` storage: ${Pn(t.storage)}`,` attachmentStorage: ${Pn(t.attachmentStorage)}`,` shell: ${Pn(t.shell)}`," workspace: /workspace","agent:",' loop: "@deepseek-ai/dsh-agent-loop"',' registry: "@deepseek-ai/dsh-agent"',' sessionStore: "@deepseek-ai/dsh-session"',` systemPrompt: ${Pn(zm)}`,"model:",` provider: ${Pn(eY)}`,` defaultId: ${Pn(e.model)}`," selectionScope: session"," catalogSource: upstream-provider"," available:",...r.flatMap(n=>[` - id: ${Pn(n.id)}`,` name: ${Pn(n.name)}`]),` baseURL: ${Pn(t.baseURL)}`,` reasoningEffort: ${Pn(t.reasoningEffort)}`,` maxOutputTokens: ${String(t.maxTokens)}`,` streamIdleTimeoutMs: ${String(t.streamIdleTimeoutMs)}`," credential:"," ref: DEEPSEEK_API_KEY",` configured: ${String(t.apiKeyConfigured)}`," persisted: false","attachments:"," enabled: true",` storage: ${Pn(t.attachmentStorage)}`,...t.attachmentStorage==="temporary-do"?[` storageLimitBytes: ${String(S6)}`]:[],` mediaTypes: ${Pn(e.imageLimits?.mediaTypes.join(",")??"")}`,` maxImagesPerMessage: ${String(e.imageLimits?.maxImagesPerMessage??0)}`,` maxImageBytes: ${String(e.imageLimits?.maxImageBytes??0)}`,` maxMessageImageBytes: ${String(e.imageLimits?.maxMessageImageBytes??0)}`,"tools:"," - id: bash"," runtime: just-bash"," filesystem: /workspace",` defaultTimeoutMs: ${String(t.commandTimeoutPolicy.defaultTimeoutMs)}`,` maxTimeoutMs: ${String(t.commandTimeoutPolicy.maxTimeoutMs)}`," - id: web_search"," provider: deepseek-official",` baseURL: ${Pn(t.searchBaseURL)}`," credentialRef: DEEPSEEK_API_KEY"," maxResults: 8"," webFetchEnabled: false"].join(`
|
|
2357
|
+
`,"%0A")}l(u3e,"encodeEventType");function m8(e={}){let t=new Headers(e);return t.set("cache-control","no-cache, no-transform"),t.set("content-type","text/event-stream; charset=utf-8"),t.set("x-accel-buffering","no"),t}l(m8,"edgeEventStreamHeaders");function JK(e,t){let r=!0,n,i=new Promise(o=>{n=o});return{stream:new ReadableStream({start(o){Promise.resolve().then(async()=>e(a=>{if(r)try{let c=h8(a);if(o.desiredSize===null||o.desiredSize<c.byteLength){r=!1,o.error(new Error("dsh-edge event stream client is too slow."));return}o.enqueue(c)}catch{r=!1}})).then(()=>{if(r)try{o.close()}catch{r=!1}},a=>{t(a),r&&(r=!1,o.error(new Error("dsh-edge turn transport failed.")))}).finally(n)},cancel(){r=!1}},{highWaterMark:c3e,size:l(o=>o.byteLength,"size")}),completion:i}}l(JK,"createLiveSessionEventStream");var un="edge-workspace",Mi="/workspace",ey="dsh-edge:workspace-domain-state:v2",$l="dsh-edge:workspace-domain-workspaces:edge-workspace:v2",yo=class extends Error{constructor(r,n){super(n);this.code=r;this.name="EdgeWorkspaceStoreError"}code;static{l(this,"EdgeWorkspaceStoreError")}},ty=class{constructor(t){this.storage=t}storage;static{l(this,"EdgeWorkspaceStore")}operationTail=Promise.resolve();list(t){return this.serialize(async()=>{let r=await this.readState();if(!r.workspaceIds.includes(un))return{items:[],archivedSessionIds:r.archivedSessionIds};let n=await this.readOrCreateRecord(t);return{items:[qs(n)],archivedSessionIds:r.archivedSessionIds}})}create(t,r){return this.serialize(async()=>{if(t!==Mi)throw new yo("INVALID_PATH",`Edge workspaces must use ${Mi}.`);let n=await this.readState();if(n.workspaceIds.includes(un)){let o=await this.readOrCreateRecord(r);return{workspace:qs(o),created:!1}}let i=new Date().toISOString(),s={path:Mi,title:"workspace",sessionIds:[],createdAt:i,updatedAt:i};return await this.storage.transaction(async o=>{await o.put($l,s),await o.put(ey,{...n,workspaceIds:[un]})}),{workspace:qs(s),created:!0}})}rename(t,r,n){return this.serialize(async()=>{await this.requireWorkspace(t);let i=await this.readOrCreateRecord(n);if(i.title===r)return{workspace:qs(i),changed:!1};let s={...i,title:r,updatedAt:new Date().toISOString()};return await this.storage.put($l,s),{workspace:qs(s),changed:!0}})}delete(t){return this.serialize(async()=>{let r=await this.requireWorkspace(t);await this.storage.transaction(async n=>{await n.delete($l),await n.put(ey,{...r,workspaceIds:[]})})})}insertBefore(t,r){return this.serialize(async()=>{let n=await this.requireWorkspace(t);if(r!==void 0&&r!==un)throw new yo("NOT_FOUND",`Workspace "${r}" is not available in this Edge instance.`);return[...n.workspaceIds]})}insertSessionBefore(t,r,n,i){return this.serialize(async()=>{await this.requireWorkspace(t);let s=await this.readOrCreateRecord(i);if(!s.sessionIds.includes(r))throw new yo("MOVE_INVALID",`Session "${r}" is not accounted by workspace "${t}".`);if(n!==void 0&&!s.sessionIds.includes(n))throw new yo("MOVE_INVALID",`Anchor session "${n}" is not accounted by workspace "${t}".`);if(n===r)return{workspace:qs(s),changed:!1};let o=s.sessionIds.filter(d=>d!==r),a=n===void 0?o.length:o.indexOf(n),c=[...o.slice(0,a),r,...o.slice(a)];if(f3e(c,s.sessionIds))return{workspace:qs(s),changed:!1};let u={...s,sessionIds:c,updatedAt:new Date().toISOString()};return await this.storage.put($l,u),{workspace:qs(u),changed:!0}})}attachSession(t,r,n){return this.serialize(async()=>{await this.requireWorkspace(t);let i=await this.readOrCreateRecord(n);if(i.sessionIds.includes(r))return qs(i);let s={...i,sessionIds:[r,...i.sessionIds],updatedAt:new Date().toISOString()};return await this.storage.put($l,s),qs(s)})}workspaceForSession(t,r){return this.serialize(async()=>(await this.readState()).workspaceIds.includes(un)&&(await this.readOrCreateRecord(r)).sessionIds.includes(t)?un:void 0)}archivedSessionIds(){return this.serialize(async()=>[...(await this.readState()).archivedSessionIds])}archiveSession(t,r){return this.serialize(async()=>{let n=await this.readState();if(n.archivedSessionIds.includes(t))return{archivedSessionIds:[...n.archivedSessionIds],changed:!1};await r();let i=[...n.archivedSessionIds,t];return await this.storage.put(ey,{...n,archivedSessionIds:i}),{archivedSessionIds:i,changed:!0}})}async requireWorkspace(t){let r=await this.readState();if(t!==un||!r.workspaceIds.includes(t))throw new yo("NOT_FOUND",`Workspace "${t}" is not available in this Edge instance.`);return r}async readOrCreateRecord(t){let r=await this.storage.get($l);if(r!==void 0)return h3e(r);let n=d3e(t);return await this.storage.put($l,n),n}async readState(){let t=await this.storage.get(ey);return t===void 0?{initialized:!0,workspaceIds:[un],archivedSessionIds:[]}:p3e(t)}serialize(t){let r=this.operationTail.then(t);return this.operationTail=r.then(()=>{},()=>{}),r}};function d3e(e){let t=e.length===0?new Date(0).toISOString():new Date(Math.min(...e.map(n=>n.createdAt))).toISOString(),r=e.length===0?t:new Date(Math.max(...e.map(n=>n.updatedAt))).toISOString();return{path:Mi,title:"Workspace",sessionIds:e.map(n=>n.id),createdAt:t,updatedAt:r}}l(d3e,"defaultWorkspaceRecord");function qs(e){return{workspaceId:un,...e,sessionIds:[...e.sessionIds]}}l(qs,"workspaceView");function f3e(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}l(f3e,"sameIds");function p3e(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("dsh-edge workspace domain state is invalid.");let t=e,r=t.workspaceIds,n=t.archivedSessionIds;if(t.initialized!==!0||!Array.isArray(r)||r.some(i=>i!==un)||new Set(r).size!==r.length||!Array.isArray(n)||n.some(i=>typeof i!="string"||i.length===0)||new Set(n).size!==n.length||Object.hasOwn(t,"pendingMutation"))throw new Error("dsh-edge workspace domain state is invalid.");return{initialized:!0,workspaceIds:r.map(()=>un),archivedSessionIds:n}}l(p3e,"workspaceDomainStateFromStorage");function h3e(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("dsh-edge workspace record is invalid.");let t=e;if(t.path!==Mi||typeof t.title!="string"||!Array.isArray(t.sessionIds)||t.sessionIds.some(r=>typeof r!="string"||r.length===0)||new Set(t.sessionIds).size!==t.sessionIds.length||typeof t.createdAt!="string"||typeof t.updatedAt!="string")throw new Error("dsh-edge workspace record is invalid.");return{path:Mi,title:t.title,sessionIds:t.sessionIds,createdAt:t.createdAt,updatedAt:t.updatedAt}}l(h3e,"workspaceRecordFromStorage");var eY="deepseek-official",m3e=50,pa=65536,g3e=new TextEncoder;function ny(e){return e.reduce((t,r)=>t+g3e.encode(r.text).byteLength,0)}l(ny,"messageTextByteLength");function tY(e){let t=new Map,r=l((i,s)=>{let o=(t.get(i)??Promise.resolve()).then(s),a=o.then(()=>{},()=>{});return t.set(i,a),o.finally(()=>{t.get(i)===a&&t.delete(i)})},"serializeImageMutation");return{sessions:{async list(i){let s=await e.sessions.listApiSessions();return zt(i,{items:s.map(o=>w3e(e,o))})},async search(i,s){try{return zt(i,await e.sessions.searchApiSessions(i.payload.query,s))}catch(o){return s.aborted||o instanceof DOMException&&o.name==="AbortError"?At(i,{code:"cancelled",message:"Session search was aborted.",details:{}}):At(i,{code:"internal",message:o instanceof Error?o.message:String(o),details:{}})}},async create(i){let{workspaceId:s,cwd:o,sessionId:a,agentPreset:c}=i.payload;if(s!==void 0&&s!==un)return At(i,{code:"workspace-not-found",message:`Workspace "${s}" is not available in this Edge instance.`,details:{workspaceId:s}});let u=await e.workspaceList(await e.sessions.listApiSessions());if(s!==void 0&&!u.items.some(d=>d.workspaceId===s))return At(i,{code:"workspace-not-found",message:`Workspace "${s}" is not available in this Edge instance.`,details:{workspaceId:s}});if(o!==void 0&&o!==Mi)return At(i,{code:"workspace-invalid-path",message:`Edge sessions must use ${Mi}.`,details:{path:o}});if(c!==void 0&&c!=="dsh-edge")return At(i,{code:"agent-preset-not-found",message:`Agent preset "${c}" is not available in this Edge instance.`,details:{agentPreset:c,available:["dsh-edge"]}});try{let d=await e.sessions.createBlankSession({model:e.model,...a===void 0?{}:{sessionId:a}}),f=(await e.sessions.listApiSessions()).find(p=>p.id===d.sessionId);if(f!==void 0&&(d.created&&e.sessionCreated(f),s!==void 0)){let p=await iy(d.sessionId,s,"created",()=>e.sessionAttached(f,s));if(p!==void 0)return At(i,p)}return zt(i,{sessionId:d.sessionId,agentPreset:d.agentPreset})}catch(d){return vo(i,d,a)}},async history(i){let{sessionId:s,beforeSeq:o,maxMessages:a}=i.payload;try{let c=await e.sessions.readHistoryPage(s,o,a??m3e),u=c.events.map(d=>({event:d}));return zt(i,{events:u,hasMore:c.hasMore,...o===void 0?{projections:rY(c.summary,e.imageLimits)}:{}})}catch(c){return vo(i,c,s)}},async models(i){try{let[s,o]=await Promise.all([e.sessions.modelSelection(i.payload.sessionId,e.model),e.sessions.modelCatalog()]);return zt(i,{current:s,routable:!0,groups:o.groups,failures:o.failures})}catch(s){return vo(i,s,i.payload.sessionId)}},async selectModel(i){let{sessionId:s,provider:o,model:a,reasoningEffort:c}=i.payload;return await r(s,async()=>{try{let u=await e.sessions.selectModel(s,{provider:o,model:a,...c===void 0?{}:{reasoningEffort:c}});return zt(i,{selected:u})}catch(u){return u instanceof dt?vo(i,u,s):At(i,{code:"model-unavailable",message:u instanceof Error?u.message:String(u),details:{provider:o,model:a}})}})},async rename(i){let{sessionId:s,title:o}=i.payload;try{let a=await e.sessions.renameSession(s,o,e.model);return a.publishRequired&&e.sessionEvent(s,a.event),zt(i,{title:a.title,seq:a.event.seq})}catch(a){return vo(i,a,s)}},async fork(i){let{sessionId:s,atSeq:o}=i.payload;try{let a=await e.workspaceForSession(s),c=await e.sessions.forkSession(s,o,e.model);if(e.sessionCreated(c),a!==void 0){let u=await iy(c.id,a,"forked",()=>e.sessionAttached(c,a));if(u!==void 0)return At(i,u)}return zt(i,{sessionId:c.id})}catch(a){return vo(i,a,s)}},async prompt(i){let{sessionId:s,mode:o,content:a,clientTimeZone:c}=i.payload,u=b3e(c);if(c!==void 0&&u===void 0)return At(i,{code:"invalid-time-zone",message:"clientTimeZone must be UTC or a valid IANA Area/Location name.",details:{value:c}});let d=a.filter(h=>h.type==="text");if(ny(d)>pa)return At(i,{code:"attachment-error",message:`Prompt text is limited to ${pa} UTF-8 bytes.`,details:{reason:"PROMPT_TEXT_TOO_LARGE"}});let f=a.some(h=>h.type==="image"),p=l(async()=>{try{let h;if(!f)h=d.map(m=>({type:"text",text:m.text}));else{let m=await e.sessions.attachmentStore();if(m===void 0)return At(i,{code:"attachment-error",message:"Image attachments are not available in this Edge instance.",details:{reason:"EDGE_ATTACHMENTS_UNAVAILABLE"}});if(!await e.sessions.modelSupportsImages(s,e.model))return At(i,{code:"attachment-error",message:"The selected model does not support image input.",details:{reason:"MODEL_DOES_NOT_SUPPORT_IMAGES"}});let g=await Wm(m,a.filter(x=>x.type==="image")),y=0;h=a.map(x=>x.type==="text"?{type:"text",text:x.text}:{type:"image",attachment:g[y++]})}return await e.prompt({sessionId:s,mode:o,content:h,rpcId:i.rpcId,...u===void 0?{}:{clientTimeZone:u}}),zt(i,{accepted:!0})}catch(h){return h instanceof Ct?At(i,{code:"attachment-error",message:h.message,details:{reason:h.code}}):vo(i,h,s)}},"admit");return f?r(s,p):p()},async attachment(i){let{sessionId:s,attachmentId:o}=i.payload;try{let a=await e.sessions.attachmentStore();if(a===void 0)return At(i,{code:"attachment-error",message:"Image attachments are not available in this Edge instance.",details:{reason:"EDGE_ATTACHMENTS_UNAVAILABLE"}});let c=await e.sessions.referencedImage(s,String(o));if(c===void 0)return At(i,{code:"attachment-error",message:"Image is not referenced by this session.",details:{reason:"ATTACHMENT_NOT_REFERENCED"}});let u=await a.readImage(c);return zt(i,{attachment:u.ref,data:v3e(u.data)})}catch(a){return a instanceof Ct?At(i,{code:"attachment-error",message:a.message,details:{reason:a.code}}):vo(i,a,s)}},updateQueue(i){let{sessionId:s,itemId:o,action:a}=i.payload;if(a.kind==="edit"&&a.content.some(u=>u.type!=="text"&&u.type!=="image"))return Promise.resolve(At(i,{code:"attachment-error",message:"Queue edits accept text and previously admitted images only.",details:{reason:"QUEUE_EDIT_NON_TEXT"}}));if(a.kind==="edit"&&ny(a.content)>pa)return Promise.resolve(At(i,{code:"attachment-error",message:`Queue edit text is limited to ${pa} UTF-8 bytes.`,details:{reason:"QUEUE_EDIT_TEXT_TOO_LARGE"}}));let c=e.updateQueue(s,o,a);return c==="queue-item-not-found"?Promise.resolve(At(i,{code:"queue-item-not-found",message:"The queued item is no longer pending.",details:{itemId:o}})):c==="steer-unavailable"?Promise.resolve(At(i,{code:"steer-unavailable",message:"The current turn no longer accepts steering.",details:{itemId:o}})):c==="queue-edit-attachment-invalid"?Promise.resolve(At(i,{code:"attachment-error",message:"Queue edits may only preserve images already admitted for this pending item.",details:{reason:"QUEUE_EDIT_ATTACHMENT_INVALID"}})):Promise.resolve(zt(i,{accepted:!0}))},cancel(i){return e.cancel(i.payload.sessionId)?Promise.resolve(zt(i,{accepted:!0})):Promise.resolve(At(i,{code:"agent-busy",message:"The session has no active turn in this Edge instance.",details:{reason:"not-running"}}))}},subagents:{list:l(i=>Promise.resolve(zt(i,{entries:[],parentAvailable:!1})),"list"),history:tn,prompt:tn,interrupt:tn},host:{async describe(i){return zt(i,{version:e.version,cwd:Mi,provider:eY,model:e.model,attachedSessions:await e.sessions.attachedSessionCount(),home:Mi,canOpenPath:!1})},pickDirectory:tn,listDirectory:tn,createDirectory:tn,openPath:tn},workspace:{async list(i){let s=await e.sessions.listApiSessions();return zt(i,await e.workspaceList(s))},async create(i){try{return zt(i,await e.workspaceCreate(i.payload.path))}catch(s){return pp(i,s,void 0,void 0,void 0,i.payload.path)}},async rename(i){let{workspaceId:s,title:o}=i.payload;try{return zt(i,{workspace:await e.workspaceRename(s,o.trim())})}catch(a){return pp(i,a,s)}},async delete(i){let{workspaceId:s}=i.payload;try{return await e.workspaceDelete(s),zt(i,{deleted:!0})}catch(o){return pp(i,o,s)}},async insertBefore(i){let{workspaceId:s,beforeWorkspaceId:o}=i.payload;try{return zt(i,{workspaceIds:await e.workspaceInsertBefore(s,o)})}catch(a){return pp(i,a,s)}},async insertSessionBefore(i){let{workspaceId:s,sessionId:o,beforeSessionId:a}=i.payload;try{return zt(i,{workspace:await e.workspaceInsertSessionBefore(s,o,a)})}catch(c){return pp(i,c,s,o,a)}},async archiveSession(i){let{sessionId:s}=i.payload;try{return zt(i,{archivedSessionIds:await e.archiveSession(s)})}catch(o){return vo(i,o,s)}}},skills:{list:l(i=>Promise.resolve(zt(i,{skills:[]})),"list")},agentPresets:{list:l(i=>Promise.resolve(zt(i,{presets:[{id:"dsh-edge",trust:"system",isDefault:!0,name:"DSH Edge",description:"DeepSeek Harness running in a Cloudflare Durable Object."}],authorable:!1,hasDocument:!1})),"list"),select(i){return i.payload.agentPreset!=="dsh-edge"?Promise.resolve(At(i,{code:"agent-preset-not-found",message:`Agent preset "${i.payload.agentPreset}" is not available.`,details:{agentPreset:i.payload.agentPreset,available:["dsh-edge"]}})):Promise.resolve(zt(i,{agentPreset:"dsh-edge"}))},async read(i){if(i.payload.agentPreset!=="dsh-edge")return At(i,{code:"agent-preset-not-found",message:`Agent preset "${i.payload.agentPreset}" is not available.`,details:{agentPreset:i.payload.agentPreset,available:["dsh-edge"]}});try{let[s,o,a]=await Promise.all([e.sessions.modelCatalog(),e.describeSettings(),e.describeCredential("DEEPSEEK_API_KEY")]),c=e.deploymentProfile(),u=o.find(m=>m.ns==="llm-deepseek")?.value,d=u?.baseURL,f=u?.reasoningEffort,p=u?.maxTokens,h={...c,...typeof d=="string"?{baseURL:x3e(d)}:{},...typeof f=="string"?{reasoningEffort:f}:{},...typeof p=="number"?{maxTokens:p}:{},apiKeyConfigured:a.configured,apiKeyPersisted:a.source==="do-storage"};return zt(i,{agentPreset:"dsh-edge",trust:"system",name:"DSH Edge",description:"DeepSeek Harness running in a Cloudflare Durable Object.",content:y3e(e,h,s.groups.flatMap(m=>m.models))})}catch(s){return At(i,{code:"internal",message:s instanceof Error?s.message:String(s),details:{}})}},copy:tn,openDocument:tn,remove:tn},goals:{create:tn,edit:tn,pause:tn,resume:tn,complete:tn,clear:tn},settings:{async describe(i){let[s,o,a]=await Promise.all([e.settingsWritable(),e.settingsHasDocument(),e.describeSettings()]);return zt(i,{writable:s,hasDocument:o,namespaces:a.map(ry)})},openDocument:tn,async update(i){let{ns:s,patch:o,expectedRevision:a}=i.payload;try{let c=await e.updateSettings(s,o,a);return c===void 0?g8(i,s):zt(i,ry(c))}catch(c){return y8(i,c)}},async replace(i){let{ns:s,section:o,expectedRevision:a}=i.payload;try{let c=await e.replaceSettings(s,o,a);return c===void 0?g8(i,s):zt(i,ry(c))}catch(c){return y8(i,c)}},async mutate(i){let{ns:s,ops:o,expectedRevision:a}=i.payload;try{let c=await e.mutateSettings(s,o,a);return c===void 0?g8(i,s):zt(i,ry(c))}catch(c){return y8(i,c)}}},credentials:{async describe(i){let s=await Promise.all(i.payload.refs.map(async o=>[o,await e.describeCredential(o)]));return zt(i,{credentials:Object.fromEntries(s)})},async set(i){let{ref:s,value:o}=i.payload;try{return await e.setCredential(s,o),zt(i,{})}catch(a){return At(i,{code:"internal",message:a instanceof Error?a.message:String(a),details:{}})}},async unset(i){let{ref:s}=i.payload;try{return await e.unsetCredential(s),zt(i,{})}catch(o){return At(i,{code:"internal",message:o instanceof Error?o.message:String(o),details:{}})}}},llm:{async providers(i){let s=await e.listConfigurableProviders();return zt(i,{providers:s.map(o=>({provider:o.provider,displayName:o.displayName,settingsNs:o.settingsNs,settingsPath:[...o.settingsPath],active:o.active,...o.declared===void 0?{}:{declared:o.declared}}))})},async models(i){return zt(i,await e.sessions.modelCatalog())},discoverModels:tn},events:{mux:l((i,s)=>QK(),"mux"),host:l((i,s)=>QK(),"host")},downloads:{sessionLog:l(()=>Promise.resolve(new Response("Session export is unavailable on Edge.",{status:501})),"sessionLog")},respond:l(()=>Promise.resolve({accepted:!1,reason:"not-pending"}),"respond")}}l(tY,"createEdgeApi");function y3e(e,t,r){return["# Effective dsh-edge composition (read-only)","# Projected from the programmatic Worker runtime; this is not an editable agent.cordis.yml.","preset:"," id: dsh-edge"," trust: system","release:",` version: ${Pn(e.version)}`,` deploymentId: ${Pn(t.deploymentId)}`,"runtime:"," platform: cloudflare-workers",` storage: ${Pn(t.storage)}`,` attachmentStorage: ${Pn(t.attachmentStorage)}`,` shell: ${Pn(t.shell)}`," workspace: /workspace","agent:",' loop: "@deepseek-ai/dsh-agent-loop"',' registry: "@deepseek-ai/dsh-agent"',' sessionStore: "@deepseek-ai/dsh-session"',` systemPrompt: ${Pn(zm)}`,"model:",` provider: ${Pn(eY)}`,` defaultId: ${Pn(e.model)}`," selectionScope: session"," catalogSource: upstream-provider"," available:",...r.flatMap(n=>[` - id: ${Pn(n.id)}`,` name: ${Pn(n.name)}`]),` baseURL: ${Pn(t.baseURL)}`,` reasoningEffort: ${Pn(t.reasoningEffort)}`,` maxOutputTokens: ${String(t.maxTokens)}`,` streamIdleTimeoutMs: ${String(t.streamIdleTimeoutMs)}`," credential:"," ref: DEEPSEEK_API_KEY",` configured: ${String(t.apiKeyConfigured)}`,` persisted: ${String(t.apiKeyPersisted??!1)}`,"attachments:"," enabled: true",` storage: ${Pn(t.attachmentStorage)}`,...t.attachmentStorage==="temporary-do"?[` storageLimitBytes: ${String(S6)}`]:[],` mediaTypes: ${Pn(e.imageLimits?.mediaTypes.join(",")??"")}`,` maxImagesPerMessage: ${String(e.imageLimits?.maxImagesPerMessage??0)}`,` maxImageBytes: ${String(e.imageLimits?.maxImageBytes??0)}`,` maxMessageImageBytes: ${String(e.imageLimits?.maxMessageImageBytes??0)}`,"tools:"," - id: bash"," runtime: just-bash"," filesystem: /workspace",` defaultTimeoutMs: ${String(t.commandTimeoutPolicy.defaultTimeoutMs)}`,` maxTimeoutMs: ${String(t.commandTimeoutPolicy.maxTimeoutMs)}`," - id: web_search"," provider: deepseek-official",` baseURL: ${Pn(t.searchBaseURL)}`," credentialRef: DEEPSEEK_API_KEY"," maxResults: 8"," webFetchEnabled: false"].join(`
|
|
2358
2358
|
`)+`
|
|
2359
|
-
`}l(y3e,"edgeAgentPresetContent");function Pn(e){return JSON.stringify(e)}l(Pn,"yamlString");function v3e(e){let r="";for(let n=0;n<e.byteLength;n+=32768)r+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(r)}l(v3e,"bytesToBase64");function w3e(e,t){return{sessionId:t.id,updatedAt:t.updatedAt,running:e.isRunning(t.id),blank:t.blank,...t.parentSessionId===void 0?{}:{parentSessionId:t.parentSessionId},...t.origin===void 0?{}:{origin:t.origin},...t.cwd===void 0?{}:{cwd:t.cwd},...t.agentPreset===void 0?{}:{agentPreset:t.agentPreset},projections:rY(t,e.imageLimits)}}l(w3e,"sessionSummary");function rY(e,t){return{asOfSeq:e.lastSeq,values:{sessionListMetadata:{blank:e.blank,lastPromptAt:e.lastPromptAt},...e.title===null?{}:{title:e.title},...t===void 0?{}:{imageLimits:t}}}}l(rY,"summaryProjections");function b3e(e){if(e===void 0)return;let t=/^[A-Za-z][A-Za-z0-9_+.-]*(?:\/[A-Za-z0-9_+.-]+)+$/;if(!(e.length===0||e.trim()!==e||e!=="UTC"&&!t.test(e)))try{let r=new Intl.DateTimeFormat("en-US",{timeZone:e}).resolvedOptions().timeZone;return r==="UTC"||t.test(r)?r:void 0}catch{return}}l(b3e,"canonicalClientTimeZone");function pp(e,t,r,n,i,s){if(t instanceof yo){if(t.code==="NOT_FOUND"&&r!==void 0)return At(e,{code:"workspace-not-found",message:t.message,details:{workspaceId:r}});if(t.code==="INVALID_PATH")return At(e,{code:"workspace-invalid-path",message:t.message,details:{path:s??Mi}});if(t.code==="MOVE_INVALID"&&r!==void 0&&n!==void 0)return At(e,{code:"workspace-move-invalid",message:t.message,details:{workspaceId:r,sessionId:n,...i===void 0?{}:{beforeSessionId:i}}})}return At(e,{code:"internal",message:t instanceof Error?t.message:String(t),details:{}})}l(pp,"workspaceFailure");async function iy(e,t,r,n){try{await n();return}catch(i){return{code:"workspace-attach-failed",message:`Session "${e}" was ${r} but could not attach to workspace "${t}": ${String(i)}`,details:{sessionId:e,workspaceId:t}}}}l(iy,"attachPublishedSession");function zt(e,t){return{rpcId:e.rpcId,result:{ok:!0,value:t}}}l(zt,"ok");function At(e,t){return{rpcId:e.rpcId,result:{ok:!1,error:t}}}l(At,"fail");function tn(e){return Promise.resolve(At(e,{code:"internal",message:"This capability is not available in the Edge runtime.",details:{}}))}l(tn,"unsupported");function vo(e,t,r){if(t instanceof dt){if(t.code==="NOT_FOUND"&&r!==void 0)return At(e,{code:"session-not-found",message:t.message,details:{sessionId:r}});if(t.code==="BUSY")return At(e,{code:"agent-busy",message:t.message,details:{reason:"running"}});if(t.code==="FORK_UNAVAILABLE"&&r!==void 0)return At(e,{code:"fork-unavailable",message:t.message,details:{sessionId:r}});if(t.code==="TITLE_INVALID"&&r!==void 0)return At(e,{code:"title-invalid",message:t.message,details:{sessionId:r}})}return At(e,{code:"internal",message:t instanceof Error?t.message:String(t),details:{}})}l(vo,"sessionFailure");function ry(e){return{ns:e.ns,schema:e.schema,value:e.value,revision:e.revision,applies:e.applies,secrets:(e.secrets??[]).map(t=>({path:t.path,set:t.set})),...e.base===void 0?{}:{base:e.base},...e.user===void 0?{}:{user:e.user}}}l(ry,"descriptorToView");function g8(e,t){return At(e,{code:"settings-rejected",message:`Settings namespace "${t}" is not registered.`,details:{ns:t}})}l(g8,"settingsNotRegistered");function y8(e,t){let r=e.payload.ns;return t instanceof Bu?At(e,{code:"settings-conflict",message:t.message,details:{ns:r,expected:t.expected,actual:t.actual}}):At(e,{code:"settings-rejected",message:t instanceof Error?t.message:String(t),details:{ns:r}})}l(y8,"settingsWriteFailure");async function*QK(){}l(QK,"emptyFrames");var x3e="/api/commands/list";async function nY(e){if(new URL(e.url).pathname!==x3e)return;if(e.method!=="POST")return new Response("method not allowed",{status:405,headers:{allow:"POST"}});if(e.headers.get("content-type")?.split(";",1).at(0)?.trim()!=="application/json")return new Response("expected application/json",{status:415});let r;try{r=await e.json()}catch{return new Response("invalid JSON body",{status:400})}let n=Fm.safeParse(r);if(!n.success||n.data.method!=="commands/list")return new Response("request path and method do not match",{status:400});let i={type:"server-response",rpcId:n.data.rpcId,result:{ok:!0,value:[]}};return Response.json(i)}l(nY,"handleEdgeRemote");var S3e=160,k3e=640,uY=128,A3e=50,iY=100,I3e=128,sY=256,oY=1048576,$3e={blank:!0,lastPromptAt:null},aY=1008,lY="owner session expired";function _3e(e,t){let r=e.blank&&t.type!=="turn/start",n=t.type==="user/message"&&t.data.source.kind==="user"?t.time:e.lastPromptAt;return r===e.blank&&n===e.lastPromptAt?e:{blank:r,lastPromptAt:n}}l(_3e,"applySessionListMetadata");var v8=class extends E3e{static{l(this,"DshEdgeObjectBase")}workspaceOptions(){let t=this.env.LOADER===void 0?new Q0:new cV({loader:this.env.LOADER,workspace:{binding:"DSH_EDGE_INSTANCE",id:this.ctx.id.toString()},ctx:this.ctx});return{storage:this.ctx.storage,backends:[t]}}},T3e=O$(v8,e=>e.workspaceOptions()),w8=class extends T3e{static{l(this,"DshEdgeInstance")}attachmentStorage=AO(this.ctx.storage,this.env.DSH_EDGE_ATTACHMENTS);sessions=new Eg(this.ctx.storage,{readDeepSeekApiKey:l(()=>this.env.DEEPSEEK_API_KEY,"readDeepSeekApiKey"),attachmentStorage:this.attachmentStorage,...this.env.DEEPSEEK_SEARCH_BASE_URL===void 0?{}:{searchBaseURL:this.env.DEEPSEEK_SEARCH_BASE_URL},...this.env.DSH_EDGE_ATTACHMENTS===void 0?{}:{attachmentBucket:this.env.DSH_EDGE_ATTACHMENTS},...this.env.DEEPSEEK_BASE_URL===void 0?{}:{baseURL:this.env.DEEPSEEK_BASE_URL},...this.env.DEEPSEEK_MAX_OUTPUT_TOKENS===void 0?{}:{maxTokens:this.env.DEEPSEEK_MAX_OUTPUT_TOKENS},...this.env.DEEPSEEK_REASONING_EFFORT===void 0?{}:{reasoningEffort:this.env.DEEPSEEK_REASONING_EFFORT},...this.env.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS===void 0?{}:{streamIdleTimeoutMs:this.env.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS}});workspaces=new ty(this.ctx.storage);model=sf(this.env.DEEPSEEK_MODEL);activeTurns=new Map;sessionListMetadata=new Map;api=tY({sessions:this.sessions,model:this.model,version:Ng,imageLimits:this.attachmentStorage==="temporary-do"?k6:cg,deploymentProfile:l(()=>pk(this.env,this.attachmentStorage),"deploymentProfile"),describeCredential:l(t=>this.sessions.describeCredential(t),"describeCredential"),setCredential:l((t,r)=>this.sessions.setCredential(t,r),"setCredential"),unsetCredential:l(t=>this.sessions.unsetCredential(t),"unsetCredential"),settingsWritable:l(()=>this.sessions.settingsWritable(),"settingsWritable"),settingsHasDocument:l(()=>this.sessions.settingsHasDocument(),"settingsHasDocument"),describeSettings:l(()=>this.sessions.describeSettings(),"describeSettings"),updateSettings:l((t,r,n)=>this.sessions.updateSettings(t,r,n),"updateSettings"),replaceSettings:l((t,r,n)=>this.sessions.replaceSettings(t,r,n),"replaceSettings"),mutateSettings:l((t,r,n)=>this.sessions.mutateSettings(t,r,n),"mutateSettings"),listConfigurableProviders:l(()=>this.sessions.listConfigurableProviders(),"listConfigurableProviders"),listLlmProviders:l(()=>this.sessions.listLlmProviders(),"listLlmProviders"),isRunning:l(t=>this.activeTurns.has(t),"isRunning"),prompt:l(t=>this.startApiPrompt(t),"prompt"),updateQueue:l((t,r,n)=>this.updateQueue(t,r,n),"updateQueue"),cancel:l(t=>this.requestTurnCancellation(t),"cancel"),workspaceList:l(t=>this.workspaces.list(t),"workspaceList"),workspaceCreate:l(t=>this.createWorkspace(t),"workspaceCreate"),workspaceRename:l((t,r)=>this.renameWorkspace(t,r),"workspaceRename"),workspaceDelete:l(t=>this.deleteWorkspace(t),"workspaceDelete"),workspaceInsertBefore:l((t,r)=>this.workspaces.insertBefore(t,r),"workspaceInsertBefore"),workspaceInsertSessionBefore:l((t,r,n)=>this.insertSessionBefore(t,r,n),"workspaceInsertSessionBefore"),archiveSession:l(t=>this.archiveSession(t),"archiveSession"),sessionCreated:l(t=>{this.publishSessionCreated(t)},"sessionCreated"),sessionAttached:l((t,r)=>this.publishSessionAttached(t,r),"sessionAttached"),workspaceForSession:l(t=>this.workspaceForSession(t),"workspaceForSession"),sessionEvent:l((t,r)=>{this.publishSessionEvent(t,r)},"sessionEvent")});apiFetch=YK(this.api).fetch;async fetch(t){try{let r=new URL(t.url),n=await nY(t);if(n!==void 0)return n;if(r.pathname==="/api/events.mux"||r.pathname==="/api/events.host")return await this.openDownlink(t,r.pathname==="/api/events.mux"?"mux":"host");if(r.pathname.startsWith("/api/")&&!r.pathname.startsWith("/api/sessions"))return await this.apiFetch(t);let i=P3e(r.pathname);if(i.sessionId===void 0){if(t.method==="POST")return await this.createSession(t);if(t.method==="GET"){let s=L3e(r),o=M3e(r),a=await this.sessions.listSessions(s,o);if(a===void 0)throw new wt(400,"Unknown session list cursor.");return yn({sessions:a.sessions.map(c=>this.presentSession(c)),hasMore:a.hasMore,...a.nextAfter===void 0?{}:{nextAfter:a.nextAfter}})}}else if(i.action===void 0){if(t.method==="GET"){let s=await this.sessions.getSession(i.sessionId);if(s===void 0)throw new wt(404,"Session not found.");return yn({session:this.presentSession(s)})}}else{if(i.action==="events"&&t.method==="GET")return await this.replayEvents(t,r,i.sessionId);if(i.action==="turn"&&t.method==="POST")return await this.startTurn(t,i.sessionId);if(i.action==="cancel"&&t.method==="POST")return this.cancelTurn(i.sessionId)}throw new wt(404,"Session route not found.")}catch(r){return await Tg(t),Cg(r)}}webSocketMessage(t,r){this.closeExpiredDownlink(t,Date.now())||t.close(1008,"downlink only")}webSocketError(t,r){console.error("dsh-edge downstream WebSocket failed.",r),t.close(1011,"downstream failure")}async alarm(){let t=this.closeExpiredDownlinks();t!==void 0&&await this.ctx.storage.setAlarm(t)}async openDownlink(t,r){if(t.headers.get("upgrade")?.toLowerCase()!=="websocket")throw new wt(426,"This event endpoint requires a WebSocket upgrade.");let n=N3e(t);await this.scheduleDownlinkExpiry(n*1e3);let i=l(s=>{let o=new WebSocketPair,a=o[0],c=o[1];if(c.serializeAttachment({channel:r,expiresAt:n}),this.ctx.acceptWebSocket(c,[r]),s!==void 0){for(let u of s.sessions)if(this.rememberSessionListMetadata(u),!this.sendFrame(c,{type:"session/subscribed",sessionId:u.id,lastSeq:u.lastSeq}))break;for(let u of s.queues)if(!this.sendFrame(c,{type:"session/queue",sessionId:u.sessionId,items:u.items}))break}return new Response(null,{status:101,webSocket:a})},"accept");return r==="mux"?this.sessions.withMuxBaseline(i):i()}publishSessionCreated(t){this.rememberSessionListMetadata(t),this.broadcast("mux",{type:"session/subscribed",sessionId:t.id,lastSeq:t.lastSeq}),this.broadcast("host",{type:"host/session-added",sessionId:t.id,blank:t.blank,...t.parentSessionId===void 0?{}:{parentSessionId:t.parentSessionId},...t.origin===void 0?{}:{origin:t.origin},...t.cwd===void 0?{}:{cwd:t.cwd},...t.agentPreset===void 0?{}:{agentPreset:t.agentPreset}})}async publishSessionAttached(t,r){let n=await this.workspaces.attachSession(r,t.id,await this.sessions.listApiSessions());this.broadcast("host",{type:"host/workspace-changed",workspace:n})}async workspaceForSession(t){return await this.workspaces.workspaceForSession(t,await this.sessions.listApiSessions())}async createWorkspace(t){let r=await this.workspaces.create(t,await this.sessions.listApiSessions());return r.created&&this.broadcast("host",{type:"host/workspace-changed",workspace:r.workspace}),r}async renameWorkspace(t,r){let n=await this.workspaces.rename(t,r,await this.sessions.listApiSessions());return n.changed&&this.broadcast("host",{type:"host/workspace-changed",workspace:n.workspace}),n.workspace}async deleteWorkspace(t){await this.workspaces.delete(t),this.broadcast("host",{type:"host/workspace-removed",workspaceId:t})}async insertSessionBefore(t,r,n){let i=await this.workspaces.insertSessionBefore(t,r,n,await this.sessions.listApiSessions());return i.changed&&this.broadcast("host",{type:"host/workspace-changed",workspace:i.workspace}),i.workspace}async archiveSession(t){let r=await this.workspaces.archiveSession(t,()=>this.sessions.requireSession(t));return r.changed&&this.broadcast("host",{type:"host/archived-sessions-changed",archivedSessionIds:r.archivedSessionIds}),r.archivedSessionIds}publishSessionEvent(t,r){this.broadcast("mux",{type:"session/event",sessionId:t,event:r}),r.type==="session/title"&&this.broadcast("mux",{type:"session/projection",sessionId:t,key:"title",value:r.data.title,seq:r.seq});let n=this.sessionListMetadata.get(t)??$3e,i=_3e(n,r);i!==n&&(this.sessionListMetadata.set(t,i),this.broadcast("mux",{type:"session/projection",sessionId:t,key:"sessionListMetadata",value:i,seq:r.seq}))}rememberSessionListMetadata(t){this.sessionListMetadata.set(t.id,{blank:t.blank,lastPromptAt:t.lastPromptAt})}publishSessionQueue(t,r){this.broadcast("mux",{type:"session/queue",sessionId:t,items:r})}publishRunning(t,r){this.broadcast("host",{type:"host/session-status",sessionId:t,running:r})}publishAgentError(t,r){this.broadcast("host",{type:"host/agent-error",sessionId:t,message:r instanceof Error?r.message:String(r)})}broadcast(t,r){let n=Date.now();for(let i of this.ctx.getWebSockets(t))if(i.readyState===WebSocket.OPEN&&!this.closeExpiredDownlink(i,n))try{this.sendFrame(i,r)}catch(s){console.error(`dsh-edge failed to publish ${r.type}.`,s),i.close(1011,"downstream send failed")}}sendFrame(t,r){if(this.closeExpiredDownlink(t,Date.now()))return!1;let n={type:"server-request",rpcId:crypto.randomUUID(),method:r.type,payload:r};return t.send(JSON.stringify(n)),!0}closeExpiredDownlinks(t=Date.now()){let r;for(let n of this.ctx.getWebSockets()){let i=cY(n);if(i===void 0||i.expiresAt*1e3<=t){n.close(aY,lY);continue}let s=i.expiresAt*1e3;r=r===void 0?s:Math.min(r,s)}return r}closeExpiredDownlink(t,r){let n=cY(t);return n!==void 0&&n.expiresAt*1e3>r?!1:(t.close(aY,lY),!0)}async scheduleDownlinkExpiry(t){let r=await this.ctx.storage.getAlarm();(r===null||t<r)&&await this.ctx.storage.setAlarm(t)}async createSession(t){let r=await nf(t,$g),n=Wo(mR(r.title,"title",S3e),k3e);if(n.length===0)throw new wt(400,"Session title must contain visible text.");let i=await this.sessions.createSession({title:n}),s=this.presentSession(i),o=await iy(i.id,un,"created",async()=>{let a=(await this.sessions.listApiSessions()).find(u=>u.id===i.id);if(a===void 0)throw new Error(`Session "${i.id}" is missing from its post-creation summary.`);this.publishSessionCreated(a),(await this.workspaces.list(await this.sessions.listApiSessions())).items.some(u=>u.workspaceId===un)&&await this.publishSessionAttached(a,un)});return o!==void 0?yn({ok:!1,error:o.message,code:o.code,details:o.details,session:s},500):yn({session:s},201)}async replayEvents(t,r,n){let i=D3e(t,r),s=F3e(r),o=await this.sessions.readEventPage(n,i+1,s,oY),a=[],c=0,u=o.hasMore;if(o.events.length===0&&o.hasMore)throw new wt(413,"The next session event exceeds the replay response limit.");for(let h of o.events){let m=h8(h);if(c+m.byteLength>oY){if(a.length===0)throw new wt(413,"The next session event exceeds the replay response limit.");u=!0;break}a.push(m),c+=m.byteLength}let d=new ReadableStream({start(h){for(let m of a)h.enqueue(m);h.close()}}),f=o.events[a.length-1]?.seq??i,p=m8(Zo());return p.set("x-dsh-edge-has-more",String(u)),p.set("x-dsh-edge-next-after",String(f)),new Response(d,{headers:p})}async startTurn(t,r){let n=await nf(t,_g),i=gR(n.message,"message",pa),{commandTimeoutPolicy:s}=Rg(this.env),o=await this.claimTurn(r),{stream:a,completion:c}=JK(u=>this.runClaimedTurn({claimed:o,commandTimeoutPolicy:s,mode:"queue",content:[{type:"text",text:i}],publish:u}),u=>{console.error("dsh-edge turn transport failed.",u)});return this.ctx.waitUntil(c.catch(()=>{})),new Response(a,{status:200,headers:m8(Zo())})}async startApiPrompt(t){if(ny(t.content.filter(r=>r.type==="text"))>pa)throw new wt(413,`Prompt text is limited to ${pa} UTF-8 bytes.`);for(;;){let r=this.activeTurns.get(t.sessionId);if(r!==void 0){if(await r.admissionReady,this.activeTurns.get(t.sessionId)===r&&r.accepting&&r.admit!==void 0){await r.admit({mode:t.mode,content:t.content,rpcId:t.rpcId,...t.clientTimeZone===void 0?{}:{clientTimeZone:t.clientTimeZone}});return}await r.releaseComplete;continue}let{commandTimeoutPolicy:n}=Rg(this.env),i;try{i=await this.claimTurn(t.sessionId)}catch(o){if(o instanceof dt&&o.code==="BUSY")continue;throw o}let s=this.runClaimedTurn({claimed:i,commandTimeoutPolicy:n,mode:t.mode,content:t.content,rpcId:t.rpcId,...t.clientTimeZone===void 0?{}:{clientTimeZone:t.clientTimeZone}});this.ctx.waitUntil(s.catch(o=>{console.error("dsh-edge upstream protocol turn failed.",o)})),await i.turn.admissionReady,i.turn.wasAdmitted||await s;return}}updateQueue(t,r,n){let s=this.activeTurns.get(t)?.agent;if(s===void 0)return"queue-item-not-found";let o=s.inbox.nextTurn.some(c=>c.id===r)?"next-turn":s.inbox.nextStep.some(c=>c.id===r)?"next-step":void 0,a=o===void 0?void 0:(o==="next-turn"?s.inbox.nextTurn:s.inbox.nextStep).find(c=>c.id===r);if(o===void 0||a===void 0)return"queue-item-not-found";if(n.kind==="steer"&&(o!=="next-turn"||s.status!=="running"))return"steer-unavailable";if(n.kind==="edit"){if(!C3e(a.content,n.content))return"queue-edit-attachment-invalid";s.inbox.replace(r,Io({...a,content:n.content}))}else s.inbox.remove(r),n.kind==="steer"&&s.steer(a);return"accepted"}async claimTurn(t){let r=await this.sessions.getApiSessionSummary(t);if(this.activeTurns.has(t))throw new dt("BUSY","The session already has a running turn.");this.rememberSessionListMetadata(r);let n={turnId:crypto.randomUUID(),cancelRequested:!1,accepting:!1,wasAdmitted:!1,...R3e()};this.activeTurns.set(t,n);try{let i=await this.sessions.openAgentForTurn(t,this.model);return n.agent=i.agent,{sessionId:t,turn:n,handle:i}}catch(i){throw this.activeTurns.delete(t),n.resolveAdmissionReady(),n.resolveReleaseComplete(),i}}async runClaimedTurn(t){let{sessionId:r,turn:n,handle:i}=t.claimed;try{await this.runTurn({...t,agent:i.agent,turn:n,onAdmitted:l(s=>{n.admit=s,n.accepting=!0,n.wasAdmitted=!0,this.publishRunning(r,!0),n.resolveAdmissionReady()},"onAdmitted"),onClosing:l(()=>{n.accepting=!1},"onClosing"),publish:l(async s=>{this.publishSessionEvent(r,s),await t.publish?.(s)},"publish"),publishQueue:l(s=>{this.publishSessionQueue(r,s)},"publishQueue")})}catch(s){throw this.publishAgentError(r,s),s}finally{n.accepting=!1,n.resolveAdmissionReady(),await i.dispose().catch(o=>{console.error("dsh-edge failed to release the turn agent.",o)}),this.activeTurns.get(r)?.turnId===n.turnId&&this.activeTurns.delete(r),n.resolveReleaseComplete(),this.publishRunning(r,!1)}}async runTurn(t){var n=[];try{let r=_l(n,await Rp(this));await this.sessions.runAgentTurn({agent:t.agent,mode:t.mode,content:t.content,...t.rpcId===void 0?{}:{rpcId:t.rpcId},...t.clientTimeZone===void 0?{}:{clientTimeZone:t.clientTimeZone},shell:{exec:l(async(a,c)=>Ig(r,Ag(a),tf(c.cwd),t.commandTimeoutPolicy,c.timeoutMs,c.signal),"exec")},afterFollowup:l(()=>{t.turn.cancelRequested&&t.agent.cancel({kind:"user"})},"afterFollowup"),...t.onAdmitted===void 0?{}:{onAdmitted:t.onAdmitted},...t.onClosing===void 0?{}:{onClosing:t.onClosing},publish:t.publish,publishQueue:t.publishQueue})}catch(i){var s=i,o=!0}finally{Tl(n,s,o)}}cancelTurn(t){let r=this.activeTurns.get(t);if(r===void 0||!this.requestTurnCancellation(t))throw new wt(409,"The session has no active turn in this Worker instance.");let n={ok:!0,sessionId:t,turnId:r.turnId};return yn(n,202)}requestTurnCancellation(t){let r=this.activeTurns.get(t);return r===void 0?!1:(r.cancelRequested=!0,r.agent?.cancel({kind:"user"}),!0)}presentSession(t){return{...t,status:this.activeTurns.has(t.id)?"running":"idle"}}};function C3e(e,t){let r=e.flatMap(n=>n.type==="image"?[n.attachment]:[]);for(let n of t){if(n.type==="text")continue;if(n.type!=="image")return!1;let i=r.findIndex(s=>O3e(s,n.attachment));if(i<0)return!1;r.splice(i,1)}return!0}l(C3e,"preservesAdmittedQueueImages");function O3e(e,t){return e.attachmentId===t.attachmentId&&e.mediaType===t.mediaType&&e.bytes===t.bytes&&e.width===t.width&&e.height===t.height&&e.name===t.name}l(O3e,"sameImageRef");function N3e(e){let t=e.headers.get(Og);if(t===null||!/^\d{10}$/u.test(t))throw new wt(401,"Owner authentication required.");let r=Number(t);if(!Number.isSafeInteger(r)||r*1e3<=Date.now())throw new wt(401,"Owner authentication required.");return r}l(N3e,"requireOwnerSessionExpiry");function cY(e){try{let t=e.deserializeAttachment();if(typeof t!="object"||t===null)return;let{channel:r,expiresAt:n}=t;return r!=="mux"&&r!=="host"||typeof n!="number"||!Number.isSafeInteger(n)?void 0:{channel:r,expiresAt:n}}catch{return}}l(cY,"readDownlinkAttachment");function R3e(){let e=Promise.withResolvers(),t=Promise.withResolvers();return{admissionReady:e.promise,releaseComplete:t.promise,resolveAdmissionReady:e.resolve,resolveReleaseComplete:t.resolve}}l(R3e,"activeTurnSignals");function P3e(e){let t=e.split("/").filter(Boolean);if(t[0]!=="api"||t[1]!=="sessions"||t.length>4)throw new wt(404,"Session route not found.");if(t.length===2)return{};let r;try{r=decodeURIComponent(t[2]??"")}catch{throw new wt(400,"Invalid session id.")}if(r.length===0||r.length>uY)throw new wt(400,"Invalid session id.");let n=r;if(t.length===3)return{sessionId:n};let i=t[3];if(i!=="events"&&i!=="turn"&&i!=="cancel")throw new wt(404,"Session route not found.");return{sessionId:n,action:i}}l(P3e,"parseSessionRoute");function D3e(e,t){let r=t.searchParams.get("after")??e.headers.get("last-event-id")??"-1";if(!/^-?\d+$/.test(r))throw new wt(400,"after must be an integer.");let n=Number(r);if(!Number.isSafeInteger(n)||n<-1||n>=Number.MAX_SAFE_INTEGER)throw new wt(400,"after exceeds the supported integer range.");return n}l(D3e,"resolveAfterSequence");function L3e(e){let t=e.searchParams.get("after");if(t!==null){if(t.length===0||t.length>uY)throw new wt(400,"Invalid session list cursor.");return t}}l(L3e,"resolveSessionListAfter");function M3e(e){let t=e.searchParams.get("limit");if(t===null)return A3e;if(!/^\d+$/.test(t))throw new wt(400,"limit must be a positive integer.");let r=Number(t);if(!Number.isSafeInteger(r)||r<=0||r>iY)throw new wt(400,`limit must be between 1 and ${iY}.`);return r}l(M3e,"resolveSessionListLimit");function F3e(e){let t=e.searchParams.get("limit");if(t===null)return I3e;if(!/^\d+$/.test(t))throw new wt(400,"limit must be a positive integer.");let r=Number(t);if(!Number.isSafeInteger(r)||r<=0||r>sY)throw new wt(400,`limit must be between 1 and ${sY}.`);return r}l(F3e,"resolveReplayLimit");var U3e="owner",Mze={async fetch(e,t){if(e.method==="OPTIONS")return new Response(null,{status:204,headers:Zo()});try{var r=[];try{let o=new URL(e.url);let a=AR(t.DSH_EDGE_ACCESS_KEY);if(e.method==="GET"&&o.pathname==="/api/health")return yn(RR(t));let c=await IR(e,a);if(c!==void 0)return c;let u=await ok(e,a);if(o.pathname==="/")return u===void 0?$R():await t.ASSETS.fetch(e);if(u===void 0)return _R();z3e(e,o);j3e(e,o);let d=t.DSH_EDGE_INSTANCE.getByName(U3e);if(q3e(o.pathname)){let p=await d.fetch(await W3e(e,u.expiresAt));if(p.webSocket!==null)return p;let h=new Headers(p.headers);for(let[m,g]of Object.entries(Zo()))h.set(m,g);return new Response(p.body,{status:p.status,statusText:p.statusText,headers:h})}let f=_l(r,await Rp(d));if(o.pathname==="/api/workspace/file"){let p=B3e(o);if(e.method==="GET"){let h=await pR(f.fs,p);return new Response(h,{headers:{...Zo(),"content-type":"text/plain; charset=utf-8"}})}if(e.method==="PUT"){let h=await rf(e,kg,"Text files are limited to 1 MiB in the Edge API.");return await f.fs.mkdir(H3e(p),{recursive:!0}),await f.fs.writeFile(p,h),yn({ok:!0,path:p})}if(e.method==="DELETE")return await f.fs.rm(p,{recursive:!1}),yn({ok:!0,path:p})}if(e.method==="POST"&&o.pathname==="/api/workspace/exec"){let p=await nf(e,hR),h=Ag(p.command),m=tf(p.cwd??"/workspace"),g=ef(t.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,t.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS),y=await Ig(f,h,m,g);return yn({executionId:y.executionId,status:y.status,timedOut:y.timedOut,exitCode:y.exitCode,stdout:y.stdout,stderr:y.stderr,outputTruncated:y.outputTruncated})}throw new wt(404,"Route not found.")}catch(n){var i=n,s=!0}finally{Tl(r,i,s)}}catch(o){return await Tg(e),Cg(o)}}};function j3e(e,t){if(e.headers.has("x-dsh-edge-instance")||t.searchParams.has("instance"))throw new wt(400,"This deployment has one owner workspace; instance selectors are not supported.")}l(j3e,"rejectLegacyInstanceSelector");function z3e(e,t){let r=e.headers.get("origin");if(r!==null&&r!==t.origin)throw new wt(403,"Cross-origin authenticated requests are not allowed.")}l(z3e,"rejectCrossOriginAuthenticatedRequest");function B3e(e){return tf(e.searchParams.get("path"))}l(B3e,"resolveWorkspacePath");async function W3e(e,t){let r=new Headers(e.headers);if(r.delete("cookie"),r.delete("authorization"),r.delete("x-dsh-edge-instance"),r.set(Og,String(t)),e.body===null)return new Request(e,{headers:r});let n=new URL(e.url),i=n.pathname.endsWith("/turn")||n.pathname==="/api/session.prompt"||n.pathname==="/api/session.updateQueue"?_g:$g,s=await ik(e,i,`Session request bodies are limited to ${i} bytes.`);return new Request(e.url,{method:e.method,headers:r,body:s})}l(W3e,"requestForInstance");function q3e(e){return e.startsWith("/api/")&&e!=="/api/health"&&e!=="/api/workspace/file"&&e!=="/api/workspace/exec"}l(q3e,"isInstanceApiPath");function H3e(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}l(H3e,"parentDirectory");export{w8 as DshEdgeInstance,see as WorkspaceProxy,oee as WorkspaceServiceProxy,Mze as default};
|
|
2359
|
+
`}l(y3e,"edgeAgentPresetContent");function Pn(e){return JSON.stringify(e)}l(Pn,"yamlString");function v3e(e){let r="";for(let n=0;n<e.byteLength;n+=32768)r+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(r)}l(v3e,"bytesToBase64");function w3e(e,t){return{sessionId:t.id,updatedAt:t.updatedAt,running:e.isRunning(t.id),blank:t.blank,...t.parentSessionId===void 0?{}:{parentSessionId:t.parentSessionId},...t.origin===void 0?{}:{origin:t.origin},...t.cwd===void 0?{}:{cwd:t.cwd},...t.agentPreset===void 0?{}:{agentPreset:t.agentPreset},projections:rY(t,e.imageLimits)}}l(w3e,"sessionSummary");function rY(e,t){return{asOfSeq:e.lastSeq,values:{sessionListMetadata:{blank:e.blank,lastPromptAt:e.lastPromptAt},...e.title===null?{}:{title:e.title},...t===void 0?{}:{imageLimits:t}}}}l(rY,"summaryProjections");function b3e(e){if(e===void 0)return;let t=/^[A-Za-z][A-Za-z0-9_+.-]*(?:\/[A-Za-z0-9_+.-]+)+$/;if(!(e.length===0||e.trim()!==e||e!=="UTC"&&!t.test(e)))try{let r=new Intl.DateTimeFormat("en-US",{timeZone:e}).resolvedOptions().timeZone;return r==="UTC"||t.test(r)?r:void 0}catch{return}}l(b3e,"canonicalClientTimeZone");function pp(e,t,r,n,i,s){if(t instanceof yo){if(t.code==="NOT_FOUND"&&r!==void 0)return At(e,{code:"workspace-not-found",message:t.message,details:{workspaceId:r}});if(t.code==="INVALID_PATH")return At(e,{code:"workspace-invalid-path",message:t.message,details:{path:s??Mi}});if(t.code==="MOVE_INVALID"&&r!==void 0&&n!==void 0)return At(e,{code:"workspace-move-invalid",message:t.message,details:{workspaceId:r,sessionId:n,...i===void 0?{}:{beforeSessionId:i}}})}return At(e,{code:"internal",message:t instanceof Error?t.message:String(t),details:{}})}l(pp,"workspaceFailure");async function iy(e,t,r,n){try{await n();return}catch(i){return{code:"workspace-attach-failed",message:`Session "${e}" was ${r} but could not attach to workspace "${t}": ${String(i)}`,details:{sessionId:e,workspaceId:t}}}}l(iy,"attachPublishedSession");function zt(e,t){return{rpcId:e.rpcId,result:{ok:!0,value:t}}}l(zt,"ok");function At(e,t){return{rpcId:e.rpcId,result:{ok:!1,error:t}}}l(At,"fail");function tn(e){return Promise.resolve(At(e,{code:"internal",message:"This capability is not available in the Edge runtime.",details:{}}))}l(tn,"unsupported");function x3e(e){try{let t=new URL(e);return t.username.length>0||t.password.length>0||t.search.length>0||t.hash.length>0?(t.username="",t.password="",t.search="",t.hash="",t.href):e}catch{return e}}l(x3e,"sanitizeProjectedURL");function vo(e,t,r){if(t instanceof dt){if(t.code==="NOT_FOUND"&&r!==void 0)return At(e,{code:"session-not-found",message:t.message,details:{sessionId:r}});if(t.code==="BUSY")return At(e,{code:"agent-busy",message:t.message,details:{reason:"running"}});if(t.code==="FORK_UNAVAILABLE"&&r!==void 0)return At(e,{code:"fork-unavailable",message:t.message,details:{sessionId:r}});if(t.code==="TITLE_INVALID"&&r!==void 0)return At(e,{code:"title-invalid",message:t.message,details:{sessionId:r}})}return At(e,{code:"internal",message:t instanceof Error?t.message:String(t),details:{}})}l(vo,"sessionFailure");function ry(e){return{ns:e.ns,schema:e.schema,value:e.value,revision:e.revision,applies:e.applies,secrets:(e.secrets??[]).map(t=>({path:t.path,set:t.set})),...e.base===void 0?{}:{base:e.base},...e.user===void 0?{}:{user:e.user}}}l(ry,"descriptorToView");function g8(e,t){return At(e,{code:"settings-rejected",message:`Settings namespace "${t}" is not registered.`,details:{ns:t}})}l(g8,"settingsNotRegistered");function y8(e,t){let r=e.payload.ns;return t instanceof Bu?At(e,{code:"settings-conflict",message:t.message,details:{ns:r,expected:t.expected,actual:t.actual}}):At(e,{code:"settings-rejected",message:t instanceof Error?t.message:String(t),details:{ns:r}})}l(y8,"settingsWriteFailure");async function*QK(){}l(QK,"emptyFrames");var E3e="/api/commands/list";async function nY(e){if(new URL(e.url).pathname!==E3e)return;if(e.method!=="POST")return new Response("method not allowed",{status:405,headers:{allow:"POST"}});if(e.headers.get("content-type")?.split(";",1).at(0)?.trim()!=="application/json")return new Response("expected application/json",{status:415});let r;try{r=await e.json()}catch{return new Response("invalid JSON body",{status:400})}let n=Fm.safeParse(r);if(!n.success||n.data.method!=="commands/list")return new Response("request path and method do not match",{status:400});let i={type:"server-response",rpcId:n.data.rpcId,result:{ok:!0,value:[]}};return Response.json(i)}l(nY,"handleEdgeRemote");var k3e=160,A3e=640,uY=128,I3e=50,iY=100,$3e=128,sY=256,oY=1048576,_3e={blank:!0,lastPromptAt:null},aY=1008,lY="owner session expired";function T3e(e,t){let r=e.blank&&t.type!=="turn/start",n=t.type==="user/message"&&t.data.source.kind==="user"?t.time:e.lastPromptAt;return r===e.blank&&n===e.lastPromptAt?e:{blank:r,lastPromptAt:n}}l(T3e,"applySessionListMetadata");var v8=class extends S3e{static{l(this,"DshEdgeObjectBase")}workspaceOptions(){let t=this.env.LOADER===void 0?new Q0:new cV({loader:this.env.LOADER,workspace:{binding:"DSH_EDGE_INSTANCE",id:this.ctx.id.toString()},ctx:this.ctx});return{storage:this.ctx.storage,backends:[t]}}},C3e=O$(v8,e=>e.workspaceOptions()),w8=class extends C3e{static{l(this,"DshEdgeInstance")}attachmentStorage=AO(this.ctx.storage,this.env.DSH_EDGE_ATTACHMENTS);sessions=new Eg(this.ctx.storage,{readDeepSeekApiKey:l(()=>this.env.DEEPSEEK_API_KEY,"readDeepSeekApiKey"),attachmentStorage:this.attachmentStorage,...this.env.DEEPSEEK_SEARCH_BASE_URL===void 0?{}:{searchBaseURL:this.env.DEEPSEEK_SEARCH_BASE_URL},...this.env.DSH_EDGE_ATTACHMENTS===void 0?{}:{attachmentBucket:this.env.DSH_EDGE_ATTACHMENTS},...this.env.DEEPSEEK_BASE_URL===void 0?{}:{baseURL:this.env.DEEPSEEK_BASE_URL},...this.env.DEEPSEEK_MAX_OUTPUT_TOKENS===void 0?{}:{maxTokens:this.env.DEEPSEEK_MAX_OUTPUT_TOKENS},...this.env.DEEPSEEK_REASONING_EFFORT===void 0?{}:{reasoningEffort:this.env.DEEPSEEK_REASONING_EFFORT},...this.env.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS===void 0?{}:{streamIdleTimeoutMs:this.env.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS}});workspaces=new ty(this.ctx.storage);model=sf(this.env.DEEPSEEK_MODEL);activeTurns=new Map;sessionListMetadata=new Map;api=tY({sessions:this.sessions,model:this.model,version:Ng,imageLimits:this.attachmentStorage==="temporary-do"?k6:cg,deploymentProfile:l(()=>pk(this.env,this.attachmentStorage),"deploymentProfile"),describeCredential:l(t=>this.sessions.describeCredential(t),"describeCredential"),setCredential:l((t,r)=>this.sessions.setCredential(t,r),"setCredential"),unsetCredential:l(t=>this.sessions.unsetCredential(t),"unsetCredential"),settingsWritable:l(()=>this.sessions.settingsWritable(),"settingsWritable"),settingsHasDocument:l(()=>this.sessions.settingsHasDocument(),"settingsHasDocument"),describeSettings:l(()=>this.sessions.describeSettings(),"describeSettings"),updateSettings:l((t,r,n)=>this.sessions.updateSettings(t,r,n),"updateSettings"),replaceSettings:l((t,r,n)=>this.sessions.replaceSettings(t,r,n),"replaceSettings"),mutateSettings:l((t,r,n)=>this.sessions.mutateSettings(t,r,n),"mutateSettings"),listConfigurableProviders:l(()=>this.sessions.listConfigurableProviders(),"listConfigurableProviders"),listLlmProviders:l(()=>this.sessions.listLlmProviders(),"listLlmProviders"),isRunning:l(t=>this.activeTurns.has(t),"isRunning"),prompt:l(t=>this.startApiPrompt(t),"prompt"),updateQueue:l((t,r,n)=>this.updateQueue(t,r,n),"updateQueue"),cancel:l(t=>this.requestTurnCancellation(t),"cancel"),workspaceList:l(t=>this.workspaces.list(t),"workspaceList"),workspaceCreate:l(t=>this.createWorkspace(t),"workspaceCreate"),workspaceRename:l((t,r)=>this.renameWorkspace(t,r),"workspaceRename"),workspaceDelete:l(t=>this.deleteWorkspace(t),"workspaceDelete"),workspaceInsertBefore:l((t,r)=>this.workspaces.insertBefore(t,r),"workspaceInsertBefore"),workspaceInsertSessionBefore:l((t,r,n)=>this.insertSessionBefore(t,r,n),"workspaceInsertSessionBefore"),archiveSession:l(t=>this.archiveSession(t),"archiveSession"),sessionCreated:l(t=>{this.publishSessionCreated(t)},"sessionCreated"),sessionAttached:l((t,r)=>this.publishSessionAttached(t,r),"sessionAttached"),workspaceForSession:l(t=>this.workspaceForSession(t),"workspaceForSession"),sessionEvent:l((t,r)=>{this.publishSessionEvent(t,r)},"sessionEvent")});apiFetch=YK(this.api).fetch;async fetch(t){try{let r=new URL(t.url),n=await nY(t);if(n!==void 0)return n;if(r.pathname==="/api/events.mux"||r.pathname==="/api/events.host")return await this.openDownlink(t,r.pathname==="/api/events.mux"?"mux":"host");if(r.pathname.startsWith("/api/")&&!r.pathname.startsWith("/api/sessions"))return await this.apiFetch(t);let i=D3e(r.pathname);if(i.sessionId===void 0){if(t.method==="POST")return await this.createSession(t);if(t.method==="GET"){let s=M3e(r),o=F3e(r),a=await this.sessions.listSessions(s,o);if(a===void 0)throw new wt(400,"Unknown session list cursor.");return yn({sessions:a.sessions.map(c=>this.presentSession(c)),hasMore:a.hasMore,...a.nextAfter===void 0?{}:{nextAfter:a.nextAfter}})}}else if(i.action===void 0){if(t.method==="GET"){let s=await this.sessions.getSession(i.sessionId);if(s===void 0)throw new wt(404,"Session not found.");return yn({session:this.presentSession(s)})}}else{if(i.action==="events"&&t.method==="GET")return await this.replayEvents(t,r,i.sessionId);if(i.action==="turn"&&t.method==="POST")return await this.startTurn(t,i.sessionId);if(i.action==="cancel"&&t.method==="POST")return this.cancelTurn(i.sessionId)}throw new wt(404,"Session route not found.")}catch(r){return await Tg(t),Cg(r)}}webSocketMessage(t,r){this.closeExpiredDownlink(t,Date.now())||t.close(1008,"downlink only")}webSocketError(t,r){console.error("dsh-edge downstream WebSocket failed.",r),t.close(1011,"downstream failure")}async alarm(){let t=this.closeExpiredDownlinks();t!==void 0&&await this.ctx.storage.setAlarm(t)}async openDownlink(t,r){if(t.headers.get("upgrade")?.toLowerCase()!=="websocket")throw new wt(426,"This event endpoint requires a WebSocket upgrade.");let n=R3e(t);await this.scheduleDownlinkExpiry(n*1e3);let i=l(s=>{let o=new WebSocketPair,a=o[0],c=o[1];if(c.serializeAttachment({channel:r,expiresAt:n}),this.ctx.acceptWebSocket(c,[r]),s!==void 0){for(let u of s.sessions)if(this.rememberSessionListMetadata(u),!this.sendFrame(c,{type:"session/subscribed",sessionId:u.id,lastSeq:u.lastSeq}))break;for(let u of s.queues)if(!this.sendFrame(c,{type:"session/queue",sessionId:u.sessionId,items:u.items}))break}return new Response(null,{status:101,webSocket:a})},"accept");return r==="mux"?this.sessions.withMuxBaseline(i):i()}publishSessionCreated(t){this.rememberSessionListMetadata(t),this.broadcast("mux",{type:"session/subscribed",sessionId:t.id,lastSeq:t.lastSeq}),this.broadcast("host",{type:"host/session-added",sessionId:t.id,blank:t.blank,...t.parentSessionId===void 0?{}:{parentSessionId:t.parentSessionId},...t.origin===void 0?{}:{origin:t.origin},...t.cwd===void 0?{}:{cwd:t.cwd},...t.agentPreset===void 0?{}:{agentPreset:t.agentPreset}})}async publishSessionAttached(t,r){let n=await this.workspaces.attachSession(r,t.id,await this.sessions.listApiSessions());this.broadcast("host",{type:"host/workspace-changed",workspace:n})}async workspaceForSession(t){return await this.workspaces.workspaceForSession(t,await this.sessions.listApiSessions())}async createWorkspace(t){let r=await this.workspaces.create(t,await this.sessions.listApiSessions());return r.created&&this.broadcast("host",{type:"host/workspace-changed",workspace:r.workspace}),r}async renameWorkspace(t,r){let n=await this.workspaces.rename(t,r,await this.sessions.listApiSessions());return n.changed&&this.broadcast("host",{type:"host/workspace-changed",workspace:n.workspace}),n.workspace}async deleteWorkspace(t){await this.workspaces.delete(t),this.broadcast("host",{type:"host/workspace-removed",workspaceId:t})}async insertSessionBefore(t,r,n){let i=await this.workspaces.insertSessionBefore(t,r,n,await this.sessions.listApiSessions());return i.changed&&this.broadcast("host",{type:"host/workspace-changed",workspace:i.workspace}),i.workspace}async archiveSession(t){let r=await this.workspaces.archiveSession(t,()=>this.sessions.requireSession(t));return r.changed&&this.broadcast("host",{type:"host/archived-sessions-changed",archivedSessionIds:r.archivedSessionIds}),r.archivedSessionIds}publishSessionEvent(t,r){this.broadcast("mux",{type:"session/event",sessionId:t,event:r}),r.type==="session/title"&&this.broadcast("mux",{type:"session/projection",sessionId:t,key:"title",value:r.data.title,seq:r.seq});let n=this.sessionListMetadata.get(t)??_3e,i=T3e(n,r);i!==n&&(this.sessionListMetadata.set(t,i),this.broadcast("mux",{type:"session/projection",sessionId:t,key:"sessionListMetadata",value:i,seq:r.seq}))}rememberSessionListMetadata(t){this.sessionListMetadata.set(t.id,{blank:t.blank,lastPromptAt:t.lastPromptAt})}publishSessionQueue(t,r){this.broadcast("mux",{type:"session/queue",sessionId:t,items:r})}publishRunning(t,r){this.broadcast("host",{type:"host/session-status",sessionId:t,running:r})}publishAgentError(t,r){this.broadcast("host",{type:"host/agent-error",sessionId:t,message:r instanceof Error?r.message:String(r)})}broadcast(t,r){let n=Date.now();for(let i of this.ctx.getWebSockets(t))if(i.readyState===WebSocket.OPEN&&!this.closeExpiredDownlink(i,n))try{this.sendFrame(i,r)}catch(s){console.error(`dsh-edge failed to publish ${r.type}.`,s),i.close(1011,"downstream send failed")}}sendFrame(t,r){if(this.closeExpiredDownlink(t,Date.now()))return!1;let n={type:"server-request",rpcId:crypto.randomUUID(),method:r.type,payload:r};return t.send(JSON.stringify(n)),!0}closeExpiredDownlinks(t=Date.now()){let r;for(let n of this.ctx.getWebSockets()){let i=cY(n);if(i===void 0||i.expiresAt*1e3<=t){n.close(aY,lY);continue}let s=i.expiresAt*1e3;r=r===void 0?s:Math.min(r,s)}return r}closeExpiredDownlink(t,r){let n=cY(t);return n!==void 0&&n.expiresAt*1e3>r?!1:(t.close(aY,lY),!0)}async scheduleDownlinkExpiry(t){let r=await this.ctx.storage.getAlarm();(r===null||t<r)&&await this.ctx.storage.setAlarm(t)}async createSession(t){let r=await nf(t,$g),n=Wo(mR(r.title,"title",k3e),A3e);if(n.length===0)throw new wt(400,"Session title must contain visible text.");let i=await this.sessions.createSession({title:n}),s=this.presentSession(i),o=await iy(i.id,un,"created",async()=>{let a=(await this.sessions.listApiSessions()).find(u=>u.id===i.id);if(a===void 0)throw new Error(`Session "${i.id}" is missing from its post-creation summary.`);this.publishSessionCreated(a),(await this.workspaces.list(await this.sessions.listApiSessions())).items.some(u=>u.workspaceId===un)&&await this.publishSessionAttached(a,un)});return o!==void 0?yn({ok:!1,error:o.message,code:o.code,details:o.details,session:s},500):yn({session:s},201)}async replayEvents(t,r,n){let i=L3e(t,r),s=U3e(r),o=await this.sessions.readEventPage(n,i+1,s,oY),a=[],c=0,u=o.hasMore;if(o.events.length===0&&o.hasMore)throw new wt(413,"The next session event exceeds the replay response limit.");for(let h of o.events){let m=h8(h);if(c+m.byteLength>oY){if(a.length===0)throw new wt(413,"The next session event exceeds the replay response limit.");u=!0;break}a.push(m),c+=m.byteLength}let d=new ReadableStream({start(h){for(let m of a)h.enqueue(m);h.close()}}),f=o.events[a.length-1]?.seq??i,p=m8(Zo());return p.set("x-dsh-edge-has-more",String(u)),p.set("x-dsh-edge-next-after",String(f)),new Response(d,{headers:p})}async startTurn(t,r){let n=await nf(t,_g),i=gR(n.message,"message",pa),{commandTimeoutPolicy:s}=Rg(this.env),o=await this.claimTurn(r),{stream:a,completion:c}=JK(u=>this.runClaimedTurn({claimed:o,commandTimeoutPolicy:s,mode:"queue",content:[{type:"text",text:i}],publish:u}),u=>{console.error("dsh-edge turn transport failed.",u)});return this.ctx.waitUntil(c.catch(()=>{})),new Response(a,{status:200,headers:m8(Zo())})}async startApiPrompt(t){if(ny(t.content.filter(r=>r.type==="text"))>pa)throw new wt(413,`Prompt text is limited to ${pa} UTF-8 bytes.`);for(;;){let r=this.activeTurns.get(t.sessionId);if(r!==void 0){if(await r.admissionReady,this.activeTurns.get(t.sessionId)===r&&r.accepting&&r.admit!==void 0){await r.admit({mode:t.mode,content:t.content,rpcId:t.rpcId,...t.clientTimeZone===void 0?{}:{clientTimeZone:t.clientTimeZone}});return}await r.releaseComplete;continue}let{commandTimeoutPolicy:n}=Rg(this.env),i;try{i=await this.claimTurn(t.sessionId)}catch(o){if(o instanceof dt&&o.code==="BUSY")continue;throw o}let s=this.runClaimedTurn({claimed:i,commandTimeoutPolicy:n,mode:t.mode,content:t.content,rpcId:t.rpcId,...t.clientTimeZone===void 0?{}:{clientTimeZone:t.clientTimeZone}});this.ctx.waitUntil(s.catch(o=>{console.error("dsh-edge upstream protocol turn failed.",o)})),await i.turn.admissionReady,i.turn.wasAdmitted||await s;return}}updateQueue(t,r,n){let s=this.activeTurns.get(t)?.agent;if(s===void 0)return"queue-item-not-found";let o=s.inbox.nextTurn.some(c=>c.id===r)?"next-turn":s.inbox.nextStep.some(c=>c.id===r)?"next-step":void 0,a=o===void 0?void 0:(o==="next-turn"?s.inbox.nextTurn:s.inbox.nextStep).find(c=>c.id===r);if(o===void 0||a===void 0)return"queue-item-not-found";if(n.kind==="steer"&&(o!=="next-turn"||s.status!=="running"))return"steer-unavailable";if(n.kind==="edit"){if(!O3e(a.content,n.content))return"queue-edit-attachment-invalid";s.inbox.replace(r,Io({...a,content:n.content}))}else s.inbox.remove(r),n.kind==="steer"&&s.steer(a);return"accepted"}async claimTurn(t){let r=await this.sessions.getApiSessionSummary(t);if(this.activeTurns.has(t))throw new dt("BUSY","The session already has a running turn.");this.rememberSessionListMetadata(r);let n={turnId:crypto.randomUUID(),cancelRequested:!1,accepting:!1,wasAdmitted:!1,...P3e()};this.activeTurns.set(t,n);try{let i=await this.sessions.openAgentForTurn(t,this.model);return n.agent=i.agent,{sessionId:t,turn:n,handle:i}}catch(i){throw this.activeTurns.delete(t),n.resolveAdmissionReady(),n.resolveReleaseComplete(),i}}async runClaimedTurn(t){let{sessionId:r,turn:n,handle:i}=t.claimed;try{await this.runTurn({...t,agent:i.agent,turn:n,onAdmitted:l(s=>{n.admit=s,n.accepting=!0,n.wasAdmitted=!0,this.publishRunning(r,!0),n.resolveAdmissionReady()},"onAdmitted"),onClosing:l(()=>{n.accepting=!1},"onClosing"),publish:l(async s=>{this.publishSessionEvent(r,s),await t.publish?.(s)},"publish"),publishQueue:l(s=>{this.publishSessionQueue(r,s)},"publishQueue")})}catch(s){throw this.publishAgentError(r,s),s}finally{n.accepting=!1,n.resolveAdmissionReady(),await i.dispose().catch(o=>{console.error("dsh-edge failed to release the turn agent.",o)}),this.activeTurns.get(r)?.turnId===n.turnId&&this.activeTurns.delete(r),n.resolveReleaseComplete(),this.publishRunning(r,!1)}}async runTurn(t){var n=[];try{let r=_l(n,await Rp(this));await this.sessions.runAgentTurn({agent:t.agent,mode:t.mode,content:t.content,...t.rpcId===void 0?{}:{rpcId:t.rpcId},...t.clientTimeZone===void 0?{}:{clientTimeZone:t.clientTimeZone},shell:{exec:l(async(a,c)=>Ig(r,Ag(a),tf(c.cwd),t.commandTimeoutPolicy,c.timeoutMs,c.signal),"exec")},afterFollowup:l(()=>{t.turn.cancelRequested&&t.agent.cancel({kind:"user"})},"afterFollowup"),...t.onAdmitted===void 0?{}:{onAdmitted:t.onAdmitted},...t.onClosing===void 0?{}:{onClosing:t.onClosing},publish:t.publish,publishQueue:t.publishQueue})}catch(i){var s=i,o=!0}finally{Tl(n,s,o)}}cancelTurn(t){let r=this.activeTurns.get(t);if(r===void 0||!this.requestTurnCancellation(t))throw new wt(409,"The session has no active turn in this Worker instance.");let n={ok:!0,sessionId:t,turnId:r.turnId};return yn(n,202)}requestTurnCancellation(t){let r=this.activeTurns.get(t);return r===void 0?!1:(r.cancelRequested=!0,r.agent?.cancel({kind:"user"}),!0)}presentSession(t){return{...t,status:this.activeTurns.has(t.id)?"running":"idle"}}};function O3e(e,t){let r=e.flatMap(n=>n.type==="image"?[n.attachment]:[]);for(let n of t){if(n.type==="text")continue;if(n.type!=="image")return!1;let i=r.findIndex(s=>N3e(s,n.attachment));if(i<0)return!1;r.splice(i,1)}return!0}l(O3e,"preservesAdmittedQueueImages");function N3e(e,t){return e.attachmentId===t.attachmentId&&e.mediaType===t.mediaType&&e.bytes===t.bytes&&e.width===t.width&&e.height===t.height&&e.name===t.name}l(N3e,"sameImageRef");function R3e(e){let t=e.headers.get(Og);if(t===null||!/^\d{10}$/u.test(t))throw new wt(401,"Owner authentication required.");let r=Number(t);if(!Number.isSafeInteger(r)||r*1e3<=Date.now())throw new wt(401,"Owner authentication required.");return r}l(R3e,"requireOwnerSessionExpiry");function cY(e){try{let t=e.deserializeAttachment();if(typeof t!="object"||t===null)return;let{channel:r,expiresAt:n}=t;return r!=="mux"&&r!=="host"||typeof n!="number"||!Number.isSafeInteger(n)?void 0:{channel:r,expiresAt:n}}catch{return}}l(cY,"readDownlinkAttachment");function P3e(){let e=Promise.withResolvers(),t=Promise.withResolvers();return{admissionReady:e.promise,releaseComplete:t.promise,resolveAdmissionReady:e.resolve,resolveReleaseComplete:t.resolve}}l(P3e,"activeTurnSignals");function D3e(e){let t=e.split("/").filter(Boolean);if(t[0]!=="api"||t[1]!=="sessions"||t.length>4)throw new wt(404,"Session route not found.");if(t.length===2)return{};let r;try{r=decodeURIComponent(t[2]??"")}catch{throw new wt(400,"Invalid session id.")}if(r.length===0||r.length>uY)throw new wt(400,"Invalid session id.");let n=r;if(t.length===3)return{sessionId:n};let i=t[3];if(i!=="events"&&i!=="turn"&&i!=="cancel")throw new wt(404,"Session route not found.");return{sessionId:n,action:i}}l(D3e,"parseSessionRoute");function L3e(e,t){let r=t.searchParams.get("after")??e.headers.get("last-event-id")??"-1";if(!/^-?\d+$/.test(r))throw new wt(400,"after must be an integer.");let n=Number(r);if(!Number.isSafeInteger(n)||n<-1||n>=Number.MAX_SAFE_INTEGER)throw new wt(400,"after exceeds the supported integer range.");return n}l(L3e,"resolveAfterSequence");function M3e(e){let t=e.searchParams.get("after");if(t!==null){if(t.length===0||t.length>uY)throw new wt(400,"Invalid session list cursor.");return t}}l(M3e,"resolveSessionListAfter");function F3e(e){let t=e.searchParams.get("limit");if(t===null)return I3e;if(!/^\d+$/.test(t))throw new wt(400,"limit must be a positive integer.");let r=Number(t);if(!Number.isSafeInteger(r)||r<=0||r>iY)throw new wt(400,`limit must be between 1 and ${iY}.`);return r}l(F3e,"resolveSessionListLimit");function U3e(e){let t=e.searchParams.get("limit");if(t===null)return $3e;if(!/^\d+$/.test(t))throw new wt(400,"limit must be a positive integer.");let r=Number(t);if(!Number.isSafeInteger(r)||r<=0||r>sY)throw new wt(400,`limit must be between 1 and ${sY}.`);return r}l(U3e,"resolveReplayLimit");var j3e="owner",Fze={async fetch(e,t){if(e.method==="OPTIONS")return new Response(null,{status:204,headers:Zo()});try{var r=[];try{let o=new URL(e.url);let a=AR(t.DSH_EDGE_ACCESS_KEY);if(e.method==="GET"&&o.pathname==="/api/health")return yn(RR(t));let c=await IR(e,a);if(c!==void 0)return c;let u=await ok(e,a);if(o.pathname==="/")return u===void 0?$R():await t.ASSETS.fetch(e);if(u===void 0)return _R();B3e(e,o);z3e(e,o);let d=t.DSH_EDGE_INSTANCE.getByName(j3e);if(H3e(o.pathname)){let p=await d.fetch(await q3e(e,u.expiresAt));if(p.webSocket!==null)return p;let h=new Headers(p.headers);for(let[m,g]of Object.entries(Zo()))h.set(m,g);return new Response(p.body,{status:p.status,statusText:p.statusText,headers:h})}let f=_l(r,await Rp(d));if(o.pathname==="/api/workspace/file"){let p=W3e(o);if(e.method==="GET"){let h=await pR(f.fs,p);return new Response(h,{headers:{...Zo(),"content-type":"text/plain; charset=utf-8"}})}if(e.method==="PUT"){let h=await rf(e,kg,"Text files are limited to 1 MiB in the Edge API.");return await f.fs.mkdir(G3e(p),{recursive:!0}),await f.fs.writeFile(p,h),yn({ok:!0,path:p})}if(e.method==="DELETE")return await f.fs.rm(p,{recursive:!1}),yn({ok:!0,path:p})}if(e.method==="POST"&&o.pathname==="/api/workspace/exec"){let p=await nf(e,hR),h=Ag(p.command),m=tf(p.cwd??"/workspace"),g=ef(t.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,t.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS),y=await Ig(f,h,m,g);return yn({executionId:y.executionId,status:y.status,timedOut:y.timedOut,exitCode:y.exitCode,stdout:y.stdout,stderr:y.stderr,outputTruncated:y.outputTruncated})}throw new wt(404,"Route not found.")}catch(n){var i=n,s=!0}finally{Tl(r,i,s)}}catch(o){return await Tg(e),Cg(o)}}};function z3e(e,t){if(e.headers.has("x-dsh-edge-instance")||t.searchParams.has("instance"))throw new wt(400,"This deployment has one owner workspace; instance selectors are not supported.")}l(z3e,"rejectLegacyInstanceSelector");function B3e(e,t){let r=e.headers.get("origin");if(r!==null&&r!==t.origin)throw new wt(403,"Cross-origin authenticated requests are not allowed.")}l(B3e,"rejectCrossOriginAuthenticatedRequest");function W3e(e){return tf(e.searchParams.get("path"))}l(W3e,"resolveWorkspacePath");async function q3e(e,t){let r=new Headers(e.headers);if(r.delete("cookie"),r.delete("authorization"),r.delete("x-dsh-edge-instance"),r.set(Og,String(t)),e.body===null)return new Request(e,{headers:r});let n=new URL(e.url),i=n.pathname.endsWith("/turn")||n.pathname==="/api/session.prompt"||n.pathname==="/api/session.updateQueue"?_g:$g,s=await ik(e,i,`Session request bodies are limited to ${i} bytes.`);return new Request(e.url,{method:e.method,headers:r,body:s})}l(q3e,"requestForInstance");function H3e(e){return e.startsWith("/api/")&&e!=="/api/health"&&e!=="/api/workspace/file"&&e!=="/api/workspace/exec"}l(H3e,"isInstanceApiPath");function G3e(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}l(G3e,"parentDirectory");export{w8 as DshEdgeInstance,see as WorkspaceProxy,oee as WorkspaceServiceProxy,Fze as default};
|
|
2360
2360
|
/*! Bundled license information:
|
|
2361
2361
|
|
|
2362
2362
|
just-bash/dist/bundle/browser.js:
|