function ds = get_conditional_forecast_dseries(type, moment, varargin)
% function ds = get_conditional_forecast_dseries(type, moment, varargin)
% Returns conditional forecasts of variables identified by their name,
% for a given type (conditional or unconditional), and a given moment,
% as a dseries object.
%
% INPUTS:
%   type       [char/string] either 'cond' or 'uncond'
%   moment     [char/string] either 'Point', 'Mean', 'CI_inf', or 'CI_sup'
%   varargin   [cell array]  list of variable names
%
% OUTPUTS
%   ds         [dseries]     conditional forecasts

% Copyright © 2026 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare.  If not, see <https://www.gnu.org/licenses/>.

global M_ oo_

if isempty(oo_.conditional_forecast.initial_date)
    error('get_conditional_forecast_dseries: the initial date of the forecast could not be determined (the initial date is typically inferred from the smoother output or the histval information)')
end

if isempty(varargin)
    varargin = [ M_.endo_names; M_.exo_names ];
end

y0 = get_conditional_forecast(type, moment, varargin{:});
ds = dseries(y0, oo_.conditional_forecast.initial_date, varargin);
