@jutge.org/toolkit 4.2.36 → 4.2.37
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/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -379,12 +379,12 @@ __pycache__/
|
|
|
379
379
|
`){let $="";for(let h of l)$+=await r2(F_(f,h))+c;await w4(F_(f,v),$)}}class QH extends w3{id(){return"GCC"}name(){return"GNU C Compiler"}type(){return"compiler"}language(){return"C"}async version(){return await this.getVersion("gcc --version",0)}flags1(){return"-D_JUDGE_ -O2 -DNDEBUG -Wall -Wextra -Wno-sign-compare"}flags2(){return""}tool(){return"gcc"}extension(){return"c"}}class sH extends w3{id(){return"GXX"}name(){return"GNU C++ Compiler"}type(){return"compiler"}language(){return"C++"}async version(){return await this.getVersion("g++ --version",0)}flags1(){return"-std=c++17 -D_JUDGE_ -O2 -DNDEBUG -Wall -Wextra -Wno-sign-compare -Wshadow"}flags2(){return"-std=c++17 -D_JUDGE_ -O2 -DNDEBUG -Wall -Wextra -Wno-sign-compare -Wshadow"}tool(){return"g++"}extension(){return"cc"}}import{join as og}from"path";class fm extends w3{id(){return"Python3"}name(){return"Python3"}type(){return"interpreter"}language(){return"Python"}async version(){return await this.getVersion("python3 --version",0)}flags1(){return""}flags2(){return""}tool(){return"python3"}extension(){return"py"}async compileNormal(f,l,v){let c=await r2(og(l,v));W.command(`tweak ${v} for turtle compatibility`);let $=c.replace("import turtle","import turtle_pil as turtle").replace("from turtle import","from turtle_pil import");await w4(og(l,v),$),W.command(`python3 -m py_compile ${v}`);let{exitCode:h}=await R1({reject:!1,stderr:"inherit",stdout:"inherit",cwd:l})`python3 -m py_compile ${v}`;if(h!==0)throw Error(`Compilation failed for ${v}`);return v}async compileWithMain(f,l,v){W.command(`add main.${this.extension()} to ${v}`),await this.concatText(l,[v,`main.${this.extension()}`],v),W.command(`python3 -m py_compile ${v}`);let{exitCode:c}=await R1({reject:!1,stderr:"inherit",stdout:"inherit",cwd:l})`python3 -m py_compile ${v}`;if(c!==0)throw Error(`Compilation failed for ${v}`);return v}async execute(f,l,v,c,$){let h=v;await this.rmInDir(l,$);let Z=await this.getInput(l,c);W.command(`python3 ${h} < ${c} > ${$}`);let{exitCode:w}=await R1({reject:!1,input:Z,stdout:{file:og(l,$)},stderr:"inherit",cwd:l})`python3 ${h}`;if(w!==0)throw Error(`Execution failed for ${h}`)}}class _m extends w3{id(){return"GHC"}name(){return"GHC"}type(){return"compiler"}language(){return"Haskell"}async version(){return await this.getVersion("ghc --version",0)}flags1(){return"-O3"}flags2(){return"-O3"}tool(){return"ghc"}extension(){return"hs"}}import{join as Mi2}from"path";class lm extends w3{id(){return"Clojure"}name(){return"Clojure"}type(){return"vm"}language(){return"Clojure"}async version(){return await this.getVersion("clj --version",0)}flags1(){return""}flags2(){return""}tool(){return"clj"}extension(){return"clj"}async compileNormal(f,l,v){return await o2(),v}async compileWithMain(f,l,v){return W.command(`add main.${this.extension()} to ${v}`),await this.concatText(l,[v,`main.${this.extension()}`],v),W.warning("No compilation available for Clojure"),v}async execute(f,l,v,c,$){let h=`${c3()}-${v}`;await this.rmInDir(l,$);let Z=await this.getInput(l,c);W.command(`clj -M ${v} < ${c} > ${$}`);let{exitCode:w}=await R1({reject:!1,input:Z,stdout:{file:Mi2(l,$)},stderr:"inherit",cwd:l})`clj -M ${v}`;if(w!==0)throw Error(`Execution failed for ${v}`)}}import{join as Hi2}from"path";class vm extends w3{id(){return"Java"}name(){return"Java"}type(){return"vm"}language(){return"Java"}async version(){return await this.getVersion("javac --version",0)}flags1(){return""}flags2(){return""}tool(){return"javac"}extension(){return"java"}async compileNormal(f,l,v){return await this.rmInDir(l,"Main.class"),W.command(`${this.tool()} ${v}`),await R1({reject:!1,stderr:"inherit",stdout:"inherit",cwd:l})`${this.tool()} ${v}`,"Main.class"}async compileWithMain(f,l,v){return W.command(`add main.${this.extension()} to ${v}`),await this.concatText(l,[`main.${this.extension()}`,v],v),await this.rmInDir(l,"Main.class"),W.command(`${this.tool()} ${v}`),await R1({reject:!1,stderr:"inherit",stdout:"inherit",cwd:l})`${this.tool()} ${v}`,"Main.class"}async execute(f,l,v,c,$){let Z="Main.class";await this.rmInDir(l,$);let w=await this.getInput(l,c);W.command(`java Main < ${c} > ${$}`);let{exitCode:q}=await R1({reject:!1,input:w,stdout:{file:Hi2(l,$)},stderr:"inherit",cwd:l})`java ${"Main"}`;if(q!==0)throw Error(`Execution failed for ${Z}`)}}class cm extends w3{id(){return"Rust"}name(){return"Rust Compiler"}type(){return"compiler"}language(){return"Rust"}async version(){return await this.getVersion("rustc --version",0)}flags1(){return"-C opt-level=2 -D warnings"}flags2(){return"-C opt-level=2 -D warnings"}tool(){return"rustc"}extension(){return"rs"}}import{join as $m,parse as Dv1}from"path";class bg extends w3{id(){return"RunPython"}name(){return"RunPython"}type(){return"interpreter"}language(){return"Python"}async version(){return await this.getVersion("python3 --version",0)}flags1(){return""}flags2(){return""}tool(){return"python3"}extension(){return"py"}async compileNormal(f,l,v){W.command(`python3 -m py_compile ${v}`);let{exitCode:c}=await R1({reject:!1,stderr:"inherit",stdout:"inherit",cwd:l})`python3 -m py_compile ${v}`;if(c!==0)throw Error(`Compilation failed for ${v}`);return v}async compileWithMain(f,l,v){throw await o2(),Error("Method not implemented.")}async execute(f,l,v,c,$){let h=`${c3()}-${Dv1(v).name}-${Dv1(c).name}.py`;W.command(`merge ${v} ${c} > ${h}`),await this.mergeScripts(l,v,c,h),W.command(`python3 ${h} > ${$}`);let{exitCode:Z}=await R1({reject:!1,stdout:{file:$m(l,$)},stderr:"inherit",cwd:l})`python3 ${h}`;if(Z!==0)throw Error(`Execution failed for ${h}`)}async mergeScripts(f,l,v,c){let $=await r2($m(f,l)),h=await r2($m(f,v)),Z=$+`
|
|
380
380
|
|
|
381
381
|
|
|
382
|
-
`+h;await w4($m(f,c),Z)}}import{join as hm,parse as Jv1}from"path";class yg extends w3{id(){return"RunHaskell"}name(){return"RunHaskell"}type(){return"interpreter"}language(){return"Haskell"}async version(){return await this.getVersion("runhaskell --version",0)}flags1(){return""}flags2(){return""}tool(){return"ghc"}extension(){return"hs"}async compileNormal(f,l,v){W.command(`ghci -e ':q' ${v}`);let{exitCode:c}=await R1({reject:!1,stderr:"inherit",stdout:"inherit",cwd:l})`ghci -e :q ${v}`;if(c!==0)throw Error(`Compilation failed for ${v}`);return v}async compileWithMain(f,l,v){throw await o2(),Error("Method not implemented.")}async execute(f,l,v,c,$){let h=`${c3()}-${Jv1(v).name}-${Jv1(c).name}.hs`;W.command(`merge ${v} ${c} > ${h}`),await this.mergeScripts(l,v,c,h),W.command(`runhaskell ${h} > ${$}`);let{exitCode:Z}=await R1({reject:!1,stdout:{file:hm(l,$)},stderr:"inherit",cwd:l})`runhaskell ${h}`;if(Z!==0)throw Error(`Execution failed for ${h}`)}async mergeScripts(f,l,v,c){let $=await r2(hm(f,l)),h=await r2(hm(f,v)),Z=$;Z+=`
|
|
382
|
+
`+h;await w4($m(f,c),Z)}}import{join as hm,parse as Jv1}from"path";class yg extends w3{id(){return"RunHaskell"}name(){return"RunHaskell"}type(){return"interpreter"}language(){return"Haskell"}async version(){return await this.getVersion("runhaskell --version",0)}flags1(){return"-Wno-empty-enumerations -Wno-tabs -Wno-x-partial"}flags2(){return""}tool(){return"ghc"}extension(){return"hs"}async compileNormal(f,l,v){W.command(`ghci -e ':q' ${this.flags1()} ${v}`);let{exitCode:c}=await R1({reject:!1,stderr:"inherit",stdout:"inherit",cwd:l})`ghci -e :q ${this.flags1().split(" ")} ${v}`;if(c!==0)throw Error(`Compilation failed for ${v}`);return v}async compileWithMain(f,l,v){throw await o2(),Error("Method not implemented.")}async execute(f,l,v,c,$){let h=`${c3()}-${Jv1(v).name}-${Jv1(c).name}.hs`;W.command(`merge ${v} ${c} > ${h}`),await this.mergeScripts(l,v,c,h),W.command(`runhaskell ${this.flags1()} ${h} > ${$}`);let{exitCode:Z}=await R1({reject:!1,stdout:{file:hm(l,$)},stderr:"inherit",cwd:l})`runhaskell ${this.flags1().split(" ")} ${h}`;if(Z!==0)throw Error(`Execution failed for ${h}`)}async mergeScripts(f,l,v,c){let $=await r2(hm(f,l)),h=await r2(hm(f,v)),Z=$;Z+=`
|
|
383
383
|
|
|
384
384
|
|
|
385
385
|
main = do
|
|
386
|
-
`;for(let w of h.split(`
|
|
387
|
-
`))if(w.trim()==="")Z+=`
|
|
386
|
+
`;for(let w of h.trim().split(`
|
|
387
|
+
`))if(w.trim()==="")Z+=` print ()
|
|
388
388
|
`;else if(w.startsWith("let"))Z+=` ${w}
|
|
389
389
|
`;else Z+=` print $ ${w}
|
|
390
390
|
`;await w4(hm(f,c),Z)}}import{join as Zm,parse as Tv1}from"path";class Sg extends w3{id(){return"RunClojure"}name(){return"RunClojure"}type(){return"interpreter"}language(){return"Clojure"}async version(){return await this.getVersion("clj --version",0)}flags1(){return""}flags2(){return""}tool(){return"clj"}extension(){return"clj"}async compileNormal(f,l,v){return await o2(),W.warning("No compilation available for Clojure"),v}async compileWithMain(f,l,v){throw await o2(),Error("Method not implemented.")}async execute(f,l,v,c,$){let h=`${c3()}-${Tv1(v).name}-${Tv1(c).name}.clj`;W.command(`merge ${v} ${c} > ${h}`),await this.mergeScripts(l,v,c,h),W.command(`clj -M ${h} > ${$}`);let{exitCode:Z}=await R1({reject:!1,stdout:{file:Zm(l,$)},stderr:"inherit",cwd:l})`clj -M ${h}`;if(Z!==0)throw Error(`Execution failed for ${h}`)}async mergeScripts(f,l,v,c){let $=await r2(Zm(f,l)),h=await r2(Zm(f,v)),Z=$;Z+=`
|
|
@@ -619,7 +619,7 @@ tell application "System Events" to get value of property list item "CFBundleNam
|
|
|
619
619
|
*
|
|
620
620
|
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
|
|
621
621
|
* Copyright (c) 2024 Florian Körner
|
|
622
|
-
*/var $O={};r5($O,{schema:()=>BJ1,meta:()=>pr2,create:()=>Nr2});var bo={};r5(bo,{ringTwo:()=>SJ1,ringThree:()=>RJ1,ringOne:()=>yJ1,ringFour:()=>IJ1,ringFive:()=>xJ1,ring:()=>bJ1});var bJ1={container:(f,l)=>{var v,c,$,h,Z,w,q,u,P,a,M,m,O,z,T,n,X,k,r,E;return`${(c=(v=f.ringOne)===null||v===void 0?void 0:v.value(f,l))!==null&&c!==void 0?c:""}${(h=($=f.ringTwo)===null||$===void 0?void 0:$.value(f,l))!==null&&h!==void 0?h:""}${(w=(Z=f.ringThree)===null||Z===void 0?void 0:Z.value(f,l))!==null&&w!==void 0?w:""}${(u=(q=f.ringFour)===null||q===void 0?void 0:q.value(f,l))!==null&&u!==void 0?u:""}${(a=(P=f.ringFive)===null||P===void 0?void 0:P.value(f,l))!==null&&a!==void 0?a:""}<g transform="matrix(1 0 0 -1 0 100)">${(m=(M=f.ringOne)===null||M===void 0?void 0:M.value(f,l))!==null&&m!==void 0?m:""}</g><g transform="matrix(1 0 0 -1 0 100)">${(z=(O=f.ringTwo)===null||O===void 0?void 0:O.value(f,l))!==null&&z!==void 0?z:""}</g><g transform="matrix(1 0 0 -1 0 100)">${(n=(T=f.ringThree)===null||T===void 0?void 0:T.value(f,l))!==null&&n!==void 0?n:""}</g><g transform="matrix(1 0 0 -1 0 100)">${(k=(X=f.ringFour)===null||X===void 0?void 0:X.value(f,l))!==null&&k!==void 0?k:""}</g><g transform="matrix(1 0 0 -1 0 100)">${(E=(r=f.ringFive)===null||r===void 0?void 0:r.value(f,l))!==null&&E!==void 0?E:""}</g><circle cx="50" cy="50" r="45" stroke="#fff" stroke-opacity=".25" stroke-width="10" style="mix-blend-mode:lighten"/><circle cx="50" cy="50" r="25" stroke="#fff" stroke-opacity=".25" stroke-width="10" style="mix-blend-mode:lighten"/><circle cx="50" cy="50" r="10" fill="#fff" fill-opacity=".25" style="mix-blend-mode:lighten"/>`}};var yJ1={half:(f,l)=>`<path d="M90 50h10c0-27.614-22.386-50-50-50S0 22.386 0 50h10c0-22.091 17.909-40 40-40s40 17.909 40 40Z" fill="${q1.xml(`${l.ring}`)}"/>`,quarter:(f,l)=>`<path d="M50 10V0C22.386 0 0 22.386 0 50h10c0-22.091 17.909-40 40-40Z" fill="${q1.xml(`${l.ring}`)}"/>`,eighth:(f,l)=>`<path d="M21.716 21.716C14.477 28.954 10 38.954 10 50H0c0-13.807 5.596-26.307 14.645-35.355l7.07 7.07Z" fill="${q1.xml(`${l.ring}`)}"/>`,full:(f,l)=>`<circle cx="50" cy="50" r="45" stroke="${q1.xml(`${l.ring}`)}" stroke-width="10"/>`};var SJ1={eighth:(f,l)=>`<path d="M20 50c0-8.284 3.358-15.784 8.787-21.213l-7.071-7.071C14.477 28.954 10 38.954 10 50h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,quarter:(f,l)=>`<path d="M50 10c-22.091 0-40 17.909-40 40h10c0-16.569 13.431-30 30-30V10Z" fill="${q1.xml(`${l.ring}`)}"/>`,half:(f,l)=>`<path d="M90 50c0-22.091-17.909-40-40-40S10 27.909 10 50h10c0-16.569 13.431-30 30-30 16.569 0 30 13.431 30 30h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,full:(f,l)=>`<circle cx="50" cy="50" r="35" stroke="${q1.xml(`${l.ring}`)}" stroke-width="10"/>`};var RJ1={eighth:(f,l)=>`<path d="M30 50a19.937 19.937 0 0 1 5.858-14.142l-7.071-7.071C23.357 34.216 20 41.716 20 50h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,quarter:(f,l)=>`<path d="M50 20c-16.569 0-30 13.431-30 30h10c0-11.046 8.954-20 20-20V20Z" fill="${q1.xml(`${l.ring}`)}"/>`,half:(f,l)=>`<path d="M80 50c0-16.569-13.431-30-30-30-16.569 0-30 13.431-30 30h10c0-11.046 8.954-20 20-20s20 8.954 20 20h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,full:(f,l)=>`<circle cx="50" cy="50" r="25" stroke="${q1.xml(`${l.ring}`)}" stroke-width="10"/>`};var IJ1={eighth:(f,l)=>`<path d="M40 50a9.97 9.97 0 0 1 2.929-7.071l-7.071-7.071A19.937 19.937 0 0 0 30 50h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,quarter:(f,l)=>`<path d="M50 30c-11.046 0-20 8.954-20 20h10c0-5.523 4.477-10 10-10V30Z" fill="${q1.xml(`${l.ring}`)}"/>`,half:(f,l)=>`<path d="M70 50c0-11.046-8.954-20-20-20s-20 8.954-20 20h10c0-5.523 4.477-10 10-10s10 4.477 10 10h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,full:(f,l)=>`<circle cx="50" cy="50" r="15" stroke="${q1.xml(`${l.ring}`)}" stroke-width="10"/>`};var xJ1={eighth:(f,l)=>`<path d="m42.929 42.929 7.07 7.07H40a9.97 9.97 0 0 1 2.93-7.07Z" fill="${q1.xml(`${l.ring}`)}"/>`,quarter:(f,l)=>`<path d="M50 40v10H40c0-5.523 4.477-10 10-10Z" fill="${q1.xml(`${l.ring}`)}"/>`,half:(f,l)=>`<path d="M60 50c0-5.523-4.477-10-10-10s-10 4.477-10 10h20Z" fill="${q1.xml(`${l.ring}`)}"/>`,full:(f,l)=>`<circle cx="50" cy="50" r="10" fill="${q1.xml(`${l.ring}`)}"/>`};function Ll({prng:f,group:l,width:v,height:c,values:$=[],rotation:h,offsetX:Z,offsetY:w}){let q=bo,u=f.pick($),P=f.integer(Math.min(...h),Math.max(...h)),a=f.integer(Math.min(...Z),Math.max(...Z)),M=f.integer(Math.min(...w),Math.max(...w));if(u&&q[l][u])return{name:u,value(m,O){var z,T,n;let X=q[l][u](m,O);if(this.rotation||this.offsetX||this.offsetY)X=`<g transform="translate(${(z=this.offsetX)!==null&&z!==void 0?z:0}, ${(T=this.offsetY)!==null&&T!==void 0?T:0}) rotate(${(n=this.rotation)!==null&&n!==void 0?n:0} ${v/2} ${c/2})">${X}</g>`;return X},rotation:P,offsetX:a,offsetY:M};else return}function LJ1({prng:f,options:l}){var v,c,$,h,Z,w;let q=Ll({prng:f,group:"ring",values:l.ring,width:100,height:100,rotation:((v=l.ringRotation)===null||v===void 0?void 0:v.length)?l.ringRotation:[0],offsetX:[0],offsetY:[0]}),u=Ll({prng:f,group:"ringOne",values:l.ringOne,width:100,height:100,rotation:((c=l.ringOneRotation)===null||c===void 0?void 0:c.length)?l.ringOneRotation:[0],offsetX:[0],offsetY:[0]}),P=Ll({prng:f,group:"ringTwo",values:l.ringTwo,width:100,height:100,rotation:(($=l.ringTwoRotation)===null||$===void 0?void 0:$.length)?l.ringTwoRotation:[0],offsetX:[0],offsetY:[0]}),a=Ll({prng:f,group:"ringThree",values:l.ringThree,width:100,height:100,rotation:((h=l.ringThreeRotation)===null||h===void 0?void 0:h.length)?l.ringThreeRotation:[0],offsetX:[0],offsetY:[0]}),M=Ll({prng:f,group:"ringFour",values:l.ringFour,width:100,height:100,rotation:((Z=l.ringFourRotation)===null||Z===void 0?void 0:Z.length)?l.ringFourRotation:[0],offsetX:[0],offsetY:[0]}),m=Ll({prng:f,group:"ringFive",values:l.ringFive,width:100,height:100,rotation:((w=l.ringFiveRotation)===null||w===void 0?void 0:w.length)?l.ringFiveRotation:[0],offsetX:[0],offsetY:[0]});return{ring:q,ringOne:u,ringTwo:P,ringThree:a,ringFour:M,ringFive:m}}function tJ1(f){return f==="transparent"?f:`#${f}`}function eJ1({prng:f,options:l}){var v;return{ring:tJ1(f.pick((v=l.ringColor)!==null&&v!==void 0?v:[],"transparent"))}}var BJ1={$schema:"http://json-schema.org/draft-07/schema#",properties:{ring:{type:"array",items:{type:"string",enum:["container"]},default:["container"]},ringColor:{type:"array",items:{type:"string",pattern:"^(transparent|[a-fA-F0-9]{6})$"},default:["ffd54f","64b5f6","4dd0e1","ff8a65","9575cd","81c784","7986cb","4fc3f7","aed581","dce775","ffb74d","f06292","ba68c8","e57373","4db6ac","fff176"]},ringFive:{type:"array",items:{type:"string",enum:["eighth","quarter","half","full"]},default:["full"]},ringFiveRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]},ringFour:{type:"array",items:{type:"string",enum:["eighth","quarter","half","full"]},default:["quarter","half"]},ringFourRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]},ringOne:{type:"array",items:{type:"string",enum:["half","quarter","eighth","full"]},default:["half","quarter"]},ringOneRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]},ringRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]},ringThree:{type:"array",items:{type:"string",enum:["eighth","quarter","half","full"]},default:["quarter","half"]},ringThreeRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]},ringTwo:{type:"array",items:{type:"string",enum:["eighth","quarter","half","full"]},default:["quarter","half"]},ringTwoRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]}}};var pr2={title:"Rings",creator:"DiceBear",source:"https://www.dicebear.com",homepage:"https://www.dicebear.com",license:{name:"CC0 1.0",url:"https://creativecommons.org/publicdomain/zero/1.0/"}},Nr2=({prng:f,options:l})=>{var v,c;let $=LJ1({prng:f,options:l}),h=eJ1({prng:f,options:l});return{attributes:{viewBox:"0 0 100 100",fill:"none","shape-rendering":"crispEdges"},body:`${(c=(v=$.ring)===null||v===void 0?void 0:v.value($,h))!==null&&c!==void 0?c:""}`,extra:()=>({...Object.entries($).reduce((Z,[w,q])=>{return Z[w]=q===null||q===void 0?void 0:q.name,Z},{}),...Object.entries(h).reduce((Z,[w,q])=>{return Z[`${w}Color`]=q,Z},{})})}};var yo=m2(fp(),1);Kf();var QJ1=m2(fY(),1);import{cp as K4,exists as hO,glob as H6,mkdir as f9,rm as FJ1,writeFile as Ir2}from"fs/promises";import Ph from"os";import{join as k1,resolve as xr2}from"path";class So{directory;problem_nm;workspace;workDir;stagingDir;stagingDirLang="to-be-set";workDirLang="to-be-set";problem_id="to-be-set";languages=[];original_language="";problem_ymls={};handlers={};author="";author_email="";problem_type="std";constructor(f,l){if(this.directory=xr2(f),!this.directory.endsWith(".pbm"))throw Error(`Directory ${this.directory} is not a problem root directory (missing .pbm suffix)`);this.problem_nm=l,this.workspace=k1(f,c3()+"-stage",W0()),this.workDir=k1(this.workspace,"work.pbm"),this.stagingDir=k1(this.workspace,"stage",this.problem_nm)}async stage(){await W.section(`Staging problem at ${W.hyperlink(this.directory)}`,async()=>{await this.createWorkspace(),await this.separateByLanguages(),await this.readMetadata();for(let f of this.languages)await W.section(`Staging language ${f}`,async()=>{if(await this.setLanguage(f),this.problem_type==="std")await this.stageLanguage_Std(f);else if(this.problem_type==="game")await this.stageLanguage_Game(f);else if(this.problem_type==="quiz")await this.stageLanguage_Quizz(f)});await this.stageFirstToSolve(),await this.stageInformationYml(),await this.stageReadMd()}),await W.section("Summary",async()=>{let f=k1(this.stagingDir,"README.md");W.success("README.md content:"),await W.markdown(await r2(f)),W.success("Staging tree:"),W.print(QJ1.default(this.stagingDir))}),W.success(`Problem successfully staged at directory ${W.hyperlink(this.stagingDir)}`),await JJ1(this.stagingDir)}async stageLanguage_Std(f){await this.prepareStatements_Std(f),await this.computeCodeMetrics(f),await this.stageProblemFiles_Std(f),await this.stageAwards(f),await this.stageStatements(f),await this.stageZip_Std(f)}async stageLanguage_Game(f){await this.prepareStatements_Game(f),await this.computeCodeMetrics(f),await this.stageProblemFiles_Game(f),await this.stageAwards(f),await this.stageStatements(f),await this.stageZip_Game(f),await this.stageViewer(f)}async stageLanguage_Quizz(f){await this.stageQuiz(f)}async setLanguage(f){this.workDirLang=k1(this.workDir,f),this.problem_id=`${this.problem_nm}_${f}`,this.stagingDirLang=k1(this.stagingDir,f),await f9(this.stagingDirLang,{recursive:!0})}async createWorkspace(){await W.section(`Creating workspace ${this.workspace}`,async()=>{if(await hO(this.workspace))throw Error(`Workspace directory ${this.workspace} already exists`);await f9(this.workspace,{recursive:!0}),await f9(this.workDir,{recursive:!0}),await f9(this.stagingDir,{recursive:!0}),W.directory(this.workspace)})}doNotCopy(f,l){if(f==="problem.yml")return!0;if(f.startsWith(c3()))return!0;let v=f.match(/^problem\.([a-z][a-z])\.[a-z]*$/);if(v&&v[1]!==l)return!0;if(f===`problem.${l}.pdf`)return!0;return!1}async separateByLanguages(){await W.section("Detecting if there are language folders or not",async()=>{if((await Array.fromAsync(H6("handler.yml",{cwd:this.directory}))).length===0)await this.separateByLanguagesWithFolders();else await this.separateByLanguagesWithoutFolders()})}async separateByLanguagesWithoutFolders(){await W.section("Separating problem by languages without folders",async()=>{let l=(await Array.fromAsync(H6("problem.[a-z][a-z].yml",{cwd:this.directory}))).map((v)=>{let c=v.match(/^problem\.([a-z][a-z])\.yml$/);if(!c)throw Error(`Unexpected yml file name: ${v}`);return c[1]});this.languages=l;for(let v of l){let c=k1(this.workDir,v);await f9(c,{recursive:!0});let $=await Array.fromAsync(H6("*",{cwd:this.directory}));for(let h of $){if(this.doNotCopy(h,v))continue;await K4(k1(this.directory,h),k1(c,h),{recursive:!0})}}W.success(`Found languages: ${l.join(", ")}`)})}async separateByLanguagesWithFolders(){await W.section("Separating problem by languages with folders",async()=>{let f=await Array.fromAsync(H6("[a-z][a-z]",{cwd:this.directory}));this.languages=f;for(let l of f){let v=k1(this.directory,l),c=k1(this.workDir,l);await f9(c,{recursive:!0});let $=await Array.fromAsync(H6("*",{cwd:v}));for(let h of $){if(this.doNotCopy(h,l))continue;await K4(k1(v,h),k1(c,h),{recursive:!0})}}W.success(`Found languages: ${f.join(", ")}`)})}async readMetadata(){await W.section("Reading problem metadata",async()=>{for(let l of this.languages){let v=k1(this.workDir,l,`problem.${l}.yml`);this.problem_ymls[l]=await $6(v),AM.parse(this.problem_ymls[l])}for(let l of this.languages){let v=k1(this.workDir,l,"handler.yml");this.handlers[l]=await $6(v)}for(let l of this.languages){let v=this.problem_ymls[l];if(v.author)this.author=v.author;if(v.author)this.original_language=l;if(v.email)this.author_email=v.email}if(!this.original_language)throw Error("Original language not found in problem.<lang>.yml files");let{handler:f}=this.handlers[this.original_language];if(f==="game")this.problem_type="game";else if(f==="quiz")this.problem_type="quiz";else this.problem_type="std";W.success(`Problem type: ${this.problem_type}`),W.success(`Original language: ${this.original_language}`),W.success(`Author: ${this.author} <${this.author_email}>`)})}async findGoldenSolution(f){return await W.section("Finding golden solution",async()=>{let l=this.handlers[f].handler,v=this.handlers[f].compilers||"",c=this.handlers[f].solution,$;if(l==="circuits")$="solution.v";else if(v==="RunPython")$="solution.py";else if(v==="RunHaskell"||v==="GHC"||c==="Haskell")$="solution.hs";else if(v==="RunClojure"||v==="Clojure")$="solution.clj";else if(v==="PRO2"||v==="MakePRO2"){let h=await Array.fromAsync(H6("solution.{cc,hh,tar}",{cwd:this.directory}));if(h.length!==1)throw Error(`Expected exactly one PRO2/MakePRO2 solution file, but got ${h.join(", ")}`);$=h[0]}else{let h=this.handlers[f].solution||"C++";if(h==="C++"){let u=await Array.fromAsync(H6("solution.*",{cwd:this.directory}));if(W.print(u.join(", ")),u.length===1){let P=u[0].split(".").pop();h=Ro[P]}}let Z=Lr2[h];if(!Z)throw Error(`Unknown programming language ${h} for solution`);let w=k1(this.workDir,f,`solution.${Z}`);if(!await hO(w))throw Error(`Golden solution file ${w} not found`);$=`solution.${Z}`}return W.success(`Golden solution: ${$}`),$})}async prepareStatements_Std(f){await W.section("Preparing statements",async()=>{let l=k1(this.workDir,f);W.command(`jtk make pdf html md txt --problem_nm ${this.problem_nm}`),await R1({cwd:l,stdout:"inherit",stderr:"inherit",env:{JUTGE_INDENTATION_LEVEL:W.getIndentationLevelAsString()}})`jtk make pdf html md txt --problem_nm ${this.problem_nm}`,await FJ1(k1(l,"jtk-pdf"),{recursive:!0,force:!0}),await FJ1(k1(l,"jtk-text"),{recursive:!0,force:!0}),W.success("Generated statements")})}async prepareStatements_Game(f){await W.section("Preparing game statements",async()=>{let l=k1(this.workDirLang,"Doc");await W.section("Generating PDF with xelatex",async()=>{W.command("xelatex -no-shell-escape -interaction=nonstopmode -file-line-error main.tex"),await R1({cwd:l})`xelatex -no-shell-escape -interaction=nonstopmode -file-line-error main.tex`,await R1({cwd:l})`xelatex -no-shell-escape -interaction=nonstopmode -file-line-error main.tex`,await K4(k1(l,"main.pdf"),k1(this.workDirLang,`problem.${f}.pdf`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.pdf`)}`)}),await W.section("Generating TXT with pandoc",async()=>{W.command("pandoc --quiet main.tex --to plain --output main.txt"),await R1({cwd:l})`pandoc --quiet main.tex --to plain --output main.txt`,await K4(k1(l,"main.txt"),k1(this.workDirLang,`problem.${f}.txt`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.txt`)}`),await K4(k1(l,"main.txt"),k1(this.workDirLang,`problem.${f}.short.txt`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.short.txt`)}`)}),await W.section("Generating Markdown with pandoc",async()=>{W.command("pandoc --quiet main.tex --to markdown --to markdown-header_attributes --output main.md"),await R1({cwd:l})`pandoc --quiet main.tex --to markdown --to markdown-header_attributes --output main.md`,await K4(k1(l,"main.md"),k1(this.workDirLang,`problem.${f}.md`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.md`)}`),await K4(k1(l,"main.md"),k1(this.workDirLang,`problem.${f}.short.md`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.short.md`)}`)}),await W.section("Generating HTML with pandoc",async()=>{W.command("pandoc --quiet main.tex --to html --mathml --embed-resources --standalone --output main.html"),await R1({cwd:l})`pandoc --quiet main.tex --to html --mathml --embed-resources --standalone --output main.html`,await K4(k1(l,"main.html"),k1(this.workDirLang,`problem.${f}.html`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.html`)}`),await K4(k1(l,"main.html"),k1(this.workDirLang,`problem.${f}.short.html`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.short.html`)}`)})})}async computeCodeMetrics(f){if(!await Sv1()){W.warning("jutge-code-metrics not installed, skipping code metrics");return}if(this.problem_type!=="std"){await W.section("Skipping code metrics",async()=>{await o2(),W.warning("Code metrics not applicable for this problem type")});return}await W.section("Computing code metrics",async()=>{let l=await this.findGoldenSolution(f);W.command(`jutge-code-metrics ${l}`);try{let{stdout:v}=await R1({cwd:this.workDirLang})`jutge-code-metrics ${l}`;await w4(k1(this.stagingDirLang,"code-metrics.json"),v),W.success(`Generated ${W.hyperlink(this.stagingDirLang,"code-metrics.json")}`)}catch(v){W.warning("Failed to compute code metrics")}})}async stageProblemFiles_Std(f){let l=($)=>{if($==="handler.yml")return!0;for(let h of["inp","cor","ops"])if($.endsWith(`.${h}`))return!0;for(let h of UJ1){if($===`solution.${h}`)return!0;if($===`main.${h}`)return!0}if($==="scores.yml")return!0;if($==="checker.py")return!0;if($==="checker.cc")return!0;if($==="private.tar")return!0;if($==="public.tar")return!0;if($==="solution.tar")return!0;if($==="solution.cc")return!0;if($==="solution.hh")return!0;return!1},v=k1(this.stagingDirLang,"problem.pbm");await f9(v,{recursive:!0});let c=await Array.fromAsync(H6("*",{cwd:this.workDirLang}));for(let $ of c)if(l($))await K4(k1(this.workDirLang,$),k1(v,$));await K4(k1(this.workDirLang,`problem.${f}.yml`),k1(v,"problem.yml")),W.success(`Problem staged to ${W.hyperlink(this.stagingDirLang,"problem.pbm")}`)}async stageProblemFiles_Game(f){let l=(h)=>{if(h==="handler.yml")return!0;if(h==="Makefile")return!0;if(h==="README.txt")return!0;if(h==="README.md")return!0;if(h.endsWith(".cc"))return!0;if(h.endsWith(".hh"))return!0;if(h.endsWith(".cnf"))return!0;return!1},v=k1(this.workDirLang,"Runner"),c=k1(this.stagingDirLang,"problem.pbm");await f9(c,{recursive:!0});let $=await Array.fromAsync(H6("*",{cwd:v}));for(let h of $)if(l(h))await K4(k1(v,h),k1(c,h));await K4(k1(this.workDirLang,`problem.${f}.yml`),k1(c,"problem.yml")),W.success(`Problem staged to ${W.hyperlink(this.stagingDirLang,"problem.pbm")}`)}async stageAwards(f){await W.section("Staging awards",async()=>{let l=0;for(let v of["award.png","award.txt"])if(await P5(this.workDirLang,v))await K4(k1(this.workDirLang,v),k1(this.stagingDir,v)),l++;if(l>0)W.success(`Staged ${l} award file(s)`);else W.warning("No award files found")})}async stageStatements(f){await W.section("Staging statements",async()=>{let l=0;for(let v of["pdf","html","md","txt","yml","short.html","short.md","short.txt"]){let c=`problem.${f}.${v}`,$=`problem.${v}`;if(await P5(this.workDirLang,c))await K4(k1(this.workDirLang,c),k1(this.stagingDirLang,$)),l++}W.success(`Staged ${l} statement file(s)`)})}async stageFirstToSolve(){await W.section("Staging first-to-solve avatar",async()=>{let f=k1(this.stagingDir,"first-to-solve.svg"),v=oJ1($O,{seed:this.problem_nm}).toString();await w4(f,v),W.success(`Generated ${W.hyperlink(this.stagingDir,"first-to-solve.svg")}`)})}async stageZip_Std(f){let l=($)=>{for(let h of["pdf","html","md","txt"])if($===`problem.${f}.${h}`)return!0;for(let h of UJ1){if($===`main.${h}`)return!0;if($===`code.${h}`)return!0}if(($.includes("sample")||$.startsWith("public")||$.startsWith("hint")||$.startsWith("distilled"))&&($.endsWith(".inp")||$.endsWith(".cor")))return!0;if($==="sample.dt")return!0;return!1},v=[],c=await Array.fromAsync(H6("*",{cwd:this.workDirLang}));for(let $ of c)if(l($))v.push({sourcePath:k1(this.workDirLang,$),archivePath:k1(`${this.problem_id}`,$)});await ti(v,k1(this.stagingDirLang,"problem.zip")),W.success(`Created ${W.hyperlink(this.stagingDirLang,"problem.zip")} with ${v.length} files`)}async stageZip_Game(f){let l=this.handlers[this.original_language].game.hide||["AIDummy.cc"],v=($)=>{if($.endsWith(".cc")||$.endsWith(".hh"))return!l.includes($);if($.endsWith(".cnf"))return!0;if($=="Makefile")return!0;if($=="README.txt")return!0;if($=="README.md")return!0;return!1},c=[];for(let $ of["pdf","html","md","txt","short.html","short.md","short.txt"]){let h=`problem.${f}.${$}`;if(await P5(this.workDirLang,h))c.push({sourcePath:k1(this.workDirLang,h),archivePath:k1(`${this.problem_id}`,h)})}{let $=k1(this.workDirLang,"Runner"),h=await Array.fromAsync(H6("*",{cwd:$}));for(let Z of h)if(v(Z))c.push({sourcePath:k1($,Z),archivePath:k1(`${this.problem_id}`,"src",Z)})}{let $=k1(this.workDirLang,"Obj"),h=await Array.fromAsync(H6("*.o.*",{cwd:$}));for(let Z of h)c.push({sourcePath:k1($,Z),archivePath:k1(`${this.problem_id}`,"src",Z)})}{let $=k1(this.workDirLang,"Viewer"),h=await Array.fromAsync(H6("**/*",{cwd:$}));for(let Z of h)c.push({sourcePath:k1($,Z),archivePath:k1(`${this.problem_id}`,"src","Viewer",Z)})}await ti(c,k1(this.stagingDirLang,"problem.zip")),W.success(`Created ${W.hyperlink(this.stagingDirLang,"problem.zip")} with ${c.length} files`)}async stageViewer(f){await W.section("Staging viewer",async()=>{await K4(k1(this.workDirLang,"Viewer"),k1(this.stagingDirLang,"viewer"),{recursive:!0}),W.success(`Staged ${W.hyperlink(this.stagingDirLang,"viewer")}`)})}async stageQuiz(f){await W.section("Staging quiz",async()=>{let l=Mw.parse(await $6(k1(this.workDirLang,"quiz.yml"))),v=k1(this.stagingDirLang,"quiz.pbm");await f9(v,{recursive:!0}),await F9(k1(v,"quiz.yml"),l),await K4(k1(this.workDirLang,`problem.${f}.yml`),k1(v,"problem.yml")),await K4(k1(this.workDirLang,`problem.${f}.yml`),k1(v,"..","problem.yml"));for(let c of l.questions){{let $=k1(this.workDirLang,`${c.file}.yml`),h=k1(v,`${c.file}.yml`);if(await hO($))await K4($,h);else throw Error(`Quiz question file ${c.file}.yml not found`)}{let $=k1(this.workDirLang,`${c.file}.py`),h=k1(v,`${c.file}.py`);if(await hO($))await K4($,h)}}W.success(`Staged ${W.hyperlink(this.stagingDirLang,"quiz")}`)})}async stageInformationYml(){await W.section("Staging information.yml",async()=>{let f={problem_nm:this.problem_nm,languages:this.languages,original_language:this.original_language,author:this.author,author_email:this.author_email,problems:this.problem_ymls,handlers:this.handlers},l=k1(this.stagingDir,"information.yml");await F9(l,f),W.success(`Generated ${W.hyperlink(this.stagingDir,"information.yml")}`)})}async stageReadMd(){await W.section("Staging README.md",async()=>{let f=f5.version,l=this.languages.map((h)=>{let w=this.problem_ymls[h].title,q=`- *${h}*: ${w}
|
|
622
|
+
*/var $O={};r5($O,{schema:()=>BJ1,meta:()=>pr2,create:()=>Nr2});var bo={};r5(bo,{ringTwo:()=>SJ1,ringThree:()=>RJ1,ringOne:()=>yJ1,ringFour:()=>IJ1,ringFive:()=>xJ1,ring:()=>bJ1});var bJ1={container:(f,l)=>{var v,c,$,h,Z,w,q,u,P,a,M,m,O,z,T,n,X,k,r,E;return`${(c=(v=f.ringOne)===null||v===void 0?void 0:v.value(f,l))!==null&&c!==void 0?c:""}${(h=($=f.ringTwo)===null||$===void 0?void 0:$.value(f,l))!==null&&h!==void 0?h:""}${(w=(Z=f.ringThree)===null||Z===void 0?void 0:Z.value(f,l))!==null&&w!==void 0?w:""}${(u=(q=f.ringFour)===null||q===void 0?void 0:q.value(f,l))!==null&&u!==void 0?u:""}${(a=(P=f.ringFive)===null||P===void 0?void 0:P.value(f,l))!==null&&a!==void 0?a:""}<g transform="matrix(1 0 0 -1 0 100)">${(m=(M=f.ringOne)===null||M===void 0?void 0:M.value(f,l))!==null&&m!==void 0?m:""}</g><g transform="matrix(1 0 0 -1 0 100)">${(z=(O=f.ringTwo)===null||O===void 0?void 0:O.value(f,l))!==null&&z!==void 0?z:""}</g><g transform="matrix(1 0 0 -1 0 100)">${(n=(T=f.ringThree)===null||T===void 0?void 0:T.value(f,l))!==null&&n!==void 0?n:""}</g><g transform="matrix(1 0 0 -1 0 100)">${(k=(X=f.ringFour)===null||X===void 0?void 0:X.value(f,l))!==null&&k!==void 0?k:""}</g><g transform="matrix(1 0 0 -1 0 100)">${(E=(r=f.ringFive)===null||r===void 0?void 0:r.value(f,l))!==null&&E!==void 0?E:""}</g><circle cx="50" cy="50" r="45" stroke="#fff" stroke-opacity=".25" stroke-width="10" style="mix-blend-mode:lighten"/><circle cx="50" cy="50" r="25" stroke="#fff" stroke-opacity=".25" stroke-width="10" style="mix-blend-mode:lighten"/><circle cx="50" cy="50" r="10" fill="#fff" fill-opacity=".25" style="mix-blend-mode:lighten"/>`}};var yJ1={half:(f,l)=>`<path d="M90 50h10c0-27.614-22.386-50-50-50S0 22.386 0 50h10c0-22.091 17.909-40 40-40s40 17.909 40 40Z" fill="${q1.xml(`${l.ring}`)}"/>`,quarter:(f,l)=>`<path d="M50 10V0C22.386 0 0 22.386 0 50h10c0-22.091 17.909-40 40-40Z" fill="${q1.xml(`${l.ring}`)}"/>`,eighth:(f,l)=>`<path d="M21.716 21.716C14.477 28.954 10 38.954 10 50H0c0-13.807 5.596-26.307 14.645-35.355l7.07 7.07Z" fill="${q1.xml(`${l.ring}`)}"/>`,full:(f,l)=>`<circle cx="50" cy="50" r="45" stroke="${q1.xml(`${l.ring}`)}" stroke-width="10"/>`};var SJ1={eighth:(f,l)=>`<path d="M20 50c0-8.284 3.358-15.784 8.787-21.213l-7.071-7.071C14.477 28.954 10 38.954 10 50h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,quarter:(f,l)=>`<path d="M50 10c-22.091 0-40 17.909-40 40h10c0-16.569 13.431-30 30-30V10Z" fill="${q1.xml(`${l.ring}`)}"/>`,half:(f,l)=>`<path d="M90 50c0-22.091-17.909-40-40-40S10 27.909 10 50h10c0-16.569 13.431-30 30-30 16.569 0 30 13.431 30 30h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,full:(f,l)=>`<circle cx="50" cy="50" r="35" stroke="${q1.xml(`${l.ring}`)}" stroke-width="10"/>`};var RJ1={eighth:(f,l)=>`<path d="M30 50a19.937 19.937 0 0 1 5.858-14.142l-7.071-7.071C23.357 34.216 20 41.716 20 50h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,quarter:(f,l)=>`<path d="M50 20c-16.569 0-30 13.431-30 30h10c0-11.046 8.954-20 20-20V20Z" fill="${q1.xml(`${l.ring}`)}"/>`,half:(f,l)=>`<path d="M80 50c0-16.569-13.431-30-30-30-16.569 0-30 13.431-30 30h10c0-11.046 8.954-20 20-20s20 8.954 20 20h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,full:(f,l)=>`<circle cx="50" cy="50" r="25" stroke="${q1.xml(`${l.ring}`)}" stroke-width="10"/>`};var IJ1={eighth:(f,l)=>`<path d="M40 50a9.97 9.97 0 0 1 2.929-7.071l-7.071-7.071A19.937 19.937 0 0 0 30 50h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,quarter:(f,l)=>`<path d="M50 30c-11.046 0-20 8.954-20 20h10c0-5.523 4.477-10 10-10V30Z" fill="${q1.xml(`${l.ring}`)}"/>`,half:(f,l)=>`<path d="M70 50c0-11.046-8.954-20-20-20s-20 8.954-20 20h10c0-5.523 4.477-10 10-10s10 4.477 10 10h10Z" fill="${q1.xml(`${l.ring}`)}"/>`,full:(f,l)=>`<circle cx="50" cy="50" r="15" stroke="${q1.xml(`${l.ring}`)}" stroke-width="10"/>`};var xJ1={eighth:(f,l)=>`<path d="m42.929 42.929 7.07 7.07H40a9.97 9.97 0 0 1 2.93-7.07Z" fill="${q1.xml(`${l.ring}`)}"/>`,quarter:(f,l)=>`<path d="M50 40v10H40c0-5.523 4.477-10 10-10Z" fill="${q1.xml(`${l.ring}`)}"/>`,half:(f,l)=>`<path d="M60 50c0-5.523-4.477-10-10-10s-10 4.477-10 10h20Z" fill="${q1.xml(`${l.ring}`)}"/>`,full:(f,l)=>`<circle cx="50" cy="50" r="10" fill="${q1.xml(`${l.ring}`)}"/>`};function Ll({prng:f,group:l,width:v,height:c,values:$=[],rotation:h,offsetX:Z,offsetY:w}){let q=bo,u=f.pick($),P=f.integer(Math.min(...h),Math.max(...h)),a=f.integer(Math.min(...Z),Math.max(...Z)),M=f.integer(Math.min(...w),Math.max(...w));if(u&&q[l][u])return{name:u,value(m,O){var z,T,n;let X=q[l][u](m,O);if(this.rotation||this.offsetX||this.offsetY)X=`<g transform="translate(${(z=this.offsetX)!==null&&z!==void 0?z:0}, ${(T=this.offsetY)!==null&&T!==void 0?T:0}) rotate(${(n=this.rotation)!==null&&n!==void 0?n:0} ${v/2} ${c/2})">${X}</g>`;return X},rotation:P,offsetX:a,offsetY:M};else return}function LJ1({prng:f,options:l}){var v,c,$,h,Z,w;let q=Ll({prng:f,group:"ring",values:l.ring,width:100,height:100,rotation:((v=l.ringRotation)===null||v===void 0?void 0:v.length)?l.ringRotation:[0],offsetX:[0],offsetY:[0]}),u=Ll({prng:f,group:"ringOne",values:l.ringOne,width:100,height:100,rotation:((c=l.ringOneRotation)===null||c===void 0?void 0:c.length)?l.ringOneRotation:[0],offsetX:[0],offsetY:[0]}),P=Ll({prng:f,group:"ringTwo",values:l.ringTwo,width:100,height:100,rotation:(($=l.ringTwoRotation)===null||$===void 0?void 0:$.length)?l.ringTwoRotation:[0],offsetX:[0],offsetY:[0]}),a=Ll({prng:f,group:"ringThree",values:l.ringThree,width:100,height:100,rotation:((h=l.ringThreeRotation)===null||h===void 0?void 0:h.length)?l.ringThreeRotation:[0],offsetX:[0],offsetY:[0]}),M=Ll({prng:f,group:"ringFour",values:l.ringFour,width:100,height:100,rotation:((Z=l.ringFourRotation)===null||Z===void 0?void 0:Z.length)?l.ringFourRotation:[0],offsetX:[0],offsetY:[0]}),m=Ll({prng:f,group:"ringFive",values:l.ringFive,width:100,height:100,rotation:((w=l.ringFiveRotation)===null||w===void 0?void 0:w.length)?l.ringFiveRotation:[0],offsetX:[0],offsetY:[0]});return{ring:q,ringOne:u,ringTwo:P,ringThree:a,ringFour:M,ringFive:m}}function tJ1(f){return f==="transparent"?f:`#${f}`}function eJ1({prng:f,options:l}){var v;return{ring:tJ1(f.pick((v=l.ringColor)!==null&&v!==void 0?v:[],"transparent"))}}var BJ1={$schema:"http://json-schema.org/draft-07/schema#",properties:{ring:{type:"array",items:{type:"string",enum:["container"]},default:["container"]},ringColor:{type:"array",items:{type:"string",pattern:"^(transparent|[a-fA-F0-9]{6})$"},default:["ffd54f","64b5f6","4dd0e1","ff8a65","9575cd","81c784","7986cb","4fc3f7","aed581","dce775","ffb74d","f06292","ba68c8","e57373","4db6ac","fff176"]},ringFive:{type:"array",items:{type:"string",enum:["eighth","quarter","half","full"]},default:["full"]},ringFiveRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]},ringFour:{type:"array",items:{type:"string",enum:["eighth","quarter","half","full"]},default:["quarter","half"]},ringFourRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]},ringOne:{type:"array",items:{type:"string",enum:["half","quarter","eighth","full"]},default:["half","quarter"]},ringOneRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]},ringRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]},ringThree:{type:"array",items:{type:"string",enum:["eighth","quarter","half","full"]},default:["quarter","half"]},ringThreeRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]},ringTwo:{type:"array",items:{type:"string",enum:["eighth","quarter","half","full"]},default:["quarter","half"]},ringTwoRotation:{type:"array",items:{type:"integer",minimum:-180,maximum:180},maxItems:2,default:[-180,180]}}};var pr2={title:"Rings",creator:"DiceBear",source:"https://www.dicebear.com",homepage:"https://www.dicebear.com",license:{name:"CC0 1.0",url:"https://creativecommons.org/publicdomain/zero/1.0/"}},Nr2=({prng:f,options:l})=>{var v,c;let $=LJ1({prng:f,options:l}),h=eJ1({prng:f,options:l});return{attributes:{viewBox:"0 0 100 100",fill:"none","shape-rendering":"crispEdges"},body:`${(c=(v=$.ring)===null||v===void 0?void 0:v.value($,h))!==null&&c!==void 0?c:""}`,extra:()=>({...Object.entries($).reduce((Z,[w,q])=>{return Z[w]=q===null||q===void 0?void 0:q.name,Z},{}),...Object.entries(h).reduce((Z,[w,q])=>{return Z[`${w}Color`]=q,Z},{})})}};var yo=m2(fp(),1);Kf();var QJ1=m2(fY(),1);import{cp as K4,exists as hO,glob as H6,mkdir as f9,rm as FJ1,writeFile as Ir2}from"fs/promises";import Ph from"os";import{join as k1,resolve as xr2}from"path";class So{directory;problem_nm;workspace;workDir;stagingDir;stagingDirLang="to-be-set";workDirLang="to-be-set";problem_id="to-be-set";languages=[];original_language="";problem_ymls={};handlers={};author="";author_email="";problem_type="std";constructor(f,l){if(this.directory=xr2(f),!this.directory.endsWith(".pbm"))throw Error(`Directory ${this.directory} is not a problem root directory (missing .pbm suffix)`);this.problem_nm=l,this.workspace=k1(f,c3()+"-stage",W0()),this.workDir=k1(this.workspace,"work.pbm"),this.stagingDir=k1(this.workspace,"stage",this.problem_nm)}async stage(){await W.section(`Staging problem at ${W.hyperlink(this.directory)}`,async()=>{await this.createWorkspace(),await this.separateByLanguages(),await this.readMetadata();for(let f of this.languages)await W.section(`Staging language ${f}`,async()=>{if(await this.setLanguage(f),this.problem_type==="std")await this.stageLanguage_Std(f);else if(this.problem_type==="game")await this.stageLanguage_Game(f);else if(this.problem_type==="quiz")await this.stageLanguage_Quizz(f)});await this.stageFirstToSolve(),await this.stageInformationYml(),await this.stageReadMd()}),await W.section("Summary",async()=>{let f=k1(this.stagingDir,"README.md");W.success("README.md content:"),await W.markdown(await r2(f)),W.success("Staging tree:"),W.print(QJ1.default(this.stagingDir))}),W.success(`Problem successfully staged at directory ${W.hyperlink(this.stagingDir)}`),await JJ1(this.stagingDir)}async stageLanguage_Std(f){await this.prepareStatements_Std(f),await this.computeCodeMetrics(f),await this.stageProblemFiles_Std(f),await this.stageAwards(f),await this.stageStatements(f),await this.stageZip_Std(f)}async stageLanguage_Game(f){await this.prepareStatements_Game(f),await this.computeCodeMetrics(f),await this.stageProblemFiles_Game(f),await this.stageAwards(f),await this.stageStatements(f),await this.stageZip_Game(f),await this.stageViewer(f)}async stageLanguage_Quizz(f){await this.stageQuiz(f)}async setLanguage(f){this.workDirLang=k1(this.workDir,f),this.problem_id=`${this.problem_nm}_${f}`,this.stagingDirLang=k1(this.stagingDir,f),await f9(this.stagingDirLang,{recursive:!0})}async createWorkspace(){await W.section(`Creating workspace ${this.workspace}`,async()=>{if(await hO(this.workspace))throw Error(`Workspace directory ${this.workspace} already exists`);await f9(this.workspace,{recursive:!0}),await f9(this.workDir,{recursive:!0}),await f9(this.stagingDir,{recursive:!0}),W.directory(this.workspace)})}doNotCopy(f,l){if(f==="problem.yml")return!0;if(f.startsWith(c3()))return!0;let v=f.match(/^problem\.([a-z][a-z])\.[a-z]*$/);if(v&&v[1]!==l)return!0;if(f===`problem.${l}.pdf`)return!0;return!1}async separateByLanguages(){await W.section("Detecting if there are language folders or not",async()=>{if((await Array.fromAsync(H6("handler.yml",{cwd:this.directory}))).length===0)await this.separateByLanguagesWithFolders();else await this.separateByLanguagesWithoutFolders()})}async separateByLanguagesWithoutFolders(){await W.section("Separating problem by languages without folders",async()=>{let l=(await Array.fromAsync(H6("problem.[a-z][a-z].yml",{cwd:this.directory}))).map((v)=>{let c=v.match(/^problem\.([a-z][a-z])\.yml$/);if(!c)throw Error(`Unexpected yml file name: ${v}`);return c[1]});this.languages=l;for(let v of l){let c=k1(this.workDir,v);await f9(c,{recursive:!0});let $=await Array.fromAsync(H6("*",{cwd:this.directory}));for(let h of $){if(this.doNotCopy(h,v))continue;await K4(k1(this.directory,h),k1(c,h),{recursive:!0})}}W.success(`Found languages: ${l.join(", ")}`)})}async separateByLanguagesWithFolders(){await W.section("Separating problem by languages with folders",async()=>{let f=await Array.fromAsync(H6("[a-z][a-z]",{cwd:this.directory}));this.languages=f;for(let l of f){let v=k1(this.directory,l),c=k1(this.workDir,l);await f9(c,{recursive:!0});let $=await Array.fromAsync(H6("*",{cwd:v}));for(let h of $){if(this.doNotCopy(h,l))continue;await K4(k1(v,h),k1(c,h),{recursive:!0})}}W.success(`Found languages: ${f.join(", ")}`)})}async readMetadata(){await W.section("Reading problem metadata",async()=>{for(let l of this.languages){let v=k1(this.workDir,l,`problem.${l}.yml`);this.problem_ymls[l]=await $6(v),AM.parse(this.problem_ymls[l])}for(let l of this.languages){let v=k1(this.workDir,l,"handler.yml");this.handlers[l]=await $6(v)}for(let l of this.languages){let v=this.problem_ymls[l];if(v.author)this.author=v.author;if(v.author)this.original_language=l;if(v.email)this.author_email=v.email}if(!this.original_language)throw Error("Original language not found in problem.<lang>.yml files");let{handler:f}=this.handlers[this.original_language];if(f==="game")this.problem_type="game";else if(f==="quiz")this.problem_type="quiz";else this.problem_type="std";W.success(`Problem type: ${this.problem_type}`),W.success(`Original language: ${this.original_language}`),W.success(`Author: ${this.author} <${this.author_email}>`)})}async findGoldenSolution(f){return await W.section("Finding golden solution",async()=>{let l=this.handlers[f].handler,v=this.handlers[f].compilers||"",c=this.handlers[f].solution,$;if(l==="circuits")$="solution.v";else if(v==="RunPython")$="solution.py";else if(v==="RunHaskell"||v==="GHC"||c==="Haskell"||c==="GHC")$="solution.hs";else if(v==="RunClojure"||v==="Clojure")$="solution.clj";else if(v==="PRO2"||v==="MakePRO2"){let h=await Array.fromAsync(H6("solution.{cc,hh,tar}",{cwd:this.directory}));if(h.length!==1)throw Error(`Expected exactly one PRO2/MakePRO2 solution file, but got ${h.join(", ")}`);$=h[0]}else{let h=this.handlers[f].solution||"C++";if(h==="C++"){let u=await Array.fromAsync(H6("solution.*",{cwd:this.directory}));if(W.print(u.join(", ")),u.length===1){let P=u[0].split(".").pop();h=Ro[P]}}let Z=Lr2[h];if(!Z)throw Error(`Unknown programming language ${h} for solution`);let w=k1(this.workDir,f,`solution.${Z}`);if(!await hO(w))throw Error(`Golden solution file ${w} not found`);$=`solution.${Z}`}return W.success(`Golden solution: ${$}`),$})}async prepareStatements_Std(f){await W.section("Preparing statements",async()=>{let l=k1(this.workDir,f);W.command(`jtk make pdf html md txt --problem_nm ${this.problem_nm}`),await R1({cwd:l,stdout:"inherit",stderr:"inherit",env:{JUTGE_INDENTATION_LEVEL:W.getIndentationLevelAsString()}})`jtk make pdf html md txt --problem_nm ${this.problem_nm}`,await FJ1(k1(l,"jtk-pdf"),{recursive:!0,force:!0}),await FJ1(k1(l,"jtk-text"),{recursive:!0,force:!0}),W.success("Generated statements")})}async prepareStatements_Game(f){await W.section("Preparing game statements",async()=>{let l=k1(this.workDirLang,"Doc");await W.section("Generating PDF with xelatex",async()=>{W.command("xelatex -no-shell-escape -interaction=nonstopmode -file-line-error main.tex"),await R1({cwd:l})`xelatex -no-shell-escape -interaction=nonstopmode -file-line-error main.tex`,await R1({cwd:l})`xelatex -no-shell-escape -interaction=nonstopmode -file-line-error main.tex`,await K4(k1(l,"main.pdf"),k1(this.workDirLang,`problem.${f}.pdf`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.pdf`)}`)}),await W.section("Generating TXT with pandoc",async()=>{W.command("pandoc --quiet main.tex --to plain --output main.txt"),await R1({cwd:l})`pandoc --quiet main.tex --to plain --output main.txt`,await K4(k1(l,"main.txt"),k1(this.workDirLang,`problem.${f}.txt`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.txt`)}`),await K4(k1(l,"main.txt"),k1(this.workDirLang,`problem.${f}.short.txt`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.short.txt`)}`)}),await W.section("Generating Markdown with pandoc",async()=>{W.command("pandoc --quiet main.tex --to markdown --to markdown-header_attributes --output main.md"),await R1({cwd:l})`pandoc --quiet main.tex --to markdown --to markdown-header_attributes --output main.md`,await K4(k1(l,"main.md"),k1(this.workDirLang,`problem.${f}.md`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.md`)}`),await K4(k1(l,"main.md"),k1(this.workDirLang,`problem.${f}.short.md`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.short.md`)}`)}),await W.section("Generating HTML with pandoc",async()=>{W.command("pandoc --quiet main.tex --to html --mathml --embed-resources --standalone --output main.html"),await R1({cwd:l})`pandoc --quiet main.tex --to html --mathml --embed-resources --standalone --output main.html`,await K4(k1(l,"main.html"),k1(this.workDirLang,`problem.${f}.html`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.html`)}`),await K4(k1(l,"main.html"),k1(this.workDirLang,`problem.${f}.short.html`)),W.success(`Generated ${W.hyperlink(this.workDirLang,`problem.${f}.short.html`)}`)})})}async computeCodeMetrics(f){if(!await Sv1()){W.warning("jutge-code-metrics not installed, skipping code metrics");return}if(this.problem_type!=="std"){await W.section("Skipping code metrics",async()=>{await o2(),W.warning("Code metrics not applicable for this problem type")});return}await W.section("Computing code metrics",async()=>{let l=await this.findGoldenSolution(f);W.command(`jutge-code-metrics ${l}`);try{let{stdout:v}=await R1({cwd:this.workDirLang})`jutge-code-metrics ${l}`;await w4(k1(this.stagingDirLang,"code-metrics.json"),v),W.success(`Generated ${W.hyperlink(this.stagingDirLang,"code-metrics.json")}`)}catch(v){W.warning("Failed to compute code metrics")}})}async stageProblemFiles_Std(f){let l=($)=>{if($==="handler.yml")return!0;for(let h of["inp","cor","ops"])if($.endsWith(`.${h}`))return!0;for(let h of UJ1){if($===`solution.${h}`)return!0;if($===`main.${h}`)return!0}if($==="scores.yml")return!0;if($==="checker.py")return!0;if($==="checker.cc")return!0;if($==="private.tar")return!0;if($==="public.tar")return!0;if($==="solution.tar")return!0;if($==="solution.cc")return!0;if($==="solution.hh")return!0;return!1},v=k1(this.stagingDirLang,"problem.pbm");await f9(v,{recursive:!0});let c=await Array.fromAsync(H6("*",{cwd:this.workDirLang}));for(let $ of c)if(l($))await K4(k1(this.workDirLang,$),k1(v,$));await K4(k1(this.workDirLang,`problem.${f}.yml`),k1(v,"problem.yml")),W.success(`Problem staged to ${W.hyperlink(this.stagingDirLang,"problem.pbm")}`)}async stageProblemFiles_Game(f){let l=(h)=>{if(h==="handler.yml")return!0;if(h==="Makefile")return!0;if(h==="README.txt")return!0;if(h==="README.md")return!0;if(h.endsWith(".cc"))return!0;if(h.endsWith(".hh"))return!0;if(h.endsWith(".cnf"))return!0;return!1},v=k1(this.workDirLang,"Runner"),c=k1(this.stagingDirLang,"problem.pbm");await f9(c,{recursive:!0});let $=await Array.fromAsync(H6("*",{cwd:v}));for(let h of $)if(l(h))await K4(k1(v,h),k1(c,h));await K4(k1(this.workDirLang,`problem.${f}.yml`),k1(c,"problem.yml")),W.success(`Problem staged to ${W.hyperlink(this.stagingDirLang,"problem.pbm")}`)}async stageAwards(f){await W.section("Staging awards",async()=>{let l=0;for(let v of["award.png","award.txt"])if(await P5(this.workDirLang,v))await K4(k1(this.workDirLang,v),k1(this.stagingDir,v)),l++;if(l>0)W.success(`Staged ${l} award file(s)`);else W.warning("No award files found")})}async stageStatements(f){await W.section("Staging statements",async()=>{let l=0;for(let v of["pdf","html","md","txt","yml","short.html","short.md","short.txt"]){let c=`problem.${f}.${v}`,$=`problem.${v}`;if(await P5(this.workDirLang,c))await K4(k1(this.workDirLang,c),k1(this.stagingDirLang,$)),l++}W.success(`Staged ${l} statement file(s)`)})}async stageFirstToSolve(){await W.section("Staging first-to-solve avatar",async()=>{let f=k1(this.stagingDir,"first-to-solve.svg"),v=oJ1($O,{seed:this.problem_nm}).toString();await w4(f,v),W.success(`Generated ${W.hyperlink(this.stagingDir,"first-to-solve.svg")}`)})}async stageZip_Std(f){let l=($)=>{for(let h of["pdf","html","md","txt"])if($===`problem.${f}.${h}`)return!0;for(let h of UJ1){if($===`main.${h}`)return!0;if($===`code.${h}`)return!0}if(($.includes("sample")||$.startsWith("public")||$.startsWith("hint")||$.startsWith("distilled"))&&($.endsWith(".inp")||$.endsWith(".cor")))return!0;if($==="sample.dt")return!0;return!1},v=[],c=await Array.fromAsync(H6("*",{cwd:this.workDirLang}));for(let $ of c)if(l($))v.push({sourcePath:k1(this.workDirLang,$),archivePath:k1(`${this.problem_id}`,$)});await ti(v,k1(this.stagingDirLang,"problem.zip")),W.success(`Created ${W.hyperlink(this.stagingDirLang,"problem.zip")} with ${v.length} files`)}async stageZip_Game(f){let l=this.handlers[this.original_language].game.hide||["AIDummy.cc"],v=($)=>{if($.endsWith(".cc")||$.endsWith(".hh"))return!l.includes($);if($.endsWith(".cnf"))return!0;if($=="Makefile")return!0;if($=="README.txt")return!0;if($=="README.md")return!0;return!1},c=[];for(let $ of["pdf","html","md","txt","short.html","short.md","short.txt"]){let h=`problem.${f}.${$}`;if(await P5(this.workDirLang,h))c.push({sourcePath:k1(this.workDirLang,h),archivePath:k1(`${this.problem_id}`,h)})}{let $=k1(this.workDirLang,"Runner"),h=await Array.fromAsync(H6("*",{cwd:$}));for(let Z of h)if(v(Z))c.push({sourcePath:k1($,Z),archivePath:k1(`${this.problem_id}`,"src",Z)})}{let $=k1(this.workDirLang,"Obj"),h=await Array.fromAsync(H6("*.o.*",{cwd:$}));for(let Z of h)c.push({sourcePath:k1($,Z),archivePath:k1(`${this.problem_id}`,"src",Z)})}{let $=k1(this.workDirLang,"Viewer"),h=await Array.fromAsync(H6("**/*",{cwd:$}));for(let Z of h)c.push({sourcePath:k1($,Z),archivePath:k1(`${this.problem_id}`,"src","Viewer",Z)})}await ti(c,k1(this.stagingDirLang,"problem.zip")),W.success(`Created ${W.hyperlink(this.stagingDirLang,"problem.zip")} with ${c.length} files`)}async stageViewer(f){await W.section("Staging viewer",async()=>{await K4(k1(this.workDirLang,"Viewer"),k1(this.stagingDirLang,"viewer"),{recursive:!0}),W.success(`Staged ${W.hyperlink(this.stagingDirLang,"viewer")}`)})}async stageQuiz(f){await W.section("Staging quiz",async()=>{let l=Mw.parse(await $6(k1(this.workDirLang,"quiz.yml"))),v=k1(this.stagingDirLang,"quiz.pbm");await f9(v,{recursive:!0}),await F9(k1(v,"quiz.yml"),l),await K4(k1(this.workDirLang,`problem.${f}.yml`),k1(v,"problem.yml")),await K4(k1(this.workDirLang,`problem.${f}.yml`),k1(v,"..","problem.yml"));for(let c of l.questions){{let $=k1(this.workDirLang,`${c.file}.yml`),h=k1(v,`${c.file}.yml`);if(await hO($))await K4($,h);else throw Error(`Quiz question file ${c.file}.yml not found`)}{let $=k1(this.workDirLang,`${c.file}.py`),h=k1(v,`${c.file}.py`);if(await hO($))await K4($,h)}}W.success(`Staged ${W.hyperlink(this.stagingDirLang,"quiz")}`)})}async stageInformationYml(){await W.section("Staging information.yml",async()=>{let f={problem_nm:this.problem_nm,languages:this.languages,original_language:this.original_language,author:this.author,author_email:this.author_email,problems:this.problem_ymls,handlers:this.handlers},l=k1(this.stagingDir,"information.yml");await F9(l,f),W.success(`Generated ${W.hyperlink(this.stagingDir,"information.yml")}`)})}async stageReadMd(){await W.section("Staging README.md",async()=>{let f=f5.version,l=this.languages.map((h)=>{let w=this.problem_ymls[h].title,q=`- *${h}*: ${w}
|
|
623
623
|
`;if(h!==this.original_language)q+=` ${this.problem_ymls[h].translator} <${this.problem_ymls[h].translator_email}>`;else q="";return q}).join(`
|
|
624
624
|
`);if(l.trim())l=`## Translations
|
|
625
625
|
|