JSFiddle - React, Tailwind, and code Playground

JavaScript

f=(
  _=c=>c.repeat(10),
  x=_('_'),
  z=a=>a.reverse().join(''),
  (n,d)=>{
    [p,q,g,r,s]=(d=="L")?["(",")","<",(a=>a.join('')),(y=>y)]:(d=="R")?[")","(",">",z,(y=>z(y.split('')))]:[];
    return ` ${x}\n${r([p,x,s("@%")])}\n${(r(["|",g,"*",q,"_____","><","||"]) + "\n").repeat(n)}${r(["'",_("="),"''"])}`
  }
)

console.log(f(3, "L"));
console.log(f(2, "R"));