local p = {}

function p.office3( statement , options) -- used by قالب:معلومات صاحب منصب/منصب ويكي بيانات
		local value = statement.mainsnak.datavalue.value
   		local entit = getEntityIdFromValue( value )
    	local s = formatSnak( statement.mainsnak, options ).value

		if s then
		        local entit = getEntityIdFromValue( value )
        		local ca1 = formatStatements( {property ='P154', entityId = entit
        			, noref ='true' ,rank='all'	,size ='35',image ='image', firstvalue='true',separator='',conjunction=''})
        		local ca2 = formatStatements( {property ='P41', entityId = entit
        			, noref ='true' ,rank='all'	,size ='35',image ='image', firstvalue='true',separator='',conjunction=''})
        		if ca1 and ca1 ~= '' then  caca  =  ca1  else  caca  = ca2 end

        		local asdf = formatEntityId( entit , options ).value
        			if asdf and asdf  ~= '' then
        		if caca and caca  ~= '' then  s =  caca .. ' '.. asdf   else  s = asdf   end
				end
		if statement.references then
			if options.reff and options.reff ~= ''  then
				reff  = formatReferences( statement, options )
				s = s..reff
			end 
		end
		if statement.qualifiers
			then
				if statement.qualifiers.P580 or statement.qualifiers.P582 or statement.qualifiers.P1365 or statement.qualifiers.P1366 then
					start	=	formatStatements({property = "P580", firstvalue= 'true',modifytime = 'longdate'}, statement.qualifiers) or ''
					finish	=	formatStatements({property = "P582", firstvalue= 'true',modifytime = 'longdate'}, statement.qualifiers) or ''
					before	=	formatStatements({property = "P1365", firstvalue= 'true'}, statement.qualifiers) or ''
					after	=	formatStatements({property = "P1366", firstvalue= 'true'}, statement.qualifiers) or ''
					constituency	=	formatStatements({property = "P768"}, statement.qualifiers) or ''
					series	=	formatStatements({property = "P1545", firstvalue= 'true'}, statement.qualifiers) or ''
					electedin	=	formatStatements({property = "P2715"}, statement.qualifiers) or ''
					P1001	=	formatStatements({property = "P1001"}, statement.qualifiers) or ''
					P108	=	formatStatements({property = "P108"}, statement.qualifiers) or ''
					P642 = formatStatements({property = "P642"}, statement.qualifiers) or ''
					president = formatStatements({property = "P325"}, statement.qualifiers) or ''
					premier= formatStatements({property = "P6"}, statement.qualifiers) or ''

P2937= formatStatements({property = "P2937", addTrackingCat='t'}, statement.qualifiers) or ''
			end
		end
		if options.office2 and options.office2 ~= '' then
							s = mw.getCurrentFrame():expandTemplate{ title = "معلومات صاحب منصب/منصب ويكي بيانات/نواة"	, 
				args = {
						  office 		= s
						, termstart 	= start
						, termend 		= finish
						, constituency 	= constituency
						, predecesso	= before
						, successor 	= after
						, president		= president
						, premier 		= premier
						, series		= series
						, electedin		= electedin
						, jurisdiction	= P1001
						, employer		= P108
						, of			= P642
						, P2937			= addTrackingCategory(P2937 ,{property='P2937',noicon='t'}) 
						, entityId		= options.entityId
						}
					} 
				end
	
	end
	 return s 
end

return p